[
  {
    "path": ".gitignore",
    "content": ".DS_Store\nMakefile\nCMakeCache.txt\nCMakeFiles\ncmake_install.cmake\nconfig.py\ncraft\nworld\nenv\nlog.txt\n*.o\n*.db\n*.exe\n*.dll\n*.pyc\n\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 2.8)\n\nproject(craft)\n\nFILE(GLOB SOURCE_FILES src/*.c)\n\nadd_executable(\n    craft\n    ${SOURCE_FILES}\n    deps/glew/src/glew.c\n    deps/lodepng/lodepng.c\n    deps/noise/noise.c\n    deps/sqlite/sqlite3.c\n    deps/tinycthread/tinycthread.c)\n\nadd_definitions(-std=c99 -O3)\n\nadd_subdirectory(deps/glfw)\ninclude_directories(deps/glew/include)\ninclude_directories(deps/glfw/include)\ninclude_directories(deps/lodepng)\ninclude_directories(deps/noise)\ninclude_directories(deps/sqlite)\ninclude_directories(deps/tinycthread)\n\nif(MINGW)\n    set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}\n        \"C:/Program Files/CURL/lib\" \"C:/Program Files (x86)/CURL/lib\")\n    set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}\n        \"C:/Program Files/CURL/include\" \"C:/Program Files (x86)/CURL/include\")\nendif()\n\nfind_package(CURL REQUIRED)\ninclude_directories(${CURL_INCLUDE_DIR})\n\nif(APPLE)\n    target_link_libraries(craft glfw\n        ${GLFW_LIBRARIES} ${CURL_LIBRARIES})\nendif()\n\nif(UNIX)\n    target_link_libraries(craft dl glfw\n        ${GLFW_LIBRARIES} ${CURL_LIBRARIES})\nendif()\n\nif(MINGW)\n    target_link_libraries(craft ws2_32.lib glfw\n        ${GLFW_LIBRARIES} ${CURL_LIBRARIES})\nendif()\n"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright (C) 2013 Michael Fogleman\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "## Craft\n\nMinecraft clone for Windows, Mac OS X and Linux. Just a few thousand lines of C using modern OpenGL (shaders). Online multiplayer support is included using a Python-based server.\n\nhttp://www.michaelfogleman.com/craft/\n\n![Screenshot](https://i.imgur.com/SH7wcas.png)\n\n### Features\n\n* Simple but nice looking terrain generation using perlin / simplex noise.\n* More than 10 types of blocks and more can be added easily.\n* Supports plants (grass, flowers, trees, etc.) and transparency (glass).\n* Simple clouds in the sky (they don't move).\n* Day / night cycles and a textured sky dome.\n* World changes persisted in a sqlite3 database.\n* Multiplayer support!\n\n### Download\n\nMac and Windows binaries are available on the website.\n\nhttp://www.michaelfogleman.com/craft/\n\nSee below to run from source.\n\n### Install Dependencies\n\n#### Mac OS X\n\nDownload and install [CMake](http://www.cmake.org/cmake/resources/software.html)\nif you don't already have it. You may use [Homebrew](http://brew.sh) to simplify\nthe installation:\n\n    brew install cmake\n\n#### Linux (Ubuntu)\n\n    sudo apt-get install cmake libglew-dev xorg-dev libcurl4-openssl-dev\n    sudo apt-get build-dep glfw\n\n#### Windows\n\nDownload and install [CMake](http://www.cmake.org/cmake/resources/software.html)\nand [MinGW](http://www.mingw.org/). Add `C:\\MinGW\\bin` to your `PATH`.\n\nDownload and install [cURL](http://curl.haxx.se/download.html) so that\nCURL/lib and CURL/include are in your Program Files directory.\n\nUse the following commands in place of the ones described in the next section.\n\n    cmake -G \"MinGW Makefiles\"\n    mingw32-make\n\n### Compile and Run\n\nOnce you have the dependencies (see above), run the following commands in your\nterminal.\n\n    git clone https://github.com/fogleman/Craft.git\n    cd Craft\n    cmake .\n    make\n    ./craft\n\n### Multiplayer\n\nAfter many years, craft.michaelfogleman.com has been taken down. See the [Server](#server) section for info on self-hosting.\n\n#### Client\n\nYou can connect to a server with command line arguments...\n\n```bash\n./craft [HOST [PORT]]\n```\n\nOr, with the \"/online\" command in the game itself.\n    \n    /online [HOST [PORT]]\n\n#### Server\n\nYou can run your own server or connect to mine. The server is written in Python\nbut requires a compiled DLL so it can perform the terrain generation just like\nthe client.\n\n```bash\ngcc -std=c99 -O3 -fPIC -shared -o world -I src -I deps/noise deps/noise/noise.c src/world.c\npython server.py [HOST [PORT]]\n```\n\n### Controls\n\n- WASD to move forward, left, backward, right.\n- Space to jump.\n- Left Click to destroy a block.\n- Right Click or Cmd + Left Click to create a block.\n- Ctrl + Right Click to toggle a block as a light source.\n- 1-9 to select the block type to create.\n- E to cycle through the block types.\n- Tab to toggle between walking and flying.\n- ZXCVBN to move in exact directions along the XYZ axes.\n- Left shift to zoom.\n- F to show the scene in orthographic mode.\n- O to observe players in the main view.\n- P to observe players in the picture-in-picture view.\n- T to type text into chat.\n- Forward slash (/) to enter a command.\n- Backquote (`) to write text on any block (signs).\n- Arrow keys emulate mouse movement.\n- Enter emulates mouse click.\n\n### Chat Commands\n\n    /goto [NAME]\n\nTeleport to another user.\nIf NAME is unspecified, a random user is chosen.\n\n    /list\n\nDisplay a list of connected users.\n\n    /login NAME\n\nSwitch to another registered username.\nThe login server will be re-contacted. The username is case-sensitive.\n\n    /logout\n\nUnauthenticate and become a guest user.\nAutomatic logins will not occur again until the /login command is re-issued.\n\n    /offline [FILE]\n\nSwitch to offline mode.\nFILE specifies the save file to use and defaults to \"craft\".\n\n    /online HOST [PORT]\n\nConnect to the specified server.\n\n    /pq P Q\n\nTeleport to the specified chunk.\n\n    /spawn\n\nTeleport back to the spawn point.\n\n### Screenshot\n\n![Screenshot](https://i.imgur.com/foYz3aN.png)\n\n### Implementation Details\n\n#### Terrain Generation\n\nThe terrain is generated using Simplex noise - a deterministic noise function seeded based on position. So the world will always be generated the same way in a given location.\n\nThe world is split up into 32x32 block chunks in the XZ plane (Y is up). This allows the world to be “infinite” (floating point precision is currently a problem at large X or Z values) and also makes it easier to manage the data. Only visible chunks need to be queried from the database.\n\n#### Rendering\n\nOnly exposed faces are rendered. This is an important optimization as the vast majority of blocks are either completely hidden or are only exposing one or two faces. Each chunk records a one-block width overlap for each neighboring chunk so it knows which blocks along its perimeter are exposed.\n\nOnly visible chunks are rendered. A naive frustum-culling approach is used to test if a chunk is in the camera’s view. If it is not, it is not rendered. This results in a pretty decent performance improvement as well.\n\nChunk buffers are completely regenerated when a block is changed in that chunk, instead of trying to update the VBO.\n\nText is rendered using a bitmap atlas. Each character is rendered onto two triangles forming a 2D rectangle.\n\n“Modern” OpenGL is used - no deprecated, fixed-function pipeline functions are used. Vertex buffer objects are used for position, normal and texture coordinates. Vertex and fragment shaders are used for rendering. Matrix manipulation functions are in matrix.c for translation, rotation, perspective, orthographic, etc. matrices. The 3D models are made up of very simple primitives - mostly cubes and rectangles. These models are generated in code in cube.c.\n\nTransparency in glass blocks and plants (plants don’t take up the full rectangular shape of their triangle primitives) is implemented by discarding magenta-colored pixels in the fragment shader.\n\n#### Database\n\nUser changes to the world are stored in a sqlite database. Only the delta is stored, so the default world is generated and then the user changes are applied on top when loading.\n\nThe main database table is named “block” and has columns p, q, x, y, z, w. (p, q) identifies the chunk, (x, y, z) identifies the block position and (w) identifies the block type. 0 represents an empty block (air).\n\nIn game, the chunks store their blocks in a hash map. An (x, y, z) key maps to a (w) value.\n\nThe y-position of blocks are limited to 0 <= y < 256. The upper limit is mainly an artificial limitation to prevent users from building unnecessarily tall structures. Users are not allowed to destroy blocks at y = 0 to avoid falling underneath the world.\n\n#### Multiplayer\n\nMultiplayer mode is implemented using plain-old sockets. A simple, ASCII, line-based protocol is used. Each line is made up of a command code and zero or more comma-separated arguments. The client requests chunks from the server with a simple command: C,p,q,key. “C” means “Chunk” and (p, q) identifies the chunk. The key is used for caching - the server will only send block updates that have been performed since the client last asked for that chunk. Block updates (in realtime or as part of a chunk request) are sent to the client in the format: B,p,q,x,y,z,w. After sending all of the blocks for a requested chunk, the server will send an updated cache key in the format: K,p,q,key. The client will store this key and use it the next time it needs to ask for that chunk. Player positions are sent in the format: P,pid,x,y,z,rx,ry. The pid is the player ID and the rx and ry values indicate the player’s rotation in two different axes. The client interpolates player positions from the past two position updates for smoother animation. The client sends its position to the server at most every 0.1 seconds (less if not moving).\n\nClient-side caching to the sqlite database can be performance intensive when connecting to a server for the first time. For this reason, sqlite writes are performed on a background thread. All writes occur in a transaction for performance. The transaction is committed every 5 seconds as opposed to some logical amount of work completed. A ring / circular buffer is used as a queue for what data is to be written to the database.\n\nIn multiplayer mode, players can observe one another in the main view or in a picture-in-picture view. Implementation of the PnP was surprisingly simple - just change the viewport and render the scene again from the other player’s point of view.\n\n#### Collision Testing\n\nHit testing (what block the user is pointing at) is implemented by scanning a ray from the player’s position outward, following their sight vector. This is not a precise method, so the step rate can be made smaller to be more accurate.\n\nCollision testing simply adjusts the player’s position to remain a certain distance away from any adjacent blocks that are obstacles. (Clouds and plants are not marked as obstacles, so you pass right through them.)\n\n#### Sky Dome\n\nA textured sky dome is used for the sky. The X-coordinate of the texture represents time of day. The Y-values map from the bottom of the sky sphere to the top of the sky sphere. The player is always in the center of the sphere. The fragment shaders for the blocks also sample the sky texture to determine the appropriate fog color to blend with based on the block’s position relative to the backing sky.\n\n#### Ambient Occlusion\n\nAmbient occlusion is implemented as described on this page:\n\nhttp://0fps.wordpress.com/2013/07/03/ambient-occlusion-for-minecraft-like-worlds/\n\n#### Dependencies\n\n* GLEW is used for managing OpenGL extensions across platforms.\n* GLFW is used for cross-platform window management.\n* CURL is used for HTTPS / SSL POST for the authentication process.\n* lodepng is used for loading PNG textures.\n* sqlite3 is used for saving the blocks added / removed by the user.\n* tinycthread is used for cross-platform threading.\n"
  },
  {
    "path": "builder.py",
    "content": "# This file allows you to programmatically create blocks in Craft.\n# Please use this wisely. Test on your own server first. Do not abuse it.\n\nimport requests\nimport socket\nimport sqlite3\nimport sys\n\nDEFAULT_HOST = '127.0.0.1'\nDEFAULT_PORT = 4080\n\nEMPTY = 0\nGRASS = 1\nSAND = 2\nSTONE = 3\nBRICK = 4\nWOOD = 5\nCEMENT = 6\nDIRT = 7\nPLANK = 8\nSNOW = 9\nGLASS = 10\nCOBBLE = 11\nLIGHT_STONE = 12\nDARK_STONE = 13\nCHEST = 14\nLEAVES = 15\nCLOUD = 16\nTALL_GRASS = 17\nYELLOW_FLOWER = 18\nRED_FLOWER = 19\nPURPLE_FLOWER = 20\nSUN_FLOWER = 21\nWHITE_FLOWER = 22\nBLUE_FLOWER = 23\n\nOFFSETS = [\n    (-0.5, -0.5, -0.5),\n    (-0.5, -0.5, 0.5),\n    (-0.5, 0.5, -0.5),\n    (-0.5, 0.5, 0.5),\n    (0.5, -0.5, -0.5),\n    (0.5, -0.5, 0.5),\n    (0.5, 0.5, -0.5),\n    (0.5, 0.5, 0.5),\n]\n\ndef sphere(cx, cy, cz, r, fill=False, fx=False, fy=False, fz=False):\n    result = set()\n    for x in range(cx - r, cx + r + 1):\n        if fx and x != cx:\n            continue\n        for y in range(cy - r, cy + r + 1):\n            # if y < cy:\n            #     continue # top hemisphere only\n            if fy and y != cy:\n                continue\n            for z in range(cz - r, cz + r + 1):\n                if fz and z != cz:\n                    continue\n                inside = False\n                outside = fill\n                for dx, dy, dz in OFFSETS:\n                    ox, oy, oz = x + dx, y + dy, z + dz\n                    d2 = (ox - cx) ** 2 + (oy - cy) ** 2 + (oz - cz) ** 2\n                    d = d2 ** 0.5\n                    if d < r:\n                        inside = True\n                    else:\n                        outside = True\n                if inside and outside:\n                    result.add((x, y, z))\n    return result\n\ndef circle_x(x, y, z, r, fill=False):\n    return sphere(x, y, z, r, fill, fx=True)\n\ndef circle_y(x, y, z, r, fill=False):\n    return sphere(x, y, z, r, fill, fy=True)\n\ndef circle_z(x, y, z, r, fill=False):\n    return sphere(x, y, z, r, fill, fz=True)\n\ndef cylinder_x(x1, x2, y, z, r, fill=False):\n    x1, x2 = sorted((x1, x2))\n    result = set()\n    for x in range(x1, x2 + 1):\n        result |= circle_x(x, y, z, r, fill)\n    return result\n\ndef cylinder_y(x, y1, y2, z, r, fill=False):\n    y1, y2 = sorted((y1, y2))\n    result = set()\n    for y in range(y1, y2 + 1):\n        result |= circle_y(x, y, z, r, fill)\n    return result\n\ndef cylinder_z(x, y, z1, z2, r, fill=False):\n    z1, z2 = sorted((z1, z2))\n    result = set()\n    for z in range(z1, z2 + 1):\n        result |= circle_z(x, y, z, r, fill)\n    return result\n\ndef cuboid(x1, x2, y1, y2, z1, z2, fill=True):\n    x1, x2 = sorted((x1, x2))\n    y1, y2 = sorted((y1, y2))\n    z1, z2 = sorted((z1, z2))\n    result = set()\n    a = (x1 == x2) + (y1 == y2) + (z1 == z2)\n    for x in range(x1, x2 + 1):\n        for y in range(y1, y2 + 1):\n            for z in range(z1, z2 + 1):\n                n = 0\n                n += x in (x1, x2)\n                n += y in (y1, y2)\n                n += z in (z1, z2)\n                if not fill and n <= a:\n                    continue\n                result.add((x, y, z))\n    return result\n\ndef pyramid(x1, x2, y, z1, z2, fill=False):\n    x1, x2 = sorted((x1, x2))\n    z1, z2 = sorted((z1, z2))\n    result = set()\n    while x2 >= x1 and z2 >= z2:\n        result |= cuboid(x1, x2, y, y, z1, z2, fill)\n        y, x1, x2, z1, z2 = y + 1, x1 + 1, x2 - 1, z1 + 1, z2 - 1\n    return result\n\ndef get_identity():\n    query = (\n        'select username, token from identity_token where selected = 1;'\n    )\n    conn = sqlite3.connect('auth.db')\n    rows = conn.execute(query)\n    for row in rows:\n        return row\n    raise Exception('No identities found.')\n\nclass Client(object):\n    def __init__(self, host, port):\n        self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        self.conn.connect((host, port))\n        self.authenticate()\n    def authenticate(self):\n        username, identity_token = get_identity()\n        url = 'https://craft.michaelfogleman.com/api/1/identity'\n        payload = {\n            'username': username,\n            'identity_token': identity_token,\n        }\n        response = requests.post(url, data=payload)\n        if response.status_code == 200 and response.text.isalnum():\n            access_token = response.text\n            self.conn.sendall('A,%s,%s\\n' % (username, access_token))\n        else:\n            raise Exception('Failed to authenticate.')\n    def set_block(self, x, y, z, w):\n        self.conn.sendall('B,%d,%d,%d,%d\\n' % (x, y, z, w))\n    def set_blocks(self, blocks, w):\n        key = lambda block: (block[1], block[0], block[2])\n        for x, y, z in sorted(blocks, key=key):\n            self.set_block(x, y, z, w)\n    def bitmap(self, sx, sy, sz, d1, d2, data, lookup):\n        x, y, z = sx, sy, sz\n        dx1, dy1, dz1 = d1\n        dx2, dy2, dz2 = d2\n        for row in data:\n            x = sx if dx1 else x\n            y = sy if dy1 else y\n            z = sz if dz1 else z\n            for c in row:\n                w = lookup.get(c)\n                if w is not None:\n                    self.set_block(x, y, z, w)\n                x, y, z = x + dx1, y + dy1, z + dz1\n            x, y, z = x + dx2, y + dy2, z + dz2\n\ndef get_client():\n    default_args = [DEFAULT_HOST, DEFAULT_PORT]\n    args = sys.argv[1:] + [None] * len(default_args)\n    host, port = [a or b for a, b in zip(args, default_args)]\n    client = Client(host, int(port))\n    return client\n\ndef main():\n    client = get_client()\n    set_block = client.set_block\n    set_blocks = client.set_blocks\n    # set_blocks(circle_y(0, 32, 0, 16, True), STONE)\n    # set_blocks(circle_y(0, 33, 0, 16), BRICK)\n    # set_blocks(cuboid(-1, 1, 1, 31, -1, 1), CEMENT)\n    # set_blocks(cuboid(-1024, 1024, 32, 32, -3, 3), STONE)\n    # set_blocks(cuboid(-3, 3, 32, 32, -1024, 1024), STONE)\n    # set_blocks(cuboid(-1024, 1024, 33, 33, -3, -3), BRICK)\n    # set_blocks(cuboid(-1024, 1024, 33, 33, 3, 3), BRICK)\n    # set_blocks(cuboid(-3, -3, 33, 33, -1024, 1024), BRICK)\n    # set_blocks(cuboid(3, 3, 33, 33, -1024, 1024), BRICK)\n    # set_blocks(sphere(0, 32, 0, 16), GLASS)\n    # for y in range(1, 32):\n    #     set_blocks(circle_y(0, y, 0, 4, True), CEMENT)\n    # set_blocks(circle_x(16, 33, 0, 3), BRICK)\n    # set_blocks(circle_x(-16, 33, 0, 3), BRICK)\n    # set_blocks(circle_z(0, 33, 16, 3), BRICK)\n    # set_blocks(circle_z(0, 33, -16, 3), BRICK)\n    # for x in range(0, 1024, 32):\n    #     set_blocks(cuboid(x - 1, x + 1, 31, 32, -1, 1), CEMENT)\n    #     set_blocks(cuboid(-x - 1, -x + 1, 31, 32, -1, 1), CEMENT)\n    #     set_blocks(cuboid(x, x, 1, 32, -1, 1), CEMENT)\n    #     set_blocks(cuboid(-x, -x, 1, 32, -1, 1), CEMENT)\n    # for z in range(0, 1024, 32):\n    #     set_blocks(cuboid(-1, 1, 31, 32, z - 1, z + 1), CEMENT)\n    #     set_blocks(cuboid(-1, 1, 31, 32, -z - 1, -z + 1), CEMENT)\n    #     set_blocks(cuboid(-1, 1, 1, 32, z, z), CEMENT)\n    #     set_blocks(cuboid(-1, 1, 1, 32, -z, -z), CEMENT)\n    # for x in range(0, 1024, 8):\n    #     set_block(x, 32, 0, CEMENT)\n    #     set_block(-x, 32, 0, CEMENT)\n    # for z in range(0, 1024, 8):\n    #     set_block(0, 32, z, CEMENT)\n    #     set_block(0, 32, -z, CEMENT)\n    # set_blocks(pyramid(32, 32+64-1, 12, 32, 32+64-1), COBBLE)\n    # outer = circle_y(0, 11, 0, 176 + 3, True)\n    # inner = circle_y(0, 11, 0, 176 - 3, True)\n    # set_blocks(outer - inner, STONE)\n    # a = sphere(-32, 48, -32, 24, True)\n    # b = sphere(-24, 40, -24, 24, True)\n    # set_blocks(a - b, PLANK)\n    # set_blocks(cylinder_x(-64, 64, 32, 0, 8), STONE)\n    # data = [\n    #     '...............................',\n    #     '..xxx..xxxx...xxx..xxxxx.xxxxx.',\n    #     '.x...x.x...x.x...x.x.......x...',\n    #     '.x.....xxxx..xxxxx.xxx.....x...',\n    #     '.x...x.x..x..x...x.x.......x...',\n    #     '..xxx..x...x.x...x.x.......x...',\n    #     '...............................',\n    # ]\n    # lookup = {\n    #     'x': STONE,\n    #     '.': PLANK,\n    # }\n    # client.bitmap(0, 32, 32, (1, 0, 0), (0, -1, 0), data, lookup)\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "deps/glew/LICENSE.txt",
    "content": "The OpenGL Extension Wrangler Library\nCopyright (C) 2002-2007, Milan Ikits <milan ikits[]ieee org>\nCopyright (C) 2002-2007, Marcelo E. Magallon <mmagallo[]debian org>\nCopyright (C) 2002, Lev Povalahev\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without \nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, \n  this list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice, \n  this list of conditions and the following disclaimer in the documentation \n  and/or other materials provided with the distribution.\n* The name of the author may be used to endorse or promote products \n  derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\nTHE POSSIBILITY OF SUCH DAMAGE.\n\n\nMesa 3-D graphics library\nVersion:  7.0\n\nCopyright (C) 1999-2007  Brian Paul   All Rights Reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\nBRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\nCopyright (c) 2007 The Khronos Group Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and/or associated documentation files (the\n\"Materials\"), to deal in the Materials without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Materials, and to\npermit persons to whom the Materials are furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Materials.\n\nTHE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nMATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n"
  },
  {
    "path": "deps/glew/include/GL/glew.h",
    "content": "/*\n** The OpenGL Extension Wrangler Library\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\n** Copyright (C) 2002, Lev Povalahev\n** All rights reserved.\n**\n** Redistribution and use in source and binary forms, with or without\n** modification, are permitted provided that the following conditions are met:\n**\n** * Redistributions of source code must retain the above copyright notice,\n**   this list of conditions and the following disclaimer.\n** * Redistributions in binary form must reproduce the above copyright notice,\n**   this list of conditions and the following disclaimer in the documentation\n**   and/or other materials provided with the distribution.\n** * The name of the author may be used to endorse or promote products\n**   derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n** THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * Mesa 3-D graphics library\n * Version:  7.0\n *\n * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\n * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/*\n** Copyright (c) 2007 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#ifndef __glew_h__\n#define __glew_h__\n#define __GLEW_H__\n\n#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)\n#error gl.h included before glew.h\n#endif\n#if defined(__REGAL_H__)\n#error Regal.h included before glew.h\n#endif\n#if defined(__glext_h_) || defined(__GLEXT_H_)\n#error glext.h included before glew.h\n#endif\n#if defined(__gl_ATI_h_)\n#error glATI.h included before glew.h\n#endif\n\n#define __gl_h_\n#define __GL_H__\n#define __REGAL_H__\n#define __X_GL_H\n#define __glext_h_\n#define __GLEXT_H_\n#define __gl_ATI_h_\n\n#if defined(_WIN32)\n\n/*\n * GLEW does not include <windows.h> to avoid name space pollution.\n * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t\n * defined properly.\n */\n/* <windef.h> */\n#ifndef APIENTRY\n#define GLEW_APIENTRY_DEFINED\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\n#    define APIENTRY __stdcall\n#  elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)\n#    define APIENTRY __stdcall\n#  else\n#    define APIENTRY\n#  endif\n#endif\n#ifndef GLAPI\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\n#    define GLAPI extern\n#  endif\n#endif\n/* <winnt.h> */\n#ifndef CALLBACK\n#define GLEW_CALLBACK_DEFINED\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\n#    define CALLBACK __attribute__ ((__stdcall__))\n#  elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)\n#    define CALLBACK __stdcall\n#  else\n#    define CALLBACK\n#  endif\n#endif\n/* <wingdi.h> and <winnt.h> */\n#ifndef WINGDIAPI\n#define GLEW_WINGDIAPI_DEFINED\n#define WINGDIAPI __declspec(dllimport)\n#endif\n/* <ctype.h> */\n#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED)\ntypedef unsigned short wchar_t;\n#  define _WCHAR_T_DEFINED\n#endif\n/* <stddef.h> */\n#if !defined(_W64)\n#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300\n#    define _W64 __w64\n#  else\n#    define _W64\n#  endif\n#endif\n#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) && !defined(__MINGW64__)\n#  ifdef _WIN64\ntypedef __int64 ptrdiff_t;\n#  else\ntypedef _W64 int ptrdiff_t;\n#  endif\n#  define _PTRDIFF_T_DEFINED\n#  define _PTRDIFF_T_\n#endif\n\n#ifndef GLAPI\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\n#    define GLAPI extern\n#  else\n#    define GLAPI WINGDIAPI\n#  endif\n#endif\n\n#ifndef GLAPIENTRY\n#define GLAPIENTRY APIENTRY\n#endif\n\n#ifndef GLEWAPIENTRY\n#define GLEWAPIENTRY APIENTRY\n#endif\n\n/*\n * GLEW_STATIC is defined for static library.\n * GLEW_BUILD  is defined for building the DLL library.\n */\n\n/* @rlyeh { */\n#ifndef GLEW_STATIC\n#  define GLEW_STATIC\n#endif\n/* } @rlyeh */\n\n#ifdef GLEW_STATIC\n#  define GLEWAPI extern\n#else\n#  ifdef GLEW_BUILD\n#    define GLEWAPI extern __declspec(dllexport)\n#  else\n#    define GLEWAPI extern __declspec(dllimport)\n#  endif\n#endif\n\n#else /* _UNIX */\n\n/*\n * Needed for ptrdiff_t in turn needed by VBO.  This is defined by ISO\n * C.  On my system, this amounts to _3 lines_ of included code, all of\n * them pretty much harmless.  If you know of a way of detecting 32 vs\n * 64 _targets_ at compile time you are free to replace this with\n * something that's portable.  For now, _this_ is the portable solution.\n * (mem, 2004-01-04)\n */\n\n#include <stddef.h>\n\n/* SGI MIPSPro doesn't like stdint.h in C++ mode          */\n/* ID: 3376260 Solaris 9 has inttypes.h, but not stdint.h */\n\n#if (defined(__sgi) || defined(__sun)) && !defined(__GNUC__)\n#include <inttypes.h>\n#else\n#include <stdint.h>\n#endif\n\n#define GLEW_APIENTRY_DEFINED\n#define APIENTRY\n\n/*\n * GLEW_STATIC is defined for static library.\n */\n\n#ifdef GLEW_STATIC\n#  define GLEWAPI extern\n#else\n#  if defined(__GNUC__) && __GNUC__>=4\n#   define GLEWAPI extern __attribute__ ((visibility(\"default\")))\n#  elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)\n#   define GLEWAPI extern __global\n#  else\n#   define GLEWAPI extern\n#  endif\n#endif\n\n/* <glu.h> */\n#ifndef GLAPI\n#define GLAPI extern\n#endif\n\n#ifndef GLAPIENTRY\n#define GLAPIENTRY\n#endif\n\n#ifndef GLEWAPIENTRY\n#define GLEWAPIENTRY\n#endif\n\n#endif /* _WIN32 */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* ----------------------------- GL_VERSION_1_1 ---------------------------- */\n\n#ifndef GL_VERSION_1_1\n#define GL_VERSION_1_1 1\n\ntypedef unsigned int GLenum;\ntypedef unsigned int GLbitfield;\ntypedef unsigned int GLuint;\ntypedef int GLint;\ntypedef int GLsizei;\ntypedef unsigned char GLboolean;\ntypedef signed char GLbyte;\ntypedef short GLshort;\ntypedef unsigned char GLubyte;\ntypedef unsigned short GLushort;\ntypedef unsigned long GLulong;\ntypedef float GLfloat;\ntypedef float GLclampf;\ntypedef double GLdouble;\ntypedef double GLclampd;\ntypedef void GLvoid;\n#if defined(_MSC_VER) && _MSC_VER < 1400\ntypedef __int64 GLint64EXT;\ntypedef unsigned __int64 GLuint64EXT;\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef signed long long GLint64EXT;\ntypedef unsigned long long GLuint64EXT;\n#else\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\n#include <inttypes.h>\n#  endif\ntypedef int64_t GLint64EXT;\ntypedef uint64_t GLuint64EXT;\n#endif\ntypedef GLint64EXT  GLint64;\ntypedef GLuint64EXT GLuint64;\ntypedef struct __GLsync *GLsync;\n\ntypedef char GLchar;\n\n#define GL_ZERO 0\n#define GL_FALSE 0\n#define GL_LOGIC_OP 0x0BF1\n#define GL_NONE 0\n#define GL_TEXTURE_COMPONENTS 0x1003\n#define GL_NO_ERROR 0\n#define GL_POINTS 0x0000\n#define GL_CURRENT_BIT 0x00000001\n#define GL_TRUE 1\n#define GL_ONE 1\n#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001\n#define GL_LINES 0x0001\n#define GL_LINE_LOOP 0x0002\n#define GL_POINT_BIT 0x00000002\n#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002\n#define GL_LINE_STRIP 0x0003\n#define GL_LINE_BIT 0x00000004\n#define GL_TRIANGLES 0x0004\n#define GL_TRIANGLE_STRIP 0x0005\n#define GL_TRIANGLE_FAN 0x0006\n#define GL_QUADS 0x0007\n#define GL_QUAD_STRIP 0x0008\n#define GL_POLYGON_BIT 0x00000008\n#define GL_POLYGON 0x0009\n#define GL_POLYGON_STIPPLE_BIT 0x00000010\n#define GL_PIXEL_MODE_BIT 0x00000020\n#define GL_LIGHTING_BIT 0x00000040\n#define GL_FOG_BIT 0x00000080\n#define GL_DEPTH_BUFFER_BIT 0x00000100\n#define GL_ACCUM 0x0100\n#define GL_LOAD 0x0101\n#define GL_RETURN 0x0102\n#define GL_MULT 0x0103\n#define GL_ADD 0x0104\n#define GL_NEVER 0x0200\n#define GL_ACCUM_BUFFER_BIT 0x00000200\n#define GL_LESS 0x0201\n#define GL_EQUAL 0x0202\n#define GL_LEQUAL 0x0203\n#define GL_GREATER 0x0204\n#define GL_NOTEQUAL 0x0205\n#define GL_GEQUAL 0x0206\n#define GL_ALWAYS 0x0207\n#define GL_SRC_COLOR 0x0300\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\n#define GL_SRC_ALPHA 0x0302\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\n#define GL_DST_ALPHA 0x0304\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\n#define GL_DST_COLOR 0x0306\n#define GL_ONE_MINUS_DST_COLOR 0x0307\n#define GL_SRC_ALPHA_SATURATE 0x0308\n#define GL_STENCIL_BUFFER_BIT 0x00000400\n#define GL_FRONT_LEFT 0x0400\n#define GL_FRONT_RIGHT 0x0401\n#define GL_BACK_LEFT 0x0402\n#define GL_BACK_RIGHT 0x0403\n#define GL_FRONT 0x0404\n#define GL_BACK 0x0405\n#define GL_LEFT 0x0406\n#define GL_RIGHT 0x0407\n#define GL_FRONT_AND_BACK 0x0408\n#define GL_AUX0 0x0409\n#define GL_AUX1 0x040A\n#define GL_AUX2 0x040B\n#define GL_AUX3 0x040C\n#define GL_INVALID_ENUM 0x0500\n#define GL_INVALID_VALUE 0x0501\n#define GL_INVALID_OPERATION 0x0502\n#define GL_STACK_OVERFLOW 0x0503\n#define GL_STACK_UNDERFLOW 0x0504\n#define GL_OUT_OF_MEMORY 0x0505\n#define GL_2D 0x0600\n#define GL_3D 0x0601\n#define GL_3D_COLOR 0x0602\n#define GL_3D_COLOR_TEXTURE 0x0603\n#define GL_4D_COLOR_TEXTURE 0x0604\n#define GL_PASS_THROUGH_TOKEN 0x0700\n#define GL_POINT_TOKEN 0x0701\n#define GL_LINE_TOKEN 0x0702\n#define GL_POLYGON_TOKEN 0x0703\n#define GL_BITMAP_TOKEN 0x0704\n#define GL_DRAW_PIXEL_TOKEN 0x0705\n#define GL_COPY_PIXEL_TOKEN 0x0706\n#define GL_LINE_RESET_TOKEN 0x0707\n#define GL_EXP 0x0800\n#define GL_VIEWPORT_BIT 0x00000800\n#define GL_EXP2 0x0801\n#define GL_CW 0x0900\n#define GL_CCW 0x0901\n#define GL_COEFF 0x0A00\n#define GL_ORDER 0x0A01\n#define GL_DOMAIN 0x0A02\n#define GL_CURRENT_COLOR 0x0B00\n#define GL_CURRENT_INDEX 0x0B01\n#define GL_CURRENT_NORMAL 0x0B02\n#define GL_CURRENT_TEXTURE_COORDS 0x0B03\n#define GL_CURRENT_RASTER_COLOR 0x0B04\n#define GL_CURRENT_RASTER_INDEX 0x0B05\n#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06\n#define GL_CURRENT_RASTER_POSITION 0x0B07\n#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08\n#define GL_CURRENT_RASTER_DISTANCE 0x0B09\n#define GL_POINT_SMOOTH 0x0B10\n#define GL_POINT_SIZE 0x0B11\n#define GL_POINT_SIZE_RANGE 0x0B12\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_LINE_SMOOTH 0x0B20\n#define GL_LINE_WIDTH 0x0B21\n#define GL_LINE_WIDTH_RANGE 0x0B22\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_LINE_STIPPLE 0x0B24\n#define GL_LINE_STIPPLE_PATTERN 0x0B25\n#define GL_LINE_STIPPLE_REPEAT 0x0B26\n#define GL_LIST_MODE 0x0B30\n#define GL_MAX_LIST_NESTING 0x0B31\n#define GL_LIST_BASE 0x0B32\n#define GL_LIST_INDEX 0x0B33\n#define GL_POLYGON_MODE 0x0B40\n#define GL_POLYGON_SMOOTH 0x0B41\n#define GL_POLYGON_STIPPLE 0x0B42\n#define GL_EDGE_FLAG 0x0B43\n#define GL_CULL_FACE 0x0B44\n#define GL_CULL_FACE_MODE 0x0B45\n#define GL_FRONT_FACE 0x0B46\n#define GL_LIGHTING 0x0B50\n#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51\n#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52\n#define GL_LIGHT_MODEL_AMBIENT 0x0B53\n#define GL_SHADE_MODEL 0x0B54\n#define GL_COLOR_MATERIAL_FACE 0x0B55\n#define GL_COLOR_MATERIAL_PARAMETER 0x0B56\n#define GL_COLOR_MATERIAL 0x0B57\n#define GL_FOG 0x0B60\n#define GL_FOG_INDEX 0x0B61\n#define GL_FOG_DENSITY 0x0B62\n#define GL_FOG_START 0x0B63\n#define GL_FOG_END 0x0B64\n#define GL_FOG_MODE 0x0B65\n#define GL_FOG_COLOR 0x0B66\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_DEPTH_TEST 0x0B71\n#define GL_DEPTH_WRITEMASK 0x0B72\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\n#define GL_DEPTH_FUNC 0x0B74\n#define GL_ACCUM_CLEAR_VALUE 0x0B80\n#define GL_STENCIL_TEST 0x0B90\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\n#define GL_STENCIL_FUNC 0x0B92\n#define GL_STENCIL_VALUE_MASK 0x0B93\n#define GL_STENCIL_FAIL 0x0B94\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\n#define GL_STENCIL_REF 0x0B97\n#define GL_STENCIL_WRITEMASK 0x0B98\n#define GL_MATRIX_MODE 0x0BA0\n#define GL_NORMALIZE 0x0BA1\n#define GL_VIEWPORT 0x0BA2\n#define GL_MODELVIEW_STACK_DEPTH 0x0BA3\n#define GL_PROJECTION_STACK_DEPTH 0x0BA4\n#define GL_TEXTURE_STACK_DEPTH 0x0BA5\n#define GL_MODELVIEW_MATRIX 0x0BA6\n#define GL_PROJECTION_MATRIX 0x0BA7\n#define GL_TEXTURE_MATRIX 0x0BA8\n#define GL_ATTRIB_STACK_DEPTH 0x0BB0\n#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1\n#define GL_ALPHA_TEST 0x0BC0\n#define GL_ALPHA_TEST_FUNC 0x0BC1\n#define GL_ALPHA_TEST_REF 0x0BC2\n#define GL_DITHER 0x0BD0\n#define GL_BLEND_DST 0x0BE0\n#define GL_BLEND_SRC 0x0BE1\n#define GL_BLEND 0x0BE2\n#define GL_LOGIC_OP_MODE 0x0BF0\n#define GL_INDEX_LOGIC_OP 0x0BF1\n#define GL_COLOR_LOGIC_OP 0x0BF2\n#define GL_AUX_BUFFERS 0x0C00\n#define GL_DRAW_BUFFER 0x0C01\n#define GL_READ_BUFFER 0x0C02\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_INDEX_CLEAR_VALUE 0x0C20\n#define GL_INDEX_WRITEMASK 0x0C21\n#define GL_COLOR_CLEAR_VALUE 0x0C22\n#define GL_COLOR_WRITEMASK 0x0C23\n#define GL_INDEX_MODE 0x0C30\n#define GL_RGBA_MODE 0x0C31\n#define GL_DOUBLEBUFFER 0x0C32\n#define GL_STEREO 0x0C33\n#define GL_RENDER_MODE 0x0C40\n#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50\n#define GL_POINT_SMOOTH_HINT 0x0C51\n#define GL_LINE_SMOOTH_HINT 0x0C52\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\n#define GL_FOG_HINT 0x0C54\n#define GL_TEXTURE_GEN_S 0x0C60\n#define GL_TEXTURE_GEN_T 0x0C61\n#define GL_TEXTURE_GEN_R 0x0C62\n#define GL_TEXTURE_GEN_Q 0x0C63\n#define GL_PIXEL_MAP_I_TO_I 0x0C70\n#define GL_PIXEL_MAP_S_TO_S 0x0C71\n#define GL_PIXEL_MAP_I_TO_R 0x0C72\n#define GL_PIXEL_MAP_I_TO_G 0x0C73\n#define GL_PIXEL_MAP_I_TO_B 0x0C74\n#define GL_PIXEL_MAP_I_TO_A 0x0C75\n#define GL_PIXEL_MAP_R_TO_R 0x0C76\n#define GL_PIXEL_MAP_G_TO_G 0x0C77\n#define GL_PIXEL_MAP_B_TO_B 0x0C78\n#define GL_PIXEL_MAP_A_TO_A 0x0C79\n#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0\n#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1\n#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2\n#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3\n#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4\n#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5\n#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6\n#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7\n#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8\n#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\n#define GL_UNPACK_LSB_FIRST 0x0CF1\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\n#define GL_UNPACK_ALIGNMENT 0x0CF5\n#define GL_PACK_SWAP_BYTES 0x0D00\n#define GL_PACK_LSB_FIRST 0x0D01\n#define GL_PACK_ROW_LENGTH 0x0D02\n#define GL_PACK_SKIP_ROWS 0x0D03\n#define GL_PACK_SKIP_PIXELS 0x0D04\n#define GL_PACK_ALIGNMENT 0x0D05\n#define GL_MAP_COLOR 0x0D10\n#define GL_MAP_STENCIL 0x0D11\n#define GL_INDEX_SHIFT 0x0D12\n#define GL_INDEX_OFFSET 0x0D13\n#define GL_RED_SCALE 0x0D14\n#define GL_RED_BIAS 0x0D15\n#define GL_ZOOM_X 0x0D16\n#define GL_ZOOM_Y 0x0D17\n#define GL_GREEN_SCALE 0x0D18\n#define GL_GREEN_BIAS 0x0D19\n#define GL_BLUE_SCALE 0x0D1A\n#define GL_BLUE_BIAS 0x0D1B\n#define GL_ALPHA_SCALE 0x0D1C\n#define GL_ALPHA_BIAS 0x0D1D\n#define GL_DEPTH_SCALE 0x0D1E\n#define GL_DEPTH_BIAS 0x0D1F\n#define GL_MAX_EVAL_ORDER 0x0D30\n#define GL_MAX_LIGHTS 0x0D31\n#define GL_MAX_CLIP_PLANES 0x0D32\n#define GL_MAX_TEXTURE_SIZE 0x0D33\n#define GL_MAX_PIXEL_MAP_TABLE 0x0D34\n#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35\n#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36\n#define GL_MAX_NAME_STACK_DEPTH 0x0D37\n#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38\n#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\n#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B\n#define GL_SUBPIXEL_BITS 0x0D50\n#define GL_INDEX_BITS 0x0D51\n#define GL_RED_BITS 0x0D52\n#define GL_GREEN_BITS 0x0D53\n#define GL_BLUE_BITS 0x0D54\n#define GL_ALPHA_BITS 0x0D55\n#define GL_DEPTH_BITS 0x0D56\n#define GL_STENCIL_BITS 0x0D57\n#define GL_ACCUM_RED_BITS 0x0D58\n#define GL_ACCUM_GREEN_BITS 0x0D59\n#define GL_ACCUM_BLUE_BITS 0x0D5A\n#define GL_ACCUM_ALPHA_BITS 0x0D5B\n#define GL_NAME_STACK_DEPTH 0x0D70\n#define GL_AUTO_NORMAL 0x0D80\n#define GL_MAP1_COLOR_4 0x0D90\n#define GL_MAP1_INDEX 0x0D91\n#define GL_MAP1_NORMAL 0x0D92\n#define GL_MAP1_TEXTURE_COORD_1 0x0D93\n#define GL_MAP1_TEXTURE_COORD_2 0x0D94\n#define GL_MAP1_TEXTURE_COORD_3 0x0D95\n#define GL_MAP1_TEXTURE_COORD_4 0x0D96\n#define GL_MAP1_VERTEX_3 0x0D97\n#define GL_MAP1_VERTEX_4 0x0D98\n#define GL_MAP2_COLOR_4 0x0DB0\n#define GL_MAP2_INDEX 0x0DB1\n#define GL_MAP2_NORMAL 0x0DB2\n#define GL_MAP2_TEXTURE_COORD_1 0x0DB3\n#define GL_MAP2_TEXTURE_COORD_2 0x0DB4\n#define GL_MAP2_TEXTURE_COORD_3 0x0DB5\n#define GL_MAP2_TEXTURE_COORD_4 0x0DB6\n#define GL_MAP2_VERTEX_3 0x0DB7\n#define GL_MAP2_VERTEX_4 0x0DB8\n#define GL_MAP1_GRID_DOMAIN 0x0DD0\n#define GL_MAP1_GRID_SEGMENTS 0x0DD1\n#define GL_MAP2_GRID_DOMAIN 0x0DD2\n#define GL_MAP2_GRID_SEGMENTS 0x0DD3\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0\n#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1\n#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2\n#define GL_SELECTION_BUFFER_POINTER 0x0DF3\n#define GL_SELECTION_BUFFER_SIZE 0x0DF4\n#define GL_TEXTURE_WIDTH 0x1000\n#define GL_TRANSFORM_BIT 0x00001000\n#define GL_TEXTURE_HEIGHT 0x1001\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\n#define GL_TEXTURE_BORDER_COLOR 0x1004\n#define GL_TEXTURE_BORDER 0x1005\n#define GL_DONT_CARE 0x1100\n#define GL_FASTEST 0x1101\n#define GL_NICEST 0x1102\n#define GL_AMBIENT 0x1200\n#define GL_DIFFUSE 0x1201\n#define GL_SPECULAR 0x1202\n#define GL_POSITION 0x1203\n#define GL_SPOT_DIRECTION 0x1204\n#define GL_SPOT_EXPONENT 0x1205\n#define GL_SPOT_CUTOFF 0x1206\n#define GL_CONSTANT_ATTENUATION 0x1207\n#define GL_LINEAR_ATTENUATION 0x1208\n#define GL_QUADRATIC_ATTENUATION 0x1209\n#define GL_COMPILE 0x1300\n#define GL_COMPILE_AND_EXECUTE 0x1301\n#define GL_BYTE 0x1400\n#define GL_UNSIGNED_BYTE 0x1401\n#define GL_SHORT 0x1402\n#define GL_UNSIGNED_SHORT 0x1403\n#define GL_INT 0x1404\n#define GL_UNSIGNED_INT 0x1405\n#define GL_FLOAT 0x1406\n#define GL_2_BYTES 0x1407\n#define GL_3_BYTES 0x1408\n#define GL_4_BYTES 0x1409\n#define GL_DOUBLE 0x140A\n#define GL_CLEAR 0x1500\n#define GL_AND 0x1501\n#define GL_AND_REVERSE 0x1502\n#define GL_COPY 0x1503\n#define GL_AND_INVERTED 0x1504\n#define GL_NOOP 0x1505\n#define GL_XOR 0x1506\n#define GL_OR 0x1507\n#define GL_NOR 0x1508\n#define GL_EQUIV 0x1509\n#define GL_INVERT 0x150A\n#define GL_OR_REVERSE 0x150B\n#define GL_COPY_INVERTED 0x150C\n#define GL_OR_INVERTED 0x150D\n#define GL_NAND 0x150E\n#define GL_SET 0x150F\n#define GL_EMISSION 0x1600\n#define GL_SHININESS 0x1601\n#define GL_AMBIENT_AND_DIFFUSE 0x1602\n#define GL_COLOR_INDEXES 0x1603\n#define GL_MODELVIEW 0x1700\n#define GL_PROJECTION 0x1701\n#define GL_TEXTURE 0x1702\n#define GL_COLOR 0x1800\n#define GL_DEPTH 0x1801\n#define GL_STENCIL 0x1802\n#define GL_COLOR_INDEX 0x1900\n#define GL_STENCIL_INDEX 0x1901\n#define GL_DEPTH_COMPONENT 0x1902\n#define GL_RED 0x1903\n#define GL_GREEN 0x1904\n#define GL_BLUE 0x1905\n#define GL_ALPHA 0x1906\n#define GL_RGB 0x1907\n#define GL_RGBA 0x1908\n#define GL_LUMINANCE 0x1909\n#define GL_LUMINANCE_ALPHA 0x190A\n#define GL_BITMAP 0x1A00\n#define GL_POINT 0x1B00\n#define GL_LINE 0x1B01\n#define GL_FILL 0x1B02\n#define GL_RENDER 0x1C00\n#define GL_FEEDBACK 0x1C01\n#define GL_SELECT 0x1C02\n#define GL_FLAT 0x1D00\n#define GL_SMOOTH 0x1D01\n#define GL_KEEP 0x1E00\n#define GL_REPLACE 0x1E01\n#define GL_INCR 0x1E02\n#define GL_DECR 0x1E03\n#define GL_VENDOR 0x1F00\n#define GL_RENDERER 0x1F01\n#define GL_VERSION 0x1F02\n#define GL_EXTENSIONS 0x1F03\n#define GL_S 0x2000\n#define GL_ENABLE_BIT 0x00002000\n#define GL_T 0x2001\n#define GL_R 0x2002\n#define GL_Q 0x2003\n#define GL_MODULATE 0x2100\n#define GL_DECAL 0x2101\n#define GL_TEXTURE_ENV_MODE 0x2200\n#define GL_TEXTURE_ENV_COLOR 0x2201\n#define GL_TEXTURE_ENV 0x2300\n#define GL_EYE_LINEAR 0x2400\n#define GL_OBJECT_LINEAR 0x2401\n#define GL_SPHERE_MAP 0x2402\n#define GL_TEXTURE_GEN_MODE 0x2500\n#define GL_OBJECT_PLANE 0x2501\n#define GL_EYE_PLANE 0x2502\n#define GL_NEAREST 0x2600\n#define GL_LINEAR 0x2601\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\n#define GL_TEXTURE_MAG_FILTER 0x2800\n#define GL_TEXTURE_MIN_FILTER 0x2801\n#define GL_TEXTURE_WRAP_S 0x2802\n#define GL_TEXTURE_WRAP_T 0x2803\n#define GL_CLAMP 0x2900\n#define GL_REPEAT 0x2901\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\n#define GL_POLYGON_OFFSET_POINT 0x2A01\n#define GL_POLYGON_OFFSET_LINE 0x2A02\n#define GL_R3_G3_B2 0x2A10\n#define GL_V2F 0x2A20\n#define GL_V3F 0x2A21\n#define GL_C4UB_V2F 0x2A22\n#define GL_C4UB_V3F 0x2A23\n#define GL_C3F_V3F 0x2A24\n#define GL_N3F_V3F 0x2A25\n#define GL_C4F_N3F_V3F 0x2A26\n#define GL_T2F_V3F 0x2A27\n#define GL_T4F_V4F 0x2A28\n#define GL_T2F_C4UB_V3F 0x2A29\n#define GL_T2F_C3F_V3F 0x2A2A\n#define GL_T2F_N3F_V3F 0x2A2B\n#define GL_T2F_C4F_N3F_V3F 0x2A2C\n#define GL_T4F_C4F_N3F_V4F 0x2A2D\n#define GL_CLIP_PLANE0 0x3000\n#define GL_CLIP_PLANE1 0x3001\n#define GL_CLIP_PLANE2 0x3002\n#define GL_CLIP_PLANE3 0x3003\n#define GL_CLIP_PLANE4 0x3004\n#define GL_CLIP_PLANE5 0x3005\n#define GL_LIGHT0 0x4000\n#define GL_COLOR_BUFFER_BIT 0x00004000\n#define GL_LIGHT1 0x4001\n#define GL_LIGHT2 0x4002\n#define GL_LIGHT3 0x4003\n#define GL_LIGHT4 0x4004\n#define GL_LIGHT5 0x4005\n#define GL_LIGHT6 0x4006\n#define GL_LIGHT7 0x4007\n#define GL_HINT_BIT 0x00008000\n#define GL_POLYGON_OFFSET_FILL 0x8037\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\n#define GL_ALPHA4 0x803B\n#define GL_ALPHA8 0x803C\n#define GL_ALPHA12 0x803D\n#define GL_ALPHA16 0x803E\n#define GL_LUMINANCE4 0x803F\n#define GL_LUMINANCE8 0x8040\n#define GL_LUMINANCE12 0x8041\n#define GL_LUMINANCE16 0x8042\n#define GL_LUMINANCE4_ALPHA4 0x8043\n#define GL_LUMINANCE6_ALPHA2 0x8044\n#define GL_LUMINANCE8_ALPHA8 0x8045\n#define GL_LUMINANCE12_ALPHA4 0x8046\n#define GL_LUMINANCE12_ALPHA12 0x8047\n#define GL_LUMINANCE16_ALPHA16 0x8048\n#define GL_INTENSITY 0x8049\n#define GL_INTENSITY4 0x804A\n#define GL_INTENSITY8 0x804B\n#define GL_INTENSITY12 0x804C\n#define GL_INTENSITY16 0x804D\n#define GL_RGB4 0x804F\n#define GL_RGB5 0x8050\n#define GL_RGB8 0x8051\n#define GL_RGB10 0x8052\n#define GL_RGB12 0x8053\n#define GL_RGB16 0x8054\n#define GL_RGBA2 0x8055\n#define GL_RGBA4 0x8056\n#define GL_RGB5_A1 0x8057\n#define GL_RGBA8 0x8058\n#define GL_RGB10_A2 0x8059\n#define GL_RGBA12 0x805A\n#define GL_RGBA16 0x805B\n#define GL_TEXTURE_RED_SIZE 0x805C\n#define GL_TEXTURE_GREEN_SIZE 0x805D\n#define GL_TEXTURE_BLUE_SIZE 0x805E\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\n#define GL_TEXTURE_LUMINANCE_SIZE 0x8060\n#define GL_TEXTURE_INTENSITY_SIZE 0x8061\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_TEXTURE_PRIORITY 0x8066\n#define GL_TEXTURE_RESIDENT 0x8067\n#define GL_TEXTURE_BINDING_1D 0x8068\n#define GL_TEXTURE_BINDING_2D 0x8069\n#define GL_VERTEX_ARRAY 0x8074\n#define GL_NORMAL_ARRAY 0x8075\n#define GL_COLOR_ARRAY 0x8076\n#define GL_INDEX_ARRAY 0x8077\n#define GL_TEXTURE_COORD_ARRAY 0x8078\n#define GL_EDGE_FLAG_ARRAY 0x8079\n#define GL_VERTEX_ARRAY_SIZE 0x807A\n#define GL_VERTEX_ARRAY_TYPE 0x807B\n#define GL_VERTEX_ARRAY_STRIDE 0x807C\n#define GL_NORMAL_ARRAY_TYPE 0x807E\n#define GL_NORMAL_ARRAY_STRIDE 0x807F\n#define GL_COLOR_ARRAY_SIZE 0x8081\n#define GL_COLOR_ARRAY_TYPE 0x8082\n#define GL_COLOR_ARRAY_STRIDE 0x8083\n#define GL_INDEX_ARRAY_TYPE 0x8085\n#define GL_INDEX_ARRAY_STRIDE 0x8086\n#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088\n#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089\n#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A\n#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C\n#define GL_VERTEX_ARRAY_POINTER 0x808E\n#define GL_NORMAL_ARRAY_POINTER 0x808F\n#define GL_COLOR_ARRAY_POINTER 0x8090\n#define GL_INDEX_ARRAY_POINTER 0x8091\n#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092\n#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093\n#define GL_COLOR_INDEX1_EXT 0x80E2\n#define GL_COLOR_INDEX2_EXT 0x80E3\n#define GL_COLOR_INDEX4_EXT 0x80E4\n#define GL_COLOR_INDEX8_EXT 0x80E5\n#define GL_COLOR_INDEX12_EXT 0x80E6\n#define GL_COLOR_INDEX16_EXT 0x80E7\n#define GL_EVAL_BIT 0x00010000\n#define GL_LIST_BIT 0x00020000\n#define GL_TEXTURE_BIT 0x00040000\n#define GL_SCISSOR_BIT 0x00080000\n#define GL_ALL_ATTRIB_BITS 0x000fffff\n#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff\n\nGLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value);\nGLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref);\nGLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences);\nGLAPI void GLAPIENTRY glArrayElement (GLint i);\nGLAPI void GLAPIENTRY glBegin (GLenum mode);\nGLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture);\nGLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\nGLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);\nGLAPI void GLAPIENTRY glCallList (GLuint list);\nGLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists);\nGLAPI void GLAPIENTRY glClear (GLbitfield mask);\nGLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nGLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nGLAPI void GLAPIENTRY glClearDepth (GLclampd depth);\nGLAPI void GLAPIENTRY glClearIndex (GLfloat c);\nGLAPI void GLAPIENTRY glClearStencil (GLint s);\nGLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation);\nGLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue);\nGLAPI void GLAPIENTRY glColor3bv (const GLbyte *v);\nGLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue);\nGLAPI void GLAPIENTRY glColor3dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue);\nGLAPI void GLAPIENTRY glColor3fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue);\nGLAPI void GLAPIENTRY glColor3iv (const GLint *v);\nGLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue);\nGLAPI void GLAPIENTRY glColor3sv (const GLshort *v);\nGLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue);\nGLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v);\nGLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue);\nGLAPI void GLAPIENTRY glColor3uiv (const GLuint *v);\nGLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue);\nGLAPI void GLAPIENTRY glColor3usv (const GLushort *v);\nGLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\nGLAPI void GLAPIENTRY glColor4bv (const GLbyte *v);\nGLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\nGLAPI void GLAPIENTRY glColor4dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nGLAPI void GLAPIENTRY glColor4fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha);\nGLAPI void GLAPIENTRY glColor4iv (const GLint *v);\nGLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha);\nGLAPI void GLAPIENTRY glColor4sv (const GLshort *v);\nGLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\nGLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v);\nGLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha);\nGLAPI void GLAPIENTRY glColor4uiv (const GLuint *v);\nGLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha);\nGLAPI void GLAPIENTRY glColor4usv (const GLushort *v);\nGLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nGLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode);\nGLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\nGLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\nGLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nGLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nGLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void GLAPIENTRY glCullFace (GLenum mode);\nGLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range);\nGLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);\nGLAPI void GLAPIENTRY glDepthFunc (GLenum func);\nGLAPI void GLAPIENTRY glDepthMask (GLboolean flag);\nGLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar);\nGLAPI void GLAPIENTRY glDisable (GLenum cap);\nGLAPI void GLAPIENTRY glDisableClientState (GLenum array);\nGLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);\nGLAPI void GLAPIENTRY glDrawBuffer (GLenum mode);\nGLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);\nGLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nGLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag);\nGLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag);\nGLAPI void GLAPIENTRY glEnable (GLenum cap);\nGLAPI void GLAPIENTRY glEnableClientState (GLenum array);\nGLAPI void GLAPIENTRY glEnd (void);\nGLAPI void GLAPIENTRY glEndList (void);\nGLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u);\nGLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u);\nGLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u);\nGLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u);\nGLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v);\nGLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u);\nGLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v);\nGLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u);\nGLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2);\nGLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\nGLAPI void GLAPIENTRY glEvalPoint1 (GLint i);\nGLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j);\nGLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer);\nGLAPI void GLAPIENTRY glFinish (void);\nGLAPI void GLAPIENTRY glFlush (void);\nGLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glFrontFace (GLenum mode);\nGLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLAPI GLuint GLAPIENTRY glGenLists (GLsizei range);\nGLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures);\nGLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params);\nGLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation);\nGLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params);\nGLAPI GLenum GLAPIENTRY glGetError (void);\nGLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v);\nGLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v);\nGLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v);\nGLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values);\nGLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values);\nGLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values);\nGLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params);\nGLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask);\nGLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name);\nGLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params);\nGLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);\nGLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode);\nGLAPI void GLAPIENTRY glIndexMask (GLuint mask);\nGLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glIndexd (GLdouble c);\nGLAPI void GLAPIENTRY glIndexdv (const GLdouble *c);\nGLAPI void GLAPIENTRY glIndexf (GLfloat c);\nGLAPI void GLAPIENTRY glIndexfv (const GLfloat *c);\nGLAPI void GLAPIENTRY glIndexi (GLint c);\nGLAPI void GLAPIENTRY glIndexiv (const GLint *c);\nGLAPI void GLAPIENTRY glIndexs (GLshort c);\nGLAPI void GLAPIENTRY glIndexsv (const GLshort *c);\nGLAPI void GLAPIENTRY glIndexub (GLubyte c);\nGLAPI void GLAPIENTRY glIndexubv (const GLubyte *c);\nGLAPI void GLAPIENTRY glInitNames (void);\nGLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer);\nGLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap);\nGLAPI GLboolean GLAPIENTRY glIsList (GLuint list);\nGLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture);\nGLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern);\nGLAPI void GLAPIENTRY glLineWidth (GLfloat width);\nGLAPI void GLAPIENTRY glListBase (GLuint base);\nGLAPI void GLAPIENTRY glLoadIdentity (void);\nGLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m);\nGLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m);\nGLAPI void GLAPIENTRY glLoadName (GLuint name);\nGLAPI void GLAPIENTRY glLogicOp (GLenum opcode);\nGLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nGLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nGLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nGLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\nGLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2);\nGLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2);\nGLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\nGLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\nGLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glMatrixMode (GLenum mode);\nGLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m);\nGLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m);\nGLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode);\nGLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz);\nGLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v);\nGLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz);\nGLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);\nGLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz);\nGLAPI void GLAPIENTRY glNormal3iv (const GLint *v);\nGLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz);\nGLAPI void GLAPIENTRY glNormal3sv (const GLshort *v);\nGLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLAPI void GLAPIENTRY glPassThrough (GLfloat token);\nGLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values);\nGLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values);\nGLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values);\nGLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor);\nGLAPI void GLAPIENTRY glPointSize (GLfloat size);\nGLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode);\nGLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units);\nGLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask);\nGLAPI void GLAPIENTRY glPopAttrib (void);\nGLAPI void GLAPIENTRY glPopClientAttrib (void);\nGLAPI void GLAPIENTRY glPopMatrix (void);\nGLAPI void GLAPIENTRY glPopName (void);\nGLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities);\nGLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask);\nGLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask);\nGLAPI void GLAPIENTRY glPushMatrix (void);\nGLAPI void GLAPIENTRY glPushName (GLuint name);\nGLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y);\nGLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y);\nGLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y);\nGLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v);\nGLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y);\nGLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v);\nGLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z);\nGLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v);\nGLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z);\nGLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v);\nGLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w);\nGLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v);\nGLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v);\nGLAPI void GLAPIENTRY glReadBuffer (GLenum mode);\nGLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);\nGLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\nGLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2);\nGLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\nGLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2);\nGLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2);\nGLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2);\nGLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2);\nGLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2);\nGLAPI GLint GLAPIENTRY glRenderMode (GLenum mode);\nGLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer);\nGLAPI void GLAPIENTRY glShadeModel (GLenum mode);\nGLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);\nGLAPI void GLAPIENTRY glStencilMask (GLuint mask);\nGLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);\nGLAPI void GLAPIENTRY glTexCoord1d (GLdouble s);\nGLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glTexCoord1f (GLfloat s);\nGLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glTexCoord1i (GLint s);\nGLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v);\nGLAPI void GLAPIENTRY glTexCoord1s (GLshort s);\nGLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v);\nGLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t);\nGLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t);\nGLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t);\nGLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v);\nGLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t);\nGLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v);\nGLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r);\nGLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r);\nGLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r);\nGLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v);\nGLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r);\nGLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v);\nGLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nGLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nGLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q);\nGLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v);\nGLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q);\nGLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v);\nGLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param);\nGLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params);\nGLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nGLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\nGLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);\nGLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);\nGLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);\nGLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);\nGLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);\nGLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y);\nGLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y);\nGLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y);\nGLAPI void GLAPIENTRY glVertex2iv (const GLint *v);\nGLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y);\nGLAPI void GLAPIENTRY glVertex2sv (const GLshort *v);\nGLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z);\nGLAPI void GLAPIENTRY glVertex3iv (const GLint *v);\nGLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z);\nGLAPI void GLAPIENTRY glVertex3sv (const GLshort *v);\nGLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v);\nGLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v);\nGLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w);\nGLAPI void GLAPIENTRY glVertex4iv (const GLint *v);\nGLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void GLAPIENTRY glVertex4sv (const GLshort *v);\nGLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\nGLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);\n\n#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1)\n\n#endif /* GL_VERSION_1_1 */\n\n/* ---------------------------------- GLU ---------------------------------- */\n\n#ifndef GLEW_NO_GLU\n/* this is where we can safely include GLU */\n#  if defined(__APPLE__) && defined(__MACH__)\n#    include <OpenGL/glu.h>\n#  else\n#    include <GL/glu.h>\n#  endif\n#endif\n\n/* ----------------------------- GL_VERSION_1_2 ---------------------------- */\n\n#ifndef GL_VERSION_1_2\n#define GL_VERSION_1_2 1\n\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\n#define GL_RESCALE_NORMAL 0x803A\n#define GL_TEXTURE_BINDING_3D 0x806A\n#define GL_PACK_SKIP_IMAGES 0x806B\n#define GL_PACK_IMAGE_HEIGHT 0x806C\n#define GL_UNPACK_SKIP_IMAGES 0x806D\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\n#define GL_TEXTURE_3D 0x806F\n#define GL_PROXY_TEXTURE_3D 0x8070\n#define GL_TEXTURE_DEPTH 0x8071\n#define GL_TEXTURE_WRAP_R 0x8072\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\n#define GL_BGR 0x80E0\n#define GL_BGRA 0x80E1\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\n#define GL_CLAMP_TO_EDGE 0x812F\n#define GL_TEXTURE_MIN_LOD 0x813A\n#define GL_TEXTURE_MAX_LOD 0x813B\n#define GL_TEXTURE_BASE_LEVEL 0x813C\n#define GL_TEXTURE_MAX_LEVEL 0x813D\n#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8\n#define GL_SINGLE_COLOR 0x81F9\n#define GL_SEPARATE_SPECULAR_COLOR 0x81FA\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_ALIASED_POINT_SIZE_RANGE 0x846D\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\n\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);\n\n#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D)\n#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements)\n#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D)\n#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D)\n\n#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2)\n\n#endif /* GL_VERSION_1_2 */\n\n/* ---------------------------- GL_VERSION_1_2_1 --------------------------- */\n\n#ifndef GL_VERSION_1_2_1\n#define GL_VERSION_1_2_1 1\n\n#define GLEW_VERSION_1_2_1 GLEW_GET_VAR(__GLEW_VERSION_1_2_1)\n\n#endif /* GL_VERSION_1_2_1 */\n\n/* ----------------------------- GL_VERSION_1_3 ---------------------------- */\n\n#ifndef GL_VERSION_1_3\n#define GL_VERSION_1_3 1\n\n#define GL_MULTISAMPLE 0x809D\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\n#define GL_SAMPLE_COVERAGE 0x80A0\n#define GL_SAMPLE_BUFFERS 0x80A8\n#define GL_SAMPLES 0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\n#define GL_CLAMP_TO_BORDER 0x812D\n#define GL_TEXTURE0 0x84C0\n#define GL_TEXTURE1 0x84C1\n#define GL_TEXTURE2 0x84C2\n#define GL_TEXTURE3 0x84C3\n#define GL_TEXTURE4 0x84C4\n#define GL_TEXTURE5 0x84C5\n#define GL_TEXTURE6 0x84C6\n#define GL_TEXTURE7 0x84C7\n#define GL_TEXTURE8 0x84C8\n#define GL_TEXTURE9 0x84C9\n#define GL_TEXTURE10 0x84CA\n#define GL_TEXTURE11 0x84CB\n#define GL_TEXTURE12 0x84CC\n#define GL_TEXTURE13 0x84CD\n#define GL_TEXTURE14 0x84CE\n#define GL_TEXTURE15 0x84CF\n#define GL_TEXTURE16 0x84D0\n#define GL_TEXTURE17 0x84D1\n#define GL_TEXTURE18 0x84D2\n#define GL_TEXTURE19 0x84D3\n#define GL_TEXTURE20 0x84D4\n#define GL_TEXTURE21 0x84D5\n#define GL_TEXTURE22 0x84D6\n#define GL_TEXTURE23 0x84D7\n#define GL_TEXTURE24 0x84D8\n#define GL_TEXTURE25 0x84D9\n#define GL_TEXTURE26 0x84DA\n#define GL_TEXTURE27 0x84DB\n#define GL_TEXTURE28 0x84DC\n#define GL_TEXTURE29 0x84DD\n#define GL_TEXTURE30 0x84DE\n#define GL_TEXTURE31 0x84DF\n#define GL_ACTIVE_TEXTURE 0x84E0\n#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1\n#define GL_MAX_TEXTURE_UNITS 0x84E2\n#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3\n#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4\n#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5\n#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6\n#define GL_SUBTRACT 0x84E7\n#define GL_COMPRESSED_ALPHA 0x84E9\n#define GL_COMPRESSED_LUMINANCE 0x84EA\n#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB\n#define GL_COMPRESSED_INTENSITY 0x84EC\n#define GL_COMPRESSED_RGB 0x84ED\n#define GL_COMPRESSED_RGBA 0x84EE\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\n#define GL_NORMAL_MAP 0x8511\n#define GL_REFLECTION_MAP 0x8512\n#define GL_TEXTURE_CUBE_MAP 0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\n#define GL_COMBINE 0x8570\n#define GL_COMBINE_RGB 0x8571\n#define GL_COMBINE_ALPHA 0x8572\n#define GL_RGB_SCALE 0x8573\n#define GL_ADD_SIGNED 0x8574\n#define GL_INTERPOLATE 0x8575\n#define GL_CONSTANT 0x8576\n#define GL_PRIMARY_COLOR 0x8577\n#define GL_PREVIOUS 0x8578\n#define GL_SOURCE0_RGB 0x8580\n#define GL_SOURCE1_RGB 0x8581\n#define GL_SOURCE2_RGB 0x8582\n#define GL_SOURCE0_ALPHA 0x8588\n#define GL_SOURCE1_ALPHA 0x8589\n#define GL_SOURCE2_ALPHA 0x858A\n#define GL_OPERAND0_RGB 0x8590\n#define GL_OPERAND1_RGB 0x8591\n#define GL_OPERAND2_RGB 0x8592\n#define GL_OPERAND0_ALPHA 0x8598\n#define GL_OPERAND1_ALPHA 0x8599\n#define GL_OPERAND2_ALPHA 0x859A\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\n#define GL_TEXTURE_COMPRESSED 0x86A1\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\n#define GL_DOT3_RGB 0x86AE\n#define GL_DOT3_RGBA 0x86AF\n#define GL_MULTISAMPLE_BIT 0x20000000\n\ntypedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture);\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img);\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]);\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]);\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]);\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);\n\n#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture)\n#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture)\n#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D)\n#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D)\n#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D)\n#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D)\n#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D)\n#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D)\n#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage)\n#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd)\n#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf)\n#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd)\n#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf)\n#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d)\n#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv)\n#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f)\n#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv)\n#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i)\n#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv)\n#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s)\n#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv)\n#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d)\n#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv)\n#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f)\n#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv)\n#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i)\n#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv)\n#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s)\n#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv)\n#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d)\n#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv)\n#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f)\n#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv)\n#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i)\n#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv)\n#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s)\n#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv)\n#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d)\n#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv)\n#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f)\n#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv)\n#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i)\n#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv)\n#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s)\n#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv)\n#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage)\n\n#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3)\n\n#endif /* GL_VERSION_1_3 */\n\n/* ----------------------------- GL_VERSION_1_4 ---------------------------- */\n\n#ifndef GL_VERSION_1_4\n#define GL_VERSION_1_4 1\n\n#define GL_BLEND_DST_RGB 0x80C8\n#define GL_BLEND_SRC_RGB 0x80C9\n#define GL_BLEND_DST_ALPHA 0x80CA\n#define GL_BLEND_SRC_ALPHA 0x80CB\n#define GL_POINT_SIZE_MIN 0x8126\n#define GL_POINT_SIZE_MAX 0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\n#define GL_POINT_DISTANCE_ATTENUATION 0x8129\n#define GL_GENERATE_MIPMAP 0x8191\n#define GL_GENERATE_MIPMAP_HINT 0x8192\n#define GL_DEPTH_COMPONENT16 0x81A5\n#define GL_DEPTH_COMPONENT24 0x81A6\n#define GL_DEPTH_COMPONENT32 0x81A7\n#define GL_MIRRORED_REPEAT 0x8370\n#define GL_FOG_COORDINATE_SOURCE 0x8450\n#define GL_FOG_COORDINATE 0x8451\n#define GL_FRAGMENT_DEPTH 0x8452\n#define GL_CURRENT_FOG_COORDINATE 0x8453\n#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454\n#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455\n#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456\n#define GL_FOG_COORDINATE_ARRAY 0x8457\n#define GL_COLOR_SUM 0x8458\n#define GL_CURRENT_SECONDARY_COLOR 0x8459\n#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A\n#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C\n#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D\n#define GL_SECONDARY_COLOR_ARRAY 0x845E\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\n#define GL_TEXTURE_FILTER_CONTROL 0x8500\n#define GL_TEXTURE_LOD_BIAS 0x8501\n#define GL_INCR_WRAP 0x8507\n#define GL_DECR_WRAP 0x8508\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\n#define GL_DEPTH_TEXTURE_MODE 0x884B\n#define GL_TEXTURE_COMPARE_MODE 0x884C\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\n#define GL_COMPARE_R_TO_TEXTURE 0x884E\n\ntypedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei drawcount);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p);\n\n#define glBlendColor GLEW_GET_FUN(__glewBlendColor)\n#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation)\n#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate)\n#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer)\n#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd)\n#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv)\n#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf)\n#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv)\n#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays)\n#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements)\n#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf)\n#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv)\n#define glPointParameteri GLEW_GET_FUN(__glewPointParameteri)\n#define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv)\n#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b)\n#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv)\n#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d)\n#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv)\n#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f)\n#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv)\n#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i)\n#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv)\n#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s)\n#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv)\n#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub)\n#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv)\n#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui)\n#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv)\n#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us)\n#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv)\n#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer)\n#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d)\n#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv)\n#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f)\n#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv)\n#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i)\n#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv)\n#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s)\n#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv)\n#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d)\n#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv)\n#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f)\n#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv)\n#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i)\n#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv)\n#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s)\n#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv)\n\n#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4)\n\n#endif /* GL_VERSION_1_4 */\n\n/* ----------------------------- GL_VERSION_1_5 ---------------------------- */\n\n#ifndef GL_VERSION_1_5\n#define GL_VERSION_1_5 1\n\n#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE\n#define GL_FOG_COORD GL_FOG_COORDINATE\n#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY\n#define GL_SRC0_RGB GL_SOURCE0_RGB\n#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER\n#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE\n#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA\n#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE\n#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE\n#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA\n#define GL_SRC1_RGB GL_SOURCE1_RGB\n#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\n#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA\n#define GL_SRC2_RGB GL_SOURCE2_RGB\n#define GL_BUFFER_SIZE 0x8764\n#define GL_BUFFER_USAGE 0x8765\n#define GL_QUERY_COUNTER_BITS 0x8864\n#define GL_CURRENT_QUERY 0x8865\n#define GL_QUERY_RESULT 0x8866\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\n#define GL_ARRAY_BUFFER 0x8892\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\n#define GL_ARRAY_BUFFER_BINDING 0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\n#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896\n#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897\n#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898\n#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_READ_ONLY 0x88B8\n#define GL_WRITE_ONLY 0x88B9\n#define GL_READ_WRITE 0x88BA\n#define GL_BUFFER_ACCESS 0x88BB\n#define GL_BUFFER_MAPPED 0x88BC\n#define GL_BUFFER_MAP_POINTER 0x88BD\n#define GL_STREAM_DRAW 0x88E0\n#define GL_STREAM_READ 0x88E1\n#define GL_STREAM_COPY 0x88E2\n#define GL_STATIC_DRAW 0x88E4\n#define GL_STATIC_READ 0x88E5\n#define GL_STATIC_COPY 0x88E6\n#define GL_DYNAMIC_DRAW 0x88E8\n#define GL_DYNAMIC_READ 0x88E9\n#define GL_DYNAMIC_COPY 0x88EA\n#define GL_SAMPLES_PASSED 0x8914\n\ntypedef ptrdiff_t GLintptr;\ntypedef ptrdiff_t GLsizeiptr;\n\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);\ntypedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);\ntypedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers);\ntypedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer);\ntypedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id);\ntypedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target);\n\n#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery)\n#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer)\n#define glBufferData GLEW_GET_FUN(__glewBufferData)\n#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData)\n#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers)\n#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries)\n#define glEndQuery GLEW_GET_FUN(__glewEndQuery)\n#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers)\n#define glGenQueries GLEW_GET_FUN(__glewGenQueries)\n#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv)\n#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv)\n#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData)\n#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv)\n#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv)\n#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv)\n#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer)\n#define glIsQuery GLEW_GET_FUN(__glewIsQuery)\n#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer)\n#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer)\n\n#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5)\n\n#endif /* GL_VERSION_1_5 */\n\n/* ----------------------------- GL_VERSION_2_0 ---------------------------- */\n\n#ifndef GL_VERSION_2_0\n#define GL_VERSION_2_0 1\n\n#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\n#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\n#define GL_STENCIL_BACK_FUNC 0x8800\n#define GL_STENCIL_BACK_FAIL 0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\n#define GL_MAX_DRAW_BUFFERS 0x8824\n#define GL_DRAW_BUFFER0 0x8825\n#define GL_DRAW_BUFFER1 0x8826\n#define GL_DRAW_BUFFER2 0x8827\n#define GL_DRAW_BUFFER3 0x8828\n#define GL_DRAW_BUFFER4 0x8829\n#define GL_DRAW_BUFFER5 0x882A\n#define GL_DRAW_BUFFER6 0x882B\n#define GL_DRAW_BUFFER7 0x882C\n#define GL_DRAW_BUFFER8 0x882D\n#define GL_DRAW_BUFFER9 0x882E\n#define GL_DRAW_BUFFER10 0x882F\n#define GL_DRAW_BUFFER11 0x8830\n#define GL_DRAW_BUFFER12 0x8831\n#define GL_DRAW_BUFFER13 0x8832\n#define GL_DRAW_BUFFER14 0x8833\n#define GL_DRAW_BUFFER15 0x8834\n#define GL_BLEND_EQUATION_ALPHA 0x883D\n#define GL_POINT_SPRITE 0x8861\n#define GL_COORD_REPLACE 0x8862\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_MAX_TEXTURE_COORDS 0x8871\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\n#define GL_FRAGMENT_SHADER 0x8B30\n#define GL_VERTEX_SHADER 0x8B31\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\n#define GL_MAX_VARYING_FLOATS 0x8B4B\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_SHADER_TYPE 0x8B4F\n#define GL_FLOAT_VEC2 0x8B50\n#define GL_FLOAT_VEC3 0x8B51\n#define GL_FLOAT_VEC4 0x8B52\n#define GL_INT_VEC2 0x8B53\n#define GL_INT_VEC3 0x8B54\n#define GL_INT_VEC4 0x8B55\n#define GL_BOOL 0x8B56\n#define GL_BOOL_VEC2 0x8B57\n#define GL_BOOL_VEC3 0x8B58\n#define GL_BOOL_VEC4 0x8B59\n#define GL_FLOAT_MAT2 0x8B5A\n#define GL_FLOAT_MAT3 0x8B5B\n#define GL_FLOAT_MAT4 0x8B5C\n#define GL_SAMPLER_1D 0x8B5D\n#define GL_SAMPLER_2D 0x8B5E\n#define GL_SAMPLER_3D 0x8B5F\n#define GL_SAMPLER_CUBE 0x8B60\n#define GL_SAMPLER_1D_SHADOW 0x8B61\n#define GL_SAMPLER_2D_SHADOW 0x8B62\n#define GL_DELETE_STATUS 0x8B80\n#define GL_COMPILE_STATUS 0x8B81\n#define GL_LINK_STATUS 0x8B82\n#define GL_VALIDATE_STATUS 0x8B83\n#define GL_INFO_LOG_LENGTH 0x8B84\n#define GL_ATTACHED_SHADERS 0x8B85\n#define GL_ACTIVE_UNIFORMS 0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\n#define GL_CURRENT_PROGRAM 0x8B8D\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\n#define GL_LOWER_LEFT 0x8CA1\n#define GL_UPPER_LEFT 0x8CA2\n#define GL_STENCIL_BACK_REF 0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\n\ntypedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);\ntypedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum);\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader);\ntypedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void);\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type);\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program);\ntypedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader);\ntypedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs);\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);\ntypedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param);\ntypedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);\ntypedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source);\ntypedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param);\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid**);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program);\ntypedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader);\ntypedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program);\ntypedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths);\ntypedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\ntypedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint);\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program);\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);\n\n#define glAttachShader GLEW_GET_FUN(__glewAttachShader)\n#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation)\n#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate)\n#define glCompileShader GLEW_GET_FUN(__glewCompileShader)\n#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram)\n#define glCreateShader GLEW_GET_FUN(__glewCreateShader)\n#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram)\n#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader)\n#define glDetachShader GLEW_GET_FUN(__glewDetachShader)\n#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray)\n#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers)\n#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray)\n#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib)\n#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform)\n#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders)\n#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation)\n#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog)\n#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv)\n#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog)\n#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource)\n#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv)\n#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation)\n#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv)\n#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv)\n#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv)\n#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv)\n#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv)\n#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv)\n#define glIsProgram GLEW_GET_FUN(__glewIsProgram)\n#define glIsShader GLEW_GET_FUN(__glewIsShader)\n#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram)\n#define glShaderSource GLEW_GET_FUN(__glewShaderSource)\n#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate)\n#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate)\n#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate)\n#define glUniform1f GLEW_GET_FUN(__glewUniform1f)\n#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv)\n#define glUniform1i GLEW_GET_FUN(__glewUniform1i)\n#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv)\n#define glUniform2f GLEW_GET_FUN(__glewUniform2f)\n#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv)\n#define glUniform2i GLEW_GET_FUN(__glewUniform2i)\n#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv)\n#define glUniform3f GLEW_GET_FUN(__glewUniform3f)\n#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv)\n#define glUniform3i GLEW_GET_FUN(__glewUniform3i)\n#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv)\n#define glUniform4f GLEW_GET_FUN(__glewUniform4f)\n#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv)\n#define glUniform4i GLEW_GET_FUN(__glewUniform4i)\n#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv)\n#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv)\n#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv)\n#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv)\n#define glUseProgram GLEW_GET_FUN(__glewUseProgram)\n#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram)\n#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d)\n#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv)\n#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f)\n#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv)\n#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s)\n#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv)\n#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d)\n#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv)\n#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f)\n#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv)\n#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s)\n#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv)\n#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d)\n#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv)\n#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f)\n#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv)\n#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s)\n#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv)\n#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv)\n#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv)\n#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv)\n#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub)\n#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv)\n#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv)\n#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv)\n#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv)\n#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d)\n#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv)\n#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f)\n#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv)\n#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv)\n#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s)\n#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv)\n#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv)\n#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv)\n#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv)\n#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer)\n\n#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0)\n\n#endif /* GL_VERSION_2_0 */\n\n/* ----------------------------- GL_VERSION_2_1 ---------------------------- */\n\n#ifndef GL_VERSION_2_1\n#define GL_VERSION_2_1 1\n\n#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F\n#define GL_PIXEL_PACK_BUFFER 0x88EB\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\n#define GL_FLOAT_MAT2x3 0x8B65\n#define GL_FLOAT_MAT2x4 0x8B66\n#define GL_FLOAT_MAT3x2 0x8B67\n#define GL_FLOAT_MAT3x4 0x8B68\n#define GL_FLOAT_MAT4x2 0x8B69\n#define GL_FLOAT_MAT4x3 0x8B6A\n#define GL_SRGB 0x8C40\n#define GL_SRGB8 0x8C41\n#define GL_SRGB_ALPHA 0x8C42\n#define GL_SRGB8_ALPHA8 0x8C43\n#define GL_SLUMINANCE_ALPHA 0x8C44\n#define GL_SLUMINANCE8_ALPHA8 0x8C45\n#define GL_SLUMINANCE 0x8C46\n#define GL_SLUMINANCE8 0x8C47\n#define GL_COMPRESSED_SRGB 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\n#define GL_COMPRESSED_SLUMINANCE 0x8C4A\n#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B\n\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\n\n#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv)\n#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv)\n#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv)\n#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv)\n#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv)\n#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv)\n\n#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1)\n\n#endif /* GL_VERSION_2_1 */\n\n/* ----------------------------- GL_VERSION_3_0 ---------------------------- */\n\n#ifndef GL_VERSION_3_0\n#define GL_VERSION_3_0 1\n\n#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES\n#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5\n#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1\n#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3\n#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB\n#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0\n#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4\n#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2\n#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001\n#define GL_MAJOR_VERSION 0x821B\n#define GL_MINOR_VERSION 0x821C\n#define GL_NUM_EXTENSIONS 0x821D\n#define GL_CONTEXT_FLAGS 0x821E\n#define GL_DEPTH_BUFFER 0x8223\n#define GL_STENCIL_BUFFER 0x8224\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RG 0x8226\n#define GL_RGBA32F 0x8814\n#define GL_RGB32F 0x8815\n#define GL_RGBA16F 0x881A\n#define GL_RGB16F 0x881B\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\n#define GL_CLAMP_VERTEX_COLOR 0x891A\n#define GL_CLAMP_FRAGMENT_COLOR 0x891B\n#define GL_CLAMP_READ_COLOR 0x891C\n#define GL_FIXED_ONLY 0x891D\n#define GL_TEXTURE_RED_TYPE 0x8C10\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\n#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14\n#define GL_TEXTURE_INTENSITY_TYPE 0x8C15\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\n#define GL_R11F_G11F_B10F 0x8C3A\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\n#define GL_RGB9_E5 0x8C3D\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_PRIMITIVES_GENERATED 0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_RASTERIZER_DISCARD 0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\n#define GL_SEPARATE_ATTRIBS 0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_RGBA32UI 0x8D70\n#define GL_RGB32UI 0x8D71\n#define GL_RGBA16UI 0x8D76\n#define GL_RGB16UI 0x8D77\n#define GL_RGBA8UI 0x8D7C\n#define GL_RGB8UI 0x8D7D\n#define GL_RGBA32I 0x8D82\n#define GL_RGB32I 0x8D83\n#define GL_RGBA16I 0x8D88\n#define GL_RGB16I 0x8D89\n#define GL_RGBA8I 0x8D8E\n#define GL_RGB8I 0x8D8F\n#define GL_RED_INTEGER 0x8D94\n#define GL_GREEN_INTEGER 0x8D95\n#define GL_BLUE_INTEGER 0x8D96\n#define GL_ALPHA_INTEGER 0x8D97\n#define GL_RGB_INTEGER 0x8D98\n#define GL_RGBA_INTEGER 0x8D99\n#define GL_BGR_INTEGER 0x8D9A\n#define GL_BGRA_INTEGER 0x8D9B\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\n#define GL_INT_SAMPLER_1D 0x8DC9\n#define GL_INT_SAMPLER_2D 0x8DCA\n#define GL_INT_SAMPLER_3D 0x8DCB\n#define GL_INT_SAMPLER_CUBE 0x8DCC\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\n#define GL_QUERY_WAIT 0x8E13\n#define GL_QUERY_NO_WAIT 0x8E14\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\n\ntypedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint, GLenum);\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum);\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint, GLuint, const GLchar*);\ntypedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum, GLenum);\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum, GLint, GLfloat, GLint);\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum, GLint, const GLfloat*);\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum, GLint, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum, GLint, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean);\ntypedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum, GLuint);\ntypedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum, GLuint);\ntypedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum, GLuint, GLboolean*);\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint, const GLchar*);\ntypedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum, GLuint);\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum, GLenum, GLint*);\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum, GLenum, GLuint*);\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint, GLint, GLuint*);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint, GLenum, GLint*);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint, GLenum, GLuint*);\ntypedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum, GLuint);\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum, GLenum, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum, GLenum, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLchar **, GLenum);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint, GLsizei, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint, GLsizei, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint, GLuint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint, GLsizei, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint, GLuint, GLuint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint, GLsizei, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint, GLint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint, GLint, GLint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint, GLint, GLint, GLint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint, GLuint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint, const GLbyte*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint, GLint, GLint, GLint, GLint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint, const GLint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint, const GLshort*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint, const GLubyte*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint, GLuint, GLuint, GLuint, GLuint);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint, const GLuint*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint, const GLushort*);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum, GLsizei, const GLvoid*);\n\n#define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender)\n#define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback)\n#define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation)\n#define glClampColor GLEW_GET_FUN(__glewClampColor)\n#define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi)\n#define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv)\n#define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv)\n#define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv)\n#define glColorMaski GLEW_GET_FUN(__glewColorMaski)\n#define glDisablei GLEW_GET_FUN(__glewDisablei)\n#define glEnablei GLEW_GET_FUN(__glewEnablei)\n#define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender)\n#define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback)\n#define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v)\n#define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation)\n#define glGetStringi GLEW_GET_FUN(__glewGetStringi)\n#define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv)\n#define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv)\n#define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying)\n#define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv)\n#define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv)\n#define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv)\n#define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi)\n#define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv)\n#define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv)\n#define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings)\n#define glUniform1ui GLEW_GET_FUN(__glewUniform1ui)\n#define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv)\n#define glUniform2ui GLEW_GET_FUN(__glewUniform2ui)\n#define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv)\n#define glUniform3ui GLEW_GET_FUN(__glewUniform3ui)\n#define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv)\n#define glUniform4ui GLEW_GET_FUN(__glewUniform4ui)\n#define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv)\n#define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i)\n#define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv)\n#define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui)\n#define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv)\n#define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i)\n#define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv)\n#define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui)\n#define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv)\n#define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i)\n#define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv)\n#define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui)\n#define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv)\n#define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv)\n#define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i)\n#define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv)\n#define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv)\n#define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv)\n#define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui)\n#define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv)\n#define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv)\n#define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer)\n\n#define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0)\n\n#endif /* GL_VERSION_3_0 */\n\n/* ----------------------------- GL_VERSION_3_1 ---------------------------- */\n\n#ifndef GL_VERSION_3_1\n#define GL_VERSION_3_1 1\n\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\n#define GL_SAMPLER_2D_RECT 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E\n#define GL_SAMPLER_BUFFER 0x8DC2\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\n#define GL_RED_SNORM 0x8F90\n#define GL_RG_SNORM 0x8F91\n#define GL_RGB_SNORM 0x8F92\n#define GL_RGBA_SNORM 0x8F93\n#define GL_R8_SNORM 0x8F94\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_R16_SNORM 0x8F98\n#define GL_RG16_SNORM 0x8F99\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_PRIMITIVE_RESTART 0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\n#define GL_BUFFER_MAP_LENGTH 0x9120\n#define GL_BUFFER_MAP_OFFSET 0x9121\n\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum, GLint, GLsizei, GLsizei);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum, GLsizei, GLenum, const GLvoid*, GLsizei);\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint);\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum, GLenum, GLuint);\n\n#define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced)\n#define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced)\n#define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex)\n#define glTexBuffer GLEW_GET_FUN(__glewTexBuffer)\n\n#define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1)\n\n#endif /* GL_VERSION_3_1 */\n\n/* ----------------------------- GL_VERSION_3_2 ---------------------------- */\n\n#ifndef GL_VERSION_3_2\n#define GL_VERSION_3_2 1\n\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_LINES_ADJACENCY 0x000A\n#define GL_LINE_STRIP_ADJACENCY 0x000B\n#define GL_TRIANGLES_ADJACENCY 0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\n#define GL_PROGRAM_POINT_SIZE 0x8642\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_SHADER 0x8DD9\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\n#define GL_CONTEXT_PROFILE_MASK 0x9126\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum, GLenum, GLuint, GLint);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum, GLenum, GLint64 *);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum, GLuint, GLint64 *);\n\n#define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture)\n#define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v)\n#define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v)\n\n#define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2)\n\n#endif /* GL_VERSION_3_2 */\n\n/* ----------------------------- GL_VERSION_3_3 ---------------------------- */\n\n#ifndef GL_VERSION_3_3\n#define GL_VERSION_3_3 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\n#define GL_RGB10_A2UI 0x906F\n\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);\n\n#define glVertexAttribDivisor GLEW_GET_FUN(__glewVertexAttribDivisor)\n\n#define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3)\n\n#endif /* GL_VERSION_3_3 */\n\n/* ----------------------------- GL_VERSION_4_0 ---------------------------- */\n\n#ifndef GL_VERSION_4_0\n#define GL_VERSION_4_0 1\n\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\n#define GL_SAMPLE_SHADING 0x8C36\n#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F\n#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F\n\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);\ntypedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value);\n\n#define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei)\n#define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi)\n#define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei)\n#define glBlendFunci GLEW_GET_FUN(__glewBlendFunci)\n#define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading)\n\n#define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0)\n\n#endif /* GL_VERSION_4_0 */\n\n/* ----------------------------- GL_VERSION_4_1 ---------------------------- */\n\n#ifndef GL_VERSION_4_1\n#define GL_VERSION_4_1 1\n\n#define GLEW_VERSION_4_1 GLEW_GET_VAR(__GLEW_VERSION_4_1)\n\n#endif /* GL_VERSION_4_1 */\n\n/* ----------------------------- GL_VERSION_4_2 ---------------------------- */\n\n#ifndef GL_VERSION_4_2\n#define GL_VERSION_4_2 1\n\n#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F\n\n#define GLEW_VERSION_4_2 GLEW_GET_VAR(__GLEW_VERSION_4_2)\n\n#endif /* GL_VERSION_4_2 */\n\n/* ----------------------------- GL_VERSION_4_3 ---------------------------- */\n\n#ifndef GL_VERSION_4_3\n#define GL_VERSION_4_3 1\n\n#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9\n#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E\n\n#define GLEW_VERSION_4_3 GLEW_GET_VAR(__GLEW_VERSION_4_3)\n\n#endif /* GL_VERSION_4_3 */\n\n/* -------------------------- GL_3DFX_multisample -------------------------- */\n\n#ifndef GL_3DFX_multisample\n#define GL_3DFX_multisample 1\n\n#define GL_MULTISAMPLE_3DFX 0x86B2\n#define GL_SAMPLE_BUFFERS_3DFX 0x86B3\n#define GL_SAMPLES_3DFX 0x86B4\n#define GL_MULTISAMPLE_BIT_3DFX 0x20000000\n\n#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample)\n\n#endif /* GL_3DFX_multisample */\n\n/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */\n\n#ifndef GL_3DFX_tbuffer\n#define GL_3DFX_tbuffer 1\n\ntypedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);\n\n#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX)\n\n#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer)\n\n#endif /* GL_3DFX_tbuffer */\n\n/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */\n\n#ifndef GL_3DFX_texture_compression_FXT1\n#define GL_3DFX_texture_compression_FXT1 1\n\n#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0\n#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1\n\n#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1)\n\n#endif /* GL_3DFX_texture_compression_FXT1 */\n\n/* ----------------------- GL_AMD_blend_minmax_factor ---------------------- */\n\n#ifndef GL_AMD_blend_minmax_factor\n#define GL_AMD_blend_minmax_factor 1\n\n#define GL_FACTOR_MIN_AMD 0x901C\n#define GL_FACTOR_MAX_AMD 0x901D\n\n#define GLEW_AMD_blend_minmax_factor GLEW_GET_VAR(__GLEW_AMD_blend_minmax_factor)\n\n#endif /* GL_AMD_blend_minmax_factor */\n\n/* ----------------------- GL_AMD_conservative_depth ----------------------- */\n\n#ifndef GL_AMD_conservative_depth\n#define GL_AMD_conservative_depth 1\n\n#define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth)\n\n#endif /* GL_AMD_conservative_depth */\n\n/* -------------------------- GL_AMD_debug_output -------------------------- */\n\n#ifndef GL_AMD_debug_output\n#define GL_AMD_debug_output 1\n\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144\n#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145\n#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147\n#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148\n#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149\n#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A\n#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B\n#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C\n#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D\n#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E\n#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F\n#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150\n\ntypedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);\n\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void* userParam);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf);\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message);\n\n#define glDebugMessageCallbackAMD GLEW_GET_FUN(__glewDebugMessageCallbackAMD)\n#define glDebugMessageEnableAMD GLEW_GET_FUN(__glewDebugMessageEnableAMD)\n#define glDebugMessageInsertAMD GLEW_GET_FUN(__glewDebugMessageInsertAMD)\n#define glGetDebugMessageLogAMD GLEW_GET_FUN(__glewGetDebugMessageLogAMD)\n\n#define GLEW_AMD_debug_output GLEW_GET_VAR(__GLEW_AMD_debug_output)\n\n#endif /* GL_AMD_debug_output */\n\n/* ---------------------- GL_AMD_depth_clamp_separate ---------------------- */\n\n#ifndef GL_AMD_depth_clamp_separate\n#define GL_AMD_depth_clamp_separate 1\n\n#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E\n#define GL_DEPTH_CLAMP_FAR_AMD 0x901F\n\n#define GLEW_AMD_depth_clamp_separate GLEW_GET_VAR(__GLEW_AMD_depth_clamp_separate)\n\n#endif /* GL_AMD_depth_clamp_separate */\n\n/* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */\n\n#ifndef GL_AMD_draw_buffers_blend\n#define GL_AMD_draw_buffers_blend 1\n\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\n\n#define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD)\n#define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD)\n#define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD)\n#define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD)\n\n#define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend)\n\n#endif /* GL_AMD_draw_buffers_blend */\n\n/* ----------------------- GL_AMD_multi_draw_indirect ---------------------- */\n\n#ifndef GL_AMD_multi_draw_indirect\n#define GL_AMD_multi_draw_indirect 1\n\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void* indirect, GLsizei primcount, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void* indirect, GLsizei primcount, GLsizei stride);\n\n#define glMultiDrawArraysIndirectAMD GLEW_GET_FUN(__glewMultiDrawArraysIndirectAMD)\n#define glMultiDrawElementsIndirectAMD GLEW_GET_FUN(__glewMultiDrawElementsIndirectAMD)\n\n#define GLEW_AMD_multi_draw_indirect GLEW_GET_VAR(__GLEW_AMD_multi_draw_indirect)\n\n#endif /* GL_AMD_multi_draw_indirect */\n\n/* ------------------------- GL_AMD_name_gen_delete ------------------------ */\n\n#ifndef GL_AMD_name_gen_delete\n#define GL_AMD_name_gen_delete 1\n\n#define GL_DATA_BUFFER_AMD 0x9151\n#define GL_PERFORMANCE_MONITOR_AMD 0x9152\n#define GL_QUERY_OBJECT_AMD 0x9153\n#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154\n#define GL_SAMPLER_OBJECT_AMD 0x9155\n\ntypedef void (GLAPIENTRY * PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint* names);\ntypedef void (GLAPIENTRY * PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint* names);\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);\n\n#define glDeleteNamesAMD GLEW_GET_FUN(__glewDeleteNamesAMD)\n#define glGenNamesAMD GLEW_GET_FUN(__glewGenNamesAMD)\n#define glIsNameAMD GLEW_GET_FUN(__glewIsNameAMD)\n\n#define GLEW_AMD_name_gen_delete GLEW_GET_VAR(__GLEW_AMD_name_gen_delete)\n\n#endif /* GL_AMD_name_gen_delete */\n\n/* ----------------------- GL_AMD_performance_monitor ---------------------- */\n\n#ifndef GL_AMD_performance_monitor\n#define GL_AMD_performance_monitor 1\n\n#define GL_COUNTER_TYPE_AMD 0x8BC0\n#define GL_COUNTER_RANGE_AMD 0x8BC1\n#define GL_UNSIGNED_INT64_AMD 0x8BC2\n#define GL_PERCENTAGE_AMD 0x8BC3\n#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4\n#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5\n#define GL_PERFMON_RESULT_AMD 0x8BC6\n\ntypedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);\ntypedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void* data);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar *counterString);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, GLchar *groupString);\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups);\ntypedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList);\n\n#define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD)\n#define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD)\n#define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD)\n#define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD)\n#define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD)\n#define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD)\n#define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD)\n#define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD)\n#define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD)\n#define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD)\n#define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD)\n\n#define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor)\n\n#endif /* GL_AMD_performance_monitor */\n\n/* -------------------------- GL_AMD_pinned_memory ------------------------- */\n\n#ifndef GL_AMD_pinned_memory\n#define GL_AMD_pinned_memory 1\n\n#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160\n\n#define GLEW_AMD_pinned_memory GLEW_GET_VAR(__GLEW_AMD_pinned_memory)\n\n#endif /* GL_AMD_pinned_memory */\n\n/* ----------------------- GL_AMD_query_buffer_object ---------------------- */\n\n#ifndef GL_AMD_query_buffer_object\n#define GL_AMD_query_buffer_object 1\n\n#define GL_QUERY_BUFFER_AMD 0x9192\n#define GL_QUERY_BUFFER_BINDING_AMD 0x9193\n#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194\n\n#define GLEW_AMD_query_buffer_object GLEW_GET_VAR(__GLEW_AMD_query_buffer_object)\n\n#endif /* GL_AMD_query_buffer_object */\n\n/* ------------------------ GL_AMD_sample_positions ------------------------ */\n\n#ifndef GL_AMD_sample_positions\n#define GL_AMD_sample_positions 1\n\n#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F\n\ntypedef void (GLAPIENTRY * PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat* val);\n\n#define glSetMultisamplefvAMD GLEW_GET_FUN(__glewSetMultisamplefvAMD)\n\n#define GLEW_AMD_sample_positions GLEW_GET_VAR(__GLEW_AMD_sample_positions)\n\n#endif /* GL_AMD_sample_positions */\n\n/* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */\n\n#ifndef GL_AMD_seamless_cubemap_per_texture\n#define GL_AMD_seamless_cubemap_per_texture 1\n\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F\n\n#define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture)\n\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n\n/* ---------------------- GL_AMD_shader_stencil_export --------------------- */\n\n#ifndef GL_AMD_shader_stencil_export\n#define GL_AMD_shader_stencil_export 1\n\n#define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export)\n\n#endif /* GL_AMD_shader_stencil_export */\n\n/* ------------------- GL_AMD_stencil_operation_extended ------------------- */\n\n#ifndef GL_AMD_stencil_operation_extended\n#define GL_AMD_stencil_operation_extended 1\n\n#define GL_SET_AMD 0x874A\n#define GL_REPLACE_VALUE_AMD 0x874B\n#define GL_STENCIL_OP_VALUE_AMD 0x874C\n#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D\n\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value);\n\n#define glStencilOpValueAMD GLEW_GET_FUN(__glewStencilOpValueAMD)\n\n#define GLEW_AMD_stencil_operation_extended GLEW_GET_VAR(__GLEW_AMD_stencil_operation_extended)\n\n#endif /* GL_AMD_stencil_operation_extended */\n\n/* ------------------------ GL_AMD_texture_texture4 ------------------------ */\n\n#ifndef GL_AMD_texture_texture4\n#define GL_AMD_texture_texture4 1\n\n#define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4)\n\n#endif /* GL_AMD_texture_texture4 */\n\n/* --------------- GL_AMD_transform_feedback3_lines_triangles -------------- */\n\n#ifndef GL_AMD_transform_feedback3_lines_triangles\n#define GL_AMD_transform_feedback3_lines_triangles 1\n\n#define GLEW_AMD_transform_feedback3_lines_triangles GLEW_GET_VAR(__GLEW_AMD_transform_feedback3_lines_triangles)\n\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n\n/* ----------------------- GL_AMD_vertex_shader_layer ---------------------- */\n\n#ifndef GL_AMD_vertex_shader_layer\n#define GL_AMD_vertex_shader_layer 1\n\n#define GLEW_AMD_vertex_shader_layer GLEW_GET_VAR(__GLEW_AMD_vertex_shader_layer)\n\n#endif /* GL_AMD_vertex_shader_layer */\n\n/* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */\n\n#ifndef GL_AMD_vertex_shader_tessellator\n#define GL_AMD_vertex_shader_tessellator 1\n\n#define GL_SAMPLER_BUFFER_AMD 0x9001\n#define GL_INT_SAMPLER_BUFFER_AMD 0x9002\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003\n#define GL_TESSELLATION_MODE_AMD 0x9004\n#define GL_TESSELLATION_FACTOR_AMD 0x9005\n#define GL_DISCRETE_AMD 0x9006\n#define GL_CONTINUOUS_AMD 0x9007\n\ntypedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);\ntypedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);\n\n#define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD)\n#define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD)\n\n#define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator)\n\n#endif /* GL_AMD_vertex_shader_tessellator */\n\n/* ------------------ GL_AMD_vertex_shader_viewport_index ------------------ */\n\n#ifndef GL_AMD_vertex_shader_viewport_index\n#define GL_AMD_vertex_shader_viewport_index 1\n\n#define GLEW_AMD_vertex_shader_viewport_index GLEW_GET_VAR(__GLEW_AMD_vertex_shader_viewport_index)\n\n#endif /* GL_AMD_vertex_shader_viewport_index */\n\n/* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */\n\n#ifndef GL_APPLE_aux_depth_stencil\n#define GL_APPLE_aux_depth_stencil 1\n\n#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14\n\n#define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil)\n\n#endif /* GL_APPLE_aux_depth_stencil */\n\n/* ------------------------ GL_APPLE_client_storage ------------------------ */\n\n#ifndef GL_APPLE_client_storage\n#define GL_APPLE_client_storage 1\n\n#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2\n\n#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage)\n\n#endif /* GL_APPLE_client_storage */\n\n/* ------------------------- GL_APPLE_element_array ------------------------ */\n\n#ifndef GL_APPLE_element_array\n#define GL_APPLE_element_array 1\n\n#define GL_ELEMENT_ARRAY_APPLE 0x8A0C\n#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D\n#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E\n\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount);\n\n#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE)\n#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE)\n#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE)\n#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE)\n#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE)\n\n#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array)\n\n#endif /* GL_APPLE_element_array */\n\n/* ----------------------------- GL_APPLE_fence ---------------------------- */\n\n#ifndef GL_APPLE_fence\n#define GL_APPLE_fence 1\n\n#define GL_DRAW_PIXELS_APPLE 0x8A0A\n#define GL_FENCE_APPLE 0x8A0B\n\ntypedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences);\ntypedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);\ntypedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);\ntypedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences);\ntypedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence);\ntypedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence);\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence);\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);\n\n#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE)\n#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE)\n#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE)\n#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE)\n#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE)\n#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE)\n#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE)\n#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE)\n\n#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence)\n\n#endif /* GL_APPLE_fence */\n\n/* ------------------------- GL_APPLE_float_pixels ------------------------- */\n\n#ifndef GL_APPLE_float_pixels\n#define GL_APPLE_float_pixels 1\n\n#define GL_HALF_APPLE 0x140B\n#define GL_RGBA_FLOAT32_APPLE 0x8814\n#define GL_RGB_FLOAT32_APPLE 0x8815\n#define GL_ALPHA_FLOAT32_APPLE 0x8816\n#define GL_INTENSITY_FLOAT32_APPLE 0x8817\n#define GL_LUMINANCE_FLOAT32_APPLE 0x8818\n#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819\n#define GL_RGBA_FLOAT16_APPLE 0x881A\n#define GL_RGB_FLOAT16_APPLE 0x881B\n#define GL_ALPHA_FLOAT16_APPLE 0x881C\n#define GL_INTENSITY_FLOAT16_APPLE 0x881D\n#define GL_LUMINANCE_FLOAT16_APPLE 0x881E\n#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F\n#define GL_COLOR_FLOAT_APPLE 0x8A0F\n\n#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels)\n\n#endif /* GL_APPLE_float_pixels */\n\n/* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */\n\n#ifndef GL_APPLE_flush_buffer_range\n#define GL_APPLE_flush_buffer_range 1\n\n#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12\n#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13\n\ntypedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);\n\n#define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE)\n#define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE)\n\n#define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range)\n\n#endif /* GL_APPLE_flush_buffer_range */\n\n/* ----------------------- GL_APPLE_object_purgeable ----------------------- */\n\n#ifndef GL_APPLE_object_purgeable\n#define GL_APPLE_object_purgeable 1\n\n#define GL_BUFFER_OBJECT_APPLE 0x85B3\n#define GL_RELEASED_APPLE 0x8A19\n#define GL_VOLATILE_APPLE 0x8A1A\n#define GL_RETAINED_APPLE 0x8A1B\n#define GL_UNDEFINED_APPLE 0x8A1C\n#define GL_PURGEABLE_APPLE 0x8A1D\n\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params);\ntypedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\ntypedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\n\n#define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE)\n#define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE)\n#define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE)\n\n#define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable)\n\n#endif /* GL_APPLE_object_purgeable */\n\n/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */\n\n#ifndef GL_APPLE_pixel_buffer\n#define GL_APPLE_pixel_buffer 1\n\n#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10\n\n#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer)\n\n#endif /* GL_APPLE_pixel_buffer */\n\n/* ---------------------------- GL_APPLE_rgb_422 --------------------------- */\n\n#ifndef GL_APPLE_rgb_422\n#define GL_APPLE_rgb_422 1\n\n#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB\n#define GL_RGB_422_APPLE 0x8A1F\n\n#define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422)\n\n#endif /* GL_APPLE_rgb_422 */\n\n/* --------------------------- GL_APPLE_row_bytes -------------------------- */\n\n#ifndef GL_APPLE_row_bytes\n#define GL_APPLE_row_bytes 1\n\n#define GL_PACK_ROW_BYTES_APPLE 0x8A15\n#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16\n\n#define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes)\n\n#endif /* GL_APPLE_row_bytes */\n\n/* ------------------------ GL_APPLE_specular_vector ----------------------- */\n\n#ifndef GL_APPLE_specular_vector\n#define GL_APPLE_specular_vector 1\n\n#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0\n\n#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector)\n\n#endif /* GL_APPLE_specular_vector */\n\n/* ------------------------- GL_APPLE_texture_range ------------------------ */\n\n#ifndef GL_APPLE_texture_range\n#define GL_APPLE_texture_range 1\n\n#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7\n#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8\n#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC\n#define GL_STORAGE_PRIVATE_APPLE 0x85BD\n#define GL_STORAGE_CACHED_APPLE 0x85BE\n#define GL_STORAGE_SHARED_APPLE 0x85BF\n\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params);\ntypedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer);\n\n#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE)\n#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE)\n\n#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range)\n\n#endif /* GL_APPLE_texture_range */\n\n/* ------------------------ GL_APPLE_transform_hint ------------------------ */\n\n#ifndef GL_APPLE_transform_hint\n#define GL_APPLE_transform_hint 1\n\n#define GL_TRANSFORM_HINT_APPLE 0x85B1\n\n#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint)\n\n#endif /* GL_APPLE_transform_hint */\n\n/* ---------------------- GL_APPLE_vertex_array_object --------------------- */\n\n#ifndef GL_APPLE_vertex_array_object\n#define GL_APPLE_vertex_array_object 1\n\n#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5\n\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays);\ntypedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays);\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);\n\n#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE)\n#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE)\n#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE)\n#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE)\n\n#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object)\n\n#endif /* GL_APPLE_vertex_array_object */\n\n/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */\n\n#ifndef GL_APPLE_vertex_array_range\n#define GL_APPLE_vertex_array_range 1\n\n#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E\n#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F\n#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520\n#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521\n#define GL_STORAGE_CLIENT_APPLE 0x85B4\n#define GL_STORAGE_CACHED_APPLE 0x85BE\n#define GL_STORAGE_SHARED_APPLE 0x85BF\n\ntypedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer);\n\n#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE)\n#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE)\n#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE)\n\n#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range)\n\n#endif /* GL_APPLE_vertex_array_range */\n\n/* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */\n\n#ifndef GL_APPLE_vertex_program_evaluators\n#define GL_APPLE_vertex_program_evaluators 1\n\n#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00\n#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01\n#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02\n#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03\n#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04\n#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05\n#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06\n#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07\n#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08\n#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09\n\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points);\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points);\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points);\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points);\n\n#define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE)\n#define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE)\n#define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE)\n#define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE)\n#define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE)\n#define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE)\n#define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE)\n\n#define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators)\n\n#endif /* GL_APPLE_vertex_program_evaluators */\n\n/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */\n\n#ifndef GL_APPLE_ycbcr_422\n#define GL_APPLE_ycbcr_422 1\n\n#define GL_YCBCR_422_APPLE 0x85B9\n\n#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422)\n\n#endif /* GL_APPLE_ycbcr_422 */\n\n/* ------------------------ GL_ARB_ES2_compatibility ----------------------- */\n\n#ifndef GL_ARB_ES2_compatibility\n#define GL_ARB_ES2_compatibility 1\n\n#define GL_FIXED 0x140C\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B\n#define GL_RGB565 0x8D62\n#define GL_LOW_FLOAT 0x8DF0\n#define GL_MEDIUM_FLOAT 0x8DF1\n#define GL_HIGH_FLOAT 0x8DF2\n#define GL_LOW_INT 0x8DF3\n#define GL_MEDIUM_INT 0x8DF4\n#define GL_HIGH_INT 0x8DF5\n#define GL_SHADER_BINARY_FORMATS 0x8DF8\n#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9\n#define GL_SHADER_COMPILER 0x8DFA\n#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB\n#define GL_MAX_VARYING_VECTORS 0x8DFC\n#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD\n\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d);\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f);\ntypedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision);\ntypedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const GLvoid*binary, GLsizei length);\n\n#define glClearDepthf GLEW_GET_FUN(__glewClearDepthf)\n#define glDepthRangef GLEW_GET_FUN(__glewDepthRangef)\n#define glGetShaderPrecisionFormat GLEW_GET_FUN(__glewGetShaderPrecisionFormat)\n#define glReleaseShaderCompiler GLEW_GET_FUN(__glewReleaseShaderCompiler)\n#define glShaderBinary GLEW_GET_FUN(__glewShaderBinary)\n\n#define GLEW_ARB_ES2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES2_compatibility)\n\n#endif /* GL_ARB_ES2_compatibility */\n\n/* ------------------------ GL_ARB_ES3_compatibility ----------------------- */\n\n#ifndef GL_ARB_ES3_compatibility\n#define GL_ARB_ES3_compatibility 1\n\n#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69\n#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A\n#define GL_MAX_ELEMENT_INDEX 0x8D6B\n#define GL_COMPRESSED_R11_EAC 0x9270\n#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271\n#define GL_COMPRESSED_RG11_EAC 0x9272\n#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273\n#define GL_COMPRESSED_RGB8_ETC2 0x9274\n#define GL_COMPRESSED_SRGB8_ETC2 0x9275\n#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276\n#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277\n#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278\n#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279\n\n#define GLEW_ARB_ES3_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_compatibility)\n\n#endif /* GL_ARB_ES3_compatibility */\n\n/* ------------------------ GL_ARB_arrays_of_arrays ------------------------ */\n\n#ifndef GL_ARB_arrays_of_arrays\n#define GL_ARB_arrays_of_arrays 1\n\n#define GLEW_ARB_arrays_of_arrays GLEW_GET_VAR(__GLEW_ARB_arrays_of_arrays)\n\n#endif /* GL_ARB_arrays_of_arrays */\n\n/* -------------------------- GL_ARB_base_instance ------------------------- */\n\n#ifndef GL_ARB_base_instance\n#define GL_ARB_base_instance 1\n\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLuint baseinstance);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);\n\n#define glDrawArraysInstancedBaseInstance GLEW_GET_FUN(__glewDrawArraysInstancedBaseInstance)\n#define glDrawElementsInstancedBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseInstance)\n#define glDrawElementsInstancedBaseVertexBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertexBaseInstance)\n\n#define GLEW_ARB_base_instance GLEW_GET_VAR(__GLEW_ARB_base_instance)\n\n#endif /* GL_ARB_base_instance */\n\n/* ----------------------- GL_ARB_blend_func_extended ---------------------- */\n\n#ifndef GL_ARB_blend_func_extended\n#define GL_ARB_blend_func_extended 1\n\n#define GL_SRC1_COLOR 0x88F9\n#define GL_ONE_MINUS_SRC1_COLOR 0x88FA\n#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC\n\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar * name);\n\n#define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed)\n#define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex)\n\n#define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended)\n\n#endif /* GL_ARB_blend_func_extended */\n\n/* ---------------------------- GL_ARB_cl_event ---------------------------- */\n\n#ifndef GL_ARB_cl_event\n#define GL_ARB_cl_event 1\n\n#define GL_SYNC_CL_EVENT_ARB 0x8240\n#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241\n\ntypedef struct _cl_context *cl_context;\ntypedef struct _cl_event *cl_event;\n\ntypedef GLsync (GLAPIENTRY * PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags);\n\n#define glCreateSyncFromCLeventARB GLEW_GET_FUN(__glewCreateSyncFromCLeventARB)\n\n#define GLEW_ARB_cl_event GLEW_GET_VAR(__GLEW_ARB_cl_event)\n\n#endif /* GL_ARB_cl_event */\n\n/* ----------------------- GL_ARB_clear_buffer_object ---------------------- */\n\n#ifndef GL_ARB_clear_buffer_object\n#define GL_ARB_clear_buffer_object 1\n\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid* data);\n\n#define glClearBufferData GLEW_GET_FUN(__glewClearBufferData)\n#define glClearBufferSubData GLEW_GET_FUN(__glewClearBufferSubData)\n#define glClearNamedBufferDataEXT GLEW_GET_FUN(__glewClearNamedBufferDataEXT)\n#define glClearNamedBufferSubDataEXT GLEW_GET_FUN(__glewClearNamedBufferSubDataEXT)\n\n#define GLEW_ARB_clear_buffer_object GLEW_GET_VAR(__GLEW_ARB_clear_buffer_object)\n\n#endif /* GL_ARB_clear_buffer_object */\n\n/* ----------------------- GL_ARB_color_buffer_float ----------------------- */\n\n#ifndef GL_ARB_color_buffer_float\n#define GL_ARB_color_buffer_float 1\n\n#define GL_RGBA_FLOAT_MODE_ARB 0x8820\n#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A\n#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B\n#define GL_CLAMP_READ_COLOR_ARB 0x891C\n#define GL_FIXED_ONLY_ARB 0x891D\n\ntypedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);\n\n#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB)\n\n#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float)\n\n#endif /* GL_ARB_color_buffer_float */\n\n/* -------------------------- GL_ARB_compatibility ------------------------- */\n\n#ifndef GL_ARB_compatibility\n#define GL_ARB_compatibility 1\n\n#define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility)\n\n#endif /* GL_ARB_compatibility */\n\n/* ---------------- GL_ARB_compressed_texture_pixel_storage ---------------- */\n\n#ifndef GL_ARB_compressed_texture_pixel_storage\n#define GL_ARB_compressed_texture_pixel_storage 1\n\n#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127\n#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128\n#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129\n#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A\n#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B\n#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C\n#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D\n#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E\n\n#define GLEW_ARB_compressed_texture_pixel_storage GLEW_GET_VAR(__GLEW_ARB_compressed_texture_pixel_storage)\n\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n\n/* ------------------------- GL_ARB_compute_shader ------------------------- */\n\n#ifndef GL_ARB_compute_shader\n#define GL_ARB_compute_shader 1\n\n#define GL_COMPUTE_SHADER_BIT 0x00000020\n#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262\n#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263\n#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264\n#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265\n#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266\n#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267\n#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED\n#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE\n#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF\n#define GL_COMPUTE_SHADER 0x91B9\n#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB\n#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC\n#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD\n#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE\n#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF\n\ntypedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);\ntypedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect);\n\n#define glDispatchCompute GLEW_GET_FUN(__glewDispatchCompute)\n#define glDispatchComputeIndirect GLEW_GET_FUN(__glewDispatchComputeIndirect)\n\n#define GLEW_ARB_compute_shader GLEW_GET_VAR(__GLEW_ARB_compute_shader)\n\n#endif /* GL_ARB_compute_shader */\n\n/* ----------------------- GL_ARB_conservative_depth ----------------------- */\n\n#ifndef GL_ARB_conservative_depth\n#define GL_ARB_conservative_depth 1\n\n#define GLEW_ARB_conservative_depth GLEW_GET_VAR(__GLEW_ARB_conservative_depth)\n\n#endif /* GL_ARB_conservative_depth */\n\n/* --------------------------- GL_ARB_copy_buffer -------------------------- */\n\n#ifndef GL_ARB_copy_buffer\n#define GL_ARB_copy_buffer 1\n\n#define GL_COPY_READ_BUFFER 0x8F36\n#define GL_COPY_WRITE_BUFFER 0x8F37\n\ntypedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size);\n\n#define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData)\n\n#define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer)\n\n#endif /* GL_ARB_copy_buffer */\n\n/* --------------------------- GL_ARB_copy_image --------------------------- */\n\n#ifndef GL_ARB_copy_image\n#define GL_ARB_copy_image 1\n\ntypedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);\n\n#define glCopyImageSubData GLEW_GET_FUN(__glewCopyImageSubData)\n\n#define GLEW_ARB_copy_image GLEW_GET_VAR(__GLEW_ARB_copy_image)\n\n#endif /* GL_ARB_copy_image */\n\n/* -------------------------- GL_ARB_debug_output -------------------------- */\n\n#ifndef GL_ARB_debug_output\n#define GL_ARB_debug_output 1\n\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243\n#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244\n#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245\n#define GL_DEBUG_SOURCE_API_ARB 0x8246\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247\n#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248\n#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249\n#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A\n#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B\n#define GL_DEBUG_TYPE_ERROR_ARB 0x824C\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E\n#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F\n#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250\n#define GL_DEBUG_TYPE_OTHER_ARB 0x8251\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144\n#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145\n#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147\n#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148\n\ntypedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);\n\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, void* userParam);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);\n\n#define glDebugMessageCallbackARB GLEW_GET_FUN(__glewDebugMessageCallbackARB)\n#define glDebugMessageControlARB GLEW_GET_FUN(__glewDebugMessageControlARB)\n#define glDebugMessageInsertARB GLEW_GET_FUN(__glewDebugMessageInsertARB)\n#define glGetDebugMessageLogARB GLEW_GET_FUN(__glewGetDebugMessageLogARB)\n\n#define GLEW_ARB_debug_output GLEW_GET_VAR(__GLEW_ARB_debug_output)\n\n#endif /* GL_ARB_debug_output */\n\n/* ----------------------- GL_ARB_depth_buffer_float ----------------------- */\n\n#ifndef GL_ARB_depth_buffer_float\n#define GL_ARB_depth_buffer_float 1\n\n#define GL_DEPTH_COMPONENT32F 0x8CAC\n#define GL_DEPTH32F_STENCIL8 0x8CAD\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n\n#define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float)\n\n#endif /* GL_ARB_depth_buffer_float */\n\n/* --------------------------- GL_ARB_depth_clamp -------------------------- */\n\n#ifndef GL_ARB_depth_clamp\n#define GL_ARB_depth_clamp 1\n\n#define GL_DEPTH_CLAMP 0x864F\n\n#define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp)\n\n#endif /* GL_ARB_depth_clamp */\n\n/* -------------------------- GL_ARB_depth_texture ------------------------- */\n\n#ifndef GL_ARB_depth_texture\n#define GL_ARB_depth_texture 1\n\n#define GL_DEPTH_COMPONENT16_ARB 0x81A5\n#define GL_DEPTH_COMPONENT24_ARB 0x81A6\n#define GL_DEPTH_COMPONENT32_ARB 0x81A7\n#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A\n#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B\n\n#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture)\n\n#endif /* GL_ARB_depth_texture */\n\n/* -------------------------- GL_ARB_draw_buffers -------------------------- */\n\n#ifndef GL_ARB_draw_buffers\n#define GL_ARB_draw_buffers 1\n\n#define GL_MAX_DRAW_BUFFERS_ARB 0x8824\n#define GL_DRAW_BUFFER0_ARB 0x8825\n#define GL_DRAW_BUFFER1_ARB 0x8826\n#define GL_DRAW_BUFFER2_ARB 0x8827\n#define GL_DRAW_BUFFER3_ARB 0x8828\n#define GL_DRAW_BUFFER4_ARB 0x8829\n#define GL_DRAW_BUFFER5_ARB 0x882A\n#define GL_DRAW_BUFFER6_ARB 0x882B\n#define GL_DRAW_BUFFER7_ARB 0x882C\n#define GL_DRAW_BUFFER8_ARB 0x882D\n#define GL_DRAW_BUFFER9_ARB 0x882E\n#define GL_DRAW_BUFFER10_ARB 0x882F\n#define GL_DRAW_BUFFER11_ARB 0x8830\n#define GL_DRAW_BUFFER12_ARB 0x8831\n#define GL_DRAW_BUFFER13_ARB 0x8832\n#define GL_DRAW_BUFFER14_ARB 0x8833\n#define GL_DRAW_BUFFER15_ARB 0x8834\n\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs);\n\n#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB)\n\n#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers)\n\n#endif /* GL_ARB_draw_buffers */\n\n/* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */\n\n#ifndef GL_ARB_draw_buffers_blend\n#define GL_ARB_draw_buffers_blend 1\n\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);\n\n#define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB)\n#define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB)\n#define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB)\n#define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB)\n\n#define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend)\n\n#endif /* GL_ARB_draw_buffers_blend */\n\n/* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */\n\n#ifndef GL_ARB_draw_elements_base_vertex\n#define GL_ARB_draw_elements_base_vertex 1\n\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, void* indices, GLint basevertex);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLint basevertex);\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, void* indices, GLint basevertex);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei* count, GLenum type, GLvoid**indices, GLsizei primcount, GLint *basevertex);\n\n#define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex)\n#define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex)\n#define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex)\n#define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex)\n\n#define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex)\n\n#endif /* GL_ARB_draw_elements_base_vertex */\n\n/* -------------------------- GL_ARB_draw_indirect ------------------------- */\n\n#ifndef GL_ARB_draw_indirect\n#define GL_ARB_draw_indirect 1\n\n#define GL_DRAW_INDIRECT_BUFFER 0x8F3F\n#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43\n\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void* indirect);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void* indirect);\n\n#define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect)\n#define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect)\n\n#define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect)\n\n#endif /* GL_ARB_draw_indirect */\n\n/* ------------------------- GL_ARB_draw_instanced ------------------------- */\n\n#ifndef GL_ARB_draw_instanced\n#define GL_ARB_draw_instanced 1\n\n#define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced)\n\n#endif /* GL_ARB_draw_instanced */\n\n/* -------------------- GL_ARB_explicit_attrib_location -------------------- */\n\n#ifndef GL_ARB_explicit_attrib_location\n#define GL_ARB_explicit_attrib_location 1\n\n#define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location)\n\n#endif /* GL_ARB_explicit_attrib_location */\n\n/* -------------------- GL_ARB_explicit_uniform_location ------------------- */\n\n#ifndef GL_ARB_explicit_uniform_location\n#define GL_ARB_explicit_uniform_location 1\n\n#define GL_MAX_UNIFORM_LOCATIONS 0x826E\n\n#define GLEW_ARB_explicit_uniform_location GLEW_GET_VAR(__GLEW_ARB_explicit_uniform_location)\n\n#endif /* GL_ARB_explicit_uniform_location */\n\n/* ------------------- GL_ARB_fragment_coord_conventions ------------------- */\n\n#ifndef GL_ARB_fragment_coord_conventions\n#define GL_ARB_fragment_coord_conventions 1\n\n#define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions)\n\n#endif /* GL_ARB_fragment_coord_conventions */\n\n/* --------------------- GL_ARB_fragment_layer_viewport -------------------- */\n\n#ifndef GL_ARB_fragment_layer_viewport\n#define GL_ARB_fragment_layer_viewport 1\n\n#define GLEW_ARB_fragment_layer_viewport GLEW_GET_VAR(__GLEW_ARB_fragment_layer_viewport)\n\n#endif /* GL_ARB_fragment_layer_viewport */\n\n/* ------------------------ GL_ARB_fragment_program ------------------------ */\n\n#ifndef GL_ARB_fragment_program\n#define GL_ARB_fragment_program 1\n\n#define GL_FRAGMENT_PROGRAM_ARB 0x8804\n#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805\n#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806\n#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807\n#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808\n#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809\n#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A\n#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B\n#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C\n#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D\n#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E\n#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F\n#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810\n#define GL_MAX_TEXTURE_COORDS_ARB 0x8871\n#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872\n\n#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program)\n\n#endif /* GL_ARB_fragment_program */\n\n/* --------------------- GL_ARB_fragment_program_shadow -------------------- */\n\n#ifndef GL_ARB_fragment_program_shadow\n#define GL_ARB_fragment_program_shadow 1\n\n#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow)\n\n#endif /* GL_ARB_fragment_program_shadow */\n\n/* ------------------------- GL_ARB_fragment_shader ------------------------ */\n\n#ifndef GL_ARB_fragment_shader\n#define GL_ARB_fragment_shader 1\n\n#define GL_FRAGMENT_SHADER_ARB 0x8B30\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B\n\n#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader)\n\n#endif /* GL_ARB_fragment_shader */\n\n/* ------------------- GL_ARB_framebuffer_no_attachments ------------------- */\n\n#ifndef GL_ARB_framebuffer_no_attachments\n#define GL_ARB_framebuffer_no_attachments 1\n\n#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310\n#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311\n#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312\n#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313\n#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314\n#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315\n#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316\n#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317\n#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param);\n\n#define glFramebufferParameteri GLEW_GET_FUN(__glewFramebufferParameteri)\n#define glGetFramebufferParameteriv GLEW_GET_FUN(__glewGetFramebufferParameteriv)\n#define glGetNamedFramebufferParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferParameterivEXT)\n#define glNamedFramebufferParameteriEXT GLEW_GET_FUN(__glewNamedFramebufferParameteriEXT)\n\n#define GLEW_ARB_framebuffer_no_attachments GLEW_GET_VAR(__GLEW_ARB_framebuffer_no_attachments)\n\n#endif /* GL_ARB_framebuffer_no_attachments */\n\n/* ----------------------- GL_ARB_framebuffer_object ----------------------- */\n\n#ifndef GL_ARB_framebuffer_object\n#define GL_ARB_framebuffer_object 1\n\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\n#define GL_INDEX 0x8222\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\n#define GL_DEPTH_STENCIL 0x84F9\n#define GL_UNSIGNED_INT_24_8 0x84FA\n#define GL_DEPTH24_STENCIL8 0x88F0\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\n#define GL_UNSIGNED_NORMALIZED 0x8C17\n#define GL_SRGB 0x8C40\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_RENDERBUFFER_BINDING 0x8CA7\n#define GL_READ_FRAMEBUFFER 0x8CA8\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\n#define GL_COLOR_ATTACHMENT0 0x8CE0\n#define GL_COLOR_ATTACHMENT1 0x8CE1\n#define GL_COLOR_ATTACHMENT2 0x8CE2\n#define GL_COLOR_ATTACHMENT3 0x8CE3\n#define GL_COLOR_ATTACHMENT4 0x8CE4\n#define GL_COLOR_ATTACHMENT5 0x8CE5\n#define GL_COLOR_ATTACHMENT6 0x8CE6\n#define GL_COLOR_ATTACHMENT7 0x8CE7\n#define GL_COLOR_ATTACHMENT8 0x8CE8\n#define GL_COLOR_ATTACHMENT9 0x8CE9\n#define GL_COLOR_ATTACHMENT10 0x8CEA\n#define GL_COLOR_ATTACHMENT11 0x8CEB\n#define GL_COLOR_ATTACHMENT12 0x8CEC\n#define GL_COLOR_ATTACHMENT13 0x8CED\n#define GL_COLOR_ATTACHMENT14 0x8CEE\n#define GL_COLOR_ATTACHMENT15 0x8CEF\n#define GL_DEPTH_ATTACHMENT 0x8D00\n#define GL_STENCIL_ATTACHMENT 0x8D20\n#define GL_FRAMEBUFFER 0x8D40\n#define GL_RENDERBUFFER 0x8D41\n#define GL_RENDERBUFFER_WIDTH 0x8D42\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\n#define GL_STENCIL_INDEX1 0x8D46\n#define GL_STENCIL_INDEX4 0x8D47\n#define GL_STENCIL_INDEX8 0x8D48\n#define GL_STENCIL_INDEX16 0x8D49\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_MAX_SAMPLES 0x8D57\n\ntypedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);\ntypedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);\ntypedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);\ntypedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers);\ntypedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers);\ntypedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);\ntypedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n\n#define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer)\n#define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer)\n#define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer)\n#define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus)\n#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)\n#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)\n#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)\n#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)\n#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)\n#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)\n#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)\n#define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers)\n#define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers)\n#define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap)\n#define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv)\n#define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv)\n#define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer)\n#define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer)\n#define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage)\n#define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample)\n\n#define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object)\n\n#endif /* GL_ARB_framebuffer_object */\n\n/* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */\n\n#ifndef GL_ARB_framebuffer_sRGB\n#define GL_ARB_framebuffer_sRGB 1\n\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\n\n#define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB)\n\n#endif /* GL_ARB_framebuffer_sRGB */\n\n/* ------------------------ GL_ARB_geometry_shader4 ------------------------ */\n\n#ifndef GL_ARB_geometry_shader4\n#define GL_ARB_geometry_shader4 1\n\n#define GL_LINES_ADJACENCY_ARB 0xA\n#define GL_LINE_STRIP_ADJACENCY_ARB 0xB\n#define GL_TRIANGLES_ADJACENCY_ARB 0xC\n#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD\n#define GL_PROGRAM_POINT_SIZE_ARB 0x8642\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9\n#define GL_GEOMETRY_SHADER_ARB 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA\n#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB\n#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);\n\n#define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB)\n#define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB)\n#define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB)\n#define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB)\n\n#define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4)\n\n#endif /* GL_ARB_geometry_shader4 */\n\n/* ----------------------- GL_ARB_get_program_binary ----------------------- */\n\n#ifndef GL_ARB_get_program_binary\n#define GL_ARB_get_program_binary 1\n\n#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257\n#define GL_PROGRAM_BINARY_LENGTH 0x8741\n#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE\n#define GL_PROGRAM_BINARY_FORMATS 0x87FF\n\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, GLvoid*binary);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void* binary, GLsizei length);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);\n\n#define glGetProgramBinary GLEW_GET_FUN(__glewGetProgramBinary)\n#define glProgramBinary GLEW_GET_FUN(__glewProgramBinary)\n#define glProgramParameteri GLEW_GET_FUN(__glewProgramParameteri)\n\n#define GLEW_ARB_get_program_binary GLEW_GET_VAR(__GLEW_ARB_get_program_binary)\n\n#endif /* GL_ARB_get_program_binary */\n\n/* --------------------------- GL_ARB_gpu_shader5 -------------------------- */\n\n#ifndef GL_ARB_gpu_shader5\n#define GL_ARB_gpu_shader5 1\n\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\n#define GL_MAX_VERTEX_STREAMS 0x8E71\n\n#define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5)\n\n#endif /* GL_ARB_gpu_shader5 */\n\n/* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */\n\n#ifndef GL_ARB_gpu_shader_fp64\n#define GL_ARB_gpu_shader_fp64 1\n\n#define GL_DOUBLE_MAT2 0x8F46\n#define GL_DOUBLE_MAT3 0x8F47\n#define GL_DOUBLE_MAT4 0x8F48\n#define GL_DOUBLE_MAT2x3 0x8F49\n#define GL_DOUBLE_MAT2x4 0x8F4A\n#define GL_DOUBLE_MAT3x2 0x8F4B\n#define GL_DOUBLE_MAT3x4 0x8F4C\n#define GL_DOUBLE_MAT4x2 0x8F4D\n#define GL_DOUBLE_MAT4x3 0x8F4E\n#define GL_DOUBLE_VEC2 0x8FFC\n#define GL_DOUBLE_VEC3 0x8FFD\n#define GL_DOUBLE_VEC4 0x8FFE\n\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\n\n#define glGetUniformdv GLEW_GET_FUN(__glewGetUniformdv)\n#define glUniform1d GLEW_GET_FUN(__glewUniform1d)\n#define glUniform1dv GLEW_GET_FUN(__glewUniform1dv)\n#define glUniform2d GLEW_GET_FUN(__glewUniform2d)\n#define glUniform2dv GLEW_GET_FUN(__glewUniform2dv)\n#define glUniform3d GLEW_GET_FUN(__glewUniform3d)\n#define glUniform3dv GLEW_GET_FUN(__glewUniform3dv)\n#define glUniform4d GLEW_GET_FUN(__glewUniform4d)\n#define glUniform4dv GLEW_GET_FUN(__glewUniform4dv)\n#define glUniformMatrix2dv GLEW_GET_FUN(__glewUniformMatrix2dv)\n#define glUniformMatrix2x3dv GLEW_GET_FUN(__glewUniformMatrix2x3dv)\n#define glUniformMatrix2x4dv GLEW_GET_FUN(__glewUniformMatrix2x4dv)\n#define glUniformMatrix3dv GLEW_GET_FUN(__glewUniformMatrix3dv)\n#define glUniformMatrix3x2dv GLEW_GET_FUN(__glewUniformMatrix3x2dv)\n#define glUniformMatrix3x4dv GLEW_GET_FUN(__glewUniformMatrix3x4dv)\n#define glUniformMatrix4dv GLEW_GET_FUN(__glewUniformMatrix4dv)\n#define glUniformMatrix4x2dv GLEW_GET_FUN(__glewUniformMatrix4x2dv)\n#define glUniformMatrix4x3dv GLEW_GET_FUN(__glewUniformMatrix4x3dv)\n\n#define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64)\n\n#endif /* GL_ARB_gpu_shader_fp64 */\n\n/* ------------------------ GL_ARB_half_float_pixel ------------------------ */\n\n#ifndef GL_ARB_half_float_pixel\n#define GL_ARB_half_float_pixel 1\n\n#define GL_HALF_FLOAT_ARB 0x140B\n\n#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel)\n\n#endif /* GL_ARB_half_float_pixel */\n\n/* ------------------------ GL_ARB_half_float_vertex ----------------------- */\n\n#ifndef GL_ARB_half_float_vertex\n#define GL_ARB_half_float_vertex 1\n\n#define GL_HALF_FLOAT 0x140B\n\n#define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex)\n\n#endif /* GL_ARB_half_float_vertex */\n\n/* ----------------------------- GL_ARB_imaging ---------------------------- */\n\n#ifndef GL_ARB_imaging\n#define GL_ARB_imaging 1\n\n#define GL_CONSTANT_COLOR 0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\n#define GL_CONSTANT_ALPHA 0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\n#define GL_BLEND_COLOR 0x8005\n#define GL_FUNC_ADD 0x8006\n#define GL_MIN 0x8007\n#define GL_MAX 0x8008\n#define GL_BLEND_EQUATION 0x8009\n#define GL_FUNC_SUBTRACT 0x800A\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\n#define GL_CONVOLUTION_1D 0x8010\n#define GL_CONVOLUTION_2D 0x8011\n#define GL_SEPARABLE_2D 0x8012\n#define GL_CONVOLUTION_BORDER_MODE 0x8013\n#define GL_CONVOLUTION_FILTER_SCALE 0x8014\n#define GL_CONVOLUTION_FILTER_BIAS 0x8015\n#define GL_REDUCE 0x8016\n#define GL_CONVOLUTION_FORMAT 0x8017\n#define GL_CONVOLUTION_WIDTH 0x8018\n#define GL_CONVOLUTION_HEIGHT 0x8019\n#define GL_MAX_CONVOLUTION_WIDTH 0x801A\n#define GL_MAX_CONVOLUTION_HEIGHT 0x801B\n#define GL_POST_CONVOLUTION_RED_SCALE 0x801C\n#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D\n#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E\n#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F\n#define GL_POST_CONVOLUTION_RED_BIAS 0x8020\n#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021\n#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022\n#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023\n#define GL_HISTOGRAM 0x8024\n#define GL_PROXY_HISTOGRAM 0x8025\n#define GL_HISTOGRAM_WIDTH 0x8026\n#define GL_HISTOGRAM_FORMAT 0x8027\n#define GL_HISTOGRAM_RED_SIZE 0x8028\n#define GL_HISTOGRAM_GREEN_SIZE 0x8029\n#define GL_HISTOGRAM_BLUE_SIZE 0x802A\n#define GL_HISTOGRAM_ALPHA_SIZE 0x802B\n#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C\n#define GL_HISTOGRAM_SINK 0x802D\n#define GL_MINMAX 0x802E\n#define GL_MINMAX_FORMAT 0x802F\n#define GL_MINMAX_SINK 0x8030\n#define GL_TABLE_TOO_LARGE 0x8031\n#define GL_COLOR_MATRIX 0x80B1\n#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3\n#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7\n#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB\n#define GL_COLOR_TABLE 0x80D0\n#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2\n#define GL_PROXY_COLOR_TABLE 0x80D3\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5\n#define GL_COLOR_TABLE_SCALE 0x80D6\n#define GL_COLOR_TABLE_BIAS 0x80D7\n#define GL_COLOR_TABLE_FORMAT 0x80D8\n#define GL_COLOR_TABLE_WIDTH 0x80D9\n#define GL_COLOR_TABLE_RED_SIZE 0x80DA\n#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB\n#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC\n#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD\n#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE\n#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF\n#define GL_IGNORE_BORDER 0x8150\n#define GL_CONSTANT_BORDER 0x8151\n#define GL_WRAP_BORDER 0x8152\n#define GL_REPLICATE_BORDER 0x8153\n#define GL_CONVOLUTION_BORDER_COLOR 0x8154\n\ntypedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);\ntypedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\ntypedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);\ntypedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);\n\n#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable)\n#define glColorTable GLEW_GET_FUN(__glewColorTable)\n#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv)\n#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv)\n#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D)\n#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D)\n#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf)\n#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv)\n#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri)\n#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv)\n#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable)\n#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable)\n#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D)\n#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D)\n#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable)\n#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv)\n#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv)\n#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter)\n#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv)\n#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv)\n#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram)\n#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv)\n#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv)\n#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax)\n#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv)\n#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv)\n#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter)\n#define glHistogram GLEW_GET_FUN(__glewHistogram)\n#define glMinmax GLEW_GET_FUN(__glewMinmax)\n#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram)\n#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax)\n#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D)\n\n#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging)\n\n#endif /* GL_ARB_imaging */\n\n/* ------------------------ GL_ARB_instanced_arrays ------------------------ */\n\n#ifndef GL_ARB_instanced_arrays\n#define GL_ARB_instanced_arrays 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE\n\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);\n\n#define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB)\n#define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB)\n#define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB)\n\n#define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays)\n\n#endif /* GL_ARB_instanced_arrays */\n\n/* ---------------------- GL_ARB_internalformat_query ---------------------- */\n\n#ifndef GL_ARB_internalformat_query\n#define GL_ARB_internalformat_query 1\n\n#define GL_NUM_SAMPLE_COUNTS 0x9380\n\ntypedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);\n\n#define glGetInternalformativ GLEW_GET_FUN(__glewGetInternalformativ)\n\n#define GLEW_ARB_internalformat_query GLEW_GET_VAR(__GLEW_ARB_internalformat_query)\n\n#endif /* GL_ARB_internalformat_query */\n\n/* ---------------------- GL_ARB_internalformat_query2 --------------------- */\n\n#ifndef GL_ARB_internalformat_query2\n#define GL_ARB_internalformat_query2 1\n\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_TEXTURE_3D 0x806F\n#define GL_SAMPLES 0x80A9\n#define GL_INTERNALFORMAT_SUPPORTED 0x826F\n#define GL_INTERNALFORMAT_PREFERRED 0x8270\n#define GL_INTERNALFORMAT_RED_SIZE 0x8271\n#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272\n#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273\n#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274\n#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275\n#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276\n#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277\n#define GL_INTERNALFORMAT_RED_TYPE 0x8278\n#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279\n#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A\n#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B\n#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C\n#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D\n#define GL_MAX_WIDTH 0x827E\n#define GL_MAX_HEIGHT 0x827F\n#define GL_MAX_DEPTH 0x8280\n#define GL_MAX_LAYERS 0x8281\n#define GL_MAX_COMBINED_DIMENSIONS 0x8282\n#define GL_COLOR_COMPONENTS 0x8283\n#define GL_DEPTH_COMPONENTS 0x8284\n#define GL_STENCIL_COMPONENTS 0x8285\n#define GL_COLOR_RENDERABLE 0x8286\n#define GL_DEPTH_RENDERABLE 0x8287\n#define GL_STENCIL_RENDERABLE 0x8288\n#define GL_FRAMEBUFFER_RENDERABLE 0x8289\n#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A\n#define GL_FRAMEBUFFER_BLEND 0x828B\n#define GL_READ_PIXELS 0x828C\n#define GL_READ_PIXELS_FORMAT 0x828D\n#define GL_READ_PIXELS_TYPE 0x828E\n#define GL_TEXTURE_IMAGE_FORMAT 0x828F\n#define GL_TEXTURE_IMAGE_TYPE 0x8290\n#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291\n#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292\n#define GL_MIPMAP 0x8293\n#define GL_MANUAL_GENERATE_MIPMAP 0x8294\n#define GL_AUTO_GENERATE_MIPMAP 0x8295\n#define GL_COLOR_ENCODING 0x8296\n#define GL_SRGB_READ 0x8297\n#define GL_SRGB_WRITE 0x8298\n#define GL_SRGB_DECODE_ARB 0x8299\n#define GL_FILTER 0x829A\n#define GL_VERTEX_TEXTURE 0x829B\n#define GL_TESS_CONTROL_TEXTURE 0x829C\n#define GL_TESS_EVALUATION_TEXTURE 0x829D\n#define GL_GEOMETRY_TEXTURE 0x829E\n#define GL_FRAGMENT_TEXTURE 0x829F\n#define GL_COMPUTE_TEXTURE 0x82A0\n#define GL_TEXTURE_SHADOW 0x82A1\n#define GL_TEXTURE_GATHER 0x82A2\n#define GL_TEXTURE_GATHER_SHADOW 0x82A3\n#define GL_SHADER_IMAGE_LOAD 0x82A4\n#define GL_SHADER_IMAGE_STORE 0x82A5\n#define GL_SHADER_IMAGE_ATOMIC 0x82A6\n#define GL_IMAGE_TEXEL_SIZE 0x82A7\n#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8\n#define GL_IMAGE_PIXEL_FORMAT 0x82A9\n#define GL_IMAGE_PIXEL_TYPE 0x82AA\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF\n#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1\n#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2\n#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3\n#define GL_CLEAR_BUFFER 0x82B4\n#define GL_TEXTURE_VIEW 0x82B5\n#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6\n#define GL_FULL_SUPPORT 0x82B7\n#define GL_CAVEAT_SUPPORT 0x82B8\n#define GL_IMAGE_CLASS_4_X_32 0x82B9\n#define GL_IMAGE_CLASS_2_X_32 0x82BA\n#define GL_IMAGE_CLASS_1_X_32 0x82BB\n#define GL_IMAGE_CLASS_4_X_16 0x82BC\n#define GL_IMAGE_CLASS_2_X_16 0x82BD\n#define GL_IMAGE_CLASS_1_X_16 0x82BE\n#define GL_IMAGE_CLASS_4_X_8 0x82BF\n#define GL_IMAGE_CLASS_2_X_8 0x82C0\n#define GL_IMAGE_CLASS_1_X_8 0x82C1\n#define GL_IMAGE_CLASS_11_11_10 0x82C2\n#define GL_IMAGE_CLASS_10_10_10_2 0x82C3\n#define GL_VIEW_CLASS_128_BITS 0x82C4\n#define GL_VIEW_CLASS_96_BITS 0x82C5\n#define GL_VIEW_CLASS_64_BITS 0x82C6\n#define GL_VIEW_CLASS_48_BITS 0x82C7\n#define GL_VIEW_CLASS_32_BITS 0x82C8\n#define GL_VIEW_CLASS_24_BITS 0x82C9\n#define GL_VIEW_CLASS_16_BITS 0x82CA\n#define GL_VIEW_CLASS_8_BITS 0x82CB\n#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC\n#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD\n#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE\n#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF\n#define GL_VIEW_CLASS_RGTC1_RED 0x82D0\n#define GL_VIEW_CLASS_RGTC2_RG 0x82D1\n#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2\n#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_RENDERBUFFER 0x8D41\n#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_NUM_SAMPLE_COUNTS 0x9380\n\ntypedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64* params);\n\n#define glGetInternalformati64v GLEW_GET_FUN(__glewGetInternalformati64v)\n\n#define GLEW_ARB_internalformat_query2 GLEW_GET_VAR(__GLEW_ARB_internalformat_query2)\n\n#endif /* GL_ARB_internalformat_query2 */\n\n/* ----------------------- GL_ARB_invalidate_subdata ----------------------- */\n\n#ifndef GL_ARB_invalidate_subdata\n#define GL_ARB_invalidate_subdata 1\n\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments);\ntypedef void (GLAPIENTRY * PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);\n\n#define glInvalidateBufferData GLEW_GET_FUN(__glewInvalidateBufferData)\n#define glInvalidateBufferSubData GLEW_GET_FUN(__glewInvalidateBufferSubData)\n#define glInvalidateFramebuffer GLEW_GET_FUN(__glewInvalidateFramebuffer)\n#define glInvalidateSubFramebuffer GLEW_GET_FUN(__glewInvalidateSubFramebuffer)\n#define glInvalidateTexImage GLEW_GET_FUN(__glewInvalidateTexImage)\n#define glInvalidateTexSubImage GLEW_GET_FUN(__glewInvalidateTexSubImage)\n\n#define GLEW_ARB_invalidate_subdata GLEW_GET_VAR(__GLEW_ARB_invalidate_subdata)\n\n#endif /* GL_ARB_invalidate_subdata */\n\n/* ---------------------- GL_ARB_map_buffer_alignment ---------------------- */\n\n#ifndef GL_ARB_map_buffer_alignment\n#define GL_ARB_map_buffer_alignment 1\n\n#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC\n\n#define GLEW_ARB_map_buffer_alignment GLEW_GET_VAR(__GLEW_ARB_map_buffer_alignment)\n\n#endif /* GL_ARB_map_buffer_alignment */\n\n/* ------------------------ GL_ARB_map_buffer_range ------------------------ */\n\n#ifndef GL_ARB_map_buffer_range\n#define GL_ARB_map_buffer_range 1\n\n#define GL_MAP_READ_BIT 0x0001\n#define GL_MAP_WRITE_BIT 0x0002\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\n\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);\ntypedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\n\n#define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange)\n#define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange)\n\n#define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range)\n\n#endif /* GL_ARB_map_buffer_range */\n\n/* ------------------------- GL_ARB_matrix_palette ------------------------- */\n\n#ifndef GL_ARB_matrix_palette\n#define GL_ARB_matrix_palette 1\n\n#define GL_MATRIX_PALETTE_ARB 0x8840\n#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841\n#define GL_MAX_PALETTE_MATRICES_ARB 0x8842\n#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843\n#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844\n#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845\n#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846\n#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847\n#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848\n#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849\n\ntypedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer);\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices);\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices);\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices);\n\n#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB)\n#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB)\n#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB)\n#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB)\n#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB)\n\n#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette)\n\n#endif /* GL_ARB_matrix_palette */\n\n/* ----------------------- GL_ARB_multi_draw_indirect ---------------------- */\n\n#ifndef GL_ARB_multi_draw_indirect\n#define GL_ARB_multi_draw_indirect 1\n\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void* indirect, GLsizei primcount, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void* indirect, GLsizei primcount, GLsizei stride);\n\n#define glMultiDrawArraysIndirect GLEW_GET_FUN(__glewMultiDrawArraysIndirect)\n#define glMultiDrawElementsIndirect GLEW_GET_FUN(__glewMultiDrawElementsIndirect)\n\n#define GLEW_ARB_multi_draw_indirect GLEW_GET_VAR(__GLEW_ARB_multi_draw_indirect)\n\n#endif /* GL_ARB_multi_draw_indirect */\n\n/* --------------------------- GL_ARB_multisample -------------------------- */\n\n#ifndef GL_ARB_multisample\n#define GL_ARB_multisample 1\n\n#define GL_MULTISAMPLE_ARB 0x809D\n#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F\n#define GL_SAMPLE_COVERAGE_ARB 0x80A0\n#define GL_SAMPLE_BUFFERS_ARB 0x80A8\n#define GL_SAMPLES_ARB 0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB\n#define GL_MULTISAMPLE_BIT_ARB 0x20000000\n\ntypedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);\n\n#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB)\n\n#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample)\n\n#endif /* GL_ARB_multisample */\n\n/* -------------------------- GL_ARB_multitexture -------------------------- */\n\n#ifndef GL_ARB_multitexture\n#define GL_ARB_multitexture 1\n\n#define GL_TEXTURE0_ARB 0x84C0\n#define GL_TEXTURE1_ARB 0x84C1\n#define GL_TEXTURE2_ARB 0x84C2\n#define GL_TEXTURE3_ARB 0x84C3\n#define GL_TEXTURE4_ARB 0x84C4\n#define GL_TEXTURE5_ARB 0x84C5\n#define GL_TEXTURE6_ARB 0x84C6\n#define GL_TEXTURE7_ARB 0x84C7\n#define GL_TEXTURE8_ARB 0x84C8\n#define GL_TEXTURE9_ARB 0x84C9\n#define GL_TEXTURE10_ARB 0x84CA\n#define GL_TEXTURE11_ARB 0x84CB\n#define GL_TEXTURE12_ARB 0x84CC\n#define GL_TEXTURE13_ARB 0x84CD\n#define GL_TEXTURE14_ARB 0x84CE\n#define GL_TEXTURE15_ARB 0x84CF\n#define GL_TEXTURE16_ARB 0x84D0\n#define GL_TEXTURE17_ARB 0x84D1\n#define GL_TEXTURE18_ARB 0x84D2\n#define GL_TEXTURE19_ARB 0x84D3\n#define GL_TEXTURE20_ARB 0x84D4\n#define GL_TEXTURE21_ARB 0x84D5\n#define GL_TEXTURE22_ARB 0x84D6\n#define GL_TEXTURE23_ARB 0x84D7\n#define GL_TEXTURE24_ARB 0x84D8\n#define GL_TEXTURE25_ARB 0x84D9\n#define GL_TEXTURE26_ARB 0x84DA\n#define GL_TEXTURE27_ARB 0x84DB\n#define GL_TEXTURE28_ARB 0x84DC\n#define GL_TEXTURE29_ARB 0x84DD\n#define GL_TEXTURE30_ARB 0x84DE\n#define GL_TEXTURE31_ARB 0x84DF\n#define GL_ACTIVE_TEXTURE_ARB 0x84E0\n#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1\n#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2\n\ntypedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);\n\n#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB)\n#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB)\n#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB)\n#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB)\n#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB)\n#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB)\n#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB)\n#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB)\n#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB)\n#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB)\n#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB)\n#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB)\n#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB)\n#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB)\n#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB)\n#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB)\n#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB)\n#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB)\n#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB)\n#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB)\n#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB)\n#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB)\n#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB)\n#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB)\n#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB)\n#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB)\n#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB)\n#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB)\n#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB)\n#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB)\n#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB)\n#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB)\n#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB)\n#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB)\n\n#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture)\n\n#endif /* GL_ARB_multitexture */\n\n/* ------------------------- GL_ARB_occlusion_query ------------------------ */\n\n#ifndef GL_ARB_occlusion_query\n#define GL_ARB_occlusion_query 1\n\n#define GL_QUERY_COUNTER_BITS_ARB 0x8864\n#define GL_CURRENT_QUERY_ARB 0x8865\n#define GL_QUERY_RESULT_ARB 0x8866\n#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867\n#define GL_SAMPLES_PASSED_ARB 0x8914\n\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id);\n\n#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB)\n#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB)\n#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB)\n#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB)\n#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB)\n#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB)\n#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB)\n#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB)\n\n#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query)\n\n#endif /* GL_ARB_occlusion_query */\n\n/* ------------------------ GL_ARB_occlusion_query2 ------------------------ */\n\n#ifndef GL_ARB_occlusion_query2\n#define GL_ARB_occlusion_query2 1\n\n#define GL_ANY_SAMPLES_PASSED 0x8C2F\n\n#define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2)\n\n#endif /* GL_ARB_occlusion_query2 */\n\n/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */\n\n#ifndef GL_ARB_pixel_buffer_object\n#define GL_ARB_pixel_buffer_object 1\n\n#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB\n#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF\n\n#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object)\n\n#endif /* GL_ARB_pixel_buffer_object */\n\n/* ------------------------ GL_ARB_point_parameters ------------------------ */\n\n#ifndef GL_ARB_point_parameters\n#define GL_ARB_point_parameters 1\n\n#define GL_POINT_SIZE_MIN_ARB 0x8126\n#define GL_POINT_SIZE_MAX_ARB 0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128\n#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129\n\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params);\n\n#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB)\n#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB)\n\n#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters)\n\n#endif /* GL_ARB_point_parameters */\n\n/* -------------------------- GL_ARB_point_sprite -------------------------- */\n\n#ifndef GL_ARB_point_sprite\n#define GL_ARB_point_sprite 1\n\n#define GL_POINT_SPRITE_ARB 0x8861\n#define GL_COORD_REPLACE_ARB 0x8862\n\n#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite)\n\n#endif /* GL_ARB_point_sprite */\n\n/* --------------------- GL_ARB_program_interface_query -------------------- */\n\n#ifndef GL_ARB_program_interface_query\n#define GL_ARB_program_interface_query 1\n\n#define GL_UNIFORM 0x92E1\n#define GL_UNIFORM_BLOCK 0x92E2\n#define GL_PROGRAM_INPUT 0x92E3\n#define GL_PROGRAM_OUTPUT 0x92E4\n#define GL_BUFFER_VARIABLE 0x92E5\n#define GL_SHADER_STORAGE_BLOCK 0x92E6\n#define GL_IS_PER_PATCH 0x92E7\n#define GL_VERTEX_SUBROUTINE 0x92E8\n#define GL_TESS_CONTROL_SUBROUTINE 0x92E9\n#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA\n#define GL_GEOMETRY_SUBROUTINE 0x92EB\n#define GL_FRAGMENT_SUBROUTINE 0x92EC\n#define GL_COMPUTE_SUBROUTINE 0x92ED\n#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE\n#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF\n#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0\n#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1\n#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2\n#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3\n#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4\n#define GL_ACTIVE_RESOURCES 0x92F5\n#define GL_MAX_NAME_LENGTH 0x92F6\n#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7\n#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8\n#define GL_NAME_LENGTH 0x92F9\n#define GL_TYPE 0x92FA\n#define GL_ARRAY_SIZE 0x92FB\n#define GL_OFFSET 0x92FC\n#define GL_BLOCK_INDEX 0x92FD\n#define GL_ARRAY_STRIDE 0x92FE\n#define GL_MATRIX_STRIDE 0x92FF\n#define GL_IS_ROW_MAJOR 0x9300\n#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301\n#define GL_BUFFER_BINDING 0x9302\n#define GL_BUFFER_DATA_SIZE 0x9303\n#define GL_NUM_ACTIVE_VARIABLES 0x9304\n#define GL_ACTIVE_VARIABLES 0x9305\n#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306\n#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307\n#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308\n#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309\n#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A\n#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B\n#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C\n#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D\n#define GL_LOCATION 0x930E\n#define GL_LOCATION_INDEX 0x930F\n\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params);\ntypedef GLuint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name);\ntypedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar* name);\ntypedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params);\n\n#define glGetProgramInterfaceiv GLEW_GET_FUN(__glewGetProgramInterfaceiv)\n#define glGetProgramResourceIndex GLEW_GET_FUN(__glewGetProgramResourceIndex)\n#define glGetProgramResourceLocation GLEW_GET_FUN(__glewGetProgramResourceLocation)\n#define glGetProgramResourceLocationIndex GLEW_GET_FUN(__glewGetProgramResourceLocationIndex)\n#define glGetProgramResourceName GLEW_GET_FUN(__glewGetProgramResourceName)\n#define glGetProgramResourceiv GLEW_GET_FUN(__glewGetProgramResourceiv)\n\n#define GLEW_ARB_program_interface_query GLEW_GET_VAR(__GLEW_ARB_program_interface_query)\n\n#endif /* GL_ARB_program_interface_query */\n\n/* ------------------------ GL_ARB_provoking_vertex ------------------------ */\n\n#ifndef GL_ARB_provoking_vertex\n#define GL_ARB_provoking_vertex 1\n\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_PROVOKING_VERTEX 0x8E4F\n\ntypedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode);\n\n#define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex)\n\n#define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex)\n\n#endif /* GL_ARB_provoking_vertex */\n\n/* ------------------ GL_ARB_robust_buffer_access_behavior ----------------- */\n\n#ifndef GL_ARB_robust_buffer_access_behavior\n#define GL_ARB_robust_buffer_access_behavior 1\n\n#define GLEW_ARB_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_ARB_robust_buffer_access_behavior)\n\n#endif /* GL_ARB_robust_buffer_access_behavior */\n\n/* --------------------------- GL_ARB_robustness --------------------------- */\n\n#ifndef GL_ARB_robustness\n#define GL_ARB_robustness 1\n\n#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252\n#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253\n#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254\n#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255\n#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define GL_NO_RESET_NOTIFICATION_ARB 0x8261\n\ntypedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* table);\ntypedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void* img);\ntypedef void (GLAPIENTRY * PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* image);\ntypedef void (GLAPIENTRY * PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values);\ntypedef void (GLAPIENTRY * PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint* v);\ntypedef void (GLAPIENTRY * PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values);\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat* values);\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint* values);\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort* values);\ntypedef void (GLAPIENTRY * PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte* pattern);\ntypedef void (GLAPIENTRY * PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void* row, GLsizei columnBufSize, GLvoid*column, GLvoid*span);\ntypedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* img);\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void* data);\n\n#define glGetGraphicsResetStatusARB GLEW_GET_FUN(__glewGetGraphicsResetStatusARB)\n#define glGetnColorTableARB GLEW_GET_FUN(__glewGetnColorTableARB)\n#define glGetnCompressedTexImageARB GLEW_GET_FUN(__glewGetnCompressedTexImageARB)\n#define glGetnConvolutionFilterARB GLEW_GET_FUN(__glewGetnConvolutionFilterARB)\n#define glGetnHistogramARB GLEW_GET_FUN(__glewGetnHistogramARB)\n#define glGetnMapdvARB GLEW_GET_FUN(__glewGetnMapdvARB)\n#define glGetnMapfvARB GLEW_GET_FUN(__glewGetnMapfvARB)\n#define glGetnMapivARB GLEW_GET_FUN(__glewGetnMapivARB)\n#define glGetnMinmaxARB GLEW_GET_FUN(__glewGetnMinmaxARB)\n#define glGetnPixelMapfvARB GLEW_GET_FUN(__glewGetnPixelMapfvARB)\n#define glGetnPixelMapuivARB GLEW_GET_FUN(__glewGetnPixelMapuivARB)\n#define glGetnPixelMapusvARB GLEW_GET_FUN(__glewGetnPixelMapusvARB)\n#define glGetnPolygonStippleARB GLEW_GET_FUN(__glewGetnPolygonStippleARB)\n#define glGetnSeparableFilterARB GLEW_GET_FUN(__glewGetnSeparableFilterARB)\n#define glGetnTexImageARB GLEW_GET_FUN(__glewGetnTexImageARB)\n#define glGetnUniformdvARB GLEW_GET_FUN(__glewGetnUniformdvARB)\n#define glGetnUniformfvARB GLEW_GET_FUN(__glewGetnUniformfvARB)\n#define glGetnUniformivARB GLEW_GET_FUN(__glewGetnUniformivARB)\n#define glGetnUniformuivARB GLEW_GET_FUN(__glewGetnUniformuivARB)\n#define glReadnPixelsARB GLEW_GET_FUN(__glewReadnPixelsARB)\n\n#define GLEW_ARB_robustness GLEW_GET_VAR(__GLEW_ARB_robustness)\n\n#endif /* GL_ARB_robustness */\n\n/* ---------------- GL_ARB_robustness_application_isolation ---------------- */\n\n#ifndef GL_ARB_robustness_application_isolation\n#define GL_ARB_robustness_application_isolation 1\n\n#define GLEW_ARB_robustness_application_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_application_isolation)\n\n#endif /* GL_ARB_robustness_application_isolation */\n\n/* ---------------- GL_ARB_robustness_share_group_isolation ---------------- */\n\n#ifndef GL_ARB_robustness_share_group_isolation\n#define GL_ARB_robustness_share_group_isolation 1\n\n#define GLEW_ARB_robustness_share_group_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_share_group_isolation)\n\n#endif /* GL_ARB_robustness_share_group_isolation */\n\n/* ------------------------- GL_ARB_sample_shading ------------------------- */\n\n#ifndef GL_ARB_sample_shading\n#define GL_ARB_sample_shading 1\n\n#define GL_SAMPLE_SHADING_ARB 0x8C36\n#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37\n\ntypedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value);\n\n#define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB)\n\n#define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading)\n\n#endif /* GL_ARB_sample_shading */\n\n/* ------------------------- GL_ARB_sampler_objects ------------------------ */\n\n#ifndef GL_ARB_sampler_objects\n#define GL_ARB_sampler_objects 1\n\n#define GL_SAMPLER_BINDING 0x8919\n\ntypedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);\ntypedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers);\ntypedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers);\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params);\n\n#define glBindSampler GLEW_GET_FUN(__glewBindSampler)\n#define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers)\n#define glGenSamplers GLEW_GET_FUN(__glewGenSamplers)\n#define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv)\n#define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv)\n#define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv)\n#define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv)\n#define glIsSampler GLEW_GET_FUN(__glewIsSampler)\n#define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv)\n#define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv)\n#define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf)\n#define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv)\n#define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri)\n#define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv)\n\n#define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects)\n\n#endif /* GL_ARB_sampler_objects */\n\n/* ------------------------ GL_ARB_seamless_cube_map ----------------------- */\n\n#ifndef GL_ARB_seamless_cube_map\n#define GL_ARB_seamless_cube_map 1\n\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\n\n#define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map)\n\n#endif /* GL_ARB_seamless_cube_map */\n\n/* --------------------- GL_ARB_separate_shader_objects -------------------- */\n\n#ifndef GL_ARB_separate_shader_objects\n#define GL_ARB_separate_shader_objects 1\n\n#define GL_VERTEX_SHADER_BIT 0x00000001\n#define GL_FRAGMENT_SHADER_BIT 0x00000002\n#define GL_GEOMETRY_SHADER_BIT 0x00000004\n#define GL_TESS_CONTROL_SHADER_BIT 0x00000008\n#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010\n#define GL_PROGRAM_SEPARABLE 0x8258\n#define GL_ACTIVE_PROGRAM 0x8259\n#define GL_PROGRAM_PIPELINE_BINDING 0x825A\n#define GL_ALL_SHADER_BITS 0xFFFFFFFF\n\ntypedef void (GLAPIENTRY * PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar ** strings);\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines);\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar *infoLog);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint x, GLuint y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);\n\n#define glActiveShaderProgram GLEW_GET_FUN(__glewActiveShaderProgram)\n#define glBindProgramPipeline GLEW_GET_FUN(__glewBindProgramPipeline)\n#define glCreateShaderProgramv GLEW_GET_FUN(__glewCreateShaderProgramv)\n#define glDeleteProgramPipelines GLEW_GET_FUN(__glewDeleteProgramPipelines)\n#define glGenProgramPipelines GLEW_GET_FUN(__glewGenProgramPipelines)\n#define glGetProgramPipelineInfoLog GLEW_GET_FUN(__glewGetProgramPipelineInfoLog)\n#define glGetProgramPipelineiv GLEW_GET_FUN(__glewGetProgramPipelineiv)\n#define glIsProgramPipeline GLEW_GET_FUN(__glewIsProgramPipeline)\n#define glProgramUniform1d GLEW_GET_FUN(__glewProgramUniform1d)\n#define glProgramUniform1dv GLEW_GET_FUN(__glewProgramUniform1dv)\n#define glProgramUniform1f GLEW_GET_FUN(__glewProgramUniform1f)\n#define glProgramUniform1fv GLEW_GET_FUN(__glewProgramUniform1fv)\n#define glProgramUniform1i GLEW_GET_FUN(__glewProgramUniform1i)\n#define glProgramUniform1iv GLEW_GET_FUN(__glewProgramUniform1iv)\n#define glProgramUniform1ui GLEW_GET_FUN(__glewProgramUniform1ui)\n#define glProgramUniform1uiv GLEW_GET_FUN(__glewProgramUniform1uiv)\n#define glProgramUniform2d GLEW_GET_FUN(__glewProgramUniform2d)\n#define glProgramUniform2dv GLEW_GET_FUN(__glewProgramUniform2dv)\n#define glProgramUniform2f GLEW_GET_FUN(__glewProgramUniform2f)\n#define glProgramUniform2fv GLEW_GET_FUN(__glewProgramUniform2fv)\n#define glProgramUniform2i GLEW_GET_FUN(__glewProgramUniform2i)\n#define glProgramUniform2iv GLEW_GET_FUN(__glewProgramUniform2iv)\n#define glProgramUniform2ui GLEW_GET_FUN(__glewProgramUniform2ui)\n#define glProgramUniform2uiv GLEW_GET_FUN(__glewProgramUniform2uiv)\n#define glProgramUniform3d GLEW_GET_FUN(__glewProgramUniform3d)\n#define glProgramUniform3dv GLEW_GET_FUN(__glewProgramUniform3dv)\n#define glProgramUniform3f GLEW_GET_FUN(__glewProgramUniform3f)\n#define glProgramUniform3fv GLEW_GET_FUN(__glewProgramUniform3fv)\n#define glProgramUniform3i GLEW_GET_FUN(__glewProgramUniform3i)\n#define glProgramUniform3iv GLEW_GET_FUN(__glewProgramUniform3iv)\n#define glProgramUniform3ui GLEW_GET_FUN(__glewProgramUniform3ui)\n#define glProgramUniform3uiv GLEW_GET_FUN(__glewProgramUniform3uiv)\n#define glProgramUniform4d GLEW_GET_FUN(__glewProgramUniform4d)\n#define glProgramUniform4dv GLEW_GET_FUN(__glewProgramUniform4dv)\n#define glProgramUniform4f GLEW_GET_FUN(__glewProgramUniform4f)\n#define glProgramUniform4fv GLEW_GET_FUN(__glewProgramUniform4fv)\n#define glProgramUniform4i GLEW_GET_FUN(__glewProgramUniform4i)\n#define glProgramUniform4iv GLEW_GET_FUN(__glewProgramUniform4iv)\n#define glProgramUniform4ui GLEW_GET_FUN(__glewProgramUniform4ui)\n#define glProgramUniform4uiv GLEW_GET_FUN(__glewProgramUniform4uiv)\n#define glProgramUniformMatrix2dv GLEW_GET_FUN(__glewProgramUniformMatrix2dv)\n#define glProgramUniformMatrix2fv GLEW_GET_FUN(__glewProgramUniformMatrix2fv)\n#define glProgramUniformMatrix2x3dv GLEW_GET_FUN(__glewProgramUniformMatrix2x3dv)\n#define glProgramUniformMatrix2x3fv GLEW_GET_FUN(__glewProgramUniformMatrix2x3fv)\n#define glProgramUniformMatrix2x4dv GLEW_GET_FUN(__glewProgramUniformMatrix2x4dv)\n#define glProgramUniformMatrix2x4fv GLEW_GET_FUN(__glewProgramUniformMatrix2x4fv)\n#define glProgramUniformMatrix3dv GLEW_GET_FUN(__glewProgramUniformMatrix3dv)\n#define glProgramUniformMatrix3fv GLEW_GET_FUN(__glewProgramUniformMatrix3fv)\n#define glProgramUniformMatrix3x2dv GLEW_GET_FUN(__glewProgramUniformMatrix3x2dv)\n#define glProgramUniformMatrix3x2fv GLEW_GET_FUN(__glewProgramUniformMatrix3x2fv)\n#define glProgramUniformMatrix3x4dv GLEW_GET_FUN(__glewProgramUniformMatrix3x4dv)\n#define glProgramUniformMatrix3x4fv GLEW_GET_FUN(__glewProgramUniformMatrix3x4fv)\n#define glProgramUniformMatrix4dv GLEW_GET_FUN(__glewProgramUniformMatrix4dv)\n#define glProgramUniformMatrix4fv GLEW_GET_FUN(__glewProgramUniformMatrix4fv)\n#define glProgramUniformMatrix4x2dv GLEW_GET_FUN(__glewProgramUniformMatrix4x2dv)\n#define glProgramUniformMatrix4x2fv GLEW_GET_FUN(__glewProgramUniformMatrix4x2fv)\n#define glProgramUniformMatrix4x3dv GLEW_GET_FUN(__glewProgramUniformMatrix4x3dv)\n#define glProgramUniformMatrix4x3fv GLEW_GET_FUN(__glewProgramUniformMatrix4x3fv)\n#define glUseProgramStages GLEW_GET_FUN(__glewUseProgramStages)\n#define glValidateProgramPipeline GLEW_GET_FUN(__glewValidateProgramPipeline)\n\n#define GLEW_ARB_separate_shader_objects GLEW_GET_VAR(__GLEW_ARB_separate_shader_objects)\n\n#endif /* GL_ARB_separate_shader_objects */\n\n/* --------------------- GL_ARB_shader_atomic_counters --------------------- */\n\n#ifndef GL_ARB_shader_atomic_counters\n#define GL_ARB_shader_atomic_counters 1\n\n#define GL_ATOMIC_COUNTER_BUFFER 0x92C0\n#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1\n#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2\n#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3\n#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB\n#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0\n#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1\n#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6\n#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8\n#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9\n#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA\n#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC\n\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint* params);\n\n#define glGetActiveAtomicCounterBufferiv GLEW_GET_FUN(__glewGetActiveAtomicCounterBufferiv)\n\n#define GLEW_ARB_shader_atomic_counters GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counters)\n\n#endif /* GL_ARB_shader_atomic_counters */\n\n/* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */\n\n#ifndef GL_ARB_shader_bit_encoding\n#define GL_ARB_shader_bit_encoding 1\n\n#define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding)\n\n#endif /* GL_ARB_shader_bit_encoding */\n\n/* --------------------- GL_ARB_shader_image_load_store -------------------- */\n\n#ifndef GL_ARB_shader_image_load_store\n#define GL_ARB_shader_image_load_store 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001\n#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002\n#define GL_UNIFORM_BARRIER_BIT 0x00000004\n#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020\n#define GL_COMMAND_BARRIER_BIT 0x00000040\n#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080\n#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100\n#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200\n#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800\n#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000\n#define GL_MAX_IMAGE_UNITS 0x8F38\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39\n#define GL_IMAGE_BINDING_NAME 0x8F3A\n#define GL_IMAGE_BINDING_LEVEL 0x8F3B\n#define GL_IMAGE_BINDING_LAYERED 0x8F3C\n#define GL_IMAGE_BINDING_LAYER 0x8F3D\n#define GL_IMAGE_BINDING_ACCESS 0x8F3E\n#define GL_IMAGE_1D 0x904C\n#define GL_IMAGE_2D 0x904D\n#define GL_IMAGE_3D 0x904E\n#define GL_IMAGE_2D_RECT 0x904F\n#define GL_IMAGE_CUBE 0x9050\n#define GL_IMAGE_BUFFER 0x9051\n#define GL_IMAGE_1D_ARRAY 0x9052\n#define GL_IMAGE_2D_ARRAY 0x9053\n#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054\n#define GL_IMAGE_2D_MULTISAMPLE 0x9055\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056\n#define GL_INT_IMAGE_1D 0x9057\n#define GL_INT_IMAGE_2D 0x9058\n#define GL_INT_IMAGE_3D 0x9059\n#define GL_INT_IMAGE_2D_RECT 0x905A\n#define GL_INT_IMAGE_CUBE 0x905B\n#define GL_INT_IMAGE_BUFFER 0x905C\n#define GL_INT_IMAGE_1D_ARRAY 0x905D\n#define GL_INT_IMAGE_2D_ARRAY 0x905E\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F\n#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061\n#define GL_UNSIGNED_INT_IMAGE_1D 0x9062\n#define GL_UNSIGNED_INT_IMAGE_2D 0x9063\n#define GL_UNSIGNED_INT_IMAGE_3D 0x9064\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065\n#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066\n#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C\n#define GL_MAX_IMAGE_SAMPLES 0x906D\n#define GL_IMAGE_BINDING_FORMAT 0x906E\n#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9\n#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA\n#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB\n#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC\n#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD\n#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE\n#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF\n#define GL_ALL_BARRIER_BITS 0xFFFFFFFF\n\ntypedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);\ntypedef void (GLAPIENTRY * PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);\n\n#define glBindImageTexture GLEW_GET_FUN(__glewBindImageTexture)\n#define glMemoryBarrier GLEW_GET_FUN(__glewMemoryBarrier)\n\n#define GLEW_ARB_shader_image_load_store GLEW_GET_VAR(__GLEW_ARB_shader_image_load_store)\n\n#endif /* GL_ARB_shader_image_load_store */\n\n/* ------------------------ GL_ARB_shader_image_size ----------------------- */\n\n#ifndef GL_ARB_shader_image_size\n#define GL_ARB_shader_image_size 1\n\n#define GLEW_ARB_shader_image_size GLEW_GET_VAR(__GLEW_ARB_shader_image_size)\n\n#endif /* GL_ARB_shader_image_size */\n\n/* ------------------------- GL_ARB_shader_objects ------------------------- */\n\n#ifndef GL_ARB_shader_objects\n#define GL_ARB_shader_objects 1\n\n#define GL_PROGRAM_OBJECT_ARB 0x8B40\n#define GL_SHADER_OBJECT_ARB 0x8B48\n#define GL_OBJECT_TYPE_ARB 0x8B4E\n#define GL_OBJECT_SUBTYPE_ARB 0x8B4F\n#define GL_FLOAT_VEC2_ARB 0x8B50\n#define GL_FLOAT_VEC3_ARB 0x8B51\n#define GL_FLOAT_VEC4_ARB 0x8B52\n#define GL_INT_VEC2_ARB 0x8B53\n#define GL_INT_VEC3_ARB 0x8B54\n#define GL_INT_VEC4_ARB 0x8B55\n#define GL_BOOL_ARB 0x8B56\n#define GL_BOOL_VEC2_ARB 0x8B57\n#define GL_BOOL_VEC3_ARB 0x8B58\n#define GL_BOOL_VEC4_ARB 0x8B59\n#define GL_FLOAT_MAT2_ARB 0x8B5A\n#define GL_FLOAT_MAT3_ARB 0x8B5B\n#define GL_FLOAT_MAT4_ARB 0x8B5C\n#define GL_SAMPLER_1D_ARB 0x8B5D\n#define GL_SAMPLER_2D_ARB 0x8B5E\n#define GL_SAMPLER_3D_ARB 0x8B5F\n#define GL_SAMPLER_CUBE_ARB 0x8B60\n#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61\n#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62\n#define GL_SAMPLER_2D_RECT_ARB 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64\n#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80\n#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81\n#define GL_OBJECT_LINK_STATUS_ARB 0x8B82\n#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83\n#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84\n#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85\n#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86\n#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87\n#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88\n\ntypedef char GLcharARB;\ntypedef unsigned int GLhandleARB;\n\ntypedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);\ntypedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void);\ntypedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);\ntypedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);\ntypedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name);\ntypedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj);\ntypedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname);\ntypedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source);\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);\ntypedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);\n\n#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB)\n#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB)\n#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB)\n#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB)\n#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB)\n#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB)\n#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB)\n#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB)\n#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB)\n#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB)\n#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB)\n#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB)\n#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB)\n#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB)\n#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB)\n#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB)\n#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB)\n#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB)\n#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB)\n#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB)\n#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB)\n#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB)\n#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB)\n#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB)\n#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB)\n#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB)\n#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB)\n#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB)\n#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB)\n#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB)\n#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB)\n#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB)\n#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB)\n#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB)\n#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB)\n#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB)\n#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB)\n#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB)\n#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB)\n\n#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects)\n\n#endif /* GL_ARB_shader_objects */\n\n/* ------------------------ GL_ARB_shader_precision ------------------------ */\n\n#ifndef GL_ARB_shader_precision\n#define GL_ARB_shader_precision 1\n\n#define GLEW_ARB_shader_precision GLEW_GET_VAR(__GLEW_ARB_shader_precision)\n\n#endif /* GL_ARB_shader_precision */\n\n/* ---------------------- GL_ARB_shader_stencil_export --------------------- */\n\n#ifndef GL_ARB_shader_stencil_export\n#define GL_ARB_shader_stencil_export 1\n\n#define GLEW_ARB_shader_stencil_export GLEW_GET_VAR(__GLEW_ARB_shader_stencil_export)\n\n#endif /* GL_ARB_shader_stencil_export */\n\n/* ------------------ GL_ARB_shader_storage_buffer_object ------------------ */\n\n#ifndef GL_ARB_shader_storage_buffer_object\n#define GL_ARB_shader_storage_buffer_object 1\n\n#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000\n#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39\n#define GL_SHADER_STORAGE_BUFFER 0x90D2\n#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3\n#define GL_SHADER_STORAGE_BUFFER_START 0x90D4\n#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5\n#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6\n#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7\n#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8\n#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9\n#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA\n#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB\n#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC\n#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD\n#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE\n#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF\n\ntypedef void (GLAPIENTRY * PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);\n\n#define glShaderStorageBlockBinding GLEW_GET_FUN(__glewShaderStorageBlockBinding)\n\n#define GLEW_ARB_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_ARB_shader_storage_buffer_object)\n\n#endif /* GL_ARB_shader_storage_buffer_object */\n\n/* ------------------------ GL_ARB_shader_subroutine ----------------------- */\n\n#ifndef GL_ARB_shader_subroutine\n#define GL_ARB_shader_subroutine 1\n\n#define GL_ACTIVE_SUBROUTINES 0x8DE5\n#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6\n#define GL_MAX_SUBROUTINES 0x8DE7\n#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47\n#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49\n#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A\n#define GL_COMPATIBLE_SUBROUTINES 0x8E4B\n\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values);\ntypedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar* name);\ntypedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices);\n\n#define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName)\n#define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName)\n#define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv)\n#define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv)\n#define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex)\n#define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation)\n#define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv)\n#define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv)\n\n#define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine)\n\n#endif /* GL_ARB_shader_subroutine */\n\n/* ----------------------- GL_ARB_shader_texture_lod ----------------------- */\n\n#ifndef GL_ARB_shader_texture_lod\n#define GL_ARB_shader_texture_lod 1\n\n#define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod)\n\n#endif /* GL_ARB_shader_texture_lod */\n\n/* ---------------------- GL_ARB_shading_language_100 ---------------------- */\n\n#ifndef GL_ARB_shading_language_100\n#define GL_ARB_shading_language_100 1\n\n#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C\n\n#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100)\n\n#endif /* GL_ARB_shading_language_100 */\n\n/* -------------------- GL_ARB_shading_language_420pack -------------------- */\n\n#ifndef GL_ARB_shading_language_420pack\n#define GL_ARB_shading_language_420pack 1\n\n#define GLEW_ARB_shading_language_420pack GLEW_GET_VAR(__GLEW_ARB_shading_language_420pack)\n\n#endif /* GL_ARB_shading_language_420pack */\n\n/* -------------------- GL_ARB_shading_language_include -------------------- */\n\n#ifndef GL_ARB_shading_language_include\n#define GL_ARB_shading_language_include 1\n\n#define GL_SHADER_INCLUDE_ARB 0x8DAE\n#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9\n#define GL_NAMED_STRING_TYPE_ARB 0x8DEA\n\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar ** path, const GLint *length);\ntypedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name, GLsizei bufSize, GLint *stringlen, GLchar *string);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar* name, GLenum pname, GLint *params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name);\ntypedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar *string);\n\n#define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB)\n#define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB)\n#define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB)\n#define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB)\n#define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB)\n#define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB)\n\n#define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include)\n\n#endif /* GL_ARB_shading_language_include */\n\n/* -------------------- GL_ARB_shading_language_packing -------------------- */\n\n#ifndef GL_ARB_shading_language_packing\n#define GL_ARB_shading_language_packing 1\n\n#define GLEW_ARB_shading_language_packing GLEW_GET_VAR(__GLEW_ARB_shading_language_packing)\n\n#endif /* GL_ARB_shading_language_packing */\n\n/* ----------------------------- GL_ARB_shadow ----------------------------- */\n\n#ifndef GL_ARB_shadow\n#define GL_ARB_shadow 1\n\n#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C\n#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D\n#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E\n\n#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow)\n\n#endif /* GL_ARB_shadow */\n\n/* ------------------------- GL_ARB_shadow_ambient ------------------------- */\n\n#ifndef GL_ARB_shadow_ambient\n#define GL_ARB_shadow_ambient 1\n\n#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF\n\n#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient)\n\n#endif /* GL_ARB_shadow_ambient */\n\n/* ------------------------ GL_ARB_stencil_texturing ----------------------- */\n\n#ifndef GL_ARB_stencil_texturing\n#define GL_ARB_stencil_texturing 1\n\n#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA\n\n#define GLEW_ARB_stencil_texturing GLEW_GET_VAR(__GLEW_ARB_stencil_texturing)\n\n#endif /* GL_ARB_stencil_texturing */\n\n/* ------------------------------ GL_ARB_sync ------------------------------ */\n\n#ifndef GL_ARB_sync\n#define GL_ARB_sync 1\n\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\n#define GL_OBJECT_TYPE 0x9112\n#define GL_SYNC_CONDITION 0x9113\n#define GL_SYNC_STATUS 0x9114\n#define GL_SYNC_FLAGS 0x9115\n#define GL_SYNC_FENCE 0x9116\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\n#define GL_UNSIGNALED 0x9118\n#define GL_SIGNALED 0x9119\n#define GL_ALREADY_SIGNALED 0x911A\n#define GL_TIMEOUT_EXPIRED 0x911B\n#define GL_CONDITION_SATISFIED 0x911C\n#define GL_WAIT_FAILED 0x911D\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\n\ntypedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);\ntypedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync);\ntypedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params);\ntypedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values);\ntypedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync);\ntypedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);\n\n#define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync)\n#define glDeleteSync GLEW_GET_FUN(__glewDeleteSync)\n#define glFenceSync GLEW_GET_FUN(__glewFenceSync)\n#define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v)\n#define glGetSynciv GLEW_GET_FUN(__glewGetSynciv)\n#define glIsSync GLEW_GET_FUN(__glewIsSync)\n#define glWaitSync GLEW_GET_FUN(__glewWaitSync)\n\n#define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync)\n\n#endif /* GL_ARB_sync */\n\n/* ----------------------- GL_ARB_tessellation_shader ---------------------- */\n\n#ifndef GL_ARB_tessellation_shader\n#define GL_ARB_tessellation_shader 1\n\n#define GL_PATCHES 0xE\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1\n#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C\n#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D\n#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E\n#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F\n#define GL_PATCH_VERTICES 0x8E72\n#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73\n#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74\n#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75\n#define GL_TESS_GEN_MODE 0x8E76\n#define GL_TESS_GEN_SPACING 0x8E77\n#define GL_TESS_GEN_VERTEX_ORDER 0x8E78\n#define GL_TESS_GEN_POINT_MODE 0x8E79\n#define GL_ISOLINES 0x8E7A\n#define GL_FRACTIONAL_ODD 0x8E7B\n#define GL_FRACTIONAL_EVEN 0x8E7C\n#define GL_MAX_PATCH_VERTICES 0x8E7D\n#define GL_MAX_TESS_GEN_LEVEL 0x8E7E\n#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F\n#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80\n#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81\n#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82\n#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83\n#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84\n#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85\n#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86\n#define GL_TESS_EVALUATION_SHADER 0x8E87\n#define GL_TESS_CONTROL_SHADER 0x8E88\n#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89\n#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A\n\ntypedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values);\ntypedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);\n\n#define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv)\n#define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri)\n\n#define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader)\n\n#endif /* GL_ARB_tessellation_shader */\n\n/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */\n\n#ifndef GL_ARB_texture_border_clamp\n#define GL_ARB_texture_border_clamp 1\n\n#define GL_CLAMP_TO_BORDER_ARB 0x812D\n\n#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp)\n\n#endif /* GL_ARB_texture_border_clamp */\n\n/* ---------------------- GL_ARB_texture_buffer_object --------------------- */\n\n#ifndef GL_ARB_texture_buffer_object\n#define GL_ARB_texture_buffer_object 1\n\n#define GL_TEXTURE_BUFFER_ARB 0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D\n#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E\n\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);\n\n#define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB)\n\n#define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object)\n\n#endif /* GL_ARB_texture_buffer_object */\n\n/* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */\n\n#ifndef GL_ARB_texture_buffer_object_rgb32\n#define GL_ARB_texture_buffer_object_rgb32 1\n\n#define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32)\n\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n\n/* ---------------------- GL_ARB_texture_buffer_range ---------------------- */\n\n#ifndef GL_ARB_texture_buffer_range\n#define GL_ARB_texture_buffer_range 1\n\n#define GL_TEXTURE_BUFFER_OFFSET 0x919D\n#define GL_TEXTURE_BUFFER_SIZE 0x919E\n#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F\n\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\n\n#define glTexBufferRange GLEW_GET_FUN(__glewTexBufferRange)\n#define glTextureBufferRangeEXT GLEW_GET_FUN(__glewTextureBufferRangeEXT)\n\n#define GLEW_ARB_texture_buffer_range GLEW_GET_VAR(__GLEW_ARB_texture_buffer_range)\n\n#endif /* GL_ARB_texture_buffer_range */\n\n/* ----------------------- GL_ARB_texture_compression ---------------------- */\n\n#ifndef GL_ARB_texture_compression\n#define GL_ARB_texture_compression 1\n\n#define GL_COMPRESSED_ALPHA_ARB 0x84E9\n#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA\n#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB\n#define GL_COMPRESSED_INTENSITY_ARB 0x84EC\n#define GL_COMPRESSED_RGB_ARB 0x84ED\n#define GL_COMPRESSED_RGBA_ARB 0x84EE\n#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0\n#define GL_TEXTURE_COMPRESSED_ARB 0x86A1\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3\n\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img);\n\n#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB)\n#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB)\n#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB)\n#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB)\n#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB)\n#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB)\n#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB)\n\n#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression)\n\n#endif /* GL_ARB_texture_compression */\n\n/* -------------------- GL_ARB_texture_compression_bptc -------------------- */\n\n#ifndef GL_ARB_texture_compression_bptc\n#define GL_ARB_texture_compression_bptc 1\n\n#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F\n\n#define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc)\n\n#endif /* GL_ARB_texture_compression_bptc */\n\n/* -------------------- GL_ARB_texture_compression_rgtc -------------------- */\n\n#ifndef GL_ARB_texture_compression_rgtc\n#define GL_ARB_texture_compression_rgtc 1\n\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\n\n#define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc)\n\n#endif /* GL_ARB_texture_compression_rgtc */\n\n/* ------------------------ GL_ARB_texture_cube_map ------------------------ */\n\n#ifndef GL_ARB_texture_cube_map\n#define GL_ARB_texture_cube_map 1\n\n#define GL_NORMAL_MAP_ARB 0x8511\n#define GL_REFLECTION_MAP_ARB 0x8512\n#define GL_TEXTURE_CUBE_MAP_ARB 0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C\n\n#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map)\n\n#endif /* GL_ARB_texture_cube_map */\n\n/* --------------------- GL_ARB_texture_cube_map_array --------------------- */\n\n#ifndef GL_ARB_texture_cube_map_array\n#define GL_ARB_texture_cube_map_array 1\n\n#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F\n\n#define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array)\n\n#endif /* GL_ARB_texture_cube_map_array */\n\n/* ------------------------- GL_ARB_texture_env_add ------------------------ */\n\n#ifndef GL_ARB_texture_env_add\n#define GL_ARB_texture_env_add 1\n\n#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add)\n\n#endif /* GL_ARB_texture_env_add */\n\n/* ----------------------- GL_ARB_texture_env_combine ---------------------- */\n\n#ifndef GL_ARB_texture_env_combine\n#define GL_ARB_texture_env_combine 1\n\n#define GL_SUBTRACT_ARB 0x84E7\n#define GL_COMBINE_ARB 0x8570\n#define GL_COMBINE_RGB_ARB 0x8571\n#define GL_COMBINE_ALPHA_ARB 0x8572\n#define GL_RGB_SCALE_ARB 0x8573\n#define GL_ADD_SIGNED_ARB 0x8574\n#define GL_INTERPOLATE_ARB 0x8575\n#define GL_CONSTANT_ARB 0x8576\n#define GL_PRIMARY_COLOR_ARB 0x8577\n#define GL_PREVIOUS_ARB 0x8578\n#define GL_SOURCE0_RGB_ARB 0x8580\n#define GL_SOURCE1_RGB_ARB 0x8581\n#define GL_SOURCE2_RGB_ARB 0x8582\n#define GL_SOURCE0_ALPHA_ARB 0x8588\n#define GL_SOURCE1_ALPHA_ARB 0x8589\n#define GL_SOURCE2_ALPHA_ARB 0x858A\n#define GL_OPERAND0_RGB_ARB 0x8590\n#define GL_OPERAND1_RGB_ARB 0x8591\n#define GL_OPERAND2_RGB_ARB 0x8592\n#define GL_OPERAND0_ALPHA_ARB 0x8598\n#define GL_OPERAND1_ALPHA_ARB 0x8599\n#define GL_OPERAND2_ALPHA_ARB 0x859A\n\n#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine)\n\n#endif /* GL_ARB_texture_env_combine */\n\n/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */\n\n#ifndef GL_ARB_texture_env_crossbar\n#define GL_ARB_texture_env_crossbar 1\n\n#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar)\n\n#endif /* GL_ARB_texture_env_crossbar */\n\n/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */\n\n#ifndef GL_ARB_texture_env_dot3\n#define GL_ARB_texture_env_dot3 1\n\n#define GL_DOT3_RGB_ARB 0x86AE\n#define GL_DOT3_RGBA_ARB 0x86AF\n\n#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3)\n\n#endif /* GL_ARB_texture_env_dot3 */\n\n/* -------------------------- GL_ARB_texture_float ------------------------- */\n\n#ifndef GL_ARB_texture_float\n#define GL_ARB_texture_float 1\n\n#define GL_RGBA32F_ARB 0x8814\n#define GL_RGB32F_ARB 0x8815\n#define GL_ALPHA32F_ARB 0x8816\n#define GL_INTENSITY32F_ARB 0x8817\n#define GL_LUMINANCE32F_ARB 0x8818\n#define GL_LUMINANCE_ALPHA32F_ARB 0x8819\n#define GL_RGBA16F_ARB 0x881A\n#define GL_RGB16F_ARB 0x881B\n#define GL_ALPHA16F_ARB 0x881C\n#define GL_INTENSITY16F_ARB 0x881D\n#define GL_LUMINANCE16F_ARB 0x881E\n#define GL_LUMINANCE_ALPHA16F_ARB 0x881F\n#define GL_TEXTURE_RED_TYPE_ARB 0x8C10\n#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11\n#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12\n#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13\n#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14\n#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15\n#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16\n#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17\n\n#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float)\n\n#endif /* GL_ARB_texture_float */\n\n/* ------------------------- GL_ARB_texture_gather ------------------------- */\n\n#ifndef GL_ARB_texture_gather\n#define GL_ARB_texture_gather 1\n\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F\n\n#define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather)\n\n#endif /* GL_ARB_texture_gather */\n\n/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */\n\n#ifndef GL_ARB_texture_mirrored_repeat\n#define GL_ARB_texture_mirrored_repeat 1\n\n#define GL_MIRRORED_REPEAT_ARB 0x8370\n\n#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat)\n\n#endif /* GL_ARB_texture_mirrored_repeat */\n\n/* ----------------------- GL_ARB_texture_multisample ---------------------- */\n\n#ifndef GL_ARB_texture_multisample\n#define GL_ARB_texture_multisample 1\n\n#define GL_SAMPLE_POSITION 0x8E50\n#define GL_SAMPLE_MASK 0x8E51\n#define GL_SAMPLE_MASK_VALUE 0x8E52\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_SAMPLES 0x9106\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\n#define GL_MAX_INTEGER_SAMPLES 0x9110\n\ntypedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val);\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\n\n#define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv)\n#define glSampleMaski GLEW_GET_FUN(__glewSampleMaski)\n#define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample)\n#define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample)\n\n#define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample)\n\n#endif /* GL_ARB_texture_multisample */\n\n/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */\n\n#ifndef GL_ARB_texture_non_power_of_two\n#define GL_ARB_texture_non_power_of_two 1\n\n#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two)\n\n#endif /* GL_ARB_texture_non_power_of_two */\n\n/* ---------------------- GL_ARB_texture_query_levels ---------------------- */\n\n#ifndef GL_ARB_texture_query_levels\n#define GL_ARB_texture_query_levels 1\n\n#define GLEW_ARB_texture_query_levels GLEW_GET_VAR(__GLEW_ARB_texture_query_levels)\n\n#endif /* GL_ARB_texture_query_levels */\n\n/* ------------------------ GL_ARB_texture_query_lod ----------------------- */\n\n#ifndef GL_ARB_texture_query_lod\n#define GL_ARB_texture_query_lod 1\n\n#define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod)\n\n#endif /* GL_ARB_texture_query_lod */\n\n/* ------------------------ GL_ARB_texture_rectangle ----------------------- */\n\n#ifndef GL_ARB_texture_rectangle\n#define GL_ARB_texture_rectangle 1\n\n#define GL_TEXTURE_RECTANGLE_ARB 0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8\n#define GL_SAMPLER_2D_RECT_ARB 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64\n\n#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle)\n\n#endif /* GL_ARB_texture_rectangle */\n\n/* --------------------------- GL_ARB_texture_rg --------------------------- */\n\n#ifndef GL_ARB_texture_rg\n#define GL_ARB_texture_rg 1\n\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RG 0x8226\n#define GL_RG 0x8227\n#define GL_RG_INTEGER 0x8228\n#define GL_R8 0x8229\n#define GL_R16 0x822A\n#define GL_RG8 0x822B\n#define GL_RG16 0x822C\n#define GL_R16F 0x822D\n#define GL_R32F 0x822E\n#define GL_RG16F 0x822F\n#define GL_RG32F 0x8230\n#define GL_R8I 0x8231\n#define GL_R8UI 0x8232\n#define GL_R16I 0x8233\n#define GL_R16UI 0x8234\n#define GL_R32I 0x8235\n#define GL_R32UI 0x8236\n#define GL_RG8I 0x8237\n#define GL_RG8UI 0x8238\n#define GL_RG16I 0x8239\n#define GL_RG16UI 0x823A\n#define GL_RG32I 0x823B\n#define GL_RG32UI 0x823C\n\n#define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg)\n\n#endif /* GL_ARB_texture_rg */\n\n/* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */\n\n#ifndef GL_ARB_texture_rgb10_a2ui\n#define GL_ARB_texture_rgb10_a2ui 1\n\n#define GL_RGB10_A2UI 0x906F\n\n#define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui)\n\n#endif /* GL_ARB_texture_rgb10_a2ui */\n\n/* ------------------------- GL_ARB_texture_storage ------------------------ */\n\n#ifndef GL_ARB_texture_storage\n#define GL_ARB_texture_storage 1\n\n#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F\n\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\n\n#define glTexStorage1D GLEW_GET_FUN(__glewTexStorage1D)\n#define glTexStorage2D GLEW_GET_FUN(__glewTexStorage2D)\n#define glTexStorage3D GLEW_GET_FUN(__glewTexStorage3D)\n#define glTextureStorage1DEXT GLEW_GET_FUN(__glewTextureStorage1DEXT)\n#define glTextureStorage2DEXT GLEW_GET_FUN(__glewTextureStorage2DEXT)\n#define glTextureStorage3DEXT GLEW_GET_FUN(__glewTextureStorage3DEXT)\n\n#define GLEW_ARB_texture_storage GLEW_GET_VAR(__GLEW_ARB_texture_storage)\n\n#endif /* GL_ARB_texture_storage */\n\n/* ------------------- GL_ARB_texture_storage_multisample ------------------ */\n\n#ifndef GL_ARB_texture_storage_multisample\n#define GL_ARB_texture_storage_multisample 1\n\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\n\n#define glTexStorage2DMultisample GLEW_GET_FUN(__glewTexStorage2DMultisample)\n#define glTexStorage3DMultisample GLEW_GET_FUN(__glewTexStorage3DMultisample)\n#define glTextureStorage2DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage2DMultisampleEXT)\n#define glTextureStorage3DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage3DMultisampleEXT)\n\n#define GLEW_ARB_texture_storage_multisample GLEW_GET_VAR(__GLEW_ARB_texture_storage_multisample)\n\n#endif /* GL_ARB_texture_storage_multisample */\n\n/* ------------------------- GL_ARB_texture_swizzle ------------------------ */\n\n#ifndef GL_ARB_texture_swizzle\n#define GL_ARB_texture_swizzle 1\n\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\n\n#define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle)\n\n#endif /* GL_ARB_texture_swizzle */\n\n/* -------------------------- GL_ARB_texture_view -------------------------- */\n\n#ifndef GL_ARB_texture_view\n#define GL_ARB_texture_view 1\n\n#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB\n#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC\n#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD\n#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE\n#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF\n\ntypedef void (GLAPIENTRY * PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);\n\n#define glTextureView GLEW_GET_FUN(__glewTextureView)\n\n#define GLEW_ARB_texture_view GLEW_GET_VAR(__GLEW_ARB_texture_view)\n\n#endif /* GL_ARB_texture_view */\n\n/* --------------------------- GL_ARB_timer_query -------------------------- */\n\n#ifndef GL_ARB_timer_query\n#define GL_ARB_timer_query 1\n\n#define GL_TIME_ELAPSED 0x88BF\n#define GL_TIMESTAMP 0x8E28\n\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params);\ntypedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);\n\n#define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v)\n#define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v)\n#define glQueryCounter GLEW_GET_FUN(__glewQueryCounter)\n\n#define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query)\n\n#endif /* GL_ARB_timer_query */\n\n/* ----------------------- GL_ARB_transform_feedback2 ---------------------- */\n\n#ifndef GL_ARB_transform_feedback2\n#define GL_ARB_transform_feedback2 1\n\n#define GL_TRANSFORM_FEEDBACK 0x8E22\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25\n\ntypedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids);\ntypedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);\n\n#define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback)\n#define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks)\n#define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback)\n#define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks)\n#define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback)\n#define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback)\n#define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback)\n\n#define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2)\n\n#endif /* GL_ARB_transform_feedback2 */\n\n/* ----------------------- GL_ARB_transform_feedback3 ---------------------- */\n\n#ifndef GL_ARB_transform_feedback3\n#define GL_ARB_transform_feedback3 1\n\n#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70\n#define GL_MAX_VERTEX_STREAMS 0x8E71\n\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);\ntypedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params);\n\n#define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed)\n#define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream)\n#define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed)\n#define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv)\n\n#define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3)\n\n#endif /* GL_ARB_transform_feedback3 */\n\n/* ------------------ GL_ARB_transform_feedback_instanced ------------------ */\n\n#ifndef GL_ARB_transform_feedback_instanced\n#define GL_ARB_transform_feedback_instanced 1\n\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);\n\n#define glDrawTransformFeedbackInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackInstanced)\n#define glDrawTransformFeedbackStreamInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackStreamInstanced)\n\n#define GLEW_ARB_transform_feedback_instanced GLEW_GET_VAR(__GLEW_ARB_transform_feedback_instanced)\n\n#endif /* GL_ARB_transform_feedback_instanced */\n\n/* ------------------------ GL_ARB_transpose_matrix ------------------------ */\n\n#ifndef GL_ARB_transpose_matrix\n#define GL_ARB_transpose_matrix 1\n\n#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3\n#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4\n#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5\n#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6\n\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]);\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]);\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]);\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]);\n\n#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB)\n#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB)\n#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB)\n#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB)\n\n#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix)\n\n#endif /* GL_ARB_transpose_matrix */\n\n/* ---------------------- GL_ARB_uniform_buffer_object --------------------- */\n\n#ifndef GL_ARB_uniform_buffer_object\n#define GL_ARB_uniform_buffer_object 1\n\n#define GL_UNIFORM_BUFFER 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\n#define GL_UNIFORM_BUFFER_START 0x8A29\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\n#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\n#define GL_UNIFORM_TYPE 0x8A37\n#define GL_UNIFORM_SIZE 0x8A38\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\n#define GL_UNIFORM_OFFSET 0x8A3B\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_INVALID_INDEX 0xFFFFFFFF\n\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data);\ntypedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar** uniformNames, GLuint* uniformIndices);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\n\n#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase)\n#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange)\n#define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName)\n#define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv)\n#define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName)\n#define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv)\n#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v)\n#define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex)\n#define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices)\n#define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding)\n\n#define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object)\n\n#endif /* GL_ARB_uniform_buffer_object */\n\n/* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */\n\n#ifndef GL_ARB_vertex_array_bgra\n#define GL_ARB_vertex_array_bgra 1\n\n#define GL_BGRA 0x80E1\n\n#define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra)\n\n#endif /* GL_ARB_vertex_array_bgra */\n\n/* ----------------------- GL_ARB_vertex_array_object ---------------------- */\n\n#ifndef GL_ARB_vertex_array_object\n#define GL_ARB_vertex_array_object 1\n\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\n\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array);\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays);\ntypedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays);\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array);\n\n#define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray)\n#define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays)\n#define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays)\n#define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray)\n\n#define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object)\n\n#endif /* GL_ARB_vertex_array_object */\n\n/* ----------------------- GL_ARB_vertex_attrib_64bit ---------------------- */\n\n#ifndef GL_ARB_vertex_attrib_64bit\n#define GL_ARB_vertex_attrib_64bit 1\n\n#define GL_DOUBLE_MAT2 0x8F46\n#define GL_DOUBLE_MAT3 0x8F47\n#define GL_DOUBLE_MAT4 0x8F48\n#define GL_DOUBLE_VEC2 0x8FFC\n#define GL_DOUBLE_VEC3 0x8FFD\n#define GL_DOUBLE_VEC4 0x8FFE\n\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);\n\n#define glGetVertexAttribLdv GLEW_GET_FUN(__glewGetVertexAttribLdv)\n#define glVertexAttribL1d GLEW_GET_FUN(__glewVertexAttribL1d)\n#define glVertexAttribL1dv GLEW_GET_FUN(__glewVertexAttribL1dv)\n#define glVertexAttribL2d GLEW_GET_FUN(__glewVertexAttribL2d)\n#define glVertexAttribL2dv GLEW_GET_FUN(__glewVertexAttribL2dv)\n#define glVertexAttribL3d GLEW_GET_FUN(__glewVertexAttribL3d)\n#define glVertexAttribL3dv GLEW_GET_FUN(__glewVertexAttribL3dv)\n#define glVertexAttribL4d GLEW_GET_FUN(__glewVertexAttribL4d)\n#define glVertexAttribL4dv GLEW_GET_FUN(__glewVertexAttribL4dv)\n#define glVertexAttribLPointer GLEW_GET_FUN(__glewVertexAttribLPointer)\n\n#define GLEW_ARB_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_64bit)\n\n#endif /* GL_ARB_vertex_attrib_64bit */\n\n/* ---------------------- GL_ARB_vertex_attrib_binding --------------------- */\n\n#ifndef GL_ARB_vertex_attrib_binding\n#define GL_ARB_vertex_attrib_binding 1\n\n#define GL_VERTEX_ATTRIB_BINDING 0x82D4\n#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5\n#define GL_VERTEX_BINDING_DIVISOR 0x82D6\n#define GL_VERTEX_BINDING_OFFSET 0x82D7\n#define GL_VERTEX_BINDING_STRIDE 0x82D8\n#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9\n#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA\n\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);\n\n#define glBindVertexBuffer GLEW_GET_FUN(__glewBindVertexBuffer)\n#define glVertexAttribBinding GLEW_GET_FUN(__glewVertexAttribBinding)\n#define glVertexAttribFormat GLEW_GET_FUN(__glewVertexAttribFormat)\n#define glVertexAttribIFormat GLEW_GET_FUN(__glewVertexAttribIFormat)\n#define glVertexAttribLFormat GLEW_GET_FUN(__glewVertexAttribLFormat)\n#define glVertexBindingDivisor GLEW_GET_FUN(__glewVertexBindingDivisor)\n\n#define GLEW_ARB_vertex_attrib_binding GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_binding)\n\n#endif /* GL_ARB_vertex_attrib_binding */\n\n/* -------------------------- GL_ARB_vertex_blend -------------------------- */\n\n#ifndef GL_ARB_vertex_blend\n#define GL_ARB_vertex_blend 1\n\n#define GL_MODELVIEW0_ARB 0x1700\n#define GL_MODELVIEW1_ARB 0x850A\n#define GL_MAX_VERTEX_UNITS_ARB 0x86A4\n#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5\n#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6\n#define GL_VERTEX_BLEND_ARB 0x86A7\n#define GL_CURRENT_WEIGHT_ARB 0x86A8\n#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9\n#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA\n#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB\n#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC\n#define GL_WEIGHT_ARRAY_ARB 0x86AD\n#define GL_MODELVIEW2_ARB 0x8722\n#define GL_MODELVIEW3_ARB 0x8723\n#define GL_MODELVIEW4_ARB 0x8724\n#define GL_MODELVIEW5_ARB 0x8725\n#define GL_MODELVIEW6_ARB 0x8726\n#define GL_MODELVIEW7_ARB 0x8727\n#define GL_MODELVIEW8_ARB 0x8728\n#define GL_MODELVIEW9_ARB 0x8729\n#define GL_MODELVIEW10_ARB 0x872A\n#define GL_MODELVIEW11_ARB 0x872B\n#define GL_MODELVIEW12_ARB 0x872C\n#define GL_MODELVIEW13_ARB 0x872D\n#define GL_MODELVIEW14_ARB 0x872E\n#define GL_MODELVIEW15_ARB 0x872F\n#define GL_MODELVIEW16_ARB 0x8730\n#define GL_MODELVIEW17_ARB 0x8731\n#define GL_MODELVIEW18_ARB 0x8732\n#define GL_MODELVIEW19_ARB 0x8733\n#define GL_MODELVIEW20_ARB 0x8734\n#define GL_MODELVIEW21_ARB 0x8735\n#define GL_MODELVIEW22_ARB 0x8736\n#define GL_MODELVIEW23_ARB 0x8737\n#define GL_MODELVIEW24_ARB 0x8738\n#define GL_MODELVIEW25_ARB 0x8739\n#define GL_MODELVIEW26_ARB 0x873A\n#define GL_MODELVIEW27_ARB 0x873B\n#define GL_MODELVIEW28_ARB 0x873C\n#define GL_MODELVIEW29_ARB 0x873D\n#define GL_MODELVIEW30_ARB 0x873E\n#define GL_MODELVIEW31_ARB 0x873F\n\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights);\n\n#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB)\n#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB)\n#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB)\n#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB)\n#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB)\n#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB)\n#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB)\n#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB)\n#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB)\n#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB)\n\n#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend)\n\n#endif /* GL_ARB_vertex_blend */\n\n/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */\n\n#ifndef GL_ARB_vertex_buffer_object\n#define GL_ARB_vertex_buffer_object 1\n\n#define GL_BUFFER_SIZE_ARB 0x8764\n#define GL_BUFFER_USAGE_ARB 0x8765\n#define GL_ARRAY_BUFFER_ARB 0x8892\n#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893\n#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895\n#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896\n#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897\n#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898\n#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F\n#define GL_READ_ONLY_ARB 0x88B8\n#define GL_WRITE_ONLY_ARB 0x88B9\n#define GL_READ_WRITE_ARB 0x88BA\n#define GL_BUFFER_ACCESS_ARB 0x88BB\n#define GL_BUFFER_MAPPED_ARB 0x88BC\n#define GL_BUFFER_MAP_POINTER_ARB 0x88BD\n#define GL_STREAM_DRAW_ARB 0x88E0\n#define GL_STREAM_READ_ARB 0x88E1\n#define GL_STREAM_COPY_ARB 0x88E2\n#define GL_STATIC_DRAW_ARB 0x88E4\n#define GL_STATIC_READ_ARB 0x88E5\n#define GL_STATIC_COPY_ARB 0x88E6\n#define GL_DYNAMIC_DRAW_ARB 0x88E8\n#define GL_DYNAMIC_READ_ARB 0x88E9\n#define GL_DYNAMIC_COPY_ARB 0x88EA\n\ntypedef ptrdiff_t GLintptrARB;\ntypedef ptrdiff_t GLsizeiptrARB;\n\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage);\ntypedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data);\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers);\ntypedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params);\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data);\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer);\ntypedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target);\n\n#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB)\n#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB)\n#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB)\n#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB)\n#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB)\n#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB)\n#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB)\n#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB)\n#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB)\n#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB)\n#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB)\n\n#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object)\n\n#endif /* GL_ARB_vertex_buffer_object */\n\n/* ------------------------- GL_ARB_vertex_program ------------------------- */\n\n#ifndef GL_ARB_vertex_program\n#define GL_ARB_vertex_program 1\n\n#define GL_COLOR_SUM_ARB 0x8458\n#define GL_VERTEX_PROGRAM_ARB 0x8620\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625\n#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626\n#define GL_PROGRAM_LENGTH_ARB 0x8627\n#define GL_PROGRAM_STRING_ARB 0x8628\n#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E\n#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F\n#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640\n#define GL_CURRENT_MATRIX_ARB 0x8641\n#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642\n#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645\n#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B\n#define GL_PROGRAM_BINDING_ARB 0x8677\n#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A\n#define GL_PROGRAM_ERROR_STRING_ARB 0x8874\n#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875\n#define GL_PROGRAM_FORMAT_ARB 0x8876\n#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0\n#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1\n#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2\n#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3\n#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4\n#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5\n#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6\n#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7\n#define GL_PROGRAM_PARAMETERS_ARB 0x88A8\n#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9\n#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA\n#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB\n#define GL_PROGRAM_ATTRIBS_ARB 0x88AC\n#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD\n#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE\n#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF\n#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0\n#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1\n#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2\n#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3\n#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4\n#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5\n#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6\n#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7\n#define GL_MATRIX0_ARB 0x88C0\n#define GL_MATRIX1_ARB 0x88C1\n#define GL_MATRIX2_ARB 0x88C2\n#define GL_MATRIX3_ARB 0x88C3\n#define GL_MATRIX4_ARB 0x88C4\n#define GL_MATRIX5_ARB 0x88C5\n#define GL_MATRIX6_ARB 0x88C6\n#define GL_MATRIX7_ARB 0x88C7\n#define GL_MATRIX8_ARB 0x88C8\n#define GL_MATRIX9_ARB 0x88C9\n#define GL_MATRIX10_ARB 0x88CA\n#define GL_MATRIX11_ARB 0x88CB\n#define GL_MATRIX12_ARB 0x88CC\n#define GL_MATRIX13_ARB 0x88CD\n#define GL_MATRIX14_ARB 0x88CE\n#define GL_MATRIX15_ARB 0x88CF\n#define GL_MATRIX16_ARB 0x88D0\n#define GL_MATRIX17_ARB 0x88D1\n#define GL_MATRIX18_ARB 0x88D2\n#define GL_MATRIX19_ARB 0x88D3\n#define GL_MATRIX20_ARB 0x88D4\n#define GL_MATRIX21_ARB 0x88D5\n#define GL_MATRIX22_ARB 0x88D6\n#define GL_MATRIX23_ARB 0x88D7\n#define GL_MATRIX24_ARB 0x88D8\n#define GL_MATRIX25_ARB 0x88D9\n#define GL_MATRIX26_ARB 0x88DA\n#define GL_MATRIX27_ARB 0x88DB\n#define GL_MATRIX28_ARB 0x88DC\n#define GL_MATRIX29_ARB 0x88DD\n#define GL_MATRIX30_ARB 0x88DE\n#define GL_MATRIX31_ARB 0x88DF\n\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs);\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);\n\n#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB)\n#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB)\n#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB)\n#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB)\n#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB)\n#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB)\n#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB)\n#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB)\n#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB)\n#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB)\n#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB)\n#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB)\n#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB)\n#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB)\n#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB)\n#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB)\n#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB)\n#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB)\n#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB)\n#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB)\n#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB)\n#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB)\n#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB)\n#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB)\n#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB)\n#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB)\n#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB)\n#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB)\n#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB)\n#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB)\n#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB)\n#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB)\n#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB)\n#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB)\n#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB)\n#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB)\n#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB)\n#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB)\n#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB)\n#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB)\n#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB)\n#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB)\n#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB)\n#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB)\n#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB)\n#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB)\n#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB)\n#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB)\n#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB)\n#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB)\n#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB)\n#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB)\n#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB)\n#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB)\n#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB)\n#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB)\n#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB)\n#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB)\n#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB)\n#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB)\n#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB)\n#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB)\n\n#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program)\n\n#endif /* GL_ARB_vertex_program */\n\n/* -------------------------- GL_ARB_vertex_shader ------------------------- */\n\n#ifndef GL_ARB_vertex_shader\n#define GL_ARB_vertex_shader 1\n\n#define GL_VERTEX_SHADER_ARB 0x8B31\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A\n#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D\n#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89\n#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A\n\ntypedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name);\ntypedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name);\n\n#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB)\n#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB)\n#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB)\n\n#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader)\n\n#endif /* GL_ARB_vertex_shader */\n\n/* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */\n\n#ifndef GL_ARB_vertex_type_2_10_10_10_rev\n#define GL_ARB_vertex_type_2_10_10_10_rev 1\n\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_INT_2_10_10_10_REV 0x8D9F\n\ntypedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);\ntypedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color);\ntypedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);\ntypedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value);\n\n#define glColorP3ui GLEW_GET_FUN(__glewColorP3ui)\n#define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv)\n#define glColorP4ui GLEW_GET_FUN(__glewColorP4ui)\n#define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv)\n#define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui)\n#define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv)\n#define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui)\n#define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv)\n#define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui)\n#define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv)\n#define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui)\n#define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv)\n#define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui)\n#define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv)\n#define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui)\n#define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv)\n#define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui)\n#define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv)\n#define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui)\n#define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv)\n#define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui)\n#define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv)\n#define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui)\n#define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv)\n#define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui)\n#define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv)\n#define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui)\n#define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv)\n#define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui)\n#define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv)\n#define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui)\n#define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv)\n#define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui)\n#define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv)\n#define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui)\n#define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv)\n#define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui)\n#define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv)\n\n#define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev)\n\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n\n/* ------------------------- GL_ARB_viewport_array ------------------------- */\n\n#ifndef GL_ARB_viewport_array\n#define GL_ARB_viewport_array 1\n\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_VIEWPORT 0x0BA2\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_MAX_VIEWPORTS 0x825B\n#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C\n#define GL_VIEWPORT_BOUNDS_RANGE 0x825D\n#define GL_LAYER_PROVOKING_VERTEX 0x825E\n#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F\n#define GL_UNDEFINED_VERTEX 0x8260\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_PROVOKING_VERTEX 0x8E4F\n\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd * v);\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f);\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble* data);\ntypedef void (GLAPIENTRY * PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat* data);\ntypedef void (GLAPIENTRY * PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint * v);\ntypedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint * v);\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat * v);\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat * v);\n\n#define glDepthRangeArrayv GLEW_GET_FUN(__glewDepthRangeArrayv)\n#define glDepthRangeIndexed GLEW_GET_FUN(__glewDepthRangeIndexed)\n#define glGetDoublei_v GLEW_GET_FUN(__glewGetDoublei_v)\n#define glGetFloati_v GLEW_GET_FUN(__glewGetFloati_v)\n#define glScissorArrayv GLEW_GET_FUN(__glewScissorArrayv)\n#define glScissorIndexed GLEW_GET_FUN(__glewScissorIndexed)\n#define glScissorIndexedv GLEW_GET_FUN(__glewScissorIndexedv)\n#define glViewportArrayv GLEW_GET_FUN(__glewViewportArrayv)\n#define glViewportIndexedf GLEW_GET_FUN(__glewViewportIndexedf)\n#define glViewportIndexedfv GLEW_GET_FUN(__glewViewportIndexedfv)\n\n#define GLEW_ARB_viewport_array GLEW_GET_VAR(__GLEW_ARB_viewport_array)\n\n#endif /* GL_ARB_viewport_array */\n\n/* --------------------------- GL_ARB_window_pos --------------------------- */\n\n#ifndef GL_ARB_window_pos\n#define GL_ARB_window_pos 1\n\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p);\n\n#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB)\n#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB)\n#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB)\n#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB)\n#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB)\n#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB)\n#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB)\n#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB)\n#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB)\n#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB)\n#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB)\n#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB)\n#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB)\n#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB)\n#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB)\n#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB)\n\n#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos)\n\n#endif /* GL_ARB_window_pos */\n\n/* ------------------------- GL_ATIX_point_sprites ------------------------- */\n\n#ifndef GL_ATIX_point_sprites\n#define GL_ATIX_point_sprites 1\n\n#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0\n#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1\n#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2\n#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3\n#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4\n#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5\n\n#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites)\n\n#endif /* GL_ATIX_point_sprites */\n\n/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */\n\n#ifndef GL_ATIX_texture_env_combine3\n#define GL_ATIX_texture_env_combine3 1\n\n#define GL_MODULATE_ADD_ATIX 0x8744\n#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745\n#define GL_MODULATE_SUBTRACT_ATIX 0x8746\n\n#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3)\n\n#endif /* GL_ATIX_texture_env_combine3 */\n\n/* ----------------------- GL_ATIX_texture_env_route ----------------------- */\n\n#ifndef GL_ATIX_texture_env_route\n#define GL_ATIX_texture_env_route 1\n\n#define GL_SECONDARY_COLOR_ATIX 0x8747\n#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748\n#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749\n\n#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route)\n\n#endif /* GL_ATIX_texture_env_route */\n\n/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */\n\n#ifndef GL_ATIX_vertex_shader_output_point_size\n#define GL_ATIX_vertex_shader_output_point_size 1\n\n#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E\n\n#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size)\n\n#endif /* GL_ATIX_vertex_shader_output_point_size */\n\n/* -------------------------- GL_ATI_draw_buffers -------------------------- */\n\n#ifndef GL_ATI_draw_buffers\n#define GL_ATI_draw_buffers 1\n\n#define GL_MAX_DRAW_BUFFERS_ATI 0x8824\n#define GL_DRAW_BUFFER0_ATI 0x8825\n#define GL_DRAW_BUFFER1_ATI 0x8826\n#define GL_DRAW_BUFFER2_ATI 0x8827\n#define GL_DRAW_BUFFER3_ATI 0x8828\n#define GL_DRAW_BUFFER4_ATI 0x8829\n#define GL_DRAW_BUFFER5_ATI 0x882A\n#define GL_DRAW_BUFFER6_ATI 0x882B\n#define GL_DRAW_BUFFER7_ATI 0x882C\n#define GL_DRAW_BUFFER8_ATI 0x882D\n#define GL_DRAW_BUFFER9_ATI 0x882E\n#define GL_DRAW_BUFFER10_ATI 0x882F\n#define GL_DRAW_BUFFER11_ATI 0x8830\n#define GL_DRAW_BUFFER12_ATI 0x8831\n#define GL_DRAW_BUFFER13_ATI 0x8832\n#define GL_DRAW_BUFFER14_ATI 0x8833\n#define GL_DRAW_BUFFER15_ATI 0x8834\n\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs);\n\n#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI)\n\n#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers)\n\n#endif /* GL_ATI_draw_buffers */\n\n/* -------------------------- GL_ATI_element_array ------------------------- */\n\n#ifndef GL_ATI_element_array\n#define GL_ATI_element_array 1\n\n#define GL_ELEMENT_ARRAY_ATI 0x8768\n#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769\n#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A\n\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer);\n\n#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI)\n#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI)\n#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI)\n\n#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array)\n\n#endif /* GL_ATI_element_array */\n\n/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */\n\n#ifndef GL_ATI_envmap_bumpmap\n#define GL_ATI_envmap_bumpmap 1\n\n#define GL_BUMP_ROT_MATRIX_ATI 0x8775\n#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776\n#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777\n#define GL_BUMP_TEX_UNITS_ATI 0x8778\n#define GL_DUDV_ATI 0x8779\n#define GL_DU8DV8_ATI 0x877A\n#define GL_BUMP_ENVMAP_ATI 0x877B\n#define GL_BUMP_TARGET_ATI 0x877C\n\ntypedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);\ntypedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);\ntypedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);\ntypedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);\n\n#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI)\n#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI)\n#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI)\n#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI)\n\n#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap)\n\n#endif /* GL_ATI_envmap_bumpmap */\n\n/* ------------------------- GL_ATI_fragment_shader ------------------------ */\n\n#ifndef GL_ATI_fragment_shader\n#define GL_ATI_fragment_shader 1\n\n#define GL_RED_BIT_ATI 0x00000001\n#define GL_2X_BIT_ATI 0x00000001\n#define GL_4X_BIT_ATI 0x00000002\n#define GL_GREEN_BIT_ATI 0x00000002\n#define GL_COMP_BIT_ATI 0x00000002\n#define GL_BLUE_BIT_ATI 0x00000004\n#define GL_8X_BIT_ATI 0x00000004\n#define GL_NEGATE_BIT_ATI 0x00000004\n#define GL_BIAS_BIT_ATI 0x00000008\n#define GL_HALF_BIT_ATI 0x00000008\n#define GL_QUARTER_BIT_ATI 0x00000010\n#define GL_EIGHTH_BIT_ATI 0x00000020\n#define GL_SATURATE_BIT_ATI 0x00000040\n#define GL_FRAGMENT_SHADER_ATI 0x8920\n#define GL_REG_0_ATI 0x8921\n#define GL_REG_1_ATI 0x8922\n#define GL_REG_2_ATI 0x8923\n#define GL_REG_3_ATI 0x8924\n#define GL_REG_4_ATI 0x8925\n#define GL_REG_5_ATI 0x8926\n#define GL_CON_0_ATI 0x8941\n#define GL_CON_1_ATI 0x8942\n#define GL_CON_2_ATI 0x8943\n#define GL_CON_3_ATI 0x8944\n#define GL_CON_4_ATI 0x8945\n#define GL_CON_5_ATI 0x8946\n#define GL_CON_6_ATI 0x8947\n#define GL_CON_7_ATI 0x8948\n#define GL_MOV_ATI 0x8961\n#define GL_ADD_ATI 0x8963\n#define GL_MUL_ATI 0x8964\n#define GL_SUB_ATI 0x8965\n#define GL_DOT3_ATI 0x8966\n#define GL_DOT4_ATI 0x8967\n#define GL_MAD_ATI 0x8968\n#define GL_LERP_ATI 0x8969\n#define GL_CND_ATI 0x896A\n#define GL_CND0_ATI 0x896B\n#define GL_DOT2_ADD_ATI 0x896C\n#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D\n#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E\n#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F\n#define GL_NUM_PASSES_ATI 0x8970\n#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971\n#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972\n#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973\n#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974\n#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975\n#define GL_SWIZZLE_STR_ATI 0x8976\n#define GL_SWIZZLE_STQ_ATI 0x8977\n#define GL_SWIZZLE_STR_DR_ATI 0x8978\n#define GL_SWIZZLE_STQ_DQ_ATI 0x8979\n#define GL_SWIZZLE_STRQ_ATI 0x897A\n#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B\n\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\ntypedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void);\ntypedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);\ntypedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);\ntypedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value);\n\n#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI)\n#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI)\n#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI)\n#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI)\n#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI)\n#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI)\n#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI)\n#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI)\n#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI)\n#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI)\n#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI)\n#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI)\n#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI)\n#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI)\n\n#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader)\n\n#endif /* GL_ATI_fragment_shader */\n\n/* ------------------------ GL_ATI_map_object_buffer ----------------------- */\n\n#ifndef GL_ATI_map_object_buffer\n#define GL_ATI_map_object_buffer 1\n\ntypedef GLvoid * (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);\n\n#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI)\n#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI)\n\n#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer)\n\n#endif /* GL_ATI_map_object_buffer */\n\n/* ----------------------------- GL_ATI_meminfo ---------------------------- */\n\n#ifndef GL_ATI_meminfo\n#define GL_ATI_meminfo 1\n\n#define GL_VBO_FREE_MEMORY_ATI 0x87FB\n#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC\n#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD\n\n#define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo)\n\n#endif /* GL_ATI_meminfo */\n\n/* -------------------------- GL_ATI_pn_triangles -------------------------- */\n\n#ifndef GL_ATI_pn_triangles\n#define GL_ATI_pn_triangles 1\n\n#define GL_PN_TRIANGLES_ATI 0x87F0\n#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1\n#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2\n#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3\n#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4\n#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5\n#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6\n#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7\n#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8\n\ntypedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);\n\n#define glPNTrianglesfATI GLEW_GET_FUN(__glewPNTrianglesfATI)\n#define glPNTrianglesiATI GLEW_GET_FUN(__glewPNTrianglesiATI)\n\n#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles)\n\n#endif /* GL_ATI_pn_triangles */\n\n/* ------------------------ GL_ATI_separate_stencil ------------------------ */\n\n#ifndef GL_ATI_separate_stencil\n#define GL_ATI_separate_stencil 1\n\n#define GL_STENCIL_BACK_FUNC_ATI 0x8800\n#define GL_STENCIL_BACK_FAIL_ATI 0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803\n\ntypedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\n\n#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI)\n#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI)\n\n#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil)\n\n#endif /* GL_ATI_separate_stencil */\n\n/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */\n\n#ifndef GL_ATI_shader_texture_lod\n#define GL_ATI_shader_texture_lod 1\n\n#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod)\n\n#endif /* GL_ATI_shader_texture_lod */\n\n/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */\n\n#ifndef GL_ATI_text_fragment_shader\n#define GL_ATI_text_fragment_shader 1\n\n#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200\n\n#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader)\n\n#endif /* GL_ATI_text_fragment_shader */\n\n/* --------------------- GL_ATI_texture_compression_3dc -------------------- */\n\n#ifndef GL_ATI_texture_compression_3dc\n#define GL_ATI_texture_compression_3dc 1\n\n#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837\n\n#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc)\n\n#endif /* GL_ATI_texture_compression_3dc */\n\n/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */\n\n#ifndef GL_ATI_texture_env_combine3\n#define GL_ATI_texture_env_combine3 1\n\n#define GL_MODULATE_ADD_ATI 0x8744\n#define GL_MODULATE_SIGNED_ADD_ATI 0x8745\n#define GL_MODULATE_SUBTRACT_ATI 0x8746\n\n#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3)\n\n#endif /* GL_ATI_texture_env_combine3 */\n\n/* -------------------------- GL_ATI_texture_float ------------------------- */\n\n#ifndef GL_ATI_texture_float\n#define GL_ATI_texture_float 1\n\n#define GL_RGBA_FLOAT32_ATI 0x8814\n#define GL_RGB_FLOAT32_ATI 0x8815\n#define GL_ALPHA_FLOAT32_ATI 0x8816\n#define GL_INTENSITY_FLOAT32_ATI 0x8817\n#define GL_LUMINANCE_FLOAT32_ATI 0x8818\n#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819\n#define GL_RGBA_FLOAT16_ATI 0x881A\n#define GL_RGB_FLOAT16_ATI 0x881B\n#define GL_ALPHA_FLOAT16_ATI 0x881C\n#define GL_INTENSITY_FLOAT16_ATI 0x881D\n#define GL_LUMINANCE_FLOAT16_ATI 0x881E\n#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F\n\n#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float)\n\n#endif /* GL_ATI_texture_float */\n\n/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */\n\n#ifndef GL_ATI_texture_mirror_once\n#define GL_ATI_texture_mirror_once 1\n\n#define GL_MIRROR_CLAMP_ATI 0x8742\n#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743\n\n#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once)\n\n#endif /* GL_ATI_texture_mirror_once */\n\n/* ----------------------- GL_ATI_vertex_array_object ---------------------- */\n\n#ifndef GL_ATI_vertex_array_object\n#define GL_ATI_vertex_array_object 1\n\n#define GL_STATIC_ATI 0x8760\n#define GL_DYNAMIC_ATI 0x8761\n#define GL_PRESERVE_ATI 0x8762\n#define GL_DISCARD_ATI 0x8763\n#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764\n#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765\n#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766\n#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767\n\ntypedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\ntypedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage);\ntypedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve);\ntypedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\n\n#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI)\n#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI)\n#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI)\n#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI)\n#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI)\n#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI)\n#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI)\n#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI)\n#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI)\n#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI)\n#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI)\n#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI)\n\n#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object)\n\n#endif /* GL_ATI_vertex_array_object */\n\n/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */\n\n#ifndef GL_ATI_vertex_attrib_array_object\n#define GL_ATI_vertex_attrib_array_object 1\n\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);\n\n#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI)\n#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI)\n#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI)\n\n#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object)\n\n#endif /* GL_ATI_vertex_attrib_array_object */\n\n/* ------------------------- GL_ATI_vertex_streams ------------------------- */\n\n#ifndef GL_ATI_vertex_streams\n#define GL_ATI_vertex_streams 1\n\n#define GL_MAX_VERTEX_STREAMS_ATI 0x876B\n#define GL_VERTEX_SOURCE_ATI 0x876C\n#define GL_VERTEX_STREAM0_ATI 0x876D\n#define GL_VERTEX_STREAM1_ATI 0x876E\n#define GL_VERTEX_STREAM2_ATI 0x876F\n#define GL_VERTEX_STREAM3_ATI 0x8770\n#define GL_VERTEX_STREAM4_ATI 0x8771\n#define GL_VERTEX_STREAM5_ATI 0x8772\n#define GL_VERTEX_STREAM6_ATI 0x8773\n#define GL_VERTEX_STREAM7_ATI 0x8774\n\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);\n\n#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI)\n#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI)\n#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI)\n#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI)\n#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI)\n#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI)\n#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI)\n#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI)\n#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI)\n#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI)\n#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI)\n#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI)\n#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI)\n#define glVertexStream1dATI GLEW_GET_FUN(__glewVertexStream1dATI)\n#define glVertexStream1dvATI GLEW_GET_FUN(__glewVertexStream1dvATI)\n#define glVertexStream1fATI GLEW_GET_FUN(__glewVertexStream1fATI)\n#define glVertexStream1fvATI GLEW_GET_FUN(__glewVertexStream1fvATI)\n#define glVertexStream1iATI GLEW_GET_FUN(__glewVertexStream1iATI)\n#define glVertexStream1ivATI GLEW_GET_FUN(__glewVertexStream1ivATI)\n#define glVertexStream1sATI GLEW_GET_FUN(__glewVertexStream1sATI)\n#define glVertexStream1svATI GLEW_GET_FUN(__glewVertexStream1svATI)\n#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI)\n#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI)\n#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI)\n#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI)\n#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI)\n#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI)\n#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI)\n#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI)\n#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI)\n#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI)\n#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI)\n#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI)\n#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI)\n#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI)\n#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI)\n#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI)\n#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI)\n#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI)\n#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI)\n#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI)\n#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI)\n#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI)\n#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI)\n#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI)\n\n#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams)\n\n#endif /* GL_ATI_vertex_streams */\n\n/* --------------------------- GL_EXT_422_pixels --------------------------- */\n\n#ifndef GL_EXT_422_pixels\n#define GL_EXT_422_pixels 1\n\n#define GL_422_EXT 0x80CC\n#define GL_422_REV_EXT 0x80CD\n#define GL_422_AVERAGE_EXT 0x80CE\n#define GL_422_REV_AVERAGE_EXT 0x80CF\n\n#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels)\n\n#endif /* GL_EXT_422_pixels */\n\n/* ---------------------------- GL_EXT_Cg_shader --------------------------- */\n\n#ifndef GL_EXT_Cg_shader\n#define GL_EXT_Cg_shader 1\n\n#define GL_CG_VERTEX_SHADER_EXT 0x890E\n#define GL_CG_FRAGMENT_SHADER_EXT 0x890F\n\n#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader)\n\n#endif /* GL_EXT_Cg_shader */\n\n/* ------------------------------ GL_EXT_abgr ------------------------------ */\n\n#ifndef GL_EXT_abgr\n#define GL_EXT_abgr 1\n\n#define GL_ABGR_EXT 0x8000\n\n#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr)\n\n#endif /* GL_EXT_abgr */\n\n/* ------------------------------ GL_EXT_bgra ------------------------------ */\n\n#ifndef GL_EXT_bgra\n#define GL_EXT_bgra 1\n\n#define GL_BGR_EXT 0x80E0\n#define GL_BGRA_EXT 0x80E1\n\n#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra)\n\n#endif /* GL_EXT_bgra */\n\n/* ------------------------ GL_EXT_bindable_uniform ------------------------ */\n\n#ifndef GL_EXT_bindable_uniform\n#define GL_EXT_bindable_uniform 1\n\n#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2\n#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3\n#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4\n#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED\n#define GL_UNIFORM_BUFFER_EXT 0x8DEE\n#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF\n\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);\ntypedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);\n\n#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT)\n#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT)\n#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT)\n\n#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform)\n\n#endif /* GL_EXT_bindable_uniform */\n\n/* --------------------------- GL_EXT_blend_color -------------------------- */\n\n#ifndef GL_EXT_blend_color\n#define GL_EXT_blend_color 1\n\n#define GL_CONSTANT_COLOR_EXT 0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002\n#define GL_CONSTANT_ALPHA_EXT 0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004\n#define GL_BLEND_COLOR_EXT 0x8005\n\ntypedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\n\n#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT)\n\n#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color)\n\n#endif /* GL_EXT_blend_color */\n\n/* --------------------- GL_EXT_blend_equation_separate -------------------- */\n\n#ifndef GL_EXT_blend_equation_separate\n#define GL_EXT_blend_equation_separate 1\n\n#define GL_BLEND_EQUATION_RGB_EXT 0x8009\n#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D\n\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);\n\n#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT)\n\n#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate)\n\n#endif /* GL_EXT_blend_equation_separate */\n\n/* ----------------------- GL_EXT_blend_func_separate ---------------------- */\n\n#ifndef GL_EXT_blend_func_separate\n#define GL_EXT_blend_func_separate 1\n\n#define GL_BLEND_DST_RGB_EXT 0x80C8\n#define GL_BLEND_SRC_RGB_EXT 0x80C9\n#define GL_BLEND_DST_ALPHA_EXT 0x80CA\n#define GL_BLEND_SRC_ALPHA_EXT 0x80CB\n\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n\n#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT)\n\n#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate)\n\n#endif /* GL_EXT_blend_func_separate */\n\n/* ------------------------- GL_EXT_blend_logic_op ------------------------- */\n\n#ifndef GL_EXT_blend_logic_op\n#define GL_EXT_blend_logic_op 1\n\n#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op)\n\n#endif /* GL_EXT_blend_logic_op */\n\n/* -------------------------- GL_EXT_blend_minmax -------------------------- */\n\n#ifndef GL_EXT_blend_minmax\n#define GL_EXT_blend_minmax 1\n\n#define GL_FUNC_ADD_EXT 0x8006\n#define GL_MIN_EXT 0x8007\n#define GL_MAX_EXT 0x8008\n#define GL_BLEND_EQUATION_EXT 0x8009\n\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);\n\n#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT)\n\n#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax)\n\n#endif /* GL_EXT_blend_minmax */\n\n/* ------------------------- GL_EXT_blend_subtract ------------------------- */\n\n#ifndef GL_EXT_blend_subtract\n#define GL_EXT_blend_subtract 1\n\n#define GL_FUNC_SUBTRACT_EXT 0x800A\n#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B\n\n#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract)\n\n#endif /* GL_EXT_blend_subtract */\n\n/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */\n\n#ifndef GL_EXT_clip_volume_hint\n#define GL_EXT_clip_volume_hint 1\n\n#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0\n\n#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint)\n\n#endif /* GL_EXT_clip_volume_hint */\n\n/* ------------------------------ GL_EXT_cmyka ----------------------------- */\n\n#ifndef GL_EXT_cmyka\n#define GL_EXT_cmyka 1\n\n#define GL_CMYK_EXT 0x800C\n#define GL_CMYKA_EXT 0x800D\n#define GL_PACK_CMYK_HINT_EXT 0x800E\n#define GL_UNPACK_CMYK_HINT_EXT 0x800F\n\n#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka)\n\n#endif /* GL_EXT_cmyka */\n\n/* ------------------------- GL_EXT_color_subtable ------------------------- */\n\n#ifndef GL_EXT_color_subtable\n#define GL_EXT_color_subtable 1\n\ntypedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\n\n#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT)\n#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT)\n\n#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable)\n\n#endif /* GL_EXT_color_subtable */\n\n/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */\n\n#ifndef GL_EXT_compiled_vertex_array\n#define GL_EXT_compiled_vertex_array 1\n\n#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8\n#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9\n\ntypedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void);\n\n#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT)\n#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT)\n\n#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array)\n\n#endif /* GL_EXT_compiled_vertex_array */\n\n/* --------------------------- GL_EXT_convolution -------------------------- */\n\n#ifndef GL_EXT_convolution\n#define GL_EXT_convolution 1\n\n#define GL_CONVOLUTION_1D_EXT 0x8010\n#define GL_CONVOLUTION_2D_EXT 0x8011\n#define GL_SEPARABLE_2D_EXT 0x8012\n#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013\n#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014\n#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015\n#define GL_REDUCE_EXT 0x8016\n#define GL_CONVOLUTION_FORMAT_EXT 0x8017\n#define GL_CONVOLUTION_WIDTH_EXT 0x8018\n#define GL_CONVOLUTION_HEIGHT_EXT 0x8019\n#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A\n#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B\n#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C\n#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D\n#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E\n#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F\n#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020\n#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021\n#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022\n#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023\n\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span);\ntypedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column);\n\n#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT)\n#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT)\n#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT)\n#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT)\n#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT)\n#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT)\n#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT)\n#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT)\n#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT)\n#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT)\n#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT)\n#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT)\n#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT)\n\n#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution)\n\n#endif /* GL_EXT_convolution */\n\n/* ------------------------ GL_EXT_coordinate_frame ------------------------ */\n\n#ifndef GL_EXT_coordinate_frame\n#define GL_EXT_coordinate_frame 1\n\n#define GL_TANGENT_ARRAY_EXT 0x8439\n#define GL_BINORMAL_ARRAY_EXT 0x843A\n#define GL_CURRENT_TANGENT_EXT 0x843B\n#define GL_CURRENT_BINORMAL_EXT 0x843C\n#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E\n#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F\n#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440\n#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441\n#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442\n#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443\n#define GL_MAP1_TANGENT_EXT 0x8444\n#define GL_MAP2_TANGENT_EXT 0x8445\n#define GL_MAP1_BINORMAL_EXT 0x8446\n#define GL_MAP2_BINORMAL_EXT 0x8447\n\ntypedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer);\ntypedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer);\n\n#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT)\n#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT)\n\n#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame)\n\n#endif /* GL_EXT_coordinate_frame */\n\n/* -------------------------- GL_EXT_copy_texture -------------------------- */\n\n#ifndef GL_EXT_copy_texture\n#define GL_EXT_copy_texture 1\n\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n\n#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT)\n#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT)\n#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT)\n#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT)\n#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT)\n\n#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture)\n\n#endif /* GL_EXT_copy_texture */\n\n/* --------------------------- GL_EXT_cull_vertex -------------------------- */\n\n#ifndef GL_EXT_cull_vertex\n#define GL_EXT_cull_vertex 1\n\n#define GL_CULL_VERTEX_EXT 0x81AA\n#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB\n#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC\n\ntypedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params);\n\n#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT)\n#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT)\n\n#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex)\n\n#endif /* GL_EXT_cull_vertex */\n\n/* -------------------------- GL_EXT_debug_marker -------------------------- */\n\n#ifndef GL_EXT_debug_marker\n#define GL_EXT_debug_marker 1\n\ntypedef void (GLAPIENTRY * PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar* marker);\ntypedef void (GLAPIENTRY * PFNGLPOPGROUPMARKEREXTPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar* marker);\n\n#define glInsertEventMarkerEXT GLEW_GET_FUN(__glewInsertEventMarkerEXT)\n#define glPopGroupMarkerEXT GLEW_GET_FUN(__glewPopGroupMarkerEXT)\n#define glPushGroupMarkerEXT GLEW_GET_FUN(__glewPushGroupMarkerEXT)\n\n#define GLEW_EXT_debug_marker GLEW_GET_VAR(__GLEW_EXT_debug_marker)\n\n#endif /* GL_EXT_debug_marker */\n\n/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */\n\n#ifndef GL_EXT_depth_bounds_test\n#define GL_EXT_depth_bounds_test 1\n\n#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890\n#define GL_DEPTH_BOUNDS_EXT 0x8891\n\ntypedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);\n\n#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT)\n\n#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test)\n\n#endif /* GL_EXT_depth_bounds_test */\n\n/* ----------------------- GL_EXT_direct_state_access ---------------------- */\n\n#ifndef GL_EXT_direct_state_access\n#define GL_EXT_direct_state_access 1\n\n#define GL_PROGRAM_MATRIX_EXT 0x8E2D\n#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E\n#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F\n\ntypedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);\ntypedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\ntypedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void* img);\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void* img);\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void* pixels);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void* data);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void* string);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid** params);\ntypedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid** params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void* pixels);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid** param);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid** param);\ntypedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);\ntypedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\ntypedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f);\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode);\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m);\ntypedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f);\ntypedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode);\ntypedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode);\ntypedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void* data, GLenum usage);\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data);\ntypedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void* string);\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param);\ntypedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\n\n#define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT)\n#define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT)\n#define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT)\n#define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT)\n#define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT)\n#define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT)\n#define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT)\n#define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT)\n#define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT)\n#define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT)\n#define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT)\n#define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT)\n#define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT)\n#define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT)\n#define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT)\n#define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT)\n#define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT)\n#define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT)\n#define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT)\n#define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT)\n#define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT)\n#define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT)\n#define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT)\n#define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT)\n#define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT)\n#define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT)\n#define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT)\n#define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT)\n#define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT)\n#define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT)\n#define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT)\n#define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT)\n#define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT)\n#define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT)\n#define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT)\n#define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT)\n#define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT)\n#define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT)\n#define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT)\n#define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT)\n#define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT)\n#define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT)\n#define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT)\n#define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT)\n#define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT)\n#define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT)\n#define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT)\n#define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT)\n#define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT)\n#define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT)\n#define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT)\n#define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT)\n#define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT)\n#define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT)\n#define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT)\n#define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT)\n#define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT)\n#define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT)\n#define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT)\n#define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT)\n#define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT)\n#define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT)\n#define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT)\n#define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT)\n#define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT)\n#define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT)\n#define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT)\n#define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT)\n#define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT)\n#define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT)\n#define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT)\n#define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT)\n#define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT)\n#define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT)\n#define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT)\n#define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT)\n#define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT)\n#define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT)\n#define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT)\n#define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT)\n#define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT)\n#define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT)\n#define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT)\n#define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT)\n#define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT)\n#define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT)\n#define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT)\n#define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT)\n#define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT)\n#define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT)\n#define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT)\n#define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT)\n#define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT)\n#define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT)\n#define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT)\n#define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT)\n#define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT)\n#define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT)\n#define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT)\n#define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT)\n#define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT)\n#define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT)\n#define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT)\n#define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT)\n#define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT)\n#define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT)\n#define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT)\n#define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT)\n#define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT)\n#define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT)\n#define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT)\n#define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT)\n#define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT)\n#define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT)\n#define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT)\n#define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT)\n#define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT)\n#define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT)\n#define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT)\n#define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT)\n#define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT)\n#define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT)\n#define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT)\n#define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT)\n#define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT)\n#define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT)\n#define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT)\n#define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT)\n#define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT)\n#define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT)\n#define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT)\n#define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT)\n#define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT)\n#define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT)\n#define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT)\n#define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT)\n#define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT)\n#define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT)\n#define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT)\n#define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT)\n#define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT)\n#define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT)\n#define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT)\n#define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT)\n#define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT)\n#define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT)\n#define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT)\n#define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT)\n#define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT)\n#define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT)\n#define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT)\n#define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT)\n#define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT)\n#define glProgramUniform1dEXT GLEW_GET_FUN(__glewProgramUniform1dEXT)\n#define glProgramUniform1dvEXT GLEW_GET_FUN(__glewProgramUniform1dvEXT)\n#define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT)\n#define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT)\n#define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT)\n#define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT)\n#define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT)\n#define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT)\n#define glProgramUniform2dEXT GLEW_GET_FUN(__glewProgramUniform2dEXT)\n#define glProgramUniform2dvEXT GLEW_GET_FUN(__glewProgramUniform2dvEXT)\n#define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT)\n#define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT)\n#define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT)\n#define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT)\n#define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT)\n#define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT)\n#define glProgramUniform3dEXT GLEW_GET_FUN(__glewProgramUniform3dEXT)\n#define glProgramUniform3dvEXT GLEW_GET_FUN(__glewProgramUniform3dvEXT)\n#define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT)\n#define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT)\n#define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT)\n#define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT)\n#define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT)\n#define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT)\n#define glProgramUniform4dEXT GLEW_GET_FUN(__glewProgramUniform4dEXT)\n#define glProgramUniform4dvEXT GLEW_GET_FUN(__glewProgramUniform4dvEXT)\n#define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT)\n#define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT)\n#define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT)\n#define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT)\n#define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT)\n#define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT)\n#define glProgramUniformMatrix2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2dvEXT)\n#define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT)\n#define glProgramUniformMatrix2x3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3dvEXT)\n#define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT)\n#define glProgramUniformMatrix2x4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4dvEXT)\n#define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT)\n#define glProgramUniformMatrix3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3dvEXT)\n#define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT)\n#define glProgramUniformMatrix3x2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2dvEXT)\n#define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT)\n#define glProgramUniformMatrix3x4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4dvEXT)\n#define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT)\n#define glProgramUniformMatrix4dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4dvEXT)\n#define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT)\n#define glProgramUniformMatrix4x2dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2dvEXT)\n#define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT)\n#define glProgramUniformMatrix4x3dvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3dvEXT)\n#define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT)\n#define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT)\n#define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT)\n#define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT)\n#define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT)\n#define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT)\n#define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT)\n#define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT)\n#define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT)\n#define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT)\n#define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT)\n#define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT)\n#define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT)\n#define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT)\n#define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT)\n#define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT)\n#define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT)\n#define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT)\n#define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT)\n#define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT)\n#define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT)\n#define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT)\n#define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT)\n#define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT)\n#define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT)\n#define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT)\n#define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT)\n#define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT)\n\n#define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access)\n\n#endif /* GL_EXT_direct_state_access */\n\n/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */\n\n#ifndef GL_EXT_draw_buffers2\n#define GL_EXT_draw_buffers2 1\n\ntypedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\ntypedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\ntypedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data);\ntypedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);\n\n#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT)\n#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT)\n#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT)\n#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT)\n#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT)\n#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT)\n\n#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2)\n\n#endif /* GL_EXT_draw_buffers2 */\n\n/* ------------------------- GL_EXT_draw_instanced ------------------------- */\n\n#ifndef GL_EXT_draw_instanced\n#define GL_EXT_draw_instanced 1\n\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);\n\n#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT)\n#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT)\n\n#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced)\n\n#endif /* GL_EXT_draw_instanced */\n\n/* ----------------------- GL_EXT_draw_range_elements ---------------------- */\n\n#ifndef GL_EXT_draw_range_elements\n#define GL_EXT_draw_range_elements 1\n\n#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8\n#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9\n\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);\n\n#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT)\n\n#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements)\n\n#endif /* GL_EXT_draw_range_elements */\n\n/* ---------------------------- GL_EXT_fog_coord --------------------------- */\n\n#ifndef GL_EXT_fog_coord\n#define GL_EXT_fog_coord 1\n\n#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450\n#define GL_FOG_COORDINATE_EXT 0x8451\n#define GL_FRAGMENT_DEPTH_EXT 0x8452\n#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453\n#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454\n#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455\n#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456\n#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457\n\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);\n\n#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT)\n#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT)\n#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT)\n#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT)\n#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT)\n\n#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord)\n\n#endif /* GL_EXT_fog_coord */\n\n/* ------------------------ GL_EXT_fragment_lighting ----------------------- */\n\n#ifndef GL_EXT_fragment_lighting\n#define GL_EXT_fragment_lighting 1\n\n#define GL_FRAGMENT_LIGHTING_EXT 0x8400\n#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401\n#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402\n#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403\n#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404\n#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405\n#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406\n#define GL_LIGHT_ENV_MODE_EXT 0x8407\n#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408\n#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409\n#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A\n#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B\n#define GL_FRAGMENT_LIGHT0_EXT 0x840C\n#define GL_FRAGMENT_LIGHT7_EXT 0x8413\n\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param);\n\n#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT)\n#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT)\n#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT)\n#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT)\n#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT)\n#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT)\n#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT)\n#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT)\n#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT)\n#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT)\n#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT)\n#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT)\n#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT)\n#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT)\n#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT)\n#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT)\n#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT)\n#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT)\n\n#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting)\n\n#endif /* GL_EXT_fragment_lighting */\n\n/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */\n\n#ifndef GL_EXT_framebuffer_blit\n#define GL_EXT_framebuffer_blit 1\n\n#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6\n#define GL_READ_FRAMEBUFFER_EXT 0x8CA8\n#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9\n#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA\n\ntypedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n\n#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT)\n\n#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit)\n\n#endif /* GL_EXT_framebuffer_blit */\n\n/* --------------------- GL_EXT_framebuffer_multisample -------------------- */\n\n#ifndef GL_EXT_framebuffer_multisample\n#define GL_EXT_framebuffer_multisample 1\n\n#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56\n#define GL_MAX_SAMPLES_EXT 0x8D57\n\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n\n#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT)\n\n#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample)\n\n#endif /* GL_EXT_framebuffer_multisample */\n\n/* --------------- GL_EXT_framebuffer_multisample_blit_scaled -------------- */\n\n#ifndef GL_EXT_framebuffer_multisample_blit_scaled\n#define GL_EXT_framebuffer_multisample_blit_scaled 1\n\n#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA\n#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB\n\n#define GLEW_EXT_framebuffer_multisample_blit_scaled GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample_blit_scaled)\n\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n\n/* ----------------------- GL_EXT_framebuffer_object ----------------------- */\n\n#ifndef GL_EXT_framebuffer_object\n#define GL_EXT_framebuffer_object 1\n\n#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506\n#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8\n#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6\n#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4\n#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9\n#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC\n#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD\n#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF\n#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0\n#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1\n#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2\n#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3\n#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4\n#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5\n#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6\n#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7\n#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8\n#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9\n#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA\n#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB\n#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC\n#define GL_COLOR_ATTACHMENT13_EXT 0x8CED\n#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE\n#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF\n#define GL_DEPTH_ATTACHMENT_EXT 0x8D00\n#define GL_STENCIL_ATTACHMENT_EXT 0x8D20\n#define GL_FRAMEBUFFER_EXT 0x8D40\n#define GL_RENDERBUFFER_EXT 0x8D41\n#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42\n#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44\n#define GL_STENCIL_INDEX1_EXT 0x8D46\n#define GL_STENCIL_INDEX4_EXT 0x8D47\n#define GL_STENCIL_INDEX8_EXT 0x8D48\n#define GL_STENCIL_INDEX16_EXT 0x8D49\n#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55\n\ntypedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);\ntypedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers);\ntypedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\ntypedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers);\ntypedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers);\ntypedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);\ntypedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\n\n#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT)\n#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT)\n#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT)\n#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT)\n#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT)\n#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT)\n#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT)\n#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT)\n#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT)\n#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT)\n#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT)\n#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT)\n#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT)\n#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT)\n#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT)\n#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT)\n#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT)\n\n#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object)\n\n#endif /* GL_EXT_framebuffer_object */\n\n/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */\n\n#ifndef GL_EXT_framebuffer_sRGB\n#define GL_EXT_framebuffer_sRGB 1\n\n#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9\n#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA\n\n#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB)\n\n#endif /* GL_EXT_framebuffer_sRGB */\n\n/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */\n\n#ifndef GL_EXT_geometry_shader4\n#define GL_EXT_geometry_shader4 1\n\n#define GL_LINES_ADJACENCY_EXT 0xA\n#define GL_LINE_STRIP_ADJACENCY_EXT 0xB\n#define GL_TRIANGLES_ADJACENCY_EXT 0xC\n#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD\n#define GL_PROGRAM_POINT_SIZE_EXT 0x8642\n#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9\n#define GL_GEOMETRY_SHADER_EXT 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA\n#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB\n#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);\n\n#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT)\n#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT)\n#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT)\n\n#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4)\n\n#endif /* GL_EXT_geometry_shader4 */\n\n/* --------------------- GL_EXT_gpu_program_parameters --------------------- */\n\n#ifndef GL_EXT_gpu_program_parameters\n#define GL_EXT_gpu_program_parameters 1\n\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params);\n\n#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT)\n#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT)\n\n#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters)\n\n#endif /* GL_EXT_gpu_program_parameters */\n\n/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */\n\n#ifndef GL_EXT_gpu_shader4\n#define GL_EXT_gpu_shader4 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD\n#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0\n#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1\n#define GL_SAMPLER_BUFFER_EXT 0x8DC2\n#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3\n#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5\n#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6\n#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7\n#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8\n#define GL_INT_SAMPLER_1D_EXT 0x8DC9\n#define GL_INT_SAMPLER_2D_EXT 0x8DCA\n#define GL_INT_SAMPLER_3D_EXT 0x8DCB\n#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC\n#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD\n#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE\n#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF\n#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0\n#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8\n\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\n\n#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT)\n#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT)\n#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT)\n#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT)\n#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT)\n#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT)\n#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT)\n#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT)\n#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT)\n#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT)\n#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT)\n#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT)\n#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT)\n#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT)\n#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT)\n#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT)\n#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT)\n#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT)\n#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT)\n#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT)\n#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT)\n#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT)\n#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT)\n#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT)\n#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT)\n#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT)\n#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT)\n#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT)\n#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT)\n#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT)\n#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT)\n#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT)\n#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT)\n#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT)\n\n#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4)\n\n#endif /* GL_EXT_gpu_shader4 */\n\n/* ---------------------------- GL_EXT_histogram --------------------------- */\n\n#ifndef GL_EXT_histogram\n#define GL_EXT_histogram 1\n\n#define GL_HISTOGRAM_EXT 0x8024\n#define GL_PROXY_HISTOGRAM_EXT 0x8025\n#define GL_HISTOGRAM_WIDTH_EXT 0x8026\n#define GL_HISTOGRAM_FORMAT_EXT 0x8027\n#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028\n#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029\n#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A\n#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B\n#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C\n#define GL_HISTOGRAM_SINK_EXT 0x802D\n#define GL_MINMAX_EXT 0x802E\n#define GL_MINMAX_FORMAT_EXT 0x802F\n#define GL_MINMAX_SINK_EXT 0x8030\n\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values);\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\ntypedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);\ntypedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target);\n\n#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT)\n#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT)\n#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT)\n#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT)\n#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT)\n#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT)\n#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT)\n#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT)\n#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT)\n#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT)\n\n#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram)\n\n#endif /* GL_EXT_histogram */\n\n/* ----------------------- GL_EXT_index_array_formats ---------------------- */\n\n#ifndef GL_EXT_index_array_formats\n#define GL_EXT_index_array_formats 1\n\n#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats)\n\n#endif /* GL_EXT_index_array_formats */\n\n/* --------------------------- GL_EXT_index_func --------------------------- */\n\n#ifndef GL_EXT_index_func\n#define GL_EXT_index_func 1\n\ntypedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref);\n\n#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT)\n\n#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func)\n\n#endif /* GL_EXT_index_func */\n\n/* ------------------------- GL_EXT_index_material ------------------------- */\n\n#ifndef GL_EXT_index_material\n#define GL_EXT_index_material 1\n\ntypedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);\n\n#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT)\n\n#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material)\n\n#endif /* GL_EXT_index_material */\n\n/* -------------------------- GL_EXT_index_texture ------------------------- */\n\n#ifndef GL_EXT_index_texture\n#define GL_EXT_index_texture 1\n\n#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture)\n\n#endif /* GL_EXT_index_texture */\n\n/* -------------------------- GL_EXT_light_texture ------------------------- */\n\n#ifndef GL_EXT_light_texture\n#define GL_EXT_light_texture 1\n\n#define GL_FRAGMENT_MATERIAL_EXT 0x8349\n#define GL_FRAGMENT_NORMAL_EXT 0x834A\n#define GL_FRAGMENT_COLOR_EXT 0x834C\n#define GL_ATTENUATION_EXT 0x834D\n#define GL_SHADOW_ATTENUATION_EXT 0x834E\n#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F\n#define GL_TEXTURE_LIGHT_EXT 0x8350\n#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351\n#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352\n\ntypedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);\n\n#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT)\n#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT)\n#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT)\n\n#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture)\n\n#endif /* GL_EXT_light_texture */\n\n/* ------------------------- GL_EXT_misc_attribute ------------------------- */\n\n#ifndef GL_EXT_misc_attribute\n#define GL_EXT_misc_attribute 1\n\n#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute)\n\n#endif /* GL_EXT_misc_attribute */\n\n/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */\n\n#ifndef GL_EXT_multi_draw_arrays\n#define GL_EXT_multi_draw_arrays 1\n\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount);\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount);\n\n#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT)\n#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT)\n\n#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays)\n\n#endif /* GL_EXT_multi_draw_arrays */\n\n/* --------------------------- GL_EXT_multisample -------------------------- */\n\n#ifndef GL_EXT_multisample\n#define GL_EXT_multisample 1\n\n#define GL_MULTISAMPLE_EXT 0x809D\n#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F\n#define GL_SAMPLE_MASK_EXT 0x80A0\n#define GL_1PASS_EXT 0x80A1\n#define GL_2PASS_0_EXT 0x80A2\n#define GL_2PASS_1_EXT 0x80A3\n#define GL_4PASS_0_EXT 0x80A4\n#define GL_4PASS_1_EXT 0x80A5\n#define GL_4PASS_2_EXT 0x80A6\n#define GL_4PASS_3_EXT 0x80A7\n#define GL_SAMPLE_BUFFERS_EXT 0x80A8\n#define GL_SAMPLES_EXT 0x80A9\n#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA\n#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB\n#define GL_SAMPLE_PATTERN_EXT 0x80AC\n#define GL_MULTISAMPLE_BIT_EXT 0x20000000\n\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);\ntypedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);\n\n#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT)\n#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT)\n\n#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample)\n\n#endif /* GL_EXT_multisample */\n\n/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */\n\n#ifndef GL_EXT_packed_depth_stencil\n#define GL_EXT_packed_depth_stencil 1\n\n#define GL_DEPTH_STENCIL_EXT 0x84F9\n#define GL_UNSIGNED_INT_24_8_EXT 0x84FA\n#define GL_DEPTH24_STENCIL8_EXT 0x88F0\n#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1\n\n#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil)\n\n#endif /* GL_EXT_packed_depth_stencil */\n\n/* -------------------------- GL_EXT_packed_float -------------------------- */\n\n#ifndef GL_EXT_packed_float\n#define GL_EXT_packed_float 1\n\n#define GL_R11F_G11F_B10F_EXT 0x8C3A\n#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B\n#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C\n\n#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float)\n\n#endif /* GL_EXT_packed_float */\n\n/* -------------------------- GL_EXT_packed_pixels ------------------------- */\n\n#ifndef GL_EXT_packed_pixels\n#define GL_EXT_packed_pixels 1\n\n#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032\n#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034\n#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035\n#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036\n\n#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels)\n\n#endif /* GL_EXT_packed_pixels */\n\n/* ------------------------ GL_EXT_paletted_texture ------------------------ */\n\n#ifndef GL_EXT_paletted_texture\n#define GL_EXT_paletted_texture 1\n\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8\n#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9\n#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA\n#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB\n#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC\n#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD\n#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE\n#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF\n#define GL_COLOR_INDEX1_EXT 0x80E2\n#define GL_COLOR_INDEX2_EXT 0x80E3\n#define GL_COLOR_INDEX4_EXT 0x80E4\n#define GL_COLOR_INDEX8_EXT 0x80E5\n#define GL_COLOR_INDEX12_EXT 0x80E6\n#define GL_COLOR_INDEX16_EXT 0x80E7\n#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED\n#define GL_TEXTURE_CUBE_MAP_ARB 0x8513\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B\n\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\n\n#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT)\n#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT)\n#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT)\n#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT)\n\n#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture)\n\n#endif /* GL_EXT_paletted_texture */\n\n/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */\n\n#ifndef GL_EXT_pixel_buffer_object\n#define GL_EXT_pixel_buffer_object 1\n\n#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB\n#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF\n\n#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object)\n\n#endif /* GL_EXT_pixel_buffer_object */\n\n/* ------------------------- GL_EXT_pixel_transform ------------------------ */\n\n#ifndef GL_EXT_pixel_transform\n#define GL_EXT_pixel_transform 1\n\n#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330\n#define GL_PIXEL_MAG_FILTER_EXT 0x8331\n#define GL_PIXEL_MIN_FILTER_EXT 0x8332\n#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333\n#define GL_CUBIC_EXT 0x8334\n#define GL_AVERAGE_EXT 0x8335\n#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336\n#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337\n#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338\n\ntypedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param);\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\n\n#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT)\n#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT)\n#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT)\n#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT)\n#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT)\n#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT)\n\n#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform)\n\n#endif /* GL_EXT_pixel_transform */\n\n/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */\n\n#ifndef GL_EXT_pixel_transform_color_table\n#define GL_EXT_pixel_transform_color_table 1\n\n#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table)\n\n#endif /* GL_EXT_pixel_transform_color_table */\n\n/* ------------------------ GL_EXT_point_parameters ------------------------ */\n\n#ifndef GL_EXT_point_parameters\n#define GL_EXT_point_parameters 1\n\n#define GL_POINT_SIZE_MIN_EXT 0x8126\n#define GL_POINT_SIZE_MAX_EXT 0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128\n#define GL_DISTANCE_ATTENUATION_EXT 0x8129\n\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat* params);\n\n#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT)\n#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT)\n\n#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters)\n\n#endif /* GL_EXT_point_parameters */\n\n/* ------------------------- GL_EXT_polygon_offset ------------------------- */\n\n#ifndef GL_EXT_polygon_offset\n#define GL_EXT_polygon_offset 1\n\n#define GL_POLYGON_OFFSET_EXT 0x8037\n#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038\n#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039\n\ntypedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);\n\n#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT)\n\n#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset)\n\n#endif /* GL_EXT_polygon_offset */\n\n/* ------------------------ GL_EXT_provoking_vertex ------------------------ */\n\n#ifndef GL_EXT_provoking_vertex\n#define GL_EXT_provoking_vertex 1\n\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C\n#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D\n#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E\n#define GL_PROVOKING_VERTEX_EXT 0x8E4F\n\ntypedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);\n\n#define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT)\n\n#define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex)\n\n#endif /* GL_EXT_provoking_vertex */\n\n/* ------------------------- GL_EXT_rescale_normal ------------------------- */\n\n#ifndef GL_EXT_rescale_normal\n#define GL_EXT_rescale_normal 1\n\n#define GL_RESCALE_NORMAL_EXT 0x803A\n\n#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal)\n\n#endif /* GL_EXT_rescale_normal */\n\n/* -------------------------- GL_EXT_scene_marker -------------------------- */\n\n#ifndef GL_EXT_scene_marker\n#define GL_EXT_scene_marker 1\n\ntypedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void);\n\n#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT)\n#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT)\n\n#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker)\n\n#endif /* GL_EXT_scene_marker */\n\n/* ------------------------- GL_EXT_secondary_color ------------------------ */\n\n#ifndef GL_EXT_secondary_color\n#define GL_EXT_secondary_color 1\n\n#define GL_COLOR_SUM_EXT 0x8458\n#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459\n#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A\n#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C\n#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D\n#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E\n\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);\n\n#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT)\n#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT)\n#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT)\n#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT)\n#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT)\n#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT)\n#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT)\n#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT)\n#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT)\n#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT)\n#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT)\n#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT)\n#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT)\n#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT)\n#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT)\n#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT)\n#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT)\n\n#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color)\n\n#endif /* GL_EXT_secondary_color */\n\n/* --------------------- GL_EXT_separate_shader_objects -------------------- */\n\n#ifndef GL_EXT_separate_shader_objects\n#define GL_EXT_separate_shader_objects 1\n\n#define GL_ACTIVE_PROGRAM_EXT 0x8B8D\n\ntypedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar* string);\ntypedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);\n\n#define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT)\n#define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT)\n#define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT)\n\n#define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects)\n\n#endif /* GL_EXT_separate_shader_objects */\n\n/* --------------------- GL_EXT_separate_specular_color -------------------- */\n\n#ifndef GL_EXT_separate_specular_color\n#define GL_EXT_separate_specular_color 1\n\n#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8\n#define GL_SINGLE_COLOR_EXT 0x81F9\n#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA\n\n#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color)\n\n#endif /* GL_EXT_separate_specular_color */\n\n/* --------------------- GL_EXT_shader_image_load_store -------------------- */\n\n#ifndef GL_EXT_shader_image_load_store\n#define GL_EXT_shader_image_load_store 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001\n#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002\n#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004\n#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020\n#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040\n#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080\n#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100\n#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200\n#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800\n#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000\n#define GL_MAX_IMAGE_UNITS_EXT 0x8F38\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39\n#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A\n#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B\n#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C\n#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D\n#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E\n#define GL_IMAGE_1D_EXT 0x904C\n#define GL_IMAGE_2D_EXT 0x904D\n#define GL_IMAGE_3D_EXT 0x904E\n#define GL_IMAGE_2D_RECT_EXT 0x904F\n#define GL_IMAGE_CUBE_EXT 0x9050\n#define GL_IMAGE_BUFFER_EXT 0x9051\n#define GL_IMAGE_1D_ARRAY_EXT 0x9052\n#define GL_IMAGE_2D_ARRAY_EXT 0x9053\n#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054\n#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056\n#define GL_INT_IMAGE_1D_EXT 0x9057\n#define GL_INT_IMAGE_2D_EXT 0x9058\n#define GL_INT_IMAGE_3D_EXT 0x9059\n#define GL_INT_IMAGE_2D_RECT_EXT 0x905A\n#define GL_INT_IMAGE_CUBE_EXT 0x905B\n#define GL_INT_IMAGE_BUFFER_EXT 0x905C\n#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D\n#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F\n#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061\n#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062\n#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063\n#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065\n#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066\n#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C\n#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D\n#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E\n#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF\n\ntypedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);\ntypedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);\n\n#define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT)\n#define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT)\n\n#define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store)\n\n#endif /* GL_EXT_shader_image_load_store */\n\n/* -------------------------- GL_EXT_shadow_funcs -------------------------- */\n\n#ifndef GL_EXT_shadow_funcs\n#define GL_EXT_shadow_funcs 1\n\n#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs)\n\n#endif /* GL_EXT_shadow_funcs */\n\n/* --------------------- GL_EXT_shared_texture_palette --------------------- */\n\n#ifndef GL_EXT_shared_texture_palette\n#define GL_EXT_shared_texture_palette 1\n\n#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB\n\n#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette)\n\n#endif /* GL_EXT_shared_texture_palette */\n\n/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */\n\n#ifndef GL_EXT_stencil_clear_tag\n#define GL_EXT_stencil_clear_tag 1\n\n#define GL_STENCIL_TAG_BITS_EXT 0x88F2\n#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3\n\n#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag)\n\n#endif /* GL_EXT_stencil_clear_tag */\n\n/* ------------------------ GL_EXT_stencil_two_side ------------------------ */\n\n#ifndef GL_EXT_stencil_two_side\n#define GL_EXT_stencil_two_side 1\n\n#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910\n#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911\n\ntypedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);\n\n#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT)\n\n#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side)\n\n#endif /* GL_EXT_stencil_two_side */\n\n/* -------------------------- GL_EXT_stencil_wrap -------------------------- */\n\n#ifndef GL_EXT_stencil_wrap\n#define GL_EXT_stencil_wrap 1\n\n#define GL_INCR_WRAP_EXT 0x8507\n#define GL_DECR_WRAP_EXT 0x8508\n\n#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap)\n\n#endif /* GL_EXT_stencil_wrap */\n\n/* --------------------------- GL_EXT_subtexture --------------------------- */\n\n#ifndef GL_EXT_subtexture\n#define GL_EXT_subtexture 1\n\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);\n\n#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT)\n#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT)\n#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT)\n\n#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture)\n\n#endif /* GL_EXT_subtexture */\n\n/* ----------------------------- GL_EXT_texture ---------------------------- */\n\n#ifndef GL_EXT_texture\n#define GL_EXT_texture 1\n\n#define GL_ALPHA4_EXT 0x803B\n#define GL_ALPHA8_EXT 0x803C\n#define GL_ALPHA12_EXT 0x803D\n#define GL_ALPHA16_EXT 0x803E\n#define GL_LUMINANCE4_EXT 0x803F\n#define GL_LUMINANCE8_EXT 0x8040\n#define GL_LUMINANCE12_EXT 0x8041\n#define GL_LUMINANCE16_EXT 0x8042\n#define GL_LUMINANCE4_ALPHA4_EXT 0x8043\n#define GL_LUMINANCE6_ALPHA2_EXT 0x8044\n#define GL_LUMINANCE8_ALPHA8_EXT 0x8045\n#define GL_LUMINANCE12_ALPHA4_EXT 0x8046\n#define GL_LUMINANCE12_ALPHA12_EXT 0x8047\n#define GL_LUMINANCE16_ALPHA16_EXT 0x8048\n#define GL_INTENSITY_EXT 0x8049\n#define GL_INTENSITY4_EXT 0x804A\n#define GL_INTENSITY8_EXT 0x804B\n#define GL_INTENSITY12_EXT 0x804C\n#define GL_INTENSITY16_EXT 0x804D\n#define GL_RGB2_EXT 0x804E\n#define GL_RGB4_EXT 0x804F\n#define GL_RGB5_EXT 0x8050\n#define GL_RGB8_EXT 0x8051\n#define GL_RGB10_EXT 0x8052\n#define GL_RGB12_EXT 0x8053\n#define GL_RGB16_EXT 0x8054\n#define GL_RGBA2_EXT 0x8055\n#define GL_RGBA4_EXT 0x8056\n#define GL_RGB5_A1_EXT 0x8057\n#define GL_RGBA8_EXT 0x8058\n#define GL_RGB10_A2_EXT 0x8059\n#define GL_RGBA12_EXT 0x805A\n#define GL_RGBA16_EXT 0x805B\n#define GL_TEXTURE_RED_SIZE_EXT 0x805C\n#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D\n#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E\n#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F\n#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060\n#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061\n#define GL_REPLACE_EXT 0x8062\n#define GL_PROXY_TEXTURE_1D_EXT 0x8063\n#define GL_PROXY_TEXTURE_2D_EXT 0x8064\n\n#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture)\n\n#endif /* GL_EXT_texture */\n\n/* ---------------------------- GL_EXT_texture3D --------------------------- */\n\n#ifndef GL_EXT_texture3D\n#define GL_EXT_texture3D 1\n\n#define GL_PACK_SKIP_IMAGES_EXT 0x806B\n#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C\n#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D\n#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E\n#define GL_TEXTURE_3D_EXT 0x806F\n#define GL_PROXY_TEXTURE_3D_EXT 0x8070\n#define GL_TEXTURE_DEPTH_EXT 0x8071\n#define GL_TEXTURE_WRAP_R_EXT 0x8072\n#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073\n\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels);\n\n#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT)\n\n#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D)\n\n#endif /* GL_EXT_texture3D */\n\n/* -------------------------- GL_EXT_texture_array ------------------------- */\n\n#ifndef GL_EXT_texture_array\n#define GL_EXT_texture_array 1\n\n#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E\n#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF\n#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18\n#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19\n#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A\n#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B\n#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\n\n#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT)\n\n#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array)\n\n#endif /* GL_EXT_texture_array */\n\n/* ---------------------- GL_EXT_texture_buffer_object --------------------- */\n\n#ifndef GL_EXT_texture_buffer_object\n#define GL_EXT_texture_buffer_object 1\n\n#define GL_TEXTURE_BUFFER_EXT 0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D\n#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E\n\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);\n\n#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT)\n\n#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object)\n\n#endif /* GL_EXT_texture_buffer_object */\n\n/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */\n\n#ifndef GL_EXT_texture_compression_dxt1\n#define GL_EXT_texture_compression_dxt1 1\n\n#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1)\n\n#endif /* GL_EXT_texture_compression_dxt1 */\n\n/* -------------------- GL_EXT_texture_compression_latc -------------------- */\n\n#ifndef GL_EXT_texture_compression_latc\n#define GL_EXT_texture_compression_latc 1\n\n#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70\n#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71\n#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72\n#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73\n\n#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc)\n\n#endif /* GL_EXT_texture_compression_latc */\n\n/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */\n\n#ifndef GL_EXT_texture_compression_rgtc\n#define GL_EXT_texture_compression_rgtc 1\n\n#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB\n#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC\n#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD\n#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE\n\n#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc)\n\n#endif /* GL_EXT_texture_compression_rgtc */\n\n/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */\n\n#ifndef GL_EXT_texture_compression_s3tc\n#define GL_EXT_texture_compression_s3tc 1\n\n#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3\n\n#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc)\n\n#endif /* GL_EXT_texture_compression_s3tc */\n\n/* ------------------------ GL_EXT_texture_cube_map ------------------------ */\n\n#ifndef GL_EXT_texture_cube_map\n#define GL_EXT_texture_cube_map 1\n\n#define GL_NORMAL_MAP_EXT 0x8511\n#define GL_REFLECTION_MAP_EXT 0x8512\n#define GL_TEXTURE_CUBE_MAP_EXT 0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C\n\n#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map)\n\n#endif /* GL_EXT_texture_cube_map */\n\n/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */\n\n#ifndef GL_EXT_texture_edge_clamp\n#define GL_EXT_texture_edge_clamp 1\n\n#define GL_CLAMP_TO_EDGE_EXT 0x812F\n\n#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp)\n\n#endif /* GL_EXT_texture_edge_clamp */\n\n/* --------------------------- GL_EXT_texture_env -------------------------- */\n\n#ifndef GL_EXT_texture_env\n#define GL_EXT_texture_env 1\n\n#define GL_TEXTURE_ENV0_EXT 0\n#define GL_ENV_BLEND_EXT 0\n#define GL_TEXTURE_ENV_SHIFT_EXT 0\n#define GL_ENV_REPLACE_EXT 0\n#define GL_ENV_ADD_EXT 0\n#define GL_ENV_SUBTRACT_EXT 0\n#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0\n#define GL_ENV_REVERSE_SUBTRACT_EXT 0\n#define GL_ENV_REVERSE_BLEND_EXT 0\n#define GL_ENV_COPY_EXT 0\n#define GL_ENV_MODULATE_EXT 0\n\n#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env)\n\n#endif /* GL_EXT_texture_env */\n\n/* ------------------------- GL_EXT_texture_env_add ------------------------ */\n\n#ifndef GL_EXT_texture_env_add\n#define GL_EXT_texture_env_add 1\n\n#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add)\n\n#endif /* GL_EXT_texture_env_add */\n\n/* ----------------------- GL_EXT_texture_env_combine ---------------------- */\n\n#ifndef GL_EXT_texture_env_combine\n#define GL_EXT_texture_env_combine 1\n\n#define GL_COMBINE_EXT 0x8570\n#define GL_COMBINE_RGB_EXT 0x8571\n#define GL_COMBINE_ALPHA_EXT 0x8572\n#define GL_RGB_SCALE_EXT 0x8573\n#define GL_ADD_SIGNED_EXT 0x8574\n#define GL_INTERPOLATE_EXT 0x8575\n#define GL_CONSTANT_EXT 0x8576\n#define GL_PRIMARY_COLOR_EXT 0x8577\n#define GL_PREVIOUS_EXT 0x8578\n#define GL_SOURCE0_RGB_EXT 0x8580\n#define GL_SOURCE1_RGB_EXT 0x8581\n#define GL_SOURCE2_RGB_EXT 0x8582\n#define GL_SOURCE0_ALPHA_EXT 0x8588\n#define GL_SOURCE1_ALPHA_EXT 0x8589\n#define GL_SOURCE2_ALPHA_EXT 0x858A\n#define GL_OPERAND0_RGB_EXT 0x8590\n#define GL_OPERAND1_RGB_EXT 0x8591\n#define GL_OPERAND2_RGB_EXT 0x8592\n#define GL_OPERAND0_ALPHA_EXT 0x8598\n#define GL_OPERAND1_ALPHA_EXT 0x8599\n#define GL_OPERAND2_ALPHA_EXT 0x859A\n\n#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine)\n\n#endif /* GL_EXT_texture_env_combine */\n\n/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */\n\n#ifndef GL_EXT_texture_env_dot3\n#define GL_EXT_texture_env_dot3 1\n\n#define GL_DOT3_RGB_EXT 0x8740\n#define GL_DOT3_RGBA_EXT 0x8741\n\n#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3)\n\n#endif /* GL_EXT_texture_env_dot3 */\n\n/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */\n\n#ifndef GL_EXT_texture_filter_anisotropic\n#define GL_EXT_texture_filter_anisotropic 1\n\n#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE\n#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF\n\n#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic)\n\n#endif /* GL_EXT_texture_filter_anisotropic */\n\n/* ------------------------- GL_EXT_texture_integer ------------------------ */\n\n#ifndef GL_EXT_texture_integer\n#define GL_EXT_texture_integer 1\n\n#define GL_RGBA32UI_EXT 0x8D70\n#define GL_RGB32UI_EXT 0x8D71\n#define GL_ALPHA32UI_EXT 0x8D72\n#define GL_INTENSITY32UI_EXT 0x8D73\n#define GL_LUMINANCE32UI_EXT 0x8D74\n#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75\n#define GL_RGBA16UI_EXT 0x8D76\n#define GL_RGB16UI_EXT 0x8D77\n#define GL_ALPHA16UI_EXT 0x8D78\n#define GL_INTENSITY16UI_EXT 0x8D79\n#define GL_LUMINANCE16UI_EXT 0x8D7A\n#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B\n#define GL_RGBA8UI_EXT 0x8D7C\n#define GL_RGB8UI_EXT 0x8D7D\n#define GL_ALPHA8UI_EXT 0x8D7E\n#define GL_INTENSITY8UI_EXT 0x8D7F\n#define GL_LUMINANCE8UI_EXT 0x8D80\n#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81\n#define GL_RGBA32I_EXT 0x8D82\n#define GL_RGB32I_EXT 0x8D83\n#define GL_ALPHA32I_EXT 0x8D84\n#define GL_INTENSITY32I_EXT 0x8D85\n#define GL_LUMINANCE32I_EXT 0x8D86\n#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87\n#define GL_RGBA16I_EXT 0x8D88\n#define GL_RGB16I_EXT 0x8D89\n#define GL_ALPHA16I_EXT 0x8D8A\n#define GL_INTENSITY16I_EXT 0x8D8B\n#define GL_LUMINANCE16I_EXT 0x8D8C\n#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D\n#define GL_RGBA8I_EXT 0x8D8E\n#define GL_RGB8I_EXT 0x8D8F\n#define GL_ALPHA8I_EXT 0x8D90\n#define GL_INTENSITY8I_EXT 0x8D91\n#define GL_LUMINANCE8I_EXT 0x8D92\n#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93\n#define GL_RED_INTEGER_EXT 0x8D94\n#define GL_GREEN_INTEGER_EXT 0x8D95\n#define GL_BLUE_INTEGER_EXT 0x8D96\n#define GL_ALPHA_INTEGER_EXT 0x8D97\n#define GL_RGB_INTEGER_EXT 0x8D98\n#define GL_RGBA_INTEGER_EXT 0x8D99\n#define GL_BGR_INTEGER_EXT 0x8D9A\n#define GL_BGRA_INTEGER_EXT 0x8D9B\n#define GL_LUMINANCE_INTEGER_EXT 0x8D9C\n#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D\n#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E\n\ntypedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);\ntypedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);\n\n#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT)\n#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT)\n#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT)\n#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT)\n#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT)\n#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT)\n\n#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer)\n\n#endif /* GL_EXT_texture_integer */\n\n/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */\n\n#ifndef GL_EXT_texture_lod_bias\n#define GL_EXT_texture_lod_bias 1\n\n#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD\n#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500\n#define GL_TEXTURE_LOD_BIAS_EXT 0x8501\n\n#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias)\n\n#endif /* GL_EXT_texture_lod_bias */\n\n/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */\n\n#ifndef GL_EXT_texture_mirror_clamp\n#define GL_EXT_texture_mirror_clamp 1\n\n#define GL_MIRROR_CLAMP_EXT 0x8742\n#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743\n#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912\n\n#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp)\n\n#endif /* GL_EXT_texture_mirror_clamp */\n\n/* ------------------------- GL_EXT_texture_object ------------------------- */\n\n#ifndef GL_EXT_texture_object\n#define GL_EXT_texture_object 1\n\n#define GL_TEXTURE_PRIORITY_EXT 0x8066\n#define GL_TEXTURE_RESIDENT_EXT 0x8067\n#define GL_TEXTURE_1D_BINDING_EXT 0x8068\n#define GL_TEXTURE_2D_BINDING_EXT 0x8069\n#define GL_TEXTURE_3D_BINDING_EXT 0x806A\n\ntypedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences);\ntypedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);\ntypedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures);\ntypedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures);\ntypedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture);\ntypedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities);\n\n#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT)\n#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT)\n#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT)\n#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT)\n#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT)\n#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT)\n\n#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object)\n\n#endif /* GL_EXT_texture_object */\n\n/* --------------------- GL_EXT_texture_perturb_normal --------------------- */\n\n#ifndef GL_EXT_texture_perturb_normal\n#define GL_EXT_texture_perturb_normal 1\n\n#define GL_PERTURB_EXT 0x85AE\n#define GL_TEXTURE_NORMAL_EXT 0x85AF\n\ntypedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode);\n\n#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT)\n\n#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal)\n\n#endif /* GL_EXT_texture_perturb_normal */\n\n/* ------------------------ GL_EXT_texture_rectangle ----------------------- */\n\n#ifndef GL_EXT_texture_rectangle\n#define GL_EXT_texture_rectangle 1\n\n#define GL_TEXTURE_RECTANGLE_EXT 0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8\n\n#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle)\n\n#endif /* GL_EXT_texture_rectangle */\n\n/* -------------------------- GL_EXT_texture_sRGB -------------------------- */\n\n#ifndef GL_EXT_texture_sRGB\n#define GL_EXT_texture_sRGB 1\n\n#define GL_SRGB_EXT 0x8C40\n#define GL_SRGB8_EXT 0x8C41\n#define GL_SRGB_ALPHA_EXT 0x8C42\n#define GL_SRGB8_ALPHA8_EXT 0x8C43\n#define GL_SLUMINANCE_ALPHA_EXT 0x8C44\n#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45\n#define GL_SLUMINANCE_EXT 0x8C46\n#define GL_SLUMINANCE8_EXT 0x8C47\n#define GL_COMPRESSED_SRGB_EXT 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49\n#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A\n#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B\n#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F\n\n#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB)\n\n#endif /* GL_EXT_texture_sRGB */\n\n/* ----------------------- GL_EXT_texture_sRGB_decode ---------------------- */\n\n#ifndef GL_EXT_texture_sRGB_decode\n#define GL_EXT_texture_sRGB_decode 1\n\n#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48\n#define GL_DECODE_EXT 0x8A49\n#define GL_SKIP_DECODE_EXT 0x8A4A\n\n#define GLEW_EXT_texture_sRGB_decode GLEW_GET_VAR(__GLEW_EXT_texture_sRGB_decode)\n\n#endif /* GL_EXT_texture_sRGB_decode */\n\n/* --------------------- GL_EXT_texture_shared_exponent -------------------- */\n\n#ifndef GL_EXT_texture_shared_exponent\n#define GL_EXT_texture_shared_exponent 1\n\n#define GL_RGB9_E5_EXT 0x8C3D\n#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E\n#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F\n\n#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent)\n\n#endif /* GL_EXT_texture_shared_exponent */\n\n/* -------------------------- GL_EXT_texture_snorm ------------------------- */\n\n#ifndef GL_EXT_texture_snorm\n#define GL_EXT_texture_snorm 1\n\n#define GL_RED_SNORM 0x8F90\n#define GL_RG_SNORM 0x8F91\n#define GL_RGB_SNORM 0x8F92\n#define GL_RGBA_SNORM 0x8F93\n#define GL_R8_SNORM 0x8F94\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_R16_SNORM 0x8F98\n#define GL_RG16_SNORM 0x8F99\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_ALPHA_SNORM 0x9010\n#define GL_LUMINANCE_SNORM 0x9011\n#define GL_LUMINANCE_ALPHA_SNORM 0x9012\n#define GL_INTENSITY_SNORM 0x9013\n#define GL_ALPHA8_SNORM 0x9014\n#define GL_LUMINANCE8_SNORM 0x9015\n#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016\n#define GL_INTENSITY8_SNORM 0x9017\n#define GL_ALPHA16_SNORM 0x9018\n#define GL_LUMINANCE16_SNORM 0x9019\n#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A\n#define GL_INTENSITY16_SNORM 0x901B\n\n#define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm)\n\n#endif /* GL_EXT_texture_snorm */\n\n/* ------------------------- GL_EXT_texture_swizzle ------------------------ */\n\n#ifndef GL_EXT_texture_swizzle\n#define GL_EXT_texture_swizzle 1\n\n#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42\n#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43\n#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44\n#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45\n#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46\n\n#define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle)\n\n#endif /* GL_EXT_texture_swizzle */\n\n/* --------------------------- GL_EXT_timer_query -------------------------- */\n\n#ifndef GL_EXT_timer_query\n#define GL_EXT_timer_query 1\n\n#define GL_TIME_ELAPSED_EXT 0x88BF\n\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);\n\n#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT)\n#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT)\n\n#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query)\n\n#endif /* GL_EXT_timer_query */\n\n/* ----------------------- GL_EXT_transform_feedback ----------------------- */\n\n#ifndef GL_EXT_transform_feedback\n#define GL_EXT_transform_feedback 1\n\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85\n#define GL_PRIMITIVES_GENERATED_EXT 0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88\n#define GL_RASTERIZER_DISCARD_EXT 0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C\n#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F\n\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar ** varyings, GLenum bufferMode);\n\n#define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT)\n#define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT)\n#define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT)\n#define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT)\n#define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT)\n#define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT)\n#define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT)\n\n#define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback)\n\n#endif /* GL_EXT_transform_feedback */\n\n/* -------------------------- GL_EXT_vertex_array -------------------------- */\n\n#ifndef GL_EXT_vertex_array\n#define GL_EXT_vertex_array 1\n\n#define GL_DOUBLE_EXT 0x140A\n#define GL_VERTEX_ARRAY_EXT 0x8074\n#define GL_NORMAL_ARRAY_EXT 0x8075\n#define GL_COLOR_ARRAY_EXT 0x8076\n#define GL_INDEX_ARRAY_EXT 0x8077\n#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078\n#define GL_EDGE_FLAG_ARRAY_EXT 0x8079\n#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A\n#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B\n#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C\n#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D\n#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E\n#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F\n#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080\n#define GL_COLOR_ARRAY_SIZE_EXT 0x8081\n#define GL_COLOR_ARRAY_TYPE_EXT 0x8082\n#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083\n#define GL_COLOR_ARRAY_COUNT_EXT 0x8084\n#define GL_INDEX_ARRAY_TYPE_EXT 0x8085\n#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086\n#define GL_INDEX_ARRAY_COUNT_EXT 0x8087\n#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088\n#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089\n#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A\n#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B\n#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C\n#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D\n#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E\n#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F\n#define GL_COLOR_ARRAY_POINTER_EXT 0x8090\n#define GL_INDEX_ARRAY_POINTER_EXT 0x8091\n#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092\n#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093\n\ntypedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer);\ntypedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);\n\n#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT)\n#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT)\n#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT)\n#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT)\n#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT)\n#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT)\n#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT)\n#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT)\n\n#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array)\n\n#endif /* GL_EXT_vertex_array */\n\n/* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */\n\n#ifndef GL_EXT_vertex_array_bgra\n#define GL_EXT_vertex_array_bgra 1\n\n#define GL_BGRA 0x80E1\n\n#define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra)\n\n#endif /* GL_EXT_vertex_array_bgra */\n\n/* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */\n\n#ifndef GL_EXT_vertex_attrib_64bit\n#define GL_EXT_vertex_attrib_64bit 1\n\n#define GL_DOUBLE_MAT2_EXT 0x8F46\n#define GL_DOUBLE_MAT3_EXT 0x8F47\n#define GL_DOUBLE_MAT4_EXT 0x8F48\n#define GL_DOUBLE_MAT2x3_EXT 0x8F49\n#define GL_DOUBLE_MAT2x4_EXT 0x8F4A\n#define GL_DOUBLE_MAT3x2_EXT 0x8F4B\n#define GL_DOUBLE_MAT3x4_EXT 0x8F4C\n#define GL_DOUBLE_MAT4x2_EXT 0x8F4D\n#define GL_DOUBLE_MAT4x3_EXT 0x8F4E\n#define GL_DOUBLE_VEC2_EXT 0x8FFC\n#define GL_DOUBLE_VEC3_EXT 0x8FFD\n#define GL_DOUBLE_VEC4_EXT 0x8FFE\n\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);\n\n#define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT)\n#define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT)\n#define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT)\n#define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT)\n#define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT)\n#define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT)\n#define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT)\n#define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT)\n#define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT)\n#define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT)\n#define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT)\n\n#define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit)\n\n#endif /* GL_EXT_vertex_attrib_64bit */\n\n/* -------------------------- GL_EXT_vertex_shader ------------------------- */\n\n#ifndef GL_EXT_vertex_shader\n#define GL_EXT_vertex_shader 1\n\n#define GL_VERTEX_SHADER_EXT 0x8780\n#define GL_VERTEX_SHADER_BINDING_EXT 0x8781\n#define GL_OP_INDEX_EXT 0x8782\n#define GL_OP_NEGATE_EXT 0x8783\n#define GL_OP_DOT3_EXT 0x8784\n#define GL_OP_DOT4_EXT 0x8785\n#define GL_OP_MUL_EXT 0x8786\n#define GL_OP_ADD_EXT 0x8787\n#define GL_OP_MADD_EXT 0x8788\n#define GL_OP_FRAC_EXT 0x8789\n#define GL_OP_MAX_EXT 0x878A\n#define GL_OP_MIN_EXT 0x878B\n#define GL_OP_SET_GE_EXT 0x878C\n#define GL_OP_SET_LT_EXT 0x878D\n#define GL_OP_CLAMP_EXT 0x878E\n#define GL_OP_FLOOR_EXT 0x878F\n#define GL_OP_ROUND_EXT 0x8790\n#define GL_OP_EXP_BASE_2_EXT 0x8791\n#define GL_OP_LOG_BASE_2_EXT 0x8792\n#define GL_OP_POWER_EXT 0x8793\n#define GL_OP_RECIP_EXT 0x8794\n#define GL_OP_RECIP_SQRT_EXT 0x8795\n#define GL_OP_SUB_EXT 0x8796\n#define GL_OP_CROSS_PRODUCT_EXT 0x8797\n#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798\n#define GL_OP_MOV_EXT 0x8799\n#define GL_OUTPUT_VERTEX_EXT 0x879A\n#define GL_OUTPUT_COLOR0_EXT 0x879B\n#define GL_OUTPUT_COLOR1_EXT 0x879C\n#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D\n#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E\n#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F\n#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0\n#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1\n#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2\n#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3\n#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4\n#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5\n#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6\n#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7\n#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8\n#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9\n#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA\n#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB\n#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC\n#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD\n#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE\n#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF\n#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0\n#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1\n#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2\n#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3\n#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4\n#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5\n#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6\n#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7\n#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8\n#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9\n#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA\n#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB\n#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC\n#define GL_OUTPUT_FOG_EXT 0x87BD\n#define GL_SCALAR_EXT 0x87BE\n#define GL_VECTOR_EXT 0x87BF\n#define GL_MATRIX_EXT 0x87C0\n#define GL_VARIANT_EXT 0x87C1\n#define GL_INVARIANT_EXT 0x87C2\n#define GL_LOCAL_CONSTANT_EXT 0x87C3\n#define GL_LOCAL_EXT 0x87C4\n#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5\n#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6\n#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7\n#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8\n#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE\n#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF\n#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0\n#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1\n#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2\n#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3\n#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4\n#define GL_X_EXT 0x87D5\n#define GL_Y_EXT 0x87D6\n#define GL_Z_EXT 0x87D7\n#define GL_W_EXT 0x87D8\n#define GL_NEGATIVE_X_EXT 0x87D9\n#define GL_NEGATIVE_Y_EXT 0x87DA\n#define GL_NEGATIVE_Z_EXT 0x87DB\n#define GL_NEGATIVE_W_EXT 0x87DC\n#define GL_ZERO_EXT 0x87DD\n#define GL_ONE_EXT 0x87DE\n#define GL_NEGATIVE_ONE_EXT 0x87DF\n#define GL_NORMALIZED_RANGE_EXT 0x87E0\n#define GL_FULL_RANGE_EXT 0x87E1\n#define GL_CURRENT_VERTEX_EXT 0x87E2\n#define GL_MVP_MATRIX_EXT 0x87E3\n#define GL_VARIANT_VALUE_EXT 0x87E4\n#define GL_VARIANT_DATATYPE_EXT 0x87E5\n#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6\n#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7\n#define GL_VARIANT_ARRAY_EXT 0x87E8\n#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9\n#define GL_INVARIANT_VALUE_EXT 0x87EA\n#define GL_INVARIANT_DATATYPE_EXT 0x87EB\n#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC\n#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED\n\ntypedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void);\ntypedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);\ntypedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);\ntypedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value);\ntypedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);\ntypedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\ntypedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components);\ntypedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data);\ntypedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\ntypedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);\ntypedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr);\ntypedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr);\ntypedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);\ntypedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);\ntypedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);\ntypedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\ntypedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr);\ntypedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr);\ntypedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\n\n#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT)\n#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT)\n#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT)\n#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT)\n#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT)\n#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT)\n#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT)\n#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT)\n#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT)\n#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT)\n#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT)\n#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT)\n#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT)\n#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT)\n#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT)\n#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT)\n#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT)\n#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT)\n#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT)\n#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT)\n#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT)\n#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT)\n#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT)\n#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT)\n#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT)\n#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT)\n#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT)\n#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT)\n#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT)\n#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT)\n#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT)\n#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT)\n#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT)\n#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT)\n#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT)\n#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT)\n#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT)\n#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT)\n#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT)\n#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT)\n#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT)\n#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT)\n\n#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader)\n\n#endif /* GL_EXT_vertex_shader */\n\n/* ------------------------ GL_EXT_vertex_weighting ------------------------ */\n\n#ifndef GL_EXT_vertex_weighting\n#define GL_EXT_vertex_weighting 1\n\n#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3\n#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6\n#define GL_MODELVIEW0_EXT 0x1700\n#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502\n#define GL_MODELVIEW1_MATRIX_EXT 0x8506\n#define GL_VERTEX_WEIGHTING_EXT 0x8509\n#define GL_MODELVIEW1_EXT 0x850A\n#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B\n#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C\n#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D\n#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E\n#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F\n#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510\n\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight);\n\n#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT)\n#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT)\n#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT)\n\n#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting)\n\n#endif /* GL_EXT_vertex_weighting */\n\n/* ------------------------- GL_EXT_x11_sync_object ------------------------ */\n\n#ifndef GL_EXT_x11_sync_object\n#define GL_EXT_x11_sync_object 1\n\n#define GL_SYNC_X11_FENCE_EXT 0x90E1\n\ntypedef GLsync (GLAPIENTRY * PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);\n\n#define glImportSyncEXT GLEW_GET_FUN(__glewImportSyncEXT)\n\n#define GLEW_EXT_x11_sync_object GLEW_GET_VAR(__GLEW_EXT_x11_sync_object)\n\n#endif /* GL_EXT_x11_sync_object */\n\n/* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */\n\n#ifndef GL_GREMEDY_frame_terminator\n#define GL_GREMEDY_frame_terminator 1\n\ntypedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void);\n\n#define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY)\n\n#define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator)\n\n#endif /* GL_GREMEDY_frame_terminator */\n\n/* ------------------------ GL_GREMEDY_string_marker ----------------------- */\n\n#ifndef GL_GREMEDY_string_marker\n#define GL_GREMEDY_string_marker 1\n\ntypedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string);\n\n#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY)\n\n#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker)\n\n#endif /* GL_GREMEDY_string_marker */\n\n/* --------------------- GL_HP_convolution_border_modes -------------------- */\n\n#ifndef GL_HP_convolution_border_modes\n#define GL_HP_convolution_border_modes 1\n\n#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes)\n\n#endif /* GL_HP_convolution_border_modes */\n\n/* ------------------------- GL_HP_image_transform ------------------------- */\n\n#ifndef GL_HP_image_transform\n#define GL_HP_image_transform 1\n\ntypedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param);\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params);\n\n#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP)\n#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP)\n#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP)\n#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP)\n#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP)\n#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP)\n\n#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform)\n\n#endif /* GL_HP_image_transform */\n\n/* -------------------------- GL_HP_occlusion_test ------------------------- */\n\n#ifndef GL_HP_occlusion_test\n#define GL_HP_occlusion_test 1\n\n#define GL_OCCLUSION_TEST_HP 0x8165\n#define GL_OCCLUSION_TEST_RESULT_HP 0x8166\n\n#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test)\n\n#endif /* GL_HP_occlusion_test */\n\n/* ------------------------- GL_HP_texture_lighting ------------------------ */\n\n#ifndef GL_HP_texture_lighting\n#define GL_HP_texture_lighting 1\n\n#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting)\n\n#endif /* GL_HP_texture_lighting */\n\n/* --------------------------- GL_IBM_cull_vertex -------------------------- */\n\n#ifndef GL_IBM_cull_vertex\n#define GL_IBM_cull_vertex 1\n\n#define GL_CULL_VERTEX_IBM 103050\n\n#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex)\n\n#endif /* GL_IBM_cull_vertex */\n\n/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */\n\n#ifndef GL_IBM_multimode_draw_arrays\n#define GL_IBM_multimode_draw_arrays 1\n\ntypedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);\ntypedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride);\n\n#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM)\n#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM)\n\n#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays)\n\n#endif /* GL_IBM_multimode_draw_arrays */\n\n/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */\n\n#ifndef GL_IBM_rasterpos_clip\n#define GL_IBM_rasterpos_clip 1\n\n#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010\n\n#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip)\n\n#endif /* GL_IBM_rasterpos_clip */\n\n/* --------------------------- GL_IBM_static_data -------------------------- */\n\n#ifndef GL_IBM_static_data\n#define GL_IBM_static_data 1\n\n#define GL_ALL_STATIC_DATA_IBM 103060\n#define GL_STATIC_VERTEX_ARRAY_IBM 103061\n\n#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data)\n\n#endif /* GL_IBM_static_data */\n\n/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */\n\n#ifndef GL_IBM_texture_mirrored_repeat\n#define GL_IBM_texture_mirrored_repeat 1\n\n#define GL_MIRRORED_REPEAT_IBM 0x8370\n\n#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat)\n\n#endif /* GL_IBM_texture_mirrored_repeat */\n\n/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */\n\n#ifndef GL_IBM_vertex_array_lists\n#define GL_IBM_vertex_array_lists 1\n\n#define GL_VERTEX_ARRAY_LIST_IBM 103070\n#define GL_NORMAL_ARRAY_LIST_IBM 103071\n#define GL_COLOR_ARRAY_LIST_IBM 103072\n#define GL_INDEX_ARRAY_LIST_IBM 103073\n#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074\n#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075\n#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076\n#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077\n#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080\n#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081\n#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082\n#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083\n#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084\n#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085\n#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086\n#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087\n\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride);\n\n#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM)\n#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM)\n#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM)\n#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM)\n#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM)\n#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM)\n#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM)\n#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM)\n\n#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists)\n\n#endif /* GL_IBM_vertex_array_lists */\n\n/* -------------------------- GL_INGR_color_clamp -------------------------- */\n\n#ifndef GL_INGR_color_clamp\n#define GL_INGR_color_clamp 1\n\n#define GL_RED_MIN_CLAMP_INGR 0x8560\n#define GL_GREEN_MIN_CLAMP_INGR 0x8561\n#define GL_BLUE_MIN_CLAMP_INGR 0x8562\n#define GL_ALPHA_MIN_CLAMP_INGR 0x8563\n#define GL_RED_MAX_CLAMP_INGR 0x8564\n#define GL_GREEN_MAX_CLAMP_INGR 0x8565\n#define GL_BLUE_MAX_CLAMP_INGR 0x8566\n#define GL_ALPHA_MAX_CLAMP_INGR 0x8567\n\n#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp)\n\n#endif /* GL_INGR_color_clamp */\n\n/* ------------------------- GL_INGR_interlace_read ------------------------ */\n\n#ifndef GL_INGR_interlace_read\n#define GL_INGR_interlace_read 1\n\n#define GL_INTERLACE_READ_INGR 0x8568\n\n#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read)\n\n#endif /* GL_INGR_interlace_read */\n\n/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */\n\n#ifndef GL_INTEL_parallel_arrays\n#define GL_INTEL_parallel_arrays 1\n\n#define GL_PARALLEL_ARRAYS_INTEL 0x83F4\n#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5\n#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6\n#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7\n#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8\n\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\n\n#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL)\n#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL)\n#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL)\n#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL)\n\n#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays)\n\n#endif /* GL_INTEL_parallel_arrays */\n\n/* ------------------------ GL_INTEL_texture_scissor ----------------------- */\n\n#ifndef GL_INTEL_texture_scissor\n#define GL_INTEL_texture_scissor 1\n\ntypedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc);\ntypedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh);\n\n#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL)\n#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL)\n\n#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor)\n\n#endif /* GL_INTEL_texture_scissor */\n\n/* ------------------------------ GL_KHR_debug ----------------------------- */\n\n#ifndef GL_KHR_debug\n#define GL_KHR_debug 1\n\n#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002\n#define GL_STACK_OVERFLOW 0x0503\n#define GL_STACK_UNDERFLOW 0x0504\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243\n#define GL_DEBUG_CALLBACK_FUNCTION 0x8244\n#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245\n#define GL_DEBUG_SOURCE_API 0x8246\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247\n#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248\n#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249\n#define GL_DEBUG_SOURCE_APPLICATION 0x824A\n#define GL_DEBUG_SOURCE_OTHER 0x824B\n#define GL_DEBUG_TYPE_ERROR 0x824C\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E\n#define GL_DEBUG_TYPE_PORTABILITY 0x824F\n#define GL_DEBUG_TYPE_PERFORMANCE 0x8250\n#define GL_DEBUG_TYPE_OTHER 0x8251\n#define GL_DEBUG_TYPE_MARKER 0x8268\n#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269\n#define GL_DEBUG_TYPE_POP_GROUP 0x826A\n#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B\n#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C\n#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D\n#define GL_BUFFER 0x82E0\n#define GL_SHADER 0x82E1\n#define GL_PROGRAM 0x82E2\n#define GL_QUERY 0x82E3\n#define GL_PROGRAM_PIPELINE 0x82E4\n#define GL_SAMPLER 0x82E6\n#define GL_DISPLAY_LIST 0x82E7\n#define GL_MAX_LABEL_LENGTH 0x82E8\n#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144\n#define GL_DEBUG_LOGGED_MESSAGES 0x9145\n#define GL_DEBUG_SEVERITY_HIGH 0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM 0x9147\n#define GL_DEBUG_SEVERITY_LOW 0x9148\n#define GL_DEBUG_OUTPUT 0x92E0\n\ntypedef void (APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam);\n\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, void* userParam);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar *label);\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABELPROC) (void* ptr, GLsizei bufSize, GLsizei* length, GLchar *label);\ntypedef void (GLAPIENTRY * PFNGLGETPOINTERVPROC) (GLenum pname, void** params);\ntypedef void (GLAPIENTRY * PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label);\ntypedef void (GLAPIENTRY * PFNGLOBJECTPTRLABELPROC) (void* ptr, GLsizei length, const GLchar* label);\ntypedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar * message);\n\n#define glDebugMessageCallback GLEW_GET_FUN(__glewDebugMessageCallback)\n#define glDebugMessageControl GLEW_GET_FUN(__glewDebugMessageControl)\n#define glDebugMessageInsert GLEW_GET_FUN(__glewDebugMessageInsert)\n#define glGetDebugMessageLog GLEW_GET_FUN(__glewGetDebugMessageLog)\n#define glGetObjectLabel GLEW_GET_FUN(__glewGetObjectLabel)\n#define glGetObjectPtrLabel GLEW_GET_FUN(__glewGetObjectPtrLabel)\n#define glGetPointerv GLEW_GET_FUN(__glewGetPointerv)\n#define glObjectLabel GLEW_GET_FUN(__glewObjectLabel)\n#define glObjectPtrLabel GLEW_GET_FUN(__glewObjectPtrLabel)\n#define glPushDebugGroup GLEW_GET_FUN(__glewPushDebugGroup)\n\n#define GLEW_KHR_debug GLEW_GET_VAR(__GLEW_KHR_debug)\n\n#endif /* GL_KHR_debug */\n\n/* ------------------ GL_KHR_texture_compression_astc_ldr ------------------ */\n\n#ifndef GL_KHR_texture_compression_astc_ldr\n#define GL_KHR_texture_compression_astc_ldr 1\n\n#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0\n#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1\n#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2\n#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3\n#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4\n#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5\n#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6\n#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7\n#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8\n#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9\n#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA\n#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB\n#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC\n#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD\n\n#define GLEW_KHR_texture_compression_astc_ldr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_ldr)\n\n#endif /* GL_KHR_texture_compression_astc_ldr */\n\n/* -------------------------- GL_KTX_buffer_region ------------------------- */\n\n#ifndef GL_KTX_buffer_region\n#define GL_KTX_buffer_region 1\n\n#define GL_KTX_FRONT_REGION 0x0\n#define GL_KTX_BACK_REGION 0x1\n#define GL_KTX_Z_REGION 0x2\n#define GL_KTX_STENCIL_REGION 0x3\n\ntypedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLenum region);\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest);\ntypedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum region);\ntypedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height);\n\n#define glBufferRegionEnabled GLEW_GET_FUN(__glewBufferRegionEnabled)\n#define glDeleteBufferRegion GLEW_GET_FUN(__glewDeleteBufferRegion)\n#define glDrawBufferRegion GLEW_GET_FUN(__glewDrawBufferRegion)\n#define glNewBufferRegion GLEW_GET_FUN(__glewNewBufferRegion)\n#define glReadBufferRegion GLEW_GET_FUN(__glewReadBufferRegion)\n\n#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region)\n\n#endif /* GL_KTX_buffer_region */\n\n/* ------------------------- GL_MESAX_texture_stack ------------------------ */\n\n#ifndef GL_MESAX_texture_stack\n#define GL_MESAX_texture_stack 1\n\n#define GL_TEXTURE_1D_STACK_MESAX 0x8759\n#define GL_TEXTURE_2D_STACK_MESAX 0x875A\n#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B\n#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C\n#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D\n#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E\n\n#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack)\n\n#endif /* GL_MESAX_texture_stack */\n\n/* -------------------------- GL_MESA_pack_invert -------------------------- */\n\n#ifndef GL_MESA_pack_invert\n#define GL_MESA_pack_invert 1\n\n#define GL_PACK_INVERT_MESA 0x8758\n\n#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert)\n\n#endif /* GL_MESA_pack_invert */\n\n/* ------------------------- GL_MESA_resize_buffers ------------------------ */\n\n#ifndef GL_MESA_resize_buffers\n#define GL_MESA_resize_buffers 1\n\ntypedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void);\n\n#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA)\n\n#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers)\n\n#endif /* GL_MESA_resize_buffers */\n\n/* --------------------------- GL_MESA_window_pos -------------------------- */\n\n#ifndef GL_MESA_window_pos\n#define GL_MESA_window_pos 1\n\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p);\n\n#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA)\n#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA)\n#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA)\n#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA)\n#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA)\n#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA)\n#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA)\n#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA)\n#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA)\n#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA)\n#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA)\n#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA)\n#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA)\n#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA)\n#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA)\n#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA)\n#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA)\n#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA)\n#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA)\n#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA)\n#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA)\n#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA)\n#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA)\n#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA)\n\n#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos)\n\n#endif /* GL_MESA_window_pos */\n\n/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */\n\n#ifndef GL_MESA_ycbcr_texture\n#define GL_MESA_ycbcr_texture 1\n\n#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB\n#define GL_YCBCR_MESA 0x8757\n\n#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture)\n\n#endif /* GL_MESA_ycbcr_texture */\n\n/* ------------------------- GL_NVX_gpu_memory_info ------------------------ */\n\n#ifndef GL_NVX_gpu_memory_info\n#define GL_NVX_gpu_memory_info 1\n\n#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047\n#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048\n#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049\n#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A\n#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B\n\n#define GLEW_NVX_gpu_memory_info GLEW_GET_VAR(__GLEW_NVX_gpu_memory_info)\n\n#endif /* GL_NVX_gpu_memory_info */\n\n/* ------------------------- GL_NV_bindless_texture ------------------------ */\n\n#ifndef GL_NV_bindless_texture\n#define GL_NV_bindless_texture 1\n\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);\ntypedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);\ntypedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64* value);\n\n#define glGetImageHandleNV GLEW_GET_FUN(__glewGetImageHandleNV)\n#define glGetTextureHandleNV GLEW_GET_FUN(__glewGetTextureHandleNV)\n#define glGetTextureSamplerHandleNV GLEW_GET_FUN(__glewGetTextureSamplerHandleNV)\n#define glIsImageHandleResidentNV GLEW_GET_FUN(__glewIsImageHandleResidentNV)\n#define glIsTextureHandleResidentNV GLEW_GET_FUN(__glewIsTextureHandleResidentNV)\n#define glMakeImageHandleNonResidentNV GLEW_GET_FUN(__glewMakeImageHandleNonResidentNV)\n#define glMakeImageHandleResidentNV GLEW_GET_FUN(__glewMakeImageHandleResidentNV)\n#define glMakeTextureHandleNonResidentNV GLEW_GET_FUN(__glewMakeTextureHandleNonResidentNV)\n#define glMakeTextureHandleResidentNV GLEW_GET_FUN(__glewMakeTextureHandleResidentNV)\n#define glProgramUniformHandleui64NV GLEW_GET_FUN(__glewProgramUniformHandleui64NV)\n#define glProgramUniformHandleui64vNV GLEW_GET_FUN(__glewProgramUniformHandleui64vNV)\n#define glUniformHandleui64NV GLEW_GET_FUN(__glewUniformHandleui64NV)\n#define glUniformHandleui64vNV GLEW_GET_FUN(__glewUniformHandleui64vNV)\n\n#define GLEW_NV_bindless_texture GLEW_GET_VAR(__GLEW_NV_bindless_texture)\n\n#endif /* GL_NV_bindless_texture */\n\n/* --------------------------- GL_NV_blend_square -------------------------- */\n\n#ifndef GL_NV_blend_square\n#define GL_NV_blend_square 1\n\n#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square)\n\n#endif /* GL_NV_blend_square */\n\n/* ------------------------ GL_NV_conditional_render ----------------------- */\n\n#ifndef GL_NV_conditional_render\n#define GL_NV_conditional_render 1\n\n#define GL_QUERY_WAIT_NV 0x8E13\n#define GL_QUERY_NO_WAIT_NV 0x8E14\n#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15\n#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16\n\ntypedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void);\n\n#define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV)\n#define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV)\n\n#define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render)\n\n#endif /* GL_NV_conditional_render */\n\n/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */\n\n#ifndef GL_NV_copy_depth_to_color\n#define GL_NV_copy_depth_to_color 1\n\n#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E\n#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F\n\n#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color)\n\n#endif /* GL_NV_copy_depth_to_color */\n\n/* ---------------------------- GL_NV_copy_image --------------------------- */\n\n#ifndef GL_NV_copy_image\n#define GL_NV_copy_image 1\n\ntypedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n\n#define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV)\n\n#define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image)\n\n#endif /* GL_NV_copy_image */\n\n/* ------------------------ GL_NV_depth_buffer_float ----------------------- */\n\n#ifndef GL_NV_depth_buffer_float\n#define GL_NV_depth_buffer_float 1\n\n#define GL_DEPTH_COMPONENT32F_NV 0x8DAB\n#define GL_DEPTH32F_STENCIL8_NV 0x8DAC\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD\n#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF\n\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);\ntypedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);\n\n#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV)\n#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV)\n#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV)\n\n#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float)\n\n#endif /* GL_NV_depth_buffer_float */\n\n/* --------------------------- GL_NV_depth_clamp --------------------------- */\n\n#ifndef GL_NV_depth_clamp\n#define GL_NV_depth_clamp 1\n\n#define GL_DEPTH_CLAMP_NV 0x864F\n\n#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp)\n\n#endif /* GL_NV_depth_clamp */\n\n/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */\n\n#ifndef GL_NV_depth_range_unclamped\n#define GL_NV_depth_range_unclamped 1\n\n#define GL_SAMPLE_COUNT_BITS_NV 0x8864\n#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865\n#define GL_QUERY_RESULT_NV 0x8866\n#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867\n#define GL_SAMPLE_COUNT_NV 0x8914\n\n#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped)\n\n#endif /* GL_NV_depth_range_unclamped */\n\n/* ---------------------------- GL_NV_evaluators --------------------------- */\n\n#ifndef GL_NV_evaluators\n#define GL_NV_evaluators 1\n\n#define GL_EVAL_2D_NV 0x86C0\n#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1\n#define GL_MAP_TESSELLATION_NV 0x86C2\n#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3\n#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4\n#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5\n#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6\n#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7\n#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8\n#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9\n#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA\n#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB\n#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC\n#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD\n#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE\n#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF\n#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0\n#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1\n#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2\n#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3\n#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4\n#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5\n#define GL_MAX_MAP_TESSELLATION_NV 0x86D6\n#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7\n\ntypedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points);\ntypedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points);\ntypedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params);\n\n#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV)\n#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV)\n#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV)\n#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV)\n#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV)\n#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV)\n#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV)\n#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV)\n#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV)\n\n#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators)\n\n#endif /* GL_NV_evaluators */\n\n/* ----------------------- GL_NV_explicit_multisample ---------------------- */\n\n#ifndef GL_NV_explicit_multisample\n#define GL_NV_explicit_multisample 1\n\n#define GL_SAMPLE_POSITION_NV 0x8E50\n#define GL_SAMPLE_MASK_NV 0x8E51\n#define GL_SAMPLE_MASK_VALUE_NV 0x8E52\n#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53\n#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54\n#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55\n#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56\n#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57\n#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58\n#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59\n\ntypedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val);\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);\ntypedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);\n\n#define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV)\n#define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV)\n#define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV)\n\n#define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample)\n\n#endif /* GL_NV_explicit_multisample */\n\n/* ------------------------------ GL_NV_fence ------------------------------ */\n\n#ifndef GL_NV_fence\n#define GL_NV_fence 1\n\n#define GL_ALL_COMPLETED_NV 0x84F2\n#define GL_FENCE_STATUS_NV 0x84F3\n#define GL_FENCE_CONDITION_NV 0x84F4\n\ntypedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences);\ntypedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence);\ntypedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences);\ntypedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence);\ntypedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence);\n\n#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV)\n#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV)\n#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV)\n#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV)\n#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV)\n#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV)\n#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV)\n\n#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence)\n\n#endif /* GL_NV_fence */\n\n/* --------------------------- GL_NV_float_buffer -------------------------- */\n\n#ifndef GL_NV_float_buffer\n#define GL_NV_float_buffer 1\n\n#define GL_FLOAT_R_NV 0x8880\n#define GL_FLOAT_RG_NV 0x8881\n#define GL_FLOAT_RGB_NV 0x8882\n#define GL_FLOAT_RGBA_NV 0x8883\n#define GL_FLOAT_R16_NV 0x8884\n#define GL_FLOAT_R32_NV 0x8885\n#define GL_FLOAT_RG16_NV 0x8886\n#define GL_FLOAT_RG32_NV 0x8887\n#define GL_FLOAT_RGB16_NV 0x8888\n#define GL_FLOAT_RGB32_NV 0x8889\n#define GL_FLOAT_RGBA16_NV 0x888A\n#define GL_FLOAT_RGBA32_NV 0x888B\n#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C\n#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D\n#define GL_FLOAT_RGBA_MODE_NV 0x888E\n\n#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer)\n\n#endif /* GL_NV_float_buffer */\n\n/* --------------------------- GL_NV_fog_distance -------------------------- */\n\n#ifndef GL_NV_fog_distance\n#define GL_NV_fog_distance 1\n\n#define GL_FOG_DISTANCE_MODE_NV 0x855A\n#define GL_EYE_RADIAL_NV 0x855B\n#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C\n\n#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance)\n\n#endif /* GL_NV_fog_distance */\n\n/* ------------------------- GL_NV_fragment_program ------------------------ */\n\n#ifndef GL_NV_fragment_program\n#define GL_NV_fragment_program 1\n\n#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868\n#define GL_FRAGMENT_PROGRAM_NV 0x8870\n#define GL_MAX_TEXTURE_COORDS_NV 0x8871\n#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872\n#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873\n#define GL_PROGRAM_ERROR_STRING_NV 0x8874\n\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]);\n\n#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV)\n#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV)\n#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV)\n#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV)\n#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV)\n#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV)\n\n#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program)\n\n#endif /* GL_NV_fragment_program */\n\n/* ------------------------ GL_NV_fragment_program2 ------------------------ */\n\n#ifndef GL_NV_fragment_program2\n#define GL_NV_fragment_program2 1\n\n#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4\n#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5\n#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6\n#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7\n#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8\n\n#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2)\n\n#endif /* GL_NV_fragment_program2 */\n\n/* ------------------------ GL_NV_fragment_program4 ------------------------ */\n\n#ifndef GL_NV_fragment_program4\n#define GL_NV_fragment_program4 1\n\n#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4)\n\n#endif /* GL_NV_fragment_program4 */\n\n/* --------------------- GL_NV_fragment_program_option --------------------- */\n\n#ifndef GL_NV_fragment_program_option\n#define GL_NV_fragment_program_option 1\n\n#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option)\n\n#endif /* GL_NV_fragment_program_option */\n\n/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */\n\n#ifndef GL_NV_framebuffer_multisample_coverage\n#define GL_NV_framebuffer_multisample_coverage 1\n\n#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB\n#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10\n#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11\n#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12\n\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\n\n#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV)\n\n#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage)\n\n#endif /* GL_NV_framebuffer_multisample_coverage */\n\n/* ------------------------ GL_NV_geometry_program4 ------------------------ */\n\n#ifndef GL_NV_geometry_program4\n#define GL_NV_geometry_program4 1\n\n#define GL_GEOMETRY_PROGRAM_NV 0x8C26\n#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27\n#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28\n\ntypedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);\n\n#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV)\n\n#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4)\n\n#endif /* GL_NV_geometry_program4 */\n\n/* ------------------------- GL_NV_geometry_shader4 ------------------------ */\n\n#ifndef GL_NV_geometry_shader4\n#define GL_NV_geometry_shader4 1\n\n#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4)\n\n#endif /* GL_NV_geometry_shader4 */\n\n/* --------------------------- GL_NV_gpu_program4 -------------------------- */\n\n#ifndef GL_NV_gpu_program4\n#define GL_NV_gpu_program4 1\n\n#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905\n#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906\n#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907\n#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908\n#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909\n#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5\n#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6\n\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\n\n#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV)\n#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV)\n#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV)\n#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV)\n#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV)\n#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV)\n#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV)\n#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV)\n#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV)\n#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV)\n#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV)\n#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV)\n\n#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4)\n\n#endif /* GL_NV_gpu_program4 */\n\n/* --------------------------- GL_NV_gpu_program5 -------------------------- */\n\n#ifndef GL_NV_gpu_program5\n#define GL_NV_gpu_program5 1\n\n#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C\n#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F\n\n#define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5)\n\n#endif /* GL_NV_gpu_program5 */\n\n/* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */\n\n#ifndef GL_NV_gpu_program_fp64\n#define GL_NV_gpu_program_fp64 1\n\n#define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64)\n\n#endif /* GL_NV_gpu_program_fp64 */\n\n/* --------------------------- GL_NV_gpu_shader5 --------------------------- */\n\n#ifndef GL_NV_gpu_shader5\n#define GL_NV_gpu_shader5 1\n\n#define GL_INT64_NV 0x140E\n#define GL_UNSIGNED_INT64_NV 0x140F\n#define GL_INT8_NV 0x8FE0\n#define GL_INT8_VEC2_NV 0x8FE1\n#define GL_INT8_VEC3_NV 0x8FE2\n#define GL_INT8_VEC4_NV 0x8FE3\n#define GL_INT16_NV 0x8FE4\n#define GL_INT16_VEC2_NV 0x8FE5\n#define GL_INT16_VEC3_NV 0x8FE6\n#define GL_INT16_VEC4_NV 0x8FE7\n#define GL_INT64_VEC2_NV 0x8FE9\n#define GL_INT64_VEC3_NV 0x8FEA\n#define GL_INT64_VEC4_NV 0x8FEB\n#define GL_UNSIGNED_INT8_NV 0x8FEC\n#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED\n#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE\n#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF\n#define GL_UNSIGNED_INT16_NV 0x8FF0\n#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1\n#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2\n#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3\n#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5\n#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6\n#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7\n#define GL_FLOAT16_NV 0x8FF8\n#define GL_FLOAT16_VEC2_NV 0x8FF9\n#define GL_FLOAT16_VEC3_NV 0x8FFA\n#define GL_FLOAT16_VEC4_NV 0x8FFB\n\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\n\n#define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV)\n#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV)\n#define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV)\n#define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV)\n#define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV)\n#define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV)\n#define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV)\n#define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV)\n#define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV)\n#define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV)\n#define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV)\n#define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV)\n#define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV)\n#define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV)\n#define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV)\n#define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV)\n#define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV)\n#define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV)\n#define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV)\n#define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV)\n#define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV)\n#define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV)\n#define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV)\n#define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV)\n#define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV)\n#define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV)\n#define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV)\n#define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV)\n#define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV)\n#define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV)\n#define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV)\n#define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV)\n#define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV)\n#define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV)\n\n#define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5)\n\n#endif /* GL_NV_gpu_shader5 */\n\n/* ---------------------------- GL_NV_half_float --------------------------- */\n\n#ifndef GL_NV_half_float\n#define GL_NV_half_float 1\n\n#define GL_HALF_FLOAT_NV 0x140B\n\ntypedef unsigned short GLhalf;\n\ntypedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue);\ntypedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q);\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz);\ntypedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y);\ntypedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z);\ntypedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w);\ntypedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight);\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight);\n\n#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV)\n#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV)\n#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV)\n#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV)\n#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV)\n#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV)\n#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV)\n#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV)\n#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV)\n#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV)\n#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV)\n#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV)\n#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV)\n#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV)\n#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV)\n#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV)\n#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV)\n#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV)\n#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV)\n#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV)\n#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV)\n#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV)\n#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV)\n#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV)\n#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV)\n#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV)\n#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV)\n#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV)\n#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV)\n#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV)\n#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV)\n#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV)\n#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV)\n#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV)\n#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV)\n#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV)\n#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV)\n#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV)\n#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV)\n#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV)\n#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV)\n#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV)\n#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV)\n#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV)\n#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV)\n#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV)\n\n#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float)\n\n#endif /* GL_NV_half_float */\n\n/* ------------------------ GL_NV_light_max_exponent ----------------------- */\n\n#ifndef GL_NV_light_max_exponent\n#define GL_NV_light_max_exponent 1\n\n#define GL_MAX_SHININESS_NV 0x8504\n#define GL_MAX_SPOT_EXPONENT_NV 0x8505\n\n#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent)\n\n#endif /* GL_NV_light_max_exponent */\n\n/* ----------------------- GL_NV_multisample_coverage ---------------------- */\n\n#ifndef GL_NV_multisample_coverage\n#define GL_NV_multisample_coverage 1\n\n#define GL_COVERAGE_SAMPLES_NV 0x80A9\n#define GL_COLOR_SAMPLES_NV 0x8E20\n\n#define GLEW_NV_multisample_coverage GLEW_GET_VAR(__GLEW_NV_multisample_coverage)\n\n#endif /* GL_NV_multisample_coverage */\n\n/* --------------------- GL_NV_multisample_filter_hint --------------------- */\n\n#ifndef GL_NV_multisample_filter_hint\n#define GL_NV_multisample_filter_hint 1\n\n#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534\n\n#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint)\n\n#endif /* GL_NV_multisample_filter_hint */\n\n/* ------------------------- GL_NV_occlusion_query ------------------------- */\n\n#ifndef GL_NV_occlusion_query\n#define GL_NV_occlusion_query 1\n\n#define GL_PIXEL_COUNTER_BITS_NV 0x8864\n#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865\n#define GL_PIXEL_COUNT_NV 0x8866\n#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867\n\ntypedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);\n\n#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV)\n#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV)\n#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV)\n#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV)\n#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV)\n#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV)\n#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV)\n\n#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query)\n\n#endif /* GL_NV_occlusion_query */\n\n/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */\n\n#ifndef GL_NV_packed_depth_stencil\n#define GL_NV_packed_depth_stencil 1\n\n#define GL_DEPTH_STENCIL_NV 0x84F9\n#define GL_UNSIGNED_INT_24_8_NV 0x84FA\n\n#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil)\n\n#endif /* GL_NV_packed_depth_stencil */\n\n/* --------------------- GL_NV_parameter_buffer_object --------------------- */\n\n#ifndef GL_NV_parameter_buffer_object\n#define GL_NV_parameter_buffer_object 1\n\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1\n#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2\n#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3\n#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4\n\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);\n\n#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV)\n#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV)\n#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV)\n\n#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object)\n\n#endif /* GL_NV_parameter_buffer_object */\n\n/* --------------------- GL_NV_parameter_buffer_object2 -------------------- */\n\n#ifndef GL_NV_parameter_buffer_object2\n#define GL_NV_parameter_buffer_object2 1\n\n#define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2)\n\n#endif /* GL_NV_parameter_buffer_object2 */\n\n/* -------------------------- GL_NV_path_rendering ------------------------- */\n\n#ifndef GL_NV_path_rendering\n#define GL_NV_path_rendering 1\n\n#define GL_CLOSE_PATH_NV 0x00\n#define GL_BOLD_BIT_NV 0x01\n#define GL_GLYPH_WIDTH_BIT_NV 0x01\n#define GL_GLYPH_HEIGHT_BIT_NV 0x02\n#define GL_ITALIC_BIT_NV 0x02\n#define GL_MOVE_TO_NV 0x02\n#define GL_RELATIVE_MOVE_TO_NV 0x03\n#define GL_LINE_TO_NV 0x04\n#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04\n#define GL_RELATIVE_LINE_TO_NV 0x05\n#define GL_HORIZONTAL_LINE_TO_NV 0x06\n#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07\n#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08\n#define GL_VERTICAL_LINE_TO_NV 0x08\n#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09\n#define GL_QUADRATIC_CURVE_TO_NV 0x0A\n#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B\n#define GL_CUBIC_CURVE_TO_NV 0x0C\n#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D\n#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E\n#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F\n#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10\n#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10\n#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11\n#define GL_SMALL_CCW_ARC_TO_NV 0x12\n#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13\n#define GL_SMALL_CW_ARC_TO_NV 0x14\n#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15\n#define GL_LARGE_CCW_ARC_TO_NV 0x16\n#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17\n#define GL_LARGE_CW_ARC_TO_NV 0x18\n#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19\n#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20\n#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40\n#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80\n#define GL_RESTART_PATH_NV 0xF0\n#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2\n#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4\n#define GL_RECT_NV 0xF6\n#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8\n#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA\n#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC\n#define GL_ARC_TO_NV 0xFE\n#define GL_RELATIVE_ARC_TO_NV 0xFF\n#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100\n#define GL_PRIMARY_COLOR_NV 0x852C\n#define GL_SECONDARY_COLOR_NV 0x852D\n#define GL_PRIMARY_COLOR 0x8577\n#define GL_PATH_FORMAT_SVG_NV 0x9070\n#define GL_PATH_FORMAT_PS_NV 0x9071\n#define GL_STANDARD_FONT_NAME_NV 0x9072\n#define GL_SYSTEM_FONT_NAME_NV 0x9073\n#define GL_FILE_NAME_NV 0x9074\n#define GL_PATH_STROKE_WIDTH_NV 0x9075\n#define GL_PATH_END_CAPS_NV 0x9076\n#define GL_PATH_INITIAL_END_CAP_NV 0x9077\n#define GL_PATH_TERMINAL_END_CAP_NV 0x9078\n#define GL_PATH_JOIN_STYLE_NV 0x9079\n#define GL_PATH_MITER_LIMIT_NV 0x907A\n#define GL_PATH_DASH_CAPS_NV 0x907B\n#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C\n#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D\n#define GL_PATH_DASH_OFFSET_NV 0x907E\n#define GL_PATH_CLIENT_LENGTH_NV 0x907F\n#define GL_PATH_FILL_MODE_NV 0x9080\n#define GL_PATH_FILL_MASK_NV 0x9081\n#define GL_PATH_FILL_COVER_MODE_NV 0x9082\n#define GL_PATH_STROKE_COVER_MODE_NV 0x9083\n#define GL_PATH_STROKE_MASK_NV 0x9084\n#define GL_COUNT_UP_NV 0x9088\n#define GL_COUNT_DOWN_NV 0x9089\n#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A\n#define GL_CONVEX_HULL_NV 0x908B\n#define GL_BOUNDING_BOX_NV 0x908D\n#define GL_TRANSLATE_X_NV 0x908E\n#define GL_TRANSLATE_Y_NV 0x908F\n#define GL_TRANSLATE_2D_NV 0x9090\n#define GL_TRANSLATE_3D_NV 0x9091\n#define GL_AFFINE_2D_NV 0x9092\n#define GL_AFFINE_3D_NV 0x9094\n#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096\n#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098\n#define GL_UTF8_NV 0x909A\n#define GL_UTF16_NV 0x909B\n#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C\n#define GL_PATH_COMMAND_COUNT_NV 0x909D\n#define GL_PATH_COORD_COUNT_NV 0x909E\n#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F\n#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0\n#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1\n#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2\n#define GL_SQUARE_NV 0x90A3\n#define GL_ROUND_NV 0x90A4\n#define GL_TRIANGULAR_NV 0x90A5\n#define GL_BEVEL_NV 0x90A6\n#define GL_MITER_REVERT_NV 0x90A7\n#define GL_MITER_TRUNCATE_NV 0x90A8\n#define GL_SKIP_MISSING_GLYPH_NV 0x90A9\n#define GL_USE_MISSING_GLYPH_NV 0x90AA\n#define GL_PATH_ERROR_POSITION_NV 0x90AB\n#define GL_PATH_FOG_GEN_MODE_NV 0x90AC\n#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD\n#define GL_ADJACENT_PAIRS_NV 0x90AE\n#define GL_FIRST_TO_REST_NV 0x90AF\n#define GL_PATH_GEN_MODE_NV 0x90B0\n#define GL_PATH_GEN_COEFF_NV 0x90B1\n#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2\n#define GL_PATH_GEN_COMPONENTS_NV 0x90B3\n#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4\n#define GL_MOVE_TO_RESETS_NV 0x90B5\n#define GL_MOVE_TO_CONTINUES_NV 0x90B6\n#define GL_PATH_STENCIL_FUNC_NV 0x90B7\n#define GL_PATH_STENCIL_REF_NV 0x90B8\n#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9\n#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD\n#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE\n#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF\n#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000\n#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000\n#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000\n#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000\n#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000\n#define GL_FONT_ASCENDER_BIT_NV 0x00200000\n#define GL_FONT_DESCENDER_BIT_NV 0x00400000\n#define GL_FONT_HEIGHT_BIT_NV 0x00800000\n#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000\n#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000\n#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000\n#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000\n#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000\n\ntypedef void (GLAPIENTRY * PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);\ntypedef void (GLAPIENTRY * PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef void (GLAPIENTRY * PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);\ntypedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHNVPROC) (GLuint name, GLenum coverMode);\ntypedef void (GLAPIENTRY * PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);\ntypedef GLuint (GLAPIENTRY * PFNGLGENPATHSNVPROC) (GLsizei range);\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint* value);\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOMMANDSNVPROC) (GLuint name, GLubyte* commands);\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOORDSNVPROC) (GLuint name, GLfloat* coords);\ntypedef void (GLAPIENTRY * PFNGLGETPATHDASHARRAYNVPROC) (GLuint name, GLfloat* dashArray);\ntypedef GLfloat (GLAPIENTRY * PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);\ntypedef void (GLAPIENTRY * PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint fistPathName, GLsizei numPaths, GLsizei stride, GLfloat* metrics);\ntypedef void (GLAPIENTRY * PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);\ntypedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERFVNVPROC) (GLuint name, GLenum param, GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERIVNVPROC) (GLuint name, GLenum param, GLint* value);\ntypedef void (GLAPIENTRY * PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);\ntypedef void (GLAPIENTRY * PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint* value);\ntypedef void (GLAPIENTRY * PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPATHNVPROC) (GLuint path);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat* coeffs);\ntypedef void (GLAPIENTRY * PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const GLvoid*coords);\ntypedef void (GLAPIENTRY * PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void* coords);\ntypedef void (GLAPIENTRY * PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum zfunc);\ntypedef void (GLAPIENTRY * PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat* dashArray);\ntypedef void (GLAPIENTRY * PFNGLPATHFOGGENNVPROC) (GLenum genMode);\ntypedef void (GLAPIENTRY * PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void* fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef void (GLAPIENTRY * PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void* fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid*charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat* value);\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint* value);\ntypedef void (GLAPIENTRY * PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);\ntypedef void (GLAPIENTRY * PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);\ntypedef void (GLAPIENTRY * PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void* pathString);\ntypedef void (GLAPIENTRY * PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const GLvoid*coords);\ntypedef void (GLAPIENTRY * PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void* coords);\ntypedef void (GLAPIENTRY * PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat* coeffs);\ntypedef GLboolean (GLAPIENTRY * PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat* x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);\ntypedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);\ntypedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);\ntypedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void* paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);\ntypedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat* transformValues);\ntypedef void (GLAPIENTRY * PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint paths[], const GLfloat weights[]);\n\n#define glCopyPathNV GLEW_GET_FUN(__glewCopyPathNV)\n#define glCoverFillPathInstancedNV GLEW_GET_FUN(__glewCoverFillPathInstancedNV)\n#define glCoverFillPathNV GLEW_GET_FUN(__glewCoverFillPathNV)\n#define glCoverStrokePathInstancedNV GLEW_GET_FUN(__glewCoverStrokePathInstancedNV)\n#define glCoverStrokePathNV GLEW_GET_FUN(__glewCoverStrokePathNV)\n#define glDeletePathsNV GLEW_GET_FUN(__glewDeletePathsNV)\n#define glGenPathsNV GLEW_GET_FUN(__glewGenPathsNV)\n#define glGetPathColorGenfvNV GLEW_GET_FUN(__glewGetPathColorGenfvNV)\n#define glGetPathColorGenivNV GLEW_GET_FUN(__glewGetPathColorGenivNV)\n#define glGetPathCommandsNV GLEW_GET_FUN(__glewGetPathCommandsNV)\n#define glGetPathCoordsNV GLEW_GET_FUN(__glewGetPathCoordsNV)\n#define glGetPathDashArrayNV GLEW_GET_FUN(__glewGetPathDashArrayNV)\n#define glGetPathLengthNV GLEW_GET_FUN(__glewGetPathLengthNV)\n#define glGetPathMetricRangeNV GLEW_GET_FUN(__glewGetPathMetricRangeNV)\n#define glGetPathMetricsNV GLEW_GET_FUN(__glewGetPathMetricsNV)\n#define glGetPathParameterfvNV GLEW_GET_FUN(__glewGetPathParameterfvNV)\n#define glGetPathParameterivNV GLEW_GET_FUN(__glewGetPathParameterivNV)\n#define glGetPathSpacingNV GLEW_GET_FUN(__glewGetPathSpacingNV)\n#define glGetPathTexGenfvNV GLEW_GET_FUN(__glewGetPathTexGenfvNV)\n#define glGetPathTexGenivNV GLEW_GET_FUN(__glewGetPathTexGenivNV)\n#define glInterpolatePathsNV GLEW_GET_FUN(__glewInterpolatePathsNV)\n#define glIsPathNV GLEW_GET_FUN(__glewIsPathNV)\n#define glIsPointInFillPathNV GLEW_GET_FUN(__glewIsPointInFillPathNV)\n#define glIsPointInStrokePathNV GLEW_GET_FUN(__glewIsPointInStrokePathNV)\n#define glPathColorGenNV GLEW_GET_FUN(__glewPathColorGenNV)\n#define glPathCommandsNV GLEW_GET_FUN(__glewPathCommandsNV)\n#define glPathCoordsNV GLEW_GET_FUN(__glewPathCoordsNV)\n#define glPathCoverDepthFuncNV GLEW_GET_FUN(__glewPathCoverDepthFuncNV)\n#define glPathDashArrayNV GLEW_GET_FUN(__glewPathDashArrayNV)\n#define glPathFogGenNV GLEW_GET_FUN(__glewPathFogGenNV)\n#define glPathGlyphRangeNV GLEW_GET_FUN(__glewPathGlyphRangeNV)\n#define glPathGlyphsNV GLEW_GET_FUN(__glewPathGlyphsNV)\n#define glPathParameterfNV GLEW_GET_FUN(__glewPathParameterfNV)\n#define glPathParameterfvNV GLEW_GET_FUN(__glewPathParameterfvNV)\n#define glPathParameteriNV GLEW_GET_FUN(__glewPathParameteriNV)\n#define glPathParameterivNV GLEW_GET_FUN(__glewPathParameterivNV)\n#define glPathStencilDepthOffsetNV GLEW_GET_FUN(__glewPathStencilDepthOffsetNV)\n#define glPathStencilFuncNV GLEW_GET_FUN(__glewPathStencilFuncNV)\n#define glPathStringNV GLEW_GET_FUN(__glewPathStringNV)\n#define glPathSubCommandsNV GLEW_GET_FUN(__glewPathSubCommandsNV)\n#define glPathSubCoordsNV GLEW_GET_FUN(__glewPathSubCoordsNV)\n#define glPathTexGenNV GLEW_GET_FUN(__glewPathTexGenNV)\n#define glPointAlongPathNV GLEW_GET_FUN(__glewPointAlongPathNV)\n#define glStencilFillPathInstancedNV GLEW_GET_FUN(__glewStencilFillPathInstancedNV)\n#define glStencilFillPathNV GLEW_GET_FUN(__glewStencilFillPathNV)\n#define glStencilStrokePathInstancedNV GLEW_GET_FUN(__glewStencilStrokePathInstancedNV)\n#define glStencilStrokePathNV GLEW_GET_FUN(__glewStencilStrokePathNV)\n#define glTransformPathNV GLEW_GET_FUN(__glewTransformPathNV)\n#define glWeightPathsNV GLEW_GET_FUN(__glewWeightPathsNV)\n\n#define GLEW_NV_path_rendering GLEW_GET_VAR(__GLEW_NV_path_rendering)\n\n#endif /* GL_NV_path_rendering */\n\n/* ------------------------- GL_NV_pixel_data_range ------------------------ */\n\n#ifndef GL_NV_pixel_data_range\n#define GL_NV_pixel_data_range 1\n\n#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878\n#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879\n#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A\n#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B\n#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C\n#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D\n\ntypedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer);\n\n#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV)\n#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV)\n\n#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range)\n\n#endif /* GL_NV_pixel_data_range */\n\n/* --------------------------- GL_NV_point_sprite -------------------------- */\n\n#ifndef GL_NV_point_sprite\n#define GL_NV_point_sprite 1\n\n#define GL_POINT_SPRITE_NV 0x8861\n#define GL_COORD_REPLACE_NV 0x8862\n#define GL_POINT_SPRITE_R_MODE_NV 0x8863\n\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params);\n\n#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV)\n#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV)\n\n#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite)\n\n#endif /* GL_NV_point_sprite */\n\n/* -------------------------- GL_NV_present_video -------------------------- */\n\n#ifndef GL_NV_present_video\n#define GL_NV_present_video 1\n\n#define GL_FRAME_NV 0x8E26\n#define GL_FIELDS_NV 0x8E27\n#define GL_CURRENT_TIME_NV 0x8E28\n#define GL_NUM_FILL_STREAMS_NV 0x8E29\n#define GL_PRESENT_TIME_NV 0x8E2A\n#define GL_PRESENT_DURATION_NV 0x8E2B\n\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params);\ntypedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);\ntypedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);\n\n#define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV)\n#define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV)\n#define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV)\n#define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV)\n#define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV)\n#define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV)\n\n#define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video)\n\n#endif /* GL_NV_present_video */\n\n/* ------------------------ GL_NV_primitive_restart ------------------------ */\n\n#ifndef GL_NV_primitive_restart\n#define GL_NV_primitive_restart 1\n\n#define GL_PRIMITIVE_RESTART_NV 0x8558\n#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559\n\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void);\n\n#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV)\n#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV)\n\n#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart)\n\n#endif /* GL_NV_primitive_restart */\n\n/* ------------------------ GL_NV_register_combiners ----------------------- */\n\n#ifndef GL_NV_register_combiners\n#define GL_NV_register_combiners 1\n\n#define GL_REGISTER_COMBINERS_NV 0x8522\n#define GL_VARIABLE_A_NV 0x8523\n#define GL_VARIABLE_B_NV 0x8524\n#define GL_VARIABLE_C_NV 0x8525\n#define GL_VARIABLE_D_NV 0x8526\n#define GL_VARIABLE_E_NV 0x8527\n#define GL_VARIABLE_F_NV 0x8528\n#define GL_VARIABLE_G_NV 0x8529\n#define GL_CONSTANT_COLOR0_NV 0x852A\n#define GL_CONSTANT_COLOR1_NV 0x852B\n#define GL_PRIMARY_COLOR_NV 0x852C\n#define GL_SECONDARY_COLOR_NV 0x852D\n#define GL_SPARE0_NV 0x852E\n#define GL_SPARE1_NV 0x852F\n#define GL_DISCARD_NV 0x8530\n#define GL_E_TIMES_F_NV 0x8531\n#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532\n#define GL_UNSIGNED_IDENTITY_NV 0x8536\n#define GL_UNSIGNED_INVERT_NV 0x8537\n#define GL_EXPAND_NORMAL_NV 0x8538\n#define GL_EXPAND_NEGATE_NV 0x8539\n#define GL_HALF_BIAS_NORMAL_NV 0x853A\n#define GL_HALF_BIAS_NEGATE_NV 0x853B\n#define GL_SIGNED_IDENTITY_NV 0x853C\n#define GL_SIGNED_NEGATE_NV 0x853D\n#define GL_SCALE_BY_TWO_NV 0x853E\n#define GL_SCALE_BY_FOUR_NV 0x853F\n#define GL_SCALE_BY_ONE_HALF_NV 0x8540\n#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541\n#define GL_COMBINER_INPUT_NV 0x8542\n#define GL_COMBINER_MAPPING_NV 0x8543\n#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544\n#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545\n#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546\n#define GL_COMBINER_MUX_SUM_NV 0x8547\n#define GL_COMBINER_SCALE_NV 0x8548\n#define GL_COMBINER_BIAS_NV 0x8549\n#define GL_COMBINER_AB_OUTPUT_NV 0x854A\n#define GL_COMBINER_CD_OUTPUT_NV 0x854B\n#define GL_COMBINER_SUM_OUTPUT_NV 0x854C\n#define GL_MAX_GENERAL_COMBINERS_NV 0x854D\n#define GL_NUM_GENERAL_COMBINERS_NV 0x854E\n#define GL_COLOR_SUM_CLAMP_NV 0x854F\n#define GL_COMBINER0_NV 0x8550\n#define GL_COMBINER1_NV 0x8551\n#define GL_COMBINER2_NV 0x8552\n#define GL_COMBINER3_NV 0x8553\n#define GL_COMBINER4_NV 0x8554\n#define GL_COMBINER5_NV 0x8555\n#define GL_COMBINER6_NV 0x8556\n#define GL_COMBINER7_NV 0x8557\n\ntypedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\ntypedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params);\n\n#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV)\n#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV)\n#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV)\n#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV)\n#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV)\n#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV)\n#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV)\n#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV)\n#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV)\n#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV)\n#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV)\n#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV)\n#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV)\n\n#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners)\n\n#endif /* GL_NV_register_combiners */\n\n/* ----------------------- GL_NV_register_combiners2 ----------------------- */\n\n#ifndef GL_NV_register_combiners2\n#define GL_NV_register_combiners2 1\n\n#define GL_PER_STAGE_CONSTANTS_NV 0x8535\n\ntypedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params);\n\n#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV)\n#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV)\n\n#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2)\n\n#endif /* GL_NV_register_combiners2 */\n\n/* ----------------------- GL_NV_shader_atomic_float ----------------------- */\n\n#ifndef GL_NV_shader_atomic_float\n#define GL_NV_shader_atomic_float 1\n\n#define GLEW_NV_shader_atomic_float GLEW_GET_VAR(__GLEW_NV_shader_atomic_float)\n\n#endif /* GL_NV_shader_atomic_float */\n\n/* ------------------------ GL_NV_shader_buffer_load ----------------------- */\n\n#ifndef GL_NV_shader_buffer_load\n#define GL_NV_shader_buffer_load 1\n\n#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D\n#define GL_GPU_ADDRESS_NV 0x8F34\n#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35\n\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result);\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);\ntypedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);\ntypedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);\ntypedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\n\n#define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV)\n#define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV)\n#define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV)\n#define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV)\n#define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV)\n#define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV)\n#define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV)\n#define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV)\n#define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV)\n#define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV)\n#define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV)\n#define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV)\n#define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV)\n\n#define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load)\n\n#endif /* GL_NV_shader_buffer_load */\n\n/* ---------------------- GL_NV_tessellation_program5 ---------------------- */\n\n#ifndef GL_NV_tessellation_program5\n#define GL_NV_tessellation_program5 1\n\n#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8\n#define GL_TESS_CONTROL_PROGRAM_NV 0x891E\n#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F\n#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74\n#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75\n\n#define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5)\n\n#endif /* GL_NV_tessellation_program5 */\n\n/* -------------------------- GL_NV_texgen_emboss -------------------------- */\n\n#ifndef GL_NV_texgen_emboss\n#define GL_NV_texgen_emboss 1\n\n#define GL_EMBOSS_LIGHT_NV 0x855D\n#define GL_EMBOSS_CONSTANT_NV 0x855E\n#define GL_EMBOSS_MAP_NV 0x855F\n\n#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss)\n\n#endif /* GL_NV_texgen_emboss */\n\n/* ------------------------ GL_NV_texgen_reflection ------------------------ */\n\n#ifndef GL_NV_texgen_reflection\n#define GL_NV_texgen_reflection 1\n\n#define GL_NORMAL_MAP_NV 0x8511\n#define GL_REFLECTION_MAP_NV 0x8512\n\n#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection)\n\n#endif /* GL_NV_texgen_reflection */\n\n/* ------------------------- GL_NV_texture_barrier ------------------------- */\n\n#ifndef GL_NV_texture_barrier\n#define GL_NV_texture_barrier 1\n\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void);\n\n#define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV)\n\n#define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier)\n\n#endif /* GL_NV_texture_barrier */\n\n/* --------------------- GL_NV_texture_compression_vtc --------------------- */\n\n#ifndef GL_NV_texture_compression_vtc\n#define GL_NV_texture_compression_vtc 1\n\n#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc)\n\n#endif /* GL_NV_texture_compression_vtc */\n\n/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */\n\n#ifndef GL_NV_texture_env_combine4\n#define GL_NV_texture_env_combine4 1\n\n#define GL_COMBINE4_NV 0x8503\n#define GL_SOURCE3_RGB_NV 0x8583\n#define GL_SOURCE3_ALPHA_NV 0x858B\n#define GL_OPERAND3_RGB_NV 0x8593\n#define GL_OPERAND3_ALPHA_NV 0x859B\n\n#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4)\n\n#endif /* GL_NV_texture_env_combine4 */\n\n/* ---------------------- GL_NV_texture_expand_normal ---------------------- */\n\n#ifndef GL_NV_texture_expand_normal\n#define GL_NV_texture_expand_normal 1\n\n#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F\n\n#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal)\n\n#endif /* GL_NV_texture_expand_normal */\n\n/* ----------------------- GL_NV_texture_multisample ----------------------- */\n\n#ifndef GL_NV_texture_multisample\n#define GL_NV_texture_multisample 1\n\n#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045\n#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046\n\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\n\n#define glTexImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage2DMultisampleCoverageNV)\n#define glTexImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage3DMultisampleCoverageNV)\n#define glTextureImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage2DMultisampleCoverageNV)\n#define glTextureImage2DMultisampleNV GLEW_GET_FUN(__glewTextureImage2DMultisampleNV)\n#define glTextureImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage3DMultisampleCoverageNV)\n#define glTextureImage3DMultisampleNV GLEW_GET_FUN(__glewTextureImage3DMultisampleNV)\n\n#define GLEW_NV_texture_multisample GLEW_GET_VAR(__GLEW_NV_texture_multisample)\n\n#endif /* GL_NV_texture_multisample */\n\n/* ------------------------ GL_NV_texture_rectangle ------------------------ */\n\n#ifndef GL_NV_texture_rectangle\n#define GL_NV_texture_rectangle 1\n\n#define GL_TEXTURE_RECTANGLE_NV 0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8\n\n#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle)\n\n#endif /* GL_NV_texture_rectangle */\n\n/* -------------------------- GL_NV_texture_shader ------------------------- */\n\n#ifndef GL_NV_texture_shader\n#define GL_NV_texture_shader 1\n\n#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C\n#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D\n#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E\n#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9\n#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA\n#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB\n#define GL_DSDT_MAG_INTENSITY_NV 0x86DC\n#define GL_SHADER_CONSISTENT_NV 0x86DD\n#define GL_TEXTURE_SHADER_NV 0x86DE\n#define GL_SHADER_OPERATION_NV 0x86DF\n#define GL_CULL_MODES_NV 0x86E0\n#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1\n#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1\n#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2\n#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2\n#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3\n#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3\n#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4\n#define GL_CONST_EYE_NV 0x86E5\n#define GL_PASS_THROUGH_NV 0x86E6\n#define GL_CULL_FRAGMENT_NV 0x86E7\n#define GL_OFFSET_TEXTURE_2D_NV 0x86E8\n#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9\n#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA\n#define GL_DOT_PRODUCT_NV 0x86EC\n#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED\n#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE\n#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0\n#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1\n#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2\n#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3\n#define GL_HILO_NV 0x86F4\n#define GL_DSDT_NV 0x86F5\n#define GL_DSDT_MAG_NV 0x86F6\n#define GL_DSDT_MAG_VIB_NV 0x86F7\n#define GL_HILO16_NV 0x86F8\n#define GL_SIGNED_HILO_NV 0x86F9\n#define GL_SIGNED_HILO16_NV 0x86FA\n#define GL_SIGNED_RGBA_NV 0x86FB\n#define GL_SIGNED_RGBA8_NV 0x86FC\n#define GL_SIGNED_RGB_NV 0x86FE\n#define GL_SIGNED_RGB8_NV 0x86FF\n#define GL_SIGNED_LUMINANCE_NV 0x8701\n#define GL_SIGNED_LUMINANCE8_NV 0x8702\n#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703\n#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704\n#define GL_SIGNED_ALPHA_NV 0x8705\n#define GL_SIGNED_ALPHA8_NV 0x8706\n#define GL_SIGNED_INTENSITY_NV 0x8707\n#define GL_SIGNED_INTENSITY8_NV 0x8708\n#define GL_DSDT8_NV 0x8709\n#define GL_DSDT8_MAG8_NV 0x870A\n#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B\n#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C\n#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D\n#define GL_HI_SCALE_NV 0x870E\n#define GL_LO_SCALE_NV 0x870F\n#define GL_DS_SCALE_NV 0x8710\n#define GL_DT_SCALE_NV 0x8711\n#define GL_MAGNITUDE_SCALE_NV 0x8712\n#define GL_VIBRANCE_SCALE_NV 0x8713\n#define GL_HI_BIAS_NV 0x8714\n#define GL_LO_BIAS_NV 0x8715\n#define GL_DS_BIAS_NV 0x8716\n#define GL_DT_BIAS_NV 0x8717\n#define GL_MAGNITUDE_BIAS_NV 0x8718\n#define GL_VIBRANCE_BIAS_NV 0x8719\n#define GL_TEXTURE_BORDER_VALUES_NV 0x871A\n#define GL_TEXTURE_HI_SIZE_NV 0x871B\n#define GL_TEXTURE_LO_SIZE_NV 0x871C\n#define GL_TEXTURE_DS_SIZE_NV 0x871D\n#define GL_TEXTURE_DT_SIZE_NV 0x871E\n#define GL_TEXTURE_MAG_SIZE_NV 0x871F\n\n#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader)\n\n#endif /* GL_NV_texture_shader */\n\n/* ------------------------- GL_NV_texture_shader2 ------------------------- */\n\n#ifndef GL_NV_texture_shader2\n#define GL_NV_texture_shader2 1\n\n#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA\n#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB\n#define GL_DSDT_MAG_INTENSITY_NV 0x86DC\n#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF\n#define GL_HILO_NV 0x86F4\n#define GL_DSDT_NV 0x86F5\n#define GL_DSDT_MAG_NV 0x86F6\n#define GL_DSDT_MAG_VIB_NV 0x86F7\n#define GL_HILO16_NV 0x86F8\n#define GL_SIGNED_HILO_NV 0x86F9\n#define GL_SIGNED_HILO16_NV 0x86FA\n#define GL_SIGNED_RGBA_NV 0x86FB\n#define GL_SIGNED_RGBA8_NV 0x86FC\n#define GL_SIGNED_RGB_NV 0x86FE\n#define GL_SIGNED_RGB8_NV 0x86FF\n#define GL_SIGNED_LUMINANCE_NV 0x8701\n#define GL_SIGNED_LUMINANCE8_NV 0x8702\n#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703\n#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704\n#define GL_SIGNED_ALPHA_NV 0x8705\n#define GL_SIGNED_ALPHA8_NV 0x8706\n#define GL_SIGNED_INTENSITY_NV 0x8707\n#define GL_SIGNED_INTENSITY8_NV 0x8708\n#define GL_DSDT8_NV 0x8709\n#define GL_DSDT8_MAG8_NV 0x870A\n#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B\n#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C\n#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D\n\n#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2)\n\n#endif /* GL_NV_texture_shader2 */\n\n/* ------------------------- GL_NV_texture_shader3 ------------------------- */\n\n#ifndef GL_NV_texture_shader3\n#define GL_NV_texture_shader3 1\n\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853\n#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854\n#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857\n#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858\n#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859\n#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A\n#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B\n#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C\n#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D\n#define GL_HILO8_NV 0x885E\n#define GL_SIGNED_HILO8_NV 0x885F\n#define GL_FORCE_BLUE_TO_ONE_NV 0x8860\n\n#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3)\n\n#endif /* GL_NV_texture_shader3 */\n\n/* ------------------------ GL_NV_transform_feedback ----------------------- */\n\n#ifndef GL_NV_transform_feedback\n#define GL_NV_transform_feedback 1\n\n#define GL_BACK_PRIMARY_COLOR_NV 0x8C77\n#define GL_BACK_SECONDARY_COLOR_NV 0x8C78\n#define GL_TEXTURE_COORD_NV 0x8C79\n#define GL_CLIP_DISTANCE_NV 0x8C7A\n#define GL_VERTEX_ID_NV 0x8C7B\n#define GL_PRIMITIVE_ID_NV 0x8C7C\n#define GL_GENERIC_ATTRIB_NV 0x8C7D\n#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80\n#define GL_ACTIVE_VARYINGS_NV 0x8C81\n#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85\n#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86\n#define GL_PRIMITIVES_GENERATED_NV 0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88\n#define GL_RASTERIZER_DISCARD_NV 0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C\n#define GL_SEPARATE_ATTRIBS_NV 0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F\n\ntypedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);\ntypedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);\n\n#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV)\n#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV)\n#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV)\n#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV)\n#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV)\n#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV)\n#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV)\n#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV)\n#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV)\n#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV)\n#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV)\n\n#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback)\n\n#endif /* GL_NV_transform_feedback */\n\n/* ----------------------- GL_NV_transform_feedback2 ----------------------- */\n\n#ifndef GL_NV_transform_feedback2\n#define GL_NV_transform_feedback2 1\n\n#define GL_TRANSFORM_FEEDBACK_NV 0x8E22\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25\n\ntypedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids);\ntypedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);\n\n#define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV)\n#define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV)\n#define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV)\n#define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV)\n#define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV)\n#define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV)\n#define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV)\n\n#define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2)\n\n#endif /* GL_NV_transform_feedback2 */\n\n/* -------------------------- GL_NV_vdpau_interop -------------------------- */\n\n#ifndef GL_NV_vdpau_interop\n#define GL_NV_vdpau_interop 1\n\n#define GL_SURFACE_STATE_NV 0x86EB\n#define GL_SURFACE_REGISTERED_NV 0x86FD\n#define GL_SURFACE_MAPPED_NV 0x8700\n#define GL_WRITE_DISCARD_NV 0x88BE\n\ntypedef GLintptr GLvdpauSurfaceNV;\n\ntypedef void (GLAPIENTRY * PFNGLVDPAUFININVPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei* length, GLint *values);\ntypedef void (GLAPIENTRY * PFNGLVDPAUINITNVPROC) (const void* vdpDevice, const GLvoid*getProcAddress);\ntypedef void (GLAPIENTRY * PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);\ntypedef void (GLAPIENTRY * PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV* surfaces);\ntypedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\ntypedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\ntypedef void (GLAPIENTRY * PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);\ntypedef void (GLAPIENTRY * PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV* surfaces);\ntypedef void (GLAPIENTRY * PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);\n\n#define glVDPAUFiniNV GLEW_GET_FUN(__glewVDPAUFiniNV)\n#define glVDPAUGetSurfaceivNV GLEW_GET_FUN(__glewVDPAUGetSurfaceivNV)\n#define glVDPAUInitNV GLEW_GET_FUN(__glewVDPAUInitNV)\n#define glVDPAUIsSurfaceNV GLEW_GET_FUN(__glewVDPAUIsSurfaceNV)\n#define glVDPAUMapSurfacesNV GLEW_GET_FUN(__glewVDPAUMapSurfacesNV)\n#define glVDPAURegisterOutputSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterOutputSurfaceNV)\n#define glVDPAURegisterVideoSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterVideoSurfaceNV)\n#define glVDPAUSurfaceAccessNV GLEW_GET_FUN(__glewVDPAUSurfaceAccessNV)\n#define glVDPAUUnmapSurfacesNV GLEW_GET_FUN(__glewVDPAUUnmapSurfacesNV)\n#define glVDPAUUnregisterSurfaceNV GLEW_GET_FUN(__glewVDPAUUnregisterSurfaceNV)\n\n#define GLEW_NV_vdpau_interop GLEW_GET_VAR(__GLEW_NV_vdpau_interop)\n\n#endif /* GL_NV_vdpau_interop */\n\n/* ------------------------ GL_NV_vertex_array_range ----------------------- */\n\n#ifndef GL_NV_vertex_array_range\n#define GL_NV_vertex_array_range 1\n\n#define GL_VERTEX_ARRAY_RANGE_NV 0x851D\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E\n#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F\n#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520\n#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521\n\ntypedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer);\n\n#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV)\n#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV)\n\n#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range)\n\n#endif /* GL_NV_vertex_array_range */\n\n/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */\n\n#ifndef GL_NV_vertex_array_range2\n#define GL_NV_vertex_array_range2 1\n\n#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533\n\n#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2)\n\n#endif /* GL_NV_vertex_array_range2 */\n\n/* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */\n\n#ifndef GL_NV_vertex_attrib_integer_64bit\n#define GL_NV_vertex_attrib_integer_64bit 1\n\n#define GL_INT64_NV 0x140E\n#define GL_UNSIGNED_INT64_NV 0x140F\n\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\n\n#define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV)\n#define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV)\n#define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV)\n#define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV)\n#define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV)\n#define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV)\n#define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV)\n#define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV)\n#define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV)\n#define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV)\n#define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV)\n#define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV)\n#define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV)\n#define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV)\n#define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV)\n#define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV)\n#define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV)\n#define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV)\n#define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV)\n\n#define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit)\n\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n\n/* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */\n\n#ifndef GL_NV_vertex_buffer_unified_memory\n#define GL_NV_vertex_buffer_unified_memory 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E\n#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F\n#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20\n#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21\n#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22\n#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23\n#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24\n#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25\n#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26\n#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27\n#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28\n#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29\n#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A\n#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B\n#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C\n#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D\n#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E\n#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F\n#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30\n#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31\n#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32\n#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33\n#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40\n#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41\n#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42\n\ntypedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);\ntypedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]);\ntypedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\ntypedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\n\n#define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV)\n#define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV)\n#define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV)\n#define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV)\n#define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV)\n#define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV)\n#define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV)\n#define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV)\n#define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV)\n#define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV)\n#define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV)\n#define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV)\n\n#define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory)\n\n#endif /* GL_NV_vertex_buffer_unified_memory */\n\n/* -------------------------- GL_NV_vertex_program ------------------------- */\n\n#ifndef GL_NV_vertex_program\n#define GL_NV_vertex_program 1\n\n#define GL_VERTEX_PROGRAM_NV 0x8620\n#define GL_VERTEX_STATE_PROGRAM_NV 0x8621\n#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623\n#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624\n#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625\n#define GL_CURRENT_ATTRIB_NV 0x8626\n#define GL_PROGRAM_LENGTH_NV 0x8627\n#define GL_PROGRAM_STRING_NV 0x8628\n#define GL_MODELVIEW_PROJECTION_NV 0x8629\n#define GL_IDENTITY_NV 0x862A\n#define GL_INVERSE_NV 0x862B\n#define GL_TRANSPOSE_NV 0x862C\n#define GL_INVERSE_TRANSPOSE_NV 0x862D\n#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E\n#define GL_MAX_TRACK_MATRICES_NV 0x862F\n#define GL_MATRIX0_NV 0x8630\n#define GL_MATRIX1_NV 0x8631\n#define GL_MATRIX2_NV 0x8632\n#define GL_MATRIX3_NV 0x8633\n#define GL_MATRIX4_NV 0x8634\n#define GL_MATRIX5_NV 0x8635\n#define GL_MATRIX6_NV 0x8636\n#define GL_MATRIX7_NV 0x8637\n#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640\n#define GL_CURRENT_MATRIX_NV 0x8641\n#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642\n#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643\n#define GL_PROGRAM_PARAMETER_NV 0x8644\n#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645\n#define GL_PROGRAM_TARGET_NV 0x8646\n#define GL_PROGRAM_RESIDENT_NV 0x8647\n#define GL_TRACK_MATRIX_NV 0x8648\n#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649\n#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A\n#define GL_PROGRAM_ERROR_POSITION_NV 0x864B\n#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650\n#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651\n#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652\n#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653\n#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654\n#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655\n#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656\n#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657\n#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658\n#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659\n#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A\n#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B\n#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C\n#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D\n#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E\n#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F\n#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660\n#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661\n#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662\n#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663\n#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664\n#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665\n#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666\n#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667\n#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668\n#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669\n#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A\n#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B\n#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C\n#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D\n#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E\n#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F\n#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670\n#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671\n#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672\n#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673\n#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674\n#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675\n#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676\n#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677\n#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678\n#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679\n#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A\n#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B\n#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C\n#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D\n#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E\n#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F\n\ntypedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences);\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program);\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params);\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id);\ntypedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids);\ntypedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v);\n\n#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV)\n#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV)\n#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV)\n#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV)\n#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV)\n#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV)\n#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV)\n#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV)\n#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV)\n#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV)\n#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV)\n#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV)\n#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV)\n#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV)\n#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV)\n#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV)\n#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV)\n#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV)\n#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV)\n#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV)\n#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV)\n#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV)\n#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV)\n#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV)\n#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV)\n#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV)\n#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV)\n#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV)\n#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV)\n#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV)\n#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV)\n#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV)\n#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV)\n#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV)\n#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV)\n#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV)\n#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV)\n#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV)\n#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV)\n#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV)\n#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV)\n#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV)\n#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV)\n#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV)\n#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV)\n#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV)\n#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV)\n#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV)\n#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV)\n#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV)\n#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV)\n#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV)\n#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV)\n#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV)\n#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV)\n#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV)\n#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV)\n#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV)\n#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV)\n#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV)\n#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV)\n#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV)\n#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV)\n#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV)\n\n#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program)\n\n#endif /* GL_NV_vertex_program */\n\n/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */\n\n#ifndef GL_NV_vertex_program1_1\n#define GL_NV_vertex_program1_1 1\n\n#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1)\n\n#endif /* GL_NV_vertex_program1_1 */\n\n/* ------------------------- GL_NV_vertex_program2 ------------------------- */\n\n#ifndef GL_NV_vertex_program2\n#define GL_NV_vertex_program2 1\n\n#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2)\n\n#endif /* GL_NV_vertex_program2 */\n\n/* ---------------------- GL_NV_vertex_program2_option --------------------- */\n\n#ifndef GL_NV_vertex_program2_option\n#define GL_NV_vertex_program2_option 1\n\n#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4\n#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5\n\n#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option)\n\n#endif /* GL_NV_vertex_program2_option */\n\n/* ------------------------- GL_NV_vertex_program3 ------------------------- */\n\n#ifndef GL_NV_vertex_program3\n#define GL_NV_vertex_program3 1\n\n#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C\n\n#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3)\n\n#endif /* GL_NV_vertex_program3 */\n\n/* ------------------------- GL_NV_vertex_program4 ------------------------- */\n\n#ifndef GL_NV_vertex_program4\n#define GL_NV_vertex_program4 1\n\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD\n\n#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4)\n\n#endif /* GL_NV_vertex_program4 */\n\n/* -------------------------- GL_NV_video_capture -------------------------- */\n\n#ifndef GL_NV_video_capture\n#define GL_NV_video_capture 1\n\n#define GL_VIDEO_BUFFER_NV 0x9020\n#define GL_VIDEO_BUFFER_BINDING_NV 0x9021\n#define GL_FIELD_UPPER_NV 0x9022\n#define GL_FIELD_LOWER_NV 0x9023\n#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024\n#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025\n#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026\n#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027\n#define GL_VIDEO_BUFFER_PITCH_NV 0x9028\n#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029\n#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A\n#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B\n#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C\n#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D\n#define GL_PARTIAL_SUCCESS_NV 0x902E\n#define GL_SUCCESS_NV 0x902F\n#define GL_FAILURE_NV 0x9030\n#define GL_YCBYCR8_422_NV 0x9031\n#define GL_YCBAYCR8A_4224_NV 0x9032\n#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033\n#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034\n#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035\n#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036\n#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037\n#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038\n#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039\n#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A\n#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B\n#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C\n\ntypedef void (GLAPIENTRY * PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\ntypedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);\ntypedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);\ntypedef void (GLAPIENTRY * PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint* params);\ntypedef GLenum (GLAPIENTRY * PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint* sequence_num, GLuint64EXT *capture_time);\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params);\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params);\n\n#define glBeginVideoCaptureNV GLEW_GET_FUN(__glewBeginVideoCaptureNV)\n#define glBindVideoCaptureStreamBufferNV GLEW_GET_FUN(__glewBindVideoCaptureStreamBufferNV)\n#define glBindVideoCaptureStreamTextureNV GLEW_GET_FUN(__glewBindVideoCaptureStreamTextureNV)\n#define glEndVideoCaptureNV GLEW_GET_FUN(__glewEndVideoCaptureNV)\n#define glGetVideoCaptureStreamdvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamdvNV)\n#define glGetVideoCaptureStreamfvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamfvNV)\n#define glGetVideoCaptureStreamivNV GLEW_GET_FUN(__glewGetVideoCaptureStreamivNV)\n#define glGetVideoCaptureivNV GLEW_GET_FUN(__glewGetVideoCaptureivNV)\n#define glVideoCaptureNV GLEW_GET_FUN(__glewVideoCaptureNV)\n#define glVideoCaptureStreamParameterdvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterdvNV)\n#define glVideoCaptureStreamParameterfvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterfvNV)\n#define glVideoCaptureStreamParameterivNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterivNV)\n\n#define GLEW_NV_video_capture GLEW_GET_VAR(__GLEW_NV_video_capture)\n\n#endif /* GL_NV_video_capture */\n\n/* ------------------------ GL_OES_byte_coordinates ------------------------ */\n\n#ifndef GL_OES_byte_coordinates\n#define GL_OES_byte_coordinates 1\n\n#define GL_BYTE 0x1400\n\n#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates)\n\n#endif /* GL_OES_byte_coordinates */\n\n/* ------------------- GL_OES_compressed_paletted_texture ------------------ */\n\n#ifndef GL_OES_compressed_paletted_texture\n#define GL_OES_compressed_paletted_texture 1\n\n#define GL_PALETTE4_RGB8_OES 0x8B90\n#define GL_PALETTE4_RGBA8_OES 0x8B91\n#define GL_PALETTE4_R5_G6_B5_OES 0x8B92\n#define GL_PALETTE4_RGBA4_OES 0x8B93\n#define GL_PALETTE4_RGB5_A1_OES 0x8B94\n#define GL_PALETTE8_RGB8_OES 0x8B95\n#define GL_PALETTE8_RGBA8_OES 0x8B96\n#define GL_PALETTE8_R5_G6_B5_OES 0x8B97\n#define GL_PALETTE8_RGBA4_OES 0x8B98\n#define GL_PALETTE8_RGB5_A1_OES 0x8B99\n\n#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture)\n\n#endif /* GL_OES_compressed_paletted_texture */\n\n/* --------------------------- GL_OES_read_format -------------------------- */\n\n#ifndef GL_OES_read_format\n#define GL_OES_read_format 1\n\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B\n\n#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format)\n\n#endif /* GL_OES_read_format */\n\n/* ------------------------ GL_OES_single_precision ------------------------ */\n\n#ifndef GL_OES_single_precision\n#define GL_OES_single_precision 1\n\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth);\ntypedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation);\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f);\ntypedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\ntypedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation);\ntypedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\n\n#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES)\n#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES)\n#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES)\n#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES)\n#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES)\n#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES)\n\n#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision)\n\n#endif /* GL_OES_single_precision */\n\n/* ---------------------------- GL_OML_interlace --------------------------- */\n\n#ifndef GL_OML_interlace\n#define GL_OML_interlace 1\n\n#define GL_INTERLACE_OML 0x8980\n#define GL_INTERLACE_READ_OML 0x8981\n\n#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace)\n\n#endif /* GL_OML_interlace */\n\n/* ---------------------------- GL_OML_resample ---------------------------- */\n\n#ifndef GL_OML_resample\n#define GL_OML_resample 1\n\n#define GL_PACK_RESAMPLE_OML 0x8984\n#define GL_UNPACK_RESAMPLE_OML 0x8985\n#define GL_RESAMPLE_REPLICATE_OML 0x8986\n#define GL_RESAMPLE_ZERO_FILL_OML 0x8987\n#define GL_RESAMPLE_AVERAGE_OML 0x8988\n#define GL_RESAMPLE_DECIMATE_OML 0x8989\n\n#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample)\n\n#endif /* GL_OML_resample */\n\n/* ---------------------------- GL_OML_subsample --------------------------- */\n\n#ifndef GL_OML_subsample\n#define GL_OML_subsample 1\n\n#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982\n#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983\n\n#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample)\n\n#endif /* GL_OML_subsample */\n\n/* --------------------------- GL_PGI_misc_hints --------------------------- */\n\n#ifndef GL_PGI_misc_hints\n#define GL_PGI_misc_hints 1\n\n#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000\n#define GL_CONSERVE_MEMORY_HINT_PGI 107005\n#define GL_RECLAIM_MEMORY_HINT_PGI 107006\n#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010\n#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011\n#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012\n#define GL_ALWAYS_FAST_HINT_PGI 107020\n#define GL_ALWAYS_SOFT_HINT_PGI 107021\n#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022\n#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023\n#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024\n#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025\n#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030\n#define GL_STRICT_LIGHTING_HINT_PGI 107031\n#define GL_STRICT_SCISSOR_HINT_PGI 107032\n#define GL_FULL_STIPPLE_HINT_PGI 107033\n#define GL_CLIP_NEAR_HINT_PGI 107040\n#define GL_CLIP_FAR_HINT_PGI 107041\n#define GL_WIDE_LINE_HINT_PGI 107042\n#define GL_BACK_NORMALS_HINT_PGI 107043\n\n#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints)\n\n#endif /* GL_PGI_misc_hints */\n\n/* -------------------------- GL_PGI_vertex_hints -------------------------- */\n\n#ifndef GL_PGI_vertex_hints\n#define GL_PGI_vertex_hints 1\n\n#define GL_VERTEX23_BIT_PGI 0x00000004\n#define GL_VERTEX4_BIT_PGI 0x00000008\n#define GL_COLOR3_BIT_PGI 0x00010000\n#define GL_COLOR4_BIT_PGI 0x00020000\n#define GL_EDGEFLAG_BIT_PGI 0x00040000\n#define GL_INDEX_BIT_PGI 0x00080000\n#define GL_MAT_AMBIENT_BIT_PGI 0x00100000\n#define GL_VERTEX_DATA_HINT_PGI 107050\n#define GL_VERTEX_CONSISTENT_HINT_PGI 107051\n#define GL_MATERIAL_SIDE_HINT_PGI 107052\n#define GL_MAX_VERTEX_HINT_PGI 107053\n#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000\n#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000\n#define GL_MAT_EMISSION_BIT_PGI 0x00800000\n#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000\n#define GL_MAT_SHININESS_BIT_PGI 0x02000000\n#define GL_MAT_SPECULAR_BIT_PGI 0x04000000\n#define GL_NORMAL_BIT_PGI 0x08000000\n#define GL_TEXCOORD1_BIT_PGI 0x10000000\n#define GL_TEXCOORD2_BIT_PGI 0x20000000\n#define GL_TEXCOORD3_BIT_PGI 0x40000000\n#define GL_TEXCOORD4_BIT_PGI 0x80000000\n\n#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints)\n\n#endif /* GL_PGI_vertex_hints */\n\n/* ------------------------- GL_REGAL_error_string ------------------------- */\n\n#ifndef GL_REGAL_error_string\n#define GL_REGAL_error_string 1\n\ntypedef const GLchar* (GLAPIENTRY * PFNGLERRORSTRINGREGALPROC) (GLenum error);\n\n#define glErrorStringREGAL GLEW_GET_FUN(__glewErrorStringREGAL)\n\n#define GLEW_REGAL_error_string GLEW_GET_VAR(__GLEW_REGAL_error_string)\n\n#endif /* GL_REGAL_error_string */\n\n/* ------------------------ GL_REGAL_extension_query ----------------------- */\n\n#ifndef GL_REGAL_extension_query\n#define GL_REGAL_extension_query 1\n\ntypedef GLboolean (GLAPIENTRY * PFNGLGETEXTENSIONREGALPROC) (const GLchar* ext);\ntypedef GLboolean (GLAPIENTRY * PFNGLISSUPPORTEDREGALPROC) (const GLchar* ext);\n\n#define glGetExtensionREGAL GLEW_GET_FUN(__glewGetExtensionREGAL)\n#define glIsSupportedREGAL GLEW_GET_FUN(__glewIsSupportedREGAL)\n\n#define GLEW_REGAL_extension_query GLEW_GET_VAR(__GLEW_REGAL_extension_query)\n\n#endif /* GL_REGAL_extension_query */\n\n/* ------------------------------ GL_REGAL_log ----------------------------- */\n\n#ifndef GL_REGAL_log\n#define GL_REGAL_log 1\n\n#define GL_LOG_ERROR_REGAL 0x9319\n#define GL_LOG_WARNING_REGAL 0x931A\n#define GL_LOG_INFO_REGAL 0x931B\n#define GL_LOG_APP_REGAL 0x931C\n#define GL_LOG_DRIVER_REGAL 0x931D\n#define GL_LOG_INTERNAL_REGAL 0x931E\n#define GL_LOG_DEBUG_REGAL 0x931F\n#define GL_LOG_STATUS_REGAL 0x9320\n#define GL_LOG_HTTP_REGAL 0x9321\n\n#define GLEW_REGAL_log GLEW_GET_VAR(__GLEW_REGAL_log)\n\n#endif /* GL_REGAL_log */\n\n/* ----------------------- GL_REND_screen_coordinates ---------------------- */\n\n#ifndef GL_REND_screen_coordinates\n#define GL_REND_screen_coordinates 1\n\n#define GL_SCREEN_COORDINATES_REND 0x8490\n#define GL_INVERTED_SCREEN_W_REND 0x8491\n\n#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates)\n\n#endif /* GL_REND_screen_coordinates */\n\n/* ------------------------------- GL_S3_s3tc ------------------------------ */\n\n#ifndef GL_S3_s3tc\n#define GL_S3_s3tc 1\n\n#define GL_RGB_S3TC 0x83A0\n#define GL_RGB4_S3TC 0x83A1\n#define GL_RGBA_S3TC 0x83A2\n#define GL_RGBA4_S3TC 0x83A3\n#define GL_RGBA_DXT5_S3TC 0x83A4\n#define GL_RGBA4_DXT5_S3TC 0x83A5\n\n#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc)\n\n#endif /* GL_S3_s3tc */\n\n/* -------------------------- GL_SGIS_color_range -------------------------- */\n\n#ifndef GL_SGIS_color_range\n#define GL_SGIS_color_range 1\n\n#define GL_EXTENDED_RANGE_SGIS 0x85A5\n#define GL_MIN_RED_SGIS 0x85A6\n#define GL_MAX_RED_SGIS 0x85A7\n#define GL_MIN_GREEN_SGIS 0x85A8\n#define GL_MAX_GREEN_SGIS 0x85A9\n#define GL_MIN_BLUE_SGIS 0x85AA\n#define GL_MAX_BLUE_SGIS 0x85AB\n#define GL_MIN_ALPHA_SGIS 0x85AC\n#define GL_MAX_ALPHA_SGIS 0x85AD\n\n#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range)\n\n#endif /* GL_SGIS_color_range */\n\n/* ------------------------- GL_SGIS_detail_texture ------------------------ */\n\n#ifndef GL_SGIS_detail_texture\n#define GL_SGIS_detail_texture 1\n\ntypedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points);\ntypedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points);\n\n#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS)\n#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS)\n\n#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture)\n\n#endif /* GL_SGIS_detail_texture */\n\n/* -------------------------- GL_SGIS_fog_function ------------------------- */\n\n#ifndef GL_SGIS_fog_function\n#define GL_SGIS_fog_function 1\n\ntypedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points);\ntypedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points);\n\n#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS)\n#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS)\n\n#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function)\n\n#endif /* GL_SGIS_fog_function */\n\n/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */\n\n#ifndef GL_SGIS_generate_mipmap\n#define GL_SGIS_generate_mipmap 1\n\n#define GL_GENERATE_MIPMAP_SGIS 0x8191\n#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192\n\n#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap)\n\n#endif /* GL_SGIS_generate_mipmap */\n\n/* -------------------------- GL_SGIS_multisample -------------------------- */\n\n#ifndef GL_SGIS_multisample\n#define GL_SGIS_multisample 1\n\n#define GL_MULTISAMPLE_SGIS 0x809D\n#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F\n#define GL_SAMPLE_MASK_SGIS 0x80A0\n#define GL_1PASS_SGIS 0x80A1\n#define GL_2PASS_0_SGIS 0x80A2\n#define GL_2PASS_1_SGIS 0x80A3\n#define GL_4PASS_0_SGIS 0x80A4\n#define GL_4PASS_1_SGIS 0x80A5\n#define GL_4PASS_2_SGIS 0x80A6\n#define GL_4PASS_3_SGIS 0x80A7\n#define GL_SAMPLE_BUFFERS_SGIS 0x80A8\n#define GL_SAMPLES_SGIS 0x80A9\n#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA\n#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB\n#define GL_SAMPLE_PATTERN_SGIS 0x80AC\n\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);\ntypedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);\n\n#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS)\n#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS)\n\n#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample)\n\n#endif /* GL_SGIS_multisample */\n\n/* ------------------------- GL_SGIS_pixel_texture ------------------------- */\n\n#ifndef GL_SGIS_pixel_texture\n#define GL_SGIS_pixel_texture 1\n\n#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture)\n\n#endif /* GL_SGIS_pixel_texture */\n\n/* ----------------------- GL_SGIS_point_line_texgen ----------------------- */\n\n#ifndef GL_SGIS_point_line_texgen\n#define GL_SGIS_point_line_texgen 1\n\n#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0\n#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1\n#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2\n#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3\n#define GL_EYE_POINT_SGIS 0x81F4\n#define GL_OBJECT_POINT_SGIS 0x81F5\n#define GL_EYE_LINE_SGIS 0x81F6\n#define GL_OBJECT_LINE_SGIS 0x81F7\n\n#define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen)\n\n#endif /* GL_SGIS_point_line_texgen */\n\n/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */\n\n#ifndef GL_SGIS_sharpen_texture\n#define GL_SGIS_sharpen_texture 1\n\ntypedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points);\ntypedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points);\n\n#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS)\n#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS)\n\n#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture)\n\n#endif /* GL_SGIS_sharpen_texture */\n\n/* --------------------------- GL_SGIS_texture4D --------------------------- */\n\n#ifndef GL_SGIS_texture4D\n#define GL_SGIS_texture4D 1\n\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels);\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels);\n\n#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS)\n#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS)\n\n#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D)\n\n#endif /* GL_SGIS_texture4D */\n\n/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */\n\n#ifndef GL_SGIS_texture_border_clamp\n#define GL_SGIS_texture_border_clamp 1\n\n#define GL_CLAMP_TO_BORDER_SGIS 0x812D\n\n#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp)\n\n#endif /* GL_SGIS_texture_border_clamp */\n\n/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */\n\n#ifndef GL_SGIS_texture_edge_clamp\n#define GL_SGIS_texture_edge_clamp 1\n\n#define GL_CLAMP_TO_EDGE_SGIS 0x812F\n\n#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp)\n\n#endif /* GL_SGIS_texture_edge_clamp */\n\n/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */\n\n#ifndef GL_SGIS_texture_filter4\n#define GL_SGIS_texture_filter4 1\n\ntypedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights);\ntypedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights);\n\n#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS)\n#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS)\n\n#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4)\n\n#endif /* GL_SGIS_texture_filter4 */\n\n/* -------------------------- GL_SGIS_texture_lod -------------------------- */\n\n#ifndef GL_SGIS_texture_lod\n#define GL_SGIS_texture_lod 1\n\n#define GL_TEXTURE_MIN_LOD_SGIS 0x813A\n#define GL_TEXTURE_MAX_LOD_SGIS 0x813B\n#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C\n#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D\n\n#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod)\n\n#endif /* GL_SGIS_texture_lod */\n\n/* ------------------------- GL_SGIS_texture_select ------------------------ */\n\n#ifndef GL_SGIS_texture_select\n#define GL_SGIS_texture_select 1\n\n#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select)\n\n#endif /* GL_SGIS_texture_select */\n\n/* ----------------------------- GL_SGIX_async ----------------------------- */\n\n#ifndef GL_SGIX_async\n#define GL_SGIX_async 1\n\n#define GL_ASYNC_MARKER_SGIX 0x8329\n\ntypedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker);\ntypedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);\ntypedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp);\ntypedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);\ntypedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);\ntypedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp);\n\n#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX)\n#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX)\n#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX)\n#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX)\n#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX)\n#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX)\n\n#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async)\n\n#endif /* GL_SGIX_async */\n\n/* ------------------------ GL_SGIX_async_histogram ------------------------ */\n\n#ifndef GL_SGIX_async_histogram\n#define GL_SGIX_async_histogram 1\n\n#define GL_ASYNC_HISTOGRAM_SGIX 0x832C\n#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D\n\n#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram)\n\n#endif /* GL_SGIX_async_histogram */\n\n/* -------------------------- GL_SGIX_async_pixel -------------------------- */\n\n#ifndef GL_SGIX_async_pixel\n#define GL_SGIX_async_pixel 1\n\n#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C\n#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D\n#define GL_ASYNC_READ_PIXELS_SGIX 0x835E\n#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F\n#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360\n#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361\n\n#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel)\n\n#endif /* GL_SGIX_async_pixel */\n\n/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */\n\n#ifndef GL_SGIX_blend_alpha_minmax\n#define GL_SGIX_blend_alpha_minmax 1\n\n#define GL_ALPHA_MIN_SGIX 0x8320\n#define GL_ALPHA_MAX_SGIX 0x8321\n\n#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax)\n\n#endif /* GL_SGIX_blend_alpha_minmax */\n\n/* ---------------------------- GL_SGIX_clipmap ---------------------------- */\n\n#ifndef GL_SGIX_clipmap\n#define GL_SGIX_clipmap 1\n\n#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap)\n\n#endif /* GL_SGIX_clipmap */\n\n/* ---------------------- GL_SGIX_convolution_accuracy --------------------- */\n\n#ifndef GL_SGIX_convolution_accuracy\n#define GL_SGIX_convolution_accuracy 1\n\n#define GL_CONVOLUTION_HINT_SGIX 0x8316\n\n#define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy)\n\n#endif /* GL_SGIX_convolution_accuracy */\n\n/* ------------------------- GL_SGIX_depth_texture ------------------------- */\n\n#ifndef GL_SGIX_depth_texture\n#define GL_SGIX_depth_texture 1\n\n#define GL_DEPTH_COMPONENT16_SGIX 0x81A5\n#define GL_DEPTH_COMPONENT24_SGIX 0x81A6\n#define GL_DEPTH_COMPONENT32_SGIX 0x81A7\n\n#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture)\n\n#endif /* GL_SGIX_depth_texture */\n\n/* -------------------------- GL_SGIX_flush_raster ------------------------- */\n\n#ifndef GL_SGIX_flush_raster\n#define GL_SGIX_flush_raster 1\n\ntypedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void);\n\n#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX)\n\n#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster)\n\n#endif /* GL_SGIX_flush_raster */\n\n/* --------------------------- GL_SGIX_fog_offset -------------------------- */\n\n#ifndef GL_SGIX_fog_offset\n#define GL_SGIX_fog_offset 1\n\n#define GL_FOG_OFFSET_SGIX 0x8198\n#define GL_FOG_OFFSET_VALUE_SGIX 0x8199\n\n#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset)\n\n#endif /* GL_SGIX_fog_offset */\n\n/* -------------------------- GL_SGIX_fog_texture -------------------------- */\n\n#ifndef GL_SGIX_fog_texture\n#define GL_SGIX_fog_texture 1\n\n#define GL_TEXTURE_FOG_SGIX 0\n#define GL_FOG_PATCHY_FACTOR_SGIX 0\n#define GL_FRAGMENT_FOG_SGIX 0\n\ntypedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname);\n\n#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX)\n\n#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture)\n\n#endif /* GL_SGIX_fog_texture */\n\n/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */\n\n#ifndef GL_SGIX_fragment_specular_lighting\n#define GL_SGIX_fragment_specular_lighting 1\n\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param);\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data);\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data);\n\n#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX)\n#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX)\n#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX)\n#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX)\n#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX)\n#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX)\n#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX)\n#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX)\n#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX)\n#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX)\n#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX)\n#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX)\n#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX)\n#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX)\n#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX)\n#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX)\n#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX)\n\n#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting)\n\n#endif /* GL_SGIX_fragment_specular_lighting */\n\n/* --------------------------- GL_SGIX_framezoom --------------------------- */\n\n#ifndef GL_SGIX_framezoom\n#define GL_SGIX_framezoom 1\n\ntypedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor);\n\n#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX)\n\n#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom)\n\n#endif /* GL_SGIX_framezoom */\n\n/* --------------------------- GL_SGIX_interlace --------------------------- */\n\n#ifndef GL_SGIX_interlace\n#define GL_SGIX_interlace 1\n\n#define GL_INTERLACE_SGIX 0x8094\n\n#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace)\n\n#endif /* GL_SGIX_interlace */\n\n/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */\n\n#ifndef GL_SGIX_ir_instrument1\n#define GL_SGIX_ir_instrument1 1\n\n#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1)\n\n#endif /* GL_SGIX_ir_instrument1 */\n\n/* ------------------------- GL_SGIX_list_priority ------------------------- */\n\n#ifndef GL_SGIX_list_priority\n#define GL_SGIX_list_priority 1\n\n#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority)\n\n#endif /* GL_SGIX_list_priority */\n\n/* ------------------------- GL_SGIX_pixel_texture ------------------------- */\n\n#ifndef GL_SGIX_pixel_texture\n#define GL_SGIX_pixel_texture 1\n\ntypedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);\n\n#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX)\n\n#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture)\n\n#endif /* GL_SGIX_pixel_texture */\n\n/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */\n\n#ifndef GL_SGIX_pixel_texture_bits\n#define GL_SGIX_pixel_texture_bits 1\n\n#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits)\n\n#endif /* GL_SGIX_pixel_texture_bits */\n\n/* ------------------------ GL_SGIX_reference_plane ------------------------ */\n\n#ifndef GL_SGIX_reference_plane\n#define GL_SGIX_reference_plane 1\n\ntypedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation);\n\n#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX)\n\n#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane)\n\n#endif /* GL_SGIX_reference_plane */\n\n/* ---------------------------- GL_SGIX_resample --------------------------- */\n\n#ifndef GL_SGIX_resample\n#define GL_SGIX_resample 1\n\n#define GL_PACK_RESAMPLE_SGIX 0x842E\n#define GL_UNPACK_RESAMPLE_SGIX 0x842F\n#define GL_RESAMPLE_DECIMATE_SGIX 0x8430\n#define GL_RESAMPLE_REPLICATE_SGIX 0x8433\n#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434\n\n#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample)\n\n#endif /* GL_SGIX_resample */\n\n/* ----------------------------- GL_SGIX_shadow ---------------------------- */\n\n#ifndef GL_SGIX_shadow\n#define GL_SGIX_shadow 1\n\n#define GL_TEXTURE_COMPARE_SGIX 0x819A\n#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B\n#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C\n#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D\n\n#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow)\n\n#endif /* GL_SGIX_shadow */\n\n/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */\n\n#ifndef GL_SGIX_shadow_ambient\n#define GL_SGIX_shadow_ambient 1\n\n#define GL_SHADOW_AMBIENT_SGIX 0x80BF\n\n#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient)\n\n#endif /* GL_SGIX_shadow_ambient */\n\n/* ----------------------------- GL_SGIX_sprite ---------------------------- */\n\n#ifndef GL_SGIX_sprite\n#define GL_SGIX_sprite 1\n\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params);\n\n#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX)\n#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX)\n#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX)\n#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX)\n\n#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite)\n\n#endif /* GL_SGIX_sprite */\n\n/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */\n\n#ifndef GL_SGIX_tag_sample_buffer\n#define GL_SGIX_tag_sample_buffer 1\n\ntypedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);\n\n#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX)\n\n#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer)\n\n#endif /* GL_SGIX_tag_sample_buffer */\n\n/* ------------------------ GL_SGIX_texture_add_env ------------------------ */\n\n#ifndef GL_SGIX_texture_add_env\n#define GL_SGIX_texture_add_env 1\n\n#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env)\n\n#endif /* GL_SGIX_texture_add_env */\n\n/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */\n\n#ifndef GL_SGIX_texture_coordinate_clamp\n#define GL_SGIX_texture_coordinate_clamp 1\n\n#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369\n#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A\n#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B\n\n#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp)\n\n#endif /* GL_SGIX_texture_coordinate_clamp */\n\n/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */\n\n#ifndef GL_SGIX_texture_lod_bias\n#define GL_SGIX_texture_lod_bias 1\n\n#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias)\n\n#endif /* GL_SGIX_texture_lod_bias */\n\n/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */\n\n#ifndef GL_SGIX_texture_multi_buffer\n#define GL_SGIX_texture_multi_buffer 1\n\n#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E\n\n#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer)\n\n#endif /* GL_SGIX_texture_multi_buffer */\n\n/* ------------------------- GL_SGIX_texture_range ------------------------- */\n\n#ifndef GL_SGIX_texture_range\n#define GL_SGIX_texture_range 1\n\n#define GL_RGB_SIGNED_SGIX 0x85E0\n#define GL_RGBA_SIGNED_SGIX 0x85E1\n#define GL_ALPHA_SIGNED_SGIX 0x85E2\n#define GL_LUMINANCE_SIGNED_SGIX 0x85E3\n#define GL_INTENSITY_SIGNED_SGIX 0x85E4\n#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5\n#define GL_RGB16_SIGNED_SGIX 0x85E6\n#define GL_RGBA16_SIGNED_SGIX 0x85E7\n#define GL_ALPHA16_SIGNED_SGIX 0x85E8\n#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9\n#define GL_INTENSITY16_SIGNED_SGIX 0x85EA\n#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB\n#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC\n#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED\n#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE\n#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF\n#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0\n#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1\n#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2\n#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3\n#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4\n#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5\n#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6\n#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7\n#define GL_MIN_LUMINANCE_SGIS 0x85F8\n#define GL_MAX_LUMINANCE_SGIS 0x85F9\n#define GL_MIN_INTENSITY_SGIS 0x85FA\n#define GL_MAX_INTENSITY_SGIS 0x85FB\n\n#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range)\n\n#endif /* GL_SGIX_texture_range */\n\n/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */\n\n#ifndef GL_SGIX_texture_scale_bias\n#define GL_SGIX_texture_scale_bias 1\n\n#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179\n#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A\n#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B\n#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C\n\n#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias)\n\n#endif /* GL_SGIX_texture_scale_bias */\n\n/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */\n\n#ifndef GL_SGIX_vertex_preclip\n#define GL_SGIX_vertex_preclip 1\n\n#define GL_VERTEX_PRECLIP_SGIX 0x83EE\n#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF\n\n#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip)\n\n#endif /* GL_SGIX_vertex_preclip */\n\n/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */\n\n#ifndef GL_SGIX_vertex_preclip_hint\n#define GL_SGIX_vertex_preclip_hint 1\n\n#define GL_VERTEX_PRECLIP_SGIX 0x83EE\n#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF\n\n#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint)\n\n#endif /* GL_SGIX_vertex_preclip_hint */\n\n/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */\n\n#ifndef GL_SGIX_ycrcb\n#define GL_SGIX_ycrcb 1\n\n#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb)\n\n#endif /* GL_SGIX_ycrcb */\n\n/* -------------------------- GL_SGI_color_matrix -------------------------- */\n\n#ifndef GL_SGI_color_matrix\n#define GL_SGI_color_matrix 1\n\n#define GL_COLOR_MATRIX_SGI 0x80B1\n#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3\n#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7\n#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB\n\n#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix)\n\n#endif /* GL_SGI_color_matrix */\n\n/* --------------------------- GL_SGI_color_table -------------------------- */\n\n#ifndef GL_SGI_color_table\n#define GL_SGI_color_table 1\n\n#define GL_COLOR_TABLE_SGI 0x80D0\n#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2\n#define GL_PROXY_COLOR_TABLE_SGI 0x80D3\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5\n#define GL_COLOR_TABLE_SCALE_SGI 0x80D6\n#define GL_COLOR_TABLE_BIAS_SGI 0x80D7\n#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8\n#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9\n#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA\n#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB\n#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC\n#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD\n#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE\n#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF\n\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params);\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table);\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params);\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table);\n\n#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI)\n#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI)\n#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI)\n#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI)\n#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI)\n#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI)\n#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI)\n\n#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table)\n\n#endif /* GL_SGI_color_table */\n\n/* ----------------------- GL_SGI_texture_color_table ---------------------- */\n\n#ifndef GL_SGI_texture_color_table\n#define GL_SGI_texture_color_table 1\n\n#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC\n#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD\n\n#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table)\n\n#endif /* GL_SGI_texture_color_table */\n\n/* ------------------------- GL_SUNX_constant_data ------------------------- */\n\n#ifndef GL_SUNX_constant_data\n#define GL_SUNX_constant_data 1\n\n#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5\n#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6\n\ntypedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void);\n\n#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX)\n\n#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data)\n\n#endif /* GL_SUNX_constant_data */\n\n/* -------------------- GL_SUN_convolution_border_modes -------------------- */\n\n#ifndef GL_SUN_convolution_border_modes\n#define GL_SUN_convolution_border_modes 1\n\n#define GL_WRAP_BORDER_SUN 0x81D4\n\n#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes)\n\n#endif /* GL_SUN_convolution_border_modes */\n\n/* -------------------------- GL_SUN_global_alpha -------------------------- */\n\n#ifndef GL_SUN_global_alpha\n#define GL_SUN_global_alpha 1\n\n#define GL_GLOBAL_ALPHA_SUN 0x81D9\n#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA\n\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);\n\n#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN)\n#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN)\n#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN)\n#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN)\n#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN)\n#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN)\n#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN)\n#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN)\n\n#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha)\n\n#endif /* GL_SUN_global_alpha */\n\n/* --------------------------- GL_SUN_mesh_array --------------------------- */\n\n#ifndef GL_SUN_mesh_array\n#define GL_SUN_mesh_array 1\n\n#define GL_QUAD_MESH_SUN 0x8614\n#define GL_TRIANGLE_MESH_SUN 0x8615\n\n#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array)\n\n#endif /* GL_SUN_mesh_array */\n\n/* ------------------------ GL_SUN_read_video_pixels ----------------------- */\n\n#ifndef GL_SUN_read_video_pixels\n#define GL_SUN_read_video_pixels 1\n\ntypedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);\n\n#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN)\n\n#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels)\n\n#endif /* GL_SUN_read_video_pixels */\n\n/* --------------------------- GL_SUN_slice_accum -------------------------- */\n\n#ifndef GL_SUN_slice_accum\n#define GL_SUN_slice_accum 1\n\n#define GL_SLICE_ACCUM_SUN 0x85CC\n\n#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum)\n\n#endif /* GL_SUN_slice_accum */\n\n/* -------------------------- GL_SUN_triangle_list ------------------------- */\n\n#ifndef GL_SUN_triangle_list\n#define GL_SUN_triangle_list 1\n\n#define GL_RESTART_SUN 0x01\n#define GL_REPLACE_MIDDLE_SUN 0x02\n#define GL_REPLACE_OLDEST_SUN 0x03\n#define GL_TRIANGLE_LIST_SUN 0x81D7\n#define GL_REPLACEMENT_CODE_SUN 0x81D8\n#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0\n#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1\n#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2\n#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3\n#define GL_R1UI_V3F_SUN 0x85C4\n#define GL_R1UI_C4UB_V3F_SUN 0x85C5\n#define GL_R1UI_C3F_V3F_SUN 0x85C6\n#define GL_R1UI_N3F_V3F_SUN 0x85C7\n#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8\n#define GL_R1UI_T2F_V3F_SUN 0x85C9\n#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA\n#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB\n\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code);\n\n#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN)\n#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN)\n#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN)\n#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN)\n#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN)\n#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN)\n#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN)\n\n#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list)\n\n#endif /* GL_SUN_triangle_list */\n\n/* ----------------------------- GL_SUN_vertex ----------------------------- */\n\n#ifndef GL_SUN_vertex\n#define GL_SUN_vertex 1\n\ntypedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v);\n\n#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN)\n#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN)\n#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN)\n#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN)\n#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN)\n#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN)\n#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN)\n#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN)\n#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN)\n#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN)\n#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN)\n#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN)\n#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN)\n#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN)\n#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN)\n#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN)\n#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN)\n#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN)\n#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN)\n#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN)\n#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN)\n#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN)\n#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN)\n#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN)\n#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN)\n#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN)\n#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN)\n#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN)\n#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN)\n#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN)\n#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN)\n#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN)\n#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN)\n#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN)\n#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN)\n#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN)\n#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN)\n#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN)\n#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN)\n#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN)\n\n#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex)\n\n#endif /* GL_SUN_vertex */\n\n/* -------------------------- GL_WIN_phong_shading ------------------------- */\n\n#ifndef GL_WIN_phong_shading\n#define GL_WIN_phong_shading 1\n\n#define GL_PHONG_WIN 0x80EA\n#define GL_PHONG_HINT_WIN 0x80EB\n\n#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading)\n\n#endif /* GL_WIN_phong_shading */\n\n/* -------------------------- GL_WIN_specular_fog -------------------------- */\n\n#ifndef GL_WIN_specular_fog\n#define GL_WIN_specular_fog 1\n\n#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC\n\n#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog)\n\n#endif /* GL_WIN_specular_fog */\n\n/* ---------------------------- GL_WIN_swap_hint --------------------------- */\n\n#ifndef GL_WIN_swap_hint\n#define GL_WIN_swap_hint 1\n\ntypedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height);\n\n#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN)\n\n#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint)\n\n#endif /* GL_WIN_swap_hint */\n\n/* ------------------------------------------------------------------------- */\n\n#if defined(GLEW_MX) && defined(_WIN32)\n#define GLEW_FUN_EXPORT\n#else\n#define GLEW_FUN_EXPORT GLEWAPI\n#endif /* GLEW_MX */\n\n#if defined(GLEW_MX)\n#define GLEW_VAR_EXPORT\n#else\n#define GLEW_VAR_EXPORT GLEWAPI\n#endif /* GLEW_MX */\n\n#if defined(GLEW_MX) && defined(_WIN32)\nstruct GLEWContextStruct\n{\n#endif /* GLEW_MX */\n\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D;\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements;\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D;\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D;\n\nGLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture;\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D;\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage;\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd;\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf;\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd;\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv;\nGLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage;\n\nGLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor;\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate;\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer;\nGLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd;\nGLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv;\nGLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf;\nGLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv;\n\nGLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer;\nGLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData;\nGLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData;\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers;\nGLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries;\nGLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery;\nGLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers;\nGLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries;\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv;\nGLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv;\nGLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv;\nGLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv;\nGLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer;\nGLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery;\nGLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer;\nGLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer;\n\nGLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader;\nGLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation;\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate;\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader;\nGLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram;\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader;\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram;\nGLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader;\nGLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader;\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray;\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers;\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray;\nGLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform;\nGLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders;\nGLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv;\nGLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog;\nGLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource;\nGLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv;\nGLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram;\nGLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader;\nGLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram;\nGLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource;\nGLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate;\nGLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate;\nGLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate;\nGLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f;\nGLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv;\nGLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i;\nGLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv;\nGLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f;\nGLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv;\nGLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i;\nGLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv;\nGLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f;\nGLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv;\nGLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i;\nGLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv;\nGLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f;\nGLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv;\nGLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i;\nGLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv;\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram;\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer;\n\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv;\n\nGLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender;\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback;\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation;\nGLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor;\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi;\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv;\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv;\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv;\nGLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski;\nGLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei;\nGLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei;\nGLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender;\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback;\nGLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v;\nGLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation;\nGLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi;\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv;\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv;\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv;\nGLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi;\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv;\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv;\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer;\n\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced;\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex;\nGLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer;\n\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture;\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v;\nGLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v;\n\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor;\n\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei;\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci;\nGLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading;\n\nGLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX;\n\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD;\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD;\n\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD;\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD;\n\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD;\n\nGLEW_FUN_EXPORT PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD;\nGLEW_FUN_EXPORT PFNGLGENNAMESAMDPROC __glewGenNamesAMD;\nGLEW_FUN_EXPORT PFNGLISNAMEAMDPROC __glewIsNameAMD;\n\nGLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD;\nGLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD;\nGLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD;\nGLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD;\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD;\nGLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD;\n\nGLEW_FUN_EXPORT PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD;\n\nGLEW_FUN_EXPORT PFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD;\n\nGLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD;\nGLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD;\n\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE;\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE;\nGLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE;\n\nGLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE;\nGLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE;\nGLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE;\nGLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE;\nGLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE;\nGLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE;\nGLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE;\nGLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE;\n\nGLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE;\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE;\n\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE;\nGLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE;\nGLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE;\n\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE;\nGLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE;\n\nGLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE;\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE;\nGLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE;\nGLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE;\n\nGLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE;\n\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE;\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE;\nGLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE;\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE;\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE;\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE;\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE;\n\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHFPROC __glewClearDepthf;\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEFPROC __glewDepthRangef;\nGLEW_FUN_EXPORT PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat;\nGLEW_FUN_EXPORT PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler;\nGLEW_FUN_EXPORT PFNGLSHADERBINARYPROC __glewShaderBinary;\n\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance;\n\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed;\nGLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex;\n\nGLEW_FUN_EXPORT PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB;\n\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERDATAPROC __glewClearBufferData;\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData;\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT;\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT;\n\nGLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB;\n\nGLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute;\nGLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect;\n\nGLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData;\n\nGLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData;\n\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB;\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB;\n\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB;\n\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB;\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB;\nGLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB;\n\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex;\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex;\n\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect;\n\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri;\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv;\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT;\n\nGLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer;\nGLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer;\nGLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer;\nGLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;\nGLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;\nGLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;\nGLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers;\nGLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers;\nGLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap;\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv;\nGLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv;\nGLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer;\nGLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer;\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage;\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample;\n\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB;\n\nGLEW_FUN_EXPORT PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary;\nGLEW_FUN_EXPORT PFNGLPROGRAMBINARYPROC __glewProgramBinary;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri;\n\nGLEW_FUN_EXPORT PFNGLGETUNIFORMDVPROC __glewGetUniformdv;\nGLEW_FUN_EXPORT PFNGLUNIFORM1DPROC __glewUniform1d;\nGLEW_FUN_EXPORT PFNGLUNIFORM1DVPROC __glewUniform1dv;\nGLEW_FUN_EXPORT PFNGLUNIFORM2DPROC __glewUniform2d;\nGLEW_FUN_EXPORT PFNGLUNIFORM2DVPROC __glewUniform2dv;\nGLEW_FUN_EXPORT PFNGLUNIFORM3DPROC __glewUniform3d;\nGLEW_FUN_EXPORT PFNGLUNIFORM3DVPROC __glewUniform3dv;\nGLEW_FUN_EXPORT PFNGLUNIFORM4DPROC __glewUniform4d;\nGLEW_FUN_EXPORT PFNGLUNIFORM4DVPROC __glewUniform4dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv;\n\nGLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable;\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable;\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv;\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv;\nGLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable;\nGLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable;\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D;\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv;\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram;\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv;\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv;\nGLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax;\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv;\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv;\nGLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter;\nGLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram;\nGLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax;\nGLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram;\nGLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax;\nGLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D;\n\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB;\n\nGLEW_FUN_EXPORT PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ;\n\nGLEW_FUN_EXPORT PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v;\n\nGLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData;\nGLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData;\nGLEW_FUN_EXPORT PFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer;\nGLEW_FUN_EXPORT PFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer;\nGLEW_FUN_EXPORT PFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage;\nGLEW_FUN_EXPORT PFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage;\n\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange;\nGLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange;\n\nGLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB;\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB;\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB;\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB;\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB;\n\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect;\n\nGLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB;\n\nGLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB;\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB;\n\nGLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB;\nGLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB;\nGLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB;\nGLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB;\nGLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB;\nGLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB;\n\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB;\n\nGLEW_FUN_EXPORT PFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv;\n\nGLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex;\n\nGLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB;\nGLEW_FUN_EXPORT PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB;\nGLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB;\nGLEW_FUN_EXPORT PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB;\nGLEW_FUN_EXPORT PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB;\nGLEW_FUN_EXPORT PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB;\nGLEW_FUN_EXPORT PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB;\nGLEW_FUN_EXPORT PFNGLGETNMAPIVARBPROC __glewGetnMapivARB;\nGLEW_FUN_EXPORT PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB;\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB;\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB;\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB;\nGLEW_FUN_EXPORT PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB;\nGLEW_FUN_EXPORT PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB;\nGLEW_FUN_EXPORT PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB;\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB;\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB;\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB;\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB;\nGLEW_FUN_EXPORT PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB;\n\nGLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB;\n\nGLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler;\nGLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers;\nGLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers;\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv;\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv;\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv;\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv;\nGLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri;\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv;\n\nGLEW_FUN_EXPORT PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram;\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline;\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv;\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines;\nGLEW_FUN_EXPORT PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv;\nGLEW_FUN_EXPORT PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv;\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages;\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline;\n\nGLEW_FUN_EXPORT PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv;\n\nGLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture;\nGLEW_FUN_EXPORT PFNGLMEMORYBARRIERPROC __glewMemoryBarrier;\n\nGLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB;\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB;\nGLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB;\nGLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB;\nGLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB;\nGLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB;\nGLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB;\nGLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB;\nGLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB;\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB;\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB;\nGLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB;\nGLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB;\nGLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB;\nGLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB;\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB;\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB;\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB;\n\nGLEW_FUN_EXPORT PFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding;\n\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName;\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName;\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv;\nGLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex;\nGLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv;\nGLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv;\n\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB;\nGLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB;\nGLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB;\nGLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB;\nGLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB;\nGLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB;\n\nGLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync;\nGLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync;\nGLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync;\nGLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v;\nGLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv;\nGLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync;\nGLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync;\n\nGLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv;\nGLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri;\n\nGLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB;\n\nGLEW_FUN_EXPORT PFNGLTEXBUFFERRANGEPROC __glewTexBufferRange;\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT;\n\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB;\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB;\n\nGLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv;\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski;\nGLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample;\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample;\n\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE1DPROC __glewTexStorage1D;\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE2DPROC __glewTexStorage2D;\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE3DPROC __glewTexStorage3D;\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample;\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample;\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXTUREVIEWPROC __glewTextureView;\n\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v;\nGLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter;\n\nGLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback;\nGLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks;\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback;\nGLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks;\nGLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback;\nGLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback;\nGLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback;\n\nGLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed;\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream;\nGLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed;\nGLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv;\n\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced;\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced;\n\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB;\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB;\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB;\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB;\n\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName;\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv;\nGLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices;\nGLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding;\n\nGLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray;\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays;\nGLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays;\nGLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray;\n\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer;\n\nGLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat;\nGLEW_FUN_EXPORT PFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor;\n\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB;\nGLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB;\n\nGLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB;\nGLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB;\nGLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB;\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB;\nGLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB;\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB;\nGLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB;\nGLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB;\nGLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB;\nGLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB;\nGLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB;\n\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB;\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB;\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB;\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB;\nGLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB;\nGLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB;\nGLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB;\n\nGLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB;\nGLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB;\nGLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB;\n\nGLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui;\nGLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv;\nGLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui;\nGLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv;\nGLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui;\nGLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui;\nGLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui;\nGLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui;\nGLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv;\nGLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui;\nGLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv;\n\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv;\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed;\nGLEW_FUN_EXPORT PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v;\nGLEW_FUN_EXPORT PFNGLGETFLOATI_VPROC __glewGetFloati_v;\nGLEW_FUN_EXPORT PFNGLSCISSORARRAYVPROC __glewScissorArrayv;\nGLEW_FUN_EXPORT PFNGLSCISSORINDEXEDPROC __glewScissorIndexed;\nGLEW_FUN_EXPORT PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv;\nGLEW_FUN_EXPORT PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv;\nGLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf;\nGLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv;\n\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB;\n\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI;\n\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI;\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI;\nGLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI;\n\nGLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI;\nGLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI;\nGLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI;\nGLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI;\n\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI;\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI;\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI;\nGLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI;\nGLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI;\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI;\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI;\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI;\nGLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI;\nGLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI;\nGLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI;\nGLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI;\nGLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI;\nGLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI;\n\nGLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI;\nGLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI;\n\nGLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI;\nGLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI;\n\nGLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI;\nGLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI;\n\nGLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI;\nGLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI;\nGLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI;\nGLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI;\nGLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI;\nGLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI;\nGLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI;\nGLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI;\nGLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI;\nGLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI;\nGLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI;\nGLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI;\n\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI;\n\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI;\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI;\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI;\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI;\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI;\n\nGLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT;\n\nGLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT;\n\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT;\n\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT;\n\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT;\n\nGLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT;\nGLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT;\n\nGLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT;\nGLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT;\n\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT;\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT;\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT;\nGLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT;\n\nGLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT;\nGLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT;\n\nGLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT;\n\nGLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT;\nGLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT;\n\nGLEW_FUN_EXPORT PFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT;\nGLEW_FUN_EXPORT PFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT;\nGLEW_FUN_EXPORT PFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT;\n\nGLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT;\n\nGLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT;\nGLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT;\nGLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT;\nGLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT;\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT;\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT;\nGLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT;\nGLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT;\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT;\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT;\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT;\nGLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT;\nGLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT;\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT;\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT;\nGLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT;\nGLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT;\nGLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT;\nGLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT;\nGLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT;\nGLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT;\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT;\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT;\nGLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT;\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DEXTPROC __glewProgramUniform1dEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVEXTPROC __glewProgramUniform1dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DEXTPROC __glewProgramUniform2dEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVEXTPROC __glewProgramUniform2dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DEXTPROC __glewProgramUniform3dEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVEXTPROC __glewProgramUniform3dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DEXTPROC __glewProgramUniform4dEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVEXTPROC __glewProgramUniform4dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC __glewProgramUniformMatrix2dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC __glewProgramUniformMatrix2x3dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC __glewProgramUniformMatrix2x4dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC __glewProgramUniformMatrix3dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC __glewProgramUniformMatrix3x2dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC __glewProgramUniformMatrix3x4dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC __glewProgramUniformMatrix4dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC __glewProgramUniformMatrix4x2dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC __glewProgramUniformMatrix4x3dvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT;\nGLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT;\nGLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT;\n\nGLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT;\nGLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT;\nGLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT;\nGLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT;\nGLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT;\nGLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT;\n\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT;\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT;\n\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT;\n\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT;\nGLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT;\nGLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT;\nGLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT;\nGLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT;\n\nGLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT;\nGLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT;\n\nGLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT;\n\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT;\n\nGLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT;\nGLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT;\nGLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT;\nGLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT;\nGLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT;\nGLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT;\nGLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT;\nGLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT;\nGLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT;\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT;\n\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT;\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT;\n\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT;\n\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT;\nGLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT;\n\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT;\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT;\nGLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT;\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT;\nGLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT;\nGLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT;\nGLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT;\nGLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT;\n\nGLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT;\n\nGLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT;\n\nGLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT;\nGLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT;\nGLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT;\n\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT;\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT;\n\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT;\nGLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT;\n\nGLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT;\n\nGLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT;\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT;\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT;\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT;\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT;\n\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT;\n\nGLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT;\n\nGLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT;\n\nGLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT;\nGLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT;\n\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT;\n\nGLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT;\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT;\nGLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT;\n\nGLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT;\nGLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT;\n\nGLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT;\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT;\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT;\n\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT;\n\nGLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT;\nGLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT;\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT;\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT;\n\nGLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT;\nGLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT;\nGLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT;\nGLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT;\nGLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT;\nGLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT;\n\nGLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT;\n\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT;\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT;\n\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT;\nGLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT;\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT;\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT;\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT;\n\nGLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT;\nGLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT;\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT;\nGLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT;\nGLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT;\nGLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT;\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT;\n\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT;\n\nGLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT;\nGLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT;\nGLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT;\nGLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT;\nGLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT;\nGLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT;\nGLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT;\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT;\nGLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT;\nGLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT;\nGLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT;\nGLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT;\nGLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT;\nGLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT;\nGLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT;\nGLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT;\nGLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT;\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT;\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT;\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT;\nGLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT;\nGLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT;\nGLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT;\nGLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT;\nGLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT;\nGLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT;\nGLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT;\nGLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT;\nGLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT;\nGLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT;\nGLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT;\nGLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT;\nGLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT;\nGLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT;\n\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT;\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT;\n\nGLEW_FUN_EXPORT PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT;\n\nGLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY;\n\nGLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY;\n\nGLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP;\nGLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP;\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP;\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP;\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP;\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP;\n\nGLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM;\nGLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM;\n\nGLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM;\nGLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM;\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM;\nGLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM;\nGLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM;\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM;\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM;\n\nGLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL;\nGLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL;\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL;\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL;\n\nGLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL;\nGLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL;\n\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl;\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert;\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog;\nGLEW_FUN_EXPORT PFNGLGETOBJECTLABELPROC __glewGetObjectLabel;\nGLEW_FUN_EXPORT PFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel;\nGLEW_FUN_EXPORT PFNGLGETPOINTERVPROC __glewGetPointerv;\nGLEW_FUN_EXPORT PFNGLOBJECTLABELPROC __glewObjectLabel;\nGLEW_FUN_EXPORT PFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel;\nGLEW_FUN_EXPORT PFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup;\n\nGLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled;\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion;\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion;\nGLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion;\nGLEW_FUN_EXPORT PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion;\n\nGLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA;\n\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA;\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA;\n\nGLEW_FUN_EXPORT PFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV;\nGLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV;\nGLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV;\nGLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV;\nGLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV;\n\nGLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV;\nGLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV;\n\nGLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV;\n\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV;\nGLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV;\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV;\n\nGLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV;\nGLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV;\nGLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV;\nGLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV;\nGLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV;\nGLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV;\nGLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV;\n\nGLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV;\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV;\nGLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV;\n\nGLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV;\nGLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV;\nGLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV;\nGLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV;\nGLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV;\nGLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV;\nGLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV;\n\nGLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV;\n\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV;\n\nGLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV;\n\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV;\n\nGLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV;\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV;\n\nGLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV;\nGLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV;\nGLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV;\nGLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV;\nGLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV;\nGLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV;\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV;\nGLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV;\nGLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV;\nGLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV;\nGLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV;\nGLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV;\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV;\n\nGLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV;\nGLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV;\nGLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV;\nGLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV;\nGLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV;\nGLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV;\nGLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV;\n\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV;\n\nGLEW_FUN_EXPORT PFNGLCOPYPATHNVPROC __glewCopyPathNV;\nGLEW_FUN_EXPORT PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV;\nGLEW_FUN_EXPORT PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV;\nGLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV;\nGLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV;\nGLEW_FUN_EXPORT PFNGLDELETEPATHSNVPROC __glewDeletePathsNV;\nGLEW_FUN_EXPORT PFNGLGENPATHSNVPROC __glewGenPathsNV;\nGLEW_FUN_EXPORT PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV;\nGLEW_FUN_EXPORT PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV;\nGLEW_FUN_EXPORT PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV;\nGLEW_FUN_EXPORT PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV;\nGLEW_FUN_EXPORT PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV;\nGLEW_FUN_EXPORT PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV;\nGLEW_FUN_EXPORT PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV;\nGLEW_FUN_EXPORT PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV;\nGLEW_FUN_EXPORT PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV;\nGLEW_FUN_EXPORT PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV;\nGLEW_FUN_EXPORT PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV;\nGLEW_FUN_EXPORT PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV;\nGLEW_FUN_EXPORT PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV;\nGLEW_FUN_EXPORT PFNGLISPATHNVPROC __glewIsPathNV;\nGLEW_FUN_EXPORT PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV;\nGLEW_FUN_EXPORT PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV;\nGLEW_FUN_EXPORT PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV;\nGLEW_FUN_EXPORT PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV;\nGLEW_FUN_EXPORT PFNGLPATHCOORDSNVPROC __glewPathCoordsNV;\nGLEW_FUN_EXPORT PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV;\nGLEW_FUN_EXPORT PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV;\nGLEW_FUN_EXPORT PFNGLPATHFOGGENNVPROC __glewPathFogGenNV;\nGLEW_FUN_EXPORT PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV;\nGLEW_FUN_EXPORT PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV;\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV;\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV;\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV;\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV;\nGLEW_FUN_EXPORT PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV;\nGLEW_FUN_EXPORT PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV;\nGLEW_FUN_EXPORT PFNGLPATHSTRINGNVPROC __glewPathStringNV;\nGLEW_FUN_EXPORT PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV;\nGLEW_FUN_EXPORT PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV;\nGLEW_FUN_EXPORT PFNGLPATHTEXGENNVPROC __glewPathTexGenNV;\nGLEW_FUN_EXPORT PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV;\nGLEW_FUN_EXPORT PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV;\nGLEW_FUN_EXPORT PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV;\nGLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV;\nGLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV;\nGLEW_FUN_EXPORT PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV;\nGLEW_FUN_EXPORT PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV;\n\nGLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV;\nGLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV;\n\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV;\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV;\n\nGLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV;\nGLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV;\nGLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV;\n\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV;\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV;\n\nGLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV;\nGLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV;\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV;\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV;\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV;\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV;\nGLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV;\nGLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV;\nGLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV;\nGLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV;\n\nGLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV;\n\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV;\nGLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV;\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV;\nGLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV;\nGLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV;\nGLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV;\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV;\nGLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV;\nGLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV;\n\nGLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV;\n\nGLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV;\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV;\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV;\n\nGLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV;\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV;\nGLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV;\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV;\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV;\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV;\nGLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV;\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV;\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV;\n\nGLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV;\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV;\nGLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV;\nGLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV;\n\nGLEW_FUN_EXPORT PFNGLVDPAUFININVPROC __glewVDPAUFiniNV;\nGLEW_FUN_EXPORT PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV;\nGLEW_FUN_EXPORT PFNGLVDPAUINITNVPROC __glewVDPAUInitNV;\nGLEW_FUN_EXPORT PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV;\nGLEW_FUN_EXPORT PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV;\nGLEW_FUN_EXPORT PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV;\nGLEW_FUN_EXPORT PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV;\nGLEW_FUN_EXPORT PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV;\nGLEW_FUN_EXPORT PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV;\nGLEW_FUN_EXPORT PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV;\n\nGLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV;\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV;\n\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV;\n\nGLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV;\nGLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV;\nGLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV;\nGLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV;\nGLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV;\nGLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV;\nGLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV;\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV;\nGLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV;\nGLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV;\n\nGLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV;\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV;\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV;\nGLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV;\nGLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV;\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV;\nGLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV;\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV;\nGLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV;\nGLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV;\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV;\nGLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV;\nGLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV;\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV;\n\nGLEW_FUN_EXPORT PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV;\nGLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV;\nGLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV;\nGLEW_FUN_EXPORT PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV;\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV;\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV;\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV;\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV;\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV;\n\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES;\nGLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES;\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES;\nGLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES;\nGLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES;\nGLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES;\n\nGLEW_FUN_EXPORT PFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL;\n\nGLEW_FUN_EXPORT PFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL;\nGLEW_FUN_EXPORT PFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL;\n\nGLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS;\nGLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS;\n\nGLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS;\nGLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS;\n\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS;\nGLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS;\n\nGLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS;\nGLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS;\n\nGLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS;\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS;\n\nGLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS;\nGLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS;\n\nGLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX;\nGLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX;\nGLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX;\nGLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX;\nGLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX;\nGLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX;\n\nGLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX;\n\nGLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX;\n\nGLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX;\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX;\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX;\n\nGLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX;\n\nGLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX;\n\nGLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX;\n\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX;\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX;\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX;\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX;\n\nGLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX;\n\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI;\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI;\nGLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI;\nGLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI;\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI;\n\nGLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX;\n\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN;\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN;\n\nGLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN;\n\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN;\n\nGLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN;\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN;\n\nGLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN;\n\n#if defined(GLEW_MX) && !defined(_WIN32)\nstruct GLEWContextStruct\n{\n#endif /* GLEW_MX */\n\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_2;\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_3;\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_blend_minmax_factor;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_debug_output;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_depth_clamp_separate;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_multi_draw_indirect;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_name_gen_delete;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_pinned_memory;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_query_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_sample_positions;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_stencil_operation_extended;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback3_lines_triangles;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_layer;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator;\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_viewport_index;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators;\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES2_compatibility;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_compatibility;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_arrays_of_arrays;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_base_instance;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_cl_event;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compressed_texture_pixel_storage;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_conservative_depth;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_image;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_debug_output;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_uniform_location;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_layer_viewport;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_no_attachments;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_program_binary;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query2;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_invalidate_subdata;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_alignment;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_draw_indirect;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_program_interface_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robust_buffer_access_behavior;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_application_isolation;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_share_group_isolation;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_separate_shader_objects;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counters;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_load_store;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_size;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_precision;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_stencil_export;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_storage_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_420pack;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_packing;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_stencil_texturing;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_levels;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_view;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_instanced;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_64bit;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_binding;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_viewport_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_marker;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB_decode;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting;\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_x11_sync_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator;\nGLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker;\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes;\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform;\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test;\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat;\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists;\nGLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read;\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays;\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor;\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_debug;\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_ldr;\nGLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region;\nGLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack;\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert;\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers;\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos;\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_NVX_gpu_memory_info;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fence;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_coverage;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_float;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vdpau_interop;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4;\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_video_capture;\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates;\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format;\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision;\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace;\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_resample;\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample;\nGLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints;\nGLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints;\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_error_string;\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_extension_query;\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_log;\nGLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates;\nGLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table;\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list;\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex;\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading;\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog;\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint;\n\n#ifdef GLEW_MX\n}; /* GLEWContextStruct */\n#endif /* GLEW_MX */\n\n/* ------------------------------------------------------------------------- */\n\n/* error codes */\n#define GLEW_OK 0\n#define GLEW_NO_ERROR 0\n#define GLEW_ERROR_NO_GL_VERSION 1  /* missing GL version */\n#define GLEW_ERROR_GL_VERSION_10_ONLY 2  /* Need at least OpenGL 1.1 */\n#define GLEW_ERROR_GLX_VERSION_11_ONLY 3  /* Need at least GLX 1.2 */\n\n/* string codes */\n#define GLEW_VERSION 1\n#define GLEW_VERSION_MAJOR 2\n#define GLEW_VERSION_MINOR 3\n#define GLEW_VERSION_MICRO 4\n\n/* API */\n#ifdef GLEW_MX\n\ntypedef struct GLEWContextStruct GLEWContext;\nGLEWAPI GLenum GLEWAPIENTRY glewContextInit (GLEWContext *ctx);\nGLEWAPI GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext *ctx, const char *name);\n\n#define glewInit() glewContextInit(glewGetContext())\n#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x)\n#define glewIsExtensionSupported(x) glewIsSupported(x)\n\n#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x))\n#ifdef _WIN32\n#  define GLEW_GET_FUN(x) glewGetContext()->x\n#else\n#  define GLEW_GET_FUN(x) x\n#endif\n\n#else /* GLEW_MX */\n\nGLEWAPI GLenum GLEWAPIENTRY glewInit (void);\nGLEWAPI GLboolean GLEWAPIENTRY glewIsSupported (const char *name);\n#define glewIsExtensionSupported(x) glewIsSupported(x)\n\n#define GLEW_GET_VAR(x) (*(const GLboolean*)&x)\n#define GLEW_GET_FUN(x) x\n\n#endif /* GLEW_MX */\n\nGLEWAPI GLboolean glewExperimental;\nGLEWAPI GLboolean GLEWAPIENTRY glewGetExtension (const char *name);\nGLEWAPI const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error);\nGLEWAPI const GLubyte * GLEWAPIENTRY glewGetString (GLenum name);\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef GLEW_APIENTRY_DEFINED\n#undef GLEW_APIENTRY_DEFINED\n#undef APIENTRY\n#undef GLAPIENTRY\n#define GLAPIENTRY\n#endif\n\n#ifdef GLEW_CALLBACK_DEFINED\n#undef GLEW_CALLBACK_DEFINED\n#undef CALLBACK\n#endif\n\n#ifdef GLEW_WINGDIAPI_DEFINED\n#undef GLEW_WINGDIAPI_DEFINED\n#undef WINGDIAPI\n#endif\n\n#undef GLAPI\n/* #undef GLEWAPI */\n\n#endif /* __glew_h__ */\n"
  },
  {
    "path": "deps/glew/include/GL/glxew.h",
    "content": "/*\n** The OpenGL Extension Wrangler Library\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\n** Copyright (C) 2002, Lev Povalahev\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without \n** modification, are permitted provided that the following conditions are met:\n** \n** * Redistributions of source code must retain the above copyright notice, \n**   this list of conditions and the following disclaimer.\n** * Redistributions in binary form must reproduce the above copyright notice, \n**   this list of conditions and the following disclaimer in the documentation \n**   and/or other materials provided with the distribution.\n** * The name of the author may be used to endorse or promote products \n**   derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n** THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * Mesa 3-D graphics library\n * Version:  7.0\n *\n * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\n * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/*\n** Copyright (c) 2007 The Khronos Group Inc.\n** \n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n** \n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n** \n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#ifndef __glxew_h__\n#define __glxew_h__\n#define __GLXEW_H__\n\n#ifdef __glxext_h_\n#error glxext.h included before glxew.h\n#endif\n\n#if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__)\n#error glx.h included before glxew.h\n#endif\n\n#define __glxext_h_\n\n#define GLX_H\n#define __GLX_glx_h__\n#define __glx_h__\n\n#include <X11/Xlib.h>\n#include <X11/Xutil.h>\n#include <X11/Xmd.h>\n#include <GL/glew.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* ---------------------------- GLX_VERSION_1_0 --------------------------- */\n\n#ifndef GLX_VERSION_1_0\n#define GLX_VERSION_1_0 1\n\n#define GLX_USE_GL 1\n#define GLX_BUFFER_SIZE 2\n#define GLX_LEVEL 3\n#define GLX_RGBA 4\n#define GLX_DOUBLEBUFFER 5\n#define GLX_STEREO 6\n#define GLX_AUX_BUFFERS 7\n#define GLX_RED_SIZE 8\n#define GLX_GREEN_SIZE 9\n#define GLX_BLUE_SIZE 10\n#define GLX_ALPHA_SIZE 11\n#define GLX_DEPTH_SIZE 12\n#define GLX_STENCIL_SIZE 13\n#define GLX_ACCUM_RED_SIZE 14\n#define GLX_ACCUM_GREEN_SIZE 15\n#define GLX_ACCUM_BLUE_SIZE 16\n#define GLX_ACCUM_ALPHA_SIZE 17\n#define GLX_BAD_SCREEN 1\n#define GLX_BAD_ATTRIBUTE 2\n#define GLX_NO_EXTENSION 3\n#define GLX_BAD_VISUAL 4\n#define GLX_BAD_CONTEXT 5\n#define GLX_BAD_VALUE 6\n#define GLX_BAD_ENUM 7\n\ntypedef XID GLXDrawable;\ntypedef XID GLXPixmap;\n#ifdef __sun\ntypedef struct __glXContextRec *GLXContext;\n#else\ntypedef struct __GLXcontextRec *GLXContext;\n#endif\n\ntypedef unsigned int GLXVideoDeviceNV; \n\nextern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);\nextern Bool glXQueryVersion (Display *dpy, int *major, int *minor);\nextern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);\nextern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);\nextern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);\nextern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);\nextern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);\nextern void glXDestroyContext (Display *dpy, GLXContext ctx);\nextern Bool glXIsDirect (Display *dpy, GLXContext ctx);\nextern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask);\nextern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx);\nextern GLXContext glXGetCurrentContext (void);\nextern GLXDrawable glXGetCurrentDrawable (void);\nextern void glXWaitGL (void);\nextern void glXWaitX (void);\nextern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);\nextern void glXUseXFont (Font font, int first, int count, int listBase);\n\n#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0)\n\n#endif /* GLX_VERSION_1_0 */\n\n/* ---------------------------- GLX_VERSION_1_1 --------------------------- */\n\n#ifndef GLX_VERSION_1_1\n#define GLX_VERSION_1_1\n\n#define GLX_VENDOR 0x1\n#define GLX_VERSION 0x2\n#define GLX_EXTENSIONS 0x3\n\nextern const char* glXQueryExtensionsString (Display *dpy, int screen);\nextern const char* glXGetClientString (Display *dpy, int name);\nextern const char* glXQueryServerString (Display *dpy, int screen, int name);\n\n#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1)\n\n#endif /* GLX_VERSION_1_1 */\n\n/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */\n\n#ifndef GLX_VERSION_1_2\n#define GLX_VERSION_1_2 1\n\ntypedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void);\n\n#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay)\n\n#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2)\n\n#endif /* GLX_VERSION_1_2 */\n\n/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */\n\n#ifndef GLX_VERSION_1_3\n#define GLX_VERSION_1_3 1\n\n#define GLX_RGBA_BIT 0x00000001\n#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001\n#define GLX_WINDOW_BIT 0x00000001\n#define GLX_COLOR_INDEX_BIT 0x00000002\n#define GLX_PIXMAP_BIT 0x00000002\n#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002\n#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004\n#define GLX_PBUFFER_BIT 0x00000004\n#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008\n#define GLX_AUX_BUFFERS_BIT 0x00000010\n#define GLX_CONFIG_CAVEAT 0x20\n#define GLX_DEPTH_BUFFER_BIT 0x00000020\n#define GLX_X_VISUAL_TYPE 0x22\n#define GLX_TRANSPARENT_TYPE 0x23\n#define GLX_TRANSPARENT_INDEX_VALUE 0x24\n#define GLX_TRANSPARENT_RED_VALUE 0x25\n#define GLX_TRANSPARENT_GREEN_VALUE 0x26\n#define GLX_TRANSPARENT_BLUE_VALUE 0x27\n#define GLX_TRANSPARENT_ALPHA_VALUE 0x28\n#define GLX_STENCIL_BUFFER_BIT 0x00000040\n#define GLX_ACCUM_BUFFER_BIT 0x00000080\n#define GLX_NONE 0x8000\n#define GLX_SLOW_CONFIG 0x8001\n#define GLX_TRUE_COLOR 0x8002\n#define GLX_DIRECT_COLOR 0x8003\n#define GLX_PSEUDO_COLOR 0x8004\n#define GLX_STATIC_COLOR 0x8005\n#define GLX_GRAY_SCALE 0x8006\n#define GLX_STATIC_GRAY 0x8007\n#define GLX_TRANSPARENT_RGB 0x8008\n#define GLX_TRANSPARENT_INDEX 0x8009\n#define GLX_VISUAL_ID 0x800B\n#define GLX_SCREEN 0x800C\n#define GLX_NON_CONFORMANT_CONFIG 0x800D\n#define GLX_DRAWABLE_TYPE 0x8010\n#define GLX_RENDER_TYPE 0x8011\n#define GLX_X_RENDERABLE 0x8012\n#define GLX_FBCONFIG_ID 0x8013\n#define GLX_RGBA_TYPE 0x8014\n#define GLX_COLOR_INDEX_TYPE 0x8015\n#define GLX_MAX_PBUFFER_WIDTH 0x8016\n#define GLX_MAX_PBUFFER_HEIGHT 0x8017\n#define GLX_MAX_PBUFFER_PIXELS 0x8018\n#define GLX_PRESERVED_CONTENTS 0x801B\n#define GLX_LARGEST_PBUFFER 0x801C\n#define GLX_WIDTH 0x801D\n#define GLX_HEIGHT 0x801E\n#define GLX_EVENT_MASK 0x801F\n#define GLX_DAMAGED 0x8020\n#define GLX_SAVED 0x8021\n#define GLX_WINDOW 0x8022\n#define GLX_PBUFFER 0x8023\n#define GLX_PBUFFER_HEIGHT 0x8040\n#define GLX_PBUFFER_WIDTH 0x8041\n#define GLX_PBUFFER_CLOBBER_MASK 0x08000000\n#define GLX_DONT_CARE 0xFFFFFFFF\n\ntypedef XID GLXFBConfigID;\ntypedef XID GLXPbuffer;\ntypedef XID GLXWindow;\ntypedef struct __GLXFBConfigRec *GLXFBConfig;\n\ntypedef struct {\n  int event_type; \n  int draw_type; \n  unsigned long serial; \n  Bool send_event; \n  Display *display; \n  GLXDrawable drawable; \n  unsigned int buffer_mask; \n  unsigned int aux_buffer; \n  int x, y; \n  int width, height; \n  int count; \n} GLXPbufferClobberEvent;\ntypedef union __GLXEvent {\n  GLXPbufferClobberEvent glxpbufferclobber; \n  long pad[24]; \n} GLXEvent;\n\ntypedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);\ntypedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\ntypedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);\ntypedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);\ntypedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);\ntypedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);\ntypedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);\ntypedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);\ntypedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);\ntypedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);\ntypedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);\ntypedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);\ntypedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);\ntypedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\ntypedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);\ntypedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);\ntypedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);\n\n#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig)\n#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext)\n#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer)\n#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap)\n#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow)\n#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer)\n#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap)\n#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow)\n#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable)\n#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib)\n#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs)\n#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent)\n#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig)\n#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent)\n#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext)\n#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable)\n#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent)\n\n#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3)\n\n#endif /* GLX_VERSION_1_3 */\n\n/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */\n\n#ifndef GLX_VERSION_1_4\n#define GLX_VERSION_1_4 1\n\n#define GLX_SAMPLE_BUFFERS 100000\n#define GLX_SAMPLES 100001\n\nextern void ( * glXGetProcAddress (const GLubyte *procName)) (void);\n\n#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4)\n\n#endif /* GLX_VERSION_1_4 */\n\n/* -------------------------- GLX_3DFX_multisample ------------------------- */\n\n#ifndef GLX_3DFX_multisample\n#define GLX_3DFX_multisample 1\n\n#define GLX_SAMPLE_BUFFERS_3DFX 0x8050\n#define GLX_SAMPLES_3DFX 0x8051\n\n#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample)\n\n#endif /* GLX_3DFX_multisample */\n\n/* ------------------------ GLX_AMD_gpu_association ------------------------ */\n\n#ifndef GLX_AMD_gpu_association\n#define GLX_AMD_gpu_association 1\n\n#define GLX_GPU_VENDOR_AMD 0x1F00\n#define GLX_GPU_RENDERER_STRING_AMD 0x1F01\n#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\n#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2\n#define GLX_GPU_RAM_AMD 0x21A3\n#define GLX_GPU_CLOCK_AMD 0x21A4\n#define GLX_GPU_NUM_PIPES_AMD 0x21A5\n#define GLX_GPU_NUM_SIMD_AMD 0x21A6\n#define GLX_GPU_NUM_RB_AMD 0x21A7\n#define GLX_GPU_NUM_SPI_AMD 0x21A8\n\n#define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association)\n\n#endif /* GLX_AMD_gpu_association */\n\n/* ------------------------- GLX_ARB_create_context ------------------------ */\n\n#ifndef GLX_ARB_create_context\n#define GLX_ARB_create_context 1\n\n#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001\n#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002\n#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091\n#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092\n#define GLX_CONTEXT_FLAGS_ARB 0x2094\n\ntypedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);\n\n#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB)\n\n#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context)\n\n#endif /* GLX_ARB_create_context */\n\n/* --------------------- GLX_ARB_create_context_profile -------------------- */\n\n#ifndef GLX_ARB_create_context_profile\n#define GLX_ARB_create_context_profile 1\n\n#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\n#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126\n\n#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile)\n\n#endif /* GLX_ARB_create_context_profile */\n\n/* ------------------- GLX_ARB_create_context_robustness ------------------- */\n\n#ifndef GLX_ARB_create_context_robustness\n#define GLX_ARB_create_context_robustness 1\n\n#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252\n#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261\n\n#define GLXEW_ARB_create_context_robustness GLXEW_GET_VAR(__GLXEW_ARB_create_context_robustness)\n\n#endif /* GLX_ARB_create_context_robustness */\n\n/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */\n\n#ifndef GLX_ARB_fbconfig_float\n#define GLX_ARB_fbconfig_float 1\n\n#define GLX_RGBA_FLOAT_BIT 0x00000004\n#define GLX_RGBA_FLOAT_TYPE 0x20B9\n\n#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float)\n\n#endif /* GLX_ARB_fbconfig_float */\n\n/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */\n\n#ifndef GLX_ARB_framebuffer_sRGB\n#define GLX_ARB_framebuffer_sRGB 1\n\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2\n\n#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB)\n\n#endif /* GLX_ARB_framebuffer_sRGB */\n\n/* ------------------------ GLX_ARB_get_proc_address ----------------------- */\n\n#ifndef GLX_ARB_get_proc_address\n#define GLX_ARB_get_proc_address 1\n\nextern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void);\n\n#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address)\n\n#endif /* GLX_ARB_get_proc_address */\n\n/* -------------------------- GLX_ARB_multisample -------------------------- */\n\n#ifndef GLX_ARB_multisample\n#define GLX_ARB_multisample 1\n\n#define GLX_SAMPLE_BUFFERS_ARB 100000\n#define GLX_SAMPLES_ARB 100001\n\n#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample)\n\n#endif /* GLX_ARB_multisample */\n\n/* ---------------- GLX_ARB_robustness_application_isolation --------------- */\n\n#ifndef GLX_ARB_robustness_application_isolation\n#define GLX_ARB_robustness_application_isolation 1\n\n#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\n\n#define GLXEW_ARB_robustness_application_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_application_isolation)\n\n#endif /* GLX_ARB_robustness_application_isolation */\n\n/* ---------------- GLX_ARB_robustness_share_group_isolation --------------- */\n\n#ifndef GLX_ARB_robustness_share_group_isolation\n#define GLX_ARB_robustness_share_group_isolation 1\n\n#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\n\n#define GLXEW_ARB_robustness_share_group_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_share_group_isolation)\n\n#endif /* GLX_ARB_robustness_share_group_isolation */\n\n/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */\n\n#ifndef GLX_ARB_vertex_buffer_object\n#define GLX_ARB_vertex_buffer_object 1\n\n#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095\n\n#define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object)\n\n#endif /* GLX_ARB_vertex_buffer_object */\n\n/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */\n\n#ifndef GLX_ATI_pixel_format_float\n#define GLX_ATI_pixel_format_float 1\n\n#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100\n\n#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float)\n\n#endif /* GLX_ATI_pixel_format_float */\n\n/* ------------------------- GLX_ATI_render_texture ------------------------ */\n\n#ifndef GLX_ATI_render_texture\n#define GLX_ATI_render_texture 1\n\n#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800\n#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801\n#define GLX_TEXTURE_FORMAT_ATI 0x9802\n#define GLX_TEXTURE_TARGET_ATI 0x9803\n#define GLX_MIPMAP_TEXTURE_ATI 0x9804\n#define GLX_TEXTURE_RGB_ATI 0x9805\n#define GLX_TEXTURE_RGBA_ATI 0x9806\n#define GLX_NO_TEXTURE_ATI 0x9807\n#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808\n#define GLX_TEXTURE_1D_ATI 0x9809\n#define GLX_TEXTURE_2D_ATI 0x980A\n#define GLX_MIPMAP_LEVEL_ATI 0x980B\n#define GLX_CUBE_MAP_FACE_ATI 0x980C\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812\n#define GLX_FRONT_LEFT_ATI 0x9813\n#define GLX_FRONT_RIGHT_ATI 0x9814\n#define GLX_BACK_LEFT_ATI 0x9815\n#define GLX_BACK_RIGHT_ATI 0x9816\n#define GLX_AUX0_ATI 0x9817\n#define GLX_AUX1_ATI 0x9818\n#define GLX_AUX2_ATI 0x9819\n#define GLX_AUX3_ATI 0x981A\n#define GLX_AUX4_ATI 0x981B\n#define GLX_AUX5_ATI 0x981C\n#define GLX_AUX6_ATI 0x981D\n#define GLX_AUX7_ATI 0x981E\n#define GLX_AUX8_ATI 0x981F\n#define GLX_AUX9_ATI 0x9820\n#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821\n#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822\n\ntypedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer);\ntypedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list);\ntypedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer);\n\n#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI)\n#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI)\n#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI)\n\n#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture)\n\n#endif /* GLX_ATI_render_texture */\n\n/* ------------------- GLX_EXT_create_context_es2_profile ------------------ */\n\n#ifndef GLX_EXT_create_context_es2_profile\n#define GLX_EXT_create_context_es2_profile 1\n\n#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004\n\n#define GLXEW_EXT_create_context_es2_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es2_profile)\n\n#endif /* GLX_EXT_create_context_es2_profile */\n\n/* ------------------- GLX_EXT_create_context_es_profile ------------------- */\n\n#ifndef GLX_EXT_create_context_es_profile\n#define GLX_EXT_create_context_es_profile 1\n\n#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004\n\n#define GLXEW_EXT_create_context_es_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es_profile)\n\n#endif /* GLX_EXT_create_context_es_profile */\n\n/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */\n\n#ifndef GLX_EXT_fbconfig_packed_float\n#define GLX_EXT_fbconfig_packed_float 1\n\n#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008\n#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1\n\n#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float)\n\n#endif /* GLX_EXT_fbconfig_packed_float */\n\n/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */\n\n#ifndef GLX_EXT_framebuffer_sRGB\n#define GLX_EXT_framebuffer_sRGB 1\n\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2\n\n#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB)\n\n#endif /* GLX_EXT_framebuffer_sRGB */\n\n/* ------------------------- GLX_EXT_import_context ------------------------ */\n\n#ifndef GLX_EXT_import_context\n#define GLX_EXT_import_context 1\n\n#define GLX_SHARE_CONTEXT_EXT 0x800A\n#define GLX_VISUAL_ID_EXT 0x800B\n#define GLX_SCREEN_EXT 0x800C\n\ntypedef XID GLXContextID;\n\ntypedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context);\ntypedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);\ntypedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID);\ntypedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value);\n\n#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT)\n#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT)\n#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT)\n#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT)\n\n#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context)\n\n#endif /* GLX_EXT_import_context */\n\n/* -------------------------- GLX_EXT_scene_marker ------------------------- */\n\n#ifndef GLX_EXT_scene_marker\n#define GLX_EXT_scene_marker 1\n\n#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker)\n\n#endif /* GLX_EXT_scene_marker */\n\n/* -------------------------- GLX_EXT_swap_control ------------------------- */\n\n#ifndef GLX_EXT_swap_control\n#define GLX_EXT_swap_control 1\n\n#define GLX_SWAP_INTERVAL_EXT 0x20F1\n#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2\n\ntypedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval);\n\n#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT)\n\n#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control)\n\n#endif /* GLX_EXT_swap_control */\n\n/* ----------------------- GLX_EXT_swap_control_tear ----------------------- */\n\n#ifndef GLX_EXT_swap_control_tear\n#define GLX_EXT_swap_control_tear 1\n\n#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3\n\n#define GLXEW_EXT_swap_control_tear GLXEW_GET_VAR(__GLXEW_EXT_swap_control_tear)\n\n#endif /* GLX_EXT_swap_control_tear */\n\n/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */\n\n#ifndef GLX_EXT_texture_from_pixmap\n#define GLX_EXT_texture_from_pixmap 1\n\n#define GLX_TEXTURE_1D_BIT_EXT 0x00000001\n#define GLX_TEXTURE_2D_BIT_EXT 0x00000002\n#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004\n#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0\n#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1\n#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2\n#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3\n#define GLX_Y_INVERTED_EXT 0x20D4\n#define GLX_TEXTURE_FORMAT_EXT 0x20D5\n#define GLX_TEXTURE_TARGET_EXT 0x20D6\n#define GLX_MIPMAP_TEXTURE_EXT 0x20D7\n#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8\n#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9\n#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA\n#define GLX_TEXTURE_1D_EXT 0x20DB\n#define GLX_TEXTURE_2D_EXT 0x20DC\n#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD\n#define GLX_FRONT_LEFT_EXT 0x20DE\n#define GLX_FRONT_RIGHT_EXT 0x20DF\n#define GLX_BACK_LEFT_EXT 0x20E0\n#define GLX_BACK_RIGHT_EXT 0x20E1\n#define GLX_AUX0_EXT 0x20E2\n#define GLX_AUX1_EXT 0x20E3\n#define GLX_AUX2_EXT 0x20E4\n#define GLX_AUX3_EXT 0x20E5\n#define GLX_AUX4_EXT 0x20E6\n#define GLX_AUX5_EXT 0x20E7\n#define GLX_AUX6_EXT 0x20E8\n#define GLX_AUX7_EXT 0x20E9\n#define GLX_AUX8_EXT 0x20EA\n#define GLX_AUX9_EXT 0x20EB\n\ntypedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list);\ntypedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer);\n\n#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT)\n#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT)\n\n#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap)\n\n#endif /* GLX_EXT_texture_from_pixmap */\n\n/* -------------------------- GLX_EXT_visual_info -------------------------- */\n\n#ifndef GLX_EXT_visual_info\n#define GLX_EXT_visual_info 1\n\n#define GLX_X_VISUAL_TYPE_EXT 0x22\n#define GLX_TRANSPARENT_TYPE_EXT 0x23\n#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24\n#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25\n#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26\n#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27\n#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28\n#define GLX_NONE_EXT 0x8000\n#define GLX_TRUE_COLOR_EXT 0x8002\n#define GLX_DIRECT_COLOR_EXT 0x8003\n#define GLX_PSEUDO_COLOR_EXT 0x8004\n#define GLX_STATIC_COLOR_EXT 0x8005\n#define GLX_GRAY_SCALE_EXT 0x8006\n#define GLX_STATIC_GRAY_EXT 0x8007\n#define GLX_TRANSPARENT_RGB_EXT 0x8008\n#define GLX_TRANSPARENT_INDEX_EXT 0x8009\n\n#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info)\n\n#endif /* GLX_EXT_visual_info */\n\n/* ------------------------- GLX_EXT_visual_rating ------------------------- */\n\n#ifndef GLX_EXT_visual_rating\n#define GLX_EXT_visual_rating 1\n\n#define GLX_VISUAL_CAVEAT_EXT 0x20\n#define GLX_SLOW_VISUAL_EXT 0x8001\n#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D\n\n#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating)\n\n#endif /* GLX_EXT_visual_rating */\n\n/* -------------------------- GLX_INTEL_swap_event ------------------------- */\n\n#ifndef GLX_INTEL_swap_event\n#define GLX_INTEL_swap_event 1\n\n#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180\n#define GLX_COPY_COMPLETE_INTEL 0x8181\n#define GLX_FLIP_COMPLETE_INTEL 0x8182\n#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000\n\n#define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event)\n\n#endif /* GLX_INTEL_swap_event */\n\n/* -------------------------- GLX_MESA_agp_offset -------------------------- */\n\n#ifndef GLX_MESA_agp_offset\n#define GLX_MESA_agp_offset 1\n\ntypedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer);\n\n#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA)\n\n#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset)\n\n#endif /* GLX_MESA_agp_offset */\n\n/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */\n\n#ifndef GLX_MESA_copy_sub_buffer\n#define GLX_MESA_copy_sub_buffer 1\n\ntypedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height);\n\n#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA)\n\n#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer)\n\n#endif /* GLX_MESA_copy_sub_buffer */\n\n/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */\n\n#ifndef GLX_MESA_pixmap_colormap\n#define GLX_MESA_pixmap_colormap 1\n\ntypedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);\n\n#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA)\n\n#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap)\n\n#endif /* GLX_MESA_pixmap_colormap */\n\n/* ------------------------ GLX_MESA_release_buffers ----------------------- */\n\n#ifndef GLX_MESA_release_buffers\n#define GLX_MESA_release_buffers 1\n\ntypedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d);\n\n#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA)\n\n#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers)\n\n#endif /* GLX_MESA_release_buffers */\n\n/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */\n\n#ifndef GLX_MESA_set_3dfx_mode\n#define GLX_MESA_set_3dfx_mode 1\n\n#define GLX_3DFX_WINDOW_MODE_MESA 0x1\n#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2\n\ntypedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode);\n\n#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA)\n\n#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode)\n\n#endif /* GLX_MESA_set_3dfx_mode */\n\n/* ------------------------- GLX_MESA_swap_control ------------------------- */\n\n#ifndef GLX_MESA_swap_control\n#define GLX_MESA_swap_control 1\n\ntypedef int ( * PFNGLXGETSWAPINTERVALMESAPROC) (void);\ntypedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval);\n\n#define glXGetSwapIntervalMESA GLXEW_GET_FUN(__glewXGetSwapIntervalMESA)\n#define glXSwapIntervalMESA GLXEW_GET_FUN(__glewXSwapIntervalMESA)\n\n#define GLXEW_MESA_swap_control GLXEW_GET_VAR(__GLXEW_MESA_swap_control)\n\n#endif /* GLX_MESA_swap_control */\n\n/* --------------------------- GLX_NV_copy_image --------------------------- */\n\n#ifndef GLX_NV_copy_image\n#define GLX_NV_copy_image 1\n\ntypedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n\n#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV)\n\n#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image)\n\n#endif /* GLX_NV_copy_image */\n\n/* -------------------------- GLX_NV_float_buffer -------------------------- */\n\n#ifndef GLX_NV_float_buffer\n#define GLX_NV_float_buffer 1\n\n#define GLX_FLOAT_COMPONENTS_NV 0x20B0\n\n#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer)\n\n#endif /* GLX_NV_float_buffer */\n\n/* ---------------------- GLX_NV_multisample_coverage ---------------------- */\n\n#ifndef GLX_NV_multisample_coverage\n#define GLX_NV_multisample_coverage 1\n\n#define GLX_COLOR_SAMPLES_NV 0x20B3\n#define GLX_COVERAGE_SAMPLES_NV 100001\n\n#define GLXEW_NV_multisample_coverage GLXEW_GET_VAR(__GLXEW_NV_multisample_coverage)\n\n#endif /* GLX_NV_multisample_coverage */\n\n/* -------------------------- GLX_NV_present_video ------------------------- */\n\n#ifndef GLX_NV_present_video\n#define GLX_NV_present_video 1\n\n#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0\n\ntypedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);\ntypedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);\n\n#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV)\n#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV)\n\n#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video)\n\n#endif /* GLX_NV_present_video */\n\n/* --------------------------- GLX_NV_swap_group --------------------------- */\n\n#ifndef GLX_NV_swap_group\n#define GLX_NV_swap_group 1\n\ntypedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier);\ntypedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group);\ntypedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count);\ntypedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);\ntypedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);\ntypedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen);\n\n#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV)\n#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV)\n#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV)\n#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV)\n#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV)\n#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV)\n\n#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group)\n\n#endif /* GLX_NV_swap_group */\n\n/* ----------------------- GLX_NV_vertex_array_range ----------------------- */\n\n#ifndef GLX_NV_vertex_array_range\n#define GLX_NV_vertex_array_range 1\n\ntypedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority);\ntypedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer);\n\n#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV)\n#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV)\n\n#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range)\n\n#endif /* GLX_NV_vertex_array_range */\n\n/* -------------------------- GLX_NV_video_capture ------------------------- */\n\n#ifndef GLX_NV_video_capture\n#define GLX_NV_video_capture 1\n\n#define GLX_DEVICE_ID_NV 0x20CD\n#define GLX_UNIQUE_ID_NV 0x20CE\n#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF\n\ntypedef XID GLXVideoCaptureDeviceNV;\n\ntypedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display* dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);\ntypedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display* dpy, int screen, int *nelements);\ntypedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device);\ntypedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);\ntypedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device);\n\n#define glXBindVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXBindVideoCaptureDeviceNV)\n#define glXEnumerateVideoCaptureDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoCaptureDevicesNV)\n#define glXLockVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXLockVideoCaptureDeviceNV)\n#define glXQueryVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXQueryVideoCaptureDeviceNV)\n#define glXReleaseVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoCaptureDeviceNV)\n\n#define GLXEW_NV_video_capture GLXEW_GET_VAR(__GLXEW_NV_video_capture)\n\n#endif /* GLX_NV_video_capture */\n\n/* ---------------------------- GLX_NV_video_out --------------------------- */\n\n#ifndef GLX_NV_video_out\n#define GLX_NV_video_out 1\n\n#define GLX_VIDEO_OUT_COLOR_NV 0x20C3\n#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4\n#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5\n#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6\n#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7\n#define GLX_VIDEO_OUT_FRAME_NV 0x20C8\n#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9\n#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA\n#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB\n#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC\n\ntypedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);\ntypedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);\ntypedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\ntypedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice);\ntypedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf);\ntypedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);\n\n#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV)\n#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV)\n#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV)\n#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV)\n#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV)\n#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV)\n\n#define GLXEW_NV_video_out GLXEW_GET_VAR(__GLXEW_NV_video_out)\n\n#endif /* GLX_NV_video_out */\n\n/* -------------------------- GLX_OML_swap_method -------------------------- */\n\n#ifndef GLX_OML_swap_method\n#define GLX_OML_swap_method 1\n\n#define GLX_SWAP_METHOD_OML 0x8060\n#define GLX_SWAP_EXCHANGE_OML 0x8061\n#define GLX_SWAP_COPY_OML 0x8062\n#define GLX_SWAP_UNDEFINED_OML 0x8063\n\n#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method)\n\n#endif /* GLX_OML_swap_method */\n\n/* -------------------------- GLX_OML_sync_control ------------------------- */\n\n#ifndef GLX_OML_sync_control\n#define GLX_OML_sync_control 1\n\ntypedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator);\ntypedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc);\ntypedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);\ntypedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc);\ntypedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc);\n\n#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML)\n#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML)\n#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML)\n#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML)\n#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML)\n\n#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control)\n\n#endif /* GLX_OML_sync_control */\n\n/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */\n\n#ifndef GLX_SGIS_blended_overlay\n#define GLX_SGIS_blended_overlay 1\n\n#define GLX_BLENDED_RGBA_SGIS 0x8025\n\n#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay)\n\n#endif /* GLX_SGIS_blended_overlay */\n\n/* -------------------------- GLX_SGIS_color_range ------------------------- */\n\n#ifndef GLX_SGIS_color_range\n#define GLX_SGIS_color_range 1\n\n#define GLX_MIN_RED_SGIS 0\n#define GLX_MAX_GREEN_SGIS 0\n#define GLX_MIN_BLUE_SGIS 0\n#define GLX_MAX_ALPHA_SGIS 0\n#define GLX_MIN_GREEN_SGIS 0\n#define GLX_MIN_ALPHA_SGIS 0\n#define GLX_MAX_RED_SGIS 0\n#define GLX_EXTENDED_RANGE_SGIS 0\n#define GLX_MAX_BLUE_SGIS 0\n\n#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range)\n\n#endif /* GLX_SGIS_color_range */\n\n/* -------------------------- GLX_SGIS_multisample ------------------------- */\n\n#ifndef GLX_SGIS_multisample\n#define GLX_SGIS_multisample 1\n\n#define GLX_SAMPLE_BUFFERS_SGIS 100000\n#define GLX_SAMPLES_SGIS 100001\n\n#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample)\n\n#endif /* GLX_SGIS_multisample */\n\n/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */\n\n#ifndef GLX_SGIS_shared_multisample\n#define GLX_SGIS_shared_multisample 1\n\n#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026\n#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027\n\n#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample)\n\n#endif /* GLX_SGIS_shared_multisample */\n\n/* --------------------------- GLX_SGIX_fbconfig --------------------------- */\n\n#ifndef GLX_SGIX_fbconfig\n#define GLX_SGIX_fbconfig 1\n\n#define GLX_WINDOW_BIT_SGIX 0x00000001\n#define GLX_RGBA_BIT_SGIX 0x00000001\n#define GLX_PIXMAP_BIT_SGIX 0x00000002\n#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002\n#define GLX_SCREEN_EXT 0x800C\n#define GLX_DRAWABLE_TYPE_SGIX 0x8010\n#define GLX_RENDER_TYPE_SGIX 0x8011\n#define GLX_X_RENDERABLE_SGIX 0x8012\n#define GLX_FBCONFIG_ID_SGIX 0x8013\n#define GLX_RGBA_TYPE_SGIX 0x8014\n#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015\n\ntypedef XID GLXFBConfigIDSGIX;\ntypedef struct __GLXFBConfigRec *GLXFBConfigSGIX;\n\ntypedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);\ntypedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\ntypedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap);\ntypedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value);\ntypedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis);\ntypedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config);\n\n#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX)\n#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX)\n#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX)\n#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX)\n#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX)\n#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX)\n\n#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig)\n\n#endif /* GLX_SGIX_fbconfig */\n\n/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */\n\n#ifndef GLX_SGIX_hyperpipe\n#define GLX_SGIX_hyperpipe 1\n\n#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001\n#define GLX_PIPE_RECT_SGIX 0x00000001\n#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002\n#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002\n#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003\n#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004\n#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80\n#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91\n#define GLX_BAD_HYPERPIPE_SGIX 92\n#define GLX_HYPERPIPE_ID_SGIX 0x8030\n\ntypedef struct {\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \n  int  networkId; \n} GLXHyperpipeNetworkSGIX;\ntypedef struct {\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \n  int XOrigin; \n  int YOrigin; \n  int maxHeight; \n  int maxWidth; \n} GLXPipeRectLimits;\ntypedef struct {\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \n  int channel; \n  unsigned int participationType; \n  int timeSlice; \n} GLXHyperpipeConfigSGIX;\ntypedef struct {\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \n  int srcXOrigin; \n  int srcYOrigin; \n  int srcWidth; \n  int srcHeight; \n  int destXOrigin; \n  int destYOrigin; \n  int destWidth; \n  int destHeight; \n} GLXPipeRect;\n\ntypedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);\ntypedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);\ntypedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);\ntypedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);\ntypedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);\ntypedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);\ntypedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);\ntypedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);\n\n#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX)\n#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX)\n#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX)\n#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX)\n#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX)\n#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX)\n#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX)\n#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX)\n\n#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe)\n\n#endif /* GLX_SGIX_hyperpipe */\n\n/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */\n\n#ifndef GLX_SGIX_pbuffer\n#define GLX_SGIX_pbuffer 1\n\n#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001\n#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002\n#define GLX_PBUFFER_BIT_SGIX 0x00000004\n#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004\n#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008\n#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010\n#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020\n#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040\n#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080\n#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100\n#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016\n#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017\n#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018\n#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019\n#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A\n#define GLX_PRESERVED_CONTENTS_SGIX 0x801B\n#define GLX_LARGEST_PBUFFER_SGIX 0x801C\n#define GLX_WIDTH_SGIX 0x801D\n#define GLX_HEIGHT_SGIX 0x801E\n#define GLX_EVENT_MASK_SGIX 0x801F\n#define GLX_DAMAGED_SGIX 0x8020\n#define GLX_SAVED_SGIX 0x8021\n#define GLX_WINDOW_SGIX 0x8022\n#define GLX_PBUFFER_SGIX 0x8023\n#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000\n\ntypedef XID GLXPbufferSGIX;\ntypedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\n\ntypedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list);\ntypedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf);\ntypedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask);\ntypedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value);\ntypedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask);\n\n#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX)\n#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX)\n#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX)\n#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX)\n#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX)\n\n#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer)\n\n#endif /* GLX_SGIX_pbuffer */\n\n/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */\n\n#ifndef GLX_SGIX_swap_barrier\n#define GLX_SGIX_swap_barrier 1\n\ntypedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);\ntypedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);\n\n#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX)\n#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX)\n\n#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier)\n\n#endif /* GLX_SGIX_swap_barrier */\n\n/* -------------------------- GLX_SGIX_swap_group -------------------------- */\n\n#ifndef GLX_SGIX_swap_group\n#define GLX_SGIX_swap_group 1\n\ntypedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);\n\n#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX)\n\n#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group)\n\n#endif /* GLX_SGIX_swap_group */\n\n/* ------------------------- GLX_SGIX_video_resize ------------------------- */\n\n#ifndef GLX_SGIX_video_resize\n#define GLX_SGIX_video_resize 1\n\n#define GLX_SYNC_FRAME_SGIX 0x00000000\n#define GLX_SYNC_SWAP_SGIX 0x00000001\n\ntypedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window);\ntypedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h);\ntypedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype);\ntypedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h);\ntypedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);\n\n#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX)\n#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX)\n#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX)\n#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX)\n#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX)\n\n#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize)\n\n#endif /* GLX_SGIX_video_resize */\n\n/* ---------------------- GLX_SGIX_visual_select_group --------------------- */\n\n#ifndef GLX_SGIX_visual_select_group\n#define GLX_SGIX_visual_select_group 1\n\n#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028\n\n#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group)\n\n#endif /* GLX_SGIX_visual_select_group */\n\n/* ---------------------------- GLX_SGI_cushion ---------------------------- */\n\n#ifndef GLX_SGI_cushion\n#define GLX_SGI_cushion 1\n\ntypedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion);\n\n#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI)\n\n#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion)\n\n#endif /* GLX_SGI_cushion */\n\n/* ----------------------- GLX_SGI_make_current_read ----------------------- */\n\n#ifndef GLX_SGI_make_current_read\n#define GLX_SGI_make_current_read 1\n\ntypedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);\ntypedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\n\n#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI)\n#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI)\n\n#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read)\n\n#endif /* GLX_SGI_make_current_read */\n\n/* -------------------------- GLX_SGI_swap_control ------------------------- */\n\n#ifndef GLX_SGI_swap_control\n#define GLX_SGI_swap_control 1\n\ntypedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);\n\n#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI)\n\n#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control)\n\n#endif /* GLX_SGI_swap_control */\n\n/* --------------------------- GLX_SGI_video_sync -------------------------- */\n\n#ifndef GLX_SGI_video_sync\n#define GLX_SGI_video_sync 1\n\ntypedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int* count);\ntypedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count);\n\n#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI)\n#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI)\n\n#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync)\n\n#endif /* GLX_SGI_video_sync */\n\n/* --------------------- GLX_SUN_get_transparent_index --------------------- */\n\n#ifndef GLX_SUN_get_transparent_index\n#define GLX_SUN_get_transparent_index 1\n\ntypedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex);\n\n#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN)\n\n#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index)\n\n#endif /* GLX_SUN_get_transparent_index */\n\n/* -------------------------- GLX_SUN_video_resize ------------------------- */\n\n#ifndef GLX_SUN_video_resize\n#define GLX_SUN_video_resize 1\n\n#define GLX_VIDEO_RESIZE_SUN 0x8171\n#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD\n\ntypedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor);\ntypedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor);\n\n#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN)\n#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN)\n\n#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize)\n\n#endif /* GLX_SUN_video_resize */\n\n/* ------------------------------------------------------------------------- */\n\n#ifdef GLEW_MX\n#define GLXEW_FUN_EXPORT\n#define GLXEW_VAR_EXPORT\n#else\n#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT\n#define GLXEW_VAR_EXPORT GLEW_VAR_EXPORT\n#endif /* GLEW_MX */\n\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;\n\nGLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;\nGLXEW_FUN_EXPORT PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext;\nGLXEW_FUN_EXPORT PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer;\nGLXEW_FUN_EXPORT PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap;\nGLXEW_FUN_EXPORT PFNGLXCREATEWINDOWPROC __glewXCreateWindow;\nGLXEW_FUN_EXPORT PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer;\nGLXEW_FUN_EXPORT PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap;\nGLXEW_FUN_EXPORT PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow;\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable;\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib;\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs;\nGLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent;\nGLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig;\nGLXEW_FUN_EXPORT PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent;\nGLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTPROC __glewXQueryContext;\nGLXEW_FUN_EXPORT PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable;\nGLXEW_FUN_EXPORT PFNGLXSELECTEVENTPROC __glewXSelectEvent;\n\nGLXEW_FUN_EXPORT PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB;\n\nGLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI;\nGLXEW_FUN_EXPORT PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI;\nGLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI;\n\nGLXEW_FUN_EXPORT PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT;\nGLXEW_FUN_EXPORT PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT;\nGLXEW_FUN_EXPORT PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT;\nGLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT;\n\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT;\n\nGLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT;\nGLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT;\n\nGLXEW_FUN_EXPORT PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA;\n\nGLXEW_FUN_EXPORT PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;\n\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;\n\nGLXEW_FUN_EXPORT PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;\n\nGLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;\n\nGLXEW_FUN_EXPORT PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;\n\nGLXEW_FUN_EXPORT PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;\n\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;\n\nGLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV;\nGLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV;\nGLXEW_FUN_EXPORT PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV;\nGLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV;\nGLXEW_FUN_EXPORT PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV;\nGLXEW_FUN_EXPORT PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV;\n\nGLXEW_FUN_EXPORT PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV;\nGLXEW_FUN_EXPORT PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV;\n\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV;\nGLXEW_FUN_EXPORT PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV;\n\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV;\nGLXEW_FUN_EXPORT PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV;\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV;\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV;\nGLXEW_FUN_EXPORT PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV;\n\nGLXEW_FUN_EXPORT PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;\nGLXEW_FUN_EXPORT PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML;\nGLXEW_FUN_EXPORT PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML;\nGLXEW_FUN_EXPORT PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML;\nGLXEW_FUN_EXPORT PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;\n\nGLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX;\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX;\nGLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX;\nGLXEW_FUN_EXPORT PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX;\nGLXEW_FUN_EXPORT PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX;\nGLXEW_FUN_EXPORT PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX;\nGLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX;\nGLXEW_FUN_EXPORT PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX;\nGLXEW_FUN_EXPORT PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX;\nGLXEW_FUN_EXPORT PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX;\nGLXEW_FUN_EXPORT PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX;\n\nGLXEW_FUN_EXPORT PFNGLXCUSHIONSGIPROC __glewXCushionSGI;\n\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI;\nGLXEW_FUN_EXPORT PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI;\n\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI;\n\nGLXEW_FUN_EXPORT PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI;\nGLXEW_FUN_EXPORT PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI;\n\nGLXEW_FUN_EXPORT PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN;\n\nGLXEW_FUN_EXPORT PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN;\nGLXEW_FUN_EXPORT PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN;\n\n#if defined(GLEW_MX)\nstruct GLXEWContextStruct\n{\n#endif /* GLEW_MX */\n\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_3;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_4;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_3DFX_multisample;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_AMD_gpu_association;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_profile;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_get_proc_address;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_multisample;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_application_isolation;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_share_group_isolation;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_pixel_format_float;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_render_texture;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es_profile;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control_tear;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_info;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_rating;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_INTEL_swap_event;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_agp_offset;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_release_buffers;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_swap_control;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_image;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_vertex_array_range;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_capture;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_out;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_OML_swap_method;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_OML_sync_control;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_color_range;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_multisample;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_shared_multisample;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_fbconfig;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_hyperpipe;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_pbuffer;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_barrier;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_group;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_video_resize;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_visual_select_group;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_cushion;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_make_current_read;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_swap_control;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_video_sync;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_get_transparent_index;\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_video_resize;\n\n#ifdef GLEW_MX\n}; /* GLXEWContextStruct */\n#endif /* GLEW_MX */\n\n/* ------------------------------------------------------------------------ */\n\n#ifdef GLEW_MX\n\ntypedef struct GLXEWContextStruct GLXEWContext;\nGLEWAPI GLenum GLEWAPIENTRY glxewContextInit (GLXEWContext *ctx);\nGLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx, const char *name);\n\n#define glxewInit() glxewContextInit(glxewGetContext())\n#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x)\n\n#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x))\n#define GLXEW_GET_FUN(x) x\n\n#else /* GLEW_MX */\n\n#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)\n#define GLXEW_GET_FUN(x) x\n\nGLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);\n\n#endif /* GLEW_MX */\n\nGLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __glxew_h__ */\n"
  },
  {
    "path": "deps/glew/include/GL/wglew.h",
    "content": "/*\n** The OpenGL Extension Wrangler Library\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\n** Copyright (C) 2002, Lev Povalahev\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without \n** modification, are permitted provided that the following conditions are met:\n** \n** * Redistributions of source code must retain the above copyright notice, \n**   this list of conditions and the following disclaimer.\n** * Redistributions in binary form must reproduce the above copyright notice, \n**   this list of conditions and the following disclaimer in the documentation \n**   and/or other materials provided with the distribution.\n** * The name of the author may be used to endorse or promote products \n**   derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n** THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n** Copyright (c) 2007 The Khronos Group Inc.\n** \n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n** \n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n** \n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#ifndef __wglew_h__\n#define __wglew_h__\n#define __WGLEW_H__\n\n#ifdef __wglext_h_\n#error wglext.h included before wglew.h\n#endif\n\n#define __wglext_h_\n\n#if !defined(WINAPI)\n#  ifndef WIN32_LEAN_AND_MEAN\n#    define WIN32_LEAN_AND_MEAN 1\n#  endif\n#include <windows.h>\n#  undef WIN32_LEAN_AND_MEAN\n#endif\n\n/*\n * GLEW_STATIC needs to be set when using the static version.\n * GLEW_BUILD is set when building the DLL version.\n */\n#ifdef GLEW_STATIC\n#  define GLEWAPI extern\n#else\n#  ifdef GLEW_BUILD\n#    define GLEWAPI extern __declspec(dllexport)\n#  else\n#    define GLEWAPI extern __declspec(dllimport)\n#  endif\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* -------------------------- WGL_3DFX_multisample ------------------------- */\n\n#ifndef WGL_3DFX_multisample\n#define WGL_3DFX_multisample 1\n\n#define WGL_SAMPLE_BUFFERS_3DFX 0x2060\n#define WGL_SAMPLES_3DFX 0x2061\n\n#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample)\n\n#endif /* WGL_3DFX_multisample */\n\n/* ------------------------- WGL_3DL_stereo_control ------------------------ */\n\n#ifndef WGL_3DL_stereo_control\n#define WGL_3DL_stereo_control 1\n\n#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055\n#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056\n#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057\n#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058\n\ntypedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);\n\n#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL)\n\n#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control)\n\n#endif /* WGL_3DL_stereo_control */\n\n/* ------------------------ WGL_AMD_gpu_association ------------------------ */\n\n#ifndef WGL_AMD_gpu_association\n#define WGL_AMD_gpu_association 1\n\n#define WGL_GPU_VENDOR_AMD 0x1F00\n#define WGL_GPU_RENDERER_STRING_AMD 0x1F01\n#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\n#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2\n#define WGL_GPU_RAM_AMD 0x21A3\n#define WGL_GPU_CLOCK_AMD 0x21A4\n#define WGL_GPU_NUM_PIPES_AMD 0x21A5\n#define WGL_GPU_NUM_SIMD_AMD 0x21A6\n#define WGL_GPU_NUM_RB_AMD 0x21A7\n#define WGL_GPU_NUM_SPI_AMD 0x21A8\n\ntypedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList);\ntypedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);\ntypedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);\ntypedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);\ntypedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids);\ntypedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data);\ntypedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);\n\n#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD)\n#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD)\n#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD)\n#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD)\n#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD)\n#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD)\n#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD)\n#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD)\n#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD)\n\n#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association)\n\n#endif /* WGL_AMD_gpu_association */\n\n/* ------------------------- WGL_ARB_buffer_region ------------------------- */\n\n#ifndef WGL_ARB_buffer_region\n#define WGL_ARB_buffer_region 1\n\n#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001\n#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002\n#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004\n#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008\n\ntypedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);\ntypedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);\ntypedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\ntypedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);\n\n#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB)\n#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB)\n#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB)\n#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB)\n\n#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region)\n\n#endif /* WGL_ARB_buffer_region */\n\n/* ------------------------- WGL_ARB_create_context ------------------------ */\n\n#ifndef WGL_ARB_create_context\n#define WGL_ARB_create_context 1\n\n#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001\n#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002\n#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091\n#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092\n#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093\n#define WGL_CONTEXT_FLAGS_ARB 0x2094\n#define ERROR_INVALID_VERSION_ARB 0x2095\n#define ERROR_INVALID_PROFILE_ARB 0x2096\n\ntypedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList);\n\n#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB)\n\n#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context)\n\n#endif /* WGL_ARB_create_context */\n\n/* --------------------- WGL_ARB_create_context_profile -------------------- */\n\n#ifndef WGL_ARB_create_context_profile\n#define WGL_ARB_create_context_profile 1\n\n#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\n#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126\n\n#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile)\n\n#endif /* WGL_ARB_create_context_profile */\n\n/* ------------------- WGL_ARB_create_context_robustness ------------------- */\n\n#ifndef WGL_ARB_create_context_robustness\n#define WGL_ARB_create_context_robustness 1\n\n#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252\n#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261\n\n#define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness)\n\n#endif /* WGL_ARB_create_context_robustness */\n\n/* ----------------------- WGL_ARB_extensions_string ----------------------- */\n\n#ifndef WGL_ARB_extensions_string\n#define WGL_ARB_extensions_string 1\n\ntypedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);\n\n#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB)\n\n#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string)\n\n#endif /* WGL_ARB_extensions_string */\n\n/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */\n\n#ifndef WGL_ARB_framebuffer_sRGB\n#define WGL_ARB_framebuffer_sRGB 1\n\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9\n\n#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB)\n\n#endif /* WGL_ARB_framebuffer_sRGB */\n\n/* ----------------------- WGL_ARB_make_current_read ----------------------- */\n\n#ifndef WGL_ARB_make_current_read\n#define WGL_ARB_make_current_read 1\n\n#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043\n#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054\n\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID);\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\n#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB)\n#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB)\n\n#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read)\n\n#endif /* WGL_ARB_make_current_read */\n\n/* -------------------------- WGL_ARB_multisample -------------------------- */\n\n#ifndef WGL_ARB_multisample\n#define WGL_ARB_multisample 1\n\n#define WGL_SAMPLE_BUFFERS_ARB 0x2041\n#define WGL_SAMPLES_ARB 0x2042\n\n#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample)\n\n#endif /* WGL_ARB_multisample */\n\n/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */\n\n#ifndef WGL_ARB_pbuffer\n#define WGL_ARB_pbuffer 1\n\n#define WGL_DRAW_TO_PBUFFER_ARB 0x202D\n#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E\n#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030\n#define WGL_PBUFFER_LARGEST_ARB 0x2033\n#define WGL_PBUFFER_WIDTH_ARB 0x2034\n#define WGL_PBUFFER_HEIGHT_ARB 0x2035\n#define WGL_PBUFFER_LOST_ARB 0x2036\n\nDECLARE_HANDLE(HPBUFFERARB);\n\ntypedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue);\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);\n\n#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB)\n#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB)\n#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB)\n#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB)\n#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB)\n\n#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer)\n\n#endif /* WGL_ARB_pbuffer */\n\n/* -------------------------- WGL_ARB_pixel_format ------------------------- */\n\n#ifndef WGL_ARB_pixel_format\n#define WGL_ARB_pixel_format 1\n\n#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000\n#define WGL_DRAW_TO_WINDOW_ARB 0x2001\n#define WGL_DRAW_TO_BITMAP_ARB 0x2002\n#define WGL_ACCELERATION_ARB 0x2003\n#define WGL_NEED_PALETTE_ARB 0x2004\n#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005\n#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006\n#define WGL_SWAP_METHOD_ARB 0x2007\n#define WGL_NUMBER_OVERLAYS_ARB 0x2008\n#define WGL_NUMBER_UNDERLAYS_ARB 0x2009\n#define WGL_TRANSPARENT_ARB 0x200A\n#define WGL_SHARE_DEPTH_ARB 0x200C\n#define WGL_SHARE_STENCIL_ARB 0x200D\n#define WGL_SHARE_ACCUM_ARB 0x200E\n#define WGL_SUPPORT_GDI_ARB 0x200F\n#define WGL_SUPPORT_OPENGL_ARB 0x2010\n#define WGL_DOUBLE_BUFFER_ARB 0x2011\n#define WGL_STEREO_ARB 0x2012\n#define WGL_PIXEL_TYPE_ARB 0x2013\n#define WGL_COLOR_BITS_ARB 0x2014\n#define WGL_RED_BITS_ARB 0x2015\n#define WGL_RED_SHIFT_ARB 0x2016\n#define WGL_GREEN_BITS_ARB 0x2017\n#define WGL_GREEN_SHIFT_ARB 0x2018\n#define WGL_BLUE_BITS_ARB 0x2019\n#define WGL_BLUE_SHIFT_ARB 0x201A\n#define WGL_ALPHA_BITS_ARB 0x201B\n#define WGL_ALPHA_SHIFT_ARB 0x201C\n#define WGL_ACCUM_BITS_ARB 0x201D\n#define WGL_ACCUM_RED_BITS_ARB 0x201E\n#define WGL_ACCUM_GREEN_BITS_ARB 0x201F\n#define WGL_ACCUM_BLUE_BITS_ARB 0x2020\n#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021\n#define WGL_DEPTH_BITS_ARB 0x2022\n#define WGL_STENCIL_BITS_ARB 0x2023\n#define WGL_AUX_BUFFERS_ARB 0x2024\n#define WGL_NO_ACCELERATION_ARB 0x2025\n#define WGL_GENERIC_ACCELERATION_ARB 0x2026\n#define WGL_FULL_ACCELERATION_ARB 0x2027\n#define WGL_SWAP_EXCHANGE_ARB 0x2028\n#define WGL_SWAP_COPY_ARB 0x2029\n#define WGL_SWAP_UNDEFINED_ARB 0x202A\n#define WGL_TYPE_RGBA_ARB 0x202B\n#define WGL_TYPE_COLORINDEX_ARB 0x202C\n#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037\n#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038\n#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039\n#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A\n#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B\n\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues);\n\n#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB)\n#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB)\n#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB)\n\n#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format)\n\n#endif /* WGL_ARB_pixel_format */\n\n/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */\n\n#ifndef WGL_ARB_pixel_format_float\n#define WGL_ARB_pixel_format_float 1\n\n#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0\n\n#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float)\n\n#endif /* WGL_ARB_pixel_format_float */\n\n/* ------------------------- WGL_ARB_render_texture ------------------------ */\n\n#ifndef WGL_ARB_render_texture\n#define WGL_ARB_render_texture 1\n\n#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070\n#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071\n#define WGL_TEXTURE_FORMAT_ARB 0x2072\n#define WGL_TEXTURE_TARGET_ARB 0x2073\n#define WGL_MIPMAP_TEXTURE_ARB 0x2074\n#define WGL_TEXTURE_RGB_ARB 0x2075\n#define WGL_TEXTURE_RGBA_ARB 0x2076\n#define WGL_NO_TEXTURE_ARB 0x2077\n#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078\n#define WGL_TEXTURE_1D_ARB 0x2079\n#define WGL_TEXTURE_2D_ARB 0x207A\n#define WGL_MIPMAP_LEVEL_ARB 0x207B\n#define WGL_CUBE_MAP_FACE_ARB 0x207C\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082\n#define WGL_FRONT_LEFT_ARB 0x2083\n#define WGL_FRONT_RIGHT_ARB 0x2084\n#define WGL_BACK_LEFT_ARB 0x2085\n#define WGL_BACK_RIGHT_ARB 0x2086\n#define WGL_AUX0_ARB 0x2087\n#define WGL_AUX1_ARB 0x2088\n#define WGL_AUX2_ARB 0x2089\n#define WGL_AUX3_ARB 0x208A\n#define WGL_AUX4_ARB 0x208B\n#define WGL_AUX5_ARB 0x208C\n#define WGL_AUX6_ARB 0x208D\n#define WGL_AUX7_ARB 0x208E\n#define WGL_AUX8_ARB 0x208F\n#define WGL_AUX9_ARB 0x2090\n\ntypedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\ntypedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\ntypedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList);\n\n#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB)\n#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB)\n#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB)\n\n#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture)\n\n#endif /* WGL_ARB_render_texture */\n\n/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */\n\n#ifndef WGL_ATI_pixel_format_float\n#define WGL_ATI_pixel_format_float 1\n\n#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0\n#define GL_RGBA_FLOAT_MODE_ATI 0x8820\n#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835\n\n#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float)\n\n#endif /* WGL_ATI_pixel_format_float */\n\n/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */\n\n#ifndef WGL_ATI_render_texture_rectangle\n#define WGL_ATI_render_texture_rectangle 1\n\n#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5\n\n#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle)\n\n#endif /* WGL_ATI_render_texture_rectangle */\n\n/* ------------------- WGL_EXT_create_context_es2_profile ------------------ */\n\n#ifndef WGL_EXT_create_context_es2_profile\n#define WGL_EXT_create_context_es2_profile 1\n\n#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004\n\n#define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile)\n\n#endif /* WGL_EXT_create_context_es2_profile */\n\n/* ------------------- WGL_EXT_create_context_es_profile ------------------- */\n\n#ifndef WGL_EXT_create_context_es_profile\n#define WGL_EXT_create_context_es_profile 1\n\n#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004\n\n#define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile)\n\n#endif /* WGL_EXT_create_context_es_profile */\n\n/* -------------------------- WGL_EXT_depth_float -------------------------- */\n\n#ifndef WGL_EXT_depth_float\n#define WGL_EXT_depth_float 1\n\n#define WGL_DEPTH_FLOAT_EXT 0x2040\n\n#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float)\n\n#endif /* WGL_EXT_depth_float */\n\n/* ---------------------- WGL_EXT_display_color_table ---------------------- */\n\n#ifndef WGL_EXT_display_color_table\n#define WGL_EXT_display_color_table 1\n\ntypedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);\ntypedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);\ntypedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);\ntypedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length);\n\n#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT)\n#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT)\n#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT)\n#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT)\n\n#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table)\n\n#endif /* WGL_EXT_display_color_table */\n\n/* ----------------------- WGL_EXT_extensions_string ----------------------- */\n\n#ifndef WGL_EXT_extensions_string\n#define WGL_EXT_extensions_string 1\n\ntypedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);\n\n#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT)\n\n#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string)\n\n#endif /* WGL_EXT_extensions_string */\n\n/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */\n\n#ifndef WGL_EXT_framebuffer_sRGB\n#define WGL_EXT_framebuffer_sRGB 1\n\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9\n\n#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB)\n\n#endif /* WGL_EXT_framebuffer_sRGB */\n\n/* ----------------------- WGL_EXT_make_current_read ----------------------- */\n\n#ifndef WGL_EXT_make_current_read\n#define WGL_EXT_make_current_read 1\n\n#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043\n\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID);\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\n\n#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT)\n#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT)\n\n#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read)\n\n#endif /* WGL_EXT_make_current_read */\n\n/* -------------------------- WGL_EXT_multisample -------------------------- */\n\n#ifndef WGL_EXT_multisample\n#define WGL_EXT_multisample 1\n\n#define WGL_SAMPLE_BUFFERS_EXT 0x2041\n#define WGL_SAMPLES_EXT 0x2042\n\n#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample)\n\n#endif /* WGL_EXT_multisample */\n\n/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */\n\n#ifndef WGL_EXT_pbuffer\n#define WGL_EXT_pbuffer 1\n\n#define WGL_DRAW_TO_PBUFFER_EXT 0x202D\n#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E\n#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030\n#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031\n#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032\n#define WGL_PBUFFER_LARGEST_EXT 0x2033\n#define WGL_PBUFFER_WIDTH_EXT 0x2034\n#define WGL_PBUFFER_HEIGHT_EXT 0x2035\n\nDECLARE_HANDLE(HPBUFFEREXT);\n\ntypedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue);\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);\n\n#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT)\n#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT)\n#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT)\n#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT)\n#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT)\n\n#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer)\n\n#endif /* WGL_EXT_pbuffer */\n\n/* -------------------------- WGL_EXT_pixel_format ------------------------- */\n\n#ifndef WGL_EXT_pixel_format\n#define WGL_EXT_pixel_format 1\n\n#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000\n#define WGL_DRAW_TO_WINDOW_EXT 0x2001\n#define WGL_DRAW_TO_BITMAP_EXT 0x2002\n#define WGL_ACCELERATION_EXT 0x2003\n#define WGL_NEED_PALETTE_EXT 0x2004\n#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005\n#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006\n#define WGL_SWAP_METHOD_EXT 0x2007\n#define WGL_NUMBER_OVERLAYS_EXT 0x2008\n#define WGL_NUMBER_UNDERLAYS_EXT 0x2009\n#define WGL_TRANSPARENT_EXT 0x200A\n#define WGL_TRANSPARENT_VALUE_EXT 0x200B\n#define WGL_SHARE_DEPTH_EXT 0x200C\n#define WGL_SHARE_STENCIL_EXT 0x200D\n#define WGL_SHARE_ACCUM_EXT 0x200E\n#define WGL_SUPPORT_GDI_EXT 0x200F\n#define WGL_SUPPORT_OPENGL_EXT 0x2010\n#define WGL_DOUBLE_BUFFER_EXT 0x2011\n#define WGL_STEREO_EXT 0x2012\n#define WGL_PIXEL_TYPE_EXT 0x2013\n#define WGL_COLOR_BITS_EXT 0x2014\n#define WGL_RED_BITS_EXT 0x2015\n#define WGL_RED_SHIFT_EXT 0x2016\n#define WGL_GREEN_BITS_EXT 0x2017\n#define WGL_GREEN_SHIFT_EXT 0x2018\n#define WGL_BLUE_BITS_EXT 0x2019\n#define WGL_BLUE_SHIFT_EXT 0x201A\n#define WGL_ALPHA_BITS_EXT 0x201B\n#define WGL_ALPHA_SHIFT_EXT 0x201C\n#define WGL_ACCUM_BITS_EXT 0x201D\n#define WGL_ACCUM_RED_BITS_EXT 0x201E\n#define WGL_ACCUM_GREEN_BITS_EXT 0x201F\n#define WGL_ACCUM_BLUE_BITS_EXT 0x2020\n#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021\n#define WGL_DEPTH_BITS_EXT 0x2022\n#define WGL_STENCIL_BITS_EXT 0x2023\n#define WGL_AUX_BUFFERS_EXT 0x2024\n#define WGL_NO_ACCELERATION_EXT 0x2025\n#define WGL_GENERIC_ACCELERATION_EXT 0x2026\n#define WGL_FULL_ACCELERATION_EXT 0x2027\n#define WGL_SWAP_EXCHANGE_EXT 0x2028\n#define WGL_SWAP_COPY_EXT 0x2029\n#define WGL_SWAP_UNDEFINED_EXT 0x202A\n#define WGL_TYPE_RGBA_EXT 0x202B\n#define WGL_TYPE_COLORINDEX_EXT 0x202C\n\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);\n\n#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT)\n#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT)\n#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT)\n\n#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format)\n\n#endif /* WGL_EXT_pixel_format */\n\n/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */\n\n#ifndef WGL_EXT_pixel_format_packed_float\n#define WGL_EXT_pixel_format_packed_float 1\n\n#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8\n\n#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float)\n\n#endif /* WGL_EXT_pixel_format_packed_float */\n\n/* -------------------------- WGL_EXT_swap_control ------------------------- */\n\n#ifndef WGL_EXT_swap_control\n#define WGL_EXT_swap_control 1\n\ntypedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);\n\n#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT)\n#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT)\n\n#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control)\n\n#endif /* WGL_EXT_swap_control */\n\n/* ----------------------- WGL_EXT_swap_control_tear ----------------------- */\n\n#ifndef WGL_EXT_swap_control_tear\n#define WGL_EXT_swap_control_tear 1\n\n#define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear)\n\n#endif /* WGL_EXT_swap_control_tear */\n\n/* --------------------- WGL_I3D_digital_video_control --------------------- */\n\n#ifndef WGL_I3D_digital_video_control\n#define WGL_I3D_digital_video_control 1\n\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051\n#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052\n#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053\n\ntypedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue);\ntypedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue);\n\n#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D)\n#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D)\n\n#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control)\n\n#endif /* WGL_I3D_digital_video_control */\n\n/* ----------------------------- WGL_I3D_gamma ----------------------------- */\n\n#ifndef WGL_I3D_gamma\n#define WGL_I3D_gamma 1\n\n#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E\n#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F\n\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue);\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue);\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue);\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue);\n\n#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D)\n#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D)\n#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D)\n#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D)\n\n#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma)\n\n#endif /* WGL_I3D_gamma */\n\n/* ---------------------------- WGL_I3D_genlock ---------------------------- */\n\n#ifndef WGL_I3D_genlock\n#define WGL_I3D_genlock 1\n\n#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044\n#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045\n#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046\n#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047\n#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048\n#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049\n#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A\n#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B\n#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C\n\ntypedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource);\ntypedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag);\ntypedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay);\n\n#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D)\n#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D)\n#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D)\n#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D)\n#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D)\n#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D)\n#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D)\n#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D)\n#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D)\n#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D)\n#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D)\n#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D)\n\n#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock)\n\n#endif /* WGL_I3D_genlock */\n\n/* -------------------------- WGL_I3D_image_buffer ------------------------- */\n\n#ifndef WGL_I3D_image_buffer\n#define WGL_I3D_image_buffer 1\n\n#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001\n#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002\n\ntypedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count);\ntypedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);\ntypedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);\ntypedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count);\n\n#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D)\n#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D)\n#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D)\n#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D)\n\n#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer)\n\n#endif /* WGL_I3D_image_buffer */\n\n/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */\n\n#ifndef WGL_I3D_swap_frame_lock\n#define WGL_I3D_swap_frame_lock 1\n\ntypedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID);\ntypedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID);\ntypedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag);\n\n#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D)\n#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D)\n#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D)\n#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D)\n\n#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock)\n\n#endif /* WGL_I3D_swap_frame_lock */\n\n/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */\n\n#ifndef WGL_I3D_swap_frame_usage\n#define WGL_I3D_swap_frame_usage 1\n\ntypedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\n\n#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D)\n#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D)\n#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D)\n#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D)\n\n#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage)\n\n#endif /* WGL_I3D_swap_frame_usage */\n\n/* --------------------------- WGL_NV_DX_interop --------------------------- */\n\n#ifndef WGL_NV_DX_interop\n#define WGL_NV_DX_interop 1\n\n#define WGL_ACCESS_READ_ONLY_NV 0x0000\n#define WGL_ACCESS_READ_WRITE_NV 0x0001\n#define WGL_ACCESS_WRITE_DISCARD_NV 0x0002\n\ntypedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);\ntypedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);\ntypedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);\ntypedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice);\ntypedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);\ntypedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle);\ntypedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);\ntypedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);\n\n#define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV)\n#define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV)\n#define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV)\n#define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV)\n#define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV)\n#define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV)\n#define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV)\n#define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV)\n\n#define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop)\n\n#endif /* WGL_NV_DX_interop */\n\n/* --------------------------- WGL_NV_DX_interop2 -------------------------- */\n\n#ifndef WGL_NV_DX_interop2\n#define WGL_NV_DX_interop2 1\n\n#define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2)\n\n#endif /* WGL_NV_DX_interop2 */\n\n/* --------------------------- WGL_NV_copy_image --------------------------- */\n\n#ifndef WGL_NV_copy_image\n#define WGL_NV_copy_image 1\n\ntypedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n\n#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV)\n\n#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image)\n\n#endif /* WGL_NV_copy_image */\n\n/* -------------------------- WGL_NV_float_buffer -------------------------- */\n\n#ifndef WGL_NV_float_buffer\n#define WGL_NV_float_buffer 1\n\n#define WGL_FLOAT_COMPONENTS_NV 0x20B0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4\n#define WGL_TEXTURE_FLOAT_R_NV 0x20B5\n#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6\n#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7\n#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8\n\n#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer)\n\n#endif /* WGL_NV_float_buffer */\n\n/* -------------------------- WGL_NV_gpu_affinity -------------------------- */\n\n#ifndef WGL_NV_gpu_affinity\n#define WGL_NV_gpu_affinity 1\n\n#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0\n#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1\n\nDECLARE_HANDLE(HGPUNV);\ntypedef struct _GPU_DEVICE {\n  DWORD cb; \n  CHAR DeviceName[32]; \n  CHAR DeviceString[128]; \n  DWORD Flags; \n  RECT rcVirtualScreen; \n} GPU_DEVICE, *PGPU_DEVICE;\n\ntypedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);\ntypedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);\ntypedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);\n\n#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV)\n#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV)\n#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV)\n#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV)\n#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV)\n\n#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity)\n\n#endif /* WGL_NV_gpu_affinity */\n\n/* ---------------------- WGL_NV_multisample_coverage ---------------------- */\n\n#ifndef WGL_NV_multisample_coverage\n#define WGL_NV_multisample_coverage 1\n\n#define WGL_COVERAGE_SAMPLES_NV 0x2042\n#define WGL_COLOR_SAMPLES_NV 0x20B9\n\n#define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage)\n\n#endif /* WGL_NV_multisample_coverage */\n\n/* -------------------------- WGL_NV_present_video ------------------------- */\n\n#ifndef WGL_NV_present_video\n#define WGL_NV_present_video 1\n\n#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0\n\nDECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);\n\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList);\ntypedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList);\ntypedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue);\n\n#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV)\n#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV)\n#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV)\n\n#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video)\n\n#endif /* WGL_NV_present_video */\n\n/* ---------------------- WGL_NV_render_depth_texture ---------------------- */\n\n#ifndef WGL_NV_render_depth_texture\n#define WGL_NV_render_depth_texture 1\n\n#define WGL_NO_TEXTURE_ARB 0x2077\n#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4\n#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5\n#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6\n#define WGL_DEPTH_COMPONENT_NV 0x20A7\n\n#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture)\n\n#endif /* WGL_NV_render_depth_texture */\n\n/* -------------------- WGL_NV_render_texture_rectangle -------------------- */\n\n#ifndef WGL_NV_render_texture_rectangle\n#define WGL_NV_render_texture_rectangle 1\n\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1\n#define WGL_TEXTURE_RECTANGLE_NV 0x20A2\n\n#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle)\n\n#endif /* WGL_NV_render_texture_rectangle */\n\n/* --------------------------- WGL_NV_swap_group --------------------------- */\n\n#ifndef WGL_NV_swap_group\n#define WGL_NV_swap_group 1\n\ntypedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);\ntypedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count);\ntypedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers);\ntypedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier);\ntypedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);\n\n#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV)\n#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV)\n#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV)\n#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV)\n#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV)\n#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV)\n\n#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group)\n\n#endif /* WGL_NV_swap_group */\n\n/* ----------------------- WGL_NV_vertex_array_range ----------------------- */\n\n#ifndef WGL_NV_vertex_array_range\n#define WGL_NV_vertex_array_range 1\n\ntypedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority);\ntypedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);\n\n#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV)\n#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV)\n\n#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range)\n\n#endif /* WGL_NV_vertex_array_range */\n\n/* -------------------------- WGL_NV_video_capture ------------------------- */\n\n#ifndef WGL_NV_video_capture\n#define WGL_NV_video_capture 1\n\n#define WGL_UNIQUE_ID_NV 0x20CE\n#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF\n\nDECLARE_HANDLE(HVIDEOINPUTDEVICENV);\n\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\ntypedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList);\ntypedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\ntypedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n\n#define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV)\n#define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV)\n#define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV)\n#define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV)\n#define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV)\n\n#define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture)\n\n#endif /* WGL_NV_video_capture */\n\n/* -------------------------- WGL_NV_video_output -------------------------- */\n\n#ifndef WGL_NV_video_output\n#define WGL_NV_video_output 1\n\n#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0\n#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1\n#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2\n#define WGL_VIDEO_OUT_COLOR_NV 0x20C3\n#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4\n#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5\n#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6\n#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7\n#define WGL_VIDEO_OUT_FRAME 0x20C8\n#define WGL_VIDEO_OUT_FIELD_1 0x20C9\n#define WGL_VIDEO_OUT_FIELD_2 0x20CA\n#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB\n#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC\n\nDECLARE_HANDLE(HPVIDEODEV);\n\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\ntypedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice);\ntypedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);\ntypedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock);\n\n#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV)\n#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV)\n#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV)\n#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV)\n#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV)\n#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV)\n\n#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output)\n\n#endif /* WGL_NV_video_output */\n\n/* -------------------------- WGL_OML_sync_control ------------------------- */\n\n#ifndef WGL_OML_sync_control\n#define WGL_OML_sync_control 1\n\ntypedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator);\ntypedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc);\ntypedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\ntypedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\ntypedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc);\ntypedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc);\n\n#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML)\n#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML)\n#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML)\n#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML)\n#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML)\n#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML)\n\n#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control)\n\n#endif /* WGL_OML_sync_control */\n\n/* ------------------------------------------------------------------------- */\n\n#ifdef GLEW_MX\n#define WGLEW_FUN_EXPORT\n#define WGLEW_VAR_EXPORT\n#else\n#define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT\n#define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT\n#endif /* GLEW_MX */\n\n#ifdef GLEW_MX\nstruct WGLEWContextStruct\n{\n#endif /* GLEW_MX */\n\nWGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL;\n\nWGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD;\nWGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD;\nWGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD;\nWGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD;\nWGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD;\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD;\nWGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD;\nWGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD;\nWGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD;\n\nWGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB;\nWGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB;\nWGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB;\nWGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB;\n\nWGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB;\n\nWGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB;\n\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB;\nWGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB;\n\nWGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB;\nWGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB;\nWGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB;\nWGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB;\nWGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB;\n\nWGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB;\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB;\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB;\n\nWGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB;\nWGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB;\nWGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB;\n\nWGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT;\nWGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT;\nWGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT;\nWGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT;\n\nWGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT;\n\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT;\nWGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT;\n\nWGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT;\nWGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT;\nWGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT;\nWGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT;\nWGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT;\n\nWGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT;\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT;\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT;\n\nWGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT;\nWGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT;\n\nWGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D;\nWGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D;\n\nWGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D;\nWGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D;\nWGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D;\nWGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D;\n\nWGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D;\nWGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D;\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D;\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D;\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D;\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D;\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D;\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D;\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D;\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D;\nWGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D;\nWGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D;\n\nWGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D;\nWGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D;\nWGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D;\nWGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D;\n\nWGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D;\nWGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D;\nWGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D;\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D;\n\nWGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D;\nWGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D;\nWGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D;\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D;\n\nWGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV;\nWGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV;\nWGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV;\nWGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV;\nWGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV;\nWGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;\n\nWGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;\n\nWGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;\nWGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;\nWGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;\nWGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV;\nWGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV;\n\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV;\nWGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV;\n\nWGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV;\nWGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV;\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV;\nWGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV;\nWGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV;\nWGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV;\n\nWGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV;\nWGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV;\n\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV;\nWGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV;\n\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV;\nWGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV;\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV;\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV;\nWGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV;\n\nWGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML;\nWGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML;\nWGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML;\nWGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML;\nWGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML;\nWGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output;\nWGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control;\n\n#ifdef GLEW_MX\n}; /* WGLEWContextStruct */\n#endif /* GLEW_MX */\n\n/* ------------------------------------------------------------------------- */\n\n#ifdef GLEW_MX\n\ntypedef struct WGLEWContextStruct WGLEWContext;\nGLEWAPI GLenum GLEWAPIENTRY wglewContextInit (WGLEWContext *ctx);\nGLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, const char *name);\n\n#define wglewInit() wglewContextInit(wglewGetContext())\n#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x)\n\n#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x))\n#define WGLEW_GET_FUN(x) wglewGetContext()->x\n\n#else /* GLEW_MX */\n\n#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)\n#define WGLEW_GET_FUN(x) x\n\nGLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);\n\n#endif /* GLEW_MX */\n\nGLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name);\n\n#ifdef __cplusplus\n}\n#endif\n\n#undef GLEWAPI\n\n#endif /* __wglew_h__ */\n"
  },
  {
    "path": "deps/glew/src/glew.c",
    "content": "/*\n** The OpenGL Extension Wrangler Library\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\n** Copyright (C) 2002, Lev Povalahev\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without \n** modification, are permitted provided that the following conditions are met:\n** \n** * Redistributions of source code must retain the above copyright notice, \n**   this list of conditions and the following disclaimer.\n** * Redistributions in binary form must reproduce the above copyright notice, \n**   this list of conditions and the following disclaimer in the documentation \n**   and/or other materials provided with the distribution.\n** * The name of the author may be used to endorse or promote products \n**   derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n** THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include <GL/glew.h>\n\n#if defined(_WIN32)\n#  include <GL/wglew.h>\n#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))\n#  include <GL/glxew.h>\n#endif\n\n/*\n * Define glewGetContext and related helper macros.\n */\n#ifdef GLEW_MX\n#  define glewGetContext() ctx\n#  ifdef _WIN32\n#    define GLEW_CONTEXT_ARG_DEF_INIT GLEWContext* ctx\n#    define GLEW_CONTEXT_ARG_VAR_INIT ctx\n#    define wglewGetContext() ctx\n#    define WGLEW_CONTEXT_ARG_DEF_INIT WGLEWContext* ctx\n#    define WGLEW_CONTEXT_ARG_DEF_LIST WGLEWContext* ctx\n#  else /* _WIN32 */\n#    define GLEW_CONTEXT_ARG_DEF_INIT void\n#    define GLEW_CONTEXT_ARG_VAR_INIT\n#    define glxewGetContext() ctx\n#    define GLXEW_CONTEXT_ARG_DEF_INIT void\n#    define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx\n#  endif /* _WIN32 */\n#  define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx\n#else /* GLEW_MX */\n#  define GLEW_CONTEXT_ARG_DEF_INIT void\n#  define GLEW_CONTEXT_ARG_VAR_INIT\n#  define GLEW_CONTEXT_ARG_DEF_LIST void\n#  define WGLEW_CONTEXT_ARG_DEF_INIT void\n#  define WGLEW_CONTEXT_ARG_DEF_LIST void\n#  define GLXEW_CONTEXT_ARG_DEF_INIT void\n#  define GLXEW_CONTEXT_ARG_DEF_LIST void\n#endif /* GLEW_MX */\n\n#if defined(__sgi) || defined (__sun) || defined(GLEW_APPLE_GLX)\n#include <dlfcn.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nvoid* dlGetProcAddress (const GLubyte* name)\n{\n  static void* h = NULL;\n  static void* gpa;\n\n  if (h == NULL)\n  {\n    if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL;\n    gpa = dlsym(h, \"glXGetProcAddress\");\n  }\n\n  if (gpa != NULL)\n    return ((void*(*)(const GLubyte*))gpa)(name);\n  else\n    return dlsym(h, (const char*)name);\n}\n#endif /* __sgi || __sun || GLEW_APPLE_GLX */\n\n#if defined(__APPLE__)\n#include <stdlib.h>\n#include <string.h>\n#include <AvailabilityMacros.h>\n\n#ifdef MAC_OS_X_VERSION_10_3\n\n#include <dlfcn.h>\n\nvoid* NSGLGetProcAddress (const GLubyte *name)\n{\n  static void* image = NULL;\n  void* addr;\n  if (NULL == image) \n  {\n#ifdef GLEW_REGAL\n    image = dlopen(\"libRegal.dylib\", RTLD_LAZY);\n#else\n    image = dlopen(\"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL\", RTLD_LAZY);\n#endif\n  }\n  if( !image ) return NULL;\n  addr = dlsym(image, (const char*)name);\n  if( addr ) return addr;\n#ifdef GLEW_APPLE_GLX\n  return dlGetProcAddress( name ); // try next for glx symbols\n#else\n  return NULL;\n#endif\n}\n#else\n\n#include <mach-o/dyld.h>\n\nvoid* NSGLGetProcAddress (const GLubyte *name)\n{\n  static const struct mach_header* image = NULL;\n  NSSymbol symbol;\n  char* symbolName;\n  if (NULL == image)\n  {\n#ifdef GLEW_REGAL\n    image = NSAddImage(\"libRegal.dylib\", NSADDIMAGE_OPTION_RETURN_ON_ERROR);\n#else\n    image = NSAddImage(\"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL\", NSADDIMAGE_OPTION_RETURN_ON_ERROR);\n#endif\n  }\n  /* prepend a '_' for the Unix C symbol mangling convention */\n  symbolName = malloc(strlen((const char*)name) + 2);\n  strcpy(symbolName+1, (const char*)name);\n  symbolName[0] = '_';\n  symbol = NULL;\n  /* if (NSIsSymbolNameDefined(symbolName))\n\t symbol = NSLookupAndBindSymbol(symbolName); */\n  symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;\n  free(symbolName);\n  if( symbol ) return NSAddressOfSymbol(symbol);\n#ifdef GLEW_APPLE_GLX\n  return dlGetProcAddress( name ); // try next for glx symbols\n#else\n  return NULL;\n#endif\n}\n#endif /* MAC_OS_X_VERSION_10_3 */\n#endif /* __APPLE__ */\n\n/*\n * Define glewGetProcAddress.\n */\n#if defined(_WIN32)\n#  define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name)\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n#  define glewGetProcAddress(name) NSGLGetProcAddress(name)\n#elif defined(__sgi) || defined(__sun)\n#  define glewGetProcAddress(name) dlGetProcAddress(name)\n#elif defined(__ANDROID__)\n#  define glewGetProcAddress(name) NULL /* TODO */\n#else /* __linux */\n#  define glewGetProcAddress(name) (*glXGetProcAddressARB)(name)\n#endif\n\n/*\n * Define GLboolean const cast.\n */\n#define CONST_CAST(x) (*(GLboolean*)&x)\n\n/*\n * GLEW, just like OpenGL or GLU, does not rely on the standard C library.\n * These functions implement the functionality required in this file.\n */\nstatic GLuint _glewStrLen (const GLubyte* s)\n{\n  GLuint i=0;\n  if (s == NULL) return 0;\n  while (s[i] != '\\0') i++;\n  return i;\n}\n\nstatic GLuint _glewStrCLen (const GLubyte* s, GLubyte c)\n{\n  GLuint i=0;\n  if (s == NULL) return 0;\n  while (s[i] != '\\0' && s[i] != c) i++;\n  return (s[i] == '\\0' || s[i] == c) ? i : 0;\n}\n\nstatic GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)\n{\n  GLuint i=0;\n  if(a == NULL || b == NULL)\n    return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE;\n  while (i < n && a[i] != '\\0' && b[i] != '\\0' && a[i] == b[i]) i++;\n  return i == n ? GL_TRUE : GL_FALSE;\n}\n\nstatic GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)\n{\n  while (*na > 0 && (**a == ' ' || **a == '\\n' || **a == '\\r' || **a == '\\t'))\n  {\n    (*a)++;\n    (*na)--;\n  }\n  if(*na >= nb)\n  {\n    GLuint i=0;\n    while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;\n    if(i == nb)\n    {\n      *a = *a + nb;\n      *na = *na - nb;\n      return GL_TRUE;\n    }\n  }\n  return GL_FALSE;\n}\n\nstatic GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)\n{\n  if(*na >= nb)\n  {\n    GLuint i=0;\n    while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;\n    if(i == nb)\n    {\n      *a = *a + nb;\n      *na = *na - nb;\n      return GL_TRUE;\n    }\n  }\n  return GL_FALSE;\n}\n\nstatic GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb)\n{\n  if(*na >= nb)\n  {\n    GLuint i=0;\n    while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++;\n    if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\\n' || (*a)[i] == '\\r' || (*a)[i] == '\\t'))\n    {\n      *a = *a + nb;\n      *na = *na - nb;\n      return GL_TRUE;\n    }\n  }\n  return GL_FALSE;\n}\n\n/*\n * Search for name in the extensions string. Use of strstr()\n * is not sufficient because extension names can be prefixes of\n * other extension names. Could use strtok() but the constant\n * string returned by glGetString might be in read-only memory.\n */\nstatic GLboolean _glewSearchExtension (const char* name, const GLubyte *start, const GLubyte *end)\n{\n  const GLubyte* p;\n  GLuint len = _glewStrLen((const GLubyte*)name);\n  p = start;\n  while (p < end)\n  {\n    GLuint n = _glewStrCLen(p, ' ');\n    if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE;\n    p += n+1;\n  }\n  return GL_FALSE;\n}\n\n#if !defined(_WIN32) || !defined(GLEW_MX)\n\nPFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D = NULL;\nPFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements = NULL;\nPFNGLTEXIMAGE3DPROC __glewTexImage3D = NULL;\nPFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D = NULL;\n\nPFNGLACTIVETEXTUREPROC __glewActiveTexture = NULL;\nPFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture = NULL;\nPFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D = NULL;\nPFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D = NULL;\nPFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D = NULL;\nPFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage = NULL;\nPFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd = NULL;\nPFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf = NULL;\nPFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd = NULL;\nPFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf = NULL;\nPFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d = NULL;\nPFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv = NULL;\nPFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f = NULL;\nPFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv = NULL;\nPFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i = NULL;\nPFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv = NULL;\nPFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s = NULL;\nPFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv = NULL;\nPFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d = NULL;\nPFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv = NULL;\nPFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f = NULL;\nPFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv = NULL;\nPFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i = NULL;\nPFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv = NULL;\nPFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s = NULL;\nPFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv = NULL;\nPFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d = NULL;\nPFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv = NULL;\nPFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f = NULL;\nPFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv = NULL;\nPFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i = NULL;\nPFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv = NULL;\nPFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s = NULL;\nPFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv = NULL;\nPFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d = NULL;\nPFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv = NULL;\nPFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f = NULL;\nPFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv = NULL;\nPFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i = NULL;\nPFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv = NULL;\nPFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s = NULL;\nPFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv = NULL;\nPFNGLSAMPLECOVERAGEPROC __glewSampleCoverage = NULL;\n\nPFNGLBLENDCOLORPROC __glewBlendColor = NULL;\nPFNGLBLENDEQUATIONPROC __glewBlendEquation = NULL;\nPFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate = NULL;\nPFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer = NULL;\nPFNGLFOGCOORDDPROC __glewFogCoordd = NULL;\nPFNGLFOGCOORDDVPROC __glewFogCoorddv = NULL;\nPFNGLFOGCOORDFPROC __glewFogCoordf = NULL;\nPFNGLFOGCOORDFVPROC __glewFogCoordfv = NULL;\nPFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays = NULL;\nPFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements = NULL;\nPFNGLPOINTPARAMETERFPROC __glewPointParameterf = NULL;\nPFNGLPOINTPARAMETERFVPROC __glewPointParameterfv = NULL;\nPFNGLPOINTPARAMETERIPROC __glewPointParameteri = NULL;\nPFNGLPOINTPARAMETERIVPROC __glewPointParameteriv = NULL;\nPFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b = NULL;\nPFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv = NULL;\nPFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d = NULL;\nPFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv = NULL;\nPFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f = NULL;\nPFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv = NULL;\nPFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i = NULL;\nPFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv = NULL;\nPFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s = NULL;\nPFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv = NULL;\nPFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub = NULL;\nPFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv = NULL;\nPFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui = NULL;\nPFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv = NULL;\nPFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us = NULL;\nPFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv = NULL;\nPFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer = NULL;\nPFNGLWINDOWPOS2DPROC __glewWindowPos2d = NULL;\nPFNGLWINDOWPOS2DVPROC __glewWindowPos2dv = NULL;\nPFNGLWINDOWPOS2FPROC __glewWindowPos2f = NULL;\nPFNGLWINDOWPOS2FVPROC __glewWindowPos2fv = NULL;\nPFNGLWINDOWPOS2IPROC __glewWindowPos2i = NULL;\nPFNGLWINDOWPOS2IVPROC __glewWindowPos2iv = NULL;\nPFNGLWINDOWPOS2SPROC __glewWindowPos2s = NULL;\nPFNGLWINDOWPOS2SVPROC __glewWindowPos2sv = NULL;\nPFNGLWINDOWPOS3DPROC __glewWindowPos3d = NULL;\nPFNGLWINDOWPOS3DVPROC __glewWindowPos3dv = NULL;\nPFNGLWINDOWPOS3FPROC __glewWindowPos3f = NULL;\nPFNGLWINDOWPOS3FVPROC __glewWindowPos3fv = NULL;\nPFNGLWINDOWPOS3IPROC __glewWindowPos3i = NULL;\nPFNGLWINDOWPOS3IVPROC __glewWindowPos3iv = NULL;\nPFNGLWINDOWPOS3SPROC __glewWindowPos3s = NULL;\nPFNGLWINDOWPOS3SVPROC __glewWindowPos3sv = NULL;\n\nPFNGLBEGINQUERYPROC __glewBeginQuery = NULL;\nPFNGLBINDBUFFERPROC __glewBindBuffer = NULL;\nPFNGLBUFFERDATAPROC __glewBufferData = NULL;\nPFNGLBUFFERSUBDATAPROC __glewBufferSubData = NULL;\nPFNGLDELETEBUFFERSPROC __glewDeleteBuffers = NULL;\nPFNGLDELETEQUERIESPROC __glewDeleteQueries = NULL;\nPFNGLENDQUERYPROC __glewEndQuery = NULL;\nPFNGLGENBUFFERSPROC __glewGenBuffers = NULL;\nPFNGLGENQUERIESPROC __glewGenQueries = NULL;\nPFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv = NULL;\nPFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv = NULL;\nPFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData = NULL;\nPFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv = NULL;\nPFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv = NULL;\nPFNGLGETQUERYIVPROC __glewGetQueryiv = NULL;\nPFNGLISBUFFERPROC __glewIsBuffer = NULL;\nPFNGLISQUERYPROC __glewIsQuery = NULL;\nPFNGLMAPBUFFERPROC __glewMapBuffer = NULL;\nPFNGLUNMAPBUFFERPROC __glewUnmapBuffer = NULL;\n\nPFNGLATTACHSHADERPROC __glewAttachShader = NULL;\nPFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation = NULL;\nPFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate = NULL;\nPFNGLCOMPILESHADERPROC __glewCompileShader = NULL;\nPFNGLCREATEPROGRAMPROC __glewCreateProgram = NULL;\nPFNGLCREATESHADERPROC __glewCreateShader = NULL;\nPFNGLDELETEPROGRAMPROC __glewDeleteProgram = NULL;\nPFNGLDELETESHADERPROC __glewDeleteShader = NULL;\nPFNGLDETACHSHADERPROC __glewDetachShader = NULL;\nPFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray = NULL;\nPFNGLDRAWBUFFERSPROC __glewDrawBuffers = NULL;\nPFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray = NULL;\nPFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib = NULL;\nPFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform = NULL;\nPFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders = NULL;\nPFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation = NULL;\nPFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog = NULL;\nPFNGLGETPROGRAMIVPROC __glewGetProgramiv = NULL;\nPFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog = NULL;\nPFNGLGETSHADERSOURCEPROC __glewGetShaderSource = NULL;\nPFNGLGETSHADERIVPROC __glewGetShaderiv = NULL;\nPFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation = NULL;\nPFNGLGETUNIFORMFVPROC __glewGetUniformfv = NULL;\nPFNGLGETUNIFORMIVPROC __glewGetUniformiv = NULL;\nPFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv = NULL;\nPFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv = NULL;\nPFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv = NULL;\nPFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv = NULL;\nPFNGLISPROGRAMPROC __glewIsProgram = NULL;\nPFNGLISSHADERPROC __glewIsShader = NULL;\nPFNGLLINKPROGRAMPROC __glewLinkProgram = NULL;\nPFNGLSHADERSOURCEPROC __glewShaderSource = NULL;\nPFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate = NULL;\nPFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate = NULL;\nPFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate = NULL;\nPFNGLUNIFORM1FPROC __glewUniform1f = NULL;\nPFNGLUNIFORM1FVPROC __glewUniform1fv = NULL;\nPFNGLUNIFORM1IPROC __glewUniform1i = NULL;\nPFNGLUNIFORM1IVPROC __glewUniform1iv = NULL;\nPFNGLUNIFORM2FPROC __glewUniform2f = NULL;\nPFNGLUNIFORM2FVPROC __glewUniform2fv = NULL;\nPFNGLUNIFORM2IPROC __glewUniform2i = NULL;\nPFNGLUNIFORM2IVPROC __glewUniform2iv = NULL;\nPFNGLUNIFORM3FPROC __glewUniform3f = NULL;\nPFNGLUNIFORM3FVPROC __glewUniform3fv = NULL;\nPFNGLUNIFORM3IPROC __glewUniform3i = NULL;\nPFNGLUNIFORM3IVPROC __glewUniform3iv = NULL;\nPFNGLUNIFORM4FPROC __glewUniform4f = NULL;\nPFNGLUNIFORM4FVPROC __glewUniform4fv = NULL;\nPFNGLUNIFORM4IPROC __glewUniform4i = NULL;\nPFNGLUNIFORM4IVPROC __glewUniform4iv = NULL;\nPFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv = NULL;\nPFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv = NULL;\nPFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv = NULL;\nPFNGLUSEPROGRAMPROC __glewUseProgram = NULL;\nPFNGLVALIDATEPROGRAMPROC __glewValidateProgram = NULL;\nPFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d = NULL;\nPFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv = NULL;\nPFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f = NULL;\nPFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv = NULL;\nPFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s = NULL;\nPFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv = NULL;\nPFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d = NULL;\nPFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv = NULL;\nPFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f = NULL;\nPFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv = NULL;\nPFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s = NULL;\nPFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv = NULL;\nPFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d = NULL;\nPFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv = NULL;\nPFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f = NULL;\nPFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv = NULL;\nPFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s = NULL;\nPFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv = NULL;\nPFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv = NULL;\nPFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv = NULL;\nPFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv = NULL;\nPFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub = NULL;\nPFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv = NULL;\nPFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv = NULL;\nPFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv = NULL;\nPFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv = NULL;\nPFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d = NULL;\nPFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv = NULL;\nPFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f = NULL;\nPFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv = NULL;\nPFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv = NULL;\nPFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s = NULL;\nPFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv = NULL;\nPFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv = NULL;\nPFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv = NULL;\nPFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv = NULL;\nPFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer = NULL;\n\nPFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv = NULL;\nPFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv = NULL;\nPFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv = NULL;\nPFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv = NULL;\nPFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv = NULL;\nPFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv = NULL;\n\nPFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender = NULL;\nPFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback = NULL;\nPFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation = NULL;\nPFNGLCLAMPCOLORPROC __glewClampColor = NULL;\nPFNGLCLEARBUFFERFIPROC __glewClearBufferfi = NULL;\nPFNGLCLEARBUFFERFVPROC __glewClearBufferfv = NULL;\nPFNGLCLEARBUFFERIVPROC __glewClearBufferiv = NULL;\nPFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv = NULL;\nPFNGLCOLORMASKIPROC __glewColorMaski = NULL;\nPFNGLDISABLEIPROC __glewDisablei = NULL;\nPFNGLENABLEIPROC __glewEnablei = NULL;\nPFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender = NULL;\nPFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback = NULL;\nPFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL;\nPFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation = NULL;\nPFNGLGETSTRINGIPROC __glewGetStringi = NULL;\nPFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv = NULL;\nPFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv = NULL;\nPFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying = NULL;\nPFNGLGETUNIFORMUIVPROC __glewGetUniformuiv = NULL;\nPFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv = NULL;\nPFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv = NULL;\nPFNGLISENABLEDIPROC __glewIsEnabledi = NULL;\nPFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv = NULL;\nPFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv = NULL;\nPFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings = NULL;\nPFNGLUNIFORM1UIPROC __glewUniform1ui = NULL;\nPFNGLUNIFORM1UIVPROC __glewUniform1uiv = NULL;\nPFNGLUNIFORM2UIPROC __glewUniform2ui = NULL;\nPFNGLUNIFORM2UIVPROC __glewUniform2uiv = NULL;\nPFNGLUNIFORM3UIPROC __glewUniform3ui = NULL;\nPFNGLUNIFORM3UIVPROC __glewUniform3uiv = NULL;\nPFNGLUNIFORM4UIPROC __glewUniform4ui = NULL;\nPFNGLUNIFORM4UIVPROC __glewUniform4uiv = NULL;\nPFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i = NULL;\nPFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv = NULL;\nPFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui = NULL;\nPFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv = NULL;\nPFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i = NULL;\nPFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv = NULL;\nPFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui = NULL;\nPFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv = NULL;\nPFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i = NULL;\nPFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv = NULL;\nPFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui = NULL;\nPFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv = NULL;\nPFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv = NULL;\nPFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i = NULL;\nPFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv = NULL;\nPFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv = NULL;\nPFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv = NULL;\nPFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui = NULL;\nPFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv = NULL;\nPFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv = NULL;\nPFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer = NULL;\n\nPFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced = NULL;\nPFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced = NULL;\nPFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex = NULL;\nPFNGLTEXBUFFERPROC __glewTexBuffer = NULL;\n\nPFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture = NULL;\nPFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v = NULL;\nPFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v = NULL;\n\nPFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor = NULL;\n\nPFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei = NULL;\nPFNGLBLENDEQUATIONIPROC __glewBlendEquationi = NULL;\nPFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei = NULL;\nPFNGLBLENDFUNCIPROC __glewBlendFunci = NULL;\nPFNGLMINSAMPLESHADINGPROC __glewMinSampleShading = NULL;\n\nPFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL;\n\nPFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD = NULL;\nPFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD = NULL;\nPFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD = NULL;\nPFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD = NULL;\n\nPFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD = NULL;\nPFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD = NULL;\nPFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD = NULL;\nPFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD = NULL;\n\nPFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD = NULL;\nPFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD = NULL;\n\nPFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD = NULL;\nPFNGLGENNAMESAMDPROC __glewGenNamesAMD = NULL;\nPFNGLISNAMEAMDPROC __glewIsNameAMD = NULL;\n\nPFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD = NULL;\nPFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD = NULL;\nPFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD = NULL;\nPFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD = NULL;\nPFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD = NULL;\nPFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD = NULL;\nPFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD = NULL;\nPFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD = NULL;\nPFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD = NULL;\nPFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD = NULL;\nPFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD = NULL;\n\nPFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD = NULL;\n\nPFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD = NULL;\n\nPFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD = NULL;\nPFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD = NULL;\n\nPFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE = NULL;\nPFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE = NULL;\nPFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE = NULL;\nPFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE = NULL;\nPFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE = NULL;\n\nPFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE = NULL;\nPFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE = NULL;\nPFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE = NULL;\nPFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE = NULL;\nPFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE = NULL;\nPFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE = NULL;\nPFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE = NULL;\nPFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE = NULL;\n\nPFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE = NULL;\nPFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE = NULL;\n\nPFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE = NULL;\nPFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE = NULL;\nPFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE = NULL;\n\nPFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE = NULL;\nPFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE = NULL;\n\nPFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE = NULL;\nPFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE = NULL;\nPFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE = NULL;\nPFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE = NULL;\n\nPFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE = NULL;\nPFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE = NULL;\nPFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE = NULL;\n\nPFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE = NULL;\nPFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE = NULL;\nPFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE = NULL;\nPFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE = NULL;\nPFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE = NULL;\nPFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE = NULL;\nPFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE = NULL;\n\nPFNGLCLEARDEPTHFPROC __glewClearDepthf = NULL;\nPFNGLDEPTHRANGEFPROC __glewDepthRangef = NULL;\nPFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat = NULL;\nPFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler = NULL;\nPFNGLSHADERBINARYPROC __glewShaderBinary = NULL;\n\nPFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance = NULL;\nPFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance = NULL;\nPFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance = NULL;\n\nPFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed = NULL;\nPFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex = NULL;\n\nPFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB = NULL;\n\nPFNGLCLEARBUFFERDATAPROC __glewClearBufferData = NULL;\nPFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData = NULL;\nPFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT = NULL;\nPFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT = NULL;\n\nPFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL;\n\nPFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute = NULL;\nPFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect = NULL;\n\nPFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData = NULL;\n\nPFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData = NULL;\n\nPFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB = NULL;\nPFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB = NULL;\nPFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB = NULL;\nPFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB = NULL;\n\nPFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB = NULL;\n\nPFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB = NULL;\nPFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB = NULL;\nPFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB = NULL;\nPFNGLBLENDFUNCIARBPROC __glewBlendFunciARB = NULL;\n\nPFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex = NULL;\nPFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex = NULL;\nPFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex = NULL;\nPFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex = NULL;\n\nPFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect = NULL;\nPFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect = NULL;\n\nPFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri = NULL;\nPFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv = NULL;\nPFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT = NULL;\n\nPFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer = NULL;\nPFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer = NULL;\nPFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer = NULL;\nPFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL;\nPFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL;\nPFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL;\nPFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL;\nPFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL;\nPFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL;\nPFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL;\nPFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL;\nPFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers = NULL;\nPFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers = NULL;\nPFNGLGENERATEMIPMAPPROC __glewGenerateMipmap = NULL;\nPFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv = NULL;\nPFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv = NULL;\nPFNGLISFRAMEBUFFERPROC __glewIsFramebuffer = NULL;\nPFNGLISRENDERBUFFERPROC __glewIsRenderbuffer = NULL;\nPFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage = NULL;\nPFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample = NULL;\n\nPFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB = NULL;\nPFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB = NULL;\nPFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB = NULL;\nPFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB = NULL;\n\nPFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary = NULL;\nPFNGLPROGRAMBINARYPROC __glewProgramBinary = NULL;\nPFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri = NULL;\n\nPFNGLGETUNIFORMDVPROC __glewGetUniformdv = NULL;\nPFNGLUNIFORM1DPROC __glewUniform1d = NULL;\nPFNGLUNIFORM1DVPROC __glewUniform1dv = NULL;\nPFNGLUNIFORM2DPROC __glewUniform2d = NULL;\nPFNGLUNIFORM2DVPROC __glewUniform2dv = NULL;\nPFNGLUNIFORM3DPROC __glewUniform3d = NULL;\nPFNGLUNIFORM3DVPROC __glewUniform3dv = NULL;\nPFNGLUNIFORM4DPROC __glewUniform4d = NULL;\nPFNGLUNIFORM4DVPROC __glewUniform4dv = NULL;\nPFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv = NULL;\nPFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv = NULL;\nPFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv = NULL;\nPFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv = NULL;\nPFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv = NULL;\nPFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv = NULL;\nPFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv = NULL;\nPFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv = NULL;\nPFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv = NULL;\n\nPFNGLCOLORSUBTABLEPROC __glewColorSubTable = NULL;\nPFNGLCOLORTABLEPROC __glewColorTable = NULL;\nPFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv = NULL;\nPFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv = NULL;\nPFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D = NULL;\nPFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D = NULL;\nPFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf = NULL;\nPFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv = NULL;\nPFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri = NULL;\nPFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv = NULL;\nPFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable = NULL;\nPFNGLCOPYCOLORTABLEPROC __glewCopyColorTable = NULL;\nPFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D = NULL;\nPFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D = NULL;\nPFNGLGETCOLORTABLEPROC __glewGetColorTable = NULL;\nPFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv = NULL;\nPFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv = NULL;\nPFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter = NULL;\nPFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv = NULL;\nPFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv = NULL;\nPFNGLGETHISTOGRAMPROC __glewGetHistogram = NULL;\nPFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv = NULL;\nPFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv = NULL;\nPFNGLGETMINMAXPROC __glewGetMinmax = NULL;\nPFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv = NULL;\nPFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv = NULL;\nPFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter = NULL;\nPFNGLHISTOGRAMPROC __glewHistogram = NULL;\nPFNGLMINMAXPROC __glewMinmax = NULL;\nPFNGLRESETHISTOGRAMPROC __glewResetHistogram = NULL;\nPFNGLRESETMINMAXPROC __glewResetMinmax = NULL;\nPFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D = NULL;\n\nPFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL;\nPFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL;\nPFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB = NULL;\n\nPFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ = NULL;\n\nPFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v = NULL;\n\nPFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData = NULL;\nPFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData = NULL;\nPFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer = NULL;\nPFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer = NULL;\nPFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage = NULL;\nPFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage = NULL;\n\nPFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange = NULL;\nPFNGLMAPBUFFERRANGEPROC __glewMapBufferRange = NULL;\n\nPFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB = NULL;\nPFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB = NULL;\nPFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB = NULL;\nPFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB = NULL;\nPFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB = NULL;\n\nPFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect = NULL;\nPFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect = NULL;\n\nPFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB = NULL;\n\nPFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB = NULL;\nPFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB = NULL;\nPFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB = NULL;\nPFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB = NULL;\nPFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB = NULL;\nPFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB = NULL;\nPFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB = NULL;\nPFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB = NULL;\nPFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB = NULL;\nPFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB = NULL;\nPFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB = NULL;\nPFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB = NULL;\nPFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB = NULL;\nPFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB = NULL;\nPFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB = NULL;\nPFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB = NULL;\nPFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB = NULL;\nPFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB = NULL;\nPFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB = NULL;\nPFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB = NULL;\nPFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB = NULL;\nPFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB = NULL;\nPFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB = NULL;\nPFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB = NULL;\nPFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB = NULL;\nPFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB = NULL;\nPFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB = NULL;\nPFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB = NULL;\nPFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB = NULL;\nPFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB = NULL;\nPFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB = NULL;\nPFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB = NULL;\nPFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB = NULL;\nPFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB = NULL;\n\nPFNGLBEGINQUERYARBPROC __glewBeginQueryARB = NULL;\nPFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB = NULL;\nPFNGLENDQUERYARBPROC __glewEndQueryARB = NULL;\nPFNGLGENQUERIESARBPROC __glewGenQueriesARB = NULL;\nPFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB = NULL;\nPFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB = NULL;\nPFNGLGETQUERYIVARBPROC __glewGetQueryivARB = NULL;\nPFNGLISQUERYARBPROC __glewIsQueryARB = NULL;\n\nPFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB = NULL;\nPFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB = NULL;\n\nPFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv = NULL;\nPFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex = NULL;\nPFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation = NULL;\nPFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex = NULL;\nPFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName = NULL;\nPFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv = NULL;\n\nPFNGLPROVOKINGVERTEXPROC __glewProvokingVertex = NULL;\n\nPFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB = NULL;\nPFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB = NULL;\nPFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB = NULL;\nPFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB = NULL;\nPFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB = NULL;\nPFNGLGETNMAPDVARBPROC __glewGetnMapdvARB = NULL;\nPFNGLGETNMAPFVARBPROC __glewGetnMapfvARB = NULL;\nPFNGLGETNMAPIVARBPROC __glewGetnMapivARB = NULL;\nPFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB = NULL;\nPFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB = NULL;\nPFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB = NULL;\nPFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB = NULL;\nPFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB = NULL;\nPFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB = NULL;\nPFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB = NULL;\nPFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB = NULL;\nPFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB = NULL;\nPFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB = NULL;\nPFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB = NULL;\nPFNGLREADNPIXELSARBPROC __glewReadnPixelsARB = NULL;\n\nPFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB = NULL;\n\nPFNGLBINDSAMPLERPROC __glewBindSampler = NULL;\nPFNGLDELETESAMPLERSPROC __glewDeleteSamplers = NULL;\nPFNGLGENSAMPLERSPROC __glewGenSamplers = NULL;\nPFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv = NULL;\nPFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv = NULL;\nPFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv = NULL;\nPFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv = NULL;\nPFNGLISSAMPLERPROC __glewIsSampler = NULL;\nPFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv = NULL;\nPFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv = NULL;\nPFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf = NULL;\nPFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv = NULL;\nPFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri = NULL;\nPFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv = NULL;\n\nPFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram = NULL;\nPFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline = NULL;\nPFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv = NULL;\nPFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines = NULL;\nPFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines = NULL;\nPFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog = NULL;\nPFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv = NULL;\nPFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline = NULL;\nPFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d = NULL;\nPFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv = NULL;\nPFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f = NULL;\nPFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv = NULL;\nPFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i = NULL;\nPFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv = NULL;\nPFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui = NULL;\nPFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv = NULL;\nPFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d = NULL;\nPFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv = NULL;\nPFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f = NULL;\nPFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv = NULL;\nPFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i = NULL;\nPFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv = NULL;\nPFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui = NULL;\nPFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv = NULL;\nPFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d = NULL;\nPFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv = NULL;\nPFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f = NULL;\nPFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv = NULL;\nPFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i = NULL;\nPFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv = NULL;\nPFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui = NULL;\nPFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv = NULL;\nPFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d = NULL;\nPFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv = NULL;\nPFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f = NULL;\nPFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv = NULL;\nPFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i = NULL;\nPFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv = NULL;\nPFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui = NULL;\nPFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv = NULL;\nPFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages = NULL;\nPFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline = NULL;\n\nPFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv = NULL;\n\nPFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture = NULL;\nPFNGLMEMORYBARRIERPROC __glewMemoryBarrier = NULL;\n\nPFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL;\nPFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL;\nPFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL;\nPFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB = NULL;\nPFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB = NULL;\nPFNGLDETACHOBJECTARBPROC __glewDetachObjectARB = NULL;\nPFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB = NULL;\nPFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB = NULL;\nPFNGLGETHANDLEARBPROC __glewGetHandleARB = NULL;\nPFNGLGETINFOLOGARBPROC __glewGetInfoLogARB = NULL;\nPFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB = NULL;\nPFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB = NULL;\nPFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB = NULL;\nPFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB = NULL;\nPFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB = NULL;\nPFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB = NULL;\nPFNGLLINKPROGRAMARBPROC __glewLinkProgramARB = NULL;\nPFNGLSHADERSOURCEARBPROC __glewShaderSourceARB = NULL;\nPFNGLUNIFORM1FARBPROC __glewUniform1fARB = NULL;\nPFNGLUNIFORM1FVARBPROC __glewUniform1fvARB = NULL;\nPFNGLUNIFORM1IARBPROC __glewUniform1iARB = NULL;\nPFNGLUNIFORM1IVARBPROC __glewUniform1ivARB = NULL;\nPFNGLUNIFORM2FARBPROC __glewUniform2fARB = NULL;\nPFNGLUNIFORM2FVARBPROC __glewUniform2fvARB = NULL;\nPFNGLUNIFORM2IARBPROC __glewUniform2iARB = NULL;\nPFNGLUNIFORM2IVARBPROC __glewUniform2ivARB = NULL;\nPFNGLUNIFORM3FARBPROC __glewUniform3fARB = NULL;\nPFNGLUNIFORM3FVARBPROC __glewUniform3fvARB = NULL;\nPFNGLUNIFORM3IARBPROC __glewUniform3iARB = NULL;\nPFNGLUNIFORM3IVARBPROC __glewUniform3ivARB = NULL;\nPFNGLUNIFORM4FARBPROC __glewUniform4fARB = NULL;\nPFNGLUNIFORM4FVARBPROC __glewUniform4fvARB = NULL;\nPFNGLUNIFORM4IARBPROC __glewUniform4iARB = NULL;\nPFNGLUNIFORM4IVARBPROC __glewUniform4ivARB = NULL;\nPFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB = NULL;\nPFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB = NULL;\nPFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL;\nPFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL;\nPFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL;\n\nPFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding = NULL;\n\nPFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName = NULL;\nPFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName = NULL;\nPFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv = NULL;\nPFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv = NULL;\nPFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex = NULL;\nPFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation = NULL;\nPFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv = NULL;\nPFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv = NULL;\n\nPFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB = NULL;\nPFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB = NULL;\nPFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB = NULL;\nPFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB = NULL;\nPFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB = NULL;\nPFNGLNAMEDSTRINGARBPROC __glewNamedStringARB = NULL;\n\nPFNGLCLIENTWAITSYNCPROC __glewClientWaitSync = NULL;\nPFNGLDELETESYNCPROC __glewDeleteSync = NULL;\nPFNGLFENCESYNCPROC __glewFenceSync = NULL;\nPFNGLGETINTEGER64VPROC __glewGetInteger64v = NULL;\nPFNGLGETSYNCIVPROC __glewGetSynciv = NULL;\nPFNGLISSYNCPROC __glewIsSync = NULL;\nPFNGLWAITSYNCPROC __glewWaitSync = NULL;\n\nPFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv = NULL;\nPFNGLPATCHPARAMETERIPROC __glewPatchParameteri = NULL;\n\nPFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL;\n\nPFNGLTEXBUFFERRANGEPROC __glewTexBufferRange = NULL;\nPFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT = NULL;\n\nPFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL;\nPFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB = NULL;\nPFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB = NULL;\nPFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB = NULL;\nPFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB = NULL;\n\nPFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv = NULL;\nPFNGLSAMPLEMASKIPROC __glewSampleMaski = NULL;\nPFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample = NULL;\nPFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample = NULL;\n\nPFNGLTEXSTORAGE1DPROC __glewTexStorage1D = NULL;\nPFNGLTEXSTORAGE2DPROC __glewTexStorage2D = NULL;\nPFNGLTEXSTORAGE3DPROC __glewTexStorage3D = NULL;\nPFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT = NULL;\nPFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT = NULL;\nPFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT = NULL;\n\nPFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample = NULL;\nPFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample = NULL;\nPFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT = NULL;\nPFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT = NULL;\n\nPFNGLTEXTUREVIEWPROC __glewTextureView = NULL;\n\nPFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v = NULL;\nPFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v = NULL;\nPFNGLQUERYCOUNTERPROC __glewQueryCounter = NULL;\n\nPFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback = NULL;\nPFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks = NULL;\nPFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback = NULL;\nPFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks = NULL;\nPFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback = NULL;\nPFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback = NULL;\nPFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback = NULL;\n\nPFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed = NULL;\nPFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream = NULL;\nPFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed = NULL;\nPFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv = NULL;\n\nPFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced = NULL;\nPFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced = NULL;\n\nPFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL;\nPFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL;\nPFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL;\nPFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB = NULL;\n\nPFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL;\nPFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL;\nPFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName = NULL;\nPFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv = NULL;\nPFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName = NULL;\nPFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv = NULL;\nPFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL;\nPFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex = NULL;\nPFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices = NULL;\nPFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding = NULL;\n\nPFNGLBINDVERTEXARRAYPROC __glewBindVertexArray = NULL;\nPFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays = NULL;\nPFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays = NULL;\nPFNGLISVERTEXARRAYPROC __glewIsVertexArray = NULL;\n\nPFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv = NULL;\nPFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d = NULL;\nPFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv = NULL;\nPFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d = NULL;\nPFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv = NULL;\nPFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d = NULL;\nPFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv = NULL;\nPFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d = NULL;\nPFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv = NULL;\nPFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer = NULL;\n\nPFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer = NULL;\nPFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding = NULL;\nPFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat = NULL;\nPFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat = NULL;\nPFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat = NULL;\nPFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor = NULL;\n\nPFNGLVERTEXBLENDARBPROC __glewVertexBlendARB = NULL;\nPFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB = NULL;\nPFNGLWEIGHTBVARBPROC __glewWeightbvARB = NULL;\nPFNGLWEIGHTDVARBPROC __glewWeightdvARB = NULL;\nPFNGLWEIGHTFVARBPROC __glewWeightfvARB = NULL;\nPFNGLWEIGHTIVARBPROC __glewWeightivARB = NULL;\nPFNGLWEIGHTSVARBPROC __glewWeightsvARB = NULL;\nPFNGLWEIGHTUBVARBPROC __glewWeightubvARB = NULL;\nPFNGLWEIGHTUIVARBPROC __glewWeightuivARB = NULL;\nPFNGLWEIGHTUSVARBPROC __glewWeightusvARB = NULL;\n\nPFNGLBINDBUFFERARBPROC __glewBindBufferARB = NULL;\nPFNGLBUFFERDATAARBPROC __glewBufferDataARB = NULL;\nPFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB = NULL;\nPFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB = NULL;\nPFNGLGENBUFFERSARBPROC __glewGenBuffersARB = NULL;\nPFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB = NULL;\nPFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB = NULL;\nPFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB = NULL;\nPFNGLISBUFFERARBPROC __glewIsBufferARB = NULL;\nPFNGLMAPBUFFERARBPROC __glewMapBufferARB = NULL;\nPFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB = NULL;\n\nPFNGLBINDPROGRAMARBPROC __glewBindProgramARB = NULL;\nPFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB = NULL;\nPFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB = NULL;\nPFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB = NULL;\nPFNGLGENPROGRAMSARBPROC __glewGenProgramsARB = NULL;\nPFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB = NULL;\nPFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB = NULL;\nPFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB = NULL;\nPFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB = NULL;\nPFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB = NULL;\nPFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB = NULL;\nPFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB = NULL;\nPFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB = NULL;\nPFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB = NULL;\nPFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB = NULL;\nPFNGLISPROGRAMARBPROC __glewIsProgramARB = NULL;\nPFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB = NULL;\nPFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB = NULL;\nPFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB = NULL;\nPFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB = NULL;\nPFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB = NULL;\nPFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB = NULL;\nPFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB = NULL;\nPFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB = NULL;\nPFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB = NULL;\nPFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB = NULL;\nPFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB = NULL;\nPFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB = NULL;\nPFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB = NULL;\nPFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB = NULL;\nPFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB = NULL;\nPFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB = NULL;\nPFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB = NULL;\nPFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB = NULL;\nPFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB = NULL;\nPFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB = NULL;\nPFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB = NULL;\nPFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB = NULL;\nPFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB = NULL;\nPFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB = NULL;\nPFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB = NULL;\nPFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB = NULL;\nPFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB = NULL;\nPFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB = NULL;\nPFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB = NULL;\nPFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB = NULL;\nPFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB = NULL;\nPFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB = NULL;\nPFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB = NULL;\nPFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB = NULL;\nPFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB = NULL;\nPFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB = NULL;\nPFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB = NULL;\nPFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB = NULL;\nPFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB = NULL;\nPFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB = NULL;\nPFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB = NULL;\nPFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB = NULL;\nPFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB = NULL;\nPFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB = NULL;\nPFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB = NULL;\nPFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB = NULL;\n\nPFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB = NULL;\nPFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB = NULL;\nPFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB = NULL;\n\nPFNGLCOLORP3UIPROC __glewColorP3ui = NULL;\nPFNGLCOLORP3UIVPROC __glewColorP3uiv = NULL;\nPFNGLCOLORP4UIPROC __glewColorP4ui = NULL;\nPFNGLCOLORP4UIVPROC __glewColorP4uiv = NULL;\nPFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui = NULL;\nPFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv = NULL;\nPFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui = NULL;\nPFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv = NULL;\nPFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui = NULL;\nPFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv = NULL;\nPFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui = NULL;\nPFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv = NULL;\nPFNGLNORMALP3UIPROC __glewNormalP3ui = NULL;\nPFNGLNORMALP3UIVPROC __glewNormalP3uiv = NULL;\nPFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui = NULL;\nPFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv = NULL;\nPFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui = NULL;\nPFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv = NULL;\nPFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui = NULL;\nPFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv = NULL;\nPFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui = NULL;\nPFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv = NULL;\nPFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui = NULL;\nPFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv = NULL;\nPFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui = NULL;\nPFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv = NULL;\nPFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui = NULL;\nPFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv = NULL;\nPFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui = NULL;\nPFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv = NULL;\nPFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui = NULL;\nPFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv = NULL;\nPFNGLVERTEXP2UIPROC __glewVertexP2ui = NULL;\nPFNGLVERTEXP2UIVPROC __glewVertexP2uiv = NULL;\nPFNGLVERTEXP3UIPROC __glewVertexP3ui = NULL;\nPFNGLVERTEXP3UIVPROC __glewVertexP3uiv = NULL;\nPFNGLVERTEXP4UIPROC __glewVertexP4ui = NULL;\nPFNGLVERTEXP4UIVPROC __glewVertexP4uiv = NULL;\n\nPFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv = NULL;\nPFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed = NULL;\nPFNGLGETDOUBLEI_VPROC __glewGetDoublei_v = NULL;\nPFNGLGETFLOATI_VPROC __glewGetFloati_v = NULL;\nPFNGLSCISSORARRAYVPROC __glewScissorArrayv = NULL;\nPFNGLSCISSORINDEXEDPROC __glewScissorIndexed = NULL;\nPFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv = NULL;\nPFNGLVIEWPORTARRAYVPROC __glewViewportArrayv = NULL;\nPFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf = NULL;\nPFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv = NULL;\n\nPFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB = NULL;\nPFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB = NULL;\nPFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB = NULL;\nPFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB = NULL;\nPFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB = NULL;\nPFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB = NULL;\nPFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB = NULL;\nPFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB = NULL;\nPFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB = NULL;\nPFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB = NULL;\nPFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB = NULL;\nPFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB = NULL;\nPFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB = NULL;\nPFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB = NULL;\nPFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB = NULL;\nPFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB = NULL;\n\nPFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI = NULL;\n\nPFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI = NULL;\nPFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI = NULL;\nPFNGLELEMENTPOINTERATIPROC __glewElementPointerATI = NULL;\n\nPFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI = NULL;\nPFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI = NULL;\nPFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI = NULL;\nPFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI = NULL;\n\nPFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI = NULL;\nPFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI = NULL;\nPFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI = NULL;\nPFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI = NULL;\nPFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI = NULL;\nPFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI = NULL;\nPFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI = NULL;\nPFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI = NULL;\nPFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI = NULL;\nPFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI = NULL;\nPFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI = NULL;\nPFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI = NULL;\nPFNGLSAMPLEMAPATIPROC __glewSampleMapATI = NULL;\nPFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI = NULL;\n\nPFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI = NULL;\nPFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI = NULL;\n\nPFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI = NULL;\nPFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI = NULL;\n\nPFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI = NULL;\nPFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI = NULL;\n\nPFNGLARRAYOBJECTATIPROC __glewArrayObjectATI = NULL;\nPFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI = NULL;\nPFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI = NULL;\nPFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI = NULL;\nPFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI = NULL;\nPFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI = NULL;\nPFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI = NULL;\nPFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI = NULL;\nPFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI = NULL;\nPFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI = NULL;\nPFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI = NULL;\nPFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI = NULL;\n\nPFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI = NULL;\nPFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI = NULL;\nPFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI = NULL;\n\nPFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI = NULL;\nPFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI = NULL;\nPFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI = NULL;\nPFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI = NULL;\nPFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI = NULL;\nPFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI = NULL;\nPFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI = NULL;\nPFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI = NULL;\nPFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI = NULL;\nPFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI = NULL;\nPFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI = NULL;\nPFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI = NULL;\nPFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI = NULL;\nPFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI = NULL;\nPFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI = NULL;\nPFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI = NULL;\nPFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI = NULL;\nPFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI = NULL;\nPFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI = NULL;\nPFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI = NULL;\nPFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI = NULL;\nPFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI = NULL;\nPFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI = NULL;\nPFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI = NULL;\nPFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI = NULL;\nPFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI = NULL;\nPFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI = NULL;\nPFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI = NULL;\nPFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI = NULL;\nPFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI = NULL;\nPFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI = NULL;\nPFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI = NULL;\nPFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI = NULL;\nPFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI = NULL;\nPFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI = NULL;\nPFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI = NULL;\nPFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI = NULL;\nPFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI = NULL;\nPFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI = NULL;\nPFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI = NULL;\nPFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI = NULL;\nPFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI = NULL;\nPFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI = NULL;\nPFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI = NULL;\nPFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI = NULL;\n\nPFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT = NULL;\nPFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT = NULL;\nPFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT = NULL;\n\nPFNGLBLENDCOLOREXTPROC __glewBlendColorEXT = NULL;\n\nPFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT = NULL;\n\nPFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT = NULL;\n\nPFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT = NULL;\n\nPFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT = NULL;\nPFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT = NULL;\n\nPFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT = NULL;\nPFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT = NULL;\n\nPFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT = NULL;\nPFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT = NULL;\nPFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT = NULL;\nPFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT = NULL;\nPFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT = NULL;\nPFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT = NULL;\nPFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT = NULL;\nPFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT = NULL;\nPFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT = NULL;\nPFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT = NULL;\nPFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT = NULL;\nPFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT = NULL;\nPFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT = NULL;\n\nPFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT = NULL;\nPFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT = NULL;\n\nPFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT = NULL;\nPFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT = NULL;\nPFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT = NULL;\nPFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT = NULL;\nPFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT = NULL;\n\nPFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT = NULL;\nPFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT = NULL;\n\nPFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT = NULL;\nPFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT = NULL;\nPFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT = NULL;\n\nPFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT = NULL;\n\nPFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT = NULL;\nPFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT = NULL;\nPFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT = NULL;\nPFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT = NULL;\nPFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT = NULL;\nPFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT = NULL;\nPFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT = NULL;\nPFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT = NULL;\nPFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT = NULL;\nPFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT = NULL;\nPFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT = NULL;\nPFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT = NULL;\nPFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT = NULL;\nPFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT = NULL;\nPFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT = NULL;\nPFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT = NULL;\nPFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT = NULL;\nPFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT = NULL;\nPFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT = NULL;\nPFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT = NULL;\nPFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT = NULL;\nPFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT = NULL;\nPFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT = NULL;\nPFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT = NULL;\nPFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT = NULL;\nPFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT = NULL;\nPFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT = NULL;\nPFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT = NULL;\nPFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT = NULL;\nPFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT = NULL;\nPFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT = NULL;\nPFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT = NULL;\nPFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT = NULL;\nPFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT = NULL;\nPFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT = NULL;\nPFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT = NULL;\nPFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT = NULL;\nPFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT = NULL;\nPFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT = NULL;\nPFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT = NULL;\nPFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT = NULL;\nPFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT = NULL;\nPFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT = NULL;\nPFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT = NULL;\nPFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT = NULL;\nPFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT = NULL;\nPFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT = NULL;\nPFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT = NULL;\nPFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT = NULL;\nPFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT = NULL;\nPFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT = NULL;\nPFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT = NULL;\nPFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT = NULL;\nPFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT = NULL;\nPFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT = NULL;\nPFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT = NULL;\nPFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT = NULL;\nPFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT = NULL;\nPFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT = NULL;\nPFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT = NULL;\nPFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT = NULL;\nPFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT = NULL;\nPFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT = NULL;\nPFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT = NULL;\nPFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT = NULL;\nPFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT = NULL;\nPFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT = NULL;\nPFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT = NULL;\nPFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT = NULL;\nPFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT = NULL;\nPFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT = NULL;\nPFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT = NULL;\nPFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT = NULL;\nPFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT = NULL;\nPFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT = NULL;\nPFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT = NULL;\nPFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT = NULL;\nPFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT = NULL;\nPFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT = NULL;\nPFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT = NULL;\nPFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT = NULL;\nPFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT = NULL;\nPFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT = NULL;\nPFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT = NULL;\nPFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT = NULL;\nPFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT = NULL;\nPFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT = NULL;\nPFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT = NULL;\nPFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT = NULL;\nPFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT = NULL;\nPFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT = NULL;\nPFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT = NULL;\nPFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT = NULL;\nPFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT = NULL;\nPFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT = NULL;\nPFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT = NULL;\nPFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT = NULL;\nPFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT = NULL;\nPFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT = NULL;\nPFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT = NULL;\nPFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT = NULL;\nPFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT = NULL;\nPFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT = NULL;\nPFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT = NULL;\nPFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT = NULL;\nPFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT = NULL;\nPFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT = NULL;\nPFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT = NULL;\nPFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT = NULL;\nPFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT = NULL;\nPFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT = NULL;\nPFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT = NULL;\nPFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT = NULL;\nPFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT = NULL;\nPFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT = NULL;\nPFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT = NULL;\nPFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT = NULL;\nPFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT = NULL;\nPFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT = NULL;\nPFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT = NULL;\nPFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT = NULL;\nPFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT = NULL;\nPFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT = NULL;\nPFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT = NULL;\nPFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT = NULL;\nPFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT = NULL;\nPFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT = NULL;\nPFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT = NULL;\nPFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT = NULL;\nPFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT = NULL;\nPFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT = NULL;\nPFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT = NULL;\nPFNGLPROGRAMUNIFORM1DEXTPROC __glewProgramUniform1dEXT = NULL;\nPFNGLPROGRAMUNIFORM1DVEXTPROC __glewProgramUniform1dvEXT = NULL;\nPFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT = NULL;\nPFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT = NULL;\nPFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT = NULL;\nPFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT = NULL;\nPFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT = NULL;\nPFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT = NULL;\nPFNGLPROGRAMUNIFORM2DEXTPROC __glewProgramUniform2dEXT = NULL;\nPFNGLPROGRAMUNIFORM2DVEXTPROC __glewProgramUniform2dvEXT = NULL;\nPFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT = NULL;\nPFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT = NULL;\nPFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT = NULL;\nPFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT = NULL;\nPFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT = NULL;\nPFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT = NULL;\nPFNGLPROGRAMUNIFORM3DEXTPROC __glewProgramUniform3dEXT = NULL;\nPFNGLPROGRAMUNIFORM3DVEXTPROC __glewProgramUniform3dvEXT = NULL;\nPFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT = NULL;\nPFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT = NULL;\nPFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT = NULL;\nPFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT = NULL;\nPFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT = NULL;\nPFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT = NULL;\nPFNGLPROGRAMUNIFORM4DEXTPROC __glewProgramUniform4dEXT = NULL;\nPFNGLPROGRAMUNIFORM4DVEXTPROC __glewProgramUniform4dvEXT = NULL;\nPFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT = NULL;\nPFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT = NULL;\nPFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT = NULL;\nPFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT = NULL;\nPFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT = NULL;\nPFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC __glewProgramUniformMatrix2dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC __glewProgramUniformMatrix2x3dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC __glewProgramUniformMatrix2x4dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC __glewProgramUniformMatrix3dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC __glewProgramUniformMatrix3x2dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC __glewProgramUniformMatrix3x4dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC __glewProgramUniformMatrix4dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC __glewProgramUniformMatrix4x2dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC __glewProgramUniformMatrix4x3dvEXT = NULL;\nPFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT = NULL;\nPFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT = NULL;\nPFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT = NULL;\nPFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT = NULL;\nPFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT = NULL;\nPFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT = NULL;\nPFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT = NULL;\nPFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT = NULL;\nPFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT = NULL;\nPFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT = NULL;\nPFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT = NULL;\nPFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT = NULL;\nPFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT = NULL;\nPFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT = NULL;\nPFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT = NULL;\nPFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT = NULL;\nPFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT = NULL;\nPFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT = NULL;\nPFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT = NULL;\nPFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT = NULL;\nPFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT = NULL;\nPFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT = NULL;\nPFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT = NULL;\nPFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT = NULL;\nPFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT = NULL;\nPFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT = NULL;\nPFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT = NULL;\nPFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT = NULL;\n\nPFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT = NULL;\nPFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT = NULL;\nPFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT = NULL;\nPFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT = NULL;\nPFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT = NULL;\nPFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT = NULL;\n\nPFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT = NULL;\nPFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT = NULL;\n\nPFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT = NULL;\n\nPFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT = NULL;\nPFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT = NULL;\nPFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT = NULL;\nPFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT = NULL;\nPFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT = NULL;\n\nPFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT = NULL;\nPFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT = NULL;\nPFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT = NULL;\nPFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT = NULL;\nPFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT = NULL;\nPFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT = NULL;\nPFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT = NULL;\nPFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT = NULL;\nPFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT = NULL;\nPFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT = NULL;\nPFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT = NULL;\nPFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT = NULL;\nPFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT = NULL;\nPFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT = NULL;\nPFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT = NULL;\nPFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT = NULL;\nPFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT = NULL;\nPFNGLLIGHTENVIEXTPROC __glewLightEnviEXT = NULL;\n\nPFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT = NULL;\n\nPFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT = NULL;\n\nPFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT = NULL;\nPFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT = NULL;\nPFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT = NULL;\nPFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT = NULL;\nPFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT = NULL;\nPFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT = NULL;\nPFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT = NULL;\nPFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT = NULL;\nPFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT = NULL;\nPFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT = NULL;\nPFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT = NULL;\nPFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT = NULL;\nPFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT = NULL;\nPFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT = NULL;\nPFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT = NULL;\nPFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT = NULL;\nPFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT = NULL;\n\nPFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT = NULL;\nPFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT = NULL;\nPFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT = NULL;\n\nPFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT = NULL;\nPFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT = NULL;\n\nPFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT = NULL;\nPFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT = NULL;\nPFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT = NULL;\nPFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT = NULL;\nPFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT = NULL;\nPFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT = NULL;\nPFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT = NULL;\nPFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT = NULL;\nPFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT = NULL;\nPFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT = NULL;\nPFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT = NULL;\nPFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT = NULL;\nPFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT = NULL;\nPFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT = NULL;\nPFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT = NULL;\nPFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT = NULL;\nPFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT = NULL;\nPFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT = NULL;\nPFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT = NULL;\nPFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT = NULL;\nPFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT = NULL;\nPFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT = NULL;\nPFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT = NULL;\nPFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT = NULL;\nPFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT = NULL;\nPFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT = NULL;\nPFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT = NULL;\nPFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT = NULL;\nPFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT = NULL;\nPFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT = NULL;\nPFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT = NULL;\nPFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT = NULL;\nPFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT = NULL;\nPFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT = NULL;\n\nPFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT = NULL;\nPFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT = NULL;\nPFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT = NULL;\nPFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT = NULL;\nPFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT = NULL;\nPFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT = NULL;\nPFNGLHISTOGRAMEXTPROC __glewHistogramEXT = NULL;\nPFNGLMINMAXEXTPROC __glewMinmaxEXT = NULL;\nPFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT = NULL;\nPFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT = NULL;\n\nPFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT = NULL;\n\nPFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT = NULL;\n\nPFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT = NULL;\nPFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT = NULL;\nPFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT = NULL;\n\nPFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT = NULL;\nPFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT = NULL;\n\nPFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT = NULL;\nPFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT = NULL;\n\nPFNGLCOLORTABLEEXTPROC __glewColorTableEXT = NULL;\nPFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT = NULL;\nPFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT = NULL;\nPFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT = NULL;\n\nPFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT = NULL;\nPFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT = NULL;\nPFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT = NULL;\nPFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT = NULL;\nPFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT = NULL;\nPFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT = NULL;\n\nPFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT = NULL;\nPFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT = NULL;\n\nPFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT = NULL;\n\nPFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT = NULL;\n\nPFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT = NULL;\nPFNGLENDSCENEEXTPROC __glewEndSceneEXT = NULL;\n\nPFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT = NULL;\nPFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT = NULL;\nPFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT = NULL;\nPFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT = NULL;\nPFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT = NULL;\nPFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT = NULL;\nPFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT = NULL;\nPFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT = NULL;\nPFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT = NULL;\nPFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT = NULL;\nPFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT = NULL;\nPFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT = NULL;\nPFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT = NULL;\nPFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT = NULL;\nPFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT = NULL;\nPFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT = NULL;\nPFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT = NULL;\n\nPFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT = NULL;\nPFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT = NULL;\nPFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT = NULL;\n\nPFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT = NULL;\nPFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT = NULL;\n\nPFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL;\n\nPFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL;\nPFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT = NULL;\nPFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT = NULL;\n\nPFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT = NULL;\n\nPFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT = NULL;\n\nPFNGLTEXBUFFEREXTPROC __glewTexBufferEXT = NULL;\n\nPFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT = NULL;\nPFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT = NULL;\nPFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT = NULL;\nPFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT = NULL;\nPFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT = NULL;\nPFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT = NULL;\n\nPFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT = NULL;\nPFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT = NULL;\nPFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT = NULL;\nPFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT = NULL;\nPFNGLISTEXTUREEXTPROC __glewIsTextureEXT = NULL;\nPFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT = NULL;\n\nPFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT = NULL;\n\nPFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT = NULL;\nPFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT = NULL;\n\nPFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT = NULL;\nPFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT = NULL;\nPFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT = NULL;\nPFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT = NULL;\nPFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT = NULL;\nPFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT = NULL;\nPFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT = NULL;\n\nPFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT = NULL;\nPFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT = NULL;\nPFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT = NULL;\nPFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT = NULL;\nPFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT = NULL;\nPFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT = NULL;\nPFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT = NULL;\nPFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT = NULL;\n\nPFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT = NULL;\nPFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT = NULL;\nPFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT = NULL;\nPFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT = NULL;\nPFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT = NULL;\nPFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT = NULL;\nPFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT = NULL;\nPFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT = NULL;\nPFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT = NULL;\nPFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT = NULL;\nPFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT = NULL;\n\nPFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT = NULL;\nPFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT = NULL;\nPFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT = NULL;\nPFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT = NULL;\nPFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT = NULL;\nPFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT = NULL;\nPFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT = NULL;\nPFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT = NULL;\nPFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT = NULL;\nPFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT = NULL;\nPFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT = NULL;\nPFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT = NULL;\nPFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT = NULL;\nPFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT = NULL;\nPFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT = NULL;\nPFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT = NULL;\nPFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT = NULL;\nPFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT = NULL;\nPFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT = NULL;\nPFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT = NULL;\nPFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT = NULL;\nPFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT = NULL;\nPFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT = NULL;\nPFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT = NULL;\nPFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT = NULL;\nPFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT = NULL;\nPFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT = NULL;\nPFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT = NULL;\nPFNGLSHADEROP1EXTPROC __glewShaderOp1EXT = NULL;\nPFNGLSHADEROP2EXTPROC __glewShaderOp2EXT = NULL;\nPFNGLSHADEROP3EXTPROC __glewShaderOp3EXT = NULL;\nPFNGLSWIZZLEEXTPROC __glewSwizzleEXT = NULL;\nPFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT = NULL;\nPFNGLVARIANTBVEXTPROC __glewVariantbvEXT = NULL;\nPFNGLVARIANTDVEXTPROC __glewVariantdvEXT = NULL;\nPFNGLVARIANTFVEXTPROC __glewVariantfvEXT = NULL;\nPFNGLVARIANTIVEXTPROC __glewVariantivEXT = NULL;\nPFNGLVARIANTSVEXTPROC __glewVariantsvEXT = NULL;\nPFNGLVARIANTUBVEXTPROC __glewVariantubvEXT = NULL;\nPFNGLVARIANTUIVEXTPROC __glewVariantuivEXT = NULL;\nPFNGLVARIANTUSVEXTPROC __glewVariantusvEXT = NULL;\nPFNGLWRITEMASKEXTPROC __glewWriteMaskEXT = NULL;\n\nPFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT = NULL;\nPFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT = NULL;\nPFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT = NULL;\n\nPFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT = NULL;\n\nPFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY = NULL;\n\nPFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY = NULL;\n\nPFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP = NULL;\nPFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP = NULL;\nPFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP = NULL;\nPFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP = NULL;\nPFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP = NULL;\nPFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP = NULL;\n\nPFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM = NULL;\nPFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM = NULL;\n\nPFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM = NULL;\nPFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM = NULL;\nPFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM = NULL;\nPFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM = NULL;\nPFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM = NULL;\nPFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM = NULL;\nPFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM = NULL;\nPFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM = NULL;\n\nPFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL = NULL;\nPFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL = NULL;\nPFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL = NULL;\nPFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL = NULL;\n\nPFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL = NULL;\nPFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL = NULL;\n\nPFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback = NULL;\nPFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl = NULL;\nPFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert = NULL;\nPFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog = NULL;\nPFNGLGETOBJECTLABELPROC __glewGetObjectLabel = NULL;\nPFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel = NULL;\nPFNGLGETPOINTERVPROC __glewGetPointerv = NULL;\nPFNGLOBJECTLABELPROC __glewObjectLabel = NULL;\nPFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel = NULL;\nPFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup = NULL;\n\nPFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled = NULL;\nPFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion = NULL;\nPFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion = NULL;\nPFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion = NULL;\nPFNGLREADBUFFERREGIONPROC __glewReadBufferRegion = NULL;\n\nPFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA = NULL;\n\nPFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA = NULL;\nPFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA = NULL;\nPFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA = NULL;\nPFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA = NULL;\nPFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA = NULL;\nPFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA = NULL;\nPFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA = NULL;\nPFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA = NULL;\nPFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA = NULL;\nPFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA = NULL;\nPFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA = NULL;\nPFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA = NULL;\nPFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA = NULL;\nPFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA = NULL;\nPFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA = NULL;\nPFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA = NULL;\nPFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA = NULL;\nPFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA = NULL;\nPFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA = NULL;\nPFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA = NULL;\nPFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA = NULL;\nPFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA = NULL;\nPFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA = NULL;\nPFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA = NULL;\n\nPFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV = NULL;\nPFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV = NULL;\nPFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV = NULL;\nPFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV = NULL;\nPFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV = NULL;\nPFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV = NULL;\nPFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV = NULL;\nPFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV = NULL;\nPFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV = NULL;\nPFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV = NULL;\nPFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV = NULL;\nPFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV = NULL;\nPFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV = NULL;\n\nPFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV = NULL;\nPFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV = NULL;\n\nPFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV = NULL;\n\nPFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV = NULL;\nPFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV = NULL;\nPFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV = NULL;\n\nPFNGLEVALMAPSNVPROC __glewEvalMapsNV = NULL;\nPFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV = NULL;\nPFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV = NULL;\nPFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV = NULL;\nPFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV = NULL;\nPFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV = NULL;\nPFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV = NULL;\nPFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV = NULL;\nPFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV = NULL;\n\nPFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV = NULL;\nPFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV = NULL;\nPFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV = NULL;\n\nPFNGLDELETEFENCESNVPROC __glewDeleteFencesNV = NULL;\nPFNGLFINISHFENCENVPROC __glewFinishFenceNV = NULL;\nPFNGLGENFENCESNVPROC __glewGenFencesNV = NULL;\nPFNGLGETFENCEIVNVPROC __glewGetFenceivNV = NULL;\nPFNGLISFENCENVPROC __glewIsFenceNV = NULL;\nPFNGLSETFENCENVPROC __glewSetFenceNV = NULL;\nPFNGLTESTFENCENVPROC __glewTestFenceNV = NULL;\n\nPFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV = NULL;\nPFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV = NULL;\nPFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV = NULL;\nPFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV = NULL;\nPFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV = NULL;\nPFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV = NULL;\n\nPFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV = NULL;\n\nPFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV = NULL;\n\nPFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV = NULL;\nPFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV = NULL;\nPFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV = NULL;\nPFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV = NULL;\nPFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV = NULL;\nPFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV = NULL;\nPFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV = NULL;\n\nPFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV = NULL;\nPFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV = NULL;\nPFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV = NULL;\nPFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV = NULL;\nPFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV = NULL;\nPFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV = NULL;\nPFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV = NULL;\nPFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV = NULL;\nPFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV = NULL;\nPFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV = NULL;\nPFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV = NULL;\nPFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV = NULL;\nPFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV = NULL;\nPFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV = NULL;\nPFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV = NULL;\nPFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV = NULL;\nPFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV = NULL;\nPFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV = NULL;\nPFNGLUNIFORM1I64NVPROC __glewUniform1i64NV = NULL;\nPFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV = NULL;\nPFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV = NULL;\nPFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV = NULL;\nPFNGLUNIFORM2I64NVPROC __glewUniform2i64NV = NULL;\nPFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV = NULL;\nPFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV = NULL;\nPFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV = NULL;\nPFNGLUNIFORM3I64NVPROC __glewUniform3i64NV = NULL;\nPFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV = NULL;\nPFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV = NULL;\nPFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV = NULL;\nPFNGLUNIFORM4I64NVPROC __glewUniform4i64NV = NULL;\nPFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV = NULL;\nPFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV = NULL;\nPFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV = NULL;\n\nPFNGLCOLOR3HNVPROC __glewColor3hNV = NULL;\nPFNGLCOLOR3HVNVPROC __glewColor3hvNV = NULL;\nPFNGLCOLOR4HNVPROC __glewColor4hNV = NULL;\nPFNGLCOLOR4HVNVPROC __glewColor4hvNV = NULL;\nPFNGLFOGCOORDHNVPROC __glewFogCoordhNV = NULL;\nPFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV = NULL;\nPFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV = NULL;\nPFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV = NULL;\nPFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV = NULL;\nPFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV = NULL;\nPFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV = NULL;\nPFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV = NULL;\nPFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV = NULL;\nPFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV = NULL;\nPFNGLNORMAL3HNVPROC __glewNormal3hNV = NULL;\nPFNGLNORMAL3HVNVPROC __glewNormal3hvNV = NULL;\nPFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV = NULL;\nPFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV = NULL;\nPFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV = NULL;\nPFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV = NULL;\nPFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV = NULL;\nPFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV = NULL;\nPFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV = NULL;\nPFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV = NULL;\nPFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV = NULL;\nPFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV = NULL;\nPFNGLVERTEX2HNVPROC __glewVertex2hNV = NULL;\nPFNGLVERTEX2HVNVPROC __glewVertex2hvNV = NULL;\nPFNGLVERTEX3HNVPROC __glewVertex3hNV = NULL;\nPFNGLVERTEX3HVNVPROC __glewVertex3hvNV = NULL;\nPFNGLVERTEX4HNVPROC __glewVertex4hNV = NULL;\nPFNGLVERTEX4HVNVPROC __glewVertex4hvNV = NULL;\nPFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV = NULL;\nPFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV = NULL;\nPFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV = NULL;\nPFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV = NULL;\nPFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV = NULL;\nPFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV = NULL;\nPFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV = NULL;\nPFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV = NULL;\nPFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV = NULL;\nPFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV = NULL;\nPFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV = NULL;\nPFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV = NULL;\nPFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV = NULL;\nPFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV = NULL;\n\nPFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV = NULL;\nPFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV = NULL;\nPFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV = NULL;\nPFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV = NULL;\nPFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV = NULL;\nPFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV = NULL;\nPFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV = NULL;\n\nPFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV = NULL;\nPFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV = NULL;\nPFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV = NULL;\n\nPFNGLCOPYPATHNVPROC __glewCopyPathNV = NULL;\nPFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV = NULL;\nPFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV = NULL;\nPFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV = NULL;\nPFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV = NULL;\nPFNGLDELETEPATHSNVPROC __glewDeletePathsNV = NULL;\nPFNGLGENPATHSNVPROC __glewGenPathsNV = NULL;\nPFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV = NULL;\nPFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV = NULL;\nPFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV = NULL;\nPFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV = NULL;\nPFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV = NULL;\nPFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV = NULL;\nPFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV = NULL;\nPFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV = NULL;\nPFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV = NULL;\nPFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV = NULL;\nPFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV = NULL;\nPFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV = NULL;\nPFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV = NULL;\nPFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV = NULL;\nPFNGLISPATHNVPROC __glewIsPathNV = NULL;\nPFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV = NULL;\nPFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV = NULL;\nPFNGLPATHCOLORGENNVPROC __glewPathColorGenNV = NULL;\nPFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV = NULL;\nPFNGLPATHCOORDSNVPROC __glewPathCoordsNV = NULL;\nPFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV = NULL;\nPFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV = NULL;\nPFNGLPATHFOGGENNVPROC __glewPathFogGenNV = NULL;\nPFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV = NULL;\nPFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV = NULL;\nPFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV = NULL;\nPFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV = NULL;\nPFNGLPATHPARAMETERINVPROC __glewPathParameteriNV = NULL;\nPFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV = NULL;\nPFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV = NULL;\nPFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV = NULL;\nPFNGLPATHSTRINGNVPROC __glewPathStringNV = NULL;\nPFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV = NULL;\nPFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV = NULL;\nPFNGLPATHTEXGENNVPROC __glewPathTexGenNV = NULL;\nPFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV = NULL;\nPFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV = NULL;\nPFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV = NULL;\nPFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV = NULL;\nPFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV = NULL;\nPFNGLTRANSFORMPATHNVPROC __glewTransformPathNV = NULL;\nPFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV = NULL;\n\nPFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV = NULL;\nPFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV = NULL;\n\nPFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV = NULL;\nPFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV = NULL;\n\nPFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV = NULL;\nPFNGLGETVIDEOIVNVPROC __glewGetVideoivNV = NULL;\nPFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV = NULL;\nPFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV = NULL;\nPFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV = NULL;\nPFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV = NULL;\n\nPFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV = NULL;\nPFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV = NULL;\n\nPFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV = NULL;\nPFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV = NULL;\nPFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV = NULL;\nPFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV = NULL;\nPFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV = NULL;\nPFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV = NULL;\nPFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV = NULL;\nPFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV = NULL;\nPFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV = NULL;\nPFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV = NULL;\nPFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV = NULL;\nPFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV = NULL;\nPFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV = NULL;\n\nPFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV = NULL;\nPFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NULL;\n\nPFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV = NULL;\nPFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV = NULL;\nPFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV = NULL;\nPFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV = NULL;\nPFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV = NULL;\nPFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV = NULL;\nPFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV = NULL;\nPFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV = NULL;\nPFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV = NULL;\nPFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV = NULL;\nPFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV = NULL;\nPFNGLUNIFORMUI64NVPROC __glewUniformui64NV = NULL;\nPFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV = NULL;\n\nPFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV = NULL;\n\nPFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV = NULL;\nPFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV = NULL;\nPFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV = NULL;\nPFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV = NULL;\nPFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV = NULL;\nPFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV = NULL;\n\nPFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV = NULL;\nPFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV = NULL;\nPFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV = NULL;\nPFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV = NULL;\nPFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV = NULL;\nPFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV = NULL;\nPFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV = NULL;\nPFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV = NULL;\nPFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV = NULL;\nPFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV = NULL;\nPFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV = NULL;\n\nPFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV = NULL;\nPFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV = NULL;\nPFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV = NULL;\nPFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV = NULL;\nPFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV = NULL;\nPFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV = NULL;\nPFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV = NULL;\n\nPFNGLVDPAUFININVPROC __glewVDPAUFiniNV = NULL;\nPFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV = NULL;\nPFNGLVDPAUINITNVPROC __glewVDPAUInitNV = NULL;\nPFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV = NULL;\nPFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV = NULL;\nPFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV = NULL;\nPFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV = NULL;\nPFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV = NULL;\nPFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV = NULL;\nPFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV = NULL;\n\nPFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL;\nPFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL;\n\nPFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV = NULL;\nPFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV = NULL;\nPFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV = NULL;\nPFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV = NULL;\nPFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV = NULL;\nPFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV = NULL;\nPFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV = NULL;\nPFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV = NULL;\nPFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV = NULL;\nPFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV = NULL;\nPFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV = NULL;\nPFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV = NULL;\nPFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV = NULL;\nPFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV = NULL;\nPFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV = NULL;\nPFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV = NULL;\nPFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV = NULL;\nPFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV = NULL;\nPFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV = NULL;\n\nPFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV = NULL;\nPFNGLCOLORFORMATNVPROC __glewColorFormatNV = NULL;\nPFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV = NULL;\nPFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV = NULL;\nPFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV = NULL;\nPFNGLINDEXFORMATNVPROC __glewIndexFormatNV = NULL;\nPFNGLNORMALFORMATNVPROC __glewNormalFormatNV = NULL;\nPFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV = NULL;\nPFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV = NULL;\nPFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV = NULL;\nPFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV = NULL;\nPFNGLVERTEXFORMATNVPROC __glewVertexFormatNV = NULL;\n\nPFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV = NULL;\nPFNGLBINDPROGRAMNVPROC __glewBindProgramNV = NULL;\nPFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV = NULL;\nPFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV = NULL;\nPFNGLGENPROGRAMSNVPROC __glewGenProgramsNV = NULL;\nPFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV = NULL;\nPFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV = NULL;\nPFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV = NULL;\nPFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV = NULL;\nPFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV = NULL;\nPFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV = NULL;\nPFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV = NULL;\nPFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV = NULL;\nPFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV = NULL;\nPFNGLISPROGRAMNVPROC __glewIsProgramNV = NULL;\nPFNGLLOADPROGRAMNVPROC __glewLoadProgramNV = NULL;\nPFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV = NULL;\nPFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV = NULL;\nPFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV = NULL;\nPFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV = NULL;\nPFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV = NULL;\nPFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV = NULL;\nPFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV = NULL;\nPFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV = NULL;\nPFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV = NULL;\nPFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV = NULL;\nPFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV = NULL;\nPFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV = NULL;\nPFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV = NULL;\nPFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV = NULL;\nPFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV = NULL;\nPFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV = NULL;\nPFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV = NULL;\nPFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV = NULL;\nPFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV = NULL;\nPFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV = NULL;\nPFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV = NULL;\nPFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV = NULL;\nPFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV = NULL;\nPFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV = NULL;\nPFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV = NULL;\nPFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV = NULL;\nPFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV = NULL;\nPFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV = NULL;\nPFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV = NULL;\nPFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV = NULL;\nPFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV = NULL;\nPFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV = NULL;\nPFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV = NULL;\nPFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV = NULL;\nPFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV = NULL;\nPFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV = NULL;\nPFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV = NULL;\nPFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV = NULL;\nPFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV = NULL;\nPFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV = NULL;\nPFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV = NULL;\nPFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV = NULL;\nPFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV = NULL;\nPFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV = NULL;\nPFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV = NULL;\nPFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV = NULL;\nPFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV = NULL;\nPFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV = NULL;\n\nPFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV = NULL;\nPFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV = NULL;\nPFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV = NULL;\nPFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV = NULL;\nPFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV = NULL;\nPFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV = NULL;\nPFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV = NULL;\nPFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV = NULL;\nPFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV = NULL;\nPFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV = NULL;\nPFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV = NULL;\nPFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV = NULL;\n\nPFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES = NULL;\nPFNGLCLIPPLANEFOESPROC __glewClipPlanefOES = NULL;\nPFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES = NULL;\nPFNGLFRUSTUMFOESPROC __glewFrustumfOES = NULL;\nPFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES = NULL;\nPFNGLORTHOFOESPROC __glewOrthofOES = NULL;\n\nPFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL = NULL;\n\nPFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL = NULL;\nPFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL = NULL;\n\nPFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS = NULL;\nPFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS = NULL;\n\nPFNGLFOGFUNCSGISPROC __glewFogFuncSGIS = NULL;\nPFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS = NULL;\n\nPFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS = NULL;\nPFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS = NULL;\n\nPFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS = NULL;\nPFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS = NULL;\n\nPFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS = NULL;\nPFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS = NULL;\n\nPFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS = NULL;\nPFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS = NULL;\n\nPFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX = NULL;\nPFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX = NULL;\nPFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX = NULL;\nPFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX = NULL;\nPFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX = NULL;\nPFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX = NULL;\n\nPFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX = NULL;\n\nPFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX = NULL;\n\nPFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX = NULL;\nPFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX = NULL;\nPFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX = NULL;\nPFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX = NULL;\nPFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX = NULL;\nPFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX = NULL;\nPFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX = NULL;\nPFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX = NULL;\nPFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX = NULL;\nPFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX = NULL;\nPFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX = NULL;\nPFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX = NULL;\nPFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX = NULL;\nPFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX = NULL;\nPFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX = NULL;\nPFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX = NULL;\nPFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX = NULL;\n\nPFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX = NULL;\n\nPFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX = NULL;\n\nPFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX = NULL;\n\nPFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX = NULL;\nPFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX = NULL;\nPFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX = NULL;\nPFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX = NULL;\n\nPFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX = NULL;\n\nPFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI = NULL;\nPFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI = NULL;\nPFNGLCOLORTABLESGIPROC __glewColorTableSGI = NULL;\nPFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI = NULL;\nPFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI = NULL;\nPFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI = NULL;\nPFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI = NULL;\n\nPFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX = NULL;\n\nPFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN = NULL;\nPFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN = NULL;\nPFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN = NULL;\nPFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN = NULL;\nPFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN = NULL;\nPFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN = NULL;\nPFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN = NULL;\nPFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN = NULL;\n\nPFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN = NULL;\n\nPFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN = NULL;\nPFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN = NULL;\nPFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN = NULL;\nPFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN = NULL;\nPFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN = NULL;\nPFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN = NULL;\nPFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN = NULL;\n\nPFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN = NULL;\nPFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN = NULL;\nPFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN = NULL;\nPFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN = NULL;\nPFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN = NULL;\nPFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN = NULL;\nPFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN = NULL;\nPFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN = NULL;\nPFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN = NULL;\nPFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN = NULL;\nPFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN = NULL;\nPFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN = NULL;\nPFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN = NULL;\nPFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN = NULL;\nPFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN = NULL;\nPFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN = NULL;\nPFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN = NULL;\nPFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN = NULL;\nPFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN = NULL;\nPFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN = NULL;\nPFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN = NULL;\nPFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN = NULL;\nPFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN = NULL;\nPFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN = NULL;\nPFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN = NULL;\nPFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN = NULL;\n\nPFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN = NULL;\n\n#endif /* !WIN32 || !GLEW_MX */\n\n#if !defined(GLEW_MX)\n\nGLboolean __GLEW_VERSION_1_1 = GL_FALSE;\nGLboolean __GLEW_VERSION_1_2 = GL_FALSE;\nGLboolean __GLEW_VERSION_1_2_1 = GL_FALSE;\nGLboolean __GLEW_VERSION_1_3 = GL_FALSE;\nGLboolean __GLEW_VERSION_1_4 = GL_FALSE;\nGLboolean __GLEW_VERSION_1_5 = GL_FALSE;\nGLboolean __GLEW_VERSION_2_0 = GL_FALSE;\nGLboolean __GLEW_VERSION_2_1 = GL_FALSE;\nGLboolean __GLEW_VERSION_3_0 = GL_FALSE;\nGLboolean __GLEW_VERSION_3_1 = GL_FALSE;\nGLboolean __GLEW_VERSION_3_2 = GL_FALSE;\nGLboolean __GLEW_VERSION_3_3 = GL_FALSE;\nGLboolean __GLEW_VERSION_4_0 = GL_FALSE;\nGLboolean __GLEW_VERSION_4_1 = GL_FALSE;\nGLboolean __GLEW_VERSION_4_2 = GL_FALSE;\nGLboolean __GLEW_VERSION_4_3 = GL_FALSE;\nGLboolean __GLEW_3DFX_multisample = GL_FALSE;\nGLboolean __GLEW_3DFX_tbuffer = GL_FALSE;\nGLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE;\nGLboolean __GLEW_AMD_blend_minmax_factor = GL_FALSE;\nGLboolean __GLEW_AMD_conservative_depth = GL_FALSE;\nGLboolean __GLEW_AMD_debug_output = GL_FALSE;\nGLboolean __GLEW_AMD_depth_clamp_separate = GL_FALSE;\nGLboolean __GLEW_AMD_draw_buffers_blend = GL_FALSE;\nGLboolean __GLEW_AMD_multi_draw_indirect = GL_FALSE;\nGLboolean __GLEW_AMD_name_gen_delete = GL_FALSE;\nGLboolean __GLEW_AMD_performance_monitor = GL_FALSE;\nGLboolean __GLEW_AMD_pinned_memory = GL_FALSE;\nGLboolean __GLEW_AMD_query_buffer_object = GL_FALSE;\nGLboolean __GLEW_AMD_sample_positions = GL_FALSE;\nGLboolean __GLEW_AMD_seamless_cubemap_per_texture = GL_FALSE;\nGLboolean __GLEW_AMD_shader_stencil_export = GL_FALSE;\nGLboolean __GLEW_AMD_stencil_operation_extended = GL_FALSE;\nGLboolean __GLEW_AMD_texture_texture4 = GL_FALSE;\nGLboolean __GLEW_AMD_transform_feedback3_lines_triangles = GL_FALSE;\nGLboolean __GLEW_AMD_vertex_shader_layer = GL_FALSE;\nGLboolean __GLEW_AMD_vertex_shader_tessellator = GL_FALSE;\nGLboolean __GLEW_AMD_vertex_shader_viewport_index = GL_FALSE;\nGLboolean __GLEW_APPLE_aux_depth_stencil = GL_FALSE;\nGLboolean __GLEW_APPLE_client_storage = GL_FALSE;\nGLboolean __GLEW_APPLE_element_array = GL_FALSE;\nGLboolean __GLEW_APPLE_fence = GL_FALSE;\nGLboolean __GLEW_APPLE_float_pixels = GL_FALSE;\nGLboolean __GLEW_APPLE_flush_buffer_range = GL_FALSE;\nGLboolean __GLEW_APPLE_object_purgeable = GL_FALSE;\nGLboolean __GLEW_APPLE_pixel_buffer = GL_FALSE;\nGLboolean __GLEW_APPLE_rgb_422 = GL_FALSE;\nGLboolean __GLEW_APPLE_row_bytes = GL_FALSE;\nGLboolean __GLEW_APPLE_specular_vector = GL_FALSE;\nGLboolean __GLEW_APPLE_texture_range = GL_FALSE;\nGLboolean __GLEW_APPLE_transform_hint = GL_FALSE;\nGLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE;\nGLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE;\nGLboolean __GLEW_APPLE_vertex_program_evaluators = GL_FALSE;\nGLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE;\nGLboolean __GLEW_ARB_ES2_compatibility = GL_FALSE;\nGLboolean __GLEW_ARB_ES3_compatibility = GL_FALSE;\nGLboolean __GLEW_ARB_arrays_of_arrays = GL_FALSE;\nGLboolean __GLEW_ARB_base_instance = GL_FALSE;\nGLboolean __GLEW_ARB_blend_func_extended = GL_FALSE;\nGLboolean __GLEW_ARB_cl_event = GL_FALSE;\nGLboolean __GLEW_ARB_clear_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_color_buffer_float = GL_FALSE;\nGLboolean __GLEW_ARB_compatibility = GL_FALSE;\nGLboolean __GLEW_ARB_compressed_texture_pixel_storage = GL_FALSE;\nGLboolean __GLEW_ARB_compute_shader = GL_FALSE;\nGLboolean __GLEW_ARB_conservative_depth = GL_FALSE;\nGLboolean __GLEW_ARB_copy_buffer = GL_FALSE;\nGLboolean __GLEW_ARB_copy_image = GL_FALSE;\nGLboolean __GLEW_ARB_debug_output = GL_FALSE;\nGLboolean __GLEW_ARB_depth_buffer_float = GL_FALSE;\nGLboolean __GLEW_ARB_depth_clamp = GL_FALSE;\nGLboolean __GLEW_ARB_depth_texture = GL_FALSE;\nGLboolean __GLEW_ARB_draw_buffers = GL_FALSE;\nGLboolean __GLEW_ARB_draw_buffers_blend = GL_FALSE;\nGLboolean __GLEW_ARB_draw_elements_base_vertex = GL_FALSE;\nGLboolean __GLEW_ARB_draw_indirect = GL_FALSE;\nGLboolean __GLEW_ARB_draw_instanced = GL_FALSE;\nGLboolean __GLEW_ARB_explicit_attrib_location = GL_FALSE;\nGLboolean __GLEW_ARB_explicit_uniform_location = GL_FALSE;\nGLboolean __GLEW_ARB_fragment_coord_conventions = GL_FALSE;\nGLboolean __GLEW_ARB_fragment_layer_viewport = GL_FALSE;\nGLboolean __GLEW_ARB_fragment_program = GL_FALSE;\nGLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE;\nGLboolean __GLEW_ARB_fragment_shader = GL_FALSE;\nGLboolean __GLEW_ARB_framebuffer_no_attachments = GL_FALSE;\nGLboolean __GLEW_ARB_framebuffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_framebuffer_sRGB = GL_FALSE;\nGLboolean __GLEW_ARB_geometry_shader4 = GL_FALSE;\nGLboolean __GLEW_ARB_get_program_binary = GL_FALSE;\nGLboolean __GLEW_ARB_gpu_shader5 = GL_FALSE;\nGLboolean __GLEW_ARB_gpu_shader_fp64 = GL_FALSE;\nGLboolean __GLEW_ARB_half_float_pixel = GL_FALSE;\nGLboolean __GLEW_ARB_half_float_vertex = GL_FALSE;\nGLboolean __GLEW_ARB_imaging = GL_FALSE;\nGLboolean __GLEW_ARB_instanced_arrays = GL_FALSE;\nGLboolean __GLEW_ARB_internalformat_query = GL_FALSE;\nGLboolean __GLEW_ARB_internalformat_query2 = GL_FALSE;\nGLboolean __GLEW_ARB_invalidate_subdata = GL_FALSE;\nGLboolean __GLEW_ARB_map_buffer_alignment = GL_FALSE;\nGLboolean __GLEW_ARB_map_buffer_range = GL_FALSE;\nGLboolean __GLEW_ARB_matrix_palette = GL_FALSE;\nGLboolean __GLEW_ARB_multi_draw_indirect = GL_FALSE;\nGLboolean __GLEW_ARB_multisample = GL_FALSE;\nGLboolean __GLEW_ARB_multitexture = GL_FALSE;\nGLboolean __GLEW_ARB_occlusion_query = GL_FALSE;\nGLboolean __GLEW_ARB_occlusion_query2 = GL_FALSE;\nGLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_point_parameters = GL_FALSE;\nGLboolean __GLEW_ARB_point_sprite = GL_FALSE;\nGLboolean __GLEW_ARB_program_interface_query = GL_FALSE;\nGLboolean __GLEW_ARB_provoking_vertex = GL_FALSE;\nGLboolean __GLEW_ARB_robust_buffer_access_behavior = GL_FALSE;\nGLboolean __GLEW_ARB_robustness = GL_FALSE;\nGLboolean __GLEW_ARB_robustness_application_isolation = GL_FALSE;\nGLboolean __GLEW_ARB_robustness_share_group_isolation = GL_FALSE;\nGLboolean __GLEW_ARB_sample_shading = GL_FALSE;\nGLboolean __GLEW_ARB_sampler_objects = GL_FALSE;\nGLboolean __GLEW_ARB_seamless_cube_map = GL_FALSE;\nGLboolean __GLEW_ARB_separate_shader_objects = GL_FALSE;\nGLboolean __GLEW_ARB_shader_atomic_counters = GL_FALSE;\nGLboolean __GLEW_ARB_shader_bit_encoding = GL_FALSE;\nGLboolean __GLEW_ARB_shader_image_load_store = GL_FALSE;\nGLboolean __GLEW_ARB_shader_image_size = GL_FALSE;\nGLboolean __GLEW_ARB_shader_objects = GL_FALSE;\nGLboolean __GLEW_ARB_shader_precision = GL_FALSE;\nGLboolean __GLEW_ARB_shader_stencil_export = GL_FALSE;\nGLboolean __GLEW_ARB_shader_storage_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_shader_subroutine = GL_FALSE;\nGLboolean __GLEW_ARB_shader_texture_lod = GL_FALSE;\nGLboolean __GLEW_ARB_shading_language_100 = GL_FALSE;\nGLboolean __GLEW_ARB_shading_language_420pack = GL_FALSE;\nGLboolean __GLEW_ARB_shading_language_include = GL_FALSE;\nGLboolean __GLEW_ARB_shading_language_packing = GL_FALSE;\nGLboolean __GLEW_ARB_shadow = GL_FALSE;\nGLboolean __GLEW_ARB_shadow_ambient = GL_FALSE;\nGLboolean __GLEW_ARB_stencil_texturing = GL_FALSE;\nGLboolean __GLEW_ARB_sync = GL_FALSE;\nGLboolean __GLEW_ARB_tessellation_shader = GL_FALSE;\nGLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE;\nGLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_texture_buffer_object_rgb32 = GL_FALSE;\nGLboolean __GLEW_ARB_texture_buffer_range = GL_FALSE;\nGLboolean __GLEW_ARB_texture_compression = GL_FALSE;\nGLboolean __GLEW_ARB_texture_compression_bptc = GL_FALSE;\nGLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE;\nGLboolean __GLEW_ARB_texture_cube_map = GL_FALSE;\nGLboolean __GLEW_ARB_texture_cube_map_array = GL_FALSE;\nGLboolean __GLEW_ARB_texture_env_add = GL_FALSE;\nGLboolean __GLEW_ARB_texture_env_combine = GL_FALSE;\nGLboolean __GLEW_ARB_texture_env_crossbar = GL_FALSE;\nGLboolean __GLEW_ARB_texture_env_dot3 = GL_FALSE;\nGLboolean __GLEW_ARB_texture_float = GL_FALSE;\nGLboolean __GLEW_ARB_texture_gather = GL_FALSE;\nGLboolean __GLEW_ARB_texture_mirrored_repeat = GL_FALSE;\nGLboolean __GLEW_ARB_texture_multisample = GL_FALSE;\nGLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE;\nGLboolean __GLEW_ARB_texture_query_levels = GL_FALSE;\nGLboolean __GLEW_ARB_texture_query_lod = GL_FALSE;\nGLboolean __GLEW_ARB_texture_rectangle = GL_FALSE;\nGLboolean __GLEW_ARB_texture_rg = GL_FALSE;\nGLboolean __GLEW_ARB_texture_rgb10_a2ui = GL_FALSE;\nGLboolean __GLEW_ARB_texture_storage = GL_FALSE;\nGLboolean __GLEW_ARB_texture_storage_multisample = GL_FALSE;\nGLboolean __GLEW_ARB_texture_swizzle = GL_FALSE;\nGLboolean __GLEW_ARB_texture_view = GL_FALSE;\nGLboolean __GLEW_ARB_timer_query = GL_FALSE;\nGLboolean __GLEW_ARB_transform_feedback2 = GL_FALSE;\nGLboolean __GLEW_ARB_transform_feedback3 = GL_FALSE;\nGLboolean __GLEW_ARB_transform_feedback_instanced = GL_FALSE;\nGLboolean __GLEW_ARB_transpose_matrix = GL_FALSE;\nGLboolean __GLEW_ARB_uniform_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_array_bgra = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_array_object = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_attrib_64bit = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_attrib_binding = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_blend = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_program = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_shader = GL_FALSE;\nGLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev = GL_FALSE;\nGLboolean __GLEW_ARB_viewport_array = GL_FALSE;\nGLboolean __GLEW_ARB_window_pos = GL_FALSE;\nGLboolean __GLEW_ATIX_point_sprites = GL_FALSE;\nGLboolean __GLEW_ATIX_texture_env_combine3 = GL_FALSE;\nGLboolean __GLEW_ATIX_texture_env_route = GL_FALSE;\nGLboolean __GLEW_ATIX_vertex_shader_output_point_size = GL_FALSE;\nGLboolean __GLEW_ATI_draw_buffers = GL_FALSE;\nGLboolean __GLEW_ATI_element_array = GL_FALSE;\nGLboolean __GLEW_ATI_envmap_bumpmap = GL_FALSE;\nGLboolean __GLEW_ATI_fragment_shader = GL_FALSE;\nGLboolean __GLEW_ATI_map_object_buffer = GL_FALSE;\nGLboolean __GLEW_ATI_meminfo = GL_FALSE;\nGLboolean __GLEW_ATI_pn_triangles = GL_FALSE;\nGLboolean __GLEW_ATI_separate_stencil = GL_FALSE;\nGLboolean __GLEW_ATI_shader_texture_lod = GL_FALSE;\nGLboolean __GLEW_ATI_text_fragment_shader = GL_FALSE;\nGLboolean __GLEW_ATI_texture_compression_3dc = GL_FALSE;\nGLboolean __GLEW_ATI_texture_env_combine3 = GL_FALSE;\nGLboolean __GLEW_ATI_texture_float = GL_FALSE;\nGLboolean __GLEW_ATI_texture_mirror_once = GL_FALSE;\nGLboolean __GLEW_ATI_vertex_array_object = GL_FALSE;\nGLboolean __GLEW_ATI_vertex_attrib_array_object = GL_FALSE;\nGLboolean __GLEW_ATI_vertex_streams = GL_FALSE;\nGLboolean __GLEW_EXT_422_pixels = GL_FALSE;\nGLboolean __GLEW_EXT_Cg_shader = GL_FALSE;\nGLboolean __GLEW_EXT_abgr = GL_FALSE;\nGLboolean __GLEW_EXT_bgra = GL_FALSE;\nGLboolean __GLEW_EXT_bindable_uniform = GL_FALSE;\nGLboolean __GLEW_EXT_blend_color = GL_FALSE;\nGLboolean __GLEW_EXT_blend_equation_separate = GL_FALSE;\nGLboolean __GLEW_EXT_blend_func_separate = GL_FALSE;\nGLboolean __GLEW_EXT_blend_logic_op = GL_FALSE;\nGLboolean __GLEW_EXT_blend_minmax = GL_FALSE;\nGLboolean __GLEW_EXT_blend_subtract = GL_FALSE;\nGLboolean __GLEW_EXT_clip_volume_hint = GL_FALSE;\nGLboolean __GLEW_EXT_cmyka = GL_FALSE;\nGLboolean __GLEW_EXT_color_subtable = GL_FALSE;\nGLboolean __GLEW_EXT_compiled_vertex_array = GL_FALSE;\nGLboolean __GLEW_EXT_convolution = GL_FALSE;\nGLboolean __GLEW_EXT_coordinate_frame = GL_FALSE;\nGLboolean __GLEW_EXT_copy_texture = GL_FALSE;\nGLboolean __GLEW_EXT_cull_vertex = GL_FALSE;\nGLboolean __GLEW_EXT_debug_marker = GL_FALSE;\nGLboolean __GLEW_EXT_depth_bounds_test = GL_FALSE;\nGLboolean __GLEW_EXT_direct_state_access = GL_FALSE;\nGLboolean __GLEW_EXT_draw_buffers2 = GL_FALSE;\nGLboolean __GLEW_EXT_draw_instanced = GL_FALSE;\nGLboolean __GLEW_EXT_draw_range_elements = GL_FALSE;\nGLboolean __GLEW_EXT_fog_coord = GL_FALSE;\nGLboolean __GLEW_EXT_fragment_lighting = GL_FALSE;\nGLboolean __GLEW_EXT_framebuffer_blit = GL_FALSE;\nGLboolean __GLEW_EXT_framebuffer_multisample = GL_FALSE;\nGLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled = GL_FALSE;\nGLboolean __GLEW_EXT_framebuffer_object = GL_FALSE;\nGLboolean __GLEW_EXT_framebuffer_sRGB = GL_FALSE;\nGLboolean __GLEW_EXT_geometry_shader4 = GL_FALSE;\nGLboolean __GLEW_EXT_gpu_program_parameters = GL_FALSE;\nGLboolean __GLEW_EXT_gpu_shader4 = GL_FALSE;\nGLboolean __GLEW_EXT_histogram = GL_FALSE;\nGLboolean __GLEW_EXT_index_array_formats = GL_FALSE;\nGLboolean __GLEW_EXT_index_func = GL_FALSE;\nGLboolean __GLEW_EXT_index_material = GL_FALSE;\nGLboolean __GLEW_EXT_index_texture = GL_FALSE;\nGLboolean __GLEW_EXT_light_texture = GL_FALSE;\nGLboolean __GLEW_EXT_misc_attribute = GL_FALSE;\nGLboolean __GLEW_EXT_multi_draw_arrays = GL_FALSE;\nGLboolean __GLEW_EXT_multisample = GL_FALSE;\nGLboolean __GLEW_EXT_packed_depth_stencil = GL_FALSE;\nGLboolean __GLEW_EXT_packed_float = GL_FALSE;\nGLboolean __GLEW_EXT_packed_pixels = GL_FALSE;\nGLboolean __GLEW_EXT_paletted_texture = GL_FALSE;\nGLboolean __GLEW_EXT_pixel_buffer_object = GL_FALSE;\nGLboolean __GLEW_EXT_pixel_transform = GL_FALSE;\nGLboolean __GLEW_EXT_pixel_transform_color_table = GL_FALSE;\nGLboolean __GLEW_EXT_point_parameters = GL_FALSE;\nGLboolean __GLEW_EXT_polygon_offset = GL_FALSE;\nGLboolean __GLEW_EXT_provoking_vertex = GL_FALSE;\nGLboolean __GLEW_EXT_rescale_normal = GL_FALSE;\nGLboolean __GLEW_EXT_scene_marker = GL_FALSE;\nGLboolean __GLEW_EXT_secondary_color = GL_FALSE;\nGLboolean __GLEW_EXT_separate_shader_objects = GL_FALSE;\nGLboolean __GLEW_EXT_separate_specular_color = GL_FALSE;\nGLboolean __GLEW_EXT_shader_image_load_store = GL_FALSE;\nGLboolean __GLEW_EXT_shadow_funcs = GL_FALSE;\nGLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE;\nGLboolean __GLEW_EXT_stencil_clear_tag = GL_FALSE;\nGLboolean __GLEW_EXT_stencil_two_side = GL_FALSE;\nGLboolean __GLEW_EXT_stencil_wrap = GL_FALSE;\nGLboolean __GLEW_EXT_subtexture = GL_FALSE;\nGLboolean __GLEW_EXT_texture = GL_FALSE;\nGLboolean __GLEW_EXT_texture3D = GL_FALSE;\nGLboolean __GLEW_EXT_texture_array = GL_FALSE;\nGLboolean __GLEW_EXT_texture_buffer_object = GL_FALSE;\nGLboolean __GLEW_EXT_texture_compression_dxt1 = GL_FALSE;\nGLboolean __GLEW_EXT_texture_compression_latc = GL_FALSE;\nGLboolean __GLEW_EXT_texture_compression_rgtc = GL_FALSE;\nGLboolean __GLEW_EXT_texture_compression_s3tc = GL_FALSE;\nGLboolean __GLEW_EXT_texture_cube_map = GL_FALSE;\nGLboolean __GLEW_EXT_texture_edge_clamp = GL_FALSE;\nGLboolean __GLEW_EXT_texture_env = GL_FALSE;\nGLboolean __GLEW_EXT_texture_env_add = GL_FALSE;\nGLboolean __GLEW_EXT_texture_env_combine = GL_FALSE;\nGLboolean __GLEW_EXT_texture_env_dot3 = GL_FALSE;\nGLboolean __GLEW_EXT_texture_filter_anisotropic = GL_FALSE;\nGLboolean __GLEW_EXT_texture_integer = GL_FALSE;\nGLboolean __GLEW_EXT_texture_lod_bias = GL_FALSE;\nGLboolean __GLEW_EXT_texture_mirror_clamp = GL_FALSE;\nGLboolean __GLEW_EXT_texture_object = GL_FALSE;\nGLboolean __GLEW_EXT_texture_perturb_normal = GL_FALSE;\nGLboolean __GLEW_EXT_texture_rectangle = GL_FALSE;\nGLboolean __GLEW_EXT_texture_sRGB = GL_FALSE;\nGLboolean __GLEW_EXT_texture_sRGB_decode = GL_FALSE;\nGLboolean __GLEW_EXT_texture_shared_exponent = GL_FALSE;\nGLboolean __GLEW_EXT_texture_snorm = GL_FALSE;\nGLboolean __GLEW_EXT_texture_swizzle = GL_FALSE;\nGLboolean __GLEW_EXT_timer_query = GL_FALSE;\nGLboolean __GLEW_EXT_transform_feedback = GL_FALSE;\nGLboolean __GLEW_EXT_vertex_array = GL_FALSE;\nGLboolean __GLEW_EXT_vertex_array_bgra = GL_FALSE;\nGLboolean __GLEW_EXT_vertex_attrib_64bit = GL_FALSE;\nGLboolean __GLEW_EXT_vertex_shader = GL_FALSE;\nGLboolean __GLEW_EXT_vertex_weighting = GL_FALSE;\nGLboolean __GLEW_EXT_x11_sync_object = GL_FALSE;\nGLboolean __GLEW_GREMEDY_frame_terminator = GL_FALSE;\nGLboolean __GLEW_GREMEDY_string_marker = GL_FALSE;\nGLboolean __GLEW_HP_convolution_border_modes = GL_FALSE;\nGLboolean __GLEW_HP_image_transform = GL_FALSE;\nGLboolean __GLEW_HP_occlusion_test = GL_FALSE;\nGLboolean __GLEW_HP_texture_lighting = GL_FALSE;\nGLboolean __GLEW_IBM_cull_vertex = GL_FALSE;\nGLboolean __GLEW_IBM_multimode_draw_arrays = GL_FALSE;\nGLboolean __GLEW_IBM_rasterpos_clip = GL_FALSE;\nGLboolean __GLEW_IBM_static_data = GL_FALSE;\nGLboolean __GLEW_IBM_texture_mirrored_repeat = GL_FALSE;\nGLboolean __GLEW_IBM_vertex_array_lists = GL_FALSE;\nGLboolean __GLEW_INGR_color_clamp = GL_FALSE;\nGLboolean __GLEW_INGR_interlace_read = GL_FALSE;\nGLboolean __GLEW_INTEL_parallel_arrays = GL_FALSE;\nGLboolean __GLEW_INTEL_texture_scissor = GL_FALSE;\nGLboolean __GLEW_KHR_debug = GL_FALSE;\nGLboolean __GLEW_KHR_texture_compression_astc_ldr = GL_FALSE;\nGLboolean __GLEW_KTX_buffer_region = GL_FALSE;\nGLboolean __GLEW_MESAX_texture_stack = GL_FALSE;\nGLboolean __GLEW_MESA_pack_invert = GL_FALSE;\nGLboolean __GLEW_MESA_resize_buffers = GL_FALSE;\nGLboolean __GLEW_MESA_window_pos = GL_FALSE;\nGLboolean __GLEW_MESA_ycbcr_texture = GL_FALSE;\nGLboolean __GLEW_NVX_gpu_memory_info = GL_FALSE;\nGLboolean __GLEW_NV_bindless_texture = GL_FALSE;\nGLboolean __GLEW_NV_blend_square = GL_FALSE;\nGLboolean __GLEW_NV_conditional_render = GL_FALSE;\nGLboolean __GLEW_NV_copy_depth_to_color = GL_FALSE;\nGLboolean __GLEW_NV_copy_image = GL_FALSE;\nGLboolean __GLEW_NV_depth_buffer_float = GL_FALSE;\nGLboolean __GLEW_NV_depth_clamp = GL_FALSE;\nGLboolean __GLEW_NV_depth_range_unclamped = GL_FALSE;\nGLboolean __GLEW_NV_evaluators = GL_FALSE;\nGLboolean __GLEW_NV_explicit_multisample = GL_FALSE;\nGLboolean __GLEW_NV_fence = GL_FALSE;\nGLboolean __GLEW_NV_float_buffer = GL_FALSE;\nGLboolean __GLEW_NV_fog_distance = GL_FALSE;\nGLboolean __GLEW_NV_fragment_program = GL_FALSE;\nGLboolean __GLEW_NV_fragment_program2 = GL_FALSE;\nGLboolean __GLEW_NV_fragment_program4 = GL_FALSE;\nGLboolean __GLEW_NV_fragment_program_option = GL_FALSE;\nGLboolean __GLEW_NV_framebuffer_multisample_coverage = GL_FALSE;\nGLboolean __GLEW_NV_geometry_program4 = GL_FALSE;\nGLboolean __GLEW_NV_geometry_shader4 = GL_FALSE;\nGLboolean __GLEW_NV_gpu_program4 = GL_FALSE;\nGLboolean __GLEW_NV_gpu_program5 = GL_FALSE;\nGLboolean __GLEW_NV_gpu_program_fp64 = GL_FALSE;\nGLboolean __GLEW_NV_gpu_shader5 = GL_FALSE;\nGLboolean __GLEW_NV_half_float = GL_FALSE;\nGLboolean __GLEW_NV_light_max_exponent = GL_FALSE;\nGLboolean __GLEW_NV_multisample_coverage = GL_FALSE;\nGLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE;\nGLboolean __GLEW_NV_occlusion_query = GL_FALSE;\nGLboolean __GLEW_NV_packed_depth_stencil = GL_FALSE;\nGLboolean __GLEW_NV_parameter_buffer_object = GL_FALSE;\nGLboolean __GLEW_NV_parameter_buffer_object2 = GL_FALSE;\nGLboolean __GLEW_NV_path_rendering = GL_FALSE;\nGLboolean __GLEW_NV_pixel_data_range = GL_FALSE;\nGLboolean __GLEW_NV_point_sprite = GL_FALSE;\nGLboolean __GLEW_NV_present_video = GL_FALSE;\nGLboolean __GLEW_NV_primitive_restart = GL_FALSE;\nGLboolean __GLEW_NV_register_combiners = GL_FALSE;\nGLboolean __GLEW_NV_register_combiners2 = GL_FALSE;\nGLboolean __GLEW_NV_shader_atomic_float = GL_FALSE;\nGLboolean __GLEW_NV_shader_buffer_load = GL_FALSE;\nGLboolean __GLEW_NV_tessellation_program5 = GL_FALSE;\nGLboolean __GLEW_NV_texgen_emboss = GL_FALSE;\nGLboolean __GLEW_NV_texgen_reflection = GL_FALSE;\nGLboolean __GLEW_NV_texture_barrier = GL_FALSE;\nGLboolean __GLEW_NV_texture_compression_vtc = GL_FALSE;\nGLboolean __GLEW_NV_texture_env_combine4 = GL_FALSE;\nGLboolean __GLEW_NV_texture_expand_normal = GL_FALSE;\nGLboolean __GLEW_NV_texture_multisample = GL_FALSE;\nGLboolean __GLEW_NV_texture_rectangle = GL_FALSE;\nGLboolean __GLEW_NV_texture_shader = GL_FALSE;\nGLboolean __GLEW_NV_texture_shader2 = GL_FALSE;\nGLboolean __GLEW_NV_texture_shader3 = GL_FALSE;\nGLboolean __GLEW_NV_transform_feedback = GL_FALSE;\nGLboolean __GLEW_NV_transform_feedback2 = GL_FALSE;\nGLboolean __GLEW_NV_vdpau_interop = GL_FALSE;\nGLboolean __GLEW_NV_vertex_array_range = GL_FALSE;\nGLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE;\nGLboolean __GLEW_NV_vertex_attrib_integer_64bit = GL_FALSE;\nGLboolean __GLEW_NV_vertex_buffer_unified_memory = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program2 = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program2_option = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program3 = GL_FALSE;\nGLboolean __GLEW_NV_vertex_program4 = GL_FALSE;\nGLboolean __GLEW_NV_video_capture = GL_FALSE;\nGLboolean __GLEW_OES_byte_coordinates = GL_FALSE;\nGLboolean __GLEW_OES_compressed_paletted_texture = GL_FALSE;\nGLboolean __GLEW_OES_read_format = GL_FALSE;\nGLboolean __GLEW_OES_single_precision = GL_FALSE;\nGLboolean __GLEW_OML_interlace = GL_FALSE;\nGLboolean __GLEW_OML_resample = GL_FALSE;\nGLboolean __GLEW_OML_subsample = GL_FALSE;\nGLboolean __GLEW_PGI_misc_hints = GL_FALSE;\nGLboolean __GLEW_PGI_vertex_hints = GL_FALSE;\nGLboolean __GLEW_REGAL_error_string = GL_FALSE;\nGLboolean __GLEW_REGAL_extension_query = GL_FALSE;\nGLboolean __GLEW_REGAL_log = GL_FALSE;\nGLboolean __GLEW_REND_screen_coordinates = GL_FALSE;\nGLboolean __GLEW_S3_s3tc = GL_FALSE;\nGLboolean __GLEW_SGIS_color_range = GL_FALSE;\nGLboolean __GLEW_SGIS_detail_texture = GL_FALSE;\nGLboolean __GLEW_SGIS_fog_function = GL_FALSE;\nGLboolean __GLEW_SGIS_generate_mipmap = GL_FALSE;\nGLboolean __GLEW_SGIS_multisample = GL_FALSE;\nGLboolean __GLEW_SGIS_pixel_texture = GL_FALSE;\nGLboolean __GLEW_SGIS_point_line_texgen = GL_FALSE;\nGLboolean __GLEW_SGIS_sharpen_texture = GL_FALSE;\nGLboolean __GLEW_SGIS_texture4D = GL_FALSE;\nGLboolean __GLEW_SGIS_texture_border_clamp = GL_FALSE;\nGLboolean __GLEW_SGIS_texture_edge_clamp = GL_FALSE;\nGLboolean __GLEW_SGIS_texture_filter4 = GL_FALSE;\nGLboolean __GLEW_SGIS_texture_lod = GL_FALSE;\nGLboolean __GLEW_SGIS_texture_select = GL_FALSE;\nGLboolean __GLEW_SGIX_async = GL_FALSE;\nGLboolean __GLEW_SGIX_async_histogram = GL_FALSE;\nGLboolean __GLEW_SGIX_async_pixel = GL_FALSE;\nGLboolean __GLEW_SGIX_blend_alpha_minmax = GL_FALSE;\nGLboolean __GLEW_SGIX_clipmap = GL_FALSE;\nGLboolean __GLEW_SGIX_convolution_accuracy = GL_FALSE;\nGLboolean __GLEW_SGIX_depth_texture = GL_FALSE;\nGLboolean __GLEW_SGIX_flush_raster = GL_FALSE;\nGLboolean __GLEW_SGIX_fog_offset = GL_FALSE;\nGLboolean __GLEW_SGIX_fog_texture = GL_FALSE;\nGLboolean __GLEW_SGIX_fragment_specular_lighting = GL_FALSE;\nGLboolean __GLEW_SGIX_framezoom = GL_FALSE;\nGLboolean __GLEW_SGIX_interlace = GL_FALSE;\nGLboolean __GLEW_SGIX_ir_instrument1 = GL_FALSE;\nGLboolean __GLEW_SGIX_list_priority = GL_FALSE;\nGLboolean __GLEW_SGIX_pixel_texture = GL_FALSE;\nGLboolean __GLEW_SGIX_pixel_texture_bits = GL_FALSE;\nGLboolean __GLEW_SGIX_reference_plane = GL_FALSE;\nGLboolean __GLEW_SGIX_resample = GL_FALSE;\nGLboolean __GLEW_SGIX_shadow = GL_FALSE;\nGLboolean __GLEW_SGIX_shadow_ambient = GL_FALSE;\nGLboolean __GLEW_SGIX_sprite = GL_FALSE;\nGLboolean __GLEW_SGIX_tag_sample_buffer = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_add_env = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_coordinate_clamp = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_lod_bias = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_multi_buffer = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_range = GL_FALSE;\nGLboolean __GLEW_SGIX_texture_scale_bias = GL_FALSE;\nGLboolean __GLEW_SGIX_vertex_preclip = GL_FALSE;\nGLboolean __GLEW_SGIX_vertex_preclip_hint = GL_FALSE;\nGLboolean __GLEW_SGIX_ycrcb = GL_FALSE;\nGLboolean __GLEW_SGI_color_matrix = GL_FALSE;\nGLboolean __GLEW_SGI_color_table = GL_FALSE;\nGLboolean __GLEW_SGI_texture_color_table = GL_FALSE;\nGLboolean __GLEW_SUNX_constant_data = GL_FALSE;\nGLboolean __GLEW_SUN_convolution_border_modes = GL_FALSE;\nGLboolean __GLEW_SUN_global_alpha = GL_FALSE;\nGLboolean __GLEW_SUN_mesh_array = GL_FALSE;\nGLboolean __GLEW_SUN_read_video_pixels = GL_FALSE;\nGLboolean __GLEW_SUN_slice_accum = GL_FALSE;\nGLboolean __GLEW_SUN_triangle_list = GL_FALSE;\nGLboolean __GLEW_SUN_vertex = GL_FALSE;\nGLboolean __GLEW_WIN_phong_shading = GL_FALSE;\nGLboolean __GLEW_WIN_specular_fog = GL_FALSE;\nGLboolean __GLEW_WIN_swap_hint = GL_FALSE;\n\n#endif /* !GLEW_MX */\n\n#ifdef GL_VERSION_1_2\n\nstatic GLboolean _glewInit_GL_VERSION_1_2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexSubImage3D\")) == NULL) || r;\n  r = ((glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)glewGetProcAddress((const GLubyte*)\"glDrawRangeElements\")) == NULL) || r;\n  r = ((glTexImage3D = (PFNGLTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glTexImage3D\")) == NULL) || r;\n  r = ((glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glTexSubImage3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_1_2 */\n\n#ifdef GL_VERSION_1_2_1\n\n#endif /* GL_VERSION_1_2_1 */\n\n#ifdef GL_VERSION_1_3\n\nstatic GLboolean _glewInit_GL_VERSION_1_3 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveTexture = (PFNGLACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)\"glActiveTexture\")) == NULL) || r;\n  r = ((glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)\"glClientActiveTexture\")) == NULL) || r;\n  r = ((glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage1D\")) == NULL) || r;\n  r = ((glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage2D\")) == NULL) || r;\n  r = ((glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage3D\")) == NULL) || r;\n  r = ((glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage1D\")) == NULL) || r;\n  r = ((glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage2D\")) == NULL) || r;\n  r = ((glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage3D\")) == NULL) || r;\n  r = ((glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)\"glGetCompressedTexImage\")) == NULL) || r;\n  r = ((glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)\"glLoadTransposeMatrixd\")) == NULL) || r;\n  r = ((glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)\"glLoadTransposeMatrixf\")) == NULL) || r;\n  r = ((glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)\"glMultTransposeMatrixd\")) == NULL) || r;\n  r = ((glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)\"glMultTransposeMatrixf\")) == NULL) || r;\n  r = ((glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1d\")) == NULL) || r;\n  r = ((glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1dv\")) == NULL) || r;\n  r = ((glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1f\")) == NULL) || r;\n  r = ((glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1fv\")) == NULL) || r;\n  r = ((glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1i\")) == NULL) || r;\n  r = ((glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1iv\")) == NULL) || r;\n  r = ((glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1s\")) == NULL) || r;\n  r = ((glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1sv\")) == NULL) || r;\n  r = ((glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2d\")) == NULL) || r;\n  r = ((glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2dv\")) == NULL) || r;\n  r = ((glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2f\")) == NULL) || r;\n  r = ((glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2fv\")) == NULL) || r;\n  r = ((glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2i\")) == NULL) || r;\n  r = ((glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2iv\")) == NULL) || r;\n  r = ((glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2s\")) == NULL) || r;\n  r = ((glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2sv\")) == NULL) || r;\n  r = ((glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3d\")) == NULL) || r;\n  r = ((glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3dv\")) == NULL) || r;\n  r = ((glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3f\")) == NULL) || r;\n  r = ((glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3fv\")) == NULL) || r;\n  r = ((glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3i\")) == NULL) || r;\n  r = ((glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3iv\")) == NULL) || r;\n  r = ((glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3s\")) == NULL) || r;\n  r = ((glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3sv\")) == NULL) || r;\n  r = ((glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4d\")) == NULL) || r;\n  r = ((glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4dv\")) == NULL) || r;\n  r = ((glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4f\")) == NULL) || r;\n  r = ((glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4fv\")) == NULL) || r;\n  r = ((glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4i\")) == NULL) || r;\n  r = ((glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4iv\")) == NULL) || r;\n  r = ((glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4s\")) == NULL) || r;\n  r = ((glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4sv\")) == NULL) || r;\n  r = ((glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)glewGetProcAddress((const GLubyte*)\"glSampleCoverage\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_1_3 */\n\n#ifdef GL_VERSION_1_4\n\nstatic GLboolean _glewInit_GL_VERSION_1_4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendColor = (PFNGLBLENDCOLORPROC)glewGetProcAddress((const GLubyte*)\"glBlendColor\")) == NULL) || r;\n  r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n  r = ((glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncSeparate\")) == NULL) || r;\n  r = ((glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordPointer\")) == NULL) || r;\n  r = ((glFogCoordd = (PFNGLFOGCOORDDPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordd\")) == NULL) || r;\n  r = ((glFogCoorddv = (PFNGLFOGCOORDDVPROC)glewGetProcAddress((const GLubyte*)\"glFogCoorddv\")) == NULL) || r;\n  r = ((glFogCoordf = (PFNGLFOGCOORDFPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordf\")) == NULL) || r;\n  r = ((glFogCoordfv = (PFNGLFOGCOORDFVPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordfv\")) == NULL) || r;\n  r = ((glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawArrays\")) == NULL) || r;\n  r = ((glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElements\")) == NULL) || r;\n  r = ((glPointParameterf = (PFNGLPOINTPARAMETERFPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterf\")) == NULL) || r;\n  r = ((glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterfv\")) == NULL) || r;\n  r = ((glPointParameteri = (PFNGLPOINTPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glPointParameteri\")) == NULL) || r;\n  r = ((glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glPointParameteriv\")) == NULL) || r;\n  r = ((glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3b\")) == NULL) || r;\n  r = ((glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3bv\")) == NULL) || r;\n  r = ((glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3d\")) == NULL) || r;\n  r = ((glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3dv\")) == NULL) || r;\n  r = ((glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3f\")) == NULL) || r;\n  r = ((glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3fv\")) == NULL) || r;\n  r = ((glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3i\")) == NULL) || r;\n  r = ((glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3iv\")) == NULL) || r;\n  r = ((glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3s\")) == NULL) || r;\n  r = ((glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3sv\")) == NULL) || r;\n  r = ((glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ub\")) == NULL) || r;\n  r = ((glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ubv\")) == NULL) || r;\n  r = ((glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ui\")) == NULL) || r;\n  r = ((glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3uiv\")) == NULL) || r;\n  r = ((glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3us\")) == NULL) || r;\n  r = ((glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3usv\")) == NULL) || r;\n  r = ((glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorPointer\")) == NULL) || r;\n  r = ((glWindowPos2d = (PFNGLWINDOWPOS2DPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2d\")) == NULL) || r;\n  r = ((glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2dv\")) == NULL) || r;\n  r = ((glWindowPos2f = (PFNGLWINDOWPOS2FPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2f\")) == NULL) || r;\n  r = ((glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2fv\")) == NULL) || r;\n  r = ((glWindowPos2i = (PFNGLWINDOWPOS2IPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2i\")) == NULL) || r;\n  r = ((glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2iv\")) == NULL) || r;\n  r = ((glWindowPos2s = (PFNGLWINDOWPOS2SPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2s\")) == NULL) || r;\n  r = ((glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2sv\")) == NULL) || r;\n  r = ((glWindowPos3d = (PFNGLWINDOWPOS3DPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3d\")) == NULL) || r;\n  r = ((glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3dv\")) == NULL) || r;\n  r = ((glWindowPos3f = (PFNGLWINDOWPOS3FPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3f\")) == NULL) || r;\n  r = ((glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3fv\")) == NULL) || r;\n  r = ((glWindowPos3i = (PFNGLWINDOWPOS3IPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3i\")) == NULL) || r;\n  r = ((glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3iv\")) == NULL) || r;\n  r = ((glWindowPos3s = (PFNGLWINDOWPOS3SPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3s\")) == NULL) || r;\n  r = ((glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3sv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_1_4 */\n\n#ifdef GL_VERSION_1_5\n\nstatic GLboolean _glewInit_GL_VERSION_1_5 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginQuery = (PFNGLBEGINQUERYPROC)glewGetProcAddress((const GLubyte*)\"glBeginQuery\")) == NULL) || r;\n  r = ((glBindBuffer = (PFNGLBINDBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glBindBuffer\")) == NULL) || r;\n  r = ((glBufferData = (PFNGLBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)\"glBufferData\")) == NULL) || r;\n  r = ((glBufferSubData = (PFNGLBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glBufferSubData\")) == NULL) || r;\n  r = ((glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteBuffers\")) == NULL) || r;\n  r = ((glDeleteQueries = (PFNGLDELETEQUERIESPROC)glewGetProcAddress((const GLubyte*)\"glDeleteQueries\")) == NULL) || r;\n  r = ((glEndQuery = (PFNGLENDQUERYPROC)glewGetProcAddress((const GLubyte*)\"glEndQuery\")) == NULL) || r;\n  r = ((glGenBuffers = (PFNGLGENBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glGenBuffers\")) == NULL) || r;\n  r = ((glGenQueries = (PFNGLGENQUERIESPROC)glewGetProcAddress((const GLubyte*)\"glGenQueries\")) == NULL) || r;\n  r = ((glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferParameteriv\")) == NULL) || r;\n  r = ((glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferPointerv\")) == NULL) || r;\n  r = ((glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferSubData\")) == NULL) || r;\n  r = ((glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectiv\")) == NULL) || r;\n  r = ((glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectuiv\")) == NULL) || r;\n  r = ((glGetQueryiv = (PFNGLGETQUERYIVPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryiv\")) == NULL) || r;\n  r = ((glIsBuffer = (PFNGLISBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glIsBuffer\")) == NULL) || r;\n  r = ((glIsQuery = (PFNGLISQUERYPROC)glewGetProcAddress((const GLubyte*)\"glIsQuery\")) == NULL) || r;\n  r = ((glMapBuffer = (PFNGLMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glMapBuffer\")) == NULL) || r;\n  r = ((glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glUnmapBuffer\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_1_5 */\n\n#ifdef GL_VERSION_2_0\n\nstatic GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAttachShader = (PFNGLATTACHSHADERPROC)glewGetProcAddress((const GLubyte*)\"glAttachShader\")) == NULL) || r;\n  r = ((glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glBindAttribLocation\")) == NULL) || r;\n  r = ((glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationSeparate\")) == NULL) || r;\n  r = ((glCompileShader = (PFNGLCOMPILESHADERPROC)glewGetProcAddress((const GLubyte*)\"glCompileShader\")) == NULL) || r;\n  r = ((glCreateProgram = (PFNGLCREATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glCreateProgram\")) == NULL) || r;\n  r = ((glCreateShader = (PFNGLCREATESHADERPROC)glewGetProcAddress((const GLubyte*)\"glCreateShader\")) == NULL) || r;\n  r = ((glDeleteProgram = (PFNGLDELETEPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glDeleteProgram\")) == NULL) || r;\n  r = ((glDeleteShader = (PFNGLDELETESHADERPROC)glewGetProcAddress((const GLubyte*)\"glDeleteShader\")) == NULL) || r;\n  r = ((glDetachShader = (PFNGLDETACHSHADERPROC)glewGetProcAddress((const GLubyte*)\"glDetachShader\")) == NULL) || r;\n  r = ((glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)\"glDisableVertexAttribArray\")) == NULL) || r;\n  r = ((glDrawBuffers = (PFNGLDRAWBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glDrawBuffers\")) == NULL) || r;\n  r = ((glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)\"glEnableVertexAttribArray\")) == NULL) || r;\n  r = ((glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveAttrib\")) == NULL) || r;\n  r = ((glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniform\")) == NULL) || r;\n  r = ((glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)glewGetProcAddress((const GLubyte*)\"glGetAttachedShaders\")) == NULL) || r;\n  r = ((glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glGetAttribLocation\")) == NULL) || r;\n  r = ((glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramInfoLog\")) == NULL) || r;\n  r = ((glGetProgramiv = (PFNGLGETPROGRAMIVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramiv\")) == NULL) || r;\n  r = ((glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)glewGetProcAddress((const GLubyte*)\"glGetShaderInfoLog\")) == NULL) || r;\n  r = ((glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)\"glGetShaderSource\")) == NULL) || r;\n  r = ((glGetShaderiv = (PFNGLGETSHADERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetShaderiv\")) == NULL) || r;\n  r = ((glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformLocation\")) == NULL) || r;\n  r = ((glGetUniformfv = (PFNGLGETUNIFORMFVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformfv\")) == NULL) || r;\n  r = ((glGetUniformiv = (PFNGLGETUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformiv\")) == NULL) || r;\n  r = ((glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribPointerv\")) == NULL) || r;\n  r = ((glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribdv\")) == NULL) || r;\n  r = ((glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribfv\")) == NULL) || r;\n  r = ((glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribiv\")) == NULL) || r;\n  r = ((glIsProgram = (PFNGLISPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glIsProgram\")) == NULL) || r;\n  r = ((glIsShader = (PFNGLISSHADERPROC)glewGetProcAddress((const GLubyte*)\"glIsShader\")) == NULL) || r;\n  r = ((glLinkProgram = (PFNGLLINKPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glLinkProgram\")) == NULL) || r;\n  r = ((glShaderSource = (PFNGLSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)\"glShaderSource\")) == NULL) || r;\n  r = ((glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)\"glStencilFuncSeparate\")) == NULL) || r;\n  r = ((glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)glewGetProcAddress((const GLubyte*)\"glStencilMaskSeparate\")) == NULL) || r;\n  r = ((glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)glewGetProcAddress((const GLubyte*)\"glStencilOpSeparate\")) == NULL) || r;\n  r = ((glUniform1f = (PFNGLUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)\"glUniform1f\")) == NULL) || r;\n  r = ((glUniform1fv = (PFNGLUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1fv\")) == NULL) || r;\n  r = ((glUniform1i = (PFNGLUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)\"glUniform1i\")) == NULL) || r;\n  r = ((glUniform1iv = (PFNGLUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1iv\")) == NULL) || r;\n  r = ((glUniform2f = (PFNGLUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)\"glUniform2f\")) == NULL) || r;\n  r = ((glUniform2fv = (PFNGLUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2fv\")) == NULL) || r;\n  r = ((glUniform2i = (PFNGLUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)\"glUniform2i\")) == NULL) || r;\n  r = ((glUniform2iv = (PFNGLUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2iv\")) == NULL) || r;\n  r = ((glUniform3f = (PFNGLUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)\"glUniform3f\")) == NULL) || r;\n  r = ((glUniform3fv = (PFNGLUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3fv\")) == NULL) || r;\n  r = ((glUniform3i = (PFNGLUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)\"glUniform3i\")) == NULL) || r;\n  r = ((glUniform3iv = (PFNGLUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3iv\")) == NULL) || r;\n  r = ((glUniform4f = (PFNGLUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)\"glUniform4f\")) == NULL) || r;\n  r = ((glUniform4fv = (PFNGLUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4fv\")) == NULL) || r;\n  r = ((glUniform4i = (PFNGLUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)\"glUniform4i\")) == NULL) || r;\n  r = ((glUniform4iv = (PFNGLUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4iv\")) == NULL) || r;\n  r = ((glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2fv\")) == NULL) || r;\n  r = ((glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3fv\")) == NULL) || r;\n  r = ((glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4fv\")) == NULL) || r;\n  r = ((glUseProgram = (PFNGLUSEPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glUseProgram\")) == NULL) || r;\n  r = ((glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glValidateProgram\")) == NULL) || r;\n  r = ((glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1d\")) == NULL) || r;\n  r = ((glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1dv\")) == NULL) || r;\n  r = ((glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1f\")) == NULL) || r;\n  r = ((glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1fv\")) == NULL) || r;\n  r = ((glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1s\")) == NULL) || r;\n  r = ((glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1sv\")) == NULL) || r;\n  r = ((glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2d\")) == NULL) || r;\n  r = ((glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2dv\")) == NULL) || r;\n  r = ((glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2f\")) == NULL) || r;\n  r = ((glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2fv\")) == NULL) || r;\n  r = ((glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2s\")) == NULL) || r;\n  r = ((glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2sv\")) == NULL) || r;\n  r = ((glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3d\")) == NULL) || r;\n  r = ((glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3dv\")) == NULL) || r;\n  r = ((glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3f\")) == NULL) || r;\n  r = ((glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3fv\")) == NULL) || r;\n  r = ((glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3s\")) == NULL) || r;\n  r = ((glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3sv\")) == NULL) || r;\n  r = ((glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nbv\")) == NULL) || r;\n  r = ((glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Niv\")) == NULL) || r;\n  r = ((glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nsv\")) == NULL) || r;\n  r = ((glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nub\")) == NULL) || r;\n  r = ((glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nubv\")) == NULL) || r;\n  r = ((glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nuiv\")) == NULL) || r;\n  r = ((glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4Nusv\")) == NULL) || r;\n  r = ((glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4bv\")) == NULL) || r;\n  r = ((glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4d\")) == NULL) || r;\n  r = ((glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4dv\")) == NULL) || r;\n  r = ((glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4f\")) == NULL) || r;\n  r = ((glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4fv\")) == NULL) || r;\n  r = ((glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4iv\")) == NULL) || r;\n  r = ((glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4s\")) == NULL) || r;\n  r = ((glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4sv\")) == NULL) || r;\n  r = ((glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4ubv\")) == NULL) || r;\n  r = ((glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4uiv\")) == NULL) || r;\n  r = ((glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4usv\")) == NULL) || r;\n  r = ((glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribPointer\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_2_0 */\n\n#ifdef GL_VERSION_2_1\n\nstatic GLboolean _glewInit_GL_VERSION_2_1 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2x3fv\")) == NULL) || r;\n  r = ((glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2x4fv\")) == NULL) || r;\n  r = ((glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3x2fv\")) == NULL) || r;\n  r = ((glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3x4fv\")) == NULL) || r;\n  r = ((glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4x2fv\")) == NULL) || r;\n  r = ((glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4x3fv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_2_1 */\n\n#ifdef GL_VERSION_3_0\n\nstatic GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)\"glBeginConditionalRender\")) == NULL) || r;\n  r = ((glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glBeginTransformFeedback\")) == NULL) || r;\n  r = ((glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glBindFragDataLocation\")) == NULL) || r;\n  r = ((glClampColor = (PFNGLCLAMPCOLORPROC)glewGetProcAddress((const GLubyte*)\"glClampColor\")) == NULL) || r;\n  r = ((glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferfi\")) == NULL) || r;\n  r = ((glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferfv\")) == NULL) || r;\n  r = ((glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferiv\")) == NULL) || r;\n  r = ((glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferuiv\")) == NULL) || r;\n  r = ((glColorMaski = (PFNGLCOLORMASKIPROC)glewGetProcAddress((const GLubyte*)\"glColorMaski\")) == NULL) || r;\n  r = ((glDisablei = (PFNGLDISABLEIPROC)glewGetProcAddress((const GLubyte*)\"glDisablei\")) == NULL) || r;\n  r = ((glEnablei = (PFNGLENABLEIPROC)glewGetProcAddress((const GLubyte*)\"glEnablei\")) == NULL) || r;\n  r = ((glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)\"glEndConditionalRender\")) == NULL) || r;\n  r = ((glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glEndTransformFeedback\")) == NULL) || r;\n  r = ((glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)glewGetProcAddress((const GLubyte*)\"glGetBooleani_v\")) == NULL) || r;\n  r = ((glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glGetFragDataLocation\")) == NULL) || r;\n  r = ((glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)\"glGetStringi\")) == NULL) || r;\n  r = ((glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)\"glGetTexParameterIiv\")) == NULL) || r;\n  r = ((glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetTexParameterIuiv\")) == NULL) || r;\n  r = ((glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)glewGetProcAddress((const GLubyte*)\"glGetTransformFeedbackVarying\")) == NULL) || r;\n  r = ((glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformuiv\")) == NULL) || r;\n  r = ((glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribIiv\")) == NULL) || r;\n  r = ((glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribIuiv\")) == NULL) || r;\n  r = ((glIsEnabledi = (PFNGLISENABLEDIPROC)glewGetProcAddress((const GLubyte*)\"glIsEnabledi\")) == NULL) || r;\n  r = ((glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)\"glTexParameterIiv\")) == NULL) || r;\n  r = ((glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)\"glTexParameterIuiv\")) == NULL) || r;\n  r = ((glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)glewGetProcAddress((const GLubyte*)\"glTransformFeedbackVaryings\")) == NULL) || r;\n  r = ((glUniform1ui = (PFNGLUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)\"glUniform1ui\")) == NULL) || r;\n  r = ((glUniform1uiv = (PFNGLUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1uiv\")) == NULL) || r;\n  r = ((glUniform2ui = (PFNGLUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)\"glUniform2ui\")) == NULL) || r;\n  r = ((glUniform2uiv = (PFNGLUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2uiv\")) == NULL) || r;\n  r = ((glUniform3ui = (PFNGLUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)\"glUniform3ui\")) == NULL) || r;\n  r = ((glUniform3uiv = (PFNGLUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3uiv\")) == NULL) || r;\n  r = ((glUniform4ui = (PFNGLUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)\"glUniform4ui\")) == NULL) || r;\n  r = ((glUniform4uiv = (PFNGLUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4uiv\")) == NULL) || r;\n  r = ((glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1i\")) == NULL) || r;\n  r = ((glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1iv\")) == NULL) || r;\n  r = ((glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1ui\")) == NULL) || r;\n  r = ((glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1uiv\")) == NULL) || r;\n  r = ((glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2i\")) == NULL) || r;\n  r = ((glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2iv\")) == NULL) || r;\n  r = ((glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2ui\")) == NULL) || r;\n  r = ((glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2uiv\")) == NULL) || r;\n  r = ((glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3i\")) == NULL) || r;\n  r = ((glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3iv\")) == NULL) || r;\n  r = ((glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3ui\")) == NULL) || r;\n  r = ((glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3uiv\")) == NULL) || r;\n  r = ((glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4bv\")) == NULL) || r;\n  r = ((glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4i\")) == NULL) || r;\n  r = ((glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4iv\")) == NULL) || r;\n  r = ((glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4sv\")) == NULL) || r;\n  r = ((glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4ubv\")) == NULL) || r;\n  r = ((glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4ui\")) == NULL) || r;\n  r = ((glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4uiv\")) == NULL) || r;\n  r = ((glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4usv\")) == NULL) || r;\n  r = ((glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribIPointer\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_3_0 */\n\n#ifdef GL_VERSION_3_1\n\nstatic GLboolean _glewInit_GL_VERSION_3_1 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysInstanced\")) == NULL) || r;\n  r = ((glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstanced\")) == NULL) || r;\n  r = ((glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)glewGetProcAddress((const GLubyte*)\"glPrimitiveRestartIndex\")) == NULL) || r;\n  r = ((glTexBuffer = (PFNGLTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glTexBuffer\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_3_1 */\n\n#ifdef GL_VERSION_3_2\n\nstatic GLboolean _glewInit_GL_VERSION_3_2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture\")) == NULL) || r;\n  r = ((glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferParameteri64v\")) == NULL) || r;\n  r = ((glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)glewGetProcAddress((const GLubyte*)\"glGetInteger64i_v\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_3_2 */\n\n#ifdef GL_VERSION_3_3\n\nstatic GLboolean _glewInit_GL_VERSION_3_3 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribDivisor\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_3_3 */\n\n#ifdef GL_VERSION_4_0\n\nstatic GLboolean _glewInit_GL_VERSION_4_0 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationSeparatei\")) == NULL) || r;\n  r = ((glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationi\")) == NULL) || r;\n  r = ((glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncSeparatei\")) == NULL) || r;\n  r = ((glBlendFunci = (PFNGLBLENDFUNCIPROC)glewGetProcAddress((const GLubyte*)\"glBlendFunci\")) == NULL) || r;\n  r = ((glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)glewGetProcAddress((const GLubyte*)\"glMinSampleShading\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_VERSION_4_0 */\n\n#ifdef GL_VERSION_4_1\n\n#endif /* GL_VERSION_4_1 */\n\n#ifdef GL_VERSION_4_2\n\n#endif /* GL_VERSION_4_2 */\n\n#ifdef GL_VERSION_4_3\n\n#endif /* GL_VERSION_4_3 */\n\n#ifdef GL_3DFX_multisample\n\n#endif /* GL_3DFX_multisample */\n\n#ifdef GL_3DFX_tbuffer\n\nstatic GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTbufferMask3DFX = (PFNGLTBUFFERMASK3DFXPROC)glewGetProcAddress((const GLubyte*)\"glTbufferMask3DFX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_3DFX_tbuffer */\n\n#ifdef GL_3DFX_texture_compression_FXT1\n\n#endif /* GL_3DFX_texture_compression_FXT1 */\n\n#ifdef GL_AMD_blend_minmax_factor\n\n#endif /* GL_AMD_blend_minmax_factor */\n\n#ifdef GL_AMD_conservative_depth\n\n#endif /* GL_AMD_conservative_depth */\n\n#ifdef GL_AMD_debug_output\n\nstatic GLboolean _glewInit_GL_AMD_debug_output (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDebugMessageCallbackAMD = (PFNGLDEBUGMESSAGECALLBACKAMDPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageCallbackAMD\")) == NULL) || r;\n  r = ((glDebugMessageEnableAMD = (PFNGLDEBUGMESSAGEENABLEAMDPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageEnableAMD\")) == NULL) || r;\n  r = ((glDebugMessageInsertAMD = (PFNGLDEBUGMESSAGEINSERTAMDPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageInsertAMD\")) == NULL) || r;\n  r = ((glGetDebugMessageLogAMD = (PFNGLGETDEBUGMESSAGELOGAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetDebugMessageLogAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_debug_output */\n\n#ifdef GL_AMD_depth_clamp_separate\n\n#endif /* GL_AMD_depth_clamp_separate */\n\n#ifdef GL_AMD_draw_buffers_blend\n\nstatic GLboolean _glewInit_GL_AMD_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquationIndexedAMD = (PFNGLBLENDEQUATIONINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationIndexedAMD\")) == NULL) || r;\n  r = ((glBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationSeparateIndexedAMD\")) == NULL) || r;\n  r = ((glBlendFuncIndexedAMD = (PFNGLBLENDFUNCINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncIndexedAMD\")) == NULL) || r;\n  r = ((glBlendFuncSeparateIndexedAMD = (PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncSeparateIndexedAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_draw_buffers_blend */\n\n#ifdef GL_AMD_multi_draw_indirect\n\nstatic GLboolean _glewInit_GL_AMD_multi_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMultiDrawArraysIndirectAMD = (PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawArraysIndirectAMD\")) == NULL) || r;\n  r = ((glMultiDrawElementsIndirectAMD = (PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElementsIndirectAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_multi_draw_indirect */\n\n#ifdef GL_AMD_name_gen_delete\n\nstatic GLboolean _glewInit_GL_AMD_name_gen_delete (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDeleteNamesAMD = (PFNGLDELETENAMESAMDPROC)glewGetProcAddress((const GLubyte*)\"glDeleteNamesAMD\")) == NULL) || r;\n  r = ((glGenNamesAMD = (PFNGLGENNAMESAMDPROC)glewGetProcAddress((const GLubyte*)\"glGenNamesAMD\")) == NULL) || r;\n  r = ((glIsNameAMD = (PFNGLISNAMEAMDPROC)glewGetProcAddress((const GLubyte*)\"glIsNameAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_name_gen_delete */\n\n#ifdef GL_AMD_performance_monitor\n\nstatic GLboolean _glewInit_GL_AMD_performance_monitor (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginPerfMonitorAMD = (PFNGLBEGINPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)\"glBeginPerfMonitorAMD\")) == NULL) || r;\n  r = ((glDeletePerfMonitorsAMD = (PFNGLDELETEPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)\"glDeletePerfMonitorsAMD\")) == NULL) || r;\n  r = ((glEndPerfMonitorAMD = (PFNGLENDPERFMONITORAMDPROC)glewGetProcAddress((const GLubyte*)\"glEndPerfMonitorAMD\")) == NULL) || r;\n  r = ((glGenPerfMonitorsAMD = (PFNGLGENPERFMONITORSAMDPROC)glewGetProcAddress((const GLubyte*)\"glGenPerfMonitorsAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorCounterDataAMD = (PFNGLGETPERFMONITORCOUNTERDATAAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorCounterDataAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorCounterInfoAMD = (PFNGLGETPERFMONITORCOUNTERINFOAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorCounterInfoAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorCounterStringAMD = (PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorCounterStringAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorCountersAMD = (PFNGLGETPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorCountersAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorGroupStringAMD = (PFNGLGETPERFMONITORGROUPSTRINGAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorGroupStringAMD\")) == NULL) || r;\n  r = ((glGetPerfMonitorGroupsAMD = (PFNGLGETPERFMONITORGROUPSAMDPROC)glewGetProcAddress((const GLubyte*)\"glGetPerfMonitorGroupsAMD\")) == NULL) || r;\n  r = ((glSelectPerfMonitorCountersAMD = (PFNGLSELECTPERFMONITORCOUNTERSAMDPROC)glewGetProcAddress((const GLubyte*)\"glSelectPerfMonitorCountersAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_performance_monitor */\n\n#ifdef GL_AMD_pinned_memory\n\n#endif /* GL_AMD_pinned_memory */\n\n#ifdef GL_AMD_query_buffer_object\n\n#endif /* GL_AMD_query_buffer_object */\n\n#ifdef GL_AMD_sample_positions\n\nstatic GLboolean _glewInit_GL_AMD_sample_positions (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSetMultisamplefvAMD = (PFNGLSETMULTISAMPLEFVAMDPROC)glewGetProcAddress((const GLubyte*)\"glSetMultisamplefvAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_sample_positions */\n\n#ifdef GL_AMD_seamless_cubemap_per_texture\n\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n\n#ifdef GL_AMD_shader_stencil_export\n\n#endif /* GL_AMD_shader_stencil_export */\n\n#ifdef GL_AMD_stencil_operation_extended\n\nstatic GLboolean _glewInit_GL_AMD_stencil_operation_extended (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glStencilOpValueAMD = (PFNGLSTENCILOPVALUEAMDPROC)glewGetProcAddress((const GLubyte*)\"glStencilOpValueAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_stencil_operation_extended */\n\n#ifdef GL_AMD_texture_texture4\n\n#endif /* GL_AMD_texture_texture4 */\n\n#ifdef GL_AMD_transform_feedback3_lines_triangles\n\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n\n#ifdef GL_AMD_vertex_shader_layer\n\n#endif /* GL_AMD_vertex_shader_layer */\n\n#ifdef GL_AMD_vertex_shader_tessellator\n\nstatic GLboolean _glewInit_GL_AMD_vertex_shader_tessellator (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTessellationFactorAMD = (PFNGLTESSELLATIONFACTORAMDPROC)glewGetProcAddress((const GLubyte*)\"glTessellationFactorAMD\")) == NULL) || r;\n  r = ((glTessellationModeAMD = (PFNGLTESSELLATIONMODEAMDPROC)glewGetProcAddress((const GLubyte*)\"glTessellationModeAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_AMD_vertex_shader_tessellator */\n\n#ifdef GL_AMD_vertex_shader_viewport_index\n\n#endif /* GL_AMD_vertex_shader_viewport_index */\n\n#ifdef GL_APPLE_aux_depth_stencil\n\n#endif /* GL_APPLE_aux_depth_stencil */\n\n#ifdef GL_APPLE_client_storage\n\n#endif /* GL_APPLE_client_storage */\n\n#ifdef GL_APPLE_element_array\n\nstatic GLboolean _glewInit_GL_APPLE_element_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawElementArrayAPPLE = (PFNGLDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementArrayAPPLE\")) == NULL) || r;\n  r = ((glDrawRangeElementArrayAPPLE = (PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glDrawRangeElementArrayAPPLE\")) == NULL) || r;\n  r = ((glElementPointerAPPLE = (PFNGLELEMENTPOINTERAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glElementPointerAPPLE\")) == NULL) || r;\n  r = ((glMultiDrawElementArrayAPPLE = (PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElementArrayAPPLE\")) == NULL) || r;\n  r = ((glMultiDrawRangeElementArrayAPPLE = (PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawRangeElementArrayAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_element_array */\n\n#ifdef GL_APPLE_fence\n\nstatic GLboolean _glewInit_GL_APPLE_fence (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDeleteFencesAPPLE = (PFNGLDELETEFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glDeleteFencesAPPLE\")) == NULL) || r;\n  r = ((glFinishFenceAPPLE = (PFNGLFINISHFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glFinishFenceAPPLE\")) == NULL) || r;\n  r = ((glFinishObjectAPPLE = (PFNGLFINISHOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glFinishObjectAPPLE\")) == NULL) || r;\n  r = ((glGenFencesAPPLE = (PFNGLGENFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glGenFencesAPPLE\")) == NULL) || r;\n  r = ((glIsFenceAPPLE = (PFNGLISFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glIsFenceAPPLE\")) == NULL) || r;\n  r = ((glSetFenceAPPLE = (PFNGLSETFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glSetFenceAPPLE\")) == NULL) || r;\n  r = ((glTestFenceAPPLE = (PFNGLTESTFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glTestFenceAPPLE\")) == NULL) || r;\n  r = ((glTestObjectAPPLE = (PFNGLTESTOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glTestObjectAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_fence */\n\n#ifdef GL_APPLE_float_pixels\n\n#endif /* GL_APPLE_float_pixels */\n\n#ifdef GL_APPLE_flush_buffer_range\n\nstatic GLboolean _glewInit_GL_APPLE_flush_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBufferParameteriAPPLE = (PFNGLBUFFERPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glBufferParameteriAPPLE\")) == NULL) || r;\n  r = ((glFlushMappedBufferRangeAPPLE = (PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glFlushMappedBufferRangeAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_flush_buffer_range */\n\n#ifdef GL_APPLE_object_purgeable\n\nstatic GLboolean _glewInit_GL_APPLE_object_purgeable (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetObjectParameterivAPPLE = (PFNGLGETOBJECTPARAMETERIVAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectParameterivAPPLE\")) == NULL) || r;\n  r = ((glObjectPurgeableAPPLE = (PFNGLOBJECTPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glObjectPurgeableAPPLE\")) == NULL) || r;\n  r = ((glObjectUnpurgeableAPPLE = (PFNGLOBJECTUNPURGEABLEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glObjectUnpurgeableAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_object_purgeable */\n\n#ifdef GL_APPLE_pixel_buffer\n\n#endif /* GL_APPLE_pixel_buffer */\n\n#ifdef GL_APPLE_rgb_422\n\n#endif /* GL_APPLE_rgb_422 */\n\n#ifdef GL_APPLE_row_bytes\n\n#endif /* GL_APPLE_row_bytes */\n\n#ifdef GL_APPLE_specular_vector\n\n#endif /* GL_APPLE_specular_vector */\n\n#ifdef GL_APPLE_texture_range\n\nstatic GLboolean _glewInit_GL_APPLE_texture_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetTexParameterPointervAPPLE = (PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glGetTexParameterPointervAPPLE\")) == NULL) || r;\n  r = ((glTextureRangeAPPLE = (PFNGLTEXTURERANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glTextureRangeAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_texture_range */\n\n#ifdef GL_APPLE_transform_hint\n\n#endif /* GL_APPLE_transform_hint */\n\n#ifdef GL_APPLE_vertex_array_object\n\nstatic GLboolean _glewInit_GL_APPLE_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindVertexArrayAPPLE = (PFNGLBINDVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glBindVertexArrayAPPLE\")) == NULL) || r;\n  r = ((glDeleteVertexArraysAPPLE = (PFNGLDELETEVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glDeleteVertexArraysAPPLE\")) == NULL) || r;\n  r = ((glGenVertexArraysAPPLE = (PFNGLGENVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glGenVertexArraysAPPLE\")) == NULL) || r;\n  r = ((glIsVertexArrayAPPLE = (PFNGLISVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glIsVertexArrayAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_vertex_array_object */\n\n#ifdef GL_APPLE_vertex_array_range\n\nstatic GLboolean _glewInit_GL_APPLE_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFlushVertexArrayRangeAPPLE = (PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glFlushVertexArrayRangeAPPLE\")) == NULL) || r;\n  r = ((glVertexArrayParameteriAPPLE = (PFNGLVERTEXARRAYPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayParameteriAPPLE\")) == NULL) || r;\n  r = ((glVertexArrayRangeAPPLE = (PFNGLVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayRangeAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_vertex_array_range */\n\n#ifdef GL_APPLE_vertex_program_evaluators\n\nstatic GLboolean _glewInit_GL_APPLE_vertex_program_evaluators (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDisableVertexAttribAPPLE = (PFNGLDISABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glDisableVertexAttribAPPLE\")) == NULL) || r;\n  r = ((glEnableVertexAttribAPPLE = (PFNGLENABLEVERTEXATTRIBAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glEnableVertexAttribAPPLE\")) == NULL) || r;\n  r = ((glIsVertexAttribEnabledAPPLE = (PFNGLISVERTEXATTRIBENABLEDAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glIsVertexAttribEnabledAPPLE\")) == NULL) || r;\n  r = ((glMapVertexAttrib1dAPPLE = (PFNGLMAPVERTEXATTRIB1DAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMapVertexAttrib1dAPPLE\")) == NULL) || r;\n  r = ((glMapVertexAttrib1fAPPLE = (PFNGLMAPVERTEXATTRIB1FAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMapVertexAttrib1fAPPLE\")) == NULL) || r;\n  r = ((glMapVertexAttrib2dAPPLE = (PFNGLMAPVERTEXATTRIB2DAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMapVertexAttrib2dAPPLE\")) == NULL) || r;\n  r = ((glMapVertexAttrib2fAPPLE = (PFNGLMAPVERTEXATTRIB2FAPPLEPROC)glewGetProcAddress((const GLubyte*)\"glMapVertexAttrib2fAPPLE\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_APPLE_vertex_program_evaluators */\n\n#ifdef GL_APPLE_ycbcr_422\n\n#endif /* GL_APPLE_ycbcr_422 */\n\n#ifdef GL_ARB_ES2_compatibility\n\nstatic GLboolean _glewInit_GL_ARB_ES2_compatibility (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClearDepthf = (PFNGLCLEARDEPTHFPROC)glewGetProcAddress((const GLubyte*)\"glClearDepthf\")) == NULL) || r;\n  r = ((glDepthRangef = (PFNGLDEPTHRANGEFPROC)glewGetProcAddress((const GLubyte*)\"glDepthRangef\")) == NULL) || r;\n  r = ((glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)glewGetProcAddress((const GLubyte*)\"glGetShaderPrecisionFormat\")) == NULL) || r;\n  r = ((glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)glewGetProcAddress((const GLubyte*)\"glReleaseShaderCompiler\")) == NULL) || r;\n  r = ((glShaderBinary = (PFNGLSHADERBINARYPROC)glewGetProcAddress((const GLubyte*)\"glShaderBinary\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_ES2_compatibility */\n\n#ifdef GL_ARB_ES3_compatibility\n\n#endif /* GL_ARB_ES3_compatibility */\n\n#ifdef GL_ARB_arrays_of_arrays\n\n#endif /* GL_ARB_arrays_of_arrays */\n\n#ifdef GL_ARB_base_instance\n\nstatic GLboolean _glewInit_GL_ARB_base_instance (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysInstancedBaseInstance\")) == NULL) || r;\n  r = ((glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstancedBaseInstance\")) == NULL) || r;\n  r = ((glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstancedBaseVertexBaseInstance\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_base_instance */\n\n#ifdef GL_ARB_blend_func_extended\n\nstatic GLboolean _glewInit_GL_ARB_blend_func_extended (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)glewGetProcAddress((const GLubyte*)\"glBindFragDataLocationIndexed\")) == NULL) || r;\n  r = ((glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)glewGetProcAddress((const GLubyte*)\"glGetFragDataIndex\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_blend_func_extended */\n\n#ifdef GL_ARB_cl_event\n\nstatic GLboolean _glewInit_GL_ARB_cl_event (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCreateSyncFromCLeventARB = (PFNGLCREATESYNCFROMCLEVENTARBPROC)glewGetProcAddress((const GLubyte*)\"glCreateSyncFromCLeventARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_cl_event */\n\n#ifdef GL_ARB_clear_buffer_object\n\nstatic GLboolean _glewInit_GL_ARB_clear_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferData\")) == NULL) || r;\n  r = ((glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glClearBufferSubData\")) == NULL) || r;\n  r = ((glClearNamedBufferDataEXT = (PFNGLCLEARNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glClearNamedBufferDataEXT\")) == NULL) || r;\n  r = ((glClearNamedBufferSubDataEXT = (PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glClearNamedBufferSubDataEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_clear_buffer_object */\n\n#ifdef GL_ARB_color_buffer_float\n\nstatic GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClampColorARB = (PFNGLCLAMPCOLORARBPROC)glewGetProcAddress((const GLubyte*)\"glClampColorARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_color_buffer_float */\n\n#ifdef GL_ARB_compatibility\n\n#endif /* GL_ARB_compatibility */\n\n#ifdef GL_ARB_compressed_texture_pixel_storage\n\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n\n#ifdef GL_ARB_compute_shader\n\nstatic GLboolean _glewInit_GL_ARB_compute_shader (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)glewGetProcAddress((const GLubyte*)\"glDispatchCompute\")) == NULL) || r;\n  r = ((glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)glewGetProcAddress((const GLubyte*)\"glDispatchComputeIndirect\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_compute_shader */\n\n#ifdef GL_ARB_conservative_depth\n\n#endif /* GL_ARB_conservative_depth */\n\n#ifdef GL_ARB_copy_buffer\n\nstatic GLboolean _glewInit_GL_ARB_copy_buffer (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glCopyBufferSubData\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_copy_buffer */\n\n#ifdef GL_ARB_copy_image\n\nstatic GLboolean _glewInit_GL_ARB_copy_image (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glCopyImageSubData\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_copy_image */\n\n#ifdef GL_ARB_debug_output\n\nstatic GLboolean _glewInit_GL_ARB_debug_output (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageCallbackARB\")) == NULL) || r;\n  r = ((glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageControlARB\")) == NULL) || r;\n  r = ((glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageInsertARB\")) == NULL) || r;\n  r = ((glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)glewGetProcAddress((const GLubyte*)\"glGetDebugMessageLogARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_debug_output */\n\n#ifdef GL_ARB_depth_buffer_float\n\n#endif /* GL_ARB_depth_buffer_float */\n\n#ifdef GL_ARB_depth_clamp\n\n#endif /* GL_ARB_depth_clamp */\n\n#ifdef GL_ARB_depth_texture\n\n#endif /* GL_ARB_depth_texture */\n\n#ifdef GL_ARB_draw_buffers\n\nstatic GLboolean _glewInit_GL_ARB_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)\"glDrawBuffersARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_draw_buffers */\n\n#ifdef GL_ARB_draw_buffers_blend\n\nstatic GLboolean _glewInit_GL_ARB_draw_buffers_blend (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationSeparateiARB\")) == NULL) || r;\n  r = ((glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationiARB\")) == NULL) || r;\n  r = ((glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncSeparateiARB\")) == NULL) || r;\n  r = ((glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC)glewGetProcAddress((const GLubyte*)\"glBlendFunciARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_draw_buffers_blend */\n\n#ifdef GL_ARB_draw_elements_base_vertex\n\nstatic GLboolean _glewInit_GL_ARB_draw_elements_base_vertex (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsBaseVertex\")) == NULL) || r;\n  r = ((glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstancedBaseVertex\")) == NULL) || r;\n  r = ((glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)\"glDrawRangeElementsBaseVertex\")) == NULL) || r;\n  r = ((glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElementsBaseVertex\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_draw_elements_base_vertex */\n\n#ifdef GL_ARB_draw_indirect\n\nstatic GLboolean _glewInit_GL_ARB_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysIndirect\")) == NULL) || r;\n  r = ((glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsIndirect\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_draw_indirect */\n\n#ifdef GL_ARB_draw_instanced\n\n#endif /* GL_ARB_draw_instanced */\n\n#ifdef GL_ARB_explicit_attrib_location\n\n#endif /* GL_ARB_explicit_attrib_location */\n\n#ifdef GL_ARB_explicit_uniform_location\n\n#endif /* GL_ARB_explicit_uniform_location */\n\n#ifdef GL_ARB_fragment_coord_conventions\n\n#endif /* GL_ARB_fragment_coord_conventions */\n\n#ifdef GL_ARB_fragment_layer_viewport\n\n#endif /* GL_ARB_fragment_layer_viewport */\n\n#ifdef GL_ARB_fragment_program\n\n#endif /* GL_ARB_fragment_program */\n\n#ifdef GL_ARB_fragment_program_shadow\n\n#endif /* GL_ARB_fragment_program_shadow */\n\n#ifdef GL_ARB_fragment_shader\n\n#endif /* GL_ARB_fragment_shader */\n\n#ifdef GL_ARB_framebuffer_no_attachments\n\nstatic GLboolean _glewInit_GL_ARB_framebuffer_no_attachments (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferParameteri\")) == NULL) || r;\n  r = ((glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetFramebufferParameteriv\")) == NULL) || r;\n  r = ((glGetNamedFramebufferParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedFramebufferParameterivEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferParameteriEXT = (PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferParameteriEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_framebuffer_no_attachments */\n\n#ifdef GL_ARB_framebuffer_object\n\nstatic GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glBindFramebuffer\")) == NULL) || r;\n  r = ((glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glBindRenderbuffer\")) == NULL) || r;\n  r = ((glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glBlitFramebuffer\")) == NULL) || r;\n  r = ((glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)glewGetProcAddress((const GLubyte*)\"glCheckFramebufferStatus\")) == NULL) || r;\n  r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteFramebuffers\")) == NULL) || r;\n  r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteRenderbuffers\")) == NULL) || r;\n  r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferRenderbuffer\")) == NULL) || r;\n  r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture1D\")) == NULL) || r;\n  r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture2D\")) == NULL) || r;\n  r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture3D\")) == NULL) || r;\n  r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureLayer\")) == NULL) || r;\n  r = ((glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glGenFramebuffers\")) == NULL) || r;\n  r = ((glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)\"glGenRenderbuffers\")) == NULL) || r;\n  r = ((glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glewGetProcAddress((const GLubyte*)\"glGenerateMipmap\")) == NULL) || r;\n  r = ((glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetFramebufferAttachmentParameteriv\")) == NULL) || r;\n  r = ((glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetRenderbufferParameteriv\")) == NULL) || r;\n  r = ((glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glIsFramebuffer\")) == NULL) || r;\n  r = ((glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glIsRenderbuffer\")) == NULL) || r;\n  r = ((glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)\"glRenderbufferStorage\")) == NULL) || r;\n  r = ((glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)\"glRenderbufferStorageMultisample\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_framebuffer_object */\n\n#ifdef GL_ARB_framebuffer_sRGB\n\n#endif /* GL_ARB_framebuffer_sRGB */\n\n#ifdef GL_ARB_geometry_shader4\n\nstatic GLboolean _glewInit_GL_ARB_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFramebufferTextureARB = (PFNGLFRAMEBUFFERTEXTUREARBPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureARB\")) == NULL) || r;\n  r = ((glFramebufferTextureFaceARB = (PFNGLFRAMEBUFFERTEXTUREFACEARBPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureFaceARB\")) == NULL) || r;\n  r = ((glFramebufferTextureLayerARB = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureLayerARB\")) == NULL) || r;\n  r = ((glProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameteriARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_geometry_shader4 */\n\n#ifdef GL_ARB_get_program_binary\n\nstatic GLboolean _glewInit_GL_ARB_get_program_binary (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramBinary\")) == NULL) || r;\n  r = ((glProgramBinary = (PFNGLPROGRAMBINARYPROC)glewGetProcAddress((const GLubyte*)\"glProgramBinary\")) == NULL) || r;\n  r = ((glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameteri\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_get_program_binary */\n\n#ifdef GL_ARB_gpu_shader5\n\n#endif /* GL_ARB_gpu_shader5 */\n\n#ifdef GL_ARB_gpu_shader_fp64\n\nstatic GLboolean _glewInit_GL_ARB_gpu_shader_fp64 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetUniformdv = (PFNGLGETUNIFORMDVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformdv\")) == NULL) || r;\n  r = ((glUniform1d = (PFNGLUNIFORM1DPROC)glewGetProcAddress((const GLubyte*)\"glUniform1d\")) == NULL) || r;\n  r = ((glUniform1dv = (PFNGLUNIFORM1DVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1dv\")) == NULL) || r;\n  r = ((glUniform2d = (PFNGLUNIFORM2DPROC)glewGetProcAddress((const GLubyte*)\"glUniform2d\")) == NULL) || r;\n  r = ((glUniform2dv = (PFNGLUNIFORM2DVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2dv\")) == NULL) || r;\n  r = ((glUniform3d = (PFNGLUNIFORM3DPROC)glewGetProcAddress((const GLubyte*)\"glUniform3d\")) == NULL) || r;\n  r = ((glUniform3dv = (PFNGLUNIFORM3DVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3dv\")) == NULL) || r;\n  r = ((glUniform4d = (PFNGLUNIFORM4DPROC)glewGetProcAddress((const GLubyte*)\"glUniform4d\")) == NULL) || r;\n  r = ((glUniform4dv = (PFNGLUNIFORM4DVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4dv\")) == NULL) || r;\n  r = ((glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2dv\")) == NULL) || r;\n  r = ((glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2x3dv\")) == NULL) || r;\n  r = ((glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2x4dv\")) == NULL) || r;\n  r = ((glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3dv\")) == NULL) || r;\n  r = ((glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3x2dv\")) == NULL) || r;\n  r = ((glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3x4dv\")) == NULL) || r;\n  r = ((glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4dv\")) == NULL) || r;\n  r = ((glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4x2dv\")) == NULL) || r;\n  r = ((glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4x3dv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_gpu_shader_fp64 */\n\n#ifdef GL_ARB_half_float_pixel\n\n#endif /* GL_ARB_half_float_pixel */\n\n#ifdef GL_ARB_half_float_vertex\n\n#endif /* GL_ARB_half_float_vertex */\n\n#ifdef GL_ARB_imaging\n\nstatic GLboolean _glewInit_GL_ARB_imaging (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquation\")) == NULL) || r;\n  r = ((glColorSubTable = (PFNGLCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)\"glColorSubTable\")) == NULL) || r;\n  r = ((glColorTable = (PFNGLCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)\"glColorTable\")) == NULL) || r;\n  r = ((glColorTableParameterfv = (PFNGLCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glColorTableParameterfv\")) == NULL) || r;\n  r = ((glColorTableParameteriv = (PFNGLCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glColorTableParameteriv\")) == NULL) || r;\n  r = ((glConvolutionFilter1D = (PFNGLCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionFilter1D\")) == NULL) || r;\n  r = ((glConvolutionFilter2D = (PFNGLCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionFilter2D\")) == NULL) || r;\n  r = ((glConvolutionParameterf = (PFNGLCONVOLUTIONPARAMETERFPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameterf\")) == NULL) || r;\n  r = ((glConvolutionParameterfv = (PFNGLCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameterfv\")) == NULL) || r;\n  r = ((glConvolutionParameteri = (PFNGLCONVOLUTIONPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameteri\")) == NULL) || r;\n  r = ((glConvolutionParameteriv = (PFNGLCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameteriv\")) == NULL) || r;\n  r = ((glCopyColorSubTable = (PFNGLCOPYCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)\"glCopyColorSubTable\")) == NULL) || r;\n  r = ((glCopyColorTable = (PFNGLCOPYCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)\"glCopyColorTable\")) == NULL) || r;\n  r = ((glCopyConvolutionFilter1D = (PFNGLCOPYCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)\"glCopyConvolutionFilter1D\")) == NULL) || r;\n  r = ((glCopyConvolutionFilter2D = (PFNGLCOPYCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)\"glCopyConvolutionFilter2D\")) == NULL) || r;\n  r = ((glGetColorTable = (PFNGLGETCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTable\")) == NULL) || r;\n  r = ((glGetColorTableParameterfv = (PFNGLGETCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameterfv\")) == NULL) || r;\n  r = ((glGetColorTableParameteriv = (PFNGLGETCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameteriv\")) == NULL) || r;\n  r = ((glGetConvolutionFilter = (PFNGLGETCONVOLUTIONFILTERPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionFilter\")) == NULL) || r;\n  r = ((glGetConvolutionParameterfv = (PFNGLGETCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionParameterfv\")) == NULL) || r;\n  r = ((glGetConvolutionParameteriv = (PFNGLGETCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionParameteriv\")) == NULL) || r;\n  r = ((glGetHistogram = (PFNGLGETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogram\")) == NULL) || r;\n  r = ((glGetHistogramParameterfv = (PFNGLGETHISTOGRAMPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogramParameterfv\")) == NULL) || r;\n  r = ((glGetHistogramParameteriv = (PFNGLGETHISTOGRAMPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogramParameteriv\")) == NULL) || r;\n  r = ((glGetMinmax = (PFNGLGETMINMAXPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmax\")) == NULL) || r;\n  r = ((glGetMinmaxParameterfv = (PFNGLGETMINMAXPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmaxParameterfv\")) == NULL) || r;\n  r = ((glGetMinmaxParameteriv = (PFNGLGETMINMAXPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmaxParameteriv\")) == NULL) || r;\n  r = ((glGetSeparableFilter = (PFNGLGETSEPARABLEFILTERPROC)glewGetProcAddress((const GLubyte*)\"glGetSeparableFilter\")) == NULL) || r;\n  r = ((glHistogram = (PFNGLHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)\"glHistogram\")) == NULL) || r;\n  r = ((glMinmax = (PFNGLMINMAXPROC)glewGetProcAddress((const GLubyte*)\"glMinmax\")) == NULL) || r;\n  r = ((glResetHistogram = (PFNGLRESETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)\"glResetHistogram\")) == NULL) || r;\n  r = ((glResetMinmax = (PFNGLRESETMINMAXPROC)glewGetProcAddress((const GLubyte*)\"glResetMinmax\")) == NULL) || r;\n  r = ((glSeparableFilter2D = (PFNGLSEPARABLEFILTER2DPROC)glewGetProcAddress((const GLubyte*)\"glSeparableFilter2D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_imaging */\n\n#ifdef GL_ARB_instanced_arrays\n\nstatic GLboolean _glewInit_GL_ARB_instanced_arrays (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawArraysInstancedARB = (PFNGLDRAWARRAYSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysInstancedARB\")) == NULL) || r;\n  r = ((glDrawElementsInstancedARB = (PFNGLDRAWELEMENTSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstancedARB\")) == NULL) || r;\n  r = ((glVertexAttribDivisorARB = (PFNGLVERTEXATTRIBDIVISORARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribDivisorARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_instanced_arrays */\n\n#ifdef GL_ARB_internalformat_query\n\nstatic GLboolean _glewInit_GL_ARB_internalformat_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)glewGetProcAddress((const GLubyte*)\"glGetInternalformativ\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_internalformat_query */\n\n#ifdef GL_ARB_internalformat_query2\n\nstatic GLboolean _glewInit_GL_ARB_internalformat_query2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)glewGetProcAddress((const GLubyte*)\"glGetInternalformati64v\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_internalformat_query2 */\n\n#ifdef GL_ARB_invalidate_subdata\n\nstatic GLboolean _glewInit_GL_ARB_invalidate_subdata (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateBufferData\")) == NULL) || r;\n  r = ((glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateBufferSubData\")) == NULL) || r;\n  r = ((glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateFramebuffer\")) == NULL) || r;\n  r = ((glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateSubFramebuffer\")) == NULL) || r;\n  r = ((glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateTexImage\")) == NULL) || r;\n  r = ((glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)glewGetProcAddress((const GLubyte*)\"glInvalidateTexSubImage\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_invalidate_subdata */\n\n#ifdef GL_ARB_map_buffer_alignment\n\n#endif /* GL_ARB_map_buffer_alignment */\n\n#ifdef GL_ARB_map_buffer_range\n\nstatic GLboolean _glewInit_GL_ARB_map_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)\"glFlushMappedBufferRange\")) == NULL) || r;\n  r = ((glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)\"glMapBufferRange\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_map_buffer_range */\n\n#ifdef GL_ARB_matrix_palette\n\nstatic GLboolean _glewInit_GL_ARB_matrix_palette (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCurrentPaletteMatrixARB = (PFNGLCURRENTPALETTEMATRIXARBPROC)glewGetProcAddress((const GLubyte*)\"glCurrentPaletteMatrixARB\")) == NULL) || r;\n  r = ((glMatrixIndexPointerARB = (PFNGLMATRIXINDEXPOINTERARBPROC)glewGetProcAddress((const GLubyte*)\"glMatrixIndexPointerARB\")) == NULL) || r;\n  r = ((glMatrixIndexubvARB = (PFNGLMATRIXINDEXUBVARBPROC)glewGetProcAddress((const GLubyte*)\"glMatrixIndexubvARB\")) == NULL) || r;\n  r = ((glMatrixIndexuivARB = (PFNGLMATRIXINDEXUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glMatrixIndexuivARB\")) == NULL) || r;\n  r = ((glMatrixIndexusvARB = (PFNGLMATRIXINDEXUSVARBPROC)glewGetProcAddress((const GLubyte*)\"glMatrixIndexusvARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_matrix_palette */\n\n#ifdef GL_ARB_multi_draw_indirect\n\nstatic GLboolean _glewInit_GL_ARB_multi_draw_indirect (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawArraysIndirect\")) == NULL) || r;\n  r = ((glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElementsIndirect\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_multi_draw_indirect */\n\n#ifdef GL_ARB_multisample\n\nstatic GLboolean _glewInit_GL_ARB_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)glewGetProcAddress((const GLubyte*)\"glSampleCoverageARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_multisample */\n\n#ifdef GL_ARB_multitexture\n\nstatic GLboolean _glewInit_GL_ARB_multitexture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)\"glActiveTextureARB\")) == NULL) || r;\n  r = ((glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)\"glClientActiveTextureARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1dARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1dvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1fARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1fvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1iARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1ivARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1sARB\")) == NULL) || r;\n  r = ((glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1svARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2dARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2dvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2fARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2fvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2iARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2ivARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2sARB\")) == NULL) || r;\n  r = ((glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2svARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3dARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3dvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3fARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3fvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3iARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3ivARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3sARB\")) == NULL) || r;\n  r = ((glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3svARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4dARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4dvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4fARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4fvARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4iARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4ivARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4sARB\")) == NULL) || r;\n  r = ((glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4svARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_multitexture */\n\n#ifdef GL_ARB_occlusion_query\n\nstatic GLboolean _glewInit_GL_ARB_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)glewGetProcAddress((const GLubyte*)\"glBeginQueryARB\")) == NULL) || r;\n  r = ((glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteQueriesARB\")) == NULL) || r;\n  r = ((glEndQueryARB = (PFNGLENDQUERYARBPROC)glewGetProcAddress((const GLubyte*)\"glEndQueryARB\")) == NULL) || r;\n  r = ((glGenQueriesARB = (PFNGLGENQUERIESARBPROC)glewGetProcAddress((const GLubyte*)\"glGenQueriesARB\")) == NULL) || r;\n  r = ((glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectivARB\")) == NULL) || r;\n  r = ((glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectuivARB\")) == NULL) || r;\n  r = ((glGetQueryivARB = (PFNGLGETQUERYIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryivARB\")) == NULL) || r;\n  r = ((glIsQueryARB = (PFNGLISQUERYARBPROC)glewGetProcAddress((const GLubyte*)\"glIsQueryARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_occlusion_query */\n\n#ifdef GL_ARB_occlusion_query2\n\n#endif /* GL_ARB_occlusion_query2 */\n\n#ifdef GL_ARB_pixel_buffer_object\n\n#endif /* GL_ARB_pixel_buffer_object */\n\n#ifdef GL_ARB_point_parameters\n\nstatic GLboolean _glewInit_GL_ARB_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterfARB\")) == NULL) || r;\n  r = ((glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterfvARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_point_parameters */\n\n#ifdef GL_ARB_point_sprite\n\n#endif /* GL_ARB_point_sprite */\n\n#ifdef GL_ARB_program_interface_query\n\nstatic GLboolean _glewInit_GL_ARB_program_interface_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramInterfaceiv\")) == NULL) || r;\n  r = ((glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramResourceIndex\")) == NULL) || r;\n  r = ((glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramResourceLocation\")) == NULL) || r;\n  r = ((glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramResourceLocationIndex\")) == NULL) || r;\n  r = ((glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramResourceName\")) == NULL) || r;\n  r = ((glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramResourceiv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_program_interface_query */\n\n#ifdef GL_ARB_provoking_vertex\n\nstatic GLboolean _glewInit_GL_ARB_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)glewGetProcAddress((const GLubyte*)\"glProvokingVertex\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_provoking_vertex */\n\n#ifdef GL_ARB_robust_buffer_access_behavior\n\n#endif /* GL_ARB_robust_buffer_access_behavior */\n\n#ifdef GL_ARB_robustness\n\nstatic GLboolean _glewInit_GL_ARB_robustness (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC)glewGetProcAddress((const GLubyte*)\"glGetGraphicsResetStatusARB\")) == NULL) || r;\n  r = ((glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnColorTableARB\")) == NULL) || r;\n  r = ((glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnCompressedTexImageARB\")) == NULL) || r;\n  r = ((glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnConvolutionFilterARB\")) == NULL) || r;\n  r = ((glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnHistogramARB\")) == NULL) || r;\n  r = ((glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnMapdvARB\")) == NULL) || r;\n  r = ((glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnMapfvARB\")) == NULL) || r;\n  r = ((glGetnMapivARB = (PFNGLGETNMAPIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnMapivARB\")) == NULL) || r;\n  r = ((glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnMinmaxARB\")) == NULL) || r;\n  r = ((glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnPixelMapfvARB\")) == NULL) || r;\n  r = ((glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnPixelMapuivARB\")) == NULL) || r;\n  r = ((glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnPixelMapusvARB\")) == NULL) || r;\n  r = ((glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnPolygonStippleARB\")) == NULL) || r;\n  r = ((glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnSeparableFilterARB\")) == NULL) || r;\n  r = ((glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnTexImageARB\")) == NULL) || r;\n  r = ((glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnUniformdvARB\")) == NULL) || r;\n  r = ((glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnUniformfvARB\")) == NULL) || r;\n  r = ((glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnUniformivARB\")) == NULL) || r;\n  r = ((glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetnUniformuivARB\")) == NULL) || r;\n  r = ((glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC)glewGetProcAddress((const GLubyte*)\"glReadnPixelsARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_robustness */\n\n#ifdef GL_ARB_robustness_application_isolation\n\n#endif /* GL_ARB_robustness_application_isolation */\n\n#ifdef GL_ARB_robustness_share_group_isolation\n\n#endif /* GL_ARB_robustness_share_group_isolation */\n\n#ifdef GL_ARB_sample_shading\n\nstatic GLboolean _glewInit_GL_ARB_sample_shading (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMinSampleShadingARB = (PFNGLMINSAMPLESHADINGARBPROC)glewGetProcAddress((const GLubyte*)\"glMinSampleShadingARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_sample_shading */\n\n#ifdef GL_ARB_sampler_objects\n\nstatic GLboolean _glewInit_GL_ARB_sampler_objects (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindSampler = (PFNGLBINDSAMPLERPROC)glewGetProcAddress((const GLubyte*)\"glBindSampler\")) == NULL) || r;\n  r = ((glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteSamplers\")) == NULL) || r;\n  r = ((glGenSamplers = (PFNGLGENSAMPLERSPROC)glewGetProcAddress((const GLubyte*)\"glGenSamplers\")) == NULL) || r;\n  r = ((glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)\"glGetSamplerParameterIiv\")) == NULL) || r;\n  r = ((glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetSamplerParameterIuiv\")) == NULL) || r;\n  r = ((glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glGetSamplerParameterfv\")) == NULL) || r;\n  r = ((glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetSamplerParameteriv\")) == NULL) || r;\n  r = ((glIsSampler = (PFNGLISSAMPLERPROC)glewGetProcAddress((const GLubyte*)\"glIsSampler\")) == NULL) || r;\n  r = ((glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameterIiv\")) == NULL) || r;\n  r = ((glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameterIuiv\")) == NULL) || r;\n  r = ((glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameterf\")) == NULL) || r;\n  r = ((glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameterfv\")) == NULL) || r;\n  r = ((glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameteri\")) == NULL) || r;\n  r = ((glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)\"glSamplerParameteriv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_sampler_objects */\n\n#ifdef GL_ARB_seamless_cube_map\n\n#endif /* GL_ARB_seamless_cube_map */\n\n#ifdef GL_ARB_separate_shader_objects\n\nstatic GLboolean _glewInit_GL_ARB_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)glewGetProcAddress((const GLubyte*)\"glActiveShaderProgram\")) == NULL) || r;\n  r = ((glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)\"glBindProgramPipeline\")) == NULL) || r;\n  r = ((glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)glewGetProcAddress((const GLubyte*)\"glCreateShaderProgramv\")) == NULL) || r;\n  r = ((glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)glewGetProcAddress((const GLubyte*)\"glDeleteProgramPipelines\")) == NULL) || r;\n  r = ((glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)glewGetProcAddress((const GLubyte*)\"glGenProgramPipelines\")) == NULL) || r;\n  r = ((glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramPipelineInfoLog\")) == NULL) || r;\n  r = ((glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramPipelineiv\")) == NULL) || r;\n  r = ((glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)\"glIsProgramPipeline\")) == NULL) || r;\n  r = ((glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1d\")) == NULL) || r;\n  r = ((glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1dv\")) == NULL) || r;\n  r = ((glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1f\")) == NULL) || r;\n  r = ((glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1fv\")) == NULL) || r;\n  r = ((glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1i\")) == NULL) || r;\n  r = ((glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1iv\")) == NULL) || r;\n  r = ((glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1ui\")) == NULL) || r;\n  r = ((glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1uiv\")) == NULL) || r;\n  r = ((glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2d\")) == NULL) || r;\n  r = ((glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2dv\")) == NULL) || r;\n  r = ((glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2f\")) == NULL) || r;\n  r = ((glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2fv\")) == NULL) || r;\n  r = ((glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2i\")) == NULL) || r;\n  r = ((glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2iv\")) == NULL) || r;\n  r = ((glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2ui\")) == NULL) || r;\n  r = ((glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2uiv\")) == NULL) || r;\n  r = ((glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3d\")) == NULL) || r;\n  r = ((glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3dv\")) == NULL) || r;\n  r = ((glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3f\")) == NULL) || r;\n  r = ((glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3fv\")) == NULL) || r;\n  r = ((glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3i\")) == NULL) || r;\n  r = ((glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3iv\")) == NULL) || r;\n  r = ((glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3ui\")) == NULL) || r;\n  r = ((glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3uiv\")) == NULL) || r;\n  r = ((glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4d\")) == NULL) || r;\n  r = ((glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4dv\")) == NULL) || r;\n  r = ((glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4f\")) == NULL) || r;\n  r = ((glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4fv\")) == NULL) || r;\n  r = ((glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4i\")) == NULL) || r;\n  r = ((glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4iv\")) == NULL) || r;\n  r = ((glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4ui\")) == NULL) || r;\n  r = ((glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4uiv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x3dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x3fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x4dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x4fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x2dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x2fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x4dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x4fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x2dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x2fv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x3dv\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x3fv\")) == NULL) || r;\n  r = ((glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)glewGetProcAddress((const GLubyte*)\"glUseProgramStages\")) == NULL) || r;\n  r = ((glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)glewGetProcAddress((const GLubyte*)\"glValidateProgramPipeline\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_separate_shader_objects */\n\n#ifdef GL_ARB_shader_atomic_counters\n\nstatic GLboolean _glewInit_GL_ARB_shader_atomic_counters (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveAtomicCounterBufferiv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shader_atomic_counters */\n\n#ifdef GL_ARB_shader_bit_encoding\n\n#endif /* GL_ARB_shader_bit_encoding */\n\n#ifdef GL_ARB_shader_image_load_store\n\nstatic GLboolean _glewInit_GL_ARB_shader_image_load_store (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)glewGetProcAddress((const GLubyte*)\"glBindImageTexture\")) == NULL) || r;\n  r = ((glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)glewGetProcAddress((const GLubyte*)\"glMemoryBarrier\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shader_image_load_store */\n\n#ifdef GL_ARB_shader_image_size\n\n#endif /* GL_ARB_shader_image_size */\n\n#ifdef GL_ARB_shader_objects\n\nstatic GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glAttachObjectARB\")) == NULL) || r;\n  r = ((glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)glewGetProcAddress((const GLubyte*)\"glCompileShaderARB\")) == NULL) || r;\n  r = ((glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glCreateProgramObjectARB\")) == NULL) || r;\n  r = ((glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glCreateShaderObjectARB\")) == NULL) || r;\n  r = ((glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteObjectARB\")) == NULL) || r;\n  r = ((glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glDetachObjectARB\")) == NULL) || r;\n  r = ((glGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniformARB\")) == NULL) || r;\n  r = ((glGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC)glewGetProcAddress((const GLubyte*)\"glGetAttachedObjectsARB\")) == NULL) || r;\n  r = ((glGetHandleARB = (PFNGLGETHANDLEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetHandleARB\")) == NULL) || r;\n  r = ((glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)glewGetProcAddress((const GLubyte*)\"glGetInfoLogARB\")) == NULL) || r;\n  r = ((glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectParameterfvARB\")) == NULL) || r;\n  r = ((glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectParameterivARB\")) == NULL) || r;\n  r = ((glGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetShaderSourceARB\")) == NULL) || r;\n  r = ((glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformLocationARB\")) == NULL) || r;\n  r = ((glGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformfvARB\")) == NULL) || r;\n  r = ((glGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformivARB\")) == NULL) || r;\n  r = ((glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)\"glLinkProgramARB\")) == NULL) || r;\n  r = ((glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)\"glShaderSourceARB\")) == NULL) || r;\n  r = ((glUniform1fARB = (PFNGLUNIFORM1FARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform1fARB\")) == NULL) || r;\n  r = ((glUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform1fvARB\")) == NULL) || r;\n  r = ((glUniform1iARB = (PFNGLUNIFORM1IARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform1iARB\")) == NULL) || r;\n  r = ((glUniform1ivARB = (PFNGLUNIFORM1IVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform1ivARB\")) == NULL) || r;\n  r = ((glUniform2fARB = (PFNGLUNIFORM2FARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform2fARB\")) == NULL) || r;\n  r = ((glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform2fvARB\")) == NULL) || r;\n  r = ((glUniform2iARB = (PFNGLUNIFORM2IARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform2iARB\")) == NULL) || r;\n  r = ((glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform2ivARB\")) == NULL) || r;\n  r = ((glUniform3fARB = (PFNGLUNIFORM3FARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform3fARB\")) == NULL) || r;\n  r = ((glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform3fvARB\")) == NULL) || r;\n  r = ((glUniform3iARB = (PFNGLUNIFORM3IARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform3iARB\")) == NULL) || r;\n  r = ((glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform3ivARB\")) == NULL) || r;\n  r = ((glUniform4fARB = (PFNGLUNIFORM4FARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform4fARB\")) == NULL) || r;\n  r = ((glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform4fvARB\")) == NULL) || r;\n  r = ((glUniform4iARB = (PFNGLUNIFORM4IARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform4iARB\")) == NULL) || r;\n  r = ((glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniform4ivARB\")) == NULL) || r;\n  r = ((glUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix2fvARB\")) == NULL) || r;\n  r = ((glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix3fvARB\")) == NULL) || r;\n  r = ((glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glUniformMatrix4fvARB\")) == NULL) || r;\n  r = ((glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)\"glUseProgramObjectARB\")) == NULL) || r;\n  r = ((glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)\"glValidateProgramARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shader_objects */\n\n#ifdef GL_ARB_shader_precision\n\n#endif /* GL_ARB_shader_precision */\n\n#ifdef GL_ARB_shader_stencil_export\n\n#endif /* GL_ARB_shader_stencil_export */\n\n#ifdef GL_ARB_shader_storage_buffer_object\n\nstatic GLboolean _glewInit_GL_ARB_shader_storage_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)glewGetProcAddress((const GLubyte*)\"glShaderStorageBlockBinding\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shader_storage_buffer_object */\n\n#ifdef GL_ARB_shader_subroutine\n\nstatic GLboolean _glewInit_GL_ARB_shader_subroutine (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveSubroutineName\")) == NULL) || r;\n  r = ((glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveSubroutineUniformName\")) == NULL) || r;\n  r = ((glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveSubroutineUniformiv\")) == NULL) || r;\n  r = ((glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramStageiv\")) == NULL) || r;\n  r = ((glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)glewGetProcAddress((const GLubyte*)\"glGetSubroutineIndex\")) == NULL) || r;\n  r = ((glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)\"glGetSubroutineUniformLocation\")) == NULL) || r;\n  r = ((glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformSubroutineuiv\")) == NULL) || r;\n  r = ((glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)glewGetProcAddress((const GLubyte*)\"glUniformSubroutinesuiv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shader_subroutine */\n\n#ifdef GL_ARB_shader_texture_lod\n\n#endif /* GL_ARB_shader_texture_lod */\n\n#ifdef GL_ARB_shading_language_100\n\n#endif /* GL_ARB_shading_language_100 */\n\n#ifdef GL_ARB_shading_language_420pack\n\n#endif /* GL_ARB_shading_language_420pack */\n\n#ifdef GL_ARB_shading_language_include\n\nstatic GLboolean _glewInit_GL_ARB_shading_language_include (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCompileShaderIncludeARB = (PFNGLCOMPILESHADERINCLUDEARBPROC)glewGetProcAddress((const GLubyte*)\"glCompileShaderIncludeARB\")) == NULL) || r;\n  r = ((glDeleteNamedStringARB = (PFNGLDELETENAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteNamedStringARB\")) == NULL) || r;\n  r = ((glGetNamedStringARB = (PFNGLGETNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedStringARB\")) == NULL) || r;\n  r = ((glGetNamedStringivARB = (PFNGLGETNAMEDSTRINGIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedStringivARB\")) == NULL) || r;\n  r = ((glIsNamedStringARB = (PFNGLISNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glIsNamedStringARB\")) == NULL) || r;\n  r = ((glNamedStringARB = (PFNGLNAMEDSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glNamedStringARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_shading_language_include */\n\n#ifdef GL_ARB_shading_language_packing\n\n#endif /* GL_ARB_shading_language_packing */\n\n#ifdef GL_ARB_shadow\n\n#endif /* GL_ARB_shadow */\n\n#ifdef GL_ARB_shadow_ambient\n\n#endif /* GL_ARB_shadow_ambient */\n\n#ifdef GL_ARB_stencil_texturing\n\n#endif /* GL_ARB_stencil_texturing */\n\n#ifdef GL_ARB_sync\n\nstatic GLboolean _glewInit_GL_ARB_sync (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)glewGetProcAddress((const GLubyte*)\"glClientWaitSync\")) == NULL) || r;\n  r = ((glDeleteSync = (PFNGLDELETESYNCPROC)glewGetProcAddress((const GLubyte*)\"glDeleteSync\")) == NULL) || r;\n  r = ((glFenceSync = (PFNGLFENCESYNCPROC)glewGetProcAddress((const GLubyte*)\"glFenceSync\")) == NULL) || r;\n  r = ((glGetInteger64v = (PFNGLGETINTEGER64VPROC)glewGetProcAddress((const GLubyte*)\"glGetInteger64v\")) == NULL) || r;\n  r = ((glGetSynciv = (PFNGLGETSYNCIVPROC)glewGetProcAddress((const GLubyte*)\"glGetSynciv\")) == NULL) || r;\n  r = ((glIsSync = (PFNGLISSYNCPROC)glewGetProcAddress((const GLubyte*)\"glIsSync\")) == NULL) || r;\n  r = ((glWaitSync = (PFNGLWAITSYNCPROC)glewGetProcAddress((const GLubyte*)\"glWaitSync\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_sync */\n\n#ifdef GL_ARB_tessellation_shader\n\nstatic GLboolean _glewInit_GL_ARB_tessellation_shader (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)\"glPatchParameterfv\")) == NULL) || r;\n  r = ((glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)glewGetProcAddress((const GLubyte*)\"glPatchParameteri\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_tessellation_shader */\n\n#ifdef GL_ARB_texture_border_clamp\n\n#endif /* GL_ARB_texture_border_clamp */\n\n#ifdef GL_ARB_texture_buffer_object\n\nstatic GLboolean _glewInit_GL_ARB_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexBufferARB = (PFNGLTEXBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"glTexBufferARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_buffer_object */\n\n#ifdef GL_ARB_texture_buffer_object_rgb32\n\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n\n#ifdef GL_ARB_texture_buffer_range\n\nstatic GLboolean _glewInit_GL_ARB_texture_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)\"glTexBufferRange\")) == NULL) || r;\n  r = ((glTextureBufferRangeEXT = (PFNGLTEXTUREBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureBufferRangeEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_buffer_range */\n\n#ifdef GL_ARB_texture_compression\n\nstatic GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage1DARB\")) == NULL) || r;\n  r = ((glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage2DARB\")) == NULL) || r;\n  r = ((glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexImage3DARB\")) == NULL) || r;\n  r = ((glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage1DARB\")) == NULL) || r;\n  r = ((glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage2DARB\")) == NULL) || r;\n  r = ((glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTexSubImage3DARB\")) == NULL) || r;\n  r = ((glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)\"glGetCompressedTexImageARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_compression */\n\n#ifdef GL_ARB_texture_compression_bptc\n\n#endif /* GL_ARB_texture_compression_bptc */\n\n#ifdef GL_ARB_texture_compression_rgtc\n\n#endif /* GL_ARB_texture_compression_rgtc */\n\n#ifdef GL_ARB_texture_cube_map\n\n#endif /* GL_ARB_texture_cube_map */\n\n#ifdef GL_ARB_texture_cube_map_array\n\n#endif /* GL_ARB_texture_cube_map_array */\n\n#ifdef GL_ARB_texture_env_add\n\n#endif /* GL_ARB_texture_env_add */\n\n#ifdef GL_ARB_texture_env_combine\n\n#endif /* GL_ARB_texture_env_combine */\n\n#ifdef GL_ARB_texture_env_crossbar\n\n#endif /* GL_ARB_texture_env_crossbar */\n\n#ifdef GL_ARB_texture_env_dot3\n\n#endif /* GL_ARB_texture_env_dot3 */\n\n#ifdef GL_ARB_texture_float\n\n#endif /* GL_ARB_texture_float */\n\n#ifdef GL_ARB_texture_gather\n\n#endif /* GL_ARB_texture_gather */\n\n#ifdef GL_ARB_texture_mirrored_repeat\n\n#endif /* GL_ARB_texture_mirrored_repeat */\n\n#ifdef GL_ARB_texture_multisample\n\nstatic GLboolean _glewInit_GL_ARB_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)glewGetProcAddress((const GLubyte*)\"glGetMultisamplefv\")) == NULL) || r;\n  r = ((glSampleMaski = (PFNGLSAMPLEMASKIPROC)glewGetProcAddress((const GLubyte*)\"glSampleMaski\")) == NULL) || r;\n  r = ((glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)\"glTexImage2DMultisample\")) == NULL) || r;\n  r = ((glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)\"glTexImage3DMultisample\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_multisample */\n\n#ifdef GL_ARB_texture_non_power_of_two\n\n#endif /* GL_ARB_texture_non_power_of_two */\n\n#ifdef GL_ARB_texture_query_levels\n\n#endif /* GL_ARB_texture_query_levels */\n\n#ifdef GL_ARB_texture_query_lod\n\n#endif /* GL_ARB_texture_query_lod */\n\n#ifdef GL_ARB_texture_rectangle\n\n#endif /* GL_ARB_texture_rectangle */\n\n#ifdef GL_ARB_texture_rg\n\n#endif /* GL_ARB_texture_rg */\n\n#ifdef GL_ARB_texture_rgb10_a2ui\n\n#endif /* GL_ARB_texture_rgb10_a2ui */\n\n#ifdef GL_ARB_texture_storage\n\nstatic GLboolean _glewInit_GL_ARB_texture_storage (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)glewGetProcAddress((const GLubyte*)\"glTexStorage1D\")) == NULL) || r;\n  r = ((glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)glewGetProcAddress((const GLubyte*)\"glTexStorage2D\")) == NULL) || r;\n  r = ((glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)glewGetProcAddress((const GLubyte*)\"glTexStorage3D\")) == NULL) || r;\n  r = ((glTextureStorage1DEXT = (PFNGLTEXTURESTORAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureStorage1DEXT\")) == NULL) || r;\n  r = ((glTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureStorage2DEXT\")) == NULL) || r;\n  r = ((glTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureStorage3DEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_storage */\n\n#ifdef GL_ARB_texture_storage_multisample\n\nstatic GLboolean _glewInit_GL_ARB_texture_storage_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)\"glTexStorage2DMultisample\")) == NULL) || r;\n  r = ((glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)\"glTexStorage3DMultisample\")) == NULL) || r;\n  r = ((glTextureStorage2DMultisampleEXT = (PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureStorage2DMultisampleEXT\")) == NULL) || r;\n  r = ((glTextureStorage3DMultisampleEXT = (PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureStorage3DMultisampleEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_storage_multisample */\n\n#ifdef GL_ARB_texture_swizzle\n\n#endif /* GL_ARB_texture_swizzle */\n\n#ifdef GL_ARB_texture_view\n\nstatic GLboolean _glewInit_GL_ARB_texture_view (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTextureView = (PFNGLTEXTUREVIEWPROC)glewGetProcAddress((const GLubyte*)\"glTextureView\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_texture_view */\n\n#ifdef GL_ARB_timer_query\n\nstatic GLboolean _glewInit_GL_ARB_timer_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjecti64v\")) == NULL) || r;\n  r = ((glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectui64v\")) == NULL) || r;\n  r = ((glQueryCounter = (PFNGLQUERYCOUNTERPROC)glewGetProcAddress((const GLubyte*)\"glQueryCounter\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_timer_query */\n\n#ifdef GL_ARB_transform_feedback2\n\nstatic GLboolean _glewInit_GL_ARB_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glBindTransformFeedback\")) == NULL) || r;\n  r = ((glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteTransformFeedbacks\")) == NULL) || r;\n  r = ((glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glDrawTransformFeedback\")) == NULL) || r;\n  r = ((glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)glewGetProcAddress((const GLubyte*)\"glGenTransformFeedbacks\")) == NULL) || r;\n  r = ((glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glIsTransformFeedback\")) == NULL) || r;\n  r = ((glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glPauseTransformFeedback\")) == NULL) || r;\n  r = ((glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)\"glResumeTransformFeedback\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_transform_feedback2 */\n\n#ifdef GL_ARB_transform_feedback3\n\nstatic GLboolean _glewInit_GL_ARB_transform_feedback3 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)\"glBeginQueryIndexed\")) == NULL) || r;\n  r = ((glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)glewGetProcAddress((const GLubyte*)\"glDrawTransformFeedbackStream\")) == NULL) || r;\n  r = ((glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)glewGetProcAddress((const GLubyte*)\"glEndQueryIndexed\")) == NULL) || r;\n  r = ((glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryIndexediv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_transform_feedback3 */\n\n#ifdef GL_ARB_transform_feedback_instanced\n\nstatic GLboolean _glewInit_GL_ARB_transform_feedback_instanced (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)glewGetProcAddress((const GLubyte*)\"glDrawTransformFeedbackInstanced\")) == NULL) || r;\n  r = ((glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)glewGetProcAddress((const GLubyte*)\"glDrawTransformFeedbackStreamInstanced\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_transform_feedback_instanced */\n\n#ifdef GL_ARB_transpose_matrix\n\nstatic GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glLoadTransposeMatrixdARB = (PFNGLLOADTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)\"glLoadTransposeMatrixdARB\")) == NULL) || r;\n  r = ((glLoadTransposeMatrixfARB = (PFNGLLOADTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)\"glLoadTransposeMatrixfARB\")) == NULL) || r;\n  r = ((glMultTransposeMatrixdARB = (PFNGLMULTTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)\"glMultTransposeMatrixdARB\")) == NULL) || r;\n  r = ((glMultTransposeMatrixfARB = (PFNGLMULTTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)\"glMultTransposeMatrixfARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_transpose_matrix */\n\n#ifdef GL_ARB_uniform_buffer_object\n\nstatic GLboolean _glewInit_GL_ARB_uniform_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferBase\")) == NULL) || r;\n  r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferRange\")) == NULL) || r;\n  r = ((glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniformBlockName\")) == NULL) || r;\n  r = ((glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniformBlockiv\")) == NULL) || r;\n  r = ((glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniformName\")) == NULL) || r;\n  r = ((glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveUniformsiv\")) == NULL) || r;\n  r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)\"glGetIntegeri_v\")) == NULL) || r;\n  r = ((glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformBlockIndex\")) == NULL) || r;\n  r = ((glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformIndices\")) == NULL) || r;\n  r = ((glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)glewGetProcAddress((const GLubyte*)\"glUniformBlockBinding\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_uniform_buffer_object */\n\n#ifdef GL_ARB_vertex_array_bgra\n\n#endif /* GL_ARB_vertex_array_bgra */\n\n#ifdef GL_ARB_vertex_array_object\n\nstatic GLboolean _glewInit_GL_ARB_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)\"glBindVertexArray\")) == NULL) || r;\n  r = ((glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)\"glDeleteVertexArrays\")) == NULL) || r;\n  r = ((glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)\"glGenVertexArrays\")) == NULL) || r;\n  r = ((glIsVertexArray = (PFNGLISVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)\"glIsVertexArray\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_array_object */\n\n#ifdef GL_ARB_vertex_attrib_64bit\n\nstatic GLboolean _glewInit_GL_ARB_vertex_attrib_64bit (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribLdv\")) == NULL) || r;\n  r = ((glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1d\")) == NULL) || r;\n  r = ((glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1dv\")) == NULL) || r;\n  r = ((glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2d\")) == NULL) || r;\n  r = ((glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2dv\")) == NULL) || r;\n  r = ((glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3d\")) == NULL) || r;\n  r = ((glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3dv\")) == NULL) || r;\n  r = ((glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4d\")) == NULL) || r;\n  r = ((glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4dv\")) == NULL) || r;\n  r = ((glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribLPointer\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_attrib_64bit */\n\n#ifdef GL_ARB_vertex_attrib_binding\n\nstatic GLboolean _glewInit_GL_ARB_vertex_attrib_binding (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glBindVertexBuffer\")) == NULL) || r;\n  r = ((glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribBinding\")) == NULL) || r;\n  r = ((glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribFormat\")) == NULL) || r;\n  r = ((glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribIFormat\")) == NULL) || r;\n  r = ((glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribLFormat\")) == NULL) || r;\n  r = ((glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)glewGetProcAddress((const GLubyte*)\"glVertexBindingDivisor\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_attrib_binding */\n\n#ifdef GL_ARB_vertex_blend\n\nstatic GLboolean _glewInit_GL_ARB_vertex_blend (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glVertexBlendARB = (PFNGLVERTEXBLENDARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexBlendARB\")) == NULL) || r;\n  r = ((glWeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightPointerARB\")) == NULL) || r;\n  r = ((glWeightbvARB = (PFNGLWEIGHTBVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightbvARB\")) == NULL) || r;\n  r = ((glWeightdvARB = (PFNGLWEIGHTDVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightdvARB\")) == NULL) || r;\n  r = ((glWeightfvARB = (PFNGLWEIGHTFVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightfvARB\")) == NULL) || r;\n  r = ((glWeightivARB = (PFNGLWEIGHTIVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightivARB\")) == NULL) || r;\n  r = ((glWeightsvARB = (PFNGLWEIGHTSVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightsvARB\")) == NULL) || r;\n  r = ((glWeightubvARB = (PFNGLWEIGHTUBVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightubvARB\")) == NULL) || r;\n  r = ((glWeightuivARB = (PFNGLWEIGHTUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightuivARB\")) == NULL) || r;\n  r = ((glWeightusvARB = (PFNGLWEIGHTUSVARBPROC)glewGetProcAddress((const GLubyte*)\"glWeightusvARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_blend */\n\n#ifdef GL_ARB_vertex_buffer_object\n\nstatic GLboolean _glewInit_GL_ARB_vertex_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferARB\")) == NULL) || r;\n  r = ((glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glewGetProcAddress((const GLubyte*)\"glBufferDataARB\")) == NULL) || r;\n  r = ((glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)\"glBufferSubDataARB\")) == NULL) || r;\n  r = ((glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteBuffersARB\")) == NULL) || r;\n  r = ((glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)\"glGenBuffersARB\")) == NULL) || r;\n  r = ((glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferParameterivARB\")) == NULL) || r;\n  r = ((glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferPointervARB\")) == NULL) || r;\n  r = ((glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferSubDataARB\")) == NULL) || r;\n  r = ((glIsBufferARB = (PFNGLISBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"glIsBufferARB\")) == NULL) || r;\n  r = ((glMapBufferARB = (PFNGLMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"glMapBufferARB\")) == NULL) || r;\n  r = ((glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"glUnmapBufferARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_buffer_object */\n\n#ifdef GL_ARB_vertex_program\n\nstatic GLboolean _glewInit_GL_ARB_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)\"glBindProgramARB\")) == NULL) || r;\n  r = ((glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)\"glDeleteProgramsARB\")) == NULL) || r;\n  r = ((glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)\"glDisableVertexAttribArrayARB\")) == NULL) || r;\n  r = ((glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)\"glEnableVertexAttribArrayARB\")) == NULL) || r;\n  r = ((glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)\"glGenProgramsARB\")) == NULL) || r;\n  r = ((glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramEnvParameterdvARB\")) == NULL) || r;\n  r = ((glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramEnvParameterfvARB\")) == NULL) || r;\n  r = ((glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramLocalParameterdvARB\")) == NULL) || r;\n  r = ((glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramLocalParameterfvARB\")) == NULL) || r;\n  r = ((glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramStringARB\")) == NULL) || r;\n  r = ((glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramivARB\")) == NULL) || r;\n  r = ((glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribPointervARB\")) == NULL) || r;\n  r = ((glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribdvARB\")) == NULL) || r;\n  r = ((glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribfvARB\")) == NULL) || r;\n  r = ((glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribivARB\")) == NULL) || r;\n  r = ((glIsProgramARB = (PFNGLISPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)\"glIsProgramARB\")) == NULL) || r;\n  r = ((glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameter4dARB\")) == NULL) || r;\n  r = ((glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameter4dvARB\")) == NULL) || r;\n  r = ((glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameter4fARB\")) == NULL) || r;\n  r = ((glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameter4fvARB\")) == NULL) || r;\n  r = ((glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameter4dARB\")) == NULL) || r;\n  r = ((glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameter4dvARB\")) == NULL) || r;\n  r = ((glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameter4fARB\")) == NULL) || r;\n  r = ((glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameter4fvARB\")) == NULL) || r;\n  r = ((glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"glProgramStringARB\")) == NULL) || r;\n  r = ((glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1dARB\")) == NULL) || r;\n  r = ((glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1dvARB\")) == NULL) || r;\n  r = ((glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1fARB\")) == NULL) || r;\n  r = ((glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1fvARB\")) == NULL) || r;\n  r = ((glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1sARB\")) == NULL) || r;\n  r = ((glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1svARB\")) == NULL) || r;\n  r = ((glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2dARB\")) == NULL) || r;\n  r = ((glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2dvARB\")) == NULL) || r;\n  r = ((glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2fARB\")) == NULL) || r;\n  r = ((glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2fvARB\")) == NULL) || r;\n  r = ((glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2sARB\")) == NULL) || r;\n  r = ((glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2svARB\")) == NULL) || r;\n  r = ((glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3dARB\")) == NULL) || r;\n  r = ((glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3dvARB\")) == NULL) || r;\n  r = ((glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3fARB\")) == NULL) || r;\n  r = ((glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3fvARB\")) == NULL) || r;\n  r = ((glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3sARB\")) == NULL) || r;\n  r = ((glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3svARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NbvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NivARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NsvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NubARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NubvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NuivARB\")) == NULL) || r;\n  r = ((glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4NusvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4bvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4dARB\")) == NULL) || r;\n  r = ((glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4dvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4fARB\")) == NULL) || r;\n  r = ((glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4fvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4ivARB\")) == NULL) || r;\n  r = ((glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4sARB\")) == NULL) || r;\n  r = ((glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4svARB\")) == NULL) || r;\n  r = ((glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4ubvARB\")) == NULL) || r;\n  r = ((glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4uivARB\")) == NULL) || r;\n  r = ((glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4usvARB\")) == NULL) || r;\n  r = ((glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribPointerARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_program */\n\n#ifdef GL_ARB_vertex_shader\n\nstatic GLboolean _glewInit_GL_ARB_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)\"glBindAttribLocationARB\")) == NULL) || r;\n  r = ((glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveAttribARB\")) == NULL) || r;\n  r = ((glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)\"glGetAttribLocationARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_shader */\n\n#ifdef GL_ARB_vertex_type_2_10_10_10_rev\n\nstatic GLboolean _glewInit_GL_ARB_vertex_type_2_10_10_10_rev (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorP3ui = (PFNGLCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)\"glColorP3ui\")) == NULL) || r;\n  r = ((glColorP3uiv = (PFNGLCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glColorP3uiv\")) == NULL) || r;\n  r = ((glColorP4ui = (PFNGLCOLORP4UIPROC)glewGetProcAddress((const GLubyte*)\"glColorP4ui\")) == NULL) || r;\n  r = ((glColorP4uiv = (PFNGLCOLORP4UIVPROC)glewGetProcAddress((const GLubyte*)\"glColorP4uiv\")) == NULL) || r;\n  r = ((glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP1ui\")) == NULL) || r;\n  r = ((glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP1uiv\")) == NULL) || r;\n  r = ((glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP2ui\")) == NULL) || r;\n  r = ((glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP2uiv\")) == NULL) || r;\n  r = ((glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP3ui\")) == NULL) || r;\n  r = ((glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP3uiv\")) == NULL) || r;\n  r = ((glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP4ui\")) == NULL) || r;\n  r = ((glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordP4uiv\")) == NULL) || r;\n  r = ((glNormalP3ui = (PFNGLNORMALP3UIPROC)glewGetProcAddress((const GLubyte*)\"glNormalP3ui\")) == NULL) || r;\n  r = ((glNormalP3uiv = (PFNGLNORMALP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glNormalP3uiv\")) == NULL) || r;\n  r = ((glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorP3ui\")) == NULL) || r;\n  r = ((glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorP3uiv\")) == NULL) || r;\n  r = ((glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP1ui\")) == NULL) || r;\n  r = ((glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP1uiv\")) == NULL) || r;\n  r = ((glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP2ui\")) == NULL) || r;\n  r = ((glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP2uiv\")) == NULL) || r;\n  r = ((glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP3ui\")) == NULL) || r;\n  r = ((glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP3uiv\")) == NULL) || r;\n  r = ((glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP4ui\")) == NULL) || r;\n  r = ((glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordP4uiv\")) == NULL) || r;\n  r = ((glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP1ui\")) == NULL) || r;\n  r = ((glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP1uiv\")) == NULL) || r;\n  r = ((glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP2ui\")) == NULL) || r;\n  r = ((glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP2uiv\")) == NULL) || r;\n  r = ((glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP3ui\")) == NULL) || r;\n  r = ((glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP3uiv\")) == NULL) || r;\n  r = ((glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP4ui\")) == NULL) || r;\n  r = ((glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribP4uiv\")) == NULL) || r;\n  r = ((glVertexP2ui = (PFNGLVERTEXP2UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexP2ui\")) == NULL) || r;\n  r = ((glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexP2uiv\")) == NULL) || r;\n  r = ((glVertexP3ui = (PFNGLVERTEXP3UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexP3ui\")) == NULL) || r;\n  r = ((glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexP3uiv\")) == NULL) || r;\n  r = ((glVertexP4ui = (PFNGLVERTEXP4UIPROC)glewGetProcAddress((const GLubyte*)\"glVertexP4ui\")) == NULL) || r;\n  r = ((glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)glewGetProcAddress((const GLubyte*)\"glVertexP4uiv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n\n#ifdef GL_ARB_viewport_array\n\nstatic GLboolean _glewInit_GL_ARB_viewport_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)glewGetProcAddress((const GLubyte*)\"glDepthRangeArrayv\")) == NULL) || r;\n  r = ((glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)glewGetProcAddress((const GLubyte*)\"glDepthRangeIndexed\")) == NULL) || r;\n  r = ((glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)glewGetProcAddress((const GLubyte*)\"glGetDoublei_v\")) == NULL) || r;\n  r = ((glGetFloati_v = (PFNGLGETFLOATI_VPROC)glewGetProcAddress((const GLubyte*)\"glGetFloati_v\")) == NULL) || r;\n  r = ((glScissorArrayv = (PFNGLSCISSORARRAYVPROC)glewGetProcAddress((const GLubyte*)\"glScissorArrayv\")) == NULL) || r;\n  r = ((glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)glewGetProcAddress((const GLubyte*)\"glScissorIndexed\")) == NULL) || r;\n  r = ((glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)glewGetProcAddress((const GLubyte*)\"glScissorIndexedv\")) == NULL) || r;\n  r = ((glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)glewGetProcAddress((const GLubyte*)\"glViewportArrayv\")) == NULL) || r;\n  r = ((glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)glewGetProcAddress((const GLubyte*)\"glViewportIndexedf\")) == NULL) || r;\n  r = ((glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)glewGetProcAddress((const GLubyte*)\"glViewportIndexedfv\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_viewport_array */\n\n#ifdef GL_ARB_window_pos\n\nstatic GLboolean _glewInit_GL_ARB_window_pos (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glWindowPos2dARB = (PFNGLWINDOWPOS2DARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2dARB\")) == NULL) || r;\n  r = ((glWindowPos2dvARB = (PFNGLWINDOWPOS2DVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2dvARB\")) == NULL) || r;\n  r = ((glWindowPos2fARB = (PFNGLWINDOWPOS2FARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2fARB\")) == NULL) || r;\n  r = ((glWindowPos2fvARB = (PFNGLWINDOWPOS2FVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2fvARB\")) == NULL) || r;\n  r = ((glWindowPos2iARB = (PFNGLWINDOWPOS2IARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2iARB\")) == NULL) || r;\n  r = ((glWindowPos2ivARB = (PFNGLWINDOWPOS2IVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2ivARB\")) == NULL) || r;\n  r = ((glWindowPos2sARB = (PFNGLWINDOWPOS2SARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2sARB\")) == NULL) || r;\n  r = ((glWindowPos2svARB = (PFNGLWINDOWPOS2SVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2svARB\")) == NULL) || r;\n  r = ((glWindowPos3dARB = (PFNGLWINDOWPOS3DARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3dARB\")) == NULL) || r;\n  r = ((glWindowPos3dvARB = (PFNGLWINDOWPOS3DVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3dvARB\")) == NULL) || r;\n  r = ((glWindowPos3fARB = (PFNGLWINDOWPOS3FARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3fARB\")) == NULL) || r;\n  r = ((glWindowPos3fvARB = (PFNGLWINDOWPOS3FVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3fvARB\")) == NULL) || r;\n  r = ((glWindowPos3iARB = (PFNGLWINDOWPOS3IARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3iARB\")) == NULL) || r;\n  r = ((glWindowPos3ivARB = (PFNGLWINDOWPOS3IVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3ivARB\")) == NULL) || r;\n  r = ((glWindowPos3sARB = (PFNGLWINDOWPOS3SARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3sARB\")) == NULL) || r;\n  r = ((glWindowPos3svARB = (PFNGLWINDOWPOS3SVARBPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3svARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ARB_window_pos */\n\n#ifdef GL_ATIX_point_sprites\n\n#endif /* GL_ATIX_point_sprites */\n\n#ifdef GL_ATIX_texture_env_combine3\n\n#endif /* GL_ATIX_texture_env_combine3 */\n\n#ifdef GL_ATIX_texture_env_route\n\n#endif /* GL_ATIX_texture_env_route */\n\n#ifdef GL_ATIX_vertex_shader_output_point_size\n\n#endif /* GL_ATIX_vertex_shader_output_point_size */\n\n#ifdef GL_ATI_draw_buffers\n\nstatic GLboolean _glewInit_GL_ATI_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)glewGetProcAddress((const GLubyte*)\"glDrawBuffersATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_draw_buffers */\n\n#ifdef GL_ATI_element_array\n\nstatic GLboolean _glewInit_GL_ATI_element_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementArrayATI\")) == NULL) || r;\n  r = ((glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)\"glDrawRangeElementArrayATI\")) == NULL) || r;\n  r = ((glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)glewGetProcAddress((const GLubyte*)\"glElementPointerATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_element_array */\n\n#ifdef GL_ATI_envmap_bumpmap\n\nstatic GLboolean _glewInit_GL_ATI_envmap_bumpmap (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetTexBumpParameterfvATI = (PFNGLGETTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetTexBumpParameterfvATI\")) == NULL) || r;\n  r = ((glGetTexBumpParameterivATI = (PFNGLGETTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetTexBumpParameterivATI\")) == NULL) || r;\n  r = ((glTexBumpParameterfvATI = (PFNGLTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)\"glTexBumpParameterfvATI\")) == NULL) || r;\n  r = ((glTexBumpParameterivATI = (PFNGLTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)\"glTexBumpParameterivATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_envmap_bumpmap */\n\n#ifdef GL_ATI_fragment_shader\n\nstatic GLboolean _glewInit_GL_ATI_fragment_shader (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)\"glAlphaFragmentOp1ATI\")) == NULL) || r;\n  r = ((glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)\"glAlphaFragmentOp2ATI\")) == NULL) || r;\n  r = ((glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)\"glAlphaFragmentOp3ATI\")) == NULL) || r;\n  r = ((glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)\"glBeginFragmentShaderATI\")) == NULL) || r;\n  r = ((glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)\"glBindFragmentShaderATI\")) == NULL) || r;\n  r = ((glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)\"glColorFragmentOp1ATI\")) == NULL) || r;\n  r = ((glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)\"glColorFragmentOp2ATI\")) == NULL) || r;\n  r = ((glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)\"glColorFragmentOp3ATI\")) == NULL) || r;\n  r = ((glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)\"glDeleteFragmentShaderATI\")) == NULL) || r;\n  r = ((glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)\"glEndFragmentShaderATI\")) == NULL) || r;\n  r = ((glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)glewGetProcAddress((const GLubyte*)\"glGenFragmentShadersATI\")) == NULL) || r;\n  r = ((glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)glewGetProcAddress((const GLubyte*)\"glPassTexCoordATI\")) == NULL) || r;\n  r = ((glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)glewGetProcAddress((const GLubyte*)\"glSampleMapATI\")) == NULL) || r;\n  r = ((glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)glewGetProcAddress((const GLubyte*)\"glSetFragmentShaderConstantATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_fragment_shader */\n\n#ifdef GL_ATI_map_object_buffer\n\nstatic GLboolean _glewInit_GL_ATI_map_object_buffer (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMapObjectBufferATI = (PFNGLMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glMapObjectBufferATI\")) == NULL) || r;\n  r = ((glUnmapObjectBufferATI = (PFNGLUNMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glUnmapObjectBufferATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_map_object_buffer */\n\n#ifdef GL_ATI_meminfo\n\n#endif /* GL_ATI_meminfo */\n\n#ifdef GL_ATI_pn_triangles\n\nstatic GLboolean _glewInit_GL_ATI_pn_triangles (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPNTrianglesfATI = (PFNGLPNTRIANGLESFATIPROC)glewGetProcAddress((const GLubyte*)\"glPNTrianglesfATI\")) == NULL) || r;\n  r = ((glPNTrianglesiATI = (PFNGLPNTRIANGLESIATIPROC)glewGetProcAddress((const GLubyte*)\"glPNTrianglesiATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_pn_triangles */\n\n#ifdef GL_ATI_separate_stencil\n\nstatic GLboolean _glewInit_GL_ATI_separate_stencil (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)\"glStencilFuncSeparateATI\")) == NULL) || r;\n  r = ((glStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)\"glStencilOpSeparateATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_separate_stencil */\n\n#ifdef GL_ATI_shader_texture_lod\n\n#endif /* GL_ATI_shader_texture_lod */\n\n#ifdef GL_ATI_text_fragment_shader\n\n#endif /* GL_ATI_text_fragment_shader */\n\n#ifdef GL_ATI_texture_compression_3dc\n\n#endif /* GL_ATI_texture_compression_3dc */\n\n#ifdef GL_ATI_texture_env_combine3\n\n#endif /* GL_ATI_texture_env_combine3 */\n\n#ifdef GL_ATI_texture_float\n\n#endif /* GL_ATI_texture_float */\n\n#ifdef GL_ATI_texture_mirror_once\n\n#endif /* GL_ATI_texture_mirror_once */\n\n#ifdef GL_ATI_vertex_array_object\n\nstatic GLboolean _glewInit_GL_ATI_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)\"glArrayObjectATI\")) == NULL) || r;\n  r = ((glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glFreeObjectBufferATI\")) == NULL) || r;\n  r = ((glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetArrayObjectfvATI\")) == NULL) || r;\n  r = ((glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetArrayObjectivATI\")) == NULL) || r;\n  r = ((glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectBufferfvATI\")) == NULL) || r;\n  r = ((glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectBufferivATI\")) == NULL) || r;\n  r = ((glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantArrayObjectfvATI\")) == NULL) || r;\n  r = ((glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantArrayObjectivATI\")) == NULL) || r;\n  r = ((glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glIsObjectBufferATI\")) == NULL) || r;\n  r = ((glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glNewObjectBufferATI\")) == NULL) || r;\n  r = ((glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)\"glUpdateObjectBufferATI\")) == NULL) || r;\n  r = ((glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)\"glVariantArrayObjectATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_vertex_array_object */\n\n#ifdef GL_ATI_vertex_attrib_array_object\n\nstatic GLboolean _glewInit_GL_ATI_vertex_attrib_array_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetVertexAttribArrayObjectfvATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribArrayObjectfvATI\")) == NULL) || r;\n  r = ((glGetVertexAttribArrayObjectivATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribArrayObjectivATI\")) == NULL) || r;\n  r = ((glVertexAttribArrayObjectATI = (PFNGLVERTEXATTRIBARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribArrayObjectATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_vertex_attrib_array_object */\n\n#ifdef GL_ATI_vertex_streams\n\nstatic GLboolean _glewInit_GL_ATI_vertex_streams (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClientActiveVertexStreamATI = (PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC)glewGetProcAddress((const GLubyte*)\"glClientActiveVertexStreamATI\")) == NULL) || r;\n  r = ((glNormalStream3bATI = (PFNGLNORMALSTREAM3BATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3bATI\")) == NULL) || r;\n  r = ((glNormalStream3bvATI = (PFNGLNORMALSTREAM3BVATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3bvATI\")) == NULL) || r;\n  r = ((glNormalStream3dATI = (PFNGLNORMALSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3dATI\")) == NULL) || r;\n  r = ((glNormalStream3dvATI = (PFNGLNORMALSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3dvATI\")) == NULL) || r;\n  r = ((glNormalStream3fATI = (PFNGLNORMALSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3fATI\")) == NULL) || r;\n  r = ((glNormalStream3fvATI = (PFNGLNORMALSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3fvATI\")) == NULL) || r;\n  r = ((glNormalStream3iATI = (PFNGLNORMALSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3iATI\")) == NULL) || r;\n  r = ((glNormalStream3ivATI = (PFNGLNORMALSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3ivATI\")) == NULL) || r;\n  r = ((glNormalStream3sATI = (PFNGLNORMALSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3sATI\")) == NULL) || r;\n  r = ((glNormalStream3svATI = (PFNGLNORMALSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)\"glNormalStream3svATI\")) == NULL) || r;\n  r = ((glVertexBlendEnvfATI = (PFNGLVERTEXBLENDENVFATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexBlendEnvfATI\")) == NULL) || r;\n  r = ((glVertexBlendEnviATI = (PFNGLVERTEXBLENDENVIATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexBlendEnviATI\")) == NULL) || r;\n  r = ((glVertexStream1dATI = (PFNGLVERTEXSTREAM1DATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1dATI\")) == NULL) || r;\n  r = ((glVertexStream1dvATI = (PFNGLVERTEXSTREAM1DVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1dvATI\")) == NULL) || r;\n  r = ((glVertexStream1fATI = (PFNGLVERTEXSTREAM1FATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1fATI\")) == NULL) || r;\n  r = ((glVertexStream1fvATI = (PFNGLVERTEXSTREAM1FVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1fvATI\")) == NULL) || r;\n  r = ((glVertexStream1iATI = (PFNGLVERTEXSTREAM1IATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1iATI\")) == NULL) || r;\n  r = ((glVertexStream1ivATI = (PFNGLVERTEXSTREAM1IVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1ivATI\")) == NULL) || r;\n  r = ((glVertexStream1sATI = (PFNGLVERTEXSTREAM1SATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1sATI\")) == NULL) || r;\n  r = ((glVertexStream1svATI = (PFNGLVERTEXSTREAM1SVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream1svATI\")) == NULL) || r;\n  r = ((glVertexStream2dATI = (PFNGLVERTEXSTREAM2DATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2dATI\")) == NULL) || r;\n  r = ((glVertexStream2dvATI = (PFNGLVERTEXSTREAM2DVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2dvATI\")) == NULL) || r;\n  r = ((glVertexStream2fATI = (PFNGLVERTEXSTREAM2FATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2fATI\")) == NULL) || r;\n  r = ((glVertexStream2fvATI = (PFNGLVERTEXSTREAM2FVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2fvATI\")) == NULL) || r;\n  r = ((glVertexStream2iATI = (PFNGLVERTEXSTREAM2IATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2iATI\")) == NULL) || r;\n  r = ((glVertexStream2ivATI = (PFNGLVERTEXSTREAM2IVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2ivATI\")) == NULL) || r;\n  r = ((glVertexStream2sATI = (PFNGLVERTEXSTREAM2SATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2sATI\")) == NULL) || r;\n  r = ((glVertexStream2svATI = (PFNGLVERTEXSTREAM2SVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream2svATI\")) == NULL) || r;\n  r = ((glVertexStream3dATI = (PFNGLVERTEXSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3dATI\")) == NULL) || r;\n  r = ((glVertexStream3dvATI = (PFNGLVERTEXSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3dvATI\")) == NULL) || r;\n  r = ((glVertexStream3fATI = (PFNGLVERTEXSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3fATI\")) == NULL) || r;\n  r = ((glVertexStream3fvATI = (PFNGLVERTEXSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3fvATI\")) == NULL) || r;\n  r = ((glVertexStream3iATI = (PFNGLVERTEXSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3iATI\")) == NULL) || r;\n  r = ((glVertexStream3ivATI = (PFNGLVERTEXSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3ivATI\")) == NULL) || r;\n  r = ((glVertexStream3sATI = (PFNGLVERTEXSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3sATI\")) == NULL) || r;\n  r = ((glVertexStream3svATI = (PFNGLVERTEXSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream3svATI\")) == NULL) || r;\n  r = ((glVertexStream4dATI = (PFNGLVERTEXSTREAM4DATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4dATI\")) == NULL) || r;\n  r = ((glVertexStream4dvATI = (PFNGLVERTEXSTREAM4DVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4dvATI\")) == NULL) || r;\n  r = ((glVertexStream4fATI = (PFNGLVERTEXSTREAM4FATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4fATI\")) == NULL) || r;\n  r = ((glVertexStream4fvATI = (PFNGLVERTEXSTREAM4FVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4fvATI\")) == NULL) || r;\n  r = ((glVertexStream4iATI = (PFNGLVERTEXSTREAM4IATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4iATI\")) == NULL) || r;\n  r = ((glVertexStream4ivATI = (PFNGLVERTEXSTREAM4IVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4ivATI\")) == NULL) || r;\n  r = ((glVertexStream4sATI = (PFNGLVERTEXSTREAM4SATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4sATI\")) == NULL) || r;\n  r = ((glVertexStream4svATI = (PFNGLVERTEXSTREAM4SVATIPROC)glewGetProcAddress((const GLubyte*)\"glVertexStream4svATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_ATI_vertex_streams */\n\n#ifdef GL_EXT_422_pixels\n\n#endif /* GL_EXT_422_pixels */\n\n#ifdef GL_EXT_Cg_shader\n\n#endif /* GL_EXT_Cg_shader */\n\n#ifdef GL_EXT_abgr\n\n#endif /* GL_EXT_abgr */\n\n#ifdef GL_EXT_bgra\n\n#endif /* GL_EXT_bgra */\n\n#ifdef GL_EXT_bindable_uniform\n\nstatic GLboolean _glewInit_GL_EXT_bindable_uniform (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetUniformBufferSizeEXT = (PFNGLGETUNIFORMBUFFERSIZEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformBufferSizeEXT\")) == NULL) || r;\n  r = ((glGetUniformOffsetEXT = (PFNGLGETUNIFORMOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformOffsetEXT\")) == NULL) || r;\n  r = ((glUniformBufferEXT = (PFNGLUNIFORMBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glUniformBufferEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_bindable_uniform */\n\n#ifdef GL_EXT_blend_color\n\nstatic GLboolean _glewInit_GL_EXT_blend_color (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)glewGetProcAddress((const GLubyte*)\"glBlendColorEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_blend_color */\n\n#ifdef GL_EXT_blend_equation_separate\n\nstatic GLboolean _glewInit_GL_EXT_blend_equation_separate (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationSeparateEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_blend_equation_separate */\n\n#ifdef GL_EXT_blend_func_separate\n\nstatic GLboolean _glewInit_GL_EXT_blend_func_separate (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)\"glBlendFuncSeparateEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_blend_func_separate */\n\n#ifdef GL_EXT_blend_logic_op\n\n#endif /* GL_EXT_blend_logic_op */\n\n#ifdef GL_EXT_blend_minmax\n\nstatic GLboolean _glewInit_GL_EXT_blend_minmax (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)glewGetProcAddress((const GLubyte*)\"glBlendEquationEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_blend_minmax */\n\n#ifdef GL_EXT_blend_subtract\n\n#endif /* GL_EXT_blend_subtract */\n\n#ifdef GL_EXT_clip_volume_hint\n\n#endif /* GL_EXT_clip_volume_hint */\n\n#ifdef GL_EXT_cmyka\n\n#endif /* GL_EXT_cmyka */\n\n#ifdef GL_EXT_color_subtable\n\nstatic GLboolean _glewInit_GL_EXT_color_subtable (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glColorSubTableEXT\")) == NULL) || r;\n  r = ((glCopyColorSubTableEXT = (PFNGLCOPYCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyColorSubTableEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_color_subtable */\n\n#ifdef GL_EXT_compiled_vertex_array\n\nstatic GLboolean _glewInit_GL_EXT_compiled_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)\"glLockArraysEXT\")) == NULL) || r;\n  r = ((glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)\"glUnlockArraysEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_compiled_vertex_array */\n\n#ifdef GL_EXT_convolution\n\nstatic GLboolean _glewInit_GL_EXT_convolution (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glConvolutionFilter1DEXT = (PFNGLCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionFilter1DEXT\")) == NULL) || r;\n  r = ((glConvolutionFilter2DEXT = (PFNGLCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionFilter2DEXT\")) == NULL) || r;\n  r = ((glConvolutionParameterfEXT = (PFNGLCONVOLUTIONPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameterfEXT\")) == NULL) || r;\n  r = ((glConvolutionParameterfvEXT = (PFNGLCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameterfvEXT\")) == NULL) || r;\n  r = ((glConvolutionParameteriEXT = (PFNGLCONVOLUTIONPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameteriEXT\")) == NULL) || r;\n  r = ((glConvolutionParameterivEXT = (PFNGLCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glConvolutionParameterivEXT\")) == NULL) || r;\n  r = ((glCopyConvolutionFilter1DEXT = (PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyConvolutionFilter1DEXT\")) == NULL) || r;\n  r = ((glCopyConvolutionFilter2DEXT = (PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyConvolutionFilter2DEXT\")) == NULL) || r;\n  r = ((glGetConvolutionFilterEXT = (PFNGLGETCONVOLUTIONFILTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionFilterEXT\")) == NULL) || r;\n  r = ((glGetConvolutionParameterfvEXT = (PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionParameterfvEXT\")) == NULL) || r;\n  r = ((glGetConvolutionParameterivEXT = (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetConvolutionParameterivEXT\")) == NULL) || r;\n  r = ((glGetSeparableFilterEXT = (PFNGLGETSEPARABLEFILTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glGetSeparableFilterEXT\")) == NULL) || r;\n  r = ((glSeparableFilter2DEXT = (PFNGLSEPARABLEFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glSeparableFilter2DEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_convolution */\n\n#ifdef GL_EXT_coordinate_frame\n\nstatic GLboolean _glewInit_GL_EXT_coordinate_frame (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBinormalPointerEXT = (PFNGLBINORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBinormalPointerEXT\")) == NULL) || r;\n  r = ((glTangentPointerEXT = (PFNGLTANGENTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glTangentPointerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_coordinate_frame */\n\n#ifdef GL_EXT_copy_texture\n\nstatic GLboolean _glewInit_GL_EXT_copy_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyTexImage1DEXT = (PFNGLCOPYTEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexImage1DEXT\")) == NULL) || r;\n  r = ((glCopyTexImage2DEXT = (PFNGLCOPYTEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexImage2DEXT\")) == NULL) || r;\n  r = ((glCopyTexSubImage1DEXT = (PFNGLCOPYTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexSubImage1DEXT\")) == NULL) || r;\n  r = ((glCopyTexSubImage2DEXT = (PFNGLCOPYTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexSubImage2DEXT\")) == NULL) || r;\n  r = ((glCopyTexSubImage3DEXT = (PFNGLCOPYTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTexSubImage3DEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_copy_texture */\n\n#ifdef GL_EXT_cull_vertex\n\nstatic GLboolean _glewInit_GL_EXT_cull_vertex (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCullParameterdvEXT = (PFNGLCULLPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glCullParameterdvEXT\")) == NULL) || r;\n  r = ((glCullParameterfvEXT = (PFNGLCULLPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glCullParameterfvEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_cull_vertex */\n\n#ifdef GL_EXT_debug_marker\n\nstatic GLboolean _glewInit_GL_EXT_debug_marker (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC)glewGetProcAddress((const GLubyte*)\"glInsertEventMarkerEXT\")) == NULL) || r;\n  r = ((glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC)glewGetProcAddress((const GLubyte*)\"glPopGroupMarkerEXT\")) == NULL) || r;\n  r = ((glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC)glewGetProcAddress((const GLubyte*)\"glPushGroupMarkerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_debug_marker */\n\n#ifdef GL_EXT_depth_bounds_test\n\nstatic GLboolean _glewInit_GL_EXT_depth_bounds_test (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDepthBoundsEXT = (PFNGLDEPTHBOUNDSEXTPROC)glewGetProcAddress((const GLubyte*)\"glDepthBoundsEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_depth_bounds_test */\n\n#ifdef GL_EXT_direct_state_access\n\nstatic GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindMultiTextureEXT = (PFNGLBINDMULTITEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindMultiTextureEXT\")) == NULL) || r;\n  r = ((glCheckNamedFramebufferStatusEXT = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)\"glCheckNamedFramebufferStatusEXT\")) == NULL) || r;\n  r = ((glClientAttribDefaultEXT = (PFNGLCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)\"glClientAttribDefaultEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexImage1DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexImage1DEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexImage2DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexImage2DEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexImage3DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexImage3DEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexSubImage1DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexSubImage1DEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexSubImage2DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexSubImage2DEXT\")) == NULL) || r;\n  r = ((glCompressedMultiTexSubImage3DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedMultiTexSubImage3DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureImage1DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureImage1DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureImage2DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureImage2DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureImage3DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureImage3DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureSubImage1DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureSubImage1DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureSubImage2DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureSubImage2DEXT\")) == NULL) || r;\n  r = ((glCompressedTextureSubImage3DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCompressedTextureSubImage3DEXT\")) == NULL) || r;\n  r = ((glCopyMultiTexImage1DEXT = (PFNGLCOPYMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyMultiTexImage1DEXT\")) == NULL) || r;\n  r = ((glCopyMultiTexImage2DEXT = (PFNGLCOPYMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyMultiTexImage2DEXT\")) == NULL) || r;\n  r = ((glCopyMultiTexSubImage1DEXT = (PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyMultiTexSubImage1DEXT\")) == NULL) || r;\n  r = ((glCopyMultiTexSubImage2DEXT = (PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyMultiTexSubImage2DEXT\")) == NULL) || r;\n  r = ((glCopyMultiTexSubImage3DEXT = (PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyMultiTexSubImage3DEXT\")) == NULL) || r;\n  r = ((glCopyTextureImage1DEXT = (PFNGLCOPYTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTextureImage1DEXT\")) == NULL) || r;\n  r = ((glCopyTextureImage2DEXT = (PFNGLCOPYTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTextureImage2DEXT\")) == NULL) || r;\n  r = ((glCopyTextureSubImage1DEXT = (PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTextureSubImage1DEXT\")) == NULL) || r;\n  r = ((glCopyTextureSubImage2DEXT = (PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTextureSubImage2DEXT\")) == NULL) || r;\n  r = ((glCopyTextureSubImage3DEXT = (PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glCopyTextureSubImage3DEXT\")) == NULL) || r;\n  r = ((glDisableClientStateIndexedEXT = (PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableClientStateIndexedEXT\")) == NULL) || r;\n  r = ((glDisableClientStateiEXT = (PFNGLDISABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableClientStateiEXT\")) == NULL) || r;\n  r = ((glDisableVertexArrayAttribEXT = (PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableVertexArrayAttribEXT\")) == NULL) || r;\n  r = ((glDisableVertexArrayEXT = (PFNGLDISABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableVertexArrayEXT\")) == NULL) || r;\n  r = ((glEnableClientStateIndexedEXT = (PFNGLENABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableClientStateIndexedEXT\")) == NULL) || r;\n  r = ((glEnableClientStateiEXT = (PFNGLENABLECLIENTSTATEIEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableClientStateiEXT\")) == NULL) || r;\n  r = ((glEnableVertexArrayAttribEXT = (PFNGLENABLEVERTEXARRAYATTRIBEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableVertexArrayAttribEXT\")) == NULL) || r;\n  r = ((glEnableVertexArrayEXT = (PFNGLENABLEVERTEXARRAYEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableVertexArrayEXT\")) == NULL) || r;\n  r = ((glFlushMappedNamedBufferRangeEXT = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glFlushMappedNamedBufferRangeEXT\")) == NULL) || r;\n  r = ((glFramebufferDrawBufferEXT = (PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferDrawBufferEXT\")) == NULL) || r;\n  r = ((glFramebufferDrawBuffersEXT = (PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferDrawBuffersEXT\")) == NULL) || r;\n  r = ((glFramebufferReadBufferEXT = (PFNGLFRAMEBUFFERREADBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferReadBufferEXT\")) == NULL) || r;\n  r = ((glGenerateMultiTexMipmapEXT = (PFNGLGENERATEMULTITEXMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenerateMultiTexMipmapEXT\")) == NULL) || r;\n  r = ((glGenerateTextureMipmapEXT = (PFNGLGENERATETEXTUREMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenerateTextureMipmapEXT\")) == NULL) || r;\n  r = ((glGetCompressedMultiTexImageEXT = (PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetCompressedMultiTexImageEXT\")) == NULL) || r;\n  r = ((glGetCompressedTextureImageEXT = (PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetCompressedTextureImageEXT\")) == NULL) || r;\n  r = ((glGetDoubleIndexedvEXT = (PFNGLGETDOUBLEINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetDoubleIndexedvEXT\")) == NULL) || r;\n  r = ((glGetDoublei_vEXT = (PFNGLGETDOUBLEI_VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetDoublei_vEXT\")) == NULL) || r;\n  r = ((glGetFloatIndexedvEXT = (PFNGLGETFLOATINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFloatIndexedvEXT\")) == NULL) || r;\n  r = ((glGetFloati_vEXT = (PFNGLGETFLOATI_VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFloati_vEXT\")) == NULL) || r;\n  r = ((glGetFramebufferParameterivEXT = (PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFramebufferParameterivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexEnvfvEXT = (PFNGLGETMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexEnvfvEXT\")) == NULL) || r;\n  r = ((glGetMultiTexEnvivEXT = (PFNGLGETMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexEnvivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexGendvEXT = (PFNGLGETMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexGendvEXT\")) == NULL) || r;\n  r = ((glGetMultiTexGenfvEXT = (PFNGLGETMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexGenfvEXT\")) == NULL) || r;\n  r = ((glGetMultiTexGenivEXT = (PFNGLGETMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexGenivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexImageEXT = (PFNGLGETMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexImageEXT\")) == NULL) || r;\n  r = ((glGetMultiTexLevelParameterfvEXT = (PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexLevelParameterfvEXT\")) == NULL) || r;\n  r = ((glGetMultiTexLevelParameterivEXT = (PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexLevelParameterivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexParameterIivEXT = (PFNGLGETMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexParameterIivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexParameterIuivEXT = (PFNGLGETMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexParameterIuivEXT\")) == NULL) || r;\n  r = ((glGetMultiTexParameterfvEXT = (PFNGLGETMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexParameterfvEXT\")) == NULL) || r;\n  r = ((glGetMultiTexParameterivEXT = (PFNGLGETMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMultiTexParameterivEXT\")) == NULL) || r;\n  r = ((glGetNamedBufferParameterivEXT = (PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedBufferParameterivEXT\")) == NULL) || r;\n  r = ((glGetNamedBufferPointervEXT = (PFNGLGETNAMEDBUFFERPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedBufferPointervEXT\")) == NULL) || r;\n  r = ((glGetNamedBufferSubDataEXT = (PFNGLGETNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedBufferSubDataEXT\")) == NULL) || r;\n  r = ((glGetNamedFramebufferAttachmentParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedFramebufferAttachmentParameterivEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramLocalParameterIivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramLocalParameterIivEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramLocalParameterIuivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramLocalParameterIuivEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramLocalParameterdvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramLocalParameterdvEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramLocalParameterfvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramLocalParameterfvEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramStringEXT = (PFNGLGETNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramStringEXT\")) == NULL) || r;\n  r = ((glGetNamedProgramivEXT = (PFNGLGETNAMEDPROGRAMIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedProgramivEXT\")) == NULL) || r;\n  r = ((glGetNamedRenderbufferParameterivEXT = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedRenderbufferParameterivEXT\")) == NULL) || r;\n  r = ((glGetPointerIndexedvEXT = (PFNGLGETPOINTERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetPointerIndexedvEXT\")) == NULL) || r;\n  r = ((glGetPointeri_vEXT = (PFNGLGETPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetPointeri_vEXT\")) == NULL) || r;\n  r = ((glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureImageEXT\")) == NULL) || r;\n  r = ((glGetTextureLevelParameterfvEXT = (PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureLevelParameterfvEXT\")) == NULL) || r;\n  r = ((glGetTextureLevelParameterivEXT = (PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureLevelParameterivEXT\")) == NULL) || r;\n  r = ((glGetTextureParameterIivEXT = (PFNGLGETTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureParameterIivEXT\")) == NULL) || r;\n  r = ((glGetTextureParameterIuivEXT = (PFNGLGETTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureParameterIuivEXT\")) == NULL) || r;\n  r = ((glGetTextureParameterfvEXT = (PFNGLGETTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureParameterfvEXT\")) == NULL) || r;\n  r = ((glGetTextureParameterivEXT = (PFNGLGETTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureParameterivEXT\")) == NULL) || r;\n  r = ((glGetVertexArrayIntegeri_vEXT = (PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexArrayIntegeri_vEXT\")) == NULL) || r;\n  r = ((glGetVertexArrayIntegervEXT = (PFNGLGETVERTEXARRAYINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexArrayIntegervEXT\")) == NULL) || r;\n  r = ((glGetVertexArrayPointeri_vEXT = (PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexArrayPointeri_vEXT\")) == NULL) || r;\n  r = ((glGetVertexArrayPointervEXT = (PFNGLGETVERTEXARRAYPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexArrayPointervEXT\")) == NULL) || r;\n  r = ((glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glMapNamedBufferEXT\")) == NULL) || r;\n  r = ((glMapNamedBufferRangeEXT = (PFNGLMAPNAMEDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glMapNamedBufferRangeEXT\")) == NULL) || r;\n  r = ((glMatrixFrustumEXT = (PFNGLMATRIXFRUSTUMEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixFrustumEXT\")) == NULL) || r;\n  r = ((glMatrixLoadIdentityEXT = (PFNGLMATRIXLOADIDENTITYEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixLoadIdentityEXT\")) == NULL) || r;\n  r = ((glMatrixLoadTransposedEXT = (PFNGLMATRIXLOADTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixLoadTransposedEXT\")) == NULL) || r;\n  r = ((glMatrixLoadTransposefEXT = (PFNGLMATRIXLOADTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixLoadTransposefEXT\")) == NULL) || r;\n  r = ((glMatrixLoaddEXT = (PFNGLMATRIXLOADDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixLoaddEXT\")) == NULL) || r;\n  r = ((glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixLoadfEXT\")) == NULL) || r;\n  r = ((glMatrixMultTransposedEXT = (PFNGLMATRIXMULTTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixMultTransposedEXT\")) == NULL) || r;\n  r = ((glMatrixMultTransposefEXT = (PFNGLMATRIXMULTTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixMultTransposefEXT\")) == NULL) || r;\n  r = ((glMatrixMultdEXT = (PFNGLMATRIXMULTDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixMultdEXT\")) == NULL) || r;\n  r = ((glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixMultfEXT\")) == NULL) || r;\n  r = ((glMatrixOrthoEXT = (PFNGLMATRIXORTHOEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixOrthoEXT\")) == NULL) || r;\n  r = ((glMatrixPopEXT = (PFNGLMATRIXPOPEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixPopEXT\")) == NULL) || r;\n  r = ((glMatrixPushEXT = (PFNGLMATRIXPUSHEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixPushEXT\")) == NULL) || r;\n  r = ((glMatrixRotatedEXT = (PFNGLMATRIXROTATEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixRotatedEXT\")) == NULL) || r;\n  r = ((glMatrixRotatefEXT = (PFNGLMATRIXROTATEFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixRotatefEXT\")) == NULL) || r;\n  r = ((glMatrixScaledEXT = (PFNGLMATRIXSCALEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixScaledEXT\")) == NULL) || r;\n  r = ((glMatrixScalefEXT = (PFNGLMATRIXSCALEFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixScalefEXT\")) == NULL) || r;\n  r = ((glMatrixTranslatedEXT = (PFNGLMATRIXTRANSLATEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixTranslatedEXT\")) == NULL) || r;\n  r = ((glMatrixTranslatefEXT = (PFNGLMATRIXTRANSLATEFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMatrixTranslatefEXT\")) == NULL) || r;\n  r = ((glMultiTexBufferEXT = (PFNGLMULTITEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexBufferEXT\")) == NULL) || r;\n  r = ((glMultiTexCoordPointerEXT = (PFNGLMULTITEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoordPointerEXT\")) == NULL) || r;\n  r = ((glMultiTexEnvfEXT = (PFNGLMULTITEXENVFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexEnvfEXT\")) == NULL) || r;\n  r = ((glMultiTexEnvfvEXT = (PFNGLMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexEnvfvEXT\")) == NULL) || r;\n  r = ((glMultiTexEnviEXT = (PFNGLMULTITEXENVIEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexEnviEXT\")) == NULL) || r;\n  r = ((glMultiTexEnvivEXT = (PFNGLMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexEnvivEXT\")) == NULL) || r;\n  r = ((glMultiTexGendEXT = (PFNGLMULTITEXGENDEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGendEXT\")) == NULL) || r;\n  r = ((glMultiTexGendvEXT = (PFNGLMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGendvEXT\")) == NULL) || r;\n  r = ((glMultiTexGenfEXT = (PFNGLMULTITEXGENFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGenfEXT\")) == NULL) || r;\n  r = ((glMultiTexGenfvEXT = (PFNGLMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGenfvEXT\")) == NULL) || r;\n  r = ((glMultiTexGeniEXT = (PFNGLMULTITEXGENIEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGeniEXT\")) == NULL) || r;\n  r = ((glMultiTexGenivEXT = (PFNGLMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexGenivEXT\")) == NULL) || r;\n  r = ((glMultiTexImage1DEXT = (PFNGLMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexImage1DEXT\")) == NULL) || r;\n  r = ((glMultiTexImage2DEXT = (PFNGLMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexImage2DEXT\")) == NULL) || r;\n  r = ((glMultiTexImage3DEXT = (PFNGLMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexImage3DEXT\")) == NULL) || r;\n  r = ((glMultiTexParameterIivEXT = (PFNGLMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameterIivEXT\")) == NULL) || r;\n  r = ((glMultiTexParameterIuivEXT = (PFNGLMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameterIuivEXT\")) == NULL) || r;\n  r = ((glMultiTexParameterfEXT = (PFNGLMULTITEXPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameterfEXT\")) == NULL) || r;\n  r = ((glMultiTexParameterfvEXT = (PFNGLMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameterfvEXT\")) == NULL) || r;\n  r = ((glMultiTexParameteriEXT = (PFNGLMULTITEXPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameteriEXT\")) == NULL) || r;\n  r = ((glMultiTexParameterivEXT = (PFNGLMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexParameterivEXT\")) == NULL) || r;\n  r = ((glMultiTexRenderbufferEXT = (PFNGLMULTITEXRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexRenderbufferEXT\")) == NULL) || r;\n  r = ((glMultiTexSubImage1DEXT = (PFNGLMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexSubImage1DEXT\")) == NULL) || r;\n  r = ((glMultiTexSubImage2DEXT = (PFNGLMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexSubImage2DEXT\")) == NULL) || r;\n  r = ((glMultiTexSubImage3DEXT = (PFNGLMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexSubImage3DEXT\")) == NULL) || r;\n  r = ((glNamedBufferDataEXT = (PFNGLNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedBufferDataEXT\")) == NULL) || r;\n  r = ((glNamedBufferSubDataEXT = (PFNGLNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedBufferSubDataEXT\")) == NULL) || r;\n  r = ((glNamedCopyBufferSubDataEXT = (PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedCopyBufferSubDataEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferRenderbufferEXT = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferRenderbufferEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTexture1DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTexture1DEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTexture2DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTexture2DEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTexture3DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTexture3DEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTextureEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTextureFaceEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTextureFaceEXT\")) == NULL) || r;\n  r = ((glNamedFramebufferTextureLayerEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedFramebufferTextureLayerEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameter4dEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameter4dEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameter4dvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameter4dvEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameter4fEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameter4fEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameter4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameter4fvEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameterI4iEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameterI4iEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameterI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameterI4ivEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameterI4uiEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameterI4uiEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameterI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameterI4uivEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParameters4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParameters4fvEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParametersI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParametersI4ivEXT\")) == NULL) || r;\n  r = ((glNamedProgramLocalParametersI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramLocalParametersI4uivEXT\")) == NULL) || r;\n  r = ((glNamedProgramStringEXT = (PFNGLNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedProgramStringEXT\")) == NULL) || r;\n  r = ((glNamedRenderbufferStorageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedRenderbufferStorageEXT\")) == NULL) || r;\n  r = ((glNamedRenderbufferStorageMultisampleCoverageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedRenderbufferStorageMultisampleCoverageEXT\")) == NULL) || r;\n  r = ((glNamedRenderbufferStorageMultisampleEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glNamedRenderbufferStorageMultisampleEXT\")) == NULL) || r;\n  r = ((glProgramUniform1dEXT = (PFNGLPROGRAMUNIFORM1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1dEXT\")) == NULL) || r;\n  r = ((glProgramUniform1dvEXT = (PFNGLPROGRAMUNIFORM1DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1dvEXT\")) == NULL) || r;\n  r = ((glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1fEXT\")) == NULL) || r;\n  r = ((glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1fvEXT\")) == NULL) || r;\n  r = ((glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1iEXT\")) == NULL) || r;\n  r = ((glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1ivEXT\")) == NULL) || r;\n  r = ((glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1uiEXT\")) == NULL) || r;\n  r = ((glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1uivEXT\")) == NULL) || r;\n  r = ((glProgramUniform2dEXT = (PFNGLPROGRAMUNIFORM2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2dEXT\")) == NULL) || r;\n  r = ((glProgramUniform2dvEXT = (PFNGLPROGRAMUNIFORM2DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2dvEXT\")) == NULL) || r;\n  r = ((glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2fEXT\")) == NULL) || r;\n  r = ((glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2fvEXT\")) == NULL) || r;\n  r = ((glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2iEXT\")) == NULL) || r;\n  r = ((glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2ivEXT\")) == NULL) || r;\n  r = ((glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2uiEXT\")) == NULL) || r;\n  r = ((glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2uivEXT\")) == NULL) || r;\n  r = ((glProgramUniform3dEXT = (PFNGLPROGRAMUNIFORM3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3dEXT\")) == NULL) || r;\n  r = ((glProgramUniform3dvEXT = (PFNGLPROGRAMUNIFORM3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3dvEXT\")) == NULL) || r;\n  r = ((glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3fEXT\")) == NULL) || r;\n  r = ((glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3fvEXT\")) == NULL) || r;\n  r = ((glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3iEXT\")) == NULL) || r;\n  r = ((glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3ivEXT\")) == NULL) || r;\n  r = ((glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3uiEXT\")) == NULL) || r;\n  r = ((glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3uivEXT\")) == NULL) || r;\n  r = ((glProgramUniform4dEXT = (PFNGLPROGRAMUNIFORM4DEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4dEXT\")) == NULL) || r;\n  r = ((glProgramUniform4dvEXT = (PFNGLPROGRAMUNIFORM4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4dvEXT\")) == NULL) || r;\n  r = ((glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4fEXT\")) == NULL) || r;\n  r = ((glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4fvEXT\")) == NULL) || r;\n  r = ((glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4iEXT\")) == NULL) || r;\n  r = ((glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4ivEXT\")) == NULL) || r;\n  r = ((glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4uiEXT\")) == NULL) || r;\n  r = ((glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4uivEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2dvEXT = (PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x3dvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x3dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x3fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x4dvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x4dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix2x4fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3dvEXT = (PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x2dvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x2dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x2fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x4dvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x4dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix3x4fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4dvEXT = (PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x2dvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x2dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x2fvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x3dvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x3dvEXT\")) == NULL) || r;\n  r = ((glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformMatrix4x3fvEXT\")) == NULL) || r;\n  r = ((glPushClientAttribDefaultEXT = (PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)\"glPushClientAttribDefaultEXT\")) == NULL) || r;\n  r = ((glTextureBufferEXT = (PFNGLTEXTUREBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureBufferEXT\")) == NULL) || r;\n  r = ((glTextureImage1DEXT = (PFNGLTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage1DEXT\")) == NULL) || r;\n  r = ((glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage2DEXT\")) == NULL) || r;\n  r = ((glTextureImage3DEXT = (PFNGLTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage3DEXT\")) == NULL) || r;\n  r = ((glTextureParameterIivEXT = (PFNGLTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameterIivEXT\")) == NULL) || r;\n  r = ((glTextureParameterIuivEXT = (PFNGLTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameterIuivEXT\")) == NULL) || r;\n  r = ((glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameterfEXT\")) == NULL) || r;\n  r = ((glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameterfvEXT\")) == NULL) || r;\n  r = ((glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameteriEXT\")) == NULL) || r;\n  r = ((glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureParameterivEXT\")) == NULL) || r;\n  r = ((glTextureRenderbufferEXT = (PFNGLTEXTURERENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureRenderbufferEXT\")) == NULL) || r;\n  r = ((glTextureSubImage1DEXT = (PFNGLTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureSubImage1DEXT\")) == NULL) || r;\n  r = ((glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureSubImage2DEXT\")) == NULL) || r;\n  r = ((glTextureSubImage3DEXT = (PFNGLTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureSubImage3DEXT\")) == NULL) || r;\n  r = ((glUnmapNamedBufferEXT = (PFNGLUNMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glUnmapNamedBufferEXT\")) == NULL) || r;\n  r = ((glVertexArrayColorOffsetEXT = (PFNGLVERTEXARRAYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayColorOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayEdgeFlagOffsetEXT = (PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayEdgeFlagOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayFogCoordOffsetEXT = (PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayFogCoordOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayIndexOffsetEXT = (PFNGLVERTEXARRAYINDEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayIndexOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayMultiTexCoordOffsetEXT = (PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayMultiTexCoordOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayNormalOffsetEXT = (PFNGLVERTEXARRAYNORMALOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayNormalOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArraySecondaryColorOffsetEXT = (PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArraySecondaryColorOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayTexCoordOffsetEXT = (PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayTexCoordOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayVertexAttribIOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayVertexAttribIOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayVertexAttribOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayVertexAttribOffsetEXT\")) == NULL) || r;\n  r = ((glVertexArrayVertexOffsetEXT = (PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayVertexOffsetEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_direct_state_access */\n\n#ifdef GL_EXT_draw_buffers2\n\nstatic GLboolean _glewInit_GL_EXT_draw_buffers2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorMaskIndexedEXT = (PFNGLCOLORMASKINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glColorMaskIndexedEXT\")) == NULL) || r;\n  r = ((glDisableIndexedEXT = (PFNGLDISABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableIndexedEXT\")) == NULL) || r;\n  r = ((glEnableIndexedEXT = (PFNGLENABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableIndexedEXT\")) == NULL) || r;\n  r = ((glGetBooleanIndexedvEXT = (PFNGLGETBOOLEANINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetBooleanIndexedvEXT\")) == NULL) || r;\n  r = ((glGetIntegerIndexedvEXT = (PFNGLGETINTEGERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetIntegerIndexedvEXT\")) == NULL) || r;\n  r = ((glIsEnabledIndexedEXT = (PFNGLISENABLEDINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glIsEnabledIndexedEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_draw_buffers2 */\n\n#ifdef GL_EXT_draw_instanced\n\nstatic GLboolean _glewInit_GL_EXT_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysInstancedEXT\")) == NULL) || r;\n  r = ((glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glDrawElementsInstancedEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_draw_instanced */\n\n#ifdef GL_EXT_draw_range_elements\n\nstatic GLboolean _glewInit_GL_EXT_draw_range_elements (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDrawRangeElementsEXT = (PFNGLDRAWRANGEELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)\"glDrawRangeElementsEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_draw_range_elements */\n\n#ifdef GL_EXT_fog_coord\n\nstatic GLboolean _glewInit_GL_EXT_fog_coord (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordPointerEXT\")) == NULL) || r;\n  r = ((glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glewGetProcAddress((const GLubyte*)\"glFogCoorddEXT\")) == NULL) || r;\n  r = ((glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFogCoorddvEXT\")) == NULL) || r;\n  r = ((glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordfEXT\")) == NULL) || r;\n  r = ((glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordfvEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_fog_coord */\n\n#ifdef GL_EXT_fragment_lighting\n\nstatic GLboolean _glewInit_GL_EXT_fragment_lighting (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFragmentColorMaterialEXT = (PFNGLFRAGMENTCOLORMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentColorMaterialEXT\")) == NULL) || r;\n  r = ((glFragmentLightModelfEXT = (PFNGLFRAGMENTLIGHTMODELFEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelfEXT\")) == NULL) || r;\n  r = ((glFragmentLightModelfvEXT = (PFNGLFRAGMENTLIGHTMODELFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelfvEXT\")) == NULL) || r;\n  r = ((glFragmentLightModeliEXT = (PFNGLFRAGMENTLIGHTMODELIEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModeliEXT\")) == NULL) || r;\n  r = ((glFragmentLightModelivEXT = (PFNGLFRAGMENTLIGHTMODELIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelivEXT\")) == NULL) || r;\n  r = ((glFragmentLightfEXT = (PFNGLFRAGMENTLIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightfEXT\")) == NULL) || r;\n  r = ((glFragmentLightfvEXT = (PFNGLFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightfvEXT\")) == NULL) || r;\n  r = ((glFragmentLightiEXT = (PFNGLFRAGMENTLIGHTIEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightiEXT\")) == NULL) || r;\n  r = ((glFragmentLightivEXT = (PFNGLFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightivEXT\")) == NULL) || r;\n  r = ((glFragmentMaterialfEXT = (PFNGLFRAGMENTMATERIALFEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialfEXT\")) == NULL) || r;\n  r = ((glFragmentMaterialfvEXT = (PFNGLFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialfvEXT\")) == NULL) || r;\n  r = ((glFragmentMaterialiEXT = (PFNGLFRAGMENTMATERIALIEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialiEXT\")) == NULL) || r;\n  r = ((glFragmentMaterialivEXT = (PFNGLFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialivEXT\")) == NULL) || r;\n  r = ((glGetFragmentLightfvEXT = (PFNGLGETFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentLightfvEXT\")) == NULL) || r;\n  r = ((glGetFragmentLightivEXT = (PFNGLGETFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentLightivEXT\")) == NULL) || r;\n  r = ((glGetFragmentMaterialfvEXT = (PFNGLGETFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentMaterialfvEXT\")) == NULL) || r;\n  r = ((glGetFragmentMaterialivEXT = (PFNGLGETFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentMaterialivEXT\")) == NULL) || r;\n  r = ((glLightEnviEXT = (PFNGLLIGHTENVIEXTPROC)glewGetProcAddress((const GLubyte*)\"glLightEnviEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_fragment_lighting */\n\n#ifdef GL_EXT_framebuffer_blit\n\nstatic GLboolean _glewInit_GL_EXT_framebuffer_blit (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBlitFramebufferEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_framebuffer_blit */\n\n#ifdef GL_EXT_framebuffer_multisample\n\nstatic GLboolean _glewInit_GL_EXT_framebuffer_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glRenderbufferStorageMultisampleEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_framebuffer_multisample */\n\n#ifdef GL_EXT_framebuffer_multisample_blit_scaled\n\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n\n#ifdef GL_EXT_framebuffer_object\n\nstatic GLboolean _glewInit_GL_EXT_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindFramebufferEXT\")) == NULL) || r;\n  r = ((glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindRenderbufferEXT\")) == NULL) || r;\n  r = ((glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)\"glCheckFramebufferStatusEXT\")) == NULL) || r;\n  r = ((glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glDeleteFramebuffersEXT\")) == NULL) || r;\n  r = ((glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glDeleteRenderbuffersEXT\")) == NULL) || r;\n  r = ((glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferRenderbufferEXT\")) == NULL) || r;\n  r = ((glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture1DEXT\")) == NULL) || r;\n  r = ((glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture2DEXT\")) == NULL) || r;\n  r = ((glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTexture3DEXT\")) == NULL) || r;\n  r = ((glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenFramebuffersEXT\")) == NULL) || r;\n  r = ((glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenRenderbuffersEXT\")) == NULL) || r;\n  r = ((glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenerateMipmapEXT\")) == NULL) || r;\n  r = ((glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFramebufferAttachmentParameterivEXT\")) == NULL) || r;\n  r = ((glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetRenderbufferParameterivEXT\")) == NULL) || r;\n  r = ((glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glIsFramebufferEXT\")) == NULL) || r;\n  r = ((glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glIsRenderbufferEXT\")) == NULL) || r;\n  r = ((glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glRenderbufferStorageEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_framebuffer_object */\n\n#ifdef GL_EXT_framebuffer_sRGB\n\n#endif /* GL_EXT_framebuffer_sRGB */\n\n#ifdef GL_EXT_geometry_shader4\n\nstatic GLboolean _glewInit_GL_EXT_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureEXT\")) == NULL) || r;\n  r = ((glFramebufferTextureFaceEXT = (PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureFaceEXT\")) == NULL) || r;\n  r = ((glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameteriEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_geometry_shader4 */\n\n#ifdef GL_EXT_gpu_program_parameters\n\nstatic GLboolean _glewInit_GL_EXT_gpu_program_parameters (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProgramEnvParameters4fvEXT = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameters4fvEXT\")) == NULL) || r;\n  r = ((glProgramLocalParameters4fvEXT = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameters4fvEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_gpu_program_parameters */\n\n#ifdef GL_EXT_gpu_shader4\n\nstatic GLboolean _glewInit_GL_EXT_gpu_shader4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindFragDataLocationEXT\")) == NULL) || r;\n  r = ((glGetFragDataLocationEXT = (PFNGLGETFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetFragDataLocationEXT\")) == NULL) || r;\n  r = ((glGetUniformuivEXT = (PFNGLGETUNIFORMUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformuivEXT\")) == NULL) || r;\n  r = ((glGetVertexAttribIivEXT = (PFNGLGETVERTEXATTRIBIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribIivEXT\")) == NULL) || r;\n  r = ((glGetVertexAttribIuivEXT = (PFNGLGETVERTEXATTRIBIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribIuivEXT\")) == NULL) || r;\n  r = ((glUniform1uiEXT = (PFNGLUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform1uiEXT\")) == NULL) || r;\n  r = ((glUniform1uivEXT = (PFNGLUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform1uivEXT\")) == NULL) || r;\n  r = ((glUniform2uiEXT = (PFNGLUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform2uiEXT\")) == NULL) || r;\n  r = ((glUniform2uivEXT = (PFNGLUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform2uivEXT\")) == NULL) || r;\n  r = ((glUniform3uiEXT = (PFNGLUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform3uiEXT\")) == NULL) || r;\n  r = ((glUniform3uivEXT = (PFNGLUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform3uivEXT\")) == NULL) || r;\n  r = ((glUniform4uiEXT = (PFNGLUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform4uiEXT\")) == NULL) || r;\n  r = ((glUniform4uivEXT = (PFNGLUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glUniform4uivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI1iEXT = (PFNGLVERTEXATTRIBI1IEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1iEXT\")) == NULL) || r;\n  r = ((glVertexAttribI1ivEXT = (PFNGLVERTEXATTRIBI1IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1ivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI1uiEXT = (PFNGLVERTEXATTRIBI1UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1uiEXT\")) == NULL) || r;\n  r = ((glVertexAttribI1uivEXT = (PFNGLVERTEXATTRIBI1UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI1uivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI2iEXT = (PFNGLVERTEXATTRIBI2IEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2iEXT\")) == NULL) || r;\n  r = ((glVertexAttribI2ivEXT = (PFNGLVERTEXATTRIBI2IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2ivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI2uiEXT = (PFNGLVERTEXATTRIBI2UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2uiEXT\")) == NULL) || r;\n  r = ((glVertexAttribI2uivEXT = (PFNGLVERTEXATTRIBI2UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI2uivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI3iEXT = (PFNGLVERTEXATTRIBI3IEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3iEXT\")) == NULL) || r;\n  r = ((glVertexAttribI3ivEXT = (PFNGLVERTEXATTRIBI3IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3ivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI3uiEXT = (PFNGLVERTEXATTRIBI3UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3uiEXT\")) == NULL) || r;\n  r = ((glVertexAttribI3uivEXT = (PFNGLVERTEXATTRIBI3UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI3uivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4bvEXT = (PFNGLVERTEXATTRIBI4BVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4bvEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4iEXT = (PFNGLVERTEXATTRIBI4IEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4iEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4ivEXT = (PFNGLVERTEXATTRIBI4IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4ivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4svEXT = (PFNGLVERTEXATTRIBI4SVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4svEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4ubvEXT = (PFNGLVERTEXATTRIBI4UBVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4ubvEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4uiEXT = (PFNGLVERTEXATTRIBI4UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4uiEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4uivEXT = (PFNGLVERTEXATTRIBI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4uivEXT\")) == NULL) || r;\n  r = ((glVertexAttribI4usvEXT = (PFNGLVERTEXATTRIBI4USVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribI4usvEXT\")) == NULL) || r;\n  r = ((glVertexAttribIPointerEXT = (PFNGLVERTEXATTRIBIPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribIPointerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_gpu_shader4 */\n\n#ifdef GL_EXT_histogram\n\nstatic GLboolean _glewInit_GL_EXT_histogram (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetHistogramEXT = (PFNGLGETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogramEXT\")) == NULL) || r;\n  r = ((glGetHistogramParameterfvEXT = (PFNGLGETHISTOGRAMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogramParameterfvEXT\")) == NULL) || r;\n  r = ((glGetHistogramParameterivEXT = (PFNGLGETHISTOGRAMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetHistogramParameterivEXT\")) == NULL) || r;\n  r = ((glGetMinmaxEXT = (PFNGLGETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmaxEXT\")) == NULL) || r;\n  r = ((glGetMinmaxParameterfvEXT = (PFNGLGETMINMAXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmaxParameterfvEXT\")) == NULL) || r;\n  r = ((glGetMinmaxParameterivEXT = (PFNGLGETMINMAXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetMinmaxParameterivEXT\")) == NULL) || r;\n  r = ((glHistogramEXT = (PFNGLHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glHistogramEXT\")) == NULL) || r;\n  r = ((glMinmaxEXT = (PFNGLMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)\"glMinmaxEXT\")) == NULL) || r;\n  r = ((glResetHistogramEXT = (PFNGLRESETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glResetHistogramEXT\")) == NULL) || r;\n  r = ((glResetMinmaxEXT = (PFNGLRESETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)\"glResetMinmaxEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_histogram */\n\n#ifdef GL_EXT_index_array_formats\n\n#endif /* GL_EXT_index_array_formats */\n\n#ifdef GL_EXT_index_func\n\nstatic GLboolean _glewInit_GL_EXT_index_func (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glIndexFuncEXT = (PFNGLINDEXFUNCEXTPROC)glewGetProcAddress((const GLubyte*)\"glIndexFuncEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_index_func */\n\n#ifdef GL_EXT_index_material\n\nstatic GLboolean _glewInit_GL_EXT_index_material (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glIndexMaterialEXT = (PFNGLINDEXMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)\"glIndexMaterialEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_index_material */\n\n#ifdef GL_EXT_index_texture\n\n#endif /* GL_EXT_index_texture */\n\n#ifdef GL_EXT_light_texture\n\nstatic GLboolean _glewInit_GL_EXT_light_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glApplyTextureEXT = (PFNGLAPPLYTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glApplyTextureEXT\")) == NULL) || r;\n  r = ((glTextureLightEXT = (PFNGLTEXTURELIGHTEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureLightEXT\")) == NULL) || r;\n  r = ((glTextureMaterialEXT = (PFNGLTEXTUREMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureMaterialEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_light_texture */\n\n#ifdef GL_EXT_misc_attribute\n\n#endif /* GL_EXT_misc_attribute */\n\n#ifdef GL_EXT_multi_draw_arrays\n\nstatic GLboolean _glewInit_GL_EXT_multi_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawArraysEXT\")) == NULL) || r;\n  r = ((glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)\"glMultiDrawElementsEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_multi_draw_arrays */\n\n#ifdef GL_EXT_multisample\n\nstatic GLboolean _glewInit_GL_EXT_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSampleMaskEXT = (PFNGLSAMPLEMASKEXTPROC)glewGetProcAddress((const GLubyte*)\"glSampleMaskEXT\")) == NULL) || r;\n  r = ((glSamplePatternEXT = (PFNGLSAMPLEPATTERNEXTPROC)glewGetProcAddress((const GLubyte*)\"glSamplePatternEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_multisample */\n\n#ifdef GL_EXT_packed_depth_stencil\n\n#endif /* GL_EXT_packed_depth_stencil */\n\n#ifdef GL_EXT_packed_float\n\n#endif /* GL_EXT_packed_float */\n\n#ifdef GL_EXT_packed_pixels\n\n#endif /* GL_EXT_packed_pixels */\n\n#ifdef GL_EXT_paletted_texture\n\nstatic GLboolean _glewInit_GL_EXT_paletted_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glColorTableEXT\")) == NULL) || r;\n  r = ((glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableEXT\")) == NULL) || r;\n  r = ((glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameterfvEXT\")) == NULL) || r;\n  r = ((glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameterivEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_paletted_texture */\n\n#ifdef GL_EXT_pixel_buffer_object\n\n#endif /* GL_EXT_pixel_buffer_object */\n\n#ifdef GL_EXT_pixel_transform\n\nstatic GLboolean _glewInit_GL_EXT_pixel_transform (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetPixelTransformParameterfvEXT = (PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetPixelTransformParameterfvEXT\")) == NULL) || r;\n  r = ((glGetPixelTransformParameterivEXT = (PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetPixelTransformParameterivEXT\")) == NULL) || r;\n  r = ((glPixelTransformParameterfEXT = (PFNGLPIXELTRANSFORMPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)\"glPixelTransformParameterfEXT\")) == NULL) || r;\n  r = ((glPixelTransformParameterfvEXT = (PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glPixelTransformParameterfvEXT\")) == NULL) || r;\n  r = ((glPixelTransformParameteriEXT = (PFNGLPIXELTRANSFORMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)\"glPixelTransformParameteriEXT\")) == NULL) || r;\n  r = ((glPixelTransformParameterivEXT = (PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glPixelTransformParameterivEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_pixel_transform */\n\n#ifdef GL_EXT_pixel_transform_color_table\n\n#endif /* GL_EXT_pixel_transform_color_table */\n\n#ifdef GL_EXT_point_parameters\n\nstatic GLboolean _glewInit_GL_EXT_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterfEXT\")) == NULL) || r;\n  r = ((glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterfvEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_point_parameters */\n\n#ifdef GL_EXT_polygon_offset\n\nstatic GLboolean _glewInit_GL_EXT_polygon_offset (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPolygonOffsetEXT = (PFNGLPOLYGONOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glPolygonOffsetEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_polygon_offset */\n\n#ifdef GL_EXT_provoking_vertex\n\nstatic GLboolean _glewInit_GL_EXT_provoking_vertex (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProvokingVertexEXT = (PFNGLPROVOKINGVERTEXEXTPROC)glewGetProcAddress((const GLubyte*)\"glProvokingVertexEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_provoking_vertex */\n\n#ifdef GL_EXT_rescale_normal\n\n#endif /* GL_EXT_rescale_normal */\n\n#ifdef GL_EXT_scene_marker\n\nstatic GLboolean _glewInit_GL_EXT_scene_marker (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginSceneEXT = (PFNGLBEGINSCENEEXTPROC)glewGetProcAddress((const GLubyte*)\"glBeginSceneEXT\")) == NULL) || r;\n  r = ((glEndSceneEXT = (PFNGLENDSCENEEXTPROC)glewGetProcAddress((const GLubyte*)\"glEndSceneEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_scene_marker */\n\n#ifdef GL_EXT_secondary_color\n\nstatic GLboolean _glewInit_GL_EXT_secondary_color (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSecondaryColor3bEXT = (PFNGLSECONDARYCOLOR3BEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3bEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3bvEXT = (PFNGLSECONDARYCOLOR3BVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3bvEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3dEXT = (PFNGLSECONDARYCOLOR3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3dEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3dvEXT = (PFNGLSECONDARYCOLOR3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3dvEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3fEXT = (PFNGLSECONDARYCOLOR3FEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3fEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3fvEXT = (PFNGLSECONDARYCOLOR3FVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3fvEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3iEXT = (PFNGLSECONDARYCOLOR3IEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3iEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3ivEXT = (PFNGLSECONDARYCOLOR3IVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ivEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3sEXT = (PFNGLSECONDARYCOLOR3SEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3sEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3svEXT = (PFNGLSECONDARYCOLOR3SVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3svEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3ubEXT = (PFNGLSECONDARYCOLOR3UBEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ubEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3ubvEXT = (PFNGLSECONDARYCOLOR3UBVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3ubvEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3uiEXT = (PFNGLSECONDARYCOLOR3UIEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3uiEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3uivEXT = (PFNGLSECONDARYCOLOR3UIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3uivEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3usEXT = (PFNGLSECONDARYCOLOR3USEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3usEXT\")) == NULL) || r;\n  r = ((glSecondaryColor3usvEXT = (PFNGLSECONDARYCOLOR3USVEXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3usvEXT\")) == NULL) || r;\n  r = ((glSecondaryColorPointerEXT = (PFNGLSECONDARYCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorPointerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_secondary_color */\n\n#ifdef GL_EXT_separate_shader_objects\n\nstatic GLboolean _glewInit_GL_EXT_separate_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveProgramEXT = (PFNGLACTIVEPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glActiveProgramEXT\")) == NULL) || r;\n  r = ((glCreateShaderProgramEXT = (PFNGLCREATESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glCreateShaderProgramEXT\")) == NULL) || r;\n  r = ((glUseShaderProgramEXT = (PFNGLUSESHADERPROGRAMEXTPROC)glewGetProcAddress((const GLubyte*)\"glUseShaderProgramEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_separate_shader_objects */\n\n#ifdef GL_EXT_separate_specular_color\n\n#endif /* GL_EXT_separate_specular_color */\n\n#ifdef GL_EXT_shader_image_load_store\n\nstatic GLboolean _glewInit_GL_EXT_shader_image_load_store (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindImageTextureEXT = (PFNGLBINDIMAGETEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindImageTextureEXT\")) == NULL) || r;\n  r = ((glMemoryBarrierEXT = (PFNGLMEMORYBARRIEREXTPROC)glewGetProcAddress((const GLubyte*)\"glMemoryBarrierEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_shader_image_load_store */\n\n#ifdef GL_EXT_shadow_funcs\n\n#endif /* GL_EXT_shadow_funcs */\n\n#ifdef GL_EXT_shared_texture_palette\n\n#endif /* GL_EXT_shared_texture_palette */\n\n#ifdef GL_EXT_stencil_clear_tag\n\n#endif /* GL_EXT_stencil_clear_tag */\n\n#ifdef GL_EXT_stencil_two_side\n\nstatic GLboolean _glewInit_GL_EXT_stencil_two_side (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)glewGetProcAddress((const GLubyte*)\"glActiveStencilFaceEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_stencil_two_side */\n\n#ifdef GL_EXT_stencil_wrap\n\n#endif /* GL_EXT_stencil_wrap */\n\n#ifdef GL_EXT_subtexture\n\nstatic GLboolean _glewInit_GL_EXT_subtexture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexSubImage1DEXT = (PFNGLTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexSubImage1DEXT\")) == NULL) || r;\n  r = ((glTexSubImage2DEXT = (PFNGLTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexSubImage2DEXT\")) == NULL) || r;\n  r = ((glTexSubImage3DEXT = (PFNGLTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexSubImage3DEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_subtexture */\n\n#ifdef GL_EXT_texture\n\n#endif /* GL_EXT_texture */\n\n#ifdef GL_EXT_texture3D\n\nstatic GLboolean _glewInit_GL_EXT_texture3D (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexImage3DEXT = (PFNGLTEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexImage3DEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture3D */\n\n#ifdef GL_EXT_texture_array\n\nstatic GLboolean _glewInit_GL_EXT_texture_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFramebufferTextureLayerEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)\"glFramebufferTextureLayerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture_array */\n\n#ifdef GL_EXT_texture_buffer_object\n\nstatic GLboolean _glewInit_GL_EXT_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"glTexBufferEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture_buffer_object */\n\n#ifdef GL_EXT_texture_compression_dxt1\n\n#endif /* GL_EXT_texture_compression_dxt1 */\n\n#ifdef GL_EXT_texture_compression_latc\n\n#endif /* GL_EXT_texture_compression_latc */\n\n#ifdef GL_EXT_texture_compression_rgtc\n\n#endif /* GL_EXT_texture_compression_rgtc */\n\n#ifdef GL_EXT_texture_compression_s3tc\n\n#endif /* GL_EXT_texture_compression_s3tc */\n\n#ifdef GL_EXT_texture_cube_map\n\n#endif /* GL_EXT_texture_cube_map */\n\n#ifdef GL_EXT_texture_edge_clamp\n\n#endif /* GL_EXT_texture_edge_clamp */\n\n#ifdef GL_EXT_texture_env\n\n#endif /* GL_EXT_texture_env */\n\n#ifdef GL_EXT_texture_env_add\n\n#endif /* GL_EXT_texture_env_add */\n\n#ifdef GL_EXT_texture_env_combine\n\n#endif /* GL_EXT_texture_env_combine */\n\n#ifdef GL_EXT_texture_env_dot3\n\n#endif /* GL_EXT_texture_env_dot3 */\n\n#ifdef GL_EXT_texture_filter_anisotropic\n\n#endif /* GL_EXT_texture_filter_anisotropic */\n\n#ifdef GL_EXT_texture_integer\n\nstatic GLboolean _glewInit_GL_EXT_texture_integer (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClearColorIiEXT = (PFNGLCLEARCOLORIIEXTPROC)glewGetProcAddress((const GLubyte*)\"glClearColorIiEXT\")) == NULL) || r;\n  r = ((glClearColorIuiEXT = (PFNGLCLEARCOLORIUIEXTPROC)glewGetProcAddress((const GLubyte*)\"glClearColorIuiEXT\")) == NULL) || r;\n  r = ((glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTexParameterIivEXT\")) == NULL) || r;\n  r = ((glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTexParameterIuivEXT\")) == NULL) || r;\n  r = ((glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexParameterIivEXT\")) == NULL) || r;\n  r = ((glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glTexParameterIuivEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture_integer */\n\n#ifdef GL_EXT_texture_lod_bias\n\n#endif /* GL_EXT_texture_lod_bias */\n\n#ifdef GL_EXT_texture_mirror_clamp\n\n#endif /* GL_EXT_texture_mirror_clamp */\n\n#ifdef GL_EXT_texture_object\n\nstatic GLboolean _glewInit_GL_EXT_texture_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAreTexturesResidentEXT = (PFNGLARETEXTURESRESIDENTEXTPROC)glewGetProcAddress((const GLubyte*)\"glAreTexturesResidentEXT\")) == NULL) || r;\n  r = ((glBindTextureEXT = (PFNGLBINDTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindTextureEXT\")) == NULL) || r;\n  r = ((glDeleteTexturesEXT = (PFNGLDELETETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)\"glDeleteTexturesEXT\")) == NULL) || r;\n  r = ((glGenTexturesEXT = (PFNGLGENTEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenTexturesEXT\")) == NULL) || r;\n  r = ((glIsTextureEXT = (PFNGLISTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)\"glIsTextureEXT\")) == NULL) || r;\n  r = ((glPrioritizeTexturesEXT = (PFNGLPRIORITIZETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)\"glPrioritizeTexturesEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture_object */\n\n#ifdef GL_EXT_texture_perturb_normal\n\nstatic GLboolean _glewInit_GL_EXT_texture_perturb_normal (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTextureNormalEXT = (PFNGLTEXTURENORMALEXTPROC)glewGetProcAddress((const GLubyte*)\"glTextureNormalEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_texture_perturb_normal */\n\n#ifdef GL_EXT_texture_rectangle\n\n#endif /* GL_EXT_texture_rectangle */\n\n#ifdef GL_EXT_texture_sRGB\n\n#endif /* GL_EXT_texture_sRGB */\n\n#ifdef GL_EXT_texture_sRGB_decode\n\n#endif /* GL_EXT_texture_sRGB_decode */\n\n#ifdef GL_EXT_texture_shared_exponent\n\n#endif /* GL_EXT_texture_shared_exponent */\n\n#ifdef GL_EXT_texture_snorm\n\n#endif /* GL_EXT_texture_snorm */\n\n#ifdef GL_EXT_texture_swizzle\n\n#endif /* GL_EXT_texture_swizzle */\n\n#ifdef GL_EXT_timer_query\n\nstatic GLboolean _glewInit_GL_EXT_timer_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjecti64vEXT\")) == NULL) || r;\n  r = ((glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetQueryObjectui64vEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_timer_query */\n\n#ifdef GL_EXT_transform_feedback\n\nstatic GLboolean _glewInit_GL_EXT_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginTransformFeedbackEXT = (PFNGLBEGINTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)\"glBeginTransformFeedbackEXT\")) == NULL) || r;\n  r = ((glBindBufferBaseEXT = (PFNGLBINDBUFFERBASEEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferBaseEXT\")) == NULL) || r;\n  r = ((glBindBufferOffsetEXT = (PFNGLBINDBUFFEROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferOffsetEXT\")) == NULL) || r;\n  r = ((glBindBufferRangeEXT = (PFNGLBINDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferRangeEXT\")) == NULL) || r;\n  r = ((glEndTransformFeedbackEXT = (PFNGLENDTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)\"glEndTransformFeedbackEXT\")) == NULL) || r;\n  r = ((glGetTransformFeedbackVaryingEXT = (PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetTransformFeedbackVaryingEXT\")) == NULL) || r;\n  r = ((glTransformFeedbackVaryingsEXT = (PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC)glewGetProcAddress((const GLubyte*)\"glTransformFeedbackVaryingsEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_transform_feedback */\n\n#ifdef GL_EXT_vertex_array\n\nstatic GLboolean _glewInit_GL_EXT_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)glewGetProcAddress((const GLubyte*)\"glArrayElementEXT\")) == NULL) || r;\n  r = ((glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glColorPointerEXT\")) == NULL) || r;\n  r = ((glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)\"glDrawArraysEXT\")) == NULL) || r;\n  r = ((glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glEdgeFlagPointerEXT\")) == NULL) || r;\n  r = ((glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glIndexPointerEXT\")) == NULL) || r;\n  r = ((glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glNormalPointerEXT\")) == NULL) || r;\n  r = ((glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordPointerEXT\")) == NULL) || r;\n  r = ((glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexPointerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_vertex_array */\n\n#ifdef GL_EXT_vertex_array_bgra\n\n#endif /* GL_EXT_vertex_array_bgra */\n\n#ifdef GL_EXT_vertex_attrib_64bit\n\nstatic GLboolean _glewInit_GL_EXT_vertex_attrib_64bit (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetVertexAttribLdvEXT = (PFNGLGETVERTEXATTRIBLDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribLdvEXT\")) == NULL) || r;\n  r = ((glVertexArrayVertexAttribLOffsetEXT = (PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayVertexAttribLOffsetEXT\")) == NULL) || r;\n  r = ((glVertexAttribL1dEXT = (PFNGLVERTEXATTRIBL1DEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1dEXT\")) == NULL) || r;\n  r = ((glVertexAttribL1dvEXT = (PFNGLVERTEXATTRIBL1DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1dvEXT\")) == NULL) || r;\n  r = ((glVertexAttribL2dEXT = (PFNGLVERTEXATTRIBL2DEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2dEXT\")) == NULL) || r;\n  r = ((glVertexAttribL2dvEXT = (PFNGLVERTEXATTRIBL2DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2dvEXT\")) == NULL) || r;\n  r = ((glVertexAttribL3dEXT = (PFNGLVERTEXATTRIBL3DEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3dEXT\")) == NULL) || r;\n  r = ((glVertexAttribL3dvEXT = (PFNGLVERTEXATTRIBL3DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3dvEXT\")) == NULL) || r;\n  r = ((glVertexAttribL4dEXT = (PFNGLVERTEXATTRIBL4DEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4dEXT\")) == NULL) || r;\n  r = ((glVertexAttribL4dvEXT = (PFNGLVERTEXATTRIBL4DVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4dvEXT\")) == NULL) || r;\n  r = ((glVertexAttribLPointerEXT = (PFNGLVERTEXATTRIBLPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribLPointerEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_vertex_attrib_64bit */\n\n#ifdef GL_EXT_vertex_shader\n\nstatic GLboolean _glewInit_GL_EXT_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBeginVertexShaderEXT\")) == NULL) || r;\n  r = ((glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindLightParameterEXT\")) == NULL) || r;\n  r = ((glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindMaterialParameterEXT\")) == NULL) || r;\n  r = ((glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindParameterEXT\")) == NULL) || r;\n  r = ((glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindTexGenParameterEXT\")) == NULL) || r;\n  r = ((glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindTextureUnitParameterEXT\")) == NULL) || r;\n  r = ((glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)\"glBindVertexShaderEXT\")) == NULL) || r;\n  r = ((glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)\"glDeleteVertexShaderEXT\")) == NULL) || r;\n  r = ((glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)\"glDisableVariantClientStateEXT\")) == NULL) || r;\n  r = ((glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)\"glEnableVariantClientStateEXT\")) == NULL) || r;\n  r = ((glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)\"glEndVertexShaderEXT\")) == NULL) || r;\n  r = ((glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)\"glExtractComponentEXT\")) == NULL) || r;\n  r = ((glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenSymbolsEXT\")) == NULL) || r;\n  r = ((glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)glewGetProcAddress((const GLubyte*)\"glGenVertexShadersEXT\")) == NULL) || r;\n  r = ((glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetInvariantBooleanvEXT\")) == NULL) || r;\n  r = ((glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetInvariantFloatvEXT\")) == NULL) || r;\n  r = ((glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetInvariantIntegervEXT\")) == NULL) || r;\n  r = ((glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetLocalConstantBooleanvEXT\")) == NULL) || r;\n  r = ((glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetLocalConstantFloatvEXT\")) == NULL) || r;\n  r = ((glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetLocalConstantIntegervEXT\")) == NULL) || r;\n  r = ((glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantBooleanvEXT\")) == NULL) || r;\n  r = ((glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantFloatvEXT\")) == NULL) || r;\n  r = ((glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantIntegervEXT\")) == NULL) || r;\n  r = ((glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)\"glGetVariantPointervEXT\")) == NULL) || r;\n  r = ((glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)\"glInsertComponentEXT\")) == NULL) || r;\n  r = ((glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)\"glIsVariantEnabledEXT\")) == NULL) || r;\n  r = ((glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)glewGetProcAddress((const GLubyte*)\"glSetInvariantEXT\")) == NULL) || r;\n  r = ((glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)glewGetProcAddress((const GLubyte*)\"glSetLocalConstantEXT\")) == NULL) || r;\n  r = ((glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)glewGetProcAddress((const GLubyte*)\"glShaderOp1EXT\")) == NULL) || r;\n  r = ((glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)glewGetProcAddress((const GLubyte*)\"glShaderOp2EXT\")) == NULL) || r;\n  r = ((glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)glewGetProcAddress((const GLubyte*)\"glShaderOp3EXT\")) == NULL) || r;\n  r = ((glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)glewGetProcAddress((const GLubyte*)\"glSwizzleEXT\")) == NULL) || r;\n  r = ((glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantPointerEXT\")) == NULL) || r;\n  r = ((glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantbvEXT\")) == NULL) || r;\n  r = ((glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantdvEXT\")) == NULL) || r;\n  r = ((glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantfvEXT\")) == NULL) || r;\n  r = ((glVariantivEXT = (PFNGLVARIANTIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantivEXT\")) == NULL) || r;\n  r = ((glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantsvEXT\")) == NULL) || r;\n  r = ((glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantubvEXT\")) == NULL) || r;\n  r = ((glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantuivEXT\")) == NULL) || r;\n  r = ((glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVariantusvEXT\")) == NULL) || r;\n  r = ((glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)glewGetProcAddress((const GLubyte*)\"glWriteMaskEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_vertex_shader */\n\n#ifdef GL_EXT_vertex_weighting\n\nstatic GLboolean _glewInit_GL_EXT_vertex_weighting (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glVertexWeightPointerEXT = (PFNGLVERTEXWEIGHTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexWeightPointerEXT\")) == NULL) || r;\n  r = ((glVertexWeightfEXT = (PFNGLVERTEXWEIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexWeightfEXT\")) == NULL) || r;\n  r = ((glVertexWeightfvEXT = (PFNGLVERTEXWEIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)\"glVertexWeightfvEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_vertex_weighting */\n\n#ifdef GL_EXT_x11_sync_object\n\nstatic GLboolean _glewInit_GL_EXT_x11_sync_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glImportSyncEXT = (PFNGLIMPORTSYNCEXTPROC)glewGetProcAddress((const GLubyte*)\"glImportSyncEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_EXT_x11_sync_object */\n\n#ifdef GL_GREMEDY_frame_terminator\n\nstatic GLboolean _glewInit_GL_GREMEDY_frame_terminator (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)glewGetProcAddress((const GLubyte*)\"glFrameTerminatorGREMEDY\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_GREMEDY_frame_terminator */\n\n#ifdef GL_GREMEDY_string_marker\n\nstatic GLboolean _glewInit_GL_GREMEDY_string_marker (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glStringMarkerGREMEDY = (PFNGLSTRINGMARKERGREMEDYPROC)glewGetProcAddress((const GLubyte*)\"glStringMarkerGREMEDY\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_GREMEDY_string_marker */\n\n#ifdef GL_HP_convolution_border_modes\n\n#endif /* GL_HP_convolution_border_modes */\n\n#ifdef GL_HP_image_transform\n\nstatic GLboolean _glewInit_GL_HP_image_transform (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetImageTransformParameterfvHP = (PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)\"glGetImageTransformParameterfvHP\")) == NULL) || r;\n  r = ((glGetImageTransformParameterivHP = (PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)\"glGetImageTransformParameterivHP\")) == NULL) || r;\n  r = ((glImageTransformParameterfHP = (PFNGLIMAGETRANSFORMPARAMETERFHPPROC)glewGetProcAddress((const GLubyte*)\"glImageTransformParameterfHP\")) == NULL) || r;\n  r = ((glImageTransformParameterfvHP = (PFNGLIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)\"glImageTransformParameterfvHP\")) == NULL) || r;\n  r = ((glImageTransformParameteriHP = (PFNGLIMAGETRANSFORMPARAMETERIHPPROC)glewGetProcAddress((const GLubyte*)\"glImageTransformParameteriHP\")) == NULL) || r;\n  r = ((glImageTransformParameterivHP = (PFNGLIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)\"glImageTransformParameterivHP\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_HP_image_transform */\n\n#ifdef GL_HP_occlusion_test\n\n#endif /* GL_HP_occlusion_test */\n\n#ifdef GL_HP_texture_lighting\n\n#endif /* GL_HP_texture_lighting */\n\n#ifdef GL_IBM_cull_vertex\n\n#endif /* GL_IBM_cull_vertex */\n\n#ifdef GL_IBM_multimode_draw_arrays\n\nstatic GLboolean _glewInit_GL_IBM_multimode_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glMultiModeDrawArraysIBM = (PFNGLMULTIMODEDRAWARRAYSIBMPROC)glewGetProcAddress((const GLubyte*)\"glMultiModeDrawArraysIBM\")) == NULL) || r;\n  r = ((glMultiModeDrawElementsIBM = (PFNGLMULTIMODEDRAWELEMENTSIBMPROC)glewGetProcAddress((const GLubyte*)\"glMultiModeDrawElementsIBM\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_IBM_multimode_draw_arrays */\n\n#ifdef GL_IBM_rasterpos_clip\n\n#endif /* GL_IBM_rasterpos_clip */\n\n#ifdef GL_IBM_static_data\n\n#endif /* GL_IBM_static_data */\n\n#ifdef GL_IBM_texture_mirrored_repeat\n\n#endif /* GL_IBM_texture_mirrored_repeat */\n\n#ifdef GL_IBM_vertex_array_lists\n\nstatic GLboolean _glewInit_GL_IBM_vertex_array_lists (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorPointerListIBM = (PFNGLCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glColorPointerListIBM\")) == NULL) || r;\n  r = ((glEdgeFlagPointerListIBM = (PFNGLEDGEFLAGPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glEdgeFlagPointerListIBM\")) == NULL) || r;\n  r = ((glFogCoordPointerListIBM = (PFNGLFOGCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordPointerListIBM\")) == NULL) || r;\n  r = ((glIndexPointerListIBM = (PFNGLINDEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glIndexPointerListIBM\")) == NULL) || r;\n  r = ((glNormalPointerListIBM = (PFNGLNORMALPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glNormalPointerListIBM\")) == NULL) || r;\n  r = ((glSecondaryColorPointerListIBM = (PFNGLSECONDARYCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorPointerListIBM\")) == NULL) || r;\n  r = ((glTexCoordPointerListIBM = (PFNGLTEXCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordPointerListIBM\")) == NULL) || r;\n  r = ((glVertexPointerListIBM = (PFNGLVERTEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)\"glVertexPointerListIBM\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_IBM_vertex_array_lists */\n\n#ifdef GL_INGR_color_clamp\n\n#endif /* GL_INGR_color_clamp */\n\n#ifdef GL_INGR_interlace_read\n\n#endif /* GL_INGR_interlace_read */\n\n#ifdef GL_INTEL_parallel_arrays\n\nstatic GLboolean _glewInit_GL_INTEL_parallel_arrays (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorPointervINTEL = (PFNGLCOLORPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)\"glColorPointervINTEL\")) == NULL) || r;\n  r = ((glNormalPointervINTEL = (PFNGLNORMALPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)\"glNormalPointervINTEL\")) == NULL) || r;\n  r = ((glTexCoordPointervINTEL = (PFNGLTEXCOORDPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordPointervINTEL\")) == NULL) || r;\n  r = ((glVertexPointervINTEL = (PFNGLVERTEXPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)\"glVertexPointervINTEL\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_INTEL_parallel_arrays */\n\n#ifdef GL_INTEL_texture_scissor\n\nstatic GLboolean _glewInit_GL_INTEL_texture_scissor (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexScissorFuncINTEL = (PFNGLTEXSCISSORFUNCINTELPROC)glewGetProcAddress((const GLubyte*)\"glTexScissorFuncINTEL\")) == NULL) || r;\n  r = ((glTexScissorINTEL = (PFNGLTEXSCISSORINTELPROC)glewGetProcAddress((const GLubyte*)\"glTexScissorINTEL\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_INTEL_texture_scissor */\n\n#ifdef GL_KHR_debug\n\nstatic GLboolean _glewInit_GL_KHR_debug (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageCallback\")) == NULL) || r;\n  r = ((glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageControl\")) == NULL) || r;\n  r = ((glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)glewGetProcAddress((const GLubyte*)\"glDebugMessageInsert\")) == NULL) || r;\n  r = ((glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)glewGetProcAddress((const GLubyte*)\"glGetDebugMessageLog\")) == NULL) || r;\n  r = ((glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectLabel\")) == NULL) || r;\n  r = ((glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)glewGetProcAddress((const GLubyte*)\"glGetObjectPtrLabel\")) == NULL) || r;\n  r = ((glGetPointerv = (PFNGLGETPOINTERVPROC)glewGetProcAddress((const GLubyte*)\"glGetPointerv\")) == NULL) || r;\n  r = ((glObjectLabel = (PFNGLOBJECTLABELPROC)glewGetProcAddress((const GLubyte*)\"glObjectLabel\")) == NULL) || r;\n  r = ((glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)glewGetProcAddress((const GLubyte*)\"glObjectPtrLabel\")) == NULL) || r;\n  r = ((glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)glewGetProcAddress((const GLubyte*)\"glPushDebugGroup\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_KHR_debug */\n\n#ifdef GL_KHR_texture_compression_astc_ldr\n\n#endif /* GL_KHR_texture_compression_astc_ldr */\n\n#ifdef GL_KTX_buffer_region\n\nstatic GLboolean _glewInit_GL_KTX_buffer_region (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBufferRegionEnabled = (PFNGLBUFFERREGIONENABLEDPROC)glewGetProcAddress((const GLubyte*)\"glBufferRegionEnabled\")) == NULL) || r;\n  r = ((glDeleteBufferRegion = (PFNGLDELETEBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)\"glDeleteBufferRegion\")) == NULL) || r;\n  r = ((glDrawBufferRegion = (PFNGLDRAWBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)\"glDrawBufferRegion\")) == NULL) || r;\n  r = ((glNewBufferRegion = (PFNGLNEWBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)\"glNewBufferRegion\")) == NULL) || r;\n  r = ((glReadBufferRegion = (PFNGLREADBUFFERREGIONPROC)glewGetProcAddress((const GLubyte*)\"glReadBufferRegion\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_KTX_buffer_region */\n\n#ifdef GL_MESAX_texture_stack\n\n#endif /* GL_MESAX_texture_stack */\n\n#ifdef GL_MESA_pack_invert\n\n#endif /* GL_MESA_pack_invert */\n\n#ifdef GL_MESA_resize_buffers\n\nstatic GLboolean _glewInit_GL_MESA_resize_buffers (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glResizeBuffersMESA = (PFNGLRESIZEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)\"glResizeBuffersMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_MESA_resize_buffers */\n\n#ifdef GL_MESA_window_pos\n\nstatic GLboolean _glewInit_GL_MESA_window_pos (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glWindowPos2dMESA = (PFNGLWINDOWPOS2DMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2dMESA\")) == NULL) || r;\n  r = ((glWindowPos2dvMESA = (PFNGLWINDOWPOS2DVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2dvMESA\")) == NULL) || r;\n  r = ((glWindowPos2fMESA = (PFNGLWINDOWPOS2FMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2fMESA\")) == NULL) || r;\n  r = ((glWindowPos2fvMESA = (PFNGLWINDOWPOS2FVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2fvMESA\")) == NULL) || r;\n  r = ((glWindowPos2iMESA = (PFNGLWINDOWPOS2IMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2iMESA\")) == NULL) || r;\n  r = ((glWindowPos2ivMESA = (PFNGLWINDOWPOS2IVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2ivMESA\")) == NULL) || r;\n  r = ((glWindowPos2sMESA = (PFNGLWINDOWPOS2SMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2sMESA\")) == NULL) || r;\n  r = ((glWindowPos2svMESA = (PFNGLWINDOWPOS2SVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos2svMESA\")) == NULL) || r;\n  r = ((glWindowPos3dMESA = (PFNGLWINDOWPOS3DMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3dMESA\")) == NULL) || r;\n  r = ((glWindowPos3dvMESA = (PFNGLWINDOWPOS3DVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3dvMESA\")) == NULL) || r;\n  r = ((glWindowPos3fMESA = (PFNGLWINDOWPOS3FMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3fMESA\")) == NULL) || r;\n  r = ((glWindowPos3fvMESA = (PFNGLWINDOWPOS3FVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3fvMESA\")) == NULL) || r;\n  r = ((glWindowPos3iMESA = (PFNGLWINDOWPOS3IMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3iMESA\")) == NULL) || r;\n  r = ((glWindowPos3ivMESA = (PFNGLWINDOWPOS3IVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3ivMESA\")) == NULL) || r;\n  r = ((glWindowPos3sMESA = (PFNGLWINDOWPOS3SMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3sMESA\")) == NULL) || r;\n  r = ((glWindowPos3svMESA = (PFNGLWINDOWPOS3SVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos3svMESA\")) == NULL) || r;\n  r = ((glWindowPos4dMESA = (PFNGLWINDOWPOS4DMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4dMESA\")) == NULL) || r;\n  r = ((glWindowPos4dvMESA = (PFNGLWINDOWPOS4DVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4dvMESA\")) == NULL) || r;\n  r = ((glWindowPos4fMESA = (PFNGLWINDOWPOS4FMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4fMESA\")) == NULL) || r;\n  r = ((glWindowPos4fvMESA = (PFNGLWINDOWPOS4FVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4fvMESA\")) == NULL) || r;\n  r = ((glWindowPos4iMESA = (PFNGLWINDOWPOS4IMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4iMESA\")) == NULL) || r;\n  r = ((glWindowPos4ivMESA = (PFNGLWINDOWPOS4IVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4ivMESA\")) == NULL) || r;\n  r = ((glWindowPos4sMESA = (PFNGLWINDOWPOS4SMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4sMESA\")) == NULL) || r;\n  r = ((glWindowPos4svMESA = (PFNGLWINDOWPOS4SVMESAPROC)glewGetProcAddress((const GLubyte*)\"glWindowPos4svMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_MESA_window_pos */\n\n#ifdef GL_MESA_ycbcr_texture\n\n#endif /* GL_MESA_ycbcr_texture */\n\n#ifdef GL_NVX_gpu_memory_info\n\n#endif /* GL_NVX_gpu_memory_info */\n\n#ifdef GL_NV_bindless_texture\n\nstatic GLboolean _glewInit_GL_NV_bindless_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetImageHandleNV = (PFNGLGETIMAGEHANDLENVPROC)glewGetProcAddress((const GLubyte*)\"glGetImageHandleNV\")) == NULL) || r;\n  r = ((glGetTextureHandleNV = (PFNGLGETTEXTUREHANDLENVPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureHandleNV\")) == NULL) || r;\n  r = ((glGetTextureSamplerHandleNV = (PFNGLGETTEXTURESAMPLERHANDLENVPROC)glewGetProcAddress((const GLubyte*)\"glGetTextureSamplerHandleNV\")) == NULL) || r;\n  r = ((glIsImageHandleResidentNV = (PFNGLISIMAGEHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glIsImageHandleResidentNV\")) == NULL) || r;\n  r = ((glIsTextureHandleResidentNV = (PFNGLISTEXTUREHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glIsTextureHandleResidentNV\")) == NULL) || r;\n  r = ((glMakeImageHandleNonResidentNV = (PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeImageHandleNonResidentNV\")) == NULL) || r;\n  r = ((glMakeImageHandleResidentNV = (PFNGLMAKEIMAGEHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeImageHandleResidentNV\")) == NULL) || r;\n  r = ((glMakeTextureHandleNonResidentNV = (PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeTextureHandleNonResidentNV\")) == NULL) || r;\n  r = ((glMakeTextureHandleResidentNV = (PFNGLMAKETEXTUREHANDLERESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeTextureHandleResidentNV\")) == NULL) || r;\n  r = ((glProgramUniformHandleui64NV = (PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformHandleui64NV\")) == NULL) || r;\n  r = ((glProgramUniformHandleui64vNV = (PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformHandleui64vNV\")) == NULL) || r;\n  r = ((glUniformHandleui64NV = (PFNGLUNIFORMHANDLEUI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniformHandleui64NV\")) == NULL) || r;\n  r = ((glUniformHandleui64vNV = (PFNGLUNIFORMHANDLEUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniformHandleui64vNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_bindless_texture */\n\n#ifdef GL_NV_blend_square\n\n#endif /* GL_NV_blend_square */\n\n#ifdef GL_NV_conditional_render\n\nstatic GLboolean _glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginConditionalRenderNV = (PFNGLBEGINCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)\"glBeginConditionalRenderNV\")) == NULL) || r;\n  r = ((glEndConditionalRenderNV = (PFNGLENDCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)\"glEndConditionalRenderNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_conditional_render */\n\n#ifdef GL_NV_copy_depth_to_color\n\n#endif /* GL_NV_copy_depth_to_color */\n\n#ifdef GL_NV_copy_image\n\nstatic GLboolean _glewInit_GL_NV_copy_image (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyImageSubDataNV = (PFNGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)\"glCopyImageSubDataNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_copy_image */\n\n#ifdef GL_NV_depth_buffer_float\n\nstatic GLboolean _glewInit_GL_NV_depth_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClearDepthdNV = (PFNGLCLEARDEPTHDNVPROC)glewGetProcAddress((const GLubyte*)\"glClearDepthdNV\")) == NULL) || r;\n  r = ((glDepthBoundsdNV = (PFNGLDEPTHBOUNDSDNVPROC)glewGetProcAddress((const GLubyte*)\"glDepthBoundsdNV\")) == NULL) || r;\n  r = ((glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)glewGetProcAddress((const GLubyte*)\"glDepthRangedNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_depth_buffer_float */\n\n#ifdef GL_NV_depth_clamp\n\n#endif /* GL_NV_depth_clamp */\n\n#ifdef GL_NV_depth_range_unclamped\n\n#endif /* GL_NV_depth_range_unclamped */\n\n#ifdef GL_NV_evaluators\n\nstatic GLboolean _glewInit_GL_NV_evaluators (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glEvalMapsNV = (PFNGLEVALMAPSNVPROC)glewGetProcAddress((const GLubyte*)\"glEvalMapsNV\")) == NULL) || r;\n  r = ((glGetMapAttribParameterfvNV = (PFNGLGETMAPATTRIBPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMapAttribParameterfvNV\")) == NULL) || r;\n  r = ((glGetMapAttribParameterivNV = (PFNGLGETMAPATTRIBPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMapAttribParameterivNV\")) == NULL) || r;\n  r = ((glGetMapControlPointsNV = (PFNGLGETMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMapControlPointsNV\")) == NULL) || r;\n  r = ((glGetMapParameterfvNV = (PFNGLGETMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMapParameterfvNV\")) == NULL) || r;\n  r = ((glGetMapParameterivNV = (PFNGLGETMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMapParameterivNV\")) == NULL) || r;\n  r = ((glMapControlPointsNV = (PFNGLMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)\"glMapControlPointsNV\")) == NULL) || r;\n  r = ((glMapParameterfvNV = (PFNGLMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glMapParameterfvNV\")) == NULL) || r;\n  r = ((glMapParameterivNV = (PFNGLMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glMapParameterivNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_evaluators */\n\n#ifdef GL_NV_explicit_multisample\n\nstatic GLboolean _glewInit_GL_NV_explicit_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetMultisamplefvNV = (PFNGLGETMULTISAMPLEFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetMultisamplefvNV\")) == NULL) || r;\n  r = ((glSampleMaskIndexedNV = (PFNGLSAMPLEMASKINDEXEDNVPROC)glewGetProcAddress((const GLubyte*)\"glSampleMaskIndexedNV\")) == NULL) || r;\n  r = ((glTexRenderbufferNV = (PFNGLTEXRENDERBUFFERNVPROC)glewGetProcAddress((const GLubyte*)\"glTexRenderbufferNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_explicit_multisample */\n\n#ifdef GL_NV_fence\n\nstatic GLboolean _glewInit_GL_NV_fence (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC)glewGetProcAddress((const GLubyte*)\"glDeleteFencesNV\")) == NULL) || r;\n  r = ((glFinishFenceNV = (PFNGLFINISHFENCENVPROC)glewGetProcAddress((const GLubyte*)\"glFinishFenceNV\")) == NULL) || r;\n  r = ((glGenFencesNV = (PFNGLGENFENCESNVPROC)glewGetProcAddress((const GLubyte*)\"glGenFencesNV\")) == NULL) || r;\n  r = ((glGetFenceivNV = (PFNGLGETFENCEIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetFenceivNV\")) == NULL) || r;\n  r = ((glIsFenceNV = (PFNGLISFENCENVPROC)glewGetProcAddress((const GLubyte*)\"glIsFenceNV\")) == NULL) || r;\n  r = ((glSetFenceNV = (PFNGLSETFENCENVPROC)glewGetProcAddress((const GLubyte*)\"glSetFenceNV\")) == NULL) || r;\n  r = ((glTestFenceNV = (PFNGLTESTFENCENVPROC)glewGetProcAddress((const GLubyte*)\"glTestFenceNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_fence */\n\n#ifdef GL_NV_float_buffer\n\n#endif /* GL_NV_float_buffer */\n\n#ifdef GL_NV_fog_distance\n\n#endif /* GL_NV_fog_distance */\n\n#ifdef GL_NV_fragment_program\n\nstatic GLboolean _glewInit_GL_NV_fragment_program (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetProgramNamedParameterdvNV = (PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramNamedParameterdvNV\")) == NULL) || r;\n  r = ((glGetProgramNamedParameterfvNV = (PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramNamedParameterfvNV\")) == NULL) || r;\n  r = ((glProgramNamedParameter4dNV = (PFNGLPROGRAMNAMEDPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramNamedParameter4dNV\")) == NULL) || r;\n  r = ((glProgramNamedParameter4dvNV = (PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramNamedParameter4dvNV\")) == NULL) || r;\n  r = ((glProgramNamedParameter4fNV = (PFNGLPROGRAMNAMEDPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramNamedParameter4fNV\")) == NULL) || r;\n  r = ((glProgramNamedParameter4fvNV = (PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramNamedParameter4fvNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_fragment_program */\n\n#ifdef GL_NV_fragment_program2\n\n#endif /* GL_NV_fragment_program2 */\n\n#ifdef GL_NV_fragment_program4\n\n#endif /* GL_NV_fragment_program4 */\n\n#ifdef GL_NV_fragment_program_option\n\n#endif /* GL_NV_fragment_program_option */\n\n#ifdef GL_NV_framebuffer_multisample_coverage\n\nstatic GLboolean _glewInit_GL_NV_framebuffer_multisample_coverage (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glRenderbufferStorageMultisampleCoverageNV = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)\"glRenderbufferStorageMultisampleCoverageNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_framebuffer_multisample_coverage */\n\n#ifdef GL_NV_geometry_program4\n\nstatic GLboolean _glewInit_GL_NV_geometry_program4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProgramVertexLimitNV = (PFNGLPROGRAMVERTEXLIMITNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramVertexLimitNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_geometry_program4 */\n\n#ifdef GL_NV_geometry_shader4\n\n#endif /* GL_NV_geometry_shader4 */\n\n#ifdef GL_NV_gpu_program4\n\nstatic GLboolean _glewInit_GL_NV_gpu_program4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProgramEnvParameterI4iNV = (PFNGLPROGRAMENVPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameterI4iNV\")) == NULL) || r;\n  r = ((glProgramEnvParameterI4ivNV = (PFNGLPROGRAMENVPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameterI4ivNV\")) == NULL) || r;\n  r = ((glProgramEnvParameterI4uiNV = (PFNGLPROGRAMENVPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameterI4uiNV\")) == NULL) || r;\n  r = ((glProgramEnvParameterI4uivNV = (PFNGLPROGRAMENVPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParameterI4uivNV\")) == NULL) || r;\n  r = ((glProgramEnvParametersI4ivNV = (PFNGLPROGRAMENVPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParametersI4ivNV\")) == NULL) || r;\n  r = ((glProgramEnvParametersI4uivNV = (PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramEnvParametersI4uivNV\")) == NULL) || r;\n  r = ((glProgramLocalParameterI4iNV = (PFNGLPROGRAMLOCALPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameterI4iNV\")) == NULL) || r;\n  r = ((glProgramLocalParameterI4ivNV = (PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameterI4ivNV\")) == NULL) || r;\n  r = ((glProgramLocalParameterI4uiNV = (PFNGLPROGRAMLOCALPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameterI4uiNV\")) == NULL) || r;\n  r = ((glProgramLocalParameterI4uivNV = (PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParameterI4uivNV\")) == NULL) || r;\n  r = ((glProgramLocalParametersI4ivNV = (PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParametersI4ivNV\")) == NULL) || r;\n  r = ((glProgramLocalParametersI4uivNV = (PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramLocalParametersI4uivNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_gpu_program4 */\n\n#ifdef GL_NV_gpu_program5\n\n#endif /* GL_NV_gpu_program5 */\n\n#ifdef GL_NV_gpu_program_fp64\n\n#endif /* GL_NV_gpu_program_fp64 */\n\n#ifdef GL_NV_gpu_shader5\n\nstatic GLboolean _glewInit_GL_NV_gpu_shader5 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetUniformi64vNV = (PFNGLGETUNIFORMI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformi64vNV\")) == NULL) || r;\n  r = ((glGetUniformui64vNV = (PFNGLGETUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetUniformui64vNV\")) == NULL) || r;\n  r = ((glProgramUniform1i64NV = (PFNGLPROGRAMUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1i64NV\")) == NULL) || r;\n  r = ((glProgramUniform1i64vNV = (PFNGLPROGRAMUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1i64vNV\")) == NULL) || r;\n  r = ((glProgramUniform1ui64NV = (PFNGLPROGRAMUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1ui64NV\")) == NULL) || r;\n  r = ((glProgramUniform1ui64vNV = (PFNGLPROGRAMUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform1ui64vNV\")) == NULL) || r;\n  r = ((glProgramUniform2i64NV = (PFNGLPROGRAMUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2i64NV\")) == NULL) || r;\n  r = ((glProgramUniform2i64vNV = (PFNGLPROGRAMUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2i64vNV\")) == NULL) || r;\n  r = ((glProgramUniform2ui64NV = (PFNGLPROGRAMUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2ui64NV\")) == NULL) || r;\n  r = ((glProgramUniform2ui64vNV = (PFNGLPROGRAMUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform2ui64vNV\")) == NULL) || r;\n  r = ((glProgramUniform3i64NV = (PFNGLPROGRAMUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3i64NV\")) == NULL) || r;\n  r = ((glProgramUniform3i64vNV = (PFNGLPROGRAMUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3i64vNV\")) == NULL) || r;\n  r = ((glProgramUniform3ui64NV = (PFNGLPROGRAMUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3ui64NV\")) == NULL) || r;\n  r = ((glProgramUniform3ui64vNV = (PFNGLPROGRAMUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform3ui64vNV\")) == NULL) || r;\n  r = ((glProgramUniform4i64NV = (PFNGLPROGRAMUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4i64NV\")) == NULL) || r;\n  r = ((glProgramUniform4i64vNV = (PFNGLPROGRAMUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4i64vNV\")) == NULL) || r;\n  r = ((glProgramUniform4ui64NV = (PFNGLPROGRAMUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4ui64NV\")) == NULL) || r;\n  r = ((glProgramUniform4ui64vNV = (PFNGLPROGRAMUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniform4ui64vNV\")) == NULL) || r;\n  r = ((glUniform1i64NV = (PFNGLUNIFORM1I64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1i64NV\")) == NULL) || r;\n  r = ((glUniform1i64vNV = (PFNGLUNIFORM1I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1i64vNV\")) == NULL) || r;\n  r = ((glUniform1ui64NV = (PFNGLUNIFORM1UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1ui64NV\")) == NULL) || r;\n  r = ((glUniform1ui64vNV = (PFNGLUNIFORM1UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform1ui64vNV\")) == NULL) || r;\n  r = ((glUniform2i64NV = (PFNGLUNIFORM2I64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2i64NV\")) == NULL) || r;\n  r = ((glUniform2i64vNV = (PFNGLUNIFORM2I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2i64vNV\")) == NULL) || r;\n  r = ((glUniform2ui64NV = (PFNGLUNIFORM2UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2ui64NV\")) == NULL) || r;\n  r = ((glUniform2ui64vNV = (PFNGLUNIFORM2UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform2ui64vNV\")) == NULL) || r;\n  r = ((glUniform3i64NV = (PFNGLUNIFORM3I64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3i64NV\")) == NULL) || r;\n  r = ((glUniform3i64vNV = (PFNGLUNIFORM3I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3i64vNV\")) == NULL) || r;\n  r = ((glUniform3ui64NV = (PFNGLUNIFORM3UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3ui64NV\")) == NULL) || r;\n  r = ((glUniform3ui64vNV = (PFNGLUNIFORM3UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform3ui64vNV\")) == NULL) || r;\n  r = ((glUniform4i64NV = (PFNGLUNIFORM4I64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4i64NV\")) == NULL) || r;\n  r = ((glUniform4i64vNV = (PFNGLUNIFORM4I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4i64vNV\")) == NULL) || r;\n  r = ((glUniform4ui64NV = (PFNGLUNIFORM4UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4ui64NV\")) == NULL) || r;\n  r = ((glUniform4ui64vNV = (PFNGLUNIFORM4UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniform4ui64vNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_gpu_shader5 */\n\n#ifdef GL_NV_half_float\n\nstatic GLboolean _glewInit_GL_NV_half_float (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColor3hNV = (PFNGLCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)\"glColor3hNV\")) == NULL) || r;\n  r = ((glColor3hvNV = (PFNGLCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glColor3hvNV\")) == NULL) || r;\n  r = ((glColor4hNV = (PFNGLCOLOR4HNVPROC)glewGetProcAddress((const GLubyte*)\"glColor4hNV\")) == NULL) || r;\n  r = ((glColor4hvNV = (PFNGLCOLOR4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glColor4hvNV\")) == NULL) || r;\n  r = ((glFogCoordhNV = (PFNGLFOGCOORDHNVPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordhNV\")) == NULL) || r;\n  r = ((glFogCoordhvNV = (PFNGLFOGCOORDHVNVPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordhvNV\")) == NULL) || r;\n  r = ((glMultiTexCoord1hNV = (PFNGLMULTITEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1hNV\")) == NULL) || r;\n  r = ((glMultiTexCoord1hvNV = (PFNGLMULTITEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord1hvNV\")) == NULL) || r;\n  r = ((glMultiTexCoord2hNV = (PFNGLMULTITEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2hNV\")) == NULL) || r;\n  r = ((glMultiTexCoord2hvNV = (PFNGLMULTITEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord2hvNV\")) == NULL) || r;\n  r = ((glMultiTexCoord3hNV = (PFNGLMULTITEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3hNV\")) == NULL) || r;\n  r = ((glMultiTexCoord3hvNV = (PFNGLMULTITEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord3hvNV\")) == NULL) || r;\n  r = ((glMultiTexCoord4hNV = (PFNGLMULTITEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4hNV\")) == NULL) || r;\n  r = ((glMultiTexCoord4hvNV = (PFNGLMULTITEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glMultiTexCoord4hvNV\")) == NULL) || r;\n  r = ((glNormal3hNV = (PFNGLNORMAL3HNVPROC)glewGetProcAddress((const GLubyte*)\"glNormal3hNV\")) == NULL) || r;\n  r = ((glNormal3hvNV = (PFNGLNORMAL3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glNormal3hvNV\")) == NULL) || r;\n  r = ((glSecondaryColor3hNV = (PFNGLSECONDARYCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3hNV\")) == NULL) || r;\n  r = ((glSecondaryColor3hvNV = (PFNGLSECONDARYCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColor3hvNV\")) == NULL) || r;\n  r = ((glTexCoord1hNV = (PFNGLTEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord1hNV\")) == NULL) || r;\n  r = ((glTexCoord1hvNV = (PFNGLTEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord1hvNV\")) == NULL) || r;\n  r = ((glTexCoord2hNV = (PFNGLTEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2hNV\")) == NULL) || r;\n  r = ((glTexCoord2hvNV = (PFNGLTEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2hvNV\")) == NULL) || r;\n  r = ((glTexCoord3hNV = (PFNGLTEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord3hNV\")) == NULL) || r;\n  r = ((glTexCoord3hvNV = (PFNGLTEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord3hvNV\")) == NULL) || r;\n  r = ((glTexCoord4hNV = (PFNGLTEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4hNV\")) == NULL) || r;\n  r = ((glTexCoord4hvNV = (PFNGLTEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4hvNV\")) == NULL) || r;\n  r = ((glVertex2hNV = (PFNGLVERTEX2HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex2hNV\")) == NULL) || r;\n  r = ((glVertex2hvNV = (PFNGLVERTEX2HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex2hvNV\")) == NULL) || r;\n  r = ((glVertex3hNV = (PFNGLVERTEX3HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex3hNV\")) == NULL) || r;\n  r = ((glVertex3hvNV = (PFNGLVERTEX3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex3hvNV\")) == NULL) || r;\n  r = ((glVertex4hNV = (PFNGLVERTEX4HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex4hNV\")) == NULL) || r;\n  r = ((glVertex4hvNV = (PFNGLVERTEX4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertex4hvNV\")) == NULL) || r;\n  r = ((glVertexAttrib1hNV = (PFNGLVERTEXATTRIB1HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1hNV\")) == NULL) || r;\n  r = ((glVertexAttrib1hvNV = (PFNGLVERTEXATTRIB1HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1hvNV\")) == NULL) || r;\n  r = ((glVertexAttrib2hNV = (PFNGLVERTEXATTRIB2HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2hNV\")) == NULL) || r;\n  r = ((glVertexAttrib2hvNV = (PFNGLVERTEXATTRIB2HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2hvNV\")) == NULL) || r;\n  r = ((glVertexAttrib3hNV = (PFNGLVERTEXATTRIB3HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3hNV\")) == NULL) || r;\n  r = ((glVertexAttrib3hvNV = (PFNGLVERTEXATTRIB3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3hvNV\")) == NULL) || r;\n  r = ((glVertexAttrib4hNV = (PFNGLVERTEXATTRIB4HNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4hNV\")) == NULL) || r;\n  r = ((glVertexAttrib4hvNV = (PFNGLVERTEXATTRIB4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4hvNV\")) == NULL) || r;\n  r = ((glVertexAttribs1hvNV = (PFNGLVERTEXATTRIBS1HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs1hvNV\")) == NULL) || r;\n  r = ((glVertexAttribs2hvNV = (PFNGLVERTEXATTRIBS2HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs2hvNV\")) == NULL) || r;\n  r = ((glVertexAttribs3hvNV = (PFNGLVERTEXATTRIBS3HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs3hvNV\")) == NULL) || r;\n  r = ((glVertexAttribs4hvNV = (PFNGLVERTEXATTRIBS4HVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs4hvNV\")) == NULL) || r;\n  r = ((glVertexWeighthNV = (PFNGLVERTEXWEIGHTHNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexWeighthNV\")) == NULL) || r;\n  r = ((glVertexWeighthvNV = (PFNGLVERTEXWEIGHTHVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexWeighthvNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_half_float */\n\n#ifdef GL_NV_light_max_exponent\n\n#endif /* GL_NV_light_max_exponent */\n\n#ifdef GL_NV_multisample_coverage\n\n#endif /* GL_NV_multisample_coverage */\n\n#ifdef GL_NV_multisample_filter_hint\n\n#endif /* GL_NV_multisample_filter_hint */\n\n#ifdef GL_NV_occlusion_query\n\nstatic GLboolean _glewInit_GL_NV_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)\"glBeginOcclusionQueryNV\")) == NULL) || r;\n  r = ((glDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)\"glDeleteOcclusionQueriesNV\")) == NULL) || r;\n  r = ((glEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)\"glEndOcclusionQueryNV\")) == NULL) || r;\n  r = ((glGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)\"glGenOcclusionQueriesNV\")) == NULL) || r;\n  r = ((glGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetOcclusionQueryivNV\")) == NULL) || r;\n  r = ((glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetOcclusionQueryuivNV\")) == NULL) || r;\n  r = ((glIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)\"glIsOcclusionQueryNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_occlusion_query */\n\n#ifdef GL_NV_packed_depth_stencil\n\n#endif /* GL_NV_packed_depth_stencil */\n\n#ifdef GL_NV_parameter_buffer_object\n\nstatic GLboolean _glewInit_GL_NV_parameter_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glProgramBufferParametersIivNV = (PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramBufferParametersIivNV\")) == NULL) || r;\n  r = ((glProgramBufferParametersIuivNV = (PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramBufferParametersIuivNV\")) == NULL) || r;\n  r = ((glProgramBufferParametersfvNV = (PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramBufferParametersfvNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_parameter_buffer_object */\n\n#ifdef GL_NV_parameter_buffer_object2\n\n#endif /* GL_NV_parameter_buffer_object2 */\n\n#ifdef GL_NV_path_rendering\n\nstatic GLboolean _glewInit_GL_NV_path_rendering (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCopyPathNV = (PFNGLCOPYPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glCopyPathNV\")) == NULL) || r;\n  r = ((glCoverFillPathInstancedNV = (PFNGLCOVERFILLPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)\"glCoverFillPathInstancedNV\")) == NULL) || r;\n  r = ((glCoverFillPathNV = (PFNGLCOVERFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glCoverFillPathNV\")) == NULL) || r;\n  r = ((glCoverStrokePathInstancedNV = (PFNGLCOVERSTROKEPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)\"glCoverStrokePathInstancedNV\")) == NULL) || r;\n  r = ((glCoverStrokePathNV = (PFNGLCOVERSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glCoverStrokePathNV\")) == NULL) || r;\n  r = ((glDeletePathsNV = (PFNGLDELETEPATHSNVPROC)glewGetProcAddress((const GLubyte*)\"glDeletePathsNV\")) == NULL) || r;\n  r = ((glGenPathsNV = (PFNGLGENPATHSNVPROC)glewGetProcAddress((const GLubyte*)\"glGenPathsNV\")) == NULL) || r;\n  r = ((glGetPathColorGenfvNV = (PFNGLGETPATHCOLORGENFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathColorGenfvNV\")) == NULL) || r;\n  r = ((glGetPathColorGenivNV = (PFNGLGETPATHCOLORGENIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathColorGenivNV\")) == NULL) || r;\n  r = ((glGetPathCommandsNV = (PFNGLGETPATHCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathCommandsNV\")) == NULL) || r;\n  r = ((glGetPathCoordsNV = (PFNGLGETPATHCOORDSNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathCoordsNV\")) == NULL) || r;\n  r = ((glGetPathDashArrayNV = (PFNGLGETPATHDASHARRAYNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathDashArrayNV\")) == NULL) || r;\n  r = ((glGetPathLengthNV = (PFNGLGETPATHLENGTHNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathLengthNV\")) == NULL) || r;\n  r = ((glGetPathMetricRangeNV = (PFNGLGETPATHMETRICRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathMetricRangeNV\")) == NULL) || r;\n  r = ((glGetPathMetricsNV = (PFNGLGETPATHMETRICSNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathMetricsNV\")) == NULL) || r;\n  r = ((glGetPathParameterfvNV = (PFNGLGETPATHPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathParameterfvNV\")) == NULL) || r;\n  r = ((glGetPathParameterivNV = (PFNGLGETPATHPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathParameterivNV\")) == NULL) || r;\n  r = ((glGetPathSpacingNV = (PFNGLGETPATHSPACINGNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathSpacingNV\")) == NULL) || r;\n  r = ((glGetPathTexGenfvNV = (PFNGLGETPATHTEXGENFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathTexGenfvNV\")) == NULL) || r;\n  r = ((glGetPathTexGenivNV = (PFNGLGETPATHTEXGENIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetPathTexGenivNV\")) == NULL) || r;\n  r = ((glInterpolatePathsNV = (PFNGLINTERPOLATEPATHSNVPROC)glewGetProcAddress((const GLubyte*)\"glInterpolatePathsNV\")) == NULL) || r;\n  r = ((glIsPathNV = (PFNGLISPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glIsPathNV\")) == NULL) || r;\n  r = ((glIsPointInFillPathNV = (PFNGLISPOINTINFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glIsPointInFillPathNV\")) == NULL) || r;\n  r = ((glIsPointInStrokePathNV = (PFNGLISPOINTINSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glIsPointInStrokePathNV\")) == NULL) || r;\n  r = ((glPathColorGenNV = (PFNGLPATHCOLORGENNVPROC)glewGetProcAddress((const GLubyte*)\"glPathColorGenNV\")) == NULL) || r;\n  r = ((glPathCommandsNV = (PFNGLPATHCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)\"glPathCommandsNV\")) == NULL) || r;\n  r = ((glPathCoordsNV = (PFNGLPATHCOORDSNVPROC)glewGetProcAddress((const GLubyte*)\"glPathCoordsNV\")) == NULL) || r;\n  r = ((glPathCoverDepthFuncNV = (PFNGLPATHCOVERDEPTHFUNCNVPROC)glewGetProcAddress((const GLubyte*)\"glPathCoverDepthFuncNV\")) == NULL) || r;\n  r = ((glPathDashArrayNV = (PFNGLPATHDASHARRAYNVPROC)glewGetProcAddress((const GLubyte*)\"glPathDashArrayNV\")) == NULL) || r;\n  r = ((glPathFogGenNV = (PFNGLPATHFOGGENNVPROC)glewGetProcAddress((const GLubyte*)\"glPathFogGenNV\")) == NULL) || r;\n  r = ((glPathGlyphRangeNV = (PFNGLPATHGLYPHRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glPathGlyphRangeNV\")) == NULL) || r;\n  r = ((glPathGlyphsNV = (PFNGLPATHGLYPHSNVPROC)glewGetProcAddress((const GLubyte*)\"glPathGlyphsNV\")) == NULL) || r;\n  r = ((glPathParameterfNV = (PFNGLPATHPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)\"glPathParameterfNV\")) == NULL) || r;\n  r = ((glPathParameterfvNV = (PFNGLPATHPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glPathParameterfvNV\")) == NULL) || r;\n  r = ((glPathParameteriNV = (PFNGLPATHPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)\"glPathParameteriNV\")) == NULL) || r;\n  r = ((glPathParameterivNV = (PFNGLPATHPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glPathParameterivNV\")) == NULL) || r;\n  r = ((glPathStencilDepthOffsetNV = (PFNGLPATHSTENCILDEPTHOFFSETNVPROC)glewGetProcAddress((const GLubyte*)\"glPathStencilDepthOffsetNV\")) == NULL) || r;\n  r = ((glPathStencilFuncNV = (PFNGLPATHSTENCILFUNCNVPROC)glewGetProcAddress((const GLubyte*)\"glPathStencilFuncNV\")) == NULL) || r;\n  r = ((glPathStringNV = (PFNGLPATHSTRINGNVPROC)glewGetProcAddress((const GLubyte*)\"glPathStringNV\")) == NULL) || r;\n  r = ((glPathSubCommandsNV = (PFNGLPATHSUBCOMMANDSNVPROC)glewGetProcAddress((const GLubyte*)\"glPathSubCommandsNV\")) == NULL) || r;\n  r = ((glPathSubCoordsNV = (PFNGLPATHSUBCOORDSNVPROC)glewGetProcAddress((const GLubyte*)\"glPathSubCoordsNV\")) == NULL) || r;\n  r = ((glPathTexGenNV = (PFNGLPATHTEXGENNVPROC)glewGetProcAddress((const GLubyte*)\"glPathTexGenNV\")) == NULL) || r;\n  r = ((glPointAlongPathNV = (PFNGLPOINTALONGPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glPointAlongPathNV\")) == NULL) || r;\n  r = ((glStencilFillPathInstancedNV = (PFNGLSTENCILFILLPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)\"glStencilFillPathInstancedNV\")) == NULL) || r;\n  r = ((glStencilFillPathNV = (PFNGLSTENCILFILLPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glStencilFillPathNV\")) == NULL) || r;\n  r = ((glStencilStrokePathInstancedNV = (PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC)glewGetProcAddress((const GLubyte*)\"glStencilStrokePathInstancedNV\")) == NULL) || r;\n  r = ((glStencilStrokePathNV = (PFNGLSTENCILSTROKEPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glStencilStrokePathNV\")) == NULL) || r;\n  r = ((glTransformPathNV = (PFNGLTRANSFORMPATHNVPROC)glewGetProcAddress((const GLubyte*)\"glTransformPathNV\")) == NULL) || r;\n  r = ((glWeightPathsNV = (PFNGLWEIGHTPATHSNVPROC)glewGetProcAddress((const GLubyte*)\"glWeightPathsNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_path_rendering */\n\n#ifdef GL_NV_pixel_data_range\n\nstatic GLboolean _glewInit_GL_NV_pixel_data_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFlushPixelDataRangeNV = (PFNGLFLUSHPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)\"glFlushPixelDataRangeNV\")) == NULL) || r;\n  r = ((glPixelDataRangeNV = (PFNGLPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)\"glPixelDataRangeNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_pixel_data_range */\n\n#ifdef GL_NV_point_sprite\n\nstatic GLboolean _glewInit_GL_NV_point_sprite (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPointParameteriNV = (PFNGLPOINTPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)\"glPointParameteriNV\")) == NULL) || r;\n  r = ((glPointParameterivNV = (PFNGLPOINTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glPointParameterivNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_point_sprite */\n\n#ifdef GL_NV_present_video\n\nstatic GLboolean _glewInit_GL_NV_present_video (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetVideoi64vNV = (PFNGLGETVIDEOI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoi64vNV\")) == NULL) || r;\n  r = ((glGetVideoivNV = (PFNGLGETVIDEOIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoivNV\")) == NULL) || r;\n  r = ((glGetVideoui64vNV = (PFNGLGETVIDEOUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoui64vNV\")) == NULL) || r;\n  r = ((glGetVideouivNV = (PFNGLGETVIDEOUIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideouivNV\")) == NULL) || r;\n  r = ((glPresentFrameDualFillNV = (PFNGLPRESENTFRAMEDUALFILLNVPROC)glewGetProcAddress((const GLubyte*)\"glPresentFrameDualFillNV\")) == NULL) || r;\n  r = ((glPresentFrameKeyedNV = (PFNGLPRESENTFRAMEKEYEDNVPROC)glewGetProcAddress((const GLubyte*)\"glPresentFrameKeyedNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_present_video */\n\n#ifdef GL_NV_primitive_restart\n\nstatic GLboolean _glewInit_GL_NV_primitive_restart (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPrimitiveRestartIndexNV = (PFNGLPRIMITIVERESTARTINDEXNVPROC)glewGetProcAddress((const GLubyte*)\"glPrimitiveRestartIndexNV\")) == NULL) || r;\n  r = ((glPrimitiveRestartNV = (PFNGLPRIMITIVERESTARTNVPROC)glewGetProcAddress((const GLubyte*)\"glPrimitiveRestartNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_primitive_restart */\n\n#ifdef GL_NV_register_combiners\n\nstatic GLboolean _glewInit_GL_NV_register_combiners (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerInputNV\")) == NULL) || r;\n  r = ((glCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerOutputNV\")) == NULL) || r;\n  r = ((glCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerParameterfNV\")) == NULL) || r;\n  r = ((glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerParameterfvNV\")) == NULL) || r;\n  r = ((glCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerParameteriNV\")) == NULL) || r;\n  r = ((glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerParameterivNV\")) == NULL) || r;\n  r = ((glFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)\"glFinalCombinerInputNV\")) == NULL) || r;\n  r = ((glGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetCombinerInputParameterfvNV\")) == NULL) || r;\n  r = ((glGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetCombinerInputParameterivNV\")) == NULL) || r;\n  r = ((glGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetCombinerOutputParameterfvNV\")) == NULL) || r;\n  r = ((glGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetCombinerOutputParameterivNV\")) == NULL) || r;\n  r = ((glGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetFinalCombinerInputParameterfvNV\")) == NULL) || r;\n  r = ((glGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetFinalCombinerInputParameterivNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_register_combiners */\n\n#ifdef GL_NV_register_combiners2\n\nstatic GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glCombinerStageParameterfvNV = (PFNGLCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glCombinerStageParameterfvNV\")) == NULL) || r;\n  r = ((glGetCombinerStageParameterfvNV = (PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetCombinerStageParameterfvNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_register_combiners2 */\n\n#ifdef GL_NV_shader_atomic_float\n\n#endif /* GL_NV_shader_atomic_float */\n\n#ifdef GL_NV_shader_buffer_load\n\nstatic GLboolean _glewInit_GL_NV_shader_buffer_load (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetBufferParameterui64vNV = (PFNGLGETBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetBufferParameterui64vNV\")) == NULL) || r;\n  r = ((glGetIntegerui64vNV = (PFNGLGETINTEGERUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetIntegerui64vNV\")) == NULL) || r;\n  r = ((glGetNamedBufferParameterui64vNV = (PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetNamedBufferParameterui64vNV\")) == NULL) || r;\n  r = ((glIsBufferResidentNV = (PFNGLISBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glIsBufferResidentNV\")) == NULL) || r;\n  r = ((glIsNamedBufferResidentNV = (PFNGLISNAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glIsNamedBufferResidentNV\")) == NULL) || r;\n  r = ((glMakeBufferNonResidentNV = (PFNGLMAKEBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeBufferNonResidentNV\")) == NULL) || r;\n  r = ((glMakeBufferResidentNV = (PFNGLMAKEBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeBufferResidentNV\")) == NULL) || r;\n  r = ((glMakeNamedBufferNonResidentNV = (PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeNamedBufferNonResidentNV\")) == NULL) || r;\n  r = ((glMakeNamedBufferResidentNV = (PFNGLMAKENAMEDBUFFERRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glMakeNamedBufferResidentNV\")) == NULL) || r;\n  r = ((glProgramUniformui64NV = (PFNGLPROGRAMUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformui64NV\")) == NULL) || r;\n  r = ((glProgramUniformui64vNV = (PFNGLPROGRAMUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramUniformui64vNV\")) == NULL) || r;\n  r = ((glUniformui64NV = (PFNGLUNIFORMUI64NVPROC)glewGetProcAddress((const GLubyte*)\"glUniformui64NV\")) == NULL) || r;\n  r = ((glUniformui64vNV = (PFNGLUNIFORMUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glUniformui64vNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_shader_buffer_load */\n\n#ifdef GL_NV_tessellation_program5\n\n#endif /* GL_NV_tessellation_program5 */\n\n#ifdef GL_NV_texgen_emboss\n\n#endif /* GL_NV_texgen_emboss */\n\n#ifdef GL_NV_texgen_reflection\n\n#endif /* GL_NV_texgen_reflection */\n\n#ifdef GL_NV_texture_barrier\n\nstatic GLboolean _glewInit_GL_NV_texture_barrier (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTextureBarrierNV = (PFNGLTEXTUREBARRIERNVPROC)glewGetProcAddress((const GLubyte*)\"glTextureBarrierNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_texture_barrier */\n\n#ifdef GL_NV_texture_compression_vtc\n\n#endif /* GL_NV_texture_compression_vtc */\n\n#ifdef GL_NV_texture_env_combine4\n\n#endif /* GL_NV_texture_env_combine4 */\n\n#ifdef GL_NV_texture_expand_normal\n\n#endif /* GL_NV_texture_expand_normal */\n\n#ifdef GL_NV_texture_multisample\n\nstatic GLboolean _glewInit_GL_NV_texture_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexImage2DMultisampleCoverageNV = (PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)\"glTexImage2DMultisampleCoverageNV\")) == NULL) || r;\n  r = ((glTexImage3DMultisampleCoverageNV = (PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)\"glTexImage3DMultisampleCoverageNV\")) == NULL) || r;\n  r = ((glTextureImage2DMultisampleCoverageNV = (PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage2DMultisampleCoverageNV\")) == NULL) || r;\n  r = ((glTextureImage2DMultisampleNV = (PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage2DMultisampleNV\")) == NULL) || r;\n  r = ((glTextureImage3DMultisampleCoverageNV = (PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage3DMultisampleCoverageNV\")) == NULL) || r;\n  r = ((glTextureImage3DMultisampleNV = (PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC)glewGetProcAddress((const GLubyte*)\"glTextureImage3DMultisampleNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_texture_multisample */\n\n#ifdef GL_NV_texture_rectangle\n\n#endif /* GL_NV_texture_rectangle */\n\n#ifdef GL_NV_texture_shader\n\n#endif /* GL_NV_texture_shader */\n\n#ifdef GL_NV_texture_shader2\n\n#endif /* GL_NV_texture_shader2 */\n\n#ifdef GL_NV_texture_shader3\n\n#endif /* GL_NV_texture_shader3 */\n\n#ifdef GL_NV_transform_feedback\n\nstatic GLboolean _glewInit_GL_NV_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glActiveVaryingNV = (PFNGLACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)\"glActiveVaryingNV\")) == NULL) || r;\n  r = ((glBeginTransformFeedbackNV = (PFNGLBEGINTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glBeginTransformFeedbackNV\")) == NULL) || r;\n  r = ((glBindBufferBaseNV = (PFNGLBINDBUFFERBASENVPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferBaseNV\")) == NULL) || r;\n  r = ((glBindBufferOffsetNV = (PFNGLBINDBUFFEROFFSETNVPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferOffsetNV\")) == NULL) || r;\n  r = ((glBindBufferRangeNV = (PFNGLBINDBUFFERRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glBindBufferRangeNV\")) == NULL) || r;\n  r = ((glEndTransformFeedbackNV = (PFNGLENDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glEndTransformFeedbackNV\")) == NULL) || r;\n  r = ((glGetActiveVaryingNV = (PFNGLGETACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)\"glGetActiveVaryingNV\")) == NULL) || r;\n  r = ((glGetTransformFeedbackVaryingNV = (PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC)glewGetProcAddress((const GLubyte*)\"glGetTransformFeedbackVaryingNV\")) == NULL) || r;\n  r = ((glGetVaryingLocationNV = (PFNGLGETVARYINGLOCATIONNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVaryingLocationNV\")) == NULL) || r;\n  r = ((glTransformFeedbackAttribsNV = (PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC)glewGetProcAddress((const GLubyte*)\"glTransformFeedbackAttribsNV\")) == NULL) || r;\n  r = ((glTransformFeedbackVaryingsNV = (PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC)glewGetProcAddress((const GLubyte*)\"glTransformFeedbackVaryingsNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_transform_feedback */\n\n#ifdef GL_NV_transform_feedback2\n\nstatic GLboolean _glewInit_GL_NV_transform_feedback2 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBindTransformFeedbackNV = (PFNGLBINDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glBindTransformFeedbackNV\")) == NULL) || r;\n  r = ((glDeleteTransformFeedbacksNV = (PFNGLDELETETRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)\"glDeleteTransformFeedbacksNV\")) == NULL) || r;\n  r = ((glDrawTransformFeedbackNV = (PFNGLDRAWTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glDrawTransformFeedbackNV\")) == NULL) || r;\n  r = ((glGenTransformFeedbacksNV = (PFNGLGENTRANSFORMFEEDBACKSNVPROC)glewGetProcAddress((const GLubyte*)\"glGenTransformFeedbacksNV\")) == NULL) || r;\n  r = ((glIsTransformFeedbackNV = (PFNGLISTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glIsTransformFeedbackNV\")) == NULL) || r;\n  r = ((glPauseTransformFeedbackNV = (PFNGLPAUSETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glPauseTransformFeedbackNV\")) == NULL) || r;\n  r = ((glResumeTransformFeedbackNV = (PFNGLRESUMETRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)\"glResumeTransformFeedbackNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_transform_feedback2 */\n\n#ifdef GL_NV_vdpau_interop\n\nstatic GLboolean _glewInit_GL_NV_vdpau_interop (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUFiniNV\")) == NULL) || r;\n  r = ((glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUGetSurfaceivNV\")) == NULL) || r;\n  r = ((glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUInitNV\")) == NULL) || r;\n  r = ((glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUIsSurfaceNV\")) == NULL) || r;\n  r = ((glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUMapSurfacesNV\")) == NULL) || r;\n  r = ((glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAURegisterOutputSurfaceNV\")) == NULL) || r;\n  r = ((glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAURegisterVideoSurfaceNV\")) == NULL) || r;\n  r = ((glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUSurfaceAccessNV\")) == NULL) || r;\n  r = ((glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUUnmapSurfacesNV\")) == NULL) || r;\n  r = ((glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glewGetProcAddress((const GLubyte*)\"glVDPAUUnregisterSurfaceNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_vdpau_interop */\n\n#ifdef GL_NV_vertex_array_range\n\nstatic GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFlushVertexArrayRangeNV = (PFNGLFLUSHVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glFlushVertexArrayRangeNV\")) == NULL) || r;\n  r = ((glVertexArrayRangeNV = (PFNGLVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glVertexArrayRangeNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_vertex_array_range */\n\n#ifdef GL_NV_vertex_array_range2\n\n#endif /* GL_NV_vertex_array_range2 */\n\n#ifdef GL_NV_vertex_attrib_integer_64bit\n\nstatic GLboolean _glewInit_GL_NV_vertex_attrib_integer_64bit (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetVertexAttribLi64vNV = (PFNGLGETVERTEXATTRIBLI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribLi64vNV\")) == NULL) || r;\n  r = ((glGetVertexAttribLui64vNV = (PFNGLGETVERTEXATTRIBLUI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribLui64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL1i64NV = (PFNGLVERTEXATTRIBL1I64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1i64NV\")) == NULL) || r;\n  r = ((glVertexAttribL1i64vNV = (PFNGLVERTEXATTRIBL1I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1i64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL1ui64NV = (PFNGLVERTEXATTRIBL1UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1ui64NV\")) == NULL) || r;\n  r = ((glVertexAttribL1ui64vNV = (PFNGLVERTEXATTRIBL1UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL1ui64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL2i64NV = (PFNGLVERTEXATTRIBL2I64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2i64NV\")) == NULL) || r;\n  r = ((glVertexAttribL2i64vNV = (PFNGLVERTEXATTRIBL2I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2i64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL2ui64NV = (PFNGLVERTEXATTRIBL2UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2ui64NV\")) == NULL) || r;\n  r = ((glVertexAttribL2ui64vNV = (PFNGLVERTEXATTRIBL2UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL2ui64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL3i64NV = (PFNGLVERTEXATTRIBL3I64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3i64NV\")) == NULL) || r;\n  r = ((glVertexAttribL3i64vNV = (PFNGLVERTEXATTRIBL3I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3i64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL3ui64NV = (PFNGLVERTEXATTRIBL3UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3ui64NV\")) == NULL) || r;\n  r = ((glVertexAttribL3ui64vNV = (PFNGLVERTEXATTRIBL3UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL3ui64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL4i64NV = (PFNGLVERTEXATTRIBL4I64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4i64NV\")) == NULL) || r;\n  r = ((glVertexAttribL4i64vNV = (PFNGLVERTEXATTRIBL4I64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4i64vNV\")) == NULL) || r;\n  r = ((glVertexAttribL4ui64NV = (PFNGLVERTEXATTRIBL4UI64NVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4ui64NV\")) == NULL) || r;\n  r = ((glVertexAttribL4ui64vNV = (PFNGLVERTEXATTRIBL4UI64VNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribL4ui64vNV\")) == NULL) || r;\n  r = ((glVertexAttribLFormatNV = (PFNGLVERTEXATTRIBLFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribLFormatNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n\n#ifdef GL_NV_vertex_buffer_unified_memory\n\nstatic GLboolean _glewInit_GL_NV_vertex_buffer_unified_memory (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBufferAddressRangeNV = (PFNGLBUFFERADDRESSRANGENVPROC)glewGetProcAddress((const GLubyte*)\"glBufferAddressRangeNV\")) == NULL) || r;\n  r = ((glColorFormatNV = (PFNGLCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glColorFormatNV\")) == NULL) || r;\n  r = ((glEdgeFlagFormatNV = (PFNGLEDGEFLAGFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glEdgeFlagFormatNV\")) == NULL) || r;\n  r = ((glFogCoordFormatNV = (PFNGLFOGCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glFogCoordFormatNV\")) == NULL) || r;\n  r = ((glGetIntegerui64i_vNV = (PFNGLGETINTEGERUI64I_VNVPROC)glewGetProcAddress((const GLubyte*)\"glGetIntegerui64i_vNV\")) == NULL) || r;\n  r = ((glIndexFormatNV = (PFNGLINDEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glIndexFormatNV\")) == NULL) || r;\n  r = ((glNormalFormatNV = (PFNGLNORMALFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glNormalFormatNV\")) == NULL) || r;\n  r = ((glSecondaryColorFormatNV = (PFNGLSECONDARYCOLORFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glSecondaryColorFormatNV\")) == NULL) || r;\n  r = ((glTexCoordFormatNV = (PFNGLTEXCOORDFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glTexCoordFormatNV\")) == NULL) || r;\n  r = ((glVertexAttribFormatNV = (PFNGLVERTEXATTRIBFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribFormatNV\")) == NULL) || r;\n  r = ((glVertexAttribIFormatNV = (PFNGLVERTEXATTRIBIFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribIFormatNV\")) == NULL) || r;\n  r = ((glVertexFormatNV = (PFNGLVERTEXFORMATNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexFormatNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_vertex_buffer_unified_memory */\n\n#ifdef GL_NV_vertex_program\n\nstatic GLboolean _glewInit_GL_NV_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAreProgramsResidentNV = (PFNGLAREPROGRAMSRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)\"glAreProgramsResidentNV\")) == NULL) || r;\n  r = ((glBindProgramNV = (PFNGLBINDPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)\"glBindProgramNV\")) == NULL) || r;\n  r = ((glDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)\"glDeleteProgramsNV\")) == NULL) || r;\n  r = ((glExecuteProgramNV = (PFNGLEXECUTEPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)\"glExecuteProgramNV\")) == NULL) || r;\n  r = ((glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)\"glGenProgramsNV\")) == NULL) || r;\n  r = ((glGetProgramParameterdvNV = (PFNGLGETPROGRAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramParameterdvNV\")) == NULL) || r;\n  r = ((glGetProgramParameterfvNV = (PFNGLGETPROGRAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramParameterfvNV\")) == NULL) || r;\n  r = ((glGetProgramStringNV = (PFNGLGETPROGRAMSTRINGNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramStringNV\")) == NULL) || r;\n  r = ((glGetProgramivNV = (PFNGLGETPROGRAMIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetProgramivNV\")) == NULL) || r;\n  r = ((glGetTrackMatrixivNV = (PFNGLGETTRACKMATRIXIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetTrackMatrixivNV\")) == NULL) || r;\n  r = ((glGetVertexAttribPointervNV = (PFNGLGETVERTEXATTRIBPOINTERVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribPointervNV\")) == NULL) || r;\n  r = ((glGetVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribdvNV\")) == NULL) || r;\n  r = ((glGetVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribfvNV\")) == NULL) || r;\n  r = ((glGetVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVertexAttribivNV\")) == NULL) || r;\n  r = ((glIsProgramNV = (PFNGLISPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)\"glIsProgramNV\")) == NULL) || r;\n  r = ((glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)\"glLoadProgramNV\")) == NULL) || r;\n  r = ((glProgramParameter4dNV = (PFNGLPROGRAMPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameter4dNV\")) == NULL) || r;\n  r = ((glProgramParameter4dvNV = (PFNGLPROGRAMPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameter4dvNV\")) == NULL) || r;\n  r = ((glProgramParameter4fNV = (PFNGLPROGRAMPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameter4fNV\")) == NULL) || r;\n  r = ((glProgramParameter4fvNV = (PFNGLPROGRAMPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameter4fvNV\")) == NULL) || r;\n  r = ((glProgramParameters4dvNV = (PFNGLPROGRAMPARAMETERS4DVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameters4dvNV\")) == NULL) || r;\n  r = ((glProgramParameters4fvNV = (PFNGLPROGRAMPARAMETERS4FVNVPROC)glewGetProcAddress((const GLubyte*)\"glProgramParameters4fvNV\")) == NULL) || r;\n  r = ((glRequestResidentProgramsNV = (PFNGLREQUESTRESIDENTPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)\"glRequestResidentProgramsNV\")) == NULL) || r;\n  r = ((glTrackMatrixNV = (PFNGLTRACKMATRIXNVPROC)glewGetProcAddress((const GLubyte*)\"glTrackMatrixNV\")) == NULL) || r;\n  r = ((glVertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1dNV\")) == NULL) || r;\n  r = ((glVertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1dvNV\")) == NULL) || r;\n  r = ((glVertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1fNV\")) == NULL) || r;\n  r = ((glVertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1fvNV\")) == NULL) || r;\n  r = ((glVertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1sNV\")) == NULL) || r;\n  r = ((glVertexAttrib1svNV = (PFNGLVERTEXATTRIB1SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib1svNV\")) == NULL) || r;\n  r = ((glVertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2dNV\")) == NULL) || r;\n  r = ((glVertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2dvNV\")) == NULL) || r;\n  r = ((glVertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2fNV\")) == NULL) || r;\n  r = ((glVertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2fvNV\")) == NULL) || r;\n  r = ((glVertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2sNV\")) == NULL) || r;\n  r = ((glVertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib2svNV\")) == NULL) || r;\n  r = ((glVertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3dNV\")) == NULL) || r;\n  r = ((glVertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3dvNV\")) == NULL) || r;\n  r = ((glVertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3fNV\")) == NULL) || r;\n  r = ((glVertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3fvNV\")) == NULL) || r;\n  r = ((glVertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3sNV\")) == NULL) || r;\n  r = ((glVertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib3svNV\")) == NULL) || r;\n  r = ((glVertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4dNV\")) == NULL) || r;\n  r = ((glVertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4dvNV\")) == NULL) || r;\n  r = ((glVertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4fNV\")) == NULL) || r;\n  r = ((glVertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4fvNV\")) == NULL) || r;\n  r = ((glVertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4sNV\")) == NULL) || r;\n  r = ((glVertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4svNV\")) == NULL) || r;\n  r = ((glVertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4ubNV\")) == NULL) || r;\n  r = ((glVertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttrib4ubvNV\")) == NULL) || r;\n  r = ((glVertexAttribPointerNV = (PFNGLVERTEXATTRIBPOINTERNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribPointerNV\")) == NULL) || r;\n  r = ((glVertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs1dvNV\")) == NULL) || r;\n  r = ((glVertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs1fvNV\")) == NULL) || r;\n  r = ((glVertexAttribs1svNV = (PFNGLVERTEXATTRIBS1SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs1svNV\")) == NULL) || r;\n  r = ((glVertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs2dvNV\")) == NULL) || r;\n  r = ((glVertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs2fvNV\")) == NULL) || r;\n  r = ((glVertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs2svNV\")) == NULL) || r;\n  r = ((glVertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs3dvNV\")) == NULL) || r;\n  r = ((glVertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs3fvNV\")) == NULL) || r;\n  r = ((glVertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs3svNV\")) == NULL) || r;\n  r = ((glVertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs4dvNV\")) == NULL) || r;\n  r = ((glVertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs4fvNV\")) == NULL) || r;\n  r = ((glVertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs4svNV\")) == NULL) || r;\n  r = ((glVertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC)glewGetProcAddress((const GLubyte*)\"glVertexAttribs4ubvNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_vertex_program */\n\n#ifdef GL_NV_vertex_program1_1\n\n#endif /* GL_NV_vertex_program1_1 */\n\n#ifdef GL_NV_vertex_program2\n\n#endif /* GL_NV_vertex_program2 */\n\n#ifdef GL_NV_vertex_program2_option\n\n#endif /* GL_NV_vertex_program2_option */\n\n#ifdef GL_NV_vertex_program3\n\n#endif /* GL_NV_vertex_program3 */\n\n#ifdef GL_NV_vertex_program4\n\n#endif /* GL_NV_vertex_program4 */\n\n#ifdef GL_NV_video_capture\n\nstatic GLboolean _glewInit_GL_NV_video_capture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glBeginVideoCaptureNV = (PFNGLBEGINVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)\"glBeginVideoCaptureNV\")) == NULL) || r;\n  r = ((glBindVideoCaptureStreamBufferNV = (PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC)glewGetProcAddress((const GLubyte*)\"glBindVideoCaptureStreamBufferNV\")) == NULL) || r;\n  r = ((glBindVideoCaptureStreamTextureNV = (PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC)glewGetProcAddress((const GLubyte*)\"glBindVideoCaptureStreamTextureNV\")) == NULL) || r;\n  r = ((glEndVideoCaptureNV = (PFNGLENDVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)\"glEndVideoCaptureNV\")) == NULL) || r;\n  r = ((glGetVideoCaptureStreamdvNV = (PFNGLGETVIDEOCAPTURESTREAMDVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoCaptureStreamdvNV\")) == NULL) || r;\n  r = ((glGetVideoCaptureStreamfvNV = (PFNGLGETVIDEOCAPTURESTREAMFVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoCaptureStreamfvNV\")) == NULL) || r;\n  r = ((glGetVideoCaptureStreamivNV = (PFNGLGETVIDEOCAPTURESTREAMIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoCaptureStreamivNV\")) == NULL) || r;\n  r = ((glGetVideoCaptureivNV = (PFNGLGETVIDEOCAPTUREIVNVPROC)glewGetProcAddress((const GLubyte*)\"glGetVideoCaptureivNV\")) == NULL) || r;\n  r = ((glVideoCaptureNV = (PFNGLVIDEOCAPTURENVPROC)glewGetProcAddress((const GLubyte*)\"glVideoCaptureNV\")) == NULL) || r;\n  r = ((glVideoCaptureStreamParameterdvNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)\"glVideoCaptureStreamParameterdvNV\")) == NULL) || r;\n  r = ((glVideoCaptureStreamParameterfvNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)\"glVideoCaptureStreamParameterfvNV\")) == NULL) || r;\n  r = ((glVideoCaptureStreamParameterivNV = (PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)\"glVideoCaptureStreamParameterivNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_NV_video_capture */\n\n#ifdef GL_OES_byte_coordinates\n\n#endif /* GL_OES_byte_coordinates */\n\n#ifdef GL_OES_compressed_paletted_texture\n\n#endif /* GL_OES_compressed_paletted_texture */\n\n#ifdef GL_OES_read_format\n\n#endif /* GL_OES_read_format */\n\n#ifdef GL_OES_single_precision\n\nstatic GLboolean _glewInit_GL_OES_single_precision (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glClearDepthfOES = (PFNGLCLEARDEPTHFOESPROC)glewGetProcAddress((const GLubyte*)\"glClearDepthfOES\")) == NULL) || r;\n  r = ((glClipPlanefOES = (PFNGLCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)\"glClipPlanefOES\")) == NULL) || r;\n  r = ((glDepthRangefOES = (PFNGLDEPTHRANGEFOESPROC)glewGetProcAddress((const GLubyte*)\"glDepthRangefOES\")) == NULL) || r;\n  r = ((glFrustumfOES = (PFNGLFRUSTUMFOESPROC)glewGetProcAddress((const GLubyte*)\"glFrustumfOES\")) == NULL) || r;\n  r = ((glGetClipPlanefOES = (PFNGLGETCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)\"glGetClipPlanefOES\")) == NULL) || r;\n  r = ((glOrthofOES = (PFNGLORTHOFOESPROC)glewGetProcAddress((const GLubyte*)\"glOrthofOES\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_OES_single_precision */\n\n#ifdef GL_OML_interlace\n\n#endif /* GL_OML_interlace */\n\n#ifdef GL_OML_resample\n\n#endif /* GL_OML_resample */\n\n#ifdef GL_OML_subsample\n\n#endif /* GL_OML_subsample */\n\n#ifdef GL_PGI_misc_hints\n\n#endif /* GL_PGI_misc_hints */\n\n#ifdef GL_PGI_vertex_hints\n\n#endif /* GL_PGI_vertex_hints */\n\n#ifdef GL_REGAL_error_string\n\nstatic GLboolean _glewInit_GL_REGAL_error_string (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glErrorStringREGAL = (PFNGLERRORSTRINGREGALPROC)glewGetProcAddress((const GLubyte*)\"glErrorStringREGAL\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_REGAL_error_string */\n\n#ifdef GL_REGAL_extension_query\n\nstatic GLboolean _glewInit_GL_REGAL_extension_query (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetExtensionREGAL = (PFNGLGETEXTENSIONREGALPROC)glewGetProcAddress((const GLubyte*)\"glGetExtensionREGAL\")) == NULL) || r;\n  r = ((glIsSupportedREGAL = (PFNGLISSUPPORTEDREGALPROC)glewGetProcAddress((const GLubyte*)\"glIsSupportedREGAL\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_REGAL_extension_query */\n\n#ifdef GL_REGAL_log\n\n#endif /* GL_REGAL_log */\n\n#ifdef GL_REND_screen_coordinates\n\n#endif /* GL_REND_screen_coordinates */\n\n#ifdef GL_S3_s3tc\n\n#endif /* GL_S3_s3tc */\n\n#ifdef GL_SGIS_color_range\n\n#endif /* GL_SGIS_color_range */\n\n#ifdef GL_SGIS_detail_texture\n\nstatic GLboolean _glewInit_GL_SGIS_detail_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glDetailTexFuncSGIS = (PFNGLDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glDetailTexFuncSGIS\")) == NULL) || r;\n  r = ((glGetDetailTexFuncSGIS = (PFNGLGETDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glGetDetailTexFuncSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_detail_texture */\n\n#ifdef GL_SGIS_fog_function\n\nstatic GLboolean _glewInit_GL_SGIS_fog_function (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFogFuncSGIS = (PFNGLFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glFogFuncSGIS\")) == NULL) || r;\n  r = ((glGetFogFuncSGIS = (PFNGLGETFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glGetFogFuncSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_fog_function */\n\n#ifdef GL_SGIS_generate_mipmap\n\n#endif /* GL_SGIS_generate_mipmap */\n\n#ifdef GL_SGIS_multisample\n\nstatic GLboolean _glewInit_GL_SGIS_multisample (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSampleMaskSGIS = (PFNGLSAMPLEMASKSGISPROC)glewGetProcAddress((const GLubyte*)\"glSampleMaskSGIS\")) == NULL) || r;\n  r = ((glSamplePatternSGIS = (PFNGLSAMPLEPATTERNSGISPROC)glewGetProcAddress((const GLubyte*)\"glSamplePatternSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_multisample */\n\n#ifdef GL_SGIS_pixel_texture\n\n#endif /* GL_SGIS_pixel_texture */\n\n#ifdef GL_SGIS_point_line_texgen\n\n#endif /* GL_SGIS_point_line_texgen */\n\n#ifdef GL_SGIS_sharpen_texture\n\nstatic GLboolean _glewInit_GL_SGIS_sharpen_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetSharpenTexFuncSGIS = (PFNGLGETSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glGetSharpenTexFuncSGIS\")) == NULL) || r;\n  r = ((glSharpenTexFuncSGIS = (PFNGLSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glSharpenTexFuncSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_sharpen_texture */\n\n#ifdef GL_SGIS_texture4D\n\nstatic GLboolean _glewInit_GL_SGIS_texture4D (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTexImage4DSGIS = (PFNGLTEXIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)\"glTexImage4DSGIS\")) == NULL) || r;\n  r = ((glTexSubImage4DSGIS = (PFNGLTEXSUBIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)\"glTexSubImage4DSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_texture4D */\n\n#ifdef GL_SGIS_texture_border_clamp\n\n#endif /* GL_SGIS_texture_border_clamp */\n\n#ifdef GL_SGIS_texture_edge_clamp\n\n#endif /* GL_SGIS_texture_edge_clamp */\n\n#ifdef GL_SGIS_texture_filter4\n\nstatic GLboolean _glewInit_GL_SGIS_texture_filter4 (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGetTexFilterFuncSGIS = (PFNGLGETTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glGetTexFilterFuncSGIS\")) == NULL) || r;\n  r = ((glTexFilterFuncSGIS = (PFNGLTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)\"glTexFilterFuncSGIS\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIS_texture_filter4 */\n\n#ifdef GL_SGIS_texture_lod\n\n#endif /* GL_SGIS_texture_lod */\n\n#ifdef GL_SGIS_texture_select\n\n#endif /* GL_SGIS_texture_select */\n\n#ifdef GL_SGIX_async\n\nstatic GLboolean _glewInit_GL_SGIX_async (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAsyncMarkerSGIX = (PFNGLASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glAsyncMarkerSGIX\")) == NULL) || r;\n  r = ((glDeleteAsyncMarkersSGIX = (PFNGLDELETEASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)\"glDeleteAsyncMarkersSGIX\")) == NULL) || r;\n  r = ((glFinishAsyncSGIX = (PFNGLFINISHASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFinishAsyncSGIX\")) == NULL) || r;\n  r = ((glGenAsyncMarkersSGIX = (PFNGLGENASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)\"glGenAsyncMarkersSGIX\")) == NULL) || r;\n  r = ((glIsAsyncMarkerSGIX = (PFNGLISASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glIsAsyncMarkerSGIX\")) == NULL) || r;\n  r = ((glPollAsyncSGIX = (PFNGLPOLLASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)\"glPollAsyncSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_async */\n\n#ifdef GL_SGIX_async_histogram\n\n#endif /* GL_SGIX_async_histogram */\n\n#ifdef GL_SGIX_async_pixel\n\n#endif /* GL_SGIX_async_pixel */\n\n#ifdef GL_SGIX_blend_alpha_minmax\n\n#endif /* GL_SGIX_blend_alpha_minmax */\n\n#ifdef GL_SGIX_clipmap\n\n#endif /* GL_SGIX_clipmap */\n\n#ifdef GL_SGIX_convolution_accuracy\n\n#endif /* GL_SGIX_convolution_accuracy */\n\n#ifdef GL_SGIX_depth_texture\n\n#endif /* GL_SGIX_depth_texture */\n\n#ifdef GL_SGIX_flush_raster\n\nstatic GLboolean _glewInit_GL_SGIX_flush_raster (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFlushRasterSGIX = (PFNGLFLUSHRASTERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFlushRasterSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_flush_raster */\n\n#ifdef GL_SGIX_fog_offset\n\n#endif /* GL_SGIX_fog_offset */\n\n#ifdef GL_SGIX_fog_texture\n\nstatic GLboolean _glewInit_GL_SGIX_fog_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTextureFogSGIX = (PFNGLTEXTUREFOGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glTextureFogSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_fog_texture */\n\n#ifdef GL_SGIX_fragment_specular_lighting\n\nstatic GLboolean _glewInit_GL_SGIX_fragment_specular_lighting (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFragmentColorMaterialSGIX = (PFNGLFRAGMENTCOLORMATERIALSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentColorMaterialSGIX\")) == NULL) || r;\n  r = ((glFragmentLightModelfSGIX = (PFNGLFRAGMENTLIGHTMODELFSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelfSGIX\")) == NULL) || r;\n  r = ((glFragmentLightModelfvSGIX = (PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelfvSGIX\")) == NULL) || r;\n  r = ((glFragmentLightModeliSGIX = (PFNGLFRAGMENTLIGHTMODELISGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModeliSGIX\")) == NULL) || r;\n  r = ((glFragmentLightModelivSGIX = (PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightModelivSGIX\")) == NULL) || r;\n  r = ((glFragmentLightfSGIX = (PFNGLFRAGMENTLIGHTFSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightfSGIX\")) == NULL) || r;\n  r = ((glFragmentLightfvSGIX = (PFNGLFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightfvSGIX\")) == NULL) || r;\n  r = ((glFragmentLightiSGIX = (PFNGLFRAGMENTLIGHTISGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightiSGIX\")) == NULL) || r;\n  r = ((glFragmentLightivSGIX = (PFNGLFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentLightivSGIX\")) == NULL) || r;\n  r = ((glFragmentMaterialfSGIX = (PFNGLFRAGMENTMATERIALFSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialfSGIX\")) == NULL) || r;\n  r = ((glFragmentMaterialfvSGIX = (PFNGLFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialfvSGIX\")) == NULL) || r;\n  r = ((glFragmentMaterialiSGIX = (PFNGLFRAGMENTMATERIALISGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialiSGIX\")) == NULL) || r;\n  r = ((glFragmentMaterialivSGIX = (PFNGLFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFragmentMaterialivSGIX\")) == NULL) || r;\n  r = ((glGetFragmentLightfvSGIX = (PFNGLGETFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentLightfvSGIX\")) == NULL) || r;\n  r = ((glGetFragmentLightivSGIX = (PFNGLGETFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentLightivSGIX\")) == NULL) || r;\n  r = ((glGetFragmentMaterialfvSGIX = (PFNGLGETFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentMaterialfvSGIX\")) == NULL) || r;\n  r = ((glGetFragmentMaterialivSGIX = (PFNGLGETFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glGetFragmentMaterialivSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_fragment_specular_lighting */\n\n#ifdef GL_SGIX_framezoom\n\nstatic GLboolean _glewInit_GL_SGIX_framezoom (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFrameZoomSGIX = (PFNGLFRAMEZOOMSGIXPROC)glewGetProcAddress((const GLubyte*)\"glFrameZoomSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_framezoom */\n\n#ifdef GL_SGIX_interlace\n\n#endif /* GL_SGIX_interlace */\n\n#ifdef GL_SGIX_ir_instrument1\n\n#endif /* GL_SGIX_ir_instrument1 */\n\n#ifdef GL_SGIX_list_priority\n\n#endif /* GL_SGIX_list_priority */\n\n#ifdef GL_SGIX_pixel_texture\n\nstatic GLboolean _glewInit_GL_SGIX_pixel_texture (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glPixelTexGenSGIX = (PFNGLPIXELTEXGENSGIXPROC)glewGetProcAddress((const GLubyte*)\"glPixelTexGenSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_pixel_texture */\n\n#ifdef GL_SGIX_pixel_texture_bits\n\n#endif /* GL_SGIX_pixel_texture_bits */\n\n#ifdef GL_SGIX_reference_plane\n\nstatic GLboolean _glewInit_GL_SGIX_reference_plane (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glReferencePlaneSGIX = (PFNGLREFERENCEPLANESGIXPROC)glewGetProcAddress((const GLubyte*)\"glReferencePlaneSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_reference_plane */\n\n#ifdef GL_SGIX_resample\n\n#endif /* GL_SGIX_resample */\n\n#ifdef GL_SGIX_shadow\n\n#endif /* GL_SGIX_shadow */\n\n#ifdef GL_SGIX_shadow_ambient\n\n#endif /* GL_SGIX_shadow_ambient */\n\n#ifdef GL_SGIX_sprite\n\nstatic GLboolean _glewInit_GL_SGIX_sprite (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glSpriteParameterfSGIX = (PFNGLSPRITEPARAMETERFSGIXPROC)glewGetProcAddress((const GLubyte*)\"glSpriteParameterfSGIX\")) == NULL) || r;\n  r = ((glSpriteParameterfvSGIX = (PFNGLSPRITEPARAMETERFVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glSpriteParameterfvSGIX\")) == NULL) || r;\n  r = ((glSpriteParameteriSGIX = (PFNGLSPRITEPARAMETERISGIXPROC)glewGetProcAddress((const GLubyte*)\"glSpriteParameteriSGIX\")) == NULL) || r;\n  r = ((glSpriteParameterivSGIX = (PFNGLSPRITEPARAMETERIVSGIXPROC)glewGetProcAddress((const GLubyte*)\"glSpriteParameterivSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_sprite */\n\n#ifdef GL_SGIX_tag_sample_buffer\n\nstatic GLboolean _glewInit_GL_SGIX_tag_sample_buffer (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glTagSampleBufferSGIX = (PFNGLTAGSAMPLEBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glTagSampleBufferSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGIX_tag_sample_buffer */\n\n#ifdef GL_SGIX_texture_add_env\n\n#endif /* GL_SGIX_texture_add_env */\n\n#ifdef GL_SGIX_texture_coordinate_clamp\n\n#endif /* GL_SGIX_texture_coordinate_clamp */\n\n#ifdef GL_SGIX_texture_lod_bias\n\n#endif /* GL_SGIX_texture_lod_bias */\n\n#ifdef GL_SGIX_texture_multi_buffer\n\n#endif /* GL_SGIX_texture_multi_buffer */\n\n#ifdef GL_SGIX_texture_range\n\n#endif /* GL_SGIX_texture_range */\n\n#ifdef GL_SGIX_texture_scale_bias\n\n#endif /* GL_SGIX_texture_scale_bias */\n\n#ifdef GL_SGIX_vertex_preclip\n\n#endif /* GL_SGIX_vertex_preclip */\n\n#ifdef GL_SGIX_vertex_preclip_hint\n\n#endif /* GL_SGIX_vertex_preclip_hint */\n\n#ifdef GL_SGIX_ycrcb\n\n#endif /* GL_SGIX_ycrcb */\n\n#ifdef GL_SGI_color_matrix\n\n#endif /* GL_SGI_color_matrix */\n\n#ifdef GL_SGI_color_table\n\nstatic GLboolean _glewInit_GL_SGI_color_table (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColorTableParameterfvSGI = (PFNGLCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)\"glColorTableParameterfvSGI\")) == NULL) || r;\n  r = ((glColorTableParameterivSGI = (PFNGLCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)\"glColorTableParameterivSGI\")) == NULL) || r;\n  r = ((glColorTableSGI = (PFNGLCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)\"glColorTableSGI\")) == NULL) || r;\n  r = ((glCopyColorTableSGI = (PFNGLCOPYCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)\"glCopyColorTableSGI\")) == NULL) || r;\n  r = ((glGetColorTableParameterfvSGI = (PFNGLGETCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameterfvSGI\")) == NULL) || r;\n  r = ((glGetColorTableParameterivSGI = (PFNGLGETCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableParameterivSGI\")) == NULL) || r;\n  r = ((glGetColorTableSGI = (PFNGLGETCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)\"glGetColorTableSGI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SGI_color_table */\n\n#ifdef GL_SGI_texture_color_table\n\n#endif /* GL_SGI_texture_color_table */\n\n#ifdef GL_SUNX_constant_data\n\nstatic GLboolean _glewInit_GL_SUNX_constant_data (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glFinishTextureSUNX = (PFNGLFINISHTEXTURESUNXPROC)glewGetProcAddress((const GLubyte*)\"glFinishTextureSUNX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SUNX_constant_data */\n\n#ifdef GL_SUN_convolution_border_modes\n\n#endif /* GL_SUN_convolution_border_modes */\n\n#ifdef GL_SUN_global_alpha\n\nstatic GLboolean _glewInit_GL_SUN_global_alpha (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glGlobalAlphaFactorbSUN = (PFNGLGLOBALALPHAFACTORBSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactorbSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactordSUN = (PFNGLGLOBALALPHAFACTORDSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactordSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactorfSUN = (PFNGLGLOBALALPHAFACTORFSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactorfSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactoriSUN = (PFNGLGLOBALALPHAFACTORISUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactoriSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactorsSUN = (PFNGLGLOBALALPHAFACTORSSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactorsSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactorubSUN = (PFNGLGLOBALALPHAFACTORUBSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactorubSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactoruiSUN = (PFNGLGLOBALALPHAFACTORUISUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactoruiSUN\")) == NULL) || r;\n  r = ((glGlobalAlphaFactorusSUN = (PFNGLGLOBALALPHAFACTORUSSUNPROC)glewGetProcAddress((const GLubyte*)\"glGlobalAlphaFactorusSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SUN_global_alpha */\n\n#ifdef GL_SUN_mesh_array\n\n#endif /* GL_SUN_mesh_array */\n\n#ifdef GL_SUN_read_video_pixels\n\nstatic GLboolean _glewInit_GL_SUN_read_video_pixels (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glReadVideoPixelsSUN = (PFNGLREADVIDEOPIXELSSUNPROC)glewGetProcAddress((const GLubyte*)\"glReadVideoPixelsSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SUN_read_video_pixels */\n\n#ifdef GL_SUN_slice_accum\n\n#endif /* GL_SUN_slice_accum */\n\n#ifdef GL_SUN_triangle_list\n\nstatic GLboolean _glewInit_GL_SUN_triangle_list (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glReplacementCodePointerSUN = (PFNGLREPLACEMENTCODEPOINTERSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodePointerSUN\")) == NULL) || r;\n  r = ((glReplacementCodeubSUN = (PFNGLREPLACEMENTCODEUBSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeubSUN\")) == NULL) || r;\n  r = ((glReplacementCodeubvSUN = (PFNGLREPLACEMENTCODEUBVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeubvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiSUN = (PFNGLREPLACEMENTCODEUISUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuivSUN = (PFNGLREPLACEMENTCODEUIVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuivSUN\")) == NULL) || r;\n  r = ((glReplacementCodeusSUN = (PFNGLREPLACEMENTCODEUSSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeusSUN\")) == NULL) || r;\n  r = ((glReplacementCodeusvSUN = (PFNGLREPLACEMENTCODEUSVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeusvSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SUN_triangle_list */\n\n#ifdef GL_SUN_vertex\n\nstatic GLboolean _glewInit_GL_SUN_vertex (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glColor3fVertex3fSUN = (PFNGLCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor3fVertex3fSUN\")) == NULL) || r;\n  r = ((glColor3fVertex3fvSUN = (PFNGLCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glColor4fNormal3fVertex3fSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glColor4fNormal3fVertex3fvSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glColor4ubVertex2fSUN = (PFNGLCOLOR4UBVERTEX2FSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4ubVertex2fSUN\")) == NULL) || r;\n  r = ((glColor4ubVertex2fvSUN = (PFNGLCOLOR4UBVERTEX2FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4ubVertex2fvSUN\")) == NULL) || r;\n  r = ((glColor4ubVertex3fSUN = (PFNGLCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4ubVertex3fSUN\")) == NULL) || r;\n  r = ((glColor4ubVertex3fvSUN = (PFNGLCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glColor4ubVertex3fvSUN\")) == NULL) || r;\n  r = ((glNormal3fVertex3fSUN = (PFNGLNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glNormal3fVertex3fvSUN = (PFNGLNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor3fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor4fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor4fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor4ubVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor4ubVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiColor4ubVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiColor4ubVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiTexCoord2fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiTexCoord2fVertex3fvSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiVertex3fSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiVertex3fSUN\")) == NULL) || r;\n  r = ((glReplacementCodeuiVertex3fvSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glReplacementCodeuiVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor3fVertex3fSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor4fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor4fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor4ubVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor4ubVertex3fSUN\")) == NULL) || r;\n  r = ((glTexCoord2fColor4ubVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fColor4ubVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord2fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fNormal3fVertex3fSUN\")) == NULL) || r;\n  r = ((glTexCoord2fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fNormal3fVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord2fVertex3fSUN = (PFNGLTEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fVertex3fSUN\")) == NULL) || r;\n  r = ((glTexCoord2fVertex3fvSUN = (PFNGLTEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord2fVertex3fvSUN\")) == NULL) || r;\n  r = ((glTexCoord4fColor4fNormal3fVertex4fSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4fColor4fNormal3fVertex4fSUN\")) == NULL) || r;\n  r = ((glTexCoord4fColor4fNormal3fVertex4fvSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4fColor4fNormal3fVertex4fvSUN\")) == NULL) || r;\n  r = ((glTexCoord4fVertex4fSUN = (PFNGLTEXCOORD4FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4fVertex4fSUN\")) == NULL) || r;\n  r = ((glTexCoord4fVertex4fvSUN = (PFNGLTEXCOORD4FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)\"glTexCoord4fVertex4fvSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_SUN_vertex */\n\n#ifdef GL_WIN_phong_shading\n\n#endif /* GL_WIN_phong_shading */\n\n#ifdef GL_WIN_specular_fog\n\n#endif /* GL_WIN_specular_fog */\n\n#ifdef GL_WIN_swap_hint\n\nstatic GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glAddSwapHintRectWIN = (PFNGLADDSWAPHINTRECTWINPROC)glewGetProcAddress((const GLubyte*)\"glAddSwapHintRectWIN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GL_WIN_swap_hint */\n\n/* ------------------------------------------------------------------------- */\n\nGLboolean GLEWAPIENTRY glewGetExtension (const char* name)\n{    \n  const GLubyte* start;\n  const GLubyte* end;\n  start = (const GLubyte*)glGetString(GL_EXTENSIONS);\n  if (start == 0)\n    return GL_FALSE;\n  end = start + _glewStrLen(start);\n  return _glewSearchExtension(name, start, end);\n}\n\n/* ------------------------------------------------------------------------- */\n\n#ifndef GLEW_MX\nstatic\n#endif\nGLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)\n{\n  const GLubyte* s;\n  GLuint dot;\n  GLint major, minor;\n  const GLubyte* extStart;\n  const GLubyte* extEnd;\n  /* query opengl version */\n  s = glGetString(GL_VERSION);\n  dot = _glewStrCLen(s, '.');\n  if (dot == 0)\n    return GLEW_ERROR_NO_GL_VERSION;\n  \n  major = s[dot-1]-'0';\n  minor = s[dot+1]-'0';\n\n  if (minor < 0 || minor > 9)\n    minor = 0;\n  if (major<0 || major>9)\n    return GLEW_ERROR_NO_GL_VERSION;\n  \n\n  if (major == 1 && minor == 0)\n  {\n    return GLEW_ERROR_GL_VERSION_10_ONLY;\n  }\n  else\n  {\n    CONST_CAST(GLEW_VERSION_4_3)   = ( major > 4 )                 || ( major == 4 && minor >= 3 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_4_2)   = GLEW_VERSION_4_3   == GL_TRUE || ( major == 4 && minor >= 2 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_4_1)   = GLEW_VERSION_4_2   == GL_TRUE || ( major == 4 && minor >= 1 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_4_0)   = GLEW_VERSION_4_1   == GL_TRUE || ( major == 4               ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_3_3)   = GLEW_VERSION_4_0   == GL_TRUE || ( major == 3 && minor >= 3 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_3_2)   = GLEW_VERSION_3_3   == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_3_1)   = GLEW_VERSION_3_2   == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_3_0)   = GLEW_VERSION_3_1   == GL_TRUE || ( major == 3               ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_2_1)   = GLEW_VERSION_3_0   == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;    \n    CONST_CAST(GLEW_VERSION_2_0)   = GLEW_VERSION_2_1   == GL_TRUE || ( major == 2               ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_1_5)   = GLEW_VERSION_2_0   == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_1_4)   = GLEW_VERSION_1_5   == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_1_3)   = GLEW_VERSION_1_4   == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_1_2_1) = GLEW_VERSION_1_3   == GL_TRUE                                 ? GL_TRUE : GL_FALSE; \n    CONST_CAST(GLEW_VERSION_1_2)   = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;\n    CONST_CAST(GLEW_VERSION_1_1)   = GLEW_VERSION_1_2   == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;\n  }\n\n  /* query opengl extensions string */\n  extStart = glGetString(GL_EXTENSIONS);\n  if (extStart == 0)\n    extStart = (const GLubyte*)\"\";\n  extEnd = extStart + _glewStrLen(extStart);\n\n  /* initialize extensions */\n#ifdef GL_VERSION_1_2\n  if (glewExperimental || GLEW_VERSION_1_2) CONST_CAST(GLEW_VERSION_1_2) = !_glewInit_GL_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_1_2 */\n#ifdef GL_VERSION_1_2_1\n#endif /* GL_VERSION_1_2_1 */\n#ifdef GL_VERSION_1_3\n  if (glewExperimental || GLEW_VERSION_1_3) CONST_CAST(GLEW_VERSION_1_3) = !_glewInit_GL_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_1_3 */\n#ifdef GL_VERSION_1_4\n  if (glewExperimental || GLEW_VERSION_1_4) CONST_CAST(GLEW_VERSION_1_4) = !_glewInit_GL_VERSION_1_4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_1_4 */\n#ifdef GL_VERSION_1_5\n  if (glewExperimental || GLEW_VERSION_1_5) CONST_CAST(GLEW_VERSION_1_5) = !_glewInit_GL_VERSION_1_5(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_1_5 */\n#ifdef GL_VERSION_2_0\n  if (glewExperimental || GLEW_VERSION_2_0) CONST_CAST(GLEW_VERSION_2_0) = !_glewInit_GL_VERSION_2_0(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_2_0 */\n#ifdef GL_VERSION_2_1\n  if (glewExperimental || GLEW_VERSION_2_1) CONST_CAST(GLEW_VERSION_2_1) = !_glewInit_GL_VERSION_2_1(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_2_1 */\n#ifdef GL_VERSION_3_0\n  if (glewExperimental || GLEW_VERSION_3_0) CONST_CAST(GLEW_VERSION_3_0) = !_glewInit_GL_VERSION_3_0(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_3_0 */\n#ifdef GL_VERSION_3_1\n  if (glewExperimental || GLEW_VERSION_3_1) CONST_CAST(GLEW_VERSION_3_1) = !_glewInit_GL_VERSION_3_1(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_3_1 */\n#ifdef GL_VERSION_3_2\n  if (glewExperimental || GLEW_VERSION_3_2) CONST_CAST(GLEW_VERSION_3_2) = !_glewInit_GL_VERSION_3_2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_3_2 */\n#ifdef GL_VERSION_3_3\n  if (glewExperimental || GLEW_VERSION_3_3) CONST_CAST(GLEW_VERSION_3_3) = !_glewInit_GL_VERSION_3_3(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_3_3 */\n#ifdef GL_VERSION_4_0\n  if (glewExperimental || GLEW_VERSION_4_0) CONST_CAST(GLEW_VERSION_4_0) = !_glewInit_GL_VERSION_4_0(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_VERSION_4_0 */\n#ifdef GL_VERSION_4_1\n#endif /* GL_VERSION_4_1 */\n#ifdef GL_VERSION_4_2\n#endif /* GL_VERSION_4_2 */\n#ifdef GL_VERSION_4_3\n#endif /* GL_VERSION_4_3 */\n#ifdef GL_3DFX_multisample\n  CONST_CAST(GLEW_3DFX_multisample) = _glewSearchExtension(\"GL_3DFX_multisample\", extStart, extEnd);\n#endif /* GL_3DFX_multisample */\n#ifdef GL_3DFX_tbuffer\n  CONST_CAST(GLEW_3DFX_tbuffer) = _glewSearchExtension(\"GL_3DFX_tbuffer\", extStart, extEnd);\n  if (glewExperimental || GLEW_3DFX_tbuffer) CONST_CAST(GLEW_3DFX_tbuffer) = !_glewInit_GL_3DFX_tbuffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_3DFX_tbuffer */\n#ifdef GL_3DFX_texture_compression_FXT1\n  CONST_CAST(GLEW_3DFX_texture_compression_FXT1) = _glewSearchExtension(\"GL_3DFX_texture_compression_FXT1\", extStart, extEnd);\n#endif /* GL_3DFX_texture_compression_FXT1 */\n#ifdef GL_AMD_blend_minmax_factor\n  CONST_CAST(GLEW_AMD_blend_minmax_factor) = _glewSearchExtension(\"GL_AMD_blend_minmax_factor\", extStart, extEnd);\n#endif /* GL_AMD_blend_minmax_factor */\n#ifdef GL_AMD_conservative_depth\n  CONST_CAST(GLEW_AMD_conservative_depth) = _glewSearchExtension(\"GL_AMD_conservative_depth\", extStart, extEnd);\n#endif /* GL_AMD_conservative_depth */\n#ifdef GL_AMD_debug_output\n  CONST_CAST(GLEW_AMD_debug_output) = _glewSearchExtension(\"GL_AMD_debug_output\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_debug_output) CONST_CAST(GLEW_AMD_debug_output) = !_glewInit_GL_AMD_debug_output(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_debug_output */\n#ifdef GL_AMD_depth_clamp_separate\n  CONST_CAST(GLEW_AMD_depth_clamp_separate) = _glewSearchExtension(\"GL_AMD_depth_clamp_separate\", extStart, extEnd);\n#endif /* GL_AMD_depth_clamp_separate */\n#ifdef GL_AMD_draw_buffers_blend\n  CONST_CAST(GLEW_AMD_draw_buffers_blend) = _glewSearchExtension(\"GL_AMD_draw_buffers_blend\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_draw_buffers_blend) CONST_CAST(GLEW_AMD_draw_buffers_blend) = !_glewInit_GL_AMD_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_draw_buffers_blend */\n#ifdef GL_AMD_multi_draw_indirect\n  CONST_CAST(GLEW_AMD_multi_draw_indirect) = _glewSearchExtension(\"GL_AMD_multi_draw_indirect\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_multi_draw_indirect) CONST_CAST(GLEW_AMD_multi_draw_indirect) = !_glewInit_GL_AMD_multi_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_multi_draw_indirect */\n#ifdef GL_AMD_name_gen_delete\n  CONST_CAST(GLEW_AMD_name_gen_delete) = _glewSearchExtension(\"GL_AMD_name_gen_delete\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_name_gen_delete) CONST_CAST(GLEW_AMD_name_gen_delete) = !_glewInit_GL_AMD_name_gen_delete(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_name_gen_delete */\n#ifdef GL_AMD_performance_monitor\n  CONST_CAST(GLEW_AMD_performance_monitor) = _glewSearchExtension(\"GL_AMD_performance_monitor\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_performance_monitor) CONST_CAST(GLEW_AMD_performance_monitor) = !_glewInit_GL_AMD_performance_monitor(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_performance_monitor */\n#ifdef GL_AMD_pinned_memory\n  CONST_CAST(GLEW_AMD_pinned_memory) = _glewSearchExtension(\"GL_AMD_pinned_memory\", extStart, extEnd);\n#endif /* GL_AMD_pinned_memory */\n#ifdef GL_AMD_query_buffer_object\n  CONST_CAST(GLEW_AMD_query_buffer_object) = _glewSearchExtension(\"GL_AMD_query_buffer_object\", extStart, extEnd);\n#endif /* GL_AMD_query_buffer_object */\n#ifdef GL_AMD_sample_positions\n  CONST_CAST(GLEW_AMD_sample_positions) = _glewSearchExtension(\"GL_AMD_sample_positions\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_sample_positions) CONST_CAST(GLEW_AMD_sample_positions) = !_glewInit_GL_AMD_sample_positions(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_sample_positions */\n#ifdef GL_AMD_seamless_cubemap_per_texture\n  CONST_CAST(GLEW_AMD_seamless_cubemap_per_texture) = _glewSearchExtension(\"GL_AMD_seamless_cubemap_per_texture\", extStart, extEnd);\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n#ifdef GL_AMD_shader_stencil_export\n  CONST_CAST(GLEW_AMD_shader_stencil_export) = _glewSearchExtension(\"GL_AMD_shader_stencil_export\", extStart, extEnd);\n#endif /* GL_AMD_shader_stencil_export */\n#ifdef GL_AMD_stencil_operation_extended\n  CONST_CAST(GLEW_AMD_stencil_operation_extended) = _glewSearchExtension(\"GL_AMD_stencil_operation_extended\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_stencil_operation_extended) CONST_CAST(GLEW_AMD_stencil_operation_extended) = !_glewInit_GL_AMD_stencil_operation_extended(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_stencil_operation_extended */\n#ifdef GL_AMD_texture_texture4\n  CONST_CAST(GLEW_AMD_texture_texture4) = _glewSearchExtension(\"GL_AMD_texture_texture4\", extStart, extEnd);\n#endif /* GL_AMD_texture_texture4 */\n#ifdef GL_AMD_transform_feedback3_lines_triangles\n  CONST_CAST(GLEW_AMD_transform_feedback3_lines_triangles) = _glewSearchExtension(\"GL_AMD_transform_feedback3_lines_triangles\", extStart, extEnd);\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n#ifdef GL_AMD_vertex_shader_layer\n  CONST_CAST(GLEW_AMD_vertex_shader_layer) = _glewSearchExtension(\"GL_AMD_vertex_shader_layer\", extStart, extEnd);\n#endif /* GL_AMD_vertex_shader_layer */\n#ifdef GL_AMD_vertex_shader_tessellator\n  CONST_CAST(GLEW_AMD_vertex_shader_tessellator) = _glewSearchExtension(\"GL_AMD_vertex_shader_tessellator\", extStart, extEnd);\n  if (glewExperimental || GLEW_AMD_vertex_shader_tessellator) CONST_CAST(GLEW_AMD_vertex_shader_tessellator) = !_glewInit_GL_AMD_vertex_shader_tessellator(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_AMD_vertex_shader_tessellator */\n#ifdef GL_AMD_vertex_shader_viewport_index\n  CONST_CAST(GLEW_AMD_vertex_shader_viewport_index) = _glewSearchExtension(\"GL_AMD_vertex_shader_viewport_index\", extStart, extEnd);\n#endif /* GL_AMD_vertex_shader_viewport_index */\n#ifdef GL_APPLE_aux_depth_stencil\n  CONST_CAST(GLEW_APPLE_aux_depth_stencil) = _glewSearchExtension(\"GL_APPLE_aux_depth_stencil\", extStart, extEnd);\n#endif /* GL_APPLE_aux_depth_stencil */\n#ifdef GL_APPLE_client_storage\n  CONST_CAST(GLEW_APPLE_client_storage) = _glewSearchExtension(\"GL_APPLE_client_storage\", extStart, extEnd);\n#endif /* GL_APPLE_client_storage */\n#ifdef GL_APPLE_element_array\n  CONST_CAST(GLEW_APPLE_element_array) = _glewSearchExtension(\"GL_APPLE_element_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_element_array) CONST_CAST(GLEW_APPLE_element_array) = !_glewInit_GL_APPLE_element_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_element_array */\n#ifdef GL_APPLE_fence\n  CONST_CAST(GLEW_APPLE_fence) = _glewSearchExtension(\"GL_APPLE_fence\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_fence) CONST_CAST(GLEW_APPLE_fence) = !_glewInit_GL_APPLE_fence(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_fence */\n#ifdef GL_APPLE_float_pixels\n  CONST_CAST(GLEW_APPLE_float_pixels) = _glewSearchExtension(\"GL_APPLE_float_pixels\", extStart, extEnd);\n#endif /* GL_APPLE_float_pixels */\n#ifdef GL_APPLE_flush_buffer_range\n  CONST_CAST(GLEW_APPLE_flush_buffer_range) = _glewSearchExtension(\"GL_APPLE_flush_buffer_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_flush_buffer_range) CONST_CAST(GLEW_APPLE_flush_buffer_range) = !_glewInit_GL_APPLE_flush_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_flush_buffer_range */\n#ifdef GL_APPLE_object_purgeable\n  CONST_CAST(GLEW_APPLE_object_purgeable) = _glewSearchExtension(\"GL_APPLE_object_purgeable\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_object_purgeable) CONST_CAST(GLEW_APPLE_object_purgeable) = !_glewInit_GL_APPLE_object_purgeable(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_object_purgeable */\n#ifdef GL_APPLE_pixel_buffer\n  CONST_CAST(GLEW_APPLE_pixel_buffer) = _glewSearchExtension(\"GL_APPLE_pixel_buffer\", extStart, extEnd);\n#endif /* GL_APPLE_pixel_buffer */\n#ifdef GL_APPLE_rgb_422\n  CONST_CAST(GLEW_APPLE_rgb_422) = _glewSearchExtension(\"GL_APPLE_rgb_422\", extStart, extEnd);\n#endif /* GL_APPLE_rgb_422 */\n#ifdef GL_APPLE_row_bytes\n  CONST_CAST(GLEW_APPLE_row_bytes) = _glewSearchExtension(\"GL_APPLE_row_bytes\", extStart, extEnd);\n#endif /* GL_APPLE_row_bytes */\n#ifdef GL_APPLE_specular_vector\n  CONST_CAST(GLEW_APPLE_specular_vector) = _glewSearchExtension(\"GL_APPLE_specular_vector\", extStart, extEnd);\n#endif /* GL_APPLE_specular_vector */\n#ifdef GL_APPLE_texture_range\n  CONST_CAST(GLEW_APPLE_texture_range) = _glewSearchExtension(\"GL_APPLE_texture_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_texture_range) CONST_CAST(GLEW_APPLE_texture_range) = !_glewInit_GL_APPLE_texture_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_texture_range */\n#ifdef GL_APPLE_transform_hint\n  CONST_CAST(GLEW_APPLE_transform_hint) = _glewSearchExtension(\"GL_APPLE_transform_hint\", extStart, extEnd);\n#endif /* GL_APPLE_transform_hint */\n#ifdef GL_APPLE_vertex_array_object\n  CONST_CAST(GLEW_APPLE_vertex_array_object) = _glewSearchExtension(\"GL_APPLE_vertex_array_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_vertex_array_object) CONST_CAST(GLEW_APPLE_vertex_array_object) = !_glewInit_GL_APPLE_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_vertex_array_object */\n#ifdef GL_APPLE_vertex_array_range\n  CONST_CAST(GLEW_APPLE_vertex_array_range) = _glewSearchExtension(\"GL_APPLE_vertex_array_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_vertex_array_range) CONST_CAST(GLEW_APPLE_vertex_array_range) = !_glewInit_GL_APPLE_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_vertex_array_range */\n#ifdef GL_APPLE_vertex_program_evaluators\n  CONST_CAST(GLEW_APPLE_vertex_program_evaluators) = _glewSearchExtension(\"GL_APPLE_vertex_program_evaluators\", extStart, extEnd);\n  if (glewExperimental || GLEW_APPLE_vertex_program_evaluators) CONST_CAST(GLEW_APPLE_vertex_program_evaluators) = !_glewInit_GL_APPLE_vertex_program_evaluators(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_APPLE_vertex_program_evaluators */\n#ifdef GL_APPLE_ycbcr_422\n  CONST_CAST(GLEW_APPLE_ycbcr_422) = _glewSearchExtension(\"GL_APPLE_ycbcr_422\", extStart, extEnd);\n#endif /* GL_APPLE_ycbcr_422 */\n#ifdef GL_ARB_ES2_compatibility\n  CONST_CAST(GLEW_ARB_ES2_compatibility) = _glewSearchExtension(\"GL_ARB_ES2_compatibility\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_ES2_compatibility) CONST_CAST(GLEW_ARB_ES2_compatibility) = !_glewInit_GL_ARB_ES2_compatibility(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_ES2_compatibility */\n#ifdef GL_ARB_ES3_compatibility\n  CONST_CAST(GLEW_ARB_ES3_compatibility) = _glewSearchExtension(\"GL_ARB_ES3_compatibility\", extStart, extEnd);\n#endif /* GL_ARB_ES3_compatibility */\n#ifdef GL_ARB_arrays_of_arrays\n  CONST_CAST(GLEW_ARB_arrays_of_arrays) = _glewSearchExtension(\"GL_ARB_arrays_of_arrays\", extStart, extEnd);\n#endif /* GL_ARB_arrays_of_arrays */\n#ifdef GL_ARB_base_instance\n  CONST_CAST(GLEW_ARB_base_instance) = _glewSearchExtension(\"GL_ARB_base_instance\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_base_instance) CONST_CAST(GLEW_ARB_base_instance) = !_glewInit_GL_ARB_base_instance(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_base_instance */\n#ifdef GL_ARB_blend_func_extended\n  CONST_CAST(GLEW_ARB_blend_func_extended) = _glewSearchExtension(\"GL_ARB_blend_func_extended\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_blend_func_extended) CONST_CAST(GLEW_ARB_blend_func_extended) = !_glewInit_GL_ARB_blend_func_extended(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_blend_func_extended */\n#ifdef GL_ARB_cl_event\n  CONST_CAST(GLEW_ARB_cl_event) = _glewSearchExtension(\"GL_ARB_cl_event\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_cl_event) CONST_CAST(GLEW_ARB_cl_event) = !_glewInit_GL_ARB_cl_event(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_cl_event */\n#ifdef GL_ARB_clear_buffer_object\n  CONST_CAST(GLEW_ARB_clear_buffer_object) = _glewSearchExtension(\"GL_ARB_clear_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_clear_buffer_object) CONST_CAST(GLEW_ARB_clear_buffer_object) = !_glewInit_GL_ARB_clear_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_clear_buffer_object */\n#ifdef GL_ARB_color_buffer_float\n  CONST_CAST(GLEW_ARB_color_buffer_float) = _glewSearchExtension(\"GL_ARB_color_buffer_float\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_color_buffer_float) CONST_CAST(GLEW_ARB_color_buffer_float) = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_color_buffer_float */\n#ifdef GL_ARB_compatibility\n  CONST_CAST(GLEW_ARB_compatibility) = _glewSearchExtension(\"GL_ARB_compatibility\", extStart, extEnd);\n#endif /* GL_ARB_compatibility */\n#ifdef GL_ARB_compressed_texture_pixel_storage\n  CONST_CAST(GLEW_ARB_compressed_texture_pixel_storage) = _glewSearchExtension(\"GL_ARB_compressed_texture_pixel_storage\", extStart, extEnd);\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n#ifdef GL_ARB_compute_shader\n  CONST_CAST(GLEW_ARB_compute_shader) = _glewSearchExtension(\"GL_ARB_compute_shader\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_compute_shader) CONST_CAST(GLEW_ARB_compute_shader) = !_glewInit_GL_ARB_compute_shader(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_compute_shader */\n#ifdef GL_ARB_conservative_depth\n  CONST_CAST(GLEW_ARB_conservative_depth) = _glewSearchExtension(\"GL_ARB_conservative_depth\", extStart, extEnd);\n#endif /* GL_ARB_conservative_depth */\n#ifdef GL_ARB_copy_buffer\n  CONST_CAST(GLEW_ARB_copy_buffer) = _glewSearchExtension(\"GL_ARB_copy_buffer\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_copy_buffer) CONST_CAST(GLEW_ARB_copy_buffer) = !_glewInit_GL_ARB_copy_buffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_copy_buffer */\n#ifdef GL_ARB_copy_image\n  CONST_CAST(GLEW_ARB_copy_image) = _glewSearchExtension(\"GL_ARB_copy_image\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_copy_image) CONST_CAST(GLEW_ARB_copy_image) = !_glewInit_GL_ARB_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_copy_image */\n#ifdef GL_ARB_debug_output\n  CONST_CAST(GLEW_ARB_debug_output) = _glewSearchExtension(\"GL_ARB_debug_output\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_debug_output) CONST_CAST(GLEW_ARB_debug_output) = !_glewInit_GL_ARB_debug_output(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_debug_output */\n#ifdef GL_ARB_depth_buffer_float\n  CONST_CAST(GLEW_ARB_depth_buffer_float) = _glewSearchExtension(\"GL_ARB_depth_buffer_float\", extStart, extEnd);\n#endif /* GL_ARB_depth_buffer_float */\n#ifdef GL_ARB_depth_clamp\n  CONST_CAST(GLEW_ARB_depth_clamp) = _glewSearchExtension(\"GL_ARB_depth_clamp\", extStart, extEnd);\n#endif /* GL_ARB_depth_clamp */\n#ifdef GL_ARB_depth_texture\n  CONST_CAST(GLEW_ARB_depth_texture) = _glewSearchExtension(\"GL_ARB_depth_texture\", extStart, extEnd);\n#endif /* GL_ARB_depth_texture */\n#ifdef GL_ARB_draw_buffers\n  CONST_CAST(GLEW_ARB_draw_buffers) = _glewSearchExtension(\"GL_ARB_draw_buffers\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_draw_buffers) CONST_CAST(GLEW_ARB_draw_buffers) = !_glewInit_GL_ARB_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_draw_buffers */\n#ifdef GL_ARB_draw_buffers_blend\n  CONST_CAST(GLEW_ARB_draw_buffers_blend) = _glewSearchExtension(\"GL_ARB_draw_buffers_blend\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_draw_buffers_blend) CONST_CAST(GLEW_ARB_draw_buffers_blend) = !_glewInit_GL_ARB_draw_buffers_blend(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_draw_buffers_blend */\n#ifdef GL_ARB_draw_elements_base_vertex\n  CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = _glewSearchExtension(\"GL_ARB_draw_elements_base_vertex\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_draw_elements_base_vertex) CONST_CAST(GLEW_ARB_draw_elements_base_vertex) = !_glewInit_GL_ARB_draw_elements_base_vertex(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_draw_elements_base_vertex */\n#ifdef GL_ARB_draw_indirect\n  CONST_CAST(GLEW_ARB_draw_indirect) = _glewSearchExtension(\"GL_ARB_draw_indirect\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_draw_indirect) CONST_CAST(GLEW_ARB_draw_indirect) = !_glewInit_GL_ARB_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_draw_indirect */\n#ifdef GL_ARB_draw_instanced\n  CONST_CAST(GLEW_ARB_draw_instanced) = _glewSearchExtension(\"GL_ARB_draw_instanced\", extStart, extEnd);\n#endif /* GL_ARB_draw_instanced */\n#ifdef GL_ARB_explicit_attrib_location\n  CONST_CAST(GLEW_ARB_explicit_attrib_location) = _glewSearchExtension(\"GL_ARB_explicit_attrib_location\", extStart, extEnd);\n#endif /* GL_ARB_explicit_attrib_location */\n#ifdef GL_ARB_explicit_uniform_location\n  CONST_CAST(GLEW_ARB_explicit_uniform_location) = _glewSearchExtension(\"GL_ARB_explicit_uniform_location\", extStart, extEnd);\n#endif /* GL_ARB_explicit_uniform_location */\n#ifdef GL_ARB_fragment_coord_conventions\n  CONST_CAST(GLEW_ARB_fragment_coord_conventions) = _glewSearchExtension(\"GL_ARB_fragment_coord_conventions\", extStart, extEnd);\n#endif /* GL_ARB_fragment_coord_conventions */\n#ifdef GL_ARB_fragment_layer_viewport\n  CONST_CAST(GLEW_ARB_fragment_layer_viewport) = _glewSearchExtension(\"GL_ARB_fragment_layer_viewport\", extStart, extEnd);\n#endif /* GL_ARB_fragment_layer_viewport */\n#ifdef GL_ARB_fragment_program\n  CONST_CAST(GLEW_ARB_fragment_program) = _glewSearchExtension(\"GL_ARB_fragment_program\", extStart, extEnd);\n#endif /* GL_ARB_fragment_program */\n#ifdef GL_ARB_fragment_program_shadow\n  CONST_CAST(GLEW_ARB_fragment_program_shadow) = _glewSearchExtension(\"GL_ARB_fragment_program_shadow\", extStart, extEnd);\n#endif /* GL_ARB_fragment_program_shadow */\n#ifdef GL_ARB_fragment_shader\n  CONST_CAST(GLEW_ARB_fragment_shader) = _glewSearchExtension(\"GL_ARB_fragment_shader\", extStart, extEnd);\n#endif /* GL_ARB_fragment_shader */\n#ifdef GL_ARB_framebuffer_no_attachments\n  CONST_CAST(GLEW_ARB_framebuffer_no_attachments) = _glewSearchExtension(\"GL_ARB_framebuffer_no_attachments\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_framebuffer_no_attachments) CONST_CAST(GLEW_ARB_framebuffer_no_attachments) = !_glewInit_GL_ARB_framebuffer_no_attachments(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_framebuffer_no_attachments */\n#ifdef GL_ARB_framebuffer_object\n  CONST_CAST(GLEW_ARB_framebuffer_object) = _glewSearchExtension(\"GL_ARB_framebuffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_framebuffer_object) CONST_CAST(GLEW_ARB_framebuffer_object) = !_glewInit_GL_ARB_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_framebuffer_object */\n#ifdef GL_ARB_framebuffer_sRGB\n  CONST_CAST(GLEW_ARB_framebuffer_sRGB) = _glewSearchExtension(\"GL_ARB_framebuffer_sRGB\", extStart, extEnd);\n#endif /* GL_ARB_framebuffer_sRGB */\n#ifdef GL_ARB_geometry_shader4\n  CONST_CAST(GLEW_ARB_geometry_shader4) = _glewSearchExtension(\"GL_ARB_geometry_shader4\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_geometry_shader4) CONST_CAST(GLEW_ARB_geometry_shader4) = !_glewInit_GL_ARB_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_geometry_shader4 */\n#ifdef GL_ARB_get_program_binary\n  CONST_CAST(GLEW_ARB_get_program_binary) = _glewSearchExtension(\"GL_ARB_get_program_binary\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_get_program_binary) CONST_CAST(GLEW_ARB_get_program_binary) = !_glewInit_GL_ARB_get_program_binary(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_get_program_binary */\n#ifdef GL_ARB_gpu_shader5\n  CONST_CAST(GLEW_ARB_gpu_shader5) = _glewSearchExtension(\"GL_ARB_gpu_shader5\", extStart, extEnd);\n#endif /* GL_ARB_gpu_shader5 */\n#ifdef GL_ARB_gpu_shader_fp64\n  CONST_CAST(GLEW_ARB_gpu_shader_fp64) = _glewSearchExtension(\"GL_ARB_gpu_shader_fp64\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_gpu_shader_fp64) CONST_CAST(GLEW_ARB_gpu_shader_fp64) = !_glewInit_GL_ARB_gpu_shader_fp64(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_gpu_shader_fp64 */\n#ifdef GL_ARB_half_float_pixel\n  CONST_CAST(GLEW_ARB_half_float_pixel) = _glewSearchExtension(\"GL_ARB_half_float_pixel\", extStart, extEnd);\n#endif /* GL_ARB_half_float_pixel */\n#ifdef GL_ARB_half_float_vertex\n  CONST_CAST(GLEW_ARB_half_float_vertex) = _glewSearchExtension(\"GL_ARB_half_float_vertex\", extStart, extEnd);\n#endif /* GL_ARB_half_float_vertex */\n#ifdef GL_ARB_imaging\n  CONST_CAST(GLEW_ARB_imaging) = _glewSearchExtension(\"GL_ARB_imaging\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_imaging) CONST_CAST(GLEW_ARB_imaging) = !_glewInit_GL_ARB_imaging(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_imaging */\n#ifdef GL_ARB_instanced_arrays\n  CONST_CAST(GLEW_ARB_instanced_arrays) = _glewSearchExtension(\"GL_ARB_instanced_arrays\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_instanced_arrays) CONST_CAST(GLEW_ARB_instanced_arrays) = !_glewInit_GL_ARB_instanced_arrays(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_instanced_arrays */\n#ifdef GL_ARB_internalformat_query\n  CONST_CAST(GLEW_ARB_internalformat_query) = _glewSearchExtension(\"GL_ARB_internalformat_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_internalformat_query) CONST_CAST(GLEW_ARB_internalformat_query) = !_glewInit_GL_ARB_internalformat_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_internalformat_query */\n#ifdef GL_ARB_internalformat_query2\n  CONST_CAST(GLEW_ARB_internalformat_query2) = _glewSearchExtension(\"GL_ARB_internalformat_query2\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_internalformat_query2) CONST_CAST(GLEW_ARB_internalformat_query2) = !_glewInit_GL_ARB_internalformat_query2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_internalformat_query2 */\n#ifdef GL_ARB_invalidate_subdata\n  CONST_CAST(GLEW_ARB_invalidate_subdata) = _glewSearchExtension(\"GL_ARB_invalidate_subdata\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_invalidate_subdata) CONST_CAST(GLEW_ARB_invalidate_subdata) = !_glewInit_GL_ARB_invalidate_subdata(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_invalidate_subdata */\n#ifdef GL_ARB_map_buffer_alignment\n  CONST_CAST(GLEW_ARB_map_buffer_alignment) = _glewSearchExtension(\"GL_ARB_map_buffer_alignment\", extStart, extEnd);\n#endif /* GL_ARB_map_buffer_alignment */\n#ifdef GL_ARB_map_buffer_range\n  CONST_CAST(GLEW_ARB_map_buffer_range) = _glewSearchExtension(\"GL_ARB_map_buffer_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_map_buffer_range) CONST_CAST(GLEW_ARB_map_buffer_range) = !_glewInit_GL_ARB_map_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_map_buffer_range */\n#ifdef GL_ARB_matrix_palette\n  CONST_CAST(GLEW_ARB_matrix_palette) = _glewSearchExtension(\"GL_ARB_matrix_palette\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_matrix_palette) CONST_CAST(GLEW_ARB_matrix_palette) = !_glewInit_GL_ARB_matrix_palette(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_matrix_palette */\n#ifdef GL_ARB_multi_draw_indirect\n  CONST_CAST(GLEW_ARB_multi_draw_indirect) = _glewSearchExtension(\"GL_ARB_multi_draw_indirect\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_multi_draw_indirect) CONST_CAST(GLEW_ARB_multi_draw_indirect) = !_glewInit_GL_ARB_multi_draw_indirect(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_multi_draw_indirect */\n#ifdef GL_ARB_multisample\n  CONST_CAST(GLEW_ARB_multisample) = _glewSearchExtension(\"GL_ARB_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_multisample) CONST_CAST(GLEW_ARB_multisample) = !_glewInit_GL_ARB_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_multisample */\n#ifdef GL_ARB_multitexture\n  CONST_CAST(GLEW_ARB_multitexture) = _glewSearchExtension(\"GL_ARB_multitexture\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_multitexture) CONST_CAST(GLEW_ARB_multitexture) = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_multitexture */\n#ifdef GL_ARB_occlusion_query\n  CONST_CAST(GLEW_ARB_occlusion_query) = _glewSearchExtension(\"GL_ARB_occlusion_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_occlusion_query) CONST_CAST(GLEW_ARB_occlusion_query) = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_occlusion_query */\n#ifdef GL_ARB_occlusion_query2\n  CONST_CAST(GLEW_ARB_occlusion_query2) = _glewSearchExtension(\"GL_ARB_occlusion_query2\", extStart, extEnd);\n#endif /* GL_ARB_occlusion_query2 */\n#ifdef GL_ARB_pixel_buffer_object\n  CONST_CAST(GLEW_ARB_pixel_buffer_object) = _glewSearchExtension(\"GL_ARB_pixel_buffer_object\", extStart, extEnd);\n#endif /* GL_ARB_pixel_buffer_object */\n#ifdef GL_ARB_point_parameters\n  CONST_CAST(GLEW_ARB_point_parameters) = _glewSearchExtension(\"GL_ARB_point_parameters\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_point_parameters) CONST_CAST(GLEW_ARB_point_parameters) = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_point_parameters */\n#ifdef GL_ARB_point_sprite\n  CONST_CAST(GLEW_ARB_point_sprite) = _glewSearchExtension(\"GL_ARB_point_sprite\", extStart, extEnd);\n#endif /* GL_ARB_point_sprite */\n#ifdef GL_ARB_program_interface_query\n  CONST_CAST(GLEW_ARB_program_interface_query) = _glewSearchExtension(\"GL_ARB_program_interface_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_program_interface_query) CONST_CAST(GLEW_ARB_program_interface_query) = !_glewInit_GL_ARB_program_interface_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_program_interface_query */\n#ifdef GL_ARB_provoking_vertex\n  CONST_CAST(GLEW_ARB_provoking_vertex) = _glewSearchExtension(\"GL_ARB_provoking_vertex\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_provoking_vertex) CONST_CAST(GLEW_ARB_provoking_vertex) = !_glewInit_GL_ARB_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_provoking_vertex */\n#ifdef GL_ARB_robust_buffer_access_behavior\n  CONST_CAST(GLEW_ARB_robust_buffer_access_behavior) = _glewSearchExtension(\"GL_ARB_robust_buffer_access_behavior\", extStart, extEnd);\n#endif /* GL_ARB_robust_buffer_access_behavior */\n#ifdef GL_ARB_robustness\n  CONST_CAST(GLEW_ARB_robustness) = _glewSearchExtension(\"GL_ARB_robustness\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_robustness) CONST_CAST(GLEW_ARB_robustness) = !_glewInit_GL_ARB_robustness(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_robustness */\n#ifdef GL_ARB_robustness_application_isolation\n  CONST_CAST(GLEW_ARB_robustness_application_isolation) = _glewSearchExtension(\"GL_ARB_robustness_application_isolation\", extStart, extEnd);\n#endif /* GL_ARB_robustness_application_isolation */\n#ifdef GL_ARB_robustness_share_group_isolation\n  CONST_CAST(GLEW_ARB_robustness_share_group_isolation) = _glewSearchExtension(\"GL_ARB_robustness_share_group_isolation\", extStart, extEnd);\n#endif /* GL_ARB_robustness_share_group_isolation */\n#ifdef GL_ARB_sample_shading\n  CONST_CAST(GLEW_ARB_sample_shading) = _glewSearchExtension(\"GL_ARB_sample_shading\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_sample_shading) CONST_CAST(GLEW_ARB_sample_shading) = !_glewInit_GL_ARB_sample_shading(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_sample_shading */\n#ifdef GL_ARB_sampler_objects\n  CONST_CAST(GLEW_ARB_sampler_objects) = _glewSearchExtension(\"GL_ARB_sampler_objects\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_sampler_objects) CONST_CAST(GLEW_ARB_sampler_objects) = !_glewInit_GL_ARB_sampler_objects(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_sampler_objects */\n#ifdef GL_ARB_seamless_cube_map\n  CONST_CAST(GLEW_ARB_seamless_cube_map) = _glewSearchExtension(\"GL_ARB_seamless_cube_map\", extStart, extEnd);\n#endif /* GL_ARB_seamless_cube_map */\n#ifdef GL_ARB_separate_shader_objects\n  CONST_CAST(GLEW_ARB_separate_shader_objects) = _glewSearchExtension(\"GL_ARB_separate_shader_objects\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_separate_shader_objects) CONST_CAST(GLEW_ARB_separate_shader_objects) = !_glewInit_GL_ARB_separate_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_separate_shader_objects */\n#ifdef GL_ARB_shader_atomic_counters\n  CONST_CAST(GLEW_ARB_shader_atomic_counters) = _glewSearchExtension(\"GL_ARB_shader_atomic_counters\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shader_atomic_counters) CONST_CAST(GLEW_ARB_shader_atomic_counters) = !_glewInit_GL_ARB_shader_atomic_counters(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shader_atomic_counters */\n#ifdef GL_ARB_shader_bit_encoding\n  CONST_CAST(GLEW_ARB_shader_bit_encoding) = _glewSearchExtension(\"GL_ARB_shader_bit_encoding\", extStart, extEnd);\n#endif /* GL_ARB_shader_bit_encoding */\n#ifdef GL_ARB_shader_image_load_store\n  CONST_CAST(GLEW_ARB_shader_image_load_store) = _glewSearchExtension(\"GL_ARB_shader_image_load_store\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shader_image_load_store) CONST_CAST(GLEW_ARB_shader_image_load_store) = !_glewInit_GL_ARB_shader_image_load_store(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shader_image_load_store */\n#ifdef GL_ARB_shader_image_size\n  CONST_CAST(GLEW_ARB_shader_image_size) = _glewSearchExtension(\"GL_ARB_shader_image_size\", extStart, extEnd);\n#endif /* GL_ARB_shader_image_size */\n#ifdef GL_ARB_shader_objects\n  CONST_CAST(GLEW_ARB_shader_objects) = _glewSearchExtension(\"GL_ARB_shader_objects\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shader_objects) CONST_CAST(GLEW_ARB_shader_objects) = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shader_objects */\n#ifdef GL_ARB_shader_precision\n  CONST_CAST(GLEW_ARB_shader_precision) = _glewSearchExtension(\"GL_ARB_shader_precision\", extStart, extEnd);\n#endif /* GL_ARB_shader_precision */\n#ifdef GL_ARB_shader_stencil_export\n  CONST_CAST(GLEW_ARB_shader_stencil_export) = _glewSearchExtension(\"GL_ARB_shader_stencil_export\", extStart, extEnd);\n#endif /* GL_ARB_shader_stencil_export */\n#ifdef GL_ARB_shader_storage_buffer_object\n  CONST_CAST(GLEW_ARB_shader_storage_buffer_object) = _glewSearchExtension(\"GL_ARB_shader_storage_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shader_storage_buffer_object) CONST_CAST(GLEW_ARB_shader_storage_buffer_object) = !_glewInit_GL_ARB_shader_storage_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shader_storage_buffer_object */\n#ifdef GL_ARB_shader_subroutine\n  CONST_CAST(GLEW_ARB_shader_subroutine) = _glewSearchExtension(\"GL_ARB_shader_subroutine\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shader_subroutine) CONST_CAST(GLEW_ARB_shader_subroutine) = !_glewInit_GL_ARB_shader_subroutine(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shader_subroutine */\n#ifdef GL_ARB_shader_texture_lod\n  CONST_CAST(GLEW_ARB_shader_texture_lod) = _glewSearchExtension(\"GL_ARB_shader_texture_lod\", extStart, extEnd);\n#endif /* GL_ARB_shader_texture_lod */\n#ifdef GL_ARB_shading_language_100\n  CONST_CAST(GLEW_ARB_shading_language_100) = _glewSearchExtension(\"GL_ARB_shading_language_100\", extStart, extEnd);\n#endif /* GL_ARB_shading_language_100 */\n#ifdef GL_ARB_shading_language_420pack\n  CONST_CAST(GLEW_ARB_shading_language_420pack) = _glewSearchExtension(\"GL_ARB_shading_language_420pack\", extStart, extEnd);\n#endif /* GL_ARB_shading_language_420pack */\n#ifdef GL_ARB_shading_language_include\n  CONST_CAST(GLEW_ARB_shading_language_include) = _glewSearchExtension(\"GL_ARB_shading_language_include\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_shading_language_include) CONST_CAST(GLEW_ARB_shading_language_include) = !_glewInit_GL_ARB_shading_language_include(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_shading_language_include */\n#ifdef GL_ARB_shading_language_packing\n  CONST_CAST(GLEW_ARB_shading_language_packing) = _glewSearchExtension(\"GL_ARB_shading_language_packing\", extStart, extEnd);\n#endif /* GL_ARB_shading_language_packing */\n#ifdef GL_ARB_shadow\n  CONST_CAST(GLEW_ARB_shadow) = _glewSearchExtension(\"GL_ARB_shadow\", extStart, extEnd);\n#endif /* GL_ARB_shadow */\n#ifdef GL_ARB_shadow_ambient\n  CONST_CAST(GLEW_ARB_shadow_ambient) = _glewSearchExtension(\"GL_ARB_shadow_ambient\", extStart, extEnd);\n#endif /* GL_ARB_shadow_ambient */\n#ifdef GL_ARB_stencil_texturing\n  CONST_CAST(GLEW_ARB_stencil_texturing) = _glewSearchExtension(\"GL_ARB_stencil_texturing\", extStart, extEnd);\n#endif /* GL_ARB_stencil_texturing */\n#ifdef GL_ARB_sync\n  CONST_CAST(GLEW_ARB_sync) = _glewSearchExtension(\"GL_ARB_sync\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_sync) CONST_CAST(GLEW_ARB_sync) = !_glewInit_GL_ARB_sync(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_sync */\n#ifdef GL_ARB_tessellation_shader\n  CONST_CAST(GLEW_ARB_tessellation_shader) = _glewSearchExtension(\"GL_ARB_tessellation_shader\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_tessellation_shader) CONST_CAST(GLEW_ARB_tessellation_shader) = !_glewInit_GL_ARB_tessellation_shader(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_tessellation_shader */\n#ifdef GL_ARB_texture_border_clamp\n  CONST_CAST(GLEW_ARB_texture_border_clamp) = _glewSearchExtension(\"GL_ARB_texture_border_clamp\", extStart, extEnd);\n#endif /* GL_ARB_texture_border_clamp */\n#ifdef GL_ARB_texture_buffer_object\n  CONST_CAST(GLEW_ARB_texture_buffer_object) = _glewSearchExtension(\"GL_ARB_texture_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_buffer_object) CONST_CAST(GLEW_ARB_texture_buffer_object) = !_glewInit_GL_ARB_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_buffer_object */\n#ifdef GL_ARB_texture_buffer_object_rgb32\n  CONST_CAST(GLEW_ARB_texture_buffer_object_rgb32) = _glewSearchExtension(\"GL_ARB_texture_buffer_object_rgb32\", extStart, extEnd);\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n#ifdef GL_ARB_texture_buffer_range\n  CONST_CAST(GLEW_ARB_texture_buffer_range) = _glewSearchExtension(\"GL_ARB_texture_buffer_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_buffer_range) CONST_CAST(GLEW_ARB_texture_buffer_range) = !_glewInit_GL_ARB_texture_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_buffer_range */\n#ifdef GL_ARB_texture_compression\n  CONST_CAST(GLEW_ARB_texture_compression) = _glewSearchExtension(\"GL_ARB_texture_compression\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_compression) CONST_CAST(GLEW_ARB_texture_compression) = !_glewInit_GL_ARB_texture_compression(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_compression */\n#ifdef GL_ARB_texture_compression_bptc\n  CONST_CAST(GLEW_ARB_texture_compression_bptc) = _glewSearchExtension(\"GL_ARB_texture_compression_bptc\", extStart, extEnd);\n#endif /* GL_ARB_texture_compression_bptc */\n#ifdef GL_ARB_texture_compression_rgtc\n  CONST_CAST(GLEW_ARB_texture_compression_rgtc) = _glewSearchExtension(\"GL_ARB_texture_compression_rgtc\", extStart, extEnd);\n#endif /* GL_ARB_texture_compression_rgtc */\n#ifdef GL_ARB_texture_cube_map\n  CONST_CAST(GLEW_ARB_texture_cube_map) = _glewSearchExtension(\"GL_ARB_texture_cube_map\", extStart, extEnd);\n#endif /* GL_ARB_texture_cube_map */\n#ifdef GL_ARB_texture_cube_map_array\n  CONST_CAST(GLEW_ARB_texture_cube_map_array) = _glewSearchExtension(\"GL_ARB_texture_cube_map_array\", extStart, extEnd);\n#endif /* GL_ARB_texture_cube_map_array */\n#ifdef GL_ARB_texture_env_add\n  CONST_CAST(GLEW_ARB_texture_env_add) = _glewSearchExtension(\"GL_ARB_texture_env_add\", extStart, extEnd);\n#endif /* GL_ARB_texture_env_add */\n#ifdef GL_ARB_texture_env_combine\n  CONST_CAST(GLEW_ARB_texture_env_combine) = _glewSearchExtension(\"GL_ARB_texture_env_combine\", extStart, extEnd);\n#endif /* GL_ARB_texture_env_combine */\n#ifdef GL_ARB_texture_env_crossbar\n  CONST_CAST(GLEW_ARB_texture_env_crossbar) = _glewSearchExtension(\"GL_ARB_texture_env_crossbar\", extStart, extEnd);\n#endif /* GL_ARB_texture_env_crossbar */\n#ifdef GL_ARB_texture_env_dot3\n  CONST_CAST(GLEW_ARB_texture_env_dot3) = _glewSearchExtension(\"GL_ARB_texture_env_dot3\", extStart, extEnd);\n#endif /* GL_ARB_texture_env_dot3 */\n#ifdef GL_ARB_texture_float\n  CONST_CAST(GLEW_ARB_texture_float) = _glewSearchExtension(\"GL_ARB_texture_float\", extStart, extEnd);\n#endif /* GL_ARB_texture_float */\n#ifdef GL_ARB_texture_gather\n  CONST_CAST(GLEW_ARB_texture_gather) = _glewSearchExtension(\"GL_ARB_texture_gather\", extStart, extEnd);\n#endif /* GL_ARB_texture_gather */\n#ifdef GL_ARB_texture_mirrored_repeat\n  CONST_CAST(GLEW_ARB_texture_mirrored_repeat) = _glewSearchExtension(\"GL_ARB_texture_mirrored_repeat\", extStart, extEnd);\n#endif /* GL_ARB_texture_mirrored_repeat */\n#ifdef GL_ARB_texture_multisample\n  CONST_CAST(GLEW_ARB_texture_multisample) = _glewSearchExtension(\"GL_ARB_texture_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_multisample) CONST_CAST(GLEW_ARB_texture_multisample) = !_glewInit_GL_ARB_texture_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_multisample */\n#ifdef GL_ARB_texture_non_power_of_two\n  CONST_CAST(GLEW_ARB_texture_non_power_of_two) = _glewSearchExtension(\"GL_ARB_texture_non_power_of_two\", extStart, extEnd);\n#endif /* GL_ARB_texture_non_power_of_two */\n#ifdef GL_ARB_texture_query_levels\n  CONST_CAST(GLEW_ARB_texture_query_levels) = _glewSearchExtension(\"GL_ARB_texture_query_levels\", extStart, extEnd);\n#endif /* GL_ARB_texture_query_levels */\n#ifdef GL_ARB_texture_query_lod\n  CONST_CAST(GLEW_ARB_texture_query_lod) = _glewSearchExtension(\"GL_ARB_texture_query_lod\", extStart, extEnd);\n#endif /* GL_ARB_texture_query_lod */\n#ifdef GL_ARB_texture_rectangle\n  CONST_CAST(GLEW_ARB_texture_rectangle) = _glewSearchExtension(\"GL_ARB_texture_rectangle\", extStart, extEnd);\n#endif /* GL_ARB_texture_rectangle */\n#ifdef GL_ARB_texture_rg\n  CONST_CAST(GLEW_ARB_texture_rg) = _glewSearchExtension(\"GL_ARB_texture_rg\", extStart, extEnd);\n#endif /* GL_ARB_texture_rg */\n#ifdef GL_ARB_texture_rgb10_a2ui\n  CONST_CAST(GLEW_ARB_texture_rgb10_a2ui) = _glewSearchExtension(\"GL_ARB_texture_rgb10_a2ui\", extStart, extEnd);\n#endif /* GL_ARB_texture_rgb10_a2ui */\n#ifdef GL_ARB_texture_storage\n  CONST_CAST(GLEW_ARB_texture_storage) = _glewSearchExtension(\"GL_ARB_texture_storage\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_storage) CONST_CAST(GLEW_ARB_texture_storage) = !_glewInit_GL_ARB_texture_storage(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_storage */\n#ifdef GL_ARB_texture_storage_multisample\n  CONST_CAST(GLEW_ARB_texture_storage_multisample) = _glewSearchExtension(\"GL_ARB_texture_storage_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_storage_multisample) CONST_CAST(GLEW_ARB_texture_storage_multisample) = !_glewInit_GL_ARB_texture_storage_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_storage_multisample */\n#ifdef GL_ARB_texture_swizzle\n  CONST_CAST(GLEW_ARB_texture_swizzle) = _glewSearchExtension(\"GL_ARB_texture_swizzle\", extStart, extEnd);\n#endif /* GL_ARB_texture_swizzle */\n#ifdef GL_ARB_texture_view\n  CONST_CAST(GLEW_ARB_texture_view) = _glewSearchExtension(\"GL_ARB_texture_view\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_texture_view) CONST_CAST(GLEW_ARB_texture_view) = !_glewInit_GL_ARB_texture_view(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_texture_view */\n#ifdef GL_ARB_timer_query\n  CONST_CAST(GLEW_ARB_timer_query) = _glewSearchExtension(\"GL_ARB_timer_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_timer_query) CONST_CAST(GLEW_ARB_timer_query) = !_glewInit_GL_ARB_timer_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_timer_query */\n#ifdef GL_ARB_transform_feedback2\n  CONST_CAST(GLEW_ARB_transform_feedback2) = _glewSearchExtension(\"GL_ARB_transform_feedback2\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_transform_feedback2) CONST_CAST(GLEW_ARB_transform_feedback2) = !_glewInit_GL_ARB_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_transform_feedback2 */\n#ifdef GL_ARB_transform_feedback3\n  CONST_CAST(GLEW_ARB_transform_feedback3) = _glewSearchExtension(\"GL_ARB_transform_feedback3\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_transform_feedback3) CONST_CAST(GLEW_ARB_transform_feedback3) = !_glewInit_GL_ARB_transform_feedback3(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_transform_feedback3 */\n#ifdef GL_ARB_transform_feedback_instanced\n  CONST_CAST(GLEW_ARB_transform_feedback_instanced) = _glewSearchExtension(\"GL_ARB_transform_feedback_instanced\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_transform_feedback_instanced) CONST_CAST(GLEW_ARB_transform_feedback_instanced) = !_glewInit_GL_ARB_transform_feedback_instanced(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_transform_feedback_instanced */\n#ifdef GL_ARB_transpose_matrix\n  CONST_CAST(GLEW_ARB_transpose_matrix) = _glewSearchExtension(\"GL_ARB_transpose_matrix\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_transpose_matrix) CONST_CAST(GLEW_ARB_transpose_matrix) = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_transpose_matrix */\n#ifdef GL_ARB_uniform_buffer_object\n  CONST_CAST(GLEW_ARB_uniform_buffer_object) = _glewSearchExtension(\"GL_ARB_uniform_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_uniform_buffer_object) CONST_CAST(GLEW_ARB_uniform_buffer_object) = !_glewInit_GL_ARB_uniform_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_uniform_buffer_object */\n#ifdef GL_ARB_vertex_array_bgra\n  CONST_CAST(GLEW_ARB_vertex_array_bgra) = _glewSearchExtension(\"GL_ARB_vertex_array_bgra\", extStart, extEnd);\n#endif /* GL_ARB_vertex_array_bgra */\n#ifdef GL_ARB_vertex_array_object\n  CONST_CAST(GLEW_ARB_vertex_array_object) = _glewSearchExtension(\"GL_ARB_vertex_array_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_array_object) CONST_CAST(GLEW_ARB_vertex_array_object) = !_glewInit_GL_ARB_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_array_object */\n#ifdef GL_ARB_vertex_attrib_64bit\n  CONST_CAST(GLEW_ARB_vertex_attrib_64bit) = _glewSearchExtension(\"GL_ARB_vertex_attrib_64bit\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_attrib_64bit) CONST_CAST(GLEW_ARB_vertex_attrib_64bit) = !_glewInit_GL_ARB_vertex_attrib_64bit(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_attrib_64bit */\n#ifdef GL_ARB_vertex_attrib_binding\n  CONST_CAST(GLEW_ARB_vertex_attrib_binding) = _glewSearchExtension(\"GL_ARB_vertex_attrib_binding\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_attrib_binding) CONST_CAST(GLEW_ARB_vertex_attrib_binding) = !_glewInit_GL_ARB_vertex_attrib_binding(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_attrib_binding */\n#ifdef GL_ARB_vertex_blend\n  CONST_CAST(GLEW_ARB_vertex_blend) = _glewSearchExtension(\"GL_ARB_vertex_blend\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_blend) CONST_CAST(GLEW_ARB_vertex_blend) = !_glewInit_GL_ARB_vertex_blend(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_blend */\n#ifdef GL_ARB_vertex_buffer_object\n  CONST_CAST(GLEW_ARB_vertex_buffer_object) = _glewSearchExtension(\"GL_ARB_vertex_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_buffer_object) CONST_CAST(GLEW_ARB_vertex_buffer_object) = !_glewInit_GL_ARB_vertex_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_buffer_object */\n#ifdef GL_ARB_vertex_program\n  CONST_CAST(GLEW_ARB_vertex_program) = _glewSearchExtension(\"GL_ARB_vertex_program\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_program) CONST_CAST(GLEW_ARB_vertex_program) = !_glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_program */\n#ifdef GL_ARB_vertex_shader\n  CONST_CAST(GLEW_ARB_vertex_shader) = _glewSearchExtension(\"GL_ARB_vertex_shader\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_shader) CONST_CAST(GLEW_ARB_vertex_shader) = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_shader */\n#ifdef GL_ARB_vertex_type_2_10_10_10_rev\n  CONST_CAST(GLEW_ARB_vertex_type_2_10_10_10_rev) = _glewSearchExtension(\"GL_ARB_vertex_type_2_10_10_10_rev\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_vertex_type_2_10_10_10_rev) CONST_CAST(GLEW_ARB_vertex_type_2_10_10_10_rev) = !_glewInit_GL_ARB_vertex_type_2_10_10_10_rev(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n#ifdef GL_ARB_viewport_array\n  CONST_CAST(GLEW_ARB_viewport_array) = _glewSearchExtension(\"GL_ARB_viewport_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_viewport_array) CONST_CAST(GLEW_ARB_viewport_array) = !_glewInit_GL_ARB_viewport_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_viewport_array */\n#ifdef GL_ARB_window_pos\n  CONST_CAST(GLEW_ARB_window_pos) = _glewSearchExtension(\"GL_ARB_window_pos\", extStart, extEnd);\n  if (glewExperimental || GLEW_ARB_window_pos) CONST_CAST(GLEW_ARB_window_pos) = !_glewInit_GL_ARB_window_pos(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ARB_window_pos */\n#ifdef GL_ATIX_point_sprites\n  CONST_CAST(GLEW_ATIX_point_sprites) = _glewSearchExtension(\"GL_ATIX_point_sprites\", extStart, extEnd);\n#endif /* GL_ATIX_point_sprites */\n#ifdef GL_ATIX_texture_env_combine3\n  CONST_CAST(GLEW_ATIX_texture_env_combine3) = _glewSearchExtension(\"GL_ATIX_texture_env_combine3\", extStart, extEnd);\n#endif /* GL_ATIX_texture_env_combine3 */\n#ifdef GL_ATIX_texture_env_route\n  CONST_CAST(GLEW_ATIX_texture_env_route) = _glewSearchExtension(\"GL_ATIX_texture_env_route\", extStart, extEnd);\n#endif /* GL_ATIX_texture_env_route */\n#ifdef GL_ATIX_vertex_shader_output_point_size\n  CONST_CAST(GLEW_ATIX_vertex_shader_output_point_size) = _glewSearchExtension(\"GL_ATIX_vertex_shader_output_point_size\", extStart, extEnd);\n#endif /* GL_ATIX_vertex_shader_output_point_size */\n#ifdef GL_ATI_draw_buffers\n  CONST_CAST(GLEW_ATI_draw_buffers) = _glewSearchExtension(\"GL_ATI_draw_buffers\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_draw_buffers) CONST_CAST(GLEW_ATI_draw_buffers) = !_glewInit_GL_ATI_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_draw_buffers */\n#ifdef GL_ATI_element_array\n  CONST_CAST(GLEW_ATI_element_array) = _glewSearchExtension(\"GL_ATI_element_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_element_array) CONST_CAST(GLEW_ATI_element_array) = !_glewInit_GL_ATI_element_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_element_array */\n#ifdef GL_ATI_envmap_bumpmap\n  CONST_CAST(GLEW_ATI_envmap_bumpmap) = _glewSearchExtension(\"GL_ATI_envmap_bumpmap\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_envmap_bumpmap) CONST_CAST(GLEW_ATI_envmap_bumpmap) = !_glewInit_GL_ATI_envmap_bumpmap(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_envmap_bumpmap */\n#ifdef GL_ATI_fragment_shader\n  CONST_CAST(GLEW_ATI_fragment_shader) = _glewSearchExtension(\"GL_ATI_fragment_shader\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_fragment_shader) CONST_CAST(GLEW_ATI_fragment_shader) = !_glewInit_GL_ATI_fragment_shader(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_fragment_shader */\n#ifdef GL_ATI_map_object_buffer\n  CONST_CAST(GLEW_ATI_map_object_buffer) = _glewSearchExtension(\"GL_ATI_map_object_buffer\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_map_object_buffer) CONST_CAST(GLEW_ATI_map_object_buffer) = !_glewInit_GL_ATI_map_object_buffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_map_object_buffer */\n#ifdef GL_ATI_meminfo\n  CONST_CAST(GLEW_ATI_meminfo) = _glewSearchExtension(\"GL_ATI_meminfo\", extStart, extEnd);\n#endif /* GL_ATI_meminfo */\n#ifdef GL_ATI_pn_triangles\n  CONST_CAST(GLEW_ATI_pn_triangles) = _glewSearchExtension(\"GL_ATI_pn_triangles\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_pn_triangles) CONST_CAST(GLEW_ATI_pn_triangles) = !_glewInit_GL_ATI_pn_triangles(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_pn_triangles */\n#ifdef GL_ATI_separate_stencil\n  CONST_CAST(GLEW_ATI_separate_stencil) = _glewSearchExtension(\"GL_ATI_separate_stencil\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_separate_stencil) CONST_CAST(GLEW_ATI_separate_stencil) = !_glewInit_GL_ATI_separate_stencil(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_separate_stencil */\n#ifdef GL_ATI_shader_texture_lod\n  CONST_CAST(GLEW_ATI_shader_texture_lod) = _glewSearchExtension(\"GL_ATI_shader_texture_lod\", extStart, extEnd);\n#endif /* GL_ATI_shader_texture_lod */\n#ifdef GL_ATI_text_fragment_shader\n  CONST_CAST(GLEW_ATI_text_fragment_shader) = _glewSearchExtension(\"GL_ATI_text_fragment_shader\", extStart, extEnd);\n#endif /* GL_ATI_text_fragment_shader */\n#ifdef GL_ATI_texture_compression_3dc\n  CONST_CAST(GLEW_ATI_texture_compression_3dc) = _glewSearchExtension(\"GL_ATI_texture_compression_3dc\", extStart, extEnd);\n#endif /* GL_ATI_texture_compression_3dc */\n#ifdef GL_ATI_texture_env_combine3\n  CONST_CAST(GLEW_ATI_texture_env_combine3) = _glewSearchExtension(\"GL_ATI_texture_env_combine3\", extStart, extEnd);\n#endif /* GL_ATI_texture_env_combine3 */\n#ifdef GL_ATI_texture_float\n  CONST_CAST(GLEW_ATI_texture_float) = _glewSearchExtension(\"GL_ATI_texture_float\", extStart, extEnd);\n#endif /* GL_ATI_texture_float */\n#ifdef GL_ATI_texture_mirror_once\n  CONST_CAST(GLEW_ATI_texture_mirror_once) = _glewSearchExtension(\"GL_ATI_texture_mirror_once\", extStart, extEnd);\n#endif /* GL_ATI_texture_mirror_once */\n#ifdef GL_ATI_vertex_array_object\n  CONST_CAST(GLEW_ATI_vertex_array_object) = _glewSearchExtension(\"GL_ATI_vertex_array_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_vertex_array_object) CONST_CAST(GLEW_ATI_vertex_array_object) = !_glewInit_GL_ATI_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_vertex_array_object */\n#ifdef GL_ATI_vertex_attrib_array_object\n  CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = _glewSearchExtension(\"GL_ATI_vertex_attrib_array_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_vertex_attrib_array_object) CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = !_glewInit_GL_ATI_vertex_attrib_array_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_vertex_attrib_array_object */\n#ifdef GL_ATI_vertex_streams\n  CONST_CAST(GLEW_ATI_vertex_streams) = _glewSearchExtension(\"GL_ATI_vertex_streams\", extStart, extEnd);\n  if (glewExperimental || GLEW_ATI_vertex_streams) CONST_CAST(GLEW_ATI_vertex_streams) = !_glewInit_GL_ATI_vertex_streams(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_ATI_vertex_streams */\n#ifdef GL_EXT_422_pixels\n  CONST_CAST(GLEW_EXT_422_pixels) = _glewSearchExtension(\"GL_EXT_422_pixels\", extStart, extEnd);\n#endif /* GL_EXT_422_pixels */\n#ifdef GL_EXT_Cg_shader\n  CONST_CAST(GLEW_EXT_Cg_shader) = _glewSearchExtension(\"GL_EXT_Cg_shader\", extStart, extEnd);\n#endif /* GL_EXT_Cg_shader */\n#ifdef GL_EXT_abgr\n  CONST_CAST(GLEW_EXT_abgr) = _glewSearchExtension(\"GL_EXT_abgr\", extStart, extEnd);\n#endif /* GL_EXT_abgr */\n#ifdef GL_EXT_bgra\n  CONST_CAST(GLEW_EXT_bgra) = _glewSearchExtension(\"GL_EXT_bgra\", extStart, extEnd);\n#endif /* GL_EXT_bgra */\n#ifdef GL_EXT_bindable_uniform\n  CONST_CAST(GLEW_EXT_bindable_uniform) = _glewSearchExtension(\"GL_EXT_bindable_uniform\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_bindable_uniform) CONST_CAST(GLEW_EXT_bindable_uniform) = !_glewInit_GL_EXT_bindable_uniform(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_bindable_uniform */\n#ifdef GL_EXT_blend_color\n  CONST_CAST(GLEW_EXT_blend_color) = _glewSearchExtension(\"GL_EXT_blend_color\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_blend_color) CONST_CAST(GLEW_EXT_blend_color) = !_glewInit_GL_EXT_blend_color(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_blend_color */\n#ifdef GL_EXT_blend_equation_separate\n  CONST_CAST(GLEW_EXT_blend_equation_separate) = _glewSearchExtension(\"GL_EXT_blend_equation_separate\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_blend_equation_separate) CONST_CAST(GLEW_EXT_blend_equation_separate) = !_glewInit_GL_EXT_blend_equation_separate(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_blend_equation_separate */\n#ifdef GL_EXT_blend_func_separate\n  CONST_CAST(GLEW_EXT_blend_func_separate) = _glewSearchExtension(\"GL_EXT_blend_func_separate\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_blend_func_separate) CONST_CAST(GLEW_EXT_blend_func_separate) = !_glewInit_GL_EXT_blend_func_separate(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_blend_func_separate */\n#ifdef GL_EXT_blend_logic_op\n  CONST_CAST(GLEW_EXT_blend_logic_op) = _glewSearchExtension(\"GL_EXT_blend_logic_op\", extStart, extEnd);\n#endif /* GL_EXT_blend_logic_op */\n#ifdef GL_EXT_blend_minmax\n  CONST_CAST(GLEW_EXT_blend_minmax) = _glewSearchExtension(\"GL_EXT_blend_minmax\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_blend_minmax) CONST_CAST(GLEW_EXT_blend_minmax) = !_glewInit_GL_EXT_blend_minmax(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_blend_minmax */\n#ifdef GL_EXT_blend_subtract\n  CONST_CAST(GLEW_EXT_blend_subtract) = _glewSearchExtension(\"GL_EXT_blend_subtract\", extStart, extEnd);\n#endif /* GL_EXT_blend_subtract */\n#ifdef GL_EXT_clip_volume_hint\n  CONST_CAST(GLEW_EXT_clip_volume_hint) = _glewSearchExtension(\"GL_EXT_clip_volume_hint\", extStart, extEnd);\n#endif /* GL_EXT_clip_volume_hint */\n#ifdef GL_EXT_cmyka\n  CONST_CAST(GLEW_EXT_cmyka) = _glewSearchExtension(\"GL_EXT_cmyka\", extStart, extEnd);\n#endif /* GL_EXT_cmyka */\n#ifdef GL_EXT_color_subtable\n  CONST_CAST(GLEW_EXT_color_subtable) = _glewSearchExtension(\"GL_EXT_color_subtable\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_color_subtable) CONST_CAST(GLEW_EXT_color_subtable) = !_glewInit_GL_EXT_color_subtable(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_color_subtable */\n#ifdef GL_EXT_compiled_vertex_array\n  CONST_CAST(GLEW_EXT_compiled_vertex_array) = _glewSearchExtension(\"GL_EXT_compiled_vertex_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_compiled_vertex_array) CONST_CAST(GLEW_EXT_compiled_vertex_array) = !_glewInit_GL_EXT_compiled_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_compiled_vertex_array */\n#ifdef GL_EXT_convolution\n  CONST_CAST(GLEW_EXT_convolution) = _glewSearchExtension(\"GL_EXT_convolution\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_convolution) CONST_CAST(GLEW_EXT_convolution) = !_glewInit_GL_EXT_convolution(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_convolution */\n#ifdef GL_EXT_coordinate_frame\n  CONST_CAST(GLEW_EXT_coordinate_frame) = _glewSearchExtension(\"GL_EXT_coordinate_frame\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_coordinate_frame) CONST_CAST(GLEW_EXT_coordinate_frame) = !_glewInit_GL_EXT_coordinate_frame(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_coordinate_frame */\n#ifdef GL_EXT_copy_texture\n  CONST_CAST(GLEW_EXT_copy_texture) = _glewSearchExtension(\"GL_EXT_copy_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_copy_texture) CONST_CAST(GLEW_EXT_copy_texture) = !_glewInit_GL_EXT_copy_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_copy_texture */\n#ifdef GL_EXT_cull_vertex\n  CONST_CAST(GLEW_EXT_cull_vertex) = _glewSearchExtension(\"GL_EXT_cull_vertex\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_cull_vertex) CONST_CAST(GLEW_EXT_cull_vertex) = !_glewInit_GL_EXT_cull_vertex(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_cull_vertex */\n#ifdef GL_EXT_debug_marker\n  CONST_CAST(GLEW_EXT_debug_marker) = _glewSearchExtension(\"GL_EXT_debug_marker\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_debug_marker) CONST_CAST(GLEW_EXT_debug_marker) = !_glewInit_GL_EXT_debug_marker(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_debug_marker */\n#ifdef GL_EXT_depth_bounds_test\n  CONST_CAST(GLEW_EXT_depth_bounds_test) = _glewSearchExtension(\"GL_EXT_depth_bounds_test\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_depth_bounds_test) CONST_CAST(GLEW_EXT_depth_bounds_test) = !_glewInit_GL_EXT_depth_bounds_test(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_depth_bounds_test */\n#ifdef GL_EXT_direct_state_access\n  CONST_CAST(GLEW_EXT_direct_state_access) = _glewSearchExtension(\"GL_EXT_direct_state_access\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_direct_state_access) CONST_CAST(GLEW_EXT_direct_state_access) = !_glewInit_GL_EXT_direct_state_access(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_direct_state_access */\n#ifdef GL_EXT_draw_buffers2\n  CONST_CAST(GLEW_EXT_draw_buffers2) = _glewSearchExtension(\"GL_EXT_draw_buffers2\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_draw_buffers2) CONST_CAST(GLEW_EXT_draw_buffers2) = !_glewInit_GL_EXT_draw_buffers2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_draw_buffers2 */\n#ifdef GL_EXT_draw_instanced\n  CONST_CAST(GLEW_EXT_draw_instanced) = _glewSearchExtension(\"GL_EXT_draw_instanced\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_draw_instanced) CONST_CAST(GLEW_EXT_draw_instanced) = !_glewInit_GL_EXT_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_draw_instanced */\n#ifdef GL_EXT_draw_range_elements\n  CONST_CAST(GLEW_EXT_draw_range_elements) = _glewSearchExtension(\"GL_EXT_draw_range_elements\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_draw_range_elements) CONST_CAST(GLEW_EXT_draw_range_elements) = !_glewInit_GL_EXT_draw_range_elements(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_draw_range_elements */\n#ifdef GL_EXT_fog_coord\n  CONST_CAST(GLEW_EXT_fog_coord) = _glewSearchExtension(\"GL_EXT_fog_coord\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_fog_coord) CONST_CAST(GLEW_EXT_fog_coord) = !_glewInit_GL_EXT_fog_coord(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_fog_coord */\n#ifdef GL_EXT_fragment_lighting\n  CONST_CAST(GLEW_EXT_fragment_lighting) = _glewSearchExtension(\"GL_EXT_fragment_lighting\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_fragment_lighting) CONST_CAST(GLEW_EXT_fragment_lighting) = !_glewInit_GL_EXT_fragment_lighting(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_fragment_lighting */\n#ifdef GL_EXT_framebuffer_blit\n  CONST_CAST(GLEW_EXT_framebuffer_blit) = _glewSearchExtension(\"GL_EXT_framebuffer_blit\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_framebuffer_blit) CONST_CAST(GLEW_EXT_framebuffer_blit) = !_glewInit_GL_EXT_framebuffer_blit(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_framebuffer_blit */\n#ifdef GL_EXT_framebuffer_multisample\n  CONST_CAST(GLEW_EXT_framebuffer_multisample) = _glewSearchExtension(\"GL_EXT_framebuffer_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_framebuffer_multisample) CONST_CAST(GLEW_EXT_framebuffer_multisample) = !_glewInit_GL_EXT_framebuffer_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_framebuffer_multisample */\n#ifdef GL_EXT_framebuffer_multisample_blit_scaled\n  CONST_CAST(GLEW_EXT_framebuffer_multisample_blit_scaled) = _glewSearchExtension(\"GL_EXT_framebuffer_multisample_blit_scaled\", extStart, extEnd);\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n#ifdef GL_EXT_framebuffer_object\n  CONST_CAST(GLEW_EXT_framebuffer_object) = _glewSearchExtension(\"GL_EXT_framebuffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_framebuffer_object) CONST_CAST(GLEW_EXT_framebuffer_object) = !_glewInit_GL_EXT_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_framebuffer_object */\n#ifdef GL_EXT_framebuffer_sRGB\n  CONST_CAST(GLEW_EXT_framebuffer_sRGB) = _glewSearchExtension(\"GL_EXT_framebuffer_sRGB\", extStart, extEnd);\n#endif /* GL_EXT_framebuffer_sRGB */\n#ifdef GL_EXT_geometry_shader4\n  CONST_CAST(GLEW_EXT_geometry_shader4) = _glewSearchExtension(\"GL_EXT_geometry_shader4\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_geometry_shader4) CONST_CAST(GLEW_EXT_geometry_shader4) = !_glewInit_GL_EXT_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_geometry_shader4 */\n#ifdef GL_EXT_gpu_program_parameters\n  CONST_CAST(GLEW_EXT_gpu_program_parameters) = _glewSearchExtension(\"GL_EXT_gpu_program_parameters\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_gpu_program_parameters) CONST_CAST(GLEW_EXT_gpu_program_parameters) = !_glewInit_GL_EXT_gpu_program_parameters(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_gpu_program_parameters */\n#ifdef GL_EXT_gpu_shader4\n  CONST_CAST(GLEW_EXT_gpu_shader4) = _glewSearchExtension(\"GL_EXT_gpu_shader4\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_gpu_shader4) CONST_CAST(GLEW_EXT_gpu_shader4) = !_glewInit_GL_EXT_gpu_shader4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_gpu_shader4 */\n#ifdef GL_EXT_histogram\n  CONST_CAST(GLEW_EXT_histogram) = _glewSearchExtension(\"GL_EXT_histogram\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_histogram) CONST_CAST(GLEW_EXT_histogram) = !_glewInit_GL_EXT_histogram(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_histogram */\n#ifdef GL_EXT_index_array_formats\n  CONST_CAST(GLEW_EXT_index_array_formats) = _glewSearchExtension(\"GL_EXT_index_array_formats\", extStart, extEnd);\n#endif /* GL_EXT_index_array_formats */\n#ifdef GL_EXT_index_func\n  CONST_CAST(GLEW_EXT_index_func) = _glewSearchExtension(\"GL_EXT_index_func\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_index_func) CONST_CAST(GLEW_EXT_index_func) = !_glewInit_GL_EXT_index_func(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_index_func */\n#ifdef GL_EXT_index_material\n  CONST_CAST(GLEW_EXT_index_material) = _glewSearchExtension(\"GL_EXT_index_material\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_index_material) CONST_CAST(GLEW_EXT_index_material) = !_glewInit_GL_EXT_index_material(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_index_material */\n#ifdef GL_EXT_index_texture\n  CONST_CAST(GLEW_EXT_index_texture) = _glewSearchExtension(\"GL_EXT_index_texture\", extStart, extEnd);\n#endif /* GL_EXT_index_texture */\n#ifdef GL_EXT_light_texture\n  CONST_CAST(GLEW_EXT_light_texture) = _glewSearchExtension(\"GL_EXT_light_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_light_texture) CONST_CAST(GLEW_EXT_light_texture) = !_glewInit_GL_EXT_light_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_light_texture */\n#ifdef GL_EXT_misc_attribute\n  CONST_CAST(GLEW_EXT_misc_attribute) = _glewSearchExtension(\"GL_EXT_misc_attribute\", extStart, extEnd);\n#endif /* GL_EXT_misc_attribute */\n#ifdef GL_EXT_multi_draw_arrays\n  CONST_CAST(GLEW_EXT_multi_draw_arrays) = _glewSearchExtension(\"GL_EXT_multi_draw_arrays\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_multi_draw_arrays) CONST_CAST(GLEW_EXT_multi_draw_arrays) = !_glewInit_GL_EXT_multi_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_multi_draw_arrays */\n#ifdef GL_EXT_multisample\n  CONST_CAST(GLEW_EXT_multisample) = _glewSearchExtension(\"GL_EXT_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_multisample) CONST_CAST(GLEW_EXT_multisample) = !_glewInit_GL_EXT_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_multisample */\n#ifdef GL_EXT_packed_depth_stencil\n  CONST_CAST(GLEW_EXT_packed_depth_stencil) = _glewSearchExtension(\"GL_EXT_packed_depth_stencil\", extStart, extEnd);\n#endif /* GL_EXT_packed_depth_stencil */\n#ifdef GL_EXT_packed_float\n  CONST_CAST(GLEW_EXT_packed_float) = _glewSearchExtension(\"GL_EXT_packed_float\", extStart, extEnd);\n#endif /* GL_EXT_packed_float */\n#ifdef GL_EXT_packed_pixels\n  CONST_CAST(GLEW_EXT_packed_pixels) = _glewSearchExtension(\"GL_EXT_packed_pixels\", extStart, extEnd);\n#endif /* GL_EXT_packed_pixels */\n#ifdef GL_EXT_paletted_texture\n  CONST_CAST(GLEW_EXT_paletted_texture) = _glewSearchExtension(\"GL_EXT_paletted_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_paletted_texture) CONST_CAST(GLEW_EXT_paletted_texture) = !_glewInit_GL_EXT_paletted_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_paletted_texture */\n#ifdef GL_EXT_pixel_buffer_object\n  CONST_CAST(GLEW_EXT_pixel_buffer_object) = _glewSearchExtension(\"GL_EXT_pixel_buffer_object\", extStart, extEnd);\n#endif /* GL_EXT_pixel_buffer_object */\n#ifdef GL_EXT_pixel_transform\n  CONST_CAST(GLEW_EXT_pixel_transform) = _glewSearchExtension(\"GL_EXT_pixel_transform\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_pixel_transform) CONST_CAST(GLEW_EXT_pixel_transform) = !_glewInit_GL_EXT_pixel_transform(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_pixel_transform */\n#ifdef GL_EXT_pixel_transform_color_table\n  CONST_CAST(GLEW_EXT_pixel_transform_color_table) = _glewSearchExtension(\"GL_EXT_pixel_transform_color_table\", extStart, extEnd);\n#endif /* GL_EXT_pixel_transform_color_table */\n#ifdef GL_EXT_point_parameters\n  CONST_CAST(GLEW_EXT_point_parameters) = _glewSearchExtension(\"GL_EXT_point_parameters\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_point_parameters) CONST_CAST(GLEW_EXT_point_parameters) = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_point_parameters */\n#ifdef GL_EXT_polygon_offset\n  CONST_CAST(GLEW_EXT_polygon_offset) = _glewSearchExtension(\"GL_EXT_polygon_offset\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_polygon_offset) CONST_CAST(GLEW_EXT_polygon_offset) = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_polygon_offset */\n#ifdef GL_EXT_provoking_vertex\n  CONST_CAST(GLEW_EXT_provoking_vertex) = _glewSearchExtension(\"GL_EXT_provoking_vertex\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_provoking_vertex) CONST_CAST(GLEW_EXT_provoking_vertex) = !_glewInit_GL_EXT_provoking_vertex(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_provoking_vertex */\n#ifdef GL_EXT_rescale_normal\n  CONST_CAST(GLEW_EXT_rescale_normal) = _glewSearchExtension(\"GL_EXT_rescale_normal\", extStart, extEnd);\n#endif /* GL_EXT_rescale_normal */\n#ifdef GL_EXT_scene_marker\n  CONST_CAST(GLEW_EXT_scene_marker) = _glewSearchExtension(\"GL_EXT_scene_marker\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_scene_marker) CONST_CAST(GLEW_EXT_scene_marker) = !_glewInit_GL_EXT_scene_marker(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_scene_marker */\n#ifdef GL_EXT_secondary_color\n  CONST_CAST(GLEW_EXT_secondary_color) = _glewSearchExtension(\"GL_EXT_secondary_color\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_secondary_color) CONST_CAST(GLEW_EXT_secondary_color) = !_glewInit_GL_EXT_secondary_color(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_secondary_color */\n#ifdef GL_EXT_separate_shader_objects\n  CONST_CAST(GLEW_EXT_separate_shader_objects) = _glewSearchExtension(\"GL_EXT_separate_shader_objects\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_separate_shader_objects) CONST_CAST(GLEW_EXT_separate_shader_objects) = !_glewInit_GL_EXT_separate_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_separate_shader_objects */\n#ifdef GL_EXT_separate_specular_color\n  CONST_CAST(GLEW_EXT_separate_specular_color) = _glewSearchExtension(\"GL_EXT_separate_specular_color\", extStart, extEnd);\n#endif /* GL_EXT_separate_specular_color */\n#ifdef GL_EXT_shader_image_load_store\n  CONST_CAST(GLEW_EXT_shader_image_load_store) = _glewSearchExtension(\"GL_EXT_shader_image_load_store\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_shader_image_load_store) CONST_CAST(GLEW_EXT_shader_image_load_store) = !_glewInit_GL_EXT_shader_image_load_store(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_shader_image_load_store */\n#ifdef GL_EXT_shadow_funcs\n  CONST_CAST(GLEW_EXT_shadow_funcs) = _glewSearchExtension(\"GL_EXT_shadow_funcs\", extStart, extEnd);\n#endif /* GL_EXT_shadow_funcs */\n#ifdef GL_EXT_shared_texture_palette\n  CONST_CAST(GLEW_EXT_shared_texture_palette) = _glewSearchExtension(\"GL_EXT_shared_texture_palette\", extStart, extEnd);\n#endif /* GL_EXT_shared_texture_palette */\n#ifdef GL_EXT_stencil_clear_tag\n  CONST_CAST(GLEW_EXT_stencil_clear_tag) = _glewSearchExtension(\"GL_EXT_stencil_clear_tag\", extStart, extEnd);\n#endif /* GL_EXT_stencil_clear_tag */\n#ifdef GL_EXT_stencil_two_side\n  CONST_CAST(GLEW_EXT_stencil_two_side) = _glewSearchExtension(\"GL_EXT_stencil_two_side\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_stencil_two_side) CONST_CAST(GLEW_EXT_stencil_two_side) = !_glewInit_GL_EXT_stencil_two_side(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_stencil_two_side */\n#ifdef GL_EXT_stencil_wrap\n  CONST_CAST(GLEW_EXT_stencil_wrap) = _glewSearchExtension(\"GL_EXT_stencil_wrap\", extStart, extEnd);\n#endif /* GL_EXT_stencil_wrap */\n#ifdef GL_EXT_subtexture\n  CONST_CAST(GLEW_EXT_subtexture) = _glewSearchExtension(\"GL_EXT_subtexture\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_subtexture) CONST_CAST(GLEW_EXT_subtexture) = !_glewInit_GL_EXT_subtexture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_subtexture */\n#ifdef GL_EXT_texture\n  CONST_CAST(GLEW_EXT_texture) = _glewSearchExtension(\"GL_EXT_texture\", extStart, extEnd);\n#endif /* GL_EXT_texture */\n#ifdef GL_EXT_texture3D\n  CONST_CAST(GLEW_EXT_texture3D) = _glewSearchExtension(\"GL_EXT_texture3D\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture3D) CONST_CAST(GLEW_EXT_texture3D) = !_glewInit_GL_EXT_texture3D(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture3D */\n#ifdef GL_EXT_texture_array\n  CONST_CAST(GLEW_EXT_texture_array) = _glewSearchExtension(\"GL_EXT_texture_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture_array) CONST_CAST(GLEW_EXT_texture_array) = !_glewInit_GL_EXT_texture_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture_array */\n#ifdef GL_EXT_texture_buffer_object\n  CONST_CAST(GLEW_EXT_texture_buffer_object) = _glewSearchExtension(\"GL_EXT_texture_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture_buffer_object) CONST_CAST(GLEW_EXT_texture_buffer_object) = !_glewInit_GL_EXT_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture_buffer_object */\n#ifdef GL_EXT_texture_compression_dxt1\n  CONST_CAST(GLEW_EXT_texture_compression_dxt1) = _glewSearchExtension(\"GL_EXT_texture_compression_dxt1\", extStart, extEnd);\n#endif /* GL_EXT_texture_compression_dxt1 */\n#ifdef GL_EXT_texture_compression_latc\n  CONST_CAST(GLEW_EXT_texture_compression_latc) = _glewSearchExtension(\"GL_EXT_texture_compression_latc\", extStart, extEnd);\n#endif /* GL_EXT_texture_compression_latc */\n#ifdef GL_EXT_texture_compression_rgtc\n  CONST_CAST(GLEW_EXT_texture_compression_rgtc) = _glewSearchExtension(\"GL_EXT_texture_compression_rgtc\", extStart, extEnd);\n#endif /* GL_EXT_texture_compression_rgtc */\n#ifdef GL_EXT_texture_compression_s3tc\n  CONST_CAST(GLEW_EXT_texture_compression_s3tc) = _glewSearchExtension(\"GL_EXT_texture_compression_s3tc\", extStart, extEnd);\n#endif /* GL_EXT_texture_compression_s3tc */\n#ifdef GL_EXT_texture_cube_map\n  CONST_CAST(GLEW_EXT_texture_cube_map) = _glewSearchExtension(\"GL_EXT_texture_cube_map\", extStart, extEnd);\n#endif /* GL_EXT_texture_cube_map */\n#ifdef GL_EXT_texture_edge_clamp\n  CONST_CAST(GLEW_EXT_texture_edge_clamp) = _glewSearchExtension(\"GL_EXT_texture_edge_clamp\", extStart, extEnd);\n#endif /* GL_EXT_texture_edge_clamp */\n#ifdef GL_EXT_texture_env\n  CONST_CAST(GLEW_EXT_texture_env) = _glewSearchExtension(\"GL_EXT_texture_env\", extStart, extEnd);\n#endif /* GL_EXT_texture_env */\n#ifdef GL_EXT_texture_env_add\n  CONST_CAST(GLEW_EXT_texture_env_add) = _glewSearchExtension(\"GL_EXT_texture_env_add\", extStart, extEnd);\n#endif /* GL_EXT_texture_env_add */\n#ifdef GL_EXT_texture_env_combine\n  CONST_CAST(GLEW_EXT_texture_env_combine) = _glewSearchExtension(\"GL_EXT_texture_env_combine\", extStart, extEnd);\n#endif /* GL_EXT_texture_env_combine */\n#ifdef GL_EXT_texture_env_dot3\n  CONST_CAST(GLEW_EXT_texture_env_dot3) = _glewSearchExtension(\"GL_EXT_texture_env_dot3\", extStart, extEnd);\n#endif /* GL_EXT_texture_env_dot3 */\n#ifdef GL_EXT_texture_filter_anisotropic\n  CONST_CAST(GLEW_EXT_texture_filter_anisotropic) = _glewSearchExtension(\"GL_EXT_texture_filter_anisotropic\", extStart, extEnd);\n#endif /* GL_EXT_texture_filter_anisotropic */\n#ifdef GL_EXT_texture_integer\n  CONST_CAST(GLEW_EXT_texture_integer) = _glewSearchExtension(\"GL_EXT_texture_integer\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture_integer) CONST_CAST(GLEW_EXT_texture_integer) = !_glewInit_GL_EXT_texture_integer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture_integer */\n#ifdef GL_EXT_texture_lod_bias\n  CONST_CAST(GLEW_EXT_texture_lod_bias) = _glewSearchExtension(\"GL_EXT_texture_lod_bias\", extStart, extEnd);\n#endif /* GL_EXT_texture_lod_bias */\n#ifdef GL_EXT_texture_mirror_clamp\n  CONST_CAST(GLEW_EXT_texture_mirror_clamp) = _glewSearchExtension(\"GL_EXT_texture_mirror_clamp\", extStart, extEnd);\n#endif /* GL_EXT_texture_mirror_clamp */\n#ifdef GL_EXT_texture_object\n  CONST_CAST(GLEW_EXT_texture_object) = _glewSearchExtension(\"GL_EXT_texture_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture_object) CONST_CAST(GLEW_EXT_texture_object) = !_glewInit_GL_EXT_texture_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture_object */\n#ifdef GL_EXT_texture_perturb_normal\n  CONST_CAST(GLEW_EXT_texture_perturb_normal) = _glewSearchExtension(\"GL_EXT_texture_perturb_normal\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_texture_perturb_normal) CONST_CAST(GLEW_EXT_texture_perturb_normal) = !_glewInit_GL_EXT_texture_perturb_normal(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_texture_perturb_normal */\n#ifdef GL_EXT_texture_rectangle\n  CONST_CAST(GLEW_EXT_texture_rectangle) = _glewSearchExtension(\"GL_EXT_texture_rectangle\", extStart, extEnd);\n#endif /* GL_EXT_texture_rectangle */\n#ifdef GL_EXT_texture_sRGB\n  CONST_CAST(GLEW_EXT_texture_sRGB) = _glewSearchExtension(\"GL_EXT_texture_sRGB\", extStart, extEnd);\n#endif /* GL_EXT_texture_sRGB */\n#ifdef GL_EXT_texture_sRGB_decode\n  CONST_CAST(GLEW_EXT_texture_sRGB_decode) = _glewSearchExtension(\"GL_EXT_texture_sRGB_decode\", extStart, extEnd);\n#endif /* GL_EXT_texture_sRGB_decode */\n#ifdef GL_EXT_texture_shared_exponent\n  CONST_CAST(GLEW_EXT_texture_shared_exponent) = _glewSearchExtension(\"GL_EXT_texture_shared_exponent\", extStart, extEnd);\n#endif /* GL_EXT_texture_shared_exponent */\n#ifdef GL_EXT_texture_snorm\n  CONST_CAST(GLEW_EXT_texture_snorm) = _glewSearchExtension(\"GL_EXT_texture_snorm\", extStart, extEnd);\n#endif /* GL_EXT_texture_snorm */\n#ifdef GL_EXT_texture_swizzle\n  CONST_CAST(GLEW_EXT_texture_swizzle) = _glewSearchExtension(\"GL_EXT_texture_swizzle\", extStart, extEnd);\n#endif /* GL_EXT_texture_swizzle */\n#ifdef GL_EXT_timer_query\n  CONST_CAST(GLEW_EXT_timer_query) = _glewSearchExtension(\"GL_EXT_timer_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_timer_query) CONST_CAST(GLEW_EXT_timer_query) = !_glewInit_GL_EXT_timer_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_timer_query */\n#ifdef GL_EXT_transform_feedback\n  CONST_CAST(GLEW_EXT_transform_feedback) = _glewSearchExtension(\"GL_EXT_transform_feedback\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_transform_feedback) CONST_CAST(GLEW_EXT_transform_feedback) = !_glewInit_GL_EXT_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_transform_feedback */\n#ifdef GL_EXT_vertex_array\n  CONST_CAST(GLEW_EXT_vertex_array) = _glewSearchExtension(\"GL_EXT_vertex_array\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_vertex_array) CONST_CAST(GLEW_EXT_vertex_array) = !_glewInit_GL_EXT_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_vertex_array */\n#ifdef GL_EXT_vertex_array_bgra\n  CONST_CAST(GLEW_EXT_vertex_array_bgra) = _glewSearchExtension(\"GL_EXT_vertex_array_bgra\", extStart, extEnd);\n#endif /* GL_EXT_vertex_array_bgra */\n#ifdef GL_EXT_vertex_attrib_64bit\n  CONST_CAST(GLEW_EXT_vertex_attrib_64bit) = _glewSearchExtension(\"GL_EXT_vertex_attrib_64bit\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_vertex_attrib_64bit) CONST_CAST(GLEW_EXT_vertex_attrib_64bit) = !_glewInit_GL_EXT_vertex_attrib_64bit(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_vertex_attrib_64bit */\n#ifdef GL_EXT_vertex_shader\n  CONST_CAST(GLEW_EXT_vertex_shader) = _glewSearchExtension(\"GL_EXT_vertex_shader\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_vertex_shader) CONST_CAST(GLEW_EXT_vertex_shader) = !_glewInit_GL_EXT_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_vertex_shader */\n#ifdef GL_EXT_vertex_weighting\n  CONST_CAST(GLEW_EXT_vertex_weighting) = _glewSearchExtension(\"GL_EXT_vertex_weighting\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_vertex_weighting) CONST_CAST(GLEW_EXT_vertex_weighting) = !_glewInit_GL_EXT_vertex_weighting(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_vertex_weighting */\n#ifdef GL_EXT_x11_sync_object\n  CONST_CAST(GLEW_EXT_x11_sync_object) = _glewSearchExtension(\"GL_EXT_x11_sync_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_EXT_x11_sync_object) CONST_CAST(GLEW_EXT_x11_sync_object) = !_glewInit_GL_EXT_x11_sync_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_EXT_x11_sync_object */\n#ifdef GL_GREMEDY_frame_terminator\n  CONST_CAST(GLEW_GREMEDY_frame_terminator) = _glewSearchExtension(\"GL_GREMEDY_frame_terminator\", extStart, extEnd);\n  if (glewExperimental || GLEW_GREMEDY_frame_terminator) CONST_CAST(GLEW_GREMEDY_frame_terminator) = !_glewInit_GL_GREMEDY_frame_terminator(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_GREMEDY_frame_terminator */\n#ifdef GL_GREMEDY_string_marker\n  CONST_CAST(GLEW_GREMEDY_string_marker) = _glewSearchExtension(\"GL_GREMEDY_string_marker\", extStart, extEnd);\n  if (glewExperimental || GLEW_GREMEDY_string_marker) CONST_CAST(GLEW_GREMEDY_string_marker) = !_glewInit_GL_GREMEDY_string_marker(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_GREMEDY_string_marker */\n#ifdef GL_HP_convolution_border_modes\n  CONST_CAST(GLEW_HP_convolution_border_modes) = _glewSearchExtension(\"GL_HP_convolution_border_modes\", extStart, extEnd);\n#endif /* GL_HP_convolution_border_modes */\n#ifdef GL_HP_image_transform\n  CONST_CAST(GLEW_HP_image_transform) = _glewSearchExtension(\"GL_HP_image_transform\", extStart, extEnd);\n  if (glewExperimental || GLEW_HP_image_transform) CONST_CAST(GLEW_HP_image_transform) = !_glewInit_GL_HP_image_transform(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_HP_image_transform */\n#ifdef GL_HP_occlusion_test\n  CONST_CAST(GLEW_HP_occlusion_test) = _glewSearchExtension(\"GL_HP_occlusion_test\", extStart, extEnd);\n#endif /* GL_HP_occlusion_test */\n#ifdef GL_HP_texture_lighting\n  CONST_CAST(GLEW_HP_texture_lighting) = _glewSearchExtension(\"GL_HP_texture_lighting\", extStart, extEnd);\n#endif /* GL_HP_texture_lighting */\n#ifdef GL_IBM_cull_vertex\n  CONST_CAST(GLEW_IBM_cull_vertex) = _glewSearchExtension(\"GL_IBM_cull_vertex\", extStart, extEnd);\n#endif /* GL_IBM_cull_vertex */\n#ifdef GL_IBM_multimode_draw_arrays\n  CONST_CAST(GLEW_IBM_multimode_draw_arrays) = _glewSearchExtension(\"GL_IBM_multimode_draw_arrays\", extStart, extEnd);\n  if (glewExperimental || GLEW_IBM_multimode_draw_arrays) CONST_CAST(GLEW_IBM_multimode_draw_arrays) = !_glewInit_GL_IBM_multimode_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_IBM_multimode_draw_arrays */\n#ifdef GL_IBM_rasterpos_clip\n  CONST_CAST(GLEW_IBM_rasterpos_clip) = _glewSearchExtension(\"GL_IBM_rasterpos_clip\", extStart, extEnd);\n#endif /* GL_IBM_rasterpos_clip */\n#ifdef GL_IBM_static_data\n  CONST_CAST(GLEW_IBM_static_data) = _glewSearchExtension(\"GL_IBM_static_data\", extStart, extEnd);\n#endif /* GL_IBM_static_data */\n#ifdef GL_IBM_texture_mirrored_repeat\n  CONST_CAST(GLEW_IBM_texture_mirrored_repeat) = _glewSearchExtension(\"GL_IBM_texture_mirrored_repeat\", extStart, extEnd);\n#endif /* GL_IBM_texture_mirrored_repeat */\n#ifdef GL_IBM_vertex_array_lists\n  CONST_CAST(GLEW_IBM_vertex_array_lists) = _glewSearchExtension(\"GL_IBM_vertex_array_lists\", extStart, extEnd);\n  if (glewExperimental || GLEW_IBM_vertex_array_lists) CONST_CAST(GLEW_IBM_vertex_array_lists) = !_glewInit_GL_IBM_vertex_array_lists(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_IBM_vertex_array_lists */\n#ifdef GL_INGR_color_clamp\n  CONST_CAST(GLEW_INGR_color_clamp) = _glewSearchExtension(\"GL_INGR_color_clamp\", extStart, extEnd);\n#endif /* GL_INGR_color_clamp */\n#ifdef GL_INGR_interlace_read\n  CONST_CAST(GLEW_INGR_interlace_read) = _glewSearchExtension(\"GL_INGR_interlace_read\", extStart, extEnd);\n#endif /* GL_INGR_interlace_read */\n#ifdef GL_INTEL_parallel_arrays\n  CONST_CAST(GLEW_INTEL_parallel_arrays) = _glewSearchExtension(\"GL_INTEL_parallel_arrays\", extStart, extEnd);\n  if (glewExperimental || GLEW_INTEL_parallel_arrays) CONST_CAST(GLEW_INTEL_parallel_arrays) = !_glewInit_GL_INTEL_parallel_arrays(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_INTEL_parallel_arrays */\n#ifdef GL_INTEL_texture_scissor\n  CONST_CAST(GLEW_INTEL_texture_scissor) = _glewSearchExtension(\"GL_INTEL_texture_scissor\", extStart, extEnd);\n  if (glewExperimental || GLEW_INTEL_texture_scissor) CONST_CAST(GLEW_INTEL_texture_scissor) = !_glewInit_GL_INTEL_texture_scissor(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_INTEL_texture_scissor */\n#ifdef GL_KHR_debug\n  CONST_CAST(GLEW_KHR_debug) = _glewSearchExtension(\"GL_KHR_debug\", extStart, extEnd);\n  if (glewExperimental || GLEW_KHR_debug) CONST_CAST(GLEW_KHR_debug) = !_glewInit_GL_KHR_debug(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_KHR_debug */\n#ifdef GL_KHR_texture_compression_astc_ldr\n  CONST_CAST(GLEW_KHR_texture_compression_astc_ldr) = _glewSearchExtension(\"GL_KHR_texture_compression_astc_ldr\", extStart, extEnd);\n#endif /* GL_KHR_texture_compression_astc_ldr */\n#ifdef GL_KTX_buffer_region\n  CONST_CAST(GLEW_KTX_buffer_region) = _glewSearchExtension(\"GL_KTX_buffer_region\", extStart, extEnd);\n  if (glewExperimental || GLEW_KTX_buffer_region) CONST_CAST(GLEW_KTX_buffer_region) = !_glewInit_GL_KTX_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_KTX_buffer_region */\n#ifdef GL_MESAX_texture_stack\n  CONST_CAST(GLEW_MESAX_texture_stack) = _glewSearchExtension(\"GL_MESAX_texture_stack\", extStart, extEnd);\n#endif /* GL_MESAX_texture_stack */\n#ifdef GL_MESA_pack_invert\n  CONST_CAST(GLEW_MESA_pack_invert) = _glewSearchExtension(\"GL_MESA_pack_invert\", extStart, extEnd);\n#endif /* GL_MESA_pack_invert */\n#ifdef GL_MESA_resize_buffers\n  CONST_CAST(GLEW_MESA_resize_buffers) = _glewSearchExtension(\"GL_MESA_resize_buffers\", extStart, extEnd);\n  if (glewExperimental || GLEW_MESA_resize_buffers) CONST_CAST(GLEW_MESA_resize_buffers) = !_glewInit_GL_MESA_resize_buffers(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_MESA_resize_buffers */\n#ifdef GL_MESA_window_pos\n  CONST_CAST(GLEW_MESA_window_pos) = _glewSearchExtension(\"GL_MESA_window_pos\", extStart, extEnd);\n  if (glewExperimental || GLEW_MESA_window_pos) CONST_CAST(GLEW_MESA_window_pos) = !_glewInit_GL_MESA_window_pos(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_MESA_window_pos */\n#ifdef GL_MESA_ycbcr_texture\n  CONST_CAST(GLEW_MESA_ycbcr_texture) = _glewSearchExtension(\"GL_MESA_ycbcr_texture\", extStart, extEnd);\n#endif /* GL_MESA_ycbcr_texture */\n#ifdef GL_NVX_gpu_memory_info\n  CONST_CAST(GLEW_NVX_gpu_memory_info) = _glewSearchExtension(\"GL_NVX_gpu_memory_info\", extStart, extEnd);\n#endif /* GL_NVX_gpu_memory_info */\n#ifdef GL_NV_bindless_texture\n  CONST_CAST(GLEW_NV_bindless_texture) = _glewSearchExtension(\"GL_NV_bindless_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_bindless_texture) CONST_CAST(GLEW_NV_bindless_texture) = !_glewInit_GL_NV_bindless_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_bindless_texture */\n#ifdef GL_NV_blend_square\n  CONST_CAST(GLEW_NV_blend_square) = _glewSearchExtension(\"GL_NV_blend_square\", extStart, extEnd);\n#endif /* GL_NV_blend_square */\n#ifdef GL_NV_conditional_render\n  CONST_CAST(GLEW_NV_conditional_render) = _glewSearchExtension(\"GL_NV_conditional_render\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_conditional_render) CONST_CAST(GLEW_NV_conditional_render) = !_glewInit_GL_NV_conditional_render(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_conditional_render */\n#ifdef GL_NV_copy_depth_to_color\n  CONST_CAST(GLEW_NV_copy_depth_to_color) = _glewSearchExtension(\"GL_NV_copy_depth_to_color\", extStart, extEnd);\n#endif /* GL_NV_copy_depth_to_color */\n#ifdef GL_NV_copy_image\n  CONST_CAST(GLEW_NV_copy_image) = _glewSearchExtension(\"GL_NV_copy_image\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_copy_image) CONST_CAST(GLEW_NV_copy_image) = !_glewInit_GL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_copy_image */\n#ifdef GL_NV_depth_buffer_float\n  CONST_CAST(GLEW_NV_depth_buffer_float) = _glewSearchExtension(\"GL_NV_depth_buffer_float\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_depth_buffer_float) CONST_CAST(GLEW_NV_depth_buffer_float) = !_glewInit_GL_NV_depth_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_depth_buffer_float */\n#ifdef GL_NV_depth_clamp\n  CONST_CAST(GLEW_NV_depth_clamp) = _glewSearchExtension(\"GL_NV_depth_clamp\", extStart, extEnd);\n#endif /* GL_NV_depth_clamp */\n#ifdef GL_NV_depth_range_unclamped\n  CONST_CAST(GLEW_NV_depth_range_unclamped) = _glewSearchExtension(\"GL_NV_depth_range_unclamped\", extStart, extEnd);\n#endif /* GL_NV_depth_range_unclamped */\n#ifdef GL_NV_evaluators\n  CONST_CAST(GLEW_NV_evaluators) = _glewSearchExtension(\"GL_NV_evaluators\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_evaluators) CONST_CAST(GLEW_NV_evaluators) = !_glewInit_GL_NV_evaluators(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_evaluators */\n#ifdef GL_NV_explicit_multisample\n  CONST_CAST(GLEW_NV_explicit_multisample) = _glewSearchExtension(\"GL_NV_explicit_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_explicit_multisample) CONST_CAST(GLEW_NV_explicit_multisample) = !_glewInit_GL_NV_explicit_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_explicit_multisample */\n#ifdef GL_NV_fence\n  CONST_CAST(GLEW_NV_fence) = _glewSearchExtension(\"GL_NV_fence\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_fence) CONST_CAST(GLEW_NV_fence) = !_glewInit_GL_NV_fence(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_fence */\n#ifdef GL_NV_float_buffer\n  CONST_CAST(GLEW_NV_float_buffer) = _glewSearchExtension(\"GL_NV_float_buffer\", extStart, extEnd);\n#endif /* GL_NV_float_buffer */\n#ifdef GL_NV_fog_distance\n  CONST_CAST(GLEW_NV_fog_distance) = _glewSearchExtension(\"GL_NV_fog_distance\", extStart, extEnd);\n#endif /* GL_NV_fog_distance */\n#ifdef GL_NV_fragment_program\n  CONST_CAST(GLEW_NV_fragment_program) = _glewSearchExtension(\"GL_NV_fragment_program\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_fragment_program) CONST_CAST(GLEW_NV_fragment_program) = !_glewInit_GL_NV_fragment_program(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_fragment_program */\n#ifdef GL_NV_fragment_program2\n  CONST_CAST(GLEW_NV_fragment_program2) = _glewSearchExtension(\"GL_NV_fragment_program2\", extStart, extEnd);\n#endif /* GL_NV_fragment_program2 */\n#ifdef GL_NV_fragment_program4\n  CONST_CAST(GLEW_NV_fragment_program4) = _glewSearchExtension(\"GL_NV_gpu_program4\", extStart, extEnd);\n#endif /* GL_NV_fragment_program4 */\n#ifdef GL_NV_fragment_program_option\n  CONST_CAST(GLEW_NV_fragment_program_option) = _glewSearchExtension(\"GL_NV_fragment_program_option\", extStart, extEnd);\n#endif /* GL_NV_fragment_program_option */\n#ifdef GL_NV_framebuffer_multisample_coverage\n  CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = _glewSearchExtension(\"GL_NV_framebuffer_multisample_coverage\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_framebuffer_multisample_coverage) CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = !_glewInit_GL_NV_framebuffer_multisample_coverage(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_framebuffer_multisample_coverage */\n#ifdef GL_NV_geometry_program4\n  CONST_CAST(GLEW_NV_geometry_program4) = _glewSearchExtension(\"GL_NV_gpu_program4\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_geometry_program4) CONST_CAST(GLEW_NV_geometry_program4) = !_glewInit_GL_NV_geometry_program4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_geometry_program4 */\n#ifdef GL_NV_geometry_shader4\n  CONST_CAST(GLEW_NV_geometry_shader4) = _glewSearchExtension(\"GL_NV_geometry_shader4\", extStart, extEnd);\n#endif /* GL_NV_geometry_shader4 */\n#ifdef GL_NV_gpu_program4\n  CONST_CAST(GLEW_NV_gpu_program4) = _glewSearchExtension(\"GL_NV_gpu_program4\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_gpu_program4) CONST_CAST(GLEW_NV_gpu_program4) = !_glewInit_GL_NV_gpu_program4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_gpu_program4 */\n#ifdef GL_NV_gpu_program5\n  CONST_CAST(GLEW_NV_gpu_program5) = _glewSearchExtension(\"GL_NV_gpu_program5\", extStart, extEnd);\n#endif /* GL_NV_gpu_program5 */\n#ifdef GL_NV_gpu_program_fp64\n  CONST_CAST(GLEW_NV_gpu_program_fp64) = _glewSearchExtension(\"GL_NV_gpu_program_fp64\", extStart, extEnd);\n#endif /* GL_NV_gpu_program_fp64 */\n#ifdef GL_NV_gpu_shader5\n  CONST_CAST(GLEW_NV_gpu_shader5) = _glewSearchExtension(\"GL_NV_gpu_shader5\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_gpu_shader5) CONST_CAST(GLEW_NV_gpu_shader5) = !_glewInit_GL_NV_gpu_shader5(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_gpu_shader5 */\n#ifdef GL_NV_half_float\n  CONST_CAST(GLEW_NV_half_float) = _glewSearchExtension(\"GL_NV_half_float\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_half_float) CONST_CAST(GLEW_NV_half_float) = !_glewInit_GL_NV_half_float(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_half_float */\n#ifdef GL_NV_light_max_exponent\n  CONST_CAST(GLEW_NV_light_max_exponent) = _glewSearchExtension(\"GL_NV_light_max_exponent\", extStart, extEnd);\n#endif /* GL_NV_light_max_exponent */\n#ifdef GL_NV_multisample_coverage\n  CONST_CAST(GLEW_NV_multisample_coverage) = _glewSearchExtension(\"GL_NV_multisample_coverage\", extStart, extEnd);\n#endif /* GL_NV_multisample_coverage */\n#ifdef GL_NV_multisample_filter_hint\n  CONST_CAST(GLEW_NV_multisample_filter_hint) = _glewSearchExtension(\"GL_NV_multisample_filter_hint\", extStart, extEnd);\n#endif /* GL_NV_multisample_filter_hint */\n#ifdef GL_NV_occlusion_query\n  CONST_CAST(GLEW_NV_occlusion_query) = _glewSearchExtension(\"GL_NV_occlusion_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_occlusion_query) CONST_CAST(GLEW_NV_occlusion_query) = !_glewInit_GL_NV_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_occlusion_query */\n#ifdef GL_NV_packed_depth_stencil\n  CONST_CAST(GLEW_NV_packed_depth_stencil) = _glewSearchExtension(\"GL_NV_packed_depth_stencil\", extStart, extEnd);\n#endif /* GL_NV_packed_depth_stencil */\n#ifdef GL_NV_parameter_buffer_object\n  CONST_CAST(GLEW_NV_parameter_buffer_object) = _glewSearchExtension(\"GL_NV_parameter_buffer_object\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_parameter_buffer_object) CONST_CAST(GLEW_NV_parameter_buffer_object) = !_glewInit_GL_NV_parameter_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_parameter_buffer_object */\n#ifdef GL_NV_parameter_buffer_object2\n  CONST_CAST(GLEW_NV_parameter_buffer_object2) = _glewSearchExtension(\"GL_NV_parameter_buffer_object2\", extStart, extEnd);\n#endif /* GL_NV_parameter_buffer_object2 */\n#ifdef GL_NV_path_rendering\n  CONST_CAST(GLEW_NV_path_rendering) = _glewSearchExtension(\"GL_NV_path_rendering\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_path_rendering) CONST_CAST(GLEW_NV_path_rendering) = !_glewInit_GL_NV_path_rendering(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_path_rendering */\n#ifdef GL_NV_pixel_data_range\n  CONST_CAST(GLEW_NV_pixel_data_range) = _glewSearchExtension(\"GL_NV_pixel_data_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_pixel_data_range) CONST_CAST(GLEW_NV_pixel_data_range) = !_glewInit_GL_NV_pixel_data_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_pixel_data_range */\n#ifdef GL_NV_point_sprite\n  CONST_CAST(GLEW_NV_point_sprite) = _glewSearchExtension(\"GL_NV_point_sprite\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_point_sprite) CONST_CAST(GLEW_NV_point_sprite) = !_glewInit_GL_NV_point_sprite(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_point_sprite */\n#ifdef GL_NV_present_video\n  CONST_CAST(GLEW_NV_present_video) = _glewSearchExtension(\"GL_NV_present_video\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_present_video) CONST_CAST(GLEW_NV_present_video) = !_glewInit_GL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_present_video */\n#ifdef GL_NV_primitive_restart\n  CONST_CAST(GLEW_NV_primitive_restart) = _glewSearchExtension(\"GL_NV_primitive_restart\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_primitive_restart) CONST_CAST(GLEW_NV_primitive_restart) = !_glewInit_GL_NV_primitive_restart(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_primitive_restart */\n#ifdef GL_NV_register_combiners\n  CONST_CAST(GLEW_NV_register_combiners) = _glewSearchExtension(\"GL_NV_register_combiners\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_register_combiners) CONST_CAST(GLEW_NV_register_combiners) = !_glewInit_GL_NV_register_combiners(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_register_combiners */\n#ifdef GL_NV_register_combiners2\n  CONST_CAST(GLEW_NV_register_combiners2) = _glewSearchExtension(\"GL_NV_register_combiners2\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_register_combiners2) CONST_CAST(GLEW_NV_register_combiners2) = !_glewInit_GL_NV_register_combiners2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_register_combiners2 */\n#ifdef GL_NV_shader_atomic_float\n  CONST_CAST(GLEW_NV_shader_atomic_float) = _glewSearchExtension(\"GL_NV_shader_atomic_float\", extStart, extEnd);\n#endif /* GL_NV_shader_atomic_float */\n#ifdef GL_NV_shader_buffer_load\n  CONST_CAST(GLEW_NV_shader_buffer_load) = _glewSearchExtension(\"GL_NV_shader_buffer_load\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_shader_buffer_load) CONST_CAST(GLEW_NV_shader_buffer_load) = !_glewInit_GL_NV_shader_buffer_load(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_shader_buffer_load */\n#ifdef GL_NV_tessellation_program5\n  CONST_CAST(GLEW_NV_tessellation_program5) = _glewSearchExtension(\"GL_NV_gpu_program5\", extStart, extEnd);\n#endif /* GL_NV_tessellation_program5 */\n#ifdef GL_NV_texgen_emboss\n  CONST_CAST(GLEW_NV_texgen_emboss) = _glewSearchExtension(\"GL_NV_texgen_emboss\", extStart, extEnd);\n#endif /* GL_NV_texgen_emboss */\n#ifdef GL_NV_texgen_reflection\n  CONST_CAST(GLEW_NV_texgen_reflection) = _glewSearchExtension(\"GL_NV_texgen_reflection\", extStart, extEnd);\n#endif /* GL_NV_texgen_reflection */\n#ifdef GL_NV_texture_barrier\n  CONST_CAST(GLEW_NV_texture_barrier) = _glewSearchExtension(\"GL_NV_texture_barrier\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_texture_barrier) CONST_CAST(GLEW_NV_texture_barrier) = !_glewInit_GL_NV_texture_barrier(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_texture_barrier */\n#ifdef GL_NV_texture_compression_vtc\n  CONST_CAST(GLEW_NV_texture_compression_vtc) = _glewSearchExtension(\"GL_NV_texture_compression_vtc\", extStart, extEnd);\n#endif /* GL_NV_texture_compression_vtc */\n#ifdef GL_NV_texture_env_combine4\n  CONST_CAST(GLEW_NV_texture_env_combine4) = _glewSearchExtension(\"GL_NV_texture_env_combine4\", extStart, extEnd);\n#endif /* GL_NV_texture_env_combine4 */\n#ifdef GL_NV_texture_expand_normal\n  CONST_CAST(GLEW_NV_texture_expand_normal) = _glewSearchExtension(\"GL_NV_texture_expand_normal\", extStart, extEnd);\n#endif /* GL_NV_texture_expand_normal */\n#ifdef GL_NV_texture_multisample\n  CONST_CAST(GLEW_NV_texture_multisample) = _glewSearchExtension(\"GL_NV_texture_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_texture_multisample) CONST_CAST(GLEW_NV_texture_multisample) = !_glewInit_GL_NV_texture_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_texture_multisample */\n#ifdef GL_NV_texture_rectangle\n  CONST_CAST(GLEW_NV_texture_rectangle) = _glewSearchExtension(\"GL_NV_texture_rectangle\", extStart, extEnd);\n#endif /* GL_NV_texture_rectangle */\n#ifdef GL_NV_texture_shader\n  CONST_CAST(GLEW_NV_texture_shader) = _glewSearchExtension(\"GL_NV_texture_shader\", extStart, extEnd);\n#endif /* GL_NV_texture_shader */\n#ifdef GL_NV_texture_shader2\n  CONST_CAST(GLEW_NV_texture_shader2) = _glewSearchExtension(\"GL_NV_texture_shader2\", extStart, extEnd);\n#endif /* GL_NV_texture_shader2 */\n#ifdef GL_NV_texture_shader3\n  CONST_CAST(GLEW_NV_texture_shader3) = _glewSearchExtension(\"GL_NV_texture_shader3\", extStart, extEnd);\n#endif /* GL_NV_texture_shader3 */\n#ifdef GL_NV_transform_feedback\n  CONST_CAST(GLEW_NV_transform_feedback) = _glewSearchExtension(\"GL_NV_transform_feedback\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_transform_feedback) CONST_CAST(GLEW_NV_transform_feedback) = !_glewInit_GL_NV_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_transform_feedback */\n#ifdef GL_NV_transform_feedback2\n  CONST_CAST(GLEW_NV_transform_feedback2) = _glewSearchExtension(\"GL_NV_transform_feedback2\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_transform_feedback2) CONST_CAST(GLEW_NV_transform_feedback2) = !_glewInit_GL_NV_transform_feedback2(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_transform_feedback2 */\n#ifdef GL_NV_vdpau_interop\n  CONST_CAST(GLEW_NV_vdpau_interop) = _glewSearchExtension(\"GL_NV_vdpau_interop\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_vdpau_interop) CONST_CAST(GLEW_NV_vdpau_interop) = !_glewInit_GL_NV_vdpau_interop(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_vdpau_interop */\n#ifdef GL_NV_vertex_array_range\n  CONST_CAST(GLEW_NV_vertex_array_range) = _glewSearchExtension(\"GL_NV_vertex_array_range\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_vertex_array_range) CONST_CAST(GLEW_NV_vertex_array_range) = !_glewInit_GL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_vertex_array_range */\n#ifdef GL_NV_vertex_array_range2\n  CONST_CAST(GLEW_NV_vertex_array_range2) = _glewSearchExtension(\"GL_NV_vertex_array_range2\", extStart, extEnd);\n#endif /* GL_NV_vertex_array_range2 */\n#ifdef GL_NV_vertex_attrib_integer_64bit\n  CONST_CAST(GLEW_NV_vertex_attrib_integer_64bit) = _glewSearchExtension(\"GL_NV_vertex_attrib_integer_64bit\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_vertex_attrib_integer_64bit) CONST_CAST(GLEW_NV_vertex_attrib_integer_64bit) = !_glewInit_GL_NV_vertex_attrib_integer_64bit(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n#ifdef GL_NV_vertex_buffer_unified_memory\n  CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = _glewSearchExtension(\"GL_NV_vertex_buffer_unified_memory\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_vertex_buffer_unified_memory) CONST_CAST(GLEW_NV_vertex_buffer_unified_memory) = !_glewInit_GL_NV_vertex_buffer_unified_memory(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_vertex_buffer_unified_memory */\n#ifdef GL_NV_vertex_program\n  CONST_CAST(GLEW_NV_vertex_program) = _glewSearchExtension(\"GL_NV_vertex_program\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_vertex_program) CONST_CAST(GLEW_NV_vertex_program) = !_glewInit_GL_NV_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_vertex_program */\n#ifdef GL_NV_vertex_program1_1\n  CONST_CAST(GLEW_NV_vertex_program1_1) = _glewSearchExtension(\"GL_NV_vertex_program1_1\", extStart, extEnd);\n#endif /* GL_NV_vertex_program1_1 */\n#ifdef GL_NV_vertex_program2\n  CONST_CAST(GLEW_NV_vertex_program2) = _glewSearchExtension(\"GL_NV_vertex_program2\", extStart, extEnd);\n#endif /* GL_NV_vertex_program2 */\n#ifdef GL_NV_vertex_program2_option\n  CONST_CAST(GLEW_NV_vertex_program2_option) = _glewSearchExtension(\"GL_NV_vertex_program2_option\", extStart, extEnd);\n#endif /* GL_NV_vertex_program2_option */\n#ifdef GL_NV_vertex_program3\n  CONST_CAST(GLEW_NV_vertex_program3) = _glewSearchExtension(\"GL_NV_vertex_program3\", extStart, extEnd);\n#endif /* GL_NV_vertex_program3 */\n#ifdef GL_NV_vertex_program4\n  CONST_CAST(GLEW_NV_vertex_program4) = _glewSearchExtension(\"GL_NV_gpu_program4\", extStart, extEnd);\n#endif /* GL_NV_vertex_program4 */\n#ifdef GL_NV_video_capture\n  CONST_CAST(GLEW_NV_video_capture) = _glewSearchExtension(\"GL_NV_video_capture\", extStart, extEnd);\n  if (glewExperimental || GLEW_NV_video_capture) CONST_CAST(GLEW_NV_video_capture) = !_glewInit_GL_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_NV_video_capture */\n#ifdef GL_OES_byte_coordinates\n  CONST_CAST(GLEW_OES_byte_coordinates) = _glewSearchExtension(\"GL_OES_byte_coordinates\", extStart, extEnd);\n#endif /* GL_OES_byte_coordinates */\n#ifdef GL_OES_compressed_paletted_texture\n  CONST_CAST(GLEW_OES_compressed_paletted_texture) = _glewSearchExtension(\"GL_OES_compressed_paletted_texture\", extStart, extEnd);\n#endif /* GL_OES_compressed_paletted_texture */\n#ifdef GL_OES_read_format\n  CONST_CAST(GLEW_OES_read_format) = _glewSearchExtension(\"GL_OES_read_format\", extStart, extEnd);\n#endif /* GL_OES_read_format */\n#ifdef GL_OES_single_precision\n  CONST_CAST(GLEW_OES_single_precision) = _glewSearchExtension(\"GL_OES_single_precision\", extStart, extEnd);\n  if (glewExperimental || GLEW_OES_single_precision) CONST_CAST(GLEW_OES_single_precision) = !_glewInit_GL_OES_single_precision(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_OES_single_precision */\n#ifdef GL_OML_interlace\n  CONST_CAST(GLEW_OML_interlace) = _glewSearchExtension(\"GL_OML_interlace\", extStart, extEnd);\n#endif /* GL_OML_interlace */\n#ifdef GL_OML_resample\n  CONST_CAST(GLEW_OML_resample) = _glewSearchExtension(\"GL_OML_resample\", extStart, extEnd);\n#endif /* GL_OML_resample */\n#ifdef GL_OML_subsample\n  CONST_CAST(GLEW_OML_subsample) = _glewSearchExtension(\"GL_OML_subsample\", extStart, extEnd);\n#endif /* GL_OML_subsample */\n#ifdef GL_PGI_misc_hints\n  CONST_CAST(GLEW_PGI_misc_hints) = _glewSearchExtension(\"GL_PGI_misc_hints\", extStart, extEnd);\n#endif /* GL_PGI_misc_hints */\n#ifdef GL_PGI_vertex_hints\n  CONST_CAST(GLEW_PGI_vertex_hints) = _glewSearchExtension(\"GL_PGI_vertex_hints\", extStart, extEnd);\n#endif /* GL_PGI_vertex_hints */\n#ifdef GL_REGAL_error_string\n  CONST_CAST(GLEW_REGAL_error_string) = _glewSearchExtension(\"GL_REGAL_error_string\", extStart, extEnd);\n  if (glewExperimental || GLEW_REGAL_error_string) CONST_CAST(GLEW_REGAL_error_string) = !_glewInit_GL_REGAL_error_string(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_REGAL_error_string */\n#ifdef GL_REGAL_extension_query\n  CONST_CAST(GLEW_REGAL_extension_query) = _glewSearchExtension(\"GL_REGAL_extension_query\", extStart, extEnd);\n  if (glewExperimental || GLEW_REGAL_extension_query) CONST_CAST(GLEW_REGAL_extension_query) = !_glewInit_GL_REGAL_extension_query(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_REGAL_extension_query */\n#ifdef GL_REGAL_log\n  CONST_CAST(GLEW_REGAL_log) = _glewSearchExtension(\"GL_REGAL_log\", extStart, extEnd);\n#endif /* GL_REGAL_log */\n#ifdef GL_REND_screen_coordinates\n  CONST_CAST(GLEW_REND_screen_coordinates) = _glewSearchExtension(\"GL_REND_screen_coordinates\", extStart, extEnd);\n#endif /* GL_REND_screen_coordinates */\n#ifdef GL_S3_s3tc\n  CONST_CAST(GLEW_S3_s3tc) = _glewSearchExtension(\"GL_S3_s3tc\", extStart, extEnd);\n#endif /* GL_S3_s3tc */\n#ifdef GL_SGIS_color_range\n  CONST_CAST(GLEW_SGIS_color_range) = _glewSearchExtension(\"GL_SGIS_color_range\", extStart, extEnd);\n#endif /* GL_SGIS_color_range */\n#ifdef GL_SGIS_detail_texture\n  CONST_CAST(GLEW_SGIS_detail_texture) = _glewSearchExtension(\"GL_SGIS_detail_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_detail_texture) CONST_CAST(GLEW_SGIS_detail_texture) = !_glewInit_GL_SGIS_detail_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_detail_texture */\n#ifdef GL_SGIS_fog_function\n  CONST_CAST(GLEW_SGIS_fog_function) = _glewSearchExtension(\"GL_SGIS_fog_function\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_fog_function) CONST_CAST(GLEW_SGIS_fog_function) = !_glewInit_GL_SGIS_fog_function(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_fog_function */\n#ifdef GL_SGIS_generate_mipmap\n  CONST_CAST(GLEW_SGIS_generate_mipmap) = _glewSearchExtension(\"GL_SGIS_generate_mipmap\", extStart, extEnd);\n#endif /* GL_SGIS_generate_mipmap */\n#ifdef GL_SGIS_multisample\n  CONST_CAST(GLEW_SGIS_multisample) = _glewSearchExtension(\"GL_SGIS_multisample\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_multisample) CONST_CAST(GLEW_SGIS_multisample) = !_glewInit_GL_SGIS_multisample(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_multisample */\n#ifdef GL_SGIS_pixel_texture\n  CONST_CAST(GLEW_SGIS_pixel_texture) = _glewSearchExtension(\"GL_SGIS_pixel_texture\", extStart, extEnd);\n#endif /* GL_SGIS_pixel_texture */\n#ifdef GL_SGIS_point_line_texgen\n  CONST_CAST(GLEW_SGIS_point_line_texgen) = _glewSearchExtension(\"GL_SGIS_point_line_texgen\", extStart, extEnd);\n#endif /* GL_SGIS_point_line_texgen */\n#ifdef GL_SGIS_sharpen_texture\n  CONST_CAST(GLEW_SGIS_sharpen_texture) = _glewSearchExtension(\"GL_SGIS_sharpen_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_sharpen_texture) CONST_CAST(GLEW_SGIS_sharpen_texture) = !_glewInit_GL_SGIS_sharpen_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_sharpen_texture */\n#ifdef GL_SGIS_texture4D\n  CONST_CAST(GLEW_SGIS_texture4D) = _glewSearchExtension(\"GL_SGIS_texture4D\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_texture4D) CONST_CAST(GLEW_SGIS_texture4D) = !_glewInit_GL_SGIS_texture4D(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_texture4D */\n#ifdef GL_SGIS_texture_border_clamp\n  CONST_CAST(GLEW_SGIS_texture_border_clamp) = _glewSearchExtension(\"GL_SGIS_texture_border_clamp\", extStart, extEnd);\n#endif /* GL_SGIS_texture_border_clamp */\n#ifdef GL_SGIS_texture_edge_clamp\n  CONST_CAST(GLEW_SGIS_texture_edge_clamp) = _glewSearchExtension(\"GL_SGIS_texture_edge_clamp\", extStart, extEnd);\n#endif /* GL_SGIS_texture_edge_clamp */\n#ifdef GL_SGIS_texture_filter4\n  CONST_CAST(GLEW_SGIS_texture_filter4) = _glewSearchExtension(\"GL_SGIS_texture_filter4\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIS_texture_filter4) CONST_CAST(GLEW_SGIS_texture_filter4) = !_glewInit_GL_SGIS_texture_filter4(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIS_texture_filter4 */\n#ifdef GL_SGIS_texture_lod\n  CONST_CAST(GLEW_SGIS_texture_lod) = _glewSearchExtension(\"GL_SGIS_texture_lod\", extStart, extEnd);\n#endif /* GL_SGIS_texture_lod */\n#ifdef GL_SGIS_texture_select\n  CONST_CAST(GLEW_SGIS_texture_select) = _glewSearchExtension(\"GL_SGIS_texture_select\", extStart, extEnd);\n#endif /* GL_SGIS_texture_select */\n#ifdef GL_SGIX_async\n  CONST_CAST(GLEW_SGIX_async) = _glewSearchExtension(\"GL_SGIX_async\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_async) CONST_CAST(GLEW_SGIX_async) = !_glewInit_GL_SGIX_async(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_async */\n#ifdef GL_SGIX_async_histogram\n  CONST_CAST(GLEW_SGIX_async_histogram) = _glewSearchExtension(\"GL_SGIX_async_histogram\", extStart, extEnd);\n#endif /* GL_SGIX_async_histogram */\n#ifdef GL_SGIX_async_pixel\n  CONST_CAST(GLEW_SGIX_async_pixel) = _glewSearchExtension(\"GL_SGIX_async_pixel\", extStart, extEnd);\n#endif /* GL_SGIX_async_pixel */\n#ifdef GL_SGIX_blend_alpha_minmax\n  CONST_CAST(GLEW_SGIX_blend_alpha_minmax) = _glewSearchExtension(\"GL_SGIX_blend_alpha_minmax\", extStart, extEnd);\n#endif /* GL_SGIX_blend_alpha_minmax */\n#ifdef GL_SGIX_clipmap\n  CONST_CAST(GLEW_SGIX_clipmap) = _glewSearchExtension(\"GL_SGIX_clipmap\", extStart, extEnd);\n#endif /* GL_SGIX_clipmap */\n#ifdef GL_SGIX_convolution_accuracy\n  CONST_CAST(GLEW_SGIX_convolution_accuracy) = _glewSearchExtension(\"GL_SGIX_convolution_accuracy\", extStart, extEnd);\n#endif /* GL_SGIX_convolution_accuracy */\n#ifdef GL_SGIX_depth_texture\n  CONST_CAST(GLEW_SGIX_depth_texture) = _glewSearchExtension(\"GL_SGIX_depth_texture\", extStart, extEnd);\n#endif /* GL_SGIX_depth_texture */\n#ifdef GL_SGIX_flush_raster\n  CONST_CAST(GLEW_SGIX_flush_raster) = _glewSearchExtension(\"GL_SGIX_flush_raster\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_flush_raster) CONST_CAST(GLEW_SGIX_flush_raster) = !_glewInit_GL_SGIX_flush_raster(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_flush_raster */\n#ifdef GL_SGIX_fog_offset\n  CONST_CAST(GLEW_SGIX_fog_offset) = _glewSearchExtension(\"GL_SGIX_fog_offset\", extStart, extEnd);\n#endif /* GL_SGIX_fog_offset */\n#ifdef GL_SGIX_fog_texture\n  CONST_CAST(GLEW_SGIX_fog_texture) = _glewSearchExtension(\"GL_SGIX_fog_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_fog_texture) CONST_CAST(GLEW_SGIX_fog_texture) = !_glewInit_GL_SGIX_fog_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_fog_texture */\n#ifdef GL_SGIX_fragment_specular_lighting\n  CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = _glewSearchExtension(\"GL_SGIX_fragment_specular_lighting\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_fragment_specular_lighting) CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = !_glewInit_GL_SGIX_fragment_specular_lighting(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_fragment_specular_lighting */\n#ifdef GL_SGIX_framezoom\n  CONST_CAST(GLEW_SGIX_framezoom) = _glewSearchExtension(\"GL_SGIX_framezoom\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_framezoom) CONST_CAST(GLEW_SGIX_framezoom) = !_glewInit_GL_SGIX_framezoom(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_framezoom */\n#ifdef GL_SGIX_interlace\n  CONST_CAST(GLEW_SGIX_interlace) = _glewSearchExtension(\"GL_SGIX_interlace\", extStart, extEnd);\n#endif /* GL_SGIX_interlace */\n#ifdef GL_SGIX_ir_instrument1\n  CONST_CAST(GLEW_SGIX_ir_instrument1) = _glewSearchExtension(\"GL_SGIX_ir_instrument1\", extStart, extEnd);\n#endif /* GL_SGIX_ir_instrument1 */\n#ifdef GL_SGIX_list_priority\n  CONST_CAST(GLEW_SGIX_list_priority) = _glewSearchExtension(\"GL_SGIX_list_priority\", extStart, extEnd);\n#endif /* GL_SGIX_list_priority */\n#ifdef GL_SGIX_pixel_texture\n  CONST_CAST(GLEW_SGIX_pixel_texture) = _glewSearchExtension(\"GL_SGIX_pixel_texture\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_pixel_texture) CONST_CAST(GLEW_SGIX_pixel_texture) = !_glewInit_GL_SGIX_pixel_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_pixel_texture */\n#ifdef GL_SGIX_pixel_texture_bits\n  CONST_CAST(GLEW_SGIX_pixel_texture_bits) = _glewSearchExtension(\"GL_SGIX_pixel_texture_bits\", extStart, extEnd);\n#endif /* GL_SGIX_pixel_texture_bits */\n#ifdef GL_SGIX_reference_plane\n  CONST_CAST(GLEW_SGIX_reference_plane) = _glewSearchExtension(\"GL_SGIX_reference_plane\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_reference_plane) CONST_CAST(GLEW_SGIX_reference_plane) = !_glewInit_GL_SGIX_reference_plane(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_reference_plane */\n#ifdef GL_SGIX_resample\n  CONST_CAST(GLEW_SGIX_resample) = _glewSearchExtension(\"GL_SGIX_resample\", extStart, extEnd);\n#endif /* GL_SGIX_resample */\n#ifdef GL_SGIX_shadow\n  CONST_CAST(GLEW_SGIX_shadow) = _glewSearchExtension(\"GL_SGIX_shadow\", extStart, extEnd);\n#endif /* GL_SGIX_shadow */\n#ifdef GL_SGIX_shadow_ambient\n  CONST_CAST(GLEW_SGIX_shadow_ambient) = _glewSearchExtension(\"GL_SGIX_shadow_ambient\", extStart, extEnd);\n#endif /* GL_SGIX_shadow_ambient */\n#ifdef GL_SGIX_sprite\n  CONST_CAST(GLEW_SGIX_sprite) = _glewSearchExtension(\"GL_SGIX_sprite\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_sprite) CONST_CAST(GLEW_SGIX_sprite) = !_glewInit_GL_SGIX_sprite(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_sprite */\n#ifdef GL_SGIX_tag_sample_buffer\n  CONST_CAST(GLEW_SGIX_tag_sample_buffer) = _glewSearchExtension(\"GL_SGIX_tag_sample_buffer\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGIX_tag_sample_buffer) CONST_CAST(GLEW_SGIX_tag_sample_buffer) = !_glewInit_GL_SGIX_tag_sample_buffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGIX_tag_sample_buffer */\n#ifdef GL_SGIX_texture_add_env\n  CONST_CAST(GLEW_SGIX_texture_add_env) = _glewSearchExtension(\"GL_SGIX_texture_add_env\", extStart, extEnd);\n#endif /* GL_SGIX_texture_add_env */\n#ifdef GL_SGIX_texture_coordinate_clamp\n  CONST_CAST(GLEW_SGIX_texture_coordinate_clamp) = _glewSearchExtension(\"GL_SGIX_texture_coordinate_clamp\", extStart, extEnd);\n#endif /* GL_SGIX_texture_coordinate_clamp */\n#ifdef GL_SGIX_texture_lod_bias\n  CONST_CAST(GLEW_SGIX_texture_lod_bias) = _glewSearchExtension(\"GL_SGIX_texture_lod_bias\", extStart, extEnd);\n#endif /* GL_SGIX_texture_lod_bias */\n#ifdef GL_SGIX_texture_multi_buffer\n  CONST_CAST(GLEW_SGIX_texture_multi_buffer) = _glewSearchExtension(\"GL_SGIX_texture_multi_buffer\", extStart, extEnd);\n#endif /* GL_SGIX_texture_multi_buffer */\n#ifdef GL_SGIX_texture_range\n  CONST_CAST(GLEW_SGIX_texture_range) = _glewSearchExtension(\"GL_SGIX_texture_range\", extStart, extEnd);\n#endif /* GL_SGIX_texture_range */\n#ifdef GL_SGIX_texture_scale_bias\n  CONST_CAST(GLEW_SGIX_texture_scale_bias) = _glewSearchExtension(\"GL_SGIX_texture_scale_bias\", extStart, extEnd);\n#endif /* GL_SGIX_texture_scale_bias */\n#ifdef GL_SGIX_vertex_preclip\n  CONST_CAST(GLEW_SGIX_vertex_preclip) = _glewSearchExtension(\"GL_SGIX_vertex_preclip\", extStart, extEnd);\n#endif /* GL_SGIX_vertex_preclip */\n#ifdef GL_SGIX_vertex_preclip_hint\n  CONST_CAST(GLEW_SGIX_vertex_preclip_hint) = _glewSearchExtension(\"GL_SGIX_vertex_preclip_hint\", extStart, extEnd);\n#endif /* GL_SGIX_vertex_preclip_hint */\n#ifdef GL_SGIX_ycrcb\n  CONST_CAST(GLEW_SGIX_ycrcb) = _glewSearchExtension(\"GL_SGIX_ycrcb\", extStart, extEnd);\n#endif /* GL_SGIX_ycrcb */\n#ifdef GL_SGI_color_matrix\n  CONST_CAST(GLEW_SGI_color_matrix) = _glewSearchExtension(\"GL_SGI_color_matrix\", extStart, extEnd);\n#endif /* GL_SGI_color_matrix */\n#ifdef GL_SGI_color_table\n  CONST_CAST(GLEW_SGI_color_table) = _glewSearchExtension(\"GL_SGI_color_table\", extStart, extEnd);\n  if (glewExperimental || GLEW_SGI_color_table) CONST_CAST(GLEW_SGI_color_table) = !_glewInit_GL_SGI_color_table(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SGI_color_table */\n#ifdef GL_SGI_texture_color_table\n  CONST_CAST(GLEW_SGI_texture_color_table) = _glewSearchExtension(\"GL_SGI_texture_color_table\", extStart, extEnd);\n#endif /* GL_SGI_texture_color_table */\n#ifdef GL_SUNX_constant_data\n  CONST_CAST(GLEW_SUNX_constant_data) = _glewSearchExtension(\"GL_SUNX_constant_data\", extStart, extEnd);\n  if (glewExperimental || GLEW_SUNX_constant_data) CONST_CAST(GLEW_SUNX_constant_data) = !_glewInit_GL_SUNX_constant_data(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SUNX_constant_data */\n#ifdef GL_SUN_convolution_border_modes\n  CONST_CAST(GLEW_SUN_convolution_border_modes) = _glewSearchExtension(\"GL_SUN_convolution_border_modes\", extStart, extEnd);\n#endif /* GL_SUN_convolution_border_modes */\n#ifdef GL_SUN_global_alpha\n  CONST_CAST(GLEW_SUN_global_alpha) = _glewSearchExtension(\"GL_SUN_global_alpha\", extStart, extEnd);\n  if (glewExperimental || GLEW_SUN_global_alpha) CONST_CAST(GLEW_SUN_global_alpha) = !_glewInit_GL_SUN_global_alpha(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SUN_global_alpha */\n#ifdef GL_SUN_mesh_array\n  CONST_CAST(GLEW_SUN_mesh_array) = _glewSearchExtension(\"GL_SUN_mesh_array\", extStart, extEnd);\n#endif /* GL_SUN_mesh_array */\n#ifdef GL_SUN_read_video_pixels\n  CONST_CAST(GLEW_SUN_read_video_pixels) = _glewSearchExtension(\"GL_SUN_read_video_pixels\", extStart, extEnd);\n  if (glewExperimental || GLEW_SUN_read_video_pixels) CONST_CAST(GLEW_SUN_read_video_pixels) = !_glewInit_GL_SUN_read_video_pixels(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SUN_read_video_pixels */\n#ifdef GL_SUN_slice_accum\n  CONST_CAST(GLEW_SUN_slice_accum) = _glewSearchExtension(\"GL_SUN_slice_accum\", extStart, extEnd);\n#endif /* GL_SUN_slice_accum */\n#ifdef GL_SUN_triangle_list\n  CONST_CAST(GLEW_SUN_triangle_list) = _glewSearchExtension(\"GL_SUN_triangle_list\", extStart, extEnd);\n  if (glewExperimental || GLEW_SUN_triangle_list) CONST_CAST(GLEW_SUN_triangle_list) = !_glewInit_GL_SUN_triangle_list(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SUN_triangle_list */\n#ifdef GL_SUN_vertex\n  CONST_CAST(GLEW_SUN_vertex) = _glewSearchExtension(\"GL_SUN_vertex\", extStart, extEnd);\n  if (glewExperimental || GLEW_SUN_vertex) CONST_CAST(GLEW_SUN_vertex) = !_glewInit_GL_SUN_vertex(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_SUN_vertex */\n#ifdef GL_WIN_phong_shading\n  CONST_CAST(GLEW_WIN_phong_shading) = _glewSearchExtension(\"GL_WIN_phong_shading\", extStart, extEnd);\n#endif /* GL_WIN_phong_shading */\n#ifdef GL_WIN_specular_fog\n  CONST_CAST(GLEW_WIN_specular_fog) = _glewSearchExtension(\"GL_WIN_specular_fog\", extStart, extEnd);\n#endif /* GL_WIN_specular_fog */\n#ifdef GL_WIN_swap_hint\n  CONST_CAST(GLEW_WIN_swap_hint) = _glewSearchExtension(\"GL_WIN_swap_hint\", extStart, extEnd);\n  if (glewExperimental || GLEW_WIN_swap_hint) CONST_CAST(GLEW_WIN_swap_hint) = !_glewInit_GL_WIN_swap_hint(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GL_WIN_swap_hint */\n\n  return GLEW_OK;\n}\n\n\n#if defined(_WIN32)\n\n#if !defined(GLEW_MX)\n\nPFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL;\n\nPFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD = NULL;\nPFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD = NULL;\nPFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD = NULL;\nPFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD = NULL;\nPFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD = NULL;\nPFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD = NULL;\nPFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD = NULL;\nPFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD = NULL;\nPFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD = NULL;\n\nPFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL;\nPFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL;\nPFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL;\nPFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL;\n\nPFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL;\n\nPFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL;\n\nPFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB = NULL;\nPFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB = NULL;\n\nPFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB = NULL;\nPFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB = NULL;\nPFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB = NULL;\nPFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB = NULL;\nPFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB = NULL;\n\nPFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB = NULL;\nPFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB = NULL;\nPFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB = NULL;\n\nPFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB = NULL;\nPFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB = NULL;\nPFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB = NULL;\n\nPFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT = NULL;\nPFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT = NULL;\nPFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT = NULL;\nPFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT = NULL;\n\nPFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT = NULL;\n\nPFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT = NULL;\nPFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT = NULL;\n\nPFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT = NULL;\nPFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT = NULL;\nPFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT = NULL;\nPFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT = NULL;\nPFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT = NULL;\n\nPFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT = NULL;\nPFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT = NULL;\nPFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT = NULL;\n\nPFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT = NULL;\nPFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT = NULL;\n\nPFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D = NULL;\nPFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D = NULL;\n\nPFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D = NULL;\nPFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D = NULL;\nPFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D = NULL;\nPFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D = NULL;\n\nPFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D = NULL;\nPFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D = NULL;\nPFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D = NULL;\nPFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D = NULL;\nPFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D = NULL;\nPFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D = NULL;\nPFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D = NULL;\nPFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D = NULL;\nPFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D = NULL;\nPFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D = NULL;\nPFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D = NULL;\nPFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D = NULL;\n\nPFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D = NULL;\nPFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D = NULL;\nPFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D = NULL;\nPFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D = NULL;\n\nPFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D = NULL;\nPFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D = NULL;\nPFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D = NULL;\nPFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D = NULL;\n\nPFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D = NULL;\nPFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D = NULL;\nPFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D = NULL;\nPFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D = NULL;\n\nPFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV = NULL;\nPFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV = NULL;\nPFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV = NULL;\nPFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV = NULL;\nPFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV = NULL;\nPFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV = NULL;\nPFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV = NULL;\nPFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV = NULL;\n\nPFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV = NULL;\n\nPFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV = NULL;\nPFNWGLDELETEDCNVPROC __wglewDeleteDCNV = NULL;\nPFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV = NULL;\nPFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV = NULL;\nPFNWGLENUMGPUSNVPROC __wglewEnumGpusNV = NULL;\n\nPFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV = NULL;\nPFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV = NULL;\nPFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV = NULL;\n\nPFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV = NULL;\nPFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV = NULL;\nPFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV = NULL;\nPFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV = NULL;\nPFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV = NULL;\nPFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV = NULL;\n\nPFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV = NULL;\nPFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV = NULL;\n\nPFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV = NULL;\nPFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV = NULL;\nPFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV = NULL;\nPFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV = NULL;\nPFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV = NULL;\n\nPFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV = NULL;\nPFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV = NULL;\nPFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV = NULL;\nPFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV = NULL;\nPFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV = NULL;\nPFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV = NULL;\n\nPFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML = NULL;\nPFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML = NULL;\nPFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML = NULL;\nPFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML = NULL;\nPFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML = NULL;\nPFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML = NULL;\nGLboolean __WGLEW_3DFX_multisample = GL_FALSE;\nGLboolean __WGLEW_3DL_stereo_control = GL_FALSE;\nGLboolean __WGLEW_AMD_gpu_association = GL_FALSE;\nGLboolean __WGLEW_ARB_buffer_region = GL_FALSE;\nGLboolean __WGLEW_ARB_create_context = GL_FALSE;\nGLboolean __WGLEW_ARB_create_context_profile = GL_FALSE;\nGLboolean __WGLEW_ARB_create_context_robustness = GL_FALSE;\nGLboolean __WGLEW_ARB_extensions_string = GL_FALSE;\nGLboolean __WGLEW_ARB_framebuffer_sRGB = GL_FALSE;\nGLboolean __WGLEW_ARB_make_current_read = GL_FALSE;\nGLboolean __WGLEW_ARB_multisample = GL_FALSE;\nGLboolean __WGLEW_ARB_pbuffer = GL_FALSE;\nGLboolean __WGLEW_ARB_pixel_format = GL_FALSE;\nGLboolean __WGLEW_ARB_pixel_format_float = GL_FALSE;\nGLboolean __WGLEW_ARB_render_texture = GL_FALSE;\nGLboolean __WGLEW_ATI_pixel_format_float = GL_FALSE;\nGLboolean __WGLEW_ATI_render_texture_rectangle = GL_FALSE;\nGLboolean __WGLEW_EXT_create_context_es2_profile = GL_FALSE;\nGLboolean __WGLEW_EXT_create_context_es_profile = GL_FALSE;\nGLboolean __WGLEW_EXT_depth_float = GL_FALSE;\nGLboolean __WGLEW_EXT_display_color_table = GL_FALSE;\nGLboolean __WGLEW_EXT_extensions_string = GL_FALSE;\nGLboolean __WGLEW_EXT_framebuffer_sRGB = GL_FALSE;\nGLboolean __WGLEW_EXT_make_current_read = GL_FALSE;\nGLboolean __WGLEW_EXT_multisample = GL_FALSE;\nGLboolean __WGLEW_EXT_pbuffer = GL_FALSE;\nGLboolean __WGLEW_EXT_pixel_format = GL_FALSE;\nGLboolean __WGLEW_EXT_pixel_format_packed_float = GL_FALSE;\nGLboolean __WGLEW_EXT_swap_control = GL_FALSE;\nGLboolean __WGLEW_EXT_swap_control_tear = GL_FALSE;\nGLboolean __WGLEW_I3D_digital_video_control = GL_FALSE;\nGLboolean __WGLEW_I3D_gamma = GL_FALSE;\nGLboolean __WGLEW_I3D_genlock = GL_FALSE;\nGLboolean __WGLEW_I3D_image_buffer = GL_FALSE;\nGLboolean __WGLEW_I3D_swap_frame_lock = GL_FALSE;\nGLboolean __WGLEW_I3D_swap_frame_usage = GL_FALSE;\nGLboolean __WGLEW_NV_DX_interop = GL_FALSE;\nGLboolean __WGLEW_NV_DX_interop2 = GL_FALSE;\nGLboolean __WGLEW_NV_copy_image = GL_FALSE;\nGLboolean __WGLEW_NV_float_buffer = GL_FALSE;\nGLboolean __WGLEW_NV_gpu_affinity = GL_FALSE;\nGLboolean __WGLEW_NV_multisample_coverage = GL_FALSE;\nGLboolean __WGLEW_NV_present_video = GL_FALSE;\nGLboolean __WGLEW_NV_render_depth_texture = GL_FALSE;\nGLboolean __WGLEW_NV_render_texture_rectangle = GL_FALSE;\nGLboolean __WGLEW_NV_swap_group = GL_FALSE;\nGLboolean __WGLEW_NV_vertex_array_range = GL_FALSE;\nGLboolean __WGLEW_NV_video_capture = GL_FALSE;\nGLboolean __WGLEW_NV_video_output = GL_FALSE;\nGLboolean __WGLEW_OML_sync_control = GL_FALSE;\n\n#endif /* !GLEW_MX */\n\n#ifdef WGL_3DFX_multisample\n\n#endif /* WGL_3DFX_multisample */\n\n#ifdef WGL_3DL_stereo_control\n\nstatic GLboolean _glewInit_WGL_3DL_stereo_control (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglSetStereoEmitterState3DL = (PFNWGLSETSTEREOEMITTERSTATE3DLPROC)glewGetProcAddress((const GLubyte*)\"wglSetStereoEmitterState3DL\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_3DL_stereo_control */\n\n#ifdef WGL_AMD_gpu_association\n\nstatic GLboolean _glewInit_WGL_AMD_gpu_association (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBlitContextFramebufferAMD = (PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC)glewGetProcAddress((const GLubyte*)\"wglBlitContextFramebufferAMD\")) == NULL) || r;\n  r = ((wglCreateAssociatedContextAMD = (PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)\"wglCreateAssociatedContextAMD\")) == NULL) || r;\n  r = ((wglCreateAssociatedContextAttribsAMD = (PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC)glewGetProcAddress((const GLubyte*)\"wglCreateAssociatedContextAttribsAMD\")) == NULL) || r;\n  r = ((wglDeleteAssociatedContextAMD = (PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)\"wglDeleteAssociatedContextAMD\")) == NULL) || r;\n  r = ((wglGetContextGPUIDAMD = (PFNWGLGETCONTEXTGPUIDAMDPROC)glewGetProcAddress((const GLubyte*)\"wglGetContextGPUIDAMD\")) == NULL) || r;\n  r = ((wglGetCurrentAssociatedContextAMD = (PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC)glewGetProcAddress((const GLubyte*)\"wglGetCurrentAssociatedContextAMD\")) == NULL) || r;\n  r = ((wglGetGPUIDsAMD = (PFNWGLGETGPUIDSAMDPROC)glewGetProcAddress((const GLubyte*)\"wglGetGPUIDsAMD\")) == NULL) || r;\n  r = ((wglGetGPUInfoAMD = (PFNWGLGETGPUINFOAMDPROC)glewGetProcAddress((const GLubyte*)\"wglGetGPUInfoAMD\")) == NULL) || r;\n  r = ((wglMakeAssociatedContextCurrentAMD = (PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC)glewGetProcAddress((const GLubyte*)\"wglMakeAssociatedContextCurrentAMD\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_AMD_gpu_association */\n\n#ifdef WGL_ARB_buffer_region\n\nstatic GLboolean _glewInit_WGL_ARB_buffer_region (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCreateBufferRegionARB = (PFNWGLCREATEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)\"wglCreateBufferRegionARB\")) == NULL) || r;\n  r = ((wglDeleteBufferRegionARB = (PFNWGLDELETEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)\"wglDeleteBufferRegionARB\")) == NULL) || r;\n  r = ((wglRestoreBufferRegionARB = (PFNWGLRESTOREBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)\"wglRestoreBufferRegionARB\")) == NULL) || r;\n  r = ((wglSaveBufferRegionARB = (PFNWGLSAVEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)\"wglSaveBufferRegionARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_buffer_region */\n\n#ifdef WGL_ARB_create_context\n\nstatic GLboolean _glewInit_WGL_ARB_create_context (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)\"wglCreateContextAttribsARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_create_context */\n\n#ifdef WGL_ARB_create_context_profile\n\n#endif /* WGL_ARB_create_context_profile */\n\n#ifdef WGL_ARB_create_context_robustness\n\n#endif /* WGL_ARB_create_context_robustness */\n\n#ifdef WGL_ARB_extensions_string\n\nstatic GLboolean _glewInit_WGL_ARB_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetExtensionsStringARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_extensions_string */\n\n#ifdef WGL_ARB_framebuffer_sRGB\n\n#endif /* WGL_ARB_framebuffer_sRGB */\n\n#ifdef WGL_ARB_make_current_read\n\nstatic GLboolean _glewInit_WGL_ARB_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetCurrentReadDCARB = (PFNWGLGETCURRENTREADDCARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetCurrentReadDCARB\")) == NULL) || r;\n  r = ((wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)glewGetProcAddress((const GLubyte*)\"wglMakeContextCurrentARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_make_current_read */\n\n#ifdef WGL_ARB_multisample\n\n#endif /* WGL_ARB_multisample */\n\n#ifdef WGL_ARB_pbuffer\n\nstatic GLboolean _glewInit_WGL_ARB_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"wglCreatePbufferARB\")) == NULL) || r;\n  r = ((wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"wglDestroyPbufferARB\")) == NULL) || r;\n  r = ((wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetPbufferDCARB\")) == NULL) || r;\n  r = ((wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)\"wglQueryPbufferARB\")) == NULL) || r;\n  r = ((wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)\"wglReleasePbufferDCARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_pbuffer */\n\n#ifdef WGL_ARB_pixel_format\n\nstatic GLboolean _glewInit_WGL_ARB_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)glewGetProcAddress((const GLubyte*)\"wglChoosePixelFormatARB\")) == NULL) || r;\n  r = ((wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetPixelFormatAttribfvARB\")) == NULL) || r;\n  r = ((wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetPixelFormatAttribivARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_pixel_format */\n\n#ifdef WGL_ARB_pixel_format_float\n\n#endif /* WGL_ARB_pixel_format_float */\n\n#ifdef WGL_ARB_render_texture\n\nstatic GLboolean _glewInit_WGL_ARB_render_texture (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)\"wglBindTexImageARB\")) == NULL) || r;\n  r = ((wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)\"wglReleaseTexImageARB\")) == NULL) || r;\n  r = ((wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)glewGetProcAddress((const GLubyte*)\"wglSetPbufferAttribARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_ARB_render_texture */\n\n#ifdef WGL_ATI_pixel_format_float\n\n#endif /* WGL_ATI_pixel_format_float */\n\n#ifdef WGL_ATI_render_texture_rectangle\n\n#endif /* WGL_ATI_render_texture_rectangle */\n\n#ifdef WGL_EXT_create_context_es2_profile\n\n#endif /* WGL_EXT_create_context_es2_profile */\n\n#ifdef WGL_EXT_create_context_es_profile\n\n#endif /* WGL_EXT_create_context_es_profile */\n\n#ifdef WGL_EXT_depth_float\n\n#endif /* WGL_EXT_depth_float */\n\n#ifdef WGL_EXT_display_color_table\n\nstatic GLboolean _glewInit_WGL_EXT_display_color_table (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindDisplayColorTableEXT = (PFNWGLBINDDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"wglBindDisplayColorTableEXT\")) == NULL) || r;\n  r = ((wglCreateDisplayColorTableEXT = (PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"wglCreateDisplayColorTableEXT\")) == NULL) || r;\n  r = ((wglDestroyDisplayColorTableEXT = (PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"wglDestroyDisplayColorTableEXT\")) == NULL) || r;\n  r = ((wglLoadDisplayColorTableEXT = (PFNWGLLOADDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)\"wglLoadDisplayColorTableEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_display_color_table */\n\n#ifdef WGL_EXT_extensions_string\n\nstatic GLboolean _glewInit_WGL_EXT_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetExtensionsStringEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_extensions_string */\n\n#ifdef WGL_EXT_framebuffer_sRGB\n\n#endif /* WGL_EXT_framebuffer_sRGB */\n\n#ifdef WGL_EXT_make_current_read\n\nstatic GLboolean _glewInit_WGL_EXT_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetCurrentReadDCEXT = (PFNWGLGETCURRENTREADDCEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetCurrentReadDCEXT\")) == NULL) || r;\n  r = ((wglMakeContextCurrentEXT = (PFNWGLMAKECONTEXTCURRENTEXTPROC)glewGetProcAddress((const GLubyte*)\"wglMakeContextCurrentEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_make_current_read */\n\n#ifdef WGL_EXT_multisample\n\n#endif /* WGL_EXT_multisample */\n\n#ifdef WGL_EXT_pbuffer\n\nstatic GLboolean _glewInit_WGL_EXT_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCreatePbufferEXT = (PFNWGLCREATEPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"wglCreatePbufferEXT\")) == NULL) || r;\n  r = ((wglDestroyPbufferEXT = (PFNWGLDESTROYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"wglDestroyPbufferEXT\")) == NULL) || r;\n  r = ((wglGetPbufferDCEXT = (PFNWGLGETPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetPbufferDCEXT\")) == NULL) || r;\n  r = ((wglQueryPbufferEXT = (PFNWGLQUERYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)\"wglQueryPbufferEXT\")) == NULL) || r;\n  r = ((wglReleasePbufferDCEXT = (PFNWGLRELEASEPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)\"wglReleasePbufferDCEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_pbuffer */\n\n#ifdef WGL_EXT_pixel_format\n\nstatic GLboolean _glewInit_WGL_EXT_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)glewGetProcAddress((const GLubyte*)\"wglChoosePixelFormatEXT\")) == NULL) || r;\n  r = ((wglGetPixelFormatAttribfvEXT = (PFNWGLGETPIXELFORMATATTRIBFVEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetPixelFormatAttribfvEXT\")) == NULL) || r;\n  r = ((wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetPixelFormatAttribivEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_pixel_format */\n\n#ifdef WGL_EXT_pixel_format_packed_float\n\n#endif /* WGL_EXT_pixel_format_packed_float */\n\n#ifdef WGL_EXT_swap_control\n\nstatic GLboolean _glewInit_WGL_EXT_swap_control (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetSwapIntervalEXT\")) == NULL) || r;\n  r = ((wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)\"wglSwapIntervalEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_EXT_swap_control */\n\n#ifdef WGL_EXT_swap_control_tear\n\n#endif /* WGL_EXT_swap_control_tear */\n\n#ifdef WGL_I3D_digital_video_control\n\nstatic GLboolean _glewInit_WGL_I3D_digital_video_control (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetDigitalVideoParametersI3D = (PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetDigitalVideoParametersI3D\")) == NULL) || r;\n  r = ((wglSetDigitalVideoParametersI3D = (PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglSetDigitalVideoParametersI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_digital_video_control */\n\n#ifdef WGL_I3D_gamma\n\nstatic GLboolean _glewInit_WGL_I3D_gamma (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetGammaTableI3D = (PFNWGLGETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGammaTableI3D\")) == NULL) || r;\n  r = ((wglGetGammaTableParametersI3D = (PFNWGLGETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGammaTableParametersI3D\")) == NULL) || r;\n  r = ((wglSetGammaTableI3D = (PFNWGLSETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglSetGammaTableI3D\")) == NULL) || r;\n  r = ((wglSetGammaTableParametersI3D = (PFNWGLSETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglSetGammaTableParametersI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_gamma */\n\n#ifdef WGL_I3D_genlock\n\nstatic GLboolean _glewInit_WGL_I3D_genlock (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglDisableGenlockI3D = (PFNWGLDISABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglDisableGenlockI3D\")) == NULL) || r;\n  r = ((wglEnableGenlockI3D = (PFNWGLENABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglEnableGenlockI3D\")) == NULL) || r;\n  r = ((wglGenlockSampleRateI3D = (PFNWGLGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGenlockSampleRateI3D\")) == NULL) || r;\n  r = ((wglGenlockSourceDelayI3D = (PFNWGLGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGenlockSourceDelayI3D\")) == NULL) || r;\n  r = ((wglGenlockSourceEdgeI3D = (PFNWGLGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGenlockSourceEdgeI3D\")) == NULL) || r;\n  r = ((wglGenlockSourceI3D = (PFNWGLGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGenlockSourceI3D\")) == NULL) || r;\n  r = ((wglGetGenlockSampleRateI3D = (PFNWGLGETGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGenlockSampleRateI3D\")) == NULL) || r;\n  r = ((wglGetGenlockSourceDelayI3D = (PFNWGLGETGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGenlockSourceDelayI3D\")) == NULL) || r;\n  r = ((wglGetGenlockSourceEdgeI3D = (PFNWGLGETGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGenlockSourceEdgeI3D\")) == NULL) || r;\n  r = ((wglGetGenlockSourceI3D = (PFNWGLGETGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetGenlockSourceI3D\")) == NULL) || r;\n  r = ((wglIsEnabledGenlockI3D = (PFNWGLISENABLEDGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglIsEnabledGenlockI3D\")) == NULL) || r;\n  r = ((wglQueryGenlockMaxSourceDelayI3D = (PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)\"wglQueryGenlockMaxSourceDelayI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_genlock */\n\n#ifdef WGL_I3D_image_buffer\n\nstatic GLboolean _glewInit_WGL_I3D_image_buffer (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglAssociateImageBufferEventsI3D = (PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglAssociateImageBufferEventsI3D\")) == NULL) || r;\n  r = ((wglCreateImageBufferI3D = (PFNWGLCREATEIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)\"wglCreateImageBufferI3D\")) == NULL) || r;\n  r = ((wglDestroyImageBufferI3D = (PFNWGLDESTROYIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)\"wglDestroyImageBufferI3D\")) == NULL) || r;\n  r = ((wglReleaseImageBufferEventsI3D = (PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)\"wglReleaseImageBufferEventsI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_image_buffer */\n\n#ifdef WGL_I3D_swap_frame_lock\n\nstatic GLboolean _glewInit_WGL_I3D_swap_frame_lock (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglDisableFrameLockI3D = (PFNWGLDISABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglDisableFrameLockI3D\")) == NULL) || r;\n  r = ((wglEnableFrameLockI3D = (PFNWGLENABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglEnableFrameLockI3D\")) == NULL) || r;\n  r = ((wglIsEnabledFrameLockI3D = (PFNWGLISENABLEDFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)\"wglIsEnabledFrameLockI3D\")) == NULL) || r;\n  r = ((wglQueryFrameLockMasterI3D = (PFNWGLQUERYFRAMELOCKMASTERI3DPROC)glewGetProcAddress((const GLubyte*)\"wglQueryFrameLockMasterI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_swap_frame_lock */\n\n#ifdef WGL_I3D_swap_frame_usage\n\nstatic GLboolean _glewInit_WGL_I3D_swap_frame_usage (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBeginFrameTrackingI3D = (PFNWGLBEGINFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)\"wglBeginFrameTrackingI3D\")) == NULL) || r;\n  r = ((wglEndFrameTrackingI3D = (PFNWGLENDFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)\"wglEndFrameTrackingI3D\")) == NULL) || r;\n  r = ((wglGetFrameUsageI3D = (PFNWGLGETFRAMEUSAGEI3DPROC)glewGetProcAddress((const GLubyte*)\"wglGetFrameUsageI3D\")) == NULL) || r;\n  r = ((wglQueryFrameTrackingI3D = (PFNWGLQUERYFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)\"wglQueryFrameTrackingI3D\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_I3D_swap_frame_usage */\n\n#ifdef WGL_NV_DX_interop\n\nstatic GLboolean _glewInit_WGL_NV_DX_interop (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglDXCloseDeviceNV = (PFNWGLDXCLOSEDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglDXCloseDeviceNV\")) == NULL) || r;\n  r = ((wglDXLockObjectsNV = (PFNWGLDXLOCKOBJECTSNVPROC)glewGetProcAddress((const GLubyte*)\"wglDXLockObjectsNV\")) == NULL) || r;\n  r = ((wglDXObjectAccessNV = (PFNWGLDXOBJECTACCESSNVPROC)glewGetProcAddress((const GLubyte*)\"wglDXObjectAccessNV\")) == NULL) || r;\n  r = ((wglDXOpenDeviceNV = (PFNWGLDXOPENDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglDXOpenDeviceNV\")) == NULL) || r;\n  r = ((wglDXRegisterObjectNV = (PFNWGLDXREGISTEROBJECTNVPROC)glewGetProcAddress((const GLubyte*)\"wglDXRegisterObjectNV\")) == NULL) || r;\n  r = ((wglDXSetResourceShareHandleNV = (PFNWGLDXSETRESOURCESHAREHANDLENVPROC)glewGetProcAddress((const GLubyte*)\"wglDXSetResourceShareHandleNV\")) == NULL) || r;\n  r = ((wglDXUnlockObjectsNV = (PFNWGLDXUNLOCKOBJECTSNVPROC)glewGetProcAddress((const GLubyte*)\"wglDXUnlockObjectsNV\")) == NULL) || r;\n  r = ((wglDXUnregisterObjectNV = (PFNWGLDXUNREGISTEROBJECTNVPROC)glewGetProcAddress((const GLubyte*)\"wglDXUnregisterObjectNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_DX_interop */\n\n#ifdef WGL_NV_DX_interop2\n\n#endif /* WGL_NV_DX_interop2 */\n\n#ifdef WGL_NV_copy_image\n\nstatic GLboolean _glewInit_WGL_NV_copy_image (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCopyImageSubDataNV = (PFNWGLCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)\"wglCopyImageSubDataNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_copy_image */\n\n#ifdef WGL_NV_float_buffer\n\n#endif /* WGL_NV_float_buffer */\n\n#ifdef WGL_NV_gpu_affinity\n\nstatic GLboolean _glewInit_WGL_NV_gpu_affinity (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)\"wglCreateAffinityDCNV\")) == NULL) || r;\n  r = ((wglDeleteDCNV = (PFNWGLDELETEDCNVPROC)glewGetProcAddress((const GLubyte*)\"wglDeleteDCNV\")) == NULL) || r;\n  r = ((wglEnumGpuDevicesNV = (PFNWGLENUMGPUDEVICESNVPROC)glewGetProcAddress((const GLubyte*)\"wglEnumGpuDevicesNV\")) == NULL) || r;\n  r = ((wglEnumGpusFromAffinityDCNV = (PFNWGLENUMGPUSFROMAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)\"wglEnumGpusFromAffinityDCNV\")) == NULL) || r;\n  r = ((wglEnumGpusNV = (PFNWGLENUMGPUSNVPROC)glewGetProcAddress((const GLubyte*)\"wglEnumGpusNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_gpu_affinity */\n\n#ifdef WGL_NV_multisample_coverage\n\n#endif /* WGL_NV_multisample_coverage */\n\n#ifdef WGL_NV_present_video\n\nstatic GLboolean _glewInit_WGL_NV_present_video (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindVideoDeviceNV = (PFNWGLBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglBindVideoDeviceNV\")) == NULL) || r;\n  r = ((wglEnumerateVideoDevicesNV = (PFNWGLENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)\"wglEnumerateVideoDevicesNV\")) == NULL) || r;\n  r = ((wglQueryCurrentContextNV = (PFNWGLQUERYCURRENTCONTEXTNVPROC)glewGetProcAddress((const GLubyte*)\"wglQueryCurrentContextNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_present_video */\n\n#ifdef WGL_NV_render_depth_texture\n\n#endif /* WGL_NV_render_depth_texture */\n\n#ifdef WGL_NV_render_texture_rectangle\n\n#endif /* WGL_NV_render_texture_rectangle */\n\n#ifdef WGL_NV_swap_group\n\nstatic GLboolean _glewInit_WGL_NV_swap_group (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)\"wglBindSwapBarrierNV\")) == NULL) || r;\n  r = ((wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)\"wglJoinSwapGroupNV\")) == NULL) || r;\n  r = ((wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)\"wglQueryFrameCountNV\")) == NULL) || r;\n  r = ((wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)\"wglQueryMaxSwapGroupsNV\")) == NULL) || r;\n  r = ((wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)\"wglQuerySwapGroupNV\")) == NULL) || r;\n  r = ((wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)\"wglResetFrameCountNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_swap_group */\n\n#ifdef WGL_NV_vertex_array_range\n\nstatic GLboolean _glewInit_WGL_NV_vertex_array_range (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)\"wglAllocateMemoryNV\")) == NULL) || r;\n  r = ((wglFreeMemoryNV = (PFNWGLFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)\"wglFreeMemoryNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_vertex_array_range */\n\n#ifdef WGL_NV_video_capture\n\nstatic GLboolean _glewInit_WGL_NV_video_capture (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindVideoCaptureDeviceNV = (PFNWGLBINDVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglBindVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((wglEnumerateVideoCaptureDevicesNV = (PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC)glewGetProcAddress((const GLubyte*)\"wglEnumerateVideoCaptureDevicesNV\")) == NULL) || r;\n  r = ((wglLockVideoCaptureDeviceNV = (PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglLockVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((wglQueryVideoCaptureDeviceNV = (PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglQueryVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((wglReleaseVideoCaptureDeviceNV = (PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglReleaseVideoCaptureDeviceNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_video_capture */\n\n#ifdef WGL_NV_video_output\n\nstatic GLboolean _glewInit_WGL_NV_video_output (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglBindVideoImageNV = (PFNWGLBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)\"wglBindVideoImageNV\")) == NULL) || r;\n  r = ((wglGetVideoDeviceNV = (PFNWGLGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglGetVideoDeviceNV\")) == NULL) || r;\n  r = ((wglGetVideoInfoNV = (PFNWGLGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)\"wglGetVideoInfoNV\")) == NULL) || r;\n  r = ((wglReleaseVideoDeviceNV = (PFNWGLRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"wglReleaseVideoDeviceNV\")) == NULL) || r;\n  r = ((wglReleaseVideoImageNV = (PFNWGLRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)\"wglReleaseVideoImageNV\")) == NULL) || r;\n  r = ((wglSendPbufferToVideoNV = (PFNWGLSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)\"wglSendPbufferToVideoNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_NV_video_output */\n\n#ifdef WGL_OML_sync_control\n\nstatic GLboolean _glewInit_WGL_OML_sync_control (WGLEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)\"wglGetMscRateOML\")) == NULL) || r;\n  r = ((wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)\"wglGetSyncValuesOML\")) == NULL) || r;\n  r = ((wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)\"wglSwapBuffersMscOML\")) == NULL) || r;\n  r = ((wglSwapLayerBuffersMscOML = (PFNWGLSWAPLAYERBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)\"wglSwapLayerBuffersMscOML\")) == NULL) || r;\n  r = ((wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)\"wglWaitForMscOML\")) == NULL) || r;\n  r = ((wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)\"wglWaitForSbcOML\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* WGL_OML_sync_control */\n\n/* ------------------------------------------------------------------------- */\n\nstatic PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL;\nstatic PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL;\n\nGLboolean GLEWAPIENTRY wglewGetExtension (const char* name)\n{    \n  const GLubyte* start;\n  const GLubyte* end;\n  if (_wglewGetExtensionsStringARB == NULL)\n    if (_wglewGetExtensionsStringEXT == NULL)\n      return GL_FALSE;\n    else\n      start = (const GLubyte*)_wglewGetExtensionsStringEXT();\n  else\n    start = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());\n  if (start == 0)\n    return GL_FALSE;\n  end = start + _glewStrLen(start);\n  return _glewSearchExtension(name, start, end);\n}\n\nGLenum GLEWAPIENTRY wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST)\n{\n  GLboolean crippled;\n  const GLubyte* extStart;\n  const GLubyte* extEnd;\n  /* find wgl extension string query functions */\n  _wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)\"wglGetExtensionsStringARB\");\n  _wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)\"wglGetExtensionsStringEXT\");\n  /* query wgl extension string */\n  if (_wglewGetExtensionsStringARB == NULL)\n    if (_wglewGetExtensionsStringEXT == NULL)\n      extStart = (const GLubyte*)\"\";\n    else\n      extStart = (const GLubyte*)_wglewGetExtensionsStringEXT();\n  else\n    extStart = (const GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC());\n  extEnd = extStart + _glewStrLen(extStart);\n  /* initialize extensions */\n  crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL;\n#ifdef WGL_3DFX_multisample\n  CONST_CAST(WGLEW_3DFX_multisample) = _glewSearchExtension(\"WGL_3DFX_multisample\", extStart, extEnd);\n#endif /* WGL_3DFX_multisample */\n#ifdef WGL_3DL_stereo_control\n  CONST_CAST(WGLEW_3DL_stereo_control) = _glewSearchExtension(\"WGL_3DL_stereo_control\", extStart, extEnd);\n  if (glewExperimental || WGLEW_3DL_stereo_control|| crippled) CONST_CAST(WGLEW_3DL_stereo_control)= !_glewInit_WGL_3DL_stereo_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_3DL_stereo_control */\n#ifdef WGL_AMD_gpu_association\n  CONST_CAST(WGLEW_AMD_gpu_association) = _glewSearchExtension(\"WGL_AMD_gpu_association\", extStart, extEnd);\n  if (glewExperimental || WGLEW_AMD_gpu_association|| crippled) CONST_CAST(WGLEW_AMD_gpu_association)= !_glewInit_WGL_AMD_gpu_association(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_AMD_gpu_association */\n#ifdef WGL_ARB_buffer_region\n  CONST_CAST(WGLEW_ARB_buffer_region) = _glewSearchExtension(\"WGL_ARB_buffer_region\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_buffer_region|| crippled) CONST_CAST(WGLEW_ARB_buffer_region)= !_glewInit_WGL_ARB_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_buffer_region */\n#ifdef WGL_ARB_create_context\n  CONST_CAST(WGLEW_ARB_create_context) = _glewSearchExtension(\"WGL_ARB_create_context\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_create_context|| crippled) CONST_CAST(WGLEW_ARB_create_context)= !_glewInit_WGL_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_create_context */\n#ifdef WGL_ARB_create_context_profile\n  CONST_CAST(WGLEW_ARB_create_context_profile) = _glewSearchExtension(\"WGL_ARB_create_context_profile\", extStart, extEnd);\n#endif /* WGL_ARB_create_context_profile */\n#ifdef WGL_ARB_create_context_robustness\n  CONST_CAST(WGLEW_ARB_create_context_robustness) = _glewSearchExtension(\"WGL_ARB_create_context_robustness\", extStart, extEnd);\n#endif /* WGL_ARB_create_context_robustness */\n#ifdef WGL_ARB_extensions_string\n  CONST_CAST(WGLEW_ARB_extensions_string) = _glewSearchExtension(\"WGL_ARB_extensions_string\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_extensions_string|| crippled) CONST_CAST(WGLEW_ARB_extensions_string)= !_glewInit_WGL_ARB_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_extensions_string */\n#ifdef WGL_ARB_framebuffer_sRGB\n  CONST_CAST(WGLEW_ARB_framebuffer_sRGB) = _glewSearchExtension(\"WGL_ARB_framebuffer_sRGB\", extStart, extEnd);\n#endif /* WGL_ARB_framebuffer_sRGB */\n#ifdef WGL_ARB_make_current_read\n  CONST_CAST(WGLEW_ARB_make_current_read) = _glewSearchExtension(\"WGL_ARB_make_current_read\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_make_current_read|| crippled) CONST_CAST(WGLEW_ARB_make_current_read)= !_glewInit_WGL_ARB_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_make_current_read */\n#ifdef WGL_ARB_multisample\n  CONST_CAST(WGLEW_ARB_multisample) = _glewSearchExtension(\"WGL_ARB_multisample\", extStart, extEnd);\n#endif /* WGL_ARB_multisample */\n#ifdef WGL_ARB_pbuffer\n  CONST_CAST(WGLEW_ARB_pbuffer) = _glewSearchExtension(\"WGL_ARB_pbuffer\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_pbuffer|| crippled) CONST_CAST(WGLEW_ARB_pbuffer)= !_glewInit_WGL_ARB_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_pbuffer */\n#ifdef WGL_ARB_pixel_format\n  CONST_CAST(WGLEW_ARB_pixel_format) = _glewSearchExtension(\"WGL_ARB_pixel_format\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_pixel_format|| crippled) CONST_CAST(WGLEW_ARB_pixel_format)= !_glewInit_WGL_ARB_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_pixel_format */\n#ifdef WGL_ARB_pixel_format_float\n  CONST_CAST(WGLEW_ARB_pixel_format_float) = _glewSearchExtension(\"WGL_ARB_pixel_format_float\", extStart, extEnd);\n#endif /* WGL_ARB_pixel_format_float */\n#ifdef WGL_ARB_render_texture\n  CONST_CAST(WGLEW_ARB_render_texture) = _glewSearchExtension(\"WGL_ARB_render_texture\", extStart, extEnd);\n  if (glewExperimental || WGLEW_ARB_render_texture|| crippled) CONST_CAST(WGLEW_ARB_render_texture)= !_glewInit_WGL_ARB_render_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_ARB_render_texture */\n#ifdef WGL_ATI_pixel_format_float\n  CONST_CAST(WGLEW_ATI_pixel_format_float) = _glewSearchExtension(\"WGL_ATI_pixel_format_float\", extStart, extEnd);\n#endif /* WGL_ATI_pixel_format_float */\n#ifdef WGL_ATI_render_texture_rectangle\n  CONST_CAST(WGLEW_ATI_render_texture_rectangle) = _glewSearchExtension(\"WGL_ATI_render_texture_rectangle\", extStart, extEnd);\n#endif /* WGL_ATI_render_texture_rectangle */\n#ifdef WGL_EXT_create_context_es2_profile\n  CONST_CAST(WGLEW_EXT_create_context_es2_profile) = _glewSearchExtension(\"WGL_EXT_create_context_es2_profile\", extStart, extEnd);\n#endif /* WGL_EXT_create_context_es2_profile */\n#ifdef WGL_EXT_create_context_es_profile\n  CONST_CAST(WGLEW_EXT_create_context_es_profile) = _glewSearchExtension(\"WGL_EXT_create_context_es_profile\", extStart, extEnd);\n#endif /* WGL_EXT_create_context_es_profile */\n#ifdef WGL_EXT_depth_float\n  CONST_CAST(WGLEW_EXT_depth_float) = _glewSearchExtension(\"WGL_EXT_depth_float\", extStart, extEnd);\n#endif /* WGL_EXT_depth_float */\n#ifdef WGL_EXT_display_color_table\n  CONST_CAST(WGLEW_EXT_display_color_table) = _glewSearchExtension(\"WGL_EXT_display_color_table\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_display_color_table|| crippled) CONST_CAST(WGLEW_EXT_display_color_table)= !_glewInit_WGL_EXT_display_color_table(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_display_color_table */\n#ifdef WGL_EXT_extensions_string\n  CONST_CAST(WGLEW_EXT_extensions_string) = _glewSearchExtension(\"WGL_EXT_extensions_string\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_extensions_string|| crippled) CONST_CAST(WGLEW_EXT_extensions_string)= !_glewInit_WGL_EXT_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_extensions_string */\n#ifdef WGL_EXT_framebuffer_sRGB\n  CONST_CAST(WGLEW_EXT_framebuffer_sRGB) = _glewSearchExtension(\"WGL_EXT_framebuffer_sRGB\", extStart, extEnd);\n#endif /* WGL_EXT_framebuffer_sRGB */\n#ifdef WGL_EXT_make_current_read\n  CONST_CAST(WGLEW_EXT_make_current_read) = _glewSearchExtension(\"WGL_EXT_make_current_read\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_make_current_read|| crippled) CONST_CAST(WGLEW_EXT_make_current_read)= !_glewInit_WGL_EXT_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_make_current_read */\n#ifdef WGL_EXT_multisample\n  CONST_CAST(WGLEW_EXT_multisample) = _glewSearchExtension(\"WGL_EXT_multisample\", extStart, extEnd);\n#endif /* WGL_EXT_multisample */\n#ifdef WGL_EXT_pbuffer\n  CONST_CAST(WGLEW_EXT_pbuffer) = _glewSearchExtension(\"WGL_EXT_pbuffer\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_pbuffer|| crippled) CONST_CAST(WGLEW_EXT_pbuffer)= !_glewInit_WGL_EXT_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_pbuffer */\n#ifdef WGL_EXT_pixel_format\n  CONST_CAST(WGLEW_EXT_pixel_format) = _glewSearchExtension(\"WGL_EXT_pixel_format\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_pixel_format|| crippled) CONST_CAST(WGLEW_EXT_pixel_format)= !_glewInit_WGL_EXT_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_pixel_format */\n#ifdef WGL_EXT_pixel_format_packed_float\n  CONST_CAST(WGLEW_EXT_pixel_format_packed_float) = _glewSearchExtension(\"WGL_EXT_pixel_format_packed_float\", extStart, extEnd);\n#endif /* WGL_EXT_pixel_format_packed_float */\n#ifdef WGL_EXT_swap_control\n  CONST_CAST(WGLEW_EXT_swap_control) = _glewSearchExtension(\"WGL_EXT_swap_control\", extStart, extEnd);\n  if (glewExperimental || WGLEW_EXT_swap_control|| crippled) CONST_CAST(WGLEW_EXT_swap_control)= !_glewInit_WGL_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_EXT_swap_control */\n#ifdef WGL_EXT_swap_control_tear\n  CONST_CAST(WGLEW_EXT_swap_control_tear) = _glewSearchExtension(\"WGL_EXT_swap_control_tear\", extStart, extEnd);\n#endif /* WGL_EXT_swap_control_tear */\n#ifdef WGL_I3D_digital_video_control\n  CONST_CAST(WGLEW_I3D_digital_video_control) = _glewSearchExtension(\"WGL_I3D_digital_video_control\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_digital_video_control|| crippled) CONST_CAST(WGLEW_I3D_digital_video_control)= !_glewInit_WGL_I3D_digital_video_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_digital_video_control */\n#ifdef WGL_I3D_gamma\n  CONST_CAST(WGLEW_I3D_gamma) = _glewSearchExtension(\"WGL_I3D_gamma\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_gamma|| crippled) CONST_CAST(WGLEW_I3D_gamma)= !_glewInit_WGL_I3D_gamma(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_gamma */\n#ifdef WGL_I3D_genlock\n  CONST_CAST(WGLEW_I3D_genlock) = _glewSearchExtension(\"WGL_I3D_genlock\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_genlock|| crippled) CONST_CAST(WGLEW_I3D_genlock)= !_glewInit_WGL_I3D_genlock(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_genlock */\n#ifdef WGL_I3D_image_buffer\n  CONST_CAST(WGLEW_I3D_image_buffer) = _glewSearchExtension(\"WGL_I3D_image_buffer\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_image_buffer|| crippled) CONST_CAST(WGLEW_I3D_image_buffer)= !_glewInit_WGL_I3D_image_buffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_image_buffer */\n#ifdef WGL_I3D_swap_frame_lock\n  CONST_CAST(WGLEW_I3D_swap_frame_lock) = _glewSearchExtension(\"WGL_I3D_swap_frame_lock\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_swap_frame_lock|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_lock)= !_glewInit_WGL_I3D_swap_frame_lock(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_swap_frame_lock */\n#ifdef WGL_I3D_swap_frame_usage\n  CONST_CAST(WGLEW_I3D_swap_frame_usage) = _glewSearchExtension(\"WGL_I3D_swap_frame_usage\", extStart, extEnd);\n  if (glewExperimental || WGLEW_I3D_swap_frame_usage|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_usage)= !_glewInit_WGL_I3D_swap_frame_usage(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_I3D_swap_frame_usage */\n#ifdef WGL_NV_DX_interop\n  CONST_CAST(WGLEW_NV_DX_interop) = _glewSearchExtension(\"WGL_NV_DX_interop\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_DX_interop|| crippled) CONST_CAST(WGLEW_NV_DX_interop)= !_glewInit_WGL_NV_DX_interop(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_DX_interop */\n#ifdef WGL_NV_DX_interop2\n  CONST_CAST(WGLEW_NV_DX_interop2) = _glewSearchExtension(\"WGL_NV_DX_interop2\", extStart, extEnd);\n#endif /* WGL_NV_DX_interop2 */\n#ifdef WGL_NV_copy_image\n  CONST_CAST(WGLEW_NV_copy_image) = _glewSearchExtension(\"WGL_NV_copy_image\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_copy_image|| crippled) CONST_CAST(WGLEW_NV_copy_image)= !_glewInit_WGL_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_copy_image */\n#ifdef WGL_NV_float_buffer\n  CONST_CAST(WGLEW_NV_float_buffer) = _glewSearchExtension(\"WGL_NV_float_buffer\", extStart, extEnd);\n#endif /* WGL_NV_float_buffer */\n#ifdef WGL_NV_gpu_affinity\n  CONST_CAST(WGLEW_NV_gpu_affinity) = _glewSearchExtension(\"WGL_NV_gpu_affinity\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_gpu_affinity|| crippled) CONST_CAST(WGLEW_NV_gpu_affinity)= !_glewInit_WGL_NV_gpu_affinity(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_gpu_affinity */\n#ifdef WGL_NV_multisample_coverage\n  CONST_CAST(WGLEW_NV_multisample_coverage) = _glewSearchExtension(\"WGL_NV_multisample_coverage\", extStart, extEnd);\n#endif /* WGL_NV_multisample_coverage */\n#ifdef WGL_NV_present_video\n  CONST_CAST(WGLEW_NV_present_video) = _glewSearchExtension(\"WGL_NV_present_video\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_present_video|| crippled) CONST_CAST(WGLEW_NV_present_video)= !_glewInit_WGL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_present_video */\n#ifdef WGL_NV_render_depth_texture\n  CONST_CAST(WGLEW_NV_render_depth_texture) = _glewSearchExtension(\"WGL_NV_render_depth_texture\", extStart, extEnd);\n#endif /* WGL_NV_render_depth_texture */\n#ifdef WGL_NV_render_texture_rectangle\n  CONST_CAST(WGLEW_NV_render_texture_rectangle) = _glewSearchExtension(\"WGL_NV_render_texture_rectangle\", extStart, extEnd);\n#endif /* WGL_NV_render_texture_rectangle */\n#ifdef WGL_NV_swap_group\n  CONST_CAST(WGLEW_NV_swap_group) = _glewSearchExtension(\"WGL_NV_swap_group\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_swap_group|| crippled) CONST_CAST(WGLEW_NV_swap_group)= !_glewInit_WGL_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_swap_group */\n#ifdef WGL_NV_vertex_array_range\n  CONST_CAST(WGLEW_NV_vertex_array_range) = _glewSearchExtension(\"WGL_NV_vertex_array_range\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_vertex_array_range|| crippled) CONST_CAST(WGLEW_NV_vertex_array_range)= !_glewInit_WGL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_vertex_array_range */\n#ifdef WGL_NV_video_capture\n  CONST_CAST(WGLEW_NV_video_capture) = _glewSearchExtension(\"WGL_NV_video_capture\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_video_capture|| crippled) CONST_CAST(WGLEW_NV_video_capture)= !_glewInit_WGL_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_video_capture */\n#ifdef WGL_NV_video_output\n  CONST_CAST(WGLEW_NV_video_output) = _glewSearchExtension(\"WGL_NV_video_output\", extStart, extEnd);\n  if (glewExperimental || WGLEW_NV_video_output|| crippled) CONST_CAST(WGLEW_NV_video_output)= !_glewInit_WGL_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_NV_video_output */\n#ifdef WGL_OML_sync_control\n  CONST_CAST(WGLEW_OML_sync_control) = _glewSearchExtension(\"WGL_OML_sync_control\", extStart, extEnd);\n  if (glewExperimental || WGLEW_OML_sync_control|| crippled) CONST_CAST(WGLEW_OML_sync_control)= !_glewInit_WGL_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* WGL_OML_sync_control */\n\n  return GLEW_OK;\n}\n\n#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))\n\nPFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL;\n\nPFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL;\nPFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext = NULL;\nPFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer = NULL;\nPFNGLXCREATEPIXMAPPROC __glewXCreatePixmap = NULL;\nPFNGLXCREATEWINDOWPROC __glewXCreateWindow = NULL;\nPFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer = NULL;\nPFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap = NULL;\nPFNGLXDESTROYWINDOWPROC __glewXDestroyWindow = NULL;\nPFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable = NULL;\nPFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib = NULL;\nPFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs = NULL;\nPFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent = NULL;\nPFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig = NULL;\nPFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent = NULL;\nPFNGLXQUERYCONTEXTPROC __glewXQueryContext = NULL;\nPFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable = NULL;\nPFNGLXSELECTEVENTPROC __glewXSelectEvent = NULL;\n\nPFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB = NULL;\n\nPFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI = NULL;\nPFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI = NULL;\nPFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI = NULL;\n\nPFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT = NULL;\nPFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT = NULL;\nPFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT = NULL;\nPFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT = NULL;\n\nPFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT = NULL;\n\nPFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT = NULL;\nPFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT = NULL;\n\nPFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA = NULL;\n\nPFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA = NULL;\n\nPFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA = NULL;\n\nPFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA = NULL;\n\nPFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA = NULL;\n\nPFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA = NULL;\nPFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA = NULL;\n\nPFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV = NULL;\n\nPFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV = NULL;\nPFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV = NULL;\n\nPFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV = NULL;\nPFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV = NULL;\nPFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV = NULL;\nPFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV = NULL;\nPFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV = NULL;\nPFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV = NULL;\n\nPFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV = NULL;\nPFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV = NULL;\n\nPFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV = NULL;\nPFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV = NULL;\nPFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV = NULL;\nPFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV = NULL;\nPFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV = NULL;\n\nPFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV = NULL;\nPFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV = NULL;\nPFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV = NULL;\nPFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV = NULL;\nPFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV = NULL;\nPFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV = NULL;\n\nPFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML = NULL;\nPFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML = NULL;\nPFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML = NULL;\nPFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML = NULL;\nPFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML = NULL;\n\nPFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX = NULL;\nPFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX = NULL;\nPFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX = NULL;\nPFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX = NULL;\nPFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX = NULL;\nPFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX = NULL;\n\nPFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX = NULL;\nPFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX = NULL;\nPFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX = NULL;\nPFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX = NULL;\nPFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX = NULL;\nPFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX = NULL;\nPFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX = NULL;\nPFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX = NULL;\n\nPFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX = NULL;\nPFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX = NULL;\nPFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX = NULL;\nPFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX = NULL;\nPFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX = NULL;\n\nPFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX = NULL;\nPFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX = NULL;\n\nPFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX = NULL;\n\nPFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX = NULL;\nPFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX = NULL;\nPFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX = NULL;\nPFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX = NULL;\nPFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX = NULL;\n\nPFNGLXCUSHIONSGIPROC __glewXCushionSGI = NULL;\n\nPFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI = NULL;\nPFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI = NULL;\n\nPFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI = NULL;\n\nPFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI = NULL;\nPFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI = NULL;\n\nPFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN = NULL;\n\nPFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN = NULL;\nPFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN = NULL;\n\n#if !defined(GLEW_MX)\n\nGLboolean __GLXEW_VERSION_1_0 = GL_FALSE;\nGLboolean __GLXEW_VERSION_1_1 = GL_FALSE;\nGLboolean __GLXEW_VERSION_1_2 = GL_FALSE;\nGLboolean __GLXEW_VERSION_1_3 = GL_FALSE;\nGLboolean __GLXEW_VERSION_1_4 = GL_FALSE;\nGLboolean __GLXEW_3DFX_multisample = GL_FALSE;\nGLboolean __GLXEW_AMD_gpu_association = GL_FALSE;\nGLboolean __GLXEW_ARB_create_context = GL_FALSE;\nGLboolean __GLXEW_ARB_create_context_profile = GL_FALSE;\nGLboolean __GLXEW_ARB_create_context_robustness = GL_FALSE;\nGLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE;\nGLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE;\nGLboolean __GLXEW_ARB_get_proc_address = GL_FALSE;\nGLboolean __GLXEW_ARB_multisample = GL_FALSE;\nGLboolean __GLXEW_ARB_robustness_application_isolation = GL_FALSE;\nGLboolean __GLXEW_ARB_robustness_share_group_isolation = GL_FALSE;\nGLboolean __GLXEW_ARB_vertex_buffer_object = GL_FALSE;\nGLboolean __GLXEW_ATI_pixel_format_float = GL_FALSE;\nGLboolean __GLXEW_ATI_render_texture = GL_FALSE;\nGLboolean __GLXEW_EXT_create_context_es2_profile = GL_FALSE;\nGLboolean __GLXEW_EXT_create_context_es_profile = GL_FALSE;\nGLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE;\nGLboolean __GLXEW_EXT_framebuffer_sRGB = GL_FALSE;\nGLboolean __GLXEW_EXT_import_context = GL_FALSE;\nGLboolean __GLXEW_EXT_scene_marker = GL_FALSE;\nGLboolean __GLXEW_EXT_swap_control = GL_FALSE;\nGLboolean __GLXEW_EXT_swap_control_tear = GL_FALSE;\nGLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE;\nGLboolean __GLXEW_EXT_visual_info = GL_FALSE;\nGLboolean __GLXEW_EXT_visual_rating = GL_FALSE;\nGLboolean __GLXEW_INTEL_swap_event = GL_FALSE;\nGLboolean __GLXEW_MESA_agp_offset = GL_FALSE;\nGLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE;\nGLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE;\nGLboolean __GLXEW_MESA_release_buffers = GL_FALSE;\nGLboolean __GLXEW_MESA_set_3dfx_mode = GL_FALSE;\nGLboolean __GLXEW_MESA_swap_control = GL_FALSE;\nGLboolean __GLXEW_NV_copy_image = GL_FALSE;\nGLboolean __GLXEW_NV_float_buffer = GL_FALSE;\nGLboolean __GLXEW_NV_multisample_coverage = GL_FALSE;\nGLboolean __GLXEW_NV_present_video = GL_FALSE;\nGLboolean __GLXEW_NV_swap_group = GL_FALSE;\nGLboolean __GLXEW_NV_vertex_array_range = GL_FALSE;\nGLboolean __GLXEW_NV_video_capture = GL_FALSE;\nGLboolean __GLXEW_NV_video_out = GL_FALSE;\nGLboolean __GLXEW_OML_swap_method = GL_FALSE;\nGLboolean __GLXEW_OML_sync_control = GL_FALSE;\nGLboolean __GLXEW_SGIS_blended_overlay = GL_FALSE;\nGLboolean __GLXEW_SGIS_color_range = GL_FALSE;\nGLboolean __GLXEW_SGIS_multisample = GL_FALSE;\nGLboolean __GLXEW_SGIS_shared_multisample = GL_FALSE;\nGLboolean __GLXEW_SGIX_fbconfig = GL_FALSE;\nGLboolean __GLXEW_SGIX_hyperpipe = GL_FALSE;\nGLboolean __GLXEW_SGIX_pbuffer = GL_FALSE;\nGLboolean __GLXEW_SGIX_swap_barrier = GL_FALSE;\nGLboolean __GLXEW_SGIX_swap_group = GL_FALSE;\nGLboolean __GLXEW_SGIX_video_resize = GL_FALSE;\nGLboolean __GLXEW_SGIX_visual_select_group = GL_FALSE;\nGLboolean __GLXEW_SGI_cushion = GL_FALSE;\nGLboolean __GLXEW_SGI_make_current_read = GL_FALSE;\nGLboolean __GLXEW_SGI_swap_control = GL_FALSE;\nGLboolean __GLXEW_SGI_video_sync = GL_FALSE;\nGLboolean __GLXEW_SUN_get_transparent_index = GL_FALSE;\nGLboolean __GLXEW_SUN_video_resize = GL_FALSE;\n\n#endif /* !GLEW_MX */\n\n#ifdef GLX_VERSION_1_2\n\nstatic GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)glewGetProcAddress((const GLubyte*)\"glXGetCurrentDisplay\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_VERSION_1_2 */\n\n#ifdef GLX_VERSION_1_3\n\nstatic GLboolean _glewInit_GLX_VERSION_1_3 (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glewGetProcAddress((const GLubyte*)\"glXChooseFBConfig\")) == NULL) || r;\n  r = ((glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)glewGetProcAddress((const GLubyte*)\"glXCreateNewContext\")) == NULL) || r;\n  r = ((glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glXCreatePbuffer\")) == NULL) || r;\n  r = ((glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)glewGetProcAddress((const GLubyte*)\"glXCreatePixmap\")) == NULL) || r;\n  r = ((glXCreateWindow = (PFNGLXCREATEWINDOWPROC)glewGetProcAddress((const GLubyte*)\"glXCreateWindow\")) == NULL) || r;\n  r = ((glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)glewGetProcAddress((const GLubyte*)\"glXDestroyPbuffer\")) == NULL) || r;\n  r = ((glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)glewGetProcAddress((const GLubyte*)\"glXDestroyPixmap\")) == NULL) || r;\n  r = ((glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)glewGetProcAddress((const GLubyte*)\"glXDestroyWindow\")) == NULL) || r;\n  r = ((glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)glewGetProcAddress((const GLubyte*)\"glXGetCurrentReadDrawable\")) == NULL) || r;\n  r = ((glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)glewGetProcAddress((const GLubyte*)\"glXGetFBConfigAttrib\")) == NULL) || r;\n  r = ((glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)glewGetProcAddress((const GLubyte*)\"glXGetFBConfigs\")) == NULL) || r;\n  r = ((glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)glewGetProcAddress((const GLubyte*)\"glXGetSelectedEvent\")) == NULL) || r;\n  r = ((glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glewGetProcAddress((const GLubyte*)\"glXGetVisualFromFBConfig\")) == NULL) || r;\n  r = ((glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)glewGetProcAddress((const GLubyte*)\"glXMakeContextCurrent\")) == NULL) || r;\n  r = ((glXQueryContext = (PFNGLXQUERYCONTEXTPROC)glewGetProcAddress((const GLubyte*)\"glXQueryContext\")) == NULL) || r;\n  r = ((glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)glewGetProcAddress((const GLubyte*)\"glXQueryDrawable\")) == NULL) || r;\n  r = ((glXSelectEvent = (PFNGLXSELECTEVENTPROC)glewGetProcAddress((const GLubyte*)\"glXSelectEvent\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_VERSION_1_3 */\n\n#ifdef GLX_VERSION_1_4\n\n#endif /* GLX_VERSION_1_4 */\n\n#ifdef GLX_3DFX_multisample\n\n#endif /* GLX_3DFX_multisample */\n\n#ifdef GLX_AMD_gpu_association\n\n#endif /* GLX_AMD_gpu_association */\n\n#ifdef GLX_ARB_create_context\n\nstatic GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)\"glXCreateContextAttribsARB\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_ARB_create_context */\n\n#ifdef GLX_ARB_create_context_profile\n\n#endif /* GLX_ARB_create_context_profile */\n\n#ifdef GLX_ARB_create_context_robustness\n\n#endif /* GLX_ARB_create_context_robustness */\n\n#ifdef GLX_ARB_fbconfig_float\n\n#endif /* GLX_ARB_fbconfig_float */\n\n#ifdef GLX_ARB_framebuffer_sRGB\n\n#endif /* GLX_ARB_framebuffer_sRGB */\n\n#ifdef GLX_ARB_get_proc_address\n\n#endif /* GLX_ARB_get_proc_address */\n\n#ifdef GLX_ARB_multisample\n\n#endif /* GLX_ARB_multisample */\n\n#ifdef GLX_ARB_robustness_application_isolation\n\n#endif /* GLX_ARB_robustness_application_isolation */\n\n#ifdef GLX_ARB_robustness_share_group_isolation\n\n#endif /* GLX_ARB_robustness_share_group_isolation */\n\n#ifdef GLX_ARB_vertex_buffer_object\n\n#endif /* GLX_ARB_vertex_buffer_object */\n\n#ifdef GLX_ATI_pixel_format_float\n\n#endif /* GLX_ATI_pixel_format_float */\n\n#ifdef GLX_ATI_render_texture\n\nstatic GLboolean _glewInit_GLX_ATI_render_texture (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindTexImageATI = (PFNGLXBINDTEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)\"glXBindTexImageATI\")) == NULL) || r;\n  r = ((glXDrawableAttribATI = (PFNGLXDRAWABLEATTRIBATIPROC)glewGetProcAddress((const GLubyte*)\"glXDrawableAttribATI\")) == NULL) || r;\n  r = ((glXReleaseTexImageATI = (PFNGLXRELEASETEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseTexImageATI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_ATI_render_texture */\n\n#ifdef GLX_EXT_create_context_es2_profile\n\n#endif /* GLX_EXT_create_context_es2_profile */\n\n#ifdef GLX_EXT_create_context_es_profile\n\n#endif /* GLX_EXT_create_context_es_profile */\n\n#ifdef GLX_EXT_fbconfig_packed_float\n\n#endif /* GLX_EXT_fbconfig_packed_float */\n\n#ifdef GLX_EXT_framebuffer_sRGB\n\n#endif /* GLX_EXT_framebuffer_sRGB */\n\n#ifdef GLX_EXT_import_context\n\nstatic GLboolean _glewInit_GLX_EXT_import_context (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXFreeContextEXT = (PFNGLXFREECONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)\"glXFreeContextEXT\")) == NULL) || r;\n  r = ((glXGetContextIDEXT = (PFNGLXGETCONTEXTIDEXTPROC)glewGetProcAddress((const GLubyte*)\"glXGetContextIDEXT\")) == NULL) || r;\n  r = ((glXImportContextEXT = (PFNGLXIMPORTCONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)\"glXImportContextEXT\")) == NULL) || r;\n  r = ((glXQueryContextInfoEXT = (PFNGLXQUERYCONTEXTINFOEXTPROC)glewGetProcAddress((const GLubyte*)\"glXQueryContextInfoEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_EXT_import_context */\n\n#ifdef GLX_EXT_scene_marker\n\n#endif /* GLX_EXT_scene_marker */\n\n#ifdef GLX_EXT_swap_control\n\nstatic GLboolean _glewInit_GLX_EXT_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)\"glXSwapIntervalEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_EXT_swap_control */\n\n#ifdef GLX_EXT_swap_control_tear\n\n#endif /* GLX_EXT_swap_control_tear */\n\n#ifdef GLX_EXT_texture_from_pixmap\n\nstatic GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glXBindTexImageEXT\")) == NULL) || r;\n  r = ((glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseTexImageEXT\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_EXT_texture_from_pixmap */\n\n#ifdef GLX_EXT_visual_info\n\n#endif /* GLX_EXT_visual_info */\n\n#ifdef GLX_EXT_visual_rating\n\n#endif /* GLX_EXT_visual_rating */\n\n#ifdef GLX_INTEL_swap_event\n\n#endif /* GLX_INTEL_swap_event */\n\n#ifdef GLX_MESA_agp_offset\n\nstatic GLboolean _glewInit_GLX_MESA_agp_offset (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetAGPOffsetMESA = (PFNGLXGETAGPOFFSETMESAPROC)glewGetProcAddress((const GLubyte*)\"glXGetAGPOffsetMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_agp_offset */\n\n#ifdef GLX_MESA_copy_sub_buffer\n\nstatic GLboolean _glewInit_GLX_MESA_copy_sub_buffer (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCopySubBufferMESA = (PFNGLXCOPYSUBBUFFERMESAPROC)glewGetProcAddress((const GLubyte*)\"glXCopySubBufferMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_copy_sub_buffer */\n\n#ifdef GLX_MESA_pixmap_colormap\n\nstatic GLboolean _glewInit_GLX_MESA_pixmap_colormap (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCreateGLXPixmapMESA = (PFNGLXCREATEGLXPIXMAPMESAPROC)glewGetProcAddress((const GLubyte*)\"glXCreateGLXPixmapMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_pixmap_colormap */\n\n#ifdef GLX_MESA_release_buffers\n\nstatic GLboolean _glewInit_GLX_MESA_release_buffers (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXReleaseBuffersMESA = (PFNGLXRELEASEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseBuffersMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_release_buffers */\n\n#ifdef GLX_MESA_set_3dfx_mode\n\nstatic GLboolean _glewInit_GLX_MESA_set_3dfx_mode (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXSet3DfxModeMESA = (PFNGLXSET3DFXMODEMESAPROC)glewGetProcAddress((const GLubyte*)\"glXSet3DfxModeMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_set_3dfx_mode */\n\n#ifdef GLX_MESA_swap_control\n\nstatic GLboolean _glewInit_GLX_MESA_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC)glewGetProcAddress((const GLubyte*)\"glXGetSwapIntervalMESA\")) == NULL) || r;\n  r = ((glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)glewGetProcAddress((const GLubyte*)\"glXSwapIntervalMESA\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_MESA_swap_control */\n\n#ifdef GLX_NV_copy_image\n\nstatic GLboolean _glewInit_GLX_NV_copy_image (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCopyImageSubDataNV = (PFNGLXCOPYIMAGESUBDATANVPROC)glewGetProcAddress((const GLubyte*)\"glXCopyImageSubDataNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_copy_image */\n\n#ifdef GLX_NV_float_buffer\n\n#endif /* GLX_NV_float_buffer */\n\n#ifdef GLX_NV_multisample_coverage\n\n#endif /* GLX_NV_multisample_coverage */\n\n#ifdef GLX_NV_present_video\n\nstatic GLboolean _glewInit_GLX_NV_present_video (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindVideoDeviceNV = (PFNGLXBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXBindVideoDeviceNV\")) == NULL) || r;\n  r = ((glXEnumerateVideoDevicesNV = (PFNGLXENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)\"glXEnumerateVideoDevicesNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_present_video */\n\n#ifdef GLX_NV_swap_group\n\nstatic GLboolean _glewInit_GLX_NV_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)\"glXBindSwapBarrierNV\")) == NULL) || r;\n  r = ((glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)\"glXJoinSwapGroupNV\")) == NULL) || r;\n  r = ((glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)\"glXQueryFrameCountNV\")) == NULL) || r;\n  r = ((glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)\"glXQueryMaxSwapGroupsNV\")) == NULL) || r;\n  r = ((glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)\"glXQuerySwapGroupNV\")) == NULL) || r;\n  r = ((glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)\"glXResetFrameCountNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_swap_group */\n\n#ifdef GLX_NV_vertex_array_range\n\nstatic GLboolean _glewInit_GLX_NV_vertex_array_range (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXAllocateMemoryNV = (PFNGLXALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)\"glXAllocateMemoryNV\")) == NULL) || r;\n  r = ((glXFreeMemoryNV = (PFNGLXFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)\"glXFreeMemoryNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_vertex_array_range */\n\n#ifdef GLX_NV_video_capture\n\nstatic GLboolean _glewInit_GLX_NV_video_capture (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindVideoCaptureDeviceNV = (PFNGLXBINDVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXBindVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((glXEnumerateVideoCaptureDevicesNV = (PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC)glewGetProcAddress((const GLubyte*)\"glXEnumerateVideoCaptureDevicesNV\")) == NULL) || r;\n  r = ((glXLockVideoCaptureDeviceNV = (PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXLockVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((glXQueryVideoCaptureDeviceNV = (PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXQueryVideoCaptureDeviceNV\")) == NULL) || r;\n  r = ((glXReleaseVideoCaptureDeviceNV = (PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseVideoCaptureDeviceNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_video_capture */\n\n#ifdef GLX_NV_video_out\n\nstatic GLboolean _glewInit_GLX_NV_video_out (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindVideoImageNV = (PFNGLXBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)\"glXBindVideoImageNV\")) == NULL) || r;\n  r = ((glXGetVideoDeviceNV = (PFNGLXGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXGetVideoDeviceNV\")) == NULL) || r;\n  r = ((glXGetVideoInfoNV = (PFNGLXGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)\"glXGetVideoInfoNV\")) == NULL) || r;\n  r = ((glXReleaseVideoDeviceNV = (PFNGLXRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseVideoDeviceNV\")) == NULL) || r;\n  r = ((glXReleaseVideoImageNV = (PFNGLXRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)\"glXReleaseVideoImageNV\")) == NULL) || r;\n  r = ((glXSendPbufferToVideoNV = (PFNGLXSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)\"glXSendPbufferToVideoNV\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_NV_video_out */\n\n#ifdef GLX_OML_swap_method\n\n#endif /* GLX_OML_swap_method */\n\n#ifdef GLX_OML_sync_control\n\nstatic GLboolean _glewInit_GLX_OML_sync_control (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetMscRateOML = (PFNGLXGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)\"glXGetMscRateOML\")) == NULL) || r;\n  r = ((glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)\"glXGetSyncValuesOML\")) == NULL) || r;\n  r = ((glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)\"glXSwapBuffersMscOML\")) == NULL) || r;\n  r = ((glXWaitForMscOML = (PFNGLXWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)\"glXWaitForMscOML\")) == NULL) || r;\n  r = ((glXWaitForSbcOML = (PFNGLXWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)\"glXWaitForSbcOML\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_OML_sync_control */\n\n#ifdef GLX_SGIS_blended_overlay\n\n#endif /* GLX_SGIS_blended_overlay */\n\n#ifdef GLX_SGIS_color_range\n\n#endif /* GLX_SGIS_color_range */\n\n#ifdef GLX_SGIS_multisample\n\n#endif /* GLX_SGIS_multisample */\n\n#ifdef GLX_SGIS_shared_multisample\n\n#endif /* GLX_SGIS_shared_multisample */\n\n#ifdef GLX_SGIX_fbconfig\n\nstatic GLboolean _glewInit_GLX_SGIX_fbconfig (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXChooseFBConfigSGIX\")) == NULL) || r;\n  r = ((glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXCreateContextWithConfigSGIX\")) == NULL) || r;\n  r = ((glXCreateGLXPixmapWithConfigSGIX = (PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXCreateGLXPixmapWithConfigSGIX\")) == NULL) || r;\n  r = ((glXGetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXGetFBConfigAttribSGIX\")) == NULL) || r;\n  r = ((glXGetFBConfigFromVisualSGIX = (PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXGetFBConfigFromVisualSGIX\")) == NULL) || r;\n  r = ((glXGetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXGetVisualFromFBConfigSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_fbconfig */\n\n#ifdef GLX_SGIX_hyperpipe\n\nstatic GLboolean _glewInit_GLX_SGIX_hyperpipe (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindHyperpipeSGIX = (PFNGLXBINDHYPERPIPESGIXPROC)glewGetProcAddress((const GLubyte*)\"glXBindHyperpipeSGIX\")) == NULL) || r;\n  r = ((glXDestroyHyperpipeConfigSGIX = (PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXDestroyHyperpipeConfigSGIX\")) == NULL) || r;\n  r = ((glXHyperpipeAttribSGIX = (PFNGLXHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXHyperpipeAttribSGIX\")) == NULL) || r;\n  r = ((glXHyperpipeConfigSGIX = (PFNGLXHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXHyperpipeConfigSGIX\")) == NULL) || r;\n  r = ((glXQueryHyperpipeAttribSGIX = (PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryHyperpipeAttribSGIX\")) == NULL) || r;\n  r = ((glXQueryHyperpipeBestAttribSGIX = (PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryHyperpipeBestAttribSGIX\")) == NULL) || r;\n  r = ((glXQueryHyperpipeConfigSGIX = (PFNGLXQUERYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryHyperpipeConfigSGIX\")) == NULL) || r;\n  r = ((glXQueryHyperpipeNetworkSGIX = (PFNGLXQUERYHYPERPIPENETWORKSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryHyperpipeNetworkSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_hyperpipe */\n\n#ifdef GLX_SGIX_pbuffer\n\nstatic GLboolean _glewInit_GLX_SGIX_pbuffer (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXCreateGLXPbufferSGIX\")) == NULL) || r;\n  r = ((glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXDestroyGLXPbufferSGIX\")) == NULL) || r;\n  r = ((glXGetSelectedEventSGIX = (PFNGLXGETSELECTEDEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXGetSelectedEventSGIX\")) == NULL) || r;\n  r = ((glXQueryGLXPbufferSGIX = (PFNGLXQUERYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryGLXPbufferSGIX\")) == NULL) || r;\n  r = ((glXSelectEventSGIX = (PFNGLXSELECTEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXSelectEventSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_pbuffer */\n\n#ifdef GLX_SGIX_swap_barrier\n\nstatic GLboolean _glewInit_GLX_SGIX_swap_barrier (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindSwapBarrierSGIX = (PFNGLXBINDSWAPBARRIERSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXBindSwapBarrierSGIX\")) == NULL) || r;\n  r = ((glXQueryMaxSwapBarriersSGIX = (PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryMaxSwapBarriersSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_swap_barrier */\n\n#ifdef GLX_SGIX_swap_group\n\nstatic GLboolean _glewInit_GLX_SGIX_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXJoinSwapGroupSGIX = (PFNGLXJOINSWAPGROUPSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXJoinSwapGroupSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_swap_group */\n\n#ifdef GLX_SGIX_video_resize\n\nstatic GLboolean _glewInit_GLX_SGIX_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXBindChannelToWindowSGIX = (PFNGLXBINDCHANNELTOWINDOWSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXBindChannelToWindowSGIX\")) == NULL) || r;\n  r = ((glXChannelRectSGIX = (PFNGLXCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXChannelRectSGIX\")) == NULL) || r;\n  r = ((glXChannelRectSyncSGIX = (PFNGLXCHANNELRECTSYNCSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXChannelRectSyncSGIX\")) == NULL) || r;\n  r = ((glXQueryChannelDeltasSGIX = (PFNGLXQUERYCHANNELDELTASSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryChannelDeltasSGIX\")) == NULL) || r;\n  r = ((glXQueryChannelRectSGIX = (PFNGLXQUERYCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)\"glXQueryChannelRectSGIX\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGIX_video_resize */\n\n#ifdef GLX_SGIX_visual_select_group\n\n#endif /* GLX_SGIX_visual_select_group */\n\n#ifdef GLX_SGI_cushion\n\nstatic GLboolean _glewInit_GLX_SGI_cushion (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXCushionSGI = (PFNGLXCUSHIONSGIPROC)glewGetProcAddress((const GLubyte*)\"glXCushionSGI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGI_cushion */\n\n#ifdef GLX_SGI_make_current_read\n\nstatic GLboolean _glewInit_GLX_SGI_make_current_read (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetCurrentReadDrawableSGI = (PFNGLXGETCURRENTREADDRAWABLESGIPROC)glewGetProcAddress((const GLubyte*)\"glXGetCurrentReadDrawableSGI\")) == NULL) || r;\n  r = ((glXMakeCurrentReadSGI = (PFNGLXMAKECURRENTREADSGIPROC)glewGetProcAddress((const GLubyte*)\"glXMakeCurrentReadSGI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGI_make_current_read */\n\n#ifdef GLX_SGI_swap_control\n\nstatic GLboolean _glewInit_GLX_SGI_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glewGetProcAddress((const GLubyte*)\"glXSwapIntervalSGI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGI_swap_control */\n\n#ifdef GLX_SGI_video_sync\n\nstatic GLboolean _glewInit_GLX_SGI_video_sync (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)\"glXGetVideoSyncSGI\")) == NULL) || r;\n  r = ((glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)\"glXWaitVideoSyncSGI\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SGI_video_sync */\n\n#ifdef GLX_SUN_get_transparent_index\n\nstatic GLboolean _glewInit_GLX_SUN_get_transparent_index (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetTransparentIndexSUN = (PFNGLXGETTRANSPARENTINDEXSUNPROC)glewGetProcAddress((const GLubyte*)\"glXGetTransparentIndexSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SUN_get_transparent_index */\n\n#ifdef GLX_SUN_video_resize\n\nstatic GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT)\n{\n  GLboolean r = GL_FALSE;\n\n  r = ((glXGetVideoResizeSUN = (PFNGLXGETVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)\"glXGetVideoResizeSUN\")) == NULL) || r;\n  r = ((glXVideoResizeSUN = (PFNGLXVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)\"glXVideoResizeSUN\")) == NULL) || r;\n\n  return r;\n}\n\n#endif /* GLX_SUN_video_resize */\n\n/* ------------------------------------------------------------------------ */\n\nGLboolean glxewGetExtension (const char* name)\n{    \n  const GLubyte* start;\n  const GLubyte* end;\n\n  if (glXGetCurrentDisplay == NULL) return GL_FALSE;\n  start = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);\n  if (0 == start) return GL_FALSE;\n  end = start + _glewStrLen(start);\n  return _glewSearchExtension(name, start, end);\n}\n\nGLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)\n{\n  int major, minor;\n  const GLubyte* extStart;\n  const GLubyte* extEnd;\n  /* initialize core GLX 1.2 */\n  if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY;\n  /* initialize flags */\n  CONST_CAST(GLXEW_VERSION_1_0) = GL_TRUE;\n  CONST_CAST(GLXEW_VERSION_1_1) = GL_TRUE;\n  CONST_CAST(GLXEW_VERSION_1_2) = GL_TRUE;\n  CONST_CAST(GLXEW_VERSION_1_3) = GL_TRUE;\n  CONST_CAST(GLXEW_VERSION_1_4) = GL_TRUE;\n  /* query GLX version */\n  glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);\n  if (major == 1 && minor <= 3)\n  {\n    switch (minor)\n    {\n      case 3:\n      CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE;\n      break;\n      case 2:\n      CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE;\n      CONST_CAST(GLXEW_VERSION_1_3) = GL_FALSE;\n      break;\n      default:\n      return GLEW_ERROR_GLX_VERSION_11_ONLY;\n      break;\n    }\n  }\n  /* query GLX extension string */\n  extStart = 0;\n  if (glXGetCurrentDisplay != NULL)\n    extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);\n  if (extStart == 0)\n    extStart = (const GLubyte *)\"\";\n  extEnd = extStart + _glewStrLen(extStart);\n  /* initialize extensions */\n#ifdef GLX_VERSION_1_3\n  if (glewExperimental || GLXEW_VERSION_1_3) CONST_CAST(GLXEW_VERSION_1_3) = !_glewInit_GLX_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_VERSION_1_3 */\n#ifdef GLX_3DFX_multisample\n  CONST_CAST(GLXEW_3DFX_multisample) = _glewSearchExtension(\"GLX_3DFX_multisample\", extStart, extEnd);\n#endif /* GLX_3DFX_multisample */\n#ifdef GLX_AMD_gpu_association\n  CONST_CAST(GLXEW_AMD_gpu_association) = _glewSearchExtension(\"GLX_AMD_gpu_association\", extStart, extEnd);\n#endif /* GLX_AMD_gpu_association */\n#ifdef GLX_ARB_create_context\n  CONST_CAST(GLXEW_ARB_create_context) = _glewSearchExtension(\"GLX_ARB_create_context\", extStart, extEnd);\n  if (glewExperimental || GLXEW_ARB_create_context) CONST_CAST(GLXEW_ARB_create_context) = !_glewInit_GLX_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_ARB_create_context */\n#ifdef GLX_ARB_create_context_profile\n  CONST_CAST(GLXEW_ARB_create_context_profile) = _glewSearchExtension(\"GLX_ARB_create_context_profile\", extStart, extEnd);\n#endif /* GLX_ARB_create_context_profile */\n#ifdef GLX_ARB_create_context_robustness\n  CONST_CAST(GLXEW_ARB_create_context_robustness) = _glewSearchExtension(\"GLX_ARB_create_context_robustness\", extStart, extEnd);\n#endif /* GLX_ARB_create_context_robustness */\n#ifdef GLX_ARB_fbconfig_float\n  CONST_CAST(GLXEW_ARB_fbconfig_float) = _glewSearchExtension(\"GLX_ARB_fbconfig_float\", extStart, extEnd);\n#endif /* GLX_ARB_fbconfig_float */\n#ifdef GLX_ARB_framebuffer_sRGB\n  CONST_CAST(GLXEW_ARB_framebuffer_sRGB) = _glewSearchExtension(\"GLX_ARB_framebuffer_sRGB\", extStart, extEnd);\n#endif /* GLX_ARB_framebuffer_sRGB */\n#ifdef GLX_ARB_get_proc_address\n  CONST_CAST(GLXEW_ARB_get_proc_address) = _glewSearchExtension(\"GLX_ARB_get_proc_address\", extStart, extEnd);\n#endif /* GLX_ARB_get_proc_address */\n#ifdef GLX_ARB_multisample\n  CONST_CAST(GLXEW_ARB_multisample) = _glewSearchExtension(\"GLX_ARB_multisample\", extStart, extEnd);\n#endif /* GLX_ARB_multisample */\n#ifdef GLX_ARB_robustness_application_isolation\n  CONST_CAST(GLXEW_ARB_robustness_application_isolation) = _glewSearchExtension(\"GLX_ARB_robustness_application_isolation\", extStart, extEnd);\n#endif /* GLX_ARB_robustness_application_isolation */\n#ifdef GLX_ARB_robustness_share_group_isolation\n  CONST_CAST(GLXEW_ARB_robustness_share_group_isolation) = _glewSearchExtension(\"GLX_ARB_robustness_share_group_isolation\", extStart, extEnd);\n#endif /* GLX_ARB_robustness_share_group_isolation */\n#ifdef GLX_ARB_vertex_buffer_object\n  CONST_CAST(GLXEW_ARB_vertex_buffer_object) = _glewSearchExtension(\"GLX_ARB_vertex_buffer_object\", extStart, extEnd);\n#endif /* GLX_ARB_vertex_buffer_object */\n#ifdef GLX_ATI_pixel_format_float\n  CONST_CAST(GLXEW_ATI_pixel_format_float) = _glewSearchExtension(\"GLX_ATI_pixel_format_float\", extStart, extEnd);\n#endif /* GLX_ATI_pixel_format_float */\n#ifdef GLX_ATI_render_texture\n  CONST_CAST(GLXEW_ATI_render_texture) = _glewSearchExtension(\"GLX_ATI_render_texture\", extStart, extEnd);\n  if (glewExperimental || GLXEW_ATI_render_texture) CONST_CAST(GLXEW_ATI_render_texture) = !_glewInit_GLX_ATI_render_texture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_ATI_render_texture */\n#ifdef GLX_EXT_create_context_es2_profile\n  CONST_CAST(GLXEW_EXT_create_context_es2_profile) = _glewSearchExtension(\"GLX_EXT_create_context_es2_profile\", extStart, extEnd);\n#endif /* GLX_EXT_create_context_es2_profile */\n#ifdef GLX_EXT_create_context_es_profile\n  CONST_CAST(GLXEW_EXT_create_context_es_profile) = _glewSearchExtension(\"GLX_EXT_create_context_es_profile\", extStart, extEnd);\n#endif /* GLX_EXT_create_context_es_profile */\n#ifdef GLX_EXT_fbconfig_packed_float\n  CONST_CAST(GLXEW_EXT_fbconfig_packed_float) = _glewSearchExtension(\"GLX_EXT_fbconfig_packed_float\", extStart, extEnd);\n#endif /* GLX_EXT_fbconfig_packed_float */\n#ifdef GLX_EXT_framebuffer_sRGB\n  CONST_CAST(GLXEW_EXT_framebuffer_sRGB) = _glewSearchExtension(\"GLX_EXT_framebuffer_sRGB\", extStart, extEnd);\n#endif /* GLX_EXT_framebuffer_sRGB */\n#ifdef GLX_EXT_import_context\n  CONST_CAST(GLXEW_EXT_import_context) = _glewSearchExtension(\"GLX_EXT_import_context\", extStart, extEnd);\n  if (glewExperimental || GLXEW_EXT_import_context) CONST_CAST(GLXEW_EXT_import_context) = !_glewInit_GLX_EXT_import_context(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_EXT_import_context */\n#ifdef GLX_EXT_scene_marker\n  CONST_CAST(GLXEW_EXT_scene_marker) = _glewSearchExtension(\"GLX_EXT_scene_marker\", extStart, extEnd);\n#endif /* GLX_EXT_scene_marker */\n#ifdef GLX_EXT_swap_control\n  CONST_CAST(GLXEW_EXT_swap_control) = _glewSearchExtension(\"GLX_EXT_swap_control\", extStart, extEnd);\n  if (glewExperimental || GLXEW_EXT_swap_control) CONST_CAST(GLXEW_EXT_swap_control) = !_glewInit_GLX_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_EXT_swap_control */\n#ifdef GLX_EXT_swap_control_tear\n  CONST_CAST(GLXEW_EXT_swap_control_tear) = _glewSearchExtension(\"GLX_EXT_swap_control_tear\", extStart, extEnd);\n#endif /* GLX_EXT_swap_control_tear */\n#ifdef GLX_EXT_texture_from_pixmap\n  CONST_CAST(GLXEW_EXT_texture_from_pixmap) = _glewSearchExtension(\"GLX_EXT_texture_from_pixmap\", extStart, extEnd);\n  if (glewExperimental || GLXEW_EXT_texture_from_pixmap) CONST_CAST(GLXEW_EXT_texture_from_pixmap) = !_glewInit_GLX_EXT_texture_from_pixmap(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_EXT_texture_from_pixmap */\n#ifdef GLX_EXT_visual_info\n  CONST_CAST(GLXEW_EXT_visual_info) = _glewSearchExtension(\"GLX_EXT_visual_info\", extStart, extEnd);\n#endif /* GLX_EXT_visual_info */\n#ifdef GLX_EXT_visual_rating\n  CONST_CAST(GLXEW_EXT_visual_rating) = _glewSearchExtension(\"GLX_EXT_visual_rating\", extStart, extEnd);\n#endif /* GLX_EXT_visual_rating */\n#ifdef GLX_INTEL_swap_event\n  CONST_CAST(GLXEW_INTEL_swap_event) = _glewSearchExtension(\"GLX_INTEL_swap_event\", extStart, extEnd);\n#endif /* GLX_INTEL_swap_event */\n#ifdef GLX_MESA_agp_offset\n  CONST_CAST(GLXEW_MESA_agp_offset) = _glewSearchExtension(\"GLX_MESA_agp_offset\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_agp_offset) CONST_CAST(GLXEW_MESA_agp_offset) = !_glewInit_GLX_MESA_agp_offset(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_agp_offset */\n#ifdef GLX_MESA_copy_sub_buffer\n  CONST_CAST(GLXEW_MESA_copy_sub_buffer) = _glewSearchExtension(\"GLX_MESA_copy_sub_buffer\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_copy_sub_buffer) CONST_CAST(GLXEW_MESA_copy_sub_buffer) = !_glewInit_GLX_MESA_copy_sub_buffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_copy_sub_buffer */\n#ifdef GLX_MESA_pixmap_colormap\n  CONST_CAST(GLXEW_MESA_pixmap_colormap) = _glewSearchExtension(\"GLX_MESA_pixmap_colormap\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_pixmap_colormap) CONST_CAST(GLXEW_MESA_pixmap_colormap) = !_glewInit_GLX_MESA_pixmap_colormap(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_pixmap_colormap */\n#ifdef GLX_MESA_release_buffers\n  CONST_CAST(GLXEW_MESA_release_buffers) = _glewSearchExtension(\"GLX_MESA_release_buffers\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_release_buffers) CONST_CAST(GLXEW_MESA_release_buffers) = !_glewInit_GLX_MESA_release_buffers(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_release_buffers */\n#ifdef GLX_MESA_set_3dfx_mode\n  CONST_CAST(GLXEW_MESA_set_3dfx_mode) = _glewSearchExtension(\"GLX_MESA_set_3dfx_mode\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_set_3dfx_mode) CONST_CAST(GLXEW_MESA_set_3dfx_mode) = !_glewInit_GLX_MESA_set_3dfx_mode(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_set_3dfx_mode */\n#ifdef GLX_MESA_swap_control\n  CONST_CAST(GLXEW_MESA_swap_control) = _glewSearchExtension(\"GLX_MESA_swap_control\", extStart, extEnd);\n  if (glewExperimental || GLXEW_MESA_swap_control) CONST_CAST(GLXEW_MESA_swap_control) = !_glewInit_GLX_MESA_swap_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_MESA_swap_control */\n#ifdef GLX_NV_copy_image\n  CONST_CAST(GLXEW_NV_copy_image) = _glewSearchExtension(\"GLX_NV_copy_image\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_copy_image) CONST_CAST(GLXEW_NV_copy_image) = !_glewInit_GLX_NV_copy_image(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_copy_image */\n#ifdef GLX_NV_float_buffer\n  CONST_CAST(GLXEW_NV_float_buffer) = _glewSearchExtension(\"GLX_NV_float_buffer\", extStart, extEnd);\n#endif /* GLX_NV_float_buffer */\n#ifdef GLX_NV_multisample_coverage\n  CONST_CAST(GLXEW_NV_multisample_coverage) = _glewSearchExtension(\"GLX_NV_multisample_coverage\", extStart, extEnd);\n#endif /* GLX_NV_multisample_coverage */\n#ifdef GLX_NV_present_video\n  CONST_CAST(GLXEW_NV_present_video) = _glewSearchExtension(\"GLX_NV_present_video\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_present_video) CONST_CAST(GLXEW_NV_present_video) = !_glewInit_GLX_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_present_video */\n#ifdef GLX_NV_swap_group\n  CONST_CAST(GLXEW_NV_swap_group) = _glewSearchExtension(\"GLX_NV_swap_group\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_swap_group) CONST_CAST(GLXEW_NV_swap_group) = !_glewInit_GLX_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_swap_group */\n#ifdef GLX_NV_vertex_array_range\n  CONST_CAST(GLXEW_NV_vertex_array_range) = _glewSearchExtension(\"GLX_NV_vertex_array_range\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_vertex_array_range) CONST_CAST(GLXEW_NV_vertex_array_range) = !_glewInit_GLX_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_vertex_array_range */\n#ifdef GLX_NV_video_capture\n  CONST_CAST(GLXEW_NV_video_capture) = _glewSearchExtension(\"GLX_NV_video_capture\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_video_capture) CONST_CAST(GLXEW_NV_video_capture) = !_glewInit_GLX_NV_video_capture(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_video_capture */\n#ifdef GLX_NV_video_out\n  CONST_CAST(GLXEW_NV_video_out) = _glewSearchExtension(\"GLX_NV_video_out\", extStart, extEnd);\n  if (glewExperimental || GLXEW_NV_video_out) CONST_CAST(GLXEW_NV_video_out) = !_glewInit_GLX_NV_video_out(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_NV_video_out */\n#ifdef GLX_OML_swap_method\n  CONST_CAST(GLXEW_OML_swap_method) = _glewSearchExtension(\"GLX_OML_swap_method\", extStart, extEnd);\n#endif /* GLX_OML_swap_method */\n#ifdef GLX_OML_sync_control\n  CONST_CAST(GLXEW_OML_sync_control) = _glewSearchExtension(\"GLX_OML_sync_control\", extStart, extEnd);\n  if (glewExperimental || GLXEW_OML_sync_control) CONST_CAST(GLXEW_OML_sync_control) = !_glewInit_GLX_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_OML_sync_control */\n#ifdef GLX_SGIS_blended_overlay\n  CONST_CAST(GLXEW_SGIS_blended_overlay) = _glewSearchExtension(\"GLX_SGIS_blended_overlay\", extStart, extEnd);\n#endif /* GLX_SGIS_blended_overlay */\n#ifdef GLX_SGIS_color_range\n  CONST_CAST(GLXEW_SGIS_color_range) = _glewSearchExtension(\"GLX_SGIS_color_range\", extStart, extEnd);\n#endif /* GLX_SGIS_color_range */\n#ifdef GLX_SGIS_multisample\n  CONST_CAST(GLXEW_SGIS_multisample) = _glewSearchExtension(\"GLX_SGIS_multisample\", extStart, extEnd);\n#endif /* GLX_SGIS_multisample */\n#ifdef GLX_SGIS_shared_multisample\n  CONST_CAST(GLXEW_SGIS_shared_multisample) = _glewSearchExtension(\"GLX_SGIS_shared_multisample\", extStart, extEnd);\n#endif /* GLX_SGIS_shared_multisample */\n#ifdef GLX_SGIX_fbconfig\n  CONST_CAST(GLXEW_SGIX_fbconfig) = _glewSearchExtension(\"GLX_SGIX_fbconfig\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_fbconfig) CONST_CAST(GLXEW_SGIX_fbconfig) = !_glewInit_GLX_SGIX_fbconfig(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_fbconfig */\n#ifdef GLX_SGIX_hyperpipe\n  CONST_CAST(GLXEW_SGIX_hyperpipe) = _glewSearchExtension(\"GLX_SGIX_hyperpipe\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_hyperpipe) CONST_CAST(GLXEW_SGIX_hyperpipe) = !_glewInit_GLX_SGIX_hyperpipe(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_hyperpipe */\n#ifdef GLX_SGIX_pbuffer\n  CONST_CAST(GLXEW_SGIX_pbuffer) = _glewSearchExtension(\"GLX_SGIX_pbuffer\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_pbuffer) CONST_CAST(GLXEW_SGIX_pbuffer) = !_glewInit_GLX_SGIX_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_pbuffer */\n#ifdef GLX_SGIX_swap_barrier\n  CONST_CAST(GLXEW_SGIX_swap_barrier) = _glewSearchExtension(\"GLX_SGIX_swap_barrier\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_swap_barrier) CONST_CAST(GLXEW_SGIX_swap_barrier) = !_glewInit_GLX_SGIX_swap_barrier(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_swap_barrier */\n#ifdef GLX_SGIX_swap_group\n  CONST_CAST(GLXEW_SGIX_swap_group) = _glewSearchExtension(\"GLX_SGIX_swap_group\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_swap_group) CONST_CAST(GLXEW_SGIX_swap_group) = !_glewInit_GLX_SGIX_swap_group(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_swap_group */\n#ifdef GLX_SGIX_video_resize\n  CONST_CAST(GLXEW_SGIX_video_resize) = _glewSearchExtension(\"GLX_SGIX_video_resize\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGIX_video_resize) CONST_CAST(GLXEW_SGIX_video_resize) = !_glewInit_GLX_SGIX_video_resize(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGIX_video_resize */\n#ifdef GLX_SGIX_visual_select_group\n  CONST_CAST(GLXEW_SGIX_visual_select_group) = _glewSearchExtension(\"GLX_SGIX_visual_select_group\", extStart, extEnd);\n#endif /* GLX_SGIX_visual_select_group */\n#ifdef GLX_SGI_cushion\n  CONST_CAST(GLXEW_SGI_cushion) = _glewSearchExtension(\"GLX_SGI_cushion\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGI_cushion) CONST_CAST(GLXEW_SGI_cushion) = !_glewInit_GLX_SGI_cushion(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGI_cushion */\n#ifdef GLX_SGI_make_current_read\n  CONST_CAST(GLXEW_SGI_make_current_read) = _glewSearchExtension(\"GLX_SGI_make_current_read\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGI_make_current_read) CONST_CAST(GLXEW_SGI_make_current_read) = !_glewInit_GLX_SGI_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGI_make_current_read */\n#ifdef GLX_SGI_swap_control\n  CONST_CAST(GLXEW_SGI_swap_control) = _glewSearchExtension(\"GLX_SGI_swap_control\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGI_swap_control) CONST_CAST(GLXEW_SGI_swap_control) = !_glewInit_GLX_SGI_swap_control(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGI_swap_control */\n#ifdef GLX_SGI_video_sync\n  CONST_CAST(GLXEW_SGI_video_sync) = _glewSearchExtension(\"GLX_SGI_video_sync\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SGI_video_sync) CONST_CAST(GLXEW_SGI_video_sync) = !_glewInit_GLX_SGI_video_sync(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SGI_video_sync */\n#ifdef GLX_SUN_get_transparent_index\n  CONST_CAST(GLXEW_SUN_get_transparent_index) = _glewSearchExtension(\"GLX_SUN_get_transparent_index\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SUN_get_transparent_index) CONST_CAST(GLXEW_SUN_get_transparent_index) = !_glewInit_GLX_SUN_get_transparent_index(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SUN_get_transparent_index */\n#ifdef GLX_SUN_video_resize\n  CONST_CAST(GLXEW_SUN_video_resize) = _glewSearchExtension(\"GLX_SUN_video_resize\", extStart, extEnd);\n  if (glewExperimental || GLXEW_SUN_video_resize) CONST_CAST(GLXEW_SUN_video_resize) = !_glewInit_GLX_SUN_video_resize(GLEW_CONTEXT_ARG_VAR_INIT);\n#endif /* GLX_SUN_video_resize */\n\n  return GLEW_OK;\n}\n\n#endif /* !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) */\n\n/* ------------------------------------------------------------------------ */\n\nconst GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error)\n{\n  static const GLubyte* _glewErrorString[] =\n  {\n    (const GLubyte*)\"No error\",\n    (const GLubyte*)\"Missing GL version\",\n    (const GLubyte*)\"GL 1.1 and up are not supported\",\n    (const GLubyte*)\"GLX 1.2 and up are not supported\",\n    (const GLubyte*)\"Unknown error\"\n  };\n  const int max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1;\n  return _glewErrorString[(int)error > max_error ? max_error : (int)error];\n}\n\nconst GLubyte * GLEWAPIENTRY glewGetString (GLenum name)\n{\n  static const GLubyte* _glewString[] =\n  {\n    (const GLubyte*)NULL,\n    (const GLubyte*)\"1.9.0\",\n    (const GLubyte*)\"1\",\n    (const GLubyte*)\"9\",\n    (const GLubyte*)\"0\"\n  };\n  const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1;\n  return _glewString[(int)name > max_string ? 0 : (int)name];\n}\n\n/* ------------------------------------------------------------------------ */\n\nGLboolean glewExperimental = GL_FALSE;\n\n#if !defined(GLEW_MX)\n\n#if defined(_WIN32)\nextern GLenum GLEWAPIENTRY wglewContextInit (void);\n#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX))\nextern GLenum GLEWAPIENTRY glxewContextInit (void);\n#endif /* _WIN32 */\n\nGLenum GLEWAPIENTRY glewInit (void)\n{\n  GLenum r;\n  r = glewContextInit();\n  if ( r != 0 ) return r;\n#if defined(_WIN32)\n  return wglewContextInit();\n#elif !defined(__ANDROID__) && (!defined(__APPLE__) || defined(GLEW_APPLE_GLX)) /* _UNIX */\n  return glxewContextInit();\n#else\n  return r;\n#endif /* _WIN32 */\n}\n\n#endif /* !GLEW_MX */\n#ifdef GLEW_MX\nGLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext* ctx, const char* name)\n#else\nGLboolean GLEWAPIENTRY glewIsSupported (const char* name)\n#endif\n{\n  GLubyte* pos = (GLubyte*)name;\n  GLuint len = _glewStrLen(pos);\n  GLboolean ret = GL_TRUE;\n  while (ret && len > 0)\n  {\n    if (_glewStrSame1(&pos, &len, (const GLubyte*)\"GL_\", 3))\n    {\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"VERSION_\", 8))\n      {\n#ifdef GL_VERSION_1_2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_2\", 3))\n        {\n          ret = GLEW_VERSION_1_2;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_1_2_1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_2_1\", 5))\n        {\n          ret = GLEW_VERSION_1_2_1;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_1_3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_3\", 3))\n        {\n          ret = GLEW_VERSION_1_3;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_1_4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_4\", 3))\n        {\n          ret = GLEW_VERSION_1_4;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_1_5\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_5\", 3))\n        {\n          ret = GLEW_VERSION_1_5;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_2_0\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"2_0\", 3))\n        {\n          ret = GLEW_VERSION_2_0;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_2_1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"2_1\", 3))\n        {\n          ret = GLEW_VERSION_2_1;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_3_0\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"3_0\", 3))\n        {\n          ret = GLEW_VERSION_3_0;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_3_1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"3_1\", 3))\n        {\n          ret = GLEW_VERSION_3_1;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_3_2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"3_2\", 3))\n        {\n          ret = GLEW_VERSION_3_2;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_3_3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"3_3\", 3))\n        {\n          ret = GLEW_VERSION_3_3;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_4_0\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"4_0\", 3))\n        {\n          ret = GLEW_VERSION_4_0;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_4_1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"4_1\", 3))\n        {\n          ret = GLEW_VERSION_4_1;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_4_2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"4_2\", 3))\n        {\n          ret = GLEW_VERSION_4_2;\n          continue;\n        }\n#endif\n#ifdef GL_VERSION_4_3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"4_3\", 3))\n        {\n          ret = GLEW_VERSION_4_3;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"3DFX_\", 5))\n      {\n#ifdef GL_3DFX_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLEW_3DFX_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_3DFX_tbuffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"tbuffer\", 7))\n        {\n          ret = GLEW_3DFX_tbuffer;\n          continue;\n        }\n#endif\n#ifdef GL_3DFX_texture_compression_FXT1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_FXT1\", 24))\n        {\n          ret = GLEW_3DFX_texture_compression_FXT1;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"AMD_\", 4))\n      {\n#ifdef GL_AMD_blend_minmax_factor\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_minmax_factor\", 19))\n        {\n          ret = GLEW_AMD_blend_minmax_factor;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_conservative_depth\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"conservative_depth\", 18))\n        {\n          ret = GLEW_AMD_conservative_depth;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_debug_output\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"debug_output\", 12))\n        {\n          ret = GLEW_AMD_debug_output;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_depth_clamp_separate\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_clamp_separate\", 20))\n        {\n          ret = GLEW_AMD_depth_clamp_separate;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_draw_buffers_blend\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_buffers_blend\", 18))\n        {\n          ret = GLEW_AMD_draw_buffers_blend;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_multi_draw_indirect\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multi_draw_indirect\", 19))\n        {\n          ret = GLEW_AMD_multi_draw_indirect;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_name_gen_delete\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"name_gen_delete\", 15))\n        {\n          ret = GLEW_AMD_name_gen_delete;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_performance_monitor\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"performance_monitor\", 19))\n        {\n          ret = GLEW_AMD_performance_monitor;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_pinned_memory\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pinned_memory\", 13))\n        {\n          ret = GLEW_AMD_pinned_memory;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_query_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"query_buffer_object\", 19))\n        {\n          ret = GLEW_AMD_query_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_sample_positions\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sample_positions\", 16))\n        {\n          ret = GLEW_AMD_sample_positions;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_seamless_cubemap_per_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"seamless_cubemap_per_texture\", 28))\n        {\n          ret = GLEW_AMD_seamless_cubemap_per_texture;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_shader_stencil_export\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_stencil_export\", 21))\n        {\n          ret = GLEW_AMD_shader_stencil_export;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_stencil_operation_extended\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stencil_operation_extended\", 26))\n        {\n          ret = GLEW_AMD_stencil_operation_extended;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_texture_texture4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_texture4\", 16))\n        {\n          ret = GLEW_AMD_texture_texture4;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_transform_feedback3_lines_triangles\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback3_lines_triangles\", 35))\n        {\n          ret = GLEW_AMD_transform_feedback3_lines_triangles;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_vertex_shader_layer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader_layer\", 19))\n        {\n          ret = GLEW_AMD_vertex_shader_layer;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_vertex_shader_tessellator\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader_tessellator\", 25))\n        {\n          ret = GLEW_AMD_vertex_shader_tessellator;\n          continue;\n        }\n#endif\n#ifdef GL_AMD_vertex_shader_viewport_index\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader_viewport_index\", 28))\n        {\n          ret = GLEW_AMD_vertex_shader_viewport_index;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"APPLE_\", 6))\n      {\n#ifdef GL_APPLE_aux_depth_stencil\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"aux_depth_stencil\", 17))\n        {\n          ret = GLEW_APPLE_aux_depth_stencil;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_client_storage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"client_storage\", 14))\n        {\n          ret = GLEW_APPLE_client_storage;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_element_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"element_array\", 13))\n        {\n          ret = GLEW_APPLE_element_array;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_fence\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fence\", 5))\n        {\n          ret = GLEW_APPLE_fence;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_float_pixels\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"float_pixels\", 12))\n        {\n          ret = GLEW_APPLE_float_pixels;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_flush_buffer_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"flush_buffer_range\", 18))\n        {\n          ret = GLEW_APPLE_flush_buffer_range;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_object_purgeable\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"object_purgeable\", 16))\n        {\n          ret = GLEW_APPLE_object_purgeable;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_pixel_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_buffer\", 12))\n        {\n          ret = GLEW_APPLE_pixel_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_rgb_422\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"rgb_422\", 7))\n        {\n          ret = GLEW_APPLE_rgb_422;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_row_bytes\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"row_bytes\", 9))\n        {\n          ret = GLEW_APPLE_row_bytes;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_specular_vector\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"specular_vector\", 15))\n        {\n          ret = GLEW_APPLE_specular_vector;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_texture_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_range\", 13))\n        {\n          ret = GLEW_APPLE_texture_range;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_transform_hint\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_hint\", 14))\n        {\n          ret = GLEW_APPLE_transform_hint;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_vertex_array_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_object\", 19))\n        {\n          ret = GLEW_APPLE_vertex_array_object;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_vertex_array_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_range\", 18))\n        {\n          ret = GLEW_APPLE_vertex_array_range;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_vertex_program_evaluators\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program_evaluators\", 25))\n        {\n          ret = GLEW_APPLE_vertex_program_evaluators;\n          continue;\n        }\n#endif\n#ifdef GL_APPLE_ycbcr_422\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ycbcr_422\", 9))\n        {\n          ret = GLEW_APPLE_ycbcr_422;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ARB_\", 4))\n      {\n#ifdef GL_ARB_ES2_compatibility\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ES2_compatibility\", 17))\n        {\n          ret = GLEW_ARB_ES2_compatibility;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_ES3_compatibility\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ES3_compatibility\", 17))\n        {\n          ret = GLEW_ARB_ES3_compatibility;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_arrays_of_arrays\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"arrays_of_arrays\", 16))\n        {\n          ret = GLEW_ARB_arrays_of_arrays;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_base_instance\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"base_instance\", 13))\n        {\n          ret = GLEW_ARB_base_instance;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_blend_func_extended\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_func_extended\", 19))\n        {\n          ret = GLEW_ARB_blend_func_extended;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_cl_event\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"cl_event\", 8))\n        {\n          ret = GLEW_ARB_cl_event;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_clear_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"clear_buffer_object\", 19))\n        {\n          ret = GLEW_ARB_clear_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_color_buffer_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_buffer_float\", 18))\n        {\n          ret = GLEW_ARB_color_buffer_float;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_compatibility\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"compatibility\", 13))\n        {\n          ret = GLEW_ARB_compatibility;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_compressed_texture_pixel_storage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"compressed_texture_pixel_storage\", 32))\n        {\n          ret = GLEW_ARB_compressed_texture_pixel_storage;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_compute_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"compute_shader\", 14))\n        {\n          ret = GLEW_ARB_compute_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_conservative_depth\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"conservative_depth\", 18))\n        {\n          ret = GLEW_ARB_conservative_depth;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_copy_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_buffer\", 11))\n        {\n          ret = GLEW_ARB_copy_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_copy_image\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_image\", 10))\n        {\n          ret = GLEW_ARB_copy_image;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_debug_output\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"debug_output\", 12))\n        {\n          ret = GLEW_ARB_debug_output;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_depth_buffer_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_buffer_float\", 18))\n        {\n          ret = GLEW_ARB_depth_buffer_float;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_depth_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_clamp\", 11))\n        {\n          ret = GLEW_ARB_depth_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_depth_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_texture\", 13))\n        {\n          ret = GLEW_ARB_depth_texture;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_draw_buffers\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_buffers\", 12))\n        {\n          ret = GLEW_ARB_draw_buffers;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_draw_buffers_blend\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_buffers_blend\", 18))\n        {\n          ret = GLEW_ARB_draw_buffers_blend;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_draw_elements_base_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_elements_base_vertex\", 25))\n        {\n          ret = GLEW_ARB_draw_elements_base_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_draw_indirect\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_indirect\", 13))\n        {\n          ret = GLEW_ARB_draw_indirect;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_draw_instanced\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_instanced\", 14))\n        {\n          ret = GLEW_ARB_draw_instanced;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_explicit_attrib_location\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"explicit_attrib_location\", 24))\n        {\n          ret = GLEW_ARB_explicit_attrib_location;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_explicit_uniform_location\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"explicit_uniform_location\", 25))\n        {\n          ret = GLEW_ARB_explicit_uniform_location;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_fragment_coord_conventions\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_coord_conventions\", 26))\n        {\n          ret = GLEW_ARB_fragment_coord_conventions;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_fragment_layer_viewport\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_layer_viewport\", 23))\n        {\n          ret = GLEW_ARB_fragment_layer_viewport;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_fragment_program\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program\", 16))\n        {\n          ret = GLEW_ARB_fragment_program;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_fragment_program_shadow\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program_shadow\", 23))\n        {\n          ret = GLEW_ARB_fragment_program_shadow;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_fragment_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_shader\", 15))\n        {\n          ret = GLEW_ARB_fragment_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_framebuffer_no_attachments\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_no_attachments\", 26))\n        {\n          ret = GLEW_ARB_framebuffer_no_attachments;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_framebuffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_object\", 18))\n        {\n          ret = GLEW_ARB_framebuffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = GLEW_ARB_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_geometry_shader4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"geometry_shader4\", 16))\n        {\n          ret = GLEW_ARB_geometry_shader4;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_get_program_binary\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"get_program_binary\", 18))\n        {\n          ret = GLEW_ARB_get_program_binary;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_gpu_shader5\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_shader5\", 11))\n        {\n          ret = GLEW_ARB_gpu_shader5;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_gpu_shader_fp64\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_shader_fp64\", 15))\n        {\n          ret = GLEW_ARB_gpu_shader_fp64;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_half_float_pixel\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"half_float_pixel\", 16))\n        {\n          ret = GLEW_ARB_half_float_pixel;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_half_float_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"half_float_vertex\", 17))\n        {\n          ret = GLEW_ARB_half_float_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_imaging\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"imaging\", 7))\n        {\n          ret = GLEW_ARB_imaging;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_instanced_arrays\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"instanced_arrays\", 16))\n        {\n          ret = GLEW_ARB_instanced_arrays;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_internalformat_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"internalformat_query\", 20))\n        {\n          ret = GLEW_ARB_internalformat_query;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_internalformat_query2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"internalformat_query2\", 21))\n        {\n          ret = GLEW_ARB_internalformat_query2;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_invalidate_subdata\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"invalidate_subdata\", 18))\n        {\n          ret = GLEW_ARB_invalidate_subdata;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_map_buffer_alignment\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"map_buffer_alignment\", 20))\n        {\n          ret = GLEW_ARB_map_buffer_alignment;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_map_buffer_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"map_buffer_range\", 16))\n        {\n          ret = GLEW_ARB_map_buffer_range;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_matrix_palette\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"matrix_palette\", 14))\n        {\n          ret = GLEW_ARB_matrix_palette;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_multi_draw_indirect\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multi_draw_indirect\", 19))\n        {\n          ret = GLEW_ARB_multi_draw_indirect;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLEW_ARB_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_multitexture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multitexture\", 12))\n        {\n          ret = GLEW_ARB_multitexture;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_occlusion_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"occlusion_query\", 15))\n        {\n          ret = GLEW_ARB_occlusion_query;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_occlusion_query2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"occlusion_query2\", 16))\n        {\n          ret = GLEW_ARB_occlusion_query2;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_pixel_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_buffer_object\", 19))\n        {\n          ret = GLEW_ARB_pixel_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_point_parameters\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_parameters\", 16))\n        {\n          ret = GLEW_ARB_point_parameters;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_point_sprite\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_sprite\", 12))\n        {\n          ret = GLEW_ARB_point_sprite;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_program_interface_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"program_interface_query\", 23))\n        {\n          ret = GLEW_ARB_program_interface_query;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_provoking_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"provoking_vertex\", 16))\n        {\n          ret = GLEW_ARB_provoking_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_robust_buffer_access_behavior\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robust_buffer_access_behavior\", 29))\n        {\n          ret = GLEW_ARB_robust_buffer_access_behavior;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_robustness\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robustness\", 10))\n        {\n          ret = GLEW_ARB_robustness;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_robustness_application_isolation\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robustness_application_isolation\", 32))\n        {\n          ret = GLEW_ARB_robustness_application_isolation;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_robustness_share_group_isolation\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robustness_share_group_isolation\", 32))\n        {\n          ret = GLEW_ARB_robustness_share_group_isolation;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_sample_shading\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sample_shading\", 14))\n        {\n          ret = GLEW_ARB_sample_shading;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_sampler_objects\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sampler_objects\", 15))\n        {\n          ret = GLEW_ARB_sampler_objects;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_seamless_cube_map\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"seamless_cube_map\", 17))\n        {\n          ret = GLEW_ARB_seamless_cube_map;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_separate_shader_objects\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"separate_shader_objects\", 23))\n        {\n          ret = GLEW_ARB_separate_shader_objects;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_atomic_counters\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_atomic_counters\", 22))\n        {\n          ret = GLEW_ARB_shader_atomic_counters;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_bit_encoding\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_bit_encoding\", 19))\n        {\n          ret = GLEW_ARB_shader_bit_encoding;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_image_load_store\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_image_load_store\", 23))\n        {\n          ret = GLEW_ARB_shader_image_load_store;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_image_size\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_image_size\", 17))\n        {\n          ret = GLEW_ARB_shader_image_size;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_objects\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_objects\", 14))\n        {\n          ret = GLEW_ARB_shader_objects;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_precision\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_precision\", 16))\n        {\n          ret = GLEW_ARB_shader_precision;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_stencil_export\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_stencil_export\", 21))\n        {\n          ret = GLEW_ARB_shader_stencil_export;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_storage_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_storage_buffer_object\", 28))\n        {\n          ret = GLEW_ARB_shader_storage_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_subroutine\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_subroutine\", 17))\n        {\n          ret = GLEW_ARB_shader_subroutine;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shader_texture_lod\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_texture_lod\", 18))\n        {\n          ret = GLEW_ARB_shader_texture_lod;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shading_language_100\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shading_language_100\", 20))\n        {\n          ret = GLEW_ARB_shading_language_100;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shading_language_420pack\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shading_language_420pack\", 24))\n        {\n          ret = GLEW_ARB_shading_language_420pack;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shading_language_include\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shading_language_include\", 24))\n        {\n          ret = GLEW_ARB_shading_language_include;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shading_language_packing\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shading_language_packing\", 24))\n        {\n          ret = GLEW_ARB_shading_language_packing;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shadow\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shadow\", 6))\n        {\n          ret = GLEW_ARB_shadow;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_shadow_ambient\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shadow_ambient\", 14))\n        {\n          ret = GLEW_ARB_shadow_ambient;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_stencil_texturing\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stencil_texturing\", 17))\n        {\n          ret = GLEW_ARB_stencil_texturing;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_sync\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sync\", 4))\n        {\n          ret = GLEW_ARB_sync;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_tessellation_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"tessellation_shader\", 19))\n        {\n          ret = GLEW_ARB_tessellation_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_border_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_border_clamp\", 20))\n        {\n          ret = GLEW_ARB_texture_border_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_buffer_object\", 21))\n        {\n          ret = GLEW_ARB_texture_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_buffer_object_rgb32\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_buffer_object_rgb32\", 27))\n        {\n          ret = GLEW_ARB_texture_buffer_object_rgb32;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_buffer_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_buffer_range\", 20))\n        {\n          ret = GLEW_ARB_texture_buffer_range;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_compression\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression\", 19))\n        {\n          ret = GLEW_ARB_texture_compression;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_compression_bptc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_bptc\", 24))\n        {\n          ret = GLEW_ARB_texture_compression_bptc;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_compression_rgtc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_rgtc\", 24))\n        {\n          ret = GLEW_ARB_texture_compression_rgtc;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_cube_map\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_cube_map\", 16))\n        {\n          ret = GLEW_ARB_texture_cube_map;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_cube_map_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_cube_map_array\", 22))\n        {\n          ret = GLEW_ARB_texture_cube_map_array;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_env_add\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_add\", 15))\n        {\n          ret = GLEW_ARB_texture_env_add;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_env_combine\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_combine\", 19))\n        {\n          ret = GLEW_ARB_texture_env_combine;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_env_crossbar\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_crossbar\", 20))\n        {\n          ret = GLEW_ARB_texture_env_crossbar;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_env_dot3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_dot3\", 16))\n        {\n          ret = GLEW_ARB_texture_env_dot3;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_float\", 13))\n        {\n          ret = GLEW_ARB_texture_float;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_gather\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_gather\", 14))\n        {\n          ret = GLEW_ARB_texture_gather;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_mirrored_repeat\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_mirrored_repeat\", 23))\n        {\n          ret = GLEW_ARB_texture_mirrored_repeat;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_multisample\", 19))\n        {\n          ret = GLEW_ARB_texture_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_non_power_of_two\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_non_power_of_two\", 24))\n        {\n          ret = GLEW_ARB_texture_non_power_of_two;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_query_levels\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_query_levels\", 20))\n        {\n          ret = GLEW_ARB_texture_query_levels;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_query_lod\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_query_lod\", 17))\n        {\n          ret = GLEW_ARB_texture_query_lod;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_rectangle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_rectangle\", 17))\n        {\n          ret = GLEW_ARB_texture_rectangle;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_rg\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_rg\", 10))\n        {\n          ret = GLEW_ARB_texture_rg;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_rgb10_a2ui\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_rgb10_a2ui\", 18))\n        {\n          ret = GLEW_ARB_texture_rgb10_a2ui;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_storage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_storage\", 15))\n        {\n          ret = GLEW_ARB_texture_storage;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_storage_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_storage_multisample\", 27))\n        {\n          ret = GLEW_ARB_texture_storage_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_swizzle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_swizzle\", 15))\n        {\n          ret = GLEW_ARB_texture_swizzle;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_texture_view\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_view\", 12))\n        {\n          ret = GLEW_ARB_texture_view;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_timer_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"timer_query\", 11))\n        {\n          ret = GLEW_ARB_timer_query;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_transform_feedback2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback2\", 19))\n        {\n          ret = GLEW_ARB_transform_feedback2;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_transform_feedback3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback3\", 19))\n        {\n          ret = GLEW_ARB_transform_feedback3;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_transform_feedback_instanced\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback_instanced\", 28))\n        {\n          ret = GLEW_ARB_transform_feedback_instanced;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_transpose_matrix\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transpose_matrix\", 16))\n        {\n          ret = GLEW_ARB_transpose_matrix;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_uniform_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"uniform_buffer_object\", 21))\n        {\n          ret = GLEW_ARB_uniform_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_array_bgra\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_bgra\", 17))\n        {\n          ret = GLEW_ARB_vertex_array_bgra;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_array_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_object\", 19))\n        {\n          ret = GLEW_ARB_vertex_array_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_attrib_64bit\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_attrib_64bit\", 19))\n        {\n          ret = GLEW_ARB_vertex_attrib_64bit;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_attrib_binding\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_attrib_binding\", 21))\n        {\n          ret = GLEW_ARB_vertex_attrib_binding;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_blend\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_blend\", 12))\n        {\n          ret = GLEW_ARB_vertex_blend;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_buffer_object\", 20))\n        {\n          ret = GLEW_ARB_vertex_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_program\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program\", 14))\n        {\n          ret = GLEW_ARB_vertex_program;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader\", 13))\n        {\n          ret = GLEW_ARB_vertex_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_vertex_type_2_10_10_10_rev\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_type_2_10_10_10_rev\", 26))\n        {\n          ret = GLEW_ARB_vertex_type_2_10_10_10_rev;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_viewport_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"viewport_array\", 14))\n        {\n          ret = GLEW_ARB_viewport_array;\n          continue;\n        }\n#endif\n#ifdef GL_ARB_window_pos\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"window_pos\", 10))\n        {\n          ret = GLEW_ARB_window_pos;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ATIX_\", 5))\n      {\n#ifdef GL_ATIX_point_sprites\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_sprites\", 13))\n        {\n          ret = GLEW_ATIX_point_sprites;\n          continue;\n        }\n#endif\n#ifdef GL_ATIX_texture_env_combine3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_combine3\", 20))\n        {\n          ret = GLEW_ATIX_texture_env_combine3;\n          continue;\n        }\n#endif\n#ifdef GL_ATIX_texture_env_route\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_route\", 17))\n        {\n          ret = GLEW_ATIX_texture_env_route;\n          continue;\n        }\n#endif\n#ifdef GL_ATIX_vertex_shader_output_point_size\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader_output_point_size\", 31))\n        {\n          ret = GLEW_ATIX_vertex_shader_output_point_size;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ATI_\", 4))\n      {\n#ifdef GL_ATI_draw_buffers\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_buffers\", 12))\n        {\n          ret = GLEW_ATI_draw_buffers;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_element_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"element_array\", 13))\n        {\n          ret = GLEW_ATI_element_array;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_envmap_bumpmap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"envmap_bumpmap\", 14))\n        {\n          ret = GLEW_ATI_envmap_bumpmap;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_fragment_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_shader\", 15))\n        {\n          ret = GLEW_ATI_fragment_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_map_object_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"map_object_buffer\", 17))\n        {\n          ret = GLEW_ATI_map_object_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_meminfo\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"meminfo\", 7))\n        {\n          ret = GLEW_ATI_meminfo;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_pn_triangles\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pn_triangles\", 12))\n        {\n          ret = GLEW_ATI_pn_triangles;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_separate_stencil\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"separate_stencil\", 16))\n        {\n          ret = GLEW_ATI_separate_stencil;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_shader_texture_lod\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_texture_lod\", 18))\n        {\n          ret = GLEW_ATI_shader_texture_lod;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_text_fragment_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"text_fragment_shader\", 20))\n        {\n          ret = GLEW_ATI_text_fragment_shader;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_texture_compression_3dc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_3dc\", 23))\n        {\n          ret = GLEW_ATI_texture_compression_3dc;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_texture_env_combine3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_combine3\", 20))\n        {\n          ret = GLEW_ATI_texture_env_combine3;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_texture_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_float\", 13))\n        {\n          ret = GLEW_ATI_texture_float;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_texture_mirror_once\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_mirror_once\", 19))\n        {\n          ret = GLEW_ATI_texture_mirror_once;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_vertex_array_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_object\", 19))\n        {\n          ret = GLEW_ATI_vertex_array_object;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_vertex_attrib_array_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_attrib_array_object\", 26))\n        {\n          ret = GLEW_ATI_vertex_attrib_array_object;\n          continue;\n        }\n#endif\n#ifdef GL_ATI_vertex_streams\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_streams\", 14))\n        {\n          ret = GLEW_ATI_vertex_streams;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"EXT_\", 4))\n      {\n#ifdef GL_EXT_422_pixels\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"422_pixels\", 10))\n        {\n          ret = GLEW_EXT_422_pixels;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_Cg_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"Cg_shader\", 9))\n        {\n          ret = GLEW_EXT_Cg_shader;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_abgr\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"abgr\", 4))\n        {\n          ret = GLEW_EXT_abgr;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_bgra\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"bgra\", 4))\n        {\n          ret = GLEW_EXT_bgra;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_bindable_uniform\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"bindable_uniform\", 16))\n        {\n          ret = GLEW_EXT_bindable_uniform;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_color\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_color\", 11))\n        {\n          ret = GLEW_EXT_blend_color;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_equation_separate\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_equation_separate\", 23))\n        {\n          ret = GLEW_EXT_blend_equation_separate;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_func_separate\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_func_separate\", 19))\n        {\n          ret = GLEW_EXT_blend_func_separate;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_logic_op\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_logic_op\", 14))\n        {\n          ret = GLEW_EXT_blend_logic_op;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_minmax\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_minmax\", 12))\n        {\n          ret = GLEW_EXT_blend_minmax;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_blend_subtract\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_subtract\", 14))\n        {\n          ret = GLEW_EXT_blend_subtract;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_clip_volume_hint\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"clip_volume_hint\", 16))\n        {\n          ret = GLEW_EXT_clip_volume_hint;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_cmyka\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"cmyka\", 5))\n        {\n          ret = GLEW_EXT_cmyka;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_color_subtable\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_subtable\", 14))\n        {\n          ret = GLEW_EXT_color_subtable;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_compiled_vertex_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"compiled_vertex_array\", 21))\n        {\n          ret = GLEW_EXT_compiled_vertex_array;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_convolution\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"convolution\", 11))\n        {\n          ret = GLEW_EXT_convolution;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_coordinate_frame\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"coordinate_frame\", 16))\n        {\n          ret = GLEW_EXT_coordinate_frame;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_copy_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_texture\", 12))\n        {\n          ret = GLEW_EXT_copy_texture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_cull_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"cull_vertex\", 11))\n        {\n          ret = GLEW_EXT_cull_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_debug_marker\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"debug_marker\", 12))\n        {\n          ret = GLEW_EXT_debug_marker;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_depth_bounds_test\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_bounds_test\", 17))\n        {\n          ret = GLEW_EXT_depth_bounds_test;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_direct_state_access\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"direct_state_access\", 19))\n        {\n          ret = GLEW_EXT_direct_state_access;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_draw_buffers2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_buffers2\", 13))\n        {\n          ret = GLEW_EXT_draw_buffers2;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_draw_instanced\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_instanced\", 14))\n        {\n          ret = GLEW_EXT_draw_instanced;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_draw_range_elements\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"draw_range_elements\", 19))\n        {\n          ret = GLEW_EXT_draw_range_elements;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_fog_coord\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fog_coord\", 9))\n        {\n          ret = GLEW_EXT_fog_coord;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_fragment_lighting\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_lighting\", 17))\n        {\n          ret = GLEW_EXT_fragment_lighting;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_framebuffer_blit\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_blit\", 16))\n        {\n          ret = GLEW_EXT_framebuffer_blit;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_framebuffer_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_multisample\", 23))\n        {\n          ret = GLEW_EXT_framebuffer_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_framebuffer_multisample_blit_scaled\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_multisample_blit_scaled\", 35))\n        {\n          ret = GLEW_EXT_framebuffer_multisample_blit_scaled;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_framebuffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_object\", 18))\n        {\n          ret = GLEW_EXT_framebuffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = GLEW_EXT_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_geometry_shader4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"geometry_shader4\", 16))\n        {\n          ret = GLEW_EXT_geometry_shader4;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_gpu_program_parameters\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_program_parameters\", 22))\n        {\n          ret = GLEW_EXT_gpu_program_parameters;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_gpu_shader4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_shader4\", 11))\n        {\n          ret = GLEW_EXT_gpu_shader4;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_histogram\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"histogram\", 9))\n        {\n          ret = GLEW_EXT_histogram;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_index_array_formats\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"index_array_formats\", 19))\n        {\n          ret = GLEW_EXT_index_array_formats;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_index_func\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"index_func\", 10))\n        {\n          ret = GLEW_EXT_index_func;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_index_material\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"index_material\", 14))\n        {\n          ret = GLEW_EXT_index_material;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_index_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"index_texture\", 13))\n        {\n          ret = GLEW_EXT_index_texture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_light_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"light_texture\", 13))\n        {\n          ret = GLEW_EXT_light_texture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_misc_attribute\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"misc_attribute\", 14))\n        {\n          ret = GLEW_EXT_misc_attribute;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_multi_draw_arrays\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multi_draw_arrays\", 17))\n        {\n          ret = GLEW_EXT_multi_draw_arrays;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLEW_EXT_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_packed_depth_stencil\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"packed_depth_stencil\", 20))\n        {\n          ret = GLEW_EXT_packed_depth_stencil;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_packed_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"packed_float\", 12))\n        {\n          ret = GLEW_EXT_packed_float;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_packed_pixels\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"packed_pixels\", 13))\n        {\n          ret = GLEW_EXT_packed_pixels;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_paletted_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"paletted_texture\", 16))\n        {\n          ret = GLEW_EXT_paletted_texture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_pixel_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_buffer_object\", 19))\n        {\n          ret = GLEW_EXT_pixel_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_pixel_transform\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_transform\", 15))\n        {\n          ret = GLEW_EXT_pixel_transform;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_pixel_transform_color_table\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_transform_color_table\", 27))\n        {\n          ret = GLEW_EXT_pixel_transform_color_table;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_point_parameters\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_parameters\", 16))\n        {\n          ret = GLEW_EXT_point_parameters;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_polygon_offset\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"polygon_offset\", 14))\n        {\n          ret = GLEW_EXT_polygon_offset;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_provoking_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"provoking_vertex\", 16))\n        {\n          ret = GLEW_EXT_provoking_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_rescale_normal\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"rescale_normal\", 14))\n        {\n          ret = GLEW_EXT_rescale_normal;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_scene_marker\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"scene_marker\", 12))\n        {\n          ret = GLEW_EXT_scene_marker;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_secondary_color\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"secondary_color\", 15))\n        {\n          ret = GLEW_EXT_secondary_color;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_separate_shader_objects\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"separate_shader_objects\", 23))\n        {\n          ret = GLEW_EXT_separate_shader_objects;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_separate_specular_color\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"separate_specular_color\", 23))\n        {\n          ret = GLEW_EXT_separate_specular_color;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_shader_image_load_store\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_image_load_store\", 23))\n        {\n          ret = GLEW_EXT_shader_image_load_store;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_shadow_funcs\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shadow_funcs\", 12))\n        {\n          ret = GLEW_EXT_shadow_funcs;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_shared_texture_palette\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shared_texture_palette\", 22))\n        {\n          ret = GLEW_EXT_shared_texture_palette;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_stencil_clear_tag\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stencil_clear_tag\", 17))\n        {\n          ret = GLEW_EXT_stencil_clear_tag;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_stencil_two_side\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stencil_two_side\", 16))\n        {\n          ret = GLEW_EXT_stencil_two_side;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_stencil_wrap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stencil_wrap\", 12))\n        {\n          ret = GLEW_EXT_stencil_wrap;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_subtexture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"subtexture\", 10))\n        {\n          ret = GLEW_EXT_subtexture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture\", 7))\n        {\n          ret = GLEW_EXT_texture;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture3D\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture3D\", 9))\n        {\n          ret = GLEW_EXT_texture3D;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_array\", 13))\n        {\n          ret = GLEW_EXT_texture_array;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_buffer_object\", 21))\n        {\n          ret = GLEW_EXT_texture_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_compression_dxt1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_dxt1\", 24))\n        {\n          ret = GLEW_EXT_texture_compression_dxt1;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_compression_latc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_latc\", 24))\n        {\n          ret = GLEW_EXT_texture_compression_latc;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_compression_rgtc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_rgtc\", 24))\n        {\n          ret = GLEW_EXT_texture_compression_rgtc;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_compression_s3tc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_s3tc\", 24))\n        {\n          ret = GLEW_EXT_texture_compression_s3tc;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_cube_map\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_cube_map\", 16))\n        {\n          ret = GLEW_EXT_texture_cube_map;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_edge_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_edge_clamp\", 18))\n        {\n          ret = GLEW_EXT_texture_edge_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_env\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env\", 11))\n        {\n          ret = GLEW_EXT_texture_env;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_env_add\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_add\", 15))\n        {\n          ret = GLEW_EXT_texture_env_add;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_env_combine\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_combine\", 19))\n        {\n          ret = GLEW_EXT_texture_env_combine;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_env_dot3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_dot3\", 16))\n        {\n          ret = GLEW_EXT_texture_env_dot3;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_filter_anisotropic\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_filter_anisotropic\", 26))\n        {\n          ret = GLEW_EXT_texture_filter_anisotropic;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_integer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_integer\", 15))\n        {\n          ret = GLEW_EXT_texture_integer;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_lod_bias\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_lod_bias\", 16))\n        {\n          ret = GLEW_EXT_texture_lod_bias;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_mirror_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_mirror_clamp\", 20))\n        {\n          ret = GLEW_EXT_texture_mirror_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_object\", 14))\n        {\n          ret = GLEW_EXT_texture_object;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_perturb_normal\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_perturb_normal\", 22))\n        {\n          ret = GLEW_EXT_texture_perturb_normal;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_rectangle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_rectangle\", 17))\n        {\n          ret = GLEW_EXT_texture_rectangle;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_sRGB\", 12))\n        {\n          ret = GLEW_EXT_texture_sRGB;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_sRGB_decode\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_sRGB_decode\", 19))\n        {\n          ret = GLEW_EXT_texture_sRGB_decode;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_shared_exponent\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_shared_exponent\", 23))\n        {\n          ret = GLEW_EXT_texture_shared_exponent;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_snorm\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_snorm\", 13))\n        {\n          ret = GLEW_EXT_texture_snorm;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_texture_swizzle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_swizzle\", 15))\n        {\n          ret = GLEW_EXT_texture_swizzle;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_timer_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"timer_query\", 11))\n        {\n          ret = GLEW_EXT_timer_query;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_transform_feedback\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback\", 18))\n        {\n          ret = GLEW_EXT_transform_feedback;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_vertex_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array\", 12))\n        {\n          ret = GLEW_EXT_vertex_array;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_vertex_array_bgra\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_bgra\", 17))\n        {\n          ret = GLEW_EXT_vertex_array_bgra;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_vertex_attrib_64bit\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_attrib_64bit\", 19))\n        {\n          ret = GLEW_EXT_vertex_attrib_64bit;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_vertex_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_shader\", 13))\n        {\n          ret = GLEW_EXT_vertex_shader;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_vertex_weighting\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_weighting\", 16))\n        {\n          ret = GLEW_EXT_vertex_weighting;\n          continue;\n        }\n#endif\n#ifdef GL_EXT_x11_sync_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"x11_sync_object\", 15))\n        {\n          ret = GLEW_EXT_x11_sync_object;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"GREMEDY_\", 8))\n      {\n#ifdef GL_GREMEDY_frame_terminator\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"frame_terminator\", 16))\n        {\n          ret = GLEW_GREMEDY_frame_terminator;\n          continue;\n        }\n#endif\n#ifdef GL_GREMEDY_string_marker\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"string_marker\", 13))\n        {\n          ret = GLEW_GREMEDY_string_marker;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"HP_\", 3))\n      {\n#ifdef GL_HP_convolution_border_modes\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"convolution_border_modes\", 24))\n        {\n          ret = GLEW_HP_convolution_border_modes;\n          continue;\n        }\n#endif\n#ifdef GL_HP_image_transform\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"image_transform\", 15))\n        {\n          ret = GLEW_HP_image_transform;\n          continue;\n        }\n#endif\n#ifdef GL_HP_occlusion_test\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"occlusion_test\", 14))\n        {\n          ret = GLEW_HP_occlusion_test;\n          continue;\n        }\n#endif\n#ifdef GL_HP_texture_lighting\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_lighting\", 16))\n        {\n          ret = GLEW_HP_texture_lighting;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"IBM_\", 4))\n      {\n#ifdef GL_IBM_cull_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"cull_vertex\", 11))\n        {\n          ret = GLEW_IBM_cull_vertex;\n          continue;\n        }\n#endif\n#ifdef GL_IBM_multimode_draw_arrays\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multimode_draw_arrays\", 21))\n        {\n          ret = GLEW_IBM_multimode_draw_arrays;\n          continue;\n        }\n#endif\n#ifdef GL_IBM_rasterpos_clip\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"rasterpos_clip\", 14))\n        {\n          ret = GLEW_IBM_rasterpos_clip;\n          continue;\n        }\n#endif\n#ifdef GL_IBM_static_data\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"static_data\", 11))\n        {\n          ret = GLEW_IBM_static_data;\n          continue;\n        }\n#endif\n#ifdef GL_IBM_texture_mirrored_repeat\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_mirrored_repeat\", 23))\n        {\n          ret = GLEW_IBM_texture_mirrored_repeat;\n          continue;\n        }\n#endif\n#ifdef GL_IBM_vertex_array_lists\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_lists\", 18))\n        {\n          ret = GLEW_IBM_vertex_array_lists;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"INGR_\", 5))\n      {\n#ifdef GL_INGR_color_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_clamp\", 11))\n        {\n          ret = GLEW_INGR_color_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_INGR_interlace_read\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"interlace_read\", 14))\n        {\n          ret = GLEW_INGR_interlace_read;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"INTEL_\", 6))\n      {\n#ifdef GL_INTEL_parallel_arrays\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"parallel_arrays\", 15))\n        {\n          ret = GLEW_INTEL_parallel_arrays;\n          continue;\n        }\n#endif\n#ifdef GL_INTEL_texture_scissor\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_scissor\", 15))\n        {\n          ret = GLEW_INTEL_texture_scissor;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"KHR_\", 4))\n      {\n#ifdef GL_KHR_debug\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"debug\", 5))\n        {\n          ret = GLEW_KHR_debug;\n          continue;\n        }\n#endif\n#ifdef GL_KHR_texture_compression_astc_ldr\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_astc_ldr\", 28))\n        {\n          ret = GLEW_KHR_texture_compression_astc_ldr;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"KTX_\", 4))\n      {\n#ifdef GL_KTX_buffer_region\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"buffer_region\", 13))\n        {\n          ret = GLEW_KTX_buffer_region;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"MESAX_\", 6))\n      {\n#ifdef GL_MESAX_texture_stack\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_stack\", 13))\n        {\n          ret = GLEW_MESAX_texture_stack;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"MESA_\", 5))\n      {\n#ifdef GL_MESA_pack_invert\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pack_invert\", 11))\n        {\n          ret = GLEW_MESA_pack_invert;\n          continue;\n        }\n#endif\n#ifdef GL_MESA_resize_buffers\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"resize_buffers\", 14))\n        {\n          ret = GLEW_MESA_resize_buffers;\n          continue;\n        }\n#endif\n#ifdef GL_MESA_window_pos\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"window_pos\", 10))\n        {\n          ret = GLEW_MESA_window_pos;\n          continue;\n        }\n#endif\n#ifdef GL_MESA_ycbcr_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ycbcr_texture\", 13))\n        {\n          ret = GLEW_MESA_ycbcr_texture;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"NVX_\", 4))\n      {\n#ifdef GL_NVX_gpu_memory_info\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_memory_info\", 15))\n        {\n          ret = GLEW_NVX_gpu_memory_info;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"NV_\", 3))\n      {\n#ifdef GL_NV_bindless_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"bindless_texture\", 16))\n        {\n          ret = GLEW_NV_bindless_texture;\n          continue;\n        }\n#endif\n#ifdef GL_NV_blend_square\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_square\", 12))\n        {\n          ret = GLEW_NV_blend_square;\n          continue;\n        }\n#endif\n#ifdef GL_NV_conditional_render\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"conditional_render\", 18))\n        {\n          ret = GLEW_NV_conditional_render;\n          continue;\n        }\n#endif\n#ifdef GL_NV_copy_depth_to_color\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_depth_to_color\", 19))\n        {\n          ret = GLEW_NV_copy_depth_to_color;\n          continue;\n        }\n#endif\n#ifdef GL_NV_copy_image\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_image\", 10))\n        {\n          ret = GLEW_NV_copy_image;\n          continue;\n        }\n#endif\n#ifdef GL_NV_depth_buffer_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_buffer_float\", 18))\n        {\n          ret = GLEW_NV_depth_buffer_float;\n          continue;\n        }\n#endif\n#ifdef GL_NV_depth_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_clamp\", 11))\n        {\n          ret = GLEW_NV_depth_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_NV_depth_range_unclamped\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_range_unclamped\", 21))\n        {\n          ret = GLEW_NV_depth_range_unclamped;\n          continue;\n        }\n#endif\n#ifdef GL_NV_evaluators\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"evaluators\", 10))\n        {\n          ret = GLEW_NV_evaluators;\n          continue;\n        }\n#endif\n#ifdef GL_NV_explicit_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"explicit_multisample\", 20))\n        {\n          ret = GLEW_NV_explicit_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fence\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fence\", 5))\n        {\n          ret = GLEW_NV_fence;\n          continue;\n        }\n#endif\n#ifdef GL_NV_float_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"float_buffer\", 12))\n        {\n          ret = GLEW_NV_float_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fog_distance\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fog_distance\", 12))\n        {\n          ret = GLEW_NV_fog_distance;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fragment_program\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program\", 16))\n        {\n          ret = GLEW_NV_fragment_program;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fragment_program2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program2\", 17))\n        {\n          ret = GLEW_NV_fragment_program2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fragment_program4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program4\", 17))\n        {\n          ret = GLEW_NV_fragment_program4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_fragment_program_option\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_program_option\", 23))\n        {\n          ret = GLEW_NV_fragment_program_option;\n          continue;\n        }\n#endif\n#ifdef GL_NV_framebuffer_multisample_coverage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_multisample_coverage\", 32))\n        {\n          ret = GLEW_NV_framebuffer_multisample_coverage;\n          continue;\n        }\n#endif\n#ifdef GL_NV_geometry_program4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"geometry_program4\", 17))\n        {\n          ret = GLEW_NV_geometry_program4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_geometry_shader4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"geometry_shader4\", 16))\n        {\n          ret = GLEW_NV_geometry_shader4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_gpu_program4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_program4\", 12))\n        {\n          ret = GLEW_NV_gpu_program4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_gpu_program5\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_program5\", 12))\n        {\n          ret = GLEW_NV_gpu_program5;\n          continue;\n        }\n#endif\n#ifdef GL_NV_gpu_program_fp64\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_program_fp64\", 16))\n        {\n          ret = GLEW_NV_gpu_program_fp64;\n          continue;\n        }\n#endif\n#ifdef GL_NV_gpu_shader5\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_shader5\", 11))\n        {\n          ret = GLEW_NV_gpu_shader5;\n          continue;\n        }\n#endif\n#ifdef GL_NV_half_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"half_float\", 10))\n        {\n          ret = GLEW_NV_half_float;\n          continue;\n        }\n#endif\n#ifdef GL_NV_light_max_exponent\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"light_max_exponent\", 18))\n        {\n          ret = GLEW_NV_light_max_exponent;\n          continue;\n        }\n#endif\n#ifdef GL_NV_multisample_coverage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample_coverage\", 20))\n        {\n          ret = GLEW_NV_multisample_coverage;\n          continue;\n        }\n#endif\n#ifdef GL_NV_multisample_filter_hint\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample_filter_hint\", 23))\n        {\n          ret = GLEW_NV_multisample_filter_hint;\n          continue;\n        }\n#endif\n#ifdef GL_NV_occlusion_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"occlusion_query\", 15))\n        {\n          ret = GLEW_NV_occlusion_query;\n          continue;\n        }\n#endif\n#ifdef GL_NV_packed_depth_stencil\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"packed_depth_stencil\", 20))\n        {\n          ret = GLEW_NV_packed_depth_stencil;\n          continue;\n        }\n#endif\n#ifdef GL_NV_parameter_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"parameter_buffer_object\", 23))\n        {\n          ret = GLEW_NV_parameter_buffer_object;\n          continue;\n        }\n#endif\n#ifdef GL_NV_parameter_buffer_object2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"parameter_buffer_object2\", 24))\n        {\n          ret = GLEW_NV_parameter_buffer_object2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_path_rendering\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"path_rendering\", 14))\n        {\n          ret = GLEW_NV_path_rendering;\n          continue;\n        }\n#endif\n#ifdef GL_NV_pixel_data_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_data_range\", 16))\n        {\n          ret = GLEW_NV_pixel_data_range;\n          continue;\n        }\n#endif\n#ifdef GL_NV_point_sprite\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_sprite\", 12))\n        {\n          ret = GLEW_NV_point_sprite;\n          continue;\n        }\n#endif\n#ifdef GL_NV_present_video\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"present_video\", 13))\n        {\n          ret = GLEW_NV_present_video;\n          continue;\n        }\n#endif\n#ifdef GL_NV_primitive_restart\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"primitive_restart\", 17))\n        {\n          ret = GLEW_NV_primitive_restart;\n          continue;\n        }\n#endif\n#ifdef GL_NV_register_combiners\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"register_combiners\", 18))\n        {\n          ret = GLEW_NV_register_combiners;\n          continue;\n        }\n#endif\n#ifdef GL_NV_register_combiners2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"register_combiners2\", 19))\n        {\n          ret = GLEW_NV_register_combiners2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_shader_atomic_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_atomic_float\", 19))\n        {\n          ret = GLEW_NV_shader_atomic_float;\n          continue;\n        }\n#endif\n#ifdef GL_NV_shader_buffer_load\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shader_buffer_load\", 18))\n        {\n          ret = GLEW_NV_shader_buffer_load;\n          continue;\n        }\n#endif\n#ifdef GL_NV_tessellation_program5\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"tessellation_program5\", 21))\n        {\n          ret = GLEW_NV_tessellation_program5;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texgen_emboss\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texgen_emboss\", 13))\n        {\n          ret = GLEW_NV_texgen_emboss;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texgen_reflection\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texgen_reflection\", 17))\n        {\n          ret = GLEW_NV_texgen_reflection;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_barrier\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_barrier\", 15))\n        {\n          ret = GLEW_NV_texture_barrier;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_compression_vtc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_compression_vtc\", 23))\n        {\n          ret = GLEW_NV_texture_compression_vtc;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_env_combine4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_env_combine4\", 20))\n        {\n          ret = GLEW_NV_texture_env_combine4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_expand_normal\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_expand_normal\", 21))\n        {\n          ret = GLEW_NV_texture_expand_normal;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_multisample\", 19))\n        {\n          ret = GLEW_NV_texture_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_rectangle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_rectangle\", 17))\n        {\n          ret = GLEW_NV_texture_rectangle;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_shader\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_shader\", 14))\n        {\n          ret = GLEW_NV_texture_shader;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_shader2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_shader2\", 15))\n        {\n          ret = GLEW_NV_texture_shader2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_texture_shader3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_shader3\", 15))\n        {\n          ret = GLEW_NV_texture_shader3;\n          continue;\n        }\n#endif\n#ifdef GL_NV_transform_feedback\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback\", 18))\n        {\n          ret = GLEW_NV_transform_feedback;\n          continue;\n        }\n#endif\n#ifdef GL_NV_transform_feedback2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"transform_feedback2\", 19))\n        {\n          ret = GLEW_NV_transform_feedback2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vdpau_interop\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vdpau_interop\", 13))\n        {\n          ret = GLEW_NV_vdpau_interop;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_array_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_range\", 18))\n        {\n          ret = GLEW_NV_vertex_array_range;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_array_range2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_range2\", 19))\n        {\n          ret = GLEW_NV_vertex_array_range2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_attrib_integer_64bit\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_attrib_integer_64bit\", 27))\n        {\n          ret = GLEW_NV_vertex_attrib_integer_64bit;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_buffer_unified_memory\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_buffer_unified_memory\", 28))\n        {\n          ret = GLEW_NV_vertex_buffer_unified_memory;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program\", 14))\n        {\n          ret = GLEW_NV_vertex_program;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program1_1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program1_1\", 17))\n        {\n          ret = GLEW_NV_vertex_program1_1;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program2\", 15))\n        {\n          ret = GLEW_NV_vertex_program2;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program2_option\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program2_option\", 22))\n        {\n          ret = GLEW_NV_vertex_program2_option;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program3\", 15))\n        {\n          ret = GLEW_NV_vertex_program3;\n          continue;\n        }\n#endif\n#ifdef GL_NV_vertex_program4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_program4\", 15))\n        {\n          ret = GLEW_NV_vertex_program4;\n          continue;\n        }\n#endif\n#ifdef GL_NV_video_capture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_capture\", 13))\n        {\n          ret = GLEW_NV_video_capture;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"OES_\", 4))\n      {\n#ifdef GL_OES_byte_coordinates\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"byte_coordinates\", 16))\n        {\n          ret = GLEW_OES_byte_coordinates;\n          continue;\n        }\n#endif\n#ifdef GL_OES_compressed_paletted_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"compressed_paletted_texture\", 27))\n        {\n          ret = GLEW_OES_compressed_paletted_texture;\n          continue;\n        }\n#endif\n#ifdef GL_OES_read_format\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"read_format\", 11))\n        {\n          ret = GLEW_OES_read_format;\n          continue;\n        }\n#endif\n#ifdef GL_OES_single_precision\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"single_precision\", 16))\n        {\n          ret = GLEW_OES_single_precision;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"OML_\", 4))\n      {\n#ifdef GL_OML_interlace\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"interlace\", 9))\n        {\n          ret = GLEW_OML_interlace;\n          continue;\n        }\n#endif\n#ifdef GL_OML_resample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"resample\", 8))\n        {\n          ret = GLEW_OML_resample;\n          continue;\n        }\n#endif\n#ifdef GL_OML_subsample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"subsample\", 9))\n        {\n          ret = GLEW_OML_subsample;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"PGI_\", 4))\n      {\n#ifdef GL_PGI_misc_hints\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"misc_hints\", 10))\n        {\n          ret = GLEW_PGI_misc_hints;\n          continue;\n        }\n#endif\n#ifdef GL_PGI_vertex_hints\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_hints\", 12))\n        {\n          ret = GLEW_PGI_vertex_hints;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"REGAL_\", 6))\n      {\n#ifdef GL_REGAL_error_string\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"error_string\", 12))\n        {\n          ret = GLEW_REGAL_error_string;\n          continue;\n        }\n#endif\n#ifdef GL_REGAL_extension_query\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"extension_query\", 15))\n        {\n          ret = GLEW_REGAL_extension_query;\n          continue;\n        }\n#endif\n#ifdef GL_REGAL_log\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"log\", 3))\n        {\n          ret = GLEW_REGAL_log;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"REND_\", 5))\n      {\n#ifdef GL_REND_screen_coordinates\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"screen_coordinates\", 18))\n        {\n          ret = GLEW_REND_screen_coordinates;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"S3_\", 3))\n      {\n#ifdef GL_S3_s3tc\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"s3tc\", 4))\n        {\n          ret = GLEW_S3_s3tc;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGIS_\", 5))\n      {\n#ifdef GL_SGIS_color_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_range\", 11))\n        {\n          ret = GLEW_SGIS_color_range;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_detail_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"detail_texture\", 14))\n        {\n          ret = GLEW_SGIS_detail_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_fog_function\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fog_function\", 12))\n        {\n          ret = GLEW_SGIS_fog_function;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_generate_mipmap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"generate_mipmap\", 15))\n        {\n          ret = GLEW_SGIS_generate_mipmap;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLEW_SGIS_multisample;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_pixel_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_texture\", 13))\n        {\n          ret = GLEW_SGIS_pixel_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_point_line_texgen\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"point_line_texgen\", 17))\n        {\n          ret = GLEW_SGIS_point_line_texgen;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_sharpen_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sharpen_texture\", 15))\n        {\n          ret = GLEW_SGIS_sharpen_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture4D\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture4D\", 9))\n        {\n          ret = GLEW_SGIS_texture4D;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture_border_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_border_clamp\", 20))\n        {\n          ret = GLEW_SGIS_texture_border_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture_edge_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_edge_clamp\", 18))\n        {\n          ret = GLEW_SGIS_texture_edge_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture_filter4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_filter4\", 15))\n        {\n          ret = GLEW_SGIS_texture_filter4;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture_lod\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_lod\", 11))\n        {\n          ret = GLEW_SGIS_texture_lod;\n          continue;\n        }\n#endif\n#ifdef GL_SGIS_texture_select\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_select\", 14))\n        {\n          ret = GLEW_SGIS_texture_select;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGIX_\", 5))\n      {\n#ifdef GL_SGIX_async\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"async\", 5))\n        {\n          ret = GLEW_SGIX_async;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_async_histogram\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"async_histogram\", 15))\n        {\n          ret = GLEW_SGIX_async_histogram;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_async_pixel\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"async_pixel\", 11))\n        {\n          ret = GLEW_SGIX_async_pixel;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_blend_alpha_minmax\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blend_alpha_minmax\", 18))\n        {\n          ret = GLEW_SGIX_blend_alpha_minmax;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_clipmap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"clipmap\", 7))\n        {\n          ret = GLEW_SGIX_clipmap;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_convolution_accuracy\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"convolution_accuracy\", 20))\n        {\n          ret = GLEW_SGIX_convolution_accuracy;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_depth_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_texture\", 13))\n        {\n          ret = GLEW_SGIX_depth_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_flush_raster\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"flush_raster\", 12))\n        {\n          ret = GLEW_SGIX_flush_raster;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_fog_offset\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fog_offset\", 10))\n        {\n          ret = GLEW_SGIX_fog_offset;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_fog_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fog_texture\", 11))\n        {\n          ret = GLEW_SGIX_fog_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_fragment_specular_lighting\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fragment_specular_lighting\", 26))\n        {\n          ret = GLEW_SGIX_fragment_specular_lighting;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_framezoom\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framezoom\", 9))\n        {\n          ret = GLEW_SGIX_framezoom;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_interlace\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"interlace\", 9))\n        {\n          ret = GLEW_SGIX_interlace;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_ir_instrument1\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ir_instrument1\", 14))\n        {\n          ret = GLEW_SGIX_ir_instrument1;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_list_priority\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"list_priority\", 13))\n        {\n          ret = GLEW_SGIX_list_priority;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_pixel_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_texture\", 13))\n        {\n          ret = GLEW_SGIX_pixel_texture;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_pixel_texture_bits\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_texture_bits\", 18))\n        {\n          ret = GLEW_SGIX_pixel_texture_bits;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_reference_plane\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"reference_plane\", 15))\n        {\n          ret = GLEW_SGIX_reference_plane;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_resample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"resample\", 8))\n        {\n          ret = GLEW_SGIX_resample;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_shadow\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shadow\", 6))\n        {\n          ret = GLEW_SGIX_shadow;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_shadow_ambient\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shadow_ambient\", 14))\n        {\n          ret = GLEW_SGIX_shadow_ambient;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_sprite\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sprite\", 6))\n        {\n          ret = GLEW_SGIX_sprite;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_tag_sample_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"tag_sample_buffer\", 17))\n        {\n          ret = GLEW_SGIX_tag_sample_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_add_env\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_add_env\", 15))\n        {\n          ret = GLEW_SGIX_texture_add_env;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_coordinate_clamp\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_coordinate_clamp\", 24))\n        {\n          ret = GLEW_SGIX_texture_coordinate_clamp;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_lod_bias\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_lod_bias\", 16))\n        {\n          ret = GLEW_SGIX_texture_lod_bias;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_multi_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_multi_buffer\", 20))\n        {\n          ret = GLEW_SGIX_texture_multi_buffer;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_range\", 13))\n        {\n          ret = GLEW_SGIX_texture_range;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_texture_scale_bias\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_scale_bias\", 18))\n        {\n          ret = GLEW_SGIX_texture_scale_bias;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_vertex_preclip\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_preclip\", 14))\n        {\n          ret = GLEW_SGIX_vertex_preclip;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_vertex_preclip_hint\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_preclip_hint\", 19))\n        {\n          ret = GLEW_SGIX_vertex_preclip_hint;\n          continue;\n        }\n#endif\n#ifdef GL_SGIX_ycrcb\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"ycrcb\", 5))\n        {\n          ret = GLEW_SGIX_ycrcb;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGI_\", 4))\n      {\n#ifdef GL_SGI_color_matrix\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_matrix\", 12))\n        {\n          ret = GLEW_SGI_color_matrix;\n          continue;\n        }\n#endif\n#ifdef GL_SGI_color_table\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_table\", 11))\n        {\n          ret = GLEW_SGI_color_table;\n          continue;\n        }\n#endif\n#ifdef GL_SGI_texture_color_table\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_color_table\", 19))\n        {\n          ret = GLEW_SGI_texture_color_table;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SUNX_\", 5))\n      {\n#ifdef GL_SUNX_constant_data\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"constant_data\", 13))\n        {\n          ret = GLEW_SUNX_constant_data;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SUN_\", 4))\n      {\n#ifdef GL_SUN_convolution_border_modes\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"convolution_border_modes\", 24))\n        {\n          ret = GLEW_SUN_convolution_border_modes;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_global_alpha\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"global_alpha\", 12))\n        {\n          ret = GLEW_SUN_global_alpha;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_mesh_array\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"mesh_array\", 10))\n        {\n          ret = GLEW_SUN_mesh_array;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_read_video_pixels\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"read_video_pixels\", 17))\n        {\n          ret = GLEW_SUN_read_video_pixels;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_slice_accum\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"slice_accum\", 11))\n        {\n          ret = GLEW_SUN_slice_accum;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_triangle_list\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"triangle_list\", 13))\n        {\n          ret = GLEW_SUN_triangle_list;\n          continue;\n        }\n#endif\n#ifdef GL_SUN_vertex\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex\", 6))\n        {\n          ret = GLEW_SUN_vertex;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"WIN_\", 4))\n      {\n#ifdef GL_WIN_phong_shading\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"phong_shading\", 13))\n        {\n          ret = GLEW_WIN_phong_shading;\n          continue;\n        }\n#endif\n#ifdef GL_WIN_specular_fog\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"specular_fog\", 12))\n        {\n          ret = GLEW_WIN_specular_fog;\n          continue;\n        }\n#endif\n#ifdef GL_WIN_swap_hint\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_hint\", 9))\n        {\n          ret = GLEW_WIN_swap_hint;\n          continue;\n        }\n#endif\n      }\n    }\n    ret = (len == 0);\n  }\n  return ret;\n}\n\n#if defined(_WIN32)\n\n#if defined(GLEW_MX)\nGLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext* ctx, const char* name)\n#else\nGLboolean GLEWAPIENTRY wglewIsSupported (const char* name)\n#endif\n{\n  GLubyte* pos = (GLubyte*)name;\n  GLuint len = _glewStrLen(pos);\n  GLboolean ret = GL_TRUE;\n  while (ret && len > 0)\n  {\n    if (_glewStrSame1(&pos, &len, (const GLubyte*)\"WGL_\", 4))\n    {\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"3DFX_\", 5))\n      {\n#ifdef WGL_3DFX_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = WGLEW_3DFX_multisample;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"3DL_\", 4))\n      {\n#ifdef WGL_3DL_stereo_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"stereo_control\", 14))\n        {\n          ret = WGLEW_3DL_stereo_control;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"AMD_\", 4))\n      {\n#ifdef WGL_AMD_gpu_association\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_association\", 15))\n        {\n          ret = WGLEW_AMD_gpu_association;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ARB_\", 4))\n      {\n#ifdef WGL_ARB_buffer_region\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"buffer_region\", 13))\n        {\n          ret = WGLEW_ARB_buffer_region;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_create_context\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context\", 14))\n        {\n          ret = WGLEW_ARB_create_context;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_create_context_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_profile\", 22))\n        {\n          ret = WGLEW_ARB_create_context_profile;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_create_context_robustness\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_robustness\", 25))\n        {\n          ret = WGLEW_ARB_create_context_robustness;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_extensions_string\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"extensions_string\", 17))\n        {\n          ret = WGLEW_ARB_extensions_string;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = WGLEW_ARB_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_make_current_read\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"make_current_read\", 17))\n        {\n          ret = WGLEW_ARB_make_current_read;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = WGLEW_ARB_multisample;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_pbuffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pbuffer\", 7))\n        {\n          ret = WGLEW_ARB_pbuffer;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_pixel_format\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format\", 12))\n        {\n          ret = WGLEW_ARB_pixel_format;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_pixel_format_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format_float\", 18))\n        {\n          ret = WGLEW_ARB_pixel_format_float;\n          continue;\n        }\n#endif\n#ifdef WGL_ARB_render_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"render_texture\", 14))\n        {\n          ret = WGLEW_ARB_render_texture;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ATI_\", 4))\n      {\n#ifdef WGL_ATI_pixel_format_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format_float\", 18))\n        {\n          ret = WGLEW_ATI_pixel_format_float;\n          continue;\n        }\n#endif\n#ifdef WGL_ATI_render_texture_rectangle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"render_texture_rectangle\", 24))\n        {\n          ret = WGLEW_ATI_render_texture_rectangle;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"EXT_\", 4))\n      {\n#ifdef WGL_EXT_create_context_es2_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_es2_profile\", 26))\n        {\n          ret = WGLEW_EXT_create_context_es2_profile;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_create_context_es_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_es_profile\", 25))\n        {\n          ret = WGLEW_EXT_create_context_es_profile;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_depth_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"depth_float\", 11))\n        {\n          ret = WGLEW_EXT_depth_float;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_display_color_table\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"display_color_table\", 19))\n        {\n          ret = WGLEW_EXT_display_color_table;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_extensions_string\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"extensions_string\", 17))\n        {\n          ret = WGLEW_EXT_extensions_string;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = WGLEW_EXT_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_make_current_read\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"make_current_read\", 17))\n        {\n          ret = WGLEW_EXT_make_current_read;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = WGLEW_EXT_multisample;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_pbuffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pbuffer\", 7))\n        {\n          ret = WGLEW_EXT_pbuffer;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_pixel_format\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format\", 12))\n        {\n          ret = WGLEW_EXT_pixel_format;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_pixel_format_packed_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format_packed_float\", 25))\n        {\n          ret = WGLEW_EXT_pixel_format_packed_float;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_swap_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control\", 12))\n        {\n          ret = WGLEW_EXT_swap_control;\n          continue;\n        }\n#endif\n#ifdef WGL_EXT_swap_control_tear\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control_tear\", 17))\n        {\n          ret = WGLEW_EXT_swap_control_tear;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"I3D_\", 4))\n      {\n#ifdef WGL_I3D_digital_video_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"digital_video_control\", 21))\n        {\n          ret = WGLEW_I3D_digital_video_control;\n          continue;\n        }\n#endif\n#ifdef WGL_I3D_gamma\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gamma\", 5))\n        {\n          ret = WGLEW_I3D_gamma;\n          continue;\n        }\n#endif\n#ifdef WGL_I3D_genlock\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"genlock\", 7))\n        {\n          ret = WGLEW_I3D_genlock;\n          continue;\n        }\n#endif\n#ifdef WGL_I3D_image_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"image_buffer\", 12))\n        {\n          ret = WGLEW_I3D_image_buffer;\n          continue;\n        }\n#endif\n#ifdef WGL_I3D_swap_frame_lock\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_frame_lock\", 15))\n        {\n          ret = WGLEW_I3D_swap_frame_lock;\n          continue;\n        }\n#endif\n#ifdef WGL_I3D_swap_frame_usage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_frame_usage\", 16))\n        {\n          ret = WGLEW_I3D_swap_frame_usage;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"NV_\", 3))\n      {\n#ifdef WGL_NV_DX_interop\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"DX_interop\", 10))\n        {\n          ret = WGLEW_NV_DX_interop;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_DX_interop2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"DX_interop2\", 11))\n        {\n          ret = WGLEW_NV_DX_interop2;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_copy_image\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_image\", 10))\n        {\n          ret = WGLEW_NV_copy_image;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_float_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"float_buffer\", 12))\n        {\n          ret = WGLEW_NV_float_buffer;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_gpu_affinity\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_affinity\", 12))\n        {\n          ret = WGLEW_NV_gpu_affinity;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_multisample_coverage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample_coverage\", 20))\n        {\n          ret = WGLEW_NV_multisample_coverage;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_present_video\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"present_video\", 13))\n        {\n          ret = WGLEW_NV_present_video;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_render_depth_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"render_depth_texture\", 20))\n        {\n          ret = WGLEW_NV_render_depth_texture;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_render_texture_rectangle\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"render_texture_rectangle\", 24))\n        {\n          ret = WGLEW_NV_render_texture_rectangle;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_swap_group\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_group\", 10))\n        {\n          ret = WGLEW_NV_swap_group;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_vertex_array_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_range\", 18))\n        {\n          ret = WGLEW_NV_vertex_array_range;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_video_capture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_capture\", 13))\n        {\n          ret = WGLEW_NV_video_capture;\n          continue;\n        }\n#endif\n#ifdef WGL_NV_video_output\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_output\", 12))\n        {\n          ret = WGLEW_NV_video_output;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"OML_\", 4))\n      {\n#ifdef WGL_OML_sync_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sync_control\", 12))\n        {\n          ret = WGLEW_OML_sync_control;\n          continue;\n        }\n#endif\n      }\n    }\n    ret = (len == 0);\n  }\n  return ret;\n}\n\n#elif !defined(__ANDROID__) && !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n\n#if defined(GLEW_MX)\nGLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name)\n#else\nGLboolean glxewIsSupported (const char* name)\n#endif\n{\n  GLubyte* pos = (GLubyte*)name;\n  GLuint len = _glewStrLen(pos);\n  GLboolean ret = GL_TRUE;\n  while (ret && len > 0)\n  {\n    if(_glewStrSame1(&pos, &len, (const GLubyte*)\"GLX_\", 4))\n    {\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"VERSION_\", 8))\n      {\n#ifdef GLX_VERSION_1_2\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_2\", 3))\n        {\n          ret = GLXEW_VERSION_1_2;\n          continue;\n        }\n#endif\n#ifdef GLX_VERSION_1_3\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_3\", 3))\n        {\n          ret = GLXEW_VERSION_1_3;\n          continue;\n        }\n#endif\n#ifdef GLX_VERSION_1_4\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"1_4\", 3))\n        {\n          ret = GLXEW_VERSION_1_4;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"3DFX_\", 5))\n      {\n#ifdef GLX_3DFX_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLXEW_3DFX_multisample;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"AMD_\", 4))\n      {\n#ifdef GLX_AMD_gpu_association\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"gpu_association\", 15))\n        {\n          ret = GLXEW_AMD_gpu_association;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ARB_\", 4))\n      {\n#ifdef GLX_ARB_create_context\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context\", 14))\n        {\n          ret = GLXEW_ARB_create_context;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_create_context_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_profile\", 22))\n        {\n          ret = GLXEW_ARB_create_context_profile;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_create_context_robustness\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_robustness\", 25))\n        {\n          ret = GLXEW_ARB_create_context_robustness;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_fbconfig_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fbconfig_float\", 14))\n        {\n          ret = GLXEW_ARB_fbconfig_float;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = GLXEW_ARB_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_get_proc_address\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"get_proc_address\", 16))\n        {\n          ret = GLXEW_ARB_get_proc_address;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLXEW_ARB_multisample;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_robustness_application_isolation\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robustness_application_isolation\", 32))\n        {\n          ret = GLXEW_ARB_robustness_application_isolation;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_robustness_share_group_isolation\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"robustness_share_group_isolation\", 32))\n        {\n          ret = GLXEW_ARB_robustness_share_group_isolation;\n          continue;\n        }\n#endif\n#ifdef GLX_ARB_vertex_buffer_object\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_buffer_object\", 20))\n        {\n          ret = GLXEW_ARB_vertex_buffer_object;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"ATI_\", 4))\n      {\n#ifdef GLX_ATI_pixel_format_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixel_format_float\", 18))\n        {\n          ret = GLXEW_ATI_pixel_format_float;\n          continue;\n        }\n#endif\n#ifdef GLX_ATI_render_texture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"render_texture\", 14))\n        {\n          ret = GLXEW_ATI_render_texture;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"EXT_\", 4))\n      {\n#ifdef GLX_EXT_create_context_es2_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_es2_profile\", 26))\n        {\n          ret = GLXEW_EXT_create_context_es2_profile;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_create_context_es_profile\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"create_context_es_profile\", 25))\n        {\n          ret = GLXEW_EXT_create_context_es_profile;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_fbconfig_packed_float\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fbconfig_packed_float\", 21))\n        {\n          ret = GLXEW_EXT_fbconfig_packed_float;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_framebuffer_sRGB\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"framebuffer_sRGB\", 16))\n        {\n          ret = GLXEW_EXT_framebuffer_sRGB;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_import_context\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"import_context\", 14))\n        {\n          ret = GLXEW_EXT_import_context;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_scene_marker\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"scene_marker\", 12))\n        {\n          ret = GLXEW_EXT_scene_marker;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_swap_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control\", 12))\n        {\n          ret = GLXEW_EXT_swap_control;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_swap_control_tear\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control_tear\", 17))\n        {\n          ret = GLXEW_EXT_swap_control_tear;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_texture_from_pixmap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"texture_from_pixmap\", 19))\n        {\n          ret = GLXEW_EXT_texture_from_pixmap;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_visual_info\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"visual_info\", 11))\n        {\n          ret = GLXEW_EXT_visual_info;\n          continue;\n        }\n#endif\n#ifdef GLX_EXT_visual_rating\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"visual_rating\", 13))\n        {\n          ret = GLXEW_EXT_visual_rating;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"INTEL_\", 6))\n      {\n#ifdef GLX_INTEL_swap_event\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_event\", 10))\n        {\n          ret = GLXEW_INTEL_swap_event;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"MESA_\", 5))\n      {\n#ifdef GLX_MESA_agp_offset\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"agp_offset\", 10))\n        {\n          ret = GLXEW_MESA_agp_offset;\n          continue;\n        }\n#endif\n#ifdef GLX_MESA_copy_sub_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_sub_buffer\", 15))\n        {\n          ret = GLXEW_MESA_copy_sub_buffer;\n          continue;\n        }\n#endif\n#ifdef GLX_MESA_pixmap_colormap\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pixmap_colormap\", 15))\n        {\n          ret = GLXEW_MESA_pixmap_colormap;\n          continue;\n        }\n#endif\n#ifdef GLX_MESA_release_buffers\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"release_buffers\", 15))\n        {\n          ret = GLXEW_MESA_release_buffers;\n          continue;\n        }\n#endif\n#ifdef GLX_MESA_set_3dfx_mode\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"set_3dfx_mode\", 13))\n        {\n          ret = GLXEW_MESA_set_3dfx_mode;\n          continue;\n        }\n#endif\n#ifdef GLX_MESA_swap_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control\", 12))\n        {\n          ret = GLXEW_MESA_swap_control;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"NV_\", 3))\n      {\n#ifdef GLX_NV_copy_image\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"copy_image\", 10))\n        {\n          ret = GLXEW_NV_copy_image;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_float_buffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"float_buffer\", 12))\n        {\n          ret = GLXEW_NV_float_buffer;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_multisample_coverage\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample_coverage\", 20))\n        {\n          ret = GLXEW_NV_multisample_coverage;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_present_video\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"present_video\", 13))\n        {\n          ret = GLXEW_NV_present_video;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_swap_group\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_group\", 10))\n        {\n          ret = GLXEW_NV_swap_group;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_vertex_array_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"vertex_array_range\", 18))\n        {\n          ret = GLXEW_NV_vertex_array_range;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_video_capture\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_capture\", 13))\n        {\n          ret = GLXEW_NV_video_capture;\n          continue;\n        }\n#endif\n#ifdef GLX_NV_video_out\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_out\", 9))\n        {\n          ret = GLXEW_NV_video_out;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"OML_\", 4))\n      {\n#ifdef GLX_OML_swap_method\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_method\", 11))\n        {\n          ret = GLXEW_OML_swap_method;\n          continue;\n        }\n#endif\n#ifdef GLX_OML_sync_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"sync_control\", 12))\n        {\n          ret = GLXEW_OML_sync_control;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGIS_\", 5))\n      {\n#ifdef GLX_SGIS_blended_overlay\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"blended_overlay\", 15))\n        {\n          ret = GLXEW_SGIS_blended_overlay;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIS_color_range\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"color_range\", 11))\n        {\n          ret = GLXEW_SGIS_color_range;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIS_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"multisample\", 11))\n        {\n          ret = GLXEW_SGIS_multisample;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIS_shared_multisample\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"shared_multisample\", 18))\n        {\n          ret = GLXEW_SGIS_shared_multisample;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGIX_\", 5))\n      {\n#ifdef GLX_SGIX_fbconfig\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"fbconfig\", 8))\n        {\n          ret = GLXEW_SGIX_fbconfig;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_hyperpipe\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"hyperpipe\", 9))\n        {\n          ret = GLXEW_SGIX_hyperpipe;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_pbuffer\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"pbuffer\", 7))\n        {\n          ret = GLXEW_SGIX_pbuffer;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_swap_barrier\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_barrier\", 12))\n        {\n          ret = GLXEW_SGIX_swap_barrier;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_swap_group\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_group\", 10))\n        {\n          ret = GLXEW_SGIX_swap_group;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_video_resize\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_resize\", 12))\n        {\n          ret = GLXEW_SGIX_video_resize;\n          continue;\n        }\n#endif\n#ifdef GLX_SGIX_visual_select_group\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"visual_select_group\", 19))\n        {\n          ret = GLXEW_SGIX_visual_select_group;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SGI_\", 4))\n      {\n#ifdef GLX_SGI_cushion\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"cushion\", 7))\n        {\n          ret = GLXEW_SGI_cushion;\n          continue;\n        }\n#endif\n#ifdef GLX_SGI_make_current_read\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"make_current_read\", 17))\n        {\n          ret = GLXEW_SGI_make_current_read;\n          continue;\n        }\n#endif\n#ifdef GLX_SGI_swap_control\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"swap_control\", 12))\n        {\n          ret = GLXEW_SGI_swap_control;\n          continue;\n        }\n#endif\n#ifdef GLX_SGI_video_sync\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_sync\", 10))\n        {\n          ret = GLXEW_SGI_video_sync;\n          continue;\n        }\n#endif\n      }\n      if (_glewStrSame2(&pos, &len, (const GLubyte*)\"SUN_\", 4))\n      {\n#ifdef GLX_SUN_get_transparent_index\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"get_transparent_index\", 21))\n        {\n          ret = GLXEW_SUN_get_transparent_index;\n          continue;\n        }\n#endif\n#ifdef GLX_SUN_video_resize\n        if (_glewStrSame3(&pos, &len, (const GLubyte*)\"video_resize\", 12))\n        {\n          ret = GLXEW_SUN_video_resize;\n          continue;\n        }\n#endif\n      }\n    }\n    ret = (len == 0);\n  }\n  return ret;\n}\n\n#endif /* _WIN32 */\n"
  },
  {
    "path": "deps/glew/src/glewinfo.c",
    "content": "/*\n** The OpenGL Extension Wrangler Library\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\n** Copyright (C) 2002, Lev Povalahev\n** All rights reserved.\n** \n** Redistribution and use in source and binary forms, with or without \n** modification, are permitted provided that the following conditions are met:\n** \n** * Redistributions of source code must retain the above copyright notice, \n**   this list of conditions and the following disclaimer.\n** * Redistributions in binary form must reproduce the above copyright notice, \n**   this list of conditions and the following disclaimer in the documentation \n**   and/or other materials provided with the distribution.\n** * The name of the author may be used to endorse or promote products \n**   derived from this software without specific prior written permission.\n**\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\n** THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <GL/glew.h>\n#if defined(_WIN32)\n#include <GL/wglew.h>\n#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n#include <GL/glxew.h>\n#endif\n\n#ifdef GLEW_REGAL\n#include <GL/Regal.h>\n#endif\n\nstatic FILE* f;\n\n#ifdef GLEW_MX\nGLEWContext _glewctx;\n#define glewGetContext() (&_glewctx)\n#ifdef _WIN32\nWGLEWContext _wglewctx;\n#define wglewGetContext() (&_wglewctx)\n#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nGLXEWContext _glxewctx;\n#define glxewGetContext() (&_glxewctx)\n#endif\n#endif\n\n#if defined(_WIN32)\nGLboolean glewCreateContext (int* pixelformat);\n#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nGLboolean glewCreateContext (const char* display, int* visual);\n#else\nGLboolean glewCreateContext ();\n#endif\n\n#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nGLboolean glewParseArgs (int argc, char** argv, char** display, int* visual);\n#endif\n\nvoid glewDestroyContext ();\n\n/* ------------------------------------------------------------------------- */\n\nstatic void glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLboolean def3)\n{\n  unsigned int i;\n  fprintf(f, \"\\n%s:\", name);\n  for (i=0; i<62-strlen(name); i++) fprintf(f, \" \");\n  fprintf(f, \"%s \", def1 ? \"OK\" : \"MISSING\");\n  if (def1 != def2)\n    fprintf(f, \"[%s] \", def2 ? \"OK\" : \"MISSING\");\n  if (def1 != def3)\n    fprintf(f, \"[%s]\\n\", def3 ? \"OK\" : \"MISSING\");\n  else\n    fprintf(f, \"\\n\");\n  for (i=0; i<strlen(name)+1; i++) fprintf(f, \"-\");\n  fprintf(f, \"\\n\");\n  fflush(f);\n}\n\nstatic void glewInfoFunc (const char* name, GLint undefined)\n{\n  unsigned int i;\n  fprintf(f, \"  %s:\", name);\n  for (i=0; i<60-strlen(name); i++) fprintf(f, \" \");\n  fprintf(f, \"%s\\n\", undefined ? \"MISSING\" : \"OK\");\n  fflush(f);\n}\n\n/* ----------------------------- GL_VERSION_1_1 ---------------------------- */\n\n#ifdef GL_VERSION_1_1\n\nstatic void _glewInfo_GL_VERSION_1_1 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_1\", GLEW_VERSION_1_1, GLEW_VERSION_1_1, GLEW_VERSION_1_1);\n}\n\n#endif /* GL_VERSION_1_1 */\n\n#ifdef GL_VERSION_1_2\n\nstatic void _glewInfo_GL_VERSION_1_2 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_2\", GLEW_VERSION_1_2, GLEW_VERSION_1_2, GLEW_VERSION_1_2);\n\n  glewInfoFunc(\"glCopyTexSubImage3D\", glCopyTexSubImage3D == NULL);\n  glewInfoFunc(\"glDrawRangeElements\", glDrawRangeElements == NULL);\n  glewInfoFunc(\"glTexImage3D\", glTexImage3D == NULL);\n  glewInfoFunc(\"glTexSubImage3D\", glTexSubImage3D == NULL);\n}\n\n#endif /* GL_VERSION_1_2 */\n\n#ifdef GL_VERSION_1_2_1\n\nstatic void _glewInfo_GL_VERSION_1_2_1 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_2_1\", GLEW_VERSION_1_2_1, GLEW_VERSION_1_2_1, GLEW_VERSION_1_2_1);\n}\n\n#endif /* GL_VERSION_1_2_1 */\n\n#ifdef GL_VERSION_1_3\n\nstatic void _glewInfo_GL_VERSION_1_3 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_3\", GLEW_VERSION_1_3, GLEW_VERSION_1_3, GLEW_VERSION_1_3);\n\n  glewInfoFunc(\"glActiveTexture\", glActiveTexture == NULL);\n  glewInfoFunc(\"glClientActiveTexture\", glClientActiveTexture == NULL);\n  glewInfoFunc(\"glCompressedTexImage1D\", glCompressedTexImage1D == NULL);\n  glewInfoFunc(\"glCompressedTexImage2D\", glCompressedTexImage2D == NULL);\n  glewInfoFunc(\"glCompressedTexImage3D\", glCompressedTexImage3D == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage1D\", glCompressedTexSubImage1D == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage2D\", glCompressedTexSubImage2D == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage3D\", glCompressedTexSubImage3D == NULL);\n  glewInfoFunc(\"glGetCompressedTexImage\", glGetCompressedTexImage == NULL);\n  glewInfoFunc(\"glLoadTransposeMatrixd\", glLoadTransposeMatrixd == NULL);\n  glewInfoFunc(\"glLoadTransposeMatrixf\", glLoadTransposeMatrixf == NULL);\n  glewInfoFunc(\"glMultTransposeMatrixd\", glMultTransposeMatrixd == NULL);\n  glewInfoFunc(\"glMultTransposeMatrixf\", glMultTransposeMatrixf == NULL);\n  glewInfoFunc(\"glMultiTexCoord1d\", glMultiTexCoord1d == NULL);\n  glewInfoFunc(\"glMultiTexCoord1dv\", glMultiTexCoord1dv == NULL);\n  glewInfoFunc(\"glMultiTexCoord1f\", glMultiTexCoord1f == NULL);\n  glewInfoFunc(\"glMultiTexCoord1fv\", glMultiTexCoord1fv == NULL);\n  glewInfoFunc(\"glMultiTexCoord1i\", glMultiTexCoord1i == NULL);\n  glewInfoFunc(\"glMultiTexCoord1iv\", glMultiTexCoord1iv == NULL);\n  glewInfoFunc(\"glMultiTexCoord1s\", glMultiTexCoord1s == NULL);\n  glewInfoFunc(\"glMultiTexCoord1sv\", glMultiTexCoord1sv == NULL);\n  glewInfoFunc(\"glMultiTexCoord2d\", glMultiTexCoord2d == NULL);\n  glewInfoFunc(\"glMultiTexCoord2dv\", glMultiTexCoord2dv == NULL);\n  glewInfoFunc(\"glMultiTexCoord2f\", glMultiTexCoord2f == NULL);\n  glewInfoFunc(\"glMultiTexCoord2fv\", glMultiTexCoord2fv == NULL);\n  glewInfoFunc(\"glMultiTexCoord2i\", glMultiTexCoord2i == NULL);\n  glewInfoFunc(\"glMultiTexCoord2iv\", glMultiTexCoord2iv == NULL);\n  glewInfoFunc(\"glMultiTexCoord2s\", glMultiTexCoord2s == NULL);\n  glewInfoFunc(\"glMultiTexCoord2sv\", glMultiTexCoord2sv == NULL);\n  glewInfoFunc(\"glMultiTexCoord3d\", glMultiTexCoord3d == NULL);\n  glewInfoFunc(\"glMultiTexCoord3dv\", glMultiTexCoord3dv == NULL);\n  glewInfoFunc(\"glMultiTexCoord3f\", glMultiTexCoord3f == NULL);\n  glewInfoFunc(\"glMultiTexCoord3fv\", glMultiTexCoord3fv == NULL);\n  glewInfoFunc(\"glMultiTexCoord3i\", glMultiTexCoord3i == NULL);\n  glewInfoFunc(\"glMultiTexCoord3iv\", glMultiTexCoord3iv == NULL);\n  glewInfoFunc(\"glMultiTexCoord3s\", glMultiTexCoord3s == NULL);\n  glewInfoFunc(\"glMultiTexCoord3sv\", glMultiTexCoord3sv == NULL);\n  glewInfoFunc(\"glMultiTexCoord4d\", glMultiTexCoord4d == NULL);\n  glewInfoFunc(\"glMultiTexCoord4dv\", glMultiTexCoord4dv == NULL);\n  glewInfoFunc(\"glMultiTexCoord4f\", glMultiTexCoord4f == NULL);\n  glewInfoFunc(\"glMultiTexCoord4fv\", glMultiTexCoord4fv == NULL);\n  glewInfoFunc(\"glMultiTexCoord4i\", glMultiTexCoord4i == NULL);\n  glewInfoFunc(\"glMultiTexCoord4iv\", glMultiTexCoord4iv == NULL);\n  glewInfoFunc(\"glMultiTexCoord4s\", glMultiTexCoord4s == NULL);\n  glewInfoFunc(\"glMultiTexCoord4sv\", glMultiTexCoord4sv == NULL);\n  glewInfoFunc(\"glSampleCoverage\", glSampleCoverage == NULL);\n}\n\n#endif /* GL_VERSION_1_3 */\n\n#ifdef GL_VERSION_1_4\n\nstatic void _glewInfo_GL_VERSION_1_4 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_4\", GLEW_VERSION_1_4, GLEW_VERSION_1_4, GLEW_VERSION_1_4);\n\n  glewInfoFunc(\"glBlendColor\", glBlendColor == NULL);\n  glewInfoFunc(\"glBlendEquation\", glBlendEquation == NULL);\n  glewInfoFunc(\"glBlendFuncSeparate\", glBlendFuncSeparate == NULL);\n  glewInfoFunc(\"glFogCoordPointer\", glFogCoordPointer == NULL);\n  glewInfoFunc(\"glFogCoordd\", glFogCoordd == NULL);\n  glewInfoFunc(\"glFogCoorddv\", glFogCoorddv == NULL);\n  glewInfoFunc(\"glFogCoordf\", glFogCoordf == NULL);\n  glewInfoFunc(\"glFogCoordfv\", glFogCoordfv == NULL);\n  glewInfoFunc(\"glMultiDrawArrays\", glMultiDrawArrays == NULL);\n  glewInfoFunc(\"glMultiDrawElements\", glMultiDrawElements == NULL);\n  glewInfoFunc(\"glPointParameterf\", glPointParameterf == NULL);\n  glewInfoFunc(\"glPointParameterfv\", glPointParameterfv == NULL);\n  glewInfoFunc(\"glPointParameteri\", glPointParameteri == NULL);\n  glewInfoFunc(\"glPointParameteriv\", glPointParameteriv == NULL);\n  glewInfoFunc(\"glSecondaryColor3b\", glSecondaryColor3b == NULL);\n  glewInfoFunc(\"glSecondaryColor3bv\", glSecondaryColor3bv == NULL);\n  glewInfoFunc(\"glSecondaryColor3d\", glSecondaryColor3d == NULL);\n  glewInfoFunc(\"glSecondaryColor3dv\", glSecondaryColor3dv == NULL);\n  glewInfoFunc(\"glSecondaryColor3f\", glSecondaryColor3f == NULL);\n  glewInfoFunc(\"glSecondaryColor3fv\", glSecondaryColor3fv == NULL);\n  glewInfoFunc(\"glSecondaryColor3i\", glSecondaryColor3i == NULL);\n  glewInfoFunc(\"glSecondaryColor3iv\", glSecondaryColor3iv == NULL);\n  glewInfoFunc(\"glSecondaryColor3s\", glSecondaryColor3s == NULL);\n  glewInfoFunc(\"glSecondaryColor3sv\", glSecondaryColor3sv == NULL);\n  glewInfoFunc(\"glSecondaryColor3ub\", glSecondaryColor3ub == NULL);\n  glewInfoFunc(\"glSecondaryColor3ubv\", glSecondaryColor3ubv == NULL);\n  glewInfoFunc(\"glSecondaryColor3ui\", glSecondaryColor3ui == NULL);\n  glewInfoFunc(\"glSecondaryColor3uiv\", glSecondaryColor3uiv == NULL);\n  glewInfoFunc(\"glSecondaryColor3us\", glSecondaryColor3us == NULL);\n  glewInfoFunc(\"glSecondaryColor3usv\", glSecondaryColor3usv == NULL);\n  glewInfoFunc(\"glSecondaryColorPointer\", glSecondaryColorPointer == NULL);\n  glewInfoFunc(\"glWindowPos2d\", glWindowPos2d == NULL);\n  glewInfoFunc(\"glWindowPos2dv\", glWindowPos2dv == NULL);\n  glewInfoFunc(\"glWindowPos2f\", glWindowPos2f == NULL);\n  glewInfoFunc(\"glWindowPos2fv\", glWindowPos2fv == NULL);\n  glewInfoFunc(\"glWindowPos2i\", glWindowPos2i == NULL);\n  glewInfoFunc(\"glWindowPos2iv\", glWindowPos2iv == NULL);\n  glewInfoFunc(\"glWindowPos2s\", glWindowPos2s == NULL);\n  glewInfoFunc(\"glWindowPos2sv\", glWindowPos2sv == NULL);\n  glewInfoFunc(\"glWindowPos3d\", glWindowPos3d == NULL);\n  glewInfoFunc(\"glWindowPos3dv\", glWindowPos3dv == NULL);\n  glewInfoFunc(\"glWindowPos3f\", glWindowPos3f == NULL);\n  glewInfoFunc(\"glWindowPos3fv\", glWindowPos3fv == NULL);\n  glewInfoFunc(\"glWindowPos3i\", glWindowPos3i == NULL);\n  glewInfoFunc(\"glWindowPos3iv\", glWindowPos3iv == NULL);\n  glewInfoFunc(\"glWindowPos3s\", glWindowPos3s == NULL);\n  glewInfoFunc(\"glWindowPos3sv\", glWindowPos3sv == NULL);\n}\n\n#endif /* GL_VERSION_1_4 */\n\n#ifdef GL_VERSION_1_5\n\nstatic void _glewInfo_GL_VERSION_1_5 (void)\n{\n  glewPrintExt(\"GL_VERSION_1_5\", GLEW_VERSION_1_5, GLEW_VERSION_1_5, GLEW_VERSION_1_5);\n\n  glewInfoFunc(\"glBeginQuery\", glBeginQuery == NULL);\n  glewInfoFunc(\"glBindBuffer\", glBindBuffer == NULL);\n  glewInfoFunc(\"glBufferData\", glBufferData == NULL);\n  glewInfoFunc(\"glBufferSubData\", glBufferSubData == NULL);\n  glewInfoFunc(\"glDeleteBuffers\", glDeleteBuffers == NULL);\n  glewInfoFunc(\"glDeleteQueries\", glDeleteQueries == NULL);\n  glewInfoFunc(\"glEndQuery\", glEndQuery == NULL);\n  glewInfoFunc(\"glGenBuffers\", glGenBuffers == NULL);\n  glewInfoFunc(\"glGenQueries\", glGenQueries == NULL);\n  glewInfoFunc(\"glGetBufferParameteriv\", glGetBufferParameteriv == NULL);\n  glewInfoFunc(\"glGetBufferPointerv\", glGetBufferPointerv == NULL);\n  glewInfoFunc(\"glGetBufferSubData\", glGetBufferSubData == NULL);\n  glewInfoFunc(\"glGetQueryObjectiv\", glGetQueryObjectiv == NULL);\n  glewInfoFunc(\"glGetQueryObjectuiv\", glGetQueryObjectuiv == NULL);\n  glewInfoFunc(\"glGetQueryiv\", glGetQueryiv == NULL);\n  glewInfoFunc(\"glIsBuffer\", glIsBuffer == NULL);\n  glewInfoFunc(\"glIsQuery\", glIsQuery == NULL);\n  glewInfoFunc(\"glMapBuffer\", glMapBuffer == NULL);\n  glewInfoFunc(\"glUnmapBuffer\", glUnmapBuffer == NULL);\n}\n\n#endif /* GL_VERSION_1_5 */\n\n#ifdef GL_VERSION_2_0\n\nstatic void _glewInfo_GL_VERSION_2_0 (void)\n{\n  glewPrintExt(\"GL_VERSION_2_0\", GLEW_VERSION_2_0, GLEW_VERSION_2_0, GLEW_VERSION_2_0);\n\n  glewInfoFunc(\"glAttachShader\", glAttachShader == NULL);\n  glewInfoFunc(\"glBindAttribLocation\", glBindAttribLocation == NULL);\n  glewInfoFunc(\"glBlendEquationSeparate\", glBlendEquationSeparate == NULL);\n  glewInfoFunc(\"glCompileShader\", glCompileShader == NULL);\n  glewInfoFunc(\"glCreateProgram\", glCreateProgram == NULL);\n  glewInfoFunc(\"glCreateShader\", glCreateShader == NULL);\n  glewInfoFunc(\"glDeleteProgram\", glDeleteProgram == NULL);\n  glewInfoFunc(\"glDeleteShader\", glDeleteShader == NULL);\n  glewInfoFunc(\"glDetachShader\", glDetachShader == NULL);\n  glewInfoFunc(\"glDisableVertexAttribArray\", glDisableVertexAttribArray == NULL);\n  glewInfoFunc(\"glDrawBuffers\", glDrawBuffers == NULL);\n  glewInfoFunc(\"glEnableVertexAttribArray\", glEnableVertexAttribArray == NULL);\n  glewInfoFunc(\"glGetActiveAttrib\", glGetActiveAttrib == NULL);\n  glewInfoFunc(\"glGetActiveUniform\", glGetActiveUniform == NULL);\n  glewInfoFunc(\"glGetAttachedShaders\", glGetAttachedShaders == NULL);\n  glewInfoFunc(\"glGetAttribLocation\", glGetAttribLocation == NULL);\n  glewInfoFunc(\"glGetProgramInfoLog\", glGetProgramInfoLog == NULL);\n  glewInfoFunc(\"glGetProgramiv\", glGetProgramiv == NULL);\n  glewInfoFunc(\"glGetShaderInfoLog\", glGetShaderInfoLog == NULL);\n  glewInfoFunc(\"glGetShaderSource\", glGetShaderSource == NULL);\n  glewInfoFunc(\"glGetShaderiv\", glGetShaderiv == NULL);\n  glewInfoFunc(\"glGetUniformLocation\", glGetUniformLocation == NULL);\n  glewInfoFunc(\"glGetUniformfv\", glGetUniformfv == NULL);\n  glewInfoFunc(\"glGetUniformiv\", glGetUniformiv == NULL);\n  glewInfoFunc(\"glGetVertexAttribPointerv\", glGetVertexAttribPointerv == NULL);\n  glewInfoFunc(\"glGetVertexAttribdv\", glGetVertexAttribdv == NULL);\n  glewInfoFunc(\"glGetVertexAttribfv\", glGetVertexAttribfv == NULL);\n  glewInfoFunc(\"glGetVertexAttribiv\", glGetVertexAttribiv == NULL);\n  glewInfoFunc(\"glIsProgram\", glIsProgram == NULL);\n  glewInfoFunc(\"glIsShader\", glIsShader == NULL);\n  glewInfoFunc(\"glLinkProgram\", glLinkProgram == NULL);\n  glewInfoFunc(\"glShaderSource\", glShaderSource == NULL);\n  glewInfoFunc(\"glStencilFuncSeparate\", glStencilFuncSeparate == NULL);\n  glewInfoFunc(\"glStencilMaskSeparate\", glStencilMaskSeparate == NULL);\n  glewInfoFunc(\"glStencilOpSeparate\", glStencilOpSeparate == NULL);\n  glewInfoFunc(\"glUniform1f\", glUniform1f == NULL);\n  glewInfoFunc(\"glUniform1fv\", glUniform1fv == NULL);\n  glewInfoFunc(\"glUniform1i\", glUniform1i == NULL);\n  glewInfoFunc(\"glUniform1iv\", glUniform1iv == NULL);\n  glewInfoFunc(\"glUniform2f\", glUniform2f == NULL);\n  glewInfoFunc(\"glUniform2fv\", glUniform2fv == NULL);\n  glewInfoFunc(\"glUniform2i\", glUniform2i == NULL);\n  glewInfoFunc(\"glUniform2iv\", glUniform2iv == NULL);\n  glewInfoFunc(\"glUniform3f\", glUniform3f == NULL);\n  glewInfoFunc(\"glUniform3fv\", glUniform3fv == NULL);\n  glewInfoFunc(\"glUniform3i\", glUniform3i == NULL);\n  glewInfoFunc(\"glUniform3iv\", glUniform3iv == NULL);\n  glewInfoFunc(\"glUniform4f\", glUniform4f == NULL);\n  glewInfoFunc(\"glUniform4fv\", glUniform4fv == NULL);\n  glewInfoFunc(\"glUniform4i\", glUniform4i == NULL);\n  glewInfoFunc(\"glUniform4iv\", glUniform4iv == NULL);\n  glewInfoFunc(\"glUniformMatrix2fv\", glUniformMatrix2fv == NULL);\n  glewInfoFunc(\"glUniformMatrix3fv\", glUniformMatrix3fv == NULL);\n  glewInfoFunc(\"glUniformMatrix4fv\", glUniformMatrix4fv == NULL);\n  glewInfoFunc(\"glUseProgram\", glUseProgram == NULL);\n  glewInfoFunc(\"glValidateProgram\", glValidateProgram == NULL);\n  glewInfoFunc(\"glVertexAttrib1d\", glVertexAttrib1d == NULL);\n  glewInfoFunc(\"glVertexAttrib1dv\", glVertexAttrib1dv == NULL);\n  glewInfoFunc(\"glVertexAttrib1f\", glVertexAttrib1f == NULL);\n  glewInfoFunc(\"glVertexAttrib1fv\", glVertexAttrib1fv == NULL);\n  glewInfoFunc(\"glVertexAttrib1s\", glVertexAttrib1s == NULL);\n  glewInfoFunc(\"glVertexAttrib1sv\", glVertexAttrib1sv == NULL);\n  glewInfoFunc(\"glVertexAttrib2d\", glVertexAttrib2d == NULL);\n  glewInfoFunc(\"glVertexAttrib2dv\", glVertexAttrib2dv == NULL);\n  glewInfoFunc(\"glVertexAttrib2f\", glVertexAttrib2f == NULL);\n  glewInfoFunc(\"glVertexAttrib2fv\", glVertexAttrib2fv == NULL);\n  glewInfoFunc(\"glVertexAttrib2s\", glVertexAttrib2s == NULL);\n  glewInfoFunc(\"glVertexAttrib2sv\", glVertexAttrib2sv == NULL);\n  glewInfoFunc(\"glVertexAttrib3d\", glVertexAttrib3d == NULL);\n  glewInfoFunc(\"glVertexAttrib3dv\", glVertexAttrib3dv == NULL);\n  glewInfoFunc(\"glVertexAttrib3f\", glVertexAttrib3f == NULL);\n  glewInfoFunc(\"glVertexAttrib3fv\", glVertexAttrib3fv == NULL);\n  glewInfoFunc(\"glVertexAttrib3s\", glVertexAttrib3s == NULL);\n  glewInfoFunc(\"glVertexAttrib3sv\", glVertexAttrib3sv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nbv\", glVertexAttrib4Nbv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Niv\", glVertexAttrib4Niv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nsv\", glVertexAttrib4Nsv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nub\", glVertexAttrib4Nub == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nubv\", glVertexAttrib4Nubv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nuiv\", glVertexAttrib4Nuiv == NULL);\n  glewInfoFunc(\"glVertexAttrib4Nusv\", glVertexAttrib4Nusv == NULL);\n  glewInfoFunc(\"glVertexAttrib4bv\", glVertexAttrib4bv == NULL);\n  glewInfoFunc(\"glVertexAttrib4d\", glVertexAttrib4d == NULL);\n  glewInfoFunc(\"glVertexAttrib4dv\", glVertexAttrib4dv == NULL);\n  glewInfoFunc(\"glVertexAttrib4f\", glVertexAttrib4f == NULL);\n  glewInfoFunc(\"glVertexAttrib4fv\", glVertexAttrib4fv == NULL);\n  glewInfoFunc(\"glVertexAttrib4iv\", glVertexAttrib4iv == NULL);\n  glewInfoFunc(\"glVertexAttrib4s\", glVertexAttrib4s == NULL);\n  glewInfoFunc(\"glVertexAttrib4sv\", glVertexAttrib4sv == NULL);\n  glewInfoFunc(\"glVertexAttrib4ubv\", glVertexAttrib4ubv == NULL);\n  glewInfoFunc(\"glVertexAttrib4uiv\", glVertexAttrib4uiv == NULL);\n  glewInfoFunc(\"glVertexAttrib4usv\", glVertexAttrib4usv == NULL);\n  glewInfoFunc(\"glVertexAttribPointer\", glVertexAttribPointer == NULL);\n}\n\n#endif /* GL_VERSION_2_0 */\n\n#ifdef GL_VERSION_2_1\n\nstatic void _glewInfo_GL_VERSION_2_1 (void)\n{\n  glewPrintExt(\"GL_VERSION_2_1\", GLEW_VERSION_2_1, GLEW_VERSION_2_1, GLEW_VERSION_2_1);\n\n  glewInfoFunc(\"glUniformMatrix2x3fv\", glUniformMatrix2x3fv == NULL);\n  glewInfoFunc(\"glUniformMatrix2x4fv\", glUniformMatrix2x4fv == NULL);\n  glewInfoFunc(\"glUniformMatrix3x2fv\", glUniformMatrix3x2fv == NULL);\n  glewInfoFunc(\"glUniformMatrix3x4fv\", glUniformMatrix3x4fv == NULL);\n  glewInfoFunc(\"glUniformMatrix4x2fv\", glUniformMatrix4x2fv == NULL);\n  glewInfoFunc(\"glUniformMatrix4x3fv\", glUniformMatrix4x3fv == NULL);\n}\n\n#endif /* GL_VERSION_2_1 */\n\n#ifdef GL_VERSION_3_0\n\nstatic void _glewInfo_GL_VERSION_3_0 (void)\n{\n  glewPrintExt(\"GL_VERSION_3_0\", GLEW_VERSION_3_0, GLEW_VERSION_3_0, GLEW_VERSION_3_0);\n\n  glewInfoFunc(\"glBeginConditionalRender\", glBeginConditionalRender == NULL);\n  glewInfoFunc(\"glBeginTransformFeedback\", glBeginTransformFeedback == NULL);\n  glewInfoFunc(\"glBindFragDataLocation\", glBindFragDataLocation == NULL);\n  glewInfoFunc(\"glClampColor\", glClampColor == NULL);\n  glewInfoFunc(\"glClearBufferfi\", glClearBufferfi == NULL);\n  glewInfoFunc(\"glClearBufferfv\", glClearBufferfv == NULL);\n  glewInfoFunc(\"glClearBufferiv\", glClearBufferiv == NULL);\n  glewInfoFunc(\"glClearBufferuiv\", glClearBufferuiv == NULL);\n  glewInfoFunc(\"glColorMaski\", glColorMaski == NULL);\n  glewInfoFunc(\"glDisablei\", glDisablei == NULL);\n  glewInfoFunc(\"glEnablei\", glEnablei == NULL);\n  glewInfoFunc(\"glEndConditionalRender\", glEndConditionalRender == NULL);\n  glewInfoFunc(\"glEndTransformFeedback\", glEndTransformFeedback == NULL);\n  glewInfoFunc(\"glGetBooleani_v\", glGetBooleani_v == NULL);\n  glewInfoFunc(\"glGetFragDataLocation\", glGetFragDataLocation == NULL);\n  glewInfoFunc(\"glGetStringi\", glGetStringi == NULL);\n  glewInfoFunc(\"glGetTexParameterIiv\", glGetTexParameterIiv == NULL);\n  glewInfoFunc(\"glGetTexParameterIuiv\", glGetTexParameterIuiv == NULL);\n  glewInfoFunc(\"glGetTransformFeedbackVarying\", glGetTransformFeedbackVarying == NULL);\n  glewInfoFunc(\"glGetUniformuiv\", glGetUniformuiv == NULL);\n  glewInfoFunc(\"glGetVertexAttribIiv\", glGetVertexAttribIiv == NULL);\n  glewInfoFunc(\"glGetVertexAttribIuiv\", glGetVertexAttribIuiv == NULL);\n  glewInfoFunc(\"glIsEnabledi\", glIsEnabledi == NULL);\n  glewInfoFunc(\"glTexParameterIiv\", glTexParameterIiv == NULL);\n  glewInfoFunc(\"glTexParameterIuiv\", glTexParameterIuiv == NULL);\n  glewInfoFunc(\"glTransformFeedbackVaryings\", glTransformFeedbackVaryings == NULL);\n  glewInfoFunc(\"glUniform1ui\", glUniform1ui == NULL);\n  glewInfoFunc(\"glUniform1uiv\", glUniform1uiv == NULL);\n  glewInfoFunc(\"glUniform2ui\", glUniform2ui == NULL);\n  glewInfoFunc(\"glUniform2uiv\", glUniform2uiv == NULL);\n  glewInfoFunc(\"glUniform3ui\", glUniform3ui == NULL);\n  glewInfoFunc(\"glUniform3uiv\", glUniform3uiv == NULL);\n  glewInfoFunc(\"glUniform4ui\", glUniform4ui == NULL);\n  glewInfoFunc(\"glUniform4uiv\", glUniform4uiv == NULL);\n  glewInfoFunc(\"glVertexAttribI1i\", glVertexAttribI1i == NULL);\n  glewInfoFunc(\"glVertexAttribI1iv\", glVertexAttribI1iv == NULL);\n  glewInfoFunc(\"glVertexAttribI1ui\", glVertexAttribI1ui == NULL);\n  glewInfoFunc(\"glVertexAttribI1uiv\", glVertexAttribI1uiv == NULL);\n  glewInfoFunc(\"glVertexAttribI2i\", glVertexAttribI2i == NULL);\n  glewInfoFunc(\"glVertexAttribI2iv\", glVertexAttribI2iv == NULL);\n  glewInfoFunc(\"glVertexAttribI2ui\", glVertexAttribI2ui == NULL);\n  glewInfoFunc(\"glVertexAttribI2uiv\", glVertexAttribI2uiv == NULL);\n  glewInfoFunc(\"glVertexAttribI3i\", glVertexAttribI3i == NULL);\n  glewInfoFunc(\"glVertexAttribI3iv\", glVertexAttribI3iv == NULL);\n  glewInfoFunc(\"glVertexAttribI3ui\", glVertexAttribI3ui == NULL);\n  glewInfoFunc(\"glVertexAttribI3uiv\", glVertexAttribI3uiv == NULL);\n  glewInfoFunc(\"glVertexAttribI4bv\", glVertexAttribI4bv == NULL);\n  glewInfoFunc(\"glVertexAttribI4i\", glVertexAttribI4i == NULL);\n  glewInfoFunc(\"glVertexAttribI4iv\", glVertexAttribI4iv == NULL);\n  glewInfoFunc(\"glVertexAttribI4sv\", glVertexAttribI4sv == NULL);\n  glewInfoFunc(\"glVertexAttribI4ubv\", glVertexAttribI4ubv == NULL);\n  glewInfoFunc(\"glVertexAttribI4ui\", glVertexAttribI4ui == NULL);\n  glewInfoFunc(\"glVertexAttribI4uiv\", glVertexAttribI4uiv == NULL);\n  glewInfoFunc(\"glVertexAttribI4usv\", glVertexAttribI4usv == NULL);\n  glewInfoFunc(\"glVertexAttribIPointer\", glVertexAttribIPointer == NULL);\n}\n\n#endif /* GL_VERSION_3_0 */\n\n#ifdef GL_VERSION_3_1\n\nstatic void _glewInfo_GL_VERSION_3_1 (void)\n{\n  glewPrintExt(\"GL_VERSION_3_1\", GLEW_VERSION_3_1, GLEW_VERSION_3_1, GLEW_VERSION_3_1);\n\n  glewInfoFunc(\"glDrawArraysInstanced\", glDrawArraysInstanced == NULL);\n  glewInfoFunc(\"glDrawElementsInstanced\", glDrawElementsInstanced == NULL);\n  glewInfoFunc(\"glPrimitiveRestartIndex\", glPrimitiveRestartIndex == NULL);\n  glewInfoFunc(\"glTexBuffer\", glTexBuffer == NULL);\n}\n\n#endif /* GL_VERSION_3_1 */\n\n#ifdef GL_VERSION_3_2\n\nstatic void _glewInfo_GL_VERSION_3_2 (void)\n{\n  glewPrintExt(\"GL_VERSION_3_2\", GLEW_VERSION_3_2, GLEW_VERSION_3_2, GLEW_VERSION_3_2);\n\n  glewInfoFunc(\"glFramebufferTexture\", glFramebufferTexture == NULL);\n  glewInfoFunc(\"glGetBufferParameteri64v\", glGetBufferParameteri64v == NULL);\n  glewInfoFunc(\"glGetInteger64i_v\", glGetInteger64i_v == NULL);\n}\n\n#endif /* GL_VERSION_3_2 */\n\n#ifdef GL_VERSION_3_3\n\nstatic void _glewInfo_GL_VERSION_3_3 (void)\n{\n  glewPrintExt(\"GL_VERSION_3_3\", GLEW_VERSION_3_3, GLEW_VERSION_3_3, GLEW_VERSION_3_3);\n\n  glewInfoFunc(\"glVertexAttribDivisor\", glVertexAttribDivisor == NULL);\n}\n\n#endif /* GL_VERSION_3_3 */\n\n#ifdef GL_VERSION_4_0\n\nstatic void _glewInfo_GL_VERSION_4_0 (void)\n{\n  glewPrintExt(\"GL_VERSION_4_0\", GLEW_VERSION_4_0, GLEW_VERSION_4_0, GLEW_VERSION_4_0);\n\n  glewInfoFunc(\"glBlendEquationSeparatei\", glBlendEquationSeparatei == NULL);\n  glewInfoFunc(\"glBlendEquationi\", glBlendEquationi == NULL);\n  glewInfoFunc(\"glBlendFuncSeparatei\", glBlendFuncSeparatei == NULL);\n  glewInfoFunc(\"glBlendFunci\", glBlendFunci == NULL);\n  glewInfoFunc(\"glMinSampleShading\", glMinSampleShading == NULL);\n}\n\n#endif /* GL_VERSION_4_0 */\n\n#ifdef GL_VERSION_4_1\n\nstatic void _glewInfo_GL_VERSION_4_1 (void)\n{\n  glewPrintExt(\"GL_VERSION_4_1\", GLEW_VERSION_4_1, GLEW_VERSION_4_1, GLEW_VERSION_4_1);\n}\n\n#endif /* GL_VERSION_4_1 */\n\n#ifdef GL_VERSION_4_2\n\nstatic void _glewInfo_GL_VERSION_4_2 (void)\n{\n  glewPrintExt(\"GL_VERSION_4_2\", GLEW_VERSION_4_2, GLEW_VERSION_4_2, GLEW_VERSION_4_2);\n}\n\n#endif /* GL_VERSION_4_2 */\n\n#ifdef GL_VERSION_4_3\n\nstatic void _glewInfo_GL_VERSION_4_3 (void)\n{\n  glewPrintExt(\"GL_VERSION_4_3\", GLEW_VERSION_4_3, GLEW_VERSION_4_3, GLEW_VERSION_4_3);\n}\n\n#endif /* GL_VERSION_4_3 */\n\n#ifdef GL_3DFX_multisample\n\nstatic void _glewInfo_GL_3DFX_multisample (void)\n{\n  glewPrintExt(\"GL_3DFX_multisample\", GLEW_3DFX_multisample, glewIsSupported(\"GL_3DFX_multisample\"), glewGetExtension(\"GL_3DFX_multisample\"));\n}\n\n#endif /* GL_3DFX_multisample */\n\n#ifdef GL_3DFX_tbuffer\n\nstatic void _glewInfo_GL_3DFX_tbuffer (void)\n{\n  glewPrintExt(\"GL_3DFX_tbuffer\", GLEW_3DFX_tbuffer, glewIsSupported(\"GL_3DFX_tbuffer\"), glewGetExtension(\"GL_3DFX_tbuffer\"));\n\n  glewInfoFunc(\"glTbufferMask3DFX\", glTbufferMask3DFX == NULL);\n}\n\n#endif /* GL_3DFX_tbuffer */\n\n#ifdef GL_3DFX_texture_compression_FXT1\n\nstatic void _glewInfo_GL_3DFX_texture_compression_FXT1 (void)\n{\n  glewPrintExt(\"GL_3DFX_texture_compression_FXT1\", GLEW_3DFX_texture_compression_FXT1, glewIsSupported(\"GL_3DFX_texture_compression_FXT1\"), glewGetExtension(\"GL_3DFX_texture_compression_FXT1\"));\n}\n\n#endif /* GL_3DFX_texture_compression_FXT1 */\n\n#ifdef GL_AMD_blend_minmax_factor\n\nstatic void _glewInfo_GL_AMD_blend_minmax_factor (void)\n{\n  glewPrintExt(\"GL_AMD_blend_minmax_factor\", GLEW_AMD_blend_minmax_factor, glewIsSupported(\"GL_AMD_blend_minmax_factor\"), glewGetExtension(\"GL_AMD_blend_minmax_factor\"));\n}\n\n#endif /* GL_AMD_blend_minmax_factor */\n\n#ifdef GL_AMD_conservative_depth\n\nstatic void _glewInfo_GL_AMD_conservative_depth (void)\n{\n  glewPrintExt(\"GL_AMD_conservative_depth\", GLEW_AMD_conservative_depth, glewIsSupported(\"GL_AMD_conservative_depth\"), glewGetExtension(\"GL_AMD_conservative_depth\"));\n}\n\n#endif /* GL_AMD_conservative_depth */\n\n#ifdef GL_AMD_debug_output\n\nstatic void _glewInfo_GL_AMD_debug_output (void)\n{\n  glewPrintExt(\"GL_AMD_debug_output\", GLEW_AMD_debug_output, glewIsSupported(\"GL_AMD_debug_output\"), glewGetExtension(\"GL_AMD_debug_output\"));\n\n  glewInfoFunc(\"glDebugMessageCallbackAMD\", glDebugMessageCallbackAMD == NULL);\n  glewInfoFunc(\"glDebugMessageEnableAMD\", glDebugMessageEnableAMD == NULL);\n  glewInfoFunc(\"glDebugMessageInsertAMD\", glDebugMessageInsertAMD == NULL);\n  glewInfoFunc(\"glGetDebugMessageLogAMD\", glGetDebugMessageLogAMD == NULL);\n}\n\n#endif /* GL_AMD_debug_output */\n\n#ifdef GL_AMD_depth_clamp_separate\n\nstatic void _glewInfo_GL_AMD_depth_clamp_separate (void)\n{\n  glewPrintExt(\"GL_AMD_depth_clamp_separate\", GLEW_AMD_depth_clamp_separate, glewIsSupported(\"GL_AMD_depth_clamp_separate\"), glewGetExtension(\"GL_AMD_depth_clamp_separate\"));\n}\n\n#endif /* GL_AMD_depth_clamp_separate */\n\n#ifdef GL_AMD_draw_buffers_blend\n\nstatic void _glewInfo_GL_AMD_draw_buffers_blend (void)\n{\n  glewPrintExt(\"GL_AMD_draw_buffers_blend\", GLEW_AMD_draw_buffers_blend, glewIsSupported(\"GL_AMD_draw_buffers_blend\"), glewGetExtension(\"GL_AMD_draw_buffers_blend\"));\n\n  glewInfoFunc(\"glBlendEquationIndexedAMD\", glBlendEquationIndexedAMD == NULL);\n  glewInfoFunc(\"glBlendEquationSeparateIndexedAMD\", glBlendEquationSeparateIndexedAMD == NULL);\n  glewInfoFunc(\"glBlendFuncIndexedAMD\", glBlendFuncIndexedAMD == NULL);\n  glewInfoFunc(\"glBlendFuncSeparateIndexedAMD\", glBlendFuncSeparateIndexedAMD == NULL);\n}\n\n#endif /* GL_AMD_draw_buffers_blend */\n\n#ifdef GL_AMD_multi_draw_indirect\n\nstatic void _glewInfo_GL_AMD_multi_draw_indirect (void)\n{\n  glewPrintExt(\"GL_AMD_multi_draw_indirect\", GLEW_AMD_multi_draw_indirect, glewIsSupported(\"GL_AMD_multi_draw_indirect\"), glewGetExtension(\"GL_AMD_multi_draw_indirect\"));\n\n  glewInfoFunc(\"glMultiDrawArraysIndirectAMD\", glMultiDrawArraysIndirectAMD == NULL);\n  glewInfoFunc(\"glMultiDrawElementsIndirectAMD\", glMultiDrawElementsIndirectAMD == NULL);\n}\n\n#endif /* GL_AMD_multi_draw_indirect */\n\n#ifdef GL_AMD_name_gen_delete\n\nstatic void _glewInfo_GL_AMD_name_gen_delete (void)\n{\n  glewPrintExt(\"GL_AMD_name_gen_delete\", GLEW_AMD_name_gen_delete, glewIsSupported(\"GL_AMD_name_gen_delete\"), glewGetExtension(\"GL_AMD_name_gen_delete\"));\n\n  glewInfoFunc(\"glDeleteNamesAMD\", glDeleteNamesAMD == NULL);\n  glewInfoFunc(\"glGenNamesAMD\", glGenNamesAMD == NULL);\n  glewInfoFunc(\"glIsNameAMD\", glIsNameAMD == NULL);\n}\n\n#endif /* GL_AMD_name_gen_delete */\n\n#ifdef GL_AMD_performance_monitor\n\nstatic void _glewInfo_GL_AMD_performance_monitor (void)\n{\n  glewPrintExt(\"GL_AMD_performance_monitor\", GLEW_AMD_performance_monitor, glewIsSupported(\"GL_AMD_performance_monitor\"), glewGetExtension(\"GL_AMD_performance_monitor\"));\n\n  glewInfoFunc(\"glBeginPerfMonitorAMD\", glBeginPerfMonitorAMD == NULL);\n  glewInfoFunc(\"glDeletePerfMonitorsAMD\", glDeletePerfMonitorsAMD == NULL);\n  glewInfoFunc(\"glEndPerfMonitorAMD\", glEndPerfMonitorAMD == NULL);\n  glewInfoFunc(\"glGenPerfMonitorsAMD\", glGenPerfMonitorsAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorCounterDataAMD\", glGetPerfMonitorCounterDataAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorCounterInfoAMD\", glGetPerfMonitorCounterInfoAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorCounterStringAMD\", glGetPerfMonitorCounterStringAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorCountersAMD\", glGetPerfMonitorCountersAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorGroupStringAMD\", glGetPerfMonitorGroupStringAMD == NULL);\n  glewInfoFunc(\"glGetPerfMonitorGroupsAMD\", glGetPerfMonitorGroupsAMD == NULL);\n  glewInfoFunc(\"glSelectPerfMonitorCountersAMD\", glSelectPerfMonitorCountersAMD == NULL);\n}\n\n#endif /* GL_AMD_performance_monitor */\n\n#ifdef GL_AMD_pinned_memory\n\nstatic void _glewInfo_GL_AMD_pinned_memory (void)\n{\n  glewPrintExt(\"GL_AMD_pinned_memory\", GLEW_AMD_pinned_memory, glewIsSupported(\"GL_AMD_pinned_memory\"), glewGetExtension(\"GL_AMD_pinned_memory\"));\n}\n\n#endif /* GL_AMD_pinned_memory */\n\n#ifdef GL_AMD_query_buffer_object\n\nstatic void _glewInfo_GL_AMD_query_buffer_object (void)\n{\n  glewPrintExt(\"GL_AMD_query_buffer_object\", GLEW_AMD_query_buffer_object, glewIsSupported(\"GL_AMD_query_buffer_object\"), glewGetExtension(\"GL_AMD_query_buffer_object\"));\n}\n\n#endif /* GL_AMD_query_buffer_object */\n\n#ifdef GL_AMD_sample_positions\n\nstatic void _glewInfo_GL_AMD_sample_positions (void)\n{\n  glewPrintExt(\"GL_AMD_sample_positions\", GLEW_AMD_sample_positions, glewIsSupported(\"GL_AMD_sample_positions\"), glewGetExtension(\"GL_AMD_sample_positions\"));\n\n  glewInfoFunc(\"glSetMultisamplefvAMD\", glSetMultisamplefvAMD == NULL);\n}\n\n#endif /* GL_AMD_sample_positions */\n\n#ifdef GL_AMD_seamless_cubemap_per_texture\n\nstatic void _glewInfo_GL_AMD_seamless_cubemap_per_texture (void)\n{\n  glewPrintExt(\"GL_AMD_seamless_cubemap_per_texture\", GLEW_AMD_seamless_cubemap_per_texture, glewIsSupported(\"GL_AMD_seamless_cubemap_per_texture\"), glewGetExtension(\"GL_AMD_seamless_cubemap_per_texture\"));\n}\n\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n\n#ifdef GL_AMD_shader_stencil_export\n\nstatic void _glewInfo_GL_AMD_shader_stencil_export (void)\n{\n  glewPrintExt(\"GL_AMD_shader_stencil_export\", GLEW_AMD_shader_stencil_export, glewIsSupported(\"GL_AMD_shader_stencil_export\"), glewGetExtension(\"GL_AMD_shader_stencil_export\"));\n}\n\n#endif /* GL_AMD_shader_stencil_export */\n\n#ifdef GL_AMD_stencil_operation_extended\n\nstatic void _glewInfo_GL_AMD_stencil_operation_extended (void)\n{\n  glewPrintExt(\"GL_AMD_stencil_operation_extended\", GLEW_AMD_stencil_operation_extended, glewIsSupported(\"GL_AMD_stencil_operation_extended\"), glewGetExtension(\"GL_AMD_stencil_operation_extended\"));\n\n  glewInfoFunc(\"glStencilOpValueAMD\", glStencilOpValueAMD == NULL);\n}\n\n#endif /* GL_AMD_stencil_operation_extended */\n\n#ifdef GL_AMD_texture_texture4\n\nstatic void _glewInfo_GL_AMD_texture_texture4 (void)\n{\n  glewPrintExt(\"GL_AMD_texture_texture4\", GLEW_AMD_texture_texture4, glewIsSupported(\"GL_AMD_texture_texture4\"), glewGetExtension(\"GL_AMD_texture_texture4\"));\n}\n\n#endif /* GL_AMD_texture_texture4 */\n\n#ifdef GL_AMD_transform_feedback3_lines_triangles\n\nstatic void _glewInfo_GL_AMD_transform_feedback3_lines_triangles (void)\n{\n  glewPrintExt(\"GL_AMD_transform_feedback3_lines_triangles\", GLEW_AMD_transform_feedback3_lines_triangles, glewIsSupported(\"GL_AMD_transform_feedback3_lines_triangles\"), glewGetExtension(\"GL_AMD_transform_feedback3_lines_triangles\"));\n}\n\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n\n#ifdef GL_AMD_vertex_shader_layer\n\nstatic void _glewInfo_GL_AMD_vertex_shader_layer (void)\n{\n  glewPrintExt(\"GL_AMD_vertex_shader_layer\", GLEW_AMD_vertex_shader_layer, glewIsSupported(\"GL_AMD_vertex_shader_layer\"), glewGetExtension(\"GL_AMD_vertex_shader_layer\"));\n}\n\n#endif /* GL_AMD_vertex_shader_layer */\n\n#ifdef GL_AMD_vertex_shader_tessellator\n\nstatic void _glewInfo_GL_AMD_vertex_shader_tessellator (void)\n{\n  glewPrintExt(\"GL_AMD_vertex_shader_tessellator\", GLEW_AMD_vertex_shader_tessellator, glewIsSupported(\"GL_AMD_vertex_shader_tessellator\"), glewGetExtension(\"GL_AMD_vertex_shader_tessellator\"));\n\n  glewInfoFunc(\"glTessellationFactorAMD\", glTessellationFactorAMD == NULL);\n  glewInfoFunc(\"glTessellationModeAMD\", glTessellationModeAMD == NULL);\n}\n\n#endif /* GL_AMD_vertex_shader_tessellator */\n\n#ifdef GL_AMD_vertex_shader_viewport_index\n\nstatic void _glewInfo_GL_AMD_vertex_shader_viewport_index (void)\n{\n  glewPrintExt(\"GL_AMD_vertex_shader_viewport_index\", GLEW_AMD_vertex_shader_viewport_index, glewIsSupported(\"GL_AMD_vertex_shader_viewport_index\"), glewGetExtension(\"GL_AMD_vertex_shader_viewport_index\"));\n}\n\n#endif /* GL_AMD_vertex_shader_viewport_index */\n\n#ifdef GL_APPLE_aux_depth_stencil\n\nstatic void _glewInfo_GL_APPLE_aux_depth_stencil (void)\n{\n  glewPrintExt(\"GL_APPLE_aux_depth_stencil\", GLEW_APPLE_aux_depth_stencil, glewIsSupported(\"GL_APPLE_aux_depth_stencil\"), glewGetExtension(\"GL_APPLE_aux_depth_stencil\"));\n}\n\n#endif /* GL_APPLE_aux_depth_stencil */\n\n#ifdef GL_APPLE_client_storage\n\nstatic void _glewInfo_GL_APPLE_client_storage (void)\n{\n  glewPrintExt(\"GL_APPLE_client_storage\", GLEW_APPLE_client_storage, glewIsSupported(\"GL_APPLE_client_storage\"), glewGetExtension(\"GL_APPLE_client_storage\"));\n}\n\n#endif /* GL_APPLE_client_storage */\n\n#ifdef GL_APPLE_element_array\n\nstatic void _glewInfo_GL_APPLE_element_array (void)\n{\n  glewPrintExt(\"GL_APPLE_element_array\", GLEW_APPLE_element_array, glewIsSupported(\"GL_APPLE_element_array\"), glewGetExtension(\"GL_APPLE_element_array\"));\n\n  glewInfoFunc(\"glDrawElementArrayAPPLE\", glDrawElementArrayAPPLE == NULL);\n  glewInfoFunc(\"glDrawRangeElementArrayAPPLE\", glDrawRangeElementArrayAPPLE == NULL);\n  glewInfoFunc(\"glElementPointerAPPLE\", glElementPointerAPPLE == NULL);\n  glewInfoFunc(\"glMultiDrawElementArrayAPPLE\", glMultiDrawElementArrayAPPLE == NULL);\n  glewInfoFunc(\"glMultiDrawRangeElementArrayAPPLE\", glMultiDrawRangeElementArrayAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_element_array */\n\n#ifdef GL_APPLE_fence\n\nstatic void _glewInfo_GL_APPLE_fence (void)\n{\n  glewPrintExt(\"GL_APPLE_fence\", GLEW_APPLE_fence, glewIsSupported(\"GL_APPLE_fence\"), glewGetExtension(\"GL_APPLE_fence\"));\n\n  glewInfoFunc(\"glDeleteFencesAPPLE\", glDeleteFencesAPPLE == NULL);\n  glewInfoFunc(\"glFinishFenceAPPLE\", glFinishFenceAPPLE == NULL);\n  glewInfoFunc(\"glFinishObjectAPPLE\", glFinishObjectAPPLE == NULL);\n  glewInfoFunc(\"glGenFencesAPPLE\", glGenFencesAPPLE == NULL);\n  glewInfoFunc(\"glIsFenceAPPLE\", glIsFenceAPPLE == NULL);\n  glewInfoFunc(\"glSetFenceAPPLE\", glSetFenceAPPLE == NULL);\n  glewInfoFunc(\"glTestFenceAPPLE\", glTestFenceAPPLE == NULL);\n  glewInfoFunc(\"glTestObjectAPPLE\", glTestObjectAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_fence */\n\n#ifdef GL_APPLE_float_pixels\n\nstatic void _glewInfo_GL_APPLE_float_pixels (void)\n{\n  glewPrintExt(\"GL_APPLE_float_pixels\", GLEW_APPLE_float_pixels, glewIsSupported(\"GL_APPLE_float_pixels\"), glewGetExtension(\"GL_APPLE_float_pixels\"));\n}\n\n#endif /* GL_APPLE_float_pixels */\n\n#ifdef GL_APPLE_flush_buffer_range\n\nstatic void _glewInfo_GL_APPLE_flush_buffer_range (void)\n{\n  glewPrintExt(\"GL_APPLE_flush_buffer_range\", GLEW_APPLE_flush_buffer_range, glewIsSupported(\"GL_APPLE_flush_buffer_range\"), glewGetExtension(\"GL_APPLE_flush_buffer_range\"));\n\n  glewInfoFunc(\"glBufferParameteriAPPLE\", glBufferParameteriAPPLE == NULL);\n  glewInfoFunc(\"glFlushMappedBufferRangeAPPLE\", glFlushMappedBufferRangeAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_flush_buffer_range */\n\n#ifdef GL_APPLE_object_purgeable\n\nstatic void _glewInfo_GL_APPLE_object_purgeable (void)\n{\n  glewPrintExt(\"GL_APPLE_object_purgeable\", GLEW_APPLE_object_purgeable, glewIsSupported(\"GL_APPLE_object_purgeable\"), glewGetExtension(\"GL_APPLE_object_purgeable\"));\n\n  glewInfoFunc(\"glGetObjectParameterivAPPLE\", glGetObjectParameterivAPPLE == NULL);\n  glewInfoFunc(\"glObjectPurgeableAPPLE\", glObjectPurgeableAPPLE == NULL);\n  glewInfoFunc(\"glObjectUnpurgeableAPPLE\", glObjectUnpurgeableAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_object_purgeable */\n\n#ifdef GL_APPLE_pixel_buffer\n\nstatic void _glewInfo_GL_APPLE_pixel_buffer (void)\n{\n  glewPrintExt(\"GL_APPLE_pixel_buffer\", GLEW_APPLE_pixel_buffer, glewIsSupported(\"GL_APPLE_pixel_buffer\"), glewGetExtension(\"GL_APPLE_pixel_buffer\"));\n}\n\n#endif /* GL_APPLE_pixel_buffer */\n\n#ifdef GL_APPLE_rgb_422\n\nstatic void _glewInfo_GL_APPLE_rgb_422 (void)\n{\n  glewPrintExt(\"GL_APPLE_rgb_422\", GLEW_APPLE_rgb_422, glewIsSupported(\"GL_APPLE_rgb_422\"), glewGetExtension(\"GL_APPLE_rgb_422\"));\n}\n\n#endif /* GL_APPLE_rgb_422 */\n\n#ifdef GL_APPLE_row_bytes\n\nstatic void _glewInfo_GL_APPLE_row_bytes (void)\n{\n  glewPrintExt(\"GL_APPLE_row_bytes\", GLEW_APPLE_row_bytes, glewIsSupported(\"GL_APPLE_row_bytes\"), glewGetExtension(\"GL_APPLE_row_bytes\"));\n}\n\n#endif /* GL_APPLE_row_bytes */\n\n#ifdef GL_APPLE_specular_vector\n\nstatic void _glewInfo_GL_APPLE_specular_vector (void)\n{\n  glewPrintExt(\"GL_APPLE_specular_vector\", GLEW_APPLE_specular_vector, glewIsSupported(\"GL_APPLE_specular_vector\"), glewGetExtension(\"GL_APPLE_specular_vector\"));\n}\n\n#endif /* GL_APPLE_specular_vector */\n\n#ifdef GL_APPLE_texture_range\n\nstatic void _glewInfo_GL_APPLE_texture_range (void)\n{\n  glewPrintExt(\"GL_APPLE_texture_range\", GLEW_APPLE_texture_range, glewIsSupported(\"GL_APPLE_texture_range\"), glewGetExtension(\"GL_APPLE_texture_range\"));\n\n  glewInfoFunc(\"glGetTexParameterPointervAPPLE\", glGetTexParameterPointervAPPLE == NULL);\n  glewInfoFunc(\"glTextureRangeAPPLE\", glTextureRangeAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_texture_range */\n\n#ifdef GL_APPLE_transform_hint\n\nstatic void _glewInfo_GL_APPLE_transform_hint (void)\n{\n  glewPrintExt(\"GL_APPLE_transform_hint\", GLEW_APPLE_transform_hint, glewIsSupported(\"GL_APPLE_transform_hint\"), glewGetExtension(\"GL_APPLE_transform_hint\"));\n}\n\n#endif /* GL_APPLE_transform_hint */\n\n#ifdef GL_APPLE_vertex_array_object\n\nstatic void _glewInfo_GL_APPLE_vertex_array_object (void)\n{\n  glewPrintExt(\"GL_APPLE_vertex_array_object\", GLEW_APPLE_vertex_array_object, glewIsSupported(\"GL_APPLE_vertex_array_object\"), glewGetExtension(\"GL_APPLE_vertex_array_object\"));\n\n  glewInfoFunc(\"glBindVertexArrayAPPLE\", glBindVertexArrayAPPLE == NULL);\n  glewInfoFunc(\"glDeleteVertexArraysAPPLE\", glDeleteVertexArraysAPPLE == NULL);\n  glewInfoFunc(\"glGenVertexArraysAPPLE\", glGenVertexArraysAPPLE == NULL);\n  glewInfoFunc(\"glIsVertexArrayAPPLE\", glIsVertexArrayAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_vertex_array_object */\n\n#ifdef GL_APPLE_vertex_array_range\n\nstatic void _glewInfo_GL_APPLE_vertex_array_range (void)\n{\n  glewPrintExt(\"GL_APPLE_vertex_array_range\", GLEW_APPLE_vertex_array_range, glewIsSupported(\"GL_APPLE_vertex_array_range\"), glewGetExtension(\"GL_APPLE_vertex_array_range\"));\n\n  glewInfoFunc(\"glFlushVertexArrayRangeAPPLE\", glFlushVertexArrayRangeAPPLE == NULL);\n  glewInfoFunc(\"glVertexArrayParameteriAPPLE\", glVertexArrayParameteriAPPLE == NULL);\n  glewInfoFunc(\"glVertexArrayRangeAPPLE\", glVertexArrayRangeAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_vertex_array_range */\n\n#ifdef GL_APPLE_vertex_program_evaluators\n\nstatic void _glewInfo_GL_APPLE_vertex_program_evaluators (void)\n{\n  glewPrintExt(\"GL_APPLE_vertex_program_evaluators\", GLEW_APPLE_vertex_program_evaluators, glewIsSupported(\"GL_APPLE_vertex_program_evaluators\"), glewGetExtension(\"GL_APPLE_vertex_program_evaluators\"));\n\n  glewInfoFunc(\"glDisableVertexAttribAPPLE\", glDisableVertexAttribAPPLE == NULL);\n  glewInfoFunc(\"glEnableVertexAttribAPPLE\", glEnableVertexAttribAPPLE == NULL);\n  glewInfoFunc(\"glIsVertexAttribEnabledAPPLE\", glIsVertexAttribEnabledAPPLE == NULL);\n  glewInfoFunc(\"glMapVertexAttrib1dAPPLE\", glMapVertexAttrib1dAPPLE == NULL);\n  glewInfoFunc(\"glMapVertexAttrib1fAPPLE\", glMapVertexAttrib1fAPPLE == NULL);\n  glewInfoFunc(\"glMapVertexAttrib2dAPPLE\", glMapVertexAttrib2dAPPLE == NULL);\n  glewInfoFunc(\"glMapVertexAttrib2fAPPLE\", glMapVertexAttrib2fAPPLE == NULL);\n}\n\n#endif /* GL_APPLE_vertex_program_evaluators */\n\n#ifdef GL_APPLE_ycbcr_422\n\nstatic void _glewInfo_GL_APPLE_ycbcr_422 (void)\n{\n  glewPrintExt(\"GL_APPLE_ycbcr_422\", GLEW_APPLE_ycbcr_422, glewIsSupported(\"GL_APPLE_ycbcr_422\"), glewGetExtension(\"GL_APPLE_ycbcr_422\"));\n}\n\n#endif /* GL_APPLE_ycbcr_422 */\n\n#ifdef GL_ARB_ES2_compatibility\n\nstatic void _glewInfo_GL_ARB_ES2_compatibility (void)\n{\n  glewPrintExt(\"GL_ARB_ES2_compatibility\", GLEW_ARB_ES2_compatibility, glewIsSupported(\"GL_ARB_ES2_compatibility\"), glewGetExtension(\"GL_ARB_ES2_compatibility\"));\n\n  glewInfoFunc(\"glClearDepthf\", glClearDepthf == NULL);\n  glewInfoFunc(\"glDepthRangef\", glDepthRangef == NULL);\n  glewInfoFunc(\"glGetShaderPrecisionFormat\", glGetShaderPrecisionFormat == NULL);\n  glewInfoFunc(\"glReleaseShaderCompiler\", glReleaseShaderCompiler == NULL);\n  glewInfoFunc(\"glShaderBinary\", glShaderBinary == NULL);\n}\n\n#endif /* GL_ARB_ES2_compatibility */\n\n#ifdef GL_ARB_ES3_compatibility\n\nstatic void _glewInfo_GL_ARB_ES3_compatibility (void)\n{\n  glewPrintExt(\"GL_ARB_ES3_compatibility\", GLEW_ARB_ES3_compatibility, glewIsSupported(\"GL_ARB_ES3_compatibility\"), glewGetExtension(\"GL_ARB_ES3_compatibility\"));\n}\n\n#endif /* GL_ARB_ES3_compatibility */\n\n#ifdef GL_ARB_arrays_of_arrays\n\nstatic void _glewInfo_GL_ARB_arrays_of_arrays (void)\n{\n  glewPrintExt(\"GL_ARB_arrays_of_arrays\", GLEW_ARB_arrays_of_arrays, glewIsSupported(\"GL_ARB_arrays_of_arrays\"), glewGetExtension(\"GL_ARB_arrays_of_arrays\"));\n}\n\n#endif /* GL_ARB_arrays_of_arrays */\n\n#ifdef GL_ARB_base_instance\n\nstatic void _glewInfo_GL_ARB_base_instance (void)\n{\n  glewPrintExt(\"GL_ARB_base_instance\", GLEW_ARB_base_instance, glewIsSupported(\"GL_ARB_base_instance\"), glewGetExtension(\"GL_ARB_base_instance\"));\n\n  glewInfoFunc(\"glDrawArraysInstancedBaseInstance\", glDrawArraysInstancedBaseInstance == NULL);\n  glewInfoFunc(\"glDrawElementsInstancedBaseInstance\", glDrawElementsInstancedBaseInstance == NULL);\n  glewInfoFunc(\"glDrawElementsInstancedBaseVertexBaseInstance\", glDrawElementsInstancedBaseVertexBaseInstance == NULL);\n}\n\n#endif /* GL_ARB_base_instance */\n\n#ifdef GL_ARB_blend_func_extended\n\nstatic void _glewInfo_GL_ARB_blend_func_extended (void)\n{\n  glewPrintExt(\"GL_ARB_blend_func_extended\", GLEW_ARB_blend_func_extended, glewIsSupported(\"GL_ARB_blend_func_extended\"), glewGetExtension(\"GL_ARB_blend_func_extended\"));\n\n  glewInfoFunc(\"glBindFragDataLocationIndexed\", glBindFragDataLocationIndexed == NULL);\n  glewInfoFunc(\"glGetFragDataIndex\", glGetFragDataIndex == NULL);\n}\n\n#endif /* GL_ARB_blend_func_extended */\n\n#ifdef GL_ARB_cl_event\n\nstatic void _glewInfo_GL_ARB_cl_event (void)\n{\n  glewPrintExt(\"GL_ARB_cl_event\", GLEW_ARB_cl_event, glewIsSupported(\"GL_ARB_cl_event\"), glewGetExtension(\"GL_ARB_cl_event\"));\n\n  glewInfoFunc(\"glCreateSyncFromCLeventARB\", glCreateSyncFromCLeventARB == NULL);\n}\n\n#endif /* GL_ARB_cl_event */\n\n#ifdef GL_ARB_clear_buffer_object\n\nstatic void _glewInfo_GL_ARB_clear_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_clear_buffer_object\", GLEW_ARB_clear_buffer_object, glewIsSupported(\"GL_ARB_clear_buffer_object\"), glewGetExtension(\"GL_ARB_clear_buffer_object\"));\n\n  glewInfoFunc(\"glClearBufferData\", glClearBufferData == NULL);\n  glewInfoFunc(\"glClearBufferSubData\", glClearBufferSubData == NULL);\n  glewInfoFunc(\"glClearNamedBufferDataEXT\", glClearNamedBufferDataEXT == NULL);\n  glewInfoFunc(\"glClearNamedBufferSubDataEXT\", glClearNamedBufferSubDataEXT == NULL);\n}\n\n#endif /* GL_ARB_clear_buffer_object */\n\n#ifdef GL_ARB_color_buffer_float\n\nstatic void _glewInfo_GL_ARB_color_buffer_float (void)\n{\n  glewPrintExt(\"GL_ARB_color_buffer_float\", GLEW_ARB_color_buffer_float, glewIsSupported(\"GL_ARB_color_buffer_float\"), glewGetExtension(\"GL_ARB_color_buffer_float\"));\n\n  glewInfoFunc(\"glClampColorARB\", glClampColorARB == NULL);\n}\n\n#endif /* GL_ARB_color_buffer_float */\n\n#ifdef GL_ARB_compatibility\n\nstatic void _glewInfo_GL_ARB_compatibility (void)\n{\n  glewPrintExt(\"GL_ARB_compatibility\", GLEW_ARB_compatibility, glewIsSupported(\"GL_ARB_compatibility\"), glewGetExtension(\"GL_ARB_compatibility\"));\n}\n\n#endif /* GL_ARB_compatibility */\n\n#ifdef GL_ARB_compressed_texture_pixel_storage\n\nstatic void _glewInfo_GL_ARB_compressed_texture_pixel_storage (void)\n{\n  glewPrintExt(\"GL_ARB_compressed_texture_pixel_storage\", GLEW_ARB_compressed_texture_pixel_storage, glewIsSupported(\"GL_ARB_compressed_texture_pixel_storage\"), glewGetExtension(\"GL_ARB_compressed_texture_pixel_storage\"));\n}\n\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n\n#ifdef GL_ARB_compute_shader\n\nstatic void _glewInfo_GL_ARB_compute_shader (void)\n{\n  glewPrintExt(\"GL_ARB_compute_shader\", GLEW_ARB_compute_shader, glewIsSupported(\"GL_ARB_compute_shader\"), glewGetExtension(\"GL_ARB_compute_shader\"));\n\n  glewInfoFunc(\"glDispatchCompute\", glDispatchCompute == NULL);\n  glewInfoFunc(\"glDispatchComputeIndirect\", glDispatchComputeIndirect == NULL);\n}\n\n#endif /* GL_ARB_compute_shader */\n\n#ifdef GL_ARB_conservative_depth\n\nstatic void _glewInfo_GL_ARB_conservative_depth (void)\n{\n  glewPrintExt(\"GL_ARB_conservative_depth\", GLEW_ARB_conservative_depth, glewIsSupported(\"GL_ARB_conservative_depth\"), glewGetExtension(\"GL_ARB_conservative_depth\"));\n}\n\n#endif /* GL_ARB_conservative_depth */\n\n#ifdef GL_ARB_copy_buffer\n\nstatic void _glewInfo_GL_ARB_copy_buffer (void)\n{\n  glewPrintExt(\"GL_ARB_copy_buffer\", GLEW_ARB_copy_buffer, glewIsSupported(\"GL_ARB_copy_buffer\"), glewGetExtension(\"GL_ARB_copy_buffer\"));\n\n  glewInfoFunc(\"glCopyBufferSubData\", glCopyBufferSubData == NULL);\n}\n\n#endif /* GL_ARB_copy_buffer */\n\n#ifdef GL_ARB_copy_image\n\nstatic void _glewInfo_GL_ARB_copy_image (void)\n{\n  glewPrintExt(\"GL_ARB_copy_image\", GLEW_ARB_copy_image, glewIsSupported(\"GL_ARB_copy_image\"), glewGetExtension(\"GL_ARB_copy_image\"));\n\n  glewInfoFunc(\"glCopyImageSubData\", glCopyImageSubData == NULL);\n}\n\n#endif /* GL_ARB_copy_image */\n\n#ifdef GL_ARB_debug_output\n\nstatic void _glewInfo_GL_ARB_debug_output (void)\n{\n  glewPrintExt(\"GL_ARB_debug_output\", GLEW_ARB_debug_output, glewIsSupported(\"GL_ARB_debug_output\"), glewGetExtension(\"GL_ARB_debug_output\"));\n\n  glewInfoFunc(\"glDebugMessageCallbackARB\", glDebugMessageCallbackARB == NULL);\n  glewInfoFunc(\"glDebugMessageControlARB\", glDebugMessageControlARB == NULL);\n  glewInfoFunc(\"glDebugMessageInsertARB\", glDebugMessageInsertARB == NULL);\n  glewInfoFunc(\"glGetDebugMessageLogARB\", glGetDebugMessageLogARB == NULL);\n}\n\n#endif /* GL_ARB_debug_output */\n\n#ifdef GL_ARB_depth_buffer_float\n\nstatic void _glewInfo_GL_ARB_depth_buffer_float (void)\n{\n  glewPrintExt(\"GL_ARB_depth_buffer_float\", GLEW_ARB_depth_buffer_float, glewIsSupported(\"GL_ARB_depth_buffer_float\"), glewGetExtension(\"GL_ARB_depth_buffer_float\"));\n}\n\n#endif /* GL_ARB_depth_buffer_float */\n\n#ifdef GL_ARB_depth_clamp\n\nstatic void _glewInfo_GL_ARB_depth_clamp (void)\n{\n  glewPrintExt(\"GL_ARB_depth_clamp\", GLEW_ARB_depth_clamp, glewIsSupported(\"GL_ARB_depth_clamp\"), glewGetExtension(\"GL_ARB_depth_clamp\"));\n}\n\n#endif /* GL_ARB_depth_clamp */\n\n#ifdef GL_ARB_depth_texture\n\nstatic void _glewInfo_GL_ARB_depth_texture (void)\n{\n  glewPrintExt(\"GL_ARB_depth_texture\", GLEW_ARB_depth_texture, glewIsSupported(\"GL_ARB_depth_texture\"), glewGetExtension(\"GL_ARB_depth_texture\"));\n}\n\n#endif /* GL_ARB_depth_texture */\n\n#ifdef GL_ARB_draw_buffers\n\nstatic void _glewInfo_GL_ARB_draw_buffers (void)\n{\n  glewPrintExt(\"GL_ARB_draw_buffers\", GLEW_ARB_draw_buffers, glewIsSupported(\"GL_ARB_draw_buffers\"), glewGetExtension(\"GL_ARB_draw_buffers\"));\n\n  glewInfoFunc(\"glDrawBuffersARB\", glDrawBuffersARB == NULL);\n}\n\n#endif /* GL_ARB_draw_buffers */\n\n#ifdef GL_ARB_draw_buffers_blend\n\nstatic void _glewInfo_GL_ARB_draw_buffers_blend (void)\n{\n  glewPrintExt(\"GL_ARB_draw_buffers_blend\", GLEW_ARB_draw_buffers_blend, glewIsSupported(\"GL_ARB_draw_buffers_blend\"), glewGetExtension(\"GL_ARB_draw_buffers_blend\"));\n\n  glewInfoFunc(\"glBlendEquationSeparateiARB\", glBlendEquationSeparateiARB == NULL);\n  glewInfoFunc(\"glBlendEquationiARB\", glBlendEquationiARB == NULL);\n  glewInfoFunc(\"glBlendFuncSeparateiARB\", glBlendFuncSeparateiARB == NULL);\n  glewInfoFunc(\"glBlendFunciARB\", glBlendFunciARB == NULL);\n}\n\n#endif /* GL_ARB_draw_buffers_blend */\n\n#ifdef GL_ARB_draw_elements_base_vertex\n\nstatic void _glewInfo_GL_ARB_draw_elements_base_vertex (void)\n{\n  glewPrintExt(\"GL_ARB_draw_elements_base_vertex\", GLEW_ARB_draw_elements_base_vertex, glewIsSupported(\"GL_ARB_draw_elements_base_vertex\"), glewGetExtension(\"GL_ARB_draw_elements_base_vertex\"));\n\n  glewInfoFunc(\"glDrawElementsBaseVertex\", glDrawElementsBaseVertex == NULL);\n  glewInfoFunc(\"glDrawElementsInstancedBaseVertex\", glDrawElementsInstancedBaseVertex == NULL);\n  glewInfoFunc(\"glDrawRangeElementsBaseVertex\", glDrawRangeElementsBaseVertex == NULL);\n  glewInfoFunc(\"glMultiDrawElementsBaseVertex\", glMultiDrawElementsBaseVertex == NULL);\n}\n\n#endif /* GL_ARB_draw_elements_base_vertex */\n\n#ifdef GL_ARB_draw_indirect\n\nstatic void _glewInfo_GL_ARB_draw_indirect (void)\n{\n  glewPrintExt(\"GL_ARB_draw_indirect\", GLEW_ARB_draw_indirect, glewIsSupported(\"GL_ARB_draw_indirect\"), glewGetExtension(\"GL_ARB_draw_indirect\"));\n\n  glewInfoFunc(\"glDrawArraysIndirect\", glDrawArraysIndirect == NULL);\n  glewInfoFunc(\"glDrawElementsIndirect\", glDrawElementsIndirect == NULL);\n}\n\n#endif /* GL_ARB_draw_indirect */\n\n#ifdef GL_ARB_draw_instanced\n\nstatic void _glewInfo_GL_ARB_draw_instanced (void)\n{\n  glewPrintExt(\"GL_ARB_draw_instanced\", GLEW_ARB_draw_instanced, glewIsSupported(\"GL_ARB_draw_instanced\"), glewGetExtension(\"GL_ARB_draw_instanced\"));\n}\n\n#endif /* GL_ARB_draw_instanced */\n\n#ifdef GL_ARB_explicit_attrib_location\n\nstatic void _glewInfo_GL_ARB_explicit_attrib_location (void)\n{\n  glewPrintExt(\"GL_ARB_explicit_attrib_location\", GLEW_ARB_explicit_attrib_location, glewIsSupported(\"GL_ARB_explicit_attrib_location\"), glewGetExtension(\"GL_ARB_explicit_attrib_location\"));\n}\n\n#endif /* GL_ARB_explicit_attrib_location */\n\n#ifdef GL_ARB_explicit_uniform_location\n\nstatic void _glewInfo_GL_ARB_explicit_uniform_location (void)\n{\n  glewPrintExt(\"GL_ARB_explicit_uniform_location\", GLEW_ARB_explicit_uniform_location, glewIsSupported(\"GL_ARB_explicit_uniform_location\"), glewGetExtension(\"GL_ARB_explicit_uniform_location\"));\n}\n\n#endif /* GL_ARB_explicit_uniform_location */\n\n#ifdef GL_ARB_fragment_coord_conventions\n\nstatic void _glewInfo_GL_ARB_fragment_coord_conventions (void)\n{\n  glewPrintExt(\"GL_ARB_fragment_coord_conventions\", GLEW_ARB_fragment_coord_conventions, glewIsSupported(\"GL_ARB_fragment_coord_conventions\"), glewGetExtension(\"GL_ARB_fragment_coord_conventions\"));\n}\n\n#endif /* GL_ARB_fragment_coord_conventions */\n\n#ifdef GL_ARB_fragment_layer_viewport\n\nstatic void _glewInfo_GL_ARB_fragment_layer_viewport (void)\n{\n  glewPrintExt(\"GL_ARB_fragment_layer_viewport\", GLEW_ARB_fragment_layer_viewport, glewIsSupported(\"GL_ARB_fragment_layer_viewport\"), glewGetExtension(\"GL_ARB_fragment_layer_viewport\"));\n}\n\n#endif /* GL_ARB_fragment_layer_viewport */\n\n#ifdef GL_ARB_fragment_program\n\nstatic void _glewInfo_GL_ARB_fragment_program (void)\n{\n  glewPrintExt(\"GL_ARB_fragment_program\", GLEW_ARB_fragment_program, glewIsSupported(\"GL_ARB_fragment_program\"), glewGetExtension(\"GL_ARB_fragment_program\"));\n}\n\n#endif /* GL_ARB_fragment_program */\n\n#ifdef GL_ARB_fragment_program_shadow\n\nstatic void _glewInfo_GL_ARB_fragment_program_shadow (void)\n{\n  glewPrintExt(\"GL_ARB_fragment_program_shadow\", GLEW_ARB_fragment_program_shadow, glewIsSupported(\"GL_ARB_fragment_program_shadow\"), glewGetExtension(\"GL_ARB_fragment_program_shadow\"));\n}\n\n#endif /* GL_ARB_fragment_program_shadow */\n\n#ifdef GL_ARB_fragment_shader\n\nstatic void _glewInfo_GL_ARB_fragment_shader (void)\n{\n  glewPrintExt(\"GL_ARB_fragment_shader\", GLEW_ARB_fragment_shader, glewIsSupported(\"GL_ARB_fragment_shader\"), glewGetExtension(\"GL_ARB_fragment_shader\"));\n}\n\n#endif /* GL_ARB_fragment_shader */\n\n#ifdef GL_ARB_framebuffer_no_attachments\n\nstatic void _glewInfo_GL_ARB_framebuffer_no_attachments (void)\n{\n  glewPrintExt(\"GL_ARB_framebuffer_no_attachments\", GLEW_ARB_framebuffer_no_attachments, glewIsSupported(\"GL_ARB_framebuffer_no_attachments\"), glewGetExtension(\"GL_ARB_framebuffer_no_attachments\"));\n\n  glewInfoFunc(\"glFramebufferParameteri\", glFramebufferParameteri == NULL);\n  glewInfoFunc(\"glGetFramebufferParameteriv\", glGetFramebufferParameteriv == NULL);\n  glewInfoFunc(\"glGetNamedFramebufferParameterivEXT\", glGetNamedFramebufferParameterivEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferParameteriEXT\", glNamedFramebufferParameteriEXT == NULL);\n}\n\n#endif /* GL_ARB_framebuffer_no_attachments */\n\n#ifdef GL_ARB_framebuffer_object\n\nstatic void _glewInfo_GL_ARB_framebuffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_framebuffer_object\", GLEW_ARB_framebuffer_object, glewIsSupported(\"GL_ARB_framebuffer_object\"), glewGetExtension(\"GL_ARB_framebuffer_object\"));\n\n  glewInfoFunc(\"glBindFramebuffer\", glBindFramebuffer == NULL);\n  glewInfoFunc(\"glBindRenderbuffer\", glBindRenderbuffer == NULL);\n  glewInfoFunc(\"glBlitFramebuffer\", glBlitFramebuffer == NULL);\n  glewInfoFunc(\"glCheckFramebufferStatus\", glCheckFramebufferStatus == NULL);\n  glewInfoFunc(\"glDeleteFramebuffers\", glDeleteFramebuffers == NULL);\n  glewInfoFunc(\"glDeleteRenderbuffers\", glDeleteRenderbuffers == NULL);\n  glewInfoFunc(\"glFramebufferRenderbuffer\", glFramebufferRenderbuffer == NULL);\n  glewInfoFunc(\"glFramebufferTexture1D\", glFramebufferTexture1D == NULL);\n  glewInfoFunc(\"glFramebufferTexture2D\", glFramebufferTexture2D == NULL);\n  glewInfoFunc(\"glFramebufferTexture3D\", glFramebufferTexture3D == NULL);\n  glewInfoFunc(\"glFramebufferTextureLayer\", glFramebufferTextureLayer == NULL);\n  glewInfoFunc(\"glGenFramebuffers\", glGenFramebuffers == NULL);\n  glewInfoFunc(\"glGenRenderbuffers\", glGenRenderbuffers == NULL);\n  glewInfoFunc(\"glGenerateMipmap\", glGenerateMipmap == NULL);\n  glewInfoFunc(\"glGetFramebufferAttachmentParameteriv\", glGetFramebufferAttachmentParameteriv == NULL);\n  glewInfoFunc(\"glGetRenderbufferParameteriv\", glGetRenderbufferParameteriv == NULL);\n  glewInfoFunc(\"glIsFramebuffer\", glIsFramebuffer == NULL);\n  glewInfoFunc(\"glIsRenderbuffer\", glIsRenderbuffer == NULL);\n  glewInfoFunc(\"glRenderbufferStorage\", glRenderbufferStorage == NULL);\n  glewInfoFunc(\"glRenderbufferStorageMultisample\", glRenderbufferStorageMultisample == NULL);\n}\n\n#endif /* GL_ARB_framebuffer_object */\n\n#ifdef GL_ARB_framebuffer_sRGB\n\nstatic void _glewInfo_GL_ARB_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"GL_ARB_framebuffer_sRGB\", GLEW_ARB_framebuffer_sRGB, glewIsSupported(\"GL_ARB_framebuffer_sRGB\"), glewGetExtension(\"GL_ARB_framebuffer_sRGB\"));\n}\n\n#endif /* GL_ARB_framebuffer_sRGB */\n\n#ifdef GL_ARB_geometry_shader4\n\nstatic void _glewInfo_GL_ARB_geometry_shader4 (void)\n{\n  glewPrintExt(\"GL_ARB_geometry_shader4\", GLEW_ARB_geometry_shader4, glewIsSupported(\"GL_ARB_geometry_shader4\"), glewGetExtension(\"GL_ARB_geometry_shader4\"));\n\n  glewInfoFunc(\"glFramebufferTextureARB\", glFramebufferTextureARB == NULL);\n  glewInfoFunc(\"glFramebufferTextureFaceARB\", glFramebufferTextureFaceARB == NULL);\n  glewInfoFunc(\"glFramebufferTextureLayerARB\", glFramebufferTextureLayerARB == NULL);\n  glewInfoFunc(\"glProgramParameteriARB\", glProgramParameteriARB == NULL);\n}\n\n#endif /* GL_ARB_geometry_shader4 */\n\n#ifdef GL_ARB_get_program_binary\n\nstatic void _glewInfo_GL_ARB_get_program_binary (void)\n{\n  glewPrintExt(\"GL_ARB_get_program_binary\", GLEW_ARB_get_program_binary, glewIsSupported(\"GL_ARB_get_program_binary\"), glewGetExtension(\"GL_ARB_get_program_binary\"));\n\n  glewInfoFunc(\"glGetProgramBinary\", glGetProgramBinary == NULL);\n  glewInfoFunc(\"glProgramBinary\", glProgramBinary == NULL);\n  glewInfoFunc(\"glProgramParameteri\", glProgramParameteri == NULL);\n}\n\n#endif /* GL_ARB_get_program_binary */\n\n#ifdef GL_ARB_gpu_shader5\n\nstatic void _glewInfo_GL_ARB_gpu_shader5 (void)\n{\n  glewPrintExt(\"GL_ARB_gpu_shader5\", GLEW_ARB_gpu_shader5, glewIsSupported(\"GL_ARB_gpu_shader5\"), glewGetExtension(\"GL_ARB_gpu_shader5\"));\n}\n\n#endif /* GL_ARB_gpu_shader5 */\n\n#ifdef GL_ARB_gpu_shader_fp64\n\nstatic void _glewInfo_GL_ARB_gpu_shader_fp64 (void)\n{\n  glewPrintExt(\"GL_ARB_gpu_shader_fp64\", GLEW_ARB_gpu_shader_fp64, glewIsSupported(\"GL_ARB_gpu_shader_fp64\"), glewGetExtension(\"GL_ARB_gpu_shader_fp64\"));\n\n  glewInfoFunc(\"glGetUniformdv\", glGetUniformdv == NULL);\n  glewInfoFunc(\"glUniform1d\", glUniform1d == NULL);\n  glewInfoFunc(\"glUniform1dv\", glUniform1dv == NULL);\n  glewInfoFunc(\"glUniform2d\", glUniform2d == NULL);\n  glewInfoFunc(\"glUniform2dv\", glUniform2dv == NULL);\n  glewInfoFunc(\"glUniform3d\", glUniform3d == NULL);\n  glewInfoFunc(\"glUniform3dv\", glUniform3dv == NULL);\n  glewInfoFunc(\"glUniform4d\", glUniform4d == NULL);\n  glewInfoFunc(\"glUniform4dv\", glUniform4dv == NULL);\n  glewInfoFunc(\"glUniformMatrix2dv\", glUniformMatrix2dv == NULL);\n  glewInfoFunc(\"glUniformMatrix2x3dv\", glUniformMatrix2x3dv == NULL);\n  glewInfoFunc(\"glUniformMatrix2x4dv\", glUniformMatrix2x4dv == NULL);\n  glewInfoFunc(\"glUniformMatrix3dv\", glUniformMatrix3dv == NULL);\n  glewInfoFunc(\"glUniformMatrix3x2dv\", glUniformMatrix3x2dv == NULL);\n  glewInfoFunc(\"glUniformMatrix3x4dv\", glUniformMatrix3x4dv == NULL);\n  glewInfoFunc(\"glUniformMatrix4dv\", glUniformMatrix4dv == NULL);\n  glewInfoFunc(\"glUniformMatrix4x2dv\", glUniformMatrix4x2dv == NULL);\n  glewInfoFunc(\"glUniformMatrix4x3dv\", glUniformMatrix4x3dv == NULL);\n}\n\n#endif /* GL_ARB_gpu_shader_fp64 */\n\n#ifdef GL_ARB_half_float_pixel\n\nstatic void _glewInfo_GL_ARB_half_float_pixel (void)\n{\n  glewPrintExt(\"GL_ARB_half_float_pixel\", GLEW_ARB_half_float_pixel, glewIsSupported(\"GL_ARB_half_float_pixel\"), glewGetExtension(\"GL_ARB_half_float_pixel\"));\n}\n\n#endif /* GL_ARB_half_float_pixel */\n\n#ifdef GL_ARB_half_float_vertex\n\nstatic void _glewInfo_GL_ARB_half_float_vertex (void)\n{\n  glewPrintExt(\"GL_ARB_half_float_vertex\", GLEW_ARB_half_float_vertex, glewIsSupported(\"GL_ARB_half_float_vertex\"), glewGetExtension(\"GL_ARB_half_float_vertex\"));\n}\n\n#endif /* GL_ARB_half_float_vertex */\n\n#ifdef GL_ARB_imaging\n\nstatic void _glewInfo_GL_ARB_imaging (void)\n{\n  glewPrintExt(\"GL_ARB_imaging\", GLEW_ARB_imaging, glewIsSupported(\"GL_ARB_imaging\"), glewGetExtension(\"GL_ARB_imaging\"));\n\n  glewInfoFunc(\"glBlendEquation\", glBlendEquation == NULL);\n  glewInfoFunc(\"glColorSubTable\", glColorSubTable == NULL);\n  glewInfoFunc(\"glColorTable\", glColorTable == NULL);\n  glewInfoFunc(\"glColorTableParameterfv\", glColorTableParameterfv == NULL);\n  glewInfoFunc(\"glColorTableParameteriv\", glColorTableParameteriv == NULL);\n  glewInfoFunc(\"glConvolutionFilter1D\", glConvolutionFilter1D == NULL);\n  glewInfoFunc(\"glConvolutionFilter2D\", glConvolutionFilter2D == NULL);\n  glewInfoFunc(\"glConvolutionParameterf\", glConvolutionParameterf == NULL);\n  glewInfoFunc(\"glConvolutionParameterfv\", glConvolutionParameterfv == NULL);\n  glewInfoFunc(\"glConvolutionParameteri\", glConvolutionParameteri == NULL);\n  glewInfoFunc(\"glConvolutionParameteriv\", glConvolutionParameteriv == NULL);\n  glewInfoFunc(\"glCopyColorSubTable\", glCopyColorSubTable == NULL);\n  glewInfoFunc(\"glCopyColorTable\", glCopyColorTable == NULL);\n  glewInfoFunc(\"glCopyConvolutionFilter1D\", glCopyConvolutionFilter1D == NULL);\n  glewInfoFunc(\"glCopyConvolutionFilter2D\", glCopyConvolutionFilter2D == NULL);\n  glewInfoFunc(\"glGetColorTable\", glGetColorTable == NULL);\n  glewInfoFunc(\"glGetColorTableParameterfv\", glGetColorTableParameterfv == NULL);\n  glewInfoFunc(\"glGetColorTableParameteriv\", glGetColorTableParameteriv == NULL);\n  glewInfoFunc(\"glGetConvolutionFilter\", glGetConvolutionFilter == NULL);\n  glewInfoFunc(\"glGetConvolutionParameterfv\", glGetConvolutionParameterfv == NULL);\n  glewInfoFunc(\"glGetConvolutionParameteriv\", glGetConvolutionParameteriv == NULL);\n  glewInfoFunc(\"glGetHistogram\", glGetHistogram == NULL);\n  glewInfoFunc(\"glGetHistogramParameterfv\", glGetHistogramParameterfv == NULL);\n  glewInfoFunc(\"glGetHistogramParameteriv\", glGetHistogramParameteriv == NULL);\n  glewInfoFunc(\"glGetMinmax\", glGetMinmax == NULL);\n  glewInfoFunc(\"glGetMinmaxParameterfv\", glGetMinmaxParameterfv == NULL);\n  glewInfoFunc(\"glGetMinmaxParameteriv\", glGetMinmaxParameteriv == NULL);\n  glewInfoFunc(\"glGetSeparableFilter\", glGetSeparableFilter == NULL);\n  glewInfoFunc(\"glHistogram\", glHistogram == NULL);\n  glewInfoFunc(\"glMinmax\", glMinmax == NULL);\n  glewInfoFunc(\"glResetHistogram\", glResetHistogram == NULL);\n  glewInfoFunc(\"glResetMinmax\", glResetMinmax == NULL);\n  glewInfoFunc(\"glSeparableFilter2D\", glSeparableFilter2D == NULL);\n}\n\n#endif /* GL_ARB_imaging */\n\n#ifdef GL_ARB_instanced_arrays\n\nstatic void _glewInfo_GL_ARB_instanced_arrays (void)\n{\n  glewPrintExt(\"GL_ARB_instanced_arrays\", GLEW_ARB_instanced_arrays, glewIsSupported(\"GL_ARB_instanced_arrays\"), glewGetExtension(\"GL_ARB_instanced_arrays\"));\n\n  glewInfoFunc(\"glDrawArraysInstancedARB\", glDrawArraysInstancedARB == NULL);\n  glewInfoFunc(\"glDrawElementsInstancedARB\", glDrawElementsInstancedARB == NULL);\n  glewInfoFunc(\"glVertexAttribDivisorARB\", glVertexAttribDivisorARB == NULL);\n}\n\n#endif /* GL_ARB_instanced_arrays */\n\n#ifdef GL_ARB_internalformat_query\n\nstatic void _glewInfo_GL_ARB_internalformat_query (void)\n{\n  glewPrintExt(\"GL_ARB_internalformat_query\", GLEW_ARB_internalformat_query, glewIsSupported(\"GL_ARB_internalformat_query\"), glewGetExtension(\"GL_ARB_internalformat_query\"));\n\n  glewInfoFunc(\"glGetInternalformativ\", glGetInternalformativ == NULL);\n}\n\n#endif /* GL_ARB_internalformat_query */\n\n#ifdef GL_ARB_internalformat_query2\n\nstatic void _glewInfo_GL_ARB_internalformat_query2 (void)\n{\n  glewPrintExt(\"GL_ARB_internalformat_query2\", GLEW_ARB_internalformat_query2, glewIsSupported(\"GL_ARB_internalformat_query2\"), glewGetExtension(\"GL_ARB_internalformat_query2\"));\n\n  glewInfoFunc(\"glGetInternalformati64v\", glGetInternalformati64v == NULL);\n}\n\n#endif /* GL_ARB_internalformat_query2 */\n\n#ifdef GL_ARB_invalidate_subdata\n\nstatic void _glewInfo_GL_ARB_invalidate_subdata (void)\n{\n  glewPrintExt(\"GL_ARB_invalidate_subdata\", GLEW_ARB_invalidate_subdata, glewIsSupported(\"GL_ARB_invalidate_subdata\"), glewGetExtension(\"GL_ARB_invalidate_subdata\"));\n\n  glewInfoFunc(\"glInvalidateBufferData\", glInvalidateBufferData == NULL);\n  glewInfoFunc(\"glInvalidateBufferSubData\", glInvalidateBufferSubData == NULL);\n  glewInfoFunc(\"glInvalidateFramebuffer\", glInvalidateFramebuffer == NULL);\n  glewInfoFunc(\"glInvalidateSubFramebuffer\", glInvalidateSubFramebuffer == NULL);\n  glewInfoFunc(\"glInvalidateTexImage\", glInvalidateTexImage == NULL);\n  glewInfoFunc(\"glInvalidateTexSubImage\", glInvalidateTexSubImage == NULL);\n}\n\n#endif /* GL_ARB_invalidate_subdata */\n\n#ifdef GL_ARB_map_buffer_alignment\n\nstatic void _glewInfo_GL_ARB_map_buffer_alignment (void)\n{\n  glewPrintExt(\"GL_ARB_map_buffer_alignment\", GLEW_ARB_map_buffer_alignment, glewIsSupported(\"GL_ARB_map_buffer_alignment\"), glewGetExtension(\"GL_ARB_map_buffer_alignment\"));\n}\n\n#endif /* GL_ARB_map_buffer_alignment */\n\n#ifdef GL_ARB_map_buffer_range\n\nstatic void _glewInfo_GL_ARB_map_buffer_range (void)\n{\n  glewPrintExt(\"GL_ARB_map_buffer_range\", GLEW_ARB_map_buffer_range, glewIsSupported(\"GL_ARB_map_buffer_range\"), glewGetExtension(\"GL_ARB_map_buffer_range\"));\n\n  glewInfoFunc(\"glFlushMappedBufferRange\", glFlushMappedBufferRange == NULL);\n  glewInfoFunc(\"glMapBufferRange\", glMapBufferRange == NULL);\n}\n\n#endif /* GL_ARB_map_buffer_range */\n\n#ifdef GL_ARB_matrix_palette\n\nstatic void _glewInfo_GL_ARB_matrix_palette (void)\n{\n  glewPrintExt(\"GL_ARB_matrix_palette\", GLEW_ARB_matrix_palette, glewIsSupported(\"GL_ARB_matrix_palette\"), glewGetExtension(\"GL_ARB_matrix_palette\"));\n\n  glewInfoFunc(\"glCurrentPaletteMatrixARB\", glCurrentPaletteMatrixARB == NULL);\n  glewInfoFunc(\"glMatrixIndexPointerARB\", glMatrixIndexPointerARB == NULL);\n  glewInfoFunc(\"glMatrixIndexubvARB\", glMatrixIndexubvARB == NULL);\n  glewInfoFunc(\"glMatrixIndexuivARB\", glMatrixIndexuivARB == NULL);\n  glewInfoFunc(\"glMatrixIndexusvARB\", glMatrixIndexusvARB == NULL);\n}\n\n#endif /* GL_ARB_matrix_palette */\n\n#ifdef GL_ARB_multi_draw_indirect\n\nstatic void _glewInfo_GL_ARB_multi_draw_indirect (void)\n{\n  glewPrintExt(\"GL_ARB_multi_draw_indirect\", GLEW_ARB_multi_draw_indirect, glewIsSupported(\"GL_ARB_multi_draw_indirect\"), glewGetExtension(\"GL_ARB_multi_draw_indirect\"));\n\n  glewInfoFunc(\"glMultiDrawArraysIndirect\", glMultiDrawArraysIndirect == NULL);\n  glewInfoFunc(\"glMultiDrawElementsIndirect\", glMultiDrawElementsIndirect == NULL);\n}\n\n#endif /* GL_ARB_multi_draw_indirect */\n\n#ifdef GL_ARB_multisample\n\nstatic void _glewInfo_GL_ARB_multisample (void)\n{\n  glewPrintExt(\"GL_ARB_multisample\", GLEW_ARB_multisample, glewIsSupported(\"GL_ARB_multisample\"), glewGetExtension(\"GL_ARB_multisample\"));\n\n  glewInfoFunc(\"glSampleCoverageARB\", glSampleCoverageARB == NULL);\n}\n\n#endif /* GL_ARB_multisample */\n\n#ifdef GL_ARB_multitexture\n\nstatic void _glewInfo_GL_ARB_multitexture (void)\n{\n  glewPrintExt(\"GL_ARB_multitexture\", GLEW_ARB_multitexture, glewIsSupported(\"GL_ARB_multitexture\"), glewGetExtension(\"GL_ARB_multitexture\"));\n\n  glewInfoFunc(\"glActiveTextureARB\", glActiveTextureARB == NULL);\n  glewInfoFunc(\"glClientActiveTextureARB\", glClientActiveTextureARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1dARB\", glMultiTexCoord1dARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1dvARB\", glMultiTexCoord1dvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1fARB\", glMultiTexCoord1fARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1fvARB\", glMultiTexCoord1fvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1iARB\", glMultiTexCoord1iARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1ivARB\", glMultiTexCoord1ivARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1sARB\", glMultiTexCoord1sARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord1svARB\", glMultiTexCoord1svARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2dARB\", glMultiTexCoord2dARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2dvARB\", glMultiTexCoord2dvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2fARB\", glMultiTexCoord2fARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2fvARB\", glMultiTexCoord2fvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2iARB\", glMultiTexCoord2iARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2ivARB\", glMultiTexCoord2ivARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2sARB\", glMultiTexCoord2sARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord2svARB\", glMultiTexCoord2svARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3dARB\", glMultiTexCoord3dARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3dvARB\", glMultiTexCoord3dvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3fARB\", glMultiTexCoord3fARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3fvARB\", glMultiTexCoord3fvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3iARB\", glMultiTexCoord3iARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3ivARB\", glMultiTexCoord3ivARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3sARB\", glMultiTexCoord3sARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord3svARB\", glMultiTexCoord3svARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4dARB\", glMultiTexCoord4dARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4dvARB\", glMultiTexCoord4dvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4fARB\", glMultiTexCoord4fARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4fvARB\", glMultiTexCoord4fvARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4iARB\", glMultiTexCoord4iARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4ivARB\", glMultiTexCoord4ivARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4sARB\", glMultiTexCoord4sARB == NULL);\n  glewInfoFunc(\"glMultiTexCoord4svARB\", glMultiTexCoord4svARB == NULL);\n}\n\n#endif /* GL_ARB_multitexture */\n\n#ifdef GL_ARB_occlusion_query\n\nstatic void _glewInfo_GL_ARB_occlusion_query (void)\n{\n  glewPrintExt(\"GL_ARB_occlusion_query\", GLEW_ARB_occlusion_query, glewIsSupported(\"GL_ARB_occlusion_query\"), glewGetExtension(\"GL_ARB_occlusion_query\"));\n\n  glewInfoFunc(\"glBeginQueryARB\", glBeginQueryARB == NULL);\n  glewInfoFunc(\"glDeleteQueriesARB\", glDeleteQueriesARB == NULL);\n  glewInfoFunc(\"glEndQueryARB\", glEndQueryARB == NULL);\n  glewInfoFunc(\"glGenQueriesARB\", glGenQueriesARB == NULL);\n  glewInfoFunc(\"glGetQueryObjectivARB\", glGetQueryObjectivARB == NULL);\n  glewInfoFunc(\"glGetQueryObjectuivARB\", glGetQueryObjectuivARB == NULL);\n  glewInfoFunc(\"glGetQueryivARB\", glGetQueryivARB == NULL);\n  glewInfoFunc(\"glIsQueryARB\", glIsQueryARB == NULL);\n}\n\n#endif /* GL_ARB_occlusion_query */\n\n#ifdef GL_ARB_occlusion_query2\n\nstatic void _glewInfo_GL_ARB_occlusion_query2 (void)\n{\n  glewPrintExt(\"GL_ARB_occlusion_query2\", GLEW_ARB_occlusion_query2, glewIsSupported(\"GL_ARB_occlusion_query2\"), glewGetExtension(\"GL_ARB_occlusion_query2\"));\n}\n\n#endif /* GL_ARB_occlusion_query2 */\n\n#ifdef GL_ARB_pixel_buffer_object\n\nstatic void _glewInfo_GL_ARB_pixel_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_pixel_buffer_object\", GLEW_ARB_pixel_buffer_object, glewIsSupported(\"GL_ARB_pixel_buffer_object\"), glewGetExtension(\"GL_ARB_pixel_buffer_object\"));\n}\n\n#endif /* GL_ARB_pixel_buffer_object */\n\n#ifdef GL_ARB_point_parameters\n\nstatic void _glewInfo_GL_ARB_point_parameters (void)\n{\n  glewPrintExt(\"GL_ARB_point_parameters\", GLEW_ARB_point_parameters, glewIsSupported(\"GL_ARB_point_parameters\"), glewGetExtension(\"GL_ARB_point_parameters\"));\n\n  glewInfoFunc(\"glPointParameterfARB\", glPointParameterfARB == NULL);\n  glewInfoFunc(\"glPointParameterfvARB\", glPointParameterfvARB == NULL);\n}\n\n#endif /* GL_ARB_point_parameters */\n\n#ifdef GL_ARB_point_sprite\n\nstatic void _glewInfo_GL_ARB_point_sprite (void)\n{\n  glewPrintExt(\"GL_ARB_point_sprite\", GLEW_ARB_point_sprite, glewIsSupported(\"GL_ARB_point_sprite\"), glewGetExtension(\"GL_ARB_point_sprite\"));\n}\n\n#endif /* GL_ARB_point_sprite */\n\n#ifdef GL_ARB_program_interface_query\n\nstatic void _glewInfo_GL_ARB_program_interface_query (void)\n{\n  glewPrintExt(\"GL_ARB_program_interface_query\", GLEW_ARB_program_interface_query, glewIsSupported(\"GL_ARB_program_interface_query\"), glewGetExtension(\"GL_ARB_program_interface_query\"));\n\n  glewInfoFunc(\"glGetProgramInterfaceiv\", glGetProgramInterfaceiv == NULL);\n  glewInfoFunc(\"glGetProgramResourceIndex\", glGetProgramResourceIndex == NULL);\n  glewInfoFunc(\"glGetProgramResourceLocation\", glGetProgramResourceLocation == NULL);\n  glewInfoFunc(\"glGetProgramResourceLocationIndex\", glGetProgramResourceLocationIndex == NULL);\n  glewInfoFunc(\"glGetProgramResourceName\", glGetProgramResourceName == NULL);\n  glewInfoFunc(\"glGetProgramResourceiv\", glGetProgramResourceiv == NULL);\n}\n\n#endif /* GL_ARB_program_interface_query */\n\n#ifdef GL_ARB_provoking_vertex\n\nstatic void _glewInfo_GL_ARB_provoking_vertex (void)\n{\n  glewPrintExt(\"GL_ARB_provoking_vertex\", GLEW_ARB_provoking_vertex, glewIsSupported(\"GL_ARB_provoking_vertex\"), glewGetExtension(\"GL_ARB_provoking_vertex\"));\n\n  glewInfoFunc(\"glProvokingVertex\", glProvokingVertex == NULL);\n}\n\n#endif /* GL_ARB_provoking_vertex */\n\n#ifdef GL_ARB_robust_buffer_access_behavior\n\nstatic void _glewInfo_GL_ARB_robust_buffer_access_behavior (void)\n{\n  glewPrintExt(\"GL_ARB_robust_buffer_access_behavior\", GLEW_ARB_robust_buffer_access_behavior, glewIsSupported(\"GL_ARB_robust_buffer_access_behavior\"), glewGetExtension(\"GL_ARB_robust_buffer_access_behavior\"));\n}\n\n#endif /* GL_ARB_robust_buffer_access_behavior */\n\n#ifdef GL_ARB_robustness\n\nstatic void _glewInfo_GL_ARB_robustness (void)\n{\n  glewPrintExt(\"GL_ARB_robustness\", GLEW_ARB_robustness, glewIsSupported(\"GL_ARB_robustness\"), glewGetExtension(\"GL_ARB_robustness\"));\n\n  glewInfoFunc(\"glGetGraphicsResetStatusARB\", glGetGraphicsResetStatusARB == NULL);\n  glewInfoFunc(\"glGetnColorTableARB\", glGetnColorTableARB == NULL);\n  glewInfoFunc(\"glGetnCompressedTexImageARB\", glGetnCompressedTexImageARB == NULL);\n  glewInfoFunc(\"glGetnConvolutionFilterARB\", glGetnConvolutionFilterARB == NULL);\n  glewInfoFunc(\"glGetnHistogramARB\", glGetnHistogramARB == NULL);\n  glewInfoFunc(\"glGetnMapdvARB\", glGetnMapdvARB == NULL);\n  glewInfoFunc(\"glGetnMapfvARB\", glGetnMapfvARB == NULL);\n  glewInfoFunc(\"glGetnMapivARB\", glGetnMapivARB == NULL);\n  glewInfoFunc(\"glGetnMinmaxARB\", glGetnMinmaxARB == NULL);\n  glewInfoFunc(\"glGetnPixelMapfvARB\", glGetnPixelMapfvARB == NULL);\n  glewInfoFunc(\"glGetnPixelMapuivARB\", glGetnPixelMapuivARB == NULL);\n  glewInfoFunc(\"glGetnPixelMapusvARB\", glGetnPixelMapusvARB == NULL);\n  glewInfoFunc(\"glGetnPolygonStippleARB\", glGetnPolygonStippleARB == NULL);\n  glewInfoFunc(\"glGetnSeparableFilterARB\", glGetnSeparableFilterARB == NULL);\n  glewInfoFunc(\"glGetnTexImageARB\", glGetnTexImageARB == NULL);\n  glewInfoFunc(\"glGetnUniformdvARB\", glGetnUniformdvARB == NULL);\n  glewInfoFunc(\"glGetnUniformfvARB\", glGetnUniformfvARB == NULL);\n  glewInfoFunc(\"glGetnUniformivARB\", glGetnUniformivARB == NULL);\n  glewInfoFunc(\"glGetnUniformuivARB\", glGetnUniformuivARB == NULL);\n  glewInfoFunc(\"glReadnPixelsARB\", glReadnPixelsARB == NULL);\n}\n\n#endif /* GL_ARB_robustness */\n\n#ifdef GL_ARB_robustness_application_isolation\n\nstatic void _glewInfo_GL_ARB_robustness_application_isolation (void)\n{\n  glewPrintExt(\"GL_ARB_robustness_application_isolation\", GLEW_ARB_robustness_application_isolation, glewIsSupported(\"GL_ARB_robustness_application_isolation\"), glewGetExtension(\"GL_ARB_robustness_application_isolation\"));\n}\n\n#endif /* GL_ARB_robustness_application_isolation */\n\n#ifdef GL_ARB_robustness_share_group_isolation\n\nstatic void _glewInfo_GL_ARB_robustness_share_group_isolation (void)\n{\n  glewPrintExt(\"GL_ARB_robustness_share_group_isolation\", GLEW_ARB_robustness_share_group_isolation, glewIsSupported(\"GL_ARB_robustness_share_group_isolation\"), glewGetExtension(\"GL_ARB_robustness_share_group_isolation\"));\n}\n\n#endif /* GL_ARB_robustness_share_group_isolation */\n\n#ifdef GL_ARB_sample_shading\n\nstatic void _glewInfo_GL_ARB_sample_shading (void)\n{\n  glewPrintExt(\"GL_ARB_sample_shading\", GLEW_ARB_sample_shading, glewIsSupported(\"GL_ARB_sample_shading\"), glewGetExtension(\"GL_ARB_sample_shading\"));\n\n  glewInfoFunc(\"glMinSampleShadingARB\", glMinSampleShadingARB == NULL);\n}\n\n#endif /* GL_ARB_sample_shading */\n\n#ifdef GL_ARB_sampler_objects\n\nstatic void _glewInfo_GL_ARB_sampler_objects (void)\n{\n  glewPrintExt(\"GL_ARB_sampler_objects\", GLEW_ARB_sampler_objects, glewIsSupported(\"GL_ARB_sampler_objects\"), glewGetExtension(\"GL_ARB_sampler_objects\"));\n\n  glewInfoFunc(\"glBindSampler\", glBindSampler == NULL);\n  glewInfoFunc(\"glDeleteSamplers\", glDeleteSamplers == NULL);\n  glewInfoFunc(\"glGenSamplers\", glGenSamplers == NULL);\n  glewInfoFunc(\"glGetSamplerParameterIiv\", glGetSamplerParameterIiv == NULL);\n  glewInfoFunc(\"glGetSamplerParameterIuiv\", glGetSamplerParameterIuiv == NULL);\n  glewInfoFunc(\"glGetSamplerParameterfv\", glGetSamplerParameterfv == NULL);\n  glewInfoFunc(\"glGetSamplerParameteriv\", glGetSamplerParameteriv == NULL);\n  glewInfoFunc(\"glIsSampler\", glIsSampler == NULL);\n  glewInfoFunc(\"glSamplerParameterIiv\", glSamplerParameterIiv == NULL);\n  glewInfoFunc(\"glSamplerParameterIuiv\", glSamplerParameterIuiv == NULL);\n  glewInfoFunc(\"glSamplerParameterf\", glSamplerParameterf == NULL);\n  glewInfoFunc(\"glSamplerParameterfv\", glSamplerParameterfv == NULL);\n  glewInfoFunc(\"glSamplerParameteri\", glSamplerParameteri == NULL);\n  glewInfoFunc(\"glSamplerParameteriv\", glSamplerParameteriv == NULL);\n}\n\n#endif /* GL_ARB_sampler_objects */\n\n#ifdef GL_ARB_seamless_cube_map\n\nstatic void _glewInfo_GL_ARB_seamless_cube_map (void)\n{\n  glewPrintExt(\"GL_ARB_seamless_cube_map\", GLEW_ARB_seamless_cube_map, glewIsSupported(\"GL_ARB_seamless_cube_map\"), glewGetExtension(\"GL_ARB_seamless_cube_map\"));\n}\n\n#endif /* GL_ARB_seamless_cube_map */\n\n#ifdef GL_ARB_separate_shader_objects\n\nstatic void _glewInfo_GL_ARB_separate_shader_objects (void)\n{\n  glewPrintExt(\"GL_ARB_separate_shader_objects\", GLEW_ARB_separate_shader_objects, glewIsSupported(\"GL_ARB_separate_shader_objects\"), glewGetExtension(\"GL_ARB_separate_shader_objects\"));\n\n  glewInfoFunc(\"glActiveShaderProgram\", glActiveShaderProgram == NULL);\n  glewInfoFunc(\"glBindProgramPipeline\", glBindProgramPipeline == NULL);\n  glewInfoFunc(\"glCreateShaderProgramv\", glCreateShaderProgramv == NULL);\n  glewInfoFunc(\"glDeleteProgramPipelines\", glDeleteProgramPipelines == NULL);\n  glewInfoFunc(\"glGenProgramPipelines\", glGenProgramPipelines == NULL);\n  glewInfoFunc(\"glGetProgramPipelineInfoLog\", glGetProgramPipelineInfoLog == NULL);\n  glewInfoFunc(\"glGetProgramPipelineiv\", glGetProgramPipelineiv == NULL);\n  glewInfoFunc(\"glIsProgramPipeline\", glIsProgramPipeline == NULL);\n  glewInfoFunc(\"glProgramUniform1d\", glProgramUniform1d == NULL);\n  glewInfoFunc(\"glProgramUniform1dv\", glProgramUniform1dv == NULL);\n  glewInfoFunc(\"glProgramUniform1f\", glProgramUniform1f == NULL);\n  glewInfoFunc(\"glProgramUniform1fv\", glProgramUniform1fv == NULL);\n  glewInfoFunc(\"glProgramUniform1i\", glProgramUniform1i == NULL);\n  glewInfoFunc(\"glProgramUniform1iv\", glProgramUniform1iv == NULL);\n  glewInfoFunc(\"glProgramUniform1ui\", glProgramUniform1ui == NULL);\n  glewInfoFunc(\"glProgramUniform1uiv\", glProgramUniform1uiv == NULL);\n  glewInfoFunc(\"glProgramUniform2d\", glProgramUniform2d == NULL);\n  glewInfoFunc(\"glProgramUniform2dv\", glProgramUniform2dv == NULL);\n  glewInfoFunc(\"glProgramUniform2f\", glProgramUniform2f == NULL);\n  glewInfoFunc(\"glProgramUniform2fv\", glProgramUniform2fv == NULL);\n  glewInfoFunc(\"glProgramUniform2i\", glProgramUniform2i == NULL);\n  glewInfoFunc(\"glProgramUniform2iv\", glProgramUniform2iv == NULL);\n  glewInfoFunc(\"glProgramUniform2ui\", glProgramUniform2ui == NULL);\n  glewInfoFunc(\"glProgramUniform2uiv\", glProgramUniform2uiv == NULL);\n  glewInfoFunc(\"glProgramUniform3d\", glProgramUniform3d == NULL);\n  glewInfoFunc(\"glProgramUniform3dv\", glProgramUniform3dv == NULL);\n  glewInfoFunc(\"glProgramUniform3f\", glProgramUniform3f == NULL);\n  glewInfoFunc(\"glProgramUniform3fv\", glProgramUniform3fv == NULL);\n  glewInfoFunc(\"glProgramUniform3i\", glProgramUniform3i == NULL);\n  glewInfoFunc(\"glProgramUniform3iv\", glProgramUniform3iv == NULL);\n  glewInfoFunc(\"glProgramUniform3ui\", glProgramUniform3ui == NULL);\n  glewInfoFunc(\"glProgramUniform3uiv\", glProgramUniform3uiv == NULL);\n  glewInfoFunc(\"glProgramUniform4d\", glProgramUniform4d == NULL);\n  glewInfoFunc(\"glProgramUniform4dv\", glProgramUniform4dv == NULL);\n  glewInfoFunc(\"glProgramUniform4f\", glProgramUniform4f == NULL);\n  glewInfoFunc(\"glProgramUniform4fv\", glProgramUniform4fv == NULL);\n  glewInfoFunc(\"glProgramUniform4i\", glProgramUniform4i == NULL);\n  glewInfoFunc(\"glProgramUniform4iv\", glProgramUniform4iv == NULL);\n  glewInfoFunc(\"glProgramUniform4ui\", glProgramUniform4ui == NULL);\n  glewInfoFunc(\"glProgramUniform4uiv\", glProgramUniform4uiv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2dv\", glProgramUniformMatrix2dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2fv\", glProgramUniformMatrix2fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x3dv\", glProgramUniformMatrix2x3dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x3fv\", glProgramUniformMatrix2x3fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x4dv\", glProgramUniformMatrix2x4dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x4fv\", glProgramUniformMatrix2x4fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3dv\", glProgramUniformMatrix3dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3fv\", glProgramUniformMatrix3fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x2dv\", glProgramUniformMatrix3x2dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x2fv\", glProgramUniformMatrix3x2fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x4dv\", glProgramUniformMatrix3x4dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x4fv\", glProgramUniformMatrix3x4fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4dv\", glProgramUniformMatrix4dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4fv\", glProgramUniformMatrix4fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x2dv\", glProgramUniformMatrix4x2dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x2fv\", glProgramUniformMatrix4x2fv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x3dv\", glProgramUniformMatrix4x3dv == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x3fv\", glProgramUniformMatrix4x3fv == NULL);\n  glewInfoFunc(\"glUseProgramStages\", glUseProgramStages == NULL);\n  glewInfoFunc(\"glValidateProgramPipeline\", glValidateProgramPipeline == NULL);\n}\n\n#endif /* GL_ARB_separate_shader_objects */\n\n#ifdef GL_ARB_shader_atomic_counters\n\nstatic void _glewInfo_GL_ARB_shader_atomic_counters (void)\n{\n  glewPrintExt(\"GL_ARB_shader_atomic_counters\", GLEW_ARB_shader_atomic_counters, glewIsSupported(\"GL_ARB_shader_atomic_counters\"), glewGetExtension(\"GL_ARB_shader_atomic_counters\"));\n\n  glewInfoFunc(\"glGetActiveAtomicCounterBufferiv\", glGetActiveAtomicCounterBufferiv == NULL);\n}\n\n#endif /* GL_ARB_shader_atomic_counters */\n\n#ifdef GL_ARB_shader_bit_encoding\n\nstatic void _glewInfo_GL_ARB_shader_bit_encoding (void)\n{\n  glewPrintExt(\"GL_ARB_shader_bit_encoding\", GLEW_ARB_shader_bit_encoding, glewIsSupported(\"GL_ARB_shader_bit_encoding\"), glewGetExtension(\"GL_ARB_shader_bit_encoding\"));\n}\n\n#endif /* GL_ARB_shader_bit_encoding */\n\n#ifdef GL_ARB_shader_image_load_store\n\nstatic void _glewInfo_GL_ARB_shader_image_load_store (void)\n{\n  glewPrintExt(\"GL_ARB_shader_image_load_store\", GLEW_ARB_shader_image_load_store, glewIsSupported(\"GL_ARB_shader_image_load_store\"), glewGetExtension(\"GL_ARB_shader_image_load_store\"));\n\n  glewInfoFunc(\"glBindImageTexture\", glBindImageTexture == NULL);\n  glewInfoFunc(\"glMemoryBarrier\", glMemoryBarrier == NULL);\n}\n\n#endif /* GL_ARB_shader_image_load_store */\n\n#ifdef GL_ARB_shader_image_size\n\nstatic void _glewInfo_GL_ARB_shader_image_size (void)\n{\n  glewPrintExt(\"GL_ARB_shader_image_size\", GLEW_ARB_shader_image_size, glewIsSupported(\"GL_ARB_shader_image_size\"), glewGetExtension(\"GL_ARB_shader_image_size\"));\n}\n\n#endif /* GL_ARB_shader_image_size */\n\n#ifdef GL_ARB_shader_objects\n\nstatic void _glewInfo_GL_ARB_shader_objects (void)\n{\n  glewPrintExt(\"GL_ARB_shader_objects\", GLEW_ARB_shader_objects, glewIsSupported(\"GL_ARB_shader_objects\"), glewGetExtension(\"GL_ARB_shader_objects\"));\n\n  glewInfoFunc(\"glAttachObjectARB\", glAttachObjectARB == NULL);\n  glewInfoFunc(\"glCompileShaderARB\", glCompileShaderARB == NULL);\n  glewInfoFunc(\"glCreateProgramObjectARB\", glCreateProgramObjectARB == NULL);\n  glewInfoFunc(\"glCreateShaderObjectARB\", glCreateShaderObjectARB == NULL);\n  glewInfoFunc(\"glDeleteObjectARB\", glDeleteObjectARB == NULL);\n  glewInfoFunc(\"glDetachObjectARB\", glDetachObjectARB == NULL);\n  glewInfoFunc(\"glGetActiveUniformARB\", glGetActiveUniformARB == NULL);\n  glewInfoFunc(\"glGetAttachedObjectsARB\", glGetAttachedObjectsARB == NULL);\n  glewInfoFunc(\"glGetHandleARB\", glGetHandleARB == NULL);\n  glewInfoFunc(\"glGetInfoLogARB\", glGetInfoLogARB == NULL);\n  glewInfoFunc(\"glGetObjectParameterfvARB\", glGetObjectParameterfvARB == NULL);\n  glewInfoFunc(\"glGetObjectParameterivARB\", glGetObjectParameterivARB == NULL);\n  glewInfoFunc(\"glGetShaderSourceARB\", glGetShaderSourceARB == NULL);\n  glewInfoFunc(\"glGetUniformLocationARB\", glGetUniformLocationARB == NULL);\n  glewInfoFunc(\"glGetUniformfvARB\", glGetUniformfvARB == NULL);\n  glewInfoFunc(\"glGetUniformivARB\", glGetUniformivARB == NULL);\n  glewInfoFunc(\"glLinkProgramARB\", glLinkProgramARB == NULL);\n  glewInfoFunc(\"glShaderSourceARB\", glShaderSourceARB == NULL);\n  glewInfoFunc(\"glUniform1fARB\", glUniform1fARB == NULL);\n  glewInfoFunc(\"glUniform1fvARB\", glUniform1fvARB == NULL);\n  glewInfoFunc(\"glUniform1iARB\", glUniform1iARB == NULL);\n  glewInfoFunc(\"glUniform1ivARB\", glUniform1ivARB == NULL);\n  glewInfoFunc(\"glUniform2fARB\", glUniform2fARB == NULL);\n  glewInfoFunc(\"glUniform2fvARB\", glUniform2fvARB == NULL);\n  glewInfoFunc(\"glUniform2iARB\", glUniform2iARB == NULL);\n  glewInfoFunc(\"glUniform2ivARB\", glUniform2ivARB == NULL);\n  glewInfoFunc(\"glUniform3fARB\", glUniform3fARB == NULL);\n  glewInfoFunc(\"glUniform3fvARB\", glUniform3fvARB == NULL);\n  glewInfoFunc(\"glUniform3iARB\", glUniform3iARB == NULL);\n  glewInfoFunc(\"glUniform3ivARB\", glUniform3ivARB == NULL);\n  glewInfoFunc(\"glUniform4fARB\", glUniform4fARB == NULL);\n  glewInfoFunc(\"glUniform4fvARB\", glUniform4fvARB == NULL);\n  glewInfoFunc(\"glUniform4iARB\", glUniform4iARB == NULL);\n  glewInfoFunc(\"glUniform4ivARB\", glUniform4ivARB == NULL);\n  glewInfoFunc(\"glUniformMatrix2fvARB\", glUniformMatrix2fvARB == NULL);\n  glewInfoFunc(\"glUniformMatrix3fvARB\", glUniformMatrix3fvARB == NULL);\n  glewInfoFunc(\"glUniformMatrix4fvARB\", glUniformMatrix4fvARB == NULL);\n  glewInfoFunc(\"glUseProgramObjectARB\", glUseProgramObjectARB == NULL);\n  glewInfoFunc(\"glValidateProgramARB\", glValidateProgramARB == NULL);\n}\n\n#endif /* GL_ARB_shader_objects */\n\n#ifdef GL_ARB_shader_precision\n\nstatic void _glewInfo_GL_ARB_shader_precision (void)\n{\n  glewPrintExt(\"GL_ARB_shader_precision\", GLEW_ARB_shader_precision, glewIsSupported(\"GL_ARB_shader_precision\"), glewGetExtension(\"GL_ARB_shader_precision\"));\n}\n\n#endif /* GL_ARB_shader_precision */\n\n#ifdef GL_ARB_shader_stencil_export\n\nstatic void _glewInfo_GL_ARB_shader_stencil_export (void)\n{\n  glewPrintExt(\"GL_ARB_shader_stencil_export\", GLEW_ARB_shader_stencil_export, glewIsSupported(\"GL_ARB_shader_stencil_export\"), glewGetExtension(\"GL_ARB_shader_stencil_export\"));\n}\n\n#endif /* GL_ARB_shader_stencil_export */\n\n#ifdef GL_ARB_shader_storage_buffer_object\n\nstatic void _glewInfo_GL_ARB_shader_storage_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_shader_storage_buffer_object\", GLEW_ARB_shader_storage_buffer_object, glewIsSupported(\"GL_ARB_shader_storage_buffer_object\"), glewGetExtension(\"GL_ARB_shader_storage_buffer_object\"));\n\n  glewInfoFunc(\"glShaderStorageBlockBinding\", glShaderStorageBlockBinding == NULL);\n}\n\n#endif /* GL_ARB_shader_storage_buffer_object */\n\n#ifdef GL_ARB_shader_subroutine\n\nstatic void _glewInfo_GL_ARB_shader_subroutine (void)\n{\n  glewPrintExt(\"GL_ARB_shader_subroutine\", GLEW_ARB_shader_subroutine, glewIsSupported(\"GL_ARB_shader_subroutine\"), glewGetExtension(\"GL_ARB_shader_subroutine\"));\n\n  glewInfoFunc(\"glGetActiveSubroutineName\", glGetActiveSubroutineName == NULL);\n  glewInfoFunc(\"glGetActiveSubroutineUniformName\", glGetActiveSubroutineUniformName == NULL);\n  glewInfoFunc(\"glGetActiveSubroutineUniformiv\", glGetActiveSubroutineUniformiv == NULL);\n  glewInfoFunc(\"glGetProgramStageiv\", glGetProgramStageiv == NULL);\n  glewInfoFunc(\"glGetSubroutineIndex\", glGetSubroutineIndex == NULL);\n  glewInfoFunc(\"glGetSubroutineUniformLocation\", glGetSubroutineUniformLocation == NULL);\n  glewInfoFunc(\"glGetUniformSubroutineuiv\", glGetUniformSubroutineuiv == NULL);\n  glewInfoFunc(\"glUniformSubroutinesuiv\", glUniformSubroutinesuiv == NULL);\n}\n\n#endif /* GL_ARB_shader_subroutine */\n\n#ifdef GL_ARB_shader_texture_lod\n\nstatic void _glewInfo_GL_ARB_shader_texture_lod (void)\n{\n  glewPrintExt(\"GL_ARB_shader_texture_lod\", GLEW_ARB_shader_texture_lod, glewIsSupported(\"GL_ARB_shader_texture_lod\"), glewGetExtension(\"GL_ARB_shader_texture_lod\"));\n}\n\n#endif /* GL_ARB_shader_texture_lod */\n\n#ifdef GL_ARB_shading_language_100\n\nstatic void _glewInfo_GL_ARB_shading_language_100 (void)\n{\n  glewPrintExt(\"GL_ARB_shading_language_100\", GLEW_ARB_shading_language_100, glewIsSupported(\"GL_ARB_shading_language_100\"), glewGetExtension(\"GL_ARB_shading_language_100\"));\n}\n\n#endif /* GL_ARB_shading_language_100 */\n\n#ifdef GL_ARB_shading_language_420pack\n\nstatic void _glewInfo_GL_ARB_shading_language_420pack (void)\n{\n  glewPrintExt(\"GL_ARB_shading_language_420pack\", GLEW_ARB_shading_language_420pack, glewIsSupported(\"GL_ARB_shading_language_420pack\"), glewGetExtension(\"GL_ARB_shading_language_420pack\"));\n}\n\n#endif /* GL_ARB_shading_language_420pack */\n\n#ifdef GL_ARB_shading_language_include\n\nstatic void _glewInfo_GL_ARB_shading_language_include (void)\n{\n  glewPrintExt(\"GL_ARB_shading_language_include\", GLEW_ARB_shading_language_include, glewIsSupported(\"GL_ARB_shading_language_include\"), glewGetExtension(\"GL_ARB_shading_language_include\"));\n\n  glewInfoFunc(\"glCompileShaderIncludeARB\", glCompileShaderIncludeARB == NULL);\n  glewInfoFunc(\"glDeleteNamedStringARB\", glDeleteNamedStringARB == NULL);\n  glewInfoFunc(\"glGetNamedStringARB\", glGetNamedStringARB == NULL);\n  glewInfoFunc(\"glGetNamedStringivARB\", glGetNamedStringivARB == NULL);\n  glewInfoFunc(\"glIsNamedStringARB\", glIsNamedStringARB == NULL);\n  glewInfoFunc(\"glNamedStringARB\", glNamedStringARB == NULL);\n}\n\n#endif /* GL_ARB_shading_language_include */\n\n#ifdef GL_ARB_shading_language_packing\n\nstatic void _glewInfo_GL_ARB_shading_language_packing (void)\n{\n  glewPrintExt(\"GL_ARB_shading_language_packing\", GLEW_ARB_shading_language_packing, glewIsSupported(\"GL_ARB_shading_language_packing\"), glewGetExtension(\"GL_ARB_shading_language_packing\"));\n}\n\n#endif /* GL_ARB_shading_language_packing */\n\n#ifdef GL_ARB_shadow\n\nstatic void _glewInfo_GL_ARB_shadow (void)\n{\n  glewPrintExt(\"GL_ARB_shadow\", GLEW_ARB_shadow, glewIsSupported(\"GL_ARB_shadow\"), glewGetExtension(\"GL_ARB_shadow\"));\n}\n\n#endif /* GL_ARB_shadow */\n\n#ifdef GL_ARB_shadow_ambient\n\nstatic void _glewInfo_GL_ARB_shadow_ambient (void)\n{\n  glewPrintExt(\"GL_ARB_shadow_ambient\", GLEW_ARB_shadow_ambient, glewIsSupported(\"GL_ARB_shadow_ambient\"), glewGetExtension(\"GL_ARB_shadow_ambient\"));\n}\n\n#endif /* GL_ARB_shadow_ambient */\n\n#ifdef GL_ARB_stencil_texturing\n\nstatic void _glewInfo_GL_ARB_stencil_texturing (void)\n{\n  glewPrintExt(\"GL_ARB_stencil_texturing\", GLEW_ARB_stencil_texturing, glewIsSupported(\"GL_ARB_stencil_texturing\"), glewGetExtension(\"GL_ARB_stencil_texturing\"));\n}\n\n#endif /* GL_ARB_stencil_texturing */\n\n#ifdef GL_ARB_sync\n\nstatic void _glewInfo_GL_ARB_sync (void)\n{\n  glewPrintExt(\"GL_ARB_sync\", GLEW_ARB_sync, glewIsSupported(\"GL_ARB_sync\"), glewGetExtension(\"GL_ARB_sync\"));\n\n  glewInfoFunc(\"glClientWaitSync\", glClientWaitSync == NULL);\n  glewInfoFunc(\"glDeleteSync\", glDeleteSync == NULL);\n  glewInfoFunc(\"glFenceSync\", glFenceSync == NULL);\n  glewInfoFunc(\"glGetInteger64v\", glGetInteger64v == NULL);\n  glewInfoFunc(\"glGetSynciv\", glGetSynciv == NULL);\n  glewInfoFunc(\"glIsSync\", glIsSync == NULL);\n  glewInfoFunc(\"glWaitSync\", glWaitSync == NULL);\n}\n\n#endif /* GL_ARB_sync */\n\n#ifdef GL_ARB_tessellation_shader\n\nstatic void _glewInfo_GL_ARB_tessellation_shader (void)\n{\n  glewPrintExt(\"GL_ARB_tessellation_shader\", GLEW_ARB_tessellation_shader, glewIsSupported(\"GL_ARB_tessellation_shader\"), glewGetExtension(\"GL_ARB_tessellation_shader\"));\n\n  glewInfoFunc(\"glPatchParameterfv\", glPatchParameterfv == NULL);\n  glewInfoFunc(\"glPatchParameteri\", glPatchParameteri == NULL);\n}\n\n#endif /* GL_ARB_tessellation_shader */\n\n#ifdef GL_ARB_texture_border_clamp\n\nstatic void _glewInfo_GL_ARB_texture_border_clamp (void)\n{\n  glewPrintExt(\"GL_ARB_texture_border_clamp\", GLEW_ARB_texture_border_clamp, glewIsSupported(\"GL_ARB_texture_border_clamp\"), glewGetExtension(\"GL_ARB_texture_border_clamp\"));\n}\n\n#endif /* GL_ARB_texture_border_clamp */\n\n#ifdef GL_ARB_texture_buffer_object\n\nstatic void _glewInfo_GL_ARB_texture_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_texture_buffer_object\", GLEW_ARB_texture_buffer_object, glewIsSupported(\"GL_ARB_texture_buffer_object\"), glewGetExtension(\"GL_ARB_texture_buffer_object\"));\n\n  glewInfoFunc(\"glTexBufferARB\", glTexBufferARB == NULL);\n}\n\n#endif /* GL_ARB_texture_buffer_object */\n\n#ifdef GL_ARB_texture_buffer_object_rgb32\n\nstatic void _glewInfo_GL_ARB_texture_buffer_object_rgb32 (void)\n{\n  glewPrintExt(\"GL_ARB_texture_buffer_object_rgb32\", GLEW_ARB_texture_buffer_object_rgb32, glewIsSupported(\"GL_ARB_texture_buffer_object_rgb32\"), glewGetExtension(\"GL_ARB_texture_buffer_object_rgb32\"));\n}\n\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n\n#ifdef GL_ARB_texture_buffer_range\n\nstatic void _glewInfo_GL_ARB_texture_buffer_range (void)\n{\n  glewPrintExt(\"GL_ARB_texture_buffer_range\", GLEW_ARB_texture_buffer_range, glewIsSupported(\"GL_ARB_texture_buffer_range\"), glewGetExtension(\"GL_ARB_texture_buffer_range\"));\n\n  glewInfoFunc(\"glTexBufferRange\", glTexBufferRange == NULL);\n  glewInfoFunc(\"glTextureBufferRangeEXT\", glTextureBufferRangeEXT == NULL);\n}\n\n#endif /* GL_ARB_texture_buffer_range */\n\n#ifdef GL_ARB_texture_compression\n\nstatic void _glewInfo_GL_ARB_texture_compression (void)\n{\n  glewPrintExt(\"GL_ARB_texture_compression\", GLEW_ARB_texture_compression, glewIsSupported(\"GL_ARB_texture_compression\"), glewGetExtension(\"GL_ARB_texture_compression\"));\n\n  glewInfoFunc(\"glCompressedTexImage1DARB\", glCompressedTexImage1DARB == NULL);\n  glewInfoFunc(\"glCompressedTexImage2DARB\", glCompressedTexImage2DARB == NULL);\n  glewInfoFunc(\"glCompressedTexImage3DARB\", glCompressedTexImage3DARB == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage1DARB\", glCompressedTexSubImage1DARB == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage2DARB\", glCompressedTexSubImage2DARB == NULL);\n  glewInfoFunc(\"glCompressedTexSubImage3DARB\", glCompressedTexSubImage3DARB == NULL);\n  glewInfoFunc(\"glGetCompressedTexImageARB\", glGetCompressedTexImageARB == NULL);\n}\n\n#endif /* GL_ARB_texture_compression */\n\n#ifdef GL_ARB_texture_compression_bptc\n\nstatic void _glewInfo_GL_ARB_texture_compression_bptc (void)\n{\n  glewPrintExt(\"GL_ARB_texture_compression_bptc\", GLEW_ARB_texture_compression_bptc, glewIsSupported(\"GL_ARB_texture_compression_bptc\"), glewGetExtension(\"GL_ARB_texture_compression_bptc\"));\n}\n\n#endif /* GL_ARB_texture_compression_bptc */\n\n#ifdef GL_ARB_texture_compression_rgtc\n\nstatic void _glewInfo_GL_ARB_texture_compression_rgtc (void)\n{\n  glewPrintExt(\"GL_ARB_texture_compression_rgtc\", GLEW_ARB_texture_compression_rgtc, glewIsSupported(\"GL_ARB_texture_compression_rgtc\"), glewGetExtension(\"GL_ARB_texture_compression_rgtc\"));\n}\n\n#endif /* GL_ARB_texture_compression_rgtc */\n\n#ifdef GL_ARB_texture_cube_map\n\nstatic void _glewInfo_GL_ARB_texture_cube_map (void)\n{\n  glewPrintExt(\"GL_ARB_texture_cube_map\", GLEW_ARB_texture_cube_map, glewIsSupported(\"GL_ARB_texture_cube_map\"), glewGetExtension(\"GL_ARB_texture_cube_map\"));\n}\n\n#endif /* GL_ARB_texture_cube_map */\n\n#ifdef GL_ARB_texture_cube_map_array\n\nstatic void _glewInfo_GL_ARB_texture_cube_map_array (void)\n{\n  glewPrintExt(\"GL_ARB_texture_cube_map_array\", GLEW_ARB_texture_cube_map_array, glewIsSupported(\"GL_ARB_texture_cube_map_array\"), glewGetExtension(\"GL_ARB_texture_cube_map_array\"));\n}\n\n#endif /* GL_ARB_texture_cube_map_array */\n\n#ifdef GL_ARB_texture_env_add\n\nstatic void _glewInfo_GL_ARB_texture_env_add (void)\n{\n  glewPrintExt(\"GL_ARB_texture_env_add\", GLEW_ARB_texture_env_add, glewIsSupported(\"GL_ARB_texture_env_add\"), glewGetExtension(\"GL_ARB_texture_env_add\"));\n}\n\n#endif /* GL_ARB_texture_env_add */\n\n#ifdef GL_ARB_texture_env_combine\n\nstatic void _glewInfo_GL_ARB_texture_env_combine (void)\n{\n  glewPrintExt(\"GL_ARB_texture_env_combine\", GLEW_ARB_texture_env_combine, glewIsSupported(\"GL_ARB_texture_env_combine\"), glewGetExtension(\"GL_ARB_texture_env_combine\"));\n}\n\n#endif /* GL_ARB_texture_env_combine */\n\n#ifdef GL_ARB_texture_env_crossbar\n\nstatic void _glewInfo_GL_ARB_texture_env_crossbar (void)\n{\n  glewPrintExt(\"GL_ARB_texture_env_crossbar\", GLEW_ARB_texture_env_crossbar, glewIsSupported(\"GL_ARB_texture_env_crossbar\"), glewGetExtension(\"GL_ARB_texture_env_crossbar\"));\n}\n\n#endif /* GL_ARB_texture_env_crossbar */\n\n#ifdef GL_ARB_texture_env_dot3\n\nstatic void _glewInfo_GL_ARB_texture_env_dot3 (void)\n{\n  glewPrintExt(\"GL_ARB_texture_env_dot3\", GLEW_ARB_texture_env_dot3, glewIsSupported(\"GL_ARB_texture_env_dot3\"), glewGetExtension(\"GL_ARB_texture_env_dot3\"));\n}\n\n#endif /* GL_ARB_texture_env_dot3 */\n\n#ifdef GL_ARB_texture_float\n\nstatic void _glewInfo_GL_ARB_texture_float (void)\n{\n  glewPrintExt(\"GL_ARB_texture_float\", GLEW_ARB_texture_float, glewIsSupported(\"GL_ARB_texture_float\"), glewGetExtension(\"GL_ARB_texture_float\"));\n}\n\n#endif /* GL_ARB_texture_float */\n\n#ifdef GL_ARB_texture_gather\n\nstatic void _glewInfo_GL_ARB_texture_gather (void)\n{\n  glewPrintExt(\"GL_ARB_texture_gather\", GLEW_ARB_texture_gather, glewIsSupported(\"GL_ARB_texture_gather\"), glewGetExtension(\"GL_ARB_texture_gather\"));\n}\n\n#endif /* GL_ARB_texture_gather */\n\n#ifdef GL_ARB_texture_mirrored_repeat\n\nstatic void _glewInfo_GL_ARB_texture_mirrored_repeat (void)\n{\n  glewPrintExt(\"GL_ARB_texture_mirrored_repeat\", GLEW_ARB_texture_mirrored_repeat, glewIsSupported(\"GL_ARB_texture_mirrored_repeat\"), glewGetExtension(\"GL_ARB_texture_mirrored_repeat\"));\n}\n\n#endif /* GL_ARB_texture_mirrored_repeat */\n\n#ifdef GL_ARB_texture_multisample\n\nstatic void _glewInfo_GL_ARB_texture_multisample (void)\n{\n  glewPrintExt(\"GL_ARB_texture_multisample\", GLEW_ARB_texture_multisample, glewIsSupported(\"GL_ARB_texture_multisample\"), glewGetExtension(\"GL_ARB_texture_multisample\"));\n\n  glewInfoFunc(\"glGetMultisamplefv\", glGetMultisamplefv == NULL);\n  glewInfoFunc(\"glSampleMaski\", glSampleMaski == NULL);\n  glewInfoFunc(\"glTexImage2DMultisample\", glTexImage2DMultisample == NULL);\n  glewInfoFunc(\"glTexImage3DMultisample\", glTexImage3DMultisample == NULL);\n}\n\n#endif /* GL_ARB_texture_multisample */\n\n#ifdef GL_ARB_texture_non_power_of_two\n\nstatic void _glewInfo_GL_ARB_texture_non_power_of_two (void)\n{\n  glewPrintExt(\"GL_ARB_texture_non_power_of_two\", GLEW_ARB_texture_non_power_of_two, glewIsSupported(\"GL_ARB_texture_non_power_of_two\"), glewGetExtension(\"GL_ARB_texture_non_power_of_two\"));\n}\n\n#endif /* GL_ARB_texture_non_power_of_two */\n\n#ifdef GL_ARB_texture_query_levels\n\nstatic void _glewInfo_GL_ARB_texture_query_levels (void)\n{\n  glewPrintExt(\"GL_ARB_texture_query_levels\", GLEW_ARB_texture_query_levels, glewIsSupported(\"GL_ARB_texture_query_levels\"), glewGetExtension(\"GL_ARB_texture_query_levels\"));\n}\n\n#endif /* GL_ARB_texture_query_levels */\n\n#ifdef GL_ARB_texture_query_lod\n\nstatic void _glewInfo_GL_ARB_texture_query_lod (void)\n{\n  glewPrintExt(\"GL_ARB_texture_query_lod\", GLEW_ARB_texture_query_lod, glewIsSupported(\"GL_ARB_texture_query_lod\"), glewGetExtension(\"GL_ARB_texture_query_lod\"));\n}\n\n#endif /* GL_ARB_texture_query_lod */\n\n#ifdef GL_ARB_texture_rectangle\n\nstatic void _glewInfo_GL_ARB_texture_rectangle (void)\n{\n  glewPrintExt(\"GL_ARB_texture_rectangle\", GLEW_ARB_texture_rectangle, glewIsSupported(\"GL_ARB_texture_rectangle\"), glewGetExtension(\"GL_ARB_texture_rectangle\"));\n}\n\n#endif /* GL_ARB_texture_rectangle */\n\n#ifdef GL_ARB_texture_rg\n\nstatic void _glewInfo_GL_ARB_texture_rg (void)\n{\n  glewPrintExt(\"GL_ARB_texture_rg\", GLEW_ARB_texture_rg, glewIsSupported(\"GL_ARB_texture_rg\"), glewGetExtension(\"GL_ARB_texture_rg\"));\n}\n\n#endif /* GL_ARB_texture_rg */\n\n#ifdef GL_ARB_texture_rgb10_a2ui\n\nstatic void _glewInfo_GL_ARB_texture_rgb10_a2ui (void)\n{\n  glewPrintExt(\"GL_ARB_texture_rgb10_a2ui\", GLEW_ARB_texture_rgb10_a2ui, glewIsSupported(\"GL_ARB_texture_rgb10_a2ui\"), glewGetExtension(\"GL_ARB_texture_rgb10_a2ui\"));\n}\n\n#endif /* GL_ARB_texture_rgb10_a2ui */\n\n#ifdef GL_ARB_texture_storage\n\nstatic void _glewInfo_GL_ARB_texture_storage (void)\n{\n  glewPrintExt(\"GL_ARB_texture_storage\", GLEW_ARB_texture_storage, glewIsSupported(\"GL_ARB_texture_storage\"), glewGetExtension(\"GL_ARB_texture_storage\"));\n\n  glewInfoFunc(\"glTexStorage1D\", glTexStorage1D == NULL);\n  glewInfoFunc(\"glTexStorage2D\", glTexStorage2D == NULL);\n  glewInfoFunc(\"glTexStorage3D\", glTexStorage3D == NULL);\n  glewInfoFunc(\"glTextureStorage1DEXT\", glTextureStorage1DEXT == NULL);\n  glewInfoFunc(\"glTextureStorage2DEXT\", glTextureStorage2DEXT == NULL);\n  glewInfoFunc(\"glTextureStorage3DEXT\", glTextureStorage3DEXT == NULL);\n}\n\n#endif /* GL_ARB_texture_storage */\n\n#ifdef GL_ARB_texture_storage_multisample\n\nstatic void _glewInfo_GL_ARB_texture_storage_multisample (void)\n{\n  glewPrintExt(\"GL_ARB_texture_storage_multisample\", GLEW_ARB_texture_storage_multisample, glewIsSupported(\"GL_ARB_texture_storage_multisample\"), glewGetExtension(\"GL_ARB_texture_storage_multisample\"));\n\n  glewInfoFunc(\"glTexStorage2DMultisample\", glTexStorage2DMultisample == NULL);\n  glewInfoFunc(\"glTexStorage3DMultisample\", glTexStorage3DMultisample == NULL);\n  glewInfoFunc(\"glTextureStorage2DMultisampleEXT\", glTextureStorage2DMultisampleEXT == NULL);\n  glewInfoFunc(\"glTextureStorage3DMultisampleEXT\", glTextureStorage3DMultisampleEXT == NULL);\n}\n\n#endif /* GL_ARB_texture_storage_multisample */\n\n#ifdef GL_ARB_texture_swizzle\n\nstatic void _glewInfo_GL_ARB_texture_swizzle (void)\n{\n  glewPrintExt(\"GL_ARB_texture_swizzle\", GLEW_ARB_texture_swizzle, glewIsSupported(\"GL_ARB_texture_swizzle\"), glewGetExtension(\"GL_ARB_texture_swizzle\"));\n}\n\n#endif /* GL_ARB_texture_swizzle */\n\n#ifdef GL_ARB_texture_view\n\nstatic void _glewInfo_GL_ARB_texture_view (void)\n{\n  glewPrintExt(\"GL_ARB_texture_view\", GLEW_ARB_texture_view, glewIsSupported(\"GL_ARB_texture_view\"), glewGetExtension(\"GL_ARB_texture_view\"));\n\n  glewInfoFunc(\"glTextureView\", glTextureView == NULL);\n}\n\n#endif /* GL_ARB_texture_view */\n\n#ifdef GL_ARB_timer_query\n\nstatic void _glewInfo_GL_ARB_timer_query (void)\n{\n  glewPrintExt(\"GL_ARB_timer_query\", GLEW_ARB_timer_query, glewIsSupported(\"GL_ARB_timer_query\"), glewGetExtension(\"GL_ARB_timer_query\"));\n\n  glewInfoFunc(\"glGetQueryObjecti64v\", glGetQueryObjecti64v == NULL);\n  glewInfoFunc(\"glGetQueryObjectui64v\", glGetQueryObjectui64v == NULL);\n  glewInfoFunc(\"glQueryCounter\", glQueryCounter == NULL);\n}\n\n#endif /* GL_ARB_timer_query */\n\n#ifdef GL_ARB_transform_feedback2\n\nstatic void _glewInfo_GL_ARB_transform_feedback2 (void)\n{\n  glewPrintExt(\"GL_ARB_transform_feedback2\", GLEW_ARB_transform_feedback2, glewIsSupported(\"GL_ARB_transform_feedback2\"), glewGetExtension(\"GL_ARB_transform_feedback2\"));\n\n  glewInfoFunc(\"glBindTransformFeedback\", glBindTransformFeedback == NULL);\n  glewInfoFunc(\"glDeleteTransformFeedbacks\", glDeleteTransformFeedbacks == NULL);\n  glewInfoFunc(\"glDrawTransformFeedback\", glDrawTransformFeedback == NULL);\n  glewInfoFunc(\"glGenTransformFeedbacks\", glGenTransformFeedbacks == NULL);\n  glewInfoFunc(\"glIsTransformFeedback\", glIsTransformFeedback == NULL);\n  glewInfoFunc(\"glPauseTransformFeedback\", glPauseTransformFeedback == NULL);\n  glewInfoFunc(\"glResumeTransformFeedback\", glResumeTransformFeedback == NULL);\n}\n\n#endif /* GL_ARB_transform_feedback2 */\n\n#ifdef GL_ARB_transform_feedback3\n\nstatic void _glewInfo_GL_ARB_transform_feedback3 (void)\n{\n  glewPrintExt(\"GL_ARB_transform_feedback3\", GLEW_ARB_transform_feedback3, glewIsSupported(\"GL_ARB_transform_feedback3\"), glewGetExtension(\"GL_ARB_transform_feedback3\"));\n\n  glewInfoFunc(\"glBeginQueryIndexed\", glBeginQueryIndexed == NULL);\n  glewInfoFunc(\"glDrawTransformFeedbackStream\", glDrawTransformFeedbackStream == NULL);\n  glewInfoFunc(\"glEndQueryIndexed\", glEndQueryIndexed == NULL);\n  glewInfoFunc(\"glGetQueryIndexediv\", glGetQueryIndexediv == NULL);\n}\n\n#endif /* GL_ARB_transform_feedback3 */\n\n#ifdef GL_ARB_transform_feedback_instanced\n\nstatic void _glewInfo_GL_ARB_transform_feedback_instanced (void)\n{\n  glewPrintExt(\"GL_ARB_transform_feedback_instanced\", GLEW_ARB_transform_feedback_instanced, glewIsSupported(\"GL_ARB_transform_feedback_instanced\"), glewGetExtension(\"GL_ARB_transform_feedback_instanced\"));\n\n  glewInfoFunc(\"glDrawTransformFeedbackInstanced\", glDrawTransformFeedbackInstanced == NULL);\n  glewInfoFunc(\"glDrawTransformFeedbackStreamInstanced\", glDrawTransformFeedbackStreamInstanced == NULL);\n}\n\n#endif /* GL_ARB_transform_feedback_instanced */\n\n#ifdef GL_ARB_transpose_matrix\n\nstatic void _glewInfo_GL_ARB_transpose_matrix (void)\n{\n  glewPrintExt(\"GL_ARB_transpose_matrix\", GLEW_ARB_transpose_matrix, glewIsSupported(\"GL_ARB_transpose_matrix\"), glewGetExtension(\"GL_ARB_transpose_matrix\"));\n\n  glewInfoFunc(\"glLoadTransposeMatrixdARB\", glLoadTransposeMatrixdARB == NULL);\n  glewInfoFunc(\"glLoadTransposeMatrixfARB\", glLoadTransposeMatrixfARB == NULL);\n  glewInfoFunc(\"glMultTransposeMatrixdARB\", glMultTransposeMatrixdARB == NULL);\n  glewInfoFunc(\"glMultTransposeMatrixfARB\", glMultTransposeMatrixfARB == NULL);\n}\n\n#endif /* GL_ARB_transpose_matrix */\n\n#ifdef GL_ARB_uniform_buffer_object\n\nstatic void _glewInfo_GL_ARB_uniform_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_uniform_buffer_object\", GLEW_ARB_uniform_buffer_object, glewIsSupported(\"GL_ARB_uniform_buffer_object\"), glewGetExtension(\"GL_ARB_uniform_buffer_object\"));\n\n  glewInfoFunc(\"glBindBufferBase\", glBindBufferBase == NULL);\n  glewInfoFunc(\"glBindBufferRange\", glBindBufferRange == NULL);\n  glewInfoFunc(\"glGetActiveUniformBlockName\", glGetActiveUniformBlockName == NULL);\n  glewInfoFunc(\"glGetActiveUniformBlockiv\", glGetActiveUniformBlockiv == NULL);\n  glewInfoFunc(\"glGetActiveUniformName\", glGetActiveUniformName == NULL);\n  glewInfoFunc(\"glGetActiveUniformsiv\", glGetActiveUniformsiv == NULL);\n  glewInfoFunc(\"glGetIntegeri_v\", glGetIntegeri_v == NULL);\n  glewInfoFunc(\"glGetUniformBlockIndex\", glGetUniformBlockIndex == NULL);\n  glewInfoFunc(\"glGetUniformIndices\", glGetUniformIndices == NULL);\n  glewInfoFunc(\"glUniformBlockBinding\", glUniformBlockBinding == NULL);\n}\n\n#endif /* GL_ARB_uniform_buffer_object */\n\n#ifdef GL_ARB_vertex_array_bgra\n\nstatic void _glewInfo_GL_ARB_vertex_array_bgra (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_array_bgra\", GLEW_ARB_vertex_array_bgra, glewIsSupported(\"GL_ARB_vertex_array_bgra\"), glewGetExtension(\"GL_ARB_vertex_array_bgra\"));\n}\n\n#endif /* GL_ARB_vertex_array_bgra */\n\n#ifdef GL_ARB_vertex_array_object\n\nstatic void _glewInfo_GL_ARB_vertex_array_object (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_array_object\", GLEW_ARB_vertex_array_object, glewIsSupported(\"GL_ARB_vertex_array_object\"), glewGetExtension(\"GL_ARB_vertex_array_object\"));\n\n  glewInfoFunc(\"glBindVertexArray\", glBindVertexArray == NULL);\n  glewInfoFunc(\"glDeleteVertexArrays\", glDeleteVertexArrays == NULL);\n  glewInfoFunc(\"glGenVertexArrays\", glGenVertexArrays == NULL);\n  glewInfoFunc(\"glIsVertexArray\", glIsVertexArray == NULL);\n}\n\n#endif /* GL_ARB_vertex_array_object */\n\n#ifdef GL_ARB_vertex_attrib_64bit\n\nstatic void _glewInfo_GL_ARB_vertex_attrib_64bit (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_attrib_64bit\", GLEW_ARB_vertex_attrib_64bit, glewIsSupported(\"GL_ARB_vertex_attrib_64bit\"), glewGetExtension(\"GL_ARB_vertex_attrib_64bit\"));\n\n  glewInfoFunc(\"glGetVertexAttribLdv\", glGetVertexAttribLdv == NULL);\n  glewInfoFunc(\"glVertexAttribL1d\", glVertexAttribL1d == NULL);\n  glewInfoFunc(\"glVertexAttribL1dv\", glVertexAttribL1dv == NULL);\n  glewInfoFunc(\"glVertexAttribL2d\", glVertexAttribL2d == NULL);\n  glewInfoFunc(\"glVertexAttribL2dv\", glVertexAttribL2dv == NULL);\n  glewInfoFunc(\"glVertexAttribL3d\", glVertexAttribL3d == NULL);\n  glewInfoFunc(\"glVertexAttribL3dv\", glVertexAttribL3dv == NULL);\n  glewInfoFunc(\"glVertexAttribL4d\", glVertexAttribL4d == NULL);\n  glewInfoFunc(\"glVertexAttribL4dv\", glVertexAttribL4dv == NULL);\n  glewInfoFunc(\"glVertexAttribLPointer\", glVertexAttribLPointer == NULL);\n}\n\n#endif /* GL_ARB_vertex_attrib_64bit */\n\n#ifdef GL_ARB_vertex_attrib_binding\n\nstatic void _glewInfo_GL_ARB_vertex_attrib_binding (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_attrib_binding\", GLEW_ARB_vertex_attrib_binding, glewIsSupported(\"GL_ARB_vertex_attrib_binding\"), glewGetExtension(\"GL_ARB_vertex_attrib_binding\"));\n\n  glewInfoFunc(\"glBindVertexBuffer\", glBindVertexBuffer == NULL);\n  glewInfoFunc(\"glVertexAttribBinding\", glVertexAttribBinding == NULL);\n  glewInfoFunc(\"glVertexAttribFormat\", glVertexAttribFormat == NULL);\n  glewInfoFunc(\"glVertexAttribIFormat\", glVertexAttribIFormat == NULL);\n  glewInfoFunc(\"glVertexAttribLFormat\", glVertexAttribLFormat == NULL);\n  glewInfoFunc(\"glVertexBindingDivisor\", glVertexBindingDivisor == NULL);\n}\n\n#endif /* GL_ARB_vertex_attrib_binding */\n\n#ifdef GL_ARB_vertex_blend\n\nstatic void _glewInfo_GL_ARB_vertex_blend (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_blend\", GLEW_ARB_vertex_blend, glewIsSupported(\"GL_ARB_vertex_blend\"), glewGetExtension(\"GL_ARB_vertex_blend\"));\n\n  glewInfoFunc(\"glVertexBlendARB\", glVertexBlendARB == NULL);\n  glewInfoFunc(\"glWeightPointerARB\", glWeightPointerARB == NULL);\n  glewInfoFunc(\"glWeightbvARB\", glWeightbvARB == NULL);\n  glewInfoFunc(\"glWeightdvARB\", glWeightdvARB == NULL);\n  glewInfoFunc(\"glWeightfvARB\", glWeightfvARB == NULL);\n  glewInfoFunc(\"glWeightivARB\", glWeightivARB == NULL);\n  glewInfoFunc(\"glWeightsvARB\", glWeightsvARB == NULL);\n  glewInfoFunc(\"glWeightubvARB\", glWeightubvARB == NULL);\n  glewInfoFunc(\"glWeightuivARB\", glWeightuivARB == NULL);\n  glewInfoFunc(\"glWeightusvARB\", glWeightusvARB == NULL);\n}\n\n#endif /* GL_ARB_vertex_blend */\n\n#ifdef GL_ARB_vertex_buffer_object\n\nstatic void _glewInfo_GL_ARB_vertex_buffer_object (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_buffer_object\", GLEW_ARB_vertex_buffer_object, glewIsSupported(\"GL_ARB_vertex_buffer_object\"), glewGetExtension(\"GL_ARB_vertex_buffer_object\"));\n\n  glewInfoFunc(\"glBindBufferARB\", glBindBufferARB == NULL);\n  glewInfoFunc(\"glBufferDataARB\", glBufferDataARB == NULL);\n  glewInfoFunc(\"glBufferSubDataARB\", glBufferSubDataARB == NULL);\n  glewInfoFunc(\"glDeleteBuffersARB\", glDeleteBuffersARB == NULL);\n  glewInfoFunc(\"glGenBuffersARB\", glGenBuffersARB == NULL);\n  glewInfoFunc(\"glGetBufferParameterivARB\", glGetBufferParameterivARB == NULL);\n  glewInfoFunc(\"glGetBufferPointervARB\", glGetBufferPointervARB == NULL);\n  glewInfoFunc(\"glGetBufferSubDataARB\", glGetBufferSubDataARB == NULL);\n  glewInfoFunc(\"glIsBufferARB\", glIsBufferARB == NULL);\n  glewInfoFunc(\"glMapBufferARB\", glMapBufferARB == NULL);\n  glewInfoFunc(\"glUnmapBufferARB\", glUnmapBufferARB == NULL);\n}\n\n#endif /* GL_ARB_vertex_buffer_object */\n\n#ifdef GL_ARB_vertex_program\n\nstatic void _glewInfo_GL_ARB_vertex_program (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_program\", GLEW_ARB_vertex_program, glewIsSupported(\"GL_ARB_vertex_program\"), glewGetExtension(\"GL_ARB_vertex_program\"));\n\n  glewInfoFunc(\"glBindProgramARB\", glBindProgramARB == NULL);\n  glewInfoFunc(\"glDeleteProgramsARB\", glDeleteProgramsARB == NULL);\n  glewInfoFunc(\"glDisableVertexAttribArrayARB\", glDisableVertexAttribArrayARB == NULL);\n  glewInfoFunc(\"glEnableVertexAttribArrayARB\", glEnableVertexAttribArrayARB == NULL);\n  glewInfoFunc(\"glGenProgramsARB\", glGenProgramsARB == NULL);\n  glewInfoFunc(\"glGetProgramEnvParameterdvARB\", glGetProgramEnvParameterdvARB == NULL);\n  glewInfoFunc(\"glGetProgramEnvParameterfvARB\", glGetProgramEnvParameterfvARB == NULL);\n  glewInfoFunc(\"glGetProgramLocalParameterdvARB\", glGetProgramLocalParameterdvARB == NULL);\n  glewInfoFunc(\"glGetProgramLocalParameterfvARB\", glGetProgramLocalParameterfvARB == NULL);\n  glewInfoFunc(\"glGetProgramStringARB\", glGetProgramStringARB == NULL);\n  glewInfoFunc(\"glGetProgramivARB\", glGetProgramivARB == NULL);\n  glewInfoFunc(\"glGetVertexAttribPointervARB\", glGetVertexAttribPointervARB == NULL);\n  glewInfoFunc(\"glGetVertexAttribdvARB\", glGetVertexAttribdvARB == NULL);\n  glewInfoFunc(\"glGetVertexAttribfvARB\", glGetVertexAttribfvARB == NULL);\n  glewInfoFunc(\"glGetVertexAttribivARB\", glGetVertexAttribivARB == NULL);\n  glewInfoFunc(\"glIsProgramARB\", glIsProgramARB == NULL);\n  glewInfoFunc(\"glProgramEnvParameter4dARB\", glProgramEnvParameter4dARB == NULL);\n  glewInfoFunc(\"glProgramEnvParameter4dvARB\", glProgramEnvParameter4dvARB == NULL);\n  glewInfoFunc(\"glProgramEnvParameter4fARB\", glProgramEnvParameter4fARB == NULL);\n  glewInfoFunc(\"glProgramEnvParameter4fvARB\", glProgramEnvParameter4fvARB == NULL);\n  glewInfoFunc(\"glProgramLocalParameter4dARB\", glProgramLocalParameter4dARB == NULL);\n  glewInfoFunc(\"glProgramLocalParameter4dvARB\", glProgramLocalParameter4dvARB == NULL);\n  glewInfoFunc(\"glProgramLocalParameter4fARB\", glProgramLocalParameter4fARB == NULL);\n  glewInfoFunc(\"glProgramLocalParameter4fvARB\", glProgramLocalParameter4fvARB == NULL);\n  glewInfoFunc(\"glProgramStringARB\", glProgramStringARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1dARB\", glVertexAttrib1dARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1dvARB\", glVertexAttrib1dvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1fARB\", glVertexAttrib1fARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1fvARB\", glVertexAttrib1fvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1sARB\", glVertexAttrib1sARB == NULL);\n  glewInfoFunc(\"glVertexAttrib1svARB\", glVertexAttrib1svARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2dARB\", glVertexAttrib2dARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2dvARB\", glVertexAttrib2dvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2fARB\", glVertexAttrib2fARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2fvARB\", glVertexAttrib2fvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2sARB\", glVertexAttrib2sARB == NULL);\n  glewInfoFunc(\"glVertexAttrib2svARB\", glVertexAttrib2svARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3dARB\", glVertexAttrib3dARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3dvARB\", glVertexAttrib3dvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3fARB\", glVertexAttrib3fARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3fvARB\", glVertexAttrib3fvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3sARB\", glVertexAttrib3sARB == NULL);\n  glewInfoFunc(\"glVertexAttrib3svARB\", glVertexAttrib3svARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NbvARB\", glVertexAttrib4NbvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NivARB\", glVertexAttrib4NivARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NsvARB\", glVertexAttrib4NsvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NubARB\", glVertexAttrib4NubARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NubvARB\", glVertexAttrib4NubvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NuivARB\", glVertexAttrib4NuivARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4NusvARB\", glVertexAttrib4NusvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4bvARB\", glVertexAttrib4bvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4dARB\", glVertexAttrib4dARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4dvARB\", glVertexAttrib4dvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4fARB\", glVertexAttrib4fARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4fvARB\", glVertexAttrib4fvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4ivARB\", glVertexAttrib4ivARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4sARB\", glVertexAttrib4sARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4svARB\", glVertexAttrib4svARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4ubvARB\", glVertexAttrib4ubvARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4uivARB\", glVertexAttrib4uivARB == NULL);\n  glewInfoFunc(\"glVertexAttrib4usvARB\", glVertexAttrib4usvARB == NULL);\n  glewInfoFunc(\"glVertexAttribPointerARB\", glVertexAttribPointerARB == NULL);\n}\n\n#endif /* GL_ARB_vertex_program */\n\n#ifdef GL_ARB_vertex_shader\n\nstatic void _glewInfo_GL_ARB_vertex_shader (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_shader\", GLEW_ARB_vertex_shader, glewIsSupported(\"GL_ARB_vertex_shader\"), glewGetExtension(\"GL_ARB_vertex_shader\"));\n\n  glewInfoFunc(\"glBindAttribLocationARB\", glBindAttribLocationARB == NULL);\n  glewInfoFunc(\"glGetActiveAttribARB\", glGetActiveAttribARB == NULL);\n  glewInfoFunc(\"glGetAttribLocationARB\", glGetAttribLocationARB == NULL);\n}\n\n#endif /* GL_ARB_vertex_shader */\n\n#ifdef GL_ARB_vertex_type_2_10_10_10_rev\n\nstatic void _glewInfo_GL_ARB_vertex_type_2_10_10_10_rev (void)\n{\n  glewPrintExt(\"GL_ARB_vertex_type_2_10_10_10_rev\", GLEW_ARB_vertex_type_2_10_10_10_rev, glewIsSupported(\"GL_ARB_vertex_type_2_10_10_10_rev\"), glewGetExtension(\"GL_ARB_vertex_type_2_10_10_10_rev\"));\n\n  glewInfoFunc(\"glColorP3ui\", glColorP3ui == NULL);\n  glewInfoFunc(\"glColorP3uiv\", glColorP3uiv == NULL);\n  glewInfoFunc(\"glColorP4ui\", glColorP4ui == NULL);\n  glewInfoFunc(\"glColorP4uiv\", glColorP4uiv == NULL);\n  glewInfoFunc(\"glMultiTexCoordP1ui\", glMultiTexCoordP1ui == NULL);\n  glewInfoFunc(\"glMultiTexCoordP1uiv\", glMultiTexCoordP1uiv == NULL);\n  glewInfoFunc(\"glMultiTexCoordP2ui\", glMultiTexCoordP2ui == NULL);\n  glewInfoFunc(\"glMultiTexCoordP2uiv\", glMultiTexCoordP2uiv == NULL);\n  glewInfoFunc(\"glMultiTexCoordP3ui\", glMultiTexCoordP3ui == NULL);\n  glewInfoFunc(\"glMultiTexCoordP3uiv\", glMultiTexCoordP3uiv == NULL);\n  glewInfoFunc(\"glMultiTexCoordP4ui\", glMultiTexCoordP4ui == NULL);\n  glewInfoFunc(\"glMultiTexCoordP4uiv\", glMultiTexCoordP4uiv == NULL);\n  glewInfoFunc(\"glNormalP3ui\", glNormalP3ui == NULL);\n  glewInfoFunc(\"glNormalP3uiv\", glNormalP3uiv == NULL);\n  glewInfoFunc(\"glSecondaryColorP3ui\", glSecondaryColorP3ui == NULL);\n  glewInfoFunc(\"glSecondaryColorP3uiv\", glSecondaryColorP3uiv == NULL);\n  glewInfoFunc(\"glTexCoordP1ui\", glTexCoordP1ui == NULL);\n  glewInfoFunc(\"glTexCoordP1uiv\", glTexCoordP1uiv == NULL);\n  glewInfoFunc(\"glTexCoordP2ui\", glTexCoordP2ui == NULL);\n  glewInfoFunc(\"glTexCoordP2uiv\", glTexCoordP2uiv == NULL);\n  glewInfoFunc(\"glTexCoordP3ui\", glTexCoordP3ui == NULL);\n  glewInfoFunc(\"glTexCoordP3uiv\", glTexCoordP3uiv == NULL);\n  glewInfoFunc(\"glTexCoordP4ui\", glTexCoordP4ui == NULL);\n  glewInfoFunc(\"glTexCoordP4uiv\", glTexCoordP4uiv == NULL);\n  glewInfoFunc(\"glVertexAttribP1ui\", glVertexAttribP1ui == NULL);\n  glewInfoFunc(\"glVertexAttribP1uiv\", glVertexAttribP1uiv == NULL);\n  glewInfoFunc(\"glVertexAttribP2ui\", glVertexAttribP2ui == NULL);\n  glewInfoFunc(\"glVertexAttribP2uiv\", glVertexAttribP2uiv == NULL);\n  glewInfoFunc(\"glVertexAttribP3ui\", glVertexAttribP3ui == NULL);\n  glewInfoFunc(\"glVertexAttribP3uiv\", glVertexAttribP3uiv == NULL);\n  glewInfoFunc(\"glVertexAttribP4ui\", glVertexAttribP4ui == NULL);\n  glewInfoFunc(\"glVertexAttribP4uiv\", glVertexAttribP4uiv == NULL);\n  glewInfoFunc(\"glVertexP2ui\", glVertexP2ui == NULL);\n  glewInfoFunc(\"glVertexP2uiv\", glVertexP2uiv == NULL);\n  glewInfoFunc(\"glVertexP3ui\", glVertexP3ui == NULL);\n  glewInfoFunc(\"glVertexP3uiv\", glVertexP3uiv == NULL);\n  glewInfoFunc(\"glVertexP4ui\", glVertexP4ui == NULL);\n  glewInfoFunc(\"glVertexP4uiv\", glVertexP4uiv == NULL);\n}\n\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n\n#ifdef GL_ARB_viewport_array\n\nstatic void _glewInfo_GL_ARB_viewport_array (void)\n{\n  glewPrintExt(\"GL_ARB_viewport_array\", GLEW_ARB_viewport_array, glewIsSupported(\"GL_ARB_viewport_array\"), glewGetExtension(\"GL_ARB_viewport_array\"));\n\n  glewInfoFunc(\"glDepthRangeArrayv\", glDepthRangeArrayv == NULL);\n  glewInfoFunc(\"glDepthRangeIndexed\", glDepthRangeIndexed == NULL);\n  glewInfoFunc(\"glGetDoublei_v\", glGetDoublei_v == NULL);\n  glewInfoFunc(\"glGetFloati_v\", glGetFloati_v == NULL);\n  glewInfoFunc(\"glScissorArrayv\", glScissorArrayv == NULL);\n  glewInfoFunc(\"glScissorIndexed\", glScissorIndexed == NULL);\n  glewInfoFunc(\"glScissorIndexedv\", glScissorIndexedv == NULL);\n  glewInfoFunc(\"glViewportArrayv\", glViewportArrayv == NULL);\n  glewInfoFunc(\"glViewportIndexedf\", glViewportIndexedf == NULL);\n  glewInfoFunc(\"glViewportIndexedfv\", glViewportIndexedfv == NULL);\n}\n\n#endif /* GL_ARB_viewport_array */\n\n#ifdef GL_ARB_window_pos\n\nstatic void _glewInfo_GL_ARB_window_pos (void)\n{\n  glewPrintExt(\"GL_ARB_window_pos\", GLEW_ARB_window_pos, glewIsSupported(\"GL_ARB_window_pos\"), glewGetExtension(\"GL_ARB_window_pos\"));\n\n  glewInfoFunc(\"glWindowPos2dARB\", glWindowPos2dARB == NULL);\n  glewInfoFunc(\"glWindowPos2dvARB\", glWindowPos2dvARB == NULL);\n  glewInfoFunc(\"glWindowPos2fARB\", glWindowPos2fARB == NULL);\n  glewInfoFunc(\"glWindowPos2fvARB\", glWindowPos2fvARB == NULL);\n  glewInfoFunc(\"glWindowPos2iARB\", glWindowPos2iARB == NULL);\n  glewInfoFunc(\"glWindowPos2ivARB\", glWindowPos2ivARB == NULL);\n  glewInfoFunc(\"glWindowPos2sARB\", glWindowPos2sARB == NULL);\n  glewInfoFunc(\"glWindowPos2svARB\", glWindowPos2svARB == NULL);\n  glewInfoFunc(\"glWindowPos3dARB\", glWindowPos3dARB == NULL);\n  glewInfoFunc(\"glWindowPos3dvARB\", glWindowPos3dvARB == NULL);\n  glewInfoFunc(\"glWindowPos3fARB\", glWindowPos3fARB == NULL);\n  glewInfoFunc(\"glWindowPos3fvARB\", glWindowPos3fvARB == NULL);\n  glewInfoFunc(\"glWindowPos3iARB\", glWindowPos3iARB == NULL);\n  glewInfoFunc(\"glWindowPos3ivARB\", glWindowPos3ivARB == NULL);\n  glewInfoFunc(\"glWindowPos3sARB\", glWindowPos3sARB == NULL);\n  glewInfoFunc(\"glWindowPos3svARB\", glWindowPos3svARB == NULL);\n}\n\n#endif /* GL_ARB_window_pos */\n\n#ifdef GL_ATIX_point_sprites\n\nstatic void _glewInfo_GL_ATIX_point_sprites (void)\n{\n  glewPrintExt(\"GL_ATIX_point_sprites\", GLEW_ATIX_point_sprites, glewIsSupported(\"GL_ATIX_point_sprites\"), glewGetExtension(\"GL_ATIX_point_sprites\"));\n}\n\n#endif /* GL_ATIX_point_sprites */\n\n#ifdef GL_ATIX_texture_env_combine3\n\nstatic void _glewInfo_GL_ATIX_texture_env_combine3 (void)\n{\n  glewPrintExt(\"GL_ATIX_texture_env_combine3\", GLEW_ATIX_texture_env_combine3, glewIsSupported(\"GL_ATIX_texture_env_combine3\"), glewGetExtension(\"GL_ATIX_texture_env_combine3\"));\n}\n\n#endif /* GL_ATIX_texture_env_combine3 */\n\n#ifdef GL_ATIX_texture_env_route\n\nstatic void _glewInfo_GL_ATIX_texture_env_route (void)\n{\n  glewPrintExt(\"GL_ATIX_texture_env_route\", GLEW_ATIX_texture_env_route, glewIsSupported(\"GL_ATIX_texture_env_route\"), glewGetExtension(\"GL_ATIX_texture_env_route\"));\n}\n\n#endif /* GL_ATIX_texture_env_route */\n\n#ifdef GL_ATIX_vertex_shader_output_point_size\n\nstatic void _glewInfo_GL_ATIX_vertex_shader_output_point_size (void)\n{\n  glewPrintExt(\"GL_ATIX_vertex_shader_output_point_size\", GLEW_ATIX_vertex_shader_output_point_size, glewIsSupported(\"GL_ATIX_vertex_shader_output_point_size\"), glewGetExtension(\"GL_ATIX_vertex_shader_output_point_size\"));\n}\n\n#endif /* GL_ATIX_vertex_shader_output_point_size */\n\n#ifdef GL_ATI_draw_buffers\n\nstatic void _glewInfo_GL_ATI_draw_buffers (void)\n{\n  glewPrintExt(\"GL_ATI_draw_buffers\", GLEW_ATI_draw_buffers, glewIsSupported(\"GL_ATI_draw_buffers\"), glewGetExtension(\"GL_ATI_draw_buffers\"));\n\n  glewInfoFunc(\"glDrawBuffersATI\", glDrawBuffersATI == NULL);\n}\n\n#endif /* GL_ATI_draw_buffers */\n\n#ifdef GL_ATI_element_array\n\nstatic void _glewInfo_GL_ATI_element_array (void)\n{\n  glewPrintExt(\"GL_ATI_element_array\", GLEW_ATI_element_array, glewIsSupported(\"GL_ATI_element_array\"), glewGetExtension(\"GL_ATI_element_array\"));\n\n  glewInfoFunc(\"glDrawElementArrayATI\", glDrawElementArrayATI == NULL);\n  glewInfoFunc(\"glDrawRangeElementArrayATI\", glDrawRangeElementArrayATI == NULL);\n  glewInfoFunc(\"glElementPointerATI\", glElementPointerATI == NULL);\n}\n\n#endif /* GL_ATI_element_array */\n\n#ifdef GL_ATI_envmap_bumpmap\n\nstatic void _glewInfo_GL_ATI_envmap_bumpmap (void)\n{\n  glewPrintExt(\"GL_ATI_envmap_bumpmap\", GLEW_ATI_envmap_bumpmap, glewIsSupported(\"GL_ATI_envmap_bumpmap\"), glewGetExtension(\"GL_ATI_envmap_bumpmap\"));\n\n  glewInfoFunc(\"glGetTexBumpParameterfvATI\", glGetTexBumpParameterfvATI == NULL);\n  glewInfoFunc(\"glGetTexBumpParameterivATI\", glGetTexBumpParameterivATI == NULL);\n  glewInfoFunc(\"glTexBumpParameterfvATI\", glTexBumpParameterfvATI == NULL);\n  glewInfoFunc(\"glTexBumpParameterivATI\", glTexBumpParameterivATI == NULL);\n}\n\n#endif /* GL_ATI_envmap_bumpmap */\n\n#ifdef GL_ATI_fragment_shader\n\nstatic void _glewInfo_GL_ATI_fragment_shader (void)\n{\n  glewPrintExt(\"GL_ATI_fragment_shader\", GLEW_ATI_fragment_shader, glewIsSupported(\"GL_ATI_fragment_shader\"), glewGetExtension(\"GL_ATI_fragment_shader\"));\n\n  glewInfoFunc(\"glAlphaFragmentOp1ATI\", glAlphaFragmentOp1ATI == NULL);\n  glewInfoFunc(\"glAlphaFragmentOp2ATI\", glAlphaFragmentOp2ATI == NULL);\n  glewInfoFunc(\"glAlphaFragmentOp3ATI\", glAlphaFragmentOp3ATI == NULL);\n  glewInfoFunc(\"glBeginFragmentShaderATI\", glBeginFragmentShaderATI == NULL);\n  glewInfoFunc(\"glBindFragmentShaderATI\", glBindFragmentShaderATI == NULL);\n  glewInfoFunc(\"glColorFragmentOp1ATI\", glColorFragmentOp1ATI == NULL);\n  glewInfoFunc(\"glColorFragmentOp2ATI\", glColorFragmentOp2ATI == NULL);\n  glewInfoFunc(\"glColorFragmentOp3ATI\", glColorFragmentOp3ATI == NULL);\n  glewInfoFunc(\"glDeleteFragmentShaderATI\", glDeleteFragmentShaderATI == NULL);\n  glewInfoFunc(\"glEndFragmentShaderATI\", glEndFragmentShaderATI == NULL);\n  glewInfoFunc(\"glGenFragmentShadersATI\", glGenFragmentShadersATI == NULL);\n  glewInfoFunc(\"glPassTexCoordATI\", glPassTexCoordATI == NULL);\n  glewInfoFunc(\"glSampleMapATI\", glSampleMapATI == NULL);\n  glewInfoFunc(\"glSetFragmentShaderConstantATI\", glSetFragmentShaderConstantATI == NULL);\n}\n\n#endif /* GL_ATI_fragment_shader */\n\n#ifdef GL_ATI_map_object_buffer\n\nstatic void _glewInfo_GL_ATI_map_object_buffer (void)\n{\n  glewPrintExt(\"GL_ATI_map_object_buffer\", GLEW_ATI_map_object_buffer, glewIsSupported(\"GL_ATI_map_object_buffer\"), glewGetExtension(\"GL_ATI_map_object_buffer\"));\n\n  glewInfoFunc(\"glMapObjectBufferATI\", glMapObjectBufferATI == NULL);\n  glewInfoFunc(\"glUnmapObjectBufferATI\", glUnmapObjectBufferATI == NULL);\n}\n\n#endif /* GL_ATI_map_object_buffer */\n\n#ifdef GL_ATI_meminfo\n\nstatic void _glewInfo_GL_ATI_meminfo (void)\n{\n  glewPrintExt(\"GL_ATI_meminfo\", GLEW_ATI_meminfo, glewIsSupported(\"GL_ATI_meminfo\"), glewGetExtension(\"GL_ATI_meminfo\"));\n}\n\n#endif /* GL_ATI_meminfo */\n\n#ifdef GL_ATI_pn_triangles\n\nstatic void _glewInfo_GL_ATI_pn_triangles (void)\n{\n  glewPrintExt(\"GL_ATI_pn_triangles\", GLEW_ATI_pn_triangles, glewIsSupported(\"GL_ATI_pn_triangles\"), glewGetExtension(\"GL_ATI_pn_triangles\"));\n\n  glewInfoFunc(\"glPNTrianglesfATI\", glPNTrianglesfATI == NULL);\n  glewInfoFunc(\"glPNTrianglesiATI\", glPNTrianglesiATI == NULL);\n}\n\n#endif /* GL_ATI_pn_triangles */\n\n#ifdef GL_ATI_separate_stencil\n\nstatic void _glewInfo_GL_ATI_separate_stencil (void)\n{\n  glewPrintExt(\"GL_ATI_separate_stencil\", GLEW_ATI_separate_stencil, glewIsSupported(\"GL_ATI_separate_stencil\"), glewGetExtension(\"GL_ATI_separate_stencil\"));\n\n  glewInfoFunc(\"glStencilFuncSeparateATI\", glStencilFuncSeparateATI == NULL);\n  glewInfoFunc(\"glStencilOpSeparateATI\", glStencilOpSeparateATI == NULL);\n}\n\n#endif /* GL_ATI_separate_stencil */\n\n#ifdef GL_ATI_shader_texture_lod\n\nstatic void _glewInfo_GL_ATI_shader_texture_lod (void)\n{\n  glewPrintExt(\"GL_ATI_shader_texture_lod\", GLEW_ATI_shader_texture_lod, glewIsSupported(\"GL_ATI_shader_texture_lod\"), glewGetExtension(\"GL_ATI_shader_texture_lod\"));\n}\n\n#endif /* GL_ATI_shader_texture_lod */\n\n#ifdef GL_ATI_text_fragment_shader\n\nstatic void _glewInfo_GL_ATI_text_fragment_shader (void)\n{\n  glewPrintExt(\"GL_ATI_text_fragment_shader\", GLEW_ATI_text_fragment_shader, glewIsSupported(\"GL_ATI_text_fragment_shader\"), glewGetExtension(\"GL_ATI_text_fragment_shader\"));\n}\n\n#endif /* GL_ATI_text_fragment_shader */\n\n#ifdef GL_ATI_texture_compression_3dc\n\nstatic void _glewInfo_GL_ATI_texture_compression_3dc (void)\n{\n  glewPrintExt(\"GL_ATI_texture_compression_3dc\", GLEW_ATI_texture_compression_3dc, glewIsSupported(\"GL_ATI_texture_compression_3dc\"), glewGetExtension(\"GL_ATI_texture_compression_3dc\"));\n}\n\n#endif /* GL_ATI_texture_compression_3dc */\n\n#ifdef GL_ATI_texture_env_combine3\n\nstatic void _glewInfo_GL_ATI_texture_env_combine3 (void)\n{\n  glewPrintExt(\"GL_ATI_texture_env_combine3\", GLEW_ATI_texture_env_combine3, glewIsSupported(\"GL_ATI_texture_env_combine3\"), glewGetExtension(\"GL_ATI_texture_env_combine3\"));\n}\n\n#endif /* GL_ATI_texture_env_combine3 */\n\n#ifdef GL_ATI_texture_float\n\nstatic void _glewInfo_GL_ATI_texture_float (void)\n{\n  glewPrintExt(\"GL_ATI_texture_float\", GLEW_ATI_texture_float, glewIsSupported(\"GL_ATI_texture_float\"), glewGetExtension(\"GL_ATI_texture_float\"));\n}\n\n#endif /* GL_ATI_texture_float */\n\n#ifdef GL_ATI_texture_mirror_once\n\nstatic void _glewInfo_GL_ATI_texture_mirror_once (void)\n{\n  glewPrintExt(\"GL_ATI_texture_mirror_once\", GLEW_ATI_texture_mirror_once, glewIsSupported(\"GL_ATI_texture_mirror_once\"), glewGetExtension(\"GL_ATI_texture_mirror_once\"));\n}\n\n#endif /* GL_ATI_texture_mirror_once */\n\n#ifdef GL_ATI_vertex_array_object\n\nstatic void _glewInfo_GL_ATI_vertex_array_object (void)\n{\n  glewPrintExt(\"GL_ATI_vertex_array_object\", GLEW_ATI_vertex_array_object, glewIsSupported(\"GL_ATI_vertex_array_object\"), glewGetExtension(\"GL_ATI_vertex_array_object\"));\n\n  glewInfoFunc(\"glArrayObjectATI\", glArrayObjectATI == NULL);\n  glewInfoFunc(\"glFreeObjectBufferATI\", glFreeObjectBufferATI == NULL);\n  glewInfoFunc(\"glGetArrayObjectfvATI\", glGetArrayObjectfvATI == NULL);\n  glewInfoFunc(\"glGetArrayObjectivATI\", glGetArrayObjectivATI == NULL);\n  glewInfoFunc(\"glGetObjectBufferfvATI\", glGetObjectBufferfvATI == NULL);\n  glewInfoFunc(\"glGetObjectBufferivATI\", glGetObjectBufferivATI == NULL);\n  glewInfoFunc(\"glGetVariantArrayObjectfvATI\", glGetVariantArrayObjectfvATI == NULL);\n  glewInfoFunc(\"glGetVariantArrayObjectivATI\", glGetVariantArrayObjectivATI == NULL);\n  glewInfoFunc(\"glIsObjectBufferATI\", glIsObjectBufferATI == NULL);\n  glewInfoFunc(\"glNewObjectBufferATI\", glNewObjectBufferATI == NULL);\n  glewInfoFunc(\"glUpdateObjectBufferATI\", glUpdateObjectBufferATI == NULL);\n  glewInfoFunc(\"glVariantArrayObjectATI\", glVariantArrayObjectATI == NULL);\n}\n\n#endif /* GL_ATI_vertex_array_object */\n\n#ifdef GL_ATI_vertex_attrib_array_object\n\nstatic void _glewInfo_GL_ATI_vertex_attrib_array_object (void)\n{\n  glewPrintExt(\"GL_ATI_vertex_attrib_array_object\", GLEW_ATI_vertex_attrib_array_object, glewIsSupported(\"GL_ATI_vertex_attrib_array_object\"), glewGetExtension(\"GL_ATI_vertex_attrib_array_object\"));\n\n  glewInfoFunc(\"glGetVertexAttribArrayObjectfvATI\", glGetVertexAttribArrayObjectfvATI == NULL);\n  glewInfoFunc(\"glGetVertexAttribArrayObjectivATI\", glGetVertexAttribArrayObjectivATI == NULL);\n  glewInfoFunc(\"glVertexAttribArrayObjectATI\", glVertexAttribArrayObjectATI == NULL);\n}\n\n#endif /* GL_ATI_vertex_attrib_array_object */\n\n#ifdef GL_ATI_vertex_streams\n\nstatic void _glewInfo_GL_ATI_vertex_streams (void)\n{\n  glewPrintExt(\"GL_ATI_vertex_streams\", GLEW_ATI_vertex_streams, glewIsSupported(\"GL_ATI_vertex_streams\"), glewGetExtension(\"GL_ATI_vertex_streams\"));\n\n  glewInfoFunc(\"glClientActiveVertexStreamATI\", glClientActiveVertexStreamATI == NULL);\n  glewInfoFunc(\"glNormalStream3bATI\", glNormalStream3bATI == NULL);\n  glewInfoFunc(\"glNormalStream3bvATI\", glNormalStream3bvATI == NULL);\n  glewInfoFunc(\"glNormalStream3dATI\", glNormalStream3dATI == NULL);\n  glewInfoFunc(\"glNormalStream3dvATI\", glNormalStream3dvATI == NULL);\n  glewInfoFunc(\"glNormalStream3fATI\", glNormalStream3fATI == NULL);\n  glewInfoFunc(\"glNormalStream3fvATI\", glNormalStream3fvATI == NULL);\n  glewInfoFunc(\"glNormalStream3iATI\", glNormalStream3iATI == NULL);\n  glewInfoFunc(\"glNormalStream3ivATI\", glNormalStream3ivATI == NULL);\n  glewInfoFunc(\"glNormalStream3sATI\", glNormalStream3sATI == NULL);\n  glewInfoFunc(\"glNormalStream3svATI\", glNormalStream3svATI == NULL);\n  glewInfoFunc(\"glVertexBlendEnvfATI\", glVertexBlendEnvfATI == NULL);\n  glewInfoFunc(\"glVertexBlendEnviATI\", glVertexBlendEnviATI == NULL);\n  glewInfoFunc(\"glVertexStream1dATI\", glVertexStream1dATI == NULL);\n  glewInfoFunc(\"glVertexStream1dvATI\", glVertexStream1dvATI == NULL);\n  glewInfoFunc(\"glVertexStream1fATI\", glVertexStream1fATI == NULL);\n  glewInfoFunc(\"glVertexStream1fvATI\", glVertexStream1fvATI == NULL);\n  glewInfoFunc(\"glVertexStream1iATI\", glVertexStream1iATI == NULL);\n  glewInfoFunc(\"glVertexStream1ivATI\", glVertexStream1ivATI == NULL);\n  glewInfoFunc(\"glVertexStream1sATI\", glVertexStream1sATI == NULL);\n  glewInfoFunc(\"glVertexStream1svATI\", glVertexStream1svATI == NULL);\n  glewInfoFunc(\"glVertexStream2dATI\", glVertexStream2dATI == NULL);\n  glewInfoFunc(\"glVertexStream2dvATI\", glVertexStream2dvATI == NULL);\n  glewInfoFunc(\"glVertexStream2fATI\", glVertexStream2fATI == NULL);\n  glewInfoFunc(\"glVertexStream2fvATI\", glVertexStream2fvATI == NULL);\n  glewInfoFunc(\"glVertexStream2iATI\", glVertexStream2iATI == NULL);\n  glewInfoFunc(\"glVertexStream2ivATI\", glVertexStream2ivATI == NULL);\n  glewInfoFunc(\"glVertexStream2sATI\", glVertexStream2sATI == NULL);\n  glewInfoFunc(\"glVertexStream2svATI\", glVertexStream2svATI == NULL);\n  glewInfoFunc(\"glVertexStream3dATI\", glVertexStream3dATI == NULL);\n  glewInfoFunc(\"glVertexStream3dvATI\", glVertexStream3dvATI == NULL);\n  glewInfoFunc(\"glVertexStream3fATI\", glVertexStream3fATI == NULL);\n  glewInfoFunc(\"glVertexStream3fvATI\", glVertexStream3fvATI == NULL);\n  glewInfoFunc(\"glVertexStream3iATI\", glVertexStream3iATI == NULL);\n  glewInfoFunc(\"glVertexStream3ivATI\", glVertexStream3ivATI == NULL);\n  glewInfoFunc(\"glVertexStream3sATI\", glVertexStream3sATI == NULL);\n  glewInfoFunc(\"glVertexStream3svATI\", glVertexStream3svATI == NULL);\n  glewInfoFunc(\"glVertexStream4dATI\", glVertexStream4dATI == NULL);\n  glewInfoFunc(\"glVertexStream4dvATI\", glVertexStream4dvATI == NULL);\n  glewInfoFunc(\"glVertexStream4fATI\", glVertexStream4fATI == NULL);\n  glewInfoFunc(\"glVertexStream4fvATI\", glVertexStream4fvATI == NULL);\n  glewInfoFunc(\"glVertexStream4iATI\", glVertexStream4iATI == NULL);\n  glewInfoFunc(\"glVertexStream4ivATI\", glVertexStream4ivATI == NULL);\n  glewInfoFunc(\"glVertexStream4sATI\", glVertexStream4sATI == NULL);\n  glewInfoFunc(\"glVertexStream4svATI\", glVertexStream4svATI == NULL);\n}\n\n#endif /* GL_ATI_vertex_streams */\n\n#ifdef GL_EXT_422_pixels\n\nstatic void _glewInfo_GL_EXT_422_pixels (void)\n{\n  glewPrintExt(\"GL_EXT_422_pixels\", GLEW_EXT_422_pixels, glewIsSupported(\"GL_EXT_422_pixels\"), glewGetExtension(\"GL_EXT_422_pixels\"));\n}\n\n#endif /* GL_EXT_422_pixels */\n\n#ifdef GL_EXT_Cg_shader\n\nstatic void _glewInfo_GL_EXT_Cg_shader (void)\n{\n  glewPrintExt(\"GL_EXT_Cg_shader\", GLEW_EXT_Cg_shader, glewIsSupported(\"GL_EXT_Cg_shader\"), glewGetExtension(\"GL_EXT_Cg_shader\"));\n}\n\n#endif /* GL_EXT_Cg_shader */\n\n#ifdef GL_EXT_abgr\n\nstatic void _glewInfo_GL_EXT_abgr (void)\n{\n  glewPrintExt(\"GL_EXT_abgr\", GLEW_EXT_abgr, glewIsSupported(\"GL_EXT_abgr\"), glewGetExtension(\"GL_EXT_abgr\"));\n}\n\n#endif /* GL_EXT_abgr */\n\n#ifdef GL_EXT_bgra\n\nstatic void _glewInfo_GL_EXT_bgra (void)\n{\n  glewPrintExt(\"GL_EXT_bgra\", GLEW_EXT_bgra, glewIsSupported(\"GL_EXT_bgra\"), glewGetExtension(\"GL_EXT_bgra\"));\n}\n\n#endif /* GL_EXT_bgra */\n\n#ifdef GL_EXT_bindable_uniform\n\nstatic void _glewInfo_GL_EXT_bindable_uniform (void)\n{\n  glewPrintExt(\"GL_EXT_bindable_uniform\", GLEW_EXT_bindable_uniform, glewIsSupported(\"GL_EXT_bindable_uniform\"), glewGetExtension(\"GL_EXT_bindable_uniform\"));\n\n  glewInfoFunc(\"glGetUniformBufferSizeEXT\", glGetUniformBufferSizeEXT == NULL);\n  glewInfoFunc(\"glGetUniformOffsetEXT\", glGetUniformOffsetEXT == NULL);\n  glewInfoFunc(\"glUniformBufferEXT\", glUniformBufferEXT == NULL);\n}\n\n#endif /* GL_EXT_bindable_uniform */\n\n#ifdef GL_EXT_blend_color\n\nstatic void _glewInfo_GL_EXT_blend_color (void)\n{\n  glewPrintExt(\"GL_EXT_blend_color\", GLEW_EXT_blend_color, glewIsSupported(\"GL_EXT_blend_color\"), glewGetExtension(\"GL_EXT_blend_color\"));\n\n  glewInfoFunc(\"glBlendColorEXT\", glBlendColorEXT == NULL);\n}\n\n#endif /* GL_EXT_blend_color */\n\n#ifdef GL_EXT_blend_equation_separate\n\nstatic void _glewInfo_GL_EXT_blend_equation_separate (void)\n{\n  glewPrintExt(\"GL_EXT_blend_equation_separate\", GLEW_EXT_blend_equation_separate, glewIsSupported(\"GL_EXT_blend_equation_separate\"), glewGetExtension(\"GL_EXT_blend_equation_separate\"));\n\n  glewInfoFunc(\"glBlendEquationSeparateEXT\", glBlendEquationSeparateEXT == NULL);\n}\n\n#endif /* GL_EXT_blend_equation_separate */\n\n#ifdef GL_EXT_blend_func_separate\n\nstatic void _glewInfo_GL_EXT_blend_func_separate (void)\n{\n  glewPrintExt(\"GL_EXT_blend_func_separate\", GLEW_EXT_blend_func_separate, glewIsSupported(\"GL_EXT_blend_func_separate\"), glewGetExtension(\"GL_EXT_blend_func_separate\"));\n\n  glewInfoFunc(\"glBlendFuncSeparateEXT\", glBlendFuncSeparateEXT == NULL);\n}\n\n#endif /* GL_EXT_blend_func_separate */\n\n#ifdef GL_EXT_blend_logic_op\n\nstatic void _glewInfo_GL_EXT_blend_logic_op (void)\n{\n  glewPrintExt(\"GL_EXT_blend_logic_op\", GLEW_EXT_blend_logic_op, glewIsSupported(\"GL_EXT_blend_logic_op\"), glewGetExtension(\"GL_EXT_blend_logic_op\"));\n}\n\n#endif /* GL_EXT_blend_logic_op */\n\n#ifdef GL_EXT_blend_minmax\n\nstatic void _glewInfo_GL_EXT_blend_minmax (void)\n{\n  glewPrintExt(\"GL_EXT_blend_minmax\", GLEW_EXT_blend_minmax, glewIsSupported(\"GL_EXT_blend_minmax\"), glewGetExtension(\"GL_EXT_blend_minmax\"));\n\n  glewInfoFunc(\"glBlendEquationEXT\", glBlendEquationEXT == NULL);\n}\n\n#endif /* GL_EXT_blend_minmax */\n\n#ifdef GL_EXT_blend_subtract\n\nstatic void _glewInfo_GL_EXT_blend_subtract (void)\n{\n  glewPrintExt(\"GL_EXT_blend_subtract\", GLEW_EXT_blend_subtract, glewIsSupported(\"GL_EXT_blend_subtract\"), glewGetExtension(\"GL_EXT_blend_subtract\"));\n}\n\n#endif /* GL_EXT_blend_subtract */\n\n#ifdef GL_EXT_clip_volume_hint\n\nstatic void _glewInfo_GL_EXT_clip_volume_hint (void)\n{\n  glewPrintExt(\"GL_EXT_clip_volume_hint\", GLEW_EXT_clip_volume_hint, glewIsSupported(\"GL_EXT_clip_volume_hint\"), glewGetExtension(\"GL_EXT_clip_volume_hint\"));\n}\n\n#endif /* GL_EXT_clip_volume_hint */\n\n#ifdef GL_EXT_cmyka\n\nstatic void _glewInfo_GL_EXT_cmyka (void)\n{\n  glewPrintExt(\"GL_EXT_cmyka\", GLEW_EXT_cmyka, glewIsSupported(\"GL_EXT_cmyka\"), glewGetExtension(\"GL_EXT_cmyka\"));\n}\n\n#endif /* GL_EXT_cmyka */\n\n#ifdef GL_EXT_color_subtable\n\nstatic void _glewInfo_GL_EXT_color_subtable (void)\n{\n  glewPrintExt(\"GL_EXT_color_subtable\", GLEW_EXT_color_subtable, glewIsSupported(\"GL_EXT_color_subtable\"), glewGetExtension(\"GL_EXT_color_subtable\"));\n\n  glewInfoFunc(\"glColorSubTableEXT\", glColorSubTableEXT == NULL);\n  glewInfoFunc(\"glCopyColorSubTableEXT\", glCopyColorSubTableEXT == NULL);\n}\n\n#endif /* GL_EXT_color_subtable */\n\n#ifdef GL_EXT_compiled_vertex_array\n\nstatic void _glewInfo_GL_EXT_compiled_vertex_array (void)\n{\n  glewPrintExt(\"GL_EXT_compiled_vertex_array\", GLEW_EXT_compiled_vertex_array, glewIsSupported(\"GL_EXT_compiled_vertex_array\"), glewGetExtension(\"GL_EXT_compiled_vertex_array\"));\n\n  glewInfoFunc(\"glLockArraysEXT\", glLockArraysEXT == NULL);\n  glewInfoFunc(\"glUnlockArraysEXT\", glUnlockArraysEXT == NULL);\n}\n\n#endif /* GL_EXT_compiled_vertex_array */\n\n#ifdef GL_EXT_convolution\n\nstatic void _glewInfo_GL_EXT_convolution (void)\n{\n  glewPrintExt(\"GL_EXT_convolution\", GLEW_EXT_convolution, glewIsSupported(\"GL_EXT_convolution\"), glewGetExtension(\"GL_EXT_convolution\"));\n\n  glewInfoFunc(\"glConvolutionFilter1DEXT\", glConvolutionFilter1DEXT == NULL);\n  glewInfoFunc(\"glConvolutionFilter2DEXT\", glConvolutionFilter2DEXT == NULL);\n  glewInfoFunc(\"glConvolutionParameterfEXT\", glConvolutionParameterfEXT == NULL);\n  glewInfoFunc(\"glConvolutionParameterfvEXT\", glConvolutionParameterfvEXT == NULL);\n  glewInfoFunc(\"glConvolutionParameteriEXT\", glConvolutionParameteriEXT == NULL);\n  glewInfoFunc(\"glConvolutionParameterivEXT\", glConvolutionParameterivEXT == NULL);\n  glewInfoFunc(\"glCopyConvolutionFilter1DEXT\", glCopyConvolutionFilter1DEXT == NULL);\n  glewInfoFunc(\"glCopyConvolutionFilter2DEXT\", glCopyConvolutionFilter2DEXT == NULL);\n  glewInfoFunc(\"glGetConvolutionFilterEXT\", glGetConvolutionFilterEXT == NULL);\n  glewInfoFunc(\"glGetConvolutionParameterfvEXT\", glGetConvolutionParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetConvolutionParameterivEXT\", glGetConvolutionParameterivEXT == NULL);\n  glewInfoFunc(\"glGetSeparableFilterEXT\", glGetSeparableFilterEXT == NULL);\n  glewInfoFunc(\"glSeparableFilter2DEXT\", glSeparableFilter2DEXT == NULL);\n}\n\n#endif /* GL_EXT_convolution */\n\n#ifdef GL_EXT_coordinate_frame\n\nstatic void _glewInfo_GL_EXT_coordinate_frame (void)\n{\n  glewPrintExt(\"GL_EXT_coordinate_frame\", GLEW_EXT_coordinate_frame, glewIsSupported(\"GL_EXT_coordinate_frame\"), glewGetExtension(\"GL_EXT_coordinate_frame\"));\n\n  glewInfoFunc(\"glBinormalPointerEXT\", glBinormalPointerEXT == NULL);\n  glewInfoFunc(\"glTangentPointerEXT\", glTangentPointerEXT == NULL);\n}\n\n#endif /* GL_EXT_coordinate_frame */\n\n#ifdef GL_EXT_copy_texture\n\nstatic void _glewInfo_GL_EXT_copy_texture (void)\n{\n  glewPrintExt(\"GL_EXT_copy_texture\", GLEW_EXT_copy_texture, glewIsSupported(\"GL_EXT_copy_texture\"), glewGetExtension(\"GL_EXT_copy_texture\"));\n\n  glewInfoFunc(\"glCopyTexImage1DEXT\", glCopyTexImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyTexImage2DEXT\", glCopyTexImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyTexSubImage1DEXT\", glCopyTexSubImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyTexSubImage2DEXT\", glCopyTexSubImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyTexSubImage3DEXT\", glCopyTexSubImage3DEXT == NULL);\n}\n\n#endif /* GL_EXT_copy_texture */\n\n#ifdef GL_EXT_cull_vertex\n\nstatic void _glewInfo_GL_EXT_cull_vertex (void)\n{\n  glewPrintExt(\"GL_EXT_cull_vertex\", GLEW_EXT_cull_vertex, glewIsSupported(\"GL_EXT_cull_vertex\"), glewGetExtension(\"GL_EXT_cull_vertex\"));\n\n  glewInfoFunc(\"glCullParameterdvEXT\", glCullParameterdvEXT == NULL);\n  glewInfoFunc(\"glCullParameterfvEXT\", glCullParameterfvEXT == NULL);\n}\n\n#endif /* GL_EXT_cull_vertex */\n\n#ifdef GL_EXT_debug_marker\n\nstatic void _glewInfo_GL_EXT_debug_marker (void)\n{\n  glewPrintExt(\"GL_EXT_debug_marker\", GLEW_EXT_debug_marker, glewIsSupported(\"GL_EXT_debug_marker\"), glewGetExtension(\"GL_EXT_debug_marker\"));\n\n  glewInfoFunc(\"glInsertEventMarkerEXT\", glInsertEventMarkerEXT == NULL);\n  glewInfoFunc(\"glPopGroupMarkerEXT\", glPopGroupMarkerEXT == NULL);\n  glewInfoFunc(\"glPushGroupMarkerEXT\", glPushGroupMarkerEXT == NULL);\n}\n\n#endif /* GL_EXT_debug_marker */\n\n#ifdef GL_EXT_depth_bounds_test\n\nstatic void _glewInfo_GL_EXT_depth_bounds_test (void)\n{\n  glewPrintExt(\"GL_EXT_depth_bounds_test\", GLEW_EXT_depth_bounds_test, glewIsSupported(\"GL_EXT_depth_bounds_test\"), glewGetExtension(\"GL_EXT_depth_bounds_test\"));\n\n  glewInfoFunc(\"glDepthBoundsEXT\", glDepthBoundsEXT == NULL);\n}\n\n#endif /* GL_EXT_depth_bounds_test */\n\n#ifdef GL_EXT_direct_state_access\n\nstatic void _glewInfo_GL_EXT_direct_state_access (void)\n{\n  glewPrintExt(\"GL_EXT_direct_state_access\", GLEW_EXT_direct_state_access, glewIsSupported(\"GL_EXT_direct_state_access\"), glewGetExtension(\"GL_EXT_direct_state_access\"));\n\n  glewInfoFunc(\"glBindMultiTextureEXT\", glBindMultiTextureEXT == NULL);\n  glewInfoFunc(\"glCheckNamedFramebufferStatusEXT\", glCheckNamedFramebufferStatusEXT == NULL);\n  glewInfoFunc(\"glClientAttribDefaultEXT\", glClientAttribDefaultEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexImage1DEXT\", glCompressedMultiTexImage1DEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexImage2DEXT\", glCompressedMultiTexImage2DEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexImage3DEXT\", glCompressedMultiTexImage3DEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexSubImage1DEXT\", glCompressedMultiTexSubImage1DEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexSubImage2DEXT\", glCompressedMultiTexSubImage2DEXT == NULL);\n  glewInfoFunc(\"glCompressedMultiTexSubImage3DEXT\", glCompressedMultiTexSubImage3DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureImage1DEXT\", glCompressedTextureImage1DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureImage2DEXT\", glCompressedTextureImage2DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureImage3DEXT\", glCompressedTextureImage3DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureSubImage1DEXT\", glCompressedTextureSubImage1DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureSubImage2DEXT\", glCompressedTextureSubImage2DEXT == NULL);\n  glewInfoFunc(\"glCompressedTextureSubImage3DEXT\", glCompressedTextureSubImage3DEXT == NULL);\n  glewInfoFunc(\"glCopyMultiTexImage1DEXT\", glCopyMultiTexImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyMultiTexImage2DEXT\", glCopyMultiTexImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyMultiTexSubImage1DEXT\", glCopyMultiTexSubImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyMultiTexSubImage2DEXT\", glCopyMultiTexSubImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyMultiTexSubImage3DEXT\", glCopyMultiTexSubImage3DEXT == NULL);\n  glewInfoFunc(\"glCopyTextureImage1DEXT\", glCopyTextureImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyTextureImage2DEXT\", glCopyTextureImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyTextureSubImage1DEXT\", glCopyTextureSubImage1DEXT == NULL);\n  glewInfoFunc(\"glCopyTextureSubImage2DEXT\", glCopyTextureSubImage2DEXT == NULL);\n  glewInfoFunc(\"glCopyTextureSubImage3DEXT\", glCopyTextureSubImage3DEXT == NULL);\n  glewInfoFunc(\"glDisableClientStateIndexedEXT\", glDisableClientStateIndexedEXT == NULL);\n  glewInfoFunc(\"glDisableClientStateiEXT\", glDisableClientStateiEXT == NULL);\n  glewInfoFunc(\"glDisableVertexArrayAttribEXT\", glDisableVertexArrayAttribEXT == NULL);\n  glewInfoFunc(\"glDisableVertexArrayEXT\", glDisableVertexArrayEXT == NULL);\n  glewInfoFunc(\"glEnableClientStateIndexedEXT\", glEnableClientStateIndexedEXT == NULL);\n  glewInfoFunc(\"glEnableClientStateiEXT\", glEnableClientStateiEXT == NULL);\n  glewInfoFunc(\"glEnableVertexArrayAttribEXT\", glEnableVertexArrayAttribEXT == NULL);\n  glewInfoFunc(\"glEnableVertexArrayEXT\", glEnableVertexArrayEXT == NULL);\n  glewInfoFunc(\"glFlushMappedNamedBufferRangeEXT\", glFlushMappedNamedBufferRangeEXT == NULL);\n  glewInfoFunc(\"glFramebufferDrawBufferEXT\", glFramebufferDrawBufferEXT == NULL);\n  glewInfoFunc(\"glFramebufferDrawBuffersEXT\", glFramebufferDrawBuffersEXT == NULL);\n  glewInfoFunc(\"glFramebufferReadBufferEXT\", glFramebufferReadBufferEXT == NULL);\n  glewInfoFunc(\"glGenerateMultiTexMipmapEXT\", glGenerateMultiTexMipmapEXT == NULL);\n  glewInfoFunc(\"glGenerateTextureMipmapEXT\", glGenerateTextureMipmapEXT == NULL);\n  glewInfoFunc(\"glGetCompressedMultiTexImageEXT\", glGetCompressedMultiTexImageEXT == NULL);\n  glewInfoFunc(\"glGetCompressedTextureImageEXT\", glGetCompressedTextureImageEXT == NULL);\n  glewInfoFunc(\"glGetDoubleIndexedvEXT\", glGetDoubleIndexedvEXT == NULL);\n  glewInfoFunc(\"glGetDoublei_vEXT\", glGetDoublei_vEXT == NULL);\n  glewInfoFunc(\"glGetFloatIndexedvEXT\", glGetFloatIndexedvEXT == NULL);\n  glewInfoFunc(\"glGetFloati_vEXT\", glGetFloati_vEXT == NULL);\n  glewInfoFunc(\"glGetFramebufferParameterivEXT\", glGetFramebufferParameterivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexEnvfvEXT\", glGetMultiTexEnvfvEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexEnvivEXT\", glGetMultiTexEnvivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexGendvEXT\", glGetMultiTexGendvEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexGenfvEXT\", glGetMultiTexGenfvEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexGenivEXT\", glGetMultiTexGenivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexImageEXT\", glGetMultiTexImageEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexLevelParameterfvEXT\", glGetMultiTexLevelParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexLevelParameterivEXT\", glGetMultiTexLevelParameterivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexParameterIivEXT\", glGetMultiTexParameterIivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexParameterIuivEXT\", glGetMultiTexParameterIuivEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexParameterfvEXT\", glGetMultiTexParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetMultiTexParameterivEXT\", glGetMultiTexParameterivEXT == NULL);\n  glewInfoFunc(\"glGetNamedBufferParameterivEXT\", glGetNamedBufferParameterivEXT == NULL);\n  glewInfoFunc(\"glGetNamedBufferPointervEXT\", glGetNamedBufferPointervEXT == NULL);\n  glewInfoFunc(\"glGetNamedBufferSubDataEXT\", glGetNamedBufferSubDataEXT == NULL);\n  glewInfoFunc(\"glGetNamedFramebufferAttachmentParameterivEXT\", glGetNamedFramebufferAttachmentParameterivEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramLocalParameterIivEXT\", glGetNamedProgramLocalParameterIivEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramLocalParameterIuivEXT\", glGetNamedProgramLocalParameterIuivEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramLocalParameterdvEXT\", glGetNamedProgramLocalParameterdvEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramLocalParameterfvEXT\", glGetNamedProgramLocalParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramStringEXT\", glGetNamedProgramStringEXT == NULL);\n  glewInfoFunc(\"glGetNamedProgramivEXT\", glGetNamedProgramivEXT == NULL);\n  glewInfoFunc(\"glGetNamedRenderbufferParameterivEXT\", glGetNamedRenderbufferParameterivEXT == NULL);\n  glewInfoFunc(\"glGetPointerIndexedvEXT\", glGetPointerIndexedvEXT == NULL);\n  glewInfoFunc(\"glGetPointeri_vEXT\", glGetPointeri_vEXT == NULL);\n  glewInfoFunc(\"glGetTextureImageEXT\", glGetTextureImageEXT == NULL);\n  glewInfoFunc(\"glGetTextureLevelParameterfvEXT\", glGetTextureLevelParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetTextureLevelParameterivEXT\", glGetTextureLevelParameterivEXT == NULL);\n  glewInfoFunc(\"glGetTextureParameterIivEXT\", glGetTextureParameterIivEXT == NULL);\n  glewInfoFunc(\"glGetTextureParameterIuivEXT\", glGetTextureParameterIuivEXT == NULL);\n  glewInfoFunc(\"glGetTextureParameterfvEXT\", glGetTextureParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetTextureParameterivEXT\", glGetTextureParameterivEXT == NULL);\n  glewInfoFunc(\"glGetVertexArrayIntegeri_vEXT\", glGetVertexArrayIntegeri_vEXT == NULL);\n  glewInfoFunc(\"glGetVertexArrayIntegervEXT\", glGetVertexArrayIntegervEXT == NULL);\n  glewInfoFunc(\"glGetVertexArrayPointeri_vEXT\", glGetVertexArrayPointeri_vEXT == NULL);\n  glewInfoFunc(\"glGetVertexArrayPointervEXT\", glGetVertexArrayPointervEXT == NULL);\n  glewInfoFunc(\"glMapNamedBufferEXT\", glMapNamedBufferEXT == NULL);\n  glewInfoFunc(\"glMapNamedBufferRangeEXT\", glMapNamedBufferRangeEXT == NULL);\n  glewInfoFunc(\"glMatrixFrustumEXT\", glMatrixFrustumEXT == NULL);\n  glewInfoFunc(\"glMatrixLoadIdentityEXT\", glMatrixLoadIdentityEXT == NULL);\n  glewInfoFunc(\"glMatrixLoadTransposedEXT\", glMatrixLoadTransposedEXT == NULL);\n  glewInfoFunc(\"glMatrixLoadTransposefEXT\", glMatrixLoadTransposefEXT == NULL);\n  glewInfoFunc(\"glMatrixLoaddEXT\", glMatrixLoaddEXT == NULL);\n  glewInfoFunc(\"glMatrixLoadfEXT\", glMatrixLoadfEXT == NULL);\n  glewInfoFunc(\"glMatrixMultTransposedEXT\", glMatrixMultTransposedEXT == NULL);\n  glewInfoFunc(\"glMatrixMultTransposefEXT\", glMatrixMultTransposefEXT == NULL);\n  glewInfoFunc(\"glMatrixMultdEXT\", glMatrixMultdEXT == NULL);\n  glewInfoFunc(\"glMatrixMultfEXT\", glMatrixMultfEXT == NULL);\n  glewInfoFunc(\"glMatrixOrthoEXT\", glMatrixOrthoEXT == NULL);\n  glewInfoFunc(\"glMatrixPopEXT\", glMatrixPopEXT == NULL);\n  glewInfoFunc(\"glMatrixPushEXT\", glMatrixPushEXT == NULL);\n  glewInfoFunc(\"glMatrixRotatedEXT\", glMatrixRotatedEXT == NULL);\n  glewInfoFunc(\"glMatrixRotatefEXT\", glMatrixRotatefEXT == NULL);\n  glewInfoFunc(\"glMatrixScaledEXT\", glMatrixScaledEXT == NULL);\n  glewInfoFunc(\"glMatrixScalefEXT\", glMatrixScalefEXT == NULL);\n  glewInfoFunc(\"glMatrixTranslatedEXT\", glMatrixTranslatedEXT == NULL);\n  glewInfoFunc(\"glMatrixTranslatefEXT\", glMatrixTranslatefEXT == NULL);\n  glewInfoFunc(\"glMultiTexBufferEXT\", glMultiTexBufferEXT == NULL);\n  glewInfoFunc(\"glMultiTexCoordPointerEXT\", glMultiTexCoordPointerEXT == NULL);\n  glewInfoFunc(\"glMultiTexEnvfEXT\", glMultiTexEnvfEXT == NULL);\n  glewInfoFunc(\"glMultiTexEnvfvEXT\", glMultiTexEnvfvEXT == NULL);\n  glewInfoFunc(\"glMultiTexEnviEXT\", glMultiTexEnviEXT == NULL);\n  glewInfoFunc(\"glMultiTexEnvivEXT\", glMultiTexEnvivEXT == NULL);\n  glewInfoFunc(\"glMultiTexGendEXT\", glMultiTexGendEXT == NULL);\n  glewInfoFunc(\"glMultiTexGendvEXT\", glMultiTexGendvEXT == NULL);\n  glewInfoFunc(\"glMultiTexGenfEXT\", glMultiTexGenfEXT == NULL);\n  glewInfoFunc(\"glMultiTexGenfvEXT\", glMultiTexGenfvEXT == NULL);\n  glewInfoFunc(\"glMultiTexGeniEXT\", glMultiTexGeniEXT == NULL);\n  glewInfoFunc(\"glMultiTexGenivEXT\", glMultiTexGenivEXT == NULL);\n  glewInfoFunc(\"glMultiTexImage1DEXT\", glMultiTexImage1DEXT == NULL);\n  glewInfoFunc(\"glMultiTexImage2DEXT\", glMultiTexImage2DEXT == NULL);\n  glewInfoFunc(\"glMultiTexImage3DEXT\", glMultiTexImage3DEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameterIivEXT\", glMultiTexParameterIivEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameterIuivEXT\", glMultiTexParameterIuivEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameterfEXT\", glMultiTexParameterfEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameterfvEXT\", glMultiTexParameterfvEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameteriEXT\", glMultiTexParameteriEXT == NULL);\n  glewInfoFunc(\"glMultiTexParameterivEXT\", glMultiTexParameterivEXT == NULL);\n  glewInfoFunc(\"glMultiTexRenderbufferEXT\", glMultiTexRenderbufferEXT == NULL);\n  glewInfoFunc(\"glMultiTexSubImage1DEXT\", glMultiTexSubImage1DEXT == NULL);\n  glewInfoFunc(\"glMultiTexSubImage2DEXT\", glMultiTexSubImage2DEXT == NULL);\n  glewInfoFunc(\"glMultiTexSubImage3DEXT\", glMultiTexSubImage3DEXT == NULL);\n  glewInfoFunc(\"glNamedBufferDataEXT\", glNamedBufferDataEXT == NULL);\n  glewInfoFunc(\"glNamedBufferSubDataEXT\", glNamedBufferSubDataEXT == NULL);\n  glewInfoFunc(\"glNamedCopyBufferSubDataEXT\", glNamedCopyBufferSubDataEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferRenderbufferEXT\", glNamedFramebufferRenderbufferEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTexture1DEXT\", glNamedFramebufferTexture1DEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTexture2DEXT\", glNamedFramebufferTexture2DEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTexture3DEXT\", glNamedFramebufferTexture3DEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTextureEXT\", glNamedFramebufferTextureEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTextureFaceEXT\", glNamedFramebufferTextureFaceEXT == NULL);\n  glewInfoFunc(\"glNamedFramebufferTextureLayerEXT\", glNamedFramebufferTextureLayerEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameter4dEXT\", glNamedProgramLocalParameter4dEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameter4dvEXT\", glNamedProgramLocalParameter4dvEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameter4fEXT\", glNamedProgramLocalParameter4fEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameter4fvEXT\", glNamedProgramLocalParameter4fvEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameterI4iEXT\", glNamedProgramLocalParameterI4iEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameterI4ivEXT\", glNamedProgramLocalParameterI4ivEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameterI4uiEXT\", glNamedProgramLocalParameterI4uiEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameterI4uivEXT\", glNamedProgramLocalParameterI4uivEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParameters4fvEXT\", glNamedProgramLocalParameters4fvEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParametersI4ivEXT\", glNamedProgramLocalParametersI4ivEXT == NULL);\n  glewInfoFunc(\"glNamedProgramLocalParametersI4uivEXT\", glNamedProgramLocalParametersI4uivEXT == NULL);\n  glewInfoFunc(\"glNamedProgramStringEXT\", glNamedProgramStringEXT == NULL);\n  glewInfoFunc(\"glNamedRenderbufferStorageEXT\", glNamedRenderbufferStorageEXT == NULL);\n  glewInfoFunc(\"glNamedRenderbufferStorageMultisampleCoverageEXT\", glNamedRenderbufferStorageMultisampleCoverageEXT == NULL);\n  glewInfoFunc(\"glNamedRenderbufferStorageMultisampleEXT\", glNamedRenderbufferStorageMultisampleEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1dEXT\", glProgramUniform1dEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1dvEXT\", glProgramUniform1dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1fEXT\", glProgramUniform1fEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1fvEXT\", glProgramUniform1fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1iEXT\", glProgramUniform1iEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1ivEXT\", glProgramUniform1ivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1uiEXT\", glProgramUniform1uiEXT == NULL);\n  glewInfoFunc(\"glProgramUniform1uivEXT\", glProgramUniform1uivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2dEXT\", glProgramUniform2dEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2dvEXT\", glProgramUniform2dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2fEXT\", glProgramUniform2fEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2fvEXT\", glProgramUniform2fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2iEXT\", glProgramUniform2iEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2ivEXT\", glProgramUniform2ivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2uiEXT\", glProgramUniform2uiEXT == NULL);\n  glewInfoFunc(\"glProgramUniform2uivEXT\", glProgramUniform2uivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3dEXT\", glProgramUniform3dEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3dvEXT\", glProgramUniform3dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3fEXT\", glProgramUniform3fEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3fvEXT\", glProgramUniform3fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3iEXT\", glProgramUniform3iEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3ivEXT\", glProgramUniform3ivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3uiEXT\", glProgramUniform3uiEXT == NULL);\n  glewInfoFunc(\"glProgramUniform3uivEXT\", glProgramUniform3uivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4dEXT\", glProgramUniform4dEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4dvEXT\", glProgramUniform4dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4fEXT\", glProgramUniform4fEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4fvEXT\", glProgramUniform4fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4iEXT\", glProgramUniform4iEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4ivEXT\", glProgramUniform4ivEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4uiEXT\", glProgramUniform4uiEXT == NULL);\n  glewInfoFunc(\"glProgramUniform4uivEXT\", glProgramUniform4uivEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2dvEXT\", glProgramUniformMatrix2dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2fvEXT\", glProgramUniformMatrix2fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x3dvEXT\", glProgramUniformMatrix2x3dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x3fvEXT\", glProgramUniformMatrix2x3fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x4dvEXT\", glProgramUniformMatrix2x4dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix2x4fvEXT\", glProgramUniformMatrix2x4fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3dvEXT\", glProgramUniformMatrix3dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3fvEXT\", glProgramUniformMatrix3fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x2dvEXT\", glProgramUniformMatrix3x2dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x2fvEXT\", glProgramUniformMatrix3x2fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x4dvEXT\", glProgramUniformMatrix3x4dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix3x4fvEXT\", glProgramUniformMatrix3x4fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4dvEXT\", glProgramUniformMatrix4dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4fvEXT\", glProgramUniformMatrix4fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x2dvEXT\", glProgramUniformMatrix4x2dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x2fvEXT\", glProgramUniformMatrix4x2fvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x3dvEXT\", glProgramUniformMatrix4x3dvEXT == NULL);\n  glewInfoFunc(\"glProgramUniformMatrix4x3fvEXT\", glProgramUniformMatrix4x3fvEXT == NULL);\n  glewInfoFunc(\"glPushClientAttribDefaultEXT\", glPushClientAttribDefaultEXT == NULL);\n  glewInfoFunc(\"glTextureBufferEXT\", glTextureBufferEXT == NULL);\n  glewInfoFunc(\"glTextureImage1DEXT\", glTextureImage1DEXT == NULL);\n  glewInfoFunc(\"glTextureImage2DEXT\", glTextureImage2DEXT == NULL);\n  glewInfoFunc(\"glTextureImage3DEXT\", glTextureImage3DEXT == NULL);\n  glewInfoFunc(\"glTextureParameterIivEXT\", glTextureParameterIivEXT == NULL);\n  glewInfoFunc(\"glTextureParameterIuivEXT\", glTextureParameterIuivEXT == NULL);\n  glewInfoFunc(\"glTextureParameterfEXT\", glTextureParameterfEXT == NULL);\n  glewInfoFunc(\"glTextureParameterfvEXT\", glTextureParameterfvEXT == NULL);\n  glewInfoFunc(\"glTextureParameteriEXT\", glTextureParameteriEXT == NULL);\n  glewInfoFunc(\"glTextureParameterivEXT\", glTextureParameterivEXT == NULL);\n  glewInfoFunc(\"glTextureRenderbufferEXT\", glTextureRenderbufferEXT == NULL);\n  glewInfoFunc(\"glTextureSubImage1DEXT\", glTextureSubImage1DEXT == NULL);\n  glewInfoFunc(\"glTextureSubImage2DEXT\", glTextureSubImage2DEXT == NULL);\n  glewInfoFunc(\"glTextureSubImage3DEXT\", glTextureSubImage3DEXT == NULL);\n  glewInfoFunc(\"glUnmapNamedBufferEXT\", glUnmapNamedBufferEXT == NULL);\n  glewInfoFunc(\"glVertexArrayColorOffsetEXT\", glVertexArrayColorOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayEdgeFlagOffsetEXT\", glVertexArrayEdgeFlagOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayFogCoordOffsetEXT\", glVertexArrayFogCoordOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayIndexOffsetEXT\", glVertexArrayIndexOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayMultiTexCoordOffsetEXT\", glVertexArrayMultiTexCoordOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayNormalOffsetEXT\", glVertexArrayNormalOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArraySecondaryColorOffsetEXT\", glVertexArraySecondaryColorOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayTexCoordOffsetEXT\", glVertexArrayTexCoordOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayVertexAttribIOffsetEXT\", glVertexArrayVertexAttribIOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayVertexAttribOffsetEXT\", glVertexArrayVertexAttribOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexArrayVertexOffsetEXT\", glVertexArrayVertexOffsetEXT == NULL);\n}\n\n#endif /* GL_EXT_direct_state_access */\n\n#ifdef GL_EXT_draw_buffers2\n\nstatic void _glewInfo_GL_EXT_draw_buffers2 (void)\n{\n  glewPrintExt(\"GL_EXT_draw_buffers2\", GLEW_EXT_draw_buffers2, glewIsSupported(\"GL_EXT_draw_buffers2\"), glewGetExtension(\"GL_EXT_draw_buffers2\"));\n\n  glewInfoFunc(\"glColorMaskIndexedEXT\", glColorMaskIndexedEXT == NULL);\n  glewInfoFunc(\"glDisableIndexedEXT\", glDisableIndexedEXT == NULL);\n  glewInfoFunc(\"glEnableIndexedEXT\", glEnableIndexedEXT == NULL);\n  glewInfoFunc(\"glGetBooleanIndexedvEXT\", glGetBooleanIndexedvEXT == NULL);\n  glewInfoFunc(\"glGetIntegerIndexedvEXT\", glGetIntegerIndexedvEXT == NULL);\n  glewInfoFunc(\"glIsEnabledIndexedEXT\", glIsEnabledIndexedEXT == NULL);\n}\n\n#endif /* GL_EXT_draw_buffers2 */\n\n#ifdef GL_EXT_draw_instanced\n\nstatic void _glewInfo_GL_EXT_draw_instanced (void)\n{\n  glewPrintExt(\"GL_EXT_draw_instanced\", GLEW_EXT_draw_instanced, glewIsSupported(\"GL_EXT_draw_instanced\"), glewGetExtension(\"GL_EXT_draw_instanced\"));\n\n  glewInfoFunc(\"glDrawArraysInstancedEXT\", glDrawArraysInstancedEXT == NULL);\n  glewInfoFunc(\"glDrawElementsInstancedEXT\", glDrawElementsInstancedEXT == NULL);\n}\n\n#endif /* GL_EXT_draw_instanced */\n\n#ifdef GL_EXT_draw_range_elements\n\nstatic void _glewInfo_GL_EXT_draw_range_elements (void)\n{\n  glewPrintExt(\"GL_EXT_draw_range_elements\", GLEW_EXT_draw_range_elements, glewIsSupported(\"GL_EXT_draw_range_elements\"), glewGetExtension(\"GL_EXT_draw_range_elements\"));\n\n  glewInfoFunc(\"glDrawRangeElementsEXT\", glDrawRangeElementsEXT == NULL);\n}\n\n#endif /* GL_EXT_draw_range_elements */\n\n#ifdef GL_EXT_fog_coord\n\nstatic void _glewInfo_GL_EXT_fog_coord (void)\n{\n  glewPrintExt(\"GL_EXT_fog_coord\", GLEW_EXT_fog_coord, glewIsSupported(\"GL_EXT_fog_coord\"), glewGetExtension(\"GL_EXT_fog_coord\"));\n\n  glewInfoFunc(\"glFogCoordPointerEXT\", glFogCoordPointerEXT == NULL);\n  glewInfoFunc(\"glFogCoorddEXT\", glFogCoorddEXT == NULL);\n  glewInfoFunc(\"glFogCoorddvEXT\", glFogCoorddvEXT == NULL);\n  glewInfoFunc(\"glFogCoordfEXT\", glFogCoordfEXT == NULL);\n  glewInfoFunc(\"glFogCoordfvEXT\", glFogCoordfvEXT == NULL);\n}\n\n#endif /* GL_EXT_fog_coord */\n\n#ifdef GL_EXT_fragment_lighting\n\nstatic void _glewInfo_GL_EXT_fragment_lighting (void)\n{\n  glewPrintExt(\"GL_EXT_fragment_lighting\", GLEW_EXT_fragment_lighting, glewIsSupported(\"GL_EXT_fragment_lighting\"), glewGetExtension(\"GL_EXT_fragment_lighting\"));\n\n  glewInfoFunc(\"glFragmentColorMaterialEXT\", glFragmentColorMaterialEXT == NULL);\n  glewInfoFunc(\"glFragmentLightModelfEXT\", glFragmentLightModelfEXT == NULL);\n  glewInfoFunc(\"glFragmentLightModelfvEXT\", glFragmentLightModelfvEXT == NULL);\n  glewInfoFunc(\"glFragmentLightModeliEXT\", glFragmentLightModeliEXT == NULL);\n  glewInfoFunc(\"glFragmentLightModelivEXT\", glFragmentLightModelivEXT == NULL);\n  glewInfoFunc(\"glFragmentLightfEXT\", glFragmentLightfEXT == NULL);\n  glewInfoFunc(\"glFragmentLightfvEXT\", glFragmentLightfvEXT == NULL);\n  glewInfoFunc(\"glFragmentLightiEXT\", glFragmentLightiEXT == NULL);\n  glewInfoFunc(\"glFragmentLightivEXT\", glFragmentLightivEXT == NULL);\n  glewInfoFunc(\"glFragmentMaterialfEXT\", glFragmentMaterialfEXT == NULL);\n  glewInfoFunc(\"glFragmentMaterialfvEXT\", glFragmentMaterialfvEXT == NULL);\n  glewInfoFunc(\"glFragmentMaterialiEXT\", glFragmentMaterialiEXT == NULL);\n  glewInfoFunc(\"glFragmentMaterialivEXT\", glFragmentMaterialivEXT == NULL);\n  glewInfoFunc(\"glGetFragmentLightfvEXT\", glGetFragmentLightfvEXT == NULL);\n  glewInfoFunc(\"glGetFragmentLightivEXT\", glGetFragmentLightivEXT == NULL);\n  glewInfoFunc(\"glGetFragmentMaterialfvEXT\", glGetFragmentMaterialfvEXT == NULL);\n  glewInfoFunc(\"glGetFragmentMaterialivEXT\", glGetFragmentMaterialivEXT == NULL);\n  glewInfoFunc(\"glLightEnviEXT\", glLightEnviEXT == NULL);\n}\n\n#endif /* GL_EXT_fragment_lighting */\n\n#ifdef GL_EXT_framebuffer_blit\n\nstatic void _glewInfo_GL_EXT_framebuffer_blit (void)\n{\n  glewPrintExt(\"GL_EXT_framebuffer_blit\", GLEW_EXT_framebuffer_blit, glewIsSupported(\"GL_EXT_framebuffer_blit\"), glewGetExtension(\"GL_EXT_framebuffer_blit\"));\n\n  glewInfoFunc(\"glBlitFramebufferEXT\", glBlitFramebufferEXT == NULL);\n}\n\n#endif /* GL_EXT_framebuffer_blit */\n\n#ifdef GL_EXT_framebuffer_multisample\n\nstatic void _glewInfo_GL_EXT_framebuffer_multisample (void)\n{\n  glewPrintExt(\"GL_EXT_framebuffer_multisample\", GLEW_EXT_framebuffer_multisample, glewIsSupported(\"GL_EXT_framebuffer_multisample\"), glewGetExtension(\"GL_EXT_framebuffer_multisample\"));\n\n  glewInfoFunc(\"glRenderbufferStorageMultisampleEXT\", glRenderbufferStorageMultisampleEXT == NULL);\n}\n\n#endif /* GL_EXT_framebuffer_multisample */\n\n#ifdef GL_EXT_framebuffer_multisample_blit_scaled\n\nstatic void _glewInfo_GL_EXT_framebuffer_multisample_blit_scaled (void)\n{\n  glewPrintExt(\"GL_EXT_framebuffer_multisample_blit_scaled\", GLEW_EXT_framebuffer_multisample_blit_scaled, glewIsSupported(\"GL_EXT_framebuffer_multisample_blit_scaled\"), glewGetExtension(\"GL_EXT_framebuffer_multisample_blit_scaled\"));\n}\n\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n\n#ifdef GL_EXT_framebuffer_object\n\nstatic void _glewInfo_GL_EXT_framebuffer_object (void)\n{\n  glewPrintExt(\"GL_EXT_framebuffer_object\", GLEW_EXT_framebuffer_object, glewIsSupported(\"GL_EXT_framebuffer_object\"), glewGetExtension(\"GL_EXT_framebuffer_object\"));\n\n  glewInfoFunc(\"glBindFramebufferEXT\", glBindFramebufferEXT == NULL);\n  glewInfoFunc(\"glBindRenderbufferEXT\", glBindRenderbufferEXT == NULL);\n  glewInfoFunc(\"glCheckFramebufferStatusEXT\", glCheckFramebufferStatusEXT == NULL);\n  glewInfoFunc(\"glDeleteFramebuffersEXT\", glDeleteFramebuffersEXT == NULL);\n  glewInfoFunc(\"glDeleteRenderbuffersEXT\", glDeleteRenderbuffersEXT == NULL);\n  glewInfoFunc(\"glFramebufferRenderbufferEXT\", glFramebufferRenderbufferEXT == NULL);\n  glewInfoFunc(\"glFramebufferTexture1DEXT\", glFramebufferTexture1DEXT == NULL);\n  glewInfoFunc(\"glFramebufferTexture2DEXT\", glFramebufferTexture2DEXT == NULL);\n  glewInfoFunc(\"glFramebufferTexture3DEXT\", glFramebufferTexture3DEXT == NULL);\n  glewInfoFunc(\"glGenFramebuffersEXT\", glGenFramebuffersEXT == NULL);\n  glewInfoFunc(\"glGenRenderbuffersEXT\", glGenRenderbuffersEXT == NULL);\n  glewInfoFunc(\"glGenerateMipmapEXT\", glGenerateMipmapEXT == NULL);\n  glewInfoFunc(\"glGetFramebufferAttachmentParameterivEXT\", glGetFramebufferAttachmentParameterivEXT == NULL);\n  glewInfoFunc(\"glGetRenderbufferParameterivEXT\", glGetRenderbufferParameterivEXT == NULL);\n  glewInfoFunc(\"glIsFramebufferEXT\", glIsFramebufferEXT == NULL);\n  glewInfoFunc(\"glIsRenderbufferEXT\", glIsRenderbufferEXT == NULL);\n  glewInfoFunc(\"glRenderbufferStorageEXT\", glRenderbufferStorageEXT == NULL);\n}\n\n#endif /* GL_EXT_framebuffer_object */\n\n#ifdef GL_EXT_framebuffer_sRGB\n\nstatic void _glewInfo_GL_EXT_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"GL_EXT_framebuffer_sRGB\", GLEW_EXT_framebuffer_sRGB, glewIsSupported(\"GL_EXT_framebuffer_sRGB\"), glewGetExtension(\"GL_EXT_framebuffer_sRGB\"));\n}\n\n#endif /* GL_EXT_framebuffer_sRGB */\n\n#ifdef GL_EXT_geometry_shader4\n\nstatic void _glewInfo_GL_EXT_geometry_shader4 (void)\n{\n  glewPrintExt(\"GL_EXT_geometry_shader4\", GLEW_EXT_geometry_shader4, glewIsSupported(\"GL_EXT_geometry_shader4\"), glewGetExtension(\"GL_EXT_geometry_shader4\"));\n\n  glewInfoFunc(\"glFramebufferTextureEXT\", glFramebufferTextureEXT == NULL);\n  glewInfoFunc(\"glFramebufferTextureFaceEXT\", glFramebufferTextureFaceEXT == NULL);\n  glewInfoFunc(\"glProgramParameteriEXT\", glProgramParameteriEXT == NULL);\n}\n\n#endif /* GL_EXT_geometry_shader4 */\n\n#ifdef GL_EXT_gpu_program_parameters\n\nstatic void _glewInfo_GL_EXT_gpu_program_parameters (void)\n{\n  glewPrintExt(\"GL_EXT_gpu_program_parameters\", GLEW_EXT_gpu_program_parameters, glewIsSupported(\"GL_EXT_gpu_program_parameters\"), glewGetExtension(\"GL_EXT_gpu_program_parameters\"));\n\n  glewInfoFunc(\"glProgramEnvParameters4fvEXT\", glProgramEnvParameters4fvEXT == NULL);\n  glewInfoFunc(\"glProgramLocalParameters4fvEXT\", glProgramLocalParameters4fvEXT == NULL);\n}\n\n#endif /* GL_EXT_gpu_program_parameters */\n\n#ifdef GL_EXT_gpu_shader4\n\nstatic void _glewInfo_GL_EXT_gpu_shader4 (void)\n{\n  glewPrintExt(\"GL_EXT_gpu_shader4\", GLEW_EXT_gpu_shader4, glewIsSupported(\"GL_EXT_gpu_shader4\"), glewGetExtension(\"GL_EXT_gpu_shader4\"));\n\n  glewInfoFunc(\"glBindFragDataLocationEXT\", glBindFragDataLocationEXT == NULL);\n  glewInfoFunc(\"glGetFragDataLocationEXT\", glGetFragDataLocationEXT == NULL);\n  glewInfoFunc(\"glGetUniformuivEXT\", glGetUniformuivEXT == NULL);\n  glewInfoFunc(\"glGetVertexAttribIivEXT\", glGetVertexAttribIivEXT == NULL);\n  glewInfoFunc(\"glGetVertexAttribIuivEXT\", glGetVertexAttribIuivEXT == NULL);\n  glewInfoFunc(\"glUniform1uiEXT\", glUniform1uiEXT == NULL);\n  glewInfoFunc(\"glUniform1uivEXT\", glUniform1uivEXT == NULL);\n  glewInfoFunc(\"glUniform2uiEXT\", glUniform2uiEXT == NULL);\n  glewInfoFunc(\"glUniform2uivEXT\", glUniform2uivEXT == NULL);\n  glewInfoFunc(\"glUniform3uiEXT\", glUniform3uiEXT == NULL);\n  glewInfoFunc(\"glUniform3uivEXT\", glUniform3uivEXT == NULL);\n  glewInfoFunc(\"glUniform4uiEXT\", glUniform4uiEXT == NULL);\n  glewInfoFunc(\"glUniform4uivEXT\", glUniform4uivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI1iEXT\", glVertexAttribI1iEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI1ivEXT\", glVertexAttribI1ivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI1uiEXT\", glVertexAttribI1uiEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI1uivEXT\", glVertexAttribI1uivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI2iEXT\", glVertexAttribI2iEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI2ivEXT\", glVertexAttribI2ivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI2uiEXT\", glVertexAttribI2uiEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI2uivEXT\", glVertexAttribI2uivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI3iEXT\", glVertexAttribI3iEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI3ivEXT\", glVertexAttribI3ivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI3uiEXT\", glVertexAttribI3uiEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI3uivEXT\", glVertexAttribI3uivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4bvEXT\", glVertexAttribI4bvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4iEXT\", glVertexAttribI4iEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4ivEXT\", glVertexAttribI4ivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4svEXT\", glVertexAttribI4svEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4ubvEXT\", glVertexAttribI4ubvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4uiEXT\", glVertexAttribI4uiEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4uivEXT\", glVertexAttribI4uivEXT == NULL);\n  glewInfoFunc(\"glVertexAttribI4usvEXT\", glVertexAttribI4usvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribIPointerEXT\", glVertexAttribIPointerEXT == NULL);\n}\n\n#endif /* GL_EXT_gpu_shader4 */\n\n#ifdef GL_EXT_histogram\n\nstatic void _glewInfo_GL_EXT_histogram (void)\n{\n  glewPrintExt(\"GL_EXT_histogram\", GLEW_EXT_histogram, glewIsSupported(\"GL_EXT_histogram\"), glewGetExtension(\"GL_EXT_histogram\"));\n\n  glewInfoFunc(\"glGetHistogramEXT\", glGetHistogramEXT == NULL);\n  glewInfoFunc(\"glGetHistogramParameterfvEXT\", glGetHistogramParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetHistogramParameterivEXT\", glGetHistogramParameterivEXT == NULL);\n  glewInfoFunc(\"glGetMinmaxEXT\", glGetMinmaxEXT == NULL);\n  glewInfoFunc(\"glGetMinmaxParameterfvEXT\", glGetMinmaxParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetMinmaxParameterivEXT\", glGetMinmaxParameterivEXT == NULL);\n  glewInfoFunc(\"glHistogramEXT\", glHistogramEXT == NULL);\n  glewInfoFunc(\"glMinmaxEXT\", glMinmaxEXT == NULL);\n  glewInfoFunc(\"glResetHistogramEXT\", glResetHistogramEXT == NULL);\n  glewInfoFunc(\"glResetMinmaxEXT\", glResetMinmaxEXT == NULL);\n}\n\n#endif /* GL_EXT_histogram */\n\n#ifdef GL_EXT_index_array_formats\n\nstatic void _glewInfo_GL_EXT_index_array_formats (void)\n{\n  glewPrintExt(\"GL_EXT_index_array_formats\", GLEW_EXT_index_array_formats, glewIsSupported(\"GL_EXT_index_array_formats\"), glewGetExtension(\"GL_EXT_index_array_formats\"));\n}\n\n#endif /* GL_EXT_index_array_formats */\n\n#ifdef GL_EXT_index_func\n\nstatic void _glewInfo_GL_EXT_index_func (void)\n{\n  glewPrintExt(\"GL_EXT_index_func\", GLEW_EXT_index_func, glewIsSupported(\"GL_EXT_index_func\"), glewGetExtension(\"GL_EXT_index_func\"));\n\n  glewInfoFunc(\"glIndexFuncEXT\", glIndexFuncEXT == NULL);\n}\n\n#endif /* GL_EXT_index_func */\n\n#ifdef GL_EXT_index_material\n\nstatic void _glewInfo_GL_EXT_index_material (void)\n{\n  glewPrintExt(\"GL_EXT_index_material\", GLEW_EXT_index_material, glewIsSupported(\"GL_EXT_index_material\"), glewGetExtension(\"GL_EXT_index_material\"));\n\n  glewInfoFunc(\"glIndexMaterialEXT\", glIndexMaterialEXT == NULL);\n}\n\n#endif /* GL_EXT_index_material */\n\n#ifdef GL_EXT_index_texture\n\nstatic void _glewInfo_GL_EXT_index_texture (void)\n{\n  glewPrintExt(\"GL_EXT_index_texture\", GLEW_EXT_index_texture, glewIsSupported(\"GL_EXT_index_texture\"), glewGetExtension(\"GL_EXT_index_texture\"));\n}\n\n#endif /* GL_EXT_index_texture */\n\n#ifdef GL_EXT_light_texture\n\nstatic void _glewInfo_GL_EXT_light_texture (void)\n{\n  glewPrintExt(\"GL_EXT_light_texture\", GLEW_EXT_light_texture, glewIsSupported(\"GL_EXT_light_texture\"), glewGetExtension(\"GL_EXT_light_texture\"));\n\n  glewInfoFunc(\"glApplyTextureEXT\", glApplyTextureEXT == NULL);\n  glewInfoFunc(\"glTextureLightEXT\", glTextureLightEXT == NULL);\n  glewInfoFunc(\"glTextureMaterialEXT\", glTextureMaterialEXT == NULL);\n}\n\n#endif /* GL_EXT_light_texture */\n\n#ifdef GL_EXT_misc_attribute\n\nstatic void _glewInfo_GL_EXT_misc_attribute (void)\n{\n  glewPrintExt(\"GL_EXT_misc_attribute\", GLEW_EXT_misc_attribute, glewIsSupported(\"GL_EXT_misc_attribute\"), glewGetExtension(\"GL_EXT_misc_attribute\"));\n}\n\n#endif /* GL_EXT_misc_attribute */\n\n#ifdef GL_EXT_multi_draw_arrays\n\nstatic void _glewInfo_GL_EXT_multi_draw_arrays (void)\n{\n  glewPrintExt(\"GL_EXT_multi_draw_arrays\", GLEW_EXT_multi_draw_arrays, glewIsSupported(\"GL_EXT_multi_draw_arrays\"), glewGetExtension(\"GL_EXT_multi_draw_arrays\"));\n\n  glewInfoFunc(\"glMultiDrawArraysEXT\", glMultiDrawArraysEXT == NULL);\n  glewInfoFunc(\"glMultiDrawElementsEXT\", glMultiDrawElementsEXT == NULL);\n}\n\n#endif /* GL_EXT_multi_draw_arrays */\n\n#ifdef GL_EXT_multisample\n\nstatic void _glewInfo_GL_EXT_multisample (void)\n{\n  glewPrintExt(\"GL_EXT_multisample\", GLEW_EXT_multisample, glewIsSupported(\"GL_EXT_multisample\"), glewGetExtension(\"GL_EXT_multisample\"));\n\n  glewInfoFunc(\"glSampleMaskEXT\", glSampleMaskEXT == NULL);\n  glewInfoFunc(\"glSamplePatternEXT\", glSamplePatternEXT == NULL);\n}\n\n#endif /* GL_EXT_multisample */\n\n#ifdef GL_EXT_packed_depth_stencil\n\nstatic void _glewInfo_GL_EXT_packed_depth_stencil (void)\n{\n  glewPrintExt(\"GL_EXT_packed_depth_stencil\", GLEW_EXT_packed_depth_stencil, glewIsSupported(\"GL_EXT_packed_depth_stencil\"), glewGetExtension(\"GL_EXT_packed_depth_stencil\"));\n}\n\n#endif /* GL_EXT_packed_depth_stencil */\n\n#ifdef GL_EXT_packed_float\n\nstatic void _glewInfo_GL_EXT_packed_float (void)\n{\n  glewPrintExt(\"GL_EXT_packed_float\", GLEW_EXT_packed_float, glewIsSupported(\"GL_EXT_packed_float\"), glewGetExtension(\"GL_EXT_packed_float\"));\n}\n\n#endif /* GL_EXT_packed_float */\n\n#ifdef GL_EXT_packed_pixels\n\nstatic void _glewInfo_GL_EXT_packed_pixels (void)\n{\n  glewPrintExt(\"GL_EXT_packed_pixels\", GLEW_EXT_packed_pixels, glewIsSupported(\"GL_EXT_packed_pixels\"), glewGetExtension(\"GL_EXT_packed_pixels\"));\n}\n\n#endif /* GL_EXT_packed_pixels */\n\n#ifdef GL_EXT_paletted_texture\n\nstatic void _glewInfo_GL_EXT_paletted_texture (void)\n{\n  glewPrintExt(\"GL_EXT_paletted_texture\", GLEW_EXT_paletted_texture, glewIsSupported(\"GL_EXT_paletted_texture\"), glewGetExtension(\"GL_EXT_paletted_texture\"));\n\n  glewInfoFunc(\"glColorTableEXT\", glColorTableEXT == NULL);\n  glewInfoFunc(\"glGetColorTableEXT\", glGetColorTableEXT == NULL);\n  glewInfoFunc(\"glGetColorTableParameterfvEXT\", glGetColorTableParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetColorTableParameterivEXT\", glGetColorTableParameterivEXT == NULL);\n}\n\n#endif /* GL_EXT_paletted_texture */\n\n#ifdef GL_EXT_pixel_buffer_object\n\nstatic void _glewInfo_GL_EXT_pixel_buffer_object (void)\n{\n  glewPrintExt(\"GL_EXT_pixel_buffer_object\", GLEW_EXT_pixel_buffer_object, glewIsSupported(\"GL_EXT_pixel_buffer_object\"), glewGetExtension(\"GL_EXT_pixel_buffer_object\"));\n}\n\n#endif /* GL_EXT_pixel_buffer_object */\n\n#ifdef GL_EXT_pixel_transform\n\nstatic void _glewInfo_GL_EXT_pixel_transform (void)\n{\n  glewPrintExt(\"GL_EXT_pixel_transform\", GLEW_EXT_pixel_transform, glewIsSupported(\"GL_EXT_pixel_transform\"), glewGetExtension(\"GL_EXT_pixel_transform\"));\n\n  glewInfoFunc(\"glGetPixelTransformParameterfvEXT\", glGetPixelTransformParameterfvEXT == NULL);\n  glewInfoFunc(\"glGetPixelTransformParameterivEXT\", glGetPixelTransformParameterivEXT == NULL);\n  glewInfoFunc(\"glPixelTransformParameterfEXT\", glPixelTransformParameterfEXT == NULL);\n  glewInfoFunc(\"glPixelTransformParameterfvEXT\", glPixelTransformParameterfvEXT == NULL);\n  glewInfoFunc(\"glPixelTransformParameteriEXT\", glPixelTransformParameteriEXT == NULL);\n  glewInfoFunc(\"glPixelTransformParameterivEXT\", glPixelTransformParameterivEXT == NULL);\n}\n\n#endif /* GL_EXT_pixel_transform */\n\n#ifdef GL_EXT_pixel_transform_color_table\n\nstatic void _glewInfo_GL_EXT_pixel_transform_color_table (void)\n{\n  glewPrintExt(\"GL_EXT_pixel_transform_color_table\", GLEW_EXT_pixel_transform_color_table, glewIsSupported(\"GL_EXT_pixel_transform_color_table\"), glewGetExtension(\"GL_EXT_pixel_transform_color_table\"));\n}\n\n#endif /* GL_EXT_pixel_transform_color_table */\n\n#ifdef GL_EXT_point_parameters\n\nstatic void _glewInfo_GL_EXT_point_parameters (void)\n{\n  glewPrintExt(\"GL_EXT_point_parameters\", GLEW_EXT_point_parameters, glewIsSupported(\"GL_EXT_point_parameters\"), glewGetExtension(\"GL_EXT_point_parameters\"));\n\n  glewInfoFunc(\"glPointParameterfEXT\", glPointParameterfEXT == NULL);\n  glewInfoFunc(\"glPointParameterfvEXT\", glPointParameterfvEXT == NULL);\n}\n\n#endif /* GL_EXT_point_parameters */\n\n#ifdef GL_EXT_polygon_offset\n\nstatic void _glewInfo_GL_EXT_polygon_offset (void)\n{\n  glewPrintExt(\"GL_EXT_polygon_offset\", GLEW_EXT_polygon_offset, glewIsSupported(\"GL_EXT_polygon_offset\"), glewGetExtension(\"GL_EXT_polygon_offset\"));\n\n  glewInfoFunc(\"glPolygonOffsetEXT\", glPolygonOffsetEXT == NULL);\n}\n\n#endif /* GL_EXT_polygon_offset */\n\n#ifdef GL_EXT_provoking_vertex\n\nstatic void _glewInfo_GL_EXT_provoking_vertex (void)\n{\n  glewPrintExt(\"GL_EXT_provoking_vertex\", GLEW_EXT_provoking_vertex, glewIsSupported(\"GL_EXT_provoking_vertex\"), glewGetExtension(\"GL_EXT_provoking_vertex\"));\n\n  glewInfoFunc(\"glProvokingVertexEXT\", glProvokingVertexEXT == NULL);\n}\n\n#endif /* GL_EXT_provoking_vertex */\n\n#ifdef GL_EXT_rescale_normal\n\nstatic void _glewInfo_GL_EXT_rescale_normal (void)\n{\n  glewPrintExt(\"GL_EXT_rescale_normal\", GLEW_EXT_rescale_normal, glewIsSupported(\"GL_EXT_rescale_normal\"), glewGetExtension(\"GL_EXT_rescale_normal\"));\n}\n\n#endif /* GL_EXT_rescale_normal */\n\n#ifdef GL_EXT_scene_marker\n\nstatic void _glewInfo_GL_EXT_scene_marker (void)\n{\n  glewPrintExt(\"GL_EXT_scene_marker\", GLEW_EXT_scene_marker, glewIsSupported(\"GL_EXT_scene_marker\"), glewGetExtension(\"GL_EXT_scene_marker\"));\n\n  glewInfoFunc(\"glBeginSceneEXT\", glBeginSceneEXT == NULL);\n  glewInfoFunc(\"glEndSceneEXT\", glEndSceneEXT == NULL);\n}\n\n#endif /* GL_EXT_scene_marker */\n\n#ifdef GL_EXT_secondary_color\n\nstatic void _glewInfo_GL_EXT_secondary_color (void)\n{\n  glewPrintExt(\"GL_EXT_secondary_color\", GLEW_EXT_secondary_color, glewIsSupported(\"GL_EXT_secondary_color\"), glewGetExtension(\"GL_EXT_secondary_color\"));\n\n  glewInfoFunc(\"glSecondaryColor3bEXT\", glSecondaryColor3bEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3bvEXT\", glSecondaryColor3bvEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3dEXT\", glSecondaryColor3dEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3dvEXT\", glSecondaryColor3dvEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3fEXT\", glSecondaryColor3fEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3fvEXT\", glSecondaryColor3fvEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3iEXT\", glSecondaryColor3iEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3ivEXT\", glSecondaryColor3ivEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3sEXT\", glSecondaryColor3sEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3svEXT\", glSecondaryColor3svEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3ubEXT\", glSecondaryColor3ubEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3ubvEXT\", glSecondaryColor3ubvEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3uiEXT\", glSecondaryColor3uiEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3uivEXT\", glSecondaryColor3uivEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3usEXT\", glSecondaryColor3usEXT == NULL);\n  glewInfoFunc(\"glSecondaryColor3usvEXT\", glSecondaryColor3usvEXT == NULL);\n  glewInfoFunc(\"glSecondaryColorPointerEXT\", glSecondaryColorPointerEXT == NULL);\n}\n\n#endif /* GL_EXT_secondary_color */\n\n#ifdef GL_EXT_separate_shader_objects\n\nstatic void _glewInfo_GL_EXT_separate_shader_objects (void)\n{\n  glewPrintExt(\"GL_EXT_separate_shader_objects\", GLEW_EXT_separate_shader_objects, glewIsSupported(\"GL_EXT_separate_shader_objects\"), glewGetExtension(\"GL_EXT_separate_shader_objects\"));\n\n  glewInfoFunc(\"glActiveProgramEXT\", glActiveProgramEXT == NULL);\n  glewInfoFunc(\"glCreateShaderProgramEXT\", glCreateShaderProgramEXT == NULL);\n  glewInfoFunc(\"glUseShaderProgramEXT\", glUseShaderProgramEXT == NULL);\n}\n\n#endif /* GL_EXT_separate_shader_objects */\n\n#ifdef GL_EXT_separate_specular_color\n\nstatic void _glewInfo_GL_EXT_separate_specular_color (void)\n{\n  glewPrintExt(\"GL_EXT_separate_specular_color\", GLEW_EXT_separate_specular_color, glewIsSupported(\"GL_EXT_separate_specular_color\"), glewGetExtension(\"GL_EXT_separate_specular_color\"));\n}\n\n#endif /* GL_EXT_separate_specular_color */\n\n#ifdef GL_EXT_shader_image_load_store\n\nstatic void _glewInfo_GL_EXT_shader_image_load_store (void)\n{\n  glewPrintExt(\"GL_EXT_shader_image_load_store\", GLEW_EXT_shader_image_load_store, glewIsSupported(\"GL_EXT_shader_image_load_store\"), glewGetExtension(\"GL_EXT_shader_image_load_store\"));\n\n  glewInfoFunc(\"glBindImageTextureEXT\", glBindImageTextureEXT == NULL);\n  glewInfoFunc(\"glMemoryBarrierEXT\", glMemoryBarrierEXT == NULL);\n}\n\n#endif /* GL_EXT_shader_image_load_store */\n\n#ifdef GL_EXT_shadow_funcs\n\nstatic void _glewInfo_GL_EXT_shadow_funcs (void)\n{\n  glewPrintExt(\"GL_EXT_shadow_funcs\", GLEW_EXT_shadow_funcs, glewIsSupported(\"GL_EXT_shadow_funcs\"), glewGetExtension(\"GL_EXT_shadow_funcs\"));\n}\n\n#endif /* GL_EXT_shadow_funcs */\n\n#ifdef GL_EXT_shared_texture_palette\n\nstatic void _glewInfo_GL_EXT_shared_texture_palette (void)\n{\n  glewPrintExt(\"GL_EXT_shared_texture_palette\", GLEW_EXT_shared_texture_palette, glewIsSupported(\"GL_EXT_shared_texture_palette\"), glewGetExtension(\"GL_EXT_shared_texture_palette\"));\n}\n\n#endif /* GL_EXT_shared_texture_palette */\n\n#ifdef GL_EXT_stencil_clear_tag\n\nstatic void _glewInfo_GL_EXT_stencil_clear_tag (void)\n{\n  glewPrintExt(\"GL_EXT_stencil_clear_tag\", GLEW_EXT_stencil_clear_tag, glewIsSupported(\"GL_EXT_stencil_clear_tag\"), glewGetExtension(\"GL_EXT_stencil_clear_tag\"));\n}\n\n#endif /* GL_EXT_stencil_clear_tag */\n\n#ifdef GL_EXT_stencil_two_side\n\nstatic void _glewInfo_GL_EXT_stencil_two_side (void)\n{\n  glewPrintExt(\"GL_EXT_stencil_two_side\", GLEW_EXT_stencil_two_side, glewIsSupported(\"GL_EXT_stencil_two_side\"), glewGetExtension(\"GL_EXT_stencil_two_side\"));\n\n  glewInfoFunc(\"glActiveStencilFaceEXT\", glActiveStencilFaceEXT == NULL);\n}\n\n#endif /* GL_EXT_stencil_two_side */\n\n#ifdef GL_EXT_stencil_wrap\n\nstatic void _glewInfo_GL_EXT_stencil_wrap (void)\n{\n  glewPrintExt(\"GL_EXT_stencil_wrap\", GLEW_EXT_stencil_wrap, glewIsSupported(\"GL_EXT_stencil_wrap\"), glewGetExtension(\"GL_EXT_stencil_wrap\"));\n}\n\n#endif /* GL_EXT_stencil_wrap */\n\n#ifdef GL_EXT_subtexture\n\nstatic void _glewInfo_GL_EXT_subtexture (void)\n{\n  glewPrintExt(\"GL_EXT_subtexture\", GLEW_EXT_subtexture, glewIsSupported(\"GL_EXT_subtexture\"), glewGetExtension(\"GL_EXT_subtexture\"));\n\n  glewInfoFunc(\"glTexSubImage1DEXT\", glTexSubImage1DEXT == NULL);\n  glewInfoFunc(\"glTexSubImage2DEXT\", glTexSubImage2DEXT == NULL);\n  glewInfoFunc(\"glTexSubImage3DEXT\", glTexSubImage3DEXT == NULL);\n}\n\n#endif /* GL_EXT_subtexture */\n\n#ifdef GL_EXT_texture\n\nstatic void _glewInfo_GL_EXT_texture (void)\n{\n  glewPrintExt(\"GL_EXT_texture\", GLEW_EXT_texture, glewIsSupported(\"GL_EXT_texture\"), glewGetExtension(\"GL_EXT_texture\"));\n}\n\n#endif /* GL_EXT_texture */\n\n#ifdef GL_EXT_texture3D\n\nstatic void _glewInfo_GL_EXT_texture3D (void)\n{\n  glewPrintExt(\"GL_EXT_texture3D\", GLEW_EXT_texture3D, glewIsSupported(\"GL_EXT_texture3D\"), glewGetExtension(\"GL_EXT_texture3D\"));\n\n  glewInfoFunc(\"glTexImage3DEXT\", glTexImage3DEXT == NULL);\n}\n\n#endif /* GL_EXT_texture3D */\n\n#ifdef GL_EXT_texture_array\n\nstatic void _glewInfo_GL_EXT_texture_array (void)\n{\n  glewPrintExt(\"GL_EXT_texture_array\", GLEW_EXT_texture_array, glewIsSupported(\"GL_EXT_texture_array\"), glewGetExtension(\"GL_EXT_texture_array\"));\n\n  glewInfoFunc(\"glFramebufferTextureLayerEXT\", glFramebufferTextureLayerEXT == NULL);\n}\n\n#endif /* GL_EXT_texture_array */\n\n#ifdef GL_EXT_texture_buffer_object\n\nstatic void _glewInfo_GL_EXT_texture_buffer_object (void)\n{\n  glewPrintExt(\"GL_EXT_texture_buffer_object\", GLEW_EXT_texture_buffer_object, glewIsSupported(\"GL_EXT_texture_buffer_object\"), glewGetExtension(\"GL_EXT_texture_buffer_object\"));\n\n  glewInfoFunc(\"glTexBufferEXT\", glTexBufferEXT == NULL);\n}\n\n#endif /* GL_EXT_texture_buffer_object */\n\n#ifdef GL_EXT_texture_compression_dxt1\n\nstatic void _glewInfo_GL_EXT_texture_compression_dxt1 (void)\n{\n  glewPrintExt(\"GL_EXT_texture_compression_dxt1\", GLEW_EXT_texture_compression_dxt1, glewIsSupported(\"GL_EXT_texture_compression_dxt1\"), glewGetExtension(\"GL_EXT_texture_compression_dxt1\"));\n}\n\n#endif /* GL_EXT_texture_compression_dxt1 */\n\n#ifdef GL_EXT_texture_compression_latc\n\nstatic void _glewInfo_GL_EXT_texture_compression_latc (void)\n{\n  glewPrintExt(\"GL_EXT_texture_compression_latc\", GLEW_EXT_texture_compression_latc, glewIsSupported(\"GL_EXT_texture_compression_latc\"), glewGetExtension(\"GL_EXT_texture_compression_latc\"));\n}\n\n#endif /* GL_EXT_texture_compression_latc */\n\n#ifdef GL_EXT_texture_compression_rgtc\n\nstatic void _glewInfo_GL_EXT_texture_compression_rgtc (void)\n{\n  glewPrintExt(\"GL_EXT_texture_compression_rgtc\", GLEW_EXT_texture_compression_rgtc, glewIsSupported(\"GL_EXT_texture_compression_rgtc\"), glewGetExtension(\"GL_EXT_texture_compression_rgtc\"));\n}\n\n#endif /* GL_EXT_texture_compression_rgtc */\n\n#ifdef GL_EXT_texture_compression_s3tc\n\nstatic void _glewInfo_GL_EXT_texture_compression_s3tc (void)\n{\n  glewPrintExt(\"GL_EXT_texture_compression_s3tc\", GLEW_EXT_texture_compression_s3tc, glewIsSupported(\"GL_EXT_texture_compression_s3tc\"), glewGetExtension(\"GL_EXT_texture_compression_s3tc\"));\n}\n\n#endif /* GL_EXT_texture_compression_s3tc */\n\n#ifdef GL_EXT_texture_cube_map\n\nstatic void _glewInfo_GL_EXT_texture_cube_map (void)\n{\n  glewPrintExt(\"GL_EXT_texture_cube_map\", GLEW_EXT_texture_cube_map, glewIsSupported(\"GL_EXT_texture_cube_map\"), glewGetExtension(\"GL_EXT_texture_cube_map\"));\n}\n\n#endif /* GL_EXT_texture_cube_map */\n\n#ifdef GL_EXT_texture_edge_clamp\n\nstatic void _glewInfo_GL_EXT_texture_edge_clamp (void)\n{\n  glewPrintExt(\"GL_EXT_texture_edge_clamp\", GLEW_EXT_texture_edge_clamp, glewIsSupported(\"GL_EXT_texture_edge_clamp\"), glewGetExtension(\"GL_EXT_texture_edge_clamp\"));\n}\n\n#endif /* GL_EXT_texture_edge_clamp */\n\n#ifdef GL_EXT_texture_env\n\nstatic void _glewInfo_GL_EXT_texture_env (void)\n{\n  glewPrintExt(\"GL_EXT_texture_env\", GLEW_EXT_texture_env, glewIsSupported(\"GL_EXT_texture_env\"), glewGetExtension(\"GL_EXT_texture_env\"));\n}\n\n#endif /* GL_EXT_texture_env */\n\n#ifdef GL_EXT_texture_env_add\n\nstatic void _glewInfo_GL_EXT_texture_env_add (void)\n{\n  glewPrintExt(\"GL_EXT_texture_env_add\", GLEW_EXT_texture_env_add, glewIsSupported(\"GL_EXT_texture_env_add\"), glewGetExtension(\"GL_EXT_texture_env_add\"));\n}\n\n#endif /* GL_EXT_texture_env_add */\n\n#ifdef GL_EXT_texture_env_combine\n\nstatic void _glewInfo_GL_EXT_texture_env_combine (void)\n{\n  glewPrintExt(\"GL_EXT_texture_env_combine\", GLEW_EXT_texture_env_combine, glewIsSupported(\"GL_EXT_texture_env_combine\"), glewGetExtension(\"GL_EXT_texture_env_combine\"));\n}\n\n#endif /* GL_EXT_texture_env_combine */\n\n#ifdef GL_EXT_texture_env_dot3\n\nstatic void _glewInfo_GL_EXT_texture_env_dot3 (void)\n{\n  glewPrintExt(\"GL_EXT_texture_env_dot3\", GLEW_EXT_texture_env_dot3, glewIsSupported(\"GL_EXT_texture_env_dot3\"), glewGetExtension(\"GL_EXT_texture_env_dot3\"));\n}\n\n#endif /* GL_EXT_texture_env_dot3 */\n\n#ifdef GL_EXT_texture_filter_anisotropic\n\nstatic void _glewInfo_GL_EXT_texture_filter_anisotropic (void)\n{\n  glewPrintExt(\"GL_EXT_texture_filter_anisotropic\", GLEW_EXT_texture_filter_anisotropic, glewIsSupported(\"GL_EXT_texture_filter_anisotropic\"), glewGetExtension(\"GL_EXT_texture_filter_anisotropic\"));\n}\n\n#endif /* GL_EXT_texture_filter_anisotropic */\n\n#ifdef GL_EXT_texture_integer\n\nstatic void _glewInfo_GL_EXT_texture_integer (void)\n{\n  glewPrintExt(\"GL_EXT_texture_integer\", GLEW_EXT_texture_integer, glewIsSupported(\"GL_EXT_texture_integer\"), glewGetExtension(\"GL_EXT_texture_integer\"));\n\n  glewInfoFunc(\"glClearColorIiEXT\", glClearColorIiEXT == NULL);\n  glewInfoFunc(\"glClearColorIuiEXT\", glClearColorIuiEXT == NULL);\n  glewInfoFunc(\"glGetTexParameterIivEXT\", glGetTexParameterIivEXT == NULL);\n  glewInfoFunc(\"glGetTexParameterIuivEXT\", glGetTexParameterIuivEXT == NULL);\n  glewInfoFunc(\"glTexParameterIivEXT\", glTexParameterIivEXT == NULL);\n  glewInfoFunc(\"glTexParameterIuivEXT\", glTexParameterIuivEXT == NULL);\n}\n\n#endif /* GL_EXT_texture_integer */\n\n#ifdef GL_EXT_texture_lod_bias\n\nstatic void _glewInfo_GL_EXT_texture_lod_bias (void)\n{\n  glewPrintExt(\"GL_EXT_texture_lod_bias\", GLEW_EXT_texture_lod_bias, glewIsSupported(\"GL_EXT_texture_lod_bias\"), glewGetExtension(\"GL_EXT_texture_lod_bias\"));\n}\n\n#endif /* GL_EXT_texture_lod_bias */\n\n#ifdef GL_EXT_texture_mirror_clamp\n\nstatic void _glewInfo_GL_EXT_texture_mirror_clamp (void)\n{\n  glewPrintExt(\"GL_EXT_texture_mirror_clamp\", GLEW_EXT_texture_mirror_clamp, glewIsSupported(\"GL_EXT_texture_mirror_clamp\"), glewGetExtension(\"GL_EXT_texture_mirror_clamp\"));\n}\n\n#endif /* GL_EXT_texture_mirror_clamp */\n\n#ifdef GL_EXT_texture_object\n\nstatic void _glewInfo_GL_EXT_texture_object (void)\n{\n  glewPrintExt(\"GL_EXT_texture_object\", GLEW_EXT_texture_object, glewIsSupported(\"GL_EXT_texture_object\"), glewGetExtension(\"GL_EXT_texture_object\"));\n\n  glewInfoFunc(\"glAreTexturesResidentEXT\", glAreTexturesResidentEXT == NULL);\n  glewInfoFunc(\"glBindTextureEXT\", glBindTextureEXT == NULL);\n  glewInfoFunc(\"glDeleteTexturesEXT\", glDeleteTexturesEXT == NULL);\n  glewInfoFunc(\"glGenTexturesEXT\", glGenTexturesEXT == NULL);\n  glewInfoFunc(\"glIsTextureEXT\", glIsTextureEXT == NULL);\n  glewInfoFunc(\"glPrioritizeTexturesEXT\", glPrioritizeTexturesEXT == NULL);\n}\n\n#endif /* GL_EXT_texture_object */\n\n#ifdef GL_EXT_texture_perturb_normal\n\nstatic void _glewInfo_GL_EXT_texture_perturb_normal (void)\n{\n  glewPrintExt(\"GL_EXT_texture_perturb_normal\", GLEW_EXT_texture_perturb_normal, glewIsSupported(\"GL_EXT_texture_perturb_normal\"), glewGetExtension(\"GL_EXT_texture_perturb_normal\"));\n\n  glewInfoFunc(\"glTextureNormalEXT\", glTextureNormalEXT == NULL);\n}\n\n#endif /* GL_EXT_texture_perturb_normal */\n\n#ifdef GL_EXT_texture_rectangle\n\nstatic void _glewInfo_GL_EXT_texture_rectangle (void)\n{\n  glewPrintExt(\"GL_EXT_texture_rectangle\", GLEW_EXT_texture_rectangle, glewIsSupported(\"GL_EXT_texture_rectangle\"), glewGetExtension(\"GL_EXT_texture_rectangle\"));\n}\n\n#endif /* GL_EXT_texture_rectangle */\n\n#ifdef GL_EXT_texture_sRGB\n\nstatic void _glewInfo_GL_EXT_texture_sRGB (void)\n{\n  glewPrintExt(\"GL_EXT_texture_sRGB\", GLEW_EXT_texture_sRGB, glewIsSupported(\"GL_EXT_texture_sRGB\"), glewGetExtension(\"GL_EXT_texture_sRGB\"));\n}\n\n#endif /* GL_EXT_texture_sRGB */\n\n#ifdef GL_EXT_texture_sRGB_decode\n\nstatic void _glewInfo_GL_EXT_texture_sRGB_decode (void)\n{\n  glewPrintExt(\"GL_EXT_texture_sRGB_decode\", GLEW_EXT_texture_sRGB_decode, glewIsSupported(\"GL_EXT_texture_sRGB_decode\"), glewGetExtension(\"GL_EXT_texture_sRGB_decode\"));\n}\n\n#endif /* GL_EXT_texture_sRGB_decode */\n\n#ifdef GL_EXT_texture_shared_exponent\n\nstatic void _glewInfo_GL_EXT_texture_shared_exponent (void)\n{\n  glewPrintExt(\"GL_EXT_texture_shared_exponent\", GLEW_EXT_texture_shared_exponent, glewIsSupported(\"GL_EXT_texture_shared_exponent\"), glewGetExtension(\"GL_EXT_texture_shared_exponent\"));\n}\n\n#endif /* GL_EXT_texture_shared_exponent */\n\n#ifdef GL_EXT_texture_snorm\n\nstatic void _glewInfo_GL_EXT_texture_snorm (void)\n{\n  glewPrintExt(\"GL_EXT_texture_snorm\", GLEW_EXT_texture_snorm, glewIsSupported(\"GL_EXT_texture_snorm\"), glewGetExtension(\"GL_EXT_texture_snorm\"));\n}\n\n#endif /* GL_EXT_texture_snorm */\n\n#ifdef GL_EXT_texture_swizzle\n\nstatic void _glewInfo_GL_EXT_texture_swizzle (void)\n{\n  glewPrintExt(\"GL_EXT_texture_swizzle\", GLEW_EXT_texture_swizzle, glewIsSupported(\"GL_EXT_texture_swizzle\"), glewGetExtension(\"GL_EXT_texture_swizzle\"));\n}\n\n#endif /* GL_EXT_texture_swizzle */\n\n#ifdef GL_EXT_timer_query\n\nstatic void _glewInfo_GL_EXT_timer_query (void)\n{\n  glewPrintExt(\"GL_EXT_timer_query\", GLEW_EXT_timer_query, glewIsSupported(\"GL_EXT_timer_query\"), glewGetExtension(\"GL_EXT_timer_query\"));\n\n  glewInfoFunc(\"glGetQueryObjecti64vEXT\", glGetQueryObjecti64vEXT == NULL);\n  glewInfoFunc(\"glGetQueryObjectui64vEXT\", glGetQueryObjectui64vEXT == NULL);\n}\n\n#endif /* GL_EXT_timer_query */\n\n#ifdef GL_EXT_transform_feedback\n\nstatic void _glewInfo_GL_EXT_transform_feedback (void)\n{\n  glewPrintExt(\"GL_EXT_transform_feedback\", GLEW_EXT_transform_feedback, glewIsSupported(\"GL_EXT_transform_feedback\"), glewGetExtension(\"GL_EXT_transform_feedback\"));\n\n  glewInfoFunc(\"glBeginTransformFeedbackEXT\", glBeginTransformFeedbackEXT == NULL);\n  glewInfoFunc(\"glBindBufferBaseEXT\", glBindBufferBaseEXT == NULL);\n  glewInfoFunc(\"glBindBufferOffsetEXT\", glBindBufferOffsetEXT == NULL);\n  glewInfoFunc(\"glBindBufferRangeEXT\", glBindBufferRangeEXT == NULL);\n  glewInfoFunc(\"glEndTransformFeedbackEXT\", glEndTransformFeedbackEXT == NULL);\n  glewInfoFunc(\"glGetTransformFeedbackVaryingEXT\", glGetTransformFeedbackVaryingEXT == NULL);\n  glewInfoFunc(\"glTransformFeedbackVaryingsEXT\", glTransformFeedbackVaryingsEXT == NULL);\n}\n\n#endif /* GL_EXT_transform_feedback */\n\n#ifdef GL_EXT_vertex_array\n\nstatic void _glewInfo_GL_EXT_vertex_array (void)\n{\n  glewPrintExt(\"GL_EXT_vertex_array\", GLEW_EXT_vertex_array, glewIsSupported(\"GL_EXT_vertex_array\"), glewGetExtension(\"GL_EXT_vertex_array\"));\n\n  glewInfoFunc(\"glArrayElementEXT\", glArrayElementEXT == NULL);\n  glewInfoFunc(\"glColorPointerEXT\", glColorPointerEXT == NULL);\n  glewInfoFunc(\"glDrawArraysEXT\", glDrawArraysEXT == NULL);\n  glewInfoFunc(\"glEdgeFlagPointerEXT\", glEdgeFlagPointerEXT == NULL);\n  glewInfoFunc(\"glIndexPointerEXT\", glIndexPointerEXT == NULL);\n  glewInfoFunc(\"glNormalPointerEXT\", glNormalPointerEXT == NULL);\n  glewInfoFunc(\"glTexCoordPointerEXT\", glTexCoordPointerEXT == NULL);\n  glewInfoFunc(\"glVertexPointerEXT\", glVertexPointerEXT == NULL);\n}\n\n#endif /* GL_EXT_vertex_array */\n\n#ifdef GL_EXT_vertex_array_bgra\n\nstatic void _glewInfo_GL_EXT_vertex_array_bgra (void)\n{\n  glewPrintExt(\"GL_EXT_vertex_array_bgra\", GLEW_EXT_vertex_array_bgra, glewIsSupported(\"GL_EXT_vertex_array_bgra\"), glewGetExtension(\"GL_EXT_vertex_array_bgra\"));\n}\n\n#endif /* GL_EXT_vertex_array_bgra */\n\n#ifdef GL_EXT_vertex_attrib_64bit\n\nstatic void _glewInfo_GL_EXT_vertex_attrib_64bit (void)\n{\n  glewPrintExt(\"GL_EXT_vertex_attrib_64bit\", GLEW_EXT_vertex_attrib_64bit, glewIsSupported(\"GL_EXT_vertex_attrib_64bit\"), glewGetExtension(\"GL_EXT_vertex_attrib_64bit\"));\n\n  glewInfoFunc(\"glGetVertexAttribLdvEXT\", glGetVertexAttribLdvEXT == NULL);\n  glewInfoFunc(\"glVertexArrayVertexAttribLOffsetEXT\", glVertexArrayVertexAttribLOffsetEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL1dEXT\", glVertexAttribL1dEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL1dvEXT\", glVertexAttribL1dvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL2dEXT\", glVertexAttribL2dEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL2dvEXT\", glVertexAttribL2dvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL3dEXT\", glVertexAttribL3dEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL3dvEXT\", glVertexAttribL3dvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL4dEXT\", glVertexAttribL4dEXT == NULL);\n  glewInfoFunc(\"glVertexAttribL4dvEXT\", glVertexAttribL4dvEXT == NULL);\n  glewInfoFunc(\"glVertexAttribLPointerEXT\", glVertexAttribLPointerEXT == NULL);\n}\n\n#endif /* GL_EXT_vertex_attrib_64bit */\n\n#ifdef GL_EXT_vertex_shader\n\nstatic void _glewInfo_GL_EXT_vertex_shader (void)\n{\n  glewPrintExt(\"GL_EXT_vertex_shader\", GLEW_EXT_vertex_shader, glewIsSupported(\"GL_EXT_vertex_shader\"), glewGetExtension(\"GL_EXT_vertex_shader\"));\n\n  glewInfoFunc(\"glBeginVertexShaderEXT\", glBeginVertexShaderEXT == NULL);\n  glewInfoFunc(\"glBindLightParameterEXT\", glBindLightParameterEXT == NULL);\n  glewInfoFunc(\"glBindMaterialParameterEXT\", glBindMaterialParameterEXT == NULL);\n  glewInfoFunc(\"glBindParameterEXT\", glBindParameterEXT == NULL);\n  glewInfoFunc(\"glBindTexGenParameterEXT\", glBindTexGenParameterEXT == NULL);\n  glewInfoFunc(\"glBindTextureUnitParameterEXT\", glBindTextureUnitParameterEXT == NULL);\n  glewInfoFunc(\"glBindVertexShaderEXT\", glBindVertexShaderEXT == NULL);\n  glewInfoFunc(\"glDeleteVertexShaderEXT\", glDeleteVertexShaderEXT == NULL);\n  glewInfoFunc(\"glDisableVariantClientStateEXT\", glDisableVariantClientStateEXT == NULL);\n  glewInfoFunc(\"glEnableVariantClientStateEXT\", glEnableVariantClientStateEXT == NULL);\n  glewInfoFunc(\"glEndVertexShaderEXT\", glEndVertexShaderEXT == NULL);\n  glewInfoFunc(\"glExtractComponentEXT\", glExtractComponentEXT == NULL);\n  glewInfoFunc(\"glGenSymbolsEXT\", glGenSymbolsEXT == NULL);\n  glewInfoFunc(\"glGenVertexShadersEXT\", glGenVertexShadersEXT == NULL);\n  glewInfoFunc(\"glGetInvariantBooleanvEXT\", glGetInvariantBooleanvEXT == NULL);\n  glewInfoFunc(\"glGetInvariantFloatvEXT\", glGetInvariantFloatvEXT == NULL);\n  glewInfoFunc(\"glGetInvariantIntegervEXT\", glGetInvariantIntegervEXT == NULL);\n  glewInfoFunc(\"glGetLocalConstantBooleanvEXT\", glGetLocalConstantBooleanvEXT == NULL);\n  glewInfoFunc(\"glGetLocalConstantFloatvEXT\", glGetLocalConstantFloatvEXT == NULL);\n  glewInfoFunc(\"glGetLocalConstantIntegervEXT\", glGetLocalConstantIntegervEXT == NULL);\n  glewInfoFunc(\"glGetVariantBooleanvEXT\", glGetVariantBooleanvEXT == NULL);\n  glewInfoFunc(\"glGetVariantFloatvEXT\", glGetVariantFloatvEXT == NULL);\n  glewInfoFunc(\"glGetVariantIntegervEXT\", glGetVariantIntegervEXT == NULL);\n  glewInfoFunc(\"glGetVariantPointervEXT\", glGetVariantPointervEXT == NULL);\n  glewInfoFunc(\"glInsertComponentEXT\", glInsertComponentEXT == NULL);\n  glewInfoFunc(\"glIsVariantEnabledEXT\", glIsVariantEnabledEXT == NULL);\n  glewInfoFunc(\"glSetInvariantEXT\", glSetInvariantEXT == NULL);\n  glewInfoFunc(\"glSetLocalConstantEXT\", glSetLocalConstantEXT == NULL);\n  glewInfoFunc(\"glShaderOp1EXT\", glShaderOp1EXT == NULL);\n  glewInfoFunc(\"glShaderOp2EXT\", glShaderOp2EXT == NULL);\n  glewInfoFunc(\"glShaderOp3EXT\", glShaderOp3EXT == NULL);\n  glewInfoFunc(\"glSwizzleEXT\", glSwizzleEXT == NULL);\n  glewInfoFunc(\"glVariantPointerEXT\", glVariantPointerEXT == NULL);\n  glewInfoFunc(\"glVariantbvEXT\", glVariantbvEXT == NULL);\n  glewInfoFunc(\"glVariantdvEXT\", glVariantdvEXT == NULL);\n  glewInfoFunc(\"glVariantfvEXT\", glVariantfvEXT == NULL);\n  glewInfoFunc(\"glVariantivEXT\", glVariantivEXT == NULL);\n  glewInfoFunc(\"glVariantsvEXT\", glVariantsvEXT == NULL);\n  glewInfoFunc(\"glVariantubvEXT\", glVariantubvEXT == NULL);\n  glewInfoFunc(\"glVariantuivEXT\", glVariantuivEXT == NULL);\n  glewInfoFunc(\"glVariantusvEXT\", glVariantusvEXT == NULL);\n  glewInfoFunc(\"glWriteMaskEXT\", glWriteMaskEXT == NULL);\n}\n\n#endif /* GL_EXT_vertex_shader */\n\n#ifdef GL_EXT_vertex_weighting\n\nstatic void _glewInfo_GL_EXT_vertex_weighting (void)\n{\n  glewPrintExt(\"GL_EXT_vertex_weighting\", GLEW_EXT_vertex_weighting, glewIsSupported(\"GL_EXT_vertex_weighting\"), glewGetExtension(\"GL_EXT_vertex_weighting\"));\n\n  glewInfoFunc(\"glVertexWeightPointerEXT\", glVertexWeightPointerEXT == NULL);\n  glewInfoFunc(\"glVertexWeightfEXT\", glVertexWeightfEXT == NULL);\n  glewInfoFunc(\"glVertexWeightfvEXT\", glVertexWeightfvEXT == NULL);\n}\n\n#endif /* GL_EXT_vertex_weighting */\n\n#ifdef GL_EXT_x11_sync_object\n\nstatic void _glewInfo_GL_EXT_x11_sync_object (void)\n{\n  glewPrintExt(\"GL_EXT_x11_sync_object\", GLEW_EXT_x11_sync_object, glewIsSupported(\"GL_EXT_x11_sync_object\"), glewGetExtension(\"GL_EXT_x11_sync_object\"));\n\n  glewInfoFunc(\"glImportSyncEXT\", glImportSyncEXT == NULL);\n}\n\n#endif /* GL_EXT_x11_sync_object */\n\n#ifdef GL_GREMEDY_frame_terminator\n\nstatic void _glewInfo_GL_GREMEDY_frame_terminator (void)\n{\n  glewPrintExt(\"GL_GREMEDY_frame_terminator\", GLEW_GREMEDY_frame_terminator, glewIsSupported(\"GL_GREMEDY_frame_terminator\"), glewGetExtension(\"GL_GREMEDY_frame_terminator\"));\n\n  glewInfoFunc(\"glFrameTerminatorGREMEDY\", glFrameTerminatorGREMEDY == NULL);\n}\n\n#endif /* GL_GREMEDY_frame_terminator */\n\n#ifdef GL_GREMEDY_string_marker\n\nstatic void _glewInfo_GL_GREMEDY_string_marker (void)\n{\n  glewPrintExt(\"GL_GREMEDY_string_marker\", GLEW_GREMEDY_string_marker, glewIsSupported(\"GL_GREMEDY_string_marker\"), glewGetExtension(\"GL_GREMEDY_string_marker\"));\n\n  glewInfoFunc(\"glStringMarkerGREMEDY\", glStringMarkerGREMEDY == NULL);\n}\n\n#endif /* GL_GREMEDY_string_marker */\n\n#ifdef GL_HP_convolution_border_modes\n\nstatic void _glewInfo_GL_HP_convolution_border_modes (void)\n{\n  glewPrintExt(\"GL_HP_convolution_border_modes\", GLEW_HP_convolution_border_modes, glewIsSupported(\"GL_HP_convolution_border_modes\"), glewGetExtension(\"GL_HP_convolution_border_modes\"));\n}\n\n#endif /* GL_HP_convolution_border_modes */\n\n#ifdef GL_HP_image_transform\n\nstatic void _glewInfo_GL_HP_image_transform (void)\n{\n  glewPrintExt(\"GL_HP_image_transform\", GLEW_HP_image_transform, glewIsSupported(\"GL_HP_image_transform\"), glewGetExtension(\"GL_HP_image_transform\"));\n\n  glewInfoFunc(\"glGetImageTransformParameterfvHP\", glGetImageTransformParameterfvHP == NULL);\n  glewInfoFunc(\"glGetImageTransformParameterivHP\", glGetImageTransformParameterivHP == NULL);\n  glewInfoFunc(\"glImageTransformParameterfHP\", glImageTransformParameterfHP == NULL);\n  glewInfoFunc(\"glImageTransformParameterfvHP\", glImageTransformParameterfvHP == NULL);\n  glewInfoFunc(\"glImageTransformParameteriHP\", glImageTransformParameteriHP == NULL);\n  glewInfoFunc(\"glImageTransformParameterivHP\", glImageTransformParameterivHP == NULL);\n}\n\n#endif /* GL_HP_image_transform */\n\n#ifdef GL_HP_occlusion_test\n\nstatic void _glewInfo_GL_HP_occlusion_test (void)\n{\n  glewPrintExt(\"GL_HP_occlusion_test\", GLEW_HP_occlusion_test, glewIsSupported(\"GL_HP_occlusion_test\"), glewGetExtension(\"GL_HP_occlusion_test\"));\n}\n\n#endif /* GL_HP_occlusion_test */\n\n#ifdef GL_HP_texture_lighting\n\nstatic void _glewInfo_GL_HP_texture_lighting (void)\n{\n  glewPrintExt(\"GL_HP_texture_lighting\", GLEW_HP_texture_lighting, glewIsSupported(\"GL_HP_texture_lighting\"), glewGetExtension(\"GL_HP_texture_lighting\"));\n}\n\n#endif /* GL_HP_texture_lighting */\n\n#ifdef GL_IBM_cull_vertex\n\nstatic void _glewInfo_GL_IBM_cull_vertex (void)\n{\n  glewPrintExt(\"GL_IBM_cull_vertex\", GLEW_IBM_cull_vertex, glewIsSupported(\"GL_IBM_cull_vertex\"), glewGetExtension(\"GL_IBM_cull_vertex\"));\n}\n\n#endif /* GL_IBM_cull_vertex */\n\n#ifdef GL_IBM_multimode_draw_arrays\n\nstatic void _glewInfo_GL_IBM_multimode_draw_arrays (void)\n{\n  glewPrintExt(\"GL_IBM_multimode_draw_arrays\", GLEW_IBM_multimode_draw_arrays, glewIsSupported(\"GL_IBM_multimode_draw_arrays\"), glewGetExtension(\"GL_IBM_multimode_draw_arrays\"));\n\n  glewInfoFunc(\"glMultiModeDrawArraysIBM\", glMultiModeDrawArraysIBM == NULL);\n  glewInfoFunc(\"glMultiModeDrawElementsIBM\", glMultiModeDrawElementsIBM == NULL);\n}\n\n#endif /* GL_IBM_multimode_draw_arrays */\n\n#ifdef GL_IBM_rasterpos_clip\n\nstatic void _glewInfo_GL_IBM_rasterpos_clip (void)\n{\n  glewPrintExt(\"GL_IBM_rasterpos_clip\", GLEW_IBM_rasterpos_clip, glewIsSupported(\"GL_IBM_rasterpos_clip\"), glewGetExtension(\"GL_IBM_rasterpos_clip\"));\n}\n\n#endif /* GL_IBM_rasterpos_clip */\n\n#ifdef GL_IBM_static_data\n\nstatic void _glewInfo_GL_IBM_static_data (void)\n{\n  glewPrintExt(\"GL_IBM_static_data\", GLEW_IBM_static_data, glewIsSupported(\"GL_IBM_static_data\"), glewGetExtension(\"GL_IBM_static_data\"));\n}\n\n#endif /* GL_IBM_static_data */\n\n#ifdef GL_IBM_texture_mirrored_repeat\n\nstatic void _glewInfo_GL_IBM_texture_mirrored_repeat (void)\n{\n  glewPrintExt(\"GL_IBM_texture_mirrored_repeat\", GLEW_IBM_texture_mirrored_repeat, glewIsSupported(\"GL_IBM_texture_mirrored_repeat\"), glewGetExtension(\"GL_IBM_texture_mirrored_repeat\"));\n}\n\n#endif /* GL_IBM_texture_mirrored_repeat */\n\n#ifdef GL_IBM_vertex_array_lists\n\nstatic void _glewInfo_GL_IBM_vertex_array_lists (void)\n{\n  glewPrintExt(\"GL_IBM_vertex_array_lists\", GLEW_IBM_vertex_array_lists, glewIsSupported(\"GL_IBM_vertex_array_lists\"), glewGetExtension(\"GL_IBM_vertex_array_lists\"));\n\n  glewInfoFunc(\"glColorPointerListIBM\", glColorPointerListIBM == NULL);\n  glewInfoFunc(\"glEdgeFlagPointerListIBM\", glEdgeFlagPointerListIBM == NULL);\n  glewInfoFunc(\"glFogCoordPointerListIBM\", glFogCoordPointerListIBM == NULL);\n  glewInfoFunc(\"glIndexPointerListIBM\", glIndexPointerListIBM == NULL);\n  glewInfoFunc(\"glNormalPointerListIBM\", glNormalPointerListIBM == NULL);\n  glewInfoFunc(\"glSecondaryColorPointerListIBM\", glSecondaryColorPointerListIBM == NULL);\n  glewInfoFunc(\"glTexCoordPointerListIBM\", glTexCoordPointerListIBM == NULL);\n  glewInfoFunc(\"glVertexPointerListIBM\", glVertexPointerListIBM == NULL);\n}\n\n#endif /* GL_IBM_vertex_array_lists */\n\n#ifdef GL_INGR_color_clamp\n\nstatic void _glewInfo_GL_INGR_color_clamp (void)\n{\n  glewPrintExt(\"GL_INGR_color_clamp\", GLEW_INGR_color_clamp, glewIsSupported(\"GL_INGR_color_clamp\"), glewGetExtension(\"GL_INGR_color_clamp\"));\n}\n\n#endif /* GL_INGR_color_clamp */\n\n#ifdef GL_INGR_interlace_read\n\nstatic void _glewInfo_GL_INGR_interlace_read (void)\n{\n  glewPrintExt(\"GL_INGR_interlace_read\", GLEW_INGR_interlace_read, glewIsSupported(\"GL_INGR_interlace_read\"), glewGetExtension(\"GL_INGR_interlace_read\"));\n}\n\n#endif /* GL_INGR_interlace_read */\n\n#ifdef GL_INTEL_parallel_arrays\n\nstatic void _glewInfo_GL_INTEL_parallel_arrays (void)\n{\n  glewPrintExt(\"GL_INTEL_parallel_arrays\", GLEW_INTEL_parallel_arrays, glewIsSupported(\"GL_INTEL_parallel_arrays\"), glewGetExtension(\"GL_INTEL_parallel_arrays\"));\n\n  glewInfoFunc(\"glColorPointervINTEL\", glColorPointervINTEL == NULL);\n  glewInfoFunc(\"glNormalPointervINTEL\", glNormalPointervINTEL == NULL);\n  glewInfoFunc(\"glTexCoordPointervINTEL\", glTexCoordPointervINTEL == NULL);\n  glewInfoFunc(\"glVertexPointervINTEL\", glVertexPointervINTEL == NULL);\n}\n\n#endif /* GL_INTEL_parallel_arrays */\n\n#ifdef GL_INTEL_texture_scissor\n\nstatic void _glewInfo_GL_INTEL_texture_scissor (void)\n{\n  glewPrintExt(\"GL_INTEL_texture_scissor\", GLEW_INTEL_texture_scissor, glewIsSupported(\"GL_INTEL_texture_scissor\"), glewGetExtension(\"GL_INTEL_texture_scissor\"));\n\n  glewInfoFunc(\"glTexScissorFuncINTEL\", glTexScissorFuncINTEL == NULL);\n  glewInfoFunc(\"glTexScissorINTEL\", glTexScissorINTEL == NULL);\n}\n\n#endif /* GL_INTEL_texture_scissor */\n\n#ifdef GL_KHR_debug\n\nstatic void _glewInfo_GL_KHR_debug (void)\n{\n  glewPrintExt(\"GL_KHR_debug\", GLEW_KHR_debug, glewIsSupported(\"GL_KHR_debug\"), glewGetExtension(\"GL_KHR_debug\"));\n\n  glewInfoFunc(\"glDebugMessageCallback\", glDebugMessageCallback == NULL);\n  glewInfoFunc(\"glDebugMessageControl\", glDebugMessageControl == NULL);\n  glewInfoFunc(\"glDebugMessageInsert\", glDebugMessageInsert == NULL);\n  glewInfoFunc(\"glGetDebugMessageLog\", glGetDebugMessageLog == NULL);\n  glewInfoFunc(\"glGetObjectLabel\", glGetObjectLabel == NULL);\n  glewInfoFunc(\"glGetObjectPtrLabel\", glGetObjectPtrLabel == NULL);\n  glewInfoFunc(\"glGetPointerv\", glGetPointerv == NULL);\n  glewInfoFunc(\"glObjectLabel\", glObjectLabel == NULL);\n  glewInfoFunc(\"glObjectPtrLabel\", glObjectPtrLabel == NULL);\n  glewInfoFunc(\"glPushDebugGroup\", glPushDebugGroup == NULL);\n}\n\n#endif /* GL_KHR_debug */\n\n#ifdef GL_KHR_texture_compression_astc_ldr\n\nstatic void _glewInfo_GL_KHR_texture_compression_astc_ldr (void)\n{\n  glewPrintExt(\"GL_KHR_texture_compression_astc_ldr\", GLEW_KHR_texture_compression_astc_ldr, glewIsSupported(\"GL_KHR_texture_compression_astc_ldr\"), glewGetExtension(\"GL_KHR_texture_compression_astc_ldr\"));\n}\n\n#endif /* GL_KHR_texture_compression_astc_ldr */\n\n#ifdef GL_KTX_buffer_region\n\nstatic void _glewInfo_GL_KTX_buffer_region (void)\n{\n  glewPrintExt(\"GL_KTX_buffer_region\", GLEW_KTX_buffer_region, glewIsSupported(\"GL_KTX_buffer_region\"), glewGetExtension(\"GL_KTX_buffer_region\"));\n\n  glewInfoFunc(\"glBufferRegionEnabled\", glBufferRegionEnabled == NULL);\n  glewInfoFunc(\"glDeleteBufferRegion\", glDeleteBufferRegion == NULL);\n  glewInfoFunc(\"glDrawBufferRegion\", glDrawBufferRegion == NULL);\n  glewInfoFunc(\"glNewBufferRegion\", glNewBufferRegion == NULL);\n  glewInfoFunc(\"glReadBufferRegion\", glReadBufferRegion == NULL);\n}\n\n#endif /* GL_KTX_buffer_region */\n\n#ifdef GL_MESAX_texture_stack\n\nstatic void _glewInfo_GL_MESAX_texture_stack (void)\n{\n  glewPrintExt(\"GL_MESAX_texture_stack\", GLEW_MESAX_texture_stack, glewIsSupported(\"GL_MESAX_texture_stack\"), glewGetExtension(\"GL_MESAX_texture_stack\"));\n}\n\n#endif /* GL_MESAX_texture_stack */\n\n#ifdef GL_MESA_pack_invert\n\nstatic void _glewInfo_GL_MESA_pack_invert (void)\n{\n  glewPrintExt(\"GL_MESA_pack_invert\", GLEW_MESA_pack_invert, glewIsSupported(\"GL_MESA_pack_invert\"), glewGetExtension(\"GL_MESA_pack_invert\"));\n}\n\n#endif /* GL_MESA_pack_invert */\n\n#ifdef GL_MESA_resize_buffers\n\nstatic void _glewInfo_GL_MESA_resize_buffers (void)\n{\n  glewPrintExt(\"GL_MESA_resize_buffers\", GLEW_MESA_resize_buffers, glewIsSupported(\"GL_MESA_resize_buffers\"), glewGetExtension(\"GL_MESA_resize_buffers\"));\n\n  glewInfoFunc(\"glResizeBuffersMESA\", glResizeBuffersMESA == NULL);\n}\n\n#endif /* GL_MESA_resize_buffers */\n\n#ifdef GL_MESA_window_pos\n\nstatic void _glewInfo_GL_MESA_window_pos (void)\n{\n  glewPrintExt(\"GL_MESA_window_pos\", GLEW_MESA_window_pos, glewIsSupported(\"GL_MESA_window_pos\"), glewGetExtension(\"GL_MESA_window_pos\"));\n\n  glewInfoFunc(\"glWindowPos2dMESA\", glWindowPos2dMESA == NULL);\n  glewInfoFunc(\"glWindowPos2dvMESA\", glWindowPos2dvMESA == NULL);\n  glewInfoFunc(\"glWindowPos2fMESA\", glWindowPos2fMESA == NULL);\n  glewInfoFunc(\"glWindowPos2fvMESA\", glWindowPos2fvMESA == NULL);\n  glewInfoFunc(\"glWindowPos2iMESA\", glWindowPos2iMESA == NULL);\n  glewInfoFunc(\"glWindowPos2ivMESA\", glWindowPos2ivMESA == NULL);\n  glewInfoFunc(\"glWindowPos2sMESA\", glWindowPos2sMESA == NULL);\n  glewInfoFunc(\"glWindowPos2svMESA\", glWindowPos2svMESA == NULL);\n  glewInfoFunc(\"glWindowPos3dMESA\", glWindowPos3dMESA == NULL);\n  glewInfoFunc(\"glWindowPos3dvMESA\", glWindowPos3dvMESA == NULL);\n  glewInfoFunc(\"glWindowPos3fMESA\", glWindowPos3fMESA == NULL);\n  glewInfoFunc(\"glWindowPos3fvMESA\", glWindowPos3fvMESA == NULL);\n  glewInfoFunc(\"glWindowPos3iMESA\", glWindowPos3iMESA == NULL);\n  glewInfoFunc(\"glWindowPos3ivMESA\", glWindowPos3ivMESA == NULL);\n  glewInfoFunc(\"glWindowPos3sMESA\", glWindowPos3sMESA == NULL);\n  glewInfoFunc(\"glWindowPos3svMESA\", glWindowPos3svMESA == NULL);\n  glewInfoFunc(\"glWindowPos4dMESA\", glWindowPos4dMESA == NULL);\n  glewInfoFunc(\"glWindowPos4dvMESA\", glWindowPos4dvMESA == NULL);\n  glewInfoFunc(\"glWindowPos4fMESA\", glWindowPos4fMESA == NULL);\n  glewInfoFunc(\"glWindowPos4fvMESA\", glWindowPos4fvMESA == NULL);\n  glewInfoFunc(\"glWindowPos4iMESA\", glWindowPos4iMESA == NULL);\n  glewInfoFunc(\"glWindowPos4ivMESA\", glWindowPos4ivMESA == NULL);\n  glewInfoFunc(\"glWindowPos4sMESA\", glWindowPos4sMESA == NULL);\n  glewInfoFunc(\"glWindowPos4svMESA\", glWindowPos4svMESA == NULL);\n}\n\n#endif /* GL_MESA_window_pos */\n\n#ifdef GL_MESA_ycbcr_texture\n\nstatic void _glewInfo_GL_MESA_ycbcr_texture (void)\n{\n  glewPrintExt(\"GL_MESA_ycbcr_texture\", GLEW_MESA_ycbcr_texture, glewIsSupported(\"GL_MESA_ycbcr_texture\"), glewGetExtension(\"GL_MESA_ycbcr_texture\"));\n}\n\n#endif /* GL_MESA_ycbcr_texture */\n\n#ifdef GL_NVX_gpu_memory_info\n\nstatic void _glewInfo_GL_NVX_gpu_memory_info (void)\n{\n  glewPrintExt(\"GL_NVX_gpu_memory_info\", GLEW_NVX_gpu_memory_info, glewIsSupported(\"GL_NVX_gpu_memory_info\"), glewGetExtension(\"GL_NVX_gpu_memory_info\"));\n}\n\n#endif /* GL_NVX_gpu_memory_info */\n\n#ifdef GL_NV_bindless_texture\n\nstatic void _glewInfo_GL_NV_bindless_texture (void)\n{\n  glewPrintExt(\"GL_NV_bindless_texture\", GLEW_NV_bindless_texture, glewIsSupported(\"GL_NV_bindless_texture\"), glewGetExtension(\"GL_NV_bindless_texture\"));\n\n  glewInfoFunc(\"glGetImageHandleNV\", glGetImageHandleNV == NULL);\n  glewInfoFunc(\"glGetTextureHandleNV\", glGetTextureHandleNV == NULL);\n  glewInfoFunc(\"glGetTextureSamplerHandleNV\", glGetTextureSamplerHandleNV == NULL);\n  glewInfoFunc(\"glIsImageHandleResidentNV\", glIsImageHandleResidentNV == NULL);\n  glewInfoFunc(\"glIsTextureHandleResidentNV\", glIsTextureHandleResidentNV == NULL);\n  glewInfoFunc(\"glMakeImageHandleNonResidentNV\", glMakeImageHandleNonResidentNV == NULL);\n  glewInfoFunc(\"glMakeImageHandleResidentNV\", glMakeImageHandleResidentNV == NULL);\n  glewInfoFunc(\"glMakeTextureHandleNonResidentNV\", glMakeTextureHandleNonResidentNV == NULL);\n  glewInfoFunc(\"glMakeTextureHandleResidentNV\", glMakeTextureHandleResidentNV == NULL);\n  glewInfoFunc(\"glProgramUniformHandleui64NV\", glProgramUniformHandleui64NV == NULL);\n  glewInfoFunc(\"glProgramUniformHandleui64vNV\", glProgramUniformHandleui64vNV == NULL);\n  glewInfoFunc(\"glUniformHandleui64NV\", glUniformHandleui64NV == NULL);\n  glewInfoFunc(\"glUniformHandleui64vNV\", glUniformHandleui64vNV == NULL);\n}\n\n#endif /* GL_NV_bindless_texture */\n\n#ifdef GL_NV_blend_square\n\nstatic void _glewInfo_GL_NV_blend_square (void)\n{\n  glewPrintExt(\"GL_NV_blend_square\", GLEW_NV_blend_square, glewIsSupported(\"GL_NV_blend_square\"), glewGetExtension(\"GL_NV_blend_square\"));\n}\n\n#endif /* GL_NV_blend_square */\n\n#ifdef GL_NV_conditional_render\n\nstatic void _glewInfo_GL_NV_conditional_render (void)\n{\n  glewPrintExt(\"GL_NV_conditional_render\", GLEW_NV_conditional_render, glewIsSupported(\"GL_NV_conditional_render\"), glewGetExtension(\"GL_NV_conditional_render\"));\n\n  glewInfoFunc(\"glBeginConditionalRenderNV\", glBeginConditionalRenderNV == NULL);\n  glewInfoFunc(\"glEndConditionalRenderNV\", glEndConditionalRenderNV == NULL);\n}\n\n#endif /* GL_NV_conditional_render */\n\n#ifdef GL_NV_copy_depth_to_color\n\nstatic void _glewInfo_GL_NV_copy_depth_to_color (void)\n{\n  glewPrintExt(\"GL_NV_copy_depth_to_color\", GLEW_NV_copy_depth_to_color, glewIsSupported(\"GL_NV_copy_depth_to_color\"), glewGetExtension(\"GL_NV_copy_depth_to_color\"));\n}\n\n#endif /* GL_NV_copy_depth_to_color */\n\n#ifdef GL_NV_copy_image\n\nstatic void _glewInfo_GL_NV_copy_image (void)\n{\n  glewPrintExt(\"GL_NV_copy_image\", GLEW_NV_copy_image, glewIsSupported(\"GL_NV_copy_image\"), glewGetExtension(\"GL_NV_copy_image\"));\n\n  glewInfoFunc(\"glCopyImageSubDataNV\", glCopyImageSubDataNV == NULL);\n}\n\n#endif /* GL_NV_copy_image */\n\n#ifdef GL_NV_depth_buffer_float\n\nstatic void _glewInfo_GL_NV_depth_buffer_float (void)\n{\n  glewPrintExt(\"GL_NV_depth_buffer_float\", GLEW_NV_depth_buffer_float, glewIsSupported(\"GL_NV_depth_buffer_float\"), glewGetExtension(\"GL_NV_depth_buffer_float\"));\n\n  glewInfoFunc(\"glClearDepthdNV\", glClearDepthdNV == NULL);\n  glewInfoFunc(\"glDepthBoundsdNV\", glDepthBoundsdNV == NULL);\n  glewInfoFunc(\"glDepthRangedNV\", glDepthRangedNV == NULL);\n}\n\n#endif /* GL_NV_depth_buffer_float */\n\n#ifdef GL_NV_depth_clamp\n\nstatic void _glewInfo_GL_NV_depth_clamp (void)\n{\n  glewPrintExt(\"GL_NV_depth_clamp\", GLEW_NV_depth_clamp, glewIsSupported(\"GL_NV_depth_clamp\"), glewGetExtension(\"GL_NV_depth_clamp\"));\n}\n\n#endif /* GL_NV_depth_clamp */\n\n#ifdef GL_NV_depth_range_unclamped\n\nstatic void _glewInfo_GL_NV_depth_range_unclamped (void)\n{\n  glewPrintExt(\"GL_NV_depth_range_unclamped\", GLEW_NV_depth_range_unclamped, glewIsSupported(\"GL_NV_depth_range_unclamped\"), glewGetExtension(\"GL_NV_depth_range_unclamped\"));\n}\n\n#endif /* GL_NV_depth_range_unclamped */\n\n#ifdef GL_NV_evaluators\n\nstatic void _glewInfo_GL_NV_evaluators (void)\n{\n  glewPrintExt(\"GL_NV_evaluators\", GLEW_NV_evaluators, glewIsSupported(\"GL_NV_evaluators\"), glewGetExtension(\"GL_NV_evaluators\"));\n\n  glewInfoFunc(\"glEvalMapsNV\", glEvalMapsNV == NULL);\n  glewInfoFunc(\"glGetMapAttribParameterfvNV\", glGetMapAttribParameterfvNV == NULL);\n  glewInfoFunc(\"glGetMapAttribParameterivNV\", glGetMapAttribParameterivNV == NULL);\n  glewInfoFunc(\"glGetMapControlPointsNV\", glGetMapControlPointsNV == NULL);\n  glewInfoFunc(\"glGetMapParameterfvNV\", glGetMapParameterfvNV == NULL);\n  glewInfoFunc(\"glGetMapParameterivNV\", glGetMapParameterivNV == NULL);\n  glewInfoFunc(\"glMapControlPointsNV\", glMapControlPointsNV == NULL);\n  glewInfoFunc(\"glMapParameterfvNV\", glMapParameterfvNV == NULL);\n  glewInfoFunc(\"glMapParameterivNV\", glMapParameterivNV == NULL);\n}\n\n#endif /* GL_NV_evaluators */\n\n#ifdef GL_NV_explicit_multisample\n\nstatic void _glewInfo_GL_NV_explicit_multisample (void)\n{\n  glewPrintExt(\"GL_NV_explicit_multisample\", GLEW_NV_explicit_multisample, glewIsSupported(\"GL_NV_explicit_multisample\"), glewGetExtension(\"GL_NV_explicit_multisample\"));\n\n  glewInfoFunc(\"glGetMultisamplefvNV\", glGetMultisamplefvNV == NULL);\n  glewInfoFunc(\"glSampleMaskIndexedNV\", glSampleMaskIndexedNV == NULL);\n  glewInfoFunc(\"glTexRenderbufferNV\", glTexRenderbufferNV == NULL);\n}\n\n#endif /* GL_NV_explicit_multisample */\n\n#ifdef GL_NV_fence\n\nstatic void _glewInfo_GL_NV_fence (void)\n{\n  glewPrintExt(\"GL_NV_fence\", GLEW_NV_fence, glewIsSupported(\"GL_NV_fence\"), glewGetExtension(\"GL_NV_fence\"));\n\n  glewInfoFunc(\"glDeleteFencesNV\", glDeleteFencesNV == NULL);\n  glewInfoFunc(\"glFinishFenceNV\", glFinishFenceNV == NULL);\n  glewInfoFunc(\"glGenFencesNV\", glGenFencesNV == NULL);\n  glewInfoFunc(\"glGetFenceivNV\", glGetFenceivNV == NULL);\n  glewInfoFunc(\"glIsFenceNV\", glIsFenceNV == NULL);\n  glewInfoFunc(\"glSetFenceNV\", glSetFenceNV == NULL);\n  glewInfoFunc(\"glTestFenceNV\", glTestFenceNV == NULL);\n}\n\n#endif /* GL_NV_fence */\n\n#ifdef GL_NV_float_buffer\n\nstatic void _glewInfo_GL_NV_float_buffer (void)\n{\n  glewPrintExt(\"GL_NV_float_buffer\", GLEW_NV_float_buffer, glewIsSupported(\"GL_NV_float_buffer\"), glewGetExtension(\"GL_NV_float_buffer\"));\n}\n\n#endif /* GL_NV_float_buffer */\n\n#ifdef GL_NV_fog_distance\n\nstatic void _glewInfo_GL_NV_fog_distance (void)\n{\n  glewPrintExt(\"GL_NV_fog_distance\", GLEW_NV_fog_distance, glewIsSupported(\"GL_NV_fog_distance\"), glewGetExtension(\"GL_NV_fog_distance\"));\n}\n\n#endif /* GL_NV_fog_distance */\n\n#ifdef GL_NV_fragment_program\n\nstatic void _glewInfo_GL_NV_fragment_program (void)\n{\n  glewPrintExt(\"GL_NV_fragment_program\", GLEW_NV_fragment_program, glewIsSupported(\"GL_NV_fragment_program\"), glewGetExtension(\"GL_NV_fragment_program\"));\n\n  glewInfoFunc(\"glGetProgramNamedParameterdvNV\", glGetProgramNamedParameterdvNV == NULL);\n  glewInfoFunc(\"glGetProgramNamedParameterfvNV\", glGetProgramNamedParameterfvNV == NULL);\n  glewInfoFunc(\"glProgramNamedParameter4dNV\", glProgramNamedParameter4dNV == NULL);\n  glewInfoFunc(\"glProgramNamedParameter4dvNV\", glProgramNamedParameter4dvNV == NULL);\n  glewInfoFunc(\"glProgramNamedParameter4fNV\", glProgramNamedParameter4fNV == NULL);\n  glewInfoFunc(\"glProgramNamedParameter4fvNV\", glProgramNamedParameter4fvNV == NULL);\n}\n\n#endif /* GL_NV_fragment_program */\n\n#ifdef GL_NV_fragment_program2\n\nstatic void _glewInfo_GL_NV_fragment_program2 (void)\n{\n  glewPrintExt(\"GL_NV_fragment_program2\", GLEW_NV_fragment_program2, glewIsSupported(\"GL_NV_fragment_program2\"), glewGetExtension(\"GL_NV_fragment_program2\"));\n}\n\n#endif /* GL_NV_fragment_program2 */\n\n#ifdef GL_NV_fragment_program4\n\nstatic void _glewInfo_GL_NV_fragment_program4 (void)\n{\n  glewPrintExt(\"GL_NV_fragment_program4\", GLEW_NV_fragment_program4, glewIsSupported(\"GL_NV_fragment_program4\"), glewGetExtension(\"GL_NV_gpu_program4\"));\n}\n\n#endif /* GL_NV_fragment_program4 */\n\n#ifdef GL_NV_fragment_program_option\n\nstatic void _glewInfo_GL_NV_fragment_program_option (void)\n{\n  glewPrintExt(\"GL_NV_fragment_program_option\", GLEW_NV_fragment_program_option, glewIsSupported(\"GL_NV_fragment_program_option\"), glewGetExtension(\"GL_NV_fragment_program_option\"));\n}\n\n#endif /* GL_NV_fragment_program_option */\n\n#ifdef GL_NV_framebuffer_multisample_coverage\n\nstatic void _glewInfo_GL_NV_framebuffer_multisample_coverage (void)\n{\n  glewPrintExt(\"GL_NV_framebuffer_multisample_coverage\", GLEW_NV_framebuffer_multisample_coverage, glewIsSupported(\"GL_NV_framebuffer_multisample_coverage\"), glewGetExtension(\"GL_NV_framebuffer_multisample_coverage\"));\n\n  glewInfoFunc(\"glRenderbufferStorageMultisampleCoverageNV\", glRenderbufferStorageMultisampleCoverageNV == NULL);\n}\n\n#endif /* GL_NV_framebuffer_multisample_coverage */\n\n#ifdef GL_NV_geometry_program4\n\nstatic void _glewInfo_GL_NV_geometry_program4 (void)\n{\n  glewPrintExt(\"GL_NV_geometry_program4\", GLEW_NV_geometry_program4, glewIsSupported(\"GL_NV_geometry_program4\"), glewGetExtension(\"GL_NV_gpu_program4\"));\n\n  glewInfoFunc(\"glProgramVertexLimitNV\", glProgramVertexLimitNV == NULL);\n}\n\n#endif /* GL_NV_geometry_program4 */\n\n#ifdef GL_NV_geometry_shader4\n\nstatic void _glewInfo_GL_NV_geometry_shader4 (void)\n{\n  glewPrintExt(\"GL_NV_geometry_shader4\", GLEW_NV_geometry_shader4, glewIsSupported(\"GL_NV_geometry_shader4\"), glewGetExtension(\"GL_NV_geometry_shader4\"));\n}\n\n#endif /* GL_NV_geometry_shader4 */\n\n#ifdef GL_NV_gpu_program4\n\nstatic void _glewInfo_GL_NV_gpu_program4 (void)\n{\n  glewPrintExt(\"GL_NV_gpu_program4\", GLEW_NV_gpu_program4, glewIsSupported(\"GL_NV_gpu_program4\"), glewGetExtension(\"GL_NV_gpu_program4\"));\n\n  glewInfoFunc(\"glProgramEnvParameterI4iNV\", glProgramEnvParameterI4iNV == NULL);\n  glewInfoFunc(\"glProgramEnvParameterI4ivNV\", glProgramEnvParameterI4ivNV == NULL);\n  glewInfoFunc(\"glProgramEnvParameterI4uiNV\", glProgramEnvParameterI4uiNV == NULL);\n  glewInfoFunc(\"glProgramEnvParameterI4uivNV\", glProgramEnvParameterI4uivNV == NULL);\n  glewInfoFunc(\"glProgramEnvParametersI4ivNV\", glProgramEnvParametersI4ivNV == NULL);\n  glewInfoFunc(\"glProgramEnvParametersI4uivNV\", glProgramEnvParametersI4uivNV == NULL);\n  glewInfoFunc(\"glProgramLocalParameterI4iNV\", glProgramLocalParameterI4iNV == NULL);\n  glewInfoFunc(\"glProgramLocalParameterI4ivNV\", glProgramLocalParameterI4ivNV == NULL);\n  glewInfoFunc(\"glProgramLocalParameterI4uiNV\", glProgramLocalParameterI4uiNV == NULL);\n  glewInfoFunc(\"glProgramLocalParameterI4uivNV\", glProgramLocalParameterI4uivNV == NULL);\n  glewInfoFunc(\"glProgramLocalParametersI4ivNV\", glProgramLocalParametersI4ivNV == NULL);\n  glewInfoFunc(\"glProgramLocalParametersI4uivNV\", glProgramLocalParametersI4uivNV == NULL);\n}\n\n#endif /* GL_NV_gpu_program4 */\n\n#ifdef GL_NV_gpu_program5\n\nstatic void _glewInfo_GL_NV_gpu_program5 (void)\n{\n  glewPrintExt(\"GL_NV_gpu_program5\", GLEW_NV_gpu_program5, glewIsSupported(\"GL_NV_gpu_program5\"), glewGetExtension(\"GL_NV_gpu_program5\"));\n}\n\n#endif /* GL_NV_gpu_program5 */\n\n#ifdef GL_NV_gpu_program_fp64\n\nstatic void _glewInfo_GL_NV_gpu_program_fp64 (void)\n{\n  glewPrintExt(\"GL_NV_gpu_program_fp64\", GLEW_NV_gpu_program_fp64, glewIsSupported(\"GL_NV_gpu_program_fp64\"), glewGetExtension(\"GL_NV_gpu_program_fp64\"));\n}\n\n#endif /* GL_NV_gpu_program_fp64 */\n\n#ifdef GL_NV_gpu_shader5\n\nstatic void _glewInfo_GL_NV_gpu_shader5 (void)\n{\n  glewPrintExt(\"GL_NV_gpu_shader5\", GLEW_NV_gpu_shader5, glewIsSupported(\"GL_NV_gpu_shader5\"), glewGetExtension(\"GL_NV_gpu_shader5\"));\n\n  glewInfoFunc(\"glGetUniformi64vNV\", glGetUniformi64vNV == NULL);\n  glewInfoFunc(\"glGetUniformui64vNV\", glGetUniformui64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform1i64NV\", glProgramUniform1i64NV == NULL);\n  glewInfoFunc(\"glProgramUniform1i64vNV\", glProgramUniform1i64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform1ui64NV\", glProgramUniform1ui64NV == NULL);\n  glewInfoFunc(\"glProgramUniform1ui64vNV\", glProgramUniform1ui64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform2i64NV\", glProgramUniform2i64NV == NULL);\n  glewInfoFunc(\"glProgramUniform2i64vNV\", glProgramUniform2i64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform2ui64NV\", glProgramUniform2ui64NV == NULL);\n  glewInfoFunc(\"glProgramUniform2ui64vNV\", glProgramUniform2ui64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform3i64NV\", glProgramUniform3i64NV == NULL);\n  glewInfoFunc(\"glProgramUniform3i64vNV\", glProgramUniform3i64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform3ui64NV\", glProgramUniform3ui64NV == NULL);\n  glewInfoFunc(\"glProgramUniform3ui64vNV\", glProgramUniform3ui64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform4i64NV\", glProgramUniform4i64NV == NULL);\n  glewInfoFunc(\"glProgramUniform4i64vNV\", glProgramUniform4i64vNV == NULL);\n  glewInfoFunc(\"glProgramUniform4ui64NV\", glProgramUniform4ui64NV == NULL);\n  glewInfoFunc(\"glProgramUniform4ui64vNV\", glProgramUniform4ui64vNV == NULL);\n  glewInfoFunc(\"glUniform1i64NV\", glUniform1i64NV == NULL);\n  glewInfoFunc(\"glUniform1i64vNV\", glUniform1i64vNV == NULL);\n  glewInfoFunc(\"glUniform1ui64NV\", glUniform1ui64NV == NULL);\n  glewInfoFunc(\"glUniform1ui64vNV\", glUniform1ui64vNV == NULL);\n  glewInfoFunc(\"glUniform2i64NV\", glUniform2i64NV == NULL);\n  glewInfoFunc(\"glUniform2i64vNV\", glUniform2i64vNV == NULL);\n  glewInfoFunc(\"glUniform2ui64NV\", glUniform2ui64NV == NULL);\n  glewInfoFunc(\"glUniform2ui64vNV\", glUniform2ui64vNV == NULL);\n  glewInfoFunc(\"glUniform3i64NV\", glUniform3i64NV == NULL);\n  glewInfoFunc(\"glUniform3i64vNV\", glUniform3i64vNV == NULL);\n  glewInfoFunc(\"glUniform3ui64NV\", glUniform3ui64NV == NULL);\n  glewInfoFunc(\"glUniform3ui64vNV\", glUniform3ui64vNV == NULL);\n  glewInfoFunc(\"glUniform4i64NV\", glUniform4i64NV == NULL);\n  glewInfoFunc(\"glUniform4i64vNV\", glUniform4i64vNV == NULL);\n  glewInfoFunc(\"glUniform4ui64NV\", glUniform4ui64NV == NULL);\n  glewInfoFunc(\"glUniform4ui64vNV\", glUniform4ui64vNV == NULL);\n}\n\n#endif /* GL_NV_gpu_shader5 */\n\n#ifdef GL_NV_half_float\n\nstatic void _glewInfo_GL_NV_half_float (void)\n{\n  glewPrintExt(\"GL_NV_half_float\", GLEW_NV_half_float, glewIsSupported(\"GL_NV_half_float\"), glewGetExtension(\"GL_NV_half_float\"));\n\n  glewInfoFunc(\"glColor3hNV\", glColor3hNV == NULL);\n  glewInfoFunc(\"glColor3hvNV\", glColor3hvNV == NULL);\n  glewInfoFunc(\"glColor4hNV\", glColor4hNV == NULL);\n  glewInfoFunc(\"glColor4hvNV\", glColor4hvNV == NULL);\n  glewInfoFunc(\"glFogCoordhNV\", glFogCoordhNV == NULL);\n  glewInfoFunc(\"glFogCoordhvNV\", glFogCoordhvNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord1hNV\", glMultiTexCoord1hNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord1hvNV\", glMultiTexCoord1hvNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord2hNV\", glMultiTexCoord2hNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord2hvNV\", glMultiTexCoord2hvNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord3hNV\", glMultiTexCoord3hNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord3hvNV\", glMultiTexCoord3hvNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord4hNV\", glMultiTexCoord4hNV == NULL);\n  glewInfoFunc(\"glMultiTexCoord4hvNV\", glMultiTexCoord4hvNV == NULL);\n  glewInfoFunc(\"glNormal3hNV\", glNormal3hNV == NULL);\n  glewInfoFunc(\"glNormal3hvNV\", glNormal3hvNV == NULL);\n  glewInfoFunc(\"glSecondaryColor3hNV\", glSecondaryColor3hNV == NULL);\n  glewInfoFunc(\"glSecondaryColor3hvNV\", glSecondaryColor3hvNV == NULL);\n  glewInfoFunc(\"glTexCoord1hNV\", glTexCoord1hNV == NULL);\n  glewInfoFunc(\"glTexCoord1hvNV\", glTexCoord1hvNV == NULL);\n  glewInfoFunc(\"glTexCoord2hNV\", glTexCoord2hNV == NULL);\n  glewInfoFunc(\"glTexCoord2hvNV\", glTexCoord2hvNV == NULL);\n  glewInfoFunc(\"glTexCoord3hNV\", glTexCoord3hNV == NULL);\n  glewInfoFunc(\"glTexCoord3hvNV\", glTexCoord3hvNV == NULL);\n  glewInfoFunc(\"glTexCoord4hNV\", glTexCoord4hNV == NULL);\n  glewInfoFunc(\"glTexCoord4hvNV\", glTexCoord4hvNV == NULL);\n  glewInfoFunc(\"glVertex2hNV\", glVertex2hNV == NULL);\n  glewInfoFunc(\"glVertex2hvNV\", glVertex2hvNV == NULL);\n  glewInfoFunc(\"glVertex3hNV\", glVertex3hNV == NULL);\n  glewInfoFunc(\"glVertex3hvNV\", glVertex3hvNV == NULL);\n  glewInfoFunc(\"glVertex4hNV\", glVertex4hNV == NULL);\n  glewInfoFunc(\"glVertex4hvNV\", glVertex4hvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1hNV\", glVertexAttrib1hNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1hvNV\", glVertexAttrib1hvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2hNV\", glVertexAttrib2hNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2hvNV\", glVertexAttrib2hvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3hNV\", glVertexAttrib3hNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3hvNV\", glVertexAttrib3hvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4hNV\", glVertexAttrib4hNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4hvNV\", glVertexAttrib4hvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs1hvNV\", glVertexAttribs1hvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs2hvNV\", glVertexAttribs2hvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs3hvNV\", glVertexAttribs3hvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs4hvNV\", glVertexAttribs4hvNV == NULL);\n  glewInfoFunc(\"glVertexWeighthNV\", glVertexWeighthNV == NULL);\n  glewInfoFunc(\"glVertexWeighthvNV\", glVertexWeighthvNV == NULL);\n}\n\n#endif /* GL_NV_half_float */\n\n#ifdef GL_NV_light_max_exponent\n\nstatic void _glewInfo_GL_NV_light_max_exponent (void)\n{\n  glewPrintExt(\"GL_NV_light_max_exponent\", GLEW_NV_light_max_exponent, glewIsSupported(\"GL_NV_light_max_exponent\"), glewGetExtension(\"GL_NV_light_max_exponent\"));\n}\n\n#endif /* GL_NV_light_max_exponent */\n\n#ifdef GL_NV_multisample_coverage\n\nstatic void _glewInfo_GL_NV_multisample_coverage (void)\n{\n  glewPrintExt(\"GL_NV_multisample_coverage\", GLEW_NV_multisample_coverage, glewIsSupported(\"GL_NV_multisample_coverage\"), glewGetExtension(\"GL_NV_multisample_coverage\"));\n}\n\n#endif /* GL_NV_multisample_coverage */\n\n#ifdef GL_NV_multisample_filter_hint\n\nstatic void _glewInfo_GL_NV_multisample_filter_hint (void)\n{\n  glewPrintExt(\"GL_NV_multisample_filter_hint\", GLEW_NV_multisample_filter_hint, glewIsSupported(\"GL_NV_multisample_filter_hint\"), glewGetExtension(\"GL_NV_multisample_filter_hint\"));\n}\n\n#endif /* GL_NV_multisample_filter_hint */\n\n#ifdef GL_NV_occlusion_query\n\nstatic void _glewInfo_GL_NV_occlusion_query (void)\n{\n  glewPrintExt(\"GL_NV_occlusion_query\", GLEW_NV_occlusion_query, glewIsSupported(\"GL_NV_occlusion_query\"), glewGetExtension(\"GL_NV_occlusion_query\"));\n\n  glewInfoFunc(\"glBeginOcclusionQueryNV\", glBeginOcclusionQueryNV == NULL);\n  glewInfoFunc(\"glDeleteOcclusionQueriesNV\", glDeleteOcclusionQueriesNV == NULL);\n  glewInfoFunc(\"glEndOcclusionQueryNV\", glEndOcclusionQueryNV == NULL);\n  glewInfoFunc(\"glGenOcclusionQueriesNV\", glGenOcclusionQueriesNV == NULL);\n  glewInfoFunc(\"glGetOcclusionQueryivNV\", glGetOcclusionQueryivNV == NULL);\n  glewInfoFunc(\"glGetOcclusionQueryuivNV\", glGetOcclusionQueryuivNV == NULL);\n  glewInfoFunc(\"glIsOcclusionQueryNV\", glIsOcclusionQueryNV == NULL);\n}\n\n#endif /* GL_NV_occlusion_query */\n\n#ifdef GL_NV_packed_depth_stencil\n\nstatic void _glewInfo_GL_NV_packed_depth_stencil (void)\n{\n  glewPrintExt(\"GL_NV_packed_depth_stencil\", GLEW_NV_packed_depth_stencil, glewIsSupported(\"GL_NV_packed_depth_stencil\"), glewGetExtension(\"GL_NV_packed_depth_stencil\"));\n}\n\n#endif /* GL_NV_packed_depth_stencil */\n\n#ifdef GL_NV_parameter_buffer_object\n\nstatic void _glewInfo_GL_NV_parameter_buffer_object (void)\n{\n  glewPrintExt(\"GL_NV_parameter_buffer_object\", GLEW_NV_parameter_buffer_object, glewIsSupported(\"GL_NV_parameter_buffer_object\"), glewGetExtension(\"GL_NV_parameter_buffer_object\"));\n\n  glewInfoFunc(\"glProgramBufferParametersIivNV\", glProgramBufferParametersIivNV == NULL);\n  glewInfoFunc(\"glProgramBufferParametersIuivNV\", glProgramBufferParametersIuivNV == NULL);\n  glewInfoFunc(\"glProgramBufferParametersfvNV\", glProgramBufferParametersfvNV == NULL);\n}\n\n#endif /* GL_NV_parameter_buffer_object */\n\n#ifdef GL_NV_parameter_buffer_object2\n\nstatic void _glewInfo_GL_NV_parameter_buffer_object2 (void)\n{\n  glewPrintExt(\"GL_NV_parameter_buffer_object2\", GLEW_NV_parameter_buffer_object2, glewIsSupported(\"GL_NV_parameter_buffer_object2\"), glewGetExtension(\"GL_NV_parameter_buffer_object2\"));\n}\n\n#endif /* GL_NV_parameter_buffer_object2 */\n\n#ifdef GL_NV_path_rendering\n\nstatic void _glewInfo_GL_NV_path_rendering (void)\n{\n  glewPrintExt(\"GL_NV_path_rendering\", GLEW_NV_path_rendering, glewIsSupported(\"GL_NV_path_rendering\"), glewGetExtension(\"GL_NV_path_rendering\"));\n\n  glewInfoFunc(\"glCopyPathNV\", glCopyPathNV == NULL);\n  glewInfoFunc(\"glCoverFillPathInstancedNV\", glCoverFillPathInstancedNV == NULL);\n  glewInfoFunc(\"glCoverFillPathNV\", glCoverFillPathNV == NULL);\n  glewInfoFunc(\"glCoverStrokePathInstancedNV\", glCoverStrokePathInstancedNV == NULL);\n  glewInfoFunc(\"glCoverStrokePathNV\", glCoverStrokePathNV == NULL);\n  glewInfoFunc(\"glDeletePathsNV\", glDeletePathsNV == NULL);\n  glewInfoFunc(\"glGenPathsNV\", glGenPathsNV == NULL);\n  glewInfoFunc(\"glGetPathColorGenfvNV\", glGetPathColorGenfvNV == NULL);\n  glewInfoFunc(\"glGetPathColorGenivNV\", glGetPathColorGenivNV == NULL);\n  glewInfoFunc(\"glGetPathCommandsNV\", glGetPathCommandsNV == NULL);\n  glewInfoFunc(\"glGetPathCoordsNV\", glGetPathCoordsNV == NULL);\n  glewInfoFunc(\"glGetPathDashArrayNV\", glGetPathDashArrayNV == NULL);\n  glewInfoFunc(\"glGetPathLengthNV\", glGetPathLengthNV == NULL);\n  glewInfoFunc(\"glGetPathMetricRangeNV\", glGetPathMetricRangeNV == NULL);\n  glewInfoFunc(\"glGetPathMetricsNV\", glGetPathMetricsNV == NULL);\n  glewInfoFunc(\"glGetPathParameterfvNV\", glGetPathParameterfvNV == NULL);\n  glewInfoFunc(\"glGetPathParameterivNV\", glGetPathParameterivNV == NULL);\n  glewInfoFunc(\"glGetPathSpacingNV\", glGetPathSpacingNV == NULL);\n  glewInfoFunc(\"glGetPathTexGenfvNV\", glGetPathTexGenfvNV == NULL);\n  glewInfoFunc(\"glGetPathTexGenivNV\", glGetPathTexGenivNV == NULL);\n  glewInfoFunc(\"glInterpolatePathsNV\", glInterpolatePathsNV == NULL);\n  glewInfoFunc(\"glIsPathNV\", glIsPathNV == NULL);\n  glewInfoFunc(\"glIsPointInFillPathNV\", glIsPointInFillPathNV == NULL);\n  glewInfoFunc(\"glIsPointInStrokePathNV\", glIsPointInStrokePathNV == NULL);\n  glewInfoFunc(\"glPathColorGenNV\", glPathColorGenNV == NULL);\n  glewInfoFunc(\"glPathCommandsNV\", glPathCommandsNV == NULL);\n  glewInfoFunc(\"glPathCoordsNV\", glPathCoordsNV == NULL);\n  glewInfoFunc(\"glPathCoverDepthFuncNV\", glPathCoverDepthFuncNV == NULL);\n  glewInfoFunc(\"glPathDashArrayNV\", glPathDashArrayNV == NULL);\n  glewInfoFunc(\"glPathFogGenNV\", glPathFogGenNV == NULL);\n  glewInfoFunc(\"glPathGlyphRangeNV\", glPathGlyphRangeNV == NULL);\n  glewInfoFunc(\"glPathGlyphsNV\", glPathGlyphsNV == NULL);\n  glewInfoFunc(\"glPathParameterfNV\", glPathParameterfNV == NULL);\n  glewInfoFunc(\"glPathParameterfvNV\", glPathParameterfvNV == NULL);\n  glewInfoFunc(\"glPathParameteriNV\", glPathParameteriNV == NULL);\n  glewInfoFunc(\"glPathParameterivNV\", glPathParameterivNV == NULL);\n  glewInfoFunc(\"glPathStencilDepthOffsetNV\", glPathStencilDepthOffsetNV == NULL);\n  glewInfoFunc(\"glPathStencilFuncNV\", glPathStencilFuncNV == NULL);\n  glewInfoFunc(\"glPathStringNV\", glPathStringNV == NULL);\n  glewInfoFunc(\"glPathSubCommandsNV\", glPathSubCommandsNV == NULL);\n  glewInfoFunc(\"glPathSubCoordsNV\", glPathSubCoordsNV == NULL);\n  glewInfoFunc(\"glPathTexGenNV\", glPathTexGenNV == NULL);\n  glewInfoFunc(\"glPointAlongPathNV\", glPointAlongPathNV == NULL);\n  glewInfoFunc(\"glStencilFillPathInstancedNV\", glStencilFillPathInstancedNV == NULL);\n  glewInfoFunc(\"glStencilFillPathNV\", glStencilFillPathNV == NULL);\n  glewInfoFunc(\"glStencilStrokePathInstancedNV\", glStencilStrokePathInstancedNV == NULL);\n  glewInfoFunc(\"glStencilStrokePathNV\", glStencilStrokePathNV == NULL);\n  glewInfoFunc(\"glTransformPathNV\", glTransformPathNV == NULL);\n  glewInfoFunc(\"glWeightPathsNV\", glWeightPathsNV == NULL);\n}\n\n#endif /* GL_NV_path_rendering */\n\n#ifdef GL_NV_pixel_data_range\n\nstatic void _glewInfo_GL_NV_pixel_data_range (void)\n{\n  glewPrintExt(\"GL_NV_pixel_data_range\", GLEW_NV_pixel_data_range, glewIsSupported(\"GL_NV_pixel_data_range\"), glewGetExtension(\"GL_NV_pixel_data_range\"));\n\n  glewInfoFunc(\"glFlushPixelDataRangeNV\", glFlushPixelDataRangeNV == NULL);\n  glewInfoFunc(\"glPixelDataRangeNV\", glPixelDataRangeNV == NULL);\n}\n\n#endif /* GL_NV_pixel_data_range */\n\n#ifdef GL_NV_point_sprite\n\nstatic void _glewInfo_GL_NV_point_sprite (void)\n{\n  glewPrintExt(\"GL_NV_point_sprite\", GLEW_NV_point_sprite, glewIsSupported(\"GL_NV_point_sprite\"), glewGetExtension(\"GL_NV_point_sprite\"));\n\n  glewInfoFunc(\"glPointParameteriNV\", glPointParameteriNV == NULL);\n  glewInfoFunc(\"glPointParameterivNV\", glPointParameterivNV == NULL);\n}\n\n#endif /* GL_NV_point_sprite */\n\n#ifdef GL_NV_present_video\n\nstatic void _glewInfo_GL_NV_present_video (void)\n{\n  glewPrintExt(\"GL_NV_present_video\", GLEW_NV_present_video, glewIsSupported(\"GL_NV_present_video\"), glewGetExtension(\"GL_NV_present_video\"));\n\n  glewInfoFunc(\"glGetVideoi64vNV\", glGetVideoi64vNV == NULL);\n  glewInfoFunc(\"glGetVideoivNV\", glGetVideoivNV == NULL);\n  glewInfoFunc(\"glGetVideoui64vNV\", glGetVideoui64vNV == NULL);\n  glewInfoFunc(\"glGetVideouivNV\", glGetVideouivNV == NULL);\n  glewInfoFunc(\"glPresentFrameDualFillNV\", glPresentFrameDualFillNV == NULL);\n  glewInfoFunc(\"glPresentFrameKeyedNV\", glPresentFrameKeyedNV == NULL);\n}\n\n#endif /* GL_NV_present_video */\n\n#ifdef GL_NV_primitive_restart\n\nstatic void _glewInfo_GL_NV_primitive_restart (void)\n{\n  glewPrintExt(\"GL_NV_primitive_restart\", GLEW_NV_primitive_restart, glewIsSupported(\"GL_NV_primitive_restart\"), glewGetExtension(\"GL_NV_primitive_restart\"));\n\n  glewInfoFunc(\"glPrimitiveRestartIndexNV\", glPrimitiveRestartIndexNV == NULL);\n  glewInfoFunc(\"glPrimitiveRestartNV\", glPrimitiveRestartNV == NULL);\n}\n\n#endif /* GL_NV_primitive_restart */\n\n#ifdef GL_NV_register_combiners\n\nstatic void _glewInfo_GL_NV_register_combiners (void)\n{\n  glewPrintExt(\"GL_NV_register_combiners\", GLEW_NV_register_combiners, glewIsSupported(\"GL_NV_register_combiners\"), glewGetExtension(\"GL_NV_register_combiners\"));\n\n  glewInfoFunc(\"glCombinerInputNV\", glCombinerInputNV == NULL);\n  glewInfoFunc(\"glCombinerOutputNV\", glCombinerOutputNV == NULL);\n  glewInfoFunc(\"glCombinerParameterfNV\", glCombinerParameterfNV == NULL);\n  glewInfoFunc(\"glCombinerParameterfvNV\", glCombinerParameterfvNV == NULL);\n  glewInfoFunc(\"glCombinerParameteriNV\", glCombinerParameteriNV == NULL);\n  glewInfoFunc(\"glCombinerParameterivNV\", glCombinerParameterivNV == NULL);\n  glewInfoFunc(\"glFinalCombinerInputNV\", glFinalCombinerInputNV == NULL);\n  glewInfoFunc(\"glGetCombinerInputParameterfvNV\", glGetCombinerInputParameterfvNV == NULL);\n  glewInfoFunc(\"glGetCombinerInputParameterivNV\", glGetCombinerInputParameterivNV == NULL);\n  glewInfoFunc(\"glGetCombinerOutputParameterfvNV\", glGetCombinerOutputParameterfvNV == NULL);\n  glewInfoFunc(\"glGetCombinerOutputParameterivNV\", glGetCombinerOutputParameterivNV == NULL);\n  glewInfoFunc(\"glGetFinalCombinerInputParameterfvNV\", glGetFinalCombinerInputParameterfvNV == NULL);\n  glewInfoFunc(\"glGetFinalCombinerInputParameterivNV\", glGetFinalCombinerInputParameterivNV == NULL);\n}\n\n#endif /* GL_NV_register_combiners */\n\n#ifdef GL_NV_register_combiners2\n\nstatic void _glewInfo_GL_NV_register_combiners2 (void)\n{\n  glewPrintExt(\"GL_NV_register_combiners2\", GLEW_NV_register_combiners2, glewIsSupported(\"GL_NV_register_combiners2\"), glewGetExtension(\"GL_NV_register_combiners2\"));\n\n  glewInfoFunc(\"glCombinerStageParameterfvNV\", glCombinerStageParameterfvNV == NULL);\n  glewInfoFunc(\"glGetCombinerStageParameterfvNV\", glGetCombinerStageParameterfvNV == NULL);\n}\n\n#endif /* GL_NV_register_combiners2 */\n\n#ifdef GL_NV_shader_atomic_float\n\nstatic void _glewInfo_GL_NV_shader_atomic_float (void)\n{\n  glewPrintExt(\"GL_NV_shader_atomic_float\", GLEW_NV_shader_atomic_float, glewIsSupported(\"GL_NV_shader_atomic_float\"), glewGetExtension(\"GL_NV_shader_atomic_float\"));\n}\n\n#endif /* GL_NV_shader_atomic_float */\n\n#ifdef GL_NV_shader_buffer_load\n\nstatic void _glewInfo_GL_NV_shader_buffer_load (void)\n{\n  glewPrintExt(\"GL_NV_shader_buffer_load\", GLEW_NV_shader_buffer_load, glewIsSupported(\"GL_NV_shader_buffer_load\"), glewGetExtension(\"GL_NV_shader_buffer_load\"));\n\n  glewInfoFunc(\"glGetBufferParameterui64vNV\", glGetBufferParameterui64vNV == NULL);\n  glewInfoFunc(\"glGetIntegerui64vNV\", glGetIntegerui64vNV == NULL);\n  glewInfoFunc(\"glGetNamedBufferParameterui64vNV\", glGetNamedBufferParameterui64vNV == NULL);\n  glewInfoFunc(\"glIsBufferResidentNV\", glIsBufferResidentNV == NULL);\n  glewInfoFunc(\"glIsNamedBufferResidentNV\", glIsNamedBufferResidentNV == NULL);\n  glewInfoFunc(\"glMakeBufferNonResidentNV\", glMakeBufferNonResidentNV == NULL);\n  glewInfoFunc(\"glMakeBufferResidentNV\", glMakeBufferResidentNV == NULL);\n  glewInfoFunc(\"glMakeNamedBufferNonResidentNV\", glMakeNamedBufferNonResidentNV == NULL);\n  glewInfoFunc(\"glMakeNamedBufferResidentNV\", glMakeNamedBufferResidentNV == NULL);\n  glewInfoFunc(\"glProgramUniformui64NV\", glProgramUniformui64NV == NULL);\n  glewInfoFunc(\"glProgramUniformui64vNV\", glProgramUniformui64vNV == NULL);\n  glewInfoFunc(\"glUniformui64NV\", glUniformui64NV == NULL);\n  glewInfoFunc(\"glUniformui64vNV\", glUniformui64vNV == NULL);\n}\n\n#endif /* GL_NV_shader_buffer_load */\n\n#ifdef GL_NV_tessellation_program5\n\nstatic void _glewInfo_GL_NV_tessellation_program5 (void)\n{\n  glewPrintExt(\"GL_NV_tessellation_program5\", GLEW_NV_tessellation_program5, glewIsSupported(\"GL_NV_tessellation_program5\"), glewGetExtension(\"GL_NV_gpu_program5\"));\n}\n\n#endif /* GL_NV_tessellation_program5 */\n\n#ifdef GL_NV_texgen_emboss\n\nstatic void _glewInfo_GL_NV_texgen_emboss (void)\n{\n  glewPrintExt(\"GL_NV_texgen_emboss\", GLEW_NV_texgen_emboss, glewIsSupported(\"GL_NV_texgen_emboss\"), glewGetExtension(\"GL_NV_texgen_emboss\"));\n}\n\n#endif /* GL_NV_texgen_emboss */\n\n#ifdef GL_NV_texgen_reflection\n\nstatic void _glewInfo_GL_NV_texgen_reflection (void)\n{\n  glewPrintExt(\"GL_NV_texgen_reflection\", GLEW_NV_texgen_reflection, glewIsSupported(\"GL_NV_texgen_reflection\"), glewGetExtension(\"GL_NV_texgen_reflection\"));\n}\n\n#endif /* GL_NV_texgen_reflection */\n\n#ifdef GL_NV_texture_barrier\n\nstatic void _glewInfo_GL_NV_texture_barrier (void)\n{\n  glewPrintExt(\"GL_NV_texture_barrier\", GLEW_NV_texture_barrier, glewIsSupported(\"GL_NV_texture_barrier\"), glewGetExtension(\"GL_NV_texture_barrier\"));\n\n  glewInfoFunc(\"glTextureBarrierNV\", glTextureBarrierNV == NULL);\n}\n\n#endif /* GL_NV_texture_barrier */\n\n#ifdef GL_NV_texture_compression_vtc\n\nstatic void _glewInfo_GL_NV_texture_compression_vtc (void)\n{\n  glewPrintExt(\"GL_NV_texture_compression_vtc\", GLEW_NV_texture_compression_vtc, glewIsSupported(\"GL_NV_texture_compression_vtc\"), glewGetExtension(\"GL_NV_texture_compression_vtc\"));\n}\n\n#endif /* GL_NV_texture_compression_vtc */\n\n#ifdef GL_NV_texture_env_combine4\n\nstatic void _glewInfo_GL_NV_texture_env_combine4 (void)\n{\n  glewPrintExt(\"GL_NV_texture_env_combine4\", GLEW_NV_texture_env_combine4, glewIsSupported(\"GL_NV_texture_env_combine4\"), glewGetExtension(\"GL_NV_texture_env_combine4\"));\n}\n\n#endif /* GL_NV_texture_env_combine4 */\n\n#ifdef GL_NV_texture_expand_normal\n\nstatic void _glewInfo_GL_NV_texture_expand_normal (void)\n{\n  glewPrintExt(\"GL_NV_texture_expand_normal\", GLEW_NV_texture_expand_normal, glewIsSupported(\"GL_NV_texture_expand_normal\"), glewGetExtension(\"GL_NV_texture_expand_normal\"));\n}\n\n#endif /* GL_NV_texture_expand_normal */\n\n#ifdef GL_NV_texture_multisample\n\nstatic void _glewInfo_GL_NV_texture_multisample (void)\n{\n  glewPrintExt(\"GL_NV_texture_multisample\", GLEW_NV_texture_multisample, glewIsSupported(\"GL_NV_texture_multisample\"), glewGetExtension(\"GL_NV_texture_multisample\"));\n\n  glewInfoFunc(\"glTexImage2DMultisampleCoverageNV\", glTexImage2DMultisampleCoverageNV == NULL);\n  glewInfoFunc(\"glTexImage3DMultisampleCoverageNV\", glTexImage3DMultisampleCoverageNV == NULL);\n  glewInfoFunc(\"glTextureImage2DMultisampleCoverageNV\", glTextureImage2DMultisampleCoverageNV == NULL);\n  glewInfoFunc(\"glTextureImage2DMultisampleNV\", glTextureImage2DMultisampleNV == NULL);\n  glewInfoFunc(\"glTextureImage3DMultisampleCoverageNV\", glTextureImage3DMultisampleCoverageNV == NULL);\n  glewInfoFunc(\"glTextureImage3DMultisampleNV\", glTextureImage3DMultisampleNV == NULL);\n}\n\n#endif /* GL_NV_texture_multisample */\n\n#ifdef GL_NV_texture_rectangle\n\nstatic void _glewInfo_GL_NV_texture_rectangle (void)\n{\n  glewPrintExt(\"GL_NV_texture_rectangle\", GLEW_NV_texture_rectangle, glewIsSupported(\"GL_NV_texture_rectangle\"), glewGetExtension(\"GL_NV_texture_rectangle\"));\n}\n\n#endif /* GL_NV_texture_rectangle */\n\n#ifdef GL_NV_texture_shader\n\nstatic void _glewInfo_GL_NV_texture_shader (void)\n{\n  glewPrintExt(\"GL_NV_texture_shader\", GLEW_NV_texture_shader, glewIsSupported(\"GL_NV_texture_shader\"), glewGetExtension(\"GL_NV_texture_shader\"));\n}\n\n#endif /* GL_NV_texture_shader */\n\n#ifdef GL_NV_texture_shader2\n\nstatic void _glewInfo_GL_NV_texture_shader2 (void)\n{\n  glewPrintExt(\"GL_NV_texture_shader2\", GLEW_NV_texture_shader2, glewIsSupported(\"GL_NV_texture_shader2\"), glewGetExtension(\"GL_NV_texture_shader2\"));\n}\n\n#endif /* GL_NV_texture_shader2 */\n\n#ifdef GL_NV_texture_shader3\n\nstatic void _glewInfo_GL_NV_texture_shader3 (void)\n{\n  glewPrintExt(\"GL_NV_texture_shader3\", GLEW_NV_texture_shader3, glewIsSupported(\"GL_NV_texture_shader3\"), glewGetExtension(\"GL_NV_texture_shader3\"));\n}\n\n#endif /* GL_NV_texture_shader3 */\n\n#ifdef GL_NV_transform_feedback\n\nstatic void _glewInfo_GL_NV_transform_feedback (void)\n{\n  glewPrintExt(\"GL_NV_transform_feedback\", GLEW_NV_transform_feedback, glewIsSupported(\"GL_NV_transform_feedback\"), glewGetExtension(\"GL_NV_transform_feedback\"));\n\n  glewInfoFunc(\"glActiveVaryingNV\", glActiveVaryingNV == NULL);\n  glewInfoFunc(\"glBeginTransformFeedbackNV\", glBeginTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glBindBufferBaseNV\", glBindBufferBaseNV == NULL);\n  glewInfoFunc(\"glBindBufferOffsetNV\", glBindBufferOffsetNV == NULL);\n  glewInfoFunc(\"glBindBufferRangeNV\", glBindBufferRangeNV == NULL);\n  glewInfoFunc(\"glEndTransformFeedbackNV\", glEndTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glGetActiveVaryingNV\", glGetActiveVaryingNV == NULL);\n  glewInfoFunc(\"glGetTransformFeedbackVaryingNV\", glGetTransformFeedbackVaryingNV == NULL);\n  glewInfoFunc(\"glGetVaryingLocationNV\", glGetVaryingLocationNV == NULL);\n  glewInfoFunc(\"glTransformFeedbackAttribsNV\", glTransformFeedbackAttribsNV == NULL);\n  glewInfoFunc(\"glTransformFeedbackVaryingsNV\", glTransformFeedbackVaryingsNV == NULL);\n}\n\n#endif /* GL_NV_transform_feedback */\n\n#ifdef GL_NV_transform_feedback2\n\nstatic void _glewInfo_GL_NV_transform_feedback2 (void)\n{\n  glewPrintExt(\"GL_NV_transform_feedback2\", GLEW_NV_transform_feedback2, glewIsSupported(\"GL_NV_transform_feedback2\"), glewGetExtension(\"GL_NV_transform_feedback2\"));\n\n  glewInfoFunc(\"glBindTransformFeedbackNV\", glBindTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glDeleteTransformFeedbacksNV\", glDeleteTransformFeedbacksNV == NULL);\n  glewInfoFunc(\"glDrawTransformFeedbackNV\", glDrawTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glGenTransformFeedbacksNV\", glGenTransformFeedbacksNV == NULL);\n  glewInfoFunc(\"glIsTransformFeedbackNV\", glIsTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glPauseTransformFeedbackNV\", glPauseTransformFeedbackNV == NULL);\n  glewInfoFunc(\"glResumeTransformFeedbackNV\", glResumeTransformFeedbackNV == NULL);\n}\n\n#endif /* GL_NV_transform_feedback2 */\n\n#ifdef GL_NV_vdpau_interop\n\nstatic void _glewInfo_GL_NV_vdpau_interop (void)\n{\n  glewPrintExt(\"GL_NV_vdpau_interop\", GLEW_NV_vdpau_interop, glewIsSupported(\"GL_NV_vdpau_interop\"), glewGetExtension(\"GL_NV_vdpau_interop\"));\n\n  glewInfoFunc(\"glVDPAUFiniNV\", glVDPAUFiniNV == NULL);\n  glewInfoFunc(\"glVDPAUGetSurfaceivNV\", glVDPAUGetSurfaceivNV == NULL);\n  glewInfoFunc(\"glVDPAUInitNV\", glVDPAUInitNV == NULL);\n  glewInfoFunc(\"glVDPAUIsSurfaceNV\", glVDPAUIsSurfaceNV == NULL);\n  glewInfoFunc(\"glVDPAUMapSurfacesNV\", glVDPAUMapSurfacesNV == NULL);\n  glewInfoFunc(\"glVDPAURegisterOutputSurfaceNV\", glVDPAURegisterOutputSurfaceNV == NULL);\n  glewInfoFunc(\"glVDPAURegisterVideoSurfaceNV\", glVDPAURegisterVideoSurfaceNV == NULL);\n  glewInfoFunc(\"glVDPAUSurfaceAccessNV\", glVDPAUSurfaceAccessNV == NULL);\n  glewInfoFunc(\"glVDPAUUnmapSurfacesNV\", glVDPAUUnmapSurfacesNV == NULL);\n  glewInfoFunc(\"glVDPAUUnregisterSurfaceNV\", glVDPAUUnregisterSurfaceNV == NULL);\n}\n\n#endif /* GL_NV_vdpau_interop */\n\n#ifdef GL_NV_vertex_array_range\n\nstatic void _glewInfo_GL_NV_vertex_array_range (void)\n{\n  glewPrintExt(\"GL_NV_vertex_array_range\", GLEW_NV_vertex_array_range, glewIsSupported(\"GL_NV_vertex_array_range\"), glewGetExtension(\"GL_NV_vertex_array_range\"));\n\n  glewInfoFunc(\"glFlushVertexArrayRangeNV\", glFlushVertexArrayRangeNV == NULL);\n  glewInfoFunc(\"glVertexArrayRangeNV\", glVertexArrayRangeNV == NULL);\n}\n\n#endif /* GL_NV_vertex_array_range */\n\n#ifdef GL_NV_vertex_array_range2\n\nstatic void _glewInfo_GL_NV_vertex_array_range2 (void)\n{\n  glewPrintExt(\"GL_NV_vertex_array_range2\", GLEW_NV_vertex_array_range2, glewIsSupported(\"GL_NV_vertex_array_range2\"), glewGetExtension(\"GL_NV_vertex_array_range2\"));\n}\n\n#endif /* GL_NV_vertex_array_range2 */\n\n#ifdef GL_NV_vertex_attrib_integer_64bit\n\nstatic void _glewInfo_GL_NV_vertex_attrib_integer_64bit (void)\n{\n  glewPrintExt(\"GL_NV_vertex_attrib_integer_64bit\", GLEW_NV_vertex_attrib_integer_64bit, glewIsSupported(\"GL_NV_vertex_attrib_integer_64bit\"), glewGetExtension(\"GL_NV_vertex_attrib_integer_64bit\"));\n\n  glewInfoFunc(\"glGetVertexAttribLi64vNV\", glGetVertexAttribLi64vNV == NULL);\n  glewInfoFunc(\"glGetVertexAttribLui64vNV\", glGetVertexAttribLui64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL1i64NV\", glVertexAttribL1i64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL1i64vNV\", glVertexAttribL1i64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL1ui64NV\", glVertexAttribL1ui64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL1ui64vNV\", glVertexAttribL1ui64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL2i64NV\", glVertexAttribL2i64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL2i64vNV\", glVertexAttribL2i64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL2ui64NV\", glVertexAttribL2ui64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL2ui64vNV\", glVertexAttribL2ui64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL3i64NV\", glVertexAttribL3i64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL3i64vNV\", glVertexAttribL3i64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL3ui64NV\", glVertexAttribL3ui64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL3ui64vNV\", glVertexAttribL3ui64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL4i64NV\", glVertexAttribL4i64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL4i64vNV\", glVertexAttribL4i64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribL4ui64NV\", glVertexAttribL4ui64NV == NULL);\n  glewInfoFunc(\"glVertexAttribL4ui64vNV\", glVertexAttribL4ui64vNV == NULL);\n  glewInfoFunc(\"glVertexAttribLFormatNV\", glVertexAttribLFormatNV == NULL);\n}\n\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n\n#ifdef GL_NV_vertex_buffer_unified_memory\n\nstatic void _glewInfo_GL_NV_vertex_buffer_unified_memory (void)\n{\n  glewPrintExt(\"GL_NV_vertex_buffer_unified_memory\", GLEW_NV_vertex_buffer_unified_memory, glewIsSupported(\"GL_NV_vertex_buffer_unified_memory\"), glewGetExtension(\"GL_NV_vertex_buffer_unified_memory\"));\n\n  glewInfoFunc(\"glBufferAddressRangeNV\", glBufferAddressRangeNV == NULL);\n  glewInfoFunc(\"glColorFormatNV\", glColorFormatNV == NULL);\n  glewInfoFunc(\"glEdgeFlagFormatNV\", glEdgeFlagFormatNV == NULL);\n  glewInfoFunc(\"glFogCoordFormatNV\", glFogCoordFormatNV == NULL);\n  glewInfoFunc(\"glGetIntegerui64i_vNV\", glGetIntegerui64i_vNV == NULL);\n  glewInfoFunc(\"glIndexFormatNV\", glIndexFormatNV == NULL);\n  glewInfoFunc(\"glNormalFormatNV\", glNormalFormatNV == NULL);\n  glewInfoFunc(\"glSecondaryColorFormatNV\", glSecondaryColorFormatNV == NULL);\n  glewInfoFunc(\"glTexCoordFormatNV\", glTexCoordFormatNV == NULL);\n  glewInfoFunc(\"glVertexAttribFormatNV\", glVertexAttribFormatNV == NULL);\n  glewInfoFunc(\"glVertexAttribIFormatNV\", glVertexAttribIFormatNV == NULL);\n  glewInfoFunc(\"glVertexFormatNV\", glVertexFormatNV == NULL);\n}\n\n#endif /* GL_NV_vertex_buffer_unified_memory */\n\n#ifdef GL_NV_vertex_program\n\nstatic void _glewInfo_GL_NV_vertex_program (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program\", GLEW_NV_vertex_program, glewIsSupported(\"GL_NV_vertex_program\"), glewGetExtension(\"GL_NV_vertex_program\"));\n\n  glewInfoFunc(\"glAreProgramsResidentNV\", glAreProgramsResidentNV == NULL);\n  glewInfoFunc(\"glBindProgramNV\", glBindProgramNV == NULL);\n  glewInfoFunc(\"glDeleteProgramsNV\", glDeleteProgramsNV == NULL);\n  glewInfoFunc(\"glExecuteProgramNV\", glExecuteProgramNV == NULL);\n  glewInfoFunc(\"glGenProgramsNV\", glGenProgramsNV == NULL);\n  glewInfoFunc(\"glGetProgramParameterdvNV\", glGetProgramParameterdvNV == NULL);\n  glewInfoFunc(\"glGetProgramParameterfvNV\", glGetProgramParameterfvNV == NULL);\n  glewInfoFunc(\"glGetProgramStringNV\", glGetProgramStringNV == NULL);\n  glewInfoFunc(\"glGetProgramivNV\", glGetProgramivNV == NULL);\n  glewInfoFunc(\"glGetTrackMatrixivNV\", glGetTrackMatrixivNV == NULL);\n  glewInfoFunc(\"glGetVertexAttribPointervNV\", glGetVertexAttribPointervNV == NULL);\n  glewInfoFunc(\"glGetVertexAttribdvNV\", glGetVertexAttribdvNV == NULL);\n  glewInfoFunc(\"glGetVertexAttribfvNV\", glGetVertexAttribfvNV == NULL);\n  glewInfoFunc(\"glGetVertexAttribivNV\", glGetVertexAttribivNV == NULL);\n  glewInfoFunc(\"glIsProgramNV\", glIsProgramNV == NULL);\n  glewInfoFunc(\"glLoadProgramNV\", glLoadProgramNV == NULL);\n  glewInfoFunc(\"glProgramParameter4dNV\", glProgramParameter4dNV == NULL);\n  glewInfoFunc(\"glProgramParameter4dvNV\", glProgramParameter4dvNV == NULL);\n  glewInfoFunc(\"glProgramParameter4fNV\", glProgramParameter4fNV == NULL);\n  glewInfoFunc(\"glProgramParameter4fvNV\", glProgramParameter4fvNV == NULL);\n  glewInfoFunc(\"glProgramParameters4dvNV\", glProgramParameters4dvNV == NULL);\n  glewInfoFunc(\"glProgramParameters4fvNV\", glProgramParameters4fvNV == NULL);\n  glewInfoFunc(\"glRequestResidentProgramsNV\", glRequestResidentProgramsNV == NULL);\n  glewInfoFunc(\"glTrackMatrixNV\", glTrackMatrixNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1dNV\", glVertexAttrib1dNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1dvNV\", glVertexAttrib1dvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1fNV\", glVertexAttrib1fNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1fvNV\", glVertexAttrib1fvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1sNV\", glVertexAttrib1sNV == NULL);\n  glewInfoFunc(\"glVertexAttrib1svNV\", glVertexAttrib1svNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2dNV\", glVertexAttrib2dNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2dvNV\", glVertexAttrib2dvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2fNV\", glVertexAttrib2fNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2fvNV\", glVertexAttrib2fvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2sNV\", glVertexAttrib2sNV == NULL);\n  glewInfoFunc(\"glVertexAttrib2svNV\", glVertexAttrib2svNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3dNV\", glVertexAttrib3dNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3dvNV\", glVertexAttrib3dvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3fNV\", glVertexAttrib3fNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3fvNV\", glVertexAttrib3fvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3sNV\", glVertexAttrib3sNV == NULL);\n  glewInfoFunc(\"glVertexAttrib3svNV\", glVertexAttrib3svNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4dNV\", glVertexAttrib4dNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4dvNV\", glVertexAttrib4dvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4fNV\", glVertexAttrib4fNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4fvNV\", glVertexAttrib4fvNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4sNV\", glVertexAttrib4sNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4svNV\", glVertexAttrib4svNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4ubNV\", glVertexAttrib4ubNV == NULL);\n  glewInfoFunc(\"glVertexAttrib4ubvNV\", glVertexAttrib4ubvNV == NULL);\n  glewInfoFunc(\"glVertexAttribPointerNV\", glVertexAttribPointerNV == NULL);\n  glewInfoFunc(\"glVertexAttribs1dvNV\", glVertexAttribs1dvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs1fvNV\", glVertexAttribs1fvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs1svNV\", glVertexAttribs1svNV == NULL);\n  glewInfoFunc(\"glVertexAttribs2dvNV\", glVertexAttribs2dvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs2fvNV\", glVertexAttribs2fvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs2svNV\", glVertexAttribs2svNV == NULL);\n  glewInfoFunc(\"glVertexAttribs3dvNV\", glVertexAttribs3dvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs3fvNV\", glVertexAttribs3fvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs3svNV\", glVertexAttribs3svNV == NULL);\n  glewInfoFunc(\"glVertexAttribs4dvNV\", glVertexAttribs4dvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs4fvNV\", glVertexAttribs4fvNV == NULL);\n  glewInfoFunc(\"glVertexAttribs4svNV\", glVertexAttribs4svNV == NULL);\n  glewInfoFunc(\"glVertexAttribs4ubvNV\", glVertexAttribs4ubvNV == NULL);\n}\n\n#endif /* GL_NV_vertex_program */\n\n#ifdef GL_NV_vertex_program1_1\n\nstatic void _glewInfo_GL_NV_vertex_program1_1 (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program1_1\", GLEW_NV_vertex_program1_1, glewIsSupported(\"GL_NV_vertex_program1_1\"), glewGetExtension(\"GL_NV_vertex_program1_1\"));\n}\n\n#endif /* GL_NV_vertex_program1_1 */\n\n#ifdef GL_NV_vertex_program2\n\nstatic void _glewInfo_GL_NV_vertex_program2 (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program2\", GLEW_NV_vertex_program2, glewIsSupported(\"GL_NV_vertex_program2\"), glewGetExtension(\"GL_NV_vertex_program2\"));\n}\n\n#endif /* GL_NV_vertex_program2 */\n\n#ifdef GL_NV_vertex_program2_option\n\nstatic void _glewInfo_GL_NV_vertex_program2_option (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program2_option\", GLEW_NV_vertex_program2_option, glewIsSupported(\"GL_NV_vertex_program2_option\"), glewGetExtension(\"GL_NV_vertex_program2_option\"));\n}\n\n#endif /* GL_NV_vertex_program2_option */\n\n#ifdef GL_NV_vertex_program3\n\nstatic void _glewInfo_GL_NV_vertex_program3 (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program3\", GLEW_NV_vertex_program3, glewIsSupported(\"GL_NV_vertex_program3\"), glewGetExtension(\"GL_NV_vertex_program3\"));\n}\n\n#endif /* GL_NV_vertex_program3 */\n\n#ifdef GL_NV_vertex_program4\n\nstatic void _glewInfo_GL_NV_vertex_program4 (void)\n{\n  glewPrintExt(\"GL_NV_vertex_program4\", GLEW_NV_vertex_program4, glewIsSupported(\"GL_NV_vertex_program4\"), glewGetExtension(\"GL_NV_gpu_program4\"));\n}\n\n#endif /* GL_NV_vertex_program4 */\n\n#ifdef GL_NV_video_capture\n\nstatic void _glewInfo_GL_NV_video_capture (void)\n{\n  glewPrintExt(\"GL_NV_video_capture\", GLEW_NV_video_capture, glewIsSupported(\"GL_NV_video_capture\"), glewGetExtension(\"GL_NV_video_capture\"));\n\n  glewInfoFunc(\"glBeginVideoCaptureNV\", glBeginVideoCaptureNV == NULL);\n  glewInfoFunc(\"glBindVideoCaptureStreamBufferNV\", glBindVideoCaptureStreamBufferNV == NULL);\n  glewInfoFunc(\"glBindVideoCaptureStreamTextureNV\", glBindVideoCaptureStreamTextureNV == NULL);\n  glewInfoFunc(\"glEndVideoCaptureNV\", glEndVideoCaptureNV == NULL);\n  glewInfoFunc(\"glGetVideoCaptureStreamdvNV\", glGetVideoCaptureStreamdvNV == NULL);\n  glewInfoFunc(\"glGetVideoCaptureStreamfvNV\", glGetVideoCaptureStreamfvNV == NULL);\n  glewInfoFunc(\"glGetVideoCaptureStreamivNV\", glGetVideoCaptureStreamivNV == NULL);\n  glewInfoFunc(\"glGetVideoCaptureivNV\", glGetVideoCaptureivNV == NULL);\n  glewInfoFunc(\"glVideoCaptureNV\", glVideoCaptureNV == NULL);\n  glewInfoFunc(\"glVideoCaptureStreamParameterdvNV\", glVideoCaptureStreamParameterdvNV == NULL);\n  glewInfoFunc(\"glVideoCaptureStreamParameterfvNV\", glVideoCaptureStreamParameterfvNV == NULL);\n  glewInfoFunc(\"glVideoCaptureStreamParameterivNV\", glVideoCaptureStreamParameterivNV == NULL);\n}\n\n#endif /* GL_NV_video_capture */\n\n#ifdef GL_OES_byte_coordinates\n\nstatic void _glewInfo_GL_OES_byte_coordinates (void)\n{\n  glewPrintExt(\"GL_OES_byte_coordinates\", GLEW_OES_byte_coordinates, glewIsSupported(\"GL_OES_byte_coordinates\"), glewGetExtension(\"GL_OES_byte_coordinates\"));\n}\n\n#endif /* GL_OES_byte_coordinates */\n\n#ifdef GL_OES_compressed_paletted_texture\n\nstatic void _glewInfo_GL_OES_compressed_paletted_texture (void)\n{\n  glewPrintExt(\"GL_OES_compressed_paletted_texture\", GLEW_OES_compressed_paletted_texture, glewIsSupported(\"GL_OES_compressed_paletted_texture\"), glewGetExtension(\"GL_OES_compressed_paletted_texture\"));\n}\n\n#endif /* GL_OES_compressed_paletted_texture */\n\n#ifdef GL_OES_read_format\n\nstatic void _glewInfo_GL_OES_read_format (void)\n{\n  glewPrintExt(\"GL_OES_read_format\", GLEW_OES_read_format, glewIsSupported(\"GL_OES_read_format\"), glewGetExtension(\"GL_OES_read_format\"));\n}\n\n#endif /* GL_OES_read_format */\n\n#ifdef GL_OES_single_precision\n\nstatic void _glewInfo_GL_OES_single_precision (void)\n{\n  glewPrintExt(\"GL_OES_single_precision\", GLEW_OES_single_precision, glewIsSupported(\"GL_OES_single_precision\"), glewGetExtension(\"GL_OES_single_precision\"));\n\n  glewInfoFunc(\"glClearDepthfOES\", glClearDepthfOES == NULL);\n  glewInfoFunc(\"glClipPlanefOES\", glClipPlanefOES == NULL);\n  glewInfoFunc(\"glDepthRangefOES\", glDepthRangefOES == NULL);\n  glewInfoFunc(\"glFrustumfOES\", glFrustumfOES == NULL);\n  glewInfoFunc(\"glGetClipPlanefOES\", glGetClipPlanefOES == NULL);\n  glewInfoFunc(\"glOrthofOES\", glOrthofOES == NULL);\n}\n\n#endif /* GL_OES_single_precision */\n\n#ifdef GL_OML_interlace\n\nstatic void _glewInfo_GL_OML_interlace (void)\n{\n  glewPrintExt(\"GL_OML_interlace\", GLEW_OML_interlace, glewIsSupported(\"GL_OML_interlace\"), glewGetExtension(\"GL_OML_interlace\"));\n}\n\n#endif /* GL_OML_interlace */\n\n#ifdef GL_OML_resample\n\nstatic void _glewInfo_GL_OML_resample (void)\n{\n  glewPrintExt(\"GL_OML_resample\", GLEW_OML_resample, glewIsSupported(\"GL_OML_resample\"), glewGetExtension(\"GL_OML_resample\"));\n}\n\n#endif /* GL_OML_resample */\n\n#ifdef GL_OML_subsample\n\nstatic void _glewInfo_GL_OML_subsample (void)\n{\n  glewPrintExt(\"GL_OML_subsample\", GLEW_OML_subsample, glewIsSupported(\"GL_OML_subsample\"), glewGetExtension(\"GL_OML_subsample\"));\n}\n\n#endif /* GL_OML_subsample */\n\n#ifdef GL_PGI_misc_hints\n\nstatic void _glewInfo_GL_PGI_misc_hints (void)\n{\n  glewPrintExt(\"GL_PGI_misc_hints\", GLEW_PGI_misc_hints, glewIsSupported(\"GL_PGI_misc_hints\"), glewGetExtension(\"GL_PGI_misc_hints\"));\n}\n\n#endif /* GL_PGI_misc_hints */\n\n#ifdef GL_PGI_vertex_hints\n\nstatic void _glewInfo_GL_PGI_vertex_hints (void)\n{\n  glewPrintExt(\"GL_PGI_vertex_hints\", GLEW_PGI_vertex_hints, glewIsSupported(\"GL_PGI_vertex_hints\"), glewGetExtension(\"GL_PGI_vertex_hints\"));\n}\n\n#endif /* GL_PGI_vertex_hints */\n\n#ifdef GL_REGAL_error_string\n\nstatic void _glewInfo_GL_REGAL_error_string (void)\n{\n  glewPrintExt(\"GL_REGAL_error_string\", GLEW_REGAL_error_string, glewIsSupported(\"GL_REGAL_error_string\"), glewGetExtension(\"GL_REGAL_error_string\"));\n\n  glewInfoFunc(\"glErrorStringREGAL\", glErrorStringREGAL == NULL);\n}\n\n#endif /* GL_REGAL_error_string */\n\n#ifdef GL_REGAL_extension_query\n\nstatic void _glewInfo_GL_REGAL_extension_query (void)\n{\n  glewPrintExt(\"GL_REGAL_extension_query\", GLEW_REGAL_extension_query, glewIsSupported(\"GL_REGAL_extension_query\"), glewGetExtension(\"GL_REGAL_extension_query\"));\n\n  glewInfoFunc(\"glGetExtensionREGAL\", glGetExtensionREGAL == NULL);\n  glewInfoFunc(\"glIsSupportedREGAL\", glIsSupportedREGAL == NULL);\n}\n\n#endif /* GL_REGAL_extension_query */\n\n#ifdef GL_REGAL_log\n\nstatic void _glewInfo_GL_REGAL_log (void)\n{\n  glewPrintExt(\"GL_REGAL_log\", GLEW_REGAL_log, glewIsSupported(\"GL_REGAL_log\"), glewGetExtension(\"GL_REGAL_log\"));\n}\n\n#endif /* GL_REGAL_log */\n\n#ifdef GL_REND_screen_coordinates\n\nstatic void _glewInfo_GL_REND_screen_coordinates (void)\n{\n  glewPrintExt(\"GL_REND_screen_coordinates\", GLEW_REND_screen_coordinates, glewIsSupported(\"GL_REND_screen_coordinates\"), glewGetExtension(\"GL_REND_screen_coordinates\"));\n}\n\n#endif /* GL_REND_screen_coordinates */\n\n#ifdef GL_S3_s3tc\n\nstatic void _glewInfo_GL_S3_s3tc (void)\n{\n  glewPrintExt(\"GL_S3_s3tc\", GLEW_S3_s3tc, glewIsSupported(\"GL_S3_s3tc\"), glewGetExtension(\"GL_S3_s3tc\"));\n}\n\n#endif /* GL_S3_s3tc */\n\n#ifdef GL_SGIS_color_range\n\nstatic void _glewInfo_GL_SGIS_color_range (void)\n{\n  glewPrintExt(\"GL_SGIS_color_range\", GLEW_SGIS_color_range, glewIsSupported(\"GL_SGIS_color_range\"), glewGetExtension(\"GL_SGIS_color_range\"));\n}\n\n#endif /* GL_SGIS_color_range */\n\n#ifdef GL_SGIS_detail_texture\n\nstatic void _glewInfo_GL_SGIS_detail_texture (void)\n{\n  glewPrintExt(\"GL_SGIS_detail_texture\", GLEW_SGIS_detail_texture, glewIsSupported(\"GL_SGIS_detail_texture\"), glewGetExtension(\"GL_SGIS_detail_texture\"));\n\n  glewInfoFunc(\"glDetailTexFuncSGIS\", glDetailTexFuncSGIS == NULL);\n  glewInfoFunc(\"glGetDetailTexFuncSGIS\", glGetDetailTexFuncSGIS == NULL);\n}\n\n#endif /* GL_SGIS_detail_texture */\n\n#ifdef GL_SGIS_fog_function\n\nstatic void _glewInfo_GL_SGIS_fog_function (void)\n{\n  glewPrintExt(\"GL_SGIS_fog_function\", GLEW_SGIS_fog_function, glewIsSupported(\"GL_SGIS_fog_function\"), glewGetExtension(\"GL_SGIS_fog_function\"));\n\n  glewInfoFunc(\"glFogFuncSGIS\", glFogFuncSGIS == NULL);\n  glewInfoFunc(\"glGetFogFuncSGIS\", glGetFogFuncSGIS == NULL);\n}\n\n#endif /* GL_SGIS_fog_function */\n\n#ifdef GL_SGIS_generate_mipmap\n\nstatic void _glewInfo_GL_SGIS_generate_mipmap (void)\n{\n  glewPrintExt(\"GL_SGIS_generate_mipmap\", GLEW_SGIS_generate_mipmap, glewIsSupported(\"GL_SGIS_generate_mipmap\"), glewGetExtension(\"GL_SGIS_generate_mipmap\"));\n}\n\n#endif /* GL_SGIS_generate_mipmap */\n\n#ifdef GL_SGIS_multisample\n\nstatic void _glewInfo_GL_SGIS_multisample (void)\n{\n  glewPrintExt(\"GL_SGIS_multisample\", GLEW_SGIS_multisample, glewIsSupported(\"GL_SGIS_multisample\"), glewGetExtension(\"GL_SGIS_multisample\"));\n\n  glewInfoFunc(\"glSampleMaskSGIS\", glSampleMaskSGIS == NULL);\n  glewInfoFunc(\"glSamplePatternSGIS\", glSamplePatternSGIS == NULL);\n}\n\n#endif /* GL_SGIS_multisample */\n\n#ifdef GL_SGIS_pixel_texture\n\nstatic void _glewInfo_GL_SGIS_pixel_texture (void)\n{\n  glewPrintExt(\"GL_SGIS_pixel_texture\", GLEW_SGIS_pixel_texture, glewIsSupported(\"GL_SGIS_pixel_texture\"), glewGetExtension(\"GL_SGIS_pixel_texture\"));\n}\n\n#endif /* GL_SGIS_pixel_texture */\n\n#ifdef GL_SGIS_point_line_texgen\n\nstatic void _glewInfo_GL_SGIS_point_line_texgen (void)\n{\n  glewPrintExt(\"GL_SGIS_point_line_texgen\", GLEW_SGIS_point_line_texgen, glewIsSupported(\"GL_SGIS_point_line_texgen\"), glewGetExtension(\"GL_SGIS_point_line_texgen\"));\n}\n\n#endif /* GL_SGIS_point_line_texgen */\n\n#ifdef GL_SGIS_sharpen_texture\n\nstatic void _glewInfo_GL_SGIS_sharpen_texture (void)\n{\n  glewPrintExt(\"GL_SGIS_sharpen_texture\", GLEW_SGIS_sharpen_texture, glewIsSupported(\"GL_SGIS_sharpen_texture\"), glewGetExtension(\"GL_SGIS_sharpen_texture\"));\n\n  glewInfoFunc(\"glGetSharpenTexFuncSGIS\", glGetSharpenTexFuncSGIS == NULL);\n  glewInfoFunc(\"glSharpenTexFuncSGIS\", glSharpenTexFuncSGIS == NULL);\n}\n\n#endif /* GL_SGIS_sharpen_texture */\n\n#ifdef GL_SGIS_texture4D\n\nstatic void _glewInfo_GL_SGIS_texture4D (void)\n{\n  glewPrintExt(\"GL_SGIS_texture4D\", GLEW_SGIS_texture4D, glewIsSupported(\"GL_SGIS_texture4D\"), glewGetExtension(\"GL_SGIS_texture4D\"));\n\n  glewInfoFunc(\"glTexImage4DSGIS\", glTexImage4DSGIS == NULL);\n  glewInfoFunc(\"glTexSubImage4DSGIS\", glTexSubImage4DSGIS == NULL);\n}\n\n#endif /* GL_SGIS_texture4D */\n\n#ifdef GL_SGIS_texture_border_clamp\n\nstatic void _glewInfo_GL_SGIS_texture_border_clamp (void)\n{\n  glewPrintExt(\"GL_SGIS_texture_border_clamp\", GLEW_SGIS_texture_border_clamp, glewIsSupported(\"GL_SGIS_texture_border_clamp\"), glewGetExtension(\"GL_SGIS_texture_border_clamp\"));\n}\n\n#endif /* GL_SGIS_texture_border_clamp */\n\n#ifdef GL_SGIS_texture_edge_clamp\n\nstatic void _glewInfo_GL_SGIS_texture_edge_clamp (void)\n{\n  glewPrintExt(\"GL_SGIS_texture_edge_clamp\", GLEW_SGIS_texture_edge_clamp, glewIsSupported(\"GL_SGIS_texture_edge_clamp\"), glewGetExtension(\"GL_SGIS_texture_edge_clamp\"));\n}\n\n#endif /* GL_SGIS_texture_edge_clamp */\n\n#ifdef GL_SGIS_texture_filter4\n\nstatic void _glewInfo_GL_SGIS_texture_filter4 (void)\n{\n  glewPrintExt(\"GL_SGIS_texture_filter4\", GLEW_SGIS_texture_filter4, glewIsSupported(\"GL_SGIS_texture_filter4\"), glewGetExtension(\"GL_SGIS_texture_filter4\"));\n\n  glewInfoFunc(\"glGetTexFilterFuncSGIS\", glGetTexFilterFuncSGIS == NULL);\n  glewInfoFunc(\"glTexFilterFuncSGIS\", glTexFilterFuncSGIS == NULL);\n}\n\n#endif /* GL_SGIS_texture_filter4 */\n\n#ifdef GL_SGIS_texture_lod\n\nstatic void _glewInfo_GL_SGIS_texture_lod (void)\n{\n  glewPrintExt(\"GL_SGIS_texture_lod\", GLEW_SGIS_texture_lod, glewIsSupported(\"GL_SGIS_texture_lod\"), glewGetExtension(\"GL_SGIS_texture_lod\"));\n}\n\n#endif /* GL_SGIS_texture_lod */\n\n#ifdef GL_SGIS_texture_select\n\nstatic void _glewInfo_GL_SGIS_texture_select (void)\n{\n  glewPrintExt(\"GL_SGIS_texture_select\", GLEW_SGIS_texture_select, glewIsSupported(\"GL_SGIS_texture_select\"), glewGetExtension(\"GL_SGIS_texture_select\"));\n}\n\n#endif /* GL_SGIS_texture_select */\n\n#ifdef GL_SGIX_async\n\nstatic void _glewInfo_GL_SGIX_async (void)\n{\n  glewPrintExt(\"GL_SGIX_async\", GLEW_SGIX_async, glewIsSupported(\"GL_SGIX_async\"), glewGetExtension(\"GL_SGIX_async\"));\n\n  glewInfoFunc(\"glAsyncMarkerSGIX\", glAsyncMarkerSGIX == NULL);\n  glewInfoFunc(\"glDeleteAsyncMarkersSGIX\", glDeleteAsyncMarkersSGIX == NULL);\n  glewInfoFunc(\"glFinishAsyncSGIX\", glFinishAsyncSGIX == NULL);\n  glewInfoFunc(\"glGenAsyncMarkersSGIX\", glGenAsyncMarkersSGIX == NULL);\n  glewInfoFunc(\"glIsAsyncMarkerSGIX\", glIsAsyncMarkerSGIX == NULL);\n  glewInfoFunc(\"glPollAsyncSGIX\", glPollAsyncSGIX == NULL);\n}\n\n#endif /* GL_SGIX_async */\n\n#ifdef GL_SGIX_async_histogram\n\nstatic void _glewInfo_GL_SGIX_async_histogram (void)\n{\n  glewPrintExt(\"GL_SGIX_async_histogram\", GLEW_SGIX_async_histogram, glewIsSupported(\"GL_SGIX_async_histogram\"), glewGetExtension(\"GL_SGIX_async_histogram\"));\n}\n\n#endif /* GL_SGIX_async_histogram */\n\n#ifdef GL_SGIX_async_pixel\n\nstatic void _glewInfo_GL_SGIX_async_pixel (void)\n{\n  glewPrintExt(\"GL_SGIX_async_pixel\", GLEW_SGIX_async_pixel, glewIsSupported(\"GL_SGIX_async_pixel\"), glewGetExtension(\"GL_SGIX_async_pixel\"));\n}\n\n#endif /* GL_SGIX_async_pixel */\n\n#ifdef GL_SGIX_blend_alpha_minmax\n\nstatic void _glewInfo_GL_SGIX_blend_alpha_minmax (void)\n{\n  glewPrintExt(\"GL_SGIX_blend_alpha_minmax\", GLEW_SGIX_blend_alpha_minmax, glewIsSupported(\"GL_SGIX_blend_alpha_minmax\"), glewGetExtension(\"GL_SGIX_blend_alpha_minmax\"));\n}\n\n#endif /* GL_SGIX_blend_alpha_minmax */\n\n#ifdef GL_SGIX_clipmap\n\nstatic void _glewInfo_GL_SGIX_clipmap (void)\n{\n  glewPrintExt(\"GL_SGIX_clipmap\", GLEW_SGIX_clipmap, glewIsSupported(\"GL_SGIX_clipmap\"), glewGetExtension(\"GL_SGIX_clipmap\"));\n}\n\n#endif /* GL_SGIX_clipmap */\n\n#ifdef GL_SGIX_convolution_accuracy\n\nstatic void _glewInfo_GL_SGIX_convolution_accuracy (void)\n{\n  glewPrintExt(\"GL_SGIX_convolution_accuracy\", GLEW_SGIX_convolution_accuracy, glewIsSupported(\"GL_SGIX_convolution_accuracy\"), glewGetExtension(\"GL_SGIX_convolution_accuracy\"));\n}\n\n#endif /* GL_SGIX_convolution_accuracy */\n\n#ifdef GL_SGIX_depth_texture\n\nstatic void _glewInfo_GL_SGIX_depth_texture (void)\n{\n  glewPrintExt(\"GL_SGIX_depth_texture\", GLEW_SGIX_depth_texture, glewIsSupported(\"GL_SGIX_depth_texture\"), glewGetExtension(\"GL_SGIX_depth_texture\"));\n}\n\n#endif /* GL_SGIX_depth_texture */\n\n#ifdef GL_SGIX_flush_raster\n\nstatic void _glewInfo_GL_SGIX_flush_raster (void)\n{\n  glewPrintExt(\"GL_SGIX_flush_raster\", GLEW_SGIX_flush_raster, glewIsSupported(\"GL_SGIX_flush_raster\"), glewGetExtension(\"GL_SGIX_flush_raster\"));\n\n  glewInfoFunc(\"glFlushRasterSGIX\", glFlushRasterSGIX == NULL);\n}\n\n#endif /* GL_SGIX_flush_raster */\n\n#ifdef GL_SGIX_fog_offset\n\nstatic void _glewInfo_GL_SGIX_fog_offset (void)\n{\n  glewPrintExt(\"GL_SGIX_fog_offset\", GLEW_SGIX_fog_offset, glewIsSupported(\"GL_SGIX_fog_offset\"), glewGetExtension(\"GL_SGIX_fog_offset\"));\n}\n\n#endif /* GL_SGIX_fog_offset */\n\n#ifdef GL_SGIX_fog_texture\n\nstatic void _glewInfo_GL_SGIX_fog_texture (void)\n{\n  glewPrintExt(\"GL_SGIX_fog_texture\", GLEW_SGIX_fog_texture, glewIsSupported(\"GL_SGIX_fog_texture\"), glewGetExtension(\"GL_SGIX_fog_texture\"));\n\n  glewInfoFunc(\"glTextureFogSGIX\", glTextureFogSGIX == NULL);\n}\n\n#endif /* GL_SGIX_fog_texture */\n\n#ifdef GL_SGIX_fragment_specular_lighting\n\nstatic void _glewInfo_GL_SGIX_fragment_specular_lighting (void)\n{\n  glewPrintExt(\"GL_SGIX_fragment_specular_lighting\", GLEW_SGIX_fragment_specular_lighting, glewIsSupported(\"GL_SGIX_fragment_specular_lighting\"), glewGetExtension(\"GL_SGIX_fragment_specular_lighting\"));\n\n  glewInfoFunc(\"glFragmentColorMaterialSGIX\", glFragmentColorMaterialSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightModelfSGIX\", glFragmentLightModelfSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightModelfvSGIX\", glFragmentLightModelfvSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightModeliSGIX\", glFragmentLightModeliSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightModelivSGIX\", glFragmentLightModelivSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightfSGIX\", glFragmentLightfSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightfvSGIX\", glFragmentLightfvSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightiSGIX\", glFragmentLightiSGIX == NULL);\n  glewInfoFunc(\"glFragmentLightivSGIX\", glFragmentLightivSGIX == NULL);\n  glewInfoFunc(\"glFragmentMaterialfSGIX\", glFragmentMaterialfSGIX == NULL);\n  glewInfoFunc(\"glFragmentMaterialfvSGIX\", glFragmentMaterialfvSGIX == NULL);\n  glewInfoFunc(\"glFragmentMaterialiSGIX\", glFragmentMaterialiSGIX == NULL);\n  glewInfoFunc(\"glFragmentMaterialivSGIX\", glFragmentMaterialivSGIX == NULL);\n  glewInfoFunc(\"glGetFragmentLightfvSGIX\", glGetFragmentLightfvSGIX == NULL);\n  glewInfoFunc(\"glGetFragmentLightivSGIX\", glGetFragmentLightivSGIX == NULL);\n  glewInfoFunc(\"glGetFragmentMaterialfvSGIX\", glGetFragmentMaterialfvSGIX == NULL);\n  glewInfoFunc(\"glGetFragmentMaterialivSGIX\", glGetFragmentMaterialivSGIX == NULL);\n}\n\n#endif /* GL_SGIX_fragment_specular_lighting */\n\n#ifdef GL_SGIX_framezoom\n\nstatic void _glewInfo_GL_SGIX_framezoom (void)\n{\n  glewPrintExt(\"GL_SGIX_framezoom\", GLEW_SGIX_framezoom, glewIsSupported(\"GL_SGIX_framezoom\"), glewGetExtension(\"GL_SGIX_framezoom\"));\n\n  glewInfoFunc(\"glFrameZoomSGIX\", glFrameZoomSGIX == NULL);\n}\n\n#endif /* GL_SGIX_framezoom */\n\n#ifdef GL_SGIX_interlace\n\nstatic void _glewInfo_GL_SGIX_interlace (void)\n{\n  glewPrintExt(\"GL_SGIX_interlace\", GLEW_SGIX_interlace, glewIsSupported(\"GL_SGIX_interlace\"), glewGetExtension(\"GL_SGIX_interlace\"));\n}\n\n#endif /* GL_SGIX_interlace */\n\n#ifdef GL_SGIX_ir_instrument1\n\nstatic void _glewInfo_GL_SGIX_ir_instrument1 (void)\n{\n  glewPrintExt(\"GL_SGIX_ir_instrument1\", GLEW_SGIX_ir_instrument1, glewIsSupported(\"GL_SGIX_ir_instrument1\"), glewGetExtension(\"GL_SGIX_ir_instrument1\"));\n}\n\n#endif /* GL_SGIX_ir_instrument1 */\n\n#ifdef GL_SGIX_list_priority\n\nstatic void _glewInfo_GL_SGIX_list_priority (void)\n{\n  glewPrintExt(\"GL_SGIX_list_priority\", GLEW_SGIX_list_priority, glewIsSupported(\"GL_SGIX_list_priority\"), glewGetExtension(\"GL_SGIX_list_priority\"));\n}\n\n#endif /* GL_SGIX_list_priority */\n\n#ifdef GL_SGIX_pixel_texture\n\nstatic void _glewInfo_GL_SGIX_pixel_texture (void)\n{\n  glewPrintExt(\"GL_SGIX_pixel_texture\", GLEW_SGIX_pixel_texture, glewIsSupported(\"GL_SGIX_pixel_texture\"), glewGetExtension(\"GL_SGIX_pixel_texture\"));\n\n  glewInfoFunc(\"glPixelTexGenSGIX\", glPixelTexGenSGIX == NULL);\n}\n\n#endif /* GL_SGIX_pixel_texture */\n\n#ifdef GL_SGIX_pixel_texture_bits\n\nstatic void _glewInfo_GL_SGIX_pixel_texture_bits (void)\n{\n  glewPrintExt(\"GL_SGIX_pixel_texture_bits\", GLEW_SGIX_pixel_texture_bits, glewIsSupported(\"GL_SGIX_pixel_texture_bits\"), glewGetExtension(\"GL_SGIX_pixel_texture_bits\"));\n}\n\n#endif /* GL_SGIX_pixel_texture_bits */\n\n#ifdef GL_SGIX_reference_plane\n\nstatic void _glewInfo_GL_SGIX_reference_plane (void)\n{\n  glewPrintExt(\"GL_SGIX_reference_plane\", GLEW_SGIX_reference_plane, glewIsSupported(\"GL_SGIX_reference_plane\"), glewGetExtension(\"GL_SGIX_reference_plane\"));\n\n  glewInfoFunc(\"glReferencePlaneSGIX\", glReferencePlaneSGIX == NULL);\n}\n\n#endif /* GL_SGIX_reference_plane */\n\n#ifdef GL_SGIX_resample\n\nstatic void _glewInfo_GL_SGIX_resample (void)\n{\n  glewPrintExt(\"GL_SGIX_resample\", GLEW_SGIX_resample, glewIsSupported(\"GL_SGIX_resample\"), glewGetExtension(\"GL_SGIX_resample\"));\n}\n\n#endif /* GL_SGIX_resample */\n\n#ifdef GL_SGIX_shadow\n\nstatic void _glewInfo_GL_SGIX_shadow (void)\n{\n  glewPrintExt(\"GL_SGIX_shadow\", GLEW_SGIX_shadow, glewIsSupported(\"GL_SGIX_shadow\"), glewGetExtension(\"GL_SGIX_shadow\"));\n}\n\n#endif /* GL_SGIX_shadow */\n\n#ifdef GL_SGIX_shadow_ambient\n\nstatic void _glewInfo_GL_SGIX_shadow_ambient (void)\n{\n  glewPrintExt(\"GL_SGIX_shadow_ambient\", GLEW_SGIX_shadow_ambient, glewIsSupported(\"GL_SGIX_shadow_ambient\"), glewGetExtension(\"GL_SGIX_shadow_ambient\"));\n}\n\n#endif /* GL_SGIX_shadow_ambient */\n\n#ifdef GL_SGIX_sprite\n\nstatic void _glewInfo_GL_SGIX_sprite (void)\n{\n  glewPrintExt(\"GL_SGIX_sprite\", GLEW_SGIX_sprite, glewIsSupported(\"GL_SGIX_sprite\"), glewGetExtension(\"GL_SGIX_sprite\"));\n\n  glewInfoFunc(\"glSpriteParameterfSGIX\", glSpriteParameterfSGIX == NULL);\n  glewInfoFunc(\"glSpriteParameterfvSGIX\", glSpriteParameterfvSGIX == NULL);\n  glewInfoFunc(\"glSpriteParameteriSGIX\", glSpriteParameteriSGIX == NULL);\n  glewInfoFunc(\"glSpriteParameterivSGIX\", glSpriteParameterivSGIX == NULL);\n}\n\n#endif /* GL_SGIX_sprite */\n\n#ifdef GL_SGIX_tag_sample_buffer\n\nstatic void _glewInfo_GL_SGIX_tag_sample_buffer (void)\n{\n  glewPrintExt(\"GL_SGIX_tag_sample_buffer\", GLEW_SGIX_tag_sample_buffer, glewIsSupported(\"GL_SGIX_tag_sample_buffer\"), glewGetExtension(\"GL_SGIX_tag_sample_buffer\"));\n\n  glewInfoFunc(\"glTagSampleBufferSGIX\", glTagSampleBufferSGIX == NULL);\n}\n\n#endif /* GL_SGIX_tag_sample_buffer */\n\n#ifdef GL_SGIX_texture_add_env\n\nstatic void _glewInfo_GL_SGIX_texture_add_env (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_add_env\", GLEW_SGIX_texture_add_env, glewIsSupported(\"GL_SGIX_texture_add_env\"), glewGetExtension(\"GL_SGIX_texture_add_env\"));\n}\n\n#endif /* GL_SGIX_texture_add_env */\n\n#ifdef GL_SGIX_texture_coordinate_clamp\n\nstatic void _glewInfo_GL_SGIX_texture_coordinate_clamp (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_coordinate_clamp\", GLEW_SGIX_texture_coordinate_clamp, glewIsSupported(\"GL_SGIX_texture_coordinate_clamp\"), glewGetExtension(\"GL_SGIX_texture_coordinate_clamp\"));\n}\n\n#endif /* GL_SGIX_texture_coordinate_clamp */\n\n#ifdef GL_SGIX_texture_lod_bias\n\nstatic void _glewInfo_GL_SGIX_texture_lod_bias (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_lod_bias\", GLEW_SGIX_texture_lod_bias, glewIsSupported(\"GL_SGIX_texture_lod_bias\"), glewGetExtension(\"GL_SGIX_texture_lod_bias\"));\n}\n\n#endif /* GL_SGIX_texture_lod_bias */\n\n#ifdef GL_SGIX_texture_multi_buffer\n\nstatic void _glewInfo_GL_SGIX_texture_multi_buffer (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_multi_buffer\", GLEW_SGIX_texture_multi_buffer, glewIsSupported(\"GL_SGIX_texture_multi_buffer\"), glewGetExtension(\"GL_SGIX_texture_multi_buffer\"));\n}\n\n#endif /* GL_SGIX_texture_multi_buffer */\n\n#ifdef GL_SGIX_texture_range\n\nstatic void _glewInfo_GL_SGIX_texture_range (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_range\", GLEW_SGIX_texture_range, glewIsSupported(\"GL_SGIX_texture_range\"), glewGetExtension(\"GL_SGIX_texture_range\"));\n}\n\n#endif /* GL_SGIX_texture_range */\n\n#ifdef GL_SGIX_texture_scale_bias\n\nstatic void _glewInfo_GL_SGIX_texture_scale_bias (void)\n{\n  glewPrintExt(\"GL_SGIX_texture_scale_bias\", GLEW_SGIX_texture_scale_bias, glewIsSupported(\"GL_SGIX_texture_scale_bias\"), glewGetExtension(\"GL_SGIX_texture_scale_bias\"));\n}\n\n#endif /* GL_SGIX_texture_scale_bias */\n\n#ifdef GL_SGIX_vertex_preclip\n\nstatic void _glewInfo_GL_SGIX_vertex_preclip (void)\n{\n  glewPrintExt(\"GL_SGIX_vertex_preclip\", GLEW_SGIX_vertex_preclip, glewIsSupported(\"GL_SGIX_vertex_preclip\"), glewGetExtension(\"GL_SGIX_vertex_preclip\"));\n}\n\n#endif /* GL_SGIX_vertex_preclip */\n\n#ifdef GL_SGIX_vertex_preclip_hint\n\nstatic void _glewInfo_GL_SGIX_vertex_preclip_hint (void)\n{\n  glewPrintExt(\"GL_SGIX_vertex_preclip_hint\", GLEW_SGIX_vertex_preclip_hint, glewIsSupported(\"GL_SGIX_vertex_preclip_hint\"), glewGetExtension(\"GL_SGIX_vertex_preclip_hint\"));\n}\n\n#endif /* GL_SGIX_vertex_preclip_hint */\n\n#ifdef GL_SGIX_ycrcb\n\nstatic void _glewInfo_GL_SGIX_ycrcb (void)\n{\n  glewPrintExt(\"GL_SGIX_ycrcb\", GLEW_SGIX_ycrcb, glewIsSupported(\"GL_SGIX_ycrcb\"), glewGetExtension(\"GL_SGIX_ycrcb\"));\n}\n\n#endif /* GL_SGIX_ycrcb */\n\n#ifdef GL_SGI_color_matrix\n\nstatic void _glewInfo_GL_SGI_color_matrix (void)\n{\n  glewPrintExt(\"GL_SGI_color_matrix\", GLEW_SGI_color_matrix, glewIsSupported(\"GL_SGI_color_matrix\"), glewGetExtension(\"GL_SGI_color_matrix\"));\n}\n\n#endif /* GL_SGI_color_matrix */\n\n#ifdef GL_SGI_color_table\n\nstatic void _glewInfo_GL_SGI_color_table (void)\n{\n  glewPrintExt(\"GL_SGI_color_table\", GLEW_SGI_color_table, glewIsSupported(\"GL_SGI_color_table\"), glewGetExtension(\"GL_SGI_color_table\"));\n\n  glewInfoFunc(\"glColorTableParameterfvSGI\", glColorTableParameterfvSGI == NULL);\n  glewInfoFunc(\"glColorTableParameterivSGI\", glColorTableParameterivSGI == NULL);\n  glewInfoFunc(\"glColorTableSGI\", glColorTableSGI == NULL);\n  glewInfoFunc(\"glCopyColorTableSGI\", glCopyColorTableSGI == NULL);\n  glewInfoFunc(\"glGetColorTableParameterfvSGI\", glGetColorTableParameterfvSGI == NULL);\n  glewInfoFunc(\"glGetColorTableParameterivSGI\", glGetColorTableParameterivSGI == NULL);\n  glewInfoFunc(\"glGetColorTableSGI\", glGetColorTableSGI == NULL);\n}\n\n#endif /* GL_SGI_color_table */\n\n#ifdef GL_SGI_texture_color_table\n\nstatic void _glewInfo_GL_SGI_texture_color_table (void)\n{\n  glewPrintExt(\"GL_SGI_texture_color_table\", GLEW_SGI_texture_color_table, glewIsSupported(\"GL_SGI_texture_color_table\"), glewGetExtension(\"GL_SGI_texture_color_table\"));\n}\n\n#endif /* GL_SGI_texture_color_table */\n\n#ifdef GL_SUNX_constant_data\n\nstatic void _glewInfo_GL_SUNX_constant_data (void)\n{\n  glewPrintExt(\"GL_SUNX_constant_data\", GLEW_SUNX_constant_data, glewIsSupported(\"GL_SUNX_constant_data\"), glewGetExtension(\"GL_SUNX_constant_data\"));\n\n  glewInfoFunc(\"glFinishTextureSUNX\", glFinishTextureSUNX == NULL);\n}\n\n#endif /* GL_SUNX_constant_data */\n\n#ifdef GL_SUN_convolution_border_modes\n\nstatic void _glewInfo_GL_SUN_convolution_border_modes (void)\n{\n  glewPrintExt(\"GL_SUN_convolution_border_modes\", GLEW_SUN_convolution_border_modes, glewIsSupported(\"GL_SUN_convolution_border_modes\"), glewGetExtension(\"GL_SUN_convolution_border_modes\"));\n}\n\n#endif /* GL_SUN_convolution_border_modes */\n\n#ifdef GL_SUN_global_alpha\n\nstatic void _glewInfo_GL_SUN_global_alpha (void)\n{\n  glewPrintExt(\"GL_SUN_global_alpha\", GLEW_SUN_global_alpha, glewIsSupported(\"GL_SUN_global_alpha\"), glewGetExtension(\"GL_SUN_global_alpha\"));\n\n  glewInfoFunc(\"glGlobalAlphaFactorbSUN\", glGlobalAlphaFactorbSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactordSUN\", glGlobalAlphaFactordSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactorfSUN\", glGlobalAlphaFactorfSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactoriSUN\", glGlobalAlphaFactoriSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactorsSUN\", glGlobalAlphaFactorsSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactorubSUN\", glGlobalAlphaFactorubSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactoruiSUN\", glGlobalAlphaFactoruiSUN == NULL);\n  glewInfoFunc(\"glGlobalAlphaFactorusSUN\", glGlobalAlphaFactorusSUN == NULL);\n}\n\n#endif /* GL_SUN_global_alpha */\n\n#ifdef GL_SUN_mesh_array\n\nstatic void _glewInfo_GL_SUN_mesh_array (void)\n{\n  glewPrintExt(\"GL_SUN_mesh_array\", GLEW_SUN_mesh_array, glewIsSupported(\"GL_SUN_mesh_array\"), glewGetExtension(\"GL_SUN_mesh_array\"));\n}\n\n#endif /* GL_SUN_mesh_array */\n\n#ifdef GL_SUN_read_video_pixels\n\nstatic void _glewInfo_GL_SUN_read_video_pixels (void)\n{\n  glewPrintExt(\"GL_SUN_read_video_pixels\", GLEW_SUN_read_video_pixels, glewIsSupported(\"GL_SUN_read_video_pixels\"), glewGetExtension(\"GL_SUN_read_video_pixels\"));\n\n  glewInfoFunc(\"glReadVideoPixelsSUN\", glReadVideoPixelsSUN == NULL);\n}\n\n#endif /* GL_SUN_read_video_pixels */\n\n#ifdef GL_SUN_slice_accum\n\nstatic void _glewInfo_GL_SUN_slice_accum (void)\n{\n  glewPrintExt(\"GL_SUN_slice_accum\", GLEW_SUN_slice_accum, glewIsSupported(\"GL_SUN_slice_accum\"), glewGetExtension(\"GL_SUN_slice_accum\"));\n}\n\n#endif /* GL_SUN_slice_accum */\n\n#ifdef GL_SUN_triangle_list\n\nstatic void _glewInfo_GL_SUN_triangle_list (void)\n{\n  glewPrintExt(\"GL_SUN_triangle_list\", GLEW_SUN_triangle_list, glewIsSupported(\"GL_SUN_triangle_list\"), glewGetExtension(\"GL_SUN_triangle_list\"));\n\n  glewInfoFunc(\"glReplacementCodePointerSUN\", glReplacementCodePointerSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeubSUN\", glReplacementCodeubSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeubvSUN\", glReplacementCodeubvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiSUN\", glReplacementCodeuiSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuivSUN\", glReplacementCodeuivSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeusSUN\", glReplacementCodeusSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeusvSUN\", glReplacementCodeusvSUN == NULL);\n}\n\n#endif /* GL_SUN_triangle_list */\n\n#ifdef GL_SUN_vertex\n\nstatic void _glewInfo_GL_SUN_vertex (void)\n{\n  glewPrintExt(\"GL_SUN_vertex\", GLEW_SUN_vertex, glewIsSupported(\"GL_SUN_vertex\"), glewGetExtension(\"GL_SUN_vertex\"));\n\n  glewInfoFunc(\"glColor3fVertex3fSUN\", glColor3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glColor3fVertex3fvSUN\", glColor3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glColor4fNormal3fVertex3fSUN\", glColor4fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glColor4fNormal3fVertex3fvSUN\", glColor4fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glColor4ubVertex2fSUN\", glColor4ubVertex2fSUN == NULL);\n  glewInfoFunc(\"glColor4ubVertex2fvSUN\", glColor4ubVertex2fvSUN == NULL);\n  glewInfoFunc(\"glColor4ubVertex3fSUN\", glColor4ubVertex3fSUN == NULL);\n  glewInfoFunc(\"glColor4ubVertex3fvSUN\", glColor4ubVertex3fvSUN == NULL);\n  glewInfoFunc(\"glNormal3fVertex3fSUN\", glNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glNormal3fVertex3fvSUN\", glNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor3fVertex3fSUN\", glReplacementCodeuiColor3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor3fVertex3fvSUN\", glReplacementCodeuiColor3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor4fNormal3fVertex3fSUN\", glReplacementCodeuiColor4fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor4fNormal3fVertex3fvSUN\", glReplacementCodeuiColor4fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor4ubVertex3fSUN\", glReplacementCodeuiColor4ubVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiColor4ubVertex3fvSUN\", glReplacementCodeuiColor4ubVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiNormal3fVertex3fSUN\", glReplacementCodeuiNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiNormal3fVertex3fvSUN\", glReplacementCodeuiNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\", glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\", glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\", glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\", glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fVertex3fSUN\", glReplacementCodeuiTexCoord2fVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiTexCoord2fVertex3fvSUN\", glReplacementCodeuiTexCoord2fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiVertex3fSUN\", glReplacementCodeuiVertex3fSUN == NULL);\n  glewInfoFunc(\"glReplacementCodeuiVertex3fvSUN\", glReplacementCodeuiVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor3fVertex3fSUN\", glTexCoord2fColor3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor3fVertex3fvSUN\", glTexCoord2fColor3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor4fNormal3fVertex3fSUN\", glTexCoord2fColor4fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor4fNormal3fVertex3fvSUN\", glTexCoord2fColor4fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor4ubVertex3fSUN\", glTexCoord2fColor4ubVertex3fSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fColor4ubVertex3fvSUN\", glTexCoord2fColor4ubVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fNormal3fVertex3fSUN\", glTexCoord2fNormal3fVertex3fSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fNormal3fVertex3fvSUN\", glTexCoord2fNormal3fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fVertex3fSUN\", glTexCoord2fVertex3fSUN == NULL);\n  glewInfoFunc(\"glTexCoord2fVertex3fvSUN\", glTexCoord2fVertex3fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord4fColor4fNormal3fVertex4fSUN\", glTexCoord4fColor4fNormal3fVertex4fSUN == NULL);\n  glewInfoFunc(\"glTexCoord4fColor4fNormal3fVertex4fvSUN\", glTexCoord4fColor4fNormal3fVertex4fvSUN == NULL);\n  glewInfoFunc(\"glTexCoord4fVertex4fSUN\", glTexCoord4fVertex4fSUN == NULL);\n  glewInfoFunc(\"glTexCoord4fVertex4fvSUN\", glTexCoord4fVertex4fvSUN == NULL);\n}\n\n#endif /* GL_SUN_vertex */\n\n#ifdef GL_WIN_phong_shading\n\nstatic void _glewInfo_GL_WIN_phong_shading (void)\n{\n  glewPrintExt(\"GL_WIN_phong_shading\", GLEW_WIN_phong_shading, glewIsSupported(\"GL_WIN_phong_shading\"), glewGetExtension(\"GL_WIN_phong_shading\"));\n}\n\n#endif /* GL_WIN_phong_shading */\n\n#ifdef GL_WIN_specular_fog\n\nstatic void _glewInfo_GL_WIN_specular_fog (void)\n{\n  glewPrintExt(\"GL_WIN_specular_fog\", GLEW_WIN_specular_fog, glewIsSupported(\"GL_WIN_specular_fog\"), glewGetExtension(\"GL_WIN_specular_fog\"));\n}\n\n#endif /* GL_WIN_specular_fog */\n\n#ifdef GL_WIN_swap_hint\n\nstatic void _glewInfo_GL_WIN_swap_hint (void)\n{\n  glewPrintExt(\"GL_WIN_swap_hint\", GLEW_WIN_swap_hint, glewIsSupported(\"GL_WIN_swap_hint\"), glewGetExtension(\"GL_WIN_swap_hint\"));\n\n  glewInfoFunc(\"glAddSwapHintRectWIN\", glAddSwapHintRectWIN == NULL);\n}\n\n#endif /* GL_WIN_swap_hint */\n\n#ifdef _WIN32\n\n#ifdef WGL_3DFX_multisample\n\nstatic void _glewInfo_WGL_3DFX_multisample (void)\n{\n  glewPrintExt(\"WGL_3DFX_multisample\", WGLEW_3DFX_multisample, wglewIsSupported(\"WGL_3DFX_multisample\"), wglewGetExtension(\"WGL_3DFX_multisample\"));\n}\n\n#endif /* WGL_3DFX_multisample */\n\n#ifdef WGL_3DL_stereo_control\n\nstatic void _glewInfo_WGL_3DL_stereo_control (void)\n{\n  glewPrintExt(\"WGL_3DL_stereo_control\", WGLEW_3DL_stereo_control, wglewIsSupported(\"WGL_3DL_stereo_control\"), wglewGetExtension(\"WGL_3DL_stereo_control\"));\n\n  glewInfoFunc(\"wglSetStereoEmitterState3DL\", wglSetStereoEmitterState3DL == NULL);\n}\n\n#endif /* WGL_3DL_stereo_control */\n\n#ifdef WGL_AMD_gpu_association\n\nstatic void _glewInfo_WGL_AMD_gpu_association (void)\n{\n  glewPrintExt(\"WGL_AMD_gpu_association\", WGLEW_AMD_gpu_association, wglewIsSupported(\"WGL_AMD_gpu_association\"), wglewGetExtension(\"WGL_AMD_gpu_association\"));\n\n  glewInfoFunc(\"wglBlitContextFramebufferAMD\", wglBlitContextFramebufferAMD == NULL);\n  glewInfoFunc(\"wglCreateAssociatedContextAMD\", wglCreateAssociatedContextAMD == NULL);\n  glewInfoFunc(\"wglCreateAssociatedContextAttribsAMD\", wglCreateAssociatedContextAttribsAMD == NULL);\n  glewInfoFunc(\"wglDeleteAssociatedContextAMD\", wglDeleteAssociatedContextAMD == NULL);\n  glewInfoFunc(\"wglGetContextGPUIDAMD\", wglGetContextGPUIDAMD == NULL);\n  glewInfoFunc(\"wglGetCurrentAssociatedContextAMD\", wglGetCurrentAssociatedContextAMD == NULL);\n  glewInfoFunc(\"wglGetGPUIDsAMD\", wglGetGPUIDsAMD == NULL);\n  glewInfoFunc(\"wglGetGPUInfoAMD\", wglGetGPUInfoAMD == NULL);\n  glewInfoFunc(\"wglMakeAssociatedContextCurrentAMD\", wglMakeAssociatedContextCurrentAMD == NULL);\n}\n\n#endif /* WGL_AMD_gpu_association */\n\n#ifdef WGL_ARB_buffer_region\n\nstatic void _glewInfo_WGL_ARB_buffer_region (void)\n{\n  glewPrintExt(\"WGL_ARB_buffer_region\", WGLEW_ARB_buffer_region, wglewIsSupported(\"WGL_ARB_buffer_region\"), wglewGetExtension(\"WGL_ARB_buffer_region\"));\n\n  glewInfoFunc(\"wglCreateBufferRegionARB\", wglCreateBufferRegionARB == NULL);\n  glewInfoFunc(\"wglDeleteBufferRegionARB\", wglDeleteBufferRegionARB == NULL);\n  glewInfoFunc(\"wglRestoreBufferRegionARB\", wglRestoreBufferRegionARB == NULL);\n  glewInfoFunc(\"wglSaveBufferRegionARB\", wglSaveBufferRegionARB == NULL);\n}\n\n#endif /* WGL_ARB_buffer_region */\n\n#ifdef WGL_ARB_create_context\n\nstatic void _glewInfo_WGL_ARB_create_context (void)\n{\n  glewPrintExt(\"WGL_ARB_create_context\", WGLEW_ARB_create_context, wglewIsSupported(\"WGL_ARB_create_context\"), wglewGetExtension(\"WGL_ARB_create_context\"));\n\n  glewInfoFunc(\"wglCreateContextAttribsARB\", wglCreateContextAttribsARB == NULL);\n}\n\n#endif /* WGL_ARB_create_context */\n\n#ifdef WGL_ARB_create_context_profile\n\nstatic void _glewInfo_WGL_ARB_create_context_profile (void)\n{\n  glewPrintExt(\"WGL_ARB_create_context_profile\", WGLEW_ARB_create_context_profile, wglewIsSupported(\"WGL_ARB_create_context_profile\"), wglewGetExtension(\"WGL_ARB_create_context_profile\"));\n}\n\n#endif /* WGL_ARB_create_context_profile */\n\n#ifdef WGL_ARB_create_context_robustness\n\nstatic void _glewInfo_WGL_ARB_create_context_robustness (void)\n{\n  glewPrintExt(\"WGL_ARB_create_context_robustness\", WGLEW_ARB_create_context_robustness, wglewIsSupported(\"WGL_ARB_create_context_robustness\"), wglewGetExtension(\"WGL_ARB_create_context_robustness\"));\n}\n\n#endif /* WGL_ARB_create_context_robustness */\n\n#ifdef WGL_ARB_extensions_string\n\nstatic void _glewInfo_WGL_ARB_extensions_string (void)\n{\n  glewPrintExt(\"WGL_ARB_extensions_string\", WGLEW_ARB_extensions_string, wglewIsSupported(\"WGL_ARB_extensions_string\"), wglewGetExtension(\"WGL_ARB_extensions_string\"));\n\n  glewInfoFunc(\"wglGetExtensionsStringARB\", wglGetExtensionsStringARB == NULL);\n}\n\n#endif /* WGL_ARB_extensions_string */\n\n#ifdef WGL_ARB_framebuffer_sRGB\n\nstatic void _glewInfo_WGL_ARB_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"WGL_ARB_framebuffer_sRGB\", WGLEW_ARB_framebuffer_sRGB, wglewIsSupported(\"WGL_ARB_framebuffer_sRGB\"), wglewGetExtension(\"WGL_ARB_framebuffer_sRGB\"));\n}\n\n#endif /* WGL_ARB_framebuffer_sRGB */\n\n#ifdef WGL_ARB_make_current_read\n\nstatic void _glewInfo_WGL_ARB_make_current_read (void)\n{\n  glewPrintExt(\"WGL_ARB_make_current_read\", WGLEW_ARB_make_current_read, wglewIsSupported(\"WGL_ARB_make_current_read\"), wglewGetExtension(\"WGL_ARB_make_current_read\"));\n\n  glewInfoFunc(\"wglGetCurrentReadDCARB\", wglGetCurrentReadDCARB == NULL);\n  glewInfoFunc(\"wglMakeContextCurrentARB\", wglMakeContextCurrentARB == NULL);\n}\n\n#endif /* WGL_ARB_make_current_read */\n\n#ifdef WGL_ARB_multisample\n\nstatic void _glewInfo_WGL_ARB_multisample (void)\n{\n  glewPrintExt(\"WGL_ARB_multisample\", WGLEW_ARB_multisample, wglewIsSupported(\"WGL_ARB_multisample\"), wglewGetExtension(\"WGL_ARB_multisample\"));\n}\n\n#endif /* WGL_ARB_multisample */\n\n#ifdef WGL_ARB_pbuffer\n\nstatic void _glewInfo_WGL_ARB_pbuffer (void)\n{\n  glewPrintExt(\"WGL_ARB_pbuffer\", WGLEW_ARB_pbuffer, wglewIsSupported(\"WGL_ARB_pbuffer\"), wglewGetExtension(\"WGL_ARB_pbuffer\"));\n\n  glewInfoFunc(\"wglCreatePbufferARB\", wglCreatePbufferARB == NULL);\n  glewInfoFunc(\"wglDestroyPbufferARB\", wglDestroyPbufferARB == NULL);\n  glewInfoFunc(\"wglGetPbufferDCARB\", wglGetPbufferDCARB == NULL);\n  glewInfoFunc(\"wglQueryPbufferARB\", wglQueryPbufferARB == NULL);\n  glewInfoFunc(\"wglReleasePbufferDCARB\", wglReleasePbufferDCARB == NULL);\n}\n\n#endif /* WGL_ARB_pbuffer */\n\n#ifdef WGL_ARB_pixel_format\n\nstatic void _glewInfo_WGL_ARB_pixel_format (void)\n{\n  glewPrintExt(\"WGL_ARB_pixel_format\", WGLEW_ARB_pixel_format, wglewIsSupported(\"WGL_ARB_pixel_format\"), wglewGetExtension(\"WGL_ARB_pixel_format\"));\n\n  glewInfoFunc(\"wglChoosePixelFormatARB\", wglChoosePixelFormatARB == NULL);\n  glewInfoFunc(\"wglGetPixelFormatAttribfvARB\", wglGetPixelFormatAttribfvARB == NULL);\n  glewInfoFunc(\"wglGetPixelFormatAttribivARB\", wglGetPixelFormatAttribivARB == NULL);\n}\n\n#endif /* WGL_ARB_pixel_format */\n\n#ifdef WGL_ARB_pixel_format_float\n\nstatic void _glewInfo_WGL_ARB_pixel_format_float (void)\n{\n  glewPrintExt(\"WGL_ARB_pixel_format_float\", WGLEW_ARB_pixel_format_float, wglewIsSupported(\"WGL_ARB_pixel_format_float\"), wglewGetExtension(\"WGL_ARB_pixel_format_float\"));\n}\n\n#endif /* WGL_ARB_pixel_format_float */\n\n#ifdef WGL_ARB_render_texture\n\nstatic void _glewInfo_WGL_ARB_render_texture (void)\n{\n  glewPrintExt(\"WGL_ARB_render_texture\", WGLEW_ARB_render_texture, wglewIsSupported(\"WGL_ARB_render_texture\"), wglewGetExtension(\"WGL_ARB_render_texture\"));\n\n  glewInfoFunc(\"wglBindTexImageARB\", wglBindTexImageARB == NULL);\n  glewInfoFunc(\"wglReleaseTexImageARB\", wglReleaseTexImageARB == NULL);\n  glewInfoFunc(\"wglSetPbufferAttribARB\", wglSetPbufferAttribARB == NULL);\n}\n\n#endif /* WGL_ARB_render_texture */\n\n#ifdef WGL_ATI_pixel_format_float\n\nstatic void _glewInfo_WGL_ATI_pixel_format_float (void)\n{\n  glewPrintExt(\"WGL_ATI_pixel_format_float\", WGLEW_ATI_pixel_format_float, wglewIsSupported(\"WGL_ATI_pixel_format_float\"), wglewGetExtension(\"WGL_ATI_pixel_format_float\"));\n}\n\n#endif /* WGL_ATI_pixel_format_float */\n\n#ifdef WGL_ATI_render_texture_rectangle\n\nstatic void _glewInfo_WGL_ATI_render_texture_rectangle (void)\n{\n  glewPrintExt(\"WGL_ATI_render_texture_rectangle\", WGLEW_ATI_render_texture_rectangle, wglewIsSupported(\"WGL_ATI_render_texture_rectangle\"), wglewGetExtension(\"WGL_ATI_render_texture_rectangle\"));\n}\n\n#endif /* WGL_ATI_render_texture_rectangle */\n\n#ifdef WGL_EXT_create_context_es2_profile\n\nstatic void _glewInfo_WGL_EXT_create_context_es2_profile (void)\n{\n  glewPrintExt(\"WGL_EXT_create_context_es2_profile\", WGLEW_EXT_create_context_es2_profile, wglewIsSupported(\"WGL_EXT_create_context_es2_profile\"), wglewGetExtension(\"WGL_EXT_create_context_es2_profile\"));\n}\n\n#endif /* WGL_EXT_create_context_es2_profile */\n\n#ifdef WGL_EXT_create_context_es_profile\n\nstatic void _glewInfo_WGL_EXT_create_context_es_profile (void)\n{\n  glewPrintExt(\"WGL_EXT_create_context_es_profile\", WGLEW_EXT_create_context_es_profile, wglewIsSupported(\"WGL_EXT_create_context_es_profile\"), wglewGetExtension(\"WGL_EXT_create_context_es_profile\"));\n}\n\n#endif /* WGL_EXT_create_context_es_profile */\n\n#ifdef WGL_EXT_depth_float\n\nstatic void _glewInfo_WGL_EXT_depth_float (void)\n{\n  glewPrintExt(\"WGL_EXT_depth_float\", WGLEW_EXT_depth_float, wglewIsSupported(\"WGL_EXT_depth_float\"), wglewGetExtension(\"WGL_EXT_depth_float\"));\n}\n\n#endif /* WGL_EXT_depth_float */\n\n#ifdef WGL_EXT_display_color_table\n\nstatic void _glewInfo_WGL_EXT_display_color_table (void)\n{\n  glewPrintExt(\"WGL_EXT_display_color_table\", WGLEW_EXT_display_color_table, wglewIsSupported(\"WGL_EXT_display_color_table\"), wglewGetExtension(\"WGL_EXT_display_color_table\"));\n\n  glewInfoFunc(\"wglBindDisplayColorTableEXT\", wglBindDisplayColorTableEXT == NULL);\n  glewInfoFunc(\"wglCreateDisplayColorTableEXT\", wglCreateDisplayColorTableEXT == NULL);\n  glewInfoFunc(\"wglDestroyDisplayColorTableEXT\", wglDestroyDisplayColorTableEXT == NULL);\n  glewInfoFunc(\"wglLoadDisplayColorTableEXT\", wglLoadDisplayColorTableEXT == NULL);\n}\n\n#endif /* WGL_EXT_display_color_table */\n\n#ifdef WGL_EXT_extensions_string\n\nstatic void _glewInfo_WGL_EXT_extensions_string (void)\n{\n  glewPrintExt(\"WGL_EXT_extensions_string\", WGLEW_EXT_extensions_string, wglewIsSupported(\"WGL_EXT_extensions_string\"), wglewGetExtension(\"WGL_EXT_extensions_string\"));\n\n  glewInfoFunc(\"wglGetExtensionsStringEXT\", wglGetExtensionsStringEXT == NULL);\n}\n\n#endif /* WGL_EXT_extensions_string */\n\n#ifdef WGL_EXT_framebuffer_sRGB\n\nstatic void _glewInfo_WGL_EXT_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"WGL_EXT_framebuffer_sRGB\", WGLEW_EXT_framebuffer_sRGB, wglewIsSupported(\"WGL_EXT_framebuffer_sRGB\"), wglewGetExtension(\"WGL_EXT_framebuffer_sRGB\"));\n}\n\n#endif /* WGL_EXT_framebuffer_sRGB */\n\n#ifdef WGL_EXT_make_current_read\n\nstatic void _glewInfo_WGL_EXT_make_current_read (void)\n{\n  glewPrintExt(\"WGL_EXT_make_current_read\", WGLEW_EXT_make_current_read, wglewIsSupported(\"WGL_EXT_make_current_read\"), wglewGetExtension(\"WGL_EXT_make_current_read\"));\n\n  glewInfoFunc(\"wglGetCurrentReadDCEXT\", wglGetCurrentReadDCEXT == NULL);\n  glewInfoFunc(\"wglMakeContextCurrentEXT\", wglMakeContextCurrentEXT == NULL);\n}\n\n#endif /* WGL_EXT_make_current_read */\n\n#ifdef WGL_EXT_multisample\n\nstatic void _glewInfo_WGL_EXT_multisample (void)\n{\n  glewPrintExt(\"WGL_EXT_multisample\", WGLEW_EXT_multisample, wglewIsSupported(\"WGL_EXT_multisample\"), wglewGetExtension(\"WGL_EXT_multisample\"));\n}\n\n#endif /* WGL_EXT_multisample */\n\n#ifdef WGL_EXT_pbuffer\n\nstatic void _glewInfo_WGL_EXT_pbuffer (void)\n{\n  glewPrintExt(\"WGL_EXT_pbuffer\", WGLEW_EXT_pbuffer, wglewIsSupported(\"WGL_EXT_pbuffer\"), wglewGetExtension(\"WGL_EXT_pbuffer\"));\n\n  glewInfoFunc(\"wglCreatePbufferEXT\", wglCreatePbufferEXT == NULL);\n  glewInfoFunc(\"wglDestroyPbufferEXT\", wglDestroyPbufferEXT == NULL);\n  glewInfoFunc(\"wglGetPbufferDCEXT\", wglGetPbufferDCEXT == NULL);\n  glewInfoFunc(\"wglQueryPbufferEXT\", wglQueryPbufferEXT == NULL);\n  glewInfoFunc(\"wglReleasePbufferDCEXT\", wglReleasePbufferDCEXT == NULL);\n}\n\n#endif /* WGL_EXT_pbuffer */\n\n#ifdef WGL_EXT_pixel_format\n\nstatic void _glewInfo_WGL_EXT_pixel_format (void)\n{\n  glewPrintExt(\"WGL_EXT_pixel_format\", WGLEW_EXT_pixel_format, wglewIsSupported(\"WGL_EXT_pixel_format\"), wglewGetExtension(\"WGL_EXT_pixel_format\"));\n\n  glewInfoFunc(\"wglChoosePixelFormatEXT\", wglChoosePixelFormatEXT == NULL);\n  glewInfoFunc(\"wglGetPixelFormatAttribfvEXT\", wglGetPixelFormatAttribfvEXT == NULL);\n  glewInfoFunc(\"wglGetPixelFormatAttribivEXT\", wglGetPixelFormatAttribivEXT == NULL);\n}\n\n#endif /* WGL_EXT_pixel_format */\n\n#ifdef WGL_EXT_pixel_format_packed_float\n\nstatic void _glewInfo_WGL_EXT_pixel_format_packed_float (void)\n{\n  glewPrintExt(\"WGL_EXT_pixel_format_packed_float\", WGLEW_EXT_pixel_format_packed_float, wglewIsSupported(\"WGL_EXT_pixel_format_packed_float\"), wglewGetExtension(\"WGL_EXT_pixel_format_packed_float\"));\n}\n\n#endif /* WGL_EXT_pixel_format_packed_float */\n\n#ifdef WGL_EXT_swap_control\n\nstatic void _glewInfo_WGL_EXT_swap_control (void)\n{\n  glewPrintExt(\"WGL_EXT_swap_control\", WGLEW_EXT_swap_control, wglewIsSupported(\"WGL_EXT_swap_control\"), wglewGetExtension(\"WGL_EXT_swap_control\"));\n\n  glewInfoFunc(\"wglGetSwapIntervalEXT\", wglGetSwapIntervalEXT == NULL);\n  glewInfoFunc(\"wglSwapIntervalEXT\", wglSwapIntervalEXT == NULL);\n}\n\n#endif /* WGL_EXT_swap_control */\n\n#ifdef WGL_EXT_swap_control_tear\n\nstatic void _glewInfo_WGL_EXT_swap_control_tear (void)\n{\n  glewPrintExt(\"WGL_EXT_swap_control_tear\", WGLEW_EXT_swap_control_tear, wglewIsSupported(\"WGL_EXT_swap_control_tear\"), wglewGetExtension(\"WGL_EXT_swap_control_tear\"));\n}\n\n#endif /* WGL_EXT_swap_control_tear */\n\n#ifdef WGL_I3D_digital_video_control\n\nstatic void _glewInfo_WGL_I3D_digital_video_control (void)\n{\n  glewPrintExt(\"WGL_I3D_digital_video_control\", WGLEW_I3D_digital_video_control, wglewIsSupported(\"WGL_I3D_digital_video_control\"), wglewGetExtension(\"WGL_I3D_digital_video_control\"));\n\n  glewInfoFunc(\"wglGetDigitalVideoParametersI3D\", wglGetDigitalVideoParametersI3D == NULL);\n  glewInfoFunc(\"wglSetDigitalVideoParametersI3D\", wglSetDigitalVideoParametersI3D == NULL);\n}\n\n#endif /* WGL_I3D_digital_video_control */\n\n#ifdef WGL_I3D_gamma\n\nstatic void _glewInfo_WGL_I3D_gamma (void)\n{\n  glewPrintExt(\"WGL_I3D_gamma\", WGLEW_I3D_gamma, wglewIsSupported(\"WGL_I3D_gamma\"), wglewGetExtension(\"WGL_I3D_gamma\"));\n\n  glewInfoFunc(\"wglGetGammaTableI3D\", wglGetGammaTableI3D == NULL);\n  glewInfoFunc(\"wglGetGammaTableParametersI3D\", wglGetGammaTableParametersI3D == NULL);\n  glewInfoFunc(\"wglSetGammaTableI3D\", wglSetGammaTableI3D == NULL);\n  glewInfoFunc(\"wglSetGammaTableParametersI3D\", wglSetGammaTableParametersI3D == NULL);\n}\n\n#endif /* WGL_I3D_gamma */\n\n#ifdef WGL_I3D_genlock\n\nstatic void _glewInfo_WGL_I3D_genlock (void)\n{\n  glewPrintExt(\"WGL_I3D_genlock\", WGLEW_I3D_genlock, wglewIsSupported(\"WGL_I3D_genlock\"), wglewGetExtension(\"WGL_I3D_genlock\"));\n\n  glewInfoFunc(\"wglDisableGenlockI3D\", wglDisableGenlockI3D == NULL);\n  glewInfoFunc(\"wglEnableGenlockI3D\", wglEnableGenlockI3D == NULL);\n  glewInfoFunc(\"wglGenlockSampleRateI3D\", wglGenlockSampleRateI3D == NULL);\n  glewInfoFunc(\"wglGenlockSourceDelayI3D\", wglGenlockSourceDelayI3D == NULL);\n  glewInfoFunc(\"wglGenlockSourceEdgeI3D\", wglGenlockSourceEdgeI3D == NULL);\n  glewInfoFunc(\"wglGenlockSourceI3D\", wglGenlockSourceI3D == NULL);\n  glewInfoFunc(\"wglGetGenlockSampleRateI3D\", wglGetGenlockSampleRateI3D == NULL);\n  glewInfoFunc(\"wglGetGenlockSourceDelayI3D\", wglGetGenlockSourceDelayI3D == NULL);\n  glewInfoFunc(\"wglGetGenlockSourceEdgeI3D\", wglGetGenlockSourceEdgeI3D == NULL);\n  glewInfoFunc(\"wglGetGenlockSourceI3D\", wglGetGenlockSourceI3D == NULL);\n  glewInfoFunc(\"wglIsEnabledGenlockI3D\", wglIsEnabledGenlockI3D == NULL);\n  glewInfoFunc(\"wglQueryGenlockMaxSourceDelayI3D\", wglQueryGenlockMaxSourceDelayI3D == NULL);\n}\n\n#endif /* WGL_I3D_genlock */\n\n#ifdef WGL_I3D_image_buffer\n\nstatic void _glewInfo_WGL_I3D_image_buffer (void)\n{\n  glewPrintExt(\"WGL_I3D_image_buffer\", WGLEW_I3D_image_buffer, wglewIsSupported(\"WGL_I3D_image_buffer\"), wglewGetExtension(\"WGL_I3D_image_buffer\"));\n\n  glewInfoFunc(\"wglAssociateImageBufferEventsI3D\", wglAssociateImageBufferEventsI3D == NULL);\n  glewInfoFunc(\"wglCreateImageBufferI3D\", wglCreateImageBufferI3D == NULL);\n  glewInfoFunc(\"wglDestroyImageBufferI3D\", wglDestroyImageBufferI3D == NULL);\n  glewInfoFunc(\"wglReleaseImageBufferEventsI3D\", wglReleaseImageBufferEventsI3D == NULL);\n}\n\n#endif /* WGL_I3D_image_buffer */\n\n#ifdef WGL_I3D_swap_frame_lock\n\nstatic void _glewInfo_WGL_I3D_swap_frame_lock (void)\n{\n  glewPrintExt(\"WGL_I3D_swap_frame_lock\", WGLEW_I3D_swap_frame_lock, wglewIsSupported(\"WGL_I3D_swap_frame_lock\"), wglewGetExtension(\"WGL_I3D_swap_frame_lock\"));\n\n  glewInfoFunc(\"wglDisableFrameLockI3D\", wglDisableFrameLockI3D == NULL);\n  glewInfoFunc(\"wglEnableFrameLockI3D\", wglEnableFrameLockI3D == NULL);\n  glewInfoFunc(\"wglIsEnabledFrameLockI3D\", wglIsEnabledFrameLockI3D == NULL);\n  glewInfoFunc(\"wglQueryFrameLockMasterI3D\", wglQueryFrameLockMasterI3D == NULL);\n}\n\n#endif /* WGL_I3D_swap_frame_lock */\n\n#ifdef WGL_I3D_swap_frame_usage\n\nstatic void _glewInfo_WGL_I3D_swap_frame_usage (void)\n{\n  glewPrintExt(\"WGL_I3D_swap_frame_usage\", WGLEW_I3D_swap_frame_usage, wglewIsSupported(\"WGL_I3D_swap_frame_usage\"), wglewGetExtension(\"WGL_I3D_swap_frame_usage\"));\n\n  glewInfoFunc(\"wglBeginFrameTrackingI3D\", wglBeginFrameTrackingI3D == NULL);\n  glewInfoFunc(\"wglEndFrameTrackingI3D\", wglEndFrameTrackingI3D == NULL);\n  glewInfoFunc(\"wglGetFrameUsageI3D\", wglGetFrameUsageI3D == NULL);\n  glewInfoFunc(\"wglQueryFrameTrackingI3D\", wglQueryFrameTrackingI3D == NULL);\n}\n\n#endif /* WGL_I3D_swap_frame_usage */\n\n#ifdef WGL_NV_DX_interop\n\nstatic void _glewInfo_WGL_NV_DX_interop (void)\n{\n  glewPrintExt(\"WGL_NV_DX_interop\", WGLEW_NV_DX_interop, wglewIsSupported(\"WGL_NV_DX_interop\"), wglewGetExtension(\"WGL_NV_DX_interop\"));\n\n  glewInfoFunc(\"wglDXCloseDeviceNV\", wglDXCloseDeviceNV == NULL);\n  glewInfoFunc(\"wglDXLockObjectsNV\", wglDXLockObjectsNV == NULL);\n  glewInfoFunc(\"wglDXObjectAccessNV\", wglDXObjectAccessNV == NULL);\n  glewInfoFunc(\"wglDXOpenDeviceNV\", wglDXOpenDeviceNV == NULL);\n  glewInfoFunc(\"wglDXRegisterObjectNV\", wglDXRegisterObjectNV == NULL);\n  glewInfoFunc(\"wglDXSetResourceShareHandleNV\", wglDXSetResourceShareHandleNV == NULL);\n  glewInfoFunc(\"wglDXUnlockObjectsNV\", wglDXUnlockObjectsNV == NULL);\n  glewInfoFunc(\"wglDXUnregisterObjectNV\", wglDXUnregisterObjectNV == NULL);\n}\n\n#endif /* WGL_NV_DX_interop */\n\n#ifdef WGL_NV_DX_interop2\n\nstatic void _glewInfo_WGL_NV_DX_interop2 (void)\n{\n  glewPrintExt(\"WGL_NV_DX_interop2\", WGLEW_NV_DX_interop2, wglewIsSupported(\"WGL_NV_DX_interop2\"), wglewGetExtension(\"WGL_NV_DX_interop2\"));\n}\n\n#endif /* WGL_NV_DX_interop2 */\n\n#ifdef WGL_NV_copy_image\n\nstatic void _glewInfo_WGL_NV_copy_image (void)\n{\n  glewPrintExt(\"WGL_NV_copy_image\", WGLEW_NV_copy_image, wglewIsSupported(\"WGL_NV_copy_image\"), wglewGetExtension(\"WGL_NV_copy_image\"));\n\n  glewInfoFunc(\"wglCopyImageSubDataNV\", wglCopyImageSubDataNV == NULL);\n}\n\n#endif /* WGL_NV_copy_image */\n\n#ifdef WGL_NV_float_buffer\n\nstatic void _glewInfo_WGL_NV_float_buffer (void)\n{\n  glewPrintExt(\"WGL_NV_float_buffer\", WGLEW_NV_float_buffer, wglewIsSupported(\"WGL_NV_float_buffer\"), wglewGetExtension(\"WGL_NV_float_buffer\"));\n}\n\n#endif /* WGL_NV_float_buffer */\n\n#ifdef WGL_NV_gpu_affinity\n\nstatic void _glewInfo_WGL_NV_gpu_affinity (void)\n{\n  glewPrintExt(\"WGL_NV_gpu_affinity\", WGLEW_NV_gpu_affinity, wglewIsSupported(\"WGL_NV_gpu_affinity\"), wglewGetExtension(\"WGL_NV_gpu_affinity\"));\n\n  glewInfoFunc(\"wglCreateAffinityDCNV\", wglCreateAffinityDCNV == NULL);\n  glewInfoFunc(\"wglDeleteDCNV\", wglDeleteDCNV == NULL);\n  glewInfoFunc(\"wglEnumGpuDevicesNV\", wglEnumGpuDevicesNV == NULL);\n  glewInfoFunc(\"wglEnumGpusFromAffinityDCNV\", wglEnumGpusFromAffinityDCNV == NULL);\n  glewInfoFunc(\"wglEnumGpusNV\", wglEnumGpusNV == NULL);\n}\n\n#endif /* WGL_NV_gpu_affinity */\n\n#ifdef WGL_NV_multisample_coverage\n\nstatic void _glewInfo_WGL_NV_multisample_coverage (void)\n{\n  glewPrintExt(\"WGL_NV_multisample_coverage\", WGLEW_NV_multisample_coverage, wglewIsSupported(\"WGL_NV_multisample_coverage\"), wglewGetExtension(\"WGL_NV_multisample_coverage\"));\n}\n\n#endif /* WGL_NV_multisample_coverage */\n\n#ifdef WGL_NV_present_video\n\nstatic void _glewInfo_WGL_NV_present_video (void)\n{\n  glewPrintExt(\"WGL_NV_present_video\", WGLEW_NV_present_video, wglewIsSupported(\"WGL_NV_present_video\"), wglewGetExtension(\"WGL_NV_present_video\"));\n\n  glewInfoFunc(\"wglBindVideoDeviceNV\", wglBindVideoDeviceNV == NULL);\n  glewInfoFunc(\"wglEnumerateVideoDevicesNV\", wglEnumerateVideoDevicesNV == NULL);\n  glewInfoFunc(\"wglQueryCurrentContextNV\", wglQueryCurrentContextNV == NULL);\n}\n\n#endif /* WGL_NV_present_video */\n\n#ifdef WGL_NV_render_depth_texture\n\nstatic void _glewInfo_WGL_NV_render_depth_texture (void)\n{\n  glewPrintExt(\"WGL_NV_render_depth_texture\", WGLEW_NV_render_depth_texture, wglewIsSupported(\"WGL_NV_render_depth_texture\"), wglewGetExtension(\"WGL_NV_render_depth_texture\"));\n}\n\n#endif /* WGL_NV_render_depth_texture */\n\n#ifdef WGL_NV_render_texture_rectangle\n\nstatic void _glewInfo_WGL_NV_render_texture_rectangle (void)\n{\n  glewPrintExt(\"WGL_NV_render_texture_rectangle\", WGLEW_NV_render_texture_rectangle, wglewIsSupported(\"WGL_NV_render_texture_rectangle\"), wglewGetExtension(\"WGL_NV_render_texture_rectangle\"));\n}\n\n#endif /* WGL_NV_render_texture_rectangle */\n\n#ifdef WGL_NV_swap_group\n\nstatic void _glewInfo_WGL_NV_swap_group (void)\n{\n  glewPrintExt(\"WGL_NV_swap_group\", WGLEW_NV_swap_group, wglewIsSupported(\"WGL_NV_swap_group\"), wglewGetExtension(\"WGL_NV_swap_group\"));\n\n  glewInfoFunc(\"wglBindSwapBarrierNV\", wglBindSwapBarrierNV == NULL);\n  glewInfoFunc(\"wglJoinSwapGroupNV\", wglJoinSwapGroupNV == NULL);\n  glewInfoFunc(\"wglQueryFrameCountNV\", wglQueryFrameCountNV == NULL);\n  glewInfoFunc(\"wglQueryMaxSwapGroupsNV\", wglQueryMaxSwapGroupsNV == NULL);\n  glewInfoFunc(\"wglQuerySwapGroupNV\", wglQuerySwapGroupNV == NULL);\n  glewInfoFunc(\"wglResetFrameCountNV\", wglResetFrameCountNV == NULL);\n}\n\n#endif /* WGL_NV_swap_group */\n\n#ifdef WGL_NV_vertex_array_range\n\nstatic void _glewInfo_WGL_NV_vertex_array_range (void)\n{\n  glewPrintExt(\"WGL_NV_vertex_array_range\", WGLEW_NV_vertex_array_range, wglewIsSupported(\"WGL_NV_vertex_array_range\"), wglewGetExtension(\"WGL_NV_vertex_array_range\"));\n\n  glewInfoFunc(\"wglAllocateMemoryNV\", wglAllocateMemoryNV == NULL);\n  glewInfoFunc(\"wglFreeMemoryNV\", wglFreeMemoryNV == NULL);\n}\n\n#endif /* WGL_NV_vertex_array_range */\n\n#ifdef WGL_NV_video_capture\n\nstatic void _glewInfo_WGL_NV_video_capture (void)\n{\n  glewPrintExt(\"WGL_NV_video_capture\", WGLEW_NV_video_capture, wglewIsSupported(\"WGL_NV_video_capture\"), wglewGetExtension(\"WGL_NV_video_capture\"));\n\n  glewInfoFunc(\"wglBindVideoCaptureDeviceNV\", wglBindVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"wglEnumerateVideoCaptureDevicesNV\", wglEnumerateVideoCaptureDevicesNV == NULL);\n  glewInfoFunc(\"wglLockVideoCaptureDeviceNV\", wglLockVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"wglQueryVideoCaptureDeviceNV\", wglQueryVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"wglReleaseVideoCaptureDeviceNV\", wglReleaseVideoCaptureDeviceNV == NULL);\n}\n\n#endif /* WGL_NV_video_capture */\n\n#ifdef WGL_NV_video_output\n\nstatic void _glewInfo_WGL_NV_video_output (void)\n{\n  glewPrintExt(\"WGL_NV_video_output\", WGLEW_NV_video_output, wglewIsSupported(\"WGL_NV_video_output\"), wglewGetExtension(\"WGL_NV_video_output\"));\n\n  glewInfoFunc(\"wglBindVideoImageNV\", wglBindVideoImageNV == NULL);\n  glewInfoFunc(\"wglGetVideoDeviceNV\", wglGetVideoDeviceNV == NULL);\n  glewInfoFunc(\"wglGetVideoInfoNV\", wglGetVideoInfoNV == NULL);\n  glewInfoFunc(\"wglReleaseVideoDeviceNV\", wglReleaseVideoDeviceNV == NULL);\n  glewInfoFunc(\"wglReleaseVideoImageNV\", wglReleaseVideoImageNV == NULL);\n  glewInfoFunc(\"wglSendPbufferToVideoNV\", wglSendPbufferToVideoNV == NULL);\n}\n\n#endif /* WGL_NV_video_output */\n\n#ifdef WGL_OML_sync_control\n\nstatic void _glewInfo_WGL_OML_sync_control (void)\n{\n  glewPrintExt(\"WGL_OML_sync_control\", WGLEW_OML_sync_control, wglewIsSupported(\"WGL_OML_sync_control\"), wglewGetExtension(\"WGL_OML_sync_control\"));\n\n  glewInfoFunc(\"wglGetMscRateOML\", wglGetMscRateOML == NULL);\n  glewInfoFunc(\"wglGetSyncValuesOML\", wglGetSyncValuesOML == NULL);\n  glewInfoFunc(\"wglSwapBuffersMscOML\", wglSwapBuffersMscOML == NULL);\n  glewInfoFunc(\"wglSwapLayerBuffersMscOML\", wglSwapLayerBuffersMscOML == NULL);\n  glewInfoFunc(\"wglWaitForMscOML\", wglWaitForMscOML == NULL);\n  glewInfoFunc(\"wglWaitForSbcOML\", wglWaitForSbcOML == NULL);\n}\n\n#endif /* WGL_OML_sync_control */\n\n#else /* _UNIX */\n\n#ifdef GLX_VERSION_1_2\n\nstatic void _glewInfo_GLX_VERSION_1_2 (void)\n{\n  glewPrintExt(\"GLX_VERSION_1_2\", GLXEW_VERSION_1_2, GLXEW_VERSION_1_2, GLXEW_VERSION_1_2);\n\n  glewInfoFunc(\"glXGetCurrentDisplay\", glXGetCurrentDisplay == NULL);\n}\n\n#endif /* GLX_VERSION_1_2 */\n\n#ifdef GLX_VERSION_1_3\n\nstatic void _glewInfo_GLX_VERSION_1_3 (void)\n{\n  glewPrintExt(\"GLX_VERSION_1_3\", GLXEW_VERSION_1_3, GLXEW_VERSION_1_3, GLXEW_VERSION_1_3);\n\n  glewInfoFunc(\"glXChooseFBConfig\", glXChooseFBConfig == NULL);\n  glewInfoFunc(\"glXCreateNewContext\", glXCreateNewContext == NULL);\n  glewInfoFunc(\"glXCreatePbuffer\", glXCreatePbuffer == NULL);\n  glewInfoFunc(\"glXCreatePixmap\", glXCreatePixmap == NULL);\n  glewInfoFunc(\"glXCreateWindow\", glXCreateWindow == NULL);\n  glewInfoFunc(\"glXDestroyPbuffer\", glXDestroyPbuffer == NULL);\n  glewInfoFunc(\"glXDestroyPixmap\", glXDestroyPixmap == NULL);\n  glewInfoFunc(\"glXDestroyWindow\", glXDestroyWindow == NULL);\n  glewInfoFunc(\"glXGetCurrentReadDrawable\", glXGetCurrentReadDrawable == NULL);\n  glewInfoFunc(\"glXGetFBConfigAttrib\", glXGetFBConfigAttrib == NULL);\n  glewInfoFunc(\"glXGetFBConfigs\", glXGetFBConfigs == NULL);\n  glewInfoFunc(\"glXGetSelectedEvent\", glXGetSelectedEvent == NULL);\n  glewInfoFunc(\"glXGetVisualFromFBConfig\", glXGetVisualFromFBConfig == NULL);\n  glewInfoFunc(\"glXMakeContextCurrent\", glXMakeContextCurrent == NULL);\n  glewInfoFunc(\"glXQueryContext\", glXQueryContext == NULL);\n  glewInfoFunc(\"glXQueryDrawable\", glXQueryDrawable == NULL);\n  glewInfoFunc(\"glXSelectEvent\", glXSelectEvent == NULL);\n}\n\n#endif /* GLX_VERSION_1_3 */\n\n#ifdef GLX_VERSION_1_4\n\nstatic void _glewInfo_GLX_VERSION_1_4 (void)\n{\n  glewPrintExt(\"GLX_VERSION_1_4\", GLXEW_VERSION_1_4, GLXEW_VERSION_1_4, GLXEW_VERSION_1_4);\n}\n\n#endif /* GLX_VERSION_1_4 */\n\n#ifdef GLX_3DFX_multisample\n\nstatic void _glewInfo_GLX_3DFX_multisample (void)\n{\n  glewPrintExt(\"GLX_3DFX_multisample\", GLXEW_3DFX_multisample, glxewIsSupported(\"GLX_3DFX_multisample\"), glxewGetExtension(\"GLX_3DFX_multisample\"));\n}\n\n#endif /* GLX_3DFX_multisample */\n\n#ifdef GLX_AMD_gpu_association\n\nstatic void _glewInfo_GLX_AMD_gpu_association (void)\n{\n  glewPrintExt(\"GLX_AMD_gpu_association\", GLXEW_AMD_gpu_association, glxewIsSupported(\"GLX_AMD_gpu_association\"), glxewGetExtension(\"GLX_AMD_gpu_association\"));\n}\n\n#endif /* GLX_AMD_gpu_association */\n\n#ifdef GLX_ARB_create_context\n\nstatic void _glewInfo_GLX_ARB_create_context (void)\n{\n  glewPrintExt(\"GLX_ARB_create_context\", GLXEW_ARB_create_context, glxewIsSupported(\"GLX_ARB_create_context\"), glxewGetExtension(\"GLX_ARB_create_context\"));\n\n  glewInfoFunc(\"glXCreateContextAttribsARB\", glXCreateContextAttribsARB == NULL);\n}\n\n#endif /* GLX_ARB_create_context */\n\n#ifdef GLX_ARB_create_context_profile\n\nstatic void _glewInfo_GLX_ARB_create_context_profile (void)\n{\n  glewPrintExt(\"GLX_ARB_create_context_profile\", GLXEW_ARB_create_context_profile, glxewIsSupported(\"GLX_ARB_create_context_profile\"), glxewGetExtension(\"GLX_ARB_create_context_profile\"));\n}\n\n#endif /* GLX_ARB_create_context_profile */\n\n#ifdef GLX_ARB_create_context_robustness\n\nstatic void _glewInfo_GLX_ARB_create_context_robustness (void)\n{\n  glewPrintExt(\"GLX_ARB_create_context_robustness\", GLXEW_ARB_create_context_robustness, glxewIsSupported(\"GLX_ARB_create_context_robustness\"), glxewGetExtension(\"GLX_ARB_create_context_robustness\"));\n}\n\n#endif /* GLX_ARB_create_context_robustness */\n\n#ifdef GLX_ARB_fbconfig_float\n\nstatic void _glewInfo_GLX_ARB_fbconfig_float (void)\n{\n  glewPrintExt(\"GLX_ARB_fbconfig_float\", GLXEW_ARB_fbconfig_float, glxewIsSupported(\"GLX_ARB_fbconfig_float\"), glxewGetExtension(\"GLX_ARB_fbconfig_float\"));\n}\n\n#endif /* GLX_ARB_fbconfig_float */\n\n#ifdef GLX_ARB_framebuffer_sRGB\n\nstatic void _glewInfo_GLX_ARB_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"GLX_ARB_framebuffer_sRGB\", GLXEW_ARB_framebuffer_sRGB, glxewIsSupported(\"GLX_ARB_framebuffer_sRGB\"), glxewGetExtension(\"GLX_ARB_framebuffer_sRGB\"));\n}\n\n#endif /* GLX_ARB_framebuffer_sRGB */\n\n#ifdef GLX_ARB_get_proc_address\n\nstatic void _glewInfo_GLX_ARB_get_proc_address (void)\n{\n  glewPrintExt(\"GLX_ARB_get_proc_address\", GLXEW_ARB_get_proc_address, glxewIsSupported(\"GLX_ARB_get_proc_address\"), glxewGetExtension(\"GLX_ARB_get_proc_address\"));\n}\n\n#endif /* GLX_ARB_get_proc_address */\n\n#ifdef GLX_ARB_multisample\n\nstatic void _glewInfo_GLX_ARB_multisample (void)\n{\n  glewPrintExt(\"GLX_ARB_multisample\", GLXEW_ARB_multisample, glxewIsSupported(\"GLX_ARB_multisample\"), glxewGetExtension(\"GLX_ARB_multisample\"));\n}\n\n#endif /* GLX_ARB_multisample */\n\n#ifdef GLX_ARB_robustness_application_isolation\n\nstatic void _glewInfo_GLX_ARB_robustness_application_isolation (void)\n{\n  glewPrintExt(\"GLX_ARB_robustness_application_isolation\", GLXEW_ARB_robustness_application_isolation, glxewIsSupported(\"GLX_ARB_robustness_application_isolation\"), glxewGetExtension(\"GLX_ARB_robustness_application_isolation\"));\n}\n\n#endif /* GLX_ARB_robustness_application_isolation */\n\n#ifdef GLX_ARB_robustness_share_group_isolation\n\nstatic void _glewInfo_GLX_ARB_robustness_share_group_isolation (void)\n{\n  glewPrintExt(\"GLX_ARB_robustness_share_group_isolation\", GLXEW_ARB_robustness_share_group_isolation, glxewIsSupported(\"GLX_ARB_robustness_share_group_isolation\"), glxewGetExtension(\"GLX_ARB_robustness_share_group_isolation\"));\n}\n\n#endif /* GLX_ARB_robustness_share_group_isolation */\n\n#ifdef GLX_ARB_vertex_buffer_object\n\nstatic void _glewInfo_GLX_ARB_vertex_buffer_object (void)\n{\n  glewPrintExt(\"GLX_ARB_vertex_buffer_object\", GLXEW_ARB_vertex_buffer_object, glxewIsSupported(\"GLX_ARB_vertex_buffer_object\"), glxewGetExtension(\"GLX_ARB_vertex_buffer_object\"));\n}\n\n#endif /* GLX_ARB_vertex_buffer_object */\n\n#ifdef GLX_ATI_pixel_format_float\n\nstatic void _glewInfo_GLX_ATI_pixel_format_float (void)\n{\n  glewPrintExt(\"GLX_ATI_pixel_format_float\", GLXEW_ATI_pixel_format_float, glxewIsSupported(\"GLX_ATI_pixel_format_float\"), glxewGetExtension(\"GLX_ATI_pixel_format_float\"));\n}\n\n#endif /* GLX_ATI_pixel_format_float */\n\n#ifdef GLX_ATI_render_texture\n\nstatic void _glewInfo_GLX_ATI_render_texture (void)\n{\n  glewPrintExt(\"GLX_ATI_render_texture\", GLXEW_ATI_render_texture, glxewIsSupported(\"GLX_ATI_render_texture\"), glxewGetExtension(\"GLX_ATI_render_texture\"));\n\n  glewInfoFunc(\"glXBindTexImageATI\", glXBindTexImageATI == NULL);\n  glewInfoFunc(\"glXDrawableAttribATI\", glXDrawableAttribATI == NULL);\n  glewInfoFunc(\"glXReleaseTexImageATI\", glXReleaseTexImageATI == NULL);\n}\n\n#endif /* GLX_ATI_render_texture */\n\n#ifdef GLX_EXT_create_context_es2_profile\n\nstatic void _glewInfo_GLX_EXT_create_context_es2_profile (void)\n{\n  glewPrintExt(\"GLX_EXT_create_context_es2_profile\", GLXEW_EXT_create_context_es2_profile, glxewIsSupported(\"GLX_EXT_create_context_es2_profile\"), glxewGetExtension(\"GLX_EXT_create_context_es2_profile\"));\n}\n\n#endif /* GLX_EXT_create_context_es2_profile */\n\n#ifdef GLX_EXT_create_context_es_profile\n\nstatic void _glewInfo_GLX_EXT_create_context_es_profile (void)\n{\n  glewPrintExt(\"GLX_EXT_create_context_es_profile\", GLXEW_EXT_create_context_es_profile, glxewIsSupported(\"GLX_EXT_create_context_es_profile\"), glxewGetExtension(\"GLX_EXT_create_context_es_profile\"));\n}\n\n#endif /* GLX_EXT_create_context_es_profile */\n\n#ifdef GLX_EXT_fbconfig_packed_float\n\nstatic void _glewInfo_GLX_EXT_fbconfig_packed_float (void)\n{\n  glewPrintExt(\"GLX_EXT_fbconfig_packed_float\", GLXEW_EXT_fbconfig_packed_float, glxewIsSupported(\"GLX_EXT_fbconfig_packed_float\"), glxewGetExtension(\"GLX_EXT_fbconfig_packed_float\"));\n}\n\n#endif /* GLX_EXT_fbconfig_packed_float */\n\n#ifdef GLX_EXT_framebuffer_sRGB\n\nstatic void _glewInfo_GLX_EXT_framebuffer_sRGB (void)\n{\n  glewPrintExt(\"GLX_EXT_framebuffer_sRGB\", GLXEW_EXT_framebuffer_sRGB, glxewIsSupported(\"GLX_EXT_framebuffer_sRGB\"), glxewGetExtension(\"GLX_EXT_framebuffer_sRGB\"));\n}\n\n#endif /* GLX_EXT_framebuffer_sRGB */\n\n#ifdef GLX_EXT_import_context\n\nstatic void _glewInfo_GLX_EXT_import_context (void)\n{\n  glewPrintExt(\"GLX_EXT_import_context\", GLXEW_EXT_import_context, glxewIsSupported(\"GLX_EXT_import_context\"), glxewGetExtension(\"GLX_EXT_import_context\"));\n\n  glewInfoFunc(\"glXFreeContextEXT\", glXFreeContextEXT == NULL);\n  glewInfoFunc(\"glXGetContextIDEXT\", glXGetContextIDEXT == NULL);\n  glewInfoFunc(\"glXImportContextEXT\", glXImportContextEXT == NULL);\n  glewInfoFunc(\"glXQueryContextInfoEXT\", glXQueryContextInfoEXT == NULL);\n}\n\n#endif /* GLX_EXT_import_context */\n\n#ifdef GLX_EXT_scene_marker\n\nstatic void _glewInfo_GLX_EXT_scene_marker (void)\n{\n  glewPrintExt(\"GLX_EXT_scene_marker\", GLXEW_EXT_scene_marker, glxewIsSupported(\"GLX_EXT_scene_marker\"), glxewGetExtension(\"GLX_EXT_scene_marker\"));\n}\n\n#endif /* GLX_EXT_scene_marker */\n\n#ifdef GLX_EXT_swap_control\n\nstatic void _glewInfo_GLX_EXT_swap_control (void)\n{\n  glewPrintExt(\"GLX_EXT_swap_control\", GLXEW_EXT_swap_control, glxewIsSupported(\"GLX_EXT_swap_control\"), glxewGetExtension(\"GLX_EXT_swap_control\"));\n\n  glewInfoFunc(\"glXSwapIntervalEXT\", glXSwapIntervalEXT == NULL);\n}\n\n#endif /* GLX_EXT_swap_control */\n\n#ifdef GLX_EXT_swap_control_tear\n\nstatic void _glewInfo_GLX_EXT_swap_control_tear (void)\n{\n  glewPrintExt(\"GLX_EXT_swap_control_tear\", GLXEW_EXT_swap_control_tear, glxewIsSupported(\"GLX_EXT_swap_control_tear\"), glxewGetExtension(\"GLX_EXT_swap_control_tear\"));\n}\n\n#endif /* GLX_EXT_swap_control_tear */\n\n#ifdef GLX_EXT_texture_from_pixmap\n\nstatic void _glewInfo_GLX_EXT_texture_from_pixmap (void)\n{\n  glewPrintExt(\"GLX_EXT_texture_from_pixmap\", GLXEW_EXT_texture_from_pixmap, glxewIsSupported(\"GLX_EXT_texture_from_pixmap\"), glxewGetExtension(\"GLX_EXT_texture_from_pixmap\"));\n\n  glewInfoFunc(\"glXBindTexImageEXT\", glXBindTexImageEXT == NULL);\n  glewInfoFunc(\"glXReleaseTexImageEXT\", glXReleaseTexImageEXT == NULL);\n}\n\n#endif /* GLX_EXT_texture_from_pixmap */\n\n#ifdef GLX_EXT_visual_info\n\nstatic void _glewInfo_GLX_EXT_visual_info (void)\n{\n  glewPrintExt(\"GLX_EXT_visual_info\", GLXEW_EXT_visual_info, glxewIsSupported(\"GLX_EXT_visual_info\"), glxewGetExtension(\"GLX_EXT_visual_info\"));\n}\n\n#endif /* GLX_EXT_visual_info */\n\n#ifdef GLX_EXT_visual_rating\n\nstatic void _glewInfo_GLX_EXT_visual_rating (void)\n{\n  glewPrintExt(\"GLX_EXT_visual_rating\", GLXEW_EXT_visual_rating, glxewIsSupported(\"GLX_EXT_visual_rating\"), glxewGetExtension(\"GLX_EXT_visual_rating\"));\n}\n\n#endif /* GLX_EXT_visual_rating */\n\n#ifdef GLX_INTEL_swap_event\n\nstatic void _glewInfo_GLX_INTEL_swap_event (void)\n{\n  glewPrintExt(\"GLX_INTEL_swap_event\", GLXEW_INTEL_swap_event, glxewIsSupported(\"GLX_INTEL_swap_event\"), glxewGetExtension(\"GLX_INTEL_swap_event\"));\n}\n\n#endif /* GLX_INTEL_swap_event */\n\n#ifdef GLX_MESA_agp_offset\n\nstatic void _glewInfo_GLX_MESA_agp_offset (void)\n{\n  glewPrintExt(\"GLX_MESA_agp_offset\", GLXEW_MESA_agp_offset, glxewIsSupported(\"GLX_MESA_agp_offset\"), glxewGetExtension(\"GLX_MESA_agp_offset\"));\n\n  glewInfoFunc(\"glXGetAGPOffsetMESA\", glXGetAGPOffsetMESA == NULL);\n}\n\n#endif /* GLX_MESA_agp_offset */\n\n#ifdef GLX_MESA_copy_sub_buffer\n\nstatic void _glewInfo_GLX_MESA_copy_sub_buffer (void)\n{\n  glewPrintExt(\"GLX_MESA_copy_sub_buffer\", GLXEW_MESA_copy_sub_buffer, glxewIsSupported(\"GLX_MESA_copy_sub_buffer\"), glxewGetExtension(\"GLX_MESA_copy_sub_buffer\"));\n\n  glewInfoFunc(\"glXCopySubBufferMESA\", glXCopySubBufferMESA == NULL);\n}\n\n#endif /* GLX_MESA_copy_sub_buffer */\n\n#ifdef GLX_MESA_pixmap_colormap\n\nstatic void _glewInfo_GLX_MESA_pixmap_colormap (void)\n{\n  glewPrintExt(\"GLX_MESA_pixmap_colormap\", GLXEW_MESA_pixmap_colormap, glxewIsSupported(\"GLX_MESA_pixmap_colormap\"), glxewGetExtension(\"GLX_MESA_pixmap_colormap\"));\n\n  glewInfoFunc(\"glXCreateGLXPixmapMESA\", glXCreateGLXPixmapMESA == NULL);\n}\n\n#endif /* GLX_MESA_pixmap_colormap */\n\n#ifdef GLX_MESA_release_buffers\n\nstatic void _glewInfo_GLX_MESA_release_buffers (void)\n{\n  glewPrintExt(\"GLX_MESA_release_buffers\", GLXEW_MESA_release_buffers, glxewIsSupported(\"GLX_MESA_release_buffers\"), glxewGetExtension(\"GLX_MESA_release_buffers\"));\n\n  glewInfoFunc(\"glXReleaseBuffersMESA\", glXReleaseBuffersMESA == NULL);\n}\n\n#endif /* GLX_MESA_release_buffers */\n\n#ifdef GLX_MESA_set_3dfx_mode\n\nstatic void _glewInfo_GLX_MESA_set_3dfx_mode (void)\n{\n  glewPrintExt(\"GLX_MESA_set_3dfx_mode\", GLXEW_MESA_set_3dfx_mode, glxewIsSupported(\"GLX_MESA_set_3dfx_mode\"), glxewGetExtension(\"GLX_MESA_set_3dfx_mode\"));\n\n  glewInfoFunc(\"glXSet3DfxModeMESA\", glXSet3DfxModeMESA == NULL);\n}\n\n#endif /* GLX_MESA_set_3dfx_mode */\n\n#ifdef GLX_MESA_swap_control\n\nstatic void _glewInfo_GLX_MESA_swap_control (void)\n{\n  glewPrintExt(\"GLX_MESA_swap_control\", GLXEW_MESA_swap_control, glxewIsSupported(\"GLX_MESA_swap_control\"), glxewGetExtension(\"GLX_MESA_swap_control\"));\n\n  glewInfoFunc(\"glXGetSwapIntervalMESA\", glXGetSwapIntervalMESA == NULL);\n  glewInfoFunc(\"glXSwapIntervalMESA\", glXSwapIntervalMESA == NULL);\n}\n\n#endif /* GLX_MESA_swap_control */\n\n#ifdef GLX_NV_copy_image\n\nstatic void _glewInfo_GLX_NV_copy_image (void)\n{\n  glewPrintExt(\"GLX_NV_copy_image\", GLXEW_NV_copy_image, glxewIsSupported(\"GLX_NV_copy_image\"), glxewGetExtension(\"GLX_NV_copy_image\"));\n\n  glewInfoFunc(\"glXCopyImageSubDataNV\", glXCopyImageSubDataNV == NULL);\n}\n\n#endif /* GLX_NV_copy_image */\n\n#ifdef GLX_NV_float_buffer\n\nstatic void _glewInfo_GLX_NV_float_buffer (void)\n{\n  glewPrintExt(\"GLX_NV_float_buffer\", GLXEW_NV_float_buffer, glxewIsSupported(\"GLX_NV_float_buffer\"), glxewGetExtension(\"GLX_NV_float_buffer\"));\n}\n\n#endif /* GLX_NV_float_buffer */\n\n#ifdef GLX_NV_multisample_coverage\n\nstatic void _glewInfo_GLX_NV_multisample_coverage (void)\n{\n  glewPrintExt(\"GLX_NV_multisample_coverage\", GLXEW_NV_multisample_coverage, glxewIsSupported(\"GLX_NV_multisample_coverage\"), glxewGetExtension(\"GLX_NV_multisample_coverage\"));\n}\n\n#endif /* GLX_NV_multisample_coverage */\n\n#ifdef GLX_NV_present_video\n\nstatic void _glewInfo_GLX_NV_present_video (void)\n{\n  glewPrintExt(\"GLX_NV_present_video\", GLXEW_NV_present_video, glxewIsSupported(\"GLX_NV_present_video\"), glxewGetExtension(\"GLX_NV_present_video\"));\n\n  glewInfoFunc(\"glXBindVideoDeviceNV\", glXBindVideoDeviceNV == NULL);\n  glewInfoFunc(\"glXEnumerateVideoDevicesNV\", glXEnumerateVideoDevicesNV == NULL);\n}\n\n#endif /* GLX_NV_present_video */\n\n#ifdef GLX_NV_swap_group\n\nstatic void _glewInfo_GLX_NV_swap_group (void)\n{\n  glewPrintExt(\"GLX_NV_swap_group\", GLXEW_NV_swap_group, glxewIsSupported(\"GLX_NV_swap_group\"), glxewGetExtension(\"GLX_NV_swap_group\"));\n\n  glewInfoFunc(\"glXBindSwapBarrierNV\", glXBindSwapBarrierNV == NULL);\n  glewInfoFunc(\"glXJoinSwapGroupNV\", glXJoinSwapGroupNV == NULL);\n  glewInfoFunc(\"glXQueryFrameCountNV\", glXQueryFrameCountNV == NULL);\n  glewInfoFunc(\"glXQueryMaxSwapGroupsNV\", glXQueryMaxSwapGroupsNV == NULL);\n  glewInfoFunc(\"glXQuerySwapGroupNV\", glXQuerySwapGroupNV == NULL);\n  glewInfoFunc(\"glXResetFrameCountNV\", glXResetFrameCountNV == NULL);\n}\n\n#endif /* GLX_NV_swap_group */\n\n#ifdef GLX_NV_vertex_array_range\n\nstatic void _glewInfo_GLX_NV_vertex_array_range (void)\n{\n  glewPrintExt(\"GLX_NV_vertex_array_range\", GLXEW_NV_vertex_array_range, glxewIsSupported(\"GLX_NV_vertex_array_range\"), glxewGetExtension(\"GLX_NV_vertex_array_range\"));\n\n  glewInfoFunc(\"glXAllocateMemoryNV\", glXAllocateMemoryNV == NULL);\n  glewInfoFunc(\"glXFreeMemoryNV\", glXFreeMemoryNV == NULL);\n}\n\n#endif /* GLX_NV_vertex_array_range */\n\n#ifdef GLX_NV_video_capture\n\nstatic void _glewInfo_GLX_NV_video_capture (void)\n{\n  glewPrintExt(\"GLX_NV_video_capture\", GLXEW_NV_video_capture, glxewIsSupported(\"GLX_NV_video_capture\"), glxewGetExtension(\"GLX_NV_video_capture\"));\n\n  glewInfoFunc(\"glXBindVideoCaptureDeviceNV\", glXBindVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"glXEnumerateVideoCaptureDevicesNV\", glXEnumerateVideoCaptureDevicesNV == NULL);\n  glewInfoFunc(\"glXLockVideoCaptureDeviceNV\", glXLockVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"glXQueryVideoCaptureDeviceNV\", glXQueryVideoCaptureDeviceNV == NULL);\n  glewInfoFunc(\"glXReleaseVideoCaptureDeviceNV\", glXReleaseVideoCaptureDeviceNV == NULL);\n}\n\n#endif /* GLX_NV_video_capture */\n\n#ifdef GLX_NV_video_out\n\nstatic void _glewInfo_GLX_NV_video_out (void)\n{\n  glewPrintExt(\"GLX_NV_video_out\", GLXEW_NV_video_out, glxewIsSupported(\"GLX_NV_video_out\"), glxewGetExtension(\"GLX_NV_video_out\"));\n\n  glewInfoFunc(\"glXBindVideoImageNV\", glXBindVideoImageNV == NULL);\n  glewInfoFunc(\"glXGetVideoDeviceNV\", glXGetVideoDeviceNV == NULL);\n  glewInfoFunc(\"glXGetVideoInfoNV\", glXGetVideoInfoNV == NULL);\n  glewInfoFunc(\"glXReleaseVideoDeviceNV\", glXReleaseVideoDeviceNV == NULL);\n  glewInfoFunc(\"glXReleaseVideoImageNV\", glXReleaseVideoImageNV == NULL);\n  glewInfoFunc(\"glXSendPbufferToVideoNV\", glXSendPbufferToVideoNV == NULL);\n}\n\n#endif /* GLX_NV_video_out */\n\n#ifdef GLX_OML_swap_method\n\nstatic void _glewInfo_GLX_OML_swap_method (void)\n{\n  glewPrintExt(\"GLX_OML_swap_method\", GLXEW_OML_swap_method, glxewIsSupported(\"GLX_OML_swap_method\"), glxewGetExtension(\"GLX_OML_swap_method\"));\n}\n\n#endif /* GLX_OML_swap_method */\n\n#ifdef GLX_OML_sync_control\n\nstatic void _glewInfo_GLX_OML_sync_control (void)\n{\n  glewPrintExt(\"GLX_OML_sync_control\", GLXEW_OML_sync_control, glxewIsSupported(\"GLX_OML_sync_control\"), glxewGetExtension(\"GLX_OML_sync_control\"));\n\n  glewInfoFunc(\"glXGetMscRateOML\", glXGetMscRateOML == NULL);\n  glewInfoFunc(\"glXGetSyncValuesOML\", glXGetSyncValuesOML == NULL);\n  glewInfoFunc(\"glXSwapBuffersMscOML\", glXSwapBuffersMscOML == NULL);\n  glewInfoFunc(\"glXWaitForMscOML\", glXWaitForMscOML == NULL);\n  glewInfoFunc(\"glXWaitForSbcOML\", glXWaitForSbcOML == NULL);\n}\n\n#endif /* GLX_OML_sync_control */\n\n#ifdef GLX_SGIS_blended_overlay\n\nstatic void _glewInfo_GLX_SGIS_blended_overlay (void)\n{\n  glewPrintExt(\"GLX_SGIS_blended_overlay\", GLXEW_SGIS_blended_overlay, glxewIsSupported(\"GLX_SGIS_blended_overlay\"), glxewGetExtension(\"GLX_SGIS_blended_overlay\"));\n}\n\n#endif /* GLX_SGIS_blended_overlay */\n\n#ifdef GLX_SGIS_color_range\n\nstatic void _glewInfo_GLX_SGIS_color_range (void)\n{\n  glewPrintExt(\"GLX_SGIS_color_range\", GLXEW_SGIS_color_range, glxewIsSupported(\"GLX_SGIS_color_range\"), glxewGetExtension(\"GLX_SGIS_color_range\"));\n}\n\n#endif /* GLX_SGIS_color_range */\n\n#ifdef GLX_SGIS_multisample\n\nstatic void _glewInfo_GLX_SGIS_multisample (void)\n{\n  glewPrintExt(\"GLX_SGIS_multisample\", GLXEW_SGIS_multisample, glxewIsSupported(\"GLX_SGIS_multisample\"), glxewGetExtension(\"GLX_SGIS_multisample\"));\n}\n\n#endif /* GLX_SGIS_multisample */\n\n#ifdef GLX_SGIS_shared_multisample\n\nstatic void _glewInfo_GLX_SGIS_shared_multisample (void)\n{\n  glewPrintExt(\"GLX_SGIS_shared_multisample\", GLXEW_SGIS_shared_multisample, glxewIsSupported(\"GLX_SGIS_shared_multisample\"), glxewGetExtension(\"GLX_SGIS_shared_multisample\"));\n}\n\n#endif /* GLX_SGIS_shared_multisample */\n\n#ifdef GLX_SGIX_fbconfig\n\nstatic void _glewInfo_GLX_SGIX_fbconfig (void)\n{\n  glewPrintExt(\"GLX_SGIX_fbconfig\", GLXEW_SGIX_fbconfig, glxewIsSupported(\"GLX_SGIX_fbconfig\"), glxewGetExtension(\"GLX_SGIX_fbconfig\"));\n\n  glewInfoFunc(\"glXChooseFBConfigSGIX\", glXChooseFBConfigSGIX == NULL);\n  glewInfoFunc(\"glXCreateContextWithConfigSGIX\", glXCreateContextWithConfigSGIX == NULL);\n  glewInfoFunc(\"glXCreateGLXPixmapWithConfigSGIX\", glXCreateGLXPixmapWithConfigSGIX == NULL);\n  glewInfoFunc(\"glXGetFBConfigAttribSGIX\", glXGetFBConfigAttribSGIX == NULL);\n  glewInfoFunc(\"glXGetFBConfigFromVisualSGIX\", glXGetFBConfigFromVisualSGIX == NULL);\n  glewInfoFunc(\"glXGetVisualFromFBConfigSGIX\", glXGetVisualFromFBConfigSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_fbconfig */\n\n#ifdef GLX_SGIX_hyperpipe\n\nstatic void _glewInfo_GLX_SGIX_hyperpipe (void)\n{\n  glewPrintExt(\"GLX_SGIX_hyperpipe\", GLXEW_SGIX_hyperpipe, glxewIsSupported(\"GLX_SGIX_hyperpipe\"), glxewGetExtension(\"GLX_SGIX_hyperpipe\"));\n\n  glewInfoFunc(\"glXBindHyperpipeSGIX\", glXBindHyperpipeSGIX == NULL);\n  glewInfoFunc(\"glXDestroyHyperpipeConfigSGIX\", glXDestroyHyperpipeConfigSGIX == NULL);\n  glewInfoFunc(\"glXHyperpipeAttribSGIX\", glXHyperpipeAttribSGIX == NULL);\n  glewInfoFunc(\"glXHyperpipeConfigSGIX\", glXHyperpipeConfigSGIX == NULL);\n  glewInfoFunc(\"glXQueryHyperpipeAttribSGIX\", glXQueryHyperpipeAttribSGIX == NULL);\n  glewInfoFunc(\"glXQueryHyperpipeBestAttribSGIX\", glXQueryHyperpipeBestAttribSGIX == NULL);\n  glewInfoFunc(\"glXQueryHyperpipeConfigSGIX\", glXQueryHyperpipeConfigSGIX == NULL);\n  glewInfoFunc(\"glXQueryHyperpipeNetworkSGIX\", glXQueryHyperpipeNetworkSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_hyperpipe */\n\n#ifdef GLX_SGIX_pbuffer\n\nstatic void _glewInfo_GLX_SGIX_pbuffer (void)\n{\n  glewPrintExt(\"GLX_SGIX_pbuffer\", GLXEW_SGIX_pbuffer, glxewIsSupported(\"GLX_SGIX_pbuffer\"), glxewGetExtension(\"GLX_SGIX_pbuffer\"));\n\n  glewInfoFunc(\"glXCreateGLXPbufferSGIX\", glXCreateGLXPbufferSGIX == NULL);\n  glewInfoFunc(\"glXDestroyGLXPbufferSGIX\", glXDestroyGLXPbufferSGIX == NULL);\n  glewInfoFunc(\"glXGetSelectedEventSGIX\", glXGetSelectedEventSGIX == NULL);\n  glewInfoFunc(\"glXQueryGLXPbufferSGIX\", glXQueryGLXPbufferSGIX == NULL);\n  glewInfoFunc(\"glXSelectEventSGIX\", glXSelectEventSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_pbuffer */\n\n#ifdef GLX_SGIX_swap_barrier\n\nstatic void _glewInfo_GLX_SGIX_swap_barrier (void)\n{\n  glewPrintExt(\"GLX_SGIX_swap_barrier\", GLXEW_SGIX_swap_barrier, glxewIsSupported(\"GLX_SGIX_swap_barrier\"), glxewGetExtension(\"GLX_SGIX_swap_barrier\"));\n\n  glewInfoFunc(\"glXBindSwapBarrierSGIX\", glXBindSwapBarrierSGIX == NULL);\n  glewInfoFunc(\"glXQueryMaxSwapBarriersSGIX\", glXQueryMaxSwapBarriersSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_swap_barrier */\n\n#ifdef GLX_SGIX_swap_group\n\nstatic void _glewInfo_GLX_SGIX_swap_group (void)\n{\n  glewPrintExt(\"GLX_SGIX_swap_group\", GLXEW_SGIX_swap_group, glxewIsSupported(\"GLX_SGIX_swap_group\"), glxewGetExtension(\"GLX_SGIX_swap_group\"));\n\n  glewInfoFunc(\"glXJoinSwapGroupSGIX\", glXJoinSwapGroupSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_swap_group */\n\n#ifdef GLX_SGIX_video_resize\n\nstatic void _glewInfo_GLX_SGIX_video_resize (void)\n{\n  glewPrintExt(\"GLX_SGIX_video_resize\", GLXEW_SGIX_video_resize, glxewIsSupported(\"GLX_SGIX_video_resize\"), glxewGetExtension(\"GLX_SGIX_video_resize\"));\n\n  glewInfoFunc(\"glXBindChannelToWindowSGIX\", glXBindChannelToWindowSGIX == NULL);\n  glewInfoFunc(\"glXChannelRectSGIX\", glXChannelRectSGIX == NULL);\n  glewInfoFunc(\"glXChannelRectSyncSGIX\", glXChannelRectSyncSGIX == NULL);\n  glewInfoFunc(\"glXQueryChannelDeltasSGIX\", glXQueryChannelDeltasSGIX == NULL);\n  glewInfoFunc(\"glXQueryChannelRectSGIX\", glXQueryChannelRectSGIX == NULL);\n}\n\n#endif /* GLX_SGIX_video_resize */\n\n#ifdef GLX_SGIX_visual_select_group\n\nstatic void _glewInfo_GLX_SGIX_visual_select_group (void)\n{\n  glewPrintExt(\"GLX_SGIX_visual_select_group\", GLXEW_SGIX_visual_select_group, glxewIsSupported(\"GLX_SGIX_visual_select_group\"), glxewGetExtension(\"GLX_SGIX_visual_select_group\"));\n}\n\n#endif /* GLX_SGIX_visual_select_group */\n\n#ifdef GLX_SGI_cushion\n\nstatic void _glewInfo_GLX_SGI_cushion (void)\n{\n  glewPrintExt(\"GLX_SGI_cushion\", GLXEW_SGI_cushion, glxewIsSupported(\"GLX_SGI_cushion\"), glxewGetExtension(\"GLX_SGI_cushion\"));\n\n  glewInfoFunc(\"glXCushionSGI\", glXCushionSGI == NULL);\n}\n\n#endif /* GLX_SGI_cushion */\n\n#ifdef GLX_SGI_make_current_read\n\nstatic void _glewInfo_GLX_SGI_make_current_read (void)\n{\n  glewPrintExt(\"GLX_SGI_make_current_read\", GLXEW_SGI_make_current_read, glxewIsSupported(\"GLX_SGI_make_current_read\"), glxewGetExtension(\"GLX_SGI_make_current_read\"));\n\n  glewInfoFunc(\"glXGetCurrentReadDrawableSGI\", glXGetCurrentReadDrawableSGI == NULL);\n  glewInfoFunc(\"glXMakeCurrentReadSGI\", glXMakeCurrentReadSGI == NULL);\n}\n\n#endif /* GLX_SGI_make_current_read */\n\n#ifdef GLX_SGI_swap_control\n\nstatic void _glewInfo_GLX_SGI_swap_control (void)\n{\n  glewPrintExt(\"GLX_SGI_swap_control\", GLXEW_SGI_swap_control, glxewIsSupported(\"GLX_SGI_swap_control\"), glxewGetExtension(\"GLX_SGI_swap_control\"));\n\n  glewInfoFunc(\"glXSwapIntervalSGI\", glXSwapIntervalSGI == NULL);\n}\n\n#endif /* GLX_SGI_swap_control */\n\n#ifdef GLX_SGI_video_sync\n\nstatic void _glewInfo_GLX_SGI_video_sync (void)\n{\n  glewPrintExt(\"GLX_SGI_video_sync\", GLXEW_SGI_video_sync, glxewIsSupported(\"GLX_SGI_video_sync\"), glxewGetExtension(\"GLX_SGI_video_sync\"));\n\n  glewInfoFunc(\"glXGetVideoSyncSGI\", glXGetVideoSyncSGI == NULL);\n  glewInfoFunc(\"glXWaitVideoSyncSGI\", glXWaitVideoSyncSGI == NULL);\n}\n\n#endif /* GLX_SGI_video_sync */\n\n#ifdef GLX_SUN_get_transparent_index\n\nstatic void _glewInfo_GLX_SUN_get_transparent_index (void)\n{\n  glewPrintExt(\"GLX_SUN_get_transparent_index\", GLXEW_SUN_get_transparent_index, glxewIsSupported(\"GLX_SUN_get_transparent_index\"), glxewGetExtension(\"GLX_SUN_get_transparent_index\"));\n\n  glewInfoFunc(\"glXGetTransparentIndexSUN\", glXGetTransparentIndexSUN == NULL);\n}\n\n#endif /* GLX_SUN_get_transparent_index */\n\n#ifdef GLX_SUN_video_resize\n\nstatic void _glewInfo_GLX_SUN_video_resize (void)\n{\n  glewPrintExt(\"GLX_SUN_video_resize\", GLXEW_SUN_video_resize, glxewIsSupported(\"GLX_SUN_video_resize\"), glxewGetExtension(\"GLX_SUN_video_resize\"));\n\n  glewInfoFunc(\"glXGetVideoResizeSUN\", glXGetVideoResizeSUN == NULL);\n  glewInfoFunc(\"glXVideoResizeSUN\", glXVideoResizeSUN == NULL);\n}\n\n#endif /* GLX_SUN_video_resize */\n\n#endif /* _WIN32 */\n\n/* ------------------------------------------------------------------------ */\n\nstatic void glewInfo (void)\n{\n#ifdef GL_VERSION_1_1\n  _glewInfo_GL_VERSION_1_1();\n#endif /* GL_VERSION_1_1 */\n#ifdef GL_VERSION_1_2\n  _glewInfo_GL_VERSION_1_2();\n#endif /* GL_VERSION_1_2 */\n#ifdef GL_VERSION_1_2_1\n  _glewInfo_GL_VERSION_1_2_1();\n#endif /* GL_VERSION_1_2_1 */\n#ifdef GL_VERSION_1_3\n  _glewInfo_GL_VERSION_1_3();\n#endif /* GL_VERSION_1_3 */\n#ifdef GL_VERSION_1_4\n  _glewInfo_GL_VERSION_1_4();\n#endif /* GL_VERSION_1_4 */\n#ifdef GL_VERSION_1_5\n  _glewInfo_GL_VERSION_1_5();\n#endif /* GL_VERSION_1_5 */\n#ifdef GL_VERSION_2_0\n  _glewInfo_GL_VERSION_2_0();\n#endif /* GL_VERSION_2_0 */\n#ifdef GL_VERSION_2_1\n  _glewInfo_GL_VERSION_2_1();\n#endif /* GL_VERSION_2_1 */\n#ifdef GL_VERSION_3_0\n  _glewInfo_GL_VERSION_3_0();\n#endif /* GL_VERSION_3_0 */\n#ifdef GL_VERSION_3_1\n  _glewInfo_GL_VERSION_3_1();\n#endif /* GL_VERSION_3_1 */\n#ifdef GL_VERSION_3_2\n  _glewInfo_GL_VERSION_3_2();\n#endif /* GL_VERSION_3_2 */\n#ifdef GL_VERSION_3_3\n  _glewInfo_GL_VERSION_3_3();\n#endif /* GL_VERSION_3_3 */\n#ifdef GL_VERSION_4_0\n  _glewInfo_GL_VERSION_4_0();\n#endif /* GL_VERSION_4_0 */\n#ifdef GL_VERSION_4_1\n  _glewInfo_GL_VERSION_4_1();\n#endif /* GL_VERSION_4_1 */\n#ifdef GL_VERSION_4_2\n  _glewInfo_GL_VERSION_4_2();\n#endif /* GL_VERSION_4_2 */\n#ifdef GL_VERSION_4_3\n  _glewInfo_GL_VERSION_4_3();\n#endif /* GL_VERSION_4_3 */\n#ifdef GL_3DFX_multisample\n  _glewInfo_GL_3DFX_multisample();\n#endif /* GL_3DFX_multisample */\n#ifdef GL_3DFX_tbuffer\n  _glewInfo_GL_3DFX_tbuffer();\n#endif /* GL_3DFX_tbuffer */\n#ifdef GL_3DFX_texture_compression_FXT1\n  _glewInfo_GL_3DFX_texture_compression_FXT1();\n#endif /* GL_3DFX_texture_compression_FXT1 */\n#ifdef GL_AMD_blend_minmax_factor\n  _glewInfo_GL_AMD_blend_minmax_factor();\n#endif /* GL_AMD_blend_minmax_factor */\n#ifdef GL_AMD_conservative_depth\n  _glewInfo_GL_AMD_conservative_depth();\n#endif /* GL_AMD_conservative_depth */\n#ifdef GL_AMD_debug_output\n  _glewInfo_GL_AMD_debug_output();\n#endif /* GL_AMD_debug_output */\n#ifdef GL_AMD_depth_clamp_separate\n  _glewInfo_GL_AMD_depth_clamp_separate();\n#endif /* GL_AMD_depth_clamp_separate */\n#ifdef GL_AMD_draw_buffers_blend\n  _glewInfo_GL_AMD_draw_buffers_blend();\n#endif /* GL_AMD_draw_buffers_blend */\n#ifdef GL_AMD_multi_draw_indirect\n  _glewInfo_GL_AMD_multi_draw_indirect();\n#endif /* GL_AMD_multi_draw_indirect */\n#ifdef GL_AMD_name_gen_delete\n  _glewInfo_GL_AMD_name_gen_delete();\n#endif /* GL_AMD_name_gen_delete */\n#ifdef GL_AMD_performance_monitor\n  _glewInfo_GL_AMD_performance_monitor();\n#endif /* GL_AMD_performance_monitor */\n#ifdef GL_AMD_pinned_memory\n  _glewInfo_GL_AMD_pinned_memory();\n#endif /* GL_AMD_pinned_memory */\n#ifdef GL_AMD_query_buffer_object\n  _glewInfo_GL_AMD_query_buffer_object();\n#endif /* GL_AMD_query_buffer_object */\n#ifdef GL_AMD_sample_positions\n  _glewInfo_GL_AMD_sample_positions();\n#endif /* GL_AMD_sample_positions */\n#ifdef GL_AMD_seamless_cubemap_per_texture\n  _glewInfo_GL_AMD_seamless_cubemap_per_texture();\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n#ifdef GL_AMD_shader_stencil_export\n  _glewInfo_GL_AMD_shader_stencil_export();\n#endif /* GL_AMD_shader_stencil_export */\n#ifdef GL_AMD_stencil_operation_extended\n  _glewInfo_GL_AMD_stencil_operation_extended();\n#endif /* GL_AMD_stencil_operation_extended */\n#ifdef GL_AMD_texture_texture4\n  _glewInfo_GL_AMD_texture_texture4();\n#endif /* GL_AMD_texture_texture4 */\n#ifdef GL_AMD_transform_feedback3_lines_triangles\n  _glewInfo_GL_AMD_transform_feedback3_lines_triangles();\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n#ifdef GL_AMD_vertex_shader_layer\n  _glewInfo_GL_AMD_vertex_shader_layer();\n#endif /* GL_AMD_vertex_shader_layer */\n#ifdef GL_AMD_vertex_shader_tessellator\n  _glewInfo_GL_AMD_vertex_shader_tessellator();\n#endif /* GL_AMD_vertex_shader_tessellator */\n#ifdef GL_AMD_vertex_shader_viewport_index\n  _glewInfo_GL_AMD_vertex_shader_viewport_index();\n#endif /* GL_AMD_vertex_shader_viewport_index */\n#ifdef GL_APPLE_aux_depth_stencil\n  _glewInfo_GL_APPLE_aux_depth_stencil();\n#endif /* GL_APPLE_aux_depth_stencil */\n#ifdef GL_APPLE_client_storage\n  _glewInfo_GL_APPLE_client_storage();\n#endif /* GL_APPLE_client_storage */\n#ifdef GL_APPLE_element_array\n  _glewInfo_GL_APPLE_element_array();\n#endif /* GL_APPLE_element_array */\n#ifdef GL_APPLE_fence\n  _glewInfo_GL_APPLE_fence();\n#endif /* GL_APPLE_fence */\n#ifdef GL_APPLE_float_pixels\n  _glewInfo_GL_APPLE_float_pixels();\n#endif /* GL_APPLE_float_pixels */\n#ifdef GL_APPLE_flush_buffer_range\n  _glewInfo_GL_APPLE_flush_buffer_range();\n#endif /* GL_APPLE_flush_buffer_range */\n#ifdef GL_APPLE_object_purgeable\n  _glewInfo_GL_APPLE_object_purgeable();\n#endif /* GL_APPLE_object_purgeable */\n#ifdef GL_APPLE_pixel_buffer\n  _glewInfo_GL_APPLE_pixel_buffer();\n#endif /* GL_APPLE_pixel_buffer */\n#ifdef GL_APPLE_rgb_422\n  _glewInfo_GL_APPLE_rgb_422();\n#endif /* GL_APPLE_rgb_422 */\n#ifdef GL_APPLE_row_bytes\n  _glewInfo_GL_APPLE_row_bytes();\n#endif /* GL_APPLE_row_bytes */\n#ifdef GL_APPLE_specular_vector\n  _glewInfo_GL_APPLE_specular_vector();\n#endif /* GL_APPLE_specular_vector */\n#ifdef GL_APPLE_texture_range\n  _glewInfo_GL_APPLE_texture_range();\n#endif /* GL_APPLE_texture_range */\n#ifdef GL_APPLE_transform_hint\n  _glewInfo_GL_APPLE_transform_hint();\n#endif /* GL_APPLE_transform_hint */\n#ifdef GL_APPLE_vertex_array_object\n  _glewInfo_GL_APPLE_vertex_array_object();\n#endif /* GL_APPLE_vertex_array_object */\n#ifdef GL_APPLE_vertex_array_range\n  _glewInfo_GL_APPLE_vertex_array_range();\n#endif /* GL_APPLE_vertex_array_range */\n#ifdef GL_APPLE_vertex_program_evaluators\n  _glewInfo_GL_APPLE_vertex_program_evaluators();\n#endif /* GL_APPLE_vertex_program_evaluators */\n#ifdef GL_APPLE_ycbcr_422\n  _glewInfo_GL_APPLE_ycbcr_422();\n#endif /* GL_APPLE_ycbcr_422 */\n#ifdef GL_ARB_ES2_compatibility\n  _glewInfo_GL_ARB_ES2_compatibility();\n#endif /* GL_ARB_ES2_compatibility */\n#ifdef GL_ARB_ES3_compatibility\n  _glewInfo_GL_ARB_ES3_compatibility();\n#endif /* GL_ARB_ES3_compatibility */\n#ifdef GL_ARB_arrays_of_arrays\n  _glewInfo_GL_ARB_arrays_of_arrays();\n#endif /* GL_ARB_arrays_of_arrays */\n#ifdef GL_ARB_base_instance\n  _glewInfo_GL_ARB_base_instance();\n#endif /* GL_ARB_base_instance */\n#ifdef GL_ARB_blend_func_extended\n  _glewInfo_GL_ARB_blend_func_extended();\n#endif /* GL_ARB_blend_func_extended */\n#ifdef GL_ARB_cl_event\n  _glewInfo_GL_ARB_cl_event();\n#endif /* GL_ARB_cl_event */\n#ifdef GL_ARB_clear_buffer_object\n  _glewInfo_GL_ARB_clear_buffer_object();\n#endif /* GL_ARB_clear_buffer_object */\n#ifdef GL_ARB_color_buffer_float\n  _glewInfo_GL_ARB_color_buffer_float();\n#endif /* GL_ARB_color_buffer_float */\n#ifdef GL_ARB_compatibility\n  _glewInfo_GL_ARB_compatibility();\n#endif /* GL_ARB_compatibility */\n#ifdef GL_ARB_compressed_texture_pixel_storage\n  _glewInfo_GL_ARB_compressed_texture_pixel_storage();\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n#ifdef GL_ARB_compute_shader\n  _glewInfo_GL_ARB_compute_shader();\n#endif /* GL_ARB_compute_shader */\n#ifdef GL_ARB_conservative_depth\n  _glewInfo_GL_ARB_conservative_depth();\n#endif /* GL_ARB_conservative_depth */\n#ifdef GL_ARB_copy_buffer\n  _glewInfo_GL_ARB_copy_buffer();\n#endif /* GL_ARB_copy_buffer */\n#ifdef GL_ARB_copy_image\n  _glewInfo_GL_ARB_copy_image();\n#endif /* GL_ARB_copy_image */\n#ifdef GL_ARB_debug_output\n  _glewInfo_GL_ARB_debug_output();\n#endif /* GL_ARB_debug_output */\n#ifdef GL_ARB_depth_buffer_float\n  _glewInfo_GL_ARB_depth_buffer_float();\n#endif /* GL_ARB_depth_buffer_float */\n#ifdef GL_ARB_depth_clamp\n  _glewInfo_GL_ARB_depth_clamp();\n#endif /* GL_ARB_depth_clamp */\n#ifdef GL_ARB_depth_texture\n  _glewInfo_GL_ARB_depth_texture();\n#endif /* GL_ARB_depth_texture */\n#ifdef GL_ARB_draw_buffers\n  _glewInfo_GL_ARB_draw_buffers();\n#endif /* GL_ARB_draw_buffers */\n#ifdef GL_ARB_draw_buffers_blend\n  _glewInfo_GL_ARB_draw_buffers_blend();\n#endif /* GL_ARB_draw_buffers_blend */\n#ifdef GL_ARB_draw_elements_base_vertex\n  _glewInfo_GL_ARB_draw_elements_base_vertex();\n#endif /* GL_ARB_draw_elements_base_vertex */\n#ifdef GL_ARB_draw_indirect\n  _glewInfo_GL_ARB_draw_indirect();\n#endif /* GL_ARB_draw_indirect */\n#ifdef GL_ARB_draw_instanced\n  _glewInfo_GL_ARB_draw_instanced();\n#endif /* GL_ARB_draw_instanced */\n#ifdef GL_ARB_explicit_attrib_location\n  _glewInfo_GL_ARB_explicit_attrib_location();\n#endif /* GL_ARB_explicit_attrib_location */\n#ifdef GL_ARB_explicit_uniform_location\n  _glewInfo_GL_ARB_explicit_uniform_location();\n#endif /* GL_ARB_explicit_uniform_location */\n#ifdef GL_ARB_fragment_coord_conventions\n  _glewInfo_GL_ARB_fragment_coord_conventions();\n#endif /* GL_ARB_fragment_coord_conventions */\n#ifdef GL_ARB_fragment_layer_viewport\n  _glewInfo_GL_ARB_fragment_layer_viewport();\n#endif /* GL_ARB_fragment_layer_viewport */\n#ifdef GL_ARB_fragment_program\n  _glewInfo_GL_ARB_fragment_program();\n#endif /* GL_ARB_fragment_program */\n#ifdef GL_ARB_fragment_program_shadow\n  _glewInfo_GL_ARB_fragment_program_shadow();\n#endif /* GL_ARB_fragment_program_shadow */\n#ifdef GL_ARB_fragment_shader\n  _glewInfo_GL_ARB_fragment_shader();\n#endif /* GL_ARB_fragment_shader */\n#ifdef GL_ARB_framebuffer_no_attachments\n  _glewInfo_GL_ARB_framebuffer_no_attachments();\n#endif /* GL_ARB_framebuffer_no_attachments */\n#ifdef GL_ARB_framebuffer_object\n  _glewInfo_GL_ARB_framebuffer_object();\n#endif /* GL_ARB_framebuffer_object */\n#ifdef GL_ARB_framebuffer_sRGB\n  _glewInfo_GL_ARB_framebuffer_sRGB();\n#endif /* GL_ARB_framebuffer_sRGB */\n#ifdef GL_ARB_geometry_shader4\n  _glewInfo_GL_ARB_geometry_shader4();\n#endif /* GL_ARB_geometry_shader4 */\n#ifdef GL_ARB_get_program_binary\n  _glewInfo_GL_ARB_get_program_binary();\n#endif /* GL_ARB_get_program_binary */\n#ifdef GL_ARB_gpu_shader5\n  _glewInfo_GL_ARB_gpu_shader5();\n#endif /* GL_ARB_gpu_shader5 */\n#ifdef GL_ARB_gpu_shader_fp64\n  _glewInfo_GL_ARB_gpu_shader_fp64();\n#endif /* GL_ARB_gpu_shader_fp64 */\n#ifdef GL_ARB_half_float_pixel\n  _glewInfo_GL_ARB_half_float_pixel();\n#endif /* GL_ARB_half_float_pixel */\n#ifdef GL_ARB_half_float_vertex\n  _glewInfo_GL_ARB_half_float_vertex();\n#endif /* GL_ARB_half_float_vertex */\n#ifdef GL_ARB_imaging\n  _glewInfo_GL_ARB_imaging();\n#endif /* GL_ARB_imaging */\n#ifdef GL_ARB_instanced_arrays\n  _glewInfo_GL_ARB_instanced_arrays();\n#endif /* GL_ARB_instanced_arrays */\n#ifdef GL_ARB_internalformat_query\n  _glewInfo_GL_ARB_internalformat_query();\n#endif /* GL_ARB_internalformat_query */\n#ifdef GL_ARB_internalformat_query2\n  _glewInfo_GL_ARB_internalformat_query2();\n#endif /* GL_ARB_internalformat_query2 */\n#ifdef GL_ARB_invalidate_subdata\n  _glewInfo_GL_ARB_invalidate_subdata();\n#endif /* GL_ARB_invalidate_subdata */\n#ifdef GL_ARB_map_buffer_alignment\n  _glewInfo_GL_ARB_map_buffer_alignment();\n#endif /* GL_ARB_map_buffer_alignment */\n#ifdef GL_ARB_map_buffer_range\n  _glewInfo_GL_ARB_map_buffer_range();\n#endif /* GL_ARB_map_buffer_range */\n#ifdef GL_ARB_matrix_palette\n  _glewInfo_GL_ARB_matrix_palette();\n#endif /* GL_ARB_matrix_palette */\n#ifdef GL_ARB_multi_draw_indirect\n  _glewInfo_GL_ARB_multi_draw_indirect();\n#endif /* GL_ARB_multi_draw_indirect */\n#ifdef GL_ARB_multisample\n  _glewInfo_GL_ARB_multisample();\n#endif /* GL_ARB_multisample */\n#ifdef GL_ARB_multitexture\n  _glewInfo_GL_ARB_multitexture();\n#endif /* GL_ARB_multitexture */\n#ifdef GL_ARB_occlusion_query\n  _glewInfo_GL_ARB_occlusion_query();\n#endif /* GL_ARB_occlusion_query */\n#ifdef GL_ARB_occlusion_query2\n  _glewInfo_GL_ARB_occlusion_query2();\n#endif /* GL_ARB_occlusion_query2 */\n#ifdef GL_ARB_pixel_buffer_object\n  _glewInfo_GL_ARB_pixel_buffer_object();\n#endif /* GL_ARB_pixel_buffer_object */\n#ifdef GL_ARB_point_parameters\n  _glewInfo_GL_ARB_point_parameters();\n#endif /* GL_ARB_point_parameters */\n#ifdef GL_ARB_point_sprite\n  _glewInfo_GL_ARB_point_sprite();\n#endif /* GL_ARB_point_sprite */\n#ifdef GL_ARB_program_interface_query\n  _glewInfo_GL_ARB_program_interface_query();\n#endif /* GL_ARB_program_interface_query */\n#ifdef GL_ARB_provoking_vertex\n  _glewInfo_GL_ARB_provoking_vertex();\n#endif /* GL_ARB_provoking_vertex */\n#ifdef GL_ARB_robust_buffer_access_behavior\n  _glewInfo_GL_ARB_robust_buffer_access_behavior();\n#endif /* GL_ARB_robust_buffer_access_behavior */\n#ifdef GL_ARB_robustness\n  _glewInfo_GL_ARB_robustness();\n#endif /* GL_ARB_robustness */\n#ifdef GL_ARB_robustness_application_isolation\n  _glewInfo_GL_ARB_robustness_application_isolation();\n#endif /* GL_ARB_robustness_application_isolation */\n#ifdef GL_ARB_robustness_share_group_isolation\n  _glewInfo_GL_ARB_robustness_share_group_isolation();\n#endif /* GL_ARB_robustness_share_group_isolation */\n#ifdef GL_ARB_sample_shading\n  _glewInfo_GL_ARB_sample_shading();\n#endif /* GL_ARB_sample_shading */\n#ifdef GL_ARB_sampler_objects\n  _glewInfo_GL_ARB_sampler_objects();\n#endif /* GL_ARB_sampler_objects */\n#ifdef GL_ARB_seamless_cube_map\n  _glewInfo_GL_ARB_seamless_cube_map();\n#endif /* GL_ARB_seamless_cube_map */\n#ifdef GL_ARB_separate_shader_objects\n  _glewInfo_GL_ARB_separate_shader_objects();\n#endif /* GL_ARB_separate_shader_objects */\n#ifdef GL_ARB_shader_atomic_counters\n  _glewInfo_GL_ARB_shader_atomic_counters();\n#endif /* GL_ARB_shader_atomic_counters */\n#ifdef GL_ARB_shader_bit_encoding\n  _glewInfo_GL_ARB_shader_bit_encoding();\n#endif /* GL_ARB_shader_bit_encoding */\n#ifdef GL_ARB_shader_image_load_store\n  _glewInfo_GL_ARB_shader_image_load_store();\n#endif /* GL_ARB_shader_image_load_store */\n#ifdef GL_ARB_shader_image_size\n  _glewInfo_GL_ARB_shader_image_size();\n#endif /* GL_ARB_shader_image_size */\n#ifdef GL_ARB_shader_objects\n  _glewInfo_GL_ARB_shader_objects();\n#endif /* GL_ARB_shader_objects */\n#ifdef GL_ARB_shader_precision\n  _glewInfo_GL_ARB_shader_precision();\n#endif /* GL_ARB_shader_precision */\n#ifdef GL_ARB_shader_stencil_export\n  _glewInfo_GL_ARB_shader_stencil_export();\n#endif /* GL_ARB_shader_stencil_export */\n#ifdef GL_ARB_shader_storage_buffer_object\n  _glewInfo_GL_ARB_shader_storage_buffer_object();\n#endif /* GL_ARB_shader_storage_buffer_object */\n#ifdef GL_ARB_shader_subroutine\n  _glewInfo_GL_ARB_shader_subroutine();\n#endif /* GL_ARB_shader_subroutine */\n#ifdef GL_ARB_shader_texture_lod\n  _glewInfo_GL_ARB_shader_texture_lod();\n#endif /* GL_ARB_shader_texture_lod */\n#ifdef GL_ARB_shading_language_100\n  _glewInfo_GL_ARB_shading_language_100();\n#endif /* GL_ARB_shading_language_100 */\n#ifdef GL_ARB_shading_language_420pack\n  _glewInfo_GL_ARB_shading_language_420pack();\n#endif /* GL_ARB_shading_language_420pack */\n#ifdef GL_ARB_shading_language_include\n  _glewInfo_GL_ARB_shading_language_include();\n#endif /* GL_ARB_shading_language_include */\n#ifdef GL_ARB_shading_language_packing\n  _glewInfo_GL_ARB_shading_language_packing();\n#endif /* GL_ARB_shading_language_packing */\n#ifdef GL_ARB_shadow\n  _glewInfo_GL_ARB_shadow();\n#endif /* GL_ARB_shadow */\n#ifdef GL_ARB_shadow_ambient\n  _glewInfo_GL_ARB_shadow_ambient();\n#endif /* GL_ARB_shadow_ambient */\n#ifdef GL_ARB_stencil_texturing\n  _glewInfo_GL_ARB_stencil_texturing();\n#endif /* GL_ARB_stencil_texturing */\n#ifdef GL_ARB_sync\n  _glewInfo_GL_ARB_sync();\n#endif /* GL_ARB_sync */\n#ifdef GL_ARB_tessellation_shader\n  _glewInfo_GL_ARB_tessellation_shader();\n#endif /* GL_ARB_tessellation_shader */\n#ifdef GL_ARB_texture_border_clamp\n  _glewInfo_GL_ARB_texture_border_clamp();\n#endif /* GL_ARB_texture_border_clamp */\n#ifdef GL_ARB_texture_buffer_object\n  _glewInfo_GL_ARB_texture_buffer_object();\n#endif /* GL_ARB_texture_buffer_object */\n#ifdef GL_ARB_texture_buffer_object_rgb32\n  _glewInfo_GL_ARB_texture_buffer_object_rgb32();\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n#ifdef GL_ARB_texture_buffer_range\n  _glewInfo_GL_ARB_texture_buffer_range();\n#endif /* GL_ARB_texture_buffer_range */\n#ifdef GL_ARB_texture_compression\n  _glewInfo_GL_ARB_texture_compression();\n#endif /* GL_ARB_texture_compression */\n#ifdef GL_ARB_texture_compression_bptc\n  _glewInfo_GL_ARB_texture_compression_bptc();\n#endif /* GL_ARB_texture_compression_bptc */\n#ifdef GL_ARB_texture_compression_rgtc\n  _glewInfo_GL_ARB_texture_compression_rgtc();\n#endif /* GL_ARB_texture_compression_rgtc */\n#ifdef GL_ARB_texture_cube_map\n  _glewInfo_GL_ARB_texture_cube_map();\n#endif /* GL_ARB_texture_cube_map */\n#ifdef GL_ARB_texture_cube_map_array\n  _glewInfo_GL_ARB_texture_cube_map_array();\n#endif /* GL_ARB_texture_cube_map_array */\n#ifdef GL_ARB_texture_env_add\n  _glewInfo_GL_ARB_texture_env_add();\n#endif /* GL_ARB_texture_env_add */\n#ifdef GL_ARB_texture_env_combine\n  _glewInfo_GL_ARB_texture_env_combine();\n#endif /* GL_ARB_texture_env_combine */\n#ifdef GL_ARB_texture_env_crossbar\n  _glewInfo_GL_ARB_texture_env_crossbar();\n#endif /* GL_ARB_texture_env_crossbar */\n#ifdef GL_ARB_texture_env_dot3\n  _glewInfo_GL_ARB_texture_env_dot3();\n#endif /* GL_ARB_texture_env_dot3 */\n#ifdef GL_ARB_texture_float\n  _glewInfo_GL_ARB_texture_float();\n#endif /* GL_ARB_texture_float */\n#ifdef GL_ARB_texture_gather\n  _glewInfo_GL_ARB_texture_gather();\n#endif /* GL_ARB_texture_gather */\n#ifdef GL_ARB_texture_mirrored_repeat\n  _glewInfo_GL_ARB_texture_mirrored_repeat();\n#endif /* GL_ARB_texture_mirrored_repeat */\n#ifdef GL_ARB_texture_multisample\n  _glewInfo_GL_ARB_texture_multisample();\n#endif /* GL_ARB_texture_multisample */\n#ifdef GL_ARB_texture_non_power_of_two\n  _glewInfo_GL_ARB_texture_non_power_of_two();\n#endif /* GL_ARB_texture_non_power_of_two */\n#ifdef GL_ARB_texture_query_levels\n  _glewInfo_GL_ARB_texture_query_levels();\n#endif /* GL_ARB_texture_query_levels */\n#ifdef GL_ARB_texture_query_lod\n  _glewInfo_GL_ARB_texture_query_lod();\n#endif /* GL_ARB_texture_query_lod */\n#ifdef GL_ARB_texture_rectangle\n  _glewInfo_GL_ARB_texture_rectangle();\n#endif /* GL_ARB_texture_rectangle */\n#ifdef GL_ARB_texture_rg\n  _glewInfo_GL_ARB_texture_rg();\n#endif /* GL_ARB_texture_rg */\n#ifdef GL_ARB_texture_rgb10_a2ui\n  _glewInfo_GL_ARB_texture_rgb10_a2ui();\n#endif /* GL_ARB_texture_rgb10_a2ui */\n#ifdef GL_ARB_texture_storage\n  _glewInfo_GL_ARB_texture_storage();\n#endif /* GL_ARB_texture_storage */\n#ifdef GL_ARB_texture_storage_multisample\n  _glewInfo_GL_ARB_texture_storage_multisample();\n#endif /* GL_ARB_texture_storage_multisample */\n#ifdef GL_ARB_texture_swizzle\n  _glewInfo_GL_ARB_texture_swizzle();\n#endif /* GL_ARB_texture_swizzle */\n#ifdef GL_ARB_texture_view\n  _glewInfo_GL_ARB_texture_view();\n#endif /* GL_ARB_texture_view */\n#ifdef GL_ARB_timer_query\n  _glewInfo_GL_ARB_timer_query();\n#endif /* GL_ARB_timer_query */\n#ifdef GL_ARB_transform_feedback2\n  _glewInfo_GL_ARB_transform_feedback2();\n#endif /* GL_ARB_transform_feedback2 */\n#ifdef GL_ARB_transform_feedback3\n  _glewInfo_GL_ARB_transform_feedback3();\n#endif /* GL_ARB_transform_feedback3 */\n#ifdef GL_ARB_transform_feedback_instanced\n  _glewInfo_GL_ARB_transform_feedback_instanced();\n#endif /* GL_ARB_transform_feedback_instanced */\n#ifdef GL_ARB_transpose_matrix\n  _glewInfo_GL_ARB_transpose_matrix();\n#endif /* GL_ARB_transpose_matrix */\n#ifdef GL_ARB_uniform_buffer_object\n  _glewInfo_GL_ARB_uniform_buffer_object();\n#endif /* GL_ARB_uniform_buffer_object */\n#ifdef GL_ARB_vertex_array_bgra\n  _glewInfo_GL_ARB_vertex_array_bgra();\n#endif /* GL_ARB_vertex_array_bgra */\n#ifdef GL_ARB_vertex_array_object\n  _glewInfo_GL_ARB_vertex_array_object();\n#endif /* GL_ARB_vertex_array_object */\n#ifdef GL_ARB_vertex_attrib_64bit\n  _glewInfo_GL_ARB_vertex_attrib_64bit();\n#endif /* GL_ARB_vertex_attrib_64bit */\n#ifdef GL_ARB_vertex_attrib_binding\n  _glewInfo_GL_ARB_vertex_attrib_binding();\n#endif /* GL_ARB_vertex_attrib_binding */\n#ifdef GL_ARB_vertex_blend\n  _glewInfo_GL_ARB_vertex_blend();\n#endif /* GL_ARB_vertex_blend */\n#ifdef GL_ARB_vertex_buffer_object\n  _glewInfo_GL_ARB_vertex_buffer_object();\n#endif /* GL_ARB_vertex_buffer_object */\n#ifdef GL_ARB_vertex_program\n  _glewInfo_GL_ARB_vertex_program();\n#endif /* GL_ARB_vertex_program */\n#ifdef GL_ARB_vertex_shader\n  _glewInfo_GL_ARB_vertex_shader();\n#endif /* GL_ARB_vertex_shader */\n#ifdef GL_ARB_vertex_type_2_10_10_10_rev\n  _glewInfo_GL_ARB_vertex_type_2_10_10_10_rev();\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n#ifdef GL_ARB_viewport_array\n  _glewInfo_GL_ARB_viewport_array();\n#endif /* GL_ARB_viewport_array */\n#ifdef GL_ARB_window_pos\n  _glewInfo_GL_ARB_window_pos();\n#endif /* GL_ARB_window_pos */\n#ifdef GL_ATIX_point_sprites\n  _glewInfo_GL_ATIX_point_sprites();\n#endif /* GL_ATIX_point_sprites */\n#ifdef GL_ATIX_texture_env_combine3\n  _glewInfo_GL_ATIX_texture_env_combine3();\n#endif /* GL_ATIX_texture_env_combine3 */\n#ifdef GL_ATIX_texture_env_route\n  _glewInfo_GL_ATIX_texture_env_route();\n#endif /* GL_ATIX_texture_env_route */\n#ifdef GL_ATIX_vertex_shader_output_point_size\n  _glewInfo_GL_ATIX_vertex_shader_output_point_size();\n#endif /* GL_ATIX_vertex_shader_output_point_size */\n#ifdef GL_ATI_draw_buffers\n  _glewInfo_GL_ATI_draw_buffers();\n#endif /* GL_ATI_draw_buffers */\n#ifdef GL_ATI_element_array\n  _glewInfo_GL_ATI_element_array();\n#endif /* GL_ATI_element_array */\n#ifdef GL_ATI_envmap_bumpmap\n  _glewInfo_GL_ATI_envmap_bumpmap();\n#endif /* GL_ATI_envmap_bumpmap */\n#ifdef GL_ATI_fragment_shader\n  _glewInfo_GL_ATI_fragment_shader();\n#endif /* GL_ATI_fragment_shader */\n#ifdef GL_ATI_map_object_buffer\n  _glewInfo_GL_ATI_map_object_buffer();\n#endif /* GL_ATI_map_object_buffer */\n#ifdef GL_ATI_meminfo\n  _glewInfo_GL_ATI_meminfo();\n#endif /* GL_ATI_meminfo */\n#ifdef GL_ATI_pn_triangles\n  _glewInfo_GL_ATI_pn_triangles();\n#endif /* GL_ATI_pn_triangles */\n#ifdef GL_ATI_separate_stencil\n  _glewInfo_GL_ATI_separate_stencil();\n#endif /* GL_ATI_separate_stencil */\n#ifdef GL_ATI_shader_texture_lod\n  _glewInfo_GL_ATI_shader_texture_lod();\n#endif /* GL_ATI_shader_texture_lod */\n#ifdef GL_ATI_text_fragment_shader\n  _glewInfo_GL_ATI_text_fragment_shader();\n#endif /* GL_ATI_text_fragment_shader */\n#ifdef GL_ATI_texture_compression_3dc\n  _glewInfo_GL_ATI_texture_compression_3dc();\n#endif /* GL_ATI_texture_compression_3dc */\n#ifdef GL_ATI_texture_env_combine3\n  _glewInfo_GL_ATI_texture_env_combine3();\n#endif /* GL_ATI_texture_env_combine3 */\n#ifdef GL_ATI_texture_float\n  _glewInfo_GL_ATI_texture_float();\n#endif /* GL_ATI_texture_float */\n#ifdef GL_ATI_texture_mirror_once\n  _glewInfo_GL_ATI_texture_mirror_once();\n#endif /* GL_ATI_texture_mirror_once */\n#ifdef GL_ATI_vertex_array_object\n  _glewInfo_GL_ATI_vertex_array_object();\n#endif /* GL_ATI_vertex_array_object */\n#ifdef GL_ATI_vertex_attrib_array_object\n  _glewInfo_GL_ATI_vertex_attrib_array_object();\n#endif /* GL_ATI_vertex_attrib_array_object */\n#ifdef GL_ATI_vertex_streams\n  _glewInfo_GL_ATI_vertex_streams();\n#endif /* GL_ATI_vertex_streams */\n#ifdef GL_EXT_422_pixels\n  _glewInfo_GL_EXT_422_pixels();\n#endif /* GL_EXT_422_pixels */\n#ifdef GL_EXT_Cg_shader\n  _glewInfo_GL_EXT_Cg_shader();\n#endif /* GL_EXT_Cg_shader */\n#ifdef GL_EXT_abgr\n  _glewInfo_GL_EXT_abgr();\n#endif /* GL_EXT_abgr */\n#ifdef GL_EXT_bgra\n  _glewInfo_GL_EXT_bgra();\n#endif /* GL_EXT_bgra */\n#ifdef GL_EXT_bindable_uniform\n  _glewInfo_GL_EXT_bindable_uniform();\n#endif /* GL_EXT_bindable_uniform */\n#ifdef GL_EXT_blend_color\n  _glewInfo_GL_EXT_blend_color();\n#endif /* GL_EXT_blend_color */\n#ifdef GL_EXT_blend_equation_separate\n  _glewInfo_GL_EXT_blend_equation_separate();\n#endif /* GL_EXT_blend_equation_separate */\n#ifdef GL_EXT_blend_func_separate\n  _glewInfo_GL_EXT_blend_func_separate();\n#endif /* GL_EXT_blend_func_separate */\n#ifdef GL_EXT_blend_logic_op\n  _glewInfo_GL_EXT_blend_logic_op();\n#endif /* GL_EXT_blend_logic_op */\n#ifdef GL_EXT_blend_minmax\n  _glewInfo_GL_EXT_blend_minmax();\n#endif /* GL_EXT_blend_minmax */\n#ifdef GL_EXT_blend_subtract\n  _glewInfo_GL_EXT_blend_subtract();\n#endif /* GL_EXT_blend_subtract */\n#ifdef GL_EXT_clip_volume_hint\n  _glewInfo_GL_EXT_clip_volume_hint();\n#endif /* GL_EXT_clip_volume_hint */\n#ifdef GL_EXT_cmyka\n  _glewInfo_GL_EXT_cmyka();\n#endif /* GL_EXT_cmyka */\n#ifdef GL_EXT_color_subtable\n  _glewInfo_GL_EXT_color_subtable();\n#endif /* GL_EXT_color_subtable */\n#ifdef GL_EXT_compiled_vertex_array\n  _glewInfo_GL_EXT_compiled_vertex_array();\n#endif /* GL_EXT_compiled_vertex_array */\n#ifdef GL_EXT_convolution\n  _glewInfo_GL_EXT_convolution();\n#endif /* GL_EXT_convolution */\n#ifdef GL_EXT_coordinate_frame\n  _glewInfo_GL_EXT_coordinate_frame();\n#endif /* GL_EXT_coordinate_frame */\n#ifdef GL_EXT_copy_texture\n  _glewInfo_GL_EXT_copy_texture();\n#endif /* GL_EXT_copy_texture */\n#ifdef GL_EXT_cull_vertex\n  _glewInfo_GL_EXT_cull_vertex();\n#endif /* GL_EXT_cull_vertex */\n#ifdef GL_EXT_debug_marker\n  _glewInfo_GL_EXT_debug_marker();\n#endif /* GL_EXT_debug_marker */\n#ifdef GL_EXT_depth_bounds_test\n  _glewInfo_GL_EXT_depth_bounds_test();\n#endif /* GL_EXT_depth_bounds_test */\n#ifdef GL_EXT_direct_state_access\n  _glewInfo_GL_EXT_direct_state_access();\n#endif /* GL_EXT_direct_state_access */\n#ifdef GL_EXT_draw_buffers2\n  _glewInfo_GL_EXT_draw_buffers2();\n#endif /* GL_EXT_draw_buffers2 */\n#ifdef GL_EXT_draw_instanced\n  _glewInfo_GL_EXT_draw_instanced();\n#endif /* GL_EXT_draw_instanced */\n#ifdef GL_EXT_draw_range_elements\n  _glewInfo_GL_EXT_draw_range_elements();\n#endif /* GL_EXT_draw_range_elements */\n#ifdef GL_EXT_fog_coord\n  _glewInfo_GL_EXT_fog_coord();\n#endif /* GL_EXT_fog_coord */\n#ifdef GL_EXT_fragment_lighting\n  _glewInfo_GL_EXT_fragment_lighting();\n#endif /* GL_EXT_fragment_lighting */\n#ifdef GL_EXT_framebuffer_blit\n  _glewInfo_GL_EXT_framebuffer_blit();\n#endif /* GL_EXT_framebuffer_blit */\n#ifdef GL_EXT_framebuffer_multisample\n  _glewInfo_GL_EXT_framebuffer_multisample();\n#endif /* GL_EXT_framebuffer_multisample */\n#ifdef GL_EXT_framebuffer_multisample_blit_scaled\n  _glewInfo_GL_EXT_framebuffer_multisample_blit_scaled();\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n#ifdef GL_EXT_framebuffer_object\n  _glewInfo_GL_EXT_framebuffer_object();\n#endif /* GL_EXT_framebuffer_object */\n#ifdef GL_EXT_framebuffer_sRGB\n  _glewInfo_GL_EXT_framebuffer_sRGB();\n#endif /* GL_EXT_framebuffer_sRGB */\n#ifdef GL_EXT_geometry_shader4\n  _glewInfo_GL_EXT_geometry_shader4();\n#endif /* GL_EXT_geometry_shader4 */\n#ifdef GL_EXT_gpu_program_parameters\n  _glewInfo_GL_EXT_gpu_program_parameters();\n#endif /* GL_EXT_gpu_program_parameters */\n#ifdef GL_EXT_gpu_shader4\n  _glewInfo_GL_EXT_gpu_shader4();\n#endif /* GL_EXT_gpu_shader4 */\n#ifdef GL_EXT_histogram\n  _glewInfo_GL_EXT_histogram();\n#endif /* GL_EXT_histogram */\n#ifdef GL_EXT_index_array_formats\n  _glewInfo_GL_EXT_index_array_formats();\n#endif /* GL_EXT_index_array_formats */\n#ifdef GL_EXT_index_func\n  _glewInfo_GL_EXT_index_func();\n#endif /* GL_EXT_index_func */\n#ifdef GL_EXT_index_material\n  _glewInfo_GL_EXT_index_material();\n#endif /* GL_EXT_index_material */\n#ifdef GL_EXT_index_texture\n  _glewInfo_GL_EXT_index_texture();\n#endif /* GL_EXT_index_texture */\n#ifdef GL_EXT_light_texture\n  _glewInfo_GL_EXT_light_texture();\n#endif /* GL_EXT_light_texture */\n#ifdef GL_EXT_misc_attribute\n  _glewInfo_GL_EXT_misc_attribute();\n#endif /* GL_EXT_misc_attribute */\n#ifdef GL_EXT_multi_draw_arrays\n  _glewInfo_GL_EXT_multi_draw_arrays();\n#endif /* GL_EXT_multi_draw_arrays */\n#ifdef GL_EXT_multisample\n  _glewInfo_GL_EXT_multisample();\n#endif /* GL_EXT_multisample */\n#ifdef GL_EXT_packed_depth_stencil\n  _glewInfo_GL_EXT_packed_depth_stencil();\n#endif /* GL_EXT_packed_depth_stencil */\n#ifdef GL_EXT_packed_float\n  _glewInfo_GL_EXT_packed_float();\n#endif /* GL_EXT_packed_float */\n#ifdef GL_EXT_packed_pixels\n  _glewInfo_GL_EXT_packed_pixels();\n#endif /* GL_EXT_packed_pixels */\n#ifdef GL_EXT_paletted_texture\n  _glewInfo_GL_EXT_paletted_texture();\n#endif /* GL_EXT_paletted_texture */\n#ifdef GL_EXT_pixel_buffer_object\n  _glewInfo_GL_EXT_pixel_buffer_object();\n#endif /* GL_EXT_pixel_buffer_object */\n#ifdef GL_EXT_pixel_transform\n  _glewInfo_GL_EXT_pixel_transform();\n#endif /* GL_EXT_pixel_transform */\n#ifdef GL_EXT_pixel_transform_color_table\n  _glewInfo_GL_EXT_pixel_transform_color_table();\n#endif /* GL_EXT_pixel_transform_color_table */\n#ifdef GL_EXT_point_parameters\n  _glewInfo_GL_EXT_point_parameters();\n#endif /* GL_EXT_point_parameters */\n#ifdef GL_EXT_polygon_offset\n  _glewInfo_GL_EXT_polygon_offset();\n#endif /* GL_EXT_polygon_offset */\n#ifdef GL_EXT_provoking_vertex\n  _glewInfo_GL_EXT_provoking_vertex();\n#endif /* GL_EXT_provoking_vertex */\n#ifdef GL_EXT_rescale_normal\n  _glewInfo_GL_EXT_rescale_normal();\n#endif /* GL_EXT_rescale_normal */\n#ifdef GL_EXT_scene_marker\n  _glewInfo_GL_EXT_scene_marker();\n#endif /* GL_EXT_scene_marker */\n#ifdef GL_EXT_secondary_color\n  _glewInfo_GL_EXT_secondary_color();\n#endif /* GL_EXT_secondary_color */\n#ifdef GL_EXT_separate_shader_objects\n  _glewInfo_GL_EXT_separate_shader_objects();\n#endif /* GL_EXT_separate_shader_objects */\n#ifdef GL_EXT_separate_specular_color\n  _glewInfo_GL_EXT_separate_specular_color();\n#endif /* GL_EXT_separate_specular_color */\n#ifdef GL_EXT_shader_image_load_store\n  _glewInfo_GL_EXT_shader_image_load_store();\n#endif /* GL_EXT_shader_image_load_store */\n#ifdef GL_EXT_shadow_funcs\n  _glewInfo_GL_EXT_shadow_funcs();\n#endif /* GL_EXT_shadow_funcs */\n#ifdef GL_EXT_shared_texture_palette\n  _glewInfo_GL_EXT_shared_texture_palette();\n#endif /* GL_EXT_shared_texture_palette */\n#ifdef GL_EXT_stencil_clear_tag\n  _glewInfo_GL_EXT_stencil_clear_tag();\n#endif /* GL_EXT_stencil_clear_tag */\n#ifdef GL_EXT_stencil_two_side\n  _glewInfo_GL_EXT_stencil_two_side();\n#endif /* GL_EXT_stencil_two_side */\n#ifdef GL_EXT_stencil_wrap\n  _glewInfo_GL_EXT_stencil_wrap();\n#endif /* GL_EXT_stencil_wrap */\n#ifdef GL_EXT_subtexture\n  _glewInfo_GL_EXT_subtexture();\n#endif /* GL_EXT_subtexture */\n#ifdef GL_EXT_texture\n  _glewInfo_GL_EXT_texture();\n#endif /* GL_EXT_texture */\n#ifdef GL_EXT_texture3D\n  _glewInfo_GL_EXT_texture3D();\n#endif /* GL_EXT_texture3D */\n#ifdef GL_EXT_texture_array\n  _glewInfo_GL_EXT_texture_array();\n#endif /* GL_EXT_texture_array */\n#ifdef GL_EXT_texture_buffer_object\n  _glewInfo_GL_EXT_texture_buffer_object();\n#endif /* GL_EXT_texture_buffer_object */\n#ifdef GL_EXT_texture_compression_dxt1\n  _glewInfo_GL_EXT_texture_compression_dxt1();\n#endif /* GL_EXT_texture_compression_dxt1 */\n#ifdef GL_EXT_texture_compression_latc\n  _glewInfo_GL_EXT_texture_compression_latc();\n#endif /* GL_EXT_texture_compression_latc */\n#ifdef GL_EXT_texture_compression_rgtc\n  _glewInfo_GL_EXT_texture_compression_rgtc();\n#endif /* GL_EXT_texture_compression_rgtc */\n#ifdef GL_EXT_texture_compression_s3tc\n  _glewInfo_GL_EXT_texture_compression_s3tc();\n#endif /* GL_EXT_texture_compression_s3tc */\n#ifdef GL_EXT_texture_cube_map\n  _glewInfo_GL_EXT_texture_cube_map();\n#endif /* GL_EXT_texture_cube_map */\n#ifdef GL_EXT_texture_edge_clamp\n  _glewInfo_GL_EXT_texture_edge_clamp();\n#endif /* GL_EXT_texture_edge_clamp */\n#ifdef GL_EXT_texture_env\n  _glewInfo_GL_EXT_texture_env();\n#endif /* GL_EXT_texture_env */\n#ifdef GL_EXT_texture_env_add\n  _glewInfo_GL_EXT_texture_env_add();\n#endif /* GL_EXT_texture_env_add */\n#ifdef GL_EXT_texture_env_combine\n  _glewInfo_GL_EXT_texture_env_combine();\n#endif /* GL_EXT_texture_env_combine */\n#ifdef GL_EXT_texture_env_dot3\n  _glewInfo_GL_EXT_texture_env_dot3();\n#endif /* GL_EXT_texture_env_dot3 */\n#ifdef GL_EXT_texture_filter_anisotropic\n  _glewInfo_GL_EXT_texture_filter_anisotropic();\n#endif /* GL_EXT_texture_filter_anisotropic */\n#ifdef GL_EXT_texture_integer\n  _glewInfo_GL_EXT_texture_integer();\n#endif /* GL_EXT_texture_integer */\n#ifdef GL_EXT_texture_lod_bias\n  _glewInfo_GL_EXT_texture_lod_bias();\n#endif /* GL_EXT_texture_lod_bias */\n#ifdef GL_EXT_texture_mirror_clamp\n  _glewInfo_GL_EXT_texture_mirror_clamp();\n#endif /* GL_EXT_texture_mirror_clamp */\n#ifdef GL_EXT_texture_object\n  _glewInfo_GL_EXT_texture_object();\n#endif /* GL_EXT_texture_object */\n#ifdef GL_EXT_texture_perturb_normal\n  _glewInfo_GL_EXT_texture_perturb_normal();\n#endif /* GL_EXT_texture_perturb_normal */\n#ifdef GL_EXT_texture_rectangle\n  _glewInfo_GL_EXT_texture_rectangle();\n#endif /* GL_EXT_texture_rectangle */\n#ifdef GL_EXT_texture_sRGB\n  _glewInfo_GL_EXT_texture_sRGB();\n#endif /* GL_EXT_texture_sRGB */\n#ifdef GL_EXT_texture_sRGB_decode\n  _glewInfo_GL_EXT_texture_sRGB_decode();\n#endif /* GL_EXT_texture_sRGB_decode */\n#ifdef GL_EXT_texture_shared_exponent\n  _glewInfo_GL_EXT_texture_shared_exponent();\n#endif /* GL_EXT_texture_shared_exponent */\n#ifdef GL_EXT_texture_snorm\n  _glewInfo_GL_EXT_texture_snorm();\n#endif /* GL_EXT_texture_snorm */\n#ifdef GL_EXT_texture_swizzle\n  _glewInfo_GL_EXT_texture_swizzle();\n#endif /* GL_EXT_texture_swizzle */\n#ifdef GL_EXT_timer_query\n  _glewInfo_GL_EXT_timer_query();\n#endif /* GL_EXT_timer_query */\n#ifdef GL_EXT_transform_feedback\n  _glewInfo_GL_EXT_transform_feedback();\n#endif /* GL_EXT_transform_feedback */\n#ifdef GL_EXT_vertex_array\n  _glewInfo_GL_EXT_vertex_array();\n#endif /* GL_EXT_vertex_array */\n#ifdef GL_EXT_vertex_array_bgra\n  _glewInfo_GL_EXT_vertex_array_bgra();\n#endif /* GL_EXT_vertex_array_bgra */\n#ifdef GL_EXT_vertex_attrib_64bit\n  _glewInfo_GL_EXT_vertex_attrib_64bit();\n#endif /* GL_EXT_vertex_attrib_64bit */\n#ifdef GL_EXT_vertex_shader\n  _glewInfo_GL_EXT_vertex_shader();\n#endif /* GL_EXT_vertex_shader */\n#ifdef GL_EXT_vertex_weighting\n  _glewInfo_GL_EXT_vertex_weighting();\n#endif /* GL_EXT_vertex_weighting */\n#ifdef GL_EXT_x11_sync_object\n  _glewInfo_GL_EXT_x11_sync_object();\n#endif /* GL_EXT_x11_sync_object */\n#ifdef GL_GREMEDY_frame_terminator\n  _glewInfo_GL_GREMEDY_frame_terminator();\n#endif /* GL_GREMEDY_frame_terminator */\n#ifdef GL_GREMEDY_string_marker\n  _glewInfo_GL_GREMEDY_string_marker();\n#endif /* GL_GREMEDY_string_marker */\n#ifdef GL_HP_convolution_border_modes\n  _glewInfo_GL_HP_convolution_border_modes();\n#endif /* GL_HP_convolution_border_modes */\n#ifdef GL_HP_image_transform\n  _glewInfo_GL_HP_image_transform();\n#endif /* GL_HP_image_transform */\n#ifdef GL_HP_occlusion_test\n  _glewInfo_GL_HP_occlusion_test();\n#endif /* GL_HP_occlusion_test */\n#ifdef GL_HP_texture_lighting\n  _glewInfo_GL_HP_texture_lighting();\n#endif /* GL_HP_texture_lighting */\n#ifdef GL_IBM_cull_vertex\n  _glewInfo_GL_IBM_cull_vertex();\n#endif /* GL_IBM_cull_vertex */\n#ifdef GL_IBM_multimode_draw_arrays\n  _glewInfo_GL_IBM_multimode_draw_arrays();\n#endif /* GL_IBM_multimode_draw_arrays */\n#ifdef GL_IBM_rasterpos_clip\n  _glewInfo_GL_IBM_rasterpos_clip();\n#endif /* GL_IBM_rasterpos_clip */\n#ifdef GL_IBM_static_data\n  _glewInfo_GL_IBM_static_data();\n#endif /* GL_IBM_static_data */\n#ifdef GL_IBM_texture_mirrored_repeat\n  _glewInfo_GL_IBM_texture_mirrored_repeat();\n#endif /* GL_IBM_texture_mirrored_repeat */\n#ifdef GL_IBM_vertex_array_lists\n  _glewInfo_GL_IBM_vertex_array_lists();\n#endif /* GL_IBM_vertex_array_lists */\n#ifdef GL_INGR_color_clamp\n  _glewInfo_GL_INGR_color_clamp();\n#endif /* GL_INGR_color_clamp */\n#ifdef GL_INGR_interlace_read\n  _glewInfo_GL_INGR_interlace_read();\n#endif /* GL_INGR_interlace_read */\n#ifdef GL_INTEL_parallel_arrays\n  _glewInfo_GL_INTEL_parallel_arrays();\n#endif /* GL_INTEL_parallel_arrays */\n#ifdef GL_INTEL_texture_scissor\n  _glewInfo_GL_INTEL_texture_scissor();\n#endif /* GL_INTEL_texture_scissor */\n#ifdef GL_KHR_debug\n  _glewInfo_GL_KHR_debug();\n#endif /* GL_KHR_debug */\n#ifdef GL_KHR_texture_compression_astc_ldr\n  _glewInfo_GL_KHR_texture_compression_astc_ldr();\n#endif /* GL_KHR_texture_compression_astc_ldr */\n#ifdef GL_KTX_buffer_region\n  _glewInfo_GL_KTX_buffer_region();\n#endif /* GL_KTX_buffer_region */\n#ifdef GL_MESAX_texture_stack\n  _glewInfo_GL_MESAX_texture_stack();\n#endif /* GL_MESAX_texture_stack */\n#ifdef GL_MESA_pack_invert\n  _glewInfo_GL_MESA_pack_invert();\n#endif /* GL_MESA_pack_invert */\n#ifdef GL_MESA_resize_buffers\n  _glewInfo_GL_MESA_resize_buffers();\n#endif /* GL_MESA_resize_buffers */\n#ifdef GL_MESA_window_pos\n  _glewInfo_GL_MESA_window_pos();\n#endif /* GL_MESA_window_pos */\n#ifdef GL_MESA_ycbcr_texture\n  _glewInfo_GL_MESA_ycbcr_texture();\n#endif /* GL_MESA_ycbcr_texture */\n#ifdef GL_NVX_gpu_memory_info\n  _glewInfo_GL_NVX_gpu_memory_info();\n#endif /* GL_NVX_gpu_memory_info */\n#ifdef GL_NV_bindless_texture\n  _glewInfo_GL_NV_bindless_texture();\n#endif /* GL_NV_bindless_texture */\n#ifdef GL_NV_blend_square\n  _glewInfo_GL_NV_blend_square();\n#endif /* GL_NV_blend_square */\n#ifdef GL_NV_conditional_render\n  _glewInfo_GL_NV_conditional_render();\n#endif /* GL_NV_conditional_render */\n#ifdef GL_NV_copy_depth_to_color\n  _glewInfo_GL_NV_copy_depth_to_color();\n#endif /* GL_NV_copy_depth_to_color */\n#ifdef GL_NV_copy_image\n  _glewInfo_GL_NV_copy_image();\n#endif /* GL_NV_copy_image */\n#ifdef GL_NV_depth_buffer_float\n  _glewInfo_GL_NV_depth_buffer_float();\n#endif /* GL_NV_depth_buffer_float */\n#ifdef GL_NV_depth_clamp\n  _glewInfo_GL_NV_depth_clamp();\n#endif /* GL_NV_depth_clamp */\n#ifdef GL_NV_depth_range_unclamped\n  _glewInfo_GL_NV_depth_range_unclamped();\n#endif /* GL_NV_depth_range_unclamped */\n#ifdef GL_NV_evaluators\n  _glewInfo_GL_NV_evaluators();\n#endif /* GL_NV_evaluators */\n#ifdef GL_NV_explicit_multisample\n  _glewInfo_GL_NV_explicit_multisample();\n#endif /* GL_NV_explicit_multisample */\n#ifdef GL_NV_fence\n  _glewInfo_GL_NV_fence();\n#endif /* GL_NV_fence */\n#ifdef GL_NV_float_buffer\n  _glewInfo_GL_NV_float_buffer();\n#endif /* GL_NV_float_buffer */\n#ifdef GL_NV_fog_distance\n  _glewInfo_GL_NV_fog_distance();\n#endif /* GL_NV_fog_distance */\n#ifdef GL_NV_fragment_program\n  _glewInfo_GL_NV_fragment_program();\n#endif /* GL_NV_fragment_program */\n#ifdef GL_NV_fragment_program2\n  _glewInfo_GL_NV_fragment_program2();\n#endif /* GL_NV_fragment_program2 */\n#ifdef GL_NV_fragment_program4\n  _glewInfo_GL_NV_fragment_program4();\n#endif /* GL_NV_fragment_program4 */\n#ifdef GL_NV_fragment_program_option\n  _glewInfo_GL_NV_fragment_program_option();\n#endif /* GL_NV_fragment_program_option */\n#ifdef GL_NV_framebuffer_multisample_coverage\n  _glewInfo_GL_NV_framebuffer_multisample_coverage();\n#endif /* GL_NV_framebuffer_multisample_coverage */\n#ifdef GL_NV_geometry_program4\n  _glewInfo_GL_NV_geometry_program4();\n#endif /* GL_NV_geometry_program4 */\n#ifdef GL_NV_geometry_shader4\n  _glewInfo_GL_NV_geometry_shader4();\n#endif /* GL_NV_geometry_shader4 */\n#ifdef GL_NV_gpu_program4\n  _glewInfo_GL_NV_gpu_program4();\n#endif /* GL_NV_gpu_program4 */\n#ifdef GL_NV_gpu_program5\n  _glewInfo_GL_NV_gpu_program5();\n#endif /* GL_NV_gpu_program5 */\n#ifdef GL_NV_gpu_program_fp64\n  _glewInfo_GL_NV_gpu_program_fp64();\n#endif /* GL_NV_gpu_program_fp64 */\n#ifdef GL_NV_gpu_shader5\n  _glewInfo_GL_NV_gpu_shader5();\n#endif /* GL_NV_gpu_shader5 */\n#ifdef GL_NV_half_float\n  _glewInfo_GL_NV_half_float();\n#endif /* GL_NV_half_float */\n#ifdef GL_NV_light_max_exponent\n  _glewInfo_GL_NV_light_max_exponent();\n#endif /* GL_NV_light_max_exponent */\n#ifdef GL_NV_multisample_coverage\n  _glewInfo_GL_NV_multisample_coverage();\n#endif /* GL_NV_multisample_coverage */\n#ifdef GL_NV_multisample_filter_hint\n  _glewInfo_GL_NV_multisample_filter_hint();\n#endif /* GL_NV_multisample_filter_hint */\n#ifdef GL_NV_occlusion_query\n  _glewInfo_GL_NV_occlusion_query();\n#endif /* GL_NV_occlusion_query */\n#ifdef GL_NV_packed_depth_stencil\n  _glewInfo_GL_NV_packed_depth_stencil();\n#endif /* GL_NV_packed_depth_stencil */\n#ifdef GL_NV_parameter_buffer_object\n  _glewInfo_GL_NV_parameter_buffer_object();\n#endif /* GL_NV_parameter_buffer_object */\n#ifdef GL_NV_parameter_buffer_object2\n  _glewInfo_GL_NV_parameter_buffer_object2();\n#endif /* GL_NV_parameter_buffer_object2 */\n#ifdef GL_NV_path_rendering\n  _glewInfo_GL_NV_path_rendering();\n#endif /* GL_NV_path_rendering */\n#ifdef GL_NV_pixel_data_range\n  _glewInfo_GL_NV_pixel_data_range();\n#endif /* GL_NV_pixel_data_range */\n#ifdef GL_NV_point_sprite\n  _glewInfo_GL_NV_point_sprite();\n#endif /* GL_NV_point_sprite */\n#ifdef GL_NV_present_video\n  _glewInfo_GL_NV_present_video();\n#endif /* GL_NV_present_video */\n#ifdef GL_NV_primitive_restart\n  _glewInfo_GL_NV_primitive_restart();\n#endif /* GL_NV_primitive_restart */\n#ifdef GL_NV_register_combiners\n  _glewInfo_GL_NV_register_combiners();\n#endif /* GL_NV_register_combiners */\n#ifdef GL_NV_register_combiners2\n  _glewInfo_GL_NV_register_combiners2();\n#endif /* GL_NV_register_combiners2 */\n#ifdef GL_NV_shader_atomic_float\n  _glewInfo_GL_NV_shader_atomic_float();\n#endif /* GL_NV_shader_atomic_float */\n#ifdef GL_NV_shader_buffer_load\n  _glewInfo_GL_NV_shader_buffer_load();\n#endif /* GL_NV_shader_buffer_load */\n#ifdef GL_NV_tessellation_program5\n  _glewInfo_GL_NV_tessellation_program5();\n#endif /* GL_NV_tessellation_program5 */\n#ifdef GL_NV_texgen_emboss\n  _glewInfo_GL_NV_texgen_emboss();\n#endif /* GL_NV_texgen_emboss */\n#ifdef GL_NV_texgen_reflection\n  _glewInfo_GL_NV_texgen_reflection();\n#endif /* GL_NV_texgen_reflection */\n#ifdef GL_NV_texture_barrier\n  _glewInfo_GL_NV_texture_barrier();\n#endif /* GL_NV_texture_barrier */\n#ifdef GL_NV_texture_compression_vtc\n  _glewInfo_GL_NV_texture_compression_vtc();\n#endif /* GL_NV_texture_compression_vtc */\n#ifdef GL_NV_texture_env_combine4\n  _glewInfo_GL_NV_texture_env_combine4();\n#endif /* GL_NV_texture_env_combine4 */\n#ifdef GL_NV_texture_expand_normal\n  _glewInfo_GL_NV_texture_expand_normal();\n#endif /* GL_NV_texture_expand_normal */\n#ifdef GL_NV_texture_multisample\n  _glewInfo_GL_NV_texture_multisample();\n#endif /* GL_NV_texture_multisample */\n#ifdef GL_NV_texture_rectangle\n  _glewInfo_GL_NV_texture_rectangle();\n#endif /* GL_NV_texture_rectangle */\n#ifdef GL_NV_texture_shader\n  _glewInfo_GL_NV_texture_shader();\n#endif /* GL_NV_texture_shader */\n#ifdef GL_NV_texture_shader2\n  _glewInfo_GL_NV_texture_shader2();\n#endif /* GL_NV_texture_shader2 */\n#ifdef GL_NV_texture_shader3\n  _glewInfo_GL_NV_texture_shader3();\n#endif /* GL_NV_texture_shader3 */\n#ifdef GL_NV_transform_feedback\n  _glewInfo_GL_NV_transform_feedback();\n#endif /* GL_NV_transform_feedback */\n#ifdef GL_NV_transform_feedback2\n  _glewInfo_GL_NV_transform_feedback2();\n#endif /* GL_NV_transform_feedback2 */\n#ifdef GL_NV_vdpau_interop\n  _glewInfo_GL_NV_vdpau_interop();\n#endif /* GL_NV_vdpau_interop */\n#ifdef GL_NV_vertex_array_range\n  _glewInfo_GL_NV_vertex_array_range();\n#endif /* GL_NV_vertex_array_range */\n#ifdef GL_NV_vertex_array_range2\n  _glewInfo_GL_NV_vertex_array_range2();\n#endif /* GL_NV_vertex_array_range2 */\n#ifdef GL_NV_vertex_attrib_integer_64bit\n  _glewInfo_GL_NV_vertex_attrib_integer_64bit();\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n#ifdef GL_NV_vertex_buffer_unified_memory\n  _glewInfo_GL_NV_vertex_buffer_unified_memory();\n#endif /* GL_NV_vertex_buffer_unified_memory */\n#ifdef GL_NV_vertex_program\n  _glewInfo_GL_NV_vertex_program();\n#endif /* GL_NV_vertex_program */\n#ifdef GL_NV_vertex_program1_1\n  _glewInfo_GL_NV_vertex_program1_1();\n#endif /* GL_NV_vertex_program1_1 */\n#ifdef GL_NV_vertex_program2\n  _glewInfo_GL_NV_vertex_program2();\n#endif /* GL_NV_vertex_program2 */\n#ifdef GL_NV_vertex_program2_option\n  _glewInfo_GL_NV_vertex_program2_option();\n#endif /* GL_NV_vertex_program2_option */\n#ifdef GL_NV_vertex_program3\n  _glewInfo_GL_NV_vertex_program3();\n#endif /* GL_NV_vertex_program3 */\n#ifdef GL_NV_vertex_program4\n  _glewInfo_GL_NV_vertex_program4();\n#endif /* GL_NV_vertex_program4 */\n#ifdef GL_NV_video_capture\n  _glewInfo_GL_NV_video_capture();\n#endif /* GL_NV_video_capture */\n#ifdef GL_OES_byte_coordinates\n  _glewInfo_GL_OES_byte_coordinates();\n#endif /* GL_OES_byte_coordinates */\n#ifdef GL_OES_compressed_paletted_texture\n  _glewInfo_GL_OES_compressed_paletted_texture();\n#endif /* GL_OES_compressed_paletted_texture */\n#ifdef GL_OES_read_format\n  _glewInfo_GL_OES_read_format();\n#endif /* GL_OES_read_format */\n#ifdef GL_OES_single_precision\n  _glewInfo_GL_OES_single_precision();\n#endif /* GL_OES_single_precision */\n#ifdef GL_OML_interlace\n  _glewInfo_GL_OML_interlace();\n#endif /* GL_OML_interlace */\n#ifdef GL_OML_resample\n  _glewInfo_GL_OML_resample();\n#endif /* GL_OML_resample */\n#ifdef GL_OML_subsample\n  _glewInfo_GL_OML_subsample();\n#endif /* GL_OML_subsample */\n#ifdef GL_PGI_misc_hints\n  _glewInfo_GL_PGI_misc_hints();\n#endif /* GL_PGI_misc_hints */\n#ifdef GL_PGI_vertex_hints\n  _glewInfo_GL_PGI_vertex_hints();\n#endif /* GL_PGI_vertex_hints */\n#ifdef GL_REGAL_error_string\n  _glewInfo_GL_REGAL_error_string();\n#endif /* GL_REGAL_error_string */\n#ifdef GL_REGAL_extension_query\n  _glewInfo_GL_REGAL_extension_query();\n#endif /* GL_REGAL_extension_query */\n#ifdef GL_REGAL_log\n  _glewInfo_GL_REGAL_log();\n#endif /* GL_REGAL_log */\n#ifdef GL_REND_screen_coordinates\n  _glewInfo_GL_REND_screen_coordinates();\n#endif /* GL_REND_screen_coordinates */\n#ifdef GL_S3_s3tc\n  _glewInfo_GL_S3_s3tc();\n#endif /* GL_S3_s3tc */\n#ifdef GL_SGIS_color_range\n  _glewInfo_GL_SGIS_color_range();\n#endif /* GL_SGIS_color_range */\n#ifdef GL_SGIS_detail_texture\n  _glewInfo_GL_SGIS_detail_texture();\n#endif /* GL_SGIS_detail_texture */\n#ifdef GL_SGIS_fog_function\n  _glewInfo_GL_SGIS_fog_function();\n#endif /* GL_SGIS_fog_function */\n#ifdef GL_SGIS_generate_mipmap\n  _glewInfo_GL_SGIS_generate_mipmap();\n#endif /* GL_SGIS_generate_mipmap */\n#ifdef GL_SGIS_multisample\n  _glewInfo_GL_SGIS_multisample();\n#endif /* GL_SGIS_multisample */\n#ifdef GL_SGIS_pixel_texture\n  _glewInfo_GL_SGIS_pixel_texture();\n#endif /* GL_SGIS_pixel_texture */\n#ifdef GL_SGIS_point_line_texgen\n  _glewInfo_GL_SGIS_point_line_texgen();\n#endif /* GL_SGIS_point_line_texgen */\n#ifdef GL_SGIS_sharpen_texture\n  _glewInfo_GL_SGIS_sharpen_texture();\n#endif /* GL_SGIS_sharpen_texture */\n#ifdef GL_SGIS_texture4D\n  _glewInfo_GL_SGIS_texture4D();\n#endif /* GL_SGIS_texture4D */\n#ifdef GL_SGIS_texture_border_clamp\n  _glewInfo_GL_SGIS_texture_border_clamp();\n#endif /* GL_SGIS_texture_border_clamp */\n#ifdef GL_SGIS_texture_edge_clamp\n  _glewInfo_GL_SGIS_texture_edge_clamp();\n#endif /* GL_SGIS_texture_edge_clamp */\n#ifdef GL_SGIS_texture_filter4\n  _glewInfo_GL_SGIS_texture_filter4();\n#endif /* GL_SGIS_texture_filter4 */\n#ifdef GL_SGIS_texture_lod\n  _glewInfo_GL_SGIS_texture_lod();\n#endif /* GL_SGIS_texture_lod */\n#ifdef GL_SGIS_texture_select\n  _glewInfo_GL_SGIS_texture_select();\n#endif /* GL_SGIS_texture_select */\n#ifdef GL_SGIX_async\n  _glewInfo_GL_SGIX_async();\n#endif /* GL_SGIX_async */\n#ifdef GL_SGIX_async_histogram\n  _glewInfo_GL_SGIX_async_histogram();\n#endif /* GL_SGIX_async_histogram */\n#ifdef GL_SGIX_async_pixel\n  _glewInfo_GL_SGIX_async_pixel();\n#endif /* GL_SGIX_async_pixel */\n#ifdef GL_SGIX_blend_alpha_minmax\n  _glewInfo_GL_SGIX_blend_alpha_minmax();\n#endif /* GL_SGIX_blend_alpha_minmax */\n#ifdef GL_SGIX_clipmap\n  _glewInfo_GL_SGIX_clipmap();\n#endif /* GL_SGIX_clipmap */\n#ifdef GL_SGIX_convolution_accuracy\n  _glewInfo_GL_SGIX_convolution_accuracy();\n#endif /* GL_SGIX_convolution_accuracy */\n#ifdef GL_SGIX_depth_texture\n  _glewInfo_GL_SGIX_depth_texture();\n#endif /* GL_SGIX_depth_texture */\n#ifdef GL_SGIX_flush_raster\n  _glewInfo_GL_SGIX_flush_raster();\n#endif /* GL_SGIX_flush_raster */\n#ifdef GL_SGIX_fog_offset\n  _glewInfo_GL_SGIX_fog_offset();\n#endif /* GL_SGIX_fog_offset */\n#ifdef GL_SGIX_fog_texture\n  _glewInfo_GL_SGIX_fog_texture();\n#endif /* GL_SGIX_fog_texture */\n#ifdef GL_SGIX_fragment_specular_lighting\n  _glewInfo_GL_SGIX_fragment_specular_lighting();\n#endif /* GL_SGIX_fragment_specular_lighting */\n#ifdef GL_SGIX_framezoom\n  _glewInfo_GL_SGIX_framezoom();\n#endif /* GL_SGIX_framezoom */\n#ifdef GL_SGIX_interlace\n  _glewInfo_GL_SGIX_interlace();\n#endif /* GL_SGIX_interlace */\n#ifdef GL_SGIX_ir_instrument1\n  _glewInfo_GL_SGIX_ir_instrument1();\n#endif /* GL_SGIX_ir_instrument1 */\n#ifdef GL_SGIX_list_priority\n  _glewInfo_GL_SGIX_list_priority();\n#endif /* GL_SGIX_list_priority */\n#ifdef GL_SGIX_pixel_texture\n  _glewInfo_GL_SGIX_pixel_texture();\n#endif /* GL_SGIX_pixel_texture */\n#ifdef GL_SGIX_pixel_texture_bits\n  _glewInfo_GL_SGIX_pixel_texture_bits();\n#endif /* GL_SGIX_pixel_texture_bits */\n#ifdef GL_SGIX_reference_plane\n  _glewInfo_GL_SGIX_reference_plane();\n#endif /* GL_SGIX_reference_plane */\n#ifdef GL_SGIX_resample\n  _glewInfo_GL_SGIX_resample();\n#endif /* GL_SGIX_resample */\n#ifdef GL_SGIX_shadow\n  _glewInfo_GL_SGIX_shadow();\n#endif /* GL_SGIX_shadow */\n#ifdef GL_SGIX_shadow_ambient\n  _glewInfo_GL_SGIX_shadow_ambient();\n#endif /* GL_SGIX_shadow_ambient */\n#ifdef GL_SGIX_sprite\n  _glewInfo_GL_SGIX_sprite();\n#endif /* GL_SGIX_sprite */\n#ifdef GL_SGIX_tag_sample_buffer\n  _glewInfo_GL_SGIX_tag_sample_buffer();\n#endif /* GL_SGIX_tag_sample_buffer */\n#ifdef GL_SGIX_texture_add_env\n  _glewInfo_GL_SGIX_texture_add_env();\n#endif /* GL_SGIX_texture_add_env */\n#ifdef GL_SGIX_texture_coordinate_clamp\n  _glewInfo_GL_SGIX_texture_coordinate_clamp();\n#endif /* GL_SGIX_texture_coordinate_clamp */\n#ifdef GL_SGIX_texture_lod_bias\n  _glewInfo_GL_SGIX_texture_lod_bias();\n#endif /* GL_SGIX_texture_lod_bias */\n#ifdef GL_SGIX_texture_multi_buffer\n  _glewInfo_GL_SGIX_texture_multi_buffer();\n#endif /* GL_SGIX_texture_multi_buffer */\n#ifdef GL_SGIX_texture_range\n  _glewInfo_GL_SGIX_texture_range();\n#endif /* GL_SGIX_texture_range */\n#ifdef GL_SGIX_texture_scale_bias\n  _glewInfo_GL_SGIX_texture_scale_bias();\n#endif /* GL_SGIX_texture_scale_bias */\n#ifdef GL_SGIX_vertex_preclip\n  _glewInfo_GL_SGIX_vertex_preclip();\n#endif /* GL_SGIX_vertex_preclip */\n#ifdef GL_SGIX_vertex_preclip_hint\n  _glewInfo_GL_SGIX_vertex_preclip_hint();\n#endif /* GL_SGIX_vertex_preclip_hint */\n#ifdef GL_SGIX_ycrcb\n  _glewInfo_GL_SGIX_ycrcb();\n#endif /* GL_SGIX_ycrcb */\n#ifdef GL_SGI_color_matrix\n  _glewInfo_GL_SGI_color_matrix();\n#endif /* GL_SGI_color_matrix */\n#ifdef GL_SGI_color_table\n  _glewInfo_GL_SGI_color_table();\n#endif /* GL_SGI_color_table */\n#ifdef GL_SGI_texture_color_table\n  _glewInfo_GL_SGI_texture_color_table();\n#endif /* GL_SGI_texture_color_table */\n#ifdef GL_SUNX_constant_data\n  _glewInfo_GL_SUNX_constant_data();\n#endif /* GL_SUNX_constant_data */\n#ifdef GL_SUN_convolution_border_modes\n  _glewInfo_GL_SUN_convolution_border_modes();\n#endif /* GL_SUN_convolution_border_modes */\n#ifdef GL_SUN_global_alpha\n  _glewInfo_GL_SUN_global_alpha();\n#endif /* GL_SUN_global_alpha */\n#ifdef GL_SUN_mesh_array\n  _glewInfo_GL_SUN_mesh_array();\n#endif /* GL_SUN_mesh_array */\n#ifdef GL_SUN_read_video_pixels\n  _glewInfo_GL_SUN_read_video_pixels();\n#endif /* GL_SUN_read_video_pixels */\n#ifdef GL_SUN_slice_accum\n  _glewInfo_GL_SUN_slice_accum();\n#endif /* GL_SUN_slice_accum */\n#ifdef GL_SUN_triangle_list\n  _glewInfo_GL_SUN_triangle_list();\n#endif /* GL_SUN_triangle_list */\n#ifdef GL_SUN_vertex\n  _glewInfo_GL_SUN_vertex();\n#endif /* GL_SUN_vertex */\n#ifdef GL_WIN_phong_shading\n  _glewInfo_GL_WIN_phong_shading();\n#endif /* GL_WIN_phong_shading */\n#ifdef GL_WIN_specular_fog\n  _glewInfo_GL_WIN_specular_fog();\n#endif /* GL_WIN_specular_fog */\n#ifdef GL_WIN_swap_hint\n  _glewInfo_GL_WIN_swap_hint();\n#endif /* GL_WIN_swap_hint */\n}\n\n/* ------------------------------------------------------------------------ */\n\n#ifdef _WIN32\n\nstatic void wglewInfo ()\n{\n#ifdef WGL_3DFX_multisample\n  _glewInfo_WGL_3DFX_multisample();\n#endif /* WGL_3DFX_multisample */\n#ifdef WGL_3DL_stereo_control\n  _glewInfo_WGL_3DL_stereo_control();\n#endif /* WGL_3DL_stereo_control */\n#ifdef WGL_AMD_gpu_association\n  _glewInfo_WGL_AMD_gpu_association();\n#endif /* WGL_AMD_gpu_association */\n#ifdef WGL_ARB_buffer_region\n  _glewInfo_WGL_ARB_buffer_region();\n#endif /* WGL_ARB_buffer_region */\n#ifdef WGL_ARB_create_context\n  _glewInfo_WGL_ARB_create_context();\n#endif /* WGL_ARB_create_context */\n#ifdef WGL_ARB_create_context_profile\n  _glewInfo_WGL_ARB_create_context_profile();\n#endif /* WGL_ARB_create_context_profile */\n#ifdef WGL_ARB_create_context_robustness\n  _glewInfo_WGL_ARB_create_context_robustness();\n#endif /* WGL_ARB_create_context_robustness */\n#ifdef WGL_ARB_extensions_string\n  _glewInfo_WGL_ARB_extensions_string();\n#endif /* WGL_ARB_extensions_string */\n#ifdef WGL_ARB_framebuffer_sRGB\n  _glewInfo_WGL_ARB_framebuffer_sRGB();\n#endif /* WGL_ARB_framebuffer_sRGB */\n#ifdef WGL_ARB_make_current_read\n  _glewInfo_WGL_ARB_make_current_read();\n#endif /* WGL_ARB_make_current_read */\n#ifdef WGL_ARB_multisample\n  _glewInfo_WGL_ARB_multisample();\n#endif /* WGL_ARB_multisample */\n#ifdef WGL_ARB_pbuffer\n  _glewInfo_WGL_ARB_pbuffer();\n#endif /* WGL_ARB_pbuffer */\n#ifdef WGL_ARB_pixel_format\n  _glewInfo_WGL_ARB_pixel_format();\n#endif /* WGL_ARB_pixel_format */\n#ifdef WGL_ARB_pixel_format_float\n  _glewInfo_WGL_ARB_pixel_format_float();\n#endif /* WGL_ARB_pixel_format_float */\n#ifdef WGL_ARB_render_texture\n  _glewInfo_WGL_ARB_render_texture();\n#endif /* WGL_ARB_render_texture */\n#ifdef WGL_ATI_pixel_format_float\n  _glewInfo_WGL_ATI_pixel_format_float();\n#endif /* WGL_ATI_pixel_format_float */\n#ifdef WGL_ATI_render_texture_rectangle\n  _glewInfo_WGL_ATI_render_texture_rectangle();\n#endif /* WGL_ATI_render_texture_rectangle */\n#ifdef WGL_EXT_create_context_es2_profile\n  _glewInfo_WGL_EXT_create_context_es2_profile();\n#endif /* WGL_EXT_create_context_es2_profile */\n#ifdef WGL_EXT_create_context_es_profile\n  _glewInfo_WGL_EXT_create_context_es_profile();\n#endif /* WGL_EXT_create_context_es_profile */\n#ifdef WGL_EXT_depth_float\n  _glewInfo_WGL_EXT_depth_float();\n#endif /* WGL_EXT_depth_float */\n#ifdef WGL_EXT_display_color_table\n  _glewInfo_WGL_EXT_display_color_table();\n#endif /* WGL_EXT_display_color_table */\n#ifdef WGL_EXT_extensions_string\n  _glewInfo_WGL_EXT_extensions_string();\n#endif /* WGL_EXT_extensions_string */\n#ifdef WGL_EXT_framebuffer_sRGB\n  _glewInfo_WGL_EXT_framebuffer_sRGB();\n#endif /* WGL_EXT_framebuffer_sRGB */\n#ifdef WGL_EXT_make_current_read\n  _glewInfo_WGL_EXT_make_current_read();\n#endif /* WGL_EXT_make_current_read */\n#ifdef WGL_EXT_multisample\n  _glewInfo_WGL_EXT_multisample();\n#endif /* WGL_EXT_multisample */\n#ifdef WGL_EXT_pbuffer\n  _glewInfo_WGL_EXT_pbuffer();\n#endif /* WGL_EXT_pbuffer */\n#ifdef WGL_EXT_pixel_format\n  _glewInfo_WGL_EXT_pixel_format();\n#endif /* WGL_EXT_pixel_format */\n#ifdef WGL_EXT_pixel_format_packed_float\n  _glewInfo_WGL_EXT_pixel_format_packed_float();\n#endif /* WGL_EXT_pixel_format_packed_float */\n#ifdef WGL_EXT_swap_control\n  _glewInfo_WGL_EXT_swap_control();\n#endif /* WGL_EXT_swap_control */\n#ifdef WGL_EXT_swap_control_tear\n  _glewInfo_WGL_EXT_swap_control_tear();\n#endif /* WGL_EXT_swap_control_tear */\n#ifdef WGL_I3D_digital_video_control\n  _glewInfo_WGL_I3D_digital_video_control();\n#endif /* WGL_I3D_digital_video_control */\n#ifdef WGL_I3D_gamma\n  _glewInfo_WGL_I3D_gamma();\n#endif /* WGL_I3D_gamma */\n#ifdef WGL_I3D_genlock\n  _glewInfo_WGL_I3D_genlock();\n#endif /* WGL_I3D_genlock */\n#ifdef WGL_I3D_image_buffer\n  _glewInfo_WGL_I3D_image_buffer();\n#endif /* WGL_I3D_image_buffer */\n#ifdef WGL_I3D_swap_frame_lock\n  _glewInfo_WGL_I3D_swap_frame_lock();\n#endif /* WGL_I3D_swap_frame_lock */\n#ifdef WGL_I3D_swap_frame_usage\n  _glewInfo_WGL_I3D_swap_frame_usage();\n#endif /* WGL_I3D_swap_frame_usage */\n#ifdef WGL_NV_DX_interop\n  _glewInfo_WGL_NV_DX_interop();\n#endif /* WGL_NV_DX_interop */\n#ifdef WGL_NV_DX_interop2\n  _glewInfo_WGL_NV_DX_interop2();\n#endif /* WGL_NV_DX_interop2 */\n#ifdef WGL_NV_copy_image\n  _glewInfo_WGL_NV_copy_image();\n#endif /* WGL_NV_copy_image */\n#ifdef WGL_NV_float_buffer\n  _glewInfo_WGL_NV_float_buffer();\n#endif /* WGL_NV_float_buffer */\n#ifdef WGL_NV_gpu_affinity\n  _glewInfo_WGL_NV_gpu_affinity();\n#endif /* WGL_NV_gpu_affinity */\n#ifdef WGL_NV_multisample_coverage\n  _glewInfo_WGL_NV_multisample_coverage();\n#endif /* WGL_NV_multisample_coverage */\n#ifdef WGL_NV_present_video\n  _glewInfo_WGL_NV_present_video();\n#endif /* WGL_NV_present_video */\n#ifdef WGL_NV_render_depth_texture\n  _glewInfo_WGL_NV_render_depth_texture();\n#endif /* WGL_NV_render_depth_texture */\n#ifdef WGL_NV_render_texture_rectangle\n  _glewInfo_WGL_NV_render_texture_rectangle();\n#endif /* WGL_NV_render_texture_rectangle */\n#ifdef WGL_NV_swap_group\n  _glewInfo_WGL_NV_swap_group();\n#endif /* WGL_NV_swap_group */\n#ifdef WGL_NV_vertex_array_range\n  _glewInfo_WGL_NV_vertex_array_range();\n#endif /* WGL_NV_vertex_array_range */\n#ifdef WGL_NV_video_capture\n  _glewInfo_WGL_NV_video_capture();\n#endif /* WGL_NV_video_capture */\n#ifdef WGL_NV_video_output\n  _glewInfo_WGL_NV_video_output();\n#endif /* WGL_NV_video_output */\n#ifdef WGL_OML_sync_control\n  _glewInfo_WGL_OML_sync_control();\n#endif /* WGL_OML_sync_control */\n}\n\n#else /* _UNIX */\n\nstatic void glxewInfo ()\n{\n#ifdef GLX_VERSION_1_2\n  _glewInfo_GLX_VERSION_1_2();\n#endif /* GLX_VERSION_1_2 */\n#ifdef GLX_VERSION_1_3\n  _glewInfo_GLX_VERSION_1_3();\n#endif /* GLX_VERSION_1_3 */\n#ifdef GLX_VERSION_1_4\n  _glewInfo_GLX_VERSION_1_4();\n#endif /* GLX_VERSION_1_4 */\n#ifdef GLX_3DFX_multisample\n  _glewInfo_GLX_3DFX_multisample();\n#endif /* GLX_3DFX_multisample */\n#ifdef GLX_AMD_gpu_association\n  _glewInfo_GLX_AMD_gpu_association();\n#endif /* GLX_AMD_gpu_association */\n#ifdef GLX_ARB_create_context\n  _glewInfo_GLX_ARB_create_context();\n#endif /* GLX_ARB_create_context */\n#ifdef GLX_ARB_create_context_profile\n  _glewInfo_GLX_ARB_create_context_profile();\n#endif /* GLX_ARB_create_context_profile */\n#ifdef GLX_ARB_create_context_robustness\n  _glewInfo_GLX_ARB_create_context_robustness();\n#endif /* GLX_ARB_create_context_robustness */\n#ifdef GLX_ARB_fbconfig_float\n  _glewInfo_GLX_ARB_fbconfig_float();\n#endif /* GLX_ARB_fbconfig_float */\n#ifdef GLX_ARB_framebuffer_sRGB\n  _glewInfo_GLX_ARB_framebuffer_sRGB();\n#endif /* GLX_ARB_framebuffer_sRGB */\n#ifdef GLX_ARB_get_proc_address\n  _glewInfo_GLX_ARB_get_proc_address();\n#endif /* GLX_ARB_get_proc_address */\n#ifdef GLX_ARB_multisample\n  _glewInfo_GLX_ARB_multisample();\n#endif /* GLX_ARB_multisample */\n#ifdef GLX_ARB_robustness_application_isolation\n  _glewInfo_GLX_ARB_robustness_application_isolation();\n#endif /* GLX_ARB_robustness_application_isolation */\n#ifdef GLX_ARB_robustness_share_group_isolation\n  _glewInfo_GLX_ARB_robustness_share_group_isolation();\n#endif /* GLX_ARB_robustness_share_group_isolation */\n#ifdef GLX_ARB_vertex_buffer_object\n  _glewInfo_GLX_ARB_vertex_buffer_object();\n#endif /* GLX_ARB_vertex_buffer_object */\n#ifdef GLX_ATI_pixel_format_float\n  _glewInfo_GLX_ATI_pixel_format_float();\n#endif /* GLX_ATI_pixel_format_float */\n#ifdef GLX_ATI_render_texture\n  _glewInfo_GLX_ATI_render_texture();\n#endif /* GLX_ATI_render_texture */\n#ifdef GLX_EXT_create_context_es2_profile\n  _glewInfo_GLX_EXT_create_context_es2_profile();\n#endif /* GLX_EXT_create_context_es2_profile */\n#ifdef GLX_EXT_create_context_es_profile\n  _glewInfo_GLX_EXT_create_context_es_profile();\n#endif /* GLX_EXT_create_context_es_profile */\n#ifdef GLX_EXT_fbconfig_packed_float\n  _glewInfo_GLX_EXT_fbconfig_packed_float();\n#endif /* GLX_EXT_fbconfig_packed_float */\n#ifdef GLX_EXT_framebuffer_sRGB\n  _glewInfo_GLX_EXT_framebuffer_sRGB();\n#endif /* GLX_EXT_framebuffer_sRGB */\n#ifdef GLX_EXT_import_context\n  _glewInfo_GLX_EXT_import_context();\n#endif /* GLX_EXT_import_context */\n#ifdef GLX_EXT_scene_marker\n  _glewInfo_GLX_EXT_scene_marker();\n#endif /* GLX_EXT_scene_marker */\n#ifdef GLX_EXT_swap_control\n  _glewInfo_GLX_EXT_swap_control();\n#endif /* GLX_EXT_swap_control */\n#ifdef GLX_EXT_swap_control_tear\n  _glewInfo_GLX_EXT_swap_control_tear();\n#endif /* GLX_EXT_swap_control_tear */\n#ifdef GLX_EXT_texture_from_pixmap\n  _glewInfo_GLX_EXT_texture_from_pixmap();\n#endif /* GLX_EXT_texture_from_pixmap */\n#ifdef GLX_EXT_visual_info\n  _glewInfo_GLX_EXT_visual_info();\n#endif /* GLX_EXT_visual_info */\n#ifdef GLX_EXT_visual_rating\n  _glewInfo_GLX_EXT_visual_rating();\n#endif /* GLX_EXT_visual_rating */\n#ifdef GLX_INTEL_swap_event\n  _glewInfo_GLX_INTEL_swap_event();\n#endif /* GLX_INTEL_swap_event */\n#ifdef GLX_MESA_agp_offset\n  _glewInfo_GLX_MESA_agp_offset();\n#endif /* GLX_MESA_agp_offset */\n#ifdef GLX_MESA_copy_sub_buffer\n  _glewInfo_GLX_MESA_copy_sub_buffer();\n#endif /* GLX_MESA_copy_sub_buffer */\n#ifdef GLX_MESA_pixmap_colormap\n  _glewInfo_GLX_MESA_pixmap_colormap();\n#endif /* GLX_MESA_pixmap_colormap */\n#ifdef GLX_MESA_release_buffers\n  _glewInfo_GLX_MESA_release_buffers();\n#endif /* GLX_MESA_release_buffers */\n#ifdef GLX_MESA_set_3dfx_mode\n  _glewInfo_GLX_MESA_set_3dfx_mode();\n#endif /* GLX_MESA_set_3dfx_mode */\n#ifdef GLX_MESA_swap_control\n  _glewInfo_GLX_MESA_swap_control();\n#endif /* GLX_MESA_swap_control */\n#ifdef GLX_NV_copy_image\n  _glewInfo_GLX_NV_copy_image();\n#endif /* GLX_NV_copy_image */\n#ifdef GLX_NV_float_buffer\n  _glewInfo_GLX_NV_float_buffer();\n#endif /* GLX_NV_float_buffer */\n#ifdef GLX_NV_multisample_coverage\n  _glewInfo_GLX_NV_multisample_coverage();\n#endif /* GLX_NV_multisample_coverage */\n#ifdef GLX_NV_present_video\n  _glewInfo_GLX_NV_present_video();\n#endif /* GLX_NV_present_video */\n#ifdef GLX_NV_swap_group\n  _glewInfo_GLX_NV_swap_group();\n#endif /* GLX_NV_swap_group */\n#ifdef GLX_NV_vertex_array_range\n  _glewInfo_GLX_NV_vertex_array_range();\n#endif /* GLX_NV_vertex_array_range */\n#ifdef GLX_NV_video_capture\n  _glewInfo_GLX_NV_video_capture();\n#endif /* GLX_NV_video_capture */\n#ifdef GLX_NV_video_out\n  _glewInfo_GLX_NV_video_out();\n#endif /* GLX_NV_video_out */\n#ifdef GLX_OML_swap_method\n  _glewInfo_GLX_OML_swap_method();\n#endif /* GLX_OML_swap_method */\n#ifdef GLX_OML_sync_control\n  _glewInfo_GLX_OML_sync_control();\n#endif /* GLX_OML_sync_control */\n#ifdef GLX_SGIS_blended_overlay\n  _glewInfo_GLX_SGIS_blended_overlay();\n#endif /* GLX_SGIS_blended_overlay */\n#ifdef GLX_SGIS_color_range\n  _glewInfo_GLX_SGIS_color_range();\n#endif /* GLX_SGIS_color_range */\n#ifdef GLX_SGIS_multisample\n  _glewInfo_GLX_SGIS_multisample();\n#endif /* GLX_SGIS_multisample */\n#ifdef GLX_SGIS_shared_multisample\n  _glewInfo_GLX_SGIS_shared_multisample();\n#endif /* GLX_SGIS_shared_multisample */\n#ifdef GLX_SGIX_fbconfig\n  _glewInfo_GLX_SGIX_fbconfig();\n#endif /* GLX_SGIX_fbconfig */\n#ifdef GLX_SGIX_hyperpipe\n  _glewInfo_GLX_SGIX_hyperpipe();\n#endif /* GLX_SGIX_hyperpipe */\n#ifdef GLX_SGIX_pbuffer\n  _glewInfo_GLX_SGIX_pbuffer();\n#endif /* GLX_SGIX_pbuffer */\n#ifdef GLX_SGIX_swap_barrier\n  _glewInfo_GLX_SGIX_swap_barrier();\n#endif /* GLX_SGIX_swap_barrier */\n#ifdef GLX_SGIX_swap_group\n  _glewInfo_GLX_SGIX_swap_group();\n#endif /* GLX_SGIX_swap_group */\n#ifdef GLX_SGIX_video_resize\n  _glewInfo_GLX_SGIX_video_resize();\n#endif /* GLX_SGIX_video_resize */\n#ifdef GLX_SGIX_visual_select_group\n  _glewInfo_GLX_SGIX_visual_select_group();\n#endif /* GLX_SGIX_visual_select_group */\n#ifdef GLX_SGI_cushion\n  _glewInfo_GLX_SGI_cushion();\n#endif /* GLX_SGI_cushion */\n#ifdef GLX_SGI_make_current_read\n  _glewInfo_GLX_SGI_make_current_read();\n#endif /* GLX_SGI_make_current_read */\n#ifdef GLX_SGI_swap_control\n  _glewInfo_GLX_SGI_swap_control();\n#endif /* GLX_SGI_swap_control */\n#ifdef GLX_SGI_video_sync\n  _glewInfo_GLX_SGI_video_sync();\n#endif /* GLX_SGI_video_sync */\n#ifdef GLX_SUN_get_transparent_index\n  _glewInfo_GLX_SUN_get_transparent_index();\n#endif /* GLX_SUN_get_transparent_index */\n#ifdef GLX_SUN_video_resize\n  _glewInfo_GLX_SUN_video_resize();\n#endif /* GLX_SUN_video_resize */\n}\n\n#endif /* _WIN32 */\n\n/* ------------------------------------------------------------------------ */\n\n#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nint main (int argc, char** argv)\n#else\nint main (void)\n#endif\n{\n  GLuint err;\n\n#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n  char* display = NULL;\n  int visual = -1;\n\n  if (glewParseArgs(argc-1, argv+1, &display, &visual))\n  {\n#if defined(_WIN32)\n    fprintf(stderr, \"Usage: glewinfo [-pf <id>]\\n\");\n#else\n    fprintf(stderr, \"Usage: glewinfo [-display <display>] [-visual <id>]\\n\");\n#endif\n    return 1;\n  }\n#endif\n\n#if defined(_WIN32)\n  if (GL_TRUE == glewCreateContext(&visual))\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n  if (GL_TRUE == glewCreateContext())\n#else\n  if (GL_TRUE == glewCreateContext(display, &visual))\n#endif\n  {\n    fprintf(stderr, \"Error: glewCreateContext failed\\n\");\n    glewDestroyContext();\n    return 1;\n  }\n  glewExperimental = GL_TRUE;\n#ifdef GLEW_MX\n  err = glewContextInit(glewGetContext());\n#ifdef _WIN32\n  err = err || wglewContextInit(wglewGetContext());\n#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n  err = err || glxewContextInit(glxewGetContext());\n#endif\n\n#else\n  err = glewInit();\n#endif\n  if (GLEW_OK != err)\n  {\n    fprintf(stderr, \"Error [main]: glewInit failed: %s\\n\", glewGetErrorString(err));\n    glewDestroyContext();\n    return 1;\n  }\n#if defined(_WIN32)\n  f = fopen(\"glewinfo.txt\", \"w\");\n  if (f == NULL) f = stdout;\n#else\n  f = stdout;\n#endif\n  fprintf(f, \"---------------------------\\n\");\n  fprintf(f, \"    GLEW Extension Info\\n\");\n  fprintf(f, \"---------------------------\\n\\n\");\n  fprintf(f, \"GLEW version %s\\n\", glewGetString(GLEW_VERSION));\n#if defined(_WIN32)\n  fprintf(f, \"Reporting capabilities of pixelformat %d\\n\", visual);\n#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n  fprintf(f, \"Reporting capabilities of display %s, visual 0x%x\\n\", \n    display == NULL ? getenv(\"DISPLAY\") : display, visual);\n#endif\n  fprintf(f, \"Running on a %s from %s\\n\", \n\t  glGetString(GL_RENDERER), glGetString(GL_VENDOR));\n  fprintf(f, \"OpenGL version %s is supported\\n\", glGetString(GL_VERSION));\n  glewInfo();\n#if defined(_WIN32)\n  wglewInfo();\n#else\n  glxewInfo();\n#endif\n  if (f != stdout) fclose(f);\n  glewDestroyContext();\n  return 0;\n}\n\n/* ------------------------------------------------------------------------ */\n\n#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nGLboolean glewParseArgs (int argc, char** argv, char** display, int* visual)\n{\n  int p = 0;\n  while (p < argc)\n  {\n#if defined(_WIN32)\n    if (!strcmp(argv[p], \"-pf\") || !strcmp(argv[p], \"-pixelformat\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      *display = 0;\n      *visual = strtol(argv[p++], NULL, 0);\n    }\n    else\n      return GL_TRUE;\n#else\n    if (!strcmp(argv[p], \"-display\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      *display = argv[p++];\n    }\n    else if (!strcmp(argv[p], \"-visual\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      *visual = (int)strtol(argv[p++], NULL, 0);\n    }\n    else\n      return GL_TRUE;\n#endif\n  }\n  return GL_FALSE;\n}\n#endif\n\n/* ------------------------------------------------------------------------ */\n\n#if defined(_WIN32)\n\nHWND wnd = NULL;\nHDC dc = NULL;\nHGLRC rc = NULL;\n\nGLboolean glewCreateContext (int* pixelformat)\n{\n  WNDCLASS wc;\n  PIXELFORMATDESCRIPTOR pfd;\n  /* register window class */\n  ZeroMemory(&wc, sizeof(WNDCLASS));\n  wc.hInstance = GetModuleHandle(NULL);\n  wc.lpfnWndProc = DefWindowProc;\n  wc.lpszClassName = \"GLEW\";\n  if (0 == RegisterClass(&wc)) return GL_TRUE;\n  /* create window */\n  wnd = CreateWindow(\"GLEW\", \"GLEW\", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, \n                     CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);\n  if (NULL == wnd) return GL_TRUE;\n  /* get the device context */\n  dc = GetDC(wnd);\n  if (NULL == dc) return GL_TRUE;\n  /* find pixel format */\n  ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));\n  if (*pixelformat == -1) /* find default */\n  {\n    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);\n    pfd.nVersion = 1;\n    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;\n    *pixelformat = ChoosePixelFormat(dc, &pfd);\n    if (*pixelformat == 0) return GL_TRUE;\n  }\n  /* set the pixel format for the dc */\n  if (FALSE == SetPixelFormat(dc, *pixelformat, &pfd)) return GL_TRUE;\n  /* create rendering context */\n  rc = wglCreateContext(dc);\n  if (NULL == rc) return GL_TRUE;\n  if (FALSE == wglMakeCurrent(dc, rc)) return GL_TRUE;\n  return GL_FALSE;\n}\n\nvoid glewDestroyContext ()\n{\n  if (NULL != rc) wglMakeCurrent(NULL, NULL);\n  if (NULL != rc) wglDeleteContext(rc);\n  if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc);\n  if (NULL != wnd) DestroyWindow(wnd);\n  UnregisterClass(\"GLEW\", GetModuleHandle(NULL));\n}\n\n/* ------------------------------------------------------------------------ */\n\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n\n#include <AGL/agl.h>\n\nAGLContext ctx, octx;\n\nGLboolean glewCreateContext ()\n{\n  int attrib[] = { AGL_RGBA, AGL_NONE };\n  AGLPixelFormat pf;\n  /*int major, minor;\n  SetPortWindowPort(wnd);\n  aglGetVersion(&major, &minor);\n  fprintf(stderr, \"GL %d.%d\\n\", major, minor);*/\n  pf = aglChoosePixelFormat(NULL, 0, attrib);\n  if (NULL == pf) return GL_TRUE;\n  ctx = aglCreateContext(pf, NULL);\n  if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE;\n  aglDestroyPixelFormat(pf);\n  /*aglSetDrawable(ctx, GetWindowPort(wnd));*/\n  octx = aglGetCurrentContext();\n  if (GL_FALSE == aglSetCurrentContext(ctx)) return GL_TRUE;\n  /* Needed for Regal on the Mac */\n  #if defined(GLEW_REGAL) && defined(__APPLE__)\n  RegalMakeCurrent(octx);\n  #endif\n  return GL_FALSE;\n}\n\nvoid glewDestroyContext ()\n{\n  aglSetCurrentContext(octx);\n  if (NULL != ctx) aglDestroyContext(ctx);\n}\n\n/* ------------------------------------------------------------------------ */\n\n#else /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */\n\nDisplay* dpy = NULL;\nXVisualInfo* vi = NULL;\nXVisualInfo* vis = NULL;\nGLXContext ctx = NULL;\nWindow wnd = 0;\nColormap cmap = 0;\n\nGLboolean glewCreateContext (const char* display, int* visual)\n{\n  int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };\n  int erb, evb;\n  XSetWindowAttributes swa;\n  /* open display */\n  dpy = XOpenDisplay(display);\n  if (NULL == dpy) return GL_TRUE;\n  /* query for glx */\n  if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE;\n  /* choose visual */\n  if (*visual == -1)\n  {\n    vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib);\n    if (NULL == vi) return GL_TRUE;\n    *visual = (int)XVisualIDFromVisual(vi->visual);\n  }\n  else\n  {\n    int n_vis, i;\n    vis = XGetVisualInfo(dpy, 0, NULL, &n_vis);\n    for (i=0; i<n_vis; i++)\n    {\n      if ((int)XVisualIDFromVisual(vis[i].visual) == *visual)\n        vi = &vis[i];\n    }\n    if (vi == NULL) return GL_TRUE;\n  }\n  /* create context */\n  ctx = glXCreateContext(dpy, vi, None, True);\n  if (NULL == ctx) return GL_TRUE;\n  /* create window */\n  /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/\n  cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone);\n  swa.border_pixel = 0;\n  swa.colormap = cmap;\n  wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), \n                      0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual, \n                      CWBorderPixel | CWColormap, &swa);\n  /* make context current */\n  if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE;\n  return GL_FALSE;\n}\n\nvoid glewDestroyContext ()\n{\n  if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx);\n  if (NULL != dpy && 0 != wnd) XDestroyWindow(dpy, wnd);\n  if (NULL != dpy && 0 != cmap) XFreeColormap(dpy, cmap);\n  if (NULL != vis)\n    XFree(vis);\n  else if (NULL != vi)\n    XFree(vi);\n  if (NULL != dpy) XCloseDisplay(dpy);\n}\n\n#endif /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */\n"
  },
  {
    "path": "deps/glew/src/visualinfo.c",
    "content": "/*\n** visualinfo.c\n**\n** Copyright (C) Nate Robins, 1997\n**               Michael Wimmer, 1999\n**               Milan Ikits, 2002-2008\n**\n** visualinfo is a small utility that displays all available visuals,\n** aka. pixelformats, in an OpenGL system along with renderer version\n** information. It shows a table of all the visuals that support OpenGL\n** along with their capabilities. The format of the table is similar to\n** that of glxinfo on Unix systems:\n**\n** visual ~= pixel format descriptor\n** id       = visual id (integer from 1 - max visuals)\n** tp       = type (wn: window, pb: pbuffer, wp: window & pbuffer, bm: bitmap)\n** ac\t    = acceleration (ge: generic, fu: full, no: none)\n** fm\t    = format (i: integer, f: float, c: color index)\n** db\t    = double buffer (y = yes)\n** sw       = swap method (x: exchange, c: copy, u: undefined)\n** st\t    = stereo (y = yes)\n** sz       = total # bits\n** r        = # bits of red\n** g        = # bits of green\n** b        = # bits of blue\n** a        = # bits of alpha\n** axbf     = # aux buffers\n** dpth     = # bits of depth\n** stcl     = # bits of stencil\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <GL/glew.h>\n#if defined(_WIN32)\n#include <GL/wglew.h>\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n#include <AGL/agl.h>\n#else\n#include <GL/glxew.h>\n#endif\n\n#ifdef GLEW_MX\nGLEWContext _glewctx;\n#  define glewGetContext() (&_glewctx)\n#  ifdef _WIN32\nWGLEWContext _wglewctx;\n#    define wglewGetContext() (&_wglewctx)\n#  elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\nGLXEWContext _glxewctx;\n#    define glxewGetContext() (&_glxewctx)\n#  endif\n#endif /* GLEW_MX */\n\ntypedef struct GLContextStruct\n{\n#ifdef _WIN32\n  HWND wnd;\n  HDC dc;\n  HGLRC rc;\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n  AGLContext ctx, octx;\n#else\n  Display* dpy;\n  XVisualInfo* vi;\n  GLXContext ctx;\n  Window wnd;\n  Colormap cmap;\n#endif\n} GLContext;\n\nvoid InitContext (GLContext* ctx);\nGLboolean CreateContext (GLContext* ctx);\nvoid DestroyContext (GLContext* ctx);\nvoid VisualInfo (GLContext* ctx);\nvoid PrintExtensions (const char* s);\nGLboolean ParseArgs (int argc, char** argv);\n\nint showall = 0;\nint displaystdout = 0;\nint verbose = 0;\nint drawableonly = 0;\n\nchar* display = NULL;\nint visual = -1;\n\nFILE* file = 0;\n\nint \nmain (int argc, char** argv)\n{\n  GLenum err;\n  GLContext ctx;\n\n  /* ---------------------------------------------------------------------- */\n  /* parse arguments */\n  if (GL_TRUE == ParseArgs(argc-1, argv+1))\n  {\n#if defined(_WIN32)\n    fprintf(stderr, \"Usage: visualinfo [-a] [-s] [-h] [-pf <id>]\\n\");\n    fprintf(stderr, \"        -a: show all visuals\\n\");\n    fprintf(stderr, \"        -s: display to stdout instead of visualinfo.txt\\n\");\n    fprintf(stderr, \"        -pf <id>: use given pixelformat\\n\");\n    fprintf(stderr, \"        -h: this screen\\n\");\n#else\n    fprintf(stderr, \"Usage: visualinfo [-h] [-display <display>] [-visual <id>]\\n\");\n    fprintf(stderr, \"        -h: this screen\\n\");\n    fprintf(stderr, \"        -display <display>: use given display\\n\");\n    fprintf(stderr, \"        -visual <id>: use given visual\\n\");\n#endif\n    return 1;\n  }\n\n  /* ---------------------------------------------------------------------- */\n  /* create OpenGL rendering context */\n  InitContext(&ctx);\n  if (GL_TRUE == CreateContext(&ctx))\n  {\n    fprintf(stderr, \"Error: CreateContext failed\\n\");\n    DestroyContext(&ctx);\n    return 1;\n  }\n\n  /* ---------------------------------------------------------------------- */\n  /* initialize GLEW */\n  glewExperimental = GL_TRUE;\n#ifdef GLEW_MX\n  err = glewContextInit(glewGetContext());\n#  ifdef _WIN32\n  err = err || wglewContextInit(wglewGetContext());\n#  elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)\n  err = err || glxewContextInit(glxewGetContext());\n#  endif\n#else\n  err = glewInit();\n#endif\n  if (GLEW_OK != err)\n  {\n    fprintf(stderr, \"Error [main]: glewInit failed: %s\\n\", glewGetErrorString(err));\n    DestroyContext(&ctx);\n    return 1;\n  }\n\n  /* ---------------------------------------------------------------------- */\n  /* open file */\n#if defined(_WIN32)\n  if (!displaystdout) \n    file = fopen(\"visualinfo.txt\", \"w\");\n  if (file == NULL)\n    file = stdout;\n#else\n  file = stdout;\n#endif\n\n  /* ---------------------------------------------------------------------- */\n  /* output header information */\n  /* OpenGL extensions */\n  fprintf(file, \"OpenGL vendor string: %s\\n\", glGetString(GL_VENDOR));\n  fprintf(file, \"OpenGL renderer string: %s\\n\", glGetString(GL_RENDERER));\n  fprintf(file, \"OpenGL version string: %s\\n\", glGetString(GL_VERSION));\n  fprintf(file, \"OpenGL extensions (GL_): \\n\");\n  PrintExtensions((char*)glGetString(GL_EXTENSIONS));\n\n#ifndef GLEW_NO_GLU\n  /* GLU extensions */\n  fprintf(file, \"GLU version string: %s\\n\", gluGetString(GLU_VERSION));\n  fprintf(file, \"GLU extensions (GLU_): \\n\");\n  PrintExtensions((char*)gluGetString(GLU_EXTENSIONS));\n#endif\n\n  /* ---------------------------------------------------------------------- */\n  /* extensions string */\n#if defined(_WIN32)\n  /* WGL extensions */\n  if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string)\n  {\n    fprintf(file, \"WGL extensions (WGL_): \\n\");\n    PrintExtensions(wglGetExtensionsStringARB ? \n                    (char*)wglGetExtensionsStringARB(ctx.dc) :\n\t\t    (char*)wglGetExtensionsStringEXT());\n  }\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n  \n#else\n  /* GLX extensions */\n  fprintf(file, \"GLX extensions (GLX_): \\n\");\n  PrintExtensions(glXQueryExtensionsString(glXGetCurrentDisplay(), \n                                           DefaultScreen(glXGetCurrentDisplay())));\n#endif\n\n  /* ---------------------------------------------------------------------- */\n  /* enumerate all the formats */\n  VisualInfo(&ctx);\n\n  /* ---------------------------------------------------------------------- */\n  /* release resources */\n  DestroyContext(&ctx);\n  if (file != stdout)\n    fclose(file);\n  return 0;\n}\n\n/* do the magic to separate all extensions with comma's, except\n   for the last one that _may_ terminate in a space. */\nvoid PrintExtensions (const char* s)\n{\n  char t[80];\n  int i=0;\n  char* p=0;\n\n  t[79] = '\\0';\n  while (*s)\n  {\n    t[i++] = *s;\n    if(*s == ' ')\n    {\n      if (*(s+1) != '\\0') {\n\tt[i-1] = ',';\n\tt[i] = ' ';\n\tp = &t[i++];\n      }\n      else /* zoinks! last one terminated in a space! */\n      {\n\tt[i-1] = '\\0';\n      }\n    }\n    if(i > 80 - 5)\n    {\n      *p = t[i] = '\\0';\n      fprintf(file, \"    %s\\n\", t);\n      p++;\n      i = (int)strlen(p);\n      strcpy(t, p);\n    }\n    s++;\n  }\n  t[i] = '\\0';\n  fprintf(file, \"    %s.\\n\", t);\n}\n\n/* ---------------------------------------------------------------------- */\n\n#if defined(_WIN32)\n\nvoid\nVisualInfoARB (GLContext* ctx)\n{\n  int attrib[32], value[32], n_attrib, n_pbuffer=0, n_float=0;\n  int i, pf, maxpf;\n  unsigned int c;\n\n  /* to get pbuffer capable pixel formats */\n  attrib[0] = WGL_DRAW_TO_PBUFFER_ARB;\n  attrib[1] = GL_TRUE;\n  attrib[2] = 0;\n  wglChoosePixelFormatARB(ctx->dc, attrib, 0, 1, &pf, &c);\n  /* query number of pixel formats */\n  attrib[0] = WGL_NUMBER_PIXEL_FORMATS_ARB;\n  wglGetPixelFormatAttribivARB(ctx->dc, 0, 0, 1, attrib, value);\n  maxpf = value[0];\n  for (i=0; i<32; i++)\n    value[i] = 0;\n\n  attrib[0] = WGL_SUPPORT_OPENGL_ARB;\n  attrib[1] = WGL_DRAW_TO_WINDOW_ARB;\n  attrib[2] = WGL_DRAW_TO_BITMAP_ARB;\n  attrib[3] = WGL_ACCELERATION_ARB;\n  /* WGL_NO_ACCELERATION_ARB, WGL_GENERIC_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB */\n  attrib[4] = WGL_SWAP_METHOD_ARB;\n  /* WGL_SWAP_EXCHANGE_ARB, WGL_SWAP_COPY_ARB, WGL_SWAP_UNDEFINED_ARB */\n  attrib[5] = WGL_DOUBLE_BUFFER_ARB;\n  attrib[6] = WGL_STEREO_ARB;\n  attrib[7] = WGL_PIXEL_TYPE_ARB;\n  /* WGL_TYPE_RGBA_ARB, WGL_TYPE_COLORINDEX_ARB,\n     WGL_TYPE_RGBA_FLOAT_ATI (WGL_ATI_pixel_format_float) */\n  /* Color buffer information */\n  attrib[8] = WGL_COLOR_BITS_ARB;\n  attrib[9] = WGL_RED_BITS_ARB;\n  attrib[10] = WGL_GREEN_BITS_ARB;\n  attrib[11] = WGL_BLUE_BITS_ARB;\n  attrib[12] = WGL_ALPHA_BITS_ARB;\n  /* Accumulation buffer information */\n  attrib[13] = WGL_ACCUM_BITS_ARB;\n  attrib[14] = WGL_ACCUM_RED_BITS_ARB;\n  attrib[15] = WGL_ACCUM_GREEN_BITS_ARB;\n  attrib[16] = WGL_ACCUM_BLUE_BITS_ARB;\n  attrib[17] = WGL_ACCUM_ALPHA_BITS_ARB;\n  /* Depth, stencil, and aux buffer information */\n  attrib[18] = WGL_DEPTH_BITS_ARB;\n  attrib[19] = WGL_STENCIL_BITS_ARB;\n  attrib[20] = WGL_AUX_BUFFERS_ARB;\n  /* Layer information */\n  attrib[21] = WGL_NUMBER_OVERLAYS_ARB;\n  attrib[22] = WGL_NUMBER_UNDERLAYS_ARB;\n  attrib[23] = WGL_SWAP_LAYER_BUFFERS_ARB;\n  attrib[24] = WGL_SAMPLES_ARB;\n  attrib[25] = WGL_SUPPORT_GDI_ARB;\n  n_attrib = 26;\n  if (WGLEW_ARB_pbuffer)\n  {\n    attrib[n_attrib] = WGL_DRAW_TO_PBUFFER_ARB;\n    n_pbuffer = n_attrib;\n    n_attrib++;\n  }\n  if (WGLEW_NV_float_buffer)\n  {\n    attrib[n_attrib] = WGL_FLOAT_COMPONENTS_NV;\n    n_float = n_attrib;\n    n_attrib++;\n  }\n  \n  if (!verbose)\n  {\n    /* print table header */\n    fprintf(file, \" +-----+-------------------------+-----------------+----------+-----------------+----------+\\n\");\n    fprintf(file, \" |     |          visual         |      color      | ax dp st |      accum      |   layer  |\\n\");\n    fprintf(file, \" |  id | tp ac gd fm db sw st ms |  sz  r  g  b  a | bf th cl |  sz  r  g  b  a | ov un sw |\\n\");\n    fprintf(file, \" +-----+-------------------------+-----------------+----------+-----------------+----------+\\n\");\n    /* loop through all the pixel formats */\n    for(i = 1; i <= maxpf; i++)\n    {\n      wglGetPixelFormatAttribivARB(ctx->dc, i, 0, n_attrib, attrib, value);\n      /* only describe this format if it supports OpenGL */\n      if (!value[0]) continue;\n      /* by default show only fully accelerated window or pbuffer capable visuals */\n      if (!showall\n\t  && ((value[2] && !value[1])\n\t  || (!WGLEW_ARB_pbuffer || !value[n_pbuffer])\n\t  || (value[3] != WGL_FULL_ACCELERATION_ARB))) continue;\n      /* print out the information for this visual */\n      /* visual id */\n      fprintf(file, \" |% 4d | \", i);\n      /* visual type */\n      if (value[1])\n      {\n\tif (WGLEW_ARB_pbuffer && value[n_pbuffer]) fprintf(file, \"wp \");\n\telse fprintf(file, \"wn \");\n      }\n      else\n      {\n\tif (value[2]) fprintf(file, \"bm \");\n\telse if (WGLEW_ARB_pbuffer && value[n_pbuffer]) fprintf(file, \"pb \");\n      }\n      /* acceleration */\n      fprintf(file, \"%s \", value[3] == WGL_FULL_ACCELERATION_ARB ? \"fu\" : \n\t      value[3] == WGL_GENERIC_ACCELERATION_ARB ? \"ge\" :\n\t      value[3] == WGL_NO_ACCELERATION_ARB ? \"no\" : \". \");\n      /* gdi support */\n      fprintf(file, \" %c \", value[25] ? 'y' : '.');\n      /* format */\n      if (WGLEW_NV_float_buffer && value[n_float]) fprintf(file, \" f \");\n      else if (WGLEW_ATI_pixel_format_float && value[7] == WGL_TYPE_RGBA_FLOAT_ATI) fprintf(file, \" f \");\n      else if (value[7] == WGL_TYPE_RGBA_ARB) fprintf(file, \" i \");\n      else if (value[7] == WGL_TYPE_COLORINDEX_ARB) fprintf(file, \" c \");\n      else if (value[7] == WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT) fprintf(file,\" p \");\n      else fprintf(file,\" ? \");\n      /* double buffer */\n      fprintf(file, \" %c \", value[5] ? 'y' : '.');\n      /* swap method */\n      if (value[4] == WGL_SWAP_EXCHANGE_ARB) fprintf(file, \" x \");\n      else if (value[4] == WGL_SWAP_COPY_ARB) fprintf(file, \" c \");\n      else if (value[4] == WGL_SWAP_UNDEFINED_ARB) fprintf(file, \" . \");\n      else fprintf(file, \" . \");\n      /* stereo */\n      fprintf(file, \" %c \", value[6] ? 'y' : '.');\n      /* multisample */\n      if (value[24] > 0)\n\tfprintf(file, \"%2d | \", value[24]);\n      else\n\tfprintf(file, \" . | \");\n      /* color size */\n      if (value[8]) fprintf(file, \"%3d \", value[8]);\n      else fprintf(file, \"  . \");\n      /* red */\n      if (value[9]) fprintf(file, \"%2d \", value[9]); \n      else fprintf(file, \" . \");\n      /* green */\n      if (value[10]) fprintf(file, \"%2d \", value[10]); \n      else fprintf(file, \" . \");\n      /* blue */\n      if (value[11]) fprintf(file, \"%2d \", value[11]);\n      else fprintf(file, \" . \");\n      /* alpha */\n      if (value[12]) fprintf(file, \"%2d | \", value[12]); \n      else fprintf(file, \" . | \");\n      /* aux buffers */\n      if (value[20]) fprintf(file, \"%2d \", value[20]);\n      else fprintf(file, \" . \");\n      /* depth */\n      if (value[18]) fprintf(file, \"%2d \", value[18]);\n      else fprintf(file, \" . \");\n      /* stencil */\n      if (value[19]) fprintf(file, \"%2d | \", value[19]);\n      else fprintf(file, \" . | \");\n      /* accum size */\n      if (value[13]) fprintf(file, \"%3d \", value[13]);\n      else fprintf(file, \"  . \");\n      /* accum red */\n      if (value[14]) fprintf(file, \"%2d \", value[14]);\n      else fprintf(file, \" . \");\n      /* accum green */\n      if (value[15]) fprintf(file, \"%2d \", value[15]);\n      else fprintf(file, \" . \");\n      /* accum blue */\n      if (value[16]) fprintf(file, \"%2d \", value[16]);\n      else fprintf(file, \" . \");\n      /* accum alpha */\n      if (value[17]) fprintf(file, \"%2d | \", value[17]);\n      else fprintf(file, \" . | \");\n      /* overlay */\n      if (value[21]) fprintf(file, \"%2d \", value[21]);\n      else fprintf(file, \" . \");\n      /* underlay */\n      if (value[22]) fprintf(file, \"%2d \", value[22]);\n      else fprintf(file, \" . \");\n      /* layer swap */\n      if (value[23]) fprintf(file, \"y \");\n      else fprintf(file, \" . \");\n      fprintf(file, \"|\\n\");\n    }\n    /* print table footer */\n    fprintf(file, \" +-----+-------------------------+-----------------+----------+-----------------+----------+\\n\");\n    fprintf(file, \" |     |          visual         |      color      | ax dp st |      accum      |   layer  |\\n\");\n    fprintf(file, \" |  id | tp ac gd fm db sw st ms |  sz  r  g  b  a | bf th cl |  sz  r  g  b  a | ov un sw |\\n\");\n    fprintf(file, \" +-----+-------------------------+-----------------+----------+-----------------+----------+\\n\");\n  }\n  else /* verbose */\n  {\n#if 0\n    fprintf(file, \"\\n\");\n    /* loop through all the pixel formats */\n    for(i = 1; i <= maxpf; i++)\n    {\t    \n      DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);\n      /* only describe this format if it supports OpenGL */\n      if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL)\n\t || (drawableonly && !(pfd.dwFlags & PFD_DRAW_TO_WINDOW))) continue;\n      fprintf(file, \"Visual ID: %2d  depth=%d  class=%s\\n\", i, pfd.cDepthBits, \n\t     pfd.cColorBits <= 8 ? \"PseudoColor\" : \"TrueColor\");\n      fprintf(file, \"    bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\\n\", pfd.cColorBits, pfd.bReserved, pfd.iPixelType == PFD_TYPE_RGBA ? \"rgba\" : \"ci\", pfd.dwFlags & PFD_DOUBLEBUFFER, pfd.dwFlags & PFD_STEREO);\n      fprintf(file, \"    generic=%d generic accelerated=%d\\n\", (pfd.dwFlags & PFD_GENERIC_FORMAT) == PFD_GENERIC_FORMAT, (pfd.dwFlags & PFD_GENERIC_ACCELERATED) == PFD_GENERIC_ACCELERATED);\n      fprintf(file, \"    rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\\n\", pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits);\n      fprintf(file, \"    auxBuffers=%d depthSize=%d stencilSize=%d\\n\", pfd.cAuxBuffers, pfd.cDepthBits, pfd.cStencilBits);\n      fprintf(file, \"    accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\\n\", pfd.cAccumRedBits, pfd.cAccumGreenBits, pfd.cAccumBlueBits, pfd.cAccumAlphaBits);\n      fprintf(file, \"    multiSample=%d multisampleBuffers=%d\\n\", 0, 0);\n      fprintf(file, \"    Opaque.\\n\");\n    }\n#endif\n  }\n}\n\nvoid\nVisualInfoGDI (GLContext* ctx)\n{\n  int i, maxpf;\n  PIXELFORMATDESCRIPTOR pfd;\n\n  /* calling DescribePixelFormat() with NULL pfd (!!!) return maximum\n     number of pixel formats */\n  maxpf = DescribePixelFormat(ctx->dc, 1, 0, NULL);\n\n  if (!verbose)\n  {\n    fprintf(file, \"-----------------------------------------------------------------------------\\n\");\n    fprintf(file, \"   visual   x  bf  lv rg d st ge ge  r  g  b a  ax dp st   accum buffs    ms \\n\");\n    fprintf(file, \" id  dep tp sp sz  l  ci b ro ne ac sz sz sz sz bf th cl  sz  r  g  b  a ns b\\n\");\n    fprintf(file, \"-----------------------------------------------------------------------------\\n\");\n\n    /* loop through all the pixel formats */\n    for(i = 1; i <= maxpf; i++)\n    {\n      DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);\n      /* only describe this format if it supports OpenGL */\n      if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL)\n\t || (drawableonly && (pfd.dwFlags & PFD_DRAW_TO_BITMAP))) continue;\n      /* other criteria could be tested here for actual pixel format\n\t choosing in an application:\n\t   \n\t for (...each pixel format...) {\n\t if (pfd.dwFlags & PFD_SUPPORT_OPENGL &&\n\t pfd.dwFlags & PFD_DOUBLEBUFFER &&\n\t pfd.cDepthBits >= 24 &&\n\t pfd.cColorBits >= 24)\n\t {\n\t goto found;\n\t }\n\t }\n\t ... not found so exit ...\n\t found:\n\t ... found so use it ...\n      */\n      /* print out the information for this pixel format */\n      fprintf(file, \"0x%02x \", i);\n      fprintf(file, \"%3d \", pfd.cColorBits);\n      if(pfd.dwFlags & PFD_DRAW_TO_WINDOW) fprintf(file, \"wn \");\n      else if(pfd.dwFlags & PFD_DRAW_TO_BITMAP) fprintf(file, \"bm \");\n      else fprintf(file, \"pb \");\n      /* should find transparent pixel from LAYERPLANEDESCRIPTOR */\n      fprintf(file, \" . \"); \n      fprintf(file, \"%3d \", pfd.cColorBits);\n      /* bReserved field indicates number of over/underlays */\n      if(pfd.bReserved) fprintf(file, \" %d \", pfd.bReserved);\n      else fprintf(file, \" . \"); \n      fprintf(file, \" %c \", pfd.iPixelType == PFD_TYPE_RGBA ? 'r' : 'c');\n      fprintf(file, \"%c \", pfd.dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.');\n      fprintf(file, \" %c \", pfd.dwFlags & PFD_STEREO ? 'y' : '.');\n      /* added: */\n      fprintf(file, \" %c \", pfd.dwFlags & PFD_GENERIC_FORMAT ? 'y' : '.');\n      fprintf(file, \" %c \", pfd.dwFlags & PFD_GENERIC_ACCELERATED ? 'y' : '.');\n      if(pfd.cRedBits && pfd.iPixelType == PFD_TYPE_RGBA) \n\tfprintf(file, \"%2d \", pfd.cRedBits);\n      else fprintf(file, \" . \");\n      if(pfd.cGreenBits && pfd.iPixelType == PFD_TYPE_RGBA) \n\tfprintf(file, \"%2d \", pfd.cGreenBits);\n      else fprintf(file, \" . \");\n      if(pfd.cBlueBits && pfd.iPixelType == PFD_TYPE_RGBA) \n\tfprintf(file, \"%2d \", pfd.cBlueBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAlphaBits && pfd.iPixelType == PFD_TYPE_RGBA) \n\tfprintf(file, \"%2d \", pfd.cAlphaBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAuxBuffers)     fprintf(file, \"%2d \", pfd.cAuxBuffers);\n      else fprintf(file, \" . \");\n      if(pfd.cDepthBits)      fprintf(file, \"%2d \", pfd.cDepthBits);\n      else fprintf(file, \" . \");\n      if(pfd.cStencilBits)    fprintf(file, \"%2d \", pfd.cStencilBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAccumBits)   fprintf(file, \"%3d \", pfd.cAccumBits);\n      else fprintf(file, \"  . \");\n      if(pfd.cAccumRedBits)   fprintf(file, \"%2d \", pfd.cAccumRedBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAccumGreenBits) fprintf(file, \"%2d \", pfd.cAccumGreenBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAccumBlueBits)  fprintf(file, \"%2d \", pfd.cAccumBlueBits);\n      else fprintf(file, \" . \");\n      if(pfd.cAccumAlphaBits) fprintf(file, \"%2d \", pfd.cAccumAlphaBits);\n      else fprintf(file, \" . \");\n      /* no multisample in win32 */\n      fprintf(file, \" . .\\n\");\n    }\n    /* print table footer */\n    fprintf(file, \"-----------------------------------------------------------------------------\\n\");\n    fprintf(file, \"   visual   x  bf  lv rg d st ge ge  r  g  b a  ax dp st   accum buffs    ms \\n\");\n    fprintf(file, \" id  dep tp sp sz  l  ci b ro ne ac sz sz sz sz bf th cl  sz  r  g  b  a ns b\\n\");\n    fprintf(file, \"-----------------------------------------------------------------------------\\n\");\n  }\n  else /* verbose */\n  {\n    fprintf(file, \"\\n\");\n    /* loop through all the pixel formats */\n    for(i = 1; i <= maxpf; i++)\n    {\t    \n      DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);\n      /* only describe this format if it supports OpenGL */\n      if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL)\n\t || (drawableonly && !(pfd.dwFlags & PFD_DRAW_TO_WINDOW))) continue;\n      fprintf(file, \"Visual ID: %2d  depth=%d  class=%s\\n\", i, pfd.cDepthBits, \n\t     pfd.cColorBits <= 8 ? \"PseudoColor\" : \"TrueColor\");\n      fprintf(file, \"    bufferSize=%d level=%d renderType=%s doubleBuffer=%ld stereo=%ld\\n\", pfd.cColorBits, pfd.bReserved, pfd.iPixelType == PFD_TYPE_RGBA ? \"rgba\" : \"ci\", pfd.dwFlags & PFD_DOUBLEBUFFER, pfd.dwFlags & PFD_STEREO);\n      fprintf(file, \"    generic=%d generic accelerated=%d\\n\", (pfd.dwFlags & PFD_GENERIC_FORMAT) == PFD_GENERIC_FORMAT, (pfd.dwFlags & PFD_GENERIC_ACCELERATED) == PFD_GENERIC_ACCELERATED);\n      fprintf(file, \"    rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\\n\", pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits);\n      fprintf(file, \"    auxBuffers=%d depthSize=%d stencilSize=%d\\n\", pfd.cAuxBuffers, pfd.cDepthBits, pfd.cStencilBits);\n      fprintf(file, \"    accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\\n\", pfd.cAccumRedBits, pfd.cAccumGreenBits, pfd.cAccumBlueBits, pfd.cAccumAlphaBits);\n      fprintf(file, \"    multiSample=%d multisampleBuffers=%d\\n\", 0, 0);\n      fprintf(file, \"    Opaque.\\n\");\n    }\n  }\n}\n\nvoid\nVisualInfo (GLContext* ctx)\n{\n  if (WGLEW_ARB_pixel_format)\n    VisualInfoARB(ctx);\n  else\n    VisualInfoGDI(ctx);\n}\n\n/* ---------------------------------------------------------------------- */\n\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n\nvoid\nVisualInfo (GLContext* ctx)\n{\n/*\n  int attrib[] = { AGL_RGBA, AGL_NONE };\n  AGLPixelFormat pf;\n  GLint value;\n  pf = aglChoosePixelFormat(NULL, 0, attrib);\n  while (pf != NULL)\n  {\n    aglDescribePixelFormat(pf, GL_RGBA, &value);\n    fprintf(stderr, \"%d\\n\", value);\n    pf = aglNextPixelFormat(pf);\n  }\n*/\n}\n\n#else /* GLX */\n\nvoid\nVisualInfo (GLContext* ctx)\n{\n  int n_fbc;\n  GLXFBConfig* fbc;\n  int value, ret, i;\n\n  fbc = glXGetFBConfigs(ctx->dpy, DefaultScreen(ctx->dpy), &n_fbc);\n\n  if (fbc)\n  {\n    if (!verbose)\n    {\n      /* print table header */\n      fprintf(file, \" +-----+-------------------------+-----------------+----------+-------------+-------+------+\\n\");\n      fprintf(file, \" |     |        visual           |      color      | ax dp st |    accum    |   ms  |  cav |\\n\");\n      fprintf(file, \" |  id | tp xr cl fm db st lv xp |  sz  r  g  b  a | bf th cl | r  g  b  a  | ns  b |  eat |\\n\");\n      fprintf(file, \" +-----+-------------------------+-----------------+----------+-------------+-------+------+\\n\");\n      /* loop through all the fbcs */\n      for (i=0; i<n_fbc; i++)\n      {\n        /* print out the information for this fbc */\n        /* visual id */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_FBCONFIG_ID, &value);\n        if (ret != Success)\n        {\n          fprintf(file, \"|  ?  |\");\n        }\n        else\n        {\n          fprintf(file, \" |% 4d | \", value);\n        }\n        /* visual type */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DRAWABLE_TYPE, &value);\n        if (ret != Success)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value & GLX_WINDOW_BIT)\n          {\n            if (value & GLX_PBUFFER_BIT)\n            {\n              fprintf(file, \"wp \");\n            }\n            else\n            {\n              fprintf(file, \"wn \");\n            }\n          }\n          else\n          {\n            if (value & GLX_PBUFFER_BIT)\n            {\n              fprintf(file, \"pb \");\n            }\n            else if (value & GLX_PIXMAP_BIT)\n            {\n              fprintf(file, \"pm \");\n            }\n            else\n            {\n              fprintf(file, \" ? \");\n            }\n          }\n        }\n        /* x renderable */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_X_RENDERABLE, &value);\n        if (ret != Success)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          fprintf(file, value ? \" y \" : \" n \");\n        }\n        /* class */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_X_VISUAL_TYPE, &value);\n        if (ret != Success)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (GLX_TRUE_COLOR == value)\n            fprintf(file, \"tc \");\n          else if (GLX_DIRECT_COLOR == value)\n            fprintf(file, \"dc \");\n          else if (GLX_PSEUDO_COLOR == value)\n            fprintf(file, \"pc \");\n          else if (GLX_STATIC_COLOR == value)\n            fprintf(file, \"sc \");\n          else if (GLX_GRAY_SCALE == value)\n            fprintf(file, \"gs \");\n          else if (GLX_STATIC_GRAY == value)\n            fprintf(file, \"sg \");\n          else if (GLX_X_VISUAL_TYPE == value)\n            fprintf(file, \" . \");\n          else\n            fprintf(file, \" ? \");\n        }\n        /* format */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_RENDER_TYPE, &value);\n        if (ret != Success)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (GLXEW_NV_float_buffer)\n          {\n            int ret2, value2;\n            ret2 = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_FLOAT_COMPONENTS_NV, &value2);\n            if (Success == ret2 && GL_TRUE == value2)\n            {\n              fprintf(file, \" f \");\n            }\n            else if (value & GLX_RGBA_BIT)\n              fprintf(file, \" i \");\n            else if (value & GLX_COLOR_INDEX_BIT)\n              fprintf(file, \" c \");\n            else\n              fprintf(file, \" ? \");\n          }\n          else\n          {\n            if (value & GLX_RGBA_FLOAT_ATI_BIT)\n              fprintf(file, \" f \");\n            else if (value & GLX_RGBA_BIT)\n              fprintf(file, \" i \");\n            else if (value & GLX_COLOR_INDEX_BIT)\n              fprintf(file, \" c \");\n            else\n              fprintf(file, \" ? \");\n          }\n        }\n        /* double buffer */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DOUBLEBUFFER, &value);\n        fprintf(file, \" %c \", Success != ret ? '?' : (value ? 'y' : '.'));\n        /* stereo */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_STEREO, &value);\n        fprintf(file, \" %c \", Success != ret ? '?' : (value ? 'y' : '.'));\n        /* level */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_LEVEL, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          fprintf(file, \"%2d \", value);\n        }\n        /* transparency */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_TRANSPARENT_TYPE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? | \");\n        }\n        else\n        {\n          if (GLX_TRANSPARENT_RGB == value)\n            fprintf(file, \" r | \");\n          else if (GLX_TRANSPARENT_INDEX == value)\n            fprintf(file, \" i | \");\n          else if (GLX_NONE == value)\n            fprintf(file, \" . | \");\n          else\n            fprintf(file, \" ? | \");\n        }\n        /* color size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_BUFFER_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \"  ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%3d \", value);\n          else\n            fprintf(file, \"  . \");\n        }\n        /* red size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_RED_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* green size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_GREEN_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* blue size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_BLUE_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* alpha size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ALPHA_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? | \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d | \", value);\n          else\n            fprintf(file, \" . | \");\n        }\n        /* aux buffers */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_AUX_BUFFERS, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* depth size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DEPTH_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* stencil size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_STENCIL_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? | \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d | \", value);\n          else\n            fprintf(file, \" . | \");\n        }\n        /* accum red size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_RED_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* accum green size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_GREEN_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* accum blue size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_BLUE_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d \", value);\n          else\n            fprintf(file, \" . \");\n        }\n        /* accum alpha size */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_ALPHA_SIZE, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? | \");\n        }\n        else\n        {\n          if (value)\n            fprintf(file, \"%2d | \", value);\n          else\n            fprintf(file, \" . | \");\n        }\n        /* multisample */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_SAMPLES, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? \");\n        }\n        else\n        {\n          fprintf(file, \"%2d \", value);\n        }\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_SAMPLE_BUFFERS, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \" ? | \");\n        }\n        else\n        {\n          fprintf(file, \"%2d | \", value);\n        }\n        /* caveat */\n        ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_CONFIG_CAVEAT, &value);\n        if (Success != ret)\n        {\n          fprintf(file, \"???? |\");\n        }\n        else\n        {\n          if (GLX_NONE == value)\n            fprintf(file, \"none |\\n\");\n          else if (GLX_SLOW_CONFIG == value)\n            fprintf(file, \"slow |\\n\");\n          else if (GLX_NON_CONFORMANT_CONFIG == value)\n            fprintf(file, \"ncft |\\n\");\n          else\n            fprintf(file, \"???? |\\n\");\n        }\n      }\n      /* print table footer */\n      fprintf(file, \" +-----+-------------------------+-----------------+----------+-------------+-------+------+\\n\");\n      fprintf(file, \" |  id | tp xr cl fm db st lv xp |  sz  r  g  b  a | bf th cl | r  g  b  a  | ns  b |  eat |\\n\");\n      fprintf(file, \" |     |        visual           |      color      | ax dp st |    accum    |   ms  |  cav |\\n\");\n      fprintf(file, \" +-----+-------------------------+-----------------+----------+-------------+-------+------+\\n\");\n    }\n  }\n}\n\n#endif\n\n/* ------------------------------------------------------------------------ */\n\n#if defined(_WIN32)\n\nvoid InitContext (GLContext* ctx)\n{\n  ctx->wnd = NULL;\n  ctx->dc = NULL;\n  ctx->rc = NULL;\n}\n\nGLboolean CreateContext (GLContext* ctx)\n{\n  WNDCLASS wc;\n  PIXELFORMATDESCRIPTOR pfd;\n  /* check for input */\n  if (NULL == ctx) return GL_TRUE;\n  /* register window class */\n  ZeroMemory(&wc, sizeof(WNDCLASS));\n  wc.hInstance = GetModuleHandle(NULL);\n  wc.lpfnWndProc = DefWindowProc;\n  wc.lpszClassName = \"GLEW\";\n  if (0 == RegisterClass(&wc)) return GL_TRUE;\n  /* create window */\n  ctx->wnd = CreateWindow(\"GLEW\", \"GLEW\", 0, CW_USEDEFAULT, CW_USEDEFAULT, \n                          CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, \n                          GetModuleHandle(NULL), NULL);\n  if (NULL == ctx->wnd) return GL_TRUE;\n  /* get the device context */\n  ctx->dc = GetDC(ctx->wnd);\n  if (NULL == ctx->dc) return GL_TRUE;\n  /* find pixel format */\n  ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));\n  if (visual == -1) /* find default */\n  {\n    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);\n    pfd.nVersion = 1;\n    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;\n    visual = ChoosePixelFormat(ctx->dc, &pfd);\n    if (0 == visual) return GL_TRUE;\n  }\n  /* set the pixel format for the dc */\n  if (FALSE == SetPixelFormat(ctx->dc, visual, &pfd)) return GL_TRUE;\n  /* create rendering context */\n  ctx->rc = wglCreateContext(ctx->dc);\n  if (NULL == ctx->rc) return GL_TRUE;\n  if (FALSE == wglMakeCurrent(ctx->dc, ctx->rc)) return GL_TRUE;\n  return GL_FALSE;\n}\n\nvoid DestroyContext (GLContext* ctx)\n{\n  if (NULL == ctx) return;\n  if (NULL != ctx->rc) wglMakeCurrent(NULL, NULL);\n  if (NULL != ctx->rc) wglDeleteContext(wglGetCurrentContext());\n  if (NULL != ctx->wnd && NULL != ctx->dc) ReleaseDC(ctx->wnd, ctx->dc);\n  if (NULL != ctx->wnd) DestroyWindow(ctx->wnd);\n  UnregisterClass(\"GLEW\", GetModuleHandle(NULL));\n}\n\n/* ------------------------------------------------------------------------ */\n\n#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)\n\nvoid InitContext (GLContext* ctx)\n{\n  ctx->ctx = NULL;\n  ctx->octx = NULL;\n}\n\nGLboolean CreateContext (GLContext* ctx)\n{\n  int attrib[] = { AGL_RGBA, AGL_NONE };\n  AGLPixelFormat pf;\n  /* check input */\n  if (NULL == ctx) return GL_TRUE;\n  /*int major, minor;\n  SetPortWindowPort(wnd);\n  aglGetVersion(&major, &minor);\n  fprintf(stderr, \"GL %d.%d\\n\", major, minor);*/\n  pf = aglChoosePixelFormat(NULL, 0, attrib);\n  if (NULL == pf) return GL_TRUE;\n  ctx->ctx = aglCreateContext(pf, NULL);\n  if (NULL == ctx->ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE;\n  aglDestroyPixelFormat(pf);\n  /*aglSetDrawable(ctx, GetWindowPort(wnd));*/\n  ctx->octx = aglGetCurrentContext();\n  if (GL_FALSE == aglSetCurrentContext(ctx->ctx)) return GL_TRUE;\n  return GL_FALSE;\n}\n\nvoid DestroyContext (GLContext* ctx)\n{\n  if (NULL == ctx) return;\n  aglSetCurrentContext(ctx->octx);\n  if (NULL != ctx->ctx) aglDestroyContext(ctx->ctx);\n}\n\n/* ------------------------------------------------------------------------ */\n\n#else /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */\n\nvoid InitContext (GLContext* ctx)\n{\n  ctx->dpy = NULL;\n  ctx->vi = NULL;\n  ctx->ctx = NULL;\n  ctx->wnd = 0;\n  ctx->cmap = 0;\n}\n\nGLboolean CreateContext (GLContext* ctx)\n{\n  int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None };\n  int erb, evb;\n  XSetWindowAttributes swa;\n  /* check input */\n  if (NULL == ctx) return GL_TRUE;\n  /* open display */\n  ctx->dpy = XOpenDisplay(display);\n  if (NULL == ctx->dpy) return GL_TRUE;\n  /* query for glx */\n  if (!glXQueryExtension(ctx->dpy, &erb, &evb)) return GL_TRUE;\n  /* choose visual */\n  ctx->vi = glXChooseVisual(ctx->dpy, DefaultScreen(ctx->dpy), attrib);\n  if (NULL == ctx->vi) return GL_TRUE;\n  /* create context */\n  ctx->ctx = glXCreateContext(ctx->dpy, ctx->vi, None, True);\n  if (NULL == ctx->ctx) return GL_TRUE;\n  /* create window */\n  /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/\n  ctx->cmap = XCreateColormap(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen),\n                              ctx->vi->visual, AllocNone);\n  swa.border_pixel = 0;\n  swa.colormap = ctx->cmap;\n  ctx->wnd = XCreateWindow(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen), \n                           0, 0, 1, 1, 0, ctx->vi->depth, InputOutput, ctx->vi->visual, \n                           CWBorderPixel | CWColormap, &swa);\n  /* make context current */\n  if (!glXMakeCurrent(ctx->dpy, ctx->wnd, ctx->ctx)) return GL_TRUE;\n  return GL_FALSE;\n}\n\nvoid DestroyContext (GLContext* ctx)\n{\n  if (NULL != ctx->dpy && NULL != ctx->ctx) glXDestroyContext(ctx->dpy, ctx->ctx);\n  if (NULL != ctx->dpy && 0 != ctx->wnd) XDestroyWindow(ctx->dpy, ctx->wnd);\n  if (NULL != ctx->dpy && 0 != ctx->cmap) XFreeColormap(ctx->dpy, ctx->cmap);\n  if (NULL != ctx->vi) XFree(ctx->vi);\n  if (NULL != ctx->dpy) XCloseDisplay(ctx->dpy);\n}\n\n#endif /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */\n\nGLboolean ParseArgs (int argc, char** argv)\n{\n  int p = 0;\n  while (p < argc)\n  {\n#if defined(_WIN32)\n    if (!strcmp(argv[p], \"-pf\") || !strcmp(argv[p], \"-pixelformat\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      display = NULL;\n      visual = strtol(argv[p], NULL, 0);\n    }\n    else if (!strcmp(argv[p], \"-a\"))\n    {\n      showall = 1;\n    }\n    else if (!strcmp(argv[p], \"-s\"))\n    {\n      displaystdout = 1;\n    }\n    else if (!strcmp(argv[p], \"-h\"))\n    {\n      return GL_TRUE;\n    }\n    else\n      return GL_TRUE;\n#else\n    if (!strcmp(argv[p], \"-display\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      display = argv[p];\n    }\n    else if (!strcmp(argv[p], \"-visual\"))\n    {\n      if (++p >= argc) return GL_TRUE;\n      visual = (int)strtol(argv[p], NULL, 0);\n    }\n    else if (!strcmp(argv[p], \"-h\"))\n    {\n      return GL_TRUE;\n    }\n    else\n      return GL_TRUE;\n#endif\n    p++;\n  }\n  return GL_FALSE;\n}\n"
  },
  {
    "path": "deps/glfw/.gitignore",
    "content": "# External junk\n.DS_Store\n_ReSharper*\n*.opensdf\n*.sdf\n*.dir\n*.vcxproj*\n*.sln\nWin32\nDebug\nRelease\n\n# CMake files\nMakefile\nCMakeCache.txt\nCMakeFiles\ncmake_install.cmake\ncmake_uninstall.cmake\n\n# Generated files\ndocs/Doxyfile\ndocs/html\ndocs/warnings.txt\nsrc/config.h\nsrc/glfw3.pc\nsrc/glfwConfig.cmake\nsrc/glfwConfigVersion.cmake\n\n# Compiled binaries\nsrc/libglfw.so\nsrc/libglfw.so.3\nsrc/libglfw.so.3.0\nsrc/libglfw.dylib\nsrc/libglfw.dylib\nsrc/libglfw.3.dylib\nsrc/libglfw.3.0.dylib\nsrc/libglfw3.a\nsrc/glfw3.lib\nsrc/glfw3.dll\nsrc/glfw3dll.lib\nsrc/glfw3dll.a\nexamples/*.app\nexamples/*.exe\nexamples/boing\nexamples/gears\nexamples/heightmap\nexamples/splitview\nexamples/simple\nexamples/wave\ntests/*.app\ntests/*.exe\ntests/accuracy\ntests/clipboard\ntests/defaults\ntests/events\ntests/fsaa\ntests/gamma\ntests/glfwinfo\ntests/iconify\ntests/joysticks\ntests/modes\ntests/peter\ntests/reopen\ntests/sharing\ntests/tearing\ntests/threads\ntests/title\ntests/version\ntests/windows\n\n"
  },
  {
    "path": "deps/glfw/CMake/MacOSXBundleInfo.plist.in",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>${MACOSX_BUNDLE_INFO_STRING}</string>\n\t<key>CFBundleIconFile</key>\n\t<string>${MACOSX_BUNDLE_ICON_FILE}</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleLongVersionString</key>\n\t<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>\n\t<key>CFBundleName</key>\n\t<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>\n\t<key>CSResourcesFileMapped</key>\n\t<true/>\n\t<key>LSRequiresCarbon</key>\n\t<true/>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>${MACOSX_BUNDLE_COPYRIGHT}</string>\n\t<key>NSHighResolutionCapable</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "deps/glfw/CMake/amd64-mingw32msvc.cmake",
    "content": "# Define the environment for cross compiling from Linux to Win64\nSET(CMAKE_SYSTEM_NAME    Windows)\nSET(CMAKE_SYSTEM_VERSION 1)\nSET(CMAKE_C_COMPILER     \"amd64-mingw32msvc-gcc\")\nSET(CMAKE_CXX_COMPILER   \"amd64-mingw32msvc-g++\")\nSET(CMAKE_RC_COMPILER    \"amd64-mingw32msvc-windres\")\nSET(CMAKE_RANLIB         \"amd64-mingw32msvc-ranlib\")\n\n# Configure the behaviour of the find commands \nSET(CMAKE_FIND_ROOT_PATH \"/usr/amd64-mingw32msvc\")\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"
  },
  {
    "path": "deps/glfw/CMake/i586-mingw32msvc.cmake",
    "content": "# Define the environment for cross compiling from Linux to Win32\nSET(CMAKE_SYSTEM_NAME    Windows)\nSET(CMAKE_SYSTEM_VERSION 1)\nSET(CMAKE_C_COMPILER     \"i586-mingw32msvc-gcc\")\nSET(CMAKE_CXX_COMPILER   \"i586-mingw32msvc-g++\")\nSET(CMAKE_RC_COMPILER    \"i586-mingw32msvc-windres\")\nSET(CMAKE_RANLIB         \"i586-mingw32msvc-ranlib\")\n\n# Configure the behaviour of the find commands \nSET(CMAKE_FIND_ROOT_PATH \"/usr/i586-mingw32msvc\")\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"
  },
  {
    "path": "deps/glfw/CMake/i686-pc-mingw32.cmake",
    "content": "# Define the environment for cross compiling from Linux to Win32\nSET(CMAKE_SYSTEM_NAME    Windows) # Target system name\nSET(CMAKE_SYSTEM_VERSION 1)\nSET(CMAKE_C_COMPILER     \"i686-pc-mingw32-gcc\")\nSET(CMAKE_CXX_COMPILER   \"i686-pc-mingw32-g++\")\nSET(CMAKE_RC_COMPILER    \"i686-pc-mingw32-windres\")\nSET(CMAKE_RANLIB         \"i686-pc-mingw32-ranlib\")\n\n#Configure the behaviour of the find commands \nSET(CMAKE_FIND_ROOT_PATH \"/opt/mingw/usr/i686-pc-mingw32\")\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"
  },
  {
    "path": "deps/glfw/CMake/i686-w64-mingw32.cmake",
    "content": "# Define the environment for cross compiling from Linux to Win32\nSET(CMAKE_SYSTEM_NAME    Windows) # Target system name\nSET(CMAKE_SYSTEM_VERSION 1)\nSET(CMAKE_C_COMPILER     \"i686-w64-mingw32-gcc\")\nSET(CMAKE_CXX_COMPILER   \"i686-w64-mingw32-g++\")\nSET(CMAKE_RC_COMPILER    \"i686-w64-mingw32-windres\")\nSET(CMAKE_RANLIB         \"i686-w64-mingw32-ranlib\")\n\n# Configure the behaviour of the find commands \nSET(CMAKE_FIND_ROOT_PATH \"/usr/i686-w64-mingw32\")\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindEGL.cmake",
    "content": "# Find EGL\n#\n# EGL_INCLUDE_DIR\n# EGL_LIBRARY\n# EGL_FOUND\n\nfind_path(EGL_INCLUDE_DIR NAMES EGL/egl.h PATHS /opt/vc/include)\n\nset(EGL_NAMES ${EGL_NAMES} egl EGL libEGL)\nfind_library(EGL_LIBRARY NAMES ${EGL_NAMES} PATHS /opt/vc/lib)\n\ninclude(FindPackageHandleStandardArgs)\nfind_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR)\n\nmark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY)\n\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindGLESv1.cmake",
    "content": "# Find GLESv1\n#\n# GLESv1_INCLUDE_DIR\n# GLESv1_LIBRARY\n# GLESv1_FOUND\n\nfind_path(GLESv1_INCLUDE_DIR NAMES GLES/gl.h PATHS /opt/vc/include)\n\nset(GLESv1_NAMES ${GLESv1_NAMES} GLESv1_CM libGLES_CM)\nfind_library(GLESv1_LIBRARY NAMES ${GLESv1_NAMES} PATHS /opt/vc/lib)\n\ninclude(FindPackageHandleStandardArgs)\nfind_package_handle_standard_args(GLESv1 DEFAULT_MSG GLESv1_LIBRARY GLESv1_INCLUDE_DIR)\n\nmark_as_advanced(GLESv1_INCLUDE_DIR GLESv1_LIBRARY)\n\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindGLESv2.cmake",
    "content": "# Find GLESv2\n#\n# GLESv2_INCLUDE_DIR\n# GLESv2_LIBRARY\n# GLESv2_FOUND\n\nfind_path(GLESv2_INCLUDE_DIR NAMES GLES2/gl2.h PATHS /opt/vc/include)\n\nset(GLESv2_NAMES ${GLESv2_NAMES} GLESv2 libGLESv2)\nfind_library(GLESv2_LIBRARY NAMES ${GLESv2_NAMES} PATHS /opt/vc/lib)\n\ninclude(FindPackageHandleStandardArgs)\nfind_package_handle_standard_args(GLESv2 DEFAULT_MSG GLESv2_LIBRARY GLESv2_INCLUDE_DIR)\n\nmark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY)\n\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindMir.cmake",
    "content": "# Try to find Mir on a Unix system\n#\n# This will define:\n#\n#   MIR_LIBRARIES   - Link these to use Wayland\n#   MIR_INCLUDE_DIR - Include directory for Wayland\n#\n# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>\n\nif (NOT WIN32)\n\n  find_package (PkgConfig)\n  pkg_check_modules (PKG_MIR QUIET mirclient)\n\n  set (MIR_INCLUDE_DIR ${PKG_MIR_INCLUDE_DIRS})\n  set (MIR_LIBRARIES   ${PKG_MIR_LIBRARIES})\n\nendif ()\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindWayland.cmake",
    "content": "# Try to find Wayland on a Unix system\n#\n# This will define:\n#\n#   WAYLAND_FOUND       - True if Wayland is found\n#   WAYLAND_LIBRARIES   - Link these to use Wayland\n#   WAYLAND_INCLUDE_DIR - Include directory for Wayland\n#   WAYLAND_DEFINITIONS - Compiler flags for using Wayland\n#\n# In addition the following more fine grained variables will be defined:\n#\n#   WAYLAND_CLIENT_FOUND  WAYLAND_CLIENT_INCLUDE_DIR  WAYLAND_CLIENT_LIBRARIES\n#   WAYLAND_SERVER_FOUND  WAYLAND_SERVER_INCLUDE_DIR  WAYLAND_SERVER_LIBRARIES\n#   WAYLAND_EGL_FOUND     WAYLAND_EGL_INCLUDE_DIR     WAYLAND_EGL_LIBRARIES\n#\n# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>\n#\n# Redistribution and use is allowed according to the terms of the BSD license.\n# For details see the accompanying COPYING-CMAKE-SCRIPTS file.\n\nIF (NOT WIN32)\n  IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)\n    # In the cache already\n    SET(WAYLAND_FIND_QUIETLY TRUE)\n  ENDIF ()\n\n  # Use pkg-config to get the directories and then use these values\n  # in the FIND_PATH() and FIND_LIBRARY() calls\n  FIND_PACKAGE(PkgConfig)\n  PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)\n\n  SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})\n\n  FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR  NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})\n  FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR  NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})\n  FIND_PATH(WAYLAND_EGL_INCLUDE_DIR     NAMES wayland-egl.h    HINTS ${PKG_WAYLAND_INCLUDE_DIRS})\n  FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR  NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})\n\n  FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})\n  FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})\n  FIND_LIBRARY(WAYLAND_EGL_LIBRARIES    NAMES wayland-egl      HINTS ${PKG_WAYLAND_LIBRARY_DIRS})\n  FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})\n\n  set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})\n\n  set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})\n\n  list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)\n\n  include(FindPackageHandleStandardArgs)\n\n  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT  DEFAULT_MSG  WAYLAND_CLIENT_LIBRARIES  WAYLAND_CLIENT_INCLUDE_DIR)\n  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER  DEFAULT_MSG  WAYLAND_SERVER_LIBRARIES  WAYLAND_SERVER_INCLUDE_DIR)\n  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL     DEFAULT_MSG  WAYLAND_EGL_LIBRARIES     WAYLAND_EGL_INCLUDE_DIR)\n  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR  DEFAULT_MSG  WAYLAND_CURSOR_LIBRARIES  WAYLAND_CURSOR_INCLUDE_DIR)\n  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND         DEFAULT_MSG  WAYLAND_LIBRARIES         WAYLAND_INCLUDE_DIR)\n\n  MARK_AS_ADVANCED(\n        WAYLAND_INCLUDE_DIR         WAYLAND_LIBRARIES\n        WAYLAND_CLIENT_INCLUDE_DIR  WAYLAND_CLIENT_LIBRARIES\n        WAYLAND_SERVER_INCLUDE_DIR  WAYLAND_SERVER_LIBRARIES\n        WAYLAND_EGL_INCLUDE_DIR     WAYLAND_EGL_LIBRARIES\n        WAYLAND_CURSOR_INCLUDE_DIR  WAYLAND_CURSOR_LIBRARIES\n  )\n\nENDIF ()\n"
  },
  {
    "path": "deps/glfw/CMake/modules/FindXKBCommon.cmake",
    "content": "# - Try to find XKBCommon\n# Once done, this will define\n#\n#   XKBCOMMON_FOUND - System has XKBCommon\n#   XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories\n#   XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon\n#   XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon\n\nfind_package(PkgConfig)\npkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)\nset(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})\n\nfind_path(XKBCOMMON_INCLUDE_DIR\n    NAMES xkbcommon/xkbcommon.h\n    HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}\n)\n\nfind_library(XKBCOMMON_LIBRARY\n    NAMES xkbcommon\n    HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS}\n)\n\nset(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY})\nset(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS})\nset(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR})\n\ninclude(FindPackageHandleStandardArgs)\nfind_package_handle_standard_args(XKBCommon DEFAULT_MSG\n    XKBCOMMON_LIBRARY\n    XKBCOMMON_INCLUDE_DIR\n)\n\nmark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)\n\n"
  },
  {
    "path": "deps/glfw/CMake/x86_64-w64-mingw32.cmake",
    "content": "# Define the environment for cross compiling from Linux to Win32\nSET(CMAKE_SYSTEM_NAME    Windows) # Target system name\nSET(CMAKE_SYSTEM_VERSION 1)\nSET(CMAKE_C_COMPILER     \"x86_64-w64-mingw32-gcc\")\nSET(CMAKE_CXX_COMPILER   \"x86_64-w64-mingw32-g++\")\nSET(CMAKE_RC_COMPILER    \"x86_64-w64-mingw32-windres\")\nSET(CMAKE_RANLIB         \"x86_64-w64-mingw32-ranlib\")\n\n# Configure the behaviour of the find commands \nSET(CMAKE_FIND_ROOT_PATH \"/usr/x86_64-w64-mingw32\")\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n"
  },
  {
    "path": "deps/glfw/CMakeLists.txt",
    "content": "project(GLFW C)\n\ncmake_minimum_required(VERSION 2.8.12)\n\nif (NOT CMAKE_VERSION VERSION_LESS \"3.0\")\n    # Until all major package systems have moved to CMake 3,\n    # we stick with the older INSTALL_NAME_DIR mechanism\n    cmake_policy(SET CMP0042 OLD)\nendif()\n\nset(GLFW_VERSION_MAJOR \"3\")\nset(GLFW_VERSION_MINOR \"1\")\nset(GLFW_VERSION_PATCH \"2\")\nset(GLFW_VERSION_EXTRA \"\")\nset(GLFW_VERSION \"${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}\")\nset(GLFW_VERSION_FULL \"${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}\")\nset(LIB_SUFFIX \"\" CACHE STRING \"Takes an empty string or 64. Directory where lib will be installed: lib or lib64\")\n\nset_property(GLOBAL PROPERTY USE_FOLDERS ON)\n\noption(BUILD_SHARED_LIBS \"Build shared libraries\" OFF)\noption(GLFW_BUILD_EXAMPLES \"Build the GLFW example programs\" ON)\noption(GLFW_BUILD_TESTS \"Build the GLFW test programs\" ON)\noption(GLFW_BUILD_DOCS \"Build the GLFW documentation\" ON)\noption(GLFW_INSTALL \"Generate installation target\" ON)\noption(GLFW_DOCUMENT_INTERNALS \"Include internals in documentation\" OFF)\n\nif (WIN32)\n    option(GLFW_USE_HYBRID_HPG \"Force use of high-performance GPU on hybrid systems\" OFF)\nendif()\n\nif (APPLE)\n    option(GLFW_BUILD_UNIVERSAL \"Build GLFW as a Universal Binary\" OFF)\n    option(GLFW_USE_CHDIR \"Make glfwInit chdir to Contents/Resources\" ON)\n    option(GLFW_USE_MENUBAR \"Populate the menu bar on first window creation\" ON)\n    option(GLFW_USE_RETINA \"Use the full resolution of Retina displays\" ON)\nelse()\n    option(GLFW_USE_EGL \"Use EGL for context creation\" OFF)\nendif()\n\nif (UNIX AND NOT APPLE)\n    option(GLFW_USE_WAYLAND \"Use Wayland for context creation (implies EGL as well)\" OFF)\n    option(GLFW_USE_MIR     \"Use Mir for context creation (implies EGL as well)\" OFF)\nendif()\n\nif (MSVC)\n    option(USE_MSVC_RUNTIME_LIBRARY_DLL \"Use MSVC runtime library DLL\" ON)\nendif()\n\nif (BUILD_SHARED_LIBS)\n    set(_GLFW_BUILD_DLL 1)\nendif()\n\nif (GLFW_USE_WAYLAND)\n    set(GLFW_USE_EGL ON)\nelseif (GLFW_USE_MIR)\n    set(GLFW_USE_EGL ON)\nendif()\n\nset(CMAKE_MODULE_PATH \"${GLFW_SOURCE_DIR}/CMake/modules\")\n\nif (GLFW_USE_EGL)\n    set(GLFW_CLIENT_LIBRARY \"opengl\" CACHE STRING\n        \"The client library to use; one of opengl, glesv1 or glesv2\")\n\n    if (${GLFW_CLIENT_LIBRARY} STREQUAL \"opengl\")\n        set(_GLFW_USE_OPENGL 1)\n    elseif (${GLFW_CLIENT_LIBRARY} STREQUAL \"glesv1\")\n        set(_GLFW_USE_GLESV1 1)\n    elseif (${GLFW_CLIENT_LIBRARY} STREQUAL \"glesv2\")\n        set(_GLFW_USE_GLESV2 1)\n    else()\n        message(FATAL_ERROR \"Unsupported client library\")\n    endif()\n\n    find_package(EGL REQUIRED)\n\n    if (NOT _GLFW_USE_OPENGL)\n        set(GLFW_BUILD_EXAMPLES OFF)\n        set(GLFW_BUILD_TESTS OFF)\n        message(STATUS \"NOTE: Examples and tests require OpenGL\")\n    endif()\nelse()\n    set(_GLFW_USE_OPENGL 1)\nendif()\n\nif (_GLFW_USE_OPENGL)\n    find_package(OpenGL REQUIRED)\nelseif (_GLFW_USE_GLESV1)\n    find_package(GLESv1 REQUIRED)\nelseif (_GLFW_USE_GLESV2)\n    find_package(GLESv2 REQUIRED)\nendif()\n\nfind_package(Threads REQUIRED)\n\nif (GLFW_BUILD_DOCS)\n    set(DOXYGEN_SKIP_DOT TRUE)\n    find_package(Doxygen)\n\n    if (GLFW_DOCUMENT_INTERNALS)\n        set(GLFW_INTERNAL_DOCS \"${GLFW_SOURCE_DIR}/src/internal.h ${GLFW_SOURCE_DIR}/docs/internal.dox\")\n    endif()\nendif()\n\n#--------------------------------------------------------------------\n# Set compiler specific flags\n#--------------------------------------------------------------------\nif (UNIX)\n    add_definitions(-Wall)\n\n    if (BUILD_SHARED_LIBS)\n        add_definitions(-fvisibility=hidden)\n    endif()\nendif()\n\nif (MSVC)\n    add_definitions(-D_CRT_SECURE_NO_WARNINGS)\n\n    if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)\n        foreach (flag CMAKE_C_FLAGS\n                        CMAKE_C_FLAGS_DEBUG\n                        CMAKE_C_FLAGS_RELEASE\n                        CMAKE_C_FLAGS_MINSIZEREL\n                        CMAKE_C_FLAGS_RELWITHDEBINFO)\n\n            if (${flag} MATCHES \"/MD\")\n                string(REGEX REPLACE \"/MD\" \"/MT\" ${flag} \"${${flag}}\")\n            endif()\n            if (${flag} MATCHES \"/MDd\")\n                string(REGEX REPLACE \"/MDd\" \"/MTd\" ${flag} \"${${flag}}\")\n            endif()\n\n        endforeach()\n    endif()\nendif()\n\nif (MINGW)\n    # Enable link-time exploit mitigation features enabled by default on MSVC\n    include(CheckCCompilerFlag)\n\n    # Compatibility with data execution prevention (DEP)\n    set(CMAKE_REQUIRED_FLAGS \"-Wl,--nxcompat\")\n    check_c_compiler_flag(\"\" _GLFW_HAS_DEP)\n    if (_GLFW_HAS_DEP)\n        set(CMAKE_SHARED_LINKER_FLAGS \"-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}\")\n    endif()\n\n    # Compatibility with address space layout randomization (ASLR)\n    set(CMAKE_REQUIRED_FLAGS \"-Wl,--dynamicbase\")\n    check_c_compiler_flag(\"\" _GLFW_HAS_ASLR)\n    if (_GLFW_HAS_ASLR)\n        set(CMAKE_SHARED_LINKER_FLAGS \"-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}\")\n    endif()\n\n    # Compatibility with 64-bit address space layout randomization (ASLR)\n    set(CMAKE_REQUIRED_FLAGS \"-Wl,--high-entropy-va\")\n    check_c_compiler_flag(\"\" _GLFW_HAS_64ASLR)\n    if (_GLFW_HAS_64ASLR)\n        set(CMAKE_SHARED_LINKER_FLAGS \"-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}\")\n    endif()\n\n    # HACK: When building on MinGW, WINVER and UNICODE need to be defined before\n    # the inclusion of stddef.h (by glfw3.h), which is itself included before\n    # win32_platform.h.  We define them here until a saner solution can be found\n    # NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.\n    add_definitions(-DUNICODE -DWINVER=0x0501)\nendif()\n\n#--------------------------------------------------------------------\n# Detect and select backend APIs\n#--------------------------------------------------------------------\nif (WIN32)\n    set(_GLFW_WIN32 1)\n    message(STATUS \"Using Win32 for window creation\")\n\n    if (GLFW_USE_EGL)\n        set(_GLFW_EGL 1)\n        message(STATUS \"Using EGL for context creation\")\n    else()\n        set(_GLFW_WGL 1)\n        message(STATUS \"Using WGL for context creation\")\n    endif()\nelseif (APPLE)\n    set(_GLFW_COCOA 1)\n    message(STATUS \"Using Cocoa for window creation\")\n    set(_GLFW_NSGL 1)\n    message(STATUS \"Using NSGL for context creation\")\nelseif (UNIX)\n    if (GLFW_USE_WAYLAND)\n        set(_GLFW_WAYLAND 1)\n        message(STATUS \"Using Wayland for window creation\")\n    elseif (GLFW_USE_MIR)\n        set(_GLFW_MIR 1)\n        message(STATUS \"Using Mir for window creation\")\n    else()\n        set(_GLFW_X11 1)\n        message(STATUS \"Using X11 for window creation\")\n    endif()\n\n    if (GLFW_USE_EGL)\n        set(_GLFW_EGL 1)\n        message(STATUS \"Using EGL for context creation\")\n    else()\n        set(_GLFW_GLX 1)\n        message(STATUS \"Using GLX for context creation\")\n    endif()\nelse()\n    message(FATAL_ERROR \"No supported platform was detected\")\nendif()\n\n#--------------------------------------------------------------------\n# Find and add Unix math and time libraries\n#--------------------------------------------------------------------\nif (UNIX AND NOT APPLE)\n    find_library(RT_LIBRARY rt)\n    mark_as_advanced(RT_LIBRARY)\n    if (RT_LIBRARY)\n        list(APPEND glfw_LIBRARIES \"${RT_LIBRARY}\")\n        list(APPEND glfw_PKG_LIBS \"-lrt\")\n    endif()\n\n    find_library(MATH_LIBRARY m)\n    mark_as_advanced(MATH_LIBRARY)\n    if (MATH_LIBRARY)\n        list(APPEND glfw_LIBRARIES \"${MATH_LIBRARY}\")\n        list(APPEND glfw_PKG_LIBS \"-lm\")\n    endif()\nendif()\n\n#--------------------------------------------------------------------\n# Use Win32 for window creation\n#--------------------------------------------------------------------\nif (_GLFW_WIN32)\n\n    list(APPEND glfw_PKG_LIBS \"-lgdi32\")\n\n    if (GLFW_USE_HYBRID_HPG)\n        set(_GLFW_USE_HYBRID_HPG 1)\n    endif()\nendif()\n\n#--------------------------------------------------------------------\n# Use WGL for context creation\n#--------------------------------------------------------------------\nif (_GLFW_WGL)\n\n    list(APPEND glfw_PKG_LIBS \"-lopengl32\")\n\n    list(APPEND glfw_INCLUDE_DIRS \"${OPENGL_INCLUDE_DIR}\")\n    list(APPEND glfw_LIBRARIES \"${OPENGL_gl_LIBRARY}\")\nendif()\n\n#--------------------------------------------------------------------\n# Use X11 for window creation\n#--------------------------------------------------------------------\nif (_GLFW_X11)\n\n    find_package(X11 REQUIRED)\n\n    list(APPEND glfw_PKG_DEPS \"x11\")\n\n    # Set up library and include paths\n    list(APPEND glfw_INCLUDE_DIRS \"${X11_X11_INCLUDE_PATH}\")\n    list(APPEND glfw_LIBRARIES \"${X11_X11_LIB}\" \"${CMAKE_THREAD_LIBS_INIT}\")\n\n    # Check for XRandR (modern resolution switching and gamma control)\n    if (NOT X11_Xrandr_FOUND)\n        message(FATAL_ERROR \"The RandR library and headers were not found\")\n    endif()\n\n    list(APPEND glfw_INCLUDE_DIRS \"${X11_Xrandr_INCLUDE_PATH}\")\n    list(APPEND glfw_LIBRARIES \"${X11_Xrandr_LIB}\")\n    list(APPEND glfw_PKG_DEPS \"xrandr\")\n\n    # Check for Xinerama (legacy multi-monitor support)\n    if (NOT X11_Xinerama_FOUND)\n        message(FATAL_ERROR \"The Xinerama library and headers were not found\")\n    endif()\n\n    list(APPEND glfw_INCLUDE_DIRS \"${X11_Xinerama_INCLUDE_PATH}\")\n    list(APPEND glfw_LIBRARIES \"${X11_Xinerama_LIB}\")\n    list(APPEND glfw_PKG_DEPS \"xinerama\")\n\n    # Check for XInput (high-resolution cursor motion)\n    if (X11_Xinput_FOUND)\n        list(APPEND glfw_INCLUDE_DIRS \"${X11_Xinput_INCLUDE_PATH}\")\n        list(APPEND glfw_PKG_DEPS \"xi\")\n\n        if (X11_Xinput_LIB)\n            list(APPEND glfw_LIBRARIES \"${X11_Xinput_LIB}\")\n        else()\n            # Backwards compatibility (bug in CMake 2.8.7)\n            list(APPEND glfw_LIBRARIES Xi)\n        endif()\n\n        set(_GLFW_HAS_XINPUT TRUE)\n    endif()\n\n    # Check for Xf86VidMode (fallback gamma control)\n    if (X11_xf86vmode_FOUND)\n        list(APPEND glfw_INCLUDE_DIRS \"${X11_xf86vmode_INCLUDE_PATH}\")\n        list(APPEND glfw_PKG_DEPS \"xxf86vm\")\n\n        if (X11_Xxf86vm_LIB)\n            list(APPEND glfw_LIBRARIES \"${X11_Xxf86vm_LIB}\")\n        else()\n            # Backwards compatibility (see CMake bug 0006976)\n            list(APPEND glfw_LIBRARIES Xxf86vm)\n        endif()\n\n        set(_GLFW_HAS_XF86VM TRUE)\n    endif()\n\n    # Check for Xkb (X keyboard extension)\n    if (NOT X11_Xkb_FOUND)\n        message(FATAL_ERROR \"The X keyboard extension headers were not found\")\n    endif()\n\n    list(APPEND glfw_INCLUDE_DIR \"${X11_Xkb_INCLUDE_PATH}\")\n\n    # Check for Xcursor\n    if (NOT X11_Xcursor_FOUND)\n        message(FATAL_ERROR \"The Xcursor libraries and headers were not found\")\n    endif()\n\n    list(APPEND glfw_INCLUDE_DIR \"${X11_Xcursor_INCLUDE_PATH}\")\n    list(APPEND glfw_LIBRARIES \"${X11_Xcursor_LIB}\")\n    list(APPEND glfw_PKG_DEPS \"xcursor\")\n\nendif()\n\n#--------------------------------------------------------------------\n# Use Wayland for window creation\n#--------------------------------------------------------------------\nif (_GLFW_WAYLAND)\n    find_package(Wayland REQUIRED)\n    list(APPEND glfw_PKG_DEPS \"wayland-egl\")\n\n    list(APPEND glfw_INCLUDE_DIRS \"${WAYLAND_INCLUDE_DIR}\")\n    list(APPEND glfw_LIBRARIES \"${WAYLAND_LIBRARIES}\" \"${CMAKE_THREAD_LIBS_INIT}\")\n\n    find_package(XKBCommon REQUIRED)\n    list(APPEND glfw_PKG_DEPS \"xkbcommon\")\n    list(APPEND glfw_INCLUDE_DIRS \"${XKBCOMMON_INCLUDE_DIRS}\")\n    list(APPEND glfw_LIBRARIES \"${XKBCOMMON_LIBRARY}\")\nendif()\n\n#--------------------------------------------------------------------\n# Use Mir for window creation\n#--------------------------------------------------------------------\nif (_GLFW_MIR)\n    find_package(Mir REQUIRED)\n    list(APPEND glfw_PKG_DEPS \"mirclient\")\n\n    list(APPEND glfw_INCLUDE_DIRS \"${MIR_INCLUDE_DIR}\")\n    list(APPEND glfw_LIBRARIES \"${MIR_LIBRARIES}\" \"${CMAKE_THREAD_LIBS_INIT}\")\n\n    find_package(XKBCommon REQUIRED)\n    list(APPEND glfw_PKG_DEPS \"xkbcommon\")\n    list(APPEND glfw_INCLUDE_DIRS \"${XKBCOMMON_INCLUDE_DIRS}\")\n    list(APPEND glfw_LIBRARIES \"${XKBCOMMON_LIBRARY}\")\nendif()\n\n#--------------------------------------------------------------------\n# Use GLX for context creation\n#--------------------------------------------------------------------\nif (_GLFW_GLX)\n\n    list(APPEND glfw_INCLUDE_DIRS \"${OPENGL_INCLUDE_DIR}\")\n    list(APPEND glfw_LIBRARIES \"${OPENGL_gl_LIBRARY}\")\n\n    list(APPEND glfw_PKG_DEPS \"gl\")\n\n    if (CMAKE_DL_LIBS)\n        list(APPEND glfw_LIBRARIES \"${CMAKE_DL_LIBS}\")\n        list(APPEND glfw_PKG_LIBS \"-l${CMAKE_DL_LIBS}\")\n    endif()\nendif()\n\n#--------------------------------------------------------------------\n# Use EGL for context creation\n#--------------------------------------------------------------------\nif (_GLFW_EGL)\n\n    list(APPEND glfw_INCLUDE_DIRS \"${EGL_INCLUDE_DIR}\")\n    list(APPEND glfw_LIBRARIES \"${EGL_LIBRARY}\")\n\n    list(APPEND glfw_PKG_DEPS \"egl\")\n\n    if (_GLFW_USE_OPENGL)\n        list(APPEND glfw_LIBRARIES \"${OPENGL_gl_LIBRARY}\")\n        list(APPEND glfw_INCLUDE_DIRS \"${OPENGL_INCLUDE_DIR}\")\n        list(APPEND glfw_PKG_DEPS \"gl\")\n    elseif (_GLFW_USE_GLESV1)\n        list(APPEND glfw_LIBRARIES \"${GLESv1_LIBRARY}\")\n        list(APPEND glfw_INCLUDE_DIRS \"${GLESv1_INCLUDE_DIR}\")\n        list(APPEND glfw_PKG_DEPS \"glesv1_cm\")\n    elseif (_GLFW_USE_GLESV2)\n        list(APPEND glfw_LIBRARIES \"${GLESv2_LIBRARY}\")\n        list(APPEND glfw_INCLUDE_DIRS \"${GLESv2_INCLUDE_DIR}\")\n        list(APPEND glfw_PKG_DEPS \"glesv2\")\n    endif()\n\n    if (CMAKE_DL_LIBS)\n        list(APPEND glfw_LIBRARIES \"${CMAKE_DL_LIBS}\")\n        list(APPEND glfw_PKG_LIBS \"-l${CMAKE_DL_LIBS}\")\n    endif()\n\nendif()\n\n#--------------------------------------------------------------------\n# Use Cocoa for window creation and NSOpenGL for context creation\n#--------------------------------------------------------------------\nif (_GLFW_COCOA AND _GLFW_NSGL)\n\n    if (GLFW_USE_MENUBAR)\n        set(_GLFW_USE_MENUBAR 1)\n    endif()\n\n    if (GLFW_USE_CHDIR)\n        set(_GLFW_USE_CHDIR 1)\n    endif()\n\n    if (GLFW_USE_RETINA)\n        set(_GLFW_USE_RETINA 1)\n    endif()\n\n    if (GLFW_BUILD_UNIVERSAL)\n        message(STATUS \"Building GLFW as Universal Binaries\")\n        set(CMAKE_OSX_ARCHITECTURES i386;x86_64)\n    else()\n        message(STATUS \"Building GLFW only for the native architecture\")\n    endif()\n\n    # Set up library and include paths\n    find_library(COCOA_FRAMEWORK Cocoa)\n    find_library(IOKIT_FRAMEWORK IOKit)\n    find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)\n    find_library(CORE_VIDEO_FRAMEWORK CoreVideo)\n    mark_as_advanced(COCOA_FRAMEWORK\n                     IOKIT_FRAMEWORK\n                     CORE_FOUNDATION_FRAMEWORK\n                     CORE_VIDEO_FRAMEWORK)\n    list(APPEND glfw_LIBRARIES \"${COCOA_FRAMEWORK}\"\n                               \"${OPENGL_gl_LIBRARY}\"\n                               \"${IOKIT_FRAMEWORK}\"\n                               \"${CORE_FOUNDATION_FRAMEWORK}\"\n                               \"${CORE_VIDEO_FRAMEWORK}\")\n\n    set(glfw_PKG_DEPS \"\")\n    set(glfw_PKG_LIBS \"-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo\")\nendif()\n\n#--------------------------------------------------------------------\n# Export GLFW library dependencies\n#--------------------------------------------------------------------\nset(GLFW_LIBRARIES ${glfw_LIBRARIES} CACHE STRING \"Dependencies of GLFW\")\nforeach(arg ${glfw_PKG_DEPS})\n    set(GLFW_PKG_DEPS \"${GLFW_PKG_DEPS} ${arg}\")\nendforeach()\nforeach(arg ${glfw_PKG_LIBS})\n    set(GLFW_PKG_LIBS \"${GLFW_PKG_LIBS} ${arg}\")\nendforeach()\n\n#--------------------------------------------------------------------\n# Choose library output name\n#--------------------------------------------------------------------\nif (BUILD_SHARED_LIBS AND UNIX)\n    # On Unix-like systems, shared libraries can use the soname system.\n    set(GLFW_LIB_NAME glfw)\nelse()\n    set(GLFW_LIB_NAME glfw3)\nendif()\n\n#--------------------------------------------------------------------\n# Create generated files\n#--------------------------------------------------------------------\ninclude(CMakePackageConfigHelpers)\n\nif (UNIX)\n    set(GLFW_CONFIG_PATH \"${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw3/\")\nelse()\n    set(GLFW_CONFIG_PATH \"${CMAKE_INSTALL_PREFIX}/\")\nendif()\n\nconfigure_package_config_file(\"${GLFW_SOURCE_DIR}/src/glfw3Config.cmake.in\"\n                              \"${GLFW_BINARY_DIR}/src/glfw3Config.cmake\"\n                              INSTALL_DESTINATION \"${GLFW_CONFIG_PATH}\"\n                              PATH_VARS CMAKE_INSTALL_PREFIX\n                              NO_CHECK_REQUIRED_COMPONENTS_MACRO)\n\nwrite_basic_package_version_file(\"${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake\" \n                                 VERSION ${GLFW_VERSION_FULL}\n                                 COMPATIBILITY SameMajorVersion)\n\nif (GLFW_BUILD_DOCS)\n    configure_file(\"${GLFW_SOURCE_DIR}/docs/Doxyfile.in\"\n                   \"${GLFW_BINARY_DIR}/docs/Doxyfile\" @ONLY)\nendif()\n\nconfigure_file(\"${GLFW_SOURCE_DIR}/src/glfw_config.h.in\"\n               \"${GLFW_BINARY_DIR}/src/glfw_config.h\" @ONLY)\n\nconfigure_file(\"${GLFW_SOURCE_DIR}/src/glfw3.pc.in\"\n               \"${GLFW_BINARY_DIR}/src/glfw3.pc\" @ONLY)\n\n#--------------------------------------------------------------------\n# Add subdirectories\n#--------------------------------------------------------------------\nadd_subdirectory(src)\n\nif (GLFW_BUILD_EXAMPLES)\n    add_subdirectory(examples)\nendif()\n\nif (GLFW_BUILD_TESTS)\n    add_subdirectory(tests)\nendif()\n\nif (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)\n    add_subdirectory(docs)\nendif()\n\n#--------------------------------------------------------------------\n# Install files other than the library\n# The library is installed by src/CMakeLists.txt\n#--------------------------------------------------------------------\nif (GLFW_INSTALL)\n    install(DIRECTORY include/GLFW DESTINATION include\n            FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)\n\n    install(FILES \"${GLFW_BINARY_DIR}/src/glfw3Config.cmake\"\n                  \"${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake\"\n            DESTINATION lib${LIB_SUFFIX}/cmake/glfw)\n\n    install(EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}/cmake/glfw)\n    install(FILES \"${GLFW_BINARY_DIR}/src/glfw3.pc\"\n            DESTINATION lib${LIB_SUFFIX}/pkgconfig)\n\n    # Only generate this target if no higher-level project already has\n    if (NOT TARGET uninstall)\n        configure_file(\"${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in\"\n                       \"${GLFW_BINARY_DIR}/cmake_uninstall.cmake\" IMMEDIATE @ONLY)\n\n        add_custom_target(uninstall\n                          \"${CMAKE_COMMAND}\" -P\n                          \"${GLFW_BINARY_DIR}/cmake_uninstall.cmake\")\n    endif()\nendif()\n\n"
  },
  {
    "path": "deps/glfw/COPYING.txt",
    "content": "Copyright (c) 2002-2006 Marcus Geelnard\nCopyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n   claim that you wrote the original software. If you use this software\n   in a product, an acknowledgment in the product documentation would\n   be appreciated but is not required.\n\n2. Altered source versions must be plainly marked as such, and must not\n   be misrepresented as being the original software.\n\n3. This notice may not be removed or altered from any source\n   distribution.\n\n"
  },
  {
    "path": "deps/glfw/README.md",
    "content": "# GLFW\n\n## Introduction\n\nGLFW is a free, Open Source, multi-platform library for OpenGL and OpenGL ES\napplication development.  It provides a simple, platform-independent API for\ncreating windows and contexts, reading input, handling events, etc.\n\nVersion 3.1.2 adds fixes for a large number of bugs that together affect all\nsupported platforms, as well as dynamic loading work that simplifies compilation\nand linking.\n\nIf you are new to GLFW, you may find the\n[introductory tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW\n3 useful.  If you have used GLFW 2 in the past, there is a\n[transition guide](http://www.glfw.org/docs/latest/moving.html) for moving to\nthe GLFW 3 API.\n\nNote that a number of source files have been added or renamed in 3.1, which may\nrequire you to update any custom build files you have.\n\n\n## Compiling GLFW\n\nSee the [Compiling GLFW](http://www.glfw.org/docs/latest/compile.html) guide in\nthe GLFW documentation.\n\n\n## Using GLFW\n\nSee the\n[Building programs that use GLFW](http://www.glfw.org/docs/latest/build.html)\nguide in the GLFW documentation.\n\n\n## Reporting bugs\n\nBugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).\nPlease always include the name and version of the OS where the bug occurs and\nthe version of GLFW used.  If you have cloned it, include the commit ID used.\n\nIf it's a build issue, please also include the build log and the name and\nversion of your development environment.\n\nIf it's a context creation issue, please also include the make and model of your\ngraphics card and the version of your driver.\n\nThis will help both us and other people experiencing the same bug.\n\n\n## Dependencies\n\nGLFW bundles a number of dependencies in the `deps/` directory.\n\n - [Khronos extension headers](https://www.opengl.org/registry/) for API\n   extension symbols used by GLFW\n - [getopt\\_port](https://github.com/kimgr/getopt_port/) for examples\n   with command-line options\n - [TinyCThread](https://github.com/tinycthread/tinycthread) for threaded\n   examples\n - An OpenGL 3.2 core loader generated by\n   [glad](https://github.com/Dav1dde/glad) for examples using modern OpenGL\n - [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in\n   examples\n\n\n## Changelog\n\n - Made all client API functions dynamically loaded\n - Changed minimum required CMake version to 2.8.12\n - Replaced GLU with [linmath.h](https://github.com/datenwolf/linmath.h) in\n   example programs\n - Merged all cursor test programs into the `cursor` program\n - Removed all mention of GLU in examples, build files and package dependencies\n - Bugfix: Initialization failed on headless systems\n - Bugfix: The cached current context could get out of sync\n - Bugfix: `glfwIconifyWindow` did not restore the original video mode for full\n           screen windows created with `GLFW_AUTO_ICONIFY`\n - [Win32] Renamed hybrid GPU override compile-time option to\n           `_GLFW_USE_HYBRID_HPG` and added support for AMD PowerXpress systems\n - [Win32] Bugfix: `glfwGetVideoModes` included unusable modes on some systems\n - [Win32] Bugfix: `glfwWaitEvents` would return directly for focused windows in\n                   disabled cursor mode\n - [Cocoa] Bugfix: The cached `NSScreen` for a monitor could get out of sync\n - [Cocoa] Bugfix: The `GLFW_AUTO_ICONIFY` window hint was ignored\n - [Cocoa] Bugfix: Resizing a window to its minimum size would segfault\n - [Cocoa] Bugfix: Creating or showing a window would make its context current\n - [Cocoa] Bugfix: Joysticks connected after `glfwInit` were not detected\n - [Cocoa] Bugfix: Cursor creation failed unless a window had been created.\n - [Cocoa] Bugfix: Window refresh events were not generated by iconification or\n                   restoration\n - [Cocoa] Bugfix: The primary monitor would get reported as disconnected when\n                   entering full screen on a dual-GPU machine with automatic\n                   graphics switching\n - [Cocoa] Bugfix: The original video modes were not restored when the\n                   application was hidden\n - [X11] Bugfix: `glfwInit` would segfault on systems without RandR\n - [X11] Bugfix: The response to `_NET_WM_PING` was sent to the wrong window\n - [X11] Bugfix: Character input via XIM did not work in many cases\n - [X11] Bugfix: No fallback existed for missing `_NET_ACTIVE_WINDOW` support\n - [X11] Bugfix: Some significant window focus events were ignored\n - [X11] Bugfix: The `GLFW_AUTO_ICONIFY` window hint was ignored\n - [X11] Bugfix: The original video mode was not restored on iconification of\n                 full screen windows\n - [X11] Bugfix: `GLFW_ARROW_CURSOR` selected the wrong cursor image\n - [X11] Bugfix: The `GLFW_DECORATED` hint was not ignored for full screen\n - [X11] Bugfix: `glfwWaitEvents` did not handle `EINTR` for `select`\n - [X11] Bugfix: `glfwWaitEvents` could return when no events were available\n - [X11] Bugfix: `XkbGetKeyboard` fails on XWayland\n - [X11] Bugfix: Character input did not work correctly for non-UTF-8 locales\n - [X11] Bugfix: Long input sequences generated by IMEs were discarded\n - [WGL] Made all WGL functions dynamically loaded\n - [WGL] Removed `GLFW_USE_DWM_SWAP_INTERVAL` compile-time option\n - [WGL] Bugfix: Swap interval was ignored when DWM was enabled\n - [WGL] Bugfix: Failure to find a pixel format was reported incorrectly\n - [GLX] Added dependency on `libdl` on systems where it provides `dlopen`\n - [GLX] Made all GLX functions dynamically loaded\n - [GLX] Removed `_GLFW_HAS_GLXGETPROCADDRESS*` and `_GLFW_HAS_DLOPEN`\n         compile-time options\n - [GLX] Bugfix: Failure to find a `GLXFBConfig` was reported incorrectly\n - [EGL] Made all EGL functions dynamically loaded\n - [EGL] Bugfix: `glfwGetProcAddress` did not return the addresses of core\n                 functions\n - [EGL] Bugfix: Failure to find an `EGLConfig` was reported incorrectly\n - [NSGL] Bugfix: Failure to find a pixel format was reported incorrectly\n\n\n## Contact\n\nThe official website for GLFW is [glfw.org](http://www.glfw.org/).  There you\ncan find the latest version of GLFW, as well as news, documentation and other\ninformation about the project.\n\nIf you have questions related to the use of GLFW, we have a\n[support forum](https://sourceforge.net/p/glfw/discussion/247562/), and the IRC\nchannel `#glfw` on [Freenode](http://freenode.net/).\n\nIf you have a bug to report, a patch to submit or a feature you'd like to\nrequest, please file it in the\n[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.\n\nFinally, if you're interested in helping out with the development of GLFW or\nporting it to your favorite platform, join us on GitHub or IRC.\n\n\n## Acknowledgements\n\nGLFW exists because people around the world donated their time and lent their\nskills.\n\n - Bobyshev Alexander\n - artblanc\n - arturo\n - Matt Arsenault\n - Keith Bauer\n - John Bartholomew\n - Niklas Behrens\n - Niklas Bergström\n - Doug Binks\n - blanco\n - Martin Capitanio\n - Chi-kwan Chan\n - Lambert Clara\n - Andrew Corrigan\n - Noel Cower\n - Jarrod Davis\n - Olivier Delannoy\n - Paul R. Deppe\n - Michael Dickens\n - Jonathan Dummer\n - Ralph Eastwood\n - Siavash Eliasi\n - Michael Fogleman\n - Gerald Franz\n - GeO4d\n - Marcus Geelnard\n - Eloi Marín Gratacós\n - Stefan Gustavson\n - Sylvain Hellegouarch\n - Matthew Henry\n - heromyth\n - Lucas Hinderberger\n - Paul Holden\n - Aaron Jacobs\n - Toni Jovanoski\n - Arseny Kapoulkine\n - Osman Keskin\n - Cameron King\n - Peter Knut\n - Eric Larson\n - Robin Leffmann\n - Glenn Lewis\n - Shane Liesegang\n - Eyal Lotem\n - Дмитри Малышев\n - Martins Mozeiko\n - Tristam MacDonald\n - Hans Mackowiak\n - Kyle McDonald\n - David Medlock\n - Bryce Mehring\n - Jonathan Mercier\n - Marcel Metz\n - Jonathan Miller\n - Kenneth Miller\n - Bruce Mitchener\n - Jack Moffitt\n - Jeff Molofee\n - Jon Morton\n - Pierre Moulon\n - Julian Møller\n - Kamil Nowakowski\n - Ozzy\n - Andri Pálsson\n - Peoro\n - Braden Pellett\n - Arturo J. Pérez\n - Emmanuel Gil Peyrot\n - Cyril Pichard\n - Pieroman\n - Jorge Rodriguez\n - Ed Ropple\n - Aleksey Rybalkin\n - Riku Salminen\n - Brandon Schaefer\n - Sebastian Schuberth\n - Matt Sealey\n - SephiRok\n - Steve Sexton\n - Systemcluster\n - Dmitri Shuralyov\n - Daniel Skorupski\n - Bradley Smith\n - Julian Squires\n - Johannes Stein\n - Justin Stoecker\n - Elviss Strazdins\n - Nathan Sweet\n - TTK-Bandit\n - Sergey Tikhomirov\n - A. Tombs\n - Samuli Tuomola\n - urraka\n - Jari Vetoniemi\n - Ricardo Vieira\n - Simon Voordouw\n - Torsten Walluhn\n - Patrick Walton\n - Jay Weisskopf\n - Frank Wille\n - yuriks\n - Santi Zupancic\n - Jonas Ådahl\n - Lasse Öörni\n - All the unmentioned and anonymous contributors in the GLFW community, for bug\n   reports, patches, feedback, testing and encouragement\n\n"
  },
  {
    "path": "deps/glfw/cmake_uninstall.cmake.in",
    "content": "\nif (NOT EXISTS \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\")\n  message(FATAL_ERROR \"Cannot find install manifest: \\\"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\\\"\")\nendif()\n\nfile(READ \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\" files)\nstring(REGEX REPLACE \"\\n\" \";\" files \"${files}\")\n\nforeach (file ${files})\n  message(STATUS \"Uninstalling \\\"$ENV{DESTDIR}${file}\\\"\")\n  if (EXISTS \"$ENV{DESTDIR}${file}\")\n    exec_program(\"@CMAKE_COMMAND@\" ARGS \"-E remove \\\"$ENV{DESTDIR}${file}\\\"\"\n                 OUTPUT_VARIABLE rm_out\n                 RETURN_VALUE rm_retval)\n    if (NOT \"${rm_retval}\" STREQUAL 0)\n      MESSAGE(FATAL_ERROR \"Problem when removing \\\"$ENV{DESTDIR}${file}\\\"\")\n    endif()\n  elseif (IS_SYMLINK \"$ENV{DESTDIR}${file}\")\n    EXEC_PROGRAM(\"@CMAKE_COMMAND@\" ARGS \"-E remove \\\"$ENV{DESTDIR}${file}\\\"\"\n                 OUTPUT_VARIABLE rm_out\n                 RETURN_VALUE rm_retval)\n    if (NOT \"${rm_retval}\" STREQUAL 0)\n      message(FATAL_ERROR \"Problem when removing symlink \\\"$ENV{DESTDIR}${file}\\\"\")\n    endif()\n  else()\n    message(STATUS \"File \\\"$ENV{DESTDIR}${file}\\\" does not exist.\")\n  endif()\nendforeach()\n\n"
  },
  {
    "path": "deps/glfw/deps/EGL/eglext.h",
    "content": "#ifndef __eglext_h_\n#define __eglext_h_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Copyright (c) 2007-2013 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#include <EGL/eglplatform.h>\n\n/*************************************************************/\n\n/* Header file version number */\n/* Current version at http://www.khronos.org/registry/egl/ */\n/* $Revision: 20690 $ on $Date: 2013-02-22 17:15:05 -0800 (Fri, 22 Feb 2013) $ */\n#define EGL_EGLEXT_VERSION 15\n\n#ifndef EGL_KHR_config_attribs\n#define EGL_KHR_config_attribs 1\n#define EGL_CONFORMANT_KHR\t\t\t0x3042\t/* EGLConfig attribute */\n#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR\t0x0020\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR\t\t0x0040\t/* EGL_SURFACE_TYPE bitfield */\n#endif\n\n#ifndef EGL_KHR_lock_surface\n#define EGL_KHR_lock_surface 1\n#define EGL_READ_SURFACE_BIT_KHR\t\t0x0001\t/* EGL_LOCK_USAGE_HINT_KHR bitfield */\n#define EGL_WRITE_SURFACE_BIT_KHR\t\t0x0002\t/* EGL_LOCK_USAGE_HINT_KHR bitfield */\n#define EGL_LOCK_SURFACE_BIT_KHR\t\t0x0080\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_OPTIMAL_FORMAT_BIT_KHR\t\t0x0100\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_MATCH_FORMAT_KHR\t\t\t0x3043\t/* EGLConfig attribute */\n#define EGL_FORMAT_RGB_565_EXACT_KHR\t\t0x30C0\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGB_565_KHR\t\t\t0x30C1\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGBA_8888_EXACT_KHR\t\t0x30C2\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGBA_8888_KHR\t\t0x30C3\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_MAP_PRESERVE_PIXELS_KHR\t\t0x30C4\t/* eglLockSurfaceKHR attribute */\n#define EGL_LOCK_USAGE_HINT_KHR\t\t\t0x30C5\t/* eglLockSurfaceKHR attribute */\n#define EGL_BITMAP_POINTER_KHR\t\t\t0x30C6\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PITCH_KHR\t\t\t0x30C7\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_ORIGIN_KHR\t\t\t0x30C8\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR\t\t0x30C9\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR\t0x30CA\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR\t0x30CB\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR\t0x30CC\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR\t0x30CD\t/* eglQuerySurface attribute */\n#define EGL_LOWER_LEFT_KHR\t\t\t0x30CE\t/* EGL_BITMAP_ORIGIN_KHR value */\n#define EGL_UPPER_LEFT_KHR\t\t\t0x30CF\t/* EGL_BITMAP_ORIGIN_KHR value */\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);\n#endif\n\n#ifndef EGL_KHR_image\n#define EGL_KHR_image 1\n#define EGL_NATIVE_PIXMAP_KHR\t\t\t0x30B0\t/* eglCreateImageKHR target */\ntypedef void *EGLImageKHR;\n#define EGL_NO_IMAGE_KHR\t\t\t((EGLImageKHR)0)\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);\n#endif\n\n#ifndef EGL_KHR_vg_parent_image\n#define EGL_KHR_vg_parent_image 1\n#define EGL_VG_PARENT_IMAGE_KHR\t\t\t0x30BA\t/* eglCreateImageKHR target */\n#endif\n\n#ifndef EGL_KHR_gl_texture_2D_image\n#define EGL_KHR_gl_texture_2D_image 1\n#define EGL_GL_TEXTURE_2D_KHR\t\t\t0x30B1\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_LEVEL_KHR\t\t0x30BC\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_gl_texture_cubemap_image\n#define EGL_KHR_gl_texture_cubemap_image 1\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR\t0x30B3\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR\t0x30B4\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR\t0x30B5\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR\t0x30B6\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR\t0x30B7\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR\t0x30B8\t/* eglCreateImageKHR target */\n#endif\n\n#ifndef EGL_KHR_gl_texture_3D_image\n#define EGL_KHR_gl_texture_3D_image 1\n#define EGL_GL_TEXTURE_3D_KHR\t\t\t0x30B2\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_ZOFFSET_KHR\t\t0x30BD\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_gl_renderbuffer_image\n#define EGL_KHR_gl_renderbuffer_image 1\n#define EGL_GL_RENDERBUFFER_KHR\t\t\t0x30B9\t/* eglCreateImageKHR target */\n#endif\n\n#if KHRONOS_SUPPORT_INT64   /* EGLTimeKHR requires 64-bit uint support */\n#ifndef EGL_KHR_reusable_sync\n#define EGL_KHR_reusable_sync 1\n\ntypedef void* EGLSyncKHR;\ntypedef khronos_utime_nanoseconds_t EGLTimeKHR;\n\n#define EGL_SYNC_STATUS_KHR\t\t\t0x30F1\n#define EGL_SIGNALED_KHR\t\t\t0x30F2\n#define EGL_UNSIGNALED_KHR\t\t\t0x30F3\n#define EGL_TIMEOUT_EXPIRED_KHR\t\t\t0x30F5\n#define EGL_CONDITION_SATISFIED_KHR\t\t0x30F6\n#define EGL_SYNC_TYPE_KHR\t\t\t0x30F7\n#define EGL_SYNC_REUSABLE_KHR\t\t\t0x30FA\n#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR\t\t0x0001\t/* eglClientWaitSyncKHR <flags> bitfield */\n#define EGL_FOREVER_KHR\t\t\t\t0xFFFFFFFFFFFFFFFFull\n#define EGL_NO_SYNC_KHR\t\t\t\t((EGLSyncKHR)0)\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);\nEGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);\nEGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);\nEGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);\ntypedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);\n#endif\n#endif\n\n#ifndef EGL_KHR_image_base\n#define EGL_KHR_image_base 1\n/* Most interfaces defined by EGL_KHR_image_pixmap above */\n#define EGL_IMAGE_PRESERVED_KHR\t\t\t0x30D2\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_image_pixmap\n#define EGL_KHR_image_pixmap 1\n/* Interfaces defined by EGL_KHR_image above */\n#endif\n\n#ifndef EGL_IMG_context_priority\n#define EGL_IMG_context_priority 1\n#define EGL_CONTEXT_PRIORITY_LEVEL_IMG\t\t0x3100\n#define EGL_CONTEXT_PRIORITY_HIGH_IMG\t\t0x3101\n#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG\t\t0x3102\n#define EGL_CONTEXT_PRIORITY_LOW_IMG\t\t0x3103\n#endif\n\n#ifndef EGL_KHR_lock_surface2\n#define EGL_KHR_lock_surface2 1\n#define EGL_BITMAP_PIXEL_SIZE_KHR\t\t0x3110\n#endif\n\n#ifndef EGL_NV_coverage_sample\n#define EGL_NV_coverage_sample 1\n#define EGL_COVERAGE_BUFFERS_NV\t\t\t0x30E0\n#define EGL_COVERAGE_SAMPLES_NV\t\t\t0x30E1\n#endif\n\n#ifndef EGL_NV_depth_nonlinear\n#define EGL_NV_depth_nonlinear 1\n#define EGL_DEPTH_ENCODING_NV\t\t\t0x30E2\n#define EGL_DEPTH_ENCODING_NONE_NV 0\n#define EGL_DEPTH_ENCODING_NONLINEAR_NV\t\t0x30E3\n#endif\n\n#if KHRONOS_SUPPORT_INT64   /* EGLTimeNV requires 64-bit uint support */\n#ifndef EGL_NV_sync\n#define EGL_NV_sync 1\n#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV\t0x30E6\n#define EGL_SYNC_STATUS_NV\t\t\t0x30E7\n#define EGL_SIGNALED_NV\t\t\t\t0x30E8\n#define EGL_UNSIGNALED_NV\t\t\t0x30E9\n#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV\t\t0x0001\n#define EGL_FOREVER_NV\t\t\t\t0xFFFFFFFFFFFFFFFFull\n#define EGL_ALREADY_SIGNALED_NV\t\t\t0x30EA\n#define EGL_TIMEOUT_EXPIRED_NV\t\t\t0x30EB\n#define EGL_CONDITION_SATISFIED_NV\t\t0x30EC\n#define EGL_SYNC_TYPE_NV\t\t\t0x30ED\n#define EGL_SYNC_CONDITION_NV\t\t\t0x30EE\n#define EGL_SYNC_FENCE_NV\t\t\t0x30EF\n#define EGL_NO_SYNC_NV\t\t\t\t((EGLSyncNV)0)\ntypedef void* EGLSyncNV;\ntypedef khronos_utime_nanoseconds_t EGLTimeNV;\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync);\nEGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync);\nEGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);\nEGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode);\nEGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync);\ntypedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value);\n#endif\n#endif\n\n#if KHRONOS_SUPPORT_INT64   /* Dependent on EGL_KHR_reusable_sync which requires 64-bit uint support */\n#ifndef EGL_KHR_fence_sync\n#define EGL_KHR_fence_sync 1\n/* Reuses most tokens and entry points from EGL_KHR_reusable_sync */\n#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR\t0x30F0\n#define EGL_SYNC_CONDITION_KHR\t\t\t0x30F8\n#define EGL_SYNC_FENCE_KHR\t\t\t0x30F9\n#endif\n#endif\n\n#ifndef EGL_HI_clientpixmap\n#define EGL_HI_clientpixmap 1\n\n/* Surface Attribute */\n#define EGL_CLIENT_PIXMAP_POINTER_HI\t\t0x8F74\n/*\n * Structure representing a client pixmap\n * (pixmap's data is in client-space memory).\n */\nstruct EGLClientPixmapHI\n{\n\tvoid*\t\tpData;\n\tEGLint\t\tiWidth;\n\tEGLint\t\tiHeight;\n\tEGLint\t\tiStride;\n};\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI(EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI* pixmap);\n#endif\t/* EGL_HI_clientpixmap */\n\n#ifndef EGL_HI_colorformats\n#define EGL_HI_colorformats 1\n/* Config Attribute */\n#define EGL_COLOR_FORMAT_HI\t\t\t0x8F70\n/* Color Formats */\n#define EGL_COLOR_RGB_HI\t\t\t0x8F71\n#define EGL_COLOR_RGBA_HI\t\t\t0x8F72\n#define EGL_COLOR_ARGB_HI\t\t\t0x8F73\n#endif /* EGL_HI_colorformats */\n\n#ifndef EGL_MESA_drm_image\n#define EGL_MESA_drm_image 1\n#define EGL_DRM_BUFFER_FORMAT_MESA\t\t0x31D0\t    /* CreateDRMImageMESA attribute */\n#define EGL_DRM_BUFFER_USE_MESA\t\t\t0x31D1\t    /* CreateDRMImageMESA attribute */\n#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA\t0x31D2\t    /* EGL_IMAGE_FORMAT_MESA attribute value */\n#define EGL_DRM_BUFFER_MESA\t\t\t0x31D3\t    /* eglCreateImageKHR target */\n#define EGL_DRM_BUFFER_STRIDE_MESA\t\t0x31D4\n#define EGL_DRM_BUFFER_USE_SCANOUT_MESA\t\t0x00000001  /* EGL_DRM_BUFFER_USE_MESA bits */\n#define EGL_DRM_BUFFER_USE_SHARE_MESA\t\t0x00000002  /* EGL_DRM_BUFFER_USE_MESA bits */\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride);\n#endif\n\n#ifndef EGL_NV_post_sub_buffer\n#define EGL_NV_post_sub_buffer 1\n#define EGL_POST_SUB_BUFFER_SUPPORTED_NV\t0x30BE\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height);\n#endif\n\n#ifndef EGL_ANGLE_query_surface_pointer\n#define EGL_ANGLE_query_surface_pointer 1\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean eglQuerySurfacePointerANGLE(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);\n#endif\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);\n#endif\n\n#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle\n#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1\n#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE\t0x3200\n#endif\n\n#ifndef EGL_NV_coverage_sample_resolve\n#define EGL_NV_coverage_sample_resolve 1\n#define EGL_COVERAGE_SAMPLE_RESOLVE_NV\t\t0x3131\n#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV\t0x3132\n#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV\t0x3133\n#endif\n\n#if KHRONOS_SUPPORT_INT64   /* EGLuint64NV requires 64-bit uint support */\n#ifndef EGL_NV_system_time\n#define EGL_NV_system_time 1\ntypedef khronos_utime_nanoseconds_t EGLuint64NV;\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);\nEGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void);\ntypedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void);\n#endif\n#endif\n\n#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */\n#ifndef EGL_KHR_stream\n#define EGL_KHR_stream 1\ntypedef void* EGLStreamKHR;\ntypedef khronos_uint64_t EGLuint64KHR;\n#define EGL_NO_STREAM_KHR\t\t\t((EGLStreamKHR)0)\n#define EGL_CONSUMER_LATENCY_USEC_KHR\t\t0x3210\n#define EGL_PRODUCER_FRAME_KHR\t\t\t0x3212\n#define EGL_CONSUMER_FRAME_KHR\t\t\t0x3213\n#define EGL_STREAM_STATE_KHR\t\t\t0x3214\n#define EGL_STREAM_STATE_CREATED_KHR\t\t0x3215\n#define EGL_STREAM_STATE_CONNECTING_KHR\t\t0x3216\n#define EGL_STREAM_STATE_EMPTY_KHR\t\t0x3217\n#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR    0x3218\n#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR    0x3219\n#define EGL_STREAM_STATE_DISCONNECTED_KHR\t0x321A\n#define EGL_BAD_STREAM_KHR\t\t\t0x321B\n#define EGL_BAD_STATE_KHR\t\t\t0x321C\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream);\nEGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value);\n#endif\n#endif\n\n#ifdef EGL_KHR_stream /* Requires KHR_stream extension */\n#ifndef EGL_KHR_stream_consumer_gltexture\n#define EGL_KHR_stream_consumer_gltexture 1\n#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR\t0x321E\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream);\nEGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream);\nEGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);\n#endif\n#endif\n\n#ifdef EGL_KHR_stream /* Requires KHR_stream extension */\n#ifndef EGL_KHR_stream_producer_eglsurface\n#define EGL_KHR_stream_producer_eglsurface 1\n#define EGL_STREAM_BIT_KHR\t\t\t0x0800\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list);\n#endif\n#endif\n\n#ifdef EGL_KHR_stream /* Requires KHR_stream extension */\n#ifndef EGL_KHR_stream_producer_aldatalocator\n#define EGL_KHR_stream_producer_aldatalocator 1\n#endif\n#endif\n\n#ifdef EGL_KHR_stream /* Requires KHR_stream extension */\n#ifndef EGL_KHR_stream_fifo\n#define EGL_KHR_stream_fifo 1\n/* reuse EGLTimeKHR */\n#define EGL_STREAM_FIFO_LENGTH_KHR\t\t0x31FC\n#define EGL_STREAM_TIME_NOW_KHR\t\t\t0x31FD\n#define EGL_STREAM_TIME_CONSUMER_KHR\t\t0x31FE\n#define EGL_STREAM_TIME_PRODUCER_KHR\t\t0x31FF\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value);\n#endif\n#endif\n\n#ifndef EGL_EXT_create_context_robustness\n#define EGL_EXT_create_context_robustness 1\n#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT\t0x30BF\n#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138\n#define EGL_NO_RESET_NOTIFICATION_EXT\t\t0x31BE\n#define EGL_LOSE_CONTEXT_ON_RESET_EXT\t\t0x31BF\n#endif\n\n#ifndef EGL_ANGLE_d3d_share_handle_client_buffer\n#define EGL_ANGLE_d3d_share_handle_client_buffer 1\n/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */\n#endif\n\n#ifndef EGL_KHR_create_context\n#define EGL_KHR_create_context 1\n#define EGL_CONTEXT_MAJOR_VERSION_KHR\t\t\t    EGL_CONTEXT_CLIENT_VERSION\n#define EGL_CONTEXT_MINOR_VERSION_KHR\t\t\t    0x30FB\n#define EGL_CONTEXT_FLAGS_KHR\t\t\t\t    0x30FC\n#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR\t\t    0x30FD\n#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR  0x31BD\n#define EGL_NO_RESET_NOTIFICATION_KHR\t\t\t    0x31BE\n#define EGL_LOSE_CONTEXT_ON_RESET_KHR\t\t\t    0x31BF\n#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR\t\t    0x00000001\n#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR\t    0x00000002\n#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR\t    0x00000004\n#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR\t\t    0x00000001\n#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR    0x00000002\n#define EGL_OPENGL_ES3_BIT_KHR\t\t\t\t    0x00000040\n#endif\n\n#ifndef EGL_KHR_surfaceless_context\n#define EGL_KHR_surfaceless_context 1\n/* No tokens/entry points, just relaxes an error condition */\n#endif\n\n#ifdef EGL_KHR_stream /* Requires KHR_stream extension */\n#ifndef EGL_KHR_stream_cross_process_fd\n#define EGL_KHR_stream_cross_process_fd 1\ntypedef int EGLNativeFileDescriptorKHR;\n#define EGL_NO_FILE_DESCRIPTOR_KHR\t\t((EGLNativeFileDescriptorKHR)(-1))\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);\nEGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream);\ntypedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);\n#endif\n#endif\n\n#ifndef EGL_EXT_multiview_window\n#define EGL_EXT_multiview_window 1\n#define EGL_MULTIVIEW_VIEW_COUNT_EXT\t\t0x3134\n#endif\n\n#ifndef EGL_KHR_wait_sync\n#define EGL_KHR_wait_sync 1\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);\n#endif\n\n#ifndef EGL_NV_post_convert_rounding\n#define EGL_NV_post_convert_rounding 1\n/* No tokens or entry points, just relaxes behavior of SwapBuffers */\n#endif\n\n#ifndef EGL_NV_native_query\n#define EGL_NV_native_query 1\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap);\n#endif\n\n#ifndef EGL_NV_3dvision_surface\n#define EGL_NV_3dvision_surface 1\n#define EGL_AUTO_STEREO_NV\t\t\t0x3136\n#endif\n\n#ifndef EGL_ANDROID_framebuffer_target\n#define EGL_ANDROID_framebuffer_target 1\n#define EGL_FRAMEBUFFER_TARGET_ANDROID\t\t0x3147\n#endif\n\n#ifndef EGL_ANDROID_blob_cache\n#define EGL_ANDROID_blob_cache 1\ntypedef khronos_ssize_t EGLsizeiANDROID;\ntypedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);\ntypedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get);\n#endif\n\n#ifndef EGL_ANDROID_image_native_buffer\n#define EGL_ANDROID_image_native_buffer 1\n#define EGL_NATIVE_BUFFER_ANDROID\t\t0x3140\n#endif\n\n#ifndef EGL_ANDROID_native_fence_sync\n#define EGL_ANDROID_native_fence_sync 1\n#define EGL_SYNC_NATIVE_FENCE_ANDROID\t\t0x3144\n#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID\t0x3145\n#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID\t0x3146\n#define EGL_NO_NATIVE_FENCE_FD_ANDROID\t\t-1\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR);\n#endif\n\n#ifndef EGL_ANDROID_recordable\n#define EGL_ANDROID_recordable 1\n#define EGL_RECORDABLE_ANDROID\t\t\t0x3142\n#endif\n\n#ifndef EGL_EXT_buffer_age\n#define EGL_EXT_buffer_age 1\n#define EGL_BUFFER_AGE_EXT\t\t\t0x313D\n#endif\n\n#ifndef EGL_EXT_image_dma_buf_import\n#define EGL_EXT_image_dma_buf_import 1\n#define EGL_LINUX_DMA_BUF_EXT\t\t\t0x3270\n#define EGL_LINUX_DRM_FOURCC_EXT\t\t0x3271\n#define EGL_DMA_BUF_PLANE0_FD_EXT\t\t0x3272\n#define EGL_DMA_BUF_PLANE0_OFFSET_EXT\t\t0x3273\n#define EGL_DMA_BUF_PLANE0_PITCH_EXT\t\t0x3274\n#define EGL_DMA_BUF_PLANE1_FD_EXT\t\t0x3275\n#define EGL_DMA_BUF_PLANE1_OFFSET_EXT\t\t0x3276\n#define EGL_DMA_BUF_PLANE1_PITCH_EXT\t\t0x3277\n#define EGL_DMA_BUF_PLANE2_FD_EXT\t\t0x3278\n#define EGL_DMA_BUF_PLANE2_OFFSET_EXT\t\t0x3279\n#define EGL_DMA_BUF_PLANE2_PITCH_EXT\t\t0x327A\n#define EGL_YUV_COLOR_SPACE_HINT_EXT\t\t0x327B\n#define EGL_SAMPLE_RANGE_HINT_EXT\t\t0x327C\n#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D\n#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E\n#define EGL_ITU_REC601_EXT\t\t\t0x327F\n#define EGL_ITU_REC709_EXT\t\t\t0x3280\n#define EGL_ITU_REC2020_EXT\t\t\t0x3281\n#define EGL_YUV_FULL_RANGE_EXT\t\t\t0x3282\n#define EGL_YUV_NARROW_RANGE_EXT\t\t0x3283\n#define EGL_YUV_CHROMA_SITING_0_EXT\t\t0x3284\n#define EGL_YUV_CHROMA_SITING_0_5_EXT\t\t0x3285\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __eglext_h_ */\n"
  },
  {
    "path": "deps/glfw/deps/GL/glext.h",
    "content": "#ifndef __glext_h_\n#define __glext_h_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Copyright (c) 2013-2014 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n/*\n** This header is generated from the Khronos OpenGL / OpenGL ES XML\n** API Registry. The current version of the Registry, generator scripts\n** used to make the header, and the header can be found at\n**   http://www.opengl.org/registry/\n**\n** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $\n*/\n\n#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN 1\n#endif\n#include <windows.h>\n#endif\n\n#ifndef APIENTRY\n#define APIENTRY\n#endif\n#ifndef APIENTRYP\n#define APIENTRYP APIENTRY *\n#endif\n#ifndef GLAPI\n#define GLAPI extern\n#endif\n\n#define GL_GLEXT_VERSION 20140810\n\n/* Generated C header for:\n * API: gl\n * Profile: compatibility\n * Versions considered: .*\n * Versions emitted: 1\\.[2-9]|[234]\\.[0-9]\n * Default extensions included: gl\n * Additional extensions included: _nomatch_^\n * Extensions removed: _nomatch_^\n */\n\n#ifndef GL_VERSION_1_2\n#define GL_VERSION_1_2 1\n#define GL_UNSIGNED_BYTE_3_3_2            0x8032\n#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034\n#define GL_UNSIGNED_INT_8_8_8_8           0x8035\n#define GL_UNSIGNED_INT_10_10_10_2        0x8036\n#define GL_TEXTURE_BINDING_3D             0x806A\n#define GL_PACK_SKIP_IMAGES               0x806B\n#define GL_PACK_IMAGE_HEIGHT              0x806C\n#define GL_UNPACK_SKIP_IMAGES             0x806D\n#define GL_UNPACK_IMAGE_HEIGHT            0x806E\n#define GL_TEXTURE_3D                     0x806F\n#define GL_PROXY_TEXTURE_3D               0x8070\n#define GL_TEXTURE_DEPTH                  0x8071\n#define GL_TEXTURE_WRAP_R                 0x8072\n#define GL_MAX_3D_TEXTURE_SIZE            0x8073\n#define GL_UNSIGNED_BYTE_2_3_3_REV        0x8362\n#define GL_UNSIGNED_SHORT_5_6_5           0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV       0x8364\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV     0x8365\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV     0x8366\n#define GL_UNSIGNED_INT_8_8_8_8_REV       0x8367\n#define GL_UNSIGNED_INT_2_10_10_10_REV    0x8368\n#define GL_BGR                            0x80E0\n#define GL_BGRA                           0x80E1\n#define GL_MAX_ELEMENTS_VERTICES          0x80E8\n#define GL_MAX_ELEMENTS_INDICES           0x80E9\n#define GL_CLAMP_TO_EDGE                  0x812F\n#define GL_TEXTURE_MIN_LOD                0x813A\n#define GL_TEXTURE_MAX_LOD                0x813B\n#define GL_TEXTURE_BASE_LEVEL             0x813C\n#define GL_TEXTURE_MAX_LEVEL              0x813D\n#define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY  0x0B13\n#define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY  0x0B23\n#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E\n#define GL_RESCALE_NORMAL                 0x803A\n#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8\n#define GL_SINGLE_COLOR                   0x81F9\n#define GL_SEPARATE_SPECULAR_COLOR        0x81FA\n#define GL_ALIASED_POINT_SIZE_RANGE       0x846D\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\nGLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#endif\n#endif /* GL_VERSION_1_2 */\n\n#ifndef GL_VERSION_1_3\n#define GL_VERSION_1_3 1\n#define GL_TEXTURE0                       0x84C0\n#define GL_TEXTURE1                       0x84C1\n#define GL_TEXTURE2                       0x84C2\n#define GL_TEXTURE3                       0x84C3\n#define GL_TEXTURE4                       0x84C4\n#define GL_TEXTURE5                       0x84C5\n#define GL_TEXTURE6                       0x84C6\n#define GL_TEXTURE7                       0x84C7\n#define GL_TEXTURE8                       0x84C8\n#define GL_TEXTURE9                       0x84C9\n#define GL_TEXTURE10                      0x84CA\n#define GL_TEXTURE11                      0x84CB\n#define GL_TEXTURE12                      0x84CC\n#define GL_TEXTURE13                      0x84CD\n#define GL_TEXTURE14                      0x84CE\n#define GL_TEXTURE15                      0x84CF\n#define GL_TEXTURE16                      0x84D0\n#define GL_TEXTURE17                      0x84D1\n#define GL_TEXTURE18                      0x84D2\n#define GL_TEXTURE19                      0x84D3\n#define GL_TEXTURE20                      0x84D4\n#define GL_TEXTURE21                      0x84D5\n#define GL_TEXTURE22                      0x84D6\n#define GL_TEXTURE23                      0x84D7\n#define GL_TEXTURE24                      0x84D8\n#define GL_TEXTURE25                      0x84D9\n#define GL_TEXTURE26                      0x84DA\n#define GL_TEXTURE27                      0x84DB\n#define GL_TEXTURE28                      0x84DC\n#define GL_TEXTURE29                      0x84DD\n#define GL_TEXTURE30                      0x84DE\n#define GL_TEXTURE31                      0x84DF\n#define GL_ACTIVE_TEXTURE                 0x84E0\n#define GL_MULTISAMPLE                    0x809D\n#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE            0x809F\n#define GL_SAMPLE_COVERAGE                0x80A0\n#define GL_SAMPLE_BUFFERS                 0x80A8\n#define GL_SAMPLES                        0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE          0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT         0x80AB\n#define GL_TEXTURE_CUBE_MAP               0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP       0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X    0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y    0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z    0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP         0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C\n#define GL_COMPRESSED_RGB                 0x84ED\n#define GL_COMPRESSED_RGBA                0x84EE\n#define GL_TEXTURE_COMPRESSION_HINT       0x84EF\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE  0x86A0\n#define GL_TEXTURE_COMPRESSED             0x86A1\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3\n#define GL_CLAMP_TO_BORDER                0x812D\n#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1\n#define GL_MAX_TEXTURE_UNITS              0x84E2\n#define GL_TRANSPOSE_MODELVIEW_MATRIX     0x84E3\n#define GL_TRANSPOSE_PROJECTION_MATRIX    0x84E4\n#define GL_TRANSPOSE_TEXTURE_MATRIX       0x84E5\n#define GL_TRANSPOSE_COLOR_MATRIX         0x84E6\n#define GL_MULTISAMPLE_BIT                0x20000000\n#define GL_NORMAL_MAP                     0x8511\n#define GL_REFLECTION_MAP                 0x8512\n#define GL_COMPRESSED_ALPHA               0x84E9\n#define GL_COMPRESSED_LUMINANCE           0x84EA\n#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB\n#define GL_COMPRESSED_INTENSITY           0x84EC\n#define GL_COMBINE                        0x8570\n#define GL_COMBINE_RGB                    0x8571\n#define GL_COMBINE_ALPHA                  0x8572\n#define GL_SOURCE0_RGB                    0x8580\n#define GL_SOURCE1_RGB                    0x8581\n#define GL_SOURCE2_RGB                    0x8582\n#define GL_SOURCE0_ALPHA                  0x8588\n#define GL_SOURCE1_ALPHA                  0x8589\n#define GL_SOURCE2_ALPHA                  0x858A\n#define GL_OPERAND0_RGB                   0x8590\n#define GL_OPERAND1_RGB                   0x8591\n#define GL_OPERAND2_RGB                   0x8592\n#define GL_OPERAND0_ALPHA                 0x8598\n#define GL_OPERAND1_ALPHA                 0x8599\n#define GL_OPERAND2_ALPHA                 0x859A\n#define GL_RGB_SCALE                      0x8573\n#define GL_ADD_SIGNED                     0x8574\n#define GL_INTERPOLATE                    0x8575\n#define GL_SUBTRACT                       0x84E7\n#define GL_CONSTANT                       0x8576\n#define GL_PRIMARY_COLOR                  0x8577\n#define GL_PREVIOUS                       0x8578\n#define GL_DOT3_RGB                       0x86AE\n#define GL_DOT3_RGBA                      0x86AF\ntypedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);\ntypedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);\ntypedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);\ntypedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);\ntypedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glActiveTexture (GLenum texture);\nGLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);\nGLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img);\nGLAPI void APIENTRY glClientActiveTexture (GLenum texture);\nGLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s);\nGLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s);\nGLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s);\nGLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s);\nGLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t);\nGLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t);\nGLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t);\nGLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t);\nGLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r);\nGLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r);\nGLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r);\nGLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r);\nGLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nGLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nGLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q);\nGLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\nGLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m);\nGLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m);\nGLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m);\nGLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m);\n#endif\n#endif /* GL_VERSION_1_3 */\n\n#ifndef GL_VERSION_1_4\n#define GL_VERSION_1_4 1\n#define GL_BLEND_DST_RGB                  0x80C8\n#define GL_BLEND_SRC_RGB                  0x80C9\n#define GL_BLEND_DST_ALPHA                0x80CA\n#define GL_BLEND_SRC_ALPHA                0x80CB\n#define GL_POINT_FADE_THRESHOLD_SIZE      0x8128\n#define GL_DEPTH_COMPONENT16              0x81A5\n#define GL_DEPTH_COMPONENT24              0x81A6\n#define GL_DEPTH_COMPONENT32              0x81A7\n#define GL_MIRRORED_REPEAT                0x8370\n#define GL_MAX_TEXTURE_LOD_BIAS           0x84FD\n#define GL_TEXTURE_LOD_BIAS               0x8501\n#define GL_INCR_WRAP                      0x8507\n#define GL_DECR_WRAP                      0x8508\n#define GL_TEXTURE_DEPTH_SIZE             0x884A\n#define GL_TEXTURE_COMPARE_MODE           0x884C\n#define GL_TEXTURE_COMPARE_FUNC           0x884D\n#define GL_POINT_SIZE_MIN                 0x8126\n#define GL_POINT_SIZE_MAX                 0x8127\n#define GL_POINT_DISTANCE_ATTENUATION     0x8129\n#define GL_GENERATE_MIPMAP                0x8191\n#define GL_GENERATE_MIPMAP_HINT           0x8192\n#define GL_FOG_COORDINATE_SOURCE          0x8450\n#define GL_FOG_COORDINATE                 0x8451\n#define GL_FRAGMENT_DEPTH                 0x8452\n#define GL_CURRENT_FOG_COORDINATE         0x8453\n#define GL_FOG_COORDINATE_ARRAY_TYPE      0x8454\n#define GL_FOG_COORDINATE_ARRAY_STRIDE    0x8455\n#define GL_FOG_COORDINATE_ARRAY_POINTER   0x8456\n#define GL_FOG_COORDINATE_ARRAY           0x8457\n#define GL_COLOR_SUM                      0x8458\n#define GL_CURRENT_SECONDARY_COLOR        0x8459\n#define GL_SECONDARY_COLOR_ARRAY_SIZE     0x845A\n#define GL_SECONDARY_COLOR_ARRAY_TYPE     0x845B\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE   0x845C\n#define GL_SECONDARY_COLOR_ARRAY_POINTER  0x845D\n#define GL_SECONDARY_COLOR_ARRAY          0x845E\n#define GL_TEXTURE_FILTER_CONTROL         0x8500\n#define GL_DEPTH_TEXTURE_MODE             0x884B\n#define GL_COMPARE_R_TO_TEXTURE           0x884E\n#define GL_FUNC_ADD                       0x8006\n#define GL_FUNC_SUBTRACT                  0x800A\n#define GL_FUNC_REVERSE_SUBTRACT          0x800B\n#define GL_MIN                            0x8007\n#define GL_MAX                            0x8008\n#define GL_CONSTANT_COLOR                 0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002\n#define GL_CONSTANT_ALPHA                 0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\nGLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);\nGLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);\nGLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param);\nGLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params);\nGLAPI void APIENTRY glFogCoordf (GLfloat coord);\nGLAPI void APIENTRY glFogCoordfv (const GLfloat *coord);\nGLAPI void APIENTRY glFogCoordd (GLdouble coord);\nGLAPI void APIENTRY glFogCoorddv (const GLdouble *coord);\nGLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue);\nGLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v);\nGLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue);\nGLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v);\nGLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue);\nGLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v);\nGLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue);\nGLAPI void APIENTRY glSecondaryColor3iv (const GLint *v);\nGLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue);\nGLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v);\nGLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue);\nGLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v);\nGLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue);\nGLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v);\nGLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue);\nGLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v);\nGLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y);\nGLAPI void APIENTRY glWindowPos2dv (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y);\nGLAPI void APIENTRY glWindowPos2fv (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos2i (GLint x, GLint y);\nGLAPI void APIENTRY glWindowPos2iv (const GLint *v);\nGLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y);\nGLAPI void APIENTRY glWindowPos2sv (const GLshort *v);\nGLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glWindowPos3dv (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glWindowPos3fv (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glWindowPos3iv (const GLint *v);\nGLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glWindowPos3sv (const GLshort *v);\nGLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\nGLAPI void APIENTRY glBlendEquation (GLenum mode);\n#endif\n#endif /* GL_VERSION_1_4 */\n\n#ifndef GL_VERSION_1_5\n#define GL_VERSION_1_5 1\n#include <stddef.h>\ntypedef ptrdiff_t GLsizeiptr;\ntypedef ptrdiff_t GLintptr;\n#define GL_BUFFER_SIZE                    0x8764\n#define GL_BUFFER_USAGE                   0x8765\n#define GL_QUERY_COUNTER_BITS             0x8864\n#define GL_CURRENT_QUERY                  0x8865\n#define GL_QUERY_RESULT                   0x8866\n#define GL_QUERY_RESULT_AVAILABLE         0x8867\n#define GL_ARRAY_BUFFER                   0x8892\n#define GL_ELEMENT_ARRAY_BUFFER           0x8893\n#define GL_ARRAY_BUFFER_BINDING           0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING   0x8895\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_READ_ONLY                      0x88B8\n#define GL_WRITE_ONLY                     0x88B9\n#define GL_READ_WRITE                     0x88BA\n#define GL_BUFFER_ACCESS                  0x88BB\n#define GL_BUFFER_MAPPED                  0x88BC\n#define GL_BUFFER_MAP_POINTER             0x88BD\n#define GL_STREAM_DRAW                    0x88E0\n#define GL_STREAM_READ                    0x88E1\n#define GL_STREAM_COPY                    0x88E2\n#define GL_STATIC_DRAW                    0x88E4\n#define GL_STATIC_READ                    0x88E5\n#define GL_STATIC_COPY                    0x88E6\n#define GL_DYNAMIC_DRAW                   0x88E8\n#define GL_DYNAMIC_READ                   0x88E9\n#define GL_DYNAMIC_COPY                   0x88EA\n#define GL_SAMPLES_PASSED                 0x8914\n#define GL_SRC1_ALPHA                     0x8589\n#define GL_VERTEX_ARRAY_BUFFER_BINDING    0x8896\n#define GL_NORMAL_ARRAY_BUFFER_BINDING    0x8897\n#define GL_COLOR_ARRAY_BUFFER_BINDING     0x8898\n#define GL_INDEX_ARRAY_BUFFER_BINDING     0x8899\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING    0x889E\n#define GL_FOG_COORD_SRC                  0x8450\n#define GL_FOG_COORD                      0x8451\n#define GL_CURRENT_FOG_COORD              0x8453\n#define GL_FOG_COORD_ARRAY_TYPE           0x8454\n#define GL_FOG_COORD_ARRAY_STRIDE         0x8455\n#define GL_FOG_COORD_ARRAY_POINTER        0x8456\n#define GL_FOG_COORD_ARRAY                0x8457\n#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D\n#define GL_SRC0_RGB                       0x8580\n#define GL_SRC1_RGB                       0x8581\n#define GL_SRC2_RGB                       0x8582\n#define GL_SRC0_ALPHA                     0x8588\n#define GL_SRC2_ALPHA                     0x858A\ntypedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);\ntypedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);\ntypedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);\ntypedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);\ntypedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);\ntypedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);\ntypedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage);\ntypedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);\ntypedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data);\ntypedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);\ntypedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids);\nGLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids);\nGLAPI GLboolean APIENTRY glIsQuery (GLuint id);\nGLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id);\nGLAPI void APIENTRY glEndQuery (GLenum target);\nGLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);\nGLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);\nGLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);\nGLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer);\nGLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);\nGLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);\nGLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data);\nGLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access);\nGLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target);\nGLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params);\n#endif\n#endif /* GL_VERSION_1_5 */\n\n#ifndef GL_VERSION_2_0\n#define GL_VERSION_2_0 1\ntypedef char GLchar;\n#define GL_BLEND_EQUATION_RGB             0x8009\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED    0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE       0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE     0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE       0x8625\n#define GL_CURRENT_VERTEX_ATTRIB          0x8626\n#define GL_VERTEX_PROGRAM_POINT_SIZE      0x8642\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER    0x8645\n#define GL_STENCIL_BACK_FUNC              0x8800\n#define GL_STENCIL_BACK_FAIL              0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL   0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS   0x8803\n#define GL_MAX_DRAW_BUFFERS               0x8824\n#define GL_DRAW_BUFFER0                   0x8825\n#define GL_DRAW_BUFFER1                   0x8826\n#define GL_DRAW_BUFFER2                   0x8827\n#define GL_DRAW_BUFFER3                   0x8828\n#define GL_DRAW_BUFFER4                   0x8829\n#define GL_DRAW_BUFFER5                   0x882A\n#define GL_DRAW_BUFFER6                   0x882B\n#define GL_DRAW_BUFFER7                   0x882C\n#define GL_DRAW_BUFFER8                   0x882D\n#define GL_DRAW_BUFFER9                   0x882E\n#define GL_DRAW_BUFFER10                  0x882F\n#define GL_DRAW_BUFFER11                  0x8830\n#define GL_DRAW_BUFFER12                  0x8831\n#define GL_DRAW_BUFFER13                  0x8832\n#define GL_DRAW_BUFFER14                  0x8833\n#define GL_DRAW_BUFFER15                  0x8834\n#define GL_BLEND_EQUATION_ALPHA           0x883D\n#define GL_MAX_VERTEX_ATTRIBS             0x8869\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_MAX_TEXTURE_IMAGE_UNITS        0x8872\n#define GL_FRAGMENT_SHADER                0x8B30\n#define GL_VERTEX_SHADER                  0x8B31\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS  0x8B4A\n#define GL_MAX_VARYING_FLOATS             0x8B4B\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_SHADER_TYPE                    0x8B4F\n#define GL_FLOAT_VEC2                     0x8B50\n#define GL_FLOAT_VEC3                     0x8B51\n#define GL_FLOAT_VEC4                     0x8B52\n#define GL_INT_VEC2                       0x8B53\n#define GL_INT_VEC3                       0x8B54\n#define GL_INT_VEC4                       0x8B55\n#define GL_BOOL                           0x8B56\n#define GL_BOOL_VEC2                      0x8B57\n#define GL_BOOL_VEC3                      0x8B58\n#define GL_BOOL_VEC4                      0x8B59\n#define GL_FLOAT_MAT2                     0x8B5A\n#define GL_FLOAT_MAT3                     0x8B5B\n#define GL_FLOAT_MAT4                     0x8B5C\n#define GL_SAMPLER_1D                     0x8B5D\n#define GL_SAMPLER_2D                     0x8B5E\n#define GL_SAMPLER_3D                     0x8B5F\n#define GL_SAMPLER_CUBE                   0x8B60\n#define GL_SAMPLER_1D_SHADOW              0x8B61\n#define GL_SAMPLER_2D_SHADOW              0x8B62\n#define GL_DELETE_STATUS                  0x8B80\n#define GL_COMPILE_STATUS                 0x8B81\n#define GL_LINK_STATUS                    0x8B82\n#define GL_VALIDATE_STATUS                0x8B83\n#define GL_INFO_LOG_LENGTH                0x8B84\n#define GL_ATTACHED_SHADERS               0x8B85\n#define GL_ACTIVE_UNIFORMS                0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH      0x8B87\n#define GL_SHADER_SOURCE_LENGTH           0x8B88\n#define GL_ACTIVE_ATTRIBUTES              0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH    0x8B8A\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_SHADING_LANGUAGE_VERSION       0x8B8C\n#define GL_CURRENT_PROGRAM                0x8B8D\n#define GL_POINT_SPRITE_COORD_ORIGIN      0x8CA0\n#define GL_LOWER_LEFT                     0x8CA1\n#define GL_UPPER_LEFT                     0x8CA2\n#define GL_STENCIL_BACK_REF               0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK         0x8CA5\n#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643\n#define GL_POINT_SPRITE                   0x8861\n#define GL_COORD_REPLACE                  0x8862\n#define GL_MAX_TEXTURE_COORDS             0x8871\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);\ntypedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);\ntypedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\ntypedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask);\ntypedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);\ntypedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);\ntypedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);\ntypedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);\ntypedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);\ntypedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);\ntypedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);\ntypedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);\ntypedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);\ntypedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);\ntypedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\ntypedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);\ntypedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\ntypedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\ntypedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);\ntypedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer);\ntypedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);\ntypedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);\ntypedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);\ntypedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);\ntypedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);\ntypedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);\nGLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);\nGLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\nGLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);\nGLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);\nGLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);\nGLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);\nGLAPI void APIENTRY glCompileShader (GLuint shader);\nGLAPI GLuint APIENTRY glCreateProgram (void);\nGLAPI GLuint APIENTRY glCreateShader (GLenum type);\nGLAPI void APIENTRY glDeleteProgram (GLuint program);\nGLAPI void APIENTRY glDeleteShader (GLuint shader);\nGLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);\nGLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);\nGLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);\nGLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\nGLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);\nGLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);\nGLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nGLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nGLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);\nGLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);\nGLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);\nGLAPI GLboolean APIENTRY glIsProgram (GLuint program);\nGLAPI GLboolean APIENTRY glIsShader (GLuint shader);\nGLAPI void APIENTRY glLinkProgram (GLuint program);\nGLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);\nGLAPI void APIENTRY glUseProgram (GLuint program);\nGLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0);\nGLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);\nGLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nGLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nGLAPI void APIENTRY glUniform1i (GLint location, GLint v0);\nGLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);\nGLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);\nGLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nGLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glValidateProgram (GLuint program);\nGLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x);\nGLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);\nGLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x);\nGLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);\nGLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y);\nGLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\nGLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_VERSION_2_0 */\n\n#ifndef GL_VERSION_2_1\n#define GL_VERSION_2_1 1\n#define GL_PIXEL_PACK_BUFFER              0x88EB\n#define GL_PIXEL_UNPACK_BUFFER            0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING      0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING    0x88EF\n#define GL_FLOAT_MAT2x3                   0x8B65\n#define GL_FLOAT_MAT2x4                   0x8B66\n#define GL_FLOAT_MAT3x2                   0x8B67\n#define GL_FLOAT_MAT3x4                   0x8B68\n#define GL_FLOAT_MAT4x2                   0x8B69\n#define GL_FLOAT_MAT4x3                   0x8B6A\n#define GL_SRGB                           0x8C40\n#define GL_SRGB8                          0x8C41\n#define GL_SRGB_ALPHA                     0x8C42\n#define GL_SRGB8_ALPHA8                   0x8C43\n#define GL_COMPRESSED_SRGB                0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA          0x8C49\n#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F\n#define GL_SLUMINANCE_ALPHA               0x8C44\n#define GL_SLUMINANCE8_ALPHA8             0x8C45\n#define GL_SLUMINANCE                     0x8C46\n#define GL_SLUMINANCE8                    0x8C47\n#define GL_COMPRESSED_SLUMINANCE          0x8C4A\n#define GL_COMPRESSED_SLUMINANCE_ALPHA    0x8C4B\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\n#endif\n#endif /* GL_VERSION_2_1 */\n\n#ifndef GL_VERSION_3_0\n#define GL_VERSION_3_0 1\ntypedef unsigned short GLhalf;\n#define GL_COMPARE_REF_TO_TEXTURE         0x884E\n#define GL_CLIP_DISTANCE0                 0x3000\n#define GL_CLIP_DISTANCE1                 0x3001\n#define GL_CLIP_DISTANCE2                 0x3002\n#define GL_CLIP_DISTANCE3                 0x3003\n#define GL_CLIP_DISTANCE4                 0x3004\n#define GL_CLIP_DISTANCE5                 0x3005\n#define GL_CLIP_DISTANCE6                 0x3006\n#define GL_CLIP_DISTANCE7                 0x3007\n#define GL_MAX_CLIP_DISTANCES             0x0D32\n#define GL_MAJOR_VERSION                  0x821B\n#define GL_MINOR_VERSION                  0x821C\n#define GL_NUM_EXTENSIONS                 0x821D\n#define GL_CONTEXT_FLAGS                  0x821E\n#define GL_COMPRESSED_RED                 0x8225\n#define GL_COMPRESSED_RG                  0x8226\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001\n#define GL_RGBA32F                        0x8814\n#define GL_RGB32F                         0x8815\n#define GL_RGBA16F                        0x881A\n#define GL_RGB16F                         0x881B\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER    0x88FD\n#define GL_MAX_ARRAY_TEXTURE_LAYERS       0x88FF\n#define GL_MIN_PROGRAM_TEXEL_OFFSET       0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET       0x8905\n#define GL_CLAMP_READ_COLOR               0x891C\n#define GL_FIXED_ONLY                     0x891D\n#define GL_MAX_VARYING_COMPONENTS         0x8B4B\n#define GL_TEXTURE_1D_ARRAY               0x8C18\n#define GL_PROXY_TEXTURE_1D_ARRAY         0x8C19\n#define GL_TEXTURE_2D_ARRAY               0x8C1A\n#define GL_PROXY_TEXTURE_2D_ARRAY         0x8C1B\n#define GL_TEXTURE_BINDING_1D_ARRAY       0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY       0x8C1D\n#define GL_R11F_G11F_B10F                 0x8C3A\n#define GL_UNSIGNED_INT_10F_11F_11F_REV   0x8C3B\n#define GL_RGB9_E5                        0x8C3D\n#define GL_UNSIGNED_INT_5_9_9_9_REV       0x8C3E\n#define GL_TEXTURE_SHARED_SIZE            0x8C3F\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_TRANSFORM_FEEDBACK_VARYINGS    0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_PRIMITIVES_GENERATED           0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_RASTERIZER_DISCARD             0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS            0x8C8C\n#define GL_SEPARATE_ATTRIBS               0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER      0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_RGBA32UI                       0x8D70\n#define GL_RGB32UI                        0x8D71\n#define GL_RGBA16UI                       0x8D76\n#define GL_RGB16UI                        0x8D77\n#define GL_RGBA8UI                        0x8D7C\n#define GL_RGB8UI                         0x8D7D\n#define GL_RGBA32I                        0x8D82\n#define GL_RGB32I                         0x8D83\n#define GL_RGBA16I                        0x8D88\n#define GL_RGB16I                         0x8D89\n#define GL_RGBA8I                         0x8D8E\n#define GL_RGB8I                          0x8D8F\n#define GL_RED_INTEGER                    0x8D94\n#define GL_GREEN_INTEGER                  0x8D95\n#define GL_BLUE_INTEGER                   0x8D96\n#define GL_RGB_INTEGER                    0x8D98\n#define GL_RGBA_INTEGER                   0x8D99\n#define GL_BGR_INTEGER                    0x8D9A\n#define GL_BGRA_INTEGER                   0x8D9B\n#define GL_SAMPLER_1D_ARRAY               0x8DC0\n#define GL_SAMPLER_2D_ARRAY               0x8DC1\n#define GL_SAMPLER_1D_ARRAY_SHADOW        0x8DC3\n#define GL_SAMPLER_2D_ARRAY_SHADOW        0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW            0x8DC5\n#define GL_UNSIGNED_INT_VEC2              0x8DC6\n#define GL_UNSIGNED_INT_VEC3              0x8DC7\n#define GL_UNSIGNED_INT_VEC4              0x8DC8\n#define GL_INT_SAMPLER_1D                 0x8DC9\n#define GL_INT_SAMPLER_2D                 0x8DCA\n#define GL_INT_SAMPLER_3D                 0x8DCB\n#define GL_INT_SAMPLER_CUBE               0x8DCC\n#define GL_INT_SAMPLER_1D_ARRAY           0x8DCE\n#define GL_INT_SAMPLER_2D_ARRAY           0x8DCF\n#define GL_UNSIGNED_INT_SAMPLER_1D        0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_2D        0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_3D        0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE      0x8DD4\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY  0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY  0x8DD7\n#define GL_QUERY_WAIT                     0x8E13\n#define GL_QUERY_NO_WAIT                  0x8E14\n#define GL_QUERY_BY_REGION_WAIT           0x8E15\n#define GL_QUERY_BY_REGION_NO_WAIT        0x8E16\n#define GL_BUFFER_ACCESS_FLAGS            0x911F\n#define GL_BUFFER_MAP_LENGTH              0x9120\n#define GL_BUFFER_MAP_OFFSET              0x9121\n#define GL_DEPTH_COMPONENT32F             0x8CAC\n#define GL_DEPTH32F_STENCIL8              0x8CAD\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_DEFAULT            0x8218\n#define GL_FRAMEBUFFER_UNDEFINED          0x8219\n#define GL_DEPTH_STENCIL_ATTACHMENT       0x821A\n#define GL_MAX_RENDERBUFFER_SIZE          0x84E8\n#define GL_DEPTH_STENCIL                  0x84F9\n#define GL_UNSIGNED_INT_24_8              0x84FA\n#define GL_DEPTH24_STENCIL8               0x88F0\n#define GL_TEXTURE_STENCIL_SIZE           0x88F1\n#define GL_TEXTURE_RED_TYPE               0x8C10\n#define GL_TEXTURE_GREEN_TYPE             0x8C11\n#define GL_TEXTURE_BLUE_TYPE              0x8C12\n#define GL_TEXTURE_ALPHA_TYPE             0x8C13\n#define GL_TEXTURE_DEPTH_TYPE             0x8C16\n#define GL_UNSIGNED_NORMALIZED            0x8C17\n#define GL_FRAMEBUFFER_BINDING            0x8CA6\n#define GL_DRAW_FRAMEBUFFER_BINDING       0x8CA6\n#define GL_RENDERBUFFER_BINDING           0x8CA7\n#define GL_READ_FRAMEBUFFER               0x8CA8\n#define GL_DRAW_FRAMEBUFFER               0x8CA9\n#define GL_READ_FRAMEBUFFER_BINDING       0x8CAA\n#define GL_RENDERBUFFER_SAMPLES           0x8CAB\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_COMPLETE           0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_UNSUPPORTED        0x8CDD\n#define GL_MAX_COLOR_ATTACHMENTS          0x8CDF\n#define GL_COLOR_ATTACHMENT0              0x8CE0\n#define GL_COLOR_ATTACHMENT1              0x8CE1\n#define GL_COLOR_ATTACHMENT2              0x8CE2\n#define GL_COLOR_ATTACHMENT3              0x8CE3\n#define GL_COLOR_ATTACHMENT4              0x8CE4\n#define GL_COLOR_ATTACHMENT5              0x8CE5\n#define GL_COLOR_ATTACHMENT6              0x8CE6\n#define GL_COLOR_ATTACHMENT7              0x8CE7\n#define GL_COLOR_ATTACHMENT8              0x8CE8\n#define GL_COLOR_ATTACHMENT9              0x8CE9\n#define GL_COLOR_ATTACHMENT10             0x8CEA\n#define GL_COLOR_ATTACHMENT11             0x8CEB\n#define GL_COLOR_ATTACHMENT12             0x8CEC\n#define GL_COLOR_ATTACHMENT13             0x8CED\n#define GL_COLOR_ATTACHMENT14             0x8CEE\n#define GL_COLOR_ATTACHMENT15             0x8CEF\n#define GL_DEPTH_ATTACHMENT               0x8D00\n#define GL_STENCIL_ATTACHMENT             0x8D20\n#define GL_FRAMEBUFFER                    0x8D40\n#define GL_RENDERBUFFER                   0x8D41\n#define GL_RENDERBUFFER_WIDTH             0x8D42\n#define GL_RENDERBUFFER_HEIGHT            0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44\n#define GL_STENCIL_INDEX1                 0x8D46\n#define GL_STENCIL_INDEX4                 0x8D47\n#define GL_STENCIL_INDEX8                 0x8D48\n#define GL_STENCIL_INDEX16                0x8D49\n#define GL_RENDERBUFFER_RED_SIZE          0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_MAX_SAMPLES                    0x8D57\n#define GL_INDEX                          0x8222\n#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14\n#define GL_TEXTURE_INTENSITY_TYPE         0x8C15\n#define GL_FRAMEBUFFER_SRGB               0x8DB9\n#define GL_HALF_FLOAT                     0x140B\n#define GL_MAP_READ_BIT                   0x0001\n#define GL_MAP_WRITE_BIT                  0x0002\n#define GL_MAP_INVALIDATE_RANGE_BIT       0x0004\n#define GL_MAP_INVALIDATE_BUFFER_BIT      0x0008\n#define GL_MAP_FLUSH_EXPLICIT_BIT         0x0010\n#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020\n#define GL_COMPRESSED_RED_RGTC1           0x8DBB\n#define GL_COMPRESSED_SIGNED_RED_RGTC1    0x8DBC\n#define GL_COMPRESSED_RG_RGTC2            0x8DBD\n#define GL_COMPRESSED_SIGNED_RG_RGTC2     0x8DBE\n#define GL_RG                             0x8227\n#define GL_RG_INTEGER                     0x8228\n#define GL_R8                             0x8229\n#define GL_R16                            0x822A\n#define GL_RG8                            0x822B\n#define GL_RG16                           0x822C\n#define GL_R16F                           0x822D\n#define GL_R32F                           0x822E\n#define GL_RG16F                          0x822F\n#define GL_RG32F                          0x8230\n#define GL_R8I                            0x8231\n#define GL_R8UI                           0x8232\n#define GL_R16I                           0x8233\n#define GL_R16UI                          0x8234\n#define GL_R32I                           0x8235\n#define GL_R32UI                          0x8236\n#define GL_RG8I                           0x8237\n#define GL_RG8UI                          0x8238\n#define GL_RG16I                          0x8239\n#define GL_RG16UI                         0x823A\n#define GL_RG32I                          0x823B\n#define GL_RG32UI                         0x823C\n#define GL_VERTEX_ARRAY_BINDING           0x85B5\n#define GL_CLAMP_VERTEX_COLOR             0x891A\n#define GL_CLAMP_FRAGMENT_COLOR           0x891B\n#define GL_ALPHA_INTEGER                  0x8D97\ntypedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\ntypedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);\ntypedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);\ntypedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index);\ntypedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index);\ntypedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);\ntypedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void);\ntypedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\ntypedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);\ntypedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);\ntypedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);\ntypedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);\ntypedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);\ntypedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);\ntypedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);\ntypedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);\ntypedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);\ntypedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);\ntypedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);\ntypedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);\ntypedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);\ntypedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\ntypedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);\ntypedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);\ntypedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);\ntypedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);\ntypedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\nGLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data);\nGLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data);\nGLAPI void APIENTRY glEnablei (GLenum target, GLuint index);\nGLAPI void APIENTRY glDisablei (GLenum target, GLuint index);\nGLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index);\nGLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode);\nGLAPI void APIENTRY glEndTransformFeedback (void);\nGLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\nGLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);\nGLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);\nGLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\nGLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp);\nGLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode);\nGLAPI void APIENTRY glEndConditionalRender (void);\nGLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x);\nGLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y);\nGLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x);\nGLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y);\nGLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z);\nGLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nGLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params);\nGLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name);\nGLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0);\nGLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);\nGLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);\nGLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nGLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params);\nGLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);\nGLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);\nGLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);\nGLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);\nGLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index);\nGLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer);\nGLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);\nGLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);\nGLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);\nGLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer);\nGLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);\nGLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);\nGLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);\nGLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target);\nGLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\nGLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nGLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGenerateMipmap (GLenum target);\nGLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\nGLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\nGLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\nGLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);\nGLAPI void APIENTRY glBindVertexArray (GLuint array);\nGLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);\nGLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);\nGLAPI GLboolean APIENTRY glIsVertexArray (GLuint array);\n#endif\n#endif /* GL_VERSION_3_0 */\n\n#ifndef GL_VERSION_3_1\n#define GL_VERSION_3_1 1\n#define GL_SAMPLER_2D_RECT                0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW         0x8B64\n#define GL_SAMPLER_BUFFER                 0x8DC2\n#define GL_INT_SAMPLER_2D_RECT            0x8DCD\n#define GL_INT_SAMPLER_BUFFER             0x8DD0\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT   0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER    0x8DD8\n#define GL_TEXTURE_BUFFER                 0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE        0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER         0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_RECTANGLE              0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE      0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE        0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE     0x84F8\n#define GL_R8_SNORM                       0x8F94\n#define GL_RG8_SNORM                      0x8F95\n#define GL_RGB8_SNORM                     0x8F96\n#define GL_RGBA8_SNORM                    0x8F97\n#define GL_R16_SNORM                      0x8F98\n#define GL_RG16_SNORM                     0x8F99\n#define GL_RGB16_SNORM                    0x8F9A\n#define GL_RGBA16_SNORM                   0x8F9B\n#define GL_SIGNED_NORMALIZED              0x8F9C\n#define GL_PRIMITIVE_RESTART              0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX        0x8F9E\n#define GL_COPY_READ_BUFFER               0x8F36\n#define GL_COPY_WRITE_BUFFER              0x8F37\n#define GL_UNIFORM_BUFFER                 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING         0x8A28\n#define GL_UNIFORM_BUFFER_START           0x8A29\n#define GL_UNIFORM_BUFFER_SIZE            0x8A2A\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS      0x8A2B\n#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS    0x8A2C\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS    0x8A2D\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS    0x8A2E\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS    0x8A2F\n#define GL_MAX_UNIFORM_BLOCK_SIZE         0x8A30\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_ACTIVE_UNIFORM_BLOCKS          0x8A36\n#define GL_UNIFORM_TYPE                   0x8A37\n#define GL_UNIFORM_SIZE                   0x8A38\n#define GL_UNIFORM_NAME_LENGTH            0x8A39\n#define GL_UNIFORM_BLOCK_INDEX            0x8A3A\n#define GL_UNIFORM_OFFSET                 0x8A3B\n#define GL_UNIFORM_ARRAY_STRIDE           0x8A3C\n#define GL_UNIFORM_MATRIX_STRIDE          0x8A3D\n#define GL_UNIFORM_IS_ROW_MAJOR           0x8A3E\n#define GL_UNIFORM_BLOCK_BINDING          0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE        0x8A40\n#define GL_UNIFORM_BLOCK_NAME_LENGTH      0x8A41\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS  0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_INVALID_INDEX                  0xFFFFFFFFu\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);\ntypedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer);\ntypedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);\ntypedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);\ntypedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);\ntypedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);\nGLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);\nGLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer);\nGLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index);\nGLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\nGLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);\nGLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);\nGLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName);\nGLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);\nGLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\n#endif\n#endif /* GL_VERSION_3_1 */\n\n#ifndef GL_VERSION_3_2\n#define GL_VERSION_3_2 1\ntypedef struct __GLsync *GLsync;\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glxext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GL_EXT_timer_query extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\ntypedef uint64_t GLuint64;\ntypedef int64_t GLint64;\n#define GL_CONTEXT_CORE_PROFILE_BIT       0x00000001\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_LINES_ADJACENCY                0x000A\n#define GL_LINE_STRIP_ADJACENCY           0x000B\n#define GL_TRIANGLES_ADJACENCY            0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY       0x000D\n#define GL_PROGRAM_POINT_SIZE             0x8642\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_SHADER                0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT          0x8916\n#define GL_GEOMETRY_INPUT_TYPE            0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE           0x8918\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES   0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS   0x9122\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS  0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS  0x9125\n#define GL_CONTEXT_PROFILE_MASK           0x9126\n#define GL_DEPTH_CLAMP                    0x864F\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_FIRST_VERTEX_CONVENTION        0x8E4D\n#define GL_LAST_VERTEX_CONVENTION         0x8E4E\n#define GL_PROVOKING_VERTEX               0x8E4F\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS      0x884F\n#define GL_MAX_SERVER_WAIT_TIMEOUT        0x9111\n#define GL_OBJECT_TYPE                    0x9112\n#define GL_SYNC_CONDITION                 0x9113\n#define GL_SYNC_STATUS                    0x9114\n#define GL_SYNC_FLAGS                     0x9115\n#define GL_SYNC_FENCE                     0x9116\n#define GL_SYNC_GPU_COMMANDS_COMPLETE     0x9117\n#define GL_UNSIGNALED                     0x9118\n#define GL_SIGNALED                       0x9119\n#define GL_ALREADY_SIGNALED               0x911A\n#define GL_TIMEOUT_EXPIRED                0x911B\n#define GL_CONDITION_SATISFIED            0x911C\n#define GL_WAIT_FAILED                    0x911D\n#define GL_TIMEOUT_IGNORED                0xFFFFFFFFFFFFFFFFull\n#define GL_SYNC_FLUSH_COMMANDS_BIT        0x00000001\n#define GL_SAMPLE_POSITION                0x8E50\n#define GL_SAMPLE_MASK                    0x8E51\n#define GL_SAMPLE_MASK_VALUE              0x8E52\n#define GL_MAX_SAMPLE_MASK_WORDS          0x8E59\n#define GL_TEXTURE_2D_MULTISAMPLE         0x9100\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE   0x9101\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY   0x9102\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_SAMPLES                0x9106\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_SAMPLER_2D_MULTISAMPLE         0x9108\n#define GL_INT_SAMPLER_2D_MULTISAMPLE     0x9109\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY   0x910B\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_MAX_COLOR_TEXTURE_SAMPLES      0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES      0x910F\n#define GL_MAX_INTEGER_SAMPLES            0x9110\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);\ntypedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode);\ntypedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);\ntypedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync);\ntypedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync);\ntypedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);\ntypedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);\ntypedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data);\ntypedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);\ntypedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);\ntypedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);\nGLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);\nGLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);\nGLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);\nGLAPI void APIENTRY glProvokingVertex (GLenum mode);\nGLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags);\nGLAPI GLboolean APIENTRY glIsSync (GLsync sync);\nGLAPI void APIENTRY glDeleteSync (GLsync sync);\nGLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);\nGLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);\nGLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data);\nGLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);\nGLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);\nGLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params);\nGLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level);\nGLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);\nGLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask);\n#endif\n#endif /* GL_VERSION_3_2 */\n\n#ifndef GL_VERSION_3_3\n#define GL_VERSION_3_3 1\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR    0x88FE\n#define GL_SRC1_COLOR                     0x88F9\n#define GL_ONE_MINUS_SRC1_COLOR           0x88FA\n#define GL_ONE_MINUS_SRC1_ALPHA           0x88FB\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS   0x88FC\n#define GL_ANY_SAMPLES_PASSED             0x8C2F\n#define GL_SAMPLER_BINDING                0x8919\n#define GL_RGB10_A2UI                     0x906F\n#define GL_TEXTURE_SWIZZLE_R              0x8E42\n#define GL_TEXTURE_SWIZZLE_G              0x8E43\n#define GL_TEXTURE_SWIZZLE_B              0x8E44\n#define GL_TEXTURE_SWIZZLE_A              0x8E45\n#define GL_TEXTURE_SWIZZLE_RGBA           0x8E46\n#define GL_TIME_ELAPSED                   0x88BF\n#define GL_TIMESTAMP                      0x8E28\n#define GL_INT_2_10_10_10_REV             0x8D9F\ntypedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);\ntypedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers);\ntypedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers);\ntypedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler);\ntypedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param);\ntypedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param);\ntypedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value);\ntypedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);\ntypedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value);\ntypedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);\ntypedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords);\ntypedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);\ntypedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color);\ntypedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);\ntypedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);\nGLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);\nGLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);\nGLAPI GLboolean APIENTRY glIsSampler (GLuint sampler);\nGLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);\nGLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);\nGLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param);\nGLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param);\nGLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param);\nGLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param);\nGLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target);\nGLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params);\nGLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params);\nGLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);\nGLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);\nGLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nGLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);\nGLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nGLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);\nGLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nGLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value);\nGLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value);\nGLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value);\nGLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value);\nGLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value);\nGLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value);\nGLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value);\nGLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value);\nGLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords);\nGLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords);\nGLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords);\nGLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords);\nGLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords);\nGLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords);\nGLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords);\nGLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords);\nGLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords);\nGLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords);\nGLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color);\nGLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color);\nGLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color);\nGLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color);\nGLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color);\nGLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color);\n#endif\n#endif /* GL_VERSION_3_3 */\n\n#ifndef GL_VERSION_4_0\n#define GL_VERSION_4_0 1\n#define GL_SAMPLE_SHADING                 0x8C36\n#define GL_MIN_SAMPLE_SHADING_VALUE       0x8C37\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F\n#define GL_TEXTURE_CUBE_MAP_ARRAY         0x9009\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY   0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY         0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW  0x900D\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY     0x900E\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F\n#define GL_DRAW_INDIRECT_BUFFER           0x8F3F\n#define GL_DRAW_INDIRECT_BUFFER_BINDING   0x8F43\n#define GL_GEOMETRY_SHADER_INVOCATIONS    0x887F\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\n#define GL_MAX_VERTEX_STREAMS             0x8E71\n#define GL_DOUBLE_VEC2                    0x8FFC\n#define GL_DOUBLE_VEC3                    0x8FFD\n#define GL_DOUBLE_VEC4                    0x8FFE\n#define GL_DOUBLE_MAT2                    0x8F46\n#define GL_DOUBLE_MAT3                    0x8F47\n#define GL_DOUBLE_MAT4                    0x8F48\n#define GL_DOUBLE_MAT2x3                  0x8F49\n#define GL_DOUBLE_MAT2x4                  0x8F4A\n#define GL_DOUBLE_MAT3x2                  0x8F4B\n#define GL_DOUBLE_MAT3x4                  0x8F4C\n#define GL_DOUBLE_MAT4x2                  0x8F4D\n#define GL_DOUBLE_MAT4x3                  0x8F4E\n#define GL_ACTIVE_SUBROUTINES             0x8DE5\n#define GL_ACTIVE_SUBROUTINE_UNIFORMS     0x8DE6\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47\n#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH   0x8E48\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49\n#define GL_MAX_SUBROUTINES                0x8DE7\n#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8\n#define GL_NUM_COMPATIBLE_SUBROUTINES     0x8E4A\n#define GL_COMPATIBLE_SUBROUTINES         0x8E4B\n#define GL_PATCHES                        0x000E\n#define GL_PATCH_VERTICES                 0x8E72\n#define GL_PATCH_DEFAULT_INNER_LEVEL      0x8E73\n#define GL_PATCH_DEFAULT_OUTER_LEVEL      0x8E74\n#define GL_TESS_CONTROL_OUTPUT_VERTICES   0x8E75\n#define GL_TESS_GEN_MODE                  0x8E76\n#define GL_TESS_GEN_SPACING               0x8E77\n#define GL_TESS_GEN_VERTEX_ORDER          0x8E78\n#define GL_TESS_GEN_POINT_MODE            0x8E79\n#define GL_ISOLINES                       0x8E7A\n#define GL_FRACTIONAL_ODD                 0x8E7B\n#define GL_FRACTIONAL_EVEN                0x8E7C\n#define GL_MAX_PATCH_VERTICES             0x8E7D\n#define GL_MAX_TESS_GEN_LEVEL             0x8E7E\n#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F\n#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80\n#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81\n#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82\n#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83\n#define GL_MAX_TESS_PATCH_COMPONENTS      0x8E84\n#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85\n#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86\n#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89\n#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A\n#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C\n#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D\n#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E\n#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1\n#define GL_TESS_EVALUATION_SHADER         0x8E87\n#define GL_TESS_CONTROL_SHADER            0x8E88\n#define GL_TRANSFORM_FEEDBACK             0x8E22\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BINDING     0x8E25\n#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70\ntypedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\ntypedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect);\ntypedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);\ntypedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params);\ntypedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name);\ntypedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);\ntypedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);\ntypedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);\ntypedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices);\ntypedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values);\ntypedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);\ntypedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values);\ntypedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);\ntypedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids);\ntypedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids);\ntypedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);\ntypedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);\ntypedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);\ntypedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);\ntypedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);\ntypedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);\ntypedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMinSampleShading (GLfloat value);\nGLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode);\nGLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\nGLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst);\nGLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\nGLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect);\nGLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect);\nGLAPI void APIENTRY glUniform1d (GLint location, GLdouble x);\nGLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params);\nGLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name);\nGLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name);\nGLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);\nGLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);\nGLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);\nGLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices);\nGLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params);\nGLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values);\nGLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value);\nGLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values);\nGLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id);\nGLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids);\nGLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids);\nGLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id);\nGLAPI void APIENTRY glPauseTransformFeedback (void);\nGLAPI void APIENTRY glResumeTransformFeedback (void);\nGLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id);\nGLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream);\nGLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id);\nGLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index);\nGLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params);\n#endif\n#endif /* GL_VERSION_4_0 */\n\n#ifndef GL_VERSION_4_1\n#define GL_VERSION_4_1 1\n#define GL_FIXED                          0x140C\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B\n#define GL_LOW_FLOAT                      0x8DF0\n#define GL_MEDIUM_FLOAT                   0x8DF1\n#define GL_HIGH_FLOAT                     0x8DF2\n#define GL_LOW_INT                        0x8DF3\n#define GL_MEDIUM_INT                     0x8DF4\n#define GL_HIGH_INT                       0x8DF5\n#define GL_SHADER_COMPILER                0x8DFA\n#define GL_SHADER_BINARY_FORMATS          0x8DF8\n#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9\n#define GL_MAX_VERTEX_UNIFORM_VECTORS     0x8DFB\n#define GL_MAX_VARYING_VECTORS            0x8DFC\n#define GL_MAX_FRAGMENT_UNIFORM_VECTORS   0x8DFD\n#define GL_RGB565                         0x8D62\n#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257\n#define GL_PROGRAM_BINARY_LENGTH          0x8741\n#define GL_NUM_PROGRAM_BINARY_FORMATS     0x87FE\n#define GL_PROGRAM_BINARY_FORMATS         0x87FF\n#define GL_VERTEX_SHADER_BIT              0x00000001\n#define GL_FRAGMENT_SHADER_BIT            0x00000002\n#define GL_GEOMETRY_SHADER_BIT            0x00000004\n#define GL_TESS_CONTROL_SHADER_BIT        0x00000008\n#define GL_TESS_EVALUATION_SHADER_BIT     0x00000010\n#define GL_ALL_SHADER_BITS                0xFFFFFFFF\n#define GL_PROGRAM_SEPARABLE              0x8258\n#define GL_ACTIVE_PROGRAM                 0x8259\n#define GL_PROGRAM_PIPELINE_BINDING       0x825A\n#define GL_MAX_VIEWPORTS                  0x825B\n#define GL_VIEWPORT_SUBPIXEL_BITS         0x825C\n#define GL_VIEWPORT_BOUNDS_RANGE          0x825D\n#define GL_LAYER_PROVOKING_VERTEX         0x825E\n#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F\n#define GL_UNDEFINED_VERTEX               0x8260\ntypedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void);\ntypedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);\ntypedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);\ntypedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f);\ntypedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d);\ntypedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);\ntypedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);\ntypedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);\ntypedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);\ntypedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings);\ntypedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);\ntypedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines);\ntypedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines);\ntypedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);\ntypedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);\ntypedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);\ntypedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v);\ntypedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f);\ntypedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);\ntypedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glReleaseShaderCompiler (void);\nGLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);\nGLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);\nGLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f);\nGLAPI void APIENTRY glClearDepthf (GLfloat d);\nGLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);\nGLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);\nGLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);\nGLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program);\nGLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program);\nGLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings);\nGLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline);\nGLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines);\nGLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines);\nGLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline);\nGLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params);\nGLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0);\nGLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0);\nGLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0);\nGLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0);\nGLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1);\nGLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1);\nGLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1);\nGLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1);\nGLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\nGLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nGLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);\nGLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\nGLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nGLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nGLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);\nGLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nGLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline);\nGLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);\nGLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x);\nGLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);\nGLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v);\nGLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v);\nGLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f);\nGLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data);\nGLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data);\n#endif\n#endif /* GL_VERSION_4_1 */\n\n#ifndef GL_VERSION_4_2\n#define GL_VERSION_4_2 1\n#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH  0x9127\n#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128\n#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH  0x9129\n#define GL_UNPACK_COMPRESSED_BLOCK_SIZE   0x912A\n#define GL_PACK_COMPRESSED_BLOCK_WIDTH    0x912B\n#define GL_PACK_COMPRESSED_BLOCK_HEIGHT   0x912C\n#define GL_PACK_COMPRESSED_BLOCK_DEPTH    0x912D\n#define GL_PACK_COMPRESSED_BLOCK_SIZE     0x912E\n#define GL_NUM_SAMPLE_COUNTS              0x9380\n#define GL_MIN_MAP_BUFFER_ALIGNMENT       0x90BC\n#define GL_ATOMIC_COUNTER_BUFFER          0x92C0\n#define GL_ATOMIC_COUNTER_BUFFER_BINDING  0x92C1\n#define GL_ATOMIC_COUNTER_BUFFER_START    0x92C2\n#define GL_ATOMIC_COUNTER_BUFFER_SIZE     0x92C3\n#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB\n#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0\n#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1\n#define GL_MAX_VERTEX_ATOMIC_COUNTERS     0x92D2\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS   0x92D5\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS   0x92D6\n#define GL_MAX_COMBINED_ATOMIC_COUNTERS   0x92D7\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC\n#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS  0x92D9\n#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA\n#define GL_UNSIGNED_INT_ATOMIC_COUNTER    0x92DB\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001\n#define GL_ELEMENT_ARRAY_BARRIER_BIT      0x00000002\n#define GL_UNIFORM_BARRIER_BIT            0x00000004\n#define GL_TEXTURE_FETCH_BARRIER_BIT      0x00000008\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020\n#define GL_COMMAND_BARRIER_BIT            0x00000040\n#define GL_PIXEL_BUFFER_BARRIER_BIT       0x00000080\n#define GL_TEXTURE_UPDATE_BARRIER_BIT     0x00000100\n#define GL_BUFFER_UPDATE_BARRIER_BIT      0x00000200\n#define GL_FRAMEBUFFER_BARRIER_BIT        0x00000400\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800\n#define GL_ATOMIC_COUNTER_BARRIER_BIT     0x00001000\n#define GL_ALL_BARRIER_BITS               0xFFFFFFFF\n#define GL_MAX_IMAGE_UNITS                0x8F38\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39\n#define GL_IMAGE_BINDING_NAME             0x8F3A\n#define GL_IMAGE_BINDING_LEVEL            0x8F3B\n#define GL_IMAGE_BINDING_LAYERED          0x8F3C\n#define GL_IMAGE_BINDING_LAYER            0x8F3D\n#define GL_IMAGE_BINDING_ACCESS           0x8F3E\n#define GL_IMAGE_1D                       0x904C\n#define GL_IMAGE_2D                       0x904D\n#define GL_IMAGE_3D                       0x904E\n#define GL_IMAGE_2D_RECT                  0x904F\n#define GL_IMAGE_CUBE                     0x9050\n#define GL_IMAGE_BUFFER                   0x9051\n#define GL_IMAGE_1D_ARRAY                 0x9052\n#define GL_IMAGE_2D_ARRAY                 0x9053\n#define GL_IMAGE_CUBE_MAP_ARRAY           0x9054\n#define GL_IMAGE_2D_MULTISAMPLE           0x9055\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY     0x9056\n#define GL_INT_IMAGE_1D                   0x9057\n#define GL_INT_IMAGE_2D                   0x9058\n#define GL_INT_IMAGE_3D                   0x9059\n#define GL_INT_IMAGE_2D_RECT              0x905A\n#define GL_INT_IMAGE_CUBE                 0x905B\n#define GL_INT_IMAGE_BUFFER               0x905C\n#define GL_INT_IMAGE_1D_ARRAY             0x905D\n#define GL_INT_IMAGE_2D_ARRAY             0x905E\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY       0x905F\n#define GL_INT_IMAGE_2D_MULTISAMPLE       0x9060\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061\n#define GL_UNSIGNED_INT_IMAGE_1D          0x9062\n#define GL_UNSIGNED_INT_IMAGE_2D          0x9063\n#define GL_UNSIGNED_INT_IMAGE_3D          0x9064\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT     0x9065\n#define GL_UNSIGNED_INT_IMAGE_CUBE        0x9066\n#define GL_UNSIGNED_INT_IMAGE_BUFFER      0x9067\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY    0x9068\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY    0x9069\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C\n#define GL_MAX_IMAGE_SAMPLES              0x906D\n#define GL_IMAGE_BINDING_FORMAT           0x906E\n#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9\n#define GL_MAX_VERTEX_IMAGE_UNIFORMS      0x90CA\n#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB\n#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC\n#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS    0x90CD\n#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS    0x90CE\n#define GL_MAX_COMBINED_IMAGE_UNIFORMS    0x90CF\n#define GL_COMPRESSED_RGBA_BPTC_UNORM     0x8E8C\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F\n#define GL_TEXTURE_IMMUTABLE_FORMAT       0x912F\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);\ntypedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);\ntypedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);\ntypedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);\ntypedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\ntypedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\ntypedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount);\ntypedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);\nGLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);\nGLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);\nGLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);\nGLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);\nGLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);\nGLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);\nGLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\nGLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\nGLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount);\nGLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);\n#endif\n#endif /* GL_VERSION_4_2 */\n\n#ifndef GL_VERSION_4_3\n#define GL_VERSION_4_3 1\ntypedef void (APIENTRY  *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n#define GL_NUM_SHADING_LANGUAGE_VERSIONS  0x82E9\n#define GL_VERTEX_ATTRIB_ARRAY_LONG       0x874E\n#define GL_COMPRESSED_RGB8_ETC2           0x9274\n#define GL_COMPRESSED_SRGB8_ETC2          0x9275\n#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276\n#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277\n#define GL_COMPRESSED_RGBA8_ETC2_EAC      0x9278\n#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279\n#define GL_COMPRESSED_R11_EAC             0x9270\n#define GL_COMPRESSED_SIGNED_R11_EAC      0x9271\n#define GL_COMPRESSED_RG11_EAC            0x9272\n#define GL_COMPRESSED_SIGNED_RG11_EAC     0x9273\n#define GL_PRIMITIVE_RESTART_FIXED_INDEX  0x8D69\n#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A\n#define GL_MAX_ELEMENT_INDEX              0x8D6B\n#define GL_COMPUTE_SHADER                 0x91B9\n#define GL_MAX_COMPUTE_UNIFORM_BLOCKS     0x91BB\n#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC\n#define GL_MAX_COMPUTE_IMAGE_UNIFORMS     0x91BD\n#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262\n#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263\n#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264\n#define GL_MAX_COMPUTE_ATOMIC_COUNTERS    0x8265\n#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266\n#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB\n#define GL_MAX_COMPUTE_WORK_GROUP_COUNT   0x91BE\n#define GL_MAX_COMPUTE_WORK_GROUP_SIZE    0x91BF\n#define GL_COMPUTE_WORK_GROUP_SIZE        0x8267\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED\n#define GL_DISPATCH_INDIRECT_BUFFER       0x90EE\n#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF\n#define GL_COMPUTE_SHADER_BIT             0x00000020\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS       0x8242\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243\n#define GL_DEBUG_CALLBACK_FUNCTION        0x8244\n#define GL_DEBUG_CALLBACK_USER_PARAM      0x8245\n#define GL_DEBUG_SOURCE_API               0x8246\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM     0x8247\n#define GL_DEBUG_SOURCE_SHADER_COMPILER   0x8248\n#define GL_DEBUG_SOURCE_THIRD_PARTY       0x8249\n#define GL_DEBUG_SOURCE_APPLICATION       0x824A\n#define GL_DEBUG_SOURCE_OTHER             0x824B\n#define GL_DEBUG_TYPE_ERROR               0x824C\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR  0x824E\n#define GL_DEBUG_TYPE_PORTABILITY         0x824F\n#define GL_DEBUG_TYPE_PERFORMANCE         0x8250\n#define GL_DEBUG_TYPE_OTHER               0x8251\n#define GL_MAX_DEBUG_MESSAGE_LENGTH       0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES      0x9144\n#define GL_DEBUG_LOGGED_MESSAGES          0x9145\n#define GL_DEBUG_SEVERITY_HIGH            0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM          0x9147\n#define GL_DEBUG_SEVERITY_LOW             0x9148\n#define GL_DEBUG_TYPE_MARKER              0x8268\n#define GL_DEBUG_TYPE_PUSH_GROUP          0x8269\n#define GL_DEBUG_TYPE_POP_GROUP           0x826A\n#define GL_DEBUG_SEVERITY_NOTIFICATION    0x826B\n#define GL_MAX_DEBUG_GROUP_STACK_DEPTH    0x826C\n#define GL_DEBUG_GROUP_STACK_DEPTH        0x826D\n#define GL_BUFFER                         0x82E0\n#define GL_SHADER                         0x82E1\n#define GL_PROGRAM                        0x82E2\n#define GL_QUERY                          0x82E3\n#define GL_PROGRAM_PIPELINE               0x82E4\n#define GL_SAMPLER                        0x82E6\n#define GL_MAX_LABEL_LENGTH               0x82E8\n#define GL_DEBUG_OUTPUT                   0x92E0\n#define GL_CONTEXT_FLAG_DEBUG_BIT         0x00000002\n#define GL_MAX_UNIFORM_LOCATIONS          0x826E\n#define GL_FRAMEBUFFER_DEFAULT_WIDTH      0x9310\n#define GL_FRAMEBUFFER_DEFAULT_HEIGHT     0x9311\n#define GL_FRAMEBUFFER_DEFAULT_LAYERS     0x9312\n#define GL_FRAMEBUFFER_DEFAULT_SAMPLES    0x9313\n#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314\n#define GL_MAX_FRAMEBUFFER_WIDTH          0x9315\n#define GL_MAX_FRAMEBUFFER_HEIGHT         0x9316\n#define GL_MAX_FRAMEBUFFER_LAYERS         0x9317\n#define GL_MAX_FRAMEBUFFER_SAMPLES        0x9318\n#define GL_INTERNALFORMAT_SUPPORTED       0x826F\n#define GL_INTERNALFORMAT_PREFERRED       0x8270\n#define GL_INTERNALFORMAT_RED_SIZE        0x8271\n#define GL_INTERNALFORMAT_GREEN_SIZE      0x8272\n#define GL_INTERNALFORMAT_BLUE_SIZE       0x8273\n#define GL_INTERNALFORMAT_ALPHA_SIZE      0x8274\n#define GL_INTERNALFORMAT_DEPTH_SIZE      0x8275\n#define GL_INTERNALFORMAT_STENCIL_SIZE    0x8276\n#define GL_INTERNALFORMAT_SHARED_SIZE     0x8277\n#define GL_INTERNALFORMAT_RED_TYPE        0x8278\n#define GL_INTERNALFORMAT_GREEN_TYPE      0x8279\n#define GL_INTERNALFORMAT_BLUE_TYPE       0x827A\n#define GL_INTERNALFORMAT_ALPHA_TYPE      0x827B\n#define GL_INTERNALFORMAT_DEPTH_TYPE      0x827C\n#define GL_INTERNALFORMAT_STENCIL_TYPE    0x827D\n#define GL_MAX_WIDTH                      0x827E\n#define GL_MAX_HEIGHT                     0x827F\n#define GL_MAX_DEPTH                      0x8280\n#define GL_MAX_LAYERS                     0x8281\n#define GL_MAX_COMBINED_DIMENSIONS        0x8282\n#define GL_COLOR_COMPONENTS               0x8283\n#define GL_DEPTH_COMPONENTS               0x8284\n#define GL_STENCIL_COMPONENTS             0x8285\n#define GL_COLOR_RENDERABLE               0x8286\n#define GL_DEPTH_RENDERABLE               0x8287\n#define GL_STENCIL_RENDERABLE             0x8288\n#define GL_FRAMEBUFFER_RENDERABLE         0x8289\n#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A\n#define GL_FRAMEBUFFER_BLEND              0x828B\n#define GL_READ_PIXELS                    0x828C\n#define GL_READ_PIXELS_FORMAT             0x828D\n#define GL_READ_PIXELS_TYPE               0x828E\n#define GL_TEXTURE_IMAGE_FORMAT           0x828F\n#define GL_TEXTURE_IMAGE_TYPE             0x8290\n#define GL_GET_TEXTURE_IMAGE_FORMAT       0x8291\n#define GL_GET_TEXTURE_IMAGE_TYPE         0x8292\n#define GL_MIPMAP                         0x8293\n#define GL_MANUAL_GENERATE_MIPMAP         0x8294\n#define GL_AUTO_GENERATE_MIPMAP           0x8295\n#define GL_COLOR_ENCODING                 0x8296\n#define GL_SRGB_READ                      0x8297\n#define GL_SRGB_WRITE                     0x8298\n#define GL_FILTER                         0x829A\n#define GL_VERTEX_TEXTURE                 0x829B\n#define GL_TESS_CONTROL_TEXTURE           0x829C\n#define GL_TESS_EVALUATION_TEXTURE        0x829D\n#define GL_GEOMETRY_TEXTURE               0x829E\n#define GL_FRAGMENT_TEXTURE               0x829F\n#define GL_COMPUTE_TEXTURE                0x82A0\n#define GL_TEXTURE_SHADOW                 0x82A1\n#define GL_TEXTURE_GATHER                 0x82A2\n#define GL_TEXTURE_GATHER_SHADOW          0x82A3\n#define GL_SHADER_IMAGE_LOAD              0x82A4\n#define GL_SHADER_IMAGE_STORE             0x82A5\n#define GL_SHADER_IMAGE_ATOMIC            0x82A6\n#define GL_IMAGE_TEXEL_SIZE               0x82A7\n#define GL_IMAGE_COMPATIBILITY_CLASS      0x82A8\n#define GL_IMAGE_PIXEL_FORMAT             0x82A9\n#define GL_IMAGE_PIXEL_TYPE               0x82AA\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF\n#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1\n#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2\n#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE  0x82B3\n#define GL_CLEAR_BUFFER                   0x82B4\n#define GL_TEXTURE_VIEW                   0x82B5\n#define GL_VIEW_COMPATIBILITY_CLASS       0x82B6\n#define GL_FULL_SUPPORT                   0x82B7\n#define GL_CAVEAT_SUPPORT                 0x82B8\n#define GL_IMAGE_CLASS_4_X_32             0x82B9\n#define GL_IMAGE_CLASS_2_X_32             0x82BA\n#define GL_IMAGE_CLASS_1_X_32             0x82BB\n#define GL_IMAGE_CLASS_4_X_16             0x82BC\n#define GL_IMAGE_CLASS_2_X_16             0x82BD\n#define GL_IMAGE_CLASS_1_X_16             0x82BE\n#define GL_IMAGE_CLASS_4_X_8              0x82BF\n#define GL_IMAGE_CLASS_2_X_8              0x82C0\n#define GL_IMAGE_CLASS_1_X_8              0x82C1\n#define GL_IMAGE_CLASS_11_11_10           0x82C2\n#define GL_IMAGE_CLASS_10_10_10_2         0x82C3\n#define GL_VIEW_CLASS_128_BITS            0x82C4\n#define GL_VIEW_CLASS_96_BITS             0x82C5\n#define GL_VIEW_CLASS_64_BITS             0x82C6\n#define GL_VIEW_CLASS_48_BITS             0x82C7\n#define GL_VIEW_CLASS_32_BITS             0x82C8\n#define GL_VIEW_CLASS_24_BITS             0x82C9\n#define GL_VIEW_CLASS_16_BITS             0x82CA\n#define GL_VIEW_CLASS_8_BITS              0x82CB\n#define GL_VIEW_CLASS_S3TC_DXT1_RGB       0x82CC\n#define GL_VIEW_CLASS_S3TC_DXT1_RGBA      0x82CD\n#define GL_VIEW_CLASS_S3TC_DXT3_RGBA      0x82CE\n#define GL_VIEW_CLASS_S3TC_DXT5_RGBA      0x82CF\n#define GL_VIEW_CLASS_RGTC1_RED           0x82D0\n#define GL_VIEW_CLASS_RGTC2_RG            0x82D1\n#define GL_VIEW_CLASS_BPTC_UNORM          0x82D2\n#define GL_VIEW_CLASS_BPTC_FLOAT          0x82D3\n#define GL_UNIFORM                        0x92E1\n#define GL_UNIFORM_BLOCK                  0x92E2\n#define GL_PROGRAM_INPUT                  0x92E3\n#define GL_PROGRAM_OUTPUT                 0x92E4\n#define GL_BUFFER_VARIABLE                0x92E5\n#define GL_SHADER_STORAGE_BLOCK           0x92E6\n#define GL_VERTEX_SUBROUTINE              0x92E8\n#define GL_TESS_CONTROL_SUBROUTINE        0x92E9\n#define GL_TESS_EVALUATION_SUBROUTINE     0x92EA\n#define GL_GEOMETRY_SUBROUTINE            0x92EB\n#define GL_FRAGMENT_SUBROUTINE            0x92EC\n#define GL_COMPUTE_SUBROUTINE             0x92ED\n#define GL_VERTEX_SUBROUTINE_UNIFORM      0x92EE\n#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF\n#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0\n#define GL_GEOMETRY_SUBROUTINE_UNIFORM    0x92F1\n#define GL_FRAGMENT_SUBROUTINE_UNIFORM    0x92F2\n#define GL_COMPUTE_SUBROUTINE_UNIFORM     0x92F3\n#define GL_TRANSFORM_FEEDBACK_VARYING     0x92F4\n#define GL_ACTIVE_RESOURCES               0x92F5\n#define GL_MAX_NAME_LENGTH                0x92F6\n#define GL_MAX_NUM_ACTIVE_VARIABLES       0x92F7\n#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8\n#define GL_NAME_LENGTH                    0x92F9\n#define GL_TYPE                           0x92FA\n#define GL_ARRAY_SIZE                     0x92FB\n#define GL_OFFSET                         0x92FC\n#define GL_BLOCK_INDEX                    0x92FD\n#define GL_ARRAY_STRIDE                   0x92FE\n#define GL_MATRIX_STRIDE                  0x92FF\n#define GL_IS_ROW_MAJOR                   0x9300\n#define GL_ATOMIC_COUNTER_BUFFER_INDEX    0x9301\n#define GL_BUFFER_BINDING                 0x9302\n#define GL_BUFFER_DATA_SIZE               0x9303\n#define GL_NUM_ACTIVE_VARIABLES           0x9304\n#define GL_ACTIVE_VARIABLES               0x9305\n#define GL_REFERENCED_BY_VERTEX_SHADER    0x9306\n#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307\n#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308\n#define GL_REFERENCED_BY_GEOMETRY_SHADER  0x9309\n#define GL_REFERENCED_BY_FRAGMENT_SHADER  0x930A\n#define GL_REFERENCED_BY_COMPUTE_SHADER   0x930B\n#define GL_TOP_LEVEL_ARRAY_SIZE           0x930C\n#define GL_TOP_LEVEL_ARRAY_STRIDE         0x930D\n#define GL_LOCATION                       0x930E\n#define GL_LOCATION_INDEX                 0x930F\n#define GL_IS_PER_PATCH                   0x92E7\n#define GL_SHADER_STORAGE_BUFFER          0x90D2\n#define GL_SHADER_STORAGE_BUFFER_BINDING  0x90D3\n#define GL_SHADER_STORAGE_BUFFER_START    0x90D4\n#define GL_SHADER_STORAGE_BUFFER_SIZE     0x90D5\n#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6\n#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7\n#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8\n#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9\n#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA\n#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB\n#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC\n#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD\n#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE  0x90DE\n#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF\n#define GL_SHADER_STORAGE_BARRIER_BIT     0x00002000\n#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39\n#define GL_DEPTH_STENCIL_TEXTURE_MODE     0x90EA\n#define GL_TEXTURE_BUFFER_OFFSET          0x919D\n#define GL_TEXTURE_BUFFER_SIZE            0x919E\n#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F\n#define GL_TEXTURE_VIEW_MIN_LEVEL         0x82DB\n#define GL_TEXTURE_VIEW_NUM_LEVELS        0x82DC\n#define GL_TEXTURE_VIEW_MIN_LAYER         0x82DD\n#define GL_TEXTURE_VIEW_NUM_LAYERS        0x82DE\n#define GL_TEXTURE_IMMUTABLE_LEVELS       0x82DF\n#define GL_VERTEX_ATTRIB_BINDING          0x82D4\n#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET  0x82D5\n#define GL_VERTEX_BINDING_DIVISOR         0x82D6\n#define GL_VERTEX_BINDING_OFFSET          0x82D7\n#define GL_VERTEX_BINDING_STRIDE          0x82D8\n#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9\n#define GL_MAX_VERTEX_ATTRIB_BINDINGS     0x82DA\n#define GL_VERTEX_BINDING_BUFFER          0x8F4F\n#define GL_DISPLAY_LIST                   0x82E7\ntypedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);\ntypedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect);\ntypedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);\ntypedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);\ntypedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\ntypedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);\ntypedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);\ntypedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params);\ntypedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);\ntypedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);\ntypedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name);\ntypedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name);\ntypedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);\ntypedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);\ntypedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);\ntypedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);\ntypedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);\ntypedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);\ntypedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);\ntypedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);\ntypedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);\ntypedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);\ntypedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);\nGLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect);\nGLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);\nGLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);\nGLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);\nGLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level);\nGLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length);\nGLAPI void APIENTRY glInvalidateBufferData (GLuint buffer);\nGLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);\nGLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);\nGLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);\nGLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params);\nGLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name);\nGLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);\nGLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);\nGLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name);\nGLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name);\nGLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);\nGLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\nGLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);\nGLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\nGLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex);\nGLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor);\nGLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\nGLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);\nGLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam);\nGLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);\nGLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message);\nGLAPI void APIENTRY glPopDebugGroup (void);\nGLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);\nGLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);\nGLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label);\nGLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);\n#endif\n#endif /* GL_VERSION_4_3 */\n\n#ifndef GL_VERSION_4_4\n#define GL_VERSION_4_4 1\n#define GL_MAX_VERTEX_ATTRIB_STRIDE       0x82E5\n#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221\n#define GL_TEXTURE_BUFFER_BINDING         0x8C2A\n#define GL_MAP_PERSISTENT_BIT             0x0040\n#define GL_MAP_COHERENT_BIT               0x0080\n#define GL_DYNAMIC_STORAGE_BIT            0x0100\n#define GL_CLIENT_STORAGE_BIT             0x0200\n#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000\n#define GL_BUFFER_IMMUTABLE_STORAGE       0x821F\n#define GL_BUFFER_STORAGE_FLAGS           0x8220\n#define GL_CLEAR_TEXTURE                  0x9365\n#define GL_LOCATION_COMPONENT             0x934A\n#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B\n#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C\n#define GL_QUERY_BUFFER                   0x9192\n#define GL_QUERY_BUFFER_BARRIER_BIT       0x00008000\n#define GL_QUERY_BUFFER_BINDING           0x9193\n#define GL_QUERY_RESULT_NO_WAIT           0x9194\n#define GL_MIRROR_CLAMP_TO_EDGE           0x8743\ntypedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);\ntypedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers);\ntypedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);\ntypedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);\ntypedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers);\ntypedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures);\ntypedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);\nGLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers);\nGLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);\nGLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures);\nGLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers);\nGLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures);\nGLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\n#endif\n#endif /* GL_VERSION_4_4 */\n\n#ifndef GL_VERSION_4_5\n#define GL_VERSION_4_5 1\n#define GL_CONTEXT_LOST                   0x0507\n#define GL_NEGATIVE_ONE_TO_ONE            0x935E\n#define GL_ZERO_TO_ONE                    0x935F\n#define GL_CLIP_ORIGIN                    0x935C\n#define GL_CLIP_DEPTH_MODE                0x935D\n#define GL_QUERY_WAIT_INVERTED            0x8E17\n#define GL_QUERY_NO_WAIT_INVERTED         0x8E18\n#define GL_QUERY_BY_REGION_WAIT_INVERTED  0x8E19\n#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A\n#define GL_MAX_CULL_DISTANCES             0x82F9\n#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA\n#define GL_TEXTURE_TARGET                 0x1006\n#define GL_QUERY_TARGET                   0x82EA\n#define GL_TEXTURE_BINDING                0x82EB\n#define GL_GUILTY_CONTEXT_RESET           0x8253\n#define GL_INNOCENT_CONTEXT_RESET         0x8254\n#define GL_UNKNOWN_CONTEXT_RESET          0x8255\n#define GL_RESET_NOTIFICATION_STRATEGY    0x8256\n#define GL_LOSE_CONTEXT_ON_RESET          0x8252\n#define GL_NO_RESET_NOTIFICATION          0x8261\n#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004\n#define GL_CONTEXT_RELEASE_BEHAVIOR       0x82FB\n#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC\ntypedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth);\ntypedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);\ntypedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizei size, const void *data, GLbitfield flags);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizei size, const void *data, GLenum usage);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizei size, const void *data);\ntypedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data);\ntypedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access);\ntypedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access);\ntypedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizei length);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizei size, void *data);\ntypedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src);\ntypedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments);\ntypedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil);\ntypedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\ntypedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target);\ntypedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);\ntypedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures);\ntypedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param);\ntypedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture);\ntypedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture);\ntypedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels);\ntypedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index);\ntypedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param);\ntypedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers);\ntypedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines);\ntypedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids);\ntypedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers);\ntypedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);\ntypedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void);\ntypedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels);\ntypedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);\ntypedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\ntypedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);\ntypedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);\ntypedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values);\ntypedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern);\ntypedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);\ntypedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);\ntypedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);\ntypedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\ntypedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\ntypedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth);\nGLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids);\nGLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer);\nGLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size);\nGLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param);\nGLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);\nGLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers);\nGLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizei size, const void *data, GLbitfield flags);\nGLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const void *data, GLenum usage);\nGLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, const void *data);\nGLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);\nGLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data);\nGLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access);\nGLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access);\nGLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer);\nGLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length);\nGLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params);\nGLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params);\nGLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, void *data);\nGLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers);\nGLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nGLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param);\nGLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\nGLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\nGLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf);\nGLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs);\nGLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src);\nGLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments);\nGLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);\nGLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value);\nGLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);\nGLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil);\nGLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\nGLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target);\nGLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);\nGLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers);\nGLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures);\nGLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer);\nGLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size);\nGLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);\nGLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\nGLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param);\nGLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param);\nGLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params);\nGLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param);\nGLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture);\nGLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture);\nGLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nGLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels);\nGLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params);\nGLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays);\nGLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index);\nGLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index);\nGLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer);\nGLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\nGLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);\nGLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\nGLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor);\nGLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param);\nGLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers);\nGLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines);\nGLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids);\nGLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers);\nGLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nGLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);\nGLAPI GLenum APIENTRY glGetGraphicsResetStatus (void);\nGLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels);\nGLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\nGLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\nGLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);\nGLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params);\nGLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params);\nGLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\nGLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);\nGLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);\nGLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v);\nGLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values);\nGLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values);\nGLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values);\nGLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern);\nGLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);\nGLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);\nGLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);\nGLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\nGLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\nGLAPI void APIENTRY glTextureBarrier (void);\n#endif\n#endif /* GL_VERSION_4_5 */\n\n#ifndef GL_ARB_ES2_compatibility\n#define GL_ARB_ES2_compatibility 1\n#endif /* GL_ARB_ES2_compatibility */\n\n#ifndef GL_ARB_ES3_1_compatibility\n#define GL_ARB_ES3_1_compatibility 1\n#endif /* GL_ARB_ES3_1_compatibility */\n\n#ifndef GL_ARB_ES3_compatibility\n#define GL_ARB_ES3_compatibility 1\n#endif /* GL_ARB_ES3_compatibility */\n\n#ifndef GL_ARB_arrays_of_arrays\n#define GL_ARB_arrays_of_arrays 1\n#endif /* GL_ARB_arrays_of_arrays */\n\n#ifndef GL_ARB_base_instance\n#define GL_ARB_base_instance 1\n#endif /* GL_ARB_base_instance */\n\n#ifndef GL_ARB_bindless_texture\n#define GL_ARB_bindless_texture 1\ntypedef uint64_t GLuint64EXT;\n#define GL_UNSIGNED_INT64_ARB             0x140F\ntypedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture);\ntypedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler);\ntypedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);\ntypedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle);\ntypedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\ntypedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access);\ntypedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle);\ntypedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value);\ntypedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);\ntypedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);\ntypedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture);\nGLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler);\nGLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle);\nGLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle);\nGLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\nGLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access);\nGLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle);\nGLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value);\nGLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value);\nGLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value);\nGLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values);\nGLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle);\nGLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle);\nGLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x);\nGLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v);\nGLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params);\n#endif\n#endif /* GL_ARB_bindless_texture */\n\n#ifndef GL_ARB_blend_func_extended\n#define GL_ARB_blend_func_extended 1\n#endif /* GL_ARB_blend_func_extended */\n\n#ifndef GL_ARB_buffer_storage\n#define GL_ARB_buffer_storage 1\n#endif /* GL_ARB_buffer_storage */\n\n#ifndef GL_ARB_cl_event\n#define GL_ARB_cl_event 1\nstruct _cl_context;\nstruct _cl_event;\n#define GL_SYNC_CL_EVENT_ARB              0x8240\n#define GL_SYNC_CL_EVENT_COMPLETE_ARB     0x8241\ntypedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags);\n#endif\n#endif /* GL_ARB_cl_event */\n\n#ifndef GL_ARB_clear_buffer_object\n#define GL_ARB_clear_buffer_object 1\n#endif /* GL_ARB_clear_buffer_object */\n\n#ifndef GL_ARB_clear_texture\n#define GL_ARB_clear_texture 1\n#endif /* GL_ARB_clear_texture */\n\n#ifndef GL_ARB_clip_control\n#define GL_ARB_clip_control 1\n#endif /* GL_ARB_clip_control */\n\n#ifndef GL_ARB_color_buffer_float\n#define GL_ARB_color_buffer_float 1\n#define GL_RGBA_FLOAT_MODE_ARB            0x8820\n#define GL_CLAMP_VERTEX_COLOR_ARB         0x891A\n#define GL_CLAMP_FRAGMENT_COLOR_ARB       0x891B\n#define GL_CLAMP_READ_COLOR_ARB           0x891C\n#define GL_FIXED_ONLY_ARB                 0x891D\ntypedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp);\n#endif\n#endif /* GL_ARB_color_buffer_float */\n\n#ifndef GL_ARB_compatibility\n#define GL_ARB_compatibility 1\n#endif /* GL_ARB_compatibility */\n\n#ifndef GL_ARB_compressed_texture_pixel_storage\n#define GL_ARB_compressed_texture_pixel_storage 1\n#endif /* GL_ARB_compressed_texture_pixel_storage */\n\n#ifndef GL_ARB_compute_shader\n#define GL_ARB_compute_shader 1\n#endif /* GL_ARB_compute_shader */\n\n#ifndef GL_ARB_compute_variable_group_size\n#define GL_ARB_compute_variable_group_size 1\n#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344\n#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB\n#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345\n#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF\ntypedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z);\n#endif\n#endif /* GL_ARB_compute_variable_group_size */\n\n#ifndef GL_ARB_conditional_render_inverted\n#define GL_ARB_conditional_render_inverted 1\n#endif /* GL_ARB_conditional_render_inverted */\n\n#ifndef GL_ARB_conservative_depth\n#define GL_ARB_conservative_depth 1\n#endif /* GL_ARB_conservative_depth */\n\n#ifndef GL_ARB_copy_buffer\n#define GL_ARB_copy_buffer 1\n#define GL_COPY_READ_BUFFER_BINDING       0x8F36\n#define GL_COPY_WRITE_BUFFER_BINDING      0x8F37\n#endif /* GL_ARB_copy_buffer */\n\n#ifndef GL_ARB_copy_image\n#define GL_ARB_copy_image 1\n#endif /* GL_ARB_copy_image */\n\n#ifndef GL_ARB_cull_distance\n#define GL_ARB_cull_distance 1\n#endif /* GL_ARB_cull_distance */\n\n#ifndef GL_ARB_debug_output\n#define GL_ARB_debug_output 1\ntypedef void (APIENTRY  *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB   0x8242\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243\n#define GL_DEBUG_CALLBACK_FUNCTION_ARB    0x8244\n#define GL_DEBUG_CALLBACK_USER_PARAM_ARB  0x8245\n#define GL_DEBUG_SOURCE_API_ARB           0x8246\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247\n#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248\n#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB   0x8249\n#define GL_DEBUG_SOURCE_APPLICATION_ARB   0x824A\n#define GL_DEBUG_SOURCE_OTHER_ARB         0x824B\n#define GL_DEBUG_TYPE_ERROR_ARB           0x824C\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E\n#define GL_DEBUG_TYPE_PORTABILITY_ARB     0x824F\n#define GL_DEBUG_TYPE_PERFORMANCE_ARB     0x8250\n#define GL_DEBUG_TYPE_OTHER_ARB           0x8251\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB   0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB  0x9144\n#define GL_DEBUG_LOGGED_MESSAGES_ARB      0x9145\n#define GL_DEBUG_SEVERITY_HIGH_ARB        0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM_ARB      0x9147\n#define GL_DEBUG_SEVERITY_LOW_ARB         0x9148\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam);\ntypedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\nGLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);\nGLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam);\nGLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);\n#endif\n#endif /* GL_ARB_debug_output */\n\n#ifndef GL_ARB_depth_buffer_float\n#define GL_ARB_depth_buffer_float 1\n#endif /* GL_ARB_depth_buffer_float */\n\n#ifndef GL_ARB_depth_clamp\n#define GL_ARB_depth_clamp 1\n#endif /* GL_ARB_depth_clamp */\n\n#ifndef GL_ARB_depth_texture\n#define GL_ARB_depth_texture 1\n#define GL_DEPTH_COMPONENT16_ARB          0x81A5\n#define GL_DEPTH_COMPONENT24_ARB          0x81A6\n#define GL_DEPTH_COMPONENT32_ARB          0x81A7\n#define GL_TEXTURE_DEPTH_SIZE_ARB         0x884A\n#define GL_DEPTH_TEXTURE_MODE_ARB         0x884B\n#endif /* GL_ARB_depth_texture */\n\n#ifndef GL_ARB_derivative_control\n#define GL_ARB_derivative_control 1\n#endif /* GL_ARB_derivative_control */\n\n#ifndef GL_ARB_direct_state_access\n#define GL_ARB_direct_state_access 1\n#endif /* GL_ARB_direct_state_access */\n\n#ifndef GL_ARB_draw_buffers\n#define GL_ARB_draw_buffers 1\n#define GL_MAX_DRAW_BUFFERS_ARB           0x8824\n#define GL_DRAW_BUFFER0_ARB               0x8825\n#define GL_DRAW_BUFFER1_ARB               0x8826\n#define GL_DRAW_BUFFER2_ARB               0x8827\n#define GL_DRAW_BUFFER3_ARB               0x8828\n#define GL_DRAW_BUFFER4_ARB               0x8829\n#define GL_DRAW_BUFFER5_ARB               0x882A\n#define GL_DRAW_BUFFER6_ARB               0x882B\n#define GL_DRAW_BUFFER7_ARB               0x882C\n#define GL_DRAW_BUFFER8_ARB               0x882D\n#define GL_DRAW_BUFFER9_ARB               0x882E\n#define GL_DRAW_BUFFER10_ARB              0x882F\n#define GL_DRAW_BUFFER11_ARB              0x8830\n#define GL_DRAW_BUFFER12_ARB              0x8831\n#define GL_DRAW_BUFFER13_ARB              0x8832\n#define GL_DRAW_BUFFER14_ARB              0x8833\n#define GL_DRAW_BUFFER15_ARB              0x8834\ntypedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs);\n#endif\n#endif /* GL_ARB_draw_buffers */\n\n#ifndef GL_ARB_draw_buffers_blend\n#define GL_ARB_draw_buffers_blend 1\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\ntypedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode);\nGLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\nGLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst);\nGLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\n#endif\n#endif /* GL_ARB_draw_buffers_blend */\n\n#ifndef GL_ARB_draw_elements_base_vertex\n#define GL_ARB_draw_elements_base_vertex 1\n#endif /* GL_ARB_draw_elements_base_vertex */\n\n#ifndef GL_ARB_draw_indirect\n#define GL_ARB_draw_indirect 1\n#endif /* GL_ARB_draw_indirect */\n\n#ifndef GL_ARB_draw_instanced\n#define GL_ARB_draw_instanced 1\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\nGLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\n#endif\n#endif /* GL_ARB_draw_instanced */\n\n#ifndef GL_ARB_enhanced_layouts\n#define GL_ARB_enhanced_layouts 1\n#endif /* GL_ARB_enhanced_layouts */\n\n#ifndef GL_ARB_explicit_attrib_location\n#define GL_ARB_explicit_attrib_location 1\n#endif /* GL_ARB_explicit_attrib_location */\n\n#ifndef GL_ARB_explicit_uniform_location\n#define GL_ARB_explicit_uniform_location 1\n#endif /* GL_ARB_explicit_uniform_location */\n\n#ifndef GL_ARB_fragment_coord_conventions\n#define GL_ARB_fragment_coord_conventions 1\n#endif /* GL_ARB_fragment_coord_conventions */\n\n#ifndef GL_ARB_fragment_layer_viewport\n#define GL_ARB_fragment_layer_viewport 1\n#endif /* GL_ARB_fragment_layer_viewport */\n\n#ifndef GL_ARB_fragment_program\n#define GL_ARB_fragment_program 1\n#define GL_FRAGMENT_PROGRAM_ARB           0x8804\n#define GL_PROGRAM_FORMAT_ASCII_ARB       0x8875\n#define GL_PROGRAM_LENGTH_ARB             0x8627\n#define GL_PROGRAM_FORMAT_ARB             0x8876\n#define GL_PROGRAM_BINDING_ARB            0x8677\n#define GL_PROGRAM_INSTRUCTIONS_ARB       0x88A0\n#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB   0x88A1\n#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2\n#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3\n#define GL_PROGRAM_TEMPORARIES_ARB        0x88A4\n#define GL_MAX_PROGRAM_TEMPORARIES_ARB    0x88A5\n#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6\n#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7\n#define GL_PROGRAM_PARAMETERS_ARB         0x88A8\n#define GL_MAX_PROGRAM_PARAMETERS_ARB     0x88A9\n#define GL_PROGRAM_NATIVE_PARAMETERS_ARB  0x88AA\n#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB\n#define GL_PROGRAM_ATTRIBS_ARB            0x88AC\n#define GL_MAX_PROGRAM_ATTRIBS_ARB        0x88AD\n#define GL_PROGRAM_NATIVE_ATTRIBS_ARB     0x88AE\n#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF\n#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4\n#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5\n#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6\n#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB   0x8805\n#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB   0x8806\n#define GL_PROGRAM_TEX_INDIRECTIONS_ARB   0x8807\n#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808\n#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809\n#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A\n#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B\n#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C\n#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D\n#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E\n#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F\n#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810\n#define GL_PROGRAM_STRING_ARB             0x8628\n#define GL_PROGRAM_ERROR_POSITION_ARB     0x864B\n#define GL_CURRENT_MATRIX_ARB             0x8641\n#define GL_TRANSPOSE_CURRENT_MATRIX_ARB   0x88B7\n#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640\n#define GL_MAX_PROGRAM_MATRICES_ARB       0x862F\n#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E\n#define GL_MAX_TEXTURE_COORDS_ARB         0x8871\n#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB    0x8872\n#define GL_PROGRAM_ERROR_STRING_ARB       0x8874\n#define GL_MATRIX0_ARB                    0x88C0\n#define GL_MATRIX1_ARB                    0x88C1\n#define GL_MATRIX2_ARB                    0x88C2\n#define GL_MATRIX3_ARB                    0x88C3\n#define GL_MATRIX4_ARB                    0x88C4\n#define GL_MATRIX5_ARB                    0x88C5\n#define GL_MATRIX6_ARB                    0x88C6\n#define GL_MATRIX7_ARB                    0x88C7\n#define GL_MATRIX8_ARB                    0x88C8\n#define GL_MATRIX9_ARB                    0x88C9\n#define GL_MATRIX10_ARB                   0x88CA\n#define GL_MATRIX11_ARB                   0x88CB\n#define GL_MATRIX12_ARB                   0x88CC\n#define GL_MATRIX13_ARB                   0x88CD\n#define GL_MATRIX14_ARB                   0x88CE\n#define GL_MATRIX15_ARB                   0x88CF\n#define GL_MATRIX16_ARB                   0x88D0\n#define GL_MATRIX17_ARB                   0x88D1\n#define GL_MATRIX18_ARB                   0x88D2\n#define GL_MATRIX19_ARB                   0x88D3\n#define GL_MATRIX20_ARB                   0x88D4\n#define GL_MATRIX21_ARB                   0x88D5\n#define GL_MATRIX22_ARB                   0x88D6\n#define GL_MATRIX23_ARB                   0x88D7\n#define GL_MATRIX24_ARB                   0x88D8\n#define GL_MATRIX25_ARB                   0x88D9\n#define GL_MATRIX26_ARB                   0x88DA\n#define GL_MATRIX27_ARB                   0x88DB\n#define GL_MATRIX28_ARB                   0x88DC\n#define GL_MATRIX29_ARB                   0x88DD\n#define GL_MATRIX30_ARB                   0x88DE\n#define GL_MATRIX31_ARB                   0x88DF\ntypedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string);\ntypedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);\ntypedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);\ntypedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string);\ntypedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string);\nGLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program);\nGLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs);\nGLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs);\nGLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);\nGLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);\nGLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params);\nGLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params);\nGLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params);\nGLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params);\nGLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params);\nGLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params);\nGLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string);\nGLAPI GLboolean APIENTRY glIsProgramARB (GLuint program);\n#endif\n#endif /* GL_ARB_fragment_program */\n\n#ifndef GL_ARB_fragment_program_shadow\n#define GL_ARB_fragment_program_shadow 1\n#endif /* GL_ARB_fragment_program_shadow */\n\n#ifndef GL_ARB_fragment_shader\n#define GL_ARB_fragment_shader 1\n#define GL_FRAGMENT_SHADER_ARB            0x8B30\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B\n#endif /* GL_ARB_fragment_shader */\n\n#ifndef GL_ARB_framebuffer_no_attachments\n#define GL_ARB_framebuffer_no_attachments 1\n#endif /* GL_ARB_framebuffer_no_attachments */\n\n#ifndef GL_ARB_framebuffer_object\n#define GL_ARB_framebuffer_object 1\n#endif /* GL_ARB_framebuffer_object */\n\n#ifndef GL_ARB_framebuffer_sRGB\n#define GL_ARB_framebuffer_sRGB 1\n#endif /* GL_ARB_framebuffer_sRGB */\n\n#ifndef GL_ARB_geometry_shader4\n#define GL_ARB_geometry_shader4 1\n#define GL_LINES_ADJACENCY_ARB            0x000A\n#define GL_LINE_STRIP_ADJACENCY_ARB       0x000B\n#define GL_TRIANGLES_ADJACENCY_ARB        0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY_ARB   0x000D\n#define GL_PROGRAM_POINT_SIZE_ARB         0x8642\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9\n#define GL_GEOMETRY_SHADER_ARB            0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT_ARB      0x8DDA\n#define GL_GEOMETRY_INPUT_TYPE_ARB        0x8DDB\n#define GL_GEOMETRY_OUTPUT_TYPE_ARB       0x8DDC\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value);\nGLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\nGLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\n#endif\n#endif /* GL_ARB_geometry_shader4 */\n\n#ifndef GL_ARB_get_program_binary\n#define GL_ARB_get_program_binary 1\n#endif /* GL_ARB_get_program_binary */\n\n#ifndef GL_ARB_get_texture_sub_image\n#define GL_ARB_get_texture_sub_image 1\n#endif /* GL_ARB_get_texture_sub_image */\n\n#ifndef GL_ARB_gpu_shader5\n#define GL_ARB_gpu_shader5 1\n#endif /* GL_ARB_gpu_shader5 */\n\n#ifndef GL_ARB_gpu_shader_fp64\n#define GL_ARB_gpu_shader_fp64 1\n#endif /* GL_ARB_gpu_shader_fp64 */\n\n#ifndef GL_ARB_half_float_pixel\n#define GL_ARB_half_float_pixel 1\ntypedef unsigned short GLhalfARB;\n#define GL_HALF_FLOAT_ARB                 0x140B\n#endif /* GL_ARB_half_float_pixel */\n\n#ifndef GL_ARB_half_float_vertex\n#define GL_ARB_half_float_vertex 1\n#endif /* GL_ARB_half_float_vertex */\n\n#ifndef GL_ARB_imaging\n#define GL_ARB_imaging 1\n#define GL_BLEND_COLOR                    0x8005\n#define GL_BLEND_EQUATION                 0x8009\n#define GL_CONVOLUTION_1D                 0x8010\n#define GL_CONVOLUTION_2D                 0x8011\n#define GL_SEPARABLE_2D                   0x8012\n#define GL_CONVOLUTION_BORDER_MODE        0x8013\n#define GL_CONVOLUTION_FILTER_SCALE       0x8014\n#define GL_CONVOLUTION_FILTER_BIAS        0x8015\n#define GL_REDUCE                         0x8016\n#define GL_CONVOLUTION_FORMAT             0x8017\n#define GL_CONVOLUTION_WIDTH              0x8018\n#define GL_CONVOLUTION_HEIGHT             0x8019\n#define GL_MAX_CONVOLUTION_WIDTH          0x801A\n#define GL_MAX_CONVOLUTION_HEIGHT         0x801B\n#define GL_POST_CONVOLUTION_RED_SCALE     0x801C\n#define GL_POST_CONVOLUTION_GREEN_SCALE   0x801D\n#define GL_POST_CONVOLUTION_BLUE_SCALE    0x801E\n#define GL_POST_CONVOLUTION_ALPHA_SCALE   0x801F\n#define GL_POST_CONVOLUTION_RED_BIAS      0x8020\n#define GL_POST_CONVOLUTION_GREEN_BIAS    0x8021\n#define GL_POST_CONVOLUTION_BLUE_BIAS     0x8022\n#define GL_POST_CONVOLUTION_ALPHA_BIAS    0x8023\n#define GL_HISTOGRAM                      0x8024\n#define GL_PROXY_HISTOGRAM                0x8025\n#define GL_HISTOGRAM_WIDTH                0x8026\n#define GL_HISTOGRAM_FORMAT               0x8027\n#define GL_HISTOGRAM_RED_SIZE             0x8028\n#define GL_HISTOGRAM_GREEN_SIZE           0x8029\n#define GL_HISTOGRAM_BLUE_SIZE            0x802A\n#define GL_HISTOGRAM_ALPHA_SIZE           0x802B\n#define GL_HISTOGRAM_LUMINANCE_SIZE       0x802C\n#define GL_HISTOGRAM_SINK                 0x802D\n#define GL_MINMAX                         0x802E\n#define GL_MINMAX_FORMAT                  0x802F\n#define GL_MINMAX_SINK                    0x8030\n#define GL_TABLE_TOO_LARGE                0x8031\n#define GL_COLOR_MATRIX                   0x80B1\n#define GL_COLOR_MATRIX_STACK_DEPTH       0x80B2\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH   0x80B3\n#define GL_POST_COLOR_MATRIX_RED_SCALE    0x80B4\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE  0x80B5\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE   0x80B6\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE  0x80B7\n#define GL_POST_COLOR_MATRIX_RED_BIAS     0x80B8\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS   0x80B9\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS    0x80BA\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS   0x80BB\n#define GL_COLOR_TABLE                    0x80D0\n#define GL_POST_CONVOLUTION_COLOR_TABLE   0x80D1\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE  0x80D2\n#define GL_PROXY_COLOR_TABLE              0x80D3\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5\n#define GL_COLOR_TABLE_SCALE              0x80D6\n#define GL_COLOR_TABLE_BIAS               0x80D7\n#define GL_COLOR_TABLE_FORMAT             0x80D8\n#define GL_COLOR_TABLE_WIDTH              0x80D9\n#define GL_COLOR_TABLE_RED_SIZE           0x80DA\n#define GL_COLOR_TABLE_GREEN_SIZE         0x80DB\n#define GL_COLOR_TABLE_BLUE_SIZE          0x80DC\n#define GL_COLOR_TABLE_ALPHA_SIZE         0x80DD\n#define GL_COLOR_TABLE_LUMINANCE_SIZE     0x80DE\n#define GL_COLOR_TABLE_INTENSITY_SIZE     0x80DF\n#define GL_CONSTANT_BORDER                0x8151\n#define GL_REPLICATE_BORDER               0x8153\n#define GL_CONVOLUTION_BORDER_COLOR       0x8154\ntypedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\ntypedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\ntypedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\ntypedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\ntypedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);\ntypedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\nGLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table);\nGLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\nGLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\nGLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params);\nGLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params);\nGLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image);\nGLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\nGLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\nGLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\nGLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\nGLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\nGLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink);\nGLAPI void APIENTRY glResetHistogram (GLenum target);\nGLAPI void APIENTRY glResetMinmax (GLenum target);\n#endif\n#endif /* GL_ARB_imaging */\n\n#ifndef GL_ARB_indirect_parameters\n#define GL_ARB_indirect_parameters 1\n#define GL_PARAMETER_BUFFER_ARB           0x80EE\n#define GL_PARAMETER_BUFFER_BINDING_ARB   0x80EF\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\nGLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\n#endif\n#endif /* GL_ARB_indirect_parameters */\n\n#ifndef GL_ARB_instanced_arrays\n#define GL_ARB_instanced_arrays 1\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor);\n#endif\n#endif /* GL_ARB_instanced_arrays */\n\n#ifndef GL_ARB_internalformat_query\n#define GL_ARB_internalformat_query 1\n#endif /* GL_ARB_internalformat_query */\n\n#ifndef GL_ARB_internalformat_query2\n#define GL_ARB_internalformat_query2 1\n#define GL_SRGB_DECODE_ARB                0x8299\n#endif /* GL_ARB_internalformat_query2 */\n\n#ifndef GL_ARB_invalidate_subdata\n#define GL_ARB_invalidate_subdata 1\n#endif /* GL_ARB_invalidate_subdata */\n\n#ifndef GL_ARB_map_buffer_alignment\n#define GL_ARB_map_buffer_alignment 1\n#endif /* GL_ARB_map_buffer_alignment */\n\n#ifndef GL_ARB_map_buffer_range\n#define GL_ARB_map_buffer_range 1\n#endif /* GL_ARB_map_buffer_range */\n\n#ifndef GL_ARB_matrix_palette\n#define GL_ARB_matrix_palette 1\n#define GL_MATRIX_PALETTE_ARB             0x8840\n#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841\n#define GL_MAX_PALETTE_MATRICES_ARB       0x8842\n#define GL_CURRENT_PALETTE_MATRIX_ARB     0x8843\n#define GL_MATRIX_INDEX_ARRAY_ARB         0x8844\n#define GL_CURRENT_MATRIX_INDEX_ARB       0x8845\n#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB    0x8846\n#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB    0x8847\n#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB  0x8848\n#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849\ntypedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);\ntypedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);\ntypedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);\ntypedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);\ntypedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index);\nGLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices);\nGLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices);\nGLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices);\nGLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_ARB_matrix_palette */\n\n#ifndef GL_ARB_multi_bind\n#define GL_ARB_multi_bind 1\n#endif /* GL_ARB_multi_bind */\n\n#ifndef GL_ARB_multi_draw_indirect\n#define GL_ARB_multi_draw_indirect 1\n#endif /* GL_ARB_multi_draw_indirect */\n\n#ifndef GL_ARB_multisample\n#define GL_ARB_multisample 1\n#define GL_MULTISAMPLE_ARB                0x809D\n#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB   0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_ARB        0x809F\n#define GL_SAMPLE_COVERAGE_ARB            0x80A0\n#define GL_SAMPLE_BUFFERS_ARB             0x80A8\n#define GL_SAMPLES_ARB                    0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE_ARB      0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT_ARB     0x80AB\n#define GL_MULTISAMPLE_BIT_ARB            0x20000000\ntypedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert);\n#endif\n#endif /* GL_ARB_multisample */\n\n#ifndef GL_ARB_multitexture\n#define GL_ARB_multitexture 1\n#define GL_TEXTURE0_ARB                   0x84C0\n#define GL_TEXTURE1_ARB                   0x84C1\n#define GL_TEXTURE2_ARB                   0x84C2\n#define GL_TEXTURE3_ARB                   0x84C3\n#define GL_TEXTURE4_ARB                   0x84C4\n#define GL_TEXTURE5_ARB                   0x84C5\n#define GL_TEXTURE6_ARB                   0x84C6\n#define GL_TEXTURE7_ARB                   0x84C7\n#define GL_TEXTURE8_ARB                   0x84C8\n#define GL_TEXTURE9_ARB                   0x84C9\n#define GL_TEXTURE10_ARB                  0x84CA\n#define GL_TEXTURE11_ARB                  0x84CB\n#define GL_TEXTURE12_ARB                  0x84CC\n#define GL_TEXTURE13_ARB                  0x84CD\n#define GL_TEXTURE14_ARB                  0x84CE\n#define GL_TEXTURE15_ARB                  0x84CF\n#define GL_TEXTURE16_ARB                  0x84D0\n#define GL_TEXTURE17_ARB                  0x84D1\n#define GL_TEXTURE18_ARB                  0x84D2\n#define GL_TEXTURE19_ARB                  0x84D3\n#define GL_TEXTURE20_ARB                  0x84D4\n#define GL_TEXTURE21_ARB                  0x84D5\n#define GL_TEXTURE22_ARB                  0x84D6\n#define GL_TEXTURE23_ARB                  0x84D7\n#define GL_TEXTURE24_ARB                  0x84D8\n#define GL_TEXTURE25_ARB                  0x84D9\n#define GL_TEXTURE26_ARB                  0x84DA\n#define GL_TEXTURE27_ARB                  0x84DB\n#define GL_TEXTURE28_ARB                  0x84DC\n#define GL_TEXTURE29_ARB                  0x84DD\n#define GL_TEXTURE30_ARB                  0x84DE\n#define GL_TEXTURE31_ARB                  0x84DF\n#define GL_ACTIVE_TEXTURE_ARB             0x84E0\n#define GL_CLIENT_ACTIVE_TEXTURE_ARB      0x84E1\n#define GL_MAX_TEXTURE_UNITS_ARB          0x84E2\ntypedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);\ntypedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glActiveTextureARB (GLenum texture);\nGLAPI void APIENTRY glClientActiveTextureARB (GLenum texture);\nGLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s);\nGLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s);\nGLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s);\nGLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s);\nGLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t);\nGLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t);\nGLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t);\nGLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t);\nGLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r);\nGLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r);\nGLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r);\nGLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r);\nGLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v);\nGLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\nGLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v);\nGLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\nGLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v);\nGLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q);\nGLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v);\nGLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\nGLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v);\n#endif\n#endif /* GL_ARB_multitexture */\n\n#ifndef GL_ARB_occlusion_query\n#define GL_ARB_occlusion_query 1\n#define GL_QUERY_COUNTER_BITS_ARB         0x8864\n#define GL_CURRENT_QUERY_ARB              0x8865\n#define GL_QUERY_RESULT_ARB               0x8866\n#define GL_QUERY_RESULT_AVAILABLE_ARB     0x8867\n#define GL_SAMPLES_PASSED_ARB             0x8914\ntypedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);\ntypedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);\ntypedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);\ntypedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids);\nGLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids);\nGLAPI GLboolean APIENTRY glIsQueryARB (GLuint id);\nGLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id);\nGLAPI void APIENTRY glEndQueryARB (GLenum target);\nGLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params);\n#endif\n#endif /* GL_ARB_occlusion_query */\n\n#ifndef GL_ARB_occlusion_query2\n#define GL_ARB_occlusion_query2 1\n#endif /* GL_ARB_occlusion_query2 */\n\n#ifndef GL_ARB_pipeline_statistics_query\n#define GL_ARB_pipeline_statistics_query 1\n#define GL_VERTICES_SUBMITTED_ARB         0x82EE\n#define GL_PRIMITIVES_SUBMITTED_ARB       0x82EF\n#define GL_VERTEX_SHADER_INVOCATIONS_ARB  0x82F0\n#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1\n#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2\n#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3\n#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4\n#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5\n#define GL_CLIPPING_INPUT_PRIMITIVES_ARB  0x82F6\n#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7\n#endif /* GL_ARB_pipeline_statistics_query */\n\n#ifndef GL_ARB_pixel_buffer_object\n#define GL_ARB_pixel_buffer_object 1\n#define GL_PIXEL_PACK_BUFFER_ARB          0x88EB\n#define GL_PIXEL_UNPACK_BUFFER_ARB        0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING_ARB  0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF\n#endif /* GL_ARB_pixel_buffer_object */\n\n#ifndef GL_ARB_point_parameters\n#define GL_ARB_point_parameters 1\n#define GL_POINT_SIZE_MIN_ARB             0x8126\n#define GL_POINT_SIZE_MAX_ARB             0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_ARB  0x8128\n#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params);\n#endif\n#endif /* GL_ARB_point_parameters */\n\n#ifndef GL_ARB_point_sprite\n#define GL_ARB_point_sprite 1\n#define GL_POINT_SPRITE_ARB               0x8861\n#define GL_COORD_REPLACE_ARB              0x8862\n#endif /* GL_ARB_point_sprite */\n\n#ifndef GL_ARB_program_interface_query\n#define GL_ARB_program_interface_query 1\n#endif /* GL_ARB_program_interface_query */\n\n#ifndef GL_ARB_provoking_vertex\n#define GL_ARB_provoking_vertex 1\n#endif /* GL_ARB_provoking_vertex */\n\n#ifndef GL_ARB_query_buffer_object\n#define GL_ARB_query_buffer_object 1\n#endif /* GL_ARB_query_buffer_object */\n\n#ifndef GL_ARB_robust_buffer_access_behavior\n#define GL_ARB_robust_buffer_access_behavior 1\n#endif /* GL_ARB_robust_buffer_access_behavior */\n\n#ifndef GL_ARB_robustness\n#define GL_ARB_robustness 1\n#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define GL_LOSE_CONTEXT_ON_RESET_ARB      0x8252\n#define GL_GUILTY_CONTEXT_RESET_ARB       0x8253\n#define GL_INNOCENT_CONTEXT_RESET_ARB     0x8254\n#define GL_UNKNOWN_CONTEXT_RESET_ARB      0x8255\n#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define GL_NO_RESET_NOTIFICATION_ARB      0x8261\ntypedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);\ntypedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img);\ntypedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\ntypedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params);\ntypedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);\ntypedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);\ntypedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values);\ntypedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values);\ntypedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern);\ntypedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);\ntypedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);\ntypedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);\ntypedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\ntypedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void);\nGLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img);\nGLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\nGLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img);\nGLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);\nGLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params);\nGLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params);\nGLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\nGLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);\nGLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);\nGLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v);\nGLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values);\nGLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values);\nGLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values);\nGLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern);\nGLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);\nGLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);\nGLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);\nGLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\nGLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);\n#endif\n#endif /* GL_ARB_robustness */\n\n#ifndef GL_ARB_robustness_isolation\n#define GL_ARB_robustness_isolation 1\n#endif /* GL_ARB_robustness_isolation */\n\n#ifndef GL_ARB_sample_shading\n#define GL_ARB_sample_shading 1\n#define GL_SAMPLE_SHADING_ARB             0x8C36\n#define GL_MIN_SAMPLE_SHADING_VALUE_ARB   0x8C37\ntypedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMinSampleShadingARB (GLfloat value);\n#endif\n#endif /* GL_ARB_sample_shading */\n\n#ifndef GL_ARB_sampler_objects\n#define GL_ARB_sampler_objects 1\n#endif /* GL_ARB_sampler_objects */\n\n#ifndef GL_ARB_seamless_cube_map\n#define GL_ARB_seamless_cube_map 1\n#endif /* GL_ARB_seamless_cube_map */\n\n#ifndef GL_ARB_seamless_cubemap_per_texture\n#define GL_ARB_seamless_cubemap_per_texture 1\n#endif /* GL_ARB_seamless_cubemap_per_texture */\n\n#ifndef GL_ARB_separate_shader_objects\n#define GL_ARB_separate_shader_objects 1\n#endif /* GL_ARB_separate_shader_objects */\n\n#ifndef GL_ARB_shader_atomic_counters\n#define GL_ARB_shader_atomic_counters 1\n#endif /* GL_ARB_shader_atomic_counters */\n\n#ifndef GL_ARB_shader_bit_encoding\n#define GL_ARB_shader_bit_encoding 1\n#endif /* GL_ARB_shader_bit_encoding */\n\n#ifndef GL_ARB_shader_draw_parameters\n#define GL_ARB_shader_draw_parameters 1\n#endif /* GL_ARB_shader_draw_parameters */\n\n#ifndef GL_ARB_shader_group_vote\n#define GL_ARB_shader_group_vote 1\n#endif /* GL_ARB_shader_group_vote */\n\n#ifndef GL_ARB_shader_image_load_store\n#define GL_ARB_shader_image_load_store 1\n#endif /* GL_ARB_shader_image_load_store */\n\n#ifndef GL_ARB_shader_image_size\n#define GL_ARB_shader_image_size 1\n#endif /* GL_ARB_shader_image_size */\n\n#ifndef GL_ARB_shader_objects\n#define GL_ARB_shader_objects 1\n#ifdef __APPLE__\ntypedef void *GLhandleARB;\n#else\ntypedef unsigned int GLhandleARB;\n#endif\ntypedef char GLcharARB;\n#define GL_PROGRAM_OBJECT_ARB             0x8B40\n#define GL_SHADER_OBJECT_ARB              0x8B48\n#define GL_OBJECT_TYPE_ARB                0x8B4E\n#define GL_OBJECT_SUBTYPE_ARB             0x8B4F\n#define GL_FLOAT_VEC2_ARB                 0x8B50\n#define GL_FLOAT_VEC3_ARB                 0x8B51\n#define GL_FLOAT_VEC4_ARB                 0x8B52\n#define GL_INT_VEC2_ARB                   0x8B53\n#define GL_INT_VEC3_ARB                   0x8B54\n#define GL_INT_VEC4_ARB                   0x8B55\n#define GL_BOOL_ARB                       0x8B56\n#define GL_BOOL_VEC2_ARB                  0x8B57\n#define GL_BOOL_VEC3_ARB                  0x8B58\n#define GL_BOOL_VEC4_ARB                  0x8B59\n#define GL_FLOAT_MAT2_ARB                 0x8B5A\n#define GL_FLOAT_MAT3_ARB                 0x8B5B\n#define GL_FLOAT_MAT4_ARB                 0x8B5C\n#define GL_SAMPLER_1D_ARB                 0x8B5D\n#define GL_SAMPLER_2D_ARB                 0x8B5E\n#define GL_SAMPLER_3D_ARB                 0x8B5F\n#define GL_SAMPLER_CUBE_ARB               0x8B60\n#define GL_SAMPLER_1D_SHADOW_ARB          0x8B61\n#define GL_SAMPLER_2D_SHADOW_ARB          0x8B62\n#define GL_SAMPLER_2D_RECT_ARB            0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW_ARB     0x8B64\n#define GL_OBJECT_DELETE_STATUS_ARB       0x8B80\n#define GL_OBJECT_COMPILE_STATUS_ARB      0x8B81\n#define GL_OBJECT_LINK_STATUS_ARB         0x8B82\n#define GL_OBJECT_VALIDATE_STATUS_ARB     0x8B83\n#define GL_OBJECT_INFO_LOG_LENGTH_ARB     0x8B84\n#define GL_OBJECT_ATTACHED_OBJECTS_ARB    0x8B85\n#define GL_OBJECT_ACTIVE_UNIFORMS_ARB     0x8B86\n#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87\n#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88\ntypedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);\ntypedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);\ntypedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);\ntypedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);\ntypedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length);\ntypedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);\ntypedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);\ntypedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);\ntypedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);\ntypedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);\ntypedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);\ntypedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);\ntypedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);\ntypedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);\ntypedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj);\nGLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname);\nGLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj);\nGLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType);\nGLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length);\nGLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj);\nGLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);\nGLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj);\nGLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj);\nGLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj);\nGLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj);\nGLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0);\nGLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1);\nGLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nGLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nGLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0);\nGLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1);\nGLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2);\nGLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nGLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);\nGLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);\nGLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name);\nGLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);\nGLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params);\nGLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params);\nGLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);\n#endif\n#endif /* GL_ARB_shader_objects */\n\n#ifndef GL_ARB_shader_precision\n#define GL_ARB_shader_precision 1\n#endif /* GL_ARB_shader_precision */\n\n#ifndef GL_ARB_shader_stencil_export\n#define GL_ARB_shader_stencil_export 1\n#endif /* GL_ARB_shader_stencil_export */\n\n#ifndef GL_ARB_shader_storage_buffer_object\n#define GL_ARB_shader_storage_buffer_object 1\n#endif /* GL_ARB_shader_storage_buffer_object */\n\n#ifndef GL_ARB_shader_subroutine\n#define GL_ARB_shader_subroutine 1\n#endif /* GL_ARB_shader_subroutine */\n\n#ifndef GL_ARB_shader_texture_image_samples\n#define GL_ARB_shader_texture_image_samples 1\n#endif /* GL_ARB_shader_texture_image_samples */\n\n#ifndef GL_ARB_shader_texture_lod\n#define GL_ARB_shader_texture_lod 1\n#endif /* GL_ARB_shader_texture_lod */\n\n#ifndef GL_ARB_shading_language_100\n#define GL_ARB_shading_language_100 1\n#define GL_SHADING_LANGUAGE_VERSION_ARB   0x8B8C\n#endif /* GL_ARB_shading_language_100 */\n\n#ifndef GL_ARB_shading_language_420pack\n#define GL_ARB_shading_language_420pack 1\n#endif /* GL_ARB_shading_language_420pack */\n\n#ifndef GL_ARB_shading_language_include\n#define GL_ARB_shading_language_include 1\n#define GL_SHADER_INCLUDE_ARB             0x8DAE\n#define GL_NAMED_STRING_LENGTH_ARB        0x8DE9\n#define GL_NAMED_STRING_TYPE_ARB          0x8DEA\ntypedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);\ntypedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);\ntypedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length);\ntypedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);\ntypedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string);\nGLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name);\nGLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length);\nGLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name);\nGLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string);\nGLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params);\n#endif\n#endif /* GL_ARB_shading_language_include */\n\n#ifndef GL_ARB_shading_language_packing\n#define GL_ARB_shading_language_packing 1\n#endif /* GL_ARB_shading_language_packing */\n\n#ifndef GL_ARB_shadow\n#define GL_ARB_shadow 1\n#define GL_TEXTURE_COMPARE_MODE_ARB       0x884C\n#define GL_TEXTURE_COMPARE_FUNC_ARB       0x884D\n#define GL_COMPARE_R_TO_TEXTURE_ARB       0x884E\n#endif /* GL_ARB_shadow */\n\n#ifndef GL_ARB_shadow_ambient\n#define GL_ARB_shadow_ambient 1\n#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF\n#endif /* GL_ARB_shadow_ambient */\n\n#ifndef GL_ARB_sparse_buffer\n#define GL_ARB_sparse_buffer 1\n#define GL_SPARSE_STORAGE_BIT_ARB         0x0400\n#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB    0x82F8\ntypedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizei size, GLboolean commit);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizei size, GLboolean commit);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizei size, GLboolean commit);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizei size, GLboolean commit);\nGLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizei size, GLboolean commit);\nGLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizei size, GLboolean commit);\n#endif\n#endif /* GL_ARB_sparse_buffer */\n\n#ifndef GL_ARB_sparse_texture\n#define GL_ARB_sparse_texture 1\n#define GL_TEXTURE_SPARSE_ARB             0x91A6\n#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB    0x91A7\n#define GL_MIN_SPARSE_LEVEL_ARB           0x919B\n#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB     0x91A8\n#define GL_VIRTUAL_PAGE_SIZE_X_ARB        0x9195\n#define GL_VIRTUAL_PAGE_SIZE_Y_ARB        0x9196\n#define GL_VIRTUAL_PAGE_SIZE_Z_ARB        0x9197\n#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB    0x9198\n#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199\n#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A\n#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9\ntypedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident);\n#endif\n#endif /* GL_ARB_sparse_texture */\n\n#ifndef GL_ARB_stencil_texturing\n#define GL_ARB_stencil_texturing 1\n#endif /* GL_ARB_stencil_texturing */\n\n#ifndef GL_ARB_sync\n#define GL_ARB_sync 1\n#endif /* GL_ARB_sync */\n\n#ifndef GL_ARB_tessellation_shader\n#define GL_ARB_tessellation_shader 1\n#endif /* GL_ARB_tessellation_shader */\n\n#ifndef GL_ARB_texture_barrier\n#define GL_ARB_texture_barrier 1\n#endif /* GL_ARB_texture_barrier */\n\n#ifndef GL_ARB_texture_border_clamp\n#define GL_ARB_texture_border_clamp 1\n#define GL_CLAMP_TO_BORDER_ARB            0x812D\n#endif /* GL_ARB_texture_border_clamp */\n\n#ifndef GL_ARB_texture_buffer_object\n#define GL_ARB_texture_buffer_object 1\n#define GL_TEXTURE_BUFFER_ARB             0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB    0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER_ARB     0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D\n#define GL_TEXTURE_BUFFER_FORMAT_ARB      0x8C2E\ntypedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer);\n#endif\n#endif /* GL_ARB_texture_buffer_object */\n\n#ifndef GL_ARB_texture_buffer_object_rgb32\n#define GL_ARB_texture_buffer_object_rgb32 1\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\n\n#ifndef GL_ARB_texture_buffer_range\n#define GL_ARB_texture_buffer_range 1\n#endif /* GL_ARB_texture_buffer_range */\n\n#ifndef GL_ARB_texture_compression\n#define GL_ARB_texture_compression 1\n#define GL_COMPRESSED_ALPHA_ARB           0x84E9\n#define GL_COMPRESSED_LUMINANCE_ARB       0x84EA\n#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB\n#define GL_COMPRESSED_INTENSITY_ARB       0x84EC\n#define GL_COMPRESSED_RGB_ARB             0x84ED\n#define GL_COMPRESSED_RGBA_ARB            0x84EE\n#define GL_TEXTURE_COMPRESSION_HINT_ARB   0x84EF\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0\n#define GL_TEXTURE_COMPRESSED_ARB         0x86A1\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\nGLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img);\n#endif\n#endif /* GL_ARB_texture_compression */\n\n#ifndef GL_ARB_texture_compression_bptc\n#define GL_ARB_texture_compression_bptc 1\n#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F\n#endif /* GL_ARB_texture_compression_bptc */\n\n#ifndef GL_ARB_texture_compression_rgtc\n#define GL_ARB_texture_compression_rgtc 1\n#endif /* GL_ARB_texture_compression_rgtc */\n\n#ifndef GL_ARB_texture_cube_map\n#define GL_ARB_texture_cube_map 1\n#define GL_NORMAL_MAP_ARB                 0x8511\n#define GL_REFLECTION_MAP_ARB             0x8512\n#define GL_TEXTURE_CUBE_MAP_ARB           0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARB   0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARB     0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB  0x851C\n#endif /* GL_ARB_texture_cube_map */\n\n#ifndef GL_ARB_texture_cube_map_array\n#define GL_ARB_texture_cube_map_array 1\n#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB     0x9009\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B\n#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB     0x900C\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F\n#endif /* GL_ARB_texture_cube_map_array */\n\n#ifndef GL_ARB_texture_env_add\n#define GL_ARB_texture_env_add 1\n#endif /* GL_ARB_texture_env_add */\n\n#ifndef GL_ARB_texture_env_combine\n#define GL_ARB_texture_env_combine 1\n#define GL_COMBINE_ARB                    0x8570\n#define GL_COMBINE_RGB_ARB                0x8571\n#define GL_COMBINE_ALPHA_ARB              0x8572\n#define GL_SOURCE0_RGB_ARB                0x8580\n#define GL_SOURCE1_RGB_ARB                0x8581\n#define GL_SOURCE2_RGB_ARB                0x8582\n#define GL_SOURCE0_ALPHA_ARB              0x8588\n#define GL_SOURCE1_ALPHA_ARB              0x8589\n#define GL_SOURCE2_ALPHA_ARB              0x858A\n#define GL_OPERAND0_RGB_ARB               0x8590\n#define GL_OPERAND1_RGB_ARB               0x8591\n#define GL_OPERAND2_RGB_ARB               0x8592\n#define GL_OPERAND0_ALPHA_ARB             0x8598\n#define GL_OPERAND1_ALPHA_ARB             0x8599\n#define GL_OPERAND2_ALPHA_ARB             0x859A\n#define GL_RGB_SCALE_ARB                  0x8573\n#define GL_ADD_SIGNED_ARB                 0x8574\n#define GL_INTERPOLATE_ARB                0x8575\n#define GL_SUBTRACT_ARB                   0x84E7\n#define GL_CONSTANT_ARB                   0x8576\n#define GL_PRIMARY_COLOR_ARB              0x8577\n#define GL_PREVIOUS_ARB                   0x8578\n#endif /* GL_ARB_texture_env_combine */\n\n#ifndef GL_ARB_texture_env_crossbar\n#define GL_ARB_texture_env_crossbar 1\n#endif /* GL_ARB_texture_env_crossbar */\n\n#ifndef GL_ARB_texture_env_dot3\n#define GL_ARB_texture_env_dot3 1\n#define GL_DOT3_RGB_ARB                   0x86AE\n#define GL_DOT3_RGBA_ARB                  0x86AF\n#endif /* GL_ARB_texture_env_dot3 */\n\n#ifndef GL_ARB_texture_float\n#define GL_ARB_texture_float 1\n#define GL_TEXTURE_RED_TYPE_ARB           0x8C10\n#define GL_TEXTURE_GREEN_TYPE_ARB         0x8C11\n#define GL_TEXTURE_BLUE_TYPE_ARB          0x8C12\n#define GL_TEXTURE_ALPHA_TYPE_ARB         0x8C13\n#define GL_TEXTURE_LUMINANCE_TYPE_ARB     0x8C14\n#define GL_TEXTURE_INTENSITY_TYPE_ARB     0x8C15\n#define GL_TEXTURE_DEPTH_TYPE_ARB         0x8C16\n#define GL_UNSIGNED_NORMALIZED_ARB        0x8C17\n#define GL_RGBA32F_ARB                    0x8814\n#define GL_RGB32F_ARB                     0x8815\n#define GL_ALPHA32F_ARB                   0x8816\n#define GL_INTENSITY32F_ARB               0x8817\n#define GL_LUMINANCE32F_ARB               0x8818\n#define GL_LUMINANCE_ALPHA32F_ARB         0x8819\n#define GL_RGBA16F_ARB                    0x881A\n#define GL_RGB16F_ARB                     0x881B\n#define GL_ALPHA16F_ARB                   0x881C\n#define GL_INTENSITY16F_ARB               0x881D\n#define GL_LUMINANCE16F_ARB               0x881E\n#define GL_LUMINANCE_ALPHA16F_ARB         0x881F\n#endif /* GL_ARB_texture_float */\n\n#ifndef GL_ARB_texture_gather\n#define GL_ARB_texture_gather 1\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F\n#endif /* GL_ARB_texture_gather */\n\n#ifndef GL_ARB_texture_mirror_clamp_to_edge\n#define GL_ARB_texture_mirror_clamp_to_edge 1\n#endif /* GL_ARB_texture_mirror_clamp_to_edge */\n\n#ifndef GL_ARB_texture_mirrored_repeat\n#define GL_ARB_texture_mirrored_repeat 1\n#define GL_MIRRORED_REPEAT_ARB            0x8370\n#endif /* GL_ARB_texture_mirrored_repeat */\n\n#ifndef GL_ARB_texture_multisample\n#define GL_ARB_texture_multisample 1\n#endif /* GL_ARB_texture_multisample */\n\n#ifndef GL_ARB_texture_non_power_of_two\n#define GL_ARB_texture_non_power_of_two 1\n#endif /* GL_ARB_texture_non_power_of_two */\n\n#ifndef GL_ARB_texture_query_levels\n#define GL_ARB_texture_query_levels 1\n#endif /* GL_ARB_texture_query_levels */\n\n#ifndef GL_ARB_texture_query_lod\n#define GL_ARB_texture_query_lod 1\n#endif /* GL_ARB_texture_query_lod */\n\n#ifndef GL_ARB_texture_rectangle\n#define GL_ARB_texture_rectangle 1\n#define GL_TEXTURE_RECTANGLE_ARB          0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE_ARB  0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE_ARB    0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8\n#endif /* GL_ARB_texture_rectangle */\n\n#ifndef GL_ARB_texture_rg\n#define GL_ARB_texture_rg 1\n#endif /* GL_ARB_texture_rg */\n\n#ifndef GL_ARB_texture_rgb10_a2ui\n#define GL_ARB_texture_rgb10_a2ui 1\n#endif /* GL_ARB_texture_rgb10_a2ui */\n\n#ifndef GL_ARB_texture_stencil8\n#define GL_ARB_texture_stencil8 1\n#endif /* GL_ARB_texture_stencil8 */\n\n#ifndef GL_ARB_texture_storage\n#define GL_ARB_texture_storage 1\n#endif /* GL_ARB_texture_storage */\n\n#ifndef GL_ARB_texture_storage_multisample\n#define GL_ARB_texture_storage_multisample 1\n#endif /* GL_ARB_texture_storage_multisample */\n\n#ifndef GL_ARB_texture_swizzle\n#define GL_ARB_texture_swizzle 1\n#endif /* GL_ARB_texture_swizzle */\n\n#ifndef GL_ARB_texture_view\n#define GL_ARB_texture_view 1\n#endif /* GL_ARB_texture_view */\n\n#ifndef GL_ARB_timer_query\n#define GL_ARB_timer_query 1\n#endif /* GL_ARB_timer_query */\n\n#ifndef GL_ARB_transform_feedback2\n#define GL_ARB_transform_feedback2 1\n#define GL_TRANSFORM_FEEDBACK_PAUSED      0x8E23\n#define GL_TRANSFORM_FEEDBACK_ACTIVE      0x8E24\n#endif /* GL_ARB_transform_feedback2 */\n\n#ifndef GL_ARB_transform_feedback3\n#define GL_ARB_transform_feedback3 1\n#endif /* GL_ARB_transform_feedback3 */\n\n#ifndef GL_ARB_transform_feedback_instanced\n#define GL_ARB_transform_feedback_instanced 1\n#endif /* GL_ARB_transform_feedback_instanced */\n\n#ifndef GL_ARB_transform_feedback_overflow_query\n#define GL_ARB_transform_feedback_overflow_query 1\n#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC\n#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED\n#endif /* GL_ARB_transform_feedback_overflow_query */\n\n#ifndef GL_ARB_transpose_matrix\n#define GL_ARB_transpose_matrix 1\n#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3\n#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4\n#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB   0x84E5\n#define GL_TRANSPOSE_COLOR_MATRIX_ARB     0x84E6\ntypedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);\ntypedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);\ntypedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m);\nGLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m);\nGLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m);\nGLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m);\n#endif\n#endif /* GL_ARB_transpose_matrix */\n\n#ifndef GL_ARB_uniform_buffer_object\n#define GL_ARB_uniform_buffer_object 1\n#endif /* GL_ARB_uniform_buffer_object */\n\n#ifndef GL_ARB_vertex_array_bgra\n#define GL_ARB_vertex_array_bgra 1\n#endif /* GL_ARB_vertex_array_bgra */\n\n#ifndef GL_ARB_vertex_array_object\n#define GL_ARB_vertex_array_object 1\n#endif /* GL_ARB_vertex_array_object */\n\n#ifndef GL_ARB_vertex_attrib_64bit\n#define GL_ARB_vertex_attrib_64bit 1\n#endif /* GL_ARB_vertex_attrib_64bit */\n\n#ifndef GL_ARB_vertex_attrib_binding\n#define GL_ARB_vertex_attrib_binding 1\n#endif /* GL_ARB_vertex_attrib_binding */\n\n#ifndef GL_ARB_vertex_blend\n#define GL_ARB_vertex_blend 1\n#define GL_MAX_VERTEX_UNITS_ARB           0x86A4\n#define GL_ACTIVE_VERTEX_UNITS_ARB        0x86A5\n#define GL_WEIGHT_SUM_UNITY_ARB           0x86A6\n#define GL_VERTEX_BLEND_ARB               0x86A7\n#define GL_CURRENT_WEIGHT_ARB             0x86A8\n#define GL_WEIGHT_ARRAY_TYPE_ARB          0x86A9\n#define GL_WEIGHT_ARRAY_STRIDE_ARB        0x86AA\n#define GL_WEIGHT_ARRAY_SIZE_ARB          0x86AB\n#define GL_WEIGHT_ARRAY_POINTER_ARB       0x86AC\n#define GL_WEIGHT_ARRAY_ARB               0x86AD\n#define GL_MODELVIEW0_ARB                 0x1700\n#define GL_MODELVIEW1_ARB                 0x850A\n#define GL_MODELVIEW2_ARB                 0x8722\n#define GL_MODELVIEW3_ARB                 0x8723\n#define GL_MODELVIEW4_ARB                 0x8724\n#define GL_MODELVIEW5_ARB                 0x8725\n#define GL_MODELVIEW6_ARB                 0x8726\n#define GL_MODELVIEW7_ARB                 0x8727\n#define GL_MODELVIEW8_ARB                 0x8728\n#define GL_MODELVIEW9_ARB                 0x8729\n#define GL_MODELVIEW10_ARB                0x872A\n#define GL_MODELVIEW11_ARB                0x872B\n#define GL_MODELVIEW12_ARB                0x872C\n#define GL_MODELVIEW13_ARB                0x872D\n#define GL_MODELVIEW14_ARB                0x872E\n#define GL_MODELVIEW15_ARB                0x872F\n#define GL_MODELVIEW16_ARB                0x8730\n#define GL_MODELVIEW17_ARB                0x8731\n#define GL_MODELVIEW18_ARB                0x8732\n#define GL_MODELVIEW19_ARB                0x8733\n#define GL_MODELVIEW20_ARB                0x8734\n#define GL_MODELVIEW21_ARB                0x8735\n#define GL_MODELVIEW22_ARB                0x8736\n#define GL_MODELVIEW23_ARB                0x8737\n#define GL_MODELVIEW24_ARB                0x8738\n#define GL_MODELVIEW25_ARB                0x8739\n#define GL_MODELVIEW26_ARB                0x873A\n#define GL_MODELVIEW27_ARB                0x873B\n#define GL_MODELVIEW28_ARB                0x873C\n#define GL_MODELVIEW29_ARB                0x873D\n#define GL_MODELVIEW30_ARB                0x873E\n#define GL_MODELVIEW31_ARB                0x873F\ntypedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);\ntypedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights);\nGLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights);\nGLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights);\nGLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights);\nGLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights);\nGLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights);\nGLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights);\nGLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights);\nGLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glVertexBlendARB (GLint count);\n#endif\n#endif /* GL_ARB_vertex_blend */\n\n#ifndef GL_ARB_vertex_buffer_object\n#define GL_ARB_vertex_buffer_object 1\n/* HACK: This is a workaround for gltypes.h on OS X 10.9 defining these types as\n *       long instead of ptrdiff_t\n */\n#if defined(__APPLE__)\ntypedef long GLsizeiptrARB;\ntypedef long GLintptrARB;\n#else\ntypedef ptrdiff_t GLsizeiptrARB;\ntypedef ptrdiff_t GLintptrARB;\n#endif\n#define GL_BUFFER_SIZE_ARB                0x8764\n#define GL_BUFFER_USAGE_ARB               0x8765\n#define GL_ARRAY_BUFFER_ARB               0x8892\n#define GL_ELEMENT_ARRAY_BUFFER_ARB       0x8893\n#define GL_ARRAY_BUFFER_BINDING_ARB       0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895\n#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896\n#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897\n#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898\n#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F\n#define GL_READ_ONLY_ARB                  0x88B8\n#define GL_WRITE_ONLY_ARB                 0x88B9\n#define GL_READ_WRITE_ARB                 0x88BA\n#define GL_BUFFER_ACCESS_ARB              0x88BB\n#define GL_BUFFER_MAPPED_ARB              0x88BC\n#define GL_BUFFER_MAP_POINTER_ARB         0x88BD\n#define GL_STREAM_DRAW_ARB                0x88E0\n#define GL_STREAM_READ_ARB                0x88E1\n#define GL_STREAM_COPY_ARB                0x88E2\n#define GL_STATIC_DRAW_ARB                0x88E4\n#define GL_STATIC_READ_ARB                0x88E5\n#define GL_STATIC_COPY_ARB                0x88E6\n#define GL_DYNAMIC_DRAW_ARB               0x88E8\n#define GL_DYNAMIC_READ_ARB               0x88E9\n#define GL_DYNAMIC_COPY_ARB               0x88EA\ntypedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);\ntypedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);\ntypedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);\ntypedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage);\ntypedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data);\ntypedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data);\ntypedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);\ntypedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer);\nGLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers);\nGLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers);\nGLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer);\nGLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage);\nGLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data);\nGLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data);\nGLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access);\nGLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target);\nGLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params);\n#endif\n#endif /* GL_ARB_vertex_buffer_object */\n\n#ifndef GL_ARB_vertex_program\n#define GL_ARB_vertex_program 1\n#define GL_COLOR_SUM_ARB                  0x8458\n#define GL_VERTEX_PROGRAM_ARB             0x8620\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB   0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB   0x8625\n#define GL_CURRENT_VERTEX_ATTRIB_ARB      0x8626\n#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB  0x8642\n#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB    0x8643\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645\n#define GL_MAX_VERTEX_ATTRIBS_ARB         0x8869\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A\n#define GL_PROGRAM_ADDRESS_REGISTERS_ARB  0x88B0\n#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1\n#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2\n#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x);\nGLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x);\nGLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x);\nGLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y);\nGLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y);\nGLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\nGLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index);\nGLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index);\nGLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer);\n#endif\n#endif /* GL_ARB_vertex_program */\n\n#ifndef GL_ARB_vertex_shader\n#define GL_ARB_vertex_shader 1\n#define GL_VERTEX_SHADER_ARB              0x8B31\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A\n#define GL_MAX_VARYING_FLOATS_ARB         0x8B4B\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D\n#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB   0x8B89\n#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A\ntypedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);\ntypedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);\ntypedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name);\nGLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);\nGLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name);\n#endif\n#endif /* GL_ARB_vertex_shader */\n\n#ifndef GL_ARB_vertex_type_10f_11f_11f_rev\n#define GL_ARB_vertex_type_10f_11f_11f_rev 1\n#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */\n\n#ifndef GL_ARB_vertex_type_2_10_10_10_rev\n#define GL_ARB_vertex_type_2_10_10_10_rev 1\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\n\n#ifndef GL_ARB_viewport_array\n#define GL_ARB_viewport_array 1\n#endif /* GL_ARB_viewport_array */\n\n#ifndef GL_ARB_window_pos\n#define GL_ARB_window_pos 1\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y);\nGLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y);\nGLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y);\nGLAPI void APIENTRY glWindowPos2ivARB (const GLint *v);\nGLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y);\nGLAPI void APIENTRY glWindowPos2svARB (const GLshort *v);\nGLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glWindowPos3ivARB (const GLint *v);\nGLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glWindowPos3svARB (const GLshort *v);\n#endif\n#endif /* GL_ARB_window_pos */\n\n#ifndef GL_KHR_blend_equation_advanced\n#define GL_KHR_blend_equation_advanced 1\n#define GL_MULTIPLY_KHR                   0x9294\n#define GL_SCREEN_KHR                     0x9295\n#define GL_OVERLAY_KHR                    0x9296\n#define GL_DARKEN_KHR                     0x9297\n#define GL_LIGHTEN_KHR                    0x9298\n#define GL_COLORDODGE_KHR                 0x9299\n#define GL_COLORBURN_KHR                  0x929A\n#define GL_HARDLIGHT_KHR                  0x929B\n#define GL_SOFTLIGHT_KHR                  0x929C\n#define GL_DIFFERENCE_KHR                 0x929E\n#define GL_EXCLUSION_KHR                  0x92A0\n#define GL_HSL_HUE_KHR                    0x92AD\n#define GL_HSL_SATURATION_KHR             0x92AE\n#define GL_HSL_COLOR_KHR                  0x92AF\n#define GL_HSL_LUMINOSITY_KHR             0x92B0\ntypedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendBarrierKHR (void);\n#endif\n#endif /* GL_KHR_blend_equation_advanced */\n\n#ifndef GL_KHR_blend_equation_advanced_coherent\n#define GL_KHR_blend_equation_advanced_coherent 1\n#define GL_BLEND_ADVANCED_COHERENT_KHR    0x9285\n#endif /* GL_KHR_blend_equation_advanced_coherent */\n\n#ifndef GL_KHR_context_flush_control\n#define GL_KHR_context_flush_control 1\n#endif /* GL_KHR_context_flush_control */\n\n#ifndef GL_KHR_debug\n#define GL_KHR_debug 1\n#endif /* GL_KHR_debug */\n\n#ifndef GL_KHR_robust_buffer_access_behavior\n#define GL_KHR_robust_buffer_access_behavior 1\n#endif /* GL_KHR_robust_buffer_access_behavior */\n\n#ifndef GL_KHR_robustness\n#define GL_KHR_robustness 1\n#define GL_CONTEXT_ROBUST_ACCESS          0x90F3\n#endif /* GL_KHR_robustness */\n\n#ifndef GL_KHR_texture_compression_astc_hdr\n#define GL_KHR_texture_compression_astc_hdr 1\n#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR   0x93B0\n#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR   0x93B1\n#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR   0x93B2\n#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR   0x93B3\n#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR   0x93B4\n#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR   0x93B5\n#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR   0x93B6\n#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR   0x93B7\n#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR  0x93B8\n#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR  0x93B9\n#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR  0x93BA\n#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB\n#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC\n#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD\n#endif /* GL_KHR_texture_compression_astc_hdr */\n\n#ifndef GL_KHR_texture_compression_astc_ldr\n#define GL_KHR_texture_compression_astc_ldr 1\n#endif /* GL_KHR_texture_compression_astc_ldr */\n\n#ifndef GL_OES_byte_coordinates\n#define GL_OES_byte_coordinates 1\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s);\ntypedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t);\ntypedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r);\ntypedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q);\ntypedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y);\ntypedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z);\ntypedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w);\ntypedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s);\nGLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords);\nGLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t);\nGLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords);\nGLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r);\nGLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords);\nGLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q);\nGLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords);\nGLAPI void APIENTRY glTexCoord1bOES (GLbyte s);\nGLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t);\nGLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r);\nGLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q);\nGLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y);\nGLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z);\nGLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords);\nGLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w);\nGLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords);\n#endif\n#endif /* GL_OES_byte_coordinates */\n\n#ifndef GL_OES_compressed_paletted_texture\n#define GL_OES_compressed_paletted_texture 1\n#define GL_PALETTE4_RGB8_OES              0x8B90\n#define GL_PALETTE4_RGBA8_OES             0x8B91\n#define GL_PALETTE4_R5_G6_B5_OES          0x8B92\n#define GL_PALETTE4_RGBA4_OES             0x8B93\n#define GL_PALETTE4_RGB5_A1_OES           0x8B94\n#define GL_PALETTE8_RGB8_OES              0x8B95\n#define GL_PALETTE8_RGBA8_OES             0x8B96\n#define GL_PALETTE8_R5_G6_B5_OES          0x8B97\n#define GL_PALETTE8_RGBA4_OES             0x8B98\n#define GL_PALETTE8_RGB5_A1_OES           0x8B99\n#endif /* GL_OES_compressed_paletted_texture */\n\n#ifndef GL_OES_fixed_point\n#define GL_OES_fixed_point 1\ntypedef GLint GLfixed;\n#define GL_FIXED_OES                      0x140C\ntypedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref);\ntypedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\ntypedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth);\ntypedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);\ntypedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\ntypedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f);\ntypedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param);\ntypedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);\ntypedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation);\ntypedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param);\ntypedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);\ntypedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);\ntypedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param);\ntypedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);\ntypedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);\ntypedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);\ntypedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);\ntypedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);\ntypedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert);\ntypedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);\ntypedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);\ntypedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value);\ntypedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap);\ntypedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\ntypedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\ntypedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue);\ntypedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components);\ntypedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u);\ntypedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v);\ntypedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v);\ntypedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values);\ntypedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params);\ntypedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component);\ntypedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component);\ntypedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m);\ntypedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points);\ntypedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points);\ntypedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2);\ntypedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2);\ntypedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token);\ntypedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values);\ntypedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor);\ntypedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities);\ntypedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y);\ntypedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z);\ntypedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w);\ntypedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2);\ntypedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2);\ntypedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s);\ntypedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t);\ntypedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r);\ntypedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q);\ntypedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);\ntypedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);\ntypedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x);\ntypedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y);\ntypedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords);\ntypedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z);\ntypedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref);\nGLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\nGLAPI void APIENTRY glClearDepthxOES (GLfixed depth);\nGLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);\nGLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\nGLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f);\nGLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param);\nGLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param);\nGLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);\nGLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation);\nGLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param);\nGLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param);\nGLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glLineWidthxOES (GLfixed width);\nGLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m);\nGLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param);\nGLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m);\nGLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q);\nGLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);\nGLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f);\nGLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glPointSizexOES (GLfixed size);\nGLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);\nGLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);\nGLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert);\nGLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);\nGLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);\nGLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value);\nGLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap);\nGLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\nGLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\nGLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue);\nGLAPI void APIENTRY glColor3xvOES (const GLfixed *components);\nGLAPI void APIENTRY glColor4xvOES (const GLfixed *components);\nGLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glEvalCoord1xOES (GLfixed u);\nGLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v);\nGLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer);\nGLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v);\nGLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values);\nGLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params);\nGLAPI void APIENTRY glIndexxOES (GLfixed component);\nGLAPI void APIENTRY glIndexxvOES (const GLfixed *component);\nGLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m);\nGLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points);\nGLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points);\nGLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2);\nGLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2);\nGLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m);\nGLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s);\nGLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords);\nGLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t);\nGLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords);\nGLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r);\nGLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords);\nGLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords);\nGLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glPassThroughxOES (GLfixed token);\nGLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values);\nGLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param);\nGLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param);\nGLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor);\nGLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities);\nGLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y);\nGLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z);\nGLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w);\nGLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2);\nGLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2);\nGLAPI void APIENTRY glTexCoord1xOES (GLfixed s);\nGLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t);\nGLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r);\nGLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q);\nGLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);\nGLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);\nGLAPI void APIENTRY glVertex2xOES (GLfixed x);\nGLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y);\nGLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords);\nGLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z);\nGLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords);\n#endif\n#endif /* GL_OES_fixed_point */\n\n#ifndef GL_OES_query_matrix\n#define GL_OES_query_matrix 1\ntypedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent);\n#endif\n#endif /* GL_OES_query_matrix */\n\n#ifndef GL_OES_read_format\n#define GL_OES_read_format 1\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B\n#endif /* GL_OES_read_format */\n\n#ifndef GL_OES_single_precision\n#define GL_OES_single_precision 1\ntypedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);\ntypedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);\ntypedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f);\ntypedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\ntypedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation);\ntypedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glClearDepthfOES (GLclampf depth);\nGLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);\nGLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f);\nGLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\nGLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation);\nGLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\n#endif\n#endif /* GL_OES_single_precision */\n\n#ifndef GL_3DFX_multisample\n#define GL_3DFX_multisample 1\n#define GL_MULTISAMPLE_3DFX               0x86B2\n#define GL_SAMPLE_BUFFERS_3DFX            0x86B3\n#define GL_SAMPLES_3DFX                   0x86B4\n#define GL_MULTISAMPLE_BIT_3DFX           0x20000000\n#endif /* GL_3DFX_multisample */\n\n#ifndef GL_3DFX_tbuffer\n#define GL_3DFX_tbuffer 1\ntypedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTbufferMask3DFX (GLuint mask);\n#endif\n#endif /* GL_3DFX_tbuffer */\n\n#ifndef GL_3DFX_texture_compression_FXT1\n#define GL_3DFX_texture_compression_FXT1 1\n#define GL_COMPRESSED_RGB_FXT1_3DFX       0x86B0\n#define GL_COMPRESSED_RGBA_FXT1_3DFX      0x86B1\n#endif /* GL_3DFX_texture_compression_FXT1 */\n\n#ifndef GL_AMD_blend_minmax_factor\n#define GL_AMD_blend_minmax_factor 1\n#define GL_FACTOR_MIN_AMD                 0x901C\n#define GL_FACTOR_MAX_AMD                 0x901D\n#endif /* GL_AMD_blend_minmax_factor */\n\n#ifndef GL_AMD_conservative_depth\n#define GL_AMD_conservative_depth 1\n#endif /* GL_AMD_conservative_depth */\n\n#ifndef GL_AMD_debug_output\n#define GL_AMD_debug_output 1\ntypedef void (APIENTRY  *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD   0x9143\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD  0x9144\n#define GL_DEBUG_LOGGED_MESSAGES_AMD      0x9145\n#define GL_DEBUG_SEVERITY_HIGH_AMD        0x9146\n#define GL_DEBUG_SEVERITY_MEDIUM_AMD      0x9147\n#define GL_DEBUG_SEVERITY_LOW_AMD         0x9148\n#define GL_DEBUG_CATEGORY_API_ERROR_AMD   0x9149\n#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A\n#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B\n#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C\n#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D\n#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E\n#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F\n#define GL_DEBUG_CATEGORY_OTHER_AMD       0x9150\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);\ntypedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam);\ntypedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);\nGLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf);\nGLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam);\nGLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message);\n#endif\n#endif /* GL_AMD_debug_output */\n\n#ifndef GL_AMD_depth_clamp_separate\n#define GL_AMD_depth_clamp_separate 1\n#define GL_DEPTH_CLAMP_NEAR_AMD           0x901E\n#define GL_DEPTH_CLAMP_FAR_AMD            0x901F\n#endif /* GL_AMD_depth_clamp_separate */\n\n#ifndef GL_AMD_draw_buffers_blend\n#define GL_AMD_draw_buffers_blend 1\ntypedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst);\nGLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\nGLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode);\nGLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\n#endif\n#endif /* GL_AMD_draw_buffers_blend */\n\n#ifndef GL_AMD_gcn_shader\n#define GL_AMD_gcn_shader 1\n#endif /* GL_AMD_gcn_shader */\n\n#ifndef GL_AMD_gpu_shader_int64\n#define GL_AMD_gpu_shader_int64 1\ntypedef int64_t GLint64EXT;\n#define GL_INT64_NV                       0x140E\n#define GL_UNSIGNED_INT64_NV              0x140F\n#define GL_INT8_NV                        0x8FE0\n#define GL_INT8_VEC2_NV                   0x8FE1\n#define GL_INT8_VEC3_NV                   0x8FE2\n#define GL_INT8_VEC4_NV                   0x8FE3\n#define GL_INT16_NV                       0x8FE4\n#define GL_INT16_VEC2_NV                  0x8FE5\n#define GL_INT16_VEC3_NV                  0x8FE6\n#define GL_INT16_VEC4_NV                  0x8FE7\n#define GL_INT64_VEC2_NV                  0x8FE9\n#define GL_INT64_VEC3_NV                  0x8FEA\n#define GL_INT64_VEC4_NV                  0x8FEB\n#define GL_UNSIGNED_INT8_NV               0x8FEC\n#define GL_UNSIGNED_INT8_VEC2_NV          0x8FED\n#define GL_UNSIGNED_INT8_VEC3_NV          0x8FEE\n#define GL_UNSIGNED_INT8_VEC4_NV          0x8FEF\n#define GL_UNSIGNED_INT16_NV              0x8FF0\n#define GL_UNSIGNED_INT16_VEC2_NV         0x8FF1\n#define GL_UNSIGNED_INT16_VEC3_NV         0x8FF2\n#define GL_UNSIGNED_INT16_VEC4_NV         0x8FF3\n#define GL_UNSIGNED_INT64_VEC2_NV         0x8FF5\n#define GL_UNSIGNED_INT64_VEC3_NV         0x8FF6\n#define GL_UNSIGNED_INT64_VEC4_NV         0x8FF7\n#define GL_FLOAT16_NV                     0x8FF8\n#define GL_FLOAT16_VEC2_NV                0x8FF9\n#define GL_FLOAT16_VEC3_NV                0x8FFA\n#define GL_FLOAT16_VEC4_NV                0x8FFB\ntypedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);\ntypedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);\ntypedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);\ntypedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);\ntypedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params);\ntypedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x);\nGLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y);\nGLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\nGLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\nGLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x);\nGLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y);\nGLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\nGLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\nGLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params);\nGLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params);\nGLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x);\nGLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);\nGLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\nGLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\nGLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value);\nGLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x);\nGLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);\nGLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\nGLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\nGLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\n#endif\n#endif /* GL_AMD_gpu_shader_int64 */\n\n#ifndef GL_AMD_interleaved_elements\n#define GL_AMD_interleaved_elements 1\n#define GL_VERTEX_ELEMENT_SWIZZLE_AMD     0x91A4\n#define GL_VERTEX_ID_SWIZZLE_AMD          0x91A5\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param);\n#endif\n#endif /* GL_AMD_interleaved_elements */\n\n#ifndef GL_AMD_multi_draw_indirect\n#define GL_AMD_multi_draw_indirect 1\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride);\nGLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride);\n#endif\n#endif /* GL_AMD_multi_draw_indirect */\n\n#ifndef GL_AMD_name_gen_delete\n#define GL_AMD_name_gen_delete 1\n#define GL_DATA_BUFFER_AMD                0x9151\n#define GL_PERFORMANCE_MONITOR_AMD        0x9152\n#define GL_QUERY_OBJECT_AMD               0x9153\n#define GL_VERTEX_ARRAY_OBJECT_AMD        0x9154\n#define GL_SAMPLER_OBJECT_AMD             0x9155\ntypedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names);\ntypedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names);\ntypedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names);\nGLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names);\nGLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name);\n#endif\n#endif /* GL_AMD_name_gen_delete */\n\n#ifndef GL_AMD_occlusion_query_event\n#define GL_AMD_occlusion_query_event 1\n#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F\n#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001\n#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002\n#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004\n#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008\n#define GL_QUERY_ALL_EVENT_BITS_AMD       0xFFFFFFFF\ntypedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param);\n#endif\n#endif /* GL_AMD_occlusion_query_event */\n\n#ifndef GL_AMD_performance_monitor\n#define GL_AMD_performance_monitor 1\n#define GL_COUNTER_TYPE_AMD               0x8BC0\n#define GL_COUNTER_RANGE_AMD              0x8BC1\n#define GL_UNSIGNED_INT64_AMD             0x8BC2\n#define GL_PERCENTAGE_AMD                 0x8BC3\n#define GL_PERFMON_RESULT_AVAILABLE_AMD   0x8BC4\n#define GL_PERFMON_RESULT_SIZE_AMD        0x8BC5\n#define GL_PERFMON_RESULT_AMD             0x8BC6\ntypedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);\ntypedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);\ntypedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);\ntypedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);\ntypedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data);\ntypedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);\ntypedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);\ntypedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);\ntypedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);\nGLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);\nGLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);\nGLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);\nGLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data);\nGLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);\nGLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);\nGLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);\nGLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor);\nGLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor);\nGLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);\n#endif\n#endif /* GL_AMD_performance_monitor */\n\n#ifndef GL_AMD_pinned_memory\n#define GL_AMD_pinned_memory 1\n#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160\n#endif /* GL_AMD_pinned_memory */\n\n#ifndef GL_AMD_query_buffer_object\n#define GL_AMD_query_buffer_object 1\n#define GL_QUERY_BUFFER_AMD               0x9192\n#define GL_QUERY_BUFFER_BINDING_AMD       0x9193\n#define GL_QUERY_RESULT_NO_WAIT_AMD       0x9194\n#endif /* GL_AMD_query_buffer_object */\n\n#ifndef GL_AMD_sample_positions\n#define GL_AMD_sample_positions 1\n#define GL_SUBSAMPLE_DISTANCE_AMD         0x883F\ntypedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);\n#endif\n#endif /* GL_AMD_sample_positions */\n\n#ifndef GL_AMD_seamless_cubemap_per_texture\n#define GL_AMD_seamless_cubemap_per_texture 1\n#endif /* GL_AMD_seamless_cubemap_per_texture */\n\n#ifndef GL_AMD_shader_atomic_counter_ops\n#define GL_AMD_shader_atomic_counter_ops 1\n#endif /* GL_AMD_shader_atomic_counter_ops */\n\n#ifndef GL_AMD_shader_stencil_export\n#define GL_AMD_shader_stencil_export 1\n#endif /* GL_AMD_shader_stencil_export */\n\n#ifndef GL_AMD_shader_trinary_minmax\n#define GL_AMD_shader_trinary_minmax 1\n#endif /* GL_AMD_shader_trinary_minmax */\n\n#ifndef GL_AMD_sparse_texture\n#define GL_AMD_sparse_texture 1\n#define GL_VIRTUAL_PAGE_SIZE_X_AMD        0x9195\n#define GL_VIRTUAL_PAGE_SIZE_Y_AMD        0x9196\n#define GL_VIRTUAL_PAGE_SIZE_Z_AMD        0x9197\n#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD    0x9198\n#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199\n#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A\n#define GL_MIN_SPARSE_LEVEL_AMD           0x919B\n#define GL_MIN_LOD_WARNING_AMD            0x919C\n#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001\ntypedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\nGLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\n#endif\n#endif /* GL_AMD_sparse_texture */\n\n#ifndef GL_AMD_stencil_operation_extended\n#define GL_AMD_stencil_operation_extended 1\n#define GL_SET_AMD                        0x874A\n#define GL_REPLACE_VALUE_AMD              0x874B\n#define GL_STENCIL_OP_VALUE_AMD           0x874C\n#define GL_STENCIL_BACK_OP_VALUE_AMD      0x874D\ntypedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value);\n#endif\n#endif /* GL_AMD_stencil_operation_extended */\n\n#ifndef GL_AMD_texture_texture4\n#define GL_AMD_texture_texture4 1\n#endif /* GL_AMD_texture_texture4 */\n\n#ifndef GL_AMD_transform_feedback3_lines_triangles\n#define GL_AMD_transform_feedback3_lines_triangles 1\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\n\n#ifndef GL_AMD_transform_feedback4\n#define GL_AMD_transform_feedback4 1\n#define GL_STREAM_RASTERIZATION_AMD       0x91A0\n#endif /* GL_AMD_transform_feedback4 */\n\n#ifndef GL_AMD_vertex_shader_layer\n#define GL_AMD_vertex_shader_layer 1\n#endif /* GL_AMD_vertex_shader_layer */\n\n#ifndef GL_AMD_vertex_shader_tessellator\n#define GL_AMD_vertex_shader_tessellator 1\n#define GL_SAMPLER_BUFFER_AMD             0x9001\n#define GL_INT_SAMPLER_BUFFER_AMD         0x9002\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003\n#define GL_TESSELLATION_MODE_AMD          0x9004\n#define GL_TESSELLATION_FACTOR_AMD        0x9005\n#define GL_DISCRETE_AMD                   0x9006\n#define GL_CONTINUOUS_AMD                 0x9007\ntypedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);\ntypedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor);\nGLAPI void APIENTRY glTessellationModeAMD (GLenum mode);\n#endif\n#endif /* GL_AMD_vertex_shader_tessellator */\n\n#ifndef GL_AMD_vertex_shader_viewport_index\n#define GL_AMD_vertex_shader_viewport_index 1\n#endif /* GL_AMD_vertex_shader_viewport_index */\n\n#ifndef GL_APPLE_aux_depth_stencil\n#define GL_APPLE_aux_depth_stencil 1\n#define GL_AUX_DEPTH_STENCIL_APPLE        0x8A14\n#endif /* GL_APPLE_aux_depth_stencil */\n\n#ifndef GL_APPLE_client_storage\n#define GL_APPLE_client_storage 1\n#define GL_UNPACK_CLIENT_STORAGE_APPLE    0x85B2\n#endif /* GL_APPLE_client_storage */\n\n#ifndef GL_APPLE_element_array\n#define GL_APPLE_element_array 1\n#define GL_ELEMENT_ARRAY_APPLE            0x8A0C\n#define GL_ELEMENT_ARRAY_TYPE_APPLE       0x8A0D\n#define GL_ELEMENT_ARRAY_POINTER_APPLE    0x8A0E\ntypedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);\ntypedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer);\nGLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count);\nGLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);\nGLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);\nGLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);\n#endif\n#endif /* GL_APPLE_element_array */\n\n#ifndef GL_APPLE_fence\n#define GL_APPLE_fence 1\n#define GL_DRAW_PIXELS_APPLE              0x8A0A\n#define GL_FENCE_APPLE                    0x8A0B\ntypedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);\ntypedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);\ntypedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);\ntypedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);\ntypedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);\ntypedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);\ntypedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);\ntypedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences);\nGLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences);\nGLAPI void APIENTRY glSetFenceAPPLE (GLuint fence);\nGLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence);\nGLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence);\nGLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence);\nGLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name);\nGLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name);\n#endif\n#endif /* GL_APPLE_fence */\n\n#ifndef GL_APPLE_float_pixels\n#define GL_APPLE_float_pixels 1\n#define GL_HALF_APPLE                     0x140B\n#define GL_RGBA_FLOAT32_APPLE             0x8814\n#define GL_RGB_FLOAT32_APPLE              0x8815\n#define GL_ALPHA_FLOAT32_APPLE            0x8816\n#define GL_INTENSITY_FLOAT32_APPLE        0x8817\n#define GL_LUMINANCE_FLOAT32_APPLE        0x8818\n#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE  0x8819\n#define GL_RGBA_FLOAT16_APPLE             0x881A\n#define GL_RGB_FLOAT16_APPLE              0x881B\n#define GL_ALPHA_FLOAT16_APPLE            0x881C\n#define GL_INTENSITY_FLOAT16_APPLE        0x881D\n#define GL_LUMINANCE_FLOAT16_APPLE        0x881E\n#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE  0x881F\n#define GL_COLOR_FLOAT_APPLE              0x8A0F\n#endif /* GL_APPLE_float_pixels */\n\n#ifndef GL_APPLE_flush_buffer_range\n#define GL_APPLE_flush_buffer_range 1\n#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12\n#define GL_BUFFER_FLUSHING_UNMAP_APPLE    0x8A13\ntypedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size);\n#endif\n#endif /* GL_APPLE_flush_buffer_range */\n\n#ifndef GL_APPLE_object_purgeable\n#define GL_APPLE_object_purgeable 1\n#define GL_BUFFER_OBJECT_APPLE            0x85B3\n#define GL_RELEASED_APPLE                 0x8A19\n#define GL_VOLATILE_APPLE                 0x8A1A\n#define GL_RETAINED_APPLE                 0x8A1B\n#define GL_UNDEFINED_APPLE                0x8A1C\n#define GL_PURGEABLE_APPLE                0x8A1D\ntypedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\ntypedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\ntypedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);\nGLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option);\nGLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params);\n#endif\n#endif /* GL_APPLE_object_purgeable */\n\n#ifndef GL_APPLE_rgb_422\n#define GL_APPLE_rgb_422 1\n#define GL_RGB_422_APPLE                  0x8A1F\n#define GL_UNSIGNED_SHORT_8_8_APPLE       0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_APPLE   0x85BB\n#define GL_RGB_RAW_422_APPLE              0x8A51\n#endif /* GL_APPLE_rgb_422 */\n\n#ifndef GL_APPLE_row_bytes\n#define GL_APPLE_row_bytes 1\n#define GL_PACK_ROW_BYTES_APPLE           0x8A15\n#define GL_UNPACK_ROW_BYTES_APPLE         0x8A16\n#endif /* GL_APPLE_row_bytes */\n\n#ifndef GL_APPLE_specular_vector\n#define GL_APPLE_specular_vector 1\n#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0\n#endif /* GL_APPLE_specular_vector */\n\n#ifndef GL_APPLE_texture_range\n#define GL_APPLE_texture_range 1\n#define GL_TEXTURE_RANGE_LENGTH_APPLE     0x85B7\n#define GL_TEXTURE_RANGE_POINTER_APPLE    0x85B8\n#define GL_TEXTURE_STORAGE_HINT_APPLE     0x85BC\n#define GL_STORAGE_PRIVATE_APPLE          0x85BD\n#define GL_STORAGE_CACHED_APPLE           0x85BE\n#define GL_STORAGE_SHARED_APPLE           0x85BF\ntypedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer);\nGLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params);\n#endif\n#endif /* GL_APPLE_texture_range */\n\n#ifndef GL_APPLE_transform_hint\n#define GL_APPLE_transform_hint 1\n#define GL_TRANSFORM_HINT_APPLE           0x85B1\n#endif /* GL_APPLE_transform_hint */\n\n#ifndef GL_APPLE_vertex_array_object\n#define GL_APPLE_vertex_array_object 1\n#define GL_VERTEX_ARRAY_BINDING_APPLE     0x85B5\ntypedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);\ntypedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);\ntypedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);\ntypedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array);\nGLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays);\nGLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays);\nGLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array);\n#endif\n#endif /* GL_APPLE_vertex_array_object */\n\n#ifndef GL_APPLE_vertex_array_range\n#define GL_APPLE_vertex_array_range 1\n#define GL_VERTEX_ARRAY_RANGE_APPLE       0x851D\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E\n#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F\n#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521\n#define GL_STORAGE_CLIENT_APPLE           0x85B4\ntypedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer);\ntypedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer);\nGLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer);\nGLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param);\n#endif\n#endif /* GL_APPLE_vertex_array_range */\n\n#ifndef GL_APPLE_vertex_program_evaluators\n#define GL_APPLE_vertex_program_evaluators 1\n#define GL_VERTEX_ATTRIB_MAP1_APPLE       0x8A00\n#define GL_VERTEX_ATTRIB_MAP2_APPLE       0x8A01\n#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE  0x8A02\n#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03\n#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04\n#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05\n#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE  0x8A06\n#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07\n#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08\n#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09\ntypedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\ntypedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);\ntypedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\ntypedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\ntypedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\ntypedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname);\nGLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname);\nGLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname);\nGLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\nGLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\nGLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\nGLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\n#endif\n#endif /* GL_APPLE_vertex_program_evaluators */\n\n#ifndef GL_APPLE_ycbcr_422\n#define GL_APPLE_ycbcr_422 1\n#define GL_YCBCR_422_APPLE                0x85B9\n#endif /* GL_APPLE_ycbcr_422 */\n\n#ifndef GL_ATI_draw_buffers\n#define GL_ATI_draw_buffers 1\n#define GL_MAX_DRAW_BUFFERS_ATI           0x8824\n#define GL_DRAW_BUFFER0_ATI               0x8825\n#define GL_DRAW_BUFFER1_ATI               0x8826\n#define GL_DRAW_BUFFER2_ATI               0x8827\n#define GL_DRAW_BUFFER3_ATI               0x8828\n#define GL_DRAW_BUFFER4_ATI               0x8829\n#define GL_DRAW_BUFFER5_ATI               0x882A\n#define GL_DRAW_BUFFER6_ATI               0x882B\n#define GL_DRAW_BUFFER7_ATI               0x882C\n#define GL_DRAW_BUFFER8_ATI               0x882D\n#define GL_DRAW_BUFFER9_ATI               0x882E\n#define GL_DRAW_BUFFER10_ATI              0x882F\n#define GL_DRAW_BUFFER11_ATI              0x8830\n#define GL_DRAW_BUFFER12_ATI              0x8831\n#define GL_DRAW_BUFFER13_ATI              0x8832\n#define GL_DRAW_BUFFER14_ATI              0x8833\n#define GL_DRAW_BUFFER15_ATI              0x8834\ntypedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs);\n#endif\n#endif /* GL_ATI_draw_buffers */\n\n#ifndef GL_ATI_element_array\n#define GL_ATI_element_array 1\n#define GL_ELEMENT_ARRAY_ATI              0x8768\n#define GL_ELEMENT_ARRAY_TYPE_ATI         0x8769\n#define GL_ELEMENT_ARRAY_POINTER_ATI      0x876A\ntypedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer);\nGLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count);\nGLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count);\n#endif\n#endif /* GL_ATI_element_array */\n\n#ifndef GL_ATI_envmap_bumpmap\n#define GL_ATI_envmap_bumpmap 1\n#define GL_BUMP_ROT_MATRIX_ATI            0x8775\n#define GL_BUMP_ROT_MATRIX_SIZE_ATI       0x8776\n#define GL_BUMP_NUM_TEX_UNITS_ATI         0x8777\n#define GL_BUMP_TEX_UNITS_ATI             0x8778\n#define GL_DUDV_ATI                       0x8779\n#define GL_DU8DV8_ATI                     0x877A\n#define GL_BUMP_ENVMAP_ATI                0x877B\n#define GL_BUMP_TARGET_ATI                0x877C\ntypedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);\ntypedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);\ntypedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param);\nGLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param);\nGLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param);\n#endif\n#endif /* GL_ATI_envmap_bumpmap */\n\n#ifndef GL_ATI_fragment_shader\n#define GL_ATI_fragment_shader 1\n#define GL_FRAGMENT_SHADER_ATI            0x8920\n#define GL_REG_0_ATI                      0x8921\n#define GL_REG_1_ATI                      0x8922\n#define GL_REG_2_ATI                      0x8923\n#define GL_REG_3_ATI                      0x8924\n#define GL_REG_4_ATI                      0x8925\n#define GL_REG_5_ATI                      0x8926\n#define GL_REG_6_ATI                      0x8927\n#define GL_REG_7_ATI                      0x8928\n#define GL_REG_8_ATI                      0x8929\n#define GL_REG_9_ATI                      0x892A\n#define GL_REG_10_ATI                     0x892B\n#define GL_REG_11_ATI                     0x892C\n#define GL_REG_12_ATI                     0x892D\n#define GL_REG_13_ATI                     0x892E\n#define GL_REG_14_ATI                     0x892F\n#define GL_REG_15_ATI                     0x8930\n#define GL_REG_16_ATI                     0x8931\n#define GL_REG_17_ATI                     0x8932\n#define GL_REG_18_ATI                     0x8933\n#define GL_REG_19_ATI                     0x8934\n#define GL_REG_20_ATI                     0x8935\n#define GL_REG_21_ATI                     0x8936\n#define GL_REG_22_ATI                     0x8937\n#define GL_REG_23_ATI                     0x8938\n#define GL_REG_24_ATI                     0x8939\n#define GL_REG_25_ATI                     0x893A\n#define GL_REG_26_ATI                     0x893B\n#define GL_REG_27_ATI                     0x893C\n#define GL_REG_28_ATI                     0x893D\n#define GL_REG_29_ATI                     0x893E\n#define GL_REG_30_ATI                     0x893F\n#define GL_REG_31_ATI                     0x8940\n#define GL_CON_0_ATI                      0x8941\n#define GL_CON_1_ATI                      0x8942\n#define GL_CON_2_ATI                      0x8943\n#define GL_CON_3_ATI                      0x8944\n#define GL_CON_4_ATI                      0x8945\n#define GL_CON_5_ATI                      0x8946\n#define GL_CON_6_ATI                      0x8947\n#define GL_CON_7_ATI                      0x8948\n#define GL_CON_8_ATI                      0x8949\n#define GL_CON_9_ATI                      0x894A\n#define GL_CON_10_ATI                     0x894B\n#define GL_CON_11_ATI                     0x894C\n#define GL_CON_12_ATI                     0x894D\n#define GL_CON_13_ATI                     0x894E\n#define GL_CON_14_ATI                     0x894F\n#define GL_CON_15_ATI                     0x8950\n#define GL_CON_16_ATI                     0x8951\n#define GL_CON_17_ATI                     0x8952\n#define GL_CON_18_ATI                     0x8953\n#define GL_CON_19_ATI                     0x8954\n#define GL_CON_20_ATI                     0x8955\n#define GL_CON_21_ATI                     0x8956\n#define GL_CON_22_ATI                     0x8957\n#define GL_CON_23_ATI                     0x8958\n#define GL_CON_24_ATI                     0x8959\n#define GL_CON_25_ATI                     0x895A\n#define GL_CON_26_ATI                     0x895B\n#define GL_CON_27_ATI                     0x895C\n#define GL_CON_28_ATI                     0x895D\n#define GL_CON_29_ATI                     0x895E\n#define GL_CON_30_ATI                     0x895F\n#define GL_CON_31_ATI                     0x8960\n#define GL_MOV_ATI                        0x8961\n#define GL_ADD_ATI                        0x8963\n#define GL_MUL_ATI                        0x8964\n#define GL_SUB_ATI                        0x8965\n#define GL_DOT3_ATI                       0x8966\n#define GL_DOT4_ATI                       0x8967\n#define GL_MAD_ATI                        0x8968\n#define GL_LERP_ATI                       0x8969\n#define GL_CND_ATI                        0x896A\n#define GL_CND0_ATI                       0x896B\n#define GL_DOT2_ADD_ATI                   0x896C\n#define GL_SECONDARY_INTERPOLATOR_ATI     0x896D\n#define GL_NUM_FRAGMENT_REGISTERS_ATI     0x896E\n#define GL_NUM_FRAGMENT_CONSTANTS_ATI     0x896F\n#define GL_NUM_PASSES_ATI                 0x8970\n#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI  0x8971\n#define GL_NUM_INSTRUCTIONS_TOTAL_ATI     0x8972\n#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973\n#define GL_NUM_LOOPBACK_COMPONENTS_ATI    0x8974\n#define GL_COLOR_ALPHA_PAIRING_ATI        0x8975\n#define GL_SWIZZLE_STR_ATI                0x8976\n#define GL_SWIZZLE_STQ_ATI                0x8977\n#define GL_SWIZZLE_STR_DR_ATI             0x8978\n#define GL_SWIZZLE_STQ_DQ_ATI             0x8979\n#define GL_SWIZZLE_STRQ_ATI               0x897A\n#define GL_SWIZZLE_STRQ_DQ_ATI            0x897B\n#define GL_RED_BIT_ATI                    0x00000001\n#define GL_GREEN_BIT_ATI                  0x00000002\n#define GL_BLUE_BIT_ATI                   0x00000004\n#define GL_2X_BIT_ATI                     0x00000001\n#define GL_4X_BIT_ATI                     0x00000002\n#define GL_8X_BIT_ATI                     0x00000004\n#define GL_HALF_BIT_ATI                   0x00000008\n#define GL_QUARTER_BIT_ATI                0x00000010\n#define GL_EIGHTH_BIT_ATI                 0x00000020\n#define GL_SATURATE_BIT_ATI               0x00000040\n#define GL_COMP_BIT_ATI                   0x00000002\n#define GL_NEGATE_BIT_ATI                 0x00000004\n#define GL_BIAS_BIT_ATI                   0x00000008\ntypedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);\ntypedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);\ntypedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);\ntypedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);\ntypedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);\ntypedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\ntypedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\ntypedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\ntypedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\ntypedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\ntypedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\ntypedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range);\nGLAPI void APIENTRY glBindFragmentShaderATI (GLuint id);\nGLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id);\nGLAPI void APIENTRY glBeginFragmentShaderATI (void);\nGLAPI void APIENTRY glEndFragmentShaderATI (void);\nGLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle);\nGLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle);\nGLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\nGLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\nGLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\nGLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\nGLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\nGLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\nGLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value);\n#endif\n#endif /* GL_ATI_fragment_shader */\n\n#ifndef GL_ATI_map_object_buffer\n#define GL_ATI_map_object_buffer 1\ntypedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer);\nGLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer);\n#endif\n#endif /* GL_ATI_map_object_buffer */\n\n#ifndef GL_ATI_meminfo\n#define GL_ATI_meminfo 1\n#define GL_VBO_FREE_MEMORY_ATI            0x87FB\n#define GL_TEXTURE_FREE_MEMORY_ATI        0x87FC\n#define GL_RENDERBUFFER_FREE_MEMORY_ATI   0x87FD\n#endif /* GL_ATI_meminfo */\n\n#ifndef GL_ATI_pixel_format_float\n#define GL_ATI_pixel_format_float 1\n#define GL_RGBA_FLOAT_MODE_ATI            0x8820\n#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835\n#endif /* GL_ATI_pixel_format_float */\n\n#ifndef GL_ATI_pn_triangles\n#define GL_ATI_pn_triangles 1\n#define GL_PN_TRIANGLES_ATI               0x87F0\n#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1\n#define GL_PN_TRIANGLES_POINT_MODE_ATI    0x87F2\n#define GL_PN_TRIANGLES_NORMAL_MODE_ATI   0x87F3\n#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4\n#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5\n#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6\n#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7\n#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8\ntypedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param);\nGLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param);\n#endif\n#endif /* GL_ATI_pn_triangles */\n\n#ifndef GL_ATI_separate_stencil\n#define GL_ATI_separate_stencil 1\n#define GL_STENCIL_BACK_FUNC_ATI          0x8800\n#define GL_STENCIL_BACK_FAIL_ATI          0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803\ntypedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\ntypedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\nGLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\n#endif\n#endif /* GL_ATI_separate_stencil */\n\n#ifndef GL_ATI_text_fragment_shader\n#define GL_ATI_text_fragment_shader 1\n#define GL_TEXT_FRAGMENT_SHADER_ATI       0x8200\n#endif /* GL_ATI_text_fragment_shader */\n\n#ifndef GL_ATI_texture_env_combine3\n#define GL_ATI_texture_env_combine3 1\n#define GL_MODULATE_ADD_ATI               0x8744\n#define GL_MODULATE_SIGNED_ADD_ATI        0x8745\n#define GL_MODULATE_SUBTRACT_ATI          0x8746\n#endif /* GL_ATI_texture_env_combine3 */\n\n#ifndef GL_ATI_texture_float\n#define GL_ATI_texture_float 1\n#define GL_RGBA_FLOAT32_ATI               0x8814\n#define GL_RGB_FLOAT32_ATI                0x8815\n#define GL_ALPHA_FLOAT32_ATI              0x8816\n#define GL_INTENSITY_FLOAT32_ATI          0x8817\n#define GL_LUMINANCE_FLOAT32_ATI          0x8818\n#define GL_LUMINANCE_ALPHA_FLOAT32_ATI    0x8819\n#define GL_RGBA_FLOAT16_ATI               0x881A\n#define GL_RGB_FLOAT16_ATI                0x881B\n#define GL_ALPHA_FLOAT16_ATI              0x881C\n#define GL_INTENSITY_FLOAT16_ATI          0x881D\n#define GL_LUMINANCE_FLOAT16_ATI          0x881E\n#define GL_LUMINANCE_ALPHA_FLOAT16_ATI    0x881F\n#endif /* GL_ATI_texture_float */\n\n#ifndef GL_ATI_texture_mirror_once\n#define GL_ATI_texture_mirror_once 1\n#define GL_MIRROR_CLAMP_ATI               0x8742\n#define GL_MIRROR_CLAMP_TO_EDGE_ATI       0x8743\n#endif /* GL_ATI_texture_mirror_once */\n\n#ifndef GL_ATI_vertex_array_object\n#define GL_ATI_vertex_array_object 1\n#define GL_STATIC_ATI                     0x8760\n#define GL_DYNAMIC_ATI                    0x8761\n#define GL_PRESERVE_ATI                   0x8762\n#define GL_DISCARD_ATI                    0x8763\n#define GL_OBJECT_BUFFER_SIZE_ATI         0x8764\n#define GL_OBJECT_BUFFER_USAGE_ATI        0x8765\n#define GL_ARRAY_OBJECT_BUFFER_ATI        0x8766\n#define GL_ARRAY_OBJECT_OFFSET_ATI        0x8767\ntypedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage);\ntypedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve);\ntypedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\ntypedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\ntypedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage);\nGLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer);\nGLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve);\nGLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer);\nGLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\nGLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params);\nGLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\nGLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params);\n#endif\n#endif /* GL_ATI_vertex_array_object */\n\n#ifndef GL_ATI_vertex_attrib_array_object\n#define GL_ATI_vertex_attrib_array_object 1\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);\nGLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params);\n#endif\n#endif /* GL_ATI_vertex_attrib_array_object */\n\n#ifndef GL_ATI_vertex_streams\n#define GL_ATI_vertex_streams 1\n#define GL_MAX_VERTEX_STREAMS_ATI         0x876B\n#define GL_VERTEX_STREAM0_ATI             0x876C\n#define GL_VERTEX_STREAM1_ATI             0x876D\n#define GL_VERTEX_STREAM2_ATI             0x876E\n#define GL_VERTEX_STREAM3_ATI             0x876F\n#define GL_VERTEX_STREAM4_ATI             0x8770\n#define GL_VERTEX_STREAM5_ATI             0x8771\n#define GL_VERTEX_STREAM6_ATI             0x8772\n#define GL_VERTEX_STREAM7_ATI             0x8773\n#define GL_VERTEX_SOURCE_ATI              0x8774\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);\ntypedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\ntypedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);\ntypedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x);\nGLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords);\nGLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x);\nGLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords);\nGLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x);\nGLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords);\nGLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x);\nGLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords);\nGLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y);\nGLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords);\nGLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y);\nGLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords);\nGLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y);\nGLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords);\nGLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords);\nGLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords);\nGLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords);\nGLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords);\nGLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords);\nGLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords);\nGLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords);\nGLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords);\nGLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords);\nGLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);\nGLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords);\nGLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz);\nGLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords);\nGLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz);\nGLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords);\nGLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);\nGLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords);\nGLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);\nGLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords);\nGLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream);\nGLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param);\nGLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param);\n#endif\n#endif /* GL_ATI_vertex_streams */\n\n#ifndef GL_EXT_422_pixels\n#define GL_EXT_422_pixels 1\n#define GL_422_EXT                        0x80CC\n#define GL_422_REV_EXT                    0x80CD\n#define GL_422_AVERAGE_EXT                0x80CE\n#define GL_422_REV_AVERAGE_EXT            0x80CF\n#endif /* GL_EXT_422_pixels */\n\n#ifndef GL_EXT_abgr\n#define GL_EXT_abgr 1\n#define GL_ABGR_EXT                       0x8000\n#endif /* GL_EXT_abgr */\n\n#ifndef GL_EXT_bgra\n#define GL_EXT_bgra 1\n#define GL_BGR_EXT                        0x80E0\n#define GL_BGRA_EXT                       0x80E1\n#endif /* GL_EXT_bgra */\n\n#ifndef GL_EXT_bindable_uniform\n#define GL_EXT_bindable_uniform 1\n#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2\n#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3\n#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4\n#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT  0x8DED\n#define GL_UNIFORM_BUFFER_EXT             0x8DEE\n#define GL_UNIFORM_BUFFER_BINDING_EXT     0x8DEF\ntypedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);\ntypedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);\ntypedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer);\nGLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location);\nGLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location);\n#endif\n#endif /* GL_EXT_bindable_uniform */\n\n#ifndef GL_EXT_blend_color\n#define GL_EXT_blend_color 1\n#define GL_CONSTANT_COLOR_EXT             0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR_EXT   0x8002\n#define GL_CONSTANT_ALPHA_EXT             0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT   0x8004\n#define GL_BLEND_COLOR_EXT                0x8005\ntypedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\n#endif\n#endif /* GL_EXT_blend_color */\n\n#ifndef GL_EXT_blend_equation_separate\n#define GL_EXT_blend_equation_separate 1\n#define GL_BLEND_EQUATION_RGB_EXT         0x8009\n#define GL_BLEND_EQUATION_ALPHA_EXT       0x883D\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha);\n#endif\n#endif /* GL_EXT_blend_equation_separate */\n\n#ifndef GL_EXT_blend_func_separate\n#define GL_EXT_blend_func_separate 1\n#define GL_BLEND_DST_RGB_EXT              0x80C8\n#define GL_BLEND_SRC_RGB_EXT              0x80C9\n#define GL_BLEND_DST_ALPHA_EXT            0x80CA\n#define GL_BLEND_SRC_ALPHA_EXT            0x80CB\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n#endif\n#endif /* GL_EXT_blend_func_separate */\n\n#ifndef GL_EXT_blend_logic_op\n#define GL_EXT_blend_logic_op 1\n#endif /* GL_EXT_blend_logic_op */\n\n#ifndef GL_EXT_blend_minmax\n#define GL_EXT_blend_minmax 1\n#define GL_MIN_EXT                        0x8007\n#define GL_MAX_EXT                        0x8008\n#define GL_FUNC_ADD_EXT                   0x8006\n#define GL_BLEND_EQUATION_EXT             0x8009\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendEquationEXT (GLenum mode);\n#endif\n#endif /* GL_EXT_blend_minmax */\n\n#ifndef GL_EXT_blend_subtract\n#define GL_EXT_blend_subtract 1\n#define GL_FUNC_SUBTRACT_EXT              0x800A\n#define GL_FUNC_REVERSE_SUBTRACT_EXT      0x800B\n#endif /* GL_EXT_blend_subtract */\n\n#ifndef GL_EXT_clip_volume_hint\n#define GL_EXT_clip_volume_hint 1\n#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT  0x80F0\n#endif /* GL_EXT_clip_volume_hint */\n\n#ifndef GL_EXT_cmyka\n#define GL_EXT_cmyka 1\n#define GL_CMYK_EXT                       0x800C\n#define GL_CMYKA_EXT                      0x800D\n#define GL_PACK_CMYK_HINT_EXT             0x800E\n#define GL_UNPACK_CMYK_HINT_EXT           0x800F\n#endif /* GL_EXT_cmyka */\n\n#ifndef GL_EXT_color_subtable\n#define GL_EXT_color_subtable 1\ntypedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\n#endif\n#endif /* GL_EXT_color_subtable */\n\n#ifndef GL_EXT_compiled_vertex_array\n#define GL_EXT_compiled_vertex_array 1\n#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT   0x81A8\n#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT   0x81A9\ntypedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);\ntypedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count);\nGLAPI void APIENTRY glUnlockArraysEXT (void);\n#endif\n#endif /* GL_EXT_compiled_vertex_array */\n\n#ifndef GL_EXT_convolution\n#define GL_EXT_convolution 1\n#define GL_CONVOLUTION_1D_EXT             0x8010\n#define GL_CONVOLUTION_2D_EXT             0x8011\n#define GL_SEPARABLE_2D_EXT               0x8012\n#define GL_CONVOLUTION_BORDER_MODE_EXT    0x8013\n#define GL_CONVOLUTION_FILTER_SCALE_EXT   0x8014\n#define GL_CONVOLUTION_FILTER_BIAS_EXT    0x8015\n#define GL_REDUCE_EXT                     0x8016\n#define GL_CONVOLUTION_FORMAT_EXT         0x8017\n#define GL_CONVOLUTION_WIDTH_EXT          0x8018\n#define GL_CONVOLUTION_HEIGHT_EXT         0x8019\n#define GL_MAX_CONVOLUTION_WIDTH_EXT      0x801A\n#define GL_MAX_CONVOLUTION_HEIGHT_EXT     0x801B\n#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C\n#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D\n#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E\n#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F\n#define GL_POST_CONVOLUTION_RED_BIAS_EXT  0x8020\n#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021\n#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022\n#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023\ntypedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);\ntypedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\ntypedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\nGLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\nGLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params);\nGLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params);\nGLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image);\nGLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\nGLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\n#endif\n#endif /* GL_EXT_convolution */\n\n#ifndef GL_EXT_coordinate_frame\n#define GL_EXT_coordinate_frame 1\n#define GL_TANGENT_ARRAY_EXT              0x8439\n#define GL_BINORMAL_ARRAY_EXT             0x843A\n#define GL_CURRENT_TANGENT_EXT            0x843B\n#define GL_CURRENT_BINORMAL_EXT           0x843C\n#define GL_TANGENT_ARRAY_TYPE_EXT         0x843E\n#define GL_TANGENT_ARRAY_STRIDE_EXT       0x843F\n#define GL_BINORMAL_ARRAY_TYPE_EXT        0x8440\n#define GL_BINORMAL_ARRAY_STRIDE_EXT      0x8441\n#define GL_TANGENT_ARRAY_POINTER_EXT      0x8442\n#define GL_BINORMAL_ARRAY_POINTER_EXT     0x8443\n#define GL_MAP1_TANGENT_EXT               0x8444\n#define GL_MAP2_TANGENT_EXT               0x8445\n#define GL_MAP1_BINORMAL_EXT              0x8446\n#define GL_MAP2_BINORMAL_EXT              0x8447\ntypedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);\ntypedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);\ntypedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);\ntypedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);\ntypedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);\ntypedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);\ntypedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);\ntypedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);\ntypedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);\ntypedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);\ntypedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);\ntypedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);\ntypedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz);\nGLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v);\nGLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz);\nGLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v);\nGLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz);\nGLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v);\nGLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz);\nGLAPI void APIENTRY glTangent3ivEXT (const GLint *v);\nGLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz);\nGLAPI void APIENTRY glTangent3svEXT (const GLshort *v);\nGLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz);\nGLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v);\nGLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz);\nGLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v);\nGLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz);\nGLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v);\nGLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz);\nGLAPI void APIENTRY glBinormal3ivEXT (const GLint *v);\nGLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz);\nGLAPI void APIENTRY glBinormal3svEXT (const GLshort *v);\nGLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_EXT_coordinate_frame */\n\n#ifndef GL_EXT_copy_texture\n#define GL_EXT_copy_texture 1\ntypedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\nGLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nGLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\n#endif\n#endif /* GL_EXT_copy_texture */\n\n#ifndef GL_EXT_cull_vertex\n#define GL_EXT_cull_vertex 1\n#define GL_CULL_VERTEX_EXT                0x81AA\n#define GL_CULL_VERTEX_EYE_POSITION_EXT   0x81AB\n#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC\ntypedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_EXT_cull_vertex */\n\n#ifndef GL_EXT_debug_label\n#define GL_EXT_debug_label 1\n#define GL_PROGRAM_PIPELINE_OBJECT_EXT    0x8A4F\n#define GL_PROGRAM_OBJECT_EXT             0x8B40\n#define GL_SHADER_OBJECT_EXT              0x8B48\n#define GL_BUFFER_OBJECT_EXT              0x9151\n#define GL_QUERY_OBJECT_EXT               0x9153\n#define GL_VERTEX_ARRAY_OBJECT_EXT        0x9154\ntypedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);\ntypedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label);\nGLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);\n#endif\n#endif /* GL_EXT_debug_label */\n\n#ifndef GL_EXT_debug_marker\n#define GL_EXT_debug_marker 1\ntypedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);\ntypedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);\ntypedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);\nGLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);\nGLAPI void APIENTRY glPopGroupMarkerEXT (void);\n#endif\n#endif /* GL_EXT_debug_marker */\n\n#ifndef GL_EXT_depth_bounds_test\n#define GL_EXT_depth_bounds_test 1\n#define GL_DEPTH_BOUNDS_TEST_EXT          0x8890\n#define GL_DEPTH_BOUNDS_EXT               0x8891\ntypedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax);\n#endif\n#endif /* GL_EXT_depth_bounds_test */\n\n#ifndef GL_EXT_direct_state_access\n#define GL_EXT_direct_state_access 1\n#define GL_PROGRAM_MATRIX_EXT             0x8E2D\n#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT   0x8E2E\n#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F\ntypedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m);\ntypedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);\ntypedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\ntypedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\ntypedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode);\ntypedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode);\ntypedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\ntypedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);\ntypedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);\ntypedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\ntypedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\ntypedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\ntypedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data);\ntypedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data);\ntypedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data);\ntypedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\ntypedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);\ntypedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data);\ntypedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits);\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img);\ntypedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);\ntypedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);\ntypedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);\ntypedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params);\ntypedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\ntypedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string);\ntypedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);\ntypedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\ntypedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);\ntypedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\ntypedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param);\ntypedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param);\ntypedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\ntypedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\ntypedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\ntypedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\ntypedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\ntypedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m);\nGLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m);\nGLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode);\nGLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\nGLAPI void APIENTRY glMatrixPopEXT (GLenum mode);\nGLAPI void APIENTRY glMatrixPushEXT (GLenum mode);\nGLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask);\nGLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask);\nGLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\nGLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nGLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\nGLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);\nGLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture);\nGLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);\nGLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);\nGLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param);\nGLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params);\nGLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\nGLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nGLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\nGLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);\nGLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index);\nGLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index);\nGLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data);\nGLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data);\nGLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data);\nGLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index);\nGLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index);\nGLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index);\nGLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data);\nGLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data);\nGLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img);\nGLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits);\nGLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img);\nGLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m);\nGLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m);\nGLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);\nGLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);\nGLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access);\nGLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer);\nGLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params);\nGLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);\nGLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);\nGLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);\nGLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\nGLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\nGLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);\nGLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);\nGLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\nGLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\nGLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);\nGLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\nGLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);\nGLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);\nGLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params);\nGLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);\nGLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);\nGLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);\nGLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\nGLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nGLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);\nGLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params);\nGLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);\nGLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nGLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params);\nGLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);\nGLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params);\nGLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params);\nGLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index);\nGLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index);\nGLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params);\nGLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params);\nGLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params);\nGLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string);\nGLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params);\nGLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params);\nGLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params);\nGLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params);\nGLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string);\nGLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target);\nGLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\nGLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nGLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target);\nGLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target);\nGLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode);\nGLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs);\nGLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode);\nGLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\nGLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\nGLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\nGLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);\nGLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer);\nGLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer);\nGLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array);\nGLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array);\nGLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index);\nGLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index);\nGLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param);\nGLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param);\nGLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param);\nGLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\nGLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length);\nGLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);\nGLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\nGLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param);\nGLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params);\nGLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x);\nGLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);\nGLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\nGLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\nGLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\nGLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\nGLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\nGLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\nGLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\nGLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor);\nGLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\nGLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident);\nGLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor);\n#endif\n#endif /* GL_EXT_direct_state_access */\n\n#ifndef GL_EXT_draw_buffers2\n#define GL_EXT_draw_buffers2 1\ntypedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\n#endif\n#endif /* GL_EXT_draw_buffers2 */\n\n#ifndef GL_EXT_draw_instanced\n#define GL_EXT_draw_instanced 1\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);\nGLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\n#endif\n#endif /* GL_EXT_draw_instanced */\n\n#ifndef GL_EXT_draw_range_elements\n#define GL_EXT_draw_range_elements 1\n#define GL_MAX_ELEMENTS_VERTICES_EXT      0x80E8\n#define GL_MAX_ELEMENTS_INDICES_EXT       0x80E9\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\n#endif\n#endif /* GL_EXT_draw_range_elements */\n\n#ifndef GL_EXT_fog_coord\n#define GL_EXT_fog_coord 1\n#define GL_FOG_COORDINATE_SOURCE_EXT      0x8450\n#define GL_FOG_COORDINATE_EXT             0x8451\n#define GL_FRAGMENT_DEPTH_EXT             0x8452\n#define GL_CURRENT_FOG_COORDINATE_EXT     0x8453\n#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT  0x8454\n#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455\n#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456\n#define GL_FOG_COORDINATE_ARRAY_EXT       0x8457\ntypedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);\ntypedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFogCoordfEXT (GLfloat coord);\nGLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord);\nGLAPI void APIENTRY glFogCoorddEXT (GLdouble coord);\nGLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord);\nGLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_EXT_fog_coord */\n\n#ifndef GL_EXT_framebuffer_blit\n#define GL_EXT_framebuffer_blit 1\n#define GL_READ_FRAMEBUFFER_EXT           0x8CA8\n#define GL_DRAW_FRAMEBUFFER_EXT           0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING_EXT   0x8CA6\n#define GL_READ_FRAMEBUFFER_BINDING_EXT   0x8CAA\ntypedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#endif\n#endif /* GL_EXT_framebuffer_blit */\n\n#ifndef GL_EXT_framebuffer_multisample\n#define GL_EXT_framebuffer_multisample 1\n#define GL_RENDERBUFFER_SAMPLES_EXT       0x8CAB\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56\n#define GL_MAX_SAMPLES_EXT                0x8D57\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n#endif\n#endif /* GL_EXT_framebuffer_multisample */\n\n#ifndef GL_EXT_framebuffer_multisample_blit_scaled\n#define GL_EXT_framebuffer_multisample_blit_scaled 1\n#define GL_SCALED_RESOLVE_FASTEST_EXT     0x90BA\n#define GL_SCALED_RESOLVE_NICEST_EXT      0x90BB\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\n\n#ifndef GL_EXT_framebuffer_object\n#define GL_EXT_framebuffer_object 1\n#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506\n#define GL_MAX_RENDERBUFFER_SIZE_EXT      0x84E8\n#define GL_FRAMEBUFFER_BINDING_EXT        0x8CA6\n#define GL_RENDERBUFFER_BINDING_EXT       0x8CA7\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4\n#define GL_FRAMEBUFFER_COMPLETE_EXT       0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9\n#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC\n#define GL_FRAMEBUFFER_UNSUPPORTED_EXT    0x8CDD\n#define GL_MAX_COLOR_ATTACHMENTS_EXT      0x8CDF\n#define GL_COLOR_ATTACHMENT0_EXT          0x8CE0\n#define GL_COLOR_ATTACHMENT1_EXT          0x8CE1\n#define GL_COLOR_ATTACHMENT2_EXT          0x8CE2\n#define GL_COLOR_ATTACHMENT3_EXT          0x8CE3\n#define GL_COLOR_ATTACHMENT4_EXT          0x8CE4\n#define GL_COLOR_ATTACHMENT5_EXT          0x8CE5\n#define GL_COLOR_ATTACHMENT6_EXT          0x8CE6\n#define GL_COLOR_ATTACHMENT7_EXT          0x8CE7\n#define GL_COLOR_ATTACHMENT8_EXT          0x8CE8\n#define GL_COLOR_ATTACHMENT9_EXT          0x8CE9\n#define GL_COLOR_ATTACHMENT10_EXT         0x8CEA\n#define GL_COLOR_ATTACHMENT11_EXT         0x8CEB\n#define GL_COLOR_ATTACHMENT12_EXT         0x8CEC\n#define GL_COLOR_ATTACHMENT13_EXT         0x8CED\n#define GL_COLOR_ATTACHMENT14_EXT         0x8CEE\n#define GL_COLOR_ATTACHMENT15_EXT         0x8CEF\n#define GL_DEPTH_ATTACHMENT_EXT           0x8D00\n#define GL_STENCIL_ATTACHMENT_EXT         0x8D20\n#define GL_FRAMEBUFFER_EXT                0x8D40\n#define GL_RENDERBUFFER_EXT               0x8D41\n#define GL_RENDERBUFFER_WIDTH_EXT         0x8D42\n#define GL_RENDERBUFFER_HEIGHT_EXT        0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44\n#define GL_STENCIL_INDEX1_EXT             0x8D46\n#define GL_STENCIL_INDEX4_EXT             0x8D47\n#define GL_STENCIL_INDEX8_EXT             0x8D48\n#define GL_STENCIL_INDEX16_EXT            0x8D49\n#define GL_RENDERBUFFER_RED_SIZE_EXT      0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE_EXT    0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE_EXT     0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE_EXT    0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE_EXT    0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE_EXT  0x8D55\ntypedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);\ntypedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);\ntypedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);\ntypedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);\ntypedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);\ntypedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\ntypedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer);\nGLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer);\nGLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers);\nGLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);\nGLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\nGLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer);\nGLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer);\nGLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers);\nGLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers);\nGLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target);\nGLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\nGLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nGLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGenerateMipmapEXT (GLenum target);\n#endif\n#endif /* GL_EXT_framebuffer_object */\n\n#ifndef GL_EXT_framebuffer_sRGB\n#define GL_EXT_framebuffer_sRGB 1\n#define GL_FRAMEBUFFER_SRGB_EXT           0x8DB9\n#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT   0x8DBA\n#endif /* GL_EXT_framebuffer_sRGB */\n\n#ifndef GL_EXT_geometry_shader4\n#define GL_EXT_geometry_shader4 1\n#define GL_GEOMETRY_SHADER_EXT            0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT_EXT      0x8DDA\n#define GL_GEOMETRY_INPUT_TYPE_EXT        0x8DDB\n#define GL_GEOMETRY_OUTPUT_TYPE_EXT       0x8DDC\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE\n#define GL_MAX_VARYING_COMPONENTS_EXT     0x8B4B\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1\n#define GL_LINES_ADJACENCY_EXT            0x000A\n#define GL_LINE_STRIP_ADJACENCY_EXT       0x000B\n#define GL_TRIANGLES_ADJACENCY_EXT        0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY_EXT   0x000D\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4\n#define GL_PROGRAM_POINT_SIZE_EXT         0x8642\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);\n#endif\n#endif /* GL_EXT_geometry_shader4 */\n\n#ifndef GL_EXT_gpu_program_parameters\n#define GL_EXT_gpu_program_parameters 1\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);\nGLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params);\n#endif\n#endif /* GL_EXT_gpu_program_parameters */\n\n#ifndef GL_EXT_gpu_shader4\n#define GL_EXT_gpu_shader4 1\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD\n#define GL_SAMPLER_1D_ARRAY_EXT           0x8DC0\n#define GL_SAMPLER_2D_ARRAY_EXT           0x8DC1\n#define GL_SAMPLER_BUFFER_EXT             0x8DC2\n#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT    0x8DC3\n#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT    0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW_EXT        0x8DC5\n#define GL_UNSIGNED_INT_VEC2_EXT          0x8DC6\n#define GL_UNSIGNED_INT_VEC3_EXT          0x8DC7\n#define GL_UNSIGNED_INT_VEC4_EXT          0x8DC8\n#define GL_INT_SAMPLER_1D_EXT             0x8DC9\n#define GL_INT_SAMPLER_2D_EXT             0x8DCA\n#define GL_INT_SAMPLER_3D_EXT             0x8DCB\n#define GL_INT_SAMPLER_CUBE_EXT           0x8DCC\n#define GL_INT_SAMPLER_2D_RECT_EXT        0x8DCD\n#define GL_INT_SAMPLER_1D_ARRAY_EXT       0x8DCE\n#define GL_INT_SAMPLER_2D_ARRAY_EXT       0x8DCF\n#define GL_INT_SAMPLER_BUFFER_EXT         0x8DD0\n#define GL_UNSIGNED_INT_SAMPLER_1D_EXT    0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_2D_EXT    0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_3D_EXT    0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT  0x8DD4\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8\n#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT   0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT   0x8905\ntypedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);\ntypedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);\ntypedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);\ntypedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);\ntypedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);\ntypedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\ntypedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\ntypedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params);\nGLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name);\nGLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0);\nGLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1);\nGLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2);\nGLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\nGLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value);\nGLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value);\n#endif\n#endif /* GL_EXT_gpu_shader4 */\n\n#ifndef GL_EXT_histogram\n#define GL_EXT_histogram 1\n#define GL_HISTOGRAM_EXT                  0x8024\n#define GL_PROXY_HISTOGRAM_EXT            0x8025\n#define GL_HISTOGRAM_WIDTH_EXT            0x8026\n#define GL_HISTOGRAM_FORMAT_EXT           0x8027\n#define GL_HISTOGRAM_RED_SIZE_EXT         0x8028\n#define GL_HISTOGRAM_GREEN_SIZE_EXT       0x8029\n#define GL_HISTOGRAM_BLUE_SIZE_EXT        0x802A\n#define GL_HISTOGRAM_ALPHA_SIZE_EXT       0x802B\n#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT   0x802C\n#define GL_HISTOGRAM_SINK_EXT             0x802D\n#define GL_MINMAX_EXT                     0x802E\n#define GL_MINMAX_FORMAT_EXT              0x802F\n#define GL_MINMAX_SINK_EXT                0x8030\n#define GL_TABLE_TOO_LARGE_EXT            0x8031\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\ntypedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\ntypedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);\ntypedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\nGLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\nGLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\nGLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink);\nGLAPI void APIENTRY glResetHistogramEXT (GLenum target);\nGLAPI void APIENTRY glResetMinmaxEXT (GLenum target);\n#endif\n#endif /* GL_EXT_histogram */\n\n#ifndef GL_EXT_index_array_formats\n#define GL_EXT_index_array_formats 1\n#define GL_IUI_V2F_EXT                    0x81AD\n#define GL_IUI_V3F_EXT                    0x81AE\n#define GL_IUI_N3F_V2F_EXT                0x81AF\n#define GL_IUI_N3F_V3F_EXT                0x81B0\n#define GL_T2F_IUI_V2F_EXT                0x81B1\n#define GL_T2F_IUI_V3F_EXT                0x81B2\n#define GL_T2F_IUI_N3F_V2F_EXT            0x81B3\n#define GL_T2F_IUI_N3F_V3F_EXT            0x81B4\n#endif /* GL_EXT_index_array_formats */\n\n#ifndef GL_EXT_index_func\n#define GL_EXT_index_func 1\n#define GL_INDEX_TEST_EXT                 0x81B5\n#define GL_INDEX_TEST_FUNC_EXT            0x81B6\n#define GL_INDEX_TEST_REF_EXT             0x81B7\ntypedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref);\n#endif\n#endif /* GL_EXT_index_func */\n\n#ifndef GL_EXT_index_material\n#define GL_EXT_index_material 1\n#define GL_INDEX_MATERIAL_EXT             0x81B8\n#define GL_INDEX_MATERIAL_PARAMETER_EXT   0x81B9\n#define GL_INDEX_MATERIAL_FACE_EXT        0x81BA\ntypedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode);\n#endif\n#endif /* GL_EXT_index_material */\n\n#ifndef GL_EXT_index_texture\n#define GL_EXT_index_texture 1\n#endif /* GL_EXT_index_texture */\n\n#ifndef GL_EXT_light_texture\n#define GL_EXT_light_texture 1\n#define GL_FRAGMENT_MATERIAL_EXT          0x8349\n#define GL_FRAGMENT_NORMAL_EXT            0x834A\n#define GL_FRAGMENT_COLOR_EXT             0x834C\n#define GL_ATTENUATION_EXT                0x834D\n#define GL_SHADOW_ATTENUATION_EXT         0x834E\n#define GL_TEXTURE_APPLICATION_MODE_EXT   0x834F\n#define GL_TEXTURE_LIGHT_EXT              0x8350\n#define GL_TEXTURE_MATERIAL_FACE_EXT      0x8351\n#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352\ntypedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);\ntypedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);\ntypedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glApplyTextureEXT (GLenum mode);\nGLAPI void APIENTRY glTextureLightEXT (GLenum pname);\nGLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode);\n#endif\n#endif /* GL_EXT_light_texture */\n\n#ifndef GL_EXT_misc_attribute\n#define GL_EXT_misc_attribute 1\n#endif /* GL_EXT_misc_attribute */\n\n#ifndef GL_EXT_multi_draw_arrays\n#define GL_EXT_multi_draw_arrays 1\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);\nGLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);\n#endif\n#endif /* GL_EXT_multi_draw_arrays */\n\n#ifndef GL_EXT_multisample\n#define GL_EXT_multisample 1\n#define GL_MULTISAMPLE_EXT                0x809D\n#define GL_SAMPLE_ALPHA_TO_MASK_EXT       0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_EXT        0x809F\n#define GL_SAMPLE_MASK_EXT                0x80A0\n#define GL_1PASS_EXT                      0x80A1\n#define GL_2PASS_0_EXT                    0x80A2\n#define GL_2PASS_1_EXT                    0x80A3\n#define GL_4PASS_0_EXT                    0x80A4\n#define GL_4PASS_1_EXT                    0x80A5\n#define GL_4PASS_2_EXT                    0x80A6\n#define GL_4PASS_3_EXT                    0x80A7\n#define GL_SAMPLE_BUFFERS_EXT             0x80A8\n#define GL_SAMPLES_EXT                    0x80A9\n#define GL_SAMPLE_MASK_VALUE_EXT          0x80AA\n#define GL_SAMPLE_MASK_INVERT_EXT         0x80AB\n#define GL_SAMPLE_PATTERN_EXT             0x80AC\n#define GL_MULTISAMPLE_BIT_EXT            0x20000000\ntypedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);\ntypedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert);\nGLAPI void APIENTRY glSamplePatternEXT (GLenum pattern);\n#endif\n#endif /* GL_EXT_multisample */\n\n#ifndef GL_EXT_packed_depth_stencil\n#define GL_EXT_packed_depth_stencil 1\n#define GL_DEPTH_STENCIL_EXT              0x84F9\n#define GL_UNSIGNED_INT_24_8_EXT          0x84FA\n#define GL_DEPTH24_STENCIL8_EXT           0x88F0\n#define GL_TEXTURE_STENCIL_SIZE_EXT       0x88F1\n#endif /* GL_EXT_packed_depth_stencil */\n\n#ifndef GL_EXT_packed_float\n#define GL_EXT_packed_float 1\n#define GL_R11F_G11F_B10F_EXT             0x8C3A\n#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B\n#define GL_RGBA_SIGNED_COMPONENTS_EXT     0x8C3C\n#endif /* GL_EXT_packed_float */\n\n#ifndef GL_EXT_packed_pixels\n#define GL_EXT_packed_pixels 1\n#define GL_UNSIGNED_BYTE_3_3_2_EXT        0x8032\n#define GL_UNSIGNED_SHORT_4_4_4_4_EXT     0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1_EXT     0x8034\n#define GL_UNSIGNED_INT_8_8_8_8_EXT       0x8035\n#define GL_UNSIGNED_INT_10_10_10_2_EXT    0x8036\n#endif /* GL_EXT_packed_pixels */\n\n#ifndef GL_EXT_paletted_texture\n#define GL_EXT_paletted_texture 1\n#define GL_COLOR_INDEX1_EXT               0x80E2\n#define GL_COLOR_INDEX2_EXT               0x80E3\n#define GL_COLOR_INDEX4_EXT               0x80E4\n#define GL_COLOR_INDEX8_EXT               0x80E5\n#define GL_COLOR_INDEX12_EXT              0x80E6\n#define GL_COLOR_INDEX16_EXT              0x80E7\n#define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED\ntypedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table);\nGLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data);\nGLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_EXT_paletted_texture */\n\n#ifndef GL_EXT_pixel_buffer_object\n#define GL_EXT_pixel_buffer_object 1\n#define GL_PIXEL_PACK_BUFFER_EXT          0x88EB\n#define GL_PIXEL_UNPACK_BUFFER_EXT        0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING_EXT  0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF\n#endif /* GL_EXT_pixel_buffer_object */\n\n#ifndef GL_EXT_pixel_transform\n#define GL_EXT_pixel_transform 1\n#define GL_PIXEL_TRANSFORM_2D_EXT         0x8330\n#define GL_PIXEL_MAG_FILTER_EXT           0x8331\n#define GL_PIXEL_MIN_FILTER_EXT           0x8332\n#define GL_PIXEL_CUBIC_WEIGHT_EXT         0x8333\n#define GL_CUBIC_EXT                      0x8334\n#define GL_AVERAGE_EXT                    0x8335\n#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336\n#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337\n#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT  0x8338\ntypedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_EXT_pixel_transform */\n\n#ifndef GL_EXT_pixel_transform_color_table\n#define GL_EXT_pixel_transform_color_table 1\n#endif /* GL_EXT_pixel_transform_color_table */\n\n#ifndef GL_EXT_point_parameters\n#define GL_EXT_point_parameters 1\n#define GL_POINT_SIZE_MIN_EXT             0x8126\n#define GL_POINT_SIZE_MAX_EXT             0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_EXT  0x8128\n#define GL_DISTANCE_ATTENUATION_EXT       0x8129\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params);\n#endif\n#endif /* GL_EXT_point_parameters */\n\n#ifndef GL_EXT_polygon_offset\n#define GL_EXT_polygon_offset 1\n#define GL_POLYGON_OFFSET_EXT             0x8037\n#define GL_POLYGON_OFFSET_FACTOR_EXT      0x8038\n#define GL_POLYGON_OFFSET_BIAS_EXT        0x8039\ntypedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias);\n#endif\n#endif /* GL_EXT_polygon_offset */\n\n#ifndef GL_EXT_provoking_vertex\n#define GL_EXT_provoking_vertex 1\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C\n#define GL_FIRST_VERTEX_CONVENTION_EXT    0x8E4D\n#define GL_LAST_VERTEX_CONVENTION_EXT     0x8E4E\n#define GL_PROVOKING_VERTEX_EXT           0x8E4F\ntypedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProvokingVertexEXT (GLenum mode);\n#endif\n#endif /* GL_EXT_provoking_vertex */\n\n#ifndef GL_EXT_rescale_normal\n#define GL_EXT_rescale_normal 1\n#define GL_RESCALE_NORMAL_EXT             0x803A\n#endif /* GL_EXT_rescale_normal */\n\n#ifndef GL_EXT_secondary_color\n#define GL_EXT_secondary_color 1\n#define GL_COLOR_SUM_EXT                  0x8458\n#define GL_CURRENT_SECONDARY_COLOR_EXT    0x8459\n#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A\n#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C\n#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D\n#define GL_SECONDARY_COLOR_ARRAY_EXT      0x845E\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue);\nGLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v);\nGLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue);\nGLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v);\nGLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue);\nGLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v);\nGLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue);\nGLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v);\nGLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue);\nGLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v);\nGLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue);\nGLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v);\nGLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue);\nGLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v);\nGLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue);\nGLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v);\nGLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_EXT_secondary_color */\n\n#ifndef GL_EXT_separate_shader_objects\n#define GL_EXT_separate_shader_objects 1\n#define GL_ACTIVE_PROGRAM_EXT             0x8B8D\ntypedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);\ntypedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);\ntypedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program);\nGLAPI void APIENTRY glActiveProgramEXT (GLuint program);\nGLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string);\n#endif\n#endif /* GL_EXT_separate_shader_objects */\n\n#ifndef GL_EXT_separate_specular_color\n#define GL_EXT_separate_specular_color 1\n#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT  0x81F8\n#define GL_SINGLE_COLOR_EXT               0x81F9\n#define GL_SEPARATE_SPECULAR_COLOR_EXT    0x81FA\n#endif /* GL_EXT_separate_specular_color */\n\n#ifndef GL_EXT_shader_image_load_formatted\n#define GL_EXT_shader_image_load_formatted 1\n#endif /* GL_EXT_shader_image_load_formatted */\n\n#ifndef GL_EXT_shader_image_load_store\n#define GL_EXT_shader_image_load_store 1\n#define GL_MAX_IMAGE_UNITS_EXT            0x8F38\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39\n#define GL_IMAGE_BINDING_NAME_EXT         0x8F3A\n#define GL_IMAGE_BINDING_LEVEL_EXT        0x8F3B\n#define GL_IMAGE_BINDING_LAYERED_EXT      0x8F3C\n#define GL_IMAGE_BINDING_LAYER_EXT        0x8F3D\n#define GL_IMAGE_BINDING_ACCESS_EXT       0x8F3E\n#define GL_IMAGE_1D_EXT                   0x904C\n#define GL_IMAGE_2D_EXT                   0x904D\n#define GL_IMAGE_3D_EXT                   0x904E\n#define GL_IMAGE_2D_RECT_EXT              0x904F\n#define GL_IMAGE_CUBE_EXT                 0x9050\n#define GL_IMAGE_BUFFER_EXT               0x9051\n#define GL_IMAGE_1D_ARRAY_EXT             0x9052\n#define GL_IMAGE_2D_ARRAY_EXT             0x9053\n#define GL_IMAGE_CUBE_MAP_ARRAY_EXT       0x9054\n#define GL_IMAGE_2D_MULTISAMPLE_EXT       0x9055\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056\n#define GL_INT_IMAGE_1D_EXT               0x9057\n#define GL_INT_IMAGE_2D_EXT               0x9058\n#define GL_INT_IMAGE_3D_EXT               0x9059\n#define GL_INT_IMAGE_2D_RECT_EXT          0x905A\n#define GL_INT_IMAGE_CUBE_EXT             0x905B\n#define GL_INT_IMAGE_BUFFER_EXT           0x905C\n#define GL_INT_IMAGE_1D_ARRAY_EXT         0x905D\n#define GL_INT_IMAGE_2D_ARRAY_EXT         0x905E\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT   0x905F\n#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT   0x9060\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061\n#define GL_UNSIGNED_INT_IMAGE_1D_EXT      0x9062\n#define GL_UNSIGNED_INT_IMAGE_2D_EXT      0x9063\n#define GL_UNSIGNED_INT_IMAGE_3D_EXT      0x9064\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065\n#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT    0x9066\n#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT  0x9067\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C\n#define GL_MAX_IMAGE_SAMPLES_EXT          0x906D\n#define GL_IMAGE_BINDING_FORMAT_EXT       0x906E\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001\n#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT  0x00000002\n#define GL_UNIFORM_BARRIER_BIT_EXT        0x00000004\n#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT  0x00000008\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020\n#define GL_COMMAND_BARRIER_BIT_EXT        0x00000040\n#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT   0x00000080\n#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100\n#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT  0x00000200\n#define GL_FRAMEBUFFER_BARRIER_BIT_EXT    0x00000400\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800\n#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000\n#define GL_ALL_BARRIER_BITS_EXT           0xFFFFFFFF\ntypedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);\ntypedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);\nGLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers);\n#endif\n#endif /* GL_EXT_shader_image_load_store */\n\n#ifndef GL_EXT_shader_integer_mix\n#define GL_EXT_shader_integer_mix 1\n#endif /* GL_EXT_shader_integer_mix */\n\n#ifndef GL_EXT_shadow_funcs\n#define GL_EXT_shadow_funcs 1\n#endif /* GL_EXT_shadow_funcs */\n\n#ifndef GL_EXT_shared_texture_palette\n#define GL_EXT_shared_texture_palette 1\n#define GL_SHARED_TEXTURE_PALETTE_EXT     0x81FB\n#endif /* GL_EXT_shared_texture_palette */\n\n#ifndef GL_EXT_stencil_clear_tag\n#define GL_EXT_stencil_clear_tag 1\n#define GL_STENCIL_TAG_BITS_EXT           0x88F2\n#define GL_STENCIL_CLEAR_TAG_VALUE_EXT    0x88F3\ntypedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag);\n#endif\n#endif /* GL_EXT_stencil_clear_tag */\n\n#ifndef GL_EXT_stencil_two_side\n#define GL_EXT_stencil_two_side 1\n#define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910\n#define GL_ACTIVE_STENCIL_FACE_EXT        0x8911\ntypedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face);\n#endif\n#endif /* GL_EXT_stencil_two_side */\n\n#ifndef GL_EXT_stencil_wrap\n#define GL_EXT_stencil_wrap 1\n#define GL_INCR_WRAP_EXT                  0x8507\n#define GL_DECR_WRAP_EXT                  0x8508\n#endif /* GL_EXT_stencil_wrap */\n\n#ifndef GL_EXT_subtexture\n#define GL_EXT_subtexture 1\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\n#endif\n#endif /* GL_EXT_subtexture */\n\n#ifndef GL_EXT_texture\n#define GL_EXT_texture 1\n#define GL_ALPHA4_EXT                     0x803B\n#define GL_ALPHA8_EXT                     0x803C\n#define GL_ALPHA12_EXT                    0x803D\n#define GL_ALPHA16_EXT                    0x803E\n#define GL_LUMINANCE4_EXT                 0x803F\n#define GL_LUMINANCE8_EXT                 0x8040\n#define GL_LUMINANCE12_EXT                0x8041\n#define GL_LUMINANCE16_EXT                0x8042\n#define GL_LUMINANCE4_ALPHA4_EXT          0x8043\n#define GL_LUMINANCE6_ALPHA2_EXT          0x8044\n#define GL_LUMINANCE8_ALPHA8_EXT          0x8045\n#define GL_LUMINANCE12_ALPHA4_EXT         0x8046\n#define GL_LUMINANCE12_ALPHA12_EXT        0x8047\n#define GL_LUMINANCE16_ALPHA16_EXT        0x8048\n#define GL_INTENSITY_EXT                  0x8049\n#define GL_INTENSITY4_EXT                 0x804A\n#define GL_INTENSITY8_EXT                 0x804B\n#define GL_INTENSITY12_EXT                0x804C\n#define GL_INTENSITY16_EXT                0x804D\n#define GL_RGB2_EXT                       0x804E\n#define GL_RGB4_EXT                       0x804F\n#define GL_RGB5_EXT                       0x8050\n#define GL_RGB8_EXT                       0x8051\n#define GL_RGB10_EXT                      0x8052\n#define GL_RGB12_EXT                      0x8053\n#define GL_RGB16_EXT                      0x8054\n#define GL_RGBA2_EXT                      0x8055\n#define GL_RGBA4_EXT                      0x8056\n#define GL_RGB5_A1_EXT                    0x8057\n#define GL_RGBA8_EXT                      0x8058\n#define GL_RGB10_A2_EXT                   0x8059\n#define GL_RGBA12_EXT                     0x805A\n#define GL_RGBA16_EXT                     0x805B\n#define GL_TEXTURE_RED_SIZE_EXT           0x805C\n#define GL_TEXTURE_GREEN_SIZE_EXT         0x805D\n#define GL_TEXTURE_BLUE_SIZE_EXT          0x805E\n#define GL_TEXTURE_ALPHA_SIZE_EXT         0x805F\n#define GL_TEXTURE_LUMINANCE_SIZE_EXT     0x8060\n#define GL_TEXTURE_INTENSITY_SIZE_EXT     0x8061\n#define GL_REPLACE_EXT                    0x8062\n#define GL_PROXY_TEXTURE_1D_EXT           0x8063\n#define GL_PROXY_TEXTURE_2D_EXT           0x8064\n#define GL_TEXTURE_TOO_LARGE_EXT          0x8065\n#endif /* GL_EXT_texture */\n\n#ifndef GL_EXT_texture3D\n#define GL_EXT_texture3D 1\n#define GL_PACK_SKIP_IMAGES_EXT           0x806B\n#define GL_PACK_IMAGE_HEIGHT_EXT          0x806C\n#define GL_UNPACK_SKIP_IMAGES_EXT         0x806D\n#define GL_UNPACK_IMAGE_HEIGHT_EXT        0x806E\n#define GL_TEXTURE_3D_EXT                 0x806F\n#define GL_PROXY_TEXTURE_3D_EXT           0x8070\n#define GL_TEXTURE_DEPTH_EXT              0x8071\n#define GL_TEXTURE_WRAP_R_EXT             0x8072\n#define GL_MAX_3D_TEXTURE_SIZE_EXT        0x8073\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\n#endif\n#endif /* GL_EXT_texture3D */\n\n#ifndef GL_EXT_texture_array\n#define GL_EXT_texture_array 1\n#define GL_TEXTURE_1D_ARRAY_EXT           0x8C18\n#define GL_PROXY_TEXTURE_1D_ARRAY_EXT     0x8C19\n#define GL_TEXTURE_2D_ARRAY_EXT           0x8C1A\n#define GL_PROXY_TEXTURE_2D_ARRAY_EXT     0x8C1B\n#define GL_TEXTURE_BINDING_1D_ARRAY_EXT   0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY_EXT   0x8C1D\n#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT   0x88FF\n#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\n#endif\n#endif /* GL_EXT_texture_array */\n\n#ifndef GL_EXT_texture_buffer_object\n#define GL_EXT_texture_buffer_object 1\n#define GL_TEXTURE_BUFFER_EXT             0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT    0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER_EXT     0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D\n#define GL_TEXTURE_BUFFER_FORMAT_EXT      0x8C2E\ntypedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer);\n#endif\n#endif /* GL_EXT_texture_buffer_object */\n\n#ifndef GL_EXT_texture_compression_latc\n#define GL_EXT_texture_compression_latc 1\n#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70\n#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71\n#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72\n#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73\n#endif /* GL_EXT_texture_compression_latc */\n\n#ifndef GL_EXT_texture_compression_rgtc\n#define GL_EXT_texture_compression_rgtc 1\n#define GL_COMPRESSED_RED_RGTC1_EXT       0x8DBB\n#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC\n#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD\n#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE\n#endif /* GL_EXT_texture_compression_rgtc */\n\n#ifndef GL_EXT_texture_compression_s3tc\n#define GL_EXT_texture_compression_s3tc 1\n#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3\n#endif /* GL_EXT_texture_compression_s3tc */\n\n#ifndef GL_EXT_texture_cube_map\n#define GL_EXT_texture_cube_map 1\n#define GL_NORMAL_MAP_EXT                 0x8511\n#define GL_REFLECTION_MAP_EXT             0x8512\n#define GL_TEXTURE_CUBE_MAP_EXT           0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP_EXT   0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP_EXT     0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT  0x851C\n#endif /* GL_EXT_texture_cube_map */\n\n#ifndef GL_EXT_texture_env_add\n#define GL_EXT_texture_env_add 1\n#endif /* GL_EXT_texture_env_add */\n\n#ifndef GL_EXT_texture_env_combine\n#define GL_EXT_texture_env_combine 1\n#define GL_COMBINE_EXT                    0x8570\n#define GL_COMBINE_RGB_EXT                0x8571\n#define GL_COMBINE_ALPHA_EXT              0x8572\n#define GL_RGB_SCALE_EXT                  0x8573\n#define GL_ADD_SIGNED_EXT                 0x8574\n#define GL_INTERPOLATE_EXT                0x8575\n#define GL_CONSTANT_EXT                   0x8576\n#define GL_PRIMARY_COLOR_EXT              0x8577\n#define GL_PREVIOUS_EXT                   0x8578\n#define GL_SOURCE0_RGB_EXT                0x8580\n#define GL_SOURCE1_RGB_EXT                0x8581\n#define GL_SOURCE2_RGB_EXT                0x8582\n#define GL_SOURCE0_ALPHA_EXT              0x8588\n#define GL_SOURCE1_ALPHA_EXT              0x8589\n#define GL_SOURCE2_ALPHA_EXT              0x858A\n#define GL_OPERAND0_RGB_EXT               0x8590\n#define GL_OPERAND1_RGB_EXT               0x8591\n#define GL_OPERAND2_RGB_EXT               0x8592\n#define GL_OPERAND0_ALPHA_EXT             0x8598\n#define GL_OPERAND1_ALPHA_EXT             0x8599\n#define GL_OPERAND2_ALPHA_EXT             0x859A\n#endif /* GL_EXT_texture_env_combine */\n\n#ifndef GL_EXT_texture_env_dot3\n#define GL_EXT_texture_env_dot3 1\n#define GL_DOT3_RGB_EXT                   0x8740\n#define GL_DOT3_RGBA_EXT                  0x8741\n#endif /* GL_EXT_texture_env_dot3 */\n\n#ifndef GL_EXT_texture_filter_anisotropic\n#define GL_EXT_texture_filter_anisotropic 1\n#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE\n#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF\n#endif /* GL_EXT_texture_filter_anisotropic */\n\n#ifndef GL_EXT_texture_integer\n#define GL_EXT_texture_integer 1\n#define GL_RGBA32UI_EXT                   0x8D70\n#define GL_RGB32UI_EXT                    0x8D71\n#define GL_ALPHA32UI_EXT                  0x8D72\n#define GL_INTENSITY32UI_EXT              0x8D73\n#define GL_LUMINANCE32UI_EXT              0x8D74\n#define GL_LUMINANCE_ALPHA32UI_EXT        0x8D75\n#define GL_RGBA16UI_EXT                   0x8D76\n#define GL_RGB16UI_EXT                    0x8D77\n#define GL_ALPHA16UI_EXT                  0x8D78\n#define GL_INTENSITY16UI_EXT              0x8D79\n#define GL_LUMINANCE16UI_EXT              0x8D7A\n#define GL_LUMINANCE_ALPHA16UI_EXT        0x8D7B\n#define GL_RGBA8UI_EXT                    0x8D7C\n#define GL_RGB8UI_EXT                     0x8D7D\n#define GL_ALPHA8UI_EXT                   0x8D7E\n#define GL_INTENSITY8UI_EXT               0x8D7F\n#define GL_LUMINANCE8UI_EXT               0x8D80\n#define GL_LUMINANCE_ALPHA8UI_EXT         0x8D81\n#define GL_RGBA32I_EXT                    0x8D82\n#define GL_RGB32I_EXT                     0x8D83\n#define GL_ALPHA32I_EXT                   0x8D84\n#define GL_INTENSITY32I_EXT               0x8D85\n#define GL_LUMINANCE32I_EXT               0x8D86\n#define GL_LUMINANCE_ALPHA32I_EXT         0x8D87\n#define GL_RGBA16I_EXT                    0x8D88\n#define GL_RGB16I_EXT                     0x8D89\n#define GL_ALPHA16I_EXT                   0x8D8A\n#define GL_INTENSITY16I_EXT               0x8D8B\n#define GL_LUMINANCE16I_EXT               0x8D8C\n#define GL_LUMINANCE_ALPHA16I_EXT         0x8D8D\n#define GL_RGBA8I_EXT                     0x8D8E\n#define GL_RGB8I_EXT                      0x8D8F\n#define GL_ALPHA8I_EXT                    0x8D90\n#define GL_INTENSITY8I_EXT                0x8D91\n#define GL_LUMINANCE8I_EXT                0x8D92\n#define GL_LUMINANCE_ALPHA8I_EXT          0x8D93\n#define GL_RED_INTEGER_EXT                0x8D94\n#define GL_GREEN_INTEGER_EXT              0x8D95\n#define GL_BLUE_INTEGER_EXT               0x8D96\n#define GL_ALPHA_INTEGER_EXT              0x8D97\n#define GL_RGB_INTEGER_EXT                0x8D98\n#define GL_RGBA_INTEGER_EXT               0x8D99\n#define GL_BGR_INTEGER_EXT                0x8D9A\n#define GL_BGRA_INTEGER_EXT               0x8D9B\n#define GL_LUMINANCE_INTEGER_EXT          0x8D9C\n#define GL_LUMINANCE_ALPHA_INTEGER_EXT    0x8D9D\n#define GL_RGBA_INTEGER_MODE_EXT          0x8D9E\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);\ntypedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params);\nGLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha);\nGLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha);\n#endif\n#endif /* GL_EXT_texture_integer */\n\n#ifndef GL_EXT_texture_lod_bias\n#define GL_EXT_texture_lod_bias 1\n#define GL_MAX_TEXTURE_LOD_BIAS_EXT       0x84FD\n#define GL_TEXTURE_FILTER_CONTROL_EXT     0x8500\n#define GL_TEXTURE_LOD_BIAS_EXT           0x8501\n#endif /* GL_EXT_texture_lod_bias */\n\n#ifndef GL_EXT_texture_mirror_clamp\n#define GL_EXT_texture_mirror_clamp 1\n#define GL_MIRROR_CLAMP_EXT               0x8742\n#define GL_MIRROR_CLAMP_TO_EDGE_EXT       0x8743\n#define GL_MIRROR_CLAMP_TO_BORDER_EXT     0x8912\n#endif /* GL_EXT_texture_mirror_clamp */\n\n#ifndef GL_EXT_texture_object\n#define GL_EXT_texture_object 1\n#define GL_TEXTURE_PRIORITY_EXT           0x8066\n#define GL_TEXTURE_RESIDENT_EXT           0x8067\n#define GL_TEXTURE_1D_BINDING_EXT         0x8068\n#define GL_TEXTURE_2D_BINDING_EXT         0x8069\n#define GL_TEXTURE_3D_BINDING_EXT         0x806A\ntypedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);\ntypedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);\ntypedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);\ntypedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);\ntypedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);\ntypedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences);\nGLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture);\nGLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures);\nGLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures);\nGLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture);\nGLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities);\n#endif\n#endif /* GL_EXT_texture_object */\n\n#ifndef GL_EXT_texture_perturb_normal\n#define GL_EXT_texture_perturb_normal 1\n#define GL_PERTURB_EXT                    0x85AE\n#define GL_TEXTURE_NORMAL_EXT             0x85AF\ntypedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTextureNormalEXT (GLenum mode);\n#endif\n#endif /* GL_EXT_texture_perturb_normal */\n\n#ifndef GL_EXT_texture_sRGB\n#define GL_EXT_texture_sRGB 1\n#define GL_SRGB_EXT                       0x8C40\n#define GL_SRGB8_EXT                      0x8C41\n#define GL_SRGB_ALPHA_EXT                 0x8C42\n#define GL_SRGB8_ALPHA8_EXT               0x8C43\n#define GL_SLUMINANCE_ALPHA_EXT           0x8C44\n#define GL_SLUMINANCE8_ALPHA8_EXT         0x8C45\n#define GL_SLUMINANCE_EXT                 0x8C46\n#define GL_SLUMINANCE8_EXT                0x8C47\n#define GL_COMPRESSED_SRGB_EXT            0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA_EXT      0x8C49\n#define GL_COMPRESSED_SLUMINANCE_EXT      0x8C4A\n#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B\n#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT  0x8C4C\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F\n#endif /* GL_EXT_texture_sRGB */\n\n#ifndef GL_EXT_texture_sRGB_decode\n#define GL_EXT_texture_sRGB_decode 1\n#define GL_TEXTURE_SRGB_DECODE_EXT        0x8A48\n#define GL_DECODE_EXT                     0x8A49\n#define GL_SKIP_DECODE_EXT                0x8A4A\n#endif /* GL_EXT_texture_sRGB_decode */\n\n#ifndef GL_EXT_texture_shared_exponent\n#define GL_EXT_texture_shared_exponent 1\n#define GL_RGB9_E5_EXT                    0x8C3D\n#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT   0x8C3E\n#define GL_TEXTURE_SHARED_SIZE_EXT        0x8C3F\n#endif /* GL_EXT_texture_shared_exponent */\n\n#ifndef GL_EXT_texture_snorm\n#define GL_EXT_texture_snorm 1\n#define GL_ALPHA_SNORM                    0x9010\n#define GL_LUMINANCE_SNORM                0x9011\n#define GL_LUMINANCE_ALPHA_SNORM          0x9012\n#define GL_INTENSITY_SNORM                0x9013\n#define GL_ALPHA8_SNORM                   0x9014\n#define GL_LUMINANCE8_SNORM               0x9015\n#define GL_LUMINANCE8_ALPHA8_SNORM        0x9016\n#define GL_INTENSITY8_SNORM               0x9017\n#define GL_ALPHA16_SNORM                  0x9018\n#define GL_LUMINANCE16_SNORM              0x9019\n#define GL_LUMINANCE16_ALPHA16_SNORM      0x901A\n#define GL_INTENSITY16_SNORM              0x901B\n#define GL_RED_SNORM                      0x8F90\n#define GL_RG_SNORM                       0x8F91\n#define GL_RGB_SNORM                      0x8F92\n#define GL_RGBA_SNORM                     0x8F93\n#endif /* GL_EXT_texture_snorm */\n\n#ifndef GL_EXT_texture_swizzle\n#define GL_EXT_texture_swizzle 1\n#define GL_TEXTURE_SWIZZLE_R_EXT          0x8E42\n#define GL_TEXTURE_SWIZZLE_G_EXT          0x8E43\n#define GL_TEXTURE_SWIZZLE_B_EXT          0x8E44\n#define GL_TEXTURE_SWIZZLE_A_EXT          0x8E45\n#define GL_TEXTURE_SWIZZLE_RGBA_EXT       0x8E46\n#endif /* GL_EXT_texture_swizzle */\n\n#ifndef GL_EXT_timer_query\n#define GL_EXT_timer_query 1\n#define GL_TIME_ELAPSED_EXT               0x88BF\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params);\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params);\nGLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params);\n#endif\n#endif /* GL_EXT_timer_query */\n\n#ifndef GL_EXT_transform_feedback\n#define GL_EXT_transform_feedback 1\n#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT  0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F\n#define GL_INTERLEAVED_ATTRIBS_EXT        0x8C8C\n#define GL_SEPARATE_ATTRIBS_EXT           0x8C8D\n#define GL_PRIMITIVES_GENERATED_EXT       0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88\n#define GL_RASTERIZER_DISCARD_EXT         0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76\ntypedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);\ntypedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);\ntypedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\ntypedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode);\nGLAPI void APIENTRY glEndTransformFeedbackEXT (void);\nGLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\nGLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\nGLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer);\nGLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);\nGLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\n#endif\n#endif /* GL_EXT_transform_feedback */\n\n#ifndef GL_EXT_vertex_array\n#define GL_EXT_vertex_array 1\n#define GL_VERTEX_ARRAY_EXT               0x8074\n#define GL_NORMAL_ARRAY_EXT               0x8075\n#define GL_COLOR_ARRAY_EXT                0x8076\n#define GL_INDEX_ARRAY_EXT                0x8077\n#define GL_TEXTURE_COORD_ARRAY_EXT        0x8078\n#define GL_EDGE_FLAG_ARRAY_EXT            0x8079\n#define GL_VERTEX_ARRAY_SIZE_EXT          0x807A\n#define GL_VERTEX_ARRAY_TYPE_EXT          0x807B\n#define GL_VERTEX_ARRAY_STRIDE_EXT        0x807C\n#define GL_VERTEX_ARRAY_COUNT_EXT         0x807D\n#define GL_NORMAL_ARRAY_TYPE_EXT          0x807E\n#define GL_NORMAL_ARRAY_STRIDE_EXT        0x807F\n#define GL_NORMAL_ARRAY_COUNT_EXT         0x8080\n#define GL_COLOR_ARRAY_SIZE_EXT           0x8081\n#define GL_COLOR_ARRAY_TYPE_EXT           0x8082\n#define GL_COLOR_ARRAY_STRIDE_EXT         0x8083\n#define GL_COLOR_ARRAY_COUNT_EXT          0x8084\n#define GL_INDEX_ARRAY_TYPE_EXT           0x8085\n#define GL_INDEX_ARRAY_STRIDE_EXT         0x8086\n#define GL_INDEX_ARRAY_COUNT_EXT          0x8087\n#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT   0x8088\n#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT   0x8089\n#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A\n#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT  0x808B\n#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT     0x808C\n#define GL_EDGE_FLAG_ARRAY_COUNT_EXT      0x808D\n#define GL_VERTEX_ARRAY_POINTER_EXT       0x808E\n#define GL_NORMAL_ARRAY_POINTER_EXT       0x808F\n#define GL_COLOR_ARRAY_POINTER_EXT        0x8090\n#define GL_INDEX_ARRAY_POINTER_EXT        0x8091\n#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092\n#define GL_EDGE_FLAG_ARRAY_POINTER_EXT    0x8093\ntypedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);\ntypedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\ntypedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);\ntypedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);\ntypedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params);\ntypedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\ntypedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\ntypedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\ntypedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glArrayElementEXT (GLint i);\nGLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\nGLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count);\nGLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer);\nGLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params);\nGLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\nGLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\nGLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\nGLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\n#endif\n#endif /* GL_EXT_vertex_array */\n\n#ifndef GL_EXT_vertex_array_bgra\n#define GL_EXT_vertex_array_bgra 1\n#endif /* GL_EXT_vertex_array_bgra */\n\n#ifndef GL_EXT_vertex_attrib_64bit\n#define GL_EXT_vertex_attrib_64bit 1\n#define GL_DOUBLE_VEC2_EXT                0x8FFC\n#define GL_DOUBLE_VEC3_EXT                0x8FFD\n#define GL_DOUBLE_VEC4_EXT                0x8FFE\n#define GL_DOUBLE_MAT2_EXT                0x8F46\n#define GL_DOUBLE_MAT3_EXT                0x8F47\n#define GL_DOUBLE_MAT4_EXT                0x8F48\n#define GL_DOUBLE_MAT2x3_EXT              0x8F49\n#define GL_DOUBLE_MAT2x4_EXT              0x8F4A\n#define GL_DOUBLE_MAT3x2_EXT              0x8F4B\n#define GL_DOUBLE_MAT3x4_EXT              0x8F4C\n#define GL_DOUBLE_MAT4x2_EXT              0x8F4D\n#define GL_DOUBLE_MAT4x3_EXT              0x8F4E\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x);\nGLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params);\n#endif\n#endif /* GL_EXT_vertex_attrib_64bit */\n\n#ifndef GL_EXT_vertex_shader\n#define GL_EXT_vertex_shader 1\n#define GL_VERTEX_SHADER_EXT              0x8780\n#define GL_VERTEX_SHADER_BINDING_EXT      0x8781\n#define GL_OP_INDEX_EXT                   0x8782\n#define GL_OP_NEGATE_EXT                  0x8783\n#define GL_OP_DOT3_EXT                    0x8784\n#define GL_OP_DOT4_EXT                    0x8785\n#define GL_OP_MUL_EXT                     0x8786\n#define GL_OP_ADD_EXT                     0x8787\n#define GL_OP_MADD_EXT                    0x8788\n#define GL_OP_FRAC_EXT                    0x8789\n#define GL_OP_MAX_EXT                     0x878A\n#define GL_OP_MIN_EXT                     0x878B\n#define GL_OP_SET_GE_EXT                  0x878C\n#define GL_OP_SET_LT_EXT                  0x878D\n#define GL_OP_CLAMP_EXT                   0x878E\n#define GL_OP_FLOOR_EXT                   0x878F\n#define GL_OP_ROUND_EXT                   0x8790\n#define GL_OP_EXP_BASE_2_EXT              0x8791\n#define GL_OP_LOG_BASE_2_EXT              0x8792\n#define GL_OP_POWER_EXT                   0x8793\n#define GL_OP_RECIP_EXT                   0x8794\n#define GL_OP_RECIP_SQRT_EXT              0x8795\n#define GL_OP_SUB_EXT                     0x8796\n#define GL_OP_CROSS_PRODUCT_EXT           0x8797\n#define GL_OP_MULTIPLY_MATRIX_EXT         0x8798\n#define GL_OP_MOV_EXT                     0x8799\n#define GL_OUTPUT_VERTEX_EXT              0x879A\n#define GL_OUTPUT_COLOR0_EXT              0x879B\n#define GL_OUTPUT_COLOR1_EXT              0x879C\n#define GL_OUTPUT_TEXTURE_COORD0_EXT      0x879D\n#define GL_OUTPUT_TEXTURE_COORD1_EXT      0x879E\n#define GL_OUTPUT_TEXTURE_COORD2_EXT      0x879F\n#define GL_OUTPUT_TEXTURE_COORD3_EXT      0x87A0\n#define GL_OUTPUT_TEXTURE_COORD4_EXT      0x87A1\n#define GL_OUTPUT_TEXTURE_COORD5_EXT      0x87A2\n#define GL_OUTPUT_TEXTURE_COORD6_EXT      0x87A3\n#define GL_OUTPUT_TEXTURE_COORD7_EXT      0x87A4\n#define GL_OUTPUT_TEXTURE_COORD8_EXT      0x87A5\n#define GL_OUTPUT_TEXTURE_COORD9_EXT      0x87A6\n#define GL_OUTPUT_TEXTURE_COORD10_EXT     0x87A7\n#define GL_OUTPUT_TEXTURE_COORD11_EXT     0x87A8\n#define GL_OUTPUT_TEXTURE_COORD12_EXT     0x87A9\n#define GL_OUTPUT_TEXTURE_COORD13_EXT     0x87AA\n#define GL_OUTPUT_TEXTURE_COORD14_EXT     0x87AB\n#define GL_OUTPUT_TEXTURE_COORD15_EXT     0x87AC\n#define GL_OUTPUT_TEXTURE_COORD16_EXT     0x87AD\n#define GL_OUTPUT_TEXTURE_COORD17_EXT     0x87AE\n#define GL_OUTPUT_TEXTURE_COORD18_EXT     0x87AF\n#define GL_OUTPUT_TEXTURE_COORD19_EXT     0x87B0\n#define GL_OUTPUT_TEXTURE_COORD20_EXT     0x87B1\n#define GL_OUTPUT_TEXTURE_COORD21_EXT     0x87B2\n#define GL_OUTPUT_TEXTURE_COORD22_EXT     0x87B3\n#define GL_OUTPUT_TEXTURE_COORD23_EXT     0x87B4\n#define GL_OUTPUT_TEXTURE_COORD24_EXT     0x87B5\n#define GL_OUTPUT_TEXTURE_COORD25_EXT     0x87B6\n#define GL_OUTPUT_TEXTURE_COORD26_EXT     0x87B7\n#define GL_OUTPUT_TEXTURE_COORD27_EXT     0x87B8\n#define GL_OUTPUT_TEXTURE_COORD28_EXT     0x87B9\n#define GL_OUTPUT_TEXTURE_COORD29_EXT     0x87BA\n#define GL_OUTPUT_TEXTURE_COORD30_EXT     0x87BB\n#define GL_OUTPUT_TEXTURE_COORD31_EXT     0x87BC\n#define GL_OUTPUT_FOG_EXT                 0x87BD\n#define GL_SCALAR_EXT                     0x87BE\n#define GL_VECTOR_EXT                     0x87BF\n#define GL_MATRIX_EXT                     0x87C0\n#define GL_VARIANT_EXT                    0x87C1\n#define GL_INVARIANT_EXT                  0x87C2\n#define GL_LOCAL_CONSTANT_EXT             0x87C3\n#define GL_LOCAL_EXT                      0x87C4\n#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5\n#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6\n#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7\n#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8\n#define GL_MAX_VERTEX_SHADER_LOCALS_EXT   0x87C9\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE\n#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF\n#define GL_VERTEX_SHADER_VARIANTS_EXT     0x87D0\n#define GL_VERTEX_SHADER_INVARIANTS_EXT   0x87D1\n#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2\n#define GL_VERTEX_SHADER_LOCALS_EXT       0x87D3\n#define GL_VERTEX_SHADER_OPTIMIZED_EXT    0x87D4\n#define GL_X_EXT                          0x87D5\n#define GL_Y_EXT                          0x87D6\n#define GL_Z_EXT                          0x87D7\n#define GL_W_EXT                          0x87D8\n#define GL_NEGATIVE_X_EXT                 0x87D9\n#define GL_NEGATIVE_Y_EXT                 0x87DA\n#define GL_NEGATIVE_Z_EXT                 0x87DB\n#define GL_NEGATIVE_W_EXT                 0x87DC\n#define GL_ZERO_EXT                       0x87DD\n#define GL_ONE_EXT                        0x87DE\n#define GL_NEGATIVE_ONE_EXT               0x87DF\n#define GL_NORMALIZED_RANGE_EXT           0x87E0\n#define GL_FULL_RANGE_EXT                 0x87E1\n#define GL_CURRENT_VERTEX_EXT             0x87E2\n#define GL_MVP_MATRIX_EXT                 0x87E3\n#define GL_VARIANT_VALUE_EXT              0x87E4\n#define GL_VARIANT_DATATYPE_EXT           0x87E5\n#define GL_VARIANT_ARRAY_STRIDE_EXT       0x87E6\n#define GL_VARIANT_ARRAY_TYPE_EXT         0x87E7\n#define GL_VARIANT_ARRAY_EXT              0x87E8\n#define GL_VARIANT_ARRAY_POINTER_EXT      0x87E9\n#define GL_INVARIANT_VALUE_EXT            0x87EA\n#define GL_INVARIANT_DATATYPE_EXT         0x87EB\n#define GL_LOCAL_CONSTANT_VALUE_EXT       0x87EC\n#define GL_LOCAL_CONSTANT_DATATYPE_EXT    0x87ED\ntypedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);\ntypedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);\ntypedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);\ntypedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);\ntypedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);\ntypedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);\ntypedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);\ntypedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\ntypedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\ntypedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\ntypedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\ntypedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);\ntypedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr);\ntypedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr);\ntypedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);\ntypedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);\ntypedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);\ntypedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);\ntypedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);\ntypedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);\ntypedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);\ntypedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);\ntypedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr);\ntypedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\ntypedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);\ntypedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);\ntypedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);\ntypedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);\ntypedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);\ntypedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);\ntypedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\ntypedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data);\ntypedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\ntypedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\ntypedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\ntypedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginVertexShaderEXT (void);\nGLAPI void APIENTRY glEndVertexShaderEXT (void);\nGLAPI void APIENTRY glBindVertexShaderEXT (GLuint id);\nGLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range);\nGLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id);\nGLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1);\nGLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2);\nGLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);\nGLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\nGLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\nGLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num);\nGLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num);\nGLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);\nGLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr);\nGLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr);\nGLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr);\nGLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr);\nGLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr);\nGLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr);\nGLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr);\nGLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr);\nGLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr);\nGLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr);\nGLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr);\nGLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id);\nGLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id);\nGLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value);\nGLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value);\nGLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value);\nGLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value);\nGLAPI GLuint APIENTRY glBindParameterEXT (GLenum value);\nGLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap);\nGLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);\nGLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data);\nGLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);\nGLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data);\nGLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);\nGLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data);\nGLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data);\nGLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data);\nGLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data);\nGLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data);\n#endif\n#endif /* GL_EXT_vertex_shader */\n\n#ifndef GL_EXT_vertex_weighting\n#define GL_EXT_vertex_weighting 1\n#define GL_MODELVIEW0_STACK_DEPTH_EXT     0x0BA3\n#define GL_MODELVIEW1_STACK_DEPTH_EXT     0x8502\n#define GL_MODELVIEW0_MATRIX_EXT          0x0BA6\n#define GL_MODELVIEW1_MATRIX_EXT          0x8506\n#define GL_VERTEX_WEIGHTING_EXT           0x8509\n#define GL_MODELVIEW0_EXT                 0x1700\n#define GL_MODELVIEW1_EXT                 0x850A\n#define GL_CURRENT_VERTEX_WEIGHT_EXT      0x850B\n#define GL_VERTEX_WEIGHT_ARRAY_EXT        0x850C\n#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT   0x850D\n#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT   0x850E\n#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F\n#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510\ntypedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);\ntypedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);\ntypedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight);\nGLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight);\nGLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer);\n#endif\n#endif /* GL_EXT_vertex_weighting */\n\n#ifndef GL_EXT_x11_sync_object\n#define GL_EXT_x11_sync_object 1\n#define GL_SYNC_X11_FENCE_EXT             0x90E1\ntypedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);\n#endif\n#endif /* GL_EXT_x11_sync_object */\n\n#ifndef GL_GREMEDY_frame_terminator\n#define GL_GREMEDY_frame_terminator 1\ntypedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFrameTerminatorGREMEDY (void);\n#endif\n#endif /* GL_GREMEDY_frame_terminator */\n\n#ifndef GL_GREMEDY_string_marker\n#define GL_GREMEDY_string_marker 1\ntypedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string);\n#endif\n#endif /* GL_GREMEDY_string_marker */\n\n#ifndef GL_HP_convolution_border_modes\n#define GL_HP_convolution_border_modes 1\n#define GL_IGNORE_BORDER_HP               0x8150\n#define GL_CONSTANT_BORDER_HP             0x8151\n#define GL_REPLICATE_BORDER_HP            0x8153\n#define GL_CONVOLUTION_BORDER_COLOR_HP    0x8154\n#endif /* GL_HP_convolution_border_modes */\n\n#ifndef GL_HP_image_transform\n#define GL_HP_image_transform 1\n#define GL_IMAGE_SCALE_X_HP               0x8155\n#define GL_IMAGE_SCALE_Y_HP               0x8156\n#define GL_IMAGE_TRANSLATE_X_HP           0x8157\n#define GL_IMAGE_TRANSLATE_Y_HP           0x8158\n#define GL_IMAGE_ROTATE_ANGLE_HP          0x8159\n#define GL_IMAGE_ROTATE_ORIGIN_X_HP       0x815A\n#define GL_IMAGE_ROTATE_ORIGIN_Y_HP       0x815B\n#define GL_IMAGE_MAG_FILTER_HP            0x815C\n#define GL_IMAGE_MIN_FILTER_HP            0x815D\n#define GL_IMAGE_CUBIC_WEIGHT_HP          0x815E\n#define GL_CUBIC_HP                       0x815F\n#define GL_AVERAGE_HP                     0x8160\n#define GL_IMAGE_TRANSFORM_2D_HP          0x8161\n#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162\n#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163\ntypedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param);\nGLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_HP_image_transform */\n\n#ifndef GL_HP_occlusion_test\n#define GL_HP_occlusion_test 1\n#define GL_OCCLUSION_TEST_HP              0x8165\n#define GL_OCCLUSION_TEST_RESULT_HP       0x8166\n#endif /* GL_HP_occlusion_test */\n\n#ifndef GL_HP_texture_lighting\n#define GL_HP_texture_lighting 1\n#define GL_TEXTURE_LIGHTING_MODE_HP       0x8167\n#define GL_TEXTURE_POST_SPECULAR_HP       0x8168\n#define GL_TEXTURE_PRE_SPECULAR_HP        0x8169\n#endif /* GL_HP_texture_lighting */\n\n#ifndef GL_IBM_cull_vertex\n#define GL_IBM_cull_vertex 1\n#define GL_CULL_VERTEX_IBM                103050\n#endif /* GL_IBM_cull_vertex */\n\n#ifndef GL_IBM_multimode_draw_arrays\n#define GL_IBM_multimode_draw_arrays 1\ntypedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);\ntypedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);\nGLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride);\n#endif\n#endif /* GL_IBM_multimode_draw_arrays */\n\n#ifndef GL_IBM_rasterpos_clip\n#define GL_IBM_rasterpos_clip 1\n#define GL_RASTER_POSITION_UNCLIPPED_IBM  0x19262\n#endif /* GL_IBM_rasterpos_clip */\n\n#ifndef GL_IBM_static_data\n#define GL_IBM_static_data 1\n#define GL_ALL_STATIC_DATA_IBM            103060\n#define GL_STATIC_VERTEX_ARRAY_IBM        103061\ntypedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFlushStaticDataIBM (GLenum target);\n#endif\n#endif /* GL_IBM_static_data */\n\n#ifndef GL_IBM_texture_mirrored_repeat\n#define GL_IBM_texture_mirrored_repeat 1\n#define GL_MIRRORED_REPEAT_IBM            0x8370\n#endif /* GL_IBM_texture_mirrored_repeat */\n\n#ifndef GL_IBM_vertex_array_lists\n#define GL_IBM_vertex_array_lists 1\n#define GL_VERTEX_ARRAY_LIST_IBM          103070\n#define GL_NORMAL_ARRAY_LIST_IBM          103071\n#define GL_COLOR_ARRAY_LIST_IBM           103072\n#define GL_INDEX_ARRAY_LIST_IBM           103073\n#define GL_TEXTURE_COORD_ARRAY_LIST_IBM   103074\n#define GL_EDGE_FLAG_ARRAY_LIST_IBM       103075\n#define GL_FOG_COORDINATE_ARRAY_LIST_IBM  103076\n#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077\n#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM   103080\n#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM   103081\n#define GL_COLOR_ARRAY_LIST_STRIDE_IBM    103082\n#define GL_INDEX_ARRAY_LIST_STRIDE_IBM    103083\n#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084\n#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085\n#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086\n#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087\ntypedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\ntypedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride);\nGLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\nGLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride);\n#endif\n#endif /* GL_IBM_vertex_array_lists */\n\n#ifndef GL_INGR_blend_func_separate\n#define GL_INGR_blend_func_separate 1\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\n#endif\n#endif /* GL_INGR_blend_func_separate */\n\n#ifndef GL_INGR_color_clamp\n#define GL_INGR_color_clamp 1\n#define GL_RED_MIN_CLAMP_INGR             0x8560\n#define GL_GREEN_MIN_CLAMP_INGR           0x8561\n#define GL_BLUE_MIN_CLAMP_INGR            0x8562\n#define GL_ALPHA_MIN_CLAMP_INGR           0x8563\n#define GL_RED_MAX_CLAMP_INGR             0x8564\n#define GL_GREEN_MAX_CLAMP_INGR           0x8565\n#define GL_BLUE_MAX_CLAMP_INGR            0x8566\n#define GL_ALPHA_MAX_CLAMP_INGR           0x8567\n#endif /* GL_INGR_color_clamp */\n\n#ifndef GL_INGR_interlace_read\n#define GL_INGR_interlace_read 1\n#define GL_INTERLACE_READ_INGR            0x8568\n#endif /* GL_INGR_interlace_read */\n\n#ifndef GL_INTEL_fragment_shader_ordering\n#define GL_INTEL_fragment_shader_ordering 1\n#endif /* GL_INTEL_fragment_shader_ordering */\n\n#ifndef GL_INTEL_map_texture\n#define GL_INTEL_map_texture 1\n#define GL_TEXTURE_MEMORY_LAYOUT_INTEL    0x83FF\n#define GL_LAYOUT_DEFAULT_INTEL           0\n#define GL_LAYOUT_LINEAR_INTEL            1\n#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2\ntypedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture);\ntypedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level);\ntypedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSyncTextureINTEL (GLuint texture);\nGLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level);\nGLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout);\n#endif\n#endif /* GL_INTEL_map_texture */\n\n#ifndef GL_INTEL_parallel_arrays\n#define GL_INTEL_parallel_arrays 1\n#define GL_PARALLEL_ARRAYS_INTEL          0x83F4\n#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5\n#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6\n#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7\n#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8\ntypedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer);\ntypedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer);\ntypedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer);\ntypedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer);\nGLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer);\nGLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer);\nGLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer);\n#endif\n#endif /* GL_INTEL_parallel_arrays */\n\n#ifndef GL_INTEL_performance_query\n#define GL_INTEL_performance_query 1\n#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000\n#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001\n#define GL_PERFQUERY_WAIT_INTEL           0x83FB\n#define GL_PERFQUERY_FLUSH_INTEL          0x83FA\n#define GL_PERFQUERY_DONOT_FLUSH_INTEL    0x83F9\n#define GL_PERFQUERY_COUNTER_EVENT_INTEL  0x94F0\n#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1\n#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2\n#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3\n#define GL_PERFQUERY_COUNTER_RAW_INTEL    0x94F4\n#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5\n#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8\n#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9\n#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA\n#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB\n#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC\n#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD\n#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE\n#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF\n#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500\ntypedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle);\ntypedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle);\ntypedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle);\ntypedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle);\ntypedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId);\ntypedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId);\ntypedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);\ntypedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);\ntypedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId);\ntypedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle);\nGLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle);\nGLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle);\nGLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle);\nGLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId);\nGLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId);\nGLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);\nGLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);\nGLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId);\nGLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);\n#endif\n#endif /* GL_INTEL_performance_query */\n\n#ifndef GL_MESAX_texture_stack\n#define GL_MESAX_texture_stack 1\n#define GL_TEXTURE_1D_STACK_MESAX         0x8759\n#define GL_TEXTURE_2D_STACK_MESAX         0x875A\n#define GL_PROXY_TEXTURE_1D_STACK_MESAX   0x875B\n#define GL_PROXY_TEXTURE_2D_STACK_MESAX   0x875C\n#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D\n#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E\n#endif /* GL_MESAX_texture_stack */\n\n#ifndef GL_MESA_pack_invert\n#define GL_MESA_pack_invert 1\n#define GL_PACK_INVERT_MESA               0x8758\n#endif /* GL_MESA_pack_invert */\n\n#ifndef GL_MESA_resize_buffers\n#define GL_MESA_resize_buffers 1\ntypedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glResizeBuffersMESA (void);\n#endif\n#endif /* GL_MESA_resize_buffers */\n\n#ifndef GL_MESA_window_pos\n#define GL_MESA_window_pos 1\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y);\nGLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y);\nGLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y);\nGLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v);\nGLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y);\nGLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v);\nGLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v);\nGLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v);\nGLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v);\nGLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v);\nGLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v);\nGLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v);\n#endif\n#endif /* GL_MESA_window_pos */\n\n#ifndef GL_MESA_ycbcr_texture\n#define GL_MESA_ycbcr_texture 1\n#define GL_UNSIGNED_SHORT_8_8_MESA        0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_MESA    0x85BB\n#define GL_YCBCR_MESA                     0x8757\n#endif /* GL_MESA_ycbcr_texture */\n\n#ifndef GL_NVX_conditional_render\n#define GL_NVX_conditional_render 1\ntypedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id);\nGLAPI void APIENTRY glEndConditionalRenderNVX (void);\n#endif\n#endif /* GL_NVX_conditional_render */\n\n#ifndef GL_NVX_gpu_memory_info\n#define GL_NVX_gpu_memory_info 1\n#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047\n#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048\n#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049\n#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A\n#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B\n#endif /* GL_NVX_gpu_memory_info */\n\n#ifndef GL_NV_bindless_multi_draw_indirect\n#define GL_NV_bindless_multi_draw_indirect 1\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\nGLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\n#endif\n#endif /* GL_NV_bindless_multi_draw_indirect */\n\n#ifndef GL_NV_bindless_multi_draw_indirect_count\n#define GL_NV_bindless_multi_draw_indirect_count 1\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\nGLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\n#endif\n#endif /* GL_NV_bindless_multi_draw_indirect_count */\n\n#ifndef GL_NV_bindless_texture\n#define GL_NV_bindless_texture 1\ntypedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);\ntypedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);\ntypedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\ntypedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);\ntypedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\ntypedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);\ntypedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);\ntypedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);\ntypedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values);\ntypedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\ntypedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture);\nGLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler);\nGLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle);\nGLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle);\nGLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\nGLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access);\nGLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle);\nGLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value);\nGLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value);\nGLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value);\nGLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values);\nGLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle);\nGLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle);\n#endif\n#endif /* GL_NV_bindless_texture */\n\n#ifndef GL_NV_blend_equation_advanced\n#define GL_NV_blend_equation_advanced 1\n#define GL_BLEND_OVERLAP_NV               0x9281\n#define GL_BLEND_PREMULTIPLIED_SRC_NV     0x9280\n#define GL_BLUE_NV                        0x1905\n#define GL_COLORBURN_NV                   0x929A\n#define GL_COLORDODGE_NV                  0x9299\n#define GL_CONJOINT_NV                    0x9284\n#define GL_CONTRAST_NV                    0x92A1\n#define GL_DARKEN_NV                      0x9297\n#define GL_DIFFERENCE_NV                  0x929E\n#define GL_DISJOINT_NV                    0x9283\n#define GL_DST_ATOP_NV                    0x928F\n#define GL_DST_IN_NV                      0x928B\n#define GL_DST_NV                         0x9287\n#define GL_DST_OUT_NV                     0x928D\n#define GL_DST_OVER_NV                    0x9289\n#define GL_EXCLUSION_NV                   0x92A0\n#define GL_GREEN_NV                       0x1904\n#define GL_HARDLIGHT_NV                   0x929B\n#define GL_HARDMIX_NV                     0x92A9\n#define GL_HSL_COLOR_NV                   0x92AF\n#define GL_HSL_HUE_NV                     0x92AD\n#define GL_HSL_LUMINOSITY_NV              0x92B0\n#define GL_HSL_SATURATION_NV              0x92AE\n#define GL_INVERT_OVG_NV                  0x92B4\n#define GL_INVERT_RGB_NV                  0x92A3\n#define GL_LIGHTEN_NV                     0x9298\n#define GL_LINEARBURN_NV                  0x92A5\n#define GL_LINEARDODGE_NV                 0x92A4\n#define GL_LINEARLIGHT_NV                 0x92A7\n#define GL_MINUS_CLAMPED_NV               0x92B3\n#define GL_MINUS_NV                       0x929F\n#define GL_MULTIPLY_NV                    0x9294\n#define GL_OVERLAY_NV                     0x9296\n#define GL_PINLIGHT_NV                    0x92A8\n#define GL_PLUS_CLAMPED_ALPHA_NV          0x92B2\n#define GL_PLUS_CLAMPED_NV                0x92B1\n#define GL_PLUS_DARKER_NV                 0x9292\n#define GL_PLUS_NV                        0x9291\n#define GL_RED_NV                         0x1903\n#define GL_SCREEN_NV                      0x9295\n#define GL_SOFTLIGHT_NV                   0x929C\n#define GL_SRC_ATOP_NV                    0x928E\n#define GL_SRC_IN_NV                      0x928A\n#define GL_SRC_NV                         0x9286\n#define GL_SRC_OUT_NV                     0x928C\n#define GL_SRC_OVER_NV                    0x9288\n#define GL_UNCORRELATED_NV                0x9282\n#define GL_VIVIDLIGHT_NV                  0x92A6\n#define GL_XOR_NV                         0x1506\ntypedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value);\ntypedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value);\nGLAPI void APIENTRY glBlendBarrierNV (void);\n#endif\n#endif /* GL_NV_blend_equation_advanced */\n\n#ifndef GL_NV_blend_equation_advanced_coherent\n#define GL_NV_blend_equation_advanced_coherent 1\n#define GL_BLEND_ADVANCED_COHERENT_NV     0x9285\n#endif /* GL_NV_blend_equation_advanced_coherent */\n\n#ifndef GL_NV_blend_square\n#define GL_NV_blend_square 1\n#endif /* GL_NV_blend_square */\n\n#ifndef GL_NV_compute_program5\n#define GL_NV_compute_program5 1\n#define GL_COMPUTE_PROGRAM_NV             0x90FB\n#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC\n#endif /* GL_NV_compute_program5 */\n\n#ifndef GL_NV_conditional_render\n#define GL_NV_conditional_render 1\n#define GL_QUERY_WAIT_NV                  0x8E13\n#define GL_QUERY_NO_WAIT_NV               0x8E14\n#define GL_QUERY_BY_REGION_WAIT_NV        0x8E15\n#define GL_QUERY_BY_REGION_NO_WAIT_NV     0x8E16\ntypedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);\ntypedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode);\nGLAPI void APIENTRY glEndConditionalRenderNV (void);\n#endif\n#endif /* GL_NV_conditional_render */\n\n#ifndef GL_NV_copy_depth_to_color\n#define GL_NV_copy_depth_to_color 1\n#define GL_DEPTH_STENCIL_TO_RGBA_NV       0x886E\n#define GL_DEPTH_STENCIL_TO_BGRA_NV       0x886F\n#endif /* GL_NV_copy_depth_to_color */\n\n#ifndef GL_NV_copy_image\n#define GL_NV_copy_image 1\ntypedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#endif\n#endif /* GL_NV_copy_image */\n\n#ifndef GL_NV_deep_texture3D\n#define GL_NV_deep_texture3D 1\n#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0\n#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV   0x90D1\n#endif /* GL_NV_deep_texture3D */\n\n#ifndef GL_NV_depth_buffer_float\n#define GL_NV_depth_buffer_float 1\n#define GL_DEPTH_COMPONENT32F_NV          0x8DAB\n#define GL_DEPTH32F_STENCIL8_NV           0x8DAC\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD\n#define GL_DEPTH_BUFFER_FLOAT_MODE_NV     0x8DAF\ntypedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);\ntypedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);\ntypedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar);\nGLAPI void APIENTRY glClearDepthdNV (GLdouble depth);\nGLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax);\n#endif\n#endif /* GL_NV_depth_buffer_float */\n\n#ifndef GL_NV_depth_clamp\n#define GL_NV_depth_clamp 1\n#define GL_DEPTH_CLAMP_NV                 0x864F\n#endif /* GL_NV_depth_clamp */\n\n#ifndef GL_NV_draw_texture\n#define GL_NV_draw_texture 1\ntypedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1);\n#endif\n#endif /* GL_NV_draw_texture */\n\n#ifndef GL_NV_evaluators\n#define GL_NV_evaluators 1\n#define GL_EVAL_2D_NV                     0x86C0\n#define GL_EVAL_TRIANGULAR_2D_NV          0x86C1\n#define GL_MAP_TESSELLATION_NV            0x86C2\n#define GL_MAP_ATTRIB_U_ORDER_NV          0x86C3\n#define GL_MAP_ATTRIB_V_ORDER_NV          0x86C4\n#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5\n#define GL_EVAL_VERTEX_ATTRIB0_NV         0x86C6\n#define GL_EVAL_VERTEX_ATTRIB1_NV         0x86C7\n#define GL_EVAL_VERTEX_ATTRIB2_NV         0x86C8\n#define GL_EVAL_VERTEX_ATTRIB3_NV         0x86C9\n#define GL_EVAL_VERTEX_ATTRIB4_NV         0x86CA\n#define GL_EVAL_VERTEX_ATTRIB5_NV         0x86CB\n#define GL_EVAL_VERTEX_ATTRIB6_NV         0x86CC\n#define GL_EVAL_VERTEX_ATTRIB7_NV         0x86CD\n#define GL_EVAL_VERTEX_ATTRIB8_NV         0x86CE\n#define GL_EVAL_VERTEX_ATTRIB9_NV         0x86CF\n#define GL_EVAL_VERTEX_ATTRIB10_NV        0x86D0\n#define GL_EVAL_VERTEX_ATTRIB11_NV        0x86D1\n#define GL_EVAL_VERTEX_ATTRIB12_NV        0x86D2\n#define GL_EVAL_VERTEX_ATTRIB13_NV        0x86D3\n#define GL_EVAL_VERTEX_ATTRIB14_NV        0x86D4\n#define GL_EVAL_VERTEX_ATTRIB15_NV        0x86D5\n#define GL_MAX_MAP_TESSELLATION_NV        0x86D6\n#define GL_MAX_RATIONAL_EVAL_ORDER_NV     0x86D7\ntypedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points);\ntypedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points);\ntypedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points);\nGLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points);\nGLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode);\n#endif\n#endif /* GL_NV_evaluators */\n\n#ifndef GL_NV_explicit_multisample\n#define GL_NV_explicit_multisample 1\n#define GL_SAMPLE_POSITION_NV             0x8E50\n#define GL_SAMPLE_MASK_NV                 0x8E51\n#define GL_SAMPLE_MASK_VALUE_NV           0x8E52\n#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53\n#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54\n#define GL_TEXTURE_RENDERBUFFER_NV        0x8E55\n#define GL_SAMPLER_RENDERBUFFER_NV        0x8E56\n#define GL_INT_SAMPLER_RENDERBUFFER_NV    0x8E57\n#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58\n#define GL_MAX_SAMPLE_MASK_WORDS_NV       0x8E59\ntypedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val);\ntypedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);\ntypedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val);\nGLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask);\nGLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer);\n#endif\n#endif /* GL_NV_explicit_multisample */\n\n#ifndef GL_NV_fence\n#define GL_NV_fence 1\n#define GL_ALL_COMPLETED_NV               0x84F2\n#define GL_FENCE_STATUS_NV                0x84F3\n#define GL_FENCE_CONDITION_NV             0x84F4\ntypedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);\ntypedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);\ntypedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);\ntypedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);\ntypedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);\ntypedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);\nGLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);\nGLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence);\nGLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence);\nGLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);\nGLAPI void APIENTRY glFinishFenceNV (GLuint fence);\nGLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition);\n#endif\n#endif /* GL_NV_fence */\n\n#ifndef GL_NV_float_buffer\n#define GL_NV_float_buffer 1\n#define GL_FLOAT_R_NV                     0x8880\n#define GL_FLOAT_RG_NV                    0x8881\n#define GL_FLOAT_RGB_NV                   0x8882\n#define GL_FLOAT_RGBA_NV                  0x8883\n#define GL_FLOAT_R16_NV                   0x8884\n#define GL_FLOAT_R32_NV                   0x8885\n#define GL_FLOAT_RG16_NV                  0x8886\n#define GL_FLOAT_RG32_NV                  0x8887\n#define GL_FLOAT_RGB16_NV                 0x8888\n#define GL_FLOAT_RGB32_NV                 0x8889\n#define GL_FLOAT_RGBA16_NV                0x888A\n#define GL_FLOAT_RGBA32_NV                0x888B\n#define GL_TEXTURE_FLOAT_COMPONENTS_NV    0x888C\n#define GL_FLOAT_CLEAR_COLOR_VALUE_NV     0x888D\n#define GL_FLOAT_RGBA_MODE_NV             0x888E\n#endif /* GL_NV_float_buffer */\n\n#ifndef GL_NV_fog_distance\n#define GL_NV_fog_distance 1\n#define GL_FOG_DISTANCE_MODE_NV           0x855A\n#define GL_EYE_RADIAL_NV                  0x855B\n#define GL_EYE_PLANE_ABSOLUTE_NV          0x855C\n#endif /* GL_NV_fog_distance */\n\n#ifndef GL_NV_fragment_program\n#define GL_NV_fragment_program 1\n#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868\n#define GL_FRAGMENT_PROGRAM_NV            0x8870\n#define GL_MAX_TEXTURE_COORDS_NV          0x8871\n#define GL_MAX_TEXTURE_IMAGE_UNITS_NV     0x8872\n#define GL_FRAGMENT_PROGRAM_BINDING_NV    0x8873\n#define GL_PROGRAM_ERROR_STRING_NV        0x8874\ntypedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);\nGLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);\nGLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);\nGLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);\n#endif\n#endif /* GL_NV_fragment_program */\n\n#ifndef GL_NV_fragment_program2\n#define GL_NV_fragment_program2 1\n#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4\n#define GL_MAX_PROGRAM_CALL_DEPTH_NV      0x88F5\n#define GL_MAX_PROGRAM_IF_DEPTH_NV        0x88F6\n#define GL_MAX_PROGRAM_LOOP_DEPTH_NV      0x88F7\n#define GL_MAX_PROGRAM_LOOP_COUNT_NV      0x88F8\n#endif /* GL_NV_fragment_program2 */\n\n#ifndef GL_NV_fragment_program4\n#define GL_NV_fragment_program4 1\n#endif /* GL_NV_fragment_program4 */\n\n#ifndef GL_NV_fragment_program_option\n#define GL_NV_fragment_program_option 1\n#endif /* GL_NV_fragment_program_option */\n\n#ifndef GL_NV_framebuffer_multisample_coverage\n#define GL_NV_framebuffer_multisample_coverage 1\n#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB\n#define GL_RENDERBUFFER_COLOR_SAMPLES_NV  0x8E10\n#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11\n#define GL_MULTISAMPLE_COVERAGE_MODES_NV  0x8E12\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\n#endif\n#endif /* GL_NV_framebuffer_multisample_coverage */\n\n#ifndef GL_NV_geometry_program4\n#define GL_NV_geometry_program4 1\n#define GL_GEOMETRY_PROGRAM_NV            0x8C26\n#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27\n#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28\ntypedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit);\nGLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level);\nGLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\n#endif\n#endif /* GL_NV_geometry_program4 */\n\n#ifndef GL_NV_geometry_shader4\n#define GL_NV_geometry_shader4 1\n#endif /* GL_NV_geometry_shader4 */\n\n#ifndef GL_NV_gpu_program4\n#define GL_NV_gpu_program4 1\n#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV    0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV    0x8905\n#define GL_PROGRAM_ATTRIB_COMPONENTS_NV   0x8906\n#define GL_PROGRAM_RESULT_COMPONENTS_NV   0x8907\n#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908\n#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909\n#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5\n#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params);\nGLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);\nGLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nGLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);\nGLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);\nGLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params);\nGLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params);\nGLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nGLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params);\nGLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params);\nGLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params);\nGLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params);\nGLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params);\nGLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params);\n#endif\n#endif /* GL_NV_gpu_program4 */\n\n#ifndef GL_NV_gpu_program5\n#define GL_NV_gpu_program5 1\n#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C\n#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F\n#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44\n#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV  0x8F45\ntypedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params);\nGLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param);\n#endif\n#endif /* GL_NV_gpu_program5 */\n\n#ifndef GL_NV_gpu_program5_mem_extended\n#define GL_NV_gpu_program5_mem_extended 1\n#endif /* GL_NV_gpu_program5_mem_extended */\n\n#ifndef GL_NV_gpu_shader5\n#define GL_NV_gpu_shader5 1\n#endif /* GL_NV_gpu_shader5 */\n\n#ifndef GL_NV_half_float\n#define GL_NV_half_float 1\ntypedef unsigned short GLhalfNV;\n#define GL_HALF_FLOAT_NV                  0x140B\ntypedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);\ntypedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);\ntypedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);\ntypedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);\ntypedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);\ntypedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);\ntypedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);\ntypedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);\ntypedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);\ntypedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);\ntypedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);\ntypedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);\ntypedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);\ntypedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y);\nGLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z);\nGLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);\nGLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);\nGLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);\nGLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);\nGLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s);\nGLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t);\nGLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r);\nGLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);\nGLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s);\nGLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v);\nGLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t);\nGLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v);\nGLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);\nGLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v);\nGLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);\nGLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v);\nGLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog);\nGLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog);\nGLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue);\nGLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v);\nGLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight);\nGLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight);\nGLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x);\nGLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y);\nGLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);\nGLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);\nGLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v);\nGLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v);\n#endif\n#endif /* GL_NV_half_float */\n\n#ifndef GL_NV_light_max_exponent\n#define GL_NV_light_max_exponent 1\n#define GL_MAX_SHININESS_NV               0x8504\n#define GL_MAX_SPOT_EXPONENT_NV           0x8505\n#endif /* GL_NV_light_max_exponent */\n\n#ifndef GL_NV_multisample_coverage\n#define GL_NV_multisample_coverage 1\n#define GL_COLOR_SAMPLES_NV               0x8E20\n#endif /* GL_NV_multisample_coverage */\n\n#ifndef GL_NV_multisample_filter_hint\n#define GL_NV_multisample_filter_hint 1\n#define GL_MULTISAMPLE_FILTER_HINT_NV     0x8534\n#endif /* GL_NV_multisample_filter_hint */\n\n#ifndef GL_NV_occlusion_query\n#define GL_NV_occlusion_query 1\n#define GL_PIXEL_COUNTER_BITS_NV          0x8864\n#define GL_CURRENT_OCCLUSION_QUERY_ID_NV  0x8865\n#define GL_PIXEL_COUNT_NV                 0x8866\n#define GL_PIXEL_COUNT_AVAILABLE_NV       0x8867\ntypedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);\ntypedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);\ntypedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);\ntypedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids);\nGLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids);\nGLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id);\nGLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id);\nGLAPI void APIENTRY glEndOcclusionQueryNV (void);\nGLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params);\n#endif\n#endif /* GL_NV_occlusion_query */\n\n#ifndef GL_NV_packed_depth_stencil\n#define GL_NV_packed_depth_stencil 1\n#define GL_DEPTH_STENCIL_NV               0x84F9\n#define GL_UNSIGNED_INT_24_8_NV           0x84FA\n#endif /* GL_NV_packed_depth_stencil */\n\n#ifndef GL_NV_parameter_buffer_object\n#define GL_NV_parameter_buffer_object 1\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1\n#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2\n#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3\n#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4\ntypedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params);\ntypedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params);\nGLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params);\nGLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params);\n#endif\n#endif /* GL_NV_parameter_buffer_object */\n\n#ifndef GL_NV_parameter_buffer_object2\n#define GL_NV_parameter_buffer_object2 1\n#endif /* GL_NV_parameter_buffer_object2 */\n\n#ifndef GL_NV_path_rendering\n#define GL_NV_path_rendering 1\n#define GL_PATH_FORMAT_SVG_NV             0x9070\n#define GL_PATH_FORMAT_PS_NV              0x9071\n#define GL_STANDARD_FONT_NAME_NV          0x9072\n#define GL_SYSTEM_FONT_NAME_NV            0x9073\n#define GL_FILE_NAME_NV                   0x9074\n#define GL_PATH_STROKE_WIDTH_NV           0x9075\n#define GL_PATH_END_CAPS_NV               0x9076\n#define GL_PATH_INITIAL_END_CAP_NV        0x9077\n#define GL_PATH_TERMINAL_END_CAP_NV       0x9078\n#define GL_PATH_JOIN_STYLE_NV             0x9079\n#define GL_PATH_MITER_LIMIT_NV            0x907A\n#define GL_PATH_DASH_CAPS_NV              0x907B\n#define GL_PATH_INITIAL_DASH_CAP_NV       0x907C\n#define GL_PATH_TERMINAL_DASH_CAP_NV      0x907D\n#define GL_PATH_DASH_OFFSET_NV            0x907E\n#define GL_PATH_CLIENT_LENGTH_NV          0x907F\n#define GL_PATH_FILL_MODE_NV              0x9080\n#define GL_PATH_FILL_MASK_NV              0x9081\n#define GL_PATH_FILL_COVER_MODE_NV        0x9082\n#define GL_PATH_STROKE_COVER_MODE_NV      0x9083\n#define GL_PATH_STROKE_MASK_NV            0x9084\n#define GL_COUNT_UP_NV                    0x9088\n#define GL_COUNT_DOWN_NV                  0x9089\n#define GL_PATH_OBJECT_BOUNDING_BOX_NV    0x908A\n#define GL_CONVEX_HULL_NV                 0x908B\n#define GL_BOUNDING_BOX_NV                0x908D\n#define GL_TRANSLATE_X_NV                 0x908E\n#define GL_TRANSLATE_Y_NV                 0x908F\n#define GL_TRANSLATE_2D_NV                0x9090\n#define GL_TRANSLATE_3D_NV                0x9091\n#define GL_AFFINE_2D_NV                   0x9092\n#define GL_AFFINE_3D_NV                   0x9094\n#define GL_TRANSPOSE_AFFINE_2D_NV         0x9096\n#define GL_TRANSPOSE_AFFINE_3D_NV         0x9098\n#define GL_UTF8_NV                        0x909A\n#define GL_UTF16_NV                       0x909B\n#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C\n#define GL_PATH_COMMAND_COUNT_NV          0x909D\n#define GL_PATH_COORD_COUNT_NV            0x909E\n#define GL_PATH_DASH_ARRAY_COUNT_NV       0x909F\n#define GL_PATH_COMPUTED_LENGTH_NV        0x90A0\n#define GL_PATH_FILL_BOUNDING_BOX_NV      0x90A1\n#define GL_PATH_STROKE_BOUNDING_BOX_NV    0x90A2\n#define GL_SQUARE_NV                      0x90A3\n#define GL_ROUND_NV                       0x90A4\n#define GL_TRIANGULAR_NV                  0x90A5\n#define GL_BEVEL_NV                       0x90A6\n#define GL_MITER_REVERT_NV                0x90A7\n#define GL_MITER_TRUNCATE_NV              0x90A8\n#define GL_SKIP_MISSING_GLYPH_NV          0x90A9\n#define GL_USE_MISSING_GLYPH_NV           0x90AA\n#define GL_PATH_ERROR_POSITION_NV         0x90AB\n#define GL_PATH_FOG_GEN_MODE_NV           0x90AC\n#define GL_ACCUM_ADJACENT_PAIRS_NV        0x90AD\n#define GL_ADJACENT_PAIRS_NV              0x90AE\n#define GL_FIRST_TO_REST_NV               0x90AF\n#define GL_PATH_GEN_MODE_NV               0x90B0\n#define GL_PATH_GEN_COEFF_NV              0x90B1\n#define GL_PATH_GEN_COLOR_FORMAT_NV       0x90B2\n#define GL_PATH_GEN_COMPONENTS_NV         0x90B3\n#define GL_PATH_STENCIL_FUNC_NV           0x90B7\n#define GL_PATH_STENCIL_REF_NV            0x90B8\n#define GL_PATH_STENCIL_VALUE_MASK_NV     0x90B9\n#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD\n#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE\n#define GL_PATH_COVER_DEPTH_FUNC_NV       0x90BF\n#define GL_PATH_DASH_OFFSET_RESET_NV      0x90B4\n#define GL_MOVE_TO_RESETS_NV              0x90B5\n#define GL_MOVE_TO_CONTINUES_NV           0x90B6\n#define GL_CLOSE_PATH_NV                  0x00\n#define GL_MOVE_TO_NV                     0x02\n#define GL_RELATIVE_MOVE_TO_NV            0x03\n#define GL_LINE_TO_NV                     0x04\n#define GL_RELATIVE_LINE_TO_NV            0x05\n#define GL_HORIZONTAL_LINE_TO_NV          0x06\n#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07\n#define GL_VERTICAL_LINE_TO_NV            0x08\n#define GL_RELATIVE_VERTICAL_LINE_TO_NV   0x09\n#define GL_QUADRATIC_CURVE_TO_NV          0x0A\n#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B\n#define GL_CUBIC_CURVE_TO_NV              0x0C\n#define GL_RELATIVE_CUBIC_CURVE_TO_NV     0x0D\n#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV   0x0E\n#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F\n#define GL_SMOOTH_CUBIC_CURVE_TO_NV       0x10\n#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11\n#define GL_SMALL_CCW_ARC_TO_NV            0x12\n#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV   0x13\n#define GL_SMALL_CW_ARC_TO_NV             0x14\n#define GL_RELATIVE_SMALL_CW_ARC_TO_NV    0x15\n#define GL_LARGE_CCW_ARC_TO_NV            0x16\n#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV   0x17\n#define GL_LARGE_CW_ARC_TO_NV             0x18\n#define GL_RELATIVE_LARGE_CW_ARC_TO_NV    0x19\n#define GL_RESTART_PATH_NV                0xF0\n#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV    0xF2\n#define GL_DUP_LAST_CUBIC_CURVE_TO_NV     0xF4\n#define GL_RECT_NV                        0xF6\n#define GL_CIRCULAR_CCW_ARC_TO_NV         0xF8\n#define GL_CIRCULAR_CW_ARC_TO_NV          0xFA\n#define GL_CIRCULAR_TANGENT_ARC_TO_NV     0xFC\n#define GL_ARC_TO_NV                      0xFE\n#define GL_RELATIVE_ARC_TO_NV             0xFF\n#define GL_BOLD_BIT_NV                    0x01\n#define GL_ITALIC_BIT_NV                  0x02\n#define GL_GLYPH_WIDTH_BIT_NV             0x01\n#define GL_GLYPH_HEIGHT_BIT_NV            0x02\n#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04\n#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08\n#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10\n#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20\n#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40\n#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80\n#define GL_GLYPH_HAS_KERNING_BIT_NV       0x100\n#define GL_FONT_X_MIN_BOUNDS_BIT_NV       0x00010000\n#define GL_FONT_Y_MIN_BOUNDS_BIT_NV       0x00020000\n#define GL_FONT_X_MAX_BOUNDS_BIT_NV       0x00040000\n#define GL_FONT_Y_MAX_BOUNDS_BIT_NV       0x00080000\n#define GL_FONT_UNITS_PER_EM_BIT_NV       0x00100000\n#define GL_FONT_ASCENDER_BIT_NV           0x00200000\n#define GL_FONT_DESCENDER_BIT_NV          0x00400000\n#define GL_FONT_HEIGHT_BIT_NV             0x00800000\n#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV  0x01000000\n#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000\n#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000\n#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000\n#define GL_FONT_HAS_KERNING_BIT_NV        0x10000000\n#define GL_PRIMARY_COLOR_NV               0x852C\n#define GL_SECONDARY_COLOR_NV             0x852D\n#define GL_ROUNDED_RECT_NV                0xE8\n#define GL_RELATIVE_ROUNDED_RECT_NV       0xE9\n#define GL_ROUNDED_RECT2_NV               0xEA\n#define GL_RELATIVE_ROUNDED_RECT2_NV      0xEB\n#define GL_ROUNDED_RECT4_NV               0xEC\n#define GL_RELATIVE_ROUNDED_RECT4_NV      0xED\n#define GL_ROUNDED_RECT8_NV               0xEE\n#define GL_RELATIVE_ROUNDED_RECT8_NV      0xEF\n#define GL_RELATIVE_RECT_NV               0xF7\n#define GL_FONT_GLYPHS_AVAILABLE_NV       0x9368\n#define GL_FONT_TARGET_UNAVAILABLE_NV     0x9369\n#define GL_FONT_UNAVAILABLE_NV            0x936A\n#define GL_FONT_UNINTELLIGIBLE_NV         0x936B\n#define GL_CONIC_CURVE_TO_NV              0x1A\n#define GL_RELATIVE_CONIC_CURVE_TO_NV     0x1B\n#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV  0x20000000\n#define GL_STANDARD_FONT_FORMAT_NV        0x936C\n#define GL_2_BYTES_NV                     0x1407\n#define GL_3_BYTES_NV                     0x1408\n#define GL_4_BYTES_NV                     0x1409\n#define GL_EYE_LINEAR_NV                  0x2400\n#define GL_OBJECT_LINEAR_NV               0x2401\n#define GL_CONSTANT_NV                    0x8576\n#define GL_PATH_PROJECTION_NV             0x1701\n#define GL_PATH_MODELVIEW_NV              0x1700\n#define GL_PATH_MODELVIEW_STACK_DEPTH_NV  0x0BA3\n#define GL_PATH_MODELVIEW_MATRIX_NV       0x0BA6\n#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36\n#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3\n#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4\n#define GL_PATH_PROJECTION_MATRIX_NV      0x0BA7\n#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38\n#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4\n#define GL_FRAGMENT_INPUT_NV              0x936D\ntypedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range);\ntypedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);\ntypedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path);\ntypedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);\ntypedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);\ntypedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);\ntypedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);\ntypedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString);\ntypedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);\ntypedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);\ntypedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);\ntypedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value);\ntypedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);\ntypedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value);\ntypedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);\ntypedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray);\ntypedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);\ntypedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);\ntypedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);\ntypedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);\ntypedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func);\ntypedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);\ntypedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);\ntypedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode);\ntypedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);\ntypedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);\ntypedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value);\ntypedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value);\ntypedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands);\ntypedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords);\ntypedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray);\ntypedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);\ntypedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);\ntypedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);\ntypedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value);\ntypedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value);\ntypedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value);\ntypedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value);\ntypedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);\ntypedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);\ntypedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);\ntypedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);\ntypedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m);\ntypedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);\ntypedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode);\ntypedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\ntypedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);\ntypedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\ntypedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);\ntypedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLuint APIENTRY glGenPathsNV (GLsizei range);\nGLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range);\nGLAPI GLboolean APIENTRY glIsPathNV (GLuint path);\nGLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);\nGLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);\nGLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords);\nGLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);\nGLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString);\nGLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\nGLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\nGLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights);\nGLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath);\nGLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);\nGLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value);\nGLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value);\nGLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value);\nGLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value);\nGLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray);\nGLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask);\nGLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units);\nGLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask);\nGLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask);\nGLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func);\nGLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs);\nGLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs);\nGLAPI void APIENTRY glPathFogGenNV (GLenum genMode);\nGLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode);\nGLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode);\nGLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value);\nGLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value);\nGLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands);\nGLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords);\nGLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray);\nGLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);\nGLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics);\nGLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);\nGLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value);\nGLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value);\nGLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value);\nGLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value);\nGLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y);\nGLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y);\nGLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments);\nGLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);\nGLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m);\nGLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);\nGLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode);\nGLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\nGLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\nGLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);\nGLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\nGLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\nGLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs);\nGLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params);\n#endif\n#endif /* GL_NV_path_rendering */\n\n#ifndef GL_NV_pixel_data_range\n#define GL_NV_pixel_data_range 1\n#define GL_WRITE_PIXEL_DATA_RANGE_NV      0x8878\n#define GL_READ_PIXEL_DATA_RANGE_NV       0x8879\n#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A\n#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B\n#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C\n#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D\ntypedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer);\ntypedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer);\nGLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target);\n#endif\n#endif /* GL_NV_pixel_data_range */\n\n#ifndef GL_NV_point_sprite\n#define GL_NV_point_sprite 1\n#define GL_POINT_SPRITE_NV                0x8861\n#define GL_COORD_REPLACE_NV               0x8862\n#define GL_POINT_SPRITE_R_MODE_NV         0x8863\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param);\nGLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params);\n#endif\n#endif /* GL_NV_point_sprite */\n\n#ifndef GL_NV_present_video\n#define GL_NV_present_video 1\n#define GL_FRAME_NV                       0x8E26\n#define GL_FIELDS_NV                      0x8E27\n#define GL_CURRENT_TIME_NV                0x8E28\n#define GL_NUM_FILL_STREAMS_NV            0x8E29\n#define GL_PRESENT_TIME_NV                0x8E2A\n#define GL_PRESENT_DURATION_NV            0x8E2B\ntypedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);\ntypedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);\ntypedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);\nGLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);\nGLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params);\nGLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params);\nGLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params);\n#endif\n#endif /* GL_NV_present_video */\n\n#ifndef GL_NV_primitive_restart\n#define GL_NV_primitive_restart 1\n#define GL_PRIMITIVE_RESTART_NV           0x8558\n#define GL_PRIMITIVE_RESTART_INDEX_NV     0x8559\ntypedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);\ntypedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPrimitiveRestartNV (void);\nGLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index);\n#endif\n#endif /* GL_NV_primitive_restart */\n\n#ifndef GL_NV_register_combiners\n#define GL_NV_register_combiners 1\n#define GL_REGISTER_COMBINERS_NV          0x8522\n#define GL_VARIABLE_A_NV                  0x8523\n#define GL_VARIABLE_B_NV                  0x8524\n#define GL_VARIABLE_C_NV                  0x8525\n#define GL_VARIABLE_D_NV                  0x8526\n#define GL_VARIABLE_E_NV                  0x8527\n#define GL_VARIABLE_F_NV                  0x8528\n#define GL_VARIABLE_G_NV                  0x8529\n#define GL_CONSTANT_COLOR0_NV             0x852A\n#define GL_CONSTANT_COLOR1_NV             0x852B\n#define GL_SPARE0_NV                      0x852E\n#define GL_SPARE1_NV                      0x852F\n#define GL_DISCARD_NV                     0x8530\n#define GL_E_TIMES_F_NV                   0x8531\n#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532\n#define GL_UNSIGNED_IDENTITY_NV           0x8536\n#define GL_UNSIGNED_INVERT_NV             0x8537\n#define GL_EXPAND_NORMAL_NV               0x8538\n#define GL_EXPAND_NEGATE_NV               0x8539\n#define GL_HALF_BIAS_NORMAL_NV            0x853A\n#define GL_HALF_BIAS_NEGATE_NV            0x853B\n#define GL_SIGNED_IDENTITY_NV             0x853C\n#define GL_SIGNED_NEGATE_NV               0x853D\n#define GL_SCALE_BY_TWO_NV                0x853E\n#define GL_SCALE_BY_FOUR_NV               0x853F\n#define GL_SCALE_BY_ONE_HALF_NV           0x8540\n#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV   0x8541\n#define GL_COMBINER_INPUT_NV              0x8542\n#define GL_COMBINER_MAPPING_NV            0x8543\n#define GL_COMBINER_COMPONENT_USAGE_NV    0x8544\n#define GL_COMBINER_AB_DOT_PRODUCT_NV     0x8545\n#define GL_COMBINER_CD_DOT_PRODUCT_NV     0x8546\n#define GL_COMBINER_MUX_SUM_NV            0x8547\n#define GL_COMBINER_SCALE_NV              0x8548\n#define GL_COMBINER_BIAS_NV               0x8549\n#define GL_COMBINER_AB_OUTPUT_NV          0x854A\n#define GL_COMBINER_CD_OUTPUT_NV          0x854B\n#define GL_COMBINER_SUM_OUTPUT_NV         0x854C\n#define GL_MAX_GENERAL_COMBINERS_NV       0x854D\n#define GL_NUM_GENERAL_COMBINERS_NV       0x854E\n#define GL_COLOR_SUM_CLAMP_NV             0x854F\n#define GL_COMBINER0_NV                   0x8550\n#define GL_COMBINER1_NV                   0x8551\n#define GL_COMBINER2_NV                   0x8552\n#define GL_COMBINER3_NV                   0x8553\n#define GL_COMBINER4_NV                   0x8554\n#define GL_COMBINER5_NV                   0x8555\n#define GL_COMBINER6_NV                   0x8556\n#define GL_COMBINER7_NV                   0x8557\ntypedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\ntypedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);\ntypedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\ntypedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params);\nGLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param);\nGLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\nGLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);\nGLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\nGLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params);\n#endif\n#endif /* GL_NV_register_combiners */\n\n#ifndef GL_NV_register_combiners2\n#define GL_NV_register_combiners2 1\n#define GL_PER_STAGE_CONSTANTS_NV         0x8535\ntypedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_NV_register_combiners2 */\n\n#ifndef GL_NV_shader_atomic_counters\n#define GL_NV_shader_atomic_counters 1\n#endif /* GL_NV_shader_atomic_counters */\n\n#ifndef GL_NV_shader_atomic_float\n#define GL_NV_shader_atomic_float 1\n#endif /* GL_NV_shader_atomic_float */\n\n#ifndef GL_NV_shader_atomic_int64\n#define GL_NV_shader_atomic_int64 1\n#endif /* GL_NV_shader_atomic_int64 */\n\n#ifndef GL_NV_shader_buffer_load\n#define GL_NV_shader_buffer_load 1\n#define GL_BUFFER_GPU_ADDRESS_NV          0x8F1D\n#define GL_GPU_ADDRESS_NV                 0x8F34\n#define GL_MAX_SHADER_BUFFER_ADDRESS_NV   0x8F35\ntypedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);\ntypedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);\ntypedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);\ntypedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);\ntypedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);\ntypedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);\ntypedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);\ntypedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);\ntypedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);\ntypedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);\ntypedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access);\nGLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target);\nGLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target);\nGLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access);\nGLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer);\nGLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer);\nGLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params);\nGLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params);\nGLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result);\nGLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value);\nGLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value);\nGLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value);\nGLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);\n#endif\n#endif /* GL_NV_shader_buffer_load */\n\n#ifndef GL_NV_shader_buffer_store\n#define GL_NV_shader_buffer_store 1\n#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010\n#endif /* GL_NV_shader_buffer_store */\n\n#ifndef GL_NV_shader_storage_buffer_object\n#define GL_NV_shader_storage_buffer_object 1\n#endif /* GL_NV_shader_storage_buffer_object */\n\n#ifndef GL_NV_shader_thread_group\n#define GL_NV_shader_thread_group 1\n#define GL_WARP_SIZE_NV                   0x9339\n#define GL_WARPS_PER_SM_NV                0x933A\n#define GL_SM_COUNT_NV                    0x933B\n#endif /* GL_NV_shader_thread_group */\n\n#ifndef GL_NV_shader_thread_shuffle\n#define GL_NV_shader_thread_shuffle 1\n#endif /* GL_NV_shader_thread_shuffle */\n\n#ifndef GL_NV_tessellation_program5\n#define GL_NV_tessellation_program5 1\n#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV   0x86D8\n#define GL_TESS_CONTROL_PROGRAM_NV        0x891E\n#define GL_TESS_EVALUATION_PROGRAM_NV     0x891F\n#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74\n#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75\n#endif /* GL_NV_tessellation_program5 */\n\n#ifndef GL_NV_texgen_emboss\n#define GL_NV_texgen_emboss 1\n#define GL_EMBOSS_LIGHT_NV                0x855D\n#define GL_EMBOSS_CONSTANT_NV             0x855E\n#define GL_EMBOSS_MAP_NV                  0x855F\n#endif /* GL_NV_texgen_emboss */\n\n#ifndef GL_NV_texgen_reflection\n#define GL_NV_texgen_reflection 1\n#define GL_NORMAL_MAP_NV                  0x8511\n#define GL_REFLECTION_MAP_NV              0x8512\n#endif /* GL_NV_texgen_reflection */\n\n#ifndef GL_NV_texture_barrier\n#define GL_NV_texture_barrier 1\ntypedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTextureBarrierNV (void);\n#endif\n#endif /* GL_NV_texture_barrier */\n\n#ifndef GL_NV_texture_compression_vtc\n#define GL_NV_texture_compression_vtc 1\n#endif /* GL_NV_texture_compression_vtc */\n\n#ifndef GL_NV_texture_env_combine4\n#define GL_NV_texture_env_combine4 1\n#define GL_COMBINE4_NV                    0x8503\n#define GL_SOURCE3_RGB_NV                 0x8583\n#define GL_SOURCE3_ALPHA_NV               0x858B\n#define GL_OPERAND3_RGB_NV                0x8593\n#define GL_OPERAND3_ALPHA_NV              0x859B\n#endif /* GL_NV_texture_env_combine4 */\n\n#ifndef GL_NV_texture_expand_normal\n#define GL_NV_texture_expand_normal 1\n#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F\n#endif /* GL_NV_texture_expand_normal */\n\n#ifndef GL_NV_texture_multisample\n#define GL_NV_texture_multisample 1\n#define GL_TEXTURE_COVERAGE_SAMPLES_NV    0x9045\n#define GL_TEXTURE_COLOR_SAMPLES_NV       0x9046\ntypedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\ntypedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\nGLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\nGLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\nGLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\nGLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\nGLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\n#endif\n#endif /* GL_NV_texture_multisample */\n\n#ifndef GL_NV_texture_rectangle\n#define GL_NV_texture_rectangle 1\n#define GL_TEXTURE_RECTANGLE_NV           0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE_NV   0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE_NV     0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV  0x84F8\n#endif /* GL_NV_texture_rectangle */\n\n#ifndef GL_NV_texture_shader\n#define GL_NV_texture_shader 1\n#define GL_OFFSET_TEXTURE_RECTANGLE_NV    0x864C\n#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D\n#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E\n#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9\n#define GL_UNSIGNED_INT_S8_S8_8_8_NV      0x86DA\n#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV  0x86DB\n#define GL_DSDT_MAG_INTENSITY_NV          0x86DC\n#define GL_SHADER_CONSISTENT_NV           0x86DD\n#define GL_TEXTURE_SHADER_NV              0x86DE\n#define GL_SHADER_OPERATION_NV            0x86DF\n#define GL_CULL_MODES_NV                  0x86E0\n#define GL_OFFSET_TEXTURE_MATRIX_NV       0x86E1\n#define GL_OFFSET_TEXTURE_SCALE_NV        0x86E2\n#define GL_OFFSET_TEXTURE_BIAS_NV         0x86E3\n#define GL_OFFSET_TEXTURE_2D_MATRIX_NV    0x86E1\n#define GL_OFFSET_TEXTURE_2D_SCALE_NV     0x86E2\n#define GL_OFFSET_TEXTURE_2D_BIAS_NV      0x86E3\n#define GL_PREVIOUS_TEXTURE_INPUT_NV      0x86E4\n#define GL_CONST_EYE_NV                   0x86E5\n#define GL_PASS_THROUGH_NV                0x86E6\n#define GL_CULL_FRAGMENT_NV               0x86E7\n#define GL_OFFSET_TEXTURE_2D_NV           0x86E8\n#define GL_DEPENDENT_AR_TEXTURE_2D_NV     0x86E9\n#define GL_DEPENDENT_GB_TEXTURE_2D_NV     0x86EA\n#define GL_DOT_PRODUCT_NV                 0x86EC\n#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV   0x86ED\n#define GL_DOT_PRODUCT_TEXTURE_2D_NV      0x86EE\n#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0\n#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1\n#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2\n#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3\n#define GL_HILO_NV                        0x86F4\n#define GL_DSDT_NV                        0x86F5\n#define GL_DSDT_MAG_NV                    0x86F6\n#define GL_DSDT_MAG_VIB_NV                0x86F7\n#define GL_HILO16_NV                      0x86F8\n#define GL_SIGNED_HILO_NV                 0x86F9\n#define GL_SIGNED_HILO16_NV               0x86FA\n#define GL_SIGNED_RGBA_NV                 0x86FB\n#define GL_SIGNED_RGBA8_NV                0x86FC\n#define GL_SIGNED_RGB_NV                  0x86FE\n#define GL_SIGNED_RGB8_NV                 0x86FF\n#define GL_SIGNED_LUMINANCE_NV            0x8701\n#define GL_SIGNED_LUMINANCE8_NV           0x8702\n#define GL_SIGNED_LUMINANCE_ALPHA_NV      0x8703\n#define GL_SIGNED_LUMINANCE8_ALPHA8_NV    0x8704\n#define GL_SIGNED_ALPHA_NV                0x8705\n#define GL_SIGNED_ALPHA8_NV               0x8706\n#define GL_SIGNED_INTENSITY_NV            0x8707\n#define GL_SIGNED_INTENSITY8_NV           0x8708\n#define GL_DSDT8_NV                       0x8709\n#define GL_DSDT8_MAG8_NV                  0x870A\n#define GL_DSDT8_MAG8_INTENSITY8_NV       0x870B\n#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV   0x870C\n#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D\n#define GL_HI_SCALE_NV                    0x870E\n#define GL_LO_SCALE_NV                    0x870F\n#define GL_DS_SCALE_NV                    0x8710\n#define GL_DT_SCALE_NV                    0x8711\n#define GL_MAGNITUDE_SCALE_NV             0x8712\n#define GL_VIBRANCE_SCALE_NV              0x8713\n#define GL_HI_BIAS_NV                     0x8714\n#define GL_LO_BIAS_NV                     0x8715\n#define GL_DS_BIAS_NV                     0x8716\n#define GL_DT_BIAS_NV                     0x8717\n#define GL_MAGNITUDE_BIAS_NV              0x8718\n#define GL_VIBRANCE_BIAS_NV               0x8719\n#define GL_TEXTURE_BORDER_VALUES_NV       0x871A\n#define GL_TEXTURE_HI_SIZE_NV             0x871B\n#define GL_TEXTURE_LO_SIZE_NV             0x871C\n#define GL_TEXTURE_DS_SIZE_NV             0x871D\n#define GL_TEXTURE_DT_SIZE_NV             0x871E\n#define GL_TEXTURE_MAG_SIZE_NV            0x871F\n#endif /* GL_NV_texture_shader */\n\n#ifndef GL_NV_texture_shader2\n#define GL_NV_texture_shader2 1\n#define GL_DOT_PRODUCT_TEXTURE_3D_NV      0x86EF\n#endif /* GL_NV_texture_shader2 */\n\n#ifndef GL_NV_texture_shader3\n#define GL_NV_texture_shader3 1\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853\n#define GL_OFFSET_HILO_TEXTURE_2D_NV      0x8854\n#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857\n#define GL_DEPENDENT_HILO_TEXTURE_2D_NV   0x8858\n#define GL_DEPENDENT_RGB_TEXTURE_3D_NV    0x8859\n#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A\n#define GL_DOT_PRODUCT_PASS_THROUGH_NV    0x885B\n#define GL_DOT_PRODUCT_TEXTURE_1D_NV      0x885C\n#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D\n#define GL_HILO8_NV                       0x885E\n#define GL_SIGNED_HILO8_NV                0x885F\n#define GL_FORCE_BLUE_TO_ONE_NV           0x8860\n#endif /* GL_NV_texture_shader3 */\n\n#ifndef GL_NV_transform_feedback\n#define GL_NV_transform_feedback 1\n#define GL_BACK_PRIMARY_COLOR_NV          0x8C77\n#define GL_BACK_SECONDARY_COLOR_NV        0x8C78\n#define GL_TEXTURE_COORD_NV               0x8C79\n#define GL_CLIP_DISTANCE_NV               0x8C7A\n#define GL_VERTEX_ID_NV                   0x8C7B\n#define GL_PRIMITIVE_ID_NV                0x8C7C\n#define GL_GENERIC_ATTRIB_NV              0x8C7D\n#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV  0x8C7E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80\n#define GL_ACTIVE_VARYINGS_NV             0x8C81\n#define GL_ACTIVE_VARYING_MAX_LENGTH_NV   0x8C82\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85\n#define GL_TRANSFORM_FEEDBACK_RECORD_NV   0x8C86\n#define GL_PRIMITIVES_GENERATED_NV        0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88\n#define GL_RASTERIZER_DISCARD_NV          0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS_NV         0x8C8C\n#define GL_SEPARATE_ATTRIBS_NV            0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER_NV   0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F\n#define GL_LAYER_NV                       0x8DAA\n#define GL_NEXT_BUFFER_NV                 -2\n#define GL_SKIP_COMPONENTS4_NV            -3\n#define GL_SKIP_COMPONENTS3_NV            -4\n#define GL_SKIP_COMPONENTS2_NV            -5\n#define GL_SKIP_COMPONENTS1_NV            -6\ntypedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);\ntypedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode);\ntypedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\ntypedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\ntypedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);\ntypedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);\ntypedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);\ntypedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode);\nGLAPI void APIENTRY glEndTransformFeedbackNV (void);\nGLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode);\nGLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\nGLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\nGLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer);\nGLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);\nGLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name);\nGLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name);\nGLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\nGLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location);\nGLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode);\n#endif\n#endif /* GL_NV_transform_feedback */\n\n#ifndef GL_NV_transform_feedback2\n#define GL_NV_transform_feedback2 1\n#define GL_TRANSFORM_FEEDBACK_NV          0x8E22\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24\n#define GL_TRANSFORM_FEEDBACK_BINDING_NV  0x8E25\ntypedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);\ntypedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids);\ntypedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids);\ntypedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);\ntypedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);\ntypedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id);\nGLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids);\nGLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids);\nGLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id);\nGLAPI void APIENTRY glPauseTransformFeedbackNV (void);\nGLAPI void APIENTRY glResumeTransformFeedbackNV (void);\nGLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id);\n#endif\n#endif /* GL_NV_transform_feedback2 */\n\n#ifndef GL_NV_vdpau_interop\n#define GL_NV_vdpau_interop 1\ntypedef GLintptr GLvdpauSurfaceNV;\n#define GL_SURFACE_STATE_NV               0x86EB\n#define GL_SURFACE_REGISTERED_NV          0x86FD\n#define GL_SURFACE_MAPPED_NV              0x8700\n#define GL_WRITE_DISCARD_NV               0x88BE\ntypedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress);\ntypedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void);\ntypedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\ntypedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\ntypedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);\ntypedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);\ntypedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);\ntypedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);\ntypedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);\ntypedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress);\nGLAPI void APIENTRY glVDPAUFiniNV (void);\nGLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\nGLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\nGLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface);\nGLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface);\nGLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);\nGLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access);\nGLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);\nGLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);\n#endif\n#endif /* GL_NV_vdpau_interop */\n\n#ifndef GL_NV_vertex_array_range\n#define GL_NV_vertex_array_range 1\n#define GL_VERTEX_ARRAY_RANGE_NV          0x851D\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV   0x851E\n#define GL_VERTEX_ARRAY_RANGE_VALID_NV    0x851F\n#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520\n#define GL_VERTEX_ARRAY_RANGE_POINTER_NV  0x8521\ntypedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);\ntypedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFlushVertexArrayRangeNV (void);\nGLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer);\n#endif\n#endif /* GL_NV_vertex_array_range */\n\n#ifndef GL_NV_vertex_array_range2\n#define GL_NV_vertex_array_range2 1\n#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533\n#endif /* GL_NV_vertex_array_range2 */\n\n#ifndef GL_NV_vertex_attrib_integer_64bit\n#define GL_NV_vertex_attrib_integer_64bit 1\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x);\nGLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y);\nGLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);\nGLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\nGLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x);\nGLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y);\nGLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\nGLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\nGLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v);\nGLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v);\nGLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params);\nGLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params);\nGLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);\n#endif\n#endif /* GL_NV_vertex_attrib_integer_64bit */\n\n#ifndef GL_NV_vertex_buffer_unified_memory\n#define GL_NV_vertex_buffer_unified_memory 1\n#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E\n#define GL_ELEMENT_ARRAY_UNIFIED_NV       0x8F1F\n#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20\n#define GL_VERTEX_ARRAY_ADDRESS_NV        0x8F21\n#define GL_NORMAL_ARRAY_ADDRESS_NV        0x8F22\n#define GL_COLOR_ARRAY_ADDRESS_NV         0x8F23\n#define GL_INDEX_ARRAY_ADDRESS_NV         0x8F24\n#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25\n#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV     0x8F26\n#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27\n#define GL_FOG_COORD_ARRAY_ADDRESS_NV     0x8F28\n#define GL_ELEMENT_ARRAY_ADDRESS_NV       0x8F29\n#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV  0x8F2A\n#define GL_VERTEX_ARRAY_LENGTH_NV         0x8F2B\n#define GL_NORMAL_ARRAY_LENGTH_NV         0x8F2C\n#define GL_COLOR_ARRAY_LENGTH_NV          0x8F2D\n#define GL_INDEX_ARRAY_LENGTH_NV          0x8F2E\n#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV  0x8F2F\n#define GL_EDGE_FLAG_ARRAY_LENGTH_NV      0x8F30\n#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31\n#define GL_FOG_COORD_ARRAY_LENGTH_NV      0x8F32\n#define GL_ELEMENT_ARRAY_LENGTH_NV        0x8F33\n#define GL_DRAW_INDIRECT_UNIFIED_NV       0x8F40\n#define GL_DRAW_INDIRECT_ADDRESS_NV       0x8F41\n#define GL_DRAW_INDIRECT_LENGTH_NV        0x8F42\ntypedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);\ntypedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);\ntypedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\ntypedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);\nGLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride);\nGLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride);\nGLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride);\nGLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride);\nGLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride);\nGLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride);\nGLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride);\nGLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride);\nGLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);\nGLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride);\nGLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result);\n#endif\n#endif /* GL_NV_vertex_buffer_unified_memory */\n\n#ifndef GL_NV_vertex_program\n#define GL_NV_vertex_program 1\n#define GL_VERTEX_PROGRAM_NV              0x8620\n#define GL_VERTEX_STATE_PROGRAM_NV        0x8621\n#define GL_ATTRIB_ARRAY_SIZE_NV           0x8623\n#define GL_ATTRIB_ARRAY_STRIDE_NV         0x8624\n#define GL_ATTRIB_ARRAY_TYPE_NV           0x8625\n#define GL_CURRENT_ATTRIB_NV              0x8626\n#define GL_PROGRAM_LENGTH_NV              0x8627\n#define GL_PROGRAM_STRING_NV              0x8628\n#define GL_MODELVIEW_PROJECTION_NV        0x8629\n#define GL_IDENTITY_NV                    0x862A\n#define GL_INVERSE_NV                     0x862B\n#define GL_TRANSPOSE_NV                   0x862C\n#define GL_INVERSE_TRANSPOSE_NV           0x862D\n#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E\n#define GL_MAX_TRACK_MATRICES_NV          0x862F\n#define GL_MATRIX0_NV                     0x8630\n#define GL_MATRIX1_NV                     0x8631\n#define GL_MATRIX2_NV                     0x8632\n#define GL_MATRIX3_NV                     0x8633\n#define GL_MATRIX4_NV                     0x8634\n#define GL_MATRIX5_NV                     0x8635\n#define GL_MATRIX6_NV                     0x8636\n#define GL_MATRIX7_NV                     0x8637\n#define GL_CURRENT_MATRIX_STACK_DEPTH_NV  0x8640\n#define GL_CURRENT_MATRIX_NV              0x8641\n#define GL_VERTEX_PROGRAM_POINT_SIZE_NV   0x8642\n#define GL_VERTEX_PROGRAM_TWO_SIDE_NV     0x8643\n#define GL_PROGRAM_PARAMETER_NV           0x8644\n#define GL_ATTRIB_ARRAY_POINTER_NV        0x8645\n#define GL_PROGRAM_TARGET_NV              0x8646\n#define GL_PROGRAM_RESIDENT_NV            0x8647\n#define GL_TRACK_MATRIX_NV                0x8648\n#define GL_TRACK_MATRIX_TRANSFORM_NV      0x8649\n#define GL_VERTEX_PROGRAM_BINDING_NV      0x864A\n#define GL_PROGRAM_ERROR_POSITION_NV      0x864B\n#define GL_VERTEX_ATTRIB_ARRAY0_NV        0x8650\n#define GL_VERTEX_ATTRIB_ARRAY1_NV        0x8651\n#define GL_VERTEX_ATTRIB_ARRAY2_NV        0x8652\n#define GL_VERTEX_ATTRIB_ARRAY3_NV        0x8653\n#define GL_VERTEX_ATTRIB_ARRAY4_NV        0x8654\n#define GL_VERTEX_ATTRIB_ARRAY5_NV        0x8655\n#define GL_VERTEX_ATTRIB_ARRAY6_NV        0x8656\n#define GL_VERTEX_ATTRIB_ARRAY7_NV        0x8657\n#define GL_VERTEX_ATTRIB_ARRAY8_NV        0x8658\n#define GL_VERTEX_ATTRIB_ARRAY9_NV        0x8659\n#define GL_VERTEX_ATTRIB_ARRAY10_NV       0x865A\n#define GL_VERTEX_ATTRIB_ARRAY11_NV       0x865B\n#define GL_VERTEX_ATTRIB_ARRAY12_NV       0x865C\n#define GL_VERTEX_ATTRIB_ARRAY13_NV       0x865D\n#define GL_VERTEX_ATTRIB_ARRAY14_NV       0x865E\n#define GL_VERTEX_ATTRIB_ARRAY15_NV       0x865F\n#define GL_MAP1_VERTEX_ATTRIB0_4_NV       0x8660\n#define GL_MAP1_VERTEX_ATTRIB1_4_NV       0x8661\n#define GL_MAP1_VERTEX_ATTRIB2_4_NV       0x8662\n#define GL_MAP1_VERTEX_ATTRIB3_4_NV       0x8663\n#define GL_MAP1_VERTEX_ATTRIB4_4_NV       0x8664\n#define GL_MAP1_VERTEX_ATTRIB5_4_NV       0x8665\n#define GL_MAP1_VERTEX_ATTRIB6_4_NV       0x8666\n#define GL_MAP1_VERTEX_ATTRIB7_4_NV       0x8667\n#define GL_MAP1_VERTEX_ATTRIB8_4_NV       0x8668\n#define GL_MAP1_VERTEX_ATTRIB9_4_NV       0x8669\n#define GL_MAP1_VERTEX_ATTRIB10_4_NV      0x866A\n#define GL_MAP1_VERTEX_ATTRIB11_4_NV      0x866B\n#define GL_MAP1_VERTEX_ATTRIB12_4_NV      0x866C\n#define GL_MAP1_VERTEX_ATTRIB13_4_NV      0x866D\n#define GL_MAP1_VERTEX_ATTRIB14_4_NV      0x866E\n#define GL_MAP1_VERTEX_ATTRIB15_4_NV      0x866F\n#define GL_MAP2_VERTEX_ATTRIB0_4_NV       0x8670\n#define GL_MAP2_VERTEX_ATTRIB1_4_NV       0x8671\n#define GL_MAP2_VERTEX_ATTRIB2_4_NV       0x8672\n#define GL_MAP2_VERTEX_ATTRIB3_4_NV       0x8673\n#define GL_MAP2_VERTEX_ATTRIB4_4_NV       0x8674\n#define GL_MAP2_VERTEX_ATTRIB5_4_NV       0x8675\n#define GL_MAP2_VERTEX_ATTRIB6_4_NV       0x8676\n#define GL_MAP2_VERTEX_ATTRIB7_4_NV       0x8677\n#define GL_MAP2_VERTEX_ATTRIB8_4_NV       0x8678\n#define GL_MAP2_VERTEX_ATTRIB9_4_NV       0x8679\n#define GL_MAP2_VERTEX_ATTRIB10_4_NV      0x867A\n#define GL_MAP2_VERTEX_ATTRIB11_4_NV      0x867B\n#define GL_MAP2_VERTEX_ATTRIB12_4_NV      0x867C\n#define GL_MAP2_VERTEX_ATTRIB13_4_NV      0x867D\n#define GL_MAP2_VERTEX_ATTRIB14_4_NV      0x867E\n#define GL_MAP2_VERTEX_ATTRIB15_4_NV      0x867F\ntypedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);\ntypedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);\ntypedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);\ntypedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);\ntypedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);\ntypedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer);\ntypedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);\ntypedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);\ntypedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences);\nGLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id);\nGLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs);\nGLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params);\nGLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs);\nGLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program);\nGLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params);\nGLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer);\nGLAPI GLboolean APIENTRY glIsProgramNV (GLuint id);\nGLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program);\nGLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs);\nGLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform);\nGLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x);\nGLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x);\nGLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x);\nGLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y);\nGLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y);\nGLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y);\nGLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z);\nGLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z);\nGLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\nGLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\nGLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\nGLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v);\nGLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v);\nGLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v);\n#endif\n#endif /* GL_NV_vertex_program */\n\n#ifndef GL_NV_vertex_program1_1\n#define GL_NV_vertex_program1_1 1\n#endif /* GL_NV_vertex_program1_1 */\n\n#ifndef GL_NV_vertex_program2\n#define GL_NV_vertex_program2 1\n#endif /* GL_NV_vertex_program2 */\n\n#ifndef GL_NV_vertex_program2_option\n#define GL_NV_vertex_program2_option 1\n#endif /* GL_NV_vertex_program2_option */\n\n#ifndef GL_NV_vertex_program3\n#define GL_NV_vertex_program3 1\n#endif /* GL_NV_vertex_program3 */\n\n#ifndef GL_NV_vertex_program4\n#define GL_NV_vertex_program4 1\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x);\nGLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y);\nGLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z);\nGLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w);\nGLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x);\nGLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y);\nGLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z);\nGLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\nGLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v);\nGLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v);\nGLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v);\nGLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v);\nGLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v);\nGLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v);\nGLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\nGLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params);\n#endif\n#endif /* GL_NV_vertex_program4 */\n\n#ifndef GL_NV_video_capture\n#define GL_NV_video_capture 1\n#define GL_VIDEO_BUFFER_NV                0x9020\n#define GL_VIDEO_BUFFER_BINDING_NV        0x9021\n#define GL_FIELD_UPPER_NV                 0x9022\n#define GL_FIELD_LOWER_NV                 0x9023\n#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV   0x9024\n#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025\n#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026\n#define GL_LAST_VIDEO_CAPTURE_STATUS_NV   0x9027\n#define GL_VIDEO_BUFFER_PITCH_NV          0x9028\n#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029\n#define GL_VIDEO_COLOR_CONVERSION_MAX_NV  0x902A\n#define GL_VIDEO_COLOR_CONVERSION_MIN_NV  0x902B\n#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C\n#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D\n#define GL_PARTIAL_SUCCESS_NV             0x902E\n#define GL_SUCCESS_NV                     0x902F\n#define GL_FAILURE_NV                     0x9030\n#define GL_YCBYCR8_422_NV                 0x9031\n#define GL_YCBAYCR8A_4224_NV              0x9032\n#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV  0x9033\n#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034\n#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV  0x9035\n#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036\n#define GL_Z4Y12Z4CB12Z4CR12_444_NV       0x9037\n#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV   0x9038\n#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV  0x9039\n#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A\n#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B\n#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C\ntypedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\ntypedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);\ntypedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);\ntypedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\ntypedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);\ntypedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);\ntypedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot);\nGLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);\nGLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);\nGLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot);\nGLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);\nGLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);\nGLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);\n#endif\n#endif /* GL_NV_video_capture */\n\n#ifndef GL_OML_interlace\n#define GL_OML_interlace 1\n#define GL_INTERLACE_OML                  0x8980\n#define GL_INTERLACE_READ_OML             0x8981\n#endif /* GL_OML_interlace */\n\n#ifndef GL_OML_resample\n#define GL_OML_resample 1\n#define GL_PACK_RESAMPLE_OML              0x8984\n#define GL_UNPACK_RESAMPLE_OML            0x8985\n#define GL_RESAMPLE_REPLICATE_OML         0x8986\n#define GL_RESAMPLE_ZERO_FILL_OML         0x8987\n#define GL_RESAMPLE_AVERAGE_OML           0x8988\n#define GL_RESAMPLE_DECIMATE_OML          0x8989\n#endif /* GL_OML_resample */\n\n#ifndef GL_OML_subsample\n#define GL_OML_subsample 1\n#define GL_FORMAT_SUBSAMPLE_24_24_OML     0x8982\n#define GL_FORMAT_SUBSAMPLE_244_244_OML   0x8983\n#endif /* GL_OML_subsample */\n\n#ifndef GL_PGI_misc_hints\n#define GL_PGI_misc_hints 1\n#define GL_PREFER_DOUBLEBUFFER_HINT_PGI   0x1A1F8\n#define GL_CONSERVE_MEMORY_HINT_PGI       0x1A1FD\n#define GL_RECLAIM_MEMORY_HINT_PGI        0x1A1FE\n#define GL_NATIVE_GRAPHICS_HANDLE_PGI     0x1A202\n#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203\n#define GL_NATIVE_GRAPHICS_END_HINT_PGI   0x1A204\n#define GL_ALWAYS_FAST_HINT_PGI           0x1A20C\n#define GL_ALWAYS_SOFT_HINT_PGI           0x1A20D\n#define GL_ALLOW_DRAW_OBJ_HINT_PGI        0x1A20E\n#define GL_ALLOW_DRAW_WIN_HINT_PGI        0x1A20F\n#define GL_ALLOW_DRAW_FRG_HINT_PGI        0x1A210\n#define GL_ALLOW_DRAW_MEM_HINT_PGI        0x1A211\n#define GL_STRICT_DEPTHFUNC_HINT_PGI      0x1A216\n#define GL_STRICT_LIGHTING_HINT_PGI       0x1A217\n#define GL_STRICT_SCISSOR_HINT_PGI        0x1A218\n#define GL_FULL_STIPPLE_HINT_PGI          0x1A219\n#define GL_CLIP_NEAR_HINT_PGI             0x1A220\n#define GL_CLIP_FAR_HINT_PGI              0x1A221\n#define GL_WIDE_LINE_HINT_PGI             0x1A222\n#define GL_BACK_NORMALS_HINT_PGI          0x1A223\ntypedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glHintPGI (GLenum target, GLint mode);\n#endif\n#endif /* GL_PGI_misc_hints */\n\n#ifndef GL_PGI_vertex_hints\n#define GL_PGI_vertex_hints 1\n#define GL_VERTEX_DATA_HINT_PGI           0x1A22A\n#define GL_VERTEX_CONSISTENT_HINT_PGI     0x1A22B\n#define GL_MATERIAL_SIDE_HINT_PGI         0x1A22C\n#define GL_MAX_VERTEX_HINT_PGI            0x1A22D\n#define GL_COLOR3_BIT_PGI                 0x00010000\n#define GL_COLOR4_BIT_PGI                 0x00020000\n#define GL_EDGEFLAG_BIT_PGI               0x00040000\n#define GL_INDEX_BIT_PGI                  0x00080000\n#define GL_MAT_AMBIENT_BIT_PGI            0x00100000\n#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000\n#define GL_MAT_DIFFUSE_BIT_PGI            0x00400000\n#define GL_MAT_EMISSION_BIT_PGI           0x00800000\n#define GL_MAT_COLOR_INDEXES_BIT_PGI      0x01000000\n#define GL_MAT_SHININESS_BIT_PGI          0x02000000\n#define GL_MAT_SPECULAR_BIT_PGI           0x04000000\n#define GL_NORMAL_BIT_PGI                 0x08000000\n#define GL_TEXCOORD1_BIT_PGI              0x10000000\n#define GL_TEXCOORD2_BIT_PGI              0x20000000\n#define GL_TEXCOORD3_BIT_PGI              0x40000000\n#define GL_TEXCOORD4_BIT_PGI              0x80000000\n#define GL_VERTEX23_BIT_PGI               0x00000004\n#define GL_VERTEX4_BIT_PGI                0x00000008\n#endif /* GL_PGI_vertex_hints */\n\n#ifndef GL_REND_screen_coordinates\n#define GL_REND_screen_coordinates 1\n#define GL_SCREEN_COORDINATES_REND        0x8490\n#define GL_INVERTED_SCREEN_W_REND         0x8491\n#endif /* GL_REND_screen_coordinates */\n\n#ifndef GL_S3_s3tc\n#define GL_S3_s3tc 1\n#define GL_RGB_S3TC                       0x83A0\n#define GL_RGB4_S3TC                      0x83A1\n#define GL_RGBA_S3TC                      0x83A2\n#define GL_RGBA4_S3TC                     0x83A3\n#define GL_RGBA_DXT5_S3TC                 0x83A4\n#define GL_RGBA4_DXT5_S3TC                0x83A5\n#endif /* GL_S3_s3tc */\n\n#ifndef GL_SGIS_detail_texture\n#define GL_SGIS_detail_texture 1\n#define GL_DETAIL_TEXTURE_2D_SGIS         0x8095\n#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096\n#define GL_LINEAR_DETAIL_SGIS             0x8097\n#define GL_LINEAR_DETAIL_ALPHA_SGIS       0x8098\n#define GL_LINEAR_DETAIL_COLOR_SGIS       0x8099\n#define GL_DETAIL_TEXTURE_LEVEL_SGIS      0x809A\n#define GL_DETAIL_TEXTURE_MODE_SGIS       0x809B\n#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C\ntypedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);\ntypedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);\nGLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points);\n#endif\n#endif /* GL_SGIS_detail_texture */\n\n#ifndef GL_SGIS_fog_function\n#define GL_SGIS_fog_function 1\n#define GL_FOG_FUNC_SGIS                  0x812A\n#define GL_FOG_FUNC_POINTS_SGIS           0x812B\n#define GL_MAX_FOG_FUNC_POINTS_SGIS       0x812C\ntypedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);\ntypedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points);\nGLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points);\n#endif\n#endif /* GL_SGIS_fog_function */\n\n#ifndef GL_SGIS_generate_mipmap\n#define GL_SGIS_generate_mipmap 1\n#define GL_GENERATE_MIPMAP_SGIS           0x8191\n#define GL_GENERATE_MIPMAP_HINT_SGIS      0x8192\n#endif /* GL_SGIS_generate_mipmap */\n\n#ifndef GL_SGIS_multisample\n#define GL_SGIS_multisample 1\n#define GL_MULTISAMPLE_SGIS               0x809D\n#define GL_SAMPLE_ALPHA_TO_MASK_SGIS      0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE_SGIS       0x809F\n#define GL_SAMPLE_MASK_SGIS               0x80A0\n#define GL_1PASS_SGIS                     0x80A1\n#define GL_2PASS_0_SGIS                   0x80A2\n#define GL_2PASS_1_SGIS                   0x80A3\n#define GL_4PASS_0_SGIS                   0x80A4\n#define GL_4PASS_1_SGIS                   0x80A5\n#define GL_4PASS_2_SGIS                   0x80A6\n#define GL_4PASS_3_SGIS                   0x80A7\n#define GL_SAMPLE_BUFFERS_SGIS            0x80A8\n#define GL_SAMPLES_SGIS                   0x80A9\n#define GL_SAMPLE_MASK_VALUE_SGIS         0x80AA\n#define GL_SAMPLE_MASK_INVERT_SGIS        0x80AB\n#define GL_SAMPLE_PATTERN_SGIS            0x80AC\ntypedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);\ntypedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert);\nGLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern);\n#endif\n#endif /* GL_SGIS_multisample */\n\n#ifndef GL_SGIS_pixel_texture\n#define GL_SGIS_pixel_texture 1\n#define GL_PIXEL_TEXTURE_SGIS             0x8353\n#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354\n#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355\n#define GL_PIXEL_GROUP_COLOR_SGIS         0x8356\ntypedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param);\nGLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params);\nGLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params);\n#endif\n#endif /* GL_SGIS_pixel_texture */\n\n#ifndef GL_SGIS_point_line_texgen\n#define GL_SGIS_point_line_texgen 1\n#define GL_EYE_DISTANCE_TO_POINT_SGIS     0x81F0\n#define GL_OBJECT_DISTANCE_TO_POINT_SGIS  0x81F1\n#define GL_EYE_DISTANCE_TO_LINE_SGIS      0x81F2\n#define GL_OBJECT_DISTANCE_TO_LINE_SGIS   0x81F3\n#define GL_EYE_POINT_SGIS                 0x81F4\n#define GL_OBJECT_POINT_SGIS              0x81F5\n#define GL_EYE_LINE_SGIS                  0x81F6\n#define GL_OBJECT_LINE_SGIS               0x81F7\n#endif /* GL_SGIS_point_line_texgen */\n\n#ifndef GL_SGIS_point_parameters\n#define GL_SGIS_point_parameters 1\n#define GL_POINT_SIZE_MIN_SGIS            0x8126\n#define GL_POINT_SIZE_MAX_SGIS            0x8127\n#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128\n#define GL_DISTANCE_ATTENUATION_SGIS      0x8129\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params);\n#endif\n#endif /* GL_SGIS_point_parameters */\n\n#ifndef GL_SGIS_sharpen_texture\n#define GL_SGIS_sharpen_texture 1\n#define GL_LINEAR_SHARPEN_SGIS            0x80AD\n#define GL_LINEAR_SHARPEN_ALPHA_SGIS      0x80AE\n#define GL_LINEAR_SHARPEN_COLOR_SGIS      0x80AF\n#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0\ntypedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);\ntypedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points);\nGLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points);\n#endif\n#endif /* GL_SGIS_sharpen_texture */\n\n#ifndef GL_SGIS_texture4D\n#define GL_SGIS_texture4D 1\n#define GL_PACK_SKIP_VOLUMES_SGIS         0x8130\n#define GL_PACK_IMAGE_DEPTH_SGIS          0x8131\n#define GL_UNPACK_SKIP_VOLUMES_SGIS       0x8132\n#define GL_UNPACK_IMAGE_DEPTH_SGIS        0x8133\n#define GL_TEXTURE_4D_SGIS                0x8134\n#define GL_PROXY_TEXTURE_4D_SGIS          0x8135\n#define GL_TEXTURE_4DSIZE_SGIS            0x8136\n#define GL_TEXTURE_WRAP_Q_SGIS            0x8137\n#define GL_MAX_4D_TEXTURE_SIZE_SGIS       0x8138\n#define GL_TEXTURE_4D_BINDING_SGIS        0x814F\ntypedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels);\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels);\nGLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels);\n#endif\n#endif /* GL_SGIS_texture4D */\n\n#ifndef GL_SGIS_texture_border_clamp\n#define GL_SGIS_texture_border_clamp 1\n#define GL_CLAMP_TO_BORDER_SGIS           0x812D\n#endif /* GL_SGIS_texture_border_clamp */\n\n#ifndef GL_SGIS_texture_color_mask\n#define GL_SGIS_texture_color_mask 1\n#define GL_TEXTURE_COLOR_WRITEMASK_SGIS   0x81EF\ntypedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\n#endif\n#endif /* GL_SGIS_texture_color_mask */\n\n#ifndef GL_SGIS_texture_edge_clamp\n#define GL_SGIS_texture_edge_clamp 1\n#define GL_CLAMP_TO_EDGE_SGIS             0x812F\n#endif /* GL_SGIS_texture_edge_clamp */\n\n#ifndef GL_SGIS_texture_filter4\n#define GL_SGIS_texture_filter4 1\n#define GL_FILTER4_SGIS                   0x8146\n#define GL_TEXTURE_FILTER4_SIZE_SGIS      0x8147\ntypedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);\ntypedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights);\nGLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);\n#endif\n#endif /* GL_SGIS_texture_filter4 */\n\n#ifndef GL_SGIS_texture_lod\n#define GL_SGIS_texture_lod 1\n#define GL_TEXTURE_MIN_LOD_SGIS           0x813A\n#define GL_TEXTURE_MAX_LOD_SGIS           0x813B\n#define GL_TEXTURE_BASE_LEVEL_SGIS        0x813C\n#define GL_TEXTURE_MAX_LEVEL_SGIS         0x813D\n#endif /* GL_SGIS_texture_lod */\n\n#ifndef GL_SGIS_texture_select\n#define GL_SGIS_texture_select 1\n#define GL_DUAL_ALPHA4_SGIS               0x8110\n#define GL_DUAL_ALPHA8_SGIS               0x8111\n#define GL_DUAL_ALPHA12_SGIS              0x8112\n#define GL_DUAL_ALPHA16_SGIS              0x8113\n#define GL_DUAL_LUMINANCE4_SGIS           0x8114\n#define GL_DUAL_LUMINANCE8_SGIS           0x8115\n#define GL_DUAL_LUMINANCE12_SGIS          0x8116\n#define GL_DUAL_LUMINANCE16_SGIS          0x8117\n#define GL_DUAL_INTENSITY4_SGIS           0x8118\n#define GL_DUAL_INTENSITY8_SGIS           0x8119\n#define GL_DUAL_INTENSITY12_SGIS          0x811A\n#define GL_DUAL_INTENSITY16_SGIS          0x811B\n#define GL_DUAL_LUMINANCE_ALPHA4_SGIS     0x811C\n#define GL_DUAL_LUMINANCE_ALPHA8_SGIS     0x811D\n#define GL_QUAD_ALPHA4_SGIS               0x811E\n#define GL_QUAD_ALPHA8_SGIS               0x811F\n#define GL_QUAD_LUMINANCE4_SGIS           0x8120\n#define GL_QUAD_LUMINANCE8_SGIS           0x8121\n#define GL_QUAD_INTENSITY4_SGIS           0x8122\n#define GL_QUAD_INTENSITY8_SGIS           0x8123\n#define GL_DUAL_TEXTURE_SELECT_SGIS       0x8124\n#define GL_QUAD_TEXTURE_SELECT_SGIS       0x8125\n#endif /* GL_SGIS_texture_select */\n\n#ifndef GL_SGIX_async\n#define GL_SGIX_async 1\n#define GL_ASYNC_MARKER_SGIX              0x8329\ntypedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);\ntypedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);\ntypedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);\ntypedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);\ntypedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);\ntypedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker);\nGLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp);\nGLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp);\nGLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range);\nGLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range);\nGLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker);\n#endif\n#endif /* GL_SGIX_async */\n\n#ifndef GL_SGIX_async_histogram\n#define GL_SGIX_async_histogram 1\n#define GL_ASYNC_HISTOGRAM_SGIX           0x832C\n#define GL_MAX_ASYNC_HISTOGRAM_SGIX       0x832D\n#endif /* GL_SGIX_async_histogram */\n\n#ifndef GL_SGIX_async_pixel\n#define GL_SGIX_async_pixel 1\n#define GL_ASYNC_TEX_IMAGE_SGIX           0x835C\n#define GL_ASYNC_DRAW_PIXELS_SGIX         0x835D\n#define GL_ASYNC_READ_PIXELS_SGIX         0x835E\n#define GL_MAX_ASYNC_TEX_IMAGE_SGIX       0x835F\n#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX     0x8360\n#define GL_MAX_ASYNC_READ_PIXELS_SGIX     0x8361\n#endif /* GL_SGIX_async_pixel */\n\n#ifndef GL_SGIX_blend_alpha_minmax\n#define GL_SGIX_blend_alpha_minmax 1\n#define GL_ALPHA_MIN_SGIX                 0x8320\n#define GL_ALPHA_MAX_SGIX                 0x8321\n#endif /* GL_SGIX_blend_alpha_minmax */\n\n#ifndef GL_SGIX_calligraphic_fragment\n#define GL_SGIX_calligraphic_fragment 1\n#define GL_CALLIGRAPHIC_FRAGMENT_SGIX     0x8183\n#endif /* GL_SGIX_calligraphic_fragment */\n\n#ifndef GL_SGIX_clipmap\n#define GL_SGIX_clipmap 1\n#define GL_LINEAR_CLIPMAP_LINEAR_SGIX     0x8170\n#define GL_TEXTURE_CLIPMAP_CENTER_SGIX    0x8171\n#define GL_TEXTURE_CLIPMAP_FRAME_SGIX     0x8172\n#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX    0x8173\n#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174\n#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175\n#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX     0x8176\n#define GL_MAX_CLIPMAP_DEPTH_SGIX         0x8177\n#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178\n#define GL_NEAREST_CLIPMAP_NEAREST_SGIX   0x844D\n#define GL_NEAREST_CLIPMAP_LINEAR_SGIX    0x844E\n#define GL_LINEAR_CLIPMAP_NEAREST_SGIX    0x844F\n#endif /* GL_SGIX_clipmap */\n\n#ifndef GL_SGIX_convolution_accuracy\n#define GL_SGIX_convolution_accuracy 1\n#define GL_CONVOLUTION_HINT_SGIX          0x8316\n#endif /* GL_SGIX_convolution_accuracy */\n\n#ifndef GL_SGIX_depth_pass_instrument\n#define GL_SGIX_depth_pass_instrument 1\n#endif /* GL_SGIX_depth_pass_instrument */\n\n#ifndef GL_SGIX_depth_texture\n#define GL_SGIX_depth_texture 1\n#define GL_DEPTH_COMPONENT16_SGIX         0x81A5\n#define GL_DEPTH_COMPONENT24_SGIX         0x81A6\n#define GL_DEPTH_COMPONENT32_SGIX         0x81A7\n#endif /* GL_SGIX_depth_texture */\n\n#ifndef GL_SGIX_flush_raster\n#define GL_SGIX_flush_raster 1\ntypedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFlushRasterSGIX (void);\n#endif\n#endif /* GL_SGIX_flush_raster */\n\n#ifndef GL_SGIX_fog_offset\n#define GL_SGIX_fog_offset 1\n#define GL_FOG_OFFSET_SGIX                0x8198\n#define GL_FOG_OFFSET_VALUE_SGIX          0x8199\n#endif /* GL_SGIX_fog_offset */\n\n#ifndef GL_SGIX_fragment_lighting\n#define GL_SGIX_fragment_lighting 1\n#define GL_FRAGMENT_LIGHTING_SGIX         0x8400\n#define GL_FRAGMENT_COLOR_MATERIAL_SGIX   0x8401\n#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402\n#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403\n#define GL_MAX_FRAGMENT_LIGHTS_SGIX       0x8404\n#define GL_MAX_ACTIVE_LIGHTS_SGIX         0x8405\n#define GL_CURRENT_RASTER_NORMAL_SGIX     0x8406\n#define GL_LIGHT_ENV_MODE_SGIX            0x8407\n#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408\n#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409\n#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A\n#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B\n#define GL_FRAGMENT_LIGHT0_SGIX           0x840C\n#define GL_FRAGMENT_LIGHT1_SGIX           0x840D\n#define GL_FRAGMENT_LIGHT2_SGIX           0x840E\n#define GL_FRAGMENT_LIGHT3_SGIX           0x840F\n#define GL_FRAGMENT_LIGHT4_SGIX           0x8410\n#define GL_FRAGMENT_LIGHT5_SGIX           0x8411\n#define GL_FRAGMENT_LIGHT6_SGIX           0x8412\n#define GL_FRAGMENT_LIGHT7_SGIX           0x8413\ntypedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode);\nGLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param);\nGLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param);\nGLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params);\nGLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param);\nGLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params);\nGLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params);\nGLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param);\n#endif\n#endif /* GL_SGIX_fragment_lighting */\n\n#ifndef GL_SGIX_framezoom\n#define GL_SGIX_framezoom 1\n#define GL_FRAMEZOOM_SGIX                 0x818B\n#define GL_FRAMEZOOM_FACTOR_SGIX          0x818C\n#define GL_MAX_FRAMEZOOM_FACTOR_SGIX      0x818D\ntypedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFrameZoomSGIX (GLint factor);\n#endif\n#endif /* GL_SGIX_framezoom */\n\n#ifndef GL_SGIX_igloo_interface\n#define GL_SGIX_igloo_interface 1\ntypedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params);\n#endif\n#endif /* GL_SGIX_igloo_interface */\n\n#ifndef GL_SGIX_instruments\n#define GL_SGIX_instruments 1\n#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180\n#define GL_INSTRUMENT_MEASUREMENTS_SGIX   0x8181\ntypedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);\ntypedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);\ntypedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);\ntypedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);\ntypedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);\ntypedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI GLint APIENTRY glGetInstrumentsSGIX (void);\nGLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer);\nGLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p);\nGLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker);\nGLAPI void APIENTRY glStartInstrumentsSGIX (void);\nGLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker);\n#endif\n#endif /* GL_SGIX_instruments */\n\n#ifndef GL_SGIX_interlace\n#define GL_SGIX_interlace 1\n#define GL_INTERLACE_SGIX                 0x8094\n#endif /* GL_SGIX_interlace */\n\n#ifndef GL_SGIX_ir_instrument1\n#define GL_SGIX_ir_instrument1 1\n#define GL_IR_INSTRUMENT1_SGIX            0x817F\n#endif /* GL_SGIX_ir_instrument1 */\n\n#ifndef GL_SGIX_list_priority\n#define GL_SGIX_list_priority 1\n#define GL_LIST_PRIORITY_SGIX             0x8182\ntypedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);\ntypedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params);\nGLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param);\nGLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param);\nGLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params);\n#endif\n#endif /* GL_SGIX_list_priority */\n\n#ifndef GL_SGIX_pixel_texture\n#define GL_SGIX_pixel_texture 1\n#define GL_PIXEL_TEX_GEN_SGIX             0x8139\n#define GL_PIXEL_TEX_GEN_MODE_SGIX        0x832B\ntypedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode);\n#endif\n#endif /* GL_SGIX_pixel_texture */\n\n#ifndef GL_SGIX_pixel_tiles\n#define GL_SGIX_pixel_tiles 1\n#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E\n#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F\n#define GL_PIXEL_TILE_WIDTH_SGIX          0x8140\n#define GL_PIXEL_TILE_HEIGHT_SGIX         0x8141\n#define GL_PIXEL_TILE_GRID_WIDTH_SGIX     0x8142\n#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX    0x8143\n#define GL_PIXEL_TILE_GRID_DEPTH_SGIX     0x8144\n#define GL_PIXEL_TILE_CACHE_SIZE_SGIX     0x8145\n#endif /* GL_SGIX_pixel_tiles */\n\n#ifndef GL_SGIX_polynomial_ffd\n#define GL_SGIX_polynomial_ffd 1\n#define GL_TEXTURE_DEFORMATION_BIT_SGIX   0x00000001\n#define GL_GEOMETRY_DEFORMATION_BIT_SGIX  0x00000002\n#define GL_GEOMETRY_DEFORMATION_SGIX      0x8194\n#define GL_TEXTURE_DEFORMATION_SGIX       0x8195\n#define GL_DEFORMATIONS_MASK_SGIX         0x8196\n#define GL_MAX_DEFORMATION_ORDER_SGIX     0x8197\ntypedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);\ntypedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);\ntypedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);\ntypedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);\nGLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);\nGLAPI void APIENTRY glDeformSGIX (GLbitfield mask);\nGLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask);\n#endif\n#endif /* GL_SGIX_polynomial_ffd */\n\n#ifndef GL_SGIX_reference_plane\n#define GL_SGIX_reference_plane 1\n#define GL_REFERENCE_PLANE_SGIX           0x817D\n#define GL_REFERENCE_PLANE_EQUATION_SGIX  0x817E\ntypedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation);\n#endif\n#endif /* GL_SGIX_reference_plane */\n\n#ifndef GL_SGIX_resample\n#define GL_SGIX_resample 1\n#define GL_PACK_RESAMPLE_SGIX             0x842C\n#define GL_UNPACK_RESAMPLE_SGIX           0x842D\n#define GL_RESAMPLE_REPLICATE_SGIX        0x842E\n#define GL_RESAMPLE_ZERO_FILL_SGIX        0x842F\n#define GL_RESAMPLE_DECIMATE_SGIX         0x8430\n#endif /* GL_SGIX_resample */\n\n#ifndef GL_SGIX_scalebias_hint\n#define GL_SGIX_scalebias_hint 1\n#define GL_SCALEBIAS_HINT_SGIX            0x8322\n#endif /* GL_SGIX_scalebias_hint */\n\n#ifndef GL_SGIX_shadow\n#define GL_SGIX_shadow 1\n#define GL_TEXTURE_COMPARE_SGIX           0x819A\n#define GL_TEXTURE_COMPARE_OPERATOR_SGIX  0x819B\n#define GL_TEXTURE_LEQUAL_R_SGIX          0x819C\n#define GL_TEXTURE_GEQUAL_R_SGIX          0x819D\n#endif /* GL_SGIX_shadow */\n\n#ifndef GL_SGIX_shadow_ambient\n#define GL_SGIX_shadow_ambient 1\n#define GL_SHADOW_AMBIENT_SGIX            0x80BF\n#endif /* GL_SGIX_shadow_ambient */\n\n#ifndef GL_SGIX_sprite\n#define GL_SGIX_sprite 1\n#define GL_SPRITE_SGIX                    0x8148\n#define GL_SPRITE_MODE_SGIX               0x8149\n#define GL_SPRITE_AXIS_SGIX               0x814A\n#define GL_SPRITE_TRANSLATION_SGIX        0x814B\n#define GL_SPRITE_AXIAL_SGIX              0x814C\n#define GL_SPRITE_OBJECT_ALIGNED_SGIX     0x814D\n#define GL_SPRITE_EYE_ALIGNED_SGIX        0x814E\ntypedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);\ntypedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);\ntypedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param);\nGLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param);\nGLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params);\n#endif\n#endif /* GL_SGIX_sprite */\n\n#ifndef GL_SGIX_subsample\n#define GL_SGIX_subsample 1\n#define GL_PACK_SUBSAMPLE_RATE_SGIX       0x85A0\n#define GL_UNPACK_SUBSAMPLE_RATE_SGIX     0x85A1\n#define GL_PIXEL_SUBSAMPLE_4444_SGIX      0x85A2\n#define GL_PIXEL_SUBSAMPLE_2424_SGIX      0x85A3\n#define GL_PIXEL_SUBSAMPLE_4242_SGIX      0x85A4\n#endif /* GL_SGIX_subsample */\n\n#ifndef GL_SGIX_tag_sample_buffer\n#define GL_SGIX_tag_sample_buffer 1\ntypedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glTagSampleBufferSGIX (void);\n#endif\n#endif /* GL_SGIX_tag_sample_buffer */\n\n#ifndef GL_SGIX_texture_add_env\n#define GL_SGIX_texture_add_env 1\n#define GL_TEXTURE_ENV_BIAS_SGIX          0x80BE\n#endif /* GL_SGIX_texture_add_env */\n\n#ifndef GL_SGIX_texture_coordinate_clamp\n#define GL_SGIX_texture_coordinate_clamp 1\n#define GL_TEXTURE_MAX_CLAMP_S_SGIX       0x8369\n#define GL_TEXTURE_MAX_CLAMP_T_SGIX       0x836A\n#define GL_TEXTURE_MAX_CLAMP_R_SGIX       0x836B\n#endif /* GL_SGIX_texture_coordinate_clamp */\n\n#ifndef GL_SGIX_texture_lod_bias\n#define GL_SGIX_texture_lod_bias 1\n#define GL_TEXTURE_LOD_BIAS_S_SGIX        0x818E\n#define GL_TEXTURE_LOD_BIAS_T_SGIX        0x818F\n#define GL_TEXTURE_LOD_BIAS_R_SGIX        0x8190\n#endif /* GL_SGIX_texture_lod_bias */\n\n#ifndef GL_SGIX_texture_multi_buffer\n#define GL_SGIX_texture_multi_buffer 1\n#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E\n#endif /* GL_SGIX_texture_multi_buffer */\n\n#ifndef GL_SGIX_texture_scale_bias\n#define GL_SGIX_texture_scale_bias 1\n#define GL_POST_TEXTURE_FILTER_BIAS_SGIX  0x8179\n#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A\n#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B\n#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C\n#endif /* GL_SGIX_texture_scale_bias */\n\n#ifndef GL_SGIX_vertex_preclip\n#define GL_SGIX_vertex_preclip 1\n#define GL_VERTEX_PRECLIP_SGIX            0x83EE\n#define GL_VERTEX_PRECLIP_HINT_SGIX       0x83EF\n#endif /* GL_SGIX_vertex_preclip */\n\n#ifndef GL_SGIX_ycrcb\n#define GL_SGIX_ycrcb 1\n#define GL_YCRCB_422_SGIX                 0x81BB\n#define GL_YCRCB_444_SGIX                 0x81BC\n#endif /* GL_SGIX_ycrcb */\n\n#ifndef GL_SGIX_ycrcb_subsample\n#define GL_SGIX_ycrcb_subsample 1\n#endif /* GL_SGIX_ycrcb_subsample */\n\n#ifndef GL_SGIX_ycrcba\n#define GL_SGIX_ycrcba 1\n#define GL_YCRCB_SGIX                     0x8318\n#define GL_YCRCBA_SGIX                    0x8319\n#endif /* GL_SGIX_ycrcba */\n\n#ifndef GL_SGI_color_matrix\n#define GL_SGI_color_matrix 1\n#define GL_COLOR_MATRIX_SGI               0x80B1\n#define GL_COLOR_MATRIX_STACK_DEPTH_SGI   0x80B2\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3\n#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7\n#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB\n#endif /* GL_SGI_color_matrix */\n\n#ifndef GL_SGI_color_table\n#define GL_SGI_color_table 1\n#define GL_COLOR_TABLE_SGI                0x80D0\n#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2\n#define GL_PROXY_COLOR_TABLE_SGI          0x80D3\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5\n#define GL_COLOR_TABLE_SCALE_SGI          0x80D6\n#define GL_COLOR_TABLE_BIAS_SGI           0x80D7\n#define GL_COLOR_TABLE_FORMAT_SGI         0x80D8\n#define GL_COLOR_TABLE_WIDTH_SGI          0x80D9\n#define GL_COLOR_TABLE_RED_SIZE_SGI       0x80DA\n#define GL_COLOR_TABLE_GREEN_SIZE_SGI     0x80DB\n#define GL_COLOR_TABLE_BLUE_SIZE_SGI      0x80DC\n#define GL_COLOR_TABLE_ALPHA_SIZE_SGI     0x80DD\n#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE\n#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF\ntypedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\ntypedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);\ntypedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);\ntypedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);\ntypedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\nGLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params);\nGLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params);\nGLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\nGLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table);\nGLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params);\nGLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params);\n#endif\n#endif /* GL_SGI_color_table */\n\n#ifndef GL_SGI_texture_color_table\n#define GL_SGI_texture_color_table 1\n#define GL_TEXTURE_COLOR_TABLE_SGI        0x80BC\n#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI  0x80BD\n#endif /* GL_SGI_texture_color_table */\n\n#ifndef GL_SUNX_constant_data\n#define GL_SUNX_constant_data 1\n#define GL_UNPACK_CONSTANT_DATA_SUNX      0x81D5\n#define GL_TEXTURE_CONSTANT_DATA_SUNX     0x81D6\ntypedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glFinishTextureSUNX (void);\n#endif\n#endif /* GL_SUNX_constant_data */\n\n#ifndef GL_SUN_convolution_border_modes\n#define GL_SUN_convolution_border_modes 1\n#define GL_WRAP_BORDER_SUN                0x81D4\n#endif /* GL_SUN_convolution_border_modes */\n\n#ifndef GL_SUN_global_alpha\n#define GL_SUN_global_alpha 1\n#define GL_GLOBAL_ALPHA_SUN               0x81D9\n#define GL_GLOBAL_ALPHA_FACTOR_SUN        0x81DA\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);\ntypedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor);\nGLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor);\nGLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor);\nGLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor);\nGLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor);\nGLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor);\nGLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor);\nGLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor);\n#endif\n#endif /* GL_SUN_global_alpha */\n\n#ifndef GL_SUN_mesh_array\n#define GL_SUN_mesh_array 1\n#define GL_QUAD_MESH_SUN                  0x8614\n#define GL_TRIANGLE_MESH_SUN              0x8615\ntypedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width);\n#endif\n#endif /* GL_SUN_mesh_array */\n\n#ifndef GL_SUN_slice_accum\n#define GL_SUN_slice_accum 1\n#define GL_SLICE_ACCUM_SUN                0x85CC\n#endif /* GL_SUN_slice_accum */\n\n#ifndef GL_SUN_triangle_list\n#define GL_SUN_triangle_list 1\n#define GL_RESTART_SUN                    0x0001\n#define GL_REPLACE_MIDDLE_SUN             0x0002\n#define GL_REPLACE_OLDEST_SUN             0x0003\n#define GL_TRIANGLE_LIST_SUN              0x81D7\n#define GL_REPLACEMENT_CODE_SUN           0x81D8\n#define GL_REPLACEMENT_CODE_ARRAY_SUN     0x85C0\n#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1\n#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2\n#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3\n#define GL_R1UI_V3F_SUN                   0x85C4\n#define GL_R1UI_C4UB_V3F_SUN              0x85C5\n#define GL_R1UI_C3F_V3F_SUN               0x85C6\n#define GL_R1UI_N3F_V3F_SUN               0x85C7\n#define GL_R1UI_C4F_N3F_V3F_SUN           0x85C8\n#define GL_R1UI_T2F_V3F_SUN               0x85C9\n#define GL_R1UI_T2F_N3F_V3F_SUN           0x85CA\n#define GL_R1UI_T2F_C4F_N3F_V3F_SUN       0x85CB\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code);\nGLAPI void APIENTRY glReplacementCodeusSUN (GLushort code);\nGLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code);\nGLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code);\nGLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code);\nGLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code);\nGLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer);\n#endif\n#endif /* GL_SUN_triangle_list */\n\n#ifndef GL_SUN_vertex\n#define GL_SUN_vertex 1\ntypedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);\ntypedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\ntypedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\ntypedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\n#ifdef GL_GLEXT_PROTOTYPES\nGLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);\nGLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v);\nGLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v);\nGLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v);\nGLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\nGLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\n#endif\n#endif /* GL_SUN_vertex */\n\n#ifndef GL_WIN_phong_shading\n#define GL_WIN_phong_shading 1\n#define GL_PHONG_WIN                      0x80EA\n#define GL_PHONG_HINT_WIN                 0x80EB\n#endif /* GL_WIN_phong_shading */\n\n#ifndef GL_WIN_specular_fog\n#define GL_WIN_specular_fog 1\n#define GL_FOG_SPECULAR_TEXTURE_WIN       0x80EC\n#endif /* GL_WIN_specular_fog */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deps/glfw/deps/GL/glxext.h",
    "content": "#ifndef __glxext_h_\n#define __glxext_h_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Copyright (c) 2013-2014 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n/*\n** This header is generated from the Khronos OpenGL / OpenGL ES XML\n** API Registry. The current version of the Registry, generator scripts\n** used to make the header, and the header can be found at\n**   http://www.opengl.org/registry/\n**\n** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $\n*/\n\n#define GLX_GLXEXT_VERSION 20140810\n\n/* Generated C header for:\n * API: glx\n * Versions considered: .*\n * Versions emitted: 1\\.[3-9]\n * Default extensions included: glx\n * Additional extensions included: _nomatch_^\n * Extensions removed: _nomatch_^\n */\n\n#ifndef GLX_VERSION_1_3\n#define GLX_VERSION_1_3 1\ntypedef XID GLXContextID;\ntypedef struct __GLXFBConfigRec *GLXFBConfig;\ntypedef XID GLXWindow;\ntypedef XID GLXPbuffer;\n#define GLX_WINDOW_BIT                    0x00000001\n#define GLX_PIXMAP_BIT                    0x00000002\n#define GLX_PBUFFER_BIT                   0x00000004\n#define GLX_RGBA_BIT                      0x00000001\n#define GLX_COLOR_INDEX_BIT               0x00000002\n#define GLX_PBUFFER_CLOBBER_MASK          0x08000000\n#define GLX_FRONT_LEFT_BUFFER_BIT         0x00000001\n#define GLX_FRONT_RIGHT_BUFFER_BIT        0x00000002\n#define GLX_BACK_LEFT_BUFFER_BIT          0x00000004\n#define GLX_BACK_RIGHT_BUFFER_BIT         0x00000008\n#define GLX_AUX_BUFFERS_BIT               0x00000010\n#define GLX_DEPTH_BUFFER_BIT              0x00000020\n#define GLX_STENCIL_BUFFER_BIT            0x00000040\n#define GLX_ACCUM_BUFFER_BIT              0x00000080\n#define GLX_CONFIG_CAVEAT                 0x20\n#define GLX_X_VISUAL_TYPE                 0x22\n#define GLX_TRANSPARENT_TYPE              0x23\n#define GLX_TRANSPARENT_INDEX_VALUE       0x24\n#define GLX_TRANSPARENT_RED_VALUE         0x25\n#define GLX_TRANSPARENT_GREEN_VALUE       0x26\n#define GLX_TRANSPARENT_BLUE_VALUE        0x27\n#define GLX_TRANSPARENT_ALPHA_VALUE       0x28\n#define GLX_DONT_CARE                     0xFFFFFFFF\n#define GLX_NONE                          0x8000\n#define GLX_SLOW_CONFIG                   0x8001\n#define GLX_TRUE_COLOR                    0x8002\n#define GLX_DIRECT_COLOR                  0x8003\n#define GLX_PSEUDO_COLOR                  0x8004\n#define GLX_STATIC_COLOR                  0x8005\n#define GLX_GRAY_SCALE                    0x8006\n#define GLX_STATIC_GRAY                   0x8007\n#define GLX_TRANSPARENT_RGB               0x8008\n#define GLX_TRANSPARENT_INDEX             0x8009\n#define GLX_VISUAL_ID                     0x800B\n#define GLX_SCREEN                        0x800C\n#define GLX_NON_CONFORMANT_CONFIG         0x800D\n#define GLX_DRAWABLE_TYPE                 0x8010\n#define GLX_RENDER_TYPE                   0x8011\n#define GLX_X_RENDERABLE                  0x8012\n#define GLX_FBCONFIG_ID                   0x8013\n#define GLX_RGBA_TYPE                     0x8014\n#define GLX_COLOR_INDEX_TYPE              0x8015\n#define GLX_MAX_PBUFFER_WIDTH             0x8016\n#define GLX_MAX_PBUFFER_HEIGHT            0x8017\n#define GLX_MAX_PBUFFER_PIXELS            0x8018\n#define GLX_PRESERVED_CONTENTS            0x801B\n#define GLX_LARGEST_PBUFFER               0x801C\n#define GLX_WIDTH                         0x801D\n#define GLX_HEIGHT                        0x801E\n#define GLX_EVENT_MASK                    0x801F\n#define GLX_DAMAGED                       0x8020\n#define GLX_SAVED                         0x8021\n#define GLX_WINDOW                        0x8022\n#define GLX_PBUFFER                       0x8023\n#define GLX_PBUFFER_HEIGHT                0x8040\n#define GLX_PBUFFER_WIDTH                 0x8041\ntypedef GLXFBConfig *( *PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);\ntypedef GLXFBConfig *( *PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);\ntypedef int ( *PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);\ntypedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);\ntypedef GLXWindow ( *PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);\ntypedef void ( *PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);\ntypedef GLXPixmap ( *PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);\ntypedef void ( *PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);\ntypedef GLXPbuffer ( *PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);\ntypedef void ( *PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);\ntypedef void ( *PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);\ntypedef GLXContext ( *PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\ntypedef Bool ( *PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\ntypedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLEPROC) (void);\ntypedef int ( *PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);\ntypedef void ( *PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);\ntypedef void ( *PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXFBConfig *glXGetFBConfigs (Display *dpy, int screen, int *nelements);\nGLXFBConfig *glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements);\nint glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value);\nXVisualInfo *glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config);\nGLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);\nvoid glXDestroyWindow (Display *dpy, GLXWindow win);\nGLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);\nvoid glXDestroyPixmap (Display *dpy, GLXPixmap pixmap);\nGLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list);\nvoid glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf);\nvoid glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);\nGLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\nBool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\nGLXDrawable glXGetCurrentReadDrawable (void);\nint glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value);\nvoid glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask);\nvoid glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask);\n#endif\n#endif /* GLX_VERSION_1_3 */\n\n#ifndef GLX_VERSION_1_4\n#define GLX_VERSION_1_4 1\ntypedef void ( *__GLXextFuncPtr)(void);\n#define GLX_SAMPLE_BUFFERS                100000\n#define GLX_SAMPLES                       100001\ntypedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);\n#ifdef GLX_GLXEXT_PROTOTYPES\n__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName);\n#endif\n#endif /* GLX_VERSION_1_4 */\n\n#ifndef GLX_ARB_context_flush_control\n#define GLX_ARB_context_flush_control 1\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB  0x2097\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098\n#endif /* GLX_ARB_context_flush_control */\n\n#ifndef GLX_ARB_create_context\n#define GLX_ARB_create_context 1\n#define GLX_CONTEXT_DEBUG_BIT_ARB         0x00000001\n#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002\n#define GLX_CONTEXT_MAJOR_VERSION_ARB     0x2091\n#define GLX_CONTEXT_MINOR_VERSION_ARB     0x2092\n#define GLX_CONTEXT_FLAGS_ARB             0x2094\ntypedef GLXContext ( *PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);\n#endif\n#endif /* GLX_ARB_create_context */\n\n#ifndef GLX_ARB_create_context_profile\n#define GLX_ARB_create_context_profile 1\n#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB  0x00000001\n#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define GLX_CONTEXT_PROFILE_MASK_ARB      0x9126\n#endif /* GLX_ARB_create_context_profile */\n\n#ifndef GLX_ARB_create_context_robustness\n#define GLX_ARB_create_context_robustness 1\n#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define GLX_LOSE_CONTEXT_ON_RESET_ARB     0x8252\n#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define GLX_NO_RESET_NOTIFICATION_ARB     0x8261\n#endif /* GLX_ARB_create_context_robustness */\n\n#ifndef GLX_ARB_fbconfig_float\n#define GLX_ARB_fbconfig_float 1\n#define GLX_RGBA_FLOAT_TYPE_ARB           0x20B9\n#define GLX_RGBA_FLOAT_BIT_ARB            0x00000004\n#endif /* GLX_ARB_fbconfig_float */\n\n#ifndef GLX_ARB_framebuffer_sRGB\n#define GLX_ARB_framebuffer_sRGB 1\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB  0x20B2\n#endif /* GLX_ARB_framebuffer_sRGB */\n\n#ifndef GLX_ARB_get_proc_address\n#define GLX_ARB_get_proc_address 1\ntypedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);\n#ifdef GLX_GLXEXT_PROTOTYPES\n__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName);\n#endif\n#endif /* GLX_ARB_get_proc_address */\n\n#ifndef GLX_ARB_multisample\n#define GLX_ARB_multisample 1\n#define GLX_SAMPLE_BUFFERS_ARB            100000\n#define GLX_SAMPLES_ARB                   100001\n#endif /* GLX_ARB_multisample */\n\n#ifndef GLX_ARB_robustness_application_isolation\n#define GLX_ARB_robustness_application_isolation 1\n#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\n#endif /* GLX_ARB_robustness_application_isolation */\n\n#ifndef GLX_ARB_robustness_share_group_isolation\n#define GLX_ARB_robustness_share_group_isolation 1\n#endif /* GLX_ARB_robustness_share_group_isolation */\n\n#ifndef GLX_ARB_vertex_buffer_object\n#define GLX_ARB_vertex_buffer_object 1\n#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095\n#endif /* GLX_ARB_vertex_buffer_object */\n\n#ifndef GLX_3DFX_multisample\n#define GLX_3DFX_multisample 1\n#define GLX_SAMPLE_BUFFERS_3DFX           0x8050\n#define GLX_SAMPLES_3DFX                  0x8051\n#endif /* GLX_3DFX_multisample */\n\n#ifndef GLX_AMD_gpu_association\n#define GLX_AMD_gpu_association 1\n#define GLX_GPU_VENDOR_AMD                0x1F00\n#define GLX_GPU_RENDERER_STRING_AMD       0x1F01\n#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\n#define GLX_GPU_FASTEST_TARGET_GPUS_AMD   0x21A2\n#define GLX_GPU_RAM_AMD                   0x21A3\n#define GLX_GPU_CLOCK_AMD                 0x21A4\n#define GLX_GPU_NUM_PIPES_AMD             0x21A5\n#define GLX_GPU_NUM_SIMD_AMD              0x21A6\n#define GLX_GPU_NUM_RB_AMD                0x21A7\n#define GLX_GPU_NUM_SPI_AMD               0x21A8\n#endif /* GLX_AMD_gpu_association */\n\n#ifndef GLX_EXT_buffer_age\n#define GLX_EXT_buffer_age 1\n#define GLX_BACK_BUFFER_AGE_EXT           0x20F4\n#endif /* GLX_EXT_buffer_age */\n\n#ifndef GLX_EXT_create_context_es2_profile\n#define GLX_EXT_create_context_es2_profile 1\n#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT   0x00000004\n#endif /* GLX_EXT_create_context_es2_profile */\n\n#ifndef GLX_EXT_create_context_es_profile\n#define GLX_EXT_create_context_es_profile 1\n#define GLX_CONTEXT_ES_PROFILE_BIT_EXT    0x00000004\n#endif /* GLX_EXT_create_context_es_profile */\n\n#ifndef GLX_EXT_fbconfig_packed_float\n#define GLX_EXT_fbconfig_packed_float 1\n#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT  0x20B1\n#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT   0x00000008\n#endif /* GLX_EXT_fbconfig_packed_float */\n\n#ifndef GLX_EXT_framebuffer_sRGB\n#define GLX_EXT_framebuffer_sRGB 1\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT  0x20B2\n#endif /* GLX_EXT_framebuffer_sRGB */\n\n#ifndef GLX_EXT_import_context\n#define GLX_EXT_import_context 1\n#define GLX_SHARE_CONTEXT_EXT             0x800A\n#define GLX_VISUAL_ID_EXT                 0x800B\n#define GLX_SCREEN_EXT                    0x800C\ntypedef Display *( *PFNGLXGETCURRENTDISPLAYEXTPROC) (void);\ntypedef int ( *PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);\ntypedef GLXContextID ( *PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);\ntypedef GLXContext ( *PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);\ntypedef void ( *PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);\n#ifdef GLX_GLXEXT_PROTOTYPES\nDisplay *glXGetCurrentDisplayEXT (void);\nint glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value);\nGLXContextID glXGetContextIDEXT (const GLXContext context);\nGLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID);\nvoid glXFreeContextEXT (Display *dpy, GLXContext context);\n#endif\n#endif /* GLX_EXT_import_context */\n\n#ifndef GLX_EXT_stereo_tree\n#define GLX_EXT_stereo_tree 1\ntypedef struct {\n    int type;\n    unsigned long serial;\n    Bool send_event;\n    Display *display;\n    int extension;\n    int evtype;\n    GLXDrawable window;\n    Bool stereo_tree;\n} GLXStereoNotifyEventEXT;\n#define GLX_STEREO_TREE_EXT               0x20F5\n#define GLX_STEREO_NOTIFY_MASK_EXT        0x00000001\n#define GLX_STEREO_NOTIFY_EXT             0x00000000\n#endif /* GLX_EXT_stereo_tree */\n\n#ifndef GLX_EXT_swap_control\n#define GLX_EXT_swap_control 1\n#define GLX_SWAP_INTERVAL_EXT             0x20F1\n#define GLX_MAX_SWAP_INTERVAL_EXT         0x20F2\ntypedef void ( *PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval);\n#endif\n#endif /* GLX_EXT_swap_control */\n\n#ifndef GLX_EXT_swap_control_tear\n#define GLX_EXT_swap_control_tear 1\n#define GLX_LATE_SWAPS_TEAR_EXT           0x20F3\n#endif /* GLX_EXT_swap_control_tear */\n\n#ifndef GLX_EXT_texture_from_pixmap\n#define GLX_EXT_texture_from_pixmap 1\n#define GLX_TEXTURE_1D_BIT_EXT            0x00000001\n#define GLX_TEXTURE_2D_BIT_EXT            0x00000002\n#define GLX_TEXTURE_RECTANGLE_BIT_EXT     0x00000004\n#define GLX_BIND_TO_TEXTURE_RGB_EXT       0x20D0\n#define GLX_BIND_TO_TEXTURE_RGBA_EXT      0x20D1\n#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT    0x20D2\n#define GLX_BIND_TO_TEXTURE_TARGETS_EXT   0x20D3\n#define GLX_Y_INVERTED_EXT                0x20D4\n#define GLX_TEXTURE_FORMAT_EXT            0x20D5\n#define GLX_TEXTURE_TARGET_EXT            0x20D6\n#define GLX_MIPMAP_TEXTURE_EXT            0x20D7\n#define GLX_TEXTURE_FORMAT_NONE_EXT       0x20D8\n#define GLX_TEXTURE_FORMAT_RGB_EXT        0x20D9\n#define GLX_TEXTURE_FORMAT_RGBA_EXT       0x20DA\n#define GLX_TEXTURE_1D_EXT                0x20DB\n#define GLX_TEXTURE_2D_EXT                0x20DC\n#define GLX_TEXTURE_RECTANGLE_EXT         0x20DD\n#define GLX_FRONT_LEFT_EXT                0x20DE\n#define GLX_FRONT_RIGHT_EXT               0x20DF\n#define GLX_BACK_LEFT_EXT                 0x20E0\n#define GLX_BACK_RIGHT_EXT                0x20E1\n#define GLX_FRONT_EXT                     0x20DE\n#define GLX_BACK_EXT                      0x20E0\n#define GLX_AUX0_EXT                      0x20E2\n#define GLX_AUX1_EXT                      0x20E3\n#define GLX_AUX2_EXT                      0x20E4\n#define GLX_AUX3_EXT                      0x20E5\n#define GLX_AUX4_EXT                      0x20E6\n#define GLX_AUX5_EXT                      0x20E7\n#define GLX_AUX6_EXT                      0x20E8\n#define GLX_AUX7_EXT                      0x20E9\n#define GLX_AUX8_EXT                      0x20EA\n#define GLX_AUX9_EXT                      0x20EB\ntypedef void ( *PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);\ntypedef void ( *PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list);\nvoid glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer);\n#endif\n#endif /* GLX_EXT_texture_from_pixmap */\n\n#ifndef GLX_EXT_visual_info\n#define GLX_EXT_visual_info 1\n#define GLX_X_VISUAL_TYPE_EXT             0x22\n#define GLX_TRANSPARENT_TYPE_EXT          0x23\n#define GLX_TRANSPARENT_INDEX_VALUE_EXT   0x24\n#define GLX_TRANSPARENT_RED_VALUE_EXT     0x25\n#define GLX_TRANSPARENT_GREEN_VALUE_EXT   0x26\n#define GLX_TRANSPARENT_BLUE_VALUE_EXT    0x27\n#define GLX_TRANSPARENT_ALPHA_VALUE_EXT   0x28\n#define GLX_NONE_EXT                      0x8000\n#define GLX_TRUE_COLOR_EXT                0x8002\n#define GLX_DIRECT_COLOR_EXT              0x8003\n#define GLX_PSEUDO_COLOR_EXT              0x8004\n#define GLX_STATIC_COLOR_EXT              0x8005\n#define GLX_GRAY_SCALE_EXT                0x8006\n#define GLX_STATIC_GRAY_EXT               0x8007\n#define GLX_TRANSPARENT_RGB_EXT           0x8008\n#define GLX_TRANSPARENT_INDEX_EXT         0x8009\n#endif /* GLX_EXT_visual_info */\n\n#ifndef GLX_EXT_visual_rating\n#define GLX_EXT_visual_rating 1\n#define GLX_VISUAL_CAVEAT_EXT             0x20\n#define GLX_SLOW_VISUAL_EXT               0x8001\n#define GLX_NON_CONFORMANT_VISUAL_EXT     0x800D\n#endif /* GLX_EXT_visual_rating */\n\n#ifndef GLX_INTEL_swap_event\n#define GLX_INTEL_swap_event 1\n#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000\n#define GLX_EXCHANGE_COMPLETE_INTEL       0x8180\n#define GLX_COPY_COMPLETE_INTEL           0x8181\n#define GLX_FLIP_COMPLETE_INTEL           0x8182\n#endif /* GLX_INTEL_swap_event */\n\n#ifndef GLX_MESA_agp_offset\n#define GLX_MESA_agp_offset 1\ntypedef unsigned int ( *PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);\n#ifdef GLX_GLXEXT_PROTOTYPES\nunsigned int glXGetAGPOffsetMESA (const void *pointer);\n#endif\n#endif /* GLX_MESA_agp_offset */\n\n#ifndef GLX_MESA_copy_sub_buffer\n#define GLX_MESA_copy_sub_buffer 1\ntypedef void ( *PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);\n#endif\n#endif /* GLX_MESA_copy_sub_buffer */\n\n#ifndef GLX_MESA_pixmap_colormap\n#define GLX_MESA_pixmap_colormap 1\ntypedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);\n#endif\n#endif /* GLX_MESA_pixmap_colormap */\n\n#ifndef GLX_MESA_query_renderer\n#define GLX_MESA_query_renderer 1\n#define GLX_RENDERER_VENDOR_ID_MESA       0x8183\n#define GLX_RENDERER_DEVICE_ID_MESA       0x8184\n#define GLX_RENDERER_VERSION_MESA         0x8185\n#define GLX_RENDERER_ACCELERATED_MESA     0x8186\n#define GLX_RENDERER_VIDEO_MEMORY_MESA    0x8187\n#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188\n#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189\n#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A\n#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B\n#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C\n#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D\n#define GLX_RENDERER_ID_MESA              0x818E\ntypedef Bool ( *PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value);\ntypedef const char *( *PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);\ntypedef Bool ( *PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);\ntypedef const char *( *PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXQueryCurrentRendererIntegerMESA (int attribute, unsigned int *value);\nconst char *glXQueryCurrentRendererStringMESA (int attribute);\nBool glXQueryRendererIntegerMESA (Display *dpy, int screen, int renderer, int attribute, unsigned int *value);\nconst char *glXQueryRendererStringMESA (Display *dpy, int screen, int renderer, int attribute);\n#endif\n#endif /* GLX_MESA_query_renderer */\n\n#ifndef GLX_MESA_release_buffers\n#define GLX_MESA_release_buffers 1\ntypedef Bool ( *PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable);\n#endif\n#endif /* GLX_MESA_release_buffers */\n\n#ifndef GLX_MESA_set_3dfx_mode\n#define GLX_MESA_set_3dfx_mode 1\n#define GLX_3DFX_WINDOW_MODE_MESA         0x1\n#define GLX_3DFX_FULLSCREEN_MODE_MESA     0x2\ntypedef Bool ( *PFNGLXSET3DFXMODEMESAPROC) (int mode);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXSet3DfxModeMESA (int mode);\n#endif\n#endif /* GLX_MESA_set_3dfx_mode */\n\n#ifndef GLX_NV_copy_buffer\n#define GLX_NV_copy_buffer 1\ntypedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\ntypedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\nvoid glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\n#endif\n#endif /* GLX_NV_copy_buffer */\n\n#ifndef GLX_NV_copy_image\n#define GLX_NV_copy_image 1\ntypedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#endif\n#endif /* GLX_NV_copy_image */\n\n#ifndef GLX_NV_delay_before_swap\n#define GLX_NV_delay_before_swap 1\ntypedef Bool ( *PFNGLXDELAYBEFORESWAPNVPROC) (Display *dpy, GLXDrawable drawable, GLfloat seconds);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXDelayBeforeSwapNV (Display *dpy, GLXDrawable drawable, GLfloat seconds);\n#endif\n#endif /* GLX_NV_delay_before_swap */\n\n#ifndef GLX_NV_float_buffer\n#define GLX_NV_float_buffer 1\n#define GLX_FLOAT_COMPONENTS_NV           0x20B0\n#endif /* GLX_NV_float_buffer */\n\n#ifndef GLX_NV_multisample_coverage\n#define GLX_NV_multisample_coverage 1\n#define GLX_COVERAGE_SAMPLES_NV           100001\n#define GLX_COLOR_SAMPLES_NV              0x20B3\n#endif /* GLX_NV_multisample_coverage */\n\n#ifndef GLX_NV_present_video\n#define GLX_NV_present_video 1\n#define GLX_NUM_VIDEO_SLOTS_NV            0x20F0\ntypedef unsigned int *( *PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);\ntypedef int ( *PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);\n#ifdef GLX_GLXEXT_PROTOTYPES\nunsigned int *glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements);\nint glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);\n#endif\n#endif /* GLX_NV_present_video */\n\n#ifndef GLX_NV_swap_group\n#define GLX_NV_swap_group 1\ntypedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);\ntypedef Bool ( *PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);\ntypedef Bool ( *PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);\ntypedef Bool ( *PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);\ntypedef Bool ( *PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);\ntypedef Bool ( *PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group);\nBool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier);\nBool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);\nBool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);\nBool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count);\nBool glXResetFrameCountNV (Display *dpy, int screen);\n#endif\n#endif /* GLX_NV_swap_group */\n\n#ifndef GLX_NV_video_capture\n#define GLX_NV_video_capture 1\ntypedef XID GLXVideoCaptureDeviceNV;\n#define GLX_DEVICE_ID_NV                  0x20CD\n#define GLX_UNIQUE_ID_NV                  0x20CE\n#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV    0x20CF\ntypedef int ( *PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);\ntypedef GLXVideoCaptureDeviceNV *( *PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);\ntypedef void ( *PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);\ntypedef int ( *PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);\ntypedef void ( *PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);\nGLXVideoCaptureDeviceNV *glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements);\nvoid glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);\nint glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);\nvoid glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device);\n#endif\n#endif /* GLX_NV_video_capture */\n\n#ifndef GLX_NV_video_out\n#define GLX_NV_video_out 1\ntypedef unsigned int GLXVideoDeviceNV;\n#define GLX_VIDEO_OUT_COLOR_NV            0x20C3\n#define GLX_VIDEO_OUT_ALPHA_NV            0x20C4\n#define GLX_VIDEO_OUT_DEPTH_NV            0x20C5\n#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV  0x20C6\n#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV  0x20C7\n#define GLX_VIDEO_OUT_FRAME_NV            0x20C8\n#define GLX_VIDEO_OUT_FIELD_1_NV          0x20C9\n#define GLX_VIDEO_OUT_FIELD_2_NV          0x20CA\n#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB\n#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC\ntypedef int ( *PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);\ntypedef int ( *PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);\ntypedef int ( *PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);\ntypedef int ( *PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);\ntypedef int ( *PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);\ntypedef int ( *PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);\nint glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);\nint glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);\nint glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf);\nint glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);\nint glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#endif\n#endif /* GLX_NV_video_out */\n\n#ifndef GLX_OML_swap_method\n#define GLX_OML_swap_method 1\n#define GLX_SWAP_METHOD_OML               0x8060\n#define GLX_SWAP_EXCHANGE_OML             0x8061\n#define GLX_SWAP_COPY_OML                 0x8062\n#define GLX_SWAP_UNDEFINED_OML            0x8063\n#endif /* GLX_OML_swap_method */\n\n#ifndef GLX_OML_sync_control\n#define GLX_OML_sync_control 1\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GLX_OML_sync_control extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\ntypedef Bool ( *PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);\ntypedef Bool ( *PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);\ntypedef int64_t ( *PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);\ntypedef Bool ( *PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);\ntypedef Bool ( *PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);\nBool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);\nint64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);\nBool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);\nBool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);\n#endif\n#endif /* GLX_OML_sync_control */\n\n#ifndef GLX_SGIS_blended_overlay\n#define GLX_SGIS_blended_overlay 1\n#define GLX_BLENDED_RGBA_SGIS             0x8025\n#endif /* GLX_SGIS_blended_overlay */\n\n#ifndef GLX_SGIS_multisample\n#define GLX_SGIS_multisample 1\n#define GLX_SAMPLE_BUFFERS_SGIS           100000\n#define GLX_SAMPLES_SGIS                  100001\n#endif /* GLX_SGIS_multisample */\n\n#ifndef GLX_SGIS_shared_multisample\n#define GLX_SGIS_shared_multisample 1\n#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026\n#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027\n#endif /* GLX_SGIS_shared_multisample */\n\n#ifndef GLX_SGIX_dmbuffer\n#define GLX_SGIX_dmbuffer 1\ntypedef XID GLXPbufferSGIX;\n#ifdef _DM_BUFFER_H_\n#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX    0x8024\ntypedef Bool ( *PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);\n#endif\n#endif /* _DM_BUFFER_H_ */\n#endif /* GLX_SGIX_dmbuffer */\n\n#ifndef GLX_SGIX_fbconfig\n#define GLX_SGIX_fbconfig 1\ntypedef struct __GLXFBConfigRec *GLXFBConfigSGIX;\n#define GLX_WINDOW_BIT_SGIX               0x00000001\n#define GLX_PIXMAP_BIT_SGIX               0x00000002\n#define GLX_RGBA_BIT_SGIX                 0x00000001\n#define GLX_COLOR_INDEX_BIT_SGIX          0x00000002\n#define GLX_DRAWABLE_TYPE_SGIX            0x8010\n#define GLX_RENDER_TYPE_SGIX              0x8011\n#define GLX_X_RENDERABLE_SGIX             0x8012\n#define GLX_FBCONFIG_ID_SGIX              0x8013\n#define GLX_RGBA_TYPE_SGIX                0x8014\n#define GLX_COLOR_INDEX_TYPE_SGIX         0x8015\ntypedef int ( *PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);\ntypedef GLXFBConfigSGIX *( *PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);\ntypedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);\ntypedef GLXContext ( *PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);\ntypedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);\ntypedef GLXFBConfigSGIX ( *PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);\nGLXFBConfigSGIX *glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements);\nGLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);\nGLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);\nXVisualInfo *glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config);\nGLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis);\n#endif\n#endif /* GLX_SGIX_fbconfig */\n\n#ifndef GLX_SGIX_hyperpipe\n#define GLX_SGIX_hyperpipe 1\ntypedef struct {\n    char    pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */\n    int     networkId;\n} GLXHyperpipeNetworkSGIX;\ntypedef struct {\n    char    pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */\n    int     channel;\n    unsigned int participationType;\n    int     timeSlice;\n} GLXHyperpipeConfigSGIX;\ntypedef struct {\n    char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */\n    int srcXOrigin, srcYOrigin, srcWidth, srcHeight;\n    int destXOrigin, destYOrigin, destWidth, destHeight;\n} GLXPipeRect;\ntypedef struct {\n    char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */\n    int XOrigin, YOrigin, maxHeight, maxWidth;\n} GLXPipeRectLimits;\n#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80\n#define GLX_BAD_HYPERPIPE_CONFIG_SGIX     91\n#define GLX_BAD_HYPERPIPE_SGIX            92\n#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX   0x00000001\n#define GLX_HYPERPIPE_RENDER_PIPE_SGIX    0x00000002\n#define GLX_PIPE_RECT_SGIX                0x00000001\n#define GLX_PIPE_RECT_LIMITS_SGIX         0x00000002\n#define GLX_HYPERPIPE_STEREO_SGIX         0x00000003\n#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX  0x00000004\n#define GLX_HYPERPIPE_ID_SGIX             0x8030\ntypedef GLXHyperpipeNetworkSGIX *( *PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);\ntypedef int ( *PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);\ntypedef GLXHyperpipeConfigSGIX *( *PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);\ntypedef int ( *PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);\ntypedef int ( *PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);\ntypedef int ( *PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);\ntypedef int ( *PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);\ntypedef int ( *PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXHyperpipeNetworkSGIX *glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes);\nint glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);\nGLXHyperpipeConfigSGIX *glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes);\nint glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId);\nint glXBindHyperpipeSGIX (Display *dpy, int hpId);\nint glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);\nint glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList);\nint glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);\n#endif\n#endif /* GLX_SGIX_hyperpipe */\n\n#ifndef GLX_SGIX_pbuffer\n#define GLX_SGIX_pbuffer 1\n#define GLX_PBUFFER_BIT_SGIX              0x00000004\n#define GLX_BUFFER_CLOBBER_MASK_SGIX      0x08000000\n#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX    0x00000001\n#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX   0x00000002\n#define GLX_BACK_LEFT_BUFFER_BIT_SGIX     0x00000004\n#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX    0x00000008\n#define GLX_AUX_BUFFERS_BIT_SGIX          0x00000010\n#define GLX_DEPTH_BUFFER_BIT_SGIX         0x00000020\n#define GLX_STENCIL_BUFFER_BIT_SGIX       0x00000040\n#define GLX_ACCUM_BUFFER_BIT_SGIX         0x00000080\n#define GLX_SAMPLE_BUFFERS_BIT_SGIX       0x00000100\n#define GLX_MAX_PBUFFER_WIDTH_SGIX        0x8016\n#define GLX_MAX_PBUFFER_HEIGHT_SGIX       0x8017\n#define GLX_MAX_PBUFFER_PIXELS_SGIX       0x8018\n#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX    0x8019\n#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX   0x801A\n#define GLX_PRESERVED_CONTENTS_SGIX       0x801B\n#define GLX_LARGEST_PBUFFER_SGIX          0x801C\n#define GLX_WIDTH_SGIX                    0x801D\n#define GLX_HEIGHT_SGIX                   0x801E\n#define GLX_EVENT_MASK_SGIX               0x801F\n#define GLX_DAMAGED_SGIX                  0x8020\n#define GLX_SAVED_SGIX                    0x8021\n#define GLX_WINDOW_SGIX                   0x8022\n#define GLX_PBUFFER_SGIX                  0x8023\ntypedef GLXPbufferSGIX ( *PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);\ntypedef void ( *PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);\ntypedef int ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);\ntypedef void ( *PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);\ntypedef void ( *PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);\nvoid glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf);\nint glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);\nvoid glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask);\nvoid glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask);\n#endif\n#endif /* GLX_SGIX_pbuffer */\n\n#ifndef GLX_SGIX_swap_barrier\n#define GLX_SGIX_swap_barrier 1\ntypedef void ( *PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);\ntypedef Bool ( *PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier);\nBool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max);\n#endif\n#endif /* GLX_SGIX_swap_barrier */\n\n#ifndef GLX_SGIX_swap_group\n#define GLX_SGIX_swap_group 1\ntypedef void ( *PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member);\n#endif\n#endif /* GLX_SGIX_swap_group */\n\n#ifndef GLX_SGIX_video_resize\n#define GLX_SGIX_video_resize 1\n#define GLX_SYNC_FRAME_SGIX               0x00000000\n#define GLX_SYNC_SWAP_SGIX                0x00000001\ntypedef int ( *PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);\ntypedef int ( *PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);\ntypedef int ( *PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);\ntypedef int ( *PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);\ntypedef int ( *PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window);\nint glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h);\nint glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);\nint glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);\nint glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype);\n#endif\n#endif /* GLX_SGIX_video_resize */\n\n#ifndef GLX_SGIX_video_source\n#define GLX_SGIX_video_source 1\ntypedef XID GLXVideoSourceSGIX;\n#ifdef _VL_H\ntypedef GLXVideoSourceSGIX ( *PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);\ntypedef void ( *PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);\n#ifdef GLX_GLXEXT_PROTOTYPES\nGLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);\nvoid glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource);\n#endif\n#endif /* _VL_H */\n#endif /* GLX_SGIX_video_source */\n\n#ifndef GLX_SGIX_visual_select_group\n#define GLX_SGIX_visual_select_group 1\n#define GLX_VISUAL_SELECT_GROUP_SGIX      0x8028\n#endif /* GLX_SGIX_visual_select_group */\n\n#ifndef GLX_SGI_cushion\n#define GLX_SGI_cushion 1\ntypedef void ( *PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);\n#ifdef GLX_GLXEXT_PROTOTYPES\nvoid glXCushionSGI (Display *dpy, Window window, float cushion);\n#endif\n#endif /* GLX_SGI_cushion */\n\n#ifndef GLX_SGI_make_current_read\n#define GLX_SGI_make_current_read 1\ntypedef Bool ( *PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\ntypedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);\n#ifdef GLX_GLXEXT_PROTOTYPES\nBool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\nGLXDrawable glXGetCurrentReadDrawableSGI (void);\n#endif\n#endif /* GLX_SGI_make_current_read */\n\n#ifndef GLX_SGI_swap_control\n#define GLX_SGI_swap_control 1\ntypedef int ( *PFNGLXSWAPINTERVALSGIPROC) (int interval);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXSwapIntervalSGI (int interval);\n#endif\n#endif /* GLX_SGI_swap_control */\n\n#ifndef GLX_SGI_video_sync\n#define GLX_SGI_video_sync 1\ntypedef int ( *PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);\ntypedef int ( *PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);\n#ifdef GLX_GLXEXT_PROTOTYPES\nint glXGetVideoSyncSGI (unsigned int *count);\nint glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count);\n#endif\n#endif /* GLX_SGI_video_sync */\n\n#ifndef GLX_SUN_get_transparent_index\n#define GLX_SUN_get_transparent_index 1\ntypedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);\n#ifdef GLX_GLXEXT_PROTOTYPES\nStatus glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);\n#endif\n#endif /* GLX_SUN_get_transparent_index */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deps/glfw/deps/GL/wglext.h",
    "content": "#ifndef __wglext_h_\n#define __wglext_h_ 1\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Copyright (c) 2013-2014 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n/*\n** This header is generated from the Khronos OpenGL / OpenGL ES XML\n** API Registry. The current version of the Registry, generator scripts\n** used to make the header, and the header can be found at\n**   http://www.opengl.org/registry/\n**\n** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $\n*/\n\n#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)\n#define WIN32_LEAN_AND_MEAN 1\n#include <windows.h>\n#endif\n\n#define WGL_WGLEXT_VERSION 20140810\n\n/* Generated C header for:\n * API: wgl\n * Versions considered: .*\n * Versions emitted: _nomatch_^\n * Default extensions included: wgl\n * Additional extensions included: _nomatch_^\n * Extensions removed: _nomatch_^\n */\n\n#ifndef WGL_ARB_buffer_region\n#define WGL_ARB_buffer_region 1\n#define WGL_FRONT_COLOR_BUFFER_BIT_ARB    0x00000001\n#define WGL_BACK_COLOR_BUFFER_BIT_ARB     0x00000002\n#define WGL_DEPTH_BUFFER_BIT_ARB          0x00000004\n#define WGL_STENCIL_BUFFER_BIT_ARB        0x00000008\ntypedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);\ntypedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);\ntypedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);\ntypedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\n#ifdef WGL_WGLEXT_PROTOTYPES\nHANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType);\nVOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion);\nBOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height);\nBOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\n#endif\n#endif /* WGL_ARB_buffer_region */\n\n#ifndef WGL_ARB_context_flush_control\n#define WGL_ARB_context_flush_control 1\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB  0x2097\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098\n#endif /* WGL_ARB_context_flush_control */\n\n#ifndef WGL_ARB_create_context\n#define WGL_ARB_create_context 1\n#define WGL_CONTEXT_DEBUG_BIT_ARB         0x00000001\n#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002\n#define WGL_CONTEXT_MAJOR_VERSION_ARB     0x2091\n#define WGL_CONTEXT_MINOR_VERSION_ARB     0x2092\n#define WGL_CONTEXT_LAYER_PLANE_ARB       0x2093\n#define WGL_CONTEXT_FLAGS_ARB             0x2094\n#define ERROR_INVALID_VERSION_ARB         0x2095\ntypedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);\n#ifdef WGL_WGLEXT_PROTOTYPES\nHGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList);\n#endif\n#endif /* WGL_ARB_create_context */\n\n#ifndef WGL_ARB_create_context_profile\n#define WGL_ARB_create_context_profile 1\n#define WGL_CONTEXT_PROFILE_MASK_ARB      0x9126\n#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB  0x00000001\n#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\n#define ERROR_INVALID_PROFILE_ARB         0x2096\n#endif /* WGL_ARB_create_context_profile */\n\n#ifndef WGL_ARB_create_context_robustness\n#define WGL_ARB_create_context_robustness 1\n#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\n#define WGL_LOSE_CONTEXT_ON_RESET_ARB     0x8252\n#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\n#define WGL_NO_RESET_NOTIFICATION_ARB     0x8261\n#endif /* WGL_ARB_create_context_robustness */\n\n#ifndef WGL_ARB_extensions_string\n#define WGL_ARB_extensions_string 1\ntypedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);\n#ifdef WGL_WGLEXT_PROTOTYPES\nconst char *WINAPI wglGetExtensionsStringARB (HDC hdc);\n#endif\n#endif /* WGL_ARB_extensions_string */\n\n#ifndef WGL_ARB_framebuffer_sRGB\n#define WGL_ARB_framebuffer_sRGB 1\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB  0x20A9\n#endif /* WGL_ARB_framebuffer_sRGB */\n\n#ifndef WGL_ARB_make_current_read\n#define WGL_ARB_make_current_read 1\n#define ERROR_INVALID_PIXEL_TYPE_ARB      0x2043\n#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\nHDC WINAPI wglGetCurrentReadDCARB (void);\n#endif\n#endif /* WGL_ARB_make_current_read */\n\n#ifndef WGL_ARB_multisample\n#define WGL_ARB_multisample 1\n#define WGL_SAMPLE_BUFFERS_ARB            0x2041\n#define WGL_SAMPLES_ARB                   0x2042\n#endif /* WGL_ARB_multisample */\n\n#ifndef WGL_ARB_pbuffer\n#define WGL_ARB_pbuffer 1\nDECLARE_HANDLE(HPBUFFERARB);\n#define WGL_DRAW_TO_PBUFFER_ARB           0x202D\n#define WGL_MAX_PBUFFER_PIXELS_ARB        0x202E\n#define WGL_MAX_PBUFFER_WIDTH_ARB         0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_ARB        0x2030\n#define WGL_PBUFFER_LARGEST_ARB           0x2033\n#define WGL_PBUFFER_WIDTH_ARB             0x2034\n#define WGL_PBUFFER_HEIGHT_ARB            0x2035\n#define WGL_PBUFFER_LOST_ARB              0x2036\ntypedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\nHPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\nHDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer);\nint WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC);\nBOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer);\nBOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);\n#endif\n#endif /* WGL_ARB_pbuffer */\n\n#ifndef WGL_ARB_pixel_format\n#define WGL_ARB_pixel_format 1\n#define WGL_NUMBER_PIXEL_FORMATS_ARB      0x2000\n#define WGL_DRAW_TO_WINDOW_ARB            0x2001\n#define WGL_DRAW_TO_BITMAP_ARB            0x2002\n#define WGL_ACCELERATION_ARB              0x2003\n#define WGL_NEED_PALETTE_ARB              0x2004\n#define WGL_NEED_SYSTEM_PALETTE_ARB       0x2005\n#define WGL_SWAP_LAYER_BUFFERS_ARB        0x2006\n#define WGL_SWAP_METHOD_ARB               0x2007\n#define WGL_NUMBER_OVERLAYS_ARB           0x2008\n#define WGL_NUMBER_UNDERLAYS_ARB          0x2009\n#define WGL_TRANSPARENT_ARB               0x200A\n#define WGL_TRANSPARENT_RED_VALUE_ARB     0x2037\n#define WGL_TRANSPARENT_GREEN_VALUE_ARB   0x2038\n#define WGL_TRANSPARENT_BLUE_VALUE_ARB    0x2039\n#define WGL_TRANSPARENT_ALPHA_VALUE_ARB   0x203A\n#define WGL_TRANSPARENT_INDEX_VALUE_ARB   0x203B\n#define WGL_SHARE_DEPTH_ARB               0x200C\n#define WGL_SHARE_STENCIL_ARB             0x200D\n#define WGL_SHARE_ACCUM_ARB               0x200E\n#define WGL_SUPPORT_GDI_ARB               0x200F\n#define WGL_SUPPORT_OPENGL_ARB            0x2010\n#define WGL_DOUBLE_BUFFER_ARB             0x2011\n#define WGL_STEREO_ARB                    0x2012\n#define WGL_PIXEL_TYPE_ARB                0x2013\n#define WGL_COLOR_BITS_ARB                0x2014\n#define WGL_RED_BITS_ARB                  0x2015\n#define WGL_RED_SHIFT_ARB                 0x2016\n#define WGL_GREEN_BITS_ARB                0x2017\n#define WGL_GREEN_SHIFT_ARB               0x2018\n#define WGL_BLUE_BITS_ARB                 0x2019\n#define WGL_BLUE_SHIFT_ARB                0x201A\n#define WGL_ALPHA_BITS_ARB                0x201B\n#define WGL_ALPHA_SHIFT_ARB               0x201C\n#define WGL_ACCUM_BITS_ARB                0x201D\n#define WGL_ACCUM_RED_BITS_ARB            0x201E\n#define WGL_ACCUM_GREEN_BITS_ARB          0x201F\n#define WGL_ACCUM_BLUE_BITS_ARB           0x2020\n#define WGL_ACCUM_ALPHA_BITS_ARB          0x2021\n#define WGL_DEPTH_BITS_ARB                0x2022\n#define WGL_STENCIL_BITS_ARB              0x2023\n#define WGL_AUX_BUFFERS_ARB               0x2024\n#define WGL_NO_ACCELERATION_ARB           0x2025\n#define WGL_GENERIC_ACCELERATION_ARB      0x2026\n#define WGL_FULL_ACCELERATION_ARB         0x2027\n#define WGL_SWAP_EXCHANGE_ARB             0x2028\n#define WGL_SWAP_COPY_ARB                 0x2029\n#define WGL_SWAP_UNDEFINED_ARB            0x202A\n#define WGL_TYPE_RGBA_ARB                 0x202B\n#define WGL_TYPE_COLORINDEX_ARB           0x202C\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);\nBOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);\nBOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#endif\n#endif /* WGL_ARB_pixel_format */\n\n#ifndef WGL_ARB_pixel_format_float\n#define WGL_ARB_pixel_format_float 1\n#define WGL_TYPE_RGBA_FLOAT_ARB           0x21A0\n#endif /* WGL_ARB_pixel_format_float */\n\n#ifndef WGL_ARB_render_texture\n#define WGL_ARB_render_texture 1\n#define WGL_BIND_TO_TEXTURE_RGB_ARB       0x2070\n#define WGL_BIND_TO_TEXTURE_RGBA_ARB      0x2071\n#define WGL_TEXTURE_FORMAT_ARB            0x2072\n#define WGL_TEXTURE_TARGET_ARB            0x2073\n#define WGL_MIPMAP_TEXTURE_ARB            0x2074\n#define WGL_TEXTURE_RGB_ARB               0x2075\n#define WGL_TEXTURE_RGBA_ARB              0x2076\n#define WGL_NO_TEXTURE_ARB                0x2077\n#define WGL_TEXTURE_CUBE_MAP_ARB          0x2078\n#define WGL_TEXTURE_1D_ARB                0x2079\n#define WGL_TEXTURE_2D_ARB                0x207A\n#define WGL_MIPMAP_LEVEL_ARB              0x207B\n#define WGL_CUBE_MAP_FACE_ARB             0x207C\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082\n#define WGL_FRONT_LEFT_ARB                0x2083\n#define WGL_FRONT_RIGHT_ARB               0x2084\n#define WGL_BACK_LEFT_ARB                 0x2085\n#define WGL_BACK_RIGHT_ARB                0x2086\n#define WGL_AUX0_ARB                      0x2087\n#define WGL_AUX1_ARB                      0x2088\n#define WGL_AUX2_ARB                      0x2089\n#define WGL_AUX3_ARB                      0x208A\n#define WGL_AUX4_ARB                      0x208B\n#define WGL_AUX5_ARB                      0x208C\n#define WGL_AUX6_ARB                      0x208D\n#define WGL_AUX7_ARB                      0x208E\n#define WGL_AUX8_ARB                      0x208F\n#define WGL_AUX9_ARB                      0x2090\ntypedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\ntypedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\ntypedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);\nBOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer);\nBOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList);\n#endif\n#endif /* WGL_ARB_render_texture */\n\n#ifndef WGL_ARB_robustness_application_isolation\n#define WGL_ARB_robustness_application_isolation 1\n#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\n#endif /* WGL_ARB_robustness_application_isolation */\n\n#ifndef WGL_ARB_robustness_share_group_isolation\n#define WGL_ARB_robustness_share_group_isolation 1\n#endif /* WGL_ARB_robustness_share_group_isolation */\n\n#ifndef WGL_3DFX_multisample\n#define WGL_3DFX_multisample 1\n#define WGL_SAMPLE_BUFFERS_3DFX           0x2060\n#define WGL_SAMPLES_3DFX                  0x2061\n#endif /* WGL_3DFX_multisample */\n\n#ifndef WGL_3DL_stereo_control\n#define WGL_3DL_stereo_control 1\n#define WGL_STEREO_EMITTER_ENABLE_3DL     0x2055\n#define WGL_STEREO_EMITTER_DISABLE_3DL    0x2056\n#define WGL_STEREO_POLARITY_NORMAL_3DL    0x2057\n#define WGL_STEREO_POLARITY_INVERT_3DL    0x2058\ntypedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState);\n#endif\n#endif /* WGL_3DL_stereo_control */\n\n#ifndef WGL_AMD_gpu_association\n#define WGL_AMD_gpu_association 1\n#define WGL_GPU_VENDOR_AMD                0x1F00\n#define WGL_GPU_RENDERER_STRING_AMD       0x1F01\n#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\n#define WGL_GPU_FASTEST_TARGET_GPUS_AMD   0x21A2\n#define WGL_GPU_RAM_AMD                   0x21A3\n#define WGL_GPU_CLOCK_AMD                 0x21A4\n#define WGL_GPU_NUM_PIPES_AMD             0x21A5\n#define WGL_GPU_NUM_SIMD_AMD              0x21A6\n#define WGL_GPU_NUM_RB_AMD                0x21A7\n#define WGL_GPU_NUM_SPI_AMD               0x21A8\ntypedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids);\ntypedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data);\ntypedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList);\ntypedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);\ntypedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);\ntypedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);\ntypedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#ifdef WGL_WGLEXT_PROTOTYPES\nUINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids);\nINT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data);\nUINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc);\nHGLRC WINAPI wglCreateAssociatedContextAMD (UINT id);\nHGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList);\nBOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc);\nBOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc);\nHGLRC WINAPI wglGetCurrentAssociatedContextAMD (void);\nVOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#endif\n#endif /* WGL_AMD_gpu_association */\n\n#ifndef WGL_ATI_pixel_format_float\n#define WGL_ATI_pixel_format_float 1\n#define WGL_TYPE_RGBA_FLOAT_ATI           0x21A0\n#endif /* WGL_ATI_pixel_format_float */\n\n#ifndef WGL_EXT_create_context_es2_profile\n#define WGL_EXT_create_context_es2_profile 1\n#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT   0x00000004\n#endif /* WGL_EXT_create_context_es2_profile */\n\n#ifndef WGL_EXT_create_context_es_profile\n#define WGL_EXT_create_context_es_profile 1\n#define WGL_CONTEXT_ES_PROFILE_BIT_EXT    0x00000004\n#endif /* WGL_EXT_create_context_es_profile */\n\n#ifndef WGL_EXT_depth_float\n#define WGL_EXT_depth_float 1\n#define WGL_DEPTH_FLOAT_EXT               0x2040\n#endif /* WGL_EXT_depth_float */\n\n#ifndef WGL_EXT_display_color_table\n#define WGL_EXT_display_color_table 1\ntypedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);\ntypedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);\ntypedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);\ntypedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);\n#ifdef WGL_WGLEXT_PROTOTYPES\nGLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id);\nGLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length);\nGLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id);\nVOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id);\n#endif\n#endif /* WGL_EXT_display_color_table */\n\n#ifndef WGL_EXT_extensions_string\n#define WGL_EXT_extensions_string 1\ntypedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\nconst char *WINAPI wglGetExtensionsStringEXT (void);\n#endif\n#endif /* WGL_EXT_extensions_string */\n\n#ifndef WGL_EXT_framebuffer_sRGB\n#define WGL_EXT_framebuffer_sRGB 1\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT  0x20A9\n#endif /* WGL_EXT_framebuffer_sRGB */\n\n#ifndef WGL_EXT_make_current_read\n#define WGL_EXT_make_current_read 1\n#define ERROR_INVALID_PIXEL_TYPE_EXT      0x2043\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\nHDC WINAPI wglGetCurrentReadDCEXT (void);\n#endif\n#endif /* WGL_EXT_make_current_read */\n\n#ifndef WGL_EXT_multisample\n#define WGL_EXT_multisample 1\n#define WGL_SAMPLE_BUFFERS_EXT            0x2041\n#define WGL_SAMPLES_EXT                   0x2042\n#endif /* WGL_EXT_multisample */\n\n#ifndef WGL_EXT_pbuffer\n#define WGL_EXT_pbuffer 1\nDECLARE_HANDLE(HPBUFFEREXT);\n#define WGL_DRAW_TO_PBUFFER_EXT           0x202D\n#define WGL_MAX_PBUFFER_PIXELS_EXT        0x202E\n#define WGL_MAX_PBUFFER_WIDTH_EXT         0x202F\n#define WGL_MAX_PBUFFER_HEIGHT_EXT        0x2030\n#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT     0x2031\n#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT    0x2032\n#define WGL_PBUFFER_LARGEST_EXT           0x2033\n#define WGL_PBUFFER_WIDTH_EXT             0x2034\n#define WGL_PBUFFER_HEIGHT_EXT            0x2035\ntypedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\nHPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);\nHDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer);\nint WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC);\nBOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer);\nBOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);\n#endif\n#endif /* WGL_EXT_pbuffer */\n\n#ifndef WGL_EXT_pixel_format\n#define WGL_EXT_pixel_format 1\n#define WGL_NUMBER_PIXEL_FORMATS_EXT      0x2000\n#define WGL_DRAW_TO_WINDOW_EXT            0x2001\n#define WGL_DRAW_TO_BITMAP_EXT            0x2002\n#define WGL_ACCELERATION_EXT              0x2003\n#define WGL_NEED_PALETTE_EXT              0x2004\n#define WGL_NEED_SYSTEM_PALETTE_EXT       0x2005\n#define WGL_SWAP_LAYER_BUFFERS_EXT        0x2006\n#define WGL_SWAP_METHOD_EXT               0x2007\n#define WGL_NUMBER_OVERLAYS_EXT           0x2008\n#define WGL_NUMBER_UNDERLAYS_EXT          0x2009\n#define WGL_TRANSPARENT_EXT               0x200A\n#define WGL_TRANSPARENT_VALUE_EXT         0x200B\n#define WGL_SHARE_DEPTH_EXT               0x200C\n#define WGL_SHARE_STENCIL_EXT             0x200D\n#define WGL_SHARE_ACCUM_EXT               0x200E\n#define WGL_SUPPORT_GDI_EXT               0x200F\n#define WGL_SUPPORT_OPENGL_EXT            0x2010\n#define WGL_DOUBLE_BUFFER_EXT             0x2011\n#define WGL_STEREO_EXT                    0x2012\n#define WGL_PIXEL_TYPE_EXT                0x2013\n#define WGL_COLOR_BITS_EXT                0x2014\n#define WGL_RED_BITS_EXT                  0x2015\n#define WGL_RED_SHIFT_EXT                 0x2016\n#define WGL_GREEN_BITS_EXT                0x2017\n#define WGL_GREEN_SHIFT_EXT               0x2018\n#define WGL_BLUE_BITS_EXT                 0x2019\n#define WGL_BLUE_SHIFT_EXT                0x201A\n#define WGL_ALPHA_BITS_EXT                0x201B\n#define WGL_ALPHA_SHIFT_EXT               0x201C\n#define WGL_ACCUM_BITS_EXT                0x201D\n#define WGL_ACCUM_RED_BITS_EXT            0x201E\n#define WGL_ACCUM_GREEN_BITS_EXT          0x201F\n#define WGL_ACCUM_BLUE_BITS_EXT           0x2020\n#define WGL_ACCUM_ALPHA_BITS_EXT          0x2021\n#define WGL_DEPTH_BITS_EXT                0x2022\n#define WGL_STENCIL_BITS_EXT              0x2023\n#define WGL_AUX_BUFFERS_EXT               0x2024\n#define WGL_NO_ACCELERATION_EXT           0x2025\n#define WGL_GENERIC_ACCELERATION_EXT      0x2026\n#define WGL_FULL_ACCELERATION_EXT         0x2027\n#define WGL_SWAP_EXCHANGE_EXT             0x2028\n#define WGL_SWAP_COPY_EXT                 0x2029\n#define WGL_SWAP_UNDEFINED_EXT            0x202A\n#define WGL_TYPE_RGBA_EXT                 0x202B\n#define WGL_TYPE_COLORINDEX_EXT           0x202C\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);\nBOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);\nBOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\n#endif\n#endif /* WGL_EXT_pixel_format */\n\n#ifndef WGL_EXT_pixel_format_packed_float\n#define WGL_EXT_pixel_format_packed_float 1\n#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT  0x20A8\n#endif /* WGL_EXT_pixel_format_packed_float */\n\n#ifndef WGL_EXT_swap_control\n#define WGL_EXT_swap_control 1\ntypedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);\ntypedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglSwapIntervalEXT (int interval);\nint WINAPI wglGetSwapIntervalEXT (void);\n#endif\n#endif /* WGL_EXT_swap_control */\n\n#ifndef WGL_EXT_swap_control_tear\n#define WGL_EXT_swap_control_tear 1\n#endif /* WGL_EXT_swap_control_tear */\n\n#ifndef WGL_I3D_digital_video_control\n#define WGL_I3D_digital_video_control 1\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051\n#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052\n#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053\ntypedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);\ntypedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue);\nBOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue);\n#endif\n#endif /* WGL_I3D_digital_video_control */\n\n#ifndef WGL_I3D_gamma\n#define WGL_I3D_gamma 1\n#define WGL_GAMMA_TABLE_SIZE_I3D          0x204E\n#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D     0x204F\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue);\nBOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue);\nBOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);\nBOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);\n#endif\n#endif /* WGL_I3D_gamma */\n\n#ifndef WGL_I3D_genlock\n#define WGL_I3D_genlock 1\n#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D  0x2044\n#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045\n#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046\n#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047\n#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048\n#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049\n#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A\n#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B\n#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D  0x204C\ntypedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);\ntypedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);\ntypedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglEnableGenlockI3D (HDC hDC);\nBOOL WINAPI wglDisableGenlockI3D (HDC hDC);\nBOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag);\nBOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource);\nBOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource);\nBOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge);\nBOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge);\nBOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate);\nBOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate);\nBOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay);\nBOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay);\nBOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);\n#endif\n#endif /* WGL_I3D_genlock */\n\n#ifndef WGL_I3D_image_buffer\n#define WGL_I3D_image_buffer 1\n#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D   0x00000001\n#define WGL_IMAGE_BUFFER_LOCK_I3D         0x00000002\ntypedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);\ntypedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);\ntypedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);\ntypedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);\n#ifdef WGL_WGLEXT_PROTOTYPES\nLPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags);\nBOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress);\nBOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);\nBOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count);\n#endif\n#endif /* WGL_I3D_image_buffer */\n\n#ifndef WGL_I3D_swap_frame_lock\n#define WGL_I3D_swap_frame_lock 1\ntypedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglEnableFrameLockI3D (void);\nBOOL WINAPI wglDisableFrameLockI3D (void);\nBOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag);\nBOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag);\n#endif\n#endif /* WGL_I3D_swap_frame_lock */\n\n#ifndef WGL_I3D_swap_frame_usage\n#define WGL_I3D_swap_frame_usage 1\ntypedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);\ntypedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetFrameUsageI3D (float *pUsage);\nBOOL WINAPI wglBeginFrameTrackingI3D (void);\nBOOL WINAPI wglEndFrameTrackingI3D (void);\nBOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\n#endif\n#endif /* WGL_I3D_swap_frame_usage */\n\n#ifndef WGL_NV_DX_interop\n#define WGL_NV_DX_interop 1\n#define WGL_ACCESS_READ_ONLY_NV           0x00000000\n#define WGL_ACCESS_READ_WRITE_NV          0x00000001\n#define WGL_ACCESS_WRITE_DISCARD_NV       0x00000002\ntypedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle);\ntypedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice);\ntypedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);\ntypedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);\ntypedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);\ntypedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);\ntypedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);\ntypedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle);\nHANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice);\nBOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice);\nHANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);\nBOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject);\nBOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access);\nBOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);\nBOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects);\n#endif\n#endif /* WGL_NV_DX_interop */\n\n#ifndef WGL_NV_DX_interop2\n#define WGL_NV_DX_interop2 1\n#endif /* WGL_NV_DX_interop2 */\n\n#ifndef WGL_NV_copy_image\n#define WGL_NV_copy_image 1\ntypedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\n#endif\n#endif /* WGL_NV_copy_image */\n\n#ifndef WGL_NV_delay_before_swap\n#define WGL_NV_delay_before_swap 1\ntypedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds);\n#endif\n#endif /* WGL_NV_delay_before_swap */\n\n#ifndef WGL_NV_float_buffer\n#define WGL_NV_float_buffer 1\n#define WGL_FLOAT_COMPONENTS_NV           0x20B0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4\n#define WGL_TEXTURE_FLOAT_R_NV            0x20B5\n#define WGL_TEXTURE_FLOAT_RG_NV           0x20B6\n#define WGL_TEXTURE_FLOAT_RGB_NV          0x20B7\n#define WGL_TEXTURE_FLOAT_RGBA_NV         0x20B8\n#endif /* WGL_NV_float_buffer */\n\n#ifndef WGL_NV_gpu_affinity\n#define WGL_NV_gpu_affinity 1\nDECLARE_HANDLE(HGPUNV);\nstruct _GPU_DEVICE {\n    DWORD  cb;\n    CHAR   DeviceName[32];\n    CHAR   DeviceString[128];\n    DWORD  Flags;\n    RECT   rcVirtualScreen;\n};\ntypedef struct _GPU_DEVICE *PGPU_DEVICE;\n#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0\n#define ERROR_MISSING_AFFINITY_MASK_NV    0x20D1\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);\ntypedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\ntypedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\ntypedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu);\nBOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\nHDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList);\nBOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\nBOOL WINAPI wglDeleteDCNV (HDC hdc);\n#endif\n#endif /* WGL_NV_gpu_affinity */\n\n#ifndef WGL_NV_multisample_coverage\n#define WGL_NV_multisample_coverage 1\n#define WGL_COVERAGE_SAMPLES_NV           0x2042\n#define WGL_COLOR_SAMPLES_NV              0x20B9\n#endif /* WGL_NV_multisample_coverage */\n\n#ifndef WGL_NV_present_video\n#define WGL_NV_present_video 1\nDECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);\n#define WGL_NUM_VIDEO_SLOTS_NV            0x20F0\ntypedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);\ntypedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);\n#ifdef WGL_WGLEXT_PROTOTYPES\nint WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList);\nBOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList);\nBOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue);\n#endif\n#endif /* WGL_NV_present_video */\n\n#ifndef WGL_NV_render_depth_texture\n#define WGL_NV_render_depth_texture 1\n#define WGL_BIND_TO_TEXTURE_DEPTH_NV      0x20A3\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4\n#define WGL_DEPTH_TEXTURE_FORMAT_NV       0x20A5\n#define WGL_TEXTURE_DEPTH_COMPONENT_NV    0x20A6\n#define WGL_DEPTH_COMPONENT_NV            0x20A7\n#endif /* WGL_NV_render_depth_texture */\n\n#ifndef WGL_NV_render_texture_rectangle\n#define WGL_NV_render_texture_rectangle 1\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1\n#define WGL_TEXTURE_RECTANGLE_NV          0x20A2\n#endif /* WGL_NV_render_texture_rectangle */\n\n#ifndef WGL_NV_swap_group\n#define WGL_NV_swap_group 1\ntypedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);\ntypedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);\ntypedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier);\ntypedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count);\ntypedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group);\nBOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier);\nBOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier);\nBOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers);\nBOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count);\nBOOL WINAPI wglResetFrameCountNV (HDC hDC);\n#endif\n#endif /* WGL_NV_swap_group */\n\n#ifndef WGL_NV_vertex_array_range\n#define WGL_NV_vertex_array_range 1\ntypedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);\ntypedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);\n#ifdef WGL_WGLEXT_PROTOTYPES\nvoid *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);\nvoid WINAPI wglFreeMemoryNV (void *pointer);\n#endif\n#endif /* WGL_NV_vertex_array_range */\n\n#ifndef WGL_NV_video_capture\n#define WGL_NV_video_capture 1\nDECLARE_HANDLE(HVIDEOINPUTDEVICENV);\n#define WGL_UNIQUE_ID_NV                  0x20CE\n#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV    0x20CF\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\ntypedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);\ntypedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\ntypedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\nUINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);\nBOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\nBOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);\nBOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\n#endif\n#endif /* WGL_NV_video_capture */\n\n#ifndef WGL_NV_video_output\n#define WGL_NV_video_output 1\nDECLARE_HANDLE(HPVIDEODEV);\n#define WGL_BIND_TO_VIDEO_RGB_NV          0x20C0\n#define WGL_BIND_TO_VIDEO_RGBA_NV         0x20C1\n#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2\n#define WGL_VIDEO_OUT_COLOR_NV            0x20C3\n#define WGL_VIDEO_OUT_ALPHA_NV            0x20C4\n#define WGL_VIDEO_OUT_DEPTH_NV            0x20C5\n#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV  0x20C6\n#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV  0x20C7\n#define WGL_VIDEO_OUT_FRAME               0x20C8\n#define WGL_VIDEO_OUT_FIELD_1             0x20C9\n#define WGL_VIDEO_OUT_FIELD_2             0x20CA\n#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2  0x20CB\n#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1  0x20CC\ntypedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);\ntypedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);\ntypedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice);\nBOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice);\nBOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\nBOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer);\nBOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock);\nBOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\n#endif\n#endif /* WGL_NV_video_output */\n\n#ifndef WGL_OML_sync_control\n#define WGL_OML_sync_control 1\ntypedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);\ntypedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);\ntypedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\ntypedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\ntypedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);\ntypedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);\n#ifdef WGL_WGLEXT_PROTOTYPES\nBOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);\nBOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator);\nINT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\nINT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\nBOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);\nBOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);\n#endif\n#endif /* WGL_OML_sync_control */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deps/glfw/deps/KHR/khrplatform.h",
    "content": "#ifndef __khrplatform_h_\n#define __khrplatform_h_\n\n/*\n** Copyright (c) 2008-2009 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n/* Khronos platform-specific types and definitions.\n *\n * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $\n *\n * Adopters may modify this file to suit their platform. Adopters are\n * encouraged to submit platform specific modifications to the Khronos\n * group so that they can be included in future versions of this file.\n * Please submit changes by sending them to the public Khronos Bugzilla\n * (http://khronos.org/bugzilla) by filing a bug against product\n * \"Khronos (general)\" component \"Registry\".\n *\n * A predefined template which fills in some of the bug fields can be\n * reached using http://tinyurl.com/khrplatform-h-bugreport, but you\n * must create a Bugzilla login first.\n *\n *\n * See the Implementer's Guidelines for information about where this file\n * should be located on your system and for more details of its use:\n *    http://www.khronos.org/registry/implementers_guide.pdf\n *\n * This file should be included as\n *        #include <KHR/khrplatform.h>\n * by Khronos client API header files that use its types and defines.\n *\n * The types in khrplatform.h should only be used to define API-specific types.\n *\n * Types defined in khrplatform.h:\n *    khronos_int8_t              signed   8  bit\n *    khronos_uint8_t             unsigned 8  bit\n *    khronos_int16_t             signed   16 bit\n *    khronos_uint16_t            unsigned 16 bit\n *    khronos_int32_t             signed   32 bit\n *    khronos_uint32_t            unsigned 32 bit\n *    khronos_int64_t             signed   64 bit\n *    khronos_uint64_t            unsigned 64 bit\n *    khronos_intptr_t            signed   same number of bits as a pointer\n *    khronos_uintptr_t           unsigned same number of bits as a pointer\n *    khronos_ssize_t             signed   size\n *    khronos_usize_t             unsigned size\n *    khronos_float_t             signed   32 bit floating point\n *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds\n *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in\n *                                         nanoseconds\n *    khronos_stime_nanoseconds_t signed time interval in nanoseconds\n *    khronos_boolean_enum_t      enumerated boolean type. This should\n *      only be used as a base type when a client API's boolean type is\n *      an enum. Client APIs which use an integer or other type for\n *      booleans cannot use this as the base type for their boolean.\n *\n * Tokens defined in khrplatform.h:\n *\n *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.\n *\n *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.\n *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.\n *\n * Calling convention macros defined in this file:\n *    KHRONOS_APICALL\n *    KHRONOS_APIENTRY\n *    KHRONOS_APIATTRIBUTES\n *\n * These may be used in function prototypes as:\n *\n *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(\n *                                  int arg1,\n *                                  int arg2) KHRONOS_APIATTRIBUTES;\n */\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APICALL\n *-------------------------------------------------------------------------\n * This precedes the return type of the function in the function prototype.\n */\n#if defined(_WIN32) && !defined(__SCITECH_SNAP__)\n#   define KHRONOS_APICALL __declspec(dllimport)\n#elif defined (__SYMBIAN32__)\n#   define KHRONOS_APICALL IMPORT_C\n#else\n#   define KHRONOS_APICALL\n#endif\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APIENTRY\n *-------------------------------------------------------------------------\n * This follows the return type of the function  and precedes the function\n * name in the function prototype.\n */\n#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)\n    /* Win32 but not WinCE */\n#   define KHRONOS_APIENTRY __stdcall\n#else\n#   define KHRONOS_APIENTRY\n#endif\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APIATTRIBUTES\n *-------------------------------------------------------------------------\n * This follows the closing parenthesis of the function prototype arguments.\n */\n#if defined (__ARMCC_2__)\n#define KHRONOS_APIATTRIBUTES __softfp\n#else\n#define KHRONOS_APIATTRIBUTES\n#endif\n\n/*-------------------------------------------------------------------------\n * basic type definitions\n *-----------------------------------------------------------------------*/\n#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)\n\n\n/*\n * Using <stdint.h>\n */\n#include <stdint.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(__VMS ) || defined(__sgi)\n\n/*\n * Using <inttypes.h>\n */\n#include <inttypes.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)\n\n/*\n * Win32\n */\ntypedef __int32                 khronos_int32_t;\ntypedef unsigned __int32        khronos_uint32_t;\ntypedef __int64                 khronos_int64_t;\ntypedef unsigned __int64        khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(__sun__) || defined(__digital__)\n\n/*\n * Sun or Digital\n */\ntypedef int                     khronos_int32_t;\ntypedef unsigned int            khronos_uint32_t;\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int                khronos_int64_t;\ntypedef unsigned long int       khronos_uint64_t;\n#else\ntypedef long long int           khronos_int64_t;\ntypedef unsigned long long int  khronos_uint64_t;\n#endif /* __arch64__ */\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif 0\n\n/*\n * Hypothetical platform with no float or int64 support\n */\ntypedef int                     khronos_int32_t;\ntypedef unsigned int            khronos_uint32_t;\n#define KHRONOS_SUPPORT_INT64   0\n#define KHRONOS_SUPPORT_FLOAT   0\n\n#else\n\n/*\n * Generic fallback\n */\n#include <stdint.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#endif\n\n\n/*\n * Types that are (so far) the same on all platforms\n */\ntypedef signed   char          khronos_int8_t;\ntypedef unsigned char          khronos_uint8_t;\ntypedef signed   short int     khronos_int16_t;\ntypedef unsigned short int     khronos_uint16_t;\n\n/*\n * Types that differ between LLP64 and LP64 architectures - in LLP64, \n * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears\n * to be the only LLP64 architecture in current use.\n */\n#ifdef _WIN64\ntypedef signed   long long int khronos_intptr_t;\ntypedef unsigned long long int khronos_uintptr_t;\ntypedef signed   long long int khronos_ssize_t;\ntypedef unsigned long long int khronos_usize_t;\n#else\ntypedef signed   long  int     khronos_intptr_t;\ntypedef unsigned long  int     khronos_uintptr_t;\ntypedef signed   long  int     khronos_ssize_t;\ntypedef unsigned long  int     khronos_usize_t;\n#endif\n\n#if KHRONOS_SUPPORT_FLOAT\n/*\n * Float type\n */\ntypedef          float         khronos_float_t;\n#endif\n\n#if KHRONOS_SUPPORT_INT64\n/* Time types\n *\n * These types can be used to represent a time interval in nanoseconds or\n * an absolute Unadjusted System Time.  Unadjusted System Time is the number\n * of nanoseconds since some arbitrary system event (e.g. since the last\n * time the system booted).  The Unadjusted System Time is an unsigned\n * 64 bit value that wraps back to 0 every 584 years.  Time intervals\n * may be either signed or unsigned.\n */\ntypedef khronos_uint64_t       khronos_utime_nanoseconds_t;\ntypedef khronos_int64_t        khronos_stime_nanoseconds_t;\n#endif\n\n/*\n * Dummy value used to pad enum types to 32 bits.\n */\n#ifndef KHRONOS_MAX_ENUM\n#define KHRONOS_MAX_ENUM 0x7FFFFFFF\n#endif\n\n/*\n * Enumerated boolean type\n *\n * Values other than zero should be considered to be true.  Therefore\n * comparisons should not be made against KHRONOS_TRUE.\n */\ntypedef enum {\n    KHRONOS_FALSE = 0,\n    KHRONOS_TRUE  = 1,\n    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM\n} khronos_boolean_enum_t;\n\n#endif /* __khrplatform_h_ */\n"
  },
  {
    "path": "deps/glfw/deps/getopt.c",
    "content": "/* Copyright (c) 2012, Kim Gräsman\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *  * Redistributions of source code must retain the above copyright notice,\n *    this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *  * Neither the name of Kim Gräsman nor the names of contributors may be used\n *    to endorse or promote products derived from this software without specific\n *    prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include \"getopt.h\"\n\n#include <stddef.h>\n#include <string.h>\n\nconst int no_argument = 0;\nconst int required_argument = 1;\nconst int optional_argument = 2;\n\nchar* optarg;\nint optopt;\n/* The variable optind [...] shall be initialized to 1 by the system. */\nint optind = 1;\nint opterr;\n\nstatic char* optcursor = NULL;\n\n/* Implemented based on [1] and [2] for optional arguments.\n   optopt is handled FreeBSD-style, per [3].\n   Other GNU and FreeBSD extensions are purely accidental.\n\n[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html\n[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html\n[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE\n*/\nint getopt(int argc, char* const argv[], const char* optstring) {\n  int optchar = -1;\n  const char* optdecl = NULL;\n\n  optarg = NULL;\n  opterr = 0;\n  optopt = 0;\n\n  /* Unspecified, but we need it to avoid overrunning the argv bounds. */\n  if (optind >= argc)\n    goto no_more_optchars;\n\n  /* If, when getopt() is called argv[optind] is a null pointer, getopt()\n     shall return -1 without changing optind. */\n  if (argv[optind] == NULL)\n    goto no_more_optchars;\n\n  /* If, when getopt() is called *argv[optind]  is not the character '-',\n     getopt() shall return -1 without changing optind. */\n  if (*argv[optind] != '-')\n    goto no_more_optchars;\n\n  /* If, when getopt() is called argv[optind] points to the string \"-\",\n     getopt() shall return -1 without changing optind. */\n  if (strcmp(argv[optind], \"-\") == 0)\n    goto no_more_optchars;\n\n  /* If, when getopt() is called argv[optind] points to the string \"--\",\n     getopt() shall return -1 after incrementing optind. */\n  if (strcmp(argv[optind], \"--\") == 0) {\n    ++optind;\n    goto no_more_optchars;\n  }\n\n  if (optcursor == NULL || *optcursor == '\\0')\n    optcursor = argv[optind] + 1;\n\n  optchar = *optcursor;\n\n  /* FreeBSD: The variable optopt saves the last known option character\n     returned by getopt(). */\n  optopt = optchar;\n\n  /* The getopt() function shall return the next option character (if one is\n     found) from argv that matches a character in optstring, if there is\n     one that matches. */\n  optdecl = strchr(optstring, optchar);\n  if (optdecl) {\n    /* [I]f a character is followed by a colon, the option takes an\n       argument. */\n    if (optdecl[1] == ':') {\n      optarg = ++optcursor;\n      if (*optarg == '\\0') {\n        /* GNU extension: Two colons mean an option takes an\n           optional arg; if there is text in the current argv-element\n           (i.e., in the same word as the option name itself, for example,\n           \"-oarg\"), then it is returned in optarg, otherwise optarg is set\n           to zero. */\n        if (optdecl[2] != ':') {\n          /* If the option was the last character in the string pointed to by\n             an element of argv, then optarg shall contain the next element\n             of argv, and optind shall be incremented by 2. If the resulting\n             value of optind is greater than argc, this indicates a missing\n             option-argument, and getopt() shall return an error indication.\n\n             Otherwise, optarg shall point to the string following the\n             option character in that element of argv, and optind shall be\n             incremented by 1.\n          */\n          if (++optind < argc) {\n            optarg = argv[optind];\n          } else {\n            /* If it detects a missing option-argument, it shall return the\n               colon character ( ':' ) if the first character of optstring\n               was a colon, or a question-mark character ( '?' ) otherwise.\n            */\n            optarg = NULL;\n            optchar = (optstring[0] == ':') ? ':' : '?';\n          }\n        } else {\n          optarg = NULL;\n        }\n      }\n\n      optcursor = NULL;\n    }\n  } else {\n    /* If getopt() encounters an option character that is not contained in\n       optstring, it shall return the question-mark ( '?' ) character. */\n    optchar = '?';\n  }\n\n  if (optcursor == NULL || *++optcursor == '\\0')\n    ++optind;\n\n  return optchar;\n\nno_more_optchars:\n  optcursor = NULL;\n  return -1;\n}\n\n/* Implementation based on [1].\n\n[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html\n*/\nint getopt_long(int argc, char* const argv[], const char* optstring,\n  const struct option* longopts, int* longindex) {\n  const struct option* o = longopts;\n  const struct option* match = NULL;\n  int num_matches = 0;\n  size_t argument_name_length = 0;\n  const char* current_argument = NULL;\n  int retval = -1;\n\n  optarg = NULL;\n  optopt = 0;\n\n  if (optind >= argc)\n    return -1;\n\n  if (strlen(argv[optind]) < 3 || strncmp(argv[optind], \"--\", 2) != 0)\n    return getopt(argc, argv, optstring);\n\n  /* It's an option; starts with -- and is longer than two chars. */\n  current_argument = argv[optind] + 2;\n  argument_name_length = strcspn(current_argument, \"=\");\n  for (; o->name; ++o) {\n    if (strncmp(o->name, current_argument, argument_name_length) == 0) {\n      match = o;\n      ++num_matches;\n    }\n  }\n\n  if (num_matches == 1) {\n    /* If longindex is not NULL, it points to a variable which is set to the\n       index of the long option relative to longopts. */\n    if (longindex)\n      *longindex = (int) (match - longopts);\n\n    /* If flag is NULL, then getopt_long() shall return val.\n       Otherwise, getopt_long() returns 0, and flag shall point to a variable\n       which shall be set to val if the option is found, but left unchanged if\n       the option is not found. */\n    if (match->flag)\n      *(match->flag) = match->val;\n\n    retval = match->flag ? 0 : match->val;\n\n    if (match->has_arg != no_argument) {\n      optarg = strchr(argv[optind], '=');\n      if (optarg != NULL)\n        ++optarg;\n\n      if (match->has_arg == required_argument) {\n        /* Only scan the next argv for required arguments. Behavior is not\n           specified, but has been observed with Ubuntu and Mac OSX. */\n        if (optarg == NULL && ++optind < argc) {\n          optarg = argv[optind];\n        }\n\n        if (optarg == NULL)\n          retval = ':';\n      }\n    } else if (strchr(argv[optind], '=')) {\n      /* An argument was provided to a non-argument option.\n         I haven't seen this specified explicitly, but both GNU and BSD-based\n         implementations show this behavior.\n      */\n      retval = '?';\n    }\n  } else {\n    /* Unknown option or ambiguous match. */\n    retval = '?';\n  }\n\n  ++optind;\n  return retval;\n}\n"
  },
  {
    "path": "deps/glfw/deps/getopt.h",
    "content": "/* Copyright (c) 2012, Kim Gräsman\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *  * Redistributions of source code must retain the above copyright notice,\n *    this list of conditions and the following disclaimer.\n *  * Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *  * Neither the name of Kim Gräsman nor the names of contributors may be used\n *    to endorse or promote products derived from this software without specific\n *    prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef INCLUDED_GETOPT_PORT_H\n#define INCLUDED_GETOPT_PORT_H\n\n#if defined(__cplusplus)\nextern \"C\" {\n#endif\n\nextern const int no_argument;\nextern const int required_argument;\nextern const int optional_argument;\n\nextern char* optarg;\nextern int optind, opterr, optopt;\n\nstruct option {\n  const char* name;\n  int has_arg;\n  int* flag;\n  int val;\n};\n\nint getopt(int argc, char* const argv[], const char* optstring);\n\nint getopt_long(int argc, char* const argv[],\n  const char* optstring, const struct option* longopts, int* longindex);\n\n#if defined(__cplusplus)\n}\n#endif\n\n#endif // INCLUDED_GETOPT_PORT_H\n"
  },
  {
    "path": "deps/glfw/deps/glad/glad.h",
    "content": "\n#ifndef __glad_h_\n\n#ifdef __gl_h_\n#error OpenGL header already included, remove this include, glad already provides it\n#endif\n\n#define __glad_h_\n#define __gl_h_\n\n#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN 1\n#endif\n#include <windows.h>\n#endif\n\n#ifndef APIENTRY\n#define APIENTRY\n#endif\n#ifndef APIENTRYP\n#define APIENTRYP APIENTRY *\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct gladGLversionStruct {\n    int major;\n    int minor;\n};\n\nextern struct gladGLversionStruct GLVersion;\n\ntypedef void* (* GLADloadproc)(const char *name);\n\n#ifndef GLAPI\n# if defined(GLAD_GLAPI_EXPORT)\n#  if defined(WIN32) || defined(__CYGWIN__)\n#   if defined(GLAD_GLAPI_EXPORT_BUILD)\n#    if defined(__GNUC__)\n#     define GLAPI __attribute__ ((dllexport)) extern\n#    else\n#     define GLAPI __declspec(dllexport) extern\n#    endif\n#   else\n#    if defined(__GNUC__)\n#     define GLAPI __attribute__ ((dllimport)) extern\n#    else\n#     define GLAPI __declspec(dllimport) extern\n#    endif\n#   endif\n#  elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)\n#   define GLAPI __attribute__ ((visibility (\"default\"))) extern\n#  else\n#   define GLAPI extern\n#  endif\n# else\n#  define GLAPI extern\n# endif\n#endif\nGLAPI int gladLoadGLLoader(GLADloadproc);\n\n#include <stddef.h>\n#include <KHR/khrplatform.h>\n#ifndef GLEXT_64_TYPES_DEFINED\n/* This code block is duplicated in glxext.h, so must be protected */\n#define GLEXT_64_TYPES_DEFINED\n/* Define int32_t, int64_t, and uint64_t types for UST/MSC */\n/* (as used in the GL_EXT_timer_query extension). */\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n#include <inttypes.h>\n#elif defined(__sun__) || defined(__digital__)\n#include <inttypes.h>\n#if defined(__STDC__)\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int int64_t;\ntypedef unsigned long int uint64_t;\n#else\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#endif /* __arch64__ */\n#endif /* __STDC__ */\n#elif defined( __VMS ) || defined(__sgi)\n#include <inttypes.h>\n#elif defined(__SCO__) || defined(__USLC__)\n#include <stdint.h>\n#elif defined(__UNIXOS2__) || defined(__SOL64__)\ntypedef long int int32_t;\ntypedef long long int int64_t;\ntypedef unsigned long long int uint64_t;\n#elif defined(_WIN32) && defined(__GNUC__)\n#include <stdint.h>\n#elif defined(_WIN32)\ntypedef __int32 int32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n#else\n/* Fallback if nothing above works */\n#include <inttypes.h>\n#endif\n#endif\ntypedef unsigned int GLenum;\ntypedef unsigned char GLboolean;\ntypedef unsigned int GLbitfield;\ntypedef void GLvoid;\ntypedef signed char GLbyte;\ntypedef short GLshort;\ntypedef int GLint;\ntypedef int GLclampx;\ntypedef unsigned char GLubyte;\ntypedef unsigned short GLushort;\ntypedef unsigned int GLuint;\ntypedef int GLsizei;\ntypedef float GLfloat;\ntypedef float GLclampf;\ntypedef double GLdouble;\ntypedef double GLclampd;\ntypedef void *GLeglImageOES;\ntypedef char GLchar;\ntypedef char GLcharARB;\n#ifdef __APPLE__\ntypedef void *GLhandleARB;\n#else\ntypedef unsigned int GLhandleARB;\n#endif\ntypedef unsigned short GLhalfARB;\ntypedef unsigned short GLhalf;\ntypedef GLint GLfixed;\ntypedef ptrdiff_t GLintptr;\ntypedef ptrdiff_t GLsizeiptr;\ntypedef int64_t GLint64;\ntypedef uint64_t GLuint64;\ntypedef ptrdiff_t GLintptrARB;\ntypedef ptrdiff_t GLsizeiptrARB;\ntypedef int64_t GLint64EXT;\ntypedef uint64_t GLuint64EXT;\ntypedef struct __GLsync *GLsync;\nstruct _cl_context;\nstruct _cl_event;\ntypedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\ntypedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\ntypedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);\ntypedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);\ntypedef unsigned short GLhalfNV;\ntypedef GLintptr GLvdpauSurfaceNV;\n#define GL_DEPTH_BUFFER_BIT 0x00000100\n#define GL_STENCIL_BUFFER_BIT 0x00000400\n#define GL_COLOR_BUFFER_BIT 0x00004000\n#define GL_FALSE 0\n#define GL_TRUE 1\n#define GL_POINTS 0x0000\n#define GL_LINES 0x0001\n#define GL_LINE_LOOP 0x0002\n#define GL_LINE_STRIP 0x0003\n#define GL_TRIANGLES 0x0004\n#define GL_TRIANGLE_STRIP 0x0005\n#define GL_TRIANGLE_FAN 0x0006\n#define GL_NEVER 0x0200\n#define GL_LESS 0x0201\n#define GL_EQUAL 0x0202\n#define GL_LEQUAL 0x0203\n#define GL_GREATER 0x0204\n#define GL_NOTEQUAL 0x0205\n#define GL_GEQUAL 0x0206\n#define GL_ALWAYS 0x0207\n#define GL_ZERO 0\n#define GL_ONE 1\n#define GL_SRC_COLOR 0x0300\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\n#define GL_SRC_ALPHA 0x0302\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\n#define GL_DST_ALPHA 0x0304\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\n#define GL_DST_COLOR 0x0306\n#define GL_ONE_MINUS_DST_COLOR 0x0307\n#define GL_SRC_ALPHA_SATURATE 0x0308\n#define GL_NONE 0\n#define GL_FRONT_LEFT 0x0400\n#define GL_FRONT_RIGHT 0x0401\n#define GL_BACK_LEFT 0x0402\n#define GL_BACK_RIGHT 0x0403\n#define GL_FRONT 0x0404\n#define GL_BACK 0x0405\n#define GL_LEFT 0x0406\n#define GL_RIGHT 0x0407\n#define GL_FRONT_AND_BACK 0x0408\n#define GL_NO_ERROR 0\n#define GL_INVALID_ENUM 0x0500\n#define GL_INVALID_VALUE 0x0501\n#define GL_INVALID_OPERATION 0x0502\n#define GL_OUT_OF_MEMORY 0x0505\n#define GL_CW 0x0900\n#define GL_CCW 0x0901\n#define GL_POINT_SIZE 0x0B11\n#define GL_POINT_SIZE_RANGE 0x0B12\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_LINE_SMOOTH 0x0B20\n#define GL_LINE_WIDTH 0x0B21\n#define GL_LINE_WIDTH_RANGE 0x0B22\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_POLYGON_MODE 0x0B40\n#define GL_POLYGON_SMOOTH 0x0B41\n#define GL_CULL_FACE 0x0B44\n#define GL_CULL_FACE_MODE 0x0B45\n#define GL_FRONT_FACE 0x0B46\n#define GL_DEPTH_RANGE 0x0B70\n#define GL_DEPTH_TEST 0x0B71\n#define GL_DEPTH_WRITEMASK 0x0B72\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\n#define GL_DEPTH_FUNC 0x0B74\n#define GL_STENCIL_TEST 0x0B90\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\n#define GL_STENCIL_FUNC 0x0B92\n#define GL_STENCIL_VALUE_MASK 0x0B93\n#define GL_STENCIL_FAIL 0x0B94\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\n#define GL_STENCIL_REF 0x0B97\n#define GL_STENCIL_WRITEMASK 0x0B98\n#define GL_VIEWPORT 0x0BA2\n#define GL_DITHER 0x0BD0\n#define GL_BLEND_DST 0x0BE0\n#define GL_BLEND_SRC 0x0BE1\n#define GL_BLEND 0x0BE2\n#define GL_LOGIC_OP_MODE 0x0BF0\n#define GL_COLOR_LOGIC_OP 0x0BF2\n#define GL_DRAW_BUFFER 0x0C01\n#define GL_READ_BUFFER 0x0C02\n#define GL_SCISSOR_BOX 0x0C10\n#define GL_SCISSOR_TEST 0x0C11\n#define GL_COLOR_CLEAR_VALUE 0x0C22\n#define GL_COLOR_WRITEMASK 0x0C23\n#define GL_DOUBLEBUFFER 0x0C32\n#define GL_STEREO 0x0C33\n#define GL_LINE_SMOOTH_HINT 0x0C52\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\n#define GL_UNPACK_LSB_FIRST 0x0CF1\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\n#define GL_UNPACK_ALIGNMENT 0x0CF5\n#define GL_PACK_SWAP_BYTES 0x0D00\n#define GL_PACK_LSB_FIRST 0x0D01\n#define GL_PACK_ROW_LENGTH 0x0D02\n#define GL_PACK_SKIP_ROWS 0x0D03\n#define GL_PACK_SKIP_PIXELS 0x0D04\n#define GL_PACK_ALIGNMENT 0x0D05\n#define GL_MAX_TEXTURE_SIZE 0x0D33\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\n#define GL_SUBPIXEL_BITS 0x0D50\n#define GL_TEXTURE_1D 0x0DE0\n#define GL_TEXTURE_2D 0x0DE1\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\n#define GL_POLYGON_OFFSET_POINT 0x2A01\n#define GL_POLYGON_OFFSET_LINE 0x2A02\n#define GL_POLYGON_OFFSET_FILL 0x8037\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\n#define GL_TEXTURE_BINDING_1D 0x8068\n#define GL_TEXTURE_BINDING_2D 0x8069\n#define GL_TEXTURE_WIDTH 0x1000\n#define GL_TEXTURE_HEIGHT 0x1001\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\n#define GL_TEXTURE_BORDER_COLOR 0x1004\n#define GL_TEXTURE_RED_SIZE 0x805C\n#define GL_TEXTURE_GREEN_SIZE 0x805D\n#define GL_TEXTURE_BLUE_SIZE 0x805E\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\n#define GL_DONT_CARE 0x1100\n#define GL_FASTEST 0x1101\n#define GL_NICEST 0x1102\n#define GL_BYTE 0x1400\n#define GL_UNSIGNED_BYTE 0x1401\n#define GL_SHORT 0x1402\n#define GL_UNSIGNED_SHORT 0x1403\n#define GL_INT 0x1404\n#define GL_UNSIGNED_INT 0x1405\n#define GL_FLOAT 0x1406\n#define GL_DOUBLE 0x140A\n#define GL_CLEAR 0x1500\n#define GL_AND 0x1501\n#define GL_AND_REVERSE 0x1502\n#define GL_COPY 0x1503\n#define GL_AND_INVERTED 0x1504\n#define GL_NOOP 0x1505\n#define GL_XOR 0x1506\n#define GL_OR 0x1507\n#define GL_NOR 0x1508\n#define GL_EQUIV 0x1509\n#define GL_INVERT 0x150A\n#define GL_OR_REVERSE 0x150B\n#define GL_COPY_INVERTED 0x150C\n#define GL_OR_INVERTED 0x150D\n#define GL_NAND 0x150E\n#define GL_SET 0x150F\n#define GL_TEXTURE 0x1702\n#define GL_COLOR 0x1800\n#define GL_DEPTH 0x1801\n#define GL_STENCIL 0x1802\n#define GL_STENCIL_INDEX 0x1901\n#define GL_DEPTH_COMPONENT 0x1902\n#define GL_RED 0x1903\n#define GL_GREEN 0x1904\n#define GL_BLUE 0x1905\n#define GL_ALPHA 0x1906\n#define GL_RGB 0x1907\n#define GL_RGBA 0x1908\n#define GL_POINT 0x1B00\n#define GL_LINE 0x1B01\n#define GL_FILL 0x1B02\n#define GL_KEEP 0x1E00\n#define GL_REPLACE 0x1E01\n#define GL_INCR 0x1E02\n#define GL_DECR 0x1E03\n#define GL_VENDOR 0x1F00\n#define GL_RENDERER 0x1F01\n#define GL_VERSION 0x1F02\n#define GL_EXTENSIONS 0x1F03\n#define GL_NEAREST 0x2600\n#define GL_LINEAR 0x2601\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\n#define GL_TEXTURE_MAG_FILTER 0x2800\n#define GL_TEXTURE_MIN_FILTER 0x2801\n#define GL_TEXTURE_WRAP_S 0x2802\n#define GL_TEXTURE_WRAP_T 0x2803\n#define GL_PROXY_TEXTURE_1D 0x8063\n#define GL_PROXY_TEXTURE_2D 0x8064\n#define GL_REPEAT 0x2901\n#define GL_R3_G3_B2 0x2A10\n#define GL_RGB4 0x804F\n#define GL_RGB5 0x8050\n#define GL_RGB8 0x8051\n#define GL_RGB10 0x8052\n#define GL_RGB12 0x8053\n#define GL_RGB16 0x8054\n#define GL_RGBA2 0x8055\n#define GL_RGBA4 0x8056\n#define GL_RGB5_A1 0x8057\n#define GL_RGBA8 0x8058\n#define GL_RGB10_A2 0x8059\n#define GL_RGBA12 0x805A\n#define GL_RGBA16 0x805B\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\n#define GL_TEXTURE_BINDING_3D 0x806A\n#define GL_PACK_SKIP_IMAGES 0x806B\n#define GL_PACK_IMAGE_HEIGHT 0x806C\n#define GL_UNPACK_SKIP_IMAGES 0x806D\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\n#define GL_TEXTURE_3D 0x806F\n#define GL_PROXY_TEXTURE_3D 0x8070\n#define GL_TEXTURE_DEPTH 0x8071\n#define GL_TEXTURE_WRAP_R 0x8072\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\n#define GL_BGR 0x80E0\n#define GL_BGRA 0x80E1\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\n#define GL_CLAMP_TO_EDGE 0x812F\n#define GL_TEXTURE_MIN_LOD 0x813A\n#define GL_TEXTURE_MAX_LOD 0x813B\n#define GL_TEXTURE_BASE_LEVEL 0x813C\n#define GL_TEXTURE_MAX_LEVEL 0x813D\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\n#define GL_TEXTURE0 0x84C0\n#define GL_TEXTURE1 0x84C1\n#define GL_TEXTURE2 0x84C2\n#define GL_TEXTURE3 0x84C3\n#define GL_TEXTURE4 0x84C4\n#define GL_TEXTURE5 0x84C5\n#define GL_TEXTURE6 0x84C6\n#define GL_TEXTURE7 0x84C7\n#define GL_TEXTURE8 0x84C8\n#define GL_TEXTURE9 0x84C9\n#define GL_TEXTURE10 0x84CA\n#define GL_TEXTURE11 0x84CB\n#define GL_TEXTURE12 0x84CC\n#define GL_TEXTURE13 0x84CD\n#define GL_TEXTURE14 0x84CE\n#define GL_TEXTURE15 0x84CF\n#define GL_TEXTURE16 0x84D0\n#define GL_TEXTURE17 0x84D1\n#define GL_TEXTURE18 0x84D2\n#define GL_TEXTURE19 0x84D3\n#define GL_TEXTURE20 0x84D4\n#define GL_TEXTURE21 0x84D5\n#define GL_TEXTURE22 0x84D6\n#define GL_TEXTURE23 0x84D7\n#define GL_TEXTURE24 0x84D8\n#define GL_TEXTURE25 0x84D9\n#define GL_TEXTURE26 0x84DA\n#define GL_TEXTURE27 0x84DB\n#define GL_TEXTURE28 0x84DC\n#define GL_TEXTURE29 0x84DD\n#define GL_TEXTURE30 0x84DE\n#define GL_TEXTURE31 0x84DF\n#define GL_ACTIVE_TEXTURE 0x84E0\n#define GL_MULTISAMPLE 0x809D\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\n#define GL_SAMPLE_COVERAGE 0x80A0\n#define GL_SAMPLE_BUFFERS 0x80A8\n#define GL_SAMPLES 0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\n#define GL_TEXTURE_CUBE_MAP 0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\n#define GL_COMPRESSED_RGB 0x84ED\n#define GL_COMPRESSED_RGBA 0x84EE\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\n#define GL_TEXTURE_COMPRESSED 0x86A1\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\n#define GL_CLAMP_TO_BORDER 0x812D\n#define GL_BLEND_DST_RGB 0x80C8\n#define GL_BLEND_SRC_RGB 0x80C9\n#define GL_BLEND_DST_ALPHA 0x80CA\n#define GL_BLEND_SRC_ALPHA 0x80CB\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\n#define GL_DEPTH_COMPONENT16 0x81A5\n#define GL_DEPTH_COMPONENT24 0x81A6\n#define GL_DEPTH_COMPONENT32 0x81A7\n#define GL_MIRRORED_REPEAT 0x8370\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\n#define GL_TEXTURE_LOD_BIAS 0x8501\n#define GL_INCR_WRAP 0x8507\n#define GL_DECR_WRAP 0x8508\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\n#define GL_TEXTURE_COMPARE_MODE 0x884C\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\n#define GL_FUNC_ADD 0x8006\n#define GL_FUNC_SUBTRACT 0x800A\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\n#define GL_MIN 0x8007\n#define GL_MAX 0x8008\n#define GL_CONSTANT_COLOR 0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\n#define GL_CONSTANT_ALPHA 0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\n#define GL_BUFFER_SIZE 0x8764\n#define GL_BUFFER_USAGE 0x8765\n#define GL_QUERY_COUNTER_BITS 0x8864\n#define GL_CURRENT_QUERY 0x8865\n#define GL_QUERY_RESULT 0x8866\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\n#define GL_ARRAY_BUFFER 0x8892\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\n#define GL_ARRAY_BUFFER_BINDING 0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n#define GL_READ_ONLY 0x88B8\n#define GL_WRITE_ONLY 0x88B9\n#define GL_READ_WRITE 0x88BA\n#define GL_BUFFER_ACCESS 0x88BB\n#define GL_BUFFER_MAPPED 0x88BC\n#define GL_BUFFER_MAP_POINTER 0x88BD\n#define GL_STREAM_DRAW 0x88E0\n#define GL_STREAM_READ 0x88E1\n#define GL_STREAM_COPY 0x88E2\n#define GL_STATIC_DRAW 0x88E4\n#define GL_STATIC_READ 0x88E5\n#define GL_STATIC_COPY 0x88E6\n#define GL_DYNAMIC_DRAW 0x88E8\n#define GL_DYNAMIC_READ 0x88E9\n#define GL_DYNAMIC_COPY 0x88EA\n#define GL_SAMPLES_PASSED 0x8914\n#define GL_SRC1_ALPHA 0x8589\n#define GL_BLEND_EQUATION_RGB 0x8009\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\n#define GL_STENCIL_BACK_FUNC 0x8800\n#define GL_STENCIL_BACK_FAIL 0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\n#define GL_MAX_DRAW_BUFFERS 0x8824\n#define GL_DRAW_BUFFER0 0x8825\n#define GL_DRAW_BUFFER1 0x8826\n#define GL_DRAW_BUFFER2 0x8827\n#define GL_DRAW_BUFFER3 0x8828\n#define GL_DRAW_BUFFER4 0x8829\n#define GL_DRAW_BUFFER5 0x882A\n#define GL_DRAW_BUFFER6 0x882B\n#define GL_DRAW_BUFFER7 0x882C\n#define GL_DRAW_BUFFER8 0x882D\n#define GL_DRAW_BUFFER9 0x882E\n#define GL_DRAW_BUFFER10 0x882F\n#define GL_DRAW_BUFFER11 0x8830\n#define GL_DRAW_BUFFER12 0x8831\n#define GL_DRAW_BUFFER13 0x8832\n#define GL_DRAW_BUFFER14 0x8833\n#define GL_DRAW_BUFFER15 0x8834\n#define GL_BLEND_EQUATION_ALPHA 0x883D\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\n#define GL_FRAGMENT_SHADER 0x8B30\n#define GL_VERTEX_SHADER 0x8B31\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\n#define GL_MAX_VARYING_FLOATS 0x8B4B\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_SHADER_TYPE 0x8B4F\n#define GL_FLOAT_VEC2 0x8B50\n#define GL_FLOAT_VEC3 0x8B51\n#define GL_FLOAT_VEC4 0x8B52\n#define GL_INT_VEC2 0x8B53\n#define GL_INT_VEC3 0x8B54\n#define GL_INT_VEC4 0x8B55\n#define GL_BOOL 0x8B56\n#define GL_BOOL_VEC2 0x8B57\n#define GL_BOOL_VEC3 0x8B58\n#define GL_BOOL_VEC4 0x8B59\n#define GL_FLOAT_MAT2 0x8B5A\n#define GL_FLOAT_MAT3 0x8B5B\n#define GL_FLOAT_MAT4 0x8B5C\n#define GL_SAMPLER_1D 0x8B5D\n#define GL_SAMPLER_2D 0x8B5E\n#define GL_SAMPLER_3D 0x8B5F\n#define GL_SAMPLER_CUBE 0x8B60\n#define GL_SAMPLER_1D_SHADOW 0x8B61\n#define GL_SAMPLER_2D_SHADOW 0x8B62\n#define GL_DELETE_STATUS 0x8B80\n#define GL_COMPILE_STATUS 0x8B81\n#define GL_LINK_STATUS 0x8B82\n#define GL_VALIDATE_STATUS 0x8B83\n#define GL_INFO_LOG_LENGTH 0x8B84\n#define GL_ATTACHED_SHADERS 0x8B85\n#define GL_ACTIVE_UNIFORMS 0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\n#define GL_CURRENT_PROGRAM 0x8B8D\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\n#define GL_LOWER_LEFT 0x8CA1\n#define GL_UPPER_LEFT 0x8CA2\n#define GL_STENCIL_BACK_REF 0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\n#define GL_PIXEL_PACK_BUFFER 0x88EB\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\n#define GL_FLOAT_MAT2x3 0x8B65\n#define GL_FLOAT_MAT2x4 0x8B66\n#define GL_FLOAT_MAT3x2 0x8B67\n#define GL_FLOAT_MAT3x4 0x8B68\n#define GL_FLOAT_MAT4x2 0x8B69\n#define GL_FLOAT_MAT4x3 0x8B6A\n#define GL_SRGB 0x8C40\n#define GL_SRGB8 0x8C41\n#define GL_SRGB_ALPHA 0x8C42\n#define GL_SRGB8_ALPHA8 0x8C43\n#define GL_COMPRESSED_SRGB 0x8C48\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\n#define GL_COMPARE_REF_TO_TEXTURE 0x884E\n#define GL_CLIP_DISTANCE0 0x3000\n#define GL_CLIP_DISTANCE1 0x3001\n#define GL_CLIP_DISTANCE2 0x3002\n#define GL_CLIP_DISTANCE3 0x3003\n#define GL_CLIP_DISTANCE4 0x3004\n#define GL_CLIP_DISTANCE5 0x3005\n#define GL_CLIP_DISTANCE6 0x3006\n#define GL_CLIP_DISTANCE7 0x3007\n#define GL_MAX_CLIP_DISTANCES 0x0D32\n#define GL_MAJOR_VERSION 0x821B\n#define GL_MINOR_VERSION 0x821C\n#define GL_NUM_EXTENSIONS 0x821D\n#define GL_CONTEXT_FLAGS 0x821E\n#define GL_COMPRESSED_RED 0x8225\n#define GL_COMPRESSED_RG 0x8226\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001\n#define GL_RGBA32F 0x8814\n#define GL_RGB32F 0x8815\n#define GL_RGBA16F 0x881A\n#define GL_RGB16F 0x881B\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\n#define GL_CLAMP_READ_COLOR 0x891C\n#define GL_FIXED_ONLY 0x891D\n#define GL_MAX_VARYING_COMPONENTS 0x8B4B\n#define GL_TEXTURE_1D_ARRAY 0x8C18\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\n#define GL_R11F_G11F_B10F 0x8C3A\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\n#define GL_RGB9_E5 0x8C3D\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\n#define GL_PRIMITIVES_GENERATED 0x8C87\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\n#define GL_RASTERIZER_DISCARD 0x8C89\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\n#define GL_SEPARATE_ATTRIBS 0x8C8D\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\n#define GL_RGBA32UI 0x8D70\n#define GL_RGB32UI 0x8D71\n#define GL_RGBA16UI 0x8D76\n#define GL_RGB16UI 0x8D77\n#define GL_RGBA8UI 0x8D7C\n#define GL_RGB8UI 0x8D7D\n#define GL_RGBA32I 0x8D82\n#define GL_RGB32I 0x8D83\n#define GL_RGBA16I 0x8D88\n#define GL_RGB16I 0x8D89\n#define GL_RGBA8I 0x8D8E\n#define GL_RGB8I 0x8D8F\n#define GL_RED_INTEGER 0x8D94\n#define GL_GREEN_INTEGER 0x8D95\n#define GL_BLUE_INTEGER 0x8D96\n#define GL_RGB_INTEGER 0x8D98\n#define GL_RGBA_INTEGER 0x8D99\n#define GL_BGR_INTEGER 0x8D9A\n#define GL_BGRA_INTEGER 0x8D9B\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\n#define GL_INT_SAMPLER_1D 0x8DC9\n#define GL_INT_SAMPLER_2D 0x8DCA\n#define GL_INT_SAMPLER_3D 0x8DCB\n#define GL_INT_SAMPLER_CUBE 0x8DCC\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\n#define GL_QUERY_WAIT 0x8E13\n#define GL_QUERY_NO_WAIT 0x8E14\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\n#define GL_BUFFER_MAP_LENGTH 0x9120\n#define GL_BUFFER_MAP_OFFSET 0x9121\n#define GL_DEPTH_COMPONENT32F 0x8CAC\n#define GL_DEPTH32F_STENCIL8 0x8CAD\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\n#define GL_DEPTH_STENCIL 0x84F9\n#define GL_UNSIGNED_INT_24_8 0x84FA\n#define GL_DEPTH24_STENCIL8 0x88F0\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\n#define GL_TEXTURE_RED_TYPE 0x8C10\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\n#define GL_UNSIGNED_NORMALIZED 0x8C17\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\n#define GL_RENDERBUFFER_BINDING 0x8CA7\n#define GL_READ_FRAMEBUFFER 0x8CA8\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\n#define GL_COLOR_ATTACHMENT0 0x8CE0\n#define GL_COLOR_ATTACHMENT1 0x8CE1\n#define GL_COLOR_ATTACHMENT2 0x8CE2\n#define GL_COLOR_ATTACHMENT3 0x8CE3\n#define GL_COLOR_ATTACHMENT4 0x8CE4\n#define GL_COLOR_ATTACHMENT5 0x8CE5\n#define GL_COLOR_ATTACHMENT6 0x8CE6\n#define GL_COLOR_ATTACHMENT7 0x8CE7\n#define GL_COLOR_ATTACHMENT8 0x8CE8\n#define GL_COLOR_ATTACHMENT9 0x8CE9\n#define GL_COLOR_ATTACHMENT10 0x8CEA\n#define GL_COLOR_ATTACHMENT11 0x8CEB\n#define GL_COLOR_ATTACHMENT12 0x8CEC\n#define GL_COLOR_ATTACHMENT13 0x8CED\n#define GL_COLOR_ATTACHMENT14 0x8CEE\n#define GL_COLOR_ATTACHMENT15 0x8CEF\n#define GL_DEPTH_ATTACHMENT 0x8D00\n#define GL_STENCIL_ATTACHMENT 0x8D20\n#define GL_FRAMEBUFFER 0x8D40\n#define GL_RENDERBUFFER 0x8D41\n#define GL_RENDERBUFFER_WIDTH 0x8D42\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\n#define GL_STENCIL_INDEX1 0x8D46\n#define GL_STENCIL_INDEX4 0x8D47\n#define GL_STENCIL_INDEX8 0x8D48\n#define GL_STENCIL_INDEX16 0x8D49\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\n#define GL_MAX_SAMPLES 0x8D57\n#define GL_INDEX 0x8222\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\n#define GL_HALF_FLOAT 0x140B\n#define GL_MAP_READ_BIT 0x0001\n#define GL_MAP_WRITE_BIT 0x0002\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\n#define GL_RG 0x8227\n#define GL_RG_INTEGER 0x8228\n#define GL_R8 0x8229\n#define GL_R16 0x822A\n#define GL_RG8 0x822B\n#define GL_RG16 0x822C\n#define GL_R16F 0x822D\n#define GL_R32F 0x822E\n#define GL_RG16F 0x822F\n#define GL_RG32F 0x8230\n#define GL_R8I 0x8231\n#define GL_R8UI 0x8232\n#define GL_R16I 0x8233\n#define GL_R16UI 0x8234\n#define GL_R32I 0x8235\n#define GL_R32UI 0x8236\n#define GL_RG8I 0x8237\n#define GL_RG8UI 0x8238\n#define GL_RG16I 0x8239\n#define GL_RG16UI 0x823A\n#define GL_RG32I 0x823B\n#define GL_RG32UI 0x823C\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\n#define GL_SAMPLER_2D_RECT 0x8B63\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\n#define GL_SAMPLER_BUFFER 0x8DC2\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\n#define GL_TEXTURE_BUFFER 0x8C2A\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\n#define GL_TEXTURE_RECTANGLE 0x84F5\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\n#define GL_R8_SNORM 0x8F94\n#define GL_RG8_SNORM 0x8F95\n#define GL_RGB8_SNORM 0x8F96\n#define GL_RGBA8_SNORM 0x8F97\n#define GL_R16_SNORM 0x8F98\n#define GL_RG16_SNORM 0x8F99\n#define GL_RGB16_SNORM 0x8F9A\n#define GL_RGBA16_SNORM 0x8F9B\n#define GL_SIGNED_NORMALIZED 0x8F9C\n#define GL_PRIMITIVE_RESTART 0x8F9D\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\n#define GL_COPY_READ_BUFFER 0x8F36\n#define GL_COPY_WRITE_BUFFER 0x8F37\n#define GL_UNIFORM_BUFFER 0x8A11\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\n#define GL_UNIFORM_BUFFER_START 0x8A29\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\n#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\n#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\n#define GL_UNIFORM_TYPE 0x8A37\n#define GL_UNIFORM_SIZE 0x8A38\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\n#define GL_UNIFORM_OFFSET 0x8A3B\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\n#define GL_INVALID_INDEX 0xFFFFFFFF\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\n#define GL_LINES_ADJACENCY 0x000A\n#define GL_LINE_STRIP_ADJACENCY 0x000B\n#define GL_TRIANGLES_ADJACENCY 0x000C\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\n#define GL_PROGRAM_POINT_SIZE 0x8642\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\n#define GL_GEOMETRY_SHADER 0x8DD9\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\n#define GL_CONTEXT_PROFILE_MASK 0x9126\n#define GL_DEPTH_CLAMP 0x864F\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\n#define GL_PROVOKING_VERTEX 0x8E4F\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\n#define GL_OBJECT_TYPE 0x9112\n#define GL_SYNC_CONDITION 0x9113\n#define GL_SYNC_STATUS 0x9114\n#define GL_SYNC_FLAGS 0x9115\n#define GL_SYNC_FENCE 0x9116\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\n#define GL_UNSIGNALED 0x9118\n#define GL_SIGNALED 0x9119\n#define GL_ALREADY_SIGNALED 0x911A\n#define GL_TIMEOUT_EXPIRED 0x911B\n#define GL_CONDITION_SATISFIED 0x911C\n#define GL_WAIT_FAILED 0x911D\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\n#define GL_SAMPLE_POSITION 0x8E50\n#define GL_SAMPLE_MASK 0x8E51\n#define GL_SAMPLE_MASK_VALUE 0x8E52\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\n#define GL_TEXTURE_SAMPLES 0x9106\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\n#define GL_MAX_INTEGER_SAMPLES 0x9110\n#ifndef GL_VERSION_1_0\n#define GL_VERSION_1_0 1\nGLAPI int GLAD_GL_VERSION_1_0;\ntypedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum);\nGLAPI PFNGLCULLFACEPROC glad_glCullFace;\n#define glCullFace glad_glCullFace\ntypedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum);\nGLAPI PFNGLFRONTFACEPROC glad_glFrontFace;\n#define glFrontFace glad_glFrontFace\ntypedef void (APIENTRYP PFNGLHINTPROC)(GLenum, GLenum);\nGLAPI PFNGLHINTPROC glad_glHint;\n#define glHint glad_glHint\ntypedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat);\nGLAPI PFNGLLINEWIDTHPROC glad_glLineWidth;\n#define glLineWidth glad_glLineWidth\ntypedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat);\nGLAPI PFNGLPOINTSIZEPROC glad_glPointSize;\n#define glPointSize glad_glPointSize\ntypedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum, GLenum);\nGLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode;\n#define glPolygonMode glad_glPolygonMode\ntypedef void (APIENTRYP PFNGLSCISSORPROC)(GLint, GLint, GLsizei, GLsizei);\nGLAPI PFNGLSCISSORPROC glad_glScissor;\n#define glScissor glad_glScissor\ntypedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum, GLenum, GLfloat);\nGLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf;\n#define glTexParameterf glad_glTexParameterf\ntypedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum, GLenum, const GLfloat*);\nGLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;\n#define glTexParameterfv glad_glTexParameterfv\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum, GLenum, GLint);\nGLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri;\n#define glTexParameteri glad_glTexParameteri\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum, GLenum, const GLint*);\nGLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;\n#define glTexParameteriv glad_glTexParameteriv\ntypedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D;\n#define glTexImage1D glad_glTexImage1D\ntypedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D;\n#define glTexImage2D glad_glTexImage2D\ntypedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum);\nGLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer;\n#define glDrawBuffer glad_glDrawBuffer\ntypedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield);\nGLAPI PFNGLCLEARPROC glad_glClear;\n#define glClear glad_glClear\ntypedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLCLEARCOLORPROC glad_glClearColor;\n#define glClearColor glad_glClearColor\ntypedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint);\nGLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil;\n#define glClearStencil glad_glClearStencil\ntypedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble);\nGLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth;\n#define glClearDepth glad_glClearDepth\ntypedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint);\nGLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;\n#define glStencilMask glad_glStencilMask\ntypedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean, GLboolean, GLboolean, GLboolean);\nGLAPI PFNGLCOLORMASKPROC glad_glColorMask;\n#define glColorMask glad_glColorMask\ntypedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean);\nGLAPI PFNGLDEPTHMASKPROC glad_glDepthMask;\n#define glDepthMask glad_glDepthMask\ntypedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum);\nGLAPI PFNGLDISABLEPROC glad_glDisable;\n#define glDisable glad_glDisable\ntypedef void (APIENTRYP PFNGLENABLEPROC)(GLenum);\nGLAPI PFNGLENABLEPROC glad_glEnable;\n#define glEnable glad_glEnable\ntypedef void (APIENTRYP PFNGLFINISHPROC)();\nGLAPI PFNGLFINISHPROC glad_glFinish;\n#define glFinish glad_glFinish\ntypedef void (APIENTRYP PFNGLFLUSHPROC)();\nGLAPI PFNGLFLUSHPROC glad_glFlush;\n#define glFlush glad_glFlush\ntypedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum, GLenum);\nGLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc;\n#define glBlendFunc glad_glBlendFunc\ntypedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum);\nGLAPI PFNGLLOGICOPPROC glad_glLogicOp;\n#define glLogicOp glad_glLogicOp\ntypedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum, GLint, GLuint);\nGLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;\n#define glStencilFunc glad_glStencilFunc\ntypedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum, GLenum, GLenum);\nGLAPI PFNGLSTENCILOPPROC glad_glStencilOp;\n#define glStencilOp glad_glStencilOp\ntypedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum);\nGLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc;\n#define glDepthFunc glad_glDepthFunc\ntypedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum, GLfloat);\nGLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref;\n#define glPixelStoref glad_glPixelStoref\ntypedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum, GLint);\nGLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei;\n#define glPixelStorei glad_glPixelStorei\ntypedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum);\nGLAPI PFNGLREADBUFFERPROC glad_glReadBuffer;\n#define glReadBuffer glad_glReadBuffer\ntypedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void*);\nGLAPI PFNGLREADPIXELSPROC glad_glReadPixels;\n#define glReadPixels glad_glReadPixels\ntypedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum, GLboolean*);\nGLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv;\n#define glGetBooleanv glad_glGetBooleanv\ntypedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum, GLdouble*);\nGLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev;\n#define glGetDoublev glad_glGetDoublev\ntypedef GLenum (APIENTRYP PFNGLGETERRORPROC)();\nGLAPI PFNGLGETERRORPROC glad_glGetError;\n#define glGetError glad_glGetError\ntypedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum, GLfloat*);\nGLAPI PFNGLGETFLOATVPROC glad_glGetFloatv;\n#define glGetFloatv glad_glGetFloatv\ntypedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum, GLint*);\nGLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv;\n#define glGetIntegerv glad_glGetIntegerv\ntypedef const GLubyte* (APIENTRYP PFNGLGETSTRINGPROC)(GLenum);\nGLAPI PFNGLGETSTRINGPROC glad_glGetString;\n#define glGetString glad_glGetString\ntypedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum, GLint, GLenum, GLenum, void*);\nGLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage;\n#define glGetTexImage glad_glGetTexImage\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum, GLenum, GLfloat*);\nGLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;\n#define glGetTexParameterfv glad_glGetTexParameterfv\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum, GLenum, GLint*);\nGLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;\n#define glGetTexParameteriv glad_glGetTexParameteriv\ntypedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum, GLint, GLenum, GLfloat*);\nGLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;\n#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv\ntypedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum, GLint, GLenum, GLint*);\nGLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;\n#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv\ntypedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum);\nGLAPI PFNGLISENABLEDPROC glad_glIsEnabled;\n#define glIsEnabled glad_glIsEnabled\ntypedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble, GLdouble);\nGLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange;\n#define glDepthRange glad_glDepthRange\ntypedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint, GLint, GLsizei, GLsizei);\nGLAPI PFNGLVIEWPORTPROC glad_glViewport;\n#define glViewport glad_glViewport\n#endif\n#ifndef GL_VERSION_1_1\n#define GL_VERSION_1_1 1\nGLAPI int GLAD_GL_VERSION_1_1;\ntypedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum, GLint, GLsizei);\nGLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays;\n#define glDrawArrays glad_glDrawArrays\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum, GLsizei, GLenum, const void*);\nGLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements;\n#define glDrawElements glad_glDrawElements\ntypedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat, GLfloat);\nGLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;\n#define glPolygonOffset glad_glPolygonOffset\ntypedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);\nGLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;\n#define glCopyTexImage1D glad_glCopyTexImage1D\ntypedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);\nGLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;\n#define glCopyTexImage2D glad_glCopyTexImage2D\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum, GLint, GLint, GLint, GLint, GLsizei);\nGLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;\n#define glCopyTexSubImage1D glad_glCopyTexSubImage1D\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\nGLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;\n#define glCopyTexSubImage2D glad_glCopyTexSubImage2D\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;\n#define glTexSubImage1D glad_glTexSubImage1D\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;\n#define glTexSubImage2D glad_glTexSubImage2D\ntypedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum, GLuint);\nGLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture;\n#define glBindTexture glad_glBindTexture\ntypedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures;\n#define glDeleteTextures glad_glDeleteTextures\ntypedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENTEXTURESPROC glad_glGenTextures;\n#define glGenTextures glad_glGenTextures\ntypedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint);\nGLAPI PFNGLISTEXTUREPROC glad_glIsTexture;\n#define glIsTexture glad_glIsTexture\n#endif\n#ifndef GL_VERSION_1_2\n#define GL_VERSION_1_2 1\nGLAPI int GLAD_GL_VERSION_1_2;\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void*);\nGLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;\n#define glDrawRangeElements glad_glDrawRangeElements\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D;\n#define glTexImage3D glad_glTexImage3D\ntypedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void*);\nGLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;\n#define glTexSubImage3D glad_glTexSubImage3D\ntypedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);\nGLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;\n#define glCopyTexSubImage3D glad_glCopyTexSubImage3D\n#endif\n#ifndef GL_VERSION_1_3\n#define GL_VERSION_1_3 1\nGLAPI int GLAD_GL_VERSION_1_3;\ntypedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum);\nGLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture;\n#define glActiveTexture glad_glActiveTexture\ntypedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat, GLboolean);\nGLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;\n#define glSampleCoverage glad_glSampleCoverage\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;\n#define glCompressedTexImage3D glad_glCompressedTexImage3D\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;\n#define glCompressedTexImage2D glad_glCompressedTexImage2D\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;\n#define glCompressedTexImage1D glad_glCompressedTexImage1D\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;\n#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;\n#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D\ntypedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void*);\nGLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;\n#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D\ntypedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum, GLint, void*);\nGLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;\n#define glGetCompressedTexImage glad_glGetCompressedTexImage\n#endif\n#ifndef GL_VERSION_1_4\n#define GL_VERSION_1_4 1\nGLAPI int GLAD_GL_VERSION_1_4;\ntypedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum, GLenum, GLenum, GLenum);\nGLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;\n#define glBlendFuncSeparate glad_glBlendFuncSeparate\ntypedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum, const GLint*, const GLsizei*, GLsizei);\nGLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;\n#define glMultiDrawArrays glad_glMultiDrawArrays\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum, const GLsizei*, GLenum, const void**, GLsizei);\nGLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;\n#define glMultiDrawElements glad_glMultiDrawElements\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum, GLfloat);\nGLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;\n#define glPointParameterf glad_glPointParameterf\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum, const GLfloat*);\nGLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;\n#define glPointParameterfv glad_glPointParameterfv\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum, GLint);\nGLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;\n#define glPointParameteri glad_glPointParameteri\ntypedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum, const GLint*);\nGLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;\n#define glPointParameteriv glad_glPointParameteriv\ntypedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLBLENDCOLORPROC glad_glBlendColor;\n#define glBlendColor glad_glBlendColor\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum);\nGLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation;\n#define glBlendEquation glad_glBlendEquation\n#endif\n#ifndef GL_VERSION_1_5\n#define GL_VERSION_1_5 1\nGLAPI int GLAD_GL_VERSION_1_5;\ntypedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENQUERIESPROC glad_glGenQueries;\n#define glGenQueries glad_glGenQueries\ntypedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries;\n#define glDeleteQueries glad_glDeleteQueries\ntypedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint);\nGLAPI PFNGLISQUERYPROC glad_glIsQuery;\n#define glIsQuery glad_glIsQuery\ntypedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum, GLuint);\nGLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery;\n#define glBeginQuery glad_glBeginQuery\ntypedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum);\nGLAPI PFNGLENDQUERYPROC glad_glEndQuery;\n#define glEndQuery glad_glEndQuery\ntypedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum, GLenum, GLint*);\nGLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv;\n#define glGetQueryiv glad_glGetQueryiv\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint, GLenum, GLint*);\nGLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;\n#define glGetQueryObjectiv glad_glGetQueryObjectiv\ntypedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint, GLenum, GLuint*);\nGLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;\n#define glGetQueryObjectuiv glad_glGetQueryObjectuiv\ntypedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum, GLuint);\nGLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer;\n#define glBindBuffer glad_glBindBuffer\ntypedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;\n#define glDeleteBuffers glad_glDeleteBuffers\ntypedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers;\n#define glGenBuffers glad_glGenBuffers\ntypedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint);\nGLAPI PFNGLISBUFFERPROC glad_glIsBuffer;\n#define glIsBuffer glad_glIsBuffer\ntypedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum, GLsizeiptr, const void*, GLenum);\nGLAPI PFNGLBUFFERDATAPROC glad_glBufferData;\n#define glBufferData glad_glBufferData\ntypedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum, GLintptr, GLsizeiptr, const void*);\nGLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;\n#define glBufferSubData glad_glBufferSubData\ntypedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum, GLintptr, GLsizeiptr, void*);\nGLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;\n#define glGetBufferSubData glad_glGetBufferSubData\ntypedef void* (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum, GLenum);\nGLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer;\n#define glMapBuffer glad_glMapBuffer\ntypedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum);\nGLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;\n#define glUnmapBuffer glad_glUnmapBuffer\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum, GLenum, GLint*);\nGLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;\n#define glGetBufferParameteriv glad_glGetBufferParameteriv\ntypedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum, GLenum, void**);\nGLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;\n#define glGetBufferPointerv glad_glGetBufferPointerv\n#endif\n#ifndef GL_VERSION_2_0\n#define GL_VERSION_2_0 1\nGLAPI int GLAD_GL_VERSION_2_0;\ntypedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum, GLenum);\nGLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;\n#define glBlendEquationSeparate glad_glBlendEquationSeparate\ntypedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei, const GLenum*);\nGLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;\n#define glDrawBuffers glad_glDrawBuffers\ntypedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum, GLenum, GLenum, GLenum);\nGLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;\n#define glStencilOpSeparate glad_glStencilOpSeparate\ntypedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum, GLenum, GLint, GLuint);\nGLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;\n#define glStencilFuncSeparate glad_glStencilFuncSeparate\ntypedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum, GLuint);\nGLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;\n#define glStencilMaskSeparate glad_glStencilMaskSeparate\ntypedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint, GLuint);\nGLAPI PFNGLATTACHSHADERPROC glad_glAttachShader;\n#define glAttachShader glad_glAttachShader\ntypedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint, GLuint, const GLchar*);\nGLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;\n#define glBindAttribLocation glad_glBindAttribLocation\ntypedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint);\nGLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader;\n#define glCompileShader glad_glCompileShader\ntypedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)();\nGLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram;\n#define glCreateProgram glad_glCreateProgram\ntypedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum);\nGLAPI PFNGLCREATESHADERPROC glad_glCreateShader;\n#define glCreateShader glad_glCreateShader\ntypedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint);\nGLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;\n#define glDeleteProgram glad_glDeleteProgram\ntypedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint);\nGLAPI PFNGLDELETESHADERPROC glad_glDeleteShader;\n#define glDeleteShader glad_glDeleteShader\ntypedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint, GLuint);\nGLAPI PFNGLDETACHSHADERPROC glad_glDetachShader;\n#define glDetachShader glad_glDetachShader\ntypedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint);\nGLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;\n#define glDisableVertexAttribArray glad_glDisableVertexAttribArray\ntypedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint);\nGLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;\n#define glEnableVertexAttribArray glad_glEnableVertexAttribArray\ntypedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);\nGLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;\n#define glGetActiveAttrib glad_glGetActiveAttrib\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*);\nGLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;\n#define glGetActiveUniform glad_glGetActiveUniform\ntypedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint, GLsizei, GLsizei*, GLuint*);\nGLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;\n#define glGetAttachedShaders glad_glGetAttachedShaders\ntypedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint, const GLchar*);\nGLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;\n#define glGetAttribLocation glad_glGetAttribLocation\ntypedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint, GLenum, GLint*);\nGLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;\n#define glGetProgramiv glad_glGetProgramiv\ntypedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint, GLsizei, GLsizei*, GLchar*);\nGLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;\n#define glGetProgramInfoLog glad_glGetProgramInfoLog\ntypedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint, GLenum, GLint*);\nGLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv;\n#define glGetShaderiv glad_glGetShaderiv\ntypedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint, GLsizei, GLsizei*, GLchar*);\nGLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;\n#define glGetShaderInfoLog glad_glGetShaderInfoLog\ntypedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint, GLsizei, GLsizei*, GLchar*);\nGLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;\n#define glGetShaderSource glad_glGetShaderSource\ntypedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint, const GLchar*);\nGLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;\n#define glGetUniformLocation glad_glGetUniformLocation\ntypedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint, GLint, GLfloat*);\nGLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;\n#define glGetUniformfv glad_glGetUniformfv\ntypedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint, GLint, GLint*);\nGLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;\n#define glGetUniformiv glad_glGetUniformiv\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint, GLenum, GLdouble*);\nGLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;\n#define glGetVertexAttribdv glad_glGetVertexAttribdv\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint, GLenum, GLfloat*);\nGLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;\n#define glGetVertexAttribfv glad_glGetVertexAttribfv\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint, GLenum, GLint*);\nGLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;\n#define glGetVertexAttribiv glad_glGetVertexAttribiv\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint, GLenum, void**);\nGLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;\n#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv\ntypedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint);\nGLAPI PFNGLISPROGRAMPROC glad_glIsProgram;\n#define glIsProgram glad_glIsProgram\ntypedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint);\nGLAPI PFNGLISSHADERPROC glad_glIsShader;\n#define glIsShader glad_glIsShader\ntypedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint);\nGLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram;\n#define glLinkProgram glad_glLinkProgram\ntypedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint, GLsizei, const GLchar**, const GLint*);\nGLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource;\n#define glShaderSource glad_glShaderSource\ntypedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint);\nGLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram;\n#define glUseProgram glad_glUseProgram\ntypedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint, GLfloat);\nGLAPI PFNGLUNIFORM1FPROC glad_glUniform1f;\n#define glUniform1f glad_glUniform1f\ntypedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint, GLfloat, GLfloat);\nGLAPI PFNGLUNIFORM2FPROC glad_glUniform2f;\n#define glUniform2f glad_glUniform2f\ntypedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLUNIFORM3FPROC glad_glUniform3f;\n#define glUniform3f glad_glUniform3f\ntypedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLUNIFORM4FPROC glad_glUniform4f;\n#define glUniform4f glad_glUniform4f\ntypedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint, GLint);\nGLAPI PFNGLUNIFORM1IPROC glad_glUniform1i;\n#define glUniform1i glad_glUniform1i\ntypedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint, GLint, GLint);\nGLAPI PFNGLUNIFORM2IPROC glad_glUniform2i;\n#define glUniform2i glad_glUniform2i\ntypedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint, GLint, GLint, GLint);\nGLAPI PFNGLUNIFORM3IPROC glad_glUniform3i;\n#define glUniform3i glad_glUniform3i\ntypedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint, GLint, GLint, GLint, GLint);\nGLAPI PFNGLUNIFORM4IPROC glad_glUniform4i;\n#define glUniform4i glad_glUniform4i\ntypedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint, GLsizei, const GLfloat*);\nGLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv;\n#define glUniform1fv glad_glUniform1fv\ntypedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint, GLsizei, const GLfloat*);\nGLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv;\n#define glUniform2fv glad_glUniform2fv\ntypedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint, GLsizei, const GLfloat*);\nGLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv;\n#define glUniform3fv glad_glUniform3fv\ntypedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint, GLsizei, const GLfloat*);\nGLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv;\n#define glUniform4fv glad_glUniform4fv\ntypedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint, GLsizei, const GLint*);\nGLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv;\n#define glUniform1iv glad_glUniform1iv\ntypedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint, GLsizei, const GLint*);\nGLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv;\n#define glUniform2iv glad_glUniform2iv\ntypedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint, GLsizei, const GLint*);\nGLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv;\n#define glUniform3iv glad_glUniform3iv\ntypedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint, GLsizei, const GLint*);\nGLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv;\n#define glUniform4iv glad_glUniform4iv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;\n#define glUniformMatrix2fv glad_glUniformMatrix2fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;\n#define glUniformMatrix3fv glad_glUniformMatrix3fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;\n#define glUniformMatrix4fv glad_glUniformMatrix4fv\ntypedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint);\nGLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;\n#define glValidateProgram glad_glValidateProgram\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint, GLdouble);\nGLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;\n#define glVertexAttrib1d glad_glVertexAttrib1d\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint, const GLdouble*);\nGLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;\n#define glVertexAttrib1dv glad_glVertexAttrib1dv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint, GLfloat);\nGLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;\n#define glVertexAttrib1f glad_glVertexAttrib1f\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint, const GLfloat*);\nGLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;\n#define glVertexAttrib1fv glad_glVertexAttrib1fv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint, GLshort);\nGLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;\n#define glVertexAttrib1s glad_glVertexAttrib1s\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;\n#define glVertexAttrib1sv glad_glVertexAttrib1sv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint, GLdouble, GLdouble);\nGLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;\n#define glVertexAttrib2d glad_glVertexAttrib2d\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint, const GLdouble*);\nGLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;\n#define glVertexAttrib2dv glad_glVertexAttrib2dv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint, GLfloat, GLfloat);\nGLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;\n#define glVertexAttrib2f glad_glVertexAttrib2f\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint, const GLfloat*);\nGLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;\n#define glVertexAttrib2fv glad_glVertexAttrib2fv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint, GLshort, GLshort);\nGLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;\n#define glVertexAttrib2s glad_glVertexAttrib2s\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;\n#define glVertexAttrib2sv glad_glVertexAttrib2sv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint, GLdouble, GLdouble, GLdouble);\nGLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;\n#define glVertexAttrib3d glad_glVertexAttrib3d\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint, const GLdouble*);\nGLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;\n#define glVertexAttrib3dv glad_glVertexAttrib3dv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;\n#define glVertexAttrib3f glad_glVertexAttrib3f\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint, const GLfloat*);\nGLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;\n#define glVertexAttrib3fv glad_glVertexAttrib3fv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint, GLshort, GLshort, GLshort);\nGLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;\n#define glVertexAttrib3s glad_glVertexAttrib3s\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;\n#define glVertexAttrib3sv glad_glVertexAttrib3sv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint, const GLbyte*);\nGLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;\n#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;\n#define glVertexAttrib4Niv glad_glVertexAttrib4Niv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;\n#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);\nGLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;\n#define glVertexAttrib4Nub glad_glVertexAttrib4Nub\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint, const GLubyte*);\nGLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;\n#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;\n#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint, const GLushort*);\nGLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;\n#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint, const GLbyte*);\nGLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;\n#define glVertexAttrib4bv glad_glVertexAttrib4bv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);\nGLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;\n#define glVertexAttrib4d glad_glVertexAttrib4d\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint, const GLdouble*);\nGLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;\n#define glVertexAttrib4dv glad_glVertexAttrib4dv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);\nGLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;\n#define glVertexAttrib4f glad_glVertexAttrib4f\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint, const GLfloat*);\nGLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;\n#define glVertexAttrib4fv glad_glVertexAttrib4fv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;\n#define glVertexAttrib4iv glad_glVertexAttrib4iv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint, GLshort, GLshort, GLshort, GLshort);\nGLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;\n#define glVertexAttrib4s glad_glVertexAttrib4s\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;\n#define glVertexAttrib4sv glad_glVertexAttrib4sv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint, const GLubyte*);\nGLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;\n#define glVertexAttrib4ubv glad_glVertexAttrib4ubv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;\n#define glVertexAttrib4uiv glad_glVertexAttrib4uiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint, const GLushort*);\nGLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;\n#define glVertexAttrib4usv glad_glVertexAttrib4usv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*);\nGLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;\n#define glVertexAttribPointer glad_glVertexAttribPointer\n#endif\n#ifndef GL_VERSION_2_1\n#define GL_VERSION_2_1 1\nGLAPI int GLAD_GL_VERSION_2_1;\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;\n#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;\n#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;\n#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;\n#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;\n#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv\ntypedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint, GLsizei, GLboolean, const GLfloat*);\nGLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;\n#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv\n#endif\n#ifndef GL_VERSION_3_0\n#define GL_VERSION_3_0 1\nGLAPI int GLAD_GL_VERSION_3_0;\ntypedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean);\nGLAPI PFNGLCOLORMASKIPROC glad_glColorMaski;\n#define glColorMaski glad_glColorMaski\ntypedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum, GLuint, GLboolean*);\nGLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;\n#define glGetBooleani_v glad_glGetBooleani_v\ntypedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum, GLuint, GLint*);\nGLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;\n#define glGetIntegeri_v glad_glGetIntegeri_v\ntypedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum, GLuint);\nGLAPI PFNGLENABLEIPROC glad_glEnablei;\n#define glEnablei glad_glEnablei\ntypedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum, GLuint);\nGLAPI PFNGLDISABLEIPROC glad_glDisablei;\n#define glDisablei glad_glDisablei\ntypedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum, GLuint);\nGLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi;\n#define glIsEnabledi glad_glIsEnabledi\ntypedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum);\nGLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;\n#define glBeginTransformFeedback glad_glBeginTransformFeedback\ntypedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)();\nGLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;\n#define glEndTransformFeedback glad_glEndTransformFeedback\ntypedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);\nGLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;\n#define glBindBufferRange glad_glBindBufferRange\ntypedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum, GLuint, GLuint);\nGLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;\n#define glBindBufferBase glad_glBindBufferBase\ntypedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint, GLsizei, const GLchar**, GLenum);\nGLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;\n#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings\ntypedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint, GLuint, GLsizei, GLsizei*, GLsizei*, GLenum*, GLchar*);\nGLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;\n#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying\ntypedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum, GLenum);\nGLAPI PFNGLCLAMPCOLORPROC glad_glClampColor;\n#define glClampColor glad_glClampColor\ntypedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint, GLenum);\nGLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;\n#define glBeginConditionalRender glad_glBeginConditionalRender\ntypedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)();\nGLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;\n#define glEndConditionalRender glad_glEndConditionalRender\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint, GLint, GLenum, GLsizei, const void*);\nGLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;\n#define glVertexAttribIPointer glad_glVertexAttribIPointer\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint, GLenum, GLint*);\nGLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;\n#define glGetVertexAttribIiv glad_glGetVertexAttribIiv\ntypedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint, GLenum, GLuint*);\nGLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;\n#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint, GLint);\nGLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;\n#define glVertexAttribI1i glad_glVertexAttribI1i\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint, GLint, GLint);\nGLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;\n#define glVertexAttribI2i glad_glVertexAttribI2i\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint, GLint, GLint, GLint);\nGLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;\n#define glVertexAttribI3i glad_glVertexAttribI3i\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint, GLint, GLint, GLint, GLint);\nGLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;\n#define glVertexAttribI4i glad_glVertexAttribI4i\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint, GLuint);\nGLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;\n#define glVertexAttribI1ui glad_glVertexAttribI1ui\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint, GLuint, GLuint);\nGLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;\n#define glVertexAttribI2ui glad_glVertexAttribI2ui\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint, GLuint, GLuint, GLuint);\nGLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;\n#define glVertexAttribI3ui glad_glVertexAttribI3ui\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint, GLuint, GLuint, GLuint, GLuint);\nGLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;\n#define glVertexAttribI4ui glad_glVertexAttribI4ui\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;\n#define glVertexAttribI1iv glad_glVertexAttribI1iv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;\n#define glVertexAttribI2iv glad_glVertexAttribI2iv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;\n#define glVertexAttribI3iv glad_glVertexAttribI3iv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint, const GLint*);\nGLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;\n#define glVertexAttribI4iv glad_glVertexAttribI4iv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;\n#define glVertexAttribI1uiv glad_glVertexAttribI1uiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;\n#define glVertexAttribI2uiv glad_glVertexAttribI2uiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;\n#define glVertexAttribI3uiv glad_glVertexAttribI3uiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint, const GLuint*);\nGLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;\n#define glVertexAttribI4uiv glad_glVertexAttribI4uiv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint, const GLbyte*);\nGLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;\n#define glVertexAttribI4bv glad_glVertexAttribI4bv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint, const GLshort*);\nGLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;\n#define glVertexAttribI4sv glad_glVertexAttribI4sv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint, const GLubyte*);\nGLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;\n#define glVertexAttribI4ubv glad_glVertexAttribI4ubv\ntypedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint, const GLushort*);\nGLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;\n#define glVertexAttribI4usv glad_glVertexAttribI4usv\ntypedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint, GLint, GLuint*);\nGLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;\n#define glGetUniformuiv glad_glGetUniformuiv\ntypedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint, GLuint, const GLchar*);\nGLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;\n#define glBindFragDataLocation glad_glBindFragDataLocation\ntypedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint, const GLchar*);\nGLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;\n#define glGetFragDataLocation glad_glGetFragDataLocation\ntypedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint, GLuint);\nGLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui;\n#define glUniform1ui glad_glUniform1ui\ntypedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint, GLuint, GLuint);\nGLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui;\n#define glUniform2ui glad_glUniform2ui\ntypedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint, GLuint, GLuint, GLuint);\nGLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui;\n#define glUniform3ui glad_glUniform3ui\ntypedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint, GLuint, GLuint, GLuint, GLuint);\nGLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui;\n#define glUniform4ui glad_glUniform4ui\ntypedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint, GLsizei, const GLuint*);\nGLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;\n#define glUniform1uiv glad_glUniform1uiv\ntypedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint, GLsizei, const GLuint*);\nGLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;\n#define glUniform2uiv glad_glUniform2uiv\ntypedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint, GLsizei, const GLuint*);\nGLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;\n#define glUniform3uiv glad_glUniform3uiv\ntypedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint, GLsizei, const GLuint*);\nGLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;\n#define glUniform4uiv glad_glUniform4uiv\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum, GLenum, const GLint*);\nGLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;\n#define glTexParameterIiv glad_glTexParameterIiv\ntypedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum, GLenum, const GLuint*);\nGLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;\n#define glTexParameterIuiv glad_glTexParameterIuiv\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum, GLenum, GLint*);\nGLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;\n#define glGetTexParameterIiv glad_glGetTexParameterIiv\ntypedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum, GLenum, GLuint*);\nGLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;\n#define glGetTexParameterIuiv glad_glGetTexParameterIuiv\ntypedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum, GLint, const GLint*);\nGLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;\n#define glClearBufferiv glad_glClearBufferiv\ntypedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum, GLint, const GLuint*);\nGLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;\n#define glClearBufferuiv glad_glClearBufferuiv\ntypedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum, GLint, const GLfloat*);\nGLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;\n#define glClearBufferfv glad_glClearBufferfv\ntypedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum, GLint, GLfloat, GLint);\nGLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;\n#define glClearBufferfi glad_glClearBufferfi\ntypedef const GLubyte* (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum, GLuint);\nGLAPI PFNGLGETSTRINGIPROC glad_glGetStringi;\n#define glGetStringi glad_glGetStringi\ntypedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint);\nGLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;\n#define glIsRenderbuffer glad_glIsRenderbuffer\ntypedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum, GLuint);\nGLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;\n#define glBindRenderbuffer glad_glBindRenderbuffer\ntypedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;\n#define glDeleteRenderbuffers glad_glDeleteRenderbuffers\ntypedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;\n#define glGenRenderbuffers glad_glGenRenderbuffers\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum, GLenum, GLsizei, GLsizei);\nGLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;\n#define glRenderbufferStorage glad_glRenderbufferStorage\ntypedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum, GLenum, GLint*);\nGLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;\n#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv\ntypedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint);\nGLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;\n#define glIsFramebuffer glad_glIsFramebuffer\ntypedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum, GLuint);\nGLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;\n#define glBindFramebuffer glad_glBindFramebuffer\ntypedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;\n#define glDeleteFramebuffers glad_glDeleteFramebuffers\ntypedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;\n#define glGenFramebuffers glad_glGenFramebuffers\ntypedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum);\nGLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;\n#define glCheckFramebufferStatus glad_glCheckFramebufferStatus\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum, GLenum, GLenum, GLuint, GLint);\nGLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;\n#define glFramebufferTexture1D glad_glFramebufferTexture1D\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum, GLenum, GLenum, GLuint, GLint);\nGLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;\n#define glFramebufferTexture2D glad_glFramebufferTexture2D\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum, GLenum, GLenum, GLuint, GLint, GLint);\nGLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;\n#define glFramebufferTexture3D glad_glFramebufferTexture3D\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum, GLenum, GLenum, GLuint);\nGLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;\n#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer\ntypedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum, GLenum, GLenum, GLint*);\nGLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;\n#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv\ntypedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum);\nGLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;\n#define glGenerateMipmap glad_glGenerateMipmap\ntypedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);\nGLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;\n#define glBlitFramebuffer glad_glBlitFramebuffer\ntypedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);\nGLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;\n#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum, GLenum, GLuint, GLint, GLint);\nGLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;\n#define glFramebufferTextureLayer glad_glFramebufferTextureLayer\ntypedef void* (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum, GLintptr, GLsizeiptr, GLbitfield);\nGLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;\n#define glMapBufferRange glad_glMapBufferRange\ntypedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum, GLintptr, GLsizeiptr);\nGLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;\n#define glFlushMappedBufferRange glad_glFlushMappedBufferRange\ntypedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint);\nGLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;\n#define glBindVertexArray glad_glBindVertexArray\ntypedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei, const GLuint*);\nGLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;\n#define glDeleteVertexArrays glad_glDeleteVertexArrays\ntypedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei, GLuint*);\nGLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;\n#define glGenVertexArrays glad_glGenVertexArrays\ntypedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint);\nGLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;\n#define glIsVertexArray glad_glIsVertexArray\n#endif\n#ifndef GL_VERSION_3_1\n#define GL_VERSION_3_1 1\nGLAPI int GLAD_GL_VERSION_3_1;\ntypedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum, GLint, GLsizei, GLsizei);\nGLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;\n#define glDrawArraysInstanced glad_glDrawArraysInstanced\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum, GLsizei, GLenum, const void*, GLsizei);\nGLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;\n#define glDrawElementsInstanced glad_glDrawElementsInstanced\ntypedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum, GLenum, GLuint);\nGLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer;\n#define glTexBuffer glad_glTexBuffer\ntypedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint);\nGLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;\n#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex\ntypedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr);\nGLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;\n#define glCopyBufferSubData glad_glCopyBufferSubData\ntypedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint, GLsizei, const GLchar**, GLuint*);\nGLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;\n#define glGetUniformIndices glad_glGetUniformIndices\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint, GLsizei, const GLuint*, GLenum, GLint*);\nGLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;\n#define glGetActiveUniformsiv glad_glGetActiveUniformsiv\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint, GLuint, GLsizei, GLsizei*, GLchar*);\nGLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;\n#define glGetActiveUniformName glad_glGetActiveUniformName\ntypedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint, const GLchar*);\nGLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;\n#define glGetUniformBlockIndex glad_glGetUniformBlockIndex\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint, GLuint, GLenum, GLint*);\nGLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;\n#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv\ntypedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint, GLuint, GLsizei, GLsizei*, GLchar*);\nGLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;\n#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName\ntypedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint, GLuint, GLuint);\nGLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;\n#define glUniformBlockBinding glad_glUniformBlockBinding\n#endif\n#ifndef GL_VERSION_3_2\n#define GL_VERSION_3_2 1\nGLAPI int GLAD_GL_VERSION_3_2;\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum, GLsizei, GLenum, const void*, GLint);\nGLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;\n#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex\ntypedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void*, GLint);\nGLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;\n#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex\ntypedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum, GLsizei, GLenum, const void*, GLsizei, GLint);\nGLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;\n#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex\ntypedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum, const GLsizei*, GLenum, const void**, GLsizei, const GLint*);\nGLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;\n#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex\ntypedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum);\nGLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;\n#define glProvokingVertex glad_glProvokingVertex\ntypedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum, GLbitfield);\nGLAPI PFNGLFENCESYNCPROC glad_glFenceSync;\n#define glFenceSync glad_glFenceSync\ntypedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync);\nGLAPI PFNGLISSYNCPROC glad_glIsSync;\n#define glIsSync glad_glIsSync\ntypedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync);\nGLAPI PFNGLDELETESYNCPROC glad_glDeleteSync;\n#define glDeleteSync glad_glDeleteSync\ntypedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync, GLbitfield, GLuint64);\nGLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;\n#define glClientWaitSync glad_glClientWaitSync\ntypedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync, GLbitfield, GLuint64);\nGLAPI PFNGLWAITSYNCPROC glad_glWaitSync;\n#define glWaitSync glad_glWaitSync\ntypedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum, GLint64*);\nGLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v;\n#define glGetInteger64v glad_glGetInteger64v\ntypedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync, GLenum, GLsizei, GLsizei*, GLint*);\nGLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv;\n#define glGetSynciv glad_glGetSynciv\ntypedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum, GLuint, GLint64*);\nGLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;\n#define glGetInteger64i_v glad_glGetInteger64i_v\ntypedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum, GLenum, GLint64*);\nGLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;\n#define glGetBufferParameteri64v glad_glGetBufferParameteri64v\ntypedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum, GLenum, GLuint, GLint);\nGLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;\n#define glFramebufferTexture glad_glFramebufferTexture\ntypedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLboolean);\nGLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;\n#define glTexImage2DMultisample glad_glTexImage2DMultisample\ntypedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean);\nGLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;\n#define glTexImage3DMultisample glad_glTexImage3DMultisample\ntypedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum, GLuint, GLfloat*);\nGLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;\n#define glGetMultisamplefv glad_glGetMultisamplefv\ntypedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint, GLbitfield);\nGLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski;\n#define glSampleMaski glad_glSampleMaski\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "deps/glfw/deps/glad.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include <glad/glad.h>\n\nstruct gladGLversionStruct GLVersion;\n\n#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)\n#define _GLAD_IS_SOME_NEW_VERSION 1\n#endif\n\nint GLAD_GL_VERSION_1_0;\nint GLAD_GL_VERSION_1_1;\nint GLAD_GL_VERSION_1_2;\nint GLAD_GL_VERSION_1_3;\nint GLAD_GL_VERSION_1_4;\nint GLAD_GL_VERSION_1_5;\nint GLAD_GL_VERSION_2_0;\nint GLAD_GL_VERSION_2_1;\nint GLAD_GL_VERSION_3_0;\nint GLAD_GL_VERSION_3_1;\nint GLAD_GL_VERSION_3_2;\nPFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;\nPFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;\nPFNGLFLUSHPROC glad_glFlush;\nPFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;\nPFNGLCLEARCOLORPROC glad_glClearColor;\nPFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;\nPFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;\nPFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;\nPFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;\nPFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;\nPFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;\nPFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;\nPFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;\nPFNGLLINKPROGRAMPROC glad_glLinkProgram;\nPFNGLBINDTEXTUREPROC glad_glBindTexture;\nPFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;\nPFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;\nPFNGLFENCESYNCPROC glad_glFenceSync;\nPFNGLUNIFORM3UIPROC glad_glUniform3ui;\nPFNGLUNIFORM2UIVPROC glad_glUniform2uiv;\nPFNGLGETSTRINGPROC glad_glGetString;\nPFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;\nPFNGLDETACHSHADERPROC glad_glDetachShader;\nPFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;\nPFNGLGENBUFFERSPROC glad_glGenBuffers;\nPFNGLENDQUERYPROC glad_glEndQuery;\nPFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;\nPFNGLLINEWIDTHPROC glad_glLineWidth;\nPFNGLUNIFORM2FVPROC glad_glUniform2fv;\nPFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;\nPFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;\nPFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;\nPFNGLCOMPILESHADERPROC glad_glCompileShader;\nPFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;\nPFNGLDELETETEXTURESPROC glad_glDeleteTextures;\nPFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;\nPFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;\nPFNGLPOLYGONMODEPROC glad_glPolygonMode;\nPFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;\nPFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;\nPFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;\nPFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;\nPFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;\nPFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;\nPFNGLISSYNCPROC glad_glIsSync;\nPFNGLCLAMPCOLORPROC glad_glClampColor;\nPFNGLUNIFORM4IVPROC glad_glUniform4iv;\nPFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;\nPFNGLCLEARSTENCILPROC glad_glClearStencil;\nPFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;\nPFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;\nPFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;\nPFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;\nPFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;\nPFNGLENABLEIPROC glad_glEnablei;\nPFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;\nPFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;\nPFNGLGENTEXTURESPROC glad_glGenTextures;\nPFNGLDEPTHFUNCPROC glad_glDepthFunc;\nPFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;\nPFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;\nPFNGLUNIFORM1FPROC glad_glUniform1f;\nPFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;\nPFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;\nPFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;\nPFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;\nPFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;\nPFNGLISVERTEXARRAYPROC glad_glIsVertexArray;\nPFNGLCREATESHADERPROC glad_glCreateShader;\nPFNGLISBUFFERPROC glad_glIsBuffer;\nPFNGLUNIFORM1IPROC glad_glUniform1i;\nPFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;\nPFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;\nPFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;\nPFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;\nPFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;\nPFNGLDISABLEPROC glad_glDisable;\nPFNGLUNIFORM2IPROC glad_glUniform2i;\nPFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;\nPFNGLLOGICOPPROC glad_glLogicOp;\nPFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;\nPFNGLGETPROGRAMIVPROC glad_glGetProgramiv;\nPFNGLCOLORMASKPROC glad_glColorMask;\nPFNGLHINTPROC glad_glHint;\nPFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;\nPFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;\nPFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;\nPFNGLBLENDEQUATIONPROC glad_glBlendEquation;\nPFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;\nPFNGLSAMPLEMASKIPROC glad_glSampleMaski;\nPFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;\nPFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;\nPFNGLCULLFACEPROC glad_glCullFace;\nPFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;\nPFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;\nPFNGLUNIFORM4FVPROC glad_glUniform4fv;\nPFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;\nPFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;\nPFNGLUNIFORM1UIVPROC glad_glUniform1uiv;\nPFNGLPOINTSIZEPROC glad_glPointSize;\nPFNGLGETSTRINGIPROC glad_glGetStringi;\nPFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;\nPFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;\nPFNGLDELETEPROGRAMPROC glad_glDeleteProgram;\nPFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;\nPFNGLGENQUERIESPROC glad_glGenQueries;\nPFNGLWAITSYNCPROC glad_glWaitSync;\nPFNGLATTACHSHADERPROC glad_glAttachShader;\nPFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;\nPFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;\nPFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;\nPFNGLUNIFORM3IPROC glad_glUniform3i;\nPFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;\nPFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;\nPFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;\nPFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;\nPFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;\nPFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;\nPFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;\nPFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;\nPFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;\nPFNGLUNIFORM3FPROC glad_glUniform3f;\nPFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;\nPFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;\nPFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;\nPFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;\nPFNGLDRAWELEMENTSPROC glad_glDrawElements;\nPFNGLCOLORMASKIPROC glad_glColorMaski;\nPFNGLISENABLEDIPROC glad_glIsEnabledi;\nPFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;\nPFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;\nPFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;\nPFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;\nPFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;\nPFNGLBUFFERSUBDATAPROC glad_glBufferSubData;\nPFNGLUNIFORM1IVPROC glad_glUniform1iv;\nPFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;\nPFNGLUNIFORM4UIVPROC glad_glUniform4uiv;\nPFNGLREADBUFFERPROC glad_glReadBuffer;\nPFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;\nPFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;\nPFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;\nPFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;\nPFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;\nPFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;\nPFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;\nPFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;\nPFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;\nPFNGLGETSHADERIVPROC glad_glGetShaderiv;\nPFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;\nPFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;\nPFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;\nPFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;\nPFNGLPOINTPARAMETERIPROC glad_glPointParameteri;\nPFNGLBLENDCOLORPROC glad_glBlendColor;\nPFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;\nPFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;\nPFNGLDEPTHMASKPROC glad_glDepthMask;\nPFNGLPOINTPARAMETERFPROC glad_glPointParameterf;\nPFNGLDISABLEIPROC glad_glDisablei;\nPFNGLGETDOUBLEVPROC glad_glGetDoublev;\nPFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;\nPFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;\nPFNGLSHADERSOURCEPROC glad_glShaderSource;\nPFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;\nPFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;\nPFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;\nPFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;\nPFNGLDRAWARRAYSPROC glad_glDrawArrays;\nPFNGLUNIFORM1UIPROC glad_glUniform1ui;\nPFNGLISPROGRAMPROC glad_glIsProgram;\nPFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;\nPFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;\nPFNGLGETSYNCIVPROC glad_glGetSynciv;\nPFNGLGETUNIFORMIVPROC glad_glGetUniformiv;\nPFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;\nPFNGLUNIFORM4IPROC glad_glUniform4i;\nPFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;\nPFNGLCLEARPROC glad_glClear;\nPFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;\nPFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;\nPFNGLUNIFORM2FPROC glad_glUniform2f;\nPFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;\nPFNGLACTIVETEXTUREPROC glad_glActiveTexture;\nPFNGLBEGINQUERYPROC glad_glBeginQuery;\nPFNGLUNIFORM2IVPROC glad_glUniform2iv;\nPFNGLBINDBUFFERPROC glad_glBindBuffer;\nPFNGLISENABLEDPROC glad_glIsEnabled;\nPFNGLSTENCILOPPROC glad_glStencilOp;\nPFNGLREADPIXELSPROC glad_glReadPixels;\nPFNGLCLEARDEPTHPROC glad_glClearDepth;\nPFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;\nPFNGLUNIFORM4FPROC glad_glUniform4f;\nPFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;\nPFNGLMAPBUFFERPROC glad_glMapBuffer;\nPFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;\nPFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;\nPFNGLUNIFORM3FVPROC glad_glUniform3fv;\nPFNGLGETUNIFORMFVPROC glad_glGetUniformfv;\nPFNGLBUFFERDATAPROC glad_glBufferData;\nPFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;\nPFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;\nPFNGLTEXIMAGE1DPROC glad_glTexImage1D;\nPFNGLDELETESYNCPROC glad_glDeleteSync;\nPFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;\nPFNGLGETERRORPROC glad_glGetError;\nPFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;\nPFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;\nPFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;\nPFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;\nPFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;\nPFNGLGETFLOATVPROC glad_glGetFloatv;\nPFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;\nPFNGLUNIFORM3IVPROC glad_glUniform3iv;\nPFNGLGETTEXIMAGEPROC glad_glGetTexImage;\nPFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;\nPFNGLUSEPROGRAMPROC glad_glUseProgram;\nPFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;\nPFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;\nPFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;\nPFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;\nPFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;\nPFNGLDRAWBUFFERSPROC glad_glDrawBuffers;\nPFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;\nPFNGLSTENCILFUNCPROC glad_glStencilFunc;\nPFNGLGETINTEGERVPROC glad_glGetIntegerv;\nPFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;\nPFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;\nPFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;\nPFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;\nPFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;\nPFNGLDRAWBUFFERPROC glad_glDrawBuffer;\nPFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;\nPFNGLUNIFORM1FVPROC glad_glUniform1fv;\nPFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;\nPFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;\nPFNGLISQUERYPROC glad_glIsQuery;\nPFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;\nPFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;\nPFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;\nPFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;\nPFNGLGETQUERYIVPROC glad_glGetQueryiv;\nPFNGLTEXIMAGE2DPROC glad_glTexImage2D;\nPFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;\nPFNGLSTENCILMASKPROC glad_glStencilMask;\nPFNGLUNIFORM4UIPROC glad_glUniform4ui;\nPFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;\nPFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;\nPFNGLISTEXTUREPROC glad_glIsTexture;\nPFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;\nPFNGLISSHADERPROC glad_glIsShader;\nPFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;\nPFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;\nPFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;\nPFNGLGETINTEGER64VPROC glad_glGetInteger64v;\nPFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;\nPFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;\nPFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;\nPFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;\nPFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;\nPFNGLENABLEPROC glad_glEnable;\nPFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;\nPFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;\nPFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;\nPFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;\nPFNGLDELETEQUERIESPROC glad_glDeleteQueries;\nPFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;\nPFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;\nPFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;\nPFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;\nPFNGLFINISHPROC glad_glFinish;\nPFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;\nPFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;\nPFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;\nPFNGLDELETESHADERPROC glad_glDeleteShader;\nPFNGLBLENDFUNCPROC glad_glBlendFunc;\nPFNGLCREATEPROGRAMPROC glad_glCreateProgram;\nPFNGLTEXIMAGE3DPROC glad_glTexImage3D;\nPFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;\nPFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;\nPFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;\nPFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;\nPFNGLVIEWPORTPROC glad_glViewport;\nPFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;\nPFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;\nPFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;\nPFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;\nPFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;\nPFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;\nPFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;\nPFNGLUNIFORM2UIPROC glad_glUniform2ui;\nPFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;\nPFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;\nPFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;\nPFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;\nPFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;\nPFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;\nPFNGLDEPTHRANGEPROC glad_glDepthRange;\nPFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;\nPFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;\nPFNGLTEXPARAMETERFPROC glad_glTexParameterf;\nPFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;\nPFNGLTEXPARAMETERIPROC glad_glTexParameteri;\nPFNGLFRONTFACEPROC glad_glFrontFace;\nPFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;\nPFNGLSCISSORPROC glad_glScissor;\nPFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;\nPFNGLGETBOOLEANVPROC glad_glGetBooleanv;\nPFNGLTEXBUFFERPROC glad_glTexBuffer;\nPFNGLPIXELSTOREIPROC glad_glPixelStorei;\nPFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;\nPFNGLPIXELSTOREFPROC glad_glPixelStoref;\nPFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;\nPFNGLUNIFORM3UIVPROC glad_glUniform3uiv;\nPFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;\nPFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;\nstatic void load_GL_VERSION_1_0(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_0) return;\n\tglad_glCullFace = (PFNGLCULLFACEPROC)load(\"glCullFace\");\n\tglad_glFrontFace = (PFNGLFRONTFACEPROC)load(\"glFrontFace\");\n\tglad_glHint = (PFNGLHINTPROC)load(\"glHint\");\n\tglad_glLineWidth = (PFNGLLINEWIDTHPROC)load(\"glLineWidth\");\n\tglad_glPointSize = (PFNGLPOINTSIZEPROC)load(\"glPointSize\");\n\tglad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load(\"glPolygonMode\");\n\tglad_glScissor = (PFNGLSCISSORPROC)load(\"glScissor\");\n\tglad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load(\"glTexParameterf\");\n\tglad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load(\"glTexParameterfv\");\n\tglad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load(\"glTexParameteri\");\n\tglad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load(\"glTexParameteriv\");\n\tglad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load(\"glTexImage1D\");\n\tglad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load(\"glTexImage2D\");\n\tglad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load(\"glDrawBuffer\");\n\tglad_glClear = (PFNGLCLEARPROC)load(\"glClear\");\n\tglad_glClearColor = (PFNGLCLEARCOLORPROC)load(\"glClearColor\");\n\tglad_glClearStencil = (PFNGLCLEARSTENCILPROC)load(\"glClearStencil\");\n\tglad_glClearDepth = (PFNGLCLEARDEPTHPROC)load(\"glClearDepth\");\n\tglad_glStencilMask = (PFNGLSTENCILMASKPROC)load(\"glStencilMask\");\n\tglad_glColorMask = (PFNGLCOLORMASKPROC)load(\"glColorMask\");\n\tglad_glDepthMask = (PFNGLDEPTHMASKPROC)load(\"glDepthMask\");\n\tglad_glDisable = (PFNGLDISABLEPROC)load(\"glDisable\");\n\tglad_glEnable = (PFNGLENABLEPROC)load(\"glEnable\");\n\tglad_glFinish = (PFNGLFINISHPROC)load(\"glFinish\");\n\tglad_glFlush = (PFNGLFLUSHPROC)load(\"glFlush\");\n\tglad_glBlendFunc = (PFNGLBLENDFUNCPROC)load(\"glBlendFunc\");\n\tglad_glLogicOp = (PFNGLLOGICOPPROC)load(\"glLogicOp\");\n\tglad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load(\"glStencilFunc\");\n\tglad_glStencilOp = (PFNGLSTENCILOPPROC)load(\"glStencilOp\");\n\tglad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load(\"glDepthFunc\");\n\tglad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load(\"glPixelStoref\");\n\tglad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load(\"glPixelStorei\");\n\tglad_glReadBuffer = (PFNGLREADBUFFERPROC)load(\"glReadBuffer\");\n\tglad_glReadPixels = (PFNGLREADPIXELSPROC)load(\"glReadPixels\");\n\tglad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load(\"glGetBooleanv\");\n\tglad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load(\"glGetDoublev\");\n\tglad_glGetError = (PFNGLGETERRORPROC)load(\"glGetError\");\n\tglad_glGetFloatv = (PFNGLGETFLOATVPROC)load(\"glGetFloatv\");\n\tglad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load(\"glGetIntegerv\");\n\tglad_glGetString = (PFNGLGETSTRINGPROC)load(\"glGetString\");\n\tglad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load(\"glGetTexImage\");\n\tglad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load(\"glGetTexParameterfv\");\n\tglad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load(\"glGetTexParameteriv\");\n\tglad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load(\"glGetTexLevelParameterfv\");\n\tglad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load(\"glGetTexLevelParameteriv\");\n\tglad_glIsEnabled = (PFNGLISENABLEDPROC)load(\"glIsEnabled\");\n\tglad_glDepthRange = (PFNGLDEPTHRANGEPROC)load(\"glDepthRange\");\n\tglad_glViewport = (PFNGLVIEWPORTPROC)load(\"glViewport\");\n}\nstatic void load_GL_VERSION_1_1(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_1) return;\n\tglad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load(\"glDrawArrays\");\n\tglad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load(\"glDrawElements\");\n\tglad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load(\"glPolygonOffset\");\n\tglad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load(\"glCopyTexImage1D\");\n\tglad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load(\"glCopyTexImage2D\");\n\tglad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load(\"glCopyTexSubImage1D\");\n\tglad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load(\"glCopyTexSubImage2D\");\n\tglad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load(\"glTexSubImage1D\");\n\tglad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load(\"glTexSubImage2D\");\n\tglad_glBindTexture = (PFNGLBINDTEXTUREPROC)load(\"glBindTexture\");\n\tglad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load(\"glDeleteTextures\");\n\tglad_glGenTextures = (PFNGLGENTEXTURESPROC)load(\"glGenTextures\");\n\tglad_glIsTexture = (PFNGLISTEXTUREPROC)load(\"glIsTexture\");\n}\nstatic void load_GL_VERSION_1_2(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_2) return;\n\tglad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load(\"glDrawRangeElements\");\n\tglad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load(\"glTexImage3D\");\n\tglad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load(\"glTexSubImage3D\");\n\tglad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load(\"glCopyTexSubImage3D\");\n}\nstatic void load_GL_VERSION_1_3(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_3) return;\n\tglad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load(\"glActiveTexture\");\n\tglad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load(\"glSampleCoverage\");\n\tglad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load(\"glCompressedTexImage3D\");\n\tglad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load(\"glCompressedTexImage2D\");\n\tglad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load(\"glCompressedTexImage1D\");\n\tglad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load(\"glCompressedTexSubImage3D\");\n\tglad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load(\"glCompressedTexSubImage2D\");\n\tglad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load(\"glCompressedTexSubImage1D\");\n\tglad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load(\"glGetCompressedTexImage\");\n}\nstatic void load_GL_VERSION_1_4(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_4) return;\n\tglad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load(\"glBlendFuncSeparate\");\n\tglad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load(\"glMultiDrawArrays\");\n\tglad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load(\"glMultiDrawElements\");\n\tglad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load(\"glPointParameterf\");\n\tglad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load(\"glPointParameterfv\");\n\tglad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load(\"glPointParameteri\");\n\tglad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load(\"glPointParameteriv\");\n\tglad_glBlendColor = (PFNGLBLENDCOLORPROC)load(\"glBlendColor\");\n\tglad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load(\"glBlendEquation\");\n}\nstatic void load_GL_VERSION_1_5(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_1_5) return;\n\tglad_glGenQueries = (PFNGLGENQUERIESPROC)load(\"glGenQueries\");\n\tglad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load(\"glDeleteQueries\");\n\tglad_glIsQuery = (PFNGLISQUERYPROC)load(\"glIsQuery\");\n\tglad_glBeginQuery = (PFNGLBEGINQUERYPROC)load(\"glBeginQuery\");\n\tglad_glEndQuery = (PFNGLENDQUERYPROC)load(\"glEndQuery\");\n\tglad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load(\"glGetQueryiv\");\n\tglad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load(\"glGetQueryObjectiv\");\n\tglad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load(\"glGetQueryObjectuiv\");\n\tglad_glBindBuffer = (PFNGLBINDBUFFERPROC)load(\"glBindBuffer\");\n\tglad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load(\"glDeleteBuffers\");\n\tglad_glGenBuffers = (PFNGLGENBUFFERSPROC)load(\"glGenBuffers\");\n\tglad_glIsBuffer = (PFNGLISBUFFERPROC)load(\"glIsBuffer\");\n\tglad_glBufferData = (PFNGLBUFFERDATAPROC)load(\"glBufferData\");\n\tglad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load(\"glBufferSubData\");\n\tglad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load(\"glGetBufferSubData\");\n\tglad_glMapBuffer = (PFNGLMAPBUFFERPROC)load(\"glMapBuffer\");\n\tglad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load(\"glUnmapBuffer\");\n\tglad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load(\"glGetBufferParameteriv\");\n\tglad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load(\"glGetBufferPointerv\");\n}\nstatic void load_GL_VERSION_2_0(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_2_0) return;\n\tglad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load(\"glBlendEquationSeparate\");\n\tglad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load(\"glDrawBuffers\");\n\tglad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load(\"glStencilOpSeparate\");\n\tglad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load(\"glStencilFuncSeparate\");\n\tglad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load(\"glStencilMaskSeparate\");\n\tglad_glAttachShader = (PFNGLATTACHSHADERPROC)load(\"glAttachShader\");\n\tglad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load(\"glBindAttribLocation\");\n\tglad_glCompileShader = (PFNGLCOMPILESHADERPROC)load(\"glCompileShader\");\n\tglad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load(\"glCreateProgram\");\n\tglad_glCreateShader = (PFNGLCREATESHADERPROC)load(\"glCreateShader\");\n\tglad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load(\"glDeleteProgram\");\n\tglad_glDeleteShader = (PFNGLDELETESHADERPROC)load(\"glDeleteShader\");\n\tglad_glDetachShader = (PFNGLDETACHSHADERPROC)load(\"glDetachShader\");\n\tglad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load(\"glDisableVertexAttribArray\");\n\tglad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load(\"glEnableVertexAttribArray\");\n\tglad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load(\"glGetActiveAttrib\");\n\tglad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load(\"glGetActiveUniform\");\n\tglad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load(\"glGetAttachedShaders\");\n\tglad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load(\"glGetAttribLocation\");\n\tglad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load(\"glGetProgramiv\");\n\tglad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load(\"glGetProgramInfoLog\");\n\tglad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load(\"glGetShaderiv\");\n\tglad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load(\"glGetShaderInfoLog\");\n\tglad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load(\"glGetShaderSource\");\n\tglad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load(\"glGetUniformLocation\");\n\tglad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load(\"glGetUniformfv\");\n\tglad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load(\"glGetUniformiv\");\n\tglad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load(\"glGetVertexAttribdv\");\n\tglad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load(\"glGetVertexAttribfv\");\n\tglad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load(\"glGetVertexAttribiv\");\n\tglad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load(\"glGetVertexAttribPointerv\");\n\tglad_glIsProgram = (PFNGLISPROGRAMPROC)load(\"glIsProgram\");\n\tglad_glIsShader = (PFNGLISSHADERPROC)load(\"glIsShader\");\n\tglad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load(\"glLinkProgram\");\n\tglad_glShaderSource = (PFNGLSHADERSOURCEPROC)load(\"glShaderSource\");\n\tglad_glUseProgram = (PFNGLUSEPROGRAMPROC)load(\"glUseProgram\");\n\tglad_glUniform1f = (PFNGLUNIFORM1FPROC)load(\"glUniform1f\");\n\tglad_glUniform2f = (PFNGLUNIFORM2FPROC)load(\"glUniform2f\");\n\tglad_glUniform3f = (PFNGLUNIFORM3FPROC)load(\"glUniform3f\");\n\tglad_glUniform4f = (PFNGLUNIFORM4FPROC)load(\"glUniform4f\");\n\tglad_glUniform1i = (PFNGLUNIFORM1IPROC)load(\"glUniform1i\");\n\tglad_glUniform2i = (PFNGLUNIFORM2IPROC)load(\"glUniform2i\");\n\tglad_glUniform3i = (PFNGLUNIFORM3IPROC)load(\"glUniform3i\");\n\tglad_glUniform4i = (PFNGLUNIFORM4IPROC)load(\"glUniform4i\");\n\tglad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load(\"glUniform1fv\");\n\tglad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load(\"glUniform2fv\");\n\tglad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load(\"glUniform3fv\");\n\tglad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load(\"glUniform4fv\");\n\tglad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load(\"glUniform1iv\");\n\tglad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load(\"glUniform2iv\");\n\tglad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load(\"glUniform3iv\");\n\tglad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load(\"glUniform4iv\");\n\tglad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load(\"glUniformMatrix2fv\");\n\tglad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load(\"glUniformMatrix3fv\");\n\tglad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load(\"glUniformMatrix4fv\");\n\tglad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load(\"glValidateProgram\");\n\tglad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load(\"glVertexAttrib1d\");\n\tglad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load(\"glVertexAttrib1dv\");\n\tglad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load(\"glVertexAttrib1f\");\n\tglad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load(\"glVertexAttrib1fv\");\n\tglad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load(\"glVertexAttrib1s\");\n\tglad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load(\"glVertexAttrib1sv\");\n\tglad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load(\"glVertexAttrib2d\");\n\tglad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load(\"glVertexAttrib2dv\");\n\tglad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load(\"glVertexAttrib2f\");\n\tglad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load(\"glVertexAttrib2fv\");\n\tglad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load(\"glVertexAttrib2s\");\n\tglad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load(\"glVertexAttrib2sv\");\n\tglad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load(\"glVertexAttrib3d\");\n\tglad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load(\"glVertexAttrib3dv\");\n\tglad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load(\"glVertexAttrib3f\");\n\tglad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load(\"glVertexAttrib3fv\");\n\tglad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load(\"glVertexAttrib3s\");\n\tglad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load(\"glVertexAttrib3sv\");\n\tglad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load(\"glVertexAttrib4Nbv\");\n\tglad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load(\"glVertexAttrib4Niv\");\n\tglad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load(\"glVertexAttrib4Nsv\");\n\tglad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load(\"glVertexAttrib4Nub\");\n\tglad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load(\"glVertexAttrib4Nubv\");\n\tglad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load(\"glVertexAttrib4Nuiv\");\n\tglad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load(\"glVertexAttrib4Nusv\");\n\tglad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load(\"glVertexAttrib4bv\");\n\tglad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load(\"glVertexAttrib4d\");\n\tglad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load(\"glVertexAttrib4dv\");\n\tglad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load(\"glVertexAttrib4f\");\n\tglad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load(\"glVertexAttrib4fv\");\n\tglad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load(\"glVertexAttrib4iv\");\n\tglad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load(\"glVertexAttrib4s\");\n\tglad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load(\"glVertexAttrib4sv\");\n\tglad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load(\"glVertexAttrib4ubv\");\n\tglad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load(\"glVertexAttrib4uiv\");\n\tglad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load(\"glVertexAttrib4usv\");\n\tglad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load(\"glVertexAttribPointer\");\n}\nstatic void load_GL_VERSION_2_1(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_2_1) return;\n\tglad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load(\"glUniformMatrix2x3fv\");\n\tglad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load(\"glUniformMatrix3x2fv\");\n\tglad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load(\"glUniformMatrix2x4fv\");\n\tglad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load(\"glUniformMatrix4x2fv\");\n\tglad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load(\"glUniformMatrix3x4fv\");\n\tglad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load(\"glUniformMatrix4x3fv\");\n}\nstatic void load_GL_VERSION_3_0(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_3_0) return;\n\tglad_glColorMaski = (PFNGLCOLORMASKIPROC)load(\"glColorMaski\");\n\tglad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load(\"glGetBooleani_v\");\n\tglad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load(\"glGetIntegeri_v\");\n\tglad_glEnablei = (PFNGLENABLEIPROC)load(\"glEnablei\");\n\tglad_glDisablei = (PFNGLDISABLEIPROC)load(\"glDisablei\");\n\tglad_glIsEnabledi = (PFNGLISENABLEDIPROC)load(\"glIsEnabledi\");\n\tglad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load(\"glBeginTransformFeedback\");\n\tglad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load(\"glEndTransformFeedback\");\n\tglad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load(\"glBindBufferRange\");\n\tglad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load(\"glBindBufferBase\");\n\tglad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load(\"glTransformFeedbackVaryings\");\n\tglad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load(\"glGetTransformFeedbackVarying\");\n\tglad_glClampColor = (PFNGLCLAMPCOLORPROC)load(\"glClampColor\");\n\tglad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load(\"glBeginConditionalRender\");\n\tglad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load(\"glEndConditionalRender\");\n\tglad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load(\"glVertexAttribIPointer\");\n\tglad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load(\"glGetVertexAttribIiv\");\n\tglad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load(\"glGetVertexAttribIuiv\");\n\tglad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load(\"glVertexAttribI1i\");\n\tglad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load(\"glVertexAttribI2i\");\n\tglad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load(\"glVertexAttribI3i\");\n\tglad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load(\"glVertexAttribI4i\");\n\tglad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load(\"glVertexAttribI1ui\");\n\tglad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load(\"glVertexAttribI2ui\");\n\tglad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load(\"glVertexAttribI3ui\");\n\tglad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load(\"glVertexAttribI4ui\");\n\tglad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load(\"glVertexAttribI1iv\");\n\tglad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load(\"glVertexAttribI2iv\");\n\tglad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load(\"glVertexAttribI3iv\");\n\tglad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load(\"glVertexAttribI4iv\");\n\tglad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load(\"glVertexAttribI1uiv\");\n\tglad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load(\"glVertexAttribI2uiv\");\n\tglad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load(\"glVertexAttribI3uiv\");\n\tglad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load(\"glVertexAttribI4uiv\");\n\tglad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load(\"glVertexAttribI4bv\");\n\tglad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load(\"glVertexAttribI4sv\");\n\tglad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load(\"glVertexAttribI4ubv\");\n\tglad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load(\"glVertexAttribI4usv\");\n\tglad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load(\"glGetUniformuiv\");\n\tglad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load(\"glBindFragDataLocation\");\n\tglad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load(\"glGetFragDataLocation\");\n\tglad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load(\"glUniform1ui\");\n\tglad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load(\"glUniform2ui\");\n\tglad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load(\"glUniform3ui\");\n\tglad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load(\"glUniform4ui\");\n\tglad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load(\"glUniform1uiv\");\n\tglad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load(\"glUniform2uiv\");\n\tglad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load(\"glUniform3uiv\");\n\tglad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load(\"glUniform4uiv\");\n\tglad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load(\"glTexParameterIiv\");\n\tglad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load(\"glTexParameterIuiv\");\n\tglad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load(\"glGetTexParameterIiv\");\n\tglad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load(\"glGetTexParameterIuiv\");\n\tglad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load(\"glClearBufferiv\");\n\tglad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load(\"glClearBufferuiv\");\n\tglad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load(\"glClearBufferfv\");\n\tglad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load(\"glClearBufferfi\");\n\tglad_glGetStringi = (PFNGLGETSTRINGIPROC)load(\"glGetStringi\");\n\tglad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load(\"glIsRenderbuffer\");\n\tglad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load(\"glBindRenderbuffer\");\n\tglad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load(\"glDeleteRenderbuffers\");\n\tglad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load(\"glGenRenderbuffers\");\n\tglad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load(\"glRenderbufferStorage\");\n\tglad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load(\"glGetRenderbufferParameteriv\");\n\tglad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load(\"glIsFramebuffer\");\n\tglad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load(\"glBindFramebuffer\");\n\tglad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load(\"glDeleteFramebuffers\");\n\tglad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load(\"glGenFramebuffers\");\n\tglad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load(\"glCheckFramebufferStatus\");\n\tglad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load(\"glFramebufferTexture1D\");\n\tglad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load(\"glFramebufferTexture2D\");\n\tglad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load(\"glFramebufferTexture3D\");\n\tglad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load(\"glFramebufferRenderbuffer\");\n\tglad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load(\"glGetFramebufferAttachmentParameteriv\");\n\tglad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load(\"glGenerateMipmap\");\n\tglad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load(\"glBlitFramebuffer\");\n\tglad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load(\"glRenderbufferStorageMultisample\");\n\tglad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load(\"glFramebufferTextureLayer\");\n\tglad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load(\"glMapBufferRange\");\n\tglad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load(\"glFlushMappedBufferRange\");\n\tglad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load(\"glBindVertexArray\");\n\tglad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load(\"glDeleteVertexArrays\");\n\tglad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load(\"glGenVertexArrays\");\n\tglad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load(\"glIsVertexArray\");\n}\nstatic void load_GL_VERSION_3_1(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_3_1) return;\n\tglad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load(\"glDrawArraysInstanced\");\n\tglad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load(\"glDrawElementsInstanced\");\n\tglad_glTexBuffer = (PFNGLTEXBUFFERPROC)load(\"glTexBuffer\");\n\tglad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load(\"glPrimitiveRestartIndex\");\n\tglad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load(\"glCopyBufferSubData\");\n\tglad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load(\"glGetUniformIndices\");\n\tglad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load(\"glGetActiveUniformsiv\");\n\tglad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load(\"glGetActiveUniformName\");\n\tglad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load(\"glGetUniformBlockIndex\");\n\tglad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load(\"glGetActiveUniformBlockiv\");\n\tglad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load(\"glGetActiveUniformBlockName\");\n\tglad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load(\"glUniformBlockBinding\");\n}\nstatic void load_GL_VERSION_3_2(GLADloadproc load) {\n\tif(!GLAD_GL_VERSION_3_2) return;\n\tglad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load(\"glDrawElementsBaseVertex\");\n\tglad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load(\"glDrawRangeElementsBaseVertex\");\n\tglad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load(\"glDrawElementsInstancedBaseVertex\");\n\tglad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load(\"glMultiDrawElementsBaseVertex\");\n\tglad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load(\"glProvokingVertex\");\n\tglad_glFenceSync = (PFNGLFENCESYNCPROC)load(\"glFenceSync\");\n\tglad_glIsSync = (PFNGLISSYNCPROC)load(\"glIsSync\");\n\tglad_glDeleteSync = (PFNGLDELETESYNCPROC)load(\"glDeleteSync\");\n\tglad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load(\"glClientWaitSync\");\n\tglad_glWaitSync = (PFNGLWAITSYNCPROC)load(\"glWaitSync\");\n\tglad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load(\"glGetInteger64v\");\n\tglad_glGetSynciv = (PFNGLGETSYNCIVPROC)load(\"glGetSynciv\");\n\tglad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load(\"glGetInteger64i_v\");\n\tglad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load(\"glGetBufferParameteri64v\");\n\tglad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load(\"glFramebufferTexture\");\n\tglad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load(\"glTexImage2DMultisample\");\n\tglad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load(\"glTexImage3DMultisample\");\n\tglad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load(\"glGetMultisamplefv\");\n\tglad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load(\"glSampleMaski\");\n}\nstatic void find_extensionsGL(void) {\n}\n\nstatic void find_coreGL(void) {\n\n    /* Thank you @elmindreda\n     * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176\n     * https://github.com/glfw/glfw/blob/master/src/context.c#L36\n     */\n    int i, major, minor;\n\n    const char* version;\n    const char* prefixes[] = {\n        \"OpenGL ES-CM \",\n        \"OpenGL ES-CL \",\n        \"OpenGL ES \",\n        NULL\n    };\n\n    version = (const char*) glGetString(GL_VERSION);\n    if (!version) return;\n\n    for (i = 0;  prefixes[i];  i++) {\n        const size_t length = strlen(prefixes[i]);\n        if (strncmp(version, prefixes[i], length) == 0) {\n            version += length;\n            break;\n        }\n    }\n\n    sscanf(version, \"%d.%d\", &major, &minor);\n    GLVersion.major = major; GLVersion.minor = minor;\n\tGLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;\n\tGLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;\n\tGLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;\n\tGLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;\n\tGLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;\n\tGLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;\n\tGLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;\n\tGLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;\n\tGLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;\n\tGLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;\n\tGLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;\n}\n\nint gladLoadGLLoader(GLADloadproc load) {\n\tGLVersion.major = 0; GLVersion.minor = 0;\n\tglGetString = (PFNGLGETSTRINGPROC)load(\"glGetString\");\n\tif(glGetString == NULL) return 0;\n\tif(glGetString(GL_VERSION) == NULL) return 0;\n\tfind_coreGL();\n\tload_GL_VERSION_1_0(load);\n\tload_GL_VERSION_1_1(load);\n\tload_GL_VERSION_1_2(load);\n\tload_GL_VERSION_1_3(load);\n\tload_GL_VERSION_1_4(load);\n\tload_GL_VERSION_1_5(load);\n\tload_GL_VERSION_2_0(load);\n\tload_GL_VERSION_2_1(load);\n\tload_GL_VERSION_3_0(load);\n\tload_GL_VERSION_3_1(load);\n\tload_GL_VERSION_3_2(load);\n\n\tfind_extensionsGL();\n\treturn GLVersion.major != 0 || GLVersion.minor != 0;\n}\n\n"
  },
  {
    "path": "deps/glfw/deps/linmath.h",
    "content": "#ifndef LINMATH_H\n#define LINMATH_H\n\n#include <math.h>\n\n#ifdef _MSC_VER \n#define inline __inline\n#endif\n\n#define LINMATH_H_DEFINE_VEC(n) \\\ntypedef float vec##n[n]; \\\nstatic inline void vec##n##_add(vec##n r, vec##n const a, vec##n const b) \\\n{ \\\n\tint i; \\\n\tfor(i=0; i<n; ++i) \\\n\t\tr[i] = a[i] + b[i]; \\\n} \\\nstatic inline void vec##n##_sub(vec##n r, vec##n const a, vec##n const b) \\\n{ \\\n\tint i; \\\n\tfor(i=0; i<n; ++i) \\\n\t\tr[i] = a[i] - b[i]; \\\n} \\\nstatic inline void vec##n##_scale(vec##n r, vec##n const v, float const s) \\\n{ \\\n\tint i; \\\n\tfor(i=0; i<n; ++i) \\\n\t\tr[i] = v[i] * s; \\\n} \\\nstatic inline float vec##n##_mul_inner(vec##n const a, vec##n const b) \\\n{ \\\n\tfloat p = 0.; \\\n\tint i; \\\n\tfor(i=0; i<n; ++i) \\\n\t\tp += b[i]*a[i]; \\\n\treturn p; \\\n} \\\nstatic inline float vec##n##_len(vec##n const v) \\\n{ \\\n\treturn sqrtf(vec##n##_mul_inner(v,v)); \\\n} \\\nstatic inline void vec##n##_norm(vec##n r, vec##n const v) \\\n{ \\\n\tfloat k = 1.f / vec##n##_len(v); \\\n\tvec##n##_scale(r, v, k); \\\n}\n\nLINMATH_H_DEFINE_VEC(2)\nLINMATH_H_DEFINE_VEC(3)\nLINMATH_H_DEFINE_VEC(4)\n\nstatic inline void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b)\n{\n\tr[0] = a[1]*b[2] - a[2]*b[1];\n\tr[1] = a[2]*b[0] - a[0]*b[2];\n\tr[2] = a[0]*b[1] - a[1]*b[0];\n}\n\nstatic inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n)\n{\n\tfloat p  = 2.f*vec3_mul_inner(v, n);\n\tint i;\n\tfor(i=0;i<3;++i)\n\t\tr[i] = v[i] - p*n[i];\n}\n\nstatic inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b)\n{\n\tr[0] = a[1]*b[2] - a[2]*b[1];\n\tr[1] = a[2]*b[0] - a[0]*b[2];\n\tr[2] = a[0]*b[1] - a[1]*b[0];\n\tr[3] = 1.f;\n}\n\nstatic inline void vec4_reflect(vec4 r, vec4 v, vec4 n)\n{\n\tfloat p  = 2.f*vec4_mul_inner(v, n);\n\tint i;\n\tfor(i=0;i<4;++i)\n\t\tr[i] = v[i] - p*n[i];\n}\n\ntypedef vec4 mat4x4[4];\nstatic inline void mat4x4_identity(mat4x4 M)\n{\n\tint i, j;\n\tfor(i=0; i<4; ++i)\n\t\tfor(j=0; j<4; ++j)\n\t\t\tM[i][j] = i==j ? 1.f : 0.f;\n}\nstatic inline void mat4x4_dup(mat4x4 M, mat4x4 N)\n{\n\tint i, j;\n\tfor(i=0; i<4; ++i)\n\t\tfor(j=0; j<4; ++j)\n\t\t\tM[i][j] = N[i][j];\n}\nstatic inline void mat4x4_row(vec4 r, mat4x4 M, int i)\n{\n\tint k;\n\tfor(k=0; k<4; ++k)\n\t\tr[k] = M[k][i];\n}\nstatic inline void mat4x4_col(vec4 r, mat4x4 M, int i)\n{\n\tint k;\n\tfor(k=0; k<4; ++k)\n\t\tr[k] = M[i][k];\n}\nstatic inline void mat4x4_transpose(mat4x4 M, mat4x4 N)\n{\n\tint i, j;\n\tfor(j=0; j<4; ++j)\n\t\tfor(i=0; i<4; ++i)\n\t\t\tM[i][j] = N[j][i];\n}\nstatic inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tvec4_add(M[i], a[i], b[i]);\n}\nstatic inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tvec4_sub(M[i], a[i], b[i]);\n}\nstatic inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tvec4_scale(M[i], a[i], k);\n}\nstatic inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z)\n{\n\tint i;\n\tvec4_scale(M[0], a[0], x);\n\tvec4_scale(M[1], a[1], y);\n\tvec4_scale(M[2], a[2], z);\n\tfor(i = 0; i < 4; ++i) {\n\t\tM[3][i] = a[3][i];\n\t}\n}\nstatic inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b)\n{\n\tmat4x4 temp;\n\tint k, r, c;\n\tfor(c=0; c<4; ++c) for(r=0; r<4; ++r) {\n\t\ttemp[c][r] = 0.f;\n\t\tfor(k=0; k<4; ++k)\n\t\t\ttemp[c][r] += a[k][r] * b[c][k];\n\t}\n\tmat4x4_dup(M, temp);\n}\nstatic inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v)\n{\n\tint i, j;\n\tfor(j=0; j<4; ++j) {\n\t\tr[j] = 0.f;\n\t\tfor(i=0; i<4; ++i)\n\t\t\tr[j] += M[i][j] * v[i];\n\t}\n}\nstatic inline void mat4x4_translate(mat4x4 T, float x, float y, float z)\n{\n\tmat4x4_identity(T);\n\tT[3][0] = x;\n\tT[3][1] = y;\n\tT[3][2] = z;\n}\nstatic inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z)\n{\n\tvec4 t = {x, y, z, 0};\n\tvec4 r;\n\tint i;\n\tfor (i = 0; i < 4; ++i) {\n\t\tmat4x4_row(r, M, i);\n\t\tM[3][i] += vec4_mul_inner(r, t);\n\t}\n}\nstatic inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b)\n{\n\tint i, j;\n\tfor(i=0; i<4; ++i) for(j=0; j<4; ++j)\n\t\tM[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f;\n}\nstatic inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle)\n{\n\tfloat s = sinf(angle);\n\tfloat c = cosf(angle);\n\tvec3 u = {x, y, z};\n\n\tif(vec3_len(u) > 1e-4) {\n\t\tvec3_norm(u, u);\n\t\tmat4x4 T;\n\t\tmat4x4_from_vec3_mul_outer(T, u, u);\n\n\t\tmat4x4 S = {\n\t\t\t{    0,  u[2], -u[1], 0},\n\t\t\t{-u[2],     0,  u[0], 0},\n\t\t\t{ u[1], -u[0],     0, 0},\n\t\t\t{    0,     0,     0, 0}\n\t\t};\n\t\tmat4x4_scale(S, S, s);\n\n\t\tmat4x4 C;\n\t\tmat4x4_identity(C);\n\t\tmat4x4_sub(C, C, T);\n\n\t\tmat4x4_scale(C, C, c);\n\n\t\tmat4x4_add(T, T, C);\n\t\tmat4x4_add(T, T, S);\n\n\t\tT[3][3] = 1.;\t\t\n\t\tmat4x4_mul(R, M, T);\n\t} else {\n\t\tmat4x4_dup(R, M);\n\t}\n}\nstatic inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle)\n{\n\tfloat s = sinf(angle);\n\tfloat c = cosf(angle);\n\tmat4x4 R = {\n\t\t{1.f, 0.f, 0.f, 0.f},\n\t\t{0.f,   c,   s, 0.f},\n\t\t{0.f,  -s,   c, 0.f},\n\t\t{0.f, 0.f, 0.f, 1.f}\n\t};\n\tmat4x4_mul(Q, M, R);\n}\nstatic inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle)\n{\n\tfloat s = sinf(angle);\n\tfloat c = cosf(angle);\n\tmat4x4 R = {\n\t\t{   c, 0.f,   s, 0.f},\n\t\t{ 0.f, 1.f, 0.f, 0.f},\n\t\t{  -s, 0.f,   c, 0.f},\n\t\t{ 0.f, 0.f, 0.f, 1.f}\n\t};\n\tmat4x4_mul(Q, M, R);\n}\nstatic inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle)\n{\n\tfloat s = sinf(angle);\n\tfloat c = cosf(angle);\n\tmat4x4 R = {\n\t\t{   c,   s, 0.f, 0.f},\n\t\t{  -s,   c, 0.f, 0.f},\n\t\t{ 0.f, 0.f, 1.f, 0.f},\n\t\t{ 0.f, 0.f, 0.f, 1.f}\n\t};\n\tmat4x4_mul(Q, M, R);\n}\nstatic inline void mat4x4_invert(mat4x4 T, mat4x4 M)\n{\n\tfloat s[6];\n\tfloat c[6];\n\ts[0] = M[0][0]*M[1][1] - M[1][0]*M[0][1];\n\ts[1] = M[0][0]*M[1][2] - M[1][0]*M[0][2];\n\ts[2] = M[0][0]*M[1][3] - M[1][0]*M[0][3];\n\ts[3] = M[0][1]*M[1][2] - M[1][1]*M[0][2];\n\ts[4] = M[0][1]*M[1][3] - M[1][1]*M[0][3];\n\ts[5] = M[0][2]*M[1][3] - M[1][2]*M[0][3];\n\n\tc[0] = M[2][0]*M[3][1] - M[3][0]*M[2][1];\n\tc[1] = M[2][0]*M[3][2] - M[3][0]*M[2][2];\n\tc[2] = M[2][0]*M[3][3] - M[3][0]*M[2][3];\n\tc[3] = M[2][1]*M[3][2] - M[3][1]*M[2][2];\n\tc[4] = M[2][1]*M[3][3] - M[3][1]*M[2][3];\n\tc[5] = M[2][2]*M[3][3] - M[3][2]*M[2][3];\n\t\n\t/* Assumes it is invertible */\n\tfloat idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] );\n\t\n\tT[0][0] = ( M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet;\n\tT[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet;\n\tT[0][2] = ( M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet;\n\tT[0][3] = (-M[2][1] * s[5] + M[2][2] * s[4] - M[2][3] * s[3]) * idet;\n\n\tT[1][0] = (-M[1][0] * c[5] + M[1][2] * c[2] - M[1][3] * c[1]) * idet;\n\tT[1][1] = ( M[0][0] * c[5] - M[0][2] * c[2] + M[0][3] * c[1]) * idet;\n\tT[1][2] = (-M[3][0] * s[5] + M[3][2] * s[2] - M[3][3] * s[1]) * idet;\n\tT[1][3] = ( M[2][0] * s[5] - M[2][2] * s[2] + M[2][3] * s[1]) * idet;\n\n\tT[2][0] = ( M[1][0] * c[4] - M[1][1] * c[2] + M[1][3] * c[0]) * idet;\n\tT[2][1] = (-M[0][0] * c[4] + M[0][1] * c[2] - M[0][3] * c[0]) * idet;\n\tT[2][2] = ( M[3][0] * s[4] - M[3][1] * s[2] + M[3][3] * s[0]) * idet;\n\tT[2][3] = (-M[2][0] * s[4] + M[2][1] * s[2] - M[2][3] * s[0]) * idet;\n\n\tT[3][0] = (-M[1][0] * c[3] + M[1][1] * c[1] - M[1][2] * c[0]) * idet;\n\tT[3][1] = ( M[0][0] * c[3] - M[0][1] * c[1] + M[0][2] * c[0]) * idet;\n\tT[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet;\n\tT[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet;\n}\nstatic inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M)\n{\n\tmat4x4_dup(R, M);\n\tfloat s = 1.;\n\tvec3 h;\n\n\tvec3_norm(R[2], R[2]);\n\t\n\ts = vec3_mul_inner(R[1], R[2]);\n\tvec3_scale(h, R[2], s);\n\tvec3_sub(R[1], R[1], h);\n\tvec3_norm(R[2], R[2]);\n\n\ts = vec3_mul_inner(R[1], R[2]);\n\tvec3_scale(h, R[2], s);\n\tvec3_sub(R[1], R[1], h);\n\tvec3_norm(R[1], R[1]);\n\n\ts = vec3_mul_inner(R[0], R[1]);\n\tvec3_scale(h, R[1], s);\n\tvec3_sub(R[0], R[0], h);\n\tvec3_norm(R[0], R[0]);\n}\n\nstatic inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f)\n{\n\tM[0][0] = 2.f*n/(r-l);\n\tM[0][1] = M[0][2] = M[0][3] = 0.f;\n\t\n\tM[1][1] = 2.f*n/(t-b);\n\tM[1][0] = M[1][2] = M[1][3] = 0.f;\n\n\tM[2][0] = (r+l)/(r-l);\n\tM[2][1] = (t+b)/(t-b);\n\tM[2][2] = -(f+n)/(f-n);\n\tM[2][3] = -1.f;\n\t\n\tM[3][2] = -2.f*(f*n)/(f-n);\n\tM[3][0] = M[3][1] = M[3][3] = 0.f;\n}\nstatic inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f)\n{\n\tM[0][0] = 2.f/(r-l);\n\tM[0][1] = M[0][2] = M[0][3] = 0.f;\n\n\tM[1][1] = 2.f/(t-b);\n\tM[1][0] = M[1][2] = M[1][3] = 0.f;\n\n\tM[2][2] = -2.f/(f-n);\n\tM[2][0] = M[2][1] = M[2][3] = 0.f;\n\t\n\tM[3][0] = -(r+l)/(r-l);\n\tM[3][1] = -(t+b)/(t-b);\n\tM[3][2] = -(f+n)/(f-n);\n\tM[3][3] = 1.f;\n}\nstatic inline void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f)\n{\n\t/* NOTE: Degrees are an unhandy unit to work with.\n\t * linmath.h uses radians for everything! */\n\tfloat const a = 1.f / (float) tan(y_fov / 2.f);\n\n\tm[0][0] = a / aspect;\n\tm[0][1] = 0.f;\n\tm[0][2] = 0.f;\n\tm[0][3] = 0.f;\n\n\tm[1][0] = 0.f;\n\tm[1][1] = a;\n\tm[1][2] = 0.f;\n\tm[1][3] = 0.f;\n\n\tm[2][0] = 0.f;\n\tm[2][1] = 0.f;\n\tm[2][2] = -((f + n) / (f - n));\n\tm[2][3] = -1.f;\n\n\tm[3][0] = 0.f;\n\tm[3][1] = 0.f;\n\tm[3][2] = -((2.f * f * n) / (f - n));\n\tm[3][3] = 0.f;\n}\nstatic inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up)\n{\n\t/* Adapted from Android's OpenGL Matrix.java.                        */\n\t/* See the OpenGL GLUT documentation for gluLookAt for a description */\n\t/* of the algorithm. We implement it in a straightforward way:       */\n\n\t/* TODO: The negation of of can be spared by swapping the order of\n\t *       operands in the following cross products in the right way. */\n\tvec3 f;\n\tvec3_sub(f, center, eye);\t\n\tvec3_norm(f, f);\t\n\t\n\tvec3 s;\n\tvec3_mul_cross(s, f, up);\n\tvec3_norm(s, s);\n\n\tvec3 t;\n\tvec3_mul_cross(t, s, f);\n\n\tm[0][0] =  s[0];\n\tm[0][1] =  t[0];\n\tm[0][2] = -f[0];\n\tm[0][3] =   0.f;\n\n\tm[1][0] =  s[1];\n\tm[1][1] =  t[1];\n\tm[1][2] = -f[1];\n\tm[1][3] =   0.f;\n\n\tm[2][0] =  s[2];\n\tm[2][1] =  t[2];\n\tm[2][2] = -f[2];\n\tm[2][3] =   0.f;\n\n\tm[3][0] =  0.f;\n\tm[3][1] =  0.f;\n\tm[3][2] =  0.f;\n\tm[3][3] =  1.f;\n\n\tmat4x4_translate_in_place(m, -eye[0], -eye[1], -eye[2]);\n}\n\ntypedef float quat[4];\nstatic inline void quat_identity(quat q)\n{\n\tq[0] = q[1] = q[2] = 0.f;\n\tq[3] = 1.f;\n}\nstatic inline void quat_add(quat r, quat a, quat b)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tr[i] = a[i] + b[i];\n}\nstatic inline void quat_sub(quat r, quat a, quat b)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tr[i] = a[i] - b[i];\n}\nstatic inline void quat_mul(quat r, quat p, quat q)\n{\n\tvec3 w;\n\tvec3_mul_cross(r, p, q);\n\tvec3_scale(w, p, q[3]);\n\tvec3_add(r, r, w);\n\tvec3_scale(w, q, p[3]);\n\tvec3_add(r, r, w);\n\tr[3] = p[3]*q[3] - vec3_mul_inner(p, q);\n}\nstatic inline void quat_scale(quat r, quat v, float s)\n{\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tr[i] = v[i] * s;\n}\nstatic inline float quat_inner_product(quat a, quat b)\n{\n\tfloat p = 0.f;\n\tint i;\n\tfor(i=0; i<4; ++i)\n\t\tp += b[i]*a[i];\n\treturn p;\n}\nstatic inline void quat_conj(quat r, quat q)\n{\n\tint i;\n\tfor(i=0; i<3; ++i)\n\t\tr[i] = -q[i];\n\tr[3] = q[3];\n}\nstatic inline void quat_rotate(quat r, float angle, vec3 axis) {\n\tvec3 v;\n\tvec3_scale(v, axis, sinf(angle / 2));\n\tint i;\n\tfor(i=0; i<3; ++i)\n\t\tr[i] = v[i];\n\tr[3] = cosf(angle / 2);\n}\n#define quat_norm vec4_norm\nstatic inline void quat_mul_vec3(vec3 r, quat q, vec3 v)\n{\n/*\n * Method by Fabian 'ryg' Giessen (of Farbrausch)\nt = 2 * cross(q.xyz, v)\nv' = v + q.w * t + cross(q.xyz, t)\n */\n\tvec3 t = {q[0], q[1], q[2]};\n\tvec3 u = {q[0], q[1], q[2]};\n\n\tvec3_mul_cross(t, t, v);\n\tvec3_scale(t, t, 2);\n\n\tvec3_mul_cross(u, u, t);\n\tvec3_scale(t, t, q[3]);\n\n\tvec3_add(r, v, t);\n\tvec3_add(r, r, u);\n}\nstatic inline void mat4x4_from_quat(mat4x4 M, quat q)\n{\n\tfloat a = q[3];\n\tfloat b = q[0];\n\tfloat c = q[1];\n\tfloat d = q[2];\n\tfloat a2 = a*a;\n\tfloat b2 = b*b;\n\tfloat c2 = c*c;\n\tfloat d2 = d*d;\n\t\n\tM[0][0] = a2 + b2 - c2 - d2;\n\tM[0][1] = 2.f*(b*c + a*d);\n\tM[0][2] = 2.f*(b*d - a*c);\n\tM[0][3] = 0.f;\n\n\tM[1][0] = 2*(b*c - a*d);\n\tM[1][1] = a2 - b2 + c2 - d2;\n\tM[1][2] = 2.f*(c*d + a*b);\n\tM[1][3] = 0.f;\n\n\tM[2][0] = 2.f*(b*d + a*c);\n\tM[2][1] = 2.f*(c*d - a*b);\n\tM[2][2] = a2 - b2 - c2 + d2;\n\tM[2][3] = 0.f;\n\n\tM[3][0] = M[3][1] = M[3][2] = 0.f;\n\tM[3][3] = 1.f;\n}\n\nstatic inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q)\n{\n/*  XXX: The way this is written only works for othogonal matrices. */\n/* TODO: Take care of non-orthogonal case. */\n\tquat_mul_vec3(R[0], q, M[0]);\n\tquat_mul_vec3(R[1], q, M[1]);\n\tquat_mul_vec3(R[2], q, M[2]);\n\n\tR[3][0] = R[3][1] = R[3][2] = 0.f;\n\tR[3][3] = 1.f;\n}\nstatic inline void quat_from_mat4x4(quat q, mat4x4 M)\n{\n\tfloat r=0.f;\n\tint i;\n\n\tint perm[] = { 0, 1, 2, 0, 1 };\n\tint *p = perm;\n\n\tfor(i = 0; i<3; i++) {\n\t\tfloat m = M[i][i];\n\t\tif( m < r )\n\t\t\tcontinue;\n\t\tm = r;\n\t\tp = &perm[i];\n\t}\n\n\tr = sqrtf(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]] );\n\n\tif(r < 1e-6) {\n\t\tq[0] = 1.f;\n\t\tq[1] = q[2] = q[3] = 0.f;\n\t\treturn;\n\t}\n\n\tq[0] = r/2.f;\n\tq[1] = (M[p[0]][p[1]] - M[p[1]][p[0]])/(2.f*r);\n\tq[2] = (M[p[2]][p[0]] - M[p[0]][p[2]])/(2.f*r);\n\tq[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);\n}\n\n#endif\n"
  },
  {
    "path": "deps/glfw/deps/tinycthread.c",
    "content": "/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; -*-\nCopyright (c) 2012 Marcus Geelnard\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n/* 2013-01-06 Camilla Berglund <elmindreda@elmindreda.org>\n *\n * Added casts from time_t to DWORD to avoid warnings on VC++.\n * Fixed time retrieval on POSIX systems.\n */\n\n#include \"tinycthread.h\"\n#include <stdlib.h>\n\n/* Platform specific includes */\n#if defined(_TTHREAD_POSIX_)\n  #include <signal.h>\n  #include <sched.h>\n  #include <unistd.h>\n  #include <sys/time.h>\n  #include <errno.h>\n#elif defined(_TTHREAD_WIN32_)\n  #include <process.h>\n  #include <sys/timeb.h>\n#endif\n\n/* Standard, good-to-have defines */\n#ifndef NULL\n  #define NULL (void*)0\n#endif\n#ifndef TRUE\n  #define TRUE 1\n#endif\n#ifndef FALSE\n  #define FALSE 0\n#endif\n\nint mtx_init(mtx_t *mtx, int type)\n{\n#if defined(_TTHREAD_WIN32_)\n  mtx->mAlreadyLocked = FALSE;\n  mtx->mRecursive = type & mtx_recursive;\n  InitializeCriticalSection(&mtx->mHandle);\n  return thrd_success;\n#else\n  int ret;\n  pthread_mutexattr_t attr;\n  pthread_mutexattr_init(&attr);\n  if (type & mtx_recursive)\n  {\n    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n  }\n  ret = pthread_mutex_init(mtx, &attr);\n  pthread_mutexattr_destroy(&attr);\n  return ret == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nvoid mtx_destroy(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  DeleteCriticalSection(&mtx->mHandle);\n#else\n  pthread_mutex_destroy(mtx);\n#endif\n}\n\nint mtx_lock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  EnterCriticalSection(&mtx->mHandle);\n  if (!mtx->mRecursive)\n  {\n    while(mtx->mAlreadyLocked) Sleep(1000); /* Simulate deadlock... */\n    mtx->mAlreadyLocked = TRUE;\n  }\n  return thrd_success;\n#else\n  return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint mtx_timedlock(mtx_t *mtx, const struct timespec *ts)\n{\n  /* FIXME! */\n  (void)mtx;\n  (void)ts;\n  return thrd_error;\n}\n\nint mtx_trylock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  int ret = TryEnterCriticalSection(&mtx->mHandle) ? thrd_success : thrd_busy;\n  if ((!mtx->mRecursive) && (ret == thrd_success) && mtx->mAlreadyLocked)\n  {\n    LeaveCriticalSection(&mtx->mHandle);\n    ret = thrd_busy;\n  }\n  return ret;\n#else\n  return (pthread_mutex_trylock(mtx) == 0) ? thrd_success : thrd_busy;\n#endif\n}\n\nint mtx_unlock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  mtx->mAlreadyLocked = FALSE;\n  LeaveCriticalSection(&mtx->mHandle);\n  return thrd_success;\n#else\n  return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error;;\n#endif\n}\n\n#if defined(_TTHREAD_WIN32_)\n#define _CONDITION_EVENT_ONE 0\n#define _CONDITION_EVENT_ALL 1\n#endif\n\nint cnd_init(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  cond->mWaitersCount = 0;\n\n  /* Init critical section */\n  InitializeCriticalSection(&cond->mWaitersCountLock);\n\n  /* Init events */\n  cond->mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL);\n  if (cond->mEvents[_CONDITION_EVENT_ONE] == NULL)\n  {\n    cond->mEvents[_CONDITION_EVENT_ALL] = NULL;\n    return thrd_error;\n  }\n  cond->mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL);\n  if (cond->mEvents[_CONDITION_EVENT_ALL] == NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]);\n    cond->mEvents[_CONDITION_EVENT_ONE] = NULL;\n    return thrd_error;\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_init(cond, NULL) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nvoid cnd_destroy(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (cond->mEvents[_CONDITION_EVENT_ONE] != NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]);\n  }\n  if (cond->mEvents[_CONDITION_EVENT_ALL] != NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ALL]);\n  }\n  DeleteCriticalSection(&cond->mWaitersCountLock);\n#else\n  pthread_cond_destroy(cond);\n#endif\n}\n\nint cnd_signal(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  int haveWaiters;\n\n  /* Are there any waiters? */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  haveWaiters = (cond->mWaitersCount > 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we have any waiting threads, send them a signal */\n  if(haveWaiters)\n  {\n    if (SetEvent(cond->mEvents[_CONDITION_EVENT_ONE]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint cnd_broadcast(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  int haveWaiters;\n\n  /* Are there any waiters? */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  haveWaiters = (cond->mWaitersCount > 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we have any waiting threads, send them a signal */\n  if(haveWaiters)\n  {\n    if (SetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\n#if defined(_TTHREAD_WIN32_)\nstatic int _cnd_timedwait_win32(cnd_t *cond, mtx_t *mtx, DWORD timeout)\n{\n  int result, lastWaiter;\n\n  /* Increment number of waiters */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  ++ cond->mWaitersCount;\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* Release the mutex while waiting for the condition (will decrease\n     the number of waiters when done)... */\n  mtx_unlock(mtx);\n\n  /* Wait for either event to become signaled due to cnd_signal() or\n     cnd_broadcast() being called */\n  result = WaitForMultipleObjects(2, cond->mEvents, FALSE, timeout);\n  if (result == WAIT_TIMEOUT)\n  {\n    return thrd_timeout;\n  }\n  else if (result == (int)WAIT_FAILED)\n  {\n    return thrd_error;\n  }\n\n  /* Check if we are the last waiter */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  -- cond->mWaitersCount;\n  lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) &&\n               (cond->mWaitersCount == 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we are the last waiter to be notified to stop waiting, reset the event */\n  if (lastWaiter)\n  {\n    if (ResetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  /* Re-acquire the mutex */\n  mtx_lock(mtx);\n\n  return thrd_success;\n}\n#endif\n\nint cnd_wait(cnd_t *cond, mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  return _cnd_timedwait_win32(cond, mtx, INFINITE);\n#else\n  return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts)\n{\n#if defined(_TTHREAD_WIN32_)\n  struct timespec now;\n  if (clock_gettime(CLOCK_REALTIME, &now) == 0)\n  {\n    DWORD delta = (DWORD) ((ts->tv_sec - now.tv_sec) * 1000 +\n                           (ts->tv_nsec - now.tv_nsec + 500000) / 1000000);\n    return _cnd_timedwait_win32(cond, mtx, delta);\n  }\n  else\n    return thrd_error;\n#else\n  int ret;\n  ret = pthread_cond_timedwait(cond, mtx, ts);\n  if (ret == ETIMEDOUT)\n  {\n    return thrd_timeout;\n  }\n  return ret == 0 ? thrd_success : thrd_error;\n#endif\n}\n\n\n/** Information to pass to the new thread (what to run). */\ntypedef struct {\n  thrd_start_t mFunction; /**< Pointer to the function to be executed. */\n  void * mArg;            /**< Function argument for the thread function. */\n} _thread_start_info;\n\n/* Thread wrapper function. */\n#if defined(_TTHREAD_WIN32_)\nstatic unsigned WINAPI _thrd_wrapper_function(void * aArg)\n#elif defined(_TTHREAD_POSIX_)\nstatic void * _thrd_wrapper_function(void * aArg)\n#endif\n{\n  thrd_start_t fun;\n  void *arg;\n  int  res;\n#if defined(_TTHREAD_POSIX_)\n  void *pres;\n#endif\n\n  /* Get thread startup information */\n  _thread_start_info *ti = (_thread_start_info *) aArg;\n  fun = ti->mFunction;\n  arg = ti->mArg;\n\n  /* The thread is responsible for freeing the startup information */\n  free((void *)ti);\n\n  /* Call the actual client thread function */\n  res = fun(arg);\n\n#if defined(_TTHREAD_WIN32_)\n  return res;\n#else\n  pres = malloc(sizeof(int));\n  if (pres != NULL)\n  {\n    *(int*)pres = res;\n  }\n  return pres;\n#endif\n}\n\nint thrd_create(thrd_t *thr, thrd_start_t func, void *arg)\n{\n  /* Fill out the thread startup information (passed to the thread wrapper,\n     which will eventually free it) */\n  _thread_start_info* ti = (_thread_start_info*)malloc(sizeof(_thread_start_info));\n  if (ti == NULL)\n  {\n    return thrd_nomem;\n  }\n  ti->mFunction = func;\n  ti->mArg = arg;\n\n  /* Create the thread */\n#if defined(_TTHREAD_WIN32_)\n  *thr = (HANDLE)_beginthreadex(NULL, 0, _thrd_wrapper_function, (void *)ti, 0, NULL);\n#elif defined(_TTHREAD_POSIX_)\n  if(pthread_create(thr, NULL, _thrd_wrapper_function, (void *)ti) != 0)\n  {\n    *thr = 0;\n  }\n#endif\n\n  /* Did we fail to create the thread? */\n  if(!*thr)\n  {\n    free(ti);\n    return thrd_error;\n  }\n\n  return thrd_success;\n}\n\nthrd_t thrd_current(void)\n{\n#if defined(_TTHREAD_WIN32_)\n  return GetCurrentThread();\n#else\n  return pthread_self();\n#endif\n}\n\nint thrd_detach(thrd_t thr)\n{\n  /* FIXME! */\n  (void)thr;\n  return thrd_error;\n}\n\nint thrd_equal(thrd_t thr0, thrd_t thr1)\n{\n#if defined(_TTHREAD_WIN32_)\n  return thr0 == thr1;\n#else\n  return pthread_equal(thr0, thr1);\n#endif\n}\n\nvoid thrd_exit(int res)\n{\n#if defined(_TTHREAD_WIN32_)\n  ExitThread(res);\n#else\n  void *pres = malloc(sizeof(int));\n  if (pres != NULL)\n  {\n    *(int*)pres = res;\n  }\n  pthread_exit(pres);\n#endif\n}\n\nint thrd_join(thrd_t thr, int *res)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED)\n  {\n    return thrd_error;\n  }\n  if (res != NULL)\n  {\n    DWORD dwRes;\n    GetExitCodeThread(thr, &dwRes);\n    *res = dwRes;\n  }\n#elif defined(_TTHREAD_POSIX_)\n  void *pres;\n  int ires = 0;\n  if (pthread_join(thr, &pres) != 0)\n  {\n    return thrd_error;\n  }\n  if (pres != NULL)\n  {\n    ires = *(int*)pres;\n    free(pres);\n  }\n  if (res != NULL)\n  {\n    *res = ires;\n  }\n#endif\n  return thrd_success;\n}\n\nint thrd_sleep(const struct timespec *time_point, struct timespec *remaining)\n{\n  struct timespec now;\n#if defined(_TTHREAD_WIN32_)\n  DWORD delta;\n#else\n  long delta;\n#endif\n\n  /* Get the current time */\n  if (clock_gettime(CLOCK_REALTIME, &now) != 0)\n    return -2;  // FIXME: Some specific error code?\n\n#if defined(_TTHREAD_WIN32_)\n  /* Delta in milliseconds */\n  delta = (DWORD) ((time_point->tv_sec - now.tv_sec) * 1000 +\n                   (time_point->tv_nsec - now.tv_nsec + 500000) / 1000000);\n  if (delta > 0)\n  {\n    Sleep(delta);\n  }\n#else\n  /* Delta in microseconds */\n  delta = (time_point->tv_sec - now.tv_sec) * 1000000L +\n          (time_point->tv_nsec - now.tv_nsec + 500L) / 1000L;\n\n  /* On some systems, the usleep argument must be < 1000000 */\n  while (delta > 999999L)\n  {\n    usleep(999999);\n    delta -= 999999L;\n  }\n  if (delta > 0L)\n  {\n    usleep((useconds_t)delta);\n  }\n#endif\n\n  /* We don't support waking up prematurely (yet) */\n  if (remaining)\n  {\n    remaining->tv_sec = 0;\n    remaining->tv_nsec = 0;\n  }\n  return 0;\n}\n\nvoid thrd_yield(void)\n{\n#if defined(_TTHREAD_WIN32_)\n  Sleep(0);\n#else\n  sched_yield();\n#endif\n}\n\nint tss_create(tss_t *key, tss_dtor_t dtor)\n{\n#if defined(_TTHREAD_WIN32_)\n  /* FIXME: The destructor function is not supported yet... */\n  if (dtor != NULL)\n  {\n    return thrd_error;\n  }\n  *key = TlsAlloc();\n  if (*key == TLS_OUT_OF_INDEXES)\n  {\n    return thrd_error;\n  }\n#else\n  if (pthread_key_create(key, dtor) != 0)\n  {\n    return thrd_error;\n  }\n#endif\n  return thrd_success;\n}\n\nvoid tss_delete(tss_t key)\n{\n#if defined(_TTHREAD_WIN32_)\n  TlsFree(key);\n#else\n  pthread_key_delete(key);\n#endif\n}\n\nvoid *tss_get(tss_t key)\n{\n#if defined(_TTHREAD_WIN32_)\n  return TlsGetValue(key);\n#else\n  return pthread_getspecific(key);\n#endif\n}\n\nint tss_set(tss_t key, void *val)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (TlsSetValue(key, val) == 0)\n  {\n    return thrd_error;\n  }\n#else\n  if (pthread_setspecific(key, val) != 0)\n  {\n    return thrd_error;\n  }\n#endif\n  return thrd_success;\n}\n\n#if defined(_TTHREAD_EMULATE_CLOCK_GETTIME_)\nint _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts)\n{\n#if defined(_TTHREAD_WIN32_)\n  struct _timeb tb;\n  _ftime(&tb);\n  ts->tv_sec = (time_t)tb.time;\n  ts->tv_nsec = 1000000L * (long)tb.millitm;\n#else\n  struct timeval tv;\n  gettimeofday(&tv, NULL);\n  ts->tv_sec = (time_t)tv.tv_sec;\n  ts->tv_nsec = 1000L * (long)tv.tv_usec;\n#endif\n  return 0;\n}\n#endif // _TTHREAD_EMULATE_CLOCK_GETTIME_\n\n"
  },
  {
    "path": "deps/glfw/deps/tinycthread.h",
    "content": "/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; -*-\nCopyright (c) 2012 Marcus Geelnard\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n#ifndef _TINYCTHREAD_H_\n#define _TINYCTHREAD_H_\n\n/**\n* @file\n* @mainpage TinyCThread API Reference\n*\n* @section intro_sec Introduction\n* TinyCThread is a minimal, portable implementation of basic threading\n* classes for C.\n*\n* They closely mimic the functionality and naming of the C11 standard, and\n* should be easily replaceable with the corresponding standard variants.\n*\n* @section port_sec Portability\n* The Win32 variant uses the native Win32 API for implementing the thread\n* classes, while for other systems, the POSIX threads API (pthread) is used.\n*\n* @section misc_sec Miscellaneous\n* The following special keywords are available: #_Thread_local.\n*\n* For more detailed information, browse the different sections of this\n* documentation. A good place to start is:\n* tinycthread.h.\n*/\n\n/* Which platform are we on? */\n#if !defined(_TTHREAD_PLATFORM_DEFINED_)\n  #if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)\n    #define _TTHREAD_WIN32_\n  #else\n    #define _TTHREAD_POSIX_\n  #endif\n  #define _TTHREAD_PLATFORM_DEFINED_\n#endif\n\n/* Activate some POSIX functionality (e.g. clock_gettime and recursive mutexes) */\n#if defined(_TTHREAD_POSIX_)\n  #undef _FEATURES_H\n  #if !defined(_GNU_SOURCE)\n    #define _GNU_SOURCE\n  #endif\n  #if !defined(_POSIX_C_SOURCE) || ((_POSIX_C_SOURCE - 0) < 199309L)\n    #undef _POSIX_C_SOURCE\n    #define _POSIX_C_SOURCE 199309L\n  #endif\n  #if !defined(_XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 500)\n    #undef _XOPEN_SOURCE\n    #define _XOPEN_SOURCE 500\n  #endif\n#endif\n\n/* Generic includes */\n#include <time.h>\n\n/* Platform specific includes */\n#if defined(_TTHREAD_POSIX_)\n  #include <pthread.h>\n#elif defined(_TTHREAD_WIN32_)\n  #ifndef WIN32_LEAN_AND_MEAN\n    #define WIN32_LEAN_AND_MEAN\n    #define __UNDEF_LEAN_AND_MEAN\n  #endif\n  #include <windows.h>\n  #ifdef __UNDEF_LEAN_AND_MEAN\n    #undef WIN32_LEAN_AND_MEAN\n    #undef __UNDEF_LEAN_AND_MEAN\n  #endif\n#endif\n\n/* Workaround for missing TIME_UTC: If time.h doesn't provide TIME_UTC,\n   it's quite likely that libc does not support it either. Hence, fall back to\n   the only other supported time specifier: CLOCK_REALTIME (and if that fails,\n   we're probably emulating clock_gettime anyway, so anything goes). */\n#ifndef TIME_UTC\n  #ifdef CLOCK_REALTIME\n    #define TIME_UTC CLOCK_REALTIME\n  #else\n    #define TIME_UTC 0\n  #endif\n#endif\n\n/* Workaround for missing clock_gettime (most Windows compilers, afaik) */\n#if defined(_TTHREAD_WIN32_) || defined(__APPLE_CC__)\n#define _TTHREAD_EMULATE_CLOCK_GETTIME_\n/* Emulate struct timespec */\n#if defined(_TTHREAD_WIN32_)\nstruct _ttherad_timespec {\n  time_t tv_sec;\n  long   tv_nsec;\n};\n#define timespec _ttherad_timespec\n#endif\n\n/* Emulate clockid_t */\ntypedef int _tthread_clockid_t;\n#define clockid_t _tthread_clockid_t\n\n/* Emulate clock_gettime */\nint _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts);\n#define clock_gettime _tthread_clock_gettime\n#define CLOCK_REALTIME 0\n#endif\n\n\n/** TinyCThread version (major number). */\n#define TINYCTHREAD_VERSION_MAJOR 1\n/** TinyCThread version (minor number). */\n#define TINYCTHREAD_VERSION_MINOR 1\n/** TinyCThread version (full version). */\n#define TINYCTHREAD_VERSION (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR)\n\n/**\n* @def _Thread_local\n* Thread local storage keyword.\n* A variable that is declared with the @c _Thread_local keyword makes the\n* value of the variable local to each thread (known as thread-local storage,\n* or TLS). Example usage:\n* @code\n* // This variable is local to each thread.\n* _Thread_local int variable;\n* @endcode\n* @note The @c _Thread_local keyword is a macro that maps to the corresponding\n* compiler directive (e.g. @c __declspec(thread)).\n* @note This directive is currently not supported on Mac OS X (it will give\n* a compiler error), since compile-time TLS is not supported in the Mac OS X\n* executable format. Also, some older versions of MinGW (before GCC 4.x) do\n* not support this directive.\n* @hideinitializer\n*/\n\n/* FIXME: Check for a PROPER value of __STDC_VERSION__ to know if we have C11 */\n#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) && !defined(_Thread_local)\n #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)\n  #define _Thread_local __thread\n #else\n  #define _Thread_local __declspec(thread)\n #endif\n#endif\n\n/* Macros */\n#define TSS_DTOR_ITERATIONS 0\n\n/* Function return values */\n#define thrd_error    0 /**< The requested operation failed */\n#define thrd_success  1 /**< The requested operation succeeded */\n#define thrd_timeout  2 /**< The time specified in the call was reached without acquiring the requested resource */\n#define thrd_busy     3 /**< The requested operation failed because a tesource requested by a test and return function is already in use */\n#define thrd_nomem    4 /**< The requested operation failed because it was unable to allocate memory */\n\n/* Mutex types */\n#define mtx_plain     1\n#define mtx_timed     2\n#define mtx_try       4\n#define mtx_recursive 8\n\n/* Mutex */\n#if defined(_TTHREAD_WIN32_)\ntypedef struct {\n  CRITICAL_SECTION mHandle;   /* Critical section handle */\n  int mAlreadyLocked;         /* TRUE if the mutex is already locked */\n  int mRecursive;             /* TRUE if the mutex is recursive */\n} mtx_t;\n#else\ntypedef pthread_mutex_t mtx_t;\n#endif\n\n/** Create a mutex object.\n* @param mtx A mutex object.\n* @param type Bit-mask that must have one of the following six values:\n*   @li @c mtx_plain for a simple non-recursive mutex\n*   @li @c mtx_timed for a non-recursive mutex that supports timeout\n*   @li @c mtx_try for a non-recursive mutex that supports test and return\n*   @li @c mtx_plain | @c mtx_recursive (same as @c mtx_plain, but recursive)\n*   @li @c mtx_timed | @c mtx_recursive (same as @c mtx_timed, but recursive)\n*   @li @c mtx_try | @c mtx_recursive (same as @c mtx_try, but recursive)\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_init(mtx_t *mtx, int type);\n\n/** Release any resources used by the given mutex.\n* @param mtx A mutex object.\n*/\nvoid mtx_destroy(mtx_t *mtx);\n\n/** Lock the given mutex.\n* Blocks until the given mutex can be locked. If the mutex is non-recursive, and\n* the calling thread already has a lock on the mutex, this call will block\n* forever.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_lock(mtx_t *mtx);\n\n/** NOT YET IMPLEMENTED.\n*/\nint mtx_timedlock(mtx_t *mtx, const struct timespec *ts);\n\n/** Try to lock the given mutex.\n* The specified mutex shall support either test and return or timeout. If the\n* mutex is already locked, the function returns without blocking.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_busy if the resource\n* requested is already in use, or @ref thrd_error if the request could not be\n* honored.\n*/\nint mtx_trylock(mtx_t *mtx);\n\n/** Unlock the given mutex.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_unlock(mtx_t *mtx);\n\n/* Condition variable */\n#if defined(_TTHREAD_WIN32_)\ntypedef struct {\n  HANDLE mEvents[2];                  /* Signal and broadcast event HANDLEs. */\n  unsigned int mWaitersCount;         /* Count of the number of waiters. */\n  CRITICAL_SECTION mWaitersCountLock; /* Serialize access to mWaitersCount. */\n} cnd_t;\n#else\ntypedef pthread_cond_t cnd_t;\n#endif\n\n/** Create a condition variable object.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_init(cnd_t *cond);\n\n/** Release any resources used by the given condition variable.\n* @param cond A condition variable object.\n*/\nvoid cnd_destroy(cnd_t *cond);\n\n/** Signal a condition variable.\n* Unblocks one of the threads that are blocked on the given condition variable\n* at the time of the call. If no threads are blocked on the condition variable\n* at the time of the call, the function does nothing and return success.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_signal(cnd_t *cond);\n\n/** Broadcast a condition variable.\n* Unblocks all of the threads that are blocked on the given condition variable\n* at the time of the call. If no threads are blocked on the condition variable\n* at the time of the call, the function does nothing and return success.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_broadcast(cnd_t *cond);\n\n/** Wait for a condition variable to become signaled.\n* The function atomically unlocks the given mutex and endeavors to block until\n* the given condition variable is signaled by a call to cnd_signal or to\n* cnd_broadcast. When the calling thread becomes unblocked it locks the mutex\n* before it returns.\n* @param cond A condition variable object.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_wait(cnd_t *cond, mtx_t *mtx);\n\n/** Wait for a condition variable to become signaled.\n* The function atomically unlocks the given mutex and endeavors to block until\n* the given condition variable is signaled by a call to cnd_signal or to\n* cnd_broadcast, or until after the specified time. When the calling thread\n* becomes unblocked it locks the mutex before it returns.\n* @param cond A condition variable object.\n* @param mtx A mutex object.\n* @param xt A point in time at which the request will time out (absolute time).\n* @return @ref thrd_success upon success, or @ref thrd_timeout if the time\n* specified in the call was reached without acquiring the requested resource, or\n* @ref thrd_error if the request could not be honored.\n*/\nint cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts);\n\n/* Thread */\n#if defined(_TTHREAD_WIN32_)\ntypedef HANDLE thrd_t;\n#else\ntypedef pthread_t thrd_t;\n#endif\n\n/** Thread start function.\n* Any thread that is started with the @ref thrd_create() function must be\n* started through a function of this type.\n* @param arg The thread argument (the @c arg argument of the corresponding\n*        @ref thrd_create() call).\n* @return The thread return value, which can be obtained by another thread\n* by using the @ref thrd_join() function.\n*/\ntypedef int (*thrd_start_t)(void *arg);\n\n/** Create a new thread.\n* @param thr Identifier of the newly created thread.\n* @param func A function pointer to the function that will be executed in\n*        the new thread.\n* @param arg An argument to the thread function.\n* @return @ref thrd_success on success, or @ref thrd_nomem if no memory could\n* be allocated for the thread requested, or @ref thrd_error if the request\n* could not be honored.\n* @note A thread’s identifier may be reused for a different thread once the\n* original thread has exited and either been detached or joined to another\n* thread.\n*/\nint thrd_create(thrd_t *thr, thrd_start_t func, void *arg);\n\n/** Identify the calling thread.\n* @return The identifier of the calling thread.\n*/\nthrd_t thrd_current(void);\n\n/** NOT YET IMPLEMENTED.\n*/\nint thrd_detach(thrd_t thr);\n\n/** Compare two thread identifiers.\n* The function determines if two thread identifiers refer to the same thread.\n* @return Zero if the two thread identifiers refer to different threads.\n* Otherwise a nonzero value is returned.\n*/\nint thrd_equal(thrd_t thr0, thrd_t thr1);\n\n/** Terminate execution of the calling thread.\n* @param res Result code of the calling thread.\n*/\nvoid thrd_exit(int res);\n\n/** Wait for a thread to terminate.\n* The function joins the given thread with the current thread by blocking\n* until the other thread has terminated.\n* @param thr The thread to join with.\n* @param res If this pointer is not NULL, the function will store the result\n*        code of the given thread in the integer pointed to by @c res.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint thrd_join(thrd_t thr, int *res);\n\n/** Put the calling thread to sleep.\n* Suspend execution of the calling thread.\n* @param time_point A point in time at which the thread will resume (absolute time).\n* @param remaining If non-NULL, this parameter will hold the remaining time until\n*                  time_point upon return. This will typically be zero, but if\n*                  the thread was woken up by a signal that is not ignored before\n*                  time_point was reached @c remaining will hold a positive\n*                  time.\n* @return 0 (zero) on successful sleep, or -1 if an interrupt occurred.\n*/\nint thrd_sleep(const struct timespec *time_point, struct timespec *remaining);\n\n/** Yield execution to another thread.\n* Permit other threads to run, even if the current thread would ordinarily\n* continue to run.\n*/\nvoid thrd_yield(void);\n\n/* Thread local storage */\n#if defined(_TTHREAD_WIN32_)\ntypedef DWORD tss_t;\n#else\ntypedef pthread_key_t tss_t;\n#endif\n\n/** Destructor function for a thread-specific storage.\n* @param val The value of the destructed thread-specific storage.\n*/\ntypedef void (*tss_dtor_t)(void *val);\n\n/** Create a thread-specific storage.\n* @param key The unique key identifier that will be set if the function is\n*        successful.\n* @param dtor Destructor function. This can be NULL.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n* @note The destructor function is not supported under Windows. If @c dtor is\n* not NULL when calling this function under Windows, the function will fail\n* and return @ref thrd_error.\n*/\nint tss_create(tss_t *key, tss_dtor_t dtor);\n\n/** Delete a thread-specific storage.\n* The function releases any resources used by the given thread-specific\n* storage.\n* @param key The key that shall be deleted.\n*/\nvoid tss_delete(tss_t key);\n\n/** Get the value for a thread-specific storage.\n* @param key The thread-specific storage identifier.\n* @return The value for the current thread held in the given thread-specific\n* storage.\n*/\nvoid *tss_get(tss_t key);\n\n/** Set the value for a thread-specific storage.\n* @param key The thread-specific storage identifier.\n* @param val The value of the thread-specific storage to set for the current\n*        thread.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint tss_set(tss_t key, void *val);\n\n\n#endif /* _TINYTHREAD_H_ */\n\n"
  },
  {
    "path": "deps/glfw/docs/CMakeLists.txt",
    "content": "\nadd_custom_target(docs ALL ${DOXYGEN_EXECUTABLE}\n                  WORKING_DIRECTORY ${GLFW_BINARY_DIR}/docs\n                  COMMENT \"Generating HTML documentation\" VERBATIM)\n\n"
  },
  {
    "path": "deps/glfw/docs/Doxyfile.in",
    "content": "# Doxyfile 1.8.3.1\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a hash (#) is considered a comment and will be ignored.\n# The format is:\n#       TAG = value [value, ...]\n# For lists items can also be appended using:\n#       TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\" \").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all\n# text before the first occurrence of this tag. Doxygen uses libiconv (or the\n# iconv built into libc) for the transcoding. See\n# http://www.gnu.org/software/libiconv for the list of possible encodings.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or sequence of words) that should\n# identify the project. Note that if you do not use Doxywizard you need\n# to put quotes around the project name if it contains spaces.\n\nPROJECT_NAME           = \"GLFW\"\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number.\n# This could be handy for archiving the generated documentation or\n# if some version control system is used.\n\nPROJECT_NUMBER         = @GLFW_VERSION_FULL@\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer\n# a quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"A multi-platform library for OpenGL, window and input\"\n\n# With the PROJECT_LOGO tag one can specify an logo or icon that is\n# included in the documentation. The maximum height of the logo should not\n# exceed 55 pixels and the maximum width should not exceed 200 pixels.\n# Doxygen will copy the logo to the output directory.\n\nPROJECT_LOGO           =\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)\n# base path where the generated documentation will be put.\n# If a relative path is entered, it will be relative to the location\n# where doxygen was started. If left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = @GLFW_BINARY_DIR@/docs\n\n# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create\n# 4096 sub-directories (in 2 levels) under the output directory of each output\n# format and will distribute the generated files over these directories.\n# Enabling this option can be useful when feeding doxygen a huge amount of\n# source files, where putting all generated files in the same directory would\n# otherwise cause performance problems for the file system.\n\nCREATE_SUBDIRS         = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# The default language is English, other supported languages are:\n# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,\n# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,\n# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English\n# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,\n# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,\n# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will\n# include brief member descriptions after the members that are listed in\n# the file and class documentation (similar to JavaDoc).\n# Set to NO to disable this.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend\n# the brief description of a member or function before the detailed description.\n# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n\nREPEAT_BRIEF           = NO\n\n# This tag implements a quasi-intelligent brief description abbreviator\n# that is used to form the text in various listings. Each string\n# in this list, if found as the leading text of the brief description, will be\n# stripped from the text and the result after processing the whole list, is\n# used as the annotated text. Otherwise, the brief description is used as-is.\n# If left blank, the following values are used (\"$name\" is automatically\n# replaced with the name of the entity): \"The $name class\" \"The $name widget\"\n# \"The $name file\" \"is\" \"provides\" \"specifies\" \"contains\"\n# \"represents\" \"a\" \"an\" \"the\"\n\nABBREVIATE_BRIEF       =\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# Doxygen will generate a detailed section even if there is only a brief\n# description.\n\nALWAYS_DETAILED_SEC    = YES\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full\n# path before files name in the file list and in the header files. If set\n# to NO the shortest path that makes the file name unique will be used.\n\nFULL_PATH_NAMES        = NO\n\n# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag\n# can be used to strip a user-defined part of the path. Stripping is\n# only done if one of the specified strings matches the left-hand part of\n# the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the\n# path to strip. Note that you specify absolute paths here, but also\n# relative paths, which will be relative from the directory where doxygen is\n# started.\n\nSTRIP_FROM_PATH        =\n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of\n# the path mentioned in the documentation of a class, which tells\n# the reader which header file to include in order to use a class.\n# If left blank only the name of the header file containing the class\n# definition is used. Otherwise one should specify the include paths that\n# are normally passed to the compiler using the -I flag.\n\nSTRIP_FROM_INC_PATH    =\n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter\n# (but less readable) file names. This can be useful if your file system\n# doesn't support long names like on DOS, Mac, or CD-ROM.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen\n# will interpret the first line (until the first dot) of a JavaDoc-style\n# comment as the brief description. If set to NO, the JavaDoc\n# comments will behave just like regular Qt-style comments\n# (thus requiring an explicit @brief command for a brief description.)\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then Doxygen will\n# interpret the first line (until the first dot) of a Qt-style\n# comment as the brief description. If set to NO, the comments\n# will behave just like regular Qt-style comments (thus requiring\n# an explicit \\brief command for a brief description.)\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen\n# treat a multi-line C++ special comment block (i.e. a block of //! or ///\n# comments) as a brief description. This used to be the default behaviour.\n# The new default is to treat a multi-line C++ comment block as a detailed\n# description. Set this tag to YES if you prefer the old behaviour instead.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented\n# member inherits the documentation from any documented member that it\n# re-implements.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce\n# a new page for each member. If set to NO, the documentation of a member will\n# be part of the file/class/namespace that contains it.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab.\n# Doxygen uses this value to replace tabs by spaces in code fragments.\n\nTAB_SIZE               = 8\n\n# This tag can be used to specify a number of aliases that acts\n# as commands in the documentation. An alias has the form \"name=value\".\n# For example adding \"sideeffect=\\par Side Effects:\\n\" will allow you to\n# put the command \\sideeffect (or @sideeffect) in the documentation, which\n# will result in a user-defined paragraph with heading \"Side Effects:\".\n# You can put \\n's in the value part of an alias to insert newlines.\n\nALIASES                =\n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding\n# \"class=itcl::class\" will allow you to use the command class in the\n# itcl::class meaning.\n\nTCL_SUBST              =\n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C\n# sources only. Doxygen will then generate output that is more tailored for C.\n# For instance, some of the names that are used will be different. The list\n# of all members will be omitted, etc.\n\nOPTIMIZE_OUTPUT_FOR_C  = YES\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java\n# sources only. Doxygen will then generate output that is more tailored for\n# Java. For instance, namespaces will be presented as packages, qualified\n# scopes will look different, etc.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources only. Doxygen will then generate output that is more tailored for\n# Fortran.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for\n# VHDL.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension,\n# and language is one of the parsers supported by doxygen: IDL, Java,\n# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C,\n# C++. For instance to make doxygen treat .inc files as Fortran files (default\n# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note\n# that for custom extensions you also need to set FILE_PATTERNS otherwise the\n# files are not read by doxygen.\n\nEXTENSION_MAPPING      =\n\n# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all\n# comments according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you\n# can mix doxygen, HTML, and XML commands with Markdown formatting.\n# Disable only in case of backward compatibilities issues.\n\nMARKDOWN_SUPPORT       = YES\n\n# When enabled doxygen tries to link words that correspond to documented classes,\n# or namespaces to their corresponding documentation. Such a link can be\n# prevented in individual cases by by putting a % sign in front of the word or\n# globally by setting AUTOLINK_SUPPORT to NO.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should\n# set this tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.\n# func(std::string) {}). This also makes the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.\n# Doxygen will parse them like normal C++ but will assume all classes use public\n# instead of private inheritance when no explicit protection keyword is present.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES (the\n# default) will make doxygen replace the get and set methods by a property in\n# the documentation. This will only work if the methods are indeed getting or\n# setting a simple type. If this is not the case, or you want to show the\n# methods anyway, you should set this option to NO.\n\nIDL_PROPERTY_SUPPORT   = NO\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES, then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# Set the SUBGROUPING tag to YES (the default) to allow class member groups of\n# the same type (for instance a group of public functions) to be put as a\n# subgroup of that type (e.g. under the Public Functions section). Set it to\n# NO to prevent subgrouping. Alternatively, this can be done per class using\n# the \\nosubgrouping command.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and\n# unions are shown inside the group in which they are included (e.g. using\n# @ingroup) instead of on a separate page (for HTML and Man pages) or\n# section (for LaTeX and RTF).\n\nINLINE_GROUPED_CLASSES = NO\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and\n# unions with only public data fields will be shown inline in the documentation\n# of the scope in which they are defined (i.e. file, namespace, or group\n# documentation), provided this scope is documented. If set to NO (the default),\n# structs, classes, and unions are shown on a separate page (for HTML and Man\n# pages) or section (for LaTeX and RTF).\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum\n# is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically\n# be useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be\n# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given\n# their name and scope. Since this can be an expensive process and often the\n# same symbol appear multiple times in the code, doxygen keeps a cache of\n# pre-resolved symbols. If the cache is too small doxygen will become slower.\n# If the cache is too large, memory is wasted. The cache size is given by this\n# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,\n# corresponding to a cache size of 2^16 = 65536 symbols.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\n# documentation are documented, even if no documentation was available.\n# Private class members and static file members will be hidden unless\n# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES\n\nEXTRACT_ALL            = YES\n\n# If the EXTRACT_PRIVATE tag is set to YES all private members of a class\n# will be included in the documentation.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal\n# scope will be included in the documentation.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES all static members of a file\n# will be included in the documentation.\n\nEXTRACT_STATIC         = NO\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)\n# defined locally in source files will be included in the documentation.\n# If set to NO only classes defined in header files are included.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. When set to YES local\n# methods, which are defined in the implementation section but not in\n# the interface are included in the documentation.\n# If set to NO (the default) only methods in the interface are included.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base\n# name of the file that contains the anonymous namespace. By default\n# anonymous namespaces are hidden.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all\n# undocumented members of documented classes, files or namespaces.\n# If set to NO (the default) these members will be included in the\n# various overviews, but no documentation section is generated.\n# This option has no effect if EXTRACT_ALL is enabled.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy.\n# If set to NO (the default) these classes will be included in the various\n# overviews. This option has no effect if EXTRACT_ALL is enabled.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all\n# friend (class|struct|union) declarations.\n# If set to NO (the default) these declarations will be included in the\n# documentation.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any\n# documentation blocks found inside the body of a function.\n# If set to NO (the default) these blocks will be appended to the\n# function's detailed documentation block.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation\n# that is typed after a \\internal command is included. If the tag is set\n# to NO (the default) then the documentation will be excluded.\n# Set it to YES to include the internal documentation.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate\n# file names in lower-case letters. If set to YES upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n\nCASE_SENSE_NAMES       = YES\n\n# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen\n# will show members with their full class and namespace scopes in the\n# documentation. If set to YES the scope will be hidden.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen\n# will put a list of the files that are included by a file in the documentation\n# of that file.\n\nSHOW_INCLUDE_FILES     = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen\n# will list include files with double quotes in the documentation\n# rather than with sharp brackets.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]\n# is inserted in the documentation for inline members.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen\n# will sort the (detailed) documentation of file and class members\n# alphabetically by member name. If set to NO the members will appear in\n# declaration order.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the\n# brief documentation of file, namespace and class members alphabetically\n# by member name. If set to NO (the default) the members will appear in\n# declaration order.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen\n# will sort the (brief and detailed) documentation of class members so that\n# constructors and destructors are listed first. If set to NO (the default)\n# the constructors will appear in the respective orders defined by\n# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.\n# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO\n# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the\n# hierarchy of group names into alphabetical order. If set to NO (the default)\n# the group names will appear in their defined order.\n\nSORT_GROUP_NAMES       = YES\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be\n# sorted by fully-qualified names, including namespaces. If set to\n# NO (the default), the class list will be sorted only by class name,\n# not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the\n# alphabetical list.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to\n# do proper type resolution of all parameters of a function it will reject a\n# match between the prototype and the implementation of a member function even\n# if there is only one candidate or it is obvious which candidate to choose\n# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen\n# will still accept a match between prototype and implementation in such cases.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable (YES) or\n# disable (NO) the todo list. This list is created by putting \\todo\n# commands in the documentation.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable (YES) or\n# disable (NO) the test list. This list is created by putting \\test\n# commands in the documentation.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable (YES) or\n# disable (NO) the bug list. This list is created by putting \\bug\n# commands in the documentation.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or\n# disable (NO) the deprecated list. This list is created by putting\n# \\deprecated commands in the documentation.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional\n# documentation sections, marked by \\if section-label ... \\endif\n# and \\cond section-label ... \\endcond blocks.\n\nENABLED_SECTIONS       =\n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines\n# the initial value of a variable or macro consists of for it to appear in\n# the documentation. If the initializer consists of more lines than specified\n# here it will be hidden. Use a value of 0 to hide initializers completely.\n# The appearance of the initializer of individual variables and macros in the\n# documentation can be controlled using \\showinitializer or \\hideinitializer\n# command in the documentation regardless of this setting.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated\n# at the bottom of the documentation of classes and structs. If set to YES the\n# list will mention the files that were used to generate the documentation.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page.\n# This will remove the Files entry from the Quick Index and from the\n# Folder Tree View (if specified). The default is YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the\n# Namespaces page.\n# This will remove the Namespaces entry from the Quick Index\n# and from the Folder Tree View (if specified). The default is YES.\n\nSHOW_NAMESPACES        = NO\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command <command> <input-file>, where <command> is the value of\n# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file\n# provided by doxygen. Whatever the program writes to standard output\n# is used as the file version. See the manual for examples.\n\nFILE_VERSION_FILTER    =\n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option.\n# You can optionally specify a file name after the option, if omitted\n# DoxygenLayout.xml will be used as the name of the layout file.\n\nLAYOUT_FILE            =\n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files\n# containing the references data. This must be a list of .bib files. The\n# .bib extension is automatically appended if omitted. Using this command\n# requires the bibtex tool to be installed. See also\n# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style\n# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this\n# feature you need bibtex and perl available in the search path. Do not use\n# file names with spaces, bibtex cannot handle them.\n\nCITE_BIB_FILES         =\n\n#---------------------------------------------------------------------------\n# configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated\n# by doxygen. Possible values are YES and NO. If left blank NO is used.\n\nQUIET                  = YES\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated by doxygen. Possible values are YES and NO. If left blank\n# NO is used.\n\nWARNINGS               = YES\n\n# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings\n# for undocumented members. If EXTRACT_ALL is set to YES then this flag will\n# automatically be disabled.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some\n# parameters in a documented function, or documenting parameters that\n# don't exist or using markup commands wrongly.\n\nWARN_IF_DOC_ERROR      = YES\n\n# The WARN_NO_PARAMDOC option can be enabled to get warnings for\n# functions that are documented, but have no documentation for their parameters\n# or return value. If set to NO (the default) doxygen will only warn about\n# wrong or incomplete parameter documentation, but not about the absence of\n# documentation.\n\nWARN_NO_PARAMDOC       = YES\n\n# The WARN_FORMAT tag determines the format of the warning messages that\n# doxygen can produce. The string should contain the $file, $line, and $text\n# tags, which will be replaced by the file and line number from which the\n# warning originated and the warning text. Optionally the format may contain\n# $version, which will be replaced by the version of the file (if it could\n# be obtained via FILE_VERSION_FILTER)\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning\n# and error messages should be written. If left blank the output is written\n# to stderr.\n\nWARN_LOGFILE           = @GLFW_BINARY_DIR@/docs/warnings.txt\n\n#---------------------------------------------------------------------------\n# configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag can be used to specify the files and/or directories that contain\n# documented source files. You may enter file names like \"myfile.cpp\" or\n# directories like \"/usr/src/myproject\". Separate the files or directories\n# with spaces.\n\nINPUT                  = @GLFW_INTERNAL_DOCS@                         \\\n                         @GLFW_SOURCE_DIR@/include/GLFW/glfw3.h       \\\n                         @GLFW_SOURCE_DIR@/include/GLFW/glfw3native.h \\\n                         @GLFW_SOURCE_DIR@/docs/main.dox              \\\n                         @GLFW_SOURCE_DIR@/docs/news.dox              \\\n                         @GLFW_SOURCE_DIR@/docs/moving.dox            \\\n                         @GLFW_SOURCE_DIR@/docs/quick.dox             \\\n                         @GLFW_SOURCE_DIR@/docs/compile.dox           \\\n                         @GLFW_SOURCE_DIR@/docs/build.dox             \\\n                         @GLFW_SOURCE_DIR@/docs/intro.dox             \\\n                         @GLFW_SOURCE_DIR@/docs/context.dox           \\\n                         @GLFW_SOURCE_DIR@/docs/monitor.dox           \\\n                         @GLFW_SOURCE_DIR@/docs/window.dox            \\\n                         @GLFW_SOURCE_DIR@/docs/input.dox             \\\n                         @GLFW_SOURCE_DIR@/docs/rift.dox              \\\n                         @GLFW_SOURCE_DIR@/docs/compat.dox\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is\n# also the default input encoding. Doxygen uses libiconv (or the iconv built\n# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for\n# the list of possible encodings.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp\n# and *.h) to filter out the source-files in the directories. If left\n# blank the following patterns are tested:\n# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh\n# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py\n# *.f90 *.f *.for *.vhd *.vhdl\n\nFILE_PATTERNS          = *.h *.dox\n\n# The RECURSIVE tag can be used to turn specify whether or not subdirectories\n# should be searched for input files as well. Possible values are YES and NO.\n# If left blank NO is used.\n\nRECURSIVE              = NO\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                =\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories. Note that the wildcards are matched\n# against the file with absolute path, so to exclude all test directories\n# for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       =\n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n\nEXCLUDE_SYMBOLS        = APIENTRY GLFWAPI\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or\n# directories that contain example code fragments that are included (see\n# the \\include command).\n\nEXAMPLE_PATH           = @GLFW_SOURCE_DIR@/examples\n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp\n# and *.h) to filter out the source-files in the directories. If left\n# blank all files are included.\n\nEXAMPLE_PATTERNS       =\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude\n# commands irrespective of the value of the RECURSIVE tag.\n# Possible values are YES and NO. If left blank NO is used.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or\n# directories that contain image that are included in the documentation (see\n# the \\image command).\n\nIMAGE_PATH             =\n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command <filter> <input-file>, where <filter>\n# is the value of the INPUT_FILTER tag, and <input-file> is the name of an\n# input file. Doxygen will then use the output that the filter program writes\n# to standard output.\n# If FILTER_PATTERNS is specified, this tag will be\n# ignored.\n\nINPUT_FILTER           =\n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis.\n# Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match.\n# The filters are a list of the form:\n# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further\n# info on how filters are used. If FILTER_PATTERNS is empty or if\n# non of the patterns match the file name, INPUT_FILTER is applied.\n\nFILTER_PATTERNS        =\n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER) will be used to filter the input files when producing source\n# files to browse (i.e. when SOURCE_BROWSER is set to YES).\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any)\n# and it is also possible to disable source filtering for a specific pattern\n# using *.ext= (so without naming a filter). This option only has effect when\n# FILTER_SOURCE_FILES is enabled.\n\nFILTER_SOURCE_PATTERNS =\n\n# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page (index.html).\n# This can be useful if you have a project on for instance GitHub and want reuse\n# the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE =\n\n#---------------------------------------------------------------------------\n# configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will\n# be generated. Documented entities will be cross-referenced with these sources.\n# Note: To get rid of all source code in the generated output, make sure also\n# VERBATIM_HEADERS is set to NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body\n# of functions and classes directly in the documentation.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct\n# doxygen to hide any special comment blocks from generated source code\n# fragments. Normal C, C++ and Fortran comments will always remain visible.\n\nSTRIP_CODE_COMMENTS    = YES\n\n# If the REFERENCED_BY_RELATION tag is set to YES\n# then for each documented function all documented\n# functions referencing it will be listed.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES\n# then for each documented function all documented entities\n# called/used by that function will be listed.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)\n# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from\n# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will\n# link to the source code.\n# Otherwise they will link to the documentation.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code\n# will point to the HTML generated by the htags(1) tool instead of doxygen\n# built-in source browser. The htags tool is part of GNU's global source\n# tagging system (see http://www.gnu.org/software/global/global.html). You\n# will need version 4.8.6 or higher.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen\n# will generate a verbatim copy of the header file for each class for\n# which an include is specified. Set to NO to disable this.\n\nVERBATIM_HEADERS       = YES\n\n#---------------------------------------------------------------------------\n# configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index\n# of all compounds will be generated. Enable this if the project\n# contains a lot of classes, structs, unions or interfaces.\n\nALPHABETICAL_INDEX     = YES\n\n# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then\n# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns\n# in which this list will be split (can be a number in the range [1..20])\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all\n# classes will be put under the same header in the alphabetical index.\n# The IGNORE_PREFIX tag can be used to specify one or more prefixes that\n# should be ignored while generating the index headers.\n\nIGNORE_PREFIX          = glfw GLFW_\n\n#---------------------------------------------------------------------------\n# configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES (the default) Doxygen will\n# generate HTML output.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be\n# put in front of it. If left blank `html' will be used as the default path.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for\n# each generated HTML page (for example: .htm,.php,.asp). If it is left blank\n# doxygen will generate files with .html extension.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a personal HTML header for\n# each generated HTML page. If it is left blank doxygen will generate a\n# standard header. Note that when using a custom header you are responsible\n#  for the proper inclusion of any scripts and style sheets that doxygen\n# needs, which is dependent on the configuration options used.\n# It is advised to generate a default header using \"doxygen -w html\n# header.html footer.html stylesheet.css YourConfigFile\" and then modify\n# that header. Note that the header is subject to change so you typically\n# have to redo this when upgrading to a newer version of doxygen or when\n# changing the value of configuration settings such as GENERATE_TREEVIEW!\n\nHTML_HEADER            = @GLFW_SOURCE_DIR@/docs/header.html\n\n# The HTML_FOOTER tag can be used to specify a personal HTML footer for\n# each generated HTML page. If it is left blank doxygen will generate a\n# standard footer.\n\nHTML_FOOTER            = @GLFW_SOURCE_DIR@/docs/footer.html\n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading\n# style sheet that is used by each HTML page. It can be used to\n# fine-tune the look of the HTML output. If left blank doxygen will\n# generate a default style sheet. Note that it is recommended to use\n# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this\n# tag will in the future become obsolete.\n\nHTML_STYLESHEET        =\n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional\n# user-defined cascading style sheet that is included after the standard\n# style sheets created by doxygen. Using this option one can overrule\n# certain style aspects. This is preferred over using HTML_STYLESHEET\n# since it does not replace the standard style sheet and is therefor more\n# robust against future updates. Doxygen will copy the style sheet file to\n# the output directory.\n\nHTML_EXTRA_STYLESHEET  = @GLFW_SOURCE_DIR@/docs/extra.css\n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that\n# the files will be copied as-is; there are no commands or markers available.\n\nHTML_EXTRA_FILES       = @GLFW_SOURCE_DIR@/docs/spaces.svg\n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.\n# Doxygen will adjust the colors in the style sheet and background images\n# according to this color. Hue is specified as an angle on a colorwheel,\n# see http://en.wikipedia.org/wiki/Hue for more information.\n# For instance the value 0 represents red, 60 is yellow, 120 is green,\n# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.\n# The allowed range is 0 to 359.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of\n# the colors in the HTML output. For a value of 0 the output will use\n# grayscales only. A value of 255 will produce the most vivid colors.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to\n# the luminance component of the colors in the HTML output. Values below\n# 100 gradually make the output lighter, whereas values above 100 make\n# the output darker. The value divided by 100 is the actual gamma applied,\n# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,\n# and 100 does not change the gamma.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting\n# this to NO can help when comparing the output of multiple runs.\n\nHTML_TIMESTAMP         = YES\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of\n# entries shown in the various tree structured indices initially; the user\n# can expand and collapse entries dynamically later on. Doxygen will expand\n# the tree to such a level that at most the specified number of entries are\n# visible (unless a fully collapsed tree already exceeds this amount).\n# So setting the number of entries 1 will produce a full collapsed tree by\n# default. 0 is a special value representing an infinite number of entries\n# and will result in a full expanded tree by default.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files\n# will be generated that can be used as input for Apple's Xcode 3\n# integrated development environment, introduced with OSX 10.5 (Leopard).\n# To create a documentation set, doxygen will generate a Makefile in the\n# HTML output directory. Running make will produce the docset in that\n# directory and running \"make install\" will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find\n# it at startup.\n# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n\nGENERATE_DOCSET        = NO\n\n# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the\n# feed. A documentation feed provides an umbrella under which multiple\n# documentation sets from a single provider (such as a company or product suite)\n# can be grouped.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that\n# should uniquely identify the documentation set bundle. This should be a\n# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen\n# will append .docset to the name.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely\n# identify the documentation publisher. This should be a reverse domain-name\n# style string, e.g. com.mycompany.MyDocSet.documentation.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES, additional index files\n# will be generated that can be used as input for tools like the\n# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)\n# of the generated HTML documentation.\n\nGENERATE_HTMLHELP      = NO\n\n# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can\n# be used to specify the file name of the resulting .chm file. You\n# can add a path in front of the file if the result should not be\n# written to the html output directory.\n\nCHM_FILE               =\n\n# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can\n# be used to specify the location (absolute path including file name) of\n# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run\n# the HTML help compiler on the generated index.hhp.\n\nHHC_LOCATION           =\n\n# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag\n# controls if a separate .chi index file is generated (YES) or that\n# it should be included in the master .chm file (NO).\n\nGENERATE_CHI           = NO\n\n# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING\n# is used to encode HtmlHelp index (hhk), content (hhc) and project file\n# content.\n\nCHM_INDEX_ENCODING     =\n\n# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag\n# controls whether a binary table of contents is generated (YES) or a\n# normal table of contents (NO) in the .chm file.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members\n# to the contents of the HTML help documentation and to the tree view.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated\n# that can be used as input for Qt's qhelpgenerator to generate a\n# Qt Compressed Help (.qch) of the generated HTML documentation.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can\n# be used to specify the file name of the resulting .qch file.\n# The path specified is relative to the HTML output folder.\n\nQCH_FILE               =\n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating\n# Qt Help Project output. For more information please see\n# http://doc.trolltech.com/qthelpproject.html#namespace\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating\n# Qt Help Project output. For more information please see\n# http://doc.trolltech.com/qthelpproject.html#virtual-folders\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to\n# add. For more information please see\n# http://doc.trolltech.com/qthelpproject.html#custom-filters\n\nQHP_CUST_FILTER_NAME   =\n\n# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see\n# <a href=\"http://doc.trolltech.com/qthelpproject.html#custom-filters\">\n# Qt Help Project / Custom Filters</a>.\n\nQHP_CUST_FILTER_ATTRS  =\n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's\n# filter section matches.\n# <a href=\"http://doc.trolltech.com/qthelpproject.html#filter-attributes\">\n# Qt Help Project / Filter Attributes</a>.\n\nQHP_SECT_FILTER_ATTRS  =\n\n# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can\n# be used to specify the location of Qt's qhelpgenerator.\n# If non-empty doxygen will try to run qhelpgenerator on the generated\n# .qhp file.\n\nQHG_LOCATION           =\n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files\n#  will be generated, which together with the HTML files, form an Eclipse help\n# plugin. To install this plugin and make it available under the help contents\n# menu in Eclipse, the contents of the directory containing the HTML and XML\n# files needs to be copied into the plugins directory of eclipse. The name of\n# the directory within the plugins directory should be the same as\n# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before\n# the help appears.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have\n# this name.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)\n# at top of each HTML page. The value NO (the default) enables the index and\n# the value YES disables it. Since the tabs have the same information as the\n# navigation tree you can set this option to NO if you already set\n# GENERATE_TREEVIEW to YES.\n\nDISABLE_INDEX          = NO\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information.\n# If the tag value is set to YES, a side panel will be generated\n# containing a tree-like index structure (just like the one that\n# is generated for HTML Help). For this to work a browser that supports\n# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).\n# Windows users are probably better off using the HTML help feature.\n# Since the tree basically has the same information as the tab index you\n# could consider to set DISABLE_INDEX to NO when enabling this option.\n\nGENERATE_TREEVIEW      = NO\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values\n# (range [0,1..20]) that doxygen will group on one line in the generated HTML\n# documentation. Note that a value of 0 will completely suppress the enum\n# values from appearing in the overview section.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be\n# used to set the initial width (in pixels) of the frame in which the tree\n# is shown.\n\nTREEVIEW_WIDTH         = 300\n\n# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open\n# links to external symbols imported via tag files in a separate window.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of Latex formulas included\n# as images in the HTML documentation. The default is 10. Note that\n# when you change the font size after a successful doxygen run you need\n# to manually remove any form_*.png images from the HTML output directory\n# to force them to be regenerated.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are\n# not supported properly for IE 6.0, but are supported on all modern browsers.\n# Note that when changing this option you need to delete any form_*.png files\n# in the HTML output before the changes have effect.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax\n# (see http://www.mathjax.org) which uses client side Javascript for the\n# rendering instead of using prerendered bitmaps. Use this if you do not\n# have LaTeX installed or if you want to formulas look prettier in the HTML\n# output. When enabled you may also need to install MathJax separately and\n# configure the path to it using the MATHJAX_RELPATH option.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and\n# SVG. The default value is HTML-CSS, which is slower, but has the best\n# compatibility.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the\n# HTML output directory using the MATHJAX_RELPATH option. The destination\n# directory should contain the MathJax.js script. For instance, if the mathjax\n# directory is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to\n# the MathJax Content Delivery Network so you can quickly see the result without\n# installing MathJax.\n# However, it is strongly recommended to install a local\n# copy of MathJax from http://www.mathjax.org before deployment.\n\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension\n# names that should be enabled during MathJax rendering.\n\nMATHJAX_EXTENSIONS     =\n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box\n# for the HTML output. The underlying search engine uses javascript\n# and DHTML and should work on any modern browser. Note that when using\n# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets\n# (GENERATE_DOCSET) there is already a search function so this one should\n# typically be disabled. For large projects the javascript based search engine\n# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript.\n# There are two flavours of web server based search depending on the\n# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for\n# searching and an index file used by the script. When EXTERNAL_SEARCH is\n# enabled the indexing and searching needs to be provided by external tools.\n# See the manual for details.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain\n# the search results. Doxygen ships with an example indexer (doxyindexer) and\n# search engine (doxysearch.cgi) which are based on the open source search engine\n# library Xapian. See the manual for configuration details.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will returned the search results when EXTERNAL_SEARCH is enabled.\n# Doxygen ships with an example search engine (doxysearch) which is based on\n# the open source search engine library Xapian. See the manual for configuration\n# details.\n\nSEARCHENGINE_URL       =\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n\nEXTERNAL_SEARCH_ID     =\n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id\n# of to a relative location where the documentation can be found.\n# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...\n\nEXTRA_SEARCH_MAPPINGS  =\n\n#---------------------------------------------------------------------------\n# configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will\n# generate Latex output.\n\nGENERATE_LATEX         = NO\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be\n# put in front of it. If left blank `latex' will be used as the default path.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked. If left blank `latex' will be used as the default command name.\n# Note that when enabling USE_PDFLATEX this option is only used for\n# generating bitmaps for formulas in the HTML output, but not in the\n# Makefile that is written to the output directory.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to\n# generate index for LaTeX. If left blank `makeindex' will be used as the\n# default command name.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact\n# LaTeX documents. This may be useful for small projects and may help to\n# save some trees in general.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used\n# by the printer. Possible values are: a4, letter, legal and\n# executive. If left blank a4wide will be used.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX\n# packages that should be included in the LaTeX output.\n\nEXTRA_PACKAGES         =\n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for\n# the generated latex document. The header should contain everything until\n# the first chapter. If it is left blank doxygen will generate a\n# standard header. Notice: only use this tag if you know what you are doing!\n\nLATEX_HEADER           =\n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for\n# the generated latex document. The footer should contain everything after\n# the last chapter. If it is left blank doxygen will generate a\n# standard footer. Notice: only use this tag if you know what you are doing!\n\nLATEX_FOOTER           =\n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated\n# is prepared for conversion to pdf (using ps2pdf). The pdf file will\n# contain links (just like the HTML output) instead of page references\n# This makes the output suitable for online browsing using a pdf viewer.\n\nPDF_HYPERLINKS         = YES\n\n# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of\n# plain latex in the generated Makefile. Set this option to YES to get a\n# higher quality PDF documentation.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\\\batchmode.\n# command to the generated LaTeX files. This will instruct LaTeX to keep\n# running if errors occur, instead of asking the user for help.\n# This option is also used when generating formulas in HTML.\n\nLATEX_BATCHMODE        = NO\n\n# If LATEX_HIDE_INDICES is set to YES then doxygen will not\n# include the index chapters (such as File Index, Compound Index, etc.)\n# in the output.\n\nLATEX_HIDE_INDICES     = NO\n\n# If LATEX_SOURCE_CODE is set to YES then doxygen will include\n# source code with syntax highlighting in the LaTeX output.\n# Note that which sources are shown also depends on other settings\n# such as SOURCE_BROWSER.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. The default style is \"plain\". See\n# http://en.wikipedia.org/wiki/BibTeX for more info.\n\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output\n# The RTF output is optimized for Word 97 and may not look very pretty with\n# other RTF readers or editors.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be\n# put in front of it. If left blank `rtf' will be used as the default path.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES Doxygen generates more compact\n# RTF documents. This may be useful for small projects and may help to\n# save some trees in general.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated\n# will contain hyperlink fields. The RTF file will\n# contain links (just like the HTML output) instead of page references.\n# This makes the output suitable for online browsing using WORD or other\n# programs which support those fields.\n# Note: wordpad (write) and others do not support links.\n\nRTF_HYPERLINKS         = NO\n\n# Load style sheet definitions from file. Syntax is similar to doxygen's\n# config file, i.e. a series of assignments. You only have to provide\n# replacements, missing definitions are set to their default value.\n\nRTF_STYLESHEET_FILE    =\n\n# Set optional variables used in the generation of an rtf document.\n# Syntax is similar to doxygen's config file.\n\nRTF_EXTENSIONS_FILE    =\n\n#---------------------------------------------------------------------------\n# configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES (the default) Doxygen will\n# generate man pages\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be\n# put in front of it. If left blank `man' will be used as the default path.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to\n# the generated man pages (default is the subroutine's section .3)\n\nMAN_EXTENSION          = .3\n\n# If the MAN_LINKS tag is set to YES and Doxygen generates man output,\n# then it will generate one additional man file for each entity\n# documented in the real man page(s). These additional files\n# only source the real man page, but without them the man command\n# would be unable to find the correct page. The default is NO.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES Doxygen will\n# generate an XML file that captures the structure of\n# the code including all documentation.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be\n# put in front of it. If left blank `xml' will be used as the default path.\n\nXML_OUTPUT             = xml\n\n# If the XML_PROGRAMLISTING tag is set to YES Doxygen will\n# dump the program listings (including syntax highlighting\n# and cross-referencing information) to the XML output. Note that\n# enabling this will significantly increase the size of the XML output.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will\n# generate an AutoGen Definitions (see autogen.sf.net) file\n# that captures the structure of the code including all\n# documentation. Note that this feature is still experimental\n# and incomplete at the moment.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES Doxygen will\n# generate a Perl module file that captures the structure of\n# the code including all documentation. Note that this\n# feature is still experimental and incomplete at the\n# moment.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES Doxygen will generate\n# the necessary Makefile rules, Perl scripts and LaTeX code to be able\n# to generate PDF and DVI output from the Perl module output.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be\n# nicely formatted so it can be parsed by a human reader.\n# This is useful\n# if you want to understand what is going on.\n# On the other hand, if this\n# tag is set to NO the size of the Perl module output will be much smaller\n# and Perl will parse it just the same.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file\n# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.\n# This is useful so different doxyrules.make files included by the same\n# Makefile don't overwrite each other's variables.\n\nPERLMOD_MAKEVAR_PREFIX =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will\n# evaluate all C-preprocessor directives found in the sources and include\n# files.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro\n# names in the source code. If set to NO (the default) only conditional\n# compilation will be performed. Macro expansion can be done in a controlled\n# way by setting EXPAND_ONLY_PREDEF to YES.\n\nMACRO_EXPANSION        = YES\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES\n# then the macro expansion is limited to the macros specified with the\n# PREDEFINED and EXPAND_AS_DEFINED tags.\n\nEXPAND_ONLY_PREDEF     = YES\n\n# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files\n# pointed to by INCLUDE_PATH will be searched when a #include is found.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by\n# the preprocessor.\n\nINCLUDE_PATH           =\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will\n# be used.\n\nINCLUDE_FILE_PATTERNS  =\n\n# The PREDEFINED tag can be used to specify one or more macro names that\n# are defined before the preprocessor is started (similar to the -D option of\n# gcc). The argument of the tag is a list of macros of the form: name\n# or name=definition (no spaces). If the definition and the = are\n# omitted =1 is assumed. To prevent a macro definition from being\n# undefined via #undef or recursively expanded use the := operator\n# instead of the = operator.\n\nPREDEFINED             = GLFWAPI=                 \\\n                         GLFW_EXPOSE_NATIVE_WIN32 \\\n                         GLFW_EXPOSE_NATIVE_WGL   \\\n                         GLFW_EXPOSE_NATIVE_X11   \\\n                         GLFW_EXPOSE_NATIVE_GLX   \\\n                         GLFW_EXPOSE_NATIVE_COCOA \\\n                         GLFW_EXPOSE_NATIVE_NSGL  \\\n                         GLFW_EXPOSE_NATIVE_EGL\n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then\n# this tag can be used to specify a list of macro names that should be expanded.\n# The macro definition that is found in the sources will be used.\n# Use the PREDEFINED tag if you want to use a different macro definition that\n# overrules the definition found in the source code.\n\nEXPAND_AS_DEFINED      =\n\n# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then\n# doxygen's preprocessor will remove all references to function-like macros\n# that are alone on a line, have an all uppercase name, and do not end with a\n# semicolon, because these will confuse the parser if not removed.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration::additions related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES option can be used to specify one or more tagfiles. For each\n# tag file the location of the external documentation should be added. The\n# format of a tag file without this location is as follows:\n#\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n#\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where \"loc1\" and \"loc2\" can be relative or absolute paths\n# or URLs. Note that each tag file must have a unique name (where the name does\n# NOT include the path). If a tag file is not located in the directory in which\n# doxygen is run, you must also specify the path to the tagfile here.\n\nTAGFILES               =\n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create\n# a tag file that is based on the input files it reads.\n\nGENERATE_TAGFILE       =\n\n# If the ALLEXTERNALS tag is set to YES all external classes will be listed\n# in the class index. If set to NO only the inherited external classes\n# will be listed.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed\n# in the modules index. If set to NO, only the current project's groups will\n# be listed.\n\nEXTERNAL_GROUPS        = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of `which perl').\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will\n# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base\n# or super classes. Setting the tag to NO turns the diagrams off. Note that\n# this option also works with HAVE_DOT disabled, but it is recommended to\n# install and use dot, since it yields more powerful graphs.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see\n# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            =\n\n# If set to YES, the inheritance and collaboration graphs will hide\n# inheritance and usage relations if the target is undocumented\n# or is not a class.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz, a graph visualization\n# toolkit from AT&T and Lucent Bell Labs. The other options in this section\n# have no effect if this option is set to NO (the default)\n\nHAVE_DOT               = NO\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is\n# allowed to run in parallel. When set to 0 (the default) doxygen will\n# base this on the number of processors available in the system. You can set it\n# explicitly to a value larger than 0 to get control over the balance\n# between CPU load and processing speed.\n\nDOT_NUM_THREADS        = 0\n\n# By default doxygen will use the Helvetica font for all dot files that\n# doxygen generates. When you want a differently looking font you can specify\n# the font name using DOT_FONTNAME. You need to make sure dot is able to find\n# the font, which can be done by putting it in a standard location or by setting\n# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the\n# directory containing the font.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.\n# The default size is 10pt.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the Helvetica font.\n# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to\n# set the path where dot can find it.\n\nDOT_FONTPATH           =\n\n# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen\n# will generate a graph for each documented class showing the direct and\n# indirect inheritance relations. Setting this tag to YES will force the\n# CLASS_DIAGRAMS tag to NO.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen\n# will generate a graph for each documented class showing the direct and\n# indirect implementation dependencies (inheritance, containment, and\n# class references variables) of the class with other documented classes.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen\n# will generate a graph for groups, showing the direct groups dependencies\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside\n# the class node. If there are many fields or methods and many nodes the\n# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS\n# threshold limits the number of items for each type to make the size more\n# managable. Set this to 0 for no limit. Note that the threshold may be\n# exceeded by 50% before the limit is enforced.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If set to YES, the inheritance and collaboration graphs will show the\n# relations between templates and their instances.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT\n# tags are set to YES then doxygen will generate a graph for each documented\n# file showing the direct and indirect include dependencies of the file with\n# other documented files.\n\nINCLUDE_GRAPH          = YES\n\n# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and\n# HAVE_DOT tags are set to YES then doxygen will generate a graph for each\n# documented header file showing the documented files that directly or\n# indirectly include this file.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH and HAVE_DOT options are set to YES then\n# doxygen will generate a call dependency graph for every global function\n# or class method. Note that enabling this option will significantly increase\n# the time of a run. So in most cases it will be better to enable call graphs\n# for selected functions only using the \\callgraph command.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then\n# doxygen will generate a caller dependency graph for every global function\n# or class method. Note that enabling this option will significantly increase\n# the time of a run. So in most cases it will be better to enable caller\n# graphs for selected functions only using the \\callergraph command.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen\n# will generate a graphical hierarchy of all classes instead of a textual one.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES\n# then doxygen will show the dependencies a directory has on other directories\n# in a graphical way. The dependency relations are determined by the #include\n# relations between the files in the directories.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot. Possible values are svg, png, jpg, or gif.\n# If left blank png will be used. If you choose svg you need to set\n# HTML_FILE_EXTENSION to xhtml in order to make the SVG files\n# visible in IE 9+ (other browsers do not have this requirement).\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n# Note that this requires a modern browser other than Internet Explorer.\n# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you\n# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files\n# visible. Older versions of IE do not have SVG support.\n\nINTERACTIVE_SVG        = NO\n\n# The tag DOT_PATH can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n\nDOT_PATH               =\n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the\n# \\dotfile command).\n\nDOTFILE_DIRS           =\n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the\n# \\mscfile command).\n\nMSCFILE_DIRS           =\n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of\n# nodes that will be shown in the graph. If the number of nodes in a graph\n# becomes larger than this value, doxygen will truncate the graph, which is\n# visualized by representing a node as a red box. Note that doxygen if the\n# number of direct children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note\n# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the\n# graphs generated by dot. A depth value of 3 means that only nodes reachable\n# from the root by following a path via at most 3 edges will be shown. Nodes\n# that lay further from the root node will be omitted. Note that setting this\n# option to 1 or 2 may greatly reduce the computation time needed for large\n# code bases. Also note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not\n# seem to support this out of the box. Warning: Depending on the platform used,\n# enabling this option may lead to badly anti-aliased labels on the edges of\n# a graph (i.e. they become hard to read).\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10)\n# support this, this feature is disabled by default.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will\n# generate a legend page explaining the meaning of the various boxes and\n# arrows in the dot generated graphs.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will\n# remove the intermediate dot files that are used to generate\n# the various graphs.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "deps/glfw/docs/DoxygenLayout.xml",
    "content": "<doxygenlayout version=\"1.0\">\n  <!-- Generated by doxygen 1.8.3.1 -->\n  <!-- Navigation index tabs for HTML output -->\n  <navindex>\n    <tab type=\"mainpage\" visible=\"yes\" title=\"Introduction\"/>\n    <tab type=\"pages\" visible=\"yes\" title=\"Guides\" intro=\"\"/>\n    <tab type=\"modules\" visible=\"yes\" title=\"Reference\" intro=\"\"/>\n    <tab type=\"namespaces\" visible=\"yes\" title=\"\">\n      <tab type=\"namespacelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"namespacemembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"classes\" visible=\"no\" title=\"\">\n      <tab type=\"classlist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"classindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/> \n      <tab type=\"hierarchy\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"classmembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"files\" visible=\"yes\" title=\"Header Files\">\n      <tab type=\"filelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"globals\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"examples\" visible=\"yes\" title=\"\" intro=\"\"/>  \n  </navindex>\n\n  <!-- Layout definition for a class page -->\n  <class>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_INCLUDE_FILES\"/>\n    <inheritancegraph visible=\"$CLASS_GRAPH\"/>\n    <collaborationgraph visible=\"$COLLABORATION_GRAPH\"/>\n    <memberdecl>\n      <nestedclasses visible=\"yes\" title=\"\"/>\n      <publictypes title=\"\"/>\n      <publicslots title=\"\"/>\n      <signals title=\"\"/>\n      <publicmethods title=\"\"/>\n      <publicstaticmethods title=\"\"/>\n      <publicattributes title=\"\"/>\n      <publicstaticattributes title=\"\"/>\n      <protectedtypes title=\"\"/>\n      <protectedslots title=\"\"/>\n      <protectedmethods title=\"\"/>\n      <protectedstaticmethods title=\"\"/>\n      <protectedattributes title=\"\"/>\n      <protectedstaticattributes title=\"\"/>\n      <packagetypes title=\"\"/>\n      <packagemethods title=\"\"/>\n      <packagestaticmethods title=\"\"/>\n      <packageattributes title=\"\"/>\n      <packagestaticattributes title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n      <privatetypes title=\"\"/>\n      <privateslots title=\"\"/>\n      <privatemethods title=\"\"/>\n      <privatestaticmethods title=\"\"/>\n      <privateattributes title=\"\"/>\n      <privatestaticattributes title=\"\"/>\n      <friends title=\"\"/>\n      <related title=\"\" subtitle=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <constructors title=\"\"/>\n      <functions title=\"\"/>\n      <related title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n    </memberdef>\n    <allmemberslink visible=\"yes\"/>\n    <usedfiles visible=\"$SHOW_USED_FILES\"/>\n    <authorsection visible=\"yes\"/>\n  </class>\n\n  <!-- Layout definition for a namespace page -->\n  <namespace>\n    <briefdescription visible=\"yes\"/>\n    <memberdecl>\n      <nestednamespaces visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </namespace>\n\n  <!-- Layout definition for a file page -->\n  <file>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_INCLUDE_FILES\"/>\n    <includegraph visible=\"$INCLUDE_GRAPH\"/>\n    <includedbygraph visible=\"$INCLUDED_BY_GRAPH\"/>\n    <sourcelink visible=\"yes\"/>\n    <memberdecl>\n      <classes visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n    </memberdef>\n    <authorsection/>\n  </file>\n\n  <!-- Layout definition for a group page -->\n  <group>\n    <briefdescription visible=\"yes\"/>\n    <detaileddescription title=\"Description\"/>\n    <groupgraph visible=\"$GROUP_GRAPHS\"/>\n    <memberdecl>\n      <nestedgroups visible=\"yes\" title=\"\"/>\n      <dirs visible=\"yes\" title=\"\"/>\n      <files visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <memberdef>\n      <pagedocs/>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </group>\n\n  <!-- Layout definition for a directory page -->\n  <directory>\n    <briefdescription visible=\"yes\"/>\n    <directorygraph visible=\"yes\"/>\n    <memberdecl>\n      <dirs visible=\"yes\"/>\n      <files visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n  </directory>\n</doxygenlayout>\n"
  },
  {
    "path": "deps/glfw/docs/build.dox",
    "content": "/*!\n\n@page build Building applications\n\n@tableofcontents\n\nThis is about compiling and linking applications that use GLFW.  For information on\nhow to write such applications, start with the [introductory tutorial](@ref quick).\nFor information on how to compile the GLFW library itself, see the @ref compile\nguide.\n\nThis is not a tutorial on compilation or linking.  It assumes basic\nunderstanding of how to compile and link a C program as well as how to use the\nspecific compiler of your chosen development environment.  The compilation\nand linking process should be explained in your C programming material and in\nthe documentation for your development environment.\n\n@section build_include Including the GLFW header file\n\nIn the source files of your application where you use OpenGL or GLFW, you should\ninclude the GLFW header file, i.e.:\n\n@code\n#include <GLFW/glfw3.h>\n@endcode\n\nThe GLFW header declares the GLFW API and by default also includes the OpenGL\nheader of your development environment, which in turn defines all the constants,\ntypes and function prototypes of the OpenGL API.\n\nThe GLFW header also defines everything necessary for your OpenGL header to\nfunction.  For example, under Windows you are normally required to include\n`windows.h` before the OpenGL header, which would pollute your code namespace\nwith the entire Win32 API.\n\nInstead, the GLFW header takes care of this for you, not by including\n`windows.h`, but by duplicating only the very few necessary parts of it.  It\ndoes this only when needed, so if `windows.h` _is_ included, the GLFW header\ndoes not try to redefine those symbols.  The reverse is not true, i.e.\n`windows.h` cannot cope if any of its symbols have already been defined.\n\nIn other words:\n\n - Do _not_ include the OpenGL headers yourself, as GLFW does this for you\n - Do _not_ include `windows.h` or other platform-specific headers unless you\n   plan on using those APIs directly\n - If you _do_ need to include such headers, do it _before_ including\n   the GLFW header and it will handle this\n\nIf you are using an OpenGL extension loading library such as\n[glad](https://github.com/Dav1dde/glad), the extension loader header should\neither be included _before_ the GLFW one, or the `GLFW_INCLUDE_NONE` macro\n(described below) should be defined.\n\n\n@subsection build_macros GLFW header option macros\n\nThese macros may be defined before the inclusion of the GLFW header and affect\nits behavior.\n\n`GLFW_DLL` is required on Windows when using the GLFW DLL, to tell the compiler\nthat the GLFW functions are defined in a DLL.\n\nThe following macros control which OpenGL or OpenGL ES API header is included.\nOnly one of these may be defined at a time.\n\n`GLFW_INCLUDE_GLCOREARB` makes the GLFW header include the modern\n`GL/glcorearb.h` header (`OpenGL/gl3.h` on OS X) instead of the regular OpenGL\nheader.\n\n`GLFW_INCLUDE_ES1` makes the GLFW header include the OpenGL ES 1.x `GLES/gl.h`\nheader instead of the regular OpenGL header.\n\n`GLFW_INCLUDE_ES2` makes the GLFW header include the OpenGL ES 2.0 `GLES2/gl2.h`\nheader instead of the regular OpenGL header.\n\n`GLFW_INCLUDE_ES3` makes the GLFW header include the OpenGL ES 3.0 `GLES3/gl3.h`\nheader instead of the regular OpenGL header.\n\n`GLFW_INCLUDE_ES31` makes the GLFW header include the OpenGL ES 3.1 `GLES3/gl31.h`\nheader instead of the regular OpenGL header.\n\n`GLFW_INCLUDE_NONE` makes the GLFW header not include any OpenGL or OpenGL ES API\nheader.  This is useful in combination with an extension loading library.\n\nIf none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h`\nheader (`OpenGL/gl.h` on OS X) is included.\n\nThe following macros control the inclusion of additional API headers.  Any\nnumber of these may be defined simultaneously, and/or together with one of the\nabove macros.\n\n`GLFW_INCLUDE_GLEXT` makes the GLFW header include the appropriate extension\nheader for the OpenGL or OpenGL ES header selected above after and in addition\nto that header.\n\n`GLFW_INCLUDE_GLU` makes the header include the GLU header in addition to the\nheader selected above.  This should only be used with the standard OpenGL header\nand only for compatibility with legacy code.  GLU has been deprecated and should\nnot be used in new code.\n\n@note GLFW does not provide any of the API headers mentioned above.  They must\nbe provided by your development environment or your OpenGL or OpenGL ES SDK.\n\n@note None of these macros may be defined during the compilation of GLFW itself.\nIf your build includes GLFW and you define any these in your build files, make\nsure they are not applied to the GLFW sources.\n\n\n@section build_link Link with the right libraries\n\nGLFW is essentially a wrapper of various platform-specific APIs and therefore\nneeds to link against many different system libraries.  If you are using GLFW as\na shared library / dynamic library / DLL then it takes care of these links.\nHowever, if you are using GLFW as a static library then your executable will\nneed to link against these libraries.\n\nOn Windows and OS X, the list of system libraries is static and can be\nhard-coded into your build environment.  See the section for your development\nenvironment below.  On Linux and other Unix-like operating systems, the list\nvaries but can be retrieved in various ways as described below.\n\nA good general introduction to linking is\n[Beginner's Guide to Linkers](http://www.lurklurk.org/linkers/linkers.html) by\nDavid Drysdale.\n\n\n@subsection build_link_win32 With MinGW or Visual C++ on Windows\n\nThe static version of the GLFW library is named `glfw3`.  When using this\nversion, it is also necessary to link with some libraries that GLFW uses.\n\nWhen linking an application under Windows that uses the static version of GLFW,\nyou must link with `opengl32`.  On some versions of MinGW, you must also\nexplicitly link with `gdi32`, while other versions of MinGW include it in the\nset of default libraries along with other dependencies like `user32` and\n`kernel32`.  If you are using GLU, you must also link with `glu32`.\n\nThe link library for the GLFW DLL is named `glfw3dll`.  When compiling an\napplication that uses the DLL version of GLFW, you need to define the `GLFW_DLL`\nmacro _before_ any inclusion of the GLFW header.  This can be done either with\na compiler switch or by defining it in your source code.\n\nAn application using the GLFW DLL does not need to link against any of its\ndependencies, but you still have to link against `opengl32` if your application\nuses OpenGL and `glu32` if it uses GLU.\n\n\n@subsection build_link_cmake_source With CMake and GLFW source\n\nWith just a few changes to your `CMakeLists.txt` you can have the GLFW source\ntree built along with your application.\n\nFirstly, add the root directory of the GLFW source tree to your project.  This\nwill add the `glfw` target and the necessary cache variables to your project.\n\n@code{.cmake}\nadd_subdirectory(path/to/glfw)\n@endcode\n\nTo be able to include the GLFW header from your code, you need to tell the\ncompiler where to find it.\n\n@code{.cmake}\ninclude_directories(path/to/glfw/include)\n@endcode\n\nOnce GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable\ncontains all link-time dependencies of GLFW as it is currently configured.  To\nlink against GLFW, link against them and the `glfw` target.\n\n@code{.cmake}\ntarget_link_libraries(myapp glfw ${GLFW_LIBRARIES})\n@endcode\n\nNote that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it.  If\nyour application needs GLU, you can add it to the list of dependencies with the\n`OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW\nCMake files look for OpenGL.\n\n@code{.cmake}\ntarget_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})\n@endcode\n\n\n@subsection build_link_cmake_pkgconfig With CMake on Unix and installed GLFW binaries\n\nCMake can import settings from pkg-config, which GLFW supports.  When you\ninstalled GLFW, the pkg-config file `glfw3.pc` was installed along with it.\n\nFirst you need to find the PkgConfig package.  If this fails, you may need to\ninstall the pkg-config package for your distribution.\n\n@code{.cmake}\nfind_package(PkgConfig REQUIRED)\n@endcode\n\nThis creates the CMake commands to find pkg-config packages.  Then you need to\nfind the GLFW package.\n\n@code{.cmake}\npkg_search_module(GLFW REQUIRED glfw3)\n@endcode\n\nThis creates the CMake variables you need to use GLFW.  To be able to include\nthe GLFW header, you need to tell your compiler where it is.\n\n@code{.cmake}\ninclude_directories(${GLFW_INCLUDE_DIRS})\n@endcode\n\nYou also need to link against the correct libraries.  If you are using the\nshared library version of GLFW, use the `GLFW_LIBRARIES` variable.\n\n@code{.cmake}\ntarget_link_libraries(simple ${GLFW_LIBRARIES})\n@endcode\n\nIf you are using the static library version of GLFW, use the\n`GLFW_STATIC_LIBRARIES` variable instead.\n\n@code{.cmake}\ntarget_link_libraries(simple ${GLFW_STATIC_LIBRARIES})\n@endcode\n\n\n@subsection build_link_pkgconfig With pkg-config on OS X or other Unix\n\nGLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),\nand the `glfw3.pc` pkf-config file is generated when the GLFW library is built\nand is installed along with it.  A pkg-config file describes all necessary\ncompile-time and link-time flags and dependencies needed to use a library.  When\nthey are updated or if they differ between systems, you will get the correct\nones automatically.\n\nA typical compile and link command-line when using the static version of the\nGLFW library may look like this:\n\n@code{.sh}\ncc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3`\n@endcode\n\nIf you are using the shared version of the GLFW library, simply omit the\n`--static` flag.\n\n@code{.sh}\ncc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`\n@endcode\n\nYou can also use the `glfw3.pc` file without installing it first, by using the\n`PKG_CONFIG_PATH` environment variable.\n\n@code{.sh}\nenv PKG_CONFIG_PATH=path/to/glfw/src cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3`\n@endcode\n\nThe dependencies do not include GLU, as GLFW does not use it.  On OS X, GLU is\nbuilt into the OpenGL framework, so if you need GLU you don't need to do\nanything extra.  If you need GLU and are using Linux or BSD, you should add the\n`glu` pkg-config module.\n\n@code{.sh}\ncc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu`\n@endcode\n\nIf you are using the static version of the GLFW library, make sure you don't\nlink statically against GLU.\n\n@code{.sh}\ncc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --static --libs glfw3` `pkg-config --libs glu`\n@endcode\n\n\n@subsection build_link_xcode With Xcode on OS X\n\nIf you are using the dynamic library version of GLFW, simply add it to the\nproject dependencies.\n\nIf you are using the static library version of GLFW, add it and the Cocoa,\nOpenGL, IOKit and CoreVideo frameworks to the project as dependencies.  They can\nall be found in `/System/Library/Frameworks`.\n\n\n@subsection build_link_osx With command-line on OS X\n\nIt is recommended that you use [pkg-config](@ref build_link_pkgconfig) when\nbuilding from the command line on OS X.  That way you will get any new\ndependencies added automatically.  If you still wish to build manually, you need\nto add the required frameworks and libraries to your command-line yourself using\nthe `-l` and `-framework` switches.\n\nIf you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:\n\n@code{.sh}\ncc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo\n@endcode\n\nIf you are using the static library, named `libglfw3.a`, substitute `-lglfw3`\nfor `-lglfw`.\n\nNote that you do not add the `.framework` extension to a framework when linking\nagainst it from the command-line.\n\nThe OpenGL framework contains both the OpenGL and GLU APIs, so there is nothing\nspecial to do when using GLU.  Also note that even though your machine may have\n`libGL`-style OpenGL libraries, they are for use with the X Window System and\nwill _not_ work with the OS X native version of GLFW.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/compat.dox",
    "content": "/*!\n\n@page compat Standards conformance\n\n@tableofcontents\n\nThis guide describes the various API extensions used by this version of GLFW.\nIt lists what are essentially implementation details, but which are nonetheless\nvital knowledge for developers intending to deploy their applications on a wide\nrange of machines.\n\nThe information in this guide is not a part of GLFW API, but merely\npreconditions for some parts of the library to function on a given machine.  Any\npart of this information may change in future versions of GLFW and that will not\nbe considered a breaking API change.\n\n\n@section compat_x11 X11 extensions, protocols and IPC standards\n\nAs GLFW uses Xlib directly, without any intervening toolkit\nlibrary, it has sole responsibility for interacting well with the many and\nvaried window managers in use on Unix-like systems.  In order for applications\nand window managers to work well together, a number of standards and\nconventions have been developed that regulate behavior outside the scope of the\nX11 API; most importantly the\n[Inter-Client Communication Conventions Manual](http://www.tronche.com/gui/x/icccm/)\n(ICCCM) and\n[Extended Window Manager Hints](http://standards.freedesktop.org/wm-spec/wm-spec-latest.html)\n(EWMH) standards.\n\nGLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows.\nIf the running window manager does not support this property, the\n`GLFW_DECORATED` hint will have no effect.\n\nGLFW uses the ICCCM `WM_DELETE_WINDOW` protocol to intercept the user\nattempting to close the GLFW window.  If the running window manager does not\nsupport this protocol, the close callback will never be called.\n\nGLFW uses the EWMH `_NET_WM_PING` protocol, allowing the window manager notify\nthe user when the application has stopped responding, i.e. when it has ceased to\nprocess events.  If the running window manager does not support this protocol,\nthe user will not be notified if the application locks up.\n\nGLFW uses the EWMH `_NET_WM_STATE_FULLSCREEN` window state to tell the window\nmanager to make the GLFW window full screen.  If the running window manager does\nnot support this state, full screen windows may not work properly.  GLFW has\na fallback code path in case this state is unavailable, but every window manager\nbehaves slightly differently in this regard.\n\nGLFW uses the EWMH `_NET_WM_BYPASS_COMPOSITOR` window property to tell a\ncompositing window manager to un-redirect full screen GLFW windows.  If the\nrunning window manager uses compositing but does not support this property then\nadditional copying may be performed for each buffer swap of full screen windows.\n\nGLFW uses the\n[clipboard manager protocol](http://www.freedesktop.org/wiki/ClipboardManager/)\nto push a clipboard string (i.e. selection) owned by a GLFW window about to be\ndestroyed to the clipboard manager.  If there is no running clipboard manager,\nthe clipboard string will be unavailable once the window has been destroyed.\n\nGLFW uses the\n[X drag-and-drop protocol](http://www.freedesktop.org/wiki/Specifications/XDND/)\nto provide file drop events.  If the application originating the drag does not\nsupport this protocol, drag and drop will not work.\n\nGLFW uses the XInput 2 extension to provide sub-pixel cursor motion events.  If\nthe running X server does not support this version of this extension, cursor\nmotion will be snapped to the pixel grid.\n\nGLFW uses the XRandR 1.3 extension to provide multi-monitor support.  If the\nrunning X server does not support this version of this extension, multi-monitor\nsupport will not function and only a single, desktop-spanning monitor will be\nreported.\n\nGLFW uses the XRandR 1.3 and Xf86vidmode extensions to provide gamma ramp\nsupport.  If the running X server does not support either or both of these\nextensions, gamma ramp support will not function.\n\nGLFW uses the Xkb extension and detectable auto-repeat to provide keyboard\ninput.  If the running X server does not support this extension, a non-Xkb\nfallback path is used.\n\n\n@section compat_glx GLX extensions\n\nThe GLX API is the default API used to create OpenGL contexts on Unix-like\nsystems using the X Window System.\n\nGLFW uses the GLX 1.3 `GLXFBConfig` functions to enumerate and select framebuffer pixel\nformats.  If GLX 1.3 is not supported, @ref glfwInit will fail.\n\nGLFW uses the `GLX_MESA_swap_control,` `GLX_EXT_swap_control` and\n`GLX_SGI_swap_control` extensions to provide vertical retrace synchronization\n(or _vsync_), in that order of preference.  Where none of these extension are\navailable, calling @ref glfwSwapInterval will have no effect.\n\nGLFW uses the `GLX_ARB_multisample` extension to create contexts with\nmultisampling anti-aliasing.  Where this extension is unavailable, the\n`GLFW_SAMPLES` hint will have no effect.\n\nGLFW uses the `GLX_ARB_create_context` extension when available, even when\ncreating OpenGL contexts of version 2.1 and below.  Where this extension is\nunavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`\nhints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint\nwill have no effect, and setting the `GLFW_OPENGL_PROFILE` or\n`GLFW_OPENGL_FORWARD_COMPAT` hints to `GL_TRUE` will cause @ref\nglfwCreateWindow to fail.\n\nGLFW uses the `GLX_ARB_create_context_profile` extension to provide support for\ncontext profiles.  Where this extension is unavailable, setting the\n`GLFW_OPENGL_PROFILE` hint to anything but `GLFW_OPENGL_ANY_PROFILE`, or setting\n`GLFW_CLIENT_API` to anything but `GLFW_OPENGL_API` will cause @ref\nglfwCreateWindow to fail.\n\nGLFW uses the `GLX_ARB_context_flush_control` extension to provide control over\nwhether a context is flushed when it is released (made non-current).  Where this\nextension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no\neffect and the context will always be flushed when released.\n\nGLFW uses the `GLX_ARB_framebuffer_sRGB` and `GLX_EXT_framebuffer_sRGB`\nextensions to provide support for sRGB framebuffers.  Where both of these\nextensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect.\n\n\n@section compat_wgl WGL extensions\n\nThe WGL API is used to create OpenGL contexts on Microsoft Windows and other\nimplementations of the Win32 API, such as Wine.\n\nGLFW uses either the `WGL_EXT_extension_string` or the\n`WGL_ARB_extension_string` extension to check for the presence of all other WGL\nextensions listed below.  If both are available, the EXT one is preferred.  If\nneither is available, no other extensions are used and many GLFW features\nrelated to context creation will have no effect or cause errors when used.\n\nGLFW uses the `WGL_EXT_swap_control` extension to provide vertical retrace\nsynchronization (or _vsync_).  Where this extension is unavailable, calling @ref\nglfwSwapInterval will have no effect.\n\nGLFW uses the `WGL_ARB_pixel_format` and `WGL_ARB_multisample` extensions to\ncreate contexts with multisampling anti-aliasing.  Where these extensions are\nunavailable, the `GLFW_SAMPLES` hint will have no effect.\n\nGLFW uses the `WGL_ARB_create_context` extension when available, even when\ncreating OpenGL contexts of version 2.1 and below.  Where this extension is\nunavailable, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR`\nhints will only be partially supported, the `GLFW_OPENGL_DEBUG_CONTEXT` hint\nwill have no effect, and setting the `GLFW_OPENGL_PROFILE` or\n`GLFW_OPENGL_FORWARD_COMPAT` hints to `GL_TRUE` will cause @ref\nglfwCreateWindow to fail.\n\nGLFW uses the `WGL_ARB_create_context_profile` extension to provide support for\ncontext profiles.  Where this extension is unavailable, setting the\n`GLFW_OPENGL_PROFILE` hint to anything but `GLFW_OPENGL_ANY_PROFILE` will cause\n@ref glfwCreateWindow to fail.\n\nGLFW uses the `WGL_ARB_context_flush_control` extension to provide control over\nwhether a context is flushed when it is released (made non-current).  Where this\nextension is unavailable, the `GLFW_CONTEXT_RELEASE_BEHAVIOR` hint will have no\neffect and the context will always be flushed when released.\n\nGLFW uses the `WGL_ARB_framebuffer_sRGB` and `WGL_EXT_framebuffer_sRGB`\nextensions to provide support for sRGB framebuffers.  Where both of these\nextension are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect.\n\n\n@section compat_osx OpenGL 3.2 and later on OS X\n\nSupport for OpenGL 3.2 and above was introduced with OS X 10.7 and even then\nonly forward-compatible, core profile contexts are supported.  Support for\nOpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible,\ncore profile contexts.  There is also still no mechanism for requesting debug\ncontexts.  Versions of Mac OS X earlier than 10.7 support at most OpenGL\nversion 2.1.\n\nBecause of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and\n`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if\ngiven version 3.0 or 3.1, the `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to\n`GL_TRUE` and the `GLFW_OPENGL_PROFILE` hint must be set to\n`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts and the\n`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.\n\nAlso, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and\n`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1,\nsetting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to\na non-default value will cause @ref glfwCreateWindow to fail and the\n`GLFW_OPENGL_DEBUG_CONTEXT` hint is ignored.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/compile.dox",
    "content": "/*!\n\n@page compile Compiling GLFW\n\n@tableofcontents\n\nThis is about compiling the GLFW library itself.  For information on how to\nbuild applications that use GLFW, see the @ref build guide.\n\n\n@section compile_cmake Using CMake\n\nGLFW uses [CMake](http://www.cmake.org/) to generate project files or makefiles\nfor a particular development environment.  If you are on a Unix-like system such\nas Linux or FreeBSD or have a package system like Fink, MacPorts, Cygwin or\nHomebrew, you can simply install its CMake package.  If not, you can download\ninstallers for Windows and OS X from the [CMake website](http://www.cmake.org/).\n\n@note CMake only generates project files or makefiles.  It does not compile the\nactual GLFW library.  To compile GLFW, first generate these files for your\nchosen development environment and then use them to compile the actual GLFW\nlibrary.\n\n\n@subsection compile_deps Dependencies\n\nOnce you have installed CMake, make sure that all other dependencies are\navailable.  On some platforms, GLFW needs a few additional packages to be\ninstalled.  See the section for your chosen platform and development environment\nbelow.\n\n\n@subsubsection compile_deps_msvc Dependencies for Visual C++ on Windows\n\nThe Microsoft Platform SDK that is installed along with Visual C++ already\ncontains all the necessary headers, link libraries and tools except for CMake.\nMove on to @ref compile_generate.\n\n\n@subsubsection compile_deps_mingw Dependencies for MinGW or MinGW-w64 on Windows\n\nBoth the MinGW and the MinGW-w64 packages already contain all the necessary\nheaders, link libraries and tools except for CMake.  Move on to @ref\ncompile_generate.\n\n\n@subsubsection compile_deps_mingw_cross Dependencies for MinGW or MinGW-w64 cross-compilation\n\nBoth Cygwin and many Linux distributions have MinGW or MinGW-w64 packages.  For\nexample, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages\nfor 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives\nlike Ubuntu have the `mingw-w64` package for both.\n\nGLFW has CMake toolchain files in the `CMake/` directory that allow for easy\ncross-compilation of Windows binaries.  To use these files you need to add a\nspecial parameter when generating the project files or makefiles:\n\n@code{.sh}\ncmake -DCMAKE_TOOLCHAIN_FILE=<toolchain-file> .\n@endcode\n\nThe exact toolchain file to use depends on the prefix used by the MinGW or\nMinGW-w64 binaries on your system.  You can usually see this in the /usr\ndirectory.  For example, both the Debian/Ubuntu and Cygwin MinGW-w64 packages\nhave `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct\ninvocation would be:\n\n@code{.sh}\ncmake -DCMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake .\n@endcode\n\nFor more details see the article\n[CMake Cross Compiling](http://www.paraview.org/Wiki/CMake_Cross_Compiling) on\nthe CMake wiki.\n\nOnce you have this set up, move on to @ref compile_generate.\n\n\n@subsubsection compile_deps_xcode Dependencies for Xcode on OS X\n\nXcode comes with all necessary tools except for CMake.  The required headers\nand libraries are included in the core OS X frameworks.  Xcode can be downloaded\nfrom the Mac App Store or from the ADC Member Center.\n\nOnce you have Xcode installed, move on to @ref compile_generate.\n\n\n@subsubsection compile_deps_x11 Dependencies for Linux and X11\n\nTo compile GLFW for X11, you need to have the X11 and OpenGL header packages\ninstalled, as well as the basic development tools like GCC and make.  For\nexample, on Ubuntu and other distributions based on Debian GNU/Linux, you need\nto install the `xorg-dev` and `libgl1-mesa-dev` packages.  The former pulls in\nall X.org header packages and the latter pulls in the Mesa OpenGL development\npackages.  Note that using header files and libraries from Mesa during\ncompilation _will not_ tie your binaries to the Mesa implementation of OpenGL.\n\nOnce you have installed the necessary packages, move on to @ref\ncompile_generate.\n\n\n@subsection compile_generate Generating build files with CMake\n\nOnce you have all necessary dependencies it is time to generate the project\nfiles or makefiles for your development environment.  CMake needs to know two\npaths for this: the path to the _root_ directory of the GLFW source tree (i.e.\n_not_ the `src` subdirectory) and the target path for the generated files and\ncompiled binaries.  If these are the same, it is called an in-tree build,\notherwise it is called an out-of-tree build.\n\nOne of several advantages of out-of-tree builds is that you can generate files\nand compile for different development environments using a single source tree.\n\n@note This section is about generating the project files or makefiles necessary\nto compile the GLFW library, not about compiling the actual library.\n\n\n@subsubsection compile_generate_cli Generating files with the CMake command-line tool\n\nTo make an in-tree build, enter the _root_ directory of the GLFW source tree\n(i.e. _not_ the `src` subdirectory) and run CMake.  The current directory is\nused as target path, while the path provided as an argument is used to find the\nsource tree.\n\n@code{.sh}\ncd <glfw-root-dir>\ncmake .\n@endcode\n\nTo make an out-of-tree build, make a directory outside of the source tree, enter\nit and run CMake with the (relative or absolute) path to the root of the source\ntree as an argument.\n\n@code{.sh}\nmkdir glfw-build\ncd glfw-build\ncmake <glfw-root-dir>\n@endcode\n\nOnce you have generated the project files or makefiles for your chosen\ndevelopment environment, move on to @ref compile_compile.\n\n\n@subsubsection compile_generate_gui Generating files with the CMake GUI\n\nIf you are using the GUI version, choose the root of the GLFW source tree as\nsource location and the same directory or another, empty directory as the\ndestination for binaries.  Choose _Configure_, change any options you wish to,\n_Configure_ again to let the changes take effect and then _Generate_.\n\nOnce you have generated the project files or makefiles for your chosen\ndevelopment environment, move on to @ref compile_compile.\n\n\n@subsection compile_compile Compiling the library\n\nYou should now have all required dependencies and the project files or makefiles\nnecessary to compile GLFW.  Go ahead and compile the actual GLFW library with\nthese files, as you would with any other project.\n\nOnce the GLFW library is compiled, you are ready to build your applications,\nlinking it to the GLFW library.  See the @ref build guide for more information.\n\n\n@subsection compile_options CMake options\n\nThe CMake files for GLFW provide a number of options, although not all are\navailable on all supported platforms.  Some of these are de facto standards\namong projects using CMake and so have no `GLFW_` prefix.\n\nIf you are using the GUI version of CMake, these are listed and can be changed\nfrom there.  If you are using the command-line version, use the `ccmake` tool.\nSome package systems like Ubuntu and other distributions based on Debian\nGNU/Linux have this tool in a separate `cmake-curses-gui` package.\n\n\n@subsubsection compile_options_shared Shared CMake options\n\n`BUILD_SHARED_LIBS` determines whether GLFW is built as a static\nlibrary or as a DLL / shared library / dynamic library.\n\n`LIB_SUFFIX` affects where the GLFW shared /dynamic library is installed.  If it\nis empty, it is installed to `${CMAKE_INSTALL_PREFIX}/lib`.  If it is set to\n`64`, it is installed to `${CMAKE_INSTALL_PREFIX}/lib64`.\n\n`GLFW_CLIENT_LIBRARY` determines which client API library to use.  If set to\n`opengl` the OpenGL library is used, if set to `glesv1` for the OpenGL ES 1.x\nlibrary is used, or if set to `glesv2` the OpenGL ES 2.0 library is used.  The\nselected library and its header files must be present on the system for this to\nwork.\n\n`GLFW_BUILD_EXAMPLES` determines whether the GLFW examples are built\nalong with the library.\n\n`GLFW_BUILD_TESTS` determines whether the GLFW test programs are\nbuilt along with the library.\n\n`GLFW_BUILD_DOCS` determines whether the GLFW documentation is built along with\nthe library.\n\n\n@subsubsection compile_options_osx OS X specific CMake options\n\n`GLFW_USE_CHDIR` determines whether `glfwInit` changes the current\ndirectory of bundled applications to the `Contents/Resources` directory.\n\n`GLFW_USE_MENUBAR` determines whether the first call to\n`glfwCreateWindow` sets up a minimal menu bar.\n\n`GLFW_USE_RETINA` determines whether windows will use the full resolution of\nRetina displays.\n\n`GLFW_BUILD_UNIVERSAL` determines whether to build Universal Binaries.\n\n\n@subsubsection compile_options_win32 Windows specific CMake options\n\n`USE_MSVC_RUNTIME_LIBRARY_DLL` determines whether to use the DLL version or the\nstatic library version of the Visual C++ runtime library.  If set to `ON`, the\nDLL version of the Visual C++ library is used.  It is recommended to set this to\n`ON`, as this keeps the executable smaller and benefits from security and bug\nfix updates of the Visual C++ runtime.\n\n`GLFW_USE_HYBRID_HPG` determines whether to export the `NvOptimusEnablement` and\n`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the\nhigh-performance GPU on Nvidia Optimus and AMD PowerXpress systems.  These symbols\nneed to be exported by the EXE to be detected by the driver, so the override\nwill not work if GLFW is built as a DLL.\n\n\n@subsubsection compile_options_egl EGL specific CMake options\n\n`GLFW_USE_EGL` determines whether to use EGL instead of the platform-specific\ncontext creation API.  Note that EGL is not yet provided on all supported\nplatforms.\n\n\n@section compile_manual Compiling GLFW manually\n\nIf you wish to compile GLFW without its CMake build environment then you will\nhave to do at least some of the platform detection yourself.  GLFW needs\na number of configuration macros to be defined in order to know what it's being\ncompiled for and has many optional, platform-specific ones for various features.\n\nWhen building with CMake, the `glfw_config.h` configuration header is generated\nbased on the current platform and CMake options.  The GLFW CMake environment\ndefines `_GLFW_USE_CONFIG_H`, which causes this header to be included by\n`internal.h`.  Without this macro, GLFW will expect the necessary configuration\nmacros to be defined on the command-line.\n\nThree macros _must_ be defined when compiling GLFW: one selecting the window\ncreation API, one selecting the context creation API and one client library.\nExactly one of each kind must be defined for GLFW to compile and link.\n\nThe window creation API is used to create windows, handle input, monitors, gamma\nramps and clipboard.  The options are:\n\n - `_GLFW_COCOA` to use the Cocoa frameworks\n - `_GLFW_WIN32` to use the Win32 API\n - `_GLFW_X11` to use the X Window System\n - `_GLFW_WAYLAND` to use the Wayland API (experimental and incomplete)\n - `_GLFW_MIR` to use the Mir API (experimental and incomplete)\n\nThe context creation API is used to enumerate pixel formats / framebuffer\nconfigurations and to create contexts.  The options are:\n\n - `_GLFW_NSGL` to use the Cocoa OpenGL framework\n - `_GLFW_WGL` to use the Win32 WGL API\n - `_GLFW_GLX` to use the X11 GLX API\n - `_GLFW_EGL` to use the EGL API\n\nWayland and Mir both require the EGL backend.\n\nThe client library is the one providing the OpenGL or OpenGL ES API, which is\nused by GLFW to probe the created context.  This is not the same thing as the\nclient API, as many desktop OpenGL client libraries now expose the OpenGL ES API\nthrough extensions.  The options are:\n\n - `_GLFW_USE_OPENGL` for the desktop OpenGL (opengl32.dll, libGL.so or\n   OpenGL.framework)\n - `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental)\n - `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental)\n\nNote that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL,\nas the other context creation APIs do not interface with OpenGL ES client\nlibraries.\n\nIf you are building GLFW as a shared library / dynamic library / DLL then you\nmust also define `_GLFW_BUILD_DLL`.  Otherwise, you may not define it.\n\nIf you are using the X11 window creation API, support for the following X11\nextensions can be enabled:\n\n - `_GLFW_HAS_XINPUT` to use XInput2 for high-resolution cursor motion\n (recommended)\n - `_GLFW_HAS_XF86VM` to use Xxf86vm as a fallback when RandR gamma is broken\n (recommended)\n\nIf you are using the Cocoa window creation API, the following options are\navailable:\n\n - `_GLFW_USE_CHDIR` to `chdir` to the `Resources` subdirectory of the\n   application bundle during @ref glfwInit (recommended)\n - `_GLFW_USE_MENUBAR` to create and populate the menu bar when the first window\n   is created (recommended)\n - `_GLFW_USE_RETINA` to have windows use the full resolution of Retina displays\n   (recommended)\n\n@note None of the @ref build_macros may be defined during the compilation of\nGLFW.  If you define any of these in your build files, make sure they are not\napplied to the GLFW sources.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/context.dox",
    "content": "/*!\n\n@page context Context guide\n\n@tableofcontents\n\nThis guide introduces the OpenGL and OpenGL ES context related functions of\nGLFW.  There are also guides for the other areas of the GLFW API.\n\n - @ref intro\n - @ref window\n - @ref monitor\n - @ref input\n\n\n@section context_object Context objects\n\nA window object encapsulates both a top-level window and an OpenGL or OpenGL ES\ncontext.  It is created with @ref glfwCreateWindow and destroyed with @ref\nglfwDestroyWindow or @ref glfwTerminate.  See @ref window_creation for more\ninformation.\n\nAs the window and context are inseparably linked, the window object also serves\nas the context handle.\n\nTo test the creation of various kinds of contexts and see their properties, run\nthe `glfwinfo` test program.\n\n\n@subsection context_hints Context creation hints\n\nThere are a number of hints, specified using @ref glfwWindowHint, related to\nwhat kind of context is created.  See\n[context related hints](@ref window_hints_ctx) in the window guide.\n\n\n@subsection context_sharing Context object sharing\n\nWhen creating a window and its OpenGL or OpenGL ES context with @ref\nglfwCreateWindow, you can specify another window whose context the new one\nshould share its objects (textures, vertex and element buffers, etc.) with.\n\n@code\nGLFWwindow* second_window = glfwCreateWindow(640, 480, \"Second Window\", NULL, first_window);\n@endcode\n\nObject sharing is implemented by the operating system and graphics driver.  On\nplatforms where it is possible to choose which types of objects are shared, GLFW\nrequests that all types are shared.\n\nSee the relevant chapter of the [OpenGL](https://www.opengl.org/registry/) or\n[OpenGL ES](http://www.khronos.org/opengles/) reference documents for more\ninformation.  The name and number of this chapter unfortunately varies between\nversions and APIs, but has at times been named _Shared Objects and Multiple\nContexts_.\n\nGLFW comes with a simple object sharing test program called `sharing`.\n\n\n@subsection context_offscreen Offscreen contexts\n\nGLFW doesn't support creating contexts without an associated window.  However,\ncontexts with hidden windows can be created with the\n[GLFW_VISIBLE](@ref window_hints_wnd) window hint.\n\n@code\nglfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n\nGLFWwindow* offscreen_context = glfwCreateWindow(640, 480, \"\", NULL, NULL);\n@endcode\n\nThe window never needs to be shown and its context can be used as a plain\noffscreen context.  Depending on the window manager, the size of a hidden\nwindow's framebuffer may not be usable or modifiable, so framebuffer\nobjects are recommended for rendering with such contexts.\n\n__OS X:__ The first time a window is created the menu bar is populated with\ncommon commands like Hide, Quit and About.  This is not desirable for example\nwhen writing a command-line only application.  The menu bar setup can be\ndisabled with a [compile-time option](@ref compile_options_osx).\n\n\n@section context_current Current context\n\nBefore you can make OpenGL or OpenGL ES calls, you need to have a current\ncontext of the correct type.  A context can only be current for a single thread\nat a time, and a thread can only have a single context current at a time.\n\nThe context of a window is made current with @ref glfwMakeContextCurrent.\n\n@code\nglfwMakeContextCurrent(window);\n@endcode\n\nThe window of the current context is returned by @ref glfwGetCurrentContext.\n\n@code\nGLFWwindow* window = glfwGetCurrentContext();\n@endcode\n\nThe following GLFW functions require a context to be current.  Calling any these\nfunctions without a current context will generate a @ref GLFW_NO_CURRENT_CONTEXT\nerror.\n\n - @ref glfwSwapInterval\n - @ref glfwExtensionSupported\n - @ref glfwGetProcAddress\n\n\n@section context_swap Buffer swapping\n\nBuffer swapping is part of the window and framebuffer, not the context.  See\n@ref buffer_swap.\n\n\n@section context_glext OpenGL and OpenGL ES extensions\n\nOne of the benefits of OpenGL and OpenGL ES are their extensibility.\nHardware vendors may include extensions in their implementations that extend the\nAPI before that functionality is included in a new version of the OpenGL or\nOpenGL ES specification, and some extensions are never included and remain\nas extensions until they become obsolete.\n\nAn extension is defined by:\n\n- An extension name (e.g. `GL_ARB_debug_output`)\n- New OpenGL tokens (e.g. `GL_DEBUG_SEVERITY_HIGH_ARB`)\n- New OpenGL functions (e.g. `glGetDebugMessageLogARB`)\n\nNote the `ARB` affix, which stands for Architecture Review Board and is used\nfor official extensions.  The extension above was created by the ARB, but there\nare many different affixes, like `NV` for Nvidia and `AMD` for, well, AMD.  Any\ngroup may also use the generic `EXT` affix.  Lists of extensions, together with\ntheir specifications, can be found at the\n[OpenGL Registry](http://www.opengl.org/registry/) and\n[OpenGL ES Registry](https://www.khronos.org/registry/gles/).\n\n\n@subsection context_glext_auto Loading extension with a loader library\n\nAn extension loader library is the easiest and best way to access both OpenGL and\nOpenGL ES extensions and modern versions of the core OpenGL or OpenGL ES APIs.\nThey will take care of all the details of declaring and loading everything you\nneed.  One such library is [glad](https://github.com/Dav1dde/glad) and there are\nseveral others.  \n\nThe following example will use glad but all extension loader libraries work\nsimilarly.\n\nFirst you need to generate the source files using the glad Python script.  This\nexample generates a loader for any version of OpenGL, which is the default for\nboth GLFW and glad, but loaders for OpenGL ES, as well as loaders for specific\nAPI versions and extension sets can be generated.  The generated files are\nwritten to the `output` directory.\n\n@code{.sh}\npython main.py --generator c --no-loader --out-path output\n@endcode\n\nThe `--no-loader` option is added because GLFW already provides a function for\nloading OpenGL and OpenGL ES function pointers and glad can call this instead of\nhaving to implement its own.  There are several other command-line options as\nwell.  See the glad documentation for details.\n\nAdd the generated `output/src/glad.c`, `output/include/glad/glad.h` and\n`output/include/KHR/khrplatform.h` files to your build.  Then you need to\ninclude the glad header file, which will replace the OpenGL header of your\ndevelopment environment.  By including the glad header before the GLFW header,\nit suppresses the development environment's OpenGL or OpenGL ES header.\n\n@code\n#include <glad/glad.h>\n#include <GLFW/glfw3.h>\n@endcode\n\nFinally you need to initialize glad once you have a suitable current context.\n\n@code\nwindow = glfwCreateWindow(640, 480, \"My Window\", NULL, NULL);\nif (!window)\n{\n    ...\n}\n\nglfwMakeContextCurrent(window);\n\ngladLoadGLLoader((GLADloadproc) glfwGetProcAddress);\n@endcode\n\nOnce glad has been loaded, you have access to all OpenGL core and extension\nfunctions supported by both the context you created and the glad loader you\ngenerated and you are ready to start rendering.\n\nYou can specify a minimum required OpenGL or OpenGL ES version with\n[context hints](@ref window_hints_ctx).  If your needs are more complex, you can\ncheck the actual OpenGL or OpenGL ES version with\n[context attributes](@ref window_attribs_ctx), or you can check whether\na specific version is supported by the current context with the\n`GLAD_GL_VERSION_x_x` booleans.\n\n@code\nif (GLAD_GL_VERSION_3_2)\n{\n    // Call OpenGL 3.2+ specific code\n}\n@endcode\n\nTo check whether a specific extension is supported, use the `GLAD_GL_xxx`\nbooleans.\n\n@code\nif (GLAD_GL_ARB_debug_output)\n{\n    // Use GL_ARB_debug_output\n}\n@endcode\n\n\n@subsection context_glext_manual Loading extensions manually\n\n__Do not use this technique__ unless it is absolutely necessary.  An\n[extension loader library](@ref context_glext_auto) will save you a ton of\ntedious, repetitive, error prone work.\n\nTo use a certain extension, you must first check whether the context supports\nthat extension and then, if it introduces new functions, retrieve the pointers\nto those functions.  GLFW provides @ref glfwExtensionSupported and @ref\nglfwGetProcAddress for manual loading of extensions and new API functions.\n\nThis section will demonstrate manual loading of OpenGL extensions.  The loading\nof OpenGL ES extensions is identical except for the name of the extension header.\n\n\n@subsubsection context_glext_header The glext.h header\n\nThe `glext.h` extension header is a continually updated file that defines the\ninterfaces for all OpenGL extensions.  The latest version of this can always be\nfound at the [OpenGL Registry](http://www.opengl.org/registry/).  There are also\nextension headers for the various versions of OpenGL ES at the\n[OpenGL ES Registry](https://www.khronos.org/registry/gles/).  It it strongly\nrecommended that you use your own copy of the extension header, as the one\nincluded in your development environment may be several years out of date and\nmay not include the extensions you wish to use.\n\nThe header defines function pointer types for all functions of all extensions it\nsupports.  These have names like `PFNGLGETDEBUGMESSAGELOGARBPROC` (for\n`glGetDebugMessageLogARB`), i.e. the name is made uppercase and `PFN` (pointer\nto function) and `PROC` (procedure) are added to the ends.\n\nTo include the extension header, define [GLFW_INCLUDE_GLEXT](@ref build_macros)\nbefore including the GLFW header.\n\n@code\n#define GLFW_INCLUDE_GLEXT\n#include <GLFW/glfw3.h>\n@endcode\n\n\n@subsubsection context_glext_string Checking for extensions\n\nA given machine may not actually support the extension (it may have older\ndrivers or a graphics card that lacks the necessary hardware features), so it\nis necessary to check at run-time whether the context supports the extension.\nThis is done with @ref glfwExtensionSupported.\n\n@code\nif (glfwExtensionSupported(\"GL_ARB_debug_output\"))\n{\n    // The extension is supported by the current context\n}\n@endcode\n\nThe argument is a null terminated ASCII string with the extension name.  If the\nextension is supported, @ref glfwExtensionSupported returns `GL_TRUE`, otherwise\nit returns `GL_FALSE`.\n\n\n@subsubsection context_glext_proc Fetching function pointers\n\nMany extensions, though not all, require the use of new OpenGL functions.\nThese functions often do not have entry points in the client API libraries of\nyour operating system, making it necessary to fetch them at run time.  You can\nretrieve pointers to these functions with @ref glfwGetProcAddress.\n\n@code\nPFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog = glfwGetProcAddress(\"glGetDebugMessageLogARB\");\n@endcode\n\nIn general, you should avoid giving the function pointer variables the (exact)\nsame name as the function, as this may confuse your linker.  Instead, you can\nuse a different prefix, like above, or some other naming scheme.\n\nNow that all the pieces have been introduced, here is what they might look like\nwhen used together.\n\n@code\n#define GLFW_INCLUDE_GLEXT\n#include <GLFW/glfw3.h>\n\n#define glGetDebugMessageLogARB pfnGetDebugMessageLog\nPFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog;\n\n// Flag indicating whether the extension is supported\nint has_ARB_debug_output = 0;\n\nvoid load_extensions(void)\n{\n    if (glfwExtensionSupported(\"GL_ARB_debug_output\"))\n    {\n        pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC)\n            glfwGetProcAddress(\"glGetDebugMessageLogARB\");\n        has_ARB_debug_output = 1;\n    }\n}\n\nvoid some_function(void)\n{\n    if (has_ARB_debug_output)\n    {\n        // Now the extension function can be called as usual\n        glGetDebugMessageLogARB(...);\n    }\n}\n@endcode\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/extra.css",
    "content": "#navrow1,#navrow2,#navrow3,#navrow4,.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,hr,.memSeparator{border:none}.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code{background:#f2f2f2}body{color:#4d4d4d}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:180%}h2{padding-top:0.5em;margin-bottom:0;font-size:140%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;height:64px;max-width:920px;min-width:800px;padding:0 32px;margin:0 auto}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url(\"http://www.glfw.org/css/arrow.png\") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#navrow1,#navrow2,#navrow3,#navrow4{max-width:920px;min-width:800px;margin:0 auto;font-size:13px}.tablist{height:36px;display:block;position:relative}.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a{color:#f2f2f2}.tablist li.current a{background:linear-gradient(to bottom, #ffa733 0, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;color:#fff}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:none;width:auto}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,.tablist a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe599}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e5c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e599bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce5}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px}\n"
  },
  {
    "path": "deps/glfw/docs/extra.less",
    "content": "// NOTE: Please use this file to perform modifications on default style sheets.\n//\n// You need to install a few Ruby gems to generate extra.css from this file:\n// gem install less therubyracer\n//\n// Run this command to regenerate extra.css after you're finished with changes:\n// lessc --compress extra.less > extra.css\n//\n// Alternatively you can use online services to regenerate extra.css.\n\n\n// Default text color for page contents\n@default-text-color: hsl(0,0%,30%);\n\n// Page header, footer, table rows, inline codes and definition lists\n@header-footer-background-color: hsl(0,0%,95%);\n\n// Page header, footer links and navigation bar background\n@header-footer-link-color: hsl(0,0%,40%);\n\n// Doxygen navigation bar links\n@navbar-link-color: @header-footer-background-color;\n\n// Page content background color\n@content-background-color: hsl(0,0%,100%);\n\n// Bold, italic, h1, h2, ... and table of contents\n@heading-color: hsl(0,0%,10%);\n\n// Function, enum and macro definition separator\n@def-separator-color: @header-footer-background-color;\n\n// Base color hue\n@base-hue: 24;\n\n// Default color used for links\n@default-link-color: hsl(@base-hue,100%,50%);\n\n// Doxygen navigation bar active tab\n@tab-text-color: hsl(0,0%,100%);\n@tab-background-color1: @default-link-color;\n@tab-background-color2: lighten(spin(@tab-background-color1, 10), 10%);\n\n// Table borders\n@default-border-color: @default-link-color;\n\n// Table header\n@table-text-color: @tab-text-color;\n@table-background-color1: @tab-background-color1;\n@table-background-color2: @tab-background-color2;\n\n// Table of contents, data structure index and prototypes\n@toc-background-color1: hsl(0,0%,90%);\n@toc-background-color2: lighten(@toc-background-color1, 5%);\n\n// Function prototype parameters color\n@prototype-param-color: darken(@default-link-color, 25%);\n\n// Message box color: note, pre, post and invariant\n@box-note-color: hsl(103,80%,85%);\n\n// Message box color: warning and attention\n@box-warning-color: hsl(34,80%,85%);\n\n// Message box color: deprecated and bug\n@box-bug-color: hsl(333,80%,85%);\n\n// Message box color: todo and test\n@box-todo-color: hsl(200,80%,85%);\n\n// Message box helper function\n.message-box(@base-color) {\n\tbackground:linear-gradient(to bottom,lighten(@base-color, 5%) 0%,@base-color 100%);\n\tbox-shadow:inset 0 0 32px darken(@base-color, 5%);\n\tcolor:darken(@base-color, 67%);\n\tborder:2px solid desaturate(darken(@base-color, 10%), 20%);\n}\n\n\n#navrow1,#navrow2,#navrow3,#navrow4,.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code {\n\tbackground:none;\n}\n\n#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,hr,.memSeparator {\n\tborder:none;\n}\n\n.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a,.reflist dt a.el,.levels span,.directory .levels span {\n\ttext-shadow:none;\n}\n\n.memdoc,dl.reflist dd {\n\tbox-shadow:none;\n}\n\ndiv.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code {\n\tpadding:0;\n}\n\n#nav-path,.directory .levels,span.lineno {\n\tdisplay:none;\n}\n\nhtml,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code {\n\tbackground:@header-footer-background-color;\n}\n\nbody {\n\tcolor:@default-text-color;\n}\n\nh1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em {\n\tcolor:@heading-color;\n\tborder-bottom:none;\n}\n\nh1 {\n  padding-top:0.5em;\n  font-size:180%;\n}\n\nh2 {\n  padding-top:0.5em;\n  margin-bottom:0;\n  font-size:140%;\n}\n\nh3 {\n  padding-top:0.5em;\n  margin-bottom:0;\n  font-size:110%;\n}\n\n.glfwheader {\n\tfont-size:16px;\n\theight:64px;\n\tmax-width:920px;\n\tmin-width:800px;\n\tpadding:0 32px;\n\tmargin:0 auto;\n}\n\n#glfwhome {\n\tline-height:64px;\n\tpadding-right:48px;\n\tcolor:@header-footer-link-color;\n\tfont-size:2.5em;\n\tbackground:url(\"http://www.glfw.org/css/arrow.png\") no-repeat right;\n}\n\n.glfwnavbar {\n\tlist-style-type:none;\n\tmargin:0 auto;\n\tfloat:right;\n}\n\n#glfwhome,.glfwnavbar li {\n\tfloat:left;\n}\n\n.glfwnavbar a,.glfwnavbar a:visited {\n\tline-height:64px;\n\tmargin-left:2em;\n\tdisplay:block;\n\tcolor:@header-footer-link-color;\n}\n\n#glfwhome,.glfwnavbar a,.glfwnavbar a:visited {\n\ttransition:.35s ease;\n}\n\n#titlearea,.footer {\n\tcolor:@header-footer-link-color;\n}\n\naddress.footer {\n\ttext-align:center;\n\tpadding:2em;\n\tmargin-top:3em;\n}\n\n#top {\n\tbackground:@header-footer-link-color;\n}\n\n#navrow1,#navrow2,#navrow3,#navrow4 {\n\tmax-width:920px;\n\tmin-width:800px;\n\tmargin:0 auto;\n\tfont-size:13px;\n}\n\n.tablist {\n\theight:36px;\n\tdisplay:block;\n\tposition:relative;\n}\n\n.tablist a,.tablist a:visited,.tablist a:hover,.tablist li,.tablist li.current a {\n\tcolor:@navbar-link-color;\n}\n\n.tablist li.current a {\n\tbackground:linear-gradient(to bottom,@tab-background-color2 0%,@tab-background-color1 100%);\n\tbox-shadow:inset 0 0 32px @tab-background-color1;\n\ttext-shadow:0 -1px 1px darken(@tab-background-color1, 15%);\n\tcolor:@tab-text-color;\n}\n\n.contents {\n\tmin-height:590px;\n}\n\ndiv.contents,div.header {\n\tmax-width:920px;\n\tmargin:0 auto;\n\tpadding:0 32px;\n\tbackground:@content-background-color none;\n}\n\ntable.doxtable th,dl.reflist dt {\n\tbackground:linear-gradient(to bottom,@table-background-color2 0%,@table-background-color1 100%);\n\tbox-shadow:inset 0 0 32px @table-background-color1;\n\ttext-shadow:0 -1px 1px darken(@table-background-color1, 15%);\n\tcolor:@table-text-color;\n}\n\ndl.reflist dt a.el {\n\tcolor:@default-link-color;\n\tpadding:.2em;\n\tborder-radius:4px;\n\tbackground-color:lighten(@default-link-color, 40%);\n}\n\ndiv.toc {\n\tfloat:none;\n\twidth:auto;\n}\n\ndiv.toc h3 {\n\tfont-size:1.17em;\n}\n\ndiv.toc ul {\n\tpadding-left:1.5em;\n}\n\ndiv.toc li {\n\tfont-size:1em;\n\tpadding-left:0;\n\tlist-style-type:disc;\n}\n\ndiv.toc,.memproto,div.qindex,div.ah {\n\tbackground:linear-gradient(to bottom,@toc-background-color2 0%,@toc-background-color1 100%);\n\tbox-shadow:inset 0 0 32px @toc-background-color1;\n\ttext-shadow:0 1px 1px lighten(@toc-background-color2, 10%);\n\tcolor:@heading-color;\n\tborder:2px solid @toc-background-color1;\n\tborder-radius:4px;\n}\n\n.paramname {\n\tcolor:@prototype-param-color;\n}\n\ndl.reflist dt {\n\tborder:2px solid @default-border-color;\n\tborder-top-left-radius:4px;\n\tborder-top-right-radius:4px;\n\tborder-bottom:none;\n}\n\ndl.reflist dd {\n\tborder:2px solid @default-border-color;\n\tborder-bottom-right-radius:4px;\n\tborder-bottom-left-radius:4px;\n\tborder-top:none;\n}\n\ntable.doxtable {\n\tborder-collapse:inherit;\n\tborder-spacing:0;\n\tborder:2px solid @default-border-color;\n\tborder-radius:4px;\n}\n\na,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,.tablist a:hover,span.lineno a:hover {\n\tcolor:@default-link-color;\n\ttext-decoration:none;\n}\n\ndiv.directory {\n\tborder-collapse:inherit;\n\tborder-spacing:0;\n\tborder:2px solid @default-border-color;\n\tborder-radius:4px;\n}\n\nhr,.memSeparator {\n\theight:2px;\n\tbackground:linear-gradient(to right,@def-separator-color 0%,darken(@def-separator-color, 10%) 50%,@def-separator-color 100%);\n}\n\ndl.note,dl.pre,dl.post,dl.invariant {\n\t.message-box(@box-note-color);\n}\n\ndl.warning,dl.attention {\n\t.message-box(@box-warning-color);\n}\n\ndl.deprecated,dl.bug {\n\t.message-box(@box-bug-color);\n}\n\ndl.todo,dl.test {\n\t.message-box(@box-todo-color);\n}\n\ndl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test {\n\tborder-radius:4px;\n\tpadding:1em;\n\ttext-shadow:0 1px 1px hsl(0,0%,100%);\n\tmargin:1em 0;\n}\n\n.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited {\n\tcolor:inherit;\n}\n\ndiv.line {\n\tline-height:inherit;\n}\n\ndiv.fragment,pre.fragment {\n\tbackground:hsl(0,0%,95%);\n\tborder-radius:4px;\n\tborder:none;\n\tpadding:1em;\n\toverflow:auto;\n\tborder-left:4px solid hsl(0,0%,80%);\n\tmargin:1em 0;\n}\n\n.lineno a,.lineno a:visited,.line,pre.fragment {\n\tcolor:@default-text-color;\n}\n\nspan.preprocessor,span.comment {\n\tcolor:hsl(193,100%,30%);\n}\n\na.code,a.code:visited {\n\tcolor:hsl(18,100%,45%);\n}\n\nspan.keyword,span.keywordtype,span.keywordflow {\n\tcolor:darken(@default-text-color, 5%);\n\tfont-weight:bold;\n}\n\nspan.stringliteral {\n\tcolor:hsl(261,100%,30%);\n}\n\ncode {\n\tpadding:.1em;\n\tborder-radius:4px;\n}\n"
  },
  {
    "path": "deps/glfw/docs/footer.html",
    "content": "<address class=\"footer\">\n<p>\nLast update on $date for $projectname $projectnumber\n</p>\n</address>\n</body>\n</html>\n"
  },
  {
    "path": "deps/glfw/docs/header.html",
    "content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\"/>\n<meta name=\"generator\" content=\"Doxygen $doxygenversion\"/>\n<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->\n<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->\n<link href=\"$relpath^tabs.css\" rel=\"stylesheet\" type=\"text/css\"/>\n<script type=\"text/javascript\" src=\"$relpath^jquery.js\"></script>\n<script type=\"text/javascript\" src=\"$relpath^dynsections.js\"></script>\n$treeview\n$search\n$mathjax\n<link href=\"$relpath^$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n$extrastylesheet\n</head>\n<body>\n<div id=\"top\"><!-- do not remove this div, it is closed by doxygen! -->\n\n<!--BEGIN TITLEAREA-->\n<div id=\"titlearea\">\n\t<div class=\"glfwheader\">\n\t\t<a href=\"http://www.glfw.org/\" id=\"glfwhome\">GLFW</a>\n\t\t<ul class=\"glfwnavbar\">\n\t\t\t<li><a href=\"http://www.glfw.org/documentation.html\">Documentation</a></li>\n\t\t\t<li><a href=\"http://www.glfw.org/download.html\">Download</a></li>\n\t\t\t<li><a href=\"http://www.glfw.org/media.html\">Media</a></li>\n\t\t\t<li><a href=\"http://www.glfw.org/community.html\">Community</a></li>\n\t\t</ul>\n\t</div>\n</div>\n<!--END TITLEAREA-->\n<!-- end header part -->\n"
  },
  {
    "path": "deps/glfw/docs/input.dox",
    "content": "/*!\n\n@page input Input guide\n \n@tableofcontents\n\nThis guide introduces the input related functions of GLFW.  There are also\nguides for the other areas of GLFW.\n\n - @ref intro\n - @ref window\n - @ref context\n - @ref monitor\n\nGLFW provides many kinds of input.  While some can only be polled, like time, or\nonly received via callbacks, like scrolling, there are those that provide both\ncallbacks and polling.  Where a callback is provided, that is the recommended\nway to receive that kind of input.  The more you can use callbacks the less time\nyour users' machines will need to spend polling.\n\nAll input callbacks receive a window handle.  By using the\n[window user pointer](@ref window_userptr), you can access non-global structures\nor objects from your callbacks.\n\nTo get a better feel for how the various events callbacks behave, run the\n`events` test program.  It register every callback supported by GLFW and prints\nout all arguments provided for every event, along with time and sequence\ninformation.\n\n\n@section events Event processing\n\nGLFW needs to communicate regularly with the window system both in order to\nreceive events and to show that the application hasn't locked up.  Event\nprocessing must be done regularly while you have visible windows and is normally\ndone each frame after [buffer swapping](@ref buffer_swap).\n\nThere are two functions for processing pending events.  @ref glfwPollEvents,\nprocesses only those events that have already been received and then returns\nimmediately.\n\n@code\nglfwPollEvents();\n@endcode\n\nThis is the best choice when rendering continually, like most games do.\n\nIf you only need to update the contents of the window when you receive new\ninput, @ref glfwWaitEvents is a better choice.\n\n@code\nglfwWaitEvents();\n@endcode\n\nIt puts the thread to sleep until at least one event has been received and then\nprocesses all received events.  This saves a great deal of CPU cycles and is\nuseful for, for example, editing tools.  There must be at least one GLFW window\nfor this function to sleep.\n\nIf the main thread is sleeping in @ref glfwWaitEvents, you can wake it from\nanother thread by posting an empty event to the event queue with @ref\nglfwPostEmptyEvent.\n\n@code\nglfwPostEmptyEvent();\n@endcode\n\nDo not assume that callbacks will _only_ be called through either of the above\nfunctions.  While it is necessary to process events in the event queue, some\nwindow systems will send some events directly to the application, which in turn\ncauses callbacks to be called outside of regular event processing.\n\n\n@section input_keyboard Keyboard input\n\nGLFW divides keyboard input into two categories; key events and character\nevents.  Key events relate to actual physical keyboard keys, whereas character\nevents relate to the Unicode code points generated by pressing some of them.\n\nKeys and characters do not map 1:1.  A single key press may produce several\ncharacters, and a single character may require several keys to produce.  This\nmay not be the case on your machine, but your users are likely not all using the\nsame keyboard layout, input method or even operating system as you.\n\n\n@subsection input_key Key input\n\nIf you wish to be notified when a physical key is pressed or released or when it\nrepeats, set a key callback.\n\n@code\nglfwSetKeyCallback(window, key_callback);\n@endcode\n\nThe callback function receives the [keyboard key](@ref keys), platform-specific\nscancode, key action and [modifier bits](@ref mods).\n\n@code\nvoid key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_E && action == GLFW_PRESS)\n        activate_airship();\n}\n@endcode\n\nThe action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`.  The key\nwill be `GLFW_KEY_UNKNOWN` if GLFW lacks a key token for it, for example\n_E-mail_ and _Play_ keys.\n\nThe scancode is unique for every key, regardless of whether it has a key token.\nScancodes are platform-specific but consistent over time, so keys will have\ndifferent scancodes depending on the platform but they are safe to save to disk.\n\nKey states for [named keys](@ref keys) are also saved in per-window state arrays\nthat can be polled with @ref glfwGetKey.\n\n@code\nint state = glfwGetKey(window, GLFW_KEY_E);\nif (state == GLFW_PRESS)\n    activate_airship();\n@endcode\n\nThe returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.\n\nThis function only returns cached key event state.  It does not poll the\nsystem for the current state of the key.\n\nWhenever you poll state, you risk missing the state change you are looking for.\nIf a pressed key is released again before you poll its state, you will have\nmissed the key press.  The recommended solution for this is to use a\nkey callback, but there is also the `GLFW_STICKY_KEYS` input mode.\n\n@code\nglfwSetInputMode(window, GLFW_STICKY_KEYS, 1);\n@endcode\n\nWhen sticky keys mode is enabled, the pollable state of a key will remain\n`GLFW_PRESS` until the state of that key is polled with @ref glfwGetKey.  Once\nit has been polled, if a key release event had been processed in the meantime,\nthe state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.\n\nThe `GLFW_KEY_LAST` constant holds the highest value of any\n[named key](@ref keys).\n\n\n@subsection input_char Text input\n\nGLFW supports text input in the form of a stream of\n[Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the\noperating system text input system.  Unlike key input, text input obeys keyboard\nlayouts and modifier keys and supports composing characters using\n[dead keys](https://en.wikipedia.org/wiki/Dead_key).  Once received, you can\nencode the code points into\n[UTF-8](https://en.wikipedia.org/wiki/UTF-8) or any other encoding you prefer.\n\nBecause an `unsigned int` is 32 bits long on all platforms supported by GLFW,\nyou can treat the code point argument as native endian\n[UTF-32](https://en.wikipedia.org/wiki/UTF-32).\n\nThere are two callbacks for receiving Unicode code points.  If you wish to\noffer regular text input, set a character callback.\n\n@code\nglfwSetCharCallback(window, character_callback);\n@endcode\n\nThe callback function receives Unicode code points for key events that would\nhave led to regular text input and generally behaves as a standard text field on\nthat platform.\n\n@code\nvoid character_callback(GLFWwindow* window, unsigned int codepoint)\n{\n}\n@endcode\n\nIf you wish to receive even those Unicode code points generated with modifier\nkey combinations that a plain text field would ignore, or just want to know\nexactly what modifier keys were used, set a character with modifiers callback.\n\n@code\nglfwSetCharModsCallback(window, charmods_callback);\n@endcode\n\nThe callback function receives Unicode code points and\n[modifier bits](@ref mods).\n\n@code\nvoid charmods_callback(GLFWwindow* window, unsigned int codepoint, int mods)\n{\n}\n@endcode\n\n\n@section input_mouse Mouse input\n\nMouse input comes in many forms, including cursor motion, button presses and\nscrolling offsets.  The cursor appearance can also be changed, either to\na custom image or a standard cursor shape from the system theme.\n\n\n@subsection cursor_pos Cursor position\n\nIf you wish to be notified when the cursor moves over the window, set a cursor\nposition callback.\n\n@code\nglfwSetCursorPosCallback(window, cursor_pos_callback);\n@endcode\n\nThe callback functions receives the cursor position.  On platforms that provide\nit, the full sub-pixel cursor position is passed on.\n\n@code\nstatic void cursor_position_callback(GLFWwindow* window, double xpos, double ypos)\n{\n}\n@endcode\n\nThe cursor position is also saved per-window and can be polled with @ref\nglfwGetCursorPos.\n\n@code\ndouble xpos, ypos;\nglfwGetCursorPos(window, &xpos, &ypos);\n@endcode\n\n\n@subsection cursor_mode Cursor modes\n\nThe `GLFW_CURSOR` input mode provides several cursor modes for special forms of\nmouse motion input.  By default, the cursor mode is `GLFW_CURSOR_NORMAL`,\nmeaning the regular arrow cursor (or another cursor set with @ref glfwSetCursor)\nis used and cursor motion is not limited.\n\nIf you wish to implement mouse motion based camera controls or other input\nschemes that require unlimited mouse movement, set the cursor mode to\n`GLFW_CURSOR_DISABLED`.\n\n@code\nglfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n@endcode\n\nThis will hide the cursor and lock it to the specified window.  GLFW will then\ntake care of all the details of cursor re-centering and offset calculation and\nproviding the application with a virtual cursor position.  This virtual position\nis provided normally via both the cursor position callback and through polling.\n\n@note You should not implement your own version of this functionality using\nother features of GLFW.  It is not supported and will not work as robustly as\n`GLFW_CURSOR_DISABLED`.\n\nIf you just wish the cursor to become hidden when it is over a window, set\nthe cursor mode to `GLFW_CURSOR_HIDDEN`.\n\n@code\nglfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);\n@endcode\n\nThis mode puts no limit on the motion of the cursor.\n\nTo exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL`\ncursor mode.\n\n@code\nglfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);\n@endcode\n\n\n@subsection cursor_object Cursor objects\n\nGLFW supports creating both custom and system theme cursor images, encapsulated\nas @ref GLFWcursor objects.  They are created with @ref glfwCreateCursor or @ref\nglfwCreateStandardCursor and destroyed with @ref glfwDestroyCursor, or @ref\nglfwTerminate, if any remain.\n\n\n@subsubsection cursor_custom Custom cursor creation\n\nA custom cursor is created with @ref glfwCreateCursor, which returns a handle to\nthe created cursor object.  For example, this creates a 16x16 white square\ncursor with the hot-spot in the upper-left corner:\n\n@code\nunsigned char pixels[16 * 16 * 4];\nmemset(pixels, 0xff, sizeof(pixels));\n\nGLFWimage image;\nimage.width = 16;\nimage.height = 16;\nimage.pixels = pixels;\n\nGLFWcursor* cursor = glfwCreateCursor(&image, 0, 0);\n@endcode\n\nIf cursor creation fails, `NULL` will be returned, so it is necessary to check\nthe return value.\n\nThe image data is 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits\nper channel.  The pixels are arranged canonically as sequential rows, starting\nfrom the top-left corner.\n\n\n@subsubsection cursor_standard Standard cursor creation\n\nA cursor with a [standard shape](@ref shapes) from the current system cursor\ntheme can be can be created with @ref glfwCreateStandardCursor.\n\n@code\nGLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);\n@endcode\n\nThese cursor objects behave in the exact same way as those created with @ref\nglfwCreateCursor except that the system cursor theme provides the actual image.\n\n\n@subsubsection cursor_destruction Cursor destruction\n\nWhen a cursor is no longer needed, destroy it with @ref glfwDestroyCursor.\n\n@code\nglfwDestroyCursor(cursor);\n@endcode\n\nCursor destruction always succeeds.  All cursors remaining when @ref\nglfwTerminate is called are destroyed as well.\n\n\n@subsubsection cursor_set Cursor setting\n\nA cursor can be set as current for a window with @ref glfwSetCursor.\n\n@code\nglfwSetCursor(window, cursor);\n@endcode\n\nOnce set, the cursor image will be used as long as the system cursor is over the\nclient area of the window and the [cursor mode](@ref cursor_mode) is set\nto `GLFW_CURSOR_NORMAL`.\n\nA single cursor may be set for any number of windows.\n\nTo remove a cursor from a window, set the cursor of that window to `NULL`.\n\n@code\nglfwSetCursor(window, NULL);\n@endcode\n\nWhen a cursor is destroyed, it is removed from any window where it is set.  This\ndoes not affect the cursor modes of those windows.\n\n\n@subsection cursor_enter Cursor enter/leave events\n\nIf you wish to be notified when the cursor enters or leaves the client area of\na window, set a cursor enter/leave callback.\n\n@code\nglfwSetCursorEnterCallback(window, cursor_enter_callback);\n@endcode\n\nThe callback function receives the new classification of the cursor.\n\n@code\nvoid cursor_enter_callback(GLFWwindow* window, int entered)\n{\n    if (entered)\n    {\n        // The cursor entered the client area of the window\n    }\n    else\n    {\n        // The cursor left the client area of the window\n    }\n}\n@endcode\n\n\n@subsection input_mouse_button Mouse button input\n\nIf you wish to be notified when a mouse button is pressed or released, set\na mouse button callback.\n\n@code\nglfwSetMouseButtonCallback(window, mouse_button_callback);\n@endcode\n\nThe callback function receives the [mouse button](@ref buttons), button action\nand [modifier bits](@ref mods).\n\n@code\nvoid mouse_button_callback(GLFWwindow* window, int button, int action, int mods)\n{\n    if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS)\n        popup_menu();\n}\n@endcode\n\nThe action is one of `GLFW_PRESS` or `GLFW_RELEASE`.\n\nMouse button states for [named buttons](@ref buttons) are also saved in\nper-window state arrays that can be polled with @ref glfwGetMouseButton.\n\n@code\nint state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);\nif (state == GLFW_PRESS)\n    upgrade_cow();\n@endcode\n\nThe returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`.\n\nThis function only returns cached mouse button event state.  It does not poll\nthe system for the current state of the mouse button.\n\nWhenever you poll state, you risk missing the state change you are looking for.\nIf a pressed mouse button is released again before you poll its state, you will have\nmissed the button press.  The recommended solution for this is to use a\nmouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS`\ninput mode.\n\n@code\nglfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, 1);\n@endcode\n\nWhen sticky mouse buttons mode is enabled, the pollable state of a mouse button\nwill remain `GLFW_PRESS` until the state of that button is polled with @ref\nglfwGetMouseButton.  Once it has been polled, if a mouse button release event\nhad been processed in the meantime, the state will reset to `GLFW_RELEASE`,\notherwise it will remain `GLFW_PRESS`.\n\nThe `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any\n[named button](@ref buttons).\n\n\n@subsection scrolling Scroll input\n\nIf you wish to be notified when the user scrolls, whether with a mouse wheel or\ntouchpad gesture, set a scroll callback.\n\n@code\nglfwSetScrollCallback(window, scroll_callback);\n@endcode\n\nThe callback function receives two-dimensional scroll offsets.\n\n@code\nvoid scroll_callback(GLFWwindow* window, double xoffset, double yoffset)\n{\n}\n@endcode\n\nA simple mouse wheel, being vertical, provides offsets along the Y-axis.\n\n\n@section joystick Joystick input\n\nThe joystick functions expose connected joysticks and controllers, with both\nreferred to as joysticks.  It supports up to sixteen joysticks, ranging from\n`GLFW_JOYSTICK_1`, `GLFW_JOYSTICK_2` up to `GLFW_JOYSTICK_LAST`.  You can test\nwhether a [joystick](@ref joysticks) is present with @ref glfwJoystickPresent.\n\n@code\nint present = glfwJoystickPresent(GLFW_JOYSTICK_1);\n@endcode\n\nWhen GLFW is initialized, detected joysticks are added to to the beginning of\nthe array, starting with `GLFW_JOYSTICK_1`.  Once a joystick is detected, it\nkeeps its assigned index until it is disconnected, so as joysticks are connected\nand disconnected, they will become spread out.\n\nJoystick state is updated as needed when a joystick function is called and does\nnot require a window to be created or @ref glfwPollEvents or @ref glfwWaitEvents\nto be called.\n\n\n@subsection joystick_axis Joystick axis states\n\nThe positions of all axes of a joystick are returned by @ref\nglfwGetJoystickAxes.  See the reference documentation for the lifetime of the\nreturned array.\n\n@code\nint count;\nconst float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &count);\n@endcode\n\nEach element in the returned array is a value between -1.0 and 1.0.\n\n\n@subsection joystick_button Joystick button states\n\nThe states of all buttons of a joystick are returned by @ref\nglfwGetJoystickButtons.  See the reference documentation for the lifetime of the\nreturned array.\n\n@code\nint count;\nconst unsigned char* axes = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &count);\n@endcode\n\nEach element in the returned array is either `GLFW_PRESS` or `GLFW_RELEASE`.\n\n\n@subsection joystick_name Joystick name\n\nThe human-readable, UTF-8 encoded name of a joystick is returned by @ref\nglfwGetJoystickName.  See the reference documentation for the lifetime of the\nreturned string.           \n\n@code\nconst char* name = glfwGetJoystickName(GLFW_JOYSTICK_1);\n@endcode\n\nJoystick names are not guaranteed to be unique.  Two joysticks of the same model\nand make may have the same name.  Only the [joystick token](@ref joysticks) is\nguaranteed to be unique, and only until that joystick is disconnected.\n\n\n@section time Time input\n\nGLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.\n\n@code\ndouble seconds = glfwGetTime();\n@endcode\n\nIt returns the number of seconds since the timer was started when the library\nwas initialized with @ref glfwInit.  The platform-specific time sources used\nusually have micro- or nanosecond resolution.\n\nYou can modify the reference time with @ref glfwSetTime.\n\n@code\nglfwSetTime(4.0);\n@endcode\n\nThis sets the timer to the specified time, in seconds.\n\n\n@section clipboard Clipboard input and output\n\nIf the system clipboard contains a UTF-8 encoded string or if it can be\nconverted to one, you can retrieve it with @ref glfwGetClipboardString.  See the\nreference documentation for the lifetime of the returned string.\n\n@code\nconst char* text = glfwGetClipboardString(window);\nif (text)\n    insert_text(text);\n@endcode\n\nIf the clipboard is empty or if its contents could not be converted, `NULL` is\nreturned.\n\nThe contents of the system clipboard can be set to a UTF-8 encoded string with\n@ref glfwSetClipboardString.\n\n@code\nglfwSetClipboardString(window, \"A string with words in it\");\n@endcode\n\nThe clipboard functions take a window handle argument because some window\nsystems require a window to communicate with the system clipboard.  Any valid\nwindow may be used.\n\n\n@section path_drop Path drop input\n\nIf you wish to receive the paths of files and/or directories dropped on\na window, set a file drop callback.\n\n@code\nglfwSetDropCallback(window, drop_callback);\n@endcode\n\nThe callback function receives an array of paths encoded as UTF-8.\n\n@code\nvoid drop_callback(GLFWwindow* window, int count, const char** paths)\n{\n    int i;\n    for (i = 0;  i < count;  i++)\n        handle_dropped_file(paths[i]);\n}\n@endcode\n\nThe path array and its strings are only valid until the file drop callback\nreturns, as they may have been generated specifically for that event.  You need\nto make a deep copy of the array if you want to keep the paths.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/internal.dox",
    "content": "/*!\n\n@page internals Internal structure\n\n@tableofcontents\n\nThere are several interfaces inside GLFW.  Each interface has its own area of\nresponsibility and its own naming conventions.\n\n\n@section internals_public Public interface\n\nThe most well-known is the public interface, described in the glfw3.h header\nfile.  This is implemented in source files shared by all platforms and these\nfiles contain no platform-specific code.  This code usually ends up calling the\nplatform and internal interfaces to do the actual work.\n\nThe public interface uses the OpenGL naming conventions except with GLFW and\nglfw instead of GL and gl.  For struct members, where OpenGL sets no precedent,\nit use headless camel case.\n\nExamples: @ref glfwCreateWindow, @ref GLFWwindow, @ref GLFWvidmode.redBits,\n`GLFW_RED_BITS`\n\n\n@section internals_native Native interface\n\nThe [native interface](@ref native) is a small set of publicly available\nbut platform-specific functions, described in the glfw3native.h header file and\nused to gain access to the underlying window, context and (on some platforms)\ndisplay handles used by the platform interface.\n\nThe function names of the native interface are similar to those of the public\ninterface, but embeds the name of the interface that the returned handle is\nfrom.\n\nExamples: @ref glfwGetX11Window, @ref glfwGetWGLContext\n\n\n@section internals_internal Internal interface\n\nThe internal interface consists of utility functions used by all other\ninterfaces.  It is shared code implemented in the same shared source files as\nthe public and event interfaces.  The internal interface is described in the\ninternal.h header file.\n\nThe internal interface is in charge of GLFW's global data, which it stores in\na `_GLFWlibrary` struct named `_glfw`.\n\nThe internal interface uses the same style as the public interface, except all\nglobal names have a leading underscore.\n\nExamples: @ref _glfwIsValidContextConfig, @ref _GLFWwindow, `_glfw.currentRamp`\n\n\n@section internals_platform Platform interface\n\nThe platform interface implements all platform-specific operations as a service\nto the public interface.  This includes event processing.  The platform\ninterface is never directly called by application code and never directly calls\napplication-provided callbacks.  It is also prohibited from modifying the\nplatform-independent part of the internal structs.  Instead, it calls the event\ninterface when events interesting to GLFW are received.\n\nThe platform interface mirrors those parts of the public interface that needs to\nperform platform-specific operations on some or all platforms.  The are also\nnamed the same except that the glfw function prefix is replaced by\n_glfwPlatform.\n\nExamples: @ref _glfwPlatformCreateWindow\n\nThe platform interface also defines structs that contain platform-specific\nglobal and per-object state.  Their names mirror those of the internal\ninterface, except that an interface-specific suffix is added.\n\nExamples: `_GLFWwindowX11`, `_GLFWcontextWGL`\n\nThese structs are incorporated as members into the internal interface structs\nusing special macros that name them after the specific interface used.  This\nprevents shared code from accidentally using these members.\n\nExamples: `window.win32.handle`, `_glfw.x11.display`\n\n\n@section internals_event Event interface\n\nThe event interface is implemented in the same shared source files as the public\ninterface and is responsible for delivering the events it receives to the\napplication, either via callbacks, via window state changes or both.\n\nThe function names of the event interface use a `_glfwInput` prefix and the\nObjectEvent pattern.\n\nExamples: @ref _glfwInputWindowFocus, @ref _glfwInputCursorMotion\n\n\n@section internals_static Static functions\n\nStatic functions may be used by any interface and have no prefixes or suffixes.\nThese use headless camel case.\n\nExamples: `clearScrollOffsets`\n\n\n@section internals_config Configuration macros\n\nGLFW uses a number of configuration macros to select at compile time which\ninterfaces and code paths to use.  They are defined in the glfw_config.h header file,\nwhich is generated from the `glfw_config.h.in` file by CMake.\n\nConfiguration macros the same style as tokens in the public interface, except\nwith a leading underscore.\n\nExamples: `_GLFW_HAS_GLXGETPROCADDRESS` \n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/intro.dox",
    "content": "/*! \n\n@page intro Introduction to the API\n \n@tableofcontents\n\nThis guide introduces the basic concepts of GLFW and describes initialization,\nerror handling and API guarantees and limitations.  For a broad but shallow\ntutorial, see @ref quick instead.  There are also guides for the other areas of\nGLFW.\n\n - @ref window\n - @ref context\n - @ref monitor\n - @ref input\n\n\n@section intro_init Initialization and termination\n\nBefore most GLFW functions may be called, the library must be initialized.\nThis initialization checks what features are available on the machine,\nenumerates monitors and joysticks, initializes the timer and performs any\nrequired platform-specific initialization.\n\nOnly the following functions may be called before the library has been\nsuccessfully initialized, and only from the main thread.\n\n - @ref glfwGetVersion\n - @ref glfwGetVersionString\n - @ref glfwSetErrorCallback\n - @ref glfwInit\n - @ref glfwTerminate\n\nCalling any other function before that time will cause a @ref\nGLFW_NOT_INITIALIZED error. \n\n\n@subsection intro_init_init Initializing GLFW\n\nThe library is initialized with @ref glfwInit, which returns `GL_FALSE` if an\nerror occurred.\n\n@code\nif (!glfwInit())\n{\n    // Handle initialization failure\n}\n@endcode\n\nIf any part of initialization fails, all remaining bits are terminated as if\n@ref glfwTerminate was called.  The library only needs to be initialized once\nand additional calls to an already initialized library will simply return\n`GL_TRUE` immediately.\n\nOnce the library has been successfully initialized, it should be terminated\nbefore the application exits.\n\n\n@subsection intro_init_terminate Terminating GLFW\n\nBefore your application exits, you should terminate the GLFW library if it has\nbeen initialized.  This is done with @ref glfwTerminate.\n\n@code\nglfwTerminate();\n@endcode\n\nThis will destroy any remaining window, monitor and cursor objects, restore any\nmodified gamma ramps, re-enable the screensaver if it had been disabled and free\nany resources allocated by GLFW.\n\nOnce the library is terminated, it is as if it had never been initialized and\nyou will need to initialize it again before being able to use GLFW.  If the\nlibrary was not initialized or had already been terminated, it return\nimmediately. \n\n\n@section error_handling Error handling\n\nSome GLFW functions have return values that indicate an error, but this is often\nnot very helpful when trying to figure out _why_ the error occurred.  Some\nfunctions also return otherwise valid values on error.  Finally, far from all\nGLFW functions have return values.\n\nThis is where the error callback comes in.  This callback is called whenever an\nerror occurs.  It is set with @ref glfwSetErrorCallback, a function that may be\ncalled regardless of whether GLFW is initialized.\n\n@code\nglfwSetErrorCallback(error_callback);\n@endcode\n\nThe error callback receives a human-readable description of the error and (when\npossible) its cause.  The description encoded as UTF-8.  The callback is also\nprovided with an [error code](@ref errors). \n\n@code\nvoid error_callback(int error, const char* description)\n{\n    puts(description);\n}\n@endcode\n\nThe error code indicates the general category of the error.  Some error codes,\nsuch as @ref GLFW_NOT_INITIALIZED has only a single meaning, whereas others like\n@ref GLFW_PLATFORM_ERROR are used for many different errors.\n\nThe description string is only valid until the error callback returns, as it may\nhave been generated specifically for that error.  This lets GLFW provide much\nmore specific error descriptions but means you must make a copy if you want to\nkeep the description string.\n\n@note Relying on erroneous behavior is not forward compatible.  In other words,\ndo not rely on a currently invalid call to generate a specific error, as that\nsame call may in future versions generate a different error or become valid.\n\n\n@section coordinate_systems Coordinate systems\n\nGLFW has two primary coordinate systems: the _virtual screen_ and the window\n_client area_ or _content area_.  Both use the same unit: _virtual screen\ncoordinates_, or just _screen coordinates_, which don't necessarily correspond\nto pixels.\n\n<img src=\"spaces.svg\" width=\"90%\" />\n\nBoth the virtual screen and the client area coordinate systems have the X-axis\npointing to the right and the Y-axis pointing down.\n\nWindow and monitor positions are specified as the position of the upper-left\ncorners of their content areas relative to the virtual screen, while cursor\npositions are specified relative to a window's client area.\n\nBecause the origin of the window's client area coordinate system is also the\npoint from which the window position is specified, you can translate client area\ncoordinates to the virtual screen by adding the window position.  The window\nframe, when present, extends out from the client area but does not affect the\nwindow position.\n\nAlmost all positions and sizes in GLFW are measured in screen coordinates\nrelative to one of the two origins above.  This includes cursor positions,\nwindow positions and sizes, window frame sizes, monitor positions and video mode\nresolutions.\n\nTwo exceptions are the [monitor physical size](@ref monitor_size), which is\nmeasured in millimetres, and [framebuffer size](@ref window_fbsize), which is\nmeasured in pixels.\n\nPixels and screen coordinates may map 1:1 on your machine, but they won't on\nevery other machine, for example on a Mac with a Retina display.  The ratio\nbetween screen coordinates and pixels may also change at run-time depending on\nwhich monitor the window is currently considered to be on.\n\n\n@section guarantees_limitations Guarantees and limitations\n\nThis section describes the conditions under which GLFW can be expected to\nfunction, barring bugs in the operating system or drivers.  Use of GLFW outside\nof these limits may work on some platforms, or on some machines, or some of the\ntime, or on some versions of GLFW, but it may break at any time and this will\nnot be considered a bug.\n\n\n@subsection lifetime Pointer lifetimes\n\nGLFW will never free any pointer you provide to it and you must never free any\npointer it provides to you.\n\nMany GLFW functions return pointers to dynamically allocated structures, strings\nor arrays, and some callbacks are provided with strings or arrays.  These are\nalways managed by GLFW and should never be freed by the application.  The\nlifetime of these pointers is documented for each GLFW function and callback.\nIf you need to keep this data, you must copy it before its lifetime expires.\n\nMany GLFW functions accept pointers to structures or strings allocated by the\napplication.  These are never freed by GLFW and are always the responsibility of\nthe application.  If GLFW needs to keep the data in these structures or strings,\nit is copied before the function returns.\n\nPointer lifetimes are guaranteed not to be shortened in future minor or patch\nreleases.\n\n\n@subsection reentrancy Reentrancy\n\nGLFW event processing and object creation and destruction are not reentrant.\nThis means that the following functions may not be called from any callback\nfunction:\n\n - @ref glfwCreateWindow\n - @ref glfwDestroyWindow\n - @ref glfwCreateCursor\n - @ref glfwCreateStandardCursor\n - @ref glfwDestroyCursor\n - @ref glfwPollEvents\n - @ref glfwWaitEvents\n - @ref glfwTerminate\n\nThese functions may be made reentrant in future minor or patch releases, but\nfunctions not on this list will not be made non-reentrant.\n\n\n@subsection thread_safety Thread safety\n\nMost GLFW functions may only be called from the main thread, but some may be\ncalled from any thread.  However, no GLFW function may be called from any other\nthread until GLFW has been successfully initialized on the main thread,\nincluding functions that may called before initialization.\n\nThe reference documentation for every GLFW function states whether it is limited\nto the main thread.                                                        \n\nInitialization and termination, event processing and the creation and\ndestruction of windows, contexts and cursors are all limited to the main thread\ndue to limitations of one or several platforms.\n\nBecause event processing must be performed on the main thread, all callbacks\nexcept for the error callback will only be called on that thread.  The error\ncallback may be called on any thread, as any GLFW function may generate errors.\n\nThe posting of empty events may be done from any thread.  The window user\npointer and close flag may also be accessed and modified from any thread, but\nthis is not synchronized by GLFW.  The following window related functions may\nbe called from any thread:\n\n - @ref glfwPostEmptyEvent\n - @ref glfwGetWindowUserPointer\n - @ref glfwSetWindowUserPointer\n - @ref glfwWindowShouldClose\n - @ref glfwSetWindowShouldClose\n\nRendering may be done on any thread.  The following context related functions\nmay be called from any thread:\n\n - @ref glfwMakeContextCurrent\n - @ref glfwGetCurrentContext\n - @ref glfwSwapBuffers\n - @ref glfwSwapInterval\n - @ref glfwExtensionSupported\n - @ref glfwGetProcAddress\n\nThe timer may be accessed from any thread, but this is not synchronized by GLFW.\nThe following timer related functions may be called from any thread:        \n\n - @ref glfwGetTime\n\nLibrary version information may be queried from any thread.  The following\nversion related functions may be called from any thread:\n\n - @ref glfwGetVersion\n - @ref glfwGetVersionString\n\nGLFW uses no synchronization objects internally except for thread-local storage\nto keep track of the current context for each thread.  Synchronization is left\nto the application.\n\nFunctions that may currently be called from any thread will always remain so,\nbut functions that are currently limited to the main may be updated to allow\ncalls from any thread in future releases.\n\n\n@subsection compatibility Version compatibility\n\nGLFW guarantees binary backward compatibility with earlier minor versions of the\nAPI.  This means that you can drop in a newer version of the GLFW DLL / shared\nlibrary / dynamic library and existing applications will continue to run.\n\nOnce a function or constant has been added, the signature of that function or\nvalue of that constant will remain unchanged until the next major version of\nGLFW.  No compatibility of any kind is guaranteed between major versions.\n\nUndocumented behavior, i.e. behavior that is not described in the documentation,\nmay change at any time until it is documented.\n\nIf the reference documentation and the implementation differ, the reference\ndocumentation is correct and the implementation will be fixed in the next\nrelease.\n\n\n@subsection event_order Event order\n\nThe order of arrival of related events is not guaranteed to be consistent\nacross platforms.  The exception is synthetic key and mouse button release\nevents, which are always delivered after the window defocus event.\n\n\n@section intro_version Version management\n\nGLFW provides mechanisms for identifying what version of GLFW your application\nwas compiled against as well as what version it is currently running against.\nIf you are loading GLFW dynamically (not just linking dynamically), you can use\nthis to verify that the library binary is compatible with your application.\n\n\n@subsection intro_version_compile Compile-time version\n\nThe compile-time version of GLFW is provided by the GLFW header with the\n`GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros.\n\n@code\nprintf(\"Compiled against GLFW %i.%i.%i\\n\",\n       GLFW_VERSION_MAJOR,\n       GLFW_VERSION_MINOR,\n       GLFW_VERSION_REVISION);\n@endcode\n\n\n@subsection intro_version_runtime Run-time version\n\nThe run-time version can be retrieved with @ref glfwGetVersion, a function that\nmay be called regardless of whether GLFW is initialized.\n\n@code\nint major, minor, revision;\nglfwGetVersion(&major, &minor, &revision);\n\nprintf(\"Running against GLFW %i.%i.%i\\n\", major, minor, revision);\n@endcode\n\n\n@subsection intro_version_string Version string\n\nGLFW 3 also provides a compile-time generated version string that describes the\nversion, platform, compiler and any platform-specific compile-time options.\nThis is primarily intended for submitting bug reports, to allow developers to\nsee which code paths are enabled in a binary.\n\nThe version string is returned by @ref glfwGetVersionString, a function that may\nbe called regardless of whether GLFW is initialized.\n\n__Do not use the version string__ to parse the GLFW library version.  The @ref\nglfwGetVersion function already provides the version of the running library\nbinary.\n\nThe format of the string is as follows:\n - The version of GLFW\n - The name of the window system API\n - The name of the context creation API\n - Any additional options or APIs\n\nFor example, when compiling GLFW 3.0 with MinGW using the Win32 and WGL\nback ends, the version string may look something like this:\n\n@code\n3.0.0 Win32 WGL MinGW\n@endcode\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/main.dox",
    "content": "/*!\n\n@mainpage notitle\n\n@section main_intro Introduction\n\n__GLFW__ is a free, Open Source, multi-platform library for creating windows\nwith OpenGL or OpenGL ES contexts and receiving many kinds of input.  It is easy\nto integrate into existing applications and does not lay claim to the main loop.\n\nSee @ref news_31 for release highlights or the\n[version history](http://www.glfw.org/changelog.html) for details.\n\n@ref quick is a guide for those new to GLFW.  It takes you through how to write\na small but complete program.  For people coming from GLFW 2, the @ref moving\nguide explains what has changed and how to update existing code to use the new\nAPI.\n\nThere are guides for each of the various areas of the API.\n\n - @ref intro – initialization, error handling and high-level design\n - @ref window – creating and working with windows and framebuffers\n - @ref context – working with OpenGL and OpenGL ES contexts\n - @ref monitor – enumerating and working with monitors and video modes\n - @ref input – receiving events, polling and processing input\n\nOnce you have written a program, see the @ref compile and @ref build guides.        \n\nThe [reference documentation](modules.html) provides more detailed information\nabout specific functions.\n\nThere is a section on @ref guarantees_limitations for pointer lifetimes,\nreentrancy, thread safety, event order and backward and forward compatibility.\n\nThe @ref rift fills in the gaps for how to use LibOVR with GLFW.\n\nThe [FAQ](http://www.glfw.org/faq.html) answers many common questions about the\ndesign, implementation and use of GLFW.\n\nFinally, the @ref compat guide explains what APIs, standards and protocols GLFW\nuses and what happens when they are not present on a given machine.\n\nThis documentation was generated with Doxygen.  The sources for it are available\nin both the [source distribution](http://www.glfw.org/download.html) and\n[GitHub repository](https://github.com/glfw/glfw).\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/monitor.dox",
    "content": "/*!\n\n@page monitor Monitor guide\n\n@tableofcontents\n\nThis guide introduces the monitor related functions of GLFW.  There are also\nguides for the other areas of GLFW.\n\n - @ref intro\n - @ref window\n - @ref context\n - @ref input\n\n\n@section monitor_object Monitor objects\n\nA monitor object represents a currently connected monitor and is represented as\na pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type\n@ref GLFWmonitor.  Monitor objects cannot be created or destroyed by the\napplication and retain their addresses until the monitors they represent are\ndisconnected or until the library is [terminated](@ref intro_init_terminate).\n\nEach monitor has a current video mode, a list of supported video modes,\na virtual position, a human-readable name, an estimated physical size and\na gamma ramp.  One of the monitors is the primary monitor.\n\nThe virtual position of a monitor is in\n[screen coordinates](@ref coordinate_systems) and, together with the current\nvideo mode, describes the viewports that the connected monitors provide into the\nvirtual desktop that spans them.\n\nTo see how GLFW views your monitor setup and its available video modes, run the\n`monitors` test program.\n\n\n@subsection monitor_monitors Retrieving monitors\n\nThe primary monitor is returned by @ref glfwGetPrimaryMonitor.  It is the user's\npreferred monitor and is usually the one with global UI elements like task bar\nor menu bar.\n\n@code\nGLFWmonitor* primary = glfwGetPrimaryMonitor();\n@endcode\n\nYou can retrieve all currently connected monitors with @ref glfwGetMonitors.\nSee the reference documentation for the lifetime of the returned array.\n\n@code\nint count;\nGLFWmonitor** monitors = glfwGetMonitors(&count);\n@endcode\n\nThe primary monitor is always the first monitor in the returned array, but other\nmonitors may be moved to a different index when a monitor is connected or\ndisconnected.\n\n\n@subsection monitor_event Monitor configuration changes\n\nIf you wish to be notified when a monitor is connected or disconnected, set\na monitor callback.\n\n@code\nglfwSetMonitorCallback(monitor_callback);\n@endcode\n\nThe callback function receives the handle for the monitor that has been\nconnected or disconnected and a monitor action.\n\n@code\nvoid monitor_callback(GLFWmonitor* monitor, int event)\n{\n}\n@endcode\n\nThe action is one of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.\n\n\n@section monitor_properties Monitor properties\n\nEach monitor has a current video mode, a list of supported video modes,\na virtual position, a human-readable name, an estimated physical size and\na gamma ramp.\n\n\n@subsection monitor_modes Video modes\n\nGLFW generally does a good job selecting a suitable video mode when you create\na full screen window, but it is sometimes useful to know exactly which video\nmodes are supported.\n\nVideo modes are represented as @ref GLFWvidmode structures.  You can get an\narray of the video modes supported by a monitor with @ref glfwGetVideoModes.\nSee the reference documentation for the lifetime of the returned array.\n\n@code\nint count;\nGLFWvidmode* modes = glfwGetVideoModes(monitor, &count);\n@endcode\n\nTo get the current video mode of a monitor call @ref glfwGetVideoMode.  See the\nreference documentation for the lifetime of the returned pointer.\n\n@code\nconst GLFWvidmode* mode = glfwGetVideoMode(monitor);\n@endcode\n\nThe resolution of a video mode is specified in\n[screen coordinates](@ref coordinate_systems), not pixels.\n\n\n@subsection monitor_size Physical size\n\nThe physical size of a monitor in millimetres, or an estimation of it, can be\nretrieved with @ref glfwGetMonitorPhysicalSize.  This has no relation to its\ncurrent _resolution_, i.e. the width and height of its current\n[video mode](@ref monitor_modes).\n\n@code\nint widthMM, heightMM;\nglfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);\n@endcode\n\nThis can, for example, be used together with the current video mode to calculate\nthe DPI of a monitor. \n\n@code\nconst double dpi = mode->width / (widthMM / 25.4);\n@endcode\n\n\n@subsection monitor_pos Virtual position\n\nThe position of the monitor on the virtual desktop, in\n[screen coordinates](@ref coordinate_systems), can be retrieved with @ref\nglfwGetMonitorPos.\n\n@code\nint xpos, ypos;\nglfwGetMonitorPos(monitor, &xpos, &ypos);\n@endcode\n\n\n@subsection monitor_name Human-readable name\n\nThe human-readable, UTF-8 encoded name of a monitor is returned by @ref\nglfwGetMonitorName.  See the reference documentation for the lifetime of the\nreturned string.\n\n@code\nconst char* name = glfwGetMonitorName(monitor);\n@endcode\n\nMonitor names are not guaranteed to be unique.  Two monitors of the same model\nand make may have the same name.  Only the monitor handle is guaranteed to be\nunique, and only until that monitor is disconnected.\n\n\n@subsection monitor_gamma Gamma ramp\n\nThe gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts\na monitor handle and a pointer to a @ref GLFWgammaramp structure.\n\n@code\nGLFWgammaramp ramp;\nunsigned short red[256], green[256], blue[256];\n\nramp.size = 256;\nramp.red = red;\nramp.green = green;\nramp.blue = blue;\n\nfor (i = 0;  i < ramp.size;  i++)\n{\n    // Fill out gamma ramp arrays as desired\n}\n\nglfwSetGammaRamp(monitor, &ramp);\n@endcode\n\nThe gamma ramp data is copied before the function returns, so there is no need\nto keep it around once the ramp has been set.\n\n@note It is recommended to use gamma ramps of size 256, as that is the size\nsupported by all graphics cards on all platforms.\n\nThe current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp.  See\nthe reference documentation for the lifetime of the returned structure.\n\n@code\nconst GLFWgammaramp* ramp = glfwGetGammaRamp(monitor);\n@endcode\n\nIf you wish to set a regular gamma ramp, you can have GLFW calculate it for you\nfrom the desired exponent with @ref glfwSetGamma, which in turn calls @ref\nglfwSetGammaRamp with the resulting ramp.\n\n@code\nglfwSetGamma(monitor, 1.0);\n@endcode\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/moving.dox",
    "content": "/*!\n\n@page moving Moving from GLFW 2 to 3\n\n@tableofcontents\n\nThis is a transition guide for moving from GLFW 2 to 3.  It describes what has\nchanged or been removed, but does _not_ include\n[new features](@ref news) unless they are required when moving an existing code\nbase onto the new API.  For example, the new multi-monitor functions are\nrequired to create full screen windows with GLFW 3.\n\n\n@section moving_removed Changed and removed features\n\n@subsection moving_renamed_files Renamed library and header file\n\nThe GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to\navoid collisions with the headers of other major versions.  Similarly, the GLFW\n3 library is named `glfw3,` except when it's installed as a shared library on\nUnix-like systems, where it uses the\n[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`.\n\n@par Old syntax\n@code\n#include <GL/glfw.h>\n@endcode\n\n@par New syntax\n@code\n#include <GLFW/glfw3.h>\n@endcode\n\n\n@subsection moving_threads Removal of threading functions\n\nThe threading functions have been removed, including the per-thread sleep\nfunction.  They were fairly primitive, under-used, poorly integrated and took\ntime away from the focus of GLFW (i.e.  context, input and window).  There are\nbetter threading libraries available and native threading support is available\nin both [C++11](http://en.cppreference.com/w/cpp/thread) and\n[C11](http://en.cppreference.com/w/c/thread), both of which are gaining\ntraction. \n\nIf you wish to use the C++11 or C11 facilities but your compiler doesn't yet\nsupport them, see the\n[TinyThread++](https://gitorious.org/tinythread/tinythreadpp) and\n[TinyCThread](https://github.com/tinycthread/tinycthread) projects created by\nthe original author of GLFW.  These libraries implement a usable subset of the\nthreading APIs in C++11 and C11, and in fact some GLFW 3 test programs use\nTinyCThread.\n\nHowever, GLFW 3 has better support for _use from multiple threads_ than GLFW\n2 had.  Contexts can be made current on any thread, although only a single\nthread at a time, and the documentation explicitly states which functions may be\nused from any thread and which may only be used from the main thread.\n\n@par Removed functions\n`glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`,\n`glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`,\n`glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`,\n`glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`.\n\n\n@subsection moving_image Removal of image and texture loading\n\nThe image and texture loading functions have been removed.  They only supported\nthe Targa image format, making them mostly useful for beginner level examples.\nTo become of sufficiently high quality to warrant keeping them in GLFW 3, they\nwould need not only to support other formats, but also modern extensions to\nOpenGL texturing.  This would either add a number of external\ndependencies (libjpeg, libpng, etc.), or force GLFW to ship with inline versions\nof these libraries. \n\nAs there already are libraries doing this, it is unnecessary both to duplicate\nthe work and to tie the duplicate to GLFW.  The resulting library would also be\nplatform-independent, as both OpenGL and stdio are available wherever GLFW is.\n\n@par Removed functions\n`glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`,\n`glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`.\n\n\n@subsection moving_stdcall Removal of GLFWCALL macro\n\nThe `GLFWCALL` macro, which made callback functions use\n[__stdcall](http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows,\nhas been removed.  GLFW is written in C, not Pascal.  Removing this macro means\nthere's one less thing for application programmers to remember, i.e. the\nrequirement to mark all callback functions with `GLFWCALL`.  It also simplifies\nthe creation of DLLs and DLL link libraries, as there's no need to explicitly\ndisable `@n` entry point suffixes. \n\n@par Old syntax\n@code\nvoid GLFWCALL callback_function(...);\n@endcode\n\n@par New syntax\n@code\nvoid callback_function(...);\n@endcode\n\n\n@subsection moving_window_handles Window handle parameters\n\nBecause GLFW 3 supports multiple windows, window handle parameters have been\nadded to all window-related GLFW functions and callbacks.  The handle of\na newly created window is returned by @ref glfwCreateWindow (formerly\n`glfwOpenWindow`).  Window handles are pointers to the\n[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow.\n\n@par Old syntax\n@code\nglfwSetWindowTitle(\"New Window Title\");\n@endcode\n\n@par New syntax\n@code\nglfwSetWindowTitle(window, \"New Window Title\");\n@endcode\n\n\n@subsection moving_monitor Explicit monitor selection\n\nGLFW 3 provides support for multiple monitors.  To request a full screen mode window,\ninstead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the\nwindow to use.  The @ref glfwGetPrimaryMonitor function returns the monitor that\nGLFW 2 would have selected, but there are many other\n[monitor functions](@ref monitor).  Monitor handles are pointers to the\n[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor.\n\n@par Old basic full screen\n@code\nglfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN);\n@endcode\n\n@par New basic full screen\n@code\nwindow = glfwCreateWindow(640, 480, \"My Window\", glfwGetPrimaryMonitor(), NULL);\n@endcode\n\n@note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned\ninto [window hints](@ref window_hints), but as they have been given\n[sane defaults](@ref window_hints_values) you rarely need to set these hints.\n\n\n@subsection moving_autopoll Removal of automatic event polling\n\nGLFW 3 does not automatically poll for events in @ref glfwSwapBuffers, meaning\nyou need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself.  Unlike\nbuffer swap, which acts on a single window, the event processing functions act\non all windows at once.\n\n@par Old basic main loop\n@code\nwhile (...)\n{\n    // Process input\n    // Render output\n    glfwSwapBuffers();\n}\n@endcode\n\n@par New basic main loop\n@code\nwhile (...)\n{\n    // Process input\n    // Render output\n    glfwSwapBuffers(window);\n    glfwPollEvents();\n}\n@endcode\n\n\n@subsection moving_context Explicit context management\n\nEach GLFW 3 window has its own OpenGL context and only you, the application\nprogrammer, can know which context should be current on which thread at any\ngiven time.  Therefore, GLFW 3 leaves that decision to you.\n\nThis means that you need to call @ref glfwMakeContextCurrent after creating\na window before you can call any OpenGL functions.\n\n\n@subsection moving_hidpi Separation of window and framebuffer sizes\n\nWindow positions and sizes now use screen coordinates, which may not be the same\nas pixels on machines with high-DPI monitors.  This is important as OpenGL uses\npixels, not screen coordinates.  For example, the rectangle specified with\n`glViewport` needs to use pixels.  Therefore, framebuffer size functions have\nbeen added.  You can retrieve the size of the framebuffer of a window with @ref\nglfwGetFramebufferSize function.  A framebuffer size callback has also been\nadded, which can be set with @ref glfwSetFramebufferSizeCallback.\n\n@par Old basic viewport setup\n@code\nglfwGetWindowSize(&width, &height);\nglViewport(0, 0, width, height);\n@endcode\n\n@par New basic viewport setup\n@code\nglfwGetFramebufferSize(window, &width, &height);\nglViewport(0, 0, width, height);\n@endcode\n\n\n@subsection moving_window_close Window closing changes\n\nThe `GLFW_OPENED` window parameter has been removed.  As long as the window has\nnot been destroyed, whether through @ref glfwDestroyWindow or @ref\nglfwTerminate, the window is \"open\".\n\nA user attempting to close a window is now just an event like any other.  Unlike\nGLFW 2, windows and contexts created with GLFW 3 will never be destroyed unless\nyou choose them to be.  Each window now has a close flag that is set to\n`GL_TRUE` when the user attempts to close that window.  By default, nothing else\nhappens and the window stays visible.  It is then up to you to either destroy\nthe window, take some other action or simply ignore the request.\n\nYou can query the close flag at any time with @ref glfwWindowShouldClose and set\nit at any time with @ref glfwSetWindowShouldClose.\n\n@par Old basic main loop\n@code\nwhile (glfwGetWindowParam(GLFW_OPENED))\n{\n    ...\n}\n@endcode\n\n@par New basic main loop\n@code\nwhile (!glfwWindowShouldClose(window))\n{\n    ...\n}\n@endcode\n\nThe close callback no longer returns a value.  Instead, it is called after the\nclose flag has been set so it can override its value, if it chooses to, before\nevent processing completes.  You may however not call @ref glfwDestroyWindow\nfrom the close callback (or any other window related callback).\n\n@par Old syntax\n@code\nint GLFWCALL window_close_callback(void);\n@endcode\n\n@par New syntax\n@code\nvoid window_close_callback(GLFWwindow* window);\n@endcode\n\n@note GLFW never clears the close flag to `GL_FALSE`, meaning you can use it\nfor other reasons to close the window as well, for example the user choosing\nQuit from an in-game menu.\n\n\n@subsection moving_hints Persistent window hints\n\nThe `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint.\n\nWindow hints are no longer reset to their default values on window creation, but\ninstead retain their values until modified by @ref glfwWindowHint or @ref\nglfwDefaultWindowHints, or until the library is terminated and re-initialized.\n\n\n@subsection moving_video_modes Video mode enumeration\n\nVideo mode enumeration is now per-monitor.  The @ref glfwGetVideoModes function\nnow returns all available modes for a specific monitor instead of requiring you\nto guess how large an array you need.  The `glfwGetDesktopMode` function, which\nhad poorly defined behavior, has been replaced by @ref glfwGetVideoMode, which\nreturns the current mode of a monitor.\n\n\n@subsection moving_char_up Removal of character actions\n\nThe action parameter of the [character callback](@ref GLFWcharfun) has been\nremoved.  This was an artefact of the origin of GLFW, i.e. being developed in\nEnglish by a Swede.  However, many keyboard layouts require more than one key to\nproduce characters with diacritical marks. Even the Swedish keyboard layout\nrequires this for uncommon cases like ü.\n\n@par Old syntax\n@code\nvoid GLFWCALL character_callback(int character, int action);\n@endcode\n\n@par New syntax\n@code\nvoid character_callback(GLFWwindow* window, int character);\n@endcode\n\n\n@subsection moving_cursorpos Cursor position changes\n\nThe `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos,\n`glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref\nglfwSetCursorPosCallback.\n\nThe cursor position is now `double` instead of `int`, both for the direct\nfunctions and for the callback.  Some platforms can provide sub-pixel cursor\nmovement and this data is now passed on to the application where available.  On\nplatforms where this is not provided, the decimal part is zero.\n\nGLFW 3 only allows you to position the cursor within a window using @ref\nglfwSetCursorPos (formerly `glfwSetMousePos`) when that window is active.\nUnless the window is active, the function fails silently.\n\n\n@subsection moving_wheel Wheel position replaced by scroll offsets\n\nThe `glfwGetMouseWheel` function has been removed.  Scrolling is the input of\noffsets and has no absolute position.  The mouse wheel callback has been\nreplaced by a [scroll callback](@ref GLFWscrollfun) that receives\ntwo-dimensional floating point scroll offsets.  This allows you to receive\nprecise scroll data from for example modern touchpads.\n\n@par Old syntax\n@code\nvoid GLFWCALL mouse_wheel_callback(int position);\n@endcode\n\n@par New syntax\n@code\nvoid scroll_callback(GLFWwindow* window, double xoffset, double yoffset);\n@endcode\n\n@par Removed functions\n`glfwGetMouseWheel`\n\n\n@subsection moving_repeat Key repeat action\n\nThe `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled\nfor both keys and characters.  A new key action, `GLFW_REPEAT`, has been added\nto allow the [key callback](@ref GLFWkeyfun) to distinguish an initial key press\nfrom a repeat.  Note that @ref glfwGetKey still returns only `GLFW_PRESS` or\n`GLFW_RELEASE`.\n\n\n@subsection moving_keys Physical key input\n\nGLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to\nthe values generated by the current keyboard layout.  The tokens are named\naccording to the values they would have using the standard US layout, but this\nis only a convenience, as most programmers are assumed to know that layout.\nThis means that (for example) `GLFW_KEY_LEFT_BRACKET` is always a single key and\nis the same key in the same place regardless of what keyboard layouts the users\nof your program has.\n\nThe key input facility was never meant for text input, although using it that\nway worked slightly better in GLFW 2.  If you were using it to input text, you\nshould be using the character callback instead, on both GLFW 2 and 3.  This will\ngive you the characters being input, as opposed to the keys being pressed.\n\nGLFW 3 has key tokens for all keys on a standard 105 key keyboard, so instead of\nhaving to remember whether to check for `'a'` or `'A'`, you now check for\n`GLFW_KEY_A`.\n\n\n@subsection moving_joystick Joystick function changes\n\nThe `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes.\n\nThe `glfwGetJoystickParam` function and the `GLFW_PRESENT`, `GLFW_AXES` and\n`GLFW_BUTTONS` tokens have been replaced by the @ref glfwJoystickPresent\nfunction as well as axis and button counts returned by the @ref\nglfwGetJoystickAxes and @ref glfwGetJoystickButtons functions.\n\n\n@subsection moving_mbcs Win32 MBCS support\n\nThe Win32 port of GLFW 3 will not compile in\n[MBCS mode](http://msdn.microsoft.com/en-us/library/5z097dxa.aspx).\nHowever, because the use of the Unicode version of the Win32 API doesn't affect\nthe process as a whole, but only those windows created using it, it's perfectly\npossible to call MBCS functions from other parts of the same application.\nTherefore, even if an application using GLFW has MBCS mode code, there's no need\nfor GLFW itself to support it.\n\n\n@subsection moving_windows Support for versions of Windows older than XP\n\nAll explicit support for version of Windows older than XP has been removed.\nThere is no code that actively prevents GLFW 3 from running on these earlier\nversions, but it uses Win32 functions that those versions lack.\n\nWindows XP was released in 2001, and by now (January 2015) it has not only\nreplaced almost all earlier versions of Windows, but is itself rapidly being\nreplaced by Windows 7 and 8.  The MSDN library doesn't even provide\ndocumentation for version older than Windows 2000, making it difficult to\nmaintain compatibility with these versions even if it was deemed worth the\neffort.\n\nThe Win32 API has also not stood still, and GLFW 3 uses many functions only\npresent on Windows XP or later.  Even supporting an OS as new as XP (new\nfrom the perspective of GLFW 2, which still supports Windows 95) requires\nruntime checking for a number of functions that are present only on modern\nversion of Windows.\n\n\n@subsection moving_syskeys Capture of system-wide hotkeys\n\nThe ability to disable and capture system-wide hotkeys like Alt+Tab has been\nremoved.  Modern applications, whether they're games, scientific visualisations\nor something else, are nowadays expected to be good desktop citizens and allow\nthese hotkeys to function even when running in full screen mode.\n\n\n@subsection moving_terminate Automatic termination\n\nGLFW 3 does not register @ref glfwTerminate with `atexit` at initialization,\nbecause `exit` calls registered functions from the calling thread and while it\nis permitted to call `exit` from any thread, @ref glfwTerminate may only be\ncalled from the main thread.\n\nTo release all resources allocated by GLFW, you should call @ref glfwTerminate\nyourself, from the main thread, before the program terminates.  Note that this\ndestroys all windows not already destroyed with @ref glfwDestroyWindow,\ninvalidating any window handles you may still have.\n\n\n@subsection moving_glu GLU header inclusion\n\nGLFW 3 does not by default include the GLU header and GLU itself has been\ndeprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group).  __New\nprojects should not use GLU__, but if you need it for legacy code that\nhas been moved to GLFW 3, you can request that the GLFW header includes it by\ndefining `GLFW_INCLUDE_GLU` before the inclusion of the GLFW header.\n\n@par Old syntax\n@code\n#include <GL/glfw.h>\n@endcode\n\n@par New syntax\n@code\n#define GLFW_INCLUDE_GLU\n#include <GLFW/glfw3.h>\n@endcode\n\n\n@section moving_tables Name change tables\n\n\n@subsection moving_renamed_functions Renamed functions\n\n| GLFW 2                      | GLFW 3                        | Notes |\n| --------------------------- | ----------------------------- | ----- |\n| `glfwOpenWindow`            | @ref glfwCreateWindow         | All channel bit depths are now hints\n| `glfwCloseWindow`           | @ref glfwDestroyWindow        |       |\n| `glfwOpenWindowHint`        | @ref glfwWindowHint           | Now accepts all `GLFW_*_BITS` tokens |\n| `glfwEnable`                | @ref glfwSetInputMode         |       |\n| `glfwDisable`               | @ref glfwSetInputMode         |       |\n| `glfwGetMousePos`           | @ref glfwGetCursorPos         |       |\n| `glfwSetMousePos`           | @ref glfwSetCursorPos         |       |\n| `glfwSetMousePosCallback`   | @ref glfwSetCursorPosCallback |       |\n| `glfwSetMouseWheelCallback` | @ref glfwSetScrollCallback    | Accepts two-dimensional scroll offsets as doubles |\n| `glfwGetJoystickPos`        | @ref glfwGetJoystickAxes      |       |\n| `glfwGetWindowParam`        | @ref glfwGetWindowAttrib      |       |\n| `glfwGetGLVersion`          | @ref glfwGetWindowAttrib      | Use `GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and `GLFW_CONTEXT_REVISION` |\n| `glfwGetDesktopMode`        | @ref glfwGetVideoMode         | Returns the current mode of a monitor |\n| `glfwGetJoystickParam`      | @ref glfwJoystickPresent      | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons |\n\n@subsection moving_renamed_tokens Renamed tokens\n\n| GLFW 2                      | GLFW 3                       | Notes |\n| --------------------------- | ---------------------------- | ----- |\n| `GLFW_OPENGL_VERSION_MAJOR` | `GLFW_CONTEXT_VERSION_MAJOR` | Renamed as it applies to OpenGL ES as well |\n| `GLFW_OPENGL_VERSION_MINOR` | `GLFW_CONTEXT_VERSION_MINOR` | Renamed as it applies to OpenGL ES as well |\n| `GLFW_FSAA_SAMPLES`         | `GLFW_SAMPLES`               | Renamed to match the OpenGL API |\n| `GLFW_ACTIVE`               | `GLFW_FOCUSED`               | Renamed to match the window focus callback |\n| `GLFW_WINDOW_NO_RESIZE`     | `GLFW_RESIZABLE`             | The default has been inverted |\n| `GLFW_MOUSE_CURSOR`         | `GLFW_CURSOR`                | Used with @ref glfwSetInputMode |\n| `GLFW_KEY_ESC`              | `GLFW_KEY_ESCAPE`            |       |\n| `GLFW_KEY_DEL`              | `GLFW_KEY_DELETE`            |       |\n| `GLFW_KEY_PAGEUP`           | `GLFW_KEY_PAGE_UP`           |       |\n| `GLFW_KEY_PAGEDOWN`         | `GLFW_KEY_PAGE_DOWN`         |       |\n| `GLFW_KEY_KP_NUM_LOCK`      | `GLFW_KEY_NUM_LOCK`          |       |\n| `GLFW_KEY_LCTRL`            | `GLFW_KEY_LEFT_CONTROL`      |       |\n| `GLFW_KEY_LSHIFT`           | `GLFW_KEY_LEFT_SHIFT`        |       |\n| `GLFW_KEY_LALT`             | `GLFW_KEY_LEFT_ALT`          |       |\n| `GLFW_KEY_LSUPER`           | `GLFW_KEY_LEFT_SUPER`        |       |\n| `GLFW_KEY_RCTRL`            | `GLFW_KEY_RIGHT_CONTROL`     |       |\n| `GLFW_KEY_RSHIFT`           | `GLFW_KEY_RIGHT_SHIFT`       |       |\n| `GLFW_KEY_RALT`             | `GLFW_KEY_RIGHT_ALT`         |       |\n| `GLFW_KEY_RSUPER`           | `GLFW_KEY_RIGHT_SUPER`       |       |\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/news.dox",
    "content": "/*!\n\n@page news New features\n\n@section news_31 New features in 3.1\n\nThese are the release highlights.  For a full list of changes see the\n[version history](http://www.glfw.org/changelog.html).\n\n\n@subsection news_31_cursor Custom mouse cursor images\n\nGLFW now supports creating and setting both custom cursor images and standard\ncursor shapes.  They are created with @ref glfwCreateCursor or @ref\nglfwCreateStandardCursor, set with @ref glfwSetCursor and destroyed with @ref\nglfwDestroyCursor.\n\n@see @ref cursor_object\n\n\n@subsection news_31_drop Path drop event\n\nGLFW now provides a callback for receiving the paths of files and directories\ndropped onto GLFW windows.  The callback is set with @ref glfwSetDropCallback.\n\n@see @ref path_drop\n\n\n@subsection news_31_emptyevent Main thread wake-up\n\nGLFW now provides the @ref glfwPostEmptyEvent function for posting an empty\nevent from another thread to the main thread event queue, causing @ref\nglfwWaitEvents to return.\n\n@see @ref events\n\n\n@subsection news_31_framesize Window frame size query\n\nGLFW now supports querying the size, on each side, of the frame around the\nclient area of a window, with @ref glfwGetWindowFrameSize.\n\n@see [Window size](@ref window_size)\n\n\n@subsection news_31_autoiconify Simultaneous multi-monitor rendering\n\nGLFW now supports disabling auto-iconification of full screen windows with\nthe [GLFW_AUTO_ICONIFY](@ref window_hints_wnd) window hint.  This is intended\nfor people building multi-monitor installations, where you need windows to stay\nin full screen despite losing input focus.\n\n\n@subsection news_31_floating Floating windows\n\nGLFW now supports floating windows, also called topmost or always on top, for\neasier debugging with the [GLFW_FLOATING](@ref window_hints_wnd) window hint.\n\n\n@subsection news_31_focused Initially unfocused windows\n\nGLFW now supports preventing a windowed mode window from gaining input focus on\ncreation, with the [GLFW_FOCUSED](@ref window_hints_wnd) window hint.\n\n\n@subsection news_31_direct Direct access for window attributes and cursor position\n\nGLFW now queries the window input focus, visibility and iconification attributes\nand the cursor position directly instead of returning cached data.\n\n\n@subsection news_31_libovr Better interoperability with Oculus Rift\n\nGLFW now provides native access functions for the OS level handles corresponding\nto monitor objects, as well as a [brief guide](@ref rift).  It is also regularly\ntested for compatibility with the latest version of LibOVR (0.4.4 on release).\n\n\n@subsection news_31_charmods Character with modifiers callback\n\nGLFW now provides a callback for character events with modifier key bits.  The\ncallback is set with @ref glfwSetCharModsCallback.  Unlike the regular character\ncallback, this will report character events that will not result in a character\nbeing input, for example if the Control key is held down.\n\n@see @ref input_char\n\n\n@subsection news_31_single Single buffered framebuffers\n\nGLFW now supports the creation of single buffered windows, with the\n[GLFW_DOUBLEBUFFER](@ref window_hints_fb) window hint.\n\n\n@subsection news_31_glext Macro for including extension header\n\nGLFW now includes the extension header appropriate for the chosen OpenGL or\nOpenGL ES header when [GLFW_INCLUDE_GLEXT](@ref build_macros) is defined.  GLFW\ndoes not provide these headers.  They must be provided by your development\nenvironment or your OpenGL or OpenGL ES SDK.\n\n\n@subsection news_31_release Context release behaviors\n\nGLFW now supports controlling whether the pipeline is flushed when a context is\nmade non-current, with the\n[GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint, provided the\nmachine supports the `GL_KHR_context_flush_control` extension.\n\n\n@subsection news_31_wayland (Experimental) Wayland support\n\nGLFW now has an _experimental_ Wayland display protocol backend that can be\nselected on Linux with a CMake option.\n\n\n@subsection news_31_mir (Experimental) Mir support\n\nGLFW now has an _experimental_ Mir display server backend that can be selected\non Linux with a CMake option.\n\n\n@section news_30 New features in 3.0\n\nThese are the release highlights.  For a full list of changes see the\n[version history](http://www.glfw.org/changelog.html).\n\n\n@subsection news_30_cmake CMake build system\n\nGLFW now uses the CMake build system instead of the various makefiles and\nproject files used by earlier versions.  CMake is available for all platforms\nsupported by GLFW, is present in most package systems and can generate\nmakefiles and/or project files for most popular development environments.\n\nFor more information on how to use CMake, see the\n[CMake manual](http://cmake.org/cmake/help/documentation.html).\n\n\n@subsection news_30_multiwnd Multi-window support\n\nGLFW now supports the creation of multiple windows, each with their own OpenGL\nor OpenGL ES context, and all window functions now take a window handle.  Event\ncallbacks are now per-window and are provided with the handle of the window that\nreceived the event.  The @ref glfwMakeContextCurrent function has been added to\nselect which context is current on a given thread.\n\n\n@subsection news_30_multimon Multi-monitor support\n\nGLFW now explicitly supports multiple monitors.  They can be enumerated with\n@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref\nglfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize,\nand specified at window creation to make the newly created window full screen on\nthat specific monitor.\n\n\n@subsection news_30_unicode Unicode support\n\nAll string arguments to GLFW functions and all strings returned by GLFW now use\nthe UTF-8 encoding.  This includes the window title, error string, clipboard\ntext, monitor and joystick names as well as the extension function arguments (as\nASCII is a subset of UTF-8).\n\n\n@subsection news_30_clipboard Clipboard text I/O\n\nGLFW now supports reading and writing plain text to and from the system\nclipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString\nfunctions.\n\n\n@subsection news_30_gamma Gamma ramp support\n\nGLFW now supports setting and reading back the gamma ramp of monitors, with the\n@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions.  There is also @ref\nglfwSetGamma, which generates a ramp from a gamma value and then sets it.\n\n\n@subsection news_30_gles OpenGL ES support\n\nGLFW now supports the creation of OpenGL ES contexts, by setting the\n`GLFW_CLIENT_API` window hint to `GLFW_OPENGL_ES_API`, where creation of such\ncontexts are supported.  Note that GLFW _does not implement_ OpenGL ES, so your\ndriver must provide support in a way usable by GLFW.  Modern Nvidia and Intel\ndrivers support creation of OpenGL ES context using the GLX and WGL APIs, while\nAMD provides an EGL implementation instead.\n\n\n@subsection news_30_egl (Experimental) EGL support\n\nGLFW now has an experimental EGL context creation back end that can be selected\nthrough CMake options.\n\n\n@subsection news_30_hidpi High-DPI support\n\nGLFW now supports high-DPI monitors on both Windows and OS X, giving windows full\nresolution framebuffers where other UI elements are scaled up.  To achieve this,\n@ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have been\nadded.  These work with pixels, while the rest of the GLFW API works with screen\ncoordinates.  This is important as OpenGL uses pixels, not screen coordinates.\n\n\n@subsection news_30_error Error callback\n\nGLFW now has an error callback, which can provide your application with much\nmore detailed diagnostics than was previously possible.  The callback is passed\nan error code and a description string.\n\n\n@subsection news_30_wndptr Per-window user pointer\n\nEach window now has a user-defined pointer, retrieved with @ref\nglfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it\neasier to integrate GLFW into C++ code.\n\n\n@subsection news_30_iconifyfun Window iconification callback\n\nEach window now has a callback for iconification and restoration events,\nwhich is set with @ref glfwSetWindowIconifyCallback.\n\n\n@subsection news_30_wndposfun Window position callback\n\nEach window now has a callback for position events, which is set with @ref\nglfwSetWindowPosCallback.\n\n\n@subsection news_30_wndpos Window position query\n\nThe position of a window can now be retrieved using @ref glfwGetWindowPos.\n\n\n@subsection news_30_focusfun Window focus callback\n\nEach windows now has a callback for focus events, which is set with @ref\nglfwSetWindowFocusCallback.\n\n\n@subsection news_30_enterleave Cursor enter/leave callback\n\nEach window now has a callback for when the mouse cursor enters or leaves its\nclient area, which is set with @ref glfwSetCursorEnterCallback.\n\n\n@subsection news_30_wndtitle Initial window title\n\nThe title of a window is now specified at creation time, as one of the arguments\nto @ref glfwCreateWindow.\n\n\n@subsection news_30_hidden Hidden windows\n\nWindows can now be hidden with @ref glfwHideWindow, shown using @ref\nglfwShowWindow and created initially hidden with the `GLFW_VISIBLE` window hint.\nThis allows for off-screen rendering in a way compatible with most drivers, as\nwell as moving a window to a specific position before showing it.\n\n\n@subsection news_30_undecorated Undecorated windows\n\nWindowed mode windows can now be created without decorations, i.e. things like\na frame, a title bar, with the `GLFW_DECORATED` window hint.  This allows for\nthe creation of things like splash screens.\n\n\n@subsection news_30_keymods Modifier key bit masks\n\n[Modifier key bit mask](@ref mods) parameters have been added to the\n[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks.\n\n\n@subsection news_30_scancode Platform-specific scancodes\n\nA scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys\nthat don't have a [key token](@ref keys) still get passed on with the key\nparameter set to `GLFW_KEY_UNKNOWN`.  These scancodes will vary between machines\nand are intended to be used for key bindings.\n\n\n@subsection news_30_jsname Joystick names\n\nThe name of a joystick can now be retrieved using @ref glfwGetJoystickName.\n\n\n@subsection news_30_doxygen Doxygen documentation\n\nYou are reading it.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/quick.dox",
    "content": "/*!\n\n@page quick Getting started\n\n@tableofcontents\n\nThis guide takes you through writing a simple application using GLFW 3.  The\napplication will create a window and OpenGL context, render a rotating triangle\nand exit when the user closes the window or presses Escape.  This guide will\nintroduce a few of the most commonly used functions, but there are many more.\n\nThis guide assumes no experience with earlier versions of GLFW.  If you\nhave used GLFW 2 in the past, read the @ref moving guide, as some functions\nbehave differently in GLFW 3.\n\n\n@section quick_steps Step by step\n\n@subsection quick_include Including the GLFW header\n\nIn the source files of your application where you use OpenGL or GLFW, you need\nto include the GLFW 3 header file.\n\n@code\n#include <GLFW/glfw3.h>\n@endcode\n\nThis defines all the constants, types and function prototypes of the GLFW API.\nIt also includes the OpenGL header, and defines all the constants and types\nnecessary for it to work on your platform.\n\nFor example, under Windows you are normally required to include `windows.h`\nbefore including `GL/gl.h`.  This would make your source file tied to Windows\nand pollute your code's namespace with the whole Win32 API.\n\nInstead, the GLFW header takes care of this for you, not by including\n`windows.h`, but rather by itself duplicating only the necessary parts of it.\nIt does this only where needed, so if `windows.h` _is_ included, the GLFW header\ndoes not try to redefine those symbols.\n\nIn other words:\n\n- Do _not_ include the OpenGL headers yourself, as GLFW does this for you\n- Do _not_ include `windows.h` or other platform-specific headers unless\n  you plan on using those APIs directly\n- If you _do_ need to include such headers, do it _before_ including the\n  GLFW one and it will detect this\n\nStarting with version 3.0, the GLU header `glu.h` is no longer included by\ndefault.  GLU is deprecated and should not be used in new code.  If you need to\ninclude it for legacy code, define `GLFW_INCLUDE_GLU` before the inclusion of\nthe GLFW header.\n\n@code\n#define GLFW_INCLUDE_GLU\n#include <GLFW/glfw3.h>\n@endcode\n\n\n@subsection quick_init_term Initializing and terminating GLFW\n\nBefore you can use most GLFW functions, the library must be initialized.  On\nsuccessful initialization, `GL_TRUE` is returned.  If an error occurred,\n`GL_FALSE` is returned.\n\n@code\nif (!glfwInit())\n    exit(EXIT_FAILURE);\n@endcode\n\nWhen you are done using GLFW, typically just before the application exits, you\nneed to terminate GLFW.\n\n@code\nglfwTerminate();\n@endcode\n\nThis destroys any remaining windows and releases any other resources allocated by\nGLFW.  After this call, you must initialize GLFW again before using any GLFW\nfunctions that require it.\n\n\n@subsection quick_capture_error Setting an error callback\n\nMost events are reported through callbacks, whether it's a key being pressed,\na GLFW window being moved, or an error occurring.  Callbacks are simply\nC functions (or C++ static methods) that are called by GLFW with arguments\ndescribing the event.\n\nIn case a GLFW function fails, an error is reported to the GLFW error callback.\nYou can receive these reports with an error callback.  This function must have\nthe signature below.  This simple error callback just prints the error\ndescription to `stderr`.\n\n@code\nvoid error_callback(int error, const char* description)\n{\n    fputs(description, stderr);\n}\n@endcode\n\nCallback functions must be set, so GLFW knows to call them.  The function to set\nthe error callback is one of the few GLFW functions that may be called before\ninitialization, which lets you be notified of errors both during and after\ninitialization.\n\n@code\nglfwSetErrorCallback(error_callback);\n@endcode\n\n\n@subsection quick_create_window Creating a window and context\n\nThe window and its OpenGL context are created with a single call, which returns\na handle to the created combined window and context object.  For example, this\ncreates a 640 by 480 windowed mode window with an OpenGL context:\n\n@code\nGLFWwindow* window = glfwCreateWindow(640, 480, \"My Title\", NULL, NULL);\n@endcode\n\nIf window or context creation fails, `NULL` will be returned, so it is necessary\nto check the return value.\n\n@code\nif (!window)\n{\n    glfwTerminate();\n    exit(EXIT_FAILURE);\n}\n@endcode\n\nThe window handle is passed to all window related functions and is provided to\nalong to all window related callbacks, so they can tell which window received\nthe event.\n\nWhen a window is no longer needed, destroy it.\n\n@code\nglfwDestroyWindow(window);\n@endcode\n\nOnce this function is called, no more events will be delivered for that window\nand its handle becomes invalid.\n\n\n@subsection quick_context_current Making the OpenGL context current\n\nBefore you can use the OpenGL API, you must have a current OpenGL context.\n\n@code\nglfwMakeContextCurrent(window);\n@endcode\n\nThe context will remain current until you make another context current or until\nthe window owning the current context is destroyed.\n\n\n@subsection quick_window_close Checking the window close flag\n\nEach window has a flag indicating whether the window should be closed.\n\nWhen the user attempts to close the window, either by pressing the close widget\nin the title bar or using a key combination like Alt+F4, this flag is set to 1.\nNote that __the window isn't actually closed__, so you are expected to monitor\nthis flag and either destroy the window or give some kind of feedback to the\nuser.\n\n@code\nwhile (!glfwWindowShouldClose(window))\n{\n    // Keep running\n}\n@endcode\n\nYou can be notified when the user is attempting to close the window by setting\na close callback with @ref glfwSetWindowCloseCallback.  The callback will be\ncalled immediately after the close flag has been set.\n\nYou can also set it yourself with @ref glfwSetWindowShouldClose.  This can be\nuseful if you want to interpret other kinds of input as closing the window, like\nfor example pressing the escape key.\n\n\n@subsection quick_key_input Receiving input events\n\nEach window has a large number of callbacks that can be set to receive all the\nvarious kinds of events.  To receive key press and release events, create a key\ncallback function.\n\n@code\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n@endcode\n\nThe key callback, like other window related callbacks, are set per-window.\n\n@code\nglfwSetKeyCallback(window, key_callback);\n@endcode\n\nIn order for event callbacks to be called when events occur, you need to process\nevents as described below.\n\n\n@subsection quick_render Rendering with OpenGL\n\nOnce you have a current OpenGL context, you can use OpenGL normally.  In this\ntutorial, a multi-colored rotating triangle will be rendered.  The framebuffer\nsize needs to be retrieved for `glViewport`.\n\n@code\nint width, height;\nglfwGetFramebufferSize(window, &width, &height);\nglViewport(0, 0, width, height);\n@endcode\n\nYou can also set a framebuffer size callback using @ref\nglfwSetFramebufferSizeCallback and call `glViewport` from there.\n\n\n@subsection quick_timer Reading the timer\n\nTo create smooth animation, a time source is needed.  GLFW provides a timer that\nreturns the number of seconds since initialization.  The time source used is the\nmost accurate on each platform and generally has micro- or nanosecond\nresolution.\n\n@code\ndouble time = glfwGetTime();\n@endcode\n\n\n@subsection quick_swap_buffers Swapping buffers\n\nGLFW windows by default use double buffering.  That means that each window has\ntwo rendering buffers; a front buffer and a back buffer.  The front buffer is\nthe one being displayed and the back buffer the one you render to.\n\nWhen the entire frame has been rendered, the buffers need to be swapped with one\nanother, so the back buffer becomes the front buffer and vice versa.\n\n@code\nglfwSwapBuffers(window);\n@endcode\n\nThe swap interval indicates how many frames to wait until swapping the buffers,\ncommonly known as _vsync_.  By default, the swap interval is zero, meaning\nbuffer swapping will occur immediately.  On fast machines, many of those frames\nwill never be seen, as the screen is still only updated typically 60-75 times\nper second, so this wastes a lot of CPU and GPU cycles.\n\nAlso, because the buffers will be swapped in the middle the screen update,\nleading to [screen tearing](https://en.wikipedia.org/wiki/Screen_tearing).\n\nFor these reasons, applications will typically want to set the swap interval to\none.  It can be set to higher values, but this is usually not recommended,\nbecause of the input latency it leads to.\n\n@code\nglfwSwapInterval(1);\n@endcode\n\nThis function acts on the current context and will fail unless a context is\ncurrent.\n\n\n@subsection quick_process_events Processing events\n\nGLFW needs to communicate regularly with the window system both in order to\nreceive events and to show that the application hasn't locked up.  Event\nprocessing must be done regularly while you have visible windows and is normally\ndone each frame after buffer swapping.\n\nThere are two methods for processing pending events; polling and waiting.  This\nexample will use event polling, which processes only those events that have\nalready been received and then returns immediately.  \n\n@code\nglfwPollEvents();\n@endcode\n\nThis is the best choice when rendering continually, like most games do.  If\ninstead you only need to update your rendering once you have received new input,\n@ref glfwWaitEvents is a better choice.  It waits until at least one event has\nbeen received, putting the thread to sleep in the meantime, and then processes\nall received events.  This saves a great deal of CPU cycles and is useful for,\nfor example, many kinds of editing tools.\n\n\n@section quick_example Putting it together\n\nNow that you know how to initialize GLFW, create a window and poll for\nkeyboard input, it's possible to create a simple program.\n\n@snippet simple.c code\n\nThis program creates a 640 by 480 windowed mode window and starts a loop that\nclears the screen, renders a triangle and processes events until the user either\npresses Escape or closes the window.\n\nThis program uses only a few of the many functions GLFW provides.  There are\nguides for each of the areas covered by GLFW.  Each guide will introduce all the\nfunctions for that category.\n\n - @ref intro\n - @ref window\n - @ref context\n - @ref monitor\n - @ref input\n\n\n@section quick_build Compiling and linking the program\n\nThe complete program above can be found in the source distribution as\n`examples/simple.c` and is compiled along with all other examples when you\nbuild GLFW.  That is, if you have compiled GLFW then you have already built this\nas `simple.exe` on Windows, `simple` on Linux or `simple.app` on OS X.\n\nThis tutorial ends here.  Once you have written a program that uses GLFW, you\nwill need to compile and link it.  How to do that depends on the development\nenvironment you are using and is best explained by the documentation for that\nenvironment.  To learn about the details that are specific to GLFW, see\n@ref build.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/rift.dox",
    "content": "/*!\n\n@page rift Oculus Rift guide\n \n@tableofcontents\n\nThis guide is intended to fill in the gaps between the\n[Oculus PC SDK documentation](https://developer.oculus.com/documentation/) and\nthe rest of the GLFW documentation and is not a replacement for either.  It\nrequires you to use [native access](@ref native) and assumes a certain level of\nproficiency with LibOVR, platform specific APIs and your chosen development\nenvironment.\n\nWhile GLFW has no explicit support for LibOVR, it is tested with and tries to\ninteroperate well with it.\n\n@note Because of the speed of development of the Oculus SDK, this guide may\nbecome outdated before the next release.  If this is a local copy of the\ndocumentation, you may want to check the GLFW website for updates.  This\nrevision of the guide is written against version 0.4.4 of the SDK.\n\n\n@section rift_include Including the LibOVR and GLFW header files\n\nBoth the OpenGL LibOVR header and the GLFW native header need macros telling\nthem what OS you are building for.  Because LibOVR only supports three major\ndesktop platforms, this can be solved with canonical predefined macros.\n\n@code\n#if defined(_WIN32)\n #define GLFW_EXPOSE_NATIVE_WIN32\n #define GLFW_EXPOSE_NATIVE_WGL\n #define OVR_OS_WIN32\n#elif defined(__APPLE__)\n #define GLFW_EXPOSE_NATIVE_COCOA\n #define GLFW_EXPOSE_NATIVE_NSGL\n #define OVR_OS_MAC\n#elif defined(__linux__)\n #define GLFW_EXPOSE_NATIVE_X11\n #define GLFW_EXPOSE_NATIVE_GLX\n #define OVR_OS_LINUX\n#endif\n\n#include <GLFW/glfw3.h>\n#include <GLFW/glfw3native.h>\n\n#include <OVR_CAPI_GL.h>\n@endcode\n\nBoth the GLFW and LibOVR headers by default attempt to include the standard\nOpenGL `GL/gl.h` header (`OpenGL/gl.h` on OS X).  If you wish to use a different\nstandard header or an [extension loading library](@ref context_glext_auto),\ninclude that header before these.\n\n\n@section rift_init Initializing LibOVR and GLFW\n\nLibOVR needs to be initialized before GLFW.  This means calling at least\n`ovr_Initialize`, `ovrHmd_Create` and `ovrHmd_ConfigureTracking` before @ref\nglfwInit.  Similarly, LibOVR must be shut down after GLFW.  This means calling\n`ovrHmd_Destroy` and `ovr_Shutdown` after @ref glfwTerminate.\n\n\n@section rift_direct Direct HMD mode\n\nDirect HMD mode is the recommended display mode for new applications, but the\nOculus Rift runtime currently (January 2015) only supports this mode on Windows.\nIn direct mode the HMD is not detectable as a GLFW monitor.\n\n\n@subsection rift_direct_create Creating a window and context\n\nIf the HMD is in direct mode you can use either a full screen or a windowed mode\nwindow, but full screen is only recommended if there is a monitor that supports\nthe resolution of the HMD.  Due to limitations in LibOVR, the size of the client\narea of the window must equal the resolution of the HMD.\n\nIf the resolution of the HMD is much larger than the regular monitor, the window\nmay be resized by the window manager on creation.  One way to avoid this is to\nmake it undecorated with the [GLFW_DECORATED](@ref window_hints_wnd) window\nhint.\n\n\n@subsection rift_direct_attach Attaching the window to the HMD\n\nOnce you have created the window and context, you need to attach the native\nhandle of the GLFW window to the HMD.\n\n@code\novrHmd_AttachToWindow(hmd, glfwGetWin32Window(window), NULL, NULL);\n@endcode\n\n\n@section rift_extend Extend Desktop mode\n\nExtend desktop mode is a legacy display mode, but is still (January 2015) the\nonly available mode on OS X and Linux, as well as on Windows machines that for\ntechnical reasons do not yet support direct HMD mode.\n\n\n@subsection rift_extend_detect Detecting a HMD with GLFW\n\nIf the HMD is in extend desktop mode you can deduce which GLFW monitor it\ncorresponds to and create a full screen window on that monitor.\n\nOn Windows, the native display device name of a GLFW monitor corresponds to the\ndisplay device name of the detected HMD as stored, in the `DisplayDeviceName`\nmember of `ovrHmdDesc`.\n\nOn OS X, the native display ID of a GLFW monitor corresponds to the display ID\nof the detected HMD, as stored in the `DisplayId` member of `ovrHmdDesc`.\n\nAt the time of writing (January 2015), the Oculus SDK does not support detecting\nwhich monitor corresponds to the HMD in any sane fashion, but as long as the HMD\nis set up and rotated properly it can be found via the screen position and\nresolution provided by LibOVR.  This method may instead find another monitor\nthat is mirroring the HMD, but this only matters if you intend to change its\nvideo mode.\n\n@code\nint i, count;\nGLFWmonitor** monitors = glfwGetMonitors(&count);\n\nfor (i = 0;  i < count;  i++)\n{\n#if defined(_WIN32)\n    if (strcmp(glfwGetWin32Monitor(monitors[i]), hmd->DisplayDeviceName) == 0)\n        return monitors[i];\n#elif defined(__APPLE__)\n    if (glfwGetCocoaMonitor(monitors[i]) == hmd->DisplayId)\n        return monitors[i];\n#elif defined(__linux__)\n    int xpos, ypos;\n    const GLFWvidmode* mode = glfwGetVideoMode(monitors[i]);\n    glfwGetMonitorPos(monitors[i], &xpos, &ypos);\n\n    if (hmd->WindowsPos.x == xpos &&\n        hmd->WindowsPos.y == ypos &&\n        hmd->Resolution.w == mode->width &&\n        hmd->Resolution.h == mode->height)\n    {\n        return monitors[i];\n    }\n#endif\n}\n@endcode\n\n\n@subsection rift_extend_create Creating a window and context\n\nThe window is created as a regular full screen window on the found monitor.  It\nis usually a good idea to create a\n[windowed full screen](@ref window_windowed_full_screen) window, as the HMD will\nvery likely already be set to the correct video mode.  However, in extend\ndesktop mode it behaves like a regular monitor and any supported video mode can\nbe requested.\n\nIf other monitors are mirroring the HMD and you request a different video mode,\nall monitors in the mirroring set will get the new video mode.\n\n\n@section rift_render Rendering to the HMD\n\n@subsection rift_render_sdk SDK distortion rendering\n\nIf you wish to use SDK distortion rendering you will need some information from\nGLFW to configure the renderer.  Below are the parts of the `ovrGLConfig` union\nthat need to be filled with from GLFW.  Note that there are other fields that\nalso need to be filled for `ovrHmd_ConfigureRendering` to succeed.\n\nBefore configuring SDK distortion rendering you should make your context\ncurrent.\n\n@code\n    int width, height;\n    union ovrGLConfig config;\n\n    glfwGetFramebufferSize(window, &width, &height);\n\n    config.OGL.Header.BackBufferSize.w = width;\n    config.OGL.Header.BackBufferSize.h = height;\n#if defined(_WIN32)\n    config.OGL.Window = glfwGetWin32Window(window);\n#elif defined(__APPLE__)\n#elif defined(__linux__)\n    config.OGL.Disp = glfwGetX11Display();\n#endif\n@endcode\n\nWhen using SDK distortion rendering you should not swap the buffers yourself, as\nthe HMD is updated by `ovrHmd_EndFrame`.\n\n\n@subsection rift_render_custom Client distortion rendering\n\nWith client distortion rendering you are in full control of the contents of the\nHMD and should render and swap the buffers normally.\n\n*/\n"
  },
  {
    "path": "deps/glfw/docs/window.dox",
    "content": "/*!\n\n@page window Window guide\n \n@tableofcontents\n\nThis guide introduces the window related functions of GLFW.  There are also\nguides for the other areas of GLFW.\n\n - @ref intro\n - @ref context\n - @ref monitor\n - @ref input\n\n\n@section window_object Window objects\n\nThe @ref GLFWwindow object encapsulates both a window and a context.  They are\ncreated with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or\n@ref glfwTerminate, if any remain.  As the window and context are inseparably\nlinked, the object pointer is used as both a context and window handle.\n\nTo see the event stream provided to the various window related callbacks, run\nthe `events` test program.\n\n\n@subsection window_creation Window creation\n\nA window and its OpenGL or OpenGL ES context are created with @ref\nglfwCreateWindow, which returns a handle to the created window object.  For\nexample, this creates a 640 by 480 windowed mode window:\n\n@code\nGLFWwindow* window = glfwCreateWindow(640, 480, \"My Title\", NULL, NULL);\n@endcode\n\nIf window creation fails, `NULL` will be returned, so it is necessary to check\nthe return value.\n\nThe window handle is passed to all window related functions and is provided to\nalong with all input events, so event handlers can tell which window received\nthe event.\n\n\n@subsubsection window_full_screen Full screen windows\n\nTo create a full screen window, you need to specify which monitor the window\nshould use.  In most cases, the user's primary monitor is a good choice.\nFor more information about retrieving monitors, see @ref monitor_monitors. \n\n@code\nGLFWwindow* window = glfwCreateWindow(640, 480, \"My Title\", glfwGetPrimaryMonitor(), NULL);\n@endcode\n\nFull screen windows cover the entire display area of a monitor, have no border\nor decorations.\n\nEach field of the @ref GLFWvidmode structure corresponds to a function parameter\nor window hint and combine to form the _desired video mode_ for that window.\nThe supported video mode most closely matching the desired video mode will be\nset for the chosen monitor as long as the window has input focus.  For more\ninformation about retrieving video modes, see @ref monitor_modes.\n\nVideo mode field        | Corresponds to\n----------------------- | ------------------------\nGLFWvidmode.width       | `width` parameter\nGLFWvidmode.height      | `height` parameter\nGLFWvidmode.redBits     | `GLFW_RED_BITS` hint\nGLFWvidmode.greenBits   | `GLFW_GREEN_BITS` hint\nGLFWvidmode.blueBits    | `GLFW_BLUE_BITS` hint\nGLFWvidmode.refreshRate | `GLFW_REFRESH_RATE` hint\n\nOnce you have a full screen window, you can change its resolution with @ref\nglfwSetWindowSize.  The new video mode will be selected and set the same way as\nthe video mode chosen by @ref glfwCreateWindow.\n\nBy default, the original video mode of the monitor will be restored and the\nwindow iconified if it loses input focus, to allow the user to switch back to\nthe desktop.  This behavior can be disabled with the `GLFW_AUTO_ICONIFY` window\nhint, for example if you wish to simultaneously cover multiple windows with full\nscreen windows.\n\n\n@subsubsection window_windowed_full_screen \"Windowed full screen\" windows\n\nIf the closest match for the desired video mode is the current one, the video\nmode will not be changed, making window creation faster and application\nswitching much smoother.  This is sometimes called _windowed full screen_ or\n_borderless full screen_ window and counts as a full screen window.  To create\nsuch a window, simply request the current video mode.\n\n@code\nconst GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\nglfwWindowHint(GLFW_RED_BITS, mode->redBits);\nglfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\nglfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\nglfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n\nGLFWwindow* window = glfwCreateWindow(mode->width, mode->height, \"My Title\", monitor, NULL);\n@endcode\n\n\n@subsection window_destruction Window destruction\n\nWhen a window is no longer needed, destroy it with @ref glfwDestroyWindow.\n\n@code\nglfwDestroyWindow(window);\n@endcode\n\nWindow destruction always succeeds.  Before the actual destruction, all\ncallbacks are removed so no further events will be delivered for the window.\nAll windows remaining when @ref glfwTerminate is called are destroyed as well.\n\nWhen a full screen window is destroyed, the original video mode of its monitor\nis restored, but the gamma ramp is left untouched.\n\n\n@subsection window_hints Window creation hints\n\nThere are a number of hints that can be set before the creation of a window and\ncontext.  Some affect the window itself, others affect the framebuffer or\ncontext.  These hints are set to their default values each time the library is\ninitialized with @ref glfwInit, can be set individually with @ref glfwWindowHint\nand reset all at once to their defaults with @ref glfwDefaultWindowHints.\n\nNote that hints need to be set _before_ the creation of the window and context\nyou wish to have the specified attributes.\n\n\n@subsubsection window_hints_hard Hard and soft constraints\n\nSome window hints are hard constraints.  These must match the available\ncapabilities _exactly_ for window and context creation to succeed.  Hints\nthat are not hard constraints are matched as closely as possible, but the\nresulting context and framebuffer may differ from what these hints requested.\n\nThe following hints are always hard constraints:\n- `GLFW_STEREO`\n- `GLFW_DOUBLEBUFFER`\n- `GLFW_CLIENT_API`\n\nThe following additional hints are hard constraints when requesting an OpenGL\ncontext, but are ignored when requesting an OpenGL ES context:\n- `GLFW_OPENGL_FORWARD_COMPAT`\n- `GLFW_OPENGL_PROFILE`\n\n\n@subsubsection window_hints_wnd Window related hints\n\n`GLFW_RESIZABLE` specifies whether the windowed mode window will be resizable\n_by the user_.  The window will still be resizable using the @ref\nglfwSetWindowSize function.  This hint is ignored for full screen windows.\n\n`GLFW_VISIBLE` specifies whether the windowed mode window will be initially\nvisible.  This hint is ignored for full screen windows.\n\n`GLFW_DECORATED` specifies whether the windowed mode window will have window\ndecorations such as a border, a close widget, etc.  An undecorated window may\nstill allow the user to generate close events on some platforms.  This hint is\nignored for full screen windows.\n\n`GLFW_FOCUSED` specifies whether the windowed mode window will be given input\nfocus when created.  This hint is ignored for full screen and initially hidden\nwindows.\n\n`GLFW_AUTO_ICONIFY` specifies whether the full screen window will\nautomatically iconify and restore the previous video mode on input focus loss.\nThis hint is ignored for windowed mode windows.\n\n`GLFW_FLOATING` specifies whether the windowed mode window will be floating\nabove other regular windows, also called topmost or always-on-top.  This is\nintended primarily for debugging purposes and cannot be used to implement proper\nfull screen windows.  This hint is ignored for full screen windows.\n\n\n@subsubsection window_hints_fb Framebuffer related hints\n\n`GLFW_RED_BITS`, `GLFW_GREEN_BITS`, `GLFW_BLUE_BITS`, `GLFW_ALPHA_BITS`,\n`GLFW_DEPTH_BITS` and `GLFW_STENCIL_BITS` specify the desired bit depths of the\nvarious components of the default framebuffer.  `GLFW_DONT_CARE` means the\napplication has no preference.\n\n`GLFW_ACCUM_RED_BITS`, `GLFW_ACCUM_GREEN_BITS`, `GLFW_ACCUM_BLUE_BITS` and\n`GLFW_ACCUM_ALPHA_BITS` specify the desired bit depths of the various components\nof the accumulation buffer.  `GLFW_DONT_CARE` means the application has no\npreference.\n\n@par\nAccumulation buffers are a legacy OpenGL feature and should not be used in new\ncode.\n\n`GLFW_AUX_BUFFERS` specifies the desired number of auxiliary buffers.\n`GLFW_DONT_CARE` means the application has no preference.\n\n@par\nAuxiliary buffers are a legacy OpenGL feature and should not be used in new\ncode.\n\n`GLFW_STEREO` specifies whether to use stereoscopic rendering.  This is a hard\nconstraint.\n\n`GLFW_SAMPLES` specifies the desired number of samples to use for multisampling.\nZero disables multisampling.  `GLFW_DONT_CARE` means the application has no\npreference.\n\n`GLFW_SRGB_CAPABLE` specifies whether the framebuffer should be sRGB capable.\nIf supported, the created context will provide `GL_ARB_framebuffer_sRGB` or\n`GL_EXT_framebuffer_sRGB`.\n\n`GLFW_DOUBLEBUFFER` specifies whether the framebuffer should be double buffered.\nYou nearly always want to use double buffering.  This is a hard constraint.\n\n\n@subsubsection window_hints_mtr Monitor related hints\n\n`GLFW_REFRESH_RATE` specifies the desired refresh rate for full screen windows.\nIf set to `GLFW_DONT_CARE`, the highest available refresh rate will be used.\nThis hint is ignored for windowed mode windows.\n\n\n@subsubsection window_hints_ctx Context related hints\n\n`GLFW_CLIENT_API` specifies which client API to create the context for.\nPossible values are `GLFW_OPENGL_API` and `GLFW_OPENGL_ES_API`.  This is a hard\nconstraint.\n\n`GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` specify the client\nAPI version that the created context must be compatible with.  The exact\nbehavior of these hints depend on the requested client API.\n\n@par\n__OpenGL:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` are not hard\nconstraints, but creation will fail if the OpenGL version of the created context\nis less than the one requested.  It is therefore perfectly safe to use the\ndefault of version 1.0 for legacy code and you may still get\nbackwards-compatible contexts of version 3.0 and above when available.\n\n@par\nWhile there is no way to ask the driver for a context of the highest supported\nversion, GLFW will attempt to provide this when you ask for a version 1.0\ncontext, which is the default for these hints.\n\n@par\n__OpenGL ES:__ `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` are not hard\nconstraints, but creation will fail if the OpenGL ES version of the created\ncontext is less than the one requested.  Additionally, OpenGL ES 1.x cannot be\nreturned if 2.0 or later was requested, and vice versa.  This is because OpenGL\nES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward\ncompatible with 1.x.\n\n`GLFW_OPENGL_FORWARD_COMPAT` specifies whether the OpenGL context should be\nforward-compatible, i.e. one where all functionality deprecated in the requested\nversion of OpenGL is removed.  This may only be used if the requested OpenGL\nversion is 3.0 or above.  If OpenGL ES is requested, this hint is ignored.\n\n@par\nForward-compatibility is described in detail in the\n[OpenGL Reference Manual](https://www.opengl.org/registry/).\n\n`GLFW_OPENGL_DEBUG_CONTEXT` specifies whether to create a debug OpenGL context,\nwhich may have additional error and performance issue reporting functionality.\nIf OpenGL ES is requested, this hint is ignored.\n\n`GLFW_OPENGL_PROFILE` specifies which OpenGL profile to create the context for.\nPossible values are one of `GLFW_OPENGL_CORE_PROFILE` or\n`GLFW_OPENGL_COMPAT_PROFILE`, or `GLFW_OPENGL_ANY_PROFILE` to not request\na specific profile.  If requesting an OpenGL version below 3.2,\n`GLFW_OPENGL_ANY_PROFILE` must be used.  If OpenGL ES is requested,\nthis hint is ignored.\n\n@par\nOpenGL profiles are described in detail in the\n[OpenGL Reference Manual](https://www.opengl.org/registry/).\n\n`GLFW_CONTEXT_ROBUSTNESS` specifies the robustness strategy to be used by the\ncontext.  This can be one of `GLFW_NO_RESET_NOTIFICATION` or\n`GLFW_LOSE_CONTEXT_ON_RESET`, or `GLFW_NO_ROBUSTNESS` to not request\na robustness strategy.\n\n`GLFW_CONTEXT_RELEASE_BEHAVIOR` specifies the release behavior to be\nused by the context.  Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,\n`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`.  If the\nbehavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context\ncreation API will be used.  If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,\nthe pipeline will be flushed whenever the context is released from being the\ncurrent one.  If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will\nnot be flushed on release.\n\n@par\nContext release behaviors are described in detail by the\n[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt)\nextension.\n\n\n@subsubsection window_hints_values Supported and default values\n\nWindow hint                     | Default value               | Supported values\n------------------------------- | --------------------------- | ----------------\n`GLFW_RESIZABLE`                | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_VISIBLE`                  | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_DECORATED`                | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_FOCUSED`                  | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_AUTO_ICONIFY`             | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_FLOATING`                 | `GL_FALSE`                  | `GL_TRUE` or `GL_FALSE`\n`GLFW_RED_BITS`                 | 8                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_GREEN_BITS`               | 8                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_BLUE_BITS`                | 8                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_ALPHA_BITS`               | 8                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_DEPTH_BITS`               | 24                          | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_STENCIL_BITS`             | 8                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_ACCUM_RED_BITS`           | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_ACCUM_GREEN_BITS`         | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_ACCUM_BLUE_BITS`          | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_ACCUM_ALPHA_BITS`         | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_AUX_BUFFERS`              | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_SAMPLES`                  | 0                           | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_REFRESH_RATE`             | `GLFW_DONT_CARE`            | 0 to `INT_MAX` or `GLFW_DONT_CARE`\n`GLFW_STEREO`                   | `GL_FALSE`                  | `GL_TRUE` or `GL_FALSE`\n`GLFW_SRGB_CAPABLE`             | `GL_FALSE`                  | `GL_TRUE` or `GL_FALSE`\n`GLFW_DOUBLEBUFFER`             | `GL_TRUE`                   | `GL_TRUE` or `GL_FALSE`\n`GLFW_CLIENT_API`               | `GLFW_OPENGL_API`           | `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`\n`GLFW_CONTEXT_VERSION_MAJOR`    | 1                           | Any valid major version number of the chosen client API\n`GLFW_CONTEXT_VERSION_MINOR`    | 0                           | Any valid minor version number of the chosen client API\n`GLFW_CONTEXT_ROBUSTNESS`       | `GLFW_NO_ROBUSTNESS`        | `GLFW_NO_ROBUSTNESS`, `GLFW_NO_RESET_NOTIFICATION` or `GLFW_LOSE_CONTEXT_ON_RESET`\n`GLFW_CONTEXT_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_BEHAVIOR`, `GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`\n`GLFW_OPENGL_FORWARD_COMPAT`    | `GL_FALSE`                  | `GL_TRUE` or `GL_FALSE`\n`GLFW_OPENGL_DEBUG_CONTEXT`     | `GL_FALSE`                  | `GL_TRUE` or `GL_FALSE`\n`GLFW_OPENGL_PROFILE`           | `GLFW_OPENGL_ANY_PROFILE`   | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`\n\n\n@section window_events Window event processing\n\nSee @ref events.\n\n\n@section window_properties Window properties and events\n\n@subsection window_userptr User pointer\n\nEach window has a user pointer that can be set with @ref\nglfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer.  This\ncan be used for any purpose you need and will not be modified by GLFW throughout\nthe life-time of the window.\n\nThe initial value of the pointer is `NULL`.\n\n\n@subsection window_close Window closing and close flag\n\nWhen the user attempts to close the window, for example by clicking the close\nwidget or using a key chord like Alt+F4, the _close flag_ of the window is set.\nThe window is however not actually destroyed and, unless you watch for this\nstate change, nothing further happens.\n\nThe current state of the close flag is returned by @ref glfwWindowShouldClose\nand can be set or cleared directly with @ref glfwSetWindowShouldClose.  A common\npattern is to use the close flag as a main loop condition.\n\n@code\nwhile (!glfwWindowShouldClose(window))\n{\n    render(window);\n\n    glfwSwapBuffers(window);\n    glfwPollEvents();\n}\n@endcode\n\nIf you wish to be notified when the user attempts to close a window, set a close\ncallback.\n\n@code\nglfwSetWindowCloseCallback(window, window_close_callback);\n@endcode\n\nThe callback function is called directly _after_ the close flag has been set.\nIt can be used for example to filter close requests and clear the close flag\nagain unless certain conditions are met.\n\n@code\nvoid window_close_callback(GLFWwindow* window)\n{\n    if (!time_to_close)\n        glfwSetWindowShouldClose(window, GL_FALSE);\n}\n@endcode\n\n\n@subsection window_size Window size\n\nThe size of a window can be changed with @ref glfwSetWindowSize.  For windowed\nmode windows, this sets the size, in\n[screen coordinates](@ref coordinate_systems) of the _client area_ or _content\narea_ of the window.  The window system may impose limits on window size.\n\n@code\nglfwSetWindowSize(window, 640, 480);\n@endcode\n\nFor full screen windows, the specified size becomes the new resolution of the\nwindow's *desired video mode*.  The video mode most closely matching the new\ndesired video mode is set immediately.  The window is resized to fit the\nresolution of the set video mode.\n\nIf you wish to be notified when a window is resized, whether by the user or\nthe system, set a size callback.\n\n@code\nglfwSetWindowSizeCallback(window, window_size_callback);\n@endcode\n\nThe callback function receives the new size, in screen coordinates, of the\nclient area of the window when it is resized.\n\n@code\nvoid window_size_callback(GLFWwindow* window, int width, int height)\n{\n}\n@endcode\n\nThere is also @ref glfwGetWindowSize for directly retrieving the current size of\na window.\n\n@code\nint width, height;\nglfwGetWindowSize(window, &width, &height);\n@endcode\n\n@note Do not pass the window size to `glViewport` or other pixel-based OpenGL\ncalls.  The window size is in screen coordinates, not pixels.  Use the\n[framebuffer size](@ref window_fbsize), which is in pixels, for pixel-based\ncalls.\n\nThe above functions work with the size of the client area, but decorated windows\ntypically have title bars and window frames around this rectangle.  You can\nretrieve the extents of these with @ref glfwGetWindowFrameSize.\n\n@code\nint left, top, right, bottom;\nglfwGetWindowFrameSize(window, &left, &top, &right, &bottom);\n@endcode\n\nThe returned values are the distances, in screen coordinates, from the edges of\nthe client area to the corresponding edges of the full window.  As they are\ndistances and not coordinates, they are always zero or positive.\n\n\n@subsection window_fbsize Framebuffer size\n\nWhile the size of a window is measured in screen coordinates, OpenGL works with\npixels.  The size you pass into `glViewport`, for example, should be in pixels.\nOn some machines screen coordinates and pixels are the same, but on others they\nwill not be.  There is a second set of functions to retrieve the size, in\npixels, of the framebuffer of a window.\n\nIf you wish to be notified when the framebuffer of a window is resized, whether\nby the user or the system, set a size callback.\n\n@code\nglfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n@endcode\n\nThe callback function receives the new size of the framebuffer when it is\nresized, which can for example be used to update the OpenGL viewport.\n\n@code\nvoid framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n@endcode\n\nThere is also @ref glfwGetFramebufferSize for directly retrieving the current\nsize of the framebuffer of a window.\n\n@code\nint width, height;\nglfwGetFramebufferSize(window, &width, &height);\nglViewport(0, 0, width, height);\n@endcode\n\nThe size of a framebuffer may change independently of the size of a window, for\nexample if the window is dragged between a regular monitor and a high-DPI one.\n\n\n@subsection window_pos Window position\n\nThe position of a windowed-mode window can be changed with @ref\nglfwSetWindowPos.  This moves the window so that the upper-left corner of its\nclient area has the specified [screen coordinates](@ref coordinate_systems).\nThe window system may put limitations on window placement.\n\n@code\nglfwSetWindowPos(window, 100, 100);\n@endcode\n\nIf you wish to be notified when a window is moved, whether by the user, system\nor your own code, set a position callback.\n\n@code\nglfwSetWindowPosCallback(window, window_pos_callback);\n@endcode\n\nThe callback function receives the new position of the upper-left corner of the \nclient area when the window is moved.\n\n@code\nvoid window_pos_callback(GLFWwindow* window, int xpos, int ypos)\n{\n}\n@endcode\n\nThere is also @ref glfwGetWindowPos for directly retrieving the current position\nof the client area of the window.\n\n@code\nint xpos, ypos;\nglfwGetWindowPos(window, &xpos, &ypos);\n@endcode\n\n\n@subsection window_title Window title\n\nAll GLFW windows have a title, although undecorated or full screen windows may\nnot display it or only display it in a task bar or similar interface.  You can\nset a UTF-8 encoded window title with @ref glfwSetWindowTitle.\n\n@code\nglfwSetWindowTitle(window, \"My Window\");\n@endcode\n\nThe specified string is copied before the function returns, so there is no need\nto keep it around.\n\nAs long as your source file is encoded as UTF-8, you can use any Unicode\ncharacters directly in the source.\n\n@code\nglfwSetWindowTitle(window, \"プラネテス\");\n@endcode\n\n\n@subsection window_monitor Window monitor\n\nFull screen windows are associated with a specific monitor.  You can get the\nhandle for this monitor with @ref glfwGetWindowMonitor.\n\n@code\nGLFWmonitor* monitor = glfwGetWindowMonitor(window);\n@endcode\n\nThis monitor handle is one of those returned by @ref glfwGetMonitors.\n\nFor windowed mode windows, this function returns `NULL`.  This is the\nrecommended way to tell full screen windows from windowed mode windows.\n\n\n@subsection window_iconify Window iconification\n\nWindows can be iconified (i.e. minimized) with @ref glfwIconifyWindow.\n\n@code\nglfwIconifyWindow(window);\n@endcode\n\nWhen a full screen window is iconified, the original video mode of its monitor\nis restored until the user or application restores the window.\n\nIconified windows can be restored with @ref glfwRestoreWindow.\n\n@code\nglfwRestoreWindow(window);\n@endcode\n\nWhen a full screen window is restored, the desired video mode is restored to its\nmonitor as well.\n\nIf you wish to be notified when a window is iconified or restored, whether by\nthe user, system or your own code, set a iconify callback.\n\n@code\nglfwSetWindowIconifyCallback(window, window_iconify_callback);\n@endcode\n\nThe callback function receives changes in the iconification state of the window.\n\n@code\nvoid window_iconify_callback(GLFWwindow* window, int iconified)\n{\n    if (iconified)\n    {\n        // The window was iconified\n    }\n    else\n    {\n        // The window was restored\n    }\n}\n@endcode\n\nYou can also get the current iconification state with @ref glfwGetWindowAttrib.\n\n@code\nint iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED);\n@endcode\n\n\n@subsection window_hide Window visibility\n\nWindowed mode windows can be hidden with @ref glfwHideWindow.\n\n@code\nglfwHideWindow(window);\n@endcode\n\nThis makes the window completely invisible to the user, including removing it\nfrom the task bar, dock or window list.  Full screen windows cannot be hidden\nand calling @ref glfwHideWindow on a full screen window does nothing.\n\nHidden windows can be shown with @ref glfwShowWindow.\n\n@code\nglfwShowWindow(window);\n@endcode\n\nWindowed mode windows can be created initially hidden with the `GLFW_VISIBLE`\n[window hint](@ref window_hints_wnd).  Windows created hidden are completely\ninvisible to the user until shown.  This can be useful if you need to set up\nyour window further before showing it, for example moving it to a specific\nlocation.\n\nYou can also get the current visibility state with @ref glfwGetWindowAttrib.\n\n@code\nint visible = glfwGetWindowAttrib(window, GLFW_VISIBLE);\n@endcode\n\n\n@subsection window_focus Window input focus\n\nIf you wish to be notified when a window gains or loses input focus, whether by\nthe user, system or your own code, set a focus callback.\n\n@code\nglfwSetWindowFocusCallback(window, window_focus_callback);\n@endcode\n\nThe callback function receives changes in the input focus state of the window.\n\n@code\nvoid window_focus_callback(GLFWwindow* window, int focused)\n{\n    if (focused)\n    {\n        // The window gained input focus\n    }\n    else\n    {\n        // The window lost input focus\n    }\n}\n@endcode\n\nYou can also get the current input focus state with @ref glfwGetWindowAttrib.\n\n@code\nint focused = glfwGetWindowAttrib(window, GLFW_FOCUSED);\n@endcode\n\n\n@subsection window_refresh Window damage and refresh\n\nIf you wish to be notified when the contents of a window is damaged and needs\nto be refreshed, set a window refresh callback.\n\n@code\nglfwSetWindowRefreshCallback(m_handle, window_refresh_callback);\n@endcode\n\nThe callback function is called when the contents of the window needs to be\nrefreshed.\n\n@code\nvoid window_refresh_callback(GLFWwindow* window)\n{\n    draw_editor_ui(window);\n    glfwSwapBuffers(window);\n}\n@endcode\n\n@note On compositing window systems such as Aero, Compiz or Aqua, where the\nwindow contents are saved off-screen, this callback might only be called when\nthe window or framebuffer is resized.\n\n\n@subsection window_attribs Window attributes\n\nWindows have a number of attributes that can be returned using @ref\nglfwGetWindowAttrib.  Some reflect state that may change during the lifetime of\nthe window, while others reflect the corresponding hints and are fixed at the\ntime of creation.  Some are related to the actual window and others to its\ncontext.\n\n@code\nif (glfwGetWindowAttrib(window, GLFW_FOCUSED))\n{\n    // window has input focus\n}\n@endcode\n\n\n@subsubsection window_attribs_wnd Window related attributes\n\n`GLFW_FOCUSED` indicates whether the specified window has input focus.  Initial\ninput focus is controlled by the [window hint](@ref window_hints_wnd) with the\nsame name.   \n\n`GLFW_ICONIFIED` indicates whether the specified window is iconified, whether by\nthe user or with @ref glfwIconifyWindow.\n\n`GLFW_VISIBLE` indicates whether the specified window is visible.  Window\nvisibility can be controlled with @ref glfwShowWindow and @ref glfwHideWindow\nand initial visibility is controlled by the [window hint](@ref window_hints_wnd)\nwith the same name.  \n\n`GLFW_RESIZABLE` indicates whether the specified window is resizable _by the\nuser_.  This is set on creation with the [window hint](@ref window_hints_wnd)\n  with the same name.\n\n`GLFW_DECORATED` indicates whether the specified window has decorations such as\na border, a close widget, etc.  This is set on creation with the\n[window hint](@ref window_hints_wnd) with the same name. \n\n`GLFW_FLOATING` indicates whether the specified window is floating, also called\ntopmost or always-on-top.  This is controlled by the\n[window hint](@ref window_hints_wnd) with the same name. \n\n\n@subsubsection window_attribs_ctx Context related attributes\n\n`GLFW_CLIENT_API` indicates the client API provided by the window's context;\neither `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API`.\n\n`GLFW_CONTEXT_VERSION_MAJOR`, `GLFW_CONTEXT_VERSION_MINOR` and\n`GLFW_CONTEXT_REVISION` indicate the client API version of the window's context.\n\n`GLFW_OPENGL_FORWARD_COMPAT` is `GL_TRUE` if the window's context is an OpenGL\nforward-compatible one, or `GL_FALSE` otherwise.\n\n`GLFW_OPENGL_DEBUG_CONTEXT` is `GL_TRUE` if the window's context is an OpenGL\ndebug context, or `GL_FALSE` otherwise.\n\n`GLFW_OPENGL_PROFILE` indicates the OpenGL profile used by the context.  This is\n`GLFW_OPENGL_CORE_PROFILE` or `GLFW_OPENGL_COMPAT_PROFILE` if the context uses\na known profile, or `GLFW_OPENGL_ANY_PROFILE` if the OpenGL profile is unknown\nor the context is an OpenGL ES context.  Note that the returned profile may not\nmatch the profile bits of the context flags, as GLFW will try other means of\ndetecting the profile when no bits are set.\n\n`GLFW_CONTEXT_ROBUSTNESS` indicates the robustness strategy used by the context.\nThis is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION` if the\nwindow's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise.\n\n\n@subsubsection window_attribs_fb Framebuffer related attributes\n\nThe attributes of the default framebuffer (i.e. the framebuffer attached to the\nwindow) are not provided by this function but can be queried with both OpenGL\nand OpenGL ES.\n\nIf you are using version 3.0 or later of OpenGL or OpenGL ES, the\n`glGetFramebufferAttachmentParameteriv` function can be used to retrieve the\nnumber of bits for the red, green, blue, alpha, depth and stencil buffer\nchannels.  Otherwise, the `glGetIntegerv` function can be used.\n\nThe number of MSAA samples are always retrieved with `glGetIntegerv`.  For\ncontexts supporting framebuffer objects, the number of samples of the currently\nbound framebuffer is returned.\n\nAttribute    | glGetIntegerv     | glGetFramebufferAttachmentParameteriv\n------------ | ----------------- | -------------------------------------\nRed bits     | `GL_RED_BITS`     | `GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE`\nGreen bits   | `GL_GREEN_BITS`   | `GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE`\nBlue bits    | `GL_BLUE_BITS`    | `GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE`\nAlpha bits   | `GL_ALPHA_BITS`   | `GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE`\nDepth bits   | `GL_DEPTH_BITS`   | `GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE`\nStencil bits | `GL_STENCIL_BITS` | `GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE`\nMSAA samples | `GL_SAMPLES`      | _Not provided by this function_\n\nWhen calling `glGetFramebufferAttachmentParameteriv`, the red, green, blue and\nalpha sizes can be queried from the `GL_BACK_LEFT`, while the depth and stencil\nsizes can be queried from the `GL_DEPTH` and `GL_STENCIL` attachments,\nrespectively.\n\n\n@section buffer_swap Buffer swapping\n\nGLFW windows are by default double buffered.  That means that you have two\nrendering buffers; a front buffer and a back buffer.  The front buffer is\nthe one being displayed and the back buffer the one you render to.\n\nWhen the entire frame has been rendered, it is time to swap the back and the\nfront buffers in order to display what has been rendered and begin rendering\na new frame.  This is done with @ref glfwSwapBuffers.\n\n@code\nglfwSwapBuffers(window);\n@endcode\n\nSometimes it can be useful to select when the buffer swap will occur.  With the\nfunction @ref glfwSwapInterval it is possible to select the minimum number of\nmonitor refreshes the driver wait should from the time @ref glfwSwapBuffers was\ncalled before swapping the buffers:\n\n@code\nglfwSwapInterval(1);\n@endcode\n\nIf the interval is zero, the swap will take place immediately when @ref\nglfwSwapBuffers is called without waiting for a refresh.  Otherwise at least\ninterval retraces will pass between each buffer swap.  Using a swap interval of\nzero can be useful for benchmarking purposes, when it is not desirable to\nmeasure the time it takes to wait for the vertical retrace.  However, a swap\ninterval of one lets you avoid tearing.\n\nNote that this may not work on all machines, as some drivers have\nuser-controlled settings that override any swap interval the application\nrequests.\n\n*/\n"
  },
  {
    "path": "deps/glfw/examples/CMakeLists.txt",
    "content": "\nlink_libraries(glfw)\n\nif (BUILD_SHARED_LIBS)\n    add_definitions(-DGLFW_DLL)\n    link_libraries(\"${OPENGL_gl_LIBRARY}\" \"${MATH_LIBRARY}\")\nelse()\n    link_libraries(${glfw_LIBRARIES})\nendif()\n\ninclude_directories(\"${GLFW_SOURCE_DIR}/include\"\n                    \"${GLFW_SOURCE_DIR}/deps\")\n\nif (\"${OPENGL_INCLUDE_DIR}\")\n    include_directories(\"${OPENGL_INCLUDE_DIR}\")\nendif()\n\nset(GLAD \"${GLFW_SOURCE_DIR}/deps/glad/glad.h\"\n         \"${GLFW_SOURCE_DIR}/deps/glad.c\")\nset(GETOPT \"${GLFW_SOURCE_DIR}/deps/getopt.h\"\n           \"${GLFW_SOURCE_DIR}/deps/getopt.c\")\nset(TINYCTHREAD \"${GLFW_SOURCE_DIR}/deps/tinycthread.h\"\n                \"${GLFW_SOURCE_DIR}/deps/tinycthread.c\")\n\nadd_executable(boing WIN32 MACOSX_BUNDLE boing.c)\nadd_executable(gears WIN32 MACOSX_BUNDLE gears.c)\nadd_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${GLAD})\nadd_executable(particles WIN32 MACOSX_BUNDLE particles.c ${TINYCTHREAD} ${GETOPT})\nadd_executable(simple WIN32 MACOSX_BUNDLE simple.c)\nadd_executable(splitview WIN32 MACOSX_BUNDLE splitview.c)\nadd_executable(wave WIN32 MACOSX_BUNDLE wave.c)\n\ntarget_link_libraries(particles \"${CMAKE_THREAD_LIBS_INIT}\" \"${RT_LIBRARY}\")\n\nset(WINDOWS_BINARIES boing gears heightmap particles simple splitview wave)\n\nset_target_properties(${WINDOWS_BINARIES} PROPERTIES FOLDER \"GLFW3/Examples\")\n\nif (MSVC)\n    # Tell MSVC to use main instead of WinMain for Windows subsystem executables\n    set_target_properties(${WINDOWS_BINARIES} PROPERTIES\n                          LINK_FLAGS \"/ENTRY:mainCRTStartup\")\nendif()\n\nif (APPLE)\n    set_target_properties(boing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Boing\")\n    set_target_properties(gears PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Gears\")\n    set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Heightmap\")\n    set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Particles\")\n    set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Simple\")\n    set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Split View\")\n    set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Wave\")\n\n    set_target_properties(${WINDOWS_BINARIES} PROPERTIES\n                          MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}\n                          MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}\n                          MACOSX_BUNDLE_INFO_PLIST \"${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in\")\nendif()\n\n"
  },
  {
    "path": "deps/glfw/examples/boing.c",
    "content": "/*****************************************************************************\n * Title:   GLBoing\n * Desc:    Tribute to Amiga Boing.\n * Author:  Jim Brooks  <gfx@jimbrooks.org>\n *          Original Amiga authors were R.J. Mical and Dale Luck.\n *          GLFW conversion by Marcus Geelnard\n * Notes:   - 360' = 2*PI [radian]\n *\n *          - Distances between objects are created by doing a relative\n *            Z translations.\n *\n *          - Although OpenGL enticingly supports alpha-blending,\n *            the shadow of the original Boing didn't affect the color\n *            of the grid.\n *\n *          - [Marcus] Changed timing scheme from interval driven to frame-\n *            time based animation steps (which results in much smoother\n *            movement)\n *\n * History of Amiga Boing:\n *\n * Boing was demonstrated on the prototype Amiga (codenamed \"Lorraine\") in\n * 1985. According to legend, it was written ad-hoc in one night by\n * R. J. Mical and Dale Luck. Because the bouncing ball animation was so fast\n * and smooth, attendees did not believe the Amiga prototype was really doing\n * the rendering. Suspecting a trick, they began looking around the booth for\n * a hidden computer or VCR.\n *****************************************************************************/\n\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\n#include <GLFW/glfw3.h>\n\n#include <linmath.h>\n\n\n/*****************************************************************************\n * Various declarations and macros\n *****************************************************************************/\n\n/* Prototypes */\nvoid init( void );\nvoid display( void );\nvoid reshape( GLFWwindow* window, int w, int h );\nvoid key_callback( GLFWwindow* window, int key, int scancode, int action, int mods );\nvoid mouse_button_callback( GLFWwindow* window, int button, int action, int mods );\nvoid cursor_position_callback( GLFWwindow* window, double x, double y );\nvoid DrawBoingBall( void );\nvoid BounceBall( double dt );\nvoid DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi );\nvoid DrawGrid( void );\n\n#define RADIUS           70.f\n#define STEP_LONGITUDE   22.5f                   /* 22.5 makes 8 bands like original Boing */\n#define STEP_LATITUDE    22.5f\n\n#define DIST_BALL       (RADIUS * 2.f + RADIUS * 0.1f)\n\n#define VIEW_SCENE_DIST (DIST_BALL * 3.f + 200.f)/* distance from viewer to middle of boing area */\n#define GRID_SIZE       (RADIUS * 4.5f)          /* length (width) of grid */\n#define BOUNCE_HEIGHT   (RADIUS * 2.1f)\n#define BOUNCE_WIDTH    (RADIUS * 2.1f)\n\n#define SHADOW_OFFSET_X -20.f\n#define SHADOW_OFFSET_Y  10.f\n#define SHADOW_OFFSET_Z   0.f\n\n#define WALL_L_OFFSET   0.f\n#define WALL_R_OFFSET   5.f\n\n/* Animation speed (50.0 mimics the original GLUT demo speed) */\n#define ANIMATION_SPEED 50.f\n\n/* Maximum allowed delta time per physics iteration */\n#define MAX_DELTA_T 0.02f\n\n/* Draw ball, or its shadow */\ntypedef enum { DRAW_BALL, DRAW_BALL_SHADOW } DRAW_BALL_ENUM;\n\n/* Vertex type */\ntypedef struct {float x; float y; float z;} vertex_t;\n\n/* Global vars */\nint width, height;\nGLfloat deg_rot_y       = 0.f;\nGLfloat deg_rot_y_inc   = 2.f;\nGLboolean override_pos  = GL_FALSE;\nGLfloat cursor_x        = 0.f;\nGLfloat cursor_y        = 0.f;\nGLfloat ball_x          = -RADIUS;\nGLfloat ball_y          = -RADIUS;\nGLfloat ball_x_inc      = 1.f;\nGLfloat ball_y_inc      = 2.f;\nDRAW_BALL_ENUM drawBallHow;\ndouble  t;\ndouble  t_old = 0.f;\ndouble  dt;\n\n/* Random number generator */\n#ifndef RAND_MAX\n #define RAND_MAX 4095\n#endif\n\n\n/*****************************************************************************\n * Truncate a degree.\n *****************************************************************************/\nGLfloat TruncateDeg( GLfloat deg )\n{\n   if ( deg >= 360.f )\n      return (deg - 360.f);\n   else\n      return deg;\n}\n\n/*****************************************************************************\n * Convert a degree (360-based) into a radian.\n * 360' = 2 * PI\n *****************************************************************************/\ndouble deg2rad( double deg )\n{\n   return deg / 360 * (2 * M_PI);\n}\n\n/*****************************************************************************\n * 360' sin().\n *****************************************************************************/\ndouble sin_deg( double deg )\n{\n   return sin( deg2rad( deg ) );\n}\n\n/*****************************************************************************\n * 360' cos().\n *****************************************************************************/\ndouble cos_deg( double deg )\n{\n   return cos( deg2rad( deg ) );\n}\n\n/*****************************************************************************\n * Compute a cross product (for a normal vector).\n *\n * c = a x b\n *****************************************************************************/\nvoid CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n )\n{\n   GLfloat u1, u2, u3;\n   GLfloat v1, v2, v3;\n\n   u1 = b.x - a.x;\n   u2 = b.y - a.y;\n   u3 = b.y - a.z;\n\n   v1 = c.x - a.x;\n   v2 = c.y - a.y;\n   v3 = c.z - a.z;\n\n   n->x = u2 * v3 - v2 * v3;\n   n->y = u3 * v1 - v3 * u1;\n   n->z = u1 * v2 - v1 * u2;\n}\n\n\n#define BOING_DEBUG 0\n\n\n/*****************************************************************************\n * init()\n *****************************************************************************/\nvoid init( void )\n{\n   /*\n    * Clear background.\n    */\n   glClearColor( 0.55f, 0.55f, 0.55f, 0.f );\n\n   glShadeModel( GL_FLAT );\n}\n\n\n/*****************************************************************************\n * display()\n *****************************************************************************/\nvoid display(void)\n{\n   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );\n   glPushMatrix();\n\n   drawBallHow = DRAW_BALL_SHADOW;\n   DrawBoingBall();\n\n   DrawGrid();\n\n   drawBallHow = DRAW_BALL;\n   DrawBoingBall();\n\n   glPopMatrix();\n   glFlush();\n}\n\n\n/*****************************************************************************\n * reshape()\n *****************************************************************************/\nvoid reshape( GLFWwindow* window, int w, int h )\n{\n   mat4x4 projection, view;\n\n   glViewport( 0, 0, (GLsizei)w, (GLsizei)h );\n\n   glMatrixMode( GL_PROJECTION );\n   mat4x4_perspective( projection,\n                       2.f * (float) atan2( RADIUS, 200.f ),\n                       (float)w / (float)h,\n                       1.f, VIEW_SCENE_DIST );\n   glLoadMatrixf((const GLfloat*) projection);\n\n   glMatrixMode( GL_MODELVIEW );\n   {\n      vec3 eye = { 0.f, 0.f, VIEW_SCENE_DIST };\n      vec3 center = { 0.f, 0.f, 0.f };\n      vec3 up = { 0.f, -1.f, 0.f };\n      mat4x4_look_at( view, eye, center, up );\n   }\n   glLoadMatrixf((const GLfloat*) view);\n}\n\nvoid key_callback( GLFWwindow* window, int key, int scancode, int action, int mods )\n{\n    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\nstatic void set_ball_pos ( GLfloat x, GLfloat y )\n{\n   ball_x = (width / 2) - x;\n   ball_y = y - (height / 2);\n}\n\nvoid mouse_button_callback( GLFWwindow* window, int button, int action, int mods )\n{\n   if (button != GLFW_MOUSE_BUTTON_LEFT)\n      return;\n\n   if (action == GLFW_PRESS)\n   {\n      override_pos = GL_TRUE;\n      set_ball_pos(cursor_x, cursor_y);\n   }\n   else\n   {\n      override_pos = GL_FALSE;\n   }\n}\n\nvoid cursor_position_callback( GLFWwindow* window, double x, double y )\n{\n   cursor_x = (float) x;\n   cursor_y = (float) y;\n\n   if ( override_pos )\n      set_ball_pos(cursor_x, cursor_y);\n}\n\n/*****************************************************************************\n * Draw the Boing ball.\n *\n * The Boing ball is sphere in which each facet is a rectangle.\n * Facet colors alternate between red and white.\n * The ball is built by stacking latitudinal circles.  Each circle is composed\n * of a widely-separated set of points, so that each facet is noticably large.\n *****************************************************************************/\nvoid DrawBoingBall( void )\n{\n   GLfloat lon_deg;     /* degree of longitude */\n   double dt_total, dt2;\n\n   glPushMatrix();\n   glMatrixMode( GL_MODELVIEW );\n\n  /*\n   * Another relative Z translation to separate objects.\n   */\n   glTranslatef( 0.0, 0.0, DIST_BALL );\n\n   /* Update ball position and rotation (iterate if necessary) */\n   dt_total = dt;\n   while( dt_total > 0.0 )\n   {\n       dt2 = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;\n       dt_total -= dt2;\n       BounceBall( dt2 );\n       deg_rot_y = TruncateDeg( deg_rot_y + deg_rot_y_inc*((float)dt2*ANIMATION_SPEED) );\n   }\n\n   /* Set ball position */\n   glTranslatef( ball_x, ball_y, 0.0 );\n\n  /*\n   * Offset the shadow.\n   */\n   if ( drawBallHow == DRAW_BALL_SHADOW )\n   {\n      glTranslatef( SHADOW_OFFSET_X,\n                    SHADOW_OFFSET_Y,\n                    SHADOW_OFFSET_Z );\n   }\n\n  /*\n   * Tilt the ball.\n   */\n   glRotatef( -20.0, 0.0, 0.0, 1.0 );\n\n  /*\n   * Continually rotate ball around Y axis.\n   */\n   glRotatef( deg_rot_y, 0.0, 1.0, 0.0 );\n\n  /*\n   * Set OpenGL state for Boing ball.\n   */\n   glCullFace( GL_FRONT );\n   glEnable( GL_CULL_FACE );\n   glEnable( GL_NORMALIZE );\n\n  /*\n   * Build a faceted latitude slice of the Boing ball,\n   * stepping same-sized vertical bands of the sphere.\n   */\n   for ( lon_deg = 0;\n         lon_deg < 180;\n         lon_deg += STEP_LONGITUDE )\n   {\n     /*\n      * Draw a latitude circle at this longitude.\n      */\n      DrawBoingBallBand( lon_deg,\n                         lon_deg + STEP_LONGITUDE );\n   }\n\n   glPopMatrix();\n\n   return;\n}\n\n\n/*****************************************************************************\n * Bounce the ball.\n *****************************************************************************/\nvoid BounceBall( double delta_t )\n{\n   GLfloat sign;\n   GLfloat deg;\n\n   if ( override_pos )\n     return;\n\n   /* Bounce on walls */\n   if ( ball_x >  (BOUNCE_WIDTH/2 + WALL_R_OFFSET ) )\n   {\n      ball_x_inc = -0.5f - 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX;\n      deg_rot_y_inc = -deg_rot_y_inc;\n   }\n   if ( ball_x < -(BOUNCE_HEIGHT/2 + WALL_L_OFFSET) )\n   {\n      ball_x_inc =  0.5f + 0.75f * (GLfloat)rand() / (GLfloat)RAND_MAX;\n      deg_rot_y_inc = -deg_rot_y_inc;\n   }\n\n   /* Bounce on floor / roof */\n   if ( ball_y >  BOUNCE_HEIGHT/2      )\n   {\n      ball_y_inc = -0.75f - 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX;\n   }\n   if ( ball_y < -BOUNCE_HEIGHT/2*0.85 )\n   {\n      ball_y_inc =  0.75f + 1.f * (GLfloat)rand() / (GLfloat)RAND_MAX;\n   }\n\n   /* Update ball position */\n   ball_x += ball_x_inc * ((float)delta_t*ANIMATION_SPEED);\n   ball_y += ball_y_inc * ((float)delta_t*ANIMATION_SPEED);\n\n  /*\n   * Simulate the effects of gravity on Y movement.\n   */\n   if ( ball_y_inc < 0 ) sign = -1.0; else sign = 1.0;\n\n   deg = (ball_y + BOUNCE_HEIGHT/2) * 90 / BOUNCE_HEIGHT;\n   if ( deg > 80 ) deg = 80;\n   if ( deg < 10 ) deg = 10;\n\n   ball_y_inc = sign * 4.f * (float) sin_deg( deg );\n}\n\n\n/*****************************************************************************\n * Draw a faceted latitude band of the Boing ball.\n *\n * Parms:   long_lo, long_hi\n *          Low and high longitudes of slice, resp.\n *****************************************************************************/\nvoid DrawBoingBallBand( GLfloat long_lo,\n                        GLfloat long_hi )\n{\n   vertex_t vert_ne;            /* \"ne\" means south-east, so on */\n   vertex_t vert_nw;\n   vertex_t vert_sw;\n   vertex_t vert_se;\n   vertex_t vert_norm;\n   GLfloat  lat_deg;\n   static int colorToggle = 0;\n\n  /*\n   * Iterate thru the points of a latitude circle.\n   * A latitude circle is a 2D set of X,Z points.\n   */\n   for ( lat_deg = 0;\n         lat_deg <= (360 - STEP_LATITUDE);\n         lat_deg += STEP_LATITUDE )\n   {\n     /*\n      * Color this polygon with red or white.\n      */\n      if ( colorToggle )\n         glColor3f( 0.8f, 0.1f, 0.1f );\n      else\n         glColor3f( 0.95f, 0.95f, 0.95f );\n#if 0\n      if ( lat_deg >= 180 )\n         if ( colorToggle )\n            glColor3f( 0.1f, 0.8f, 0.1f );\n         else\n            glColor3f( 0.5f, 0.5f, 0.95f );\n#endif\n      colorToggle = ! colorToggle;\n\n     /*\n      * Change color if drawing shadow.\n      */\n      if ( drawBallHow == DRAW_BALL_SHADOW )\n         glColor3f( 0.35f, 0.35f, 0.35f );\n\n     /*\n      * Assign each Y.\n      */\n      vert_ne.y = vert_nw.y = (float) cos_deg(long_hi) * RADIUS;\n      vert_sw.y = vert_se.y = (float) cos_deg(long_lo) * RADIUS;\n\n     /*\n      * Assign each X,Z with sin,cos values scaled by latitude radius indexed by longitude.\n      * Eg, long=0 and long=180 are at the poles, so zero scale is sin(longitude),\n      * while long=90 (sin(90)=1) is at equator.\n      */\n      vert_ne.x = (float) cos_deg( lat_deg                 ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));\n      vert_se.x = (float) cos_deg( lat_deg                 ) * (RADIUS * (float) sin_deg( long_lo                  ));\n      vert_nw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));\n      vert_sw.x = (float) cos_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo                  ));\n\n      vert_ne.z = (float) sin_deg( lat_deg                 ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));\n      vert_se.z = (float) sin_deg( lat_deg                 ) * (RADIUS * (float) sin_deg( long_lo                  ));\n      vert_nw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo + STEP_LONGITUDE ));\n      vert_sw.z = (float) sin_deg( lat_deg + STEP_LATITUDE ) * (RADIUS * (float) sin_deg( long_lo                  ));\n\n     /*\n      * Draw the facet.\n      */\n      glBegin( GL_POLYGON );\n\n      CrossProduct( vert_ne, vert_nw, vert_sw, &vert_norm );\n      glNormal3f( vert_norm.x, vert_norm.y, vert_norm.z );\n\n      glVertex3f( vert_ne.x, vert_ne.y, vert_ne.z );\n      glVertex3f( vert_nw.x, vert_nw.y, vert_nw.z );\n      glVertex3f( vert_sw.x, vert_sw.y, vert_sw.z );\n      glVertex3f( vert_se.x, vert_se.y, vert_se.z );\n\n      glEnd();\n\n#if BOING_DEBUG\n      printf( \"----------------------------------------------------------- \\n\" );\n      printf( \"lat = %f  long_lo = %f  long_hi = %f \\n\", lat_deg, long_lo, long_hi );\n      printf( \"vert_ne  x = %.8f  y = %.8f  z = %.8f \\n\", vert_ne.x, vert_ne.y, vert_ne.z );\n      printf( \"vert_nw  x = %.8f  y = %.8f  z = %.8f \\n\", vert_nw.x, vert_nw.y, vert_nw.z );\n      printf( \"vert_se  x = %.8f  y = %.8f  z = %.8f \\n\", vert_se.x, vert_se.y, vert_se.z );\n      printf( \"vert_sw  x = %.8f  y = %.8f  z = %.8f \\n\", vert_sw.x, vert_sw.y, vert_sw.z );\n#endif\n\n   }\n\n  /*\n   * Toggle color so that next band will opposite red/white colors than this one.\n   */\n   colorToggle = ! colorToggle;\n\n  /*\n   * This circular band is done.\n   */\n   return;\n}\n\n\n/*****************************************************************************\n * Draw the purple grid of lines, behind the Boing ball.\n * When the Workbench is dropped to the bottom, Boing shows 12 rows.\n *****************************************************************************/\nvoid DrawGrid( void )\n{\n   int              row, col;\n   const int        rowTotal    = 12;                   /* must be divisible by 2 */\n   const int        colTotal    = rowTotal;             /* must be same as rowTotal */\n   const GLfloat    widthLine   = 2.0;                  /* should be divisible by 2 */\n   const GLfloat    sizeCell    = GRID_SIZE / rowTotal;\n   const GLfloat    z_offset    = -40.0;\n   GLfloat          xl, xr;\n   GLfloat          yt, yb;\n\n   glPushMatrix();\n   glDisable( GL_CULL_FACE );\n\n  /*\n   * Another relative Z translation to separate objects.\n   */\n   glTranslatef( 0.0, 0.0, DIST_BALL );\n\n  /*\n   * Draw vertical lines (as skinny 3D rectangles).\n   */\n   for ( col = 0; col <= colTotal; col++ )\n   {\n     /*\n      * Compute co-ords of line.\n      */\n      xl = -GRID_SIZE / 2 + col * sizeCell;\n      xr = xl + widthLine;\n\n      yt =  GRID_SIZE / 2;\n      yb = -GRID_SIZE / 2 - widthLine;\n\n      glBegin( GL_POLYGON );\n\n      glColor3f( 0.6f, 0.1f, 0.6f );               /* purple */\n\n      glVertex3f( xr, yt, z_offset );       /* NE */\n      glVertex3f( xl, yt, z_offset );       /* NW */\n      glVertex3f( xl, yb, z_offset );       /* SW */\n      glVertex3f( xr, yb, z_offset );       /* SE */\n\n      glEnd();\n   }\n\n  /*\n   * Draw horizontal lines (as skinny 3D rectangles).\n   */\n   for ( row = 0; row <= rowTotal; row++ )\n   {\n     /*\n      * Compute co-ords of line.\n      */\n      yt = GRID_SIZE / 2 - row * sizeCell;\n      yb = yt - widthLine;\n\n      xl = -GRID_SIZE / 2;\n      xr =  GRID_SIZE / 2 + widthLine;\n\n      glBegin( GL_POLYGON );\n\n      glColor3f( 0.6f, 0.1f, 0.6f );               /* purple */\n\n      glVertex3f( xr, yt, z_offset );       /* NE */\n      glVertex3f( xl, yt, z_offset );       /* NW */\n      glVertex3f( xl, yb, z_offset );       /* SW */\n      glVertex3f( xr, yb, z_offset );       /* SE */\n\n      glEnd();\n   }\n\n   glPopMatrix();\n\n   return;\n}\n\n\n/*======================================================================*\n * main()\n *======================================================================*/\n\nint main( void )\n{\n   GLFWwindow* window;\n\n   /* Init GLFW */\n   if( !glfwInit() )\n      exit( EXIT_FAILURE );\n\n   glfwWindowHint(GLFW_DEPTH_BITS, 16);\n\n   window = glfwCreateWindow( 400, 400, \"Boing (classic Amiga demo)\", NULL, NULL );\n   if (!window)\n   {\n       glfwTerminate();\n       exit( EXIT_FAILURE );\n   }\n\n   glfwSetFramebufferSizeCallback(window, reshape);\n   glfwSetKeyCallback(window, key_callback);\n   glfwSetMouseButtonCallback(window, mouse_button_callback);\n   glfwSetCursorPosCallback(window, cursor_position_callback);\n\n   glfwMakeContextCurrent(window);\n   glfwSwapInterval( 1 );\n\n   glfwGetFramebufferSize(window, &width, &height);\n   reshape(window, width, height);\n\n   glfwSetTime( 0.0 );\n\n   init();\n\n   /* Main loop */\n   for (;;)\n   {\n       /* Timing */\n       t = glfwGetTime();\n       dt = t - t_old;\n       t_old = t;\n\n       /* Draw one frame */\n       display();\n\n       /* Swap buffers */\n       glfwSwapBuffers(window);\n       glfwPollEvents();\n\n       /* Check if we are still running */\n       if (glfwWindowShouldClose(window))\n           break;\n   }\n\n   glfwTerminate();\n   exit( EXIT_SUCCESS );\n}\n\n"
  },
  {
    "path": "deps/glfw/examples/gears.c",
    "content": "/*\n * 3-D gear wheels.  This program is in the public domain.\n *\n * Command line options:\n *    -info      print GL implementation information\n *    -exit      automatically exit after 30 seconds\n *\n *\n * Brian Paul\n *\n *\n * Marcus Geelnard:\n *   - Conversion to GLFW\n *   - Time based rendering (frame rate independent)\n *   - Slightly modified camera that should work better for stereo viewing\n *\n *\n * Camilla Berglund:\n *   - Removed FPS counter (this is not a benchmark)\n *   - Added a few comments\n *   - Enabled vsync\n */\n\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#include <math.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <GLFW/glfw3.h>\n\n/**\n\n  Draw a gear wheel.  You'll probably want to call this function when\n  building a display list since we do a lot of trig here.\n\n  Input:  inner_radius - radius of hole at center\n          outer_radius - radius at center of teeth\n          width - width of gear teeth - number of teeth\n          tooth_depth - depth of tooth\n\n **/\n\nstatic void\ngear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,\n  GLint teeth, GLfloat tooth_depth)\n{\n  GLint i;\n  GLfloat r0, r1, r2;\n  GLfloat angle, da;\n  GLfloat u, v, len;\n\n  r0 = inner_radius;\n  r1 = outer_radius - tooth_depth / 2.f;\n  r2 = outer_radius + tooth_depth / 2.f;\n\n  da = 2.f * (float) M_PI / teeth / 4.f;\n\n  glShadeModel(GL_FLAT);\n\n  glNormal3f(0.f, 0.f, 1.f);\n\n  /* draw front face */\n  glBegin(GL_QUAD_STRIP);\n  for (i = 0; i <= teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n    glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);\n    if (i < teeth) {\n      glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);\n      glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);\n    }\n  }\n  glEnd();\n\n  /* draw front sides of teeth */\n  glBegin(GL_QUADS);\n  da = 2.f * (float) M_PI / teeth / 4.f;\n  for (i = 0; i < teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f);\n    glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);\n  }\n  glEnd();\n\n  glNormal3f(0.0, 0.0, -1.0);\n\n  /* draw back face */\n  glBegin(GL_QUAD_STRIP);\n  for (i = 0; i <= teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);\n    glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);\n    if (i < teeth) {\n      glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);\n      glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);\n    }\n  }\n  glEnd();\n\n  /* draw back sides of teeth */\n  glBegin(GL_QUADS);\n  da = 2.f * (float) M_PI / teeth / 4.f;\n  for (i = 0; i < teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n\n    glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f);\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);\n  }\n  glEnd();\n\n  /* draw outward faces of teeth */\n  glBegin(GL_QUAD_STRIP);\n  for (i = 0; i < teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), width * 0.5f);\n    glVertex3f(r1 * (float) cos(angle), r1 * (float) sin(angle), -width * 0.5f);\n    u = r2 * (float) cos(angle + da) - r1 * (float) cos(angle);\n    v = r2 * (float) sin(angle + da) - r1 * (float) sin(angle);\n    len = (float) sqrt(u * u + v * v);\n    u /= len;\n    v /= len;\n    glNormal3f(v, -u, 0.0);\n    glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + da), r2 * (float) sin(angle + da), -width * 0.5f);\n    glNormal3f((float) cos(angle), (float) sin(angle), 0.f);\n    glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), width * 0.5f);\n    glVertex3f(r2 * (float) cos(angle + 2 * da), r2 * (float) sin(angle + 2 * da), -width * 0.5f);\n    u = r1 * (float) cos(angle + 3 * da) - r2 * (float) cos(angle + 2 * da);\n    v = r1 * (float) sin(angle + 3 * da) - r2 * (float) sin(angle + 2 * da);\n    glNormal3f(v, -u, 0.f);\n    glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), width * 0.5f);\n    glVertex3f(r1 * (float) cos(angle + 3 * da), r1 * (float) sin(angle + 3 * da), -width * 0.5f);\n    glNormal3f((float) cos(angle), (float) sin(angle), 0.f);\n  }\n\n  glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), width * 0.5f);\n  glVertex3f(r1 * (float) cos(0), r1 * (float) sin(0), -width * 0.5f);\n\n  glEnd();\n\n  glShadeModel(GL_SMOOTH);\n\n  /* draw inside radius cylinder */\n  glBegin(GL_QUAD_STRIP);\n  for (i = 0; i <= teeth; i++) {\n    angle = i * 2.f * (float) M_PI / teeth;\n    glNormal3f(-(float) cos(angle), -(float) sin(angle), 0.f);\n    glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), -width * 0.5f);\n    glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f);\n  }\n  glEnd();\n\n}\n\n\nstatic GLfloat view_rotx = 20.f, view_roty = 30.f, view_rotz = 0.f;\nstatic GLint gear1, gear2, gear3;\nstatic GLfloat angle = 0.f;\n\n/* OpenGL draw function & timing */\nstatic void draw(void)\n{\n  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\n  glPushMatrix();\n    glRotatef(view_rotx, 1.0, 0.0, 0.0);\n    glRotatef(view_roty, 0.0, 1.0, 0.0);\n    glRotatef(view_rotz, 0.0, 0.0, 1.0);\n\n    glPushMatrix();\n      glTranslatef(-3.0, -2.0, 0.0);\n      glRotatef(angle, 0.0, 0.0, 1.0);\n      glCallList(gear1);\n    glPopMatrix();\n\n    glPushMatrix();\n      glTranslatef(3.1f, -2.f, 0.f);\n      glRotatef(-2.f * angle - 9.f, 0.f, 0.f, 1.f);\n      glCallList(gear2);\n    glPopMatrix();\n\n    glPushMatrix();\n      glTranslatef(-3.1f, 4.2f, 0.f);\n      glRotatef(-2.f * angle - 25.f, 0.f, 0.f, 1.f);\n      glCallList(gear3);\n    glPopMatrix();\n\n  glPopMatrix();\n}\n\n\n/* update animation parameters */\nstatic void animate(void)\n{\n  angle = 100.f * (float) glfwGetTime();\n}\n\n\n/* change view angle, exit upon ESC */\nvoid key( GLFWwindow* window, int k, int s, int action, int mods )\n{\n  if( action != GLFW_PRESS ) return;\n\n  switch (k) {\n  case GLFW_KEY_Z:\n    if( mods & GLFW_MOD_SHIFT )\n      view_rotz -= 5.0;\n    else\n      view_rotz += 5.0;\n    break;\n  case GLFW_KEY_ESCAPE:\n    glfwSetWindowShouldClose(window, GL_TRUE);\n    break;\n  case GLFW_KEY_UP:\n    view_rotx += 5.0;\n    break;\n  case GLFW_KEY_DOWN:\n    view_rotx -= 5.0;\n    break;\n  case GLFW_KEY_LEFT:\n    view_roty += 5.0;\n    break;\n  case GLFW_KEY_RIGHT:\n    view_roty -= 5.0;\n    break;\n  default:\n    return;\n  }\n}\n\n\n/* new window size */\nvoid reshape( GLFWwindow* window, int width, int height )\n{\n  GLfloat h = (GLfloat) height / (GLfloat) width;\n  GLfloat xmax, znear, zfar;\n\n  znear = 5.0f;\n  zfar  = 30.0f;\n  xmax  = znear * 0.5f;\n\n  glViewport( 0, 0, (GLint) width, (GLint) height );\n  glMatrixMode( GL_PROJECTION );\n  glLoadIdentity();\n  glFrustum( -xmax, xmax, -xmax*h, xmax*h, znear, zfar );\n  glMatrixMode( GL_MODELVIEW );\n  glLoadIdentity();\n  glTranslatef( 0.0, 0.0, -20.0 );\n}\n\n\n/* program & OpenGL initialization */\nstatic void init(void)\n{\n  static GLfloat pos[4] = {5.f, 5.f, 10.f, 0.f};\n  static GLfloat red[4] = {0.8f, 0.1f, 0.f, 1.f};\n  static GLfloat green[4] = {0.f, 0.8f, 0.2f, 1.f};\n  static GLfloat blue[4] = {0.2f, 0.2f, 1.f, 1.f};\n\n  glLightfv(GL_LIGHT0, GL_POSITION, pos);\n  glEnable(GL_CULL_FACE);\n  glEnable(GL_LIGHTING);\n  glEnable(GL_LIGHT0);\n  glEnable(GL_DEPTH_TEST);\n\n  /* make the gears */\n  gear1 = glGenLists(1);\n  glNewList(gear1, GL_COMPILE);\n  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);\n  gear(1.f, 4.f, 1.f, 20, 0.7f);\n  glEndList();\n\n  gear2 = glGenLists(1);\n  glNewList(gear2, GL_COMPILE);\n  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);\n  gear(0.5f, 2.f, 2.f, 10, 0.7f);\n  glEndList();\n\n  gear3 = glGenLists(1);\n  glNewList(gear3, GL_COMPILE);\n  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);\n  gear(1.3f, 2.f, 0.5f, 10, 0.7f);\n  glEndList();\n\n  glEnable(GL_NORMALIZE);\n}\n\n\n/* program entry */\nint main(int argc, char *argv[])\n{\n    GLFWwindow* window;\n    int width, height;\n\n    if( !glfwInit() )\n    {\n        fprintf( stderr, \"Failed to initialize GLFW\\n\" );\n        exit( EXIT_FAILURE );\n    }\n\n    glfwWindowHint(GLFW_DEPTH_BITS, 16);\n\n    window = glfwCreateWindow( 300, 300, \"Gears\", NULL, NULL );\n    if (!window)\n    {\n        fprintf( stderr, \"Failed to open GLFW window\\n\" );\n        glfwTerminate();\n        exit( EXIT_FAILURE );\n    }\n\n    // Set callback functions\n    glfwSetFramebufferSizeCallback(window, reshape);\n    glfwSetKeyCallback(window, key);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval( 1 );\n\n    glfwGetFramebufferSize(window, &width, &height);\n    reshape(window, width, height);\n\n    // Parse command-line options\n    init();\n\n    // Main loop\n    while( !glfwWindowShouldClose(window) )\n    {\n        // Draw gears\n        draw();\n\n        // Update animation\n        animate();\n\n        // Swap buffers\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n    }\n\n    // Terminate GLFW\n    glfwTerminate();\n\n    // Exit program\n    exit( EXIT_SUCCESS );\n}\n\n"
  },
  {
    "path": "deps/glfw/examples/heightmap.c",
    "content": "//========================================================================\n// Heightmap example program using OpenGL 3 core profile\n// Copyright (c) 2010 Olivier Delannoy\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <math.h>\n#include <assert.h>\n#include <stddef.h>\n\n#include <glad/glad.h>\n#include <GLFW/glfw3.h>\n\n/* Map height updates */\n#define MAX_CIRCLE_SIZE (5.0f)\n#define MAX_DISPLACEMENT (1.0f)\n#define DISPLACEMENT_SIGN_LIMIT (0.3f)\n#define MAX_ITER (200)\n#define NUM_ITER_AT_A_TIME (1)\n\n/* Map general information */\n#define MAP_SIZE (10.0f)\n#define MAP_NUM_VERTICES (80)\n#define MAP_NUM_TOTAL_VERTICES (MAP_NUM_VERTICES*MAP_NUM_VERTICES)\n#define MAP_NUM_LINES (3* (MAP_NUM_VERTICES - 1) * (MAP_NUM_VERTICES - 1) + \\\n               2 * (MAP_NUM_VERTICES - 1))\n\n\n/**********************************************************************\n * Default shader programs\n *********************************************************************/\n\nstatic const char* vertex_shader_text =\n\"#version 150\\n\"\n\"uniform mat4 project;\\n\"\n\"uniform mat4 modelview;\\n\"\n\"in float x;\\n\"\n\"in float y;\\n\"\n\"in float z;\\n\"\n\"\\n\"\n\"void main()\\n\"\n\"{\\n\"\n\"   gl_Position = project * modelview * vec4(x, y, z, 1.0);\\n\"\n\"}\\n\";\n\nstatic const char* fragment_shader_text =\n\"#version 150\\n\"\n\"out vec4 color;\\n\"\n\"void main()\\n\"\n\"{\\n\"\n\"    color = vec4(0.2, 1.0, 0.2, 1.0); \\n\"\n\"}\\n\";\n\n/**********************************************************************\n * Values for shader uniforms\n *********************************************************************/\n\n/* Frustum configuration */\nstatic GLfloat view_angle = 45.0f;\nstatic GLfloat aspect_ratio = 4.0f/3.0f;\nstatic GLfloat z_near = 1.0f;\nstatic GLfloat z_far = 100.f;\n\n/* Projection matrix */\nstatic GLfloat projection_matrix[16] = {\n    1.0f, 0.0f, 0.0f, 0.0f,\n    0.0f, 1.0f, 0.0f, 0.0f,\n    0.0f, 0.0f, 1.0f, 0.0f,\n    0.0f, 0.0f, 0.0f, 1.0f\n};\n\n/* Model view matrix */\nstatic GLfloat modelview_matrix[16] = {\n    1.0f, 0.0f, 0.0f, 0.0f,\n    0.0f, 1.0f, 0.0f, 0.0f,\n    0.0f, 0.0f, 1.0f, 0.0f,\n    0.0f, 0.0f, 0.0f, 1.0f\n};\n\n/**********************************************************************\n * Heightmap vertex and index data\n *********************************************************************/\n\nstatic GLfloat map_vertices[3][MAP_NUM_TOTAL_VERTICES];\nstatic GLuint  map_line_indices[2*MAP_NUM_LINES];\n\n/* Store uniform location for the shaders\n * Those values are setup as part of the process of creating\n * the shader program. They should not be used before creating\n * the program.\n */\nstatic GLuint mesh;\nstatic GLuint mesh_vbo[4];\n\n/**********************************************************************\n * OpenGL helper functions\n *********************************************************************/\n\n/* Creates a shader object of the specified type using the specified text\n */\nstatic GLuint make_shader(GLenum type, const char* text)\n{\n    GLuint shader;\n    GLint shader_ok;\n    GLsizei log_length;\n    char info_log[8192];\n\n    shader = glCreateShader(type);\n    if (shader != 0)\n    {\n        glShaderSource(shader, 1, (const GLchar**)&text, NULL);\n        glCompileShader(shader);\n        glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_ok);\n        if (shader_ok != GL_TRUE)\n        {\n            fprintf(stderr, \"ERROR: Failed to compile %s shader\\n\", (type == GL_FRAGMENT_SHADER) ? \"fragment\" : \"vertex\" );\n            glGetShaderInfoLog(shader, 8192, &log_length,info_log);\n            fprintf(stderr, \"ERROR: \\n%s\\n\\n\", info_log);\n            glDeleteShader(shader);\n            shader = 0;\n        }\n    }\n    return shader;\n}\n\n/* Creates a program object using the specified vertex and fragment text\n */\nstatic GLuint make_shader_program(const char* vs_text, const char* fs_text)\n{\n    GLuint program = 0u;\n    GLint program_ok;\n    GLuint vertex_shader = 0u;\n    GLuint fragment_shader = 0u;\n    GLsizei log_length;\n    char info_log[8192];\n\n    vertex_shader = make_shader(GL_VERTEX_SHADER, vs_text);\n    if (vertex_shader != 0u)\n    {\n        fragment_shader = make_shader(GL_FRAGMENT_SHADER, fs_text);\n        if (fragment_shader != 0u)\n        {\n            /* make the program that connect the two shader and link it */\n            program = glCreateProgram();\n            if (program != 0u)\n            {\n                /* attach both shader and link */\n                glAttachShader(program, vertex_shader);\n                glAttachShader(program, fragment_shader);\n                glLinkProgram(program);\n                glGetProgramiv(program, GL_LINK_STATUS, &program_ok);\n\n                if (program_ok != GL_TRUE)\n                {\n                    fprintf(stderr, \"ERROR, failed to link shader program\\n\");\n                    glGetProgramInfoLog(program, 8192, &log_length, info_log);\n                    fprintf(stderr, \"ERROR: \\n%s\\n\\n\", info_log);\n                    glDeleteProgram(program);\n                    glDeleteShader(fragment_shader);\n                    glDeleteShader(vertex_shader);\n                    program = 0u;\n                }\n            }\n        }\n        else\n        {\n            fprintf(stderr, \"ERROR: Unable to load fragment shader\\n\");\n            glDeleteShader(vertex_shader);\n        }\n    }\n    else\n    {\n        fprintf(stderr, \"ERROR: Unable to load vertex shader\\n\");\n    }\n    return program;\n}\n\n/**********************************************************************\n * Geometry creation functions\n *********************************************************************/\n\n/* Generate vertices and indices for the heightmap\n */\nstatic void init_map(void)\n{\n    int i;\n    int j;\n    int k;\n    GLfloat step = MAP_SIZE / (MAP_NUM_VERTICES - 1);\n    GLfloat x = 0.0f;\n    GLfloat z = 0.0f;\n    /* Create a flat grid */\n    k = 0;\n    for (i = 0 ; i < MAP_NUM_VERTICES ; ++i)\n    {\n        for (j = 0 ; j < MAP_NUM_VERTICES ; ++j)\n        {\n            map_vertices[0][k] = x;\n            map_vertices[1][k] = 0.0f;\n            map_vertices[2][k] = z;\n            z += step;\n            ++k;\n        }\n        x += step;\n        z = 0.0f;\n    }\n#if DEBUG_ENABLED\n    for (i = 0 ; i < MAP_NUM_TOTAL_VERTICES ; ++i)\n    {\n        printf (\"Vertice %d (%f, %f, %f)\\n\",\n                i, map_vertices[0][i], map_vertices[1][i], map_vertices[2][i]);\n\n    }\n#endif\n    /* create indices */\n    /* line fan based on i\n     * i+1\n     * |  / i + n + 1\n     * | /\n     * |/\n     * i --- i + n\n     */\n\n    /* close the top of the square */\n    k = 0;\n    for (i = 0 ; i < MAP_NUM_VERTICES  -1 ; ++i)\n    {\n        map_line_indices[k++] = (i + 1) * MAP_NUM_VERTICES -1;\n        map_line_indices[k++] = (i + 2) * MAP_NUM_VERTICES -1;\n    }\n    /* close the right of the square */\n    for (i = 0 ; i < MAP_NUM_VERTICES -1 ; ++i)\n    {\n        map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i;\n        map_line_indices[k++] = (MAP_NUM_VERTICES - 1) * MAP_NUM_VERTICES + i + 1;\n    }\n\n    for (i = 0 ; i < (MAP_NUM_VERTICES - 1) ; ++i)\n    {\n        for (j = 0 ; j < (MAP_NUM_VERTICES - 1) ; ++j)\n        {\n            int ref = i * (MAP_NUM_VERTICES) + j;\n            map_line_indices[k++] = ref;\n            map_line_indices[k++] = ref + 1;\n\n            map_line_indices[k++] = ref;\n            map_line_indices[k++] = ref + MAP_NUM_VERTICES;\n\n            map_line_indices[k++] = ref;\n            map_line_indices[k++] = ref + MAP_NUM_VERTICES + 1;\n        }\n    }\n\n#ifdef DEBUG_ENABLED\n    for (k = 0 ; k < 2 * MAP_NUM_LINES ; k += 2)\n    {\n        int beg, end;\n        beg = map_line_indices[k];\n        end = map_line_indices[k+1];\n        printf (\"Line %d: %d -> %d (%f, %f, %f) -> (%f, %f, %f)\\n\",\n                k / 2, beg, end,\n                map_vertices[0][beg], map_vertices[1][beg], map_vertices[2][beg],\n                map_vertices[0][end], map_vertices[1][end], map_vertices[2][end]);\n    }\n#endif\n}\n\nstatic void generate_heightmap__circle(float* center_x, float* center_y,\n        float* size, float* displacement)\n{\n    float sign;\n    /* random value for element in between [0-1.0] */\n    *center_x = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);\n    *center_y = (MAP_SIZE * rand()) / (1.0f * RAND_MAX);\n    *size = (MAX_CIRCLE_SIZE * rand()) / (1.0f * RAND_MAX);\n    sign = (1.0f * rand()) / (1.0f * RAND_MAX);\n    sign = (sign < DISPLACEMENT_SIGN_LIMIT) ? -1.0f : 1.0f;\n    *displacement = (sign * (MAX_DISPLACEMENT * rand())) / (1.0f * RAND_MAX);\n}\n\n/* Run the specified number of iterations of the generation process for the\n * heightmap\n */\nstatic void update_map(int num_iter)\n{\n    assert(num_iter > 0);\n    while(num_iter)\n    {\n        /* center of the circle */\n        float center_x;\n        float center_z;\n        float circle_size;\n        float disp;\n        size_t ii;\n        generate_heightmap__circle(&center_x, &center_z, &circle_size, &disp);\n        disp = disp / 2.0f;\n        for (ii = 0u ; ii < MAP_NUM_TOTAL_VERTICES ; ++ii)\n        {\n            GLfloat dx = center_x - map_vertices[0][ii];\n            GLfloat dz = center_z - map_vertices[2][ii];\n            GLfloat pd = (2.0f * sqrtf((dx * dx) + (dz * dz))) / circle_size;\n            if (fabs(pd) <= 1.0f)\n            {\n                /* tx,tz is within the circle */\n                GLfloat new_height = disp + (float) (cos(pd*3.14f)*disp);\n                map_vertices[1][ii] += new_height;\n            }\n        }\n        --num_iter;\n    }\n}\n\n/**********************************************************************\n * OpenGL helper functions\n *********************************************************************/\n\n/* Create VBO, IBO and VAO objects for the heightmap geometry and bind them to\n * the specified program object\n */\nstatic void make_mesh(GLuint program)\n{\n    GLuint attrloc;\n\n    glGenVertexArrays(1, &mesh);\n    glGenBuffers(4, mesh_vbo);\n    glBindVertexArray(mesh);\n    /* Prepare the data for drawing through a buffer inidices */\n    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh_vbo[3]);\n    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint)* MAP_NUM_LINES * 2, map_line_indices, GL_STATIC_DRAW);\n\n    /* Prepare the attributes for rendering */\n    attrloc = glGetAttribLocation(program, \"x\");\n    glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[0]);\n    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[0][0], GL_STATIC_DRAW);\n    glEnableVertexAttribArray(attrloc);\n    glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);\n\n    attrloc = glGetAttribLocation(program, \"z\");\n    glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[2]);\n    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[2][0], GL_STATIC_DRAW);\n    glEnableVertexAttribArray(attrloc);\n    glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);\n\n    attrloc = glGetAttribLocation(program, \"y\");\n    glBindBuffer(GL_ARRAY_BUFFER, mesh_vbo[1]);\n    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0], GL_DYNAMIC_DRAW);\n    glEnableVertexAttribArray(attrloc);\n    glVertexAttribPointer(attrloc, 1, GL_FLOAT, GL_FALSE, 0, 0);\n}\n\n/* Update VBO vertices from source data\n */\nstatic void update_mesh(void)\n{\n    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * MAP_NUM_TOTAL_VERTICES, &map_vertices[1][0]);\n}\n\n/**********************************************************************\n * GLFW callback functions\n *********************************************************************/\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    switch(key)\n    {\n        case GLFW_KEY_ESCAPE:\n            /* Exit program on Escape */\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n    }\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nint main(int argc, char** argv)\n{\n    GLFWwindow* window;\n    int iter;\n    double dt;\n    double last_update_time;\n    int frame;\n    float f;\n    GLint uloc_modelview;\n    GLint uloc_project;\n\n    GLuint shader_program;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);\n    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);\n    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);\n    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);\n    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);\n\n    window = glfwCreateWindow(800, 600, \"GLFW OpenGL3 Heightmap demo\", NULL, NULL);\n    if (! window )\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    /* Register events callback */\n    glfwSetKeyCallback(window, key_callback);\n\n    glfwMakeContextCurrent(window);\n    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);\n\n    /* Prepare opengl resources for rendering */\n    shader_program = make_shader_program(vertex_shader_text, fragment_shader_text);\n\n    if (shader_program == 0u)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glUseProgram(shader_program);\n    uloc_project   = glGetUniformLocation(shader_program, \"project\");\n    uloc_modelview = glGetUniformLocation(shader_program, \"modelview\");\n\n    /* Compute the projection matrix */\n    f = 1.0f / tanf(view_angle / 2.0f);\n    projection_matrix[0]  = f / aspect_ratio;\n    projection_matrix[5]  = f;\n    projection_matrix[10] = (z_far + z_near)/ (z_near - z_far);\n    projection_matrix[11] = -1.0f;\n    projection_matrix[14] = 2.0f * (z_far * z_near) / (z_near - z_far);\n    glUniformMatrix4fv(uloc_project, 1, GL_FALSE, projection_matrix);\n\n    /* Set the camera position */\n    modelview_matrix[12]  = -5.0f;\n    modelview_matrix[13]  = -5.0f;\n    modelview_matrix[14]  = -20.0f;\n    glUniformMatrix4fv(uloc_modelview, 1, GL_FALSE, modelview_matrix);\n\n    /* Create mesh data */\n    init_map();\n    make_mesh(shader_program);\n\n    /* Create vao + vbo to store the mesh */\n    /* Create the vbo to store all the information for the grid and the height */\n\n    /* setup the scene ready for rendering */\n    glViewport(0, 0, 800, 600);\n    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);\n\n    /* main loop */\n    frame = 0;\n    iter = 0;\n    last_update_time = glfwGetTime();\n\n    while (!glfwWindowShouldClose(window))\n    {\n        ++frame;\n        /* render the next frame */\n        glClear(GL_COLOR_BUFFER_BIT);\n        glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0);\n\n        /* display and process events through callbacks */\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n        /* Check the frame rate and update the heightmap if needed */\n        dt = glfwGetTime();\n        if ((dt - last_update_time) > 0.2)\n        {\n            /* generate the next iteration of the heightmap */\n            if (iter < MAX_ITER)\n            {\n                update_map(NUM_ITER_AT_A_TIME);\n                update_mesh();\n                iter += NUM_ITER_AT_A_TIME;\n            }\n            last_update_time = dt;\n            frame = 0;\n        }\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/examples/particles.c",
    "content": "//========================================================================\n// A simple particle engine with threaded physics\n// Copyright (c) Marcus Geelnard\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <math.h>\n#include <time.h>\n\n#include <tinycthread.h>\n#include <getopt.h>\n#include <linmath.h>\n\n#include <GLFW/glfw3.h>\n\n// Define tokens for GL_EXT_separate_specular_color if not already defined\n#ifndef GL_EXT_separate_specular_color\n#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT  0x81F8\n#define GL_SINGLE_COLOR_EXT               0x81F9\n#define GL_SEPARATE_SPECULAR_COLOR_EXT    0x81FA\n#endif // GL_EXT_separate_specular_color\n\n\n//========================================================================\n// Type definitions\n//========================================================================\n\ntypedef struct\n{\n    float x, y, z;\n} Vec3;\n\n// This structure is used for interleaved vertex arrays (see the\n// draw_particles function)\n//\n// NOTE: This structure SHOULD be packed on most systems. It uses 32-bit fields\n// on 32-bit boundaries, and is a multiple of 64 bits in total (6x32=3x64). If\n// it does not work, try using pragmas or whatever to force the structure to be\n// packed.\ntypedef struct\n{\n    GLfloat s, t;         // Texture coordinates\n    GLuint  rgba;         // Color (four ubytes packed into an uint)\n    GLfloat x, y, z;      // Vertex coordinates\n} Vertex;\n\n\n//========================================================================\n// Program control global variables\n//========================================================================\n\n// Window dimensions\nfloat aspect_ratio;\n\n// \"wireframe\" flag (true if we use wireframe view)\nint wireframe;\n\n// Thread synchronization\nstruct {\n    double    t;         // Time (s)\n    float     dt;        // Time since last frame (s)\n    int       p_frame;   // Particle physics frame number\n    int       d_frame;   // Particle draw frame number\n    cnd_t     p_done;    // Condition: particle physics done\n    cnd_t     d_done;    // Condition: particle draw done\n    mtx_t     particles_lock; // Particles data sharing mutex\n} thread_sync;\n\n\n//========================================================================\n// Texture declarations (we hard-code them into the source code, since\n// they are so simple)\n//========================================================================\n\n#define P_TEX_WIDTH  8    // Particle texture dimensions\n#define P_TEX_HEIGHT 8\n#define F_TEX_WIDTH  16   // Floor texture dimensions\n#define F_TEX_HEIGHT 16\n\n// Texture object IDs\nGLuint particle_tex_id, floor_tex_id;\n\n// Particle texture (a simple spot)\nconst unsigned char particle_texture[ P_TEX_WIDTH * P_TEX_HEIGHT ] = {\n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n    0x00, 0x00, 0x11, 0x22, 0x22, 0x11, 0x00, 0x00,\n    0x00, 0x11, 0x33, 0x88, 0x77, 0x33, 0x11, 0x00,\n    0x00, 0x22, 0x88, 0xff, 0xee, 0x77, 0x22, 0x00,\n    0x00, 0x22, 0x77, 0xee, 0xff, 0x88, 0x22, 0x00,\n    0x00, 0x11, 0x33, 0x77, 0x88, 0x33, 0x11, 0x00,\n    0x00, 0x00, 0x11, 0x33, 0x22, 0x11, 0x00, 0x00,\n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n\n// Floor texture (your basic checkered floor)\nconst unsigned char floor_texture[ F_TEX_WIDTH * F_TEX_HEIGHT ] = {\n    0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,\n    0xff, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,\n    0xf0, 0xcc, 0xee, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x66, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30,\n    0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xee, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,\n    0xf0, 0xf0, 0xf0, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x55, 0x30, 0x30, 0x44, 0x30, 0x30,\n    0xf0, 0xdd, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,\n    0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x60, 0x30,\n    0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x33, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30, 0xf0, 0xff, 0xf0, 0xf0, 0xdd, 0xf0, 0xf0, 0xff,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x55, 0x33, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xf0,\n    0x30, 0x44, 0x66, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xaa, 0xf0, 0xf0, 0xcc, 0xf0,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xff, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0xdd, 0xf0,\n    0x30, 0x30, 0x30, 0x77, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,\n    0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,\n};\n\n\n//========================================================================\n// These are fixed constants that control the particle engine. In a\n// modular world, these values should be variables...\n//========================================================================\n\n// Maximum number of particles\n#define MAX_PARTICLES   3000\n\n// Life span of a particle (in seconds)\n#define LIFE_SPAN       8.f\n\n// A new particle is born every [BIRTH_INTERVAL] second\n#define BIRTH_INTERVAL (LIFE_SPAN/(float)MAX_PARTICLES)\n\n// Particle size (meters)\n#define PARTICLE_SIZE   0.7f\n\n// Gravitational constant (m/s^2)\n#define GRAVITY         9.8f\n\n// Base initial velocity (m/s)\n#define VELOCITY        8.f\n\n// Bounce friction (1.0 = no friction, 0.0 = maximum friction)\n#define FRICTION        0.75f\n\n// \"Fountain\" height (m)\n#define FOUNTAIN_HEIGHT 3.f\n\n// Fountain radius (m)\n#define FOUNTAIN_RADIUS 1.6f\n\n// Minimum delta-time for particle phisics (s)\n#define MIN_DELTA_T     (BIRTH_INTERVAL * 0.5f)\n\n\n//========================================================================\n// Particle system global variables\n//========================================================================\n\n// This structure holds all state for a single particle\ntypedef struct {\n    float x,y,z;     // Position in space\n    float vx,vy,vz;  // Velocity vector\n    float r,g,b;     // Color of particle\n    float life;      // Life of particle (1.0 = newborn, < 0.0 = dead)\n    int   active;    // Tells if this particle is active\n} PARTICLE;\n\n// Global vectors holding all particles. We use two vectors for double\n// buffering.\nstatic PARTICLE particles[MAX_PARTICLES];\n\n// Global variable holding the age of the youngest particle\nstatic float min_age;\n\n// Color of latest born particle (used for fountain lighting)\nstatic float glow_color[4];\n\n// Position of latest born particle (used for fountain lighting)\nstatic float glow_pos[4];\n\n\n//========================================================================\n// Object material and fog configuration constants\n//========================================================================\n\nconst GLfloat fountain_diffuse[4]  = { 0.7f, 1.f,  1.f,  1.f };\nconst GLfloat fountain_specular[4] = {  1.f, 1.f,  1.f,  1.f };\nconst GLfloat fountain_shininess   = 12.f;\nconst GLfloat floor_diffuse[4]     = { 1.f,  0.6f, 0.6f, 1.f };\nconst GLfloat floor_specular[4]    = { 0.6f, 0.6f, 0.6f, 1.f };\nconst GLfloat floor_shininess      = 18.f;\nconst GLfloat fog_color[4]         = { 0.1f, 0.1f, 0.1f, 1.f };\n\n\n//========================================================================\n// Print usage information\n//========================================================================\n\nstatic void usage(void)\n{\n    printf(\"Usage: particles [-bfhs]\\n\");\n    printf(\"Options:\\n\");\n    printf(\" -f   Run in full screen\\n\");\n    printf(\" -h   Display this help\\n\");\n    printf(\" -s   Run program as single thread (default is to use two threads)\\n\");\n    printf(\"\\n\");\n    printf(\"Program runtime controls:\\n\");\n    printf(\" W    Toggle wireframe mode\\n\");\n    printf(\" Esc  Exit program\\n\");\n}\n\n\n//========================================================================\n// Initialize a new particle\n//========================================================================\n\nstatic void init_particle(PARTICLE *p, double t)\n{\n    float xy_angle, velocity;\n\n    // Start position of particle is at the fountain blow-out\n    p->x = 0.f;\n    p->y = 0.f;\n    p->z = FOUNTAIN_HEIGHT;\n\n    // Start velocity is up (Z)...\n    p->vz = 0.7f + (0.3f / 4096.f) * (float) (rand() & 4095);\n\n    // ...and a randomly chosen X/Y direction\n    xy_angle = (2.f * (float) M_PI / 4096.f) * (float) (rand() & 4095);\n    p->vx = 0.4f * (float) cos(xy_angle);\n    p->vy = 0.4f * (float) sin(xy_angle);\n\n    // Scale velocity vector according to a time-varying velocity\n    velocity = VELOCITY * (0.8f + 0.1f * (float) (sin(0.5 * t) + sin(1.31 * t)));\n    p->vx *= velocity;\n    p->vy *= velocity;\n    p->vz *= velocity;\n\n    // Color is time-varying\n    p->r = 0.7f + 0.3f * (float) sin(0.34 * t + 0.1);\n    p->g = 0.6f + 0.4f * (float) sin(0.63 * t + 1.1);\n    p->b = 0.6f + 0.4f * (float) sin(0.91 * t + 2.1);\n\n    // Store settings for fountain glow lighting\n    glow_pos[0] = 0.4f * (float) sin(1.34 * t);\n    glow_pos[1] = 0.4f * (float) sin(3.11 * t);\n    glow_pos[2] = FOUNTAIN_HEIGHT + 1.f;\n    glow_pos[3] = 1.f;\n    glow_color[0] = p->r;\n    glow_color[1] = p->g;\n    glow_color[2] = p->b;\n    glow_color[3] = 1.f;\n\n    // The particle is new-born and active\n    p->life = 1.f;\n    p->active = 1;\n}\n\n\n//========================================================================\n// Update a particle\n//========================================================================\n\n#define FOUNTAIN_R2 (FOUNTAIN_RADIUS+PARTICLE_SIZE/2)*(FOUNTAIN_RADIUS+PARTICLE_SIZE/2)\n\nstatic void update_particle(PARTICLE *p, float dt)\n{\n    // If the particle is not active, we need not do anything\n    if (!p->active)\n        return;\n\n    // The particle is getting older...\n    p->life -= dt * (1.f / LIFE_SPAN);\n\n    // Did the particle die?\n    if (p->life <= 0.f)\n    {\n        p->active = 0;\n        return;\n    }\n\n    // Apply gravity\n    p->vz = p->vz - GRAVITY * dt;\n\n    // Update particle position\n    p->x = p->x + p->vx * dt;\n    p->y = p->y + p->vy * dt;\n    p->z = p->z + p->vz * dt;\n\n    // Simple collision detection + response\n    if (p->vz < 0.f)\n    {\n        // Particles should bounce on the fountain (with friction)\n        if ((p->x * p->x + p->y * p->y) < FOUNTAIN_R2 &&\n            p->z < (FOUNTAIN_HEIGHT + PARTICLE_SIZE / 2))\n        {\n            p->vz = -FRICTION * p->vz;\n            p->z  = FOUNTAIN_HEIGHT + PARTICLE_SIZE / 2 +\n                    FRICTION * (FOUNTAIN_HEIGHT +\n                    PARTICLE_SIZE / 2 - p->z);\n        }\n\n        // Particles should bounce on the floor (with friction)\n        else if (p->z < PARTICLE_SIZE / 2)\n        {\n            p->vz = -FRICTION * p->vz;\n            p->z  = PARTICLE_SIZE / 2 +\n                    FRICTION * (PARTICLE_SIZE / 2 - p->z);\n        }\n    }\n}\n\n\n//========================================================================\n// The main frame for the particle engine. Called once per frame.\n//========================================================================\n\nstatic void particle_engine(double t, float dt)\n{\n    int i;\n    float dt2;\n\n    // Update particles (iterated several times per frame if dt is too large)\n    while (dt > 0.f)\n    {\n        // Calculate delta time for this iteration\n        dt2 = dt < MIN_DELTA_T ? dt : MIN_DELTA_T;\n\n        for (i = 0;  i < MAX_PARTICLES;  i++)\n            update_particle(&particles[i], dt2);\n\n        min_age += dt2;\n\n        // Should we create any new particle(s)?\n        while (min_age >= BIRTH_INTERVAL)\n        {\n            min_age -= BIRTH_INTERVAL;\n\n            // Find a dead particle to replace with a new one\n            for (i = 0;  i < MAX_PARTICLES;  i++)\n            {\n                if (!particles[i].active)\n                {\n                    init_particle(&particles[i], t + min_age);\n                    update_particle(&particles[i], min_age);\n                    break;\n                }\n            }\n        }\n\n        dt -= dt2;\n    }\n}\n\n\n//========================================================================\n// Draw all active particles. We use OpenGL 1.1 vertex\n// arrays for this in order to accelerate the drawing.\n//========================================================================\n\n#define BATCH_PARTICLES 70  // Number of particles to draw in each batch\n                            // (70 corresponds to 7.5 KB = will not blow\n                            // the L1 data cache on most CPUs)\n#define PARTICLE_VERTS  4   // Number of vertices per particle\n\nstatic void draw_particles(GLFWwindow* window, double t, float dt)\n{\n    int i, particle_count;\n    Vertex vertex_array[BATCH_PARTICLES * PARTICLE_VERTS];\n    Vertex* vptr;\n    float alpha;\n    GLuint rgba;\n    Vec3 quad_lower_left, quad_lower_right;\n    GLfloat mat[16];\n    PARTICLE* pptr;\n\n    // Here comes the real trick with flat single primitive objects (s.c.\n    // \"billboards\"): We must rotate the textured primitive so that it\n    // always faces the viewer (is coplanar with the view-plane).\n    // We:\n    //   1) Create the primitive around origo (0,0,0)\n    //   2) Rotate it so that it is coplanar with the view plane\n    //   3) Translate it according to the particle position\n    // Note that 1) and 2) is the same for all particles (done only once).\n\n    // Get modelview matrix. We will only use the upper left 3x3 part of\n    // the matrix, which represents the rotation.\n    glGetFloatv(GL_MODELVIEW_MATRIX, mat);\n\n    // 1) & 2) We do it in one swift step:\n    // Although not obvious, the following six lines represent two matrix/\n    // vector multiplications. The matrix is the inverse 3x3 rotation\n    // matrix (i.e. the transpose of the same matrix), and the two vectors\n    // represent the lower left corner of the quad, PARTICLE_SIZE/2 *\n    // (-1,-1,0), and the lower right corner, PARTICLE_SIZE/2 * (1,-1,0).\n    // The upper left/right corners of the quad is always the negative of\n    // the opposite corners (regardless of rotation).\n    quad_lower_left.x = (-PARTICLE_SIZE / 2) * (mat[0] + mat[1]);\n    quad_lower_left.y = (-PARTICLE_SIZE / 2) * (mat[4] + mat[5]);\n    quad_lower_left.z = (-PARTICLE_SIZE / 2) * (mat[8] + mat[9]);\n    quad_lower_right.x = (PARTICLE_SIZE / 2) * (mat[0] - mat[1]);\n    quad_lower_right.y = (PARTICLE_SIZE / 2) * (mat[4] - mat[5]);\n    quad_lower_right.z = (PARTICLE_SIZE / 2) * (mat[8] - mat[9]);\n\n    // Don't update z-buffer, since all particles are transparent!\n    glDepthMask(GL_FALSE);\n\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_SRC_ALPHA, GL_ONE);\n\n    // Select particle texture\n    if (!wireframe)\n    {\n        glEnable(GL_TEXTURE_2D);\n        glBindTexture(GL_TEXTURE_2D, particle_tex_id);\n    }\n\n    // Set up vertex arrays. We use interleaved arrays, which is easier to\n    // handle (in most situations) and it gives a linear memeory access\n    // access pattern (which may give better performance in some\n    // situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords,\n    // 4 ubytes for color and 3 floats for vertex coord (in that order).\n    // Most OpenGL cards / drivers are optimized for this format.\n    glInterleavedArrays(GL_T2F_C4UB_V3F, 0, vertex_array);\n\n    // Wait for particle physics thread to be done\n    mtx_lock(&thread_sync.particles_lock);\n    while (!glfwWindowShouldClose(window) &&\n            thread_sync.p_frame <= thread_sync.d_frame)\n    {\n        struct timespec ts;\n        clock_gettime(CLOCK_REALTIME, &ts);\n        ts.tv_nsec += 100000000;\n        cnd_timedwait(&thread_sync.p_done, &thread_sync.particles_lock, &ts);\n    }\n\n    // Store the frame time and delta time for the physics thread\n    thread_sync.t = t;\n    thread_sync.dt = dt;\n\n    // Update frame counter\n    thread_sync.d_frame++;\n\n    // Loop through all particles and build vertex arrays.\n    particle_count = 0;\n    vptr = vertex_array;\n    pptr = particles;\n\n    for (i = 0;  i < MAX_PARTICLES;  i++)\n    {\n        if (pptr->active)\n        {\n            // Calculate particle intensity (we set it to max during 75%\n            // of its life, then it fades out)\n            alpha =  4.f * pptr->life;\n            if (alpha > 1.f)\n                alpha = 1.f;\n\n            // Convert color from float to 8-bit (store it in a 32-bit\n            // integer using endian independent type casting)\n            ((GLubyte*) &rgba)[0] = (GLubyte)(pptr->r * 255.f);\n            ((GLubyte*) &rgba)[1] = (GLubyte)(pptr->g * 255.f);\n            ((GLubyte*) &rgba)[2] = (GLubyte)(pptr->b * 255.f);\n            ((GLubyte*) &rgba)[3] = (GLubyte)(alpha * 255.f);\n\n            // 3) Translate the quad to the correct position in modelview\n            // space and store its parameters in vertex arrays (we also\n            // store texture coord and color information for each vertex).\n\n            // Lower left corner\n            vptr->s    = 0.f;\n            vptr->t    = 0.f;\n            vptr->rgba = rgba;\n            vptr->x    = pptr->x + quad_lower_left.x;\n            vptr->y    = pptr->y + quad_lower_left.y;\n            vptr->z    = pptr->z + quad_lower_left.z;\n            vptr ++;\n\n            // Lower right corner\n            vptr->s    = 1.f;\n            vptr->t    = 0.f;\n            vptr->rgba = rgba;\n            vptr->x    = pptr->x + quad_lower_right.x;\n            vptr->y    = pptr->y + quad_lower_right.y;\n            vptr->z    = pptr->z + quad_lower_right.z;\n            vptr ++;\n\n            // Upper right corner\n            vptr->s    = 1.f;\n            vptr->t    = 1.f;\n            vptr->rgba = rgba;\n            vptr->x    = pptr->x - quad_lower_left.x;\n            vptr->y    = pptr->y - quad_lower_left.y;\n            vptr->z    = pptr->z - quad_lower_left.z;\n            vptr ++;\n\n            // Upper left corner\n            vptr->s    = 0.f;\n            vptr->t    = 1.f;\n            vptr->rgba = rgba;\n            vptr->x    = pptr->x - quad_lower_right.x;\n            vptr->y    = pptr->y - quad_lower_right.y;\n            vptr->z    = pptr->z - quad_lower_right.z;\n            vptr ++;\n\n            // Increase count of drawable particles\n            particle_count ++;\n        }\n\n        // If we have filled up one batch of particles, draw it as a set\n        // of quads using glDrawArrays.\n        if (particle_count >= BATCH_PARTICLES)\n        {\n            // The first argument tells which primitive type we use (QUAD)\n            // The second argument tells the index of the first vertex (0)\n            // The last argument is the vertex count\n            glDrawArrays(GL_QUADS, 0, PARTICLE_VERTS * particle_count);\n            particle_count = 0;\n            vptr = vertex_array;\n        }\n\n        // Next particle\n        pptr++;\n    }\n\n    // We are done with the particle data\n    mtx_unlock(&thread_sync.particles_lock);\n    cnd_signal(&thread_sync.d_done);\n\n    // Draw final batch of particles (if any)\n    glDrawArrays(GL_QUADS, 0, PARTICLE_VERTS * particle_count);\n\n    // Disable vertex arrays (Note: glInterleavedArrays implicitly called\n    // glEnableClientState for vertex, texture coord and color arrays)\n    glDisableClientState(GL_VERTEX_ARRAY);\n    glDisableClientState(GL_TEXTURE_COORD_ARRAY);\n    glDisableClientState(GL_COLOR_ARRAY);\n\n    glDisable(GL_TEXTURE_2D);\n    glDisable(GL_BLEND);\n\n    glDepthMask(GL_TRUE);\n}\n\n\n//========================================================================\n// Fountain geometry specification\n//========================================================================\n\n#define FOUNTAIN_SIDE_POINTS 14\n#define FOUNTAIN_SWEEP_STEPS 32\n\nstatic const float fountain_side[FOUNTAIN_SIDE_POINTS * 2] =\n{\n    1.2f, 0.f,  1.f, 0.2f,  0.41f, 0.3f, 0.4f, 0.35f,\n    0.4f, 1.95f, 0.41f, 2.f, 0.8f, 2.2f,  1.2f, 2.4f,\n    1.5f, 2.7f,  1.55f,2.95f, 1.6f, 3.f,  1.f, 3.f,\n    0.5f, 3.f,  0.f, 3.f\n};\n\nstatic const float fountain_normal[FOUNTAIN_SIDE_POINTS * 2] =\n{\n    1.0000f, 0.0000f,  0.6428f, 0.7660f,  0.3420f, 0.9397f,  1.0000f, 0.0000f,\n    1.0000f, 0.0000f,  0.3420f,-0.9397f,  0.4226f,-0.9063f,  0.5000f,-0.8660f,\n    0.7660f,-0.6428f,  0.9063f,-0.4226f,  0.0000f,1.00000f,  0.0000f,1.00000f,\n    0.0000f,1.00000f,  0.0000f,1.00000f\n};\n\n\n//========================================================================\n// Draw a fountain\n//========================================================================\n\nstatic void draw_fountain(void)\n{\n    static GLuint fountain_list = 0;\n    double angle;\n    float  x, y;\n    int m, n;\n\n    // The first time, we build the fountain display list\n    if (!fountain_list)\n    {\n        fountain_list = glGenLists(1);\n        glNewList(fountain_list, GL_COMPILE_AND_EXECUTE);\n\n        glMaterialfv(GL_FRONT, GL_DIFFUSE, fountain_diffuse);\n        glMaterialfv(GL_FRONT, GL_SPECULAR, fountain_specular);\n        glMaterialf(GL_FRONT, GL_SHININESS, fountain_shininess);\n\n        // Build fountain using triangle strips\n        for (n = 0;  n < FOUNTAIN_SIDE_POINTS - 1;  n++)\n        {\n            glBegin(GL_TRIANGLE_STRIP);\n            for (m = 0;  m <= FOUNTAIN_SWEEP_STEPS;  m++)\n            {\n                angle = (double) m * (2.0 * M_PI / (double) FOUNTAIN_SWEEP_STEPS);\n                x = (float) cos(angle);\n                y = (float) sin(angle);\n\n                // Draw triangle strip\n                glNormal3f(x * fountain_normal[n * 2 + 2],\n                           y * fountain_normal[n * 2 + 2],\n                           fountain_normal[n * 2 + 3]);\n                glVertex3f(x * fountain_side[n * 2 + 2],\n                           y * fountain_side[n * 2 + 2],\n                           fountain_side[n * 2 +3 ]);\n                glNormal3f(x * fountain_normal[n * 2],\n                           y * fountain_normal[n * 2],\n                           fountain_normal[n * 2 + 1]);\n                glVertex3f(x * fountain_side[n * 2],\n                           y * fountain_side[n * 2],\n                           fountain_side[n * 2 + 1]);\n            }\n\n            glEnd();\n        }\n\n        glEndList();\n    }\n    else\n        glCallList(fountain_list);\n}\n\n\n//========================================================================\n// Recursive function for building variable tesselated floor\n//========================================================================\n\nstatic void tessellate_floor(float x1, float y1, float x2, float y2, int depth)\n{\n    float delta, x, y;\n\n    // Last recursion?\n    if (depth >= 5)\n        delta = 999999.f;\n    else\n    {\n        x = (float) (fabs(x1) < fabs(x2) ? fabs(x1) : fabs(x2));\n        y = (float) (fabs(y1) < fabs(y2) ? fabs(y1) : fabs(y2));\n        delta = x*x + y*y;\n    }\n\n    // Recurse further?\n    if (delta < 0.1f)\n    {\n        x = (x1 + x2) * 0.5f;\n        y = (y1 + y2) * 0.5f;\n        tessellate_floor(x1, y1,  x,  y, depth + 1);\n        tessellate_floor(x, y1, x2,  y, depth + 1);\n        tessellate_floor(x1,  y,  x, y2, depth + 1);\n        tessellate_floor(x,  y, x2, y2, depth + 1);\n    }\n    else\n    {\n        glTexCoord2f(x1 * 30.f, y1 * 30.f);\n        glVertex3f(  x1 * 80.f, y1 * 80.f, 0.f);\n        glTexCoord2f(x2 * 30.f, y1 * 30.f);\n        glVertex3f(  x2 * 80.f, y1 * 80.f, 0.f);\n        glTexCoord2f(x2 * 30.f, y2 * 30.f);\n        glVertex3f(  x2 * 80.f, y2 * 80.f, 0.f);\n        glTexCoord2f(x1 * 30.f, y2 * 30.f);\n        glVertex3f(  x1 * 80.f, y2 * 80.f, 0.f);\n    }\n}\n\n\n//========================================================================\n// Draw floor. We build the floor recursively and let the tessellation in the\n// center (near x,y=0,0) be high, while the tessellation around the edges be\n// low.\n//========================================================================\n\nstatic void draw_floor(void)\n{\n    static GLuint floor_list = 0;\n\n    if (!wireframe)\n    {\n        glEnable(GL_TEXTURE_2D);\n        glBindTexture(GL_TEXTURE_2D, floor_tex_id);\n    }\n\n    // The first time, we build the floor display list\n    if (!floor_list)\n    {\n        floor_list = glGenLists(1);\n        glNewList(floor_list, GL_COMPILE_AND_EXECUTE);\n\n        glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_diffuse);\n        glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular);\n        glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess);\n\n        // Draw floor as a bunch of triangle strips (high tesselation\n        // improves lighting)\n        glNormal3f(0.f, 0.f, 1.f);\n        glBegin(GL_QUADS);\n        tessellate_floor(-1.f, -1.f, 0.f, 0.f, 0);\n        tessellate_floor( 0.f, -1.f, 1.f, 0.f, 0);\n        tessellate_floor( 0.f,  0.f, 1.f, 1.f, 0);\n        tessellate_floor(-1.f,  0.f, 0.f, 1.f, 0);\n        glEnd();\n\n        glEndList();\n    }\n    else\n        glCallList(floor_list);\n\n    glDisable(GL_TEXTURE_2D);\n\n}\n\n\n//========================================================================\n// Position and configure light sources\n//========================================================================\n\nstatic void setup_lights(void)\n{\n    float l1pos[4], l1amb[4], l1dif[4], l1spec[4];\n    float l2pos[4], l2amb[4], l2dif[4], l2spec[4];\n\n    // Set light source 1 parameters\n    l1pos[0] =  0.f;  l1pos[1] = -9.f; l1pos[2] =   8.f;  l1pos[3] = 1.f;\n    l1amb[0] = 0.2f;  l1amb[1] = 0.2f;  l1amb[2] = 0.2f;  l1amb[3] = 1.f;\n    l1dif[0] = 0.8f;  l1dif[1] = 0.4f;  l1dif[2] = 0.2f;  l1dif[3] = 1.f;\n    l1spec[0] = 1.f; l1spec[1] = 0.6f; l1spec[2] = 0.2f; l1spec[3] = 0.f;\n\n    // Set light source 2 parameters\n    l2pos[0] =  -15.f; l2pos[1] =  12.f; l2pos[2] = 1.5f; l2pos[3] =  1.f;\n    l2amb[0] =    0.f; l2amb[1] =   0.f; l2amb[2] =  0.f; l2amb[3] =  1.f;\n    l2dif[0] =   0.2f; l2dif[1] =  0.4f; l2dif[2] = 0.8f; l2dif[3] =  1.f;\n    l2spec[0] =  0.2f; l2spec[1] = 0.6f; l2spec[2] = 1.f; l2spec[3] = 0.f;\n\n    glLightfv(GL_LIGHT1, GL_POSITION, l1pos);\n    glLightfv(GL_LIGHT1, GL_AMBIENT, l1amb);\n    glLightfv(GL_LIGHT1, GL_DIFFUSE, l1dif);\n    glLightfv(GL_LIGHT1, GL_SPECULAR, l1spec);\n    glLightfv(GL_LIGHT2, GL_POSITION, l2pos);\n    glLightfv(GL_LIGHT2, GL_AMBIENT, l2amb);\n    glLightfv(GL_LIGHT2, GL_DIFFUSE, l2dif);\n    glLightfv(GL_LIGHT2, GL_SPECULAR, l2spec);\n    glLightfv(GL_LIGHT3, GL_POSITION, glow_pos);\n    glLightfv(GL_LIGHT3, GL_DIFFUSE, glow_color);\n    glLightfv(GL_LIGHT3, GL_SPECULAR, glow_color);\n\n    glEnable(GL_LIGHT1);\n    glEnable(GL_LIGHT2);\n    glEnable(GL_LIGHT3);\n}\n\n\n//========================================================================\n// Main rendering function\n//========================================================================\n\nstatic void draw_scene(GLFWwindow* window, double t)\n{\n    double xpos, ypos, zpos, angle_x, angle_y, angle_z;\n    static double t_old = 0.0;\n    float dt;\n    mat4x4 projection;\n\n    // Calculate frame-to-frame delta time\n    dt = (float) (t - t_old);\n    t_old = t;\n\n    mat4x4_perspective(projection,\n                       65.f * (float) M_PI / 180.f,\n                       aspect_ratio,\n                       1.0, 60.0);\n\n    glClearColor(0.1f, 0.1f, 0.1f, 1.f);\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\n    glMatrixMode(GL_PROJECTION);\n    glLoadMatrixf((const GLfloat*) projection);\n\n    // Setup camera\n    glMatrixMode(GL_MODELVIEW);\n    glLoadIdentity();\n\n    // Rotate camera\n    angle_x = 90.0 - 10.0;\n    angle_y = 10.0 * sin(0.3 * t);\n    angle_z = 10.0 * t;\n    glRotated(-angle_x, 1.0, 0.0, 0.0);\n    glRotated(-angle_y, 0.0, 1.0, 0.0);\n    glRotated(-angle_z, 0.0, 0.0, 1.0);\n\n    // Translate camera\n    xpos =  15.0 * sin((M_PI / 180.0) * angle_z) +\n             2.0 * sin((M_PI / 180.0) * 3.1 * t);\n    ypos = -15.0 * cos((M_PI / 180.0) * angle_z) +\n             2.0 * cos((M_PI / 180.0) * 2.9 * t);\n    zpos = 4.0 + 2.0 * cos((M_PI / 180.0) * 4.9 * t);\n    glTranslated(-xpos, -ypos, -zpos);\n\n    glFrontFace(GL_CCW);\n    glCullFace(GL_BACK);\n    glEnable(GL_CULL_FACE);\n\n    setup_lights();\n    glEnable(GL_LIGHTING);\n\n    glEnable(GL_FOG);\n    glFogi(GL_FOG_MODE, GL_EXP);\n    glFogf(GL_FOG_DENSITY, 0.05f);\n    glFogfv(GL_FOG_COLOR, fog_color);\n\n    draw_floor();\n\n    glEnable(GL_DEPTH_TEST);\n    glDepthFunc(GL_LEQUAL);\n    glDepthMask(GL_TRUE);\n\n    draw_fountain();\n\n    glDisable(GL_LIGHTING);\n    glDisable(GL_FOG);\n\n    // Particles must be drawn after all solid objects have been drawn\n    draw_particles(window, t, dt);\n\n    // Z-buffer not needed anymore\n    glDisable(GL_DEPTH_TEST);\n}\n\n\n//========================================================================\n// Window resize callback function\n//========================================================================\n\nstatic void resize_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n    aspect_ratio = height ? width / (float) height : 1.f;\n}\n\n\n//========================================================================\n// Key callback functions\n//========================================================================\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action == GLFW_PRESS)\n    {\n        switch (key)\n        {\n            case GLFW_KEY_ESCAPE:\n                glfwSetWindowShouldClose(window, GL_TRUE);\n                break;\n            case GLFW_KEY_W:\n                wireframe = !wireframe;\n                glPolygonMode(GL_FRONT_AND_BACK,\n                              wireframe ? GL_LINE : GL_FILL);\n                break;\n            default:\n                break;\n        }\n    }\n}\n\n\n//========================================================================\n// Thread for updating particle physics\n//========================================================================\n\nstatic int physics_thread_main(void* arg)\n{\n    GLFWwindow* window = arg;\n\n    for (;;)\n    {\n        mtx_lock(&thread_sync.particles_lock);\n\n        // Wait for particle drawing to be done\n        while (!glfwWindowShouldClose(window) &&\n               thread_sync.p_frame > thread_sync.d_frame)\n        {\n            struct timespec ts;\n            clock_gettime(CLOCK_REALTIME, &ts);\n            ts.tv_nsec += 100000000;\n            cnd_timedwait(&thread_sync.d_done, &thread_sync.particles_lock, &ts);\n        }\n\n        if (glfwWindowShouldClose(window))\n            break;\n\n        // Update particles\n        particle_engine(thread_sync.t, thread_sync.dt);\n\n        // Update frame counter\n        thread_sync.p_frame++;\n\n        // Unlock mutex and signal drawing thread\n        mtx_unlock(&thread_sync.particles_lock);\n        cnd_signal(&thread_sync.p_done);\n    }\n\n    return 0;\n}\n\n\n//========================================================================\n// main\n//========================================================================\n\nint main(int argc, char** argv)\n{\n    int ch, width, height;\n    thrd_t physics_thread = 0;\n    GLFWwindow* window;\n    GLFWmonitor* monitor = NULL;\n\n    if (!glfwInit())\n    {\n        fprintf(stderr, \"Failed to initialize GLFW\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    while ((ch = getopt(argc, argv, \"fh\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'f':\n                monitor = glfwGetPrimaryMonitor();\n                break;\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n        }\n    }\n\n    if (monitor)\n    {\n        const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n\n        width  = mode->width;\n        height = mode->height;\n    }\n    else\n    {\n        width  = 640;\n        height = 480;\n    }\n\n    window = glfwCreateWindow(width, height, \"Particle Engine\", monitor, NULL);\n    if (!window)\n    {\n        fprintf(stderr, \"Failed to create GLFW window\\n\");\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    if (monitor)\n        glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetFramebufferSizeCallback(window, resize_callback);\n    glfwSetKeyCallback(window, key_callback);\n\n    // Set initial aspect ratio\n    glfwGetFramebufferSize(window, &width, &height);\n    resize_callback(window, width, height);\n\n    // Upload particle texture\n    glGenTextures(1, &particle_tex_id);\n    glBindTexture(GL_TEXTURE_2D, particle_tex_id);\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, P_TEX_WIDTH, P_TEX_HEIGHT,\n                 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, particle_texture);\n\n    // Upload floor texture\n    glGenTextures(1, &floor_tex_id);\n    glBindTexture(GL_TEXTURE_2D, floor_tex_id);\n    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, F_TEX_WIDTH, F_TEX_HEIGHT,\n                 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, floor_texture);\n\n    if (glfwExtensionSupported(\"GL_EXT_separate_specular_color\"))\n    {\n        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT,\n                      GL_SEPARATE_SPECULAR_COLOR_EXT);\n    }\n\n    // Set filled polygon mode as default (not wireframe)\n    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);\n    wireframe = 0;\n\n    // Set initial times\n    thread_sync.t  = 0.0;\n    thread_sync.dt = 0.001f;\n    thread_sync.p_frame = 0;\n    thread_sync.d_frame = 0;\n\n    mtx_init(&thread_sync.particles_lock, mtx_timed);\n    cnd_init(&thread_sync.p_done);\n    cnd_init(&thread_sync.d_done);\n\n    if (thrd_create(&physics_thread, physics_thread_main, window) != thrd_success)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwSetTime(0.0);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        draw_scene(window, glfwGetTime());\n\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n    }\n\n    thrd_join(physics_thread, NULL);\n\n    glfwDestroyWindow(window);\n    glfwTerminate();\n\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/examples/simple.c",
    "content": "//========================================================================\n// Simple GLFW example\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//! [code]\n\n#include <GLFW/glfw3.h>\n\n#include <stdlib.h>\n#include <stdio.h>\n\nstatic void error_callback(int error, const char* description)\n{\n    fputs(description, stderr);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\nint main(void)\n{\n    GLFWwindow* window;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    window = glfwCreateWindow(640, 480, \"Simple example\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetKeyCallback(window, key_callback);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        float ratio;\n        int width, height;\n\n        glfwGetFramebufferSize(window, &width, &height);\n        ratio = width / (float) height;\n\n        glViewport(0, 0, width, height);\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        glMatrixMode(GL_PROJECTION);\n        glLoadIdentity();\n        glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);\n        glMatrixMode(GL_MODELVIEW);\n\n        glLoadIdentity();\n        glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f);\n\n        glBegin(GL_TRIANGLES);\n        glColor3f(1.f, 0.f, 0.f);\n        glVertex3f(-0.6f, -0.4f, 0.f);\n        glColor3f(0.f, 1.f, 0.f);\n        glVertex3f(0.6f, -0.4f, 0.f);\n        glColor3f(0.f, 0.f, 1.f);\n        glVertex3f(0.f, 0.6f, 0.f);\n        glEnd();\n\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n    }\n\n    glfwDestroyWindow(window);\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n//! [code]\n"
  },
  {
    "path": "deps/glfw/examples/splitview.c",
    "content": "//========================================================================\n// This is an example program for the GLFW library\n//\n// The program uses a \"split window\" view, rendering four views of the\n// same scene in one window (e.g. uesful for 3D modelling software). This\n// demo uses scissors to separete the four different rendering areas from\n// each other.\n//\n// (If the code seems a little bit strange here and there, it may be\n//  because I am not a friend of orthogonal projections)\n//========================================================================\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#define GLFW_INCLUDE_GLEXT\n#include <GLFW/glfw3.h>\n\n#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#include <linmath.h>\n\n\n//========================================================================\n// Global variables\n//========================================================================\n\n// Mouse position\nstatic double xpos = 0, ypos = 0;\n\n// Window size\nstatic int width, height;\n\n// Active view: 0 = none, 1 = upper left, 2 = upper right, 3 = lower left,\n// 4 = lower right\nstatic int active_view = 0;\n\n// Rotation around each axis\nstatic int rot_x = 0, rot_y = 0, rot_z = 0;\n\n// Do redraw?\nstatic int do_redraw = 1;\n\n\n//========================================================================\n// Draw a solid torus (use a display list for the model)\n//========================================================================\n\n#define TORUS_MAJOR     1.5\n#define TORUS_MINOR     0.5\n#define TORUS_MAJOR_RES 32\n#define TORUS_MINOR_RES 32\n\nstatic void drawTorus(void)\n{\n    static GLuint torus_list = 0;\n    int    i, j, k;\n    double s, t, x, y, z, nx, ny, nz, scale, twopi;\n\n    if (!torus_list)\n    {\n        // Start recording displaylist\n        torus_list = glGenLists(1);\n        glNewList(torus_list, GL_COMPILE_AND_EXECUTE);\n\n        // Draw torus\n        twopi = 2.0 * M_PI;\n        for (i = 0;  i < TORUS_MINOR_RES;  i++)\n        {\n            glBegin(GL_QUAD_STRIP);\n            for (j = 0;  j <= TORUS_MAJOR_RES;  j++)\n            {\n                for (k = 1;  k >= 0;  k--)\n                {\n                    s = (i + k) % TORUS_MINOR_RES + 0.5;\n                    t = j % TORUS_MAJOR_RES;\n\n                    // Calculate point on surface\n                    x = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * cos(t * twopi / TORUS_MAJOR_RES);\n                    y = TORUS_MINOR * sin(s * twopi / TORUS_MINOR_RES);\n                    z = (TORUS_MAJOR + TORUS_MINOR * cos(s * twopi / TORUS_MINOR_RES)) * sin(t * twopi / TORUS_MAJOR_RES);\n\n                    // Calculate surface normal\n                    nx = x - TORUS_MAJOR * cos(t * twopi / TORUS_MAJOR_RES);\n                    ny = y;\n                    nz = z - TORUS_MAJOR * sin(t * twopi / TORUS_MAJOR_RES);\n                    scale = 1.0 / sqrt(nx*nx + ny*ny + nz*nz);\n                    nx *= scale;\n                    ny *= scale;\n                    nz *= scale;\n\n                    glNormal3f((float) nx, (float) ny, (float) nz);\n                    glVertex3f((float) x, (float) y, (float) z);\n                }\n            }\n\n            glEnd();\n        }\n\n        // Stop recording displaylist\n        glEndList();\n    }\n    else\n    {\n        // Playback displaylist\n        glCallList(torus_list);\n    }\n}\n\n\n//========================================================================\n// Draw the scene (a rotating torus)\n//========================================================================\n\nstatic void drawScene(void)\n{\n    const GLfloat model_diffuse[4]  = {1.0f, 0.8f, 0.8f, 1.0f};\n    const GLfloat model_specular[4] = {0.6f, 0.6f, 0.6f, 1.0f};\n    const GLfloat model_shininess   = 20.0f;\n\n    glPushMatrix();\n\n    // Rotate the object\n    glRotatef((GLfloat) rot_x * 0.5f, 1.0f, 0.0f, 0.0f);\n    glRotatef((GLfloat) rot_y * 0.5f, 0.0f, 1.0f, 0.0f);\n    glRotatef((GLfloat) rot_z * 0.5f, 0.0f, 0.0f, 1.0f);\n\n    // Set model color (used for orthogonal views, lighting disabled)\n    glColor4fv(model_diffuse);\n\n    // Set model material (used for perspective view, lighting enabled)\n    glMaterialfv(GL_FRONT, GL_DIFFUSE, model_diffuse);\n    glMaterialfv(GL_FRONT, GL_SPECULAR, model_specular);\n    glMaterialf(GL_FRONT, GL_SHININESS, model_shininess);\n\n    // Draw torus\n    drawTorus();\n\n    glPopMatrix();\n}\n\n\n//========================================================================\n// Draw a 2D grid (used for orthogonal views)\n//========================================================================\n\nstatic void drawGrid(float scale, int steps)\n{\n    int i;\n    float x, y;\n    mat4x4 view;\n\n    glPushMatrix();\n\n    // Set background to some dark bluish grey\n    glClearColor(0.05f, 0.05f, 0.2f, 0.0f);\n    glClear(GL_COLOR_BUFFER_BIT);\n\n    // Setup modelview matrix (flat XY view)\n    {\n        vec3 eye = { 0.f, 0.f, 1.f };\n        vec3 center = { 0.f, 0.f, 0.f };\n        vec3 up = { 0.f, 1.f, 0.f };\n        mat4x4_look_at(view, eye, center, up);\n    }\n    glLoadMatrixf((const GLfloat*) view);\n\n    // We don't want to update the Z-buffer\n    glDepthMask(GL_FALSE);\n\n    // Set grid color\n    glColor3f(0.0f, 0.5f, 0.5f);\n\n    glBegin(GL_LINES);\n\n    // Horizontal lines\n    x = scale * 0.5f * (float) (steps - 1);\n    y = -scale * 0.5f * (float) (steps - 1);\n    for (i = 0;  i < steps;  i++)\n    {\n        glVertex3f(-x, y, 0.0f);\n        glVertex3f(x, y, 0.0f);\n        y += scale;\n    }\n\n    // Vertical lines\n    x = -scale * 0.5f * (float) (steps - 1);\n    y = scale * 0.5f * (float) (steps - 1);\n    for (i = 0;  i < steps;  i++)\n    {\n        glVertex3f(x, -y, 0.0f);\n        glVertex3f(x, y, 0.0f);\n        x += scale;\n    }\n\n    glEnd();\n\n    // Enable Z-buffer writing again\n    glDepthMask(GL_TRUE);\n\n    glPopMatrix();\n}\n\n\n//========================================================================\n// Draw all views\n//========================================================================\n\nstatic void drawAllViews(void)\n{\n    const GLfloat light_position[4] = {0.0f, 8.0f, 8.0f, 1.0f};\n    const GLfloat light_diffuse[4]  = {1.0f, 1.0f, 1.0f, 1.0f};\n    const GLfloat light_specular[4] = {1.0f, 1.0f, 1.0f, 1.0f};\n    const GLfloat light_ambient[4]  = {0.2f, 0.2f, 0.3f, 1.0f};\n    float aspect;\n    mat4x4 view, projection;\n\n    // Calculate aspect of window\n    if (height > 0)\n        aspect = (float) width / (float) height;\n    else\n        aspect = 1.f;\n\n    // Clear screen\n    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\n    // Enable scissor test\n    glEnable(GL_SCISSOR_TEST);\n\n    // Enable depth test\n    glEnable(GL_DEPTH_TEST);\n    glDepthFunc(GL_LEQUAL);\n\n    // ** ORTHOGONAL VIEWS **\n\n    // For orthogonal views, use wireframe rendering\n    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);\n\n    // Enable line anti-aliasing\n    glEnable(GL_LINE_SMOOTH);\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n\n    // Setup orthogonal projection matrix\n    glMatrixMode(GL_PROJECTION);\n    glLoadIdentity();\n    glOrtho(-3.0 * aspect, 3.0 * aspect, -3.0, 3.0, 1.0, 50.0);\n\n    // Upper left view (TOP VIEW)\n    glViewport(0, height / 2, width / 2, height / 2);\n    glScissor(0, height / 2, width / 2, height / 2);\n    glMatrixMode(GL_MODELVIEW);\n    {\n        vec3 eye = { 0.f, 10.f, 1e-3f };\n        vec3 center = { 0.f, 0.f, 0.f };\n        vec3 up = { 0.f, 1.f, 0.f };\n        mat4x4_look_at( view, eye, center, up );\n    }\n    glLoadMatrixf((const GLfloat*) view);\n    drawGrid(0.5, 12);\n    drawScene();\n\n    // Lower left view (FRONT VIEW)\n    glViewport(0, 0, width / 2, height / 2);\n    glScissor(0, 0, width / 2, height / 2);\n    glMatrixMode(GL_MODELVIEW);\n    {\n        vec3 eye = { 0.f, 0.f, 10.f };\n        vec3 center = { 0.f, 0.f, 0.f };\n        vec3 up = { 0.f, 1.f, 0.f };\n        mat4x4_look_at( view, eye, center, up );\n    }\n    glLoadMatrixf((const GLfloat*) view);\n    drawGrid(0.5, 12);\n    drawScene();\n\n    // Lower right view (SIDE VIEW)\n    glViewport(width / 2, 0, width / 2, height / 2);\n    glScissor(width / 2, 0, width / 2, height / 2);\n    glMatrixMode(GL_MODELVIEW);\n    {\n        vec3 eye = { 10.f, 0.f, 0.f };\n        vec3 center = { 0.f, 0.f, 0.f };\n        vec3 up = { 0.f, 1.f, 0.f };\n        mat4x4_look_at( view, eye, center, up );\n    }\n    glLoadMatrixf((const GLfloat*) view);\n    drawGrid(0.5, 12);\n    drawScene();\n\n    // Disable line anti-aliasing\n    glDisable(GL_LINE_SMOOTH);\n    glDisable(GL_BLEND);\n\n    // ** PERSPECTIVE VIEW **\n\n    // For perspective view, use solid rendering\n    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);\n\n    // Enable face culling (faster rendering)\n    glEnable(GL_CULL_FACE);\n    glCullFace(GL_BACK);\n    glFrontFace(GL_CW);\n\n    // Setup perspective projection matrix\n    glMatrixMode(GL_PROJECTION);\n    mat4x4_perspective(projection,\n                       65.f * (float) M_PI / 180.f,\n                       aspect,\n                       1.f, 50.f);\n    glLoadMatrixf((const GLfloat*) projection);\n\n    // Upper right view (PERSPECTIVE VIEW)\n    glViewport(width / 2, height / 2, width / 2, height / 2);\n    glScissor(width / 2, height / 2, width / 2, height / 2);\n    glMatrixMode(GL_MODELVIEW);\n    {\n        vec3 eye = { 3.f, 1.5f, 3.f };\n        vec3 center = { 0.f, 0.f, 0.f };\n        vec3 up = { 0.f, 1.f, 0.f };\n        mat4x4_look_at( view, eye, center, up );\n    }\n    glLoadMatrixf((const GLfloat*) view);\n\n    // Configure and enable light source 1\n    glLightfv(GL_LIGHT1, GL_POSITION, light_position);\n    glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);\n    glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);\n    glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);\n    glEnable(GL_LIGHT1);\n    glEnable(GL_LIGHTING);\n\n    // Draw scene\n    drawScene();\n\n    // Disable lighting\n    glDisable(GL_LIGHTING);\n\n    // Disable face culling\n    glDisable(GL_CULL_FACE);\n\n    // Disable depth test\n    glDisable(GL_DEPTH_TEST);\n\n    // Disable scissor test\n    glDisable(GL_SCISSOR_TEST);\n\n    // Draw a border around the active view\n    if (active_view > 0 && active_view != 2)\n    {\n        glViewport(0, 0, width, height);\n\n        glMatrixMode(GL_PROJECTION);\n        glLoadIdentity();\n        glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);\n\n        glMatrixMode(GL_MODELVIEW);\n        glLoadIdentity();\n        glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f);\n\n        glColor3f(1.0f, 1.0f, 0.6f);\n\n        glBegin(GL_LINE_STRIP);\n        glVertex2i(0, 0);\n        glVertex2i(1, 0);\n        glVertex2i(1, 1);\n        glVertex2i(0, 1);\n        glVertex2i(0, 0);\n        glEnd();\n    }\n}\n\n\n//========================================================================\n// Framebuffer size callback function\n//========================================================================\n\nstatic void framebufferSizeFun(GLFWwindow* window, int w, int h)\n{\n    width  = w;\n    height = h > 0 ? h : 1;\n    do_redraw = 1;\n}\n\n\n//========================================================================\n// Window refresh callback function\n//========================================================================\n\nstatic void windowRefreshFun(GLFWwindow* window)\n{\n    drawAllViews();\n    glfwSwapBuffers(window);\n    do_redraw = 0;\n}\n\n\n//========================================================================\n// Mouse position callback function\n//========================================================================\n\nstatic void cursorPosFun(GLFWwindow* window, double x, double y)\n{\n    int wnd_width, wnd_height, fb_width, fb_height;\n    double scale;\n\n    glfwGetWindowSize(window, &wnd_width, &wnd_height);\n    glfwGetFramebufferSize(window, &fb_width, &fb_height);\n\n    scale = (double) fb_width / (double) wnd_width;\n\n    x *= scale;\n    y *= scale;\n\n    // Depending on which view was selected, rotate around different axes\n    switch (active_view)\n    {\n        case 1:\n            rot_x += (int) (y - ypos);\n            rot_z += (int) (x - xpos);\n            do_redraw = 1;\n            break;\n        case 3:\n            rot_x += (int) (y - ypos);\n            rot_y += (int) (x - xpos);\n            do_redraw = 1;\n            break;\n        case 4:\n            rot_y += (int) (x - xpos);\n            rot_z += (int) (y - ypos);\n            do_redraw = 1;\n            break;\n        default:\n            // Do nothing for perspective view, or if no view is selected\n            break;\n    }\n\n    // Remember cursor position\n    xpos = x;\n    ypos = y;\n}\n\n\n//========================================================================\n// Mouse button callback function\n//========================================================================\n\nstatic void mouseButtonFun(GLFWwindow* window, int button, int action, int mods)\n{\n    if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)\n    {\n        // Detect which of the four views was clicked\n        active_view = 1;\n        if (xpos >= width / 2)\n            active_view += 1;\n        if (ypos >= height / 2)\n            active_view += 2;\n    }\n    else if (button == GLFW_MOUSE_BUTTON_LEFT)\n    {\n        // Deselect any previously selected view\n        active_view = 0;\n    }\n\n    do_redraw = 1;\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\n\n//========================================================================\n// main\n//========================================================================\n\nint main(void)\n{\n    GLFWwindow* window;\n\n    // Initialise GLFW\n    if (!glfwInit())\n    {\n        fprintf(stderr, \"Failed to initialize GLFW\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    glfwWindowHint(GLFW_SAMPLES, 4);\n\n    // Open OpenGL window\n    window = glfwCreateWindow(500, 500, \"Split view demo\", NULL, NULL);\n    if (!window)\n    {\n        fprintf(stderr, \"Failed to open GLFW window\\n\");\n\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    // Set callback functions\n    glfwSetFramebufferSizeCallback(window, framebufferSizeFun);\n    glfwSetWindowRefreshCallback(window, windowRefreshFun);\n    glfwSetCursorPosCallback(window, cursorPosFun);\n    glfwSetMouseButtonCallback(window, mouseButtonFun);\n    glfwSetKeyCallback(window, key_callback);\n\n    // Enable vsync\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    if (glfwExtensionSupported(\"GL_ARB_multisample\") ||\n        glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR) >= 2 ||\n        glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR) >= 3)\n    {\n        glEnable(GL_MULTISAMPLE_ARB);\n    }\n\n    glfwGetFramebufferSize(window, &width, &height);\n    framebufferSizeFun(window, width, height);\n\n    // Main loop\n    for (;;)\n    {\n        // Only redraw if we need to\n        if (do_redraw)\n            windowRefreshFun(window);\n\n        // Wait for new events\n        glfwWaitEvents();\n\n        // Check if the window should be closed\n        if (glfwWindowShouldClose(window))\n            break;\n    }\n\n    // Close OpenGL window and terminate GLFW\n    glfwTerminate();\n\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/examples/wave.c",
    "content": "/*****************************************************************************\n * Wave Simulation in OpenGL\n * (C) 2002 Jakob Thomsen\n * http://home.in.tum.de/~thomsen\n * Modified for GLFW by Sylvain Hellegouarch - sh@programmationworld.com\n * Modified for variable frame rate by Marcus Geelnard\n * 2003-Jan-31: Minor cleanups and speedups / MG\n * 2010-10-24: Formatting and cleanup - Camilla Berglund\n *****************************************************************************/\n\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\n#include <GLFW/glfw3.h>\n\n#include <linmath.h>\n\n// Maximum delta T to allow for differential calculations\n#define MAX_DELTA_T 0.01\n\n// Animation speed (10.0 looks good)\n#define ANIMATION_SPEED 10.0\n\nGLfloat alpha = 210.f, beta = -70.f;\nGLfloat zoom = 2.f;\n\ndouble cursorX;\ndouble cursorY;\n\nstruct Vertex\n{\n    GLfloat x, y, z;\n    GLfloat r, g, b;\n};\n\n#define GRIDW 50\n#define GRIDH 50\n#define VERTEXNUM (GRIDW*GRIDH)\n\n#define QUADW (GRIDW - 1)\n#define QUADH (GRIDH - 1)\n#define QUADNUM (QUADW*QUADH)\n\nGLuint quad[4 * QUADNUM];\nstruct Vertex vertex[VERTEXNUM];\n\n/* The grid will look like this:\n *\n *      3   4   5\n *      *---*---*\n *      |   |   |\n *      | 0 | 1 |\n *      |   |   |\n *      *---*---*\n *      0   1   2\n */\n\n//========================================================================\n// Initialize grid geometry\n//========================================================================\n\nvoid init_vertices(void)\n{\n    int x, y, p;\n\n    // Place the vertices in a grid\n    for (y = 0;  y < GRIDH;  y++)\n    {\n        for (x = 0;  x < GRIDW;  x++)\n        {\n            p = y * GRIDW + x;\n\n            vertex[p].x = (GLfloat) (x - GRIDW / 2) / (GLfloat) (GRIDW / 2);\n            vertex[p].y = (GLfloat) (y - GRIDH / 2) / (GLfloat) (GRIDH / 2);\n            vertex[p].z = 0;\n\n            if ((x % 4 < 2) ^ (y % 4 < 2))\n                vertex[p].r = 0.0;\n            else\n                vertex[p].r = 1.0;\n\n            vertex[p].g = (GLfloat) y / (GLfloat) GRIDH;\n            vertex[p].b = 1.f - ((GLfloat) x / (GLfloat) GRIDW + (GLfloat) y / (GLfloat) GRIDH) / 2.f;\n        }\n    }\n\n    for (y = 0;  y < QUADH;  y++)\n    {\n        for (x = 0;  x < QUADW;  x++)\n        {\n            p = 4 * (y * QUADW + x);\n\n            quad[p + 0] = y       * GRIDW + x;     // Some point\n            quad[p + 1] = y       * GRIDW + x + 1; // Neighbor at the right side\n            quad[p + 2] = (y + 1) * GRIDW + x + 1; // Upper right neighbor\n            quad[p + 3] = (y + 1) * GRIDW + x;     // Upper neighbor\n        }\n    }\n}\n\ndouble dt;\ndouble p[GRIDW][GRIDH];\ndouble vx[GRIDW][GRIDH], vy[GRIDW][GRIDH];\ndouble ax[GRIDW][GRIDH], ay[GRIDW][GRIDH];\n\n//========================================================================\n// Initialize grid\n//========================================================================\n\nvoid init_grid(void)\n{\n    int x, y;\n    double dx, dy, d;\n\n    for (y = 0; y < GRIDH;  y++)\n    {\n        for (x = 0; x < GRIDW;  x++)\n        {\n            dx = (double) (x - GRIDW / 2);\n            dy = (double) (y - GRIDH / 2);\n            d = sqrt(dx * dx + dy * dy);\n            if (d < 0.1 * (double) (GRIDW / 2))\n            {\n                d = d * 10.0;\n                p[x][y] = -cos(d * (M_PI / (double)(GRIDW * 4))) * 100.0;\n            }\n            else\n                p[x][y] = 0.0;\n\n            vx[x][y] = 0.0;\n            vy[x][y] = 0.0;\n        }\n    }\n}\n\n\n//========================================================================\n// Draw scene\n//========================================================================\n\nvoid draw_scene(GLFWwindow* window)\n{\n    // Clear the color and depth buffers\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n\n    // We don't want to modify the projection matrix\n    glMatrixMode(GL_MODELVIEW);\n    glLoadIdentity();\n\n    // Move back\n    glTranslatef(0.0, 0.0, -zoom);\n    // Rotate the view\n    glRotatef(beta, 1.0, 0.0, 0.0);\n    glRotatef(alpha, 0.0, 0.0, 1.0);\n\n    glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad);\n\n    glfwSwapBuffers(window);\n}\n\n\n//========================================================================\n// Initialize Miscellaneous OpenGL state\n//========================================================================\n\nvoid init_opengl(void)\n{\n    // Use Gouraud (smooth) shading\n    glShadeModel(GL_SMOOTH);\n\n    // Switch on the z-buffer\n    glEnable(GL_DEPTH_TEST);\n\n    glEnableClientState(GL_VERTEX_ARRAY);\n    glEnableClientState(GL_COLOR_ARRAY);\n    glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), vertex);\n    glColorPointer(3, GL_FLOAT, sizeof(struct Vertex), &vertex[0].r); // Pointer to the first color\n\n    glPointSize(2.0);\n\n    // Background color is black\n    glClearColor(0, 0, 0, 0);\n}\n\n\n//========================================================================\n// Modify the height of each vertex according to the pressure\n//========================================================================\n\nvoid adjust_grid(void)\n{\n    int pos;\n    int x, y;\n\n    for (y = 0; y < GRIDH;  y++)\n    {\n        for (x = 0;  x < GRIDW;  x++)\n        {\n            pos = y * GRIDW + x;\n            vertex[pos].z = (float) (p[x][y] * (1.0 / 50.0));\n        }\n    }\n}\n\n\n//========================================================================\n// Calculate wave propagation\n//========================================================================\n\nvoid calc_grid(void)\n{\n    int x, y, x2, y2;\n    double time_step = dt * ANIMATION_SPEED;\n\n    // Compute accelerations\n    for (x = 0;  x < GRIDW;  x++)\n    {\n        x2 = (x + 1) % GRIDW;\n        for(y = 0; y < GRIDH; y++)\n            ax[x][y] = p[x][y] - p[x2][y];\n    }\n\n    for (y = 0;  y < GRIDH;  y++)\n    {\n        y2 = (y + 1) % GRIDH;\n        for(x = 0; x < GRIDW; x++)\n            ay[x][y] = p[x][y] - p[x][y2];\n    }\n\n    // Compute speeds\n    for (x = 0;  x < GRIDW;  x++)\n    {\n        for (y = 0;  y < GRIDH;  y++)\n        {\n            vx[x][y] = vx[x][y] + ax[x][y] * time_step;\n            vy[x][y] = vy[x][y] + ay[x][y] * time_step;\n        }\n    }\n\n    // Compute pressure\n    for (x = 1;  x < GRIDW;  x++)\n    {\n        x2 = x - 1;\n        for (y = 1;  y < GRIDH;  y++)\n        {\n            y2 = y - 1;\n            p[x][y] = p[x][y] + (vx[x2][y] - vx[x][y] + vy[x][y2] - vy[x][y]) * time_step;\n        }\n    }\n}\n\n\n//========================================================================\n// Print errors\n//========================================================================\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\n\n//========================================================================\n// Handle key strokes\n//========================================================================\n\nvoid key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n        case GLFW_KEY_SPACE:\n            init_grid();\n            break;\n        case GLFW_KEY_LEFT:\n            alpha += 5;\n            break;\n        case GLFW_KEY_RIGHT:\n            alpha -= 5;\n            break;\n        case GLFW_KEY_UP:\n            beta -= 5;\n            break;\n        case GLFW_KEY_DOWN:\n            beta += 5;\n            break;\n        case GLFW_KEY_PAGE_UP:\n            zoom -= 0.25f;\n            if (zoom < 0.f)\n                zoom = 0.f;\n            break;\n        case GLFW_KEY_PAGE_DOWN:\n            zoom += 0.25f;\n            break;\n        default:\n            break;\n    }\n}\n\n\n//========================================================================\n// Callback function for mouse button events\n//========================================================================\n\nvoid mouse_button_callback(GLFWwindow* window, int button, int action, int mods)\n{\n    if (button != GLFW_MOUSE_BUTTON_LEFT)\n        return;\n\n    if (action == GLFW_PRESS)\n    {\n        glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n        glfwGetCursorPos(window, &cursorX, &cursorY);\n    }\n    else\n        glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);\n}\n\n\n//========================================================================\n// Callback function for cursor motion events\n//========================================================================\n\nvoid cursor_position_callback(GLFWwindow* window, double x, double y)\n{\n    if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)\n    {\n        alpha += (GLfloat) (x - cursorX) / 10.f;\n        beta += (GLfloat) (y - cursorY) / 10.f;\n\n        cursorX = x;\n        cursorY = y;\n    }\n}\n\n\n//========================================================================\n// Callback function for scroll events\n//========================================================================\n\nvoid scroll_callback(GLFWwindow* window, double x, double y)\n{\n    zoom += (float) y / 4.f;\n    if (zoom < 0)\n        zoom = 0;\n}\n\n\n//========================================================================\n// Callback function for framebuffer resize events\n//========================================================================\n\nvoid framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    float ratio = 1.f;\n    mat4x4 projection;\n\n    if (height > 0)\n        ratio = (float) width / (float) height;\n\n    // Setup viewport\n    glViewport(0, 0, width, height);\n\n    // Change to the projection matrix and set our viewing volume\n    glMatrixMode(GL_PROJECTION);\n    mat4x4_perspective(projection,\n                       60.f * (float) M_PI / 180.f,\n                       ratio,\n                       1.f, 1024.f);\n    glLoadMatrixf((const GLfloat*) projection);\n}\n\n\n//========================================================================\n// main\n//========================================================================\n\nint main(int argc, char* argv[])\n{\n    GLFWwindow* window;\n    double t, dt_total, t_old;\n    int width, height;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    window = glfwCreateWindow(640, 480, \"Wave Simulation\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwSetKeyCallback(window, key_callback);\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n    glfwSetMouseButtonCallback(window, mouse_button_callback);\n    glfwSetCursorPosCallback(window, cursor_position_callback);\n    glfwSetScrollCallback(window, scroll_callback);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwGetFramebufferSize(window, &width, &height);\n    framebuffer_size_callback(window, width, height);\n\n    // Initialize OpenGL\n    init_opengl();\n\n    // Initialize simulation\n    init_vertices();\n    init_grid();\n    adjust_grid();\n\n    // Initialize timer\n    t_old = glfwGetTime() - 0.01;\n\n    while (!glfwWindowShouldClose(window))\n    {\n        t = glfwGetTime();\n        dt_total = t - t_old;\n        t_old = t;\n\n        // Safety - iterate if dt_total is too large\n        while (dt_total > 0.f)\n        {\n            // Select iteration time step\n            dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;\n            dt_total -= dt;\n\n            // Calculate wave propagation\n            calc_grid();\n        }\n\n        // Compute height of each vertex\n        adjust_grid();\n\n        // Draw wave grid to OpenGL display\n        draw_scene(window);\n\n        glfwPollEvents();\n    }\n\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/include/GLFW/glfw3.h",
    "content": "/*************************************************************************\n * GLFW 3.1 - www.glfw.org\n * A library for OpenGL, window and input\n *------------------------------------------------------------------------\n * Copyright (c) 2002-2006 Marcus Geelnard\n * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n *\n * This software is provided 'as-is', without any express or implied\n * warranty. In no event will the authors be held liable for any damages\n * arising from the use of this software.\n *\n * Permission is granted to anyone to use this software for any purpose,\n * including commercial applications, and to alter it and redistribute it\n * freely, subject to the following restrictions:\n *\n * 1. The origin of this software must not be misrepresented; you must not\n *    claim that you wrote the original software. If you use this software\n *    in a product, an acknowledgment in the product documentation would\n *    be appreciated but is not required.\n *\n * 2. Altered source versions must be plainly marked as such, and must not\n *    be misrepresented as being the original software.\n *\n * 3. This notice may not be removed or altered from any source\n *    distribution.\n *\n *************************************************************************/\n\n#ifndef _glfw3_h_\n#define _glfw3_h_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*************************************************************************\n * Doxygen documentation\n *************************************************************************/\n\n/*! @defgroup context Context handling\n *\n *  This is the reference documentation for context related functions.  For more\n *  information, see the @ref context.\n */\n/*! @defgroup init Initialization, version and errors\n *\n *  This is the reference documentation for initialization and termination of\n *  the library, version management and error handling.  For more information,\n *  see the @ref intro.\n */\n/*! @defgroup input Input handling\n *\n *  This is the reference documentation for input related functions and types.\n *  For more information, see the @ref input.\n */\n/*! @defgroup monitor Monitor handling\n *\n *  This is the reference documentation for monitor related functions and types.\n *  For more information, see the @ref monitor.\n */\n/*! @defgroup window Window handling\n *\n *  This is the reference documentation for window related functions and types,\n *  including creation, deletion and event polling.  For more information, see\n *  the @ref window.\n */\n\n\n/*************************************************************************\n * Compiler- and platform-specific preprocessor work\n *************************************************************************/\n\n/* If we are we on Windows, we want a single define for it.\n */\n#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))\n #define _WIN32\n#endif /* _WIN32 */\n\n/* It is customary to use APIENTRY for OpenGL function pointer declarations on\n * all platforms.  Additionally, the Windows OpenGL header needs APIENTRY.\n */\n#ifndef APIENTRY\n #ifdef _WIN32\n  #define APIENTRY __stdcall\n #else\n  #define APIENTRY\n #endif\n#endif /* APIENTRY */\n\n/* Some Windows OpenGL headers need this.\n */\n#if !defined(WINGDIAPI) && defined(_WIN32)\n #define WINGDIAPI __declspec(dllimport)\n #define GLFW_WINGDIAPI_DEFINED\n#endif /* WINGDIAPI */\n\n/* Some Windows GLU headers need this.\n */\n#if !defined(CALLBACK) && defined(_WIN32)\n #define CALLBACK __stdcall\n #define GLFW_CALLBACK_DEFINED\n#endif /* CALLBACK */\n\n/* Most Windows GLU headers need wchar_t.\n * The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h.\n */\n#if !defined(GLFW_INCLUDE_NONE)\n #include <stddef.h>\n#endif\n\n/* Include the chosen client API headers.\n */\n#if defined(__APPLE_CC__)\n #if defined(GLFW_INCLUDE_GLCOREARB)\n  #include <OpenGL/gl3.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <OpenGL/gl3ext.h>\n  #endif\n #elif !defined(GLFW_INCLUDE_NONE)\n  #if !defined(GLFW_INCLUDE_GLEXT)\n   #define GL_GLEXT_LEGACY\n  #endif\n  #include <OpenGL/gl.h>\n #endif\n #if defined(GLFW_INCLUDE_GLU)\n  #include <OpenGL/glu.h>\n #endif\n#else\n #if defined(GLFW_INCLUDE_GLCOREARB)\n  #include <GL/glcorearb.h>\n #elif defined(GLFW_INCLUDE_ES1)\n  #include <GLES/gl.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <GLES/glext.h>\n  #endif\n #elif defined(GLFW_INCLUDE_ES2)\n  #include <GLES2/gl2.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <GLES2/gl2ext.h>\n  #endif\n #elif defined(GLFW_INCLUDE_ES3)\n  #include <GLES3/gl3.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <GLES3/gl2ext.h>\n  #endif\n #elif defined(GLFW_INCLUDE_ES31)\n  #include <GLES3/gl31.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <GLES3/gl2ext.h>\n  #endif\n #elif !defined(GLFW_INCLUDE_NONE)\n  #include <GL/gl.h>\n  #if defined(GLFW_INCLUDE_GLEXT)\n   #include <GL/glext.h>\n  #endif\n #endif\n #if defined(GLFW_INCLUDE_GLU)\n  #include <GL/glu.h>\n #endif\n#endif\n\n#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)\n /* GLFW_DLL must be defined by applications that are linking against the DLL\n  * version of the GLFW library.  _GLFW_BUILD_DLL is defined by the GLFW\n  * configuration header when compiling the DLL version of the library.\n  */\n #error \"You may not have both GLFW_DLL and _GLFW_BUILD_DLL defined\"\n#endif\n\n/* GLFWAPI is used to declare public API functions for export\n * from the DLL / shared library / dynamic library.\n */\n#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)\n /* We are building GLFW as a Win32 DLL */\n #define GLFWAPI __declspec(dllexport)\n#elif defined(_WIN32) && defined(GLFW_DLL)\n /* We are calling GLFW as a Win32 DLL */\n #define GLFWAPI __declspec(dllimport)\n#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)\n /* We are building GLFW as a shared / dynamic library */\n #define GLFWAPI __attribute__((visibility(\"default\")))\n#else\n /* We are building or calling GLFW as a static library */\n #define GLFWAPI\n#endif\n\n\n/*************************************************************************\n * GLFW API tokens\n *************************************************************************/\n\n/*! @name GLFW version macros\n *  @{ */\n/*! @brief The major version number of the GLFW library.\n *\n *  This is incremented when the API is changed in non-compatible ways.\n *  @ingroup init\n */\n#define GLFW_VERSION_MAJOR          3\n/*! @brief The minor version number of the GLFW library.\n *\n *  This is incremented when features are added to the API but it remains\n *  backward-compatible.\n *  @ingroup init\n */\n#define GLFW_VERSION_MINOR          1\n/*! @brief The revision number of the GLFW library.\n *\n *  This is incremented when a bug fix release is made that does not contain any\n *  API changes.\n *  @ingroup init\n */\n#define GLFW_VERSION_REVISION       2\n/*! @} */\n\n/*! @name Key and button actions\n *  @{ */\n/*! @brief The key or mouse button was released.\n *\n *  The key or mouse button was released.\n *\n *  @ingroup input\n */\n#define GLFW_RELEASE                0\n/*! @brief The key or mouse button was pressed.\n *\n *  The key or mouse button was pressed.\n *\n *  @ingroup input\n */\n#define GLFW_PRESS                  1\n/*! @brief The key was held down until it repeated.\n *\n *  The key was held down until it repeated.\n *\n *  @ingroup input\n */\n#define GLFW_REPEAT                 2\n/*! @} */\n\n/*! @defgroup keys Keyboard keys\n *\n *  See [key input](@ref input_key) for how these are used.\n *\n *  These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),\n *  but re-arranged to map to 7-bit ASCII for printable keys (function keys are\n *  put in the 256+ range).\n *\n *  The naming of the key codes follow these rules:\n *   - The US keyboard layout is used\n *   - Names of printable alpha-numeric characters are used (e.g. \"A\", \"R\",\n *     \"3\", etc.)\n *   - For non-alphanumeric characters, Unicode:ish names are used (e.g.\n *     \"COMMA\", \"LEFT_SQUARE_BRACKET\", etc.). Note that some names do not\n *     correspond to the Unicode standard (usually for brevity)\n *   - Keys that lack a clear US mapping are named \"WORLD_x\"\n *   - For non-printable keys, custom names are used (e.g. \"F4\",\n *     \"BACKSPACE\", etc.)\n *\n *  @ingroup input\n *  @{\n */\n\n/* The unknown key */\n#define GLFW_KEY_UNKNOWN            -1\n\n/* Printable keys */\n#define GLFW_KEY_SPACE              32\n#define GLFW_KEY_APOSTROPHE         39  /* ' */\n#define GLFW_KEY_COMMA              44  /* , */\n#define GLFW_KEY_MINUS              45  /* - */\n#define GLFW_KEY_PERIOD             46  /* . */\n#define GLFW_KEY_SLASH              47  /* / */\n#define GLFW_KEY_0                  48\n#define GLFW_KEY_1                  49\n#define GLFW_KEY_2                  50\n#define GLFW_KEY_3                  51\n#define GLFW_KEY_4                  52\n#define GLFW_KEY_5                  53\n#define GLFW_KEY_6                  54\n#define GLFW_KEY_7                  55\n#define GLFW_KEY_8                  56\n#define GLFW_KEY_9                  57\n#define GLFW_KEY_SEMICOLON          59  /* ; */\n#define GLFW_KEY_EQUAL              61  /* = */\n#define GLFW_KEY_A                  65\n#define GLFW_KEY_B                  66\n#define GLFW_KEY_C                  67\n#define GLFW_KEY_D                  68\n#define GLFW_KEY_E                  69\n#define GLFW_KEY_F                  70\n#define GLFW_KEY_G                  71\n#define GLFW_KEY_H                  72\n#define GLFW_KEY_I                  73\n#define GLFW_KEY_J                  74\n#define GLFW_KEY_K                  75\n#define GLFW_KEY_L                  76\n#define GLFW_KEY_M                  77\n#define GLFW_KEY_N                  78\n#define GLFW_KEY_O                  79\n#define GLFW_KEY_P                  80\n#define GLFW_KEY_Q                  81\n#define GLFW_KEY_R                  82\n#define GLFW_KEY_S                  83\n#define GLFW_KEY_T                  84\n#define GLFW_KEY_U                  85\n#define GLFW_KEY_V                  86\n#define GLFW_KEY_W                  87\n#define GLFW_KEY_X                  88\n#define GLFW_KEY_Y                  89\n#define GLFW_KEY_Z                  90\n#define GLFW_KEY_LEFT_BRACKET       91  /* [ */\n#define GLFW_KEY_BACKSLASH          92  /* \\ */\n#define GLFW_KEY_RIGHT_BRACKET      93  /* ] */\n#define GLFW_KEY_GRAVE_ACCENT       96  /* ` */\n#define GLFW_KEY_WORLD_1            161 /* non-US #1 */\n#define GLFW_KEY_WORLD_2            162 /* non-US #2 */\n\n/* Function keys */\n#define GLFW_KEY_ESCAPE             256\n#define GLFW_KEY_ENTER              257\n#define GLFW_KEY_TAB                258\n#define GLFW_KEY_BACKSPACE          259\n#define GLFW_KEY_INSERT             260\n#define GLFW_KEY_DELETE             261\n#define GLFW_KEY_RIGHT              262\n#define GLFW_KEY_LEFT               263\n#define GLFW_KEY_DOWN               264\n#define GLFW_KEY_UP                 265\n#define GLFW_KEY_PAGE_UP            266\n#define GLFW_KEY_PAGE_DOWN          267\n#define GLFW_KEY_HOME               268\n#define GLFW_KEY_END                269\n#define GLFW_KEY_CAPS_LOCK          280\n#define GLFW_KEY_SCROLL_LOCK        281\n#define GLFW_KEY_NUM_LOCK           282\n#define GLFW_KEY_PRINT_SCREEN       283\n#define GLFW_KEY_PAUSE              284\n#define GLFW_KEY_F1                 290\n#define GLFW_KEY_F2                 291\n#define GLFW_KEY_F3                 292\n#define GLFW_KEY_F4                 293\n#define GLFW_KEY_F5                 294\n#define GLFW_KEY_F6                 295\n#define GLFW_KEY_F7                 296\n#define GLFW_KEY_F8                 297\n#define GLFW_KEY_F9                 298\n#define GLFW_KEY_F10                299\n#define GLFW_KEY_F11                300\n#define GLFW_KEY_F12                301\n#define GLFW_KEY_F13                302\n#define GLFW_KEY_F14                303\n#define GLFW_KEY_F15                304\n#define GLFW_KEY_F16                305\n#define GLFW_KEY_F17                306\n#define GLFW_KEY_F18                307\n#define GLFW_KEY_F19                308\n#define GLFW_KEY_F20                309\n#define GLFW_KEY_F21                310\n#define GLFW_KEY_F22                311\n#define GLFW_KEY_F23                312\n#define GLFW_KEY_F24                313\n#define GLFW_KEY_F25                314\n#define GLFW_KEY_KP_0               320\n#define GLFW_KEY_KP_1               321\n#define GLFW_KEY_KP_2               322\n#define GLFW_KEY_KP_3               323\n#define GLFW_KEY_KP_4               324\n#define GLFW_KEY_KP_5               325\n#define GLFW_KEY_KP_6               326\n#define GLFW_KEY_KP_7               327\n#define GLFW_KEY_KP_8               328\n#define GLFW_KEY_KP_9               329\n#define GLFW_KEY_KP_DECIMAL         330\n#define GLFW_KEY_KP_DIVIDE          331\n#define GLFW_KEY_KP_MULTIPLY        332\n#define GLFW_KEY_KP_SUBTRACT        333\n#define GLFW_KEY_KP_ADD             334\n#define GLFW_KEY_KP_ENTER           335\n#define GLFW_KEY_KP_EQUAL           336\n#define GLFW_KEY_LEFT_SHIFT         340\n#define GLFW_KEY_LEFT_CONTROL       341\n#define GLFW_KEY_LEFT_ALT           342\n#define GLFW_KEY_LEFT_SUPER         343\n#define GLFW_KEY_RIGHT_SHIFT        344\n#define GLFW_KEY_RIGHT_CONTROL      345\n#define GLFW_KEY_RIGHT_ALT          346\n#define GLFW_KEY_RIGHT_SUPER        347\n#define GLFW_KEY_MENU               348\n#define GLFW_KEY_LAST               GLFW_KEY_MENU\n\n/*! @} */\n\n/*! @defgroup mods Modifier key flags\n *\n *  See [key input](@ref input_key) for how these are used.\n *\n *  @ingroup input\n *  @{ */\n\n/*! @brief If this bit is set one or more Shift keys were held down.\n */\n#define GLFW_MOD_SHIFT           0x0001\n/*! @brief If this bit is set one or more Control keys were held down.\n */\n#define GLFW_MOD_CONTROL         0x0002\n/*! @brief If this bit is set one or more Alt keys were held down.\n */\n#define GLFW_MOD_ALT             0x0004\n/*! @brief If this bit is set one or more Super keys were held down.\n */\n#define GLFW_MOD_SUPER           0x0008\n\n/*! @} */\n\n/*! @defgroup buttons Mouse buttons\n *\n *  See [mouse button input](@ref input_mouse_button) for how these are used.\n *\n *  @ingroup input\n *  @{ */\n#define GLFW_MOUSE_BUTTON_1         0\n#define GLFW_MOUSE_BUTTON_2         1\n#define GLFW_MOUSE_BUTTON_3         2\n#define GLFW_MOUSE_BUTTON_4         3\n#define GLFW_MOUSE_BUTTON_5         4\n#define GLFW_MOUSE_BUTTON_6         5\n#define GLFW_MOUSE_BUTTON_7         6\n#define GLFW_MOUSE_BUTTON_8         7\n#define GLFW_MOUSE_BUTTON_LAST      GLFW_MOUSE_BUTTON_8\n#define GLFW_MOUSE_BUTTON_LEFT      GLFW_MOUSE_BUTTON_1\n#define GLFW_MOUSE_BUTTON_RIGHT     GLFW_MOUSE_BUTTON_2\n#define GLFW_MOUSE_BUTTON_MIDDLE    GLFW_MOUSE_BUTTON_3\n/*! @} */\n\n/*! @defgroup joysticks Joysticks\n *\n *  See [joystick input](@ref joystick) for how these are used.\n *\n *  @ingroup input\n *  @{ */\n#define GLFW_JOYSTICK_1             0\n#define GLFW_JOYSTICK_2             1\n#define GLFW_JOYSTICK_3             2\n#define GLFW_JOYSTICK_4             3\n#define GLFW_JOYSTICK_5             4\n#define GLFW_JOYSTICK_6             5\n#define GLFW_JOYSTICK_7             6\n#define GLFW_JOYSTICK_8             7\n#define GLFW_JOYSTICK_9             8\n#define GLFW_JOYSTICK_10            9\n#define GLFW_JOYSTICK_11            10\n#define GLFW_JOYSTICK_12            11\n#define GLFW_JOYSTICK_13            12\n#define GLFW_JOYSTICK_14            13\n#define GLFW_JOYSTICK_15            14\n#define GLFW_JOYSTICK_16            15\n#define GLFW_JOYSTICK_LAST          GLFW_JOYSTICK_16\n/*! @} */\n\n/*! @defgroup errors Error codes\n *\n *  See [error handling](@ref error_handling) for how these are used.\n *\n *  @ingroup init\n *  @{ */\n/*! @brief GLFW has not been initialized.\n *\n *  This occurs if a GLFW function was called that may not be called unless the\n *  library is [initialized](@ref intro_init).\n *\n *  @par Analysis\n *  Application programmer error.  Initialize GLFW before calling any function\n *  that requires initialization.\n */\n#define GLFW_NOT_INITIALIZED        0x00010001\n/*! @brief No context is current for this thread.\n *\n *  This occurs if a GLFW function was called that needs and operates on the\n *  current OpenGL or OpenGL ES context but no context is current on the calling\n *  thread.  One such function is @ref glfwSwapInterval.\n *\n *  @par Analysis\n *  Application programmer error.  Ensure a context is current before calling\n *  functions that require a current context.\n */\n#define GLFW_NO_CURRENT_CONTEXT     0x00010002\n/*! @brief One of the arguments to the function was an invalid enum value.\n *\n *  One of the arguments to the function was an invalid enum value, for example\n *  requesting [GLFW_RED_BITS](@ref window_hints_fb) with @ref\n *  glfwGetWindowAttrib.\n *\n *  @par Analysis\n *  Application programmer error.  Fix the offending call.\n */\n#define GLFW_INVALID_ENUM           0x00010003\n/*! @brief One of the arguments to the function was an invalid value.\n *\n *  One of the arguments to the function was an invalid value, for example\n *  requesting a non-existent OpenGL or OpenGL ES version like 2.7.\n *\n *  Requesting a valid but unavailable OpenGL or OpenGL ES version will instead\n *  result in a @ref GLFW_VERSION_UNAVAILABLE error.\n *\n *  @par Analysis\n *  Application programmer error.  Fix the offending call.\n */\n#define GLFW_INVALID_VALUE          0x00010004\n/*! @brief A memory allocation failed.\n *\n *  A memory allocation failed.\n *\n *  @par Analysis\n *  A bug in GLFW or the underlying operating system.  Report the bug to our\n *  [issue tracker](https://github.com/glfw/glfw/issues).\n */\n#define GLFW_OUT_OF_MEMORY          0x00010005\n/*! @brief GLFW could not find support for the requested client API on the\n *  system.\n *\n *  GLFW could not find support for the requested client API on the system.  If\n *  emitted by functions other than @ref glfwCreateWindow, no supported client\n *  API was found.\n *\n *  @par Analysis\n *  The installed graphics driver does not support the requested client API, or\n *  does not support it via the chosen context creation backend.  Below are\n *  a few examples.\n *\n *  @par\n *  Some pre-installed Windows graphics drivers do not support OpenGL.  AMD only\n *  supports OpenGL ES via EGL, while Nvidia and Intel only support it via\n *  a WGL or GLX extension.  OS X does not provide OpenGL ES at all.  The Mesa\n *  EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary\n *  driver.\n */\n#define GLFW_API_UNAVAILABLE        0x00010006\n/*! @brief The requested OpenGL or OpenGL ES version is not available.\n *\n *  The requested OpenGL or OpenGL ES version (including any requested context\n *  or framebuffer hints) is not available on this machine.\n *\n *  @par Analysis\n *  The machine does not support your requirements.  If your application is\n *  sufficiently flexible, downgrade your requirements and try again.\n *  Otherwise, inform the user that their machine does not match your\n *  requirements.\n *\n *  @par\n *  Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0\n *  comes out before the 4.x series gets that far, also fail with this error and\n *  not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions\n *  will exist.\n */\n#define GLFW_VERSION_UNAVAILABLE    0x00010007\n/*! @brief A platform-specific error occurred that does not match any of the\n *  more specific categories.\n *\n *  A platform-specific error occurred that does not match any of the more\n *  specific categories.\n *\n *  @par Analysis\n *  A bug or configuration error in GLFW, the underlying operating system or\n *  its drivers, or a lack of required resources.  Report the issue to our\n *  [issue tracker](https://github.com/glfw/glfw/issues).\n */\n#define GLFW_PLATFORM_ERROR         0x00010008\n/*! @brief The requested format is not supported or available.\n *\n *  If emitted during window creation, the requested pixel format is not\n *  supported.\n *\n *  If emitted when querying the clipboard, the contents of the clipboard could\n *  not be converted to the requested format.\n *\n *  @par Analysis\n *  If emitted during window creation, one or more\n *  [hard constraints](@ref window_hints_hard) did not match any of the\n *  available pixel formats.  If your application is sufficiently flexible,\n *  downgrade your requirements and try again.  Otherwise, inform the user that\n *  their machine does not match your requirements.\n *\n *  @par\n *  If emitted when querying the clipboard, ignore the error or report it to\n *  the user, as appropriate.\n */\n#define GLFW_FORMAT_UNAVAILABLE     0x00010009\n/*! @} */\n\n#define GLFW_FOCUSED                0x00020001\n#define GLFW_ICONIFIED              0x00020002\n#define GLFW_RESIZABLE              0x00020003\n#define GLFW_VISIBLE                0x00020004\n#define GLFW_DECORATED              0x00020005\n#define GLFW_AUTO_ICONIFY           0x00020006\n#define GLFW_FLOATING               0x00020007\n\n#define GLFW_RED_BITS               0x00021001\n#define GLFW_GREEN_BITS             0x00021002\n#define GLFW_BLUE_BITS              0x00021003\n#define GLFW_ALPHA_BITS             0x00021004\n#define GLFW_DEPTH_BITS             0x00021005\n#define GLFW_STENCIL_BITS           0x00021006\n#define GLFW_ACCUM_RED_BITS         0x00021007\n#define GLFW_ACCUM_GREEN_BITS       0x00021008\n#define GLFW_ACCUM_BLUE_BITS        0x00021009\n#define GLFW_ACCUM_ALPHA_BITS       0x0002100A\n#define GLFW_AUX_BUFFERS            0x0002100B\n#define GLFW_STEREO                 0x0002100C\n#define GLFW_SAMPLES                0x0002100D\n#define GLFW_SRGB_CAPABLE           0x0002100E\n#define GLFW_REFRESH_RATE           0x0002100F\n#define GLFW_DOUBLEBUFFER           0x00021010\n\n#define GLFW_CLIENT_API             0x00022001\n#define GLFW_CONTEXT_VERSION_MAJOR  0x00022002\n#define GLFW_CONTEXT_VERSION_MINOR  0x00022003\n#define GLFW_CONTEXT_REVISION       0x00022004\n#define GLFW_CONTEXT_ROBUSTNESS     0x00022005\n#define GLFW_OPENGL_FORWARD_COMPAT  0x00022006\n#define GLFW_OPENGL_DEBUG_CONTEXT   0x00022007\n#define GLFW_OPENGL_PROFILE         0x00022008\n#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009\n\n#define GLFW_OPENGL_API             0x00030001\n#define GLFW_OPENGL_ES_API          0x00030002\n\n#define GLFW_NO_ROBUSTNESS                   0\n#define GLFW_NO_RESET_NOTIFICATION  0x00031001\n#define GLFW_LOSE_CONTEXT_ON_RESET  0x00031002\n\n#define GLFW_OPENGL_ANY_PROFILE              0\n#define GLFW_OPENGL_CORE_PROFILE    0x00032001\n#define GLFW_OPENGL_COMPAT_PROFILE  0x00032002\n\n#define GLFW_CURSOR                 0x00033001\n#define GLFW_STICKY_KEYS            0x00033002\n#define GLFW_STICKY_MOUSE_BUTTONS   0x00033003\n\n#define GLFW_CURSOR_NORMAL          0x00034001\n#define GLFW_CURSOR_HIDDEN          0x00034002\n#define GLFW_CURSOR_DISABLED        0x00034003\n\n#define GLFW_ANY_RELEASE_BEHAVIOR            0\n#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001\n#define GLFW_RELEASE_BEHAVIOR_NONE  0x00035002\n\n/*! @defgroup shapes Standard cursor shapes\n *\n *  See [standard cursor creation](@ref cursor_standard) for how these are used.\n *\n *  @ingroup input\n *  @{ */\n\n/*! @brief The regular arrow cursor shape.\n *\n *  The regular arrow cursor.\n */\n#define GLFW_ARROW_CURSOR           0x00036001\n/*! @brief The text input I-beam cursor shape.\n *\n *  The text input I-beam cursor shape.\n */\n#define GLFW_IBEAM_CURSOR           0x00036002\n/*! @brief The crosshair shape.\n *\n *  The crosshair shape.\n */\n#define GLFW_CROSSHAIR_CURSOR       0x00036003\n/*! @brief The hand shape.\n *\n *  The hand shape.\n */\n#define GLFW_HAND_CURSOR            0x00036004\n/*! @brief The horizontal resize arrow shape.\n *\n *  The horizontal resize arrow shape.\n */\n#define GLFW_HRESIZE_CURSOR         0x00036005\n/*! @brief The vertical resize arrow shape.\n *\n *  The vertical resize arrow shape.\n */\n#define GLFW_VRESIZE_CURSOR         0x00036006\n/*! @} */\n\n#define GLFW_CONNECTED              0x00040001\n#define GLFW_DISCONNECTED           0x00040002\n\n#define GLFW_DONT_CARE              -1\n\n\n/*************************************************************************\n * GLFW API types\n *************************************************************************/\n\n/*! @brief Client API function pointer type.\n *\n *  Generic function pointer used for returning client API function pointers\n *  without forcing a cast from a regular pointer.\n *\n *  @ingroup context\n */\ntypedef void (*GLFWglproc)(void);\n\n/*! @brief Opaque monitor object.\n *\n *  Opaque monitor object.\n *\n *  @ingroup monitor\n */\ntypedef struct GLFWmonitor GLFWmonitor;\n\n/*! @brief Opaque window object.\n *\n *  Opaque window object.\n *\n *  @ingroup window\n */\ntypedef struct GLFWwindow GLFWwindow;\n\n/*! @brief Opaque cursor object.\n *\n *  Opaque cursor object.\n *\n *  @ingroup cursor\n */\ntypedef struct GLFWcursor GLFWcursor;\n\n/*! @brief The function signature for error callbacks.\n *\n *  This is the function signature for error callback functions.\n *\n *  @param[in] error An [error code](@ref errors).\n *  @param[in] description A UTF-8 encoded string describing the error.\n *\n *  @sa glfwSetErrorCallback\n *\n *  @ingroup init\n */\ntypedef void (* GLFWerrorfun)(int,const char*);\n\n/*! @brief The function signature for window position callbacks.\n *\n *  This is the function signature for window position callback functions.\n *\n *  @param[in] window The window that was moved.\n *  @param[in] xpos The new x-coordinate, in screen coordinates, of the\n *  upper-left corner of the client area of the window.\n *  @param[in] ypos The new y-coordinate, in screen coordinates, of the\n *  upper-left corner of the client area of the window.\n *\n *  @sa glfwSetWindowPosCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);\n\n/*! @brief The function signature for window resize callbacks.\n *\n *  This is the function signature for window size callback functions.\n *\n *  @param[in] window The window that was resized.\n *  @param[in] width The new width, in screen coordinates, of the window.\n *  @param[in] height The new height, in screen coordinates, of the window.\n *\n *  @sa glfwSetWindowSizeCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);\n\n/*! @brief The function signature for window close callbacks.\n *\n *  This is the function signature for window close callback functions.\n *\n *  @param[in] window The window that the user attempted to close.\n *\n *  @sa glfwSetWindowCloseCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowclosefun)(GLFWwindow*);\n\n/*! @brief The function signature for window content refresh callbacks.\n *\n *  This is the function signature for window refresh callback functions.\n *\n *  @param[in] window The window whose content needs to be refreshed.\n *\n *  @sa glfwSetWindowRefreshCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowrefreshfun)(GLFWwindow*);\n\n/*! @brief The function signature for window focus/defocus callbacks.\n *\n *  This is the function signature for window focus callback functions.\n *\n *  @param[in] window The window that gained or lost input focus.\n *  @param[in] focused `GL_TRUE` if the window was given input focus, or\n *  `GL_FALSE` if it lost it.\n *\n *  @sa glfwSetWindowFocusCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);\n\n/*! @brief The function signature for window iconify/restore callbacks.\n *\n *  This is the function signature for window iconify/restore callback\n *  functions.\n *\n *  @param[in] window The window that was iconified or restored.\n *  @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`\n *  if it was restored.\n *\n *  @sa glfwSetWindowIconifyCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);\n\n/*! @brief The function signature for framebuffer resize callbacks.\n *\n *  This is the function signature for framebuffer resize callback\n *  functions.\n *\n *  @param[in] window The window whose framebuffer was resized.\n *  @param[in] width The new width, in pixels, of the framebuffer.\n *  @param[in] height The new height, in pixels, of the framebuffer.\n *\n *  @sa glfwSetFramebufferSizeCallback\n *\n *  @ingroup window\n */\ntypedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);\n\n/*! @brief The function signature for mouse button callbacks.\n *\n *  This is the function signature for mouse button callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] button The [mouse button](@ref buttons) that was pressed or\n *  released.\n *  @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.\n *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were\n *  held down.\n *\n *  @sa glfwSetMouseButtonCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);\n\n/*! @brief The function signature for cursor position callbacks.\n *\n *  This is the function signature for cursor position callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] xpos The new x-coordinate, in screen coordinates, of the cursor.\n *  @param[in] ypos The new y-coordinate, in screen coordinates, of the cursor.\n *\n *  @sa glfwSetCursorPosCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);\n\n/*! @brief The function signature for cursor enter/leave callbacks.\n *\n *  This is the function signature for cursor enter/leave callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] entered `GL_TRUE` if the cursor entered the window's client\n *  area, or `GL_FALSE` if it left it.\n *\n *  @sa glfwSetCursorEnterCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWcursorenterfun)(GLFWwindow*,int);\n\n/*! @brief The function signature for scroll callbacks.\n *\n *  This is the function signature for scroll callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] xoffset The scroll offset along the x-axis.\n *  @param[in] yoffset The scroll offset along the y-axis.\n *\n *  @sa glfwSetScrollCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWscrollfun)(GLFWwindow*,double,double);\n\n/*! @brief The function signature for keyboard key callbacks.\n *\n *  This is the function signature for keyboard key callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] key The [keyboard key](@ref keys) that was pressed or released.\n *  @param[in] scancode The system-specific scancode of the key.\n *  @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.\n *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were\n *  held down.\n *\n *  @sa glfwSetKeyCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);\n\n/*! @brief The function signature for Unicode character callbacks.\n *\n *  This is the function signature for Unicode character callback functions.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] codepoint The Unicode code point of the character.\n *\n *  @sa glfwSetCharCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);\n\n/*! @brief The function signature for Unicode character with modifiers\n *  callbacks.\n *\n *  This is the function signature for Unicode character with modifiers callback\n *  functions.  It is called for each input character, regardless of what\n *  modifier keys are held down.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] codepoint The Unicode code point of the character.\n *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were\n *  held down.\n *\n *  @sa glfwSetCharModsCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);\n\n/*! @brief The function signature for file drop callbacks.\n *\n *  This is the function signature for file drop callbacks.\n *\n *  @param[in] window The window that received the event.\n *  @param[in] count The number of dropped files.\n *  @param[in] paths The UTF-8 encoded file and/or directory path names.\n *\n *  @sa glfwSetDropCallback\n *\n *  @ingroup input\n */\ntypedef void (* GLFWdropfun)(GLFWwindow*,int,const char**);\n\n/*! @brief The function signature for monitor configuration callbacks.\n *\n *  This is the function signature for monitor configuration callback functions.\n *\n *  @param[in] monitor The monitor that was connected or disconnected.\n *  @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.\n *\n *  @sa glfwSetMonitorCallback\n *\n *  @ingroup monitor\n */\ntypedef void (* GLFWmonitorfun)(GLFWmonitor*,int);\n\n/*! @brief Video mode type.\n *\n *  This describes a single video mode.\n *\n *  @ingroup monitor\n */\ntypedef struct GLFWvidmode\n{\n    /*! The width, in screen coordinates, of the video mode.\n     */\n    int width;\n    /*! The height, in screen coordinates, of the video mode.\n     */\n    int height;\n    /*! The bit depth of the red channel of the video mode.\n     */\n    int redBits;\n    /*! The bit depth of the green channel of the video mode.\n     */\n    int greenBits;\n    /*! The bit depth of the blue channel of the video mode.\n     */\n    int blueBits;\n    /*! The refresh rate, in Hz, of the video mode.\n     */\n    int refreshRate;\n} GLFWvidmode;\n\n/*! @brief Gamma ramp.\n *\n *  This describes the gamma ramp for a monitor.\n *\n *  @sa glfwGetGammaRamp glfwSetGammaRamp\n *\n *  @ingroup monitor\n */\ntypedef struct GLFWgammaramp\n{\n    /*! An array of value describing the response of the red channel.\n     */\n    unsigned short* red;\n    /*! An array of value describing the response of the green channel.\n     */\n    unsigned short* green;\n    /*! An array of value describing the response of the blue channel.\n     */\n    unsigned short* blue;\n    /*! The number of elements in each array.\n     */\n    unsigned int size;\n} GLFWgammaramp;\n\n/*! @brief Image data.\n */\ntypedef struct GLFWimage\n{\n    /*! The width, in pixels, of this image.\n     */\n    int width;\n    /*! The height, in pixels, of this image.\n     */\n    int height;\n    /*! The pixel data of this image, arranged left-to-right, top-to-bottom.\n     */\n    unsigned char* pixels;\n} GLFWimage;\n\n\n/*************************************************************************\n * GLFW API functions\n *************************************************************************/\n\n/*! @brief Initializes the GLFW library.\n *\n *  This function initializes the GLFW library.  Before most GLFW functions can\n *  be used, GLFW must be initialized, and before an application terminates GLFW\n *  should be terminated in order to free any resources allocated during or\n *  after initialization.\n *\n *  If this function fails, it calls @ref glfwTerminate before returning.  If it\n *  succeeds, you should call @ref glfwTerminate before the application exits.\n *\n *  Additional calls to this function after successful initialization but before\n *  termination will return `GL_TRUE` immediately.\n *\n *  @return `GL_TRUE` if successful, or `GL_FALSE` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @remarks __OS X:__ This function will change the current directory of the\n *  application to the `Contents/Resources` subdirectory of the application's\n *  bundle, if present.  This can be disabled with a\n *  [compile-time option](@ref compile_options_osx).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref intro_init\n *  @sa glfwTerminate\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup init\n */\nGLFWAPI int glfwInit(void);\n\n/*! @brief Terminates the GLFW library.\n *\n *  This function destroys all remaining windows and cursors, restores any\n *  modified gamma ramps and frees any other allocated resources.  Once this\n *  function is called, you must again call @ref glfwInit successfully before\n *  you will be able to use most GLFW functions.\n *\n *  If GLFW has been successfully initialized, this function should be called\n *  before the application exits.  If initialization fails, there is no need to\n *  call this function, as it is called by @ref glfwInit before it returns\n *  failure.\n *\n *  @remarks This function may be called before @ref glfwInit.\n *\n *  @warning No window's context may be current on another thread when this\n *  function is called.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref intro_init\n *  @sa glfwInit\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup init\n */\nGLFWAPI void glfwTerminate(void);\n\n/*! @brief Retrieves the version of the GLFW library.\n *\n *  This function retrieves the major, minor and revision numbers of the GLFW\n *  library.  It is intended for when you are using GLFW as a shared library and\n *  want to ensure that you are using the minimum required version.\n *\n *  Any or all of the version arguments may be `NULL`.  This function always\n *  succeeds.\n *\n *  @param[out] major Where to store the major version number, or `NULL`.\n *  @param[out] minor Where to store the minor version number, or `NULL`.\n *  @param[out] rev Where to store the revision number, or `NULL`.\n *\n *  @remarks This function may be called before @ref glfwInit.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref intro_version\n *  @sa glfwGetVersionString\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup init\n */\nGLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);\n\n/*! @brief Returns a string describing the compile-time configuration.\n *\n *  This function returns the compile-time generated\n *  [version string](@ref intro_version_string) of the GLFW library binary.  It\n *  describes the version, platform, compiler and any platform-specific\n *  compile-time options.\n *\n *  __Do not use the version string__ to parse the GLFW library version.  The\n *  @ref glfwGetVersion function already provides the version of the running\n *  library binary.\n *\n *  This function always succeeds.\n *\n *  @return The GLFW version string.\n *\n *  @remarks This function may be called before @ref glfwInit.\n *\n *  @par Pointer Lifetime\n *  The returned string is static and compile-time generated.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref intro_version\n *  @sa glfwGetVersion\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup init\n */\nGLFWAPI const char* glfwGetVersionString(void);\n\n/*! @brief Sets the error callback.\n *\n *  This function sets the error callback, which is called with an error code\n *  and a human-readable description each time a GLFW error occurs.\n *\n *  The error callback is called on the thread where the error occurred.  If you\n *  are using GLFW from multiple threads, your error callback needs to be\n *  written accordingly.\n *\n *  Because the description string may have been generated specifically for that\n *  error, it is not guaranteed to be valid after the callback has returned.  If\n *  you wish to use it after the callback returns, you need to make a copy.\n *\n *  Once set, the error callback remains set even after the library has been\n *  terminated.\n *\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set.\n *\n *  @remarks This function may be called before @ref glfwInit.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref error_handling\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup init\n */\nGLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun);\n\n/*! @brief Returns the currently connected monitors.\n *\n *  This function returns an array of handles for all currently connected\n *  monitors.  The primary monitor is always first in the returned array.  If no\n *  monitors were found, this function returns `NULL`.\n *\n *  @param[out] count Where to store the number of monitors in the returned\n *  array.  This is set to zero if an error occurred.\n *  @return An array of monitor handles, or `NULL` if no monitors were found or\n *  if an [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned array is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is guaranteed to be valid only until the monitor configuration\n *  changes or the library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_monitors\n *  @sa @ref monitor_event\n *  @sa glfwGetPrimaryMonitor\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI GLFWmonitor** glfwGetMonitors(int* count);\n\n/*! @brief Returns the primary monitor.\n *\n *  This function returns the primary monitor.  This is usually the monitor\n *  where elements like the task bar or global menu bar are located.\n *\n *  @return The primary monitor, or `NULL` if no monitors were found or if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @remarks The primary monitor is always first in the array returned by @ref\n *  glfwGetMonitors.\n *\n *  @sa @ref monitor_monitors\n *  @sa glfwGetMonitors\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);\n\n/*! @brief Returns the position of the monitor's viewport on the virtual screen.\n *\n *  This function returns the position, in screen coordinates, of the upper-left\n *  corner of the specified monitor.\n *\n *  Any or all of the position arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` position arguments will be set to zero.\n *\n *  @param[in] monitor The monitor to query.\n *  @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.\n *  @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_properties\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);\n\n/*! @brief Returns the physical size of the monitor.\n *\n *  This function returns the size, in millimetres, of the display area of the\n *  specified monitor.\n *\n *  Some systems do not provide accurate monitor size information, either\n *  because the monitor\n *  [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)\n *  data is incorrect or because the driver does not report it accurately.\n *\n *  Any or all of the size arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` size arguments will be set to zero.\n *\n *  @param[in] monitor The monitor to query.\n *  @param[out] widthMM Where to store the width, in millimetres, of the\n *  monitor's display area, or `NULL`.\n *  @param[out] heightMM Where to store the height, in millimetres, of the\n *  monitor's display area, or `NULL`.\n *\n *  @remarks __Windows:__ The OS calculates the returned physical size from the\n *  current resolution and system DPI instead of querying the monitor EDID data.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_properties\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);\n\n/*! @brief Returns the name of the specified monitor.\n *\n *  This function returns a human-readable name, encoded as UTF-8, of the\n *  specified monitor.  The name typically reflects the make and model of the\n *  monitor and is not guaranteed to be unique among the connected monitors.\n *\n *  @param[in] monitor The monitor to query.\n *  @return The UTF-8 encoded name of the monitor, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned string is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified monitor is disconnected or the\n *  library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_properties\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);\n\n/*! @brief Sets the monitor configuration callback.\n *\n *  This function sets the monitor configuration callback, or removes the\n *  currently set callback.  This is called when a monitor is connected to or\n *  disconnected from the system.\n *\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @bug __X11:__ This callback is not yet called on monitor configuration\n *  changes.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_event\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun);\n\n/*! @brief Returns the available video modes for the specified monitor.\n *\n *  This function returns an array of all video modes supported by the specified\n *  monitor.  The returned array is sorted in ascending order, first by color\n *  bit depth (the sum of all channel depths) and then by resolution area (the\n *  product of width and height).\n *\n *  @param[in] monitor The monitor to query.\n *  @param[out] count Where to store the number of video modes in the returned\n *  array.  This is set to zero if an error occurred.\n *  @return An array of video modes, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned array is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified monitor is disconnected, this\n *  function is called again for that monitor or the library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_modes\n *  @sa glfwGetVideoMode\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Changed to return an array of modes for a specific monitor.\n *\n *  @ingroup monitor\n */\nGLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);\n\n/*! @brief Returns the current mode of the specified monitor.\n *\n *  This function returns the current video mode of the specified monitor.  If\n *  you have created a full screen window for that monitor, the return value\n *  will depend on whether that window is iconified.\n *\n *  @param[in] monitor The monitor to query.\n *  @return The current mode of the monitor, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned array is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified monitor is disconnected or the\n *  library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_modes\n *  @sa glfwGetVideoModes\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwGetDesktopMode`.\n *\n *  @ingroup monitor\n */\nGLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);\n\n/*! @brief Generates a gamma ramp and sets it for the specified monitor.\n *\n *  This function generates a 256-element gamma ramp from the specified exponent\n *  and then calls @ref glfwSetGammaRamp with it.  The value must be a finite\n *  number greater than zero.\n *\n *  @param[in] monitor The monitor whose gamma ramp to set.\n *  @param[in] gamma The desired exponent.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_gamma\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);\n\n/*! @brief Returns the current gamma ramp for the specified monitor.\n *\n *  This function returns the current gamma ramp of the specified monitor.\n *\n *  @param[in] monitor The monitor to query.\n *  @return The current gamma ramp, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned structure and its arrays are allocated and freed by GLFW.  You\n *  should not free them yourself.  They are valid until the specified monitor\n *  is disconnected, this function is called again for that monitor or the\n *  library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_gamma\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);\n\n/*! @brief Sets the current gamma ramp for the specified monitor.\n *\n *  This function sets the current gamma ramp for the specified monitor.  The\n *  original gamma ramp for that monitor is saved by GLFW the first time this\n *  function is called and is restored by @ref glfwTerminate.\n *\n *  @param[in] monitor The monitor whose gamma ramp to set.\n *  @param[in] ramp The gamma ramp to use.\n *\n *  @remarks Gamma ramp sizes other than 256 are not supported by all platforms\n *  or graphics hardware.\n *\n *  @remarks __Windows:__ The gamma ramp size must be 256.\n *\n *  @par Pointer Lifetime\n *  The specified gamma ramp is copied before this function returns.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref monitor_gamma\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup monitor\n */\nGLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);\n\n/*! @brief Resets all window hints to their default values.\n *\n *  This function resets all window hints to their\n *  [default values](@ref window_hints_values).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_hints\n *  @sa glfwWindowHint\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwDefaultWindowHints(void);\n\n/*! @brief Sets the specified window hint to the desired value.\n *\n *  This function sets hints for the next call to @ref glfwCreateWindow.  The\n *  hints, once set, retain their values until changed by a call to @ref\n *  glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is\n *  terminated.\n *\n *  @param[in] target The [window hint](@ref window_hints) to set.\n *  @param[in] hint The new value of the window hint.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_hints\n *  @sa glfwDefaultWindowHints\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwOpenWindowHint`.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwWindowHint(int target, int hint);\n\n/*! @brief Creates a window and its associated context.\n *\n *  This function creates a window and its associated OpenGL or OpenGL ES\n *  context.  Most of the options controlling how the window and its context\n *  should be created are specified with [window hints](@ref window_hints).\n *\n *  Successful creation does not change which context is current.  Before you\n *  can use the newly created context, you need to\n *  [make it current](@ref context_current).  For information about the `share`\n *  parameter, see @ref context_sharing.\n *\n *  The created window, framebuffer and context may differ from what you\n *  requested, as not all parameters and hints are\n *  [hard constraints](@ref window_hints_hard).  This includes the size of the\n *  window, especially for full screen windows.  To query the actual attributes\n *  of the created window, framebuffer and context, see @ref\n *  glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.\n *\n *  To create a full screen window, you need to specify the monitor the window\n *  will cover.  If no monitor is specified, windowed mode will be used.  Unless\n *  you have a way for the user to choose a specific monitor, it is recommended\n *  that you pick the primary monitor.  For more information on how to query\n *  connected monitors, see @ref monitor_monitors.\n *\n *  For full screen windows, the specified size becomes the resolution of the\n *  window's _desired video mode_.  As long as a full screen window has input\n *  focus, the supported video mode most closely matching the desired video mode\n *  is set for the specified monitor.  For more information about full screen\n *  windows, including the creation of so called _windowed full screen_ or\n *  _borderless full screen_ windows, see @ref window_windowed_full_screen.\n *\n *  By default, newly created windows use the placement recommended by the\n *  window system.  To create the window at a specific position, make it\n *  initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window\n *  hint, set its [position](@ref window_pos) and then [show](@ref window_hide)\n *  it.\n *\n *  If a full screen window has input focus, the screensaver is prohibited from\n *  starting.\n *\n *  Window systems put limits on window sizes.  Very large or very small window\n *  dimensions may be overridden by the window system on creation.  Check the\n *  actual [size](@ref window_size) after creation.\n *\n *  The [swap interval](@ref buffer_swap) is not set during window creation and\n *  the initial value may vary depending on driver settings and defaults.\n *\n *  @param[in] width The desired width, in screen coordinates, of the window.\n *  This must be greater than zero.\n *  @param[in] height The desired height, in screen coordinates, of the window.\n *  This must be greater than zero.\n *  @param[in] title The initial, UTF-8 encoded window title.\n *  @param[in] monitor The monitor to use for full screen mode, or `NULL` to use\n *  windowed mode.\n *  @param[in] share The window whose context to share resources with, or `NULL`\n *  to not share resources.\n *  @return The handle of the created window, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @remarks __Windows:__ Window creation will fail if the Microsoft GDI\n *  software OpenGL implementation is the only one available.\n *\n *  @remarks __Windows:__ If the executable has an icon resource named\n *  `GLFW_ICON,` it will be set as the icon for the window.  If no such icon is\n *  present, the `IDI_WINLOGO` icon will be used instead.\n *\n *  @remarks __Windows:__ The context to share resources with may not be current\n *  on any other thread.\n *\n *  @remarks __OS X:__ The GLFW window has no icon, as it is not a document\n *  window, but the dock icon will be the same as the application bundle's icon.\n *  For more information on bundles, see the\n *  [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)\n *  in the Mac Developer Library.\n *\n *  @remarks __OS X:__ The first time a window is created the menu bar is\n *  populated with common commands like Hide, Quit and About.  The About entry\n *  opens a minimal about dialog with information from the application's bundle.\n *  The menu bar can be disabled with a\n *  [compile-time option](@ref compile_options_osx).\n *\n *  @remarks __OS X:__ On OS X 10.10 and later the window frame will not be\n *  rendered at full resolution on Retina displays unless the\n *  `NSHighResolutionCapable` key is enabled in the application bundle's\n *  `Info.plist`.  For more information, see\n *  [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)\n *  in the Mac Developer Library.  The GLFW test and example programs use\n *  a custom `Info.plist` template for this, which can be found as\n *  `CMake/MacOSXBundleInfo.plist.in` in the source tree.\n *\n *  @remarks __X11:__ There is no mechanism for setting the window icon yet.\n *\n *  @remarks __X11:__ Some window managers will not respect the placement of\n *  initially hidden windows.\n *\n *  @remarks __X11:__ Due to the asynchronous nature of X11, it may take\n *  a moment for a window to reach its requested state.  This means you may not\n *  be able to query the final size, position or other attributes directly after\n *  window creation.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_creation\n *  @sa glfwDestroyWindow\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwOpenWindow`.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);\n\n/*! @brief Destroys the specified window and its context.\n *\n *  This function destroys the specified window and its context.  On calling\n *  this function, no further callbacks will be called for that window.\n *\n *  If the context of the specified window is current on the main thread, it is\n *  detached before being destroyed.\n *\n *  @param[in] window The window to destroy.\n *\n *  @note The context of the specified window must not be current on any other\n *  thread when this function is called.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_creation\n *  @sa glfwCreateWindow\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwCloseWindow`.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwDestroyWindow(GLFWwindow* window);\n\n/*! @brief Checks the close flag of the specified window.\n *\n *  This function returns the value of the close flag of the specified window.\n *\n *  @param[in] window The window to query.\n *  @return The value of the close flag.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @sa @ref window_close\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI int glfwWindowShouldClose(GLFWwindow* window);\n\n/*! @brief Sets the close flag of the specified window.\n *\n *  This function sets the value of the close flag of the specified window.\n *  This can be used to override the user's attempt to close the window, or\n *  to signal that it should be closed.\n *\n *  @param[in] window The window whose flag to change.\n *  @param[in] value The new value.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @sa @ref window_close\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);\n\n/*! @brief Sets the title of the specified window.\n *\n *  This function sets the window title, encoded as UTF-8, of the specified\n *  window.\n *\n *  @param[in] window The window whose title to change.\n *  @param[in] title The UTF-8 encoded window title.\n *\n *  @remarks __OS X:__ The window title will not be updated until the next time\n *  you process events.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_title\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);\n\n/*! @brief Retrieves the position of the client area of the specified window.\n *\n *  This function retrieves the position, in screen coordinates, of the\n *  upper-left corner of the client area of the specified window.\n *\n *  Any or all of the position arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` position arguments will be set to zero.\n *\n *  @param[in] window The window to query.\n *  @param[out] xpos Where to store the x-coordinate of the upper-left corner of\n *  the client area, or `NULL`.\n *  @param[out] ypos Where to store the y-coordinate of the upper-left corner of\n *  the client area, or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_pos\n *  @sa glfwSetWindowPos\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);\n\n/*! @brief Sets the position of the client area of the specified window.\n *\n *  This function sets the position, in screen coordinates, of the upper-left\n *  corner of the client area of the specified windowed mode window.  If the\n *  window is a full screen window, this function does nothing.\n *\n *  __Do not use this function__ to move an already visible window unless you\n *  have very good reasons for doing so, as it will confuse and annoy the user.\n *\n *  The window manager may put limits on what positions are allowed.  GLFW\n *  cannot and should not override these limits.\n *\n *  @param[in] window The window to query.\n *  @param[in] xpos The x-coordinate of the upper-left corner of the client area.\n *  @param[in] ypos The y-coordinate of the upper-left corner of the client area.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_pos\n *  @sa glfwGetWindowPos\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);\n\n/*! @brief Retrieves the size of the client area of the specified window.\n *\n *  This function retrieves the size, in screen coordinates, of the client area\n *  of the specified window.  If you wish to retrieve the size of the\n *  framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.\n *\n *  Any or all of the size arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` size arguments will be set to zero.\n *\n *  @param[in] window The window whose size to retrieve.\n *  @param[out] width Where to store the width, in screen coordinates, of the\n *  client area, or `NULL`.\n *  @param[out] height Where to store the height, in screen coordinates, of the\n *  client area, or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_size\n *  @sa glfwSetWindowSize\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);\n\n/*! @brief Sets the size of the client area of the specified window.\n *\n *  This function sets the size, in screen coordinates, of the client area of\n *  the specified window.\n *\n *  For full screen windows, this function selects and switches to the resolution\n *  closest to the specified size, without affecting the window's context.  As\n *  the context is unaffected, the bit depths of the framebuffer remain\n *  unchanged.\n *\n *  The window manager may put limits on what sizes are allowed.  GLFW cannot\n *  and should not override these limits.\n *\n *  @param[in] window The window to resize.\n *  @param[in] width The desired width of the specified window.\n *  @param[in] height The desired height of the specified window.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_size\n *  @sa glfwGetWindowSize\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);\n\n/*! @brief Retrieves the size of the framebuffer of the specified window.\n *\n *  This function retrieves the size, in pixels, of the framebuffer of the\n *  specified window.  If you wish to retrieve the size of the window in screen\n *  coordinates, see @ref glfwGetWindowSize.\n *\n *  Any or all of the size arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` size arguments will be set to zero.\n *\n *  @param[in] window The window whose framebuffer to query.\n *  @param[out] width Where to store the width, in pixels, of the framebuffer,\n *  or `NULL`.\n *  @param[out] height Where to store the height, in pixels, of the framebuffer,\n *  or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_fbsize\n *  @sa glfwSetFramebufferSizeCallback\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);\n\n/*! @brief Retrieves the size of the frame of the window.\n *\n *  This function retrieves the size, in screen coordinates, of each edge of the\n *  frame of the specified window.  This size includes the title bar, if the\n *  window has one.  The size of the frame may vary depending on the\n *  [window-related hints](@ref window_hints_wnd) used to create it.\n *\n *  Because this function retrieves the size of each window frame edge and not\n *  the offset along a particular coordinate axis, the retrieved values will\n *  always be zero or positive.\n *\n *  Any or all of the size arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` size arguments will be set to zero.\n *\n *  @param[in] window The window whose frame size to query.\n *  @param[out] left Where to store the size, in screen coordinates, of the left\n *  edge of the window frame, or `NULL`.\n *  @param[out] top Where to store the size, in screen coordinates, of the top\n *  edge of the window frame, or `NULL`.\n *  @param[out] right Where to store the size, in screen coordinates, of the\n *  right edge of the window frame, or `NULL`.\n *  @param[out] bottom Where to store the size, in screen coordinates, of the\n *  bottom edge of the window frame, or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_size\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);\n\n/*! @brief Iconifies the specified window.\n *\n *  This function iconifies (minimizes) the specified window if it was\n *  previously restored.  If the window is already iconified, this function does\n *  nothing.\n *\n *  If the specified window is a full screen window, the original monitor\n *  resolution is restored until the window is restored.\n *\n *  @param[in] window The window to iconify.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_iconify\n *  @sa glfwRestoreWindow\n *\n *  @since Added in GLFW 2.1.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwIconifyWindow(GLFWwindow* window);\n\n/*! @brief Restores the specified window.\n *\n *  This function restores the specified window if it was previously iconified\n *  (minimized).  If the window is already restored, this function does nothing.\n *\n *  If the specified window is a full screen window, the resolution chosen for\n *  the window is restored on the selected monitor.\n *\n *  @param[in] window The window to restore.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_iconify\n *  @sa glfwIconifyWindow\n *\n *  @since Added in GLFW 2.1.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwRestoreWindow(GLFWwindow* window);\n\n/*! @brief Makes the specified window visible.\n *\n *  This function makes the specified window visible if it was previously\n *  hidden.  If the window is already visible or is in full screen mode, this\n *  function does nothing.\n *\n *  @param[in] window The window to make visible.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_hide\n *  @sa glfwHideWindow\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwShowWindow(GLFWwindow* window);\n\n/*! @brief Hides the specified window.\n *\n *  This function hides the specified window if it was previously visible.  If\n *  the window is already hidden or is in full screen mode, this function does\n *  nothing.\n *\n *  @param[in] window The window to hide.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_hide\n *  @sa glfwShowWindow\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwHideWindow(GLFWwindow* window);\n\n/*! @brief Returns the monitor that the window uses for full screen mode.\n *\n *  This function returns the handle of the monitor that the specified window is\n *  in full screen on.\n *\n *  @param[in] window The window to query.\n *  @return The monitor, or `NULL` if the window is in windowed mode or an error\n *  occurred.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_monitor\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);\n\n/*! @brief Returns an attribute of the specified window.\n *\n *  This function returns the value of an attribute of the specified window or\n *  its OpenGL or OpenGL ES context.\n *\n *  @param[in] window The window to query.\n *  @param[in] attrib The [window attribute](@ref window_attribs) whose value to\n *  return.\n *  @return The value of the attribute, or zero if an\n *  [error](@ref error_handling) occurred.\n *\n *  @remarks Framebuffer related hints are not window attributes.  See @ref\n *  window_attribs_fb for more information.\n *\n *  @remarks Zero is a valid value for many window and context related\n *  attributes so you cannot use a return value of zero as an indication of\n *  errors.  However, this function should not fail as long as it is passed\n *  valid arguments and the library has been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_attribs\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwGetWindowParam` and\n *  `glfwGetGLVersion`.\n *\n *  @ingroup window\n */\nGLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);\n\n/*! @brief Sets the user pointer of the specified window.\n *\n *  This function sets the user-defined pointer of the specified window.  The\n *  current value is retained until the window is destroyed.  The initial value\n *  is `NULL`.\n *\n *  @param[in] window The window whose pointer to set.\n *  @param[in] pointer The new value.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @sa @ref window_userptr\n *  @sa glfwGetWindowUserPointer\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);\n\n/*! @brief Returns the user pointer of the specified window.\n *\n *  This function returns the current value of the user-defined pointer of the\n *  specified window.  The initial value is `NULL`.\n *\n *  @param[in] window The window whose pointer to return.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @sa @ref window_userptr\n *  @sa glfwSetWindowUserPointer\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);\n\n/*! @brief Sets the position callback for the specified window.\n *\n *  This function sets the position callback of the specified window, which is\n *  called when the window is moved.  The callback is provided with the screen\n *  position of the upper-left corner of the client area of the window.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_pos\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun);\n\n/*! @brief Sets the size callback for the specified window.\n *\n *  This function sets the size callback of the specified window, which is\n *  called when the window is resized.  The callback is provided with the size,\n *  in screen coordinates, of the client area of the window.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_size\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun);\n\n/*! @brief Sets the close callback for the specified window.\n *\n *  This function sets the close callback of the specified window, which is\n *  called when the user attempts to close the window, for example by clicking\n *  the close widget in the title bar.\n *\n *  The close flag is set before this callback is called, but you can modify it\n *  at any time with @ref glfwSetWindowShouldClose.\n *\n *  The close callback is not triggered by @ref glfwDestroyWindow.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @remarks __OS X:__ Selecting Quit from the application menu will\n *  trigger the close callback for all windows.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_close\n *\n *  @since Added in GLFW 2.5.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun);\n\n/*! @brief Sets the refresh callback for the specified window.\n *\n *  This function sets the refresh callback of the specified window, which is\n *  called when the client area of the window needs to be redrawn, for example\n *  if the window has been exposed after having been covered by another window.\n *\n *  On compositing window systems such as Aero, Compiz or Aqua, where the window\n *  contents are saved off-screen, this callback may be called only very\n *  infrequently or never at all.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_refresh\n *\n *  @since Added in GLFW 2.5.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun);\n\n/*! @brief Sets the focus callback for the specified window.\n *\n *  This function sets the focus callback of the specified window, which is\n *  called when the window gains or loses input focus.\n *\n *  After the focus callback is called for a window that lost input focus,\n *  synthetic key and mouse button release events will be generated for all such\n *  that had been pressed.  For more information, see @ref glfwSetKeyCallback\n *  and @ref glfwSetMouseButtonCallback.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_focus\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun);\n\n/*! @brief Sets the iconify callback for the specified window.\n *\n *  This function sets the iconification callback of the specified window, which\n *  is called when the window is iconified or restored.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_iconify\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun);\n\n/*! @brief Sets the framebuffer resize callback for the specified window.\n *\n *  This function sets the framebuffer resize callback of the specified window,\n *  which is called when the framebuffer of the specified window is resized.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref window_fbsize\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup window\n */\nGLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);\n\n/*! @brief Processes all pending events.\n *\n *  This function processes only those events that are already in the event\n *  queue and then returns immediately.  Processing events will cause the window\n *  and input callbacks associated with those events to be called.\n *\n *  On some platforms, a window move, resize or menu operation will cause event\n *  processing to block.  This is due to how event processing is designed on\n *  those platforms.  You can use the\n *  [window refresh callback](@ref window_refresh) to redraw the contents of\n *  your window when necessary during such operations.\n *\n *  On some platforms, certain events are sent directly to the application\n *  without going through the event queue, causing callbacks to be called\n *  outside of a call to one of the event processing functions.\n *\n *  Event processing is not required for joystick input to work.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref events\n *  @sa glfwWaitEvents\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwPollEvents(void);\n\n/*! @brief Waits until events are queued and processes them.\n *\n *  This function puts the calling thread to sleep until at least one event is\n *  available in the event queue.  Once one or more events are available,\n *  it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue\n *  are processed and the function then returns immediately.  Processing events\n *  will cause the window and input callbacks associated with those events to be\n *  called.\n *\n *  Since not all events are associated with callbacks, this function may return\n *  without a callback having been called even if you are monitoring all\n *  callbacks.\n *\n *  On some platforms, a window move, resize or menu operation will cause event\n *  processing to block.  This is due to how event processing is designed on\n *  those platforms.  You can use the\n *  [window refresh callback](@ref window_refresh) to redraw the contents of\n *  your window when necessary during such operations.\n *\n *  On some platforms, certain callbacks may be called outside of a call to one\n *  of the event processing functions.\n *\n *  If no windows exist, this function returns immediately.  For synchronization\n *  of threads in applications that do not create windows, use your threading\n *  library of choice.\n *\n *  Event processing is not required for joystick input to work.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref events\n *  @sa glfwPollEvents\n *\n *  @since Added in GLFW 2.5.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwWaitEvents(void);\n\n/*! @brief Posts an empty event to the event queue.\n *\n *  This function posts an empty event from the current thread to the event\n *  queue, causing @ref glfwWaitEvents to return.\n *\n *  If no windows exist, this function returns immediately.  For synchronization\n *  of threads in applications that do not create windows, use your threading\n *  library of choice.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref events\n *  @sa glfwWaitEvents\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwPostEmptyEvent(void);\n\n/*! @brief Returns the value of an input option for the specified window.\n *\n *  This function returns the value of an input option for the specified window.\n *  The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or\n *  `GLFW_STICKY_MOUSE_BUTTONS`.\n *\n *  @param[in] window The window to query.\n *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or\n *  `GLFW_STICKY_MOUSE_BUTTONS`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa glfwSetInputMode\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup input\n */\nGLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);\n\n/*! @brief Sets an input option for the specified window.\n *\n *  This function sets an input mode option for the specified window.  The mode\n *  must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or\n *  `GLFW_STICKY_MOUSE_BUTTONS`.\n *\n *  If the mode is `GLFW_CURSOR`, the value must be one of the following cursor\n *  modes:\n *  - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.\n *  - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client\n *    area of the window but does not restrict the cursor from leaving.\n *  - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual\n *    and unlimited cursor movement.  This is useful for implementing for\n *    example 3D camera controls.\n *\n *  If the mode is `GLFW_STICKY_KEYS`, the value must be either `GL_TRUE` to\n *  enable sticky keys, or `GL_FALSE` to disable it.  If sticky keys are\n *  enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`\n *  the next time it is called even if the key had been released before the\n *  call.  This is useful when you are only interested in whether keys have been\n *  pressed but not when or in which order.\n *\n *  If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either\n *  `GL_TRUE` to enable sticky mouse buttons, or `GL_FALSE` to disable it.  If\n *  sticky mouse buttons are enabled, a mouse button press will ensure that @ref\n *  glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even if\n *  the mouse button had been released before the call.  This is useful when you\n *  are only interested in whether mouse buttons have been pressed but not when\n *  or in which order.\n *\n *  @param[in] window The window whose input mode to set.\n *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or\n *  `GLFW_STICKY_MOUSE_BUTTONS`.\n *  @param[in] value The new value of the specified input mode.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa glfwGetInputMode\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwEnable` and `glfwDisable`.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);\n\n/*! @brief Returns the last reported state of a keyboard key for the specified\n *  window.\n *\n *  This function returns the last state reported for the specified key to the\n *  specified window.  The returned state is one of `GLFW_PRESS` or\n *  `GLFW_RELEASE`.  The higher-level action `GLFW_REPEAT` is only reported to\n *  the key callback.\n *\n *  If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns\n *  `GLFW_PRESS` the first time you call it for a key that was pressed, even if\n *  that key has already been released.\n *\n *  The key functions deal with physical keys, with [key tokens](@ref keys)\n *  named after their use on the standard US keyboard layout.  If you want to\n *  input text, use the Unicode character callback instead.\n *\n *  The [modifier key bit masks](@ref mods) are not key tokens and cannot be\n *  used with this function.\n *\n *  @param[in] window The desired window.\n *  @param[in] key The desired [keyboard key](@ref keys).  `GLFW_KEY_UNKNOWN` is\n *  not a valid key for this function.\n *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_key\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup input\n */\nGLFWAPI int glfwGetKey(GLFWwindow* window, int key);\n\n/*! @brief Returns the last reported state of a mouse button for the specified\n *  window.\n *\n *  This function returns the last state reported for the specified mouse button\n *  to the specified window.  The returned state is one of `GLFW_PRESS` or\n *  `GLFW_RELEASE`.\n *\n *  If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function\n *  `GLFW_PRESS` the first time you call it for a mouse button that was pressed,\n *  even if that mouse button has already been released.\n *\n *  @param[in] window The desired window.\n *  @param[in] button The desired [mouse button](@ref buttons).\n *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_mouse_button\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup input\n */\nGLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);\n\n/*! @brief Retrieves the position of the cursor relative to the client area of\n *  the window.\n *\n *  This function returns the position of the cursor, in screen coordinates,\n *  relative to the upper-left corner of the client area of the specified\n *  window.\n *\n *  If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor\n *  position is unbounded and limited only by the minimum and maximum values of\n *  a `double`.\n *\n *  The coordinate can be converted to their integer equivalents with the\n *  `floor` function.  Casting directly to an integer type works for positive\n *  coordinates, but fails for negative ones.\n *\n *  Any or all of the position arguments may be `NULL`.  If an error occurs, all\n *  non-`NULL` position arguments will be set to zero.\n *\n *  @param[in] window The desired window.\n *  @param[out] xpos Where to store the cursor x-coordinate, relative to the\n *  left edge of the client area, or `NULL`.\n *  @param[out] ypos Where to store the cursor y-coordinate, relative to the to\n *  top edge of the client area, or `NULL`.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_pos\n *  @sa glfwSetCursorPos\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwGetMousePos`.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);\n\n/*! @brief Sets the position of the cursor, relative to the client area of the\n *  window.\n *\n *  This function sets the position, in screen coordinates, of the cursor\n *  relative to the upper-left corner of the client area of the specified\n *  window.  The window must have input focus.  If the window does not have\n *  input focus when this function is called, it fails silently.\n *\n *  __Do not use this function__ to implement things like camera controls.  GLFW\n *  already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the\n *  cursor, transparently re-centers it and provides unconstrained cursor\n *  motion.  See @ref glfwSetInputMode for more information.\n *\n *  If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is\n *  unconstrained and limited only by the minimum and maximum values of\n *  a `double`.\n *\n *  @param[in] window The desired window.\n *  @param[in] xpos The desired x-coordinate, relative to the left edge of the\n *  client area.\n *  @param[in] ypos The desired y-coordinate, relative to the top edge of the\n *  client area.\n *\n *  @remarks __X11:__ Due to the asynchronous nature of X11, it may take\n *  a moment for the window focus event to arrive.  This means you may not be\n *  able to set the cursor position directly after window creation.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_pos\n *  @sa glfwGetCursorPos\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwSetMousePos`.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);\n\n/*! @brief Creates a custom cursor.\n *\n *  Creates a new custom cursor image that can be set for a window with @ref\n *  glfwSetCursor.  The cursor can be destroyed with @ref glfwDestroyCursor.\n *  Any remaining cursors are destroyed by @ref glfwTerminate.\n *\n *  The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight\n *  bits per channel.  They are arranged canonically as packed sequential rows,\n *  starting from the top-left corner.\n *\n *  The cursor hotspot is specified in pixels, relative to the upper-left corner\n *  of the cursor image.  Like all other coordinate systems in GLFW, the X-axis\n *  points to the right and the Y-axis points down.\n *\n *  @param[in] image The desired cursor image.\n *  @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.\n *  @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.\n *\n *  @return The handle of the created cursor, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The specified image data is copied before this function returns.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_object\n *  @sa glfwDestroyCursor\n *  @sa glfwCreateStandardCursor\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);\n\n/*! @brief Creates a cursor with a standard shape.\n *\n *  Returns a cursor with a [standard shape](@ref shapes), that can be set for\n *  a window with @ref glfwSetCursor.\n *\n *  @param[in] shape One of the [standard shapes](@ref shapes).\n *\n *  @return A new cursor ready to use or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_object\n *  @sa glfwCreateCursor\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);\n\n/*! @brief Destroys a cursor.\n *\n *  This function destroys a cursor previously created with @ref\n *  glfwCreateCursor.  Any remaining cursors will be destroyed by @ref\n *  glfwTerminate.\n *\n *  @param[in] cursor The cursor object to destroy.\n *\n *  @par Reentrancy\n *  This function may not be called from a callback.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_object\n *  @sa glfwCreateCursor\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);\n\n/*! @brief Sets the cursor for the window.\n *\n *  This function sets the cursor image to be used when the cursor is over the\n *  client area of the specified window.  The set cursor will only be visible\n *  when the [cursor mode](@ref cursor_mode) of the window is\n *  `GLFW_CURSOR_NORMAL`.\n *\n *  On some platforms, the set cursor may not be visible unless the window also\n *  has input focus.\n *\n *  @param[in] window The window to set the cursor for.\n *  @param[in] cursor The cursor to set, or `NULL` to switch back to the default\n *  arrow cursor.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_object\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);\n\n/*! @brief Sets the key callback.\n *\n *  This function sets the key callback of the specified window, which is called\n *  when a key is pressed, repeated or released.\n *\n *  The key functions deal with physical keys, with layout independent\n *  [key tokens](@ref keys) named after their values in the standard US keyboard\n *  layout.  If you want to input text, use the\n *  [character callback](@ref glfwSetCharCallback) instead.\n *\n *  When a window loses input focus, it will generate synthetic key release\n *  events for all pressed keys.  You can tell these events from user-generated\n *  events by the fact that the synthetic ones are generated after the focus\n *  loss event has been processed, i.e. after the\n *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.\n *\n *  The scancode of a key is specific to that platform or sometimes even to that\n *  machine.  Scancodes are intended to allow users to bind keys that don't have\n *  a GLFW key token.  Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their\n *  state is not saved and so it cannot be queried with @ref glfwGetKey.\n *\n *  Sometimes GLFW needs to generate synthetic key events, in which case the\n *  scancode may be zero.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new key callback, or `NULL` to remove the currently\n *  set callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_key\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun);\n\n/*! @brief Sets the Unicode character callback.\n *\n *  This function sets the character callback of the specified window, which is\n *  called when a Unicode character is input.\n *\n *  The character callback is intended for Unicode text input.  As it deals with\n *  characters, it is keyboard layout dependent, whereas the\n *  [key callback](@ref glfwSetKeyCallback) is not.  Characters do not map 1:1\n *  to physical keys, as a key may produce zero, one or more characters.  If you\n *  want to know whether a specific physical key was pressed or released, see\n *  the key callback instead.\n *\n *  The character callback behaves as system text input normally does and will\n *  not be called if modifier keys are held down that would prevent normal text\n *  input on that platform, for example a Super (Command) key on OS X or Alt key\n *  on Windows.  There is a\n *  [character with modifiers callback](@ref glfwSetCharModsCallback) that\n *  receives these events.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_char\n *\n *  @since Added in GLFW 2.4.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun);\n\n/*! @brief Sets the Unicode character with modifiers callback.\n *\n *  This function sets the character with modifiers callback of the specified\n *  window, which is called when a Unicode character is input regardless of what\n *  modifier keys are used.\n *\n *  The character with modifiers callback is intended for implementing custom\n *  Unicode character input.  For regular Unicode text input, see the\n *  [character callback](@ref glfwSetCharCallback).  Like the character\n *  callback, the character with modifiers callback deals with characters and is\n *  keyboard layout dependent.  Characters do not map 1:1 to physical keys, as\n *  a key may produce zero, one or more characters.  If you want to know whether\n *  a specific physical key was pressed or released, see the\n *  [key callback](@ref glfwSetKeyCallback) instead.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or an\n *  error occurred.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_char\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun);\n\n/*! @brief Sets the mouse button callback.\n *\n *  This function sets the mouse button callback of the specified window, which\n *  is called when a mouse button is pressed or released.\n *\n *  When a window loses input focus, it will generate synthetic mouse button\n *  release events for all pressed mouse buttons.  You can tell these events\n *  from user-generated events by the fact that the synthetic ones are generated\n *  after the focus loss event has been processed, i.e. after the\n *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref input_mouse_button\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.  Updated callback signature.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun);\n\n/*! @brief Sets the cursor position callback.\n *\n *  This function sets the cursor position callback of the specified window,\n *  which is called when the cursor is moved.  The callback is provided with the\n *  position, in screen coordinates, relative to the upper-left corner of the\n *  client area of the window.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_pos\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwSetMousePosCallback`.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun);\n\n/*! @brief Sets the cursor enter/exit callback.\n *\n *  This function sets the cursor boundary crossing callback of the specified\n *  window, which is called when the cursor enters or leaves the client area of\n *  the window.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new callback, or `NULL` to remove the currently set\n *  callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref cursor_enter\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun);\n\n/*! @brief Sets the scroll callback.\n *\n *  This function sets the scroll callback of the specified window, which is\n *  called when a scrolling device is used, such as a mouse wheel or scrolling\n *  area of a touchpad.\n *\n *  The scroll callback receives all scrolling input, like that from a mouse\n *  wheel or a touchpad scrolling area.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new scroll callback, or `NULL` to remove the currently\n *  set callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref scrolling\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwSetMouseWheelCallback`.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun);\n\n/*! @brief Sets the file drop callback.\n *\n *  This function sets the file drop callback of the specified window, which is\n *  called when one or more dragged files are dropped on the window.\n *\n *  Because the path array and its strings may have been generated specifically\n *  for that event, they are not guaranteed to be valid after the callback has\n *  returned.  If you wish to use them after the callback returns, you need to\n *  make a deep copy.\n *\n *  @param[in] window The window whose callback to set.\n *  @param[in] cbfun The new file drop callback, or `NULL` to remove the\n *  currently set callback.\n *  @return The previously set callback, or `NULL` if no callback was set or the\n *  library had not been [initialized](@ref intro_init).\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref path_drop\n *\n *  @since Added in GLFW 3.1.\n *\n *  @ingroup input\n */\nGLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun);\n\n/*! @brief Returns whether the specified joystick is present.\n *\n *  This function returns whether the specified joystick is present.\n *\n *  @param[in] joy The [joystick](@ref joysticks) to query.\n *  @return `GL_TRUE` if the joystick is present, or `GL_FALSE` otherwise.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref joystick\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwGetJoystickParam`.\n *\n *  @ingroup input\n */\nGLFWAPI int glfwJoystickPresent(int joy);\n\n/*! @brief Returns the values of all axes of the specified joystick.\n *\n *  This function returns the values of all axes of the specified joystick.\n *  Each element in the array is a value between -1.0 and 1.0.\n *\n *  @param[in] joy The [joystick](@ref joysticks) to query.\n *  @param[out] count Where to store the number of axis values in the returned\n *  array.  This is set to zero if an error occurred.\n *  @return An array of axis values, or `NULL` if the joystick is not present.\n *\n *  @par Pointer Lifetime\n *  The returned array is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified joystick is disconnected, this\n *  function is called again for that joystick or the library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref joystick_axis\n *\n *  @since Added in GLFW 3.0.  Replaces `glfwGetJoystickPos`.\n *\n *  @ingroup input\n */\nGLFWAPI const float* glfwGetJoystickAxes(int joy, int* count);\n\n/*! @brief Returns the state of all buttons of the specified joystick.\n *\n *  This function returns the state of all buttons of the specified joystick.\n *  Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.\n *\n *  @param[in] joy The [joystick](@ref joysticks) to query.\n *  @param[out] count Where to store the number of button states in the returned\n *  array.  This is set to zero if an error occurred.\n *  @return An array of button states, or `NULL` if the joystick is not present.\n *\n *  @par Pointer Lifetime\n *  The returned array is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified joystick is disconnected, this\n *  function is called again for that joystick or the library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref joystick_button\n *\n *  @since Added in GLFW 2.2.\n *\n *  @par\n *  __GLFW 3:__ Changed to return a dynamic array.\n *\n *  @ingroup input\n */\nGLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count);\n\n/*! @brief Returns the name of the specified joystick.\n *\n *  This function returns the name, encoded as UTF-8, of the specified joystick.\n *  The returned string is allocated and freed by GLFW.  You should not free it\n *  yourself.\n *\n *  @param[in] joy The [joystick](@ref joysticks) to query.\n *  @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick\n *  is not present.\n *\n *  @par Pointer Lifetime\n *  The returned string is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the specified joystick is disconnected, this\n *  function is called again for that joystick or the library is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref joystick_name\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup input\n */\nGLFWAPI const char* glfwGetJoystickName(int joy);\n\n/*! @brief Sets the clipboard to the specified string.\n *\n *  This function sets the system clipboard to the specified, UTF-8 encoded\n *  string.\n *\n *  @param[in] window The window that will own the clipboard contents.\n *  @param[in] string A UTF-8 encoded string.\n *\n *  @par Pointer Lifetime\n *  The specified string is copied before this function returns.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref clipboard\n *  @sa glfwGetClipboardString\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);\n\n/*! @brief Returns the contents of the clipboard as a string.\n *\n *  This function returns the contents of the system clipboard, if it contains\n *  or is convertible to a UTF-8 encoded string.  If the clipboard is empty or\n *  if its contents cannot be converted, `NULL` is returned and a @ref\n *  GLFW_FORMAT_UNAVAILABLE error is generated.\n *\n *  @param[in] window The window that will request the clipboard contents.\n *  @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`\n *  if an [error](@ref error_handling) occurred.\n *\n *  @par Pointer Lifetime\n *  The returned string is allocated and freed by GLFW.  You should not free it\n *  yourself.  It is valid until the next call to @ref\n *  glfwGetClipboardString or @ref glfwSetClipboardString, or until the library\n *  is terminated.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref clipboard\n *  @sa glfwSetClipboardString\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup input\n */\nGLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);\n\n/*! @brief Returns the value of the GLFW timer.\n *\n *  This function returns the value of the GLFW timer.  Unless the timer has\n *  been set using @ref glfwSetTime, the timer measures time elapsed since GLFW\n *  was initialized.\n *\n *  The resolution of the timer is system dependent, but is usually on the order\n *  of a few micro- or nanoseconds.  It uses the highest-resolution monotonic\n *  time source on each supported platform.\n *\n *  @return The current value, in seconds, or zero if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @sa @ref time\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup input\n */\nGLFWAPI double glfwGetTime(void);\n\n/*! @brief Sets the GLFW timer.\n *\n *  This function sets the value of the GLFW timer.  It then continues to count\n *  up from that value.  The value must be a positive finite number less than\n *  or equal to 18446744073.0, which is approximately 584.5 years.\n *\n *  @param[in] time The new value, in seconds.\n *\n *  @remarks The upper limit of the timer is calculated as\n *  floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations\n *  storing nanoseconds in 64 bits.  The limit may be increased in the future.\n *\n *  @par Thread Safety\n *  This function may only be called from the main thread.\n *\n *  @sa @ref time\n *\n *  @since Added in GLFW 2.2.\n *\n *  @ingroup input\n */\nGLFWAPI void glfwSetTime(double time);\n\n/*! @brief Makes the context of the specified window current for the calling\n *  thread.\n *\n *  This function makes the OpenGL or OpenGL ES context of the specified window\n *  current on the calling thread.  A context can only be made current on\n *  a single thread at a time and each thread can have only a single current\n *  context at a time.\n *\n *  By default, making a context non-current implicitly forces a pipeline flush.\n *  On machines that support `GL_KHR_context_flush_control`, you can control\n *  whether a context performs this flush by setting the\n *  [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint.\n *\n *  @param[in] window The window whose context to make current, or `NULL` to\n *  detach the current context.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref context_current\n *  @sa glfwGetCurrentContext\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup context\n */\nGLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);\n\n/*! @brief Returns the window whose context is current on the calling thread.\n *\n *  This function returns the window whose OpenGL or OpenGL ES context is\n *  current on the calling thread.\n *\n *  @return The window whose context is current, or `NULL` if no window's\n *  context is current.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref context_current\n *  @sa glfwMakeContextCurrent\n *\n *  @since Added in GLFW 3.0.\n *\n *  @ingroup context\n */\nGLFWAPI GLFWwindow* glfwGetCurrentContext(void);\n\n/*! @brief Swaps the front and back buffers of the specified window.\n *\n *  This function swaps the front and back buffers of the specified window.  If\n *  the swap interval is greater than zero, the GPU driver waits the specified\n *  number of screen updates before swapping the buffers.\n *\n *  @param[in] window The window whose buffers to swap.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref buffer_swap\n *  @sa glfwSwapInterval\n *\n *  @since Added in GLFW 1.0.\n *\n *  @par\n *  __GLFW 3:__ Added window handle parameter.\n *\n *  @ingroup window\n */\nGLFWAPI void glfwSwapBuffers(GLFWwindow* window);\n\n/*! @brief Sets the swap interval for the current context.\n *\n *  This function sets the swap interval for the current context, i.e. the\n *  number of screen updates to wait from the time @ref glfwSwapBuffers was\n *  called before swapping the buffers and returning.  This is sometimes called\n *  _vertical synchronization_, _vertical retrace synchronization_ or just\n *  _vsync_.\n *\n *  Contexts that support either of the `WGL_EXT_swap_control_tear` and\n *  `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals,\n *  which allow the driver to swap even if a frame arrives a little bit late.\n *  You can check for the presence of these extensions using @ref\n *  glfwExtensionSupported.  For more information about swap tearing, see the\n *  extension specifications.\n *\n *  A context must be current on the calling thread.  Calling this function\n *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.\n *\n *  @param[in] interval The minimum number of screen updates to wait for\n *  until the buffers are swapped by @ref glfwSwapBuffers.\n *\n *  @remarks This function is not called during context creation, leaving the\n *  swap interval set to whatever is the default on that platform.  This is done\n *  because some swap interval extensions used by GLFW do not allow the swap\n *  interval to be reset to zero once it has been set to a non-zero value.\n *\n *  @remarks Some GPU drivers do not honor the requested swap interval, either\n *  because of a user setting that overrides the application's request or due to\n *  bugs in the driver.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref buffer_swap\n *  @sa glfwSwapBuffers\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup context\n */\nGLFWAPI void glfwSwapInterval(int interval);\n\n/*! @brief Returns whether the specified extension is available.\n *\n *  This function returns whether the specified\n *  [client API extension](@ref context_glext) is supported by the current\n *  OpenGL or OpenGL ES context.  It searches both for OpenGL and OpenGL ES\n *  extension and platform-specific context creation API extensions.\n *\n *  A context must be current on the calling thread.  Calling this function\n *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.\n *\n *  As this functions retrieves and searches one or more extension strings each\n *  call, it is recommended that you cache its results if it is going to be used\n *  frequently.  The extension strings will not change during the lifetime of\n *  a context, so there is no danger in doing this.\n *\n *  @param[in] extension The ASCII encoded name of the extension.\n *  @return `GL_TRUE` if the extension is available, or `GL_FALSE` otherwise.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref context_glext\n *  @sa glfwGetProcAddress\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup context\n */\nGLFWAPI int glfwExtensionSupported(const char* extension);\n\n/*! @brief Returns the address of the specified function for the current\n *  context.\n *\n *  This function returns the address of the specified\n *  [core or extension function](@ref context_glext), if it is supported\n *  by the current context.\n *\n *  A context must be current on the calling thread.  Calling this function\n *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.\n *\n *  @param[in] procname The ASCII encoded name of the function.\n *  @return The address of the function, or `NULL` if an [error](@ref\n *  error_handling) occurred.\n *\n *  @remarks The address of a given function is not guaranteed to be the same\n *  between contexts.\n *\n *  @remarks This function may return a non-`NULL` address despite the\n *  associated version or extension not being available.  Always check the\n *  context version or extension string first.\n *\n *  @par Pointer Lifetime\n *  The returned function pointer is valid until the context is destroyed or the\n *  library is terminated.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.\n *\n *  @sa @ref context_glext\n *  @sa glfwExtensionSupported\n *\n *  @since Added in GLFW 1.0.\n *\n *  @ingroup context\n */\nGLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);\n\n\n/*************************************************************************\n * Global definition cleanup\n *************************************************************************/\n\n/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */\n\n#ifdef GLFW_WINGDIAPI_DEFINED\n #undef WINGDIAPI\n #undef GLFW_WINGDIAPI_DEFINED\n#endif\n\n#ifdef GLFW_CALLBACK_DEFINED\n #undef CALLBACK\n #undef GLFW_CALLBACK_DEFINED\n#endif\n\n/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _glfw3_h_ */\n\n"
  },
  {
    "path": "deps/glfw/include/GLFW/glfw3native.h",
    "content": "/*************************************************************************\n * GLFW 3.1 - www.glfw.org\n * A library for OpenGL, window and input\n *------------------------------------------------------------------------\n * Copyright (c) 2002-2006 Marcus Geelnard\n * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n *\n * This software is provided 'as-is', without any express or implied\n * warranty. In no event will the authors be held liable for any damages\n * arising from the use of this software.\n *\n * Permission is granted to anyone to use this software for any purpose,\n * including commercial applications, and to alter it and redistribute it\n * freely, subject to the following restrictions:\n *\n * 1. The origin of this software must not be misrepresented; you must not\n *    claim that you wrote the original software. If you use this software\n *    in a product, an acknowledgment in the product documentation would\n *    be appreciated but is not required.\n *\n * 2. Altered source versions must be plainly marked as such, and must not\n *    be misrepresented as being the original software.\n *\n * 3. This notice may not be removed or altered from any source\n *    distribution.\n *\n *************************************************************************/\n\n#ifndef _glfw3_native_h_\n#define _glfw3_native_h_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*************************************************************************\n * Doxygen documentation\n *************************************************************************/\n\n/*! @defgroup native Native access\n *\n *  **By using the native access functions you assert that you know what you're\n *  doing and how to fix problems caused by using them.  If you don't, you\n *  shouldn't be using them.**\n *\n *  Before the inclusion of @ref glfw3native.h, you must define exactly one\n *  window system API macro and exactly one context creation API macro.  Failure\n *  to do this will cause a compile-time error.\n *\n *  The available window API macros are:\n *  * `GLFW_EXPOSE_NATIVE_WIN32`\n *  * `GLFW_EXPOSE_NATIVE_COCOA`\n *  * `GLFW_EXPOSE_NATIVE_X11`\n *\n *  The available context API macros are:\n *  * `GLFW_EXPOSE_NATIVE_WGL`\n *  * `GLFW_EXPOSE_NATIVE_NSGL`\n *  * `GLFW_EXPOSE_NATIVE_GLX`\n *  * `GLFW_EXPOSE_NATIVE_EGL`\n *\n *  These macros select which of the native access functions that are declared\n *  and which platform-specific headers to include.  It is then up your (by\n *  definition platform-specific) code to handle which of these should be\n *  defined.\n */\n\n\n/*************************************************************************\n * System headers and types\n *************************************************************************/\n\n#if defined(GLFW_EXPOSE_NATIVE_WIN32)\n // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for\n // example to allow applications to correctly declare a GL_ARB_debug_output\n // callback) but windows.h assumes no one will define APIENTRY before it does\n #undef APIENTRY\n #include <windows.h>\n#elif defined(GLFW_EXPOSE_NATIVE_COCOA)\n #include <ApplicationServices/ApplicationServices.h>\n #if defined(__OBJC__)\n  #import <Cocoa/Cocoa.h>\n #else\n  typedef void* id;\n #endif\n#elif defined(GLFW_EXPOSE_NATIVE_X11)\n #include <X11/Xlib.h>\n #include <X11/extensions/Xrandr.h>\n#else\n #error \"No window API selected\"\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_WGL)\n /* WGL is declared by windows.h */\n#elif defined(GLFW_EXPOSE_NATIVE_NSGL)\n /* NSGL is declared by Cocoa.h */\n#elif defined(GLFW_EXPOSE_NATIVE_GLX)\n #include <GL/glx.h>\n#elif defined(GLFW_EXPOSE_NATIVE_EGL)\n #include <EGL/egl.h>\n#else\n #error \"No context API selected\"\n#endif\n\n\n/*************************************************************************\n * Functions\n *************************************************************************/\n\n#if defined(GLFW_EXPOSE_NATIVE_WIN32)\n/*! @brief Returns the adapter device name of the specified monitor.\n *\n *  @return The UTF-8 encoded adapter device name (for example `\\\\.\\DISPLAY1`)\n *  of the specified monitor, or `NULL` if an [error](@ref error_handling)\n *  occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.1.\n *\n *  @ingroup native\n */\nGLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);\n\n/*! @brief Returns the display device name of the specified monitor.\n *\n *  @return The UTF-8 encoded display device name (for example\n *  `\\\\.\\DISPLAY1\\Monitor0`) of the specified monitor, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.1.\n *\n *  @ingroup native\n */\nGLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);\n\n/*! @brief Returns the `HWND` of the specified window.\n *\n *  @return The `HWND` of the specified window, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_WGL)\n/*! @brief Returns the `HGLRC` of the specified window.\n *\n *  @return The `HGLRC` of the specified window, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_COCOA)\n/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.\n *\n *  @return The `CGDirectDisplayID` of the specified monitor, or\n *  `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.1.\n *\n *  @ingroup native\n */\nGLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);\n\n/*! @brief Returns the `NSWindow` of the specified window.\n *\n *  @return The `NSWindow` of the specified window, or `nil` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_NSGL)\n/*! @brief Returns the `NSOpenGLContext` of the specified window.\n *\n *  @return The `NSOpenGLContext` of the specified window, or `nil` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI id glfwGetNSGLContext(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_X11)\n/*! @brief Returns the `Display` used by GLFW.\n *\n *  @return The `Display` used by GLFW, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI Display* glfwGetX11Display(void);\n\n/*! @brief Returns the `RRCrtc` of the specified monitor.\n *\n *  @return The `RRCrtc` of the specified monitor, or `None` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.1.\n *\n *  @ingroup native\n */\nGLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);\n\n/*! @brief Returns the `RROutput` of the specified monitor.\n *\n *  @return The `RROutput` of the specified monitor, or `None` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.1.\n *\n *  @ingroup native\n */\nGLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);\n\n/*! @brief Returns the `Window` of the specified window.\n *\n *  @return The `Window` of the specified window, or `None` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI Window glfwGetX11Window(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_GLX)\n/*! @brief Returns the `GLXContext` of the specified window.\n *\n *  @return The `GLXContext` of the specified window, or `NULL` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);\n#endif\n\n#if defined(GLFW_EXPOSE_NATIVE_EGL)\n/*! @brief Returns the `EGLDisplay` used by GLFW.\n *\n *  @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI EGLDisplay glfwGetEGLDisplay(void);\n\n/*! @brief Returns the `EGLContext` of the specified window.\n *\n *  @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);\n\n/*! @brief Returns the `EGLSurface` of the specified window.\n *\n *  @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an\n *  [error](@ref error_handling) occurred.\n *\n *  @par Thread Safety\n *  This function may be called from any thread.  Access is not synchronized.\n *\n *  @par History\n *  Added in GLFW 3.0.\n *\n *  @ingroup native\n */\nGLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _glfw3_native_h_ */\n\n"
  },
  {
    "path": "deps/glfw/src/CMakeLists.txt",
    "content": "\ninclude_directories(\"${GLFW_SOURCE_DIR}/src\"\n                    \"${GLFW_BINARY_DIR}/src\"\n                    ${glfw_INCLUDE_DIRS})\n\nadd_definitions(-D_GLFW_USE_CONFIG_H)\n\nset(common_HEADERS internal.h\n                   \"${GLFW_BINARY_DIR}/src/glfw_config.h\"\n                   \"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h\"\n                   \"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h\")\nset(common_SOURCES context.c init.c input.c monitor.c window.c)\n\nif (_GLFW_COCOA)\n    set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h iokit_joystick.h\n                     posix_tls.h)\n    set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_monitor.m\n                     cocoa_window.m iokit_joystick.m mach_time.c posix_tls.c)\nelseif (_GLFW_WIN32)\n    set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_tls.h\n                     winmm_joystick.h)\n    set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_monitor.c win32_time.c\n                     win32_tls.c win32_window.c winmm_joystick.c)\nelseif (_GLFW_X11)\n    set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h\n                     linux_joystick.h posix_time.h posix_tls.h)\n    set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c\n                     xkb_unicode.c linux_joystick.c posix_time.c posix_tls.c)\nelseif (_GLFW_WAYLAND)\n    set(glfw_HEADERS ${common_HEADERS} wl_platform.h linux_joystick.h\n                     posix_time.h posix_tls.h xkb_unicode.h)\n    set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c\n                     linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c)\nelseif (_GLFW_MIR)\n    set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h\n                     posix_time.h posix_tls.h xkb_unicode.h)\n    set(glfw_SOURCES ${common_SOURCES} mir_init.c mir_monitor.c mir_window.c\n                     linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c)\nendif()\n\nif (_GLFW_EGL)\n    list(APPEND glfw_HEADERS ${common_HEADERS} egl_context.h)\n    list(APPEND glfw_SOURCES ${common_SOURCES} egl_context.c)\nelseif (_GLFW_NSGL)\n    list(APPEND glfw_HEADERS ${common_HEADERS} nsgl_context.h)\n    list(APPEND glfw_SOURCES ${common_SOURCES} nsgl_context.m)\nelseif (_GLFW_WGL)\n    list(APPEND glfw_HEADERS ${common_HEADERS} wgl_context.h)\n    list(APPEND glfw_SOURCES ${common_SOURCES} wgl_context.c)\nelseif (_GLFW_X11)\n    list(APPEND glfw_HEADERS ${common_HEADERS} glx_context.h)\n    list(APPEND glfw_SOURCES ${common_SOURCES} glx_context.c)\nendif()\n\nif (APPLE)\n    # For some reason, CMake doesn't know about .m\n    set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)\nendif()\n\nadd_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})\nset_target_properties(glfw PROPERTIES\n                      OUTPUT_NAME \"${GLFW_LIB_NAME}\"\n                      VERSION ${GLFW_VERSION}\n                      SOVERSION ${GLFW_VERSION_MAJOR}\n                      POSITION_INDEPENDENT_CODE ON\n                      FOLDER \"GLFW3\")\n\nif (BUILD_SHARED_LIBS)\n    if (WIN32)\n        # The GLFW DLL needs a special compile-time macro and import library name\n        set_target_properties(glfw PROPERTIES PREFIX \"\" IMPORT_PREFIX \"\")\n\n        if (MINGW)\n            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX \"dll.a\")\n        else()\n            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX \"dll.lib\")\n        endif()\n    elseif (APPLE)\n        # Append -fno-common to the compile flags to work around a bug in\n        # Apple's GCC\n        get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS)\n        if (NOT glfw_CFLAGS)\n            set(glfw_CFLAGS \"\")\n        endif()\n        set_target_properties(glfw PROPERTIES\n                              COMPILE_FLAGS \"${glfw_CFLAGS} -fno-common\"\n                              INSTALL_NAME_DIR \"${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}\")\n    endif()\n\n    target_link_libraries(glfw ${glfw_LIBRARIES})\nendif()\n\nif (GLFW_INSTALL)\n    install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX})\nendif()\n\n"
  },
  {
    "path": "deps/glfw/src/cocoa_init.m",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n#include <sys/param.h> // For MAXPATHLEN\n\n\n#if defined(_GLFW_USE_CHDIR)\n\n// Change to our application bundle's resources directory, if present\n//\nstatic void changeToResourcesDirectory(void)\n{\n    char resourcesPath[MAXPATHLEN];\n\n    CFBundleRef bundle = CFBundleGetMainBundle();\n    if (!bundle)\n        return;\n\n    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);\n\n    CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);\n    if (CFStringCompare(CFSTR(\"Resources\"), last, 0) != kCFCompareEqualTo)\n    {\n        CFRelease(last);\n        CFRelease(resourcesURL);\n        return;\n    }\n\n    CFRelease(last);\n\n    if (!CFURLGetFileSystemRepresentation(resourcesURL,\n                                          true,\n                                          (UInt8*) resourcesPath,\n                                          MAXPATHLEN))\n    {\n        CFRelease(resourcesURL);\n        return;\n    }\n\n    CFRelease(resourcesURL);\n\n    chdir(resourcesPath);\n}\n\n#endif /* _GLFW_USE_CHDIR */\n\n// Create key code translation tables\n//\nstatic void createKeyTables(void)\n{\n    memset(_glfw.ns.publicKeys, -1, sizeof(_glfw.ns.publicKeys));\n\n    _glfw.ns.publicKeys[0x1D] = GLFW_KEY_0;\n    _glfw.ns.publicKeys[0x12] = GLFW_KEY_1;\n    _glfw.ns.publicKeys[0x13] = GLFW_KEY_2;\n    _glfw.ns.publicKeys[0x14] = GLFW_KEY_3;\n    _glfw.ns.publicKeys[0x15] = GLFW_KEY_4;\n    _glfw.ns.publicKeys[0x17] = GLFW_KEY_5;\n    _glfw.ns.publicKeys[0x16] = GLFW_KEY_6;\n    _glfw.ns.publicKeys[0x1A] = GLFW_KEY_7;\n    _glfw.ns.publicKeys[0x1C] = GLFW_KEY_8;\n    _glfw.ns.publicKeys[0x19] = GLFW_KEY_9;\n    _glfw.ns.publicKeys[0x00] = GLFW_KEY_A;\n    _glfw.ns.publicKeys[0x0B] = GLFW_KEY_B;\n    _glfw.ns.publicKeys[0x08] = GLFW_KEY_C;\n    _glfw.ns.publicKeys[0x02] = GLFW_KEY_D;\n    _glfw.ns.publicKeys[0x0E] = GLFW_KEY_E;\n    _glfw.ns.publicKeys[0x03] = GLFW_KEY_F;\n    _glfw.ns.publicKeys[0x05] = GLFW_KEY_G;\n    _glfw.ns.publicKeys[0x04] = GLFW_KEY_H;\n    _glfw.ns.publicKeys[0x22] = GLFW_KEY_I;\n    _glfw.ns.publicKeys[0x26] = GLFW_KEY_J;\n    _glfw.ns.publicKeys[0x28] = GLFW_KEY_K;\n    _glfw.ns.publicKeys[0x25] = GLFW_KEY_L;\n    _glfw.ns.publicKeys[0x2E] = GLFW_KEY_M;\n    _glfw.ns.publicKeys[0x2D] = GLFW_KEY_N;\n    _glfw.ns.publicKeys[0x1F] = GLFW_KEY_O;\n    _glfw.ns.publicKeys[0x23] = GLFW_KEY_P;\n    _glfw.ns.publicKeys[0x0C] = GLFW_KEY_Q;\n    _glfw.ns.publicKeys[0x0F] = GLFW_KEY_R;\n    _glfw.ns.publicKeys[0x01] = GLFW_KEY_S;\n    _glfw.ns.publicKeys[0x11] = GLFW_KEY_T;\n    _glfw.ns.publicKeys[0x20] = GLFW_KEY_U;\n    _glfw.ns.publicKeys[0x09] = GLFW_KEY_V;\n    _glfw.ns.publicKeys[0x0D] = GLFW_KEY_W;\n    _glfw.ns.publicKeys[0x07] = GLFW_KEY_X;\n    _glfw.ns.publicKeys[0x10] = GLFW_KEY_Y;\n    _glfw.ns.publicKeys[0x06] = GLFW_KEY_Z;\n\n    _glfw.ns.publicKeys[0x27] = GLFW_KEY_APOSTROPHE;\n    _glfw.ns.publicKeys[0x2A] = GLFW_KEY_BACKSLASH;\n    _glfw.ns.publicKeys[0x2B] = GLFW_KEY_COMMA;\n    _glfw.ns.publicKeys[0x18] = GLFW_KEY_EQUAL;\n    _glfw.ns.publicKeys[0x32] = GLFW_KEY_GRAVE_ACCENT;\n    _glfw.ns.publicKeys[0x21] = GLFW_KEY_LEFT_BRACKET;\n    _glfw.ns.publicKeys[0x1B] = GLFW_KEY_MINUS;\n    _glfw.ns.publicKeys[0x2F] = GLFW_KEY_PERIOD;\n    _glfw.ns.publicKeys[0x1E] = GLFW_KEY_RIGHT_BRACKET;\n    _glfw.ns.publicKeys[0x29] = GLFW_KEY_SEMICOLON;\n    _glfw.ns.publicKeys[0x2C] = GLFW_KEY_SLASH;\n    _glfw.ns.publicKeys[0x0A] = GLFW_KEY_WORLD_1;\n\n    _glfw.ns.publicKeys[0x33] = GLFW_KEY_BACKSPACE;\n    _glfw.ns.publicKeys[0x39] = GLFW_KEY_CAPS_LOCK;\n    _glfw.ns.publicKeys[0x75] = GLFW_KEY_DELETE;\n    _glfw.ns.publicKeys[0x7D] = GLFW_KEY_DOWN;\n    _glfw.ns.publicKeys[0x77] = GLFW_KEY_END;\n    _glfw.ns.publicKeys[0x24] = GLFW_KEY_ENTER;\n    _glfw.ns.publicKeys[0x35] = GLFW_KEY_ESCAPE;\n    _glfw.ns.publicKeys[0x7A] = GLFW_KEY_F1;\n    _glfw.ns.publicKeys[0x78] = GLFW_KEY_F2;\n    _glfw.ns.publicKeys[0x63] = GLFW_KEY_F3;\n    _glfw.ns.publicKeys[0x76] = GLFW_KEY_F4;\n    _glfw.ns.publicKeys[0x60] = GLFW_KEY_F5;\n    _glfw.ns.publicKeys[0x61] = GLFW_KEY_F6;\n    _glfw.ns.publicKeys[0x62] = GLFW_KEY_F7;\n    _glfw.ns.publicKeys[0x64] = GLFW_KEY_F8;\n    _glfw.ns.publicKeys[0x65] = GLFW_KEY_F9;\n    _glfw.ns.publicKeys[0x6D] = GLFW_KEY_F10;\n    _glfw.ns.publicKeys[0x67] = GLFW_KEY_F11;\n    _glfw.ns.publicKeys[0x6F] = GLFW_KEY_F12;\n    _glfw.ns.publicKeys[0x69] = GLFW_KEY_F13;\n    _glfw.ns.publicKeys[0x6B] = GLFW_KEY_F14;\n    _glfw.ns.publicKeys[0x71] = GLFW_KEY_F15;\n    _glfw.ns.publicKeys[0x6A] = GLFW_KEY_F16;\n    _glfw.ns.publicKeys[0x40] = GLFW_KEY_F17;\n    _glfw.ns.publicKeys[0x4F] = GLFW_KEY_F18;\n    _glfw.ns.publicKeys[0x50] = GLFW_KEY_F19;\n    _glfw.ns.publicKeys[0x5A] = GLFW_KEY_F20;\n    _glfw.ns.publicKeys[0x73] = GLFW_KEY_HOME;\n    _glfw.ns.publicKeys[0x72] = GLFW_KEY_INSERT;\n    _glfw.ns.publicKeys[0x7B] = GLFW_KEY_LEFT;\n    _glfw.ns.publicKeys[0x3A] = GLFW_KEY_LEFT_ALT;\n    _glfw.ns.publicKeys[0x3B] = GLFW_KEY_LEFT_CONTROL;\n    _glfw.ns.publicKeys[0x38] = GLFW_KEY_LEFT_SHIFT;\n    _glfw.ns.publicKeys[0x37] = GLFW_KEY_LEFT_SUPER;\n    _glfw.ns.publicKeys[0x6E] = GLFW_KEY_MENU;\n    _glfw.ns.publicKeys[0x47] = GLFW_KEY_NUM_LOCK;\n    _glfw.ns.publicKeys[0x79] = GLFW_KEY_PAGE_DOWN;\n    _glfw.ns.publicKeys[0x74] = GLFW_KEY_PAGE_UP;\n    _glfw.ns.publicKeys[0x7C] = GLFW_KEY_RIGHT;\n    _glfw.ns.publicKeys[0x3D] = GLFW_KEY_RIGHT_ALT;\n    _glfw.ns.publicKeys[0x3E] = GLFW_KEY_RIGHT_CONTROL;\n    _glfw.ns.publicKeys[0x3C] = GLFW_KEY_RIGHT_SHIFT;\n    _glfw.ns.publicKeys[0x36] = GLFW_KEY_RIGHT_SUPER;\n    _glfw.ns.publicKeys[0x31] = GLFW_KEY_SPACE;\n    _glfw.ns.publicKeys[0x30] = GLFW_KEY_TAB;\n    _glfw.ns.publicKeys[0x7E] = GLFW_KEY_UP;\n\n    _glfw.ns.publicKeys[0x52] = GLFW_KEY_KP_0;\n    _glfw.ns.publicKeys[0x53] = GLFW_KEY_KP_1;\n    _glfw.ns.publicKeys[0x54] = GLFW_KEY_KP_2;\n    _glfw.ns.publicKeys[0x55] = GLFW_KEY_KP_3;\n    _glfw.ns.publicKeys[0x56] = GLFW_KEY_KP_4;\n    _glfw.ns.publicKeys[0x57] = GLFW_KEY_KP_5;\n    _glfw.ns.publicKeys[0x58] = GLFW_KEY_KP_6;\n    _glfw.ns.publicKeys[0x59] = GLFW_KEY_KP_7;\n    _glfw.ns.publicKeys[0x5B] = GLFW_KEY_KP_8;\n    _glfw.ns.publicKeys[0x5C] = GLFW_KEY_KP_9;\n    _glfw.ns.publicKeys[0x45] = GLFW_KEY_KP_ADD;\n    _glfw.ns.publicKeys[0x41] = GLFW_KEY_KP_DECIMAL;\n    _glfw.ns.publicKeys[0x4B] = GLFW_KEY_KP_DIVIDE;\n    _glfw.ns.publicKeys[0x4C] = GLFW_KEY_KP_ENTER;\n    _glfw.ns.publicKeys[0x51] = GLFW_KEY_KP_EQUAL;\n    _glfw.ns.publicKeys[0x43] = GLFW_KEY_KP_MULTIPLY;\n    _glfw.ns.publicKeys[0x4E] = GLFW_KEY_KP_SUBTRACT;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformInit(void)\n{\n    _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];\n\n#if defined(_GLFW_USE_CHDIR)\n    changeToResourcesDirectory();\n#endif\n\n    createKeyTables();\n\n    _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);\n    if (!_glfw.ns.eventSource)\n        return GL_FALSE;\n\n    CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);\n\n    if (!_glfwInitContextAPI())\n        return GL_FALSE;\n\n    _glfwInitTimer();\n    _glfwInitJoysticks();\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformTerminate(void)\n{\n    if (_glfw.ns.eventSource)\n    {\n        CFRelease(_glfw.ns.eventSource);\n        _glfw.ns.eventSource = NULL;\n    }\n\n    if (_glfw.ns.delegate)\n    {\n        [NSApp setDelegate:nil];\n        [_glfw.ns.delegate release];\n        _glfw.ns.delegate = nil;\n    }\n\n    [_glfw.ns.autoreleasePool release];\n    _glfw.ns.autoreleasePool = nil;\n\n    [_glfw.ns.cursor release];\n    _glfw.ns.cursor = nil;\n\n    free(_glfw.ns.clipboardString);\n\n    _glfwTerminateJoysticks();\n    _glfwTerminateContextAPI();\n}\n\nconst char* _glfwPlatformGetVersionString(void)\n{\n    return _GLFW_VERSION_NUMBER \" Cocoa\"\n#if defined(_GLFW_NSGL)\n        \" NSGL\"\n#endif\n#if defined(_GLFW_USE_CHDIR)\n        \" chdir\"\n#endif\n#if defined(_GLFW_USE_MENUBAR)\n        \" menubar\"\n#endif\n#if defined(_GLFW_USE_RETINA)\n        \" retina\"\n#endif\n#if defined(_GLFW_BUILD_DLL)\n        \" dynamic\"\n#endif\n        ;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/cocoa_monitor.m",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <stdlib.h>\n#include <limits.h>\n\n#include <IOKit/graphics/IOGraphicsLib.h>\n#include <IOKit/graphics/IOGraphicsLib.h>\n#include <CoreVideo/CVBase.h>\n#include <CoreVideo/CVDisplayLink.h>\n#include <ApplicationServices/ApplicationServices.h>\n\n\n// Get the name of the specified display\n//\nstatic char* getDisplayName(CGDirectDisplayID displayID)\n{\n    char* name;\n    CFDictionaryRef info, names;\n    CFStringRef value;\n    CFIndex size;\n\n    // NOTE: This uses a deprecated function because Apple has\n    //       (as of January 2015) not provided any alternative\n    info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),\n                                         kIODisplayOnlyPreferredName);\n    names = CFDictionaryGetValue(info, CFSTR(kDisplayProductName));\n\n    if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR(\"en_US\"),\n                                                 (const void**) &value))\n    {\n        // This may happen if a desktop Mac is running headless\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Failed to retrieve display name\");\n\n        CFRelease(info);\n        return strdup(\"Unknown\");\n    }\n\n    size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value),\n                                             kCFStringEncodingUTF8);\n    name = calloc(size + 1, sizeof(char));\n    CFStringGetCString(value, name, size, kCFStringEncodingUTF8);\n\n    CFRelease(info);\n\n    return name;\n}\n\n// Check whether the display mode should be included in enumeration\n//\nstatic GLboolean modeIsGood(CGDisplayModeRef mode)\n{\n    uint32_t flags = CGDisplayModeGetIOFlags(mode);\n    if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))\n        return GL_FALSE;\n\n    if (flags & kDisplayModeInterlacedFlag)\n        return GL_FALSE;\n\n    if (flags & kDisplayModeStretchedFlag)\n        return GL_FALSE;\n\n    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);\n    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&\n        CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))\n    {\n        CFRelease(format);\n        return GL_FALSE;\n    }\n\n    CFRelease(format);\n    return GL_TRUE;\n}\n\n// Convert Core Graphics display mode to GLFW video mode\n//\nstatic GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,\n                                            CVDisplayLinkRef link)\n{\n    GLFWvidmode result;\n    result.width = (int) CGDisplayModeGetWidth(mode);\n    result.height = (int) CGDisplayModeGetHeight(mode);\n    result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);\n\n    if (result.refreshRate == 0)\n    {\n        const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);\n        if (!(time.flags & kCVTimeIsIndefinite))\n            result.refreshRate = (int) (time.timeScale / (double) time.timeValue);\n    }\n\n    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);\n\n    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)\n    {\n        result.redBits = 5;\n        result.greenBits = 5;\n        result.blueBits = 5;\n    }\n    else\n    {\n        result.redBits = 8;\n        result.greenBits = 8;\n        result.blueBits = 8;\n    }\n\n    CFRelease(format);\n    return result;\n}\n\n// Starts reservation for display fading\n//\nstatic CGDisplayFadeReservationToken beginFadeReservation(void)\n{\n    CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;\n\n    if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)\n        CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE);\n\n    return token;\n}\n\n// Ends reservation for display fading\n//\nstatic void endFadeReservation(CGDisplayFadeReservationToken token)\n{\n    if (token != kCGDisplayFadeReservationInvalidToken)\n    {\n        CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE);\n        CGReleaseDisplayFadeReservation(token);\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Change the current video mode\n//\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)\n{\n    CFArrayRef modes;\n    CFIndex count, i;\n    CVDisplayLinkRef link;\n    CGDisplayModeRef native = NULL;\n    GLFWvidmode current;\n    const GLFWvidmode* best;\n\n    best = _glfwChooseVideoMode(monitor, desired);\n    _glfwPlatformGetVideoMode(monitor, &current);\n    if (_glfwCompareVideoModes(&current, best) == 0)\n        return GL_TRUE;\n\n    CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);\n\n    modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);\n    count = CFArrayGetCount(modes);\n\n    for (i = 0;  i < count;  i++)\n    {\n        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);\n        if (!modeIsGood(dm))\n            continue;\n\n        const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);\n        if (_glfwCompareVideoModes(best, &mode) == 0)\n        {\n            native = dm;\n            break;\n        }\n    }\n\n    if (native)\n    {\n        if (monitor->ns.previousMode == NULL)\n            monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);\n\n        CGDisplayFadeReservationToken token = beginFadeReservation();\n        CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);\n        endFadeReservation(token);\n    }\n\n    CFRelease(modes);\n    CVDisplayLinkRelease(link);\n\n    if (!native)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Monitor mode list changed\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n// Restore the previously saved (original) video mode\n//\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor)\n{\n    if (monitor->ns.previousMode)\n    {\n        CGDisplayFadeReservationToken token = beginFadeReservation();\n        CGDisplaySetDisplayMode(monitor->ns.displayID,\n                                monitor->ns.previousMode, NULL);\n        endFadeReservation(token);\n\n        CGDisplayModeRelease(monitor->ns.previousMode);\n        monitor->ns.previousMode = NULL;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count)\n{\n    uint32_t i, found = 0, displayCount;\n    _GLFWmonitor** monitors;\n    CGDirectDisplayID* displays;\n\n    *count = 0;\n\n    CGGetOnlineDisplayList(0, NULL, &displayCount);\n    displays = calloc(displayCount, sizeof(CGDirectDisplayID));\n    monitors = calloc(displayCount, sizeof(_GLFWmonitor*));\n\n    CGGetOnlineDisplayList(displayCount, displays, &displayCount);\n\n    for (i = 0;  i < displayCount;  i++)\n    {\n        _GLFWmonitor* monitor;\n\n        if (CGDisplayIsAsleep(displays[i]))\n            continue;\n\n        const CGSize size = CGDisplayScreenSize(displays[i]);\n        char* name = getDisplayName(displays[i]);\n\n        monitor = _glfwAllocMonitor(name, size.width, size.height);\n        monitor->ns.displayID  = displays[i];\n        monitor->ns.unitNumber = CGDisplayUnitNumber(displays[i]);\n\n        free(name);\n\n        found++;\n        monitors[found - 1] = monitor;\n    }\n\n    free(displays);\n\n    *count = found;\n    return monitors;\n}\n\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)\n{\n    // HACK: Compare unit numbers instead of display IDs to work around display\n    //       replacement on machines with automatic graphics switching\n    return first->ns.unitNumber == second->ns.unitNumber;\n}\n\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)\n{\n    const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);\n\n    if (xpos)\n        *xpos = (int) bounds.origin.x;\n    if (ypos)\n        *ypos = (int) bounds.origin.y;\n}\n\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)\n{\n    CFArrayRef modes;\n    CFIndex found, i, j;\n    GLFWvidmode* result;\n    CVDisplayLinkRef link;\n\n    *count = 0;\n\n    CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);\n\n    modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);\n    found = CFArrayGetCount(modes);\n    result = calloc(found, sizeof(GLFWvidmode));\n\n    for (i = 0;  i < found;  i++)\n    {\n        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);\n        if (!modeIsGood(dm))\n            continue;\n\n        const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);\n\n        for (j = 0;  j < *count;  j++)\n        {\n            if (_glfwCompareVideoModes(result + j, &mode) == 0)\n                break;\n        }\n\n        // Skip duplicate modes\n        if (i < *count)\n            continue;\n\n        (*count)++;\n        result[*count - 1] = mode;\n    }\n\n    CFRelease(modes);\n    CVDisplayLinkRelease(link);\n    return result;\n}\n\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)\n{\n    CGDisplayModeRef displayMode;\n    CVDisplayLinkRef link;\n\n    CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);\n\n    displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);\n    *mode = vidmodeFromCGDisplayMode(displayMode, link);\n    CGDisplayModeRelease(displayMode);\n\n    CVDisplayLinkRelease(link);\n}\n\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)\n{\n    uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);\n    CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));\n\n    CGGetDisplayTransferByTable(monitor->ns.displayID,\n                                size,\n                                values,\n                                values + size,\n                                values + size * 2,\n                                &size);\n\n    _glfwAllocGammaArrays(ramp, size);\n\n    for (i = 0; i < size; i++)\n    {\n        ramp->red[i]   = (unsigned short) (values[i] * 65535);\n        ramp->green[i] = (unsigned short) (values[i + size] * 65535);\n        ramp->blue[i]  = (unsigned short) (values[i + size * 2] * 65535);\n    }\n\n    free(values);\n}\n\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)\n{\n    int i;\n    CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));\n\n    for (i = 0;  i < ramp->size;  i++)\n    {\n        values[i]                  = ramp->red[i] / 65535.f;\n        values[i + ramp->size]     = ramp->green[i] / 65535.f;\n        values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;\n    }\n\n    CGSetDisplayTransferByTable(monitor->ns.displayID,\n                                ramp->size,\n                                values,\n                                values + ramp->size,\n                                values + ramp->size * 2);\n\n    free(values);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);\n    return monitor->ns.displayID;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/cocoa_platform.h",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_cocoa_platform_h_\n#define _glfw3_cocoa_platform_h_\n\n#include <stdint.h>\n\n#if defined(__OBJC__)\n#import <Cocoa/Cocoa.h>\n#else\n#include <ApplicationServices/ApplicationServices.h>\ntypedef void* id;\n#endif\n\n#include \"posix_tls.h\"\n#include \"iokit_joystick.h\"\n\n#if defined(_GLFW_NSGL)\n #include \"nsgl_context.h\"\n#else\n #error \"The Cocoa backend depends on NSGL platform support\"\n#endif\n\n#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowNS  ns\n#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns\n#define _GLFW_PLATFORM_LIBRARY_TIME_STATE   _GLFWtimeNS    ns_time\n#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorNS ns\n#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorNS  ns\n\n\n// Cocoa-specific per-window data\n//\ntypedef struct _GLFWwindowNS\n{\n    id              object;\n    id              delegate;\n    id              view;\n    unsigned int    modifierFlags;\n\n    // The total sum of the distances the cursor has been warped\n    // since the last cursor motion event was processed\n    // This is kept to counteract Cocoa doing the same internally\n    double          warpDeltaX, warpDeltaY;\n\n} _GLFWwindowNS;\n\n\n// Cocoa-specific global data\n//\ntypedef struct _GLFWlibraryNS\n{\n    CGEventSourceRef eventSource;\n    id              delegate;\n    id              autoreleasePool;\n    id              cursor;\n\n    short int       publicKeys[256];\n    char*           clipboardString;\n\n} _GLFWlibraryNS;\n\n\n// Cocoa-specific per-monitor data\n//\ntypedef struct _GLFWmonitorNS\n{\n    CGDirectDisplayID   displayID;\n    CGDisplayModeRef    previousMode;\n    uint32_t            unitNumber;\n\n} _GLFWmonitorNS;\n\n\n// Cocoa-specific per-cursor data\n//\ntypedef struct _GLFWcursorNS\n{\n    id              object;\n\n} _GLFWcursorNS;\n\n\n// Cocoa-specific global timer data\n//\ntypedef struct _GLFWtimeNS\n{\n    double          base;\n    double          resolution;\n\n} _GLFWtimeNS;\n\n\nvoid _glfwInitTimer(void);\n\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor);\n\n#endif // _glfw3_cocoa_platform_h_\n"
  },
  {
    "path": "deps/glfw/src/cocoa_window.m",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <string.h>\n\n// Needed for _NSGetProgname\n#include <crt_externs.h>\n\n\n// Returns the specified standard cursor\n//\nstatic NSCursor* getStandardCursor(int shape)\n{\n    switch (shape)\n    {\n        case GLFW_ARROW_CURSOR:\n            return [NSCursor arrowCursor];\n        case GLFW_IBEAM_CURSOR:\n            return [NSCursor IBeamCursor];\n        case GLFW_CROSSHAIR_CURSOR:\n            return [NSCursor crosshairCursor];\n        case GLFW_HAND_CURSOR:\n            return [NSCursor pointingHandCursor];\n        case GLFW_HRESIZE_CURSOR:\n            return [NSCursor resizeLeftRightCursor];\n        case GLFW_VRESIZE_CURSOR:\n            return [NSCursor resizeUpDownCursor];\n    }\n\n    return nil;\n}\n\n// Center the cursor in the view of the window\n//\nstatic void centerCursor(_GLFWwindow *window)\n{\n    int width, height;\n    _glfwPlatformGetWindowSize(window, &width, &height);\n    _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);\n}\n\n// Update the cursor to match the specified cursor mode\n//\nstatic void updateModeCursor(_GLFWwindow* window)\n{\n    if (window->cursorMode == GLFW_CURSOR_NORMAL)\n    {\n        if (window->cursor)\n            [(NSCursor*) window->cursor->ns.object set];\n        else\n            [[NSCursor arrowCursor] set];\n    }\n    else\n        [(NSCursor*) _glfw.ns.cursor set];\n}\n\n// Enter full screen mode\n//\nstatic GLboolean enterFullscreenMode(_GLFWwindow* window)\n{\n    GLFWvidmode mode;\n    GLboolean status;\n    int xpos, ypos;\n\n    status = _glfwSetVideoMode(window->monitor, &window->videoMode);\n\n    _glfwPlatformGetVideoMode(window->monitor, &mode);\n    _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);\n\n    [window->ns.object setFrame:NSMakeRect(xpos, ypos, mode.width, mode.height)\n                        display:YES];\n\n    return status;\n}\n\n// Leave full screen mode\n//\nstatic void leaveFullscreenMode(_GLFWwindow* window)\n{\n    _glfwRestoreVideoMode(window->monitor);\n}\n\n// Transforms the specified y-coordinate between the CG display and NS screen\n// coordinate systems\n//\nstatic float transformY(float y)\n{\n    const float height = CGDisplayBounds(CGMainDisplayID()).size.height;\n    return height - y;\n}\n\n// Returns the backing rect of the specified window\n//\nstatic NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)\n{\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n        return [window->ns.view convertRectToBacking:contentRect];\n    else\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n        return contentRect;\n}\n\n// Translates OS X key modifiers into GLFW ones\n//\nstatic int translateFlags(NSUInteger flags)\n{\n    int mods = 0;\n\n    if (flags & NSShiftKeyMask)\n        mods |= GLFW_MOD_SHIFT;\n    if (flags & NSControlKeyMask)\n        mods |= GLFW_MOD_CONTROL;\n    if (flags & NSAlternateKeyMask)\n        mods |= GLFW_MOD_ALT;\n    if (flags & NSCommandKeyMask)\n        mods |= GLFW_MOD_SUPER;\n\n    return mods;\n}\n\n// Translates a OS X keycode to a GLFW keycode\n//\nstatic int translateKey(unsigned int key)\n{\n    if (key >= sizeof(_glfw.ns.publicKeys) / sizeof(_glfw.ns.publicKeys[0]))\n        return GLFW_KEY_UNKNOWN;\n\n    return _glfw.ns.publicKeys[key];\n}\n\n\n//------------------------------------------------------------------------\n// Delegate for window related notifications\n//------------------------------------------------------------------------\n\n@interface GLFWWindowDelegate : NSObject\n{\n    _GLFWwindow* window;\n}\n\n- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;\n\n@end\n\n@implementation GLFWWindowDelegate\n\n- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow\n{\n    self = [super init];\n    if (self != nil)\n        window = initWindow;\n\n    return self;\n}\n\n- (BOOL)windowShouldClose:(id)sender\n{\n    _glfwInputWindowCloseRequest(window);\n    return NO;\n}\n\n- (void)windowDidResize:(NSNotification *)notification\n{\n    [window->nsgl.context update];\n\n    if (_glfw.cursorWindow == window &&\n        window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        centerCursor(window);\n    }\n\n    const NSRect contentRect = [window->ns.view frame];\n    const NSRect fbRect = convertRectToBacking(window, contentRect);\n\n    _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);\n    _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);\n}\n\n- (void)windowDidMove:(NSNotification *)notification\n{\n    [window->nsgl.context update];\n\n    if (_glfw.cursorWindow == window &&\n        window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        centerCursor(window);\n    }\n\n    int x, y;\n    _glfwPlatformGetWindowPos(window, &x, &y);\n    _glfwInputWindowPos(window, x, y);\n}\n\n- (void)windowDidMiniaturize:(NSNotification *)notification\n{\n    if (window->monitor)\n        leaveFullscreenMode(window);\n\n    _glfwInputWindowIconify(window, GL_TRUE);\n}\n\n- (void)windowDidDeminiaturize:(NSNotification *)notification\n{\n    if (window->monitor)\n        enterFullscreenMode(window);\n\n    _glfwInputWindowIconify(window, GL_FALSE);\n}\n\n- (void)windowDidBecomeKey:(NSNotification *)notification\n{\n    if (_glfw.cursorWindow == window &&\n        window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        centerCursor(window);\n    }\n\n    _glfwInputWindowFocus(window, GL_TRUE);\n    _glfwPlatformApplyCursorMode(window);\n}\n\n- (void)windowDidResignKey:(NSNotification *)notification\n{\n    if (window->monitor && window->autoIconify)\n        _glfwPlatformIconifyWindow(window);\n\n    _glfwInputWindowFocus(window, GL_FALSE);\n}\n\n@end\n\n\n//------------------------------------------------------------------------\n// Delegate for application related notifications\n//------------------------------------------------------------------------\n\n@interface GLFWApplicationDelegate : NSObject\n@end\n\n@implementation GLFWApplicationDelegate\n\n- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender\n{\n    _GLFWwindow* window;\n\n    for (window = _glfw.windowListHead;  window;  window = window->next)\n        _glfwInputWindowCloseRequest(window);\n\n    return NSTerminateCancel;\n}\n\n- (void)applicationDidChangeScreenParameters:(NSNotification *) notification\n{\n    _glfwInputMonitorChange();\n}\n\n- (void)applicationDidFinishLaunching:(NSNotification *)notification\n{\n    [NSApp stop:nil];\n\n    _glfwPlatformPostEmptyEvent();\n}\n\n- (void)applicationDidHide:(NSNotification *)notification\n{\n    int i;\n\n    for (i = 0;  i < _glfw.monitorCount;  i++)\n        _glfwRestoreVideoMode(_glfw.monitors[i]);\n}\n\n@end\n\n\n//------------------------------------------------------------------------\n// Content view class for the GLFW window\n//------------------------------------------------------------------------\n\n@interface GLFWContentView : NSView\n{\n    _GLFWwindow* window;\n    NSTrackingArea* trackingArea;\n}\n\n- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow;\n\n@end\n\n@implementation GLFWContentView\n\n+ (void)initialize\n{\n    if (self == [GLFWContentView class])\n    {\n        if (_glfw.ns.cursor == nil)\n        {\n            NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)];\n            _glfw.ns.cursor = [[NSCursor alloc] initWithImage:data\n                                                      hotSpot:NSZeroPoint];\n            [data release];\n        }\n    }\n}\n\n- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow\n{\n    self = [super init];\n    if (self != nil)\n    {\n        window = initWindow;\n        trackingArea = nil;\n\n        [self updateTrackingAreas];\n        [self registerForDraggedTypes:[NSArray arrayWithObjects:\n                                       NSFilenamesPboardType, nil]];\n    }\n\n    return self;\n}\n\n-(void)dealloc\n{\n    [trackingArea release];\n    [super dealloc];\n}\n\n- (BOOL)isOpaque\n{\n    return YES;\n}\n\n- (BOOL)canBecomeKeyView\n{\n    return YES;\n}\n\n- (BOOL)acceptsFirstResponder\n{\n    return YES;\n}\n\n- (void)cursorUpdate:(NSEvent *)event\n{\n    updateModeCursor(window);\n}\n\n- (void)mouseDown:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         GLFW_MOUSE_BUTTON_LEFT,\n                         GLFW_PRESS,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)mouseDragged:(NSEvent *)event\n{\n    [self mouseMoved:event];\n}\n\n- (void)mouseUp:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         GLFW_MOUSE_BUTTON_LEFT,\n                         GLFW_RELEASE,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)mouseMoved:(NSEvent *)event\n{\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        _glfwInputCursorMotion(window,\n                               [event deltaX] - window->ns.warpDeltaX,\n                               [event deltaY] - window->ns.warpDeltaY);\n    }\n    else\n    {\n        const NSRect contentRect = [window->ns.view frame];\n        const NSPoint pos = [event locationInWindow];\n\n        _glfwInputCursorMotion(window, pos.x, contentRect.size.height - pos.y);\n    }\n\n    window->ns.warpDeltaX = 0;\n    window->ns.warpDeltaY = 0;\n}\n\n- (void)rightMouseDown:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         GLFW_MOUSE_BUTTON_RIGHT,\n                         GLFW_PRESS,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)rightMouseDragged:(NSEvent *)event\n{\n    [self mouseMoved:event];\n}\n\n- (void)rightMouseUp:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         GLFW_MOUSE_BUTTON_RIGHT,\n                         GLFW_RELEASE,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)otherMouseDown:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         (int) [event buttonNumber],\n                         GLFW_PRESS,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)otherMouseDragged:(NSEvent *)event\n{\n    [self mouseMoved:event];\n}\n\n- (void)otherMouseUp:(NSEvent *)event\n{\n    _glfwInputMouseClick(window,\n                         (int) [event buttonNumber],\n                         GLFW_RELEASE,\n                         translateFlags([event modifierFlags]));\n}\n\n- (void)mouseExited:(NSEvent *)event\n{\n    _glfwInputCursorEnter(window, GL_FALSE);\n}\n\n- (void)mouseEntered:(NSEvent *)event\n{\n    _glfwInputCursorEnter(window, GL_TRUE);\n}\n\n- (void)viewDidChangeBackingProperties\n{\n    const NSRect contentRect = [window->ns.view frame];\n    const NSRect fbRect = convertRectToBacking(window, contentRect);\n\n    _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);\n}\n\n- (void)drawRect:(NSRect)rect\n{\n    _glfwInputWindowDamage(window);\n}\n\n- (void)updateTrackingAreas\n{\n    if (trackingArea != nil)\n    {\n        [self removeTrackingArea:trackingArea];\n        [trackingArea release];\n    }\n\n    const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |\n                                          NSTrackingActiveInKeyWindow |\n                                          NSTrackingEnabledDuringMouseDrag |\n                                          NSTrackingCursorUpdate |\n                                          NSTrackingInVisibleRect |\n                                          NSTrackingAssumeInside;\n\n    trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]\n                                                options:options\n                                                  owner:self\n                                               userInfo:nil];\n\n    [self addTrackingArea:trackingArea];\n    [super updateTrackingAreas];\n}\n\n- (void)keyDown:(NSEvent *)event\n{\n    const int key = translateKey([event keyCode]);\n    const int mods = translateFlags([event modifierFlags]);\n\n    _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);\n\n    NSString* characters = [event characters];\n    NSUInteger i, length = [characters length];\n    const int plain = !(mods & GLFW_MOD_SUPER);\n\n    for (i = 0;  i < length;  i++)\n    {\n        const unichar codepoint = [characters characterAtIndex:i];\n        if ((codepoint & 0xff00) == 0xf700)\n            continue;\n\n        _glfwInputChar(window, codepoint, mods, plain);\n    }\n}\n\n- (void)flagsChanged:(NSEvent *)event\n{\n    int action;\n    const unsigned int modifierFlags =\n        [event modifierFlags] & NSDeviceIndependentModifierFlagsMask;\n    const int key = translateKey([event keyCode]);\n    const int mods = translateFlags(modifierFlags);\n\n    if (modifierFlags == window->ns.modifierFlags)\n    {\n        if (window->keys[key] == GLFW_PRESS)\n            action = GLFW_RELEASE;\n        else\n            action = GLFW_PRESS;\n    }\n    else if (modifierFlags > window->ns.modifierFlags)\n        action = GLFW_PRESS;\n    else\n        action = GLFW_RELEASE;\n\n    window->ns.modifierFlags = modifierFlags;\n\n    _glfwInputKey(window, key, [event keyCode], action, mods);\n}\n\n- (void)keyUp:(NSEvent *)event\n{\n    const int key = translateKey([event keyCode]);\n    const int mods = translateFlags([event modifierFlags]);\n    _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);\n}\n\n- (void)scrollWheel:(NSEvent *)event\n{\n    double deltaX, deltaY;\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n    {\n        deltaX = [event scrollingDeltaX];\n        deltaY = [event scrollingDeltaY];\n\n        if ([event hasPreciseScrollingDeltas])\n        {\n            deltaX *= 0.1;\n            deltaY *= 0.1;\n        }\n    }\n    else\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n    {\n        deltaX = [event deltaX];\n        deltaY = [event deltaY];\n    }\n\n    if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)\n        _glfwInputScroll(window, deltaX, deltaY);\n}\n\n- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender\n{\n    if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])\n        == NSDragOperationGeneric)\n    {\n        [self setNeedsDisplay:YES];\n        return NSDragOperationGeneric;\n    }\n\n    return NSDragOperationNone;\n}\n\n- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender\n{\n    [self setNeedsDisplay:YES];\n    return YES;\n}\n\n- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender\n{\n    NSPasteboard* pasteboard = [sender draggingPasteboard];\n    NSArray* files = [pasteboard propertyListForType:NSFilenamesPboardType];\n\n    const NSRect contentRect = [window->ns.view frame];\n    _glfwInputCursorMotion(window,\n                           [sender draggingLocation].x,\n                           contentRect.size.height - [sender draggingLocation].y);\n\n    const int count = [files count];\n    if (count)\n    {\n        NSEnumerator* e = [files objectEnumerator];\n        char** paths = calloc(count, sizeof(char*));\n        int i;\n\n        for (i = 0;  i < count;  i++)\n            paths[i] = strdup([[e nextObject] UTF8String]);\n\n        _glfwInputDrop(window, count, (const char**) paths);\n\n        for (i = 0;  i < count;  i++)\n            free(paths[i]);\n        free(paths);\n    }\n\n    return YES;\n}\n\n- (void)concludeDragOperation:(id <NSDraggingInfo>)sender\n{\n    [self setNeedsDisplay:YES];\n}\n\n@end\n\n\n//------------------------------------------------------------------------\n// GLFW window class\n//------------------------------------------------------------------------\n\n@interface GLFWWindow : NSWindow {}\n@end\n\n@implementation GLFWWindow\n\n- (BOOL)canBecomeKeyWindow\n{\n    // Required for NSBorderlessWindowMask windows\n    return YES;\n}\n\n@end\n\n\n//------------------------------------------------------------------------\n// GLFW application class\n//------------------------------------------------------------------------\n\n@interface GLFWApplication : NSApplication\n@end\n\n@implementation GLFWApplication\n\n// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost\n// This works around an AppKit bug, where key up events while holding\n// down the command key don't get sent to the key window.\n- (void)sendEvent:(NSEvent *)event\n{\n    if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))\n        [[self keyWindow] sendEvent:event];\n    else\n        [super sendEvent:event];\n}\n\n@end\n\n#if defined(_GLFW_USE_MENUBAR)\n\n// Try to figure out what the calling application is called\n//\nstatic NSString* findAppName(void)\n{\n    size_t i;\n    NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];\n\n    // Keys to search for as potential application names\n    NSString* GLFWNameKeys[] =\n    {\n        @\"CFBundleDisplayName\",\n        @\"CFBundleName\",\n        @\"CFBundleExecutable\",\n    };\n\n    for (i = 0;  i < sizeof(GLFWNameKeys) / sizeof(GLFWNameKeys[0]);  i++)\n    {\n        id name = [infoDictionary objectForKey:GLFWNameKeys[i]];\n        if (name &&\n            [name isKindOfClass:[NSString class]] &&\n            ![name isEqualToString:@\"\"])\n        {\n            return name;\n        }\n    }\n\n    char** progname = _NSGetProgname();\n    if (progname && *progname)\n        return [NSString stringWithUTF8String:*progname];\n\n    // Really shouldn't get here\n    return @\"GLFW Application\";\n}\n\n// Set up the menu bar (manually)\n// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that\n// could go away at any moment, lots of stuff that really should be\n// localize(d|able), etc.  Loading a nib would save us this horror, but that\n// doesn't seem like a good thing to require of GLFW users.\n//\nstatic void createMenuBar(void)\n{\n    NSString* appName = findAppName();\n\n    NSMenu* bar = [[NSMenu alloc] init];\n    [NSApp setMainMenu:bar];\n\n    NSMenuItem* appMenuItem =\n        [bar addItemWithTitle:@\"\" action:NULL keyEquivalent:@\"\"];\n    NSMenu* appMenu = [[NSMenu alloc] init];\n    [appMenuItem setSubmenu:appMenu];\n\n    [appMenu addItemWithTitle:[NSString stringWithFormat:@\"About %@\", appName]\n                       action:@selector(orderFrontStandardAboutPanel:)\n                keyEquivalent:@\"\"];\n    [appMenu addItem:[NSMenuItem separatorItem]];\n    NSMenu* servicesMenu = [[NSMenu alloc] init];\n    [NSApp setServicesMenu:servicesMenu];\n    [[appMenu addItemWithTitle:@\"Services\"\n                       action:NULL\n                keyEquivalent:@\"\"] setSubmenu:servicesMenu];\n    [servicesMenu release];\n    [appMenu addItem:[NSMenuItem separatorItem]];\n    [appMenu addItemWithTitle:[NSString stringWithFormat:@\"Hide %@\", appName]\n                       action:@selector(hide:)\n                keyEquivalent:@\"h\"];\n    [[appMenu addItemWithTitle:@\"Hide Others\"\n                       action:@selector(hideOtherApplications:)\n                keyEquivalent:@\"h\"]\n        setKeyEquivalentModifierMask:NSAlternateKeyMask | NSCommandKeyMask];\n    [appMenu addItemWithTitle:@\"Show All\"\n                       action:@selector(unhideAllApplications:)\n                keyEquivalent:@\"\"];\n    [appMenu addItem:[NSMenuItem separatorItem]];\n    [appMenu addItemWithTitle:[NSString stringWithFormat:@\"Quit %@\", appName]\n                       action:@selector(terminate:)\n                keyEquivalent:@\"q\"];\n\n    NSMenuItem* windowMenuItem =\n        [bar addItemWithTitle:@\"\" action:NULL keyEquivalent:@\"\"];\n    [bar release];\n    NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@\"Window\"];\n    [NSApp setWindowsMenu:windowMenu];\n    [windowMenuItem setSubmenu:windowMenu];\n\n    [windowMenu addItemWithTitle:@\"Minimize\"\n                          action:@selector(performMiniaturize:)\n                   keyEquivalent:@\"m\"];\n    [windowMenu addItemWithTitle:@\"Zoom\"\n                          action:@selector(performZoom:)\n                   keyEquivalent:@\"\"];\n    [windowMenu addItem:[NSMenuItem separatorItem]];\n    [windowMenu addItemWithTitle:@\"Bring All to Front\"\n                          action:@selector(arrangeInFront:)\n                   keyEquivalent:@\"\"];\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n    {\n        // TODO: Make this appear at the bottom of the menu (for consistency)\n\n        [windowMenu addItem:[NSMenuItem separatorItem]];\n        [[windowMenu addItemWithTitle:@\"Enter Full Screen\"\n                               action:@selector(toggleFullScreen:)\n                        keyEquivalent:@\"f\"]\n            setKeyEquivalentModifierMask:NSControlKeyMask | NSCommandKeyMask];\n    }\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n    // Prior to Snow Leopard, we need to use this oddly-named semi-private API\n    // to get the application menu working properly.\n    SEL setAppleMenuSelector = NSSelectorFromString(@\"setAppleMenu:\");\n    [NSApp performSelector:setAppleMenuSelector withObject:appMenu];\n}\n\n#endif /* _GLFW_USE_MENUBAR */\n\n// Initialize the Cocoa Application Kit\n//\nstatic GLboolean initializeAppKit(void)\n{\n    if (NSApp)\n        return GL_TRUE;\n\n    // Implicitly create shared NSApplication instance\n    [GLFWApplication sharedApplication];\n\n    // In case we are unbundled, make us a proper UI application\n    [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];\n\n#if defined(_GLFW_USE_MENUBAR)\n    // Menu bar setup must go between sharedApplication above and\n    // finishLaunching below, in order to properly emulate the behavior\n    // of NSApplicationMain\n    createMenuBar();\n#endif\n\n    // There can only be one application delegate, but we allocate it the\n    // first time a window is created to keep all window code in this file\n    _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];\n    if (_glfw.ns.delegate == nil)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Failed to create application delegate\");\n        return GL_FALSE;\n    }\n\n    [NSApp setDelegate:_glfw.ns.delegate];\n    [NSApp run];\n\n    return GL_TRUE;\n}\n\n// Create the Cocoa window\n//\nstatic GLboolean createWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig)\n{\n    window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];\n    if (window->ns.delegate == nil)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Failed to create window delegate\");\n        return GL_FALSE;\n    }\n\n    unsigned int styleMask = 0;\n\n    if (wndconfig->monitor || !wndconfig->decorated)\n        styleMask = NSBorderlessWindowMask;\n    else\n    {\n        styleMask = NSTitledWindowMask | NSClosableWindowMask |\n                    NSMiniaturizableWindowMask;\n\n        if (wndconfig->resizable)\n            styleMask |= NSResizableWindowMask;\n    }\n\n    NSRect contentRect;\n\n    if (wndconfig->monitor)\n    {\n        GLFWvidmode mode;\n        int xpos, ypos;\n\n        _glfwPlatformGetVideoMode(window->monitor, &mode);\n        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);\n\n        contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);\n    }\n    else\n        contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);\n\n    window->ns.object = [[GLFWWindow alloc]\n        initWithContentRect:contentRect\n                  styleMask:styleMask\n                    backing:NSBackingStoreBuffered\n                      defer:NO];\n\n    if (window->ns.object == nil)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Cocoa: Failed to create window\");\n        return GL_FALSE;\n    }\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n    {\n        if (wndconfig->resizable)\n            [window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];\n    }\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n    if (wndconfig->monitor)\n    {\n        [window->ns.object setLevel:NSMainMenuWindowLevel + 1];\n    }\n    else\n    {\n        [window->ns.object center];\n\n        if (wndconfig->floating)\n            [window->ns.object setLevel:NSFloatingWindowLevel];\n    }\n\n    window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];\n\n#if defined(_GLFW_USE_RETINA)\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n        [window->ns.view setWantsBestResolutionOpenGLSurface:YES];\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n#endif /*_GLFW_USE_RETINA*/\n\n    [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];\n    [window->ns.object setDelegate:window->ns.delegate];\n    [window->ns.object setAcceptsMouseMovedEvents:YES];\n    [window->ns.object setContentView:window->ns.view];\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)\n        [window->ns.object setRestorable:NO];\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n    return GL_TRUE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig)\n{\n    if (!initializeAppKit())\n        return GL_FALSE;\n\n    if (!createWindow(window, wndconfig))\n        return GL_FALSE;\n\n    if (!_glfwCreateContext(window, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    [window->nsgl.context setView:window->ns.view];\n\n    if (wndconfig->monitor)\n    {\n        _glfwPlatformShowWindow(window);\n        if (!enterFullscreenMode(window))\n            return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window)\n{\n    [window->ns.object orderOut:nil];\n\n    if (window->monitor)\n        leaveFullscreenMode(window);\n\n    _glfwDestroyContext(window);\n\n    [window->ns.object setDelegate:nil];\n    [window->ns.delegate release];\n    window->ns.delegate = nil;\n\n    [window->ns.view release];\n    window->ns.view = nil;\n\n    [window->ns.object close];\n    window->ns.object = nil;\n}\n\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)\n{\n    [window->ns.object setTitle:[NSString stringWithUTF8String:title]];\n}\n\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)\n{\n    const NSRect contentRect =\n        [window->ns.object contentRectForFrameRect:[window->ns.object frame]];\n\n    if (xpos)\n        *xpos = contentRect.origin.x;\n    if (ypos)\n        *ypos = transformY(contentRect.origin.y + contentRect.size.height);\n}\n\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)\n{\n    const NSRect contentRect = [window->ns.view frame];\n    const NSRect dummyRect = NSMakeRect(x, transformY(y + contentRect.size.height), 0, 0);\n    const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];\n    [window->ns.object setFrameOrigin:frameRect.origin];\n}\n\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)\n{\n    const NSRect contentRect = [window->ns.view frame];\n\n    if (width)\n        *width = contentRect.size.width;\n    if (height)\n        *height = contentRect.size.height;\n}\n\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)\n{\n    if (window->monitor)\n        enterFullscreenMode(window);\n    else\n        [window->ns.object setContentSize:NSMakeSize(width, height)];\n}\n\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)\n{\n    const NSRect contentRect = [window->ns.view frame];\n    const NSRect fbRect = convertRectToBacking(window, contentRect);\n\n    if (width)\n        *width = (int) fbRect.size.width;\n    if (height)\n        *height = (int) fbRect.size.height;\n}\n\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,\n                                     int* left, int* top,\n                                     int* right, int* bottom)\n{\n    const NSRect contentRect = [window->ns.view frame];\n    const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];\n\n    if (left)\n        *left = contentRect.origin.x - frameRect.origin.x;\n    if (top)\n        *top = frameRect.origin.y + frameRect.size.height -\n               contentRect.origin.y - contentRect.size.height;\n    if (right)\n        *right = frameRect.origin.x + frameRect.size.width -\n                 contentRect.origin.x - contentRect.size.width;\n    if (bottom)\n        *bottom = contentRect.origin.y - frameRect.origin.y;\n}\n\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window)\n{\n    [window->ns.object miniaturize:nil];\n}\n\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window)\n{\n    [window->ns.object deminiaturize:nil];\n}\n\nvoid _glfwPlatformShowWindow(_GLFWwindow* window)\n{\n    // Make us the active application\n    // HACK: This has been moved here from initializeAppKit to prevent\n    //       applications using only hidden windows from being activated, but\n    //       should probably not be done every time any window is shown\n    [NSApp activateIgnoringOtherApps:YES];\n\n    [window->ns.object makeKeyAndOrderFront:nil];\n}\n\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window)\n{\n    [window->ns.object orderFront:nil];\n}\n\nvoid _glfwPlatformHideWindow(_GLFWwindow* window)\n{\n    [window->ns.object orderOut:nil];\n}\n\nint _glfwPlatformWindowFocused(_GLFWwindow* window)\n{\n    return [window->ns.object isKeyWindow];\n}\n\nint _glfwPlatformWindowIconified(_GLFWwindow* window)\n{\n    return [window->ns.object isMiniaturized];\n}\n\nint _glfwPlatformWindowVisible(_GLFWwindow* window)\n{\n    return [window->ns.object isVisible];\n}\n\nvoid _glfwPlatformPollEvents(void)\n{\n    for (;;)\n    {\n        NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask\n                                            untilDate:[NSDate distantPast]\n                                               inMode:NSDefaultRunLoopMode\n                                              dequeue:YES];\n        if (event == nil)\n            break;\n\n        [NSApp sendEvent:event];\n    }\n\n    [_glfw.ns.autoreleasePool drain];\n    _glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];\n}\n\nvoid _glfwPlatformWaitEvents(void)\n{\n    // I wanted to pass NO to dequeue:, and rely on PollEvents to\n    // dequeue and send.  For reasons not at all clear to me, passing\n    // NO to dequeue: causes this method never to return.\n    NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask\n                                        untilDate:[NSDate distantFuture]\n                                           inMode:NSDefaultRunLoopMode\n                                          dequeue:YES];\n    [NSApp sendEvent:event];\n\n    _glfwPlatformPollEvents();\n}\n\nvoid _glfwPlatformPostEmptyEvent(void)\n{\n    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];\n    NSEvent* event = [NSEvent otherEventWithType:NSApplicationDefined\n                                        location:NSMakePoint(0, 0)\n                                   modifierFlags:0\n                                       timestamp:0\n                                    windowNumber:0\n                                         context:nil\n                                         subtype:0\n                                           data1:0\n                                           data2:0];\n    [NSApp postEvent:event atStart:YES];\n    [pool drain];\n}\n\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)\n{\n    const NSRect contentRect = [window->ns.view frame];\n    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];\n\n    if (xpos)\n        *xpos = pos.x;\n    if (ypos)\n        *ypos = contentRect.size.height - pos.y - 1;\n}\n\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)\n{\n    updateModeCursor(window);\n\n    const NSRect contentRect = [window->ns.view frame];\n    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];\n\n    window->ns.warpDeltaX += x - pos.x;\n    window->ns.warpDeltaY += y - contentRect.size.height + pos.y;\n\n    if (window->monitor)\n    {\n        CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,\n                                   CGPointMake(x, y));\n    }\n    else\n    {\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n        const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);\n        const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];\n        const NSPoint globalPoint = globalRect.origin;\n#else\n        const NSPoint localPoint = NSMakePoint(x, contentRect.size.height - y - 1);\n        const NSPoint globalPoint = [window->ns.object convertBaseToScreen:localPoint];\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n        CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,\n                                              transformY(globalPoint.y)));\n    }\n}\n\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window)\n{\n    updateModeCursor(window);\n\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n        CGAssociateMouseAndMouseCursorPosition(false);\n    else\n        CGAssociateMouseAndMouseCursorPosition(true);\n}\n\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor,\n                              const GLFWimage* image,\n                              int xhot, int yhot)\n{\n    NSImage* native;\n    NSBitmapImageRep* rep;\n\n    if (!initializeAppKit())\n        return GL_FALSE;\n\n    rep = [[NSBitmapImageRep alloc]\n        initWithBitmapDataPlanes:NULL\n                      pixelsWide:image->width\n                      pixelsHigh:image->height\n                   bitsPerSample:8\n                 samplesPerPixel:4\n                        hasAlpha:YES\n                        isPlanar:NO\n                  colorSpaceName:NSCalibratedRGBColorSpace\n                    bitmapFormat:NSAlphaNonpremultipliedBitmapFormat\n                     bytesPerRow:image->width * 4\n                    bitsPerPixel:32];\n\n    if (rep == nil)\n        return GL_FALSE;\n\n    memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);\n\n    native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];\n    [native addRepresentation: rep];\n\n    cursor->ns.object = [[NSCursor alloc] initWithImage:native\n                                                hotSpot:NSMakePoint(xhot, yhot)];\n\n    [native release];\n    [rep release];\n\n    if (cursor->ns.object == nil)\n        return GL_FALSE;\n\n    return GL_TRUE;\n}\n\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)\n{\n    if (!initializeAppKit())\n        return GL_FALSE;\n\n    cursor->ns.object = getStandardCursor(shape);\n    if (!cursor->ns.object)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Failed to retrieve standard cursor\");\n        return GL_FALSE;\n    }\n\n    [cursor->ns.object retain];\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor)\n{\n    if (cursor->ns.object)\n        [(NSCursor*) cursor->ns.object release];\n}\n\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)\n{\n    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];\n\n    if (window->cursorMode == GLFW_CURSOR_NORMAL &&\n        [window->ns.view mouse:pos inRect:[window->ns.view frame]])\n    {\n        if (cursor)\n            [(NSCursor*) cursor->ns.object set];\n        else\n            [[NSCursor arrowCursor] set];\n    }\n}\n\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)\n{\n    NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];\n\n    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];\n    [pasteboard declareTypes:types owner:nil];\n    [pasteboard setString:[NSString stringWithUTF8String:string]\n                  forType:NSStringPboardType];\n}\n\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window)\n{\n    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];\n\n    if (![[pasteboard types] containsObject:NSStringPboardType])\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"Cocoa: Failed to retrieve string from pasteboard\");\n        return NULL;\n    }\n\n    NSString* object = [pasteboard stringForType:NSStringPboardType];\n    if (!object)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Cocoa: Failed to retrieve object from pasteboard\");\n        return NULL;\n    }\n\n    free(_glfw.ns.clipboardString);\n    _glfw.ns.clipboardString = strdup([object UTF8String]);\n\n    return _glfw.ns.clipboardString;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(nil);\n    return window->ns.object;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/context.c",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdio.h>\n#include <string.h>\n#include <limits.h>\n#include <stdio.h>\n\n\n// Parses the client API version string and extracts the version number\n//\nstatic GLboolean parseVersionString(int* api, int* major, int* minor, int* rev)\n{\n    int i;\n    _GLFWwindow* window;\n    const char* version;\n    const char* prefixes[] =\n    {\n        \"OpenGL ES-CM \",\n        \"OpenGL ES-CL \",\n        \"OpenGL ES \",\n        NULL\n    };\n\n    *api = GLFW_OPENGL_API;\n\n    window = _glfwPlatformGetCurrentContext();\n\n    version = (const char*) window->GetString(GL_VERSION);\n    if (!version)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Failed to retrieve context version string\");\n        return GL_FALSE;\n    }\n\n    for (i = 0;  prefixes[i];  i++)\n    {\n        const size_t length = strlen(prefixes[i]);\n\n        if (strncmp(version, prefixes[i], length) == 0)\n        {\n            version += length;\n            *api = GLFW_OPENGL_ES_API;\n            break;\n        }\n    }\n\n    if (!sscanf(version, \"%d.%d.%d\", major, minor, rev))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"No version found in context version string\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nGLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)\n{\n    if (ctxconfig->api != GLFW_OPENGL_API &&\n        ctxconfig->api != GLFW_OPENGL_ES_API)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid client API\");\n        return GL_FALSE;\n    }\n\n    if (ctxconfig->api == GLFW_OPENGL_API)\n    {\n        if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||\n            (ctxconfig->major == 1 && ctxconfig->minor > 5) ||\n            (ctxconfig->major == 2 && ctxconfig->minor > 1) ||\n            (ctxconfig->major == 3 && ctxconfig->minor > 3))\n        {\n            // OpenGL 1.0 is the smallest valid version\n            // OpenGL 1.x series ended with version 1.5\n            // OpenGL 2.x series ended with version 2.1\n            // OpenGL 3.x series ended with version 3.3\n            // For now, let everything else through\n\n            _glfwInputError(GLFW_INVALID_VALUE,\n                            \"Invalid OpenGL version %i.%i\",\n                            ctxconfig->major, ctxconfig->minor);\n            return GL_FALSE;\n        }\n\n        if (ctxconfig->profile)\n        {\n            if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&\n                ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)\n            {\n                _glfwInputError(GLFW_INVALID_ENUM,\n                                \"Invalid OpenGL profile\");\n                return GL_FALSE;\n            }\n\n            if (ctxconfig->major < 3 ||\n                (ctxconfig->major == 3 && ctxconfig->minor < 2))\n            {\n                // Desktop OpenGL context profiles are only defined for version 3.2\n                // and above\n\n                _glfwInputError(GLFW_INVALID_VALUE,\n                                \"Context profiles are only defined for OpenGL version 3.2 and above\");\n                return GL_FALSE;\n            }\n        }\n\n        if (ctxconfig->forward && ctxconfig->major < 3)\n        {\n            // Forward-compatible contexts are only defined for OpenGL version 3.0 and above\n            _glfwInputError(GLFW_INVALID_VALUE,\n                            \"Forward-compatibility is only defined for OpenGL version 3.0 and above\");\n            return GL_FALSE;\n        }\n    }\n    else if (ctxconfig->api == GLFW_OPENGL_ES_API)\n    {\n        if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||\n            (ctxconfig->major == 1 && ctxconfig->minor > 1) ||\n            (ctxconfig->major == 2 && ctxconfig->minor > 0))\n        {\n            // OpenGL ES 1.0 is the smallest valid version\n            // OpenGL ES 1.x series ended with version 1.1\n            // OpenGL ES 2.x series ended with version 2.0\n            // For now, let everything else through\n\n            _glfwInputError(GLFW_INVALID_VALUE,\n                            \"Invalid OpenGL ES version %i.%i\",\n                            ctxconfig->major, ctxconfig->minor);\n            return GL_FALSE;\n        }\n    }\n\n    if (ctxconfig->robustness)\n    {\n        if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&\n            ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)\n        {\n            _glfwInputError(GLFW_INVALID_ENUM,\n                            \"Invalid context robustness mode\");\n            return GL_FALSE;\n        }\n    }\n\n    if (ctxconfig->release)\n    {\n        if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&\n            ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)\n        {\n            _glfwInputError(GLFW_INVALID_ENUM,\n                            \"Invalid context release behavior\");\n            return GL_FALSE;\n        }\n    }\n\n    return GL_TRUE;\n}\n\nconst _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,\n                                         const _GLFWfbconfig* alternatives,\n                                         unsigned int count)\n{\n    unsigned int i;\n    unsigned int missing, leastMissing = UINT_MAX;\n    unsigned int colorDiff, leastColorDiff = UINT_MAX;\n    unsigned int extraDiff, leastExtraDiff = UINT_MAX;\n    const _GLFWfbconfig* current;\n    const _GLFWfbconfig* closest = NULL;\n\n    for (i = 0;  i < count;  i++)\n    {\n        current = alternatives + i;\n\n        if (desired->stereo > 0 && current->stereo == 0)\n        {\n            // Stereo is a hard constraint\n            continue;\n        }\n\n        if (desired->doublebuffer != current->doublebuffer)\n        {\n            // Double buffering is a hard constraint\n            continue;\n        }\n\n        // Count number of missing buffers\n        {\n            missing = 0;\n\n            if (desired->alphaBits > 0 && current->alphaBits == 0)\n                missing++;\n\n            if (desired->depthBits > 0 && current->depthBits == 0)\n                missing++;\n\n            if (desired->stencilBits > 0 && current->stencilBits == 0)\n                missing++;\n\n            if (desired->auxBuffers > 0 &&\n                current->auxBuffers < desired->auxBuffers)\n            {\n                missing += desired->auxBuffers - current->auxBuffers;\n            }\n\n            if (desired->samples > 0 && current->samples == 0)\n            {\n                // Technically, several multisampling buffers could be\n                // involved, but that's a lower level implementation detail and\n                // not important to us here, so we count them as one\n                missing++;\n            }\n        }\n\n        // These polynomials make many small channel size differences matter\n        // less than one large channel size difference\n\n        // Calculate color channel size difference value\n        {\n            colorDiff = 0;\n\n            if (desired->redBits != GLFW_DONT_CARE)\n            {\n                colorDiff += (desired->redBits - current->redBits) *\n                             (desired->redBits - current->redBits);\n            }\n\n            if (desired->greenBits != GLFW_DONT_CARE)\n            {\n                colorDiff += (desired->greenBits - current->greenBits) *\n                             (desired->greenBits - current->greenBits);\n            }\n\n            if (desired->blueBits != GLFW_DONT_CARE)\n            {\n                colorDiff += (desired->blueBits - current->blueBits) *\n                             (desired->blueBits - current->blueBits);\n            }\n        }\n\n        // Calculate non-color channel size difference value\n        {\n            extraDiff = 0;\n\n            if (desired->alphaBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->alphaBits - current->alphaBits) *\n                             (desired->alphaBits - current->alphaBits);\n            }\n\n            if (desired->depthBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->depthBits - current->depthBits) *\n                             (desired->depthBits - current->depthBits);\n            }\n\n            if (desired->stencilBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->stencilBits - current->stencilBits) *\n                             (desired->stencilBits - current->stencilBits);\n            }\n\n            if (desired->accumRedBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->accumRedBits - current->accumRedBits) *\n                             (desired->accumRedBits - current->accumRedBits);\n            }\n\n            if (desired->accumGreenBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->accumGreenBits - current->accumGreenBits) *\n                             (desired->accumGreenBits - current->accumGreenBits);\n            }\n\n            if (desired->accumBlueBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->accumBlueBits - current->accumBlueBits) *\n                             (desired->accumBlueBits - current->accumBlueBits);\n            }\n\n            if (desired->accumAlphaBits != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *\n                             (desired->accumAlphaBits - current->accumAlphaBits);\n            }\n\n            if (desired->samples != GLFW_DONT_CARE)\n            {\n                extraDiff += (desired->samples - current->samples) *\n                             (desired->samples - current->samples);\n            }\n\n            if (desired->sRGB && !current->sRGB)\n                extraDiff++;\n        }\n\n        // Figure out if the current one is better than the best one found so far\n        // Least number of missing buffers is the most important heuristic,\n        // then color buffer size match and lastly size match for other buffers\n\n        if (missing < leastMissing)\n            closest = current;\n        else if (missing == leastMissing)\n        {\n            if ((colorDiff < leastColorDiff) ||\n                (colorDiff == leastColorDiff && extraDiff < leastExtraDiff))\n            {\n                closest = current;\n            }\n        }\n\n        if (current == closest)\n        {\n            leastMissing = missing;\n            leastColorDiff = colorDiff;\n            leastExtraDiff = extraDiff;\n        }\n    }\n\n    return closest;\n}\n\nGLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    window->GetIntegerv = (PFNGLGETINTEGERVPROC) glfwGetProcAddress(\"glGetIntegerv\");\n    window->GetString = (PFNGLGETSTRINGPROC) glfwGetProcAddress(\"glGetString\");\n    window->Clear = (PFNGLCLEARPROC) glfwGetProcAddress(\"glClear\");\n\n    if (!parseVersionString(&window->context.api,\n                            &window->context.major,\n                            &window->context.minor,\n                            &window->context.revision))\n    {\n        return GL_FALSE;\n    }\n\n#if defined(_GLFW_USE_OPENGL)\n    if (window->context.major > 2)\n    {\n        // OpenGL 3.0+ uses a different function for extension string retrieval\n        // We cache it here instead of in glfwExtensionSupported mostly to alert\n        // users as early as possible that their build may be broken\n\n        window->GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress(\"glGetStringi\");\n        if (!window->GetStringi)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"Entry point retrieval is broken\");\n            return GL_FALSE;\n        }\n    }\n\n    if (window->context.api == GLFW_OPENGL_API)\n    {\n        // Read back context flags (OpenGL 3.0 and above)\n        if (window->context.major >= 3)\n        {\n            GLint flags;\n            window->GetIntegerv(GL_CONTEXT_FLAGS, &flags);\n\n            if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)\n                window->context.forward = GL_TRUE;\n\n            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)\n                window->context.debug = GL_TRUE;\n            else if (glfwExtensionSupported(\"GL_ARB_debug_output\") &&\n                     ctxconfig->debug)\n            {\n                // HACK: This is a workaround for older drivers (pre KHR_debug)\n                //       not setting the debug bit in the context flags for\n                //       debug contexts\n                window->context.debug = GL_TRUE;\n            }\n        }\n\n        // Read back OpenGL context profile (OpenGL 3.2 and above)\n        if (window->context.major > 3 ||\n            (window->context.major == 3 && window->context.minor >= 2))\n        {\n            GLint mask;\n            window->GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);\n\n            if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)\n                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;\n            else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)\n                window->context.profile = GLFW_OPENGL_CORE_PROFILE;\n            else if (glfwExtensionSupported(\"GL_ARB_compatibility\"))\n            {\n                // HACK: This is a workaround for the compatibility profile bit\n                //       not being set in the context flags if an OpenGL 3.2+\n                //       context was created without having requested a specific\n                //       version\n                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;\n            }\n        }\n\n        // Read back robustness strategy\n        if (glfwExtensionSupported(\"GL_ARB_robustness\"))\n        {\n            // NOTE: We avoid using the context flags for detection, as they are\n            //       only present from 3.0 while the extension applies from 1.1\n\n            GLint strategy;\n            window->GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);\n\n            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)\n                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;\n            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)\n                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;\n        }\n    }\n    else\n    {\n        // Read back robustness strategy\n        if (glfwExtensionSupported(\"GL_EXT_robustness\"))\n        {\n            // NOTE: The values of these constants match those of the OpenGL ARB\n            //       one, so we can reuse them here\n\n            GLint strategy;\n            window->GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);\n\n            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)\n                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;\n            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)\n                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;\n        }\n    }\n\n    if (glfwExtensionSupported(\"GL_KHR_context_flush_control\"))\n    {\n        GLint behavior;\n        window->GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);\n\n        if (behavior == GL_NONE)\n            window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;\n        else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)\n            window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;\n    }\n#endif // _GLFW_USE_OPENGL\n\n    return GL_TRUE;\n}\n\nGLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    if (window->context.major < ctxconfig->major ||\n        (window->context.major == ctxconfig->major &&\n         window->context.minor < ctxconfig->minor))\n    {\n        // The desired OpenGL version is greater than the actual version\n        // This only happens if the machine lacks {GLX|WGL}_ARB_create_context\n        // /and/ the user has requested an OpenGL version greater than 1.0\n\n        // For API consistency, we emulate the behavior of the\n        // {GLX|WGL}_ARB_create_context extension and fail here\n\n        _glfwInputError(GLFW_VERSION_UNAVAILABLE, NULL);\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nint _glfwStringInExtensionString(const char* string, const char* extensions)\n{\n    const char* start = extensions;\n\n    for (;;)\n    {\n        const char* where;\n        const char* terminator;\n\n        where = strstr(start, string);\n        if (!where)\n            return GL_FALSE;\n\n        terminator = where + strlen(string);\n        if (where == start || *(where - 1) == ' ')\n        {\n            if (*terminator == ' ' || *terminator == '\\0')\n                break;\n        }\n\n        start = terminator;\n    }\n\n    return GL_TRUE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW public API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformMakeContextCurrent(window);\n}\n\nGLFWAPI GLFWwindow* glfwGetCurrentContext(void)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return (GLFWwindow*) _glfwPlatformGetCurrentContext();\n}\n\nGLFWAPI void glfwSwapBuffers(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformSwapBuffers(window);\n}\n\nGLFWAPI void glfwSwapInterval(int interval)\n{\n    _GLFW_REQUIRE_INIT();\n\n    if (!_glfwPlatformGetCurrentContext())\n    {\n        _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL);\n        return;\n    }\n\n    _glfwPlatformSwapInterval(interval);\n}\n\nGLFWAPI int glfwExtensionSupported(const char* extension)\n{\n    _GLFWwindow* window;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(GL_FALSE);\n\n    window = _glfwPlatformGetCurrentContext();\n    if (!window)\n    {\n        _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL);\n        return GL_FALSE;\n    }\n\n    if (*extension == '\\0')\n    {\n        _glfwInputError(GLFW_INVALID_VALUE, NULL);\n        return GL_FALSE;\n    }\n\n#if defined(_GLFW_USE_OPENGL)\n    if (window->context.major >= 3)\n    {\n        int i;\n        GLint count;\n\n        // Check if extension is in the modern OpenGL extensions string list\n\n        window->GetIntegerv(GL_NUM_EXTENSIONS, &count);\n\n        for (i = 0;  i < count;  i++)\n        {\n            const char* en = (const char*) window->GetStringi(GL_EXTENSIONS, i);\n            if (!en)\n            {\n                _glfwInputError(GLFW_PLATFORM_ERROR,\n                                \"Failed to retrieve extension string %i\", i);\n                return GL_FALSE;\n            }\n\n            if (strcmp(en, extension) == 0)\n                return GL_TRUE;\n        }\n    }\n    else\n#endif // _GLFW_USE_OPENGL\n    {\n        // Check if extension is in the old style OpenGL extensions string\n\n        const char* extensions = (const char*) window->GetString(GL_EXTENSIONS);\n        if (!extensions)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"Failed to retrieve extension string\");\n            return GL_FALSE;\n        }\n\n        if (_glfwStringInExtensionString(extension, extensions))\n            return GL_TRUE;\n    }\n\n    // Check if extension is in the platform-specific string\n    return _glfwPlatformExtensionSupported(extension);\n}\n\nGLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (!_glfwPlatformGetCurrentContext())\n    {\n        _glfwInputError(GLFW_NO_CURRENT_CONTEXT, NULL);\n        return NULL;\n    }\n\n    return _glfwPlatformGetProcAddress(procname);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/egl_context.c",
    "content": "//========================================================================\n// GLFW 3.1 EGL - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n\n\n// Return a description of the specified EGL error\n//\nstatic const char* getErrorString(EGLint error)\n{\n    switch (error)\n    {\n        case EGL_SUCCESS:\n            return \"Success\";\n        case EGL_NOT_INITIALIZED:\n            return \"EGL is not or could not be initialized\";\n        case EGL_BAD_ACCESS:\n            return \"EGL cannot access a requested resource\";\n        case EGL_BAD_ALLOC:\n            return \"EGL failed to allocate resources for the requested operation\";\n        case EGL_BAD_ATTRIBUTE:\n            return \"An unrecognized attribute or attribute value was passed in the attribute list\";\n        case EGL_BAD_CONTEXT:\n            return \"An EGLContext argument does not name a valid EGL rendering context\";\n        case EGL_BAD_CONFIG:\n            return \"An EGLConfig argument does not name a valid EGL frame buffer configuration\";\n        case EGL_BAD_CURRENT_SURFACE:\n            return \"The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid\";\n        case EGL_BAD_DISPLAY:\n            return \"An EGLDisplay argument does not name a valid EGL display connection\";\n        case EGL_BAD_SURFACE:\n            return \"An EGLSurface argument does not name a valid surface configured for GL rendering\";\n        case EGL_BAD_MATCH:\n            return \"Arguments are inconsistent\";\n        case EGL_BAD_PARAMETER:\n            return \"One or more argument values are invalid\";\n        case EGL_BAD_NATIVE_PIXMAP:\n            return \"A NativePixmapType argument does not refer to a valid native pixmap\";\n        case EGL_BAD_NATIVE_WINDOW:\n            return \"A NativeWindowType argument does not refer to a valid native window\";\n        case EGL_CONTEXT_LOST:\n            return \"The application must destroy all contexts and reinitialise\";\n    }\n\n    return \"UNKNOWN EGL ERROR\";\n}\n\n// Returns the specified attribute of the specified EGLConfig\n//\nstatic int getConfigAttrib(EGLConfig config, int attrib)\n{\n    int value;\n    _glfw_eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);\n    return value;\n}\n\n// Return a list of available and usable framebuffer configs\n//\nstatic GLboolean chooseFBConfigs(const _GLFWctxconfig* ctxconfig,\n                                 const _GLFWfbconfig* desired,\n                                 EGLConfig* result)\n{\n    EGLConfig* nativeConfigs;\n    _GLFWfbconfig* usableConfigs;\n    const _GLFWfbconfig* closest;\n    int i, nativeCount, usableCount;\n\n    _glfw_eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);\n    if (!nativeCount)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE, \"EGL: No EGLConfigs returned\");\n        return GL_FALSE;\n    }\n\n    nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));\n    _glfw_eglGetConfigs(_glfw.egl.display, nativeConfigs,\n                        nativeCount, &nativeCount);\n\n    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));\n    usableCount = 0;\n\n    for (i = 0;  i < nativeCount;  i++)\n    {\n        const EGLConfig n = nativeConfigs[i];\n        _GLFWfbconfig* u = usableConfigs + usableCount;\n\n#if defined(_GLFW_X11)\n        // Only consider EGLConfigs with associated visuals\n        if (!getConfigAttrib(n, EGL_NATIVE_VISUAL_ID))\n            continue;\n#endif // _GLFW_X11\n\n        // Only consider RGB(A) EGLConfigs\n        if (!(getConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) & EGL_RGB_BUFFER))\n            continue;\n\n        // Only consider window EGLConfigs\n        if (!(getConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))\n            continue;\n\n        if (ctxconfig->api == GLFW_OPENGL_ES_API)\n        {\n            if (ctxconfig->major == 1)\n            {\n                if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))\n                    continue;\n            }\n            else\n            {\n                if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))\n                    continue;\n            }\n        }\n        else if (ctxconfig->api == GLFW_OPENGL_API)\n        {\n            if (!(getConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))\n                continue;\n        }\n\n        u->redBits = getConfigAttrib(n, EGL_RED_SIZE);\n        u->greenBits = getConfigAttrib(n, EGL_GREEN_SIZE);\n        u->blueBits = getConfigAttrib(n, EGL_BLUE_SIZE);\n\n        u->alphaBits = getConfigAttrib(n, EGL_ALPHA_SIZE);\n        u->depthBits = getConfigAttrib(n, EGL_DEPTH_SIZE);\n        u->stencilBits = getConfigAttrib(n, EGL_STENCIL_SIZE);\n\n        u->samples = getConfigAttrib(n, EGL_SAMPLES);\n        u->doublebuffer = GL_TRUE;\n\n        u->egl = n;\n        usableCount++;\n    }\n\n    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);\n    if (closest)\n        *result = closest->egl;\n\n    free(nativeConfigs);\n    free(usableConfigs);\n\n    return closest ? GL_TRUE : GL_FALSE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize EGL\n//\nint _glfwInitContextAPI(void)\n{\n    int i;\n    const char* sonames[] =\n    {\n#if defined(_GLFW_WIN32)\n        \"libEGL.dll\",\n        \"EGL.dll\",\n#elif defined(_GLFW_COCOA)\n        \"libEGL.dylib\",\n#else\n        \"libEGL.so.1\",\n#endif\n        NULL\n    };\n\n    if (!_glfwCreateContextTLS())\n        return GL_FALSE;\n\n    for (i = 0;  sonames[i];  i++)\n    {\n        _glfw.egl.handle = _glfw_dlopen(sonames[i]);\n        if (_glfw.egl.handle)\n            break;\n    }\n\n    if (!_glfw.egl.handle)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE, \"EGL: Failed to load EGL\");\n        return GL_FALSE;\n    }\n\n    _glfw.egl.GetConfigAttrib =\n        _glfw_dlsym(_glfw.egl.handle, \"eglGetConfigAttrib\");\n    _glfw.egl.GetConfigs =\n        _glfw_dlsym(_glfw.egl.handle, \"eglGetConfigs\");\n    _glfw.egl.GetDisplay =\n        _glfw_dlsym(_glfw.egl.handle, \"eglGetDisplay\");\n    _glfw.egl.GetError =\n        _glfw_dlsym(_glfw.egl.handle, \"eglGetError\");\n    _glfw.egl.Initialize =\n        _glfw_dlsym(_glfw.egl.handle, \"eglInitialize\");\n    _glfw.egl.Terminate =\n        _glfw_dlsym(_glfw.egl.handle, \"eglTerminate\");\n    _glfw.egl.BindAPI =\n        _glfw_dlsym(_glfw.egl.handle, \"eglBindAPI\");\n    _glfw.egl.CreateContext =\n        _glfw_dlsym(_glfw.egl.handle, \"eglCreateContext\");\n    _glfw.egl.DestroySurface =\n        _glfw_dlsym(_glfw.egl.handle, \"eglDestroySurface\");\n    _glfw.egl.DestroyContext =\n        _glfw_dlsym(_glfw.egl.handle, \"eglDestroyContext\");\n    _glfw.egl.CreateWindowSurface =\n        _glfw_dlsym(_glfw.egl.handle, \"eglCreateWindowSurface\");\n    _glfw.egl.MakeCurrent =\n        _glfw_dlsym(_glfw.egl.handle, \"eglMakeCurrent\");\n    _glfw.egl.SwapBuffers =\n        _glfw_dlsym(_glfw.egl.handle, \"eglSwapBuffers\");\n    _glfw.egl.SwapInterval =\n        _glfw_dlsym(_glfw.egl.handle, \"eglSwapInterval\");\n    _glfw.egl.QueryString =\n        _glfw_dlsym(_glfw.egl.handle, \"eglQueryString\");\n    _glfw.egl.GetProcAddress =\n        _glfw_dlsym(_glfw.egl.handle, \"eglGetProcAddress\");\n\n    _glfw.egl.display =\n        _glfw_eglGetDisplay((EGLNativeDisplayType)_GLFW_EGL_NATIVE_DISPLAY);\n    if (_glfw.egl.display == EGL_NO_DISPLAY)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"EGL: Failed to get EGL display: %s\",\n                        getErrorString(_glfw_eglGetError()));\n        return GL_FALSE;\n    }\n\n    if (!_glfw_eglInitialize(_glfw.egl.display,\n                             &_glfw.egl.major,\n                             &_glfw.egl.minor))\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"EGL: Failed to initialize EGL: %s\",\n                        getErrorString(_glfw_eglGetError()));\n        return GL_FALSE;\n    }\n\n    _glfw.egl.KHR_create_context =\n        _glfwPlatformExtensionSupported(\"EGL_KHR_create_context\");\n\n    return GL_TRUE;\n}\n\n// Terminate EGL\n//\nvoid _glfwTerminateContextAPI(void)\n{\n    if (_glfw_eglTerminate)\n        _glfw_eglTerminate(_glfw.egl.display);\n\n    if (_glfw.egl.handle)\n    {\n        _glfw_dlclose(_glfw.egl.handle);\n        _glfw.egl.handle = NULL;\n    }\n\n    _glfwDestroyContextTLS();\n}\n\n#define setEGLattrib(attribName, attribValue) \\\n{ \\\n    attribs[index++] = attribName; \\\n    attribs[index++] = attribValue; \\\n    assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \\\n}\n\n// Create the OpenGL or OpenGL ES context\n//\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig)\n{\n    int attribs[40];\n    EGLConfig config;\n    EGLContext share = NULL;\n\n    if (ctxconfig->share)\n        share = ctxconfig->share->egl.context;\n\n    if (!chooseFBConfigs(ctxconfig, fbconfig, &config))\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"EGL: Failed to find a suitable EGLConfig\");\n        return GL_FALSE;\n    }\n\n#if defined(_GLFW_X11)\n    // Retrieve the visual corresponding to the chosen EGL config\n    {\n        EGLint count = 0;\n        int mask;\n        EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;\n        XVisualInfo info;\n\n        _glfw_eglGetConfigAttrib(_glfw.egl.display, config,\n                                 EGL_NATIVE_VISUAL_ID, &visualID);\n\n        info.screen = _glfw.x11.screen;\n        mask = VisualScreenMask;\n\n        if (visualID)\n        {\n            // The X window visual must match the EGL config\n            info.visualid = visualID;\n            mask |= VisualIDMask;\n        }\n        else\n        {\n            // Some EGL drivers do not implement the EGL_NATIVE_VISUAL_ID\n            // attribute, so attempt to find the closest match\n\n            _glfw_eglGetConfigAttrib(_glfw.egl.display, config,\n                                     EGL_RED_SIZE, &redBits);\n            _glfw_eglGetConfigAttrib(_glfw.egl.display, config,\n                                     EGL_GREEN_SIZE, &greenBits);\n            _glfw_eglGetConfigAttrib(_glfw.egl.display, config,\n                                     EGL_BLUE_SIZE, &blueBits);\n            _glfw_eglGetConfigAttrib(_glfw.egl.display, config,\n                                     EGL_ALPHA_SIZE, &alphaBits);\n\n            info.depth = redBits + greenBits + blueBits + alphaBits;\n            mask |= VisualDepthMask;\n        }\n\n        window->egl.visual = XGetVisualInfo(_glfw.x11.display,\n                                            mask, &info, &count);\n        if (!window->egl.visual)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"EGL: Failed to retrieve visual for EGLConfig\");\n            return GL_FALSE;\n        }\n    }\n#endif // _GLFW_X11\n\n    if (ctxconfig->api == GLFW_OPENGL_ES_API)\n    {\n        if (!_glfw_eglBindAPI(EGL_OPENGL_ES_API))\n        {\n            _glfwInputError(GLFW_API_UNAVAILABLE,\n                            \"EGL: Failed to bind OpenGL ES: %s\",\n                            getErrorString(_glfw_eglGetError()));\n            return GL_FALSE;\n        }\n    }\n    else\n    {\n        if (!_glfw_eglBindAPI(EGL_OPENGL_API))\n        {\n            _glfwInputError(GLFW_API_UNAVAILABLE,\n                            \"EGL: Failed to bind OpenGL: %s\",\n                            getErrorString(_glfw_eglGetError()));\n            return GL_FALSE;\n        }\n    }\n\n    if (_glfw.egl.KHR_create_context)\n    {\n        int index = 0, mask = 0, flags = 0;\n\n        if (ctxconfig->api == GLFW_OPENGL_API)\n        {\n            if (ctxconfig->forward)\n                flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;\n\n            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)\n                mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;\n            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)\n                mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;\n        }\n\n        if (ctxconfig->debug)\n            flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;\n\n        if (ctxconfig->robustness)\n        {\n            if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)\n            {\n                setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,\n                             EGL_NO_RESET_NOTIFICATION_KHR);\n            }\n            else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)\n            {\n                setEGLattrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,\n                             EGL_LOSE_CONTEXT_ON_RESET_KHR);\n            }\n\n            flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;\n        }\n\n        if (ctxconfig->major != 1 || ctxconfig->minor != 0)\n        {\n            setEGLattrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);\n            setEGLattrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);\n        }\n\n        if (mask)\n            setEGLattrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);\n\n        if (flags)\n            setEGLattrib(EGL_CONTEXT_FLAGS_KHR, flags);\n\n        setEGLattrib(EGL_NONE, EGL_NONE);\n    }\n    else\n    {\n        int index = 0;\n\n        if (ctxconfig->api == GLFW_OPENGL_ES_API)\n            setEGLattrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);\n\n        setEGLattrib(EGL_NONE, EGL_NONE);\n    }\n\n    // Context release behaviors (GL_KHR_context_flush_control) are not yet\n    // supported on EGL but are not a hard constraint, so ignore and continue\n\n    window->egl.context = _glfw_eglCreateContext(_glfw.egl.display,\n                                                 config, share, attribs);\n\n    if (window->egl.context == EGL_NO_CONTEXT)\n    {\n        _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                        \"EGL: Failed to create context: %s\",\n                        getErrorString(_glfw_eglGetError()));\n        return GL_FALSE;\n    }\n\n    window->egl.config = config;\n\n    // Load the appropriate client library\n    {\n        int i;\n        const char** sonames;\n        const char* es1sonames[] =\n        {\n#if defined(_GLFW_WIN32)\n            \"GLESv1_CM.dll\",\n            \"libGLES_CM.dll\",\n#elif defined(_GLFW_COCOA)\n            \"libGLESv1_CM.dylib\",\n#else\n            \"libGLESv1_CM.so.1\",\n            \"libGLES_CM.so.1\",\n#endif\n            NULL\n        };\n        const char* es2sonames[] =\n        {\n#if defined(_GLFW_WIN32)\n            \"GLESv2.dll\",\n            \"libGLESv2.dll\",\n#elif defined(_GLFW_COCOA)\n            \"libGLESv2.dylib\",\n#else\n            \"libGLESv2.so.2\",\n#endif\n            NULL\n        };\n        const char* glsonames[] =\n        {\n#if defined(_GLFW_WIN32)\n#elif defined(_GLFW_COCOA)\n#else\n            \"libGL.so.1\",\n#endif\n            NULL\n        };\n\n        if (ctxconfig->api == GLFW_OPENGL_ES_API)\n        {\n            if (ctxconfig->major == 1)\n                sonames = es1sonames;\n            else\n                sonames = es2sonames;\n        }\n        else\n            sonames = glsonames;\n\n        for (i = 0;  sonames[i];  i++)\n        {\n            window->egl.client = _glfw_dlopen(sonames[i]);\n            if (window->egl.client)\n                break;\n        }\n\n        if (!window->egl.client)\n        {\n            _glfwInputError(GLFW_API_UNAVAILABLE,\n                            \"EGL: Failed to load client library\");\n            return GL_FALSE;\n        }\n    }\n\n    return GL_TRUE;\n}\n\n#undef setEGLattrib\n\n// Destroy the OpenGL context\n//\nvoid _glfwDestroyContext(_GLFWwindow* window)\n{\n#if defined(_GLFW_X11)\n    // NOTE: Do not unload libGL.so.1 while the X11 display is still open,\n    //       as it will make XCloseDisplay segfault\n    if (window->context.api != GLFW_OPENGL_API)\n#endif // _GLFW_X11\n    {\n        if (window->egl.client)\n        {\n            _glfw_dlclose(window->egl.client);\n            window->egl.client = NULL;\n        }\n    }\n\n#if defined(_GLFW_X11)\n    if (window->egl.visual)\n    {\n       XFree(window->egl.visual);\n       window->egl.visual = NULL;\n    }\n#endif // _GLFW_X11\n\n    if (window->egl.surface)\n    {\n        _glfw_eglDestroySurface(_glfw.egl.display, window->egl.surface);\n        window->egl.surface = EGL_NO_SURFACE;\n    }\n\n    if (window->egl.context)\n    {\n        _glfw_eglDestroyContext(_glfw.egl.display, window->egl.context);\n        window->egl.context = EGL_NO_CONTEXT;\n    }\n}\n\n// Analyzes the specified context for possible recreation\n//\nint _glfwAnalyzeContext(const _GLFWwindow* window,\n                        const _GLFWctxconfig* ctxconfig,\n                        const _GLFWfbconfig* fbconfig)\n{\n#if defined(_GLFW_WIN32)\n    return _GLFW_RECREATION_NOT_NEEDED;\n#else\n    return 0;\n#endif\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwPlatformMakeContextCurrent(_GLFWwindow* window)\n{\n    if (window)\n    {\n        if (window->egl.surface == EGL_NO_SURFACE)\n        {\n            window->egl.surface =\n                _glfw_eglCreateWindowSurface(_glfw.egl.display,\n                                             window->egl.config,\n                                             (EGLNativeWindowType)_GLFW_EGL_NATIVE_WINDOW,\n                                             NULL);\n            if (window->egl.surface == EGL_NO_SURFACE)\n            {\n                _glfwInputError(GLFW_PLATFORM_ERROR,\n                                \"EGL: Failed to create window surface: %s\",\n                                getErrorString(_glfw_eglGetError()));\n            }\n        }\n\n        _glfw_eglMakeCurrent(_glfw.egl.display,\n                             window->egl.surface,\n                             window->egl.surface,\n                             window->egl.context);\n    }\n    else\n    {\n        _glfw_eglMakeCurrent(_glfw.egl.display,\n                             EGL_NO_SURFACE,\n                             EGL_NO_SURFACE,\n                             EGL_NO_CONTEXT);\n    }\n\n    _glfwSetContextTLS(window);\n}\n\nvoid _glfwPlatformSwapBuffers(_GLFWwindow* window)\n{\n    _glfw_eglSwapBuffers(_glfw.egl.display, window->egl.surface);\n}\n\nvoid _glfwPlatformSwapInterval(int interval)\n{\n    _glfw_eglSwapInterval(_glfw.egl.display, interval);\n}\n\nint _glfwPlatformExtensionSupported(const char* extension)\n{\n    const char* extensions = _glfw_eglQueryString(_glfw.egl.display,\n                                                  EGL_EXTENSIONS);\n    if (extensions)\n    {\n        if (_glfwStringInExtensionString(extension, extensions))\n            return GL_TRUE;\n    }\n\n    return GL_FALSE;\n}\n\nGLFWglproc _glfwPlatformGetProcAddress(const char* procname)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    if (window->egl.client)\n    {\n        GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->egl.client, procname);\n        if (proc)\n            return proc;\n    }\n\n    return _glfw_eglGetProcAddress(procname);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI EGLDisplay glfwGetEGLDisplay(void)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);\n    return _glfw.egl.display;\n}\n\nGLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);\n    return window->egl.context;\n}\n\nGLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);\n    return window->egl.surface;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/egl_context.h",
    "content": "//========================================================================\n// GLFW 3.1 EGL - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_egl_context_h_\n#define _glfw3_egl_context_h_\n\n#if defined(_GLFW_WIN32)\n #define _glfw_dlopen(name) LoadLibraryA(name)\n #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)\n #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)\n#else\n #include <dlfcn.h>\n #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)\n #define _glfw_dlclose(handle) dlclose(handle)\n #define _glfw_dlsym(handle, name) dlsym(handle, name)\n#endif\n\n#include <EGL/egl.h>\n\n// This path may need to be changed if you build GLFW using your own setup\n// We ship and use our own copy of eglext.h since GLFW uses fairly new\n// extensions and not all operating systems come with an up-to-date version\n#include \"../deps/EGL/eglext.h\"\n\n// EGL function pointer typedefs\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay,EGLConfig,EGLint,EGLint*);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLGETCONFIGSPROC)(EGLDisplay,EGLConfig*,EGLint,EGLint*);\ntypedef EGLDisplay (EGLAPIENTRY * PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType);\ntypedef EGLint (EGLAPIENTRY * PFNEGLGETERRORPROC)(void);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLINITIALIZEPROC)(EGLDisplay,EGLint*,EGLint*);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLTERMINATEPROC)(EGLDisplay);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLBINDAPIPROC)(EGLenum);\ntypedef EGLContext (EGLAPIENTRY * PFNEGLCREATECONTEXTPROC)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYSURFACEPROC)(EGLDisplay,EGLSurface);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYCONTEXTPROC)(EGLDisplay,EGLContext);\ntypedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLMAKECURRENTPROC)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLSWAPBUFFERSPROC)(EGLDisplay,EGLSurface);\ntypedef EGLBoolean (EGLAPIENTRY * PFNEGLSWAPINTERVALPROC)(EGLDisplay,EGLint);\ntypedef const char* (EGLAPIENTRY * PFNEGLQUERYSTRINGPROC)(EGLDisplay,EGLint);\ntypedef GLFWglproc (EGLAPIENTRY * PFNEGLGETPROCADDRESSPROC)(const char*);\n#define _glfw_eglGetConfigAttrib _glfw.egl.GetConfigAttrib\n#define _glfw_eglGetConfigs _glfw.egl.GetConfigs\n#define _glfw_eglGetDisplay _glfw.egl.GetDisplay\n#define _glfw_eglGetError _glfw.egl.GetError\n#define _glfw_eglInitialize _glfw.egl.Initialize\n#define _glfw_eglTerminate _glfw.egl.Terminate\n#define _glfw_eglBindAPI _glfw.egl.BindAPI\n#define _glfw_eglCreateContext _glfw.egl.CreateContext\n#define _glfw_eglDestroySurface _glfw.egl.DestroySurface\n#define _glfw_eglDestroyContext _glfw.egl.DestroyContext\n#define _glfw_eglCreateWindowSurface _glfw.egl.CreateWindowSurface\n#define _glfw_eglMakeCurrent _glfw.egl.MakeCurrent\n#define _glfw_eglSwapBuffers _glfw.egl.SwapBuffers\n#define _glfw_eglSwapInterval _glfw.egl.SwapInterval\n#define _glfw_eglQueryString _glfw.egl.QueryString\n#define _glfw_eglGetProcAddress _glfw.egl.GetProcAddress\n\n#define _GLFW_PLATFORM_FBCONFIG                 EGLConfig       egl\n#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextEGL egl\n#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryEGL egl\n\n\n// EGL-specific per-context data\n//\ntypedef struct _GLFWcontextEGL\n{\n   EGLConfig        config;\n   EGLContext       context;\n   EGLSurface       surface;\n\n#if defined(_GLFW_X11)\n   XVisualInfo*     visual;\n#endif\n\n   void*            client;\n\n} _GLFWcontextEGL;\n\n\n// EGL-specific global data\n//\ntypedef struct _GLFWlibraryEGL\n{\n    EGLDisplay      display;\n    EGLint          major, minor;\n\n    GLboolean       KHR_create_context;\n\n    void*           handle;\n\n    PFNEGLGETCONFIGATTRIBPROC       GetConfigAttrib;\n    PFNEGLGETCONFIGSPROC            GetConfigs;\n    PFNEGLGETDISPLAYPROC            GetDisplay;\n    PFNEGLGETERRORPROC              GetError;\n    PFNEGLINITIALIZEPROC            Initialize;\n    PFNEGLTERMINATEPROC             Terminate;\n    PFNEGLBINDAPIPROC               BindAPI;\n    PFNEGLCREATECONTEXTPROC         CreateContext;\n    PFNEGLDESTROYSURFACEPROC        DestroySurface;\n    PFNEGLDESTROYCONTEXTPROC        DestroyContext;\n    PFNEGLCREATEWINDOWSURFACEPROC   CreateWindowSurface;\n    PFNEGLMAKECURRENTPROC           MakeCurrent;\n    PFNEGLSWAPBUFFERSPROC           SwapBuffers;\n    PFNEGLSWAPINTERVALPROC          SwapInterval;\n    PFNEGLQUERYSTRINGPROC           QueryString;\n    PFNEGLGETPROCADDRESSPROC        GetProcAddress;\n\n} _GLFWlibraryEGL;\n\n\nint _glfwInitContextAPI(void);\nvoid _glfwTerminateContextAPI(void);\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig);\nvoid _glfwDestroyContext(_GLFWwindow* window);\nint _glfwAnalyzeContext(const _GLFWwindow* window,\n                        const _GLFWctxconfig* ctxconfig,\n                        const _GLFWfbconfig* fbconfig);\n\n#endif // _glfw3_egl_context_h_\n"
  },
  {
    "path": "deps/glfw/src/glfw3.pc.in",
    "content": "prefix=@CMAKE_INSTALL_PREFIX@\nexec_prefix=${prefix}\nincludedir=${prefix}/include\nlibdir=${exec_prefix}/lib@LIB_SUFFIX@\n\nName: GLFW\nDescription: A multi-platform library for OpenGL, window and input\nVersion: @GLFW_VERSION_FULL@\nURL: http://www.glfw.org/\nRequires.private: @GLFW_PKG_DEPS@\nLibs: -L${libdir} -l@GLFW_LIB_NAME@\nLibs.private: @GLFW_PKG_LIBS@\nCflags: -I${includedir}\n"
  },
  {
    "path": "deps/glfw/src/glfw3Config.cmake.in",
    "content": "# - Config file for the glfw3 package\n# It defines the following variables\n#   GLFW3_INCLUDE_DIR, the path where GLFW headers are located\n#   GLFW3_LIBRARY_DIR, folder in which the GLFW library is located\n#   GLFW3_LIBRARY, library to link against to use GLFW\n\nset(GLFW3_VERSION \"@GLFW_VERSION_FULL@\")\n\n@PACKAGE_INIT@\n\nset_and_check(GLFW3_INCLUDE_DIR \"@PACKAGE_CMAKE_INSTALL_PREFIX@/include\")\nset_and_check(GLFW3_LIBRARY_DIR \"@PACKAGE_CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@\")\n\nfind_library(GLFW3_LIBRARY \"@GLFW_LIB_NAME@\" HINTS ${GLFW3_LIBRARY_DIR})\n\n"
  },
  {
    "path": "deps/glfw/src/glfw_config.h.in",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n// As glfw_config.h.in, this file is used by CMake to produce the\n// glfw_config.h configuration header file.  If you are adding a feature\n// requiring conditional compilation, this is where to add the macro.\n//========================================================================\n// As glfw_config.h, this file defines compile-time option macros for a\n// specific platform and development environment.  If you are using the\n// GLFW CMake files, modify glfw_config.h.in instead of this file.  If you\n// are using your own build system, make this file define the appropriate\n// macros in whatever way is suitable.\n//========================================================================\n\n// Define this to 1 if building GLFW for X11\n#cmakedefine _GLFW_X11\n// Define this to 1 if building GLFW for Win32\n#cmakedefine _GLFW_WIN32\n// Define this to 1 if building GLFW for Cocoa\n#cmakedefine _GLFW_COCOA\n// Define this to 1 if building GLFW for Wayland\n#cmakedefine _GLFW_WAYLAND\n// Define this to 1 if building GLFW for Mir\n#cmakedefine _GLFW_MIR\n\n// Define this to 1 if building GLFW for EGL\n#cmakedefine _GLFW_EGL\n// Define this to 1 if building GLFW for GLX\n#cmakedefine _GLFW_GLX\n// Define this to 1 if building GLFW for WGL\n#cmakedefine _GLFW_WGL\n// Define this to 1 if building GLFW for NSGL\n#cmakedefine _GLFW_NSGL\n\n// Define this to 1 if building as a shared library / dynamic library / DLL\n#cmakedefine _GLFW_BUILD_DLL\n\n// Define this to 1 to force use of high-performance GPU on hybrid systems\n#cmakedefine _GLFW_USE_HYBRID_HPG\n\n// Define this to 1 if the XInput X11 extension is available\n#cmakedefine _GLFW_HAS_XINPUT\n// Define this to 1 if the Xxf86vm X11 extension is available\n#cmakedefine _GLFW_HAS_XF86VM\n\n// Define this to 1 if glfwInit should change the current directory\n#cmakedefine _GLFW_USE_CHDIR\n// Define this to 1 if glfwCreateWindow should populate the menu bar\n#cmakedefine _GLFW_USE_MENUBAR\n// Define this to 1 if windows should use full resolution on Retina displays\n#cmakedefine _GLFW_USE_RETINA\n\n// Define this to 1 if using OpenGL as the client library\n#cmakedefine _GLFW_USE_OPENGL\n// Define this to 1 if using OpenGL ES 1.1 as the client library\n#cmakedefine _GLFW_USE_GLESV1\n// Define this to 1 if using OpenGL ES 2.0 as the client library\n#cmakedefine _GLFW_USE_GLESV2\n\n"
  },
  {
    "path": "deps/glfw/src/glx_context.c",
    "content": "//========================================================================\n// GLFW 3.1 GLX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <dlfcn.h>\n\n#ifndef GLXBadProfileARB\n #define GLXBadProfileARB 13\n#endif\n\n\n// Returns the specified attribute of the specified GLXFBConfig\n//\nstatic int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib)\n{\n    int value;\n    _glfw_glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);\n    return value;\n}\n\n// Return a list of available and usable framebuffer configs\n//\nstatic GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result)\n{\n    GLXFBConfig* nativeConfigs;\n    _GLFWfbconfig* usableConfigs;\n    const _GLFWfbconfig* closest;\n    int i, nativeCount, usableCount;\n    const char* vendor;\n    GLboolean trustWindowBit = GL_TRUE;\n\n    // HACK: This is a (hopefully temporary) workaround for Chromium\n    //       (VirtualBox GL) not setting the window bit on any GLXFBConfigs\n    vendor = _glfw_glXGetClientString(_glfw.x11.display, GLX_VENDOR);\n    if (strcmp(vendor, \"Chromium\") == 0)\n        trustWindowBit = GL_FALSE;\n\n    nativeConfigs = _glfw_glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen,\n                                          &nativeCount);\n    if (!nativeCount)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE, \"GLX: No GLXFBConfigs returned\");\n        return GL_FALSE;\n    }\n\n    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));\n    usableCount = 0;\n\n    for (i = 0;  i < nativeCount;  i++)\n    {\n        const GLXFBConfig n = nativeConfigs[i];\n        _GLFWfbconfig* u = usableConfigs + usableCount;\n\n        // Only consider GLXFBConfigs with associated visuals\n        if (!getFBConfigAttrib(n, GLX_VISUAL_ID))\n            continue;\n\n        // Only consider RGBA GLXFBConfigs\n        if (!(getFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))\n            continue;\n\n        // Only consider window GLXFBConfigs\n        if (!(getFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))\n        {\n            if (trustWindowBit)\n                continue;\n        }\n\n        u->redBits = getFBConfigAttrib(n, GLX_RED_SIZE);\n        u->greenBits = getFBConfigAttrib(n, GLX_GREEN_SIZE);\n        u->blueBits = getFBConfigAttrib(n, GLX_BLUE_SIZE);\n\n        u->alphaBits = getFBConfigAttrib(n, GLX_ALPHA_SIZE);\n        u->depthBits = getFBConfigAttrib(n, GLX_DEPTH_SIZE);\n        u->stencilBits = getFBConfigAttrib(n, GLX_STENCIL_SIZE);\n\n        u->accumRedBits = getFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);\n        u->accumGreenBits = getFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);\n        u->accumBlueBits = getFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);\n        u->accumAlphaBits = getFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);\n\n        u->auxBuffers = getFBConfigAttrib(n, GLX_AUX_BUFFERS);\n\n        if (getFBConfigAttrib(n, GLX_STEREO))\n            u->stereo = GL_TRUE;\n        if (getFBConfigAttrib(n, GLX_DOUBLEBUFFER))\n            u->doublebuffer = GL_TRUE;\n\n        if (_glfw.glx.ARB_multisample)\n            u->samples = getFBConfigAttrib(n, GLX_SAMPLES);\n\n        if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)\n            u->sRGB = getFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);\n\n        u->glx = n;\n        usableCount++;\n    }\n\n    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);\n    if (closest)\n        *result = closest->glx;\n\n    XFree(nativeConfigs);\n    free(usableConfigs);\n\n    return closest ? GL_TRUE : GL_FALSE;\n}\n\n// Create the OpenGL context using legacy API\n//\nstatic GLXContext createLegacyContext(_GLFWwindow* window,\n                                      GLXFBConfig fbconfig,\n                                      GLXContext share)\n{\n    return _glfw_glXCreateNewContext(_glfw.x11.display,\n                                     fbconfig,\n                                     GLX_RGBA_TYPE,\n                                     share,\n                                     True);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize GLX\n//\nint _glfwInitContextAPI(void)\n{\n#if defined(__CYGWIN__)\n    const char* soname = \"libGL-1.so\";\n#else\n    const char* soname = \"libGL.so.1\";\n#endif\n\n    if (!_glfwCreateContextTLS())\n        return GL_FALSE;\n\n    _glfw.glx.handle = dlopen(soname, RTLD_LAZY | RTLD_GLOBAL);\n    if (!_glfw.glx.handle)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE, \"GLX: %s\", dlerror());\n        return GL_FALSE;\n    }\n\n    _glfw.glx.GetFBConfigs =\n        dlsym(_glfw.glx.handle, \"glXGetFBConfigs\");\n    _glfw.glx.GetFBConfigAttrib =\n        dlsym(_glfw.glx.handle, \"glXGetFBConfigAttrib\");\n    _glfw.glx.GetClientString =\n        dlsym(_glfw.glx.handle, \"glXGetClientString\");\n    _glfw.glx.QueryExtension =\n        dlsym(_glfw.glx.handle, \"glXQueryExtension\");\n    _glfw.glx.QueryVersion =\n        dlsym(_glfw.glx.handle, \"glXQueryVersion\");\n    _glfw.glx.DestroyContext =\n        dlsym(_glfw.glx.handle, \"glXDestroyContext\");\n    _glfw.glx.MakeCurrent =\n        dlsym(_glfw.glx.handle, \"glXMakeCurrent\");\n    _glfw.glx.SwapBuffers =\n        dlsym(_glfw.glx.handle, \"glXSwapBuffers\");\n    _glfw.glx.QueryExtensionsString =\n        dlsym(_glfw.glx.handle, \"glXQueryExtensionsString\");\n    _glfw.glx.CreateNewContext =\n        dlsym(_glfw.glx.handle, \"glXCreateNewContext\");\n    _glfw.glx.GetVisualFromFBConfig =\n        dlsym(_glfw.glx.handle, \"glXGetVisualFromFBConfig\");\n    _glfw.glx.GetProcAddress =\n        dlsym(_glfw.glx.handle, \"glXGetProcAddress\");\n    _glfw.glx.GetProcAddressARB =\n        dlsym(_glfw.glx.handle, \"glXGetProcAddressARB\");\n\n    if (!_glfw_glXQueryExtension(_glfw.x11.display,\n                                 &_glfw.glx.errorBase,\n                                 &_glfw.glx.eventBase))\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE, \"GLX: GLX extension not found\");\n        return GL_FALSE;\n    }\n\n    if (!_glfw_glXQueryVersion(_glfw.x11.display,\n                               &_glfw.glx.major,\n                               &_glfw.glx.minor))\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"GLX: Failed to query GLX version\");\n        return GL_FALSE;\n    }\n\n    if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"GLX: GLX version 1.3 is required\");\n        return GL_FALSE;\n    }\n\n    if (_glfwPlatformExtensionSupported(\"GLX_EXT_swap_control\"))\n    {\n        _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)\n            _glfwPlatformGetProcAddress(\"glXSwapIntervalEXT\");\n\n        if (_glfw.glx.SwapIntervalEXT)\n            _glfw.glx.EXT_swap_control = GL_TRUE;\n    }\n\n    if (_glfwPlatformExtensionSupported(\"GLX_SGI_swap_control\"))\n    {\n        _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)\n            _glfwPlatformGetProcAddress(\"glXSwapIntervalSGI\");\n\n        if (_glfw.glx.SwapIntervalSGI)\n            _glfw.glx.SGI_swap_control = GL_TRUE;\n    }\n\n    if (_glfwPlatformExtensionSupported(\"GLX_MESA_swap_control\"))\n    {\n        _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)\n            _glfwPlatformGetProcAddress(\"glXSwapIntervalMESA\");\n\n        if (_glfw.glx.SwapIntervalMESA)\n            _glfw.glx.MESA_swap_control = GL_TRUE;\n    }\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_multisample\"))\n        _glfw.glx.ARB_multisample = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_framebuffer_sRGB\"))\n        _glfw.glx.ARB_framebuffer_sRGB = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_EXT_framebuffer_sRGB\"))\n        _glfw.glx.EXT_framebuffer_sRGB = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_create_context\"))\n    {\n        _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)\n            _glfwPlatformGetProcAddress(\"glXCreateContextAttribsARB\");\n\n        if (_glfw.glx.CreateContextAttribsARB)\n            _glfw.glx.ARB_create_context = GL_TRUE;\n    }\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_create_context_robustness\"))\n        _glfw.glx.ARB_create_context_robustness = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_create_context_profile\"))\n        _glfw.glx.ARB_create_context_profile = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_EXT_create_context_es2_profile\"))\n        _glfw.glx.EXT_create_context_es2_profile = GL_TRUE;\n\n    if (_glfwPlatformExtensionSupported(\"GLX_ARB_context_flush_control\"))\n        _glfw.glx.ARB_context_flush_control = GL_TRUE;\n\n    return GL_TRUE;\n}\n\n// Terminate GLX\n//\nvoid _glfwTerminateContextAPI(void)\n{\n    // NOTE: This function may not call any X11 functions, as it is called after\n    //       XCloseDisplay (see _glfwPlatformTerminate for details)\n\n    if (_glfw.glx.handle)\n    {\n        dlclose(_glfw.glx.handle);\n        _glfw.glx.handle = NULL;\n    }\n\n    _glfwDestroyContextTLS();\n}\n\n#define setGLXattrib(attribName, attribValue) \\\n{ \\\n    attribs[index++] = attribName; \\\n    attribs[index++] = attribValue; \\\n    assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \\\n}\n\n// Create the OpenGL or OpenGL ES context\n//\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig)\n{\n    int attribs[40];\n    GLXFBConfig native = NULL;\n    GLXContext share = NULL;\n\n    if (ctxconfig->share)\n        share = ctxconfig->share->glx.context;\n\n    if (!chooseFBConfig(fbconfig, &native))\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"GLX: Failed to find a suitable GLXFBConfig\");\n        return GL_FALSE;\n    }\n\n    window->glx.visual = _glfw_glXGetVisualFromFBConfig(_glfw.x11.display,\n                                                        native);\n    if (!window->glx.visual)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"GLX: Failed to retrieve visual for GLXFBConfig\");\n        return GL_FALSE;\n    }\n\n    if (ctxconfig->api == GLFW_OPENGL_ES_API)\n    {\n        if (!_glfw.glx.ARB_create_context ||\n            !_glfw.glx.ARB_create_context_profile ||\n            !_glfw.glx.EXT_create_context_es2_profile)\n        {\n            _glfwInputError(GLFW_API_UNAVAILABLE,\n                            \"GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable\");\n            return GL_FALSE;\n        }\n    }\n\n    if (ctxconfig->forward)\n    {\n        if (!_glfw.glx.ARB_create_context)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable\");\n            return GL_FALSE;\n        }\n    }\n\n    if (ctxconfig->profile)\n    {\n        if (!_glfw.glx.ARB_create_context ||\n            !_glfw.glx.ARB_create_context_profile)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable\");\n            return GL_FALSE;\n        }\n    }\n\n    _glfwGrabXErrorHandler();\n\n    if (_glfw.glx.ARB_create_context)\n    {\n        int index = 0, mask = 0, flags = 0;\n\n        if (ctxconfig->api == GLFW_OPENGL_API)\n        {\n            if (ctxconfig->forward)\n                flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;\n\n            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)\n                mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;\n            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)\n                mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;\n        }\n        else\n            mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;\n\n        if (ctxconfig->debug)\n            flags |= GLX_CONTEXT_DEBUG_BIT_ARB;\n\n        if (ctxconfig->robustness)\n        {\n            if (_glfw.glx.ARB_create_context_robustness)\n            {\n                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)\n                {\n                    setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,\n                                 GLX_NO_RESET_NOTIFICATION_ARB);\n                }\n                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)\n                {\n                    setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,\n                                 GLX_LOSE_CONTEXT_ON_RESET_ARB);\n                }\n\n                flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;\n            }\n        }\n\n        if (ctxconfig->release)\n        {\n            if (_glfw.glx.ARB_context_flush_control)\n            {\n                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)\n                {\n                    setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,\n                                 GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);\n                }\n                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)\n                {\n                    setGLXattrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,\n                                 GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);\n                }\n            }\n        }\n\n        // NOTE: Only request an explicitly versioned context when necessary, as\n        //       explicitly requesting version 1.0 does not always return the\n        //       highest version supported by the driver\n        if (ctxconfig->major != 1 || ctxconfig->minor != 0)\n        {\n            setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);\n            setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);\n        }\n\n        if (mask)\n            setGLXattrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);\n\n        if (flags)\n            setGLXattrib(GLX_CONTEXT_FLAGS_ARB, flags);\n\n        setGLXattrib(None, None);\n\n        window->glx.context =\n            _glfw.glx.CreateContextAttribsARB(_glfw.x11.display,\n                                              native,\n                                              share,\n                                              True,\n                                              attribs);\n\n        // HACK: This is a fallback for broken versions of the Mesa\n        //       implementation of GLX_ARB_create_context_profile that fail\n        //       default 1.0 context creation with a GLXBadProfileARB error in\n        //       violation of the extension spec\n        if (!window->glx.context)\n        {\n            if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&\n                ctxconfig->api == GLFW_OPENGL_API &&\n                ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&\n                ctxconfig->forward == GL_FALSE)\n            {\n                window->glx.context = createLegacyContext(window, native, share);\n            }\n        }\n    }\n    else\n        window->glx.context = createLegacyContext(window, native, share);\n\n    _glfwReleaseXErrorHandler();\n\n    if (!window->glx.context)\n    {\n        _glfwInputXError(GLFW_VERSION_UNAVAILABLE, \"GLX: Failed to create context\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n#undef setGLXattrib\n\n// Destroy the OpenGL context\n//\nvoid _glfwDestroyContext(_GLFWwindow* window)\n{\n    if (window->glx.visual)\n    {\n        XFree(window->glx.visual);\n        window->glx.visual = NULL;\n    }\n\n    if (window->glx.context)\n    {\n        _glfw_glXDestroyContext(_glfw.x11.display, window->glx.context);\n        window->glx.context = NULL;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwPlatformMakeContextCurrent(_GLFWwindow* window)\n{\n    if (window)\n    {\n        _glfw_glXMakeCurrent(_glfw.x11.display,\n                             window->x11.handle,\n                             window->glx.context);\n    }\n    else\n        _glfw_glXMakeCurrent(_glfw.x11.display, None, NULL);\n\n    _glfwSetContextTLS(window);\n}\n\nvoid _glfwPlatformSwapBuffers(_GLFWwindow* window)\n{\n    _glfw_glXSwapBuffers(_glfw.x11.display, window->x11.handle);\n}\n\nvoid _glfwPlatformSwapInterval(int interval)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    if (_glfw.glx.EXT_swap_control)\n    {\n        _glfw.glx.SwapIntervalEXT(_glfw.x11.display,\n                                  window->x11.handle,\n                                  interval);\n    }\n    else if (_glfw.glx.MESA_swap_control)\n        _glfw.glx.SwapIntervalMESA(interval);\n    else if (_glfw.glx.SGI_swap_control)\n    {\n        if (interval > 0)\n            _glfw.glx.SwapIntervalSGI(interval);\n    }\n}\n\nint _glfwPlatformExtensionSupported(const char* extension)\n{\n    const char* extensions =\n        _glfw_glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);\n    if (extensions)\n    {\n        if (_glfwStringInExtensionString(extension, extensions))\n            return GL_TRUE;\n    }\n\n    return GL_FALSE;\n}\n\nGLFWglproc _glfwPlatformGetProcAddress(const char* procname)\n{\n    if (_glfw.glx.GetProcAddress)\n        return _glfw.glx.GetProcAddress((const GLubyte*) procname);\n    else if (_glfw.glx.GetProcAddressARB)\n        return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);\n    else\n        return dlsym(_glfw.glx.handle, procname);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return window->glx.context;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/glx_context.h",
    "content": "//========================================================================\n// GLFW 3.1 GLX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_glx_context_h_\n#define _glfw3_glx_context_h_\n\n#define GLX_GLXEXT_LEGACY\n#include <GL/glx.h>\n\n// This path may need to be changed if you build GLFW using your own setup\n// We ship and use our own copy of glxext.h since GLFW uses fairly new\n// extensions and not all operating systems come with an up-to-date version\n#define GLX_GLXEXT_PROTOTYPES\n#include \"../deps/GL/glxext.h\"\n\n// libGL.so function pointer typedefs\ntypedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);\ntypedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);\ntypedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);\ntypedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);\ntypedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);\ntypedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);\ntypedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);\ntypedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);\n#define _glfw_glXGetFBConfigs _glfw.glx.GetFBConfigs\n#define _glfw_glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib\n#define _glfw_glXGetClientString _glfw.glx.GetClientString\n#define _glfw_glXQueryExtension _glfw.glx.QueryExtension\n#define _glfw_glXQueryVersion _glfw.glx.QueryVersion\n#define _glfw_glXDestroyContext _glfw.glx.DestroyContext\n#define _glfw_glXMakeCurrent _glfw.glx.MakeCurrent\n#define _glfw_glXSwapBuffers _glfw.glx.SwapBuffers\n#define _glfw_glXQueryExtensionsString _glfw.glx.QueryExtensionsString\n#define _glfw_glXCreateNewContext _glfw.glx.CreateNewContext\n#define _glfw_glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig\n\n#define _GLFW_PLATFORM_FBCONFIG                 GLXFBConfig     glx\n#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextGLX glx\n#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryGLX glx\n\n#ifndef GLX_MESA_swap_control\ntypedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);\n#endif\n\n\n// GLX-specific per-context data\n//\ntypedef struct _GLFWcontextGLX\n{\n    // Rendering context\n    GLXContext      context;\n    // Visual of selected GLXFBConfig\n    XVisualInfo*    visual;\n\n} _GLFWcontextGLX;\n\n\n// GLX-specific global data\n//\ntypedef struct _GLFWlibraryGLX\n{\n    int             major, minor;\n    int             eventBase;\n    int             errorBase;\n\n    // dlopen handle for libGL.so.1\n    void*           handle;\n\n    // GLX 1.3 functions\n    PFNGLXGETFBCONFIGSPROC              GetFBConfigs;\n    PFNGLXGETFBCONFIGATTRIBPROC         GetFBConfigAttrib;\n    PFNGLXGETCLIENTSTRINGPROC           GetClientString;\n    PFNGLXQUERYEXTENSIONPROC            QueryExtension;\n    PFNGLXQUERYVERSIONPROC              QueryVersion;\n    PFNGLXDESTROYCONTEXTPROC            DestroyContext;\n    PFNGLXMAKECURRENTPROC               MakeCurrent;\n    PFNGLXSWAPBUFFERSPROC               SwapBuffers;\n    PFNGLXQUERYEXTENSIONSSTRINGPROC     QueryExtensionsString;\n    PFNGLXCREATENEWCONTEXTPROC          CreateNewContext;\n    PFNGLXGETVISUALFROMFBCONFIGPROC     GetVisualFromFBConfig;\n\n    // GLX 1.4 and extension functions\n    PFNGLXGETPROCADDRESSPROC            GetProcAddress;\n    PFNGLXGETPROCADDRESSPROC            GetProcAddressARB;\n    PFNGLXSWAPINTERVALSGIPROC           SwapIntervalSGI;\n    PFNGLXSWAPINTERVALEXTPROC           SwapIntervalEXT;\n    PFNGLXSWAPINTERVALMESAPROC          SwapIntervalMESA;\n    PFNGLXCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;\n    GLboolean       SGI_swap_control;\n    GLboolean       EXT_swap_control;\n    GLboolean       MESA_swap_control;\n    GLboolean       ARB_multisample;\n    GLboolean       ARB_framebuffer_sRGB;\n    GLboolean       EXT_framebuffer_sRGB;\n    GLboolean       ARB_create_context;\n    GLboolean       ARB_create_context_profile;\n    GLboolean       ARB_create_context_robustness;\n    GLboolean       EXT_create_context_es2_profile;\n    GLboolean       ARB_context_flush_control;\n\n} _GLFWlibraryGLX;\n\n\nint _glfwInitContextAPI(void);\nvoid _glfwTerminateContextAPI(void);\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig);\nvoid _glfwDestroyContext(_GLFWwindow* window);\n\n#endif // _glfw3_glx_context_h_\n"
  },
  {
    "path": "deps/glfw/src/init.c",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <string.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <stdarg.h>\n\n\n// The three global variables below comprise all global data in GLFW.\n// Any other global variable is a bug.\n\n// Global state shared between compilation units of GLFW\n// These are documented in internal.h\n//\nGLboolean _glfwInitialized = GL_FALSE;\n_GLFWlibrary _glfw;\n\n// This is outside of _glfw so it can be initialized and usable before\n// glfwInit is called, which lets that function report errors\n//\nstatic GLFWerrorfun _glfwErrorCallback = NULL;\n\n\n// Returns a generic string representation of the specified error\n//\nstatic const char* getErrorString(int error)\n{\n    switch (error)\n    {\n        case GLFW_NOT_INITIALIZED:\n            return \"The GLFW library is not initialized\";\n        case GLFW_NO_CURRENT_CONTEXT:\n            return \"There is no current context\";\n        case GLFW_INVALID_ENUM:\n            return \"Invalid argument for enum parameter\";\n        case GLFW_INVALID_VALUE:\n            return \"Invalid value for parameter\";\n        case GLFW_OUT_OF_MEMORY:\n            return \"Out of memory\";\n        case GLFW_API_UNAVAILABLE:\n            return \"The requested client API is unavailable\";\n        case GLFW_VERSION_UNAVAILABLE:\n            return \"The requested client API version is unavailable\";\n        case GLFW_PLATFORM_ERROR:\n            return \"A platform-specific error occurred\";\n        case GLFW_FORMAT_UNAVAILABLE:\n            return \"The requested format is unavailable\";\n    }\n\n    return \"ERROR: UNKNOWN ERROR TOKEN PASSED TO glfwErrorString\";\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                         GLFW event API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwInputError(int error, const char* format, ...)\n{\n    if (_glfwErrorCallback)\n    {\n        char buffer[8192];\n        const char* description;\n\n        if (format)\n        {\n            int count;\n            va_list vl;\n\n            va_start(vl, format);\n            count = vsnprintf(buffer, sizeof(buffer), format, vl);\n            va_end(vl);\n\n            if (count < 0)\n                buffer[sizeof(buffer) - 1] = '\\0';\n\n            description = buffer;\n        }\n        else\n            description = getErrorString(error);\n\n        _glfwErrorCallback(error, description);\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW public API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI int glfwInit(void)\n{\n    if (_glfwInitialized)\n        return GL_TRUE;\n\n    memset(&_glfw, 0, sizeof(_glfw));\n\n    if (!_glfwPlatformInit())\n    {\n        _glfwPlatformTerminate();\n        return GL_FALSE;\n    }\n\n    _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);\n    _glfwInitialized = GL_TRUE;\n\n    // Not all window hints have zero as their default value\n    glfwDefaultWindowHints();\n\n    return GL_TRUE;\n}\n\nGLFWAPI void glfwTerminate(void)\n{\n    int i;\n\n    if (!_glfwInitialized)\n        return;\n\n    memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));\n\n    while (_glfw.windowListHead)\n        glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);\n\n    while (_glfw.cursorListHead)\n        glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);\n\n    for (i = 0;  i < _glfw.monitorCount;  i++)\n    {\n        _GLFWmonitor* monitor = _glfw.monitors[i];\n        if (monitor->originalRamp.size)\n            _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);\n    }\n\n    _glfwFreeMonitors(_glfw.monitors, _glfw.monitorCount);\n    _glfw.monitors = NULL;\n    _glfw.monitorCount = 0;\n\n    _glfwPlatformTerminate();\n\n    memset(&_glfw, 0, sizeof(_glfw));\n    _glfwInitialized = GL_FALSE;\n}\n\nGLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)\n{\n    if (major != NULL)\n        *major = GLFW_VERSION_MAJOR;\n\n    if (minor != NULL)\n        *minor = GLFW_VERSION_MINOR;\n\n    if (rev != NULL)\n        *rev = GLFW_VERSION_REVISION;\n}\n\nGLFWAPI const char* glfwGetVersionString(void)\n{\n    return _glfwPlatformGetVersionString();\n}\n\nGLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)\n{\n    _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);\n    return cbfun;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/input.c",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#if defined(_MSC_VER)\n #include <malloc.h>\n#endif\n\n// Internal key state used for sticky keys\n#define _GLFW_STICK 3\n\n\n// Sets the cursor mode for the specified window\n//\nstatic void setCursorMode(_GLFWwindow* window, int newMode)\n{\n    const int oldMode = window->cursorMode;\n\n    if (newMode != GLFW_CURSOR_NORMAL &&\n        newMode != GLFW_CURSOR_HIDDEN &&\n        newMode != GLFW_CURSOR_DISABLED)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid cursor mode\");\n        return;\n    }\n\n    if (oldMode == newMode)\n        return;\n\n    window->cursorMode = newMode;\n\n    if (_glfw.cursorWindow == window)\n    {\n        if (oldMode == GLFW_CURSOR_DISABLED)\n        {\n            _glfwPlatformSetCursorPos(window,\n                                      _glfw.cursorPosX,\n                                      _glfw.cursorPosY);\n        }\n        else if (newMode == GLFW_CURSOR_DISABLED)\n        {\n            int width, height;\n\n            _glfwPlatformGetCursorPos(window,\n                                      &_glfw.cursorPosX,\n                                      &_glfw.cursorPosY);\n\n            window->cursorPosX = _glfw.cursorPosX;\n            window->cursorPosY = _glfw.cursorPosY;\n\n            _glfwPlatformGetWindowSize(window, &width, &height);\n            _glfwPlatformSetCursorPos(window, width / 2, height / 2);\n        }\n\n        _glfwPlatformApplyCursorMode(window);\n    }\n}\n\n// Set sticky keys mode for the specified window\n//\nstatic void setStickyKeys(_GLFWwindow* window, int enabled)\n{\n    if (window->stickyKeys == enabled)\n        return;\n\n    if (!enabled)\n    {\n        int i;\n\n        // Release all sticky keys\n        for (i = 0;  i <= GLFW_KEY_LAST;  i++)\n        {\n            if (window->keys[i] == _GLFW_STICK)\n                window->keys[i] = GLFW_RELEASE;\n        }\n    }\n\n    window->stickyKeys = enabled;\n}\n\n// Set sticky mouse buttons mode for the specified window\n//\nstatic void setStickyMouseButtons(_GLFWwindow* window, int enabled)\n{\n    if (window->stickyMouseButtons == enabled)\n        return;\n\n    if (!enabled)\n    {\n        int i;\n\n        // Release all sticky mouse buttons\n        for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)\n        {\n            if (window->mouseButtons[i] == _GLFW_STICK)\n                window->mouseButtons[i] = GLFW_RELEASE;\n        }\n    }\n\n    window->stickyMouseButtons = enabled;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                         GLFW event API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key >= 0 && key <= GLFW_KEY_LAST)\n    {\n        GLboolean repeated = GL_FALSE;\n\n        if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)\n            return;\n\n        if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)\n            repeated = GL_TRUE;\n\n        if (action == GLFW_RELEASE && window->stickyKeys)\n            window->keys[key] = _GLFW_STICK;\n        else\n            window->keys[key] = (char) action;\n\n        if (repeated)\n            action = GLFW_REPEAT;\n    }\n\n    if (window->callbacks.key)\n        window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);\n}\n\nvoid _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, int plain)\n{\n    if (codepoint < 32 || (codepoint > 126 && codepoint < 160))\n        return;\n\n    if (window->callbacks.charmods)\n        window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);\n\n    if (plain)\n    {\n        if (window->callbacks.character)\n            window->callbacks.character((GLFWwindow*) window, codepoint);\n    }\n}\n\nvoid _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)\n{\n    if (window->callbacks.scroll)\n        window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);\n}\n\nvoid _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)\n{\n    if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)\n        return;\n\n    // Register mouse button action\n    if (action == GLFW_RELEASE && window->stickyMouseButtons)\n        window->mouseButtons[button] = _GLFW_STICK;\n    else\n        window->mouseButtons[button] = (char) action;\n\n    if (window->callbacks.mouseButton)\n        window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);\n}\n\nvoid _glfwInputCursorMotion(_GLFWwindow* window, double x, double y)\n{\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        if (x == 0.0 && y == 0.0)\n            return;\n\n        window->cursorPosX += x;\n        window->cursorPosY += y;\n\n        x = window->cursorPosX;\n        y = window->cursorPosY;\n    }\n\n    if (window->callbacks.cursorPos)\n        window->callbacks.cursorPos((GLFWwindow*) window, x, y);\n}\n\nvoid _glfwInputCursorEnter(_GLFWwindow* window, int entered)\n{\n    if (window->callbacks.cursorEnter)\n        window->callbacks.cursorEnter((GLFWwindow*) window, entered);\n}\n\nvoid _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)\n{\n    if (window->callbacks.drop)\n        window->callbacks.drop((GLFWwindow*) window, count, paths);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW public API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(0);\n\n    switch (mode)\n    {\n        case GLFW_CURSOR:\n            return window->cursorMode;\n        case GLFW_STICKY_KEYS:\n            return window->stickyKeys;\n        case GLFW_STICKY_MOUSE_BUTTONS:\n            return window->stickyMouseButtons;\n        default:\n            _glfwInputError(GLFW_INVALID_ENUM, \"Invalid input mode\");\n            return 0;\n    }\n}\n\nGLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    switch (mode)\n    {\n        case GLFW_CURSOR:\n            setCursorMode(window, value);\n            break;\n        case GLFW_STICKY_KEYS:\n            setStickyKeys(window, value ? GL_TRUE : GL_FALSE);\n            break;\n        case GLFW_STICKY_MOUSE_BUTTONS:\n            setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE);\n            break;\n        default:\n            _glfwInputError(GLFW_INVALID_ENUM, \"Invalid input mode\");\n            break;\n    }\n}\n\nGLFWAPI int glfwGetKey(GLFWwindow* handle, int key)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);\n\n    if (key < 0 || key > GLFW_KEY_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid key\");\n        return GLFW_RELEASE;\n    }\n\n    if (window->keys[key] == _GLFW_STICK)\n    {\n        // Sticky mode: release key now\n        window->keys[key] = GLFW_RELEASE;\n        return GLFW_PRESS;\n    }\n\n    return (int) window->keys[key];\n}\n\nGLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);\n\n    if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM,\n                        \"Invalid mouse button\");\n        return GLFW_RELEASE;\n    }\n\n    if (window->mouseButtons[button] == _GLFW_STICK)\n    {\n        // Sticky mode: release mouse button now\n        window->mouseButtons[button] = GLFW_RELEASE;\n        return GLFW_PRESS;\n    }\n\n    return (int) window->mouseButtons[button];\n}\n\nGLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    if (xpos)\n        *xpos = 0;\n    if (ypos)\n        *ypos = 0;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        if (xpos)\n            *xpos = window->cursorPosX;\n        if (ypos)\n            *ypos = window->cursorPosY;\n    }\n    else\n        _glfwPlatformGetCursorPos(window, xpos, ypos);\n}\n\nGLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (_glfw.cursorWindow != window)\n        return;\n\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        // Only update the accumulated position if the cursor is disabled\n        window->cursorPosX = xpos;\n        window->cursorPosY = ypos;\n    }\n    else\n    {\n        // Update system cursor position\n        _glfwPlatformSetCursorPos(window, xpos, ypos);\n    }\n}\n\nGLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)\n{\n    _GLFWcursor* cursor;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    cursor = calloc(1, sizeof(_GLFWcursor));\n    cursor->next = _glfw.cursorListHead;\n    _glfw.cursorListHead = cursor;\n\n    if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))\n    {\n        glfwDestroyCursor((GLFWcursor*) cursor);\n        return NULL;\n    }\n\n    return (GLFWcursor*) cursor;\n}\n\nGLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)\n{\n    _GLFWcursor* cursor;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (shape != GLFW_ARROW_CURSOR &&\n        shape != GLFW_IBEAM_CURSOR &&\n        shape != GLFW_CROSSHAIR_CURSOR &&\n        shape != GLFW_HAND_CURSOR &&\n        shape != GLFW_HRESIZE_CURSOR &&\n        shape != GLFW_VRESIZE_CURSOR)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid standard cursor\");\n        return NULL;\n    }\n\n    cursor = calloc(1, sizeof(_GLFWcursor));\n    cursor->next = _glfw.cursorListHead;\n    _glfw.cursorListHead = cursor;\n\n    if (!_glfwPlatformCreateStandardCursor(cursor, shape))\n    {\n        glfwDestroyCursor((GLFWcursor*) cursor);\n        return NULL;\n    }\n\n    return (GLFWcursor*) cursor;\n}\n\nGLFWAPI void glfwDestroyCursor(GLFWcursor* handle)\n{\n    _GLFWcursor* cursor = (_GLFWcursor*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (cursor == NULL)\n        return;\n\n    // Make sure the cursor is not being used by any window\n    {\n        _GLFWwindow* window;\n\n        for (window = _glfw.windowListHead;  window;  window = window->next)\n        {\n            if (window->cursor == cursor)\n                glfwSetCursor((GLFWwindow*) window, NULL);\n        }\n    }\n\n    _glfwPlatformDestroyCursor(cursor);\n\n    // Unlink cursor from global linked list\n    {\n        _GLFWcursor** prev = &_glfw.cursorListHead;\n\n        while (*prev != cursor)\n            prev = &((*prev)->next);\n\n        *prev = cursor->next;\n    }\n\n    free(cursor);\n}\n\nGLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) windowHandle;\n    _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;\n\n    _GLFW_REQUIRE_INIT();\n\n    _glfwPlatformSetCursor(window, cursor);\n\n    window->cursor = cursor;\n}\n\nGLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,\n                                                      GLFWmousebuttonfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,\n                                                  GLFWcursorposfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,\n                                                      GLFWcursorenterfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,\n                                            GLFWscrollfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);\n    return cbfun;\n}\n\nGLFWAPI int glfwJoystickPresent(int joy)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(0);\n\n    if (joy < 0 || joy > GLFW_JOYSTICK_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid joystick\");\n        return 0;\n    }\n\n    return _glfwPlatformJoystickPresent(joy);\n}\n\nGLFWAPI const float* glfwGetJoystickAxes(int joy, int* count)\n{\n    *count = 0;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (joy < 0 || joy > GLFW_JOYSTICK_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid joystick\");\n        return NULL;\n    }\n\n    return _glfwPlatformGetJoystickAxes(joy, count);\n}\n\nGLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count)\n{\n    *count = 0;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (joy < 0 || joy > GLFW_JOYSTICK_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid joystick\");\n        return NULL;\n    }\n\n    return _glfwPlatformGetJoystickButtons(joy, count);\n}\n\nGLFWAPI const char* glfwGetJoystickName(int joy)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (joy < 0 || joy > GLFW_JOYSTICK_LAST)\n    {\n        _glfwInputError(GLFW_INVALID_ENUM, \"Invalid joystick\");\n        return NULL;\n    }\n\n    return _glfwPlatformGetJoystickName(joy);\n}\n\nGLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformSetClipboardString(window, string);\n}\n\nGLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return _glfwPlatformGetClipboardString(window);\n}\n\nGLFWAPI double glfwGetTime(void)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(0.0);\n    return _glfwPlatformGetTime();\n}\n\nGLFWAPI void glfwSetTime(double time)\n{\n    _GLFW_REQUIRE_INIT();\n\n    if (time != time || time < 0.0 || time > 18446744073.0)\n    {\n        _glfwInputError(GLFW_INVALID_VALUE, \"Invalid time\");\n        return;\n    }\n\n    _glfwPlatformSetTime(time);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/internal.h",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_internal_h_\n#define _glfw3_internal_h_\n\n\n#if defined(_GLFW_USE_CONFIG_H)\n #include \"glfw_config.h\"\n#endif\n\n#define _GLFW_VERSION_NUMBER \"3.1.2\"\n\n#if defined(GLFW_INCLUDE_GLCOREARB) || \\\n    defined(GLFW_INCLUDE_ES1)       || \\\n    defined(GLFW_INCLUDE_ES2)       || \\\n    defined(GLFW_INCLUDE_ES3)       || \\\n    defined(GLFW_INCLUDE_NONE)      || \\\n    defined(GLFW_INCLUDE_GLEXT)     || \\\n    defined(GLFW_INCLUDE_GLU)       || \\\n    defined(GLFW_DLL)\n #error \"You may not define any header option macros when compiling GLFW\"\n#endif\n\n#if defined(_GLFW_USE_OPENGL)\n // This is the default for glfw3.h\n#elif defined(_GLFW_USE_GLESV1)\n #define GLFW_INCLUDE_ES1\n#elif defined(_GLFW_USE_GLESV2)\n #define GLFW_INCLUDE_ES2\n#else\n #error \"No supported client library selected\"\n#endif\n\n// Disable the inclusion of the platform glext.h by gl.h to allow proper\n// inclusion of our own, newer glext.h below\n#define GL_GLEXT_LEGACY\n\n#include \"../include/GLFW/glfw3.h\"\n\n#if defined(_GLFW_USE_OPENGL)\n // This path may need to be changed if you build GLFW using your own setup\n // GLFW comes with its own copy of glext.h since it uses fairly new extensions\n // and not all development environments come with an up-to-date version\n #include \"../deps/GL/glext.h\"\n#endif\n\ntypedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);\ntypedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);\ntypedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);\n\ntypedef struct _GLFWwndconfig   _GLFWwndconfig;\ntypedef struct _GLFWctxconfig   _GLFWctxconfig;\ntypedef struct _GLFWfbconfig    _GLFWfbconfig;\ntypedef struct _GLFWwindow      _GLFWwindow;\ntypedef struct _GLFWlibrary     _GLFWlibrary;\ntypedef struct _GLFWmonitor     _GLFWmonitor;\ntypedef struct _GLFWcursor      _GLFWcursor;\n\n#if defined(_GLFW_COCOA)\n #include \"cocoa_platform.h\"\n#elif defined(_GLFW_WIN32)\n #include \"win32_platform.h\"\n#elif defined(_GLFW_X11)\n #include \"x11_platform.h\"\n#elif defined(_GLFW_WAYLAND)\n #include \"wl_platform.h\"\n#elif defined(_GLFW_MIR)\n #include \"mir_platform.h\"\n#else\n #error \"No supported window creation API selected\"\n#endif\n\n\n//========================================================================\n// Doxygen group definitions\n//========================================================================\n\n/*! @defgroup platform Platform interface\n *  @brief The interface implemented by the platform-specific code.\n *\n *  The platform API is the interface exposed by the platform-specific code for\n *  each platform and is called by the shared code of the public API It mirrors\n *  the public API except it uses objects instead of handles.\n */\n/*! @defgroup event Event interface\n *  @brief The interface used by the platform-specific code to report events.\n *\n *  The event API is used by the platform-specific code to notify the shared\n *  code of events that can be translated into state changes and/or callback\n *  calls.\n */\n/*! @defgroup utility Utility functions\n *  @brief Various utility functions for internal use.\n *\n *  These functions are shared code and may be used by any part of GLFW\n *  Each platform may add its own utility functions, but those may only be\n *  called by the platform-specific code\n */\n\n\n//========================================================================\n// Helper macros\n//========================================================================\n\n// Checks for whether the library has been initialized\n#define _GLFW_REQUIRE_INIT()                         \\\n    if (!_glfwInitialized)                           \\\n    {                                                \\\n        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \\\n        return;                                      \\\n    }\n#define _GLFW_REQUIRE_INIT_OR_RETURN(x)              \\\n    if (!_glfwInitialized)                           \\\n    {                                                \\\n        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \\\n        return x;                                    \\\n    }\n\n// Swaps the provided pointers\n#define _GLFW_SWAP_POINTERS(x, y) \\\n    {                             \\\n        void* t;                  \\\n        t = x;                    \\\n        x = y;                    \\\n        y = t;                    \\\n    }\n\n\n//========================================================================\n// Platform-independent structures\n//========================================================================\n\n/*! @brief Window configuration.\n *\n *  Parameters relating to the creation of the window but not directly related\n *  to the framebuffer.  This is used to pass window creation parameters from\n *  shared code to the platform API.\n */\nstruct _GLFWwndconfig\n{\n    int           width;\n    int           height;\n    const char*   title;\n    GLboolean     resizable;\n    GLboolean     visible;\n    GLboolean     decorated;\n    GLboolean     focused;\n    GLboolean     autoIconify;\n    GLboolean     floating;\n    _GLFWmonitor* monitor;\n};\n\n\n/*! @brief Context configuration.\n *\n *  Parameters relating to the creation of the context but not directly related\n *  to the framebuffer.  This is used to pass context creation parameters from\n *  shared code to the platform API.\n */\nstruct _GLFWctxconfig\n{\n    int           api;\n    int           major;\n    int           minor;\n    GLboolean     forward;\n    GLboolean     debug;\n    int           profile;\n    int           robustness;\n    int           release;\n    _GLFWwindow*  share;\n};\n\n\n/*! @brief Framebuffer configuration.\n *\n *  This describes buffers and their sizes.  It also contains\n *  a platform-specific ID used to map back to the backend API object.\n *\n *  It is used to pass framebuffer parameters from shared code to the platform\n *  API and also to enumerate and select available framebuffer configs.\n */\nstruct _GLFWfbconfig\n{\n    int         redBits;\n    int         greenBits;\n    int         blueBits;\n    int         alphaBits;\n    int         depthBits;\n    int         stencilBits;\n    int         accumRedBits;\n    int         accumGreenBits;\n    int         accumBlueBits;\n    int         accumAlphaBits;\n    int         auxBuffers;\n    int         stereo;\n    int         samples;\n    int         sRGB;\n    int         doublebuffer;\n\n    // This is defined in the context API's context.h\n    _GLFW_PLATFORM_FBCONFIG;\n};\n\n\n/*! @brief Window and context structure.\n */\nstruct _GLFWwindow\n{\n    struct _GLFWwindow* next;\n\n    // Window settings and state\n    GLboolean           resizable;\n    GLboolean           decorated;\n    GLboolean           autoIconify;\n    GLboolean           floating;\n    GLboolean           closed;\n    void*               userPointer;\n    GLFWvidmode         videoMode;\n    _GLFWmonitor*       monitor;\n    _GLFWcursor*        cursor;\n\n    // Window input state\n    GLboolean           stickyKeys;\n    GLboolean           stickyMouseButtons;\n    double              cursorPosX, cursorPosY;\n    int                 cursorMode;\n    char                mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];\n    char                keys[GLFW_KEY_LAST + 1];\n\n    // OpenGL extensions and context attributes\n    struct {\n        int             api;\n        int             major, minor, revision;\n        GLboolean       forward, debug;\n        int             profile;\n        int             robustness;\n        int             release;\n    } context;\n\n#if defined(_GLFW_USE_OPENGL)\n    PFNGLGETSTRINGIPROC GetStringi;\n#endif\n    PFNGLGETINTEGERVPROC GetIntegerv;\n    PFNGLGETSTRINGPROC  GetString;\n    PFNGLCLEARPROC      Clear;\n\n    struct {\n        GLFWwindowposfun        pos;\n        GLFWwindowsizefun       size;\n        GLFWwindowclosefun      close;\n        GLFWwindowrefreshfun    refresh;\n        GLFWwindowfocusfun      focus;\n        GLFWwindowiconifyfun    iconify;\n        GLFWframebuffersizefun  fbsize;\n        GLFWmousebuttonfun      mouseButton;\n        GLFWcursorposfun        cursorPos;\n        GLFWcursorenterfun      cursorEnter;\n        GLFWscrollfun           scroll;\n        GLFWkeyfun              key;\n        GLFWcharfun             character;\n        GLFWcharmodsfun         charmods;\n        GLFWdropfun             drop;\n    } callbacks;\n\n    // This is defined in the window API's platform.h\n    _GLFW_PLATFORM_WINDOW_STATE;\n    // This is defined in the context API's context.h\n    _GLFW_PLATFORM_CONTEXT_STATE;\n};\n\n\n/*! @brief Monitor structure.\n */\nstruct _GLFWmonitor\n{\n    char*           name;\n\n    // Physical dimensions in millimeters.\n    int             widthMM, heightMM;\n\n    GLFWvidmode*    modes;\n    int             modeCount;\n    GLFWvidmode     currentMode;\n\n    GLFWgammaramp   originalRamp;\n    GLFWgammaramp   currentRamp;\n\n    // This is defined in the window API's platform.h\n    _GLFW_PLATFORM_MONITOR_STATE;\n};\n\n\n/*! @brief Cursor structure\n */\nstruct _GLFWcursor\n{\n    _GLFWcursor*    next;\n\n    // This is defined in the window API's platform.h\n    _GLFW_PLATFORM_CURSOR_STATE;\n};\n\n/*! @brief Library global data.\n */\nstruct _GLFWlibrary\n{\n    struct {\n        _GLFWfbconfig   framebuffer;\n        _GLFWwndconfig  window;\n        _GLFWctxconfig  context;\n        int             refreshRate;\n    } hints;\n\n    double              cursorPosX, cursorPosY;\n\n    _GLFWcursor*        cursorListHead;\n\n    _GLFWwindow*        windowListHead;\n    _GLFWwindow*        cursorWindow;\n\n    _GLFWmonitor**      monitors;\n    int                 monitorCount;\n\n    struct {\n        GLFWmonitorfun  monitor;\n    } callbacks;\n\n    // This is defined in the window API's platform.h\n    _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;\n    // This is defined in the context API's context.h\n    _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;\n    // This is defined in the platform's time.h\n    _GLFW_PLATFORM_LIBRARY_TIME_STATE;\n    // This is defined in the platform's joystick.h\n    _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;\n    // This is defined in the platform's tls.h\n    _GLFW_PLATFORM_LIBRARY_TLS_STATE;\n};\n\n\n//========================================================================\n// Global state shared between compilation units of GLFW\n//========================================================================\n\n/*! @brief Flag indicating whether GLFW has been successfully initialized.\n */\nextern GLboolean _glfwInitialized;\n\n/*! @brief All global data protected by @ref _glfwInitialized.\n *  This should only be touched after a call to @ref glfwInit that has not been\n *  followed by a call to @ref glfwTerminate.\n */\nextern _GLFWlibrary _glfw;\n\n\n//========================================================================\n// Platform API functions\n//========================================================================\n\n/*! @brief Initializes the platform-specific part of the library.\n *  @return `GL_TRUE` if successful, or `GL_FALSE` if an error occurred.\n *  @ingroup platform\n */\nint _glfwPlatformInit(void);\n\n/*! @brief Terminates the platform-specific part of the library.\n *  @ingroup platform\n */\nvoid _glfwPlatformTerminate(void);\n\n/*! @copydoc glfwGetVersionString\n *  @ingroup platform\n *\n *  @note The returned string must be available for the duration of the program.\n *\n *  @note The returned string must not change for the duration of the program.\n */\nconst char* _glfwPlatformGetVersionString(void);\n\n/*! @copydoc glfwGetCursorPos\n *  @ingroup platform\n */\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);\n\n/*! @copydoc glfwSetCursorPos\n *  @ingroup platform\n */\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);\n\n/*! @brief Applies the cursor mode of the specified window to the system.\n *  @param[in] window The window whose cursor mode to apply.\n *  @ingroup platform\n */\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window);\n\n/*! @copydoc glfwGetMonitors\n *  @ingroup platform\n */\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count);\n\n/*! @brief Checks whether two monitor objects represent the same monitor.\n *\n *  @param[in] first The first monitor.\n *  @param[in] second The second monitor.\n *  @return @c GL_TRUE if the monitor objects represent the same monitor, or @c\n *  GL_FALSE otherwise.\n *  @ingroup platform\n */\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second);\n\n/*! @copydoc glfwGetMonitorPos\n *  @ingroup platform\n */\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);\n\n/*! @copydoc glfwGetVideoModes\n *  @ingroup platform\n */\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);\n\n/*! @ingroup platform\n */\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);\n\n/*! @copydoc glfwGetGammaRamp\n *  @ingroup platform\n */\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);\n\n/*! @copydoc glfwSetGammaRamp\n *  @ingroup platform\n */\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);\n\n/*! @copydoc glfwSetClipboardString\n *  @ingroup platform\n */\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string);\n\n/*! @copydoc glfwGetClipboardString\n *  @ingroup platform\n *\n *  @note The returned string must be valid until the next call to @ref\n *  _glfwPlatformGetClipboardString or @ref _glfwPlatformSetClipboardString.\n */\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window);\n\n/*! @copydoc glfwJoystickPresent\n *  @ingroup platform\n */\nint _glfwPlatformJoystickPresent(int joy);\n\n/*! @copydoc glfwGetJoystickAxes\n *  @ingroup platform\n */\nconst float* _glfwPlatformGetJoystickAxes(int joy, int* count);\n\n/*! @copydoc glfwGetJoystickButtons\n *  @ingroup platform\n */\nconst unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count);\n\n/*! @copydoc glfwGetJoystickName\n *  @ingroup platform\n */\nconst char* _glfwPlatformGetJoystickName(int joy);\n\n/*! @copydoc glfwGetTime\n *  @ingroup platform\n */\ndouble _glfwPlatformGetTime(void);\n\n/*! @copydoc glfwSetTime\n *  @ingroup platform\n */\nvoid _glfwPlatformSetTime(double time);\n\n/*! @ingroup platform\n */\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig);\n\n/*! @ingroup platform\n */\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window);\n\n/*! @copydoc glfwSetWindowTitle\n *  @ingroup platform\n */\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);\n\n/*! @copydoc glfwGetWindowPos\n *  @ingroup platform\n */\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);\n\n/*! @copydoc glfwSetWindowPos\n *  @ingroup platform\n */\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);\n\n/*! @copydoc glfwGetWindowSize\n *  @ingroup platform\n */\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);\n\n/*! @copydoc glfwSetWindowSize\n *  @ingroup platform\n */\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);\n\n/*! @copydoc glfwGetFramebufferSize\n *  @ingroup platform\n */\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);\n\n/*! @copydoc glfwGetWindowFrameSize\n *  @ingroup platform\n */\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom);\n\n/*! @copydoc glfwIconifyWindow\n *  @ingroup platform\n */\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window);\n\n/*! @copydoc glfwRestoreWindow\n *  @ingroup platform\n */\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window);\n\n/*! @copydoc glfwShowWindow\n *  @ingroup platform\n */\nvoid _glfwPlatformShowWindow(_GLFWwindow* window);\n\n/*! @ingroup platform\n */\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window);\n\n/*! @copydoc glfwHideWindow\n *  @ingroup platform\n */\nvoid _glfwPlatformHideWindow(_GLFWwindow* window);\n\n/*! @brief Returns whether the window is focused.\n *  @ingroup platform\n */\nint _glfwPlatformWindowFocused(_GLFWwindow* window);\n\n/*! @brief Returns whether the window is iconified.\n *  @ingroup platform\n */\nint _glfwPlatformWindowIconified(_GLFWwindow* window);\n\n/*! @brief Returns whether the window is visible.\n *  @ingroup platform\n */\nint _glfwPlatformWindowVisible(_GLFWwindow* window);\n\n/*! @copydoc glfwPollEvents\n *  @ingroup platform\n */\nvoid _glfwPlatformPollEvents(void);\n\n/*! @copydoc glfwWaitEvents\n *  @ingroup platform\n */\nvoid _glfwPlatformWaitEvents(void);\n\n/*! @copydoc glfwPostEmptyEvent\n *  @ingroup platform\n */\nvoid _glfwPlatformPostEmptyEvent(void);\n\n/*! @copydoc glfwMakeContextCurrent\n *  @ingroup platform\n */\nvoid _glfwPlatformMakeContextCurrent(_GLFWwindow* window);\n\n/*! @copydoc glfwGetCurrentContext\n *  @ingroup platform\n */\n_GLFWwindow* _glfwPlatformGetCurrentContext(void);\n\n/*! @copydoc glfwSwapBuffers\n *  @ingroup platform\n */\nvoid _glfwPlatformSwapBuffers(_GLFWwindow* window);\n\n/*! @copydoc glfwSwapInterval\n *  @ingroup platform\n */\nvoid _glfwPlatformSwapInterval(int interval);\n\n/*! @copydoc glfwExtensionSupported\n *  @ingroup platform\n */\nint _glfwPlatformExtensionSupported(const char* extension);\n\n/*! @copydoc glfwGetProcAddress\n *  @ingroup platform\n */\nGLFWglproc _glfwPlatformGetProcAddress(const char* procname);\n\n/*! @copydoc glfwCreateCursor\n *  @ingroup platform\n */\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot);\n\n/*! @copydoc glfwCreateStandardCursor\n *  @ingroup platform\n */\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);\n\n/*! @copydoc glfwDestroyCursor\n *  @ingroup platform\n */\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor);\n\n/*! @copydoc glfwSetCursor\n *  @ingroup platform\n */\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);\n\n\n//========================================================================\n// Event API functions\n//========================================================================\n\n/*! @brief Notifies shared code of a window focus event.\n *  @param[in] window The window that received the event.\n *  @param[in] focused `GL_TRUE` if the window received focus, or `GL_FALSE`\n *  if it lost focus.\n *  @ingroup event\n */\nvoid _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused);\n\n/*! @brief Notifies shared code of a window movement event.\n *  @param[in] window The window that received the event.\n *  @param[in] xpos The new x-coordinate of the client area of the window.\n *  @param[in] ypos The new y-coordinate of the client area of the window.\n *  @ingroup event\n */\nvoid _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);\n\n/*! @brief Notifies shared code of a window resize event.\n *  @param[in] window The window that received the event.\n *  @param[in] width The new width of the client area of the window.\n *  @param[in] height The new height of the client area of the window.\n *  @ingroup event\n */\nvoid _glfwInputWindowSize(_GLFWwindow* window, int width, int height);\n\n/*! @brief Notifies shared code of a framebuffer resize event.\n *  @param[in] window The window that received the event.\n *  @param[in] width The new width, in pixels, of the framebuffer.\n *  @param[in] height The new height, in pixels, of the framebuffer.\n *  @ingroup event\n */\nvoid _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);\n\n/*! @brief Notifies shared code of a window iconification event.\n *  @param[in] window The window that received the event.\n *  @param[in] iconified `GL_TRUE` if the window was iconified, or `GL_FALSE`\n *  if it was restored.\n *  @ingroup event\n */\nvoid _glfwInputWindowIconify(_GLFWwindow* window, int iconified);\n\n/*! @brief Notifies shared code of a window damage event.\n *  @param[in] window The window that received the event.\n */\nvoid _glfwInputWindowDamage(_GLFWwindow* window);\n\n/*! @brief Notifies shared code of a window close request event\n *  @param[in] window The window that received the event.\n *  @ingroup event\n */\nvoid _glfwInputWindowCloseRequest(_GLFWwindow* window);\n\n/*! @brief Notifies shared code of a physical key event.\n *  @param[in] window The window that received the event.\n *  @param[in] key The key that was pressed or released.\n *  @param[in] scancode The system-specific scan code of the key.\n *  @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.\n *  @param[in] mods The modifiers pressed when the event was generated.\n *  @ingroup event\n */\nvoid _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods);\n\n/*! @brief Notifies shared code of a Unicode character input event.\n *  @param[in] window The window that received the event.\n *  @param[in] codepoint The Unicode code point of the input character.\n *  @param[in] mods Bit field describing which modifier keys were held down.\n *  @param[in] plain `GL_TRUE` if the character is regular text input, or\n *  `GL_FALSE` otherwise.\n *  @ingroup event\n */\nvoid _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, int plain);\n\n/*! @brief Notifies shared code of a scroll event.\n *  @param[in] window The window that received the event.\n *  @param[in] x The scroll offset along the x-axis.\n *  @param[in] y The scroll offset along the y-axis.\n *  @ingroup event\n */\nvoid _glfwInputScroll(_GLFWwindow* window, double x, double y);\n\n/*! @brief Notifies shared code of a mouse button click event.\n *  @param[in] window The window that received the event.\n *  @param[in] button The button that was pressed or released.\n *  @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE.\n *  @ingroup event\n */\nvoid _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);\n\n/*! @brief Notifies shared code of a cursor motion event.\n *  @param[in] window The window that received the event.\n *  @param[in] x The new x-coordinate of the cursor, relative to the left edge\n *  of the client area of the window.\n *  @param[in] y The new y-coordinate of the cursor, relative to the top edge\n *  of the client area of the window.\n *  @ingroup event\n */\nvoid _glfwInputCursorMotion(_GLFWwindow* window, double x, double y);\n\n/*! @brief Notifies shared code of a cursor enter/leave event.\n *  @param[in] window The window that received the event.\n *  @param[in] entered `GL_TRUE` if the cursor entered the client area of the\n *  window, or `GL_FALSE` if it left it.\n *  @ingroup event\n */\nvoid _glfwInputCursorEnter(_GLFWwindow* window, int entered);\n\n/*! @ingroup event\n */\nvoid _glfwInputMonitorChange(void);\n\n/*! @brief Notifies shared code of an error.\n *  @param[in] error The error code most suitable for the error.\n *  @param[in] format The `printf` style format string of the error\n *  description.\n *  @ingroup event\n */\nvoid _glfwInputError(int error, const char* format, ...);\n\n/*! @brief Notifies dropped object over window.\n *  @param[in] window The window that received the event.\n *  @param[in] count The number of dropped objects.\n *  @param[in] names The names of the dropped objects.\n *  @ingroup event\n */\nvoid _glfwInputDrop(_GLFWwindow* window, int count, const char** names);\n\n\n//========================================================================\n// Utility functions\n//========================================================================\n\n/*! @ingroup utility\n */\nconst GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,\n                                        const GLFWvidmode* desired);\n\n/*! @brief Performs lexical comparison between two @ref GLFWvidmode structures.\n *  @ingroup utility\n */\nint _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);\n\n/*! @brief Splits a color depth into red, green and blue bit depths.\n *  @ingroup utility\n */\nvoid _glfwSplitBPP(int bpp, int* red, int* green, int* blue);\n\n/*! @brief Searches an extension string for the specified extension.\n *  @param[in] string The extension string to search.\n *  @param[in] extensions The extension to search for.\n *  @return `GL_TRUE` if the extension was found, or `GL_FALSE` otherwise.\n *  @ingroup utility\n */\nint _glfwStringInExtensionString(const char* string, const char* extensions);\n\n/*! @brief Chooses the framebuffer config that best matches the desired one.\n *  @param[in] desired The desired framebuffer config.\n *  @param[in] alternatives The framebuffer configs supported by the system.\n *  @param[in] count The number of entries in the alternatives array.\n *  @return The framebuffer config most closely matching the desired one, or @c\n *  NULL if none fulfilled the hard constraints of the desired values.\n *  @ingroup utility\n */\nconst _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,\n                                         const _GLFWfbconfig* alternatives,\n                                         unsigned int count);\n\n/*! @brief Retrieves the attributes of the current context.\n *  @param[in] ctxconfig The desired context attributes.\n *  @return `GL_TRUE` if successful, or `GL_FALSE` if the context is unusable.\n *  @ingroup utility\n */\nGLboolean _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);\n\n/*! @brief Checks whether the desired context attributes are valid.\n *  @param[in] ctxconfig The context attributes to check.\n *  @return `GL_TRUE` if the context attributes are valid, or `GL_FALSE`\n *  otherwise.\n *  @ingroup utility\n *\n *  This function checks things like whether the specified client API version\n *  exists and whether all relevant options have supported and non-conflicting\n *  values.\n */\nGLboolean _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);\n\n/*! @brief Checks whether the current context fulfils the specified hard\n *  constraints.\n *  @param[in] ctxconfig The desired context attributes.\n *  @return `GL_TRUE` if the context fulfils the hard constraints, or `GL_FALSE`\n *  otherwise.\n *  @ingroup utility\n */\nGLboolean _glfwIsValidContext(const _GLFWctxconfig* ctxconfig);\n\n/*! @ingroup utility\n */\nvoid _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);\n\n/*! @ingroup utility\n */\nvoid _glfwFreeGammaArrays(GLFWgammaramp* ramp);\n\n/*! @brief Allocates and returns a monitor object with the specified name\n *  and dimensions.\n *  @param[in] name The name of the monitor.\n *  @param[in] widthMM The width, in mm, of the monitor's display area.\n *  @param[in] heightMM The height, in mm, of the monitor's display area.\n *  @return The newly created object.\n *  @ingroup utility\n */\n_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);\n\n/*! @brief Frees a monitor object and any data associated with it.\n *  @ingroup utility\n  */\nvoid _glfwFreeMonitor(_GLFWmonitor* monitor);\n\n/*! @ingroup utility\n  */\nvoid _glfwFreeMonitors(_GLFWmonitor** monitors, int count);\n\n#endif // _glfw3_internal_h_\n"
  },
  {
    "path": "deps/glfw/src/iokit_joystick.h",
    "content": "//========================================================================\n// GLFW 3.1 IOKit - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2006-2014 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_iokit_joystick_h_\n#define _glfw3_iokit_joystick_h_\n\n#include <IOKit/IOKitLib.h>\n#include <IOKit/IOCFPlugIn.h>\n#include <IOKit/hid/IOHIDLib.h>\n#include <IOKit/hid/IOHIDKeys.h>\n\n#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \\\n    _GLFWjoystickIOKit iokit_js\n\n\n// IOKit-specific per-joystick data\n//\ntypedef struct _GLFWjoydevice\n{\n    int             present;\n    char            name[256];\n\n    IOHIDDeviceRef deviceRef;\n\n    CFMutableArrayRef axisElements;\n    CFMutableArrayRef buttonElements;\n    CFMutableArrayRef hatElements;\n\n    float*          axes;\n    unsigned char*  buttons;\n} _GLFWjoydevice;\n\n// IOKit-specific joystick API data\n//\ntypedef struct _GLFWjoystickIOKit\n{\n    _GLFWjoydevice devices[GLFW_JOYSTICK_LAST + 1];\n\n    IOHIDManagerRef managerRef;\n} _GLFWjoystickIOKit;\n\nvoid _glfwInitJoysticks(void);\nvoid _glfwTerminateJoysticks(void);\n\n#endif // _glfw3_iokit_joystick_h_\n"
  },
  {
    "path": "deps/glfw/src/iokit_joystick.m",
    "content": "//========================================================================\n// GLFW 3.1 IOKit - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <unistd.h>\n#include <ctype.h>\n\n#include <mach/mach.h>\n#include <mach/mach_error.h>\n\n#include <CoreFoundation/CoreFoundation.h>\n#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>\n\n\n//------------------------------------------------------------------------\n// Joystick element information\n//------------------------------------------------------------------------\ntypedef struct\n{\n    IOHIDElementRef elementRef;\n\n    long min;\n    long max;\n\n    long minReport;\n    long maxReport;\n\n} _GLFWjoyelement;\n\n\nstatic void getElementsCFArrayHandler(const void* value, void* parameter);\n\n// Adds an element to the specified joystick\n//\nstatic void addJoystickElement(_GLFWjoydevice* joystick,\n                               IOHIDElementRef elementRef)\n{\n    IOHIDElementType elementType;\n    long usagePage, usage;\n    CFMutableArrayRef elementsArray = NULL;\n\n    elementType = IOHIDElementGetType(elementRef);\n    usagePage = IOHIDElementGetUsagePage(elementRef);\n    usage = IOHIDElementGetUsage(elementRef);\n\n    if ((elementType != kIOHIDElementTypeInput_Axis) &&\n        (elementType != kIOHIDElementTypeInput_Button) &&\n        (elementType != kIOHIDElementTypeInput_Misc))\n    {\n        return;\n    }\n\n    switch (usagePage)\n    {\n        case kHIDPage_GenericDesktop:\n        {\n            switch (usage)\n            {\n                case kHIDUsage_GD_X:\n                case kHIDUsage_GD_Y:\n                case kHIDUsage_GD_Z:\n                case kHIDUsage_GD_Rx:\n                case kHIDUsage_GD_Ry:\n                case kHIDUsage_GD_Rz:\n                case kHIDUsage_GD_Slider:\n                case kHIDUsage_GD_Dial:\n                case kHIDUsage_GD_Wheel:\n                    elementsArray = joystick->axisElements;\n                    break;\n                case kHIDUsage_GD_Hatswitch:\n                    elementsArray = joystick->hatElements;\n                    break;\n            }\n\n            break;\n        }\n\n        case kHIDPage_Button:\n            elementsArray = joystick->buttonElements;\n            break;\n        default:\n            break;\n    }\n\n    if (elementsArray)\n    {\n        _GLFWjoyelement* element = calloc(1, sizeof(_GLFWjoyelement));\n\n        CFArrayAppendValue(elementsArray, element);\n\n        element->elementRef = elementRef;\n\n        element->minReport = IOHIDElementGetLogicalMin(elementRef);\n        element->maxReport = IOHIDElementGetLogicalMax(elementRef);\n    }\n}\n\n// Adds an element to the specified joystick\n//\nstatic void getElementsCFArrayHandler(const void* value, void* parameter)\n{\n    if (CFGetTypeID(value) == IOHIDElementGetTypeID())\n    {\n        addJoystickElement((_GLFWjoydevice*) parameter,\n                           (IOHIDElementRef) value);\n    }\n}\n\n// Returns the value of the specified element of the specified joystick\n//\nstatic long getElementValue(_GLFWjoydevice* joystick, _GLFWjoyelement* element)\n{\n    IOReturn result = kIOReturnSuccess;\n    IOHIDValueRef valueRef;\n    long value = 0;\n\n    if (joystick && element && joystick->deviceRef)\n    {\n        result = IOHIDDeviceGetValue(joystick->deviceRef,\n                                     element->elementRef,\n                                     &valueRef);\n\n        if (kIOReturnSuccess == result)\n        {\n            value = IOHIDValueGetIntegerValue(valueRef);\n\n            // Record min and max for auto calibration\n            if (value < element->minReport)\n                element->minReport = value;\n            if (value > element->maxReport)\n                element->maxReport = value;\n        }\n    }\n\n    // Auto user scale\n    return value;\n}\n\n// Removes the specified joystick\n//\nstatic void removeJoystick(_GLFWjoydevice* joystick)\n{\n    int i;\n\n    if (!joystick->present)\n        return;\n\n    for (i = 0;  i < CFArrayGetCount(joystick->axisElements);  i++)\n        free((void*) CFArrayGetValueAtIndex(joystick->axisElements, i));\n    CFArrayRemoveAllValues(joystick->axisElements);\n    CFRelease(joystick->axisElements);\n\n    for (i = 0;  i < CFArrayGetCount(joystick->buttonElements);  i++)\n        free((void*) CFArrayGetValueAtIndex(joystick->buttonElements, i));\n    CFArrayRemoveAllValues(joystick->buttonElements);\n    CFRelease(joystick->buttonElements);\n\n    for (i = 0;  i < CFArrayGetCount(joystick->hatElements);  i++)\n        free((void*) CFArrayGetValueAtIndex(joystick->hatElements, i));\n    CFArrayRemoveAllValues(joystick->hatElements);\n    CFRelease(joystick->hatElements);\n\n    free(joystick->axes);\n    free(joystick->buttons);\n\n    memset(joystick, 0, sizeof(_GLFWjoydevice));\n}\n\n// Polls for joystick events and updates GLFW state\n//\nstatic void pollJoystickEvents(void)\n{\n    int joy;\n\n    for (joy = 0;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        CFIndex i;\n        int buttonIndex = 0;\n        _GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;\n\n        if (!joystick->present)\n            continue;\n\n        for (i = 0;  i < CFArrayGetCount(joystick->buttonElements);  i++)\n        {\n            _GLFWjoyelement* button = (_GLFWjoyelement*)\n                CFArrayGetValueAtIndex(joystick->buttonElements, i);\n\n            if (getElementValue(joystick, button))\n                joystick->buttons[buttonIndex++] = GLFW_PRESS;\n            else\n                joystick->buttons[buttonIndex++] = GLFW_RELEASE;\n        }\n\n        for (i = 0;  i < CFArrayGetCount(joystick->axisElements);  i++)\n        {\n            _GLFWjoyelement* axis = (_GLFWjoyelement*)\n                CFArrayGetValueAtIndex(joystick->axisElements, i);\n\n            long value = getElementValue(joystick, axis);\n            long readScale = axis->maxReport - axis->minReport;\n\n            if (readScale == 0)\n                joystick->axes[i] = value;\n            else\n                joystick->axes[i] = (2.f * (value - axis->minReport) / readScale) - 1.f;\n        }\n\n        for (i = 0;  i < CFArrayGetCount(joystick->hatElements);  i++)\n        {\n            _GLFWjoyelement* hat = (_GLFWjoyelement*)\n                CFArrayGetValueAtIndex(joystick->hatElements, i);\n\n            // Bit fields of button presses for each direction, including nil\n            const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 };\n\n            long j, value = getElementValue(joystick, hat);\n            if (value < 0 || value > 8)\n                value = 8;\n\n            for (j = 0;  j < 4;  j++)\n            {\n                if (directions[value] & (1 << j))\n                    joystick->buttons[buttonIndex++] = GLFW_PRESS;\n                else\n                    joystick->buttons[buttonIndex++] = GLFW_RELEASE;\n            }\n        }\n    }\n}\n\n// Callback for user-initiated joystick addition\n//\nstatic void matchCallback(void* context,\n                          IOReturn result,\n                          void* sender,\n                          IOHIDDeviceRef deviceRef)\n{\n    _GLFWjoydevice* joystick;\n    int joy;\n\n    for (joy = GLFW_JOYSTICK_1;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        joystick = _glfw.iokit_js.devices + joy;\n\n        if (!joystick->present)\n            continue;\n\n        if (joystick->deviceRef == deviceRef)\n            return;\n    }\n\n    for (joy = GLFW_JOYSTICK_1;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        joystick = _glfw.iokit_js.devices + joy;\n\n        if (!joystick->present)\n            break;\n    }\n\n    if (joy > GLFW_JOYSTICK_LAST)\n        return;\n\n    joystick->present = GL_TRUE;\n    joystick->deviceRef = deviceRef;\n\n    CFStringRef name = IOHIDDeviceGetProperty(deviceRef,\n                                              CFSTR(kIOHIDProductKey));\n    CFStringGetCString(name,\n                       joystick->name,\n                       sizeof(joystick->name),\n                       kCFStringEncodingUTF8);\n\n    joystick->axisElements = CFArrayCreateMutable(NULL, 0, NULL);\n    joystick->buttonElements = CFArrayCreateMutable(NULL, 0, NULL);\n    joystick->hatElements = CFArrayCreateMutable(NULL, 0, NULL);\n\n    CFArrayRef arrayRef = IOHIDDeviceCopyMatchingElements(deviceRef,\n                                                          NULL,\n                                                          kIOHIDOptionsTypeNone);\n    CFRange range = { 0, CFArrayGetCount(arrayRef) };\n    CFArrayApplyFunction(arrayRef,\n                         range,\n                         getElementsCFArrayHandler,\n                         (void*) joystick);\n\n    CFRelease(arrayRef);\n\n    joystick->axes = calloc(CFArrayGetCount(joystick->axisElements),\n                            sizeof(float));\n    joystick->buttons = calloc(CFArrayGetCount(joystick->buttonElements) +\n                               CFArrayGetCount(joystick->hatElements) * 4, 1);\n}\n\n// Callback for user-initiated joystick removal\n//\nstatic void removeCallback(void* context,\n                           IOReturn result,\n                           void* sender,\n                           IOHIDDeviceRef deviceRef)\n{\n    int joy;\n\n    for (joy = GLFW_JOYSTICK_1;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        _GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;\n        if (joystick->deviceRef == deviceRef)\n        {\n            removeJoystick(joystick);\n            break;\n        }\n    }\n}\n\n// Creates a dictionary to match against devices with the specified usage page\n// and usage\n//\nstatic CFMutableDictionaryRef createMatchingDictionary(long usagePage,\n                                                       long usage)\n{\n    CFMutableDictionaryRef result =\n        CFDictionaryCreateMutable(kCFAllocatorDefault,\n                                  0,\n                                  &kCFTypeDictionaryKeyCallBacks,\n                                  &kCFTypeDictionaryValueCallBacks);\n\n    if (result)\n    {\n        CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,\n                                             kCFNumberLongType,\n                                             &usagePage);\n        if (pageRef)\n        {\n            CFDictionarySetValue(result,\n                                 CFSTR(kIOHIDDeviceUsagePageKey),\n                                 pageRef);\n            CFRelease(pageRef);\n\n            CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,\n                                                  kCFNumberLongType,\n                                                  &usage);\n            if (usageRef)\n            {\n                CFDictionarySetValue(result,\n                                     CFSTR(kIOHIDDeviceUsageKey),\n                                     usageRef);\n                CFRelease(usageRef);\n            }\n        }\n    }\n\n    return result;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize joystick interface\n//\nvoid _glfwInitJoysticks(void)\n{\n    CFMutableArrayRef matchingCFArrayRef;\n\n    _glfw.iokit_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,\n                                                   kIOHIDOptionsTypeNone);\n\n    matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault,\n                                              0,\n                                              &kCFTypeArrayCallBacks);\n    if (matchingCFArrayRef)\n    {\n        CFDictionaryRef matchingCFDictRef =\n            createMatchingDictionary(kHIDPage_GenericDesktop,\n                                     kHIDUsage_GD_Joystick);\n        if (matchingCFDictRef)\n        {\n            CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);\n            CFRelease(matchingCFDictRef);\n        }\n\n        matchingCFDictRef = createMatchingDictionary(kHIDPage_GenericDesktop,\n                                                     kHIDUsage_GD_GamePad);\n        if (matchingCFDictRef)\n        {\n            CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);\n            CFRelease(matchingCFDictRef);\n        }\n\n        matchingCFDictRef =\n            createMatchingDictionary(kHIDPage_GenericDesktop,\n                                     kHIDUsage_GD_MultiAxisController);\n        if (matchingCFDictRef)\n        {\n            CFArrayAppendValue(matchingCFArrayRef, matchingCFDictRef);\n            CFRelease(matchingCFDictRef);\n        }\n\n        IOHIDManagerSetDeviceMatchingMultiple(_glfw.iokit_js.managerRef,\n                                              matchingCFArrayRef);\n        CFRelease(matchingCFArrayRef);\n    }\n\n    IOHIDManagerRegisterDeviceMatchingCallback(_glfw.iokit_js.managerRef,\n                                               &matchCallback, NULL);\n    IOHIDManagerRegisterDeviceRemovalCallback(_glfw.iokit_js.managerRef,\n                                              &removeCallback, NULL);\n\n    IOHIDManagerScheduleWithRunLoop(_glfw.iokit_js.managerRef,\n                                    CFRunLoopGetMain(),\n                                    kCFRunLoopDefaultMode);\n\n    IOHIDManagerOpen(_glfw.iokit_js.managerRef, kIOHIDOptionsTypeNone);\n\n    // Execute the run loop once in order to register any initially-attached\n    // joysticks\n    CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);\n}\n\n// Close all opened joystick handles\n//\nvoid _glfwTerminateJoysticks(void)\n{\n    int joy;\n\n    for (joy = 0;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        _GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;\n        removeJoystick(joystick);\n    }\n\n    CFRelease(_glfw.iokit_js.managerRef);\n    _glfw.iokit_js.managerRef = NULL;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformJoystickPresent(int joy)\n{\n    pollJoystickEvents();\n\n    return _glfw.iokit_js.devices[joy].present;\n}\n\nconst float* _glfwPlatformGetJoystickAxes(int joy, int* count)\n{\n    _GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;\n\n    pollJoystickEvents();\n\n    if (!joystick->present)\n        return NULL;\n\n    *count = (int) CFArrayGetCount(joystick->axisElements);\n    return joystick->axes;\n}\n\nconst unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)\n{\n    _GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;\n\n    pollJoystickEvents();\n\n    if (!joystick->present)\n        return NULL;\n\n    *count = (int) CFArrayGetCount(joystick->buttonElements) +\n             (int) CFArrayGetCount(joystick->hatElements) * 4;\n    return joystick->buttons;\n}\n\nconst char* _glfwPlatformGetJoystickName(int joy)\n{\n    pollJoystickEvents();\n\n    return _glfw.iokit_js.devices[joy].name;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/linux_joystick.c",
    "content": "//========================================================================\n// GLFW 3.1 Linux - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#if defined(__linux__)\n#include <linux/joystick.h>\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <sys/inotify.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <dirent.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#endif // __linux__\n\n\n// Attempt to open the specified joystick device\n//\nstatic void openJoystickDevice(const char* path)\n{\n#if defined(__linux__)\n    char axisCount, buttonCount;\n    char name[256];\n    int joy, fd, version;\n\n    for (joy = GLFW_JOYSTICK_1;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        if (!_glfw.linux_js.js[joy].present)\n            continue;\n\n        if (strcmp(_glfw.linux_js.js[joy].path, path) == 0)\n            return;\n    }\n\n    for (joy = GLFW_JOYSTICK_1;  joy <= GLFW_JOYSTICK_LAST;  joy++)\n    {\n        if (!_glfw.linux_js.js[joy].present)\n            break;\n    }\n\n    if (joy > GLFW_JOYSTICK_LAST)\n        return;\n\n    fd = open(path, O_RDONLY | O_NONBLOCK);\n    if (fd == -1)\n        return;\n\n    _glfw.linux_js.js[joy].fd = fd;\n\n    // Verify that the joystick driver version is at least 1.0\n    ioctl(fd, JSIOCGVERSION, &version);\n    if (version < 0x010000)\n    {\n        // It's an old 0.x interface (we don't support it)\n        close(fd);\n        return;\n    }\n\n    if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)\n        strncpy(name, \"Unknown\", sizeof(name));\n\n    _glfw.linux_js.js[joy].name = strdup(name);\n    _glfw.linux_js.js[joy].path = strdup(path);\n\n    ioctl(fd, JSIOCGAXES, &axisCount);\n    _glfw.linux_js.js[joy].axisCount = (int) axisCount;\n\n    ioctl(fd, JSIOCGBUTTONS, &buttonCount);\n    _glfw.linux_js.js[joy].buttonCount = (int) buttonCount;\n\n    _glfw.linux_js.js[joy].axes = calloc(axisCount, sizeof(float));\n    _glfw.linux_js.js[joy].buttons = calloc(buttonCount, 1);\n\n    _glfw.linux_js.js[joy].present = GL_TRUE;\n#endif // __linux__\n}\n\n// Polls for and processes events for all present joysticks\n//\nstatic void pollJoystickEvents(void)\n{\n#if defined(__linux__)\n    int i;\n    struct js_event e;\n    ssize_t offset = 0;\n    char buffer[16384];\n\n    const ssize_t size = read(_glfw.linux_js.inotify, buffer, sizeof(buffer));\n\n    while (size > offset)\n    {\n        regmatch_t match;\n        const struct inotify_event* e = (struct inotify_event*) (buffer + offset);\n\n        if (regexec(&_glfw.linux_js.regex, e->name, 1, &match, 0) == 0)\n        {\n            char path[20];\n            snprintf(path, sizeof(path), \"/dev/input/%s\", e->name);\n            openJoystickDevice(path);\n        }\n\n        offset += sizeof(struct inotify_event) + e->len;\n    }\n\n    for (i = 0;  i <= GLFW_JOYSTICK_LAST;  i++)\n    {\n        if (!_glfw.linux_js.js[i].present)\n            continue;\n\n        // Read all queued events (non-blocking)\n        for (;;)\n        {\n            errno = 0;\n            if (read(_glfw.linux_js.js[i].fd, &e, sizeof(e)) < 0)\n            {\n                if (errno == ENODEV)\n                {\n                    // The joystick was disconnected\n\n                    free(_glfw.linux_js.js[i].axes);\n                    free(_glfw.linux_js.js[i].buttons);\n                    free(_glfw.linux_js.js[i].name);\n                    free(_glfw.linux_js.js[i].path);\n\n                    memset(&_glfw.linux_js.js[i], 0, sizeof(_glfw.linux_js.js[i]));\n                }\n\n                break;\n            }\n\n            // We don't care if it's an init event or not\n            e.type &= ~JS_EVENT_INIT;\n\n            switch (e.type)\n            {\n                case JS_EVENT_AXIS:\n                    _glfw.linux_js.js[i].axes[e.number] =\n                        (float) e.value / 32767.0f;\n                    break;\n\n                case JS_EVENT_BUTTON:\n                    _glfw.linux_js.js[i].buttons[e.number] =\n                        e.value ? GLFW_PRESS : GLFW_RELEASE;\n                    break;\n\n                default:\n                    break;\n            }\n        }\n    }\n#endif // __linux__\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize joystick interface\n//\nint _glfwInitJoysticks(void)\n{\n#if defined(__linux__)\n    const char* dirname = \"/dev/input\";\n    DIR* dir;\n\n    _glfw.linux_js.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);\n    if (_glfw.linux_js.inotify == -1)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Linux: Failed to initialize inotify: %s\",\n                        strerror(errno));\n        return GL_FALSE;\n    }\n\n    // HACK: Register for IN_ATTRIB as well to get notified when udev is done\n    //       This works well in practice but the true way is libudev\n\n    _glfw.linux_js.watch = inotify_add_watch(_glfw.linux_js.inotify,\n                                             dirname,\n                                             IN_CREATE | IN_ATTRIB);\n    if (_glfw.linux_js.watch == -1)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Linux: Failed to watch for joystick connections in %s: %s\",\n                        dirname,\n                        strerror(errno));\n        // Continue without device connection notifications\n    }\n\n    if (regcomp(&_glfw.linux_js.regex, \"^js[0-9]\\\\+$\", 0) != 0)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Linux: Failed to compile regex\");\n        return GL_FALSE;\n    }\n\n    dir = opendir(dirname);\n    if (dir)\n    {\n        struct dirent* entry;\n\n        while ((entry = readdir(dir)))\n        {\n            char path[20];\n            regmatch_t match;\n\n            if (regexec(&_glfw.linux_js.regex, entry->d_name, 1, &match, 0) != 0)\n                continue;\n\n            snprintf(path, sizeof(path), \"%s/%s\", dirname, entry->d_name);\n            openJoystickDevice(path);\n        }\n\n        closedir(dir);\n    }\n    else\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Linux: Failed to open joystick device directory %s: %s\",\n                        dirname,\n                        strerror(errno));\n        // Continue with no joysticks detected\n    }\n\n#endif // __linux__\n\n    return GL_TRUE;\n}\n\n// Close all opened joystick handles\n//\nvoid _glfwTerminateJoysticks(void)\n{\n#if defined(__linux__)\n    int i;\n\n    for (i = 0;  i <= GLFW_JOYSTICK_LAST;  i++)\n    {\n        if (_glfw.linux_js.js[i].present)\n        {\n            close(_glfw.linux_js.js[i].fd);\n            free(_glfw.linux_js.js[i].axes);\n            free(_glfw.linux_js.js[i].buttons);\n            free(_glfw.linux_js.js[i].name);\n            free(_glfw.linux_js.js[i].path);\n        }\n    }\n\n    regfree(&_glfw.linux_js.regex);\n\n    if (_glfw.linux_js.inotify > 0)\n    {\n        if (_glfw.linux_js.watch > 0)\n            inotify_rm_watch(_glfw.linux_js.inotify, _glfw.linux_js.watch);\n\n        close(_glfw.linux_js.inotify);\n    }\n#endif // __linux__\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformJoystickPresent(int joy)\n{\n    pollJoystickEvents();\n\n    return _glfw.linux_js.js[joy].present;\n}\n\nconst float* _glfwPlatformGetJoystickAxes(int joy, int* count)\n{\n    pollJoystickEvents();\n\n    *count = _glfw.linux_js.js[joy].axisCount;\n    return _glfw.linux_js.js[joy].axes;\n}\n\nconst unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)\n{\n    pollJoystickEvents();\n\n    *count = _glfw.linux_js.js[joy].buttonCount;\n    return _glfw.linux_js.js[joy].buttons;\n}\n\nconst char* _glfwPlatformGetJoystickName(int joy)\n{\n    pollJoystickEvents();\n\n    return _glfw.linux_js.js[joy].name;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/linux_joystick.h",
    "content": "//========================================================================\n// GLFW 3.1 Linux - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_linux_joystick_h_\n#define _glfw3_linux_joystick_h_\n\n#include <regex.h>\n\n#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \\\n    _GLFWjoystickLinux linux_js\n\n\n// Linux-specific joystick API data\n//\ntypedef struct _GLFWjoystickLinux\n{\n    struct\n    {\n        int             present;\n        int             fd;\n        float*          axes;\n        int             axisCount;\n        unsigned char*  buttons;\n        int             buttonCount;\n        char*           name;\n        char*           path;\n    } js[GLFW_JOYSTICK_LAST + 1];\n\n#if defined(__linux__)\n    int             inotify;\n    int             watch;\n    regex_t         regex;\n#endif /*__linux__*/\n} _GLFWjoystickLinux;\n\n\nint _glfwInitJoysticks(void);\nvoid _glfwTerminateJoysticks(void);\n\n#endif // _glfw3_linux_joystick_h_\n"
  },
  {
    "path": "deps/glfw/src/mach_time.c",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <mach/mach_time.h>\n\n\n// Return raw time\n//\nstatic uint64_t getRawTime(void)\n{\n    return mach_absolute_time();\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialise timer\n//\nvoid _glfwInitTimer(void)\n{\n    mach_timebase_info_data_t info;\n    mach_timebase_info(&info);\n\n    _glfw.ns_time.resolution = (double) info.numer / (info.denom * 1.0e9);\n    _glfw.ns_time.base = getRawTime();\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\ndouble _glfwPlatformGetTime(void)\n{\n    return (double) (getRawTime() - _glfw.ns_time.base) *\n        _glfw.ns_time.resolution;\n}\n\nvoid _glfwPlatformSetTime(double time)\n{\n    _glfw.ns_time.base = getRawTime() -\n        (uint64_t) (time / _glfw.ns_time.resolution);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/mir_init.c",
    "content": "//========================================================================\n// GLFW 3.1 Mir - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <string.h>\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformInit(void)\n{\n    int error;\n\n    _glfw.mir.connection = mir_connect_sync(NULL, __PRETTY_FUNCTION__);\n\n    if (!mir_connection_is_valid(_glfw.mir.connection))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Mir: Unable to connect to server: %s\",\n                        mir_connection_get_error_message(_glfw.mir.connection));\n\n        return GL_FALSE;\n    }\n\n    _glfw.mir.display =\n        mir_connection_get_egl_native_display(_glfw.mir.connection);\n\n    if (!_glfwInitContextAPI())\n        return GL_FALSE;\n\n    // Need the default conf for when we set a NULL cursor\n    _glfw.mir.default_conf = mir_cursor_configuration_from_name(mir_arrow_cursor_name);\n\n    _glfwInitTimer();\n    _glfwInitJoysticks();\n\n    _glfw.mir.event_queue = calloc(1, sizeof(EventQueue));\n    _glfwInitEventQueue(_glfw.mir.event_queue);\n\n    error = pthread_mutex_init(&_glfw.mir.event_mutex, NULL);\n    if (error)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Mir: Failed to create event mutex: %s\",\n                        strerror(error));\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformTerminate(void)\n{\n    _glfwTerminateContextAPI();\n    _glfwTerminateJoysticks();\n\n    _glfwDeleteEventQueue(_glfw.mir.event_queue);\n\n    pthread_mutex_destroy(&_glfw.mir.event_mutex);\n\n    mir_connection_release(_glfw.mir.connection);\n}\n\nconst char* _glfwPlatformGetVersionString(void)\n{\n    return _GLFW_VERSION_NUMBER \" Mir EGL\"\n#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)\n        \" clock_gettime\"\n#else\n        \" gettimeofday\"\n#endif\n#if defined(__linux__)\n        \" /dev/js\"\n#endif\n#if defined(_GLFW_BUILD_DLL)\n        \" shared\"\n#endif\n        ;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/mir_monitor.c",
    "content": "//========================================================================\n// GLFW 3.1 Mir - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count)\n{\n    int i, found = 0;\n    _GLFWmonitor** monitors = NULL;\n    MirDisplayConfiguration* displayConfig =\n        mir_connection_create_display_config(_glfw.mir.connection);\n\n    *count = 0;\n\n    for (i = 0;  i < displayConfig->num_outputs;  i++)\n    {\n        const MirDisplayOutput* out = displayConfig->outputs + i;\n\n        if (out->used &&\n            out->connected &&\n            out->num_modes &&\n            out->current_mode < out->num_modes)\n        {\n            found++;\n            monitors        = realloc(monitors, sizeof(_GLFWmonitor*) * found);\n            monitors[i]     = _glfwAllocMonitor(\"Unknown\",\n                                                out->physical_width_mm,\n                                                out->physical_height_mm);\n\n            monitors[i]->mir.x         = out->position_x;\n            monitors[i]->mir.y         = out->position_y;\n            monitors[i]->mir.output_id = out->output_id;\n            monitors[i]->mir.cur_mode  = out->current_mode;\n\n            monitors[i]->modes = _glfwPlatformGetVideoModes(monitors[i],\n                                                            &monitors[i]->modeCount);\n        }\n    }\n\n    mir_display_config_destroy(displayConfig);\n\n    *count = found;\n    return monitors;\n}\n\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)\n{\n    return first->mir.output_id == second->mir.output_id;\n}\n\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)\n{\n    if (xpos)\n        *xpos = monitor->mir.x;\n    if (ypos)\n        *ypos = monitor->mir.y;\n}\n\nvoid FillInRGBBitsFromPixelFormat(GLFWvidmode* mode, const MirPixelFormat pf)\n{\n    switch (pf)\n    {\n      case mir_pixel_format_rgb_565:\n          mode->redBits   = 5;\n          mode->greenBits = 6;\n          mode->blueBits  = 5;\n          break;\n      case mir_pixel_format_rgba_5551:\n          mode->redBits   = 5;\n          mode->greenBits = 5;\n          mode->blueBits  = 5;\n          break;\n      case mir_pixel_format_rgba_4444:\n          mode->redBits   = 4;\n          mode->greenBits = 4;\n          mode->blueBits  = 4;\n          break;\n      case mir_pixel_format_abgr_8888:\n      case mir_pixel_format_xbgr_8888:\n      case mir_pixel_format_argb_8888:\n      case mir_pixel_format_xrgb_8888:\n      case mir_pixel_format_bgr_888:\n      case mir_pixel_format_rgb_888:\n      default:\n          mode->redBits   = 8;\n          mode->greenBits = 8;\n          mode->blueBits  = 8;\n          break;\n    }\n}\n\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)\n{\n    int i;\n    GLFWvidmode* modes = NULL;\n    MirDisplayConfiguration* displayConfig =\n        mir_connection_create_display_config(_glfw.mir.connection);\n\n    for (i = 0;  i < displayConfig->num_outputs;  i++)\n    {\n        const MirDisplayOutput* out = displayConfig->outputs + i;\n        if (out->output_id != monitor->mir.output_id)\n            continue;\n\n        modes = calloc(out->num_modes, sizeof(GLFWvidmode));\n\n        for (*found = 0;  *found < out->num_modes;  (*found)++)\n        {\n            modes[*found].width  = out->modes[*found].horizontal_resolution;\n            modes[*found].height = out->modes[*found].vertical_resolution;\n            modes[*found].refreshRate = out->modes[*found].refresh_rate;\n\n            FillInRGBBitsFromPixelFormat(&modes[*found], out->output_formats[*found]);\n        }\n\n        break;\n    }\n\n    mir_display_config_destroy(displayConfig);\n\n    return modes;\n}\n\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)\n{\n    *mode = monitor->modes[monitor->mir.cur_mode];\n}\n\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/mir_platform.h",
    "content": "//========================================================================\n// GLFW 3.1 Mir - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_mir_platform_h_\n#define _glfw3_mir_platform_h_\n\n#include <sys/queue.h>\n#include <pthread.h>\n\n#include <mir_toolkit/mir_client_library.h>\n\n#include \"posix_tls.h\"\n#include \"posix_time.h\"\n#include \"linux_joystick.h\"\n#include \"xkb_unicode.h\"\n\n#if defined(_GLFW_EGL)\n #include \"egl_context.h\"\n#else\n #error \"The Mir backend depends on EGL platform support\"\n#endif\n\n#define _GLFW_EGL_NATIVE_WINDOW  window->mir.window\n#define _GLFW_EGL_NATIVE_DISPLAY _glfw.mir.display\n\n#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowMir  mir\n#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorMir mir\n#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryMir mir\n#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorMir  mir\n\n\n// Mir-specific Event Queue\n//\ntypedef struct EventQueue\n{\n    TAILQ_HEAD(, EventNode) head;\n} EventQueue;\n\n// Mir-specific per-window data\n//\ntypedef struct _GLFWwindowMir\n{\n    MirSurface*             surface;\n    int                     width;\n    int                     height;\n    MirEGLNativeWindowType  window;\n\n} _GLFWwindowMir;\n\n\n// Mir-specific per-monitor data\n//\ntypedef struct _GLFWmonitorMir\n{\n    int cur_mode;\n    int output_id;\n    int x;\n    int y;\n\n} _GLFWmonitorMir;\n\n\n// Mir-specific global data\n//\ntypedef struct _GLFWlibraryMir\n{\n    MirConnection*          connection;\n    MirEGLNativeDisplayType display;\n    MirCursorConfiguration* default_conf;\n    EventQueue* event_queue;\n\n    pthread_mutex_t event_mutex;\n    pthread_cond_t  event_cond;\n\n} _GLFWlibraryMir;\n\n\n// Mir-specific per-cursor data\n// TODO: Only system cursors are implemented in Mir atm. Need to wait for support.\n//\ntypedef struct _GLFWcursorMir\n{\n    MirCursorConfiguration* conf;\n    MirBufferStream*        custom_cursor;\n} _GLFWcursorMir;\n\n\nextern void _glfwInitEventQueue(EventQueue* queue);\nextern void _glfwDeleteEventQueue(EventQueue* queue);\n\n#endif // _glfw3_mir_platform_h_\n"
  },
  {
    "path": "deps/glfw/src/mir_window.c",
    "content": "//========================================================================\n// GLFW 3.1 Mir - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014-2015 Brandon Schaefer <brandon.schaefer@canonical.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <linux/input.h>\n#include <stdlib.h>\n#include <string.h>\n\n\ntypedef struct EventNode\n{\n    TAILQ_ENTRY(EventNode) entries;\n    const MirEvent*        event;\n    _GLFWwindow*           window;\n} EventNode;\n\nstatic void deleteNode(EventQueue* queue, EventNode* node)\n{\n    mir_event_unref(node->event);\n    free(node);\n}\n\nstatic int emptyEventQueue(EventQueue* queue)\n{\n    return queue->head.tqh_first == NULL ? GL_TRUE : GL_FALSE;\n}\n\n// TODO The mir_event_ref is not supposed to be used but ... its needed\n//      in this case. Need to wait until we can read from an FD set up by mir\n//      for single threaded event handling.\nstatic EventNode* newEventNode(const MirEvent* event, _GLFWwindow* context)\n{\n    EventNode* new_node = calloc(1, sizeof(EventNode));\n    new_node->event     = mir_event_ref(event);\n    new_node->window    = context;\n\n    return new_node;\n}\n\nstatic void enqueueEvent(const MirEvent* event, _GLFWwindow* context)\n{\n    pthread_mutex_lock(&_glfw.mir.event_mutex);\n\n    EventNode* new_node = newEventNode(event, context);\n    TAILQ_INSERT_TAIL(&_glfw.mir.event_queue->head, new_node, entries);\n\n    pthread_cond_signal(&_glfw.mir.event_cond);\n\n    pthread_mutex_unlock(&_glfw.mir.event_mutex);\n}\n\nstatic EventNode* dequeueEvent(EventQueue* queue)\n{\n    EventNode* node = NULL;\n\n    pthread_mutex_lock(&_glfw.mir.event_mutex);\n\n    node = queue->head.tqh_first;\n\n    if (node)\n        TAILQ_REMOVE(&queue->head, node, entries);\n\n    pthread_mutex_unlock(&_glfw.mir.event_mutex);\n\n    return node;\n}\n\n/* FIXME Soon to be changed upstream mir! So we can use an egl config to figure out\n         the best pixel format!\n*/\nstatic MirPixelFormat findValidPixelFormat(void)\n{\n    unsigned int i, validFormats, mirPixelFormats = 32;\n    MirPixelFormat formats[mir_pixel_formats];\n\n    mir_connection_get_available_surface_formats(_glfw.mir.connection, formats,\n                                                 mirPixelFormats, &validFormats);\n\n    for (i = 0;  i < validFormats;  i++)\n    {\n        if (formats[i] == mir_pixel_format_abgr_8888 ||\n            formats[i] == mir_pixel_format_xbgr_8888 ||\n            formats[i] == mir_pixel_format_argb_8888 ||\n            formats[i] == mir_pixel_format_xrgb_8888)\n        {\n            return formats[i];\n        }\n    }\n\n    return mir_pixel_format_invalid;\n}\n\nstatic int mirModToGLFWMod(uint32_t mods)\n{\n    int publicMods = 0x0;\n\n    if (mods & mir_input_event_modifier_alt)\n        publicMods |= GLFW_MOD_ALT;\n    else if (mods & mir_input_event_modifier_shift)\n        publicMods |= GLFW_MOD_SHIFT;\n    else if (mods & mir_input_event_modifier_ctrl)\n        publicMods |= GLFW_MOD_CONTROL;\n    else if (mods & mir_input_event_modifier_meta)\n        publicMods |= GLFW_MOD_SUPER;\n\n    return publicMods;\n}\n\n// Taken from wl_init.c\nstatic int toGLFWKeyCode(uint32_t key)\n{\n    switch (key)\n    {\n        case KEY_GRAVE:         return GLFW_KEY_GRAVE_ACCENT;\n        case KEY_1:             return GLFW_KEY_1;\n        case KEY_2:             return GLFW_KEY_2;\n        case KEY_3:             return GLFW_KEY_3;\n        case KEY_4:             return GLFW_KEY_4;\n        case KEY_5:             return GLFW_KEY_5;\n        case KEY_6:             return GLFW_KEY_6;\n        case KEY_7:             return GLFW_KEY_7;\n        case KEY_8:             return GLFW_KEY_8;\n        case KEY_9:             return GLFW_KEY_9;\n        case KEY_0:             return GLFW_KEY_0;\n        case KEY_MINUS:         return GLFW_KEY_MINUS;\n        case KEY_EQUAL:         return GLFW_KEY_EQUAL;\n        case KEY_Q:             return GLFW_KEY_Q;\n        case KEY_W:             return GLFW_KEY_W;\n        case KEY_E:             return GLFW_KEY_E;\n        case KEY_R:             return GLFW_KEY_R;\n        case KEY_T:             return GLFW_KEY_T;\n        case KEY_Y:             return GLFW_KEY_Y;\n        case KEY_U:             return GLFW_KEY_U;\n        case KEY_I:             return GLFW_KEY_I;\n        case KEY_O:             return GLFW_KEY_O;\n        case KEY_P:             return GLFW_KEY_P;\n        case KEY_LEFTBRACE:     return GLFW_KEY_LEFT_BRACKET;\n        case KEY_RIGHTBRACE:    return GLFW_KEY_RIGHT_BRACKET;\n        case KEY_A:             return GLFW_KEY_A;\n        case KEY_S:             return GLFW_KEY_S;\n        case KEY_D:             return GLFW_KEY_D;\n        case KEY_F:             return GLFW_KEY_F;\n        case KEY_G:             return GLFW_KEY_G;\n        case KEY_H:             return GLFW_KEY_H;\n        case KEY_J:             return GLFW_KEY_J;\n        case KEY_K:             return GLFW_KEY_K;\n        case KEY_L:             return GLFW_KEY_L;\n        case KEY_SEMICOLON:     return GLFW_KEY_SEMICOLON;\n        case KEY_APOSTROPHE:    return GLFW_KEY_APOSTROPHE;\n        case KEY_Z:             return GLFW_KEY_Z;\n        case KEY_X:             return GLFW_KEY_X;\n        case KEY_C:             return GLFW_KEY_C;\n        case KEY_V:             return GLFW_KEY_V;\n        case KEY_B:             return GLFW_KEY_B;\n        case KEY_N:             return GLFW_KEY_N;\n        case KEY_M:             return GLFW_KEY_M;\n        case KEY_COMMA:         return GLFW_KEY_COMMA;\n        case KEY_DOT:           return GLFW_KEY_PERIOD;\n        case KEY_SLASH:         return GLFW_KEY_SLASH;\n        case KEY_BACKSLASH:     return GLFW_KEY_BACKSLASH;\n        case KEY_ESC:           return GLFW_KEY_ESCAPE;\n        case KEY_TAB:           return GLFW_KEY_TAB;\n        case KEY_LEFTSHIFT:     return GLFW_KEY_LEFT_SHIFT;\n        case KEY_RIGHTSHIFT:    return GLFW_KEY_RIGHT_SHIFT;\n        case KEY_LEFTCTRL:      return GLFW_KEY_LEFT_CONTROL;\n        case KEY_RIGHTCTRL:     return GLFW_KEY_RIGHT_CONTROL;\n        case KEY_LEFTALT:       return GLFW_KEY_LEFT_ALT;\n        case KEY_RIGHTALT:      return GLFW_KEY_RIGHT_ALT;\n        case KEY_LEFTMETA:      return GLFW_KEY_LEFT_SUPER;\n        case KEY_RIGHTMETA:     return GLFW_KEY_RIGHT_SUPER;\n        case KEY_MENU:          return GLFW_KEY_MENU;\n        case KEY_NUMLOCK:       return GLFW_KEY_NUM_LOCK;\n        case KEY_CAPSLOCK:      return GLFW_KEY_CAPS_LOCK;\n        case KEY_PRINT:         return GLFW_KEY_PRINT_SCREEN;\n        case KEY_SCROLLLOCK:    return GLFW_KEY_SCROLL_LOCK;\n        case KEY_PAUSE:         return GLFW_KEY_PAUSE;\n        case KEY_DELETE:        return GLFW_KEY_DELETE;\n        case KEY_BACKSPACE:     return GLFW_KEY_BACKSPACE;\n        case KEY_ENTER:         return GLFW_KEY_ENTER;\n        case KEY_HOME:          return GLFW_KEY_HOME;\n        case KEY_END:           return GLFW_KEY_END;\n        case KEY_PAGEUP:        return GLFW_KEY_PAGE_UP;\n        case KEY_PAGEDOWN:      return GLFW_KEY_PAGE_DOWN;\n        case KEY_INSERT:        return GLFW_KEY_INSERT;\n        case KEY_LEFT:          return GLFW_KEY_LEFT;\n        case KEY_RIGHT:         return GLFW_KEY_RIGHT;\n        case KEY_DOWN:          return GLFW_KEY_DOWN;\n        case KEY_UP:            return GLFW_KEY_UP;\n        case KEY_F1:            return GLFW_KEY_F1;\n        case KEY_F2:            return GLFW_KEY_F2;\n        case KEY_F3:            return GLFW_KEY_F3;\n        case KEY_F4:            return GLFW_KEY_F4;\n        case KEY_F5:            return GLFW_KEY_F5;\n        case KEY_F6:            return GLFW_KEY_F6;\n        case KEY_F7:            return GLFW_KEY_F7;\n        case KEY_F8:            return GLFW_KEY_F8;\n        case KEY_F9:            return GLFW_KEY_F9;\n        case KEY_F10:           return GLFW_KEY_F10;\n        case KEY_F11:           return GLFW_KEY_F11;\n        case KEY_F12:           return GLFW_KEY_F12;\n        case KEY_F13:           return GLFW_KEY_F13;\n        case KEY_F14:           return GLFW_KEY_F14;\n        case KEY_F15:           return GLFW_KEY_F15;\n        case KEY_F16:           return GLFW_KEY_F16;\n        case KEY_F17:           return GLFW_KEY_F17;\n        case KEY_F18:           return GLFW_KEY_F18;\n        case KEY_F19:           return GLFW_KEY_F19;\n        case KEY_F20:           return GLFW_KEY_F20;\n        case KEY_F21:           return GLFW_KEY_F21;\n        case KEY_F22:           return GLFW_KEY_F22;\n        case KEY_F23:           return GLFW_KEY_F23;\n        case KEY_F24:           return GLFW_KEY_F24;\n        case KEY_KPSLASH:       return GLFW_KEY_KP_DIVIDE;\n        case KEY_KPDOT:         return GLFW_KEY_KP_MULTIPLY;\n        case KEY_KPMINUS:       return GLFW_KEY_KP_SUBTRACT;\n        case KEY_KPPLUS:        return GLFW_KEY_KP_ADD;\n        case KEY_KP0:           return GLFW_KEY_KP_0;\n        case KEY_KP1:           return GLFW_KEY_KP_1;\n        case KEY_KP2:           return GLFW_KEY_KP_2;\n        case KEY_KP3:           return GLFW_KEY_KP_3;\n        case KEY_KP4:           return GLFW_KEY_KP_4;\n        case KEY_KP5:           return GLFW_KEY_KP_5;\n        case KEY_KP6:           return GLFW_KEY_KP_6;\n        case KEY_KP7:           return GLFW_KEY_KP_7;\n        case KEY_KP8:           return GLFW_KEY_KP_8;\n        case KEY_KP9:           return GLFW_KEY_KP_9;\n        case KEY_KPCOMMA:       return GLFW_KEY_KP_DECIMAL;\n        case KEY_KPEQUAL:       return GLFW_KEY_KP_EQUAL;\n        case KEY_KPENTER:       return GLFW_KEY_KP_ENTER;\n        default:                return GLFW_KEY_UNKNOWN;\n    }\n}\n\nstatic void handleKeyEvent(const MirKeyboardEvent* key_event, _GLFWwindow* window)\n{\n    const int action    = mir_keyboard_event_action   (key_event);\n    const int scan_code = mir_keyboard_event_scan_code(key_event);\n    const int key_code  = mir_keyboard_event_key_code (key_event);\n    const int modifiers = mir_keyboard_event_modifiers(key_event);\n\n    const int  pressed = action == mir_keyboard_action_up ? GLFW_RELEASE : GLFW_PRESS;\n    const int  mods    = mirModToGLFWMod(modifiers);\n    const long text    = _glfwKeySym2Unicode(key_code);\n    const int  plain   = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));\n\n    _glfwInputKey(window, toGLFWKeyCode(scan_code), scan_code, pressed, mods);\n\n    if (text != -1)\n        _glfwInputChar(window, text, mods, plain);\n}\n\nstatic void handlePointerButton(_GLFWwindow* window,\n                              int pressed,\n                              const MirPointerEvent* pointer_event)\n{\n    MirPointerButton button = mir_pointer_event_buttons  (pointer_event);\n    int mods                = mir_pointer_event_modifiers(pointer_event);\n    const int publicMods    = mirModToGLFWMod(mods);\n    int publicButton;\n\n    switch (button)\n    {\n        case mir_pointer_button_primary:\n            publicButton = GLFW_MOUSE_BUTTON_LEFT;\n            break;\n        case mir_pointer_button_secondary:\n            publicButton = GLFW_MOUSE_BUTTON_RIGHT;\n            break;\n        case mir_pointer_button_tertiary:\n            publicButton = GLFW_MOUSE_BUTTON_MIDDLE;\n            break;\n        case mir_pointer_button_forward:\n            // FIXME What is the forward button?\n            publicButton = GLFW_MOUSE_BUTTON_4;\n            break;\n        case mir_pointer_button_back:\n            // FIXME What is the back button?\n            publicButton = GLFW_MOUSE_BUTTON_5;\n            break;\n        default:\n            break;\n    }\n\n    _glfwInputMouseClick(window, publicButton, pressed, publicMods);\n}\n\nstatic void handlePointerMotion(_GLFWwindow* window,\n                                const MirPointerEvent* pointer_event)\n{\n    int current_x = window->cursorPosX;\n    int current_y = window->cursorPosY;\n    int x  = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_x);\n    int y  = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_y);\n    int dx = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_hscroll);\n    int dy = mir_pointer_event_axis_value(pointer_event, mir_pointer_axis_vscroll);\n\n    if (current_x != x || current_y != y)\n      _glfwInputCursorMotion(window, x, y);\n    if (dx != 0 || dy != 0)\n      _glfwInputScroll(window, dx, dy);\n}\n\nstatic void handlePointerEvent(const MirPointerEvent* pointer_event,\n                             _GLFWwindow* window)\n{\n    int action = mir_pointer_event_action(pointer_event);\n\n    switch (action)\n    {\n          case mir_pointer_action_button_down:\n              handlePointerButton(window, GLFW_PRESS, pointer_event);\n              break;\n          case mir_pointer_action_button_up:\n              handlePointerButton(window, GLFW_RELEASE, pointer_event);\n              break;\n          case mir_pointer_action_motion:\n              handlePointerMotion(window, pointer_event);\n              break;\n          case mir_pointer_action_enter:\n          case mir_pointer_action_leave:\n              break;\n          default:\n              break;\n\n    }\n}\n\nstatic void handleInput(const MirInputEvent* input_event, _GLFWwindow* window)\n{\n    int type = mir_input_event_get_type(input_event);\n\n    switch (type)\n    {\n        case mir_input_event_type_key:\n            handleKeyEvent(mir_input_event_get_keyboard_event(input_event), window);\n            break;\n        case mir_input_event_type_pointer:\n            handlePointerEvent(mir_input_event_get_pointer_event(input_event), window);\n            break;\n        default:\n            break;\n    }\n}\n\nstatic void handleEvent(const MirEvent* event, _GLFWwindow* window)\n{\n    int type = mir_event_get_type(event);\n\n    switch (type)\n    {\n        case mir_event_type_input:\n            handleInput(mir_event_get_input_event(event), window);\n            break;\n        default:\n            break;\n    }\n}\n\nstatic void addNewEvent(MirSurface* surface, const MirEvent* event, void* context)\n{\n    enqueueEvent(event, context);\n}\n\nstatic int createSurface(_GLFWwindow* window)\n{\n    MirSurfaceSpec* spec;\n    MirBufferUsage buffer_usage = mir_buffer_usage_hardware;\n    MirPixelFormat pixel_format = findValidPixelFormat();\n\n    if (pixel_format == mir_pixel_format_invalid)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Mir: Unable to find a correct pixel format\");\n        return GL_FALSE;\n    }\n \n    spec = mir_connection_create_spec_for_normal_surface(_glfw.mir.connection,\n                                                         window->mir.width,\n                                                         window->mir.height,\n                                                         pixel_format);\n\n    mir_surface_spec_set_buffer_usage(spec, buffer_usage);\n    mir_surface_spec_set_name(spec, \"MirSurface\");\n\n    window->mir.surface = mir_surface_create_sync(spec);\n    mir_surface_spec_release(spec);\n\n    if (!mir_surface_is_valid(window->mir.surface))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Mir: Unable to create surface: %s\",\n                        mir_surface_get_error_message(window->mir.surface));\n\n        return GL_FALSE;\n    }\n\n    mir_surface_set_event_handler(window->mir.surface, addNewEvent, window);\n\n    return GL_TRUE;\n}\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwInitEventQueue(EventQueue* queue)\n{\n    TAILQ_INIT(&queue->head);\n}\n\nvoid _glfwDeleteEventQueue(EventQueue* queue)\n{\n    if (queue)\n    {\n        EventNode* node, *node_next;\n        node = queue->head.tqh_first;\n\n        while (node != NULL)\n        {\n            node_next = node->entries.tqe_next;\n\n            TAILQ_REMOVE(&queue->head, node, entries);\n            deleteNode(queue, node);\n\n            node = node_next;\n        }\n\n        free(queue);\n    }\n}\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig)\n{\n    if (!_glfwCreateContext(window, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    if (wndconfig->monitor)\n    {\n        GLFWvidmode mode;\n        _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);\n\n        mir_surface_set_state(window->mir.surface, mir_surface_state_fullscreen);\n\n        if (wndconfig->width > mode.width || wndconfig->height > mode.height)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"Mir: Requested surface size too large: %ix%i\",\n                            wndconfig->width, wndconfig->height);\n\n            return GL_FALSE;\n        }\n    }\n\n    window->mir.width  = wndconfig->width;\n    window->mir.height = wndconfig->height;\n\n    if (!createSurface(window))\n        return GL_FALSE;\n\n    window->mir.window = mir_buffer_stream_get_egl_native_window(\n                                   mir_surface_get_buffer_stream(window->mir.surface));\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window)\n{\n    if (mir_surface_is_valid(window->mir.surface))\n    {\n        mir_surface_release_sync(window->mir.surface);\n        window->mir.surface = NULL;\n    }\n\n    _glfwDestroyContext(window);\n}\n\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)\n{\n    MirSurfaceSpec* spec;\n    const char* e_title = title ? title : \"\";\n\n    spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);\n    mir_surface_spec_set_name(spec, e_title);\n\n    mir_surface_apply_spec(window->mir.surface, spec);\n    mir_surface_spec_release(spec);\n}\n\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)\n{\n    MirSurfaceSpec* spec;\n\n    spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);\n    mir_surface_spec_set_width (spec, width);\n    mir_surface_spec_set_height(spec, height);\n\n    mir_surface_apply_spec(window->mir.surface, spec);\n    mir_surface_spec_release(spec);\n}\n\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,\n                                     int* left, int* top,\n                                     int* right, int* bottom)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)\n{\n    if (width)\n        *width  = window->mir.width;\n    if (height)\n        *height = window->mir.height;\n}\n\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window)\n{\n    mir_surface_set_state(window->mir.surface, mir_surface_state_minimized);\n}\n\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window)\n{\n    mir_surface_set_state(window->mir.surface, mir_surface_state_restored);\n}\n\nvoid _glfwPlatformHideWindow(_GLFWwindow* window)\n{\n    MirSurfaceSpec* spec;\n\n    spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);\n    mir_surface_spec_set_state(spec, mir_surface_state_hidden);\n\n    mir_surface_apply_spec(window->mir.surface, spec);\n    mir_surface_spec_release(spec);\n}\n\nvoid _glfwPlatformShowWindow(_GLFWwindow* window)\n{\n    MirSurfaceSpec* spec;\n\n    spec = mir_connection_create_spec_for_changes(_glfw.mir.connection);\n    mir_surface_spec_set_state(spec, mir_surface_state_restored);\n\n    mir_surface_apply_spec(window->mir.surface, spec);\n    mir_surface_spec_release(spec);\n}\n\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nint _glfwPlatformWindowFocused(_GLFWwindow* window)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n    return GL_FALSE;\n}\n\nint _glfwPlatformWindowIconified(_GLFWwindow* window)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n    return GL_FALSE;\n}\n\nint _glfwPlatformWindowVisible(_GLFWwindow* window)\n{\n    return mir_surface_get_visibility(window->mir.surface) == mir_surface_visibility_exposed;\n}\n\nvoid _glfwPlatformPollEvents(void)\n{\n    EventNode* node = NULL;\n\n    while ((node = dequeueEvent(_glfw.mir.event_queue)))\n    {\n        handleEvent(node->event, node->window);\n        deleteNode(_glfw.mir.event_queue, node);\n    }\n}\n\nvoid _glfwPlatformWaitEvents(void)\n{\n    pthread_mutex_lock(&_glfw.mir.event_mutex);\n\n    if (emptyEventQueue(_glfw.mir.event_queue))\n        pthread_cond_wait(&_glfw.mir.event_cond, &_glfw.mir.event_mutex);\n\n    pthread_mutex_unlock(&_glfw.mir.event_mutex);\n\n    _glfwPlatformPollEvents();\n}\n\nvoid _glfwPlatformPostEmptyEvent(void)\n{\n}\n\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)\n{\n    if (width)\n        *width  = window->mir.width;\n    if (height)\n        *height = window->mir.height;\n}\n\n// FIXME implement\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor,\n                              const GLFWimage* image,\n                              int xhot, int yhot)\n{\n    MirBufferStream* stream;\n    MirPixelFormat pixel_format = findValidPixelFormat();\n\n    int i_w = image->width;\n    int i_h = image->height;\n\n    if (pixel_format == mir_pixel_format_invalid)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Mir: Unable to find a correct pixel format\");\n        return GL_FALSE;\n    }\n\n    stream = mir_connection_create_buffer_stream_sync(_glfw.mir.connection,\n                                                      i_w, i_h,\n                                                      pixel_format,\n                                                      mir_buffer_usage_software);\n\n    cursor->mir.conf = mir_cursor_configuration_from_buffer_stream(stream, xhot, yhot);\n\n    char* dest;\n    unsigned char *pixels;\n    int i, r_stride, bytes_per_pixel, bytes_per_row;\n\n    MirGraphicsRegion region;\n    mir_buffer_stream_get_graphics_region(stream, &region);\n\n    // FIXME Figure this out based on the current_pf\n    bytes_per_pixel = 4;\n    bytes_per_row   = bytes_per_pixel * i_w;\n\n    dest   = region.vaddr;\n    pixels = image->pixels;\n\n    r_stride = region.stride;\n\n    for (i = 0; i < i_h; i++)\n    {\n        memcpy(dest, pixels, bytes_per_row);\n        dest   += r_stride;\n        pixels += r_stride;\n    }\n\n    cursor->mir.custom_cursor = stream;\n\n    return GL_TRUE;\n}\n\nconst char* getSystemCursorName(int shape)\n{\n    switch (shape)\n    {\n        case GLFW_ARROW_CURSOR:\n            return mir_arrow_cursor_name;\n        case GLFW_IBEAM_CURSOR:\n            return mir_caret_cursor_name;\n        case GLFW_CROSSHAIR_CURSOR:\n            return mir_crosshair_cursor_name;\n        case GLFW_HAND_CURSOR:\n            return mir_open_hand_cursor_name;\n        case GLFW_HRESIZE_CURSOR:\n            return mir_horizontal_resize_cursor_name;\n        case GLFW_VRESIZE_CURSOR:\n            return mir_vertical_resize_cursor_name;\n    }\n\n    return NULL;\n}\n\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)\n{\n    const char* cursor_name = getSystemCursorName(shape);\n\n    if (cursor_name)\n    {\n        cursor->mir.conf          = mir_cursor_configuration_from_name(cursor_name);\n        cursor->mir.custom_cursor = NULL;\n\n        return GL_TRUE;\n    }\n\n    return GL_FALSE;\n}\n\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor)\n{\n    if (cursor->mir.conf)\n        mir_cursor_configuration_destroy(cursor->mir.conf);\n    if (cursor->mir.custom_cursor)\n        mir_buffer_stream_release_sync(cursor->mir.custom_cursor);\n}\n\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)\n{\n    if (cursor && cursor->mir.conf)\n    {\n        mir_wait_for(mir_surface_configure_cursor(window->mir.surface, cursor->mir.conf));\n        if (cursor->mir.custom_cursor)\n        {\n            /* FIXME Bug https://bugs.launchpad.net/mir/+bug/1477285\n                     Requires a triple buffer swap to get the cursor buffer on top! (since mir is tripled buffered)\n            */\n            mir_buffer_stream_swap_buffers_sync(cursor->mir.custom_cursor);\n            mir_buffer_stream_swap_buffers_sync(cursor->mir.custom_cursor);\n            mir_buffer_stream_swap_buffers_sync(cursor->mir.custom_cursor);\n        }\n    }\n    else\n    {\n        mir_wait_for(mir_surface_configure_cursor(window->mir.surface, _glfw.mir.default_conf));\n    }\n}\n\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n}\n\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window)\n{\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Mir: Unsupported function %s\", __PRETTY_FUNCTION__);\n\n    return NULL;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/monitor.c",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <math.h>\n#include <float.h>\n#include <string.h>\n#include <stdlib.h>\n#include <limits.h>\n\n\n// Lexical comparison function for GLFW video modes, used by qsort\n//\nstatic int compareVideoModes(const void* firstPtr, const void* secondPtr)\n{\n    int firstBPP, secondBPP, firstSize, secondSize;\n    const GLFWvidmode* first = firstPtr;\n    const GLFWvidmode* second = secondPtr;\n\n    // First sort on color bits per pixel\n    firstBPP = first->redBits + first->greenBits + first->blueBits;\n    secondBPP = second->redBits + second->greenBits + second->blueBits;\n    if (firstBPP != secondBPP)\n        return firstBPP - secondBPP;\n\n    // Then sort on screen area, in pixels\n    firstSize = first->width * first->height;\n    secondSize = second->width * second->height;\n    if (firstSize != secondSize)\n        return firstSize - secondSize;\n\n    // Lastly sort on refresh rate\n    return first->refreshRate - second->refreshRate;\n}\n\n// Retrieves the available modes for the specified monitor\n//\nstatic int refreshVideoModes(_GLFWmonitor* monitor)\n{\n    int modeCount;\n    GLFWvidmode* modes;\n\n    if (monitor->modes)\n        return GL_TRUE;\n\n    modes = _glfwPlatformGetVideoModes(monitor, &modeCount);\n    if (!modes)\n        return GL_FALSE;\n\n    qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);\n\n    free(monitor->modes);\n    monitor->modes = modes;\n    monitor->modeCount = modeCount;\n\n    return GL_TRUE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                         GLFW event API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwInputMonitorChange(void)\n{\n    int i, j, monitorCount = _glfw.monitorCount;\n    _GLFWmonitor** monitors = _glfw.monitors;\n\n    _glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);\n\n    // Re-use still connected monitor objects\n\n    for (i = 0;  i < _glfw.monitorCount;  i++)\n    {\n        for (j = 0;  j < monitorCount;  j++)\n        {\n            if (_glfwPlatformIsSameMonitor(_glfw.monitors[i], monitors[j]))\n            {\n                _glfwFreeMonitor(_glfw.monitors[i]);\n                _glfw.monitors[i] = monitors[j];\n                break;\n            }\n        }\n    }\n\n    // Find and report disconnected monitors (not in the new list)\n\n    for (i = 0;  i < monitorCount;  i++)\n    {\n        _GLFWwindow* window;\n\n        for (j = 0;  j < _glfw.monitorCount;  j++)\n        {\n            if (monitors[i] == _glfw.monitors[j])\n                break;\n        }\n\n        if (j < _glfw.monitorCount)\n            continue;\n\n        for (window = _glfw.windowListHead;  window;  window = window->next)\n        {\n            if (window->monitor == monitors[i])\n                window->monitor = NULL;\n        }\n\n        if (_glfw.callbacks.monitor)\n            _glfw.callbacks.monitor((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED);\n    }\n\n    // Find and report newly connected monitors (not in the old list)\n    // Re-used monitor objects are then removed from the old list to avoid\n    // having them destroyed at the end of this function\n\n    for (i = 0;  i < _glfw.monitorCount;  i++)\n    {\n        for (j = 0;  j < monitorCount;  j++)\n        {\n            if (_glfw.monitors[i] == monitors[j])\n            {\n                monitors[j] = NULL;\n                break;\n            }\n        }\n\n        if (j < monitorCount)\n            continue;\n\n        if (_glfw.callbacks.monitor)\n            _glfw.callbacks.monitor((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);\n    }\n\n    _glfwFreeMonitors(monitors, monitorCount);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)\n{\n    _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));\n    monitor->name = strdup(name);\n    monitor->widthMM = widthMM;\n    monitor->heightMM = heightMM;\n\n    return monitor;\n}\n\nvoid _glfwFreeMonitor(_GLFWmonitor* monitor)\n{\n    if (monitor == NULL)\n        return;\n\n    _glfwFreeGammaArrays(&monitor->originalRamp);\n    _glfwFreeGammaArrays(&monitor->currentRamp);\n\n    free(monitor->modes);\n    free(monitor->name);\n    free(monitor);\n}\n\nvoid _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)\n{\n    ramp->red = calloc(size, sizeof(unsigned short));\n    ramp->green = calloc(size, sizeof(unsigned short));\n    ramp->blue = calloc(size, sizeof(unsigned short));\n    ramp->size = size;\n}\n\nvoid _glfwFreeGammaArrays(GLFWgammaramp* ramp)\n{\n    free(ramp->red);\n    free(ramp->green);\n    free(ramp->blue);\n\n    memset(ramp, 0, sizeof(GLFWgammaramp));\n}\n\nvoid _glfwFreeMonitors(_GLFWmonitor** monitors, int count)\n{\n    int i;\n\n    for (i = 0;  i < count;  i++)\n        _glfwFreeMonitor(monitors[i]);\n\n    free(monitors);\n}\n\nconst GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,\n                                        const GLFWvidmode* desired)\n{\n    int i;\n    unsigned int sizeDiff, leastSizeDiff = UINT_MAX;\n    unsigned int rateDiff, leastRateDiff = UINT_MAX;\n    unsigned int colorDiff, leastColorDiff = UINT_MAX;\n    const GLFWvidmode* current;\n    const GLFWvidmode* closest = NULL;\n\n    if (!refreshVideoModes(monitor))\n        return NULL;\n\n    for (i = 0;  i < monitor->modeCount;  i++)\n    {\n        current = monitor->modes + i;\n\n        colorDiff = 0;\n\n        if (desired->redBits != GLFW_DONT_CARE)\n            colorDiff += abs(current->redBits - desired->redBits);\n        if (desired->greenBits != GLFW_DONT_CARE)\n            colorDiff += abs(current->greenBits - desired->greenBits);\n        if (desired->blueBits != GLFW_DONT_CARE)\n            colorDiff += abs(current->blueBits - desired->blueBits);\n\n        sizeDiff = abs((current->width - desired->width) *\n                       (current->width - desired->width) +\n                       (current->height - desired->height) *\n                       (current->height - desired->height));\n\n        if (desired->refreshRate != GLFW_DONT_CARE)\n            rateDiff = abs(current->refreshRate - desired->refreshRate);\n        else\n            rateDiff = UINT_MAX - current->refreshRate;\n\n        if ((colorDiff < leastColorDiff) ||\n            (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||\n            (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))\n        {\n            closest = current;\n            leastSizeDiff = sizeDiff;\n            leastRateDiff = rateDiff;\n            leastColorDiff = colorDiff;\n        }\n    }\n\n    return closest;\n}\n\nint _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second)\n{\n    return compareVideoModes(first, second);\n}\n\nvoid _glfwSplitBPP(int bpp, int* red, int* green, int* blue)\n{\n    int delta;\n\n    // We assume that by 32 the user really meant 24\n    if (bpp == 32)\n        bpp = 24;\n\n    // Convert \"bits per pixel\" to red, green & blue sizes\n\n    *red = *green = *blue = bpp / 3;\n    delta = bpp - (*red * 3);\n    if (delta >= 1)\n        *green = *green + 1;\n\n    if (delta == 2)\n        *red = *red + 1;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW public API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI GLFWmonitor** glfwGetMonitors(int* count)\n{\n    *count = 0;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    *count = _glfw.monitorCount;\n    return (GLFWmonitor**) _glfw.monitors;\n}\n\nGLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (!_glfw.monitorCount)\n        return NULL;\n\n    return (GLFWmonitor*) _glfw.monitors[0];\n}\n\nGLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    if (xpos)\n        *xpos = 0;\n    if (ypos)\n        *ypos = 0;\n\n    _GLFW_REQUIRE_INIT();\n\n    _glfwPlatformGetMonitorPos(monitor, xpos, ypos);\n}\n\nGLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    if (widthMM)\n        *widthMM = 0;\n    if (heightMM)\n        *heightMM = 0;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (widthMM)\n        *widthMM = monitor->widthMM;\n    if (heightMM)\n        *heightMM = monitor->heightMM;\n}\n\nGLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return monitor->name;\n}\n\nGLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);\n    return cbfun;\n}\n\nGLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    *count = 0;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (!refreshVideoModes(monitor))\n        return NULL;\n\n    *count = monitor->modeCount;\n    return monitor->modes;\n}\n\nGLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    _glfwPlatformGetVideoMode(monitor, &monitor->currentMode);\n    return &monitor->currentMode;\n}\n\nGLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)\n{\n    int i;\n    unsigned short values[256];\n    GLFWgammaramp ramp;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)\n    {\n        _glfwInputError(GLFW_INVALID_VALUE, \"Invalid gamma value\");\n        return;\n    }\n\n    for (i = 0;  i < 256;  i++)\n    {\n        double value;\n\n        // Calculate intensity\n        value = i / 255.0;\n        // Apply gamma curve\n        value = pow(value, 1.0 / gamma) * 65535.0 + 0.5;\n\n        // Clamp to value range\n        if (value > 65535.0)\n            value = 65535.0;\n\n        values[i] = (unsigned short) value;\n    }\n\n    ramp.red = values;\n    ramp.green = values;\n    ramp.blue = values;\n    ramp.size = 256;\n\n    glfwSetGammaRamp(handle, &ramp);\n}\n\nGLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    _glfwFreeGammaArrays(&monitor->currentRamp);\n    _glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp);\n\n    return &monitor->currentRamp;\n}\n\nGLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (!monitor->originalRamp.size)\n        _glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp);\n\n    _glfwPlatformSetGammaRamp(monitor, ramp);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/nsgl_context.h",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_nsgl_context_h_\n#define _glfw3_nsgl_context_h_\n\n#define _GLFW_PLATFORM_FBCONFIG\n#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextNSGL nsgl\n#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryNSGL nsgl\n\n\n// NSGL-specific per-context data\n//\ntypedef struct _GLFWcontextNSGL\n{\n    id           pixelFormat;\n    id\t         context;\n\n} _GLFWcontextNSGL;\n\n\n// NSGL-specific global data\n//\ntypedef struct _GLFWlibraryNSGL\n{\n    // dlopen handle for OpenGL.framework (for glfwGetProcAddress)\n    void*           framework;\n\n} _GLFWlibraryNSGL;\n\n\nint _glfwInitContextAPI(void);\nvoid _glfwTerminateContextAPI(void);\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig);\nvoid _glfwDestroyContext(_GLFWwindow* window);\n\n#endif // _glfw3_nsgl_context_h_\n"
  },
  {
    "path": "deps/glfw/src/nsgl_context.m",
    "content": "//========================================================================\n// GLFW 3.1 OS X - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize OpenGL support\n//\nint _glfwInitContextAPI(void)\n{\n    if (!_glfwCreateContextTLS())\n        return GL_FALSE;\n\n    _glfw.nsgl.framework =\n        CFBundleGetBundleWithIdentifier(CFSTR(\"com.apple.opengl\"));\n    if (_glfw.nsgl.framework == NULL)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"NSGL: Failed to locate OpenGL framework\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n// Terminate OpenGL support\n//\nvoid _glfwTerminateContextAPI(void)\n{\n    _glfwDestroyContextTLS();\n}\n\n// Create the OpenGL context\n//\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig)\n{\n    unsigned int attributeCount = 0;\n\n    if (ctxconfig->api == GLFW_OPENGL_ES_API)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"NSGL: OpenGL ES is not available on OS X\");\n        return GL_FALSE;\n    }\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n    if (ctxconfig->major == 3 && ctxconfig->minor < 2)\n    {\n        _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                        \"NSGL: The targeted version of OS X does not support OpenGL 3.0 or 3.1\");\n        return GL_FALSE;\n    }\n\n    if (ctxconfig->major > 2)\n    {\n        if (!ctxconfig->forward)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"NSGL: The targeted version of OS X only supports forward-compatible contexts for OpenGL 3.2 and above\");\n            return GL_FALSE;\n        }\n\n        if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"NSGL: The targeted version of OS X only supports core profile contexts for OpenGL 3.2 and above\");\n            return GL_FALSE;\n        }\n    }\n#else\n    // Fail if OpenGL 3.0 or above was requested\n    if (ctxconfig->major > 2)\n    {\n        _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                        \"NSGL: The targeted version of OS X does not support OpenGL version 3.0 or above\");\n        return GL_FALSE;\n    }\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n    // Context robustness modes (GL_KHR_robustness) are not yet supported on\n    // OS X but are not a hard constraint, so ignore and continue\n\n    // Context release behaviors (GL_KHR_context_flush_control) are not yet\n    // supported on OS X but are not a hard constraint, so ignore and continue\n\n#define ADD_ATTR(x) { attributes[attributeCount++] = x; }\n#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }\n\n    // Arbitrary array size here\n    NSOpenGLPixelFormatAttribute attributes[40];\n\n    ADD_ATTR(NSOpenGLPFAAccelerated);\n    ADD_ATTR(NSOpenGLPFAClosestPolicy);\n\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070\n#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000\n    if (ctxconfig->major >= 4)\n    {\n        ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);\n    }\n    else\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n    if (ctxconfig->major >= 3)\n    {\n        ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);\n    }\n#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/\n\n    if (ctxconfig->major <= 2)\n    {\n        if (fbconfig->auxBuffers != GLFW_DONT_CARE)\n            ADD_ATTR2(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);\n\n        if (fbconfig->accumRedBits != GLFW_DONT_CARE &&\n            fbconfig->accumGreenBits != GLFW_DONT_CARE &&\n            fbconfig->accumBlueBits != GLFW_DONT_CARE &&\n            fbconfig->accumAlphaBits != GLFW_DONT_CARE)\n        {\n            const int accumBits = fbconfig->accumRedBits +\n                                  fbconfig->accumGreenBits +\n                                  fbconfig->accumBlueBits +\n                                  fbconfig->accumAlphaBits;\n\n            ADD_ATTR2(NSOpenGLPFAAccumSize, accumBits);\n        }\n    }\n\n    if (fbconfig->redBits != GLFW_DONT_CARE &&\n        fbconfig->greenBits != GLFW_DONT_CARE &&\n        fbconfig->blueBits != GLFW_DONT_CARE)\n    {\n        int colorBits = fbconfig->redBits +\n                        fbconfig->greenBits +\n                        fbconfig->blueBits;\n\n        // OS X needs non-zero color size, so set reasonable values\n        if (colorBits == 0)\n            colorBits = 24;\n        else if (colorBits < 15)\n            colorBits = 15;\n\n        ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);\n    }\n\n    if (fbconfig->alphaBits != GLFW_DONT_CARE)\n        ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);\n\n    if (fbconfig->depthBits != GLFW_DONT_CARE)\n        ADD_ATTR2(NSOpenGLPFADepthSize, fbconfig->depthBits);\n\n    if (fbconfig->stencilBits != GLFW_DONT_CARE)\n        ADD_ATTR2(NSOpenGLPFAStencilSize, fbconfig->stencilBits);\n\n    if (fbconfig->stereo)\n        ADD_ATTR(NSOpenGLPFAStereo);\n\n    if (fbconfig->doublebuffer)\n        ADD_ATTR(NSOpenGLPFADoubleBuffer);\n\n    if (fbconfig->samples != GLFW_DONT_CARE)\n    {\n        if (fbconfig->samples == 0)\n        {\n            ADD_ATTR2(NSOpenGLPFASampleBuffers, 0);\n        }\n        else\n        {\n            ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);\n            ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);\n        }\n    }\n\n    // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB\n    //       framebuffer, so there's no need (and no way) to request it\n\n    ADD_ATTR(0);\n\n#undef ADD_ATTR\n#undef ADD_ATTR2\n\n    window->nsgl.pixelFormat =\n        [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];\n    if (window->nsgl.pixelFormat == nil)\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"NSGL: Failed to find a suitable pixel format\");\n        return GL_FALSE;\n    }\n\n    NSOpenGLContext* share = NULL;\n\n    if (ctxconfig->share)\n        share = ctxconfig->share->nsgl.context;\n\n    window->nsgl.context =\n        [[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat\n                                   shareContext:share];\n    if (window->nsgl.context == nil)\n    {\n        _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                        \"NSGL: Failed to create OpenGL context\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n// Destroy the OpenGL context\n//\nvoid _glfwDestroyContext(_GLFWwindow* window)\n{\n    [window->nsgl.pixelFormat release];\n    window->nsgl.pixelFormat = nil;\n\n    [window->nsgl.context release];\n    window->nsgl.context = nil;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwPlatformMakeContextCurrent(_GLFWwindow* window)\n{\n    if (window)\n        [window->nsgl.context makeCurrentContext];\n    else\n        [NSOpenGLContext clearCurrentContext];\n\n    _glfwSetContextTLS(window);\n}\n\nvoid _glfwPlatformSwapBuffers(_GLFWwindow* window)\n{\n    // ARP appears to be unnecessary, but this is future-proof\n    [window->nsgl.context flushBuffer];\n}\n\nvoid _glfwPlatformSwapInterval(int interval)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    GLint sync = interval;\n    [window->nsgl.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];\n}\n\nint _glfwPlatformExtensionSupported(const char* extension)\n{\n    // There are no NSGL extensions\n    return GL_FALSE;\n}\n\nGLFWglproc _glfwPlatformGetProcAddress(const char* procname)\n{\n    CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,\n                                                       procname,\n                                                       kCFStringEncodingASCII);\n\n    GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,\n                                                          symbolName);\n\n    CFRelease(symbolName);\n\n    return symbol;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(nil);\n    return window->nsgl.context;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/posix_time.c",
    "content": "//========================================================================\n// GLFW 3.1 POSIX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <sys/time.h>\n#include <time.h>\n\n// Return raw time\n//\nstatic uint64_t getRawTime(void)\n{\n#if defined(CLOCK_MONOTONIC)\n    if (_glfw.posix_time.monotonic)\n    {\n        struct timespec ts;\n\n        clock_gettime(CLOCK_MONOTONIC, &ts);\n        return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;\n    }\n    else\n#endif\n    {\n        struct timeval tv;\n\n        gettimeofday(&tv, NULL);\n        return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialise timer\n//\nvoid _glfwInitTimer(void)\n{\n#if defined(CLOCK_MONOTONIC)\n    struct timespec ts;\n\n    if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)\n    {\n        _glfw.posix_time.monotonic = GL_TRUE;\n        _glfw.posix_time.resolution = 1e-9;\n    }\n    else\n#endif\n    {\n        _glfw.posix_time.resolution = 1e-6;\n    }\n\n    _glfw.posix_time.base = getRawTime();\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\ndouble _glfwPlatformGetTime(void)\n{\n    return (double) (getRawTime() - _glfw.posix_time.base) *\n        _glfw.posix_time.resolution;\n}\n\nvoid _glfwPlatformSetTime(double time)\n{\n    _glfw.posix_time.base = getRawTime() -\n        (uint64_t) (time / _glfw.posix_time.resolution);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/posix_time.h",
    "content": "//========================================================================\n// GLFW 3.1 POSIX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_posix_time_h_\n#define _glfw3_posix_time_h_\n\n#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimePOSIX posix_time\n\n#include <stdint.h>\n\n\n// POSIX-specific global timer data\n//\ntypedef struct _GLFWtimePOSIX\n{\n    GLboolean   monotonic;\n    double      resolution;\n    uint64_t    base;\n\n} _GLFWtimePOSIX;\n\n\nvoid _glfwInitTimer(void);\n\n#endif // _glfw3_posix_time_h_\n"
  },
  {
    "path": "deps/glfw/src/posix_tls.c",
    "content": "//========================================================================\n// GLFW 3.1 POSIX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwCreateContextTLS(void)\n{\n    if (pthread_key_create(&_glfw.posix_tls.context, NULL) != 0)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"POSIX: Failed to create context TLS\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwDestroyContextTLS(void)\n{\n    pthread_key_delete(_glfw.posix_tls.context);\n}\n\nvoid _glfwSetContextTLS(_GLFWwindow* context)\n{\n    pthread_setspecific(_glfw.posix_tls.context, context);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWwindow* _glfwPlatformGetCurrentContext(void)\n{\n    return pthread_getspecific(_glfw.posix_tls.context);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/posix_tls.h",
    "content": "//========================================================================\n// GLFW 3.1 POSIX - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_posix_tls_h_\n#define _glfw3_posix_tls_h_\n\n#include <pthread.h>\n\n#define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsPOSIX posix_tls\n\n\n// POSIX-specific global TLS data\n//\ntypedef struct _GLFWtlsPOSIX\n{\n    pthread_key_t   context;\n\n} _GLFWtlsPOSIX;\n\n\nint _glfwCreateContextTLS(void);\nvoid _glfwDestroyContextTLS(void);\nvoid _glfwSetContextTLS(_GLFWwindow* context);\n\n#endif // _glfw3_posix_tls_h_\n"
  },
  {
    "path": "deps/glfw/src/wgl_context.c",
    "content": "//========================================================================\n// GLFW 3.1 WGL - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <malloc.h>\n#include <assert.h>\n\n\n// Initialize WGL-specific extensions\n//\nstatic void initWGLExtensions(_GLFWwindow* window)\n{\n    // Functions for WGL_EXT_extension_string\n    // NOTE: These are needed by _glfwPlatformExtensionSupported\n    window->wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)\n        _glfw_wglGetProcAddress(\"wglGetExtensionsStringEXT\");\n    window->wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)\n        _glfw_wglGetProcAddress(\"wglGetExtensionsStringARB\");\n\n    // Functions for WGL_ARB_create_context\n    window->wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)\n        _glfw_wglGetProcAddress(\"wglCreateContextAttribsARB\");\n\n    // Functions for WGL_EXT_swap_control\n    window->wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)\n        _glfw_wglGetProcAddress(\"wglSwapIntervalEXT\");\n\n    // Functions for WGL_ARB_pixel_format\n    window->wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)\n        _glfw_wglGetProcAddress(\"wglGetPixelFormatAttribivARB\");\n\n    // This needs to include every extension used below except for\n    // WGL_ARB_extensions_string and WGL_EXT_extensions_string\n    window->wgl.ARB_multisample =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_multisample\");\n    window->wgl.ARB_framebuffer_sRGB =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_framebuffer_sRGB\");\n    window->wgl.EXT_framebuffer_sRGB =\n        _glfwPlatformExtensionSupported(\"WGL_EXT_framebuffer_sRGB\");\n    window->wgl.ARB_create_context =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_create_context\");\n    window->wgl.ARB_create_context_profile =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_create_context_profile\");\n    window->wgl.EXT_create_context_es2_profile =\n        _glfwPlatformExtensionSupported(\"WGL_EXT_create_context_es2_profile\");\n    window->wgl.ARB_create_context_robustness =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_create_context_robustness\");\n    window->wgl.EXT_swap_control =\n        _glfwPlatformExtensionSupported(\"WGL_EXT_swap_control\");\n    window->wgl.ARB_pixel_format =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_pixel_format\");\n    window->wgl.ARB_context_flush_control =\n        _glfwPlatformExtensionSupported(\"WGL_ARB_context_flush_control\");\n}\n\n// Returns the specified attribute of the specified pixel format\n//\nstatic int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib)\n{\n    int value = 0;\n\n    assert(window->wgl.ARB_pixel_format);\n\n    if (!window->wgl.GetPixelFormatAttribivARB(window->wgl.dc,\n                                               pixelFormat,\n                                               0, 1, &attrib, &value))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"WGL: Failed to retrieve pixel format attribute %i\",\n                        attrib);\n        return 0;\n    }\n\n    return value;\n}\n\n// Return a list of available and usable framebuffer configs\n//\nstatic GLboolean choosePixelFormat(_GLFWwindow* window,\n                                   const _GLFWfbconfig* desired,\n                                   int* result)\n{\n    _GLFWfbconfig* usableConfigs;\n    const _GLFWfbconfig* closest;\n    int i, nativeCount, usableCount;\n\n    if (window->wgl.ARB_pixel_format)\n    {\n        nativeCount = getPixelFormatAttrib(window,\n                                         1,\n                                         WGL_NUMBER_PIXEL_FORMATS_ARB);\n    }\n    else\n    {\n        nativeCount = DescribePixelFormat(window->wgl.dc,\n                                          1,\n                                          sizeof(PIXELFORMATDESCRIPTOR),\n                                          NULL);\n    }\n\n    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));\n    usableCount = 0;\n\n    for (i = 0;  i < nativeCount;  i++)\n    {\n        const int n = i + 1;\n        _GLFWfbconfig* u = usableConfigs + usableCount;\n\n        if (window->wgl.ARB_pixel_format)\n        {\n            // Get pixel format attributes through \"modern\" extension\n\n            if (!getPixelFormatAttrib(window, n, WGL_SUPPORT_OPENGL_ARB) ||\n                !getPixelFormatAttrib(window, n, WGL_DRAW_TO_WINDOW_ARB))\n            {\n                continue;\n            }\n\n            if (getPixelFormatAttrib(window, n, WGL_PIXEL_TYPE_ARB) !=\n                WGL_TYPE_RGBA_ARB)\n            {\n                continue;\n            }\n\n            if (getPixelFormatAttrib(window, n, WGL_ACCELERATION_ARB) ==\n                 WGL_NO_ACCELERATION_ARB)\n            {\n                continue;\n            }\n\n            u->redBits = getPixelFormatAttrib(window, n, WGL_RED_BITS_ARB);\n            u->greenBits = getPixelFormatAttrib(window, n, WGL_GREEN_BITS_ARB);\n            u->blueBits = getPixelFormatAttrib(window, n, WGL_BLUE_BITS_ARB);\n            u->alphaBits = getPixelFormatAttrib(window, n, WGL_ALPHA_BITS_ARB);\n\n            u->depthBits = getPixelFormatAttrib(window, n, WGL_DEPTH_BITS_ARB);\n            u->stencilBits = getPixelFormatAttrib(window, n, WGL_STENCIL_BITS_ARB);\n\n            u->accumRedBits = getPixelFormatAttrib(window, n, WGL_ACCUM_RED_BITS_ARB);\n            u->accumGreenBits = getPixelFormatAttrib(window, n, WGL_ACCUM_GREEN_BITS_ARB);\n            u->accumBlueBits = getPixelFormatAttrib(window, n, WGL_ACCUM_BLUE_BITS_ARB);\n            u->accumAlphaBits = getPixelFormatAttrib(window, n, WGL_ACCUM_ALPHA_BITS_ARB);\n\n            u->auxBuffers = getPixelFormatAttrib(window, n, WGL_AUX_BUFFERS_ARB);\n\n            if (getPixelFormatAttrib(window, n, WGL_STEREO_ARB))\n                u->stereo = GL_TRUE;\n            if (getPixelFormatAttrib(window, n, WGL_DOUBLE_BUFFER_ARB))\n                u->doublebuffer = GL_TRUE;\n\n            if (window->wgl.ARB_multisample)\n                u->samples = getPixelFormatAttrib(window, n, WGL_SAMPLES_ARB);\n\n            if (window->wgl.ARB_framebuffer_sRGB ||\n                window->wgl.EXT_framebuffer_sRGB)\n            {\n                if (getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))\n                    u->sRGB = GL_TRUE;\n            }\n        }\n        else\n        {\n            PIXELFORMATDESCRIPTOR pfd;\n\n            // Get pixel format attributes through legacy PFDs\n\n            if (!DescribePixelFormat(window->wgl.dc,\n                                     n,\n                                     sizeof(PIXELFORMATDESCRIPTOR),\n                                     &pfd))\n            {\n                continue;\n            }\n\n            if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||\n                !(pfd.dwFlags & PFD_SUPPORT_OPENGL))\n            {\n                continue;\n            }\n\n            if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&\n                (pfd.dwFlags & PFD_GENERIC_FORMAT))\n            {\n                continue;\n            }\n\n            if (pfd.iPixelType != PFD_TYPE_RGBA)\n                continue;\n\n            u->redBits = pfd.cRedBits;\n            u->greenBits = pfd.cGreenBits;\n            u->blueBits = pfd.cBlueBits;\n            u->alphaBits = pfd.cAlphaBits;\n\n            u->depthBits = pfd.cDepthBits;\n            u->stencilBits = pfd.cStencilBits;\n\n            u->accumRedBits = pfd.cAccumRedBits;\n            u->accumGreenBits = pfd.cAccumGreenBits;\n            u->accumBlueBits = pfd.cAccumBlueBits;\n            u->accumAlphaBits = pfd.cAccumAlphaBits;\n\n            u->auxBuffers = pfd.cAuxBuffers;\n\n            if (pfd.dwFlags & PFD_STEREO)\n                u->stereo = GL_TRUE;\n            if (pfd.dwFlags & PFD_DOUBLEBUFFER)\n                u->doublebuffer = GL_TRUE;\n        }\n\n        u->wgl = n;\n        usableCount++;\n    }\n\n    if (!usableCount)\n    {\n        _glfwInputError(GLFW_API_UNAVAILABLE,\n                        \"WGL: The driver does not appear to support OpenGL\");\n\n        free(usableConfigs);\n        return GL_FALSE;\n    }\n\n    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);\n    if (!closest)\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"WGL: Failed to find a suitable pixel format\");\n\n        free(usableConfigs);\n        return GL_FALSE;\n    }\n\n    *result = closest->wgl;\n    free(usableConfigs);\n\n    return GL_TRUE;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize WGL\n//\nint _glfwInitContextAPI(void)\n{\n    if (!_glfwCreateContextTLS())\n        return GL_FALSE;\n\n    _glfw.wgl.opengl32.instance = LoadLibraryW(L\"opengl32.dll\");\n    if (!_glfw.wgl.opengl32.instance)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"WGL: Failed to load opengl32.dll\");\n        return GL_FALSE;\n    }\n\n    _glfw.wgl.opengl32.CreateContext = (WGLCREATECONTEXT_T)\n        GetProcAddress(_glfw.wgl.opengl32.instance, \"wglCreateContext\");\n    _glfw.wgl.opengl32.DeleteContext = (WGLDELETECONTEXT_T)\n        GetProcAddress(_glfw.wgl.opengl32.instance, \"wglDeleteContext\");\n    _glfw.wgl.opengl32.GetProcAddress = (WGLGETPROCADDRESS_T)\n        GetProcAddress(_glfw.wgl.opengl32.instance, \"wglGetProcAddress\");\n    _glfw.wgl.opengl32.MakeCurrent = (WGLMAKECURRENT_T)\n        GetProcAddress(_glfw.wgl.opengl32.instance, \"wglMakeCurrent\");\n    _glfw.wgl.opengl32.ShareLists = (WGLSHARELISTS_T)\n        GetProcAddress(_glfw.wgl.opengl32.instance, \"wglShareLists\");\n\n    if (!_glfw.wgl.opengl32.CreateContext ||\n        !_glfw.wgl.opengl32.DeleteContext ||\n        !_glfw.wgl.opengl32.GetProcAddress ||\n        !_glfw.wgl.opengl32.MakeCurrent ||\n        !_glfw.wgl.opengl32.ShareLists)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"WGL: Failed to load opengl32 functions\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n// Terminate WGL\n//\nvoid _glfwTerminateContextAPI(void)\n{\n    if (_glfw.wgl.opengl32.instance)\n        FreeLibrary(_glfw.wgl.opengl32.instance);\n\n    _glfwDestroyContextTLS();\n}\n\n#define setWGLattrib(attribName, attribValue) \\\n{ \\\n    attribs[index++] = attribName; \\\n    attribs[index++] = attribValue; \\\n    assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \\\n}\n\n// Create the OpenGL or OpenGL ES context\n//\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig)\n{\n    int attribs[40];\n    int pixelFormat = 0;\n    PIXELFORMATDESCRIPTOR pfd;\n    HGLRC share = NULL;\n\n    if (ctxconfig->share)\n        share = ctxconfig->share->wgl.context;\n\n    window->wgl.dc = GetDC(window->win32.handle);\n    if (!window->wgl.dc)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"WGL: Failed to retrieve DC for window\");\n        return GL_FALSE;\n    }\n\n    if (!choosePixelFormat(window, fbconfig, &pixelFormat))\n        return GL_FALSE;\n\n    if (!DescribePixelFormat(window->wgl.dc, pixelFormat, sizeof(pfd), &pfd))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"WGL: Failed to retrieve PFD for selected pixel format\");\n        return GL_FALSE;\n    }\n\n    if (!SetPixelFormat(window->wgl.dc, pixelFormat, &pfd))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"WGL: Failed to set selected pixel format\");\n        return GL_FALSE;\n    }\n\n    if (window->wgl.ARB_create_context)\n    {\n        int index = 0, mask = 0, flags = 0;\n\n        if (ctxconfig->api == GLFW_OPENGL_API)\n        {\n            if (ctxconfig->forward)\n                flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;\n\n            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)\n                mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;\n            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)\n                mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;\n        }\n        else\n            mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;\n\n        if (ctxconfig->debug)\n            flags |= WGL_CONTEXT_DEBUG_BIT_ARB;\n\n        if (ctxconfig->robustness)\n        {\n            if (window->wgl.ARB_create_context_robustness)\n            {\n                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)\n                {\n                    setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,\n                                 WGL_NO_RESET_NOTIFICATION_ARB);\n                }\n                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)\n                {\n                    setWGLattrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,\n                                 WGL_LOSE_CONTEXT_ON_RESET_ARB);\n                }\n\n                flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;\n            }\n        }\n\n        if (ctxconfig->release)\n        {\n            if (window->wgl.ARB_context_flush_control)\n            {\n                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)\n                {\n                    setWGLattrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,\n                                 WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);\n                }\n                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)\n                {\n                    setWGLattrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,\n                                 WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);\n                }\n            }\n        }\n\n        // NOTE: Only request an explicitly versioned context when necessary, as\n        //       explicitly requesting version 1.0 does not always return the\n        //       highest version supported by the driver\n        if (ctxconfig->major != 1 || ctxconfig->minor != 0)\n        {\n            setWGLattrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);\n            setWGLattrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);\n        }\n\n        if (flags)\n            setWGLattrib(WGL_CONTEXT_FLAGS_ARB, flags);\n\n        if (mask)\n            setWGLattrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);\n\n        setWGLattrib(0, 0);\n\n        window->wgl.context = window->wgl.CreateContextAttribsARB(window->wgl.dc,\n                                                                  share,\n                                                                  attribs);\n        if (!window->wgl.context)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"WGL: Failed to create OpenGL context\");\n            return GL_FALSE;\n        }\n    }\n    else\n    {\n        window->wgl.context = _glfw_wglCreateContext(window->wgl.dc);\n        if (!window->wgl.context)\n        {\n            _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                            \"WGL: Failed to create OpenGL context\");\n            return GL_FALSE;\n        }\n\n        if (share)\n        {\n            if (!_glfw_wglShareLists(share, window->wgl.context))\n            {\n                _glfwInputError(GLFW_PLATFORM_ERROR,\n                                \"WGL: Failed to enable sharing with specified OpenGL context\");\n                return GL_FALSE;\n            }\n        }\n    }\n\n    _glfwPlatformMakeContextCurrent(window);\n    initWGLExtensions(window);\n\n    return GL_TRUE;\n}\n\n#undef setWGLattrib\n\n// Destroy the OpenGL context\n//\nvoid _glfwDestroyContext(_GLFWwindow* window)\n{\n    if (window->wgl.context)\n    {\n        _glfw_wglDeleteContext(window->wgl.context);\n        window->wgl.context = NULL;\n    }\n\n    if (window->wgl.dc)\n    {\n        ReleaseDC(window->win32.handle, window->wgl.dc);\n        window->wgl.dc = NULL;\n    }\n}\n\n// Analyzes the specified context for possible recreation\n//\nint _glfwAnalyzeContext(const _GLFWwindow* window,\n                        const _GLFWctxconfig* ctxconfig,\n                        const _GLFWfbconfig* fbconfig)\n{\n    GLboolean required = GL_FALSE;\n\n    if (ctxconfig->api == GLFW_OPENGL_API)\n    {\n        if (ctxconfig->forward)\n        {\n            if (!window->wgl.ARB_create_context)\n            {\n                _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                                \"WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable\");\n                return _GLFW_RECREATION_IMPOSSIBLE;\n            }\n\n            required = GL_TRUE;\n        }\n\n        if (ctxconfig->profile)\n        {\n            if (!window->wgl.ARB_create_context_profile)\n            {\n                _glfwInputError(GLFW_VERSION_UNAVAILABLE,\n                                \"WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable\");\n                return _GLFW_RECREATION_IMPOSSIBLE;\n            }\n\n            required = GL_TRUE;\n        }\n\n        if (ctxconfig->release)\n        {\n            if (window->wgl.ARB_context_flush_control)\n                required = GL_TRUE;\n        }\n    }\n    else\n    {\n        if (!window->wgl.ARB_create_context ||\n            !window->wgl.ARB_create_context_profile ||\n            !window->wgl.EXT_create_context_es2_profile)\n        {\n            _glfwInputError(GLFW_API_UNAVAILABLE,\n                            \"WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable\");\n            return _GLFW_RECREATION_IMPOSSIBLE;\n        }\n\n        required = GL_TRUE;\n    }\n\n    if (ctxconfig->major != 1 || ctxconfig->minor != 0)\n    {\n        if (window->wgl.ARB_create_context)\n            required = GL_TRUE;\n    }\n\n    if (ctxconfig->debug)\n    {\n        if (window->wgl.ARB_create_context)\n            required = GL_TRUE;\n    }\n\n    if (fbconfig->samples > 0)\n    {\n        // MSAA is not a hard constraint, so do nothing if it's not supported\n        if (window->wgl.ARB_multisample && window->wgl.ARB_pixel_format)\n            required = GL_TRUE;\n    }\n\n    if (fbconfig->sRGB)\n    {\n        // sRGB is not a hard constraint, so do nothing if it's not supported\n        if ((window->wgl.ARB_framebuffer_sRGB ||\n             window->wgl.EXT_framebuffer_sRGB) &&\n            window->wgl.ARB_pixel_format)\n        {\n            required = GL_TRUE;\n        }\n    }\n\n    if (required)\n        return _GLFW_RECREATION_REQUIRED;\n\n    return _GLFW_RECREATION_NOT_NEEDED;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwPlatformMakeContextCurrent(_GLFWwindow* window)\n{\n    if (window)\n        _glfw_wglMakeCurrent(window->wgl.dc, window->wgl.context);\n    else\n        _glfw_wglMakeCurrent(NULL, NULL);\n\n    _glfwSetContextTLS(window);\n}\n\nvoid _glfwPlatformSwapBuffers(_GLFWwindow* window)\n{\n    // HACK: Use DwmFlush when desktop composition is enabled\n    if (_glfwIsCompositionEnabled() && !window->monitor)\n    {\n        int count = abs(window->wgl.interval);\n        while (count--)\n            _glfw_DwmFlush();\n    }\n\n    SwapBuffers(window->wgl.dc);\n}\n\nvoid _glfwPlatformSwapInterval(int interval)\n{\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    window->wgl.interval = interval;\n\n    // HACK: Disable WGL swap interval when desktop composition is enabled to\n    //       avoid interfering with DWM vsync\n    if (_glfwIsCompositionEnabled() && !window->monitor)\n        interval = 0;\n\n    if (window->wgl.EXT_swap_control)\n        window->wgl.SwapIntervalEXT(interval);\n}\n\nint _glfwPlatformExtensionSupported(const char* extension)\n{\n    const char* extensions;\n\n    _GLFWwindow* window = _glfwPlatformGetCurrentContext();\n\n    if (window->wgl.GetExtensionsStringEXT != NULL)\n    {\n        extensions = window->wgl.GetExtensionsStringEXT();\n        if (extensions)\n        {\n            if (_glfwStringInExtensionString(extension, extensions))\n                return GL_TRUE;\n        }\n    }\n\n    if (window->wgl.GetExtensionsStringARB != NULL)\n    {\n        extensions = window->wgl.GetExtensionsStringARB(window->wgl.dc);\n        if (extensions)\n        {\n            if (_glfwStringInExtensionString(extension, extensions))\n                return GL_TRUE;\n        }\n    }\n\n    return GL_FALSE;\n}\n\nGLFWglproc _glfwPlatformGetProcAddress(const char* procname)\n{\n    const GLFWglproc proc = (GLFWglproc) _glfw_wglGetProcAddress(procname);\n    if (proc)\n        return proc;\n\n    return (GLFWglproc) GetProcAddress(_glfw.wgl.opengl32.instance, procname);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return window->wgl.context;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/wgl_context.h",
    "content": "//========================================================================\n// GLFW 3.1 WGL - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_wgl_context_h_\n#define _glfw3_wgl_context_h_\n\n// This path may need to be changed if you build GLFW using your own setup\n// We ship and use our own copy of wglext.h since GLFW uses fairly new\n// extensions and not all operating systems come with an up-to-date version\n#include \"../deps/GL/wglext.h\"\n\n// opengl32.dll function pointer typedefs\ntypedef HGLRC (WINAPI * WGLCREATECONTEXT_T)(HDC);\ntypedef BOOL (WINAPI * WGLDELETECONTEXT_T)(HGLRC);\ntypedef PROC (WINAPI * WGLGETPROCADDRESS_T)(LPCSTR);\ntypedef BOOL (WINAPI * WGLMAKECURRENT_T)(HDC,HGLRC);\ntypedef BOOL (WINAPI * WGLSHARELISTS_T)(HGLRC,HGLRC);\n#define _glfw_wglCreateContext _glfw.wgl.opengl32.CreateContext\n#define _glfw_wglDeleteContext _glfw.wgl.opengl32.DeleteContext\n#define _glfw_wglGetProcAddress _glfw.wgl.opengl32.GetProcAddress\n#define _glfw_wglMakeCurrent _glfw.wgl.opengl32.MakeCurrent\n#define _glfw_wglShareLists _glfw.wgl.opengl32.ShareLists\n\n#define _GLFW_PLATFORM_FBCONFIG                 int             wgl\n#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextWGL wgl\n#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryWGL wgl\n\n\n// WGL-specific per-context data\n//\ntypedef struct _GLFWcontextWGL\n{\n    HDC       dc;              // Private GDI device context\n    HGLRC     context;         // Permanent rendering context\n    int       interval;\n\n    // WGL extensions (context specific)\n    PFNWGLSWAPINTERVALEXTPROC           SwapIntervalEXT;\n    PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;\n    PFNWGLGETEXTENSIONSSTRINGEXTPROC    GetExtensionsStringEXT;\n    PFNWGLGETEXTENSIONSSTRINGARBPROC    GetExtensionsStringARB;\n    PFNWGLCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;\n    GLboolean                           EXT_swap_control;\n    GLboolean                           ARB_multisample;\n    GLboolean                           ARB_framebuffer_sRGB;\n    GLboolean                           EXT_framebuffer_sRGB;\n    GLboolean                           ARB_pixel_format;\n    GLboolean                           ARB_create_context;\n    GLboolean                           ARB_create_context_profile;\n    GLboolean                           EXT_create_context_es2_profile;\n    GLboolean                           ARB_create_context_robustness;\n    GLboolean                           ARB_context_flush_control;\n\n} _GLFWcontextWGL;\n\n\n// WGL-specific global data\n//\ntypedef struct _GLFWlibraryWGL\n{\n    struct {\n        HINSTANCE           instance;\n        WGLCREATECONTEXT_T  CreateContext;\n        WGLDELETECONTEXT_T  DeleteContext;\n        WGLGETPROCADDRESS_T GetProcAddress;\n        WGLMAKECURRENT_T    MakeCurrent;\n        WGLSHARELISTS_T     ShareLists;\n    } opengl32;\n\n} _GLFWlibraryWGL;\n\n\nint _glfwInitContextAPI(void);\nvoid _glfwTerminateContextAPI(void);\nint _glfwCreateContext(_GLFWwindow* window,\n                       const _GLFWctxconfig* ctxconfig,\n                       const _GLFWfbconfig* fbconfig);\nvoid _glfwDestroyContext(_GLFWwindow* window);\nint _glfwAnalyzeContext(const _GLFWwindow* window,\n                        const _GLFWctxconfig* ctxconfig,\n                        const _GLFWfbconfig* fbconfig);\n\n#endif // _glfw3_wgl_context_h_\n"
  },
  {
    "path": "deps/glfw/src/win32_init.c",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <malloc.h>\n\n\n#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)\n\n// Applications exporting this symbol with this value will be automatically\n// directed to the high-performance GPU on Nvidia Optimus systems with\n// up-to-date drivers\n//\n__declspec(dllexport) DWORD NvOptimusEnablement = 1;\n\n// Applications exporting this symbol with this value will be automatically\n// directed to the high-performance GPU on AMD PowerXpress systems with\n// up-to-date drivers\n//\n__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;\n\n#endif // _GLFW_USE_HYBRID_HPG\n\n#if defined(_GLFW_BUILD_DLL)\n\n// GLFW DLL entry point\n//\nBOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)\n{\n    return TRUE;\n}\n\n#endif // _GLFW_BUILD_DLL\n\n// Load necessary libraries (DLLs)\n//\nstatic GLboolean initLibraries(void)\n{\n    _glfw.win32.winmm.instance = LoadLibraryW(L\"winmm.dll\");\n    if (!_glfw.win32.winmm.instance)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to load winmm.dll\");\n        return GL_FALSE;\n    }\n\n    _glfw.win32.winmm.joyGetDevCaps = (JOYGETDEVCAPS_T)\n        GetProcAddress(_glfw.win32.winmm.instance, \"joyGetDevCapsW\");\n    _glfw.win32.winmm.joyGetPos = (JOYGETPOS_T)\n        GetProcAddress(_glfw.win32.winmm.instance, \"joyGetPos\");\n    _glfw.win32.winmm.joyGetPosEx = (JOYGETPOSEX_T)\n        GetProcAddress(_glfw.win32.winmm.instance, \"joyGetPosEx\");\n    _glfw.win32.winmm.timeGetTime = (TIMEGETTIME_T)\n        GetProcAddress(_glfw.win32.winmm.instance, \"timeGetTime\");\n\n    if (!_glfw.win32.winmm.joyGetDevCaps ||\n        !_glfw.win32.winmm.joyGetPos ||\n        !_glfw.win32.winmm.joyGetPosEx ||\n        !_glfw.win32.winmm.timeGetTime)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to load winmm functions\");\n        return GL_FALSE;\n    }\n\n    _glfw.win32.user32.instance = LoadLibraryW(L\"user32.dll\");\n    if (_glfw.win32.user32.instance)\n    {\n        _glfw.win32.user32.SetProcessDPIAware = (SETPROCESSDPIAWARE_T)\n            GetProcAddress(_glfw.win32.user32.instance, \"SetProcessDPIAware\");\n        _glfw.win32.user32.ChangeWindowMessageFilterEx = (CHANGEWINDOWMESSAGEFILTEREX_T)\n            GetProcAddress(_glfw.win32.user32.instance, \"ChangeWindowMessageFilterEx\");\n    }\n\n    _glfw.win32.dwmapi.instance = LoadLibraryW(L\"dwmapi.dll\");\n    if (_glfw.win32.dwmapi.instance)\n    {\n        _glfw.win32.dwmapi.DwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED_T)\n            GetProcAddress(_glfw.win32.dwmapi.instance, \"DwmIsCompositionEnabled\");\n        _glfw.win32.dwmapi.DwmFlush = (DWMFLUSH_T)\n            GetProcAddress(_glfw.win32.dwmapi.instance, \"DwmFlush\");\n    }\n\n    return GL_TRUE;\n}\n\n// Unload used libraries (DLLs)\n//\nstatic void terminateLibraries(void)\n{\n    if (_glfw.win32.winmm.instance)\n        FreeLibrary(_glfw.win32.winmm.instance);\n\n    if (_glfw.win32.user32.instance)\n        FreeLibrary(_glfw.win32.user32.instance);\n\n    if (_glfw.win32.dwmapi.instance)\n        FreeLibrary(_glfw.win32.dwmapi.instance);\n}\n\n// Create key code translation tables\n//\nstatic void createKeyTables(void)\n{\n    memset(_glfw.win32.publicKeys, -1, sizeof(_glfw.win32.publicKeys));\n\n    _glfw.win32.publicKeys[0x00B] = GLFW_KEY_0;\n    _glfw.win32.publicKeys[0x002] = GLFW_KEY_1;\n    _glfw.win32.publicKeys[0x003] = GLFW_KEY_2;\n    _glfw.win32.publicKeys[0x004] = GLFW_KEY_3;\n    _glfw.win32.publicKeys[0x005] = GLFW_KEY_4;\n    _glfw.win32.publicKeys[0x006] = GLFW_KEY_5;\n    _glfw.win32.publicKeys[0x007] = GLFW_KEY_6;\n    _glfw.win32.publicKeys[0x008] = GLFW_KEY_7;\n    _glfw.win32.publicKeys[0x009] = GLFW_KEY_8;\n    _glfw.win32.publicKeys[0x00A] = GLFW_KEY_9;\n    _glfw.win32.publicKeys[0x01E] = GLFW_KEY_A;\n    _glfw.win32.publicKeys[0x030] = GLFW_KEY_B;\n    _glfw.win32.publicKeys[0x02E] = GLFW_KEY_C;\n    _glfw.win32.publicKeys[0x020] = GLFW_KEY_D;\n    _glfw.win32.publicKeys[0x012] = GLFW_KEY_E;\n    _glfw.win32.publicKeys[0x021] = GLFW_KEY_F;\n    _glfw.win32.publicKeys[0x022] = GLFW_KEY_G;\n    _glfw.win32.publicKeys[0x023] = GLFW_KEY_H;\n    _glfw.win32.publicKeys[0x017] = GLFW_KEY_I;\n    _glfw.win32.publicKeys[0x024] = GLFW_KEY_J;\n    _glfw.win32.publicKeys[0x025] = GLFW_KEY_K;\n    _glfw.win32.publicKeys[0x026] = GLFW_KEY_L;\n    _glfw.win32.publicKeys[0x032] = GLFW_KEY_M;\n    _glfw.win32.publicKeys[0x031] = GLFW_KEY_N;\n    _glfw.win32.publicKeys[0x018] = GLFW_KEY_O;\n    _glfw.win32.publicKeys[0x019] = GLFW_KEY_P;\n    _glfw.win32.publicKeys[0x010] = GLFW_KEY_Q;\n    _glfw.win32.publicKeys[0x013] = GLFW_KEY_R;\n    _glfw.win32.publicKeys[0x01F] = GLFW_KEY_S;\n    _glfw.win32.publicKeys[0x014] = GLFW_KEY_T;\n    _glfw.win32.publicKeys[0x016] = GLFW_KEY_U;\n    _glfw.win32.publicKeys[0x02F] = GLFW_KEY_V;\n    _glfw.win32.publicKeys[0x011] = GLFW_KEY_W;\n    _glfw.win32.publicKeys[0x02D] = GLFW_KEY_X;\n    _glfw.win32.publicKeys[0x015] = GLFW_KEY_Y;\n    _glfw.win32.publicKeys[0x02C] = GLFW_KEY_Z;\n\n    _glfw.win32.publicKeys[0x028] = GLFW_KEY_APOSTROPHE;\n    _glfw.win32.publicKeys[0x02B] = GLFW_KEY_BACKSLASH;\n    _glfw.win32.publicKeys[0x033] = GLFW_KEY_COMMA;\n    _glfw.win32.publicKeys[0x00D] = GLFW_KEY_EQUAL;\n    _glfw.win32.publicKeys[0x029] = GLFW_KEY_GRAVE_ACCENT;\n    _glfw.win32.publicKeys[0x01A] = GLFW_KEY_LEFT_BRACKET;\n    _glfw.win32.publicKeys[0x00C] = GLFW_KEY_MINUS;\n    _glfw.win32.publicKeys[0x034] = GLFW_KEY_PERIOD;\n    _glfw.win32.publicKeys[0x01B] = GLFW_KEY_RIGHT_BRACKET;\n    _glfw.win32.publicKeys[0x027] = GLFW_KEY_SEMICOLON;\n    _glfw.win32.publicKeys[0x035] = GLFW_KEY_SLASH;\n    _glfw.win32.publicKeys[0x056] = GLFW_KEY_WORLD_2;\n\n    _glfw.win32.publicKeys[0x00E] = GLFW_KEY_BACKSPACE;\n    _glfw.win32.publicKeys[0x153] = GLFW_KEY_DELETE;\n    _glfw.win32.publicKeys[0x14F] = GLFW_KEY_END;\n    _glfw.win32.publicKeys[0x01C] = GLFW_KEY_ENTER;\n    _glfw.win32.publicKeys[0x001] = GLFW_KEY_ESCAPE;\n    _glfw.win32.publicKeys[0x147] = GLFW_KEY_HOME;\n    _glfw.win32.publicKeys[0x152] = GLFW_KEY_INSERT;\n    _glfw.win32.publicKeys[0x15D] = GLFW_KEY_MENU;\n    _glfw.win32.publicKeys[0x151] = GLFW_KEY_PAGE_DOWN;\n    _glfw.win32.publicKeys[0x149] = GLFW_KEY_PAGE_UP;\n    _glfw.win32.publicKeys[0x045] = GLFW_KEY_PAUSE;\n    _glfw.win32.publicKeys[0x039] = GLFW_KEY_SPACE;\n    _glfw.win32.publicKeys[0x00F] = GLFW_KEY_TAB;\n    _glfw.win32.publicKeys[0x03A] = GLFW_KEY_CAPS_LOCK;\n    _glfw.win32.publicKeys[0x145] = GLFW_KEY_NUM_LOCK;\n    _glfw.win32.publicKeys[0x046] = GLFW_KEY_SCROLL_LOCK;\n    _glfw.win32.publicKeys[0x03B] = GLFW_KEY_F1;\n    _glfw.win32.publicKeys[0x03C] = GLFW_KEY_F2;\n    _glfw.win32.publicKeys[0x03D] = GLFW_KEY_F3;\n    _glfw.win32.publicKeys[0x03E] = GLFW_KEY_F4;\n    _glfw.win32.publicKeys[0x03F] = GLFW_KEY_F5;\n    _glfw.win32.publicKeys[0x040] = GLFW_KEY_F6;\n    _glfw.win32.publicKeys[0x041] = GLFW_KEY_F7;\n    _glfw.win32.publicKeys[0x042] = GLFW_KEY_F8;\n    _glfw.win32.publicKeys[0x043] = GLFW_KEY_F9;\n    _glfw.win32.publicKeys[0x044] = GLFW_KEY_F10;\n    _glfw.win32.publicKeys[0x057] = GLFW_KEY_F11;\n    _glfw.win32.publicKeys[0x058] = GLFW_KEY_F12;\n    _glfw.win32.publicKeys[0x064] = GLFW_KEY_F13;\n    _glfw.win32.publicKeys[0x065] = GLFW_KEY_F14;\n    _glfw.win32.publicKeys[0x066] = GLFW_KEY_F15;\n    _glfw.win32.publicKeys[0x067] = GLFW_KEY_F16;\n    _glfw.win32.publicKeys[0x068] = GLFW_KEY_F17;\n    _glfw.win32.publicKeys[0x069] = GLFW_KEY_F18;\n    _glfw.win32.publicKeys[0x06A] = GLFW_KEY_F19;\n    _glfw.win32.publicKeys[0x06B] = GLFW_KEY_F20;\n    _glfw.win32.publicKeys[0x06C] = GLFW_KEY_F21;\n    _glfw.win32.publicKeys[0x06D] = GLFW_KEY_F22;\n    _glfw.win32.publicKeys[0x06E] = GLFW_KEY_F23;\n    _glfw.win32.publicKeys[0x076] = GLFW_KEY_F24;\n    _glfw.win32.publicKeys[0x038] = GLFW_KEY_LEFT_ALT;\n    _glfw.win32.publicKeys[0x01D] = GLFW_KEY_LEFT_CONTROL;\n    _glfw.win32.publicKeys[0x02A] = GLFW_KEY_LEFT_SHIFT;\n    _glfw.win32.publicKeys[0x15B] = GLFW_KEY_LEFT_SUPER;\n    _glfw.win32.publicKeys[0x137] = GLFW_KEY_PRINT_SCREEN;\n    _glfw.win32.publicKeys[0x138] = GLFW_KEY_RIGHT_ALT;\n    _glfw.win32.publicKeys[0x11D] = GLFW_KEY_RIGHT_CONTROL;\n    _glfw.win32.publicKeys[0x036] = GLFW_KEY_RIGHT_SHIFT;\n    _glfw.win32.publicKeys[0x15C] = GLFW_KEY_RIGHT_SUPER;\n    _glfw.win32.publicKeys[0x150] = GLFW_KEY_DOWN;\n    _glfw.win32.publicKeys[0x14B] = GLFW_KEY_LEFT;\n    _glfw.win32.publicKeys[0x14D] = GLFW_KEY_RIGHT;\n    _glfw.win32.publicKeys[0x148] = GLFW_KEY_UP;\n\n    _glfw.win32.publicKeys[0x052] = GLFW_KEY_KP_0;\n    _glfw.win32.publicKeys[0x04F] = GLFW_KEY_KP_1;\n    _glfw.win32.publicKeys[0x050] = GLFW_KEY_KP_2;\n    _glfw.win32.publicKeys[0x051] = GLFW_KEY_KP_3;\n    _glfw.win32.publicKeys[0x04B] = GLFW_KEY_KP_4;\n    _glfw.win32.publicKeys[0x04C] = GLFW_KEY_KP_5;\n    _glfw.win32.publicKeys[0x04D] = GLFW_KEY_KP_6;\n    _glfw.win32.publicKeys[0x047] = GLFW_KEY_KP_7;\n    _glfw.win32.publicKeys[0x048] = GLFW_KEY_KP_8;\n    _glfw.win32.publicKeys[0x049] = GLFW_KEY_KP_9;\n    _glfw.win32.publicKeys[0x04E] = GLFW_KEY_KP_ADD;\n    _glfw.win32.publicKeys[0x053] = GLFW_KEY_KP_DECIMAL;\n    _glfw.win32.publicKeys[0x135] = GLFW_KEY_KP_DIVIDE;\n    _glfw.win32.publicKeys[0x11C] = GLFW_KEY_KP_ENTER;\n    _glfw.win32.publicKeys[0x037] = GLFW_KEY_KP_MULTIPLY;\n    _glfw.win32.publicKeys[0x04A] = GLFW_KEY_KP_SUBTRACT;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Returns whether desktop compositing is enabled\n//\nBOOL _glfwIsCompositionEnabled(void)\n{\n    BOOL enabled;\n\n    if (!_glfw_DwmIsCompositionEnabled)\n        return FALSE;\n\n    if (_glfw_DwmIsCompositionEnabled(&enabled) != S_OK)\n        return FALSE;\n\n    return enabled;\n}\n\n// Returns a wide string version of the specified UTF-8 string\n//\nWCHAR* _glfwCreateWideStringFromUTF8(const char* source)\n{\n    WCHAR* target;\n    int length;\n\n    length = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);\n    if (!length)\n        return NULL;\n\n    target = calloc(length, sizeof(WCHAR));\n\n    if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length))\n    {\n        free(target);\n        return NULL;\n    }\n\n    return target;\n}\n\n// Returns a UTF-8 string version of the specified wide string\n//\nchar* _glfwCreateUTF8FromWideString(const WCHAR* source)\n{\n    char* target;\n    int length;\n\n    length = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);\n    if (!length)\n        return NULL;\n\n    target = calloc(length, sizeof(char));\n\n    if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length, NULL, NULL))\n    {\n        free(target);\n        return NULL;\n    }\n\n    return target;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformInit(void)\n{\n    // To make SetForegroundWindow work as we want, we need to fiddle\n    // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early\n    // as possible in the hope of still being the foreground process)\n    SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,\n                          &_glfw.win32.foregroundLockTimeout, 0);\n    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),\n                          SPIF_SENDCHANGE);\n\n    if (!initLibraries())\n        return GL_FALSE;\n\n    createKeyTables();\n\n    if (_glfw_SetProcessDPIAware)\n        _glfw_SetProcessDPIAware();\n\n    if (!_glfwRegisterWindowClass())\n        return GL_FALSE;\n\n    if (!_glfwInitContextAPI())\n        return GL_FALSE;\n\n    _glfwInitTimer();\n    _glfwInitJoysticks();\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformTerminate(void)\n{\n    _glfwUnregisterWindowClass();\n\n    // Restore previous foreground lock timeout system setting\n    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,\n                          UIntToPtr(_glfw.win32.foregroundLockTimeout),\n                          SPIF_SENDCHANGE);\n\n    free(_glfw.win32.clipboardString);\n\n    _glfwTerminateJoysticks();\n    _glfwTerminateContextAPI();\n    terminateLibraries();\n}\n\nconst char* _glfwPlatformGetVersionString(void)\n{\n    return _GLFW_VERSION_NUMBER \" Win32\"\n#if defined(_GLFW_WGL)\n        \" WGL\"\n#elif defined(_GLFW_EGL)\n        \" EGL\"\n#endif\n#if defined(__MINGW32__)\n        \" MinGW\"\n#elif defined(_MSC_VER)\n        \" VisualC\"\n#endif\n#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)\n        \" hybrid-GPU\"\n#endif\n#if defined(_GLFW_BUILD_DLL)\n        \" DLL\"\n#endif\n        ;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/win32_monitor.c",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <limits.h>\n#include <malloc.h>\n\n// These constants are missing on MinGW\n#ifndef EDS_ROTATEDMODE\n #define EDS_ROTATEDMODE 0x00000004\n#endif\n#ifndef DISPLAY_DEVICE_ACTIVE\n #define DISPLAY_DEVICE_ACTIVE 0x00000001\n#endif\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Change the current video mode\n//\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)\n{\n    GLFWvidmode current;\n    const GLFWvidmode* best;\n    DEVMODEW dm;\n\n    best = _glfwChooseVideoMode(monitor, desired);\n    _glfwPlatformGetVideoMode(monitor, &current);\n    if (_glfwCompareVideoModes(&current, best) == 0)\n        return GL_TRUE;\n\n    ZeroMemory(&dm, sizeof(dm));\n    dm.dmSize = sizeof(DEVMODEW);\n    dm.dmFields           = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |\n                            DM_DISPLAYFREQUENCY;\n    dm.dmPelsWidth        = best->width;\n    dm.dmPelsHeight       = best->height;\n    dm.dmBitsPerPel       = best->redBits + best->greenBits + best->blueBits;\n    dm.dmDisplayFrequency = best->refreshRate;\n\n    if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)\n        dm.dmBitsPerPel = 32;\n\n    if (ChangeDisplaySettingsExW(monitor->win32.adapterName,\n                                 &dm,\n                                 NULL,\n                                 CDS_FULLSCREEN,\n                                 NULL) != DISP_CHANGE_SUCCESSFUL)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Win32: Failed to set video mode\");\n        return GL_FALSE;\n    }\n\n    monitor->win32.modeChanged = GL_TRUE;\n    return GL_TRUE;\n}\n\n// Restore the previously saved (original) video mode\n//\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor)\n{\n    if (monitor->win32.modeChanged)\n    {\n        ChangeDisplaySettingsExW(monitor->win32.adapterName,\n                                 NULL, NULL, CDS_FULLSCREEN, NULL);\n        monitor->win32.modeChanged = GL_FALSE;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count)\n{\n    int found = 0;\n    _GLFWmonitor** monitors = NULL;\n    DWORD adapterIndex, displayIndex;\n\n    *count = 0;\n\n    for (adapterIndex = 0;  ;  adapterIndex++)\n    {\n        DISPLAY_DEVICEW adapter;\n\n        ZeroMemory(&adapter, sizeof(DISPLAY_DEVICEW));\n        adapter.cb = sizeof(DISPLAY_DEVICEW);\n\n        if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))\n            break;\n\n        if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))\n            continue;\n\n        for (displayIndex = 0;  ;  displayIndex++)\n        {\n            DISPLAY_DEVICEW display;\n            _GLFWmonitor* monitor;\n            char* name;\n            HDC dc;\n\n            ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));\n            display.cb = sizeof(DISPLAY_DEVICEW);\n\n            if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))\n                break;\n\n            name = _glfwCreateUTF8FromWideString(display.DeviceString);\n            if (!name)\n            {\n                _glfwInputError(GLFW_PLATFORM_ERROR,\n                                \"Win32: Failed to convert string to UTF-8\");\n                continue;\n            }\n\n            dc = CreateDCW(L\"DISPLAY\", adapter.DeviceName, NULL, NULL);\n\n            monitor = _glfwAllocMonitor(name,\n                                        GetDeviceCaps(dc, HORZSIZE),\n                                        GetDeviceCaps(dc, VERTSIZE));\n\n            DeleteDC(dc);\n            free(name);\n\n            if (adapter.StateFlags & DISPLAY_DEVICE_MODESPRUNED)\n                monitor->win32.modesPruned = GL_TRUE;\n\n            wcscpy(monitor->win32.adapterName, adapter.DeviceName);\n            wcscpy(monitor->win32.displayName, display.DeviceName);\n\n            WideCharToMultiByte(CP_UTF8, 0,\n                                adapter.DeviceName, -1,\n                                monitor->win32.publicAdapterName,\n                                sizeof(monitor->win32.publicAdapterName),\n                                NULL, NULL);\n\n            WideCharToMultiByte(CP_UTF8, 0,\n                                display.DeviceName, -1,\n                                monitor->win32.publicDisplayName,\n                                sizeof(monitor->win32.publicDisplayName),\n                                NULL, NULL);\n\n            found++;\n            monitors = realloc(monitors, sizeof(_GLFWmonitor*) * found);\n            monitors[found - 1] = monitor;\n\n            if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE &&\n                displayIndex == 0)\n            {\n                _GLFW_SWAP_POINTERS(monitors[0], monitors[found - 1]);\n            }\n        }\n    }\n\n    *count = found;\n    return monitors;\n}\n\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)\n{\n    return wcscmp(first->win32.displayName, second->win32.displayName) == 0;\n}\n\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)\n{\n    DEVMODEW settings;\n    ZeroMemory(&settings, sizeof(DEVMODEW));\n    settings.dmSize = sizeof(DEVMODEW);\n\n    EnumDisplaySettingsExW(monitor->win32.adapterName,\n                           ENUM_CURRENT_SETTINGS,\n                           &settings,\n                           EDS_ROTATEDMODE);\n\n    if (xpos)\n        *xpos = settings.dmPosition.x;\n    if (ypos)\n        *ypos = settings.dmPosition.y;\n}\n\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)\n{\n    int modeIndex = 0, size = 0;\n    GLFWvidmode* result = NULL;\n\n    *count = 0;\n\n    for (;;)\n    {\n        int i;\n        GLFWvidmode mode;\n        DEVMODEW dm;\n\n        ZeroMemory(&dm, sizeof(DEVMODEW));\n        dm.dmSize = sizeof(DEVMODEW);\n\n        if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))\n            break;\n\n        modeIndex++;\n\n        // Skip modes with less than 15 BPP\n        if (dm.dmBitsPerPel < 15)\n            continue;\n\n        mode.width  = dm.dmPelsWidth;\n        mode.height = dm.dmPelsHeight;\n        mode.refreshRate = dm.dmDisplayFrequency;\n        _glfwSplitBPP(dm.dmBitsPerPel,\n                      &mode.redBits,\n                      &mode.greenBits,\n                      &mode.blueBits);\n\n        for (i = 0;  i < *count;  i++)\n        {\n            if (_glfwCompareVideoModes(result + i, &mode) == 0)\n                break;\n        }\n\n        // Skip duplicate modes\n        if (i < *count)\n            continue;\n\n        if (monitor->win32.modesPruned)\n        {\n            // Skip modes not supported by the connected displays\n            if (ChangeDisplaySettingsExW(monitor->win32.adapterName,\n                                         &dm,\n                                         NULL,\n                                         CDS_TEST,\n                                         NULL) != DISP_CHANGE_SUCCESSFUL)\n            {\n                continue;\n            }\n        }\n\n        if (*count == size)\n        {\n            if (*count)\n                size *= 2;\n            else\n                size = 128;\n\n            result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode));\n        }\n\n        (*count)++;\n        result[*count - 1] = mode;\n    }\n\n    return result;\n}\n\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)\n{\n    DEVMODEW dm;\n\n    ZeroMemory(&dm, sizeof(DEVMODEW));\n    dm.dmSize = sizeof(DEVMODEW);\n\n    EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);\n\n    mode->width  = dm.dmPelsWidth;\n    mode->height = dm.dmPelsHeight;\n    mode->refreshRate = dm.dmDisplayFrequency;\n    _glfwSplitBPP(dm.dmBitsPerPel,\n                  &mode->redBits,\n                  &mode->greenBits,\n                  &mode->blueBits);\n}\n\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)\n{\n    HDC dc;\n    WORD values[768];\n\n    dc = CreateDCW(L\"DISPLAY\", monitor->win32.adapterName, NULL, NULL);\n    GetDeviceGammaRamp(dc, values);\n    DeleteDC(dc);\n\n    _glfwAllocGammaArrays(ramp, 256);\n\n    memcpy(ramp->red,   values +   0, 256 * sizeof(unsigned short));\n    memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short));\n    memcpy(ramp->blue,  values + 512, 256 * sizeof(unsigned short));\n}\n\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)\n{\n    HDC dc;\n    WORD values[768];\n\n    if (ramp->size != 256)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Gamma ramp size must be 256\");\n        return;\n    }\n\n    memcpy(values +   0, ramp->red,   256 * sizeof(unsigned short));\n    memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));\n    memcpy(values + 512, ramp->blue,  256 * sizeof(unsigned short));\n\n    dc = CreateDCW(L\"DISPLAY\", monitor->win32.adapterName, NULL, NULL);\n    SetDeviceGammaRamp(dc, values);\n    DeleteDC(dc);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return monitor->win32.publicAdapterName;\n}\n\nGLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return monitor->win32.publicDisplayName;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/win32_platform.h",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_win32_platform_h_\n#define _glfw3_win32_platform_h_\n\n// We don't need all the fancy stuff\n#ifndef NOMINMAX\n #define NOMINMAX\n#endif\n\n#ifndef VC_EXTRALEAN\n #define VC_EXTRALEAN\n#endif\n\n#ifndef WIN32_LEAN_AND_MEAN\n #define WIN32_LEAN_AND_MEAN\n#endif\n\n// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for\n// example to allow applications to correctly declare a GL_ARB_debug_output\n// callback) but windows.h assumes no one will define APIENTRY before it does\n#undef APIENTRY\n\n// GLFW on Windows is Unicode only and does not work in MBCS mode\n#ifndef UNICODE\n #define UNICODE\n#endif\n\n// GLFW requires Windows XP or later\n#if WINVER < 0x0501\n #undef WINVER\n #define WINVER 0x0501\n#endif\n#if _WIN32_WINNT < 0x0501\n #undef _WIN32_WINNT\n #define _WIN32_WINNT 0x0501\n#endif\n\n#include <windows.h>\n#include <mmsystem.h>\n#include <dbt.h>\n\n#if defined(_MSC_VER)\n #include <malloc.h>\n #define strdup _strdup\n#endif\n\n// HACK: Define macros that some older windows.h variants don't\n#ifndef WM_MOUSEHWHEEL\n #define WM_MOUSEHWHEEL 0x020E\n#endif\n#ifndef WM_DWMCOMPOSITIONCHANGED\n #define WM_DWMCOMPOSITIONCHANGED 0x031E\n#endif\n#ifndef WM_COPYGLOBALDATA\n #define WM_COPYGLOBALDATA 0x0049\n#endif\n#ifndef WM_UNICHAR\n #define WM_UNICHAR 0x0109\n#endif\n#ifndef UNICODE_NOCHAR\n #define UNICODE_NOCHAR 0xFFFF\n#endif\n\n#if WINVER < 0x0601\ntypedef struct tagCHANGEFILTERSTRUCT\n{\n    DWORD cbSize;\n    DWORD ExtStatus;\n\n} CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT;\n#ifndef MSGFLT_ALLOW\n #define MSGFLT_ALLOW 1\n#endif\n#endif /*Windows 7*/\n\n// winmm.dll function pointer typedefs\ntypedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);\ntypedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);\ntypedef MMRESULT (WINAPI * JOYGETPOSEX_T)(UINT,LPJOYINFOEX);\ntypedef DWORD (WINAPI * TIMEGETTIME_T)(void);\n#define _glfw_joyGetDevCaps _glfw.win32.winmm.joyGetDevCaps\n#define _glfw_joyGetPos _glfw.win32.winmm.joyGetPos\n#define _glfw_joyGetPosEx _glfw.win32.winmm.joyGetPosEx\n#define _glfw_timeGetTime _glfw.win32.winmm.timeGetTime\n\n// user32.dll function pointer typedefs\ntypedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);\ntypedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);\n#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware\n#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx\n\n// dwmapi.dll function pointer typedefs\ntypedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);\ntypedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);\n#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled\n#define _glfw_DwmFlush _glfw.win32.dwmapi.DwmFlush\n\n#define _GLFW_RECREATION_NOT_NEEDED 0\n#define _GLFW_RECREATION_REQUIRED   1\n#define _GLFW_RECREATION_IMPOSSIBLE 2\n\n#include \"win32_tls.h\"\n#include \"winmm_joystick.h\"\n\n#if defined(_GLFW_WGL)\n #include \"wgl_context.h\"\n#elif defined(_GLFW_EGL)\n #define _GLFW_EGL_NATIVE_WINDOW  window->win32.handle\n #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY\n #include \"egl_context.h\"\n#else\n #error \"No supported context creation API selected\"\n#endif\n\n#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWin32  win32\n#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32\n#define _GLFW_PLATFORM_LIBRARY_TIME_STATE   _GLFWtimeWin32    win32_time\n#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWin32 win32\n#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWin32  win32\n\n\n// Win32-specific per-window data\n//\ntypedef struct _GLFWwindowWin32\n{\n    HWND                handle;\n\n    GLboolean           cursorTracked;\n    GLboolean           iconified;\n\n    // The last received cursor position, regardless of source\n    int                 cursorPosX, cursorPosY;\n\n} _GLFWwindowWin32;\n\n\n// Win32-specific global data\n//\ntypedef struct _GLFWlibraryWin32\n{\n    DWORD               foregroundLockTimeout;\n    char*               clipboardString;\n    short int           publicKeys[512];\n\n    // winmm.dll\n    struct {\n        HINSTANCE       instance;\n        JOYGETDEVCAPS_T joyGetDevCaps;\n        JOYGETPOS_T     joyGetPos;\n        JOYGETPOSEX_T   joyGetPosEx;\n        TIMEGETTIME_T   timeGetTime;\n    } winmm;\n\n    // user32.dll\n    struct {\n        HINSTANCE       instance;\n        SETPROCESSDPIAWARE_T SetProcessDPIAware;\n        CHANGEWINDOWMESSAGEFILTEREX_T ChangeWindowMessageFilterEx;\n    } user32;\n\n    // dwmapi.dll\n    struct {\n        HINSTANCE       instance;\n        DWMISCOMPOSITIONENABLED_T DwmIsCompositionEnabled;\n        DWMFLUSH_T      DwmFlush;\n    } dwmapi;\n\n} _GLFWlibraryWin32;\n\n\n// Win32-specific per-monitor data\n//\ntypedef struct _GLFWmonitorWin32\n{\n    // This size matches the static size of DISPLAY_DEVICE.DeviceName\n    WCHAR               adapterName[32];\n    WCHAR               displayName[32];\n    char                publicAdapterName[64];\n    char                publicDisplayName[64];\n    GLboolean           modesPruned;\n    GLboolean           modeChanged;\n\n} _GLFWmonitorWin32;\n\n\n// Win32-specific per-cursor data\n//\ntypedef struct _GLFWcursorWin32\n{\n    HCURSOR handle;\n\n} _GLFWcursorWin32;\n\n\n// Win32-specific global timer data\n//\ntypedef struct _GLFWtimeWin32\n{\n    GLboolean           hasPC;\n    double              resolution;\n    unsigned __int64    base;\n\n} _GLFWtimeWin32;\n\n\nGLboolean _glfwRegisterWindowClass(void);\nvoid _glfwUnregisterWindowClass(void);\n\nBOOL _glfwIsCompositionEnabled(void);\n\nWCHAR* _glfwCreateWideStringFromUTF8(const char* source);\nchar* _glfwCreateUTF8FromWideString(const WCHAR* source);\n\nvoid _glfwInitTimer(void);\n\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor);\n\n#endif // _glfw3_win32_platform_h_\n"
  },
  {
    "path": "deps/glfw/src/win32_time.c",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n\n// Return raw time\n//\nstatic unsigned __int64 getRawTime(void)\n{\n    if (_glfw.win32_time.hasPC)\n    {\n        unsigned __int64 time;\n        QueryPerformanceCounter((LARGE_INTEGER*) &time);\n        return time;\n    }\n    else\n        return (unsigned __int64) _glfw_timeGetTime();\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialise timer\n//\nvoid _glfwInitTimer(void)\n{\n    unsigned __int64 frequency;\n\n    if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))\n    {\n        _glfw.win32_time.hasPC = GL_TRUE;\n        _glfw.win32_time.resolution = 1.0 / (double) frequency;\n    }\n    else\n    {\n        _glfw.win32_time.hasPC = GL_FALSE;\n        _glfw.win32_time.resolution = 0.001; // winmm resolution is 1 ms\n    }\n\n    _glfw.win32_time.base = getRawTime();\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\ndouble _glfwPlatformGetTime(void)\n{\n    return (double) (getRawTime() - _glfw.win32_time.base) *\n        _glfw.win32_time.resolution;\n}\n\nvoid _glfwPlatformSetTime(double time)\n{\n    _glfw.win32_time.base = getRawTime() -\n        (unsigned __int64) (time / _glfw.win32_time.resolution);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/win32_tls.c",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwCreateContextTLS(void)\n{\n    _glfw.win32_tls.context = TlsAlloc();\n    if (_glfw.win32_tls.context == TLS_OUT_OF_INDEXES)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to allocate TLS index\");\n        return GL_FALSE;\n    }\n\n    _glfw.win32_tls.allocated = GL_TRUE;\n    return GL_TRUE;\n}\n\nvoid _glfwDestroyContextTLS(void)\n{\n    if (_glfw.win32_tls.allocated)\n        TlsFree(_glfw.win32_tls.context);\n}\n\nvoid _glfwSetContextTLS(_GLFWwindow* context)\n{\n    TlsSetValue(_glfw.win32_tls.context, context);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWwindow* _glfwPlatformGetCurrentContext(void)\n{\n    return TlsGetValue(_glfw.win32_tls.context);\n}\n\n"
  },
  {
    "path": "deps/glfw/src/win32_tls.h",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_win32_tls_h_\n#define _glfw3_win32_tls_h_\n\n#define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsWin32 win32_tls\n\n\n// Win32-specific global TLS data\n//\ntypedef struct _GLFWtlsWin32\n{\n    GLboolean       allocated;\n    DWORD           context;\n\n} _GLFWtlsWin32;\n\n\nint _glfwCreateContextTLS(void);\nvoid _glfwDestroyContextTLS(void);\nvoid _glfwSetContextTLS(_GLFWwindow* context);\n\n#endif // _glfw3_win32_tls_h_\n"
  },
  {
    "path": "deps/glfw/src/win32_window.c",
    "content": "//========================================================================\n// GLFW 3.1 Win32 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n#include <malloc.h>\n#include <string.h>\n#include <windowsx.h>\n#include <shellapi.h>\n\n#define _GLFW_KEY_INVALID -2\n\n#define _GLFW_WNDCLASSNAME L\"GLFW30\"\n\n\n// Returns the window style for the specified window\n//\nstatic DWORD getWindowStyle(const _GLFWwindow* window)\n{\n    DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;\n\n    if (window->decorated && !window->monitor)\n    {\n        style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;\n\n        if (window->resizable)\n            style |= WS_MAXIMIZEBOX | WS_SIZEBOX;\n    }\n    else\n        style |= WS_POPUP;\n\n    return style;\n}\n\n// Returns the extended window style for the specified window\n//\nstatic DWORD getWindowExStyle(const _GLFWwindow* window)\n{\n    DWORD style = WS_EX_APPWINDOW;\n\n    if (window->decorated && !window->monitor)\n        style |= WS_EX_WINDOWEDGE;\n\n    return style;\n}\n\n// Updates the cursor clip rect\n//\nstatic void updateClipRect(_GLFWwindow* window)\n{\n    RECT clipRect;\n    GetClientRect(window->win32.handle, &clipRect);\n    ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);\n    ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);\n    ClipCursor(&clipRect);\n}\n\n// Hide the mouse cursor\n//\nstatic void hideCursor(_GLFWwindow* window)\n{\n    POINT pos;\n\n    ClipCursor(NULL);\n\n    if (GetCursorPos(&pos))\n    {\n        if (WindowFromPoint(pos) == window->win32.handle)\n            SetCursor(NULL);\n    }\n}\n\n// Disable the mouse cursor\n//\nstatic void disableCursor(_GLFWwindow* window)\n{\n    POINT pos;\n\n    updateClipRect(window);\n\n    if (GetCursorPos(&pos))\n    {\n        if (WindowFromPoint(pos) == window->win32.handle)\n            SetCursor(NULL);\n    }\n}\n\n// Restores the mouse cursor\n//\nstatic void restoreCursor(_GLFWwindow* window)\n{\n    POINT pos;\n\n    ClipCursor(NULL);\n\n    if (GetCursorPos(&pos))\n    {\n        if (WindowFromPoint(pos) == window->win32.handle)\n        {\n            if (window->cursor)\n                SetCursor(window->cursor->win32.handle);\n            else\n                SetCursor(LoadCursorW(NULL, IDC_ARROW));\n        }\n    }\n}\n\n// Translates a GLFW standard cursor to a resource ID\n//\nstatic LPWSTR translateCursorShape(int shape)\n{\n    switch (shape)\n    {\n        case GLFW_ARROW_CURSOR:\n            return IDC_ARROW;\n        case GLFW_IBEAM_CURSOR:\n            return IDC_IBEAM;\n        case GLFW_CROSSHAIR_CURSOR:\n            return IDC_CROSS;\n        case GLFW_HAND_CURSOR:\n            return IDC_HAND;\n        case GLFW_HRESIZE_CURSOR:\n            return IDC_SIZEWE;\n        case GLFW_VRESIZE_CURSOR:\n            return IDC_SIZENS;\n    }\n\n    return NULL;\n}\n\n// Retrieves and translates modifier keys\n//\nstatic int getKeyMods(void)\n{\n    int mods = 0;\n\n    if (GetKeyState(VK_SHIFT) & (1 << 31))\n        mods |= GLFW_MOD_SHIFT;\n    if (GetKeyState(VK_CONTROL) & (1 << 31))\n        mods |= GLFW_MOD_CONTROL;\n    if (GetKeyState(VK_MENU) & (1 << 31))\n        mods |= GLFW_MOD_ALT;\n    if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & (1 << 31))\n        mods |= GLFW_MOD_SUPER;\n\n    return mods;\n}\n\n// Retrieves and translates modifier keys\n//\nstatic int getAsyncKeyMods(void)\n{\n    int mods = 0;\n\n    if (GetAsyncKeyState(VK_SHIFT) & (1 << 31))\n        mods |= GLFW_MOD_SHIFT;\n    if (GetAsyncKeyState(VK_CONTROL) & (1 << 31))\n        mods |= GLFW_MOD_CONTROL;\n    if (GetAsyncKeyState(VK_MENU) & (1 << 31))\n        mods |= GLFW_MOD_ALT;\n    if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & (1 << 31))\n        mods |= GLFW_MOD_SUPER;\n\n    return mods;\n}\n\n// Translates a Windows key to the corresponding GLFW key\n//\nstatic int translateKey(WPARAM wParam, LPARAM lParam)\n{\n    if (wParam == VK_CONTROL)\n    {\n        // The CTRL keys require special handling\n\n        MSG next;\n        DWORD time;\n\n        // Is this an extended key (i.e. right key)?\n        if (lParam & 0x01000000)\n            return GLFW_KEY_RIGHT_CONTROL;\n\n        // Here is a trick: \"Alt Gr\" sends LCTRL, then RALT. We only\n        // want the RALT message, so we try to see if the next message\n        // is a RALT message. In that case, this is a false LCTRL!\n        time = GetMessageTime();\n\n        if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))\n        {\n            if (next.message == WM_KEYDOWN ||\n                next.message == WM_SYSKEYDOWN ||\n                next.message == WM_KEYUP ||\n                next.message == WM_SYSKEYUP)\n            {\n                if (next.wParam == VK_MENU &&\n                    (next.lParam & 0x01000000) &&\n                    next.time == time)\n                {\n                    // Next message is a RALT down message, which\n                    // means that this is not a proper LCTRL message\n                    return _GLFW_KEY_INVALID;\n                }\n            }\n        }\n\n        return GLFW_KEY_LEFT_CONTROL;\n    }\n\n    return _glfw.win32.publicKeys[HIWORD(lParam) & 0x1FF];\n}\n\n// Enter full screen mode\n//\nstatic GLboolean enterFullscreenMode(_GLFWwindow* window)\n{\n    GLFWvidmode mode;\n    GLboolean status;\n    int xpos, ypos;\n\n    status = _glfwSetVideoMode(window->monitor, &window->videoMode);\n\n    _glfwPlatformGetVideoMode(window->monitor, &mode);\n    _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);\n\n    SetWindowPos(window->win32.handle, HWND_TOPMOST,\n                 xpos, ypos, mode.width, mode.height, SWP_NOCOPYBITS);\n\n    return status;\n}\n\n// Leave full screen mode\n//\nstatic void leaveFullscreenMode(_GLFWwindow* window)\n{\n    _glfwRestoreVideoMode(window->monitor);\n}\n\n// Window callback function (handles window events)\n//\nstatic LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,\n                                   WPARAM wParam, LPARAM lParam)\n{\n    _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0);\n\n    switch (uMsg)\n    {\n        case WM_NCCREATE:\n        {\n            CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;\n            SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);\n            break;\n        }\n\n        case WM_SETFOCUS:\n        {\n            if (window->cursorMode != GLFW_CURSOR_NORMAL)\n                _glfwPlatformApplyCursorMode(window);\n\n            _glfwInputWindowFocus(window, GL_TRUE);\n            return 0;\n        }\n\n        case WM_KILLFOCUS:\n        {\n            if (window->cursorMode != GLFW_CURSOR_NORMAL)\n                restoreCursor(window);\n\n            if (window->monitor && window->autoIconify)\n                _glfwPlatformIconifyWindow(window);\n\n            _glfwInputWindowFocus(window, GL_FALSE);\n            return 0;\n        }\n\n        case WM_SYSCOMMAND:\n        {\n            switch (wParam & 0xfff0)\n            {\n                case SC_SCREENSAVE:\n                case SC_MONITORPOWER:\n                {\n                    if (window->monitor)\n                    {\n                        // We are running in full screen mode, so disallow\n                        // screen saver and screen blanking\n                        return 0;\n                    }\n                    else\n                        break;\n                }\n\n                // User trying to access application menu using ALT?\n                case SC_KEYMENU:\n                    return 0;\n            }\n            break;\n        }\n\n        case WM_CLOSE:\n        {\n            _glfwInputWindowCloseRequest(window);\n            return 0;\n        }\n\n        case WM_KEYDOWN:\n        case WM_SYSKEYDOWN:\n        {\n            const int scancode = (lParam >> 16) & 0x1ff;\n            const int key = translateKey(wParam, lParam);\n            if (key == _GLFW_KEY_INVALID)\n                break;\n\n            _glfwInputKey(window, key, scancode, GLFW_PRESS, getKeyMods());\n            break;\n        }\n\n        case WM_CHAR:\n        {\n            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);\n            return 0;\n        }\n\n        case WM_SYSCHAR:\n        {\n            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_FALSE);\n            return 0;\n        }\n\n        case WM_UNICHAR:\n        {\n            // This message is not sent by Windows, but is sent by some\n            // third-party input method engines\n\n            if (wParam == UNICODE_NOCHAR)\n            {\n                // Returning TRUE here announces support for this message\n                return TRUE;\n            }\n\n            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GL_TRUE);\n            return FALSE;\n        }\n\n        case WM_KEYUP:\n        case WM_SYSKEYUP:\n        {\n            const int mods = getKeyMods();\n            const int scancode = (lParam >> 16) & 0x1ff;\n            const int key = translateKey(wParam, lParam);\n            if (key == _GLFW_KEY_INVALID)\n                break;\n\n            if (wParam == VK_SHIFT)\n            {\n                // Release both Shift keys on Shift up event, as only one event\n                // is sent even if both keys are released\n                _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, GLFW_RELEASE, mods);\n                _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, GLFW_RELEASE, mods);\n            }\n            else if (wParam == VK_SNAPSHOT)\n            {\n                // Key down is not reported for the print screen key\n                _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);\n                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);\n            }\n            else\n                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);\n\n            break;\n        }\n\n        case WM_LBUTTONDOWN:\n        case WM_RBUTTONDOWN:\n        case WM_MBUTTONDOWN:\n        case WM_XBUTTONDOWN:\n        {\n            const int mods = getKeyMods();\n\n            SetCapture(hWnd);\n\n            if (uMsg == WM_LBUTTONDOWN)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);\n            else if (uMsg == WM_RBUTTONDOWN)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);\n            else if (uMsg == WM_MBUTTONDOWN)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);\n            else\n            {\n                if (HIWORD(wParam) == XBUTTON1)\n                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_PRESS, mods);\n                else if (HIWORD(wParam) == XBUTTON2)\n                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_PRESS, mods);\n\n                return TRUE;\n            }\n\n            return 0;\n        }\n\n        case WM_LBUTTONUP:\n        case WM_RBUTTONUP:\n        case WM_MBUTTONUP:\n        case WM_XBUTTONUP:\n        {\n            const int mods = getKeyMods();\n\n            ReleaseCapture();\n\n            if (uMsg == WM_LBUTTONUP)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods);\n            else if (uMsg == WM_RBUTTONUP)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, mods);\n            else if (uMsg == WM_MBUTTONUP)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE, mods);\n            else\n            {\n                if (HIWORD(wParam) == XBUTTON1)\n                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_4, GLFW_RELEASE, mods);\n                else if (HIWORD(wParam) == XBUTTON2)\n                    _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_5, GLFW_RELEASE, mods);\n\n                return TRUE;\n            }\n\n            return 0;\n        }\n\n        case WM_MOUSEMOVE:\n        {\n            const int x = GET_X_LPARAM(lParam);\n            const int y = GET_Y_LPARAM(lParam);\n\n            if (window->cursorMode == GLFW_CURSOR_DISABLED)\n            {\n                if (_glfw.cursorWindow != window)\n                    break;\n\n                _glfwInputCursorMotion(window,\n                                       x - window->win32.cursorPosX,\n                                       y - window->win32.cursorPosY);\n            }\n            else\n                _glfwInputCursorMotion(window, x, y);\n\n            window->win32.cursorPosX = x;\n            window->win32.cursorPosY = y;\n\n            if (!window->win32.cursorTracked)\n            {\n                TRACKMOUSEEVENT tme;\n                ZeroMemory(&tme, sizeof(tme));\n                tme.cbSize = sizeof(tme);\n                tme.dwFlags = TME_LEAVE;\n                tme.hwndTrack = window->win32.handle;\n                TrackMouseEvent(&tme);\n\n                window->win32.cursorTracked = GL_TRUE;\n                _glfwInputCursorEnter(window, GL_TRUE);\n            }\n\n            return 0;\n        }\n\n        case WM_MOUSELEAVE:\n        {\n            window->win32.cursorTracked = GL_FALSE;\n            _glfwInputCursorEnter(window, GL_FALSE);\n            return 0;\n        }\n\n        case WM_MOUSEWHEEL:\n        {\n            _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);\n            return 0;\n        }\n\n        case WM_MOUSEHWHEEL:\n        {\n            // This message is only sent on Windows Vista and later\n            // NOTE: The X-axis is inverted for consistency with OS X and X11.\n            _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);\n            return 0;\n        }\n\n        case WM_SIZE:\n        {\n            if (_glfw.cursorWindow == window)\n            {\n                if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                    updateClipRect(window);\n            }\n\n            if (!window->win32.iconified && wParam == SIZE_MINIMIZED)\n            {\n                window->win32.iconified = GL_TRUE;\n                if (window->monitor)\n                    leaveFullscreenMode(window);\n\n                _glfwInputWindowIconify(window, GL_TRUE);\n            }\n            else if (window->win32.iconified &&\n                     (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED))\n            {\n                window->win32.iconified = GL_FALSE;\n                if (window->monitor)\n                    enterFullscreenMode(window);\n\n                _glfwInputWindowIconify(window, GL_FALSE);\n            }\n\n            _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));\n            _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));\n            return 0;\n        }\n\n        case WM_MOVE:\n        {\n            if (_glfw.cursorWindow == window)\n            {\n                if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                    updateClipRect(window);\n            }\n\n            // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as\n            // those macros do not handle negative window positions correctly\n            _glfwInputWindowPos(window,\n                                GET_X_LPARAM(lParam),\n                                GET_Y_LPARAM(lParam));\n            return 0;\n        }\n\n        case WM_PAINT:\n        {\n            _glfwInputWindowDamage(window);\n            break;\n        }\n\n        case WM_ERASEBKGND:\n        {\n            return TRUE;\n        }\n\n        case WM_SETCURSOR:\n        {\n            if (_glfw.cursorWindow == window && LOWORD(lParam) == HTCLIENT)\n            {\n                if (window->cursorMode == GLFW_CURSOR_HIDDEN ||\n                    window->cursorMode == GLFW_CURSOR_DISABLED)\n                {\n                    SetCursor(NULL);\n                    return TRUE;\n                }\n                else if (window->cursor)\n                {\n                    SetCursor(window->cursor->win32.handle);\n                    return TRUE;\n                }\n            }\n\n            break;\n        }\n\n        case WM_DEVICECHANGE:\n        {\n            if (DBT_DEVNODES_CHANGED == wParam)\n            {\n                _glfwInputMonitorChange();\n                return TRUE;\n            }\n            break;\n        }\n\n        case WM_DROPFILES:\n        {\n            HDROP drop = (HDROP) wParam;\n            POINT pt;\n            int i;\n\n            const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);\n            char** paths = calloc(count, sizeof(char*));\n\n            // Move the mouse to the position of the drop\n            DragQueryPoint(drop, &pt);\n            _glfwInputCursorMotion(window, pt.x, pt.y);\n\n            for (i = 0;  i < count;  i++)\n            {\n                const UINT length = DragQueryFileW(drop, i, NULL, 0);\n                WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));\n\n                DragQueryFileW(drop, i, buffer, length + 1);\n                paths[i] = _glfwCreateUTF8FromWideString(buffer);\n\n                free(buffer);\n            }\n\n            _glfwInputDrop(window, count, (const char**) paths);\n\n            for (i = 0;  i < count;  i++)\n                free(paths[i]);\n            free(paths);\n\n            DragFinish(drop);\n            return 0;\n        }\n    }\n\n    return DefWindowProc(hWnd, uMsg, wParam, lParam);\n}\n\n// Translate client window size to full window size (including window borders)\n//\nstatic void getFullWindowSize(_GLFWwindow* window,\n                              int clientWidth, int clientHeight,\n                              int* fullWidth, int* fullHeight)\n{\n    RECT rect = { 0, 0, clientWidth, clientHeight };\n    AdjustWindowRectEx(&rect, getWindowStyle(window),\n                       FALSE, getWindowExStyle(window));\n    *fullWidth = rect.right - rect.left;\n    *fullHeight = rect.bottom - rect.top;\n}\n\n// Creates the GLFW window and rendering context\n//\nstatic int createWindow(_GLFWwindow* window,\n                        const _GLFWwndconfig* wndconfig,\n                        const _GLFWctxconfig* ctxconfig,\n                        const _GLFWfbconfig* fbconfig)\n{\n    int xpos, ypos, fullWidth, fullHeight;\n    WCHAR* wideTitle;\n\n    if (wndconfig->monitor)\n    {\n        GLFWvidmode mode;\n\n        // NOTE: This window placement is temporary and approximate, as the\n        //       correct position and size cannot be known until the monitor\n        //       video mode has been set\n        _glfwPlatformGetMonitorPos(wndconfig->monitor, &xpos, &ypos);\n        _glfwPlatformGetVideoMode(wndconfig->monitor, &mode);\n        fullWidth  = mode.width;\n        fullHeight = mode.height;\n    }\n    else\n    {\n        xpos = CW_USEDEFAULT;\n        ypos = CW_USEDEFAULT;\n\n        getFullWindowSize(window,\n                          wndconfig->width, wndconfig->height,\n                          &fullWidth, &fullHeight);\n    }\n\n    wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);\n    if (!wideTitle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to convert window title to UTF-16\");\n        return GL_FALSE;\n    }\n\n    window->win32.handle = CreateWindowExW(getWindowExStyle(window),\n                                           _GLFW_WNDCLASSNAME,\n                                           wideTitle,\n                                           getWindowStyle(window),\n                                           xpos, ypos,\n                                           fullWidth, fullHeight,\n                                           NULL, // No parent window\n                                           NULL, // No window menu\n                                           GetModuleHandleW(NULL),\n                                           window); // Pass object to WM_CREATE\n\n    free(wideTitle);\n\n    if (!window->win32.handle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Win32: Failed to create window\");\n        return GL_FALSE;\n    }\n\n    if (_glfw_ChangeWindowMessageFilterEx)\n    {\n        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,\n                                          WM_DROPFILES, MSGFLT_ALLOW, NULL);\n        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,\n                                          WM_COPYDATA, MSGFLT_ALLOW, NULL);\n        _glfw_ChangeWindowMessageFilterEx(window->win32.handle,\n                                          WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);\n    }\n\n    if (wndconfig->floating && !wndconfig->monitor)\n    {\n        SetWindowPos(window->win32.handle,\n                     HWND_TOPMOST,\n                     0, 0, 0, 0,\n                     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);\n    }\n\n    DragAcceptFiles(window->win32.handle, TRUE);\n\n    if (!_glfwCreateContext(window, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    return GL_TRUE;\n}\n\n// Destroys the GLFW window and rendering context\n//\nstatic void destroyWindow(_GLFWwindow* window)\n{\n    _glfwDestroyContext(window);\n\n    if (window->win32.handle)\n    {\n        DestroyWindow(window->win32.handle);\n        window->win32.handle = NULL;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Registers the GLFW window class\n//\nGLboolean _glfwRegisterWindowClass(void)\n{\n    WNDCLASSW wc;\n\n    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;\n    wc.lpfnWndProc   = (WNDPROC) windowProc;\n    wc.cbClsExtra    = 0;                           // No extra class data\n    wc.cbWndExtra    = sizeof(void*) + sizeof(int); // Make room for one pointer\n    wc.hInstance     = GetModuleHandleW(NULL);\n    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);\n    wc.hbrBackground = NULL;                        // No background\n    wc.lpszMenuName  = NULL;                        // No menu\n    wc.lpszClassName = _GLFW_WNDCLASSNAME;\n\n    // Load user-provided icon if available\n    wc.hIcon = LoadIconW(GetModuleHandleW(NULL), L\"GLFW_ICON\");\n    if (!wc.hIcon)\n    {\n        // No user-provided icon found, load default icon\n        wc.hIcon = LoadIconW(NULL, IDI_WINLOGO);\n    }\n\n    if (!RegisterClassW(&wc))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to register window class\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\n// Unregisters the GLFW window class\n//\nvoid _glfwUnregisterWindowClass(void)\n{\n    UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig)\n{\n    int status;\n\n    if (!createWindow(window, wndconfig, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);\n\n    if (status == _GLFW_RECREATION_IMPOSSIBLE)\n        return GL_FALSE;\n\n    if (status == _GLFW_RECREATION_REQUIRED)\n    {\n        // Some window hints require us to re-create the context using WGL\n        // extensions retrieved through the current context, as we cannot check\n        // for WGL extensions or retrieve WGL entry points before we have a\n        // current context (actually until we have implicitly loaded the ICD)\n\n        // Yes, this is strange, and yes, this is the proper way on Win32\n\n        // As Windows only allows you to set the pixel format once for a\n        // window, we need to destroy the current window and create a new one\n        // to be able to use the new pixel format\n\n        // Technically, it may be possible to keep the old window around if\n        // we're just creating an OpenGL 3.0+ context with the same pixel\n        // format, but it's not worth the added code complexity\n\n        // First we clear the current context (the one we just created)\n        // This is usually done by glfwDestroyWindow, but as we're not doing\n        // full GLFW window destruction, it's duplicated here\n        _glfwPlatformMakeContextCurrent(NULL);\n\n        // Next destroy the Win32 window and WGL context (without resetting or\n        // destroying the GLFW window object)\n        destroyWindow(window);\n\n        // ...and then create them again, this time with better APIs\n        if (!createWindow(window, wndconfig, ctxconfig, fbconfig))\n            return GL_FALSE;\n    }\n\n    if (window->monitor)\n    {\n        _glfwPlatformShowWindow(window);\n        if (!enterFullscreenMode(window))\n            return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window)\n{\n    if (window->monitor)\n        leaveFullscreenMode(window);\n\n    destroyWindow(window);\n}\n\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)\n{\n    WCHAR* wideTitle = _glfwCreateWideStringFromUTF8(title);\n    if (!wideTitle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to convert window title to UTF-16\");\n        return;\n    }\n\n    SetWindowTextW(window->win32.handle, wideTitle);\n    free(wideTitle);\n}\n\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)\n{\n    POINT pos = { 0, 0 };\n    ClientToScreen(window->win32.handle, &pos);\n\n    if (xpos)\n        *xpos = pos.x;\n    if (ypos)\n        *ypos = pos.y;\n}\n\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)\n{\n    RECT rect = { xpos, ypos, xpos, ypos };\n    AdjustWindowRectEx(&rect, getWindowStyle(window),\n                       FALSE, getWindowExStyle(window));\n    SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,\n                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);\n}\n\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)\n{\n    RECT area;\n    GetClientRect(window->win32.handle, &area);\n\n    if (width)\n        *width = area.right;\n    if (height)\n        *height = area.bottom;\n}\n\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)\n{\n    if (window->monitor)\n        enterFullscreenMode(window);\n    else\n    {\n        int fullWidth, fullHeight;\n        getFullWindowSize(window, width, height, &fullWidth, &fullHeight);\n\n        SetWindowPos(window->win32.handle, HWND_TOP,\n                     0, 0, fullWidth, fullHeight,\n                     SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);\n    }\n}\n\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)\n{\n    _glfwPlatformGetWindowSize(window, width, height);\n}\n\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,\n                                     int* left, int* top,\n                                     int* right, int* bottom)\n{\n    RECT rect;\n    int width, height;\n\n    _glfwPlatformGetWindowSize(window, &width, &height);\n    SetRect(&rect, 0, 0, width, height);\n    AdjustWindowRectEx(&rect, getWindowStyle(window),\n                       FALSE, getWindowExStyle(window));\n\n    if (left)\n        *left = -rect.left;\n    if (top)\n        *top = -rect.top;\n    if (right)\n        *right = rect.right - width;\n    if (bottom)\n        *bottom = rect.bottom - height;\n}\n\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window)\n{\n    ShowWindow(window->win32.handle, SW_MINIMIZE);\n}\n\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window)\n{\n    ShowWindow(window->win32.handle, SW_RESTORE);\n}\n\nvoid _glfwPlatformShowWindow(_GLFWwindow* window)\n{\n    ShowWindow(window->win32.handle, SW_SHOW);\n    BringWindowToTop(window->win32.handle);\n    SetForegroundWindow(window->win32.handle);\n    SetFocus(window->win32.handle);\n}\n\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window)\n{\n    ShowWindow(window->win32.handle, SW_SHOW);\n}\n\nvoid _glfwPlatformHideWindow(_GLFWwindow* window)\n{\n    ShowWindow(window->win32.handle, SW_HIDE);\n}\n\nint _glfwPlatformWindowFocused(_GLFWwindow* window)\n{\n    return window->win32.handle == GetActiveWindow();\n}\n\nint _glfwPlatformWindowIconified(_GLFWwindow* window)\n{\n    return IsIconic(window->win32.handle);\n}\n\nint _glfwPlatformWindowVisible(_GLFWwindow* window)\n{\n    return IsWindowVisible(window->win32.handle);\n}\n\nvoid _glfwPlatformPollEvents(void)\n{\n    MSG msg;\n\n    while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))\n    {\n        if (msg.message == WM_QUIT)\n        {\n            // Treat WM_QUIT as a close on all windows\n            // While GLFW does not itself post WM_QUIT, other processes may post\n            // it to this one, for example Task Manager\n\n            _GLFWwindow* window = _glfw.windowListHead;\n            while (window)\n            {\n                _glfwInputWindowCloseRequest(window);\n                window = window->next;\n            }\n        }\n        else\n        {\n            TranslateMessage(&msg);\n            DispatchMessageW(&msg);\n        }\n    }\n\n    if (_glfw.cursorWindow)\n    {\n        _GLFWwindow* window = _glfw.cursorWindow;\n\n        // LSHIFT/RSHIFT fixup (keys tend to \"stick\" without this fix)\n        // This is the only async event handling in GLFW, but it solves some\n        // nasty problems\n        {\n            const int mods = getAsyncKeyMods();\n\n            // Get current state of left and right shift keys\n            const int lshiftDown = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1;\n            const int rshiftDown = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1;\n\n            // See if this differs from our belief of what has happened\n            // (we only have to check for lost key up events)\n            if (!lshiftDown && window->keys[GLFW_KEY_LEFT_SHIFT] == 1)\n                _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, 0, GLFW_RELEASE, mods);\n\n            if (!rshiftDown && window->keys[GLFW_KEY_RIGHT_SHIFT] == 1)\n                _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, 0, GLFW_RELEASE, mods);\n        }\n\n        if (window->cursorMode == GLFW_CURSOR_DISABLED)\n        {\n            int width, height;\n            _glfwPlatformGetWindowSize(window, &width, &height);\n\n            // NOTE: Re-center the cursor only if it has moved since the last\n            //       call, to avoid breaking glfwWaitEvents with WM_MOUSEMOVE\n            if (window->win32.cursorPosX != width / 2 ||\n                window->win32.cursorPosY != height / 2)\n            {\n                _glfwPlatformSetCursorPos(window, width / 2, height / 2);\n            }\n        }\n    }\n}\n\nvoid _glfwPlatformWaitEvents(void)\n{\n    WaitMessage();\n\n    _glfwPlatformPollEvents();\n}\n\nvoid _glfwPlatformPostEmptyEvent(void)\n{\n    _GLFWwindow* window = _glfw.windowListHead;\n    PostMessage(window->win32.handle, WM_NULL, 0, 0);\n}\n\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)\n{\n    POINT pos;\n\n    if (GetCursorPos(&pos))\n    {\n        ScreenToClient(window->win32.handle, &pos);\n\n        if (xpos)\n            *xpos = pos.x;\n        if (ypos)\n            *ypos = pos.y;\n    }\n}\n\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)\n{\n    POINT pos = { (int) xpos, (int) ypos };\n\n    // Store the new position so it can be recognized later\n    window->win32.cursorPosX = pos.x;\n    window->win32.cursorPosY = pos.y;\n\n    ClientToScreen(window->win32.handle, &pos);\n    SetCursorPos(pos.x, pos.y);\n}\n\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window)\n{\n    switch (window->cursorMode)\n    {\n        case GLFW_CURSOR_NORMAL:\n            restoreCursor(window);\n            break;\n        case GLFW_CURSOR_HIDDEN:\n            hideCursor(window);\n            break;\n        case GLFW_CURSOR_DISABLED:\n            disableCursor(window);\n            break;\n    }\n}\n\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor,\n                              const GLFWimage* image,\n                              int xhot, int yhot)\n{\n    HDC dc;\n    HBITMAP bitmap, mask;\n    BITMAPV5HEADER bi;\n    ICONINFO ii;\n    DWORD* target = 0;\n    BYTE* source = (BYTE*) image->pixels;\n    int i;\n\n    ZeroMemory(&bi, sizeof(bi));\n    bi.bV5Size        = sizeof(BITMAPV5HEADER);\n    bi.bV5Width       = image->width;\n    bi.bV5Height      = -image->height;\n    bi.bV5Planes      = 1;\n    bi.bV5BitCount    = 32;\n    bi.bV5Compression = BI_BITFIELDS;\n    bi.bV5RedMask     = 0x00ff0000;\n    bi.bV5GreenMask   = 0x0000ff00;\n    bi.bV5BlueMask    = 0x000000ff;\n    bi.bV5AlphaMask   = 0xff000000;\n\n    dc = GetDC(NULL);\n    bitmap = CreateDIBSection(dc, (BITMAPINFO*) &bi, DIB_RGB_COLORS,\n                              (void**) &target, NULL, (DWORD) 0);\n    ReleaseDC(NULL, dc);\n\n    if (!bitmap)\n        return GL_FALSE;\n\n    mask = CreateBitmap(image->width, image->height, 1, 1, NULL);\n    if (!mask)\n    {\n        DeleteObject(bitmap);\n        return GL_FALSE;\n    }\n\n    for (i = 0;  i < image->width * image->height;  i++, target++, source += 4)\n    {\n        *target = (source[3] << 24) |\n                  (source[0] << 16) |\n                  (source[1] <<  8) |\n                   source[2];\n    }\n\n    ZeroMemory(&ii, sizeof(ii));\n    ii.fIcon    = FALSE;\n    ii.xHotspot = xhot;\n    ii.yHotspot = yhot;\n    ii.hbmMask  = mask;\n    ii.hbmColor = bitmap;\n\n    cursor->win32.handle = (HCURSOR) CreateIconIndirect(&ii);\n\n    DeleteObject(bitmap);\n    DeleteObject(mask);\n\n    if (!cursor->win32.handle)\n        return GL_FALSE;\n\n    return GL_TRUE;\n}\n\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)\n{\n    cursor->win32.handle =\n        CopyCursor(LoadCursorW(NULL, translateCursorShape(shape)));\n    if (!cursor->win32.handle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to create standard cursor\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor)\n{\n    if (cursor->win32.handle)\n        DestroyIcon((HICON) cursor->win32.handle);\n}\n\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)\n{\n    POINT pos;\n\n    if (_glfw.cursorWindow != window)\n        return;\n\n    if (window->cursorMode != GLFW_CURSOR_NORMAL)\n        return;\n\n    if (!GetCursorPos(&pos))\n        return;\n\n    if (WindowFromPoint(pos) != window->win32.handle)\n        return;\n\n    if (cursor)\n        SetCursor(cursor->win32.handle);\n    else\n        SetCursor(LoadCursorW(NULL, IDC_ARROW));\n}\n\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)\n{\n    WCHAR* wideString;\n    HANDLE stringHandle;\n    size_t wideSize;\n\n    wideString = _glfwCreateWideStringFromUTF8(string);\n    if (!wideString)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to convert string to UTF-16\");\n        return;\n    }\n\n    wideSize = (wcslen(wideString) + 1) * sizeof(WCHAR);\n\n    stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize);\n    if (!stringHandle)\n    {\n        free(wideString);\n\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to allocate global handle for clipboard\");\n        return;\n    }\n\n    memcpy(GlobalLock(stringHandle), wideString, wideSize);\n    GlobalUnlock(stringHandle);\n\n    if (!OpenClipboard(window->win32.handle))\n    {\n        GlobalFree(stringHandle);\n        free(wideString);\n\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Win32: Failed to open clipboard\");\n        return;\n    }\n\n    EmptyClipboard();\n    SetClipboardData(CF_UNICODETEXT, stringHandle);\n    CloseClipboard();\n\n    free(wideString);\n}\n\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window)\n{\n    HANDLE stringHandle;\n\n    if (!OpenClipboard(window->win32.handle))\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR, \"Win32: Failed to open clipboard\");\n        return NULL;\n    }\n\n    stringHandle = GetClipboardData(CF_UNICODETEXT);\n    if (!stringHandle)\n    {\n        CloseClipboard();\n\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"Win32: Failed to convert clipboard to string\");\n        return NULL;\n    }\n\n    free(_glfw.win32.clipboardString);\n    _glfw.win32.clipboardString =\n        _glfwCreateUTF8FromWideString(GlobalLock(stringHandle));\n\n    GlobalUnlock(stringHandle);\n    CloseClipboard();\n\n    if (!_glfw.win32.clipboardString)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Win32: Failed to convert wide string to UTF-8\");\n        return NULL;\n    }\n\n    return _glfw.win32.clipboardString;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return window->win32.handle;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/window.c",
    "content": "//========================================================================\n// GLFW 3.1 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <string.h>\n#include <stdlib.h>\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                         GLFW event API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)\n{\n    if (focused)\n    {\n        _glfw.cursorWindow = window;\n\n        if (window->callbacks.focus)\n            window->callbacks.focus((GLFWwindow*) window, focused);\n    }\n    else\n    {\n        int i;\n\n        _glfw.cursorWindow = NULL;\n\n        if (window->callbacks.focus)\n            window->callbacks.focus((GLFWwindow*) window, focused);\n\n        // Release all pressed keyboard keys\n        for (i = 0;  i <= GLFW_KEY_LAST;  i++)\n        {\n            if (window->keys[i] == GLFW_PRESS)\n                _glfwInputKey(window, i, 0, GLFW_RELEASE, 0);\n        }\n\n        // Release all pressed mouse buttons\n        for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)\n        {\n            if (window->mouseButtons[i] == GLFW_PRESS)\n                _glfwInputMouseClick(window, i, GLFW_RELEASE, 0);\n        }\n    }\n}\n\nvoid _glfwInputWindowPos(_GLFWwindow* window, int x, int y)\n{\n    if (window->callbacks.pos)\n        window->callbacks.pos((GLFWwindow*) window, x, y);\n}\n\nvoid _glfwInputWindowSize(_GLFWwindow* window, int width, int height)\n{\n    if (window->callbacks.size)\n        window->callbacks.size((GLFWwindow*) window, width, height);\n}\n\nvoid _glfwInputWindowIconify(_GLFWwindow* window, int iconified)\n{\n    if (window->callbacks.iconify)\n        window->callbacks.iconify((GLFWwindow*) window, iconified);\n}\n\nvoid _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)\n{\n    if (window->callbacks.fbsize)\n        window->callbacks.fbsize((GLFWwindow*) window, width, height);\n}\n\nvoid _glfwInputWindowDamage(_GLFWwindow* window)\n{\n    if (window->callbacks.refresh)\n        window->callbacks.refresh((GLFWwindow*) window);\n}\n\nvoid _glfwInputWindowCloseRequest(_GLFWwindow* window)\n{\n    window->closed = GL_TRUE;\n\n    if (window->callbacks.close)\n        window->callbacks.close((GLFWwindow*) window);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW public API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,\n                                     const char* title,\n                                     GLFWmonitor* monitor,\n                                     GLFWwindow* share)\n{\n    _GLFWfbconfig fbconfig;\n    _GLFWctxconfig ctxconfig;\n    _GLFWwndconfig wndconfig;\n    _GLFWwindow* window;\n    _GLFWwindow* previous;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n\n    if (width <= 0 || height <= 0)\n    {\n        _glfwInputError(GLFW_INVALID_VALUE, \"Invalid window size\");\n        return NULL;\n    }\n\n    fbconfig  = _glfw.hints.framebuffer;\n    ctxconfig = _glfw.hints.context;\n    wndconfig = _glfw.hints.window;\n\n    wndconfig.width   = width;\n    wndconfig.height  = height;\n    wndconfig.title   = title;\n    wndconfig.monitor = (_GLFWmonitor*) monitor;\n    ctxconfig.share   = (_GLFWwindow*) share;\n\n    if (wndconfig.monitor)\n    {\n        wndconfig.resizable = GL_TRUE;\n        wndconfig.visible   = GL_TRUE;\n        wndconfig.focused   = GL_TRUE;\n    }\n\n    // Check the OpenGL bits of the window config\n    if (!_glfwIsValidContextConfig(&ctxconfig))\n        return NULL;\n\n    window = calloc(1, sizeof(_GLFWwindow));\n    window->next = _glfw.windowListHead;\n    _glfw.windowListHead = window;\n\n    window->videoMode.width       = width;\n    window->videoMode.height      = height;\n    window->videoMode.redBits     = fbconfig.redBits;\n    window->videoMode.greenBits   = fbconfig.greenBits;\n    window->videoMode.blueBits    = fbconfig.blueBits;\n    window->videoMode.refreshRate = _glfw.hints.refreshRate;\n\n    window->monitor     = wndconfig.monitor;\n    window->resizable   = wndconfig.resizable;\n    window->decorated   = wndconfig.decorated;\n    window->autoIconify = wndconfig.autoIconify;\n    window->floating    = wndconfig.floating;\n    window->cursorMode  = GLFW_CURSOR_NORMAL;\n\n    // Save the currently current context so it can be restored later\n    previous = _glfwPlatformGetCurrentContext();\n\n    // Open the actual window and create its context\n    if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))\n    {\n        glfwDestroyWindow((GLFWwindow*) window);\n        _glfwPlatformMakeContextCurrent(previous);\n        return NULL;\n    }\n\n    _glfwPlatformMakeContextCurrent(window);\n\n    // Retrieve the actual (as opposed to requested) context attributes\n    if (!_glfwRefreshContextAttribs(&ctxconfig))\n    {\n        glfwDestroyWindow((GLFWwindow*) window);\n        _glfwPlatformMakeContextCurrent(previous);\n        return NULL;\n    }\n\n    // Verify the context against the requested parameters\n    if (!_glfwIsValidContext(&ctxconfig))\n    {\n        glfwDestroyWindow((GLFWwindow*) window);\n        _glfwPlatformMakeContextCurrent(previous);\n        return NULL;\n    }\n\n    // Clearing the front buffer to black to avoid garbage pixels left over\n    // from previous uses of our bit of VRAM\n    window->Clear(GL_COLOR_BUFFER_BIT);\n    _glfwPlatformSwapBuffers(window);\n\n    // Restore the previously current context (or NULL)\n    _glfwPlatformMakeContextCurrent(previous);\n\n    if (wndconfig.monitor)\n    {\n        int width, height;\n        _glfwPlatformGetWindowSize(window, &width, &height);\n\n        window->cursorPosX = width / 2;\n        window->cursorPosY = height / 2;\n\n        _glfwPlatformSetCursorPos(window, window->cursorPosX, window->cursorPosY);\n    }\n    else\n    {\n        if (wndconfig.visible)\n        {\n            if (wndconfig.focused)\n                _glfwPlatformShowWindow(window);\n            else\n                _glfwPlatformUnhideWindow(window);\n        }\n    }\n\n    return (GLFWwindow*) window;\n}\n\nvoid glfwDefaultWindowHints(void)\n{\n    _GLFW_REQUIRE_INIT();\n\n    memset(&_glfw.hints, 0, sizeof(_glfw.hints));\n\n    // The default is OpenGL with minimum version 1.0\n    _glfw.hints.context.api   = GLFW_OPENGL_API;\n    _glfw.hints.context.major = 1;\n    _glfw.hints.context.minor = 0;\n\n    // The default is a focused, visible, resizable window with decorations\n    _glfw.hints.window.resizable   = GL_TRUE;\n    _glfw.hints.window.visible     = GL_TRUE;\n    _glfw.hints.window.decorated   = GL_TRUE;\n    _glfw.hints.window.focused     = GL_TRUE;\n    _glfw.hints.window.autoIconify = GL_TRUE;\n\n    // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,\n    // double buffered\n    _glfw.hints.framebuffer.redBits      = 8;\n    _glfw.hints.framebuffer.greenBits    = 8;\n    _glfw.hints.framebuffer.blueBits     = 8;\n    _glfw.hints.framebuffer.alphaBits    = 8;\n    _glfw.hints.framebuffer.depthBits    = 24;\n    _glfw.hints.framebuffer.stencilBits  = 8;\n    _glfw.hints.framebuffer.doublebuffer = GL_TRUE;\n\n    // The default is to select the highest available refresh rate\n    _glfw.hints.refreshRate = GLFW_DONT_CARE;\n}\n\nGLFWAPI void glfwWindowHint(int target, int hint)\n{\n    _GLFW_REQUIRE_INIT();\n\n    switch (target)\n    {\n        case GLFW_RED_BITS:\n            _glfw.hints.framebuffer.redBits = hint;\n            break;\n        case GLFW_GREEN_BITS:\n            _glfw.hints.framebuffer.greenBits = hint;\n            break;\n        case GLFW_BLUE_BITS:\n            _glfw.hints.framebuffer.blueBits = hint;\n            break;\n        case GLFW_ALPHA_BITS:\n            _glfw.hints.framebuffer.alphaBits = hint;\n            break;\n        case GLFW_DEPTH_BITS:\n            _glfw.hints.framebuffer.depthBits = hint;\n            break;\n        case GLFW_STENCIL_BITS:\n            _glfw.hints.framebuffer.stencilBits = hint;\n            break;\n        case GLFW_ACCUM_RED_BITS:\n            _glfw.hints.framebuffer.accumRedBits = hint;\n            break;\n        case GLFW_ACCUM_GREEN_BITS:\n            _glfw.hints.framebuffer.accumGreenBits = hint;\n            break;\n        case GLFW_ACCUM_BLUE_BITS:\n            _glfw.hints.framebuffer.accumBlueBits = hint;\n            break;\n        case GLFW_ACCUM_ALPHA_BITS:\n            _glfw.hints.framebuffer.accumAlphaBits = hint;\n            break;\n        case GLFW_AUX_BUFFERS:\n            _glfw.hints.framebuffer.auxBuffers = hint;\n            break;\n        case GLFW_STEREO:\n            _glfw.hints.framebuffer.stereo = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_DOUBLEBUFFER:\n            _glfw.hints.framebuffer.doublebuffer = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_SAMPLES:\n            _glfw.hints.framebuffer.samples = hint;\n            break;\n        case GLFW_SRGB_CAPABLE:\n            _glfw.hints.framebuffer.sRGB = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_RESIZABLE:\n            _glfw.hints.window.resizable = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_DECORATED:\n            _glfw.hints.window.decorated = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_FOCUSED:\n            _glfw.hints.window.focused = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_AUTO_ICONIFY:\n            _glfw.hints.window.autoIconify = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_FLOATING:\n            _glfw.hints.window.floating = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_VISIBLE:\n            _glfw.hints.window.visible = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_CLIENT_API:\n            _glfw.hints.context.api = hint;\n            break;\n        case GLFW_CONTEXT_VERSION_MAJOR:\n            _glfw.hints.context.major = hint;\n            break;\n        case GLFW_CONTEXT_VERSION_MINOR:\n            _glfw.hints.context.minor = hint;\n            break;\n        case GLFW_CONTEXT_ROBUSTNESS:\n            _glfw.hints.context.robustness = hint;\n            break;\n        case GLFW_OPENGL_FORWARD_COMPAT:\n            _glfw.hints.context.forward = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_OPENGL_DEBUG_CONTEXT:\n            _glfw.hints.context.debug = hint ? GL_TRUE : GL_FALSE;\n            break;\n        case GLFW_OPENGL_PROFILE:\n            _glfw.hints.context.profile = hint;\n            break;\n        case GLFW_CONTEXT_RELEASE_BEHAVIOR:\n            _glfw.hints.context.release = hint;\n            break;\n        case GLFW_REFRESH_RATE:\n            _glfw.hints.refreshRate = hint;\n            break;\n        default:\n            _glfwInputError(GLFW_INVALID_ENUM, \"Invalid window hint\");\n            break;\n    }\n}\n\nGLFWAPI void glfwDestroyWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    // Allow closing of NULL (to match the behavior of free)\n    if (window == NULL)\n        return;\n\n    // Clear all callbacks to avoid exposing a half torn-down window object\n    memset(&window->callbacks, 0, sizeof(window->callbacks));\n\n    // The window's context must not be current on another thread when the\n    // window is destroyed\n    if (window == _glfwPlatformGetCurrentContext())\n        _glfwPlatformMakeContextCurrent(NULL);\n\n    // Clear the focused window pointer if this is the focused window\n    if (_glfw.cursorWindow == window)\n        _glfw.cursorWindow = NULL;\n\n    _glfwPlatformDestroyWindow(window);\n\n    // Unlink window from global linked list\n    {\n        _GLFWwindow** prev = &_glfw.windowListHead;\n\n        while (*prev != window)\n            prev = &((*prev)->next);\n\n        *prev = window->next;\n    }\n\n    free(window);\n}\n\nGLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(0);\n    return window->closed;\n}\n\nGLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    window->closed = value;\n}\n\nGLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformSetWindowTitle(window, title);\n}\n\nGLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    if (xpos)\n        *xpos = 0;\n    if (ypos)\n        *ypos = 0;\n\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformGetWindowPos(window, xpos, ypos);\n}\n\nGLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (window->monitor)\n    {\n        _glfwInputError(GLFW_INVALID_VALUE,\n                        \"Full screen windows cannot be moved\");\n        return;\n    }\n\n    _glfwPlatformSetWindowPos(window, xpos, ypos);\n}\n\nGLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    if (width)\n        *width = 0;\n    if (height)\n        *height = 0;\n\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformGetWindowSize(window, width, height);\n}\n\nGLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (window->monitor)\n    {\n        window->videoMode.width  = width;\n        window->videoMode.height = height;\n    }\n\n    _glfwPlatformSetWindowSize(window, width, height);\n}\n\nGLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    if (width)\n        *width = 0;\n    if (height)\n        *height = 0;\n\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformGetFramebufferSize(window, width, height);\n}\n\nGLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,\n                                    int* left, int* top,\n                                    int* right, int* bottom)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    if (left)\n        *left = 0;\n    if (top)\n        *top = 0;\n    if (right)\n        *right = 0;\n    if (bottom)\n        *bottom = 0;\n\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);\n}\n\nGLFWAPI void glfwIconifyWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformIconifyWindow(window);\n}\n\nGLFWAPI void glfwRestoreWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformRestoreWindow(window);\n}\n\nGLFWAPI void glfwShowWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (window->monitor)\n        return;\n\n    _glfwPlatformShowWindow(window);\n}\n\nGLFWAPI void glfwHideWindow(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT();\n\n    if (window->monitor)\n        return;\n\n    _glfwPlatformHideWindow(window);\n}\n\nGLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n\n    _GLFW_REQUIRE_INIT_OR_RETURN(0);\n\n    switch (attrib)\n    {\n        case GLFW_FOCUSED:\n            return _glfwPlatformWindowFocused(window);\n        case GLFW_ICONIFIED:\n            return _glfwPlatformWindowIconified(window);\n        case GLFW_VISIBLE:\n            return _glfwPlatformWindowVisible(window);\n        case GLFW_RESIZABLE:\n            return window->resizable;\n        case GLFW_DECORATED:\n            return window->decorated;\n        case GLFW_FLOATING:\n            return window->floating;\n        case GLFW_CLIENT_API:\n            return window->context.api;\n        case GLFW_CONTEXT_VERSION_MAJOR:\n            return window->context.major;\n        case GLFW_CONTEXT_VERSION_MINOR:\n            return window->context.minor;\n        case GLFW_CONTEXT_REVISION:\n            return window->context.revision;\n        case GLFW_CONTEXT_ROBUSTNESS:\n            return window->context.robustness;\n        case GLFW_OPENGL_FORWARD_COMPAT:\n            return window->context.forward;\n        case GLFW_OPENGL_DEBUG_CONTEXT:\n            return window->context.debug;\n        case GLFW_OPENGL_PROFILE:\n            return window->context.profile;\n        case GLFW_CONTEXT_RELEASE_BEHAVIOR:\n            return window->context.release;\n    }\n\n    _glfwInputError(GLFW_INVALID_ENUM, \"Invalid window attribute\");\n    return 0;\n}\n\nGLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return (GLFWmonitor*) window->monitor;\n}\n\nGLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT();\n    window->userPointer = pointer;\n}\n\nGLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return window->userPointer;\n}\n\nGLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,\n                                                  GLFWwindowposfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,\n                                                    GLFWwindowsizefun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,\n                                                      GLFWwindowclosefun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,\n                                                          GLFWwindowrefreshfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,\n                                                      GLFWwindowfocusfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,\n                                                          GLFWwindowiconifyfun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);\n    return cbfun;\n}\n\nGLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,\n                                                              GLFWframebuffersizefun cbfun)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);\n    return cbfun;\n}\n\nGLFWAPI void glfwPollEvents(void)\n{\n    _GLFW_REQUIRE_INIT();\n    _glfwPlatformPollEvents();\n}\n\nGLFWAPI void glfwWaitEvents(void)\n{\n    _GLFW_REQUIRE_INIT();\n\n    if (!_glfw.windowListHead)\n        return;\n\n    _glfwPlatformWaitEvents();\n}\n\nGLFWAPI void glfwPostEmptyEvent(void)\n{\n    _GLFW_REQUIRE_INIT();\n\n    if (!_glfw.windowListHead)\n        return;\n\n    _glfwPlatformPostEmptyEvent();\n}\n\n"
  },
  {
    "path": "deps/glfw/src/winmm_joystick.c",
    "content": "//========================================================================\n// GLFW 3.1 WinMM - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdlib.h>\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Convert axis value to the [-1,1] range\n//\nstatic float normalizeAxis(DWORD pos, DWORD min, DWORD max)\n{\n    float fpos = (float) pos;\n    float fmin = (float) min;\n    float fmax = (float) max;\n\n    return (2.f * (fpos - fmin) / (fmax - fmin)) - 1.f;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Initialize joystick interface\n//\nvoid _glfwInitJoysticks(void)\n{\n}\n\n// Close all opened joystick handles\n//\nvoid _glfwTerminateJoysticks(void)\n{\n    int i;\n\n    for (i = 0;  i < GLFW_JOYSTICK_LAST;  i++)\n        free(_glfw.winmm_js[i].name);\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformJoystickPresent(int joy)\n{\n    JOYINFO ji;\n\n    if (_glfw_joyGetPos(joy, &ji) != JOYERR_NOERROR)\n        return GL_FALSE;\n\n    return GL_TRUE;\n}\n\nconst float* _glfwPlatformGetJoystickAxes(int joy, int* count)\n{\n    JOYCAPS jc;\n    JOYINFOEX ji;\n    float* axes = _glfw.winmm_js[joy].axes;\n\n    if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR)\n        return NULL;\n\n    ji.dwSize = sizeof(JOYINFOEX);\n    ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ |\n                 JOY_RETURNR | JOY_RETURNU | JOY_RETURNV;\n    if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR)\n        return NULL;\n\n    axes[(*count)++] = normalizeAxis(ji.dwXpos, jc.wXmin, jc.wXmax);\n    axes[(*count)++] = normalizeAxis(ji.dwYpos, jc.wYmin, jc.wYmax);\n\n    if (jc.wCaps & JOYCAPS_HASZ)\n        axes[(*count)++] = normalizeAxis(ji.dwZpos, jc.wZmin, jc.wZmax);\n\n    if (jc.wCaps & JOYCAPS_HASR)\n        axes[(*count)++] = normalizeAxis(ji.dwRpos, jc.wRmin, jc.wRmax);\n\n    if (jc.wCaps & JOYCAPS_HASU)\n        axes[(*count)++] = normalizeAxis(ji.dwUpos, jc.wUmin, jc.wUmax);\n\n    if (jc.wCaps & JOYCAPS_HASV)\n        axes[(*count)++] = normalizeAxis(ji.dwVpos, jc.wVmin, jc.wVmax);\n\n    return axes;\n}\n\nconst unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)\n{\n    JOYCAPS jc;\n    JOYINFOEX ji;\n    unsigned char* buttons = _glfw.winmm_js[joy].buttons;\n\n    if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR)\n        return NULL;\n\n    ji.dwSize = sizeof(JOYINFOEX);\n    ji.dwFlags = JOY_RETURNBUTTONS | JOY_RETURNPOV;\n    if (_glfw_joyGetPosEx(joy, &ji) != JOYERR_NOERROR)\n        return NULL;\n\n    while (*count < (int) jc.wNumButtons)\n    {\n        buttons[*count] = (unsigned char)\n            (ji.dwButtons & (1UL << *count) ? GLFW_PRESS : GLFW_RELEASE);\n        (*count)++;\n    }\n\n    // Virtual buttons - Inject data from hats\n    // Each hat is exposed as 4 buttons which exposes 8 directions with\n    // concurrent button presses\n    // NOTE: this API exposes only one hat\n\n    if ((jc.wCaps & JOYCAPS_HASPOV) && (jc.wCaps & JOYCAPS_POV4DIR))\n    {\n        int i, value = ji.dwPOV / 100 / 45;\n\n        // Bit fields of button presses for each direction, including nil\n        const int directions[9] = { 1, 3, 2, 6, 4, 12, 8, 9, 0 };\n\n        if (value < 0 || value > 8)\n            value = 8;\n\n        for (i = 0;  i < 4;  i++)\n        {\n            if (directions[value] & (1 << i))\n                buttons[(*count)++] = GLFW_PRESS;\n            else\n                buttons[(*count)++] = GLFW_RELEASE;\n        }\n    }\n\n    return buttons;\n}\n\nconst char* _glfwPlatformGetJoystickName(int joy)\n{\n    JOYCAPS jc;\n\n    if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR)\n        return NULL;\n\n    free(_glfw.winmm_js[joy].name);\n    _glfw.winmm_js[joy].name = _glfwCreateUTF8FromWideString(jc.szPname);\n\n    return _glfw.winmm_js[joy].name;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/winmm_joystick.h",
    "content": "//========================================================================\n// GLFW 3.1 WinMM - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2006-2014 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_winmm_joystick_h_\n#define _glfw3_winmm_joystick_h_\n\n#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \\\n    _GLFWjoystickWinMM winmm_js[GLFW_JOYSTICK_LAST + 1]\n\n\n// WinMM-specific per-joystick data\n//\ntypedef struct _GLFWjoystickWinMM\n{\n    float           axes[6];\n    unsigned char   buttons[36]; // 32 buttons plus one hat\n    char*           name;\n} _GLFWjoystickWinMM;\n\n\nvoid _glfwInitJoysticks(void);\nvoid _glfwTerminateJoysticks(void);\n\n#endif // _glfw3_winmm_joystick_h_\n"
  },
  {
    "path": "deps/glfw/src/wl_init.c",
    "content": "//========================================================================\n// GLFW 3.1 Wayland - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <linux/input.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/mman.h>\n#include <unistd.h>\n#include <wayland-client.h>\n#include <wayland-cursor.h>\n\n\nstatic void pointerHandleEnter(void* data,\n                               struct wl_pointer* pointer,\n                               uint32_t serial,\n                               struct wl_surface* surface,\n                               wl_fixed_t sx,\n                               wl_fixed_t sy)\n{\n    _GLFWwindow* window = wl_surface_get_user_data(surface);\n\n    _glfw.wl.pointerSerial = serial;\n    _glfw.wl.pointerFocus = window;\n\n    _glfwPlatformSetCursor(window, window->wl.currentCursor);\n    _glfwInputCursorEnter(window, GL_TRUE);\n}\n\nstatic void pointerHandleLeave(void* data,\n                               struct wl_pointer* pointer,\n                               uint32_t serial,\n                               struct wl_surface* surface)\n{\n    _GLFWwindow* window = _glfw.wl.pointerFocus;\n\n    if (!window)\n        return;\n\n    _glfw.wl.pointerSerial = serial;\n    _glfw.wl.pointerFocus = NULL;\n    _glfwInputCursorEnter(window, GL_FALSE);\n}\n\nstatic void pointerHandleMotion(void* data,\n                                struct wl_pointer* pointer,\n                                uint32_t time,\n                                wl_fixed_t sx,\n                                wl_fixed_t sy)\n{\n    _GLFWwindow* window = _glfw.wl.pointerFocus;\n\n    if (!window)\n        return;\n\n    if (window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        /* TODO */\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: GLFW_CURSOR_DISABLED not supported\");\n        return;\n    }\n    else\n    {\n        window->wl.cursorPosX = wl_fixed_to_double(sx);\n        window->wl.cursorPosY = wl_fixed_to_double(sy);\n    }\n\n    _glfwInputCursorMotion(window,\n                           wl_fixed_to_double(sx),\n                           wl_fixed_to_double(sy));\n}\n\nstatic void pointerHandleButton(void* data,\n                                struct wl_pointer* wl_pointer,\n                                uint32_t serial,\n                                uint32_t time,\n                                uint32_t button,\n                                uint32_t state)\n{\n    _GLFWwindow* window = _glfw.wl.pointerFocus;\n    int glfwButton;\n\n    if (!window)\n        return;\n\n    /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev\n     * codes. */\n    glfwButton = button - BTN_LEFT;\n\n    _glfwInputMouseClick(window,\n                         glfwButton,\n                         state == WL_POINTER_BUTTON_STATE_PRESSED\n                                ? GLFW_PRESS\n                                : GLFW_RELEASE,\n                         _glfw.wl.xkb.modifiers);\n}\n\nstatic void pointerHandleAxis(void* data,\n                              struct wl_pointer* wl_pointer,\n                              uint32_t time,\n                              uint32_t axis,\n                              wl_fixed_t value)\n{\n    _GLFWwindow* window = _glfw.wl.pointerFocus;\n    double scroll_factor;\n    double x, y;\n\n    if (!window)\n        return;\n\n    /* Wayland scroll events are in pointer motion coordinate space (think\n     * two finger scroll). The factor 10 is commonly used to convert to\n     * \"scroll step means 1.0. */\n    scroll_factor = 1.0/10.0;\n\n    switch (axis)\n    {\n        case WL_POINTER_AXIS_HORIZONTAL_SCROLL:\n            x = wl_fixed_to_double(value) * scroll_factor;\n            y = 0.0;\n            break;\n        case WL_POINTER_AXIS_VERTICAL_SCROLL:\n            x = 0.0;\n            y = wl_fixed_to_double(value) * scroll_factor;\n            break;\n        default:\n            break;\n    }\n\n    _glfwInputScroll(window, x, y);\n}\n\nstatic const struct wl_pointer_listener pointerListener = {\n    pointerHandleEnter,\n    pointerHandleLeave,\n    pointerHandleMotion,\n    pointerHandleButton,\n    pointerHandleAxis,\n};\n\nstatic void keyboardHandleKeymap(void* data,\n                                 struct wl_keyboard* keyboard,\n                                 uint32_t format,\n                                 int fd,\n                                 uint32_t size)\n{\n    struct xkb_keymap* keymap;\n    struct xkb_state* state;\n    char* mapStr;\n\n    if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)\n    {\n        close(fd);\n        return;\n    }\n\n    mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);\n    if (mapStr == MAP_FAILED) {\n        close(fd);\n        return;\n    }\n\n    keymap = xkb_map_new_from_string(_glfw.wl.xkb.context,\n                                     mapStr,\n                                     XKB_KEYMAP_FORMAT_TEXT_V1,\n                                     0);\n    munmap(mapStr, size);\n    close(fd);\n\n    if (!keymap)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Failed to compile keymap\");\n        return;\n    }\n\n    state = xkb_state_new(keymap);\n    if (!state)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Failed to create XKB state\");\n        xkb_map_unref(keymap);\n        return;\n    }\n\n    xkb_keymap_unref(_glfw.wl.xkb.keymap);\n    xkb_state_unref(_glfw.wl.xkb.state);\n    _glfw.wl.xkb.keymap = keymap;\n    _glfw.wl.xkb.state = state;\n\n    _glfw.wl.xkb.control_mask =\n        1 << xkb_map_mod_get_index(_glfw.wl.xkb.keymap, \"Control\");\n    _glfw.wl.xkb.alt_mask =\n        1 << xkb_map_mod_get_index(_glfw.wl.xkb.keymap, \"Mod1\");\n    _glfw.wl.xkb.shift_mask =\n        1 << xkb_map_mod_get_index(_glfw.wl.xkb.keymap, \"Shift\");\n    _glfw.wl.xkb.super_mask =\n        1 << xkb_map_mod_get_index(_glfw.wl.xkb.keymap, \"Mod4\");\n}\n\nstatic void keyboardHandleEnter(void* data,\n                                struct wl_keyboard* keyboard,\n                                uint32_t serial,\n                                struct wl_surface* surface,\n                                struct wl_array* keys)\n{\n    _GLFWwindow* window = wl_surface_get_user_data(surface);\n\n    _glfw.wl.keyboardFocus = window;\n    _glfwInputWindowFocus(window, GL_TRUE);\n}\n\nstatic void keyboardHandleLeave(void* data,\n                                struct wl_keyboard* keyboard,\n                                uint32_t serial,\n                                struct wl_surface* surface)\n{\n    _GLFWwindow* window = _glfw.wl.keyboardFocus;\n\n    if (!window)\n        return;\n\n    _glfw.wl.keyboardFocus = NULL;\n    _glfwInputWindowFocus(window, GL_FALSE);\n}\n\nstatic int toGLFWKeyCode(uint32_t key)\n{\n    switch (key)\n    {\n        case KEY_GRAVE:         return GLFW_KEY_GRAVE_ACCENT;\n        case KEY_1:             return GLFW_KEY_1;\n        case KEY_2:             return GLFW_KEY_2;\n        case KEY_3:             return GLFW_KEY_3;\n        case KEY_4:             return GLFW_KEY_4;\n        case KEY_5:             return GLFW_KEY_5;\n        case KEY_6:             return GLFW_KEY_6;\n        case KEY_7:             return GLFW_KEY_7;\n        case KEY_8:             return GLFW_KEY_8;\n        case KEY_9:             return GLFW_KEY_9;\n        case KEY_0:             return GLFW_KEY_0;\n        case KEY_MINUS:         return GLFW_KEY_MINUS;\n        case KEY_EQUAL:         return GLFW_KEY_EQUAL;\n        case KEY_Q:             return GLFW_KEY_Q;\n        case KEY_W:             return GLFW_KEY_W;\n        case KEY_E:             return GLFW_KEY_E;\n        case KEY_R:             return GLFW_KEY_R;\n        case KEY_T:             return GLFW_KEY_T;\n        case KEY_Y:             return GLFW_KEY_Y;\n        case KEY_U:             return GLFW_KEY_U;\n        case KEY_I:             return GLFW_KEY_I;\n        case KEY_O:             return GLFW_KEY_O;\n        case KEY_P:             return GLFW_KEY_P;\n        case KEY_LEFTBRACE:     return GLFW_KEY_LEFT_BRACKET;\n        case KEY_RIGHTBRACE:    return GLFW_KEY_RIGHT_BRACKET;\n        case KEY_A:             return GLFW_KEY_A;\n        case KEY_S:             return GLFW_KEY_S;\n        case KEY_D:             return GLFW_KEY_D;\n        case KEY_F:             return GLFW_KEY_F;\n        case KEY_G:             return GLFW_KEY_G;\n        case KEY_H:             return GLFW_KEY_H;\n        case KEY_J:             return GLFW_KEY_J;\n        case KEY_K:             return GLFW_KEY_K;\n        case KEY_L:             return GLFW_KEY_L;\n        case KEY_SEMICOLON:     return GLFW_KEY_SEMICOLON;\n        case KEY_APOSTROPHE:    return GLFW_KEY_APOSTROPHE;\n        case KEY_Z:             return GLFW_KEY_Z;\n        case KEY_X:             return GLFW_KEY_X;\n        case KEY_C:             return GLFW_KEY_C;\n        case KEY_V:             return GLFW_KEY_V;\n        case KEY_B:             return GLFW_KEY_B;\n        case KEY_N:             return GLFW_KEY_N;\n        case KEY_M:             return GLFW_KEY_M;\n        case KEY_COMMA:         return GLFW_KEY_COMMA;\n        case KEY_DOT:           return GLFW_KEY_PERIOD;\n        case KEY_SLASH:         return GLFW_KEY_SLASH;\n        case KEY_BACKSLASH:     return GLFW_KEY_BACKSLASH;\n        case KEY_ESC:           return GLFW_KEY_ESCAPE;\n        case KEY_TAB:           return GLFW_KEY_TAB;\n        case KEY_LEFTSHIFT:     return GLFW_KEY_LEFT_SHIFT;\n        case KEY_RIGHTSHIFT:    return GLFW_KEY_RIGHT_SHIFT;\n        case KEY_LEFTCTRL:      return GLFW_KEY_LEFT_CONTROL;\n        case KEY_RIGHTCTRL:     return GLFW_KEY_RIGHT_CONTROL;\n        case KEY_LEFTALT:       return GLFW_KEY_LEFT_ALT;\n        case KEY_RIGHTALT:      return GLFW_KEY_RIGHT_ALT;\n        case KEY_LEFTMETA:      return GLFW_KEY_LEFT_SUPER;\n        case KEY_RIGHTMETA:     return GLFW_KEY_RIGHT_SUPER;\n        case KEY_MENU:          return GLFW_KEY_MENU;\n        case KEY_NUMLOCK:       return GLFW_KEY_NUM_LOCK;\n        case KEY_CAPSLOCK:      return GLFW_KEY_CAPS_LOCK;\n        case KEY_PRINT:         return GLFW_KEY_PRINT_SCREEN;\n        case KEY_SCROLLLOCK:    return GLFW_KEY_SCROLL_LOCK;\n        case KEY_PAUSE:         return GLFW_KEY_PAUSE;\n        case KEY_DELETE:        return GLFW_KEY_DELETE;\n        case KEY_BACKSPACE:     return GLFW_KEY_BACKSPACE;\n        case KEY_ENTER:         return GLFW_KEY_ENTER;\n        case KEY_HOME:          return GLFW_KEY_HOME;\n        case KEY_END:           return GLFW_KEY_END;\n        case KEY_PAGEUP:        return GLFW_KEY_PAGE_UP;\n        case KEY_PAGEDOWN:      return GLFW_KEY_PAGE_DOWN;\n        case KEY_INSERT:        return GLFW_KEY_INSERT;\n        case KEY_LEFT:          return GLFW_KEY_LEFT;\n        case KEY_RIGHT:         return GLFW_KEY_RIGHT;\n        case KEY_DOWN:          return GLFW_KEY_DOWN;\n        case KEY_UP:            return GLFW_KEY_UP;\n        case KEY_F1:            return GLFW_KEY_F1;\n        case KEY_F2:            return GLFW_KEY_F2;\n        case KEY_F3:            return GLFW_KEY_F3;\n        case KEY_F4:            return GLFW_KEY_F4;\n        case KEY_F5:            return GLFW_KEY_F5;\n        case KEY_F6:            return GLFW_KEY_F6;\n        case KEY_F7:            return GLFW_KEY_F7;\n        case KEY_F8:            return GLFW_KEY_F8;\n        case KEY_F9:            return GLFW_KEY_F9;\n        case KEY_F10:           return GLFW_KEY_F10;\n        case KEY_F11:           return GLFW_KEY_F11;\n        case KEY_F12:           return GLFW_KEY_F12;\n        case KEY_F13:           return GLFW_KEY_F13;\n        case KEY_F14:           return GLFW_KEY_F14;\n        case KEY_F15:           return GLFW_KEY_F15;\n        case KEY_F16:           return GLFW_KEY_F16;\n        case KEY_F17:           return GLFW_KEY_F17;\n        case KEY_F18:           return GLFW_KEY_F18;\n        case KEY_F19:           return GLFW_KEY_F19;\n        case KEY_F20:           return GLFW_KEY_F20;\n        case KEY_F21:           return GLFW_KEY_F21;\n        case KEY_F22:           return GLFW_KEY_F22;\n        case KEY_F23:           return GLFW_KEY_F23;\n        case KEY_F24:           return GLFW_KEY_F24;\n        case KEY_KPSLASH:       return GLFW_KEY_KP_DIVIDE;\n        case KEY_KPDOT:         return GLFW_KEY_KP_MULTIPLY;\n        case KEY_KPMINUS:       return GLFW_KEY_KP_SUBTRACT;\n        case KEY_KPPLUS:        return GLFW_KEY_KP_ADD;\n        case KEY_KP0:           return GLFW_KEY_KP_0;\n        case KEY_KP1:           return GLFW_KEY_KP_1;\n        case KEY_KP2:           return GLFW_KEY_KP_2;\n        case KEY_KP3:           return GLFW_KEY_KP_3;\n        case KEY_KP4:           return GLFW_KEY_KP_4;\n        case KEY_KP5:           return GLFW_KEY_KP_5;\n        case KEY_KP6:           return GLFW_KEY_KP_6;\n        case KEY_KP7:           return GLFW_KEY_KP_7;\n        case KEY_KP8:           return GLFW_KEY_KP_8;\n        case KEY_KP9:           return GLFW_KEY_KP_9;\n        case KEY_KPCOMMA:       return GLFW_KEY_KP_DECIMAL;\n        case KEY_KPEQUAL:       return GLFW_KEY_KP_EQUAL;\n        case KEY_KPENTER:       return GLFW_KEY_KP_ENTER;\n        default:                return GLFW_KEY_UNKNOWN;\n    }\n}\n\nstatic void keyboardHandleKey(void* data,\n                              struct wl_keyboard* keyboard,\n                              uint32_t serial,\n                              uint32_t time,\n                              uint32_t key,\n                              uint32_t state)\n{\n    uint32_t code, num_syms;\n    long cp;\n    int keyCode;\n    int action;\n    const xkb_keysym_t *syms;\n    _GLFWwindow* window = _glfw.wl.keyboardFocus;\n\n    if (!window)\n        return;\n\n    keyCode = toGLFWKeyCode(key);\n    action = state == WL_KEYBOARD_KEY_STATE_PRESSED\n            ? GLFW_PRESS : GLFW_RELEASE;\n\n    _glfwInputKey(window, keyCode, key, action,\n                  _glfw.wl.xkb.modifiers);\n\n    code = key + 8;\n    num_syms = xkb_key_get_syms(_glfw.wl.xkb.state, code, &syms);\n\n    if (num_syms == 1)\n    {\n        cp = _glfwKeySym2Unicode(syms[0]);\n        if (cp != -1)\n        {\n            const int mods = _glfw.wl.xkb.modifiers;\n            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));\n            _glfwInputChar(window, cp, mods, plain);\n        }\n    }\n}\n\nstatic void keyboardHandleModifiers(void* data,\n                                    struct wl_keyboard* keyboard,\n                                    uint32_t serial,\n                                    uint32_t modsDepressed,\n                                    uint32_t modsLatched,\n                                    uint32_t modsLocked,\n                                    uint32_t group)\n{\n    xkb_mod_mask_t mask;\n    unsigned int modifiers = 0;\n\n    if (!_glfw.wl.xkb.keymap)\n        return;\n\n    xkb_state_update_mask(_glfw.wl.xkb.state,\n                          modsDepressed,\n                          modsLatched,\n                          modsLocked,\n                          0,\n                          0,\n                          group);\n\n    mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,\n                                    XKB_STATE_DEPRESSED |\n                                    XKB_STATE_LATCHED);\n    if (mask & _glfw.wl.xkb.control_mask)\n        modifiers |= GLFW_MOD_CONTROL;\n    if (mask & _glfw.wl.xkb.alt_mask)\n        modifiers |= GLFW_MOD_ALT;\n    if (mask & _glfw.wl.xkb.shift_mask)\n        modifiers |= GLFW_MOD_SHIFT;\n    if (mask & _glfw.wl.xkb.super_mask)\n        modifiers |= GLFW_MOD_SUPER;\n    _glfw.wl.xkb.modifiers = modifiers;\n}\n\nstatic const struct wl_keyboard_listener keyboardListener = {\n    keyboardHandleKeymap,\n    keyboardHandleEnter,\n    keyboardHandleLeave,\n    keyboardHandleKey,\n    keyboardHandleModifiers,\n};\n\nstatic void seatHandleCapabilities(void* data,\n                                   struct wl_seat* seat,\n                                   enum wl_seat_capability caps)\n{\n    if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)\n    {\n        _glfw.wl.pointer = wl_seat_get_pointer(seat);\n        wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);\n    }\n    else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)\n    {\n        wl_pointer_destroy(_glfw.wl.pointer);\n        _glfw.wl.pointer = NULL;\n    }\n\n    if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)\n    {\n        _glfw.wl.keyboard = wl_seat_get_keyboard(seat);\n        wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);\n    }\n    else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)\n    {\n        wl_keyboard_destroy(_glfw.wl.keyboard);\n        _glfw.wl.keyboard = NULL;\n    }\n}\n\nstatic const struct wl_seat_listener seatListener = {\n    seatHandleCapabilities\n};\n\nstatic void registryHandleGlobal(void* data,\n                                 struct wl_registry* registry,\n                                 uint32_t name,\n                                 const char* interface,\n                                 uint32_t version)\n{\n    if (strcmp(interface, \"wl_compositor\") == 0)\n    {\n        _glfw.wl.compositor =\n            wl_registry_bind(registry, name, &wl_compositor_interface, 1);\n    }\n    else if (strcmp(interface, \"wl_shm\") == 0)\n    {\n        _glfw.wl.shm =\n            wl_registry_bind(registry, name, &wl_shm_interface, 1);\n    }\n    else if (strcmp(interface, \"wl_shell\") == 0)\n    {\n        _glfw.wl.shell =\n            wl_registry_bind(registry, name, &wl_shell_interface, 1);\n    }\n    else if (strcmp(interface, \"wl_output\") == 0)\n    {\n        _glfwAddOutput(name, version);\n    }\n    else if (strcmp(interface, \"wl_seat\") == 0)\n    {\n        if (!_glfw.wl.seat)\n        {\n            _glfw.wl.seat =\n                wl_registry_bind(registry, name, &wl_seat_interface, 1);\n            wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);\n        }\n    }\n}\n\nstatic void registryHandleGlobalRemove(void *data,\n                                       struct wl_registry *registry,\n                                       uint32_t name)\n{\n}\n\n\nstatic const struct wl_registry_listener registryListener = {\n    registryHandleGlobal,\n    registryHandleGlobalRemove\n};\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformInit(void)\n{\n    _glfw.wl.display = wl_display_connect(NULL);\n    if (!_glfw.wl.display)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Failed to connect to display\");\n        return GL_FALSE;\n    }\n\n    _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);\n    wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);\n\n    _glfw.wl.monitors = calloc(4, sizeof(_GLFWmonitor*));\n    _glfw.wl.monitorsSize = 4;\n\n    _glfw.wl.xkb.context = xkb_context_new(0);\n    if (!_glfw.wl.xkb.context)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Failed to initialize xkb context\");\n        return GL_FALSE;\n    }\n\n    // Sync so we got all registry objects\n    wl_display_roundtrip(_glfw.wl.display);\n\n    // Sync so we got all initial output events\n    wl_display_roundtrip(_glfw.wl.display);\n\n    if (!_glfwInitContextAPI())\n        return GL_FALSE;\n\n    _glfwInitTimer();\n    _glfwInitJoysticks();\n\n    if (_glfw.wl.pointer && _glfw.wl.shm)\n    {\n        _glfw.wl.cursorTheme = wl_cursor_theme_load(NULL, 32, _glfw.wl.shm);\n        if (!_glfw.wl.cursorTheme)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"Wayland: Unable to load default cursor theme\\n\");\n            return GL_FALSE;\n        }\n        _glfw.wl.defaultCursor =\n            wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, \"left_ptr\");\n        if (!_glfw.wl.defaultCursor)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"Wayland: Unable to load default left pointer\\n\");\n            return GL_FALSE;\n        }\n        _glfw.wl.cursorSurface =\n            wl_compositor_create_surface(_glfw.wl.compositor);\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformTerminate(void)\n{\n    _glfwTerminateContextAPI();\n    _glfwTerminateJoysticks();\n\n    if (_glfw.wl.cursorTheme)\n        wl_cursor_theme_destroy(_glfw.wl.cursorTheme);\n    if (_glfw.wl.cursorSurface)\n        wl_surface_destroy(_glfw.wl.cursorSurface);\n    if (_glfw.wl.registry)\n        wl_registry_destroy(_glfw.wl.registry);\n    if (_glfw.wl.display)\n        wl_display_flush(_glfw.wl.display);\n    if (_glfw.wl.display)\n        wl_display_disconnect(_glfw.wl.display);\n}\n\nconst char* _glfwPlatformGetVersionString(void)\n{\n    return _GLFW_VERSION_NUMBER \" Wayland EGL\"\n#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)\n        \" clock_gettime\"\n#else\n        \" gettimeofday\"\n#endif\n#if defined(__linux__)\n        \" /dev/js\"\n#endif\n#if defined(_GLFW_BUILD_DLL)\n        \" shared\"\n#endif\n        ;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/wl_monitor.c",
    "content": "//========================================================================\n// GLFW 3.1 Wayland - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n\n\nstruct _GLFWvidmodeWayland\n{\n    GLFWvidmode         base;\n    uint32_t            flags;\n};\n\nstatic void geometry(void* data,\n                     struct wl_output* output,\n                     int32_t x,\n                     int32_t y,\n                     int32_t physicalWidth,\n                     int32_t physicalHeight,\n                     int32_t subpixel,\n                     const char* make,\n                     const char* model,\n                     int32_t transform)\n{\n    struct _GLFWmonitor *monitor = data;\n\n    monitor->wl.x = x;\n    monitor->wl.y = y;\n    monitor->widthMM = physicalWidth;\n    monitor->heightMM = physicalHeight;\n}\n\nstatic void mode(void* data,\n                 struct wl_output* output,\n                 uint32_t flags,\n                 int32_t width,\n                 int32_t height,\n                 int32_t refresh)\n{\n    struct _GLFWmonitor *monitor = data;\n    _GLFWvidmodeWayland mode = { { 0 }, };\n\n    mode.base.width = width;\n    mode.base.height = height;\n    mode.base.refreshRate = refresh;\n    mode.flags = flags;\n\n    if (monitor->wl.modesCount + 1 >= monitor->wl.modesSize)\n    {\n        int size = monitor->wl.modesSize * 2;\n        _GLFWvidmodeWayland* modes =\n            realloc(monitor->wl.modes,\n                    size * sizeof(_GLFWvidmodeWayland));\n        monitor->wl.modes = modes;\n        monitor->wl.modesSize = size;\n    }\n\n    monitor->wl.modes[monitor->wl.modesCount++] = mode;\n}\n\nstatic void done(void* data,\n                 struct wl_output* output)\n{\n    struct _GLFWmonitor *monitor = data;\n\n    monitor->wl.done = GL_TRUE;\n}\n\nstatic void scale(void* data,\n                  struct wl_output* output,\n                  int32_t factor)\n{\n}\n\nstatic const struct wl_output_listener output_listener = {\n    geometry,\n    mode,\n    done,\n    scale,\n};\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nvoid _glfwAddOutput(uint32_t name, uint32_t version)\n{\n    _GLFWmonitor *monitor;\n    struct wl_output *output;\n    char name_str[80];\n\n    memset(name_str, 0, 80 * sizeof(char));\n    snprintf(name_str, 79, \"wl_output@%u\", name);\n\n    if (version < 2)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Unsupported output interface version\");\n        return;\n    }\n\n    monitor = _glfwAllocMonitor(name_str, 0, 0);\n\n    output = wl_registry_bind(_glfw.wl.registry,\n                              name,\n                              &wl_output_interface,\n                              2);\n    if (!output)\n    {\n        _glfwFreeMonitor(monitor);\n        return;\n    }\n\n    monitor->wl.modes = calloc(4, sizeof(_GLFWvidmodeWayland));\n    monitor->wl.modesSize = 4;\n\n    monitor->wl.output = output;\n    wl_output_add_listener(output, &output_listener, monitor);\n\n    if (_glfw.wl.monitorsCount + 1 >= _glfw.wl.monitorsSize)\n    {\n        _GLFWmonitor** monitors = _glfw.wl.monitors;\n        int size = _glfw.wl.monitorsSize * 2;\n\n        monitors = realloc(monitors, size * sizeof(_GLFWmonitor*));\n\n        _glfw.wl.monitors = monitors;\n        _glfw.wl.monitorsSize = size;\n    }\n\n    _glfw.wl.monitors[_glfw.wl.monitorsCount++] = monitor;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count)\n{\n    _GLFWmonitor** monitors;\n    _GLFWmonitor* monitor;\n    int i, monitorsCount = _glfw.wl.monitorsCount;\n\n    if (_glfw.wl.monitorsCount == 0)\n        goto err;\n\n    monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));\n\n    for (i = 0; i < monitorsCount; i++)\n    {\n        _GLFWmonitor* origMonitor = _glfw.wl.monitors[i];\n        monitor = calloc(1, sizeof(_GLFWmonitor));\n\n        monitor->modes =\n            _glfwPlatformGetVideoModes(origMonitor,\n                                       &origMonitor->wl.modesCount);\n        *monitor = *_glfw.wl.monitors[i];\n        monitors[i] = monitor;\n    }\n\n    *count = monitorsCount;\n    return monitors;\n\nerr:\n    *count = 0;\n    return NULL;\n}\n\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)\n{\n    return first->wl.output == second->wl.output;\n}\n\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)\n{\n    if (xpos)\n        *xpos = monitor->wl.x;\n    if (ypos)\n        *ypos = monitor->wl.y;\n}\n\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)\n{\n    GLFWvidmode *modes;\n    int i, modesCount = monitor->wl.modesCount;\n\n    modes = calloc(modesCount, sizeof(GLFWvidmode));\n\n    for (i = 0;  i < modesCount;  i++)\n        modes[i] = monitor->wl.modes[i].base;\n\n    *found = modesCount;\n    return modes;\n}\n\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)\n{\n    int i;\n\n    for (i = 0;  i < monitor->wl.modesCount;  i++)\n    {\n        if (monitor->wl.modes[i].flags & WL_OUTPUT_MODE_CURRENT)\n        {\n            *mode = monitor->wl.modes[i].base;\n            return;\n        }\n    }\n}\n\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformGetGammaRamp not implemented yet\\n\");\n}\n\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformSetGammaRamp not implemented yet\\n\");\n}\n\n"
  },
  {
    "path": "deps/glfw/src/wl_platform.h",
    "content": "//========================================================================\n// GLFW 3.1 Wayland - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_wayland_platform_h_\n#define _glfw3_wayland_platform_h_\n\n#include <wayland-client.h>\n#include <xkbcommon/xkbcommon.h>\n\n#include \"posix_tls.h\"\n#include \"posix_time.h\"\n#include \"linux_joystick.h\"\n#include \"xkb_unicode.h\"\n\n#if defined(_GLFW_EGL)\n #include \"egl_context.h\"\n#else\n #error \"The Wayland backend depends on EGL platform support\"\n#endif\n\n#define _GLFW_EGL_NATIVE_WINDOW         window->wl.native\n#define _GLFW_EGL_NATIVE_DISPLAY        _glfw.wl.display\n\n#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWayland  wl\n#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl\n#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWayland wl\n#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWayland  wl\n\n\n// Wayland-specific video mode data\n//\ntypedef struct _GLFWvidmodeWayland _GLFWvidmodeWayland;\n\n\n// Wayland-specific per-window data\n//\ntypedef struct _GLFWwindowWayland\n{\n    int                         width, height;\n    GLboolean                   visible;\n    struct wl_surface*          surface;\n    struct wl_egl_window*       native;\n    struct wl_shell_surface*    shell_surface;\n    struct wl_callback*         callback;\n    _GLFWcursor*                currentCursor;\n    double                      cursorPosX, cursorPosY;\n} _GLFWwindowWayland;\n\n\n// Wayland-specific global data\n//\ntypedef struct _GLFWlibraryWayland\n{\n    struct wl_display*          display;\n    struct wl_registry*         registry;\n    struct wl_compositor*       compositor;\n    struct wl_shell*            shell;\n    struct wl_shm*              shm;\n    struct wl_seat*             seat;\n    struct wl_pointer*          pointer;\n    struct wl_keyboard*         keyboard;\n\n    struct wl_cursor_theme*     cursorTheme;\n    struct wl_cursor*           defaultCursor;\n    struct wl_surface*          cursorSurface;\n    uint32_t                    pointerSerial;\n\n    _GLFWmonitor**              monitors;\n    int                         monitorsCount;\n    int                         monitorsSize;\n\n    struct {\n        struct xkb_context*     context;\n        struct xkb_keymap*      keymap;\n        struct xkb_state*       state;\n        xkb_mod_mask_t          control_mask;\n        xkb_mod_mask_t          alt_mask;\n        xkb_mod_mask_t          shift_mask;\n        xkb_mod_mask_t          super_mask;\n        unsigned int            modifiers;\n    } xkb;\n\n    _GLFWwindow*                pointerFocus;\n    _GLFWwindow*                keyboardFocus;\n\n} _GLFWlibraryWayland;\n\n\n// Wayland-specific per-monitor data\n//\ntypedef struct _GLFWmonitorWayland\n{\n    struct wl_output*           output;\n\n    _GLFWvidmodeWayland*        modes;\n    int                         modesCount;\n    int                         modesSize;\n    GLboolean                   done;\n\n    int                         x;\n    int                         y;\n\n} _GLFWmonitorWayland;\n\n\n// Wayland-specific per-cursor data\n//\ntypedef struct _GLFWcursorWayland\n{\n    struct wl_buffer*           buffer;\n    int                         width, height;\n    int                         xhot, yhot;\n} _GLFWcursorWayland;\n\n\nvoid _glfwAddOutput(uint32_t name, uint32_t version);\n\n#endif // _glfw3_wayland_platform_h_\n"
  },
  {
    "path": "deps/glfw/src/wl_window.c",
    "content": "//========================================================================\n// GLFW 3.1 Wayland - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#define _GNU_SOURCE\n\n#include \"internal.h\"\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <unistd.h>\n#include <string.h>\n#include <fcntl.h>\n#include <sys/mman.h>\n#include <poll.h>\n\n#include <wayland-egl.h>\n#include <wayland-cursor.h>\n\n\nstatic void handlePing(void* data,\n                       struct wl_shell_surface* shellSurface,\n                       uint32_t serial)\n{\n    wl_shell_surface_pong(shellSurface, serial);\n}\n\nstatic void handleConfigure(void* data,\n                            struct wl_shell_surface* shellSurface,\n                            uint32_t edges,\n                            int32_t width,\n                            int32_t height)\n{\n    _GLFWwindow* window = data;\n    _glfwInputFramebufferSize(window, width, height);\n    _glfwInputWindowSize(window, width, height);\n    _glfwPlatformSetWindowSize(window, width, height);\n    _glfwInputWindowDamage(window);\n}\n\nstatic void handlePopupDone(void* data,\n                            struct wl_shell_surface* shellSurface)\n{\n}\n\nstatic const struct wl_shell_surface_listener shellSurfaceListener = {\n    handlePing,\n    handleConfigure,\n    handlePopupDone\n};\n\nstatic GLboolean createSurface(_GLFWwindow* window,\n                               const _GLFWwndconfig* wndconfig)\n{\n    window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);\n    if (!window->wl.surface)\n        return GL_FALSE;\n\n    wl_surface_set_user_data(window->wl.surface, window);\n\n    window->wl.native = wl_egl_window_create(window->wl.surface,\n                                             wndconfig->width,\n                                             wndconfig->height);\n    if (!window->wl.native)\n        return GL_FALSE;\n\n    window->wl.shell_surface = wl_shell_get_shell_surface(_glfw.wl.shell,\n                                                          window->wl.surface);\n    if (!window->wl.shell_surface)\n        return GL_FALSE;\n\n    wl_shell_surface_add_listener(window->wl.shell_surface,\n                                  &shellSurfaceListener,\n                                  window);\n\n    window->wl.width = wndconfig->width;\n    window->wl.height = wndconfig->height;\n\n    return GL_TRUE;\n}\n\nstatic int\ncreateTmpfileCloexec(char* tmpname)\n{\n    int fd;\n\n    fd = mkostemp(tmpname, O_CLOEXEC);\n    if (fd >= 0)\n        unlink(tmpname);\n\n    return fd;\n}\n\nstatic void\nhandleEvents(int timeout)\n{\n    struct wl_display* display = _glfw.wl.display;\n    struct pollfd fds[] = {\n        { wl_display_get_fd(display), POLLIN },\n    };\n\n    while (wl_display_prepare_read(display) != 0)\n        wl_display_dispatch_pending(display);\n\n    // If an error different from EAGAIN happens, we have likely been\n    // disconnected from the Wayland session, try to handle that the best we\n    // can.\n    if (wl_display_flush(display) < 0 && errno != EAGAIN)\n    {\n        _GLFWwindow* window = _glfw.windowListHead;\n        while (window)\n        {\n            _glfwInputWindowCloseRequest(window);\n            window = window->next;\n        }\n        wl_display_cancel_read(display);\n        return;\n    }\n\n    if (poll(fds, 1, timeout) > 0)\n    {\n        wl_display_read_events(display);\n        wl_display_dispatch_pending(display);\n    }\n    else\n    {\n        wl_display_cancel_read(display);\n    }\n}\n\n/*\n * Create a new, unique, anonymous file of the given size, and\n * return the file descriptor for it. The file descriptor is set\n * CLOEXEC. The file is immediately suitable for mmap()'ing\n * the given size at offset zero.\n *\n * The file should not have a permanent backing store like a disk,\n * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.\n *\n * The file name is deleted from the file system.\n *\n * The file is suitable for buffer sharing between processes by\n * transmitting the file descriptor over Unix sockets using the\n * SCM_RIGHTS methods.\n *\n * posix_fallocate() is used to guarantee that disk space is available\n * for the file at the given size. If disk space is insufficent, errno\n * is set to ENOSPC. If posix_fallocate() is not supported, program may\n * receive SIGBUS on accessing mmap()'ed file contents instead.\n */\nint\ncreateAnonymousFile(off_t size)\n{\n    static const char template[] = \"/glfw-shared-XXXXXX\";\n    const char* path;\n    char* name;\n    int fd;\n    int ret;\n\n    path = getenv(\"XDG_RUNTIME_DIR\");\n    if (!path)\n    {\n        errno = ENOENT;\n        return -1;\n    }\n\n    name = calloc(strlen(path) + sizeof(template), 1);\n    strcpy(name, path);\n    strcat(name, template);\n\n    fd = createTmpfileCloexec(name);\n\n    free(name);\n\n    if (fd < 0)\n        return -1;\n    ret = posix_fallocate(fd, 0, size);\n    if (ret != 0)\n    {\n        close(fd);\n        errno = ret;\n        return -1;\n    }\n    return fd;\n}\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig)\n{\n    if (!_glfwCreateContext(window, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    if (!createSurface(window, wndconfig))\n        return GL_FALSE;\n\n    if (wndconfig->monitor)\n    {\n        wl_shell_surface_set_fullscreen(\n            window->wl.shell_surface,\n            WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,\n            0,\n            wndconfig->monitor->wl.output);\n    }\n    else\n    {\n        wl_shell_surface_set_toplevel(window->wl.shell_surface);\n    }\n\n    window->wl.currentCursor = NULL;\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window)\n{\n    if (window == _glfw.wl.pointerFocus)\n    {\n        _glfw.wl.pointerFocus = NULL;\n        _glfwInputCursorEnter(window, GL_FALSE);\n    }\n    if (window == _glfw.wl.keyboardFocus)\n    {\n        _glfw.wl.keyboardFocus = NULL;\n        _glfwInputWindowFocus(window, GL_FALSE);\n    }\n\n    _glfwDestroyContext(window);\n\n    if (window->wl.native)\n        wl_egl_window_destroy(window->wl.native);\n\n    if (window->wl.shell_surface)\n        wl_shell_surface_destroy(window->wl.shell_surface);\n\n    if (window->wl.surface)\n        wl_surface_destroy(window->wl.surface);\n}\n\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)\n{\n    wl_shell_surface_set_title(window->wl.shell_surface, title);\n}\n\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)\n{\n    // A Wayland client is not aware of its position, so just warn and leave it\n    // as (0, 0)\n\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Wayland: Window position retrieval not supported\");\n}\n\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)\n{\n    // A Wayland client can not set its position, so just warn\n\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Wayland: Window position setting not supported\");\n}\n\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)\n{\n    if (width)\n        *width = window->wl.width;\n    if (height)\n        *height = window->wl.height;\n}\n\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)\n{\n    wl_egl_window_resize(window->wl.native, width, height, 0, 0);\n    window->wl.width = width;\n    window->wl.height = height;\n}\n\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)\n{\n    _glfwPlatformGetWindowSize(window, width, height);\n}\n\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,\n                                     int* left, int* top,\n                                     int* right, int* bottom)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformGetWindowFrameSize not implemented yet\\n\");\n}\n\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformIconifyWindow not implemented yet\\n\");\n}\n\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformRestoreWindow not implemented yet\\n\");\n}\n\nvoid _glfwPlatformShowWindow(_GLFWwindow* window)\n{\n    wl_shell_surface_set_toplevel(window->wl.shell_surface);\n}\n\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformUnhideWindow not implemented yet\\n\");\n}\n\nvoid _glfwPlatformHideWindow(_GLFWwindow* window)\n{\n    wl_surface_attach(window->wl.surface, NULL, 0, 0);\n    wl_surface_commit(window->wl.surface);\n}\n\nint _glfwPlatformWindowFocused(_GLFWwindow* window)\n{\n    // TODO\n    return GL_FALSE;\n}\n\nint _glfwPlatformWindowIconified(_GLFWwindow* window)\n{\n    // TODO\n    return GL_FALSE;\n}\n\nint _glfwPlatformWindowVisible(_GLFWwindow* window)\n{\n    // TODO\n    return GL_FALSE;\n}\n\nvoid _glfwPlatformPollEvents(void)\n{\n    handleEvents(0);\n}\n\nvoid _glfwPlatformWaitEvents(void)\n{\n    handleEvents(-1);\n}\n\nvoid _glfwPlatformPostEmptyEvent(void)\n{\n    wl_display_sync(_glfw.wl.display);\n}\n\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)\n{\n    if (xpos)\n        *xpos = window->wl.cursorPosX;\n    if (ypos)\n        *ypos = window->wl.cursorPosY;\n}\n\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)\n{\n    // A Wayland client can not set the cursor position\n    _glfwInputError(GLFW_PLATFORM_ERROR,\n                    \"Wayland: Cursor position setting not supported\");\n}\n\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window)\n{\n    _glfwPlatformSetCursor(window, window->wl.currentCursor);\n}\n\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor,\n                              const GLFWimage* image,\n                              int xhot, int yhot)\n{\n    struct wl_shm_pool* pool;\n    int stride = image->width * 4;\n    int length = image->width * image->height * 4;\n    void* data;\n    int fd, i;\n\n    fd = createAnonymousFile(length);\n    if (fd < 0)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Creating a buffer file for %d B failed: %m\\n\",\n                        length);\n        return GL_FALSE;\n    }\n\n    data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);\n    if (data == MAP_FAILED)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"Wayland: Cursor mmap failed: %m\\n\");\n        close(fd);\n        return GL_FALSE;\n    }\n\n    pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);\n\n    close(fd);\n    unsigned char* source = (unsigned char*) image->pixels;\n    unsigned char* target = data;\n    for (i = 0;  i < image->width * image->height;  i++, source += 4)\n    {\n        *target++ = source[2];\n        *target++ = source[1];\n        *target++ = source[0];\n        *target++ = source[3];\n    }\n\n    cursor->wl.buffer =\n        wl_shm_pool_create_buffer(pool, 0,\n                                  image->width,\n                                  image->height,\n                                  stride, WL_SHM_FORMAT_ARGB8888);\n    munmap(data, length);\n    wl_shm_pool_destroy(pool);\n\n    cursor->wl.width = image->width;\n    cursor->wl.height = image->height;\n    cursor->wl.xhot = xhot;\n    cursor->wl.yhot = yhot;\n    return GL_TRUE;\n}\n\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformCreateStandardCursor not implemented yet\\n\");\n    return GL_FALSE;\n}\n\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor)\n{\n    wl_buffer_destroy(cursor->wl.buffer);\n}\n\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)\n{\n    struct wl_buffer* buffer;\n    struct wl_cursor_image* image;\n    struct wl_surface* surface = _glfw.wl.cursorSurface;\n\n    if (!_glfw.wl.pointer)\n        return;\n\n    window->wl.currentCursor = cursor;\n\n    // If we're not in the correct window just save the cursor\n    // the next time the pointer enters the window the cursor will change\n    if (window != _glfw.wl.pointerFocus)\n        return;\n\n    if (window->cursorMode == GLFW_CURSOR_NORMAL)\n    {\n        if (cursor == NULL)\n        {\n            image = _glfw.wl.defaultCursor->images[0];\n            buffer = wl_cursor_image_get_buffer(image);\n            if (!buffer)\n                return;\n            wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial,\n                                  surface,\n                                  image->hotspot_x,\n                                  image->hotspot_y);\n            wl_surface_attach(surface, buffer, 0, 0);\n            wl_surface_damage(surface, 0, 0,\n                              image->width, image->height);\n            wl_surface_commit(surface);\n        }\n        else\n        {\n            wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial,\n                                  surface,\n                                  cursor->wl.xhot,\n                                  cursor->wl.yhot);\n            wl_surface_attach(surface, cursor->wl.buffer, 0, 0);\n            wl_surface_damage(surface, 0, 0,\n                              cursor->wl.width, cursor->wl.height);\n            wl_surface_commit(surface);\n        }\n    }\n    else /* Cursor is hidden set cursor surface to NULL */\n    {\n        wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial, NULL, 0, 0);\n    }\n}\n\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformSetClipboardString not implemented yet\\n\");\n}\n\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window)\n{\n    // TODO\n    fprintf(stderr, \"_glfwPlatformGetClipboardString not implemented yet\\n\");\n    return NULL;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/x11_init.c",
    "content": "//========================================================================\n// GLFW 3.1 X11 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <X11/Xresource.h>\n\n#include <stdlib.h>\n#include <string.h>\n#include <limits.h>\n#include <stdio.h>\n#include <locale.h>\n\n\n// Translate an X11 key code to a GLFW key code.\n//\nstatic int translateKeyCode(int scancode)\n{\n    int keySym;\n\n    // Valid key code range is  [8,255], according to the Xlib manual\n    if (scancode < 8 || scancode > 255)\n        return GLFW_KEY_UNKNOWN;\n\n    if (_glfw.x11.xkb.available)\n    {\n        // Try secondary keysym, for numeric keypad keys\n        // Note: This way we always force \"NumLock = ON\", which is intentional\n        // since the returned key code should correspond to a physical\n        // location.\n        keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 1);\n        switch (keySym)\n        {\n            case XK_KP_0:           return GLFW_KEY_KP_0;\n            case XK_KP_1:           return GLFW_KEY_KP_1;\n            case XK_KP_2:           return GLFW_KEY_KP_2;\n            case XK_KP_3:           return GLFW_KEY_KP_3;\n            case XK_KP_4:           return GLFW_KEY_KP_4;\n            case XK_KP_5:           return GLFW_KEY_KP_5;\n            case XK_KP_6:           return GLFW_KEY_KP_6;\n            case XK_KP_7:           return GLFW_KEY_KP_7;\n            case XK_KP_8:           return GLFW_KEY_KP_8;\n            case XK_KP_9:           return GLFW_KEY_KP_9;\n            case XK_KP_Separator:\n            case XK_KP_Decimal:     return GLFW_KEY_KP_DECIMAL;\n            case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;\n            case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;\n            default:                break;\n        }\n\n        // Now try primary keysym for function keys (non-printable keys). These\n        // should not be layout dependent (i.e. US layout and international\n        // layouts should give the same result).\n        keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0);\n    }\n    else\n    {\n        int dummy;\n        KeySym* keySyms;\n\n        keySyms = XGetKeyboardMapping(_glfw.x11.display, scancode, 1, &dummy);\n        keySym = keySyms[0];\n        XFree(keySyms);\n    }\n\n    switch (keySym)\n    {\n        case XK_Escape:         return GLFW_KEY_ESCAPE;\n        case XK_Tab:            return GLFW_KEY_TAB;\n        case XK_Shift_L:        return GLFW_KEY_LEFT_SHIFT;\n        case XK_Shift_R:        return GLFW_KEY_RIGHT_SHIFT;\n        case XK_Control_L:      return GLFW_KEY_LEFT_CONTROL;\n        case XK_Control_R:      return GLFW_KEY_RIGHT_CONTROL;\n        case XK_Meta_L:\n        case XK_Alt_L:          return GLFW_KEY_LEFT_ALT;\n        case XK_Mode_switch: // Mapped to Alt_R on many keyboards\n        case XK_ISO_Level3_Shift: // AltGr on at least some machines\n        case XK_Meta_R:\n        case XK_Alt_R:          return GLFW_KEY_RIGHT_ALT;\n        case XK_Super_L:        return GLFW_KEY_LEFT_SUPER;\n        case XK_Super_R:        return GLFW_KEY_RIGHT_SUPER;\n        case XK_Menu:           return GLFW_KEY_MENU;\n        case XK_Num_Lock:       return GLFW_KEY_NUM_LOCK;\n        case XK_Caps_Lock:      return GLFW_KEY_CAPS_LOCK;\n        case XK_Print:          return GLFW_KEY_PRINT_SCREEN;\n        case XK_Scroll_Lock:    return GLFW_KEY_SCROLL_LOCK;\n        case XK_Pause:          return GLFW_KEY_PAUSE;\n        case XK_Delete:         return GLFW_KEY_DELETE;\n        case XK_BackSpace:      return GLFW_KEY_BACKSPACE;\n        case XK_Return:         return GLFW_KEY_ENTER;\n        case XK_Home:           return GLFW_KEY_HOME;\n        case XK_End:            return GLFW_KEY_END;\n        case XK_Page_Up:        return GLFW_KEY_PAGE_UP;\n        case XK_Page_Down:      return GLFW_KEY_PAGE_DOWN;\n        case XK_Insert:         return GLFW_KEY_INSERT;\n        case XK_Left:           return GLFW_KEY_LEFT;\n        case XK_Right:          return GLFW_KEY_RIGHT;\n        case XK_Down:           return GLFW_KEY_DOWN;\n        case XK_Up:             return GLFW_KEY_UP;\n        case XK_F1:             return GLFW_KEY_F1;\n        case XK_F2:             return GLFW_KEY_F2;\n        case XK_F3:             return GLFW_KEY_F3;\n        case XK_F4:             return GLFW_KEY_F4;\n        case XK_F5:             return GLFW_KEY_F5;\n        case XK_F6:             return GLFW_KEY_F6;\n        case XK_F7:             return GLFW_KEY_F7;\n        case XK_F8:             return GLFW_KEY_F8;\n        case XK_F9:             return GLFW_KEY_F9;\n        case XK_F10:            return GLFW_KEY_F10;\n        case XK_F11:            return GLFW_KEY_F11;\n        case XK_F12:            return GLFW_KEY_F12;\n        case XK_F13:            return GLFW_KEY_F13;\n        case XK_F14:            return GLFW_KEY_F14;\n        case XK_F15:            return GLFW_KEY_F15;\n        case XK_F16:            return GLFW_KEY_F16;\n        case XK_F17:            return GLFW_KEY_F17;\n        case XK_F18:            return GLFW_KEY_F18;\n        case XK_F19:            return GLFW_KEY_F19;\n        case XK_F20:            return GLFW_KEY_F20;\n        case XK_F21:            return GLFW_KEY_F21;\n        case XK_F22:            return GLFW_KEY_F22;\n        case XK_F23:            return GLFW_KEY_F23;\n        case XK_F24:            return GLFW_KEY_F24;\n        case XK_F25:            return GLFW_KEY_F25;\n\n        // Numeric keypad\n        case XK_KP_Divide:      return GLFW_KEY_KP_DIVIDE;\n        case XK_KP_Multiply:    return GLFW_KEY_KP_MULTIPLY;\n        case XK_KP_Subtract:    return GLFW_KEY_KP_SUBTRACT;\n        case XK_KP_Add:         return GLFW_KEY_KP_ADD;\n\n        // These should have been detected in secondary keysym test above!\n        case XK_KP_Insert:      return GLFW_KEY_KP_0;\n        case XK_KP_End:         return GLFW_KEY_KP_1;\n        case XK_KP_Down:        return GLFW_KEY_KP_2;\n        case XK_KP_Page_Down:   return GLFW_KEY_KP_3;\n        case XK_KP_Left:        return GLFW_KEY_KP_4;\n        case XK_KP_Right:       return GLFW_KEY_KP_6;\n        case XK_KP_Home:        return GLFW_KEY_KP_7;\n        case XK_KP_Up:          return GLFW_KEY_KP_8;\n        case XK_KP_Page_Up:     return GLFW_KEY_KP_9;\n        case XK_KP_Delete:      return GLFW_KEY_KP_DECIMAL;\n        case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;\n        case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;\n\n        // Last resort: Check for printable keys (should not happen if the XKB\n        // extension is available). This will give a layout dependent mapping\n        // (which is wrong, and we may miss some keys, especially on non-US\n        // keyboards), but it's better than nothing...\n        case XK_a:              return GLFW_KEY_A;\n        case XK_b:              return GLFW_KEY_B;\n        case XK_c:              return GLFW_KEY_C;\n        case XK_d:              return GLFW_KEY_D;\n        case XK_e:              return GLFW_KEY_E;\n        case XK_f:              return GLFW_KEY_F;\n        case XK_g:              return GLFW_KEY_G;\n        case XK_h:              return GLFW_KEY_H;\n        case XK_i:              return GLFW_KEY_I;\n        case XK_j:              return GLFW_KEY_J;\n        case XK_k:              return GLFW_KEY_K;\n        case XK_l:              return GLFW_KEY_L;\n        case XK_m:              return GLFW_KEY_M;\n        case XK_n:              return GLFW_KEY_N;\n        case XK_o:              return GLFW_KEY_O;\n        case XK_p:              return GLFW_KEY_P;\n        case XK_q:              return GLFW_KEY_Q;\n        case XK_r:              return GLFW_KEY_R;\n        case XK_s:              return GLFW_KEY_S;\n        case XK_t:              return GLFW_KEY_T;\n        case XK_u:              return GLFW_KEY_U;\n        case XK_v:              return GLFW_KEY_V;\n        case XK_w:              return GLFW_KEY_W;\n        case XK_x:              return GLFW_KEY_X;\n        case XK_y:              return GLFW_KEY_Y;\n        case XK_z:              return GLFW_KEY_Z;\n        case XK_1:              return GLFW_KEY_1;\n        case XK_2:              return GLFW_KEY_2;\n        case XK_3:              return GLFW_KEY_3;\n        case XK_4:              return GLFW_KEY_4;\n        case XK_5:              return GLFW_KEY_5;\n        case XK_6:              return GLFW_KEY_6;\n        case XK_7:              return GLFW_KEY_7;\n        case XK_8:              return GLFW_KEY_8;\n        case XK_9:              return GLFW_KEY_9;\n        case XK_0:              return GLFW_KEY_0;\n        case XK_space:          return GLFW_KEY_SPACE;\n        case XK_minus:          return GLFW_KEY_MINUS;\n        case XK_equal:          return GLFW_KEY_EQUAL;\n        case XK_bracketleft:    return GLFW_KEY_LEFT_BRACKET;\n        case XK_bracketright:   return GLFW_KEY_RIGHT_BRACKET;\n        case XK_backslash:      return GLFW_KEY_BACKSLASH;\n        case XK_semicolon:      return GLFW_KEY_SEMICOLON;\n        case XK_apostrophe:     return GLFW_KEY_APOSTROPHE;\n        case XK_grave:          return GLFW_KEY_GRAVE_ACCENT;\n        case XK_comma:          return GLFW_KEY_COMMA;\n        case XK_period:         return GLFW_KEY_PERIOD;\n        case XK_slash:          return GLFW_KEY_SLASH;\n        case XK_less:           return GLFW_KEY_WORLD_1; // At least in some layouts...\n        default:                break;\n    }\n\n    // No matching translation was found\n    return GLFW_KEY_UNKNOWN;\n}\n\n// Create key code translation tables\n//\nstatic void createKeyTables(void)\n{\n    int scancode, key;\n\n    memset(_glfw.x11.publicKeys, -1, sizeof(_glfw.x11.publicKeys));\n\n    if (_glfw.x11.xkb.available)\n    {\n        // Use XKB to determine physical key locations independently of the current\n        // keyboard layout\n\n        char name[XkbKeyNameLength + 1];\n        XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);\n        XkbGetNames(_glfw.x11.display, XkbKeyNamesMask, desc);\n\n        // Find the X11 key code -> GLFW key code mapping\n        for (scancode = desc->min_key_code;  scancode <= desc->max_key_code;  scancode++)\n        {\n            memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength);\n            name[XkbKeyNameLength] = '\\0';\n\n            // Map the key name to a GLFW key code. Note: We only map printable\n            // keys here, and we use the US keyboard layout. The rest of the\n            // keys (function keys) are mapped using traditional KeySym\n            // translations.\n            if (strcmp(name, \"TLDE\") == 0) key = GLFW_KEY_GRAVE_ACCENT;\n            else if (strcmp(name, \"AE01\") == 0) key = GLFW_KEY_1;\n            else if (strcmp(name, \"AE02\") == 0) key = GLFW_KEY_2;\n            else if (strcmp(name, \"AE03\") == 0) key = GLFW_KEY_3;\n            else if (strcmp(name, \"AE04\") == 0) key = GLFW_KEY_4;\n            else if (strcmp(name, \"AE05\") == 0) key = GLFW_KEY_5;\n            else if (strcmp(name, \"AE06\") == 0) key = GLFW_KEY_6;\n            else if (strcmp(name, \"AE07\") == 0) key = GLFW_KEY_7;\n            else if (strcmp(name, \"AE08\") == 0) key = GLFW_KEY_8;\n            else if (strcmp(name, \"AE09\") == 0) key = GLFW_KEY_9;\n            else if (strcmp(name, \"AE10\") == 0) key = GLFW_KEY_0;\n            else if (strcmp(name, \"AE11\") == 0) key = GLFW_KEY_MINUS;\n            else if (strcmp(name, \"AE12\") == 0) key = GLFW_KEY_EQUAL;\n            else if (strcmp(name, \"AD01\") == 0) key = GLFW_KEY_Q;\n            else if (strcmp(name, \"AD02\") == 0) key = GLFW_KEY_W;\n            else if (strcmp(name, \"AD03\") == 0) key = GLFW_KEY_E;\n            else if (strcmp(name, \"AD04\") == 0) key = GLFW_KEY_R;\n            else if (strcmp(name, \"AD05\") == 0) key = GLFW_KEY_T;\n            else if (strcmp(name, \"AD06\") == 0) key = GLFW_KEY_Y;\n            else if (strcmp(name, \"AD07\") == 0) key = GLFW_KEY_U;\n            else if (strcmp(name, \"AD08\") == 0) key = GLFW_KEY_I;\n            else if (strcmp(name, \"AD09\") == 0) key = GLFW_KEY_O;\n            else if (strcmp(name, \"AD10\") == 0) key = GLFW_KEY_P;\n            else if (strcmp(name, \"AD11\") == 0) key = GLFW_KEY_LEFT_BRACKET;\n            else if (strcmp(name, \"AD12\") == 0) key = GLFW_KEY_RIGHT_BRACKET;\n            else if (strcmp(name, \"AC01\") == 0) key = GLFW_KEY_A;\n            else if (strcmp(name, \"AC02\") == 0) key = GLFW_KEY_S;\n            else if (strcmp(name, \"AC03\") == 0) key = GLFW_KEY_D;\n            else if (strcmp(name, \"AC04\") == 0) key = GLFW_KEY_F;\n            else if (strcmp(name, \"AC05\") == 0) key = GLFW_KEY_G;\n            else if (strcmp(name, \"AC06\") == 0) key = GLFW_KEY_H;\n            else if (strcmp(name, \"AC07\") == 0) key = GLFW_KEY_J;\n            else if (strcmp(name, \"AC08\") == 0) key = GLFW_KEY_K;\n            else if (strcmp(name, \"AC09\") == 0) key = GLFW_KEY_L;\n            else if (strcmp(name, \"AC10\") == 0) key = GLFW_KEY_SEMICOLON;\n            else if (strcmp(name, \"AC11\") == 0) key = GLFW_KEY_APOSTROPHE;\n            else if (strcmp(name, \"AB01\") == 0) key = GLFW_KEY_Z;\n            else if (strcmp(name, \"AB02\") == 0) key = GLFW_KEY_X;\n            else if (strcmp(name, \"AB03\") == 0) key = GLFW_KEY_C;\n            else if (strcmp(name, \"AB04\") == 0) key = GLFW_KEY_V;\n            else if (strcmp(name, \"AB05\") == 0) key = GLFW_KEY_B;\n            else if (strcmp(name, \"AB06\") == 0) key = GLFW_KEY_N;\n            else if (strcmp(name, \"AB07\") == 0) key = GLFW_KEY_M;\n            else if (strcmp(name, \"AB08\") == 0) key = GLFW_KEY_COMMA;\n            else if (strcmp(name, \"AB09\") == 0) key = GLFW_KEY_PERIOD;\n            else if (strcmp(name, \"AB10\") == 0) key = GLFW_KEY_SLASH;\n            else if (strcmp(name, \"BKSL\") == 0) key = GLFW_KEY_BACKSLASH;\n            else if (strcmp(name, \"LSGT\") == 0) key = GLFW_KEY_WORLD_1;\n            else key = GLFW_KEY_UNKNOWN;\n\n            if ((scancode >= 0) && (scancode < 256))\n                _glfw.x11.publicKeys[scancode] = key;\n        }\n\n        XkbFreeNames(desc, XkbKeyNamesMask, True);\n        XkbFreeClientMap(desc, 0, True);\n    }\n\n    // Translate the un-translated key codes using traditional X11 KeySym\n    // lookups\n    for (scancode = 0;  scancode < 256;  scancode++)\n    {\n        if (_glfw.x11.publicKeys[scancode] < 0)\n            _glfw.x11.publicKeys[scancode] = translateKeyCode(scancode);\n    }\n}\n\n// Check whether the IM has a usable style\n//\nstatic GLboolean hasUsableInputMethodStyle(void)\n{\n    unsigned int i;\n    GLboolean found = GL_FALSE;\n    XIMStyles* styles = NULL;\n\n    if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)\n        return GL_FALSE;\n\n    for (i = 0;  i < styles->count_styles;  i++)\n    {\n        if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))\n        {\n            found = GL_TRUE;\n            break;\n        }\n    }\n\n    XFree(styles);\n    return found;\n}\n\n// Check whether the specified atom is supported\n//\nstatic Atom getSupportedAtom(Atom* supportedAtoms,\n                             unsigned long atomCount,\n                             const char* atomName)\n{\n    Atom atom = XInternAtom(_glfw.x11.display, atomName, True);\n    if (atom != None)\n    {\n        unsigned long i;\n\n        for (i = 0;  i < atomCount;  i++)\n        {\n            if (supportedAtoms[i] == atom)\n                return atom;\n        }\n    }\n\n    return None;\n}\n\n// Check whether the running window manager is EWMH-compliant\n//\nstatic void detectEWMH(void)\n{\n    Window* windowFromRoot = NULL;\n    Window* windowFromChild = NULL;\n\n    // First we need a couple of atoms, which should already be there\n    Atom supportingWmCheck =\n        XInternAtom(_glfw.x11.display, \"_NET_SUPPORTING_WM_CHECK\", True);\n    Atom wmSupported =\n        XInternAtom(_glfw.x11.display, \"_NET_SUPPORTED\", True);\n    if (supportingWmCheck == None || wmSupported == None)\n        return;\n\n    // Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window\n    if (_glfwGetWindowProperty(_glfw.x11.root,\n                               supportingWmCheck,\n                               XA_WINDOW,\n                               (unsigned char**) &windowFromRoot) != 1)\n    {\n        if (windowFromRoot)\n            XFree(windowFromRoot);\n        return;\n    }\n\n    _glfwGrabXErrorHandler();\n\n    // It should be the ID of a child window (of the root)\n    // Then we look for the same property on the child window\n    if (_glfwGetWindowProperty(*windowFromRoot,\n                               supportingWmCheck,\n                               XA_WINDOW,\n                               (unsigned char**) &windowFromChild) != 1)\n    {\n        XFree(windowFromRoot);\n        if (windowFromChild)\n            XFree(windowFromChild);\n        return;\n    }\n\n    _glfwReleaseXErrorHandler();\n\n    // It should be the ID of that same child window\n    if (*windowFromRoot != *windowFromChild)\n    {\n        XFree(windowFromRoot);\n        XFree(windowFromChild);\n        return;\n    }\n\n    XFree(windowFromRoot);\n    XFree(windowFromChild);\n\n    // We are now fairly sure that an EWMH-compliant window manager is running\n\n    Atom* supportedAtoms;\n    unsigned long atomCount;\n\n    // Now we need to check the _NET_SUPPORTED property of the root window\n    // It should be a list of supported WM protocol and state atoms\n    atomCount = _glfwGetWindowProperty(_glfw.x11.root,\n                                       wmSupported,\n                                       XA_ATOM,\n                                       (unsigned char**) &supportedAtoms);\n\n    // See which of the atoms we support that are supported by the WM\n    _glfw.x11.NET_WM_STATE =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_STATE\");\n    _glfw.x11.NET_WM_STATE_ABOVE =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_STATE_ABOVE\");\n    _glfw.x11.NET_WM_STATE_FULLSCREEN =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_STATE_FULLSCREEN\");\n    _glfw.x11.NET_WM_FULLSCREEN_MONITORS =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_FULLSCREEN_MONITORS\");\n    _glfw.x11.NET_WM_NAME =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_NAME\");\n    _glfw.x11.NET_WM_ICON_NAME =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_ICON_NAME\");\n    _glfw.x11.NET_WM_PID =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_PID\");\n    _glfw.x11.NET_WM_PING =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_PING\");\n    _glfw.x11.NET_ACTIVE_WINDOW =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_ACTIVE_WINDOW\");\n    _glfw.x11.NET_FRAME_EXTENTS =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_FRAME_EXTENTS\");\n    _glfw.x11.NET_REQUEST_FRAME_EXTENTS =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_REQUEST_FRAME_EXTENTS\");\n    _glfw.x11.NET_WM_BYPASS_COMPOSITOR =\n        getSupportedAtom(supportedAtoms, atomCount, \"_NET_WM_BYPASS_COMPOSITOR\");\n\n    XFree(supportedAtoms);\n}\n\n// Initialize X11 display and look for supported X11 extensions\n//\nstatic GLboolean initExtensions(void)\n{\n    // Find or create window manager atoms\n    _glfw.x11.WM_PROTOCOLS = XInternAtom(_glfw.x11.display,\n                                         \"WM_PROTOCOLS\",\n                                         False);\n    _glfw.x11.WM_STATE = XInternAtom(_glfw.x11.display, \"WM_STATE\", False);\n    _glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display,\n                                             \"WM_DELETE_WINDOW\",\n                                             False);\n    _glfw.x11.MOTIF_WM_HINTS = XInternAtom(_glfw.x11.display,\n                                           \"_MOTIF_WM_HINTS\",\n                                           False);\n\n#if defined(_GLFW_HAS_XF86VM)\n    // Check for XF86VidMode extension\n    _glfw.x11.vidmode.available =\n        XF86VidModeQueryExtension(_glfw.x11.display,\n                                  &_glfw.x11.vidmode.eventBase,\n                                  &_glfw.x11.vidmode.errorBase);\n#endif /*_GLFW_HAS_XF86VM*/\n\n    // Check for RandR extension\n    _glfw.x11.randr.available =\n        XRRQueryExtension(_glfw.x11.display,\n                          &_glfw.x11.randr.eventBase,\n                          &_glfw.x11.randr.errorBase);\n\n    if (_glfw.x11.randr.available)\n    {\n        XRRScreenResources* sr;\n\n        if (!XRRQueryVersion(_glfw.x11.display,\n                             &_glfw.x11.randr.major,\n                             &_glfw.x11.randr.minor))\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: Failed to query RandR version\");\n            return GL_FALSE;\n        }\n\n        // The GLFW RandR path requires at least version 1.3\n        if (_glfw.x11.randr.major == 1 && _glfw.x11.randr.minor < 3)\n            _glfw.x11.randr.available = GL_FALSE;\n\n        sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);\n\n        if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))\n        {\n            // This is either a headless system or an older Nvidia binary driver\n            // with broken gamma support\n            // Flag it as useless and fall back to Xf86VidMode gamma, if\n            // available\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: RandR gamma ramp support seems broken\");\n            _glfw.x11.randr.gammaBroken = GL_TRUE;\n        }\n\n        XRRFreeScreenResources(sr);\n    }\n\n    if (XineramaQueryExtension(_glfw.x11.display,\n                               &_glfw.x11.xinerama.major,\n                               &_glfw.x11.xinerama.minor))\n    {\n        if (XineramaIsActive(_glfw.x11.display))\n            _glfw.x11.xinerama.available = GL_TRUE;\n    }\n\n#if defined(_GLFW_HAS_XINPUT)\n    if (XQueryExtension(_glfw.x11.display,\n                        \"XInputExtension\",\n                        &_glfw.x11.xi.majorOpcode,\n                        &_glfw.x11.xi.eventBase,\n                        &_glfw.x11.xi.errorBase))\n    {\n        _glfw.x11.xi.major = 2;\n        _glfw.x11.xi.minor = 0;\n\n        if (XIQueryVersion(_glfw.x11.display,\n                           &_glfw.x11.xi.major,\n                           &_glfw.x11.xi.minor) != BadRequest)\n        {\n            _glfw.x11.xi.available = GL_TRUE;\n        }\n    }\n#endif /*_GLFW_HAS_XINPUT*/\n\n    // Check if Xkb is supported on this display\n    _glfw.x11.xkb.major = 1;\n    _glfw.x11.xkb.minor = 0;\n    _glfw.x11.xkb.available =\n        XkbQueryExtension(_glfw.x11.display,\n                          &_glfw.x11.xkb.majorOpcode,\n                          &_glfw.x11.xkb.eventBase,\n                          &_glfw.x11.xkb.errorBase,\n                          &_glfw.x11.xkb.major,\n                          &_glfw.x11.xkb.minor);\n\n    if (_glfw.x11.xkb.available)\n    {\n        Bool supported;\n\n        if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))\n        {\n            if (supported)\n                _glfw.x11.xkb.detectable = GL_TRUE;\n        }\n    }\n\n    // Update the key code LUT\n    // FIXME: We should listen to XkbMapNotify events to track changes to\n    // the keyboard mapping.\n    createKeyTables();\n\n    // Detect whether an EWMH-conformant window manager is running\n    detectEWMH();\n\n    // Find or create string format atoms\n    _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, \"NULL\", False);\n    _glfw.x11.UTF8_STRING =\n        XInternAtom(_glfw.x11.display, \"UTF8_STRING\", False);\n    _glfw.x11.COMPOUND_STRING =\n        XInternAtom(_glfw.x11.display, \"COMPOUND_STRING\", False);\n    _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, \"ATOM_PAIR\", False);\n\n    // Find or create selection property atom\n    _glfw.x11.GLFW_SELECTION =\n        XInternAtom(_glfw.x11.display, \"GLFW_SELECTION\", False);\n\n    // Find or create standard clipboard atoms\n    _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, \"TARGETS\", False);\n    _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, \"MULTIPLE\", False);\n    _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, \"CLIPBOARD\", False);\n\n    // Find or create clipboard manager atoms\n    _glfw.x11.CLIPBOARD_MANAGER =\n        XInternAtom(_glfw.x11.display, \"CLIPBOARD_MANAGER\", False);\n    _glfw.x11.SAVE_TARGETS =\n        XInternAtom(_glfw.x11.display, \"SAVE_TARGETS\", False);\n\n    // Find Xdnd (drag and drop) atoms, if available\n    _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, \"XdndAware\", True);\n    _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, \"XdndEnter\", True);\n    _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, \"XdndPosition\", True);\n    _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, \"XdndStatus\", True);\n    _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, \"XdndActionCopy\", True);\n    _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, \"XdndDrop\", True);\n    _glfw.x11.XdndLeave = XInternAtom(_glfw.x11.display, \"XdndLeave\", True);\n    _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, \"XdndFinished\", True);\n    _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, \"XdndSelection\", True);\n\n    return GL_TRUE;\n}\n\n// Create a blank cursor for hidden and disabled cursor modes\n//\nstatic Cursor createNULLCursor(void)\n{\n    unsigned char pixels[16 * 16 * 4];\n    GLFWimage image = { 16, 16, pixels };\n\n    memset(pixels, 0, sizeof(pixels));\n\n    return _glfwCreateCursor(&image, 0, 0);\n}\n\n// X error handler\n//\nstatic int errorHandler(Display *display, XErrorEvent* event)\n{\n    _glfw.x11.errorCode = event->error_code;\n    return 0;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Sets the X error handler callback\n//\nvoid _glfwGrabXErrorHandler(void)\n{\n    _glfw.x11.errorCode = Success;\n    XSetErrorHandler(errorHandler);\n}\n\n// Clears the X error handler callback\n//\nvoid _glfwReleaseXErrorHandler(void)\n{\n    // Synchronize to make sure all commands are processed\n    XSync(_glfw.x11.display, False);\n    XSetErrorHandler(NULL);\n}\n\n// Reports the specified error, appending information about the last X error\n//\nvoid _glfwInputXError(int error, const char* message)\n{\n    char buffer[8192];\n    XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,\n                  buffer, sizeof(buffer));\n\n    _glfwInputError(error, \"%s: %s\", message, buffer);\n}\n\n// Creates a native cursor object from the specified image and hotspot\n//\nCursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)\n{\n    int i;\n    Cursor cursor;\n\n    XcursorImage* native = XcursorImageCreate(image->width, image->height);\n    if (native == NULL)\n        return None;\n\n    native->xhot = xhot;\n    native->yhot = yhot;\n\n    unsigned char* source = (unsigned char*) image->pixels;\n    XcursorPixel* target = native->pixels;\n\n    for (i = 0;  i < image->width * image->height;  i++, target++, source += 4)\n    {\n        *target = (source[3] << 24) |\n                  (source[0] << 16) |\n                  (source[1] <<  8) |\n                   source[2];\n    }\n\n    cursor = XcursorImageLoadCursor(_glfw.x11.display, native);\n    XcursorImageDestroy(native);\n\n    return cursor;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformInit(void)\n{\n#if !defined(X_HAVE_UTF8_STRING)\n    // HACK: If the current locale is C, apply the environment's locale\n    //       This is done because the C locale breaks wide character input\n    if (strcmp(setlocale(LC_CTYPE, NULL), \"C\") == 0)\n        setlocale(LC_CTYPE, \"\");\n#endif\n\n    XInitThreads();\n\n    _glfw.x11.display = XOpenDisplay(NULL);\n    if (!_glfw.x11.display)\n    {\n        const char* display = getenv(\"DISPLAY\");\n        if (display)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: Failed to open display %s\", display);\n        }\n        else\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: The DISPLAY environment variable is missing\");\n        }\n\n        return GL_FALSE;\n    }\n\n    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);\n    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);\n    _glfw.x11.context = XUniqueContext();\n\n    if (!initExtensions())\n        return GL_FALSE;\n\n    _glfw.x11.cursor = createNULLCursor();\n\n    if (XSupportsLocale())\n    {\n        XSetLocaleModifiers(\"\");\n\n        _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);\n        if (_glfw.x11.im)\n        {\n            if (!hasUsableInputMethodStyle())\n            {\n                XCloseIM(_glfw.x11.im);\n                _glfw.x11.im = NULL;\n            }\n        }\n    }\n\n    if (!_glfwInitContextAPI())\n        return GL_FALSE;\n\n    if (!_glfwInitJoysticks())\n        return GL_FALSE;\n\n    _glfwInitTimer();\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformTerminate(void)\n{\n    if (_glfw.x11.cursor)\n    {\n        XFreeCursor(_glfw.x11.display, _glfw.x11.cursor);\n        _glfw.x11.cursor = (Cursor) 0;\n    }\n\n    free(_glfw.x11.clipboardString);\n\n    if (_glfw.x11.im)\n    {\n        XCloseIM(_glfw.x11.im);\n        _glfw.x11.im = NULL;\n    }\n\n    _glfwTerminateJoysticks();\n\n    if (_glfw.x11.display)\n    {\n        XCloseDisplay(_glfw.x11.display);\n        _glfw.x11.display = NULL;\n    }\n\n    // NOTE: This needs to be done after XCloseDisplay, as libGL registers\n    //       internal cleanup callbacks in libX11\n    _glfwTerminateContextAPI();\n}\n\nconst char* _glfwPlatformGetVersionString(void)\n{\n    return _GLFW_VERSION_NUMBER \" X11\"\n#if defined(_GLFW_GLX)\n        \" GLX\"\n#elif defined(_GLFW_EGL)\n        \" EGL\"\n#endif\n#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)\n        \" clock_gettime\"\n#else\n        \" gettimeofday\"\n#endif\n#if defined(__linux__)\n        \" /dev/js\"\n#endif\n#if defined(_GLFW_HAS_XINPUT)\n        \" XI\"\n#endif\n#if defined(_GLFW_HAS_XF86VM)\n        \" Xf86vm\"\n#endif\n#if defined(_GLFW_BUILD_DLL)\n        \" shared\"\n#endif\n        ;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/x11_monitor.c",
    "content": "//========================================================================\n// GLFW 3.1 X11 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <limits.h>\n#include <stdlib.h>\n#include <string.h>\n\n\n// Check whether the display mode should be included in enumeration\n//\nstatic GLboolean modeIsGood(const XRRModeInfo* mi)\n{\n    return (mi->modeFlags & RR_Interlace) == 0;\n}\n\n// Calculates the refresh rate, in Hz, from the specified RandR mode info\n//\nstatic int calculateRefreshRate(const XRRModeInfo* mi)\n{\n    if (mi->hTotal && mi->vTotal)\n        return (int) ((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));\n    else\n        return 0;\n}\n\n// Returns the mode info for a RandR mode XID\n//\nstatic const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)\n{\n    int i;\n\n    for (i = 0;  i < sr->nmode;  i++)\n    {\n        if (sr->modes[i].id == id)\n            return sr->modes + i;\n    }\n\n    return NULL;\n}\n\n// Convert RandR mode info to GLFW video mode\n//\nstatic GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,\n                                       const XRRCrtcInfo* ci)\n{\n    GLFWvidmode mode;\n\n    if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)\n    {\n        mode.width  = mi->height;\n        mode.height = mi->width;\n    }\n    else\n    {\n        mode.width  = mi->width;\n        mode.height = mi->height;\n    }\n\n    mode.refreshRate = calculateRefreshRate(mi);\n\n    _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),\n                  &mode.redBits, &mode.greenBits, &mode.blueBits);\n\n    return mode;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Set the current video mode for the specified monitor\n//\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)\n    {\n        XRRScreenResources* sr;\n        XRRCrtcInfo* ci;\n        XRROutputInfo* oi;\n        GLFWvidmode current;\n        const GLFWvidmode* best;\n        RRMode native = None;\n        int i;\n\n        best = _glfwChooseVideoMode(monitor, desired);\n        _glfwPlatformGetVideoMode(monitor, &current);\n        if (_glfwCompareVideoModes(&current, best) == 0)\n            return GL_TRUE;\n\n        sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);\n        ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);\n        oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);\n\n        for (i = 0;  i < oi->nmode;  i++)\n        {\n            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);\n            if (!modeIsGood(mi))\n                continue;\n\n            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);\n            if (_glfwCompareVideoModes(best, &mode) == 0)\n            {\n                native = mi->id;\n                break;\n            }\n        }\n\n        if (native)\n        {\n            if (monitor->x11.oldMode == None)\n                monitor->x11.oldMode = ci->mode;\n\n            XRRSetCrtcConfig(_glfw.x11.display,\n                             sr, monitor->x11.crtc,\n                             CurrentTime,\n                             ci->x, ci->y,\n                             native,\n                             ci->rotation,\n                             ci->outputs,\n                             ci->noutput);\n        }\n\n        XRRFreeOutputInfo(oi);\n        XRRFreeCrtcInfo(ci);\n        XRRFreeScreenResources(sr);\n\n        if (!native)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: Monitor mode list changed\");\n            return GL_FALSE;\n        }\n    }\n\n    return GL_TRUE;\n}\n\n// Restore the saved (original) video mode for the specified monitor\n//\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)\n    {\n        XRRScreenResources* sr;\n        XRRCrtcInfo* ci;\n\n        if (monitor->x11.oldMode == None)\n            return;\n\n        sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);\n        ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);\n\n        XRRSetCrtcConfig(_glfw.x11.display,\n                         sr, monitor->x11.crtc,\n                         CurrentTime,\n                         ci->x, ci->y,\n                         monitor->x11.oldMode,\n                         ci->rotation,\n                         ci->outputs,\n                         ci->noutput);\n\n        XRRFreeCrtcInfo(ci);\n        XRRFreeScreenResources(sr);\n\n        monitor->x11.oldMode = None;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n_GLFWmonitor** _glfwPlatformGetMonitors(int* count)\n{\n    int i, j, k, found = 0;\n    _GLFWmonitor** monitors = NULL;\n\n    *count = 0;\n\n    if (_glfw.x11.randr.available)\n    {\n        int screenCount = 0;\n        XineramaScreenInfo* screens = NULL;\n        XRRScreenResources* sr = XRRGetScreenResources(_glfw.x11.display,\n                                                       _glfw.x11.root);\n        RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,\n                                               _glfw.x11.root);\n\n        monitors = calloc(sr->noutput, sizeof(_GLFWmonitor*));\n\n        if (_glfw.x11.xinerama.available)\n            screens = XineramaQueryScreens(_glfw.x11.display, &screenCount);\n\n        for (i = 0;  i < sr->ncrtc;  i++)\n        {\n            XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display,\n                                             sr, sr->crtcs[i]);\n\n            for (j = 0;  j < ci->noutput;  j++)\n            {\n                int widthMM, heightMM;\n                _GLFWmonitor* monitor;\n                XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display,\n                                                     sr, ci->outputs[j]);\n                if (oi->connection != RR_Connected)\n                {\n                    XRRFreeOutputInfo(oi);\n                    continue;\n                }\n\n                if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)\n                {\n                    widthMM  = oi->mm_height;\n                    heightMM = oi->mm_width;\n                }\n                else\n                {\n                    widthMM  = oi->mm_width;\n                    heightMM = oi->mm_height;\n                }\n\n                monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);\n                monitor->x11.output = ci->outputs[j];\n                monitor->x11.crtc   = oi->crtc;\n\n                for (k = 0;  k < screenCount;  k++)\n                {\n                    if (screens[k].x_org == ci->x &&\n                        screens[k].y_org == ci->y &&\n                        screens[k].width == ci->width &&\n                        screens[k].height == ci->height)\n                    {\n                        monitor->x11.index = k;\n                        break;\n                    }\n                }\n\n                XRRFreeOutputInfo(oi);\n\n                found++;\n                monitors[found - 1] = monitor;\n\n                if (ci->outputs[j] == primary)\n                    _GLFW_SWAP_POINTERS(monitors[0], monitors[found - 1]);\n            }\n\n            XRRFreeCrtcInfo(ci);\n        }\n\n        XRRFreeScreenResources(sr);\n\n        if (screens)\n            XFree(screens);\n\n        if (found == 0)\n        {\n            _glfwInputError(GLFW_PLATFORM_ERROR,\n                            \"X11: RandR monitor support seems broken\");\n\n            _glfw.x11.randr.monitorBroken = GL_TRUE;\n            free(monitors);\n            monitors = NULL;\n        }\n    }\n\n    if (!monitors)\n    {\n        monitors = calloc(1, sizeof(_GLFWmonitor*));\n        monitors[0] = _glfwAllocMonitor(\"Display\",\n                                        DisplayWidthMM(_glfw.x11.display,\n                                                       _glfw.x11.screen),\n                                        DisplayHeightMM(_glfw.x11.display,\n                                                        _glfw.x11.screen));\n        found = 1;\n    }\n\n    *count = found;\n    return monitors;\n}\n\nGLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)\n{\n    return first->x11.crtc == second->x11.crtc;\n}\n\nvoid _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)\n    {\n        XRRScreenResources* sr;\n        XRRCrtcInfo* ci;\n\n        sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);\n        ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);\n\n        if (xpos)\n            *xpos = ci->x;\n        if (ypos)\n            *ypos = ci->y;\n\n        XRRFreeCrtcInfo(ci);\n        XRRFreeScreenResources(sr);\n    }\n}\n\nGLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)\n{\n    GLFWvidmode* result;\n\n    *count = 0;\n\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)\n    {\n        int i, j;\n        XRRScreenResources* sr;\n        XRRCrtcInfo* ci;\n        XRROutputInfo* oi;\n\n        sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);\n        ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);\n        oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);\n\n        result = calloc(oi->nmode, sizeof(GLFWvidmode));\n\n        for (i = 0;  i < oi->nmode;  i++)\n        {\n            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);\n            if (!modeIsGood(mi))\n                continue;\n\n            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);\n\n            for (j = 0;  j < *count;  j++)\n            {\n                if (_glfwCompareVideoModes(result + j, &mode) == 0)\n                    break;\n            }\n\n            // Skip duplicate modes\n            if (j < *count)\n                continue;\n\n            (*count)++;\n            result[*count - 1] = mode;\n        }\n\n        XRRFreeOutputInfo(oi);\n        XRRFreeCrtcInfo(ci);\n        XRRFreeScreenResources(sr);\n    }\n    else\n    {\n        *count = 1;\n        result = calloc(1, sizeof(GLFWvidmode));\n        _glfwPlatformGetVideoMode(monitor, result);\n    }\n\n    return result;\n}\n\nvoid _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)\n    {\n        XRRScreenResources* sr;\n        XRRCrtcInfo* ci;\n\n        sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);\n        ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);\n\n        *mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);\n\n        XRRFreeCrtcInfo(ci);\n        XRRFreeScreenResources(sr);\n    }\n    else\n    {\n        mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);\n        mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);\n        mode->refreshRate = 0;\n\n        _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),\n                      &mode->redBits, &mode->greenBits, &mode->blueBits);\n    }\n}\n\nvoid _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)\n    {\n        const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,\n                                                monitor->x11.crtc);\n        XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,\n                                              monitor->x11.crtc);\n\n        _glfwAllocGammaArrays(ramp, size);\n\n        memcpy(ramp->red, gamma->red, size * sizeof(unsigned short));\n        memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));\n        memcpy(ramp->blue, gamma->blue, size * sizeof(unsigned short));\n\n        XRRFreeGamma(gamma);\n    }\n#if defined(_GLFW_HAS_XF86VM)\n    else if (_glfw.x11.vidmode.available)\n    {\n        int size;\n        XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);\n\n        _glfwAllocGammaArrays(ramp, size);\n\n        XF86VidModeGetGammaRamp(_glfw.x11.display,\n                                _glfw.x11.screen,\n                                ramp->size, ramp->red, ramp->green, ramp->blue);\n    }\n#endif /*_GLFW_HAS_XF86VM*/\n}\n\nvoid _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)\n{\n    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)\n    {\n        XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size);\n\n        memcpy(gamma->red, ramp->red, ramp->size * sizeof(unsigned short));\n        memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short));\n        memcpy(gamma->blue, ramp->blue, ramp->size * sizeof(unsigned short));\n\n        XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);\n        XRRFreeGamma(gamma);\n    }\n#if defined(_GLFW_HAS_XF86VM)\n    else if (_glfw.x11.vidmode.available)\n    {\n        XF86VidModeSetGammaRamp(_glfw.x11.display,\n                                _glfw.x11.screen,\n                                ramp->size,\n                                (unsigned short*) ramp->red,\n                                (unsigned short*) ramp->green,\n                                (unsigned short*) ramp->blue);\n    }\n#endif /*_GLFW_HAS_XF86VM*/\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(None);\n    return monitor->x11.crtc;\n}\n\nGLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)\n{\n    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(None);\n    return monitor->x11.output;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/x11_platform.h",
    "content": "//========================================================================\n// GLFW 3.1 X11 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_x11_platform_h_\n#define _glfw3_x11_platform_h_\n\n#include <unistd.h>\n#include <signal.h>\n#include <stdint.h>\n\n#include <X11/Xlib.h>\n#include <X11/keysym.h>\n#include <X11/Xatom.h>\n#include <X11/Xcursor/Xcursor.h>\n\n// The XRandR extension provides mode setting and gamma control\n#include <X11/extensions/Xrandr.h>\n\n// The Xkb extension provides improved keyboard support\n#include <X11/XKBlib.h>\n\n// The Xinerama extension provides legacy monitor indices\n#include <X11/extensions/Xinerama.h>\n\n#if defined(_GLFW_HAS_XINPUT)\n // The XInput2 extension provides improved input events\n #include <X11/extensions/XInput2.h>\n#endif\n\n#if defined(_GLFW_HAS_XF86VM)\n // The Xf86VidMode extension provides fallback gamma control\n #include <X11/extensions/xf86vmode.h>\n#endif\n\n#include \"posix_tls.h\"\n#include \"posix_time.h\"\n#include \"linux_joystick.h\"\n#include \"xkb_unicode.h\"\n\n#if defined(_GLFW_GLX)\n #define _GLFW_X11_CONTEXT_VISUAL window->glx.visual\n #include \"glx_context.h\"\n#elif defined(_GLFW_EGL)\n #define _GLFW_X11_CONTEXT_VISUAL window->egl.visual\n #define _GLFW_EGL_NATIVE_WINDOW  window->x11.handle\n #define _GLFW_EGL_NATIVE_DISPLAY _glfw.x11.display\n #include \"egl_context.h\"\n#else\n #error \"No supported context creation API selected\"\n#endif\n\n#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowX11  x11\n#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11\n#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorX11 x11\n#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorX11  x11\n\n\n// X11-specific per-window data\n//\ntypedef struct _GLFWwindowX11\n{\n    Colormap        colormap;\n    Window          handle;\n    XIC             ic;\n\n    // Cached position and size used to filter out duplicate events\n    int             width, height;\n    int             xpos, ypos;\n\n    // The last received cursor position, regardless of source\n    double          cursorPosX, cursorPosY;\n    // The last position the cursor was warped to by GLFW\n    int             warpPosX, warpPosY;\n\n    // The information from the last KeyPress event\n    struct {\n        unsigned int keycode;\n        Time         time;\n    } last;\n\n} _GLFWwindowX11;\n\n\n// X11-specific global data\n//\ntypedef struct _GLFWlibraryX11\n{\n    Display*        display;\n    int             screen;\n    Window          root;\n\n    // Invisible cursor for hidden cursor mode\n    Cursor          cursor;\n    // Context for mapping window XIDs to _GLFWwindow pointers\n    XContext        context;\n    // XIM input method\n    XIM             im;\n    // Most recent error code received by X error handler\n    int             errorCode;\n    // Clipboard string (while the selection is owned)\n    char*           clipboardString;\n    // X11 keycode to GLFW key LUT\n    short int       publicKeys[256];\n\n    // Window manager atoms\n    Atom            WM_PROTOCOLS;\n    Atom            WM_STATE;\n    Atom            WM_DELETE_WINDOW;\n    Atom            NET_WM_NAME;\n    Atom            NET_WM_ICON_NAME;\n    Atom            NET_WM_PID;\n    Atom            NET_WM_PING;\n    Atom            NET_WM_STATE;\n    Atom            NET_WM_STATE_ABOVE;\n    Atom            NET_WM_STATE_FULLSCREEN;\n    Atom            NET_WM_BYPASS_COMPOSITOR;\n    Atom            NET_WM_FULLSCREEN_MONITORS;\n    Atom            NET_ACTIVE_WINDOW;\n    Atom            NET_FRAME_EXTENTS;\n    Atom            NET_REQUEST_FRAME_EXTENTS;\n    Atom            MOTIF_WM_HINTS;\n\n    // Xdnd (drag and drop) atoms\n    Atom            XdndAware;\n    Atom            XdndEnter;\n    Atom            XdndPosition;\n    Atom            XdndStatus;\n    Atom            XdndActionCopy;\n    Atom            XdndDrop;\n    Atom            XdndLeave;\n    Atom            XdndFinished;\n    Atom            XdndSelection;\n\n    // Selection (clipboard) atoms\n    Atom            TARGETS;\n    Atom            MULTIPLE;\n    Atom            CLIPBOARD;\n    Atom            CLIPBOARD_MANAGER;\n    Atom            SAVE_TARGETS;\n    Atom            NULL_;\n    Atom            UTF8_STRING;\n    Atom            COMPOUND_STRING;\n    Atom            ATOM_PAIR;\n    Atom            GLFW_SELECTION;\n\n    struct {\n        GLboolean   available;\n        int         eventBase;\n        int         errorBase;\n        int         major;\n        int         minor;\n        GLboolean   gammaBroken;\n        GLboolean   monitorBroken;\n    } randr;\n\n    struct {\n        GLboolean   available;\n        GLboolean   detectable;\n        int         majorOpcode;\n        int         eventBase;\n        int         errorBase;\n        int         major;\n        int         minor;\n    } xkb;\n\n    struct {\n        int         count;\n        int         timeout;\n        int         interval;\n        int         blanking;\n        int         exposure;\n    } saver;\n\n    struct {\n        Window      source;\n    } xdnd;\n\n    struct {\n        GLboolean   available;\n        int         major;\n        int         minor;\n    } xinerama;\n\n#if defined(_GLFW_HAS_XINPUT)\n    struct {\n        GLboolean   available;\n        int         majorOpcode;\n        int         eventBase;\n        int         errorBase;\n        int         major;\n        int         minor;\n    } xi;\n#endif /*_GLFW_HAS_XINPUT*/\n\n#if defined(_GLFW_HAS_XF86VM)\n    struct {\n        GLboolean   available;\n        int         eventBase;\n        int         errorBase;\n    } vidmode;\n#endif /*_GLFW_HAS_XF86VM*/\n\n} _GLFWlibraryX11;\n\n\n// X11-specific per-monitor data\n//\ntypedef struct _GLFWmonitorX11\n{\n    RROutput        output;\n    RRCrtc          crtc;\n    RRMode          oldMode;\n\n    // Index of corresponding Xinerama screen,\n    // for EWMH full screen window placement\n    int             index;\n\n} _GLFWmonitorX11;\n\n\n// X11-specific per-cursor data\n//\ntypedef struct _GLFWcursorX11\n{\n    Cursor handle;\n\n} _GLFWcursorX11;\n\n\nGLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);\nvoid _glfwRestoreVideoMode(_GLFWmonitor* monitor);\n\nCursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);\n\nunsigned long _glfwGetWindowProperty(Window window,\n                                     Atom property,\n                                     Atom type,\n                                     unsigned char** value);\n\nvoid _glfwGrabXErrorHandler(void);\nvoid _glfwReleaseXErrorHandler(void);\nvoid _glfwInputXError(int error, const char* message);\n\n#endif // _glfw3_x11_platform_h_\n"
  },
  {
    "path": "deps/glfw/src/x11_window.c",
    "content": "//========================================================================\n// GLFW 3.1 X11 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n#include <X11/cursorfont.h>\n#include <X11/Xmd.h>\n\n#include <sys/select.h>\n\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <errno.h>\n#include <assert.h>\n\n// Action for EWMH client messages\n#define _NET_WM_STATE_REMOVE        0\n#define _NET_WM_STATE_ADD           1\n#define _NET_WM_STATE_TOGGLE        2\n\n// Additional mouse button names for XButtonEvent\n#define Button6            6\n#define Button7            7\n\n\n// Wait for data to arrive\n//\nvoid selectDisplayConnection(struct timeval* timeout)\n{\n    fd_set fds;\n    int result;\n    const int fd = ConnectionNumber(_glfw.x11.display);\n\n    FD_ZERO(&fds);\n    FD_SET(fd, &fds);\n\n    // NOTE: We use select instead of an X function like XNextEvent, as the\n    //       wait inside those are guarded by the mutex protecting the display\n    //       struct, locking out other threads from using X (including GLX)\n    // NOTE: Only retry on EINTR if there is no timeout, as select is not\n    //       required to update it for the time elapsed\n    // TODO: Update timeout value manually\n    do\n    {\n        result = select(fd + 1, &fds, NULL, NULL, timeout);\n    }\n    while (result == -1 && errno == EINTR && timeout == NULL);\n}\n\n// Returns whether the window is iconified\n//\nstatic int getWindowState(_GLFWwindow* window)\n{\n    int result = WithdrawnState;\n    struct {\n        CARD32 state;\n        Window icon;\n    } *state = NULL;\n\n    if (_glfwGetWindowProperty(window->x11.handle,\n                               _glfw.x11.WM_STATE,\n                               _glfw.x11.WM_STATE,\n                               (unsigned char**) &state) >= 2)\n    {\n        result = state->state;\n    }\n\n    XFree(state);\n    return result;\n}\n\n// Returns whether the event is a selection event\n//\nstatic Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)\n{\n    _GLFWwindow* window = (_GLFWwindow*) pointer;\n    return event->type == PropertyNotify &&\n           event->xproperty.state == PropertyNewValue &&\n           event->xproperty.window == window->x11.handle &&\n           event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;\n}\n\n// Translates a GLFW standard cursor to a font cursor shape\n//\nstatic int translateCursorShape(int shape)\n{\n    switch (shape)\n    {\n        case GLFW_ARROW_CURSOR:\n            return XC_left_ptr;\n        case GLFW_IBEAM_CURSOR:\n            return XC_xterm;\n        case GLFW_CROSSHAIR_CURSOR:\n            return XC_crosshair;\n        case GLFW_HAND_CURSOR:\n            return XC_hand1;\n        case GLFW_HRESIZE_CURSOR:\n            return XC_sb_h_double_arrow;\n        case GLFW_VRESIZE_CURSOR:\n            return XC_sb_v_double_arrow;\n    }\n\n    return 0;\n}\n\n// Translates an X event modifier state mask\n//\nstatic int translateState(int state)\n{\n    int mods = 0;\n\n    if (state & ShiftMask)\n        mods |= GLFW_MOD_SHIFT;\n    if (state & ControlMask)\n        mods |= GLFW_MOD_CONTROL;\n    if (state & Mod1Mask)\n        mods |= GLFW_MOD_ALT;\n    if (state & Mod4Mask)\n        mods |= GLFW_MOD_SUPER;\n\n    return mods;\n}\n\n// Translates an X11 key code to a GLFW key token\n//\nstatic int translateKey(int scancode)\n{\n    // Use the pre-filled LUT (see createKeyTables() in x11_init.c)\n    if (scancode < 0 || scancode > 255)\n        return GLFW_KEY_UNKNOWN;\n\n    return _glfw.x11.publicKeys[scancode];\n}\n\n// Return the GLFW window corresponding to the specified X11 window\n//\nstatic _GLFWwindow* findWindowByHandle(Window handle)\n{\n    _GLFWwindow* window;\n\n    if (XFindContext(_glfw.x11.display,\n                     handle,\n                     _glfw.x11.context,\n                     (XPointer*) &window) != 0)\n    {\n        return NULL;\n    }\n\n    return window;\n}\n\n// Sends an EWMH or ICCCM event to the window manager\n//\nstatic void sendEventToWM(_GLFWwindow* window, Atom type,\n                          long a, long b, long c, long d, long e)\n{\n    XEvent event;\n    memset(&event, 0, sizeof(event));\n\n    event.type = ClientMessage;\n    event.xclient.window = window->x11.handle;\n    event.xclient.format = 32; // Data is 32-bit longs\n    event.xclient.message_type = type;\n    event.xclient.data.l[0] = a;\n    event.xclient.data.l[1] = b;\n    event.xclient.data.l[2] = c;\n    event.xclient.data.l[3] = d;\n    event.xclient.data.l[4] = e;\n\n    XSendEvent(_glfw.x11.display, _glfw.x11.root,\n               False,\n               SubstructureNotifyMask | SubstructureRedirectMask,\n               &event);\n}\n\n// Splits and translates a text/uri-list into separate file paths\n// NOTE: This function destroys the provided string\n//\nstatic char** parseUriList(char* text, int* count)\n{\n    const char* prefix = \"file://\";\n    char** paths = NULL;\n    char* line;\n\n    *count = 0;\n\n    while ((line = strtok(text, \"\\r\\n\")))\n    {\n        text = NULL;\n\n        if (line[0] == '#')\n            continue;\n\n        if (strncmp(line, prefix, strlen(prefix)) == 0)\n            line += strlen(prefix);\n\n        (*count)++;\n\n        char* path = calloc(strlen(line) + 1, 1);\n        paths = realloc(paths, *count * sizeof(char*));\n        paths[*count - 1] = path;\n\n        while (*line)\n        {\n            if (line[0] == '%' && line[1] && line[2])\n            {\n                const char digits[3] = { line[1], line[2], '\\0' };\n                *path = strtol(digits, NULL, 16);\n                line += 2;\n            }\n            else\n                *path = *line;\n\n            path++;\n            line++;\n        }\n    }\n\n    return paths;\n}\n\n// Create the X11 window (and its colormap)\n//\nstatic GLboolean createWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig)\n{\n    unsigned long wamask;\n    XSetWindowAttributes wa;\n    XVisualInfo* vi = _GLFW_X11_CONTEXT_VISUAL;\n\n    // Every window needs a colormap\n    // Create one based on the visual used by the current context\n    // TODO: Decouple this from context creation\n\n    window->x11.colormap = XCreateColormap(_glfw.x11.display,\n                                           _glfw.x11.root,\n                                           vi->visual,\n                                           AllocNone);\n\n    // Create the actual window\n    {\n        wamask = CWBorderPixel | CWColormap | CWEventMask;\n\n        wa.colormap = window->x11.colormap;\n        wa.border_pixel = 0;\n        wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |\n                        PointerMotionMask | ButtonPressMask | ButtonReleaseMask |\n                        ExposureMask | FocusChangeMask | VisibilityChangeMask |\n                        EnterWindowMask | LeaveWindowMask | PropertyChangeMask;\n\n        _glfwGrabXErrorHandler();\n\n        window->x11.handle = XCreateWindow(_glfw.x11.display,\n                                           _glfw.x11.root,\n                                           0, 0,\n                                           wndconfig->width, wndconfig->height,\n                                           0,          // Border width\n                                           vi->depth,  // Color depth\n                                           InputOutput,\n                                           vi->visual,\n                                           wamask,\n                                           &wa);\n\n        _glfwReleaseXErrorHandler();\n\n        if (!window->x11.handle)\n        {\n            _glfwInputXError(GLFW_PLATFORM_ERROR,\n                             \"X11: Failed to create window\");\n            return GL_FALSE;\n        }\n\n        XSaveContext(_glfw.x11.display,\n                     window->x11.handle,\n                     _glfw.x11.context,\n                     (XPointer) window);\n    }\n\n    if (wndconfig->monitor)\n    {\n        if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_FULLSCREEN)\n        {\n            // This is the butcher's way of removing window decorations\n            // Setting the override-redirect attribute on a window makes the\n            // window manager ignore the window completely (ICCCM, section 4)\n            // The good thing is that this makes undecorated full screen windows\n            // easy to do; the bad thing is that we have to do everything\n            // manually and some things (like iconify/restore) won't work at\n            // all, as those are tasks usually performed by the window manager\n\n            XSetWindowAttributes attributes;\n            attributes.override_redirect = True;\n            XChangeWindowAttributes(_glfw.x11.display,\n                                    window->x11.handle,\n                                    CWOverrideRedirect,\n                                    &attributes);\n        }\n    }\n    else\n    {\n        if (!wndconfig->decorated)\n        {\n            struct\n            {\n                unsigned long flags;\n                unsigned long functions;\n                unsigned long decorations;\n                long input_mode;\n                unsigned long status;\n            } hints;\n\n            hints.flags = 2;       // Set decorations\n            hints.decorations = 0; // No decorations\n\n            XChangeProperty(_glfw.x11.display, window->x11.handle,\n                            _glfw.x11.MOTIF_WM_HINTS,\n                            _glfw.x11.MOTIF_WM_HINTS, 32,\n                            PropModeReplace,\n                            (unsigned char*) &hints,\n                            sizeof(hints) / sizeof(long));\n        }\n\n        if (wndconfig->floating)\n        {\n            if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_ABOVE)\n            {\n                sendEventToWM(window,\n                              _glfw.x11.NET_WM_STATE,\n                              _NET_WM_STATE_ADD,\n                              _glfw.x11.NET_WM_STATE_ABOVE,\n                              0, 1, 0);\n            }\n        }\n    }\n\n\n    // Declare the WM protocols supported by GLFW\n    {\n        int count = 0;\n        Atom protocols[2];\n\n        // The WM_DELETE_WINDOW ICCCM protocol\n        // Basic window close notification protocol\n        if (_glfw.x11.WM_DELETE_WINDOW)\n            protocols[count++] = _glfw.x11.WM_DELETE_WINDOW;\n\n        // The _NET_WM_PING EWMH protocol\n        // Tells the WM to ping the GLFW window and flag the application as\n        // unresponsive if the WM doesn't get a reply within a few seconds\n        if (_glfw.x11.NET_WM_PING)\n            protocols[count++] = _glfw.x11.NET_WM_PING;\n\n        if (count > 0)\n        {\n            XSetWMProtocols(_glfw.x11.display, window->x11.handle,\n                            protocols, count);\n        }\n    }\n\n    if (_glfw.x11.NET_WM_PID)\n    {\n        const pid_t pid = getpid();\n\n        XChangeProperty(_glfw.x11.display,  window->x11.handle,\n                        _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,\n                        PropModeReplace,\n                        (unsigned char*) &pid, 1);\n    }\n\n    // Set ICCCM WM_HINTS property\n    {\n        XWMHints* hints = XAllocWMHints();\n        if (!hints)\n        {\n            _glfwInputError(GLFW_OUT_OF_MEMORY,\n                            \"X11: Failed to allocate WM hints\");\n            return GL_FALSE;\n        }\n\n        hints->flags = StateHint;\n        hints->initial_state = NormalState;\n\n        XSetWMHints(_glfw.x11.display, window->x11.handle, hints);\n        XFree(hints);\n    }\n\n    // Set ICCCM WM_NORMAL_HINTS property (even if no parts are set)\n    {\n        XSizeHints* hints = XAllocSizeHints();\n        hints->flags = 0;\n\n        if (wndconfig->monitor)\n        {\n            hints->flags |= PPosition;\n            _glfwPlatformGetMonitorPos(wndconfig->monitor, &hints->x, &hints->y);\n        }\n        else\n        {\n            // HACK: Explicitly setting PPosition to any value causes some WMs,\n            //       notably Compiz and Metacity, to honor the position of\n            //       unmapped windows set by XMoveWindow\n            hints->flags |= PPosition;\n            hints->x = hints->y = 0;\n        }\n\n        if (!wndconfig->resizable)\n        {\n            hints->flags |= (PMinSize | PMaxSize);\n            hints->min_width  = hints->max_width  = wndconfig->width;\n            hints->min_height = hints->max_height = wndconfig->height;\n        }\n\n        XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);\n        XFree(hints);\n    }\n\n    // Set ICCCM WM_CLASS property\n    // HACK: Until a mechanism for specifying the application name is added, the\n    //       initial window title is used as the window class name\n    if (strlen(wndconfig->title))\n    {\n        XClassHint* hint = XAllocClassHint();\n        hint->res_name = (char*) wndconfig->title;\n        hint->res_class = (char*) wndconfig->title;\n\n        XSetClassHint(_glfw.x11.display, window->x11.handle, hint);\n        XFree(hint);\n    }\n\n#if defined(_GLFW_HAS_XINPUT)\n    if (_glfw.x11.xi.available)\n    {\n        // Select for XInput2 events\n\n        XIEventMask eventmask;\n        unsigned char mask[] = { 0 };\n\n        eventmask.deviceid = 2;\n        eventmask.mask_len = sizeof(mask);\n        eventmask.mask = mask;\n        XISetMask(mask, XI_Motion);\n\n        XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1);\n    }\n#endif /*_GLFW_HAS_XINPUT*/\n\n    if (_glfw.x11.XdndAware)\n    {\n        // Announce support for Xdnd (drag and drop)\n        const Atom version = 5;\n        XChangeProperty(_glfw.x11.display, window->x11.handle,\n                        _glfw.x11.XdndAware, XA_ATOM, 32,\n                        PropModeReplace, (unsigned char*) &version, 1);\n    }\n\n    _glfwPlatformSetWindowTitle(window, wndconfig->title);\n\n    XRRSelectInput(_glfw.x11.display, window->x11.handle,\n                   RRScreenChangeNotifyMask);\n\n    if (_glfw.x11.im)\n    {\n        window->x11.ic = XCreateIC(_glfw.x11.im,\n                                   XNInputStyle,\n                                   XIMPreeditNothing | XIMStatusNothing,\n                                   XNClientWindow,\n                                   window->x11.handle,\n                                   XNFocusWindow,\n                                   window->x11.handle,\n                                   NULL);\n    }\n\n    _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);\n    _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);\n\n    return GL_TRUE;\n}\n\n// Hide the mouse cursor\n//\nstatic void hideCursor(_GLFWwindow* window)\n{\n    XUngrabPointer(_glfw.x11.display, CurrentTime);\n    XDefineCursor(_glfw.x11.display, window->x11.handle, _glfw.x11.cursor);\n}\n\n// Disable the mouse cursor\n//\nstatic void disableCursor(_GLFWwindow* window)\n{\n    XGrabPointer(_glfw.x11.display, window->x11.handle, True,\n                 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,\n                 GrabModeAsync, GrabModeAsync,\n                 window->x11.handle, _glfw.x11.cursor, CurrentTime);\n}\n\n// Restores the mouse cursor\n//\nstatic void restoreCursor(_GLFWwindow* window)\n{\n    XUngrabPointer(_glfw.x11.display, CurrentTime);\n\n    if (window->cursor)\n    {\n        XDefineCursor(_glfw.x11.display, window->x11.handle,\n                      window->cursor->x11.handle);\n    }\n    else\n        XUndefineCursor(_glfw.x11.display, window->x11.handle);\n}\n\n// Returns whether the event is a selection event\n//\nstatic Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)\n{\n    return event->type == SelectionRequest ||\n           event->type == SelectionNotify ||\n           event->type == SelectionClear;\n}\n\n// Set the specified property to the selection converted to the requested target\n//\nstatic Atom writeTargetToProperty(const XSelectionRequestEvent* request)\n{\n    int i;\n    const Atom formats[] = { _glfw.x11.UTF8_STRING,\n                             _glfw.x11.COMPOUND_STRING,\n                             XA_STRING };\n    const int formatCount = sizeof(formats) / sizeof(formats[0]);\n\n    if (request->property == None)\n    {\n        // The requester is a legacy client (ICCCM section 2.2)\n        // We don't support legacy clients, so fail here\n        return None;\n    }\n\n    if (request->target == _glfw.x11.TARGETS)\n    {\n        // The list of supported targets was requested\n\n        const Atom targets[] = { _glfw.x11.TARGETS,\n                                 _glfw.x11.MULTIPLE,\n                                 _glfw.x11.UTF8_STRING,\n                                 _glfw.x11.COMPOUND_STRING,\n                                 XA_STRING };\n\n        XChangeProperty(_glfw.x11.display,\n                        request->requestor,\n                        request->property,\n                        XA_ATOM,\n                        32,\n                        PropModeReplace,\n                        (unsigned char*) targets,\n                        sizeof(targets) / sizeof(targets[0]));\n\n        return request->property;\n    }\n\n    if (request->target == _glfw.x11.MULTIPLE)\n    {\n        // Multiple conversions were requested\n\n        Atom* targets;\n        unsigned long i, count;\n\n        count = _glfwGetWindowProperty(request->requestor,\n                                       request->property,\n                                       _glfw.x11.ATOM_PAIR,\n                                       (unsigned char**) &targets);\n\n        for (i = 0;  i < count;  i += 2)\n        {\n            int j;\n\n            for (j = 0;  j < formatCount;  j++)\n            {\n                if (targets[i] == formats[j])\n                    break;\n            }\n\n            if (j < formatCount)\n            {\n                XChangeProperty(_glfw.x11.display,\n                                request->requestor,\n                                targets[i + 1],\n                                targets[i],\n                                8,\n                                PropModeReplace,\n                                (unsigned char*) _glfw.x11.clipboardString,\n                                strlen(_glfw.x11.clipboardString));\n            }\n            else\n                targets[i + 1] = None;\n        }\n\n        XChangeProperty(_glfw.x11.display,\n                        request->requestor,\n                        request->property,\n                        _glfw.x11.ATOM_PAIR,\n                        32,\n                        PropModeReplace,\n                        (unsigned char*) targets,\n                        count);\n\n        XFree(targets);\n\n        return request->property;\n    }\n\n    if (request->target == _glfw.x11.SAVE_TARGETS)\n    {\n        // The request is a check whether we support SAVE_TARGETS\n        // It should be handled as a no-op side effect target\n\n        XChangeProperty(_glfw.x11.display,\n                        request->requestor,\n                        request->property,\n                        _glfw.x11.NULL_,\n                        32,\n                        PropModeReplace,\n                        NULL,\n                        0);\n\n        return request->property;\n    }\n\n    // Conversion to a data target was requested\n\n    for (i = 0;  i < formatCount;  i++)\n    {\n        if (request->target == formats[i])\n        {\n            // The requested target is one we support\n\n            XChangeProperty(_glfw.x11.display,\n                            request->requestor,\n                            request->property,\n                            request->target,\n                            8,\n                            PropModeReplace,\n                            (unsigned char*) _glfw.x11.clipboardString,\n                            strlen(_glfw.x11.clipboardString));\n\n            return request->property;\n        }\n    }\n\n    // The requested target is not supported\n\n    return None;\n}\n\nstatic void handleSelectionClear(XEvent* event)\n{\n    free(_glfw.x11.clipboardString);\n    _glfw.x11.clipboardString = NULL;\n}\n\nstatic void handleSelectionRequest(XEvent* event)\n{\n    const XSelectionRequestEvent* request = &event->xselectionrequest;\n\n    XEvent reply;\n    memset(&reply, 0, sizeof(reply));\n\n    reply.xselection.property = writeTargetToProperty(request);\n    reply.xselection.type = SelectionNotify;\n    reply.xselection.display = request->display;\n    reply.xselection.requestor = request->requestor;\n    reply.xselection.selection = request->selection;\n    reply.xselection.target = request->target;\n    reply.xselection.time = request->time;\n\n    XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);\n}\n\nstatic void pushSelectionToManager(_GLFWwindow* window)\n{\n    XConvertSelection(_glfw.x11.display,\n                      _glfw.x11.CLIPBOARD_MANAGER,\n                      _glfw.x11.SAVE_TARGETS,\n                      None,\n                      window->x11.handle,\n                      CurrentTime);\n\n    for (;;)\n    {\n        XEvent event;\n\n        while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))\n        {\n            switch (event.type)\n            {\n                case SelectionRequest:\n                    handleSelectionRequest(&event);\n                    break;\n\n                case SelectionClear:\n                    handleSelectionClear(&event);\n                    break;\n\n                case SelectionNotify:\n                {\n                    if (event.xselection.target == _glfw.x11.SAVE_TARGETS)\n                    {\n                        // This means one of two things; either the selection was\n                        // not owned, which means there is no clipboard manager, or\n                        // the transfer to the clipboard manager has completed\n                        // In either case, it means we are done here\n                        return;\n                    }\n\n                    break;\n                }\n            }\n        }\n\n        selectDisplayConnection(NULL);\n    }\n}\n\n// Enter full screen mode\n//\nstatic void enterFullscreenMode(_GLFWwindow* window)\n{\n    if (_glfw.x11.saver.count == 0)\n    {\n        // Remember old screen saver settings\n        XGetScreenSaver(_glfw.x11.display,\n                        &_glfw.x11.saver.timeout,\n                        &_glfw.x11.saver.interval,\n                        &_glfw.x11.saver.blanking,\n                        &_glfw.x11.saver.exposure);\n\n        // Disable screen saver\n        XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,\n                        DefaultExposures);\n    }\n\n    _glfw.x11.saver.count++;\n\n    _glfwSetVideoMode(window->monitor, &window->videoMode);\n\n    if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)\n    {\n        const unsigned long value = 1;\n\n        XChangeProperty(_glfw.x11.display,  window->x11.handle,\n                        _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,\n                        PropModeReplace, (unsigned char*) &value, 1);\n    }\n\n    // Position the window over its monitor\n    {\n        int xpos, ypos;\n        GLFWvidmode mode;\n\n        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);\n        _glfwPlatformGetVideoMode(window->monitor, &mode);\n\n        XMoveResizeWindow(_glfw.x11.display, window->x11.handle,\n                          xpos, ypos, mode.width, mode.height);\n    }\n\n    if (_glfw.x11.xinerama.available && _glfw.x11.NET_WM_FULLSCREEN_MONITORS)\n    {\n        sendEventToWM(window,\n                      _glfw.x11.NET_WM_FULLSCREEN_MONITORS,\n                      window->monitor->x11.index,\n                      window->monitor->x11.index,\n                      window->monitor->x11.index,\n                      window->monitor->x11.index,\n                      0);\n    }\n\n    if (_glfw.x11.NET_ACTIVE_WINDOW)\n    {\n        // Ask the window manager to raise and focus the GLFW window\n        // Only focused windows with the _NET_WM_STATE_FULLSCREEN state end up\n        // on top of all other windows (\"Stacking order\" in EWMH spec)\n        sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);\n    }\n    else\n    {\n        XRaiseWindow(_glfw.x11.display, window->x11.handle);\n        XSetInputFocus(_glfw.x11.display, window->x11.handle,\n                       RevertToParent, CurrentTime);\n    }\n\n    if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)\n    {\n        // Ask the window manager to make the GLFW window a full screen window\n        // Full screen windows are undecorated and, when focused, are kept\n        // on top of all other windows\n        sendEventToWM(window,\n                      _glfw.x11.NET_WM_STATE,\n                      _NET_WM_STATE_ADD,\n                      _glfw.x11.NET_WM_STATE_FULLSCREEN,\n                      0, 1, 0);\n    }\n}\n\n// Leave full screen mode\n//\nstatic void leaveFullscreenMode(_GLFWwindow* window)\n{\n    _glfwRestoreVideoMode(window->monitor);\n\n    _glfw.x11.saver.count--;\n\n    if (_glfw.x11.saver.count == 0)\n    {\n        // Restore old screen saver settings\n        XSetScreenSaver(_glfw.x11.display,\n                        _glfw.x11.saver.timeout,\n                        _glfw.x11.saver.interval,\n                        _glfw.x11.saver.blanking,\n                        _glfw.x11.saver.exposure);\n    }\n}\n\n// Decode a Unicode code point from a UTF-8 stream\n// Based on cutef8 by Jeff Bezanson (Public Domain)\n//\n#if defined(X_HAVE_UTF8_STRING)\nstatic unsigned int decodeUTF8(const char** s)\n{\n    unsigned int ch = 0, count = 0;\n    static const unsigned int offsets[] =\n    {\n        0x00000000u, 0x00003080u, 0x000e2080u,\n        0x03c82080u, 0xfa082080u, 0x82082080u\n    };\n\n    do\n    {\n        ch = (ch << 6) + (unsigned char) **s;\n        (*s)++;\n        count++;\n    } while ((**s & 0xc0) == 0x80);\n\n    assert(count <= 6);\n    return ch - offsets[count - 1];\n}\n#endif /*X_HAVE_UTF8_STRING*/\n\n// Process the specified X event\n//\nstatic void processEvent(XEvent *event)\n{\n    _GLFWwindow* window = NULL;\n    int keycode = 0;\n    Bool filtered = False;\n\n    // HACK: Save scancode as some IMs clear the field in XFilterEvent\n    if (event->type == KeyPress || event->type == KeyRelease)\n        keycode = event->xkey.keycode;\n\n    if (_glfw.x11.im)\n        filtered = XFilterEvent(event, None);\n\n    if (event->type != GenericEvent)\n    {\n        window = findWindowByHandle(event->xany.window);\n        if (window == NULL)\n        {\n            // This is an event for a window that has already been destroyed\n            return;\n        }\n    }\n\n    switch (event->type)\n    {\n        case KeyPress:\n        {\n            const int key = translateKey(keycode);\n            const int mods = translateState(event->xkey.state);\n            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));\n\n            if (window->x11.ic)\n            {\n                // HACK: Ignore duplicate key press events generated by ibus\n                //       Corresponding release events are filtered out by the\n                //       GLFW key repeat logic\n                if (window->x11.last.keycode != keycode ||\n                    window->x11.last.time != event->xkey.time)\n                {\n                    if (keycode)\n                        _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);\n                }\n\n                window->x11.last.keycode = keycode;\n                window->x11.last.time = event->xkey.time;\n\n                if (!filtered)\n                {\n                    int count;\n                    Status status;\n#if defined(X_HAVE_UTF8_STRING)\n                    char buffer[96];\n                    char* chars = buffer;\n\n                    count = Xutf8LookupString(window->x11.ic,\n                                              &event->xkey,\n                                              buffer, sizeof(buffer),\n                                              NULL, &status);\n\n                    if (status == XBufferOverflow)\n                    {\n                        chars = calloc(count, 1);\n                        count = Xutf8LookupString(window->x11.ic,\n                                                  &event->xkey,\n                                                  chars, count,\n                                                  NULL, &status);\n                    }\n\n                    if (status == XLookupChars || status == XLookupBoth)\n                    {\n                        const char* c = chars;\n                        while (c - chars < count)\n                            _glfwInputChar(window, decodeUTF8(&c), mods, plain);\n                    }\n#else\n                    wchar_t buffer[16];\n                    wchar_t* chars = buffer;\n\n                    count = XwcLookupString(window->x11.ic,\n                                            &event->xkey,\n                                            buffer, sizeof(buffer) / sizeof(wchar_t),\n                                            NULL, &status);\n\n                    if (status == XBufferOverflow)\n                    {\n                        chars = calloc(count, sizeof(wchar_t));\n                        count = XwcLookupString(window->x11.ic,\n                                                &event->xkey,\n                                                chars, count,\n                                                NULL, &status);\n                    }\n\n                    if (status == XLookupChars || status == XLookupBoth)\n                    {\n                        int i;\n                        for (i = 0;  i < count;  i++)\n                            _glfwInputChar(window, chars[i], mods, plain);\n                    }\n#endif\n\n                    if (chars != buffer)\n                        free(chars);\n                }\n            }\n            else\n            {\n                KeySym keysym;\n                XLookupString(&event->xkey, NULL, 0, &keysym, NULL);\n\n                _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);\n\n                const long character = _glfwKeySym2Unicode(keysym);\n                if (character != -1)\n                    _glfwInputChar(window, character, mods, plain);\n            }\n\n            return;\n        }\n\n        case KeyRelease:\n        {\n            const int key = translateKey(keycode);\n            const int mods = translateState(event->xkey.state);\n\n            if (!_glfw.x11.xkb.detectable)\n            {\n                // HACK: Key repeat events will arrive as KeyRelease/KeyPress\n                //       pairs with similar or identical time stamps\n                //       The key repeat logic in _glfwInputKey expects only key\n                //       presses to repeat, so detect and discard release events\n                if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))\n                {\n                    XEvent next;\n                    XPeekEvent(_glfw.x11.display, &next);\n\n                    if (next.type == KeyPress &&\n                        next.xkey.window == event->xkey.window &&\n                        next.xkey.keycode == keycode)\n                    {\n                        // HACK: Repeat events sometimes leak through due to\n                        //       some sort of time drift, so add an epsilon\n                        //       Toshiyuki Takahashi can press a button 16 times\n                        //       per second so it's fairly safe to assume that\n                        //       no human is pressing the key 50 times per\n                        //       second (value is ms)\n                        if ((next.xkey.time - event->xkey.time) < 20)\n                        {\n                            // This is very likely a server-generated key repeat\n                            // event, so ignore it\n                            return;\n                        }\n                    }\n                }\n            }\n\n            _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);\n            return;\n        }\n\n        case ButtonPress:\n        {\n            const int mods = translateState(event->xbutton.state);\n\n            if (event->xbutton.button == Button1)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);\n            else if (event->xbutton.button == Button2)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);\n            else if (event->xbutton.button == Button3)\n                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);\n\n            // Modern X provides scroll events as mouse button presses\n            else if (event->xbutton.button == Button4)\n                _glfwInputScroll(window, 0.0, 1.0);\n            else if (event->xbutton.button == Button5)\n                _glfwInputScroll(window, 0.0, -1.0);\n            else if (event->xbutton.button == Button6)\n                _glfwInputScroll(window, 1.0, 0.0);\n            else if (event->xbutton.button == Button7)\n                _glfwInputScroll(window, -1.0, 0.0);\n\n            else\n            {\n                // Additional buttons after 7 are treated as regular buttons\n                // We subtract 4 to fill the gap left by scroll input above\n                _glfwInputMouseClick(window,\n                                     event->xbutton.button - Button1 - 4,\n                                     GLFW_PRESS,\n                                     mods);\n            }\n\n            return;\n        }\n\n        case ButtonRelease:\n        {\n            const int mods = translateState(event->xbutton.state);\n\n            if (event->xbutton.button == Button1)\n            {\n                _glfwInputMouseClick(window,\n                                     GLFW_MOUSE_BUTTON_LEFT,\n                                     GLFW_RELEASE,\n                                     mods);\n            }\n            else if (event->xbutton.button == Button2)\n            {\n                _glfwInputMouseClick(window,\n                                     GLFW_MOUSE_BUTTON_MIDDLE,\n                                     GLFW_RELEASE,\n                                     mods);\n            }\n            else if (event->xbutton.button == Button3)\n            {\n                _glfwInputMouseClick(window,\n                                     GLFW_MOUSE_BUTTON_RIGHT,\n                                     GLFW_RELEASE,\n                                     mods);\n            }\n            else if (event->xbutton.button > Button7)\n            {\n                // Additional buttons after 7 are treated as regular buttons\n                // We subtract 4 to fill the gap left by scroll input above\n                _glfwInputMouseClick(window,\n                                     event->xbutton.button - Button1 - 4,\n                                     GLFW_RELEASE,\n                                     mods);\n            }\n\n            return;\n        }\n\n        case EnterNotify:\n        {\n            // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise\n            //       ignore the defined cursor for hidden cursor mode\n            if (window->cursorMode == GLFW_CURSOR_HIDDEN)\n                hideCursor(window);\n\n            _glfwInputCursorEnter(window, GL_TRUE);\n            return;\n        }\n\n        case LeaveNotify:\n        {\n            _glfwInputCursorEnter(window, GL_FALSE);\n            return;\n        }\n\n        case MotionNotify:\n        {\n            const int x = event->xmotion.x;\n            const int y = event->xmotion.y;\n\n            if (x != window->x11.warpPosX || y != window->x11.warpPosY)\n            {\n                // The cursor was moved by something other than GLFW\n\n                if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                {\n                    if (_glfw.cursorWindow != window)\n                        return;\n\n                    _glfwInputCursorMotion(window,\n                                           x - window->x11.cursorPosX,\n                                           y - window->x11.cursorPosY);\n                }\n                else\n                    _glfwInputCursorMotion(window, x, y);\n            }\n\n            window->x11.cursorPosX = x;\n            window->x11.cursorPosY = y;\n            return;\n        }\n\n        case ConfigureNotify:\n        {\n            if (event->xconfigure.width != window->x11.width ||\n                event->xconfigure.height != window->x11.height)\n            {\n                _glfwInputFramebufferSize(window,\n                                          event->xconfigure.width,\n                                          event->xconfigure.height);\n\n                _glfwInputWindowSize(window,\n                                     event->xconfigure.width,\n                                     event->xconfigure.height);\n\n                window->x11.width = event->xconfigure.width;\n                window->x11.height = event->xconfigure.height;\n            }\n\n            if (event->xconfigure.x != window->x11.xpos ||\n                event->xconfigure.y != window->x11.ypos)\n            {\n                _glfwInputWindowPos(window,\n                                    event->xconfigure.x,\n                                    event->xconfigure.y);\n\n                window->x11.xpos = event->xconfigure.x;\n                window->x11.ypos = event->xconfigure.y;\n            }\n\n            return;\n        }\n\n        case ClientMessage:\n        {\n            // Custom client message, probably from the window manager\n\n            if (filtered)\n                return;\n\n            if (event->xclient.message_type == None)\n                return;\n\n            if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)\n            {\n                const Atom protocol = event->xclient.data.l[0];\n                if (protocol == None)\n                    return;\n\n                if (protocol == _glfw.x11.WM_DELETE_WINDOW)\n                {\n                    // The window manager was asked to close the window, for example by\n                    // the user pressing a 'close' window decoration button\n                    _glfwInputWindowCloseRequest(window);\n                }\n                else if (protocol == _glfw.x11.NET_WM_PING)\n                {\n                    // The window manager is pinging the application to ensure it's\n                    // still responding to events\n\n                    XEvent reply = *event;\n                    reply.xclient.window = _glfw.x11.root;\n\n                    XSendEvent(_glfw.x11.display, _glfw.x11.root,\n                               False,\n                               SubstructureNotifyMask | SubstructureRedirectMask,\n                               &reply);\n                }\n            }\n            else if (event->xclient.message_type == _glfw.x11.XdndEnter)\n            {\n                // A drag operation has entered the window\n                // TODO: Check if UTF-8 string is supported by the source\n            }\n            else if (event->xclient.message_type == _glfw.x11.XdndDrop)\n            {\n                // The drag operation has finished dropping on\n                // the window, ask to convert it to a UTF-8 string\n                _glfw.x11.xdnd.source = event->xclient.data.l[0];\n                XConvertSelection(_glfw.x11.display,\n                                  _glfw.x11.XdndSelection,\n                                  _glfw.x11.UTF8_STRING,\n                                  _glfw.x11.XdndSelection,\n                                  window->x11.handle, CurrentTime);\n            }\n            else if (event->xclient.message_type == _glfw.x11.XdndPosition)\n            {\n                // The drag operation has moved over the window\n                const int absX = (event->xclient.data.l[2] >> 16) & 0xFFFF;\n                const int absY = (event->xclient.data.l[2]) & 0xFFFF;\n                int x, y;\n\n                _glfwPlatformGetWindowPos(window, &x, &y);\n                _glfwInputCursorMotion(window, absX - x, absY - y);\n\n                // Reply that we are ready to copy the dragged data\n                XEvent reply;\n                memset(&reply, 0, sizeof(reply));\n\n                reply.type = ClientMessage;\n                reply.xclient.window = event->xclient.data.l[0];\n                reply.xclient.message_type = _glfw.x11.XdndStatus;\n                reply.xclient.format = 32;\n                reply.xclient.data.l[0] = window->x11.handle;\n                reply.xclient.data.l[1] = 1; // Always accept the dnd with no rectangle\n                reply.xclient.data.l[2] = 0; // Specify an empty rectangle\n                reply.xclient.data.l[3] = 0;\n                reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;\n\n                XSendEvent(_glfw.x11.display, event->xclient.data.l[0],\n                           False, NoEventMask, &reply);\n                XFlush(_glfw.x11.display);\n            }\n\n            return;\n        }\n\n        case SelectionNotify:\n        {\n            if (event->xselection.property)\n            {\n                // The converted data from the drag operation has arrived\n                char* data;\n                const int result =\n                    _glfwGetWindowProperty(event->xselection.requestor,\n                                           event->xselection.property,\n                                           event->xselection.target,\n                                           (unsigned char**) &data);\n\n                if (result)\n                {\n                    int i, count;\n                    char** paths = parseUriList(data, &count);\n\n                    _glfwInputDrop(window, count, (const char**) paths);\n\n                    for (i = 0;  i < count;  i++)\n                        free(paths[i]);\n                    free(paths);\n                }\n\n                XFree(data);\n\n                XEvent reply;\n                memset(&reply, 0, sizeof(reply));\n\n                reply.type = ClientMessage;\n                reply.xclient.window = _glfw.x11.xdnd.source;\n                reply.xclient.message_type = _glfw.x11.XdndFinished;\n                reply.xclient.format = 32;\n                reply.xclient.data.l[0] = window->x11.handle;\n                reply.xclient.data.l[1] = result;\n                reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;\n\n                // Reply that all is well\n                XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,\n                           False, NoEventMask, &reply);\n                XFlush(_glfw.x11.display);\n            }\n\n            return;\n        }\n\n        case FocusIn:\n        {\n            if (event->xfocus.mode == NotifyGrab ||\n                event->xfocus.mode == NotifyUngrab)\n            {\n                // Ignore focus events from popup indicator windows, window menu\n                // key chords and window dragging\n                return;\n            }\n\n            if (window->x11.ic)\n                XSetICFocus(window->x11.ic);\n\n            if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                disableCursor(window);\n\n            _glfwInputWindowFocus(window, GL_TRUE);\n            return;\n        }\n\n        case FocusOut:\n        {\n            if (event->xfocus.mode == NotifyGrab ||\n                event->xfocus.mode == NotifyUngrab)\n            {\n                // Ignore focus events from popup indicator windows, window menu\n                // key chords and window dragging\n                return;\n            }\n\n            if (window->x11.ic)\n                XUnsetICFocus(window->x11.ic);\n\n            if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                restoreCursor(window);\n\n            if (window->monitor && window->autoIconify)\n                _glfwPlatformIconifyWindow(window);\n\n            _glfwInputWindowFocus(window, GL_FALSE);\n            return;\n        }\n\n        case Expose:\n        {\n            _glfwInputWindowDamage(window);\n            return;\n        }\n\n        case PropertyNotify:\n        {\n            if (event->xproperty.atom == _glfw.x11.WM_STATE &&\n                event->xproperty.state == PropertyNewValue)\n            {\n                const int state = getWindowState(window);\n                if (state == IconicState)\n                {\n                    if (window->monitor)\n                        leaveFullscreenMode(window);\n\n                    _glfwInputWindowIconify(window, GL_TRUE);\n                }\n                else if (state == NormalState)\n                {\n                    if (window->monitor)\n                        enterFullscreenMode(window);\n\n                    _glfwInputWindowIconify(window, GL_FALSE);\n                }\n            }\n\n            return;\n        }\n\n        case SelectionClear:\n        {\n            handleSelectionClear(event);\n            return;\n        }\n\n        case SelectionRequest:\n        {\n            handleSelectionRequest(event);\n            return;\n        }\n\n        case DestroyNotify:\n            return;\n\n#if defined(_GLFW_HAS_XINPUT)\n        case GenericEvent:\n        {\n            if (event->xcookie.extension == _glfw.x11.xi.majorOpcode &&\n                XGetEventData(_glfw.x11.display, &event->xcookie))\n            {\n                if (event->xcookie.evtype == XI_Motion)\n                {\n                    XIDeviceEvent* data = (XIDeviceEvent*) event->xcookie.data;\n\n                    window = findWindowByHandle(data->event);\n                    if (window)\n                    {\n                        if (data->event_x != window->x11.warpPosX ||\n                            data->event_y != window->x11.warpPosY)\n                        {\n                            // The cursor was moved by something other than GLFW\n\n                            double x, y;\n\n                            if (window->cursorMode == GLFW_CURSOR_DISABLED)\n                            {\n                                if (_glfw.cursorWindow != window)\n                                    return;\n\n                                x = data->event_x - window->x11.cursorPosX;\n                                y = data->event_y - window->x11.cursorPosY;\n                            }\n                            else\n                            {\n                                x = data->event_x;\n                                y = data->event_y;\n                            }\n\n                            _glfwInputCursorMotion(window, x, y);\n                        }\n\n                        window->x11.cursorPosX = data->event_x;\n                        window->x11.cursorPosY = data->event_y;\n                    }\n                }\n            }\n\n            XFreeEventData(_glfw.x11.display, &event->xcookie);\n            return;\n        }\n#endif /*_GLFW_HAS_XINPUT*/\n    }\n\n    if (event->type - _glfw.x11.randr.eventBase == RRScreenChangeNotify)\n    {\n        XRRUpdateConfiguration(event);\n        return;\n    }\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Retrieve a single window property of the specified type\n// Inspired by fghGetWindowProperty from freeglut\n//\nunsigned long _glfwGetWindowProperty(Window window,\n                                     Atom property,\n                                     Atom type,\n                                     unsigned char** value)\n{\n    Atom actualType;\n    int actualFormat;\n    unsigned long itemCount, bytesAfter;\n\n    XGetWindowProperty(_glfw.x11.display,\n                       window,\n                       property,\n                       0,\n                       LONG_MAX,\n                       False,\n                       type,\n                       &actualType,\n                       &actualFormat,\n                       &itemCount,\n                       &bytesAfter,\n                       value);\n\n    if (type != AnyPropertyType && actualType != type)\n        return 0;\n\n    return itemCount;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW platform API                      //////\n//////////////////////////////////////////////////////////////////////////\n\nint _glfwPlatformCreateWindow(_GLFWwindow* window,\n                              const _GLFWwndconfig* wndconfig,\n                              const _GLFWctxconfig* ctxconfig,\n                              const _GLFWfbconfig* fbconfig)\n{\n    if (!_glfwCreateContext(window, ctxconfig, fbconfig))\n        return GL_FALSE;\n\n    if (!createWindow(window, wndconfig))\n        return GL_FALSE;\n\n    if (wndconfig->monitor)\n    {\n        _glfwPlatformShowWindow(window);\n        enterFullscreenMode(window);\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyWindow(_GLFWwindow* window)\n{\n    if (window->monitor)\n        leaveFullscreenMode(window);\n\n    if (window->x11.ic)\n    {\n        XDestroyIC(window->x11.ic);\n        window->x11.ic = NULL;\n    }\n\n    _glfwDestroyContext(window);\n\n    if (window->x11.handle)\n    {\n        if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==\n            window->x11.handle)\n        {\n            pushSelectionToManager(window);\n        }\n\n        XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);\n        XUnmapWindow(_glfw.x11.display, window->x11.handle);\n        XDestroyWindow(_glfw.x11.display, window->x11.handle);\n        window->x11.handle = (Window) 0;\n    }\n\n    if (window->x11.colormap)\n    {\n        XFreeColormap(_glfw.x11.display, window->x11.colormap);\n        window->x11.colormap = (Colormap) 0;\n    }\n\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)\n{\n#if defined(X_HAVE_UTF8_STRING)\n    Xutf8SetWMProperties(_glfw.x11.display,\n                         window->x11.handle,\n                         title, title,\n                         NULL, 0,\n                         NULL, NULL, NULL);\n#else\n    // This may be a slightly better fallback than using XStoreName and\n    // XSetIconName, which always store their arguments using STRING\n    XmbSetWMProperties(_glfw.x11.display,\n                       window->x11.handle,\n                       title, title,\n                       NULL, 0,\n                       NULL, NULL, NULL);\n#endif\n\n    if (_glfw.x11.NET_WM_NAME)\n    {\n        XChangeProperty(_glfw.x11.display,  window->x11.handle,\n                        _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,\n                        PropModeReplace,\n                        (unsigned char*) title, strlen(title));\n    }\n\n    if (_glfw.x11.NET_WM_ICON_NAME)\n    {\n        XChangeProperty(_glfw.x11.display,  window->x11.handle,\n                        _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,\n                        PropModeReplace,\n                        (unsigned char*) title, strlen(title));\n    }\n\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)\n{\n    Window child;\n    int x, y;\n\n    XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,\n                          0, 0, &x, &y, &child);\n\n    if (child)\n    {\n        int left, top;\n        XTranslateCoordinates(_glfw.x11.display, window->x11.handle, child,\n                              0, 0, &left, &top, &child);\n\n        x -= left;\n        y -= top;\n    }\n\n    if (xpos)\n        *xpos = x;\n    if (ypos)\n        *ypos = y;\n}\n\nvoid _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)\n{\n    XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)\n{\n    XWindowAttributes attribs;\n    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);\n\n    if (width)\n        *width = attribs.width;\n    if (height)\n        *height = attribs.height;\n}\n\nvoid _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)\n{\n    if (window->monitor)\n    {\n        _glfwSetVideoMode(window->monitor, &window->videoMode);\n\n        if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_FULLSCREEN)\n        {\n            GLFWvidmode mode;\n            _glfwPlatformGetVideoMode(window->monitor, &mode);\n            XResizeWindow(_glfw.x11.display, window->x11.handle,\n                          mode.width, mode.height);\n        }\n    }\n    else\n    {\n        if (!window->resizable)\n        {\n            // Update window size restrictions to match new window size\n\n            XSizeHints* hints = XAllocSizeHints();\n\n            hints->flags |= (PMinSize | PMaxSize);\n            hints->min_width  = hints->max_width  = width;\n            hints->min_height = hints->max_height = height;\n\n            XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);\n            XFree(hints);\n        }\n\n        XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);\n    }\n\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)\n{\n    _glfwPlatformGetWindowSize(window, width, height);\n}\n\nvoid _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,\n                                     int* left, int* top,\n                                     int* right, int* bottom)\n{\n    long* extents = NULL;\n\n    if (_glfw.x11.NET_FRAME_EXTENTS == None)\n        return;\n\n    if (!_glfwPlatformWindowVisible(window) &&\n        _glfw.x11.NET_REQUEST_FRAME_EXTENTS)\n    {\n        double base;\n        XEvent event;\n\n        // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to\n        // function before the window is mapped\n        sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,\n                      0, 0, 0, 0, 0);\n\n        // HACK: Poll with timeout for the required reply instead of blocking\n        //       This is done because some window managers (at least Unity,\n        //       Fluxbox and Xfwm) failed to send the required reply\n        //       They have been fixed but broken versions are still in the wild\n        //       If you are affected by this and your window manager is NOT\n        //       listed above, PLEASE report it to their and our issue trackers\n        base = _glfwPlatformGetTime();\n        while (!XCheckIfEvent(_glfw.x11.display,\n                              &event,\n                              isFrameExtentsEvent,\n                              (XPointer) window))\n        {\n            double remaining;\n            struct timeval timeout;\n\n            remaining = 0.5 + base - _glfwPlatformGetTime();\n            if (remaining <= 0.0)\n            {\n                _glfwInputError(GLFW_PLATFORM_ERROR,\n                                \"X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue\");\n                return;\n            }\n\n            timeout.tv_sec = 0;\n            timeout.tv_usec = (long) (remaining * 1e6);\n            selectDisplayConnection(&timeout);\n        }\n    }\n\n    if (_glfwGetWindowProperty(window->x11.handle,\n                               _glfw.x11.NET_FRAME_EXTENTS,\n                               XA_CARDINAL,\n                               (unsigned char**) &extents) == 4)\n    {\n        if (left)\n            *left = extents[0];\n        if (top)\n            *top = extents[2];\n        if (right)\n            *right = extents[1];\n        if (bottom)\n            *bottom = extents[3];\n    }\n\n    if (extents)\n        XFree(extents);\n}\n\nvoid _glfwPlatformIconifyWindow(_GLFWwindow* window)\n{\n    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_FULLSCREEN)\n    {\n        // Override-redirect windows cannot be iconified or restored, as those\n        // tasks are performed by the window manager\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"X11: Iconification of full screen windows requires a WM that supports EWMH full screen\");\n        return;\n    }\n\n    XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformRestoreWindow(_GLFWwindow* window)\n{\n    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_FULLSCREEN)\n    {\n        // Override-redirect windows cannot be iconified or restored, as those\n        // tasks are performed by the window manager\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"X11: Iconification of full screen windows requires a WM that supports EWMH full screen\");\n        return;\n    }\n\n    XMapWindow(_glfw.x11.display, window->x11.handle);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformShowWindow(_GLFWwindow* window)\n{\n    XMapRaised(_glfw.x11.display, window->x11.handle);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformUnhideWindow(_GLFWwindow* window)\n{\n    XMapWindow(_glfw.x11.display, window->x11.handle);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformHideWindow(_GLFWwindow* window)\n{\n    XUnmapWindow(_glfw.x11.display, window->x11.handle);\n    XFlush(_glfw.x11.display);\n}\n\nint _glfwPlatformWindowFocused(_GLFWwindow* window)\n{\n    Window focused;\n    int state;\n\n    XGetInputFocus(_glfw.x11.display, &focused, &state);\n    return window->x11.handle == focused;\n}\n\nint _glfwPlatformWindowIconified(_GLFWwindow* window)\n{\n    return getWindowState(window) == IconicState;\n}\n\nint _glfwPlatformWindowVisible(_GLFWwindow* window)\n{\n    XWindowAttributes wa;\n    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);\n    return wa.map_state == IsViewable;\n}\n\nvoid _glfwPlatformPollEvents(void)\n{\n    int count = XPending(_glfw.x11.display);\n    while (count--)\n    {\n        XEvent event;\n        XNextEvent(_glfw.x11.display, &event);\n        processEvent(&event);\n    }\n\n    _GLFWwindow* window = _glfw.cursorWindow;\n    if (window && window->cursorMode == GLFW_CURSOR_DISABLED)\n    {\n        int width, height;\n        _glfwPlatformGetWindowSize(window, &width, &height);\n        _glfwPlatformSetCursorPos(window, width / 2, height / 2);\n    }\n}\n\nvoid _glfwPlatformWaitEvents(void)\n{\n    while (!XPending(_glfw.x11.display))\n        selectDisplayConnection(NULL);\n\n    _glfwPlatformPollEvents();\n}\n\nvoid _glfwPlatformPostEmptyEvent(void)\n{\n    XEvent event;\n    _GLFWwindow* window = _glfw.windowListHead;\n\n    memset(&event, 0, sizeof(event));\n    event.type = ClientMessage;\n    event.xclient.window = window->x11.handle;\n    event.xclient.format = 32; // Data is 32-bit longs\n    event.xclient.message_type = _glfw.x11.NULL_;\n\n    XSendEvent(_glfw.x11.display, window->x11.handle, False, 0, &event);\n    XFlush(_glfw.x11.display);\n}\n\nvoid _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)\n{\n    Window root, child;\n    int rootX, rootY, childX, childY;\n    unsigned int mask;\n\n    XQueryPointer(_glfw.x11.display, window->x11.handle,\n                  &root, &child,\n                  &rootX, &rootY, &childX, &childY,\n                  &mask);\n\n    if (xpos)\n        *xpos = childX;\n    if (ypos)\n        *ypos = childY;\n}\n\nvoid _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)\n{\n    // Store the new position so it can be recognized later\n    window->x11.warpPosX = (int) x;\n    window->x11.warpPosY = (int) y;\n\n    XWarpPointer(_glfw.x11.display, None, window->x11.handle,\n                 0,0,0,0, (int) x, (int) y);\n}\n\nvoid _glfwPlatformApplyCursorMode(_GLFWwindow* window)\n{\n    switch (window->cursorMode)\n    {\n        case GLFW_CURSOR_NORMAL:\n            restoreCursor(window);\n            break;\n        case GLFW_CURSOR_HIDDEN:\n            hideCursor(window);\n            break;\n        case GLFW_CURSOR_DISABLED:\n            disableCursor(window);\n            break;\n    }\n}\n\nint _glfwPlatformCreateCursor(_GLFWcursor* cursor,\n                              const GLFWimage* image,\n                              int xhot, int yhot)\n{\n    cursor->x11.handle = _glfwCreateCursor(image, xhot, yhot);\n    if (!cursor->x11.handle)\n        return GL_FALSE;\n\n    return GL_TRUE;\n}\n\nint _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)\n{\n    cursor->x11.handle = XCreateFontCursor(_glfw.x11.display,\n                                           translateCursorShape(shape));\n    if (!cursor->x11.handle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"X11: Failed to create standard cursor\");\n        return GL_FALSE;\n    }\n\n    return GL_TRUE;\n}\n\nvoid _glfwPlatformDestroyCursor(_GLFWcursor* cursor)\n{\n    if (cursor->x11.handle)\n        XFreeCursor(_glfw.x11.display, cursor->x11.handle);\n}\n\nvoid _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)\n{\n    if (window->cursorMode == GLFW_CURSOR_NORMAL)\n    {\n        if (cursor)\n            XDefineCursor(_glfw.x11.display, window->x11.handle, cursor->x11.handle);\n        else\n            XUndefineCursor(_glfw.x11.display, window->x11.handle);\n\n        XFlush(_glfw.x11.display);\n    }\n}\n\nvoid _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)\n{\n    free(_glfw.x11.clipboardString);\n    _glfw.x11.clipboardString = strdup(string);\n\n    XSetSelectionOwner(_glfw.x11.display,\n                       _glfw.x11.CLIPBOARD,\n                       window->x11.handle, CurrentTime);\n\n    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=\n        window->x11.handle)\n    {\n        _glfwInputError(GLFW_PLATFORM_ERROR,\n                        \"X11: Failed to become owner of clipboard selection\");\n    }\n}\n\nconst char* _glfwPlatformGetClipboardString(_GLFWwindow* window)\n{\n    size_t i;\n    const Atom formats[] = { _glfw.x11.UTF8_STRING,\n                             _glfw.x11.COMPOUND_STRING,\n                             XA_STRING };\n    const size_t formatCount = sizeof(formats) / sizeof(formats[0]);\n\n    if (findWindowByHandle(XGetSelectionOwner(_glfw.x11.display,\n                                              _glfw.x11.CLIPBOARD)))\n    {\n        // Instead of doing a large number of X round-trips just to put this\n        // string into a window property and then read it back, just return it\n        return _glfw.x11.clipboardString;\n    }\n\n    free(_glfw.x11.clipboardString);\n    _glfw.x11.clipboardString = NULL;\n\n    for (i = 0;  i < formatCount;  i++)\n    {\n        char* data;\n        XEvent event;\n\n        XConvertSelection(_glfw.x11.display,\n                          _glfw.x11.CLIPBOARD,\n                          formats[i],\n                          _glfw.x11.GLFW_SELECTION,\n                          window->x11.handle, CurrentTime);\n\n        // XCheckTypedEvent is used instead of XIfEvent in order not to lock\n        // other threads out from the display during the entire wait period\n        while (!XCheckTypedEvent(_glfw.x11.display, SelectionNotify, &event))\n            selectDisplayConnection(NULL);\n\n        if (event.xselection.property == None)\n            continue;\n\n        if (_glfwGetWindowProperty(event.xselection.requestor,\n                                   event.xselection.property,\n                                   event.xselection.target,\n                                   (unsigned char**) &data))\n        {\n            _glfw.x11.clipboardString = strdup(data);\n        }\n\n        XFree(data);\n\n        XDeleteProperty(_glfw.x11.display,\n                        event.xselection.requestor,\n                        event.xselection.property);\n\n        if (_glfw.x11.clipboardString)\n            break;\n    }\n\n    if (_glfw.x11.clipboardString == NULL)\n    {\n        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,\n                        \"X11: Failed to convert clipboard to string\");\n    }\n\n    return _glfw.x11.clipboardString;\n}\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                        GLFW native API                       //////\n//////////////////////////////////////////////////////////////////////////\n\nGLFWAPI Display* glfwGetX11Display(void)\n{\n    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);\n    return _glfw.x11.display;\n}\n\nGLFWAPI Window glfwGetX11Window(GLFWwindow* handle)\n{\n    _GLFWwindow* window = (_GLFWwindow*) handle;\n    _GLFW_REQUIRE_INIT_OR_RETURN(None);\n    return window->x11.handle;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/xkb_unicode.c",
    "content": "//========================================================================\n// GLFW 3.1 X11 - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2002-2006 Marcus Geelnard\n// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include \"internal.h\"\n\n\n/*\n * Marcus: This code was originally written by Markus G. Kuhn.\n * I have made some slight changes (trimmed it down a bit from >60 KB to\n * 20 KB), but the functionality is the same.\n */\n\n/*\n * This module converts keysym values into the corresponding ISO 10646\n * (UCS, Unicode) values.\n *\n * The array keysymtab[] contains pairs of X11 keysym values for graphical\n * characters and the corresponding Unicode value. The function\n * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary\n * search, therefore keysymtab[] must remain SORTED by keysym value.\n *\n * We allow to represent any UCS character in the range U-00000000 to\n * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.\n * This admittedly does not cover the entire 31-bit space of UCS, but\n * it does cover all of the characters up to U-10FFFF, which can be\n * represented by UTF-16, and more, and it is very unlikely that higher\n * UCS codes will ever be assigned by ISO. So to get Unicode character\n * U+ABCD you can directly use keysym 0x0100abcd.\n *\n * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of\n *                  Cambridge, April 2001\n *\n * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing\n * an initial draft of the mapping table.\n *\n */\n\n\n//************************************************************************\n//****                KeySym to Unicode mapping table                 ****\n//************************************************************************\n\nstatic const struct codepair {\n  unsigned short keysym;\n  unsigned short ucs;\n} keysymtab[] = {\n  { 0x01a1, 0x0104 },\n  { 0x01a2, 0x02d8 },\n  { 0x01a3, 0x0141 },\n  { 0x01a5, 0x013d },\n  { 0x01a6, 0x015a },\n  { 0x01a9, 0x0160 },\n  { 0x01aa, 0x015e },\n  { 0x01ab, 0x0164 },\n  { 0x01ac, 0x0179 },\n  { 0x01ae, 0x017d },\n  { 0x01af, 0x017b },\n  { 0x01b1, 0x0105 },\n  { 0x01b2, 0x02db },\n  { 0x01b3, 0x0142 },\n  { 0x01b5, 0x013e },\n  { 0x01b6, 0x015b },\n  { 0x01b7, 0x02c7 },\n  { 0x01b9, 0x0161 },\n  { 0x01ba, 0x015f },\n  { 0x01bb, 0x0165 },\n  { 0x01bc, 0x017a },\n  { 0x01bd, 0x02dd },\n  { 0x01be, 0x017e },\n  { 0x01bf, 0x017c },\n  { 0x01c0, 0x0154 },\n  { 0x01c3, 0x0102 },\n  { 0x01c5, 0x0139 },\n  { 0x01c6, 0x0106 },\n  { 0x01c8, 0x010c },\n  { 0x01ca, 0x0118 },\n  { 0x01cc, 0x011a },\n  { 0x01cf, 0x010e },\n  { 0x01d0, 0x0110 },\n  { 0x01d1, 0x0143 },\n  { 0x01d2, 0x0147 },\n  { 0x01d5, 0x0150 },\n  { 0x01d8, 0x0158 },\n  { 0x01d9, 0x016e },\n  { 0x01db, 0x0170 },\n  { 0x01de, 0x0162 },\n  { 0x01e0, 0x0155 },\n  { 0x01e3, 0x0103 },\n  { 0x01e5, 0x013a },\n  { 0x01e6, 0x0107 },\n  { 0x01e8, 0x010d },\n  { 0x01ea, 0x0119 },\n  { 0x01ec, 0x011b },\n  { 0x01ef, 0x010f },\n  { 0x01f0, 0x0111 },\n  { 0x01f1, 0x0144 },\n  { 0x01f2, 0x0148 },\n  { 0x01f5, 0x0151 },\n  { 0x01f8, 0x0159 },\n  { 0x01f9, 0x016f },\n  { 0x01fb, 0x0171 },\n  { 0x01fe, 0x0163 },\n  { 0x01ff, 0x02d9 },\n  { 0x02a1, 0x0126 },\n  { 0x02a6, 0x0124 },\n  { 0x02a9, 0x0130 },\n  { 0x02ab, 0x011e },\n  { 0x02ac, 0x0134 },\n  { 0x02b1, 0x0127 },\n  { 0x02b6, 0x0125 },\n  { 0x02b9, 0x0131 },\n  { 0x02bb, 0x011f },\n  { 0x02bc, 0x0135 },\n  { 0x02c5, 0x010a },\n  { 0x02c6, 0x0108 },\n  { 0x02d5, 0x0120 },\n  { 0x02d8, 0x011c },\n  { 0x02dd, 0x016c },\n  { 0x02de, 0x015c },\n  { 0x02e5, 0x010b },\n  { 0x02e6, 0x0109 },\n  { 0x02f5, 0x0121 },\n  { 0x02f8, 0x011d },\n  { 0x02fd, 0x016d },\n  { 0x02fe, 0x015d },\n  { 0x03a2, 0x0138 },\n  { 0x03a3, 0x0156 },\n  { 0x03a5, 0x0128 },\n  { 0x03a6, 0x013b },\n  { 0x03aa, 0x0112 },\n  { 0x03ab, 0x0122 },\n  { 0x03ac, 0x0166 },\n  { 0x03b3, 0x0157 },\n  { 0x03b5, 0x0129 },\n  { 0x03b6, 0x013c },\n  { 0x03ba, 0x0113 },\n  { 0x03bb, 0x0123 },\n  { 0x03bc, 0x0167 },\n  { 0x03bd, 0x014a },\n  { 0x03bf, 0x014b },\n  { 0x03c0, 0x0100 },\n  { 0x03c7, 0x012e },\n  { 0x03cc, 0x0116 },\n  { 0x03cf, 0x012a },\n  { 0x03d1, 0x0145 },\n  { 0x03d2, 0x014c },\n  { 0x03d3, 0x0136 },\n  { 0x03d9, 0x0172 },\n  { 0x03dd, 0x0168 },\n  { 0x03de, 0x016a },\n  { 0x03e0, 0x0101 },\n  { 0x03e7, 0x012f },\n  { 0x03ec, 0x0117 },\n  { 0x03ef, 0x012b },\n  { 0x03f1, 0x0146 },\n  { 0x03f2, 0x014d },\n  { 0x03f3, 0x0137 },\n  { 0x03f9, 0x0173 },\n  { 0x03fd, 0x0169 },\n  { 0x03fe, 0x016b },\n  { 0x047e, 0x203e },\n  { 0x04a1, 0x3002 },\n  { 0x04a2, 0x300c },\n  { 0x04a3, 0x300d },\n  { 0x04a4, 0x3001 },\n  { 0x04a5, 0x30fb },\n  { 0x04a6, 0x30f2 },\n  { 0x04a7, 0x30a1 },\n  { 0x04a8, 0x30a3 },\n  { 0x04a9, 0x30a5 },\n  { 0x04aa, 0x30a7 },\n  { 0x04ab, 0x30a9 },\n  { 0x04ac, 0x30e3 },\n  { 0x04ad, 0x30e5 },\n  { 0x04ae, 0x30e7 },\n  { 0x04af, 0x30c3 },\n  { 0x04b0, 0x30fc },\n  { 0x04b1, 0x30a2 },\n  { 0x04b2, 0x30a4 },\n  { 0x04b3, 0x30a6 },\n  { 0x04b4, 0x30a8 },\n  { 0x04b5, 0x30aa },\n  { 0x04b6, 0x30ab },\n  { 0x04b7, 0x30ad },\n  { 0x04b8, 0x30af },\n  { 0x04b9, 0x30b1 },\n  { 0x04ba, 0x30b3 },\n  { 0x04bb, 0x30b5 },\n  { 0x04bc, 0x30b7 },\n  { 0x04bd, 0x30b9 },\n  { 0x04be, 0x30bb },\n  { 0x04bf, 0x30bd },\n  { 0x04c0, 0x30bf },\n  { 0x04c1, 0x30c1 },\n  { 0x04c2, 0x30c4 },\n  { 0x04c3, 0x30c6 },\n  { 0x04c4, 0x30c8 },\n  { 0x04c5, 0x30ca },\n  { 0x04c6, 0x30cb },\n  { 0x04c7, 0x30cc },\n  { 0x04c8, 0x30cd },\n  { 0x04c9, 0x30ce },\n  { 0x04ca, 0x30cf },\n  { 0x04cb, 0x30d2 },\n  { 0x04cc, 0x30d5 },\n  { 0x04cd, 0x30d8 },\n  { 0x04ce, 0x30db },\n  { 0x04cf, 0x30de },\n  { 0x04d0, 0x30df },\n  { 0x04d1, 0x30e0 },\n  { 0x04d2, 0x30e1 },\n  { 0x04d3, 0x30e2 },\n  { 0x04d4, 0x30e4 },\n  { 0x04d5, 0x30e6 },\n  { 0x04d6, 0x30e8 },\n  { 0x04d7, 0x30e9 },\n  { 0x04d8, 0x30ea },\n  { 0x04d9, 0x30eb },\n  { 0x04da, 0x30ec },\n  { 0x04db, 0x30ed },\n  { 0x04dc, 0x30ef },\n  { 0x04dd, 0x30f3 },\n  { 0x04de, 0x309b },\n  { 0x04df, 0x309c },\n  { 0x05ac, 0x060c },\n  { 0x05bb, 0x061b },\n  { 0x05bf, 0x061f },\n  { 0x05c1, 0x0621 },\n  { 0x05c2, 0x0622 },\n  { 0x05c3, 0x0623 },\n  { 0x05c4, 0x0624 },\n  { 0x05c5, 0x0625 },\n  { 0x05c6, 0x0626 },\n  { 0x05c7, 0x0627 },\n  { 0x05c8, 0x0628 },\n  { 0x05c9, 0x0629 },\n  { 0x05ca, 0x062a },\n  { 0x05cb, 0x062b },\n  { 0x05cc, 0x062c },\n  { 0x05cd, 0x062d },\n  { 0x05ce, 0x062e },\n  { 0x05cf, 0x062f },\n  { 0x05d0, 0x0630 },\n  { 0x05d1, 0x0631 },\n  { 0x05d2, 0x0632 },\n  { 0x05d3, 0x0633 },\n  { 0x05d4, 0x0634 },\n  { 0x05d5, 0x0635 },\n  { 0x05d6, 0x0636 },\n  { 0x05d7, 0x0637 },\n  { 0x05d8, 0x0638 },\n  { 0x05d9, 0x0639 },\n  { 0x05da, 0x063a },\n  { 0x05e0, 0x0640 },\n  { 0x05e1, 0x0641 },\n  { 0x05e2, 0x0642 },\n  { 0x05e3, 0x0643 },\n  { 0x05e4, 0x0644 },\n  { 0x05e5, 0x0645 },\n  { 0x05e6, 0x0646 },\n  { 0x05e7, 0x0647 },\n  { 0x05e8, 0x0648 },\n  { 0x05e9, 0x0649 },\n  { 0x05ea, 0x064a },\n  { 0x05eb, 0x064b },\n  { 0x05ec, 0x064c },\n  { 0x05ed, 0x064d },\n  { 0x05ee, 0x064e },\n  { 0x05ef, 0x064f },\n  { 0x05f0, 0x0650 },\n  { 0x05f1, 0x0651 },\n  { 0x05f2, 0x0652 },\n  { 0x06a1, 0x0452 },\n  { 0x06a2, 0x0453 },\n  { 0x06a3, 0x0451 },\n  { 0x06a4, 0x0454 },\n  { 0x06a5, 0x0455 },\n  { 0x06a6, 0x0456 },\n  { 0x06a7, 0x0457 },\n  { 0x06a8, 0x0458 },\n  { 0x06a9, 0x0459 },\n  { 0x06aa, 0x045a },\n  { 0x06ab, 0x045b },\n  { 0x06ac, 0x045c },\n  { 0x06ae, 0x045e },\n  { 0x06af, 0x045f },\n  { 0x06b0, 0x2116 },\n  { 0x06b1, 0x0402 },\n  { 0x06b2, 0x0403 },\n  { 0x06b3, 0x0401 },\n  { 0x06b4, 0x0404 },\n  { 0x06b5, 0x0405 },\n  { 0x06b6, 0x0406 },\n  { 0x06b7, 0x0407 },\n  { 0x06b8, 0x0408 },\n  { 0x06b9, 0x0409 },\n  { 0x06ba, 0x040a },\n  { 0x06bb, 0x040b },\n  { 0x06bc, 0x040c },\n  { 0x06be, 0x040e },\n  { 0x06bf, 0x040f },\n  { 0x06c0, 0x044e },\n  { 0x06c1, 0x0430 },\n  { 0x06c2, 0x0431 },\n  { 0x06c3, 0x0446 },\n  { 0x06c4, 0x0434 },\n  { 0x06c5, 0x0435 },\n  { 0x06c6, 0x0444 },\n  { 0x06c7, 0x0433 },\n  { 0x06c8, 0x0445 },\n  { 0x06c9, 0x0438 },\n  { 0x06ca, 0x0439 },\n  { 0x06cb, 0x043a },\n  { 0x06cc, 0x043b },\n  { 0x06cd, 0x043c },\n  { 0x06ce, 0x043d },\n  { 0x06cf, 0x043e },\n  { 0x06d0, 0x043f },\n  { 0x06d1, 0x044f },\n  { 0x06d2, 0x0440 },\n  { 0x06d3, 0x0441 },\n  { 0x06d4, 0x0442 },\n  { 0x06d5, 0x0443 },\n  { 0x06d6, 0x0436 },\n  { 0x06d7, 0x0432 },\n  { 0x06d8, 0x044c },\n  { 0x06d9, 0x044b },\n  { 0x06da, 0x0437 },\n  { 0x06db, 0x0448 },\n  { 0x06dc, 0x044d },\n  { 0x06dd, 0x0449 },\n  { 0x06de, 0x0447 },\n  { 0x06df, 0x044a },\n  { 0x06e0, 0x042e },\n  { 0x06e1, 0x0410 },\n  { 0x06e2, 0x0411 },\n  { 0x06e3, 0x0426 },\n  { 0x06e4, 0x0414 },\n  { 0x06e5, 0x0415 },\n  { 0x06e6, 0x0424 },\n  { 0x06e7, 0x0413 },\n  { 0x06e8, 0x0425 },\n  { 0x06e9, 0x0418 },\n  { 0x06ea, 0x0419 },\n  { 0x06eb, 0x041a },\n  { 0x06ec, 0x041b },\n  { 0x06ed, 0x041c },\n  { 0x06ee, 0x041d },\n  { 0x06ef, 0x041e },\n  { 0x06f0, 0x041f },\n  { 0x06f1, 0x042f },\n  { 0x06f2, 0x0420 },\n  { 0x06f3, 0x0421 },\n  { 0x06f4, 0x0422 },\n  { 0x06f5, 0x0423 },\n  { 0x06f6, 0x0416 },\n  { 0x06f7, 0x0412 },\n  { 0x06f8, 0x042c },\n  { 0x06f9, 0x042b },\n  { 0x06fa, 0x0417 },\n  { 0x06fb, 0x0428 },\n  { 0x06fc, 0x042d },\n  { 0x06fd, 0x0429 },\n  { 0x06fe, 0x0427 },\n  { 0x06ff, 0x042a },\n  { 0x07a1, 0x0386 },\n  { 0x07a2, 0x0388 },\n  { 0x07a3, 0x0389 },\n  { 0x07a4, 0x038a },\n  { 0x07a5, 0x03aa },\n  { 0x07a7, 0x038c },\n  { 0x07a8, 0x038e },\n  { 0x07a9, 0x03ab },\n  { 0x07ab, 0x038f },\n  { 0x07ae, 0x0385 },\n  { 0x07af, 0x2015 },\n  { 0x07b1, 0x03ac },\n  { 0x07b2, 0x03ad },\n  { 0x07b3, 0x03ae },\n  { 0x07b4, 0x03af },\n  { 0x07b5, 0x03ca },\n  { 0x07b6, 0x0390 },\n  { 0x07b7, 0x03cc },\n  { 0x07b8, 0x03cd },\n  { 0x07b9, 0x03cb },\n  { 0x07ba, 0x03b0 },\n  { 0x07bb, 0x03ce },\n  { 0x07c1, 0x0391 },\n  { 0x07c2, 0x0392 },\n  { 0x07c3, 0x0393 },\n  { 0x07c4, 0x0394 },\n  { 0x07c5, 0x0395 },\n  { 0x07c6, 0x0396 },\n  { 0x07c7, 0x0397 },\n  { 0x07c8, 0x0398 },\n  { 0x07c9, 0x0399 },\n  { 0x07ca, 0x039a },\n  { 0x07cb, 0x039b },\n  { 0x07cc, 0x039c },\n  { 0x07cd, 0x039d },\n  { 0x07ce, 0x039e },\n  { 0x07cf, 0x039f },\n  { 0x07d0, 0x03a0 },\n  { 0x07d1, 0x03a1 },\n  { 0x07d2, 0x03a3 },\n  { 0x07d4, 0x03a4 },\n  { 0x07d5, 0x03a5 },\n  { 0x07d6, 0x03a6 },\n  { 0x07d7, 0x03a7 },\n  { 0x07d8, 0x03a8 },\n  { 0x07d9, 0x03a9 },\n  { 0x07e1, 0x03b1 },\n  { 0x07e2, 0x03b2 },\n  { 0x07e3, 0x03b3 },\n  { 0x07e4, 0x03b4 },\n  { 0x07e5, 0x03b5 },\n  { 0x07e6, 0x03b6 },\n  { 0x07e7, 0x03b7 },\n  { 0x07e8, 0x03b8 },\n  { 0x07e9, 0x03b9 },\n  { 0x07ea, 0x03ba },\n  { 0x07eb, 0x03bb },\n  { 0x07ec, 0x03bc },\n  { 0x07ed, 0x03bd },\n  { 0x07ee, 0x03be },\n  { 0x07ef, 0x03bf },\n  { 0x07f0, 0x03c0 },\n  { 0x07f1, 0x03c1 },\n  { 0x07f2, 0x03c3 },\n  { 0x07f3, 0x03c2 },\n  { 0x07f4, 0x03c4 },\n  { 0x07f5, 0x03c5 },\n  { 0x07f6, 0x03c6 },\n  { 0x07f7, 0x03c7 },\n  { 0x07f8, 0x03c8 },\n  { 0x07f9, 0x03c9 },\n  { 0x08a1, 0x23b7 },\n  { 0x08a2, 0x250c },\n  { 0x08a3, 0x2500 },\n  { 0x08a4, 0x2320 },\n  { 0x08a5, 0x2321 },\n  { 0x08a6, 0x2502 },\n  { 0x08a7, 0x23a1 },\n  { 0x08a8, 0x23a3 },\n  { 0x08a9, 0x23a4 },\n  { 0x08aa, 0x23a6 },\n  { 0x08ab, 0x239b },\n  { 0x08ac, 0x239d },\n  { 0x08ad, 0x239e },\n  { 0x08ae, 0x23a0 },\n  { 0x08af, 0x23a8 },\n  { 0x08b0, 0x23ac },\n  { 0x08bc, 0x2264 },\n  { 0x08bd, 0x2260 },\n  { 0x08be, 0x2265 },\n  { 0x08bf, 0x222b },\n  { 0x08c0, 0x2234 },\n  { 0x08c1, 0x221d },\n  { 0x08c2, 0x221e },\n  { 0x08c5, 0x2207 },\n  { 0x08c8, 0x223c },\n  { 0x08c9, 0x2243 },\n  { 0x08cd, 0x21d4 },\n  { 0x08ce, 0x21d2 },\n  { 0x08cf, 0x2261 },\n  { 0x08d6, 0x221a },\n  { 0x08da, 0x2282 },\n  { 0x08db, 0x2283 },\n  { 0x08dc, 0x2229 },\n  { 0x08dd, 0x222a },\n  { 0x08de, 0x2227 },\n  { 0x08df, 0x2228 },\n  { 0x08ef, 0x2202 },\n  { 0x08f6, 0x0192 },\n  { 0x08fb, 0x2190 },\n  { 0x08fc, 0x2191 },\n  { 0x08fd, 0x2192 },\n  { 0x08fe, 0x2193 },\n  { 0x09e0, 0x25c6 },\n  { 0x09e1, 0x2592 },\n  { 0x09e2, 0x2409 },\n  { 0x09e3, 0x240c },\n  { 0x09e4, 0x240d },\n  { 0x09e5, 0x240a },\n  { 0x09e8, 0x2424 },\n  { 0x09e9, 0x240b },\n  { 0x09ea, 0x2518 },\n  { 0x09eb, 0x2510 },\n  { 0x09ec, 0x250c },\n  { 0x09ed, 0x2514 },\n  { 0x09ee, 0x253c },\n  { 0x09ef, 0x23ba },\n  { 0x09f0, 0x23bb },\n  { 0x09f1, 0x2500 },\n  { 0x09f2, 0x23bc },\n  { 0x09f3, 0x23bd },\n  { 0x09f4, 0x251c },\n  { 0x09f5, 0x2524 },\n  { 0x09f6, 0x2534 },\n  { 0x09f7, 0x252c },\n  { 0x09f8, 0x2502 },\n  { 0x0aa1, 0x2003 },\n  { 0x0aa2, 0x2002 },\n  { 0x0aa3, 0x2004 },\n  { 0x0aa4, 0x2005 },\n  { 0x0aa5, 0x2007 },\n  { 0x0aa6, 0x2008 },\n  { 0x0aa7, 0x2009 },\n  { 0x0aa8, 0x200a },\n  { 0x0aa9, 0x2014 },\n  { 0x0aaa, 0x2013 },\n  { 0x0aae, 0x2026 },\n  { 0x0aaf, 0x2025 },\n  { 0x0ab0, 0x2153 },\n  { 0x0ab1, 0x2154 },\n  { 0x0ab2, 0x2155 },\n  { 0x0ab3, 0x2156 },\n  { 0x0ab4, 0x2157 },\n  { 0x0ab5, 0x2158 },\n  { 0x0ab6, 0x2159 },\n  { 0x0ab7, 0x215a },\n  { 0x0ab8, 0x2105 },\n  { 0x0abb, 0x2012 },\n  { 0x0abc, 0x2329 },\n  { 0x0abe, 0x232a },\n  { 0x0ac3, 0x215b },\n  { 0x0ac4, 0x215c },\n  { 0x0ac5, 0x215d },\n  { 0x0ac6, 0x215e },\n  { 0x0ac9, 0x2122 },\n  { 0x0aca, 0x2613 },\n  { 0x0acc, 0x25c1 },\n  { 0x0acd, 0x25b7 },\n  { 0x0ace, 0x25cb },\n  { 0x0acf, 0x25af },\n  { 0x0ad0, 0x2018 },\n  { 0x0ad1, 0x2019 },\n  { 0x0ad2, 0x201c },\n  { 0x0ad3, 0x201d },\n  { 0x0ad4, 0x211e },\n  { 0x0ad6, 0x2032 },\n  { 0x0ad7, 0x2033 },\n  { 0x0ad9, 0x271d },\n  { 0x0adb, 0x25ac },\n  { 0x0adc, 0x25c0 },\n  { 0x0add, 0x25b6 },\n  { 0x0ade, 0x25cf },\n  { 0x0adf, 0x25ae },\n  { 0x0ae0, 0x25e6 },\n  { 0x0ae1, 0x25ab },\n  { 0x0ae2, 0x25ad },\n  { 0x0ae3, 0x25b3 },\n  { 0x0ae4, 0x25bd },\n  { 0x0ae5, 0x2606 },\n  { 0x0ae6, 0x2022 },\n  { 0x0ae7, 0x25aa },\n  { 0x0ae8, 0x25b2 },\n  { 0x0ae9, 0x25bc },\n  { 0x0aea, 0x261c },\n  { 0x0aeb, 0x261e },\n  { 0x0aec, 0x2663 },\n  { 0x0aed, 0x2666 },\n  { 0x0aee, 0x2665 },\n  { 0x0af0, 0x2720 },\n  { 0x0af1, 0x2020 },\n  { 0x0af2, 0x2021 },\n  { 0x0af3, 0x2713 },\n  { 0x0af4, 0x2717 },\n  { 0x0af5, 0x266f },\n  { 0x0af6, 0x266d },\n  { 0x0af7, 0x2642 },\n  { 0x0af8, 0x2640 },\n  { 0x0af9, 0x260e },\n  { 0x0afa, 0x2315 },\n  { 0x0afb, 0x2117 },\n  { 0x0afc, 0x2038 },\n  { 0x0afd, 0x201a },\n  { 0x0afe, 0x201e },\n  { 0x0ba3, 0x003c },\n  { 0x0ba6, 0x003e },\n  { 0x0ba8, 0x2228 },\n  { 0x0ba9, 0x2227 },\n  { 0x0bc0, 0x00af },\n  { 0x0bc2, 0x22a5 },\n  { 0x0bc3, 0x2229 },\n  { 0x0bc4, 0x230a },\n  { 0x0bc6, 0x005f },\n  { 0x0bca, 0x2218 },\n  { 0x0bcc, 0x2395 },\n  { 0x0bce, 0x22a4 },\n  { 0x0bcf, 0x25cb },\n  { 0x0bd3, 0x2308 },\n  { 0x0bd6, 0x222a },\n  { 0x0bd8, 0x2283 },\n  { 0x0bda, 0x2282 },\n  { 0x0bdc, 0x22a2 },\n  { 0x0bfc, 0x22a3 },\n  { 0x0cdf, 0x2017 },\n  { 0x0ce0, 0x05d0 },\n  { 0x0ce1, 0x05d1 },\n  { 0x0ce2, 0x05d2 },\n  { 0x0ce3, 0x05d3 },\n  { 0x0ce4, 0x05d4 },\n  { 0x0ce5, 0x05d5 },\n  { 0x0ce6, 0x05d6 },\n  { 0x0ce7, 0x05d7 },\n  { 0x0ce8, 0x05d8 },\n  { 0x0ce9, 0x05d9 },\n  { 0x0cea, 0x05da },\n  { 0x0ceb, 0x05db },\n  { 0x0cec, 0x05dc },\n  { 0x0ced, 0x05dd },\n  { 0x0cee, 0x05de },\n  { 0x0cef, 0x05df },\n  { 0x0cf0, 0x05e0 },\n  { 0x0cf1, 0x05e1 },\n  { 0x0cf2, 0x05e2 },\n  { 0x0cf3, 0x05e3 },\n  { 0x0cf4, 0x05e4 },\n  { 0x0cf5, 0x05e5 },\n  { 0x0cf6, 0x05e6 },\n  { 0x0cf7, 0x05e7 },\n  { 0x0cf8, 0x05e8 },\n  { 0x0cf9, 0x05e9 },\n  { 0x0cfa, 0x05ea },\n  { 0x0da1, 0x0e01 },\n  { 0x0da2, 0x0e02 },\n  { 0x0da3, 0x0e03 },\n  { 0x0da4, 0x0e04 },\n  { 0x0da5, 0x0e05 },\n  { 0x0da6, 0x0e06 },\n  { 0x0da7, 0x0e07 },\n  { 0x0da8, 0x0e08 },\n  { 0x0da9, 0x0e09 },\n  { 0x0daa, 0x0e0a },\n  { 0x0dab, 0x0e0b },\n  { 0x0dac, 0x0e0c },\n  { 0x0dad, 0x0e0d },\n  { 0x0dae, 0x0e0e },\n  { 0x0daf, 0x0e0f },\n  { 0x0db0, 0x0e10 },\n  { 0x0db1, 0x0e11 },\n  { 0x0db2, 0x0e12 },\n  { 0x0db3, 0x0e13 },\n  { 0x0db4, 0x0e14 },\n  { 0x0db5, 0x0e15 },\n  { 0x0db6, 0x0e16 },\n  { 0x0db7, 0x0e17 },\n  { 0x0db8, 0x0e18 },\n  { 0x0db9, 0x0e19 },\n  { 0x0dba, 0x0e1a },\n  { 0x0dbb, 0x0e1b },\n  { 0x0dbc, 0x0e1c },\n  { 0x0dbd, 0x0e1d },\n  { 0x0dbe, 0x0e1e },\n  { 0x0dbf, 0x0e1f },\n  { 0x0dc0, 0x0e20 },\n  { 0x0dc1, 0x0e21 },\n  { 0x0dc2, 0x0e22 },\n  { 0x0dc3, 0x0e23 },\n  { 0x0dc4, 0x0e24 },\n  { 0x0dc5, 0x0e25 },\n  { 0x0dc6, 0x0e26 },\n  { 0x0dc7, 0x0e27 },\n  { 0x0dc8, 0x0e28 },\n  { 0x0dc9, 0x0e29 },\n  { 0x0dca, 0x0e2a },\n  { 0x0dcb, 0x0e2b },\n  { 0x0dcc, 0x0e2c },\n  { 0x0dcd, 0x0e2d },\n  { 0x0dce, 0x0e2e },\n  { 0x0dcf, 0x0e2f },\n  { 0x0dd0, 0x0e30 },\n  { 0x0dd1, 0x0e31 },\n  { 0x0dd2, 0x0e32 },\n  { 0x0dd3, 0x0e33 },\n  { 0x0dd4, 0x0e34 },\n  { 0x0dd5, 0x0e35 },\n  { 0x0dd6, 0x0e36 },\n  { 0x0dd7, 0x0e37 },\n  { 0x0dd8, 0x0e38 },\n  { 0x0dd9, 0x0e39 },\n  { 0x0dda, 0x0e3a },\n  { 0x0ddf, 0x0e3f },\n  { 0x0de0, 0x0e40 },\n  { 0x0de1, 0x0e41 },\n  { 0x0de2, 0x0e42 },\n  { 0x0de3, 0x0e43 },\n  { 0x0de4, 0x0e44 },\n  { 0x0de5, 0x0e45 },\n  { 0x0de6, 0x0e46 },\n  { 0x0de7, 0x0e47 },\n  { 0x0de8, 0x0e48 },\n  { 0x0de9, 0x0e49 },\n  { 0x0dea, 0x0e4a },\n  { 0x0deb, 0x0e4b },\n  { 0x0dec, 0x0e4c },\n  { 0x0ded, 0x0e4d },\n  { 0x0df0, 0x0e50 },\n  { 0x0df1, 0x0e51 },\n  { 0x0df2, 0x0e52 },\n  { 0x0df3, 0x0e53 },\n  { 0x0df4, 0x0e54 },\n  { 0x0df5, 0x0e55 },\n  { 0x0df6, 0x0e56 },\n  { 0x0df7, 0x0e57 },\n  { 0x0df8, 0x0e58 },\n  { 0x0df9, 0x0e59 },\n  { 0x0ea1, 0x3131 },\n  { 0x0ea2, 0x3132 },\n  { 0x0ea3, 0x3133 },\n  { 0x0ea4, 0x3134 },\n  { 0x0ea5, 0x3135 },\n  { 0x0ea6, 0x3136 },\n  { 0x0ea7, 0x3137 },\n  { 0x0ea8, 0x3138 },\n  { 0x0ea9, 0x3139 },\n  { 0x0eaa, 0x313a },\n  { 0x0eab, 0x313b },\n  { 0x0eac, 0x313c },\n  { 0x0ead, 0x313d },\n  { 0x0eae, 0x313e },\n  { 0x0eaf, 0x313f },\n  { 0x0eb0, 0x3140 },\n  { 0x0eb1, 0x3141 },\n  { 0x0eb2, 0x3142 },\n  { 0x0eb3, 0x3143 },\n  { 0x0eb4, 0x3144 },\n  { 0x0eb5, 0x3145 },\n  { 0x0eb6, 0x3146 },\n  { 0x0eb7, 0x3147 },\n  { 0x0eb8, 0x3148 },\n  { 0x0eb9, 0x3149 },\n  { 0x0eba, 0x314a },\n  { 0x0ebb, 0x314b },\n  { 0x0ebc, 0x314c },\n  { 0x0ebd, 0x314d },\n  { 0x0ebe, 0x314e },\n  { 0x0ebf, 0x314f },\n  { 0x0ec0, 0x3150 },\n  { 0x0ec1, 0x3151 },\n  { 0x0ec2, 0x3152 },\n  { 0x0ec3, 0x3153 },\n  { 0x0ec4, 0x3154 },\n  { 0x0ec5, 0x3155 },\n  { 0x0ec6, 0x3156 },\n  { 0x0ec7, 0x3157 },\n  { 0x0ec8, 0x3158 },\n  { 0x0ec9, 0x3159 },\n  { 0x0eca, 0x315a },\n  { 0x0ecb, 0x315b },\n  { 0x0ecc, 0x315c },\n  { 0x0ecd, 0x315d },\n  { 0x0ece, 0x315e },\n  { 0x0ecf, 0x315f },\n  { 0x0ed0, 0x3160 },\n  { 0x0ed1, 0x3161 },\n  { 0x0ed2, 0x3162 },\n  { 0x0ed3, 0x3163 },\n  { 0x0ed4, 0x11a8 },\n  { 0x0ed5, 0x11a9 },\n  { 0x0ed6, 0x11aa },\n  { 0x0ed7, 0x11ab },\n  { 0x0ed8, 0x11ac },\n  { 0x0ed9, 0x11ad },\n  { 0x0eda, 0x11ae },\n  { 0x0edb, 0x11af },\n  { 0x0edc, 0x11b0 },\n  { 0x0edd, 0x11b1 },\n  { 0x0ede, 0x11b2 },\n  { 0x0edf, 0x11b3 },\n  { 0x0ee0, 0x11b4 },\n  { 0x0ee1, 0x11b5 },\n  { 0x0ee2, 0x11b6 },\n  { 0x0ee3, 0x11b7 },\n  { 0x0ee4, 0x11b8 },\n  { 0x0ee5, 0x11b9 },\n  { 0x0ee6, 0x11ba },\n  { 0x0ee7, 0x11bb },\n  { 0x0ee8, 0x11bc },\n  { 0x0ee9, 0x11bd },\n  { 0x0eea, 0x11be },\n  { 0x0eeb, 0x11bf },\n  { 0x0eec, 0x11c0 },\n  { 0x0eed, 0x11c1 },\n  { 0x0eee, 0x11c2 },\n  { 0x0eef, 0x316d },\n  { 0x0ef0, 0x3171 },\n  { 0x0ef1, 0x3178 },\n  { 0x0ef2, 0x317f },\n  { 0x0ef3, 0x3181 },\n  { 0x0ef4, 0x3184 },\n  { 0x0ef5, 0x3186 },\n  { 0x0ef6, 0x318d },\n  { 0x0ef7, 0x318e },\n  { 0x0ef8, 0x11eb },\n  { 0x0ef9, 0x11f0 },\n  { 0x0efa, 0x11f9 },\n  { 0x0eff, 0x20a9 },\n  { 0x13a4, 0x20ac },\n  { 0x13bc, 0x0152 },\n  { 0x13bd, 0x0153 },\n  { 0x13be, 0x0178 },\n  { 0x20ac, 0x20ac },\n  // Numeric keypad with numlock on\n  { XK_KP_Space, ' ' },\n  { XK_KP_Equal, '=' },\n  { XK_KP_Multiply, '*' },\n  { XK_KP_Add, '+' },\n  { XK_KP_Separator, ',' },\n  { XK_KP_Subtract, '-' },\n  { XK_KP_Decimal, '.' },\n  { XK_KP_Divide, '/' },\n  { XK_KP_0, 0x0030 },\n  { XK_KP_1, 0x0031 },\n  { XK_KP_2, 0x0032 },\n  { XK_KP_3, 0x0033 },\n  { XK_KP_4, 0x0034 },\n  { XK_KP_5, 0x0035 },\n  { XK_KP_6, 0x0036 },\n  { XK_KP_7, 0x0037 },\n  { XK_KP_8, 0x0038 },\n  { XK_KP_9, 0x0039 }\n};\n\n\n//////////////////////////////////////////////////////////////////////////\n//////                       GLFW internal API                      //////\n//////////////////////////////////////////////////////////////////////////\n\n// Convert XKB KeySym to Unicode\n//\nlong _glfwKeySym2Unicode(unsigned int keysym)\n{\n    int min = 0;\n    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;\n    int mid;\n\n    // First check for Latin-1 characters (1:1 mapping)\n    if ((keysym >= 0x0020 && keysym <= 0x007e) ||\n        (keysym >= 0x00a0 && keysym <= 0x00ff))\n    {\n        return keysym;\n    }\n\n    // Also check for directly encoded 24-bit UCS characters\n    if ((keysym & 0xff000000) == 0x01000000)\n        return keysym & 0x00ffffff;\n\n    // Binary search in table\n    while (max >= min)\n    {\n        mid = (min + max) / 2;\n        if (keysymtab[mid].keysym < keysym)\n            min = mid + 1;\n        else if (keysymtab[mid].keysym > keysym)\n            max = mid - 1;\n        else\n            return keysymtab[mid].ucs;\n    }\n\n    // No matching Unicode value found\n    return -1;\n}\n\n"
  },
  {
    "path": "deps/glfw/src/xkb_unicode.h",
    "content": "//========================================================================\n// GLFW 3.1 Linux - www.glfw.org\n//------------------------------------------------------------------------\n// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#ifndef _glfw3_xkb_unicode_h_\n#define _glfw3_xkb_unicode_h_\n\n\nlong _glfwKeySym2Unicode(unsigned int keysym);\n\n#endif // _glfw3_xkb_unicode_h_\n"
  },
  {
    "path": "deps/glfw/tests/CMakeLists.txt",
    "content": "\nlink_libraries(glfw)\n\nif (BUILD_SHARED_LIBS)\n    add_definitions(-DGLFW_DLL)\n    link_libraries(\"${OPENGL_gl_LIBRARY}\" \"${MATH_LIBRARY}\")\nelse()\n    link_libraries(${glfw_LIBRARIES})\nendif()\n\ninclude_directories(\"${GLFW_SOURCE_DIR}/include\"\n                    \"${GLFW_SOURCE_DIR}/deps\")\n\nif (\"${OPENGL_INCLUDE_DIR}\")\n    include_directories(\"${OPENGL_INCLUDE_DIR}\")\nendif()\n\nset(GETOPT \"${GLFW_SOURCE_DIR}/deps/getopt.h\"\n           \"${GLFW_SOURCE_DIR}/deps/getopt.c\")\nset(TINYCTHREAD \"${GLFW_SOURCE_DIR}/deps/tinycthread.h\"\n                \"${GLFW_SOURCE_DIR}/deps/tinycthread.c\")\n\nadd_executable(clipboard clipboard.c ${GETOPT})\nadd_executable(events events.c ${GETOPT})\nadd_executable(msaa msaa.c ${GETOPT})\nadd_executable(gamma gamma.c ${GETOPT})\nadd_executable(glfwinfo glfwinfo.c ${GETOPT})\nadd_executable(iconify iconify.c ${GETOPT})\nadd_executable(joysticks joysticks.c)\nadd_executable(monitors monitors.c ${GETOPT})\nadd_executable(reopen reopen.c)\nadd_executable(cursor cursor.c)\n\nadd_executable(empty WIN32 MACOSX_BUNDLE empty.c ${TINYCTHREAD})\nset_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Empty Event\")\n\nadd_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)\nset_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Sharing\")\n\nadd_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT})\nset_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Tearing\")\n\nadd_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD})\nset_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Threads\")\n\nadd_executable(title WIN32 MACOSX_BUNDLE title.c)\nset_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Title\")\n\nadd_executable(windows WIN32 MACOSX_BUNDLE windows.c)\nset_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \"Windows\")\n\ntarget_link_libraries(empty \"${CMAKE_THREAD_LIBS_INIT}\" \"${RT_LIBRARY}\")\ntarget_link_libraries(threads \"${CMAKE_THREAD_LIBS_INIT}\" \"${RT_LIBRARY}\")\n\nset(WINDOWS_BINARIES empty sharing tearing threads title windows)\nset(CONSOLE_BINARIES clipboard events msaa gamma glfwinfo\n                     iconify joysticks monitors reopen cursor)\n\nset_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES\n                      FOLDER \"GLFW3/Tests\")\n\nif (MSVC)\n    # Tell MSVC to use main instead of WinMain for Windows subsystem executables\n    set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES\n                          LINK_FLAGS \"/ENTRY:mainCRTStartup\")\nendif()\n\nif (APPLE)\n    set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES\n                          MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}\n                          MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}\n                          MACOSX_BUNDLE_INFO_PLIST \"${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in\")\nendif()\n\n"
  },
  {
    "path": "deps/glfw/tests/clipboard.c",
    "content": "//========================================================================\n// Clipboard test program\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This program is used to test the clipboard functionality.\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"getopt.h\"\n\n#if defined(__APPLE__)\n #define MODIFIER GLFW_MOD_SUPER\n#else\n #define MODIFIER GLFW_MOD_CONTROL\n#endif\n\nstatic void usage(void)\n{\n    printf(\"Usage: clipboard [-h]\\n\");\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n\n        case GLFW_KEY_V:\n            if (mods == MODIFIER)\n            {\n                const char* string;\n\n                string = glfwGetClipboardString(window);\n                if (string)\n                    printf(\"Clipboard contains \\\"%s\\\"\\n\", string);\n                else\n                    printf(\"Clipboard does not contain a string\\n\");\n            }\n            break;\n\n        case GLFW_KEY_C:\n            if (mods == MODIFIER)\n            {\n                const char* string = \"Hello GLFW World!\";\n                glfwSetClipboardString(window, string);\n                printf(\"Setting clipboard to \\\"%s\\\"\\n\", string);\n            }\n            break;\n    }\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nint main(int argc, char** argv)\n{\n    int ch;\n    GLFWwindow* window;\n\n    while ((ch = getopt(argc, argv, \"h\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n    {\n        fprintf(stderr, \"Failed to initialize GLFW\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    window = glfwCreateWindow(200, 200, \"Clipboard Test\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n\n        fprintf(stderr, \"Failed to open GLFW window\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetKeyCallback(window, key_callback);\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\n    glMatrixMode(GL_PROJECTION);\n    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);\n    glMatrixMode(GL_MODELVIEW);\n\n    glClearColor(0.5f, 0.5f, 0.5f, 0);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        glColor3f(0.8f, 0.2f, 0.4f);\n        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);\n\n        glfwSwapBuffers(window);\n        glfwWaitEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/cursor.c",
    "content": "//========================================================================\n// Cursor & input mode tests\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test provides an interface to the cursor image and cursor mode\n// parts of the API.\n//\n// Custom cursor image generation by urraka.\n//\n//========================================================================\n\n#if defined(_MSC_VER)\n // Make MS math.h define M_PI\n #define _USE_MATH_DEFINES\n#elif __GNUC__\n #define _GNU_SOURCE\n#endif\n\n#include <GLFW/glfw3.h>\n\n#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#define CURSOR_FRAME_COUNT 60\n\nstatic double cursor_x;\nstatic double cursor_y;\nstatic int swap_interval = 1;\nstatic GLboolean wait_events = GL_FALSE;\nstatic GLboolean animate_cursor = GL_FALSE;\nstatic GLboolean track_cursor = GL_FALSE;\nstatic GLFWcursor* standard_cursors[6];\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic float star(int x, int y, float t)\n{\n    const float c = 64 / 2.f;\n\n    const float i = (0.25f * (float) sin(2.f * M_PI * t) + 0.75f);\n    const float k = 64 * 0.046875f * i;\n\n    const float dist = (float) sqrt((x - c) * (x - c) + (y - c) * (y - c));\n\n    const float salpha = 1.f - dist / c;\n    const float xalpha = (float) x == c ? c : k / (float) fabs(x - c);\n    const float yalpha = (float) y == c ? c : k / (float) fabs(y - c);\n\n    return (float) fmax(0.f, fmin(1.f, i * salpha * 0.2f + salpha * xalpha * yalpha));\n}\n\nstatic GLFWcursor* create_cursor_frame(float t)\n{\n    int i = 0, x, y;\n    unsigned char buffer[64 * 64 * 4];\n    const GLFWimage image = { 64, 64, buffer };\n\n    for (y = 0;  y < image.width;  y++)\n    {\n        for (x = 0;  x < image.height;  x++)\n        {\n            buffer[i++] = 255;\n            buffer[i++] = 255;\n            buffer[i++] = 255;\n            buffer[i++] = (unsigned char) (255 * star(x, y, t));\n        }\n    }\n\n    return glfwCreateCursor(&image, image.width / 2, image.height / 2);\n}\n\nstatic void cursor_position_callback(GLFWwindow* window, double x, double y)\n{\n    printf(\"%0.3f: Cursor position: %f %f (%+f %+f)\\n\",\n           glfwGetTime(),\n           x, y, x - cursor_x, y - cursor_y);\n\n    cursor_x = x;\n    cursor_y = y;\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_A:\n        {\n            animate_cursor = !animate_cursor;\n            if (!animate_cursor)\n                glfwSetCursor(window, NULL);\n\n            break;\n        }\n\n        case GLFW_KEY_ESCAPE:\n        {\n            if (glfwGetInputMode(window, GLFW_CURSOR) != GLFW_CURSOR_DISABLED)\n            {\n                glfwSetWindowShouldClose(window, GL_TRUE);\n                break;\n            }\n\n            /* FALLTHROUGH */\n        }\n\n        case GLFW_KEY_N:\n            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);\n            printf(\"(( cursor is normal ))\\n\");\n            break;\n\n        case GLFW_KEY_D:\n            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n            printf(\"(( cursor is disabled ))\\n\");\n            break;\n\n        case GLFW_KEY_H:\n            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);\n            printf(\"(( cursor is hidden ))\\n\");\n            break;\n\n        case GLFW_KEY_SPACE:\n            swap_interval = 1 - swap_interval;\n            printf(\"(( swap interval: %i ))\\n\", swap_interval);\n            glfwSwapInterval(swap_interval);\n            break;\n\n        case GLFW_KEY_W:\n            wait_events = !wait_events;\n            printf(\"(( %sing for events ))\\n\", wait_events ? \"wait\" : \"poll\");\n            break;\n\n        case GLFW_KEY_T:\n            track_cursor = !track_cursor;\n            break;\n\n        case GLFW_KEY_0:\n            glfwSetCursor(window, NULL);\n            break;\n\n        case GLFW_KEY_1:\n            glfwSetCursor(window, standard_cursors[0]);\n            break;\n\n        case GLFW_KEY_2:\n            glfwSetCursor(window, standard_cursors[1]);\n            break;\n\n        case GLFW_KEY_3:\n            glfwSetCursor(window, standard_cursors[2]);\n            break;\n\n        case GLFW_KEY_4:\n            glfwSetCursor(window, standard_cursors[3]);\n            break;\n\n        case GLFW_KEY_5:\n            glfwSetCursor(window, standard_cursors[4]);\n            break;\n\n        case GLFW_KEY_6:\n            glfwSetCursor(window, standard_cursors[5]);\n            break;\n    }\n}\n\nint main(void)\n{\n    int i;\n    GLFWwindow* window;\n    GLFWcursor* star_cursors[CURSOR_FRAME_COUNT];\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    for (i = 0;  i < CURSOR_FRAME_COUNT;  i++)\n    {\n        star_cursors[i] = create_cursor_frame(i / (float) CURSOR_FRAME_COUNT);\n        if (!star_cursors[i])\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n    }\n\n    for (i = 0;  i < sizeof(standard_cursors) / sizeof(standard_cursors[0]);  i++)\n    {\n        const int shapes[] = {\n            GLFW_ARROW_CURSOR,\n            GLFW_IBEAM_CURSOR,\n            GLFW_CROSSHAIR_CURSOR,\n            GLFW_HAND_CURSOR,\n            GLFW_HRESIZE_CURSOR,\n            GLFW_VRESIZE_CURSOR\n        };\n\n        standard_cursors[i] = glfwCreateStandardCursor(shapes[i]);\n        if (!standard_cursors[i])\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n    }\n\n    window = glfwCreateWindow(640, 480, \"Cursor Test\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n\n    glfwGetCursorPos(window, &cursor_x, &cursor_y);\n    printf(\"Cursor position: %f %f\\n\", cursor_x, cursor_y);\n\n    glfwSetCursorPosCallback(window, cursor_position_callback);\n    glfwSetKeyCallback(window, key_callback);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        if (track_cursor)\n        {\n            int wnd_width, wnd_height, fb_width, fb_height;\n            float scale;\n\n            glfwGetWindowSize(window, &wnd_width, &wnd_height);\n            glfwGetFramebufferSize(window, &fb_width, &fb_height);\n\n            scale = (float) fb_width / (float) wnd_width;\n\n            glViewport(0, 0, fb_width, fb_height);\n\n            glMatrixMode(GL_PROJECTION);\n            glLoadIdentity();\n            glOrtho(0.f, fb_width, 0.f, fb_height, 0.f, 1.f);\n\n            glBegin(GL_LINES);\n            glVertex2f(0.f, (GLfloat) (fb_height - cursor_y * scale));\n            glVertex2f((GLfloat) fb_width, (GLfloat) (fb_height - cursor_y * scale));\n            glVertex2f((GLfloat) cursor_x * scale, 0.f);\n            glVertex2f((GLfloat) cursor_x * scale, (GLfloat) fb_height);\n            glEnd();\n        }\n\n        glfwSwapBuffers(window);\n\n        if (animate_cursor)\n        {\n            const int i = (int) (glfwGetTime() * 30.0) % CURSOR_FRAME_COUNT;\n            glfwSetCursor(window, star_cursors[i]);\n        }\n\n        if (wait_events)\n            glfwWaitEvents();\n        else\n            glfwPollEvents();\n\n        // Workaround for an issue with msvcrt and mintty\n        fflush(stdout);\n    }\n\n    glfwDestroyWindow(window);\n\n    for (i = 0;  i < CURSOR_FRAME_COUNT;  i++)\n        glfwDestroyCursor(star_cursors[i]);\n\n    for (i = 0;  i < sizeof(standard_cursors) / sizeof(standard_cursors[0]);  i++)\n        glfwDestroyCursor(standard_cursors[i]);\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/empty.c",
    "content": "//========================================================================\n// Empty event test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test is intended to verify that posting of empty events works\n//\n//========================================================================\n\n#include \"tinycthread.h\"\n\n#include <GLFW/glfw3.h>\n\n#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic volatile GLboolean running = GL_TRUE;\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic int thread_main(void* data)\n{\n    struct timespec time;\n\n    while (running)\n    {\n        clock_gettime(CLOCK_REALTIME, &time);\n        time.tv_sec += 1;\n        thrd_sleep(&time, NULL);\n\n        glfwPostEmptyEvent();\n    }\n\n    return 0;\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\nstatic float nrand(void)\n{\n    return (float) rand() / (float) RAND_MAX;\n}\n\nint main(void)\n{\n    int result;\n    thrd_t thread;\n    GLFWwindow* window;\n\n    srand((unsigned int) time(NULL));\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    window = glfwCreateWindow(640, 480, \"Empty Event Test\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n    glfwSetKeyCallback(window, key_callback);\n\n    if (thrd_create(&thread, thread_main, NULL) != thrd_success)\n    {\n        fprintf(stderr, \"Failed to create secondary thread\\n\");\n\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    while (running)\n    {\n        int width, height;\n        float r = nrand(), g = nrand(), b = nrand();\n        float l = (float) sqrt(r * r + g * g + b * b);\n\n        glfwGetFramebufferSize(window, &width, &height);\n\n        glViewport(0, 0, width, height);\n        glClearColor(r / l, g / l, b / l, 1.f);\n        glClear(GL_COLOR_BUFFER_BIT);\n        glfwSwapBuffers(window);\n\n        glfwWaitEvents();\n\n        if (glfwWindowShouldClose(window))\n            running = GL_FALSE;\n    }\n\n    glfwHideWindow(window);\n    thrd_join(thread, &result);\n    glfwDestroyWindow(window);\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/events.c",
    "content": "//========================================================================\n// Event linter (event spewer)\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test hooks every available callback and outputs their arguments\n//\n// Log messages go to stdout, error messages to stderr\n//\n// Every event also gets a (sequential) number to aid discussion of logs\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <string.h>\n#include <locale.h>\n\n#include \"getopt.h\"\n\n// Event index\nstatic unsigned int counter = 0;\n\ntypedef struct\n{\n    GLFWwindow* window;\n    int number;\n    int closeable;\n} Slot;\n\nstatic void usage(void)\n{\n    printf(\"Usage: events [-f] [-h] [-n WINDOWS]\\n\");\n    printf(\"Options:\\n\");\n    printf(\"  -f use full screen\\n\");\n    printf(\"  -h show this help\\n\");\n    printf(\"  -n the number of windows to create\\n\");\n}\n\nstatic const char* get_key_name(int key)\n{\n    switch (key)\n    {\n        // Printable keys\n        case GLFW_KEY_A:            return \"A\";\n        case GLFW_KEY_B:            return \"B\";\n        case GLFW_KEY_C:            return \"C\";\n        case GLFW_KEY_D:            return \"D\";\n        case GLFW_KEY_E:            return \"E\";\n        case GLFW_KEY_F:            return \"F\";\n        case GLFW_KEY_G:            return \"G\";\n        case GLFW_KEY_H:            return \"H\";\n        case GLFW_KEY_I:            return \"I\";\n        case GLFW_KEY_J:            return \"J\";\n        case GLFW_KEY_K:            return \"K\";\n        case GLFW_KEY_L:            return \"L\";\n        case GLFW_KEY_M:            return \"M\";\n        case GLFW_KEY_N:            return \"N\";\n        case GLFW_KEY_O:            return \"O\";\n        case GLFW_KEY_P:            return \"P\";\n        case GLFW_KEY_Q:            return \"Q\";\n        case GLFW_KEY_R:            return \"R\";\n        case GLFW_KEY_S:            return \"S\";\n        case GLFW_KEY_T:            return \"T\";\n        case GLFW_KEY_U:            return \"U\";\n        case GLFW_KEY_V:            return \"V\";\n        case GLFW_KEY_W:            return \"W\";\n        case GLFW_KEY_X:            return \"X\";\n        case GLFW_KEY_Y:            return \"Y\";\n        case GLFW_KEY_Z:            return \"Z\";\n        case GLFW_KEY_1:            return \"1\";\n        case GLFW_KEY_2:            return \"2\";\n        case GLFW_KEY_3:            return \"3\";\n        case GLFW_KEY_4:            return \"4\";\n        case GLFW_KEY_5:            return \"5\";\n        case GLFW_KEY_6:            return \"6\";\n        case GLFW_KEY_7:            return \"7\";\n        case GLFW_KEY_8:            return \"8\";\n        case GLFW_KEY_9:            return \"9\";\n        case GLFW_KEY_0:            return \"0\";\n        case GLFW_KEY_SPACE:        return \"SPACE\";\n        case GLFW_KEY_MINUS:        return \"MINUS\";\n        case GLFW_KEY_EQUAL:        return \"EQUAL\";\n        case GLFW_KEY_LEFT_BRACKET: return \"LEFT BRACKET\";\n        case GLFW_KEY_RIGHT_BRACKET: return \"RIGHT BRACKET\";\n        case GLFW_KEY_BACKSLASH:    return \"BACKSLASH\";\n        case GLFW_KEY_SEMICOLON:    return \"SEMICOLON\";\n        case GLFW_KEY_APOSTROPHE:   return \"APOSTROPHE\";\n        case GLFW_KEY_GRAVE_ACCENT: return \"GRAVE ACCENT\";\n        case GLFW_KEY_COMMA:        return \"COMMA\";\n        case GLFW_KEY_PERIOD:       return \"PERIOD\";\n        case GLFW_KEY_SLASH:        return \"SLASH\";\n        case GLFW_KEY_WORLD_1:      return \"WORLD 1\";\n        case GLFW_KEY_WORLD_2:      return \"WORLD 2\";\n\n        // Function keys\n        case GLFW_KEY_ESCAPE:       return \"ESCAPE\";\n        case GLFW_KEY_F1:           return \"F1\";\n        case GLFW_KEY_F2:           return \"F2\";\n        case GLFW_KEY_F3:           return \"F3\";\n        case GLFW_KEY_F4:           return \"F4\";\n        case GLFW_KEY_F5:           return \"F5\";\n        case GLFW_KEY_F6:           return \"F6\";\n        case GLFW_KEY_F7:           return \"F7\";\n        case GLFW_KEY_F8:           return \"F8\";\n        case GLFW_KEY_F9:           return \"F9\";\n        case GLFW_KEY_F10:          return \"F10\";\n        case GLFW_KEY_F11:          return \"F11\";\n        case GLFW_KEY_F12:          return \"F12\";\n        case GLFW_KEY_F13:          return \"F13\";\n        case GLFW_KEY_F14:          return \"F14\";\n        case GLFW_KEY_F15:          return \"F15\";\n        case GLFW_KEY_F16:          return \"F16\";\n        case GLFW_KEY_F17:          return \"F17\";\n        case GLFW_KEY_F18:          return \"F18\";\n        case GLFW_KEY_F19:          return \"F19\";\n        case GLFW_KEY_F20:          return \"F20\";\n        case GLFW_KEY_F21:          return \"F21\";\n        case GLFW_KEY_F22:          return \"F22\";\n        case GLFW_KEY_F23:          return \"F23\";\n        case GLFW_KEY_F24:          return \"F24\";\n        case GLFW_KEY_F25:          return \"F25\";\n        case GLFW_KEY_UP:           return \"UP\";\n        case GLFW_KEY_DOWN:         return \"DOWN\";\n        case GLFW_KEY_LEFT:         return \"LEFT\";\n        case GLFW_KEY_RIGHT:        return \"RIGHT\";\n        case GLFW_KEY_LEFT_SHIFT:   return \"LEFT SHIFT\";\n        case GLFW_KEY_RIGHT_SHIFT:  return \"RIGHT SHIFT\";\n        case GLFW_KEY_LEFT_CONTROL: return \"LEFT CONTROL\";\n        case GLFW_KEY_RIGHT_CONTROL: return \"RIGHT CONTROL\";\n        case GLFW_KEY_LEFT_ALT:     return \"LEFT ALT\";\n        case GLFW_KEY_RIGHT_ALT:    return \"RIGHT ALT\";\n        case GLFW_KEY_TAB:          return \"TAB\";\n        case GLFW_KEY_ENTER:        return \"ENTER\";\n        case GLFW_KEY_BACKSPACE:    return \"BACKSPACE\";\n        case GLFW_KEY_INSERT:       return \"INSERT\";\n        case GLFW_KEY_DELETE:       return \"DELETE\";\n        case GLFW_KEY_PAGE_UP:      return \"PAGE UP\";\n        case GLFW_KEY_PAGE_DOWN:    return \"PAGE DOWN\";\n        case GLFW_KEY_HOME:         return \"HOME\";\n        case GLFW_KEY_END:          return \"END\";\n        case GLFW_KEY_KP_0:         return \"KEYPAD 0\";\n        case GLFW_KEY_KP_1:         return \"KEYPAD 1\";\n        case GLFW_KEY_KP_2:         return \"KEYPAD 2\";\n        case GLFW_KEY_KP_3:         return \"KEYPAD 3\";\n        case GLFW_KEY_KP_4:         return \"KEYPAD 4\";\n        case GLFW_KEY_KP_5:         return \"KEYPAD 5\";\n        case GLFW_KEY_KP_6:         return \"KEYPAD 6\";\n        case GLFW_KEY_KP_7:         return \"KEYPAD 7\";\n        case GLFW_KEY_KP_8:         return \"KEYPAD 8\";\n        case GLFW_KEY_KP_9:         return \"KEYPAD 9\";\n        case GLFW_KEY_KP_DIVIDE:    return \"KEYPAD DIVIDE\";\n        case GLFW_KEY_KP_MULTIPLY:  return \"KEYPAD MULTPLY\";\n        case GLFW_KEY_KP_SUBTRACT:  return \"KEYPAD SUBTRACT\";\n        case GLFW_KEY_KP_ADD:       return \"KEYPAD ADD\";\n        case GLFW_KEY_KP_DECIMAL:   return \"KEYPAD DECIMAL\";\n        case GLFW_KEY_KP_EQUAL:     return \"KEYPAD EQUAL\";\n        case GLFW_KEY_KP_ENTER:     return \"KEYPAD ENTER\";\n        case GLFW_KEY_PRINT_SCREEN: return \"PRINT SCREEN\";\n        case GLFW_KEY_NUM_LOCK:     return \"NUM LOCK\";\n        case GLFW_KEY_CAPS_LOCK:    return \"CAPS LOCK\";\n        case GLFW_KEY_SCROLL_LOCK:  return \"SCROLL LOCK\";\n        case GLFW_KEY_PAUSE:        return \"PAUSE\";\n        case GLFW_KEY_LEFT_SUPER:   return \"LEFT SUPER\";\n        case GLFW_KEY_RIGHT_SUPER:  return \"RIGHT SUPER\";\n        case GLFW_KEY_MENU:         return \"MENU\";\n\n        default:                    return \"UNKNOWN\";\n    }\n}\n\nstatic const char* get_action_name(int action)\n{\n    switch (action)\n    {\n        case GLFW_PRESS:\n            return \"pressed\";\n        case GLFW_RELEASE:\n            return \"released\";\n        case GLFW_REPEAT:\n            return \"repeated\";\n    }\n\n    return \"caused unknown action\";\n}\n\nstatic const char* get_button_name(int button)\n{\n    switch (button)\n    {\n        case GLFW_MOUSE_BUTTON_LEFT:\n            return \"left\";\n        case GLFW_MOUSE_BUTTON_RIGHT:\n            return \"right\";\n        case GLFW_MOUSE_BUTTON_MIDDLE:\n            return \"middle\";\n        default:\n        {\n            static char name[16];\n            sprintf(name, \"%i\", button);\n            return name;\n        }\n    }\n}\n\nstatic const char* get_mods_name(int mods)\n{\n    static char name[512];\n\n    if (mods == 0)\n        return \" no mods\";\n\n    name[0] = '\\0';\n\n    if (mods & GLFW_MOD_SHIFT)\n        strcat(name, \" shift\");\n    if (mods & GLFW_MOD_CONTROL)\n        strcat(name, \" control\");\n    if (mods & GLFW_MOD_ALT)\n        strcat(name, \" alt\");\n    if (mods & GLFW_MOD_SUPER)\n        strcat(name, \" super\");\n\n    return name;\n}\n\nstatic const char* get_character_string(int codepoint)\n{\n    // This assumes UTF-8, which is stupid\n    static char result[6 + 1];\n\n    int length = wctomb(result, codepoint);\n    if (length == -1)\n        length = 0;\n\n    result[length] = '\\0';\n    return result;\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void window_pos_callback(GLFWwindow* window, int x, int y)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window position: %i %i\\n\",\n           counter++, slot->number, glfwGetTime(), x, y);\n}\n\nstatic void window_size_callback(GLFWwindow* window, int width, int height)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window size: %i %i\\n\",\n           counter++, slot->number, glfwGetTime(), width, height);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Framebuffer size: %i %i\\n\",\n           counter++, slot->number, glfwGetTime(), width, height);\n\n    glViewport(0, 0, width, height);\n}\n\nstatic void window_close_callback(GLFWwindow* window)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window close\\n\",\n           counter++, slot->number, glfwGetTime());\n\n    glfwSetWindowShouldClose(window, slot->closeable);\n}\n\nstatic void window_refresh_callback(GLFWwindow* window)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window refresh\\n\",\n           counter++, slot->number, glfwGetTime());\n\n    glfwMakeContextCurrent(window);\n    glClear(GL_COLOR_BUFFER_BIT);\n    glfwSwapBuffers(window);\n}\n\nstatic void window_focus_callback(GLFWwindow* window, int focused)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window %s\\n\",\n           counter++, slot->number, glfwGetTime(),\n           focused ? \"focused\" : \"defocused\");\n}\n\nstatic void window_iconify_callback(GLFWwindow* window, int iconified)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Window was %s\\n\",\n           counter++, slot->number, glfwGetTime(),\n           iconified ? \"iconified\" : \"restored\");\n}\n\nstatic void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\\n\",\n           counter++, slot->number, glfwGetTime(), button,\n           get_button_name(button),\n           get_mods_name(mods),\n           get_action_name(action));\n}\n\nstatic void cursor_position_callback(GLFWwindow* window, double x, double y)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Cursor position: %f %f\\n\",\n           counter++, slot->number, glfwGetTime(), x, y);\n}\n\nstatic void cursor_enter_callback(GLFWwindow* window, int entered)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Cursor %s window\\n\",\n           counter++, slot->number, glfwGetTime(),\n           entered ? \"entered\" : \"left\");\n}\n\nstatic void scroll_callback(GLFWwindow* window, double x, double y)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Scroll: %0.3f %0.3f\\n\",\n           counter++, slot->number, glfwGetTime(), x, y);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n\n    printf(\"%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\\n\",\n           counter++, slot->number, glfwGetTime(), key, scancode,\n           get_key_name(key),\n           get_mods_name(mods),\n           get_action_name(action));\n\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_C:\n        {\n            slot->closeable = !slot->closeable;\n\n            printf(\"(( closing %s ))\\n\", slot->closeable ? \"enabled\" : \"disabled\");\n            break;\n        }\n    }\n}\n\nstatic void char_callback(GLFWwindow* window, unsigned int codepoint)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Character 0x%08x (%s) input\\n\",\n           counter++, slot->number, glfwGetTime(), codepoint,\n           get_character_string(codepoint));\n}\n\nstatic void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int mods)\n{\n    Slot* slot = glfwGetWindowUserPointer(window);\n    printf(\"%08x to %i at %0.3f: Character 0x%08x (%s) with modifiers (with%s) input\\n\",\n            counter++, slot->number, glfwGetTime(), codepoint,\n            get_character_string(codepoint),\n            get_mods_name(mods));\n}\n\nstatic void drop_callback(GLFWwindow* window, int count, const char** paths)\n{\n    int i;\n    Slot* slot = glfwGetWindowUserPointer(window);\n\n    printf(\"%08x to %i at %0.3f: Drop input\\n\",\n           counter++, slot->number, glfwGetTime());\n\n    for (i = 0;  i < count;  i++)\n        printf(\"  %i: \\\"%s\\\"\\n\", i, paths[i]);\n}\n\nstatic void monitor_callback(GLFWmonitor* monitor, int event)\n{\n    if (event == GLFW_CONNECTED)\n    {\n        int x, y, widthMM, heightMM;\n        const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\n        glfwGetMonitorPos(monitor, &x, &y);\n        glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);\n\n        printf(\"%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\\n\",\n               counter++,\n               glfwGetTime(),\n               glfwGetMonitorName(monitor),\n               mode->width, mode->height,\n               x, y,\n               widthMM, heightMM);\n    }\n    else\n    {\n        printf(\"%08x at %0.3f: Monitor %s was disconnected\\n\",\n               counter++,\n               glfwGetTime(),\n               glfwGetMonitorName(monitor));\n    }\n}\n\nint main(int argc, char** argv)\n{\n    Slot* slots;\n    GLFWmonitor* monitor = NULL;\n    int ch, i, width, height, count = 1;\n\n    setlocale(LC_ALL, \"\");\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    printf(\"Library initialized\\n\");\n\n    glfwSetMonitorCallback(monitor_callback);\n\n    while ((ch = getopt(argc, argv, \"hfn:\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n\n            case 'f':\n                monitor = glfwGetPrimaryMonitor();\n                break;\n\n            case 'n':\n                count = (int) strtol(optarg, NULL, 10);\n                break;\n\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    if (monitor)\n    {\n        const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n\n        width = mode->width;\n        height = mode->height;\n    }\n    else\n    {\n        width  = 640;\n        height = 480;\n    }\n\n    if (!count)\n    {\n        fprintf(stderr, \"Invalid user\\n\");\n        exit(EXIT_FAILURE);\n    }\n\n    slots = calloc(count, sizeof(Slot));\n\n    for (i = 0;  i < count;  i++)\n    {\n        char title[128];\n\n        slots[i].closeable = GL_TRUE;\n        slots[i].number = i + 1;\n\n        sprintf(title, \"Event Linter (Window %i)\", slots[i].number);\n\n        if (monitor)\n        {\n            printf(\"Creating full screen window %i (%ix%i on %s)\\n\",\n                   slots[i].number,\n                   width, height,\n                   glfwGetMonitorName(monitor));\n        }\n        else\n        {\n            printf(\"Creating windowed mode window %i (%ix%i)\\n\",\n                   slots[i].number,\n                   width, height);\n        }\n\n        slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL);\n        if (!slots[i].window)\n        {\n            free(slots);\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glfwSetWindowUserPointer(slots[i].window, slots + i);\n\n        glfwSetWindowPosCallback(slots[i].window, window_pos_callback);\n        glfwSetWindowSizeCallback(slots[i].window, window_size_callback);\n        glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback);\n        glfwSetWindowCloseCallback(slots[i].window, window_close_callback);\n        glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback);\n        glfwSetWindowFocusCallback(slots[i].window, window_focus_callback);\n        glfwSetWindowIconifyCallback(slots[i].window, window_iconify_callback);\n        glfwSetMouseButtonCallback(slots[i].window, mouse_button_callback);\n        glfwSetCursorPosCallback(slots[i].window, cursor_position_callback);\n        glfwSetCursorEnterCallback(slots[i].window, cursor_enter_callback);\n        glfwSetScrollCallback(slots[i].window, scroll_callback);\n        glfwSetKeyCallback(slots[i].window, key_callback);\n        glfwSetCharCallback(slots[i].window, char_callback);\n        glfwSetCharModsCallback(slots[i].window, char_mods_callback);\n        glfwSetDropCallback(slots[i].window, drop_callback);\n\n        glfwMakeContextCurrent(slots[i].window);\n        glfwSwapInterval(1);\n    }\n\n    printf(\"Main loop starting\\n\");\n\n    for (;;)\n    {\n        for (i = 0;  i < count;  i++)\n        {\n            if (glfwWindowShouldClose(slots[i].window))\n                break;\n        }\n\n        if (i < count)\n            break;\n\n        glfwWaitEvents();\n\n        // Workaround for an issue with msvcrt and mintty\n        fflush(stdout);\n    }\n\n    free(slots);\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/gamma.c",
    "content": "//========================================================================\n// Gamma correction test program\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This program is used to test the gamma correction functionality for\n// both full screen and windowed mode windows\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"getopt.h\"\n\n#define STEP_SIZE 0.1f\n\nstatic GLfloat gamma_value = 1.0f;\n\nstatic void usage(void)\n{\n    printf(\"Usage: gamma [-h] [-f]\\n\");\n}\n\nstatic void set_gamma(GLFWwindow* window, float value)\n{\n    GLFWmonitor* monitor = glfwGetWindowMonitor(window);\n    if (!monitor)\n        monitor = glfwGetPrimaryMonitor();\n\n    gamma_value = value;\n    printf(\"Gamma: %f\\n\", gamma_value);\n    glfwSetGamma(monitor, gamma_value);\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_ESCAPE:\n        {\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n        }\n\n        case GLFW_KEY_KP_ADD:\n        case GLFW_KEY_Q:\n        {\n            set_gamma(window, gamma_value + STEP_SIZE);\n            break;\n        }\n\n        case GLFW_KEY_KP_SUBTRACT:\n        case GLFW_KEY_W:\n        {\n            if (gamma_value - STEP_SIZE > 0.f)\n                set_gamma(window, gamma_value - STEP_SIZE);\n\n            break;\n        }\n    }\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nint main(int argc, char** argv)\n{\n    int width, height, ch;\n    GLFWmonitor* monitor = NULL;\n    GLFWwindow* window;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    while ((ch = getopt(argc, argv, \"fh\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n\n            case 'f':\n                monitor = glfwGetPrimaryMonitor();\n                break;\n\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    if (monitor)\n    {\n        const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n\n        width = mode->width;\n        height = mode->height;\n    }\n    else\n    {\n        width = 200;\n        height = 200;\n    }\n\n    window = glfwCreateWindow(width, height, \"Gamma Test\", monitor, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    set_gamma(window, 1.f);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetKeyCallback(window, key_callback);\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\n    glMatrixMode(GL_PROJECTION);\n    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);\n    glMatrixMode(GL_MODELVIEW);\n\n    glClearColor(0.5f, 0.5f, 0.5f, 0);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        glColor3f(0.8f, 0.2f, 0.4f);\n        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);\n\n        glfwSwapBuffers(window);\n        glfwWaitEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/glfwinfo.c",
    "content": "//========================================================================\n// Context creation and information tool\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n/* HACK: Explicitly include the glext.h shipping with GLFW, as this program uses\n *       many modern symbols not provided by the versions in some development\n *       environments (for example on OS X).\n */\n#include <GL/glext.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"getopt.h\"\n\n#ifdef _MSC_VER\n#define strcasecmp(x, y) _stricmp(x, y)\n#endif\n\n#define API_NAME_OPENGL     \"gl\"\n#define API_NAME_OPENGL_ES  \"es\"\n\n#define PROFILE_NAME_CORE   \"core\"\n#define PROFILE_NAME_COMPAT \"compat\"\n\n#define STRATEGY_NAME_NONE  \"none\"\n#define STRATEGY_NAME_LOSE  \"lose\"\n\n#define BEHAVIOR_NAME_NONE  \"none\"\n#define BEHAVIOR_NAME_FLUSH \"flush\"\n\nstatic void usage(void)\n{\n    printf(\"Usage: glfwinfo [OPTION]...\\n\");\n    printf(\"Options:\\n\");\n    printf(\"  -a, --client-api=API      the client API to use (\"\n                                        API_NAME_OPENGL \" or \"\n                                        API_NAME_OPENGL_ES \")\\n\");\n    printf(\"  -b, --behavior=BEHAVIOR   the release behavior to use (\"\n                                        BEHAVIOR_NAME_NONE \" or \"\n                                        BEHAVIOR_NAME_FLUSH \")\\n\");\n    printf(\"  -d, --debug               request a debug context\\n\");\n    printf(\"  -f, --forward             require a forward-compatible context\\n\");\n    printf(\"  -h, --help                show this help\\n\");\n    printf(\"  -l, --list-extensions     list all client API extensions\\n\");\n    printf(\"  -m, --major=MAJOR         the major number of the required \"\n                                        \"client API version\\n\");\n    printf(\"  -n, --minor=MINOR         the minor number of the required \"\n                                        \"client API version\\n\");\n    printf(\"  -p, --profile=PROFILE     the OpenGL profile to use (\"\n                                        PROFILE_NAME_CORE \" or \"\n                                        PROFILE_NAME_COMPAT \")\\n\");\n    printf(\"  -s, --robustness=STRATEGY the robustness strategy to use (\"\n                                        STRATEGY_NAME_NONE \" or \"\n                                        STRATEGY_NAME_LOSE \")\\n\");\n    printf(\"  -v, --version             print version information\\n\");\n    printf(\"      --red-bits=N          the number of red bits to request\\n\");\n    printf(\"      --green-bits=N        the number of green bits to request\\n\");\n    printf(\"      --blue-bits=N         the number of blue bits to request\\n\");\n    printf(\"      --alpha-bits=N        the number of alpha bits to request\\n\");\n    printf(\"      --depth-bits=N        the number of depth bits to request\\n\");\n    printf(\"      --stencil-bits=N      the number of stencil bits to request\\n\");\n    printf(\"      --accum-red-bits=N    the number of red bits to request\\n\");\n    printf(\"      --accum-green-bits=N  the number of green bits to request\\n\");\n    printf(\"      --accum-blue-bits=N   the number of blue bits to request\\n\");\n    printf(\"      --accum-alpha-bits=N  the number of alpha bits to request\\n\");\n    printf(\"      --aux-buffers=N       the number of aux buffers to request\\n\");\n    printf(\"      --samples=N           the number of MSAA samples to request\\n\");\n    printf(\"      --stereo              request stereo rendering\\n\");\n    printf(\"      --srgb                request an sRGB capable framebuffer\\n\");\n    printf(\"      --singlebuffer        request single-buffering\\n\");\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic const char* get_api_name(int api)\n{\n    if (api == GLFW_OPENGL_API)\n        return \"OpenGL\";\n    else if (api == GLFW_OPENGL_ES_API)\n        return \"OpenGL ES\";\n\n    return \"Unknown API\";\n}\n\nstatic const char* get_profile_name_gl(GLint mask)\n{\n    if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)\n        return PROFILE_NAME_COMPAT;\n    if (mask & GL_CONTEXT_CORE_PROFILE_BIT)\n        return PROFILE_NAME_CORE;\n\n    return \"unknown\";\n}\n\nstatic const char* get_profile_name_glfw(int profile)\n{\n    if (profile == GLFW_OPENGL_COMPAT_PROFILE)\n        return PROFILE_NAME_COMPAT;\n    if (profile == GLFW_OPENGL_CORE_PROFILE)\n        return PROFILE_NAME_CORE;\n\n    return \"unknown\";\n}\n\nstatic const char* get_strategy_name_gl(GLint strategy)\n{\n    if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)\n        return STRATEGY_NAME_LOSE;\n    if (strategy == GL_NO_RESET_NOTIFICATION_ARB)\n        return STRATEGY_NAME_NONE;\n\n    return \"unknown\";\n}\n\nstatic const char* get_strategy_name_glfw(int strategy)\n{\n    if (strategy == GLFW_LOSE_CONTEXT_ON_RESET)\n        return STRATEGY_NAME_LOSE;\n    if (strategy == GLFW_NO_RESET_NOTIFICATION)\n        return STRATEGY_NAME_NONE;\n\n    return \"unknown\";\n}\n\nstatic void list_extensions(int api, int major, int minor)\n{\n    int i;\n    GLint count;\n    const GLubyte* extensions;\n\n    printf(\"%s context supported extensions:\\n\", get_api_name(api));\n\n    if (api == GLFW_OPENGL_API && major > 2)\n    {\n        PFNGLGETSTRINGIPROC glGetStringi =\n            (PFNGLGETSTRINGIPROC) glfwGetProcAddress(\"glGetStringi\");\n        if (!glGetStringi)\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glGetIntegerv(GL_NUM_EXTENSIONS, &count);\n\n        for (i = 0;  i < count;  i++)\n            puts((const char*) glGetStringi(GL_EXTENSIONS, i));\n    }\n    else\n    {\n        extensions = glGetString(GL_EXTENSIONS);\n        while (*extensions != '\\0')\n        {\n            if (*extensions == ' ')\n                putchar('\\n');\n            else\n                putchar(*extensions);\n\n            extensions++;\n        }\n    }\n\n    putchar('\\n');\n}\n\nstatic GLboolean valid_version(void)\n{\n    int major, minor, revision;\n    glfwGetVersion(&major, &minor, &revision);\n\n    if (major != GLFW_VERSION_MAJOR)\n    {\n        printf(\"*** ERROR: GLFW major version mismatch! ***\\n\");\n        return GL_FALSE;\n    }\n\n    if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)\n        printf(\"*** WARNING: GLFW version mismatch! ***\\n\");\n\n    return GL_TRUE;\n}\n\nstatic void print_version(void)\n{\n    int major, minor, revision;\n    glfwGetVersion(&major, &minor, &revision);\n\n    printf(\"GLFW header version: %u.%u.%u\\n\",\n           GLFW_VERSION_MAJOR,\n           GLFW_VERSION_MINOR,\n           GLFW_VERSION_REVISION);\n    printf(\"GLFW library version: %u.%u.%u\\n\", major, minor, revision);\n    printf(\"GLFW library version string: \\\"%s\\\"\\n\", glfwGetVersionString());\n}\n\nint main(int argc, char** argv)\n{\n    int ch, api, major, minor, revision, profile;\n    GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits;\n    GLboolean list = GL_FALSE;\n    GLFWwindow* window;\n\n    enum { API, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS,\n           MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,\n           REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,\n           ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,\n           AUXBUFFERS, SAMPLES, STEREO, SRGB, SINGLEBUFFER };\n    const struct option options[] =\n    {\n        { \"behavior\",         1, NULL, BEHAVIOR },\n        { \"client-api\",       1, NULL, API },\n        { \"debug\",            0, NULL, DEBUG },\n        { \"forward\",          0, NULL, FORWARD },\n        { \"help\",             0, NULL, HELP },\n        { \"list-extensions\",  0, NULL, EXTENSIONS },\n        { \"major\",            1, NULL, MAJOR },\n        { \"minor\",            1, NULL, MINOR },\n        { \"profile\",          1, NULL, PROFILE },\n        { \"robustness\",       1, NULL, ROBUSTNESS },\n        { \"version\",          0, NULL, VERSION },\n        { \"red-bits\",         1, NULL, REDBITS },\n        { \"green-bits\",       1, NULL, GREENBITS },\n        { \"blue-bits\",        1, NULL, BLUEBITS },\n        { \"alpha-bits\",       1, NULL, ALPHABITS },\n        { \"depth-bits\",       1, NULL, DEPTHBITS },\n        { \"stencil-bits\",     1, NULL, STENCILBITS },\n        { \"accum-red-bits\",   1, NULL, ACCUMREDBITS },\n        { \"accum-green-bits\", 1, NULL, ACCUMGREENBITS },\n        { \"accum-blue-bits\",  1, NULL, ACCUMBLUEBITS },\n        { \"accum-alpha-bits\", 1, NULL, ACCUMALPHABITS },\n        { \"aux-buffers\",      1, NULL, AUXBUFFERS },\n        { \"samples\",          1, NULL, SAMPLES },\n        { \"stereo\",           0, NULL, STEREO },\n        { \"srgb\",             0, NULL, SRGB },\n        { \"singlebuffer\",     0, NULL, SINGLEBUFFER },\n        { NULL, 0, NULL, 0 }\n    };\n\n    // Initialize GLFW and create window\n\n    if (!valid_version())\n        exit(EXIT_FAILURE);\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    while ((ch = getopt_long(argc, argv, \"a:b:dfhlm:n:p:s:v\", options, NULL)) != -1)\n    {\n        switch (ch)\n        {\n            case 'a':\n            case API:\n                if (strcasecmp(optarg, API_NAME_OPENGL) == 0)\n                    glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);\n                else if (strcasecmp(optarg, API_NAME_OPENGL_ES) == 0)\n                    glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);\n                else\n                {\n                    usage();\n                    exit(EXIT_FAILURE);\n                }\n                break;\n            case 'b':\n            case BEHAVIOR:\n                if (strcasecmp(optarg, BEHAVIOR_NAME_NONE) == 0)\n                {\n                    glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR,\n                                   GLFW_RELEASE_BEHAVIOR_NONE);\n                }\n                else if (strcasecmp(optarg, BEHAVIOR_NAME_FLUSH) == 0)\n                {\n                    glfwWindowHint(GLFW_CONTEXT_RELEASE_BEHAVIOR,\n                                   GLFW_RELEASE_BEHAVIOR_FLUSH);\n                }\n                else\n                {\n                    usage();\n                    exit(EXIT_FAILURE);\n                }\n                break;\n            case 'd':\n            case DEBUG:\n                glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);\n                break;\n            case 'f':\n            case FORWARD:\n                glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);\n                break;\n            case 'h':\n            case HELP:\n                usage();\n                exit(EXIT_SUCCESS);\n            case 'l':\n            case EXTENSIONS:\n                list = GL_TRUE;\n                break;\n            case 'm':\n            case MAJOR:\n                glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, atoi(optarg));\n                break;\n            case 'n':\n            case MINOR:\n                glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, atoi(optarg));\n                break;\n            case 'p':\n            case PROFILE:\n                if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)\n                {\n                    glfwWindowHint(GLFW_OPENGL_PROFILE,\n                                   GLFW_OPENGL_CORE_PROFILE);\n                }\n                else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)\n                {\n                    glfwWindowHint(GLFW_OPENGL_PROFILE,\n                                   GLFW_OPENGL_COMPAT_PROFILE);\n                }\n                else\n                {\n                    usage();\n                    exit(EXIT_FAILURE);\n                }\n                break;\n            case 's':\n            case ROBUSTNESS:\n                if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)\n                {\n                    glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS,\n                                   GLFW_NO_RESET_NOTIFICATION);\n                }\n                else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)\n                {\n                    glfwWindowHint(GLFW_CONTEXT_ROBUSTNESS,\n                                   GLFW_LOSE_CONTEXT_ON_RESET);\n                }\n                else\n                {\n                    usage();\n                    exit(EXIT_FAILURE);\n                }\n                break;\n            case 'v':\n            case VERSION:\n                print_version();\n                exit(EXIT_SUCCESS);\n            case REDBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_RED_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_RED_BITS, atoi(optarg));\n                break;\n            case GREENBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_GREEN_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_GREEN_BITS, atoi(optarg));\n                break;\n            case BLUEBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_BLUE_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_BLUE_BITS, atoi(optarg));\n                break;\n            case ALPHABITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_ALPHA_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_ALPHA_BITS, atoi(optarg));\n                break;\n            case DEPTHBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_DEPTH_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_DEPTH_BITS, atoi(optarg));\n                break;\n            case STENCILBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_STENCIL_BITS, atoi(optarg));\n                break;\n            case ACCUMREDBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_ACCUM_RED_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_ACCUM_RED_BITS, atoi(optarg));\n                break;\n            case ACCUMGREENBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_ACCUM_GREEN_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_ACCUM_GREEN_BITS, atoi(optarg));\n                break;\n            case ACCUMBLUEBITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_ACCUM_BLUE_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_ACCUM_BLUE_BITS, atoi(optarg));\n                break;\n            case ACCUMALPHABITS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_ACCUM_ALPHA_BITS, atoi(optarg));\n                break;\n            case AUXBUFFERS:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_AUX_BUFFERS, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_AUX_BUFFERS, atoi(optarg));\n                break;\n            case SAMPLES:\n                if (strcmp(optarg, \"-\") == 0)\n                    glfwWindowHint(GLFW_SAMPLES, GLFW_DONT_CARE);\n                else\n                    glfwWindowHint(GLFW_SAMPLES, atoi(optarg));\n                break;\n            case STEREO:\n                glfwWindowHint(GLFW_STEREO, GL_TRUE);\n                break;\n            case SRGB:\n                glfwWindowHint(GLFW_SRGB_CAPABLE, GL_TRUE);\n                break;\n            case SINGLEBUFFER:\n                glfwWindowHint(GLFW_DOUBLEBUFFER, GL_FALSE);\n                break;\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    print_version();\n\n    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n\n    window = glfwCreateWindow(200, 200, \"Version\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n\n    // Report client API version\n\n    api = glfwGetWindowAttrib(window, GLFW_CLIENT_API);\n    major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);\n    minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);\n    revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);\n    profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);\n\n    printf(\"%s context version string: \\\"%s\\\"\\n\",\n           get_api_name(api),\n           glGetString(GL_VERSION));\n\n    printf(\"%s context version parsed by GLFW: %u.%u.%u\\n\",\n           get_api_name(api),\n           major, minor, revision);\n\n    // Report client API context properties\n\n    if (api == GLFW_OPENGL_API)\n    {\n        if (major >= 3)\n        {\n            GLint flags;\n\n            glGetIntegerv(GL_CONTEXT_FLAGS, &flags);\n            printf(\"%s context flags (0x%08x):\", get_api_name(api), flags);\n\n            if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)\n                printf(\" forward-compatible\");\n            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)\n                printf(\" debug\");\n            if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB)\n                printf(\" robustness\");\n            putchar('\\n');\n\n            printf(\"%s context flags parsed by GLFW:\", get_api_name(api));\n\n            if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT))\n                printf(\" forward-compatible\");\n            if (glfwGetWindowAttrib(window, GLFW_OPENGL_DEBUG_CONTEXT))\n                printf(\" debug\");\n            if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET)\n                printf(\" robustness\");\n            putchar('\\n');\n        }\n\n        if (major >= 4 || (major == 3 && minor >= 2))\n        {\n            GLint mask;\n            glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);\n\n            printf(\"%s profile mask (0x%08x): %s\\n\",\n                   get_api_name(api),\n                   mask,\n                   get_profile_name_gl(mask));\n\n            printf(\"%s profile mask parsed by GLFW: %s\\n\",\n                   get_api_name(api),\n                   get_profile_name_glfw(profile));\n        }\n\n        if (glfwExtensionSupported(\"GL_ARB_robustness\"))\n        {\n            const int robustness = glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS);\n            GLint strategy;\n            glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB, &strategy);\n\n            printf(\"%s robustness strategy (0x%08x): %s\\n\",\n                   get_api_name(api),\n                   strategy,\n                   get_strategy_name_gl(strategy));\n\n            printf(\"%s robustness strategy parsed by GLFW: %s\\n\",\n                   get_api_name(api),\n                   get_strategy_name_glfw(robustness));\n        }\n    }\n\n    printf(\"%s context renderer string: \\\"%s\\\"\\n\",\n           get_api_name(api),\n           glGetString(GL_RENDERER));\n    printf(\"%s context vendor string: \\\"%s\\\"\\n\",\n           get_api_name(api),\n           glGetString(GL_VENDOR));\n\n    if (major >= 2)\n    {\n        printf(\"%s context shading language version: \\\"%s\\\"\\n\",\n               get_api_name(api),\n               glGetString(GL_SHADING_LANGUAGE_VERSION));\n    }\n\n    printf(\"Framebuffer:\\n\");\n\n    if (api == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE)\n    {\n        PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC\n            glGetFramebufferAttachmentParameteriv =\n            (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)\n            glfwGetProcAddress(\"glGetFramebufferAttachmentParameteriv\");\n        if (!glGetFramebufferAttachmentParameteriv)\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_BACK_LEFT,\n                                              GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,\n                                              &redbits);\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_BACK_LEFT,\n                                              GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,\n                                              &greenbits);\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_BACK_LEFT,\n                                              GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE,\n                                              &bluebits);\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_BACK_LEFT,\n                                              GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,\n                                              &alphabits);\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_DEPTH,\n                                              GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE,\n                                              &depthbits);\n        glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,\n                                              GL_STENCIL,\n                                              GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,\n                                              &stencilbits);\n    }\n    else\n    {\n        glGetIntegerv(GL_RED_BITS, &redbits);\n        glGetIntegerv(GL_GREEN_BITS, &greenbits);\n        glGetIntegerv(GL_BLUE_BITS, &bluebits);\n        glGetIntegerv(GL_ALPHA_BITS, &alphabits);\n        glGetIntegerv(GL_DEPTH_BITS, &depthbits);\n        glGetIntegerv(GL_STENCIL_BITS, &stencilbits);\n    }\n\n    printf(\" red: %u green: %u blue: %u alpha: %u depth: %u stencil: %u\\n\",\n           redbits, greenbits, bluebits, alphabits, depthbits, stencilbits);\n\n    if (api == GLFW_OPENGL_ES_API ||\n        glfwExtensionSupported(\"GL_ARB_multisample\") ||\n        major > 1 || minor >= 3)\n    {\n        GLint samples, samplebuffers;\n        glGetIntegerv(GL_SAMPLES, &samples);\n        glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers);\n\n        printf(\" samples: %u sample buffers: %u\\n\", samples, samplebuffers);\n    }\n\n    if (api == GLFW_OPENGL_API && profile != GLFW_OPENGL_CORE_PROFILE)\n    {\n        GLint accumredbits, accumgreenbits, accumbluebits, accumalphabits;\n        GLint auxbuffers;\n\n        glGetIntegerv(GL_ACCUM_RED_BITS, &accumredbits);\n        glGetIntegerv(GL_ACCUM_GREEN_BITS, &accumgreenbits);\n        glGetIntegerv(GL_ACCUM_BLUE_BITS, &accumbluebits);\n        glGetIntegerv(GL_ACCUM_ALPHA_BITS, &accumalphabits);\n        glGetIntegerv(GL_AUX_BUFFERS, &auxbuffers);\n\n        printf(\" accum red: %u accum green: %u accum blue: %u accum alpha: %u aux buffers: %u\\n\",\n               accumredbits, accumgreenbits, accumbluebits, accumalphabits, auxbuffers);\n    }\n\n    // Report client API extensions\n    if (list)\n        list_extensions(api, major, minor);\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/iconify.c",
    "content": "//========================================================================\n// Iconify/restore test program\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This program is used to test the iconify/restore functionality for\n// both full screen and windowed mode windows\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"getopt.h\"\n\nstatic void usage(void)\n{\n    printf(\"Usage: iconify [-h] [-f [-a] [-n]]\\n\");\n    printf(\"Options:\\n\");\n    printf(\"  -a create windows for all monitors\\n\");\n    printf(\"  -f create full screen window(s)\\n\");\n    printf(\"  -h show this help\\n\");\n    printf(\"  -n no automatic iconification of full screen windows\\n\");\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    printf(\"%0.2f Key %s\\n\",\n           glfwGetTime(),\n           action == GLFW_PRESS ? \"pressed\" : \"released\");\n\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_SPACE:\n            glfwIconifyWindow(window);\n            break;\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n    }\n}\n\nstatic void window_size_callback(GLFWwindow* window, int width, int height)\n{\n    printf(\"%0.2f Window resized to %ix%i\\n\", glfwGetTime(), width, height);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    printf(\"%0.2f Framebuffer resized to %ix%i\\n\", glfwGetTime(), width, height);\n\n    glViewport(0, 0, width, height);\n}\n\nstatic void window_focus_callback(GLFWwindow* window, int focused)\n{\n    printf(\"%0.2f Window %s\\n\",\n           glfwGetTime(),\n           focused ? \"focused\" : \"defocused\");\n}\n\nstatic void window_iconify_callback(GLFWwindow* window, int iconified)\n{\n    printf(\"%0.2f Window %s\\n\",\n           glfwGetTime(),\n           iconified ? \"iconified\" : \"restored\");\n}\n\nstatic void window_refresh_callback(GLFWwindow* window)\n{\n    int width, height;\n\n    printf(\"%0.2f Window refresh\\n\", glfwGetTime());\n\n    glfwGetFramebufferSize(window, &width, &height);\n\n    glfwMakeContextCurrent(window);\n\n    glEnable(GL_SCISSOR_TEST);\n\n    glScissor(0, 0, width, height);\n    glClearColor(0, 0, 0, 0);\n    glClear(GL_COLOR_BUFFER_BIT);\n\n    glScissor(0, 0, 640, 480);\n    glClearColor(1, 1, 1, 0);\n    glClear(GL_COLOR_BUFFER_BIT);\n\n    glfwSwapBuffers(window);\n}\n\nstatic GLFWwindow* create_window(GLFWmonitor* monitor)\n{\n    int width, height;\n    GLFWwindow* window;\n\n    if (monitor)\n    {\n        const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n\n        width = mode->width;\n        height = mode->height;\n    }\n    else\n    {\n        width = 640;\n        height = 480;\n    }\n\n    window = glfwCreateWindow(width, height, \"Iconify\", monitor, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    return window;\n}\n\nint main(int argc, char** argv)\n{\n    int ch, i, window_count;\n    GLboolean auto_iconify = GL_TRUE, fullscreen = GL_FALSE, all_monitors = GL_FALSE;\n    GLFWwindow** windows;\n\n    while ((ch = getopt(argc, argv, \"afhn\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'a':\n                all_monitors = GL_TRUE;\n                break;\n\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n\n            case 'f':\n                fullscreen = GL_TRUE;\n                break;\n\n            case 'n':\n                auto_iconify = GL_FALSE;\n                break;\n\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    glfwWindowHint(GLFW_AUTO_ICONIFY, auto_iconify);\n\n    if (fullscreen && all_monitors)\n    {\n        int monitor_count;\n        GLFWmonitor** monitors = glfwGetMonitors(&monitor_count);\n\n        window_count = monitor_count;\n        windows = calloc(window_count, sizeof(GLFWwindow*));\n\n        for (i = 0;  i < monitor_count;  i++)\n        {\n            windows[i] = create_window(monitors[i]);\n            if (!windows[i])\n                break;\n        }\n    }\n    else\n    {\n        GLFWmonitor* monitor = NULL;\n\n        if (fullscreen)\n            monitor = glfwGetPrimaryMonitor();\n\n        window_count = 1;\n        windows = calloc(window_count, sizeof(GLFWwindow*));\n        windows[0] = create_window(monitor);\n    }\n\n    for (i = 0;  i < window_count;  i++)\n    {\n        glfwSetKeyCallback(windows[i], key_callback);\n        glfwSetFramebufferSizeCallback(windows[i], framebuffer_size_callback);\n        glfwSetWindowSizeCallback(windows[i], window_size_callback);\n        glfwSetWindowFocusCallback(windows[i], window_focus_callback);\n        glfwSetWindowIconifyCallback(windows[i], window_iconify_callback);\n        glfwSetWindowRefreshCallback(windows[i], window_refresh_callback);\n\n        window_refresh_callback(windows[i]);\n\n        printf(\"Window is %s and %s\\n\",\n            glfwGetWindowAttrib(windows[i], GLFW_ICONIFIED) ? \"iconified\" : \"restored\",\n            glfwGetWindowAttrib(windows[i], GLFW_FOCUSED) ? \"focused\" : \"defocused\");\n    }\n\n    for (;;)\n    {\n        glfwPollEvents();\n\n        for (i = 0;  i < window_count;  i++)\n        {\n            if (glfwWindowShouldClose(windows[i]))\n                break;\n        }\n\n        if (i < window_count)\n            break;\n\n        // Workaround for an issue with msvcrt and mintty\n        fflush(stdout);\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/joysticks.c",
    "content": "//========================================================================\n// Joystick input test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test displays the state of every button and axis of every connected\n// joystick and/or gamepad\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\n#ifdef _MSC_VER\n#define strdup(x) _strdup(x)\n#endif\n\ntypedef struct Joystick\n{\n    GLboolean present;\n    char* name;\n    float* axes;\n    unsigned char* buttons;\n    int axis_count;\n    int button_count;\n} Joystick;\n\nstatic Joystick joysticks[GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1 + 1];\nstatic int joystick_count = 0;\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nstatic void draw_joystick(Joystick* j, int x, int y, int width, int height)\n{\n    int i;\n    const int axis_height = 3 * height / 4;\n    const int button_height = height / 4;\n\n    if (j->axis_count)\n    {\n        const int axis_width = width / j->axis_count;\n\n        for (i = 0;  i < j->axis_count;  i++)\n        {\n            float value = j->axes[i] / 2.f + 0.5f;\n\n            glColor3f(0.3f, 0.3f, 0.3f);\n            glRecti(x + i * axis_width,\n                    y,\n                    x + (i + 1) * axis_width,\n                    y + axis_height);\n\n            glColor3f(1.f, 1.f, 1.f);\n            glRecti(x + i * axis_width,\n                    y + (int) (value * (axis_height - 5)),\n                    x + (i + 1) * axis_width,\n                    y + 5 + (int) (value * (axis_height - 5)));\n        }\n    }\n\n    if (j->button_count)\n    {\n        const int button_width = width / j->button_count;\n\n        for (i = 0;  i < j->button_count;  i++)\n        {\n            if (j->buttons[i])\n                glColor3f(1.f, 1.f, 1.f);\n            else\n                glColor3f(0.3f, 0.3f, 0.3f);\n\n            glRecti(x + i * button_width,\n                    y + axis_height,\n                    x + (i + 1) * button_width,\n                    y + axis_height + button_height);\n        }\n    }\n}\n\nstatic void draw_joysticks(GLFWwindow* window)\n{\n    int i, width, height, offset = 0;\n\n    glfwGetFramebufferSize(window, &width, &height);\n\n    glMatrixMode(GL_PROJECTION);\n    glLoadIdentity();\n    glOrtho(0.f, width, height, 0.f, 1.f, -1.f);\n    glMatrixMode(GL_MODELVIEW);\n\n    for (i = 0;  i < sizeof(joysticks) / sizeof(Joystick);  i++)\n    {\n        Joystick* j = joysticks + i;\n\n        if (j->present)\n        {\n            draw_joystick(j,\n                          0, offset * height / joystick_count,\n                          width, height / joystick_count);\n            offset++;\n        }\n    }\n}\n\nstatic void refresh_joysticks(void)\n{\n    int i;\n\n    for (i = 0;  i < sizeof(joysticks) / sizeof(Joystick);  i++)\n    {\n        Joystick* j = joysticks + i;\n\n        if (glfwJoystickPresent(GLFW_JOYSTICK_1 + i))\n        {\n            const float* axes;\n            const unsigned char* buttons;\n            int axis_count, button_count;\n\n            free(j->name);\n            j->name = strdup(glfwGetJoystickName(GLFW_JOYSTICK_1 + i));\n\n            axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1 + i, &axis_count);\n            if (axis_count != j->axis_count)\n            {\n                j->axis_count = axis_count;\n                j->axes = realloc(j->axes, j->axis_count * sizeof(float));\n            }\n\n            memcpy(j->axes, axes, axis_count * sizeof(float));\n\n            buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1 + i, &button_count);\n            if (button_count != j->button_count)\n            {\n                j->button_count = button_count;\n                j->buttons = realloc(j->buttons, j->button_count);\n            }\n\n            memcpy(j->buttons, buttons, button_count * sizeof(unsigned char));\n\n            if (!j->present)\n            {\n                printf(\"Found joystick %i named \\'%s\\' with %i axes, %i buttons\\n\",\n                       i + 1, j->name, j->axis_count, j->button_count);\n\n                joystick_count++;\n            }\n\n            j->present = GL_TRUE;\n        }\n        else\n        {\n            if (j->present)\n            {\n                printf(\"Lost joystick %i named \\'%s\\'\\n\", i + 1, j->name);\n\n                free(j->name);\n                free(j->axes);\n                free(j->buttons);\n                memset(j, 0, sizeof(Joystick));\n\n                joystick_count--;\n            }\n        }\n    }\n}\n\nint main(void)\n{\n    GLFWwindow* window;\n\n    memset(joysticks, 0, sizeof(joysticks));\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    window = glfwCreateWindow(640, 480, \"Joystick Test\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        refresh_joysticks();\n        draw_joysticks(window);\n\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/monitors.c",
    "content": "//========================================================================\n// Monitor information tool\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test prints monitor and video mode information or verifies video\n// modes\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\n#include \"getopt.h\"\n\nenum Mode\n{\n    LIST_MODE,\n    TEST_MODE\n};\n\nstatic void usage(void)\n{\n    printf(\"Usage: monitors [-t]\\n\");\n    printf(\"       monitors -h\\n\");\n}\n\nstatic const char* format_mode(const GLFWvidmode* mode)\n{\n    static char buffer[512];\n\n    sprintf(buffer,\n            \"%i x %i x %i (%i %i %i) %i Hz\",\n            mode->width, mode->height,\n            mode->redBits + mode->greenBits + mode->blueBits,\n            mode->redBits, mode->greenBits, mode->blueBits,\n            mode->refreshRate);\n\n    buffer[sizeof(buffer) - 1] = '\\0';\n    return buffer;\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    printf(\"Framebuffer resized to %ix%i\\n\", width, height);\n\n    glViewport(0, 0, width, height);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (key == GLFW_KEY_ESCAPE)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\nstatic void list_modes(GLFWmonitor* monitor)\n{\n    int count, x, y, widthMM, heightMM, i;\n    const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n    const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);\n\n    glfwGetMonitorPos(monitor, &x, &y);\n    glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);\n\n    printf(\"Name: %s (%s)\\n\",\n           glfwGetMonitorName(monitor),\n           glfwGetPrimaryMonitor() == monitor ? \"primary\" : \"secondary\");\n    printf(\"Current mode: %s\\n\", format_mode(mode));\n    printf(\"Virtual position: %i %i\\n\", x, y);\n\n    printf(\"Physical size: %i x %i mm (%0.2f dpi)\\n\",\n           widthMM, heightMM, mode->width * 25.4f / widthMM);\n\n    printf(\"Modes:\\n\");\n\n    for (i = 0;  i < count;  i++)\n    {\n        printf(\"%3u: %s\", (unsigned int) i, format_mode(modes + i));\n\n        if (memcmp(mode, modes + i, sizeof(GLFWvidmode)) == 0)\n            printf(\" (current mode)\");\n\n        putchar('\\n');\n    }\n}\n\nstatic void test_modes(GLFWmonitor* monitor)\n{\n    int i, count;\n    GLFWwindow* window;\n    const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);\n\n    for (i = 0;  i < count;  i++)\n    {\n        const GLFWvidmode* mode = modes + i;\n        GLFWvidmode current;\n\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n\n        printf(\"Testing mode %u on monitor %s: %s\\n\",\n               (unsigned int) i,\n               glfwGetMonitorName(monitor),\n               format_mode(mode));\n\n        window = glfwCreateWindow(mode->width, mode->height,\n                                  \"Video Mode Test\",\n                                  glfwGetPrimaryMonitor(),\n                                  NULL);\n        if (!window)\n        {\n            printf(\"Failed to enter mode %u: %s\\n\",\n                   (unsigned int) i,\n                   format_mode(mode));\n            continue;\n        }\n\n        glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n        glfwSetKeyCallback(window, key_callback);\n\n        glfwMakeContextCurrent(window);\n        glfwSwapInterval(1);\n\n        glfwSetTime(0.0);\n\n        while (glfwGetTime() < 5.0)\n        {\n            glClear(GL_COLOR_BUFFER_BIT);\n            glfwSwapBuffers(window);\n            glfwPollEvents();\n\n            if (glfwWindowShouldClose(window))\n            {\n                printf(\"User terminated program\\n\");\n\n                glfwTerminate();\n                exit(EXIT_SUCCESS);\n            }\n        }\n\n        glGetIntegerv(GL_RED_BITS, &current.redBits);\n        glGetIntegerv(GL_GREEN_BITS, &current.greenBits);\n        glGetIntegerv(GL_BLUE_BITS, &current.blueBits);\n\n        glfwGetWindowSize(window, &current.width, &current.height);\n\n        if (current.redBits != mode->redBits ||\n            current.greenBits != mode->greenBits ||\n            current.blueBits != mode->blueBits)\n        {\n            printf(\"*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\\n\",\n                   current.redBits, current.greenBits, current.blueBits,\n                   mode->redBits, mode->greenBits, mode->blueBits);\n        }\n\n        if (current.width != mode->width || current.height != mode->height)\n        {\n            printf(\"*** Size mismatch: %ix%i instead of %ix%i\\n\",\n                   current.width, current.height,\n                   mode->width, mode->height);\n        }\n\n        printf(\"Closing window\\n\");\n\n        glfwDestroyWindow(window);\n        window = NULL;\n\n        glfwPollEvents();\n    }\n}\n\nint main(int argc, char** argv)\n{\n    int ch, i, count, mode = LIST_MODE;\n    GLFWmonitor** monitors;\n\n    while ((ch = getopt(argc, argv, \"th\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n            case 't':\n                mode = TEST_MODE;\n                break;\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    monitors = glfwGetMonitors(&count);\n\n    for (i = 0;  i < count;  i++)\n    {\n        if (mode == LIST_MODE)\n            list_modes(monitors[i]);\n        else if (mode == TEST_MODE)\n            test_modes(monitors[i]);\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/msaa.c",
    "content": "//========================================================================\n// Multisample anti-aliasing test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test renders two high contrast, slowly rotating quads, one aliased\n// and one (hopefully) anti-aliased, thus allowing for visual verification\n// of whether MSAA is indeed enabled\n//\n//========================================================================\n\n#define GLFW_INCLUDE_GLEXT\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"getopt.h\"\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_SPACE:\n            glfwSetTime(0.0);\n            break;\n    }\n}\n\nstatic void usage(void)\n{\n    printf(\"Usage: msaa [-h] [-s SAMPLES]\\n\");\n}\n\nint main(int argc, char** argv)\n{\n    int ch, samples = 4;\n    GLFWwindow* window;\n\n    while ((ch = getopt(argc, argv, \"hs:\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n            case 's':\n                samples = atoi(optarg);\n                break;\n            default:\n                usage();\n                exit(EXIT_FAILURE);\n        }\n    }\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    if (samples)\n        printf(\"Requesting MSAA with %i samples\\n\", samples);\n    else\n        printf(\"Requesting that MSAA not be available\\n\");\n\n    glfwWindowHint(GLFW_SAMPLES, samples);\n    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n\n    window = glfwCreateWindow(800, 400, \"Aliasing Detector\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwSetKeyCallback(window, key_callback);\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    if (!glfwExtensionSupported(\"GL_ARB_multisample\"))\n    {\n        printf(\"GL_ARB_multisample extension not supported\\n\");\n\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwShowWindow(window);\n\n    glGetIntegerv(GL_SAMPLES_ARB, &samples);\n    if (samples)\n        printf(\"Context reports MSAA is available with %i samples\\n\", samples);\n    else\n        printf(\"Context reports MSAA is unavailable\\n\");\n\n    glMatrixMode(GL_PROJECTION);\n    glOrtho(0.f, 1.f, 0.f, 0.5f, 0.f, 1.f);\n    glMatrixMode(GL_MODELVIEW);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        GLfloat time = (GLfloat) glfwGetTime();\n\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        glLoadIdentity();\n        glTranslatef(0.25f, 0.25f, 0.f);\n        glRotatef(time, 0.f, 0.f, 1.f);\n\n        glDisable(GL_MULTISAMPLE_ARB);\n        glRectf(-0.15f, -0.15f, 0.15f, 0.15f);\n\n        glLoadIdentity();\n        glTranslatef(0.75f, 0.25f, 0.f);\n        glRotatef(time, 0.f, 0.f, 1.f);\n\n        glEnable(GL_MULTISAMPLE_ARB);\n        glRectf(-0.15f, -0.15f, 0.15f, 0.15f);\n\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/reopen.c",
    "content": "//========================================================================\n// Window re-opener (open/close stress test)\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test came about as the result of bug #1262773\n//\n// It closes and re-opens the GLFW window every five seconds, alternating\n// between windowed and full screen mode\n//\n// It also times and logs opening and closing actions and attempts to separate\n// user initiated window closing from its own\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <time.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nstatic void window_close_callback(GLFWwindow* window)\n{\n    printf(\"Close callback triggered\\n\");\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_Q:\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n    }\n}\n\nstatic GLFWwindow* open_window(int width, int height, GLFWmonitor* monitor)\n{\n    double base;\n    GLFWwindow* window;\n\n    base = glfwGetTime();\n\n    window = glfwCreateWindow(width, height, \"Window Re-opener\", monitor, NULL);\n    if (!window)\n        return NULL;\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n    glfwSetWindowCloseCallback(window, window_close_callback);\n    glfwSetKeyCallback(window, key_callback);\n\n    if (monitor)\n    {\n        printf(\"Opening full screen window on monitor %s took %0.3f seconds\\n\",\n               glfwGetMonitorName(monitor),\n               glfwGetTime() - base);\n    }\n    else\n    {\n        printf(\"Opening regular window took %0.3f seconds\\n\",\n               glfwGetTime() - base);\n    }\n\n    return window;\n}\n\nstatic void close_window(GLFWwindow* window)\n{\n    double base = glfwGetTime();\n    glfwDestroyWindow(window);\n    printf(\"Closing window took %0.3f seconds\\n\", glfwGetTime() - base);\n}\n\nint main(int argc, char** argv)\n{\n    int count = 0;\n    GLFWwindow* window;\n\n    srand((unsigned int) time(NULL));\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    for (;;)\n    {\n        int width, height;\n        GLFWmonitor* monitor = NULL;\n\n        if (count % 2 == 0)\n        {\n            int monitorCount;\n            GLFWmonitor** monitors = glfwGetMonitors(&monitorCount);\n            monitor = monitors[rand() % monitorCount];\n        }\n\n        if (monitor)\n        {\n            const GLFWvidmode* mode = glfwGetVideoMode(monitor);\n            width = mode->width;\n            height = mode->height;\n        }\n        else\n        {\n            width = 640;\n            height = 480;\n        }\n\n        window = open_window(width, height, monitor);\n        if (!window)\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glMatrixMode(GL_PROJECTION);\n        glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);\n        glMatrixMode(GL_MODELVIEW);\n\n        glfwSetTime(0.0);\n\n        while (glfwGetTime() < 5.0)\n        {\n            glClear(GL_COLOR_BUFFER_BIT);\n\n            glPushMatrix();\n            glRotatef((GLfloat) glfwGetTime() * 100.f, 0.f, 0.f, 1.f);\n            glRectf(-0.5f, -0.5f, 1.f, 1.f);\n            glPopMatrix();\n\n            glfwSwapBuffers(window);\n            glfwPollEvents();\n\n            if (glfwWindowShouldClose(window))\n            {\n                close_window(window);\n                printf(\"User closed window\\n\");\n\n                glfwTerminate();\n                exit(EXIT_SUCCESS);\n            }\n        }\n\n        printf(\"Closing window\\n\");\n        close_window(window);\n\n        count++;\n    }\n\n    glfwTerminate();\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/sharing.c",
    "content": "//========================================================================\n// Context sharing test program\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This program is used to test sharing of objects between contexts\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#define WIDTH  400\n#define HEIGHT 400\n#define OFFSET 50\n\nstatic GLFWwindow* windows[2];\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)\n        glfwSetWindowShouldClose(window, GL_TRUE);\n}\n\nstatic GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, int posY)\n{\n    GLFWwindow* window;\n\n    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n    window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share);\n    if (!window)\n        return NULL;\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n    glfwSetWindowPos(window, posX, posY);\n    glfwShowWindow(window);\n\n    glfwSetKeyCallback(window, key_callback);\n\n    return window;\n}\n\nstatic GLuint create_texture(void)\n{\n    int x, y;\n    char pixels[256 * 256];\n    GLuint texture;\n\n    glGenTextures(1, &texture);\n    glBindTexture(GL_TEXTURE_2D, texture);\n\n    for (y = 0;  y < 256;  y++)\n    {\n        for (x = 0;  x < 256;  x++)\n            pixels[y * 256 + x] = rand() % 256;\n    }\n\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n\n    return texture;\n}\n\nstatic void draw_quad(GLuint texture)\n{\n    int width, height;\n    glfwGetFramebufferSize(glfwGetCurrentContext(), &width, &height);\n\n    glViewport(0, 0, width, height);\n\n    glMatrixMode(GL_PROJECTION);\n    glLoadIdentity();\n    glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f);\n\n    glEnable(GL_TEXTURE_2D);\n    glBindTexture(GL_TEXTURE_2D, texture);\n    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);\n\n    glBegin(GL_QUADS);\n\n    glTexCoord2f(0.f, 0.f);\n    glVertex2f(0.f, 0.f);\n\n    glTexCoord2f(1.f, 0.f);\n    glVertex2f(1.f, 0.f);\n\n    glTexCoord2f(1.f, 1.f);\n    glVertex2f(1.f, 1.f);\n\n    glTexCoord2f(0.f, 1.f);\n    glVertex2f(0.f, 1.f);\n\n    glEnd();\n}\n\nint main(int argc, char** argv)\n{\n    int x, y, width;\n    GLuint texture;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    windows[0] = open_window(\"First\", NULL, OFFSET, OFFSET);\n    if (!windows[0])\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    // This is the one and only time we create a texture\n    // It is created inside the first context, created above\n    // It will then be shared with the second context, created below\n    texture = create_texture();\n\n    glfwGetWindowPos(windows[0], &x, &y);\n    glfwGetWindowSize(windows[0], &width, NULL);\n\n    // Put the second window to the right of the first one\n    windows[1] = open_window(\"Second\", windows[0], x + width + OFFSET, y);\n    if (!windows[1])\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    // Set drawing color for both contexts\n    glfwMakeContextCurrent(windows[0]);\n    glColor3f(0.6f, 0.f, 0.6f);\n    glfwMakeContextCurrent(windows[1]);\n    glColor3f(0.6f, 0.6f, 0.f);\n\n    glfwMakeContextCurrent(windows[0]);\n\n    while (!glfwWindowShouldClose(windows[0]) &&\n           !glfwWindowShouldClose(windows[1]))\n    {\n        glfwMakeContextCurrent(windows[0]);\n        draw_quad(texture);\n\n        glfwMakeContextCurrent(windows[1]);\n        draw_quad(texture);\n\n        glfwSwapBuffers(windows[0]);\n        glfwSwapBuffers(windows[1]);\n\n        glfwWaitEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/tearing.c",
    "content": "//========================================================================\n// Vsync enabling test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test renders a high contrast, horizontally moving bar, allowing for\n// visual verification of whether the set swap interval is indeed obeyed\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\n#include \"getopt.h\"\n\nstatic GLboolean swap_tear;\nstatic int swap_interval;\nstatic double frame_rate;\n\nstatic void usage(void)\n{\n    printf(\"Usage: iconify [-h] [-f]\\n\");\n    printf(\"Options:\\n\");\n    printf(\"  -f create full screen window\\n\");\n    printf(\"  -h show this help\\n\");\n}\n\nstatic void update_window_title(GLFWwindow* window)\n{\n    char title[256];\n\n    sprintf(title, \"Tearing detector (interval %i%s, %0.1f Hz)\",\n            swap_interval,\n            (swap_tear && swap_interval < 0) ? \" (swap tear)\" : \"\",\n            frame_rate);\n\n    glfwSetWindowTitle(window, title);\n}\n\nstatic void set_swap_interval(GLFWwindow* window, int interval)\n{\n    swap_interval = interval;\n    glfwSwapInterval(swap_interval);\n    update_window_title(window);\n}\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_UP:\n        {\n            if (swap_interval + 1 > swap_interval)\n                set_swap_interval(window, swap_interval + 1);\n            break;\n        }\n\n        case GLFW_KEY_DOWN:\n        {\n            if (swap_tear)\n            {\n                if (swap_interval - 1 < swap_interval)\n                    set_swap_interval(window, swap_interval - 1);\n            }\n            else\n            {\n                if (swap_interval - 1 >= 0)\n                    set_swap_interval(window, swap_interval - 1);\n            }\n            break;\n        }\n\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, 1);\n            break;\n    }\n}\n\nint main(int argc, char** argv)\n{\n    int ch, width, height;\n    float position;\n    unsigned long frame_count = 0;\n    double last_time, current_time;\n    GLboolean fullscreen = GL_FALSE;\n    GLFWmonitor* monitor = NULL;\n    GLFWwindow* window;\n\n    while ((ch = getopt(argc, argv, \"fh\")) != -1)\n    {\n        switch (ch)\n        {\n            case 'h':\n                usage();\n                exit(EXIT_SUCCESS);\n\n            case 'f':\n                fullscreen = GL_TRUE;\n                break;\n        }\n    }\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    if (fullscreen)\n    {\n        const GLFWvidmode* mode;\n\n        monitor = glfwGetPrimaryMonitor();\n        mode = glfwGetVideoMode(monitor);\n\n        glfwWindowHint(GLFW_RED_BITS, mode->redBits);\n        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);\n        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);\n        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);\n\n        width = mode->width;\n        height = mode->height;\n    }\n    else\n    {\n        width = 640;\n        height = 480;\n    }\n\n    window = glfwCreateWindow(width, height, \"\", monitor, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n    set_swap_interval(window, 0);\n\n    last_time = glfwGetTime();\n    frame_rate = 0.0;\n    swap_tear = (glfwExtensionSupported(\"WGL_EXT_swap_control_tear\") ||\n                 glfwExtensionSupported(\"GLX_EXT_swap_control_tear\"));\n\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n    glfwSetKeyCallback(window, key_callback);\n\n    glMatrixMode(GL_PROJECTION);\n    glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);\n    glMatrixMode(GL_MODELVIEW);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n\n        position = cosf((float) glfwGetTime() * 4.f) * 0.75f;\n        glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f);\n\n        glfwSwapBuffers(window);\n        glfwPollEvents();\n\n        frame_count++;\n\n        current_time = glfwGetTime();\n        if (current_time - last_time > 1.0)\n        {\n            frame_rate = frame_count / (current_time - last_time);\n            frame_count = 0;\n            last_time = current_time;\n            update_window_title(window);\n        }\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/threads.c",
    "content": "//========================================================================\n// Multi-threading test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test is intended to verify whether the OpenGL context part of\n// the GLFW API is able to be used from multiple threads\n//\n//========================================================================\n\n#include \"tinycthread.h\"\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\ntypedef struct\n{\n    GLFWwindow* window;\n    const char* title;\n    float r, g, b;\n    thrd_t id;\n} Thread;\n\nstatic volatile GLboolean running = GL_TRUE;\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic int thread_main(void* data)\n{\n    const Thread* thread = data;\n\n    glfwMakeContextCurrent(thread->window);\n    glfwSwapInterval(1);\n\n    while (running)\n    {\n        const float v = (float) fabs(sin(glfwGetTime() * 2.f));\n        glClearColor(thread->r * v, thread->g * v, thread->b * v, 0.f);\n\n        glClear(GL_COLOR_BUFFER_BIT);\n        glfwSwapBuffers(thread->window);\n    }\n\n    glfwMakeContextCurrent(NULL);\n    return 0;\n}\n\nint main(void)\n{\n    int i, result;\n    Thread threads[] =\n    {\n        { NULL, \"Red\", 1.f, 0.f, 0.f, 0 },\n        { NULL, \"Green\", 0.f, 1.f, 0.f, 0 },\n        { NULL, \"Blue\", 0.f, 0.f, 1.f, 0 }\n    };\n    const int count = sizeof(threads) / sizeof(Thread);\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n\n    for (i = 0;  i < count;  i++)\n    {\n        threads[i].window = glfwCreateWindow(200, 200,\n                                             threads[i].title,\n                                             NULL, NULL);\n        if (!threads[i].window)\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);\n        glfwShowWindow(threads[i].window);\n\n        if (thrd_create(&threads[i].id, thread_main, threads + i) !=\n            thrd_success)\n        {\n            fprintf(stderr, \"Failed to create secondary thread\\n\");\n\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n    }\n\n    while (running)\n    {\n        glfwWaitEvents();\n\n        for (i = 0;  i < count;  i++)\n        {\n            if (glfwWindowShouldClose(threads[i].window))\n                running = GL_FALSE;\n        }\n    }\n\n    for (i = 0;  i < count;  i++)\n        glfwHideWindow(threads[i].window);\n\n    for (i = 0;  i < count;  i++)\n        thrd_join(threads[i].id, &result);\n\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/title.c",
    "content": "//========================================================================\n// UTF-8 window title test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test sets a UTF-8 window title\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void framebuffer_size_callback(GLFWwindow* window, int width, int height)\n{\n    glViewport(0, 0, width, height);\n}\n\nint main(void)\n{\n    GLFWwindow* window;\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    window = glfwCreateWindow(400, 400, \"English 日本語 русский язык 官話\", NULL, NULL);\n    if (!window)\n    {\n        glfwTerminate();\n        exit(EXIT_FAILURE);\n    }\n\n    glfwMakeContextCurrent(window);\n    glfwSwapInterval(1);\n\n    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);\n\n    while (!glfwWindowShouldClose(window))\n    {\n        glClear(GL_COLOR_BUFFER_BIT);\n        glfwSwapBuffers(window);\n        glfwWaitEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/glfw/tests/windows.c",
    "content": "//========================================================================\n// Simple multi-window test\n// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//    claim that you wrote the original software. If you use this software\n//    in a product, an acknowledgment in the product documentation would\n//    be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such, and must not\n//    be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source\n//    distribution.\n//\n//========================================================================\n//\n// This test creates four windows and clears each in a different color\n//\n//========================================================================\n\n#include <GLFW/glfw3.h>\n\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic const char* titles[] =\n{\n    \"Red\",\n    \"Green\",\n    \"Blue\",\n    \"Yellow\"\n};\n\nstatic const struct\n{\n    float r, g, b;\n} colors[] =\n{\n    { 0.95f, 0.32f, 0.11f },\n    { 0.50f, 0.80f, 0.16f },\n    {   0.f, 0.68f, 0.94f },\n    { 0.98f, 0.74f, 0.04f }\n};\n\nstatic void error_callback(int error, const char* description)\n{\n    fprintf(stderr, \"Error: %s\\n\", description);\n}\n\nstatic void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)\n{\n    if (action != GLFW_PRESS)\n        return;\n\n    switch (key)\n    {\n        case GLFW_KEY_SPACE:\n        {\n            int xpos, ypos;\n            glfwGetWindowPos(window, &xpos, &ypos);\n            glfwSetWindowPos(window, xpos, ypos);\n            break;\n        }\n\n        case GLFW_KEY_ESCAPE:\n            glfwSetWindowShouldClose(window, GL_TRUE);\n            break;\n    }\n}\n\nint main(int argc, char** argv)\n{\n    int i;\n    GLboolean running = GL_TRUE;\n    GLFWwindow* windows[4];\n\n    glfwSetErrorCallback(error_callback);\n\n    if (!glfwInit())\n        exit(EXIT_FAILURE);\n\n    glfwWindowHint(GLFW_DECORATED, GL_FALSE);\n    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);\n\n    for (i = 0;  i < 4;  i++)\n    {\n        int left, top, right, bottom;\n\n        windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL);\n        if (!windows[i])\n        {\n            glfwTerminate();\n            exit(EXIT_FAILURE);\n        }\n\n        glfwSetKeyCallback(windows[i], key_callback);\n\n        glfwMakeContextCurrent(windows[i]);\n        glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f);\n\n        glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);\n        glfwSetWindowPos(windows[i],\n                         100 + (i & 1) * (200 + left + right),\n                         100 + (i >> 1) * (200 + top + bottom));\n    }\n\n    for (i = 0;  i < 4;  i++)\n        glfwShowWindow(windows[i]);\n\n    while (running)\n    {\n        for (i = 0;  i < 4;  i++)\n        {\n            glfwMakeContextCurrent(windows[i]);\n            glClear(GL_COLOR_BUFFER_BIT);\n            glfwSwapBuffers(windows[i]);\n\n            if (glfwWindowShouldClose(windows[i]))\n                running = GL_FALSE;\n        }\n\n        glfwPollEvents();\n    }\n\n    glfwTerminate();\n    exit(EXIT_SUCCESS);\n}\n\n"
  },
  {
    "path": "deps/lodepng/lodepng.c",
    "content": "/*\nLodePNG version 20131115\n\nCopyright (c) 2005-2013 Lode Vandevenne\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n/*\nThe manual and changelog are in the header file \"lodepng.h\"\nRename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for C.\n*/\n\n#include \"lodepng.h\"\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#ifdef LODEPNG_COMPILE_CPP\n#include <fstream>\n#endif /*LODEPNG_COMPILE_CPP*/\n\n#define VERSION_STRING \"20131115\"\n\n/*\nThis source file is built up in the following large parts. The code sections\nwith the \"LODEPNG_COMPILE_\" #defines divide this up further in an intermixed way.\n-Tools for C and common code for PNG and Zlib\n-C Code for Zlib (huffman, deflate, ...)\n-C Code for PNG (file format chunks, adam7, PNG filters, color conversions, ...)\n-The C++ wrapper around all of the above\n*/\n\n/*The malloc, realloc and free functions defined here with \"lodepng_\" in front\nof the name, so that you can easily change them to others related to your\nplatform if needed. Everything else in the code calls these. Pass\n-DLODEPNG_NO_COMPILE_ALLOCATORS to the compiler, or comment out\n#define LODEPNG_COMPILE_ALLOCATORS in the header, to disable the ones here and\ndefine them in your own project's source files without needing to change\nlodepng source code. Don't forget to remove \"static\" if you copypaste them\nfrom here.*/\n\n#ifdef LODEPNG_COMPILE_ALLOCATORS\nstatic void* lodepng_malloc(size_t size)\n{\n  return malloc(size);\n}\n\nstatic void* lodepng_realloc(void* ptr, size_t new_size)\n{\n  return realloc(ptr, new_size);\n}\n\nstatic void lodepng_free(void* ptr)\n{\n  free(ptr);\n}\n#else /*LODEPNG_COMPILE_ALLOCATORS*/\nvoid* lodepng_malloc(size_t size);\nvoid* lodepng_realloc(void* ptr, size_t new_size);\nvoid lodepng_free(void* ptr);\n#endif /*LODEPNG_COMPILE_ALLOCATORS*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* // Tools for C, and common code for PNG and Zlib.                       // */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*\nOften in case of an error a value is assigned to a variable and then it breaks\nout of a loop (to go to the cleanup phase of a function). This macro does that.\nIt makes the error handling code shorter and more readable.\n\nExample: if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83);\n*/\n#define CERROR_BREAK(errorvar, code)\\\n{\\\n  errorvar = code;\\\n  break;\\\n}\n\n/*version of CERROR_BREAK that assumes the common case where the error variable is named \"error\"*/\n#define ERROR_BREAK(code) CERROR_BREAK(error, code)\n\n/*Set error var to the error code, and return it.*/\n#define CERROR_RETURN_ERROR(errorvar, code)\\\n{\\\n  errorvar = code;\\\n  return code;\\\n}\n\n/*Try the code, if it returns error, also return the error.*/\n#define CERROR_TRY_RETURN(call)\\\n{\\\n  unsigned error = call;\\\n  if(error) return error;\\\n}\n\n/*\nAbout uivector, ucvector and string:\n-All of them wrap dynamic arrays or text strings in a similar way.\n-LodePNG was originally written in C++. The vectors replace the std::vectors that were used in the C++ version.\n-The string tools are made to avoid problems with compilers that declare things like strncat as deprecated.\n-They're not used in the interface, only internally in this file as static functions.\n-As with many other structs in this file, the init and cleanup functions serve as ctor and dtor.\n*/\n\n#ifdef LODEPNG_COMPILE_ZLIB\n/*dynamic vector of unsigned ints*/\ntypedef struct uivector\n{\n  unsigned* data;\n  size_t size; /*size in number of unsigned longs*/\n  size_t allocsize; /*allocated size in bytes*/\n} uivector;\n\nstatic void uivector_cleanup(void* p)\n{\n  ((uivector*)p)->size = ((uivector*)p)->allocsize = 0;\n  lodepng_free(((uivector*)p)->data);\n  ((uivector*)p)->data = NULL;\n}\n\n/*returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned uivector_resize(uivector* p, size_t size)\n{\n  if(size * sizeof(unsigned) > p->allocsize)\n  {\n    size_t newsize = size * sizeof(unsigned) * 2;\n    void* data = lodepng_realloc(p->data, newsize);\n    if(data)\n    {\n      p->allocsize = newsize;\n      p->data = (unsigned*)data;\n      p->size = size;\n    }\n    else return 0;\n  }\n  else p->size = size;\n  return 1;\n}\n\n/*resize and give all new elements the value*/\nstatic unsigned uivector_resizev(uivector* p, size_t size, unsigned value)\n{\n  size_t oldsize = p->size, i;\n  if(!uivector_resize(p, size)) return 0;\n  for(i = oldsize; i < size; i++) p->data[i] = value;\n  return 1;\n}\n\nstatic void uivector_init(uivector* p)\n{\n  p->data = NULL;\n  p->size = p->allocsize = 0;\n}\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned uivector_push_back(uivector* p, unsigned c)\n{\n  if(!uivector_resize(p, p->size + 1)) return 0;\n  p->data[p->size - 1] = c;\n  return 1;\n}\n\n/*copy q to p, returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned uivector_copy(uivector* p, const uivector* q)\n{\n  size_t i;\n  if(!uivector_resize(p, q->size)) return 0;\n  for(i = 0; i < q->size; i++) p->data[i] = q->data[i];\n  return 1;\n}\n\nstatic void uivector_swap(uivector* p, uivector* q)\n{\n  size_t tmp;\n  unsigned* tmpp;\n  tmp = p->size; p->size = q->size; q->size = tmp;\n  tmp = p->allocsize; p->allocsize = q->allocsize; q->allocsize = tmp;\n  tmpp = p->data; p->data = q->data; q->data = tmpp;\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n#endif /*LODEPNG_COMPILE_ZLIB*/\n\n/* /////////////////////////////////////////////////////////////////////////// */\n\n/*dynamic vector of unsigned chars*/\ntypedef struct ucvector\n{\n  unsigned char* data;\n  size_t size; /*used size*/\n  size_t allocsize; /*allocated size*/\n} ucvector;\n\n/*returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned ucvector_resize(ucvector* p, size_t size)\n{\n  if(size * sizeof(unsigned char) > p->allocsize)\n  {\n    size_t newsize = size * sizeof(unsigned char) * 2;\n    void* data = lodepng_realloc(p->data, newsize);\n    if(data)\n    {\n      p->allocsize = newsize;\n      p->data = (unsigned char*)data;\n      p->size = size;\n    }\n    else return 0; /*error: not enough memory*/\n  }\n  else p->size = size;\n  return 1;\n}\n\n#ifdef LODEPNG_COMPILE_PNG\n\nstatic void ucvector_cleanup(void* p)\n{\n  ((ucvector*)p)->size = ((ucvector*)p)->allocsize = 0;\n  lodepng_free(((ucvector*)p)->data);\n  ((ucvector*)p)->data = NULL;\n}\n\nstatic void ucvector_init(ucvector* p)\n{\n  p->data = NULL;\n  p->size = p->allocsize = 0;\n}\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*resize and give all new elements the value*/\nstatic unsigned ucvector_resizev(ucvector* p, size_t size, unsigned char value)\n{\n  size_t oldsize = p->size, i;\n  if(!ucvector_resize(p, size)) return 0;\n  for(i = oldsize; i < size; i++) p->data[i] = value;\n  return 1;\n}\n#endif /*LODEPNG_COMPILE_DECODER*/\n#endif /*LODEPNG_COMPILE_PNG*/\n\n#ifdef LODEPNG_COMPILE_ZLIB\n/*you can both convert from vector to buffer&size and vica versa. If you use\ninit_buffer to take over a buffer and size, it is not needed to use cleanup*/\nstatic void ucvector_init_buffer(ucvector* p, unsigned char* buffer, size_t size)\n{\n  p->data = buffer;\n  p->allocsize = p->size = size;\n}\n#endif /*LODEPNG_COMPILE_ZLIB*/\n\n#if (defined(LODEPNG_COMPILE_PNG) && defined(LODEPNG_COMPILE_ANCILLARY_CHUNKS)) || defined(LODEPNG_COMPILE_ENCODER)\n/*returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned ucvector_push_back(ucvector* p, unsigned char c)\n{\n  if(!ucvector_resize(p, p->size + 1)) return 0;\n  p->data[p->size - 1] = c;\n  return 1;\n}\n#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/\n\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_PNG\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n/*returns 1 if success, 0 if failure ==> nothing done*/\nstatic unsigned string_resize(char** out, size_t size)\n{\n  char* data = (char*)lodepng_realloc(*out, size + 1);\n  if(data)\n  {\n    data[size] = 0; /*null termination char*/\n    *out = data;\n  }\n  return data != 0;\n}\n\n/*init a {char*, size_t} pair for use as string*/\nstatic void string_init(char** out)\n{\n  *out = NULL;\n  string_resize(out, 0);\n}\n\n/*free the above pair again*/\nstatic void string_cleanup(char** out)\n{\n  lodepng_free(*out);\n  *out = NULL;\n}\n\nstatic void string_set(char** out, const char* in)\n{\n  size_t insize = strlen(in), i = 0;\n  if(string_resize(out, insize))\n  {\n    for(i = 0; i < insize; i++)\n    {\n      (*out)[i] = in[i];\n    }\n  }\n}\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n#endif /*LODEPNG_COMPILE_PNG*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\nunsigned lodepng_read32bitInt(const unsigned char* buffer)\n{\n  return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];\n}\n\n#if defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)\n/*buffer must have at least 4 allocated bytes available*/\nstatic void lodepng_set32bitInt(unsigned char* buffer, unsigned value)\n{\n  buffer[0] = (unsigned char)((value >> 24) & 0xff);\n  buffer[1] = (unsigned char)((value >> 16) & 0xff);\n  buffer[2] = (unsigned char)((value >>  8) & 0xff);\n  buffer[3] = (unsigned char)((value      ) & 0xff);\n}\n#endif /*defined(LODEPNG_COMPILE_PNG) || defined(LODEPNG_COMPILE_ENCODER)*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\nstatic void lodepng_add32bitInt(ucvector* buffer, unsigned value)\n{\n  ucvector_resize(buffer, buffer->size + 4); /*todo: give error if resize failed*/\n  lodepng_set32bitInt(&buffer->data[buffer->size - 4], value);\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / File IO                                                                / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_DISK\n\nunsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* filename)\n{\n  FILE* file;\n  long size;\n\n  /*provide some proper output values if error will happen*/\n  *out = 0;\n  *outsize = 0;\n\n  file = fopen(filename, \"rb\");\n  if(!file) return 78;\n\n  /*get filesize:*/\n  fseek(file , 0 , SEEK_END);\n  size = ftell(file);\n  rewind(file);\n\n  /*read contents of the file into the vector*/\n  *outsize = 0;\n  *out = (unsigned char*)lodepng_malloc((size_t)size);\n  if(size && (*out)) (*outsize) = fread(*out, 1, (size_t)size, file);\n\n  fclose(file);\n  if(!(*out) && size) return 83; /*the above malloc failed*/\n  return 0;\n}\n\n/*write given buffer to the file, overwriting the file, it doesn't append to it.*/\nunsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename)\n{\n  FILE* file;\n  file = fopen(filename, \"wb\" );\n  if(!file) return 79;\n  fwrite((char*)buffer , 1 , buffersize, file);\n  fclose(file);\n  return 0;\n}\n\n#endif /*LODEPNG_COMPILE_DISK*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* // End of common code and tools. Begin of Zlib related code.            // */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_ZLIB\n#ifdef LODEPNG_COMPILE_ENCODER\n/*TODO: this ignores potential out of memory errors*/\nstatic void addBitToStream(size_t* bitpointer, ucvector* bitstream, unsigned char bit)\n{\n  /*add a new byte at the end*/\n  if((*bitpointer) % 8 == 0) ucvector_push_back(bitstream, (unsigned char)0);\n  /*earlier bit of huffman code is in a lesser significant bit of an earlier byte*/\n  (bitstream->data[bitstream->size - 1]) |= (bit << ((*bitpointer) & 0x7));\n  (*bitpointer)++;\n}\n\nstatic void addBitsToStream(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)\n{\n  size_t i;\n  for(i = 0; i < nbits; i++) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> i) & 1));\n}\n\nstatic void addBitsToStreamReversed(size_t* bitpointer, ucvector* bitstream, unsigned value, size_t nbits)\n{\n  size_t i;\n  for(i = 0; i < nbits; i++) addBitToStream(bitpointer, bitstream, (unsigned char)((value >> (nbits - 1 - i)) & 1));\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#ifdef LODEPNG_COMPILE_DECODER\n\n#define READBIT(bitpointer, bitstream) ((bitstream[bitpointer >> 3] >> (bitpointer & 0x7)) & (unsigned char)1)\n\nstatic unsigned char readBitFromStream(size_t* bitpointer, const unsigned char* bitstream)\n{\n  unsigned char result = (unsigned char)(READBIT(*bitpointer, bitstream));\n  (*bitpointer)++;\n  return result;\n}\n\nstatic unsigned readBitsFromStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)\n{\n  unsigned result = 0, i;\n  for(i = 0; i < nbits; i++)\n  {\n    result += ((unsigned)READBIT(*bitpointer, bitstream)) << i;\n    (*bitpointer)++;\n  }\n  return result;\n}\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Deflate - Huffman                                                      / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#define FIRST_LENGTH_CODE_INDEX 257\n#define LAST_LENGTH_CODE_INDEX 285\n/*256 literals, the end code, some length codes, and 2 unused codes*/\n#define NUM_DEFLATE_CODE_SYMBOLS 288\n/*the distance codes have their own symbols, 30 used, 2 unused*/\n#define NUM_DISTANCE_SYMBOLS 32\n/*the code length codes. 0-15: code lengths, 16: copy previous 3-6 times, 17: 3-10 zeros, 18: 11-138 zeros*/\n#define NUM_CODE_LENGTH_CODES 19\n\n/*the base lengths represented by codes 257-285*/\nstatic const unsigned LENGTHBASE[29]\n  = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,\n     67, 83, 99, 115, 131, 163, 195, 227, 258};\n\n/*the extra bits used by codes 257-285 (added to base length)*/\nstatic const unsigned LENGTHEXTRA[29]\n  = {0, 0, 0, 0, 0, 0, 0,  0,  1,  1,  1,  1,  2,  2,  2,  2,  3,  3,  3,  3,\n      4,  4,  4,   4,   5,   5,   5,   5,   0};\n\n/*the base backwards distances (the bits of distance codes appear after length codes and use their own huffman tree)*/\nstatic const unsigned DISTANCEBASE[30]\n  = {1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,\n     769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};\n\n/*the extra bits of backwards distances (added to base)*/\nstatic const unsigned DISTANCEEXTRA[30]\n  = {0, 0, 0, 0, 1, 1, 2,  2,  3,  3,  4,  4,  5,  5,   6,   6,   7,   7,   8,\n       8,    9,    9,   10,   10,   11,   11,   12,    12,    13,    13};\n\n/*the order in which \"code length alphabet code lengths\" are stored, out of this\nthe huffman tree of the dynamic huffman tree lengths is generated*/\nstatic const unsigned CLCL_ORDER[NUM_CODE_LENGTH_CODES]\n  = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*\nHuffman tree struct, containing multiple representations of the tree\n*/\ntypedef struct HuffmanTree\n{\n  unsigned* tree2d;\n  unsigned* tree1d;\n  unsigned* lengths; /*the lengths of the codes of the 1d-tree*/\n  unsigned maxbitlen; /*maximum number of bits a single code can get*/\n  unsigned numcodes; /*number of symbols in the alphabet = number of codes*/\n} HuffmanTree;\n\n/*function used for debug purposes to draw the tree in ascii art with C++*/\n/*\nstatic void HuffmanTree_draw(HuffmanTree* tree)\n{\n  std::cout << \"tree. length: \" << tree->numcodes << \" maxbitlen: \" << tree->maxbitlen << std::endl;\n  for(size_t i = 0; i < tree->tree1d.size; i++)\n  {\n    if(tree->lengths.data[i])\n      std::cout << i << \" \" << tree->tree1d.data[i] << \" \" << tree->lengths.data[i] << std::endl;\n  }\n  std::cout << std::endl;\n}*/\n\nstatic void HuffmanTree_init(HuffmanTree* tree)\n{\n  tree->tree2d = 0;\n  tree->tree1d = 0;\n  tree->lengths = 0;\n}\n\nstatic void HuffmanTree_cleanup(HuffmanTree* tree)\n{\n  lodepng_free(tree->tree2d);\n  lodepng_free(tree->tree1d);\n  lodepng_free(tree->lengths);\n}\n\n/*the tree representation used by the decoder. return value is error*/\nstatic unsigned HuffmanTree_make2DTree(HuffmanTree* tree)\n{\n  unsigned nodefilled = 0; /*up to which node it is filled*/\n  unsigned treepos = 0; /*position in the tree (1 of the numcodes columns)*/\n  unsigned n, i;\n\n  tree->tree2d = (unsigned*)lodepng_malloc(tree->numcodes * 2 * sizeof(unsigned));\n  if(!tree->tree2d) return 83; /*alloc fail*/\n\n  /*\n  convert tree1d[] to tree2d[][]. In the 2D array, a value of 32767 means\n  uninited, a value >= numcodes is an address to another bit, a value < numcodes\n  is a code. The 2 rows are the 2 possible bit values (0 or 1), there are as\n  many columns as codes - 1.\n  A good huffmann tree has N * 2 - 1 nodes, of which N - 1 are internal nodes.\n  Here, the internal nodes are stored (what their 0 and 1 option point to).\n  There is only memory for such good tree currently, if there are more nodes\n  (due to too long length codes), error 55 will happen\n  */\n  for(n = 0; n < tree->numcodes * 2; n++)\n  {\n    tree->tree2d[n] = 32767; /*32767 here means the tree2d isn't filled there yet*/\n  }\n\n  for(n = 0; n < tree->numcodes; n++) /*the codes*/\n  {\n    for(i = 0; i < tree->lengths[n]; i++) /*the bits for this code*/\n    {\n      unsigned char bit = (unsigned char)((tree->tree1d[n] >> (tree->lengths[n] - i - 1)) & 1);\n      if(treepos > tree->numcodes - 2) return 55; /*oversubscribed, see comment in lodepng_error_text*/\n      if(tree->tree2d[2 * treepos + bit] == 32767) /*not yet filled in*/\n      {\n        if(i + 1 == tree->lengths[n]) /*last bit*/\n        {\n          tree->tree2d[2 * treepos + bit] = n; /*put the current code in it*/\n          treepos = 0;\n        }\n        else\n        {\n          /*put address of the next step in here, first that address has to be found of course\n          (it's just nodefilled + 1)...*/\n          nodefilled++;\n          /*addresses encoded with numcodes added to it*/\n          tree->tree2d[2 * treepos + bit] = nodefilled + tree->numcodes;\n          treepos = nodefilled;\n        }\n      }\n      else treepos = tree->tree2d[2 * treepos + bit] - tree->numcodes;\n    }\n  }\n\n  for(n = 0; n < tree->numcodes * 2; n++)\n  {\n    if(tree->tree2d[n] == 32767) tree->tree2d[n] = 0; /*remove possible remaining 32767's*/\n  }\n\n  return 0;\n}\n\n/*\nSecond step for the ...makeFromLengths and ...makeFromFrequencies functions.\nnumcodes, lengths and maxbitlen must already be filled in correctly. return\nvalue is error.\n*/\nstatic unsigned HuffmanTree_makeFromLengths2(HuffmanTree* tree)\n{\n  uivector blcount;\n  uivector nextcode;\n  unsigned bits, n, error = 0;\n\n  uivector_init(&blcount);\n  uivector_init(&nextcode);\n\n  tree->tree1d = (unsigned*)lodepng_malloc(tree->numcodes * sizeof(unsigned));\n  if(!tree->tree1d) error = 83; /*alloc fail*/\n\n  if(!uivector_resizev(&blcount, tree->maxbitlen + 1, 0)\n  || !uivector_resizev(&nextcode, tree->maxbitlen + 1, 0))\n    error = 83; /*alloc fail*/\n\n  if(!error)\n  {\n    /*step 1: count number of instances of each code length*/\n    for(bits = 0; bits < tree->numcodes; bits++) blcount.data[tree->lengths[bits]]++;\n    /*step 2: generate the nextcode values*/\n    for(bits = 1; bits <= tree->maxbitlen; bits++)\n    {\n      nextcode.data[bits] = (nextcode.data[bits - 1] + blcount.data[bits - 1]) << 1;\n    }\n    /*step 3: generate all the codes*/\n    for(n = 0; n < tree->numcodes; n++)\n    {\n      if(tree->lengths[n] != 0) tree->tree1d[n] = nextcode.data[tree->lengths[n]]++;\n    }\n  }\n\n  uivector_cleanup(&blcount);\n  uivector_cleanup(&nextcode);\n\n  if(!error) return HuffmanTree_make2DTree(tree);\n  else return error;\n}\n\n/*\ngiven the code lengths (as stored in the PNG file), generate the tree as defined\nby Deflate. maxbitlen is the maximum bits that a code in the tree can have.\nreturn value is error.\n*/\nstatic unsigned HuffmanTree_makeFromLengths(HuffmanTree* tree, const unsigned* bitlen,\n                                            size_t numcodes, unsigned maxbitlen)\n{\n  unsigned i;\n  tree->lengths = (unsigned*)lodepng_malloc(numcodes * sizeof(unsigned));\n  if(!tree->lengths) return 83; /*alloc fail*/\n  for(i = 0; i < numcodes; i++) tree->lengths[i] = bitlen[i];\n  tree->numcodes = (unsigned)numcodes; /*number of symbols*/\n  tree->maxbitlen = maxbitlen;\n  return HuffmanTree_makeFromLengths2(tree);\n}\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\n/*\nA coin, this is the terminology used for the package-merge algorithm and the\ncoin collector's problem. This is used to generate the huffman tree.\nA coin can be multiple coins (when they're merged)\n*/\ntypedef struct Coin\n{\n  uivector symbols;\n  float weight; /*the sum of all weights in this coin*/\n} Coin;\n\nstatic void coin_init(Coin* c)\n{\n  uivector_init(&c->symbols);\n}\n\n/*argument c is void* so that this dtor can be given as function pointer to the vector resize function*/\nstatic void coin_cleanup(void* c)\n{\n  uivector_cleanup(&((Coin*)c)->symbols);\n}\n\nstatic void coin_copy(Coin* c1, const Coin* c2)\n{\n  c1->weight = c2->weight;\n  uivector_copy(&c1->symbols, &c2->symbols);\n}\n\nstatic void add_coins(Coin* c1, const Coin* c2)\n{\n  size_t i;\n  for(i = 0; i < c2->symbols.size; i++) uivector_push_back(&c1->symbols, c2->symbols.data[i]);\n  c1->weight += c2->weight;\n}\n\nstatic void init_coins(Coin* coins, size_t num)\n{\n  size_t i;\n  for(i = 0; i < num; i++) coin_init(&coins[i]);\n}\n\nstatic void cleanup_coins(Coin* coins, size_t num)\n{\n  size_t i;\n  for(i = 0; i < num; i++) coin_cleanup(&coins[i]);\n}\n\n/*\nThis uses a simple combsort to sort the data. This function is not critical for\noverall encoding speed and the data amount isn't that large.\n*/\nstatic void sort_coins(Coin* data, size_t amount)\n{\n  size_t gap = amount;\n  unsigned char swapped = 0;\n  while((gap > 1) || swapped)\n  {\n    size_t i;\n    gap = (gap * 10) / 13; /*shrink factor 1.3*/\n    if(gap == 9 || gap == 10) gap = 11; /*combsort11*/\n    if(gap < 1) gap = 1;\n    swapped = 0;\n    for(i = 0; i < amount - gap; i++)\n    {\n      size_t j = i + gap;\n      if(data[j].weight < data[i].weight)\n      {\n        float temp = data[j].weight; data[j].weight = data[i].weight; data[i].weight = temp;\n        uivector_swap(&data[i].symbols, &data[j].symbols);\n        swapped = 1;\n      }\n    }\n  }\n}\n\nstatic unsigned append_symbol_coins(Coin* coins, const unsigned* frequencies, unsigned numcodes, size_t sum)\n{\n  unsigned i;\n  unsigned j = 0; /*index of present symbols*/\n  for(i = 0; i < numcodes; i++)\n  {\n    if(frequencies[i] != 0) /*only include symbols that are present*/\n    {\n      coins[j].weight = frequencies[i] / (float)sum;\n      uivector_push_back(&coins[j].symbols, i);\n      j++;\n    }\n  }\n  return 0;\n}\n\nunsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequencies,\n                                      size_t numcodes, unsigned maxbitlen)\n{\n  unsigned i, j;\n  size_t sum = 0, numpresent = 0;\n  unsigned error = 0;\n  Coin* coins; /*the coins of the currently calculated row*/\n  Coin* prev_row; /*the previous row of coins*/\n  unsigned numcoins;\n  unsigned coinmem;\n\n  if(numcodes == 0) return 80; /*error: a tree of 0 symbols is not supposed to be made*/\n\n  for(i = 0; i < numcodes; i++)\n  {\n    if(frequencies[i] > 0)\n    {\n      numpresent++;\n      sum += frequencies[i];\n    }\n  }\n\n  for(i = 0; i < numcodes; i++) lengths[i] = 0;\n\n  /*ensure at least two present symbols. There should be at least one symbol\n  according to RFC 1951 section 3.2.7. To decoders incorrectly require two. To\n  make these work as well ensure there are at least two symbols. The\n  Package-Merge code below also doesn't work correctly if there's only one\n  symbol, it'd give it the theoritical 0 bits but in practice zlib wants 1 bit*/\n  if(numpresent == 0)\n  {\n    lengths[0] = lengths[1] = 1; /*note that for RFC 1951 section 3.2.7, only lengths[0] = 1 is needed*/\n  }\n  else if(numpresent == 1)\n  {\n    for(i = 0; i < numcodes; i++)\n    {\n      if(frequencies[i])\n      {\n        lengths[i] = 1;\n        lengths[i == 0 ? 1 : 0] = 1;\n        break;\n      }\n    }\n  }\n  else\n  {\n    /*Package-Merge algorithm represented by coin collector's problem\n    For every symbol, maxbitlen coins will be created*/\n\n    coinmem = numpresent * 2; /*max amount of coins needed with the current algo*/\n    coins = (Coin*)lodepng_malloc(sizeof(Coin) * coinmem);\n    prev_row = (Coin*)lodepng_malloc(sizeof(Coin) * coinmem);\n    if(!coins || !prev_row)\n    {\n      lodepng_free(coins);\n      lodepng_free(prev_row);\n      return 83; /*alloc fail*/\n    }\n    init_coins(coins, coinmem);\n    init_coins(prev_row, coinmem);\n\n    /*first row, lowest denominator*/\n    error = append_symbol_coins(coins, frequencies, numcodes, sum);\n    numcoins = numpresent;\n    sort_coins(coins, numcoins);\n    if(!error)\n    {\n      unsigned numprev = 0;\n      for(j = 1; j <= maxbitlen && !error; j++) /*each of the remaining rows*/\n      {\n        unsigned tempnum;\n        Coin* tempcoins;\n        /*swap prev_row and coins, and their amounts*/\n        tempcoins = prev_row; prev_row = coins; coins = tempcoins;\n        tempnum = numprev; numprev = numcoins; numcoins = tempnum;\n\n        cleanup_coins(coins, numcoins);\n        init_coins(coins, numcoins);\n\n        numcoins = 0;\n\n        /*fill in the merged coins of the previous row*/\n        for(i = 0; i + 1 < numprev; i += 2)\n        {\n          /*merge prev_row[i] and prev_row[i + 1] into new coin*/\n          Coin* coin = &coins[numcoins++];\n          coin_copy(coin, &prev_row[i]);\n          add_coins(coin, &prev_row[i + 1]);\n        }\n        /*fill in all the original symbols again*/\n        if(j < maxbitlen)\n        {\n          error = append_symbol_coins(coins + numcoins, frequencies, numcodes, sum);\n          numcoins += numpresent;\n        }\n        sort_coins(coins, numcoins);\n      }\n    }\n\n    if(!error)\n    {\n      /*calculate the lenghts of each symbol, as the amount of times a coin of each symbol is used*/\n      for(i = 0; i < numpresent - 1; i++)\n      {\n        Coin* coin = &coins[i];\n        for(j = 0; j < coin->symbols.size; j++) lengths[coin->symbols.data[j]]++;\n      }\n    }\n\n    cleanup_coins(coins, coinmem);\n    lodepng_free(coins);\n    cleanup_coins(prev_row, coinmem);\n    lodepng_free(prev_row);\n  }\n\n  return error;\n}\n\n/*Create the Huffman tree given the symbol frequencies*/\nstatic unsigned HuffmanTree_makeFromFrequencies(HuffmanTree* tree, const unsigned* frequencies,\n                                                size_t mincodes, size_t numcodes, unsigned maxbitlen)\n{\n  unsigned error = 0;\n  while(!frequencies[numcodes - 1] && numcodes > mincodes) numcodes--; /*trim zeroes*/\n  tree->maxbitlen = maxbitlen;\n  tree->numcodes = (unsigned)numcodes; /*number of symbols*/\n  tree->lengths = (unsigned*)lodepng_realloc(tree->lengths, numcodes * sizeof(unsigned));\n  if(!tree->lengths) return 83; /*alloc fail*/\n  /*initialize all lengths to 0*/\n  memset(tree->lengths, 0, numcodes * sizeof(unsigned));\n\n  error = lodepng_huffman_code_lengths(tree->lengths, frequencies, numcodes, maxbitlen);\n  if(!error) error = HuffmanTree_makeFromLengths2(tree);\n  return error;\n}\n\nstatic unsigned HuffmanTree_getCode(const HuffmanTree* tree, unsigned index)\n{\n  return tree->tree1d[index];\n}\n\nstatic unsigned HuffmanTree_getLength(const HuffmanTree* tree, unsigned index)\n{\n  return tree->lengths[index];\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n/*get the literal and length code tree of a deflated block with fixed tree, as per the deflate specification*/\nstatic unsigned generateFixedLitLenTree(HuffmanTree* tree)\n{\n  unsigned i, error = 0;\n  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));\n  if(!bitlen) return 83; /*alloc fail*/\n\n  /*288 possible codes: 0-255=literals, 256=endcode, 257-285=lengthcodes, 286-287=unused*/\n  for(i =   0; i <= 143; i++) bitlen[i] = 8;\n  for(i = 144; i <= 255; i++) bitlen[i] = 9;\n  for(i = 256; i <= 279; i++) bitlen[i] = 7;\n  for(i = 280; i <= 287; i++) bitlen[i] = 8;\n\n  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DEFLATE_CODE_SYMBOLS, 15);\n\n  lodepng_free(bitlen);\n  return error;\n}\n\n/*get the distance code tree of a deflated block with fixed tree, as specified in the deflate specification*/\nstatic unsigned generateFixedDistanceTree(HuffmanTree* tree)\n{\n  unsigned i, error = 0;\n  unsigned* bitlen = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));\n  if(!bitlen) return 83; /*alloc fail*/\n\n  /*there are 32 distance codes, but 30-31 are unused*/\n  for(i = 0; i < NUM_DISTANCE_SYMBOLS; i++) bitlen[i] = 5;\n  error = HuffmanTree_makeFromLengths(tree, bitlen, NUM_DISTANCE_SYMBOLS, 15);\n\n  lodepng_free(bitlen);\n  return error;\n}\n\n#ifdef LODEPNG_COMPILE_DECODER\n\n/*\nreturns the code, or (unsigned)(-1) if error happened\ninbitlength is the length of the complete buffer, in bits (so its byte length times 8)\n*/\nstatic unsigned huffmanDecodeSymbol(const unsigned char* in, size_t* bp,\n                                    const HuffmanTree* codetree, size_t inbitlength)\n{\n  unsigned treepos = 0, ct;\n  for(;;)\n  {\n    if(*bp >= inbitlength) return (unsigned)(-1); /*error: end of input memory reached without endcode*/\n    /*\n    decode the symbol from the tree. The \"readBitFromStream\" code is inlined in\n    the expression below because this is the biggest bottleneck while decoding\n    */\n    ct = codetree->tree2d[(treepos << 1) + READBIT(*bp, in)];\n    (*bp)++;\n    if(ct < codetree->numcodes) return ct; /*the symbol is decoded, return it*/\n    else treepos = ct - codetree->numcodes; /*symbol not yet decoded, instead move tree position*/\n\n    if(treepos >= codetree->numcodes) return (unsigned)(-1); /*error: it appeared outside the codetree*/\n  }\n}\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_DECODER\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Inflator (Decompressor)                                                / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*get the tree of a deflated block with fixed tree, as specified in the deflate specification*/\nstatic void getTreeInflateFixed(HuffmanTree* tree_ll, HuffmanTree* tree_d)\n{\n  /*TODO: check for out of memory errors*/\n  generateFixedLitLenTree(tree_ll);\n  generateFixedDistanceTree(tree_d);\n}\n\n/*get the tree of a deflated block with dynamic tree, the tree itself is also Huffman compressed with a known tree*/\nstatic unsigned getTreeInflateDynamic(HuffmanTree* tree_ll, HuffmanTree* tree_d,\n                                      const unsigned char* in, size_t* bp, size_t inlength)\n{\n  /*make sure that length values that aren't filled in will be 0, or a wrong tree will be generated*/\n  unsigned error = 0;\n  unsigned n, HLIT, HDIST, HCLEN, i;\n  size_t inbitlength = inlength * 8;\n\n  /*see comments in deflateDynamic for explanation of the context and these variables, it is analogous*/\n  unsigned* bitlen_ll = 0; /*lit,len code lengths*/\n  unsigned* bitlen_d = 0; /*dist code lengths*/\n  /*code length code lengths (\"clcl\"), the bit lengths of the huffman tree used to compress bitlen_ll and bitlen_d*/\n  unsigned* bitlen_cl = 0;\n  HuffmanTree tree_cl; /*the code tree for code length codes (the huffman tree for compressed huffman trees)*/\n\n  if((*bp) >> 3 >= inlength - 2) return 49; /*error: the bit pointer is or will go past the memory*/\n\n  /*number of literal/length codes + 257. Unlike the spec, the value 257 is added to it here already*/\n  HLIT =  readBitsFromStream(bp, in, 5) + 257;\n  /*number of distance codes. Unlike the spec, the value 1 is added to it here already*/\n  HDIST = readBitsFromStream(bp, in, 5) + 1;\n  /*number of code length codes. Unlike the spec, the value 4 is added to it here already*/\n  HCLEN = readBitsFromStream(bp, in, 4) + 4;\n\n  HuffmanTree_init(&tree_cl);\n\n  while(!error)\n  {\n    /*read the code length codes out of 3 * (amount of code length codes) bits*/\n\n    bitlen_cl = (unsigned*)lodepng_malloc(NUM_CODE_LENGTH_CODES * sizeof(unsigned));\n    if(!bitlen_cl) ERROR_BREAK(83 /*alloc fail*/);\n\n    for(i = 0; i < NUM_CODE_LENGTH_CODES; i++)\n    {\n      if(i < HCLEN) bitlen_cl[CLCL_ORDER[i]] = readBitsFromStream(bp, in, 3);\n      else bitlen_cl[CLCL_ORDER[i]] = 0; /*if not, it must stay 0*/\n    }\n\n    error = HuffmanTree_makeFromLengths(&tree_cl, bitlen_cl, NUM_CODE_LENGTH_CODES, 7);\n    if(error) break;\n\n    /*now we can use this tree to read the lengths for the tree that this function will return*/\n    bitlen_ll = (unsigned*)lodepng_malloc(NUM_DEFLATE_CODE_SYMBOLS * sizeof(unsigned));\n    bitlen_d = (unsigned*)lodepng_malloc(NUM_DISTANCE_SYMBOLS * sizeof(unsigned));\n    if(!bitlen_ll || !bitlen_d) ERROR_BREAK(83 /*alloc fail*/);\n    for(i = 0; i < NUM_DEFLATE_CODE_SYMBOLS; i++) bitlen_ll[i] = 0;\n    for(i = 0; i < NUM_DISTANCE_SYMBOLS; i++) bitlen_d[i] = 0;\n\n    /*i is the current symbol we're reading in the part that contains the code lengths of lit/len and dist codes*/\n    i = 0;\n    while(i < HLIT + HDIST)\n    {\n      unsigned code = huffmanDecodeSymbol(in, bp, &tree_cl, inbitlength);\n      if(code <= 15) /*a length code*/\n      {\n        if(i < HLIT) bitlen_ll[i] = code;\n        else bitlen_d[i - HLIT] = code;\n        i++;\n      }\n      else if(code == 16) /*repeat previous*/\n      {\n        unsigned replength = 3; /*read in the 2 bits that indicate repeat length (3-6)*/\n        unsigned value; /*set value to the previous code*/\n\n        if(*bp >= inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/\n        if (i == 0) ERROR_BREAK(54); /*can't repeat previous if i is 0*/\n\n        replength += readBitsFromStream(bp, in, 2);\n\n        if(i < HLIT + 1) value = bitlen_ll[i - 1];\n        else value = bitlen_d[i - HLIT - 1];\n        /*repeat this value in the next lengths*/\n        for(n = 0; n < replength; n++)\n        {\n          if(i >= HLIT + HDIST) ERROR_BREAK(13); /*error: i is larger than the amount of codes*/\n          if(i < HLIT) bitlen_ll[i] = value;\n          else bitlen_d[i - HLIT] = value;\n          i++;\n        }\n      }\n      else if(code == 17) /*repeat \"0\" 3-10 times*/\n      {\n        unsigned replength = 3; /*read in the bits that indicate repeat length*/\n        if(*bp >= inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/\n\n        replength += readBitsFromStream(bp, in, 3);\n\n        /*repeat this value in the next lengths*/\n        for(n = 0; n < replength; n++)\n        {\n          if(i >= HLIT + HDIST) ERROR_BREAK(14); /*error: i is larger than the amount of codes*/\n\n          if(i < HLIT) bitlen_ll[i] = 0;\n          else bitlen_d[i - HLIT] = 0;\n          i++;\n        }\n      }\n      else if(code == 18) /*repeat \"0\" 11-138 times*/\n      {\n        unsigned replength = 11; /*read in the bits that indicate repeat length*/\n        if(*bp >= inbitlength) ERROR_BREAK(50); /*error, bit pointer jumps past memory*/\n\n        replength += readBitsFromStream(bp, in, 7);\n\n        /*repeat this value in the next lengths*/\n        for(n = 0; n < replength; n++)\n        {\n          if(i >= HLIT + HDIST) ERROR_BREAK(15); /*error: i is larger than the amount of codes*/\n\n          if(i < HLIT) bitlen_ll[i] = 0;\n          else bitlen_d[i - HLIT] = 0;\n          i++;\n        }\n      }\n      else /*if(code == (unsigned)(-1))*/ /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/\n      {\n        if(code == (unsigned)(-1))\n        {\n          /*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol\n          (10=no endcode, 11=wrong jump outside of tree)*/\n          error = (*bp) > inbitlength ? 10 : 11;\n        }\n        else error = 16; /*unexisting code, this can never happen*/\n        break;\n      }\n    }\n    if(error) break;\n\n    if(bitlen_ll[256] == 0) ERROR_BREAK(64); /*the length of the end code 256 must be larger than 0*/\n\n    /*now we've finally got HLIT and HDIST, so generate the code trees, and the function is done*/\n    error = HuffmanTree_makeFromLengths(tree_ll, bitlen_ll, NUM_DEFLATE_CODE_SYMBOLS, 15);\n    if(error) break;\n    error = HuffmanTree_makeFromLengths(tree_d, bitlen_d, NUM_DISTANCE_SYMBOLS, 15);\n\n    break; /*end of error-while*/\n  }\n\n  lodepng_free(bitlen_cl);\n  lodepng_free(bitlen_ll);\n  lodepng_free(bitlen_d);\n  HuffmanTree_cleanup(&tree_cl);\n\n  return error;\n}\n\n/*inflate a block with dynamic of fixed Huffman tree*/\nstatic unsigned inflateHuffmanBlock(ucvector* out, const unsigned char* in, size_t* bp,\n                                    size_t* pos, size_t inlength, unsigned btype)\n{\n  unsigned error = 0;\n  HuffmanTree tree_ll; /*the huffman tree for literal and length codes*/\n  HuffmanTree tree_d; /*the huffman tree for distance codes*/\n  size_t inbitlength = inlength * 8;\n\n  HuffmanTree_init(&tree_ll);\n  HuffmanTree_init(&tree_d);\n\n  if(btype == 1) getTreeInflateFixed(&tree_ll, &tree_d);\n  else if(btype == 2) error = getTreeInflateDynamic(&tree_ll, &tree_d, in, bp, inlength);\n\n  while(!error) /*decode all symbols until end reached, breaks at end code*/\n  {\n    /*code_ll is literal, length or end code*/\n    unsigned code_ll = huffmanDecodeSymbol(in, bp, &tree_ll, inbitlength);\n    if(code_ll <= 255) /*literal symbol*/\n    {\n      if((*pos) >= out->size)\n      {\n        /*reserve more room at once*/\n        if(!ucvector_resize(out, ((*pos) + 1) * 2)) ERROR_BREAK(83 /*alloc fail*/);\n      }\n      out->data[(*pos)] = (unsigned char)(code_ll);\n      (*pos)++;\n    }\n    else if(code_ll >= FIRST_LENGTH_CODE_INDEX && code_ll <= LAST_LENGTH_CODE_INDEX) /*length code*/\n    {\n      unsigned code_d, distance;\n      unsigned numextrabits_l, numextrabits_d; /*extra bits for length and distance*/\n      size_t start, forward, backward, length;\n\n      /*part 1: get length base*/\n      length = LENGTHBASE[code_ll - FIRST_LENGTH_CODE_INDEX];\n\n      /*part 2: get extra bits and add the value of that to length*/\n      numextrabits_l = LENGTHEXTRA[code_ll - FIRST_LENGTH_CODE_INDEX];\n      if(*bp >= inbitlength) ERROR_BREAK(51); /*error, bit pointer will jump past memory*/\n      length += readBitsFromStream(bp, in, numextrabits_l);\n\n      /*part 3: get distance code*/\n      code_d = huffmanDecodeSymbol(in, bp, &tree_d, inbitlength);\n      if(code_d > 29)\n      {\n        if(code_ll == (unsigned)(-1)) /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/\n        {\n          /*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol\n          (10=no endcode, 11=wrong jump outside of tree)*/\n          error = (*bp) > inlength * 8 ? 10 : 11;\n        }\n        else error = 18; /*error: invalid distance code (30-31 are never used)*/\n        break;\n      }\n      distance = DISTANCEBASE[code_d];\n\n      /*part 4: get extra bits from distance*/\n      numextrabits_d = DISTANCEEXTRA[code_d];\n      if(*bp >= inbitlength) ERROR_BREAK(51); /*error, bit pointer will jump past memory*/\n\n      distance += readBitsFromStream(bp, in, numextrabits_d);\n\n      /*part 5: fill in all the out[n] values based on the length and dist*/\n      start = (*pos);\n      if(distance > start) ERROR_BREAK(52); /*too long backward distance*/\n      backward = start - distance;\n      if((*pos) + length >= out->size)\n      {\n        /*reserve more room at once*/\n        if(!ucvector_resize(out, ((*pos) + length) * 2)) ERROR_BREAK(83 /*alloc fail*/);\n      }\n\n      for(forward = 0; forward < length; forward++)\n      {\n        out->data[(*pos)] = out->data[backward];\n        (*pos)++;\n        backward++;\n        if(backward >= start) backward = start - distance;\n      }\n    }\n    else if(code_ll == 256)\n    {\n      break; /*end code, break the loop*/\n    }\n    else /*if(code == (unsigned)(-1))*/ /*huffmanDecodeSymbol returns (unsigned)(-1) in case of error*/\n    {\n      /*return error code 10 or 11 depending on the situation that happened in huffmanDecodeSymbol\n      (10=no endcode, 11=wrong jump outside of tree)*/\n      error = (*bp) > inlength * 8 ? 10 : 11;\n      break;\n    }\n  }\n\n  HuffmanTree_cleanup(&tree_ll);\n  HuffmanTree_cleanup(&tree_d);\n\n  return error;\n}\n\nstatic unsigned inflateNoCompression(ucvector* out, const unsigned char* in, size_t* bp, size_t* pos, size_t inlength)\n{\n  /*go to first boundary of byte*/\n  size_t p;\n  unsigned LEN, NLEN, n, error = 0;\n  while(((*bp) & 0x7) != 0) (*bp)++;\n  p = (*bp) / 8; /*byte position*/\n\n  /*read LEN (2 bytes) and NLEN (2 bytes)*/\n  if(p >= inlength - 4) return 52; /*error, bit pointer will jump past memory*/\n  LEN = in[p] + 256 * in[p + 1]; p += 2;\n  NLEN = in[p] + 256 * in[p + 1]; p += 2;\n\n  /*check if 16-bit NLEN is really the one's complement of LEN*/\n  if(LEN + NLEN != 65535) return 21; /*error: NLEN is not one's complement of LEN*/\n\n  if((*pos) + LEN >= out->size)\n  {\n    if(!ucvector_resize(out, (*pos) + LEN)) return 83; /*alloc fail*/\n  }\n\n  /*read the literal data: LEN bytes are now stored in the out buffer*/\n  if(p + LEN > inlength) return 23; /*error: reading outside of in buffer*/\n  for(n = 0; n < LEN; n++) out->data[(*pos)++] = in[p++];\n\n  (*bp) = p * 8;\n\n  return error;\n}\n\nstatic unsigned lodepng_inflatev(ucvector* out,\n                                 const unsigned char* in, size_t insize,\n                                 const LodePNGDecompressSettings* settings)\n{\n  /*bit pointer in the \"in\" data, current byte is bp >> 3, current bit is bp & 0x7 (from lsb to msb of the byte)*/\n  size_t bp = 0;\n  unsigned BFINAL = 0;\n  size_t pos = 0; /*byte position in the out buffer*/\n\n  unsigned error = 0;\n\n  (void)settings;\n\n  while(!BFINAL)\n  {\n    unsigned BTYPE;\n    if(bp + 2 >= insize * 8) return 52; /*error, bit pointer will jump past memory*/\n    BFINAL = readBitFromStream(&bp, in);\n    BTYPE = 1 * readBitFromStream(&bp, in);\n    BTYPE += 2 * readBitFromStream(&bp, in);\n\n    if(BTYPE == 3) return 20; /*error: invalid BTYPE*/\n    else if(BTYPE == 0) error = inflateNoCompression(out, in, &bp, &pos, insize); /*no compression*/\n    else error = inflateHuffmanBlock(out, in, &bp, &pos, insize, BTYPE); /*compression, BTYPE 01 or 10*/\n\n    if(error) return error;\n  }\n\n  /*Only now we know the true size of out, resize it to that*/\n  if(!ucvector_resize(out, pos)) error = 83; /*alloc fail*/\n\n  return error;\n}\n\nunsigned lodepng_inflate(unsigned char** out, size_t* outsize,\n                         const unsigned char* in, size_t insize,\n                         const LodePNGDecompressSettings* settings)\n{\n  unsigned error;\n  ucvector v;\n  ucvector_init_buffer(&v, *out, *outsize);\n  error = lodepng_inflatev(&v, in, insize, settings);\n  *out = v.data;\n  *outsize = v.size;\n  return error;\n}\n\nstatic unsigned inflate(unsigned char** out, size_t* outsize,\n                        const unsigned char* in, size_t insize,\n                        const LodePNGDecompressSettings* settings)\n{\n  if(settings->custom_inflate)\n  {\n    return settings->custom_inflate(out, outsize, in, insize, settings);\n  }\n  else\n  {\n    return lodepng_inflate(out, outsize, in, insize, settings);\n  }\n}\n\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Deflator (Compressor)                                                  / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\nstatic const size_t MAX_SUPPORTED_DEFLATE_LENGTH = 258;\n\n/*bitlen is the size in bits of the code*/\nstatic void addHuffmanSymbol(size_t* bp, ucvector* compressed, unsigned code, unsigned bitlen)\n{\n  addBitsToStreamReversed(bp, compressed, code, bitlen);\n}\n\n/*search the index in the array, that has the largest value smaller than or equal to the given value,\ngiven array must be sorted (if no value is smaller, it returns the size of the given array)*/\nstatic size_t searchCodeIndex(const unsigned* array, size_t array_size, size_t value)\n{\n  /*linear search implementation*/\n  /*for(size_t i = 1; i < array_size; i++) if(array[i] > value) return i - 1;\n  return array_size - 1;*/\n\n  /*binary search implementation (not that much faster) (precondition: array_size > 0)*/\n  size_t left  = 1;\n  size_t right = array_size - 1;\n  while(left <= right)\n  {\n    size_t mid = (left + right) / 2;\n    if(array[mid] <= value) left = mid + 1; /*the value to find is more to the right*/\n    else if(array[mid - 1] > value) right = mid - 1; /*the value to find is more to the left*/\n    else return mid - 1;\n  }\n  return array_size - 1;\n}\n\nstatic void addLengthDistance(uivector* values, size_t length, size_t distance)\n{\n  /*values in encoded vector are those used by deflate:\n  0-255: literal bytes\n  256: end\n  257-285: length/distance pair (length code, followed by extra length bits, distance code, extra distance bits)\n  286-287: invalid*/\n\n  unsigned length_code = (unsigned)searchCodeIndex(LENGTHBASE, 29, length);\n  unsigned extra_length = (unsigned)(length - LENGTHBASE[length_code]);\n  unsigned dist_code = (unsigned)searchCodeIndex(DISTANCEBASE, 30, distance);\n  unsigned extra_distance = (unsigned)(distance - DISTANCEBASE[dist_code]);\n\n  uivector_push_back(values, length_code + FIRST_LENGTH_CODE_INDEX);\n  uivector_push_back(values, extra_length);\n  uivector_push_back(values, dist_code);\n  uivector_push_back(values, extra_distance);\n}\n\nstatic const unsigned HASH_NUM_VALUES = 65536;\nstatic const unsigned HASH_NUM_CHARACTERS = 3;\nstatic const unsigned HASH_SHIFT = 2;\n/*\nThe HASH_NUM_CHARACTERS value is used to make encoding faster by using longer\nsequences to generate a hash value from the stream bytes. Setting it to 3\ngives exactly the same compression as the brute force method, since deflate's\nrun length encoding starts with lengths of 3. Setting it to higher values,\nlike 6, can make the encoding faster (not always though!), but will cause the\nencoding to miss any length between 3 and this value, so that the compression\nmay be worse (but this can vary too depending on the image, sometimes it is\neven a bit better instead).\nThe HASH_NUM_VALUES is the amount of unique possible hash values that\ncombinations of bytes can give, the higher it is the more memory is needed, but\nif it's too low the advantage of hashing is gone.\n*/\n\ntypedef struct Hash\n{\n  int* head; /*hash value to head circular pos*/\n  int* val; /*circular pos to hash value*/\n  /*circular pos to prev circular pos*/\n  unsigned short* chain;\n  unsigned short* zeros;\n} Hash;\n\nstatic unsigned hash_init(Hash* hash, unsigned windowsize)\n{\n  unsigned i;\n  hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES);\n  hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize);\n  hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);\n  hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);\n\n  if(!hash->head || !hash->val || !hash->chain || !hash->zeros) return 83; /*alloc fail*/\n\n  /*initialize hash table*/\n  for(i = 0; i < HASH_NUM_VALUES; i++) hash->head[i] = -1;\n  for(i = 0; i < windowsize; i++) hash->val[i] = -1;\n  for(i = 0; i < windowsize; i++) hash->chain[i] = i; /*same value as index indicates uninitialized*/\n\n  return 0;\n}\n\nstatic void hash_cleanup(Hash* hash)\n{\n  lodepng_free(hash->head);\n  lodepng_free(hash->val);\n  lodepng_free(hash->chain);\n  lodepng_free(hash->zeros);\n}\n\nstatic unsigned getHash(const unsigned char* data, size_t size, size_t pos)\n{\n  unsigned result = 0;\n  size_t amount, i;\n  if(pos >= size) return 0;\n  amount = HASH_NUM_CHARACTERS;\n  if(pos + amount >= size) amount = size - pos;\n  for(i = 0; i < amount; i++) result ^= (data[pos + i] << (i * HASH_SHIFT));\n  return result % HASH_NUM_VALUES;\n}\n\nstatic unsigned countZeros(const unsigned char* data, size_t size, size_t pos)\n{\n  const unsigned char* start = data + pos;\n  const unsigned char* end = start + MAX_SUPPORTED_DEFLATE_LENGTH;\n  if(end > data + size) end = data + size;\n  data = start;\n  while (data != end && *data == 0) data++;\n  /*subtracting two addresses returned as 32-bit number (max value is MAX_SUPPORTED_DEFLATE_LENGTH)*/\n  return (unsigned)(data - start);\n}\n\nstatic void updateHashChain(Hash* hash, size_t pos, int hashval, unsigned windowsize)\n{\n  unsigned wpos = pos % windowsize;\n  hash->val[wpos] = hashval;\n  if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval];\n  hash->head[hashval] = wpos;\n}\n\n/*\nLZ77-encode the data. Return value is error code. The input are raw bytes, the output\nis in the form of unsigned integers with codes representing for example literal bytes, or\nlength/distance pairs.\nIt uses a hash table technique to let it encode faster. When doing LZ77 encoding, a\nsliding window (of windowsize) is used, and all past bytes in that window can be used as\nthe \"dictionary\". A brute force search through all possible distances would be slow, and\nthis hash technique is one out of several ways to speed this up.\n*/\nstatic unsigned encodeLZ77(uivector* out, Hash* hash,\n                           const unsigned char* in, size_t inpos, size_t insize, unsigned windowsize,\n                           unsigned minmatch, unsigned nicematch, unsigned lazymatching)\n{\n  unsigned short numzeros = 0;\n  int usezeros = windowsize >= 8192; /*for small window size, the 'max chain length' optimization does a better job*/\n  unsigned pos, i, error = 0;\n  /*for large window lengths, assume the user wants no compression loss. Otherwise, max hash chain length speedup.*/\n  unsigned maxchainlength = windowsize >= 8192 ? windowsize : windowsize / 8;\n  unsigned maxlazymatch = windowsize >= 8192 ? MAX_SUPPORTED_DEFLATE_LENGTH : 64;\n\n  if(!error)\n  {\n    unsigned offset; /*the offset represents the distance in LZ77 terminology*/\n    unsigned length;\n    unsigned lazy = 0;\n    unsigned lazylength = 0, lazyoffset = 0;\n    unsigned hashval;\n    unsigned current_offset, current_length;\n    const unsigned char *lastptr, *foreptr, *backptr;\n    unsigned short hashpos, prevpos;\n\n    for(pos = inpos; pos < insize; pos++)\n    {\n      size_t wpos = pos % windowsize; /*position for in 'circular' hash buffers*/\n\n      hashval = getHash(in, insize, pos);\n      updateHashChain(hash, pos, hashval, windowsize);\n\n      if(usezeros && hashval == 0)\n      {\n        numzeros = countZeros(in, insize, pos);\n        hash->zeros[wpos] = numzeros;\n      }\n\n      /*the length and offset found for the current position*/\n      length = 0;\n      offset = 0;\n\n      prevpos = hash->head[hashval];\n      hashpos = hash->chain[prevpos];\n\n      lastptr = &in[insize < pos + MAX_SUPPORTED_DEFLATE_LENGTH ? insize : pos + MAX_SUPPORTED_DEFLATE_LENGTH];\n\n      /*search for the longest string*/\n      if(hash->val[wpos] == (int)hashval)\n      {\n        unsigned chainlength = 0;\n        for(;;)\n        {\n          /*stop when went completely around the circular buffer*/\n          if(prevpos < wpos && hashpos > prevpos && hashpos <= wpos) break;\n          if(prevpos > wpos && (hashpos <= wpos || hashpos > prevpos)) break;\n          if(chainlength++ >= maxchainlength) break;\n\n          current_offset = hashpos <= wpos ? wpos - hashpos : wpos - hashpos + windowsize;\n          if(current_offset > 0)\n          {\n            /*test the next characters*/\n            foreptr = &in[pos];\n            backptr = &in[pos - current_offset];\n\n            /*common case in PNGs is lots of zeros. Quickly skip over them as a speedup*/\n            if(usezeros && hashval == 0 && hash->val[hashpos] == 0 /*hashval[hashpos] may be out of date*/)\n            {\n              unsigned short skip = hash->zeros[hashpos];\n              if(skip > numzeros) skip = numzeros;\n              backptr += skip;\n              foreptr += skip;\n            }\n\n            /* multiple checks at once per array bounds check */\n            while(foreptr != lastptr && *backptr == *foreptr) /*maximum supported length by deflate is max length*/\n            {\n              ++backptr;\n              ++foreptr;\n            }\n            current_length = (unsigned)(foreptr - &in[pos]);\n\n            if(current_length > length)\n            {\n              length = current_length; /*the longest length*/\n              offset = current_offset; /*the offset that is related to this longest length*/\n              /*jump out once a length of max length is found (speed gain)*/\n              if(current_length >= nicematch || current_length == MAX_SUPPORTED_DEFLATE_LENGTH) break;\n            }\n          }\n\n          if(hashpos == hash->chain[hashpos]) break;\n\n          prevpos = hashpos;\n          hashpos = hash->chain[hashpos];\n        }\n      }\n\n      if(lazymatching)\n      {\n        if(!lazy && length >= 3 && length <= maxlazymatch && length < MAX_SUPPORTED_DEFLATE_LENGTH)\n        {\n          lazy = 1;\n          lazylength = length;\n          lazyoffset = offset;\n          continue; /*try the next byte*/\n        }\n        if(lazy)\n        {\n          lazy = 0;\n          if(pos == 0) ERROR_BREAK(81);\n          if(length > lazylength + 1)\n          {\n            /*push the previous character as literal*/\n            if(!uivector_push_back(out, in[pos - 1])) ERROR_BREAK(83 /*alloc fail*/);\n          }\n          else\n          {\n            length = lazylength;\n            offset = lazyoffset;\n            hash->head[hashval] = -1; /*the same hashchain update will be done, this ensures no wrong alteration*/\n            pos--;\n          }\n        }\n      }\n      if(length >= 3 && offset > windowsize) ERROR_BREAK(86 /*too big (or overflown negative) offset*/);\n\n      /**encode it as length/distance pair or literal value**/\n      if(length < 3) /*only lengths of 3 or higher are supported as length/distance pair*/\n      {\n        if(!uivector_push_back(out, in[pos])) ERROR_BREAK(83 /*alloc fail*/);\n      }\n      else if(length < minmatch || (length == 3 && offset > 4096))\n      {\n        /*compensate for the fact that longer offsets have more extra bits, a\n        length of only 3 may be not worth it then*/\n        if(!uivector_push_back(out, in[pos])) ERROR_BREAK(83 /*alloc fail*/);\n      }\n      else\n      {\n        addLengthDistance(out, length, offset);\n        for(i = 1; i < length; i++)\n        {\n          pos++;\n          hashval = getHash(in, insize, pos);\n          updateHashChain(hash, pos, hashval, windowsize);\n          if(usezeros && hashval == 0)\n          {\n            hash->zeros[pos % windowsize] = countZeros(in, insize, pos);\n          }\n        }\n      }\n\n    } /*end of the loop through each character of input*/\n  } /*end of \"if(!error)\"*/\n\n  return error;\n}\n\n/* /////////////////////////////////////////////////////////////////////////// */\n\nstatic unsigned deflateNoCompression(ucvector* out, const unsigned char* data, size_t datasize)\n{\n  /*non compressed deflate block data: 1 bit BFINAL,2 bits BTYPE,(5 bits): it jumps to start of next byte,\n  2 bytes LEN, 2 bytes NLEN, LEN bytes literal DATA*/\n\n  size_t i, j, numdeflateblocks = (datasize + 65534) / 65535;\n  unsigned datapos = 0;\n  for(i = 0; i < numdeflateblocks; i++)\n  {\n    unsigned BFINAL, BTYPE, LEN, NLEN;\n    unsigned char firstbyte;\n\n    BFINAL = (i == numdeflateblocks - 1);\n    BTYPE = 0;\n\n    firstbyte = (unsigned char)(BFINAL + ((BTYPE & 1) << 1) + ((BTYPE & 2) << 1));\n    ucvector_push_back(out, firstbyte);\n\n    LEN = 65535;\n    if(datasize - datapos < 65535) LEN = (unsigned)datasize - datapos;\n    NLEN = 65535 - LEN;\n\n    ucvector_push_back(out, (unsigned char)(LEN % 256));\n    ucvector_push_back(out, (unsigned char)(LEN / 256));\n    ucvector_push_back(out, (unsigned char)(NLEN % 256));\n    ucvector_push_back(out, (unsigned char)(NLEN / 256));\n\n    /*Decompressed data*/\n    for(j = 0; j < 65535 && datapos < datasize; j++)\n    {\n      ucvector_push_back(out, data[datapos++]);\n    }\n  }\n\n  return 0;\n}\n\n/*\nwrite the lz77-encoded data, which has lit, len and dist codes, to compressed stream using huffman trees.\ntree_ll: the tree for lit and len codes.\ntree_d: the tree for distance codes.\n*/\nstatic void writeLZ77data(size_t* bp, ucvector* out, const uivector* lz77_encoded,\n                          const HuffmanTree* tree_ll, const HuffmanTree* tree_d)\n{\n  size_t i = 0;\n  for(i = 0; i < lz77_encoded->size; i++)\n  {\n    unsigned val = lz77_encoded->data[i];\n    addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_ll, val), HuffmanTree_getLength(tree_ll, val));\n    if(val > 256) /*for a length code, 3 more things have to be added*/\n    {\n      unsigned length_index = val - FIRST_LENGTH_CODE_INDEX;\n      unsigned n_length_extra_bits = LENGTHEXTRA[length_index];\n      unsigned length_extra_bits = lz77_encoded->data[++i];\n\n      unsigned distance_code = lz77_encoded->data[++i];\n\n      unsigned distance_index = distance_code;\n      unsigned n_distance_extra_bits = DISTANCEEXTRA[distance_index];\n      unsigned distance_extra_bits = lz77_encoded->data[++i];\n\n      addBitsToStream(bp, out, length_extra_bits, n_length_extra_bits);\n      addHuffmanSymbol(bp, out, HuffmanTree_getCode(tree_d, distance_code),\n                       HuffmanTree_getLength(tree_d, distance_code));\n      addBitsToStream(bp, out, distance_extra_bits, n_distance_extra_bits);\n    }\n  }\n}\n\n/*Deflate for a block of type \"dynamic\", that is, with freely, optimally, created huffman trees*/\nstatic unsigned deflateDynamic(ucvector* out, size_t* bp, Hash* hash,\n                               const unsigned char* data, size_t datapos, size_t dataend,\n                               const LodePNGCompressSettings* settings, int final)\n{\n  unsigned error = 0;\n\n  /*\n  A block is compressed as follows: The PNG data is lz77 encoded, resulting in\n  literal bytes and length/distance pairs. This is then huffman compressed with\n  two huffman trees. One huffman tree is used for the lit and len values (\"ll\"),\n  another huffman tree is used for the dist values (\"d\"). These two trees are\n  stored using their code lengths, and to compress even more these code lengths\n  are also run-length encoded and huffman compressed. This gives a huffman tree\n  of code lengths \"cl\". The code lenghts used to describe this third tree are\n  the code length code lengths (\"clcl\").\n  */\n\n  /*The lz77 encoded data, represented with integers since there will also be length and distance codes in it*/\n  uivector lz77_encoded;\n  HuffmanTree tree_ll; /*tree for lit,len values*/\n  HuffmanTree tree_d; /*tree for distance codes*/\n  HuffmanTree tree_cl; /*tree for encoding the code lengths representing tree_ll and tree_d*/\n  uivector frequencies_ll; /*frequency of lit,len codes*/\n  uivector frequencies_d; /*frequency of dist codes*/\n  uivector frequencies_cl; /*frequency of code length codes*/\n  uivector bitlen_lld; /*lit,len,dist code lenghts (int bits), literally (without repeat codes).*/\n  uivector bitlen_lld_e; /*bitlen_lld encoded with repeat codes (this is a rudemtary run length compression)*/\n  /*bitlen_cl is the code length code lengths (\"clcl\"). The bit lengths of codes to represent tree_cl\n  (these are written as is in the file, it would be crazy to compress these using yet another huffman\n  tree that needs to be represented by yet another set of code lengths)*/\n  uivector bitlen_cl;\n  size_t datasize = dataend - datapos;\n\n  /*\n  Due to the huffman compression of huffman tree representations (\"two levels\"), there are some anologies:\n  bitlen_lld is to tree_cl what data is to tree_ll and tree_d.\n  bitlen_lld_e is to bitlen_lld what lz77_encoded is to data.\n  bitlen_cl is to bitlen_lld_e what bitlen_lld is to lz77_encoded.\n  */\n\n  unsigned BFINAL = final;\n  size_t numcodes_ll, numcodes_d, i;\n  unsigned HLIT, HDIST, HCLEN;\n\n  uivector_init(&lz77_encoded);\n  HuffmanTree_init(&tree_ll);\n  HuffmanTree_init(&tree_d);\n  HuffmanTree_init(&tree_cl);\n  uivector_init(&frequencies_ll);\n  uivector_init(&frequencies_d);\n  uivector_init(&frequencies_cl);\n  uivector_init(&bitlen_lld);\n  uivector_init(&bitlen_lld_e);\n  uivector_init(&bitlen_cl);\n\n  /*This while loop never loops due to a break at the end, it is here to\n  allow breaking out of it to the cleanup phase on error conditions.*/\n  while(!error)\n  {\n    if(settings->use_lz77)\n    {\n      error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize,\n                         settings->minmatch, settings->nicematch, settings->lazymatching);\n      if(error) break;\n    }\n    else\n    {\n      if(!uivector_resize(&lz77_encoded, datasize)) ERROR_BREAK(83 /*alloc fail*/);\n      for(i = datapos; i < dataend; i++) lz77_encoded.data[i] = data[i]; /*no LZ77, but still will be Huffman compressed*/\n    }\n\n    if(!uivector_resizev(&frequencies_ll, 286, 0)) ERROR_BREAK(83 /*alloc fail*/);\n    if(!uivector_resizev(&frequencies_d, 30, 0)) ERROR_BREAK(83 /*alloc fail*/);\n\n    /*Count the frequencies of lit, len and dist codes*/\n    for(i = 0; i < lz77_encoded.size; i++)\n    {\n      unsigned symbol = lz77_encoded.data[i];\n      frequencies_ll.data[symbol]++;\n      if(symbol > 256)\n      {\n        unsigned dist = lz77_encoded.data[i + 2];\n        frequencies_d.data[dist]++;\n        i += 3;\n      }\n    }\n    frequencies_ll.data[256] = 1; /*there will be exactly 1 end code, at the end of the block*/\n\n    /*Make both huffman trees, one for the lit and len codes, one for the dist codes*/\n    error = HuffmanTree_makeFromFrequencies(&tree_ll, frequencies_ll.data, 257, frequencies_ll.size, 15);\n    if(error) break;\n    /*2, not 1, is chosen for mincodes: some buggy PNG decoders require at least 2 symbols in the dist tree*/\n    error = HuffmanTree_makeFromFrequencies(&tree_d, frequencies_d.data, 2, frequencies_d.size, 15);\n    if(error) break;\n\n    numcodes_ll = tree_ll.numcodes; if(numcodes_ll > 286) numcodes_ll = 286;\n    numcodes_d = tree_d.numcodes; if(numcodes_d > 30) numcodes_d = 30;\n    /*store the code lengths of both generated trees in bitlen_lld*/\n    for(i = 0; i < numcodes_ll; i++) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_ll, (unsigned)i));\n    for(i = 0; i < numcodes_d; i++) uivector_push_back(&bitlen_lld, HuffmanTree_getLength(&tree_d, (unsigned)i));\n\n    /*run-length compress bitlen_ldd into bitlen_lld_e by using repeat codes 16 (copy length 3-6 times),\n    17 (3-10 zeroes), 18 (11-138 zeroes)*/\n    for(i = 0; i < (unsigned)bitlen_lld.size; i++)\n    {\n      unsigned j = 0; /*amount of repititions*/\n      while(i + j + 1 < (unsigned)bitlen_lld.size && bitlen_lld.data[i + j + 1] == bitlen_lld.data[i]) j++;\n\n      if(bitlen_lld.data[i] == 0 && j >= 2) /*repeat code for zeroes*/\n      {\n        j++; /*include the first zero*/\n        if(j <= 10) /*repeat code 17 supports max 10 zeroes*/\n        {\n          uivector_push_back(&bitlen_lld_e, 17);\n          uivector_push_back(&bitlen_lld_e, j - 3);\n        }\n        else /*repeat code 18 supports max 138 zeroes*/\n        {\n          if(j > 138) j = 138;\n          uivector_push_back(&bitlen_lld_e, 18);\n          uivector_push_back(&bitlen_lld_e, j - 11);\n        }\n        i += (j - 1);\n      }\n      else if(j >= 3) /*repeat code for value other than zero*/\n      {\n        size_t k;\n        unsigned num = j / 6, rest = j % 6;\n        uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]);\n        for(k = 0; k < num; k++)\n        {\n          uivector_push_back(&bitlen_lld_e, 16);\n          uivector_push_back(&bitlen_lld_e, 6 - 3);\n        }\n        if(rest >= 3)\n        {\n          uivector_push_back(&bitlen_lld_e, 16);\n          uivector_push_back(&bitlen_lld_e, rest - 3);\n        }\n        else j -= rest;\n        i += j;\n      }\n      else /*too short to benefit from repeat code*/\n      {\n        uivector_push_back(&bitlen_lld_e, bitlen_lld.data[i]);\n      }\n    }\n\n    /*generate tree_cl, the huffmantree of huffmantrees*/\n\n    if(!uivector_resizev(&frequencies_cl, NUM_CODE_LENGTH_CODES, 0)) ERROR_BREAK(83 /*alloc fail*/);\n    for(i = 0; i < bitlen_lld_e.size; i++)\n    {\n      frequencies_cl.data[bitlen_lld_e.data[i]]++;\n      /*after a repeat code come the bits that specify the number of repetitions,\n      those don't need to be in the frequencies_cl calculation*/\n      if(bitlen_lld_e.data[i] >= 16) i++;\n    }\n\n    error = HuffmanTree_makeFromFrequencies(&tree_cl, frequencies_cl.data,\n                                            frequencies_cl.size, frequencies_cl.size, 7);\n    if(error) break;\n\n    if(!uivector_resize(&bitlen_cl, tree_cl.numcodes)) ERROR_BREAK(83 /*alloc fail*/);\n    for(i = 0; i < tree_cl.numcodes; i++)\n    {\n      /*lenghts of code length tree is in the order as specified by deflate*/\n      bitlen_cl.data[i] = HuffmanTree_getLength(&tree_cl, CLCL_ORDER[i]);\n    }\n    while(bitlen_cl.data[bitlen_cl.size - 1] == 0 && bitlen_cl.size > 4)\n    {\n      /*remove zeros at the end, but minimum size must be 4*/\n      if(!uivector_resize(&bitlen_cl, bitlen_cl.size - 1)) ERROR_BREAK(83 /*alloc fail*/);\n    }\n    if(error) break;\n\n    /*\n    Write everything into the output\n\n    After the BFINAL and BTYPE, the dynamic block consists out of the following:\n    - 5 bits HLIT, 5 bits HDIST, 4 bits HCLEN\n    - (HCLEN+4)*3 bits code lengths of code length alphabet\n    - HLIT + 257 code lenghts of lit/length alphabet (encoded using the code length\n      alphabet, + possible repetition codes 16, 17, 18)\n    - HDIST + 1 code lengths of distance alphabet (encoded using the code length\n      alphabet, + possible repetition codes 16, 17, 18)\n    - compressed data\n    - 256 (end code)\n    */\n\n    /*Write block type*/\n    addBitToStream(bp, out, BFINAL);\n    addBitToStream(bp, out, 0); /*first bit of BTYPE \"dynamic\"*/\n    addBitToStream(bp, out, 1); /*second bit of BTYPE \"dynamic\"*/\n\n    /*write the HLIT, HDIST and HCLEN values*/\n    HLIT = (unsigned)(numcodes_ll - 257);\n    HDIST = (unsigned)(numcodes_d - 1);\n    HCLEN = (unsigned)bitlen_cl.size - 4;\n    /*trim zeroes for HCLEN. HLIT and HDIST were already trimmed at tree creation*/\n    while(!bitlen_cl.data[HCLEN + 4 - 1] && HCLEN > 0) HCLEN--;\n    addBitsToStream(bp, out, HLIT, 5);\n    addBitsToStream(bp, out, HDIST, 5);\n    addBitsToStream(bp, out, HCLEN, 4);\n\n    /*write the code lenghts of the code length alphabet*/\n    for(i = 0; i < HCLEN + 4; i++) addBitsToStream(bp, out, bitlen_cl.data[i], 3);\n\n    /*write the lenghts of the lit/len AND the dist alphabet*/\n    for(i = 0; i < bitlen_lld_e.size; i++)\n    {\n      addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_cl, bitlen_lld_e.data[i]),\n                       HuffmanTree_getLength(&tree_cl, bitlen_lld_e.data[i]));\n      /*extra bits of repeat codes*/\n      if(bitlen_lld_e.data[i] == 16) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 2);\n      else if(bitlen_lld_e.data[i] == 17) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 3);\n      else if(bitlen_lld_e.data[i] == 18) addBitsToStream(bp, out, bitlen_lld_e.data[++i], 7);\n    }\n\n    /*write the compressed data symbols*/\n    writeLZ77data(bp, out, &lz77_encoded, &tree_ll, &tree_d);\n    /*error: the length of the end code 256 must be larger than 0*/\n    if(HuffmanTree_getLength(&tree_ll, 256) == 0) ERROR_BREAK(64);\n\n    /*write the end code*/\n    addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, 256), HuffmanTree_getLength(&tree_ll, 256));\n\n    break; /*end of error-while*/\n  }\n\n  /*cleanup*/\n  uivector_cleanup(&lz77_encoded);\n  HuffmanTree_cleanup(&tree_ll);\n  HuffmanTree_cleanup(&tree_d);\n  HuffmanTree_cleanup(&tree_cl);\n  uivector_cleanup(&frequencies_ll);\n  uivector_cleanup(&frequencies_d);\n  uivector_cleanup(&frequencies_cl);\n  uivector_cleanup(&bitlen_lld_e);\n  uivector_cleanup(&bitlen_lld);\n  uivector_cleanup(&bitlen_cl);\n\n  return error;\n}\n\nstatic unsigned deflateFixed(ucvector* out, size_t* bp, Hash* hash,\n                             const unsigned char* data,\n                             size_t datapos, size_t dataend,\n                             const LodePNGCompressSettings* settings, int final)\n{\n  HuffmanTree tree_ll; /*tree for literal values and length codes*/\n  HuffmanTree tree_d; /*tree for distance codes*/\n\n  unsigned BFINAL = final;\n  unsigned error = 0;\n  size_t i;\n\n  HuffmanTree_init(&tree_ll);\n  HuffmanTree_init(&tree_d);\n\n  generateFixedLitLenTree(&tree_ll);\n  generateFixedDistanceTree(&tree_d);\n\n  addBitToStream(bp, out, BFINAL);\n  addBitToStream(bp, out, 1); /*first bit of BTYPE*/\n  addBitToStream(bp, out, 0); /*second bit of BTYPE*/\n\n  if(settings->use_lz77) /*LZ77 encoded*/\n  {\n    uivector lz77_encoded;\n    uivector_init(&lz77_encoded);\n    error = encodeLZ77(&lz77_encoded, hash, data, datapos, dataend, settings->windowsize,\n                       settings->minmatch, settings->nicematch, settings->lazymatching);\n    if(!error) writeLZ77data(bp, out, &lz77_encoded, &tree_ll, &tree_d);\n    uivector_cleanup(&lz77_encoded);\n  }\n  else /*no LZ77, but still will be Huffman compressed*/\n  {\n    for(i = datapos; i < dataend; i++)\n    {\n      addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, data[i]), HuffmanTree_getLength(&tree_ll, data[i]));\n    }\n  }\n  /*add END code*/\n  if(!error) addHuffmanSymbol(bp, out, HuffmanTree_getCode(&tree_ll, 256), HuffmanTree_getLength(&tree_ll, 256));\n\n  /*cleanup*/\n  HuffmanTree_cleanup(&tree_ll);\n  HuffmanTree_cleanup(&tree_d);\n\n  return error;\n}\n\nstatic unsigned lodepng_deflatev(ucvector* out, const unsigned char* in, size_t insize,\n                                 const LodePNGCompressSettings* settings)\n{\n  unsigned error = 0;\n  size_t i, blocksize, numdeflateblocks;\n  size_t bp = 0; /*the bit pointer*/\n  Hash hash;\n\n  if(settings->btype > 2) return 61;\n  else if(settings->btype == 0) return deflateNoCompression(out, in, insize);\n  else if(settings->btype == 1) blocksize = insize;\n  else /*if(settings->btype == 2)*/\n  {\n    blocksize = insize / 8 + 8;\n    if(blocksize < 65535) blocksize = 65535;\n  }\n\n  numdeflateblocks = (insize + blocksize - 1) / blocksize;\n  if(numdeflateblocks == 0) numdeflateblocks = 1;\n\n  error = hash_init(&hash, settings->windowsize);\n  if(error) return error;\n\n  for(i = 0; i < numdeflateblocks && !error; i++)\n  {\n    int final = i == numdeflateblocks - 1;\n    size_t start = i * blocksize;\n    size_t end = start + blocksize;\n    if(end > insize) end = insize;\n\n    if(settings->btype == 1) error = deflateFixed(out, &bp, &hash, in, start, end, settings, final);\n    else if(settings->btype == 2) error = deflateDynamic(out, &bp, &hash, in, start, end, settings, final);\n  }\n\n  hash_cleanup(&hash);\n\n  return error;\n}\n\nunsigned lodepng_deflate(unsigned char** out, size_t* outsize,\n                         const unsigned char* in, size_t insize,\n                         const LodePNGCompressSettings* settings)\n{\n  unsigned error;\n  ucvector v;\n  ucvector_init_buffer(&v, *out, *outsize);\n  error = lodepng_deflatev(&v, in, insize, settings);\n  *out = v.data;\n  *outsize = v.size;\n  return error;\n}\n\nstatic unsigned deflate(unsigned char** out, size_t* outsize,\n                        const unsigned char* in, size_t insize,\n                        const LodePNGCompressSettings* settings)\n{\n  if(settings->custom_deflate)\n  {\n    return settings->custom_deflate(out, outsize, in, insize, settings);\n  }\n  else\n  {\n    return lodepng_deflate(out, outsize, in, insize, settings);\n  }\n}\n\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Adler32                                                                  */\n/* ////////////////////////////////////////////////////////////////////////// */\n\nstatic unsigned update_adler32(unsigned adler, const unsigned char* data, unsigned len)\n{\n   unsigned s1 = adler & 0xffff;\n   unsigned s2 = (adler >> 16) & 0xffff;\n\n  while(len > 0)\n  {\n    /*at least 5550 sums can be done before the sums overflow, saving a lot of module divisions*/\n    unsigned amount = len > 5550 ? 5550 : len;\n    len -= amount;\n    while(amount > 0)\n    {\n      s1 += (*data++);\n      s2 += s1;\n      amount--;\n    }\n    s1 %= 65521;\n    s2 %= 65521;\n  }\n\n  return (s2 << 16) | s1;\n}\n\n/*Return the adler32 of the bytes data[0..len-1]*/\nstatic unsigned adler32(const unsigned char* data, unsigned len)\n{\n  return update_adler32(1L, data, len);\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Zlib                                                                   / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_DECODER\n\nunsigned lodepng_zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                                 size_t insize, const LodePNGDecompressSettings* settings)\n{\n  unsigned error = 0;\n  unsigned CM, CINFO, FDICT;\n\n  if(insize < 2) return 53; /*error, size of zlib data too small*/\n  /*read information from zlib header*/\n  if((in[0] * 256 + in[1]) % 31 != 0)\n  {\n    /*error: 256 * in[0] + in[1] must be a multiple of 31, the FCHECK value is supposed to be made that way*/\n    return 24;\n  }\n\n  CM = in[0] & 15;\n  CINFO = (in[0] >> 4) & 15;\n  /*FCHECK = in[1] & 31;*/ /*FCHECK is already tested above*/\n  FDICT = (in[1] >> 5) & 1;\n  /*FLEVEL = (in[1] >> 6) & 3;*/ /*FLEVEL is not used here*/\n\n  if(CM != 8 || CINFO > 7)\n  {\n    /*error: only compression method 8: inflate with sliding window of 32k is supported by the PNG spec*/\n    return 25;\n  }\n  if(FDICT != 0)\n  {\n    /*error: the specification of PNG says about the zlib stream:\n      \"The additional flags shall not specify a preset dictionary.\"*/\n    return 26;\n  }\n\n  error = inflate(out, outsize, in + 2, insize - 2, settings);\n  if(error) return error;\n\n  if(!settings->ignore_adler32)\n  {\n    unsigned ADLER32 = lodepng_read32bitInt(&in[insize - 4]);\n    unsigned checksum = adler32(*out, (unsigned)(*outsize));\n    if(checksum != ADLER32) return 58; /*error, adler checksum not correct, data must be corrupted*/\n  }\n\n  return 0; /*no error*/\n}\n\nstatic unsigned zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                                size_t insize, const LodePNGDecompressSettings* settings)\n{\n  if(settings->custom_zlib)\n    return settings->custom_zlib(out, outsize, in, insize, settings);\n  else\n    return lodepng_zlib_decompress(out, outsize, in, insize, settings);\n}\n\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\nunsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                               size_t insize, const LodePNGCompressSettings* settings)\n{\n  /*initially, *out must be NULL and outsize 0, if you just give some random *out\n  that's pointing to a non allocated buffer, this'll crash*/\n  ucvector outv;\n  size_t i;\n  unsigned error;\n  unsigned char* deflatedata = 0;\n  size_t deflatesize = 0;\n\n  unsigned ADLER32;\n  /*zlib data: 1 byte CMF (CM+CINFO), 1 byte FLG, deflate data, 4 byte ADLER32 checksum of the Decompressed data*/\n  unsigned CMF = 120; /*0b01111000: CM 8, CINFO 7. With CINFO 7, any window size up to 32768 can be used.*/\n  unsigned FLEVEL = 0;\n  unsigned FDICT = 0;\n  unsigned CMFFLG = 256 * CMF + FDICT * 32 + FLEVEL * 64;\n  unsigned FCHECK = 31 - CMFFLG % 31;\n  CMFFLG += FCHECK;\n\n  /*ucvector-controlled version of the output buffer, for dynamic array*/\n  ucvector_init_buffer(&outv, *out, *outsize);\n\n  ucvector_push_back(&outv, (unsigned char)(CMFFLG / 256));\n  ucvector_push_back(&outv, (unsigned char)(CMFFLG % 256));\n\n  error = deflate(&deflatedata, &deflatesize, in, insize, settings);\n\n  if(!error)\n  {\n    ADLER32 = adler32(in, (unsigned)insize);\n    for(i = 0; i < deflatesize; i++) ucvector_push_back(&outv, deflatedata[i]);\n    lodepng_free(deflatedata);\n    lodepng_add32bitInt(&outv, ADLER32);\n  }\n\n  *out = outv.data;\n  *outsize = outv.size;\n\n  return error;\n}\n\n/* compress using the default or custom zlib function */\nstatic unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                              size_t insize, const LodePNGCompressSettings* settings)\n{\n  if(settings->custom_zlib)\n  {\n    return settings->custom_zlib(out, outsize, in, insize, settings);\n  }\n  else\n  {\n    return lodepng_zlib_compress(out, outsize, in, insize, settings);\n  }\n}\n\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#else /*no LODEPNG_COMPILE_ZLIB*/\n\n#ifdef LODEPNG_COMPILE_DECODER\nstatic unsigned zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                                size_t insize, const LodePNGDecompressSettings* settings)\n{\n  if (!settings->custom_zlib) return 87; /*no custom zlib function provided */\n  return settings->custom_zlib(out, outsize, in, insize, settings);\n}\n#endif /*LODEPNG_COMPILE_DECODER*/\n#ifdef LODEPNG_COMPILE_ENCODER\nstatic unsigned zlib_compress(unsigned char** out, size_t* outsize, const unsigned char* in,\n                              size_t insize, const LodePNGCompressSettings* settings)\n{\n  if (!settings->custom_zlib) return 87; /*no custom zlib function provided */\n  return settings->custom_zlib(out, outsize, in, insize, settings);\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#endif /*LODEPNG_COMPILE_ZLIB*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\n/*this is a good tradeoff between speed and compression ratio*/\n#define DEFAULT_WINDOWSIZE 2048\n\nvoid lodepng_compress_settings_init(LodePNGCompressSettings* settings)\n{\n  /*compress with dynamic huffman tree (not in the mathematical sense, just not the predefined one)*/\n  settings->btype = 2;\n  settings->use_lz77 = 1;\n  settings->windowsize = DEFAULT_WINDOWSIZE;\n  settings->minmatch = 3;\n  settings->nicematch = 128;\n  settings->lazymatching = 1;\n\n  settings->custom_zlib = 0;\n  settings->custom_deflate = 0;\n  settings->custom_context = 0;\n}\n\nconst LodePNGCompressSettings lodepng_default_compress_settings = {2, 1, DEFAULT_WINDOWSIZE, 3, 128, 1, 0, 0, 0};\n\n\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#ifdef LODEPNG_COMPILE_DECODER\n\nvoid lodepng_decompress_settings_init(LodePNGDecompressSettings* settings)\n{\n  settings->ignore_adler32 = 0;\n\n  settings->custom_zlib = 0;\n  settings->custom_inflate = 0;\n  settings->custom_context = 0;\n}\n\nconst LodePNGDecompressSettings lodepng_default_decompress_settings = {0, 0, 0, 0};\n\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* // End of Zlib related code. Begin of PNG related code.                 // */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n#ifdef LODEPNG_COMPILE_PNG\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / CRC32                                                                  / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/* CRC polynomial: 0xedb88320 */\nstatic unsigned lodepng_crc32_table[256] = {\n           0u, 1996959894u, 3993919788u, 2567524794u,  124634137u, 1886057615u, 3915621685u, 2657392035u,\n   249268274u, 2044508324u, 3772115230u, 2547177864u,  162941995u, 2125561021u, 3887607047u, 2428444049u,\n   498536548u, 1789927666u, 4089016648u, 2227061214u,  450548861u, 1843258603u, 4107580753u, 2211677639u,\n   325883990u, 1684777152u, 4251122042u, 2321926636u,  335633487u, 1661365465u, 4195302755u, 2366115317u,\n   997073096u, 1281953886u, 3579855332u, 2724688242u, 1006888145u, 1258607687u, 3524101629u, 2768942443u,\n   901097722u, 1119000684u, 3686517206u, 2898065728u,  853044451u, 1172266101u, 3705015759u, 2882616665u,\n   651767980u, 1373503546u, 3369554304u, 3218104598u,  565507253u, 1454621731u, 3485111705u, 3099436303u,\n   671266974u, 1594198024u, 3322730930u, 2970347812u,  795835527u, 1483230225u, 3244367275u, 3060149565u,\n  1994146192u,   31158534u, 2563907772u, 4023717930u, 1907459465u,  112637215u, 2680153253u, 3904427059u,\n  2013776290u,  251722036u, 2517215374u, 3775830040u, 2137656763u,  141376813u, 2439277719u, 3865271297u,\n  1802195444u,  476864866u, 2238001368u, 4066508878u, 1812370925u,  453092731u, 2181625025u, 4111451223u,\n  1706088902u,  314042704u, 2344532202u, 4240017532u, 1658658271u,  366619977u, 2362670323u, 4224994405u,\n  1303535960u,  984961486u, 2747007092u, 3569037538u, 1256170817u, 1037604311u, 2765210733u, 3554079995u,\n  1131014506u,  879679996u, 2909243462u, 3663771856u, 1141124467u,  855842277u, 2852801631u, 3708648649u,\n  1342533948u,  654459306u, 3188396048u, 3373015174u, 1466479909u,  544179635u, 3110523913u, 3462522015u,\n  1591671054u,  702138776u, 2966460450u, 3352799412u, 1504918807u,  783551873u, 3082640443u, 3233442989u,\n  3988292384u, 2596254646u,   62317068u, 1957810842u, 3939845945u, 2647816111u,   81470997u, 1943803523u,\n  3814918930u, 2489596804u,  225274430u, 2053790376u, 3826175755u, 2466906013u,  167816743u, 2097651377u,\n  4027552580u, 2265490386u,  503444072u, 1762050814u, 4150417245u, 2154129355u,  426522225u, 1852507879u,\n  4275313526u, 2312317920u,  282753626u, 1742555852u, 4189708143u, 2394877945u,  397917763u, 1622183637u,\n  3604390888u, 2714866558u,  953729732u, 1340076626u, 3518719985u, 2797360999u, 1068828381u, 1219638859u,\n  3624741850u, 2936675148u,  906185462u, 1090812512u, 3747672003u, 2825379669u,  829329135u, 1181335161u,\n  3412177804u, 3160834842u,  628085408u, 1382605366u, 3423369109u, 3138078467u,  570562233u, 1426400815u,\n  3317316542u, 2998733608u,  733239954u, 1555261956u, 3268935591u, 3050360625u,  752459403u, 1541320221u,\n  2607071920u, 3965973030u, 1969922972u,   40735498u, 2617837225u, 3943577151u, 1913087877u,   83908371u,\n  2512341634u, 3803740692u, 2075208622u,  213261112u, 2463272603u, 3855990285u, 2094854071u,  198958881u,\n  2262029012u, 4057260610u, 1759359992u,  534414190u, 2176718541u, 4139329115u, 1873836001u,  414664567u,\n  2282248934u, 4279200368u, 1711684554u,  285281116u, 2405801727u, 4167216745u, 1634467795u,  376229701u,\n  2685067896u, 3608007406u, 1308918612u,  956543938u, 2808555105u, 3495958263u, 1231636301u, 1047427035u,\n  2932959818u, 3654703836u, 1088359270u,  936918000u, 2847714899u, 3736837829u, 1202900863u,  817233897u,\n  3183342108u, 3401237130u, 1404277552u,  615818150u, 3134207493u, 3453421203u, 1423857449u,  601450431u,\n  3009837614u, 3294710456u, 1567103746u,  711928724u, 3020668471u, 3272380065u, 1510334235u,  755167117u\n};\n\n/*Return the CRC of the bytes buf[0..len-1].*/\nunsigned lodepng_crc32(const unsigned char* buf, size_t len)\n{\n  unsigned c = 0xffffffffL;\n  size_t n;\n\n  for(n = 0; n < len; n++)\n  {\n    c = lodepng_crc32_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);\n  }\n  return c ^ 0xffffffffL;\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Reading and writing single bits and bytes from/to stream for LodePNG   / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\nstatic unsigned char readBitFromReversedStream(size_t* bitpointer, const unsigned char* bitstream)\n{\n  unsigned char result = (unsigned char)((bitstream[(*bitpointer) >> 3] >> (7 - ((*bitpointer) & 0x7))) & 1);\n  (*bitpointer)++;\n  return result;\n}\n\nstatic unsigned readBitsFromReversedStream(size_t* bitpointer, const unsigned char* bitstream, size_t nbits)\n{\n  unsigned result = 0;\n  size_t i;\n  for(i = nbits - 1; i < nbits; i--)\n  {\n    result += (unsigned)readBitFromReversedStream(bitpointer, bitstream) << i;\n  }\n  return result;\n}\n\n#ifdef LODEPNG_COMPILE_DECODER\nstatic void setBitOfReversedStream0(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)\n{\n  /*the current bit in bitstream must be 0 for this to work*/\n  if(bit)\n  {\n    /*earlier bit of huffman code is in a lesser significant bit of an earlier byte*/\n    bitstream[(*bitpointer) >> 3] |= (bit << (7 - ((*bitpointer) & 0x7)));\n  }\n  (*bitpointer)++;\n}\n#endif /*LODEPNG_COMPILE_DECODER*/\n\nstatic void setBitOfReversedStream(size_t* bitpointer, unsigned char* bitstream, unsigned char bit)\n{\n  /*the current bit in bitstream may be 0 or 1 for this to work*/\n  if(bit == 0) bitstream[(*bitpointer) >> 3] &=  (unsigned char)(~(1 << (7 - ((*bitpointer) & 0x7))));\n  else         bitstream[(*bitpointer) >> 3] |=  (1 << (7 - ((*bitpointer) & 0x7)));\n  (*bitpointer)++;\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / PNG chunks                                                             / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\nunsigned lodepng_chunk_length(const unsigned char* chunk)\n{\n  return lodepng_read32bitInt(&chunk[0]);\n}\n\nvoid lodepng_chunk_type(char type[5], const unsigned char* chunk)\n{\n  unsigned i;\n  for(i = 0; i < 4; i++) type[i] = chunk[4 + i];\n  type[4] = 0; /*null termination char*/\n}\n\nunsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type)\n{\n  if(strlen(type) != 4) return 0;\n  return (chunk[4] == type[0] && chunk[5] == type[1] && chunk[6] == type[2] && chunk[7] == type[3]);\n}\n\nunsigned char lodepng_chunk_ancillary(const unsigned char* chunk)\n{\n  return((chunk[4] & 32) != 0);\n}\n\nunsigned char lodepng_chunk_private(const unsigned char* chunk)\n{\n  return((chunk[6] & 32) != 0);\n}\n\nunsigned char lodepng_chunk_safetocopy(const unsigned char* chunk)\n{\n  return((chunk[7] & 32) != 0);\n}\n\nunsigned char* lodepng_chunk_data(unsigned char* chunk)\n{\n  return &chunk[8];\n}\n\nconst unsigned char* lodepng_chunk_data_const(const unsigned char* chunk)\n{\n  return &chunk[8];\n}\n\nunsigned lodepng_chunk_check_crc(const unsigned char* chunk)\n{\n  unsigned length = lodepng_chunk_length(chunk);\n  unsigned CRC = lodepng_read32bitInt(&chunk[length + 8]);\n  /*the CRC is taken of the data and the 4 chunk type letters, not the length*/\n  unsigned checksum = lodepng_crc32(&chunk[4], length + 4);\n  if(CRC != checksum) return 1;\n  else return 0;\n}\n\nvoid lodepng_chunk_generate_crc(unsigned char* chunk)\n{\n  unsigned length = lodepng_chunk_length(chunk);\n  unsigned CRC = lodepng_crc32(&chunk[4], length + 4);\n  lodepng_set32bitInt(chunk + 8 + length, CRC);\n}\n\nunsigned char* lodepng_chunk_next(unsigned char* chunk)\n{\n  unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;\n  return &chunk[total_chunk_length];\n}\n\nconst unsigned char* lodepng_chunk_next_const(const unsigned char* chunk)\n{\n  unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;\n  return &chunk[total_chunk_length];\n}\n\nunsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk)\n{\n  unsigned i;\n  unsigned total_chunk_length = lodepng_chunk_length(chunk) + 12;\n  unsigned char *chunk_start, *new_buffer;\n  size_t new_length = (*outlength) + total_chunk_length;\n  if(new_length < total_chunk_length || new_length < (*outlength)) return 77; /*integer overflow happened*/\n\n  new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);\n  if(!new_buffer) return 83; /*alloc fail*/\n  (*out) = new_buffer;\n  (*outlength) = new_length;\n  chunk_start = &(*out)[new_length - total_chunk_length];\n\n  for(i = 0; i < total_chunk_length; i++) chunk_start[i] = chunk[i];\n\n  return 0;\n}\n\nunsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,\n                              const char* type, const unsigned char* data)\n{\n  unsigned i;\n  unsigned char *chunk, *new_buffer;\n  size_t new_length = (*outlength) + length + 12;\n  if(new_length < length + 12 || new_length < (*outlength)) return 77; /*integer overflow happened*/\n  new_buffer = (unsigned char*)lodepng_realloc(*out, new_length);\n  if(!new_buffer) return 83; /*alloc fail*/\n  (*out) = new_buffer;\n  (*outlength) = new_length;\n  chunk = &(*out)[(*outlength) - length - 12];\n\n  /*1: length*/\n  lodepng_set32bitInt(chunk, (unsigned)length);\n\n  /*2: chunk name (4 letters)*/\n  chunk[4] = type[0];\n  chunk[5] = type[1];\n  chunk[6] = type[2];\n  chunk[7] = type[3];\n\n  /*3: the data*/\n  for(i = 0; i < length; i++) chunk[8 + i] = data[i];\n\n  /*4: CRC (of the chunkname characters and the data)*/\n  lodepng_chunk_generate_crc(chunk);\n\n  return 0;\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / Color types and such                                                   / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*return type is a LodePNG error code*/\nstatic unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) /*bd = bitdepth*/\n{\n  switch(colortype)\n  {\n    case 0: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break; /*grey*/\n    case 2: if(!(                                 bd == 8 || bd == 16)) return 37; break; /*RGB*/\n    case 3: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8            )) return 37; break; /*palette*/\n    case 4: if(!(                                 bd == 8 || bd == 16)) return 37; break; /*grey + alpha*/\n    case 6: if(!(                                 bd == 8 || bd == 16)) return 37; break; /*RGBA*/\n    default: return 31;\n  }\n  return 0; /*allowed color type / bits combination*/\n}\n\nstatic unsigned getNumColorChannels(LodePNGColorType colortype)\n{\n  switch(colortype)\n  {\n    case 0: return 1; /*grey*/\n    case 2: return 3; /*RGB*/\n    case 3: return 1; /*palette*/\n    case 4: return 2; /*grey + alpha*/\n    case 6: return 4; /*RGBA*/\n  }\n  return 0; /*unexisting color type*/\n}\n\nstatic unsigned lodepng_get_bpp_lct(LodePNGColorType colortype, unsigned bitdepth)\n{\n  /*bits per pixel is amount of channels * bits per channel*/\n  return getNumColorChannels(colortype) * bitdepth;\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\nvoid lodepng_color_mode_init(LodePNGColorMode* info)\n{\n  info->key_defined = 0;\n  info->key_r = info->key_g = info->key_b = 0;\n  info->colortype = LCT_RGBA;\n  info->bitdepth = 8;\n  info->palette = 0;\n  info->palettesize = 0;\n}\n\nvoid lodepng_color_mode_cleanup(LodePNGColorMode* info)\n{\n  lodepng_palette_clear(info);\n}\n\nunsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source)\n{\n  size_t i;\n  lodepng_color_mode_cleanup(dest);\n  *dest = *source;\n  if(source->palette)\n  {\n    dest->palette = (unsigned char*)lodepng_malloc(1024);\n    if(!dest->palette && source->palettesize) return 83; /*alloc fail*/\n    for(i = 0; i < source->palettesize * 4; i++) dest->palette[i] = source->palette[i];\n  }\n  return 0;\n}\n\nstatic int lodepng_color_mode_equal(const LodePNGColorMode* a, const LodePNGColorMode* b)\n{\n  size_t i;\n  if(a->colortype != b->colortype) return 0;\n  if(a->bitdepth != b->bitdepth) return 0;\n  if(a->key_defined != b->key_defined) return 0;\n  if(a->key_defined)\n  {\n    if(a->key_r != b->key_r) return 0;\n    if(a->key_g != b->key_g) return 0;\n    if(a->key_b != b->key_b) return 0;\n  }\n  if(a->palettesize != b->palettesize) return 0;\n  for(i = 0; i < a->palettesize * 4; i++)\n  {\n    if(a->palette[i] != b->palette[i]) return 0;\n  }\n  return 1;\n}\n\nvoid lodepng_palette_clear(LodePNGColorMode* info)\n{\n  if(info->palette) lodepng_free(info->palette);\n  info->palette = 0;\n  info->palettesize = 0;\n}\n\nunsigned lodepng_palette_add(LodePNGColorMode* info,\n                             unsigned char r, unsigned char g, unsigned char b, unsigned char a)\n{\n  unsigned char* data;\n  /*the same resize technique as C++ std::vectors is used, and here it's made so that for a palette with\n  the max of 256 colors, it'll have the exact alloc size*/\n  if(!info->palette) /*allocate palette if empty*/\n  {\n    /*room for 256 colors with 4 bytes each*/\n    data = (unsigned char*)lodepng_realloc(info->palette, 1024);\n    if(!data) return 83; /*alloc fail*/\n    else info->palette = data;\n  }\n  info->palette[4 * info->palettesize + 0] = r;\n  info->palette[4 * info->palettesize + 1] = g;\n  info->palette[4 * info->palettesize + 2] = b;\n  info->palette[4 * info->palettesize + 3] = a;\n  info->palettesize++;\n  return 0;\n}\n\nunsigned lodepng_get_bpp(const LodePNGColorMode* info)\n{\n  /*calculate bits per pixel out of colortype and bitdepth*/\n  return lodepng_get_bpp_lct(info->colortype, info->bitdepth);\n}\n\nunsigned lodepng_get_channels(const LodePNGColorMode* info)\n{\n  return getNumColorChannels(info->colortype);\n}\n\nunsigned lodepng_is_greyscale_type(const LodePNGColorMode* info)\n{\n  return info->colortype == LCT_GREY || info->colortype == LCT_GREY_ALPHA;\n}\n\nunsigned lodepng_is_alpha_type(const LodePNGColorMode* info)\n{\n  return (info->colortype & 4) != 0; /*4 or 6*/\n}\n\nunsigned lodepng_is_palette_type(const LodePNGColorMode* info)\n{\n  return info->colortype == LCT_PALETTE;\n}\n\nunsigned lodepng_has_palette_alpha(const LodePNGColorMode* info)\n{\n  size_t i;\n  for(i = 0; i < info->palettesize; i++)\n  {\n    if(info->palette[i * 4 + 3] < 255) return 1;\n  }\n  return 0;\n}\n\nunsigned lodepng_can_have_alpha(const LodePNGColorMode* info)\n{\n  return info->key_defined\n      || lodepng_is_alpha_type(info)\n      || lodepng_has_palette_alpha(info);\n}\n\nsize_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color)\n{\n  return (w * h * lodepng_get_bpp(color) + 7) / 8;\n}\n\nsize_t lodepng_get_raw_size_lct(unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)\n{\n  return (w * h * lodepng_get_bpp_lct(colortype, bitdepth) + 7) / 8;\n}\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n\nstatic void LodePNGUnknownChunks_init(LodePNGInfo* info)\n{\n  unsigned i;\n  for(i = 0; i < 3; i++) info->unknown_chunks_data[i] = 0;\n  for(i = 0; i < 3; i++) info->unknown_chunks_size[i] = 0;\n}\n\nstatic void LodePNGUnknownChunks_cleanup(LodePNGInfo* info)\n{\n  unsigned i;\n  for(i = 0; i < 3; i++) lodepng_free(info->unknown_chunks_data[i]);\n}\n\nstatic unsigned LodePNGUnknownChunks_copy(LodePNGInfo* dest, const LodePNGInfo* src)\n{\n  unsigned i;\n\n  LodePNGUnknownChunks_cleanup(dest);\n\n  for(i = 0; i < 3; i++)\n  {\n    size_t j;\n    dest->unknown_chunks_size[i] = src->unknown_chunks_size[i];\n    dest->unknown_chunks_data[i] = (unsigned char*)lodepng_malloc(src->unknown_chunks_size[i]);\n    if(!dest->unknown_chunks_data[i] && dest->unknown_chunks_size[i]) return 83; /*alloc fail*/\n    for(j = 0; j < src->unknown_chunks_size[i]; j++)\n    {\n      dest->unknown_chunks_data[i][j] = src->unknown_chunks_data[i][j];\n    }\n  }\n\n  return 0;\n}\n\n/******************************************************************************/\n\nstatic void LodePNGText_init(LodePNGInfo* info)\n{\n  info->text_num = 0;\n  info->text_keys = NULL;\n  info->text_strings = NULL;\n}\n\nstatic void LodePNGText_cleanup(LodePNGInfo* info)\n{\n  size_t i;\n  for(i = 0; i < info->text_num; i++)\n  {\n    string_cleanup(&info->text_keys[i]);\n    string_cleanup(&info->text_strings[i]);\n  }\n  lodepng_free(info->text_keys);\n  lodepng_free(info->text_strings);\n}\n\nstatic unsigned LodePNGText_copy(LodePNGInfo* dest, const LodePNGInfo* source)\n{\n  size_t i = 0;\n  dest->text_keys = 0;\n  dest->text_strings = 0;\n  dest->text_num = 0;\n  for(i = 0; i < source->text_num; i++)\n  {\n    CERROR_TRY_RETURN(lodepng_add_text(dest, source->text_keys[i], source->text_strings[i]));\n  }\n  return 0;\n}\n\nvoid lodepng_clear_text(LodePNGInfo* info)\n{\n  LodePNGText_cleanup(info);\n}\n\nunsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str)\n{\n  char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1)));\n  char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num + 1)));\n  if(!new_keys || !new_strings)\n  {\n    lodepng_free(new_keys);\n    lodepng_free(new_strings);\n    return 83; /*alloc fail*/\n  }\n\n  info->text_num++;\n  info->text_keys = new_keys;\n  info->text_strings = new_strings;\n\n  string_init(&info->text_keys[info->text_num - 1]);\n  string_set(&info->text_keys[info->text_num - 1], key);\n\n  string_init(&info->text_strings[info->text_num - 1]);\n  string_set(&info->text_strings[info->text_num - 1], str);\n\n  return 0;\n}\n\n/******************************************************************************/\n\nstatic void LodePNGIText_init(LodePNGInfo* info)\n{\n  info->itext_num = 0;\n  info->itext_keys = NULL;\n  info->itext_langtags = NULL;\n  info->itext_transkeys = NULL;\n  info->itext_strings = NULL;\n}\n\nstatic void LodePNGIText_cleanup(LodePNGInfo* info)\n{\n  size_t i;\n  for(i = 0; i < info->itext_num; i++)\n  {\n    string_cleanup(&info->itext_keys[i]);\n    string_cleanup(&info->itext_langtags[i]);\n    string_cleanup(&info->itext_transkeys[i]);\n    string_cleanup(&info->itext_strings[i]);\n  }\n  lodepng_free(info->itext_keys);\n  lodepng_free(info->itext_langtags);\n  lodepng_free(info->itext_transkeys);\n  lodepng_free(info->itext_strings);\n}\n\nstatic unsigned LodePNGIText_copy(LodePNGInfo* dest, const LodePNGInfo* source)\n{\n  size_t i = 0;\n  dest->itext_keys = 0;\n  dest->itext_langtags = 0;\n  dest->itext_transkeys = 0;\n  dest->itext_strings = 0;\n  dest->itext_num = 0;\n  for(i = 0; i < source->itext_num; i++)\n  {\n    CERROR_TRY_RETURN(lodepng_add_itext(dest, source->itext_keys[i], source->itext_langtags[i],\n                                        source->itext_transkeys[i], source->itext_strings[i]));\n  }\n  return 0;\n}\n\nvoid lodepng_clear_itext(LodePNGInfo* info)\n{\n  LodePNGIText_cleanup(info);\n}\n\nunsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag,\n                           const char* transkey, const char* str)\n{\n  char** new_keys = (char**)(lodepng_realloc(info->itext_keys, sizeof(char*) * (info->itext_num + 1)));\n  char** new_langtags = (char**)(lodepng_realloc(info->itext_langtags, sizeof(char*) * (info->itext_num + 1)));\n  char** new_transkeys = (char**)(lodepng_realloc(info->itext_transkeys, sizeof(char*) * (info->itext_num + 1)));\n  char** new_strings = (char**)(lodepng_realloc(info->itext_strings, sizeof(char*) * (info->itext_num + 1)));\n  if(!new_keys || !new_langtags || !new_transkeys || !new_strings)\n  {\n    lodepng_free(new_keys);\n    lodepng_free(new_langtags);\n    lodepng_free(new_transkeys);\n    lodepng_free(new_strings);\n    return 83; /*alloc fail*/\n  }\n\n  info->itext_num++;\n  info->itext_keys = new_keys;\n  info->itext_langtags = new_langtags;\n  info->itext_transkeys = new_transkeys;\n  info->itext_strings = new_strings;\n\n  string_init(&info->itext_keys[info->itext_num - 1]);\n  string_set(&info->itext_keys[info->itext_num - 1], key);\n\n  string_init(&info->itext_langtags[info->itext_num - 1]);\n  string_set(&info->itext_langtags[info->itext_num - 1], langtag);\n\n  string_init(&info->itext_transkeys[info->itext_num - 1]);\n  string_set(&info->itext_transkeys[info->itext_num - 1], transkey);\n\n  string_init(&info->itext_strings[info->itext_num - 1]);\n  string_set(&info->itext_strings[info->itext_num - 1], str);\n\n  return 0;\n}\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\nvoid lodepng_info_init(LodePNGInfo* info)\n{\n  lodepng_color_mode_init(&info->color);\n  info->interlace_method = 0;\n  info->compression_method = 0;\n  info->filter_method = 0;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  info->background_defined = 0;\n  info->background_r = info->background_g = info->background_b = 0;\n\n  LodePNGText_init(info);\n  LodePNGIText_init(info);\n\n  info->time_defined = 0;\n  info->phys_defined = 0;\n\n  LodePNGUnknownChunks_init(info);\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n}\n\nvoid lodepng_info_cleanup(LodePNGInfo* info)\n{\n  lodepng_color_mode_cleanup(&info->color);\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  LodePNGText_cleanup(info);\n  LodePNGIText_cleanup(info);\n\n  LodePNGUnknownChunks_cleanup(info);\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n}\n\nunsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source)\n{\n  lodepng_info_cleanup(dest);\n  *dest = *source;\n  lodepng_color_mode_init(&dest->color);\n  CERROR_TRY_RETURN(lodepng_color_mode_copy(&dest->color, &source->color));\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  CERROR_TRY_RETURN(LodePNGText_copy(dest, source));\n  CERROR_TRY_RETURN(LodePNGIText_copy(dest, source));\n\n  LodePNGUnknownChunks_init(dest);\n  CERROR_TRY_RETURN(LodePNGUnknownChunks_copy(dest, source));\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n  return 0;\n}\n\nvoid lodepng_info_swap(LodePNGInfo* a, LodePNGInfo* b)\n{\n  LodePNGInfo temp = *a;\n  *a = *b;\n  *b = temp;\n}\n\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*index: bitgroup index, bits: bitgroup size(1, 2 or 4, in: bitgroup value, out: octet array to add bits to*/\nstatic void addColorBits(unsigned char* out, size_t index, unsigned bits, unsigned in)\n{\n  /*p = the partial index in the byte, e.g. with 4 palettebits it is 0 for first half or 1 for second half*/\n  unsigned p = index % (8 / bits);\n  in &= (1 << bits) - 1; /*filter out any other bits of the input value*/\n  in = in << (bits * (8 / bits - p - 1));\n  if(p == 0) out[index * bits / 8] = in;\n  else out[index * bits / 8] |= in;\n}\n\ntypedef struct ColorTree ColorTree;\n\n/*\nOne node of a color tree\nThis is the data structure used to count the number of unique colors and to get a palette\nindex for a color. It's like an octree, but because the alpha channel is used too, each\nnode has 16 instead of 8 children.\n*/\nstruct ColorTree\n{\n  ColorTree* children[16]; /*up to 16 pointers to ColorTree of next level*/\n  int index; /*the payload. Only has a meaningful value if this is in the last level*/\n};\n\nstatic void color_tree_init(ColorTree* tree)\n{\n  int i;\n  for(i = 0; i < 16; i++) tree->children[i] = 0;\n  tree->index = -1;\n}\n\nstatic void color_tree_cleanup(ColorTree* tree)\n{\n  int i;\n  for(i = 0; i < 16; i++)\n  {\n    if(tree->children[i])\n    {\n      color_tree_cleanup(tree->children[i]);\n      lodepng_free(tree->children[i]);\n    }\n  }\n}\n\n/*returns -1 if color not present, its index otherwise*/\nstatic int color_tree_get(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a)\n{\n  int bit = 0;\n  for(bit = 0; bit < 8; bit++)\n  {\n    int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);\n    if(!tree->children[i]) return -1;\n    else tree = tree->children[i];\n  }\n  return tree ? tree->index : -1;\n}\n\n#ifdef LODEPNG_COMPILE_ENCODER\nstatic int color_tree_has(ColorTree* tree, unsigned char r, unsigned char g, unsigned char b, unsigned char a)\n{\n  return color_tree_get(tree, r, g, b, a) >= 0;\n}\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n/*color is not allowed to already exist.\nIndex should be >= 0 (it's signed to be compatible with using -1 for \"doesn't exist\")*/\nstatic void color_tree_add(ColorTree* tree,\n                           unsigned char r, unsigned char g, unsigned char b, unsigned char a, int index)\n{\n  int bit;\n  for(bit = 0; bit < 8; bit++)\n  {\n    int i = 8 * ((r >> bit) & 1) + 4 * ((g >> bit) & 1) + 2 * ((b >> bit) & 1) + 1 * ((a >> bit) & 1);\n    if(!tree->children[i])\n    {\n      tree->children[i] = (ColorTree*)lodepng_malloc(sizeof(ColorTree));\n      color_tree_init(tree->children[i]);\n    }\n    tree = tree->children[i];\n  }\n  tree->index = index;\n}\n\n/*put a pixel, given its RGBA color, into image of any color type*/\nstatic unsigned rgba8ToPixel(unsigned char* out, size_t i,\n                             const LodePNGColorMode* mode, ColorTree* tree /*for palette*/,\n                             unsigned char r, unsigned char g, unsigned char b, unsigned char a)\n{\n  if(mode->colortype == LCT_GREY)\n  {\n    unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;\n    if(mode->bitdepth == 8) out[i] = grey;\n    else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = grey;\n    else\n    {\n      /*take the most significant bits of grey*/\n      grey = (grey >> (8 - mode->bitdepth)) & ((1 << mode->bitdepth) - 1);\n      addColorBits(out, i, mode->bitdepth, grey);\n    }\n  }\n  else if(mode->colortype == LCT_RGB)\n  {\n    if(mode->bitdepth == 8)\n    {\n      out[i * 3 + 0] = r;\n      out[i * 3 + 1] = g;\n      out[i * 3 + 2] = b;\n    }\n    else\n    {\n      out[i * 6 + 0] = out[i * 6 + 1] = r;\n      out[i * 6 + 2] = out[i * 6 + 3] = g;\n      out[i * 6 + 4] = out[i * 6 + 5] = b;\n    }\n  }\n  else if(mode->colortype == LCT_PALETTE)\n  {\n    int index = color_tree_get(tree, r, g, b, a);\n    if(index < 0) return 82; /*color not in palette*/\n    if(mode->bitdepth == 8) out[i] = index;\n    else addColorBits(out, i, mode->bitdepth, index);\n  }\n  else if(mode->colortype == LCT_GREY_ALPHA)\n  {\n    unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;\n    if(mode->bitdepth == 8)\n    {\n      out[i * 2 + 0] = grey;\n      out[i * 2 + 1] = a;\n    }\n    else if(mode->bitdepth == 16)\n    {\n      out[i * 4 + 0] = out[i * 4 + 1] = grey;\n      out[i * 4 + 2] = out[i * 4 + 3] = a;\n    }\n  }\n  else if(mode->colortype == LCT_RGBA)\n  {\n    if(mode->bitdepth == 8)\n    {\n      out[i * 4 + 0] = r;\n      out[i * 4 + 1] = g;\n      out[i * 4 + 2] = b;\n      out[i * 4 + 3] = a;\n    }\n    else\n    {\n      out[i * 8 + 0] = out[i * 8 + 1] = r;\n      out[i * 8 + 2] = out[i * 8 + 3] = g;\n      out[i * 8 + 4] = out[i * 8 + 5] = b;\n      out[i * 8 + 6] = out[i * 8 + 7] = a;\n    }\n  }\n\n  return 0; /*no error*/\n}\n\n/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/\nstatic unsigned rgba16ToPixel(unsigned char* out, size_t i,\n                              const LodePNGColorMode* mode,\n                              unsigned short r, unsigned short g, unsigned short b, unsigned short a)\n{\n  if(mode->bitdepth != 16) return 85; /*must be 16 for this function*/\n  if(mode->colortype == LCT_GREY)\n  {\n    unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;\n    out[i * 2 + 0] = (grey >> 8) & 255;\n    out[i * 2 + 1] = grey & 255;\n  }\n  else if(mode->colortype == LCT_RGB)\n  {\n    out[i * 6 + 0] = (r >> 8) & 255;\n    out[i * 6 + 1] = r & 255;\n    out[i * 6 + 2] = (g >> 8) & 255;\n    out[i * 6 + 3] = g & 255;\n    out[i * 6 + 4] = (b >> 8) & 255;\n    out[i * 6 + 5] = b & 255;\n  }\n  else if(mode->colortype == LCT_GREY_ALPHA)\n  {\n    unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;\n    out[i * 4 + 0] = (grey >> 8) & 255;\n    out[i * 4 + 1] = grey & 255;\n    out[i * 4 + 2] = (a >> 8) & 255;\n    out[i * 4 + 3] = a & 255;\n  }\n  else if(mode->colortype == LCT_RGBA)\n  {\n    out[i * 8 + 0] = (r >> 8) & 255;\n    out[i * 8 + 1] = r & 255;\n    out[i * 8 + 2] = (g >> 8) & 255;\n    out[i * 8 + 3] = g & 255;\n    out[i * 8 + 4] = (b >> 8) & 255;\n    out[i * 8 + 5] = b & 255;\n    out[i * 8 + 6] = (a >> 8) & 255;\n    out[i * 8 + 7] = a & 255;\n  }\n\n  return 0; /*no error*/\n}\n\n/*Get RGBA8 color of pixel with index i (y * width + x) from the raw image with given color type.*/\nstatic unsigned getPixelColorRGBA8(unsigned char* r, unsigned char* g,\n                                   unsigned char* b, unsigned char* a,\n                                   const unsigned char* in, size_t i,\n                                   const LodePNGColorMode* mode,\n                                   unsigned fix_png)\n{\n  if(mode->colortype == LCT_GREY)\n  {\n    if(mode->bitdepth == 8)\n    {\n      *r = *g = *b = in[i];\n      if(mode->key_defined && *r == mode->key_r) *a = 0;\n      else *a = 255;\n    }\n    else if(mode->bitdepth == 16)\n    {\n      *r = *g = *b = in[i * 2 + 0];\n      if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;\n      else *a = 255;\n    }\n    else\n    {\n      unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/\n      size_t j = i * mode->bitdepth;\n      unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);\n      *r = *g = *b = (value * 255) / highest;\n      if(mode->key_defined && value == mode->key_r) *a = 0;\n      else *a = 255;\n    }\n  }\n  else if(mode->colortype == LCT_RGB)\n  {\n    if(mode->bitdepth == 8)\n    {\n      *r = in[i * 3 + 0]; *g = in[i * 3 + 1]; *b = in[i * 3 + 2];\n      if(mode->key_defined && *r == mode->key_r && *g == mode->key_g && *b == mode->key_b) *a = 0;\n      else *a = 255;\n    }\n    else\n    {\n      *r = in[i * 6 + 0];\n      *g = in[i * 6 + 2];\n      *b = in[i * 6 + 4];\n      if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r\n         && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g\n         && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;\n      else *a = 255;\n    }\n  }\n  else if(mode->colortype == LCT_PALETTE)\n  {\n    unsigned index;\n    if(mode->bitdepth == 8) index = in[i];\n    else\n    {\n      size_t j = i * mode->bitdepth;\n      index = readBitsFromReversedStream(&j, in, mode->bitdepth);\n    }\n\n    if(index >= mode->palettesize)\n    {\n      /*This is an error according to the PNG spec, but fix_png can ignore it*/\n      if(!fix_png) return (mode->bitdepth == 8 ? 46 : 47); /*index out of palette*/\n      *r = *g = *b = 0;\n      *a = 255;\n    }\n    else\n    {\n      *r = mode->palette[index * 4 + 0];\n      *g = mode->palette[index * 4 + 1];\n      *b = mode->palette[index * 4 + 2];\n      *a = mode->palette[index * 4 + 3];\n    }\n  }\n  else if(mode->colortype == LCT_GREY_ALPHA)\n  {\n    if(mode->bitdepth == 8)\n    {\n      *r = *g = *b = in[i * 2 + 0];\n      *a = in[i * 2 + 1];\n    }\n    else\n    {\n      *r = *g = *b = in[i * 4 + 0];\n      *a = in[i * 4 + 2];\n    }\n  }\n  else if(mode->colortype == LCT_RGBA)\n  {\n    if(mode->bitdepth == 8)\n    {\n      *r = in[i * 4 + 0];\n      *g = in[i * 4 + 1];\n      *b = in[i * 4 + 2];\n      *a = in[i * 4 + 3];\n    }\n    else\n    {\n      *r = in[i * 8 + 0];\n      *g = in[i * 8 + 2];\n      *b = in[i * 8 + 4];\n      *a = in[i * 8 + 6];\n    }\n  }\n\n  return 0; /*no error*/\n}\n\n/*Similar to getPixelColorRGBA8, but with all the for loops inside of the color\nmode test cases, optimized to convert the colors much faster, when converting\nto RGBA or RGB with 8 bit per cannel. buffer must be RGBA or RGB output with\nenough memory, if has_alpha is true the output is RGBA. mode has the color mode\nof the input buffer.*/\nstatic unsigned getPixelColorsRGBA8(unsigned char* buffer, size_t numpixels,\n                                    unsigned has_alpha, const unsigned char* in,\n                                    const LodePNGColorMode* mode,\n                                    unsigned fix_png)\n{\n  unsigned num_channels = has_alpha ? 4 : 3;\n  size_t i;\n  if(mode->colortype == LCT_GREY)\n  {\n    if(mode->bitdepth == 8)\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = buffer[1] = buffer[2] = in[i];\n        if(has_alpha) buffer[3] = mode->key_defined && in[i] == mode->key_r ? 0 : 255;\n      }\n    }\n    else if(mode->bitdepth == 16)\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = buffer[1] = buffer[2] = in[i * 2];\n        if(has_alpha) buffer[3] = mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r ? 0 : 255;\n      }\n    }\n    else\n    {\n      unsigned highest = ((1U << mode->bitdepth) - 1U); /*highest possible value for this bit depth*/\n      size_t j = 0;\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        unsigned value = readBitsFromReversedStream(&j, in, mode->bitdepth);\n        buffer[0] = buffer[1] = buffer[2] = (value * 255) / highest;\n        if(has_alpha) buffer[3] = mode->key_defined && value == mode->key_r ? 0 : 255;\n      }\n    }\n  }\n  else if(mode->colortype == LCT_RGB)\n  {\n    if(mode->bitdepth == 8)\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = in[i * 3 + 0];\n        buffer[1] = in[i * 3 + 1];\n        buffer[2] = in[i * 3 + 2];\n        if(has_alpha) buffer[3] = mode->key_defined && buffer[0] == mode->key_r\n           && buffer[1]== mode->key_g && buffer[2] == mode->key_b ? 0 : 255;\n      }\n    }\n    else\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = in[i * 6 + 0];\n        buffer[1] = in[i * 6 + 2];\n        buffer[2] = in[i * 6 + 4];\n        if(has_alpha) buffer[3] = mode->key_defined\n           && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r\n           && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g\n           && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b ? 0 : 255;\n      }\n    }\n  }\n  else if(mode->colortype == LCT_PALETTE)\n  {\n    unsigned index;\n    size_t j = 0;\n    for(i = 0; i < numpixels; i++, buffer += num_channels)\n    {\n      if(mode->bitdepth == 8) index = in[i];\n      else index = readBitsFromReversedStream(&j, in, mode->bitdepth);\n\n      if(index >= mode->palettesize)\n      {\n        /*This is an error according to the PNG spec, but fix_png can ignore it*/\n        if(!fix_png) return (mode->bitdepth == 8 ? 46 : 47); /*index out of palette*/\n        buffer[0] = buffer[1] = buffer[2] = 0;\n        if(has_alpha) buffer[3] = 255;\n      }\n      else\n      {\n        buffer[0] = mode->palette[index * 4 + 0];\n        buffer[1] = mode->palette[index * 4 + 1];\n        buffer[2] = mode->palette[index * 4 + 2];\n        if(has_alpha) buffer[3] = mode->palette[index * 4 + 3];\n      }\n    }\n  }\n  else if(mode->colortype == LCT_GREY_ALPHA)\n  {\n    if(mode->bitdepth == 8)\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = buffer[1] = buffer[2] = in[i * 2 + 0];\n        if(has_alpha) buffer[3] = in[i * 2 + 1];\n      }\n    }\n    else\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = buffer[1] = buffer[2] = in[i * 4 + 0];\n        if(has_alpha) buffer[3] = in[i * 4 + 2];\n      }\n    }\n  }\n  else if(mode->colortype == LCT_RGBA)\n  {\n    if(mode->bitdepth == 8)\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = in[i * 4 + 0];\n        buffer[1] = in[i * 4 + 1];\n        buffer[2] = in[i * 4 + 2];\n        if(has_alpha) buffer[3] = in[i * 4 + 3];\n      }\n    }\n    else\n    {\n      for(i = 0; i < numpixels; i++, buffer += num_channels)\n      {\n        buffer[0] = in[i * 8 + 0];\n        buffer[1] = in[i * 8 + 2];\n        buffer[2] = in[i * 8 + 4];\n        if(has_alpha) buffer[3] = in[i * 8 + 6];\n      }\n    }\n  }\n\n  return 0; /*no error*/\n}\n\n/*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with\ngiven color type, but the given color type must be 16-bit itself.*/\nstatic unsigned getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,\n                                    const unsigned char* in, size_t i, const LodePNGColorMode* mode)\n{\n  if(mode->bitdepth != 16) return 85; /*error: this function only supports 16-bit input*/\n\n  if(mode->colortype == LCT_GREY)\n  {\n    *r = *g = *b = 256 * in[i * 2 + 0] + in[i * 2 + 1];\n    if(mode->key_defined && 256U * in[i * 2 + 0] + in[i * 2 + 1] == mode->key_r) *a = 0;\n    else *a = 65535;\n  }\n  else if(mode->colortype == LCT_RGB)\n  {\n    *r = 256 * in[i * 6 + 0] + in[i * 6 + 1];\n    *g = 256 * in[i * 6 + 2] + in[i * 6 + 3];\n    *b = 256 * in[i * 6 + 4] + in[i * 6 + 5];\n    if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r\n       && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g\n       && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;\n    else *a = 65535;\n  }\n  else if(mode->colortype == LCT_GREY_ALPHA)\n  {\n    *r = *g = *b = 256 * in[i * 4 + 0] + in[i * 4 + 1];\n    *a = 256 * in[i * 4 + 2] + in[i * 4 + 3];\n  }\n  else if(mode->colortype == LCT_RGBA)\n  {\n    *r = 256 * in[i * 8 + 0] + in[i * 8 + 1];\n    *g = 256 * in[i * 8 + 2] + in[i * 8 + 3];\n    *b = 256 * in[i * 8 + 4] + in[i * 8 + 5];\n    *a = 256 * in[i * 8 + 6] + in[i * 8 + 7];\n  }\n  else return 85; /*error: this function only supports 16-bit input, not palettes*/\n\n  return 0; /*no error*/\n}\n\n/*\nconverts from any color type to 24-bit or 32-bit (later maybe more supported). return value = LodePNG error code\nthe out buffer must have (w * h * bpp + 7) / 8 bytes, where bpp is the bits per pixel of the output color type\n(lodepng_get_bpp) for < 8 bpp images, there may _not_ be padding bits at the end of scanlines.\n*/\nunsigned lodepng_convert(unsigned char* out, const unsigned char* in,\n                         LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,\n                         unsigned w, unsigned h, unsigned fix_png)\n{\n  unsigned error = 0;\n  size_t i;\n  ColorTree tree;\n  size_t numpixels = w * h;\n\n  if(lodepng_color_mode_equal(mode_out, mode_in))\n  {\n    size_t numbytes = lodepng_get_raw_size(w, h, mode_in);\n    for(i = 0; i < numbytes; i++) out[i] = in[i];\n    return error;\n  }\n\n  if(mode_out->colortype == LCT_PALETTE)\n  {\n    size_t palsize = 1 << mode_out->bitdepth;\n    if(mode_out->palettesize < palsize) palsize = mode_out->palettesize;\n    color_tree_init(&tree);\n    for(i = 0; i < palsize; i++)\n    {\n      unsigned char* p = &mode_out->palette[i * 4];\n      color_tree_add(&tree, p[0], p[1], p[2], p[3], i);\n    }\n  }\n\n  if(mode_in->bitdepth == 16 && mode_out->bitdepth == 16)\n  {\n    for(i = 0; i < numpixels; i++)\n    {\n      unsigned short r = 0, g = 0, b = 0, a = 0;\n      error = getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);\n      if(error) break;\n      error = rgba16ToPixel(out, i, mode_out, r, g, b, a);\n      if(error) break;\n    }\n  }\n  else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGBA)\n  {\n    error = getPixelColorsRGBA8(out, numpixels, 1, in, mode_in, fix_png);\n  }\n  else if(mode_out->bitdepth == 8 && mode_out->colortype == LCT_RGB)\n  {\n    error = getPixelColorsRGBA8(out, numpixels, 0, in, mode_in, fix_png);\n  }\n  else\n  {\n    unsigned char r = 0, g = 0, b = 0, a = 0;\n    for(i = 0; i < numpixels; i++)\n    {\n      error = getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in, fix_png);\n      if(error) break;\n      error = rgba8ToPixel(out, i, mode_out, &tree, r, g, b, a);\n      if(error) break;\n    }\n  }\n\n  if(mode_out->colortype == LCT_PALETTE)\n  {\n    color_tree_cleanup(&tree);\n  }\n\n  return error;\n}\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\ntypedef struct ColorProfile\n{\n  unsigned char sixteenbit; /*needs more than 8 bits per channel*/\n  unsigned char sixteenbit_done;\n\n\n  unsigned char colored; /*not greyscale*/\n  unsigned char colored_done;\n\n  unsigned char key; /*a color key is required, or more*/\n  unsigned short key_r; /*these values are always in 16-bit bitdepth in the profile*/\n  unsigned short key_g;\n  unsigned short key_b;\n  unsigned char alpha; /*alpha channel, or alpha palette, required*/\n  unsigned char alpha_done;\n\n  unsigned numcolors;\n  ColorTree tree; /*for listing the counted colors, up to 256*/\n  unsigned char* palette; /*size 1024. Remember up to the first 256 RGBA colors*/\n  unsigned maxnumcolors; /*if more than that amount counted*/\n  unsigned char numcolors_done;\n\n  unsigned greybits; /*amount of bits required for greyscale (1, 2, 4, 8). Does not take 16 bit into account.*/\n  unsigned char greybits_done;\n\n} ColorProfile;\n\nstatic void color_profile_init(ColorProfile* profile, const LodePNGColorMode* mode)\n{\n  profile->sixteenbit = 0;\n  profile->sixteenbit_done = mode->bitdepth == 16 ? 0 : 1;\n\n  profile->colored = 0;\n  profile->colored_done = lodepng_is_greyscale_type(mode) ? 1 : 0;\n\n  profile->key = 0;\n  profile->alpha = 0;\n  profile->alpha_done = lodepng_can_have_alpha(mode) ? 0 : 1;\n\n  profile->numcolors = 0;\n  color_tree_init(&profile->tree);\n  profile->palette = (unsigned char*)lodepng_malloc(1024);\n  profile->maxnumcolors = 257;\n  if(lodepng_get_bpp(mode) <= 8)\n  {\n    int bpp = lodepng_get_bpp(mode);\n    profile->maxnumcolors = bpp == 1 ? 2 : (bpp == 2 ? 4 : (bpp == 4 ? 16 : 256));\n  }\n  profile->numcolors_done = 0;\n\n  profile->greybits = 1;\n  profile->greybits_done = lodepng_get_bpp(mode) == 1 ? 1 : 0;\n}\n\nstatic void color_profile_cleanup(ColorProfile* profile)\n{\n  color_tree_cleanup(&profile->tree);\n  lodepng_free(profile->palette);\n}\n\n/*function used for debug purposes with C++*/\n/*void printColorProfile(ColorProfile* p)\n{\n  std::cout << \"sixteenbit: \" << (int)p->sixteenbit << std::endl;\n  std::cout << \"sixteenbit_done: \" << (int)p->sixteenbit_done << std::endl;\n  std::cout << \"colored: \" << (int)p->colored << std::endl;\n  std::cout << \"colored_done: \" << (int)p->colored_done << std::endl;\n  std::cout << \"key: \" << (int)p->key << std::endl;\n  std::cout << \"key_r: \" << (int)p->key_r << std::endl;\n  std::cout << \"key_g: \" << (int)p->key_g << std::endl;\n  std::cout << \"key_b: \" << (int)p->key_b << std::endl;\n  std::cout << \"alpha: \" << (int)p->alpha << std::endl;\n  std::cout << \"alpha_done: \" << (int)p->alpha_done << std::endl;\n  std::cout << \"numcolors: \" << (int)p->numcolors << std::endl;\n  std::cout << \"maxnumcolors: \" << (int)p->maxnumcolors << std::endl;\n  std::cout << \"numcolors_done: \" << (int)p->numcolors_done << std::endl;\n  std::cout << \"greybits: \" << (int)p->greybits << std::endl;\n  std::cout << \"greybits_done: \" << (int)p->greybits_done << std::endl;\n}*/\n\n/*Returns how many bits needed to represent given value (max 8 bit)*/\nunsigned getValueRequiredBits(unsigned short value)\n{\n  if(value == 0 || value == 255) return 1;\n  /*The scaling of 2-bit and 4-bit values uses multiples of 85 and 17*/\n  if(value % 17 == 0) return value % 85 == 0 ? 2 : 4;\n  return 8;\n}\n\n/*profile must already have been inited with mode.\nIt's ok to set some parameters of profile to done already.*/\nstatic unsigned get_color_profile(ColorProfile* profile,\n                                  const unsigned char* in,\n                                  size_t numpixels /*must be full image size, for certain filesize based choices*/,\n                                  const LodePNGColorMode* mode,\n                                  unsigned fix_png)\n{\n  unsigned error = 0;\n  size_t i;\n\n  if(mode->bitdepth == 16)\n  {\n    for(i = 0; i < numpixels; i++)\n    {\n      unsigned short r, g, b, a;\n      error = getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);\n      if(error) break;\n\n      /*a color is considered good for 8-bit if the first byte and the second byte are equal,\n        (so if it's divisible through 257), NOT necessarily if the second byte is 0*/\n      if(!profile->sixteenbit_done\n          && (((r & 255) != ((r >> 8) & 255))\n           || ((g & 255) != ((g >> 8) & 255))\n           || ((b & 255) != ((b >> 8) & 255))))\n      {\n        profile->sixteenbit = 1;\n        profile->sixteenbit_done = 1;\n        profile->greybits_done = 1; /*greybits is not applicable anymore at 16-bit*/\n        profile->numcolors_done = 1; /*counting colors no longer useful, palette doesn't support 16-bit*/\n      }\n\n      if(!profile->colored_done && (r != g || r != b))\n      {\n        profile->colored = 1;\n        profile->colored_done = 1;\n        profile->greybits_done = 1; /*greybits is not applicable anymore*/\n      }\n\n      if(!profile->alpha_done && a != 65535)\n      {\n        /*only use color key if numpixels large enough to justify tRNS chunk size*/\n        if(a == 0 && numpixels > 16 && !(profile->key && (r != profile->key_r || g != profile->key_g || b != profile->key_b)))\n        {\n          if(!profile->alpha && !profile->key)\n          {\n            profile->key = 1;\n            profile->key_r = r;\n            profile->key_g = g;\n            profile->key_b = b;\n          }\n        }\n        else\n        {\n          profile->alpha = 1;\n          profile->alpha_done = 1;\n          profile->greybits_done = 1; /*greybits is not applicable anymore*/\n        }\n      }\n\n      /* Color key cannot be used if an opaque pixel also has that RGB color. */\n      if(!profile->alpha_done && a == 65535 && profile->key\n          && r == profile->key_r && g == profile->key_g && b == profile->key_b)\n      {\n          profile->alpha = 1;\n          profile->alpha_done = 1;\n          profile->greybits_done = 1; /*greybits is not applicable anymore*/\n      }\n\n      if(!profile->greybits_done)\n      {\n        /*assuming 8-bit r, this test does not care about 16-bit*/\n        unsigned bits = getValueRequiredBits(r);\n        if(bits > profile->greybits) profile->greybits = bits;\n        if(profile->greybits >= 8) profile->greybits_done = 1;\n      }\n\n      if(!profile->numcolors_done)\n      {\n        /*assuming 8-bit rgba, this test does not care about 16-bit*/\n        if(!color_tree_has(&profile->tree, (unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a))\n        {\n          color_tree_add(&profile->tree, (unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a,\n            profile->numcolors);\n          if(profile->numcolors < 256)\n          {\n            unsigned char* p = profile->palette;\n            unsigned i = profile->numcolors;\n            p[i * 4 + 0] = (unsigned char)r;\n            p[i * 4 + 1] = (unsigned char)g;\n            p[i * 4 + 2] = (unsigned char)b;\n            p[i * 4 + 3] = (unsigned char)a;\n          }\n          profile->numcolors++;\n          if(profile->numcolors >= profile->maxnumcolors) profile->numcolors_done = 1;\n        }\n      }\n\n      if(profile->alpha_done && profile->numcolors_done\n      && profile->colored_done && profile->sixteenbit_done && profile->greybits_done)\n      {\n        break;\n      }\n    };\n  }\n  else /* < 16-bit */\n  {\n    for(i = 0; i < numpixels; i++)\n    {\n      unsigned char r = 0, g = 0, b = 0, a = 0;\n      error = getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode, fix_png);\n      if(error) break;\n\n      if(!profile->colored_done && (r != g || r != b))\n      {\n        profile->colored = 1;\n        profile->colored_done = 1;\n        profile->greybits_done = 1; /*greybits is not applicable anymore*/\n      }\n\n      if(!profile->alpha_done && a != 255)\n      {\n        if(a == 0 && !(profile->key && (r != profile->key_r || g != profile->key_g || b != profile->key_b)))\n        {\n          if(!profile->key)\n          {\n            profile->key = 1;\n            profile->key_r = r;\n            profile->key_g = g;\n            profile->key_b = b;\n          }\n        }\n        else\n        {\n          profile->alpha = 1;\n          profile->alpha_done = 1;\n          profile->greybits_done = 1; /*greybits is not applicable anymore*/\n        }\n      }\n\n      /* Color key cannot be used if an opaque pixel also has that RGB color. */\n      if(!profile->alpha_done && a == 255 && profile->key\n          && r == profile->key_r && g == profile->key_g && b == profile->key_b)\n      {\n          profile->alpha = 1;\n          profile->alpha_done = 1;\n          profile->greybits_done = 1; /*greybits is not applicable anymore*/\n      }\n\n      if(!profile->greybits_done)\n      {\n        unsigned bits = getValueRequiredBits(r);\n        if(bits > profile->greybits) profile->greybits = bits;\n        if(profile->greybits >= 8) profile->greybits_done = 1;\n      }\n\n      if(!profile->numcolors_done)\n      {\n        if(!color_tree_has(&profile->tree, r, g, b, a))\n        {\n\n          color_tree_add(&profile->tree, r, g, b, a, profile->numcolors);\n          if(profile->numcolors < 256)\n          {\n            unsigned char* p = profile->palette;\n            unsigned i = profile->numcolors;\n            p[i * 4 + 0] = r;\n            p[i * 4 + 1] = g;\n            p[i * 4 + 2] = b;\n            p[i * 4 + 3] = a;\n          }\n          profile->numcolors++;\n          if(profile->numcolors >= profile->maxnumcolors) profile->numcolors_done = 1;\n        }\n      }\n\n      if(profile->alpha_done && profile->numcolors_done && profile->colored_done && profile->greybits_done)\n      {\n        break;\n      }\n    };\n  }\n\n  /*make the profile's key always 16-bit for consistency*/\n  if(mode->bitdepth < 16)\n  {\n    /*repeat each byte twice*/\n    profile->key_r *= 257;\n    profile->key_g *= 257;\n    profile->key_b *= 257;\n  }\n\n  return error;\n}\n\nstatic void setColorKeyFrom16bit(LodePNGColorMode* mode_out, unsigned r, unsigned g, unsigned b, unsigned bitdepth)\n{\n  unsigned mask = (1 << bitdepth) - 1;\n  mode_out->key_defined = 1;\n  mode_out->key_r = r & mask;\n  mode_out->key_g = g & mask;\n  mode_out->key_b = b & mask;\n}\n\n/*updates values of mode with a potentially smaller color model. mode_out should\ncontain the user chosen color model, but will be overwritten with the new chosen one.*/\nunsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,\n                                   const unsigned char* image, unsigned w, unsigned h,\n                                   const LodePNGColorMode* mode_in,\n                                   LodePNGAutoConvert auto_convert)\n{\n  ColorProfile profile;\n  unsigned error = 0;\n  int no_nibbles = auto_convert == LAC_AUTO_NO_NIBBLES || auto_convert == LAC_AUTO_NO_NIBBLES_NO_PALETTE;\n  int no_palette = auto_convert == LAC_AUTO_NO_PALETTE || auto_convert == LAC_AUTO_NO_NIBBLES_NO_PALETTE;\n\n  if(auto_convert == LAC_ALPHA)\n  {\n    if(mode_out->colortype != LCT_RGBA && mode_out->colortype != LCT_GREY_ALPHA) return 0;\n  }\n\n  color_profile_init(&profile, mode_in);\n  if(auto_convert == LAC_ALPHA)\n  {\n    profile.colored_done = 1;\n    profile.greybits_done = 1;\n    profile.numcolors_done = 1;\n    profile.sixteenbit_done = 1;\n  }\n  error = get_color_profile(&profile, image, w * h, mode_in, 0 /*fix_png*/);\n  if(!error && auto_convert == LAC_ALPHA)\n  {\n    if(!profile.alpha)\n    {\n      mode_out->colortype = (mode_out->colortype == LCT_RGBA ? LCT_RGB : LCT_GREY);\n      if(profile.key) setColorKeyFrom16bit(mode_out, profile.key_r, profile.key_g, profile.key_b, mode_out->bitdepth);\n    }\n  }\n  else if(!error && auto_convert != LAC_ALPHA)\n  {\n    mode_out->key_defined = 0;\n\n    if(profile.sixteenbit)\n    {\n      mode_out->bitdepth = 16;\n      if(profile.alpha)\n      {\n        mode_out->colortype = profile.colored ? LCT_RGBA : LCT_GREY_ALPHA;\n      }\n      else\n      {\n        mode_out->colortype = profile.colored ? LCT_RGB : LCT_GREY;\n        if(profile.key) setColorKeyFrom16bit(mode_out, profile.key_r, profile.key_g, profile.key_b, mode_out->bitdepth);\n      }\n    }\n    else /*less than 16 bits per channel*/\n    {\n      /*don't add palette overhead if image hasn't got a lot of pixels*/\n      unsigned n = profile.numcolors;\n      int palette_ok = !no_palette && n <= 256 && (n * 2 < w * h);\n      unsigned palettebits = n <= 2 ? 1 : (n <= 4 ? 2 : (n <= 16 ? 4 : 8));\n      int grey_ok = !profile.colored && !profile.alpha; /*grey without alpha, with potentially low bits*/\n      if(palette_ok || grey_ok)\n      {\n        if(!palette_ok || (grey_ok && profile.greybits <= palettebits))\n        {\n          unsigned grey = profile.key_r;\n          mode_out->colortype = LCT_GREY;\n          mode_out->bitdepth = profile.greybits;\n          if(profile.key) setColorKeyFrom16bit(mode_out, grey, grey, grey, mode_out->bitdepth);\n        }\n        else\n        {\n          /*fill in the palette*/\n          unsigned i;\n          unsigned char* p = profile.palette;\n          /*remove potential earlier palette*/\n          lodepng_palette_clear(mode_out);\n          for(i = 0; i < profile.numcolors; i++)\n          {\n            error = lodepng_palette_add(mode_out, p[i * 4 + 0], p[i * 4 + 1], p[i * 4 + 2], p[i * 4 + 3]);\n            if(error) break;\n          }\n\n          mode_out->colortype = LCT_PALETTE;\n          mode_out->bitdepth = palettebits;\n        }\n      }\n      else /*8-bit per channel*/\n      {\n        mode_out->bitdepth = 8;\n        if(profile.alpha)\n        {\n          mode_out->colortype = profile.colored ? LCT_RGBA : LCT_GREY_ALPHA;\n        }\n        else\n        {\n          mode_out->colortype = profile.colored ? LCT_RGB : LCT_GREY /*LCT_GREY normally won't occur, already done earlier*/;\n          if(profile.key) setColorKeyFrom16bit(mode_out, profile.key_r, profile.key_g, profile.key_b, mode_out->bitdepth);\n        }\n      }\n    }\n  }\n\n  color_profile_cleanup(&profile);\n\n  if(mode_out->colortype == LCT_PALETTE && mode_in->palettesize == mode_out->palettesize)\n  {\n    /*In this case keep the palette order of the input, so that the user can choose an optimal one*/\n    size_t i;\n    for(i = 0; i < mode_in->palettesize * 4; i++)\n    {\n      mode_out->palette[i] = mode_in->palette[i];\n    }\n  }\n\n  if(no_nibbles && mode_out->bitdepth < 8)\n  {\n    /*palette can keep its small amount of colors, as long as no indices use it*/\n    mode_out->bitdepth = 8;\n  }\n\n  return error;\n}\n\n#endif /* #ifdef LODEPNG_COMPILE_ENCODER */\n\n/*\nPaeth predicter, used by PNG filter type 4\nThe parameters are of type short, but should come from unsigned chars, the shorts\nare only needed to make the paeth calculation correct.\n*/\nstatic unsigned char paethPredictor(short a, short b, short c)\n{\n  short pa = abs(b - c);\n  short pb = abs(a - c);\n  short pc = abs(a + b - c - c);\n\n  if(pc < pa && pc < pb) return (unsigned char)c;\n  else if(pb < pa) return (unsigned char)b;\n  else return (unsigned char)a;\n}\n\n/*shared values used by multiple Adam7 related functions*/\n\nstatic const unsigned ADAM7_IX[7] = { 0, 4, 0, 2, 0, 1, 0 }; /*x start values*/\nstatic const unsigned ADAM7_IY[7] = { 0, 0, 4, 0, 2, 0, 1 }; /*y start values*/\nstatic const unsigned ADAM7_DX[7] = { 8, 8, 4, 4, 2, 2, 1 }; /*x delta values*/\nstatic const unsigned ADAM7_DY[7] = { 8, 8, 8, 4, 4, 2, 2 }; /*y delta values*/\n\n/*\nOutputs various dimensions and positions in the image related to the Adam7 reduced images.\npassw: output containing the width of the 7 passes\npassh: output containing the height of the 7 passes\nfilter_passstart: output containing the index of the start and end of each\n reduced image with filter bytes\npadded_passstart output containing the index of the start and end of each\n reduced image when without filter bytes but with padded scanlines\npassstart: output containing the index of the start and end of each reduced\n image without padding between scanlines, but still padding between the images\nw, h: width and height of non-interlaced image\nbpp: bits per pixel\n\"padded\" is only relevant if bpp is less than 8 and a scanline or image does not\n end at a full byte\n*/\nstatic void Adam7_getpassvalues(unsigned passw[7], unsigned passh[7], size_t filter_passstart[8],\n                                size_t padded_passstart[8], size_t passstart[8], unsigned w, unsigned h, unsigned bpp)\n{\n  /*the passstart values have 8 values: the 8th one indicates the byte after the end of the 7th (= last) pass*/\n  unsigned i;\n\n  /*calculate width and height in pixels of each pass*/\n  for(i = 0; i < 7; i++)\n  {\n    passw[i] = (w + ADAM7_DX[i] - ADAM7_IX[i] - 1) / ADAM7_DX[i];\n    passh[i] = (h + ADAM7_DY[i] - ADAM7_IY[i] - 1) / ADAM7_DY[i];\n    if(passw[i] == 0) passh[i] = 0;\n    if(passh[i] == 0) passw[i] = 0;\n  }\n\n  filter_passstart[0] = padded_passstart[0] = passstart[0] = 0;\n  for(i = 0; i < 7; i++)\n  {\n    /*if passw[i] is 0, it's 0 bytes, not 1 (no filtertype-byte)*/\n    filter_passstart[i + 1] = filter_passstart[i]\n                            + ((passw[i] && passh[i]) ? passh[i] * (1 + (passw[i] * bpp + 7) / 8) : 0);\n    /*bits padded if needed to fill full byte at end of each scanline*/\n    padded_passstart[i + 1] = padded_passstart[i] + passh[i] * ((passw[i] * bpp + 7) / 8);\n    /*only padded at end of reduced image*/\n    passstart[i + 1] = passstart[i] + (passh[i] * passw[i] * bpp + 7) / 8;\n  }\n}\n\n#ifdef LODEPNG_COMPILE_DECODER\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / PNG Decoder                                                            / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*read the information from the header and store it in the LodePNGInfo. return value is error*/\nunsigned lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state,\n                         const unsigned char* in, size_t insize)\n{\n  LodePNGInfo* info = &state->info_png;\n  if(insize == 0 || in == 0)\n  {\n    CERROR_RETURN_ERROR(state->error, 48); /*error: the given data is empty*/\n  }\n  if(insize < 29)\n  {\n    CERROR_RETURN_ERROR(state->error, 27); /*error: the data length is smaller than the length of a PNG header*/\n  }\n\n  /*when decoding a new PNG image, make sure all parameters created after previous decoding are reset*/\n  lodepng_info_cleanup(info);\n  lodepng_info_init(info);\n\n  if(in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71\n     || in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10)\n  {\n    CERROR_RETURN_ERROR(state->error, 28); /*error: the first 8 bytes are not the correct PNG signature*/\n  }\n  if(in[12] != 'I' || in[13] != 'H' || in[14] != 'D' || in[15] != 'R')\n  {\n    CERROR_RETURN_ERROR(state->error, 29); /*error: it doesn't start with a IHDR chunk!*/\n  }\n\n  /*read the values given in the header*/\n  *w = lodepng_read32bitInt(&in[16]);\n  *h = lodepng_read32bitInt(&in[20]);\n  info->color.bitdepth = in[24];\n  info->color.colortype = (LodePNGColorType)in[25];\n  info->compression_method = in[26];\n  info->filter_method = in[27];\n  info->interlace_method = in[28];\n\n  if(!state->decoder.ignore_crc)\n  {\n    unsigned CRC = lodepng_read32bitInt(&in[29]);\n    unsigned checksum = lodepng_crc32(&in[12], 17);\n    if(CRC != checksum)\n    {\n      CERROR_RETURN_ERROR(state->error, 57); /*invalid CRC*/\n    }\n  }\n\n  /*error: only compression method 0 is allowed in the specification*/\n  if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32);\n  /*error: only filter method 0 is allowed in the specification*/\n  if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33);\n  /*error: only interlace methods 0 and 1 exist in the specification*/\n  if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34);\n\n  state->error = checkColorValidity(info->color.colortype, info->color.bitdepth);\n  return state->error;\n}\n\nstatic unsigned unfilterScanline(unsigned char* recon, const unsigned char* scanline, const unsigned char* precon,\n                                 size_t bytewidth, unsigned char filterType, size_t length)\n{\n  /*\n  For PNG filter method 0\n  unfilter a PNG image scanline by scanline. when the pixels are smaller than 1 byte,\n  the filter works byte per byte (bytewidth = 1)\n  precon is the previous unfiltered scanline, recon the result, scanline the current one\n  the incoming scanlines do NOT include the filtertype byte, that one is given in the parameter filterType instead\n  recon and scanline MAY be the same memory address! precon must be disjoint.\n  */\n\n  size_t i;\n  switch(filterType)\n  {\n    case 0:\n      for(i = 0; i < length; i++) recon[i] = scanline[i];\n      break;\n    case 1:\n      for(i = 0; i < bytewidth; i++) recon[i] = scanline[i];\n      for(i = bytewidth; i < length; i++) recon[i] = scanline[i] + recon[i - bytewidth];\n      break;\n    case 2:\n      if(precon)\n      {\n        for(i = 0; i < length; i++) recon[i] = scanline[i] + precon[i];\n      }\n      else\n      {\n        for(i = 0; i < length; i++) recon[i] = scanline[i];\n      }\n      break;\n    case 3:\n      if(precon)\n      {\n        for(i = 0; i < bytewidth; i++) recon[i] = scanline[i] + precon[i] / 2;\n        for(i = bytewidth; i < length; i++) recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) / 2);\n      }\n      else\n      {\n        for(i = 0; i < bytewidth; i++) recon[i] = scanline[i];\n        for(i = bytewidth; i < length; i++) recon[i] = scanline[i] + recon[i - bytewidth] / 2;\n      }\n      break;\n    case 4:\n      if(precon)\n      {\n        for(i = 0; i < bytewidth; i++)\n        {\n          recon[i] = (scanline[i] + precon[i]); /*paethPredictor(0, precon[i], 0) is always precon[i]*/\n        }\n        for(i = bytewidth; i < length; i++)\n        {\n          recon[i] = (scanline[i] + paethPredictor(recon[i - bytewidth], precon[i], precon[i - bytewidth]));\n        }\n      }\n      else\n      {\n        for(i = 0; i < bytewidth; i++)\n        {\n          recon[i] = scanline[i];\n        }\n        for(i = bytewidth; i < length; i++)\n        {\n          /*paethPredictor(recon[i - bytewidth], 0, 0) is always recon[i - bytewidth]*/\n          recon[i] = (scanline[i] + recon[i - bytewidth]);\n        }\n      }\n      break;\n    default: return 36; /*error: unexisting filter type given*/\n  }\n  return 0;\n}\n\nstatic unsigned unfilter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)\n{\n  /*\n  For PNG filter method 0\n  this function unfilters a single image (e.g. without interlacing this is called once, with Adam7 seven times)\n  out must have enough bytes allocated already, in must have the scanlines + 1 filtertype byte per scanline\n  w and h are image dimensions or dimensions of reduced image, bpp is bits per pixel\n  in and out are allowed to be the same memory address (but aren't the same size since in has the extra filter bytes)\n  */\n\n  unsigned y;\n  unsigned char* prevline = 0;\n\n  /*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/\n  size_t bytewidth = (bpp + 7) / 8;\n  size_t linebytes = (w * bpp + 7) / 8;\n\n  for(y = 0; y < h; y++)\n  {\n    size_t outindex = linebytes * y;\n    size_t inindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/\n    unsigned char filterType = in[inindex];\n\n    CERROR_TRY_RETURN(unfilterScanline(&out[outindex], &in[inindex + 1], prevline, bytewidth, filterType, linebytes));\n\n    prevline = &out[outindex];\n  }\n\n  return 0;\n}\n\n/*\nin: Adam7 interlaced image, with no padding bits between scanlines, but between\n reduced images so that each reduced image starts at a byte.\nout: the same pixels, but re-ordered so that they're now a non-interlaced image with size w*h\nbpp: bits per pixel\nout has the following size in bits: w * h * bpp.\nin is possibly bigger due to padding bits between reduced images.\nout must be big enough AND must be 0 everywhere if bpp < 8 in the current implementation\n(because that's likely a little bit faster)\nNOTE: comments about padding bits are only relevant if bpp < 8\n*/\nstatic void Adam7_deinterlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)\n{\n  unsigned passw[7], passh[7];\n  size_t filter_passstart[8], padded_passstart[8], passstart[8];\n  unsigned i;\n\n  Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);\n\n  if(bpp >= 8)\n  {\n    for(i = 0; i < 7; i++)\n    {\n      unsigned x, y, b;\n      size_t bytewidth = bpp / 8;\n      for(y = 0; y < passh[i]; y++)\n      for(x = 0; x < passw[i]; x++)\n      {\n        size_t pixelinstart = passstart[i] + (y * passw[i] + x) * bytewidth;\n        size_t pixeloutstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w + ADAM7_IX[i] + x * ADAM7_DX[i]) * bytewidth;\n        for(b = 0; b < bytewidth; b++)\n        {\n          out[pixeloutstart + b] = in[pixelinstart + b];\n        }\n      }\n    }\n  }\n  else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/\n  {\n    for(i = 0; i < 7; i++)\n    {\n      unsigned x, y, b;\n      unsigned ilinebits = bpp * passw[i];\n      unsigned olinebits = bpp * w;\n      size_t obp, ibp; /*bit pointers (for out and in buffer)*/\n      for(y = 0; y < passh[i]; y++)\n      for(x = 0; x < passw[i]; x++)\n      {\n        ibp = (8 * passstart[i]) + (y * ilinebits + x * bpp);\n        obp = (ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp;\n        for(b = 0; b < bpp; b++)\n        {\n          unsigned char bit = readBitFromReversedStream(&ibp, in);\n          /*note that this function assumes the out buffer is completely 0, use setBitOfReversedStream otherwise*/\n          setBitOfReversedStream0(&obp, out, bit);\n        }\n      }\n    }\n  }\n}\n\nstatic void removePaddingBits(unsigned char* out, const unsigned char* in,\n                              size_t olinebits, size_t ilinebits, unsigned h)\n{\n  /*\n  After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need\n  to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers\n  for the Adam7 code, the color convert code and the output to the user.\n  in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must\n  have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits\n  also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7\n  only useful if (ilinebits - olinebits) is a value in the range 1..7\n  */\n  unsigned y;\n  size_t diff = ilinebits - olinebits;\n  size_t ibp = 0, obp = 0; /*input and output bit pointers*/\n  for(y = 0; y < h; y++)\n  {\n    size_t x;\n    for(x = 0; x < olinebits; x++)\n    {\n      unsigned char bit = readBitFromReversedStream(&ibp, in);\n      setBitOfReversedStream(&obp, out, bit);\n    }\n    ibp += diff;\n  }\n}\n\n/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from\nthe IDAT chunks (with filter index bytes and possible padding bits)\nreturn value is error*/\nstatic unsigned postProcessScanlines(unsigned char* out, unsigned char* in,\n                                     unsigned w, unsigned h, const LodePNGInfo* info_png)\n{\n  /*\n  This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.\n  Steps:\n  *) if no Adam7: 1) unfilter 2) remove padding bits (= posible extra bits per scanline if bpp < 8)\n  *) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) Adam7_deinterlace\n  NOTE: the in buffer will be overwritten with intermediate data!\n  */\n  unsigned bpp = lodepng_get_bpp(&info_png->color);\n  if(bpp == 0) return 31; /*error: invalid colortype*/\n\n  if(info_png->interlace_method == 0)\n  {\n    if(bpp < 8 && w * bpp != ((w * bpp + 7) / 8) * 8)\n    {\n      CERROR_TRY_RETURN(unfilter(in, in, w, h, bpp));\n      removePaddingBits(out, in, w * bpp, ((w * bpp + 7) / 8) * 8, h);\n    }\n    /*we can immediatly filter into the out buffer, no other steps needed*/\n    else CERROR_TRY_RETURN(unfilter(out, in, w, h, bpp));\n  }\n  else /*interlace_method is 1 (Adam7)*/\n  {\n    unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];\n    unsigned i;\n\n    Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);\n\n    for(i = 0; i < 7; i++)\n    {\n      CERROR_TRY_RETURN(unfilter(&in[padded_passstart[i]], &in[filter_passstart[i]], passw[i], passh[i], bpp));\n      /*TODO: possible efficiency improvement: if in this reduced image the bits fit nicely in 1 scanline,\n      move bytes instead of bits or move not at all*/\n      if(bpp < 8)\n      {\n        /*remove padding bits in scanlines; after this there still may be padding\n        bits between the different reduced images: each reduced image still starts nicely at a byte*/\n        removePaddingBits(&in[passstart[i]], &in[padded_passstart[i]], passw[i] * bpp,\n                          ((passw[i] * bpp + 7) / 8) * 8, passh[i]);\n      }\n    }\n\n    Adam7_deinterlace(out, in, w, h, bpp);\n  }\n\n  return 0;\n}\n\nstatic unsigned readChunk_PLTE(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)\n{\n  unsigned pos = 0, i;\n  if(color->palette) lodepng_free(color->palette);\n  color->palettesize = chunkLength / 3;\n  color->palette = (unsigned char*)lodepng_malloc(4 * color->palettesize);\n  if(!color->palette && color->palettesize)\n  {\n    color->palettesize = 0;\n    return 83; /*alloc fail*/\n  }\n  if(color->palettesize > 256) return 38; /*error: palette too big*/\n\n  for(i = 0; i < color->palettesize; i++)\n  {\n    color->palette[4 * i + 0] = data[pos++]; /*R*/\n    color->palette[4 * i + 1] = data[pos++]; /*G*/\n    color->palette[4 * i + 2] = data[pos++]; /*B*/\n    color->palette[4 * i + 3] = 255; /*alpha*/\n  }\n\n  return 0; /* OK */\n}\n\nstatic unsigned readChunk_tRNS(LodePNGColorMode* color, const unsigned char* data, size_t chunkLength)\n{\n  unsigned i;\n  if(color->colortype == LCT_PALETTE)\n  {\n    /*error: more alpha values given than there are palette entries*/\n    if(chunkLength > color->palettesize) return 38;\n\n    for(i = 0; i < chunkLength; i++) color->palette[4 * i + 3] = data[i];\n  }\n  else if(color->colortype == LCT_GREY)\n  {\n    /*error: this chunk must be 2 bytes for greyscale image*/\n    if(chunkLength != 2) return 30;\n\n    color->key_defined = 1;\n    color->key_r = color->key_g = color->key_b = 256 * data[0] + data[1];\n  }\n  else if(color->colortype == LCT_RGB)\n  {\n    /*error: this chunk must be 6 bytes for RGB image*/\n    if(chunkLength != 6) return 41;\n\n    color->key_defined = 1;\n    color->key_r = 256 * data[0] + data[1];\n    color->key_g = 256 * data[2] + data[3];\n    color->key_b = 256 * data[4] + data[5];\n  }\n  else return 42; /*error: tRNS chunk not allowed for other color models*/\n\n  return 0; /* OK */\n}\n\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n/*background color chunk (bKGD)*/\nstatic unsigned readChunk_bKGD(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)\n{\n  if(info->color.colortype == LCT_PALETTE)\n  {\n    /*error: this chunk must be 1 byte for indexed color image*/\n    if(chunkLength != 1) return 43;\n\n    info->background_defined = 1;\n    info->background_r = info->background_g = info->background_b = data[0];\n  }\n  else if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)\n  {\n    /*error: this chunk must be 2 bytes for greyscale image*/\n    if(chunkLength != 2) return 44;\n\n    info->background_defined = 1;\n    info->background_r = info->background_g = info->background_b\n                                 = 256 * data[0] + data[1];\n  }\n  else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)\n  {\n    /*error: this chunk must be 6 bytes for greyscale image*/\n    if(chunkLength != 6) return 45;\n\n    info->background_defined = 1;\n    info->background_r = 256 * data[0] + data[1];\n    info->background_g = 256 * data[2] + data[3];\n    info->background_b = 256 * data[4] + data[5];\n  }\n\n  return 0; /* OK */\n}\n\n/*text chunk (tEXt)*/\nstatic unsigned readChunk_tEXt(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)\n{\n  unsigned error = 0;\n  char *key = 0, *str = 0;\n  unsigned i;\n\n  while(!error) /*not really a while loop, only used to break on error*/\n  {\n    unsigned length, string2_begin;\n\n    length = 0;\n    while(length < chunkLength && data[length] != 0) length++;\n    /*even though it's not allowed by the standard, no error is thrown if\n    there's no null termination char, if the text is empty*/\n    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/\n\n    key = (char*)lodepng_malloc(length + 1);\n    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    key[length] = 0;\n    for(i = 0; i < length; i++) key[i] = data[i];\n\n    string2_begin = length + 1; /*skip keyword null terminator*/\n\n    length = chunkLength < string2_begin ? 0 : chunkLength - string2_begin;\n    str = (char*)lodepng_malloc(length + 1);\n    if(!str) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    str[length] = 0;\n    for(i = 0; i < length; i++) str[i] = data[string2_begin + i];\n\n    error = lodepng_add_text(info, key, str);\n\n    break;\n  }\n\n  lodepng_free(key);\n  lodepng_free(str);\n\n  return error;\n}\n\n/*compressed text chunk (zTXt)*/\nstatic unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,\n                               const unsigned char* data, size_t chunkLength)\n{\n  unsigned error = 0;\n  unsigned i;\n\n  unsigned length, string2_begin;\n  char *key = 0;\n  ucvector decoded;\n\n  ucvector_init(&decoded);\n\n  while(!error) /*not really a while loop, only used to break on error*/\n  {\n    for(length = 0; length < chunkLength && data[length] != 0; length++) ;\n    if(length + 2 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/\n    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/\n\n    key = (char*)lodepng_malloc(length + 1);\n    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    key[length] = 0;\n    for(i = 0; i < length; i++) key[i] = data[i];\n\n    if(data[length + 1] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/\n\n    string2_begin = length + 2;\n    if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/\n\n    length = chunkLength - string2_begin;\n    /*will fail if zlib error, e.g. if length is too small*/\n    error = zlib_decompress(&decoded.data, &decoded.size,\n                            (unsigned char*)(&data[string2_begin]),\n                            length, zlibsettings);\n    if(error) break;\n    ucvector_push_back(&decoded, 0);\n\n    error = lodepng_add_text(info, key, (char*)decoded.data);\n\n    break;\n  }\n\n  lodepng_free(key);\n  ucvector_cleanup(&decoded);\n\n  return error;\n}\n\n/*international text chunk (iTXt)*/\nstatic unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,\n                               const unsigned char* data, size_t chunkLength)\n{\n  unsigned error = 0;\n  unsigned i;\n\n  unsigned length, begin, compressed;\n  char *key = 0, *langtag = 0, *transkey = 0;\n  ucvector decoded;\n  ucvector_init(&decoded);\n\n  while(!error) /*not really a while loop, only used to break on error*/\n  {\n    /*Quick check if the chunk length isn't too small. Even without check\n    it'd still fail with other error checks below if it's too short. This just gives a different error code.*/\n    if(chunkLength < 5) CERROR_BREAK(error, 30); /*iTXt chunk too short*/\n\n    /*read the key*/\n    for(length = 0; length < chunkLength && data[length] != 0; length++) ;\n    if(length + 3 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination char, corrupt?*/\n    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/\n\n    key = (char*)lodepng_malloc(length + 1);\n    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    key[length] = 0;\n    for(i = 0; i < length; i++) key[i] = data[i];\n\n    /*read the compression method*/\n    compressed = data[length + 1];\n    if(data[length + 2] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/\n\n    /*even though it's not allowed by the standard, no error is thrown if\n    there's no null termination char, if the text is empty for the next 3 texts*/\n\n    /*read the langtag*/\n    begin = length + 3;\n    length = 0;\n    for(i = begin; i < chunkLength && data[i] != 0; i++) length++;\n\n    langtag = (char*)lodepng_malloc(length + 1);\n    if(!langtag) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    langtag[length] = 0;\n    for(i = 0; i < length; i++) langtag[i] = data[begin + i];\n\n    /*read the transkey*/\n    begin += length + 1;\n    length = 0;\n    for(i = begin; i < chunkLength && data[i] != 0; i++) length++;\n\n    transkey = (char*)lodepng_malloc(length + 1);\n    if(!transkey) CERROR_BREAK(error, 83); /*alloc fail*/\n\n    transkey[length] = 0;\n    for(i = 0; i < length; i++) transkey[i] = data[begin + i];\n\n    /*read the actual text*/\n    begin += length + 1;\n\n    length = chunkLength < begin ? 0 : chunkLength - begin;\n\n    if(compressed)\n    {\n      /*will fail if zlib error, e.g. if length is too small*/\n      error = zlib_decompress(&decoded.data, &decoded.size,\n                              (unsigned char*)(&data[begin]),\n                              length, zlibsettings);\n      if(error) break;\n      if(decoded.allocsize < decoded.size) decoded.allocsize = decoded.size;\n      ucvector_push_back(&decoded, 0);\n    }\n    else\n    {\n      if(!ucvector_resize(&decoded, length + 1)) CERROR_BREAK(error, 83 /*alloc fail*/);\n\n      decoded.data[length] = 0;\n      for(i = 0; i < length; i++) decoded.data[i] = data[begin + i];\n    }\n\n    error = lodepng_add_itext(info, key, langtag, transkey, (char*)decoded.data);\n\n    break;\n  }\n\n  lodepng_free(key);\n  lodepng_free(langtag);\n  lodepng_free(transkey);\n  ucvector_cleanup(&decoded);\n\n  return error;\n}\n\nstatic unsigned readChunk_tIME(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)\n{\n  if(chunkLength != 7) return 73; /*invalid tIME chunk size*/\n\n  info->time_defined = 1;\n  info->time.year = 256 * data[0] + data[+ 1];\n  info->time.month = data[2];\n  info->time.day = data[3];\n  info->time.hour = data[4];\n  info->time.minute = data[5];\n  info->time.second = data[6];\n\n  return 0; /* OK */\n}\n\nstatic unsigned readChunk_pHYs(LodePNGInfo* info, const unsigned char* data, size_t chunkLength)\n{\n  if(chunkLength != 9) return 74; /*invalid pHYs chunk size*/\n\n  info->phys_defined = 1;\n  info->phys_x = 16777216 * data[0] + 65536 * data[1] + 256 * data[2] + data[3];\n  info->phys_y = 16777216 * data[4] + 65536 * data[5] + 256 * data[6] + data[7];\n  info->phys_unit = data[8];\n\n  return 0; /* OK */\n}\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\n/*read a PNG, the result will be in the same color type as the PNG (hence \"generic\")*/\nstatic void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,\n                          LodePNGState* state,\n                          const unsigned char* in, size_t insize)\n{\n  unsigned char IEND = 0;\n  const unsigned char* chunk;\n  size_t i;\n  ucvector idat; /*the data from idat chunks*/\n\n  /*for unknown chunk order*/\n  unsigned unknown = 0;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  unsigned critical_pos = 1; /*1 = after IHDR, 2 = after PLTE, 3 = after IDAT*/\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\n  /*provide some proper output values if error will happen*/\n  *out = 0;\n\n  state->error = lodepng_inspect(w, h, state, in, insize); /*reads header and resets other parameters in state->info_png*/\n  if(state->error) return;\n\n  ucvector_init(&idat);\n  chunk = &in[33]; /*first byte of the first chunk after the header*/\n\n  /*loop through the chunks, ignoring unknown chunks and stopping at IEND chunk.\n  IDAT data is put at the start of the in buffer*/\n  while(!IEND && !state->error)\n  {\n    unsigned chunkLength;\n    const unsigned char* data; /*the data in the chunk*/\n\n    /*error: size of the in buffer too small to contain next chunk*/\n    if((size_t)((chunk - in) + 12) > insize || chunk < in) CERROR_BREAK(state->error, 30);\n\n    /*length of the data of the chunk, excluding the length bytes, chunk type and CRC bytes*/\n    chunkLength = lodepng_chunk_length(chunk);\n    /*error: chunk length larger than the max PNG chunk size*/\n    if(chunkLength > 2147483647) CERROR_BREAK(state->error, 63);\n\n    if((size_t)((chunk - in) + chunkLength + 12) > insize || (chunk + chunkLength + 12) < in)\n    {\n      CERROR_BREAK(state->error, 64); /*error: size of the in buffer too small to contain next chunk*/\n    }\n\n    data = lodepng_chunk_data_const(chunk);\n\n    /*IDAT chunk, containing compressed image data*/\n    if(lodepng_chunk_type_equals(chunk, \"IDAT\"))\n    {\n      size_t oldsize = idat.size;\n      if(!ucvector_resize(&idat, oldsize + chunkLength)) CERROR_BREAK(state->error, 83 /*alloc fail*/);\n      for(i = 0; i < chunkLength; i++) idat.data[oldsize + i] = data[i];\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n      critical_pos = 3;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    }\n    /*IEND chunk*/\n    else if(lodepng_chunk_type_equals(chunk, \"IEND\"))\n    {\n      IEND = 1;\n    }\n    /*palette chunk (PLTE)*/\n    else if(lodepng_chunk_type_equals(chunk, \"PLTE\"))\n    {\n      state->error = readChunk_PLTE(&state->info_png.color, data, chunkLength);\n      if(state->error) break;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n      critical_pos = 2;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    }\n    /*palette transparency chunk (tRNS)*/\n    else if(lodepng_chunk_type_equals(chunk, \"tRNS\"))\n    {\n      state->error = readChunk_tRNS(&state->info_png.color, data, chunkLength);\n      if(state->error) break;\n    }\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n    /*background color chunk (bKGD)*/\n    else if(lodepng_chunk_type_equals(chunk, \"bKGD\"))\n    {\n      state->error = readChunk_bKGD(&state->info_png, data, chunkLength);\n      if(state->error) break;\n    }\n    /*text chunk (tEXt)*/\n    else if(lodepng_chunk_type_equals(chunk, \"tEXt\"))\n    {\n      if(state->decoder.read_text_chunks)\n      {\n        state->error = readChunk_tEXt(&state->info_png, data, chunkLength);\n        if(state->error) break;\n      }\n    }\n    /*compressed text chunk (zTXt)*/\n    else if(lodepng_chunk_type_equals(chunk, \"zTXt\"))\n    {\n      if(state->decoder.read_text_chunks)\n      {\n        state->error = readChunk_zTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);\n        if(state->error) break;\n      }\n    }\n    /*international text chunk (iTXt)*/\n    else if(lodepng_chunk_type_equals(chunk, \"iTXt\"))\n    {\n      if(state->decoder.read_text_chunks)\n      {\n        state->error = readChunk_iTXt(&state->info_png, &state->decoder.zlibsettings, data, chunkLength);\n        if(state->error) break;\n      }\n    }\n    else if(lodepng_chunk_type_equals(chunk, \"tIME\"))\n    {\n      state->error = readChunk_tIME(&state->info_png, data, chunkLength);\n      if(state->error) break;\n    }\n    else if(lodepng_chunk_type_equals(chunk, \"pHYs\"))\n    {\n      state->error = readChunk_pHYs(&state->info_png, data, chunkLength);\n      if(state->error) break;\n    }\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    else /*it's not an implemented chunk type, so ignore it: skip over the data*/\n    {\n      /*error: unknown critical chunk (5th bit of first byte of chunk type is 0)*/\n      if(!lodepng_chunk_ancillary(chunk)) CERROR_BREAK(state->error, 69);\n\n      unknown = 1;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n      if(state->decoder.remember_unknown_chunks)\n      {\n        state->error = lodepng_chunk_append(&state->info_png.unknown_chunks_data[critical_pos - 1],\n                                            &state->info_png.unknown_chunks_size[critical_pos - 1], chunk);\n        if(state->error) break;\n      }\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    }\n\n    if(!state->decoder.ignore_crc && !unknown) /*check CRC if wanted, only on known chunk types*/\n    {\n      if(lodepng_chunk_check_crc(chunk)) CERROR_BREAK(state->error, 57); /*invalid CRC*/\n    }\n\n    if(!IEND) chunk = lodepng_chunk_next_const(chunk);\n  }\n\n  if(!state->error)\n  {\n    ucvector scanlines;\n    ucvector_init(&scanlines);\n\n    /*maximum final image length is already reserved in the vector's length - this is not really necessary*/\n    if(!ucvector_resize(&scanlines, lodepng_get_raw_size(*w, *h, &state->info_png.color) + *h))\n    {\n      state->error = 83; /*alloc fail*/\n    }\n    if(!state->error)\n    {\n      /*decompress with the Zlib decompressor*/\n      state->error = zlib_decompress(&scanlines.data, &scanlines.size, idat.data,\n                                     idat.size, &state->decoder.zlibsettings);\n    }\n\n    if(!state->error)\n    {\n      ucvector outv;\n      ucvector_init(&outv);\n      if(!ucvector_resizev(&outv,\n          lodepng_get_raw_size(*w, *h, &state->info_png.color), 0)) state->error = 83; /*alloc fail*/\n      if(!state->error) state->error = postProcessScanlines(outv.data, scanlines.data, *w, *h, &state->info_png);\n      *out = outv.data;\n    }\n    ucvector_cleanup(&scanlines);\n  }\n\n  ucvector_cleanup(&idat);\n}\n\nunsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,\n                        LodePNGState* state,\n                        const unsigned char* in, size_t insize)\n{\n  *out = 0;\n  decodeGeneric(out, w, h, state, in, insize);\n  if(state->error) return state->error;\n  if(!state->decoder.color_convert || lodepng_color_mode_equal(&state->info_raw, &state->info_png.color))\n  {\n    /*same color type, no copying or converting of data needed*/\n    /*store the info_png color settings on the info_raw so that the info_raw still reflects what colortype\n    the raw image has to the end user*/\n    if(!state->decoder.color_convert)\n    {\n      state->error = lodepng_color_mode_copy(&state->info_raw, &state->info_png.color);\n      if(state->error) return state->error;\n    }\n  }\n  else\n  {\n    /*color conversion needed; sort of copy of the data*/\n    unsigned char* data = *out;\n    size_t outsize;\n\n    /*TODO: check if this works according to the statement in the documentation: \"The converter can convert\n    from greyscale input color type, to 8-bit greyscale or greyscale with alpha\"*/\n    if(!(state->info_raw.colortype == LCT_RGB || state->info_raw.colortype == LCT_RGBA)\n       && !(state->info_raw.bitdepth == 8))\n    {\n      return 56; /*unsupported color mode conversion*/\n    }\n\n    outsize = lodepng_get_raw_size(*w, *h, &state->info_raw);\n    *out = (unsigned char*)lodepng_malloc(outsize);\n    if(!(*out))\n    {\n      state->error = 83; /*alloc fail*/\n    }\n    else state->error = lodepng_convert(*out, data, &state->info_raw, &state->info_png.color, *w, *h, state->decoder.fix_png);\n    lodepng_free(data);\n  }\n  return state->error;\n}\n\nunsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in,\n                               size_t insize, LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned error;\n  LodePNGState state;\n  lodepng_state_init(&state);\n  state.info_raw.colortype = colortype;\n  state.info_raw.bitdepth = bitdepth;\n  error = lodepng_decode(out, w, h, &state, in, insize);\n  lodepng_state_cleanup(&state);\n  return error;\n}\n\nunsigned lodepng_decode32(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in, size_t insize)\n{\n  return lodepng_decode_memory(out, w, h, in, insize, LCT_RGBA, 8);\n}\n\nunsigned lodepng_decode24(unsigned char** out, unsigned* w, unsigned* h, const unsigned char* in, size_t insize)\n{\n  return lodepng_decode_memory(out, w, h, in, insize, LCT_RGB, 8);\n}\n\n#ifdef LODEPNG_COMPILE_DISK\nunsigned lodepng_decode_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename,\n                             LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned char* buffer;\n  size_t buffersize;\n  unsigned error;\n  error = lodepng_load_file(&buffer, &buffersize, filename);\n  if(!error) error = lodepng_decode_memory(out, w, h, buffer, buffersize, colortype, bitdepth);\n  lodepng_free(buffer);\n  return error;\n}\n\nunsigned lodepng_decode32_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename)\n{\n  return lodepng_decode_file(out, w, h, filename, LCT_RGBA, 8);\n}\n\nunsigned lodepng_decode24_file(unsigned char** out, unsigned* w, unsigned* h, const char* filename)\n{\n  return lodepng_decode_file(out, w, h, filename, LCT_RGB, 8);\n}\n#endif /*LODEPNG_COMPILE_DISK*/\n\nvoid lodepng_decoder_settings_init(LodePNGDecoderSettings* settings)\n{\n  settings->color_convert = 1;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  settings->read_text_chunks = 1;\n  settings->remember_unknown_chunks = 0;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n  settings->ignore_crc = 0;\n  settings->fix_png = 0;\n  lodepng_decompress_settings_init(&settings->zlibsettings);\n}\n\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER)\n\nvoid lodepng_state_init(LodePNGState* state)\n{\n#ifdef LODEPNG_COMPILE_DECODER\n  lodepng_decoder_settings_init(&state->decoder);\n#endif /*LODEPNG_COMPILE_DECODER*/\n#ifdef LODEPNG_COMPILE_ENCODER\n  lodepng_encoder_settings_init(&state->encoder);\n#endif /*LODEPNG_COMPILE_ENCODER*/\n  lodepng_color_mode_init(&state->info_raw);\n  lodepng_info_init(&state->info_png);\n  state->error = 1;\n}\n\nvoid lodepng_state_cleanup(LodePNGState* state)\n{\n  lodepng_color_mode_cleanup(&state->info_raw);\n  lodepng_info_cleanup(&state->info_png);\n}\n\nvoid lodepng_state_copy(LodePNGState* dest, const LodePNGState* source)\n{\n  lodepng_state_cleanup(dest);\n  *dest = *source;\n  lodepng_color_mode_init(&dest->info_raw);\n  lodepng_info_init(&dest->info_png);\n  dest->error = lodepng_color_mode_copy(&dest->info_raw, &source->info_raw); if(dest->error) return;\n  dest->error = lodepng_info_copy(&dest->info_png, &source->info_png); if(dest->error) return;\n}\n\n#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */\n\n#ifdef LODEPNG_COMPILE_ENCODER\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* / PNG Encoder                                                            / */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n/*chunkName must be string of 4 characters*/\nstatic unsigned addChunk(ucvector* out, const char* chunkName, const unsigned char* data, size_t length)\n{\n  CERROR_TRY_RETURN(lodepng_chunk_create(&out->data, &out->size, (unsigned)length, chunkName, data));\n  out->allocsize = out->size; /*fix the allocsize again*/\n  return 0;\n}\n\nstatic void writeSignature(ucvector* out)\n{\n  /*8 bytes PNG signature, aka the magic bytes*/\n  ucvector_push_back(out, 137);\n  ucvector_push_back(out, 80);\n  ucvector_push_back(out, 78);\n  ucvector_push_back(out, 71);\n  ucvector_push_back(out, 13);\n  ucvector_push_back(out, 10);\n  ucvector_push_back(out, 26);\n  ucvector_push_back(out, 10);\n}\n\nstatic unsigned addChunk_IHDR(ucvector* out, unsigned w, unsigned h,\n                              LodePNGColorType colortype, unsigned bitdepth, unsigned interlace_method)\n{\n  unsigned error = 0;\n  ucvector header;\n  ucvector_init(&header);\n\n  lodepng_add32bitInt(&header, w); /*width*/\n  lodepng_add32bitInt(&header, h); /*height*/\n  ucvector_push_back(&header, (unsigned char)bitdepth); /*bit depth*/\n  ucvector_push_back(&header, (unsigned char)colortype); /*color type*/\n  ucvector_push_back(&header, 0); /*compression method*/\n  ucvector_push_back(&header, 0); /*filter method*/\n  ucvector_push_back(&header, interlace_method); /*interlace method*/\n\n  error = addChunk(out, \"IHDR\", header.data, header.size);\n  ucvector_cleanup(&header);\n\n  return error;\n}\n\nstatic unsigned addChunk_PLTE(ucvector* out, const LodePNGColorMode* info)\n{\n  unsigned error = 0;\n  size_t i;\n  ucvector PLTE;\n  ucvector_init(&PLTE);\n  for(i = 0; i < info->palettesize * 4; i++)\n  {\n    /*add all channels except alpha channel*/\n    if(i % 4 != 3) ucvector_push_back(&PLTE, info->palette[i]);\n  }\n  error = addChunk(out, \"PLTE\", PLTE.data, PLTE.size);\n  ucvector_cleanup(&PLTE);\n\n  return error;\n}\n\nstatic unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)\n{\n  unsigned error = 0;\n  size_t i;\n  ucvector tRNS;\n  ucvector_init(&tRNS);\n  if(info->colortype == LCT_PALETTE)\n  {\n    size_t amount = info->palettesize;\n    /*the tail of palette values that all have 255 as alpha, does not have to be encoded*/\n    for(i = info->palettesize; i > 0; i--)\n    {\n      if(info->palette[4 * (i - 1) + 3] == 255) amount--;\n      else break;\n    }\n    /*add only alpha channel*/\n    for(i = 0; i < amount; i++) ucvector_push_back(&tRNS, info->palette[4 * i + 3]);\n  }\n  else if(info->colortype == LCT_GREY)\n  {\n    if(info->key_defined)\n    {\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));\n    }\n  }\n  else if(info->colortype == LCT_RGB)\n  {\n    if(info->key_defined)\n    {\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_g / 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_g % 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_b / 256));\n      ucvector_push_back(&tRNS, (unsigned char)(info->key_b % 256));\n    }\n  }\n\n  error = addChunk(out, \"tRNS\", tRNS.data, tRNS.size);\n  ucvector_cleanup(&tRNS);\n\n  return error;\n}\n\nstatic unsigned addChunk_IDAT(ucvector* out, const unsigned char* data, size_t datasize,\n                              LodePNGCompressSettings* zlibsettings)\n{\n  ucvector zlibdata;\n  unsigned error = 0;\n\n  /*compress with the Zlib compressor*/\n  ucvector_init(&zlibdata);\n  error = zlib_compress(&zlibdata.data, &zlibdata.size, data, datasize, zlibsettings);\n  if(!error) error = addChunk(out, \"IDAT\", zlibdata.data, zlibdata.size);\n  ucvector_cleanup(&zlibdata);\n\n  return error;\n}\n\nstatic unsigned addChunk_IEND(ucvector* out)\n{\n  unsigned error = 0;\n  error = addChunk(out, \"IEND\", 0, 0);\n  return error;\n}\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n\nstatic unsigned addChunk_tEXt(ucvector* out, const char* keyword, const char* textstring)\n{\n  unsigned error = 0;\n  size_t i;\n  ucvector text;\n  ucvector_init(&text);\n  for(i = 0; keyword[i] != 0; i++) ucvector_push_back(&text, (unsigned char)keyword[i]);\n  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/\n  ucvector_push_back(&text, 0); /*0 termination char*/\n  for(i = 0; textstring[i] != 0; i++) ucvector_push_back(&text, (unsigned char)textstring[i]);\n  error = addChunk(out, \"tEXt\", text.data, text.size);\n  ucvector_cleanup(&text);\n\n  return error;\n}\n\nstatic unsigned addChunk_zTXt(ucvector* out, const char* keyword, const char* textstring,\n                              LodePNGCompressSettings* zlibsettings)\n{\n  unsigned error = 0;\n  ucvector data, compressed;\n  size_t i, textsize = strlen(textstring);\n\n  ucvector_init(&data);\n  ucvector_init(&compressed);\n  for(i = 0; keyword[i] != 0; i++) ucvector_push_back(&data, (unsigned char)keyword[i]);\n  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/\n  ucvector_push_back(&data, 0); /*0 termination char*/\n  ucvector_push_back(&data, 0); /*compression method: 0*/\n\n  error = zlib_compress(&compressed.data, &compressed.size,\n                        (unsigned char*)textstring, textsize, zlibsettings);\n  if(!error)\n  {\n    for(i = 0; i < compressed.size; i++) ucvector_push_back(&data, compressed.data[i]);\n    error = addChunk(out, \"zTXt\", data.data, data.size);\n  }\n\n  ucvector_cleanup(&compressed);\n  ucvector_cleanup(&data);\n  return error;\n}\n\nstatic unsigned addChunk_iTXt(ucvector* out, unsigned compressed, const char* keyword, const char* langtag,\n                              const char* transkey, const char* textstring, LodePNGCompressSettings* zlibsettings)\n{\n  unsigned error = 0;\n  ucvector data;\n  size_t i, textsize = strlen(textstring);\n\n  ucvector_init(&data);\n\n  for(i = 0; keyword[i] != 0; i++) ucvector_push_back(&data, (unsigned char)keyword[i]);\n  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/\n  ucvector_push_back(&data, 0); /*null termination char*/\n  ucvector_push_back(&data, compressed ? 1 : 0); /*compression flag*/\n  ucvector_push_back(&data, 0); /*compression method*/\n  for(i = 0; langtag[i] != 0; i++) ucvector_push_back(&data, (unsigned char)langtag[i]);\n  ucvector_push_back(&data, 0); /*null termination char*/\n  for(i = 0; transkey[i] != 0; i++) ucvector_push_back(&data, (unsigned char)transkey[i]);\n  ucvector_push_back(&data, 0); /*null termination char*/\n\n  if(compressed)\n  {\n    ucvector compressed_data;\n    ucvector_init(&compressed_data);\n    error = zlib_compress(&compressed_data.data, &compressed_data.size,\n                          (unsigned char*)textstring, textsize, zlibsettings);\n    if(!error)\n    {\n      for(i = 0; i < compressed_data.size; i++) ucvector_push_back(&data, compressed_data.data[i]);\n    }\n    ucvector_cleanup(&compressed_data);\n  }\n  else /*not compressed*/\n  {\n    for(i = 0; textstring[i] != 0; i++) ucvector_push_back(&data, (unsigned char)textstring[i]);\n  }\n\n  if(!error) error = addChunk(out, \"iTXt\", data.data, data.size);\n  ucvector_cleanup(&data);\n  return error;\n}\n\nstatic unsigned addChunk_bKGD(ucvector* out, const LodePNGInfo* info)\n{\n  unsigned error = 0;\n  ucvector bKGD;\n  ucvector_init(&bKGD);\n  if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)\n  {\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));\n  }\n  else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)\n  {\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_g / 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_g % 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_b / 256));\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_b % 256));\n  }\n  else if(info->color.colortype == LCT_PALETTE)\n  {\n    ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256)); /*palette index*/\n  }\n\n  error = addChunk(out, \"bKGD\", bKGD.data, bKGD.size);\n  ucvector_cleanup(&bKGD);\n\n  return error;\n}\n\nstatic unsigned addChunk_tIME(ucvector* out, const LodePNGTime* time)\n{\n  unsigned error = 0;\n  unsigned char* data = (unsigned char*)lodepng_malloc(7);\n  if(!data) return 83; /*alloc fail*/\n  data[0] = (unsigned char)(time->year / 256);\n  data[1] = (unsigned char)(time->year % 256);\n  data[2] = time->month;\n  data[3] = time->day;\n  data[4] = time->hour;\n  data[5] = time->minute;\n  data[6] = time->second;\n  error = addChunk(out, \"tIME\", data, 7);\n  lodepng_free(data);\n  return error;\n}\n\nstatic unsigned addChunk_pHYs(ucvector* out, const LodePNGInfo* info)\n{\n  unsigned error = 0;\n  ucvector data;\n  ucvector_init(&data);\n\n  lodepng_add32bitInt(&data, info->phys_x);\n  lodepng_add32bitInt(&data, info->phys_y);\n  ucvector_push_back(&data, info->phys_unit);\n\n  error = addChunk(out, \"pHYs\", data.data, data.size);\n  ucvector_cleanup(&data);\n\n  return error;\n}\n\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\nstatic void filterScanline(unsigned char* out, const unsigned char* scanline, const unsigned char* prevline,\n                           size_t length, size_t bytewidth, unsigned char filterType)\n{\n  size_t i;\n  switch(filterType)\n  {\n    case 0: /*None*/\n      for(i = 0; i < length; i++) out[i] = scanline[i];\n      break;\n    case 1: /*Sub*/\n      if(prevline)\n      {\n        for(i = 0; i < bytewidth; i++) out[i] = scanline[i];\n        for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth];\n      }\n      else\n      {\n        for(i = 0; i < bytewidth; i++) out[i] = scanline[i];\n        for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth];\n      }\n      break;\n    case 2: /*Up*/\n      if(prevline)\n      {\n        for(i = 0; i < length; i++) out[i] = scanline[i] - prevline[i];\n      }\n      else\n      {\n        for(i = 0; i < length; i++) out[i] = scanline[i];\n      }\n      break;\n    case 3: /*Average*/\n      if(prevline)\n      {\n        for(i = 0; i < bytewidth; i++) out[i] = scanline[i] - prevline[i] / 2;\n        for(i = bytewidth; i < length; i++) out[i] = scanline[i] - ((scanline[i - bytewidth] + prevline[i]) / 2);\n      }\n      else\n      {\n        for(i = 0; i < bytewidth; i++) out[i] = scanline[i];\n        for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth] / 2;\n      }\n      break;\n    case 4: /*Paeth*/\n      if(prevline)\n      {\n        /*paethPredictor(0, prevline[i], 0) is always prevline[i]*/\n        for(i = 0; i < bytewidth; i++) out[i] = (scanline[i] - prevline[i]);\n        for(i = bytewidth; i < length; i++)\n        {\n          out[i] = (scanline[i] - paethPredictor(scanline[i - bytewidth], prevline[i], prevline[i - bytewidth]));\n        }\n      }\n      else\n      {\n        for(i = 0; i < bytewidth; i++) out[i] = scanline[i];\n        /*paethPredictor(scanline[i - bytewidth], 0, 0) is always scanline[i - bytewidth]*/\n        for(i = bytewidth; i < length; i++) out[i] = (scanline[i] - scanline[i - bytewidth]);\n      }\n      break;\n    default: return; /*unexisting filter type given*/\n  }\n}\n\n/* log2 approximation. A slight bit faster than std::log. */\nstatic float flog2(float f)\n{\n  float result = 0;\n  while(f > 32) { result += 4; f /= 16; }\n  while(f > 2) { result++; f /= 2; }\n  return result + 1.442695f * (f * f * f / 3 - 3 * f * f / 2 + 3 * f - 1.83333f);\n}\n\nstatic unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h,\n                       const LodePNGColorMode* info, const LodePNGEncoderSettings* settings)\n{\n  /*\n  For PNG filter method 0\n  out must be a buffer with as size: h + (w * h * bpp + 7) / 8, because there are\n  the scanlines with 1 extra byte per scanline\n  */\n\n  unsigned bpp = lodepng_get_bpp(info);\n  /*the width of a scanline in bytes, not including the filter type*/\n  size_t linebytes = (w * bpp + 7) / 8;\n  /*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/\n  size_t bytewidth = (bpp + 7) / 8;\n  const unsigned char* prevline = 0;\n  unsigned x, y;\n  unsigned error = 0;\n  LodePNGFilterStrategy strategy = settings->filter_strategy;\n\n  /*\n  There is a heuristic called the minimum sum of absolute differences heuristic, suggested by the PNG standard:\n   *  If the image type is Palette, or the bit depth is smaller than 8, then do not filter the image (i.e.\n      use fixed filtering, with the filter None).\n   * (The other case) If the image type is Grayscale or RGB (with or without Alpha), and the bit depth is\n     not smaller than 8, then use adaptive filtering heuristic as follows: independently for each row, apply\n     all five filters and select the filter that produces the smallest sum of absolute values per row.\n  This heuristic is used if filter strategy is LFS_MINSUM and filter_palette_zero is true.\n\n  If filter_palette_zero is true and filter_strategy is not LFS_MINSUM, the above heuristic is followed,\n  but for \"the other case\", whatever strategy filter_strategy is set to instead of the minimum sum\n  heuristic is used.\n  */\n  if(settings->filter_palette_zero &&\n     (info->colortype == LCT_PALETTE || info->bitdepth < 8)) strategy = LFS_ZERO;\n\n  if(bpp == 0) return 31; /*error: invalid color type*/\n\n  if(strategy == LFS_ZERO)\n  {\n    for(y = 0; y < h; y++)\n    {\n      size_t outindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/\n      size_t inindex = linebytes * y;\n      out[outindex] = 0; /*filter type byte*/\n      filterScanline(&out[outindex + 1], &in[inindex], prevline, linebytes, bytewidth, 0);\n      prevline = &in[inindex];\n    }\n  }\n  else if(strategy == LFS_MINSUM)\n  {\n    /*adaptive filtering*/\n    size_t sum[5];\n    ucvector attempt[5]; /*five filtering attempts, one for each filter type*/\n    size_t smallest = 0;\n    unsigned type, bestType = 0;\n\n    for(type = 0; type < 5; type++)\n    {\n      ucvector_init(&attempt[type]);\n      if(!ucvector_resize(&attempt[type], linebytes)) return 83; /*alloc fail*/\n    }\n\n    if(!error)\n    {\n      for(y = 0; y < h; y++)\n      {\n        /*try the 5 filter types*/\n        for(type = 0; type < 5; type++)\n        {\n          filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);\n\n          /*calculate the sum of the result*/\n          sum[type] = 0;\n          if(type == 0)\n          {\n            for(x = 0; x < linebytes; x++) sum[type] += (unsigned char)(attempt[type].data[x]);\n          }\n          else\n          {\n            for(x = 0; x < linebytes; x++)\n            {\n              /*For differences, each byte should be treated as signed, values above 127 are negative\n              (converted to signed char). Filtertype 0 isn't a difference though, so use unsigned there.\n              This means filtertype 0 is almost never chosen, but that is justified.*/\n              signed char s = (signed char)(attempt[type].data[x]);\n              sum[type] += s < 0 ? -s : s;\n            }\n          }\n\n          /*check if this is smallest sum (or if type == 0 it's the first case so always store the values)*/\n          if(type == 0 || sum[type] < smallest)\n          {\n            bestType = type;\n            smallest = sum[type];\n          }\n        }\n\n        prevline = &in[y * linebytes];\n\n        /*now fill the out values*/\n        out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/\n        for(x = 0; x < linebytes; x++) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];\n      }\n    }\n\n    for(type = 0; type < 5; type++) ucvector_cleanup(&attempt[type]);\n  }\n  else if(strategy == LFS_ENTROPY)\n  {\n    float sum[5];\n    ucvector attempt[5]; /*five filtering attempts, one for each filter type*/\n    float smallest = 0;\n    unsigned type, bestType = 0;\n    unsigned count[256];\n\n    for(type = 0; type < 5; type++)\n    {\n      ucvector_init(&attempt[type]);\n      if(!ucvector_resize(&attempt[type], linebytes)) return 83; /*alloc fail*/\n    }\n\n    for(y = 0; y < h; y++)\n    {\n      /*try the 5 filter types*/\n      for(type = 0; type < 5; type++)\n      {\n        filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);\n        for(x = 0; x < 256; x++) count[x] = 0;\n        for(x = 0; x < linebytes; x++) count[attempt[type].data[x]]++;\n        count[type]++; /*the filter type itself is part of the scanline*/\n        sum[type] = 0;\n        for(x = 0; x < 256; x++)\n        {\n          float p = count[x] / (float)(linebytes + 1);\n          sum[type] += count[x] == 0 ? 0 : flog2(1 / p) * p;\n        }\n        /*check if this is smallest sum (or if type == 0 it's the first case so always store the values)*/\n        if(type == 0 || sum[type] < smallest)\n        {\n          bestType = type;\n          smallest = sum[type];\n        }\n      }\n\n      prevline = &in[y * linebytes];\n\n      /*now fill the out values*/\n      out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/\n      for(x = 0; x < linebytes; x++) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];\n    }\n\n    for(type = 0; type < 5; type++) ucvector_cleanup(&attempt[type]);\n  }\n  else if(strategy == LFS_PREDEFINED)\n  {\n    for(y = 0; y < h; y++)\n    {\n      size_t outindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/\n      size_t inindex = linebytes * y;\n      unsigned type = settings->predefined_filters[y];\n      out[outindex] = type; /*filter type byte*/\n      filterScanline(&out[outindex + 1], &in[inindex], prevline, linebytes, bytewidth, type);\n      prevline = &in[inindex];\n    }\n  }\n  else if(strategy == LFS_BRUTE_FORCE)\n  {\n    /*brute force filter chooser.\n    deflate the scanline after every filter attempt to see which one deflates best.\n    This is very slow and gives only slightly smaller, sometimes even larger, result*/\n    size_t size[5];\n    ucvector attempt[5]; /*five filtering attempts, one for each filter type*/\n    size_t smallest = 0;\n    unsigned type = 0, bestType = 0;\n    unsigned char* dummy;\n    LodePNGCompressSettings zlibsettings = settings->zlibsettings;\n    /*use fixed tree on the attempts so that the tree is not adapted to the filtertype on purpose,\n    to simulate the true case where the tree is the same for the whole image. Sometimes it gives\n    better result with dynamic tree anyway. Using the fixed tree sometimes gives worse, but in rare\n    cases better compression. It does make this a bit less slow, so it's worth doing this.*/\n    zlibsettings.btype = 1;\n    /*a custom encoder likely doesn't read the btype setting and is optimized for complete PNG\n    images only, so disable it*/\n    zlibsettings.custom_zlib = 0;\n    zlibsettings.custom_deflate = 0;\n    for(type = 0; type < 5; type++)\n    {\n      ucvector_init(&attempt[type]);\n      ucvector_resize(&attempt[type], linebytes); /*todo: give error if resize failed*/\n    }\n    for(y = 0; y < h; y++) /*try the 5 filter types*/\n    {\n      for(type = 0; type < 5; type++)\n      {\n        unsigned testsize = attempt[type].size;\n        /*if(testsize > 8) testsize /= 8;*/ /*it already works good enough by testing a part of the row*/\n\n        filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);\n        size[type] = 0;\n        dummy = 0;\n        zlib_compress(&dummy, &size[type], attempt[type].data, testsize, &zlibsettings);\n        lodepng_free(dummy);\n        /*check if this is smallest size (or if type == 0 it's the first case so always store the values)*/\n        if(type == 0 || size[type] < smallest)\n        {\n          bestType = type;\n          smallest = size[type];\n        }\n      }\n      prevline = &in[y * linebytes];\n      out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/\n      for(x = 0; x < linebytes; x++) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];\n    }\n    for(type = 0; type < 5; type++) ucvector_cleanup(&attempt[type]);\n  }\n  else return 88; /* unknown filter strategy */\n\n  return error;\n}\n\nstatic void addPaddingBits(unsigned char* out, const unsigned char* in,\n                           size_t olinebits, size_t ilinebits, unsigned h)\n{\n  /*The opposite of the removePaddingBits function\n  olinebits must be >= ilinebits*/\n  unsigned y;\n  size_t diff = olinebits - ilinebits;\n  size_t obp = 0, ibp = 0; /*bit pointers*/\n  for(y = 0; y < h; y++)\n  {\n    size_t x;\n    for(x = 0; x < ilinebits; x++)\n    {\n      unsigned char bit = readBitFromReversedStream(&ibp, in);\n      setBitOfReversedStream(&obp, out, bit);\n    }\n    /*obp += diff; --> no, fill in some value in the padding bits too, to avoid\n    \"Use of uninitialised value of size ###\" warning from valgrind*/\n    for(x = 0; x < diff; x++) setBitOfReversedStream(&obp, out, 0);\n  }\n}\n\n/*\nin: non-interlaced image with size w*h\nout: the same pixels, but re-ordered according to PNG's Adam7 interlacing, with\n no padding bits between scanlines, but between reduced images so that each\n reduced image starts at a byte.\nbpp: bits per pixel\nthere are no padding bits, not between scanlines, not between reduced images\nin has the following size in bits: w * h * bpp.\nout is possibly bigger due to padding bits between reduced images\nNOTE: comments about padding bits are only relevant if bpp < 8\n*/\nstatic void Adam7_interlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)\n{\n  unsigned passw[7], passh[7];\n  size_t filter_passstart[8], padded_passstart[8], passstart[8];\n  unsigned i;\n\n  Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);\n\n  if(bpp >= 8)\n  {\n    for(i = 0; i < 7; i++)\n    {\n      unsigned x, y, b;\n      size_t bytewidth = bpp / 8;\n      for(y = 0; y < passh[i]; y++)\n      for(x = 0; x < passw[i]; x++)\n      {\n        size_t pixelinstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w + ADAM7_IX[i] + x * ADAM7_DX[i]) * bytewidth;\n        size_t pixeloutstart = passstart[i] + (y * passw[i] + x) * bytewidth;\n        for(b = 0; b < bytewidth; b++)\n        {\n          out[pixeloutstart + b] = in[pixelinstart + b];\n        }\n      }\n    }\n  }\n  else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/\n  {\n    for(i = 0; i < 7; i++)\n    {\n      unsigned x, y, b;\n      unsigned ilinebits = bpp * passw[i];\n      unsigned olinebits = bpp * w;\n      size_t obp, ibp; /*bit pointers (for out and in buffer)*/\n      for(y = 0; y < passh[i]; y++)\n      for(x = 0; x < passw[i]; x++)\n      {\n        ibp = (ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp;\n        obp = (8 * passstart[i]) + (y * ilinebits + x * bpp);\n        for(b = 0; b < bpp; b++)\n        {\n          unsigned char bit = readBitFromReversedStream(&ibp, in);\n          setBitOfReversedStream(&obp, out, bit);\n        }\n      }\n    }\n  }\n}\n\n/*out must be buffer big enough to contain uncompressed IDAT chunk data, and in must contain the full image.\nreturn value is error**/\nstatic unsigned preProcessScanlines(unsigned char** out, size_t* outsize, const unsigned char* in,\n                                    unsigned w, unsigned h,\n                                    const LodePNGInfo* info_png, const LodePNGEncoderSettings* settings)\n{\n  /*\n  This function converts the pure 2D image with the PNG's colortype, into filtered-padded-interlaced data. Steps:\n  *) if no Adam7: 1) add padding bits (= posible extra bits per scanline if bpp < 8) 2) filter\n  *) if adam7: 1) Adam7_interlace 2) 7x add padding bits 3) 7x filter\n  */\n  unsigned bpp = lodepng_get_bpp(&info_png->color);\n  unsigned error = 0;\n\n  if(info_png->interlace_method == 0)\n  {\n    *outsize = h + (h * ((w * bpp + 7) / 8)); /*image size plus an extra byte per scanline + possible padding bits*/\n    *out = (unsigned char*)lodepng_malloc(*outsize);\n    if(!(*out) && (*outsize)) error = 83; /*alloc fail*/\n\n    if(!error)\n    {\n      /*non multiple of 8 bits per scanline, padding bits needed per scanline*/\n      if(bpp < 8 && w * bpp != ((w * bpp + 7) / 8) * 8)\n      {\n        unsigned char* padded = (unsigned char*)lodepng_malloc(h * ((w * bpp + 7) / 8));\n        if(!padded) error = 83; /*alloc fail*/\n        if(!error)\n        {\n          addPaddingBits(padded, in, ((w * bpp + 7) / 8) * 8, w * bpp, h);\n          error = filter(*out, padded, w, h, &info_png->color, settings);\n        }\n        lodepng_free(padded);\n      }\n      else\n      {\n        /*we can immediatly filter into the out buffer, no other steps needed*/\n        error = filter(*out, in, w, h, &info_png->color, settings);\n      }\n    }\n  }\n  else /*interlace_method is 1 (Adam7)*/\n  {\n    unsigned passw[7], passh[7];\n    size_t filter_passstart[8], padded_passstart[8], passstart[8];\n    unsigned char* adam7;\n\n    Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);\n\n    *outsize = filter_passstart[7]; /*image size plus an extra byte per scanline + possible padding bits*/\n    *out = (unsigned char*)lodepng_malloc(*outsize);\n    if(!(*out)) error = 83; /*alloc fail*/\n\n    adam7 = (unsigned char*)lodepng_malloc(passstart[7]);\n    if(!adam7 && passstart[7]) error = 83; /*alloc fail*/\n\n    if(!error)\n    {\n      unsigned i;\n\n      Adam7_interlace(adam7, in, w, h, bpp);\n      for(i = 0; i < 7; i++)\n      {\n        if(bpp < 8)\n        {\n          unsigned char* padded = (unsigned char*)lodepng_malloc(padded_passstart[i + 1] - padded_passstart[i]);\n          if(!padded) ERROR_BREAK(83); /*alloc fail*/\n          addPaddingBits(padded, &adam7[passstart[i]],\n                         ((passw[i] * bpp + 7) / 8) * 8, passw[i] * bpp, passh[i]);\n          error = filter(&(*out)[filter_passstart[i]], padded,\n                         passw[i], passh[i], &info_png->color, settings);\n          lodepng_free(padded);\n        }\n        else\n        {\n          error = filter(&(*out)[filter_passstart[i]], &adam7[padded_passstart[i]],\n                         passw[i], passh[i], &info_png->color, settings);\n        }\n\n        if(error) break;\n      }\n    }\n\n    lodepng_free(adam7);\n  }\n\n  return error;\n}\n\n/*\npalette must have 4 * palettesize bytes allocated, and given in format RGBARGBARGBARGBA...\nreturns 0 if the palette is opaque,\nreturns 1 if the palette has a single color with alpha 0 ==> color key\nreturns 2 if the palette is semi-translucent.\n*/\nstatic unsigned getPaletteTranslucency(const unsigned char* palette, size_t palettesize)\n{\n  size_t i, key = 0;\n  unsigned r = 0, g = 0, b = 0; /*the value of the color with alpha 0, so long as color keying is possible*/\n  for(i = 0; i < palettesize; i++)\n  {\n    if(!key && palette[4 * i + 3] == 0)\n    {\n      r = palette[4 * i + 0]; g = palette[4 * i + 1]; b = palette[4 * i + 2];\n      key = 1;\n      i = (size_t)(-1); /*restart from beginning, to detect earlier opaque colors with key's value*/\n    }\n    else if(palette[4 * i + 3] != 255) return 2;\n    /*when key, no opaque RGB may have key's RGB*/\n    else if(key && r == palette[i * 4 + 0] && g == palette[i * 4 + 1] && b == palette[i * 4 + 2]) return 2;\n  }\n  return key;\n}\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\nstatic unsigned addUnknownChunks(ucvector* out, unsigned char* data, size_t datasize)\n{\n  unsigned char* inchunk = data;\n  while((size_t)(inchunk - data) < datasize)\n  {\n    CERROR_TRY_RETURN(lodepng_chunk_append(&out->data, &out->size, inchunk));\n    out->allocsize = out->size; /*fix the allocsize again*/\n    inchunk = lodepng_chunk_next(inchunk);\n  }\n  return 0;\n}\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\nunsigned lodepng_encode(unsigned char** out, size_t* outsize,\n                        const unsigned char* image, unsigned w, unsigned h,\n                        LodePNGState* state)\n{\n  LodePNGInfo info;\n  ucvector outv;\n  unsigned char* data = 0; /*uncompressed version of the IDAT chunk data*/\n  size_t datasize = 0;\n\n  /*provide some proper output values if error will happen*/\n  *out = 0;\n  *outsize = 0;\n  state->error = 0;\n\n  lodepng_info_init(&info);\n  lodepng_info_copy(&info, &state->info_png);\n\n  if((info.color.colortype == LCT_PALETTE || state->encoder.force_palette)\n      && (info.color.palettesize == 0 || info.color.palettesize > 256))\n  {\n    state->error = 68; /*invalid palette size, it is only allowed to be 1-256*/\n    return state->error;\n  }\n\n  if(state->encoder.auto_convert != LAC_NO)\n  {\n    state->error = lodepng_auto_choose_color(&info.color, image, w, h, &state->info_raw,\n                                             state->encoder.auto_convert);\n  }\n  if(state->error) return state->error;\n\n  if(state->encoder.zlibsettings.windowsize > 32768)\n  {\n    CERROR_RETURN_ERROR(state->error, 60); /*error: windowsize larger than allowed*/\n  }\n  if(state->encoder.zlibsettings.btype > 2)\n  {\n    CERROR_RETURN_ERROR(state->error, 61); /*error: unexisting btype*/\n  }\n  if(state->info_png.interlace_method > 1)\n  {\n    CERROR_RETURN_ERROR(state->error, 71); /*error: unexisting interlace mode*/\n  }\n\n  state->error = checkColorValidity(info.color.colortype, info.color.bitdepth);\n  if(state->error) return state->error; /*error: unexisting color type given*/\n  state->error = checkColorValidity(state->info_raw.colortype, state->info_raw.bitdepth);\n  if(state->error) return state->error; /*error: unexisting color type given*/\n\n  if(!lodepng_color_mode_equal(&state->info_raw, &info.color))\n  {\n    unsigned char* converted;\n    size_t size = (w * h * lodepng_get_bpp(&info.color) + 7) / 8;\n\n    converted = (unsigned char*)lodepng_malloc(size);\n    if(!converted && size) state->error = 83; /*alloc fail*/\n    if(!state->error)\n    {\n      state->error = lodepng_convert(converted, image, &info.color, &state->info_raw, w, h, 0 /*fix_png*/);\n    }\n    if(!state->error) preProcessScanlines(&data, &datasize, converted, w, h, &info, &state->encoder);\n    lodepng_free(converted);\n  }\n  else preProcessScanlines(&data, &datasize, image, w, h, &info, &state->encoder);\n\n  ucvector_init(&outv);\n  while(!state->error) /*while only executed once, to break on error*/\n  {\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n    size_t i;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    /*write signature and chunks*/\n    writeSignature(&outv);\n    /*IHDR*/\n    addChunk_IHDR(&outv, w, h, info.color.colortype, info.color.bitdepth, info.interlace_method);\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n    /*unknown chunks between IHDR and PLTE*/\n    if(info.unknown_chunks_data[0])\n    {\n      state->error = addUnknownChunks(&outv, info.unknown_chunks_data[0], info.unknown_chunks_size[0]);\n      if(state->error) break;\n    }\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    /*PLTE*/\n    if(info.color.colortype == LCT_PALETTE)\n    {\n      addChunk_PLTE(&outv, &info.color);\n    }\n    if(state->encoder.force_palette && (info.color.colortype == LCT_RGB || info.color.colortype == LCT_RGBA))\n    {\n      addChunk_PLTE(&outv, &info.color);\n    }\n    /*tRNS*/\n    if(info.color.colortype == LCT_PALETTE && getPaletteTranslucency(info.color.palette, info.color.palettesize) != 0)\n    {\n      addChunk_tRNS(&outv, &info.color);\n    }\n    if((info.color.colortype == LCT_GREY || info.color.colortype == LCT_RGB) && info.color.key_defined)\n    {\n      addChunk_tRNS(&outv, &info.color);\n    }\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n    /*bKGD (must come between PLTE and the IDAt chunks*/\n    if(info.background_defined) addChunk_bKGD(&outv, &info);\n    /*pHYs (must come before the IDAT chunks)*/\n    if(info.phys_defined) addChunk_pHYs(&outv, &info);\n\n    /*unknown chunks between PLTE and IDAT*/\n    if(info.unknown_chunks_data[1])\n    {\n      state->error = addUnknownChunks(&outv, info.unknown_chunks_data[1], info.unknown_chunks_size[1]);\n      if(state->error) break;\n    }\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    /*IDAT (multiple IDAT chunks must be consecutive)*/\n    state->error = addChunk_IDAT(&outv, data, datasize, &state->encoder.zlibsettings);\n    if(state->error) break;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n    /*tIME*/\n    if(info.time_defined) addChunk_tIME(&outv, &info.time);\n    /*tEXt and/or zTXt*/\n    for(i = 0; i < info.text_num; i++)\n    {\n      if(strlen(info.text_keys[i]) > 79)\n      {\n        state->error = 66; /*text chunk too large*/\n        break;\n      }\n      if(strlen(info.text_keys[i]) < 1)\n      {\n        state->error = 67; /*text chunk too small*/\n        break;\n      }\n      if(state->encoder.text_compression)\n        addChunk_zTXt(&outv, info.text_keys[i], info.text_strings[i], &state->encoder.zlibsettings);\n      else\n        addChunk_tEXt(&outv, info.text_keys[i], info.text_strings[i]);\n    }\n    /*LodePNG version id in text chunk*/\n    if(state->encoder.add_id)\n    {\n      unsigned alread_added_id_text = 0;\n      for(i = 0; i < info.text_num; i++)\n      {\n        if(!strcmp(info.text_keys[i], \"LodePNG\"))\n        {\n          alread_added_id_text = 1;\n          break;\n        }\n      }\n      if(alread_added_id_text == 0)\n        addChunk_tEXt(&outv, \"LodePNG\", VERSION_STRING); /*it's shorter as tEXt than as zTXt chunk*/\n    }\n    /*iTXt*/\n    for(i = 0; i < info.itext_num; i++)\n    {\n      if(strlen(info.itext_keys[i]) > 79)\n      {\n        state->error = 66; /*text chunk too large*/\n        break;\n      }\n      if(strlen(info.itext_keys[i]) < 1)\n      {\n        state->error = 67; /*text chunk too small*/\n        break;\n      }\n      addChunk_iTXt(&outv, state->encoder.text_compression,\n                    info.itext_keys[i], info.itext_langtags[i], info.itext_transkeys[i], info.itext_strings[i],\n                    &state->encoder.zlibsettings);\n    }\n\n    /*unknown chunks between IDAT and IEND*/\n    if(info.unknown_chunks_data[2])\n    {\n      state->error = addUnknownChunks(&outv, info.unknown_chunks_data[2], info.unknown_chunks_size[2]);\n      if(state->error) break;\n    }\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n    /*IEND*/\n    addChunk_IEND(&outv);\n\n    break; /*this isn't really a while loop; no error happened so break out now!*/\n  }\n\n  lodepng_info_cleanup(&info);\n  lodepng_free(data);\n  /*instead of cleaning the vector up, give it to the output*/\n  *out = outv.data;\n  *outsize = outv.size;\n\n  return state->error;\n}\n\nunsigned lodepng_encode_memory(unsigned char** out, size_t* outsize, const unsigned char* image,\n                               unsigned w, unsigned h, LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned error;\n  LodePNGState state;\n  lodepng_state_init(&state);\n  state.info_raw.colortype = colortype;\n  state.info_raw.bitdepth = bitdepth;\n  state.info_png.color.colortype = colortype;\n  state.info_png.color.bitdepth = bitdepth;\n  lodepng_encode(out, outsize, image, w, h, &state);\n  error = state.error;\n  lodepng_state_cleanup(&state);\n  return error;\n}\n\nunsigned lodepng_encode32(unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h)\n{\n  return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGBA, 8);\n}\n\nunsigned lodepng_encode24(unsigned char** out, size_t* outsize, const unsigned char* image, unsigned w, unsigned h)\n{\n  return lodepng_encode_memory(out, outsize, image, w, h, LCT_RGB, 8);\n}\n\n#ifdef LODEPNG_COMPILE_DISK\nunsigned lodepng_encode_file(const char* filename, const unsigned char* image, unsigned w, unsigned h,\n                             LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned char* buffer;\n  size_t buffersize;\n  unsigned error = lodepng_encode_memory(&buffer, &buffersize, image, w, h, colortype, bitdepth);\n  if(!error) error = lodepng_save_file(buffer, buffersize, filename);\n  lodepng_free(buffer);\n  return error;\n}\n\nunsigned lodepng_encode32_file(const char* filename, const unsigned char* image, unsigned w, unsigned h)\n{\n  return lodepng_encode_file(filename, image, w, h, LCT_RGBA, 8);\n}\n\nunsigned lodepng_encode24_file(const char* filename, const unsigned char* image, unsigned w, unsigned h)\n{\n  return lodepng_encode_file(filename, image, w, h, LCT_RGB, 8);\n}\n#endif /*LODEPNG_COMPILE_DISK*/\n\nvoid lodepng_encoder_settings_init(LodePNGEncoderSettings* settings)\n{\n  lodepng_compress_settings_init(&settings->zlibsettings);\n  settings->filter_palette_zero = 1;\n  settings->filter_strategy = LFS_MINSUM;\n  settings->auto_convert = LAC_AUTO;\n  settings->force_palette = 0;\n  settings->predefined_filters = 0;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  settings->add_id = 0;\n  settings->text_compression = 1;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n}\n\n#endif /*LODEPNG_COMPILE_ENCODER*/\n#endif /*LODEPNG_COMPILE_PNG*/\n\n#ifdef LODEPNG_COMPILE_ERROR_TEXT\n/*\nThis returns the description of a numerical error code in English. This is also\nthe documentation of all the error codes.\n*/\nconst char* lodepng_error_text(unsigned code)\n{\n  switch(code)\n  {\n    case 0: return \"no error, everything went ok\";\n    case 1: return \"nothing done yet\"; /*the Encoder/Decoder has done nothing yet, error checking makes no sense yet*/\n    case 10: return \"end of input memory reached without huffman end code\"; /*while huffman decoding*/\n    case 11: return \"error in code tree made it jump outside of huffman tree\"; /*while huffman decoding*/\n    case 13: return \"problem while processing dynamic deflate block\";\n    case 14: return \"problem while processing dynamic deflate block\";\n    case 15: return \"problem while processing dynamic deflate block\";\n    case 16: return \"unexisting code while processing dynamic deflate block\";\n    case 17: return \"end of out buffer memory reached while inflating\";\n    case 18: return \"invalid distance code while inflating\";\n    case 19: return \"end of out buffer memory reached while inflating\";\n    case 20: return \"invalid deflate block BTYPE encountered while decoding\";\n    case 21: return \"NLEN is not ones complement of LEN in a deflate block\";\n     /*end of out buffer memory reached while inflating:\n     This can happen if the inflated deflate data is longer than the amount of bytes required to fill up\n     all the pixels of the image, given the color depth and image dimensions. Something that doesn't\n     happen in a normal, well encoded, PNG image.*/\n    case 22: return \"end of out buffer memory reached while inflating\";\n    case 23: return \"end of in buffer memory reached while inflating\";\n    case 24: return \"invalid FCHECK in zlib header\";\n    case 25: return \"invalid compression method in zlib header\";\n    case 26: return \"FDICT encountered in zlib header while it's not used for PNG\";\n    case 27: return \"PNG file is smaller than a PNG header\";\n    /*Checks the magic file header, the first 8 bytes of the PNG file*/\n    case 28: return \"incorrect PNG signature, it's no PNG or corrupted\";\n    case 29: return \"first chunk is not the header chunk\";\n    case 30: return \"chunk length too large, chunk broken off at end of file\";\n    case 31: return \"illegal PNG color type or bpp\";\n    case 32: return \"illegal PNG compression method\";\n    case 33: return \"illegal PNG filter method\";\n    case 34: return \"illegal PNG interlace method\";\n    case 35: return \"chunk length of a chunk is too large or the chunk too small\";\n    case 36: return \"illegal PNG filter type encountered\";\n    case 37: return \"illegal bit depth for this color type given\";\n    case 38: return \"the palette is too big\"; /*more than 256 colors*/\n    case 39: return \"more palette alpha values given in tRNS chunk than there are colors in the palette\";\n    case 40: return \"tRNS chunk has wrong size for greyscale image\";\n    case 41: return \"tRNS chunk has wrong size for RGB image\";\n    case 42: return \"tRNS chunk appeared while it was not allowed for this color type\";\n    case 43: return \"bKGD chunk has wrong size for palette image\";\n    case 44: return \"bKGD chunk has wrong size for greyscale image\";\n    case 45: return \"bKGD chunk has wrong size for RGB image\";\n    /*Is the palette too small?*/\n    case 46: return \"a value in indexed image is larger than the palette size (bitdepth = 8)\";\n    /*Is the palette too small?*/\n    case 47: return \"a value in indexed image is larger than the palette size (bitdepth < 8)\";\n    /*the input data is empty, maybe a PNG file doesn't exist or is in the wrong path*/\n    case 48: return \"empty input or file doesn't exist\";\n    case 49: return \"jumped past memory while generating dynamic huffman tree\";\n    case 50: return \"jumped past memory while generating dynamic huffman tree\";\n    case 51: return \"jumped past memory while inflating huffman block\";\n    case 52: return \"jumped past memory while inflating\";\n    case 53: return \"size of zlib data too small\";\n    case 54: return \"repeat symbol in tree while there was no value symbol yet\";\n    /*jumped past tree while generating huffman tree, this could be when the\n    tree will have more leaves than symbols after generating it out of the\n    given lenghts. They call this an oversubscribed dynamic bit lengths tree in zlib.*/\n    case 55: return \"jumped past tree while generating huffman tree\";\n    case 56: return \"given output image colortype or bitdepth not supported for color conversion\";\n    case 57: return \"invalid CRC encountered (checking CRC can be disabled)\";\n    case 58: return \"invalid ADLER32 encountered (checking ADLER32 can be disabled)\";\n    case 59: return \"requested color conversion not supported\";\n    case 60: return \"invalid window size given in the settings of the encoder (must be 0-32768)\";\n    case 61: return \"invalid BTYPE given in the settings of the encoder (only 0, 1 and 2 are allowed)\";\n    /*LodePNG leaves the choice of RGB to greyscale conversion formula to the user.*/\n    case 62: return \"conversion from color to greyscale not supported\";\n    case 63: return \"length of a chunk too long, max allowed for PNG is 2147483647 bytes per chunk\"; /*(2^31-1)*/\n    /*this would result in the inability of a deflated block to ever contain an end code. It must be at least 1.*/\n    case 64: return \"the length of the END symbol 256 in the Huffman tree is 0\";\n    case 66: return \"the length of a text chunk keyword given to the encoder is longer than the maximum of 79 bytes\";\n    case 67: return \"the length of a text chunk keyword given to the encoder is smaller than the minimum of 1 byte\";\n    case 68: return \"tried to encode a PLTE chunk with a palette that has less than 1 or more than 256 colors\";\n    case 69: return \"unknown chunk type with 'critical' flag encountered by the decoder\";\n    case 71: return \"unexisting interlace mode given to encoder (must be 0 or 1)\";\n    case 72: return \"while decoding, unexisting compression method encountering in zTXt or iTXt chunk (it must be 0)\";\n    case 73: return \"invalid tIME chunk size\";\n    case 74: return \"invalid pHYs chunk size\";\n    /*length could be wrong, or data chopped off*/\n    case 75: return \"no null termination char found while decoding text chunk\";\n    case 76: return \"iTXt chunk too short to contain required bytes\";\n    case 77: return \"integer overflow in buffer size\";\n    case 78: return \"failed to open file for reading\"; /*file doesn't exist or couldn't be opened for reading*/\n    case 79: return \"failed to open file for writing\";\n    case 80: return \"tried creating a tree of 0 symbols\";\n    case 81: return \"lazy matching at pos 0 is impossible\";\n    case 82: return \"color conversion to palette requested while a color isn't in palette\";\n    case 83: return \"memory allocation failed\";\n    case 84: return \"given image too small to contain all pixels to be encoded\";\n    case 85: return \"internal color conversion bug\";\n    case 86: return \"impossible offset in lz77 encoding (internal bug)\";\n    case 87: return \"must provide custom zlib function pointer if LODEPNG_COMPILE_ZLIB is not defined\";\n    case 88: return \"invalid filter strategy given for LodePNGEncoderSettings.filter_strategy\";\n    case 89: return \"text chunk keyword too short or long: must have size 1-79\";\n  }\n  return \"unknown error code\";\n}\n#endif /*LODEPNG_COMPILE_ERROR_TEXT*/\n\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* // C++ Wrapper                                                          // */\n/* ////////////////////////////////////////////////////////////////////////// */\n/* ////////////////////////////////////////////////////////////////////////// */\n\n\n#ifdef LODEPNG_COMPILE_CPP\nnamespace lodepng\n{\n\n#ifdef LODEPNG_COMPILE_DISK\nvoid load_file(std::vector<unsigned char>& buffer, const std::string& filename)\n{\n  std::ifstream file(filename.c_str(), std::ios::in|std::ios::binary|std::ios::ate);\n\n  /*get filesize*/\n  std::streamsize size = 0;\n  if(file.seekg(0, std::ios::end).good()) size = file.tellg();\n  if(file.seekg(0, std::ios::beg).good()) size -= file.tellg();\n\n  /*read contents of the file into the vector*/\n  buffer.resize(size_t(size));\n  if(size > 0) file.read((char*)(&buffer[0]), size);\n}\n\n/*write given buffer to the file, overwriting the file, it doesn't append to it.*/\nvoid save_file(const std::vector<unsigned char>& buffer, const std::string& filename)\n{\n  std::ofstream file(filename.c_str(), std::ios::out|std::ios::binary);\n  file.write(buffer.empty() ? 0 : (char*)&buffer[0], std::streamsize(buffer.size()));\n}\n#endif //LODEPNG_COMPILE_DISK\n\n#ifdef LODEPNG_COMPILE_ZLIB\n#ifdef LODEPNG_COMPILE_DECODER\nunsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,\n                    const LodePNGDecompressSettings& settings)\n{\n  unsigned char* buffer = 0;\n  size_t buffersize = 0;\n  unsigned error = zlib_decompress(&buffer, &buffersize, in, insize, &settings);\n  if(buffer)\n  {\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,\n                    const LodePNGDecompressSettings& settings)\n{\n  return decompress(out, in.empty() ? 0 : &in[0], in.size(), settings);\n}\n#endif //LODEPNG_COMPILE_DECODER\n\n#ifdef LODEPNG_COMPILE_ENCODER\nunsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,\n                  const LodePNGCompressSettings& settings)\n{\n  unsigned char* buffer = 0;\n  size_t buffersize = 0;\n  unsigned error = zlib_compress(&buffer, &buffersize, in, insize, &settings);\n  if(buffer)\n  {\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,\n                  const LodePNGCompressSettings& settings)\n{\n  return compress(out, in.empty() ? 0 : &in[0], in.size(), settings);\n}\n#endif //LODEPNG_COMPILE_ENCODER\n#endif //LODEPNG_COMPILE_ZLIB\n\n\n#ifdef LODEPNG_COMPILE_PNG\n\nState::State()\n{\n  lodepng_state_init(this);\n}\n\nState::State(const State& other)\n{\n  lodepng_state_init(this);\n  lodepng_state_copy(this, &other);\n}\n\nState::~State()\n{\n  lodepng_state_cleanup(this);\n}\n\nState& State::operator=(const State& other)\n{\n  lodepng_state_copy(this, &other);\n  return *this;\n}\n\n#ifdef LODEPNG_COMPILE_DECODER\n\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const unsigned char* in,\n                size_t insize, LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned char* buffer;\n  unsigned error = lodepng_decode_memory(&buffer, &w, &h, in, insize, colortype, bitdepth);\n  if(buffer && !error)\n  {\n    State state;\n    state.info_raw.colortype = colortype;\n    state.info_raw.bitdepth = bitdepth;\n    size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                const std::vector<unsigned char>& in, LodePNGColorType colortype, unsigned bitdepth)\n{\n  return decode(out, w, h, in.empty() ? 0 : &in[0], (unsigned)in.size(), colortype, bitdepth);\n}\n\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                State& state,\n                const unsigned char* in, size_t insize)\n{\n  unsigned char* buffer;\n  unsigned error = lodepng_decode(&buffer, &w, &h, &state, in, insize);\n  if(buffer && !error)\n  {\n    size_t buffersize = lodepng_get_raw_size(w, h, &state.info_raw);\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                State& state,\n                const std::vector<unsigned char>& in)\n{\n  return decode(out, w, h, state, in.empty() ? 0 : &in[0], in.size());\n}\n\n#ifdef LODEPNG_COMPILE_DISK\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h, const std::string& filename,\n                LodePNGColorType colortype, unsigned bitdepth)\n{\n  std::vector<unsigned char> buffer;\n  load_file(buffer, filename);\n  return decode(out, w, h, buffer, colortype, bitdepth);\n}\n#endif //LODEPNG_COMPILE_DECODER\n#endif //LODEPNG_COMPILE_DISK\n\n#ifdef LODEPNG_COMPILE_ENCODER\nunsigned encode(std::vector<unsigned char>& out, const unsigned char* in, unsigned w, unsigned h,\n                LodePNGColorType colortype, unsigned bitdepth)\n{\n  unsigned char* buffer;\n  size_t buffersize;\n  unsigned error = lodepng_encode_memory(&buffer, &buffersize, in, w, h, colortype, bitdepth);\n  if(buffer)\n  {\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned encode(std::vector<unsigned char>& out,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                LodePNGColorType colortype, unsigned bitdepth)\n{\n  if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;\n  return encode(out, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);\n}\n\nunsigned encode(std::vector<unsigned char>& out,\n                const unsigned char* in, unsigned w, unsigned h,\n                State& state)\n{\n  unsigned char* buffer;\n  size_t buffersize;\n  unsigned error = lodepng_encode(&buffer, &buffersize, in, w, h, &state);\n  if(buffer)\n  {\n    out.insert(out.end(), &buffer[0], &buffer[buffersize]);\n    lodepng_free(buffer);\n  }\n  return error;\n}\n\nunsigned encode(std::vector<unsigned char>& out,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                State& state)\n{\n  if(lodepng_get_raw_size(w, h, &state.info_raw) > in.size()) return 84;\n  return encode(out, in.empty() ? 0 : &in[0], w, h, state);\n}\n\n#ifdef LODEPNG_COMPILE_DISK\nunsigned encode(const std::string& filename,\n                const unsigned char* in, unsigned w, unsigned h,\n                LodePNGColorType colortype, unsigned bitdepth)\n{\n  std::vector<unsigned char> buffer;\n  unsigned error = encode(buffer, in, w, h, colortype, bitdepth);\n  if(!error) save_file(buffer, filename);\n  return error;\n}\n\nunsigned encode(const std::string& filename,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                LodePNGColorType colortype, unsigned bitdepth)\n{\n  if(lodepng_get_raw_size_lct(w, h, colortype, bitdepth) > in.size()) return 84;\n  return encode(filename, in.empty() ? 0 : &in[0], w, h, colortype, bitdepth);\n}\n#endif //LODEPNG_COMPILE_DISK\n#endif //LODEPNG_COMPILE_ENCODER\n#endif //LODEPNG_COMPILE_PNG\n} //namespace lodepng\n#endif /*LODEPNG_COMPILE_CPP*/\n"
  },
  {
    "path": "deps/lodepng/lodepng.h",
    "content": "/*\nLodePNG version 20131115\n\nCopyright (c) 2005-2013 Lode Vandevenne\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n#ifndef LODEPNG_H\n#define LODEPNG_H\n\n#include <string.h> /*for size_t*/\n\n#ifdef __cplusplus\n#include <vector>\n#include <string>\n#endif /*__cplusplus*/\n\n/*\nThe following #defines are used to create code sections. They can be disabled\nto disable code sections, which can give faster compile time and smaller binary.\nThe \"NO_COMPILE\" defines are designed to be used to pass as defines to the\ncompiler command to disable them without modifying this header, e.g.\n-DLODEPNG_NO_COMPILE_ZLIB for gcc.\n*/\n/*deflate & zlib. If disabled, you must specify alternative zlib functions in\nthe custom_zlib field of the compress and decompress settings*/\n#ifndef LODEPNG_NO_COMPILE_ZLIB\n#define LODEPNG_COMPILE_ZLIB\n#endif\n/*png encoder and png decoder*/\n#ifndef LODEPNG_NO_COMPILE_PNG\n#define LODEPNG_COMPILE_PNG\n#endif\n/*deflate&zlib decoder and png decoder*/\n#ifndef LODEPNG_NO_COMPILE_DECODER\n#define LODEPNG_COMPILE_DECODER\n#endif\n/*deflate&zlib encoder and png encoder*/\n#ifndef LODEPNG_NO_COMPILE_ENCODER\n#define LODEPNG_COMPILE_ENCODER\n#endif\n/*the optional built in harddisk file loading and saving functions*/\n#ifndef LODEPNG_NO_COMPILE_DISK\n#define LODEPNG_COMPILE_DISK\n#endif\n/*support for chunks other than IHDR, IDAT, PLTE, tRNS, IEND: ancillary and unknown chunks*/\n#ifndef LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS\n#define LODEPNG_COMPILE_ANCILLARY_CHUNKS\n#endif\n/*ability to convert error numerical codes to English text string*/\n#ifndef LODEPNG_NO_COMPILE_ERROR_TEXT\n#define LODEPNG_COMPILE_ERROR_TEXT\n#endif\n/*Compile the default allocators (C's free, malloc and realloc). If you disable this,\nyou can define the functions lodepng_free, lodepng_malloc and lodepng_realloc in your\nsource files with custom allocators.*/\n#ifndef LODEPNG_NO_COMPILE_ALLOCATORS\n#define LODEPNG_COMPILE_ALLOCATORS\n#endif\n/*compile the C++ version (you can disable the C++ wrapper here even when compiling for C++)*/\n#ifdef __cplusplus\n#ifndef LODEPNG_NO_COMPILE_CPP\n#define LODEPNG_COMPILE_CPP\n#endif\n#endif\n\n#ifdef LODEPNG_COMPILE_PNG\n/*The PNG color types (also used for raw).*/\ntypedef enum LodePNGColorType\n{\n  LCT_GREY = 0, /*greyscale: 1,2,4,8,16 bit*/\n  LCT_RGB = 2, /*RGB: 8,16 bit*/\n  LCT_PALETTE = 3, /*palette: 1,2,4,8 bit*/\n  LCT_GREY_ALPHA = 4, /*greyscale with alpha: 8,16 bit*/\n  LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/\n} LodePNGColorType;\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*\nConverts PNG data in memory to raw pixel data.\nout: Output parameter. Pointer to buffer that will contain the raw pixel data.\n     After decoding, its size is w * h * (bytes per pixel) bytes larger than\n     initially. Bytes per pixel depends on colortype and bitdepth.\n     Must be freed after usage with free(*out).\n     Note: for 16-bit per channel colors, uses big endian format like PNG does.\nw: Output parameter. Pointer to width of pixel data.\nh: Output parameter. Pointer to height of pixel data.\nin: Memory buffer with the PNG file.\ninsize: size of the in buffer.\ncolortype: the desired color type for the raw output image. See explanation on PNG color types.\nbitdepth: the desired bit depth for the raw output image. See explanation on PNG color types.\nReturn value: LodePNG error code (0 means no error).\n*/\nunsigned lodepng_decode_memory(unsigned char** out, unsigned* w, unsigned* h,\n                               const unsigned char* in, size_t insize,\n                               LodePNGColorType colortype, unsigned bitdepth);\n\n/*Same as lodepng_decode_memory, but always decodes to 32-bit RGBA raw image*/\nunsigned lodepng_decode32(unsigned char** out, unsigned* w, unsigned* h,\n                          const unsigned char* in, size_t insize);\n\n/*Same as lodepng_decode_memory, but always decodes to 24-bit RGB raw image*/\nunsigned lodepng_decode24(unsigned char** out, unsigned* w, unsigned* h,\n                          const unsigned char* in, size_t insize);\n\n#ifdef LODEPNG_COMPILE_DISK\n/*\nLoad PNG from disk, from file with given name.\nSame as the other decode functions, but instead takes a filename as input.\n*/\nunsigned lodepng_decode_file(unsigned char** out, unsigned* w, unsigned* h,\n                             const char* filename,\n                             LodePNGColorType colortype, unsigned bitdepth);\n\n/*Same as lodepng_decode_file, but always decodes to 32-bit RGBA raw image.*/\nunsigned lodepng_decode32_file(unsigned char** out, unsigned* w, unsigned* h,\n                               const char* filename);\n\n/*Same as lodepng_decode_file, but always decodes to 24-bit RGB raw image.*/\nunsigned lodepng_decode24_file(unsigned char** out, unsigned* w, unsigned* h,\n                               const char* filename);\n#endif /*LODEPNG_COMPILE_DISK*/\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*\nConverts raw pixel data into a PNG image in memory. The colortype and bitdepth\n  of the output PNG image cannot be chosen, they are automatically determined\n  by the colortype, bitdepth and content of the input pixel data.\n  Note: for 16-bit per channel colors, needs big endian format like PNG does.\nout: Output parameter. Pointer to buffer that will contain the PNG image data.\n     Must be freed after usage with free(*out).\noutsize: Output parameter. Pointer to the size in bytes of the out buffer.\nimage: The raw pixel data to encode. The size of this buffer should be\n       w * h * (bytes per pixel), bytes per pixel depends on colortype and bitdepth.\nw: width of the raw pixel data in pixels.\nh: height of the raw pixel data in pixels.\ncolortype: the color type of the raw input image. See explanation on PNG color types.\nbitdepth: the bit depth of the raw input image. See explanation on PNG color types.\nReturn value: LodePNG error code (0 means no error).\n*/\nunsigned lodepng_encode_memory(unsigned char** out, size_t* outsize,\n                               const unsigned char* image, unsigned w, unsigned h,\n                               LodePNGColorType colortype, unsigned bitdepth);\n\n/*Same as lodepng_encode_memory, but always encodes from 32-bit RGBA raw image.*/\nunsigned lodepng_encode32(unsigned char** out, size_t* outsize,\n                          const unsigned char* image, unsigned w, unsigned h);\n\n/*Same as lodepng_encode_memory, but always encodes from 24-bit RGB raw image.*/\nunsigned lodepng_encode24(unsigned char** out, size_t* outsize,\n                          const unsigned char* image, unsigned w, unsigned h);\n\n#ifdef LODEPNG_COMPILE_DISK\n/*\nConverts raw pixel data into a PNG file on disk.\nSame as the other encode functions, but instead takes a filename as output.\nNOTE: This overwrites existing files without warning!\n*/\nunsigned lodepng_encode_file(const char* filename,\n                             const unsigned char* image, unsigned w, unsigned h,\n                             LodePNGColorType colortype, unsigned bitdepth);\n\n/*Same as lodepng_encode_file, but always encodes from 32-bit RGBA raw image.*/\nunsigned lodepng_encode32_file(const char* filename,\n                               const unsigned char* image, unsigned w, unsigned h);\n\n/*Same as lodepng_encode_file, but always encodes from 24-bit RGB raw image.*/\nunsigned lodepng_encode24_file(const char* filename,\n                               const unsigned char* image, unsigned w, unsigned h);\n#endif /*LODEPNG_COMPILE_DISK*/\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n\n#ifdef LODEPNG_COMPILE_CPP\nnamespace lodepng\n{\n#ifdef LODEPNG_COMPILE_DECODER\n/*Same as lodepng_decode_memory, but decodes to an std::vector.*/\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                const unsigned char* in, size_t insize,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                const std::vector<unsigned char>& in,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\n#ifdef LODEPNG_COMPILE_DISK\n/*\nConverts PNG file from disk to raw pixel data in memory.\nSame as the other decode functions, but instead takes a filename as input.\n*/\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                const std::string& filename,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\n#endif //LODEPNG_COMPILE_DISK\n#endif //LODEPNG_COMPILE_DECODER\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*Same as lodepng_encode_memory, but encodes to an std::vector.*/\nunsigned encode(std::vector<unsigned char>& out,\n                const unsigned char* in, unsigned w, unsigned h,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\nunsigned encode(std::vector<unsigned char>& out,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\n#ifdef LODEPNG_COMPILE_DISK\n/*\nConverts 32-bit RGBA raw pixel data into a PNG file on disk.\nSame as the other encode functions, but instead takes a filename as output.\nNOTE: This overwrites existing files without warning!\n*/\nunsigned encode(const std::string& filename,\n                const unsigned char* in, unsigned w, unsigned h,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\nunsigned encode(const std::string& filename,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                LodePNGColorType colortype = LCT_RGBA, unsigned bitdepth = 8);\n#endif //LODEPNG_COMPILE_DISK\n#endif //LODEPNG_COMPILE_ENCODER\n} //namespace lodepng\n#endif /*LODEPNG_COMPILE_CPP*/\n#endif /*LODEPNG_COMPILE_PNG*/\n\n#ifdef LODEPNG_COMPILE_ERROR_TEXT\n/*Returns an English description of the numerical error code.*/\nconst char* lodepng_error_text(unsigned code);\n#endif /*LODEPNG_COMPILE_ERROR_TEXT*/\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*Settings for zlib decompression*/\ntypedef struct LodePNGDecompressSettings LodePNGDecompressSettings;\nstruct LodePNGDecompressSettings\n{\n  unsigned ignore_adler32; /*if 1, continue and don't give an error message if the Adler32 checksum is corrupted*/\n\n  /*use custom zlib decoder instead of built in one (default: null)*/\n  unsigned (*custom_zlib)(unsigned char**, size_t*,\n                          const unsigned char*, size_t,\n                          const LodePNGDecompressSettings*);\n  /*use custom deflate decoder instead of built in one (default: null)\n  if custom_zlib is used, custom_deflate is ignored since only the built in\n  zlib function will call custom_deflate*/\n  unsigned (*custom_inflate)(unsigned char**, size_t*,\n                             const unsigned char*, size_t,\n                             const LodePNGDecompressSettings*);\n\n  void* custom_context; /*optional custom settings for custom functions*/\n};\n\nextern const LodePNGDecompressSettings lodepng_default_decompress_settings;\nvoid lodepng_decompress_settings_init(LodePNGDecompressSettings* settings);\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*\nSettings for zlib compression. Tweaking these settings tweaks the balance\nbetween speed and compression ratio.\n*/\ntypedef struct LodePNGCompressSettings LodePNGCompressSettings;\nstruct LodePNGCompressSettings /*deflate = compress*/\n{\n  /*LZ77 related settings*/\n  unsigned btype; /*the block type for LZ (0, 1, 2 or 3, see zlib standard). Should be 2 for proper compression.*/\n  unsigned use_lz77; /*whether or not to use LZ77. Should be 1 for proper compression.*/\n  unsigned windowsize; /*the maximum is 32768, higher gives more compression but is slower. Typical value: 2048.*/\n  unsigned minmatch; /*mininum lz77 length. 3 is normally best, 6 can be better for some PNGs. Default: 0*/\n  unsigned nicematch; /*stop searching if >= this length found. Set to 258 for best compression. Default: 128*/\n  unsigned lazymatching; /*use lazy matching: better compression but a bit slower. Default: true*/\n\n  /*use custom zlib encoder instead of built in one (default: null)*/\n  unsigned (*custom_zlib)(unsigned char**, size_t*,\n                          const unsigned char*, size_t,\n                          const LodePNGCompressSettings*);\n  /*use custom deflate encoder instead of built in one (default: null)\n  if custom_zlib is used, custom_deflate is ignored since only the built in\n  zlib function will call custom_deflate*/\n  unsigned (*custom_deflate)(unsigned char**, size_t*,\n                             const unsigned char*, size_t,\n                             const LodePNGCompressSettings*);\n\n  void* custom_context; /*optional custom settings for custom functions*/\n};\n\nextern const LodePNGCompressSettings lodepng_default_compress_settings;\nvoid lodepng_compress_settings_init(LodePNGCompressSettings* settings);\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#ifdef LODEPNG_COMPILE_PNG\n/*\nColor mode of an image. Contains all information required to decode the pixel\nbits to RGBA colors. This information is the same as used in the PNG file\nformat, and is used both for PNG and raw image data in LodePNG.\n*/\ntypedef struct LodePNGColorMode\n{\n  /*header (IHDR)*/\n  LodePNGColorType colortype; /*color type, see PNG standard or documentation further in this header file*/\n  unsigned bitdepth;  /*bits per sample, see PNG standard or documentation further in this header file*/\n\n  /*\n  palette (PLTE and tRNS)\n\n  Dynamically allocated with the colors of the palette, including alpha.\n  When encoding a PNG, to store your colors in the palette of the LodePNGColorMode, first use\n  lodepng_palette_clear, then for each color use lodepng_palette_add.\n  If you encode an image without alpha with palette, don't forget to put value 255 in each A byte of the palette.\n\n  When decoding, by default you can ignore this palette, since LodePNG already\n  fills the palette colors in the pixels of the raw RGBA output.\n\n  The palette is only supported for color type 3.\n  */\n  unsigned char* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/\n  size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/\n\n  /*\n  transparent color key (tRNS)\n\n  This color uses the same bit depth as the bitdepth value in this struct, which can be 1-bit to 16-bit.\n  For greyscale PNGs, r, g and b will all 3 be set to the same.\n\n  When decoding, by default you can ignore this information, since LodePNG sets\n  pixels with this key to transparent already in the raw RGBA output.\n\n  The color key is only supported for color types 0 and 2.\n  */\n  unsigned key_defined; /*is a transparent color key given? 0 = false, 1 = true*/\n  unsigned key_r;       /*red/greyscale component of color key*/\n  unsigned key_g;       /*green component of color key*/\n  unsigned key_b;       /*blue component of color key*/\n} LodePNGColorMode;\n\n/*init, cleanup and copy functions to use with this struct*/\nvoid lodepng_color_mode_init(LodePNGColorMode* info);\nvoid lodepng_color_mode_cleanup(LodePNGColorMode* info);\n/*return value is error code (0 means no error)*/\nunsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source);\n\nvoid lodepng_palette_clear(LodePNGColorMode* info);\n/*add 1 color to the palette*/\nunsigned lodepng_palette_add(LodePNGColorMode* info,\n                             unsigned char r, unsigned char g, unsigned char b, unsigned char a);\n\n/*get the total amount of bits per pixel, based on colortype and bitdepth in the struct*/\nunsigned lodepng_get_bpp(const LodePNGColorMode* info);\n/*get the amount of color channels used, based on colortype in the struct.\nIf a palette is used, it counts as 1 channel.*/\nunsigned lodepng_get_channels(const LodePNGColorMode* info);\n/*is it a greyscale type? (only colortype 0 or 4)*/\nunsigned lodepng_is_greyscale_type(const LodePNGColorMode* info);\n/*has it got an alpha channel? (only colortype 2 or 6)*/\nunsigned lodepng_is_alpha_type(const LodePNGColorMode* info);\n/*has it got a palette? (only colortype 3)*/\nunsigned lodepng_is_palette_type(const LodePNGColorMode* info);\n/*only returns true if there is a palette and there is a value in the palette with alpha < 255.\nLoops through the palette to check this.*/\nunsigned lodepng_has_palette_alpha(const LodePNGColorMode* info);\n/*\nCheck if the given color info indicates the possibility of having non-opaque pixels in the PNG image.\nReturns true if the image can have translucent or invisible pixels (it still be opaque if it doesn't use such pixels).\nReturns false if the image can only have opaque pixels.\nIn detail, it returns true only if it's a color type with alpha, or has a palette with non-opaque values,\nor if \"key_defined\" is true.\n*/\nunsigned lodepng_can_have_alpha(const LodePNGColorMode* info);\n/*Returns the byte size of a raw image buffer with given width, height and color mode*/\nsize_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* color);\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n/*The information of a Time chunk in PNG.*/\ntypedef struct LodePNGTime\n{\n  unsigned year;    /*2 bytes used (0-65535)*/\n  unsigned month;   /*1-12*/\n  unsigned day;     /*1-31*/\n  unsigned hour;    /*0-23*/\n  unsigned minute;  /*0-59*/\n  unsigned second;  /*0-60 (to allow for leap seconds)*/\n} LodePNGTime;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\n/*Information about the PNG image, except pixels, width and height.*/\ntypedef struct LodePNGInfo\n{\n  /*header (IHDR), palette (PLTE) and transparency (tRNS) chunks*/\n  unsigned compression_method;/*compression method of the original file. Always 0.*/\n  unsigned filter_method;     /*filter method of the original file*/\n  unsigned interlace_method;  /*interlace method of the original file*/\n  LodePNGColorMode color;     /*color type and bits, palette and transparency of the PNG file*/\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  /*\n  suggested background color chunk (bKGD)\n  This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit.\n\n  For greyscale PNGs, r, g and b will all 3 be set to the same. When encoding\n  the encoder writes the red one. For palette PNGs: When decoding, the RGB value\n  will be stored, not a palette index. But when encoding, specify the index of\n  the palette in background_r, the other two are then ignored.\n\n  The decoder does not use this background color to edit the color of pixels.\n  */\n  unsigned background_defined; /*is a suggested background color given?*/\n  unsigned background_r;       /*red component of suggested background color*/\n  unsigned background_g;       /*green component of suggested background color*/\n  unsigned background_b;       /*blue component of suggested background color*/\n\n  /*\n  non-international text chunks (tEXt and zTXt)\n\n  The char** arrays each contain num strings. The actual messages are in\n  text_strings, while text_keys are keywords that give a short description what\n  the actual text represents, e.g. Title, Author, Description, or anything else.\n\n  A keyword is minimum 1 character and maximum 79 characters long. It's\n  discouraged to use a single line length longer than 79 characters for texts.\n\n  Don't allocate these text buffers yourself. Use the init/cleanup functions\n  correctly and use lodepng_add_text and lodepng_clear_text.\n  */\n  size_t text_num; /*the amount of texts in these char** buffers (there may be more texts in itext)*/\n  char** text_keys; /*the keyword of a text chunk (e.g. \"Comment\")*/\n  char** text_strings; /*the actual text*/\n\n  /*\n  international text chunks (iTXt)\n  Similar to the non-international text chunks, but with additional strings\n  \"langtags\" and \"transkeys\".\n  */\n  size_t itext_num; /*the amount of international texts in this PNG*/\n  char** itext_keys; /*the English keyword of the text chunk (e.g. \"Comment\")*/\n  char** itext_langtags; /*language tag for this text's language, ISO/IEC 646 string, e.g. ISO 639 language tag*/\n  char** itext_transkeys; /*keyword translated to the international language - UTF-8 string*/\n  char** itext_strings; /*the actual international text - UTF-8 string*/\n\n  /*time chunk (tIME)*/\n  unsigned time_defined; /*set to 1 to make the encoder generate a tIME chunk*/\n  LodePNGTime time;\n\n  /*phys chunk (pHYs)*/\n  unsigned phys_defined; /*if 0, there is no pHYs chunk and the values below are undefined, if 1 else there is one*/\n  unsigned phys_x; /*pixels per unit in x direction*/\n  unsigned phys_y; /*pixels per unit in y direction*/\n  unsigned phys_unit; /*may be 0 (unknown unit) or 1 (metre)*/\n\n  /*\n  unknown chunks\n  There are 3 buffers, one for each position in the PNG where unknown chunks can appear\n  each buffer contains all unknown chunks for that position consecutively\n  The 3 buffers are the unknown chunks between certain critical chunks:\n  0: IHDR-PLTE, 1: PLTE-IDAT, 2: IDAT-IEND\n  Do not allocate or traverse this data yourself. Use the chunk traversing functions declared\n  later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.\n  */\n  unsigned char* unknown_chunks_data[3];\n  size_t unknown_chunks_size[3]; /*size in bytes of the unknown chunks, given for protection*/\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n} LodePNGInfo;\n\n/*init, cleanup and copy functions to use with this struct*/\nvoid lodepng_info_init(LodePNGInfo* info);\nvoid lodepng_info_cleanup(LodePNGInfo* info);\n/*return value is error code (0 means no error)*/\nunsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source);\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\nvoid lodepng_clear_text(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/\nunsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str); /*push back both texts at once*/\n\nvoid lodepng_clear_itext(LodePNGInfo* info); /*use this to clear the itexts again after you filled them in*/\nunsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag,\n                           const char* transkey, const char* str); /*push back the 4 texts of 1 chunk at once*/\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n\n/*\nConverts raw buffer from one color type to another color type, based on\nLodePNGColorMode structs to describe the input and output color type.\nSee the reference manual at the end of this header file to see which color conversions are supported.\nreturn value = LodePNG error code (0 if all went ok, an error if the conversion isn't supported)\nThe out buffer must have size (w * h * bpp + 7) / 8, where bpp is the bits per pixel\nof the output color type (lodepng_get_bpp)\nThe fix_png value works as described in struct LodePNGDecoderSettings.\nNote: for 16-bit per channel colors, uses big endian format like PNG does.\n*/\nunsigned lodepng_convert(unsigned char* out, const unsigned char* in,\n                         LodePNGColorMode* mode_out, const LodePNGColorMode* mode_in,\n                         unsigned w, unsigned h, unsigned fix_png);\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*\nSettings for the decoder. This contains settings for the PNG and the Zlib\ndecoder, but not the Info settings from the Info structs.\n*/\ntypedef struct LodePNGDecoderSettings\n{\n  LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/\n\n  unsigned ignore_crc; /*ignore CRC checksums*/\n  /*\n  The fix_png setting, if 1, makes the decoder tolerant towards some PNG images\n  that do not correctly follow the PNG specification. This only supports errors\n  that are fixable, were found in images that are actually used on the web, and\n  are silently tolerated by other decoders as well. Currently only one such fix\n  is implemented: if a palette index is out of bounds given the palette size,\n  interpret it as opaque black.\n  By default this value is 0, which makes it stop with an error on such images.\n  */\n  unsigned fix_png;\n  unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/\n\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  unsigned read_text_chunks; /*if false but remember_unknown_chunks is true, they're stored in the unknown chunks*/\n  /*store all bytes from unknown chunks in the LodePNGInfo (off by default, useful for a png editor)*/\n  unsigned remember_unknown_chunks;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n} LodePNGDecoderSettings;\n\nvoid lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*automatically use color type with less bits per pixel if losslessly possible. Default: AUTO*/\ntypedef enum LodePNGFilterStrategy\n{\n  /*every filter at zero*/\n  LFS_ZERO,\n  /*Use filter that gives minumum sum, as described in the official PNG filter heuristic.*/\n  LFS_MINSUM,\n  /*Use the filter type that gives smallest Shannon entropy for this scanline. Depending\n  on the image, this is better or worse than minsum.*/\n  LFS_ENTROPY,\n  /*\n  Brute-force-search PNG filters by compressing each filter for each scanline.\n  Experimental, very slow, and only rarely gives better compression than MINSUM.\n  */\n  LFS_BRUTE_FORCE,\n  /*use predefined_filters buffer: you specify the filter type for each scanline*/\n  LFS_PREDEFINED\n} LodePNGFilterStrategy;\n\n/*automatically use color type with less bits per pixel if losslessly possible. Default: LAC_AUTO*/\ntypedef enum LodePNGAutoConvert\n{\n  LAC_NO, /*use color type user requested*/\n  LAC_ALPHA, /*use color type user requested, but if only opaque pixels and RGBA or grey+alpha, use RGB or grey*/\n  LAC_AUTO, /*use PNG color type that can losslessly represent the uncompressed image the smallest possible*/\n  /*\n  like AUTO, but do not choose 1, 2 or 4 bit per pixel types.\n  sometimes a PNG image compresses worse if less than 8 bits per pixels.\n  */\n  LAC_AUTO_NO_NIBBLES,\n  /*\n  like AUTO, but never choose palette color type. For small images, encoding\n  the palette may take more bytes than what is gained. Note that AUTO also\n  already prevents encoding the palette for extremely small images, but that may\n  not be sufficient because due to the compression it cannot predict when to\n  switch.\n  */\n  LAC_AUTO_NO_PALETTE,\n  LAC_AUTO_NO_NIBBLES_NO_PALETTE\n} LodePNGAutoConvert;\n\n\n/*\nAutomatically chooses color type that gives smallest amount of bits in the\noutput image, e.g. grey if there are only greyscale pixels, palette if there\nare less than 256 colors, ...\nThe auto_convert parameter allows limiting it to not use palette, ...\n*/\nunsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,\n                                   const unsigned char* image, unsigned w, unsigned h,\n                                   const LodePNGColorMode* mode_in,\n                                   LodePNGAutoConvert auto_convert);\n\n/*Settings for the encoder.*/\ntypedef struct LodePNGEncoderSettings\n{\n  LodePNGCompressSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/\n\n  LodePNGAutoConvert auto_convert; /*how to automatically choose output PNG color type, if at all*/\n\n  /*If true, follows the official PNG heuristic: if the PNG uses a palette or lower than\n  8 bit depth, set all filters to zero. Otherwise use the filter_strategy. Note that to\n  completely follow the official PNG heuristic, filter_palette_zero must be true and\n  filter_strategy must be LFS_MINSUM*/\n  unsigned filter_palette_zero;\n  /*Which filter strategy to use when not using zeroes due to filter_palette_zero.\n  Set filter_palette_zero to 0 to ensure always using your chosen strategy. Default: LFS_MINSUM*/\n  LodePNGFilterStrategy filter_strategy;\n  /*used if filter_strategy is LFS_PREDEFINED. In that case, this must point to a buffer with\n  the same length as the amount of scanlines in the image, and each value must <= 5. You\n  have to cleanup this buffer, LodePNG will never free it. Don't forget that filter_palette_zero\n  must be set to 0 to ensure this is also used on palette or low bitdepth images.*/\n  unsigned char* predefined_filters;\n\n  /*force creating a PLTE chunk if colortype is 2 or 6 (= a suggested palette).\n  If colortype is 3, PLTE is _always_ created.*/\n  unsigned force_palette;\n#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS\n  /*add LodePNG identifier and version as a text chunk, for debugging*/\n  unsigned add_id;\n  /*encode text chunks as zTXt chunks instead of tEXt chunks, and use compression in iTXt chunks*/\n  unsigned text_compression;\n#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/\n} LodePNGEncoderSettings;\n\nvoid lodepng_encoder_settings_init(LodePNGEncoderSettings* settings);\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n\n#if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER)\n/*The settings, state and information for extended encoding and decoding.*/\ntypedef struct LodePNGState\n{\n#ifdef LODEPNG_COMPILE_DECODER\n  LodePNGDecoderSettings decoder; /*the decoding settings*/\n#endif /*LODEPNG_COMPILE_DECODER*/\n#ifdef LODEPNG_COMPILE_ENCODER\n  LodePNGEncoderSettings encoder; /*the encoding settings*/\n#endif /*LODEPNG_COMPILE_ENCODER*/\n  LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/\n  LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/\n  unsigned error;\n#ifdef LODEPNG_COMPILE_CPP\n  //For the lodepng::State subclass.\n  virtual ~LodePNGState(){}\n#endif\n} LodePNGState;\n\n/*init, cleanup and copy functions to use with this struct*/\nvoid lodepng_state_init(LodePNGState* state);\nvoid lodepng_state_cleanup(LodePNGState* state);\nvoid lodepng_state_copy(LodePNGState* dest, const LodePNGState* source);\n#endif /* defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER) */\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*\nSame as lodepng_decode_memory, but uses a LodePNGState to allow custom settings and\ngetting much more information about the PNG image and color mode.\n*/\nunsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,\n                        LodePNGState* state,\n                        const unsigned char* in, size_t insize);\n\n/*\nRead the PNG header, but not the actual data. This returns only the information\nthat is in the header chunk of the PNG, such as width, height and color type. The\ninformation is placed in the info_png field of the LodePNGState.\n*/\nunsigned lodepng_inspect(unsigned* w, unsigned* h,\n                         LodePNGState* state,\n                         const unsigned char* in, size_t insize);\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/\nunsigned lodepng_encode(unsigned char** out, size_t* outsize,\n                        const unsigned char* image, unsigned w, unsigned h,\n                        LodePNGState* state);\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n/*\nThe lodepng_chunk functions are normally not needed, except to traverse the\nunknown chunks stored in the LodePNGInfo struct, or add new ones to it.\nIt also allows traversing the chunks of an encoded PNG file yourself.\n\nPNG standard chunk naming conventions:\nFirst byte: uppercase = critical, lowercase = ancillary\nSecond byte: uppercase = public, lowercase = private\nThird byte: must be uppercase\nFourth byte: uppercase = unsafe to copy, lowercase = safe to copy\n*/\n\n/*get the length of the data of the chunk. Total chunk length has 12 bytes more.*/\nunsigned lodepng_chunk_length(const unsigned char* chunk);\n\n/*puts the 4-byte type in null terminated string*/\nvoid lodepng_chunk_type(char type[5], const unsigned char* chunk);\n\n/*check if the type is the given type*/\nunsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type);\n\n/*0: it's one of the critical chunk types, 1: it's an ancillary chunk (see PNG standard)*/\nunsigned char lodepng_chunk_ancillary(const unsigned char* chunk);\n\n/*0: public, 1: private (see PNG standard)*/\nunsigned char lodepng_chunk_private(const unsigned char* chunk);\n\n/*0: the chunk is unsafe to copy, 1: the chunk is safe to copy (see PNG standard)*/\nunsigned char lodepng_chunk_safetocopy(const unsigned char* chunk);\n\n/*get pointer to the data of the chunk, where the input points to the header of the chunk*/\nunsigned char* lodepng_chunk_data(unsigned char* chunk);\nconst unsigned char* lodepng_chunk_data_const(const unsigned char* chunk);\n\n/*returns 0 if the crc is correct, 1 if it's incorrect (0 for OK as usual!)*/\nunsigned lodepng_chunk_check_crc(const unsigned char* chunk);\n\n/*generates the correct CRC from the data and puts it in the last 4 bytes of the chunk*/\nvoid lodepng_chunk_generate_crc(unsigned char* chunk);\n\n/*iterate to next chunks. don't use on IEND chunk, as there is no next chunk then*/\nunsigned char* lodepng_chunk_next(unsigned char* chunk);\nconst unsigned char* lodepng_chunk_next_const(const unsigned char* chunk);\n\n/*\nAppends chunk to the data in out. The given chunk should already have its chunk header.\nThe out variable and outlength are updated to reflect the new reallocated buffer.\nReturns error code (0 if it went ok)\n*/\nunsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk);\n\n/*\nAppends new chunk to out. The chunk to append is given by giving its length, type\nand data separately. The type is a 4-letter string.\nThe out variable and outlength are updated to reflect the new reallocated buffer.\nReturne error code (0 if it went ok)\n*/\nunsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,\n                              const char* type, const unsigned char* data);\n\n\n/*Calculate CRC32 of buffer*/\nunsigned lodepng_crc32(const unsigned char* buf, size_t len);\n#endif /*LODEPNG_COMPILE_PNG*/\n\n\n#ifdef LODEPNG_COMPILE_ZLIB\n/*\nThis zlib part can be used independently to zlib compress and decompress a\nbuffer. It cannot be used to create gzip files however, and it only supports the\npart of zlib that is required for PNG, it does not support dictionaries.\n*/\n\n#ifdef LODEPNG_COMPILE_DECODER\n/*Inflate a buffer. Inflate is the decompression step of deflate. Out buffer must be freed after use.*/\nunsigned lodepng_inflate(unsigned char** out, size_t* outsize,\n                         const unsigned char* in, size_t insize,\n                         const LodePNGDecompressSettings* settings);\n\n/*\nDecompresses Zlib data. Reallocates the out buffer and appends the data. The\ndata must be according to the zlib specification.\nEither, *out must be NULL and *outsize must be 0, or, *out must be a valid\nbuffer and *outsize its size in bytes. out must be freed by user after usage.\n*/\nunsigned lodepng_zlib_decompress(unsigned char** out, size_t* outsize,\n                                 const unsigned char* in, size_t insize,\n                                 const LodePNGDecompressSettings* settings);\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n/*\nCompresses data with Zlib. Reallocates the out buffer and appends the data.\nZlib adds a small header and trailer around the deflate data.\nThe data is output in the format of the zlib specification.\nEither, *out must be NULL and *outsize must be 0, or, *out must be a valid\nbuffer and *outsize its size in bytes. out must be freed by user after usage.\n*/\nunsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize,\n                               const unsigned char* in, size_t insize,\n                               const LodePNGCompressSettings* settings);\n\n/*\nFind length-limited Huffman code for given frequencies. This function is in the\npublic interface only for tests, it's used internally by lodepng_deflate.\n*/\nunsigned lodepng_huffman_code_lengths(unsigned* lengths, const unsigned* frequencies,\n                                      size_t numcodes, unsigned maxbitlen);\n\n/*Compress a buffer with deflate. See RFC 1951. Out buffer must be freed after use.*/\nunsigned lodepng_deflate(unsigned char** out, size_t* outsize,\n                         const unsigned char* in, size_t insize,\n                         const LodePNGCompressSettings* settings);\n\n#endif /*LODEPNG_COMPILE_ENCODER*/\n#endif /*LODEPNG_COMPILE_ZLIB*/\n\n#ifdef LODEPNG_COMPILE_DISK\n/*\nLoad a file from disk into buffer. The function allocates the out buffer, and\nafter usage you should free it.\nout: output parameter, contains pointer to loaded buffer.\noutsize: output parameter, size of the allocated out buffer\nfilename: the path to the file to load\nreturn value: error code (0 means ok)\n*/\nunsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* filename);\n\n/*\nSave a file from buffer to disk. Warning, if it exists, this function overwrites\nthe file without warning!\nbuffer: the buffer to write\nbuffersize: size of the buffer to write\nfilename: the path to the file to save to\nreturn value: error code (0 means ok)\n*/\nunsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const char* filename);\n#endif /*LODEPNG_COMPILE_DISK*/\n\n#ifdef LODEPNG_COMPILE_CPP\n//The LodePNG C++ wrapper uses std::vectors instead of manually allocated memory buffers.\nnamespace lodepng\n{\n#ifdef LODEPNG_COMPILE_PNG\nclass State : public LodePNGState\n{\n  public:\n    State();\n    State(const State& other);\n    virtual ~State();\n    State& operator=(const State& other);\n};\n\n#ifdef LODEPNG_COMPILE_DECODER\n//Same as other lodepng::decode, but using a State for more settings and information.\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                State& state,\n                const unsigned char* in, size_t insize);\nunsigned decode(std::vector<unsigned char>& out, unsigned& w, unsigned& h,\n                State& state,\n                const std::vector<unsigned char>& in);\n#endif /*LODEPNG_COMPILE_DECODER*/\n\n#ifdef LODEPNG_COMPILE_ENCODER\n//Same as other lodepng::encode, but using a State for more settings and information.\nunsigned encode(std::vector<unsigned char>& out,\n                const unsigned char* in, unsigned w, unsigned h,\n                State& state);\nunsigned encode(std::vector<unsigned char>& out,\n                const std::vector<unsigned char>& in, unsigned w, unsigned h,\n                State& state);\n#endif /*LODEPNG_COMPILE_ENCODER*/\n\n#ifdef LODEPNG_COMPILE_DISK\n/*\nLoad a file from disk into an std::vector. If the vector is empty, then either\nthe file doesn't exist or is an empty file.\n*/\nvoid load_file(std::vector<unsigned char>& buffer, const std::string& filename);\n\n/*\nSave the binary data in an std::vector to a file on disk. The file is overwritten\nwithout warning.\n*/\nvoid save_file(const std::vector<unsigned char>& buffer, const std::string& filename);\n#endif //LODEPNG_COMPILE_DISK\n#endif //LODEPNG_COMPILE_PNG\n\n#ifdef LODEPNG_COMPILE_ZLIB\n#ifdef LODEPNG_COMPILE_DECODER\n//Zlib-decompress an unsigned char buffer\nunsigned decompress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,\n                    const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);\n\n//Zlib-decompress an std::vector\nunsigned decompress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,\n                    const LodePNGDecompressSettings& settings = lodepng_default_decompress_settings);\n#endif //LODEPNG_COMPILE_DECODER\n\n#ifdef LODEPNG_COMPILE_ENCODER\n//Zlib-compress an unsigned char buffer\nunsigned compress(std::vector<unsigned char>& out, const unsigned char* in, size_t insize,\n                  const LodePNGCompressSettings& settings = lodepng_default_compress_settings);\n\n//Zlib-compress an std::vector\nunsigned compress(std::vector<unsigned char>& out, const std::vector<unsigned char>& in,\n                  const LodePNGCompressSettings& settings = lodepng_default_compress_settings);\n#endif //LODEPNG_COMPILE_ENCODER\n#endif //LODEPNG_COMPILE_ZLIB\n} //namespace lodepng\n#endif /*LODEPNG_COMPILE_CPP*/\n\n/*\nTODO:\n[.] test if there are no memory leaks or security exploits - done a lot but needs to be checked often\n[.] check compatibility with vareous compilers  - done but needs to be redone for every newer version\n[X] converting color to 16-bit per channel types\n[ ] read all public PNG chunk types (but never let the color profile and gamma ones touch RGB values)\n[ ] make sure encoder generates no chunks with size > (2^31)-1\n[ ] partial decoding (stream processing)\n[X] let the \"isFullyOpaque\" function check color keys and transparent palettes too\n[X] better name for the variables \"codes\", \"codesD\", \"codelengthcodes\", \"clcl\" and \"lldl\"\n[ ] don't stop decoding on errors like 69, 57, 58 (make warnings)\n[ ] make option to choose if the raw image with non multiple of 8 bits per scanline should have padding bits or not\n[ ] let the C++ wrapper catch exceptions coming from the standard library and return LodePNG error codes\n*/\n\n#endif /*LODEPNG_H inclusion guard*/\n\n/*\nLodePNG Documentation\n---------------------\n\n0. table of contents\n--------------------\n\n  1. about\n   1.1. supported features\n   1.2. features not supported\n  2. C and C++ version\n  3. security\n  4. decoding\n  5. encoding\n  6. color conversions\n    6.1. PNG color types\n    6.2. color conversions\n    6.3. padding bits\n    6.4. A note about 16-bits per channel and endianness\n  7. error values\n  8. chunks and PNG editing\n  9. compiler support\n  10. examples\n   10.1. decoder C++ example\n   10.2. decoder C example\n  11. changes\n  12. contact information\n\n\n1. about\n--------\n\nPNG is a file format to store raster images losslessly with good compression,\nsupporting different color types and alpha channel.\n\nLodePNG is a PNG codec according to the Portable Network Graphics (PNG)\nSpecification (Second Edition) - W3C Recommendation 10 November 2003.\n\nThe specifications used are:\n\n*) Portable Network Graphics (PNG) Specification (Second Edition):\n     http://www.w3.org/TR/2003/REC-PNG-20031110\n*) RFC 1950 ZLIB Compressed Data Format version 3.3:\n     http://www.gzip.org/zlib/rfc-zlib.html\n*) RFC 1951 DEFLATE Compressed Data Format Specification ver 1.3:\n     http://www.gzip.org/zlib/rfc-deflate.html\n\nThe most recent version of LodePNG can currently be found at\nhttp://lodev.org/lodepng/\n\nLodePNG works both in C (ISO C90) and C++, with a C++ wrapper that adds\nextra functionality.\n\nLodePNG exists out of two files:\n-lodepng.h: the header file for both C and C++\n-lodepng.c(pp): give it the name lodepng.c or lodepng.cpp (or .cc) depending on your usage\n\nIf you want to start using LodePNG right away without reading this doc, get the\nexamples from the LodePNG website to see how to use it in code, or check the\nsmaller examples in chapter 13 here.\n\nLodePNG is simple but only supports the basic requirements. To achieve\nsimplicity, the following design choices were made: There are no dependencies\non any external library. There are functions to decode and encode a PNG with\na single function call, and extended versions of these functions taking a\nLodePNGState struct allowing to specify or get more information. By default\nthe colors of the raw image are always RGB or RGBA, no matter what color type\nthe PNG file uses. To read and write files, there are simple functions to\nconvert the files to/from buffers in memory.\n\nThis all makes LodePNG suitable for loading textures in games, demos and small\nprograms, ... It's less suitable for full fledged image editors, loading PNGs\nover network (it requires all the image data to be available before decoding can\nbegin), life-critical systems, ...\n\n1.1. supported features\n-----------------------\n\nThe following features are supported by the decoder:\n\n*) decoding of PNGs with any color type, bit depth and interlace mode, to a 24- or 32-bit color raw image,\n   or the same color type as the PNG\n*) encoding of PNGs, from any raw image to 24- or 32-bit color, or the same color type as the raw image\n*) Adam7 interlace and deinterlace for any color type\n*) loading the image from harddisk or decoding it from a buffer from other sources than harddisk\n*) support for alpha channels, including RGBA color model, translucent palettes and color keying\n*) zlib decompression (inflate)\n*) zlib compression (deflate)\n*) CRC32 and ADLER32 checksums\n*) handling of unknown chunks, allowing making a PNG editor that stores custom and unknown chunks.\n*) the following chunks are supported (generated/interpreted) by both encoder and decoder:\n    IHDR: header information\n    PLTE: color palette\n    IDAT: pixel data\n    IEND: the final chunk\n    tRNS: transparency for palettized images\n    tEXt: textual information\n    zTXt: compressed textual information\n    iTXt: international textual information\n    bKGD: suggested background color\n    pHYs: physical dimensions\n    tIME: modification time\n\n1.2. features not supported\n---------------------------\n\nThe following features are _not_ supported:\n\n*) some features needed to make a conformant PNG-Editor might be still missing.\n*) partial loading/stream processing. All data must be available and is processed in one call.\n*) The following public chunks are not supported but treated as unknown chunks by LodePNG\n    cHRM, gAMA, iCCP, sRGB, sBIT, hIST, sPLT\n   Some of these are not supported on purpose: LodePNG wants to provide the RGB values\n   stored in the pixels, not values modified by system dependent gamma or color models.\n\n\n2. C and C++ version\n--------------------\n\nThe C version uses buffers allocated with alloc that you need to free()\nyourself. You need to use init and cleanup functions for each struct whenever\nusing a struct from the C version to avoid exploits and memory leaks.\n\nThe C++ version has extra functions with std::vectors in the interface and the\nlodepng::State class which is a LodePNGState with constructor and destructor.\n\nThese files work without modification for both C and C++ compilers because all\nthe additional C++ code is in \"#ifdef __cplusplus\" blocks that make C-compilers\nignore it, and the C code is made to compile both with strict ISO C90 and C++.\n\nTo use the C++ version, you need to rename the source file to lodepng.cpp\n(instead of lodepng.c), and compile it with a C++ compiler.\n\nTo use the C version, you need to rename the source file to lodepng.c (instead\nof lodepng.cpp), and compile it with a C compiler.\n\n\n3. Security\n-----------\n\nEven if carefully designed, it's always possible that LodePNG contains possible\nexploits. If you discover one, please let me know, and it will be fixed.\n\nWhen using LodePNG, care has to be taken with the C version of LodePNG, as well\nas the C-style structs when working with C++. The following conventions are used\nfor all C-style structs:\n\n-if a struct has a corresponding init function, always call the init function when making a new one\n-if a struct has a corresponding cleanup function, call it before the struct disappears to avoid memory leaks\n-if a struct has a corresponding copy function, use the copy function instead of \"=\".\n The destination must also be inited already.\n\n\n4. Decoding\n-----------\n\nDecoding converts a PNG compressed image to a raw pixel buffer.\n\nMost documentation on using the decoder is at its declarations in the header\nabove. For C, simple decoding can be done with functions such as\nlodepng_decode32, and more advanced decoding can be done with the struct\nLodePNGState and lodepng_decode. For C++, all decoding can be done with the\nvarious lodepng::decode functions, and lodepng::State can be used for advanced\nfeatures.\n\nWhen using the LodePNGState, it uses the following fields for decoding:\n*) LodePNGInfo info_png: it stores extra information about the PNG (the input) in here\n*) LodePNGColorMode info_raw: here you can say what color mode of the raw image (the output) you want to get\n*) LodePNGDecoderSettings decoder: you can specify a few extra settings for the decoder to use\n\nLodePNGInfo info_png\n--------------------\n\nAfter decoding, this contains extra information of the PNG image, except the actual\npixels, width and height because these are already gotten directly from the decoder\nfunctions.\n\nIt contains for example the original color type of the PNG image, text comments,\nsuggested background color, etc... More details about the LodePNGInfo struct are\nat its declaration documentation.\n\nLodePNGColorMode info_raw\n-------------------------\n\nWhen decoding, here you can specify which color type you want\nthe resulting raw image to be. If this is different from the colortype of the\nPNG, then the decoder will automatically convert the result. This conversion\nalways works, except if you want it to convert a color PNG to greyscale or to\na palette with missing colors.\n\nBy default, 32-bit color is used for the result.\n\nLodePNGDecoderSettings decoder\n------------------------------\n\nThe settings can be used to ignore the errors created by invalid CRC and Adler32\nchunks, and to disable the decoding of tEXt chunks.\n\nThere's also a setting color_convert, true by default. If false, no conversion\nis done, the resulting data will be as it was in the PNG (after decompression)\nand you'll have to puzzle the colors of the pixels together yourself using the\ncolor type information in the LodePNGInfo.\n\n\n5. Encoding\n-----------\n\nEncoding converts a raw pixel buffer to a PNG compressed image.\n\nMost documentation on using the encoder is at its declarations in the header\nabove. For C, simple encoding can be done with functions such as\nlodepng_encode32, and more advanced decoding can be done with the struct\nLodePNGState and lodepng_encode. For C++, all encoding can be done with the\nvarious lodepng::encode functions, and lodepng::State can be used for advanced\nfeatures.\n\nLike the decoder, the encoder can also give errors. However it gives less errors\nsince the encoder input is trusted, the decoder input (a PNG image that could\nbe forged by anyone) is not trusted.\n\nWhen using the LodePNGState, it uses the following fields for encoding:\n*) LodePNGInfo info_png: here you specify how you want the PNG (the output) to be.\n*) LodePNGColorMode info_raw: here you say what color type of the raw image (the input) has\n*) LodePNGEncoderSettings encoder: you can specify a few settings for the encoder to use\n\nLodePNGInfo info_png\n--------------------\n\nWhen encoding, you use this the opposite way as when decoding: for encoding,\nyou fill in the values you want the PNG to have before encoding. By default it's\nnot needed to specify a color type for the PNG since it's automatically chosen,\nbut it's possible to choose it yourself given the right settings.\n\nThe encoder will not always exactly match the LodePNGInfo struct you give,\nit tries as close as possible. Some things are ignored by the encoder. The\nencoder uses, for example, the following settings from it when applicable:\ncolortype and bitdepth, text chunks, time chunk, the color key, the palette, the\nbackground color, the interlace method, unknown chunks, ...\n\nWhen encoding to a PNG with colortype 3, the encoder will generate a PLTE chunk.\nIf the palette contains any colors for which the alpha channel is not 255 (so\nthere are translucent colors in the palette), it'll add a tRNS chunk.\n\nLodePNGColorMode info_raw\n-------------------------\n\nYou specify the color type of the raw image that you give to the input here,\nincluding a possible transparent color key and palette you happen to be using in\nyour raw image data.\n\nBy default, 32-bit color is assumed, meaning your input has to be in RGBA\nformat with 4 bytes (unsigned chars) per pixel.\n\nLodePNGEncoderSettings encoder\n------------------------------\n\nThe following settings are supported (some are in sub-structs):\n*) auto_convert: when this option is enabled, the encoder will\nautomatically choose the smallest possible color mode (including color key) that\ncan encode the colors of all pixels without information loss.\n*) btype: the block type for LZ77. 0 = uncompressed, 1 = fixed huffman tree,\n   2 = dynamic huffman tree (best compression). Should be 2 for proper\n   compression.\n*) use_lz77: whether or not to use LZ77 for compressed block types. Should be\n   true for proper compression.\n*) windowsize: the window size used by the LZ77 encoder (1 - 32768). Has value\n   2048 by default, but can be set to 32768 for better, but slow, compression.\n*) force_palette: if colortype is 2 or 6, you can make the encoder write a PLTE\n   chunk if force_palette is true. This can used as suggested palette to convert\n   to by viewers that don't support more than 256 colors (if those still exist)\n*) add_id: add text chunk \"Encoder: LodePNG <version>\" to the image.\n*) text_compression: default 1. If 1, it'll store texts as zTXt instead of tEXt chunks.\n  zTXt chunks use zlib compression on the text. This gives a smaller result on\n  large texts but a larger result on small texts (such as a single program name).\n  It's all tEXt or all zTXt though, there's no separate setting per text yet.\n\n\n6. color conversions\n--------------------\n\nAn important thing to note about LodePNG, is that the color type of the PNG, and\nthe color type of the raw image, are completely independent. By default, when\nyou decode a PNG, you get the result as a raw image in the color type you want,\nno matter whether the PNG was encoded with a palette, greyscale or RGBA color.\nAnd if you encode an image, by default LodePNG will automatically choose the PNG\ncolor type that gives good compression based on the values of colors and amount\nof colors in the image. It can be configured to let you control it instead as\nwell, though.\n\nTo be able to do this, LodePNG does conversions from one color mode to another.\nIt can convert from almost any color type to any other color type, except the\nfollowing conversions: RGB to greyscale is not supported, and converting to a\npalette when the palette doesn't have a required color is not supported. This is\nnot supported on purpose: this is information loss which requires a color\nreduction algorithm that is beyong the scope of a PNG encoder (yes, RGB to grey\nis easy, but there are multiple ways if you want to give some channels more\nweight).\n\nBy default, when decoding, you get the raw image in 32-bit RGBA or 24-bit RGB\ncolor, no matter what color type the PNG has. And by default when encoding,\nLodePNG automatically picks the best color model for the output PNG, and expects\nthe input image to be 32-bit RGBA or 24-bit RGB. So, unless you want to control\nthe color format of the images yourself, you can skip this chapter.\n\n6.1. PNG color types\n--------------------\n\nA PNG image can have many color types, ranging from 1-bit color to 64-bit color,\nas well as palettized color modes. After the zlib decompression and unfiltering\nin the PNG image is done, the raw pixel data will have that color type and thus\na certain amount of bits per pixel. If you want the output raw image after\ndecoding to have another color type, a conversion is done by LodePNG.\n\nThe PNG specification gives the following color types:\n\n0: greyscale, bit depths 1, 2, 4, 8, 16\n2: RGB, bit depths 8 and 16\n3: palette, bit depths 1, 2, 4 and 8\n4: greyscale with alpha, bit depths 8 and 16\n6: RGBA, bit depths 8 and 16\n\nBit depth is the amount of bits per pixel per color channel. So the total amount\nof bits per pixel is: amount of channels * bitdepth.\n\n6.2. color conversions\n----------------------\n\nAs explained in the sections about the encoder and decoder, you can specify\ncolor types and bit depths in info_png and info_raw to change the default\nbehaviour.\n\nIf, when decoding, you want the raw image to be something else than the default,\nyou need to set the color type and bit depth you want in the LodePNGColorMode,\nor the parameters of the simple function of LodePNG you're using.\n\nIf, when encoding, you use another color type than the default in the input\nimage, you need to specify its color type and bit depth in the LodePNGColorMode\nof the raw image, or use the parameters of the simplefunction of LodePNG you're\nusing.\n\nIf, when encoding, you don't want LodePNG to choose the output PNG color type\nbut control it yourself, you need to set auto_convert in the encoder settings\nto LAC_NONE, and specify the color type you want in the LodePNGInfo of the\nencoder.\n\nIf you do any of the above, LodePNG may need to do a color conversion, which\nfollows the rules below, and may sometimes not be allowed.\n\nTo avoid some confusion:\n-the decoder converts from PNG to raw image\n-the encoder converts from raw image to PNG\n-the colortype and bitdepth in LodePNGColorMode info_raw, are those of the raw image\n-the colortype and bitdepth in the color field of LodePNGInfo info_png, are those of the PNG\n-when encoding, the color type in LodePNGInfo is ignored if auto_convert\n is enabled, it is automatically generated instead\n-when decoding, the color type in LodePNGInfo is set by the decoder to that of the original\n PNG image, but it can be ignored since the raw image has the color type you requested instead\n-if the color type of the LodePNGColorMode and PNG image aren't the same, a conversion\n between the color types is done if the color types are supported. If it is not\n supported, an error is returned. If the types are the same, no conversion is done.\n-even though some conversions aren't supported, LodePNG supports loading PNGs from any\n colortype and saving PNGs to any colortype, sometimes it just requires preparing\n the raw image correctly before encoding.\n-both encoder and decoder use the same color converter.\n\nNon supported color conversions:\n-color to greyscale: no error is thrown, but the result will look ugly because\nonly the red channel is taken\n-anything, to palette when that palette does not have that color in it: in this\ncase an error is thrown\n\nSupported color conversions:\n-anything to 8-bit RGB, 8-bit RGBA, 16-bit RGB, 16-bit RGBA\n-any grey or grey+alpha, to grey or grey+alpha\n-anything to a palette, as long as the palette has the requested colors in it\n-removing alpha channel\n-higher to smaller bitdepth, and vice versa\n\nIf you want no color conversion to be done:\n-In the encoder, you can make it save a PNG with any color type by giving the\nraw color mode and LodePNGInfo the same color mode, and setting auto_convert to\nLAC_NO.\n-In the decoder, you can make it store the pixel data in the same color type\nas the PNG has, by setting the color_convert setting to false. Settings in\ninfo_raw are then ignored.\n\nThe function lodepng_convert does the color conversion. It is available in the\ninterface but normally isn't needed since the encoder and decoder already call\nit.\n\n6.3. padding bits\n-----------------\n\nIn the PNG file format, if a less than 8-bit per pixel color type is used and the scanlines\nhave a bit amount that isn't a multiple of 8, then padding bits are used so that each\nscanline starts at a fresh byte. But that is NOT true for the LodePNG raw input and output.\nThe raw input image you give to the encoder, and the raw output image you get from the decoder\nwill NOT have these padding bits, e.g. in the case of a 1-bit image with a width\nof 7 pixels, the first pixel of the second scanline will the the 8th bit of the first byte,\nnot the first bit of a new byte.\n\n6.4. A note about 16-bits per channel and endianness\n----------------------------------------------------\n\nLodePNG uses unsigned char arrays for 16-bit per channel colors too, just like\nfor any other color format. The 16-bit values are stored in big endian (most\nsignificant byte first) in these arrays. This is the opposite order of the\nlittle endian used by x86 CPU's.\n\nLodePNG always uses big endian because the PNG file format does so internally.\nConversions to other formats than PNG uses internally are not supported by\nLodePNG on purpose, there are myriads of formats, including endianness of 16-bit\ncolors, the order in which you store R, G, B and A, and so on. Supporting and\nconverting to/from all that is outside the scope of LodePNG.\n\nThis may mean that, depending on your use case, you may want to convert the big\nendian output of LodePNG to little endian with a for loop. This is certainly not\nalways needed, many applications and libraries support big endian 16-bit colors\nanyway, but it means you cannot simply cast the unsigned char* buffer to an\nunsigned short* buffer on x86 CPUs.\n\n\n7. error values\n---------------\n\nAll functions in LodePNG that return an error code, return 0 if everything went\nOK, or a non-zero code if there was an error.\n\nThe meaning of the LodePNG error values can be retrieved with the function\nlodepng_error_text: given the numerical error code, it returns a description\nof the error in English as a string.\n\nCheck the implementation of lodepng_error_text to see the meaning of each code.\n\n\n8. chunks and PNG editing\n-------------------------\n\nIf you want to add extra chunks to a PNG you encode, or use LodePNG for a PNG\neditor that should follow the rules about handling of unknown chunks, or if your\nprogram is able to read other types of chunks than the ones handled by LodePNG,\nthen that's possible with the chunk functions of LodePNG.\n\nA PNG chunk has the following layout:\n\n4 bytes length\n4 bytes type name\nlength bytes data\n4 bytes CRC\n\n8.1. iterating through chunks\n-----------------------------\n\nIf you have a buffer containing the PNG image data, then the first chunk (the\nIHDR chunk) starts at byte number 8 of that buffer. The first 8 bytes are the\nsignature of the PNG and are not part of a chunk. But if you start at byte 8\nthen you have a chunk, and can check the following things of it.\n\nNOTE: none of these functions check for memory buffer boundaries. To avoid\nexploits, always make sure the buffer contains all the data of the chunks.\nWhen using lodepng_chunk_next, make sure the returned value is within the\nallocated memory.\n\nunsigned lodepng_chunk_length(const unsigned char* chunk):\n\nGet the length of the chunk's data. The total chunk length is this length + 12.\n\nvoid lodepng_chunk_type(char type[5], const unsigned char* chunk):\nunsigned char lodepng_chunk_type_equals(const unsigned char* chunk, const char* type):\n\nGet the type of the chunk or compare if it's a certain type\n\nunsigned char lodepng_chunk_critical(const unsigned char* chunk):\nunsigned char lodepng_chunk_private(const unsigned char* chunk):\nunsigned char lodepng_chunk_safetocopy(const unsigned char* chunk):\n\nCheck if the chunk is critical in the PNG standard (only IHDR, PLTE, IDAT and IEND are).\nCheck if the chunk is private (public chunks are part of the standard, private ones not).\nCheck if the chunk is safe to copy. If it's not, then, when modifying data in a critical\nchunk, unsafe to copy chunks of the old image may NOT be saved in the new one if your\nprogram doesn't handle that type of unknown chunk.\n\nunsigned char* lodepng_chunk_data(unsigned char* chunk):\nconst unsigned char* lodepng_chunk_data_const(const unsigned char* chunk):\n\nGet a pointer to the start of the data of the chunk.\n\nunsigned lodepng_chunk_check_crc(const unsigned char* chunk):\nvoid lodepng_chunk_generate_crc(unsigned char* chunk):\n\nCheck if the crc is correct or generate a correct one.\n\nunsigned char* lodepng_chunk_next(unsigned char* chunk):\nconst unsigned char* lodepng_chunk_next_const(const unsigned char* chunk):\n\nIterate to the next chunk. This works if you have a buffer with consecutive chunks. Note that these\nfunctions do no boundary checking of the allocated data whatsoever, so make sure there is enough\ndata available in the buffer to be able to go to the next chunk.\n\nunsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk):\nunsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,\n                              const char* type, const unsigned char* data):\n\nThese functions are used to create new chunks that are appended to the data in *out that has\nlength *outlength. The append function appends an existing chunk to the new data. The create\nfunction creates a new chunk with the given parameters and appends it. Type is the 4-letter\nname of the chunk.\n\n8.2. chunks in info_png\n-----------------------\n\nThe LodePNGInfo struct contains fields with the unknown chunk in it. It has 3\nbuffers (each with size) to contain 3 types of unknown chunks:\nthe ones that come before the PLTE chunk, the ones that come between the PLTE\nand the IDAT chunks, and the ones that come after the IDAT chunks.\nIt's necessary to make the distionction between these 3 cases because the PNG\nstandard forces to keep the ordering of unknown chunks compared to the critical\nchunks, but does not force any other ordering rules.\n\ninfo_png.unknown_chunks_data[0] is the chunks before PLTE\ninfo_png.unknown_chunks_data[1] is the chunks after PLTE, before IDAT\ninfo_png.unknown_chunks_data[2] is the chunks after IDAT\n\nThe chunks in these 3 buffers can be iterated through and read by using the same\nway described in the previous subchapter.\n\nWhen using the decoder to decode a PNG, you can make it store all unknown chunks\nif you set the option settings.remember_unknown_chunks to 1. By default, this\noption is off (0).\n\nThe encoder will always encode unknown chunks that are stored in the info_png.\nIf you need it to add a particular chunk that isn't known by LodePNG, you can\nuse lodepng_chunk_append or lodepng_chunk_create to the chunk data in\ninfo_png.unknown_chunks_data[x].\n\nChunks that are known by LodePNG should not be added in that way. E.g. to make\nLodePNG add a bKGD chunk, set background_defined to true and add the correct\nparameters there instead.\n\n\n9. compiler support\n-------------------\n\nNo libraries other than the current standard C library are needed to compile\nLodePNG. For the C++ version, only the standard C++ library is needed on top.\nAdd the files lodepng.c(pp) and lodepng.h to your project, include\nlodepng.h where needed, and your program can read/write PNG files.\n\nIf performance is important, use optimization when compiling! For both the\nencoder and decoder, this makes a large difference.\n\nMake sure that LodePNG is compiled with the same compiler of the same version\nand with the same settings as the rest of the program, or the interfaces with\nstd::vectors and std::strings in C++ can be incompatible.\n\nCHAR_BITS must be 8 or higher, because LodePNG uses unsigned chars for octets.\n\n*) gcc and g++\n\nLodePNG is developed in gcc so this compiler is natively supported. It gives no\nwarnings with compiler options \"-Wall -Wextra -pedantic -ansi\", with gcc and g++\nversion 4.7.1 on Linux, 32-bit and 64-bit.\n\n*) Mingw\n\nThe Mingw compiler (a port of gcc) for Windows is fully supported by LodePNG.\n\n*) Visual Studio 2005 and up, Visual C++ Express Edition 2005 and up\n\nVisual Studio may give warnings about 'fopen' being deprecated. A multiplatform library\ncan't support the proposed Visual Studio alternative however, so LodePNG keeps using\nfopen. If you don't want to see the deprecated warnings, put this on top of lodepng.h\nbefore the inclusions:\n#define _CRT_SECURE_NO_DEPRECATE\n\nOther than the above warnings, LodePNG should be warning-free with warning\nlevel 3 (W3). Warning level 4 (W4) will give warnings about integer conversions.\nI'm not planning to resolve these warnings. To get rid of them, let Visual\nStudio use warning level W3 for lodepng.cpp only: right click lodepng.cpp,\nProperties, C/C++, General, Warning Level: Level 3 (/W3).\n\nVisual Studio may want \"stdafx.h\" files to be included in each source file and\ngive an error \"unexpected end of file while looking for precompiled header\".\nThat is not standard C++ and will not be added to the stock LodePNG. You can\ndisable it for lodepng.cpp only by right clicking it, Properties, C/C++,\nPrecompiled Headers, and set it to Not Using Precompiled Headers there.\n\n*) Visual Studio 6.0\n\nLodePNG support for Visual Studio 6.0 is not guaranteed because VS6 doesn't\nfollow the C++ standard correctly.\n\n*) Comeau C/C++\n\nVesion 20070107 compiles without problems on the Comeau C/C++ Online Test Drive\nat http://www.comeaucomputing.com/tryitout in both C90 and C++ mode.\n\n*) Compilers on Macintosh\n\nLodePNG has been reported to work both with the gcc and LLVM for Macintosh, both\nfor C and C++.\n\n*) Other Compilers\n\nIf you encounter problems on other compilers, feel free to let me know and I may\ntry to fix it if the compiler is modern standards complient.\n\n\n10. examples\n------------\n\nThis decoder example shows the most basic usage of LodePNG. More complex\nexamples can be found on the LodePNG website.\n\n10.1. decoder C++ example\n-------------------------\n\n#include \"lodepng.h\"\n#include <iostream>\n\nint main(int argc, char *argv[])\n{\n  const char* filename = argc > 1 ? argv[1] : \"test.png\";\n\n  //load and decode\n  std::vector<unsigned char> image;\n  unsigned width, height;\n  unsigned error = lodepng::decode(image, width, height, filename);\n\n  //if there's an error, display it\n  if(error) std::cout << \"decoder error \" << error << \": \" << lodepng_error_text(error) << std::endl;\n\n  //the pixels are now in the vector \"image\", 4 bytes per pixel, ordered RGBARGBA..., use it as texture, draw it, ...\n}\n\n10.2. decoder C example\n-----------------------\n\n#include \"lodepng.h\"\n\nint main(int argc, char *argv[])\n{\n  unsigned error;\n  unsigned char* image;\n  size_t width, height;\n  const char* filename = argc > 1 ? argv[1] : \"test.png\";\n\n  error = lodepng_decode32_file(&image, &width, &height, filename);\n\n  if(error) printf(\"decoder error %u: %s\\n\", error, lodepng_error_text(error));\n\n  / * use image here * /\n\n  free(image);\n  return 0;\n}\n\n\n11. changes\n-----------\n\nThe version number of LodePNG is the date of the change given in the format\nyyyymmdd.\n\nSome changes aren't backwards compatible. Those are indicated with a (!)\nsymbol.\n\n*) 15 apr 2013: Fixed bug with LAC_ALPHA and color key.\n*) 25 mar 2013: Added an optional feature to ignore some PNG errors (fix_png).\n*) 11 mar 2013 (!): Bugfix with custom free. Changed from \"my\" to \"lodepng_\"\n    prefix for the custom allocators and made it possible with a new #define to\n    use custom ones in your project without needing to change lodepng's code.\n*) 28 jan 2013: Bugfix with color key.\n*) 27 okt 2012: Tweaks in text chunk keyword length error handling.\n*) 8 okt 2012 (!): Added new filter strategy (entropy) and new auto color mode.\n    (no palette). Better deflate tree encoding. New compression tweak settings.\n    Faster color conversions while decoding. Some internal cleanups.\n*) 23 sep 2012: Reduced warnings in Visual Studio a little bit.\n*) 1 sep 2012 (!): Removed #define's for giving custom (de)compression functions\n    and made it work with function pointers instead.\n*) 23 jun 2012: Added more filter strategies. Made it easier to use custom alloc\n    and free functions and toggle #defines from compiler flags. Small fixes.\n*) 6 may 2012 (!): Made plugging in custom zlib/deflate functions more flexible.\n*) 22 apr 2012 (!): Made interface more consistent, renaming a lot. Removed\n    redundant C++ codec classes. Reduced amount of structs. Everything changed,\n    but it is cleaner now imho and functionality remains the same. Also fixed\n    several bugs and shrinked the implementation code. Made new samples.\n*) 6 nov 2011 (!): By default, the encoder now automatically chooses the best\n    PNG color model and bit depth, based on the amount and type of colors of the\n    raw image. For this, autoLeaveOutAlphaChannel replaced by auto_choose_color.\n*) 9 okt 2011: simpler hash chain implementation for the encoder.\n*) 8 sep 2011: lz77 encoder lazy matching instead of greedy matching.\n*) 23 aug 2011: tweaked the zlib compression parameters after benchmarking.\n    A bug with the PNG filtertype heuristic was fixed, so that it chooses much\n    better ones (it's quite significant). A setting to do an experimental, slow,\n    brute force search for PNG filter types is added.\n*) 17 aug 2011 (!): changed some C zlib related function names.\n*) 16 aug 2011: made the code less wide (max 120 characters per line).\n*) 17 apr 2011: code cleanup. Bugfixes. Convert low to 16-bit per sample colors.\n*) 21 feb 2011: fixed compiling for C90. Fixed compiling with sections disabled.\n*) 11 dec 2010: encoding is made faster, based on suggestion by Peter Eastman\n    to optimize long sequences of zeros.\n*) 13 nov 2010: added LodePNG_InfoColor_hasPaletteAlpha and\n    LodePNG_InfoColor_canHaveAlpha functions for convenience.\n*) 7 nov 2010: added LodePNG_error_text function to get error code description.\n*) 30 okt 2010: made decoding slightly faster\n*) 26 okt 2010: (!) changed some C function and struct names (more consistent).\n     Reorganized the documentation and the declaration order in the header.\n*) 08 aug 2010: only changed some comments and external samples.\n*) 05 jul 2010: fixed bug thanks to warnings in the new gcc version.\n*) 14 mar 2010: fixed bug where too much memory was allocated for char buffers.\n*) 02 sep 2008: fixed bug where it could create empty tree that linux apps could\n    read by ignoring the problem but windows apps couldn't.\n*) 06 jun 2008: added more error checks for out of memory cases.\n*) 26 apr 2008: added a few more checks here and there to ensure more safety.\n*) 06 mar 2008: crash with encoding of strings fixed\n*) 02 feb 2008: support for international text chunks added (iTXt)\n*) 23 jan 2008: small cleanups, and #defines to divide code in sections\n*) 20 jan 2008: support for unknown chunks allowing using LodePNG for an editor.\n*) 18 jan 2008: support for tIME and pHYs chunks added to encoder and decoder.\n*) 17 jan 2008: ability to encode and decode compressed zTXt chunks added\n    Also vareous fixes, such as in the deflate and the padding bits code.\n*) 13 jan 2008: Added ability to encode Adam7-interlaced images. Improved\n    filtering code of encoder.\n*) 07 jan 2008: (!) changed LodePNG to use ISO C90 instead of C++. A\n    C++ wrapper around this provides an interface almost identical to before.\n    Having LodePNG be pure ISO C90 makes it more portable. The C and C++ code\n    are together in these files but it works both for C and C++ compilers.\n*) 29 dec 2007: (!) changed most integer types to unsigned int + other tweaks\n*) 30 aug 2007: bug fixed which makes this Borland C++ compatible\n*) 09 aug 2007: some VS2005 warnings removed again\n*) 21 jul 2007: deflate code placed in new namespace separate from zlib code\n*) 08 jun 2007: fixed bug with 2- and 4-bit color, and small interlaced images\n*) 04 jun 2007: improved support for Visual Studio 2005: crash with accessing\n    invalid std::vector element [0] fixed, and level 3 and 4 warnings removed\n*) 02 jun 2007: made the encoder add a tag with version by default\n*) 27 may 2007: zlib and png code separated (but still in the same file),\n    simple encoder/decoder functions added for more simple usage cases\n*) 19 may 2007: minor fixes, some code cleaning, new error added (error 69),\n    moved some examples from here to lodepng_examples.cpp\n*) 12 may 2007: palette decoding bug fixed\n*) 24 apr 2007: changed the license from BSD to the zlib license\n*) 11 mar 2007: very simple addition: ability to encode bKGD chunks.\n*) 04 mar 2007: (!) tEXt chunk related fixes, and support for encoding\n    palettized PNG images. Plus little interface change with palette and texts.\n*) 03 mar 2007: Made it encode dynamic Huffman shorter with repeat codes.\n    Fixed a bug where the end code of a block had length 0 in the Huffman tree.\n*) 26 feb 2007: Huffman compression with dynamic trees (BTYPE 2) now implemented\n    and supported by the encoder, resulting in smaller PNGs at the output.\n*) 27 jan 2007: Made the Adler-32 test faster so that a timewaste is gone.\n*) 24 jan 2007: gave encoder an error interface. Added color conversion from any\n    greyscale type to 8-bit greyscale with or without alpha.\n*) 21 jan 2007: (!) Totally changed the interface. It allows more color types\n    to convert to and is more uniform. See the manual for how it works now.\n*) 07 jan 2007: Some cleanup & fixes, and a few changes over the last days:\n    encode/decode custom tEXt chunks, separate classes for zlib & deflate, and\n    at last made the decoder give errors for incorrect Adler32 or Crc.\n*) 01 jan 2007: Fixed bug with encoding PNGs with less than 8 bits per channel.\n*) 29 dec 2006: Added support for encoding images without alpha channel, and\n    cleaned out code as well as making certain parts faster.\n*) 28 dec 2006: Added \"Settings\" to the encoder.\n*) 26 dec 2006: The encoder now does LZ77 encoding and produces much smaller files now.\n    Removed some code duplication in the decoder. Fixed little bug in an example.\n*) 09 dec 2006: (!) Placed output parameters of public functions as first parameter.\n    Fixed a bug of the decoder with 16-bit per color.\n*) 15 okt 2006: Changed documentation structure\n*) 09 okt 2006: Encoder class added. It encodes a valid PNG image from the\n    given image buffer, however for now it's not compressed.\n*) 08 sep 2006: (!) Changed to interface with a Decoder class\n*) 30 jul 2006: (!) LodePNG_InfoPng , width and height are now retrieved in different\n    way. Renamed decodePNG to decodePNGGeneric.\n*) 29 jul 2006: (!) Changed the interface: image info is now returned as a\n    struct of type LodePNG::LodePNG_Info, instead of a vector, which was a bit clumsy.\n*) 28 jul 2006: Cleaned the code and added new error checks.\n    Corrected terminology \"deflate\" into \"inflate\".\n*) 23 jun 2006: Added SDL example in the documentation in the header, this\n    example allows easy debugging by displaying the PNG and its transparency.\n*) 22 jun 2006: (!) Changed way to obtain error value. Added\n    loadFile function for convenience. Made decodePNG32 faster.\n*) 21 jun 2006: (!) Changed type of info vector to unsigned.\n    Changed position of palette in info vector. Fixed an important bug that\n    happened on PNGs with an uncompressed block.\n*) 16 jun 2006: Internally changed unsigned into unsigned where\n    needed, and performed some optimizations.\n*) 07 jun 2006: (!) Renamed functions to decodePNG and placed them\n    in LodePNG namespace. Changed the order of the parameters. Rewrote the\n    documentation in the header. Renamed files to lodepng.cpp and lodepng.h\n*) 22 apr 2006: Optimized and improved some code\n*) 07 sep 2005: (!) Changed to std::vector interface\n*) 12 aug 2005: Initial release (C++, decoder only)\n\n\n12. contact information\n-----------------------\n\nFeel free to contact me with suggestions, problems, comments, ... concerning\nLodePNG. If you encounter a PNG image that doesn't work properly with this\ndecoder, feel free to send it and I'll use it to find and fix the problem.\n\nMy email address is (puzzle the account and domain together with an @ symbol):\nDomain: gmail dot com.\nAccount: lode dot vandevenne.\n\n\nCopyright (c) 2005-2013 Lode Vandevenne\n*/\n"
  },
  {
    "path": "deps/noise/noise.c",
    "content": "/*\nnoise.h and noise.c are derived from this project:\n\nhttps://github.com/caseman/noise\n\nCopyright (c) 2008 Casey Duncan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#include <math.h>\n#include <stdlib.h>\n#include <string.h>\n\n#define F2 0.3660254037844386f\n#define G2 0.21132486540518713f\n#define F3 (1.0f / 3.0f)\n#define G3 (1.0f / 6.0f)\n#define ASSIGN(a, v0, v1, v2) (a)[0] = v0; (a)[1] = v1; (a)[2] = v2;\n#define DOT3(v1, v2) ((v1)[0] * (v2)[0] + (v1)[1] * (v2)[1] + (v1)[2] * (v2)[2])\n\nconst static float GRAD3[16][3] = {\n    { 1, 1, 0}, {-1, 1, 0}, { 1,-1, 0}, {-1,-1, 0}, \n    { 1, 0, 1}, {-1, 0, 1}, { 1, 0,-1}, {-1, 0,-1}, \n    { 0, 1, 1}, { 0,-1, 1}, { 0, 1,-1}, { 0,-1,-1},\n    { 1, 0,-1}, {-1, 0,-1}, { 0,-1, 1}, { 0, 1, 1}\n};\n\nstatic unsigned char PERM[] = {\n    151, 160, 137,  91,  90,  15, 131,  13,\n    201,  95,  96,  53, 194, 233,   7, 225,\n    140,  36, 103,  30,  69, 142,   8,  99,\n     37, 240,  21,  10,  23, 190,   6, 148,\n    247, 120, 234,  75,   0,  26, 197,  62,\n     94, 252, 219, 203, 117,  35,  11,  32,\n     57, 177,  33,  88, 237, 149,  56,  87,\n    174,  20, 125, 136, 171, 168,  68, 175,\n     74, 165,  71, 134, 139,  48,  27, 166,\n     77, 146, 158, 231,  83, 111, 229, 122,\n     60, 211, 133, 230, 220, 105,  92,  41,\n     55,  46, 245,  40, 244, 102, 143,  54,\n     65,  25,  63, 161,   1, 216,  80,  73,\n    209,  76, 132, 187, 208,  89,  18, 169,\n    200, 196, 135, 130, 116, 188, 159,  86,\n    164, 100, 109, 198, 173, 186,   3,  64,\n     52, 217, 226, 250, 124, 123,   5, 202,\n     38, 147, 118, 126, 255,  82,  85, 212,\n    207, 206,  59, 227,  47,  16,  58,  17,\n    182, 189,  28,  42, 223, 183, 170, 213,\n    119, 248, 152,   2,  44, 154, 163,  70,\n    221, 153, 101, 155, 167,  43, 172,   9,\n    129,  22,  39, 253,  19,  98, 108, 110,\n     79, 113, 224, 232, 178, 185, 112, 104,\n    218, 246,  97, 228, 251,  34, 242, 193,\n    238, 210, 144,  12, 191, 179, 162, 241,\n     81,  51, 145, 235, 249,  14, 239, 107,\n     49, 192, 214,  31, 181, 199, 106, 157,\n    184,  84, 204, 176, 115, 121,  50,  45,\n    127,   4, 150, 254, 138, 236, 205,  93,\n    222, 114,  67,  29,  24,  72, 243, 141,\n    128, 195,  78,  66, 215,  61, 156, 180,\n    151, 160, 137,  91,  90,  15, 131,  13,\n    201,  95,  96,  53, 194, 233,   7, 225,\n    140,  36, 103,  30,  69, 142,   8,  99,\n     37, 240,  21,  10,  23, 190,   6, 148,\n    247, 120, 234,  75,   0,  26, 197,  62,\n     94, 252, 219, 203, 117,  35,  11,  32,\n     57, 177,  33,  88, 237, 149,  56,  87,\n    174,  20, 125, 136, 171, 168,  68, 175,\n     74, 165,  71, 134, 139,  48,  27, 166,\n     77, 146, 158, 231,  83, 111, 229, 122,\n     60, 211, 133, 230, 220, 105,  92,  41,\n     55,  46, 245,  40, 244, 102, 143,  54,\n     65,  25,  63, 161,   1, 216,  80,  73,\n    209,  76, 132, 187, 208,  89,  18, 169,\n    200, 196, 135, 130, 116, 188, 159,  86,\n    164, 100, 109, 198, 173, 186,   3,  64,\n     52, 217, 226, 250, 124, 123,   5, 202,\n     38, 147, 118, 126, 255,  82,  85, 212,\n    207, 206,  59, 227,  47,  16,  58,  17,\n    182, 189,  28,  42, 223, 183, 170, 213,\n    119, 248, 152,   2,  44, 154, 163,  70,\n    221, 153, 101, 155, 167,  43, 172,   9,\n    129,  22,  39, 253,  19,  98, 108, 110,\n     79, 113, 224, 232, 178, 185, 112, 104,\n    218, 246,  97, 228, 251,  34, 242, 193,\n    238, 210, 144,  12, 191, 179, 162, 241,\n     81,  51, 145, 235, 249,  14, 239, 107,\n     49, 192, 214,  31, 181, 199, 106, 157,\n    184,  84, 204, 176, 115, 121,  50,  45,\n    127,   4, 150, 254, 138, 236, 205,  93,\n    222, 114,  67,  29,  24,  72, 243, 141,\n    128, 195,  78,  66, 215,  61, 156, 180\n};\n\nvoid seed(unsigned int x) {\n    srand(x);\n    for (int i = 0; i < 256; i++) {\n        PERM[i] = i;\n    }\n    for (int i = 255; i > 0; i--) {\n        int j;\n        int n = i + 1;\n        while (n <= (j = rand() / (RAND_MAX / n)));\n        unsigned char a = PERM[i];\n        unsigned char b = PERM[j];\n        PERM[i] = b;\n        PERM[j] = a;\n    }\n    memcpy(PERM + 256, PERM, sizeof(unsigned char) * 256);\n}\n\nfloat noise2(float x, float y) {\n    int i1, j1, I, J, c;\n    float s = (x + y) * F2;\n    float i = floorf(x + s);\n    float j = floorf(y + s);\n    float t = (i + j) * G2;\n\n    float xx[3], yy[3], f[3];\n    float noise[3] = {0.0f, 0.0f, 0.0f};\n    int g[3];\n\n    xx[0] = x - (i - t);\n    yy[0] = y - (j - t);\n\n    i1 = xx[0] > yy[0];\n    j1 = xx[0] <= yy[0];\n\n    xx[2] = xx[0] + G2 * 2.0f - 1.0f;\n    yy[2] = yy[0] + G2 * 2.0f - 1.0f;\n    xx[1] = xx[0] - i1 + G2;\n    yy[1] = yy[0] - j1 + G2;\n\n    I = (int) i & 255;\n    J = (int) j & 255;\n    g[0] = PERM[I + PERM[J]] % 12;\n    g[1] = PERM[I + i1 + PERM[J + j1]] % 12;\n    g[2] = PERM[I + 1 + PERM[J + 1]] % 12;\n\n    for (c = 0; c <= 2; c++) {\n        f[c] = 0.5f - xx[c]*xx[c] - yy[c]*yy[c];\n    }\n    \n    for (c = 0; c <= 2; c++) {\n        if (f[c] > 0) {\n            noise[c] = f[c] * f[c] * f[c] * f[c] *\n                (GRAD3[g[c]][0] * xx[c] + GRAD3[g[c]][1] * yy[c]);\n        }\n    }\n    \n    return (noise[0] + noise[1] + noise[2]) * 70.0f;\n}\n\nfloat noise3(float x, float y, float z) {\n    int c, o1[3], o2[3], g[4], I, J, K;\n    float f[4], noise[4] = {0.0f, 0.0f, 0.0f, 0.0f};\n    float s = (x + y + z) * F3;\n    float i = floorf(x + s);\n    float j = floorf(y + s);\n    float k = floorf(z + s);\n    float t = (i + j + k) * G3;\n\n    float pos[4][3];\n\n    pos[0][0] = x - (i - t);\n    pos[0][1] = y - (j - t);\n    pos[0][2] = z - (k - t);\n\n    if (pos[0][0] >= pos[0][1]) {\n        if (pos[0][1] >= pos[0][2]) {\n            ASSIGN(o1, 1, 0, 0);\n            ASSIGN(o2, 1, 1, 0);\n        } else if (pos[0][0] >= pos[0][2]) {\n            ASSIGN(o1, 1, 0, 0);\n            ASSIGN(o2, 1, 0, 1);\n        } else {\n            ASSIGN(o1, 0, 0, 1);\n            ASSIGN(o2, 1, 0, 1);\n        }\n    } else {\n        if (pos[0][1] < pos[0][2]) {\n            ASSIGN(o1, 0, 0, 1);\n            ASSIGN(o2, 0, 1, 1);\n        } else if (pos[0][0] < pos[0][2]) {\n            ASSIGN(o1, 0, 1, 0);\n            ASSIGN(o2, 0, 1, 1);\n        } else {\n            ASSIGN(o1, 0, 1, 0);\n            ASSIGN(o2, 1, 1, 0);\n        }\n    }\n    \n    for (c = 0; c <= 2; c++) {\n        pos[3][c] = pos[0][c] - 1.0f + 3.0f * G3;\n        pos[2][c] = pos[0][c] - o2[c] + 2.0f * G3;\n        pos[1][c] = pos[0][c] - o1[c] + G3;\n    }\n\n    I = (int) i & 255; \n    J = (int) j & 255; \n    K = (int) k & 255;\n    g[0] = PERM[I + PERM[J + PERM[K]]] % 12;\n    g[1] = PERM[I + o1[0] + PERM[J + o1[1] + PERM[o1[2] + K]]] % 12;\n    g[2] = PERM[I + o2[0] + PERM[J + o2[1] + PERM[o2[2] + K]]] % 12;\n    g[3] = PERM[I + 1 + PERM[J + 1 + PERM[K + 1]]] % 12; \n\n    for (c = 0; c <= 3; c++) {\n        f[c] = 0.6f - pos[c][0] * pos[c][0] - pos[c][1] * pos[c][1] -\n            pos[c][2] * pos[c][2];\n    }\n    \n    for (c = 0; c <= 3; c++) {\n        if (f[c] > 0) {\n            noise[c] = f[c] * f[c] * f[c] * f[c] * DOT3(pos[c], GRAD3[g[c]]);\n        }\n    }\n    \n    return (noise[0] + noise[1] + noise[2] + noise[3]) * 32.0f;\n}\n\nfloat simplex2(\n    float x, float y,\n    int octaves, float persistence, float lacunarity)\n{\n    float freq = 1.0f;\n    float amp = 1.0f;\n    float max = 1.0f;\n    float total = noise2(x, y);\n    int i;\n    for (i = 1; i < octaves; i++) {\n        freq *= lacunarity;\n        amp *= persistence;\n        max += amp;\n        total += noise2(x * freq, y * freq) * amp;\n    }\n    return (1 + total / max) / 2;\n}\n\nfloat simplex3(\n    float x, float y, float z,\n    int octaves, float persistence, float lacunarity)\n{\n    float freq = 1.0f;\n    float amp = 1.0f;\n    float max = 1.0f;\n    float total = noise3(x, y, z);\n    int i;\n    for (i = 1; i < octaves; ++i) {\n        freq *= lacunarity;\n        amp *= persistence;\n        max += amp;\n        total += noise3(x * freq, y * freq, z * freq) * amp;\n    }\n    return (1 + total / max) / 2;\n}\n"
  },
  {
    "path": "deps/noise/noise.h",
    "content": "/*\nnoise.h and noise.c are derived from this project:\n\nhttps://github.com/caseman/noise\n\nCopyright (c) 2008 Casey Duncan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#ifndef _noise_h_\n#define _noise_h_\n\nvoid seed(unsigned int x);\n\nfloat simplex2(\n    float x, float y,\n    int octaves, float persistence, float lacunarity);\n\nfloat simplex3(\n    float x, float y, float z,\n    int octaves, float persistence, float lacunarity);\n\n#endif\n"
  },
  {
    "path": "deps/sqlite/shell.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement the \"sqlite\" command line\n** utility for accessing SQLite databases.\n*/\n#if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)\n/* This needs to come before any includes for MSVC compiler */\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n/*\n** Enable large-file support for fopen() and friends on unix.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n#include <assert.h>\n#include \"sqlite3.h\"\n#include <ctype.h>\n#include <stdarg.h>\n\n#if !defined(_WIN32) && !defined(WIN32)\n# include <signal.h>\n# if !defined(__RTP__) && !defined(_WRS_KERNEL)\n#  include <pwd.h>\n# endif\n# include <unistd.h>\n# include <sys/types.h>\n#endif\n\n#ifdef HAVE_EDITLINE\n# include <editline/editline.h>\n#endif\n#if defined(HAVE_READLINE) && HAVE_READLINE==1\n# include <readline/readline.h>\n# include <readline/history.h>\n#endif\n#if !defined(HAVE_EDITLINE) && (!defined(HAVE_READLINE) || HAVE_READLINE!=1)\n# define readline(p) local_getline(p,stdin,0)\n# define add_history(X)\n# define read_history(X)\n# define write_history(X)\n# define stifle_history(X)\n#endif\n\n#if defined(_WIN32) || defined(WIN32)\n# include <io.h>\n#define isatty(h) _isatty(h)\n#define access(f,m) _access((f),(m))\n#undef popen\n#define popen(a,b) _popen((a),(b))\n#undef pclose\n#define pclose(x) _pclose(x)\n#else\n/* Make sure isatty() has a prototype.\n*/\nextern int isatty(int);\n#endif\n\n#if defined(_WIN32_WCE)\n/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()\n * thus we always assume that we have a console. That can be\n * overridden with the -batch command line option.\n */\n#define isatty(x) 1\n#endif\n\n/* True if the timer is enabled */\nstatic int enableTimer = 0;\n\n/* ctype macros that work with signed characters */\n#define IsSpace(X)  isspace((unsigned char)X)\n#define IsDigit(X)  isdigit((unsigned char)X)\n#define ToLower(X)  (char)tolower((unsigned char)X)\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \\\n && !defined(__minux)\n#include <sys/time.h>\n#include <sys/resource.h>\n\n/* Saved resource information for the beginning of an operation */\nstatic struct rusage sBegin;\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer ){\n    getrusage(RUSAGE_SELF, &sBegin);\n  }\n}\n\n/* Return the difference of two time_structs in seconds */\nstatic double timeDiff(struct timeval *pStart, struct timeval *pEnd){\n  return (pEnd->tv_usec - pStart->tv_usec)*0.000001 + \n         (double)(pEnd->tv_sec - pStart->tv_sec);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer ){\n    struct rusage sEnd;\n    getrusage(RUSAGE_SELF, &sEnd);\n    printf(\"CPU Time: user %f sys %f\\n\",\n       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),\n       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER 1\n\n#elif (defined(_WIN32) || defined(WIN32))\n\n#include <windows.h>\n\n/* Saved resource information for the beginning of an operation */\nstatic HANDLE hProcess;\nstatic FILETIME ftKernelBegin;\nstatic FILETIME ftUserBegin;\ntypedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);\nstatic GETPROCTIMES getProcessTimesAddr = NULL;\n\n/*\n** Check to see if we have timer support.  Return 1 if necessary\n** support found (or found previously).\n*/\nstatic int hasTimer(void){\n  if( getProcessTimesAddr ){\n    return 1;\n  } else {\n    /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions.\n    ** See if the version we are running on has it, and if it does, save off\n    ** a pointer to it and the current process handle.\n    */\n    hProcess = GetCurrentProcess();\n    if( hProcess ){\n      HINSTANCE hinstLib = LoadLibrary(TEXT(\"Kernel32.dll\"));\n      if( NULL != hinstLib ){\n        getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, \"GetProcessTimes\");\n        if( NULL != getProcessTimesAddr ){\n          return 1;\n        }\n        FreeLibrary(hinstLib); \n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer && getProcessTimesAddr ){\n    FILETIME ftCreation, ftExit;\n    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);\n  }\n}\n\n/* Return the difference of two FILETIME structs in seconds */\nstatic double timeDiff(FILETIME *pStart, FILETIME *pEnd){\n  sqlite_int64 i64Start = *((sqlite_int64 *) pStart);\n  sqlite_int64 i64End = *((sqlite_int64 *) pEnd);\n  return (double) ((i64End - i64Start) / 10000000.0);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer && getProcessTimesAddr){\n    FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;\n    getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd);\n    printf(\"CPU Time: user %f sys %f\\n\",\n       timeDiff(&ftUserBegin, &ftUserEnd),\n       timeDiff(&ftKernelBegin, &ftKernelEnd));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER hasTimer()\n\n#else\n#define BEGIN_TIMER \n#define END_TIMER\n#define HAS_TIMER 0\n#endif\n\n/*\n** Used to prevent warnings about unused parameters\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** If the following flag is set, then command execution stops\n** at an error if we are not interactive.\n*/\nstatic int bail_on_error = 0;\n\n/*\n** Threat stdin as an interactive input if the following variable\n** is true.  Otherwise, assume stdin is connected to a file or pipe.\n*/\nstatic int stdin_is_interactive = 1;\n\n/*\n** The following is the open SQLite database.  We make a pointer\n** to this database a static variable so that it can be accessed\n** by the SIGINT handler to interrupt database processing.\n*/\nstatic sqlite3 *db = 0;\n\n/*\n** True if an interrupt (Control-C) has been received.\n*/\nstatic volatile int seenInterrupt = 0;\n\n/*\n** This is the name of our program. It is set in main(), used\n** in a number of other places, mostly for error messages.\n*/\nstatic char *Argv0;\n\n/*\n** Prompt strings. Initialized in main. Settable with\n**   .prompt main continue\n*/\nstatic char mainPrompt[20];     /* First line prompt. default: \"sqlite> \"*/\nstatic char continuePrompt[20]; /* Continuation prompt. default: \"   ...> \" */\n\n/*\n** Write I/O traces to the following stream.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic FILE *iotrace = 0;\n#endif\n\n/*\n** This routine works like printf in that its first argument is a\n** format string and subsequent arguments are values to be substituted\n** in place of % fields.  The result of formatting this string\n** is written to iotrace.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic void iotracePrintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  if( iotrace==0 ) return;\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  fprintf(iotrace, \"%s\", z);\n  sqlite3_free(z);\n}\n#endif\n\n\n/*\n** Determines if a string is a number of not.\n*/\nstatic int isNumber(const char *z, int *realnum){\n  if( *z=='-' || *z=='+' ) z++;\n  if( !IsDigit(*z) ){\n    return 0;\n  }\n  z++;\n  if( realnum ) *realnum = 0;\n  while( IsDigit(*z) ){ z++; }\n  if( *z=='.' ){\n    z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  if( *z=='e' || *z=='E' ){\n    z++;\n    if( *z=='+' || *z=='-' ) z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  return *z==0;\n}\n\n/*\n** A global char* and an SQL function to access its current value \n** from within an SQL statement. This program used to use the \n** sqlite_exec_printf() API to substitue a string into an SQL statement.\n** The correct way to do this with sqlite3 is to use the bind API, but\n** since the shell is built around the callback paradigm it would be a lot\n** of work. Instead just use this hack, which is quite harmless.\n*/\nstatic const char *zShellStatic = 0;\nstatic void shellstaticFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( 0==argc );\n  assert( zShellStatic );\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n  sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);\n}\n\n\n/*\n** This routine reads a line of text from FILE in, stores\n** the text in memory obtained from malloc() and returns a pointer\n** to the text.  NULL is returned at end of file, or if malloc()\n** fails.\n**\n** The interface is like \"readline\" but no command-line editing\n** is done.\n*/\nstatic char *local_getline(char *zPrompt, FILE *in, int csvFlag){\n  char *zLine;\n  int nLine;\n  int n;\n  int inQuote = 0;\n\n  if( zPrompt && *zPrompt ){\n    printf(\"%s\",zPrompt);\n    fflush(stdout);\n  }\n  nLine = 100;\n  zLine = malloc( nLine );\n  if( zLine==0 ) return 0;\n  n = 0;\n  while( 1 ){\n    if( n+100>nLine ){\n      nLine = nLine*2 + 100;\n      zLine = realloc(zLine, nLine);\n      if( zLine==0 ) return 0;\n    }\n    if( fgets(&zLine[n], nLine - n, in)==0 ){\n      if( n==0 ){\n        free(zLine);\n        return 0;\n      }\n      zLine[n] = 0;\n      break;\n    }\n    while( zLine[n] ){\n      if( zLine[n]=='\"' ) inQuote = !inQuote;\n      n++;\n    }\n    if( n>0 && zLine[n-1]=='\\n' && (!inQuote || !csvFlag) ){\n      n--;\n      if( n>0 && zLine[n-1]=='\\r' ) n--;\n      zLine[n] = 0;\n      break;\n    }\n  }\n  zLine = realloc( zLine, n+1 );\n  return zLine;\n}\n\n/*\n** Retrieve a single line of input text.\n**\n** zPrior is a string of prior text retrieved.  If not the empty\n** string, then issue a continuation prompt.\n*/\nstatic char *one_input_line(const char *zPrior, FILE *in){\n  char *zPrompt;\n  char *zResult;\n  if( in!=0 ){\n    return local_getline(0, in, 0);\n  }\n  if( zPrior && zPrior[0] ){\n    zPrompt = continuePrompt;\n  }else{\n    zPrompt = mainPrompt;\n  }\n  zResult = readline(zPrompt);\n#if defined(HAVE_READLINE) && HAVE_READLINE==1\n  if( zResult && *zResult ) add_history(zResult);\n#endif\n  return zResult;\n}\n\nstruct previous_mode_data {\n  int valid;        /* Is there legit data in here? */\n  int mode;\n  int showHeader;\n  int colWidth[100];\n};\n\n/*\n** An pointer to an instance of this structure is passed from\n** the main program to the callback.  This is used to communicate\n** state and mode information.\n*/\nstruct callback_data {\n  sqlite3 *db;           /* The database */\n  int echoOn;            /* True to echo input commands */\n  int statsOn;           /* True to display memory stats before each finalize */\n  int cnt;               /* Number of records displayed so far */\n  FILE *out;             /* Write results here */\n  FILE *traceOut;        /* Output for sqlite3_trace() */\n  int nErr;              /* Number of errors seen */\n  int mode;              /* An output mode setting */\n  int writableSchema;    /* True if PRAGMA writable_schema=ON */\n  int showHeader;        /* True to show column names in List or Column mode */\n  char *zDestTable;      /* Name of destination table when MODE_Insert */\n  char separator[20];    /* Separator character for MODE_List */\n  int colWidth[100];     /* Requested width of each column when in column mode*/\n  int actualWidth[100];  /* Actual width of each column */\n  char nullvalue[20];    /* The text to print when a NULL comes back from\n                         ** the database */\n  struct previous_mode_data explainPrev;\n                         /* Holds the mode information just before\n                         ** .explain ON */\n  char outfile[FILENAME_MAX]; /* Filename for *out */\n  const char *zDbFilename;    /* name of the database file */\n  const char *zVfs;           /* Name of VFS to use */\n  sqlite3_stmt *pStmt;   /* Current statement if any. */\n  FILE *pLog;            /* Write log output here */\n};\n\n/*\n** These are the allowed modes.\n*/\n#define MODE_Line     0  /* One column per line.  Blank line between records */\n#define MODE_Column   1  /* One record per line in neat columns */\n#define MODE_List     2  /* One record per line with a separator */\n#define MODE_Semi     3  /* Same as MODE_List but append \";\" to each line */\n#define MODE_Html     4  /* Generate an XHTML table */\n#define MODE_Insert   5  /* Generate SQL \"insert\" statements */\n#define MODE_Tcl      6  /* Generate ANSI-C or TCL quoted elements */\n#define MODE_Csv      7  /* Quote strings, numbers are plain */\n#define MODE_Explain  8  /* Like MODE_Column, but do not truncate data */\n\nstatic const char *modeDescr[] = {\n  \"line\",\n  \"column\",\n  \"list\",\n  \"semi\",\n  \"html\",\n  \"insert\",\n  \"tcl\",\n  \"csv\",\n  \"explain\",\n};\n\n/*\n** Number of elements in an array\n*/\n#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n*/\nstatic int strlen30(const char *z){\n  const char *z2 = z;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n/*\n** A callback for the sqlite3_log() interface.\n*/\nstatic void shellLog(void *pArg, int iErrCode, const char *zMsg){\n  struct callback_data *p = (struct callback_data*)pArg;\n  if( p->pLog==0 ) return;\n  fprintf(p->pLog, \"(%d) %s\\n\", iErrCode, zMsg);\n  fflush(p->pLog);\n}\n\n/*\n** Output the given string as a hex-encoded blob (eg. X'1234' )\n*/\nstatic void output_hex_blob(FILE *out, const void *pBlob, int nBlob){\n  int i;\n  char *zBlob = (char *)pBlob;\n  fprintf(out,\"X'\");\n  for(i=0; i<nBlob; i++){ fprintf(out,\"%02x\",zBlob[i]&0xff); }\n  fprintf(out,\"'\");\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n*/\nstatic void output_quoted_string(FILE *out, const char *z){\n  int i;\n  int nSingle = 0;\n  for(i=0; z[i]; i++){\n    if( z[i]=='\\'' ) nSingle++;\n  }\n  if( nSingle==0 ){\n    fprintf(out,\"'%s'\",z);\n  }else{\n    fprintf(out,\"'\");\n    while( *z ){\n      for(i=0; z[i] && z[i]!='\\''; i++){}\n      if( i==0 ){\n        fprintf(out,\"''\");\n        z++;\n      }else if( z[i]=='\\'' ){\n        fprintf(out,\"%.*s''\",i,z);\n        z += i+1;\n      }else{\n        fprintf(out,\"%s\",z);\n        break;\n      }\n    }\n    fprintf(out,\"'\");\n  }\n}\n\n/*\n** Output the given string as a quoted according to C or TCL quoting rules.\n*/\nstatic void output_c_string(FILE *out, const char *z){\n  unsigned int c;\n  fputc('\"', out);\n  while( (c = *(z++))!=0 ){\n    if( c=='\\\\' ){\n      fputc(c, out);\n      fputc(c, out);\n    }else if( c=='\"' ){\n      fputc('\\\\', out);\n      fputc('\"', out);\n    }else if( c=='\\t' ){\n      fputc('\\\\', out);\n      fputc('t', out);\n    }else if( c=='\\n' ){\n      fputc('\\\\', out);\n      fputc('n', out);\n    }else if( c=='\\r' ){\n      fputc('\\\\', out);\n      fputc('r', out);\n    }else if( !isprint(c) ){\n      fprintf(out, \"\\\\%03o\", c&0xff);\n    }else{\n      fputc(c, out);\n    }\n  }\n  fputc('\"', out);\n}\n\n/*\n** Output the given string with characters that are special to\n** HTML escaped.\n*/\nstatic void output_html_string(FILE *out, const char *z){\n  int i;\n  while( *z ){\n    for(i=0;   z[i] \n            && z[i]!='<' \n            && z[i]!='&' \n            && z[i]!='>' \n            && z[i]!='\\\"' \n            && z[i]!='\\'';\n        i++){}\n    if( i>0 ){\n      fprintf(out,\"%.*s\",i,z);\n    }\n    if( z[i]=='<' ){\n      fprintf(out,\"&lt;\");\n    }else if( z[i]=='&' ){\n      fprintf(out,\"&amp;\");\n    }else if( z[i]=='>' ){\n      fprintf(out,\"&gt;\");\n    }else if( z[i]=='\\\"' ){\n      fprintf(out,\"&quot;\");\n    }else if( z[i]=='\\'' ){\n      fprintf(out,\"&#39;\");\n    }else{\n      break;\n    }\n    z += i + 1;\n  }\n}\n\n/*\n** If a field contains any character identified by a 1 in the following\n** array, then the string must be quoted for CSV.\n*/\nstatic const char needCsvQuote[] = {\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0, \n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, \n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, \n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, \n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0, \n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1, \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   \n};\n\n/*\n** Output a single term of CSV.  Actually, p->separator is used for\n** the separator, which may or may not be a comma.  p->nullvalue is\n** the null value.  Strings are quoted if necessary.\n*/\nstatic void output_csv(struct callback_data *p, const char *z, int bSep){\n  FILE *out = p->out;\n  if( z==0 ){\n    fprintf(out,\"%s\",p->nullvalue);\n  }else{\n    int i;\n    int nSep = strlen30(p->separator);\n    for(i=0; z[i]; i++){\n      if( needCsvQuote[((unsigned char*)z)[i]] \n         || (z[i]==p->separator[0] && \n             (nSep==1 || memcmp(z, p->separator, nSep)==0)) ){\n        i = 0;\n        break;\n      }\n    }\n    if( i==0 ){\n      putc('\"', out);\n      for(i=0; z[i]; i++){\n        if( z[i]=='\"' ) putc('\"', out);\n        putc(z[i], out);\n      }\n      putc('\"', out);\n    }else{\n      fprintf(out, \"%s\", z);\n    }\n  }\n  if( bSep ){\n    fprintf(p->out, \"%s\", p->separator);\n  }\n}\n\n#ifdef SIGINT\n/*\n** This routine runs when the user presses Ctrl-C\n*/\nstatic void interrupt_handler(int NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  seenInterrupt = 1;\n  if( db ) sqlite3_interrupt(db);\n}\n#endif\n\n/*\n** This is the callback routine that the shell\n** invokes for each row of a query result.\n*/\nstatic int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){\n  int i;\n  struct callback_data *p = (struct callback_data*)pArg;\n\n  switch( p->mode ){\n    case MODE_Line: {\n      int w = 5;\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int len = strlen30(azCol[i] ? azCol[i] : \"\");\n        if( len>w ) w = len;\n      }\n      if( p->cnt++>0 ) fprintf(p->out,\"\\n\");\n      for(i=0; i<nArg; i++){\n        fprintf(p->out,\"%*s = %s\\n\", w, azCol[i],\n                azArg[i] ? azArg[i] : p->nullvalue);\n      }\n      break;\n    }\n    case MODE_Explain:\n    case MODE_Column: {\n      if( p->cnt++==0 ){\n        for(i=0; i<nArg; i++){\n          int w, n;\n          if( i<ArraySize(p->colWidth) ){\n            w = p->colWidth[i];\n          }else{\n            w = 0;\n          }\n          if( w==0 ){\n            w = strlen30(azCol[i] ? azCol[i] : \"\");\n            if( w<10 ) w = 10;\n            n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);\n            if( w<n ) w = n;\n          }\n          if( i<ArraySize(p->actualWidth) ){\n            p->actualWidth[i] = w;\n          }\n          if( p->showHeader ){\n            if( w<0 ){\n              fprintf(p->out,\"%*.*s%s\",-w,-w,azCol[i], i==nArg-1 ? \"\\n\": \"  \");\n            }else{\n              fprintf(p->out,\"%-*.*s%s\",w,w,azCol[i], i==nArg-1 ? \"\\n\": \"  \");\n            }\n          }\n        }\n        if( p->showHeader ){\n          for(i=0; i<nArg; i++){\n            int w;\n            if( i<ArraySize(p->actualWidth) ){\n               w = p->actualWidth[i];\n               if( w<0 ) w = -w;\n            }else{\n               w = 10;\n            }\n            fprintf(p->out,\"%-*.*s%s\",w,w,\"-----------------------------------\"\n                   \"----------------------------------------------------------\",\n                    i==nArg-1 ? \"\\n\": \"  \");\n          }\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int w;\n        if( i<ArraySize(p->actualWidth) ){\n           w = p->actualWidth[i];\n        }else{\n           w = 10;\n        }\n        if( p->mode==MODE_Explain && azArg[i] && \n           strlen30(azArg[i])>w ){\n          w = strlen30(azArg[i]);\n        }\n        if( w<0 ){\n          fprintf(p->out,\"%*.*s%s\",-w,-w,\n              azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? \"\\n\": \"  \");\n        }else{\n          fprintf(p->out,\"%-*.*s%s\",w,w,\n              azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? \"\\n\": \"  \");\n        }\n      }\n      break;\n    }\n    case MODE_Semi:\n    case MODE_List: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          fprintf(p->out,\"%s%s\",azCol[i], i==nArg-1 ? \"\\n\" : p->separator);\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        char *z = azArg[i];\n        if( z==0 ) z = p->nullvalue;\n        fprintf(p->out, \"%s\", z);\n        if( i<nArg-1 ){\n          fprintf(p->out, \"%s\", p->separator);\n        }else if( p->mode==MODE_Semi ){\n          fprintf(p->out, \";\\n\");\n        }else{\n          fprintf(p->out, \"\\n\");\n        }\n      }\n      break;\n    }\n    case MODE_Html: {\n      if( p->cnt++==0 && p->showHeader ){\n        fprintf(p->out,\"<TR>\");\n        for(i=0; i<nArg; i++){\n          fprintf(p->out,\"<TH>\");\n          output_html_string(p->out, azCol[i]);\n          fprintf(p->out,\"</TH>\\n\");\n        }\n        fprintf(p->out,\"</TR>\\n\");\n      }\n      if( azArg==0 ) break;\n      fprintf(p->out,\"<TR>\");\n      for(i=0; i<nArg; i++){\n        fprintf(p->out,\"<TD>\");\n        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);\n        fprintf(p->out,\"</TD>\\n\");\n      }\n      fprintf(p->out,\"</TR>\\n\");\n      break;\n    }\n    case MODE_Tcl: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_c_string(p->out,azCol[i] ? azCol[i] : \"\");\n          if(i<nArg-1) fprintf(p->out, \"%s\", p->separator);\n        }\n        fprintf(p->out,\"\\n\");\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);\n        if(i<nArg-1) fprintf(p->out, \"%s\", p->separator);\n      }\n      fprintf(p->out,\"\\n\");\n      break;\n    }\n    case MODE_Csv: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_csv(p, azCol[i] ? azCol[i] : \"\", i<nArg-1);\n        }\n        fprintf(p->out,\"\\n\");\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        output_csv(p, azArg[i], i<nArg-1);\n      }\n      fprintf(p->out,\"\\n\");\n      break;\n    }\n    case MODE_Insert: {\n      p->cnt++;\n      if( azArg==0 ) break;\n      fprintf(p->out,\"INSERT INTO %s VALUES(\",p->zDestTable);\n      for(i=0; i<nArg; i++){\n        char *zSep = i>0 ? \",\": \"\";\n        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){\n          fprintf(p->out,\"%sNULL\",zSep);\n        }else if( aiType && aiType[i]==SQLITE_TEXT ){\n          if( zSep[0] ) fprintf(p->out,\"%s\",zSep);\n          output_quoted_string(p->out, azArg[i]);\n        }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){\n          fprintf(p->out,\"%s%s\",zSep, azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){\n          const void *pBlob = sqlite3_column_blob(p->pStmt, i);\n          int nBlob = sqlite3_column_bytes(p->pStmt, i);\n          if( zSep[0] ) fprintf(p->out,\"%s\",zSep);\n          output_hex_blob(p->out, pBlob, nBlob);\n        }else if( isNumber(azArg[i], 0) ){\n          fprintf(p->out,\"%s%s\",zSep, azArg[i]);\n        }else{\n          if( zSep[0] ) fprintf(p->out,\"%s\",zSep);\n          output_quoted_string(p->out, azArg[i]);\n        }\n      }\n      fprintf(p->out,\");\\n\");\n      break;\n    }\n  }\n  return 0;\n}\n\n/*\n** This is the callback routine that the SQLite library\n** invokes for each row of a query result.\n*/\nstatic int callback(void *pArg, int nArg, char **azArg, char **azCol){\n  /* since we don't have type info, call the shell_callback with a NULL value */\n  return shell_callback(pArg, nArg, azArg, azCol, NULL);\n}\n\n/*\n** Set the destination table field of the callback_data structure to\n** the name of the table given.  Escape any quote characters in the\n** table name.\n*/\nstatic void set_table_name(struct callback_data *p, const char *zName){\n  int i, n;\n  int needQuote;\n  char *z;\n\n  if( p->zDestTable ){\n    free(p->zDestTable);\n    p->zDestTable = 0;\n  }\n  if( zName==0 ) return;\n  needQuote = !isalpha((unsigned char)*zName) && *zName!='_';\n  for(i=n=0; zName[i]; i++, n++){\n    if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ){\n      needQuote = 1;\n      if( zName[i]=='\\'' ) n++;\n    }\n  }\n  if( needQuote ) n += 2;\n  z = p->zDestTable = malloc( n+1 );\n  if( z==0 ){\n    fprintf(stderr,\"Error: out of memory\\n\");\n    exit(1);\n  }\n  n = 0;\n  if( needQuote ) z[n++] = '\\'';\n  for(i=0; zName[i]; i++){\n    z[n++] = zName[i];\n    if( zName[i]=='\\'' ) z[n++] = '\\'';\n  }\n  if( needQuote ) z[n++] = '\\'';\n  z[n] = 0;\n}\n\n/* zIn is either a pointer to a NULL-terminated string in memory obtained\n** from malloc(), or a NULL pointer. The string pointed to by zAppend is\n** added to zIn, and the result returned in memory obtained from malloc().\n** zIn, if it was not NULL, is freed.\n**\n** If the third argument, quote, is not '\\0', then it is used as a \n** quote character for zAppend.\n*/\nstatic char *appendText(char *zIn, char const *zAppend, char quote){\n  int len;\n  int i;\n  int nAppend = strlen30(zAppend);\n  int nIn = (zIn?strlen30(zIn):0);\n\n  len = nAppend+nIn+1;\n  if( quote ){\n    len += 2;\n    for(i=0; i<nAppend; i++){\n      if( zAppend[i]==quote ) len++;\n    }\n  }\n\n  zIn = (char *)realloc(zIn, len);\n  if( !zIn ){\n    return 0;\n  }\n\n  if( quote ){\n    char *zCsr = &zIn[nIn];\n    *zCsr++ = quote;\n    for(i=0; i<nAppend; i++){\n      *zCsr++ = zAppend[i];\n      if( zAppend[i]==quote ) *zCsr++ = quote;\n    }\n    *zCsr++ = quote;\n    *zCsr++ = '\\0';\n    assert( (zCsr-zIn)==len );\n  }else{\n    memcpy(&zIn[nIn], zAppend, nAppend);\n    zIn[len-1] = '\\0';\n  }\n\n  return zIn;\n}\n\n\n/*\n** Execute a query statement that will generate SQL output.  Print\n** the result columns, comma-separated, on a line and then add a\n** semicolon terminator to the end of that line.\n**\n** If the number of columns is 1 and that column contains text \"--\"\n** then write the semicolon on a separate line.  That way, if a \n** \"--\" comment occurs at the end of the statement, the comment\n** won't consume the semicolon terminator.\n*/\nstatic int run_table_dump_query(\n  struct callback_data *p, /* Query context */\n  const char *zSelect,     /* SELECT statement to extract content */\n  const char *zFirstRow    /* Print before first row, if not NULL */\n){\n  sqlite3_stmt *pSelect;\n  int rc;\n  int nResult;\n  int i;\n  const char *z;\n  rc = sqlite3_prepare(p->db, zSelect, -1, &pSelect, 0);\n  if( rc!=SQLITE_OK || !pSelect ){\n    fprintf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc, sqlite3_errmsg(p->db));\n    p->nErr++;\n    return rc;\n  }\n  rc = sqlite3_step(pSelect);\n  nResult = sqlite3_column_count(pSelect);\n  while( rc==SQLITE_ROW ){\n    if( zFirstRow ){\n      fprintf(p->out, \"%s\", zFirstRow);\n      zFirstRow = 0;\n    }\n    z = (const char*)sqlite3_column_text(pSelect, 0);\n    fprintf(p->out, \"%s\", z);\n    for(i=1; i<nResult; i++){ \n      fprintf(p->out, \",%s\", sqlite3_column_text(pSelect, i));\n    }\n    if( z==0 ) z = \"\";\n    while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;\n    if( z[0] ){\n      fprintf(p->out, \"\\n;\\n\");\n    }else{\n      fprintf(p->out, \";\\n\");\n    }    \n    rc = sqlite3_step(pSelect);\n  }\n  rc = sqlite3_finalize(pSelect);\n  if( rc!=SQLITE_OK ){\n    fprintf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc, sqlite3_errmsg(p->db));\n    p->nErr++;\n  }\n  return rc;\n}\n\n/*\n** Allocate space and save off current error string.\n*/\nstatic char *save_err_msg(\n  sqlite3 *db            /* Database to query */\n){\n  int nErrMsg = 1+strlen30(sqlite3_errmsg(db));\n  char *zErrMsg = sqlite3_malloc(nErrMsg);\n  if( zErrMsg ){\n    memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);\n  }\n  return zErrMsg;\n}\n\n/*\n** Display memory stats.\n*/\nstatic int display_stats(\n  sqlite3 *db,                /* Database to query */\n  struct callback_data *pArg, /* Pointer to struct callback_data */\n  int bReset                  /* True to reset the stats */\n){\n  int iCur;\n  int iHiwtr;\n\n  if( pArg && pArg->out ){\n    \n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Memory Used:                         %d (max %d) bytes\\n\", iCur, iHiwtr);\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Number of Outstanding Allocations:   %d (max %d)\\n\", iCur, iHiwtr);\n/*\n** Not currently used by the CLI.\n**    iHiwtr = iCur = -1;\n**    sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);\n**    fprintf(pArg->out, \"Number of Pcache Pages Used:         %d (max %d) pages\\n\", iCur, iHiwtr);\n*/\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Number of Pcache Overflow Bytes:     %d (max %d) bytes\\n\", iCur, iHiwtr);\n/*\n** Not currently used by the CLI.\n**    iHiwtr = iCur = -1;\n**    sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);\n**    fprintf(pArg->out, \"Number of Scratch Allocations Used:  %d (max %d)\\n\", iCur, iHiwtr);\n*/\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Number of Scratch Overflow Bytes:    %d (max %d) bytes\\n\", iCur, iHiwtr);\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Largest Allocation:                  %d bytes\\n\", iHiwtr);\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Largest Pcache Allocation:           %d bytes\\n\", iHiwtr);\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Largest Scratch Allocation:          %d bytes\\n\", iHiwtr);\n#ifdef YYTRACKMAXSTACKDEPTH\n    iHiwtr = iCur = -1;\n    sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Deepest Parser Stack:                %d (max %d)\\n\", iCur, iHiwtr);\n#endif\n  }\n\n  if( pArg && pArg->out && db ){\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Lookaside Slots Used:                %d (max %d)\\n\", iCur, iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Successful lookaside attempts:       %d\\n\", iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Lookaside failures due to size:      %d\\n\", iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Lookaside failures due to OOM:       %d\\n\", iHiwtr);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Pager Heap Usage:                    %d bytes\\n\", iCur);    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);\n    fprintf(pArg->out, \"Page cache hits:                     %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);\n    fprintf(pArg->out, \"Page cache misses:                   %d\\n\", iCur); \n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);\n    fprintf(pArg->out, \"Page cache writes:                   %d\\n\", iCur); \n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Schema Heap Usage:                   %d bytes\\n\", iCur); \n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);\n    fprintf(pArg->out, \"Statement Heap/Lookaside Usage:      %d bytes\\n\", iCur); \n  }\n\n  if( pArg && pArg->out && db && pArg->pStmt ){\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);\n    fprintf(pArg->out, \"Fullscan Steps:                      %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);\n    fprintf(pArg->out, \"Sort Operations:                     %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);\n    fprintf(pArg->out, \"Autoindex Inserts:                   %d\\n\", iCur);\n  }\n\n  return 0;\n}\n\n/*\n** Execute a statement or set of statements.  Print \n** any result rows/columns depending on the current mode \n** set via the supplied callback.\n**\n** This is very similar to SQLite's built-in sqlite3_exec() \n** function except it takes a slightly different callback \n** and callback data argument.\n*/\nstatic int shell_exec(\n  sqlite3 *db,                                /* An open database */\n  const char *zSql,                           /* SQL to be evaluated */\n  int (*xCallback)(void*,int,char**,char**,int*),   /* Callback function */\n                                              /* (not the same as sqlite3_exec) */\n  struct callback_data *pArg,                 /* Pointer to struct callback_data */\n  char **pzErrMsg                             /* Error msg written here */\n){\n  sqlite3_stmt *pStmt = NULL;     /* Statement to execute. */\n  int rc = SQLITE_OK;             /* Return Code */\n  int rc2;\n  const char *zLeftover;          /* Tail of unprocessed SQL */\n\n  if( pzErrMsg ){\n    *pzErrMsg = NULL;\n  }\n\n  while( zSql[0] && (SQLITE_OK == rc) ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    if( SQLITE_OK != rc ){\n      if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n    }else{\n      if( !pStmt ){\n        /* this happens for a comment or white-space */\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n        continue;\n      }\n\n      /* save off the prepared statment handle and reset row count */\n      if( pArg ){\n        pArg->pStmt = pStmt;\n        pArg->cnt = 0;\n      }\n\n      /* echo the sql statement if echo on */\n      if( pArg && pArg->echoOn ){\n        const char *zStmtSql = sqlite3_sql(pStmt);\n        fprintf(pArg->out, \"%s\\n\", zStmtSql ? zStmtSql : zSql);\n      }\n\n      /* Output TESTCTRL_EXPLAIN text of requested */\n      if( pArg && pArg->mode==MODE_Explain ){\n        const char *zExplain = 0;\n        sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);\n        if( zExplain && zExplain[0] ){\n          fprintf(pArg->out, \"%s\", zExplain);\n        }\n      }\n\n      /* perform the first step.  this will tell us if we\n      ** have a result set or not and how wide it is.\n      */\n      rc = sqlite3_step(pStmt);\n      /* if we have a result set... */\n      if( SQLITE_ROW == rc ){\n        /* if we have a callback... */\n        if( xCallback ){\n          /* allocate space for col name ptr, value ptr, and type */\n          int nCol = sqlite3_column_count(pStmt);\n          void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1);\n          if( !pData ){\n            rc = SQLITE_NOMEM;\n          }else{\n            char **azCols = (char **)pData;      /* Names of result columns */\n            char **azVals = &azCols[nCol];       /* Results */\n            int *aiTypes = (int *)&azVals[nCol]; /* Result types */\n            int i;\n            assert(sizeof(int) <= sizeof(char *)); \n            /* save off ptrs to column names */\n            for(i=0; i<nCol; i++){\n              azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n            }\n            do{\n              /* extract the data and data types */\n              for(i=0; i<nCol; i++){\n                azVals[i] = (char *)sqlite3_column_text(pStmt, i);\n                aiTypes[i] = sqlite3_column_type(pStmt, i);\n                if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){\n                  rc = SQLITE_NOMEM;\n                  break; /* from for */\n                }\n              } /* end for */\n\n              /* if data and types extracted successfully... */\n              if( SQLITE_ROW == rc ){ \n                /* call the supplied callback with the result row data */\n                if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){\n                  rc = SQLITE_ABORT;\n                }else{\n                  rc = sqlite3_step(pStmt);\n                }\n              }\n            } while( SQLITE_ROW == rc );\n            sqlite3_free(pData);\n          }\n        }else{\n          do{\n            rc = sqlite3_step(pStmt);\n          } while( rc == SQLITE_ROW );\n        }\n      }\n\n      /* print usage stats if stats on */\n      if( pArg && pArg->statsOn ){\n        display_stats(db, pArg, 0);\n      }\n\n      /* Finalize the statement just executed. If this fails, save a \n      ** copy of the error message. Otherwise, set zSql to point to the\n      ** next statement to execute. */\n      rc2 = sqlite3_finalize(pStmt);\n      if( rc!=SQLITE_NOMEM ) rc = rc2;\n      if( rc==SQLITE_OK ){\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n      }else if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n\n      /* clear saved stmt handle */\n      if( pArg ){\n        pArg->pStmt = NULL;\n      }\n    }\n  } /* end while */\n\n  return rc;\n}\n\n\n/*\n** This is a different callback routine used for dumping the database.\n** Each row received by this callback consists of a table name,\n** the table type (\"index\" or \"table\") and SQL to create the table.\n** This routine should print text sufficient to recreate the table.\n*/\nstatic int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){\n  int rc;\n  const char *zTable;\n  const char *zType;\n  const char *zSql;\n  const char *zPrepStmt = 0;\n  struct callback_data *p = (struct callback_data *)pArg;\n\n  UNUSED_PARAMETER(azCol);\n  if( nArg!=3 ) return 1;\n  zTable = azArg[0];\n  zType = azArg[1];\n  zSql = azArg[2];\n  \n  if( strcmp(zTable, \"sqlite_sequence\")==0 ){\n    zPrepStmt = \"DELETE FROM sqlite_sequence;\\n\";\n  }else if( strcmp(zTable, \"sqlite_stat1\")==0 ){\n    fprintf(p->out, \"ANALYZE sqlite_master;\\n\");\n  }else if( strncmp(zTable, \"sqlite_\", 7)==0 ){\n    return 0;\n  }else if( strncmp(zSql, \"CREATE VIRTUAL TABLE\", 20)==0 ){\n    char *zIns;\n    if( !p->writableSchema ){\n      fprintf(p->out, \"PRAGMA writable_schema=ON;\\n\");\n      p->writableSchema = 1;\n    }\n    zIns = sqlite3_mprintf(\n       \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n       \"VALUES('table','%q','%q',0,'%q');\",\n       zTable, zTable, zSql);\n    fprintf(p->out, \"%s\\n\", zIns);\n    sqlite3_free(zIns);\n    return 0;\n  }else{\n    fprintf(p->out, \"%s;\\n\", zSql);\n  }\n\n  if( strcmp(zType, \"table\")==0 ){\n    sqlite3_stmt *pTableInfo = 0;\n    char *zSelect = 0;\n    char *zTableInfo = 0;\n    char *zTmp = 0;\n    int nRow = 0;\n   \n    zTableInfo = appendText(zTableInfo, \"PRAGMA table_info(\", 0);\n    zTableInfo = appendText(zTableInfo, zTable, '\"');\n    zTableInfo = appendText(zTableInfo, \");\", 0);\n\n    rc = sqlite3_prepare(p->db, zTableInfo, -1, &pTableInfo, 0);\n    free(zTableInfo);\n    if( rc!=SQLITE_OK || !pTableInfo ){\n      return 1;\n    }\n\n    zSelect = appendText(zSelect, \"SELECT 'INSERT INTO ' || \", 0);\n    /* Always quote the table name, even if it appears to be pure ascii,\n    ** in case it is a keyword. Ex:  INSERT INTO \"table\" ... */\n    zTmp = appendText(zTmp, zTable, '\"');\n    if( zTmp ){\n      zSelect = appendText(zSelect, zTmp, '\\'');\n      free(zTmp);\n    }\n    zSelect = appendText(zSelect, \" || ' VALUES(' || \", 0);\n    rc = sqlite3_step(pTableInfo);\n    while( rc==SQLITE_ROW ){\n      const char *zText = (const char *)sqlite3_column_text(pTableInfo, 1);\n      zSelect = appendText(zSelect, \"quote(\", 0);\n      zSelect = appendText(zSelect, zText, '\"');\n      rc = sqlite3_step(pTableInfo);\n      if( rc==SQLITE_ROW ){\n        zSelect = appendText(zSelect, \"), \", 0);\n      }else{\n        zSelect = appendText(zSelect, \") \", 0);\n      }\n      nRow++;\n    }\n    rc = sqlite3_finalize(pTableInfo);\n    if( rc!=SQLITE_OK || nRow==0 ){\n      free(zSelect);\n      return 1;\n    }\n    zSelect = appendText(zSelect, \"|| ')' FROM  \", 0);\n    zSelect = appendText(zSelect, zTable, '\"');\n\n    rc = run_table_dump_query(p, zSelect, zPrepStmt);\n    if( rc==SQLITE_CORRUPT ){\n      zSelect = appendText(zSelect, \" ORDER BY rowid DESC\", 0);\n      run_table_dump_query(p, zSelect, 0);\n    }\n    free(zSelect);\n  }\n  return 0;\n}\n\n/*\n** Run zQuery.  Use dump_callback() as the callback routine so that\n** the contents of the query are output as SQL statements.\n**\n** If we get a SQLITE_CORRUPT error, rerun the query after appending\n** \"ORDER BY rowid DESC\" to the end.\n*/\nstatic int run_schema_dump_query(\n  struct callback_data *p, \n  const char *zQuery\n){\n  int rc;\n  char *zErr = 0;\n  rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);\n  if( rc==SQLITE_CORRUPT ){\n    char *zQ2;\n    int len = strlen30(zQuery);\n    fprintf(p->out, \"/****** CORRUPTION ERROR *******/\\n\");\n    if( zErr ){\n      fprintf(p->out, \"/****** %s ******/\\n\", zErr);\n      sqlite3_free(zErr);\n      zErr = 0;\n    }\n    zQ2 = malloc( len+100 );\n    if( zQ2==0 ) return rc;\n    sqlite3_snprintf(len+100, zQ2, \"%s ORDER BY rowid DESC\", zQuery);\n    rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);\n    if( rc ){\n      fprintf(p->out, \"/****** ERROR: %s ******/\\n\", zErr);\n    }else{\n      rc = SQLITE_CORRUPT;\n    }\n    sqlite3_free(zErr);\n    free(zQ2);\n  }\n  return rc;\n}\n\n/*\n** Text of a help message\n*/\nstatic char zHelp[] =\n  \".backup ?DB? FILE      Backup DB (default \\\"main\\\") to FILE\\n\"\n  \".bail ON|OFF           Stop after hitting an error.  Default OFF\\n\"\n  \".databases             List names and files of attached databases\\n\"\n  \".dump ?TABLE? ...      Dump the database in an SQL text format\\n\"\n  \"                         If TABLE specified, only dump tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".echo ON|OFF           Turn command echo on or off\\n\"\n  \".exit                  Exit this program\\n\"\n  \".explain ?ON|OFF?      Turn output mode suitable for EXPLAIN on or off.\\n\"\n  \"                         With no args, it turns EXPLAIN on.\\n\"\n  \".header(s) ON|OFF      Turn display of headers on or off\\n\"\n  \".help                  Show this message\\n\"\n  \".import FILE TABLE     Import data from FILE into TABLE\\n\"\n  \".indices ?TABLE?       Show names of all indices\\n\"\n  \"                         If TABLE specified, only show indices for tables\\n\"\n  \"                         matching LIKE pattern TABLE.\\n\"\n#ifdef SQLITE_ENABLE_IOTRACE\n  \".iotrace FILE          Enable I/O diagnostic logging to FILE\\n\"\n#endif\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  \".load FILE ?ENTRY?     Load an extension library\\n\"\n#endif\n  \".log FILE|off          Turn logging on or off.  FILE can be stderr/stdout\\n\"\n  \".mode MODE ?TABLE?     Set output mode where MODE is one of:\\n\"\n  \"                         csv      Comma-separated values\\n\"\n  \"                         column   Left-aligned columns.  (See .width)\\n\"\n  \"                         html     HTML <table> code\\n\"\n  \"                         insert   SQL insert statements for TABLE\\n\"\n  \"                         line     One value per line\\n\"\n  \"                         list     Values delimited by .separator string\\n\"\n  \"                         tabs     Tab-separated values\\n\"\n  \"                         tcl      TCL list elements\\n\"\n  \".nullvalue STRING      Use STRING in place of NULL values\\n\"\n  \".output FILENAME       Send output to FILENAME\\n\"\n  \".output stdout         Send output to the screen\\n\"\n  \".print STRING...       Print literal STRING\\n\"\n  \".prompt MAIN CONTINUE  Replace the standard prompts\\n\"\n  \".quit                  Exit this program\\n\"\n  \".read FILENAME         Execute SQL in FILENAME\\n\"\n  \".restore ?DB? FILE     Restore content of DB (default \\\"main\\\") from FILE\\n\"\n  \".schema ?TABLE?        Show the CREATE statements\\n\"\n  \"                         If TABLE specified, only show tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".separator STRING      Change separator used by output mode and .import\\n\"\n  \".show                  Show the current values for various settings\\n\"\n  \".stats ON|OFF          Turn stats on or off\\n\"\n  \".tables ?TABLE?        List names of tables\\n\"\n  \"                         If TABLE specified, only list tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".timeout MS            Try opening locked tables for MS milliseconds\\n\"\n  \".trace FILE|off        Output each SQL statement as it is run\\n\"\n  \".vfsname ?AUX?         Print the name of the VFS stack\\n\"\n  \".width NUM1 NUM2 ...   Set column widths for \\\"column\\\" mode\\n\"\n;\n\nstatic char zTimerHelp[] =\n  \".timer ON|OFF          Turn the CPU timer measurement on or off\\n\"\n;\n\n/* Forward reference */\nstatic int process_input(struct callback_data *p, FILE *in);\n\n/*\n** Make sure the database is open.  If it is not, then open it.  If\n** the database fails to open, print an error message and exit.\n*/\nstatic void open_db(struct callback_data *p){\n  if( p->db==0 ){\n    sqlite3_initialize();\n    sqlite3_open(p->zDbFilename, &p->db);\n    db = p->db;\n    if( db && sqlite3_errcode(db)==SQLITE_OK ){\n      sqlite3_create_function(db, \"shellstatic\", 0, SQLITE_UTF8, 0,\n          shellstaticFunc, 0, 0);\n    }\n    if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){\n      fprintf(stderr,\"Error: unable to open database \\\"%s\\\": %s\\n\", \n          p->zDbFilename, sqlite3_errmsg(db));\n      exit(1);\n    }\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    sqlite3_enable_load_extension(p->db, 1);\n#endif\n  }\n}\n\n/*\n** Do C-language style dequoting.\n**\n**    \\t    -> tab\n**    \\n    -> newline\n**    \\r    -> carriage return\n**    \\NNN  -> ascii character NNN in octal\n**    \\\\    -> backslash\n*/\nstatic void resolve_backslashes(char *z){\n  int i, j;\n  char c;\n  for(i=j=0; (c = z[i])!=0; i++, j++){\n    if( c=='\\\\' ){\n      c = z[++i];\n      if( c=='n' ){\n        c = '\\n';\n      }else if( c=='t' ){\n        c = '\\t';\n      }else if( c=='r' ){\n        c = '\\r';\n      }else if( c>='0' && c<='7' ){\n        c -= '0';\n        if( z[i+1]>='0' && z[i+1]<='7' ){\n          i++;\n          c = (c<<3) + z[i] - '0';\n          if( z[i+1]>='0' && z[i+1]<='7' ){\n            i++;\n            c = (c<<3) + z[i] - '0';\n          }\n        }\n      }\n    }\n    z[j] = c;\n  }\n  z[j] = 0;\n}\n\n/*\n** Interpret zArg as a boolean value.  Return either 0 or 1.\n*/\nstatic int booleanValue(char *zArg){\n  int i;\n  for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}\n  if( i>0 && zArg[i]==0 ) return atoi(zArg);\n  if( sqlite3_stricmp(zArg, \"on\")==0 || sqlite3_stricmp(zArg,\"yes\")==0 ){\n    return 1;\n  }\n  if( sqlite3_stricmp(zArg, \"off\")==0 || sqlite3_stricmp(zArg,\"no\")==0 ){\n    return 0;\n  }\n  fprintf(stderr, \"ERROR: Not a boolean value: \\\"%s\\\". Assuming \\\"no\\\".\\n\",\n          zArg);\n  return 0;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic sqlite3_int64 integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  while( isdigit(zArg[0]) ){\n    v = v*10 + zArg[0] - '0';\n    zArg++;\n  }\n  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  return isNeg? -v : v;\n}\n\n/*\n** Close an output file, assuming it is not stderr or stdout\n*/\nstatic void output_file_close(FILE *f){\n  if( f && f!=stdout && f!=stderr ) fclose(f);\n}\n\n/*\n** Try to open an output file.   The names \"stdout\" and \"stderr\" are\n** recognized and do the right thing.  NULL is returned if the output \n** filename is \"off\".\n*/\nstatic FILE *output_file_open(const char *zFile){\n  FILE *f;\n  if( strcmp(zFile,\"stdout\")==0 ){\n    f = stdout;\n  }else if( strcmp(zFile, \"stderr\")==0 ){\n    f = stderr;\n  }else if( strcmp(zFile, \"off\")==0 ){\n    f = 0;\n  }else{\n    f = fopen(zFile, \"wb\");\n    if( f==0 ){\n      fprintf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n    }\n  }\n  return f;\n}\n\n/*\n** A routine for handling output from sqlite3_trace().\n*/\nstatic void sql_trace_callback(void *pArg, const char *z){\n  FILE *f = (FILE*)pArg;\n  if( f ) fprintf(f, \"%s\\n\", z);\n}\n\n/*\n** A no-op routine that runs with the \".breakpoint\" doc-command.  This is\n** a useful spot to set a debugger breakpoint.\n*/\nstatic void test_breakpoint(void){\n  static int nCall = 0;\n  nCall++;\n}\n\n/*\n** If an input line begins with \".\" then invoke this routine to\n** process that line.\n**\n** Return 1 on error, 2 to exit, and 0 otherwise.\n*/\nstatic int do_meta_command(char *zLine, struct callback_data *p){\n  int i = 1;\n  int nArg = 0;\n  int n, c;\n  int rc = 0;\n  char *azArg[50];\n\n  /* Parse the input line into tokens.\n  */\n  while( zLine[i] && nArg<ArraySize(azArg) ){\n    while( IsSpace(zLine[i]) ){ i++; }\n    if( zLine[i]==0 ) break;\n    if( zLine[i]=='\\'' || zLine[i]=='\"' ){\n      int delim = zLine[i++];\n      azArg[nArg++] = &zLine[i];\n      while( zLine[i] && zLine[i]!=delim ){ i++; }\n      if( zLine[i]==delim ){\n        zLine[i++] = 0;\n      }\n      if( delim=='\"' ) resolve_backslashes(azArg[nArg-1]);\n    }else{\n      azArg[nArg++] = &zLine[i];\n      while( zLine[i] && !IsSpace(zLine[i]) ){ i++; }\n      if( zLine[i] ) zLine[i++] = 0;\n      resolve_backslashes(azArg[nArg-1]);\n    }\n  }\n\n  /* Process the input line.\n  */\n  if( nArg==0 ) return 0; /* no tokens, no error */\n  n = strlen30(azArg[0]);\n  c = azArg[0][0];\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"backup\", n)==0 ){\n    const char *zDestFile = 0;\n    const char *zDb = 0;\n    const char *zKey = 0;\n    sqlite3 *pDest;\n    sqlite3_backup *pBackup;\n    int j;\n    for(j=1; j<nArg; j++){\n      const char *z = azArg[j];\n      if( z[0]=='-' ){\n        while( z[0]=='-' ) z++;\n        if( strcmp(z,\"key\")==0 && j<nArg-1 ){\n          zKey = azArg[++j];\n        }else\n        {\n          fprintf(stderr, \"unknown option: %s\\n\", azArg[j]);\n          return 1;\n        }\n      }else if( zDestFile==0 ){\n        zDestFile = azArg[j];\n      }else if( zDb==0 ){\n        zDb = zDestFile;\n        zDestFile = azArg[j];\n      }else{\n        fprintf(stderr, \"too many arguments to .backup\\n\");\n        return 1;\n      }\n    }\n    if( zDestFile==0 ){\n      fprintf(stderr, \"missing FILENAME argument on .backup\\n\");\n      return 1;\n    }\n    if( zDb==0 ) zDb = \"main\";\n    rc = sqlite3_open(zDestFile, &pDest);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zDestFile);\n      sqlite3_close(pDest);\n      return 1;\n    }\n#ifdef SQLITE_HAS_CODEC\n    sqlite3_key(pDest, zKey, (int)strlen(zKey));\n#else\n    (void)zKey;\n#endif\n    open_db(p);\n    pBackup = sqlite3_backup_init(pDest, \"main\", p->db, zDb);\n    if( pBackup==0 ){\n      fprintf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      sqlite3_close(pDest);\n      return 1;\n    }\n    while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else{\n      fprintf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      rc = 1;\n    }\n    sqlite3_close(pDest);\n  }else\n\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"bail\", n)==0 && nArg>1 && nArg<3 ){\n    bail_on_error = booleanValue(azArg[1]);\n  }else\n\n  /* The undocumented \".breakpoint\" command causes a call to the no-op\n  ** routine named test_breakpoint().\n  */\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"breakpoint\", n)==0 ){\n    test_breakpoint();\n  }else\n\n  if( c=='d' && n>1 && strncmp(azArg[0], \"databases\", n)==0 && nArg==1 ){\n    struct callback_data data;\n    char *zErrMsg = 0;\n    open_db(p);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 1;\n    data.mode = MODE_Column;\n    data.colWidth[0] = 3;\n    data.colWidth[1] = 15;\n    data.colWidth[2] = 58;\n    data.cnt = 0;\n    sqlite3_exec(p->db, \"PRAGMA database_list; \", callback, &data, &zErrMsg);\n    if( zErrMsg ){\n      fprintf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n\n  if( c=='d' && strncmp(azArg[0], \"dump\", n)==0 && nArg<3 ){\n    open_db(p);\n    /* When playing back a \"dump\", the content might appear in an order\n    ** which causes immediate foreign key constraints to be violated.\n    ** So disable foreign-key constraint enforcement to prevent problems. */\n    fprintf(p->out, \"PRAGMA foreign_keys=OFF;\\n\");\n    fprintf(p->out, \"BEGIN TRANSACTION;\\n\");\n    p->writableSchema = 0;\n    sqlite3_exec(p->db, \"SAVEPOINT dump; PRAGMA writable_schema=ON\", 0, 0, 0);\n    p->nErr = 0;\n    if( nArg==1 ){\n      run_schema_dump_query(p, \n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\"\n      );\n      run_schema_dump_query(p, \n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE name=='sqlite_sequence'\"\n      );\n      run_table_dump_query(p,\n        \"SELECT sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type IN ('index','trigger','view')\", 0\n      );\n    }else{\n      int i;\n      for(i=1; i<nArg; i++){\n        zShellStatic = azArg[i];\n        run_schema_dump_query(p,\n          \"SELECT name, type, sql FROM sqlite_master \"\n          \"WHERE tbl_name LIKE shellstatic() AND type=='table'\"\n          \"  AND sql NOT NULL\");\n        run_table_dump_query(p,\n          \"SELECT sql FROM sqlite_master \"\n          \"WHERE sql NOT NULL\"\n          \"  AND type IN ('index','trigger','view')\"\n          \"  AND tbl_name LIKE shellstatic()\", 0\n        );\n        zShellStatic = 0;\n      }\n    }\n    if( p->writableSchema ){\n      fprintf(p->out, \"PRAGMA writable_schema=OFF;\\n\");\n      p->writableSchema = 0;\n    }\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"RELEASE dump;\", 0, 0, 0);\n    fprintf(p->out, p->nErr ? \"ROLLBACK; -- due to errors\\n\" : \"COMMIT;\\n\");\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"echo\", n)==0 && nArg>1 && nArg<3 ){\n    p->echoOn = booleanValue(azArg[1]);\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"exit\", n)==0 ){\n    if( nArg>1 && (rc = atoi(azArg[1]))!=0 ) exit(rc);\n    rc = 2;\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"explain\", n)==0 && nArg<3 ){\n    int val = nArg>=2 ? booleanValue(azArg[1]) : 1;\n    if(val == 1) {\n      if(!p->explainPrev.valid) {\n        p->explainPrev.valid = 1;\n        p->explainPrev.mode = p->mode;\n        p->explainPrev.showHeader = p->showHeader;\n        memcpy(p->explainPrev.colWidth,p->colWidth,sizeof(p->colWidth));\n      }\n      /* We could put this code under the !p->explainValid\n      ** condition so that it does not execute if we are already in\n      ** explain mode. However, always executing it allows us an easy\n      ** was to reset to explain mode in case the user previously\n      ** did an .explain followed by a .width, .mode or .header\n      ** command.\n      */\n      p->mode = MODE_Explain;\n      p->showHeader = 1;\n      memset(p->colWidth,0,ArraySize(p->colWidth));\n      p->colWidth[0] = 4;                  /* addr */\n      p->colWidth[1] = 13;                 /* opcode */\n      p->colWidth[2] = 4;                  /* P1 */\n      p->colWidth[3] = 4;                  /* P2 */\n      p->colWidth[4] = 4;                  /* P3 */\n      p->colWidth[5] = 13;                 /* P4 */\n      p->colWidth[6] = 2;                  /* P5 */\n      p->colWidth[7] = 13;                  /* Comment */\n    }else if (p->explainPrev.valid) {\n      p->explainPrev.valid = 0;\n      p->mode = p->explainPrev.mode;\n      p->showHeader = p->explainPrev.showHeader;\n      memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth));\n    }\n  }else\n\n  if( c=='h' && (strncmp(azArg[0], \"header\", n)==0 ||\n                 strncmp(azArg[0], \"headers\", n)==0) && nArg>1 && nArg<3 ){\n    p->showHeader = booleanValue(azArg[1]);\n  }else\n\n  if( c=='h' && strncmp(azArg[0], \"help\", n)==0 ){\n    fprintf(stderr,\"%s\",zHelp);\n    if( HAS_TIMER ){\n      fprintf(stderr,\"%s\",zTimerHelp);\n    }\n  }else\n\n  if( c=='i' && strncmp(azArg[0], \"import\", n)==0 && nArg==3 ){\n    char *zTable = azArg[2];    /* Insert data into this table */\n    char *zFile = azArg[1];     /* The file from which to extract data */\n    sqlite3_stmt *pStmt = NULL; /* A statement */\n    int nCol;                   /* Number of columns in the table */\n    int nByte;                  /* Number of bytes in an SQL string */\n    int i, j;                   /* Loop counters */\n    int nSep;                   /* Number of bytes in p->separator[] */\n    char *zSql;                 /* An SQL statement */\n    char *zLine;                /* A single line of input from the file */\n    char **azCol;               /* zLine[] broken up into columns */\n    char *zCommit;              /* How to commit changes */   \n    FILE *in;                   /* The input file */\n    int lineno = 0;             /* Line number of input file */\n\n    open_db(p);\n    nSep = strlen30(p->separator);\n    if( nSep==0 ){\n      fprintf(stderr, \"Error: non-null separator required for import\\n\");\n      return 1;\n    }\n    zSql = sqlite3_mprintf(\"SELECT * FROM %s\", zTable);\n    if( zSql==0 ){\n      fprintf(stderr, \"Error: out of memory\\n\");\n      return 1;\n    }\n    nByte = strlen30(zSql);\n    rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      if (pStmt) sqlite3_finalize(pStmt);\n      fprintf(stderr,\"Error: %s\\n\", sqlite3_errmsg(db));\n      return 1;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( nCol==0 ) return 0; /* no columns, no error */\n    zSql = malloc( nByte + 20 + nCol*2 );\n    if( zSql==0 ){\n      fprintf(stderr, \"Error: out of memory\\n\");\n      return 1;\n    }\n    sqlite3_snprintf(nByte+20, zSql, \"INSERT INTO %s VALUES(?\", zTable);\n    j = strlen30(zSql);\n    for(i=1; i<nCol; i++){\n      zSql[j++] = ',';\n      zSql[j++] = '?';\n    }\n    zSql[j++] = ')';\n    zSql[j] = 0;\n    rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n    free(zSql);\n    if( rc ){\n      fprintf(stderr, \"Error: %s\\n\", sqlite3_errmsg(db));\n      if (pStmt) sqlite3_finalize(pStmt);\n      return 1;\n    }\n    in = fopen(zFile, \"rb\");\n    if( in==0 ){\n      fprintf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n      sqlite3_finalize(pStmt);\n      return 1;\n    }\n    azCol = malloc( sizeof(azCol[0])*(nCol+1) );\n    if( azCol==0 ){\n      fprintf(stderr, \"Error: out of memory\\n\");\n      fclose(in);\n      sqlite3_finalize(pStmt);\n      return 1;\n    }\n    sqlite3_exec(p->db, \"BEGIN\", 0, 0, 0);\n    zCommit = \"COMMIT\";\n    while( (zLine = local_getline(0, in, 1))!=0 ){\n      char *z, c;\n      int inQuote = 0;\n      lineno++;\n      azCol[0] = zLine;\n      for(i=0, z=zLine; (c = *z)!=0; z++){\n        if( c=='\"' ) inQuote = !inQuote;\n        if( c=='\\n' ) lineno++;\n        if( !inQuote && c==p->separator[0] && strncmp(z,p->separator,nSep)==0 ){\n          *z = 0;\n          i++;\n          if( i<nCol ){\n            azCol[i] = &z[nSep];\n            z += nSep-1;\n          }\n        }\n      } /* end for */\n      *z = 0;\n      if( i+1!=nCol ){\n        fprintf(stderr,\n                \"Error: %s line %d: expected %d columns of data but found %d\\n\",\n                zFile, lineno, nCol, i+1);\n        zCommit = \"ROLLBACK\";\n        free(zLine);\n        rc = 1;\n        break; /* from while */\n      }\n      for(i=0; i<nCol; i++){\n        if( azCol[i][0]=='\"' ){\n          int k;\n          for(z=azCol[i], j=1, k=0; z[j]; j++){\n            if( z[j]=='\"' ){ j++; if( z[j]==0 ) break; }\n            z[k++] = z[j];\n          }\n          z[k] = 0;\n        }\n        sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC);\n      }\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n      free(zLine);\n      if( rc!=SQLITE_OK ){\n        fprintf(stderr,\"Error: %s\\n\", sqlite3_errmsg(db));\n        zCommit = \"ROLLBACK\";\n        rc = 1;\n        break; /* from while */\n      }\n    } /* end while */\n    free(azCol);\n    fclose(in);\n    sqlite3_finalize(pStmt);\n    sqlite3_exec(p->db, zCommit, 0, 0, 0);\n  }else\n\n  if( c=='i' && strncmp(azArg[0], \"indices\", n)==0 && nArg<3 ){\n    struct callback_data data;\n    char *zErrMsg = 0;\n    open_db(p);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.mode = MODE_List;\n    if( nArg==1 ){\n      rc = sqlite3_exec(p->db,\n        \"SELECT name FROM sqlite_master \"\n        \"WHERE type='index' AND name NOT LIKE 'sqlite_%' \"\n        \"UNION ALL \"\n        \"SELECT name FROM sqlite_temp_master \"\n        \"WHERE type='index' \"\n        \"ORDER BY 1\",\n        callback, &data, &zErrMsg\n      );\n    }else{\n      zShellStatic = azArg[1];\n      rc = sqlite3_exec(p->db,\n        \"SELECT name FROM sqlite_master \"\n        \"WHERE type='index' AND tbl_name LIKE shellstatic() \"\n        \"UNION ALL \"\n        \"SELECT name FROM sqlite_temp_master \"\n        \"WHERE type='index' AND tbl_name LIKE shellstatic() \"\n        \"ORDER BY 1\",\n        callback, &data, &zErrMsg\n      );\n      zShellStatic = 0;\n    }\n    if( zErrMsg ){\n      fprintf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }else if( rc != SQLITE_OK ){\n      fprintf(stderr,\"Error: querying sqlite_master and sqlite_temp_master\\n\");\n      rc = 1;\n    }\n  }else\n\n#ifdef SQLITE_ENABLE_IOTRACE\n  if( c=='i' && strncmp(azArg[0], \"iotrace\", n)==0 ){\n    extern void (*sqlite3IoTrace)(const char*, ...);\n    if( iotrace && iotrace!=stdout ) fclose(iotrace);\n    iotrace = 0;\n    if( nArg<2 ){\n      sqlite3IoTrace = 0;\n    }else if( strcmp(azArg[1], \"-\")==0 ){\n      sqlite3IoTrace = iotracePrintf;\n      iotrace = stdout;\n    }else{\n      iotrace = fopen(azArg[1], \"w\");\n      if( iotrace==0 ){\n        fprintf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n        sqlite3IoTrace = 0;\n        rc = 1;\n      }else{\n        sqlite3IoTrace = iotracePrintf;\n      }\n    }\n  }else\n#endif\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  if( c=='l' && strncmp(azArg[0], \"load\", n)==0 && nArg>=2 ){\n    const char *zFile, *zProc;\n    char *zErrMsg = 0;\n    zFile = azArg[1];\n    zProc = nArg>=3 ? azArg[2] : 0;\n    open_db(p);\n    rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n#endif\n\n  if( c=='l' && strncmp(azArg[0], \"log\", n)==0 && nArg>=2 ){\n    const char *zFile = azArg[1];\n    output_file_close(p->pLog);\n    p->pLog = output_file_open(zFile);\n  }else\n\n  if( c=='m' && strncmp(azArg[0], \"mode\", n)==0 && nArg==2 ){\n    int n2 = strlen30(azArg[1]);\n    if( (n2==4 && strncmp(azArg[1],\"line\",n2)==0)\n        ||\n        (n2==5 && strncmp(azArg[1],\"lines\",n2)==0) ){\n      p->mode = MODE_Line;\n    }else if( (n2==6 && strncmp(azArg[1],\"column\",n2)==0)\n              ||\n              (n2==7 && strncmp(azArg[1],\"columns\",n2)==0) ){\n      p->mode = MODE_Column;\n    }else if( n2==4 && strncmp(azArg[1],\"list\",n2)==0 ){\n      p->mode = MODE_List;\n    }else if( n2==4 && strncmp(azArg[1],\"html\",n2)==0 ){\n      p->mode = MODE_Html;\n    }else if( n2==3 && strncmp(azArg[1],\"tcl\",n2)==0 ){\n      p->mode = MODE_Tcl;\n      sqlite3_snprintf(sizeof(p->separator), p->separator, \" \");\n    }else if( n2==3 && strncmp(azArg[1],\"csv\",n2)==0 ){\n      p->mode = MODE_Csv;\n      sqlite3_snprintf(sizeof(p->separator), p->separator, \",\");\n    }else if( n2==4 && strncmp(azArg[1],\"tabs\",n2)==0 ){\n      p->mode = MODE_List;\n      sqlite3_snprintf(sizeof(p->separator), p->separator, \"\\t\");\n    }else if( n2==6 && strncmp(azArg[1],\"insert\",n2)==0 ){\n      p->mode = MODE_Insert;\n      set_table_name(p, \"table\");\n    }else {\n      fprintf(stderr,\"Error: mode should be one of: \"\n         \"column csv html insert line list tabs tcl\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='m' && strncmp(azArg[0], \"mode\", n)==0 && nArg==3 ){\n    int n2 = strlen30(azArg[1]);\n    if( n2==6 && strncmp(azArg[1],\"insert\",n2)==0 ){\n      p->mode = MODE_Insert;\n      set_table_name(p, azArg[2]);\n    }else {\n      fprintf(stderr, \"Error: invalid arguments: \"\n        \" \\\"%s\\\". Enter \\\".help\\\" for help\\n\", azArg[2]);\n      rc = 1;\n    }\n  }else\n\n  if( c=='n' && strncmp(azArg[0], \"nullvalue\", n)==0 && nArg==2 ) {\n    sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue,\n                     \"%.*s\", (int)ArraySize(p->nullvalue)-1, azArg[1]);\n  }else\n\n  if( c=='o' && strncmp(azArg[0], \"output\", n)==0 && nArg==2 ){\n    if( p->outfile[0]=='|' ){\n      pclose(p->out);\n    }else{\n      output_file_close(p->out);\n    }\n    p->outfile[0] = 0;\n    if( azArg[1][0]=='|' ){\n      p->out = popen(&azArg[1][1], \"w\");\n      if( p->out==0 ){\n        fprintf(stderr,\"Error: cannot open pipe \\\"%s\\\"\\n\", &azArg[1][1]);\n        p->out = stdout;\n        rc = 1;\n      }else{\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", azArg[1]);\n      }\n    }else{\n      p->out = output_file_open(azArg[1]);\n      if( p->out==0 ){\n        if( strcmp(azArg[1],\"off\")!=0 ){\n          fprintf(stderr,\"Error: cannot write to \\\"%s\\\"\\n\", azArg[1]);\n        }\n        p->out = stdout;\n        rc = 1;\n      } else {\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", azArg[1]);\n      }\n    }\n  }else\n\n  if( c=='p' && n>=3 && strncmp(azArg[0], \"print\", n)==0 ){\n    int i;\n    for(i=1; i<nArg; i++){\n      if( i>1 ) fprintf(p->out, \" \");\n      fprintf(p->out, \"%s\", azArg[i]);\n    }\n    fprintf(p->out, \"\\n\");\n  }else\n\n  if( c=='p' && strncmp(azArg[0], \"prompt\", n)==0 && (nArg==2 || nArg==3)){\n    if( nArg >= 2) {\n      strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);\n    }\n    if( nArg >= 3) {\n      strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);\n    }\n  }else\n\n  if( c=='q' && strncmp(azArg[0], \"quit\", n)==0 && nArg==1 ){\n    rc = 2;\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"read\", n)==0 && nArg==2 ){\n    FILE *alt = fopen(azArg[1], \"rb\");\n    if( alt==0 ){\n      fprintf(stderr,\"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n      rc = 1;\n    }else{\n      rc = process_input(p, alt);\n      fclose(alt);\n    }\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"restore\", n)==0 && nArg>1 && nArg<4){\n    const char *zSrcFile;\n    const char *zDb;\n    sqlite3 *pSrc;\n    sqlite3_backup *pBackup;\n    int nTimeout = 0;\n\n    if( nArg==2 ){\n      zSrcFile = azArg[1];\n      zDb = \"main\";\n    }else{\n      zSrcFile = azArg[2];\n      zDb = azArg[1];\n    }\n    rc = sqlite3_open(zSrcFile, &pSrc);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zSrcFile);\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    open_db(p);\n    pBackup = sqlite3_backup_init(p->db, zDb, pSrc, \"main\");\n    if( pBackup==0 ){\n      fprintf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK\n          || rc==SQLITE_BUSY  ){\n      if( rc==SQLITE_BUSY ){\n        if( nTimeout++ >= 3 ) break;\n        sqlite3_sleep(100);\n      }\n    }\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      fprintf(stderr, \"Error: source database is busy\\n\");\n      rc = 1;\n    }else{\n      fprintf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      rc = 1;\n    }\n    sqlite3_close(pSrc);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"schema\", n)==0 && nArg<3 ){\n    struct callback_data data;\n    char *zErrMsg = 0;\n    open_db(p);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.mode = MODE_Semi;\n    if( nArg>1 ){\n      int i;\n      for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]);\n      if( strcmp(azArg[1],\"sqlite_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TABLE sqlite_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else if( strcmp(azArg[1],\"sqlite_temp_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TEMP TABLE sqlite_temp_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else{\n        zShellStatic = azArg[1];\n        rc = sqlite3_exec(p->db,\n          \"SELECT sql FROM \"\n          \"  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x\"\n          \"     FROM sqlite_master UNION ALL\"\n          \"   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) \"\n          \"WHERE lower(tbl_name) LIKE shellstatic()\"\n          \"  AND type!='meta' AND sql NOTNULL \"\n          \"ORDER BY rowid\",\n          callback, &data, &zErrMsg);\n        zShellStatic = 0;\n      }\n    }else{\n      rc = sqlite3_exec(p->db,\n         \"SELECT sql FROM \"\n         \"  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x\"\n         \"     FROM sqlite_master UNION ALL\"\n         \"   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) \"\n         \"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'\"\n         \"ORDER BY rowid\",\n         callback, &data, &zErrMsg\n      );\n    }\n    if( zErrMsg ){\n      fprintf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }else if( rc != SQLITE_OK ){\n      fprintf(stderr,\"Error: querying schema information\\n\");\n      rc = 1;\n    }else{\n      rc = 0;\n    }\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"separator\", n)==0 && nArg==2 ){\n    sqlite3_snprintf(sizeof(p->separator), p->separator,\n                     \"%.*s\", (int)sizeof(p->separator)-1, azArg[1]);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"show\", n)==0 && nArg==1 ){\n    int i;\n    fprintf(p->out,\"%9.9s: %s\\n\",\"echo\", p->echoOn ? \"on\" : \"off\");\n    fprintf(p->out,\"%9.9s: %s\\n\",\"explain\", p->explainPrev.valid ? \"on\" :\"off\");\n    fprintf(p->out,\"%9.9s: %s\\n\",\"headers\", p->showHeader ? \"on\" : \"off\");\n    fprintf(p->out,\"%9.9s: %s\\n\",\"mode\", modeDescr[p->mode]);\n    fprintf(p->out,\"%9.9s: \", \"nullvalue\");\n      output_c_string(p->out, p->nullvalue);\n      fprintf(p->out, \"\\n\");\n    fprintf(p->out,\"%9.9s: %s\\n\",\"output\",\n            strlen30(p->outfile) ? p->outfile : \"stdout\");\n    fprintf(p->out,\"%9.9s: \", \"separator\");\n      output_c_string(p->out, p->separator);\n      fprintf(p->out, \"\\n\");\n    fprintf(p->out,\"%9.9s: %s\\n\",\"stats\", p->statsOn ? \"on\" : \"off\");\n    fprintf(p->out,\"%9.9s: \",\"width\");\n    for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {\n      fprintf(p->out,\"%d \",p->colWidth[i]);\n    }\n    fprintf(p->out,\"\\n\");\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"stats\", n)==0 && nArg>1 && nArg<3 ){\n    p->statsOn = booleanValue(azArg[1]);\n  }else\n\n  if( c=='t' && n>1 && strncmp(azArg[0], \"tables\", n)==0 && nArg<3 ){\n    sqlite3_stmt *pStmt;\n    char **azResult;\n    int nRow, nAlloc;\n    char *zSql = 0;\n    int ii;\n    open_db(p);\n    rc = sqlite3_prepare_v2(p->db, \"PRAGMA database_list\", -1, &pStmt, 0);\n    if( rc ) return rc;\n    zSql = sqlite3_mprintf(\n        \"SELECT name FROM sqlite_master\"\n        \" WHERE type IN ('table','view')\"\n        \"   AND name NOT LIKE 'sqlite_%%'\"\n        \"   AND name LIKE ?1\");\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zDbName==0 || strcmp(zDbName,\"main\")==0 ) continue;\n      if( strcmp(zDbName,\"temp\")==0 ){\n        zSql = sqlite3_mprintf(\n                 \"%z UNION ALL \"\n                 \"SELECT 'temp.' || name FROM sqlite_temp_master\"\n                 \" WHERE type IN ('table','view')\"\n                 \"   AND name NOT LIKE 'sqlite_%%'\"\n                 \"   AND name LIKE ?1\", zSql);\n      }else{\n        zSql = sqlite3_mprintf(\n                 \"%z UNION ALL \"\n                 \"SELECT '%q.' || name FROM \\\"%w\\\".sqlite_master\"\n                 \" WHERE type IN ('table','view')\"\n                 \"   AND name NOT LIKE 'sqlite_%%'\"\n                 \"   AND name LIKE ?1\", zSql, zDbName, zDbName);\n      }\n    }\n    sqlite3_finalize(pStmt);\n    zSql = sqlite3_mprintf(\"%z ORDER BY 1\", zSql);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ) return rc;\n    nRow = nAlloc = 0;\n    azResult = 0;\n    if( nArg>1 ){\n      sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT);\n    }else{\n      sqlite3_bind_text(pStmt, 1, \"%\", -1, SQLITE_STATIC);\n    }\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      if( nRow>=nAlloc ){\n        char **azNew;\n        int n = nAlloc*2 + 10;\n        azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n);\n        if( azNew==0 ){\n          fprintf(stderr, \"Error: out of memory\\n\");\n          break;\n        }\n        nAlloc = n;\n        azResult = azNew;\n      }\n      azResult[nRow] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 0));\n      if( azResult[nRow] ) nRow++;\n    }\n    sqlite3_finalize(pStmt);        \n    if( nRow>0 ){\n      int len, maxlen = 0;\n      int i, j;\n      int nPrintCol, nPrintRow;\n      for(i=0; i<nRow; i++){\n        len = strlen30(azResult[i]);\n        if( len>maxlen ) maxlen = len;\n      }\n      nPrintCol = 80/(maxlen+2);\n      if( nPrintCol<1 ) nPrintCol = 1;\n      nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;\n      for(i=0; i<nPrintRow; i++){\n        for(j=i; j<nRow; j+=nPrintRow){\n          char *zSp = j<nPrintRow ? \"\" : \"  \";\n          fprintf(p->out, \"%s%-*s\", zSp, maxlen, azResult[j] ? azResult[j] : \"\");\n        }\n        fprintf(p->out, \"\\n\");\n      }\n    }\n    for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);\n    sqlite3_free(azResult);\n  }else\n\n  if( c=='t' && n>=8 && strncmp(azArg[0], \"testctrl\", n)==0 && nArg>=2 ){\n    static const struct {\n       const char *zCtrlName;   /* Name of a test-control option */\n       int ctrlCode;            /* Integer code for that option */\n    } aCtrl[] = {\n      { \"prng_save\",             SQLITE_TESTCTRL_PRNG_SAVE              },\n      { \"prng_restore\",          SQLITE_TESTCTRL_PRNG_RESTORE           },\n      { \"prng_reset\",            SQLITE_TESTCTRL_PRNG_RESET             },\n      { \"bitvec_test\",           SQLITE_TESTCTRL_BITVEC_TEST            },\n      { \"fault_install\",         SQLITE_TESTCTRL_FAULT_INSTALL          },\n      { \"benign_malloc_hooks\",   SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS    },\n      { \"pending_byte\",          SQLITE_TESTCTRL_PENDING_BYTE           },\n      { \"assert\",                SQLITE_TESTCTRL_ASSERT                 },\n      { \"always\",                SQLITE_TESTCTRL_ALWAYS                 },\n      { \"reserve\",               SQLITE_TESTCTRL_RESERVE                },\n      { \"optimizations\",         SQLITE_TESTCTRL_OPTIMIZATIONS          },\n      { \"iskeyword\",             SQLITE_TESTCTRL_ISKEYWORD              },\n      { \"scratchmalloc\",         SQLITE_TESTCTRL_SCRATCHMALLOC          },\n    };\n    int testctrl = -1;\n    int rc = 0;\n    int i, n;\n    open_db(p);\n\n    /* convert testctrl text option to value. allow any unique prefix\n    ** of the option name, or a numerical value. */\n    n = strlen30(azArg[1]);\n    for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){\n      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){\n        if( testctrl<0 ){\n          testctrl = aCtrl[i].ctrlCode;\n        }else{\n          fprintf(stderr, \"ambiguous option name: \\\"%s\\\"\\n\", azArg[1]);\n          testctrl = -1;\n          break;\n        }\n      }\n    }\n    if( testctrl<0 ) testctrl = atoi(azArg[1]);\n    if( (testctrl<SQLITE_TESTCTRL_FIRST) || (testctrl>SQLITE_TESTCTRL_LAST) ){\n      fprintf(stderr,\"Error: invalid testctrl option: %s\\n\", azArg[1]);\n    }else{\n      switch(testctrl){\n\n        /* sqlite3_test_control(int, db, int) */\n        case SQLITE_TESTCTRL_OPTIMIZATIONS:\n        case SQLITE_TESTCTRL_RESERVE:             \n          if( nArg==3 ){\n            int opt = (int)strtol(azArg[2], 0, 0);        \n            rc = sqlite3_test_control(testctrl, p->db, opt);\n            fprintf(p->out, \"%d (0x%08x)\\n\", rc, rc);\n          } else {\n            fprintf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                    azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int) */\n        case SQLITE_TESTCTRL_PRNG_SAVE:           \n        case SQLITE_TESTCTRL_PRNG_RESTORE:        \n        case SQLITE_TESTCTRL_PRNG_RESET:\n          if( nArg==2 ){\n            rc = sqlite3_test_control(testctrl);\n            fprintf(p->out, \"%d (0x%08x)\\n\", rc, rc);\n          } else {\n            fprintf(stderr,\"Error: testctrl %s takes no options\\n\", azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, uint) */\n        case SQLITE_TESTCTRL_PENDING_BYTE:        \n          if( nArg==3 ){\n            unsigned int opt = (unsigned int)integerValue(azArg[2]);        \n            rc = sqlite3_test_control(testctrl, opt);\n            fprintf(p->out, \"%d (0x%08x)\\n\", rc, rc);\n          } else {\n            fprintf(stderr,\"Error: testctrl %s takes a single unsigned\"\n                           \" int option\\n\", azArg[1]);\n          }\n          break;\n          \n        /* sqlite3_test_control(int, int) */\n        case SQLITE_TESTCTRL_ASSERT:              \n        case SQLITE_TESTCTRL_ALWAYS:              \n          if( nArg==3 ){\n            int opt = atoi(azArg[2]);        \n            rc = sqlite3_test_control(testctrl, opt);\n            fprintf(p->out, \"%d (0x%08x)\\n\", rc, rc);\n          } else {\n            fprintf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                            azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, char *) */\n#ifdef SQLITE_N_KEYWORD\n        case SQLITE_TESTCTRL_ISKEYWORD:           \n          if( nArg==3 ){\n            const char *opt = azArg[2];        \n            rc = sqlite3_test_control(testctrl, opt);\n            fprintf(p->out, \"%d (0x%08x)\\n\", rc, rc);\n          } else {\n            fprintf(stderr,\"Error: testctrl %s takes a single char * option\\n\",\n                            azArg[1]);\n          }\n          break;\n#endif\n\n        case SQLITE_TESTCTRL_BITVEC_TEST:         \n        case SQLITE_TESTCTRL_FAULT_INSTALL:       \n        case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: \n        case SQLITE_TESTCTRL_SCRATCHMALLOC:       \n        default:\n          fprintf(stderr,\"Error: CLI support for testctrl %s not implemented\\n\",\n                  azArg[1]);\n          break;\n      }\n    }\n  }else\n\n  if( c=='t' && n>4 && strncmp(azArg[0], \"timeout\", n)==0 && nArg==2 ){\n    open_db(p);\n    sqlite3_busy_timeout(p->db, atoi(azArg[1]));\n  }else\n    \n  if( HAS_TIMER && c=='t' && n>=5 && strncmp(azArg[0], \"timer\", n)==0\n   && nArg==2\n  ){\n    enableTimer = booleanValue(azArg[1]);\n  }else\n  \n  if( c=='t' && strncmp(azArg[0], \"trace\", n)==0 && nArg>1 ){\n    open_db(p);\n    output_file_close(p->traceOut);\n    p->traceOut = output_file_open(azArg[1]);\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    if( p->traceOut==0 ){\n      sqlite3_trace(p->db, 0, 0);\n    }else{\n      sqlite3_trace(p->db, sql_trace_callback, p->traceOut);\n    }\n#endif\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"version\", n)==0 ){\n    fprintf(p->out, \"SQLite %s %s\\n\" /*extra-version-info*/,\n        sqlite3_libversion(), sqlite3_sourceid());\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfsname\", n)==0 ){\n    const char *zDbName = nArg==2 ? azArg[1] : \"main\";\n    char *zVfsName = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName);\n      if( zVfsName ){\n        fprintf(p->out, \"%s\\n\", zVfsName);\n        sqlite3_free(zVfsName);\n      }\n    }\n  }else\n\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  if( c=='w' && strncmp(azArg[0], \"wheretrace\", n)==0 ){\n    extern int sqlite3WhereTrace;\n    sqlite3WhereTrace = booleanValue(azArg[1]);\n  }else\n#endif\n\n  if( c=='w' && strncmp(azArg[0], \"width\", n)==0 && nArg>1 ){\n    int j;\n    assert( nArg<=ArraySize(azArg) );\n    for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){\n      p->colWidth[j-1] = atoi(azArg[j]);\n    }\n  }else\n\n  {\n    fprintf(stderr, \"Error: unknown command or invalid arguments: \"\n      \" \\\"%s\\\". Enter \\\".help\\\" for help\\n\", azArg[0]);\n    rc = 1;\n  }\n\n  return rc;\n}\n\n/*\n** Return TRUE if a semicolon occurs anywhere in the first N characters\n** of string z[].\n*/\nstatic int _contains_semicolon(const char *z, int N){\n  int i;\n  for(i=0; i<N; i++){  if( z[i]==';' ) return 1; }\n  return 0;\n}\n\n/*\n** Test to see if a line consists entirely of whitespace.\n*/\nstatic int _all_whitespace(const char *z){\n  for(; *z; z++){\n    if( IsSpace(z[0]) ) continue;\n    if( *z=='/' && z[1]=='*' ){\n      z += 2;\n      while( *z && (*z!='*' || z[1]!='/') ){ z++; }\n      if( *z==0 ) return 0;\n      z++;\n      continue;\n    }\n    if( *z=='-' && z[1]=='-' ){\n      z += 2;\n      while( *z && *z!='\\n' ){ z++; }\n      if( *z==0 ) return 1;\n      continue;\n    }\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Return TRUE if the line typed in is an SQL command terminator other\n** than a semi-colon.  The SQL Server style \"go\" command is understood\n** as is the Oracle \"/\".\n*/\nstatic int _is_command_terminator(const char *zLine){\n  while( IsSpace(zLine[0]) ){ zLine++; };\n  if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){\n    return 1;  /* Oracle */\n  }\n  if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'\n         && _all_whitespace(&zLine[2]) ){\n    return 1;  /* SQL Server */\n  }\n  return 0;\n}\n\n/*\n** Return true if zSql is a complete SQL statement.  Return false if it\n** ends in the middle of a string literal or C-style comment.\n*/\nstatic int _is_complete(char *zSql, int nSql){\n  int rc;\n  if( zSql==0 ) return 1;\n  zSql[nSql] = ';';\n  zSql[nSql+1] = 0;\n  rc = sqlite3_complete(zSql);\n  zSql[nSql] = 0;\n  return rc;\n}\n\n/*\n** Read input from *in and process it.  If *in==0 then input\n** is interactive - the user is typing it it.  Otherwise, input\n** is coming from a file or device.  A prompt is issued and history\n** is saved only if input is interactive.  An interrupt signal will\n** cause this routine to exit immediately, unless input is interactive.\n**\n** Return the number of errors.\n*/\nstatic int process_input(struct callback_data *p, FILE *in){\n  char *zLine = 0;\n  char *zSql = 0;\n  int nSql = 0;\n  int nSqlPrior = 0;\n  char *zErrMsg;\n  int rc;\n  int errCnt = 0;\n  int lineno = 0;\n  int startline = 0;\n\n  while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){\n    fflush(p->out);\n    free(zLine);\n    zLine = one_input_line(zSql, in);\n    if( zLine==0 ){\n      /* End of input */\n      if( stdin_is_interactive ) printf(\"\\n\");\n      break;\n    }\n    if( seenInterrupt ){\n      if( in!=0 ) break;\n      seenInterrupt = 0;\n    }\n    lineno++;\n    if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;\n    if( zLine && zLine[0]=='.' && nSql==0 ){\n      if( p->echoOn ) printf(\"%s\\n\", zLine);\n      rc = do_meta_command(zLine, p);\n      if( rc==2 ){ /* exit requested */\n        break;\n      }else if( rc ){\n        errCnt++;\n      }\n      continue;\n    }\n    if( _is_command_terminator(zLine) && _is_complete(zSql, nSql) ){\n      memcpy(zLine,\";\",2);\n    }\n    nSqlPrior = nSql;\n    if( zSql==0 ){\n      int i;\n      for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}\n      if( zLine[i]!=0 ){\n        nSql = strlen30(zLine);\n        zSql = malloc( nSql+3 );\n        if( zSql==0 ){\n          fprintf(stderr, \"Error: out of memory\\n\");\n          exit(1);\n        }\n        memcpy(zSql, zLine, nSql+1);\n        startline = lineno;\n      }\n    }else{\n      int len = strlen30(zLine);\n      zSql = realloc( zSql, nSql + len + 4 );\n      if( zSql==0 ){\n        fprintf(stderr,\"Error: out of memory\\n\");\n        exit(1);\n      }\n      zSql[nSql++] = '\\n';\n      memcpy(&zSql[nSql], zLine, len+1);\n      nSql += len;\n    }\n    if( zSql && _contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)\n                && sqlite3_complete(zSql) ){\n      p->cnt = 0;\n      open_db(p);\n      BEGIN_TIMER;\n      rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);\n      END_TIMER;\n      if( rc || zErrMsg ){\n        char zPrefix[100];\n        if( in!=0 || !stdin_is_interactive ){\n          sqlite3_snprintf(sizeof(zPrefix), zPrefix, \n                           \"Error: near line %d:\", startline);\n        }else{\n          sqlite3_snprintf(sizeof(zPrefix), zPrefix, \"Error:\");\n        }\n        if( zErrMsg!=0 ){\n          fprintf(stderr, \"%s %s\\n\", zPrefix, zErrMsg);\n          sqlite3_free(zErrMsg);\n          zErrMsg = 0;\n        }else{\n          fprintf(stderr, \"%s %s\\n\", zPrefix, sqlite3_errmsg(p->db));\n        }\n        errCnt++;\n      }\n      free(zSql);\n      zSql = 0;\n      nSql = 0;\n    }else if( zSql && _all_whitespace(zSql) ){\n      free(zSql);\n      zSql = 0;\n      nSql = 0;\n    }\n  }\n  if( zSql ){\n    if( !_all_whitespace(zSql) ){\n      fprintf(stderr, \"Error: incomplete SQL: %s\\n\", zSql);\n    }\n    free(zSql);\n  }\n  free(zLine);\n  return errCnt>0;\n}\n\n/*\n** Return a pathname which is the user's home directory.  A\n** 0 return indicates an error of some kind.\n*/\nstatic char *find_home_dir(void){\n  static char *home_dir = NULL;\n  if( home_dir ) return home_dir;\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL)\n  {\n    struct passwd *pwent;\n    uid_t uid = getuid();\n    if( (pwent=getpwuid(uid)) != NULL) {\n      home_dir = pwent->pw_dir;\n    }\n  }\n#endif\n\n#if defined(_WIN32_WCE)\n  /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()\n   */\n  home_dir = \"/\";\n#else\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    home_dir = getenv(\"USERPROFILE\");\n  }\n#endif\n\n  if (!home_dir) {\n    home_dir = getenv(\"HOME\");\n  }\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    char *zDrive, *zPath;\n    int n;\n    zDrive = getenv(\"HOMEDRIVE\");\n    zPath = getenv(\"HOMEPATH\");\n    if( zDrive && zPath ){\n      n = strlen30(zDrive) + strlen30(zPath) + 1;\n      home_dir = malloc( n );\n      if( home_dir==0 ) return 0;\n      sqlite3_snprintf(n, home_dir, \"%s%s\", zDrive, zPath);\n      return home_dir;\n    }\n    home_dir = \"c:\\\\\";\n  }\n#endif\n\n#endif /* !_WIN32_WCE */\n\n  if( home_dir ){\n    int n = strlen30(home_dir) + 1;\n    char *z = malloc( n );\n    if( z ) memcpy(z, home_dir, n);\n    home_dir = z;\n  }\n\n  return home_dir;\n}\n\n/*\n** Read input from the file given by sqliterc_override.  Or if that\n** parameter is NULL, take input from ~/.sqliterc\n**\n** Returns the number of errors.\n*/\nstatic int process_sqliterc(\n  struct callback_data *p,        /* Configuration data */\n  const char *sqliterc_override   /* Name of config file. NULL to use default */\n){\n  char *home_dir = NULL;\n  const char *sqliterc = sqliterc_override;\n  char *zBuf = 0;\n  FILE *in = NULL;\n  int rc = 0;\n\n  if (sqliterc == NULL) {\n    home_dir = find_home_dir();\n    if( home_dir==0 ){\n#if !defined(__RTP__) && !defined(_WRS_KERNEL)\n      fprintf(stderr,\"%s: Error: cannot locate your home directory\\n\", Argv0);\n#endif\n      return 1;\n    }\n    sqlite3_initialize();\n    zBuf = sqlite3_mprintf(\"%s/.sqliterc\",home_dir);\n    sqliterc = zBuf;\n  }\n  in = fopen(sqliterc,\"rb\");\n  if( in ){\n    if( stdin_is_interactive ){\n      fprintf(stderr,\"-- Loading resources from %s\\n\",sqliterc);\n    }\n    rc = process_input(p,in);\n    fclose(in);\n  }\n  sqlite3_free(zBuf);\n  return rc;\n}\n\n/*\n** Show available command line options\n*/\nstatic const char zOptions[] = \n  \"   -bail                stop after hitting an error\\n\"\n  \"   -batch               force batch I/O\\n\"\n  \"   -column              set output mode to 'column'\\n\"\n  \"   -cmd COMMAND         run \\\"COMMAND\\\" before reading stdin\\n\"\n  \"   -csv                 set output mode to 'csv'\\n\"\n  \"   -echo                print commands before execution\\n\"\n  \"   -init FILENAME       read/process named file\\n\"\n  \"   -[no]header          turn headers on or off\\n\"\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n  \"   -heap SIZE           Size of heap for memsys3 or memsys5\\n\"\n#endif\n  \"   -help                show this message\\n\"\n  \"   -html                set output mode to HTML\\n\"\n  \"   -interactive         force interactive I/O\\n\"\n  \"   -line                set output mode to 'line'\\n\"\n  \"   -list                set output mode to 'list'\\n\"\n  \"   -mmap N              default mmap size set to N\\n\"\n#ifdef SQLITE_ENABLE_MULTIPLEX\n  \"   -multiplex           enable the multiplexor VFS\\n\"\n#endif\n  \"   -nullvalue TEXT      set text string for NULL values. Default ''\\n\"\n  \"   -separator SEP       set output field separator. Default: '|'\\n\"\n  \"   -stats               print memory stats before each finalize\\n\"\n  \"   -version             show SQLite version\\n\"\n  \"   -vfs NAME            use NAME as the default VFS\\n\"\n#ifdef SQLITE_ENABLE_VFSTRACE\n  \"   -vfstrace            enable tracing of all VFS calls\\n\"\n#endif\n;\nstatic void usage(int showDetail){\n  fprintf(stderr,\n      \"Usage: %s [OPTIONS] FILENAME [SQL]\\n\"  \n      \"FILENAME is the name of an SQLite database. A new database is created\\n\"\n      \"if the file does not previously exist.\\n\", Argv0);\n  if( showDetail ){\n    fprintf(stderr, \"OPTIONS include:\\n%s\", zOptions);\n  }else{\n    fprintf(stderr, \"Use the -help option for additional information\\n\");\n  }\n  exit(1);\n}\n\n/*\n** Initialize the state information in data\n*/\nstatic void main_init(struct callback_data *data) {\n  memset(data, 0, sizeof(*data));\n  data->mode = MODE_List;\n  memcpy(data->separator,\"|\", 2);\n  data->showHeader = 0;\n  sqlite3_config(SQLITE_CONFIG_URI, 1);\n  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);\n  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,\"sqlite> \");\n  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,\"   ...> \");\n  sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);\n}\n\n/*\n** Get the argument to an --option.  Throw an error and die if no argument\n** is available.\n*/\nstatic char *cmdline_option_value(int argc, char **argv, int i){\n  if( i==argc ){\n    fprintf(stderr, \"%s: Error: missing argument to %s\\n\",\n            argv[0], argv[argc-1]);\n    exit(1);\n  }\n  return argv[i];\n}\n\nint main(int argc, char **argv){\n  char *zErrMsg = 0;\n  struct callback_data data;\n  const char *zInitFile = 0;\n  char *zFirstCmd = 0;\n  int i;\n  int rc = 0;\n\n  if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){\n    fprintf(stderr, \"SQLite header and source version mismatch\\n%s\\n%s\\n\",\n            sqlite3_sourceid(), SQLITE_SOURCE_ID);\n    exit(1);\n  }\n  Argv0 = argv[0];\n  main_init(&data);\n  stdin_is_interactive = isatty(0);\n\n  /* Make sure we have a valid signal handler early, before anything\n  ** else is done.\n  */\n#ifdef SIGINT\n  signal(SIGINT, interrupt_handler);\n#endif\n\n  /* Do an initial pass through the command-line argument to locate\n  ** the name of the database file, the name of the initialization file,\n  ** the size of the alternative malloc heap,\n  ** and the first command to execute.\n  */\n  for(i=1; i<argc; i++){\n    char *z;\n    z = argv[i];\n    if( z[0]!='-' ){\n      if( data.zDbFilename==0 ){\n        data.zDbFilename = z;\n        continue;\n      }\n      if( zFirstCmd==0 ){\n        zFirstCmd = z;\n        continue;\n      }\n      fprintf(stderr,\"%s: Error: too many options: \\\"%s\\\"\\n\", Argv0, argv[i]);\n      fprintf(stderr,\"Use -help for a list of options.\\n\");\n      return 1;\n    }\n    if( z[1]=='-' ) z++;\n    if( strcmp(z,\"-separator\")==0\n     || strcmp(z,\"-nullvalue\")==0\n     || strcmp(z,\"-cmd\")==0\n    ){\n      (void)cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-init\")==0 ){\n      zInitFile = cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-batch\")==0 ){\n      /* Need to check for batch mode here to so we can avoid printing\n      ** informational messages (like from process_sqliterc) before \n      ** we do the actual processing of arguments later in a second pass.\n      */\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n      int j, c;\n      const char *zSize;\n      sqlite3_int64 szHeap;\n\n      zSize = cmdline_option_value(argc, argv, ++i);\n      szHeap = integerValue(zSize);\n      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;\n      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);\n#endif\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      extern int vfstrace_register(\n         const char *zTraceName,\n         const char *zOldVfsName,\n         int (*xOut)(const char*,void*),\n         void *pOutArg,\n         int makeDefault\n      );\n      vfstrace_register(\"trace\",0,(int(*)(const char*,void*))fputs,stderr,1);\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      extern int sqlite3_multiple_initialize(const char*,int);\n      sqlite3_multiplex_initialize(0, 1);\n#endif\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));\n      sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, sz, sz);\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));\n      if( pVfs ){\n        sqlite3_vfs_register(pVfs, 1);\n      }else{\n        fprintf(stderr, \"no such VFS: \\\"%s\\\"\\n\", argv[i]);\n        exit(1);\n      }\n    }\n  }\n  if( data.zDbFilename==0 ){\n#ifndef SQLITE_OMIT_MEMORYDB\n    data.zDbFilename = \":memory:\";\n#else\n    fprintf(stderr,\"%s: Error: no database filename specified\\n\", Argv0);\n    return 1;\n#endif\n  }\n  data.out = stdout;\n\n  /* Go ahead and open the database file if it already exists.  If the\n  ** file does not exist, delay opening it.  This prevents empty database\n  ** files from being created if a user mistypes the database name argument\n  ** to the sqlite command-line tool.\n  */\n  if( access(data.zDbFilename, 0)==0 ){\n    open_db(&data);\n  }\n\n  /* Process the initialization file if there is one.  If no -init option\n  ** is given on the command line, look for a file named ~/.sqliterc and\n  ** try to process it.\n  */\n  rc = process_sqliterc(&data,zInitFile);\n  if( rc>0 ){\n    return rc;\n  }\n\n  /* Make a second pass through the command-line argument and set\n  ** options.  This second pass is delayed until after the initialization\n  ** file is processed so that the command-line arguments will override\n  ** settings in the initialization file.\n  */\n  for(i=1; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) continue;\n    if( z[1]=='-' ){ z++; }\n    if( strcmp(z,\"-init\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-html\")==0 ){\n      data.mode = MODE_Html;\n    }else if( strcmp(z,\"-list\")==0 ){\n      data.mode = MODE_List;\n    }else if( strcmp(z,\"-line\")==0 ){\n      data.mode = MODE_Line;\n    }else if( strcmp(z,\"-column\")==0 ){\n      data.mode = MODE_Column;\n    }else if( strcmp(z,\"-csv\")==0 ){\n      data.mode = MODE_Csv;\n      memcpy(data.separator,\",\",2);\n    }else if( strcmp(z,\"-separator\")==0 ){\n      sqlite3_snprintf(sizeof(data.separator), data.separator,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-nullvalue\")==0 ){\n      sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-header\")==0 ){\n      data.showHeader = 1;\n    }else if( strcmp(z,\"-noheader\")==0 ){\n      data.showHeader = 0;\n    }else if( strcmp(z,\"-echo\")==0 ){\n      data.echoOn = 1;\n    }else if( strcmp(z,\"-stats\")==0 ){\n      data.statsOn = 1;\n    }else if( strcmp(z,\"-bail\")==0 ){\n      bail_on_error = 1;\n    }else if( strcmp(z,\"-version\")==0 ){\n      printf(\"%s %s\\n\", sqlite3_libversion(), sqlite3_sourceid());\n      return 0;\n    }else if( strcmp(z,\"-interactive\")==0 ){\n      stdin_is_interactive = 1;\n    }else if( strcmp(z,\"-batch\")==0 ){\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      i++;\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      i++;\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      i++;\n#endif\n    }else if( strcmp(z,\"-help\")==0 ){\n      usage(1);\n    }else if( strcmp(z,\"-cmd\")==0 ){\n      if( i==argc-1 ) break;\n      z = cmdline_option_value(argc,argv,++i);\n      if( z[0]=='.' ){\n        rc = do_meta_command(z, &data);\n        if( rc && bail_on_error ) return rc==2 ? 0 : rc;\n      }else{\n        open_db(&data);\n        rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg);\n        if( zErrMsg!=0 ){\n          fprintf(stderr,\"Error: %s\\n\", zErrMsg);\n          if( bail_on_error ) return rc!=0 ? rc : 1;\n        }else if( rc!=0 ){\n          fprintf(stderr,\"Error: unable to process SQL \\\"%s\\\"\\n\", z);\n          if( bail_on_error ) return rc;\n        }\n      }\n    }else{\n      fprintf(stderr,\"%s: Error: unknown option: %s\\n\", Argv0, z);\n      fprintf(stderr,\"Use -help for a list of options.\\n\");\n      return 1;\n    }\n  }\n\n  if( zFirstCmd ){\n    /* Run just the command that follows the database name\n    */\n    if( zFirstCmd[0]=='.' ){\n      rc = do_meta_command(zFirstCmd, &data);\n      if( rc==2 ) rc = 0;\n    }else{\n      open_db(&data);\n      rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg);\n      if( zErrMsg!=0 ){\n        fprintf(stderr,\"Error: %s\\n\", zErrMsg);\n        return rc!=0 ? rc : 1;\n      }else if( rc!=0 ){\n        fprintf(stderr,\"Error: unable to process SQL \\\"%s\\\"\\n\", zFirstCmd);\n        return rc;\n      }\n    }\n  }else{\n    /* Run commands received from standard input\n    */\n    if( stdin_is_interactive ){\n      char *zHome;\n      char *zHistory = 0;\n      int nHistory;\n      printf(\n        \"SQLite version %s %.19s\\n\" /*extra-version-info*/\n        \"Enter \\\".help\\\" for instructions\\n\"\n        \"Enter SQL statements terminated with a \\\";\\\"\\n\",\n        sqlite3_libversion(), sqlite3_sourceid()\n      );\n      zHome = find_home_dir();\n      if( zHome ){\n        nHistory = strlen30(zHome) + 20;\n        if( (zHistory = malloc(nHistory))!=0 ){\n          sqlite3_snprintf(nHistory, zHistory,\"%s/.sqlite_history\", zHome);\n        }\n      }\n#if defined(HAVE_READLINE) && HAVE_READLINE==1\n      if( zHistory ) read_history(zHistory);\n#endif\n      rc = process_input(&data, 0);\n      if( zHistory ){\n        stifle_history(100);\n        write_history(zHistory);\n        free(zHistory);\n      }\n    }else{\n      rc = process_input(&data, stdin);\n    }\n  }\n  set_table_name(&data, 0);\n  if( data.db ){\n    sqlite3_close(data.db);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "deps/sqlite/sqlite3.c",
    "content": "/******************************************************************************\n** This file is an amalgamation of many separate C source files from SQLite\n** version 3.7.17.  By combining all the individual C code files into this \n** single large file, the entire code can be compiled as a single translation\n** unit.  This allows many compilers to do optimizations that would not be\n** possible if the files were compiled separately.  Performance improvements\n** of 5% or more are commonly seen when SQLite is compiled as a single\n** translation unit.\n**\n** This file is all you need to compile SQLite.  To use SQLite in other\n** programs, you need this file and the \"sqlite3.h\" header file that defines\n** the programming interface to the SQLite library.  (If you do not have \n** the \"sqlite3.h\" header file at hand, you will find a copy embedded within\n** the text of this file.  Search for \"Begin file sqlite3.h\" to find the start\n** of the embedded sqlite3.h header file.) Additional code files may be needed\n** if you want a wrapper to interface SQLite with your choice of programming\n** language. The code for the \"sqlite3\" command-line shell is also in a\n** separate file. This file contains only code for the core SQLite library.\n*/\n#define SQLITE_CORE 1\n#define SQLITE_AMALGAMATION 1\n#ifndef SQLITE_PRIVATE\n# define SQLITE_PRIVATE static\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n/************** Begin file sqliteInt.h ***************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Internal interface definitions for SQLite.\n**\n*/\n#ifndef _SQLITEINT_H_\n#define _SQLITEINT_H_\n\n/*\n** These #defines should enable >2GB file support on POSIX if the\n** underlying operating system supports it.  If the OS lacks\n** large file support, or if the OS is windows, these should be no-ops.\n**\n** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any\n** system #includes.  Hence, this block of code must be the very first\n** code in all source files.\n**\n** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch\n** on the compiler command line.  This is necessary if you are compiling\n** on a recent machine (ex: Red Hat 7.2) but you want your code to work\n** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2\n** without this option, LFS is enable.  But LFS does not exist in the kernel\n** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary\n** portability you should omit LFS.\n**\n** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#ifdef _HAVE_SQLITE_CONFIG_H\n#include \"config.h\"\n#endif\n\n/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/\n/************** Begin file sqliteLimit.h *************************************/\n/*\n** 2007 May 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file defines various limits of what SQLite can process.\n*/\n\n/*\n** The maximum length of a TEXT or BLOB in bytes.   This also\n** limits the size of a row in a table or index.\n**\n** The hard limit is the ability of a 32-bit signed integer\n** to count the size: 2^31-1 or 2147483647.\n*/\n#ifndef SQLITE_MAX_LENGTH\n# define SQLITE_MAX_LENGTH 1000000000\n#endif\n\n/*\n** This is the maximum number of\n**\n**    * Columns in a table\n**    * Columns in an index\n**    * Columns in a view\n**    * Terms in the SET clause of an UPDATE statement\n**    * Terms in the result set of a SELECT statement\n**    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.\n**    * Terms in the VALUES clause of an INSERT statement\n**\n** The hard upper limit here is 32676.  Most database people will\n** tell you that in a well-normalized database, you usually should\n** not have more than a dozen or so columns in any table.  And if\n** that is the case, there is no point in having more than a few\n** dozen values in any of the other situations described above.\n*/\n#ifndef SQLITE_MAX_COLUMN\n# define SQLITE_MAX_COLUMN 2000\n#endif\n\n/*\n** The maximum length of a single SQL statement in bytes.\n**\n** It used to be the case that setting this value to zero would\n** turn the limit off.  That is no longer true.  It is not possible\n** to turn this limit off.\n*/\n#ifndef SQLITE_MAX_SQL_LENGTH\n# define SQLITE_MAX_SQL_LENGTH 1000000000\n#endif\n\n/*\n** The maximum depth of an expression tree. This is limited to \n** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might \n** want to place more severe limits on the complexity of an \n** expression.\n**\n** A value of 0 used to mean that the limit was not enforced.\n** But that is no longer true.  The limit is now strictly enforced\n** at all times.\n*/\n#ifndef SQLITE_MAX_EXPR_DEPTH\n# define SQLITE_MAX_EXPR_DEPTH 1000\n#endif\n\n/*\n** The maximum number of terms in a compound SELECT statement.\n** The code generator for compound SELECT statements does one\n** level of recursion for each term.  A stack overflow can result\n** if the number of terms is too large.  In practice, most SQL\n** never has more than 3 or 4 terms.  Use a value of 0 to disable\n** any limit on the number of terms in a compount SELECT.\n*/\n#ifndef SQLITE_MAX_COMPOUND_SELECT\n# define SQLITE_MAX_COMPOUND_SELECT 500\n#endif\n\n/*\n** The maximum number of opcodes in a VDBE program.\n** Not currently enforced.\n*/\n#ifndef SQLITE_MAX_VDBE_OP\n# define SQLITE_MAX_VDBE_OP 25000\n#endif\n\n/*\n** The maximum number of arguments to an SQL function.\n*/\n#ifndef SQLITE_MAX_FUNCTION_ARG\n# define SQLITE_MAX_FUNCTION_ARG 127\n#endif\n\n/*\n** The maximum number of in-memory pages to use for the main database\n** table and for temporary tables.  The SQLITE_DEFAULT_CACHE_SIZE\n*/\n#ifndef SQLITE_DEFAULT_CACHE_SIZE\n# define SQLITE_DEFAULT_CACHE_SIZE  2000\n#endif\n#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE\n# define SQLITE_DEFAULT_TEMP_CACHE_SIZE  500\n#endif\n\n/*\n** The default number of frames to accumulate in the log file before\n** checkpointing the database in WAL mode.\n*/\n#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000\n#endif\n\n/*\n** The maximum number of attached databases.  This must be between 0\n** and 62.  The upper bound on 62 is because a 64-bit integer bitmap\n** is used internally to track attached databases.\n*/\n#ifndef SQLITE_MAX_ATTACHED\n# define SQLITE_MAX_ATTACHED 10\n#endif\n\n\n/*\n** The maximum value of a ?nnn wildcard that the parser will accept.\n*/\n#ifndef SQLITE_MAX_VARIABLE_NUMBER\n# define SQLITE_MAX_VARIABLE_NUMBER 999\n#endif\n\n/* Maximum page size.  The upper bound on this value is 65536.  This a limit\n** imposed by the use of 16-bit offsets within each page.\n**\n** Earlier versions of SQLite allowed the user to change this value at\n** compile time. This is no longer permitted, on the grounds that it creates\n** a library that is technically incompatible with an SQLite library \n** compiled with a different limit. If a process operating on a database \n** with a page-size of 65536 bytes crashes, then an instance of SQLite \n** compiled with the default page-size limit will not be able to rollback \n** the aborted transaction. This could lead to database corruption.\n*/\n#ifdef SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_PAGE_SIZE\n#endif\n#define SQLITE_MAX_PAGE_SIZE 65536\n\n\n/*\n** The default size of a database page.\n*/\n#ifndef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE 1024\n#endif\n#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n/*\n** Ordinarily, if no value is explicitly provided, SQLite creates databases\n** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain\n** device characteristics (sector-size and atomic write() support),\n** SQLite may choose a larger value. This constant is the maximum value\n** SQLite will choose on its own.\n*/\n#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192\n#endif\n#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n\n/*\n** Maximum number of pages in one database file.\n**\n** This is really just the default value for the max_page_count pragma.\n** This value can be lowered (or raised) at run-time using that the\n** max_page_count macro.\n*/\n#ifndef SQLITE_MAX_PAGE_COUNT\n# define SQLITE_MAX_PAGE_COUNT 1073741823\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Maximum depth of recursion for triggers.\n**\n** A value of 1 means that a trigger program will not be able to itself\n** fire any triggers. A value of 0 means that no trigger programs at all \n** may be executed.\n*/\n#ifndef SQLITE_MAX_TRIGGER_DEPTH\n# define SQLITE_MAX_TRIGGER_DEPTH 1000\n#endif\n\n/************** End of sqliteLimit.h *****************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/* Disable nuisance warnings on Borland compilers */\n#if defined(__BORLANDC__)\n#pragma warn -rch /* unreachable code */\n#pragma warn -ccc /* Condition is always true or false */\n#pragma warn -aus /* Assigned value is never used */\n#pragma warn -csu /* Comparing signed and unsigned */\n#pragma warn -spa /* Suspicious pointer arithmetic */\n#endif\n\n/* Needed for various definitions... */\n#ifndef _GNU_SOURCE\n# define _GNU_SOURCE\n#endif\n\n#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)\n# define _BSD_SOURCE\n#endif\n\n/*\n** Include standard header files as necessary\n*/\n#ifdef HAVE_STDINT_H\n#include <stdint.h>\n#endif\n#ifdef HAVE_INTTYPES_H\n#include <inttypes.h>\n#endif\n\n/*\n** The following macros are used to cast pointers to integers and\n** integers to pointers.  The way you do this varies from one compiler\n** to the next, so we have developed the following set of #if statements\n** to generate appropriate macros for a wide range of compilers.\n**\n** The correct \"ANSI\" way to do this is to use the intptr_t type. \n** Unfortunately, that typedef is not available on all compilers, or\n** if it is available, it requires an #include of specific headers\n** that vary from one machine to the next.\n**\n** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on\n** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).\n** So we have to define the macros in different ways depending on the\n** compiler.\n*/\n#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))\n#elif !defined(__GNUC__)       /* Works for compilers other than LLVM */\n# define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])\n# define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))\n#elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))\n#else                          /* Generates a warning - but it always works */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(X))\n#endif\n\n/*\n** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.\n** 0 means mutexes are permanently disable and the library is never\n** threadsafe.  1 means the library is serialized which is the highest\n** level of threadsafety.  2 means the libary is multithreaded - multiple\n** threads can use SQLite as long as no two threads try to use the same\n** database connection at the same time.\n**\n** Older versions of SQLite used an optional THREADSAFE macro.\n** We support that for legacy.\n*/\n#if !defined(SQLITE_THREADSAFE)\n# if defined(THREADSAFE)\n#   define SQLITE_THREADSAFE THREADSAFE\n# else\n#   define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */\n# endif\n#endif\n\n/*\n** Powersafe overwrite is on by default.  But can be turned off using\n** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.\n*/\n#ifndef SQLITE_POWERSAFE_OVERWRITE\n# define SQLITE_POWERSAFE_OVERWRITE 1\n#endif\n\n/*\n** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.\n** It determines whether or not the features related to \n** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can\n** be overridden at runtime using the sqlite3_config() API.\n*/\n#if !defined(SQLITE_DEFAULT_MEMSTATUS)\n# define SQLITE_DEFAULT_MEMSTATUS 1\n#endif\n\n/*\n** Exactly one of the following macros must be defined in order to\n** specify which memory allocation subsystem to use.\n**\n**     SQLITE_SYSTEM_MALLOC          // Use normal system malloc()\n**     SQLITE_WIN32_MALLOC           // Use Win32 native heap API\n**     SQLITE_ZERO_MALLOC            // Use a stub allocator that always fails\n**     SQLITE_MEMDEBUG               // Debugging version of system malloc()\n**\n** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the\n** assert() macro is enabled, each call into the Win32 native heap subsystem\n** will cause HeapValidate to be called.  If heap validation should fail, an\n** assertion will be triggered.\n**\n** (Historical note:  There used to be several other options, but we've\n** pared it down to just these three.)\n**\n** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as\n** the default.\n*/\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)>1\n# error \"Two or more of the following compile-time configuration options\\\n are defined but at most one is allowed:\\\n SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\\\n SQLITE_ZERO_MALLOC\"\n#endif\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)==0\n# define SQLITE_SYSTEM_MALLOC 1\n#endif\n\n/*\n** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the\n** sizes of memory allocations below this value where possible.\n*/\n#if !defined(SQLITE_MALLOC_SOFT_LIMIT)\n# define SQLITE_MALLOC_SOFT_LIMIT 1024\n#endif\n\n/*\n** We need to define _XOPEN_SOURCE as follows in order to enable\n** recursive mutexes on most Unix systems.  But Mac OS X is different.\n** The _XOPEN_SOURCE define causes problems for Mac OS X we are told,\n** so it is omitted there.  See ticket #2673.\n**\n** Later we learn that _XOPEN_SOURCE is poorly or incorrectly\n** implemented on some systems.  So we avoid defining it at all\n** if it is already defined or if it is unneeded because we are\n** not doing a threadsafe build.  Ticket #2681.\n**\n** See also ticket #2741.\n*/\n#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) \\\n && !defined(__APPLE__) && SQLITE_THREADSAFE\n#  define _XOPEN_SOURCE 500  /* Needed to enable pthread recursive mutexes */\n#endif\n\n/*\n** The TCL headers are only needed when compiling the TCL bindings.\n*/\n#if defined(SQLITE_TCL) || defined(TCLSH)\n# include <tcl.h>\n#endif\n\n/*\n** NDEBUG and SQLITE_DEBUG are opposites.  It should always be true that\n** defined(NDEBUG)==!defined(SQLITE_DEBUG).  If this is not currently true,\n** make it true by defining or undefining NDEBUG.\n**\n** Setting NDEBUG makes the code smaller and run faster by disabling the\n** number assert() statements in the code.  So we want the default action\n** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG\n** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out\n** feature.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** The testcase() macro is used to aid in coverage testing.  When \n** doing coverage testing, the condition inside the argument to\n** testcase() must be evaluated both true and false in order to\n** get full branch coverage.  The testcase() macro is inserted\n** to help ensure adequate test coverage in places where simple\n** condition/decision coverage is inadequate.  For example, testcase()\n** can be used to make sure boundary values are tested.  For\n** bitmask tests, testcase() can be used to make sure each bit\n** is significant and used at least once.  On switch statements\n** where multiple cases go to the same block of code, testcase()\n** can insure that all cases are evaluated.\n**\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE   void sqlite3Coverage(int);\n# define testcase(X)  if( X ){ sqlite3Coverage(__LINE__); }\n#else\n# define testcase(X)\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n/*\n** Sometimes we need a small amount of code such as a variable initialization\n** to setup for a later assert() statement.  We do not want this code to\n** appear when assert() is disabled.  The following macro is therefore\n** used to contain that setup code.  The \"VVA\" acronym stands for\n** \"Verification, Validation, and Accreditation\".  In other words, the\n** code within VVA_ONLY() will only run during verification processes.\n*/\n#ifndef NDEBUG\n# define VVA_ONLY(X)  X\n#else\n# define VVA_ONLY(X)\n#endif\n\n/*\n** The ALWAYS and NEVER macros surround boolean expressions which \n** are intended to always be true or false, respectively.  Such\n** expressions could be omitted from the code completely.  But they\n** are included in a few cases in order to enhance the resilience\n** of SQLite to unexpected behavior - to make the code \"self-healing\"\n** or \"ductile\" rather than being \"brittle\" and crashing at the first\n** hint of unplanned behavior.\n**\n** In other words, ALWAYS and NEVER are added for defensive code.\n**\n** When doing coverage testing ALWAYS and NEVER are hard-coded to\n** be true and false so that the unreachable code then specify will\n** not be counted as untested code.\n*/\n#if defined(SQLITE_COVERAGE_TEST)\n# define ALWAYS(X)      (1)\n# define NEVER(X)       (0)\n#elif !defined(NDEBUG)\n# define ALWAYS(X)      ((X)?1:(assert(0),0))\n# define NEVER(X)       ((X)?(assert(0),1):0)\n#else\n# define ALWAYS(X)      (X)\n# define NEVER(X)       (X)\n#endif\n\n/*\n** Return true (non-zero) if the input is a integer that is too large\n** to fit in 32-bits.  This macro is used inside of various testcase()\n** macros to verify that we have tested SQLite for large-file support.\n*/\n#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)\n\n/*\n** The macro unlikely() is a hint that surrounds a boolean\n** expression that is usually false.  Macro likely() surrounds\n** a boolean expression that is usually true.  GCC is able to\n** use these hints to generate better code, sometimes.\n*/\n#if defined(__GNUC__) && 0\n# define likely(X)    __builtin_expect((X),1)\n# define unlikely(X)  __builtin_expect((X),0)\n#else\n# define likely(X)    !!(X)\n# define unlikely(X)  !!(X)\n#endif\n\n/************** Include sqlite3.h in the middle of sqliteInt.h ***************/\n/************** Begin file sqlite3.h *****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are suppose to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef _SQLITE3_H_\n#define _SQLITE3_H_\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\nextern \"C\" {\n#endif\n\n\n/*\n** Add the ability to override 'extern'\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are support for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since version 3.6.18, SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and an SHA1\n** hash of the entire source tree.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.7.17\"\n#define SQLITE_VERSION_NUMBER 3007017\n#define SQLITE_SOURCE_ID      \"2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version, sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus insure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** of sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must insure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: SQLITE_OK {error code} {error codes}\n** KEYWORDS: {result code} {result codes}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [SQLITE_IOERR_READ | extended result codes],\n** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* SQL error or missing database */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Database is empty */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Auxiliary database format error */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended error code} {extended error codes}\n** KEYWORDS: {extended result code} {extended result codes}\n**\n** In its default configuration, SQLite API routines return one of 26 integer\n** [SQLITE_OK | result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 and later) include\n** support for additional result codes that provide more detailed information\n** about errors. The extended result codes are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.\n**\n** Some of the available extended result codes are listed here.\n** One may expect the number of extended result codes will be expand\n** over time.  Software that uses extended result codes should expect\n** to see new result codes in future releases of SQLite.\n**\n** The SQLITE_OK result code will never be extended.  It will always\n** be exactly zero.\n*/\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and only needs to be supported when SQLITE_TEST\n** is defined.\n** <ul>\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See the [sqlite3_file_control()] documentation for\n** additional information.\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by\n** SQLite and sent to all VFSes in place of a call to the xSync method\n** when the database connection has [PRAGMA synchronous] set to OFF.)^\n** Some specialized VFSes need this signal in order to operate correctly\n** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most \n** VFSes do not need this signal and should silently ignore this opcode.\n** Applications should not call [sqlite3_file_control()] with this\n** opcode as doing so may disrupt the operation of the specialized VFSes\n** that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer i the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log and shared memory files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_GET_LOCKPROXYFILE             2\n#define SQLITE_SET_LOCKPROXYFILE             3\n#define SQLITE_LAST_ERRNO                    4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The value of the iVersion field is initially 1 but may be larger in\n** future versions of SQLite.  Additional fields may be appended to this\n** object when the iVersion value is increased.  Note that the structure\n** of the sqlite3_vfs object changes in the transaction between\n** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not\n** modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in figure versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given no the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** The sqlite3_config() interface is not threadsafe.  The application\n** must insure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  (For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mem_methods] structure.  The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^This option takes single argument of type int, interpreted as a \n** boolean, which enables or disables the collection of memory allocation \n** statistics. ^(When memory allocation statistics are disabled, the \n** following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite can use for\n** scratch memory.  There are three arguments:  A pointer an 8-byte\n** aligned memory buffer from which the scratch allocations will be\n** drawn, the size of each scratch allocation (sz),\n** and the maximum number of scratch allocations (N).  The sz\n** argument must be a multiple of 16.\n** The first argument must be a pointer to an 8-byte aligned buffer\n** of at least sz*N bytes of memory.\n** ^SQLite will use no more than two scratch buffers per thread.  So\n** N should be set to twice the expected maximum number of threads.\n** ^SQLite will never require a scratch buffer that is more than 6\n** times the database page size. ^If SQLite needs needs additional\n** scratch memory beyond what is provided by this configuration option, then \n** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite can use for\n** the database page cache with the default page cache implementation.  \n** This configuration should not be used if an application-define page\n** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.\n** There are three arguments to this option: A pointer to 8-byte aligned\n** memory, the size of each page buffer (sz), and the number of pages (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 32768) plus a little extra for each\n** page header.  ^The page header size is 20 to 40 bytes depending on\n** the host architecture.  ^It is harmless, apart from the wasted memory,\n** to make sz a little too large.  The first\n** argument should point to an allocation of at least sz*N bytes of memory.\n** ^SQLite will use the memory provided by the first argument to satisfy its\n** memory needs for the first N pages that it adds to cache.  ^If additional\n** page cache memory is needed beyond what is provided by this option, then\n** SQLite goes to [sqlite3_malloc()] for the additional storage space.\n** The pointer in the first argument must\n** be aligned to an 8-byte boundary or subsequent behavior of SQLite\n** will be undefined.</dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite will use\n** for all of its dynamic memory allocation needs beyond those provided\n** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].\n** There are three arguments: An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or\n** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mutex_methods] structure.  The argument specifies\n** alternative low-level mutex routines to be used in place\n** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the\n** content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(This option takes two arguments that determine the default\n** memory allocation for the lookaside memory allocator on each\n** [database connection].  The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(This option sets the\n** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** verb to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(This option takes a single argument which is a pointer to\n** an [sqlite3_pcache_methods2] object.  This object specifies the interface\n** to a custom page cache implementation.)^  ^SQLite makes a copy of the\n** object and uses it for page cache memory allocations.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** [sqlite3_pcache_methods2] object.  SQLite copies of the current\n** page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd> This option takes a single argument of type int. If non-zero, then\n** URI handling is globally enabled. If the parameter is zero, then URI handling\n** is globally disabled. If URI handling is globally enabled, all filenames\n** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd> This option takes a single integer argument which is interpreted as\n** a boolean in order to enable or disable the use of covering indices for\n** full table scans in the query optimizer.  The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** malfunction when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  The maximum allowed mmap size\n** cannot be changed at run-time.  Nor may the maximum allowed mmap size\n** exceed the compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.  \n** If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* void*, int sz, int N */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** </dl>\n*/\n#define SQLITE_DBCONFIG_LOOKASIDE       1001  /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY     1002  /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER  1003  /* int int* */\n\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n**\n** ^Each entry in an SQLite table has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^This routine returns the [rowid] of the most recent\n** successful [INSERT] into the database from the [database connection]\n** in the first argument.  ^As of SQLite version 3.7.7, this routines\n** records the last insert rowid of both ordinary tables and [virtual tables].\n** ^If no successful [INSERT]s\n** have ever occurred on that database connection, zero is returned.\n**\n** ^(If an [INSERT] occurs within a trigger or within a [virtual table]\n** method, then this routine will return the [rowid] of the inserted\n** row as long as the trigger or virtual table method is running.\n** But once the trigger or virtual table method ends, the value returned \n** by this routine reverts to what it was before the trigger or virtual\n** table method began.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n**\n** ^This function returns the number of database rows that were changed\n** or inserted or deleted by the most recently completed SQL statement\n** on the [database connection] specified by the first parameter.\n** ^(Only changes that are directly specified by the [INSERT], [UPDATE],\n** or [DELETE] statement are counted.  Auxiliary changes caused by\n** triggers or [foreign key actions] are not counted.)^ Use the\n** [sqlite3_total_changes()] function to find the total number of changes\n** including changes caused by triggers and foreign key actions.\n**\n** ^Changes to a view that are simulated by an [INSTEAD OF trigger]\n** are not counted.  Only real table changes are counted.\n**\n** ^(A \"row change\" is a change to a single row of a single table\n** caused by an INSERT, DELETE, or UPDATE statement.  Rows that\n** are changed as side effects of [REPLACE] constraint resolution,\n** rollback, ABORT processing, [DROP TABLE], or by any other\n** mechanisms do not count as direct row changes.)^\n**\n** A \"trigger context\" is a scope of execution that begins and\n** ends with the script of a [CREATE TRIGGER | trigger]. \n** Most SQL statements are\n** evaluated outside of any trigger.  This is the \"top level\"\n** trigger context.  If a trigger fires from the top level, a\n** new trigger context is entered for the duration of that one\n** trigger.  Subtriggers create subcontexts for their duration.\n**\n** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does\n** not create a new trigger context.\n**\n** ^This function returns the number of direct row changes in the\n** most recent INSERT, UPDATE, or DELETE statement within the same\n** trigger context.\n**\n** ^Thus, when called from the top level, this function returns the\n** number of changes in the most recent INSERT, UPDATE, or DELETE\n** that also occurred at the top level.  ^(Within the body of a trigger,\n** the sqlite3_changes() interface can be called to find the number of\n** changes in the most recently completed INSERT, UPDATE, or DELETE\n** statement within the body of the same trigger.\n** However, the number returned does not include changes\n** caused by subtriggers since those have their own context.)^\n**\n** See also the [sqlite3_total_changes()] interface, the\n** [count_changes pragma], and the [changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n**\n** ^This function returns the number of row changes caused by [INSERT],\n** [UPDATE] or [DELETE] statements since the [database connection] was opened.\n** ^(The count returned by sqlite3_total_changes() includes all changes\n** from all [CREATE TRIGGER | trigger] contexts and changes made by\n** [foreign key actions]. However,\n** the count does not include changes used to implement [REPLACE] constraints,\n** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The\n** count does not include rows of views that fire an [INSTEAD OF trigger],\n** though if the INSTEAD OF trigger makes changes of its own, those changes \n** are counted.)^\n** ^The sqlite3_total_changes() function counts the changes as soon as\n** the statement that makes them is completed (when the statement handle\n** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).\n**\n** See also the [sqlite3_changes()] interface, the\n** [count_changes pragma], and the [total_changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n**\n** If the database connection closes while [sqlite3_interrupt()]\n** is running then bad things will likely happen.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n**\n** ^This routine sets a callback function that might be invoked whenever\n** an attempt is made to open a database table that another thread\n** or process has locked.\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked for this locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.\n** ^If the callback returns non-zero, then another attempt\n** is made to open the database for reading and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]\n** when SQLite is in the middle of a large transaction where all the\n** changes will not fit into the in-memory cache.  SQLite will\n** already hold a RESERVED lock on the database file, but it needs\n** to promote this lock to EXCLUSIVE so that it can spill cache\n** pages into the database file without harm to concurrent\n** readers.  ^If it is unable to promote the lock, then the in-memory\n** cache will be left in an inconsistent state and so the error\n** code is promoted from the relatively benign [SQLITE_BUSY] to\n** the more severe [SQLITE_IOERR_BLOCKED].  ^This error code promotion\n** forces an automatic rollback of the changes.  See the\n** <a href=\"/cvstrac/wiki?p=CorruptionFollowingBusyError\">\n** CorruptionFollowingBusyError</a> wiki page for a discussion of why\n** this is important.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** will also set or clear the busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] any any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** These routines all implement some additional formatting\n** options that are useful for constructing SQL statements.\n** All of the usual printf() formatting options apply.  In addition, there\n** is are \"%q\", \"%Q\", and \"%z\" options.\n**\n** ^(The %q option works like %s in that it substitutes a nul-terminated\n** string from the argument list.  But %q also doubles every '\\'' character.\n** %q is designed for use inside a string literal.)^  By doubling each '\\''\n** character it escapes that character and allows it to be inserted into\n** the string.\n**\n** For example, assume the string variable zText contains text as follows:\n**\n** <blockquote><pre>\n**  char *zText = \"It's a happy day!\";\n** </pre></blockquote>\n**\n** One can use this text in an SQL statement as follows:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES('%q')\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** Because the %q format string is used, the '\\'' character in zText\n** is escaped and the SQL generated is as follows:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It''s a happy day!')\n** </pre></blockquote>\n**\n** This is correct.  Had we used %s instead of %q, the generated SQL\n** would have looked like this:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It's a happy day!');\n** </pre></blockquote>\n**\n** This second example is an SQL syntax error.  As a general rule you should\n** always use %q instead of %s when inserting text into a string literal.\n**\n** ^(The %Q option works like %q except it also adds single quotes around\n** the outside of the total string.  Additionally, if the parameter in the\n** argument list is a NULL pointer, %Q substitutes the text \"NULL\" (without\n** single quotes).)^  So, for example, one could say:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES(%Q)\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** The code above will render a correct SQL statement in the zSQL\n** variable even if the zText variable is a NULL pointer.\n**\n** ^(The \"%z\" formatting option works like \"%s\" but with the\n** addition that after the string has been read and copied into\n** the result, [sqlite3_free()] is called on the input string.)^\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^(The sqlite3_realloc() interface attempts to resize a\n** prior memory allocation to be at least N bytes, where N is the\n** second parameter.  The memory allocation to be resized is the first\n** parameter.)^ ^ If the first parameter to sqlite3_realloc()\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().\n** ^If the second parameter to sqlite3_realloc() is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().\n** ^sqlite3_realloc() returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if sufficient memory is unavailable.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc() and the prior allocation is freed.\n** ^If sqlite3_realloc() returns NULL, then the prior allocation\n** is not freed.\n**\n** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void sqlite3_free(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n**\n** ^The first time this routine is invoked (either internally or by\n** the application) the PRNG is seeded using randomness obtained\n** from the xRandomness method of the default [sqlite3_vfs] object.\n** ^On all subsequent invocations, the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are zero-terminated strings that contain additional\n** details about the action to be authorized.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code]\n** from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  The\n** sqlite3_profile() function is considered experimental and is\n** subject to change in future versions of SQLite.\n*/\nSQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding for the database will be UTF-8 if\n** sqlite3_open() or sqlite3_open_v2() is called and\n** UTF-16 in the native byte order if sqlite3_open16() is used.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the fourth argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** As of SQLite version 3.7.7, URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite interprets the following three query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-nolock\".\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n**\n** ^The sqlite3_errcode() interface returns the numeric [result code] or\n** [extended result code] for the most recent failed sqlite3_* API call\n** associated with a [database connection]. If a prior API call failed\n** but the most recent API call succeeded, the return value from\n** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: SQL Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement.\n** This object is variously known as a \"prepared statement\" or a\n** \"compiled SQL statement\" or simply as a \"statement\".\n**\n** The life of a statement object goes something like this:\n**\n** <ol>\n** <li> Create the object using [sqlite3_prepare_v2()] or a related\n**      function.\n** <li> Bind values to [host parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n**\n** Refer to documentation on individual methods above for additional\n** information.\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  This limit is not currently\n** enforced, though that might be added in some future release of\n** SQLite.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n**\n** To execute an SQL query, it must first be compiled into a byte-code\n** program using one of these routines.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare() and sqlite3_prepare_v2()\n** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()\n** use UTF-16.\n**\n** ^If the nByte argument is less than zero, then zSql is read up to the\n** first zero terminator. ^If nByte is non-negative, then it is the maximum\n** number of  bytes read from zSql.  ^When nByte is non-negative, the\n** zSql string ends at either the first '\\000' or '\\u0000' character or\n** the nByte-th byte, whichever comes first. If the caller knows\n** that the supplied string is nul-terminated, then there is a small\n** performance advantage to be gained by passing an nByte parameter that\n** is equal to the number of bytes in the input string <i>including</i>\n** the nul-terminator bytes as this saves SQLite from having to\n** make a copy of the input string.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are\n** recommended for all new programs. The two older interfaces are retained\n** for backwards compatibility, but their use is discouraged.\n** ^In the \"v2\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** the \n** </li>\n** </ol>\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n**\n** ^This interface can be used to retrieve a saved copy of the original\n** SQL text used to create a [prepared statement] if that statement was\n** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has not run to completion and/or has not \n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used with\n** [sqlite3_result_value()] and [sqlite3_bind_value()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct Mem sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() then that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and\n** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),\n** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  \n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()] or\n** [sqlite3_prepare16_v2()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^This routine returns 0 if pStmt is an SQL\n** statement that does not return data (for example an [UPDATE]).\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n**\n** After a [prepared statement] has been prepared using either\n** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"v2\" interface\n** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy\n** interface [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"v2\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after version 3.6.23.1, sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"v2\" interface is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n**\n** These routines form the \"result set\" interface.\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value\n** returned by sqlite3_column_type() is only meaningful if no type\n** conversions have occurred as described below.  After a type conversion,\n** the value returned by sqlite3_column_type() is undefined.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object\n** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], then the behavior is undefined.\n**\n** These routines attempt to convert the value where appropriate.  ^For\n** example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> Convert from float to integer\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> Same as FLOAT->TEXT\n** <tr><td>  TEXT    <td> INTEGER   <td> Use atoi()\n** <tr><td>  TEXT    <td>  FLOAT    <td> Use atof()\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> Convert to TEXT then use atoi()\n** <tr><td>  BLOB    <td>  FLOAT    <td> Convert to TEXT then use atof()\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** The table above makes reference to standard C library functions atoi()\n** and atof().  SQLite does not really use these functions.  It has its\n** own equivalent internal routines.  The atoi() and atof() names are\n** used in the table for brevity and because they are familiar to most\n** C programmers.\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest and easiest to remember policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned\n** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** ^(If a memory allocation error occurs during the evaluation of any\n** of these routines, a default value is returned.  The default value\n** is either the integer 0, the floating point number 0.0, or a NULL\n** pointer.  Subsequent calls to [sqlite3_errcode()] will return\n** [SQLITE_NOMEM].)^\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates.  The only differences between\n** these routines are the text encoding expected for\n** the second parameter (the name of the function being created)\n** and the presence or absence of a destructor callback for\n** the application data pointer.\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  Every SQL function implementation must be able to work\n** with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be\n** more efficient with one encoding than another.  ^An application may\n** invoke sqlite3_create_function() or sqlite3_create_function16() multiple\n** times with the same function but with different values of eTextRep.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n** If there is only a single implementation which does not care what text\n** encoding is used, then the fourth argument should be [SQLITE_ANY].\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,\n** then it is destructor for the application data pointer. \n** The destructor is invoked when the function is deleted, either by being\n** overloaded or when the database connection closes.)^\n** ^The destructor is also invoked if the call to\n** sqlite3_create_function_v2() fails.\n** ^When the destructor callback of the tenth parameter is invoked, it\n** is passed a single argument which is a copy of the application data \n** pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1\n#define SQLITE_UTF16LE        2\n#define SQLITE_UTF16BE        3\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* sqlite3_create_function only */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To help encourage people to avoid\n** using these functions, we are not going to tell you what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Function Parameter Values\n**\n** The C-language implementation of SQL functions and aggregates uses\n** this set of interface routines to access the parameter values on\n** the function or aggregate.\n**\n** The xFunc (for scalar functions) or xStep (for aggregates) parameters\n** to [sqlite3_create_function()] and [sqlite3_create_function16()]\n** define callbacks that implement the SQL functions and aggregates.\n** The 3rd parameter to these callbacks is an array of pointers to\n** [protected sqlite3_value] objects.  There is one [sqlite3_value] object for\n** each parameter to the SQL function.  These routines are used to\n** extract values from the [sqlite3_value] objects.\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** object results in undefined behavior.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that  these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n**\n** The following two functions may be used by scalar SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved. This may\n** be used, for example, to add a regular-expression matching scalar\n** function. The compiled version of the regular expression is stored as\n** metadata associated with the SQL value passed as the regular expression\n** pattern.  The compiled regular expression can be reused on multiple\n** invocations of the same function so that the original pattern string\n** does not need to be recompiled on each invocation.\n**\n** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata() function with the Nth argument\n** value to the application-defined function. ^If no metadata has been ever\n** been set for the Nth argument of the function, or if the corresponding\n** function parameter has changed since the meta-data was set,\n** then sqlite3_get_auxdata() returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata() interface saves the metadata\n** pointed to by its 3rd parameter as the metadata for the N-th\n** argument of the application-defined function.  Subsequent\n** calls to sqlite3_get_auxdata() might return this data, if it has\n** not been destroyed.\n** ^If it is not NULL, SQLite will invoke the destructor\n** function given by the 4th parameter to sqlite3_set_auxdata() on\n** the metadata when the corresponding function parameter changes\n** or when the SQL statement completes, whichever comes first.\n**\n** SQLite is free to call the destructor and drop metadata on any\n** parameter of any function at any time.  ^The only guarantee is that\n** the destructor will be called before the metadata is dropped.\n**\n** ^(In practice, metadata is preserved between function calls for\n** expressions that are constant at compile time. This includes literal\n** values and [parameters].)^\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob() interfaces set the result of\n** the application-defined function to be a BLOB containing all zero\n** bytes and N bytes in size, where N is the value of the 2nd parameter.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained from\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted.\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n**\n** ^In the current implementation, the update hook\n** is not invoked when duplication rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]\n** interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is effect even\n** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite version 3.7.3, the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n**\n** ^This routine returns metadata about a specific column of a specific\n** database table accessible using the [database connection] handle\n** passed as the first function argument.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL. ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively. Neither of these parameters\n** may be NULL.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid only until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** explicitly declared [INTEGER PRIMARY KEY] column, then the output\n** parameters are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^(This function may load one or more schemas from database files. If an\n** error occurs during this process, or if the requested table or column\n** cannot be found, an [error code] is returned and an error message left\n** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^\n**\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] prior to calling this API,\n** otherwise an error will be returned.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects and integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()].\n*/\nSQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of doing the\n** particular lookup.  A full scan of a table with N entries should have\n** a cost of N.  A binary search of a table of N entries should have a\n** cost of approximately log(N).\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column on left-hand side of constraint */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;      /* Estimated cost of using this index */\n};\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ    2\n#define SQLITE_INDEX_CONSTRAINT_GT    4\n#define SQLITE_INDEX_CONSTRAINT_LE    8\n#define SQLITE_INDEX_CONSTRAINT_LT    16\n#define SQLITE_INDEX_CONSTRAINT_GE    32\n#define SQLITE_INDEX_CONSTRAINT_MATCH 64\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* NO LONGER USED */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If it is zero, the BLOB is opened for read access.\n** ^It is not possible to open a column that is part of an index or primary \n** key for writing. ^If [foreign key constraints] are enabled, it is \n** not possible to open a column that is part of a [child key] for writing.\n**\n** ^Note that the database name is not the filename that contains\n** the database but rather the symbolic name of the database that\n** appears after the AS keyword when the database is connected using [ATTACH].\n** ^For the main database file, the database name is \"main\".\n** ^For TEMP tables, the database name is \"temp\".\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written\n** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set\n** to be a null pointer.)^\n** ^This function sets the [database connection] error code and message\n** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related\n** functions. ^Note that the *ppBlob variable is always initialized in a\n** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob\n** regardless of the success or failure of this routine.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function can be used, if desired,\n** to create an empty, zero-filled blob in which to read or write using\n** this interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n**\n** ^This function is used to move an existing blob handle so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing blob handle to a new row can be\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n**\n** ^Closes an open [BLOB handle].\n**\n** ^Closing a BLOB shall cause the current transaction to commit\n** if there are no other BLOBs, no pending prepared statements, and the\n** database connection is in [autocommit mode].\n** ^If any writes were made to the BLOB, they might be held in cache\n** until the close operation if they will fit.\n**\n** ^(Closing the BLOB often forces the changes\n** out to disk and so if any I/O errors occur, they will likely occur\n** at the time when the BLOB is closed.  Any errors that occur during\n** closing are reported as a non-zero return value.)^\n**\n** ^(The BLOB is closed unconditionally.  Even if this routine returns\n** an error code, the BLOB is still closed.)^\n**\n** ^Calling this routine with a null pointer (such as would be returned\n** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n**\n** ^This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. ^N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.\n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** ^This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written.  ^If N is\n** less than zero [SQLITE_ERROR] is returned and no data is written.\n** The size of the BLOB (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  ^(The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>)^\n**\n** ^The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().)^\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^If it returns NULL\n** that means that a mutex could not be allocated.  ^SQLite\n** will unwind its stack and return an error.  ^(The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_MEM2\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_LRU2\n** </ul>)^\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  ^SQLite will only request a recursive mutex in\n** cases where it really needs one.  ^If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^But for the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  ^SQLite is careful to deallocate every\n** dynamic mutex that it allocates.  The dynamic mutexes must not be in\n** use when they are deallocated.  Attempting to deallocate a static\n** mutex results in undefined behavior.  ^SQLite never deallocates\n** a static mutex.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  ^(If the same thread tries to enter any other\n** kind of mutex more than once, the behavior is undefined.\n** SQLite will never exhibit\n** such behavior in its own use of mutexes.)^\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY.  The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   ^(The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.  SQLite will\n** never do either.)^\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the user has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the user\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  ^It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  ^The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  ^The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  ^External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** ^These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** ^The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** ^If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  ^The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_random() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  ^The SQLITE_FCNTL_FILE_POINTER\n** case is a short-circuit path which does not actually invoke the\n** underlying sqlite3_io_methods.xFileControl method.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [SQLITE_FCNTL_LOCKSTATE]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19\n#define SQLITE_TESTCTRL_LAST                    19\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^This interface is used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** This routine is threadsafe but is not atomic.  This routine can be\n** called while other threads are running the same or different SQLite\n** interfaces.  However the values returned in *pCurrent and\n** *pHighwater reflect the status of SQLite at different points in time\n** and it is possible that another thread might change the parameter\n** in between the times when *pCurrent and *pHighwater are written.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Scratch memory\n** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>This parameter returns the number of allocations used out of the\n** [scratch memory allocator] configured using\n** [SQLITE_CONFIG_SCRATCH].  The value returned is in allocations, not\n** in bytes.  Since a single thread may only have one scratch allocation\n** outstanding at time, this parameter also reports the number of threads\n** using scratch memory at the same time.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of scratch memory\n** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The values\n** returned include overflows because the requested allocation was too\n** larger (that is, because the requested allocation was larger than the\n** \"sz\" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer\n** slots were available.\n** </dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [scratch memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>This parameter records the deepest parser stack.  It is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_MAX                  9   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^Each call to sqlite3_backup_step() sets two values inside\n** the [sqlite3_backup] object: the number of pages still to be backed\n** up and the total number of pages in the source database file.\n** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces\n** retrieve these two values, respectively.\n**\n** ^The values returned by these functions are only updated by\n** sqlite3_backup_step(). ^If the source database is modified during a backup\n** operation, then the values are not updated to account for any extra\n** pages that need to be updated or the size of the source database file\n** changing.\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches\n** the glob pattern P, and it returns non-zero if string X does not match\n** the glob pattern P.  ^The definition of glob pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case\n** sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** will be invoked each time a database connection commits data to a\n** [write-ahead log] (i.e. whenever a transaction is committed in\n** [journal_mode | journal_mode=WAL mode]). \n**\n** ^The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** those overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n**\n** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X\n** on [database connection] D to be [checkpointed].  ^If X is NULL or an\n** empty string, then a checkpoint is run on all databases of\n** connection D.  ^If the database connection D is not in\n** [WAL | write-ahead log mode] then this interface is a harmless no-op.\n**\n** ^The [wal_checkpoint pragma] can be used to invoke this interface\n** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] can be used to cause this interface to be\n** run whenever the WAL reaches a certain size threshold.\n**\n** See also: [sqlite3_wal_checkpoint_v2()]\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n**\n** Run a checkpoint operation on WAL database zDb attached to database \n** handle db. The specific operation is determined by the value of the \n** eMode parameter:\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish. Sync the db file if all frames in the log\n**   are checkpointed. This mode is the same as calling \n**   sqlite3_wal_checkpoint(). The busy-handler callback is never invoked.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   This mode blocks (calls the busy-handler callback) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. It then checkpoints all frames in the log file and syncs the\n**   database file. This call blocks database writers while it is running,\n**   but not database readers.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after \n**   checkpointing the log file it blocks (calls the busy-handler callback)\n**   until all readers are reading from the database file only. This ensures \n**   that the next client to write to the database file restarts the log file \n**   from the beginning. This call blocks database writers while it is running,\n**   but not database readers.\n** </dl>\n**\n** If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to\n** the total number of checkpointed frames (including any that were already\n** checkpointed when this function is called). *pnLog and *pnCkpt may be\n** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.\n** If no values are available because of an error, they are both set to -1\n** before returning to communicate this to the caller.\n**\n** All calls obtain an exclusive \"checkpoint\" lock on the database file. If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive \n** \"writer\" lock on the database file. If the writer lock cannot be obtained\n** immediately, and a busy-handler is configured, it is invoked and the writer\n** lock retried until either the busy-handler returns 0 or the lock is\n** successfully obtained. The busy-handler is also invoked while waiting for\n** database readers as described above. If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. SQLITE_BUSY is returned in this case.\n**\n** If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases. In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned to the caller. If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code returned to the caller immediately. If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint operation parameters\n**\n** These constants can be used as the 3rd parameter to\n** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]\n** documentation for additional information about the meaning and use of\n** each of these values.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE 0\n#define SQLITE_CHECKPOINT_FULL    1\n#define SQLITE_CHECKPOINT_RESTART 2\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Conflict resolution modes\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#if 0\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif\n\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#if 0\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n#ifdef SQLITE_RTREE_INT_ONLY\n  int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),\n#else\n  int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),\n#endif\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  double *aParam;                 /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n\n/************** End of sqlite3.h *********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include hash.h in the middle of sqliteInt.h ******************/\n/************** Begin file hash.h ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.\n*/\n#ifndef _SQLITE_HASH_H_\n#define _SQLITE_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Hash Hash;\ntypedef struct HashElem HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, some of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n**\n** All elements of the hash table are on a single doubly-linked list.\n** Hash.first points to the head of this list.\n**\n** There are Hash.htsize buckets.  Each bucket points to a spot in\n** the global doubly-linked list.  The contents of the bucket are the\n** element pointed to plus the next _ht.count-1 elements in the list.\n**\n** Hash.htsize and Hash.ht may be zero.  In that case lookup is done\n** by a linear search of the global list.  For small tables, the \n** Hash.ht table is never allocated because if there are few elements\n** in the table, it is faster to do a linear search than to manage\n** the hash table.\n*/\nstruct Hash {\n  unsigned int htsize;      /* Number of buckets in the hash table */\n  unsigned int count;       /* Number of entries in this table */\n  HashElem *first;          /* The first element of the array */\n  struct _ht {              /* the hash table */\n    int count;                 /* Number of entries with this hash */\n    HashElem *chain;           /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct HashElem {\n  HashElem *next, *prev;       /* Next and previous elements in the table */\n  void *data;                  /* Data associated with this element */\n  const char *pKey; int nKey;  /* Key associated with this element */\n};\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash*);\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData);\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey, int nKey);\nSQLITE_PRIVATE void sqlite3HashClear(Hash*);\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Hash h;\n**   HashElem *p;\n**   ...\n**   for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){\n**     SomeStructure *pData = sqliteHashData(p);\n**     // do something with pData\n**   }\n*/\n#define sqliteHashFirst(H)  ((H)->first)\n#define sqliteHashNext(E)   ((E)->next)\n#define sqliteHashData(E)   ((E)->data)\n/* #define sqliteHashKey(E)    ((E)->pKey) // NOT USED */\n/* #define sqliteHashKeysize(E) ((E)->nKey)  // NOT USED */\n\n/*\n** Number of entries in a hash table\n*/\n/* #define sqliteHashCount(H)  ((H)->count) // NOT USED */\n\n#endif /* _SQLITE_HASH_H_ */\n\n/************** End of hash.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include parse.h in the middle of sqliteInt.h *****************/\n/************** Begin file parse.h *******************************************/\n#define TK_SEMI                            1\n#define TK_EXPLAIN                         2\n#define TK_QUERY                           3\n#define TK_PLAN                            4\n#define TK_BEGIN                           5\n#define TK_TRANSACTION                     6\n#define TK_DEFERRED                        7\n#define TK_IMMEDIATE                       8\n#define TK_EXCLUSIVE                       9\n#define TK_COMMIT                         10\n#define TK_END                            11\n#define TK_ROLLBACK                       12\n#define TK_SAVEPOINT                      13\n#define TK_RELEASE                        14\n#define TK_TO                             15\n#define TK_TABLE                          16\n#define TK_CREATE                         17\n#define TK_IF                             18\n#define TK_NOT                            19\n#define TK_EXISTS                         20\n#define TK_TEMP                           21\n#define TK_LP                             22\n#define TK_RP                             23\n#define TK_AS                             24\n#define TK_COMMA                          25\n#define TK_ID                             26\n#define TK_INDEXED                        27\n#define TK_ABORT                          28\n#define TK_ACTION                         29\n#define TK_AFTER                          30\n#define TK_ANALYZE                        31\n#define TK_ASC                            32\n#define TK_ATTACH                         33\n#define TK_BEFORE                         34\n#define TK_BY                             35\n#define TK_CASCADE                        36\n#define TK_CAST                           37\n#define TK_COLUMNKW                       38\n#define TK_CONFLICT                       39\n#define TK_DATABASE                       40\n#define TK_DESC                           41\n#define TK_DETACH                         42\n#define TK_EACH                           43\n#define TK_FAIL                           44\n#define TK_FOR                            45\n#define TK_IGNORE                         46\n#define TK_INITIALLY                      47\n#define TK_INSTEAD                        48\n#define TK_LIKE_KW                        49\n#define TK_MATCH                          50\n#define TK_NO                             51\n#define TK_KEY                            52\n#define TK_OF                             53\n#define TK_OFFSET                         54\n#define TK_PRAGMA                         55\n#define TK_RAISE                          56\n#define TK_REPLACE                        57\n#define TK_RESTRICT                       58\n#define TK_ROW                            59\n#define TK_TRIGGER                        60\n#define TK_VACUUM                         61\n#define TK_VIEW                           62\n#define TK_VIRTUAL                        63\n#define TK_REINDEX                        64\n#define TK_RENAME                         65\n#define TK_CTIME_KW                       66\n#define TK_ANY                            67\n#define TK_OR                             68\n#define TK_AND                            69\n#define TK_IS                             70\n#define TK_BETWEEN                        71\n#define TK_IN                             72\n#define TK_ISNULL                         73\n#define TK_NOTNULL                        74\n#define TK_NE                             75\n#define TK_EQ                             76\n#define TK_GT                             77\n#define TK_LE                             78\n#define TK_LT                             79\n#define TK_GE                             80\n#define TK_ESCAPE                         81\n#define TK_BITAND                         82\n#define TK_BITOR                          83\n#define TK_LSHIFT                         84\n#define TK_RSHIFT                         85\n#define TK_PLUS                           86\n#define TK_MINUS                          87\n#define TK_STAR                           88\n#define TK_SLASH                          89\n#define TK_REM                            90\n#define TK_CONCAT                         91\n#define TK_COLLATE                        92\n#define TK_BITNOT                         93\n#define TK_STRING                         94\n#define TK_JOIN_KW                        95\n#define TK_CONSTRAINT                     96\n#define TK_DEFAULT                        97\n#define TK_NULL                           98\n#define TK_PRIMARY                        99\n#define TK_UNIQUE                         100\n#define TK_CHECK                          101\n#define TK_REFERENCES                     102\n#define TK_AUTOINCR                       103\n#define TK_ON                             104\n#define TK_INSERT                         105\n#define TK_DELETE                         106\n#define TK_UPDATE                         107\n#define TK_SET                            108\n#define TK_DEFERRABLE                     109\n#define TK_FOREIGN                        110\n#define TK_DROP                           111\n#define TK_UNION                          112\n#define TK_ALL                            113\n#define TK_EXCEPT                         114\n#define TK_INTERSECT                      115\n#define TK_SELECT                         116\n#define TK_DISTINCT                       117\n#define TK_DOT                            118\n#define TK_FROM                           119\n#define TK_JOIN                           120\n#define TK_USING                          121\n#define TK_ORDER                          122\n#define TK_GROUP                          123\n#define TK_HAVING                         124\n#define TK_LIMIT                          125\n#define TK_WHERE                          126\n#define TK_INTO                           127\n#define TK_VALUES                         128\n#define TK_INTEGER                        129\n#define TK_FLOAT                          130\n#define TK_BLOB                           131\n#define TK_REGISTER                       132\n#define TK_VARIABLE                       133\n#define TK_CASE                           134\n#define TK_WHEN                           135\n#define TK_THEN                           136\n#define TK_ELSE                           137\n#define TK_INDEX                          138\n#define TK_ALTER                          139\n#define TK_ADD                            140\n#define TK_TO_TEXT                        141\n#define TK_TO_BLOB                        142\n#define TK_TO_NUMERIC                     143\n#define TK_TO_INT                         144\n#define TK_TO_REAL                        145\n#define TK_ISNOT                          146\n#define TK_END_OF_FILE                    147\n#define TK_ILLEGAL                        148\n#define TK_SPACE                          149\n#define TK_UNCLOSED_STRING                150\n#define TK_FUNCTION                       151\n#define TK_COLUMN                         152\n#define TK_AGG_FUNCTION                   153\n#define TK_AGG_COLUMN                     154\n#define TK_CONST_FUNC                     155\n#define TK_UMINUS                         156\n#define TK_UPLUS                          157\n\n/************** End of parse.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stddef.h>\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite_int64\n# define float sqlite_int64\n# define LONGDOUBLE_TYPE sqlite_int64\n# ifndef SQLITE_BIG_DBL\n#   define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)\n# endif\n# define SQLITE_OMIT_DATETIME_FUNCS 1\n# define SQLITE_OMIT_TRACE 1\n# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n# undef SQLITE_HAVE_ISNAN\n#endif\n#ifndef SQLITE_BIG_DBL\n# define SQLITE_BIG_DBL (1e99)\n#endif\n\n/*\n** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0\n** afterward. Having this macro allows us to cause the C compiler \n** to omit code used by TEMP tables without messy #ifndef statements.\n*/\n#ifdef SQLITE_OMIT_TEMPDB\n#define OMIT_TEMPDB 1\n#else\n#define OMIT_TEMPDB 0\n#endif\n\n/*\n** The \"file format\" number is an integer that is incremented whenever\n** the VDBE-level file format changes.  The following macros define the\n** the default file format for new databases and the maximum file format\n** that the library can read.\n*/\n#define SQLITE_MAX_FILE_FORMAT 4\n#ifndef SQLITE_DEFAULT_FILE_FORMAT\n# define SQLITE_DEFAULT_FILE_FORMAT 4\n#endif\n\n/*\n** Determine whether triggers are recursive by default.  This can be\n** changed at run-time using a pragma.\n*/\n#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0\n#endif\n\n/*\n** Provide a default value for SQLITE_TEMP_STORE in case it is not specified\n** on the command-line\n*/\n#ifndef SQLITE_TEMP_STORE\n# define SQLITE_TEMP_STORE 1\n# define SQLITE_TEMP_STORE_xc 1  /* Exclude from ctime.c */\n#endif\n\n/*\n** GCC does not define the offsetof() macro so we'll have to do it\n** ourselves.\n*/\n#ifndef offsetof\n#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))\n#endif\n\n/*\n** Check to see if this machine uses EBCDIC.  (Yes, believe it or\n** not, there are still machines out there that use EBCDIC.)\n*/\n#if 'A' == '\\301'\n# define SQLITE_EBCDIC 1\n#else\n# define SQLITE_ASCII 1\n#endif\n\n/*\n** Integers of known sizes.  These typedefs might change for architectures\n** where the sizes very.  Preprocessor macros are available so that the\n** types can be conveniently redefined at compile-type.  Like this:\n**\n**         cc '-DUINTPTR_TYPE=long long int' ...\n*/\n#ifndef UINT32_TYPE\n# ifdef HAVE_UINT32_T\n#  define UINT32_TYPE uint32_t\n# else\n#  define UINT32_TYPE unsigned int\n# endif\n#endif\n#ifndef UINT16_TYPE\n# ifdef HAVE_UINT16_T\n#  define UINT16_TYPE uint16_t\n# else\n#  define UINT16_TYPE unsigned short int\n# endif\n#endif\n#ifndef INT16_TYPE\n# ifdef HAVE_INT16_T\n#  define INT16_TYPE int16_t\n# else\n#  define INT16_TYPE short int\n# endif\n#endif\n#ifndef UINT8_TYPE\n# ifdef HAVE_UINT8_T\n#  define UINT8_TYPE uint8_t\n# else\n#  define UINT8_TYPE unsigned char\n# endif\n#endif\n#ifndef INT8_TYPE\n# ifdef HAVE_INT8_T\n#  define INT8_TYPE int8_t\n# else\n#  define INT8_TYPE signed char\n# endif\n#endif\n#ifndef LONGDOUBLE_TYPE\n# define LONGDOUBLE_TYPE long double\n#endif\ntypedef sqlite_int64 i64;          /* 8-byte signed integer */\ntypedef sqlite_uint64 u64;         /* 8-byte unsigned integer */\ntypedef UINT32_TYPE u32;           /* 4-byte unsigned integer */\ntypedef UINT16_TYPE u16;           /* 2-byte unsigned integer */\ntypedef INT16_TYPE i16;            /* 2-byte signed integer */\ntypedef UINT8_TYPE u8;             /* 1-byte unsigned integer */\ntypedef INT8_TYPE i8;              /* 1-byte signed integer */\n\n/*\n** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value\n** that can be stored in a u32 without loss of data.  The value\n** is 0x00000000ffffffff.  But because of quirks of some compilers, we\n** have to specify the value in the less intuitive manner shown:\n*/\n#define SQLITE_MAX_U32  ((((u64)1)<<32)-1)\n\n/*\n** The datatype used to store estimates of the number of rows in a\n** table or index.  This is an unsigned integer type.  For 99.9% of\n** the world, a 32-bit integer is sufficient.  But a 64-bit integer\n** can be used at compile-time if desired.\n*/\n#ifdef SQLITE_64BIT_STATS\n typedef u64 tRowcnt;    /* 64-bit only if requested at compile-time */\n#else\n typedef u32 tRowcnt;    /* 32-bit is the default */\n#endif\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** evaluated at runtime.\n*/\n#ifdef SQLITE_AMALGAMATION\nSQLITE_PRIVATE const int sqlite3one = 1;\n#else\nSQLITE_PRIVATE const int sqlite3one;\n#endif\n#if defined(i386) || defined(__i386__) || defined(_M_IX86)\\\n                             || defined(__x86_64) || defined(__x86_64__)\n# define SQLITE_BIGENDIAN    0\n# define SQLITE_LITTLEENDIAN 1\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16LE\n#else\n# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)\n# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)\n# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)\n#endif\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n/* \n** Round up a number to the next larger multiple of 8.  This is used\n** to force 8-byte alignment on 64-bit architectures.\n*/\n#define ROUND8(x)     (((x)+7)&~7)\n\n/*\n** Round down to the nearest multiple of 8\n*/\n#define ROUNDDOWN8(x) ((x)&~7)\n\n/*\n** Assert that the pointer X is aligned to an 8-byte boundary.  This\n** macro is used only within assert() to verify that the code gets\n** all alignment restrictions correct.\n**\n** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the\n** underlying malloc() implemention might return us 4-byte aligned\n** pointers.  In that case, only verify 4-byte alignment.\n*/\n#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)\n#else\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)\n#endif\n\n/*\n** Disable MMAP on platforms where it is known to not work\n*/\n#if defined(__OpenBSD__) || defined(__QNXNTO__)\n# undef SQLITE_MAX_MMAP_SIZE\n# define SQLITE_MAX_MMAP_SIZE 0\n#endif\n\n/*\n** Default maximum size of memory used by memory-mapped I/O in the VFS\n*/\n#ifdef __APPLE__\n# include <TargetConditionals.h>\n# if TARGET_OS_IPHONE\n#   undef SQLITE_MAX_MMAP_SIZE\n#   define SQLITE_MAX_MMAP_SIZE 0\n# endif\n#endif\n#ifndef SQLITE_MAX_MMAP_SIZE\n# if defined(__linux__) \\\n  || defined(_WIN32) \\\n  || (defined(__APPLE__) && defined(__MACH__)) \\\n  || defined(__sun)\n#   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */\n# else\n#   define SQLITE_MAX_MMAP_SIZE 0\n# endif\n# define SQLITE_MAX_MMAP_SIZE_xc 1 /* exclude from ctime.c */\n#endif\n\n/*\n** The default MMAP_SIZE is zero on all platforms.  Or, even if a larger\n** default MMAP_SIZE is specified at compile-time, make sure that it does\n** not exceed the maximum mmap size.\n*/\n#ifndef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE 0\n# define SQLITE_DEFAULT_MMAP_SIZE_xc 1  /* Exclude from ctime.c */\n#endif\n#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE\n# undef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE\n#endif\n\n/*\n** An instance of the following structure is used to store the busy-handler\n** callback for a given sqlite handle. \n**\n** The sqlite.busyHandler member of the sqlite struct contains the busy\n** callback for the database handle. Each pager opened via the sqlite\n** handle is passed a pointer to sqlite.busyHandler. The busy-handler\n** callback is currently invoked only from within pager.c.\n*/\ntypedef struct BusyHandler BusyHandler;\nstruct BusyHandler {\n  int (*xFunc)(void *,int);  /* The busy callback */\n  void *pArg;                /* First arg to busy callback */\n  int nBusy;                 /* Incremented with each busy call */\n};\n\n/*\n** Name of the master database table.  The master database table\n** is a special table that holds the names and attributes of all\n** user tables and indices.\n*/\n#define MASTER_NAME       \"sqlite_master\"\n#define TEMP_MASTER_NAME  \"sqlite_temp_master\"\n\n/*\n** The root-page of the master database table.\n*/\n#define MASTER_ROOT       1\n\n/*\n** The name of the schema table.\n*/\n#define SCHEMA_TABLE(x)  ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)\n\n/*\n** A convenience macro that returns the number of elements in\n** an array.\n*/\n#define ArraySize(X)    ((int)(sizeof(X)/sizeof(X[0])))\n\n/*\n** Determine if the argument is a power of two\n*/\n#define IsPowerOfTwo(X) (((X)&((X)-1))==0)\n\n/*\n** The following value as a destructor means to use sqlite3DbFree().\n** The sqlite3DbFree() routine requires two parameters instead of the \n** one parameter that destructors normally want.  So we have to introduce \n** this magic value that the code knows to handle differently.  Any \n** pointer will work here as long as it is distinct from SQLITE_STATIC\n** and SQLITE_TRANSIENT.\n*/\n#define SQLITE_DYNAMIC   ((sqlite3_destructor_type)sqlite3MallocSize)\n\n/*\n** When SQLITE_OMIT_WSD is defined, it means that the target platform does\n** not support Writable Static Data (WSD) such as global and static variables.\n** All variables must either be on the stack or dynamically allocated from\n** the heap.  When WSD is unsupported, the variable declarations scattered\n** throughout the SQLite code must become constants instead.  The SQLITE_WSD\n** macro is used for this purpose.  And instead of referencing the variable\n** directly, we use its constant as a key to lookup the run-time allocated\n** buffer that holds real variable.  The constant is also the initializer\n** for the run-time allocated buffer.\n**\n** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL\n** macros become no-ops and have zero performance impact.\n*/\n#ifdef SQLITE_OMIT_WSD\n  #define SQLITE_WSD const\n  #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))\n  #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)\nSQLITE_API   int sqlite3_wsd_init(int N, int J);\nSQLITE_API   void *sqlite3_wsd_find(void *K, int L);\n#else\n  #define SQLITE_WSD \n  #define GLOBAL(t,v) v\n  #define sqlite3GlobalConfig sqlite3Config\n#endif\n\n/*\n** The following macros are used to suppress compiler warnings and to\n** make it clear to human readers when a function parameter is deliberately \n** left unused within the body of a function. This usually happens when\n** a function is called via a function pointer. For example the \n** implementation of an SQL aggregate step callback may not use the\n** parameter indicating the number of arguments passed to the aggregate,\n** if it knows that this is enforced elsewhere.\n**\n** When a function parameter is not used at all within the body of a function,\n** it is generally named \"NotUsed\" or \"NotUsed2\" to make things even clearer.\n** However, these macros may also be used to suppress warnings related to\n** parameters that may or may not be used depending on compilation options.\n** For example those parameters only used in assert() statements. In these\n** cases the parameters are named as per the usual conventions.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)\n\n/*\n** Forward references to structures\n*/\ntypedef struct AggInfo AggInfo;\ntypedef struct AuthContext AuthContext;\ntypedef struct AutoincInfo AutoincInfo;\ntypedef struct Bitvec Bitvec;\ntypedef struct CollSeq CollSeq;\ntypedef struct Column Column;\ntypedef struct Db Db;\ntypedef struct Schema Schema;\ntypedef struct Expr Expr;\ntypedef struct ExprList ExprList;\ntypedef struct ExprSpan ExprSpan;\ntypedef struct FKey FKey;\ntypedef struct FuncDestructor FuncDestructor;\ntypedef struct FuncDef FuncDef;\ntypedef struct FuncDefHash FuncDefHash;\ntypedef struct IdList IdList;\ntypedef struct Index Index;\ntypedef struct IndexSample IndexSample;\ntypedef struct KeyClass KeyClass;\ntypedef struct KeyInfo KeyInfo;\ntypedef struct Lookaside Lookaside;\ntypedef struct LookasideSlot LookasideSlot;\ntypedef struct Module Module;\ntypedef struct NameContext NameContext;\ntypedef struct Parse Parse;\ntypedef struct RowSet RowSet;\ntypedef struct Savepoint Savepoint;\ntypedef struct Select Select;\ntypedef struct SelectDest SelectDest;\ntypedef struct SrcList SrcList;\ntypedef struct StrAccum StrAccum;\ntypedef struct Table Table;\ntypedef struct TableLock TableLock;\ntypedef struct Token Token;\ntypedef struct Trigger Trigger;\ntypedef struct TriggerPrg TriggerPrg;\ntypedef struct TriggerStep TriggerStep;\ntypedef struct UnpackedRecord UnpackedRecord;\ntypedef struct VTable VTable;\ntypedef struct VtabCtx VtabCtx;\ntypedef struct Walker Walker;\ntypedef struct WherePlan WherePlan;\ntypedef struct WhereInfo WhereInfo;\ntypedef struct WhereLevel WhereLevel;\n\n/*\n** Defer sourcing vdbe.h and btree.h until after the \"u8\" and \n** \"BusyHandler\" typedefs. vdbe.h also requires a few of the opaque\n** pointer types (i.e. FuncDef) defined above.\n*/\n/************** Include btree.h in the middle of sqliteInt.h *****************/\n/************** Begin file btree.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite B-Tree file\n** subsystem.  See comments in the source code for a detailed description\n** of what each interface routine does.\n*/\n#ifndef _BTREE_H_\n#define _BTREE_H_\n\n/* TODO: This definition is just included so other modules compile. It\n** needs to be revisited.\n*/\n#define SQLITE_N_BTREE_META 10\n\n/*\n** If defined as non-zero, auto-vacuum is enabled by default. Otherwise\n** it must be turned on for each database using \"PRAGMA auto_vacuum = 1\".\n*/\n#ifndef SQLITE_DEFAULT_AUTOVACUUM\n  #define SQLITE_DEFAULT_AUTOVACUUM 0\n#endif\n\n#define BTREE_AUTOVACUUM_NONE 0        /* Do not do auto-vacuum */\n#define BTREE_AUTOVACUUM_FULL 1        /* Do full auto-vacuum */\n#define BTREE_AUTOVACUUM_INCR 2        /* Incremental vacuum */\n\n/*\n** Forward declarations of structure\n*/\ntypedef struct Btree Btree;\ntypedef struct BtCursor BtCursor;\ntypedef struct BtShared BtShared;\n\n\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,       /* VFS to use with this b-tree */\n  const char *zFilename,   /* Name of database file to open */\n  sqlite3 *db,             /* Associated database connection */\n  Btree **ppBtree,         /* Return open Btree* here */\n  int flags,               /* Flags */\n  int vfsFlags             /* Flags passed through to VFS open */\n);\n\n/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the\n** following values.\n**\n** NOTE:  These values must match the corresponding PAGER_ values in\n** pager.h.\n*/\n#define BTREE_OMIT_JOURNAL  1  /* Do not create or use a rollback journal */\n#define BTREE_MEMORY        2  /* This is an in-memory DB */\n#define BTREE_SINGLE        4  /* The file contains at most 1 b-tree */\n#define BTREE_UNORDERED     8  /* Use of a hash implementation is OK */\n\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);\nSQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int);\nSQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags);\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);\n\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);\n\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);\n\n/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR\n** of the flags shown below.\n**\n** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.\n** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data\n** is stored in the leaves.  (BTREE_INTKEY is used for SQL tables.)  With\n** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored\n** anywhere - the key is the content.  (BTREE_BLOBKEY is used for SQL\n** indices.)\n*/\n#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */\n#define BTREE_BLOBKEY    2    /* Table has keys only - no data */\n\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);\nSQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);\n\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);\n\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);\n\n/*\n** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta\n** should be one of the following values. The integer values are assigned \n** to constants so that the offset of the corresponding field in an\n** SQLite database header may be found using the following formula:\n**\n**   offset = 36 + (idx * 4)\n**\n** For example, the free-page-count field is located at byte offset 36 of\n** the database file header. The incr-vacuum-flag field is located at\n** byte offset 64 (== 36+4*7).\n*/\n#define BTREE_FREE_PAGE_COUNT     0\n#define BTREE_SCHEMA_VERSION      1\n#define BTREE_FILE_FORMAT         2\n#define BTREE_DEFAULT_CACHE_SIZE  3\n#define BTREE_LARGEST_ROOT_PAGE   4\n#define BTREE_TEXT_ENCODING       5\n#define BTREE_USER_VERSION        6\n#define BTREE_INCR_VACUUM         7\n#define BTREE_APPLICATION_ID      8\n\n/*\n** Values that may be OR'd together to form the second argument of an\n** sqlite3BtreeCursorHints() call.\n*/\n#define BTREE_BULKLOAD 0x00000001\n\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree*,                              /* BTree containing table to open */\n  int iTable,                          /* Index of root page */\n  int wrFlag,                          /* 1 for writing.  0 for read-only */\n  struct KeyInfo*,                     /* First argument to compare function */\n  BtCursor *pCursor                    /* Space to write cursor structure */\n);\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void);\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);\n\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor*,\n  UnpackedRecord *pUnKey,\n  i64 intKey,\n  int bias,\n  int *pRes\n);\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*, int*);\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,\n                                  const void *pData, int nData,\n                                  int nZero, int bias, int seekResult);\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);\nSQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);\nSQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);\nSQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);\nSQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64);\nSQLITE_PRIVATE sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor*);\n\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);\nSQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);\n\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *);\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);\nSQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);\n\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);\n#endif\n\n#ifndef SQLITE_OMIT_BTREECOUNT\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);\nSQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);\n#endif\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);\n#endif\n\n/*\n** If we are not using shared cache, then there is no need to\n** use mutexes to access the BtShared structures.  So make the\n** Enter and Leave procedures no-ops.\n*/\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3BtreeEnter(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterAll(sqlite3*);\n#else\n# define sqlite3BtreeEnter(X) \n# define sqlite3BtreeEnterAll(X)\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE\nSQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeLeave(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveCursor(BtCursor*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveAll(sqlite3*);\n#ifndef NDEBUG\n  /* These routines are used inside assert() statements only. */\nSQLITE_PRIVATE   int sqlite3BtreeHoldsMutex(Btree*);\nSQLITE_PRIVATE   int sqlite3BtreeHoldsAllMutexes(sqlite3*);\nSQLITE_PRIVATE   int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);\n#endif\n#else\n\n# define sqlite3BtreeSharable(X) 0\n# define sqlite3BtreeLeave(X)\n# define sqlite3BtreeEnterCursor(X)\n# define sqlite3BtreeLeaveCursor(X)\n# define sqlite3BtreeLeaveAll(X)\n\n# define sqlite3BtreeHoldsMutex(X) 1\n# define sqlite3BtreeHoldsAllMutexes(X) 1\n# define sqlite3SchemaMutexHeld(X,Y,Z) 1\n#endif\n\n\n#endif /* _BTREE_H_ */\n\n/************** End of btree.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include vdbe.h in the middle of sqliteInt.h ******************/\n/************** Begin file vdbe.h ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Header file for the Virtual DataBase Engine (VDBE)\n**\n** This header defines the interface to the virtual database engine\n** or VDBE.  The VDBE implements an abstract machine that runs a\n** simple program to access and modify the underlying database.\n*/\n#ifndef _SQLITE_VDBE_H_\n#define _SQLITE_VDBE_H_\n/* #include <stdio.h> */\n\n/*\n** A single VDBE is an opaque structure named \"Vdbe\".  Only routines\n** in the source file sqliteVdbe.c are allowed to see the insides\n** of this structure.\n*/\ntypedef struct Vdbe Vdbe;\n\n/*\n** The names of the following types declared in vdbeInt.h are required\n** for the VdbeOp definition.\n*/\ntypedef struct VdbeFunc VdbeFunc;\ntypedef struct Mem Mem;\ntypedef struct SubProgram SubProgram;\n\n/*\n** A single instruction of the virtual machine has an opcode\n** and as many as three operands.  The instruction is recorded\n** as an instance of the following structure:\n*/\nstruct VdbeOp {\n  u8 opcode;          /* What operation to perform */\n  signed char p4type; /* One of the P4_xxx constants for p4 */\n  u8 opflags;         /* Mask of the OPFLG_* flags in opcodes.h */\n  u8 p5;              /* Fifth parameter is an unsigned character */\n  int p1;             /* First operand */\n  int p2;             /* Second parameter (often the jump destination) */\n  int p3;             /* The third parameter */\n  union {             /* fourth parameter */\n    int i;                 /* Integer value if p4type==P4_INT32 */\n    void *p;               /* Generic pointer */\n    char *z;               /* Pointer to data for string (char array) types */\n    i64 *pI64;             /* Used when p4type is P4_INT64 */\n    double *pReal;         /* Used when p4type is P4_REAL */\n    FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */\n    VdbeFunc *pVdbeFunc;   /* Used when p4type is P4_VDBEFUNC */\n    CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */\n    Mem *pMem;             /* Used when p4type is P4_MEM */\n    VTable *pVtab;         /* Used when p4type is P4_VTAB */\n    KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */\n    int *ai;               /* Used when p4type is P4_INTARRAY */\n    SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */\n    int (*xAdvance)(BtCursor *, int *);\n  } p4;\n#ifdef SQLITE_DEBUG\n  char *zComment;          /* Comment to improve readability */\n#endif\n#ifdef VDBE_PROFILE\n  int cnt;                 /* Number of times this instruction was executed */\n  u64 cycles;              /* Total time spent executing this instruction */\n#endif\n};\ntypedef struct VdbeOp VdbeOp;\n\n\n/*\n** A sub-routine used to implement a trigger program.\n*/\nstruct SubProgram {\n  VdbeOp *aOp;                  /* Array of opcodes for sub-program */\n  int nOp;                      /* Elements in aOp[] */\n  int nMem;                     /* Number of memory cells required */\n  int nCsr;                     /* Number of cursors required */\n  int nOnce;                    /* Number of OP_Once instructions */\n  void *token;                  /* id that may be used to recursive triggers */\n  SubProgram *pNext;            /* Next sub-program already visited */\n};\n\n/*\n** A smaller version of VdbeOp used for the VdbeAddOpList() function because\n** it takes up less space.\n*/\nstruct VdbeOpList {\n  u8 opcode;          /* What operation to perform */\n  signed char p1;     /* First operand */\n  signed char p2;     /* Second parameter (often the jump destination) */\n  signed char p3;     /* Third parameter */\n};\ntypedef struct VdbeOpList VdbeOpList;\n\n/*\n** Allowed values of VdbeOp.p4type\n*/\n#define P4_NOTUSED    0   /* The P4 parameter is not used */\n#define P4_DYNAMIC  (-1)  /* Pointer to a string obtained from sqliteMalloc() */\n#define P4_STATIC   (-2)  /* Pointer to a static string */\n#define P4_COLLSEQ  (-4)  /* P4 is a pointer to a CollSeq structure */\n#define P4_FUNCDEF  (-5)  /* P4 is a pointer to a FuncDef structure */\n#define P4_KEYINFO  (-6)  /* P4 is a pointer to a KeyInfo structure */\n#define P4_VDBEFUNC (-7)  /* P4 is a pointer to a VdbeFunc structure */\n#define P4_MEM      (-8)  /* P4 is a pointer to a Mem*    structure */\n#define P4_TRANSIENT  0   /* P4 is a pointer to a transient string */\n#define P4_VTAB     (-10) /* P4 is a pointer to an sqlite3_vtab structure */\n#define P4_MPRINTF  (-11) /* P4 is a string obtained from sqlite3_mprintf() */\n#define P4_REAL     (-12) /* P4 is a 64-bit floating point value */\n#define P4_INT64    (-13) /* P4 is a 64-bit signed integer */\n#define P4_INT32    (-14) /* P4 is a 32-bit signed integer */\n#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */\n#define P4_SUBPROGRAM  (-18) /* P4 is a pointer to a SubProgram structure */\n#define P4_ADVANCE  (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */\n\n/* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure\n** is made.  That copy is freed when the Vdbe is finalized.  But if the\n** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used.  It still\n** gets freed when the Vdbe is finalized so it still should be obtained\n** from a single sqliteMalloc().  But no copy is made and the calling\n** function should *not* try to free the KeyInfo.\n*/\n#define P4_KEYINFO_HANDOFF (-16)\n#define P4_KEYINFO_STATIC  (-17)\n\n/*\n** The Vdbe.aColName array contains 5n Mem structures, where n is the \n** number of columns of data returned by the statement.\n*/\n#define COLNAME_NAME     0\n#define COLNAME_DECLTYPE 1\n#define COLNAME_DATABASE 2\n#define COLNAME_TABLE    3\n#define COLNAME_COLUMN   4\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define COLNAME_N        5      /* Number of COLNAME_xxx symbols */\n#else\n# ifdef SQLITE_OMIT_DECLTYPE\n#   define COLNAME_N      1      /* Store only the name */\n# else\n#   define COLNAME_N      2      /* Store the name and decltype */\n# endif\n#endif\n\n/*\n** The following macro converts a relative address in the p2 field\n** of a VdbeOp structure into a negative number so that \n** sqlite3VdbeAddOpList() knows that the address is relative.  Calling\n** the macro again restores the address.\n*/\n#define ADDR(X)  (-1-(X))\n\n/*\n** The makefile scans the vdbe.c source file and creates the \"opcodes.h\"\n** header file that defines a number for each opcode used by the VDBE.\n*/\n/************** Include opcodes.h in the middle of vdbe.h ********************/\n/************** Begin file opcodes.h *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the mkopcodeh.awk script for details */\n#define OP_Goto                                 1\n#define OP_Gosub                                2\n#define OP_Return                               3\n#define OP_Yield                                4\n#define OP_HaltIfNull                           5\n#define OP_Halt                                 6\n#define OP_Integer                              7\n#define OP_Int64                                8\n#define OP_Real                               130   /* same as TK_FLOAT    */\n#define OP_String8                             94   /* same as TK_STRING   */\n#define OP_String                               9\n#define OP_Null                                10\n#define OP_Blob                                11\n#define OP_Variable                            12\n#define OP_Move                                13\n#define OP_Copy                                14\n#define OP_SCopy                               15\n#define OP_ResultRow                           16\n#define OP_Concat                              91   /* same as TK_CONCAT   */\n#define OP_Add                                 86   /* same as TK_PLUS     */\n#define OP_Subtract                            87   /* same as TK_MINUS    */\n#define OP_Multiply                            88   /* same as TK_STAR     */\n#define OP_Divide                              89   /* same as TK_SLASH    */\n#define OP_Remainder                           90   /* same as TK_REM      */\n#define OP_CollSeq                             17\n#define OP_Function                            18\n#define OP_BitAnd                              82   /* same as TK_BITAND   */\n#define OP_BitOr                               83   /* same as TK_BITOR    */\n#define OP_ShiftLeft                           84   /* same as TK_LSHIFT   */\n#define OP_ShiftRight                          85   /* same as TK_RSHIFT   */\n#define OP_AddImm                              20\n#define OP_MustBeInt                           21\n#define OP_RealAffinity                        22\n#define OP_ToText                             141   /* same as TK_TO_TEXT  */\n#define OP_ToBlob                             142   /* same as TK_TO_BLOB  */\n#define OP_ToNumeric                          143   /* same as TK_TO_NUMERIC*/\n#define OP_ToInt                              144   /* same as TK_TO_INT   */\n#define OP_ToReal                             145   /* same as TK_TO_REAL  */\n#define OP_Eq                                  76   /* same as TK_EQ       */\n#define OP_Ne                                  75   /* same as TK_NE       */\n#define OP_Lt                                  79   /* same as TK_LT       */\n#define OP_Le                                  78   /* same as TK_LE       */\n#define OP_Gt                                  77   /* same as TK_GT       */\n#define OP_Ge                                  80   /* same as TK_GE       */\n#define OP_Permutation                         23\n#define OP_Compare                             24\n#define OP_Jump                                25\n#define OP_And                                 69   /* same as TK_AND      */\n#define OP_Or                                  68   /* same as TK_OR       */\n#define OP_Not                                 19   /* same as TK_NOT      */\n#define OP_BitNot                              93   /* same as TK_BITNOT   */\n#define OP_Once                                26\n#define OP_If                                  27\n#define OP_IfNot                               28\n#define OP_IsNull                              73   /* same as TK_ISNULL   */\n#define OP_NotNull                             74   /* same as TK_NOTNULL  */\n#define OP_Column                              29\n#define OP_Affinity                            30\n#define OP_MakeRecord                          31\n#define OP_Count                               32\n#define OP_Savepoint                           33\n#define OP_AutoCommit                          34\n#define OP_Transaction                         35\n#define OP_ReadCookie                          36\n#define OP_SetCookie                           37\n#define OP_VerifyCookie                        38\n#define OP_OpenRead                            39\n#define OP_OpenWrite                           40\n#define OP_OpenAutoindex                       41\n#define OP_OpenEphemeral                       42\n#define OP_SorterOpen                          43\n#define OP_OpenPseudo                          44\n#define OP_Close                               45\n#define OP_SeekLt                              46\n#define OP_SeekLe                              47\n#define OP_SeekGe                              48\n#define OP_SeekGt                              49\n#define OP_Seek                                50\n#define OP_NotFound                            51\n#define OP_Found                               52\n#define OP_IsUnique                            53\n#define OP_NotExists                           54\n#define OP_Sequence                            55\n#define OP_NewRowid                            56\n#define OP_Insert                              57\n#define OP_InsertInt                           58\n#define OP_Delete                              59\n#define OP_ResetCount                          60\n#define OP_SorterCompare                       61\n#define OP_SorterData                          62\n#define OP_RowKey                              63\n#define OP_RowData                             64\n#define OP_Rowid                               65\n#define OP_NullRow                             66\n#define OP_Last                                67\n#define OP_SorterSort                          70\n#define OP_Sort                                71\n#define OP_Rewind                              72\n#define OP_SorterNext                          81\n#define OP_Prev                                92\n#define OP_Next                                95\n#define OP_SorterInsert                        96\n#define OP_IdxInsert                           97\n#define OP_IdxDelete                           98\n#define OP_IdxRowid                            99\n#define OP_IdxLT                              100\n#define OP_IdxGE                              101\n#define OP_Destroy                            102\n#define OP_Clear                              103\n#define OP_CreateIndex                        104\n#define OP_CreateTable                        105\n#define OP_ParseSchema                        106\n#define OP_LoadAnalysis                       107\n#define OP_DropTable                          108\n#define OP_DropIndex                          109\n#define OP_DropTrigger                        110\n#define OP_IntegrityCk                        111\n#define OP_RowSetAdd                          112\n#define OP_RowSetRead                         113\n#define OP_RowSetTest                         114\n#define OP_Program                            115\n#define OP_Param                              116\n#define OP_FkCounter                          117\n#define OP_FkIfZero                           118\n#define OP_MemMax                             119\n#define OP_IfPos                              120\n#define OP_IfNeg                              121\n#define OP_IfZero                             122\n#define OP_AggStep                            123\n#define OP_AggFinal                           124\n#define OP_Checkpoint                         125\n#define OP_JournalMode                        126\n#define OP_Vacuum                             127\n#define OP_IncrVacuum                         128\n#define OP_Expire                             129\n#define OP_TableLock                          131\n#define OP_VBegin                             132\n#define OP_VCreate                            133\n#define OP_VDestroy                           134\n#define OP_VOpen                              135\n#define OP_VFilter                            136\n#define OP_VColumn                            137\n#define OP_VNext                              138\n#define OP_VRename                            139\n#define OP_VUpdate                            140\n#define OP_Pagecount                          146\n#define OP_MaxPgcnt                           147\n#define OP_Trace                              148\n#define OP_Noop                               149\n#define OP_Explain                            150\n\n\n/* Properties such as \"out2\" or \"jump\" that are specified in\n** comments following the \"case\" for each opcode in the vdbe.c\n** are encoded into bitvectors as follows:\n*/\n#define OPFLG_JUMP            0x0001  /* jump:  P2 holds jmp target */\n#define OPFLG_OUT2_PRERELEASE 0x0002  /* out2-prerelease: */\n#define OPFLG_IN1             0x0004  /* in1:   P1 is an input */\n#define OPFLG_IN2             0x0008  /* in2:   P2 is an input */\n#define OPFLG_IN3             0x0010  /* in3:   P3 is an input */\n#define OPFLG_OUT2            0x0020  /* out2:  P2 is an output */\n#define OPFLG_OUT3            0x0040  /* out3:  P3 is an output */\n#define OPFLG_INITIALIZER {\\\n/*   0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\\\n/*   8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\\\n/*  16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\\\n/*  24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\\\n/*  32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\\\n/*  40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\\\n/*  48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\\\n/*  56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/*  64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\\\n/*  72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\\\n/*  80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\\\n/*  88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\\\n/*  96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\\\n/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\\\n/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\\\n/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\\\n/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,}\n\n/************** End of opcodes.h *********************************************/\n/************** Continuing where we left off in vdbe.h ***********************/\n\n/*\n** Prototypes for the VDBE interface.  See comments on the implementation\n** for a description of what each of these routines does.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(sqlite3*);\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5);\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);\nSQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr);\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);\nSQLITE_PRIVATE   void sqlite3VdbeTrace(Vdbe*,FILE*);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int);\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8);\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);\n#ifndef SQLITE_OMIT_TRACE\nSQLITE_PRIVATE   char *sqlite3VdbeExpandSql(Vdbe*, const char*);\n#endif\n\nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);\n#endif\n\n\n#ifndef NDEBUG\nSQLITE_PRIVATE   void sqlite3VdbeComment(Vdbe*, const char*, ...);\n# define VdbeComment(X)  sqlite3VdbeComment X\nSQLITE_PRIVATE   void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);\n# define VdbeNoopComment(X)  sqlite3VdbeNoopComment X\n#else\n# define VdbeComment(X)\n# define VdbeNoopComment(X)\n#endif\n\n#endif\n\n/************** End of vdbe.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pager.h in the middle of sqliteInt.h *****************/\n/************** Begin file pager.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem.  The page cache subsystem reads and writes a file a page\n** at a time and provides a journal for rollback.\n*/\n\n#ifndef _PAGER_H_\n#define _PAGER_H_\n\n/*\n** Default maximum size for persistent journal files. A negative \n** value means no limit. This value may be overridden using the \n** sqlite3PagerJournalSizeLimit() API. See also \"PRAGMA journal_size_limit\".\n*/\n#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1\n#endif\n\n/*\n** The type used to represent a page number.  The first page in a file\n** is called page 1.  0 is used to represent \"not a page\".\n*/\ntypedef u32 Pgno;\n\n/*\n** Each open file is managed by a separate instance of the \"Pager\" structure.\n*/\ntypedef struct Pager Pager;\n\n/*\n** Handle type for pages.\n*/\ntypedef struct PgHdr DbPage;\n\n/*\n** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is\n** reserved for working around a windows/posix incompatibility). It is\n** used in the journal to signify that the remainder of the journal file \n** is devoted to storing a master journal name - there are no more pages to\n** roll back. See comments for function writeMasterJournal() in pager.c \n** for details.\n*/\n#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))\n\n/*\n** Allowed values for the flags parameter to sqlite3PagerOpen().\n**\n** NOTE: These values must match the corresponding BTREE_ values in btree.h.\n*/\n#define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */\n#define PAGER_MEMORY        0x0002    /* In-memory database */\n\n/*\n** Valid values for the second argument to sqlite3PagerLockingMode().\n*/\n#define PAGER_LOCKINGMODE_QUERY      -1\n#define PAGER_LOCKINGMODE_NORMAL      0\n#define PAGER_LOCKINGMODE_EXCLUSIVE   1\n\n/*\n** Numeric constants that encode the journalmode.  \n*/\n#define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */\n#define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */\n#define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */\n#define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */\n#define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */\n#define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */\n#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */\n\n/*\n** Flags that make up the mask passed to sqlite3PagerAcquire().\n*/\n#define PAGER_ACQUIRE_NOCONTENT     0x01  /* Do not load data from disk */\n#define PAGER_ACQUIRE_READONLY      0x02  /* Read-only page is acceptable */\n\n/*\n** The remainder of this file contains the declarations of the functions\n** that make up the Pager sub-system API. See source code comments for \n** a detailed description of each routine.\n*/\n\n/* Open and close a Pager connection. */ \nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs*,\n  Pager **ppPager,\n  const char*,\n  int,\n  int,\n  int,\n  void(*)(DbPage*)\n);\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager);\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);\n\n/* Functions used to configure a Pager object. */\nSQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager*);\nSQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int,int);\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);\n\n/* Functions used to obtain and release page references. */ \nSQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);\n#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage*);\n\n/* Operations on page references. */\nSQLITE_PRIVATE int sqlite3PagerWrite(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerDontWrite(DbPage*);\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage*);\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); \nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); \n\n/* Functions used to manage pager transactions and savepoints. */\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*);\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*);\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*);\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);\nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3PagerWalSupported(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerWalCallback(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);\nSQLITE_PRIVATE   int sqlite3PagerCloseWal(Pager *pPager);\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\nSQLITE_PRIVATE   int sqlite3PagerWalFramesize(Pager *pPager);\n#endif\n\n/* Functions used to query pager state and configuration. */\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);\nSQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);\nSQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*);\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);\nSQLITE_PRIVATE int sqlite3PagerNosync(Pager*);\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager *);\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);\n\n/* Functions used to truncate the database file. */\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);\n\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)\nSQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);\n#endif\n\n/* Functions to support testing and debugging. */\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\nSQLITE_PRIVATE   Pgno sqlite3PagerPagenumber(DbPage*);\nSQLITE_PRIVATE   int sqlite3PagerIswriteable(DbPage*);\n#endif\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int *sqlite3PagerStats(Pager*);\nSQLITE_PRIVATE   void sqlite3PagerRefdump(Pager*);\n  void disable_simulated_io_errors(void);\n  void enable_simulated_io_errors(void);\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n#endif /* _PAGER_H_ */\n\n/************** End of pager.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pcache.h in the middle of sqliteInt.h ****************/\n/************** Begin file pcache.h ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem. \n*/\n\n#ifndef _PCACHE_H_\n\ntypedef struct PgHdr PgHdr;\ntypedef struct PCache PCache;\n\n/*\n** Every page in the cache is controlled by an instance of the following\n** structure.\n*/\nstruct PgHdr {\n  sqlite3_pcache_page *pPage;    /* Pcache object page handle */\n  void *pData;                   /* Page data */\n  void *pExtra;                  /* Extra content */\n  PgHdr *pDirty;                 /* Transient list of dirty pages */\n  Pager *pPager;                 /* The pager this page is part of */\n  Pgno pgno;                     /* Page number for this page */\n#ifdef SQLITE_CHECK_PAGES\n  u32 pageHash;                  /* Hash of page content */\n#endif\n  u16 flags;                     /* PGHDR flags defined below */\n\n  /**********************************************************************\n  ** Elements above are public.  All that follows is private to pcache.c\n  ** and should not be accessed by other modules.\n  */\n  i16 nRef;                      /* Number of users of this page */\n  PCache *pCache;                /* Cache that owns this page */\n\n  PgHdr *pDirtyNext;             /* Next element in list of dirty pages */\n  PgHdr *pDirtyPrev;             /* Previous element in list of dirty pages */\n};\n\n/* Bit values for PgHdr.flags */\n#define PGHDR_DIRTY             0x002  /* Page has changed */\n#define PGHDR_NEED_SYNC         0x004  /* Fsync the rollback journal before\n                                       ** writing this page to the database */\n#define PGHDR_NEED_READ         0x008  /* Content is unread */\n#define PGHDR_REUSE_UNLIKELY    0x010  /* A hint that reuse is unlikely */\n#define PGHDR_DONT_WRITE        0x020  /* Do not write content to disk */\n\n#define PGHDR_MMAP              0x040  /* This is an mmap page object */\n\n/* Initialize and shutdown the page cache subsystem */\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void);\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void);\n\n/* Page cache buffer management:\n** These routines implement SQLITE_CONFIG_PAGECACHE.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *, int sz, int n);\n\n/* Create a new pager cache.\n** Under memory stress, invoke xStress to try to make pages clean.\n** Only clean and unpinned pages can be reclaimed.\n*/\nSQLITE_PRIVATE void sqlite3PcacheOpen(\n  int szPage,                    /* Size of every page */\n  int szExtra,                   /* Extra space associated with each page */\n  int bPurgeable,                /* True if pages are on backing store */\n  int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */\n  void *pStress,                 /* Argument to xStress */\n  PCache *pToInit                /* Preallocated space for the PCache */\n);\n\n/* Modify the page-size after the cache has been created. */\nSQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *, int);\n\n/* Return the size in bytes of a PCache object.  Used to preallocate\n** storage space.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void);\n\n/* One release per successful fetch.  Page is pinned until released.\n** Reference counted. \n*/\nSQLITE_PRIVATE int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**);\nSQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*);\n\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr*);    /* Make sure page is marked dirty */\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr*);    /* Mark a single page as clean */\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache*);    /* Mark all dirty list pages as clean */\n\n/* Change a page number.  Used by incr-vacuum. */\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr*, Pgno);\n\n/* Remove all pages with pgno>x.  Reset the cache if x==0 */\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache*, Pgno x);\n\n/* Get a list of all dirty pages in the cache, sorted by page number */\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache*);\n\n/* Reset and close the cache object */\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache*);\n\n/* Clear flags from pages of the page cache */\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *);\n\n/* Discard the contents of the cache */\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache*);\n\n/* Return the total number of outstanding page references */\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*);\n\n/* Increment the reference count of an existing page */\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*);\n\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*);\n\n/* Return the total number of pages stored in the cache */\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache*);\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/* Iterate through all dirty pages currently stored in the cache. This\n** interface is only available if SQLITE_CHECK_PAGES is defined when the \n** library is built.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));\n#endif\n\n/* Set and get the suggested cache-size for the specified pager-cache.\n**\n** If no global maximum is configured, then the system attempts to limit\n** the total number of pages cached by purgeable pager-caches to the sum\n** of the suggested cache-sizes.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *);\n#endif\n\n/* Free up as much memory as possible from the page cache */\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache*);\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/* Try to return memory used by the pcache module to the main memory heap */\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*);\n#endif\n\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void);\n\n#endif /* _PCACHE_H_ */\n\n/************** End of pcache.h **********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/************** Include os.h in the middle of sqliteInt.h ********************/\n/************** Begin file os.h **********************************************/\n/*\n** 2001 September 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file (together with is companion C source-code file\n** \"os.c\") attempt to abstract the underlying operating system so that\n** the SQLite library will work on both POSIX and windows systems.\n**\n** This header file is #include-ed by sqliteInt.h and thus ends up\n** being included by every source file.\n*/\n#ifndef _SQLITE_OS_H_\n#define _SQLITE_OS_H_\n\n/*\n** Figure out if we are dealing with Unix, Windows, or some other\n** operating system.  After the following block of preprocess macros,\n** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, and SQLITE_OS_OTHER \n** will defined to either 1 or 0.  One of the four will be 1.  The other \n** three will be 0.\n*/\n#if defined(SQLITE_OS_OTHER)\n# if SQLITE_OS_OTHER==1\n#   undef SQLITE_OS_UNIX\n#   define SQLITE_OS_UNIX 0\n#   undef SQLITE_OS_WIN\n#   define SQLITE_OS_WIN 0\n# else\n#   undef SQLITE_OS_OTHER\n# endif\n#endif\n#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER)\n# define SQLITE_OS_OTHER 0\n# ifndef SQLITE_OS_WIN\n#   if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)\n#     define SQLITE_OS_WIN 1\n#     define SQLITE_OS_UNIX 0\n#   else\n#     define SQLITE_OS_WIN 0\n#     define SQLITE_OS_UNIX 1\n#  endif\n# else\n#  define SQLITE_OS_UNIX 0\n# endif\n#else\n# ifndef SQLITE_OS_WIN\n#  define SQLITE_OS_WIN 0\n# endif\n#endif\n\n#if SQLITE_OS_WIN\n# include <windows.h>\n#endif\n\n/*\n** Determine if we are dealing with Windows NT.\n**\n** We ought to be able to determine if we are compiling for win98 or winNT\n** using the _WIN32_WINNT macro as follows:\n**\n** #if defined(_WIN32_WINNT)\n** # define SQLITE_OS_WINNT 1\n** #else\n** # define SQLITE_OS_WINNT 0\n** #endif\n**\n** However, vs2005 does not set _WIN32_WINNT by default, as it ought to,\n** so the above test does not work.  We'll just assume that everything is\n** winNT unless the programmer explicitly says otherwise by setting\n** SQLITE_OS_WINNT to 0.\n*/\n#if SQLITE_OS_WIN && !defined(SQLITE_OS_WINNT)\n# define SQLITE_OS_WINNT 1\n#endif\n\n/*\n** Determine if we are dealing with WindowsCE - which has a much\n** reduced API.\n*/\n#if defined(_WIN32_WCE)\n# define SQLITE_OS_WINCE 1\n#else\n# define SQLITE_OS_WINCE 0\n#endif\n\n/*\n** Determine if we are dealing with WinRT, which provides only a subset of\n** the full Win32 API.\n*/\n#if !defined(SQLITE_OS_WINRT)\n# define SQLITE_OS_WINRT 0\n#endif\n\n/* If the SET_FULLSYNC macro is not defined above, then make it\n** a no-op\n*/\n#ifndef SET_FULLSYNC\n# define SET_FULLSYNC(x,y)\n#endif\n\n/*\n** The default size of a disk sector\n*/\n#ifndef SQLITE_DEFAULT_SECTOR_SIZE\n# define SQLITE_DEFAULT_SECTOR_SIZE 4096\n#endif\n\n/*\n** Temporary files are named starting with this prefix followed by 16 random\n** alphanumeric characters, and no file extension. They are stored in the\n** OS's standard temporary file directory, and are deleted prior to exit.\n** If sqlite is being embedded in another program, you may wish to change the\n** prefix to reflect your program's name, so that if your program exits\n** prematurely, old temporary files can be easily identified. This can be done\n** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.\n**\n** 2006-10-31:  The default prefix used to be \"sqlite_\".  But then\n** Mcafee started using SQLite in their anti-virus product and it\n** started putting files with the \"sqlite\" name in the c:/temp folder.\n** This annoyed many windows users.  Those users would then do a \n** Google search for \"sqlite\", find the telephone numbers of the\n** developers and call to wake them up at night and complain.\n** For this reason, the default name prefix is changed to be \"sqlite\" \n** spelled backwards.  So the temp files are still identified, but\n** anybody smart enough to figure out the code is also likely smart\n** enough to know that calling the developer will not help get rid\n** of the file.\n*/\n#ifndef SQLITE_TEMP_FILE_PREFIX\n# define SQLITE_TEMP_FILE_PREFIX \"etilqs_\"\n#endif\n\n/*\n** The following values may be passed as the second argument to\n** sqlite3OsLock(). The various locks exhibit the following semantics:\n**\n** SHARED:    Any number of processes may hold a SHARED lock simultaneously.\n** RESERVED:  A single process may hold a RESERVED lock on a file at\n**            any time. Other processes may hold and obtain new SHARED locks.\n** PENDING:   A single process may hold a PENDING lock on a file at\n**            any one time. Existing SHARED locks may persist, but no new\n**            SHARED locks may be obtained by other processes.\n** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.\n**\n** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a\n** process that requests an EXCLUSIVE lock may actually obtain a PENDING\n** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to\n** sqlite3OsLock().\n*/\n#define NO_LOCK         0\n#define SHARED_LOCK     1\n#define RESERVED_LOCK   2\n#define PENDING_LOCK    3\n#define EXCLUSIVE_LOCK  4\n\n/*\n** File Locking Notes:  (Mostly about windows but also some info for Unix)\n**\n** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because\n** those functions are not available.  So we use only LockFile() and\n** UnlockFile().\n**\n** LockFile() prevents not just writing but also reading by other processes.\n** A SHARED_LOCK is obtained by locking a single randomly-chosen \n** byte out of a specific range of bytes. The lock byte is obtained at \n** random so two separate readers can probably access the file at the \n** same time, unless they are unlucky and choose the same lock byte.\n** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range.\n** There can only be one writer.  A RESERVED_LOCK is obtained by locking\n** a single byte of the file that is designated as the reserved lock byte.\n** A PENDING_LOCK is obtained by locking a designated byte different from\n** the RESERVED_LOCK byte.\n**\n** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,\n** which means we can use reader/writer locks.  When reader/writer locks\n** are used, the lock is placed on the same range of bytes that is used\n** for probabilistic locking in Win95/98/ME.  Hence, the locking scheme\n** will support two or more Win95 readers or two or more WinNT readers.\n** But a single Win95 reader will lock out all WinNT readers and a single\n** WinNT reader will lock out all other Win95 readers.\n**\n** The following #defines specify the range of bytes used for locking.\n** SHARED_SIZE is the number of bytes available in the pool from which\n** a random byte is selected for a shared lock.  The pool of bytes for\n** shared locks begins at SHARED_FIRST. \n**\n** The same locking strategy and\n** byte ranges are used for Unix.  This leaves open the possiblity of having\n** clients on win95, winNT, and unix all talking to the same shared file\n** and all locking correctly.  To do so would require that samba (or whatever\n** tool is being used for file sharing) implements locks correctly between\n** windows and unix.  I'm guessing that isn't likely to happen, but by\n** using the same locking range we are at least open to the possibility.\n**\n** Locking in windows is manditory.  For this reason, we cannot store\n** actual data in the bytes used for locking.  The pager never allocates\n** the pages involved in locking therefore.  SHARED_SIZE is selected so\n** that all locks will fit on a single page even at the minimum page size.\n** PENDING_BYTE defines the beginning of the locks.  By default PENDING_BYTE\n** is set high so that we don't have to allocate an unused page except\n** for very large databases.  But one should test the page skipping logic \n** by setting PENDING_BYTE low and running the entire regression suite.\n**\n** Changing the value of PENDING_BYTE results in a subtly incompatible\n** file format.  Depending on how it is changed, you might not notice\n** the incompatibility right away, even running a full regression test.\n** The default location of PENDING_BYTE is the first byte past the\n** 1GB boundary.\n**\n*/\n#ifdef SQLITE_OMIT_WSD\n# define PENDING_BYTE     (0x40000000)\n#else\n# define PENDING_BYTE      sqlite3PendingByte\n#endif\n#define RESERVED_BYTE     (PENDING_BYTE+1)\n#define SHARED_FIRST      (PENDING_BYTE+2)\n#define SHARED_SIZE       510\n\n/*\n** Wrapper around OS specific sqlite3_os_init() function.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void);\n\n/* \n** Functions for accessing sqlite3_file methods \n*/\nSQLITE_PRIVATE int sqlite3OsClose(sqlite3_file*);\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file*, i64 size);\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file*,int,void*);\n#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **);\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int, int, int);\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int);\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64, int, void **);\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *, i64, void *);\n\n\n/* \n** Functions for accessing sqlite3_vfs methods \n*/\nSQLITE_PRIVATE int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *);\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *, const char *, int);\nSQLITE_PRIVATE int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *, const char *);\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void);\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int);\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);\n\n/*\n** Convenience functions for opening and closing files using \n** sqlite3_malloc() to obtain space for the file-handle structure.\n*/\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);\nSQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *);\n\n#endif /* _SQLITE_OS_H_ */\n\n/************** End of os.h **************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include mutex.h in the middle of sqliteInt.h *****************/\n/************** Begin file mutex.h *******************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the common header for all mutex implementations.\n** The sqliteInt.h header #includes this file so that it is available\n** to all source files.  We break it out in an effort to keep the code\n** better organized.\n**\n** NOTE:  source files should *not* #include this header file directly.\n** Source files should #include the sqliteInt.h file and let that file\n** include this one indirectly.\n*/\n\n\n/*\n** Figure out what version of the code to use.  The choices are\n**\n**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The\n**                             mutexes implemention cannot be overridden\n**                             at start-time.\n**\n**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No\n**                             mutual exclusion is provided.  But this\n**                             implementation can be overridden at\n**                             start-time.\n**\n**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.\n**\n**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.\n*/\n#if !SQLITE_THREADSAFE\n# define SQLITE_MUTEX_OMIT\n#endif\n#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)\n#  if SQLITE_OS_UNIX\n#    define SQLITE_MUTEX_PTHREADS\n#  elif SQLITE_OS_WIN\n#    define SQLITE_MUTEX_W32\n#  else\n#    define SQLITE_MUTEX_NOOP\n#  endif\n#endif\n\n#ifdef SQLITE_MUTEX_OMIT\n/*\n** If this is a no-op implementation, implement everything as macros.\n*/\n#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)\n#define sqlite3_mutex_free(X)\n#define sqlite3_mutex_enter(X)    \n#define sqlite3_mutex_try(X)      SQLITE_OK\n#define sqlite3_mutex_leave(X)    \n#define sqlite3_mutex_held(X)     ((void)(X),1)\n#define sqlite3_mutex_notheld(X)  ((void)(X),1)\n#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)\n#define sqlite3MutexInit()        SQLITE_OK\n#define sqlite3MutexEnd()\n#define MUTEX_LOGIC(X)\n#else\n#define MUTEX_LOGIC(X)            X\n#endif /* defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n\n/*\n** Each database file to be accessed by the system is an instance\n** of the following structure.  There are normally two of these structures\n** in the sqlite.aDb[] array.  aDb[0] is the main database file and\n** aDb[1] is the database file used to hold temporary tables.  Additional\n** databases may be attached.\n*/\nstruct Db {\n  char *zName;         /* Name of this database */\n  Btree *pBt;          /* The B*Tree structure for this database file */\n  u8 inTrans;          /* 0: not writable.  1: Transaction.  2: Checkpoint */\n  u8 safety_level;     /* How aggressive at syncing data to disk */\n  Schema *pSchema;     /* Pointer to database schema (possibly shared) */\n};\n\n/*\n** An instance of the following structure stores a database schema.\n**\n** Most Schema objects are associated with a Btree.  The exception is\n** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.\n** In shared cache mode, a single Schema object can be shared by multiple\n** Btrees that refer to the same underlying BtShared object.\n** \n** Schema objects are automatically deallocated when the last Btree that\n** references them is destroyed.   The TEMP Schema is manually freed by\n** sqlite3_close().\n*\n** A thread must be holding a mutex on the corresponding Btree in order\n** to access Schema content.  This implies that the thread must also be\n** holding a mutex on the sqlite3 connection pointer that owns the Btree.\n** For a TEMP Schema, only the connection mutex is required.\n*/\nstruct Schema {\n  int schema_cookie;   /* Database schema version number for this file */\n  int iGeneration;     /* Generation counter.  Incremented with each change */\n  Hash tblHash;        /* All tables indexed by name */\n  Hash idxHash;        /* All (named) indices indexed by name */\n  Hash trigHash;       /* All triggers indexed by name */\n  Hash fkeyHash;       /* All foreign keys by referenced table name */\n  Table *pSeqTab;      /* The sqlite_sequence table used by AUTOINCREMENT */\n  u8 file_format;      /* Schema format version for this file */\n  u8 enc;              /* Text encoding used by this database */\n  u16 flags;           /* Flags associated with this schema */\n  int cache_size;      /* Number of pages to use in the cache */\n};\n\n/*\n** These macros can be used to test, set, or clear bits in the \n** Db.pSchema->flags field.\n*/\n#define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->flags&(P))==(P))\n#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].pSchema->flags&(P))!=0)\n#define DbSetProperty(D,I,P)     (D)->aDb[I].pSchema->flags|=(P)\n#define DbClearProperty(D,I,P)   (D)->aDb[I].pSchema->flags&=~(P)\n\n/*\n** Allowed values for the DB.pSchema->flags field.\n**\n** The DB_SchemaLoaded flag is set after the database schema has been\n** read into internal hash tables.\n**\n** DB_UnresetViews means that one or more views have column names that\n** have been filled out.  If the schema changes, these column names might\n** changes and so the view will need to be reset.\n*/\n#define DB_SchemaLoaded    0x0001  /* The schema has been loaded */\n#define DB_UnresetViews    0x0002  /* Some views have defined column names */\n#define DB_Empty           0x0004  /* The file is empty (length 0 bytes) */\n\n/*\n** The number of different kinds of things that can be limited\n** using the sqlite3_limit() interface.\n*/\n#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1)\n\n/*\n** Lookaside malloc is a set of fixed-size buffers that can be used\n** to satisfy small transient memory allocation requests for objects\n** associated with a particular database connection.  The use of\n** lookaside malloc provides a significant performance enhancement\n** (approx 10%) by avoiding numerous malloc/free requests while parsing\n** SQL statements.\n**\n** The Lookaside structure holds configuration information about the\n** lookaside malloc subsystem.  Each available memory allocation in\n** the lookaside subsystem is stored on a linked list of LookasideSlot\n** objects.\n**\n** Lookaside allocations are only allowed for objects that are associated\n** with a particular database connection.  Hence, schema information cannot\n** be stored in lookaside because in shared cache mode the schema information\n** is shared by multiple database connections.  Therefore, while parsing\n** schema information, the Lookaside.bEnabled flag is cleared so that\n** lookaside allocations are not used to construct the schema objects.\n*/\nstruct Lookaside {\n  u16 sz;                 /* Size of each buffer in bytes */\n  u8 bEnabled;            /* False to disable new lookaside allocations */\n  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */\n  int nOut;               /* Number of buffers currently checked out */\n  int mxOut;              /* Highwater mark for nOut */\n  int anStat[3];          /* 0: hits.  1: size misses.  2: full misses */\n  LookasideSlot *pFree;   /* List of available buffers */\n  void *pStart;           /* First byte of available memory space */\n  void *pEnd;             /* First byte past end of available space */\n};\nstruct LookasideSlot {\n  LookasideSlot *pNext;    /* Next buffer in the list of free buffers */\n};\n\n/*\n** A hash table for function definitions.\n**\n** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.\n** Collisions are on the FuncDef.pHash chain.\n*/\nstruct FuncDefHash {\n  FuncDef *a[23];       /* Hash table for functions */\n};\n\n/*\n** Each database connection is an instance of the following structure.\n*/\nstruct sqlite3 {\n  sqlite3_vfs *pVfs;            /* OS Interface */\n  struct Vdbe *pVdbe;           /* List of active virtual machines */\n  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */\n  sqlite3_mutex *mutex;         /* Connection mutex */\n  Db *aDb;                      /* All backends */\n  int nDb;                      /* Number of backends currently in use */\n  int flags;                    /* Miscellaneous flags. See below */\n  i64 lastRowid;                /* ROWID of most recent insert (see above) */\n  i64 szMmap;                   /* Default mmap_size setting */\n  unsigned int openFlags;       /* Flags passed to sqlite3_vfs.xOpen() */\n  int errCode;                  /* Most recent error code (SQLITE_*) */\n  int errMask;                  /* & result codes with this before returning */\n  u16 dbOptFlags;               /* Flags to enable/disable optimizations */\n  u8 autoCommit;                /* The auto-commit flag. */\n  u8 temp_store;                /* 1: file 2: memory 0: default */\n  u8 mallocFailed;              /* True if we have seen a malloc failure */\n  u8 dfltLockMode;              /* Default locking-mode for attached dbs */\n  signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */\n  u8 suppressErr;               /* Do not issue error messages if true */\n  u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */\n  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */\n  int nextPagesize;             /* Pagesize after VACUUM if >0 */\n  u32 magic;                    /* Magic number for detect library misuse */\n  int nChange;                  /* Value returned by sqlite3_changes() */\n  int nTotalChange;             /* Value returned by sqlite3_total_changes() */\n  int aLimit[SQLITE_N_LIMIT];   /* Limits */\n  struct sqlite3InitInfo {      /* Information used during initialization */\n    int newTnum;                /* Rootpage of table being initialized */\n    u8 iDb;                     /* Which db file is being initialized */\n    u8 busy;                    /* TRUE if currently initializing */\n    u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */\n  } init;\n  int activeVdbeCnt;            /* Number of VDBEs currently executing */\n  int writeVdbeCnt;             /* Number of active VDBEs that are writing */\n  int vdbeExecCnt;              /* Number of nested calls to VdbeExec() */\n  int nExtension;               /* Number of loaded extensions */\n  void **aExtension;            /* Array of shared library handles */\n  void (*xTrace)(void*,const char*);        /* Trace function */\n  void *pTraceArg;                          /* Argument to the trace function */\n  void (*xProfile)(void*,const char*,u64);  /* Profiling function */\n  void *pProfileArg;                        /* Argument to profile function */\n  void *pCommitArg;                 /* Argument to xCommitCallback() */   \n  int (*xCommitCallback)(void*);    /* Invoked at every commit. */\n  void *pRollbackArg;               /* Argument to xRollbackCallback() */   \n  void (*xRollbackCallback)(void*); /* Invoked at every commit. */\n  void *pUpdateArg;\n  void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);\n#ifndef SQLITE_OMIT_WAL\n  int (*xWalCallback)(void *, sqlite3 *, const char *, int);\n  void *pWalArg;\n#endif\n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);\n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);\n  void *pCollNeededArg;\n  sqlite3_value *pErr;          /* Most recent error message */\n  char *zErrMsg;                /* Most recent error message (UTF-8 encoded) */\n  char *zErrMsg16;              /* Most recent error message (UTF-16 encoded) */\n  union {\n    volatile int isInterrupted; /* True if sqlite3_interrupt has been called */\n    double notUsed1;            /* Spacer */\n  } u1;\n  Lookaside lookaside;          /* Lookaside malloc configuration */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);\n                                /* Access authorization function */\n  void *pAuthArg;               /* 1st argument to the access auth function */\n#endif\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  int (*xProgress)(void *);     /* The progress callback */\n  void *pProgressArg;           /* Argument to the progress callback */\n  int nProgressOps;             /* Number of opcodes for progress callback */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nVTrans;                  /* Allocated size of aVTrans */\n  Hash aModule;                 /* populated by sqlite3_create_module() */\n  VtabCtx *pVtabCtx;            /* Context for active vtab connect/create */\n  VTable **aVTrans;             /* Virtual tables with open transactions */\n  VTable *pDisconnect;    /* Disconnect these in next sqlite3_prepare() */\n#endif\n  FuncDefHash aFunc;            /* Hash table of connection functions */\n  Hash aCollSeq;                /* All collating sequences */\n  BusyHandler busyHandler;      /* Busy callback */\n  Db aDbStatic[2];              /* Static space for the 2 default backends */\n  Savepoint *pSavepoint;        /* List of active savepoints */\n  int busyTimeout;              /* Busy handler timeout, in msec */\n  int nSavepoint;               /* Number of non-transaction savepoints */\n  int nStatement;               /* Number of nested statement-transactions  */\n  i64 nDeferredCons;            /* Net deferred constraints this transaction. */\n  int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  /* The following variables are all protected by the STATIC_MASTER \n  ** mutex, not by sqlite3.mutex. They are used by code in notify.c. \n  **\n  ** When X.pUnlockConnection==Y, that means that X is waiting for Y to\n  ** unlock so that it can proceed.\n  **\n  ** When X.pBlockingConnection==Y, that means that something that X tried\n  ** tried to do recently failed with an SQLITE_LOCKED error due to locks\n  ** held by Y.\n  */\n  sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */\n  sqlite3 *pUnlockConnection;           /* Connection to watch for unlock */\n  void *pUnlockArg;                     /* Argument to xUnlockNotify */\n  void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */\n  sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */\n#endif\n};\n\n/*\n** A macro to discover the encoding of a database.\n*/\n#define ENC(db) ((db)->aDb[0].pSchema->enc)\n\n/*\n** Possible values for the sqlite3.flags.\n*/\n#define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */\n#define SQLITE_InternChanges  0x00000002  /* Uncommitted Hash table changes */\n#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */\n#define SQLITE_ShortColNames  0x00000008  /* Show short columns names */\n#define SQLITE_CountRows      0x00000010  /* Count rows changed by INSERT, */\n                                          /*   DELETE, or UPDATE and return */\n                                          /*   the count using a callback. */\n#define SQLITE_NullCallback   0x00000020  /* Invoke the callback once if the */\n                                          /*   result set is empty */\n#define SQLITE_SqlTrace       0x00000040  /* Debug print SQL as it executes */\n#define SQLITE_VdbeListing    0x00000080  /* Debug listings of VDBE programs */\n#define SQLITE_WriteSchema    0x00000100  /* OK to update SQLITE_MASTER */\n#define SQLITE_VdbeAddopTrace 0x00000200  /* Trace sqlite3VdbeAddOp() calls */\n#define SQLITE_IgnoreChecks   0x00000400  /* Do not enforce check constraints */\n#define SQLITE_ReadUncommitted 0x0000800  /* For shared-cache mode */\n#define SQLITE_LegacyFileFmt  0x00001000  /* Create new databases in format 1 */\n#define SQLITE_FullFSync      0x00002000  /* Use full fsync on the backend */\n#define SQLITE_CkptFullFSync  0x00004000  /* Use full fsync for checkpoint */\n#define SQLITE_RecoveryMode   0x00008000  /* Ignore schema errors */\n#define SQLITE_ReverseOrder   0x00010000  /* Reverse unordered SELECTs */\n#define SQLITE_RecTriggers    0x00020000  /* Enable recursive triggers */\n#define SQLITE_ForeignKeys    0x00040000  /* Enforce foreign key constraints  */\n#define SQLITE_AutoIndex      0x00080000  /* Enable automatic indexes */\n#define SQLITE_PreferBuiltin  0x00100000  /* Preference to built-in funcs */\n#define SQLITE_LoadExtension  0x00200000  /* Enable load_extension */\n#define SQLITE_EnableTrigger  0x00400000  /* True to enable triggers */\n\n/*\n** Bits of the sqlite3.dbOptFlags field that are used by the\n** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to\n** selectively disable various optimizations.\n*/\n#define SQLITE_QueryFlattener 0x0001   /* Query flattening */\n#define SQLITE_ColumnCache    0x0002   /* Column cache */\n#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */\n#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */\n#define SQLITE_IdxRealAsInt   0x0010   /* Store REAL as INT in indices */\n#define SQLITE_DistinctOpt    0x0020   /* DISTINCT using indexes */\n#define SQLITE_CoverIdxScan   0x0040   /* Covering index scans */\n#define SQLITE_OrderByIdxJoin 0x0080   /* ORDER BY of joins via index */\n#define SQLITE_SubqCoroutine  0x0100   /* Evaluate subqueries as coroutines */\n#define SQLITE_Transitive     0x0200   /* Transitive constraints */\n#define SQLITE_AllOpts        0xffff   /* All optimizations */\n\n/*\n** Macros for testing whether or not optimizations are enabled or disabled.\n*/\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)\n#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)\n#else\n#define OptimizationDisabled(db, mask)  0\n#define OptimizationEnabled(db, mask)   1\n#endif\n\n/*\n** Possible values for the sqlite.magic field.\n** The numbers are obtained at random and have no special meaning, other\n** than being distinct from one another.\n*/\n#define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */\n#define SQLITE_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */\n#define SQLITE_MAGIC_SICK     0x4b771290  /* Error and awaiting close */\n#define SQLITE_MAGIC_BUSY     0xf03b7906  /* Database currently in use */\n#define SQLITE_MAGIC_ERROR    0xb5357930  /* An SQLITE_MISUSE error occurred */\n#define SQLITE_MAGIC_ZOMBIE   0x64cffc7f  /* Close with last statement close */\n\n/*\n** Each SQL function is defined by an instance of the following\n** structure.  A pointer to this structure is stored in the sqlite.aFunc\n** hash table.  When multiple functions have the same name, the hash table\n** points to a linked list of these structures.\n*/\nstruct FuncDef {\n  i16 nArg;            /* Number of arguments.  -1 means unlimited */\n  u8 iPrefEnc;         /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */\n  u8 flags;            /* Some combination of SQLITE_FUNC_* */\n  void *pUserData;     /* User data parameter */\n  FuncDef *pNext;      /* Next function with same name */\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */\n  void (*xFinalize)(sqlite3_context*);                /* Aggregate finalizer */\n  char *zName;         /* SQL name of the function. */\n  FuncDef *pHash;      /* Next with a different name but the same hash */\n  FuncDestructor *pDestructor;   /* Reference counted destructor function */\n};\n\n/*\n** This structure encapsulates a user-function destructor callback (as\n** configured using create_function_v2()) and a reference counter. When\n** create_function_v2() is called to create a function with a destructor,\n** a single object of this type is allocated. FuncDestructor.nRef is set to \n** the number of FuncDef objects created (either 1 or 3, depending on whether\n** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor\n** member of each of the new FuncDef objects is set to point to the allocated\n** FuncDestructor.\n**\n** Thereafter, when one of the FuncDef objects is deleted, the reference\n** count on this object is decremented. When it reaches 0, the destructor\n** is invoked and the FuncDestructor structure freed.\n*/\nstruct FuncDestructor {\n  int nRef;\n  void (*xDestroy)(void *);\n  void *pUserData;\n};\n\n/*\n** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF\n** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  There\n** are assert() statements in the code to verify this.\n*/\n#define SQLITE_FUNC_LIKE     0x01 /* Candidate for the LIKE optimization */\n#define SQLITE_FUNC_CASE     0x02 /* Case-sensitive LIKE-type function */\n#define SQLITE_FUNC_EPHEM    0x04 /* Ephemeral.  Delete with VDBE */\n#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */\n#define SQLITE_FUNC_COUNT    0x10 /* Built-in count(*) aggregate */\n#define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */\n#define SQLITE_FUNC_LENGTH   0x40 /* Built-in length() function */\n#define SQLITE_FUNC_TYPEOF   0x80 /* Built-in typeof() function */\n\n/*\n** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are\n** used to create the initializers for the FuncDef structures.\n**\n**   FUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Used to create a scalar function definition of a function zName \n**     implemented by C function xFunc that accepts nArg arguments. The\n**     value passed as iArg is cast to a (void*) and made available\n**     as the user-data (sqlite3_user_data()) for the function. If \n**     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.\n**\n**   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)\n**     Used to create an aggregate function definition implemented by\n**     the C functions xStep and xFinal. The first four parameters\n**     are interpreted in the same way as the first 4 parameters to\n**     FUNCTION().\n**\n**   LIKEFUNC(zName, nArg, pArg, flags)\n**     Used to create a scalar function definition of a function zName \n**     that accepts nArg arguments and is implemented by a call to C \n**     function likeFunc. Argument pArg is cast to a (void *) and made\n**     available as the function user-data (sqlite3_user_data()). The\n**     FuncDef.flags variable is set to the value passed as the flags\n**     parameter.\n*/\n#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}\n#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \\\n  {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}\n#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \\\n  {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \\\n   pArg, 0, xFunc, 0, 0, #zName, 0, 0}\n#define LIKEFUNC(zName, nArg, arg, flags) \\\n  {nArg, SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0}\n#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \\\n  {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \\\n   SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0,0}\n\n/*\n** All current savepoints are stored in a linked list starting at\n** sqlite3.pSavepoint. The first element in the list is the most recently\n** opened savepoint. Savepoints are added to the list by the vdbe\n** OP_Savepoint instruction.\n*/\nstruct Savepoint {\n  char *zName;                        /* Savepoint name (nul-terminated) */\n  i64 nDeferredCons;                  /* Number of deferred fk violations */\n  Savepoint *pNext;                   /* Parent savepoint (if any) */\n};\n\n/*\n** The following are used as the second parameter to sqlite3Savepoint(),\n** and as the P1 argument to the OP_Savepoint instruction.\n*/\n#define SAVEPOINT_BEGIN      0\n#define SAVEPOINT_RELEASE    1\n#define SAVEPOINT_ROLLBACK   2\n\n\n/*\n** Each SQLite module (virtual table definition) is defined by an\n** instance of the following structure, stored in the sqlite3.aModule\n** hash table.\n*/\nstruct Module {\n  const sqlite3_module *pModule;       /* Callback pointers */\n  const char *zName;                   /* Name passed to create_module() */\n  void *pAux;                          /* pAux passed to create_module() */\n  void (*xDestroy)(void *);            /* Module destructor function */\n};\n\n/*\n** information about each column of an SQL table is held in an instance\n** of this structure.\n*/\nstruct Column {\n  char *zName;     /* Name of this column */\n  Expr *pDflt;     /* Default value of this column */\n  char *zDflt;     /* Original text of the default value */\n  char *zType;     /* Data type for this column */\n  char *zColl;     /* Collating sequence.  If NULL, use the default */\n  u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */\n  char affinity;   /* One of the SQLITE_AFF_... values */\n  u16 colFlags;    /* Boolean properties.  See COLFLAG_ defines below */\n};\n\n/* Allowed values for Column.colFlags:\n*/\n#define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */\n#define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */\n\n/*\n** A \"Collating Sequence\" is defined by an instance of the following\n** structure. Conceptually, a collating sequence consists of a name and\n** a comparison routine that defines the order of that sequence.\n**\n** If CollSeq.xCmp is NULL, it means that the\n** collating sequence is undefined.  Indices built on an undefined\n** collating sequence may not be read or written.\n*/\nstruct CollSeq {\n  char *zName;          /* Name of the collating sequence, UTF-8 encoded */\n  u8 enc;               /* Text encoding handled by xCmp() */\n  void *pUser;          /* First argument to xCmp() */\n  int (*xCmp)(void*,int, const void*, int, const void*);\n  void (*xDel)(void*);  /* Destructor for pUser */\n};\n\n/*\n** A sort order can be either ASC or DESC.\n*/\n#define SQLITE_SO_ASC       0  /* Sort in ascending order */\n#define SQLITE_SO_DESC      1  /* Sort in ascending order */\n\n/*\n** Column affinity types.\n**\n** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and\n** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve\n** the speed a little by numbering the values consecutively.  \n**\n** But rather than start with 0 or 1, we begin with 'a'.  That way,\n** when multiple affinity types are concatenated into a string and\n** used as the P4 operand, they will be more readable.\n**\n** Note also that the numeric types are grouped together so that testing\n** for a numeric type is a single comparison.\n*/\n#define SQLITE_AFF_TEXT     'a'\n#define SQLITE_AFF_NONE     'b'\n#define SQLITE_AFF_NUMERIC  'c'\n#define SQLITE_AFF_INTEGER  'd'\n#define SQLITE_AFF_REAL     'e'\n\n#define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)\n\n/*\n** The SQLITE_AFF_MASK values masks off the significant bits of an\n** affinity value. \n*/\n#define SQLITE_AFF_MASK     0x67\n\n/*\n** Additional bit values that can be ORed with an affinity without\n** changing the affinity.\n*/\n#define SQLITE_JUMPIFNULL   0x08  /* jumps if either operand is NULL */\n#define SQLITE_STOREP2      0x10  /* Store result in reg[P2] rather than jump */\n#define SQLITE_NULLEQ       0x80  /* NULL=NULL */\n\n/*\n** An object of this type is created for each virtual table present in\n** the database schema. \n**\n** If the database schema is shared, then there is one instance of this\n** structure for each database connection (sqlite3*) that uses the shared\n** schema. This is because each database connection requires its own unique\n** instance of the sqlite3_vtab* handle used to access the virtual table \n** implementation. sqlite3_vtab* handles can not be shared between \n** database connections, even when the rest of the in-memory database \n** schema is shared, as the implementation often stores the database\n** connection handle passed to it via the xConnect() or xCreate() method\n** during initialization internally. This database connection handle may\n** then be used by the virtual table implementation to access real tables \n** within the database. So that they appear as part of the callers \n** transaction, these accesses need to be made via the same database \n** connection as that used to execute SQL operations on the virtual table.\n**\n** All VTable objects that correspond to a single table in a shared\n** database schema are initially stored in a linked-list pointed to by\n** the Table.pVTable member variable of the corresponding Table object.\n** When an sqlite3_prepare() operation is required to access the virtual\n** table, it searches the list for the VTable that corresponds to the\n** database connection doing the preparing so as to use the correct\n** sqlite3_vtab* handle in the compiled query.\n**\n** When an in-memory Table object is deleted (for example when the\n** schema is being reloaded for some reason), the VTable objects are not \n** deleted and the sqlite3_vtab* handles are not xDisconnect()ed \n** immediately. Instead, they are moved from the Table.pVTable list to\n** another linked list headed by the sqlite3.pDisconnect member of the\n** corresponding sqlite3 structure. They are then deleted/xDisconnected \n** next time a statement is prepared using said sqlite3*. This is done\n** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.\n** Refer to comments above function sqlite3VtabUnlockList() for an\n** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect\n** list without holding the corresponding sqlite3.mutex mutex.\n**\n** The memory for objects of this type is always allocated by \n** sqlite3DbMalloc(), using the connection handle stored in VTable.db as \n** the first argument.\n*/\nstruct VTable {\n  sqlite3 *db;              /* Database connection associated with this table */\n  Module *pMod;             /* Pointer to module implementation */\n  sqlite3_vtab *pVtab;      /* Pointer to vtab instance */\n  int nRef;                 /* Number of pointers to this structure */\n  u8 bConstraint;           /* True if constraints are supported */\n  int iSavepoint;           /* Depth of the SAVEPOINT stack */\n  VTable *pNext;            /* Next in linked list (see above) */\n};\n\n/*\n** Each SQL table is represented in memory by an instance of the\n** following structure.\n**\n** Table.zName is the name of the table.  The case of the original\n** CREATE TABLE statement is stored, but case is not significant for\n** comparisons.\n**\n** Table.nCol is the number of columns in this table.  Table.aCol is a\n** pointer to an array of Column structures, one for each column.\n**\n** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of\n** the column that is that key.   Otherwise Table.iPKey is negative.  Note\n** that the datatype of the PRIMARY KEY must be INTEGER for this field to\n** be set.  An INTEGER PRIMARY KEY is used as the rowid for each row of\n** the table.  If a table has no INTEGER PRIMARY KEY, then a random rowid\n** is generated for each row of the table.  TF_HasPrimaryKey is set if\n** the table has any PRIMARY KEY, INTEGER or otherwise.\n**\n** Table.tnum is the page number for the root BTree page of the table in the\n** database file.  If Table.iDb is the index of the database table backend\n** in sqlite.aDb[].  0 is for the main database and 1 is for the file that\n** holds temporary tables and indices.  If TF_Ephemeral is set\n** then the table is stored in a file that is automatically deleted\n** when the VDBE cursor to the table is closed.  In this case Table.tnum \n** refers VDBE cursor number that holds the table open, not to the root\n** page number.  Transient tables are used to hold the results of a\n** sub-query that appears instead of a real table name in the FROM clause \n** of a SELECT statement.\n*/\nstruct Table {\n  char *zName;         /* Name of the table or view */\n  Column *aCol;        /* Information about each column */\n  Index *pIndex;       /* List of SQL indexes on this table. */\n  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */\n  FKey *pFKey;         /* Linked list of all foreign keys in this table */\n  char *zColAff;       /* String defining the affinity of each column */\n#ifndef SQLITE_OMIT_CHECK\n  ExprList *pCheck;    /* All CHECK constraints */\n#endif\n  tRowcnt nRowEst;     /* Estimated rows in table - from sqlite_stat1 table */\n  int tnum;            /* Root BTree node for this table (see note above) */\n  i16 iPKey;           /* If not negative, use aCol[iPKey] as the primary key */\n  i16 nCol;            /* Number of columns in this table */\n  u16 nRef;            /* Number of pointers to this Table */\n  u8 tabFlags;         /* Mask of TF_* values */\n  u8 keyConf;          /* What to do in case of uniqueness conflict on iPKey */\n#ifndef SQLITE_OMIT_ALTERTABLE\n  int addColOffset;    /* Offset in CREATE TABLE stmt to add a new column */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nModuleArg;      /* Number of arguments to the module */\n  char **azModuleArg;  /* Text of all module args. [0] is module name */\n  VTable *pVTable;     /* List of VTable objects. */\n#endif\n  Trigger *pTrigger;   /* List of triggers stored in pSchema */\n  Schema *pSchema;     /* Schema that contains this table */\n  Table *pNextZombie;  /* Next on the Parse.pZombieTab list */\n};\n\n/*\n** Allowed values for Tabe.tabFlags.\n*/\n#define TF_Readonly        0x01    /* Read-only system table */\n#define TF_Ephemeral       0x02    /* An ephemeral table */\n#define TF_HasPrimaryKey   0x04    /* Table has a primary key */\n#define TF_Autoincrement   0x08    /* Integer primary key is autoincrement */\n#define TF_Virtual         0x10    /* Is a virtual table */\n\n\n/*\n** Test to see whether or not a table is a virtual table.  This is\n** done as a macro so that it will be optimized out when virtual\n** table support is omitted from the build.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n#  define IsVirtual(X)      (((X)->tabFlags & TF_Virtual)!=0)\n#  define IsHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#else\n#  define IsVirtual(X)      0\n#  define IsHiddenColumn(X) 0\n#endif\n\n/*\n** Each foreign key constraint is an instance of the following structure.\n**\n** A foreign key is associated with two tables.  The \"from\" table is\n** the table that contains the REFERENCES clause that creates the foreign\n** key.  The \"to\" table is the table that is named in the REFERENCES clause.\n** Consider this example:\n**\n**     CREATE TABLE ex1(\n**       a INTEGER PRIMARY KEY,\n**       b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)\n**     );\n**\n** For foreign key \"fk1\", the from-table is \"ex1\" and the to-table is \"ex2\".\n**\n** Each REFERENCES clause generates an instance of the following structure\n** which is attached to the from-table.  The to-table need not exist when\n** the from-table is created.  The existence of the to-table is not checked.\n*/\nstruct FKey {\n  Table *pFrom;     /* Table containing the REFERENCES clause (aka: Child) */\n  FKey *pNextFrom;  /* Next foreign key in pFrom */\n  char *zTo;        /* Name of table that the key points to (aka: Parent) */\n  FKey *pNextTo;    /* Next foreign key on table named zTo */\n  FKey *pPrevTo;    /* Previous foreign key on table named zTo */\n  int nCol;         /* Number of columns in this key */\n  /* EV: R-30323-21917 */\n  u8 isDeferred;    /* True if constraint checking is deferred till COMMIT */\n  u8 aAction[2];          /* ON DELETE and ON UPDATE actions, respectively */\n  Trigger *apTrigger[2];  /* Triggers for aAction[] actions */\n  struct sColMap {  /* Mapping of columns in pFrom to columns in zTo */\n    int iFrom;         /* Index of column in pFrom */\n    char *zCol;        /* Name of column in zTo.  If 0 use PRIMARY KEY */\n  } aCol[1];        /* One entry for each of nCol column s */\n};\n\n/*\n** SQLite supports many different ways to resolve a constraint\n** error.  ROLLBACK processing means that a constraint violation\n** causes the operation in process to fail and for the current transaction\n** to be rolled back.  ABORT processing means the operation in process\n** fails and any prior changes from that one operation are backed out,\n** but the transaction is not rolled back.  FAIL processing means that\n** the operation in progress stops and returns an error code.  But prior\n** changes due to the same operation are not backed out and no rollback\n** occurs.  IGNORE means that the particular row that caused the constraint\n** error is not inserted or updated.  Processing continues and no error\n** is returned.  REPLACE means that preexisting database rows that caused\n** a UNIQUE constraint violation are removed so that the new insert or\n** update can proceed.  Processing continues and no error is reported.\n**\n** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.\n** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the\n** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign\n** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the\n** referenced table row is propagated into the row that holds the\n** foreign key.\n** \n** The following symbolic values are used to record which type\n** of action to take.\n*/\n#define OE_None     0   /* There is no constraint to check */\n#define OE_Rollback 1   /* Fail the operation and rollback the transaction */\n#define OE_Abort    2   /* Back out changes but do no rollback transaction */\n#define OE_Fail     3   /* Stop the operation but leave all prior changes */\n#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */\n#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */\n\n#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */\n#define OE_SetNull  7   /* Set the foreign key value to NULL */\n#define OE_SetDflt  8   /* Set the foreign key value to its default */\n#define OE_Cascade  9   /* Cascade the changes */\n\n#define OE_Default  99  /* Do whatever the default action is */\n\n\n/*\n** An instance of the following structure is passed as the first\n** argument to sqlite3VdbeKeyCompare and is used to control the \n** comparison of the two index keys.\n*/\nstruct KeyInfo {\n  sqlite3 *db;        /* The database connection */\n  u8 enc;             /* Text encoding - one of the SQLITE_UTF* values */\n  u16 nField;         /* Number of entries in aColl[] */\n  u8 *aSortOrder;     /* Sort order for each column.  May be NULL */\n  CollSeq *aColl[1];  /* Collating sequence for each term of the key */\n};\n\n/*\n** An instance of the following structure holds information about a\n** single index record that has already been parsed out into individual\n** values.\n**\n** A record is an object that contains one or more fields of data.\n** Records are used to store the content of a table row and to store\n** the key of an index.  A blob encoding of a record is created by\n** the OP_MakeRecord opcode of the VDBE and is disassembled by the\n** OP_Column opcode.\n**\n** This structure holds a record that has already been disassembled\n** into its constituent fields.\n*/\nstruct UnpackedRecord {\n  KeyInfo *pKeyInfo;  /* Collation and sort-order information */\n  u16 nField;         /* Number of entries in apMem[] */\n  u8 flags;           /* Boolean settings.  UNPACKED_... below */\n  i64 rowid;          /* Used by UNPACKED_PREFIX_SEARCH */\n  Mem *aMem;          /* Values */\n};\n\n/*\n** Allowed values of UnpackedRecord.flags\n*/\n#define UNPACKED_INCRKEY       0x01  /* Make this key an epsilon larger */\n#define UNPACKED_PREFIX_MATCH  0x02  /* A prefix match is considered OK */\n#define UNPACKED_PREFIX_SEARCH 0x04  /* Ignore final (rowid) field */\n\n/*\n** Each SQL index is represented in memory by an\n** instance of the following structure.\n**\n** The columns of the table that are to be indexed are described\n** by the aiColumn[] field of this structure.  For example, suppose\n** we have the following table and index:\n**\n**     CREATE TABLE Ex1(c1 int, c2 int, c3 text);\n**     CREATE INDEX Ex2 ON Ex1(c3,c1);\n**\n** In the Table structure describing Ex1, nCol==3 because there are\n** three columns in the table.  In the Index structure describing\n** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.\n** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the \n** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].\n** The second column to be indexed (c1) has an index of 0 in\n** Ex1.aCol[], hence Ex2.aiColumn[1]==0.\n**\n** The Index.onError field determines whether or not the indexed columns\n** must be unique and what to do if they are not.  When Index.onError=OE_None,\n** it means this is not a unique index.  Otherwise it is a unique index\n** and the value of Index.onError indicate the which conflict resolution \n** algorithm to employ whenever an attempt is made to insert a non-unique\n** element.\n*/\nstruct Index {\n  char *zName;             /* Name of this index */\n  int *aiColumn;           /* Which columns are used by this index.  1st is 0 */\n  tRowcnt *aiRowEst;       /* From ANALYZE: Est. rows selected by each column */\n  Table *pTable;           /* The SQL table being indexed */\n  char *zColAff;           /* String defining the affinity of each column */\n  Index *pNext;            /* The next index associated with the same table */\n  Schema *pSchema;         /* Schema containing this index */\n  u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */\n  char **azColl;           /* Array of collation sequence names for index */\n  int tnum;                /* DB Page containing root of this index */\n  u16 nColumn;             /* Number of columns in table used by this index */\n  u8 onError;              /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  unsigned autoIndex:2;    /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */\n  unsigned bUnordered:1;   /* Use this index for == or IN queries only */\n#ifdef SQLITE_ENABLE_STAT3\n  int nSample;             /* Number of elements in aSample[] */\n  tRowcnt avgEq;           /* Average nEq value for key values not in aSample */\n  IndexSample *aSample;    /* Samples of the left-most key */\n#endif\n};\n\n/*\n** Each sample stored in the sqlite_stat3 table is represented in memory \n** using a structure of this type.  See documentation at the top of the\n** analyze.c source file for additional information.\n*/\nstruct IndexSample {\n  union {\n    char *z;        /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */\n    double r;       /* Value if eType is SQLITE_FLOAT */\n    i64 i;          /* Value if eType is SQLITE_INTEGER */\n  } u;\n  u8 eType;         /* SQLITE_NULL, SQLITE_INTEGER ... etc. */\n  int nByte;        /* Size in byte of text or blob. */\n  tRowcnt nEq;      /* Est. number of rows where the key equals this sample */\n  tRowcnt nLt;      /* Est. number of rows where key is less than this sample */\n  tRowcnt nDLt;     /* Est. number of distinct keys less than this sample */\n};\n\n/*\n** Each token coming out of the lexer is an instance of\n** this structure.  Tokens are also used as part of an expression.\n**\n** Note if Token.z==0 then Token.dyn and Token.n are undefined and\n** may contain random values.  Do not make any assumptions about Token.dyn\n** and Token.n when Token.z==0.\n*/\nstruct Token {\n  const char *z;     /* Text of the token.  Not NULL-terminated! */\n  unsigned int n;    /* Number of characters in this token */\n};\n\n/*\n** An instance of this structure contains information needed to generate\n** code for a SELECT that contains aggregate functions.\n**\n** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a\n** pointer to this structure.  The Expr.iColumn field is the index in\n** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate\n** code for that node.\n**\n** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the\n** original Select structure that describes the SELECT statement.  These\n** fields do not need to be freed when deallocating the AggInfo structure.\n*/\nstruct AggInfo {\n  u8 directMode;          /* Direct rendering mode means take data directly\n                          ** from source tables rather than from accumulators */\n  u8 useSortingIdx;       /* In direct mode, reference the sorting index rather\n                          ** than the source table */\n  int sortingIdx;         /* Cursor number of the sorting index */\n  int sortingIdxPTab;     /* Cursor number of pseudo-table */\n  int nSortingColumn;     /* Number of columns in the sorting index */\n  ExprList *pGroupBy;     /* The group by clause */\n  struct AggInfo_col {    /* For each column used in source tables */\n    Table *pTab;             /* Source table */\n    int iTable;              /* Cursor number of the source table */\n    int iColumn;             /* Column number within the source table */\n    int iSorterColumn;       /* Column number in the sorting index */\n    int iMem;                /* Memory location that acts as accumulator */\n    Expr *pExpr;             /* The original expression */\n  } *aCol;\n  int nColumn;            /* Number of used entries in aCol[] */\n  int nAccumulator;       /* Number of columns that show through to the output.\n                          ** Additional columns are used only as parameters to\n                          ** aggregate functions */\n  struct AggInfo_func {   /* For each aggregate function */\n    Expr *pExpr;             /* Expression encoding the function */\n    FuncDef *pFunc;          /* The aggregate function implementation */\n    int iMem;                /* Memory location that acts as accumulator */\n    int iDistinct;           /* Ephemeral table used to enforce DISTINCT */\n  } *aFunc;\n  int nFunc;              /* Number of entries in aFunc[] */\n};\n\n/*\n** The datatype ynVar is a signed integer, either 16-bit or 32-bit.\n** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater\n** than 32767 we have to make it 32-bit.  16-bit is preferred because\n** it uses less memory in the Expr object, which is a big memory user\n** in systems with lots of prepared statements.  And few applications\n** need more than about 10 or 20 variables.  But some extreme users want\n** to have prepared statements with over 32767 variables, and for them\n** the option is available (at compile-time).\n*/\n#if SQLITE_MAX_VARIABLE_NUMBER<=32767\ntypedef i16 ynVar;\n#else\ntypedef int ynVar;\n#endif\n\n/*\n** Each node of an expression in the parse tree is an instance\n** of this structure.\n**\n** Expr.op is the opcode. The integer parser token codes are reused\n** as opcodes here. For example, the parser defines TK_GE to be an integer\n** code representing the \">=\" operator. This same integer code is reused\n** to represent the greater-than-or-equal-to operator in the expression\n** tree.\n**\n** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, \n** or TK_STRING), then Expr.token contains the text of the SQL literal. If\n** the expression is a variable (TK_VARIABLE), then Expr.token contains the \n** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),\n** then Expr.token contains the name of the function.\n**\n** Expr.pRight and Expr.pLeft are the left and right subexpressions of a\n** binary operator. Either or both may be NULL.\n**\n** Expr.x.pList is a list of arguments if the expression is an SQL function,\n** a CASE expression or an IN expression of the form \"<lhs> IN (<y>, <z>...)\".\n** Expr.x.pSelect is used if the expression is a sub-select or an expression of\n** the form \"<lhs> IN (SELECT ...)\". If the EP_xIsSelect bit is set in the\n** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is \n** valid.\n**\n** An expression of the form ID or ID.ID refers to a column in a table.\n** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is\n** the integer cursor number of a VDBE cursor pointing to that table and\n** Expr.iColumn is the column number for the specific column.  If the\n** expression is used as a result in an aggregate SELECT, then the\n** value is also stored in the Expr.iAgg column in the aggregate so that\n** it can be accessed after all aggregates are computed.\n**\n** If the expression is an unbound variable marker (a question mark \n** character '?' in the original SQL) then the Expr.iTable holds the index \n** number for that variable.\n**\n** If the expression is a subquery then Expr.iColumn holds an integer\n** register number containing the result of the subquery.  If the\n** subquery gives a constant result, then iTable is -1.  If the subquery\n** gives a different answer at different times during statement processing\n** then iTable is the address of a subroutine that computes the subquery.\n**\n** If the Expr is of type OP_Column, and the table it is selecting from\n** is a disk table or the \"old.*\" pseudo-table, then pTab points to the\n** corresponding table definition.\n**\n** ALLOCATION NOTES:\n**\n** Expr objects can use a lot of memory space in database schema.  To\n** help reduce memory requirements, sometimes an Expr object will be\n** truncated.  And to reduce the number of memory allocations, sometimes\n** two or more Expr objects will be stored in a single memory allocation,\n** together with Expr.zToken strings.\n**\n** If the EP_Reduced and EP_TokenOnly flags are set when\n** an Expr object is truncated.  When EP_Reduced is set, then all\n** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees\n** are contained within the same memory allocation.  Note, however, that\n** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately\n** allocated, regardless of whether or not EP_Reduced is set.\n*/\nstruct Expr {\n  u8 op;                 /* Operation performed by this node */\n  char affinity;         /* The affinity of the column or 0 if not a column */\n  u16 flags;             /* Various flags.  EP_* See below */\n  union {\n    char *zToken;          /* Token value. Zero terminated and dequoted */\n    int iValue;            /* Non-negative integer value if EP_IntValue */\n  } u;\n\n  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction. \n  *********************************************************************/\n\n  Expr *pLeft;           /* Left subnode */\n  Expr *pRight;          /* Right subnode */\n  union {\n    ExprList *pList;     /* Function arguments or in \"<expr> IN (<expr-list)\" */\n    Select *pSelect;     /* Used for sub-selects and \"<expr> IN (<select>)\" */\n  } x;\n\n  /* If the EP_Reduced flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n  int nHeight;           /* Height of the tree headed by this node */\n#endif\n  int iTable;            /* TK_COLUMN: cursor number of table holding column\n                         ** TK_REGISTER: register number\n                         ** TK_TRIGGER: 1 -> new, 0 -> old */\n  ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.\n                         ** TK_VARIABLE: variable number (always >= 1). */\n  i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */\n  i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */\n  u8 flags2;             /* Second set of flags.  EP2_... */\n  u8 op2;                /* TK_REGISTER: original value of Expr.op\n                         ** TK_COLUMN: the value of p5 for OP_Column\n                         ** TK_AGG_FUNCTION: nesting depth */\n  AggInfo *pAggInfo;     /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */\n  Table *pTab;           /* Table for TK_COLUMN expressions. */\n};\n\n/*\n** The following are the meanings of bits in the Expr.flags field.\n*/\n#define EP_FromJoin   0x0001  /* Originated in ON or USING clause of a join */\n#define EP_Agg        0x0002  /* Contains one or more aggregate functions */\n#define EP_Resolved   0x0004  /* IDs have been resolved to COLUMNs */\n#define EP_Error      0x0008  /* Expression contains one or more errors */\n#define EP_Distinct   0x0010  /* Aggregate function with DISTINCT keyword */\n#define EP_VarSelect  0x0020  /* pSelect is correlated, not constant */\n#define EP_DblQuoted  0x0040  /* token.z was originally in \"...\" */\n#define EP_InfixFunc  0x0080  /* True for an infix function: LIKE, GLOB, etc */\n#define EP_Collate    0x0100  /* Tree contains a TK_COLLATE opeartor */\n#define EP_FixedDest  0x0200  /* Result needed in a specific register */\n#define EP_IntValue   0x0400  /* Integer value contained in u.iValue */\n#define EP_xIsSelect  0x0800  /* x.pSelect is valid (otherwise x.pList is) */\n#define EP_Hint       0x1000  /* Not used */\n#define EP_Reduced    0x2000  /* Expr struct is EXPR_REDUCEDSIZE bytes only */\n#define EP_TokenOnly  0x4000  /* Expr struct is EXPR_TOKENONLYSIZE bytes only */\n#define EP_Static     0x8000  /* Held in memory not obtained from malloc() */\n\n/*\n** The following are the meanings of bits in the Expr.flags2 field.\n*/\n#define EP2_MallocedToken  0x0001  /* Need to sqlite3DbFree() Expr.zToken */\n#define EP2_Irreducible    0x0002  /* Cannot EXPRDUP_REDUCE this Expr */\n\n/*\n** The pseudo-routine sqlite3ExprSetIrreducible sets the EP2_Irreducible\n** flag on an expression structure.  This flag is used for VV&A only.  The\n** routine is implemented as a macro that only works when in debugging mode,\n** so as not to burden production code.\n*/\n#ifdef SQLITE_DEBUG\n# define ExprSetIrreducible(X)  (X)->flags2 |= EP2_Irreducible\n#else\n# define ExprSetIrreducible(X)\n#endif\n\n/*\n** These macros can be used to test, set, or clear bits in the \n** Expr.flags field.\n*/\n#define ExprHasProperty(E,P)     (((E)->flags&(P))==(P))\n#define ExprHasAnyProperty(E,P)  (((E)->flags&(P))!=0)\n#define ExprSetProperty(E,P)     (E)->flags|=(P)\n#define ExprClearProperty(E,P)   (E)->flags&=~(P)\n\n/*\n** Macros to determine the number of bytes required by a normal Expr \n** struct, an Expr struct with the EP_Reduced flag set in Expr.flags \n** and an Expr struct with the EP_TokenOnly flag set.\n*/\n#define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */\n#define EXPR_REDUCEDSIZE        offsetof(Expr,iTable)  /* Common features */\n#define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */\n\n/*\n** Flags passed to the sqlite3ExprDup() function. See the header comment \n** above sqlite3ExprDup() for details.\n*/\n#define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */\n\n/*\n** A list of expressions.  Each expression may optionally have a\n** name.  An expr/name combination can be used in several ways, such\n** as the list of \"expr AS ID\" fields following a \"SELECT\" or in the\n** list of \"ID = expr\" items in an UPDATE.  A list of expressions can\n** also be used as the argument to a function, in which case the a.zName\n** field is not used.\n**\n** By default the Expr.zSpan field holds a human-readable description of\n** the expression that is used in the generation of error messages and\n** column labels.  In this case, Expr.zSpan is typically the text of a\n** column expression as it exists in a SELECT statement.  However, if\n** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name\n** of the result column in the form: DATABASE.TABLE.COLUMN.  This later\n** form is used for name resolution with nested FROM clauses.\n*/\nstruct ExprList {\n  int nExpr;             /* Number of expressions on the list */\n  int iECursor;          /* VDBE Cursor associated with this ExprList */\n  struct ExprList_item { /* For each expression in the list */\n    Expr *pExpr;            /* The list of expressions */\n    char *zName;            /* Token associated with this expression */\n    char *zSpan;            /* Original text of the expression */\n    u8 sortOrder;           /* 1 for DESC or 0 for ASC */\n    unsigned done :1;       /* A flag to indicate when processing is finished */\n    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */\n    u16 iOrderByCol;        /* For ORDER BY, column number in result set */\n    u16 iAlias;             /* Index into Parse.aAlias[] for zName */\n  } *a;                  /* Alloc a power of two greater or equal to nExpr */\n};\n\n/*\n** An instance of this structure is used by the parser to record both\n** the parse tree for an expression and the span of input text for an\n** expression.\n*/\nstruct ExprSpan {\n  Expr *pExpr;          /* The expression parse tree */\n  const char *zStart;   /* First character of input text */\n  const char *zEnd;     /* One character past the end of input text */\n};\n\n/*\n** An instance of this structure can hold a simple list of identifiers,\n** such as the list \"a,b,c\" in the following statements:\n**\n**      INSERT INTO t(a,b,c) VALUES ...;\n**      CREATE INDEX idx ON t(a,b,c);\n**      CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;\n**\n** The IdList.a.idx field is used when the IdList represents the list of\n** column names after a table name in an INSERT statement.  In the statement\n**\n**     INSERT INTO t(a,b,c) ...\n**\n** If \"a\" is the k-th column of table \"t\", then IdList.a[0].idx==k.\n*/\nstruct IdList {\n  struct IdList_item {\n    char *zName;      /* Name of the identifier */\n    int idx;          /* Index in some Table.aCol[] of a column named zName */\n  } *a;\n  int nId;         /* Number of identifiers on the list */\n};\n\n/*\n** The bitmask datatype defined below is used for various optimizations.\n**\n** Changing this from a 64-bit to a 32-bit type limits the number of\n** tables in a join to 32 instead of 64.  But it also reduces the size\n** of the library by 738 bytes on ix86.\n*/\ntypedef u64 Bitmask;\n\n/*\n** The number of bits in a Bitmask.  \"BMS\" means \"BitMask Size\".\n*/\n#define BMS  ((int)(sizeof(Bitmask)*8))\n\n/*\n** The following structure describes the FROM clause of a SELECT statement.\n** Each table or subquery in the FROM clause is a separate element of\n** the SrcList.a[] array.\n**\n** With the addition of multiple database support, the following structure\n** can also be used to describe a particular table such as the table that\n** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,\n** such a table must be a simple name: ID.  But in SQLite, the table can\n** now be identified by a database name, a dot, then the table name: ID.ID.\n**\n** The jointype starts out showing the join type between the current table\n** and the next table on the list.  The parser builds the list this way.\n** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each\n** jointype expresses the join between the table and the previous table.\n**\n** In the colUsed field, the high-order bit (bit 63) is set if the table\n** contains more than 63 columns and the 64-th or later column is used.\n*/\nstruct SrcList {\n  i16 nSrc;        /* Number of tables or subqueries in the FROM clause */\n  i16 nAlloc;      /* Number of entries allocated in a[] below */\n  struct SrcList_item {\n    Schema *pSchema;  /* Schema to which this item is fixed */\n    char *zDatabase;  /* Name of database holding this table */\n    char *zName;      /* Name of the table */\n    char *zAlias;     /* The \"B\" part of a \"A AS B\" phrase.  zName is the \"A\" */\n    Table *pTab;      /* An SQL table corresponding to zName */\n    Select *pSelect;  /* A SELECT statement used in place of a table name */\n    int addrFillSub;  /* Address of subroutine to manifest a subquery */\n    int regReturn;    /* Register holding return address of addrFillSub */\n    u8 jointype;      /* Type of join between this able and the previous */\n    unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */\n    unsigned isCorrelated :1;  /* True if sub-query is correlated */\n    unsigned viaCoroutine :1;  /* Implemented as a co-routine */\n#ifndef SQLITE_OMIT_EXPLAIN\n    u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */\n#endif\n    int iCursor;      /* The VDBE cursor number used to access this table */\n    Expr *pOn;        /* The ON clause of a join */\n    IdList *pUsing;   /* The USING clause of a join */\n    Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */\n    char *zIndex;     /* Identifier from \"INDEXED BY <zIndex>\" clause */\n    Index *pIndex;    /* Index structure corresponding to zIndex, if any */\n  } a[1];             /* One entry for each identifier on the list */\n};\n\n/*\n** Permitted values of the SrcList.a.jointype field\n*/\n#define JT_INNER     0x0001    /* Any kind of inner or cross join */\n#define JT_CROSS     0x0002    /* Explicit use of the CROSS keyword */\n#define JT_NATURAL   0x0004    /* True for a \"natural\" join */\n#define JT_LEFT      0x0008    /* Left outer join */\n#define JT_RIGHT     0x0010    /* Right outer join */\n#define JT_OUTER     0x0020    /* The \"OUTER\" keyword is present */\n#define JT_ERROR     0x0040    /* unknown or unsupported join type */\n\n\n/*\n** A WherePlan object holds information that describes a lookup\n** strategy.\n**\n** This object is intended to be opaque outside of the where.c module.\n** It is included here only so that that compiler will know how big it\n** is.  None of the fields in this object should be used outside of\n** the where.c module.\n**\n** Within the union, pIdx is only used when wsFlags&WHERE_INDEXED is true.\n** pTerm is only used when wsFlags&WHERE_MULTI_OR is true.  And pVtabIdx\n** is only used when wsFlags&WHERE_VIRTUALTABLE is true.  It is never the\n** case that more than one of these conditions is true.\n*/\nstruct WherePlan {\n  u32 wsFlags;                   /* WHERE_* flags that describe the strategy */\n  u16 nEq;                       /* Number of == constraints */\n  u16 nOBSat;                    /* Number of ORDER BY terms satisfied */\n  double nRow;                   /* Estimated number of rows (for EQP) */\n  union {\n    Index *pIdx;                   /* Index when WHERE_INDEXED is true */\n    struct WhereTerm *pTerm;       /* WHERE clause term for OR-search */\n    sqlite3_index_info *pVtabIdx;  /* Virtual table index to use */\n  } u;\n};\n\n/*\n** For each nested loop in a WHERE clause implementation, the WhereInfo\n** structure contains a single instance of this structure.  This structure\n** is intended to be private to the where.c module and should not be\n** access or modified by other modules.\n**\n** The pIdxInfo field is used to help pick the best index on a\n** virtual table.  The pIdxInfo pointer contains indexing\n** information for the i-th table in the FROM clause before reordering.\n** All the pIdxInfo pointers are freed by whereInfoFree() in where.c.\n** All other information in the i-th WhereLevel object for the i-th table\n** after FROM clause ordering.\n*/\nstruct WhereLevel {\n  WherePlan plan;       /* query plan for this element of the FROM clause */\n  int iLeftJoin;        /* Memory cell used to implement LEFT OUTER JOIN */\n  int iTabCur;          /* The VDBE cursor used to access the table */\n  int iIdxCur;          /* The VDBE cursor used to access pIdx */\n  int addrBrk;          /* Jump here to break out of the loop */\n  int addrNxt;          /* Jump here to start the next IN combination */\n  int addrCont;         /* Jump here to continue with the next loop cycle */\n  int addrFirst;        /* First instruction of interior of the loop */\n  u8 iFrom;             /* Which entry in the FROM clause */\n  u8 op, p5;            /* Opcode and P5 of the opcode that ends the loop */\n  int p1, p2;           /* Operands of the opcode used to ends the loop */\n  union {               /* Information that depends on plan.wsFlags */\n    struct {\n      int nIn;              /* Number of entries in aInLoop[] */\n      struct InLoop {\n        int iCur;              /* The VDBE cursor used by this IN operator */\n        int addrInTop;         /* Top of the IN loop */\n        u8 eEndLoopOp;         /* IN Loop terminator. OP_Next or OP_Prev */\n      } *aInLoop;           /* Information about each nested IN operator */\n    } in;                 /* Used when plan.wsFlags&WHERE_IN_ABLE */\n    Index *pCovidx;       /* Possible covering index for WHERE_MULTI_OR */\n  } u;\n  double rOptCost;      /* \"Optimal\" cost for this level */\n\n  /* The following field is really not part of the current level.  But\n  ** we need a place to cache virtual table index information for each\n  ** virtual table in the FROM clause and the WhereLevel structure is\n  ** a convenient place since there is one WhereLevel for each FROM clause\n  ** element.\n  */\n  sqlite3_index_info *pIdxInfo;  /* Index info for n-th source table */\n};\n\n/*\n** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()\n** and the WhereInfo.wctrlFlags member.\n*/\n#define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */\n#define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */\n#define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */\n#define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */\n#define WHERE_DUPLICATES_OK    0x0008 /* Ok to return a row more than once */\n#define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */\n#define WHERE_FORCE_TABLE      0x0020 /* Do not use an index-only search */\n#define WHERE_ONETABLE_ONLY    0x0040 /* Only code the 1st table in pTabList */\n#define WHERE_AND_ONLY         0x0080 /* Don't use indices for OR terms */\n\n/*\n** The WHERE clause processing routine has two halves.  The\n** first part does the start of the WHERE loop and the second\n** half does the tail of the WHERE loop.  An instance of\n** this structure is returned by the first half and passed\n** into the second half to give some continuity.\n*/\nstruct WhereInfo {\n  Parse *pParse;            /* Parsing and code generating context */\n  SrcList *pTabList;        /* List of tables in the join */\n  u16 nOBSat;               /* Number of ORDER BY terms satisfied by indices */\n  u16 wctrlFlags;           /* Flags originally passed to sqlite3WhereBegin() */\n  u8 okOnePass;             /* Ok to use one-pass algorithm for UPDATE/DELETE */\n  u8 untestedTerms;         /* Not all WHERE terms resolved by outer loop */\n  u8 eDistinct;             /* One of the WHERE_DISTINCT_* values below */\n  int iTop;                 /* The very beginning of the WHERE loop */\n  int iContinue;            /* Jump here to continue with next record */\n  int iBreak;               /* Jump here to break out of the loop */\n  int nLevel;               /* Number of nested loop */\n  struct WhereClause *pWC;  /* Decomposition of the WHERE clause */\n  double savedNQueryLoop;   /* pParse->nQueryLoop outside the WHERE loop */\n  double nRowOut;           /* Estimated number of output rows */\n  WhereLevel a[1];          /* Information about each nest loop in WHERE */\n};\n\n/* Allowed values for WhereInfo.eDistinct and DistinctCtx.eTnctType */\n#define WHERE_DISTINCT_NOOP      0  /* DISTINCT keyword not used */\n#define WHERE_DISTINCT_UNIQUE    1  /* No duplicates */\n#define WHERE_DISTINCT_ORDERED   2  /* All duplicates are adjacent */\n#define WHERE_DISTINCT_UNORDERED 3  /* Duplicates are scattered */\n\n/*\n** A NameContext defines a context in which to resolve table and column\n** names.  The context consists of a list of tables (the pSrcList) field and\n** a list of named expression (pEList).  The named expression list may\n** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or\n** to the table being operated on by INSERT, UPDATE, or DELETE.  The\n** pEList corresponds to the result set of a SELECT and is NULL for\n** other statements.\n**\n** NameContexts can be nested.  When resolving names, the inner-most \n** context is searched first.  If no match is found, the next outer\n** context is checked.  If there is still no match, the next context\n** is checked.  This process continues until either a match is found\n** or all contexts are check.  When a match is found, the nRef member of\n** the context containing the match is incremented. \n**\n** Each subquery gets a new NameContext.  The pNext field points to the\n** NameContext in the parent query.  Thus the process of scanning the\n** NameContext list corresponds to searching through successively outer\n** subqueries looking for a match.\n*/\nstruct NameContext {\n  Parse *pParse;       /* The parser */\n  SrcList *pSrcList;   /* One or more tables used to resolve names */\n  ExprList *pEList;    /* Optional list of named expressions */\n  AggInfo *pAggInfo;   /* Information about aggregates at this level */\n  NameContext *pNext;  /* Next outer name context.  NULL for outermost */\n  int nRef;            /* Number of names resolved by this context */\n  int nErr;            /* Number of errors encountered while resolving names */\n  u8 ncFlags;          /* Zero or more NC_* flags defined below */\n};\n\n/*\n** Allowed values for the NameContext, ncFlags field.\n*/\n#define NC_AllowAgg  0x01    /* Aggregate functions are allowed here */\n#define NC_HasAgg    0x02    /* One or more aggregate functions seen */\n#define NC_IsCheck   0x04    /* True if resolving names in a CHECK constraint */\n#define NC_InAggFunc 0x08    /* True if analyzing arguments to an agg func */\n#define NC_AsMaybe   0x10    /* Resolve to AS terms of the result set only\n                             ** if no other resolution is available */\n\n/*\n** An instance of the following structure contains all information\n** needed to generate code for a single SELECT statement.\n**\n** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.\n** If there is a LIMIT clause, the parser sets nLimit to the value of the\n** limit and nOffset to the value of the offset (or 0 if there is not\n** offset).  But later on, nLimit and nOffset become the memory locations\n** in the VDBE that record the limit and offset counters.\n**\n** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.\n** These addresses must be stored so that we can go back and fill in\n** the P4_KEYINFO and P2 parameters later.  Neither the KeyInfo nor\n** the number of columns in P2 can be computed at the same time\n** as the OP_OpenEphm instruction is coded because not\n** enough information about the compound query is known at that point.\n** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences\n** for the result set.  The KeyInfo for addrOpenEphm[2] contains collating\n** sequences for the ORDER BY clause.\n*/\nstruct Select {\n  ExprList *pEList;      /* The fields of the result */\n  u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */\n  u16 selFlags;          /* Various SF_* values */\n  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */\n  int addrOpenEphm[3];   /* OP_OpenEphem opcodes related to this select */\n  double nSelectRow;     /* Estimated number of result rows */\n  SrcList *pSrc;         /* The FROM clause */\n  Expr *pWhere;          /* The WHERE clause */\n  ExprList *pGroupBy;    /* The GROUP BY clause */\n  Expr *pHaving;         /* The HAVING clause */\n  ExprList *pOrderBy;    /* The ORDER BY clause */\n  Select *pPrior;        /* Prior select in a compound select statement */\n  Select *pNext;         /* Next select to the left in a compound */\n  Select *pRightmost;    /* Right-most select in a compound select statement */\n  Expr *pLimit;          /* LIMIT expression. NULL means not used. */\n  Expr *pOffset;         /* OFFSET expression. NULL means not used. */\n};\n\n/*\n** Allowed values for Select.selFlags.  The \"SF\" prefix stands for\n** \"Select Flag\".\n*/\n#define SF_Distinct        0x0001  /* Output should be DISTINCT */\n#define SF_Resolved        0x0002  /* Identifiers have been resolved */\n#define SF_Aggregate       0x0004  /* Contains aggregate functions */\n#define SF_UsesEphemeral   0x0008  /* Uses the OpenEphemeral opcode */\n#define SF_Expanded        0x0010  /* sqlite3SelectExpand() called on this */\n#define SF_HasTypeInfo     0x0020  /* FROM subqueries have Table metadata */\n#define SF_UseSorter       0x0040  /* Sort using a sorter */\n#define SF_Values          0x0080  /* Synthesized from VALUES clause */\n#define SF_Materialize     0x0100  /* Force materialization of views */\n#define SF_NestedFrom      0x0200  /* Part of a parenthesized FROM clause */\n\n\n/*\n** The results of a select can be distributed in several ways.  The\n** \"SRT\" prefix means \"SELECT Result Type\".\n*/\n#define SRT_Union        1  /* Store result as keys in an index */\n#define SRT_Except       2  /* Remove result from a UNION index */\n#define SRT_Exists       3  /* Store 1 if the result is not empty */\n#define SRT_Discard      4  /* Do not save the results anywhere */\n\n/* The ORDER BY clause is ignored for all of the above */\n#define IgnorableOrderby(X) ((X->eDest)<=SRT_Discard)\n\n#define SRT_Output       5  /* Output each row of result */\n#define SRT_Mem          6  /* Store result in a memory cell */\n#define SRT_Set          7  /* Store results as keys in an index */\n#define SRT_Table        8  /* Store result as data with an automatic rowid */\n#define SRT_EphemTab     9  /* Create transient tab and store like SRT_Table */\n#define SRT_Coroutine   10  /* Generate a single row of result */\n\n/*\n** An instance of this object describes where to put of the results of\n** a SELECT statement.\n*/\nstruct SelectDest {\n  u8 eDest;         /* How to dispose of the results.  On of SRT_* above. */\n  char affSdst;     /* Affinity used when eDest==SRT_Set */\n  int iSDParm;      /* A parameter used by the eDest disposal method */\n  int iSdst;        /* Base register where results are written */\n  int nSdst;        /* Number of registers allocated */\n};\n\n/*\n** During code generation of statements that do inserts into AUTOINCREMENT \n** tables, the following information is attached to the Table.u.autoInc.p\n** pointer of each autoincrement table to record some side information that\n** the code generator needs.  We have to keep per-table autoincrement\n** information in case inserts are down within triggers.  Triggers do not\n** normally coordinate their activities, but we do need to coordinate the\n** loading and saving of autoincrement information.\n*/\nstruct AutoincInfo {\n  AutoincInfo *pNext;   /* Next info block in a list of them all */\n  Table *pTab;          /* Table this info block refers to */\n  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */\n  int regCtr;           /* Memory register holding the rowid counter */\n};\n\n/*\n** Size of the column cache\n*/\n#ifndef SQLITE_N_COLCACHE\n# define SQLITE_N_COLCACHE 10\n#endif\n\n/*\n** At least one instance of the following structure is created for each \n** trigger that may be fired while parsing an INSERT, UPDATE or DELETE\n** statement. All such objects are stored in the linked list headed at\n** Parse.pTriggerPrg and deleted once statement compilation has been\n** completed.\n**\n** A Vdbe sub-program that implements the body and WHEN clause of trigger\n** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of\n** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.\n** The Parse.pTriggerPrg list never contains two entries with the same\n** values for both pTrigger and orconf.\n**\n** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns\n** accessed (or set to 0 for triggers fired as a result of INSERT \n** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to\n** a mask of new.* columns used by the program.\n*/\nstruct TriggerPrg {\n  Trigger *pTrigger;      /* Trigger this program was coded from */\n  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */\n  SubProgram *pProgram;   /* Program implementing pTrigger/orconf */\n  int orconf;             /* Default ON CONFLICT policy */\n  u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */\n};\n\n/*\n** The yDbMask datatype for the bitmask of all attached databases.\n*/\n#if SQLITE_MAX_ATTACHED>30\n  typedef sqlite3_uint64 yDbMask;\n#else\n  typedef unsigned int yDbMask;\n#endif\n\n/*\n** An SQL parser context.  A copy of this structure is passed through\n** the parser and down into all the parser action routine in order to\n** carry around information that is global to the entire parse.\n**\n** The structure is divided into two parts.  When the parser and code\n** generate call themselves recursively, the first part of the structure\n** is constant but the second part is reset at the beginning and end of\n** each recursion.\n**\n** The nTableLock and aTableLock variables are only used if the shared-cache \n** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are\n** used to store the set of table-locks required by the statement being\n** compiled. Function sqlite3TableLock() is used to add entries to the\n** list.\n*/\nstruct Parse {\n  sqlite3 *db;         /* The main database structure */\n  char *zErrMsg;       /* An error message */\n  Vdbe *pVdbe;         /* An engine for executing database bytecode */\n  int rc;              /* Return code from execution */\n  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */\n  u8 checkSchema;      /* Causes schema cookie check after an error */\n  u8 nested;           /* Number of nested calls to the parser/code generator */\n  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */\n  u8 nTempInUse;       /* Number of aTempReg[] currently checked out */\n  u8 nColCache;        /* Number of entries in aColCache[] */\n  u8 iColCache;        /* Next entry in aColCache[] to replace */\n  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */\n  u8 mayAbort;         /* True if statement may throw an ABORT exception */\n  int aTempReg[8];     /* Holding area for temporary registers */\n  int nRangeReg;       /* Size of the temporary register block */\n  int iRangeReg;       /* First register in temporary register block */\n  int nErr;            /* Number of errors seen */\n  int nTab;            /* Number of previously allocated VDBE cursors */\n  int nMem;            /* Number of memory cells used so far */\n  int nSet;            /* Number of sets used so far */\n  int nOnce;           /* Number of OP_Once instructions so far */\n  int ckBase;          /* Base register of data during check constraints */\n  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */\n  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */\n  struct yColCache {\n    int iTable;           /* Table cursor number */\n    int iColumn;          /* Table column number */\n    u8 tempReg;           /* iReg is a temp register that needs to be freed */\n    int iLevel;           /* Nesting level */\n    int iReg;             /* Reg with value of this column. 0 means none. */\n    int lru;              /* Least recently used entry has the smallest value */\n  } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */\n  yDbMask writeMask;   /* Start a write transaction on these databases */\n  yDbMask cookieMask;  /* Bitmask of schema verified databases */\n  int cookieGoto;      /* Address of OP_Goto to cookie verifier subroutine */\n  int cookieValue[SQLITE_MAX_ATTACHED+2];  /* Values of cookies to verify */\n  int regRowid;        /* Register holding rowid of CREATE TABLE entry */\n  int regRoot;         /* Register holding root page number for new objects */\n  int nMaxArg;         /* Max args passed to user function by sub-program */\n  Token constraintName;/* Name of the constraint currently being parsed */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nTableLock;        /* Number of locks in aTableLock */\n  TableLock *aTableLock; /* Required table locks for shared-cache mode */\n#endif\n  AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */\n\n  /* Information used while coding trigger programs. */\n  Parse *pToplevel;    /* Parse structure for main program (or NULL) */\n  Table *pTriggerTab;  /* Table triggers are being coded for */\n  double nQueryLoop;   /* Estimated number of iterations of a query */\n  u32 oldmask;         /* Mask of old.* columns referenced */\n  u32 newmask;         /* Mask of new.* columns referenced */\n  u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */\n  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */\n  u8 disableTriggers;  /* True to disable triggers */\n\n  /* Above is constant between recursions.  Below is reset before and after\n  ** each recursion */\n\n  int nVar;                 /* Number of '?' variables seen in the SQL so far */\n  int nzVar;                /* Number of available slots in azVar[] */\n  u8 explain;               /* True if the EXPLAIN flag is found on the query */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */\n  int nVtabLock;            /* Number of virtual tables to lock */\n#endif\n  int nAlias;               /* Number of aliased result set columns */\n  int nHeight;              /* Expression tree height of current sub-select */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSelectId;            /* ID of current select for EXPLAIN output */\n  int iNextSelectId;        /* Next available select ID for EXPLAIN output */\n#endif\n  char **azVar;             /* Pointers to names of parameters */\n  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */\n  int *aAlias;              /* Register used to hold aliased result */\n  const char *zTail;        /* All SQL text past the last semicolon parsed */\n  Table *pNewTable;         /* A table being constructed by CREATE TABLE */\n  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */\n  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */\n  Token sNameToken;         /* Token with unqualified schema object name */\n  Token sLastToken;         /* The last token parsed */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  Token sArg;               /* Complete text of a module argument */\n  Table **apVtabLock;       /* Pointer to virtual tables needing locking */\n#endif\n  Table *pZombieTab;        /* List of Table objects to delete after code gen */\n  TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */\n};\n\n/*\n** Return true if currently inside an sqlite3_declare_vtab() call.\n*/\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  #define IN_DECLARE_VTAB 0\n#else\n  #define IN_DECLARE_VTAB (pParse->declareVtab)\n#endif\n\n/*\n** An instance of the following structure can be declared on a stack and used\n** to save the Parse.zAuthContext value so that it can be restored later.\n*/\nstruct AuthContext {\n  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */\n  Parse *pParse;              /* The Parse structure */\n};\n\n/*\n** Bitfield flags for P5 value in various opcodes.\n*/\n#define OPFLAG_NCHANGE       0x01    /* Set to update db->nChange */\n#define OPFLAG_LASTROWID     0x02    /* Set to update db->lastRowid */\n#define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */\n#define OPFLAG_APPEND        0x08    /* This is likely to be an append */\n#define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */\n#define OPFLAG_CLEARCACHE    0x20    /* Clear pseudo-table cache in OP_Column */\n#define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */\n#define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */\n#define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */\n#define OPFLAG_P2ISREG       0x02    /* P2 to OP_Open** is a register number */\n#define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */\n\n/*\n * Each trigger present in the database schema is stored as an instance of\n * struct Trigger. \n *\n * Pointers to instances of struct Trigger are stored in two ways.\n * 1. In the \"trigHash\" hash table (part of the sqlite3* that represents the \n *    database). This allows Trigger structures to be retrieved by name.\n * 2. All triggers associated with a single table form a linked list, using the\n *    pNext member of struct Trigger. A pointer to the first element of the\n *    linked list is stored as the \"pTrigger\" member of the associated\n *    struct Table.\n *\n * The \"step_list\" member points to the first element of a linked list\n * containing the SQL statements specified as the trigger program.\n */\nstruct Trigger {\n  char *zName;            /* The name of the trigger                        */\n  char *table;            /* The table or view to which the trigger applies */\n  u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */\n  u8 tr_tm;               /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Expr *pWhen;            /* The WHEN clause of the expression (may be NULL) */\n  IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,\n                             the <column-list> is stored here */\n  Schema *pSchema;        /* Schema containing the trigger */\n  Schema *pTabSchema;     /* Schema containing the table */\n  TriggerStep *step_list; /* Link list of trigger program steps             */\n  Trigger *pNext;         /* Next trigger associated with the table */\n};\n\n/*\n** A trigger is either a BEFORE or an AFTER trigger.  The following constants\n** determine which. \n**\n** If there are multiple triggers, you might of some BEFORE and some AFTER.\n** In that cases, the constants below can be ORed together.\n*/\n#define TRIGGER_BEFORE  1\n#define TRIGGER_AFTER   2\n\n/*\n * An instance of struct TriggerStep is used to store a single SQL statement\n * that is a part of a trigger-program. \n *\n * Instances of struct TriggerStep are stored in a singly linked list (linked\n * using the \"pNext\" member) referenced by the \"step_list\" member of the \n * associated struct Trigger instance. The first element of the linked list is\n * the first step of the trigger-program.\n * \n * The \"op\" member indicates whether this is a \"DELETE\", \"INSERT\", \"UPDATE\" or\n * \"SELECT\" statement. The meanings of the other members is determined by the \n * value of \"op\" as follows:\n *\n * (op == TK_INSERT)\n * orconf    -> stores the ON CONFLICT algorithm\n * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then\n *              this stores a pointer to the SELECT statement. Otherwise NULL.\n * target    -> A token holding the quoted name of the table to insert into.\n * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then\n *              this stores values to be inserted. Otherwise NULL.\n * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ... \n *              statement, then this stores the column-names to be\n *              inserted into.\n *\n * (op == TK_DELETE)\n * target    -> A token holding the quoted name of the table to delete from.\n * pWhere    -> The WHERE clause of the DELETE statement if one is specified.\n *              Otherwise NULL.\n * \n * (op == TK_UPDATE)\n * target    -> A token holding the quoted name of the table to update rows of.\n * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.\n *              Otherwise NULL.\n * pExprList -> A list of the columns to update and the expressions to update\n *              them to. See sqlite3Update() documentation of \"pChanges\"\n *              argument.\n * \n */\nstruct TriggerStep {\n  u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */\n  u8 orconf;           /* OE_Rollback etc. */\n  Trigger *pTrig;      /* The trigger that this step is a part of */\n  Select *pSelect;     /* SELECT statment or RHS of INSERT INTO .. SELECT ... */\n  Token target;        /* Target table for DELETE, UPDATE, INSERT */\n  Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */\n  ExprList *pExprList; /* SET clause for UPDATE.  VALUES clause for INSERT */\n  IdList *pIdList;     /* Column names for INSERT */\n  TriggerStep *pNext;  /* Next in the link-list */\n  TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */\n};\n\n/*\n** The following structure contains information used by the sqliteFix...\n** routines as they walk the parse tree to make database references\n** explicit.  \n*/\ntypedef struct DbFixer DbFixer;\nstruct DbFixer {\n  Parse *pParse;      /* The parsing context.  Error messages written here */\n  Schema *pSchema;    /* Fix items to this schema */\n  const char *zDb;    /* Make sure all objects are contained in this database */\n  const char *zType;  /* Type of the container - used for error messages */\n  const Token *pName; /* Name of the container - used for error messages */\n};\n\n/*\n** An objected used to accumulate the text of a string where we\n** do not necessarily know how big the string will be in the end.\n*/\nstruct StrAccum {\n  sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */\n  char *zBase;         /* A base allocation.  Not from malloc. */\n  char *zText;         /* The string collected so far */\n  int  nChar;          /* Length of the string so far */\n  int  nAlloc;         /* Amount of space allocated in zText */\n  int  mxAlloc;        /* Maximum allowed string length */\n  u8   mallocFailed;   /* Becomes true if any memory allocation fails */\n  u8   useMalloc;      /* 0: none,  1: sqlite3DbMalloc,  2: sqlite3_malloc */\n  u8   tooBig;         /* Becomes true if string size exceeds limits */\n};\n\n/*\n** A pointer to this structure is used to communicate information\n** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.\n*/\ntypedef struct {\n  sqlite3 *db;        /* The database being initialized */\n  char **pzErrMsg;    /* Error message stored here */\n  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */\n  int rc;             /* Result code stored here */\n} InitData;\n\n/*\n** Structure containing global configuration data for the SQLite library.\n**\n** This structure also contains some state information.\n*/\nstruct Sqlite3Config {\n  int bMemstat;                     /* True to enable memory status */\n  int bCoreMutex;                   /* True to enable core mutexing */\n  int bFullMutex;                   /* True to enable full mutexing */\n  int bOpenUri;                     /* True to interpret filenames as URIs */\n  int bUseCis;                      /* Use covering indices for full-scans */\n  int mxStrlen;                     /* Maximum string length */\n  int szLookaside;                  /* Default lookaside buffer size */\n  int nLookaside;                   /* Default lookaside buffer count */\n  sqlite3_mem_methods m;            /* Low-level memory allocation interface */\n  sqlite3_mutex_methods mutex;      /* Low-level mutex interface */\n  sqlite3_pcache_methods2 pcache2;  /* Low-level page-cache interface */\n  void *pHeap;                      /* Heap storage space */\n  int nHeap;                        /* Size of pHeap[] */\n  int mnReq, mxReq;                 /* Min and max heap requests sizes */\n  sqlite3_int64 szMmap;             /* mmap() space per open file */\n  sqlite3_int64 mxMmap;             /* Maximum value for szMmap */\n  void *pScratch;                   /* Scratch memory */\n  int szScratch;                    /* Size of each scratch buffer */\n  int nScratch;                     /* Number of scratch buffers */\n  void *pPage;                      /* Page cache memory */\n  int szPage;                       /* Size of each page in pPage[] */\n  int nPage;                        /* Number of pages in pPage[] */\n  int mxParserStack;                /* maximum depth of the parser stack */\n  int sharedCacheEnabled;           /* true if shared-cache mode enabled */\n  /* The above might be initialized to non-zero.  The following need to always\n  ** initially be zero, however. */\n  int isInit;                       /* True after initialization has finished */\n  int inProgress;                   /* True while initialization in progress */\n  int isMutexInit;                  /* True after mutexes are initialized */\n  int isMallocInit;                 /* True after malloc is initialized */\n  int isPCacheInit;                 /* True after malloc is initialized */\n  sqlite3_mutex *pInitMutex;        /* Mutex used by sqlite3_initialize() */\n  int nRefInitMutex;                /* Number of users of pInitMutex */\n  void (*xLog)(void*,int,const char*); /* Function for logging */\n  void *pLogArg;                       /* First argument to xLog() */\n  int bLocaltimeFault;              /* True to fail localtime() calls */\n#ifdef SQLITE_ENABLE_SQLLOG\n  void(*xSqllog)(void*,sqlite3*,const char*, int);\n  void *pSqllogArg;\n#endif\n};\n\n/*\n** Context pointer passed down through the tree-walk.\n*/\nstruct Walker {\n  int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */\n  int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */\n  Parse *pParse;                            /* Parser context.  */\n  int walkerDepth;                          /* Number of subqueries */\n  u8 bSelectDepthFirst;                     /* Do subqueries first */\n  union {                                   /* Extra data for callback */\n    NameContext *pNC;                          /* Naming context */\n    int i;                                     /* Integer value */\n    SrcList *pSrcList;                         /* FROM clause */\n    struct SrcCount *pSrcCount;                /* Counting column references */\n  } u;\n};\n\n/* Forward declarations */\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);\n\n/*\n** Return code from the parse-tree walking primitives and their\n** callbacks.\n*/\n#define WRC_Continue    0   /* Continue down into children */\n#define WRC_Prune       1   /* Omit children but continue walking siblings */\n#define WRC_Abort       2   /* Abandon the tree walk */\n\n/*\n** Assuming zIn points to the first byte of a UTF-8 character,\n** advance zIn to point to the first byte of the next UTF-8 character.\n*/\n#define SQLITE_SKIP_UTF8(zIn) {                        \\\n  if( (*(zIn++))>=0xc0 ){                              \\\n    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \\\n  }                                                    \\\n}\n\n/*\n** The SQLITE_*_BKPT macros are substitutes for the error codes with\n** the same name but without the _BKPT suffix.  These macros invoke\n** routines that report the line-number on which the error originated\n** using sqlite3_log().  The routines also provide a convenient place\n** to set a debugger breakpoint.\n*/\nSQLITE_PRIVATE int sqlite3CorruptError(int);\nSQLITE_PRIVATE int sqlite3MisuseError(int);\nSQLITE_PRIVATE int sqlite3CantopenError(int);\n#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)\n#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)\n#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)\n\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all\n** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3\n#endif\n\n/*\n** The ctype.h header is needed for non-ASCII systems.  It is also\n** needed by FTS3 when FTS3 is included in the amalgamation.\n*/\n#if !defined(SQLITE_ASCII) || \\\n    (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))\n# include <ctype.h>\n#endif\n\n/*\n** The following macros mimic the standard library functions toupper(),\n** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The\n** sqlite versions only work for ASCII characters, regardless of locale.\n*/\n#ifdef SQLITE_ASCII\n# define sqlite3Toupper(x)  ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))\n# define sqlite3Isspace(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x01)\n# define sqlite3Isalnum(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x06)\n# define sqlite3Isalpha(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x02)\n# define sqlite3Isdigit(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x04)\n# define sqlite3Isxdigit(x)  (sqlite3CtypeMap[(unsigned char)(x)]&0x08)\n# define sqlite3Tolower(x)   (sqlite3UpperToLower[(unsigned char)(x)])\n#else\n# define sqlite3Toupper(x)   toupper((unsigned char)(x))\n# define sqlite3Isspace(x)   isspace((unsigned char)(x))\n# define sqlite3Isalnum(x)   isalnum((unsigned char)(x))\n# define sqlite3Isalpha(x)   isalpha((unsigned char)(x))\n# define sqlite3Isdigit(x)   isdigit((unsigned char)(x))\n# define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))\n# define sqlite3Tolower(x)   tolower((unsigned char)(x))\n#endif\n\n/*\n** Internal function prototypes\n*/\n#define sqlite3StrICmp sqlite3_stricmp\nSQLITE_PRIVATE int sqlite3Strlen30(const char*);\n#define sqlite3StrNICmp sqlite3_strnicmp\n\nSQLITE_PRIVATE int sqlite3MallocInit(void);\nSQLITE_PRIVATE void sqlite3MallocEnd(void);\nSQLITE_PRIVATE void *sqlite3Malloc(int);\nSQLITE_PRIVATE void *sqlite3MallocZero(int);\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, int);\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, int);\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*);\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, int);\nSQLITE_PRIVATE void *sqlite3Realloc(void*, int);\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, int);\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, int);\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);\nSQLITE_PRIVATE int sqlite3MallocSize(void*);\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);\nSQLITE_PRIVATE void *sqlite3ScratchMalloc(int);\nSQLITE_PRIVATE void sqlite3ScratchFree(void*);\nSQLITE_PRIVATE void *sqlite3PageMalloc(int);\nSQLITE_PRIVATE void sqlite3PageFree(void*);\nSQLITE_PRIVATE void sqlite3MemSetDefault(void);\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void);\n\n/*\n** On systems with ample stack space and that support alloca(), make\n** use of alloca() to obtain space for large automatic objects.  By default,\n** obtain space from malloc().\n**\n** The alloca() routine never returns NULL.  This will cause code paths\n** that deal with sqlite3StackAlloc() failures to be unreachable.\n*/\n#ifdef SQLITE_USE_ALLOCA\n# define sqlite3StackAllocRaw(D,N)   alloca(N)\n# define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)\n# define sqlite3StackFree(D,P)       \n#else\n# define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)\n# define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)\n# define sqlite3StackFree(D,P)       sqlite3DbFree(D,P)\n#endif\n\n#ifdef SQLITE_ENABLE_MEMSYS3\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);\n#endif\n\n\n#ifndef SQLITE_MUTEX_OMIT\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3DefaultMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3NoopMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex *sqlite3MutexAlloc(int);\nSQLITE_PRIVATE   int sqlite3MutexInit(void);\nSQLITE_PRIVATE   int sqlite3MutexEnd(void);\n#endif\n\nSQLITE_PRIVATE int sqlite3StatusValue(int);\nSQLITE_PRIVATE void sqlite3StatusAdd(int, int);\nSQLITE_PRIVATE void sqlite3StatusSet(int, int);\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\nSQLITE_PRIVATE   int sqlite3IsNaN(double);\n#else\n# define sqlite3IsNaN(X)  0\n#endif\n\nSQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, int, const char*, va_list);\n#ifndef SQLITE_OMIT_TRACE\nSQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);\n#endif\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);\nSQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\nSQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);\n#endif\n#if defined(SQLITE_TEST)\nSQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);\n#endif\n\n/* Output formatting for SQLITE_TESTCTRL_EXPLAIN */\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\nSQLITE_PRIVATE   void sqlite3ExplainBegin(Vdbe*);\nSQLITE_PRIVATE   void sqlite3ExplainPrintf(Vdbe*, const char*, ...);\nSQLITE_PRIVATE   void sqlite3ExplainNL(Vdbe*);\nSQLITE_PRIVATE   void sqlite3ExplainPush(Vdbe*);\nSQLITE_PRIVATE   void sqlite3ExplainPop(Vdbe*);\nSQLITE_PRIVATE   void sqlite3ExplainFinish(Vdbe*);\nSQLITE_PRIVATE   void sqlite3ExplainSelect(Vdbe*, Select*);\nSQLITE_PRIVATE   void sqlite3ExplainExpr(Vdbe*, Expr*);\nSQLITE_PRIVATE   void sqlite3ExplainExprList(Vdbe*, ExprList*);\nSQLITE_PRIVATE   const char *sqlite3VdbeExplanation(Vdbe*);\n#else\n# define sqlite3ExplainBegin(X)\n# define sqlite3ExplainSelect(A,B)\n# define sqlite3ExplainExpr(A,B)\n# define sqlite3ExplainExprList(A,B)\n# define sqlite3ExplainFinish(X)\n# define sqlite3VdbeExplanation(X) 0\n#endif\n\n\nSQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*, ...);\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);\nSQLITE_PRIVATE int sqlite3Dequote(char*);\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);\nSQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse*);\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse*);\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse*);\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);\nSQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);\nSQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*, const Token*);\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);\nSQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);\nSQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);\nSQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);\nSQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);\nSQLITE_PRIVATE void sqlite3BeginParse(Parse*,int);\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);\nSQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);\nSQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3AddColumnType(Parse*,Token*);\nSQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,ExprSpan*);\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,Select*);\nSQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,\n                    sqlite3_vfs**,char**,char **);\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);\nSQLITE_PRIVATE int sqlite3CodeOnce(Parse *);\n\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32);\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec*, u32);\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec*, u32);\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec*, u32, void*);\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec*);\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec*);\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int,int*);\n\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);\nSQLITE_PRIVATE void sqlite3RowSetClear(RowSet*);\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet*, i64);\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, u8 iBatch, i64);\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*);\n\nSQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\nSQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);\n#else\n# define sqlite3ViewGetColumnNames(A,B) 0\n#endif\n\nSQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);\n#ifndef SQLITE_OMIT_AUTOINCREMENT\nSQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);\nSQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);\n#else\n# define sqlite3AutoincrementBegin(X)\n# define sqlite3AutoincrementEnd(X)\n#endif\nSQLITE_PRIVATE int sqlite3CodeCoroutine(Parse*, Select*, SelectDest*);\nSQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,\n                                      Token*, Select*, Expr*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);\nSQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,\n                        Token*, int, int);\nSQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);\nSQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);\nSQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,\n                         Expr*,ExprList*,u16,Expr*,Expr*);\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);\nSQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*);\n#endif\nSQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);\nSQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);\nSQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);\nSQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);\nSQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);\nSQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeAndCache(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeConstants(Parse*, Expr*);\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);\nSQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*);\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *);\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3Vacuum(Parse*);\nSQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*);\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*);\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);\nSQLITE_PRIVATE void sqlite3PrngSaveState(void);\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void);\nSQLITE_PRIVATE void sqlite3PrngResetState(void);\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);\nSQLITE_PRIVATE void sqlite3CommitTransaction(Parse*);\nSQLITE_PRIVATE void sqlite3RollbackTransaction(Parse*);\nSQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);\nSQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int);\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);\nSQLITE_PRIVATE int sqlite3IsRowid(const char*);\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int);\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*);\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int);\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int,\n                                     int*,int,int,int,int,int*);\nSQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int);\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int);\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse*);\nSQLITE_PRIVATE void sqlite3MayAbort(Parse*);\nSQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, int);\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);\nSQLITE_PRIVATE void sqlite3FuncDefInsert(FuncDefHash*, FuncDef*);\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,u8);\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3*);\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);\nSQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void);\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, int);\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE   void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,\n                           Expr*,int, int);\nSQLITE_PRIVATE   void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);\nSQLITE_PRIVATE   void sqlite3DropTrigger(Parse*, SrcList*, int);\nSQLITE_PRIVATE   void sqlite3DropTriggerPtr(Parse*, Trigger*);\nSQLITE_PRIVATE   Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);\nSQLITE_PRIVATE   Trigger *sqlite3TriggerList(Parse *, Table *);\nSQLITE_PRIVATE   void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,\n                            int, int, int);\nSQLITE_PRIVATE   void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);\n  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);\nSQLITE_PRIVATE   void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,\n                                        ExprList*,Select*,u8);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);\nSQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);\nSQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);\nSQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);\n# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))\n#else\n# define sqlite3TriggersExist(B,C,D,E,F) 0\n# define sqlite3DeleteTrigger(A,B)\n# define sqlite3DropTriggerPtr(A,B)\n# define sqlite3UnlinkAndDeleteTrigger(A,B,C)\n# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)\n# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)\n# define sqlite3TriggerList(X, Y) 0\n# define sqlite3ParseToplevel(p) p\n# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0\n#endif\n\nSQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);\n#ifndef SQLITE_OMIT_AUTHORIZATION\nSQLITE_PRIVATE   void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);\nSQLITE_PRIVATE   int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPop(AuthContext*);\nSQLITE_PRIVATE   int sqlite3AuthReadCol(Parse*, const char *, const char *, int);\n#else\n# define sqlite3AuthRead(a,b,c,d)\n# define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK\n# define sqlite3AuthContextPush(a,b,c)\n# define sqlite3AuthContextPop(a)  ((void)(a))\n#endif\nSQLITE_PRIVATE void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);\nSQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);\nSQLITE_PRIVATE int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);\nSQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);\nSQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);\nSQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);\nSQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);\nSQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);\nSQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);\nSQLITE_PRIVATE int sqlite3Atoi(const char*);\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);\nSQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);\n\n/*\n** Routines to read and write variable-length integers.  These used to\n** be defined locally, but now we use the varint routines in the util.c\n** file.  Code should use the MACRO forms below, as the Varint32 versions\n** are coded to assume the single byte case is already handled (which \n** the MACRO form does).\n*/\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char*, u64);\nSQLITE_PRIVATE int sqlite3PutVarint32(unsigned char*, u32);\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *, u64 *);\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *, u32 *);\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v);\n\n/*\n** The header of a record consists of a sequence variable-length integers.\n** These integers are almost always small and are encoded as a single byte.\n** The following macros take advantage this fact to provide a fast encode\n** and decode of the integers in a record header.  It is faster for the common\n** case where the integer is a single byte.  It is a little slower when the\n** integer is two or more bytes.  But overall it is faster.\n**\n** The following expressions are equivalent:\n**\n**     x = sqlite3GetVarint32( A, &B );\n**     x = sqlite3PutVarint32( A, B );\n**\n**     x = getVarint32( A, B );\n**     x = putVarint32( A, B );\n**\n*/\n#define getVarint32(A,B)  \\\n  (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))\n#define putVarint32(A,B)  \\\n  (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\\\n  sqlite3PutVarint32((A),(B)))\n#define getVarint    sqlite3GetVarint\n#define putVarint    sqlite3PutVarint\n\n\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *);\nSQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *, Table *);\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);\nSQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);\nSQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...);\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h);\nSQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) || \\\n    defined(SQLITE_DEBUG_OS_TRACE)\nSQLITE_PRIVATE const char *sqlite3ErrName(int);\n#endif\n\nSQLITE_PRIVATE const char *sqlite3ErrStr(int);\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, Token*);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);\nSQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3AbsInt32(int);\n#ifdef SQLITE_ENABLE_8_3_NAMES\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char*, char*);\n#else\n# define sqlite3FileSuffix3(X,Y)\n#endif\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z,int);\n\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value*, u8);\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);\nSQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, \n                        void(*)(void*));\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);\n#ifdef SQLITE_ENABLE_STAT3\nSQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *);\n#endif\nSQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);\n#ifndef SQLITE_AMALGAMATION\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];\nSQLITE_PRIVATE const Token sqlite3IntTokens[];\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;\nSQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte;\n#endif\n#endif\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);\nSQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3AlterFunctions(void);\nSQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);\nSQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);\nSQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int);\nSQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);\nSQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);\nSQLITE_PRIVATE char sqlite3AffinityType(const char*);\nSQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*);\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);\nSQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3SchemaClear(void *);\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);\nSQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *);\nSQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, \n  void (*)(sqlite3_context*,int,sqlite3_value **),\n  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),\n  FuncDestructor *pDestructor\n);\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);\n\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, char*, int, int);\nSQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);\nSQLITE_PRIVATE void sqlite3AppendSpace(StrAccum*,int);\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);\nSQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);\n\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);\n\n/*\n** The interface to the LEMON-generated parser\n*/\nSQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(size_t));\nSQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));\nSQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE   int sqlite3ParserStackPeak(void*);\n#endif\n\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE   void sqlite3CloseExtensions(sqlite3*);\n#else\n# define sqlite3CloseExtensions(X)\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3TableLock(Parse *, int, int, u8, const char *);\n#else\n  #define sqlite3TableLock(v,w,x,y,z)\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int sqlite3Utf8To8(unsigned char*);\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n#  define sqlite3VtabClear(Y)\n#  define sqlite3VtabSync(X,Y) SQLITE_OK\n#  define sqlite3VtabRollback(X)\n#  define sqlite3VtabCommit(X)\n#  define sqlite3VtabInSync(db) 0\n#  define sqlite3VtabLock(X) \n#  define sqlite3VtabUnlock(X)\n#  define sqlite3VtabUnlockList(X)\n#  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK\n#  define sqlite3GetVTable(X,Y)  ((VTable*)0)\n#else\nSQLITE_PRIVATE    void sqlite3VtabClear(sqlite3 *db, Table*);\nSQLITE_PRIVATE    void sqlite3VtabDisconnect(sqlite3 *db, Table *p);\nSQLITE_PRIVATE    int sqlite3VtabSync(sqlite3 *db, char **);\nSQLITE_PRIVATE    int sqlite3VtabRollback(sqlite3 *db);\nSQLITE_PRIVATE    int sqlite3VtabCommit(sqlite3 *db);\nSQLITE_PRIVATE    void sqlite3VtabLock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlockList(sqlite3*);\nSQLITE_PRIVATE    int sqlite3VtabSavepoint(sqlite3 *, int, int);\nSQLITE_PRIVATE    VTable *sqlite3GetVTable(sqlite3*, Table*);\n#  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)\n#endif\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);\nSQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse*);\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);\nSQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);\nSQLITE_PRIVATE const char *sqlite3JournalModename(int);\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);\n#endif\n\n/* Declarations for functions in fkey.c. All of these are replaced by\n** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign\n** key functionality is available. If OMIT_TRIGGER is defined but\n** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In\n** this case foreign keys are parsed, but no other functionality is \n** provided (enforcement of FK constraints requires the triggers sub-system).\n*/\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE   void sqlite3FkCheck(Parse*, Table*, int, int);\nSQLITE_PRIVATE   void sqlite3FkDropTable(Parse*, SrcList *, Table*);\nSQLITE_PRIVATE   void sqlite3FkActions(Parse*, Table*, ExprList*, int);\nSQLITE_PRIVATE   int sqlite3FkRequired(Parse*, Table*, int*, int);\nSQLITE_PRIVATE   u32 sqlite3FkOldmask(Parse*, Table*);\nSQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *);\n#else\n  #define sqlite3FkActions(a,b,c,d)\n  #define sqlite3FkCheck(a,b,c,d)\n  #define sqlite3FkDropTable(a,b,c)\n  #define sqlite3FkOldmask(a,b)      0\n  #define sqlite3FkRequired(a,b,c,d) 0\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE   void sqlite3FkDelete(sqlite3 *, Table*);\nSQLITE_PRIVATE   int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);\n#else\n  #define sqlite3FkDelete(a,b)\n  #define sqlite3FkLocateIndex(a,b,c,d,e)\n#endif\n\n\n/*\n** Available fault injectors.  Should be numbered beginning with 0.\n*/\n#define SQLITE_FAULTINJECTOR_MALLOC     0\n#define SQLITE_FAULTINJECTOR_COUNT      1\n\n/*\n** The interface to the code in fault.c used for identifying \"benign\"\n** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST\n** is not defined.\n*/\n#ifndef SQLITE_OMIT_BUILTIN_TEST\nSQLITE_PRIVATE   void sqlite3BeginBenignMalloc(void);\nSQLITE_PRIVATE   void sqlite3EndBenignMalloc(void);\n#else\n  #define sqlite3BeginBenignMalloc()\n  #define sqlite3EndBenignMalloc()\n#endif\n\n#define IN_INDEX_ROWID           1\n#define IN_INDEX_EPH             2\n#define IN_INDEX_INDEX_ASC       3\n#define IN_INDEX_INDEX_DESC      4\nSQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, int*);\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\nSQLITE_PRIVATE   int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);\nSQLITE_PRIVATE   int sqlite3JournalSize(sqlite3_vfs *);\nSQLITE_PRIVATE   int sqlite3JournalCreate(sqlite3_file *);\nSQLITE_PRIVATE   int sqlite3JournalExists(sqlite3_file *p);\n#else\n  #define sqlite3JournalSize(pVfs) ((pVfs)->szOsFile)\n  #define sqlite3JournalExists(p) 1\n#endif\n\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);\nSQLITE_PRIVATE int sqlite3MemJournalSize(void);\nSQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);\n\n#if SQLITE_MAX_EXPR_DEPTH>0\nSQLITE_PRIVATE   void sqlite3ExprSetHeight(Parse *pParse, Expr *p);\nSQLITE_PRIVATE   int sqlite3SelectExprHeight(Select *);\nSQLITE_PRIVATE   int sqlite3ExprCheckHeight(Parse*, int);\n#else\n  #define sqlite3ExprSetHeight(x,y)\n  #define sqlite3SelectExprHeight(x) 0\n  #define sqlite3ExprCheckHeight(x,y)\n#endif\n\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8*);\nSQLITE_PRIVATE void sqlite3Put4byte(u8*, u32);\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nSQLITE_PRIVATE   void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);\nSQLITE_PRIVATE   void sqlite3ConnectionUnlocked(sqlite3 *db);\nSQLITE_PRIVATE   void sqlite3ConnectionClosed(sqlite3 *db);\n#else\n  #define sqlite3ConnectionBlocked(x,y)\n  #define sqlite3ConnectionUnlocked(x)\n  #define sqlite3ConnectionClosed(x)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3ParserTrace(FILE*, char *);\n#endif\n\n/*\n** If the SQLITE_ENABLE IOTRACE exists then the global variable\n** sqlite3IoTrace is a pointer to a printf-like routine used to\n** print I/O tracing messages. \n*/\n#ifdef SQLITE_ENABLE_IOTRACE\n# define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }\nSQLITE_PRIVATE   void sqlite3VdbeIOTraceSql(Vdbe*);\nSQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);\n#else\n# define IOTRACE(A)\n# define sqlite3VdbeIOTraceSql(X)\n#endif\n\n/*\n** These routines are available for the mem2.c debugging memory allocator\n** only.  They are used to verify that different \"types\" of memory\n** allocations are properly tracked by the system.\n**\n** sqlite3MemdebugSetType() sets the \"type\" of an allocation to one of\n** the MEMTYPE_* macros defined below.  The type must be a bitmask with\n** a single bit set.\n**\n** sqlite3MemdebugHasType() returns true if any of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n** sqlite3MemdebugHasType() is intended for use inside assert() statements.\n**\n** sqlite3MemdebugNoType() returns true if none of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n**\n** Perhaps the most important point is the difference between MEMTYPE_HEAP\n** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means\n** it might have been allocated by lookaside, except the allocation was\n** too large or lookaside was already full.  It is important to verify\n** that allocations that might have been satisfied by lookaside are not\n** passed back to non-lookaside free() routines.  Asserts such as the\n** example above are placed on the non-lookaside free() routines to verify\n** this constraint. \n**\n** All of this is no-op for a production build.  It only comes into\n** play when the SQLITE_MEMDEBUG compile-time option is used.\n*/\n#ifdef SQLITE_MEMDEBUG\nSQLITE_PRIVATE   void sqlite3MemdebugSetType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugHasType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugNoType(void*,u8);\n#else\n# define sqlite3MemdebugSetType(X,Y)  /* no-op */\n# define sqlite3MemdebugHasType(X,Y)  1\n# define sqlite3MemdebugNoType(X,Y)   1\n#endif\n#define MEMTYPE_HEAP       0x01  /* General heap allocations */\n#define MEMTYPE_LOOKASIDE  0x02  /* Might have been lookaside memory */\n#define MEMTYPE_SCRATCH    0x04  /* Scratch allocations */\n#define MEMTYPE_PCACHE     0x08  /* Page cache allocations */\n#define MEMTYPE_DB         0x10  /* Uses sqlite3DbMalloc, not sqlite_malloc */\n\n#endif /* _SQLITEINT_H_ */\n\n/************** End of sqliteInt.h *******************************************/\n/************** Begin file global.c ******************************************/\n/*\n** 2008 June 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains definitions of global variables and contants.\n*/\n\n/* An array to map all upper-case characters into their corresponding\n** lower-case character. \n**\n** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not\n** handle case conversions for the UTF character set since the tables\n** involved are nearly as big or bigger than SQLite itself.\n*/\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {\n#ifdef SQLITE_ASCII\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,\n     18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n     36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,\n     54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,\n    104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,\n    122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,\n    108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,\n    126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,\n    162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,\n    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,\n    198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,\n    216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,\n    234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,\n    252,253,254,255\n#endif\n#ifdef SQLITE_EBCDIC\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */\n     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */\n     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */\n     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */\n     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */\n     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */\n     96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */\n    112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */\n    128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */\n    160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */\n    176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */\n    192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */\n    208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */\n    224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */\n    239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */\n#endif\n};\n\n/*\n** The following 256 byte lookup table is used to support SQLites built-in\n** equivalents to the following standard library functions:\n**\n**   isspace()                        0x01\n**   isalpha()                        0x02\n**   isdigit()                        0x04\n**   isalnum()                        0x06\n**   isxdigit()                       0x08\n**   toupper()                        0x20\n**   SQLite identifier character      0x40\n**\n** Bit 0x20 is set if the mapped character requires translation to upper\n** case. i.e. if the character is a lower-case ASCII character.\n** If x is a lower-case ASCII character, then its upper-case equivalent\n** is (x - 0x20). Therefore toupper() can be implemented as:\n**\n**   (x & ~(map[x]&0x20))\n**\n** Standard function tolower() is implemented using the sqlite3UpperToLower[]\n** array. tolower() is used more often than toupper() by SQLite.\n**\n** Bit 0x40 is set if the character non-alphanumeric and can be used in an \n** SQLite identifier.  Identifiers are alphanumerics, \"_\", \"$\", and any\n** non-ASCII UTF character. Hence the test for whether or not a character is\n** part of an identifier is 0x46.\n**\n** SQLite's versions are identical to the standard versions assuming a\n** locale of \"C\". They are implemented as macros in sqliteInt.h.\n*/\n#ifdef SQLITE_ASCII\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 00..07    ........ */\n  0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */\n  0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,  /* 20..27     !\"#$%&' */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */\n  0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */\n  0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */\n\n  0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */\n  0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\\]^_ */\n  0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */\n  0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */\n};\n#endif\n\n#ifndef SQLITE_USE_URI\n# define  SQLITE_USE_URI 0\n#endif\n\n#ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN\n# define SQLITE_ALLOW_COVERING_INDEX_SCAN 1\n#endif\n\n/*\n** The following singleton contains the global configuration for\n** the SQLite library.\n*/\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {\n   SQLITE_DEFAULT_MEMSTATUS,  /* bMemstat */\n   1,                         /* bCoreMutex */\n   SQLITE_THREADSAFE==1,      /* bFullMutex */\n   SQLITE_USE_URI,            /* bOpenUri */\n   SQLITE_ALLOW_COVERING_INDEX_SCAN,   /* bUseCis */\n   0x7ffffffe,                /* mxStrlen */\n   128,                       /* szLookaside */\n   500,                       /* nLookaside */\n   {0,0,0,0,0,0,0,0},         /* m */\n   {0,0,0,0,0,0,0,0,0},       /* mutex */\n   {0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */\n   (void*)0,                  /* pHeap */\n   0,                         /* nHeap */\n   0, 0,                      /* mnHeap, mxHeap */\n   SQLITE_DEFAULT_MMAP_SIZE,  /* szMmap */\n   SQLITE_MAX_MMAP_SIZE,      /* mxMmap */\n   (void*)0,                  /* pScratch */\n   0,                         /* szScratch */\n   0,                         /* nScratch */\n   (void*)0,                  /* pPage */\n   0,                         /* szPage */\n   0,                         /* nPage */\n   0,                         /* mxParserStack */\n   0,                         /* sharedCacheEnabled */\n   /* All the rest should always be initialized to zero */\n   0,                         /* isInit */\n   0,                         /* inProgress */\n   0,                         /* isMutexInit */\n   0,                         /* isMallocInit */\n   0,                         /* isPCacheInit */\n   0,                         /* pInitMutex */\n   0,                         /* nRefInitMutex */\n   0,                         /* xLog */\n   0,                         /* pLogArg */\n   0,                         /* bLocaltimeFault */\n#ifdef SQLITE_ENABLE_SQLLOG\n   0,                         /* xSqllog */\n   0                          /* pSqllogArg */\n#endif\n};\n\n\n/*\n** Hash table for global functions - functions common to all\n** database connections.  After initialization, this table is\n** read-only.\n*/\nSQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;\n\n/*\n** Constant tokens for values 0 and 1.\n*/\nSQLITE_PRIVATE const Token sqlite3IntTokens[] = {\n   { \"0\", 1 },\n   { \"1\", 1 }\n};\n\n\n/*\n** The value of the \"pending\" byte must be 0x40000000 (1 byte past the\n** 1-gibabyte boundary) in a compatible database.  SQLite never uses\n** the database page that contains the pending byte.  It never attempts\n** to read or write that page.  The pending byte page is set assign\n** for use by the VFS layers as space for managing file locks.\n**\n** During testing, it is often desirable to move the pending byte to\n** a different position in the file.  This allows code that has to\n** deal with the pending byte to run on files that are much smaller\n** than 1 GiB.  The sqlite3_test_control() interface can be used to\n** move the pending byte.\n**\n** IMPORTANT:  Changing the pending byte to any value other than\n** 0x40000000 results in an incompatible database file format!\n** Changing the pending byte during operating results in undefined\n** and dileterious behavior.\n*/\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;\n#endif\n\n/*\n** Properties of opcodes.  The OPFLG_INITIALIZER macro is\n** created by mkopcodeh.awk during compilation.  Data is obtained\n** from the comments following the \"case OP_xxxx:\" statements in\n** the vdbe.c file.  \n*/\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;\n\n/************** End of global.c **********************************************/\n/************** Begin file ctime.c *******************************************/\n/*\n** 2010 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements routines used to report what compile-time options\n** SQLite was built with.\n*/\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n\n\n/*\n** An array of names of all compile-time options.  This array should \n** be sorted A-Z.\n**\n** This array looks large, but in a typical installation actually uses\n** only a handful of compile-time options, so most times this array is usually\n** rather short and uses little memory space.\n*/\nstatic const char * const azCompileOpt[] = {\n\n/* These macros are provided to \"stringify\" the value of the define\n** for those options in which the value is meaningful. */\n#define CTIMEOPT_VAL_(opt) #opt\n#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)\n\n#ifdef SQLITE_32BIT_ROWID\n  \"32BIT_ROWID\",\n#endif\n#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC\n  \"4_BYTE_ALIGNED_MALLOC\",\n#endif\n#ifdef SQLITE_CASE_SENSITIVE_LIKE\n  \"CASE_SENSITIVE_LIKE\",\n#endif\n#ifdef SQLITE_CHECK_PAGES\n  \"CHECK_PAGES\",\n#endif\n#ifdef SQLITE_COVERAGE_TEST\n  \"COVERAGE_TEST\",\n#endif\n#ifdef SQLITE_DEBUG\n  \"DEBUG\",\n#endif\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  \"DEFAULT_LOCKING_MODE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),\n#endif\n#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)\n  \"DEFAULT_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),\n#endif\n#ifdef SQLITE_DISABLE_DIRSYNC\n  \"DISABLE_DIRSYNC\",\n#endif\n#ifdef SQLITE_DISABLE_LFS\n  \"DISABLE_LFS\",\n#endif\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n  \"ENABLE_ATOMIC_WRITE\",\n#endif\n#ifdef SQLITE_ENABLE_CEROD\n  \"ENABLE_CEROD\",\n#endif\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n  \"ENABLE_COLUMN_METADATA\",\n#endif\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  \"ENABLE_EXPENSIVE_ASSERT\",\n#endif\n#ifdef SQLITE_ENABLE_FTS1\n  \"ENABLE_FTS1\",\n#endif\n#ifdef SQLITE_ENABLE_FTS2\n  \"ENABLE_FTS2\",\n#endif\n#ifdef SQLITE_ENABLE_FTS3\n  \"ENABLE_FTS3\",\n#endif\n#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS\n  \"ENABLE_FTS3_PARENTHESIS\",\n#endif\n#ifdef SQLITE_ENABLE_FTS4\n  \"ENABLE_FTS4\",\n#endif\n#ifdef SQLITE_ENABLE_ICU\n  \"ENABLE_ICU\",\n#endif\n#ifdef SQLITE_ENABLE_IOTRACE\n  \"ENABLE_IOTRACE\",\n#endif\n#ifdef SQLITE_ENABLE_LOAD_EXTENSION\n  \"ENABLE_LOAD_EXTENSION\",\n#endif\n#ifdef SQLITE_ENABLE_LOCKING_STYLE\n  \"ENABLE_LOCKING_STYLE=\" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),\n#endif\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  \"ENABLE_MEMORY_MANAGEMENT\",\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS3\n  \"ENABLE_MEMSYS3\",\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\n  \"ENABLE_MEMSYS5\",\n#endif\n#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK\n  \"ENABLE_OVERSIZE_CELL_CHECK\",\n#endif\n#ifdef SQLITE_ENABLE_RTREE\n  \"ENABLE_RTREE\",\n#endif\n#ifdef SQLITE_ENABLE_STAT3\n  \"ENABLE_STAT3\",\n#endif\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  \"ENABLE_UNLOCK_NOTIFY\",\n#endif\n#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  \"ENABLE_UPDATE_DELETE_LIMIT\",\n#endif\n#ifdef SQLITE_HAS_CODEC\n  \"HAS_CODEC\",\n#endif\n#ifdef SQLITE_HAVE_ISNAN\n  \"HAVE_ISNAN\",\n#endif\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  \"HOMEGROWN_RECURSIVE_MUTEX\",\n#endif\n#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS\n  \"IGNORE_AFP_LOCK_ERRORS\",\n#endif\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  \"IGNORE_FLOCK_LOCK_ERRORS\",\n#endif\n#ifdef SQLITE_INT64_TYPE\n  \"INT64_TYPE\",\n#endif\n#ifdef SQLITE_LOCK_TRACE\n  \"LOCK_TRACE\",\n#endif\n#if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)\n  \"MAX_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),\n#endif\n#ifdef SQLITE_MAX_SCHEMA_RETRY\n  \"MAX_SCHEMA_RETRY=\" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),\n#endif\n#ifdef SQLITE_MEMDEBUG\n  \"MEMDEBUG\",\n#endif\n#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n  \"MIXED_ENDIAN_64BIT_FLOAT\",\n#endif\n#ifdef SQLITE_NO_SYNC\n  \"NO_SYNC\",\n#endif\n#ifdef SQLITE_OMIT_ALTERTABLE\n  \"OMIT_ALTERTABLE\",\n#endif\n#ifdef SQLITE_OMIT_ANALYZE\n  \"OMIT_ANALYZE\",\n#endif\n#ifdef SQLITE_OMIT_ATTACH\n  \"OMIT_ATTACH\",\n#endif\n#ifdef SQLITE_OMIT_AUTHORIZATION\n  \"OMIT_AUTHORIZATION\",\n#endif\n#ifdef SQLITE_OMIT_AUTOINCREMENT\n  \"OMIT_AUTOINCREMENT\",\n#endif\n#ifdef SQLITE_OMIT_AUTOINIT\n  \"OMIT_AUTOINIT\",\n#endif\n#ifdef SQLITE_OMIT_AUTOMATIC_INDEX\n  \"OMIT_AUTOMATIC_INDEX\",\n#endif\n#ifdef SQLITE_OMIT_AUTORESET\n  \"OMIT_AUTORESET\",\n#endif\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  \"OMIT_AUTOVACUUM\",\n#endif\n#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  \"OMIT_BETWEEN_OPTIMIZATION\",\n#endif\n#ifdef SQLITE_OMIT_BLOB_LITERAL\n  \"OMIT_BLOB_LITERAL\",\n#endif\n#ifdef SQLITE_OMIT_BTREECOUNT\n  \"OMIT_BTREECOUNT\",\n#endif\n#ifdef SQLITE_OMIT_BUILTIN_TEST\n  \"OMIT_BUILTIN_TEST\",\n#endif\n#ifdef SQLITE_OMIT_CAST\n  \"OMIT_CAST\",\n#endif\n#ifdef SQLITE_OMIT_CHECK\n  \"OMIT_CHECK\",\n#endif\n#ifdef SQLITE_OMIT_COMPLETE\n  \"OMIT_COMPLETE\",\n#endif\n#ifdef SQLITE_OMIT_COMPOUND_SELECT\n  \"OMIT_COMPOUND_SELECT\",\n#endif\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n  \"OMIT_DATETIME_FUNCS\",\n#endif\n#ifdef SQLITE_OMIT_DECLTYPE\n  \"OMIT_DECLTYPE\",\n#endif\n#ifdef SQLITE_OMIT_DEPRECATED\n  \"OMIT_DEPRECATED\",\n#endif\n#ifdef SQLITE_OMIT_DISKIO\n  \"OMIT_DISKIO\",\n#endif\n#ifdef SQLITE_OMIT_EXPLAIN\n  \"OMIT_EXPLAIN\",\n#endif\n#ifdef SQLITE_OMIT_FLAG_PRAGMAS\n  \"OMIT_FLAG_PRAGMAS\",\n#endif\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  \"OMIT_FLOATING_POINT\",\n#endif\n#ifdef SQLITE_OMIT_FOREIGN_KEY\n  \"OMIT_FOREIGN_KEY\",\n#endif\n#ifdef SQLITE_OMIT_GET_TABLE\n  \"OMIT_GET_TABLE\",\n#endif\n#ifdef SQLITE_OMIT_INCRBLOB\n  \"OMIT_INCRBLOB\",\n#endif\n#ifdef SQLITE_OMIT_INTEGRITY_CHECK\n  \"OMIT_INTEGRITY_CHECK\",\n#endif\n#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION\n  \"OMIT_LIKE_OPTIMIZATION\",\n#endif\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n  \"OMIT_LOAD_EXTENSION\",\n#endif\n#ifdef SQLITE_OMIT_LOCALTIME\n  \"OMIT_LOCALTIME\",\n#endif\n#ifdef SQLITE_OMIT_LOOKASIDE\n  \"OMIT_LOOKASIDE\",\n#endif\n#ifdef SQLITE_OMIT_MEMORYDB\n  \"OMIT_MEMORYDB\",\n#endif\n#ifdef SQLITE_OMIT_OR_OPTIMIZATION\n  \"OMIT_OR_OPTIMIZATION\",\n#endif\n#ifdef SQLITE_OMIT_PAGER_PRAGMAS\n  \"OMIT_PAGER_PRAGMAS\",\n#endif\n#ifdef SQLITE_OMIT_PRAGMA\n  \"OMIT_PRAGMA\",\n#endif\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n  \"OMIT_PROGRESS_CALLBACK\",\n#endif\n#ifdef SQLITE_OMIT_QUICKBALANCE\n  \"OMIT_QUICKBALANCE\",\n#endif\n#ifdef SQLITE_OMIT_REINDEX\n  \"OMIT_REINDEX\",\n#endif\n#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS\n  \"OMIT_SCHEMA_PRAGMAS\",\n#endif\n#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  \"OMIT_SCHEMA_VERSION_PRAGMAS\",\n#endif\n#ifdef SQLITE_OMIT_SHARED_CACHE\n  \"OMIT_SHARED_CACHE\",\n#endif\n#ifdef SQLITE_OMIT_SUBQUERY\n  \"OMIT_SUBQUERY\",\n#endif\n#ifdef SQLITE_OMIT_TCL_VARIABLE\n  \"OMIT_TCL_VARIABLE\",\n#endif\n#ifdef SQLITE_OMIT_TEMPDB\n  \"OMIT_TEMPDB\",\n#endif\n#ifdef SQLITE_OMIT_TRACE\n  \"OMIT_TRACE\",\n#endif\n#ifdef SQLITE_OMIT_TRIGGER\n  \"OMIT_TRIGGER\",\n#endif\n#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  \"OMIT_TRUNCATE_OPTIMIZATION\",\n#endif\n#ifdef SQLITE_OMIT_UTF16\n  \"OMIT_UTF16\",\n#endif\n#ifdef SQLITE_OMIT_VACUUM\n  \"OMIT_VACUUM\",\n#endif\n#ifdef SQLITE_OMIT_VIEW\n  \"OMIT_VIEW\",\n#endif\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  \"OMIT_VIRTUALTABLE\",\n#endif\n#ifdef SQLITE_OMIT_WAL\n  \"OMIT_WAL\",\n#endif\n#ifdef SQLITE_OMIT_WSD\n  \"OMIT_WSD\",\n#endif\n#ifdef SQLITE_OMIT_XFER_OPT\n  \"OMIT_XFER_OPT\",\n#endif\n#ifdef SQLITE_PERFORMANCE_TRACE\n  \"PERFORMANCE_TRACE\",\n#endif\n#ifdef SQLITE_PROXY_DEBUG\n  \"PROXY_DEBUG\",\n#endif\n#ifdef SQLITE_RTREE_INT_ONLY\n  \"RTREE_INT_ONLY\",\n#endif\n#ifdef SQLITE_SECURE_DELETE\n  \"SECURE_DELETE\",\n#endif\n#ifdef SQLITE_SMALL_STACK\n  \"SMALL_STACK\",\n#endif\n#ifdef SQLITE_SOUNDEX\n  \"SOUNDEX\",\n#endif\n#ifdef SQLITE_TCL\n  \"TCL\",\n#endif\n#if defined(SQLITE_TEMP_STORE) && !defined(SQLITE_TEMP_STORE_xc)\n  \"TEMP_STORE=\" CTIMEOPT_VAL(SQLITE_TEMP_STORE),\n#endif\n#ifdef SQLITE_TEST\n  \"TEST\",\n#endif\n#if defined(SQLITE_THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(SQLITE_THREADSAFE),\n#endif\n#ifdef SQLITE_USE_ALLOCA\n  \"USE_ALLOCA\",\n#endif\n#ifdef SQLITE_ZERO_MALLOC\n  \"ZERO_MALLOC\"\n#endif\n};\n\n/*\n** Given the name of a compile-time option, return true if that option\n** was used and false if not.\n**\n** The name can optionally begin with \"SQLITE_\" but the \"SQLITE_\" prefix\n** is not required for a match.\n*/\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName){\n  int i, n;\n  if( sqlite3StrNICmp(zOptName, \"SQLITE_\", 7)==0 ) zOptName += 7;\n  n = sqlite3Strlen30(zOptName);\n\n  /* Since ArraySize(azCompileOpt) is normally in single digits, a\n  ** linear search is adequate.  No need for a binary search. */\n  for(i=0; i<ArraySize(azCompileOpt); i++){\n    if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0\n     && sqlite3CtypeMap[(unsigned char)azCompileOpt[i][n]]==0\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return the N-th compile-time option string.  If N is out of range,\n** return a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_compileoption_get(int N){\n  if( N>=0 && N<ArraySize(azCompileOpt) ){\n    return azCompileOpt[N];\n  }\n  return 0;\n}\n\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/************** End of ctime.c ***********************************************/\n/************** Begin file status.c ******************************************/\n/*\n** 2008 June 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements the sqlite3_status() interface and related\n** functionality.\n*/\n/************** Include vdbeInt.h in the middle of status.c ******************/\n/************** Begin file vdbeInt.h *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for information that is private to the\n** VDBE.  This information used to all be at the top of the single\n** source code file \"vdbe.c\".  When that file became too big (over\n** 6000 lines long) it was split up into several smaller files and\n** this header information was factored out.\n*/\n#ifndef _VDBEINT_H_\n#define _VDBEINT_H_\n\n/*\n** The maximum number of times that a statement will try to reparse\n** itself before giving up and returning SQLITE_SCHEMA.\n*/\n#ifndef SQLITE_MAX_SCHEMA_RETRY\n# define SQLITE_MAX_SCHEMA_RETRY 50\n#endif\n\n/*\n** SQL is translated into a sequence of instructions to be\n** executed by a virtual machine.  Each instruction is an instance\n** of the following structure.\n*/\ntypedef struct VdbeOp Op;\n\n/*\n** Boolean values\n*/\ntypedef unsigned char Bool;\n\n/* Opaque type used by code in vdbesort.c */\ntypedef struct VdbeSorter VdbeSorter;\n\n/* Opaque type used by the explainer */\ntypedef struct Explain Explain;\n\n/*\n** A cursor is a pointer into a single BTree within a database file.\n** The cursor can seek to a BTree entry with a particular key, or\n** loop over all entries of the Btree.  You can also insert new BTree\n** entries or retrieve the key or data from the entry that the cursor\n** is currently pointing to.\n** \n** Every cursor that the virtual machine has open is represented by an\n** instance of the following structure.\n*/\nstruct VdbeCursor {\n  BtCursor *pCursor;    /* The cursor structure of the backend */\n  Btree *pBt;           /* Separate file holding temporary table */\n  KeyInfo *pKeyInfo;    /* Info about index keys needed by index cursors */\n  int iDb;              /* Index of cursor database in db->aDb[] (or -1) */\n  int pseudoTableReg;   /* Register holding pseudotable content. */\n  int nField;           /* Number of fields in the header */\n  Bool zeroed;          /* True if zeroed out and ready for reuse */\n  Bool rowidIsValid;    /* True if lastRowid is valid */\n  Bool atFirst;         /* True if pointing to first entry */\n  Bool useRandomRowid;  /* Generate new record numbers semi-randomly */\n  Bool nullRow;         /* True if pointing to a row with no data */\n  Bool deferredMoveto;  /* A call to sqlite3BtreeMoveto() is needed */\n  Bool isTable;         /* True if a table requiring integer keys */\n  Bool isIndex;         /* True if an index containing keys only - no data */\n  Bool isOrdered;       /* True if the underlying table is BTREE_UNORDERED */\n  Bool isSorter;        /* True if a new-style sorter */\n  Bool multiPseudo;     /* Multi-register pseudo-cursor */\n  sqlite3_vtab_cursor *pVtabCursor;  /* The cursor for a virtual table */\n  const sqlite3_module *pModule;     /* Module for cursor pVtabCursor */\n  i64 seqCount;         /* Sequence counter */\n  i64 movetoTarget;     /* Argument to the deferred sqlite3BtreeMoveto() */\n  i64 lastRowid;        /* Last rowid from a Next or NextIdx operation */\n  VdbeSorter *pSorter;  /* Sorter object for OP_SorterOpen cursors */\n\n  /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or \n  ** OP_IsUnique opcode on this cursor. */\n  int seekResult;\n\n  /* Cached information about the header for the data record that the\n  ** cursor is currently pointing to.  Only valid if cacheStatus matches\n  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of\n  ** CACHE_STALE and so setting cacheStatus=CACHE_STALE guarantees that\n  ** the cache is out of date.\n  **\n  ** aRow might point to (ephemeral) data for the current row, or it might\n  ** be NULL.\n  */\n  u32 cacheStatus;      /* Cache is valid if this matches Vdbe.cacheCtr */\n  int payloadSize;      /* Total number of bytes in the record */\n  u32 *aType;           /* Type values for all entries in the record */\n  u32 *aOffset;         /* Cached offsets to the start of each columns data */\n  u8 *aRow;             /* Data for the current row, if all on one page */\n};\ntypedef struct VdbeCursor VdbeCursor;\n\n/*\n** When a sub-program is executed (OP_Program), a structure of this type\n** is allocated to store the current value of the program counter, as\n** well as the current memory cell array and various other frame specific\n** values stored in the Vdbe struct. When the sub-program is finished, \n** these values are copied back to the Vdbe from the VdbeFrame structure,\n** restoring the state of the VM to as it was before the sub-program\n** began executing.\n**\n** The memory for a VdbeFrame object is allocated and managed by a memory\n** cell in the parent (calling) frame. When the memory cell is deleted or\n** overwritten, the VdbeFrame object is not freed immediately. Instead, it\n** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame\n** list is deleted when the VM is reset in VdbeHalt(). The reason for doing\n** this instead of deleting the VdbeFrame immediately is to avoid recursive\n** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the\n** child frame are released.\n**\n** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is\n** set to NULL if the currently executing frame is the main program.\n*/\ntypedef struct VdbeFrame VdbeFrame;\nstruct VdbeFrame {\n  Vdbe *v;                /* VM this frame belongs to */\n  VdbeFrame *pParent;     /* Parent of this frame, or NULL if parent is main */\n  Op *aOp;                /* Program instructions for parent frame */\n  Mem *aMem;              /* Array of memory cells for parent frame */\n  u8 *aOnceFlag;          /* Array of OP_Once flags for parent frame */\n  VdbeCursor **apCsr;     /* Array of Vdbe cursors for parent frame */\n  void *token;            /* Copy of SubProgram.token */\n  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */\n  int nCursor;            /* Number of entries in apCsr */\n  int pc;                 /* Program Counter in parent (calling) frame */\n  int nOp;                /* Size of aOp array */\n  int nMem;               /* Number of entries in aMem */\n  int nOnceFlag;          /* Number of entries in aOnceFlag */\n  int nChildMem;          /* Number of memory cells for child frame */\n  int nChildCsr;          /* Number of cursors for child frame */\n  int nChange;            /* Statement changes (Vdbe.nChanges)     */\n};\n\n#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])\n\n/*\n** A value for VdbeCursor.cacheValid that means the cache is always invalid.\n*/\n#define CACHE_STALE 0\n\n/*\n** Internally, the vdbe manipulates nearly all SQL values as Mem\n** structures. Each Mem struct may cache multiple representations (string,\n** integer etc.) of the same value.\n*/\nstruct Mem {\n  sqlite3 *db;        /* The associated database connection */\n  char *z;            /* String or BLOB value */\n  double r;           /* Real value */\n  union {\n    i64 i;              /* Integer value used when MEM_Int is set in flags */\n    int nZero;          /* Used when bit MEM_Zero is set in flags */\n    FuncDef *pDef;      /* Used only when flags==MEM_Agg */\n    RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */\n    VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */\n  } u;\n  int n;              /* Number of characters in string value, excluding '\\0' */\n  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */\n  u8  type;           /* One of SQLITE_NULL, SQLITE_TEXT, SQLITE_INTEGER, etc */\n  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */\n#ifdef SQLITE_DEBUG\n  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */\n  void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */\n#endif\n  void (*xDel)(void *);  /* If not null, call this function to delete Mem.z */\n  char *zMalloc;      /* Dynamic buffer allocated by sqlite3_malloc() */\n};\n\n/* One or more of the following flags are set to indicate the validOK\n** representations of the value stored in the Mem struct.\n**\n** If the MEM_Null flag is set, then the value is an SQL NULL value.\n** No other flags may be set in this case.\n**\n** If the MEM_Str flag is set then Mem.z points at a string representation.\n** Usually this is encoded in the same unicode encoding as the main\n** database (see below for exceptions). If the MEM_Term flag is also\n** set, then the string is nul terminated. The MEM_Int and MEM_Real \n** flags may coexist with the MEM_Str flag.\n*/\n#define MEM_Null      0x0001   /* Value is NULL */\n#define MEM_Str       0x0002   /* Value is a string */\n#define MEM_Int       0x0004   /* Value is an integer */\n#define MEM_Real      0x0008   /* Value is a real number */\n#define MEM_Blob      0x0010   /* Value is a BLOB */\n#define MEM_RowSet    0x0020   /* Value is a RowSet object */\n#define MEM_Frame     0x0040   /* Value is a VdbeFrame object */\n#define MEM_Invalid   0x0080   /* Value is undefined */\n#define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */\n#define MEM_TypeMask  0x01ff   /* Mask of type bits */\n\n\n/* Whenever Mem contains a valid string or blob representation, one of\n** the following flags must be set to determine the memory management\n** policy for Mem.z.  The MEM_Term flag tells us whether or not the\n** string is \\000 or \\u0000 terminated\n*/\n#define MEM_Term      0x0200   /* String rep is nul terminated */\n#define MEM_Dyn       0x0400   /* Need to call sqliteFree() on Mem.z */\n#define MEM_Static    0x0800   /* Mem.z points to a static string */\n#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */\n#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */\n#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */\n#ifdef SQLITE_OMIT_INCRBLOB\n  #undef MEM_Zero\n  #define MEM_Zero 0x0000\n#endif\n\n/*\n** Clear any existing type flags from a Mem and replace them with f\n*/\n#define MemSetTypeFlag(p, f) \\\n   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)\n\n/*\n** Return true if a memory cell is not marked as invalid.  This macro\n** is for use inside assert() statements only.\n*/\n#ifdef SQLITE_DEBUG\n#define memIsValid(M)  ((M)->flags & MEM_Invalid)==0\n#endif\n\n\n/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains\n** additional information about auxiliary information bound to arguments\n** of the function.  This is used to implement the sqlite3_get_auxdata()\n** and sqlite3_set_auxdata() APIs.  The \"auxdata\" is some auxiliary data\n** that can be associated with a constant argument to a function.  This\n** allows functions such as \"regexp\" to compile their constant regular\n** expression argument once and reused the compiled code for multiple\n** invocations.\n*/\nstruct VdbeFunc {\n  FuncDef *pFunc;               /* The definition of the function */\n  int nAux;                     /* Number of entries allocated for apAux[] */\n  struct AuxData {\n    void *pAux;                   /* Aux data for the i-th argument */\n    void (*xDelete)(void *);      /* Destructor for the aux data */\n  } apAux[1];                   /* One slot for each function argument */\n};\n\n/*\n** The \"context\" argument for a installable function.  A pointer to an\n** instance of this structure is the first argument to the routines used\n** implement the SQL functions.\n**\n** There is a typedef for this structure in sqlite.h.  So all routines,\n** even the public interface to SQLite, can use a pointer to this structure.\n** But this file is the only place where the internal details of this\n** structure are known.\n**\n** This structure is defined inside of vdbeInt.h because it uses substructures\n** (Mem) which are only defined there.\n*/\nstruct sqlite3_context {\n  FuncDef *pFunc;       /* Pointer to function information.  MUST BE FIRST */\n  VdbeFunc *pVdbeFunc;  /* Auxilary data, if created. */\n  Mem s;                /* The return value is stored here */\n  Mem *pMem;            /* Memory cell used to store aggregate context */\n  CollSeq *pColl;       /* Collating sequence */\n  int isError;          /* Error code returned by the function. */\n  int skipFlag;         /* Skip skip accumulator loading if true */\n};\n\n/*\n** An Explain object accumulates indented output which is helpful\n** in describing recursive data structures.\n*/\nstruct Explain {\n  Vdbe *pVdbe;       /* Attach the explanation to this Vdbe */\n  StrAccum str;      /* The string being accumulated */\n  int nIndent;       /* Number of elements in aIndent */\n  u16 aIndent[100];  /* Levels of indentation */\n  char zBase[100];   /* Initial space */\n};\n\n/* A bitfield type for use inside of structures.  Always follow with :N where\n** N is the number of bits.\n*/\ntypedef unsigned bft;  /* Bit Field Type */\n\n/*\n** An instance of the virtual machine.  This structure contains the complete\n** state of the virtual machine.\n**\n** The \"sqlite3_stmt\" structure pointer that is returned by sqlite3_prepare()\n** is really a pointer to an instance of this structure.\n**\n** The Vdbe.inVtabMethod variable is set to non-zero for the duration of\n** any virtual table method invocations made by the vdbe program. It is\n** set to 2 for xDestroy method calls and 1 for all other methods. This\n** variable is used for two purposes: to allow xDestroy methods to execute\n** \"DROP TABLE\" statements and to prevent some nasty side effects of\n** malloc failure when SQLite is invoked recursively by a virtual table \n** method function.\n*/\nstruct Vdbe {\n  sqlite3 *db;            /* The database connection that owns this statement */\n  Op *aOp;                /* Space to hold the virtual machine's program */\n  Mem *aMem;              /* The memory locations */\n  Mem **apArg;            /* Arguments to currently executing user function */\n  Mem *aColName;          /* Column names to return */\n  Mem *pResultSet;        /* Pointer to an array of results */\n  int nMem;               /* Number of memory locations currently allocated */\n  int nOp;                /* Number of instructions in the program */\n  int nOpAlloc;           /* Number of slots allocated for aOp[] */\n  int nLabel;             /* Number of labels used */\n  int *aLabel;            /* Space to hold the labels */\n  u16 nResColumn;         /* Number of columns in one row of the result set */\n  int nCursor;            /* Number of slots in apCsr[] */\n  u32 magic;              /* Magic number for sanity checking */\n  char *zErrMsg;          /* Error message written here */\n  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */\n  VdbeCursor **apCsr;     /* One element of this array for each open cursor */\n  Mem *aVar;              /* Values for the OP_Variable opcode. */\n  char **azVar;           /* Name of variables */\n  ynVar nVar;             /* Number of entries in aVar[] */\n  ynVar nzVar;            /* Number of entries in azVar[] */\n  u32 cacheCtr;           /* VdbeCursor row cache generation counter */\n  int pc;                 /* The program counter */\n  int rc;                 /* Value to return */\n  u8 errorAction;         /* Recovery action to do in case of an error */\n  u8 minWriteFileFormat;  /* Minimum file format for writable database files */\n  bft explain:2;          /* True if EXPLAIN present on SQL command */\n  bft inVtabMethod:2;     /* See comments above */\n  bft changeCntOn:1;      /* True to update the change-counter */\n  bft expired:1;          /* True if the VM needs to be recompiled */\n  bft runOnlyOnce:1;      /* Automatically expire on reset */\n  bft usesStmtJournal:1;  /* True if uses a statement journal */\n  bft readOnly:1;         /* True for read-only statements */\n  bft isPrepareV2:1;      /* True if prepared with prepare_v2() */\n  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */\n  int nChange;            /* Number of db changes made since last reset */\n  yDbMask btreeMask;      /* Bitmask of db->aDb[] entries referenced */\n  yDbMask lockMask;       /* Subset of btreeMask that requires a lock */\n  int iStatement;         /* Statement number (or 0 if has not opened stmt) */\n  int aCounter[3];        /* Counters used by sqlite3_stmt_status() */\n#ifndef SQLITE_OMIT_TRACE\n  i64 startTime;          /* Time when query started - used for profiling */\n#endif\n  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */\n  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */\n  char *zSql;             /* Text of the SQL statement that generated this */\n  void *pFree;            /* Free this when deleting the vdbe */\n#ifdef SQLITE_DEBUG\n  FILE *trace;            /* Write an execution trace here, if not NULL */\n#endif\n#ifdef SQLITE_ENABLE_TREE_EXPLAIN\n  Explain *pExplain;      /* The explainer */\n  char *zExplain;         /* Explanation of data structures */\n#endif\n  VdbeFrame *pFrame;      /* Parent frame */\n  VdbeFrame *pDelFrame;   /* List of frame objects to free on VM reset */\n  int nFrame;             /* Number of frames in pFrame list */\n  u32 expmask;            /* Binding to these vars invalidates VM */\n  SubProgram *pProgram;   /* Linked list of all sub-programs used by VM */\n  int nOnceFlag;          /* Size of array aOnceFlag[] */\n  u8 *aOnceFlag;          /* Flags for OP_Once */\n};\n\n/*\n** The following are allowed values for Vdbe.magic\n*/\n#define VDBE_MAGIC_INIT     0x26bceaa5    /* Building a VDBE program */\n#define VDBE_MAGIC_RUN      0xbdf20da3    /* VDBE is ready to execute */\n#define VDBE_MAGIC_HALT     0x519c2973    /* VDBE has completed execution */\n#define VDBE_MAGIC_DEAD     0xb606c3c8    /* The VDBE has been deallocated */\n\n/*\n** Function prototypes\n*/\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);\nvoid sqliteVdbePopStack(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor*);\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);\n#endif\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int);\n\nint sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);\nSQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int);\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64\n#else\nSQLITE_PRIVATE   void sqlite3VdbeMemSetDouble(Mem*, double);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);\nSQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, int);\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,int,int,int,Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);\nSQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p);\n#define VdbeMemRelease(X)  \\\n  if((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame)) \\\n    sqlite3VdbeMemReleaseExternal(X);\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int);\nSQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);\nSQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem);\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);\n\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *);\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *);\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *);\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\nSQLITE_PRIVATE   void sqlite3VdbeEnter(Vdbe*);\nSQLITE_PRIVATE   void sqlite3VdbeLeave(Vdbe*);\n#else\n# define sqlite3VdbeEnter(X)\n# define sqlite3VdbeLeave(X)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);\n#endif\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);\n#else\n# define sqlite3VdbeCheckFk(p,i) 0\n#endif\n\nSQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem*, u8);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3VdbePrintSql(Vdbe*);\nSQLITE_PRIVATE   void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem);\n\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE   int sqlite3VdbeMemExpandBlob(Mem *);\n  #define ExpandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)\n#else\n  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK\n  #define ExpandBlob(P) SQLITE_OK\n#endif\n\n#endif /* !defined(_VDBEINT_H_) */\n\n/************** End of vdbeInt.h *********************************************/\n/************** Continuing where we left off in status.c *********************/\n\n/*\n** Variables in which to record status information.\n*/\ntypedef struct sqlite3StatType sqlite3StatType;\nstatic SQLITE_WSD struct sqlite3StatType {\n  int nowValue[10];         /* Current value */\n  int mxValue[10];          /* Maximum value */\n} sqlite3Stat = { {0,}, {0,} };\n\n\n/* The \"wsdStat\" macro will resolve to the status information\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Stat\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdStatInit  sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat)\n# define wsdStat x[0]\n#else\n# define wsdStatInit\n# define wsdStat sqlite3Stat\n#endif\n\n/*\n** Return the current value of a status parameter.\n*/\nSQLITE_PRIVATE int sqlite3StatusValue(int op){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  return wsdStat.nowValue[op];\n}\n\n/*\n** Add N to the value of a status record.  It is assumed that the\n** caller holds appropriate locks.\n*/\nSQLITE_PRIVATE void sqlite3StatusAdd(int op, int N){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  wsdStat.nowValue[op] += N;\n  if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n}\n\n/*\n** Set the value of a status to X.\n*/\nSQLITE_PRIVATE void sqlite3StatusSet(int op, int X){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  wsdStat.nowValue[op] = X;\n  if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n}\n\n/*\n** Query status information.\n**\n** This implementation assumes that reading or writing an aligned\n** 32-bit integer is an atomic operation.  If that assumption is not true,\n** then this routine is not threadsafe.\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){\n  wsdStatInit;\n  if( op<0 || op>=ArraySize(wsdStat.nowValue) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  *pCurrent = wsdStat.nowValue[op];\n  *pHighwater = wsdStat.mxValue[op];\n  if( resetFlag ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Query status information for a single database connection\n*/\nSQLITE_API int sqlite3_db_status(\n  sqlite3 *db,          /* The database connection whose status is desired */\n  int op,               /* Status verb */\n  int *pCurrent,        /* Write current value here */\n  int *pHighwater,      /* Write high-water mark here */\n  int resetFlag         /* Reset high-water mark if true */\n){\n  int rc = SQLITE_OK;   /* Return code */\n  sqlite3_mutex_enter(db->mutex);\n  switch( op ){\n    case SQLITE_DBSTATUS_LOOKASIDE_USED: {\n      *pCurrent = db->lookaside.nOut;\n      *pHighwater = db->lookaside.mxOut;\n      if( resetFlag ){\n        db->lookaside.mxOut = db->lookaside.nOut;\n      }\n      break;\n    }\n\n    case SQLITE_DBSTATUS_LOOKASIDE_HIT:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );\n      *pCurrent = 0;\n      *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];\n      if( resetFlag ){\n        db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;\n      }\n      break;\n    }\n\n    /* \n    ** Return an approximation for the amount of memory currently used\n    ** by all pagers associated with the given database connection.  The\n    ** highwater mark is meaningless and is returned as zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_USED: {\n      int totalUsed = 0;\n      int i;\n      sqlite3BtreeEnterAll(db);\n      for(i=0; i<db->nDb; i++){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          Pager *pPager = sqlite3BtreePager(pBt);\n          totalUsed += sqlite3PagerMemUsed(pPager);\n        }\n      }\n      sqlite3BtreeLeaveAll(db);\n      *pCurrent = totalUsed;\n      *pHighwater = 0;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store the schema for all databases (main, temp, and any ATTACHed\n    ** databases.  *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_SCHEMA_USED: {\n      int i;                      /* Used to iterate through schemas */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      sqlite3BtreeEnterAll(db);\n      db->pnBytesFreed = &nByte;\n      for(i=0; i<db->nDb; i++){\n        Schema *pSchema = db->aDb[i].pSchema;\n        if( ALWAYS(pSchema!=0) ){\n          HashElem *p;\n\n          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (\n              pSchema->tblHash.count \n            + pSchema->trigHash.count\n            + pSchema->idxHash.count\n            + pSchema->fkeyHash.count\n          );\n          nByte += sqlite3MallocSize(pSchema->tblHash.ht);\n          nByte += sqlite3MallocSize(pSchema->trigHash.ht);\n          nByte += sqlite3MallocSize(pSchema->idxHash.ht);\n          nByte += sqlite3MallocSize(pSchema->fkeyHash.ht);\n\n          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));\n          }\n          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));\n          }\n        }\n      }\n      db->pnBytesFreed = 0;\n      sqlite3BtreeLeaveAll(db);\n\n      *pHighwater = 0;\n      *pCurrent = nByte;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store all prepared statements.\n    ** *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_STMT_USED: {\n      struct Vdbe *pVdbe;         /* Used to iterate through VMs */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      db->pnBytesFreed = &nByte;\n      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){\n        sqlite3VdbeClearObject(db, pVdbe);\n        sqlite3DbFree(db, pVdbe);\n      }\n      db->pnBytesFreed = 0;\n\n      *pHighwater = 0;\n      *pCurrent = nByte;\n\n      break;\n    }\n\n    /*\n    ** Set *pCurrent to the total cache hits or misses encountered by all\n    ** pagers the database handle is connected to. *pHighwater is always set \n    ** to zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_HIT:\n    case SQLITE_DBSTATUS_CACHE_MISS:\n    case SQLITE_DBSTATUS_CACHE_WRITE:{\n      int i;\n      int nRet = 0;\n      assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );\n      assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );\n\n      for(i=0; i<db->nDb; i++){\n        if( db->aDb[i].pBt ){\n          Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);\n          sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);\n        }\n      }\n      *pHighwater = 0;\n      *pCurrent = nRet;\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of status.c **********************************************/\n/************** Begin file date.c ********************************************/\n/*\n** 2003 October 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement date and time\n** functions for SQLite.  \n**\n** There is only one exported symbol in this file - the function\n** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.\n** All other code has file scope.\n**\n** SQLite processes all times and dates as Julian Day numbers.  The\n** dates and times are stored as the number of days since noon\n** in Greenwich on November 24, 4714 B.C. according to the Gregorian\n** calendar system. \n**\n** 1970-01-01 00:00:00 is JD 2440587.5\n** 2000-01-01 00:00:00 is JD 2451544.5\n**\n** This implemention requires years to be expressed as a 4-digit number\n** which means that only dates between 0000-01-01 and 9999-12-31 can\n** be represented, even though julian day numbers allow a much wider\n** range of dates.\n**\n** The Gregorian calendar system is used for all dates and times,\n** even those that predate the Gregorian calendar.  Historians usually\n** use the Julian calendar for dates prior to 1582-10-15 and for some\n** dates afterwards, depending on locale.  Beware of this difference.\n**\n** The conversion algorithms are implemented based on descriptions\n** in the following text:\n**\n**      Jean Meeus\n**      Astronomical Algorithms, 2nd Edition, 1998\n**      ISBM 0-943396-61-1\n**      Willmann-Bell, Inc\n**      Richmond, Virginia (USA)\n*/\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n#include <time.h>\n\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n\n\n/*\n** A structure for holding a single date and time.\n*/\ntypedef struct DateTime DateTime;\nstruct DateTime {\n  sqlite3_int64 iJD; /* The julian day number times 86400000 */\n  int Y, M, D;       /* Year, month, and day */\n  int h, m;          /* Hour and minutes */\n  int tz;            /* Timezone offset in minutes */\n  double s;          /* Seconds */\n  char validYMD;     /* True (1) if Y,M,D are valid */\n  char validHMS;     /* True (1) if h,m,s are valid */\n  char validJD;      /* True (1) if iJD is valid */\n  char validTZ;      /* True (1) if tz is valid */\n};\n\n\n/*\n** Convert zDate into one or more integers.  Additional arguments\n** come in groups of 5 as follows:\n**\n**       N       number of digits in the integer\n**       min     minimum allowed value of the integer\n**       max     maximum allowed value of the integer\n**       nextC   first character after the integer\n**       pVal    where to write the integers value.\n**\n** Conversions continue until one with nextC==0 is encountered.\n** The function returns the number of successful conversions.\n*/\nstatic int getDigits(const char *zDate, ...){\n  va_list ap;\n  int val;\n  int N;\n  int min;\n  int max;\n  int nextC;\n  int *pVal;\n  int cnt = 0;\n  va_start(ap, zDate);\n  do{\n    N = va_arg(ap, int);\n    min = va_arg(ap, int);\n    max = va_arg(ap, int);\n    nextC = va_arg(ap, int);\n    pVal = va_arg(ap, int*);\n    val = 0;\n    while( N-- ){\n      if( !sqlite3Isdigit(*zDate) ){\n        goto end_getDigits;\n      }\n      val = val*10 + *zDate - '0';\n      zDate++;\n    }\n    if( val<min || val>max || (nextC!=0 && nextC!=*zDate) ){\n      goto end_getDigits;\n    }\n    *pVal = val;\n    zDate++;\n    cnt++;\n  }while( nextC );\nend_getDigits:\n  va_end(ap);\n  return cnt;\n}\n\n/*\n** Parse a timezone extension on the end of a date-time.\n** The extension is of the form:\n**\n**        (+/-)HH:MM\n**\n** Or the \"zulu\" notation:\n**\n**        Z\n**\n** If the parse is successful, write the number of minutes\n** of change in p->tz and return 0.  If a parser error occurs,\n** return non-zero.\n**\n** A missing specifier is not considered an error.\n*/\nstatic int parseTimezone(const char *zDate, DateTime *p){\n  int sgn = 0;\n  int nHr, nMn;\n  int c;\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tz = 0;\n  c = *zDate;\n  if( c=='-' ){\n    sgn = -1;\n  }else if( c=='+' ){\n    sgn = +1;\n  }else if( c=='Z' || c=='z' ){\n    zDate++;\n    goto zulu_time;\n  }else{\n    return c!=0;\n  }\n  zDate++;\n  if( getDigits(zDate, 2, 0, 14, ':', &nHr, 2, 0, 59, 0, &nMn)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  p->tz = sgn*(nMn + nHr*60);\nzulu_time:\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  return *zDate!=0;\n}\n\n/*\n** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.\n** The HH, MM, and SS must each be exactly 2 digits.  The\n** fractional seconds FFFF can be one or more digits.\n**\n** Return 1 if there is a parsing error and 0 on success.\n*/\nstatic int parseHhMmSs(const char *zDate, DateTime *p){\n  int h, m, s;\n  double ms = 0.0;\n  if( getDigits(zDate, 2, 0, 24, ':', &h, 2, 0, 59, 0, &m)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  if( *zDate==':' ){\n    zDate++;\n    if( getDigits(zDate, 2, 0, 59, 0, &s)!=1 ){\n      return 1;\n    }\n    zDate += 2;\n    if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){\n      double rScale = 1.0;\n      zDate++;\n      while( sqlite3Isdigit(*zDate) ){\n        ms = ms*10.0 + *zDate - '0';\n        rScale *= 10.0;\n        zDate++;\n      }\n      ms /= rScale;\n    }\n  }else{\n    s = 0;\n  }\n  p->validJD = 0;\n  p->validHMS = 1;\n  p->h = h;\n  p->m = m;\n  p->s = s + ms;\n  if( parseTimezone(zDate, p) ) return 1;\n  p->validTZ = (p->tz!=0)?1:0;\n  return 0;\n}\n\n/*\n** Convert from YYYY-MM-DD HH:MM:SS to julian day.  We always assume\n** that the YYYY-MM-DD is according to the Gregorian calendar.\n**\n** Reference:  Meeus page 61\n*/\nstatic void computeJD(DateTime *p){\n  int Y, M, D, A, B, X1, X2;\n\n  if( p->validJD ) return;\n  if( p->validYMD ){\n    Y = p->Y;\n    M = p->M;\n    D = p->D;\n  }else{\n    Y = 2000;  /* If no YMD specified, assume 2000-Jan-01 */\n    M = 1;\n    D = 1;\n  }\n  if( M<=2 ){\n    Y--;\n    M += 12;\n  }\n  A = Y/100;\n  B = 2 - A + (A/4);\n  X1 = 36525*(Y+4716)/100;\n  X2 = 306001*(M+1)/10000;\n  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);\n  p->validJD = 1;\n  if( p->validHMS ){\n    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);\n    if( p->validTZ ){\n      p->iJD -= p->tz*60000;\n      p->validYMD = 0;\n      p->validHMS = 0;\n      p->validTZ = 0;\n    }\n  }\n}\n\n/*\n** Parse dates of the form\n**\n**     YYYY-MM-DD HH:MM:SS.FFF\n**     YYYY-MM-DD HH:MM:SS\n**     YYYY-MM-DD HH:MM\n**     YYYY-MM-DD\n**\n** Write the result into the DateTime structure and return 0\n** on success and 1 if the input string is not a well-formed\n** date.\n*/\nstatic int parseYyyyMmDd(const char *zDate, DateTime *p){\n  int Y, M, D, neg;\n\n  if( zDate[0]=='-' ){\n    zDate++;\n    neg = 1;\n  }else{\n    neg = 0;\n  }\n  if( getDigits(zDate,4,0,9999,'-',&Y,2,1,12,'-',&M,2,1,31,0,&D)!=3 ){\n    return 1;\n  }\n  zDate += 10;\n  while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }\n  if( parseHhMmSs(zDate, p)==0 ){\n    /* We got the time */\n  }else if( *zDate==0 ){\n    p->validHMS = 0;\n  }else{\n    return 1;\n  }\n  p->validJD = 0;\n  p->validYMD = 1;\n  p->Y = neg ? -Y : Y;\n  p->M = M;\n  p->D = D;\n  if( p->validTZ ){\n    computeJD(p);\n  }\n  return 0;\n}\n\n/*\n** Set the time to the current time reported by the VFS.\n**\n** Return the number of errors.\n*/\nstatic int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  if( sqlite3OsCurrentTimeInt64(db->pVfs, &p->iJD)==SQLITE_OK ){\n    p->validJD = 1;\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Attempt to parse the given string into a Julian Day Number.  Return\n** the number of errors.\n**\n** The following are acceptable forms for the input string:\n**\n**      YYYY-MM-DD HH:MM:SS.FFF  +/-HH:MM\n**      DDDD.DD \n**      now\n**\n** In the first form, the +/-HH:MM is always optional.  The fractional\n** seconds extension (the \".FFF\") is optional.  The seconds portion\n** (\":SS.FFF\") is option.  The year and date can be omitted as long\n** as there is a time string.  The time string can be omitted as long\n** as there is a year and date.\n*/\nstatic int parseDateOrTime(\n  sqlite3_context *context, \n  const char *zDate, \n  DateTime *p\n){\n  double r;\n  if( parseYyyyMmDd(zDate,p)==0 ){\n    return 0;\n  }else if( parseHhMmSs(zDate, p)==0 ){\n    return 0;\n  }else if( sqlite3StrICmp(zDate,\"now\")==0){\n    return setDateTimeToCurrent(context, p);\n  }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){\n    p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);\n    p->validJD = 1;\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Compute the Year, Month, and Day from the julian day number.\n*/\nstatic void computeYMD(DateTime *p){\n  int Z, A, B, C, D, E, X1;\n  if( p->validYMD ) return;\n  if( !p->validJD ){\n    p->Y = 2000;\n    p->M = 1;\n    p->D = 1;\n  }else{\n    Z = (int)((p->iJD + 43200000)/86400000);\n    A = (int)((Z - 1867216.25)/36524.25);\n    A = Z + 1 + A - (A/4);\n    B = A + 1524;\n    C = (int)((B - 122.1)/365.25);\n    D = (36525*C)/100;\n    E = (int)((B-D)/30.6001);\n    X1 = (int)(30.6001*E);\n    p->D = B - D - X1;\n    p->M = E<14 ? E-1 : E-13;\n    p->Y = p->M>2 ? C - 4716 : C - 4715;\n  }\n  p->validYMD = 1;\n}\n\n/*\n** Compute the Hour, Minute, and Seconds from the julian day number.\n*/\nstatic void computeHMS(DateTime *p){\n  int s;\n  if( p->validHMS ) return;\n  computeJD(p);\n  s = (int)((p->iJD + 43200000) % 86400000);\n  p->s = s/1000.0;\n  s = (int)p->s;\n  p->s -= s;\n  p->h = s/3600;\n  s -= p->h*3600;\n  p->m = s/60;\n  p->s += s - p->m*60;\n  p->validHMS = 1;\n}\n\n/*\n** Compute both YMD and HMS\n*/\nstatic void computeYMD_HMS(DateTime *p){\n  computeYMD(p);\n  computeHMS(p);\n}\n\n/*\n** Clear the YMD and HMS and the TZ\n*/\nstatic void clearYMD_HMS_TZ(DateTime *p){\n  p->validYMD = 0;\n  p->validHMS = 0;\n  p->validTZ = 0;\n}\n\n/*\n** On recent Windows platforms, the localtime_s() function is available\n** as part of the \"Secure CRT\". It is essentially equivalent to \n** localtime_r() available under most POSIX platforms, except that the \n** order of the parameters is reversed.\n**\n** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.\n**\n** If the user has not indicated to use localtime_r() or localtime_s()\n** already, check for an MSVC build environment that provides \n** localtime_s().\n*/\n#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \\\n     defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)\n#define HAVE_LOCALTIME_S 1\n#endif\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** The following routine implements the rough equivalent of localtime_r()\n** using whatever operating-system specific localtime facility that\n** is available.  This routine returns 0 on success and\n** non-zero on any kind of error.\n**\n** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this\n** routine will always fail.\n*/\nstatic int osLocaltime(time_t *t, struct tm *pTm){\n  int rc;\n#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \\\n      && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)\n  struct tm *pX;\n#if SQLITE_THREADSAFE>0\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  pX = localtime(t);\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n  if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;\n#endif\n  if( pX ) *pTm = *pX;\n  sqlite3_mutex_leave(mutex);\n  rc = pX==0;\n#else\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n  if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;\n#endif\n#if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R\n  rc = localtime_r(t, pTm)==0;\n#else\n  rc = localtime_s(pTm, t);\n#endif /* HAVE_LOCALTIME_R */\n#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */\n  return rc;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** Compute the difference (in milliseconds) between localtime and UTC\n** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,\n** return this value and set *pRc to SQLITE_OK. \n**\n** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value\n** is undefined in this case.\n*/\nstatic sqlite3_int64 localtimeOffset(\n  DateTime *p,                    /* Date at which to calculate offset */\n  sqlite3_context *pCtx,          /* Write error here if one occurs */\n  int *pRc                        /* OUT: Error code. SQLITE_OK or ERROR */\n){\n  DateTime x, y;\n  time_t t;\n  struct tm sLocal;\n\n  /* Initialize the contents of sLocal to avoid a compiler warning. */\n  memset(&sLocal, 0, sizeof(sLocal));\n\n  x = *p;\n  computeYMD_HMS(&x);\n  if( x.Y<1971 || x.Y>=2038 ){\n    x.Y = 2000;\n    x.M = 1;\n    x.D = 1;\n    x.h = 0;\n    x.m = 0;\n    x.s = 0.0;\n  } else {\n    int s = (int)(x.s + 0.5);\n    x.s = s;\n  }\n  x.tz = 0;\n  x.validJD = 0;\n  computeJD(&x);\n  t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);\n  if( osLocaltime(&t, &sLocal) ){\n    sqlite3_result_error(pCtx, \"local time unavailable\", -1);\n    *pRc = SQLITE_ERROR;\n    return 0;\n  }\n  y.Y = sLocal.tm_year + 1900;\n  y.M = sLocal.tm_mon + 1;\n  y.D = sLocal.tm_mday;\n  y.h = sLocal.tm_hour;\n  y.m = sLocal.tm_min;\n  y.s = sLocal.tm_sec;\n  y.validYMD = 1;\n  y.validHMS = 1;\n  y.validJD = 0;\n  y.validTZ = 0;\n  computeJD(&y);\n  *pRc = SQLITE_OK;\n  return y.iJD - x.iJD;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n/*\n** Process a modifier to a date-time stamp.  The modifiers are\n** as follows:\n**\n**     NNN days\n**     NNN hours\n**     NNN minutes\n**     NNN.NNNN seconds\n**     NNN months\n**     NNN years\n**     start of month\n**     start of year\n**     start of week\n**     start of day\n**     weekday N\n**     unixepoch\n**     localtime\n**     utc\n**\n** Return 0 on success and 1 if there is any kind of error. If the error\n** is in a system call (i.e. localtime()), then an error message is written\n** to context pCtx. If the error is an unrecognized modifier, no error is\n** written to pCtx.\n*/\nstatic int parseModifier(sqlite3_context *pCtx, const char *zMod, DateTime *p){\n  int rc = 1;\n  int n;\n  double r;\n  char *z, zBuf[30];\n  z = zBuf;\n  for(n=0; n<ArraySize(zBuf)-1 && zMod[n]; n++){\n    z[n] = (char)sqlite3UpperToLower[(u8)zMod[n]];\n  }\n  z[n] = 0;\n  switch( z[0] ){\n#ifndef SQLITE_OMIT_LOCALTIME\n    case 'l': {\n      /*    localtime\n      **\n      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to\n      ** show local time.\n      */\n      if( strcmp(z, \"localtime\")==0 ){\n        computeJD(p);\n        p->iJD += localtimeOffset(p, pCtx, &rc);\n        clearYMD_HMS_TZ(p);\n      }\n      break;\n    }\n#endif\n    case 'u': {\n      /*\n      **    unixepoch\n      **\n      ** Treat the current value of p->iJD as the number of\n      ** seconds since 1970.  Convert to a real julian day number.\n      */\n      if( strcmp(z, \"unixepoch\")==0 && p->validJD ){\n        p->iJD = (p->iJD + 43200)/86400 + 21086676*(i64)10000000;\n        clearYMD_HMS_TZ(p);\n        rc = 0;\n      }\n#ifndef SQLITE_OMIT_LOCALTIME\n      else if( strcmp(z, \"utc\")==0 ){\n        sqlite3_int64 c1;\n        computeJD(p);\n        c1 = localtimeOffset(p, pCtx, &rc);\n        if( rc==SQLITE_OK ){\n          p->iJD -= c1;\n          clearYMD_HMS_TZ(p);\n          p->iJD += c1 - localtimeOffset(p, pCtx, &rc);\n        }\n      }\n#endif\n      break;\n    }\n    case 'w': {\n      /*\n      **    weekday N\n      **\n      ** Move the date to the same time on the next occurrence of\n      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the\n      ** date is already on the appropriate weekday, this is a no-op.\n      */\n      if( strncmp(z, \"weekday \", 8)==0\n               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)\n               && (n=(int)r)==r && n>=0 && r<7 ){\n        sqlite3_int64 Z;\n        computeYMD_HMS(p);\n        p->validTZ = 0;\n        p->validJD = 0;\n        computeJD(p);\n        Z = ((p->iJD + 129600000)/86400000) % 7;\n        if( Z>n ) Z -= 7;\n        p->iJD += (n - Z)*86400000;\n        clearYMD_HMS_TZ(p);\n        rc = 0;\n      }\n      break;\n    }\n    case 's': {\n      /*\n      **    start of TTTTT\n      **\n      ** Move the date backwards to the beginning of the current day,\n      ** or month or year.\n      */\n      if( strncmp(z, \"start of \", 9)!=0 ) break;\n      z += 9;\n      computeYMD(p);\n      p->validHMS = 1;\n      p->h = p->m = 0;\n      p->s = 0.0;\n      p->validTZ = 0;\n      p->validJD = 0;\n      if( strcmp(z,\"month\")==0 ){\n        p->D = 1;\n        rc = 0;\n      }else if( strcmp(z,\"year\")==0 ){\n        computeYMD(p);\n        p->M = 1;\n        p->D = 1;\n        rc = 0;\n      }else if( strcmp(z,\"day\")==0 ){\n        rc = 0;\n      }\n      break;\n    }\n    case '+':\n    case '-':\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9': {\n      double rRounder;\n      for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){}\n      if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){\n        rc = 1;\n        break;\n      }\n      if( z[n]==':' ){\n        /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the\n        ** specified number of hours, minutes, seconds, and fractional seconds\n        ** to the time.  The \".FFF\" may be omitted.  The \":SS.FFF\" may be\n        ** omitted.\n        */\n        const char *z2 = z;\n        DateTime tx;\n        sqlite3_int64 day;\n        if( !sqlite3Isdigit(*z2) ) z2++;\n        memset(&tx, 0, sizeof(tx));\n        if( parseHhMmSs(z2, &tx) ) break;\n        computeJD(&tx);\n        tx.iJD -= 43200000;\n        day = tx.iJD/86400000;\n        tx.iJD -= day*86400000;\n        if( z[0]=='-' ) tx.iJD = -tx.iJD;\n        computeJD(p);\n        clearYMD_HMS_TZ(p);\n        p->iJD += tx.iJD;\n        rc = 0;\n        break;\n      }\n      z += n;\n      while( sqlite3Isspace(*z) ) z++;\n      n = sqlite3Strlen30(z);\n      if( n>10 || n<3 ) break;\n      if( z[n-1]=='s' ){ z[n-1] = 0; n--; }\n      computeJD(p);\n      rc = 0;\n      rRounder = r<0 ? -0.5 : +0.5;\n      if( n==3 && strcmp(z,\"day\")==0 ){\n        p->iJD += (sqlite3_int64)(r*86400000.0 + rRounder);\n      }else if( n==4 && strcmp(z,\"hour\")==0 ){\n        p->iJD += (sqlite3_int64)(r*(86400000.0/24.0) + rRounder);\n      }else if( n==6 && strcmp(z,\"minute\")==0 ){\n        p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0)) + rRounder);\n      }else if( n==6 && strcmp(z,\"second\")==0 ){\n        p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0*60.0)) + rRounder);\n      }else if( n==5 && strcmp(z,\"month\")==0 ){\n        int x, y;\n        computeYMD_HMS(p);\n        p->M += (int)r;\n        x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;\n        p->Y += x;\n        p->M -= x*12;\n        p->validJD = 0;\n        computeJD(p);\n        y = (int)r;\n        if( y!=r ){\n          p->iJD += (sqlite3_int64)((r - y)*30.0*86400000.0 + rRounder);\n        }\n      }else if( n==4 && strcmp(z,\"year\")==0 ){\n        int y = (int)r;\n        computeYMD_HMS(p);\n        p->Y += y;\n        p->validJD = 0;\n        computeJD(p);\n        if( y!=r ){\n          p->iJD += (sqlite3_int64)((r - y)*365.0*86400000.0 + rRounder);\n        }\n      }else{\n        rc = 1;\n      }\n      clearYMD_HMS_TZ(p);\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n  return rc;\n}\n\n/*\n** Process time function arguments.  argv[0] is a date-time stamp.\n** argv[1] and following are modifiers.  Parse them all and write\n** the resulting time into the DateTime structure p.  Return 0\n** on success and 1 if there are any errors.\n**\n** If there are zero parameters (if even argv[0] is undefined)\n** then assume a default value of \"now\" for argv[0].\n*/\nstatic int isDate(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv, \n  DateTime *p\n){\n  int i;\n  const unsigned char *z;\n  int eType;\n  memset(p, 0, sizeof(*p));\n  if( argc==0 ){\n    return setDateTimeToCurrent(context, p);\n  }\n  if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT\n                   || eType==SQLITE_INTEGER ){\n    p->iJD = (sqlite3_int64)(sqlite3_value_double(argv[0])*86400000.0 + 0.5);\n    p->validJD = 1;\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( !z || parseDateOrTime(context, (char*)z, p) ){\n      return 1;\n    }\n  }\n  for(i=1; i<argc; i++){\n    z = sqlite3_value_text(argv[i]);\n    if( z==0 || parseModifier(context, (char*)z, p) ) return 1;\n  }\n  return 0;\n}\n\n\n/*\n** The following routines implement the various date and time functions\n** of SQLite.\n*/\n\n/*\n**    julianday( TIMESTRING, MOD, MOD, ...)\n**\n** Return the julian day number of the date specified in the arguments\n*/\nstatic void juliandayFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    computeJD(&x);\n    sqlite3_result_double(context, x.iJD/86400000.0);\n  }\n}\n\n/*\n**    datetime( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD HH:MM:SS\n*/\nstatic void datetimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD_HMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d %02d:%02d:%02d\",\n                     x.Y, x.M, x.D, x.h, x.m, (int)(x.s));\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    time( TIMESTRING, MOD, MOD, ...)\n**\n** Return HH:MM:SS\n*/\nstatic void timeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeHMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%02d:%02d:%02d\", x.h, x.m, (int)x.s);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    date( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD\n*/\nstatic void dateFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d\", x.Y, x.M, x.D);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    strftime( FORMAT, TIMESTRING, MOD, MOD, ...)\n**\n** Return a string described by FORMAT.  Conversions as follows:\n**\n**   %d  day of month\n**   %f  ** fractional seconds  SS.SSS\n**   %H  hour 00-24\n**   %j  day of year 000-366\n**   %J  ** Julian day number\n**   %m  month 01-12\n**   %M  minute 00-59\n**   %s  seconds since 1970-01-01\n**   %S  seconds 00-59\n**   %w  day of week 0-6  sunday==0\n**   %W  week of year 00-53\n**   %Y  year 0000-9999\n**   %%  %\n*/\nstatic void strftimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  u64 n;\n  size_t i,j;\n  char *z;\n  sqlite3 *db;\n  const char *zFmt = (const char*)sqlite3_value_text(argv[0]);\n  char zBuf[100];\n  if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;\n  db = sqlite3_context_db_handle(context);\n  for(i=0, n=1; zFmt[i]; i++, n++){\n    if( zFmt[i]=='%' ){\n      switch( zFmt[i+1] ){\n        case 'd':\n        case 'H':\n        case 'm':\n        case 'M':\n        case 'S':\n        case 'W':\n          n++;\n          /* fall thru */\n        case 'w':\n        case '%':\n          break;\n        case 'f':\n          n += 8;\n          break;\n        case 'j':\n          n += 3;\n          break;\n        case 'Y':\n          n += 8;\n          break;\n        case 's':\n        case 'J':\n          n += 50;\n          break;\n        default:\n          return;  /* ERROR.  return a NULL */\n      }\n      i++;\n    }\n  }\n  testcase( n==sizeof(zBuf)-1 );\n  testcase( n==sizeof(zBuf) );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] );\n  if( n<sizeof(zBuf) ){\n    z = zBuf;\n  }else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    return;\n  }else{\n    z = sqlite3DbMallocRaw(db, (int)n);\n    if( z==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }\n  computeJD(&x);\n  computeYMD_HMS(&x);\n  for(i=j=0; zFmt[i]; i++){\n    if( zFmt[i]!='%' ){\n      z[j++] = zFmt[i];\n    }else{\n      i++;\n      switch( zFmt[i] ){\n        case 'd':  sqlite3_snprintf(3, &z[j],\"%02d\",x.D); j+=2; break;\n        case 'f': {\n          double s = x.s;\n          if( s>59.999 ) s = 59.999;\n          sqlite3_snprintf(7, &z[j],\"%06.3f\", s);\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'H':  sqlite3_snprintf(3, &z[j],\"%02d\",x.h); j+=2; break;\n        case 'W': /* Fall thru */\n        case 'j': {\n          int nDay;             /* Number of days since 1st day of year */\n          DateTime y = x;\n          y.validJD = 0;\n          y.M = 1;\n          y.D = 1;\n          computeJD(&y);\n          nDay = (int)((x.iJD-y.iJD+43200000)/86400000);\n          if( zFmt[i]=='W' ){\n            int wd;   /* 0=Monday, 1=Tuesday, ... 6=Sunday */\n            wd = (int)(((x.iJD+43200000)/86400000)%7);\n            sqlite3_snprintf(3, &z[j],\"%02d\",(nDay+7-wd)/7);\n            j += 2;\n          }else{\n            sqlite3_snprintf(4, &z[j],\"%03d\",nDay+1);\n            j += 3;\n          }\n          break;\n        }\n        case 'J': {\n          sqlite3_snprintf(20, &z[j],\"%.16g\",x.iJD/86400000.0);\n          j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'm':  sqlite3_snprintf(3, &z[j],\"%02d\",x.M); j+=2; break;\n        case 'M':  sqlite3_snprintf(3, &z[j],\"%02d\",x.m); j+=2; break;\n        case 's': {\n          sqlite3_snprintf(30,&z[j],\"%lld\",\n                           (i64)(x.iJD/1000 - 21086676*(i64)10000));\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'S':  sqlite3_snprintf(3,&z[j],\"%02d\",(int)x.s); j+=2; break;\n        case 'w': {\n          z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';\n          break;\n        }\n        case 'Y': {\n          sqlite3_snprintf(5,&z[j],\"%04d\",x.Y); j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        default:   z[j++] = '%'; break;\n      }\n    }\n  }\n  z[j] = 0;\n  sqlite3_result_text(context, z, -1,\n                      z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);\n}\n\n/*\n** current_time()\n**\n** This function returns the same value as time('now').\n*/\nstatic void ctimeFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  timeFunc(context, 0, 0);\n}\n\n/*\n** current_date()\n**\n** This function returns the same value as date('now').\n*/\nstatic void cdateFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  dateFunc(context, 0, 0);\n}\n\n/*\n** current_timestamp()\n**\n** This function returns the same value as datetime('now').\n*/\nstatic void ctimestampFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  datetimeFunc(context, 0, 0);\n}\n#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */\n\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n/*\n** If the library is compiled to omit the full-scale date and time\n** handling (to get a smaller binary), the following minimal version\n** of the functions current_time(), current_date() and current_timestamp()\n** are included instead. This is to support column declarations that\n** include \"DEFAULT CURRENT_TIME\" etc.\n**\n** This function uses the C-library functions time(), gmtime()\n** and strftime(). The format string to pass to strftime() is supplied\n** as the user-data for the function.\n*/\nstatic void currentTimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  time_t t;\n  char *zFormat = (char *)sqlite3_user_data(context);\n  sqlite3 *db;\n  sqlite3_int64 iT;\n  struct tm *pTm;\n  struct tm sNow;\n  char zBuf[20];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  db = sqlite3_context_db_handle(context);\n  if( sqlite3OsCurrentTimeInt64(db->pVfs, &iT) ) return;\n  t = iT/1000 - 10000*(sqlite3_int64)21086676;\n#ifdef HAVE_GMTIME_R\n  pTm = gmtime_r(&t, &sNow);\n#else\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  pTm = gmtime(&t);\n  if( pTm ) memcpy(&sNow, pTm, sizeof(sNow));\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n#endif\n  if( pTm ){\n    strftime(zBuf, 20, zFormat, &sNow);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n#endif\n\n/*\n** This function registered all of the above C functions as SQL\n** functions.  This should be the only routine in this file with\n** external linkage.\n*/\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){\n  static SQLITE_WSD FuncDef aDateTimeFuncs[] = {\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n    FUNCTION(julianday,        -1, 0, 0, juliandayFunc ),\n    FUNCTION(date,             -1, 0, 0, dateFunc      ),\n    FUNCTION(time,             -1, 0, 0, timeFunc      ),\n    FUNCTION(datetime,         -1, 0, 0, datetimeFunc  ),\n    FUNCTION(strftime,         -1, 0, 0, strftimeFunc  ),\n    FUNCTION(current_time,      0, 0, 0, ctimeFunc     ),\n    FUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),\n    FUNCTION(current_date,      0, 0, 0, cdateFunc     ),\n#else\n    STR_FUNCTION(current_time,      0, \"%H:%M:%S\",          0, currentTimeFunc),\n    STR_FUNCTION(current_date,      0, \"%Y-%m-%d\",          0, currentTimeFunc),\n    STR_FUNCTION(current_timestamp, 0, \"%Y-%m-%d %H:%M:%S\", 0, currentTimeFunc),\n#endif\n  };\n  int i;\n  FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);\n  FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aDateTimeFuncs);\n\n  for(i=0; i<ArraySize(aDateTimeFuncs); i++){\n    sqlite3FuncDefInsert(pHash, &aFunc[i]);\n  }\n}\n\n/************** End of date.c ************************************************/\n/************** Begin file os.c **********************************************/\n/*\n** 2005 November 29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains OS interface code that is common to all\n** architectures.\n*/\n#define _SQLITE_OS_C_ 1\n#undef _SQLITE_OS_C_\n\n/*\n** The default SQLite sqlite3_vfs implementations do not allocate\n** memory (actually, os_unix.c allocates a small amount of memory\n** from within OsOpen()), but some third-party implementations may.\n** So we test the effects of a malloc() failing and the sqlite3OsXXX()\n** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.\n**\n** The following functions are instrumented for malloc() failure \n** testing:\n**\n**     sqlite3OsRead()\n**     sqlite3OsWrite()\n**     sqlite3OsSync()\n**     sqlite3OsFileSize()\n**     sqlite3OsLock()\n**     sqlite3OsCheckReservedLock()\n**     sqlite3OsFileControl()\n**     sqlite3OsShmMap()\n**     sqlite3OsOpen()\n**     sqlite3OsDelete()\n**     sqlite3OsAccess()\n**     sqlite3OsFullPathname()\n**\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_memdebug_vfs_oom_test = 1;\n  #define DO_OS_MALLOC_TEST(x)                                       \\\n  if (sqlite3_memdebug_vfs_oom_test && (!x || !sqlite3IsMemJournal(x))) {  \\\n    void *pTstAlloc = sqlite3Malloc(10);                             \\\n    if (!pTstAlloc) return SQLITE_IOERR_NOMEM;                       \\\n    sqlite3_free(pTstAlloc);                                         \\\n  }\n#else\n  #define DO_OS_MALLOC_TEST(x)\n#endif\n\n/*\n** The following routines are convenience wrappers around methods\n** of the sqlite3_file object.  This is mostly just syntactic sugar. All\n** of this would be completely automatic if SQLite were coded using\n** C++ instead of plain old C.\n*/\nSQLITE_PRIVATE int sqlite3OsClose(sqlite3_file *pId){\n  int rc = SQLITE_OK;\n  if( pId->pMethods ){\n    rc = pId->pMethods->xClose(pId);\n    pId->pMethods = 0;\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xRead(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xWrite(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file *id, i64 size){\n  return id->pMethods->xTruncate(id, size);\n}\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file *id, int flags){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xSync(id, flags);\n}\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFileSize(id, pSize);\n}\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file *id, int lockType){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xLock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file *id, int lockType){\n  return id->pMethods->xUnlock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xCheckReservedLock(id, pResOut);\n}\n\n/*\n** Use sqlite3OsFileControl() when we are doing something that might fail\n** and we need to know about the failures.  Use sqlite3OsFileControlHint()\n** when simply tossing information over the wall to the VFS and we do not\n** really care if the VFS receives and understands the information since it\n** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()\n** routine has no return value since the return value would be meaningless.\n*/\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFileControl(id, op, pArg);\n}\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){\n  (void)id->pMethods->xFileControl(id, op, pArg);\n}\n\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){\n  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;\n  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);\n}\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){\n  return id->pMethods->xDeviceCharacteristics(id);\n}\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int offset, int n, int flags){\n  return id->pMethods->xShmLock(id, offset, n, flags);\n}\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id){\n  id->pMethods->xShmBarrier(id);\n}\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){\n  return id->pMethods->xShmUnmap(id, deleteFlag);\n}\nSQLITE_PRIVATE int sqlite3OsShmMap(\n  sqlite3_file *id,               /* Database file handle */\n  int iPage,\n  int pgsz,\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Pointer to mapping */\n){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The real implementation of xFetch and xUnfetch */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFetch(id, iOff, iAmt, pp);\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return id->pMethods->xUnfetch(id, iOff, p);\n}\n#else\n/* No-op stubs to use when memory-mapped I/O is disabled */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  *pp = 0;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The next group of routines are convenience wrappers around the\n** VFS methods.\n*/\nSQLITE_PRIVATE int sqlite3OsOpen(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  sqlite3_file *pFile, \n  int flags, \n  int *pFlagsOut\n){\n  int rc;\n  DO_OS_MALLOC_TEST(0);\n  /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed\n  ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,\n  ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before\n  ** reaching the VFS. */\n  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);\n  assert( rc==SQLITE_OK || pFile->pMethods==0 );\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  DO_OS_MALLOC_TEST(0);\n  assert( dirSync==0 || dirSync==1 );\n  return pVfs->xDelete(pVfs, zPath, dirSync);\n}\nSQLITE_PRIVATE int sqlite3OsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  DO_OS_MALLOC_TEST(0);\n  return pVfs->xAccess(pVfs, zPath, flags, pResOut);\n}\nSQLITE_PRIVATE int sqlite3OsFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nPathOut, \n  char *zPathOut\n){\n  DO_OS_MALLOC_TEST(0);\n  zPathOut[0] = 0;\n  return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n}\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  pVfs->xDlError(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHdle, const char *zSym))(void){\n  return pVfs->xDlSym(pVfs, pHdle, zSym);\n}\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  pVfs->xDlClose(pVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){\n  return pVfs->xSleep(pVfs, nMicro);\n}\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  int rc;\n  /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()\n  ** method to get the current date and time if that method is available\n  ** (if iVersion is 2 or greater and the function pointer is not NULL) and\n  ** will fall back to xCurrentTime() if xCurrentTimeInt64() is\n  ** unavailable.\n  */\n  if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){\n    rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut);\n  }else{\n    double r;\n    rc = pVfs->xCurrentTime(pVfs, &r);\n    *pTimeOut = (sqlite3_int64)(r*86400000.0);\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(\n  sqlite3_vfs *pVfs, \n  const char *zFile, \n  sqlite3_file **ppFile, \n  int flags,\n  int *pOutFlags\n){\n  int rc = SQLITE_NOMEM;\n  sqlite3_file *pFile;\n  pFile = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile);\n  if( pFile ){\n    rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags);\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(pFile);\n    }else{\n      *ppFile = pFile;\n    }\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *pFile){\n  int rc = SQLITE_OK;\n  assert( pFile );\n  rc = sqlite3OsClose(pFile);\n  sqlite3_free(pFile);\n  return rc;\n}\n\n/*\n** This function is a wrapper around the OS specific implementation of\n** sqlite3_os_init(). The purpose of the wrapper is to provide the\n** ability to simulate a malloc failure, so that the handling of an\n** error in sqlite3_os_init() by the upper layers can be tested.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void){\n  void *p = sqlite3_malloc(10);\n  if( p==0 ) return SQLITE_NOMEM;\n  sqlite3_free(p);\n  return sqlite3_os_init();\n}\n\n/*\n** The list of all registered VFS implementations.\n*/\nstatic sqlite3_vfs * SQLITE_WSD vfsList = 0;\n#define vfsList GLOBAL(sqlite3_vfs *, vfsList)\n\n/*\n** Locate a VFS by name.  If no name is given, simply return the\n** first VFS on the list.\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){\n  sqlite3_vfs *pVfs = 0;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return 0;\n#endif\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){\n    if( zVfs==0 ) break;\n    if( strcmp(zVfs, pVfs->zName)==0 ) break;\n  }\n  sqlite3_mutex_leave(mutex);\n  return pVfs;\n}\n\n/*\n** Unlink a VFS from the linked list\n*/\nstatic void vfsUnlink(sqlite3_vfs *pVfs){\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) );\n  if( pVfs==0 ){\n    /* No-op */\n  }else if( vfsList==pVfs ){\n    vfsList = pVfs->pNext;\n  }else if( vfsList ){\n    sqlite3_vfs *p = vfsList;\n    while( p->pNext && p->pNext!=pVfs ){\n      p = p->pNext;\n    }\n    if( p->pNext==pVfs ){\n      p->pNext = pVfs->pNext;\n    }\n  }\n}\n\n/*\n** Register a VFS with the system.  It is harmless to register the same\n** VFS multiple times.  The new VFS becomes the default if makeDflt is\n** true.\n*/\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){\n  MUTEX_LOGIC(sqlite3_mutex *mutex;)\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  if( makeDflt || vfsList==0 ){\n    pVfs->pNext = vfsList;\n    vfsList = pVfs;\n  }else{\n    pVfs->pNext = vfsList->pNext;\n    vfsList->pNext = pVfs;\n  }\n  assert(vfsList);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Unregister a VFS so that it is no longer accessible.\n*/\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/************** End of os.c **************************************************/\n/************** Begin file fault.c *******************************************/\n/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to support the concept of \"benign\" \n** malloc failures (when the xMalloc() or xRealloc() method of the\n** sqlite3_mem_methods structure fails to allocate a block of memory\n** and returns 0). \n**\n** Most malloc failures are non-benign. After they occur, SQLite\n** abandons the current operation and returns an error code (usually\n** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily\n** fatal. For example, if a malloc fails while resizing a hash table, this \n** is completely recoverable simply by not carrying out the resize. The \n** hash table will continue to function normally.  So a malloc failure \n** during a hash table resize is a benign fault.\n*/\n\n\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n\n/*\n** Global variables.\n*/\ntypedef struct BenignMallocHooks BenignMallocHooks;\nstatic SQLITE_WSD struct BenignMallocHooks {\n  void (*xBenignBegin)(void);\n  void (*xBenignEnd)(void);\n} sqlite3Hooks = { 0, 0 };\n\n/* The \"wsdHooks\" macro will resolve to the appropriate BenignMallocHooks\n** structure.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdHooks can refer directly\n** to the \"sqlite3Hooks\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdHooksInit \\\n  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)\n# define wsdHooks x[0]\n#else\n# define wsdHooksInit\n# define wsdHooks sqlite3Hooks\n#endif\n\n\n/*\n** Register hooks to call when sqlite3BeginBenignMalloc() and\n** sqlite3EndBenignMalloc() are called, respectively.\n*/\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(\n  void (*xBenignBegin)(void),\n  void (*xBenignEnd)(void)\n){\n  wsdHooksInit;\n  wsdHooks.xBenignBegin = xBenignBegin;\n  wsdHooks.xBenignEnd = xBenignEnd;\n}\n\n/*\n** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that\n** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()\n** indicates that subsequent malloc failures are non-benign.\n*/\nSQLITE_PRIVATE void sqlite3BeginBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignBegin ){\n    wsdHooks.xBenignBegin();\n  }\n}\nSQLITE_PRIVATE void sqlite3EndBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignEnd ){\n    wsdHooks.xBenignEnd();\n  }\n}\n\n#endif   /* #ifndef SQLITE_OMIT_BUILTIN_TEST */\n\n/************** End of fault.c ***********************************************/\n/************** Begin file mem0.c ********************************************/\n/*\n** 2008 October 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a no-op memory allocation drivers for use when\n** SQLITE_ZERO_MALLOC is defined.  The allocation drivers implemented\n** here always fail.  SQLite will not operate with these drivers.  These\n** are merely placeholders.  Real drivers must be substituted using\n** sqlite3_config() before SQLite will operate.\n*/\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_ZERO_MALLOC\n\n/*\n** No-op versions of all memory allocation routines\n*/\nstatic void *sqlite3MemMalloc(int nByte){ return 0; }\nstatic void sqlite3MemFree(void *pPrior){ return; }\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){ return 0; }\nstatic int sqlite3MemSize(void *pPrior){ return 0; }\nstatic int sqlite3MemRoundup(int n){ return n; }\nstatic int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }\nstatic void sqlite3MemShutdown(void *NotUsed){ return; }\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_ZERO_MALLOC */\n\n/************** End of mem0.c ************************************************/\n/************** Begin file mem1.c ********************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.  The content of\n** this file is only used if SQLITE_SYSTEM_MALLOC is defined.  The\n** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the\n** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined.  The\n** default configuration is to use memory allocation routines in this\n** file.\n**\n** C-preprocessor macro summary:\n**\n**    HAVE_MALLOC_USABLE_SIZE     The configure script sets this symbol if\n**                                the malloc_usable_size() interface exists\n**                                on the target platform.  Or, this symbol\n**                                can be set manually, if desired.\n**                                If an equivalent interface exists by\n**                                a different name, using a separate -D\n**                                option to rename it.\n**\n**    SQLITE_WITHOUT_ZONEMALLOC   Some older macs lack support for the zone\n**                                memory allocator.  Set this symbol to enable\n**                                building on older macs.\n**\n**    SQLITE_WITHOUT_MSIZE        Set this symbol to disable the use of\n**                                _msize() on windows systems.  This might\n**                                be necessary when compiling for Delphi,\n**                                for example.\n*/\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_SYSTEM_MALLOC\n\n/*\n** The MSVCRT has malloc_usable_size() but it is called _msize().\n** The use of _msize() is automatic, but can be disabled by compiling\n** with -DSQLITE_WITHOUT_MSIZE\n*/\n#if defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)\n# define SQLITE_MALLOCSIZE _msize\n#endif\n\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n\n/*\n** Use the zone allocator available on apple products unless the\n** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.\n*/\n#include <sys/sysctl.h>\n#include <malloc/malloc.h>\n#include <libkern/OSAtomic.h>\nstatic malloc_zone_t* _sqliteZone_;\n#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))\n#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));\n#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))\n#define SQLITE_MALLOCSIZE(x) \\\n        (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))\n\n#else /* if not __APPLE__ */\n\n/*\n** Use standard C library malloc and free on non-Apple systems.  \n** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.\n*/\n#define SQLITE_MALLOC(x)    malloc(x)\n#define SQLITE_FREE(x)      free(x)\n#define SQLITE_REALLOC(x,y) realloc((x),(y))\n\n#if (defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)) \\\n      || (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))\n# include <malloc.h>    /* Needed for malloc_usable_size on linux */\n#endif\n#ifdef HAVE_MALLOC_USABLE_SIZE\n# ifndef SQLITE_MALLOCSIZE\n#  define SQLITE_MALLOCSIZE(x) malloc_usable_size(x)\n# endif\n#else\n# undef SQLITE_MALLOCSIZE\n#endif\n\n#endif /* __APPLE__ or not __APPLE__ */\n\n/*\n** Like malloc(), but remember the size of the allocation\n** so that we can find it later using sqlite3MemSize().\n**\n** For this low-level routine, we are guaranteed that nByte>0 because\n** cases of nByte<=0 will be intercepted and dealt with by higher level\n** routines.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p = SQLITE_MALLOC( nByte );\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p;\n  assert( nByte>0 );\n  nByte = ROUND8(nByte);\n  p = SQLITE_MALLOC( nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return (void *)p;\n#endif\n}\n\n/*\n** Like free() but works for allocations obtained from sqlite3MemMalloc()\n** or sqlite3MemRealloc().\n**\n** For this low-level routine, we already know that pPrior!=0 since\n** cases where pPrior==0 will have been intecepted and dealt with\n** by higher-level routines.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  SQLITE_FREE(pPrior);\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 );\n  p--;\n  SQLITE_FREE(p);\n#endif\n}\n\n/*\n** Report the allocated size of a prior return from xMalloc()\n** or xRealloc().\n*/\nstatic int sqlite3MemSize(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  return pPrior ? (int)SQLITE_MALLOCSIZE(pPrior) : 0;\n#else\n  sqlite3_int64 *p;\n  if( pPrior==0 ) return 0;\n  p = (sqlite3_int64*)pPrior;\n  p--;\n  return (int)p[0];\n#endif\n}\n\n/*\n** Like realloc().  Resize an allocation previously obtained from\n** sqlite3MemMalloc().\n**\n** For this low-level interface, we know that pPrior!=0.  Cases where\n** pPrior==0 while have been intercepted by higher-level routine and\n** redirected to xMalloc.  Similarly, we know that nByte>0 becauses\n** cases where nByte<=0 will have been intercepted by higher-level\n** routines and redirected to xFree.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p = SQLITE_REALLOC(pPrior, nByte);\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      SQLITE_MALLOCSIZE(pPrior), nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 && nByte>0 );\n  assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */\n  p--;\n  p = SQLITE_REALLOC(p, nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      sqlite3MemSize(pPrior), nByte);\n  }\n  return (void*)p;\n#endif\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Initialize this module.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n  int cpuCount;\n  size_t len;\n  if( _sqliteZone_ ){\n    return SQLITE_OK;\n  }\n  len = sizeof(cpuCount);\n  /* One usually wants to use hw.acctivecpu for MT decisions, but not here */\n  sysctlbyname(\"hw.ncpu\", &cpuCount, &len, NULL, 0);\n  if( cpuCount>1 ){\n    /* defer MT decisions to system malloc */\n    _sqliteZone_ = malloc_default_zone();\n  }else{\n    /* only 1 core, use our own zone to contention over global locks, \n    ** e.g. we have our own dedicated locks */\n    bool success;\n    malloc_zone_t* newzone = malloc_create_zone(4096, 0);\n    malloc_set_zone_name(newzone, \"Sqlite_Heap\");\n    do{\n      success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, \n                                 (void * volatile *)&_sqliteZone_);\n    }while(!_sqliteZone_);\n    if( !success ){\n      /* somebody registered a zone first */\n      malloc_destroy_zone(newzone);\n    }\n  }\n#endif\n  UNUSED_PARAMETER(NotUsed);\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  return;\n}\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_SYSTEM_MALLOC */\n\n/************** End of mem1.c ************************************************/\n/************** Begin file mem2.c ********************************************/\n/*\n** 2007 August 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs while adding lots of additional debugging\n** information to each allocation in order to help detect and fix memory\n** leaks and memory usage errors.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.\n*/\n\n/*\n** This version of the memory allocator is used only if the\n** SQLITE_MEMDEBUG macro is defined\n*/\n#ifdef SQLITE_MEMDEBUG\n\n/*\n** The backtrace functionality is only available with GLIBC\n*/\n#ifdef __GLIBC__\n  extern int backtrace(void**,int);\n  extern void backtrace_symbols_fd(void*const*,int,int);\n#else\n# define backtrace(A,B) 1\n# define backtrace_symbols_fd(A,B,C)\n#endif\n/* #include <stdio.h> */\n\n/*\n** Each memory allocation looks like this:\n**\n**  ------------------------------------------------------------------------\n**  | Title |  backtrace pointers |  MemBlockHdr |  allocation |  EndGuard |\n**  ------------------------------------------------------------------------\n**\n** The application code sees only a pointer to the allocation.  We have\n** to back up from the allocation pointer to find the MemBlockHdr.  The\n** MemBlockHdr tells us the size of the allocation and the number of\n** backtrace pointers.  There is also a guard word at the end of the\n** MemBlockHdr.\n*/\nstruct MemBlockHdr {\n  i64 iSize;                          /* Size of this allocation */\n  struct MemBlockHdr *pNext, *pPrev;  /* Linked list of all unfreed memory */\n  char nBacktrace;                    /* Number of backtraces on this alloc */\n  char nBacktraceSlots;               /* Available backtrace slots */\n  u8 nTitle;                          /* Bytes of title; includes '\\0' */\n  u8 eType;                           /* Allocation type code */\n  int iForeGuard;                     /* Guard word for sanity */\n};\n\n/*\n** Guard words\n*/\n#define FOREGUARD 0x80F5E153\n#define REARGUARD 0xE4676B53\n\n/*\n** Number of malloc size increments to track.\n*/\n#define NCSIZE  1000\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic struct {\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n  /*\n  ** Head and tail of a linked list of all outstanding allocations\n  */\n  struct MemBlockHdr *pFirst;\n  struct MemBlockHdr *pLast;\n  \n  /*\n  ** The number of levels of backtrace to save in new allocations.\n  */\n  int nBacktrace;\n  void (*xBacktrace)(int, int, void **);\n\n  /*\n  ** Title text to insert in front of each block\n  */\n  int nTitle;        /* Bytes of zTitle to save.  Includes '\\0' and padding */\n  char zTitle[100];  /* The title text */\n\n  /* \n  ** sqlite3MallocDisallow() increments the following counter.\n  ** sqlite3MallocAllow() decrements it.\n  */\n  int disallow; /* Do not allow memory allocation */\n\n  /*\n  ** Gather statistics on the sizes of memory allocations.\n  ** nAlloc[i] is the number of allocation attempts of i*8\n  ** bytes.  i==NCSIZE is the number of allocation attempts for\n  ** sizes more than NCSIZE*8 bytes.\n  */\n  int nAlloc[NCSIZE];      /* Total number of allocations */\n  int nCurrent[NCSIZE];    /* Current number of allocations */\n  int mxCurrent[NCSIZE];   /* Highwater mark for nCurrent */\n\n} mem;\n\n\n/*\n** Adjust memory usage statistics\n*/\nstatic void adjustStats(int iSize, int increment){\n  int i = ROUND8(iSize)/8;\n  if( i>NCSIZE-1 ){\n    i = NCSIZE - 1;\n  }\n  if( increment>0 ){\n    mem.nAlloc[i]++;\n    mem.nCurrent[i]++;\n    if( mem.nCurrent[i]>mem.mxCurrent[i] ){\n      mem.mxCurrent[i] = mem.nCurrent[i];\n    }\n  }else{\n    mem.nCurrent[i]--;\n    assert( mem.nCurrent[i]>=0 );\n  }\n}\n\n/*\n** Given an allocation, find the MemBlockHdr for that allocation.\n**\n** This routine checks the guards at either end of the allocation and\n** if they are incorrect it asserts.\n*/\nstatic struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){\n  struct MemBlockHdr *p;\n  int *pInt;\n  u8 *pU8;\n  int nReserve;\n\n  p = (struct MemBlockHdr*)pAllocation;\n  p--;\n  assert( p->iForeGuard==(int)FOREGUARD );\n  nReserve = ROUND8(p->iSize);\n  pInt = (int*)pAllocation;\n  pU8 = (u8*)pAllocation;\n  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );\n  /* This checks any of the \"extra\" bytes allocated due\n  ** to rounding up to an 8 byte boundary to ensure \n  ** they haven't been overwritten.\n  */\n  while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );\n  return p;\n}\n\n/*\n** Return the number of bytes currently allocated at address p.\n*/\nstatic int sqlite3MemSize(void *p){\n  struct MemBlockHdr *pHdr;\n  if( !p ){\n    return 0;\n  }\n  pHdr = sqlite3MemsysGetHeader(p);\n  return pHdr->iSize;\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( (sizeof(struct MemBlockHdr)&7) == 0 );\n  if( !sqlite3GlobalConfig.bMemstat ){\n    /* If memory status is enabled, then the malloc.c wrapper will already\n    ** hold the STATIC_MEM mutex when the routines here are invoked. */\n    mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem.mutex = 0;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Fill a buffer with pseudo-random bytes.  This is used to preset\n** the content of a new memory allocation to unpredictable values and\n** to clear the content of a freed allocation to unpredictable values.\n*/\nstatic void randomFill(char *pBuf, int nByte){\n  unsigned int x, y, r;\n  x = SQLITE_PTR_TO_INT(pBuf);\n  y = nByte | 1;\n  while( nByte >= 4 ){\n    x = (x>>1) ^ (-(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(int*)pBuf = r;\n    pBuf += 4;\n    nByte -= 4;\n  }\n  while( nByte-- > 0 ){\n    x = (x>>1) ^ (-(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(pBuf++) = r & 0xff;\n  }\n}\n\n/*\n** Allocate nByte bytes of memory.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  int *pInt;\n  void *p = 0;\n  int totalSize;\n  int nReserve;\n  sqlite3_mutex_enter(mem.mutex);\n  assert( mem.disallow==0 );\n  nReserve = ROUND8(nByte);\n  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +\n               mem.nBacktrace*sizeof(void*) + mem.nTitle;\n  p = malloc(totalSize);\n  if( p ){\n    z = p;\n    pBt = (void**)&z[mem.nTitle];\n    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];\n    pHdr->pNext = 0;\n    pHdr->pPrev = mem.pLast;\n    if( mem.pLast ){\n      mem.pLast->pNext = pHdr;\n    }else{\n      mem.pFirst = pHdr;\n    }\n    mem.pLast = pHdr;\n    pHdr->iForeGuard = FOREGUARD;\n    pHdr->eType = MEMTYPE_HEAP;\n    pHdr->nBacktraceSlots = mem.nBacktrace;\n    pHdr->nTitle = mem.nTitle;\n    if( mem.nBacktrace ){\n      void *aAddr[40];\n      pHdr->nBacktrace = backtrace(aAddr, mem.nBacktrace+1)-1;\n      memcpy(pBt, &aAddr[1], pHdr->nBacktrace*sizeof(void*));\n      assert(pBt[0]);\n      if( mem.xBacktrace ){\n        mem.xBacktrace(nByte, pHdr->nBacktrace-1, &aAddr[1]);\n      }\n    }else{\n      pHdr->nBacktrace = 0;\n    }\n    if( mem.nTitle ){\n      memcpy(z, mem.zTitle, mem.nTitle);\n    }\n    pHdr->iSize = nByte;\n    adjustStats(nByte, +1);\n    pInt = (int*)&pHdr[1];\n    pInt[nReserve/sizeof(int)] = REARGUARD;\n    randomFill((char*)pInt, nByte);\n    memset(((char*)pInt)+nByte, 0x65, nReserve-nByte);\n    p = (void*)pInt;\n  }\n  sqlite3_mutex_leave(mem.mutex);\n  return p; \n}\n\n/*\n** Free memory.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0 \n       || mem.mutex!=0 );\n  pHdr = sqlite3MemsysGetHeader(pPrior);\n  pBt = (void**)pHdr;\n  pBt -= pHdr->nBacktraceSlots;\n  sqlite3_mutex_enter(mem.mutex);\n  if( pHdr->pPrev ){\n    assert( pHdr->pPrev->pNext==pHdr );\n    pHdr->pPrev->pNext = pHdr->pNext;\n  }else{\n    assert( mem.pFirst==pHdr );\n    mem.pFirst = pHdr->pNext;\n  }\n  if( pHdr->pNext ){\n    assert( pHdr->pNext->pPrev==pHdr );\n    pHdr->pNext->pPrev = pHdr->pPrev;\n  }else{\n    assert( mem.pLast==pHdr );\n    mem.pLast = pHdr->pPrev;\n  }\n  z = (char*)pBt;\n  z -= pHdr->nTitle;\n  adjustStats(pHdr->iSize, -1);\n  randomFill(z, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +\n                pHdr->iSize + sizeof(int) + pHdr->nTitle);\n  free(z);\n  sqlite3_mutex_leave(mem.mutex);  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** For this debugging implementation, we *always* make a copy of the\n** allocation into a new place in memory.  In this way, if the \n** higher level code is using pointer to the old allocation, it is \n** much more likely to break and we are much more liking to find\n** the error.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n  struct MemBlockHdr *pOldHdr;\n  void *pNew;\n  assert( mem.disallow==0 );\n  assert( (nByte & 7)==0 );     /* EV: R-46199-30249 */\n  pOldHdr = sqlite3MemsysGetHeader(pPrior);\n  pNew = sqlite3MemMalloc(nByte);\n  if( pNew ){\n    memcpy(pNew, pPrior, nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize);\n    if( nByte>pOldHdr->iSize ){\n      randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - pOldHdr->iSize);\n    }\n    sqlite3MemFree(pPrior);\n  }\n  return pNew;\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n/*\n** Set the \"type\" of an allocation.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );\n    pHdr->eType = eType;\n  }\n}\n\n/*\n** Return TRUE if the mask of type in eType matches the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)==0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if the mask of type in eType matches no bits of the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)!=0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Set the number of backtrace levels kept for each allocation.\n** A value of zero turns off backtracing.  The number is always rounded\n** up to a multiple of 2.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugBacktrace(int depth){\n  if( depth<0 ){ depth = 0; }\n  if( depth>20 ){ depth = 20; }\n  depth = (depth+1)&0xfe;\n  mem.nBacktrace = depth;\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(int, int, void **)){\n  mem.xBacktrace = xBacktrace;\n}\n\n/*\n** Set the title string for subsequent allocations.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){\n  unsigned int n = sqlite3Strlen30(zTitle) + 1;\n  sqlite3_mutex_enter(mem.mutex);\n  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;\n  memcpy(mem.zTitle, zTitle, n);\n  mem.zTitle[n] = 0;\n  mem.nTitle = ROUND8(n);\n  sqlite3_mutex_leave(mem.mutex);\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugSync(){\n  struct MemBlockHdr *pHdr;\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    void **pBt = (void**)pHdr;\n    pBt -= pHdr->nBacktraceSlots;\n    mem.xBacktrace(pHdr->iSize, pHdr->nBacktrace-1, &pBt[1]);\n  }\n}\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugDump(const char *zFilename){\n  FILE *out;\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  int i;\n  out = fopen(zFilename, \"w\");\n  if( out==0 ){\n    fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                    zFilename);\n    return;\n  }\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    char *z = (char*)pHdr;\n    z -= pHdr->nBacktraceSlots*sizeof(void*) + pHdr->nTitle;\n    fprintf(out, \"**** %lld bytes at %p from %s ****\\n\", \n            pHdr->iSize, &pHdr[1], pHdr->nTitle ? z : \"???\");\n    if( pHdr->nBacktrace ){\n      fflush(out);\n      pBt = (void**)pHdr;\n      pBt -= pHdr->nBacktraceSlots;\n      backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out));\n      fprintf(out, \"\\n\");\n    }\n  }\n  fprintf(out, \"COUNTS:\\n\");\n  for(i=0; i<NCSIZE-1; i++){\n    if( mem.nAlloc[i] ){\n      fprintf(out, \"   %5d: %10d %10d %10d\\n\", \n            i*8, mem.nAlloc[i], mem.nCurrent[i], mem.mxCurrent[i]);\n    }\n  }\n  if( mem.nAlloc[NCSIZE-1] ){\n    fprintf(out, \"   %5d: %10d %10d %10d\\n\",\n             NCSIZE*8-8, mem.nAlloc[NCSIZE-1],\n             mem.nCurrent[NCSIZE-1], mem.mxCurrent[NCSIZE-1]);\n  }\n  fclose(out);\n}\n\n/*\n** Return the number of times sqlite3MemMalloc() has been called.\n*/\nSQLITE_PRIVATE int sqlite3MemdebugMallocCount(){\n  int i;\n  int nTotal = 0;\n  for(i=0; i<NCSIZE; i++){\n    nTotal += mem.nAlloc[i];\n  }\n  return nTotal;\n}\n\n\n#endif /* SQLITE_MEMDEBUG */\n\n/************** End of mem2.c ************************************************/\n/************** Begin file mem3.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The SQLite user supplies a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.\n*/\n\n/*\n** This version of the memory allocator is only built into the library\n** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not\n** mean that the library will use a memory-pool by default, just that\n** it is available. The mempool allocator is activated by calling\n** sqlite3_config().\n*/\n#ifdef SQLITE_ENABLE_MEMSYS3\n\n/*\n** Maximum size (in Mem3Blocks) of a \"small\" chunk.\n*/\n#define MX_SMALL 10\n\n\n/*\n** Number of freelist hash slots\n*/\n#define N_HASH  61\n\n/*\n** A memory allocation (also called a \"chunk\") consists of two or \n** more blocks where each block is 8 bytes.  The first 8 bytes are \n** a header that is not returned to the user.\n**\n** A chunk is two or more blocks that is either checked out or\n** free.  The first block has format u.hdr.  u.hdr.size4x is 4 times the\n** size of the allocation in blocks if the allocation is free.\n** The u.hdr.size4x&1 bit is true if the chunk is checked out and\n** false if the chunk is on the freelist.  The u.hdr.size4x&2 bit\n** is true if the previous chunk is checked out and false if the\n** previous chunk is free.  The u.hdr.prevSize field is the size of\n** the previous chunk in blocks if the previous chunk is on the\n** freelist. If the previous chunk is checked out, then\n** u.hdr.prevSize can be part of the data for that chunk and should\n** not be read or written.\n**\n** We often identify a chunk by its index in mem3.aPool[].  When\n** this is done, the chunk index refers to the second block of\n** the chunk.  In this way, the first chunk has an index of 1.\n** A chunk index of 0 means \"no such chunk\" and is the equivalent\n** of a NULL pointer.\n**\n** The second block of free chunks is of the form u.list.  The\n** two fields form a double-linked list of chunks of related sizes.\n** Pointers to the head of the list are stored in mem3.aiSmall[] \n** for smaller chunks and mem3.aiHash[] for larger chunks.\n**\n** The second block of a chunk is user data if the chunk is checked \n** out.  If a chunk is checked out, the user data may extend into\n** the u.hdr.prevSize value of the following chunk.\n*/\ntypedef struct Mem3Block Mem3Block;\nstruct Mem3Block {\n  union {\n    struct {\n      u32 prevSize;   /* Size of previous chunk in Mem3Block elements */\n      u32 size4x;     /* 4x the size of current chunk in Mem3Block elements */\n    } hdr;\n    struct {\n      u32 next;       /* Index in mem3.aPool[] of next free chunk */\n      u32 prev;       /* Index in mem3.aPool[] of previous free chunk */\n    } list;\n  } u;\n};\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem3\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem3Global {\n  /*\n  ** Memory available for allocation. nPool is the size of the array\n  ** (in Mem3Blocks) pointed to by aPool less 2.\n  */\n  u32 nPool;\n  Mem3Block *aPool;\n\n  /*\n  ** True if we are evaluating an out-of-memory callback.\n  */\n  int alarmBusy;\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n  \n  /*\n  ** The minimum amount of free space that we have seen.\n  */\n  u32 mnMaster;\n\n  /*\n  ** iMaster is the index of the master chunk.  Most new allocations\n  ** occur off of this chunk.  szMaster is the size (in Mem3Blocks)\n  ** of the current master.  iMaster is 0 if there is not master chunk.\n  ** The master chunk is not in either the aiHash[] or aiSmall[].\n  */\n  u32 iMaster;\n  u32 szMaster;\n\n  /*\n  ** Array of lists of free blocks according to the block size \n  ** for smaller chunks, or a hash on the block size for larger\n  ** chunks.\n  */\n  u32 aiSmall[MX_SMALL-1];   /* For sizes 2 through MX_SMALL, inclusive */\n  u32 aiHash[N_HASH];        /* For sizes MX_SMALL+1 and larger */\n} mem3 = { 97535575 };\n\n#define mem3 GLOBAL(struct Mem3Global, mem3)\n\n/*\n** Unlink the chunk at mem3.aPool[i] from list it is currently\n** on.  *pRoot is the list that i is a member of.\n*/\nstatic void memsys3UnlinkFromList(u32 i, u32 *pRoot){\n  u32 next = mem3.aPool[i].u.list.next;\n  u32 prev = mem3.aPool[i].u.list.prev;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  if( prev==0 ){\n    *pRoot = next;\n  }else{\n    mem3.aPool[prev].u.list.next = next;\n  }\n  if( next ){\n    mem3.aPool[next].u.list.prev = prev;\n  }\n  mem3.aPool[i].u.list.next = 0;\n  mem3.aPool[i].u.list.prev = 0;\n}\n\n/*\n** Unlink the chunk at index i from \n** whatever list is currently a member of.\n*/\nstatic void memsys3Unlink(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  assert( i>=1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** Link the chunk at mem3.aPool[i] so that is on the list rooted\n** at *pRoot.\n*/\nstatic void memsys3LinkIntoList(u32 i, u32 *pRoot){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  mem3.aPool[i].u.list.next = *pRoot;\n  mem3.aPool[i].u.list.prev = 0;\n  if( *pRoot ){\n    mem3.aPool[*pRoot].u.list.prev = i;\n  }\n  *pRoot = i;\n}\n\n/*\n** Link the chunk at index i into either the appropriate\n** small chunk list, or into the large chunk hash table.\n*/\nstatic void memsys3Link(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3LinkIntoList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** If the STATIC_MEM mutex is not already held, obtain it now. The mutex\n** will already be held (obtained by code in malloc.c) if\n** sqlite3GlobalConfig.bMemStat is true.\n*/\nstatic void memsys3Enter(void){\n  if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){\n    mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  sqlite3_mutex_enter(mem3.mutex);\n}\nstatic void memsys3Leave(void){\n  sqlite3_mutex_leave(mem3.mutex);\n}\n\n/*\n** Called when we are unable to satisfy an allocation of nBytes.\n*/\nstatic void memsys3OutOfMemory(int nByte){\n  if( !mem3.alarmBusy ){\n    mem3.alarmBusy = 1;\n    assert( sqlite3_mutex_held(mem3.mutex) );\n    sqlite3_mutex_leave(mem3.mutex);\n    sqlite3_release_memory(nByte);\n    sqlite3_mutex_enter(mem3.mutex);\n    mem3.alarmBusy = 0;\n  }\n}\n\n\n/*\n** Chunk i is a free chunk that has been unlinked.  Adjust its \n** size parameters for check-out and return a pointer to the \n** user portion of the chunk.\n*/\nstatic void *memsys3Checkout(u32 i, u32 nBlock){\n  u32 x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock );\n  assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock );\n  x = mem3.aPool[i-1].u.hdr.size4x;\n  mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2);\n  mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock;\n  mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2;\n  return &mem3.aPool[i];\n}\n\n/*\n** Carve a piece off of the end of the mem3.iMaster free chunk.\n** Return a pointer to the new allocation.  Or, if the master chunk\n** is not large enough, return 0.\n*/\nstatic void *memsys3FromMaster(u32 nBlock){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( mem3.szMaster>=nBlock );\n  if( nBlock>=mem3.szMaster-1 ){\n    /* Use the entire master */\n    void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster);\n    mem3.iMaster = 0;\n    mem3.szMaster = 0;\n    mem3.mnMaster = 0;\n    return p;\n  }else{\n    /* Split the master block.  Return the tail. */\n    u32 newi, x;\n    newi = mem3.iMaster + mem3.szMaster - nBlock;\n    assert( newi > mem3.iMaster+1 );\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock;\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2;\n    mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1;\n    mem3.szMaster -= nBlock;\n    mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster;\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n    if( mem3.szMaster < mem3.mnMaster ){\n      mem3.mnMaster = mem3.szMaster;\n    }\n    return (void*)&mem3.aPool[newi];\n  }\n}\n\n/*\n** *pRoot is the head of a list of free chunks of the same size\n** or same size hash.  In other words, *pRoot is an entry in either\n** mem3.aiSmall[] or mem3.aiHash[].  \n**\n** This routine examines all entries on the given list and tries\n** to coalesce each entries with adjacent free chunks.  \n**\n** If it sees a chunk that is larger than mem3.iMaster, it replaces \n** the current mem3.iMaster with the new larger chunk.  In order for\n** this mem3.iMaster replacement to work, the master chunk must be\n** linked into the hash tables.  That is not the normal state of\n** affairs, of course.  The calling routine must link the master\n** chunk before invoking this routine, then must unlink the (possibly\n** changed) master chunk once this routine has finished.\n*/\nstatic void memsys3Merge(u32 *pRoot){\n  u32 iNext, prev, size, i, x;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  for(i=*pRoot; i>0; i=iNext){\n    iNext = mem3.aPool[i].u.list.next;\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    assert( (size&1)==0 );\n    if( (size&2)==0 ){\n      memsys3UnlinkFromList(i, pRoot);\n      assert( i > mem3.aPool[i-1].u.hdr.prevSize );\n      prev = i - mem3.aPool[i-1].u.hdr.prevSize;\n      if( prev==iNext ){\n        iNext = mem3.aPool[prev].u.list.next;\n      }\n      memsys3Unlink(prev);\n      size = i + size/4 - prev;\n      x = mem3.aPool[prev-1].u.hdr.size4x & 2;\n      mem3.aPool[prev-1].u.hdr.size4x = size*4 | x;\n      mem3.aPool[prev+size-1].u.hdr.prevSize = size;\n      memsys3Link(prev);\n      i = prev;\n    }else{\n      size /= 4;\n    }\n    if( size>mem3.szMaster ){\n      mem3.iMaster = i;\n      mem3.szMaster = size;\n    }\n  }\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void *memsys3MallocUnsafe(int nByte){\n  u32 i;\n  u32 nBlock;\n  u32 toFree;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( sizeof(Mem3Block)==8 );\n  if( nByte<=12 ){\n    nBlock = 2;\n  }else{\n    nBlock = (nByte + 11)/8;\n  }\n  assert( nBlock>=2 );\n\n  /* STEP 1:\n  ** Look for an entry of the correct size in either the small\n  ** chunk table or in the large chunk hash table.  This is\n  ** successful most of the time (about 9 times out of 10).\n  */\n  if( nBlock <= MX_SMALL ){\n    i = mem3.aiSmall[nBlock-2];\n    if( i>0 ){\n      memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);\n      return memsys3Checkout(i, nBlock);\n    }\n  }else{\n    int hash = nBlock % N_HASH;\n    for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){\n      if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){\n        memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n        return memsys3Checkout(i, nBlock);\n      }\n    }\n  }\n\n  /* STEP 2:\n  ** Try to satisfy the allocation by carving a piece off of the end\n  ** of the master chunk.  This step usually works if step 1 fails.\n  */\n  if( mem3.szMaster>=nBlock ){\n    return memsys3FromMaster(nBlock);\n  }\n\n\n  /* STEP 3:  \n  ** Loop through the entire memory pool.  Coalesce adjacent free\n  ** chunks.  Recompute the master chunk as the largest free chunk.\n  ** Then try again to satisfy the allocation by carving a piece off\n  ** of the end of the master chunk.  This step happens very\n  ** rarely (we hope!)\n  */\n  for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){\n    memsys3OutOfMemory(toFree);\n    if( mem3.iMaster ){\n      memsys3Link(mem3.iMaster);\n      mem3.iMaster = 0;\n      mem3.szMaster = 0;\n    }\n    for(i=0; i<N_HASH; i++){\n      memsys3Merge(&mem3.aiHash[i]);\n    }\n    for(i=0; i<MX_SMALL-1; i++){\n      memsys3Merge(&mem3.aiSmall[i]);\n    }\n    if( mem3.szMaster ){\n      memsys3Unlink(mem3.iMaster);\n      if( mem3.szMaster>=nBlock ){\n        return memsys3FromMaster(nBlock);\n      }\n    }\n  }\n\n  /* If none of the above worked, then we fail. */\n  return 0;\n}\n\n/*\n** Free an outstanding memory allocation.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void memsys3FreeUnsafe(void *pOld){\n  Mem3Block *p = (Mem3Block*)pOld;\n  int i;\n  u32 size, x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] );\n  i = p - mem3.aPool;\n  assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( i+size<=mem3.nPool+1 );\n  mem3.aPool[i-1].u.hdr.size4x &= ~1;\n  mem3.aPool[i+size-1].u.hdr.prevSize = size;\n  mem3.aPool[i+size-1].u.hdr.size4x &= ~2;\n  memsys3Link(i);\n\n  /* Try to expand the master using the newly freed chunk */\n  if( mem3.iMaster ){\n    while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){\n      size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize;\n      mem3.iMaster -= size;\n      mem3.szMaster += size;\n      memsys3Unlink(mem3.iMaster);\n      x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){\n      memsys3Unlink(mem3.iMaster+mem3.szMaster);\n      mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n  }\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.  The\n** size returned omits the 8-byte header overhead.  This only\n** works for chunks that are currently checked out.\n*/\nstatic int memsys3Size(void *p){\n  Mem3Block *pBlock;\n  if( p==0 ) return 0;\n  pBlock = (Mem3Block*)p;\n  assert( (pBlock[-1].u.hdr.size4x&1)!=0 );\n  return (pBlock[-1].u.hdr.size4x&~3)*2 - 4;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int memsys3Roundup(int n){\n  if( n<=12 ){\n    return 12;\n  }else{\n    return ((n+11)&~7) - 4;\n  }\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys3Malloc(int nBytes){\n  sqlite3_int64 *p;\n  assert( nBytes>0 );          /* malloc.c filters out 0 byte requests */\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  memsys3Leave();\n  return (void*)p; \n}\n\n/*\n** Free memory.\n*/\nstatic void memsys3Free(void *pPrior){\n  assert( pPrior );\n  memsys3Enter();\n  memsys3FreeUnsafe(pPrior);\n  memsys3Leave();\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *memsys3Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  if( pPrior==0 ){\n    return sqlite3_malloc(nBytes);\n  }\n  if( nBytes<=0 ){\n    sqlite3_free(pPrior);\n    return 0;\n  }\n  nOld = memsys3Size(pPrior);\n  if( nBytes<=nOld && nBytes>=nOld-128 ){\n    return pPrior;\n  }\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  if( p ){\n    if( nOld<nBytes ){\n      memcpy(p, pPrior, nOld);\n    }else{\n      memcpy(p, pPrior, nBytes);\n    }\n    memsys3FreeUnsafe(pPrior);\n  }\n  memsys3Leave();\n  return p;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int memsys3Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  if( !sqlite3GlobalConfig.pHeap ){\n    return SQLITE_ERROR;\n  }\n\n  /* Store a pointer to the memory block in global structure mem3. */\n  assert( sizeof(Mem3Block)==8 );\n  mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap;\n  mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2;\n\n  /* Initialize the master block. */\n  mem3.szMaster = mem3.nPool;\n  mem3.mnMaster = mem3.szMaster;\n  mem3.iMaster = 1;\n  mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2;\n  mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool;\n  mem3.aPool[mem3.nPool].u.hdr.size4x = 1;\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys3Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem3.mutex = 0;\n  return;\n}\n\n\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys3Dump(const char *zFilename){\n#ifdef SQLITE_DEBUG\n  FILE *out;\n  u32 i, j;\n  u32 size;\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys3Enter();\n  fprintf(out, \"CHUNKS:\\n\");\n  for(i=1; i<=mem3.nPool; i+=size/4){\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    if( size/4<=1 ){\n      fprintf(out, \"%p size error\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){\n      fprintf(out, \"%p tail size does not match\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){\n      fprintf(out, \"%p tail checkout bit is incorrect\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( size&1 ){\n      fprintf(out, \"%p %6d bytes checked out\\n\", &mem3.aPool[i], (size/4)*8-8);\n    }else{\n      fprintf(out, \"%p %6d bytes free%s\\n\", &mem3.aPool[i], (size/4)*8-8,\n                  i==mem3.iMaster ? \" **master**\" : \"\");\n    }\n  }\n  for(i=0; i<MX_SMALL-1; i++){\n    if( mem3.aiSmall[i]==0 ) continue;\n    fprintf(out, \"small(%2d):\", i);\n    for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  for(i=0; i<N_HASH; i++){\n    if( mem3.aiHash[i]==0 ) continue;\n    fprintf(out, \"hash(%2d):\", i);\n    for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  fprintf(out, \"master=%d\\n\", mem3.iMaster);\n  fprintf(out, \"nowUsed=%d\\n\", mem3.nPool*8 - mem3.szMaster*8);\n  fprintf(out, \"mxUsed=%d\\n\", mem3.nPool*8 - mem3.mnMaster*8);\n  sqlite3_mutex_leave(mem3.mutex);\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n#else\n  UNUSED_PARAMETER(zFilename);\n#endif\n}\n\n/*\n** This routine is the only routine in this file with external \n** linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void){\n  static const sqlite3_mem_methods mempoolMethods = {\n     memsys3Malloc,\n     memsys3Free,\n     memsys3Realloc,\n     memsys3Size,\n     memsys3Roundup,\n     memsys3Init,\n     memsys3Shutdown,\n     0\n  };\n  return &mempoolMethods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS3 */\n\n/************** End of mem3.c ************************************************/\n/************** Begin file mem5.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The application gives SQLite a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.\n**\n** This memory allocator uses the following algorithm:\n**\n**   1.  All memory allocations sizes are rounded up to a power of 2.\n**\n**   2.  If two adjacent free blocks are the halves of a larger block,\n**       then the two blocks are coalesed into the single larger block.\n**\n**   3.  New memory is allocated from the first available free block.\n**\n** This algorithm is described in: J. M. Robson. \"Bounds for Some Functions\n** Concerning Dynamic Storage Allocation\". Journal of the Association for\n** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499.\n** \n** Let n be the size of the largest allocation divided by the minimum\n** allocation size (after rounding all sizes up to a power of 2.)  Let M\n** be the maximum amount of memory ever outstanding at one time.  Let\n** N be the total amount of memory available for allocation.  Robson\n** proved that this memory allocator will never breakdown due to \n** fragmentation as long as the following constraint holds:\n**\n**      N >=  M*(1 + log2(n)/2) - n + 1\n**\n** The sqlite3_status() logic tracks the maximum values of n and M so\n** that an application can, at any time, verify this constraint.\n*/\n\n/*\n** This version of the memory allocator is used only when \n** SQLITE_ENABLE_MEMSYS5 is defined.\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\n\n/*\n** A minimum allocation is an instance of the following structure.\n** Larger allocations are an array of these structures where the\n** size of the array is a power of 2.\n**\n** The size of this object must be a power of two.  That fact is\n** verified in memsys5Init().\n*/\ntypedef struct Mem5Link Mem5Link;\nstruct Mem5Link {\n  int next;       /* Index of next free chunk */\n  int prev;       /* Index of previous free chunk */\n};\n\n/*\n** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since\n** mem5.szAtom is always at least 8 and 32-bit integers are used,\n** it is not actually possible to reach this limit.\n*/\n#define LOGMAX 30\n\n/*\n** Masks used for mem5.aCtrl[] elements.\n*/\n#define CTRL_LOGSIZE  0x1f    /* Log2 Size of this block */\n#define CTRL_FREE     0x20    /* True if not checked out */\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem5\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem5Global {\n  /*\n  ** Memory available for allocation\n  */\n  int szAtom;      /* Smallest possible allocation in bytes */\n  int nBlock;      /* Number of szAtom sized blocks in zPool */\n  u8 *zPool;       /* Memory available to be allocated */\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n  /*\n  ** Performance statistics\n  */\n  u64 nAlloc;         /* Total number of calls to malloc */\n  u64 totalAlloc;     /* Total of all malloc calls - includes internal frag */\n  u64 totalExcess;    /* Total internal fragmentation */\n  u32 currentOut;     /* Current checkout, including internal fragmentation */\n  u32 currentCount;   /* Current number of distinct checkouts */\n  u32 maxOut;         /* Maximum instantaneous currentOut */\n  u32 maxCount;       /* Maximum instantaneous currentCount */\n  u32 maxRequest;     /* Largest allocation (exclusive of internal frag) */\n  \n  /*\n  ** Lists of free blocks.  aiFreelist[0] is a list of free blocks of\n  ** size mem5.szAtom.  aiFreelist[1] holds blocks of size szAtom*2.\n  ** and so forth.\n  */\n  int aiFreelist[LOGMAX+1];\n\n  /*\n  ** Space for tracking which blocks are checked out and the size\n  ** of each block.  One byte per block.\n  */\n  u8 *aCtrl;\n\n} mem5;\n\n/*\n** Access the static variable through a macro for SQLITE_OMIT_WSD\n*/\n#define mem5 GLOBAL(struct Mem5Global, mem5)\n\n/*\n** Assuming mem5.zPool is divided up into an array of Mem5Link\n** structures, return a pointer to the idx-th such lik.\n*/\n#define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))\n\n/*\n** Unlink the chunk at mem5.aPool[i] from list it is currently\n** on.  It should be found on mem5.aiFreelist[iLogsize].\n*/\nstatic void memsys5Unlink(int i, int iLogsize){\n  int next, prev;\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  next = MEM5LINK(i)->next;\n  prev = MEM5LINK(i)->prev;\n  if( prev<0 ){\n    mem5.aiFreelist[iLogsize] = next;\n  }else{\n    MEM5LINK(prev)->next = next;\n  }\n  if( next>=0 ){\n    MEM5LINK(next)->prev = prev;\n  }\n}\n\n/*\n** Link the chunk at mem5.aPool[i] so that is on the iLogsize\n** free list.\n*/\nstatic void memsys5Link(int i, int iLogsize){\n  int x;\n  assert( sqlite3_mutex_held(mem5.mutex) );\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];\n  MEM5LINK(i)->prev = -1;\n  if( x>=0 ){\n    assert( x<mem5.nBlock );\n    MEM5LINK(x)->prev = i;\n  }\n  mem5.aiFreelist[iLogsize] = i;\n}\n\n/*\n** If the STATIC_MEM mutex is not already held, obtain it now. The mutex\n** will already be held (obtained by code in malloc.c) if\n** sqlite3GlobalConfig.bMemStat is true.\n*/\nstatic void memsys5Enter(void){\n  sqlite3_mutex_enter(mem5.mutex);\n}\nstatic void memsys5Leave(void){\n  sqlite3_mutex_leave(mem5.mutex);\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.  The\n** size returned omits the 8-byte header overhead.  This only\n** works for chunks that are currently checked out.\n*/\nstatic int memsys5Size(void *p){\n  int iSize = 0;\n  if( p ){\n    int i = ((u8 *)p-mem5.zPool)/mem5.szAtom;\n    assert( i>=0 && i<mem5.nBlock );\n    iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));\n  }\n  return iSize;\n}\n\n/*\n** Find the first entry on the freelist iLogsize.  Unlink that\n** entry and return its index. \n*/\nstatic int memsys5UnlinkFirst(int iLogsize){\n  int i;\n  int iFirst;\n\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  i = iFirst = mem5.aiFreelist[iLogsize];\n  assert( iFirst>=0 );\n  while( i>0 ){\n    if( i<iFirst ) iFirst = i;\n    i = MEM5LINK(i)->next;\n  }\n  memsys5Unlink(iFirst, iLogsize);\n  return iFirst;\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.  Return NULL if nBytes==0.\n**\n** The caller guarantees that nByte positive.\n**\n** The caller has obtained a mutex prior to invoking this\n** routine so there is never any chance that two or more\n** threads can be in this routine at the same time.\n*/\nstatic void *memsys5MallocUnsafe(int nByte){\n  int i;           /* Index of a mem5.aPool[] slot */\n  int iBin;        /* Index into mem5.aiFreelist[] */\n  int iFullSz;     /* Size of allocation rounded up to power of 2 */\n  int iLogsize;    /* Log2 of iFullSz/POW2_MIN */\n\n  /* nByte must be a positive */\n  assert( nByte>0 );\n\n  /* Keep track of the maximum allocation request.  Even unfulfilled\n  ** requests are counted */\n  if( (u32)nByte>mem5.maxRequest ){\n    mem5.maxRequest = nByte;\n  }\n\n  /* Abort if the requested allocation size is larger than the largest\n  ** power of two that we can represent using 32-bit signed integers.\n  */\n  if( nByte > 0x40000000 ){\n    return 0;\n  }\n\n  /* Round nByte up to the next valid power of two */\n  for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){}\n\n  /* Make sure mem5.aiFreelist[iLogsize] contains at least one free\n  ** block.  If not, then split a block of the next larger power of\n  ** two in order to create a new free block of size iLogsize.\n  */\n  for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}\n  if( iBin>LOGMAX ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes\", nByte);\n    return 0;\n  }\n  i = memsys5UnlinkFirst(iBin);\n  while( iBin>iLogsize ){\n    int newSize;\n\n    iBin--;\n    newSize = 1 << iBin;\n    mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;\n    memsys5Link(i+newSize, iBin);\n  }\n  mem5.aCtrl[i] = iLogsize;\n\n  /* Update allocator performance statistics. */\n  mem5.nAlloc++;\n  mem5.totalAlloc += iFullSz;\n  mem5.totalExcess += iFullSz - nByte;\n  mem5.currentCount++;\n  mem5.currentOut += iFullSz;\n  if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;\n  if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;\n\n  /* Return a pointer to the allocated memory. */\n  return (void*)&mem5.zPool[i*mem5.szAtom];\n}\n\n/*\n** Free an outstanding memory allocation.\n*/\nstatic void memsys5FreeUnsafe(void *pOld){\n  u32 size, iLogsize;\n  int iBlock;\n\n  /* Set iBlock to the index of the block pointed to by pOld in \n  ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.\n  */\n  iBlock = ((u8 *)pOld-mem5.zPool)/mem5.szAtom;\n\n  /* Check that the pointer pOld points to a valid, non-free block. */\n  assert( iBlock>=0 && iBlock<mem5.nBlock );\n  assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );\n  assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );\n\n  iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;\n  size = 1<<iLogsize;\n  assert( iBlock+size-1<(u32)mem5.nBlock );\n\n  mem5.aCtrl[iBlock] |= CTRL_FREE;\n  mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;\n  assert( mem5.currentCount>0 );\n  assert( mem5.currentOut>=(size*mem5.szAtom) );\n  mem5.currentCount--;\n  mem5.currentOut -= size*mem5.szAtom;\n  assert( mem5.currentOut>0 || mem5.currentCount==0 );\n  assert( mem5.currentCount>0 || mem5.currentOut==0 );\n\n  mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n  while( ALWAYS(iLogsize<LOGMAX) ){\n    int iBuddy;\n    if( (iBlock>>iLogsize) & 1 ){\n      iBuddy = iBlock - size;\n    }else{\n      iBuddy = iBlock + size;\n    }\n    assert( iBuddy>=0 );\n    if( (iBuddy+(1<<iLogsize))>mem5.nBlock ) break;\n    if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;\n    memsys5Unlink(iBuddy, iLogsize);\n    iLogsize++;\n    if( iBuddy<iBlock ){\n      mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBlock] = 0;\n      iBlock = iBuddy;\n    }else{\n      mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBuddy] = 0;\n    }\n    size *= 2;\n  }\n  memsys5Link(iBlock, iLogsize);\n}\n\n/*\n** Allocate nBytes of memory\n*/\nstatic void *memsys5Malloc(int nBytes){\n  sqlite3_int64 *p = 0;\n  if( nBytes>0 ){\n    memsys5Enter();\n    p = memsys5MallocUnsafe(nBytes);\n    memsys5Leave();\n  }\n  return (void*)p; \n}\n\n/*\n** Free memory.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.\n*/\nstatic void memsys5Free(void *pPrior){\n  assert( pPrior!=0 );\n  memsys5Enter();\n  memsys5FreeUnsafe(pPrior);\n  memsys5Leave();  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.  \n**\n** nBytes is always a value obtained from a prior call to\n** memsys5Round().  Hence nBytes is always a non-negative power\n** of two.  If nBytes==0 that means that an oversize allocation\n** (an allocation larger than 0x40000000) was requested and this\n** routine should return 0 without freeing pPrior.\n*/\nstatic void *memsys5Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  assert( pPrior!=0 );\n  assert( (nBytes&(nBytes-1))==0 );  /* EV: R-46199-30249 */\n  assert( nBytes>=0 );\n  if( nBytes==0 ){\n    return 0;\n  }\n  nOld = memsys5Size(pPrior);\n  if( nBytes<=nOld ){\n    return pPrior;\n  }\n  memsys5Enter();\n  p = memsys5MallocUnsafe(nBytes);\n  if( p ){\n    memcpy(p, pPrior, nOld);\n    memsys5FreeUnsafe(pPrior);\n  }\n  memsys5Leave();\n  return p;\n}\n\n/*\n** Round up a request size to the next valid allocation size.  If\n** the allocation is too large to be handled by this allocation system,\n** return 0.\n**\n** All allocations must be a power of two and must be expressed by a\n** 32-bit signed integer.  Hence the largest allocation is 0x40000000\n** or 1073741824 bytes.\n*/\nstatic int memsys5Roundup(int n){\n  int iFullSz;\n  if( n > 0x40000000 ) return 0;\n  for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);\n  return iFullSz;\n}\n\n/*\n** Return the ceiling of the logarithm base 2 of iValue.\n**\n** Examples:   memsys5Log(1) -> 0\n**             memsys5Log(2) -> 1\n**             memsys5Log(4) -> 2\n**             memsys5Log(5) -> 3\n**             memsys5Log(8) -> 3\n**             memsys5Log(9) -> 4\n*/\nstatic int memsys5Log(int iValue){\n  int iLog;\n  for(iLog=0; (iLog<(int)((sizeof(int)*8)-1)) && (1<<iLog)<iValue; iLog++);\n  return iLog;\n}\n\n/*\n** Initialize the memory allocator.\n**\n** This routine is not threadsafe.  The caller must be holding a mutex\n** to prevent multiple threads from entering at the same time.\n*/\nstatic int memsys5Init(void *NotUsed){\n  int ii;            /* Loop counter */\n  int nByte;         /* Number of bytes of memory available to this allocator */\n  u8 *zByte;         /* Memory usable by this allocator */\n  int nMinLog;       /* Log base 2 of minimum allocation size in bytes */\n  int iOffset;       /* An offset into mem5.aCtrl[] */\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* For the purposes of this routine, disable the mutex */\n  mem5.mutex = 0;\n\n  /* The size of a Mem5Link object must be a power of two.  Verify that\n  ** this is case.\n  */\n  assert( (sizeof(Mem5Link)&(sizeof(Mem5Link)-1))==0 );\n\n  nByte = sqlite3GlobalConfig.nHeap;\n  zByte = (u8*)sqlite3GlobalConfig.pHeap;\n  assert( zByte!=0 );  /* sqlite3_config() does not allow otherwise */\n\n  /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */\n  nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);\n  mem5.szAtom = (1<<nMinLog);\n  while( (int)sizeof(Mem5Link)>mem5.szAtom ){\n    mem5.szAtom = mem5.szAtom << 1;\n  }\n\n  mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));\n  mem5.zPool = zByte;\n  mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];\n\n  for(ii=0; ii<=LOGMAX; ii++){\n    mem5.aiFreelist[ii] = -1;\n  }\n\n  iOffset = 0;\n  for(ii=LOGMAX; ii>=0; ii--){\n    int nAlloc = (1<<ii);\n    if( (iOffset+nAlloc)<=mem5.nBlock ){\n      mem5.aCtrl[iOffset] = ii | CTRL_FREE;\n      memsys5Link(iOffset, ii);\n      iOffset += nAlloc;\n    }\n    assert((iOffset+nAlloc)>mem5.nBlock);\n  }\n\n  /* If a mutex is required for normal operation, allocate one */\n  if( sqlite3GlobalConfig.bMemstat==0 ){\n    mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys5Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem5.mutex = 0;\n  return;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys5Dump(const char *zFilename){\n  FILE *out;\n  int i, j, n;\n  int nMinLog;\n\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys5Enter();\n  nMinLog = memsys5Log(mem5.szAtom);\n  for(i=0; i<=LOGMAX && i+nMinLog<32; i++){\n    for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}\n    fprintf(out, \"freelist items of size %d: %d\\n\", mem5.szAtom << i, n);\n  }\n  fprintf(out, \"mem5.nAlloc       = %llu\\n\", mem5.nAlloc);\n  fprintf(out, \"mem5.totalAlloc   = %llu\\n\", mem5.totalAlloc);\n  fprintf(out, \"mem5.totalExcess  = %llu\\n\", mem5.totalExcess);\n  fprintf(out, \"mem5.currentOut   = %u\\n\", mem5.currentOut);\n  fprintf(out, \"mem5.currentCount = %u\\n\", mem5.currentCount);\n  fprintf(out, \"mem5.maxOut       = %u\\n\", mem5.maxOut);\n  fprintf(out, \"mem5.maxCount     = %u\\n\", mem5.maxCount);\n  fprintf(out, \"mem5.maxRequest   = %u\\n\", mem5.maxRequest);\n  memsys5Leave();\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n}\n#endif\n\n/*\n** This routine is the only routine in this file with external \n** linkage. It returns a pointer to a static sqlite3_mem_methods\n** struct populated with the memsys5 methods.\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void){\n  static const sqlite3_mem_methods memsys5Methods = {\n     memsys5Malloc,\n     memsys5Free,\n     memsys5Realloc,\n     memsys5Size,\n     memsys5Roundup,\n     memsys5Init,\n     memsys5Shutdown,\n     0\n  };\n  return &memsys5Methods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS5 */\n\n/************** End of mem5.c ************************************************/\n/************** Begin file mutex.c *******************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This file contains code that is common across all mutex implementations.\n*/\n\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)\n/*\n** For debugging purposes, record when the mutex subsystem is initialized\n** and uninitialized so that we can assert() if there is an attempt to\n** allocate a mutex while the system is uninitialized.\n*/\nstatic SQLITE_WSD int mutexIsInit = 0;\n#endif /* SQLITE_DEBUG */\n\n\n#ifndef SQLITE_MUTEX_OMIT\n/*\n** Initialize the mutex system.\n*/\nSQLITE_PRIVATE int sqlite3MutexInit(void){ \n  int rc = SQLITE_OK;\n  if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){\n    /* If the xMutexAlloc method has not been set, then the user did not\n    ** install a mutex implementation via sqlite3_config() prior to \n    ** sqlite3_initialize() being called. This block copies pointers to\n    ** the default implementation into the sqlite3GlobalConfig structure.\n    */\n    sqlite3_mutex_methods const *pFrom;\n    sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pFrom = sqlite3DefaultMutex();\n    }else{\n      pFrom = sqlite3NoopMutex();\n    }\n    memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc));\n    memcpy(&pTo->xMutexFree, &pFrom->xMutexFree,\n           sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));\n    pTo->xMutexAlloc = pFrom->xMutexAlloc;\n  }\n  rc = sqlite3GlobalConfig.mutex.xMutexInit();\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 1;\n#endif\n\n  return rc;\n}\n\n/*\n** Shutdown the mutex system. This call frees resources allocated by\n** sqlite3MutexInit().\n*/\nSQLITE_PRIVATE int sqlite3MutexEnd(void){\n  int rc = SQLITE_OK;\n  if( sqlite3GlobalConfig.mutex.xMutexEnd ){\n    rc = sqlite3GlobalConfig.mutex.xMutexEnd();\n  }\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 0;\n#endif\n\n  return rc;\n}\n\n/*\n** Retrieve a pointer to a static mutex or allocate a new dynamic one.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){\n  if( !sqlite3GlobalConfig.bCoreMutex ){\n    return 0;\n  }\n  assert( GLOBAL(int, mutexIsInit) );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\n/*\n** Free a dynamic mutex.\n*/\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){\n  if( p ){\n    sqlite3GlobalConfig.mutex.xMutexFree(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If some other thread already has the mutex, block\n** until it can be obtained.\n*/\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){\n  if( p ){\n    sqlite3GlobalConfig.mutex.xMutexEnter(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another\n** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.\n*/\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    return sqlite3GlobalConfig.mutex.xMutexTry(p);\n  }\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was previously\n** entered by the same thread.  The behavior is undefined if the mutex \n** is not currently entered. If a NULL pointer is passed as an argument\n** this function is a no-op.\n*/\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){\n  if( p ){\n    sqlite3GlobalConfig.mutex.xMutexLeave(p);\n  }\n}\n\n#ifndef NDEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);\n}\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);\n}\n#endif\n\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.c ***********************************************/\n/************** Begin file mutex_noop.c **************************************/\n/*\n** 2008 October 07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This implementation in this file does not provide any mutual\n** exclusion and is thus suitable for use only in applications\n** that use SQLite in a single thread.  The routines defined\n** here are place-holders.  Applications can substitute working\n** mutex routines at start-time using the\n**\n**     sqlite3_config(SQLITE_CONFIG_MUTEX,...)\n**\n** interface.\n**\n** If compiled with SQLITE_DEBUG, then additional logic is inserted\n** that does error checking on mutexes to make sure they are being\n** called correctly.\n*/\n\n#ifndef SQLITE_MUTEX_OMIT\n\n#ifndef SQLITE_DEBUG\n/*\n** Stub routines for all mutex methods.\n**\n** This routines provide no mutual exclusion or error checking.\n*/\nstatic int noopMutexInit(void){ return SQLITE_OK; }\nstatic int noopMutexEnd(void){ return SQLITE_OK; }\nstatic sqlite3_mutex *noopMutexAlloc(int id){ \n  UNUSED_PARAMETER(id);\n  return (sqlite3_mutex*)8; \n}\nstatic void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic int noopMutexTry(sqlite3_mutex *p){\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\nstatic void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    noopMutexInit,\n    noopMutexEnd,\n    noopMutexAlloc,\n    noopMutexFree,\n    noopMutexEnter,\n    noopMutexTry,\n    noopMutexLeave,\n\n    0,\n    0,\n  };\n\n  return &sMutex;\n}\n#endif /* !SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n** In this implementation, error checking is provided for testing\n** and debugging purposes.  The mutexes still do not provide any\n** mutual exclusion.\n*/\n\n/*\n** The mutex object\n*/\ntypedef struct sqlite3_debug_mutex {\n  int id;     /* The mutex type */\n  int cnt;    /* Number of entries without a matching leave */\n} sqlite3_debug_mutex;\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nstatic int debugMutexHeld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt>0;\n}\nstatic int debugMutexNotheld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt==0;\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int debugMutexInit(void){ return SQLITE_OK; }\nstatic int debugMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated. \n*/\nstatic sqlite3_mutex *debugMutexAlloc(int id){\n  static sqlite3_debug_mutex aStatic[6];\n  sqlite3_debug_mutex *pNew = 0;\n  switch( id ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      pNew = sqlite3Malloc(sizeof(*pNew));\n      if( pNew ){\n        pNew->id = id;\n        pNew->cnt = 0;\n      }\n      break;\n    }\n    default: {\n      assert( id-2 >= 0 );\n      assert( id-2 < (int)(sizeof(aStatic)/sizeof(aStatic[0])) );\n      pNew = &aStatic[id-2];\n      pNew->id = id;\n      break;\n    }\n  }\n  return (sqlite3_mutex*)pNew;\n}\n\n/*\n** This routine deallocates a previously allocated mutex.\n*/\nstatic void debugMutexFree(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->cnt==0 );\n  assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );\n  sqlite3_free(p);\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void debugMutexEnter(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n}\nstatic int debugMutexTry(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void debugMutexLeave(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( debugMutexHeld(pX) );\n  p->cnt--;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    debugMutexInit,\n    debugMutexEnd,\n    debugMutexAlloc,\n    debugMutexFree,\n    debugMutexEnter,\n    debugMutexTry,\n    debugMutexLeave,\n\n    debugMutexHeld,\n    debugMutexNotheld\n  };\n\n  return &sMutex;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation\n** is used regardless of the run-time threadsafety setting.\n*/\n#ifdef SQLITE_MUTEX_NOOP\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  return sqlite3NoopMutex();\n}\n#endif /* defined(SQLITE_MUTEX_NOOP) */\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex_noop.c ******************************************/\n/************** Begin file mutex_unix.c **************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for pthreads\n*/\n\n/*\n** The code in this file is only used if we are compiling threadsafe\n** under unix with pthreads.\n**\n** Note that this implementation requires a version of pthreads that\n** supports recursive mutexes.\n*/\n#ifdef SQLITE_MUTEX_PTHREADS\n\n#include <pthread.h>\n\n/*\n** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields\n** are necessary under two condidtions:  (1) Debug builds and (2) using\n** home-grown mutexes.  Encapsulate these conditions into a single #define.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX)\n# define SQLITE_MUTEX_NREF 1\n#else\n# define SQLITE_MUTEX_NREF 0\n#endif\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  pthread_mutex_t mutex;     /* Mutex controlling the lock */\n#if SQLITE_MUTEX_NREF\n  int id;                    /* Mutex type */\n  volatile int nRef;         /* Number of entrances */\n  volatile pthread_t owner;  /* Thread that is within this mutex */\n  int trace;                 /* True to trace changes */\n#endif\n};\n#if SQLITE_MUTEX_NREF\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0, (pthread_t)0, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }\n#endif\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.  On some platforms,\n** there might be race conditions that can cause these routines to\n** deliver incorrect results.  In particular, if pthread_equal() is\n** not an atomic operation, then these routines might delivery\n** incorrect results.  On most platforms, pthread_equal() is a \n** comparison of two integers and is therefore atomic.  But we are\n** told that HPUX is not such a platform.  If so, then these routines\n** will not always work correctly on HPUX.\n**\n** On those platforms where pthread_equal() is not atomic, SQLite\n** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to\n** make sure no assert() statements are evaluated and hence these\n** routines are never called.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_DEBUG)\nstatic int pthreadMutexHeld(sqlite3_mutex *p){\n  return (p->nRef!=0 && pthread_equal(p->owner, pthread_self()));\n}\nstatic int pthreadMutexNotheld(sqlite3_mutex *p){\n  return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0;\n}\n#endif\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int pthreadMutexInit(void){ return SQLITE_OK; }\nstatic int pthreadMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_MEM2\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static \n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *pthreadMutexAlloc(int iType){\n  static sqlite3_mutex staticMutexes[] = {\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER\n  };\n  sqlite3_mutex *p;\n  switch( iType ){\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n        /* If recursive mutexes are not available, we will have to\n        ** build our own.  See below. */\n        pthread_mutex_init(&p->mutex, 0);\n#else\n        /* Use a recursive mutex if it is available */\n        pthread_mutexattr_t recursiveAttr;\n        pthread_mutexattr_init(&recursiveAttr);\n        pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);\n        pthread_mutex_init(&p->mutex, &recursiveAttr);\n        pthread_mutexattr_destroy(&recursiveAttr);\n#endif\n#if SQLITE_MUTEX_NREF\n        p->id = iType;\n#endif\n      }\n      break;\n    }\n    case SQLITE_MUTEX_FAST: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n#if SQLITE_MUTEX_NREF\n        p->id = iType;\n#endif\n        pthread_mutex_init(&p->mutex, 0);\n      }\n      break;\n    }\n    default: {\n      assert( iType-2 >= 0 );\n      assert( iType-2 < ArraySize(staticMutexes) );\n      p = &staticMutexes[iType-2];\n#if SQLITE_MUTEX_NREF\n      p->id = iType;\n#endif\n      break;\n    }\n  }\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void pthreadMutexFree(sqlite3_mutex *p){\n  assert( p->nRef==0 );\n  assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );\n  pthread_mutex_destroy(&p->mutex);\n  sqlite3_free(p);\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void pthreadMutexEnter(sqlite3_mutex *p){\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n    }else{\n      pthread_mutex_lock(&p->mutex);\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  pthread_mutex_lock(&p->mutex);\n#if SQLITE_MUTEX_NREF\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = pthread_self();\n  p->nRef++;\n#endif\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\nstatic int pthreadMutexTry(sqlite3_mutex *p){\n  int rc;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n      rc = SQLITE_OK;\n    }else if( pthread_mutex_trylock(&p->mutex)==0 ){\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_BUSY;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  if( pthread_mutex_trylock(&p->mutex)==0 ){\n#if SQLITE_MUTEX_NREF\n    p->owner = pthread_self();\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }else{\n    rc = SQLITE_BUSY;\n  }\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( rc==SQLITE_OK && p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void pthreadMutexLeave(sqlite3_mutex *p){\n  assert( pthreadMutexHeld(p) );\n#if SQLITE_MUTEX_NREF\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n#endif\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  if( p->nRef==0 ){\n    pthread_mutex_unlock(&p->mutex);\n  }\n#else\n  pthread_mutex_unlock(&p->mutex);\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"leave mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    pthreadMutexInit,\n    pthreadMutexEnd,\n    pthreadMutexAlloc,\n    pthreadMutexFree,\n    pthreadMutexEnter,\n    pthreadMutexTry,\n    pthreadMutexLeave,\n#ifdef SQLITE_DEBUG\n    pthreadMutexHeld,\n    pthreadMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_PTHREADS */\n\n/************** End of mutex_unix.c ******************************************/\n/************** Begin file mutex_w32.c ***************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for win32\n*/\n\n/*\n** The code in this file is only used if we are compiling multithreaded\n** on a win32 system.\n*/\n#ifdef SQLITE_MUTEX_W32\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  CRITICAL_SECTION mutex;    /* Mutex controlling the lock */\n  int id;                    /* Mutex type */\n#ifdef SQLITE_DEBUG\n  volatile int nRef;         /* Number of enterances */\n  volatile DWORD owner;      /* Thread holding this mutex */\n  int trace;                 /* True to trace changes */\n#endif\n};\n#define SQLITE_W32_MUTEX_INITIALIZER { 0 }\n#ifdef SQLITE_DEBUG\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, 0L, (DWORD)0, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 }\n#endif\n\n/*\n** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,\n** or WinCE.  Return false (zero) for Win95, Win98, or WinME.\n**\n** Here is an interesting observation:  Win95, Win98, and WinME lack\n** the LockFileEx() API.  But we can still statically link against that\n** API as long as we don't call it win running Win95/98/ME.  A call to\n** this routine is used to determine if the host is Win95/98/ME or\n** WinNT/2K/XP so that we will know whether or not we can safely call\n** the LockFileEx() API.\n**\n** mutexIsNT() is only used for the TryEnterCriticalSection() API call,\n** which is only available if your application was compiled with \n** _WIN32_WINNT defined to a value >= 0x0400.  Currently, the only\n** call to TryEnterCriticalSection() is #ifdef'ed out, so #ifdef \n** this out as well.\n*/\n#if 0\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n# define mutexIsNT()  (1)\n#else\n  static int mutexIsNT(void){\n    static int osType = 0;\n    if( osType==0 ){\n      OSVERSIONINFO sInfo;\n      sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n      GetVersionEx(&sInfo);\n      osType = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;\n    }\n    return osType==2;\n  }\n#endif /* SQLITE_OS_WINCE */\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.\n*/\nstatic int winMutexHeld(sqlite3_mutex *p){\n  return p->nRef!=0 && p->owner==GetCurrentThreadId();\n}\nstatic int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){\n  return p->nRef==0 || p->owner!=tid;\n}\nstatic int winMutexNotheld(sqlite3_mutex *p){\n  DWORD tid = GetCurrentThreadId(); \n  return winMutexNotheld2(p, tid);\n}\n#endif\n\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic sqlite3_mutex winMutex_staticMutexes[6] = {\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER\n};\nstatic int winMutex_isInit = 0;\n/* As winMutexInit() and winMutexEnd() are called as part\n** of the sqlite3_initialize and sqlite3_shutdown()\n** processing, the \"interlocked\" magic is probably not\n** strictly necessary.\n*/\nstatic long winMutex_lock = 0;\n\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */\n\nstatic int winMutexInit(void){ \n  /* The first to increment to 1 does actual initialization */\n  if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){\n    int i;\n    for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n#if SQLITE_OS_WINRT\n      InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);\n#else\n      InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);\n#endif\n    }\n    winMutex_isInit = 1;\n  }else{\n    /* Someone else is in the process of initing the static mutexes */\n    while( !winMutex_isInit ){\n      sqlite3_win32_sleep(1);\n    }\n  }\n  return SQLITE_OK; \n}\n\nstatic int winMutexEnd(void){ \n  /* The first to decrement to 0 does actual shutdown \n  ** (which should be the last to shutdown.) */\n  if( InterlockedCompareExchange(&winMutex_lock, 0, 1)==1 ){\n    if( winMutex_isInit==1 ){\n      int i;\n      for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n        DeleteCriticalSection(&winMutex_staticMutexes[i].mutex);\n      }\n      winMutex_isInit = 0;\n    }\n  }\n  return SQLITE_OK; \n}\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_MEM2\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static \n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *winMutexAlloc(int iType){\n  sqlite3_mutex *p;\n\n  switch( iType ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){  \n#ifdef SQLITE_DEBUG\n        p->id = iType;\n#endif\n#if SQLITE_OS_WINRT\n        InitializeCriticalSectionEx(&p->mutex, 0, 0);\n#else\n        InitializeCriticalSection(&p->mutex);\n#endif\n      }\n      break;\n    }\n    default: {\n      assert( winMutex_isInit==1 );\n      assert( iType-2 >= 0 );\n      assert( iType-2 < ArraySize(winMutex_staticMutexes) );\n      p = &winMutex_staticMutexes[iType-2];\n#ifdef SQLITE_DEBUG\n      p->id = iType;\n#endif\n      break;\n    }\n  }\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void winMutexFree(sqlite3_mutex *p){\n  assert( p );\n  assert( p->nRef==0 && p->owner==0 );\n  assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );\n  DeleteCriticalSection(&p->mutex);\n  sqlite3_free(p);\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void winMutexEnter(sqlite3_mutex *p){\n#ifdef SQLITE_DEBUG\n  DWORD tid = GetCurrentThreadId(); \n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n#endif\n  EnterCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = tid; \n  p->nRef++;\n  if( p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\nstatic int winMutexTry(sqlite3_mutex *p){\n#ifndef NDEBUG\n  DWORD tid = GetCurrentThreadId(); \n#endif\n  int rc = SQLITE_BUSY;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n  /*\n  ** The sqlite3_mutex_try() routine is very rarely used, and when it\n  ** is used it is merely an optimization.  So it is OK for it to always\n  ** fail.  \n  **\n  ** The TryEnterCriticalSection() interface is only available on WinNT.\n  ** And some windows compilers complain if you try to use it without\n  ** first doing some #defines that prevent SQLite from building on Win98.\n  ** For that reason, we will omit this optimization for now.  See\n  ** ticket #2685.\n  */\n#if 0\n  if( mutexIsNT() && TryEnterCriticalSection(&p->mutex) ){\n    p->owner = tid;\n    p->nRef++;\n    rc = SQLITE_OK;\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif\n#ifdef SQLITE_DEBUG\n  if( rc==SQLITE_OK && p->trace ){\n    printf(\"try mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void winMutexLeave(sqlite3_mutex *p){\n#ifndef NDEBUG\n  DWORD tid = GetCurrentThreadId();\n  assert( p->nRef>0 );\n  assert( p->owner==tid );\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n#endif\n  LeaveCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"leave mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    winMutexInit,\n    winMutexEnd,\n    winMutexAlloc,\n    winMutexFree,\n    winMutexEnter,\n    winMutexTry,\n    winMutexLeave,\n#ifdef SQLITE_DEBUG\n    winMutexHeld,\n    winMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n\n  return &sMutex;\n}\n#endif /* SQLITE_MUTEX_W32 */\n\n/************** End of mutex_w32.c *******************************************/\n/************** Begin file malloc.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Memory allocation functions used throughout sqlite.\n*/\n/* #include <stdarg.h> */\n\n/*\n** Attempt to release up to n bytes of non-essential memory currently\n** held by SQLite. An example of non-essential memory is memory used to\n** cache database pages that are not currently in use.\n*/\nSQLITE_API int sqlite3_release_memory(int n){\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  return sqlite3PcacheReleaseMemory(n);\n#else\n  /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine\n  ** is a no-op returning zero if SQLite is not compiled with\n  ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */\n  UNUSED_PARAMETER(n);\n  return 0;\n#endif\n}\n\n/*\n** An instance of the following object records the location of\n** each unused scratch buffer.\n*/\ntypedef struct ScratchFreeslot {\n  struct ScratchFreeslot *pNext;   /* Next unused scratch buffer */\n} ScratchFreeslot;\n\n/*\n** State information local to the memory allocation subsystem.\n*/\nstatic SQLITE_WSD struct Mem0Global {\n  sqlite3_mutex *mutex;         /* Mutex to serialize access */\n\n  /*\n  ** The alarm callback and its arguments.  The mem0.mutex lock will\n  ** be held while the callback is running.  Recursive calls into\n  ** the memory subsystem are allowed, but no new callbacks will be\n  ** issued.\n  */\n  sqlite3_int64 alarmThreshold;\n  void (*alarmCallback)(void*, sqlite3_int64,int);\n  void *alarmArg;\n\n  /*\n  ** Pointers to the end of sqlite3GlobalConfig.pScratch memory\n  ** (so that a range test can be used to determine if an allocation\n  ** being freed came from pScratch) and a pointer to the list of\n  ** unused scratch allocations.\n  */\n  void *pScratchEnd;\n  ScratchFreeslot *pScratchFree;\n  u32 nScratchFree;\n\n  /*\n  ** True if heap is nearly \"full\" where \"full\" is defined by the\n  ** sqlite3_soft_heap_limit() setting.\n  */\n  int nearlyFull;\n} mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 };\n\n#define mem0 GLOBAL(struct Mem0Global, mem0)\n\n/*\n** This routine runs when the memory allocator sees that the\n** total memory allocation is about to exceed the soft heap\n** limit.\n*/\nstatic void softHeapLimitEnforcer(\n  void *NotUsed, \n  sqlite3_int64 NotUsed2,\n  int allocSize\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_release_memory(allocSize);\n}\n\n/*\n** Change the alarm callback\n*/\nstatic int sqlite3MemoryAlarm(\n  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),\n  void *pArg,\n  sqlite3_int64 iThreshold\n){\n  int nUsed;\n  sqlite3_mutex_enter(mem0.mutex);\n  mem0.alarmCallback = xCallback;\n  mem0.alarmArg = pArg;\n  mem0.alarmThreshold = iThreshold;\n  nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n  mem0.nearlyFull = (iThreshold>0 && iThreshold<=nUsed);\n  sqlite3_mutex_leave(mem0.mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  Internal/core SQLite code\n** should call sqlite3MemoryAlarm.\n*/\nSQLITE_API int sqlite3_memory_alarm(\n  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),\n  void *pArg,\n  sqlite3_int64 iThreshold\n){\n  return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);\n}\n#endif\n\n/*\n** Set the soft heap-size limit for the library. Passing a zero or \n** negative value indicates no limit.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){\n  sqlite3_int64 priorLimit;\n  sqlite3_int64 excess;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return -1;\n#endif\n  sqlite3_mutex_enter(mem0.mutex);\n  priorLimit = mem0.alarmThreshold;\n  sqlite3_mutex_leave(mem0.mutex);\n  if( n<0 ) return priorLimit;\n  if( n>0 ){\n    sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n);\n  }else{\n    sqlite3MemoryAlarm(0, 0, 0);\n  }\n  excess = sqlite3_memory_used() - n;\n  if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));\n  return priorLimit;\n}\nSQLITE_API void sqlite3_soft_heap_limit(int n){\n  if( n<0 ) n = 0;\n  sqlite3_soft_heap_limit64(n);\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE int sqlite3MallocInit(void){\n  if( sqlite3GlobalConfig.m.xMalloc==0 ){\n    sqlite3MemSetDefault();\n  }\n  memset(&mem0, 0, sizeof(mem0));\n  if( sqlite3GlobalConfig.bCoreMutex ){\n    mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  if( sqlite3GlobalConfig.pScratch && sqlite3GlobalConfig.szScratch>=100\n      && sqlite3GlobalConfig.nScratch>0 ){\n    int i, n, sz;\n    ScratchFreeslot *pSlot;\n    sz = ROUNDDOWN8(sqlite3GlobalConfig.szScratch);\n    sqlite3GlobalConfig.szScratch = sz;\n    pSlot = (ScratchFreeslot*)sqlite3GlobalConfig.pScratch;\n    n = sqlite3GlobalConfig.nScratch;\n    mem0.pScratchFree = pSlot;\n    mem0.nScratchFree = n;\n    for(i=0; i<n-1; i++){\n      pSlot->pNext = (ScratchFreeslot*)(sz+(char*)pSlot);\n      pSlot = pSlot->pNext;\n    }\n    pSlot->pNext = 0;\n    mem0.pScratchEnd = (void*)&pSlot[1];\n  }else{\n    mem0.pScratchEnd = 0;\n    sqlite3GlobalConfig.pScratch = 0;\n    sqlite3GlobalConfig.szScratch = 0;\n    sqlite3GlobalConfig.nScratch = 0;\n  }\n  if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512\n      || sqlite3GlobalConfig.nPage<1 ){\n    sqlite3GlobalConfig.pPage = 0;\n    sqlite3GlobalConfig.szPage = 0;\n    sqlite3GlobalConfig.nPage = 0;\n  }\n  return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);\n}\n\n/*\n** Return true if the heap is currently under memory pressure - in other\n** words if the amount of heap used is close to the limit set by\n** sqlite3_soft_heap_limit().\n*/\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void){\n  return mem0.nearlyFull;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE void sqlite3MallocEnd(void){\n  if( sqlite3GlobalConfig.m.xShutdown ){\n    sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);\n  }\n  memset(&mem0, 0, sizeof(mem0));\n}\n\n/*\n** Return the amount of memory currently checked out.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void){\n  int n, mx;\n  sqlite3_int64 res;\n  sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);\n  res = (sqlite3_int64)n;  /* Work around bug in Borland C. Ticket #3216 */\n  return res;\n}\n\n/*\n** Return the maximum amount of memory that has ever been\n** checked out since either the beginning of this process\n** or since the most recent reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){\n  int n, mx;\n  sqlite3_int64 res;\n  sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);\n  res = (sqlite3_int64)mx;  /* Work around bug in Borland C. Ticket #3216 */\n  return res;\n}\n\n/*\n** Trigger the alarm \n*/\nstatic void sqlite3MallocAlarm(int nByte){\n  void (*xCallback)(void*,sqlite3_int64,int);\n  sqlite3_int64 nowUsed;\n  void *pArg;\n  if( mem0.alarmCallback==0 ) return;\n  xCallback = mem0.alarmCallback;\n  nowUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n  pArg = mem0.alarmArg;\n  mem0.alarmCallback = 0;\n  sqlite3_mutex_leave(mem0.mutex);\n  xCallback(pArg, nowUsed, nByte);\n  sqlite3_mutex_enter(mem0.mutex);\n  mem0.alarmCallback = xCallback;\n  mem0.alarmArg = pArg;\n}\n\n/*\n** Do a memory allocation with statistics and alarms.  Assume the\n** lock is already held.\n*/\nstatic int mallocWithAlarm(int n, void **pp){\n  int nFull;\n  void *p;\n  assert( sqlite3_mutex_held(mem0.mutex) );\n  nFull = sqlite3GlobalConfig.m.xRoundup(n);\n  sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);\n  if( mem0.alarmCallback!=0 ){\n    int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n    if( nUsed >= mem0.alarmThreshold - nFull ){\n      mem0.nearlyFull = 1;\n      sqlite3MallocAlarm(nFull);\n    }else{\n      mem0.nearlyFull = 0;\n    }\n  }\n  p = sqlite3GlobalConfig.m.xMalloc(nFull);\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  if( p==0 && mem0.alarmCallback ){\n    sqlite3MallocAlarm(nFull);\n    p = sqlite3GlobalConfig.m.xMalloc(nFull);\n  }\n#endif\n  if( p ){\n    nFull = sqlite3MallocSize(p);\n    sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);\n    sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);\n  }\n  *pp = p;\n  return nFull;\n}\n\n/*\n** Allocate memory.  This routine is like sqlite3_malloc() except that it\n** assumes the memory subsystem has already been initialized.\n*/\nSQLITE_PRIVATE void *sqlite3Malloc(int n){\n  void *p;\n  if( n<=0               /* IMP: R-65312-04917 */ \n   || n>=0x7fffff00\n  ){\n    /* A memory allocation of a number of bytes which is near the maximum\n    ** signed integer value might cause an integer overflow inside of the\n    ** xMalloc().  Hence we limit the maximum size to 0x7fffff00, giving\n    ** 255 bytes of overhead.  SQLite itself will never use anything near\n    ** this amount.  The only way to reach the limit is with sqlite3_malloc() */\n    p = 0;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    mallocWithAlarm(n, &p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    p = sqlite3GlobalConfig.m.xMalloc(n);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-04675-44850 */\n  return p;\n}\n\n/*\n** This version of the memory allocation is for use by the application.\n** First make sure the memory subsystem is initialized, then do the\n** allocation.\n*/\nSQLITE_API void *sqlite3_malloc(int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Malloc(n);\n}\n\n/*\n** Each thread may only have a single outstanding allocation from\n** xScratchMalloc().  We verify this constraint in the single-threaded\n** case by setting scratchAllocOut to 1 when an allocation\n** is outstanding clearing it when the allocation is freed.\n*/\n#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)\nstatic int scratchAllocOut = 0;\n#endif\n\n\n/*\n** Allocate memory that is to be used and released right away.\n** This routine is similar to alloca() in that it is not intended\n** for situations where the memory might be held long-term.  This\n** routine is intended to get memory to old large transient data\n** structures that would not normally fit on the stack of an\n** embedded processor.\n*/\nSQLITE_PRIVATE void *sqlite3ScratchMalloc(int n){\n  void *p;\n  assert( n>0 );\n\n  sqlite3_mutex_enter(mem0.mutex);\n  if( mem0.nScratchFree && sqlite3GlobalConfig.szScratch>=n ){\n    p = mem0.pScratchFree;\n    mem0.pScratchFree = mem0.pScratchFree->pNext;\n    mem0.nScratchFree--;\n    sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);\n    sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    if( sqlite3GlobalConfig.bMemstat ){\n      sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);\n      n = mallocWithAlarm(n, &p);\n      if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);\n      sqlite3_mutex_leave(mem0.mutex);\n    }else{\n      sqlite3_mutex_leave(mem0.mutex);\n      p = sqlite3GlobalConfig.m.xMalloc(n);\n    }\n    sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);\n  }\n  assert( sqlite3_mutex_notheld(mem0.mutex) );\n\n\n#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)\n  /* Verify that no more than two scratch allocations per thread\n  ** are outstanding at one time.  (This is only checked in the\n  ** single-threaded case since checking in the multi-threaded case\n  ** would be much more complicated.) */\n  assert( scratchAllocOut<=1 );\n  if( p ) scratchAllocOut++;\n#endif\n\n  return p;\n}\nSQLITE_PRIVATE void sqlite3ScratchFree(void *p){\n  if( p ){\n\n#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)\n    /* Verify that no more than two scratch allocation per thread\n    ** is outstanding at one time.  (This is only checked in the\n    ** single-threaded case since checking in the multi-threaded case\n    ** would be much more complicated.) */\n    assert( scratchAllocOut>=1 && scratchAllocOut<=2 );\n    scratchAllocOut--;\n#endif\n\n    if( p>=sqlite3GlobalConfig.pScratch && p<mem0.pScratchEnd ){\n      /* Release memory from the SQLITE_CONFIG_SCRATCH allocation */\n      ScratchFreeslot *pSlot;\n      pSlot = (ScratchFreeslot*)p;\n      sqlite3_mutex_enter(mem0.mutex);\n      pSlot->pNext = mem0.pScratchFree;\n      mem0.pScratchFree = pSlot;\n      mem0.nScratchFree++;\n      assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );\n      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);\n      sqlite3_mutex_leave(mem0.mutex);\n    }else{\n      /* Release memory back to the heap */\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );\n      assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );\n      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n      if( sqlite3GlobalConfig.bMemstat ){\n        int iSize = sqlite3MallocSize(p);\n        sqlite3_mutex_enter(mem0.mutex);\n        sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);\n        sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);\n        sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);\n        sqlite3GlobalConfig.m.xFree(p);\n        sqlite3_mutex_leave(mem0.mutex);\n      }else{\n        sqlite3GlobalConfig.m.xFree(p);\n      }\n    }\n  }\n}\n\n/*\n** TRUE if p is a lookaside memory allocation from db\n*/\n#ifndef SQLITE_OMIT_LOOKASIDE\nstatic int isLookaside(sqlite3 *db, void *p){\n  return p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;\n}\n#else\n#define isLookaside(A,B) 0\n#endif\n\n/*\n** Return the size of a memory allocation previously obtained from\n** sqlite3Malloc() or sqlite3_malloc().\n*/\nSQLITE_PRIVATE int sqlite3MallocSize(void *p){\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );\n  return sqlite3GlobalConfig.m.xSize(p);\n}\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  if( db && isLookaside(db, p) ){\n    return db->lookaside.sz;\n  }else{\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );\n    assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n    return sqlite3GlobalConfig.m.xSize(p);\n  }\n}\n\n/*\n** Free memory previously obtained from sqlite3Malloc().\n*/\nSQLITE_API void sqlite3_free(void *p){\n  if( p==0 ) return;  /* IMP: R-49053-54554 */\n  assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));\n    sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);\n    sqlite3GlobalConfig.m.xFree(p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    sqlite3GlobalConfig.m.xFree(p);\n  }\n}\n\n/*\n** Free memory that might be associated with a particular database\n** connection.\n*/\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  if( db ){\n    if( db->pnBytesFreed ){\n      *db->pnBytesFreed += sqlite3DbMallocSize(db, p);\n      return;\n    }\n    if( isLookaside(db, p) ){\n      LookasideSlot *pBuf = (LookasideSlot*)p;\n#if SQLITE_DEBUG\n      /* Trash all content in the buffer being freed */\n      memset(p, 0xaa, db->lookaside.sz);\n#endif\n      pBuf->pNext = db->lookaside.pFree;\n      db->lookaside.pFree = pBuf;\n      db->lookaside.nOut--;\n      return;\n    }\n  }\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );\n  assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  sqlite3_free(p);\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nSQLITE_PRIVATE void *sqlite3Realloc(void *pOld, int nBytes){\n  int nOld, nNew, nDiff;\n  void *pNew;\n  if( pOld==0 ){\n    return sqlite3Malloc(nBytes); /* IMP: R-28354-25769 */\n  }\n  if( nBytes<=0 ){\n    sqlite3_free(pOld); /* IMP: R-31593-10574 */\n    return 0;\n  }\n  if( nBytes>=0x7fffff00 ){\n    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */\n    return 0;\n  }\n  nOld = sqlite3MallocSize(pOld);\n  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second\n  ** argument to xRealloc is always a value returned by a prior call to\n  ** xRoundup. */\n  nNew = sqlite3GlobalConfig.m.xRoundup(nBytes);\n  if( nOld==nNew ){\n    pNew = pOld;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes);\n    nDiff = nNew - nOld;\n    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= \n          mem0.alarmThreshold-nDiff ){\n      sqlite3MallocAlarm(nDiff);\n    }\n    assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );\n    assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    if( pNew==0 && mem0.alarmCallback ){\n      sqlite3MallocAlarm(nBytes);\n      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    }\n    if( pNew ){\n      nNew = sqlite3MallocSize(pNew);\n      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);\n    }\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-04675-44850 */\n  return pNew;\n}\n\n/*\n** The public interface to sqlite3Realloc.  Make sure that the memory\n** subsystem is initialized prior to invoking sqliteRealloc.\n*/\nSQLITE_API void *sqlite3_realloc(void *pOld, int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Realloc(pOld, n);\n}\n\n\n/*\n** Allocate and zero memory.\n*/ \nSQLITE_PRIVATE void *sqlite3MallocZero(int n){\n  void *p = sqlite3Malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\n\n/*\n** Allocate and zero memory.  If the allocation fails, make\n** the mallocFailed flag in the connection pointer.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, int n){\n  void *p = sqlite3DbMallocRaw(db, n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\n\n/*\n** Allocate and zero memory.  If the allocation fails, make\n** the mallocFailed flag in the connection pointer.\n**\n** If db!=0 and db->mallocFailed is true (indicating a prior malloc\n** failure on the same database connection) then always return 0.\n** Hence for a particular database connection, once malloc starts\n** failing, it fails consistently until mallocFailed is reset.\n** This is an important assumption.  There are many places in the\n** code that do things like this:\n**\n**         int *a = (int*)sqlite3DbMallocRaw(db, 100);\n**         int *b = (int*)sqlite3DbMallocRaw(db, 200);\n**         if( b ) a[10] = 9;\n**\n** In other words, if a subsequent malloc (ex: \"b\") worked, it is assumed\n** that all prior mallocs (ex: \"a\") worked too.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, int n){\n  void *p;\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  assert( db==0 || db->pnBytesFreed==0 );\n#ifndef SQLITE_OMIT_LOOKASIDE\n  if( db ){\n    LookasideSlot *pBuf;\n    if( db->mallocFailed ){\n      return 0;\n    }\n    if( db->lookaside.bEnabled ){\n      if( n>db->lookaside.sz ){\n        db->lookaside.anStat[1]++;\n      }else if( (pBuf = db->lookaside.pFree)==0 ){\n        db->lookaside.anStat[2]++;\n      }else{\n        db->lookaside.pFree = pBuf->pNext;\n        db->lookaside.nOut++;\n        db->lookaside.anStat[0]++;\n        if( db->lookaside.nOut>db->lookaside.mxOut ){\n          db->lookaside.mxOut = db->lookaside.nOut;\n        }\n        return (void*)pBuf;\n      }\n    }\n  }\n#else\n  if( db && db->mallocFailed ){\n    return 0;\n  }\n#endif\n  p = sqlite3Malloc(n);\n  if( !p && db ){\n    db->mallocFailed = 1;\n  }\n  sqlite3MemdebugSetType(p, MEMTYPE_DB |\n         ((db && db->lookaside.bEnabled) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));\n  return p;\n}\n\n/*\n** Resize the block of memory pointed to by p to n bytes. If the\n** resize fails, set the mallocFailed flag in the connection object.\n*/\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, int n){\n  void *pNew = 0;\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->mallocFailed==0 ){\n    if( p==0 ){\n      return sqlite3DbMallocRaw(db, n);\n    }\n    if( isLookaside(db, p) ){\n      if( n<=db->lookaside.sz ){\n        return p;\n      }\n      pNew = sqlite3DbMallocRaw(db, n);\n      if( pNew ){\n        memcpy(pNew, p, db->lookaside.sz);\n        sqlite3DbFree(db, p);\n      }\n    }else{\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_DB) );\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_LOOKASIDE|MEMTYPE_HEAP) );\n      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n      pNew = sqlite3_realloc(p, n);\n      if( !pNew ){\n        sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP);\n        db->mallocFailed = 1;\n      }\n      sqlite3MemdebugSetType(pNew, MEMTYPE_DB | \n            (db->lookaside.bEnabled ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));\n    }\n  }\n  return pNew;\n}\n\n/*\n** Attempt to reallocate p.  If the reallocation fails, then free p\n** and set the mallocFailed flag in the database connection.\n*/\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *db, void *p, int n){\n  void *pNew;\n  pNew = sqlite3DbRealloc(db, p, n);\n  if( !pNew ){\n    sqlite3DbFree(db, p);\n  }\n  return pNew;\n}\n\n/*\n** Make a copy of a string in memory obtained from sqliteMalloc(). These \n** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This\n** is because when memory debugging is turned on, these two functions are \n** called via macros that record the current file and line number in the\n** ThreadData structure.\n*/\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3 *db, const char *z){\n  char *zNew;\n  size_t n;\n  if( z==0 ){\n    return 0;\n  }\n  n = sqlite3Strlen30(z) + 1;\n  assert( (n&0x7fffffff)==n );\n  zNew = sqlite3DbMallocRaw(db, (int)n);\n  if( zNew ){\n    memcpy(zNew, z, n);\n  }\n  return zNew;\n}\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, int n){\n  char *zNew;\n  if( z==0 ){\n    return 0;\n  }\n  assert( (n&0x7fffffff)==n );\n  zNew = sqlite3DbMallocRaw(db, n+1);\n  if( zNew ){\n    memcpy(zNew, z, n);\n    zNew[n] = 0;\n  }\n  return zNew;\n}\n\n/*\n** Create a string from the zFromat argument and the va_list that follows.\n** Store the string in memory obtained from sqliteMalloc() and make *pz\n** point to that string.\n*/\nSQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  sqlite3DbFree(db, *pz);\n  *pz = z;\n}\n\n\n/*\n** This function must be called before exiting any API function (i.e. \n** returning control to the user) that has called sqlite3_malloc or\n** sqlite3_realloc.\n**\n** The returned value is normally a copy of the second argument to this\n** function. However, if a malloc() failure has occurred since the previous\n** invocation SQLITE_NOMEM is returned instead. \n**\n** If the first argument, db, is not NULL and a malloc() error has occurred,\n** then the connection error-code (the value returned by sqlite3_errcode())\n** is set to SQLITE_NOMEM.\n*/\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){\n  /* If the db handle is not NULL, then we must hold the connection handle\n  ** mutex here. Otherwise the read (and possible write) of db->mallocFailed \n  ** is unsafe, as is the call to sqlite3Error().\n  */\n  assert( !db || sqlite3_mutex_held(db->mutex) );\n  if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){\n    sqlite3Error(db, SQLITE_NOMEM, 0);\n    db->mallocFailed = 0;\n    rc = SQLITE_NOMEM;\n  }\n  return rc & (db ? db->errMask : 0xff);\n}\n\n/************** End of malloc.c **********************************************/\n/************** Begin file printf.c ******************************************/\n/*\n** The \"printf\" code that follows dates from the 1980's.  It is in\n** the public domain.  The original comments are included here for\n** completeness.  They are very out-of-date but might be useful as\n** an historical reference.  Most of the \"enhancements\" have been backed\n** out so that the functionality is now the same as standard printf().\n**\n**************************************************************************\n**\n** This file contains code for a set of \"printf\"-like routines.  These\n** routines format strings much like the printf() from the standard C\n** library, though the implementation here has enhancements to support\n** SQLlite.\n*/\n\n/*\n** Conversion types fall into various categories as defined by the\n** following enumeration.\n*/\n#define etRADIX       1 /* Integer types.  %d, %x, %o, and so forth */\n#define etFLOAT       2 /* Floating point.  %f */\n#define etEXP         3 /* Exponentional notation. %e and %E */\n#define etGENERIC     4 /* Floating or exponential, depending on exponent. %g */\n#define etSIZE        5 /* Return number of characters processed so far. %n */\n#define etSTRING      6 /* Strings. %s */\n#define etDYNSTRING   7 /* Dynamically allocated strings. %z */\n#define etPERCENT     8 /* Percent symbol. %% */\n#define etCHARX       9 /* Characters. %c */\n/* The rest are extensions, not normally found in printf() */\n#define etSQLESCAPE  10 /* Strings with '\\'' doubled.  %q */\n#define etSQLESCAPE2 11 /* Strings with '\\'' doubled and enclosed in '',\n                          NULL pointers replaced by SQL NULL.  %Q */\n#define etTOKEN      12 /* a pointer to a Token structure */\n#define etSRCLIST    13 /* a pointer to a SrcList */\n#define etPOINTER    14 /* The %p conversion */\n#define etSQLESCAPE3 15 /* %w -> Strings with '\\\"' doubled */\n#define etORDINAL    16 /* %r -> 1st, 2nd, 3rd, 4th, etc.  English only */\n\n#define etINVALID     0 /* Any unrecognized conversion type */\n\n\n/*\n** An \"etByte\" is an 8-bit unsigned value.\n*/\ntypedef unsigned char etByte;\n\n/*\n** Each builtin conversion character (ex: the 'd' in \"%d\") is described\n** by an instance of the following structure\n*/\ntypedef struct et_info {   /* Information about each format field */\n  char fmttype;            /* The format field code letter */\n  etByte base;             /* The base for radix conversion */\n  etByte flags;            /* One or more of FLAG_ constants below */\n  etByte type;             /* Conversion paradigm */\n  etByte charset;          /* Offset into aDigits[] of the digits string */\n  etByte prefix;           /* Offset into aPrefix[] of the prefix string */\n} et_info;\n\n/*\n** Allowed values for et_info.flags\n*/\n#define FLAG_SIGNED  1     /* True if the value to convert is signed */\n#define FLAG_INTERN  2     /* True if for internal use only */\n#define FLAG_STRING  4     /* Allow infinity precision */\n\n\n/*\n** The following table is searched linearly, so it is good to put the\n** most frequently used conversion types first.\n*/\nstatic const char aDigits[] = \"0123456789ABCDEF0123456789abcdef\";\nstatic const char aPrefix[] = \"-x0\\000X0\";\nstatic const et_info fmtinfo[] = {\n  {  'd', 10, 1, etRADIX,      0,  0 },\n  {  's',  0, 4, etSTRING,     0,  0 },\n  {  'g',  0, 1, etGENERIC,    30, 0 },\n  {  'z',  0, 4, etDYNSTRING,  0,  0 },\n  {  'q',  0, 4, etSQLESCAPE,  0,  0 },\n  {  'Q',  0, 4, etSQLESCAPE2, 0,  0 },\n  {  'w',  0, 4, etSQLESCAPE3, 0,  0 },\n  {  'c',  0, 0, etCHARX,      0,  0 },\n  {  'o',  8, 0, etRADIX,      0,  2 },\n  {  'u', 10, 0, etRADIX,      0,  0 },\n  {  'x', 16, 0, etRADIX,      16, 1 },\n  {  'X', 16, 0, etRADIX,      0,  4 },\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  {  'f',  0, 1, etFLOAT,      0,  0 },\n  {  'e',  0, 1, etEXP,        30, 0 },\n  {  'E',  0, 1, etEXP,        14, 0 },\n  {  'G',  0, 1, etGENERIC,    14, 0 },\n#endif\n  {  'i', 10, 1, etRADIX,      0,  0 },\n  {  'n',  0, 0, etSIZE,       0,  0 },\n  {  '%',  0, 0, etPERCENT,    0,  0 },\n  {  'p', 16, 0, etPOINTER,    0,  1 },\n\n/* All the rest have the FLAG_INTERN bit set and are thus for internal\n** use only */\n  {  'T',  0, 2, etTOKEN,      0,  0 },\n  {  'S',  0, 2, etSRCLIST,    0,  0 },\n  {  'r', 10, 3, etORDINAL,    0,  0 },\n};\n\n/*\n** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point\n** conversions will work.\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** \"*val\" is a double such that 0.1 <= *val < 10.0\n** Return the ascii code for the leading digit of *val, then\n** multiply \"*val\" by 10.0 to renormalize.\n**\n** Example:\n**     input:     *val = 3.14159\n**     output:    *val = 1.4159    function return = '3'\n**\n** The counter *cnt is incremented each time.  After counter exceeds\n** 16 (the number of significant digits in a 64-bit float) '0' is\n** always returned.\n*/\nstatic char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){\n  int digit;\n  LONGDOUBLE_TYPE d;\n  if( (*cnt)<=0 ) return '0';\n  (*cnt)--;\n  digit = (int)*val;\n  d = digit;\n  digit += '0';\n  *val = (*val - d)*10.0;\n  return (char)digit;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Append N space characters to the given string buffer.\n*/\nSQLITE_PRIVATE void sqlite3AppendSpace(StrAccum *pAccum, int N){\n  static const char zSpaces[] = \"                             \";\n  while( N>=(int)sizeof(zSpaces)-1 ){\n    sqlite3StrAccumAppend(pAccum, zSpaces, sizeof(zSpaces)-1);\n    N -= sizeof(zSpaces)-1;\n  }\n  if( N>0 ){\n    sqlite3StrAccumAppend(pAccum, zSpaces, N);\n  }\n}\n\n/*\n** On machines with a small stack size, you can redefine the\n** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.\n*/\n#ifndef SQLITE_PRINT_BUF_SIZE\n# define SQLITE_PRINT_BUF_SIZE 70\n#endif\n#define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */\n\n/*\n** Render a string given by \"fmt\" into the StrAccum object.\n*/\nSQLITE_PRIVATE void sqlite3VXPrintf(\n  StrAccum *pAccum,                  /* Accumulate results here */\n  int useExtended,                   /* Allow extended %-conversions */\n  const char *fmt,                   /* Format string */\n  va_list ap                         /* arguments */\n){\n  int c;                     /* Next character in the format string */\n  char *bufpt;               /* Pointer to the conversion buffer */\n  int precision;             /* Precision of the current field */\n  int length;                /* Length of the field */\n  int idx;                   /* A general purpose loop counter */\n  int width;                 /* Width of the current field */\n  etByte flag_leftjustify;   /* True if \"-\" flag is present */\n  etByte flag_plussign;      /* True if \"+\" flag is present */\n  etByte flag_blanksign;     /* True if \" \" flag is present */\n  etByte flag_alternateform; /* True if \"#\" flag is present */\n  etByte flag_altform2;      /* True if \"!\" flag is present */\n  etByte flag_zeropad;       /* True if field width constant starts with zero */\n  etByte flag_long;          /* True if \"l\" flag is present */\n  etByte flag_longlong;      /* True if the \"ll\" flag is present */\n  etByte done;               /* Loop termination flag */\n  etByte xtype = 0;          /* Conversion paradigm */\n  char prefix;               /* Prefix character.  \"+\" or \"-\" or \" \" or '\\0'. */\n  sqlite_uint64 longvalue;   /* Value for integer types */\n  LONGDOUBLE_TYPE realvalue; /* Value for real types */\n  const et_info *infop;      /* Pointer to the appropriate info structure */\n  char *zOut;                /* Rendering buffer */\n  int nOut;                  /* Size of the rendering buffer */\n  char *zExtra;              /* Malloced memory used by some conversion */\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int  exp, e2;              /* exponent of real numbers */\n  int nsd;                   /* Number of significant digits returned */\n  double rounder;            /* Used for rounding floating point values */\n  etByte flag_dp;            /* True if decimal point should be shown */\n  etByte flag_rtz;           /* True if trailing zeros should be removed */\n#endif\n  char buf[etBUFSIZE];       /* Conversion buffer */\n\n  bufpt = 0;\n  for(; (c=(*fmt))!=0; ++fmt){\n    if( c!='%' ){\n      int amt;\n      bufpt = (char *)fmt;\n      amt = 1;\n      while( (c=(*++fmt))!='%' && c!=0 ) amt++;\n      sqlite3StrAccumAppend(pAccum, bufpt, amt);\n      if( c==0 ) break;\n    }\n    if( (c=(*++fmt))==0 ){\n      sqlite3StrAccumAppend(pAccum, \"%\", 1);\n      break;\n    }\n    /* Find out what flags are present */\n    flag_leftjustify = flag_plussign = flag_blanksign = \n     flag_alternateform = flag_altform2 = flag_zeropad = 0;\n    done = 0;\n    do{\n      switch( c ){\n        case '-':   flag_leftjustify = 1;     break;\n        case '+':   flag_plussign = 1;        break;\n        case ' ':   flag_blanksign = 1;       break;\n        case '#':   flag_alternateform = 1;   break;\n        case '!':   flag_altform2 = 1;        break;\n        case '0':   flag_zeropad = 1;         break;\n        default:    done = 1;                 break;\n      }\n    }while( !done && (c=(*++fmt))!=0 );\n    /* Get the field width */\n    width = 0;\n    if( c=='*' ){\n      width = va_arg(ap,int);\n      if( width<0 ){\n        flag_leftjustify = 1;\n        width = -width;\n      }\n      c = *++fmt;\n    }else{\n      while( c>='0' && c<='9' ){\n        width = width*10 + c - '0';\n        c = *++fmt;\n      }\n    }\n    /* Get the precision */\n    if( c=='.' ){\n      precision = 0;\n      c = *++fmt;\n      if( c=='*' ){\n        precision = va_arg(ap,int);\n        if( precision<0 ) precision = -precision;\n        c = *++fmt;\n      }else{\n        while( c>='0' && c<='9' ){\n          precision = precision*10 + c - '0';\n          c = *++fmt;\n        }\n      }\n    }else{\n      precision = -1;\n    }\n    /* Get the conversion type modifier */\n    if( c=='l' ){\n      flag_long = 1;\n      c = *++fmt;\n      if( c=='l' ){\n        flag_longlong = 1;\n        c = *++fmt;\n      }else{\n        flag_longlong = 0;\n      }\n    }else{\n      flag_long = flag_longlong = 0;\n    }\n    /* Fetch the info entry for the field */\n    infop = &fmtinfo[0];\n    xtype = etINVALID;\n    for(idx=0; idx<ArraySize(fmtinfo); idx++){\n      if( c==fmtinfo[idx].fmttype ){\n        infop = &fmtinfo[idx];\n        if( useExtended || (infop->flags & FLAG_INTERN)==0 ){\n          xtype = infop->type;\n        }else{\n          return;\n        }\n        break;\n      }\n    }\n    zExtra = 0;\n\n    /*\n    ** At this point, variables are initialized as follows:\n    **\n    **   flag_alternateform          TRUE if a '#' is present.\n    **   flag_altform2               TRUE if a '!' is present.\n    **   flag_plussign               TRUE if a '+' is present.\n    **   flag_leftjustify            TRUE if a '-' is present or if the\n    **                               field width was negative.\n    **   flag_zeropad                TRUE if the width began with 0.\n    **   flag_long                   TRUE if the letter 'l' (ell) prefixed\n    **                               the conversion character.\n    **   flag_longlong               TRUE if the letter 'll' (ell ell) prefixed\n    **                               the conversion character.\n    **   flag_blanksign              TRUE if a ' ' is present.\n    **   width                       The specified field width.  This is\n    **                               always non-negative.  Zero is the default.\n    **   precision                   The specified precision.  The default\n    **                               is -1.\n    **   xtype                       The class of the conversion.\n    **   infop                       Pointer to the appropriate info struct.\n    */\n    switch( xtype ){\n      case etPOINTER:\n        flag_longlong = sizeof(char*)==sizeof(i64);\n        flag_long = sizeof(char*)==sizeof(long int);\n        /* Fall through into the next case */\n      case etORDINAL:\n      case etRADIX:\n        if( infop->flags & FLAG_SIGNED ){\n          i64 v;\n          if( flag_longlong ){\n            v = va_arg(ap,i64);\n          }else if( flag_long ){\n            v = va_arg(ap,long int);\n          }else{\n            v = va_arg(ap,int);\n          }\n          if( v<0 ){\n            if( v==SMALLEST_INT64 ){\n              longvalue = ((u64)1)<<63;\n            }else{\n              longvalue = -v;\n            }\n            prefix = '-';\n          }else{\n            longvalue = v;\n            if( flag_plussign )        prefix = '+';\n            else if( flag_blanksign )  prefix = ' ';\n            else                       prefix = 0;\n          }\n        }else{\n          if( flag_longlong ){\n            longvalue = va_arg(ap,u64);\n          }else if( flag_long ){\n            longvalue = va_arg(ap,unsigned long int);\n          }else{\n            longvalue = va_arg(ap,unsigned int);\n          }\n          prefix = 0;\n        }\n        if( longvalue==0 ) flag_alternateform = 0;\n        if( flag_zeropad && precision<width-(prefix!=0) ){\n          precision = width-(prefix!=0);\n        }\n        if( precision<etBUFSIZE-10 ){\n          nOut = etBUFSIZE;\n          zOut = buf;\n        }else{\n          nOut = precision + 10;\n          zOut = zExtra = sqlite3Malloc( nOut );\n          if( zOut==0 ){\n            pAccum->mallocFailed = 1;\n            return;\n          }\n        }\n        bufpt = &zOut[nOut-1];\n        if( xtype==etORDINAL ){\n          static const char zOrd[] = \"thstndrd\";\n          int x = (int)(longvalue % 10);\n          if( x>=4 || (longvalue/10)%10==1 ){\n            x = 0;\n          }\n          *(--bufpt) = zOrd[x*2+1];\n          *(--bufpt) = zOrd[x*2];\n        }\n        {\n          register const char *cset;      /* Use registers for speed */\n          register int base;\n          cset = &aDigits[infop->charset];\n          base = infop->base;\n          do{                                           /* Convert to ascii */\n            *(--bufpt) = cset[longvalue%base];\n            longvalue = longvalue/base;\n          }while( longvalue>0 );\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        for(idx=precision-length; idx>0; idx--){\n          *(--bufpt) = '0';                             /* Zero pad */\n        }\n        if( prefix ) *(--bufpt) = prefix;               /* Add sign */\n        if( flag_alternateform && infop->prefix ){      /* Add \"0\" or \"0x\" */\n          const char *pre;\n          char x;\n          pre = &aPrefix[infop->prefix];\n          for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        break;\n      case etFLOAT:\n      case etEXP:\n      case etGENERIC:\n        realvalue = va_arg(ap,double);\n#ifdef SQLITE_OMIT_FLOATING_POINT\n        length = 0;\n#else\n        if( precision<0 ) precision = 6;         /* Set default precision */\n        if( realvalue<0.0 ){\n          realvalue = -realvalue;\n          prefix = '-';\n        }else{\n          if( flag_plussign )          prefix = '+';\n          else if( flag_blanksign )    prefix = ' ';\n          else                         prefix = 0;\n        }\n        if( xtype==etGENERIC && precision>0 ) precision--;\n#if 0\n        /* Rounding works like BSD when the constant 0.4999 is used.  Wierd! */\n        for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1);\n#else\n        /* It makes more sense to use 0.5 */\n        for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}\n#endif\n        if( xtype==etFLOAT ) realvalue += rounder;\n        /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */\n        exp = 0;\n        if( sqlite3IsNaN((double)realvalue) ){\n          bufpt = \"NaN\";\n          length = 3;\n          break;\n        }\n        if( realvalue>0.0 ){\n          LONGDOUBLE_TYPE scale = 1.0;\n          while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;}\n          while( realvalue>=1e64*scale && exp<=350 ){ scale *= 1e64; exp+=64; }\n          while( realvalue>=1e8*scale && exp<=350 ){ scale *= 1e8; exp+=8; }\n          while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }\n          realvalue /= scale;\n          while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }\n          while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }\n          if( exp>350 ){\n            if( prefix=='-' ){\n              bufpt = \"-Inf\";\n            }else if( prefix=='+' ){\n              bufpt = \"+Inf\";\n            }else{\n              bufpt = \"Inf\";\n            }\n            length = sqlite3Strlen30(bufpt);\n            break;\n          }\n        }\n        bufpt = buf;\n        /*\n        ** If the field type is etGENERIC, then convert to either etEXP\n        ** or etFLOAT, as appropriate.\n        */\n        if( xtype!=etFLOAT ){\n          realvalue += rounder;\n          if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }\n        }\n        if( xtype==etGENERIC ){\n          flag_rtz = !flag_alternateform;\n          if( exp<-4 || exp>precision ){\n            xtype = etEXP;\n          }else{\n            precision = precision - exp;\n            xtype = etFLOAT;\n          }\n        }else{\n          flag_rtz = flag_altform2;\n        }\n        if( xtype==etEXP ){\n          e2 = 0;\n        }else{\n          e2 = exp;\n        }\n        if( e2+precision+width > etBUFSIZE - 15 ){\n          bufpt = zExtra = sqlite3Malloc( e2+precision+width+15 );\n          if( bufpt==0 ){\n            pAccum->mallocFailed = 1;\n            return;\n          }\n        }\n        zOut = bufpt;\n        nsd = 16 + flag_altform2*10;\n        flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;\n        /* The sign in front of the number */\n        if( prefix ){\n          *(bufpt++) = prefix;\n        }\n        /* Digits prior to the decimal point */\n        if( e2<0 ){\n          *(bufpt++) = '0';\n        }else{\n          for(; e2>=0; e2--){\n            *(bufpt++) = et_getdigit(&realvalue,&nsd);\n          }\n        }\n        /* The decimal point */\n        if( flag_dp ){\n          *(bufpt++) = '.';\n        }\n        /* \"0\" digits after the decimal point but before the first\n        ** significant digit of the number */\n        for(e2++; e2<0; precision--, e2++){\n          assert( precision>0 );\n          *(bufpt++) = '0';\n        }\n        /* Significant digits after the decimal point */\n        while( (precision--)>0 ){\n          *(bufpt++) = et_getdigit(&realvalue,&nsd);\n        }\n        /* Remove trailing zeros and the \".\" if no digits follow the \".\" */\n        if( flag_rtz && flag_dp ){\n          while( bufpt[-1]=='0' ) *(--bufpt) = 0;\n          assert( bufpt>zOut );\n          if( bufpt[-1]=='.' ){\n            if( flag_altform2 ){\n              *(bufpt++) = '0';\n            }else{\n              *(--bufpt) = 0;\n            }\n          }\n        }\n        /* Add the \"eNNN\" suffix */\n        if( xtype==etEXP ){\n          *(bufpt++) = aDigits[infop->charset];\n          if( exp<0 ){\n            *(bufpt++) = '-'; exp = -exp;\n          }else{\n            *(bufpt++) = '+';\n          }\n          if( exp>=100 ){\n            *(bufpt++) = (char)((exp/100)+'0');        /* 100's digit */\n            exp %= 100;\n          }\n          *(bufpt++) = (char)(exp/10+'0');             /* 10's digit */\n          *(bufpt++) = (char)(exp%10+'0');             /* 1's digit */\n        }\n        *bufpt = 0;\n\n        /* The converted number is in buf[] and zero terminated. Output it.\n        ** Note that the number is in the usual order, not reversed as with\n        ** integer conversions. */\n        length = (int)(bufpt-zOut);\n        bufpt = zOut;\n\n        /* Special case:  Add leading zeros if the flag_zeropad flag is\n        ** set and we are not left justified */\n        if( flag_zeropad && !flag_leftjustify && length < width){\n          int i;\n          int nPad = width - length;\n          for(i=width; i>=nPad; i--){\n            bufpt[i] = bufpt[i-nPad];\n          }\n          i = prefix!=0;\n          while( nPad-- ) bufpt[i++] = '0';\n          length = width;\n        }\n#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */\n        break;\n      case etSIZE:\n        *(va_arg(ap,int*)) = pAccum->nChar;\n        length = width = 0;\n        break;\n      case etPERCENT:\n        buf[0] = '%';\n        bufpt = buf;\n        length = 1;\n        break;\n      case etCHARX:\n        c = va_arg(ap,int);\n        buf[0] = (char)c;\n        if( precision>=0 ){\n          for(idx=1; idx<precision; idx++) buf[idx] = (char)c;\n          length = precision;\n        }else{\n          length =1;\n        }\n        bufpt = buf;\n        break;\n      case etSTRING:\n      case etDYNSTRING:\n        bufpt = va_arg(ap,char*);\n        if( bufpt==0 ){\n          bufpt = \"\";\n        }else if( xtype==etDYNSTRING ){\n          zExtra = bufpt;\n        }\n        if( precision>=0 ){\n          for(length=0; length<precision && bufpt[length]; length++){}\n        }else{\n          length = sqlite3Strlen30(bufpt);\n        }\n        break;\n      case etSQLESCAPE:\n      case etSQLESCAPE2:\n      case etSQLESCAPE3: {\n        int i, j, k, n, isnull;\n        int needQuote;\n        char ch;\n        char q = ((xtype==etSQLESCAPE3)?'\"':'\\'');   /* Quote character */\n        char *escarg = va_arg(ap,char*);\n        isnull = escarg==0;\n        if( isnull ) escarg = (xtype==etSQLESCAPE2 ? \"NULL\" : \"(NULL)\");\n        k = precision;\n        for(i=n=0; k!=0 && (ch=escarg[i])!=0; i++, k--){\n          if( ch==q )  n++;\n        }\n        needQuote = !isnull && xtype==etSQLESCAPE2;\n        n += i + 1 + needQuote*2;\n        if( n>etBUFSIZE ){\n          bufpt = zExtra = sqlite3Malloc( n );\n          if( bufpt==0 ){\n            pAccum->mallocFailed = 1;\n            return;\n          }\n        }else{\n          bufpt = buf;\n        }\n        j = 0;\n        if( needQuote ) bufpt[j++] = q;\n        k = i;\n        for(i=0; i<k; i++){\n          bufpt[j++] = ch = escarg[i];\n          if( ch==q ) bufpt[j++] = ch;\n        }\n        if( needQuote ) bufpt[j++] = q;\n        bufpt[j] = 0;\n        length = j;\n        /* The precision in %q and %Q means how many input characters to\n        ** consume, not the length of the output...\n        ** if( precision>=0 && precision<length ) length = precision; */\n        break;\n      }\n      case etTOKEN: {\n        Token *pToken = va_arg(ap, Token*);\n        if( pToken ){\n          sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);\n        }\n        length = width = 0;\n        break;\n      }\n      case etSRCLIST: {\n        SrcList *pSrc = va_arg(ap, SrcList*);\n        int k = va_arg(ap, int);\n        struct SrcList_item *pItem = &pSrc->a[k];\n        assert( k>=0 && k<pSrc->nSrc );\n        if( pItem->zDatabase ){\n          sqlite3StrAccumAppend(pAccum, pItem->zDatabase, -1);\n          sqlite3StrAccumAppend(pAccum, \".\", 1);\n        }\n        sqlite3StrAccumAppend(pAccum, pItem->zName, -1);\n        length = width = 0;\n        break;\n      }\n      default: {\n        assert( xtype==etINVALID );\n        return;\n      }\n    }/* End switch over the format type */\n    /*\n    ** The text of the conversion is pointed to by \"bufpt\" and is\n    ** \"length\" characters long.  The field width is \"width\".  Do\n    ** the output.\n    */\n    if( !flag_leftjustify ){\n      register int nspace;\n      nspace = width-length;\n      if( nspace>0 ){\n        sqlite3AppendSpace(pAccum, nspace);\n      }\n    }\n    if( length>0 ){\n      sqlite3StrAccumAppend(pAccum, bufpt, length);\n    }\n    if( flag_leftjustify ){\n      register int nspace;\n      nspace = width-length;\n      if( nspace>0 ){\n        sqlite3AppendSpace(pAccum, nspace);\n      }\n    }\n    sqlite3_free(zExtra);\n  }/* End for loop over the format string */\n} /* End of function */\n\n/*\n** Append N bytes of text from z to the StrAccum object.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){\n  assert( z!=0 || N==0 );\n  if( p->tooBig | p->mallocFailed ){\n    testcase(p->tooBig);\n    testcase(p->mallocFailed);\n    return;\n  }\n  assert( p->zText!=0 || p->nChar==0 );\n  if( N<0 ){\n    N = sqlite3Strlen30(z);\n  }\n  if( N==0 || NEVER(z==0) ){\n    return;\n  }\n  if( p->nChar+N >= p->nAlloc ){\n    char *zNew;\n    if( !p->useMalloc ){\n      p->tooBig = 1;\n      N = p->nAlloc - p->nChar - 1;\n      if( N<=0 ){\n        return;\n      }\n    }else{\n      char *zOld = (p->zText==p->zBase ? 0 : p->zText);\n      i64 szNew = p->nChar;\n      szNew += N + 1;\n      if( szNew > p->mxAlloc ){\n        sqlite3StrAccumReset(p);\n        p->tooBig = 1;\n        return;\n      }else{\n        p->nAlloc = (int)szNew;\n      }\n      if( p->useMalloc==1 ){\n        zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);\n      }else{\n        zNew = sqlite3_realloc(zOld, p->nAlloc);\n      }\n      if( zNew ){\n        if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);\n        p->zText = zNew;\n      }else{\n        p->mallocFailed = 1;\n        sqlite3StrAccumReset(p);\n        return;\n      }\n    }\n  }\n  assert( p->zText );\n  memcpy(&p->zText[p->nChar], z, N);\n  p->nChar += N;\n}\n\n/*\n** Finish off a string by making sure it is zero-terminated.\n** Return a pointer to the resulting string.  Return a NULL\n** pointer if any kind of error was encountered.\n*/\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){\n  if( p->zText ){\n    p->zText[p->nChar] = 0;\n    if( p->useMalloc && p->zText==p->zBase ){\n      if( p->useMalloc==1 ){\n        p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );\n      }else{\n        p->zText = sqlite3_malloc(p->nChar+1);\n      }\n      if( p->zText ){\n        memcpy(p->zText, p->zBase, p->nChar+1);\n      }else{\n        p->mallocFailed = 1;\n      }\n    }\n  }\n  return p->zText;\n}\n\n/*\n** Reset an StrAccum string.  Reclaim all malloced memory.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){\n  if( p->zText!=p->zBase ){\n    if( p->useMalloc==1 ){\n      sqlite3DbFree(p->db, p->zText);\n    }else{\n      sqlite3_free(p->zText);\n    }\n  }\n  p->zText = 0;\n}\n\n/*\n** Initialize a string accumulator\n*/\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){\n  p->zText = p->zBase = zBase;\n  p->db = 0;\n  p->nChar = 0;\n  p->nAlloc = n;\n  p->mxAlloc = mx;\n  p->useMalloc = 1;\n  p->tooBig = 0;\n  p->mallocFailed = 0;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n  assert( db!=0 );\n  sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),\n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  acc.db = db;\n  sqlite3VXPrintf(&acc, 1, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  if( acc.mallocFailed ){\n    db->mallocFailed = 1;\n  }\n  return z;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting\n** the string and before returnning.  This routine is intended to be used\n** to modify an existing string.  For example:\n**\n**       x = sqlite3MPrintf(db, x, \"prefix %s suffix\", x);\n**\n*/\nSQLITE_PRIVATE char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  sqlite3DbFree(db, zStr);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);\n  acc.useMalloc = 2;\n  sqlite3VXPrintf(&acc, 0, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc()().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** sqlite3_snprintf() works like snprintf() except that it ignores the\n** current locale settings.  This is important for SQLite because we\n** are not able to use a \",\" as the decimal point in place of \".\" as\n** specified by some locales.\n**\n** Oops:  The first two arguments of sqlite3_snprintf() are backwards\n** from the snprintf() standard.  Unfortunately, it is too late to change\n** this without breaking compatibility, so we just have to live with the\n** mistake.\n**\n** sqlite3_vsnprintf() is the varargs version.\n*/\nSQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){\n  StrAccum acc;\n  if( n<=0 ) return zBuf;\n  sqlite3StrAccumInit(&acc, zBuf, n, 0);\n  acc.useMalloc = 0;\n  sqlite3VXPrintf(&acc, 0, zFormat, ap);\n  return sqlite3StrAccumFinish(&acc);\n}\nSQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){\n  char *z;\n  va_list ap;\n  va_start(ap,zFormat);\n  z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** This is the routine that actually formats the sqlite3_log() message.\n** We house it in a separate routine from sqlite3_log() to avoid using\n** stack space on small-stack systems when logging is disabled.\n**\n** sqlite3_log() must render into a static buffer.  It cannot dynamically\n** allocate memory because it might be called while the memory allocator\n** mutex is held.\n*/\nstatic void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){\n  StrAccum acc;                          /* String accumulator */\n  char zMsg[SQLITE_PRINT_BUF_SIZE*3];    /* Complete log message */\n\n  sqlite3StrAccumInit(&acc, zMsg, sizeof(zMsg), 0);\n  acc.useMalloc = 0;\n  sqlite3VXPrintf(&acc, 0, zFormat, ap);\n  sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,\n                           sqlite3StrAccumFinish(&acc));\n}\n\n/*\n** Format and write a message to the log if logging is enabled.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){\n  va_list ap;                             /* Vararg list */\n  if( sqlite3GlobalConfig.xLog ){\n    va_start(ap, zFormat);\n    renderLogMsg(iErrCode, zFormat, ap);\n    va_end(ap);\n  }\n}\n\n#if defined(SQLITE_DEBUG)\n/*\n** A version of printf() that understands %lld.  Used for debugging.\n** The printf() built into some versions of windows does not understand %lld\n** and segfaults if you give it a long long int.\n*/\nSQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){\n  va_list ap;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);\n  acc.useMalloc = 0;\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(&acc, 0, zFormat, ap);\n  va_end(ap);\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** variable-argument wrapper around sqlite3VXPrintf().\n*/\nSQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(p, 1, zFormat, ap);\n  va_end(ap);\n}\n#endif\n\n/************** End of printf.c **********************************************/\n/************** Begin file random.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement a pseudo-random number\n** generator (PRNG) for SQLite.\n**\n** Random numbers are used by some of the database backends in order\n** to generate random integer keys for tables or random filenames.\n*/\n\n\n/* All threads share a single random number generator.\n** This structure is the current state of the generator.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType {\n  unsigned char isInit;          /* True if initialized */\n  unsigned char i, j;            /* State variables */\n  unsigned char s[256];          /* State variables */\n} sqlite3Prng;\n\n/*\n** Get a single 8-bit random value from the RC4 PRNG.  The Mutex\n** must be held while executing this routine.\n**\n** Why not just use a library random generator like lrand48() for this?\n** Because the OP_NewRowid opcode in the VDBE depends on having a very\n** good source of random numbers.  The lrand48() library function may\n** well be good enough.  But maybe not.  Or maybe lrand48() has some\n** subtle problems on some systems that could cause problems.  It is hard\n** to know.  To minimize the risk of problems due to bad lrand48()\n** implementations, SQLite uses this random number generator based\n** on RC4, which we know works very well.\n**\n** (Later):  Actually, OP_NewRowid does not depend on a good source of\n** randomness any more.  But we will leave this code in all the same.\n*/\nstatic u8 randomByte(void){\n  unsigned char t;\n\n\n  /* The \"wsdPrng\" macro will resolve to the pseudo-random number generator\n  ** state vector.  If writable static data is unsupported on the target,\n  ** we have to locate the state vector at run-time.  In the more common\n  ** case where writable static data is supported, wsdPrng can refer directly\n  ** to the \"sqlite3Prng\" state vector declared above.\n  */\n#ifdef SQLITE_OMIT_WSD\n  struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);\n# define wsdPrng p[0]\n#else\n# define wsdPrng sqlite3Prng\n#endif\n\n\n  /* Initialize the state of the random number generator once,\n  ** the first time this routine is called.  The seed value does\n  ** not need to contain a lot of randomness since we are not\n  ** trying to do secure encryption or anything like that...\n  **\n  ** Nothing in this file or anywhere else in SQLite does any kind of\n  ** encryption.  The RC4 algorithm is being used as a PRNG (pseudo-random\n  ** number generator) not as an encryption device.\n  */\n  if( !wsdPrng.isInit ){\n    int i;\n    char k[256];\n    wsdPrng.j = 0;\n    wsdPrng.i = 0;\n    sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);\n    for(i=0; i<256; i++){\n      wsdPrng.s[i] = (u8)i;\n    }\n    for(i=0; i<256; i++){\n      wsdPrng.j += wsdPrng.s[i] + k[i];\n      t = wsdPrng.s[wsdPrng.j];\n      wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];\n      wsdPrng.s[i] = t;\n    }\n    wsdPrng.isInit = 1;\n  }\n\n  /* Generate and return single random byte\n  */\n  wsdPrng.i++;\n  t = wsdPrng.s[wsdPrng.i];\n  wsdPrng.j += t;\n  wsdPrng.s[wsdPrng.i] = wsdPrng.s[wsdPrng.j];\n  wsdPrng.s[wsdPrng.j] = t;\n  t += wsdPrng.s[wsdPrng.i];\n  return wsdPrng.s[t];\n}\n\n/*\n** Return N random bytes.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *pBuf){\n  unsigned char *zBuf = pBuf;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);\n#endif\n  sqlite3_mutex_enter(mutex);\n  while( N-- ){\n    *(zBuf++) = randomByte();\n  }\n  sqlite3_mutex_leave(mutex);\n}\n\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n/*\n** For testing purposes, we sometimes want to preserve the state of\n** PRNG and restore the PRNG to its saved state at a later time, or\n** to reset the PRNG to its initial state.  These routines accomplish\n** those tasks.\n**\n** The sqlite3_test_control() interface calls these routines to\n** control the PRNG.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType sqlite3SavedPrng;\nSQLITE_PRIVATE void sqlite3PrngSaveState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    sizeof(sqlite3Prng)\n  );\n}\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    sizeof(sqlite3Prng)\n  );\n}\nSQLITE_PRIVATE void sqlite3PrngResetState(void){\n  GLOBAL(struct sqlite3PrngType, sqlite3Prng).isInit = 0;\n}\n#endif /* SQLITE_OMIT_BUILTIN_TEST */\n\n/************** End of random.c **********************************************/\n/************** Begin file utf.c *********************************************/\n/*\n** 2004 April 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used to translate between UTF-8, \n** UTF-16, UTF-16BE, and UTF-16LE.\n**\n** Notes on UTF-8:\n**\n**   Byte-0    Byte-1    Byte-2    Byte-3    Value\n**  0xxxxxxx                                 00000000 00000000 0xxxxxxx\n**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx\n**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx\n**  11110uuu  10uuzzzz  10yyyyyy  10xxxxxx   000uuuuu zzzzyyyy yyxxxxxx\n**\n**\n** Notes on UTF-16:  (with wwww+1==uuuuu)\n**\n**      Word-0               Word-1          Value\n**  110110ww wwzzzzyy   110111yy yyxxxxxx    000uuuuu zzzzyyyy yyxxxxxx\n**  zzzzyyyy yyxxxxxx                        00000000 zzzzyyyy yyxxxxxx\n**\n**\n** BOM or Byte Order Mark:\n**     0xff 0xfe   little-endian utf-16 follows\n**     0xfe 0xff   big-endian utf-16 follows\n**\n*/\n/* #include <assert.h> */\n\n#ifndef SQLITE_AMALGAMATION\n/*\n** The following constant value is used by the SQLITE_BIGENDIAN and\n** SQLITE_LITTLEENDIAN macros.\n*/\nSQLITE_PRIVATE const int sqlite3one = 1;\n#endif /* SQLITE_AMALGAMATION */\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character.\n*/\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#define WRITE_UTF16LE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n  }else{                                                            \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n  }                                                                 \\\n}\n\n#define WRITE_UTF16BE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }else{                                                            \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }                                                                 \\\n}\n\n#define READ_UTF16LE(zIn, TERM, c){                                   \\\n  c = (*zIn++);                                                       \\\n  c += ((*zIn++)<<8);                                                 \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = (*zIn++);                                                \\\n    c2 += ((*zIn++)<<8);                                              \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n#define READ_UTF16BE(zIn, TERM, c){                                   \\\n  c = ((*zIn++)<<8);                                                  \\\n  c += (*zIn++);                                                      \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = ((*zIn++)<<8);                                           \\\n    c2 += (*zIn++);                                                   \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n/*\n** Translate a single UTF-8 character.  Return the unicode value.\n**\n** During translation, assume that the byte that zTerm points\n** is a 0x00.\n**\n** Write a pointer to the next unread byte back into *pzNext.\n**\n** Notes On Invalid UTF-8:\n**\n**  *  This routine never allows a 7-bit character (0x00 through 0x7f) to\n**     be encoded as a multi-byte character.  Any multi-byte character that\n**     attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd.\n**\n**  *  This routine never allows a UTF16 surrogate value to be encoded.\n**     If a multi-byte character attempts to encode a value between\n**     0xd800 and 0xe000 then it is rendered as 0xfffd.\n**\n**  *  Bytes in the range of 0x80 through 0xbf which occur as the first\n**     byte of a character are interpreted as single-byte characters\n**     and rendered as themselves even though they are technically\n**     invalid characters.\n**\n**  *  This routine accepts an infinite number of different UTF8 encodings\n**     for unicode values 0x80 and greater.  It do not change over-length\n**     encodings to 0xfffd as some systems recommend.\n*/\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\nSQLITE_PRIVATE u32 sqlite3Utf8Read(\n  const unsigned char **pz    /* Pointer to string from which to read char */\n){\n  unsigned int c;\n\n  /* Same as READ_UTF8() above but without the zTerm parameter.\n  ** For this routine, we assume the UTF8 string is always zero-terminated.\n  */\n  c = *((*pz)++);\n  if( c>=0xc0 ){\n    c = sqlite3Utf8Trans1[c-0xc0];\n    while( (*(*pz) & 0xc0)==0x80 ){\n      c = (c<<6) + (0x3f & *((*pz)++));\n    }\n    if( c<0x80\n        || (c&0xFFFFF800)==0xD800\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }\n  }\n  return c;\n}\n\n\n\n\n/*\n** If the TRANSLATE_TRACE macro is defined, the value of each Mem is\n** printed on stderr on the way into and out of sqlite3VdbeMemTranslate().\n*/ \n/* #define TRANSLATE_TRACE 1 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine transforms the internal text encoding used by pMem to\n** desiredEnc. It is an error if the string is already of the desired\n** encoding, or if *pMem does not contain a string value.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){\n  int len;                    /* Maximum length of output string in bytes */\n  unsigned char *zOut;                  /* Output buffer */\n  unsigned char *zIn;                   /* Input iterator */\n  unsigned char *zTerm;                 /* End of input */\n  unsigned char *z;                     /* Output iterator */\n  unsigned int c;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( pMem->flags&MEM_Str );\n  assert( pMem->enc!=desiredEnc );\n  assert( pMem->enc!=0 );\n  assert( pMem->n>=0 );\n\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"INPUT:  %s\\n\", zBuf);\n  }\n#endif\n\n  /* If the translation is between UTF-16 little and big endian, then \n  ** all that is required is to swap the byte order. This case is handled\n  ** differently from the others.\n  */\n  if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){\n    u8 temp;\n    int rc;\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc!=SQLITE_OK ){\n      assert( rc==SQLITE_NOMEM );\n      return SQLITE_NOMEM;\n    }\n    zIn = (u8*)pMem->z;\n    zTerm = &zIn[pMem->n&~1];\n    while( zIn<zTerm ){\n      temp = *zIn;\n      *zIn = *(zIn+1);\n      zIn++;\n      *zIn++ = temp;\n    }\n    pMem->enc = desiredEnc;\n    goto translate_out;\n  }\n\n  /* Set len to the maximum number of bytes required in the output buffer. */\n  if( desiredEnc==SQLITE_UTF8 ){\n    /* When converting from UTF-16, the maximum growth results from\n    ** translating a 2-byte character to a 4-byte UTF-8 character.\n    ** A single byte is required for the output string\n    ** nul-terminator.\n    */\n    pMem->n &= ~1;\n    len = pMem->n * 2 + 1;\n  }else{\n    /* When converting from UTF-8 to UTF-16 the maximum growth is caused\n    ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16\n    ** character. Two bytes are required in the output buffer for the\n    ** nul-terminator.\n    */\n    len = pMem->n * 2 + 2;\n  }\n\n  /* Set zIn to point at the start of the input buffer and zTerm to point 1\n  ** byte past the end.\n  **\n  ** Variable zOut is set to point at the output buffer, space obtained\n  ** from sqlite3_malloc().\n  */\n  zIn = (u8*)pMem->z;\n  zTerm = &zIn[pMem->n];\n  zOut = sqlite3DbMallocRaw(pMem->db, len);\n  if( !zOut ){\n    return SQLITE_NOMEM;\n  }\n  z = zOut;\n\n  if( pMem->enc==SQLITE_UTF8 ){\n    if( desiredEnc==SQLITE_UTF16LE ){\n      /* UTF-8 -> UTF-16 Little-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16LE(z, c);\n      }\n    }else{\n      assert( desiredEnc==SQLITE_UTF16BE );\n      /* UTF-8 -> UTF-16 Big-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16BE(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n    *z++ = 0;\n  }else{\n    assert( desiredEnc==SQLITE_UTF8 );\n    if( pMem->enc==SQLITE_UTF16LE ){\n      /* UTF-16 Little-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16LE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }else{\n      /* UTF-16 Big-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16BE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n  }\n  *z = 0;\n  assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );\n\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags &= ~(MEM_Static|MEM_Dyn|MEM_Ephem);\n  pMem->enc = desiredEnc;\n  pMem->flags |= (MEM_Term|MEM_Dyn);\n  pMem->z = (char*)zOut;\n  pMem->zMalloc = pMem->z;\n\ntranslate_out:\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"OUTPUT: %s\\n\", zBuf);\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** This routine checks for a byte-order mark at the beginning of the \n** UTF-16 string stored in *pMem. If one is present, it is removed and\n** the encoding of the Mem adjusted. This routine does not do any\n** byte-swapping, it just sets Mem.enc appropriately.\n**\n** The allocation (static, dynamic etc.) and encoding of the Mem may be\n** changed by this function.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){\n  int rc = SQLITE_OK;\n  u8 bom = 0;\n\n  assert( pMem->n>=0 );\n  if( pMem->n>1 ){\n    u8 b1 = *(u8 *)pMem->z;\n    u8 b2 = *(((u8 *)pMem->z) + 1);\n    if( b1==0xFE && b2==0xFF ){\n      bom = SQLITE_UTF16BE;\n    }\n    if( b1==0xFF && b2==0xFE ){\n      bom = SQLITE_UTF16LE;\n    }\n  }\n  \n  if( bom ){\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc==SQLITE_OK ){\n      pMem->n -= 2;\n      memmove(pMem->z, &pMem->z[2], pMem->n);\n      pMem->z[pMem->n] = '\\0';\n      pMem->z[pMem->n+1] = '\\0';\n      pMem->flags |= MEM_Term;\n      pMem->enc = bom;\n    }\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,\n** return the number of unicode characters in pZ up to (but not including)\n** the first 0x00 byte. If nByte is not less than zero, return the\n** number of unicode characters in the first nByte of pZ (or up to \n** the first 0x00, whichever comes first).\n*/\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *zIn, int nByte){\n  int r = 0;\n  const u8 *z = (const u8*)zIn;\n  const u8 *zTerm;\n  if( nByte>=0 ){\n    zTerm = &z[nByte];\n  }else{\n    zTerm = (const u8*)(-1);\n  }\n  assert( z<=zTerm );\n  while( *z!=0 && z<zTerm ){\n    SQLITE_SKIP_UTF8(z);\n    r++;\n  }\n  return r;\n}\n\n/* This test function is not currently used by the automated test-suite. \n** Hence it is only available in debug builds.\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Translate UTF-8 to UTF-8.\n**\n** This has the effect of making sure that the string is well-formed\n** UTF-8.  Miscoded characters are removed.\n**\n** The translation is done in-place and aborted if the output\n** overruns the input.\n*/\nSQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){\n  unsigned char *zOut = zIn;\n  unsigned char *zStart = zIn;\n  u32 c;\n\n  while( zIn[0] && zOut<=zIn ){\n    c = sqlite3Utf8Read((const u8**)&zIn);\n    if( c!=0xfffd ){\n      WRITE_UTF8(zOut, c);\n    }\n  }\n  *zOut = 0;\n  return (int)(zOut - zStart);\n}\n#endif\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Convert a UTF-16 string in the native encoding into a UTF-8 string.\n** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must\n** be freed by the calling function.\n**\n** NULL is returned if there is an allocation error.\n*/\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){\n  Mem m;\n  memset(&m, 0, sizeof(m));\n  m.db = db;\n  sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);\n  sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);\n  if( db->mallocFailed ){\n    sqlite3VdbeMemRelease(&m);\n    m.z = 0;\n  }\n  assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );\n  assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );\n  assert( (m.flags & MEM_Dyn)!=0 || db->mallocFailed );\n  assert( m.z || db->mallocFailed );\n  return m.z;\n}\n\n/*\n** Convert a UTF-8 string to the UTF-16 encoding specified by parameter\n** enc. A pointer to the new string is returned, and the value of *pnOut\n** is set to the length of the returned string in bytes. The call should\n** arrange to call sqlite3DbFree() on the returned pointer when it is\n** no longer required.\n** \n** If a malloc failure occurs, NULL is returned and the db.mallocFailed\n** flag set.\n*/\n#ifdef SQLITE_ENABLE_STAT3\nSQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *db, u8 enc, char *z, int n, int *pnOut){\n  Mem m;\n  memset(&m, 0, sizeof(m));\n  m.db = db;\n  sqlite3VdbeMemSetStr(&m, z, n, SQLITE_UTF8, SQLITE_STATIC);\n  if( sqlite3VdbeMemTranslate(&m, enc) ){\n    assert( db->mallocFailed );\n    return 0;\n  }\n  assert( m.z==m.zMalloc );\n  *pnOut = m.n;\n  return m.z;\n}\n#endif\n\n/*\n** zIn is a UTF-16 encoded unicode string at least nChar characters long.\n** Return the number of bytes in the first nChar unicode characters\n** in pZ.  nChar must be non-negative.\n*/\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){\n  int c;\n  unsigned char const *z = zIn;\n  int n = 0;\n  \n  if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){\n    while( n<nChar ){\n      READ_UTF16BE(z, 1, c);\n      n++;\n    }\n  }else{\n    while( n<nChar ){\n      READ_UTF16LE(z, 1, c);\n      n++;\n    }\n  }\n  return (int)(z-(unsigned char const *)zIn);\n}\n\n#if defined(SQLITE_TEST)\n/*\n** This routine is called from the TCL test function \"translate_selftest\".\n** It checks that the primitives for serializing and deserializing\n** characters in each encoding are inverses of each other.\n*/\nSQLITE_PRIVATE void sqlite3UtfSelfTest(void){\n  unsigned int i, t;\n  unsigned char zBuf[20];\n  unsigned char *z;\n  int n;\n  unsigned int c;\n\n  for(i=0; i<0x00110000; i++){\n    z = zBuf;\n    WRITE_UTF8(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    c = sqlite3Utf8Read((const u8**)&z);\n    t = i;\n    if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;\n    if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;\n    assert( c==t );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16LE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16LE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16BE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16BE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n}\n#endif /* SQLITE_TEST */\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of utf.c *************************************************/\n/************** Begin file util.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Utility functions used throughout sqlite.\n**\n** This file contains functions for allocating memory, comparing\n** strings, and stuff like that.\n**\n*/\n/* #include <stdarg.h> */\n#ifdef SQLITE_HAVE_ISNAN\n# include <math.h>\n#endif\n\n/*\n** Routine needed to support the testcase() macro.\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE void sqlite3Coverage(int x){\n  static unsigned dummy = 0;\n  dummy += (unsigned)x;\n}\n#endif\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Return true if the floating point value is Not a Number (NaN).\n**\n** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.\n** Otherwise, we have our own implementation that works on most systems.\n*/\nSQLITE_PRIVATE int sqlite3IsNaN(double x){\n  int rc;   /* The value return */\n#if !defined(SQLITE_HAVE_ISNAN)\n  /*\n  ** Systems that support the isnan() library function should probably\n  ** make use of it by compiling with -DSQLITE_HAVE_ISNAN.  But we have\n  ** found that many systems do not have a working isnan() function so\n  ** this implementation is provided as an alternative.\n  **\n  ** This NaN test sometimes fails if compiled on GCC with -ffast-math.\n  ** On the other hand, the use of -ffast-math comes with the following\n  ** warning:\n  **\n  **      This option [-ffast-math] should never be turned on by any\n  **      -O option since it can result in incorrect output for programs\n  **      which depend on an exact implementation of IEEE or ISO \n  **      rules/specifications for math functions.\n  **\n  ** Under MSVC, this NaN test may fail if compiled with a floating-\n  ** point precision mode other than /fp:precise.  From the MSDN \n  ** documentation:\n  **\n  **      The compiler [with /fp:precise] will properly handle comparisons \n  **      involving NaN. For example, x != x evaluates to true if x is NaN \n  **      ...\n  */\n#ifdef __FAST_MATH__\n# error SQLite will not work correctly with the -ffast-math option of GCC.\n#endif\n  volatile double y = x;\n  volatile double z = y;\n  rc = (y!=z);\n#else  /* if defined(SQLITE_HAVE_ISNAN) */\n  rc = isnan(x);\n#endif /* SQLITE_HAVE_ISNAN */\n  testcase( rc );\n  return rc;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n**\n** The value returned will never be negative.  Nor will it ever be greater\n** than the actual length of the string.  For very long strings (greater\n** than 1GiB) the value returned might be less than the true string length.\n*/\nSQLITE_PRIVATE int sqlite3Strlen30(const char *z){\n  const char *z2 = z;\n  if( z==0 ) return 0;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n/*\n** Set the most recent error code and error string for the sqlite\n** handle \"db\". The error code is set to \"err_code\".\n**\n** If it is not NULL, string zFormat specifies the format of the\n** error string in the style of the printf functions: The following\n** format characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** zFormat and any string tokens that follow it are assumed to be\n** encoded in UTF-8.\n**\n** To clear the most recent error for sqlite handle \"db\", sqlite3Error\n** should be called with err_code set to SQLITE_OK and zFormat set\n** to NULL.\n*/\nSQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){\n  if( db && (db->pErr || (db->pErr = sqlite3ValueNew(db))!=0) ){\n    db->errCode = err_code;\n    if( zFormat ){\n      char *z;\n      va_list ap;\n      va_start(ap, zFormat);\n      z = sqlite3VMPrintf(db, zFormat, ap);\n      va_end(ap);\n      sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);\n    }else{\n      sqlite3ValueSetStr(db->pErr, 0, 0, SQLITE_UTF8, SQLITE_STATIC);\n    }\n  }\n}\n\n/*\n** Add an error message to pParse->zErrMsg and increment pParse->nErr.\n** The following formatting characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** This function should be used to report any error that occurs whilst\n** compiling an SQL statement (i.e. within sqlite3_prepare()). The\n** last thing the sqlite3_prepare() function does is copy the error\n** stored by this function into the database handle using sqlite3Error().\n** Function sqlite3Error() should be used during statement execution\n** (sqlite3_step() etc.).\n*/\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){\n  char *zMsg;\n  va_list ap;\n  sqlite3 *db = pParse->db;\n  va_start(ap, zFormat);\n  zMsg = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( db->suppressErr ){\n    sqlite3DbFree(db, zMsg);\n  }else{\n    pParse->nErr++;\n    sqlite3DbFree(db, pParse->zErrMsg);\n    pParse->zErrMsg = zMsg;\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** The input string must be zero-terminated.  A new zero-terminator\n** is added to the dequoted string.\n**\n** The return value is -1 if no dequoting occurs or the length of the\n** dequoted string, exclusive of the zero terminator, if dequoting does\n** occur.\n**\n** 2002-Feb-14: This routine is extended to remove MS-Access style\n** brackets from around identifers.  For example:  \"[a-b-c]\" becomes\n** \"a-b-c\".\n*/\nSQLITE_PRIVATE int sqlite3Dequote(char *z){\n  char quote;\n  int i, j;\n  if( z==0 ) return -1;\n  quote = z[0];\n  switch( quote ){\n    case '\\'':  break;\n    case '\"':   break;\n    case '`':   break;                /* For MySQL compatibility */\n    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */\n    default:    return -1;\n  }\n  for(i=1, j=0; ALWAYS(z[i]); i++){\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n  z[j] = 0;\n  return j;\n}\n\n/* Convenient short-hand */\n#define UpperToLower sqlite3UpperToLower\n\n/*\n** Some systems have stricmp().  Others have strcasecmp().  Because\n** there is no consistency, we will define our own.\n**\n** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and\n** sqlite3_strnicmp() APIs allow applications and extensions to compare\n** the contents of two buffers containing UTF-8 strings in a\n** case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){\n  register unsigned char *a, *b;\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }\n  return UpperToLower[*a] - UpperToLower[*b];\n}\nSQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){\n  register unsigned char *a, *b;\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }\n  return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];\n}\n\n/*\n** The string z[] is an text representation of a real number.\n** Convert this string to a double and write it into *pResult.\n**\n** The string z[] is length bytes in length (bytes, not characters) and\n** uses the encoding enc.  The string is not necessarily zero-terminated.\n**\n** Return TRUE if the result is a valid real number (or integer) and FALSE\n** if the string is empty or contains extraneous text.  Valid numbers\n** are in one of these formats:\n**\n**    [+-]digits[E[+-]digits]\n**    [+-]digits.[digits][E[+-]digits]\n**    [+-].digits[E[+-]digits]\n**\n** Leading and trailing whitespace is ignored for the purpose of determining\n** validity.\n**\n** If some prefix of the input string is a valid number, this routine\n** returns FALSE but it still converts the prefix and writes the result\n** into *pResult.\n*/\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int incr;\n  const char *zEnd = z + length;\n  /* sign * significand * (10 ^ (esign * exponent)) */\n  int sign = 1;    /* sign of significand */\n  i64 s = 0;       /* significand */\n  int d = 0;       /* adjust exponent for shifting decimal point */\n  int esign = 1;   /* sign of exponent */\n  int e = 0;       /* exponent */\n  int eValid = 1;  /* True exponent is either not used or is well-formed */\n  double result;\n  int nDigits = 0;\n  int nonNum = 0;\n\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  *pResult = 0.0;   /* Default return value, in case of an error */\n\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    int i;\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && z[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = z+i+enc-3;\n    z += (enc&1);\n  }\n\n  /* skip leading spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n  if( z>=zEnd ) return 0;\n\n  /* get sign of significand */\n  if( *z=='-' ){\n    sign = -1;\n    z+=incr;\n  }else if( *z=='+' ){\n    z+=incr;\n  }\n\n  /* skip leading zeroes */\n  while( z<zEnd && z[0]=='0' ) z+=incr, nDigits++;\n\n  /* copy max significant digits to significand */\n  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n    s = s*10 + (*z - '0');\n    z+=incr, nDigits++;\n  }\n\n  /* skip non-significant significand digits\n  ** (increase exponent by d to shift decimal left) */\n  while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++;\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if decimal point is present */\n  if( *z=='.' ){\n    z+=incr;\n    /* copy digits from after decimal to significand\n    ** (decrease exponent by d to shift decimal right) */\n    while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n      s = s*10 + (*z - '0');\n      z+=incr, nDigits++, d--;\n    }\n    /* skip non-significant digits */\n    while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++;\n  }\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if exponent is present */\n  if( *z=='e' || *z=='E' ){\n    z+=incr;\n    eValid = 0;\n    if( z>=zEnd ) goto do_atof_calc;\n    /* get sign of exponent */\n    if( *z=='-' ){\n      esign = -1;\n      z+=incr;\n    }else if( *z=='+' ){\n      z+=incr;\n    }\n    /* copy digits to exponent */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      e = e<10000 ? (e*10 + (*z - '0')) : 10000;\n      z+=incr;\n      eValid = 1;\n    }\n  }\n\n  /* skip trailing spaces */\n  if( nDigits && eValid ){\n    while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n  }\n\ndo_atof_calc:\n  /* adjust exponent by d, and update sign */\n  e = (e*esign) + d;\n  if( e<0 ) {\n    esign = -1;\n    e *= -1;\n  } else {\n    esign = 1;\n  }\n\n  /* if 0 significand */\n  if( !s ) {\n    /* In the IEEE 754 standard, zero is signed.\n    ** Add the sign if we've seen at least one digit */\n    result = (sign<0 && nDigits) ? -(double)0 : (double)0;\n  } else {\n    /* attempt to reduce exponent */\n    if( esign>0 ){\n      while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;\n    }else{\n      while( !(s%10) && e>0 ) e--,s/=10;\n    }\n\n    /* adjust the sign of significand */\n    s = sign<0 ? -s : s;\n\n    /* if exponent, scale significand as appropriate\n    ** and store in result. */\n    if( e ){\n      LONGDOUBLE_TYPE scale = 1.0;\n      /* attempt to handle extremely small/large numbers better */\n      if( e>307 && e<342 ){\n        while( e%308 ) { scale *= 1.0e+1; e -= 1; }\n        if( esign<0 ){\n          result = s / scale;\n          result /= 1.0e+308;\n        }else{\n          result = s * scale;\n          result *= 1.0e+308;\n        }\n      }else if( e>=342 ){\n        if( esign<0 ){\n          result = 0.0*s;\n        }else{\n          result = 1e308*1e308*s;  /* Infinity */\n        }\n      }else{\n        /* 1.0e+22 is the largest power of 10 than can be \n        ** represented exactly. */\n        while( e%22 ) { scale *= 1.0e+1; e -= 1; }\n        while( e>0 ) { scale *= 1.0e+22; e -= 22; }\n        if( esign<0 ){\n          result = s / scale;\n        }else{\n          result = s * scale;\n        }\n      }\n    } else {\n      result = (double)s;\n    }\n  }\n\n  /* store the result */\n  *pResult = result;\n\n  /* return true if number and no extra non-whitespace chracters after */\n  return z>=zEnd && nDigits>0 && eValid && nonNum==0;\n#else\n  return !sqlite3Atoi64(z, pResult, length, enc);\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n}\n\n/*\n** Compare the 19-character string zNum against the text representation\n** value 2^63:  9223372036854775808.  Return negative, zero, or positive\n** if zNum is less than, equal to, or greater than the string.\n** Note that zNum must contain exactly 19 characters.\n**\n** Unlike memcmp() this routine is guaranteed to return the difference\n** in the values of the last digit if the only difference is in the\n** last digit.  So, for example,\n**\n**      compare2pow63(\"9223372036854775800\", 1)\n**\n** will return -8.\n*/\nstatic int compare2pow63(const char *zNum, int incr){\n  int c = 0;\n  int i;\n                    /* 012345678901234567 */\n  const char *pow63 = \"922337203685477580\";\n  for(i=0; c==0 && i<18; i++){\n    c = (zNum[i*incr]-pow63[i])*10;\n  }\n  if( c==0 ){\n    c = zNum[18*incr] - '8';\n    testcase( c==(-1) );\n    testcase( c==0 );\n    testcase( c==(+1) );\n  }\n  return c;\n}\n\n\n/*\n** Convert zNum to a 64-bit signed integer.\n**\n** If the zNum value is representable as a 64-bit twos-complement \n** integer, then write that value into *pNum and return 0.\n**\n** If zNum is exactly 9223372036854665808, return 2.  This special\n** case is broken out because while 9223372036854665808 cannot be a \n** signed 64-bit integer, its negative -9223372036854665808 can be.\n**\n** If zNum is too big for a 64-bit integer and is not\n** 9223372036854665808  or if zNum contains any non-numeric text,\n** then return 1.\n**\n** length is the number of bytes in the string (bytes, not characters).\n** The string is not necessarily zero-terminated.  The encoding is\n** given by enc.\n*/\nSQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){\n  int incr;\n  u64 u = 0;\n  int neg = 0; /* assume positive */\n  int i;\n  int c = 0;\n  int nonNum = 0;\n  const char *zStart;\n  const char *zEnd = zNum + length;\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && zNum[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = zNum+i+enc-3;\n    zNum += (enc&1);\n  }\n  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;\n  if( zNum<zEnd ){\n    if( *zNum=='-' ){\n      neg = 1;\n      zNum+=incr;\n    }else if( *zNum=='+' ){\n      zNum+=incr;\n    }\n  }\n  zStart = zNum;\n  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */\n  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){\n    u = u*10 + c - '0';\n  }\n  if( u>LARGEST_INT64 ){\n    *pNum = SMALLEST_INT64;\n  }else if( neg ){\n    *pNum = -(i64)u;\n  }else{\n    *pNum = (i64)u;\n  }\n  testcase( i==18 );\n  testcase( i==19 );\n  testcase( i==20 );\n  if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19*incr || nonNum ){\n    /* zNum is empty or contains non-numeric text or is longer\n    ** than 19 digits (thus guaranteeing that it is too large) */\n    return 1;\n  }else if( i<19*incr ){\n    /* Less than 19 digits, so we know that it fits in 64 bits */\n    assert( u<=LARGEST_INT64 );\n    return 0;\n  }else{\n    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */\n    c = compare2pow63(zNum, incr);\n    if( c<0 ){\n      /* zNum is less than 9223372036854775808 so it fits */\n      assert( u<=LARGEST_INT64 );\n      return 0;\n    }else if( c>0 ){\n      /* zNum is greater than 9223372036854775808 so it overflows */\n      return 1;\n    }else{\n      /* zNum is exactly 9223372036854775808.  Fits if negative.  The\n      ** special case 2 overflow if positive */\n      assert( u-1==LARGEST_INT64 );\n      assert( (*pNum)==SMALLEST_INT64 );\n      return neg ? 0 : 2;\n    }\n  }\n}\n\n/*\n** If zNum represents an integer that will fit in 32-bits, then set\n** *pValue to that integer and return true.  Otherwise return false.\n**\n** Any non-numeric characters that following zNum are ignored.\n** This is different from sqlite3Atoi64() which requires the\n** input number to be zero-terminated.\n*/\nSQLITE_PRIVATE int sqlite3GetInt32(const char *zNum, int *pValue){\n  sqlite_int64 v = 0;\n  int i, c;\n  int neg = 0;\n  if( zNum[0]=='-' ){\n    neg = 1;\n    zNum++;\n  }else if( zNum[0]=='+' ){\n    zNum++;\n  }\n  while( zNum[0]=='0' ) zNum++;\n  for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){\n    v = v*10 + c;\n  }\n\n  /* The longest decimal representation of a 32 bit integer is 10 digits:\n  **\n  **             1234567890\n  **     2^31 -> 2147483648\n  */\n  testcase( i==10 );\n  if( i>10 ){\n    return 0;\n  }\n  testcase( v-neg==2147483647 );\n  if( v-neg>2147483647 ){\n    return 0;\n  }\n  if( neg ){\n    v = -v;\n  }\n  *pValue = (int)v;\n  return 1;\n}\n\n/*\n** Return a 32-bit integer value extracted from a string.  If the\n** string is not an integer, just return 0.\n*/\nSQLITE_PRIVATE int sqlite3Atoi(const char *z){\n  int x = 0;\n  if( z ) sqlite3GetInt32(z, &x);\n  return x;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\n\n/*\n** This routine is a faster version of sqlite3PutVarint() that only\n** works for 32-bit positive integers and which is optimized for\n** the common case of small integers.  A MACRO version, putVarint32,\n** is provided which inlines the single-byte case.  All code should use\n** the MACRO version as this function assumes the single-byte case has\n** already been handled.\n*/\nSQLITE_PRIVATE int sqlite3PutVarint32(unsigned char *p, u32 v){\n#ifndef putVarint32\n  if( (v & ~0x7f)==0 ){\n    p[0] = v;\n    return 1;\n  }\n#endif\n  if( (v & ~0x3fff)==0 ){\n    p[0] = (u8)((v>>7) | 0x80);\n    p[1] = (u8)(v & 0x7f);\n    return 2;\n  }\n  return sqlite3PutVarint(p, v);\n}\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above in calc'ing s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** Read a 32-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n**\n** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned\n** integer, then set *v to 0xffffffff.\n**\n** A MACRO version, getVarint32, is provided which inlines the \n** single-byte case.  All code should use the MACRO version as \n** this function assumes the single-byte case has already been handled.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case.  Overwhelmingly the most common.  Handled inline\n  ** by the getVarin32() macro */\n  a = *p;\n  /* a: p0 (unmasked) */\n#ifndef getVarint32\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n#endif\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n#if 1\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 2;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>3 && n<=9 );\n    if( (v64 & SQLITE_MAX_U32)!=v64 ){\n      *v = 0xffffffff;\n    }else{\n      *v = (u32)v64;\n    }\n    return n;\n  }\n\n#else\n  /* For following code (kept for historical record only) shows an\n  ** unrolling for the 3- and 4-byte varint cases.  This code is\n  ** slightly faster, but it is also larger and much harder to test.\n  */\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 2097152 and 268435455 */\n    b &= (0x7f<<14)|(0x7f);\n    a &= (0x7f<<14)|(0x7f);\n    a = a<<7;\n    *v = a | b;\n    return 4;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values  between 268435456 and 34359738367 */\n    a &= SLOT_4_2_0;\n    b &= SLOT_4_2_0;\n    b = b<<7;\n    *v = a | b;\n    return 5;\n  }\n\n  /* We can only reach this point when reading a corrupt database\n  ** file.  In that case we are not in any hurry.  Use the (relatively\n  ** slow) general-purpose sqlite3GetVarint() routine to extract the\n  ** value. */\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 4;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>5 && n<=9 );\n    *v = (u32)v64;\n    return n;\n  }\n#endif\n}\n\n/*\n** Return the number of bytes that will be needed to store the given\n** 64-bit integer.\n*/\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v){\n  int i = 0;\n  do{\n    i++;\n    v >>= 7;\n  }while( v!=0 && ALWAYS(i<9) );\n  return i;\n}\n\n\n/*\n** Read or write a four-byte big-endian integer value.\n*/\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){\n  return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];\n}\nSQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){\n  p[0] = (u8)(v>>24);\n  p[1] = (u8)(v>>16);\n  p[2] = (u8)(v>>8);\n  p[3] = (u8)v;\n}\n\n\n\n/*\n** Translate a single byte of Hex into an integer.\n** This routine only works if h really is a valid hexadecimal\n** character:  0..9a..fA..F\n*/\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h){\n  assert( (h>='0' && h<='9') ||  (h>='a' && h<='f') ||  (h>='A' && h<='F') );\n#ifdef SQLITE_ASCII\n  h += 9*(1&(h>>6));\n#endif\n#ifdef SQLITE_EBCDIC\n  h += 9*(1&~(h>>4));\n#endif\n  return (u8)(h & 0xf);\n}\n\n#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)\n/*\n** Convert a BLOB literal of the form \"x'hhhhhh'\" into its binary\n** value.  Return a pointer to its binary value.  Space to hold the\n** binary value has been obtained from malloc and must be freed by\n** the calling routine.\n*/\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){\n  char *zBlob;\n  int i;\n\n  zBlob = (char *)sqlite3DbMallocRaw(db, n/2 + 1);\n  n--;\n  if( zBlob ){\n    for(i=0; i<n; i+=2){\n      zBlob[i/2] = (sqlite3HexToInt(z[i])<<4) | sqlite3HexToInt(z[i+1]);\n    }\n    zBlob[i/2] = 0;\n  }\n  return zBlob;\n}\n#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */\n\n/*\n** Log an error that is an API call on a connection pointer that should\n** not have been used.  The \"type\" of connection pointer is given as the\n** argument.  The zType is a word like \"NULL\" or \"closed\" or \"invalid\".\n*/\nstatic void logBadConnection(const char *zType){\n  sqlite3_log(SQLITE_MISUSE, \n     \"API call with %s database connection pointer\",\n     zType\n  );\n}\n\n/*\n** Check to make sure we have a valid db pointer.  This test is not\n** foolproof but it does provide some measure of protection against\n** misuse of the interface such as passing in db pointers that are\n** NULL or which have been previously closed.  If this routine returns\n** 1 it means that the db pointer is valid and 0 if it should not be\n** dereferenced for any reason.  The calling function should invoke\n** SQLITE_MISUSE immediately.\n**\n** sqlite3SafetyCheckOk() requires that the db pointer be valid for\n** use.  sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to\n** open properly and is not fit for general use but which can be\n** used as an argument to sqlite3_errmsg() or sqlite3_close().\n*/\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){\n  u32 magic;\n  if( db==0 ){\n    logBadConnection(\"NULL\");\n    return 0;\n  }\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_OPEN ){\n    if( sqlite3SafetyCheckSickOrOk(db) ){\n      testcase( sqlite3GlobalConfig.xLog!=0 );\n      logBadConnection(\"unopened\");\n    }\n    return 0;\n  }else{\n    return 1;\n  }\n}\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){\n  u32 magic;\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_SICK &&\n      magic!=SQLITE_MAGIC_OPEN &&\n      magic!=SQLITE_MAGIC_BUSY ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    logBadConnection(\"invalid\");\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Attempt to add, substract, or multiply the 64-bit signed value iB against\n** the other 64-bit signed integer at *pA and store the result in *pA.\n** Return 0 on success.  Or if the operation would have resulted in an\n** overflow, leave *pA unchanged and return 1.\n*/\nSQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){\n  i64 iA = *pA;\n  testcase( iA==0 ); testcase( iA==1 );\n  testcase( iB==-1 ); testcase( iB==0 );\n  if( iB>=0 ){\n    testcase( iA>0 && LARGEST_INT64 - iA == iB );\n    testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 );\n    if( iA>0 && LARGEST_INT64 - iA < iB ) return 1;\n    *pA += iB;\n  }else{\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 );\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 );\n    if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1;\n    *pA += iB;\n  }\n  return 0; \n}\nSQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){\n  testcase( iB==SMALLEST_INT64+1 );\n  if( iB==SMALLEST_INT64 ){\n    testcase( (*pA)==(-1) ); testcase( (*pA)==0 );\n    if( (*pA)>=0 ) return 1;\n    *pA -= iB;\n    return 0;\n  }else{\n    return sqlite3AddInt64(pA, -iB);\n  }\n}\n#define TWOPOWER32 (((i64)1)<<32)\n#define TWOPOWER31 (((i64)1)<<31)\nSQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){\n  i64 iA = *pA;\n  i64 iA1, iA0, iB1, iB0, r;\n\n  iA1 = iA/TWOPOWER32;\n  iA0 = iA % TWOPOWER32;\n  iB1 = iB/TWOPOWER32;\n  iB0 = iB % TWOPOWER32;\n  if( iA1*iB1 != 0 ) return 1;\n  assert( iA1*iB0==0 || iA0*iB1==0 );\n  r = iA1*iB0 + iA0*iB1;\n  testcase( r==(-TWOPOWER31)-1 );\n  testcase( r==(-TWOPOWER31) );\n  testcase( r==TWOPOWER31 );\n  testcase( r==TWOPOWER31-1 );\n  if( r<(-TWOPOWER31) || r>=TWOPOWER31 ) return 1;\n  r *= TWOPOWER32;\n  if( sqlite3AddInt64(&r, iA0*iB0) ) return 1;\n  *pA = r;\n  return 0;\n}\n\n/*\n** Compute the absolute value of a 32-bit signed integer, of possible.  Or \n** if the integer has a value of -2147483648, return +2147483647\n*/\nSQLITE_PRIVATE int sqlite3AbsInt32(int x){\n  if( x>=0 ) return x;\n  if( x==(int)0x80000000 ) return 0x7fffffff;\n  return -x;\n}\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n/*\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBaseFilename, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = sqlite3Strlen30(z);\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n}\n#endif\n\n/************** End of util.c ************************************************/\n/************** Begin file hash.c ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables\n** used in SQLite.\n*/\n/* #include <assert.h> */\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash *pNew){\n  assert( pNew!=0 );\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3HashClear(Hash *pH){\n  HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  sqlite3_free(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    HashElem *next_elem = elem->next;\n    sqlite3_free(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** The hashing function.\n*/\nstatic unsigned int strHash(const char *z, int nKey){\n  int h = 0;\n  assert( nKey>=0 );\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];\n    nKey--;\n  }\n  return h;\n}\n\n\n/* Link pNew element into the hash table pH.  If pEntry!=0 then also\n** insert pNew into the pEntry hash bucket.\n*/\nstatic void insertElement(\n  Hash *pH,              /* The complete hash table */\n  struct _ht *pEntry,    /* The entry into which pNew is inserted */\n  HashElem *pNew         /* The element to be inserted */\n){\n  HashElem *pHead;       /* First element already in pEntry */\n  if( pEntry ){\n    pHead = pEntry->count ? pEntry->chain : 0;\n    pEntry->count++;\n    pEntry->chain = pNew;\n  }else{\n    pHead = 0;\n  }\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n**\n** The hash table might fail to resize if sqlite3_malloc() fails or\n** if the new size is the same as the prior size.\n** Return TRUE if the resize occurs and false if not.\n*/\nstatic int rehash(Hash *pH, unsigned int new_size){\n  struct _ht *new_ht;            /* The new hash table */\n  HashElem *elem, *next_elem;    /* For looping over existing elements */\n\n#if SQLITE_MALLOC_SOFT_LIMIT>0\n  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){\n    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);\n  }\n  if( new_size==pH->htsize ) return 0;\n#endif\n\n  /* The inability to allocates space for a larger hash table is\n  ** a performance hit but it is not a fatal error.  So mark the\n  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of \n  ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()\n  ** only zeroes the requested number of bytes whereas this module will\n  ** use the actual amount of space allocated for the hash table (which\n  ** may be larger than the requested amount).\n  */\n  sqlite3BeginBenignMalloc();\n  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );\n  sqlite3EndBenignMalloc();\n\n  if( new_ht==0 ) return 0;\n  sqlite3_free(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);\n  memset(new_ht, 0, new_size*sizeof(struct _ht));\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    unsigned int h = strHash(elem->pKey, elem->nKey) % new_size;\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n  return 1;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic HashElem *findElementGivenHash(\n  const Hash *pH,     /* The pH to be searched */\n  const char *pKey,   /* The key we are searching for */\n  int nKey,           /* Bytes in key (not counting zero terminator) */\n  unsigned int h      /* The hash for this key. */\n){\n  HashElem *elem;                /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n\n  if( pH->ht ){\n    struct _ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n  }else{\n    elem = pH->first;\n    count = pH->count;\n  }\n  while( count-- && ALWAYS(elem) ){\n    if( elem->nKey==nKey && sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){ \n      return elem;\n    }\n    elem = elem->next;\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  Hash *pH,         /* The pH containing \"elem\" */\n  HashElem* elem,   /* The element to be removed from the pH */\n  unsigned int h    /* Hash value for the element */\n){\n  struct _ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  if( pH->ht ){\n    pEntry = &pH->ht[h];\n    if( pEntry->chain==elem ){\n      pEntry->chain = elem->next;\n    }\n    pEntry->count--;\n    assert( pEntry->count>=0 );\n  }\n  sqlite3_free( elem );\n  pH->count--;\n  if( pH->count==0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    sqlite3HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey, int nKey){\n  HashElem *elem;    /* The element that matches key */\n  unsigned int h;    /* A hash on key */\n\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  assert( nKey>=0 );\n  if( pH->ht ){\n    h = strHash(pKey, nKey) % pH->htsize;\n  }else{\n    h = 0;\n  }\n  elem = findElementGivenHash(pH, pKey, nKey, h);\n  return elem ? elem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created and NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, int nKey, void *data){\n  unsigned int h;       /* the hash of the key modulo hash table size */\n  HashElem *elem;       /* Used to loop thru the element list */\n  HashElem *new_elem;   /* New element added to the pH */\n\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  assert( nKey>=0 );\n  if( pH->htsize ){\n    h = strHash(pKey, nKey) % pH->htsize;\n  }else{\n    h = 0;\n  }\n  elem = findElementGivenHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n      elem->pKey = pKey;\n      assert(nKey==elem->nKey);\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );\n  if( new_elem==0 ) return data;\n  new_elem->pKey = pKey;\n  new_elem->nKey = nKey;\n  new_elem->data = data;\n  pH->count++;\n  if( pH->count>=10 && pH->count > 2*pH->htsize ){\n    if( rehash(pH, pH->count*2) ){\n      assert( pH->htsize>0 );\n      h = strHash(pKey, nKey) % pH->htsize;\n    }\n  }\n  if( pH->ht ){\n    insertElement(pH, &pH->ht[h], new_elem);\n  }else{\n    insertElement(pH, 0, new_elem);\n  }\n  return 0;\n}\n\n/************** End of hash.c ************************************************/\n/************** Begin file opcodes.c *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the mkopcodec.awk script for details. */\n#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int i){\n static const char *const azName[] = { \"?\",\n     /*   1 */ \"Goto\",\n     /*   2 */ \"Gosub\",\n     /*   3 */ \"Return\",\n     /*   4 */ \"Yield\",\n     /*   5 */ \"HaltIfNull\",\n     /*   6 */ \"Halt\",\n     /*   7 */ \"Integer\",\n     /*   8 */ \"Int64\",\n     /*   9 */ \"String\",\n     /*  10 */ \"Null\",\n     /*  11 */ \"Blob\",\n     /*  12 */ \"Variable\",\n     /*  13 */ \"Move\",\n     /*  14 */ \"Copy\",\n     /*  15 */ \"SCopy\",\n     /*  16 */ \"ResultRow\",\n     /*  17 */ \"CollSeq\",\n     /*  18 */ \"Function\",\n     /*  19 */ \"Not\",\n     /*  20 */ \"AddImm\",\n     /*  21 */ \"MustBeInt\",\n     /*  22 */ \"RealAffinity\",\n     /*  23 */ \"Permutation\",\n     /*  24 */ \"Compare\",\n     /*  25 */ \"Jump\",\n     /*  26 */ \"Once\",\n     /*  27 */ \"If\",\n     /*  28 */ \"IfNot\",\n     /*  29 */ \"Column\",\n     /*  30 */ \"Affinity\",\n     /*  31 */ \"MakeRecord\",\n     /*  32 */ \"Count\",\n     /*  33 */ \"Savepoint\",\n     /*  34 */ \"AutoCommit\",\n     /*  35 */ \"Transaction\",\n     /*  36 */ \"ReadCookie\",\n     /*  37 */ \"SetCookie\",\n     /*  38 */ \"VerifyCookie\",\n     /*  39 */ \"OpenRead\",\n     /*  40 */ \"OpenWrite\",\n     /*  41 */ \"OpenAutoindex\",\n     /*  42 */ \"OpenEphemeral\",\n     /*  43 */ \"SorterOpen\",\n     /*  44 */ \"OpenPseudo\",\n     /*  45 */ \"Close\",\n     /*  46 */ \"SeekLt\",\n     /*  47 */ \"SeekLe\",\n     /*  48 */ \"SeekGe\",\n     /*  49 */ \"SeekGt\",\n     /*  50 */ \"Seek\",\n     /*  51 */ \"NotFound\",\n     /*  52 */ \"Found\",\n     /*  53 */ \"IsUnique\",\n     /*  54 */ \"NotExists\",\n     /*  55 */ \"Sequence\",\n     /*  56 */ \"NewRowid\",\n     /*  57 */ \"Insert\",\n     /*  58 */ \"InsertInt\",\n     /*  59 */ \"Delete\",\n     /*  60 */ \"ResetCount\",\n     /*  61 */ \"SorterCompare\",\n     /*  62 */ \"SorterData\",\n     /*  63 */ \"RowKey\",\n     /*  64 */ \"RowData\",\n     /*  65 */ \"Rowid\",\n     /*  66 */ \"NullRow\",\n     /*  67 */ \"Last\",\n     /*  68 */ \"Or\",\n     /*  69 */ \"And\",\n     /*  70 */ \"SorterSort\",\n     /*  71 */ \"Sort\",\n     /*  72 */ \"Rewind\",\n     /*  73 */ \"IsNull\",\n     /*  74 */ \"NotNull\",\n     /*  75 */ \"Ne\",\n     /*  76 */ \"Eq\",\n     /*  77 */ \"Gt\",\n     /*  78 */ \"Le\",\n     /*  79 */ \"Lt\",\n     /*  80 */ \"Ge\",\n     /*  81 */ \"SorterNext\",\n     /*  82 */ \"BitAnd\",\n     /*  83 */ \"BitOr\",\n     /*  84 */ \"ShiftLeft\",\n     /*  85 */ \"ShiftRight\",\n     /*  86 */ \"Add\",\n     /*  87 */ \"Subtract\",\n     /*  88 */ \"Multiply\",\n     /*  89 */ \"Divide\",\n     /*  90 */ \"Remainder\",\n     /*  91 */ \"Concat\",\n     /*  92 */ \"Prev\",\n     /*  93 */ \"BitNot\",\n     /*  94 */ \"String8\",\n     /*  95 */ \"Next\",\n     /*  96 */ \"SorterInsert\",\n     /*  97 */ \"IdxInsert\",\n     /*  98 */ \"IdxDelete\",\n     /*  99 */ \"IdxRowid\",\n     /* 100 */ \"IdxLT\",\n     /* 101 */ \"IdxGE\",\n     /* 102 */ \"Destroy\",\n     /* 103 */ \"Clear\",\n     /* 104 */ \"CreateIndex\",\n     /* 105 */ \"CreateTable\",\n     /* 106 */ \"ParseSchema\",\n     /* 107 */ \"LoadAnalysis\",\n     /* 108 */ \"DropTable\",\n     /* 109 */ \"DropIndex\",\n     /* 110 */ \"DropTrigger\",\n     /* 111 */ \"IntegrityCk\",\n     /* 112 */ \"RowSetAdd\",\n     /* 113 */ \"RowSetRead\",\n     /* 114 */ \"RowSetTest\",\n     /* 115 */ \"Program\",\n     /* 116 */ \"Param\",\n     /* 117 */ \"FkCounter\",\n     /* 118 */ \"FkIfZero\",\n     /* 119 */ \"MemMax\",\n     /* 120 */ \"IfPos\",\n     /* 121 */ \"IfNeg\",\n     /* 122 */ \"IfZero\",\n     /* 123 */ \"AggStep\",\n     /* 124 */ \"AggFinal\",\n     /* 125 */ \"Checkpoint\",\n     /* 126 */ \"JournalMode\",\n     /* 127 */ \"Vacuum\",\n     /* 128 */ \"IncrVacuum\",\n     /* 129 */ \"Expire\",\n     /* 130 */ \"Real\",\n     /* 131 */ \"TableLock\",\n     /* 132 */ \"VBegin\",\n     /* 133 */ \"VCreate\",\n     /* 134 */ \"VDestroy\",\n     /* 135 */ \"VOpen\",\n     /* 136 */ \"VFilter\",\n     /* 137 */ \"VColumn\",\n     /* 138 */ \"VNext\",\n     /* 139 */ \"VRename\",\n     /* 140 */ \"VUpdate\",\n     /* 141 */ \"ToText\",\n     /* 142 */ \"ToBlob\",\n     /* 143 */ \"ToNumeric\",\n     /* 144 */ \"ToInt\",\n     /* 145 */ \"ToReal\",\n     /* 146 */ \"Pagecount\",\n     /* 147 */ \"MaxPgcnt\",\n     /* 148 */ \"Trace\",\n     /* 149 */ \"Noop\",\n     /* 150 */ \"Explain\",\n  };\n  return azName[i];\n}\n#endif\n\n/************** End of opcodes.c *********************************************/\n/************** Begin file os_unix.c *****************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the VFS implementation for unix-like operating systems\n** include Linux, MacOSX, *BSD, QNX, VxWorks, AIX, HPUX, and others.\n**\n** There are actually several different VFS implementations in this file.\n** The differences are in the way that file locking is done.  The default\n** implementation uses Posix Advisory Locks.  Alternative implementations\n** use flock(), dot-files, various proprietary locking schemas, or simply\n** skip locking all together.\n**\n** This source file is organized into divisions where the logic for various\n** subfunctions is contained within the appropriate division.  PLEASE\n** KEEP THE STRUCTURE OF THIS FILE INTACT.  New code should be placed\n** in the correct division and should be clearly labeled.\n**\n** The layout of divisions is as follows:\n**\n**   *  General-purpose declarations and utility functions.\n**   *  Unique file ID logic used by VxWorks.\n**   *  Various locking primitive implementations (all except proxy locking):\n**      + for Posix Advisory Locks\n**      + for no-op locks\n**      + for dot-file locks\n**      + for flock() locking\n**      + for named semaphore locks (VxWorks only)\n**      + for AFP filesystem locks (MacOSX only)\n**   *  sqlite3_file methods not associated with locking.\n**   *  Definitions of sqlite3_io_methods objects for all locking\n**      methods plus \"finder\" functions for each locking method.\n**   *  sqlite3_vfs method implementations.\n**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)\n**   *  Definitions of sqlite3_vfs objects for all locking methods\n**      plus implementations of sqlite3_os_init() and sqlite3_os_end().\n*/\n#if SQLITE_OS_UNIX              /* This file is used on unix only */\n\n/* Use posix_fallocate() if it is available\n*/\n#if !defined(HAVE_POSIX_FALLOCATE) \\\n      && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)\n# define HAVE_POSIX_FALLOCATE 1\n#endif\n\n/*\n** There are various methods for file locking used for concurrency\n** control:\n**\n**   1. POSIX locking (the default),\n**   2. No locking,\n**   3. Dot-file locking,\n**   4. flock() locking,\n**   5. AFP locking (OSX only),\n**   6. Named POSIX semaphores (VXWorks only),\n**   7. proxy locking. (OSX only)\n**\n** Styles 4, 5, and 7 are only available of SQLITE_ENABLE_LOCKING_STYLE\n** is defined to 1.  The SQLITE_ENABLE_LOCKING_STYLE also enables automatic\n** selection of the appropriate locking style based on the filesystem\n** where the database is located.  \n*/\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/*\n** Define the OS_VXWORKS pre-processor macro to 1 if building on \n** vxworks, or 0 otherwise.\n*/\n#ifndef OS_VXWORKS\n#  if defined(__RTP__) || defined(_WRS_KERNEL)\n#    define OS_VXWORKS 1\n#  else\n#    define OS_VXWORKS 0\n#  endif\n#endif\n\n/*\n** These #defines should enable >2GB file support on Posix if the\n** underlying operating system supports it.  If the OS lacks\n** large file support, these should be no-ops.\n**\n** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch\n** on the compiler command line.  This is necessary if you are compiling\n** on a recent machine (ex: RedHat 7.2) but you want your code to work\n** on an older machine (ex: RedHat 6.0).  If you compile on RedHat 7.2\n** without this option, LFS is enable.  But LFS does not exist in the kernel\n** in RedHat 6.0, so the code won't work.  Hence, for maximum binary\n** portability you should omit LFS.\n**\n** The previous paragraph was written in 2005.  (This paragraph is written\n** on 2008-11-28.) These days, all Linux kernels support large files, so\n** you should probably leave LFS enabled.  But some embedded platforms might\n** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n/*\n** standard include files.\n*/\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <unistd.h>\n/* #include <time.h> */\n#include <sys/time.h>\n#include <errno.h>\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n#include <sys/mman.h>\n#endif\n\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n# include <sys/ioctl.h>\n# if OS_VXWORKS\n#  include <semaphore.h>\n#  include <limits.h>\n# else\n#  include <sys/file.h>\n#  include <sys/param.h>\n# endif\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */\n\n#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)\n# include <sys/mount.h>\n#endif\n\n#ifdef HAVE_UTIME\n# include <utime.h>\n#endif\n\n/*\n** Allowed values of unixFile.fsFlags\n*/\n#define SQLITE_FSFLAGS_IS_MSDOS     0x1\n\n/*\n** If we are to be thread-safe, include the pthreads header and define\n** the SQLITE_UNIX_THREADS macro.\n*/\n#if SQLITE_THREADSAFE\n/* # include <pthread.h> */\n# define SQLITE_UNIX_THREADS 1\n#endif\n\n/*\n** Default permissions when creating a new file\n*/\n#ifndef SQLITE_DEFAULT_FILE_PERMISSIONS\n# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644\n#endif\n\n/*\n** Default permissions when creating auto proxy dir\n*/\n#ifndef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n# define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755\n#endif\n\n/*\n** Maximum supported path-length.\n*/\n#define MAX_PATHNAME 512\n\n/*\n** Only set the lastErrno if the error code is a real error and not \n** a normal expected return code of SQLITE_BUSY or SQLITE_OK\n*/\n#define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))\n\n/* Forward references */\ntypedef struct unixShm unixShm;               /* Connection shared memory */\ntypedef struct unixShmNode unixShmNode;       /* Shared memory instance */\ntypedef struct unixInodeInfo unixInodeInfo;   /* An i-node */\ntypedef struct UnixUnusedFd UnixUnusedFd;     /* An unused file descriptor */\n\n/*\n** Sometimes, after a file handle is closed by SQLite, the file descriptor\n** cannot be closed immediately. In these cases, instances of the following\n** structure are used to store the file descriptor while waiting for an\n** opportunity to either close or reuse it.\n*/\nstruct UnixUnusedFd {\n  int fd;                   /* File descriptor to close */\n  int flags;                /* Flags this file descriptor was opened with */\n  UnixUnusedFd *pNext;      /* Next unused file descriptor on same file */\n};\n\n/*\n** The unixFile structure is subclass of sqlite3_file specific to the unix\n** VFS implementations.\n*/\ntypedef struct unixFile unixFile;\nstruct unixFile {\n  sqlite3_io_methods const *pMethod;  /* Always the first entry */\n  sqlite3_vfs *pVfs;                  /* The VFS that created this unixFile */\n  unixInodeInfo *pInode;              /* Info about locks on this inode */\n  int h;                              /* The file descriptor */\n  unsigned char eFileLock;            /* The type of lock held on this fd */\n  unsigned short int ctrlFlags;       /* Behavioral bits.  UNIXFILE_* flags */\n  int lastErrno;                      /* The unix errno from last I/O error */\n  void *lockingContext;               /* Locking style specific state */\n  UnixUnusedFd *pUnused;              /* Pre-allocated UnixUnusedFd */\n  const char *zPath;                  /* Name of the file */\n  unixShm *pShm;                      /* Shared memory segment information */\n  int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */\n  int nFetchOut;                      /* Number of outstanding xFetch refs */\n  sqlite3_int64 mmapSize;             /* Usable size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeActual;       /* Actual size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeMax;          /* Configured FCNTL_MMAP_SIZE value */\n  void *pMapRegion;                   /* Memory mapped region */\n#ifdef __QNXNTO__\n  int sectorSize;                     /* Device sector size */\n  int deviceCharacteristics;          /* Precomputed device characteristics */\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int openFlags;                      /* The flags specified at open() */\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)\n  unsigned fsFlags;                   /* cached details from statfs() */\n#endif\n#if OS_VXWORKS\n  struct vxworksFileId *pId;          /* Unique file ID */\n#endif\n#ifdef SQLITE_DEBUG\n  /* The next group of variables are used to track whether or not the\n  ** transaction counter in bytes 24-27 of database files are updated\n  ** whenever any part of the database changes.  An assertion fault will\n  ** occur if a file is updated without also updating the transaction\n  ** counter.  This test is made to avoid new problems similar to the\n  ** one described by ticket #3584. \n  */\n  unsigned char transCntrChng;   /* True if the transaction counter changed */\n  unsigned char dbUpdate;        /* True if any part of database file changed */\n  unsigned char inNormalWrite;   /* True if in a normal write operation */\n\n#endif\n\n#ifdef SQLITE_TEST\n  /* In test mode, increase the size of this structure a bit so that \n  ** it is larger than the struct CrashFile defined in test6.c.\n  */\n  char aPadding[32];\n#endif\n};\n\n/*\n** Allowed values for the unixFile.ctrlFlags bitmask:\n*/\n#define UNIXFILE_EXCL        0x01     /* Connections from one process only */\n#define UNIXFILE_RDONLY      0x02     /* Connection is read only */\n#define UNIXFILE_PERSIST_WAL 0x04     /* Persistent WAL mode */\n#ifndef SQLITE_DISABLE_DIRSYNC\n# define UNIXFILE_DIRSYNC    0x08     /* Directory sync needed */\n#else\n# define UNIXFILE_DIRSYNC    0x00\n#endif\n#define UNIXFILE_PSOW        0x10     /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n#define UNIXFILE_DELETE      0x20     /* Delete on close */\n#define UNIXFILE_URI         0x40     /* Filename might have query parameters */\n#define UNIXFILE_NOLOCK      0x80     /* Do no file locking */\n#define UNIXFILE_WARNED    0x0100     /* verifyDbFile() warnings have been issued */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_unix.c ***************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n# ifndef SQLITE_DEBUG_OS_TRACE\n#   define SQLITE_DEBUG_OS_TRACE 0\n# endif\n  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;\n# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X\n#else\n# define OSTRACE(X)\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef _HWTIME_H_\n#define _HWTIME_H_\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(_HWTIME_H_) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_io_error_hit = 0;            /* Total number of I/O Errors */\nSQLITE_API int sqlite3_io_error_hardhit = 0;        /* Number of non-benign errors */\nSQLITE_API int sqlite3_io_error_pending = 0;        /* Count down to first I/O error */\nSQLITE_API int sqlite3_io_error_persist = 0;        /* True if I/O errors persist */\nSQLITE_API int sqlite3_io_error_benign = 0;         /* True if errors are benign */\nSQLITE_API int sqlite3_diskfull_pending = 0;\nSQLITE_API int sqlite3_diskfull = 0;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_open_file_count = 0;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_unix.c ********************/\n\n/*\n** Define various macros that are missing from some systems.\n*/\n#ifndef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifdef SQLITE_DISABLE_LFS\n# undef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifndef O_NOFOLLOW\n# define O_NOFOLLOW 0\n#endif\n#ifndef O_BINARY\n# define O_BINARY 0\n#endif\n\n/*\n** The threadid macro resolves to the thread-id or to 0.  Used for\n** testing and debugging only.\n*/\n#if SQLITE_THREADSAFE\n#define threadid pthread_self()\n#else\n#define threadid 0\n#endif\n\n/*\n** HAVE_MREMAP defaults to true on Linux and false everywhere else.\n*/\n#if !defined(HAVE_MREMAP)\n# if defined(__linux__) && defined(_GNU_SOURCE)\n#  define HAVE_MREMAP 1\n# else\n#  define HAVE_MREMAP 0\n# endif\n#endif\n\n/*\n** Different Unix systems declare open() in different ways.  Same use\n** open(const char*,int,mode_t).  Others use open(const char*,int,...).\n** The difference is important when using a pointer to the function.\n**\n** The safest way to deal with the problem is to always use this wrapper\n** which always has the same well-defined interface.\n*/\nstatic int posixOpen(const char *zFile, int flags, int mode){\n  return open(zFile, flags, mode);\n}\n\n/*\n** On some systems, calls to fchown() will trigger a message in a security\n** log if they come from non-root processes.  So avoid calling fchown() if\n** we are not running as root.\n*/\nstatic int posixFchown(int fd, uid_t uid, gid_t gid){\n  return geteuid() ? 0 : fchown(fd,uid,gid);\n}\n\n/* Forward reference */\nstatic int openDirectory(const char*, int*);\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct unix_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n  { \"open\",         (sqlite3_syscall_ptr)posixOpen,  0  },\n#define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)\n\n  { \"close\",        (sqlite3_syscall_ptr)close,      0  },\n#define osClose     ((int(*)(int))aSyscall[1].pCurrent)\n\n  { \"access\",       (sqlite3_syscall_ptr)access,     0  },\n#define osAccess    ((int(*)(const char*,int))aSyscall[2].pCurrent)\n\n  { \"getcwd\",       (sqlite3_syscall_ptr)getcwd,     0  },\n#define osGetcwd    ((char*(*)(char*,size_t))aSyscall[3].pCurrent)\n\n  { \"stat\",         (sqlite3_syscall_ptr)stat,       0  },\n#define osStat      ((int(*)(const char*,struct stat*))aSyscall[4].pCurrent)\n\n/*\n** The DJGPP compiler environment looks mostly like Unix, but it\n** lacks the fcntl() system call.  So redefine fcntl() to be something\n** that always succeeds.  This means that locking does not occur under\n** DJGPP.  But it is DOS - what did you expect?\n*/\n#ifdef __DJGPP__\n  { \"fstat\",        0,                 0  },\n#define osFstat(a,b,c)    0\n#else     \n  { \"fstat\",        (sqlite3_syscall_ptr)fstat,      0  },\n#define osFstat     ((int(*)(int,struct stat*))aSyscall[5].pCurrent)\n#endif\n\n  { \"ftruncate\",    (sqlite3_syscall_ptr)ftruncate,  0  },\n#define osFtruncate ((int(*)(int,off_t))aSyscall[6].pCurrent)\n\n  { \"fcntl\",        (sqlite3_syscall_ptr)fcntl,      0  },\n#define osFcntl     ((int(*)(int,int,...))aSyscall[7].pCurrent)\n\n  { \"read\",         (sqlite3_syscall_ptr)read,       0  },\n#define osRead      ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pread\",        (sqlite3_syscall_ptr)pread,      0  },\n#else\n  { \"pread\",        (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pread64\",      (sqlite3_syscall_ptr)pread64,    0  },\n#else\n  { \"pread64\",      (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread64   ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)\n\n  { \"write\",        (sqlite3_syscall_ptr)write,      0  },\n#define osWrite     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pwrite\",       (sqlite3_syscall_ptr)pwrite,     0  },\n#else\n  { \"pwrite\",       (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                    aSyscall[12].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pwrite64\",     (sqlite3_syscall_ptr)pwrite64,   0  },\n#else\n  { \"pwrite64\",     (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                    aSyscall[13].pCurrent)\n\n  { \"fchmod\",       (sqlite3_syscall_ptr)fchmod,     0  },\n#define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n  { \"fallocate\",    (sqlite3_syscall_ptr)posix_fallocate,  0 },\n#else\n  { \"fallocate\",    (sqlite3_syscall_ptr)0,                0 },\n#endif\n#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent)\n\n  { \"unlink\",       (sqlite3_syscall_ptr)unlink,           0 },\n#define osUnlink    ((int(*)(const char*))aSyscall[16].pCurrent)\n\n  { \"openDirectory\",    (sqlite3_syscall_ptr)openDirectory,      0 },\n#define osOpenDirectory ((int(*)(const char*,int*))aSyscall[17].pCurrent)\n\n  { \"mkdir\",        (sqlite3_syscall_ptr)mkdir,           0 },\n#define osMkdir     ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)\n\n  { \"rmdir\",        (sqlite3_syscall_ptr)rmdir,           0 },\n#define osRmdir     ((int(*)(const char*))aSyscall[19].pCurrent)\n\n  { \"fchown\",       (sqlite3_syscall_ptr)posixFchown,     0 },\n#define osFchown    ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)\n\n  { \"mmap\",       (sqlite3_syscall_ptr)mmap,     0 },\n#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[21].pCurrent)\n\n  { \"munmap\",       (sqlite3_syscall_ptr)munmap,          0 },\n#define osMunmap ((void*(*)(void*,size_t))aSyscall[22].pCurrent)\n\n#if HAVE_MREMAP\n  { \"mremap\",       (sqlite3_syscall_ptr)mremap,          0 },\n#else\n  { \"mremap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[23].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"unix\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int unixSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr unixGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n/*\n** Invoke open().  Do so multiple times, until it either succeeds or\n** fails for some reason other than EINTR.\n**\n** If the file creation mode \"m\" is 0 then set it to the default for\n** SQLite.  The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally\n** 0644) as modified by the system umask.  If m is not 0, then\n** make the file creation mode be exactly m ignoring the umask.\n**\n** The m parameter will be non-zero only when creating -wal, -journal,\n** and -shm files.  We want those files to have *exactly* the same\n** permissions as their original database, unadulterated by the umask.\n** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a\n** transaction crashes and leaves behind hot journals, then any\n** process that is able to write to the database will also be able to\n** recover the hot journals.\n*/\nstatic int robust_open(const char *z, int f, mode_t m){\n  int fd;\n  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;\n  do{\n#if defined(O_CLOEXEC)\n    fd = osOpen(z,f|O_CLOEXEC,m2);\n#else\n    fd = osOpen(z,f,m2);\n#endif\n  }while( fd<0 && errno==EINTR );\n  if( fd>=0 ){\n    if( m!=0 ){\n      struct stat statbuf;\n      if( osFstat(fd, &statbuf)==0 \n       && statbuf.st_size==0\n       && (statbuf.st_mode&0777)!=m \n      ){\n        osFchmod(fd, m);\n      }\n    }\n#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)\n    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);\n#endif\n  }\n  return fd;\n}\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the unixInodeInfo and\n** vxworksFileId objects used by this file, all of which may be \n** shared by multiple threads.\n**\n** Function unixMutexHeld() is used to assert() that the global mutex \n** is held when required. This function is only used as part of assert() \n** statements. e.g.\n**\n**   unixEnterMutex()\n**     assert( unixMutexHeld() );\n**   unixEnterLeave()\n*/\nstatic void unixEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\nstatic void unixLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n#ifdef SQLITE_DEBUG\nstatic int unixMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n#endif\n\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Helper function for printing out trace information from debugging\n** binaries. This returns the string represetation of the supplied\n** integer lock-type.\n*/\nstatic const char *azFileLock(int eFileLock){\n  switch( eFileLock ){\n    case NO_LOCK: return \"NONE\";\n    case SHARED_LOCK: return \"SHARED\";\n    case RESERVED_LOCK: return \"RESERVED\";\n    case PENDING_LOCK: return \"PENDING\";\n    case EXCLUSIVE_LOCK: return \"EXCLUSIVE\";\n  }\n  return \"ERROR\";\n}\n#endif\n\n#ifdef SQLITE_LOCK_TRACE\n/*\n** Print out information about all locking operations.\n**\n** This routine is used for troubleshooting locks on multithreaded\n** platforms.  Enable by compiling with the -DSQLITE_LOCK_TRACE\n** command-line option on the compiler.  This code is normally\n** turned off.\n*/\nstatic int lockTrace(int fd, int op, struct flock *p){\n  char *zOpName, *zType;\n  int s;\n  int savedErrno;\n  if( op==F_GETLK ){\n    zOpName = \"GETLK\";\n  }else if( op==F_SETLK ){\n    zOpName = \"SETLK\";\n  }else{\n    s = osFcntl(fd, op, p);\n    sqlite3DebugPrintf(\"fcntl unknown %d %d %d\\n\", fd, op, s);\n    return s;\n  }\n  if( p->l_type==F_RDLCK ){\n    zType = \"RDLCK\";\n  }else if( p->l_type==F_WRLCK ){\n    zType = \"WRLCK\";\n  }else if( p->l_type==F_UNLCK ){\n    zType = \"UNLCK\";\n  }else{\n    assert( 0 );\n  }\n  assert( p->l_whence==SEEK_SET );\n  s = osFcntl(fd, op, p);\n  savedErrno = errno;\n  sqlite3DebugPrintf(\"fcntl %d %d %s %s %d %d %d %d\\n\",\n     threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len,\n     (int)p->l_pid, s);\n  if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){\n    struct flock l2;\n    l2 = *p;\n    osFcntl(fd, F_GETLK, &l2);\n    if( l2.l_type==F_RDLCK ){\n      zType = \"RDLCK\";\n    }else if( l2.l_type==F_WRLCK ){\n      zType = \"WRLCK\";\n    }else if( l2.l_type==F_UNLCK ){\n      zType = \"UNLCK\";\n    }else{\n      assert( 0 );\n    }\n    sqlite3DebugPrintf(\"fcntl-failure-reason: %s %d %d %d\\n\",\n       zType, (int)l2.l_start, (int)l2.l_len, (int)l2.l_pid);\n  }\n  errno = savedErrno;\n  return s;\n}\n#undef osFcntl\n#define osFcntl lockTrace\n#endif /* SQLITE_LOCK_TRACE */\n\n/*\n** Retry ftruncate() calls that fail due to EINTR\n*/\nstatic int robust_ftruncate(int h, sqlite3_int64 sz){\n  int rc;\n  do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n\n/*\n** This routine translates a standard POSIX errno code into something\n** useful to the clients of the sqlite3 functions.  Specifically, it is\n** intended to translate a variety of \"try again\" errors into SQLITE_BUSY\n** and a variety of \"please close the file descriptor NOW\" errors into \n** SQLITE_IOERR\n** \n** Errors during initialization of locks, or file system support for locks,\n** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.\n*/\nstatic int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {\n  switch (posixError) {\n#if 0\n  /* At one point this code was not commented out. In theory, this branch\n  ** should never be hit, as this function should only be called after\n  ** a locking-related function (i.e. fcntl()) has returned non-zero with\n  ** the value of errno as the first argument. Since a system call has failed,\n  ** errno should be non-zero.\n  **\n  ** Despite this, if errno really is zero, we still don't want to return\n  ** SQLITE_OK. The system call failed, and *some* SQLite error should be\n  ** propagated back to the caller. Commenting this branch out means errno==0\n  ** will be handled by the \"default:\" case below.\n  */\n  case 0: \n    return SQLITE_OK;\n#endif\n\n  case EAGAIN:\n  case ETIMEDOUT:\n  case EBUSY:\n  case EINTR:\n  case ENOLCK:  \n    /* random NFS retry error, unless during file system support \n     * introspection, in which it actually means what it says */\n    return SQLITE_BUSY;\n    \n  case EACCES: \n    /* EACCES is like EAGAIN during locking operations, but not any other time*/\n    if( (sqliteIOErr == SQLITE_IOERR_LOCK) || \n        (sqliteIOErr == SQLITE_IOERR_UNLOCK) || \n        (sqliteIOErr == SQLITE_IOERR_RDLOCK) ||\n        (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) ){\n      return SQLITE_BUSY;\n    }\n    /* else fall through */\n  case EPERM: \n    return SQLITE_PERM;\n    \n  /* EDEADLK is only possible if a call to fcntl(F_SETLKW) is made. And\n  ** this module never makes such a call. And the code in SQLite itself \n  ** asserts that SQLITE_IOERR_BLOCKED is never returned. For these reasons\n  ** this case is also commented out. If the system does set errno to EDEADLK,\n  ** the default SQLITE_IOERR_XXX code will be returned. */\n#if 0\n  case EDEADLK:\n    return SQLITE_IOERR_BLOCKED;\n#endif\n    \n#if EOPNOTSUPP!=ENOTSUP\n  case EOPNOTSUPP: \n    /* something went terribly awry, unless during file system support \n     * introspection, in which it actually means what it says */\n#endif\n#ifdef ENOTSUP\n  case ENOTSUP: \n    /* invalid fd, unless during file system support introspection, in which \n     * it actually means what it says */\n#endif\n  case EIO:\n  case EBADF:\n  case EINVAL:\n  case ENOTCONN:\n  case ENODEV:\n  case ENXIO:\n  case ENOENT:\n#ifdef ESTALE                     /* ESTALE is not defined on Interix systems */\n  case ESTALE:\n#endif\n  case ENOSYS:\n    /* these should force the client to close the file and reconnect */\n    \n  default: \n    return sqliteIOErr;\n  }\n}\n\n\n/******************************************************************************\n****************** Begin Unique File ID Utility Used By VxWorks ***************\n**\n** On most versions of unix, we can get a unique ID for a file by concatenating\n** the device number and the inode number.  But this does not work on VxWorks.\n** On VxWorks, a unique file id must be based on the canonical filename.\n**\n** A pointer to an instance of the following structure can be used as a\n** unique file ID in VxWorks.  Each instance of this structure contains\n** a copy of the canonical filename.  There is also a reference count.  \n** The structure is reclaimed when the number of pointers to it drops to\n** zero.\n**\n** There are never very many files open at one time and lookups are not\n** a performance-critical path, so it is sufficient to put these\n** structures on a linked list.\n*/\nstruct vxworksFileId {\n  struct vxworksFileId *pNext;  /* Next in a list of them all */\n  int nRef;                     /* Number of references to this one */\n  int nName;                    /* Length of the zCanonicalName[] string */\n  char *zCanonicalName;         /* Canonical filename */\n};\n\n#if OS_VXWORKS\n/* \n** All unique filenames are held on a linked list headed by this\n** variable:\n*/\nstatic struct vxworksFileId *vxworksFileList = 0;\n\n/*\n** Simplify a filename into its canonical form\n** by making the following changes:\n**\n**  * removing any trailing and duplicate /\n**  * convert /./ into just /\n**  * convert /A/../ where A is any simple name into just /\n**\n** Changes are made in-place.  Return the new name length.\n**\n** The original filename is in z[0..n-1].  Return the number of\n** characters in the simplified name.\n*/\nstatic int vxworksSimplifyName(char *z, int n){\n  int i, j;\n  while( n>1 && z[n-1]=='/' ){ n--; }\n  for(i=j=0; i<n; i++){\n    if( z[i]=='/' ){\n      if( z[i+1]=='/' ) continue;\n      if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){\n        i += 1;\n        continue;\n      }\n      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){\n        while( j>0 && z[j-1]!='/' ){ j--; }\n        if( j>0 ){ j--; }\n        i += 2;\n        continue;\n      }\n    }\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n  return j;\n}\n\n/*\n** Find a unique file ID for the given absolute pathname.  Return\n** a pointer to the vxworksFileId object.  This pointer is the unique\n** file ID.\n**\n** The nRef field of the vxworksFileId object is incremented before\n** the object is returned.  A new vxworksFileId object is created\n** and added to the global list if necessary.\n**\n** If a memory allocation error occurs, return NULL.\n*/\nstatic struct vxworksFileId *vxworksFindFileId(const char *zAbsoluteName){\n  struct vxworksFileId *pNew;         /* search key and new file ID */\n  struct vxworksFileId *pCandidate;   /* For looping over existing file IDs */\n  int n;                              /* Length of zAbsoluteName string */\n\n  assert( zAbsoluteName[0]=='/' );\n  n = (int)strlen(zAbsoluteName);\n  pNew = sqlite3_malloc( sizeof(*pNew) + (n+1) );\n  if( pNew==0 ) return 0;\n  pNew->zCanonicalName = (char*)&pNew[1];\n  memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);\n  n = vxworksSimplifyName(pNew->zCanonicalName, n);\n\n  /* Search for an existing entry that matching the canonical name.\n  ** If found, increment the reference count and return a pointer to\n  ** the existing file ID.\n  */\n  unixEnterMutex();\n  for(pCandidate=vxworksFileList; pCandidate; pCandidate=pCandidate->pNext){\n    if( pCandidate->nName==n \n     && memcmp(pCandidate->zCanonicalName, pNew->zCanonicalName, n)==0\n    ){\n       sqlite3_free(pNew);\n       pCandidate->nRef++;\n       unixLeaveMutex();\n       return pCandidate;\n    }\n  }\n\n  /* No match was found.  We will make a new file ID */\n  pNew->nRef = 1;\n  pNew->nName = n;\n  pNew->pNext = vxworksFileList;\n  vxworksFileList = pNew;\n  unixLeaveMutex();\n  return pNew;\n}\n\n/*\n** Decrement the reference count on a vxworksFileId object.  Free\n** the object when the reference count reaches zero.\n*/\nstatic void vxworksReleaseFileId(struct vxworksFileId *pId){\n  unixEnterMutex();\n  assert( pId->nRef>0 );\n  pId->nRef--;\n  if( pId->nRef==0 ){\n    struct vxworksFileId **pp;\n    for(pp=&vxworksFileList; *pp && *pp!=pId; pp = &((*pp)->pNext)){}\n    assert( *pp==pId );\n    *pp = pId->pNext;\n    sqlite3_free(pId);\n  }\n  unixLeaveMutex();\n}\n#endif /* OS_VXWORKS */\n/*************** End of Unique File ID Utility Used By VxWorks ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Posix Advisory Locking ****************************\n**\n** POSIX advisory locks are broken by design.  ANSI STD 1003.1 (1996)\n** section 6.5.2.2 lines 483 through 490 specify that when a process\n** sets or clears a lock, that operation overrides any prior locks set\n** by the same process.  It does not explicitly say so, but this implies\n** that it overrides locks set by the same process using a different\n** file descriptor.  Consider this test case:\n**\n**       int fd1 = open(\"./file1\", O_RDWR|O_CREAT, 0644);\n**       int fd2 = open(\"./file2\", O_RDWR|O_CREAT, 0644);\n**\n** Suppose ./file1 and ./file2 are really the same file (because\n** one is a hard or symbolic link to the other) then if you set\n** an exclusive lock on fd1, then try to get an exclusive lock\n** on fd2, it works.  I would have expected the second lock to\n** fail since there was already a lock on the file due to fd1.\n** But not so.  Since both locks came from the same process, the\n** second overrides the first, even though they were on different\n** file descriptors opened on different file names.\n**\n** This means that we cannot use POSIX locks to synchronize file access\n** among competing threads of the same process.  POSIX locks will work fine\n** to synchronize access for threads in separate processes, but not\n** threads within the same process.\n**\n** To work around the problem, SQLite has to manage file locks internally\n** on its own.  Whenever a new database is opened, we have to find the\n** specific inode of the database file (the inode is determined by the\n** st_dev and st_ino fields of the stat structure that fstat() fills in)\n** and check for locks already existing on that inode.  When locks are\n** created or removed, we have to look at our own internal record of the\n** locks to see if another thread has previously set a lock on that same\n** inode.\n**\n** (Aside: The use of inode numbers as unique IDs does not work on VxWorks.\n** For VxWorks, we have to use the alternative unique ID system based on\n** canonical filename and implemented in the previous division.)\n**\n** The sqlite3_file structure for POSIX is no longer just an integer file\n** descriptor.  It is now a structure that holds the integer file\n** descriptor and a pointer to a structure that describes the internal\n** locks on the corresponding inode.  There is one locking structure\n** per inode, so if the same inode is opened twice, both unixFile structures\n** point to the same locking structure.  The locking structure keeps\n** a reference count (so we will know when to delete it) and a \"cnt\"\n** field that tells us its internal lock status.  cnt==0 means the\n** file is unlocked.  cnt==-1 means the file has an exclusive lock.\n** cnt>0 means there are cnt shared locks on the file.\n**\n** Any attempt to lock or unlock a file first checks the locking\n** structure.  The fcntl() system call is only invoked to set a \n** POSIX lock if the internal lock structure transitions between\n** a locked and an unlocked state.\n**\n** But wait:  there are yet more problems with POSIX advisory locks.\n**\n** If you close a file descriptor that points to a file that has locks,\n** all locks on that file that are owned by the current process are\n** released.  To work around this problem, each unixInodeInfo object\n** maintains a count of the number of pending locks on tha inode.\n** When an attempt is made to close an unixFile, if there are\n** other unixFile open on the same inode that are holding locks, the call\n** to close() the file descriptor is deferred until all of the locks clear.\n** The unixInodeInfo structure keeps a list of file descriptors that need to\n** be closed and that list is walked (and cleared) when the last lock\n** clears.\n**\n** Yet another problem:  LinuxThreads do not play well with posix locks.\n**\n** Many older versions of linux use the LinuxThreads library which is\n** not posix compliant.  Under LinuxThreads, a lock created by thread\n** A cannot be modified or overridden by a different thread B.\n** Only thread A can modify the lock.  Locking behavior is correct\n** if the appliation uses the newer Native Posix Thread Library (NPTL)\n** on linux - with NPTL a lock created by thread A can override locks\n** in thread B.  But there is no way to know at compile-time which\n** threading library is being used.  So there is no way to know at\n** compile-time whether or not thread A can override locks on thread B.\n** One has to do a run-time check to discover the behavior of the\n** current process.\n**\n** SQLite used to support LinuxThreads.  But support for LinuxThreads\n** was dropped beginning with version 3.7.0.  SQLite will still work with\n** LinuxThreads provided that (1) there is no more than one connection \n** per database file in the same process and (2) database connections\n** do not move across threads.\n*/\n\n/*\n** An instance of the following structure serves as the key used\n** to locate a particular unixInodeInfo object.\n*/\nstruct unixFileId {\n  dev_t dev;                  /* Device number */\n#if OS_VXWORKS\n  struct vxworksFileId *pId;  /* Unique file ID for vxworks. */\n#else\n  ino_t ino;                  /* Inode number */\n#endif\n};\n\n/*\n** An instance of the following structure is allocated for each open\n** inode.  Or, on LinuxThreads, there is one of these structures for\n** each inode opened by each thread.\n**\n** A single inode can have multiple file descriptors, so each unixFile\n** structure contains a pointer to an instance of this object and this\n** object keeps a count of the number of unixFile pointing to it.\n*/\nstruct unixInodeInfo {\n  struct unixFileId fileId;       /* The lookup key */\n  int nShared;                    /* Number of SHARED locks held */\n  unsigned char eFileLock;        /* One of SHARED_LOCK, RESERVED_LOCK etc. */\n  unsigned char bProcessLock;     /* An exclusive process lock is held */\n  int nRef;                       /* Number of pointers to this structure */\n  unixShmNode *pShmNode;          /* Shared memory associated with this inode */\n  int nLock;                      /* Number of outstanding file locks */\n  UnixUnusedFd *pUnused;          /* Unused file descriptors to close */\n  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */\n  unixInodeInfo *pPrev;           /*    .... doubly linked */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  unsigned long long sharedByte;  /* for AFP simulated shared lock */\n#endif\n#if OS_VXWORKS\n  sem_t *pSem;                    /* Named POSIX semaphore */\n  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */\n#endif\n};\n\n/*\n** A lists of all unixInodeInfo objects.\n*/\nstatic unixInodeInfo *inodeList = 0;\n\n/*\n**\n** This function - unixLogError_x(), is only ever called via the macro\n** unixLogError().\n**\n** It is invoked after an error occurs in an OS function and errno has been\n** set. It logs a message using sqlite3_log() containing the current value of\n** errno and, if possible, the human-readable equivalent from strerror() or\n** strerror_r().\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). \n** The two subsequent arguments should be the name of the OS function that\n** failed (e.g. \"unlink\", \"open\") and the associated file-system path,\n** if any.\n*/\n#define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)\nstatic int unixLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char *zErr;                     /* Message from strerror() or equivalent */\n  int iErrno = errno;             /* Saved syscall error number */\n\n  /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use\n  ** the strerror() function to obtain the human-readable error message\n  ** equivalent to errno. Otherwise, use strerror_r().\n  */ \n#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)\n  char aErr[80];\n  memset(aErr, 0, sizeof(aErr));\n  zErr = aErr;\n\n  /* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,\n  ** assume that the system provides the GNU version of strerror_r() that\n  ** returns a pointer to a buffer containing the error message. That pointer \n  ** may point to aErr[], or it may point to some static storage somewhere. \n  ** Otherwise, assume that the system provides the POSIX version of \n  ** strerror_r(), which always writes an error message into aErr[].\n  **\n  ** If the code incorrectly assumes that it is the POSIX version that is\n  ** available, the error message will often be an empty string. Not a\n  ** huge problem. Incorrectly concluding that the GNU version is available \n  ** could lead to a segfault though.\n  */\n#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)\n  zErr = \n# endif\n  strerror_r(iErrno, aErr, sizeof(aErr)-1);\n\n#elif SQLITE_THREADSAFE\n  /* This is a threadsafe build, but strerror_r() is not available. */\n  zErr = \"\";\n#else\n  /* Non-threadsafe build, use strerror(). */\n  zErr = strerror(iErrno);\n#endif\n\n  if( zPath==0 ) zPath = \"\";\n  sqlite3_log(errcode,\n      \"os_unix.c:%d: (%d) %s(%s) - %s\",\n      iLine, iErrno, zFunc, zPath, zErr\n  );\n\n  return errcode;\n}\n\n/*\n** Close a file descriptor.\n**\n** We assume that close() almost always works, since it is only in a\n** very sick application or on a very sick platform that it might fail.\n** If it does fail, simply leak the file descriptor, but do log the\n** error.\n**\n** Note that it is not safe to retry close() after EINTR since the\n** file descriptor might have already been reused by another thread.\n** So we don't even try to recover from an EINTR.  Just log the error\n** and move on.\n*/\nstatic void robust_close(unixFile *pFile, int h, int lineno){\n  if( osClose(h) ){\n    unixLogErrorAtLine(SQLITE_IOERR_CLOSE, \"close\",\n                       pFile ? pFile->zPath : 0, lineno);\n  }\n}\n\n/*\n** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.\n*/ \nstatic void closePendingFds(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p;\n  UnixUnusedFd *pNext;\n  for(p=pInode->pUnused; p; p=pNext){\n    pNext = p->pNext;\n    robust_close(pFile, p->fd, __LINE__);\n    sqlite3_free(p);\n  }\n  pInode->pUnused = 0;\n}\n\n/*\n** Release a unixInodeInfo structure previously allocated by findInodeInfo().\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n*/\nstatic void releaseInodeInfo(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  if( ALWAYS(pInode) ){\n    pInode->nRef--;\n    if( pInode->nRef==0 ){\n      assert( pInode->pShmNode==0 );\n      closePendingFds(pFile);\n      if( pInode->pPrev ){\n        assert( pInode->pPrev->pNext==pInode );\n        pInode->pPrev->pNext = pInode->pNext;\n      }else{\n        assert( inodeList==pInode );\n        inodeList = pInode->pNext;\n      }\n      if( pInode->pNext ){\n        assert( pInode->pNext->pPrev==pInode );\n        pInode->pNext->pPrev = pInode->pPrev;\n      }\n      sqlite3_free(pInode);\n    }\n  }\n}\n\n/*\n** Given a file descriptor, locate the unixInodeInfo object that\n** describes that file descriptor.  Create a new one if necessary.  The\n** return value might be uninitialized if an error occurs.\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n**\n** Return an appropriate error code.\n*/\nstatic int findInodeInfo(\n  unixFile *pFile,               /* Unix file with file desc used in the key */\n  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */\n){\n  int rc;                        /* System call return code */\n  int fd;                        /* The file descriptor for pFile */\n  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */\n  struct stat statbuf;           /* Low-level file information */\n  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */\n\n  assert( unixMutexHeld() );\n\n  /* Get low-level information about the file that we can used to\n  ** create a unique name for the file.\n  */\n  fd = pFile->h;\n  rc = osFstat(fd, &statbuf);\n  if( rc!=0 ){\n    pFile->lastErrno = errno;\n#ifdef EOVERFLOW\n    if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;\n#endif\n    return SQLITE_IOERR;\n  }\n\n#ifdef __APPLE__\n  /* On OS X on an msdos filesystem, the inode number is reported\n  ** incorrectly for zero-size files.  See ticket #3260.  To work\n  ** around this problem (we consider it a bug in OS X, not SQLite)\n  ** we always increase the file size to 1 by writing a single byte\n  ** prior to accessing the inode number.  The one byte written is\n  ** an ASCII 'S' character which also happens to be the first byte\n  ** in the header of every SQLite database.  In this way, if there\n  ** is a race condition such that another thread has already populated\n  ** the first page of the database, no damage is done.\n  */\n  if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){\n    do{ rc = osWrite(fd, \"S\", 1); }while( rc<0 && errno==EINTR );\n    if( rc!=1 ){\n      pFile->lastErrno = errno;\n      return SQLITE_IOERR;\n    }\n    rc = osFstat(fd, &statbuf);\n    if( rc!=0 ){\n      pFile->lastErrno = errno;\n      return SQLITE_IOERR;\n    }\n  }\n#endif\n\n  memset(&fileId, 0, sizeof(fileId));\n  fileId.dev = statbuf.st_dev;\n#if OS_VXWORKS\n  fileId.pId = pFile->pId;\n#else\n  fileId.ino = statbuf.st_ino;\n#endif\n  pInode = inodeList;\n  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){\n    pInode = pInode->pNext;\n  }\n  if( pInode==0 ){\n    pInode = sqlite3_malloc( sizeof(*pInode) );\n    if( pInode==0 ){\n      return SQLITE_NOMEM;\n    }\n    memset(pInode, 0, sizeof(*pInode));\n    memcpy(&pInode->fileId, &fileId, sizeof(fileId));\n    pInode->nRef = 1;\n    pInode->pNext = inodeList;\n    pInode->pPrev = 0;\n    if( inodeList ) inodeList->pPrev = pInode;\n    inodeList = pInode;\n  }else{\n    pInode->nRef++;\n  }\n  *ppInode = pInode;\n  return SQLITE_OK;\n}\n\n\n/*\n** Check a unixFile that is a database.  Verify the following:\n**\n** (1) There is exactly one hard link on the file\n** (2) The file is not a symbolic link\n** (3) The file has not been renamed or unlinked\n**\n** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right.\n*/\nstatic void verifyDbFile(unixFile *pFile){\n  struct stat buf;\n  int rc;\n  if( pFile->ctrlFlags & UNIXFILE_WARNED ){\n    /* One or more of the following warnings have already been issued.  Do not\n    ** repeat them so as not to clutter the error log */\n    return;\n  }\n  rc = osFstat(pFile->h, &buf);\n  if( rc!=0 ){\n    sqlite3_log(SQLITE_WARNING, \"cannot fstat db file %s\", pFile->zPath);\n    pFile->ctrlFlags |= UNIXFILE_WARNED;\n    return;\n  }\n  if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){\n    sqlite3_log(SQLITE_WARNING, \"file unlinked while open: %s\", pFile->zPath);\n    pFile->ctrlFlags |= UNIXFILE_WARNED;\n    return;\n  }\n  if( buf.st_nlink>1 ){\n    sqlite3_log(SQLITE_WARNING, \"multiple links to file: %s\", pFile->zPath);\n    pFile->ctrlFlags |= UNIXFILE_WARNED;\n    return;\n  }\n  if( pFile->pInode!=0\n   && ((rc = osStat(pFile->zPath, &buf))!=0\n       || buf.st_ino!=pFile->pInode->fileId.ino)\n  ){\n    sqlite3_log(SQLITE_WARNING, \"file renamed while open: %s\", pFile->zPath);\n    pFile->ctrlFlags |= UNIXFILE_WARNED;\n    return;\n  }\n}\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int unixCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n\n  assert( pFile );\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n\n  /* Otherwise see if some other process holds it.\n  */\n#ifndef __DJGPP__\n  if( !reserved && !pFile->pInode->bProcessLock ){\n    struct flock lock;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = RESERVED_BYTE;\n    lock.l_len = 1;\n    lock.l_type = F_WRLCK;\n    if( osFcntl(pFile->h, F_GETLK, &lock) ){\n      rc = SQLITE_IOERR_CHECKRESERVEDLOCK;\n      pFile->lastErrno = errno;\n    } else if( lock.l_type!=F_UNLCK ){\n      reserved = 1;\n    }\n  }\n#endif\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (unix)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Attempt to set a system-lock on the file pFile.  The lock is \n** described by pLock.\n**\n** If the pFile was opened read/write from unix-excl, then the only lock\n** ever obtained is an exclusive lock, and it is obtained exactly once\n** the first time any lock is attempted.  All subsequent system locking\n** operations become no-ops.  Locking operations still happen internally,\n** in order to coordinate access between separate database connections\n** within this process, but all of that is handled in memory and the\n** operating system does not participate.\n**\n** This function is a pass-through to fcntl(F_SETLK) if pFile is using\n** any VFS other than \"unix-excl\" or if pFile is opened on \"unix-excl\"\n** and is read-only.\n**\n** Zero is returned if the call completes successfully, or -1 if a call\n** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).\n*/\nstatic int unixFileLock(unixFile *pFile, struct flock *pLock){\n  int rc;\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  assert( pInode!=0 );\n  if( ((pFile->ctrlFlags & UNIXFILE_EXCL)!=0 || pInode->bProcessLock)\n   && ((pFile->ctrlFlags & UNIXFILE_RDONLY)==0)\n  ){\n    if( pInode->bProcessLock==0 ){\n      struct flock lock;\n      assert( pInode->nLock==0 );\n      lock.l_whence = SEEK_SET;\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n      lock.l_type = F_WRLCK;\n      rc = osFcntl(pFile->h, F_SETLK, &lock);\n      if( rc<0 ) return rc;\n      pInode->bProcessLock = 1;\n      pInode->nLock++;\n    }else{\n      rc = 0;\n    }\n  }else{\n    rc = osFcntl(pFile->h, F_SETLK, pLock);\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int unixLock(sqlite3_file *id, int eFileLock){\n  /* The following describes the implementation of the various locks and\n  ** lock transitions in terms of the POSIX advisory shared and exclusive\n  ** lock primitives (called read-locks and write-locks below, to avoid\n  ** confusion with SQLite lock names). The algorithms are complicated\n  ** slightly in order to be compatible with windows systems simultaneously\n  ** accessing the same database file, in case that is ever required.\n  **\n  ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved\n  ** byte', each single bytes at well known offsets, and the 'shared byte\n  ** range', a range of 510 bytes at a well known offset.\n  **\n  ** To obtain a SHARED lock, a read-lock is obtained on the 'pending\n  ** byte'.  If this is successful, a random byte from the 'shared byte\n  ** range' is read-locked and the lock on the 'pending byte' released.\n  **\n  ** A process may only obtain a RESERVED lock after it has a SHARED lock.\n  ** A RESERVED lock is implemented by grabbing a write-lock on the\n  ** 'reserved byte'. \n  **\n  ** A process may only obtain a PENDING lock after it has obtained a\n  ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock\n  ** on the 'pending byte'. This ensures that no new SHARED locks can be\n  ** obtained, but existing SHARED locks are allowed to persist. A process\n  ** does not have to obtain a RESERVED lock on the way to a PENDING lock.\n  ** This property is used by the algorithm for rolling back a journal file\n  ** after a crash.\n  **\n  ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is\n  ** implemented by obtaining a write-lock on the entire 'shared byte\n  ** range'. Since all other locks require a read-lock on one of the bytes\n  ** within this range, this ensures that no other locks are held on the\n  ** database. \n  **\n  ** The reason a single byte cannot be used instead of the 'shared byte\n  ** range' is that some versions of windows do not support read-locks. By\n  ** locking a random byte from a range, concurrent SHARED locks may exist\n  ** even if the locking primitive used is always a write-lock.\n  */\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int tErrno = 0;\n\n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (unix)\\n\", pFile->h,\n      azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n      azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid()));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (unix)\\n\", pFile->h,\n            azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct.\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n\n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n  ){\n    rc = SQLITE_BUSY;\n    goto end_lock;\n  }\n\n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n      (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto end_lock;\n  }\n\n\n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  lock.l_len = 1L;\n  lock.l_whence = SEEK_SET;\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);\n    lock.l_start = PENDING_BYTE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        pFile->lastErrno = tErrno;\n      }\n      goto end_lock;\n    }\n  }\n\n\n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n    assert( rc==SQLITE_OK );\n\n    /* Now get the read-lock */\n    lock.l_start = SHARED_FIRST;\n    lock.l_len = SHARED_SIZE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    }\n\n    /* Drop the temporary PENDING lock */\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 1L;\n    lock.l_type = F_UNLCK;\n    if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){\n      /* This could happen with a network mount */\n      tErrno = errno;\n      rc = SQLITE_IOERR_UNLOCK; \n    }\n\n    if( rc ){\n      if( rc!=SQLITE_BUSY ){\n        pFile->lastErrno = tErrno;\n      }\n      goto end_lock;\n    }else{\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n    ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    assert( 0!=pFile->eFileLock );\n    lock.l_type = F_WRLCK;\n\n    assert( eFileLock==RESERVED_LOCK || eFileLock==EXCLUSIVE_LOCK );\n    if( eFileLock==RESERVED_LOCK ){\n      lock.l_start = RESERVED_BYTE;\n      lock.l_len = 1L;\n    }else{\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n    }\n\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        pFile->lastErrno = tErrno;\n      }\n    }\n  }\n  \n\n#ifdef SQLITE_DEBUG\n  /* Set up the transaction-counter change checking flags when\n  ** transitioning from a SHARED to a RESERVED lock.  The change\n  ** from SHARED to RESERVED marks the beginning of a normal\n  ** write operation (not a hot journal rollback).\n  */\n  if( rc==SQLITE_OK\n   && pFile->eFileLock<=SHARED_LOCK\n   && eFileLock==RESERVED_LOCK\n  ){\n    pFile->transCntrChng = 0;\n    pFile->dbUpdate = 0;\n    pFile->inNormalWrite = 1;\n  }\n#endif\n\n\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n\nend_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (unix)\\n\", pFile->h, azFileLock(eFileLock), \n      rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Add the file descriptor used by file handle pFile to the corresponding\n** pUnused list.\n*/\nstatic void setPendingFd(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p = pFile->pUnused;\n  p->pNext = pInode->pUnused;\n  pInode->pUnused = p;\n  pFile->h = -1;\n  pFile->pUnused = 0;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n** \n** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED\n** the byte range is divided into 2 parts and the first part is unlocked then\n** set to a read lock, then the other part is simply unlocked.  This works \n** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to \n** remove the write lock on a region when a read lock is set.\n*/\nstatic int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int rc = SQLITE_OK;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\\n\", pFile->h, eFileLock,\n      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n      getpid()));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n\n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    pFile->inNormalWrite = 0;\n#endif\n\n    /* downgrading to a shared lock on NFS involves clearing the write lock\n    ** before establishing the readlock - to avoid a race condition we downgrade\n    ** the lock in 2 blocks, so that part of the range will be covered by a \n    ** write lock until the rest is covered by a read lock:\n    **  1:   [WWWWW]\n    **  2:   [....W]\n    **  3:   [RRRRW]\n    **  4:   [RRRR.]\n    */\n    if( eFileLock==SHARED_LOCK ){\n\n#if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE\n      (void)handleNFSUnlock;\n      assert( handleNFSUnlock==0 );\n#endif\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n      if( handleNFSUnlock ){\n        int tErrno;               /* Error code from system call errors */\n        off_t divSize = SHARED_SIZE - 1;\n        \n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          if( IS_LOCK_ERROR(rc) ){\n            pFile->lastErrno = tErrno;\n          }\n          goto end_unlock;\n        }\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);\n          if( IS_LOCK_ERROR(rc) ){\n            pFile->lastErrno = tErrno;\n          }\n          goto end_unlock;\n        }\n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST+divSize;\n        lock.l_len = SHARED_SIZE-divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          if( IS_LOCK_ERROR(rc) ){\n            pFile->lastErrno = tErrno;\n          }\n          goto end_unlock;\n        }\n      }else\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n      {\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = SHARED_SIZE;\n        if( unixFileLock(pFile, &lock) ){\n          /* In theory, the call to unixFileLock() cannot fail because another\n          ** process is holding an incompatible lock. If it does, this \n          ** indicates that the other process is not following the locking\n          ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning\n          ** SQLITE_BUSY would confuse the upper layer (in practice it causes \n          ** an assert to fail). */ \n          rc = SQLITE_IOERR_RDLOCK;\n          pFile->lastErrno = errno;\n          goto end_unlock;\n        }\n      }\n    }\n    lock.l_type = F_UNLCK;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );\n    if( unixFileLock(pFile, &lock)==0 ){\n      pInode->eFileLock = SHARED_LOCK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      pFile->lastErrno = errno;\n      goto end_unlock;\n    }\n  }\n  if( eFileLock==NO_LOCK ){\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      lock.l_type = F_UNLCK;\n      lock.l_whence = SEEK_SET;\n      lock.l_start = lock.l_len = 0L;\n      if( unixFileLock(pFile, &lock)==0 ){\n        pInode->eFileLock = NO_LOCK;\n      }else{\n        rc = SQLITE_IOERR_UNLOCK;\n        pFile->lastErrno = errno;\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n\n    /* Decrement the count of locks against this same file.  When the\n    ** count reaches zero, close any other file descriptors whose close\n    ** was deferred because of outstanding locks.\n    */\n    pInode->nLock--;\n    assert( pInode->nLock>=0 );\n    if( pInode->nLock==0 ){\n      closePendingFds(pFile);\n    }\n  }\n\nend_unlock:\n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int unixUnlock(sqlite3_file *id, int eFileLock){\n  assert( eFileLock==SHARED_LOCK || ((unixFile *)id)->nFetchOut==0 );\n  return posixUnlock(id, eFileLock, 0);\n}\n\nstatic int unixMapfile(unixFile *pFd, i64 nByte);\nstatic void unixUnmapfile(unixFile *pFd);\n\n/*\n** This function performs the parts of the \"close file\" operation \n** common to all locking schemes. It closes the directory and file\n** handles, if they are valid, and sets all fields of the unixFile\n** structure to 0.\n**\n** It is *not* necessary to hold the mutex when this routine is called,\n** even on VxWorks.  A mutex will be acquired on VxWorks by the\n** vxworksReleaseFileId() routine.\n*/\nstatic int closeUnixFile(sqlite3_file *id){\n  unixFile *pFile = (unixFile*)id;\n  unixUnmapfile(pFile);\n  if( pFile->h>=0 ){\n    robust_close(pFile, pFile->h, __LINE__);\n    pFile->h = -1;\n  }\n#if OS_VXWORKS\n  if( pFile->pId ){\n    if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n      osUnlink(pFile->pId->zCanonicalName);\n    }\n    vxworksReleaseFileId(pFile->pId);\n    pFile->pId = 0;\n  }\n#endif\n  OSTRACE((\"CLOSE   %-3d\\n\", pFile->h));\n  OpenCounter(-1);\n  sqlite3_free(pFile->pUnused);\n  memset(pFile, 0, sizeof(unixFile));\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.\n*/\nstatic int unixClose(sqlite3_file *id){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile *)id;\n  verifyDbFile(pFile);\n  unixUnlock(id, NO_LOCK);\n  unixEnterMutex();\n\n  /* unixFile.pInode is always valid here. Otherwise, a different close\n  ** routine (e.g. nolockClose()) would be called instead.\n  */\n  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );\n  if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->pUnused list.  It will be automatically closed \n    ** when the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  releaseInodeInfo(pFile);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n/************** End of the posix advisory lock implementation *****************\n******************************************************************************/\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){\n  UNUSED_PARAMETER(NotUsed);\n  *pResOut = 0;\n  return SQLITE_OK;\n}\nstatic int nolockLock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\nstatic int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int nolockClose(sqlite3_file *id) {\n  return closeUnixFile(id);\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************* Begin dot-file Locking ******************************\n**\n** The dotfile locking implementation uses the existence of separate lock\n** files (really a directory) to control access to the database.  This works\n** on just about every filesystem imaginable.  But there are serious downsides:\n**\n**    (1)  There is zero concurrency.  A single reader blocks all other\n**         connections from reading or writing the database.\n**\n**    (2)  An application crash or power loss can leave stale lock files\n**         sitting around that need to be cleared manually.\n**\n** Nevertheless, a dotlock is an appropriate locking mode for use if no\n** other locking strategy is available.\n**\n** Dotfile locking works by creating a subdirectory in the same directory as\n** the database and with the same name but with a \".lock\" extension added.\n** The existence of a lock directory implies an EXCLUSIVE lock.  All other\n** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.\n*/\n\n/*\n** The file suffix added to the data base filename in order to create the\n** lock directory.\n*/\n#define DOTLOCK_SUFFIX \".lock\"\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n**\n** In dotfile locking, either a lock exists or it does not.  So in this\n** variation of CheckReservedLock(), *pResOut is set to true if any lock\n** is held on the file and false if the file is unlocked.\n*/\nstatic int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    /* Either this connection or some other connection in the same process\n    ** holds a lock on the file.  No need to check further. */\n    reserved = 1;\n  }else{\n    /* The lock is held if and only if the lockfile exists */\n    const char *zLockFile = (const char*)pFile->lockingContext;\n    reserved = osAccess(zLockFile, 0)==0;\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (dotlock)\\n\", pFile->h, rc, reserved));\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n**\n** With dotfile locking, we really only support state (4): EXCLUSIVE.\n** But we track the other locking levels internally.\n*/\nstatic int dotlockLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc = SQLITE_OK;\n\n\n  /* If we have any lock, then the lock file already exists.  All we have\n  ** to do is adjust our internal record of the lock level.\n  */\n  if( pFile->eFileLock > NO_LOCK ){\n    pFile->eFileLock = eFileLock;\n    /* Always update the timestamp on the old file */\n#ifdef HAVE_UTIME\n    utime(zLockFile, NULL);\n#else\n    utimes(zLockFile, NULL);\n#endif\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  rc = osMkdir(zLockFile, 0777);\n  if( rc<0 ){\n    /* failed to open/create the lock directory */\n    int tErrno = errno;\n    if( EEXIST == tErrno ){\n      rc = SQLITE_BUSY;\n    } else {\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( IS_LOCK_ERROR(rc) ){\n        pFile->lastErrno = tErrno;\n      }\n    }\n    return rc;\n  } \n  \n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** When the locking level reaches NO_LOCK, delete the lock file.\n*/\nstatic int dotlockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (dotlock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, getpid()));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n\n  /* To downgrade to shared, simply update our internal notion of the\n  ** lock state.  No need to mess with the file on disk.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    pFile->eFileLock = SHARED_LOCK;\n    return SQLITE_OK;\n  }\n  \n  /* To fully unlock the database, delete the lock file */\n  assert( eFileLock==NO_LOCK );\n  rc = osRmdir(zLockFile);\n  if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile);\n  if( rc<0 ){\n    int tErrno = errno;\n    rc = 0;\n    if( ENOENT != tErrno ){\n      rc = SQLITE_IOERR_UNLOCK;\n    }\n    if( IS_LOCK_ERROR(rc) ){\n      pFile->lastErrno = tErrno;\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.  Make sure the lock has been released before closing.\n*/\nstatic int dotlockClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    dotlockUnlock(id, NO_LOCK);\n    sqlite3_free(pFile->lockingContext);\n    rc = closeUnixFile(id);\n  }\n  return rc;\n}\n/****************** End of the dot-file lock implementation *******************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin flock Locking ********************************\n**\n** Use the flock() system call to do file locking.\n**\n** flock() locking is like dot-file locking in that the various\n** fine-grain locking levels supported by SQLite are collapsed into\n** a single exclusive lock.  In other words, SHARED, RESERVED, and\n** PENDING locks are the same thing as an EXCLUSIVE lock.  SQLite\n** still works when you do this, but concurrency is reduced since\n** only a single process can be reading the database at a time.\n**\n** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if\n** compiling for VXWORKS.\n*/\n#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS\n\n/*\n** Retry flock() calls that fail with EINTR\n*/\n#ifdef EINTR\nstatic int robust_flock(int fd, int op){\n  int rc;\n  do{ rc = flock(fd,op); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n#else\n# define robust_flock(a,b) flock(a,b)\n#endif\n     \n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int flockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    /* attempt to get the lock */\n    int lrc = robust_flock(pFile->h, LOCK_EX | LOCK_NB);\n    if( !lrc ){\n      /* got the lock, unlock it */\n      lrc = robust_flock(pFile->h, LOCK_UN);\n      if ( lrc ) {\n        int tErrno = errno;\n        /* unlock failed with an error */\n        lrc = SQLITE_IOERR_UNLOCK; \n        if( IS_LOCK_ERROR(lrc) ){\n          pFile->lastErrno = tErrno;\n          rc = lrc;\n        }\n      }\n    } else {\n      int tErrno = errno;\n      reserved = 1;\n      /* someone else might have it reserved */\n      lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); \n      if( IS_LOCK_ERROR(lrc) ){\n        pFile->lastErrno = tErrno;\n        rc = lrc;\n      }\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (flock)\\n\", pFile->h, rc, reserved));\n\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){\n    rc = SQLITE_OK;\n    reserved=1;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** flock() only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int flockLock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n\n  assert( pFile );\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  \n  if (robust_flock(pFile->h, LOCK_EX | LOCK_NB)) {\n    int tErrno = errno;\n    /* didn't get, must be busy */\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      pFile->lastErrno = tErrno;\n    }\n  } else {\n    /* got it, set the type and return ok */\n    pFile->eFileLock = eFileLock;\n  }\n  OSTRACE((\"LOCK    %d %s %s (flock)\\n\", pFile->h, azFileLock(eFileLock), \n           rc==SQLITE_OK ? \"ok\" : \"failed\"));\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & SQLITE_IOERR) == SQLITE_IOERR ){\n    rc = SQLITE_BUSY;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int flockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  \n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (flock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, getpid()));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really, unlock. */\n  if( robust_flock(pFile->h, LOCK_UN) ){\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n    return SQLITE_OK;\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n    return SQLITE_IOERR_UNLOCK;\n  }else{\n    pFile->eFileLock = NO_LOCK;\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Close a file.\n*/\nstatic int flockClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  if( id ){\n    flockUnlock(id, NO_LOCK);\n    rc = closeUnixFile(id);\n  }\n  return rc;\n}\n\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */\n\n/******************* End of the flock lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************ Begin Named Semaphore Locking ************************\n**\n** Named semaphore locking is only supported on VxWorks.\n**\n** Semaphore locking is like dot-lock and flock in that it really only\n** supports EXCLUSIVE locking.  Only a single process can read or write\n** the database file at a time.  This reduces potential concurrency, but\n** makes the lock implementation much easier.\n*/\n#if OS_VXWORKS\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int semCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    sem_t *pSem = pFile->pInode->pSem;\n    struct stat statBuf;\n\n    if( sem_trywait(pSem)==-1 ){\n      int tErrno = errno;\n      if( EAGAIN != tErrno ){\n        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);\n        pFile->lastErrno = tErrno;\n      } else {\n        /* someone else has the lock when we are in NO_LOCK */\n        reserved = (pFile->eFileLock < SHARED_LOCK);\n      }\n    }else{\n      /* we could have it if we want it */\n      sem_post(pSem);\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (sem)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** Semaphore locks only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int semLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int fd;\n  sem_t *pSem = pFile->pInode->pSem;\n  int rc = SQLITE_OK;\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    rc = SQLITE_OK;\n    goto sem_end_lock;\n  }\n  \n  /* lock semaphore now but bail out when already locked. */\n  if( sem_trywait(pSem)==-1 ){\n    rc = SQLITE_BUSY;\n    goto sem_end_lock;\n  }\n\n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n\n sem_end_lock:\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int semUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n\n  assert( pFile );\n  assert( pSem );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (sem)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, getpid()));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really unlock. */\n  if ( sem_post(pSem)==-1 ) {\n    int rc, tErrno = errno;\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      pFile->lastErrno = tErrno;\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n ** Close a file.\n */\nstatic int semClose(sqlite3_file *id) {\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    semUnlock(id, NO_LOCK);\n    assert( pFile );\n    unixEnterMutex();\n    releaseInodeInfo(pFile);\n    unixLeaveMutex();\n    closeUnixFile(id);\n  }\n  return SQLITE_OK;\n}\n\n#endif /* OS_VXWORKS */\n/*\n** Named semaphore locking is only available on VxWorks.\n**\n*************** End of the named semaphore lock implementation ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Begin AFP Locking *********************************\n**\n** AFP is the Apple Filing Protocol.  AFP is a network filesystem found\n** on Apple Macintosh computers - both OS9 and OSX.\n**\n** Third-party implementations of AFP are available.  But this code here\n** only works on OSX.\n*/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n** The afpLockingContext structure contains all afp lock specific state\n*/\ntypedef struct afpLockingContext afpLockingContext;\nstruct afpLockingContext {\n  int reserved;\n  const char *dbPath;             /* Name of the open file */\n};\n\nstruct ByteRangeLockPB2\n{\n  unsigned long long offset;        /* offset to first byte to lock */\n  unsigned long long length;        /* nbr of bytes to lock */\n  unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */\n  unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */\n  unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */\n  int fd;                           /* file desc to assoc this lock with */\n};\n\n#define afpfsByteRangeLock2FSCTL        _IOWR('z', 23, struct ByteRangeLockPB2)\n\n/*\n** This is a utility for setting or clearing a bit-range lock on an\n** AFP filesystem.\n** \n** Return SQLITE_OK on success, SQLITE_BUSY on failure.\n*/\nstatic int afpSetLock(\n  const char *path,              /* Name of the file to be locked or unlocked */\n  unixFile *pFile,               /* Open file descriptor on path */\n  unsigned long long offset,     /* First byte to be locked */\n  unsigned long long length,     /* Number of bytes to lock */\n  int setLockFlag                /* True to set lock.  False to clear lock */\n){\n  struct ByteRangeLockPB2 pb;\n  int err;\n  \n  pb.unLockFlag = setLockFlag ? 0 : 1;\n  pb.startEndFlag = 0;\n  pb.offset = offset;\n  pb.length = length; \n  pb.fd = pFile->h;\n  \n  OSTRACE((\"AFPSETLOCK [%s] for %d%s in range %llx:%llx\\n\", \n    (setLockFlag?\"ON\":\"OFF\"), pFile->h, (pb.fd==-1?\"[testval-1]\":\"\"),\n    offset, length));\n  err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);\n  if ( err==-1 ) {\n    int rc;\n    int tErrno = errno;\n    OSTRACE((\"AFPSETLOCK failed to fsctl() '%s' %d %s\\n\",\n             path, tErrno, strerror(tErrno)));\n#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS\n    rc = SQLITE_BUSY;\n#else\n    rc = sqliteErrorFromPosixError(tErrno,\n                    setLockFlag ? SQLITE_IOERR_LOCK : SQLITE_IOERR_UNLOCK);\n#endif /* SQLITE_IGNORE_AFP_LOCK_ERRORS */\n    if( IS_LOCK_ERROR(rc) ){\n      pFile->lastErrno = tErrno;\n    }\n    return rc;\n  } else {\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int afpCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  afpLockingContext *context;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  context = (afpLockingContext *) pFile->lockingContext;\n  if( context->reserved ){\n    *pResOut = 1;\n    return SQLITE_OK;\n  }\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it.\n   */\n  if( !reserved ){\n    /* lock the RESERVED byte */\n    int lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);  \n    if( SQLITE_OK==lrc ){\n      /* if we succeeded in taking the reserved lock, unlock it to restore\n      ** the original state */\n      lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n    } else {\n      /* if we failed to get the lock then someone else must have it */\n      reserved = 1;\n    }\n    if( IS_LOCK_ERROR(lrc) ){\n      rc=lrc;\n    }\n  }\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (afp)\\n\", pFile->h, rc, reserved));\n  \n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int afpLock(sqlite3_file *id, int eFileLock){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode = pFile->pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  \n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (afp)\\n\", pFile->h,\n           azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n           azFileLock(pInode->eFileLock), pInode->nShared , getpid()));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (afp)\\n\", pFile->h,\n           azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n  \n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n     ){\n    rc = SQLITE_BUSY;\n    goto afp_end_lock;\n  }\n  \n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n     (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto afp_end_lock;\n  }\n    \n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    int failed;\n    failed = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 1);\n    if (failed) {\n      rc = failed;\n      goto afp_end_lock;\n    }\n  }\n  \n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    int lrc1, lrc2, lrc1Errno = 0;\n    long lk, mask;\n    \n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n        \n    mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;\n    /* Now get the read-lock SHARED_LOCK */\n    /* note that the quality of the randomness doesn't matter that much */\n    lk = random(); \n    pInode->sharedByte = (lk & mask)%(SHARED_SIZE - 1);\n    lrc1 = afpSetLock(context->dbPath, pFile, \n          SHARED_FIRST+pInode->sharedByte, 1, 1);\n    if( IS_LOCK_ERROR(lrc1) ){\n      lrc1Errno = pFile->lastErrno;\n    }\n    /* Drop the temporary PENDING lock */\n    lrc2 = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    \n    if( IS_LOCK_ERROR(lrc1) ) {\n      pFile->lastErrno = lrc1Errno;\n      rc = lrc1;\n      goto afp_end_lock;\n    } else if( IS_LOCK_ERROR(lrc2) ){\n      rc = lrc2;\n      goto afp_end_lock;\n    } else if( lrc1 != SQLITE_OK ) {\n      rc = lrc1;\n    } else {\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n     ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    int failed = 0;\n    assert( 0!=pFile->eFileLock );\n    if (eFileLock >= RESERVED_LOCK && pFile->eFileLock < RESERVED_LOCK) {\n        /* Acquire a RESERVED lock */\n        failed = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);\n      if( !failed ){\n        context->reserved = 1;\n      }\n    }\n    if (!failed && eFileLock == EXCLUSIVE_LOCK) {\n      /* Acquire an EXCLUSIVE lock */\n        \n      /* Remove the shared lock before trying the range.  we'll need to \n      ** reestablish the shared lock if we can't get the  afpUnlock\n      */\n      if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST +\n                         pInode->sharedByte, 1, 0)) ){\n        int failed2 = SQLITE_OK;\n        /* now attemmpt to get the exclusive lock range */\n        failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, \n                               SHARED_SIZE, 1);\n        if( failed && (failed2 = afpSetLock(context->dbPath, pFile, \n                       SHARED_FIRST + pInode->sharedByte, 1, 1)) ){\n          /* Can't reestablish the shared lock.  Sqlite can't deal, this is\n          ** a critical I/O error\n          */\n          rc = ((failed & SQLITE_IOERR) == SQLITE_IOERR) ? failed2 : \n               SQLITE_IOERR_LOCK;\n          goto afp_end_lock;\n        } \n      }else{\n        rc = failed; \n      }\n    }\n    if( failed ){\n      rc = failed;\n    }\n  }\n  \n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n  \nafp_end_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (afp)\\n\", pFile->h, azFileLock(eFileLock), \n         rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int afpUnlock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  int skipShared = 0;\n#ifdef SQLITE_TEST\n  int h = pFile->h;\n#endif\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n           getpid()));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n    SimulateIOErrorBenign(1);\n    SimulateIOError( h=(-1) )\n    SimulateIOErrorBenign(0);\n    \n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    assert( pFile->inNormalWrite==0\n           || pFile->dbUpdate==0\n           || pFile->transCntrChng==1 );\n    pFile->inNormalWrite = 0;\n#endif\n    \n    if( pFile->eFileLock==EXCLUSIVE_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);\n      if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){\n        /* only re-establish the shared lock if necessary */\n        int sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);\n      } else {\n        skipShared = 1;\n      }\n    }\n    if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    } \n    if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){\n      rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n      if( !rc ){ \n        context->reserved = 0; \n      }\n    }\n    if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){\n      pInode->eFileLock = SHARED_LOCK;\n    }\n  }\n  if( rc==SQLITE_OK && eFileLock==NO_LOCK ){\n\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      SimulateIOErrorBenign(1);\n      SimulateIOError( h=(-1) )\n      SimulateIOErrorBenign(0);\n      if( !skipShared ){\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);\n      }\n      if( !rc ){\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pInode->nLock--;\n      assert( pInode->nLock>=0 );\n      if( pInode->nLock==0 ){\n        closePendingFds(pFile);\n      }\n    }\n  }\n  \n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Close a file & cleanup AFP specific locking context \n*/\nstatic int afpClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    afpUnlock(id, NO_LOCK);\n    unixEnterMutex();\n    if( pFile->pInode && pFile->pInode->nLock ){\n      /* If there are outstanding locks, do not actually close the file just\n      ** yet because that would clear those locks.  Instead, add the file\n      ** descriptor to pInode->aPending.  It will be automatically closed when\n      ** the last lock is cleared.\n      */\n      setPendingFd(pFile);\n    }\n    releaseInodeInfo(pFile);\n    sqlite3_free(pFile->lockingContext);\n    rc = closeUnixFile(id);\n    unixLeaveMutex();\n  }\n  return rc;\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the AFP lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  If you don't compile for a mac, then the \"unix-afp\"\n** VFS is not available.\n**\n********************* End of the AFP lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n*************************** Begin NFS Locking ********************************/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n ** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n ** must be either NO_LOCK or SHARED_LOCK.\n **\n ** If the locking level of the file descriptor is already at or below\n ** the requested locking level, this routine is a no-op.\n */\nstatic int nfsUnlock(sqlite3_file *id, int eFileLock){\n  return posixUnlock(id, eFileLock, 1);\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the NFS lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  \n**\n********************* End of the NFS lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n**************** Non-locking sqlite3_file methods *****************************\n**\n** The next division contains implementations for all methods of the \n** sqlite3_file object other than the locking methods.  The locking\n** methods were defined in divisions above (one locking method per\n** division).  Those methods that are common to all locking modes\n** are gather together into this division.\n*/\n\n/*\n** Seek to the offset passed as the second argument, then read cnt \n** bytes into pBuf. Return the number of bytes actually read.\n**\n** NB:  If you define USE_PREAD or USE_PREAD64, then it might also\n** be necessary to define _XOPEN_SOURCE to be 500.  This varies from\n** one system to another.  Since SQLite does not define USE_PREAD\n** any any form by default, we will not attempt to define _XOPEN_SOURCE.\n** See tickets #2741 and #2681.\n**\n** To avoid stomping the errno value on a failed read the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){\n  int got;\n  int prior = 0;\n#if (!defined(USE_PREAD) && !defined(USE_PREAD64))\n  i64 newOffset;\n#endif\n  TIMER_START;\n  assert( cnt==(cnt&0x1ffff) );\n  cnt &= 0x1ffff;\n  do{\n#if defined(USE_PREAD)\n    got = osPread(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#elif defined(USE_PREAD64)\n    got = osPread64(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#else\n    newOffset = lseek(id->h, offset, SEEK_SET);\n    SimulateIOError( newOffset-- );\n    if( newOffset!=offset ){\n      if( newOffset == -1 ){\n        ((unixFile*)id)->lastErrno = errno;\n      }else{\n        ((unixFile*)id)->lastErrno = 0;\n      }\n      return -1;\n    }\n    got = osRead(id->h, pBuf, cnt);\n#endif\n    if( got==cnt ) break;\n    if( got<0 ){\n      if( errno==EINTR ){ got = 1; continue; }\n      prior = 0;\n      ((unixFile*)id)->lastErrno = errno;\n      break;\n    }else if( got>0 ){\n      cnt -= got;\n      offset += got;\n      prior += got;\n      pBuf = (void*)(got + (char*)pBuf);\n    }\n  }while( got>0 );\n  TIMER_END;\n  OSTRACE((\"READ    %-3d %5d %7lld %llu\\n\",\n            id->h, got+prior, offset-prior, TIMER_ELAPSED));\n  return got+prior;\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int unixRead(\n  sqlite3_file *id, \n  void *pBuf, \n  int amt,\n  sqlite3_int64 offset\n){\n  unixFile *pFile = (unixFile *)id;\n  int got;\n  assert( id );\n  assert( offset>=0 );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n  got = seekAndRead(pFile, offset, pBuf, amt);\n  if( got==amt ){\n    return SQLITE_OK;\n  }else if( got<0 ){\n    /* lastErrno set by seekAndRead */\n    return SQLITE_IOERR_READ;\n  }else{\n    pFile->lastErrno = 0; /* not a system error */\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[got], 0, amt-got);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n}\n\n/*\n** Attempt to seek the file-descriptor passed as the first argument to\n** absolute offset iOff, then attempt to write nBuf bytes of data from\n** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, \n** return the actual number of bytes written (which may be less than\n** nBuf).\n*/\nstatic int seekAndWriteFd(\n  int fd,                         /* File descriptor to write to */\n  i64 iOff,                       /* File offset to begin writing at */\n  const void *pBuf,               /* Copy data from this buffer to the file */\n  int nBuf,                       /* Size of buffer pBuf in bytes */\n  int *piErrno                    /* OUT: Error number if error occurs */\n){\n  int rc = 0;                     /* Value returned by system call */\n\n  assert( nBuf==(nBuf&0x1ffff) );\n  nBuf &= 0x1ffff;\n  TIMER_START;\n\n#if defined(USE_PREAD)\n  do{ rc = osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );\n#elif defined(USE_PREAD64)\n  do{ rc = osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);\n#else\n  do{\n    i64 iSeek = lseek(fd, iOff, SEEK_SET);\n    SimulateIOError( iSeek-- );\n\n    if( iSeek!=iOff ){\n      if( piErrno ) *piErrno = (iSeek==-1 ? errno : 0);\n      return -1;\n    }\n    rc = osWrite(fd, pBuf, nBuf);\n  }while( rc<0 && errno==EINTR );\n#endif\n\n  TIMER_END;\n  OSTRACE((\"WRITE   %-3d %5d %7lld %llu\\n\", fd, rc, iOff, TIMER_ELAPSED));\n\n  if( rc<0 && piErrno ) *piErrno = errno;\n  return rc;\n}\n\n\n/*\n** Seek to the offset in id->offset then read cnt bytes into pBuf.\n** Return the number of bytes actually read.  Update the offset.\n**\n** To avoid stomping the errno value on a failed write the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){\n  return seekAndWriteFd(id->h, offset, pBuf, cnt, &id->lastErrno);\n}\n\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int unixWrite(\n  sqlite3_file *id, \n  const void *pBuf, \n  int amt,\n  sqlite3_int64 offset \n){\n  unixFile *pFile = (unixFile*)id;\n  int wrote = 0;\n  assert( id );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* If we are doing a normal write to a database file (as opposed to\n  ** doing a hot-journal rollback or a write to some file other than a\n  ** normal database file) then record the fact that the database\n  ** has changed.  If the transaction counter is modified, record that\n  ** fact too.\n  */\n  if( pFile->inNormalWrite ){\n    pFile->dbUpdate = 1;  /* The database has been modified */\n    if( offset<=24 && offset+amt>=27 ){\n      int rc;\n      char oldCntr[4];\n      SimulateIOErrorBenign(1);\n      rc = seekAndRead(pFile, 24, oldCntr, 4);\n      SimulateIOErrorBenign(0);\n      if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){\n        pFile->transCntrChng = 1;  /* The transaction counter has changed */\n      }\n    }\n  }\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n  while( amt>0 && (wrote = seekAndWrite(pFile, offset, pBuf, amt))>0 ){\n    amt -= wrote;\n    offset += wrote;\n    pBuf = &((char*)pBuf)[wrote];\n  }\n  SimulateIOError(( wrote=(-1), amt=1 ));\n  SimulateDiskfullError(( wrote=0, amt=1 ));\n\n  if( amt>0 ){\n    if( wrote<0 && pFile->lastErrno!=ENOSPC ){\n      /* lastErrno set by seekAndWrite */\n      return SQLITE_IOERR_WRITE;\n    }else{\n      pFile->lastErrno = 0; /* not a system error */\n      return SQLITE_FULL;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occurring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** We do not trust systems to provide a working fdatasync().  Some do.\n** Others do no.  To be safe, we will stick with the (slightly slower)\n** fsync(). If you know that your system does support fdatasync() correctly,\n** then simply compile with -Dfdatasync=fdatasync\n*/\n#if !defined(fdatasync)\n# define fdatasync fsync\n#endif\n\n/*\n** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not\n** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently\n** only available on Mac OS X.  But that could change.\n*/\n#ifdef F_FULLFSYNC\n# define HAVE_FULLFSYNC 1\n#else\n# define HAVE_FULLFSYNC 0\n#endif\n\n\n/*\n** The fsync() system call does not work as advertised on many\n** unix systems.  The following procedure is an attempt to make\n** it work better.\n**\n** The SQLITE_NO_SYNC macro disables all fsync()s.  This is useful\n** for testing when we want to run through the test suite quickly.\n** You are strongly advised *not* to deploy with SQLITE_NO_SYNC\n** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash\n** or power failure will likely corrupt the database file.\n**\n** SQLite sets the dataOnly flag if the size of the file is unchanged.\n** The idea behind dataOnly is that it should only write the file content\n** to disk, not the inode.  We only set dataOnly if the file size is \n** unchanged since the file size is part of the inode.  However, \n** Ted Ts'o tells us that fdatasync() will also write the inode if the\n** file size has changed.  The only real difference between fdatasync()\n** and fsync(), Ted tells us, is that fdatasync() will not flush the\n** inode if the mtime or owner or other inode attributes have changed.\n** We only care about the file size, not the other file attributes, so\n** as far as SQLite is concerned, an fdatasync() is always adequate.\n** So, we always use fdatasync() if it is available, regardless of\n** the value of the dataOnly flag.\n*/\nstatic int full_fsync(int fd, int fullSync, int dataOnly){\n  int rc;\n\n  /* The following \"ifdef/elif/else/\" block has the same structure as\n  ** the one below. It is replicated here solely to avoid cluttering \n  ** up the real code with the UNUSED_PARAMETER() macros.\n  */\n#ifdef SQLITE_NO_SYNC\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#elif HAVE_FULLFSYNC\n  UNUSED_PARAMETER(dataOnly);\n#else\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#endif\n\n  /* Record the number of times that we do a normal fsync() and \n  ** FULLSYNC.  This is used during testing to verify that this procedure\n  ** gets called with the correct arguments.\n  */\n#ifdef SQLITE_TEST\n  if( fullSync ) sqlite3_fullsync_count++;\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op\n  */\n#ifdef SQLITE_NO_SYNC\n  rc = SQLITE_OK;\n#elif HAVE_FULLFSYNC\n  if( fullSync ){\n    rc = osFcntl(fd, F_FULLFSYNC, 0);\n  }else{\n    rc = 1;\n  }\n  /* If the FULLFSYNC failed, fall back to attempting an fsync().\n  ** It shouldn't be possible for fullfsync to fail on the local \n  ** file system (on OSX), so failure indicates that FULLFSYNC\n  ** isn't supported for this file system. So, attempt an fsync \n  ** and (for now) ignore the overhead of a superfluous fcntl call.  \n  ** It'd be better to detect fullfsync support once and avoid \n  ** the fcntl call every time sync is called.\n  */\n  if( rc ) rc = fsync(fd);\n\n#elif defined(__APPLE__)\n  /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly\n  ** so currently we default to the macro that redefines fdatasync to fsync\n  */\n  rc = fsync(fd);\n#else \n  rc = fdatasync(fd);\n#if OS_VXWORKS\n  if( rc==-1 && errno==ENOTSUP ){\n    rc = fsync(fd);\n  }\n#endif /* OS_VXWORKS */\n#endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */\n\n  if( OS_VXWORKS && rc!= -1 ){\n    rc = 0;\n  }\n  return rc;\n}\n\n/*\n** Open a file descriptor to the directory containing file zFilename.\n** If successful, *pFd is set to the opened file descriptor and\n** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM\n** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined\n** value.\n**\n** The directory file descriptor is used for only one thing - to\n** fsync() a directory to make sure file creation and deletion events\n** are flushed to disk.  Such fsyncs are not needed on newer\n** journaling filesystems, but are required on older filesystems.\n**\n** This routine can be overridden using the xSetSysCall interface.\n** The ability to override this routine was added in support of the\n** chromium sandbox.  Opening a directory is a security risk (we are\n** told) so making it overrideable allows the chromium sandbox to\n** replace this routine with a harmless no-op.  To make this routine\n** a no-op, replace it with a stub that returns SQLITE_OK but leaves\n** *pFd set to a negative number.\n**\n** If SQLITE_OK is returned, the caller is responsible for closing\n** the file descriptor *pFd using close().\n*/\nstatic int openDirectory(const char *zFilename, int *pFd){\n  int ii;\n  int fd = -1;\n  char zDirname[MAX_PATHNAME+1];\n\n  sqlite3_snprintf(MAX_PATHNAME, zDirname, \"%s\", zFilename);\n  for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--);\n  if( ii>0 ){\n    zDirname[ii] = '\\0';\n    fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);\n    if( fd>=0 ){\n      OSTRACE((\"OPENDIR %-3d %s\\n\", fd, zDirname));\n    }\n  }\n  *pFd = fd;\n  return (fd>=0?SQLITE_OK:unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zDirname));\n}\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n**\n** If dataOnly==0 then both the file itself and its metadata (file\n** size, access time, etc) are synced.  If dataOnly!=0 then only the\n** file data is synced.\n**\n** Under Unix, also make sure that the directory entry for the file\n** has been created by fsync-ing the directory that contains the file.\n** If we do not do this and we encounter a power failure, the directory\n** entry for the journal might not exist after we reboot.  The next\n** SQLite to access the file will not know that the journal exists (because\n** the directory entry for the journal was never created) and the transaction\n** will not roll back - possibly leading to database corruption.\n*/\nstatic int unixSync(sqlite3_file *id, int flags){\n  int rc;\n  unixFile *pFile = (unixFile*)id;\n\n  int isDataOnly = (flags&SQLITE_SYNC_DATAONLY);\n  int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL;\n\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  assert( pFile );\n  OSTRACE((\"SYNC    %-3d\\n\", pFile->h));\n  rc = full_fsync(pFile->h, isFullsync, isDataOnly);\n  SimulateIOError( rc=1 );\n  if( rc ){\n    pFile->lastErrno = errno;\n    return unixLogError(SQLITE_IOERR_FSYNC, \"full_fsync\", pFile->zPath);\n  }\n\n  /* Also fsync the directory containing the file if the DIRSYNC flag\n  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)\n  ** are unable to fsync a directory, so ignore errors on the fsync.\n  */\n  if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){\n    int dirfd;\n    OSTRACE((\"DIRSYNC %s (have_fullfsync=%d fullsync=%d)\\n\", pFile->zPath,\n            HAVE_FULLFSYNC, isFullsync));\n    rc = osOpenDirectory(pFile->zPath, &dirfd);\n    if( rc==SQLITE_OK && dirfd>=0 ){\n      full_fsync(dirfd, 0, 0);\n      robust_close(pFile, dirfd, __LINE__);\n    }else if( rc==SQLITE_CANTOPEN ){\n      rc = SQLITE_OK;\n    }\n    pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;\n  }\n  return rc;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int unixTruncate(sqlite3_file *id, i64 nByte){\n  unixFile *pFile = (unixFile *)id;\n  int rc;\n  assert( pFile );\n  SimulateIOError( return SQLITE_IOERR_TRUNCATE );\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  rc = robust_ftruncate(pFile->h, (off_t)nByte);\n  if( rc ){\n    pFile->lastErrno = errno;\n    return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n  }else{\n#ifdef SQLITE_DEBUG\n    /* If we are doing a normal write to a database file (as opposed to\n    ** doing a hot-journal rollback or a write to some file other than a\n    ** normal database file) and we truncate the file to zero length,\n    ** that effectively updates the change counter.  This might happen\n    ** when restoring a database using the backup API from a zero-length\n    ** source.\n    */\n    if( pFile->inNormalWrite && nByte==0 ){\n      pFile->transCntrChng = 1;\n    }\n#endif\n\n    /* If the file was just truncated to a size smaller than the currently\n    ** mapped region, reduce the effective mapping size as well. SQLite will\n    ** use read() and write() to access data beyond this point from now on.  \n    */\n    if( nByte<pFile->mmapSize ){\n      pFile->mmapSize = nByte;\n    }\n\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int unixFileSize(sqlite3_file *id, i64 *pSize){\n  int rc;\n  struct stat buf;\n  assert( id );\n  rc = osFstat(((unixFile*)id)->h, &buf);\n  SimulateIOError( rc=1 );\n  if( rc!=0 ){\n    ((unixFile*)id)->lastErrno = errno;\n    return SQLITE_IOERR_FSTAT;\n  }\n  *pSize = buf.st_size;\n\n  /* When opening a zero-size database, the findInodeInfo() procedure\n  ** writes a single byte into that file in order to work around a bug\n  ** in the OS-X msdos filesystem.  In order to avoid problems with upper\n  ** layers, we need to report this file size as zero even though it is\n  ** really 1.   Ticket #3260.\n  */\n  if( *pSize==1 ) *pSize = 0;\n\n\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Handler for proxy-locking file-control verbs.  Defined below in the\n** proxying locking division.\n*/\nstatic int proxyFileControl(sqlite3_file*,int,void*);\n#endif\n\n/* \n** This function is called to handle the SQLITE_FCNTL_SIZE_HINT \n** file-control operation.  Enlarge the database to nBytes in size\n** (rounded up to the next chunk-size).  If the database is already\n** nBytes or larger, this routine is a no-op.\n*/\nstatic int fcntlSizeHint(unixFile *pFile, i64 nByte){\n  if( pFile->szChunk>0 ){\n    i64 nSize;                    /* Required file size */\n    struct stat buf;              /* Used to hold return values of fstat() */\n   \n    if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;\n\n    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;\n    if( nSize>(i64)buf.st_size ){\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n      /* The code below is handling the return value of osFallocate() \n      ** correctly. posix_fallocate() is defined to \"returns zero on success, \n      ** or an error number on  failure\". See the manpage for details. */\n      int err;\n      do{\n        err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);\n      }while( err==EINTR );\n      if( err ) return SQLITE_IOERR_WRITE;\n#else\n      /* If the OS does not have posix_fallocate(), fake it. First use\n      ** ftruncate() to set the file size, then write a single byte to\n      ** the last byte in each block within the extended region. This\n      ** is the same technique used by glibc to implement posix_fallocate()\n      ** on systems that do not have a real fallocate() system call.\n      */\n      int nBlk = buf.st_blksize;  /* File-system block size */\n      i64 iWrite;                 /* Next offset to write to */\n\n      if( robust_ftruncate(pFile->h, nSize) ){\n        pFile->lastErrno = errno;\n        return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n      }\n      iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;\n      while( iWrite<nSize ){\n        int nWrite = seekAndWrite(pFile, iWrite, \"\", 1);\n        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;\n        iWrite += nBlk;\n      }\n#endif\n    }\n  }\n\n  if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){\n    int rc;\n    if( pFile->szChunk<=0 ){\n      if( robust_ftruncate(pFile->h, nByte) ){\n        pFile->lastErrno = errno;\n        return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n      }\n    }\n\n    rc = unixMapfile(pFile, nByte);\n    return rc;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** If *pArg is inititially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward declaration */\nstatic int unixGetTempname(int nBuf, char *zBuf);\n\n/*\n** Information and control of an open file handle.\n*/\nstatic int unixFileControl(sqlite3_file *id, int op, void *pArg){\n  unixFile *pFile = (unixFile*)id;\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->eFileLock;\n      return SQLITE_OK;\n    }\n    case SQLITE_LAST_ERRNO: {\n      *(int*)pArg = pFile->lastErrno;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      int rc;\n      SimulateIOErrorBenign(1);\n      rc = fcntlSizeHint(pFile, *(i64 *)pArg);\n      SimulateIOErrorBenign(0);\n      return rc;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      unixModeBit(pFile, UNIXFILE_PERSIST_WAL, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = sqlite3_malloc( pFile->pVfs->mxPathname );\n      if( zTFile ){\n        unixGetTempname(pFile->pVfs->mxPathname, zTFile);\n        *(char**)pArg = zTFile;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( newLimit<pFile->mmapSize ) pFile->mmapSize = newLimit;\n      }\n      return SQLITE_OK;\n    }\n#ifdef SQLITE_DEBUG\n    /* The pager calls this method to signal that it has done\n    ** a rollback and that the database is therefore unchanged and\n    ** it hence it is OK for the transaction change counter to be\n    ** unchanged.\n    */\n    case SQLITE_FCNTL_DB_UNCHANGED: {\n      ((unixFile*)id)->dbUpdate = 0;\n      return SQLITE_OK;\n    }\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    case SQLITE_SET_LOCKPROXYFILE:\n    case SQLITE_GET_LOCKPROXYFILE: {\n      return proxyFileControl(id,op,pArg);\n    }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */\n  }\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\n#ifndef __QNXNTO__ \nstatic int unixSectorSize(sqlite3_file *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  return SQLITE_DEFAULT_SECTOR_SIZE;\n}\n#endif\n\n/*\n** The following version of unixSectorSize() is optimized for QNX.\n*/\n#ifdef __QNXNTO__\n#include <sys/dcmd_blk.h>\n#include <sys/statvfs.h>\nstatic int unixSectorSize(sqlite3_file *id){\n  unixFile *pFile = (unixFile*)id;\n  if( pFile->sectorSize == 0 ){\n    struct statvfs fsInfo;\n       \n    /* Set defaults for non-supported filesystems */\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n    pFile->deviceCharacteristics = 0;\n    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {\n      return pFile->sectorSize;\n    }\n\n    if( !strcmp(fsInfo.f_basetype, \"tmp\") ) {\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"etfs\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* etfs cluster size writes are atomic */\n        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx6\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx4\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"dos\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else{\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        0;\n    }\n  }\n  /* Last chance verification.  If the sector size isn't a multiple of 512\n  ** then it isn't valid.*/\n  if( pFile->sectorSize % 512 != 0 ){\n    pFile->deviceCharacteristics = 0;\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n  return pFile->sectorSize;\n}\n#endif /* __QNXNTO__ */\n\n/*\n** Return the device characteristics for the file.\n**\n** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.\n** However, that choice is contraversial since technically the underlying\n** file system does not always provide powersafe overwrites.  (In other\n** words, after a power-loss event, parts of the file that were never\n** written might end up being altered.)  However, non-PSOW behavior is very,\n** very rare.  And asserting PSOW makes a large reduction in the amount\n** of required I/O for journaling, since a lot of padding is eliminated.\n**  Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control\n** available to turn it off and URI query parameter available to turn it off.\n*/\nstatic int unixDeviceCharacteristics(sqlite3_file *id){\n  unixFile *p = (unixFile*)id;\n  int rc = 0;\n#ifdef __QNXNTO__\n  if( p->sectorSize==0 ) unixSectorSize(id);\n  rc = p->deviceCharacteristics;\n#endif\n  if( p->ctrlFlags & UNIXFILE_PSOW ){\n    rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n  }\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_WAL\n\n\n/*\n** Object used to represent an shared memory buffer.  \n**\n** When multiple threads all reference the same wal-index, each thread\n** has its own unixShm object, but they all point to a single instance\n** of this unixShmNode object.  In other words, each wal-index is opened\n** only once per process.\n**\n** Each unixShmNode object is connected to a single unixInodeInfo object.\n** We could coalesce this object into unixInodeInfo, but that would mean\n** every open file that does not use shared memory (in other words, most\n** open files) would have to carry around this extra information.  So\n** the unixInodeInfo object contains a pointer to this unixShmNode object\n** and the unixShmNode object is created only when needed.\n**\n** unixMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**\n** The following fields are read-only after the object is created:\n** \n**      fid\n**      zFilename\n**\n** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and\n** unixMutexHeld() is true when reading or writing any other field\n** in this structure.\n*/\nstruct unixShmNode {\n  unixInodeInfo *pInode;     /* unixInodeInfo that owns this SHM node */\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the mmapped file */\n  int h;                     /* Open file descriptor */\n  int szRegion;              /* Size of shared-memory regions */\n  u16 nRegion;               /* Size of array apRegion */\n  u8 isReadonly;             /* True if read-only */\n  char **apRegion;           /* Array of mapped shared-memory regions */\n  int nRef;                  /* Number of unixShm objects pointing to this */\n  unixShm *pFirst;           /* All unixShm objects pointing to this */\n#ifdef SQLITE_DEBUG\n  u8 exclMask;               /* Mask of exclusive locks held */\n  u8 sharedMask;             /* Mask of shared locks held */\n  u8 nextShmId;              /* Next available unixShm.id value */\n#endif\n};\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    unixShm.pFile\n**    unixShm.id\n**\n** All other fields are read/write.  The unixShm.pFile->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct unixShm {\n  unixShmNode *pShmNode;     /* The underlying unixShmNode object */\n  unixShm *pNext;            /* Next unixShm with the same unixShmNode */\n  u8 hasMutex;               /* True if holding the unixShmNode mutex */\n  u8 id;                     /* Id of this connection within its unixShmNode */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n};\n\n/*\n** Constants used for locking\n*/\n#define UNIX_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)         /* first lock byte */\n#define UNIX_SHM_DMS    (UNIX_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply posix advisory locks for all bytes from ofst through ofst+n-1.\n**\n** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking\n** otherwise.\n*/\nstatic int unixShmSystemLock(\n  unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */\n  int lockType,          /* F_UNLCK, F_RDLCK, or F_WRLCK */\n  int ofst,              /* First byte of the locking range */\n  int n                  /* Number of bytes to lock */\n){\n  struct flock f;       /* The posix advisory locking structure */\n  int rc = SQLITE_OK;   /* Result code form fcntl() */\n\n  /* Access to the unixShmNode object is serialized by the caller */\n  assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );\n\n  /* Shared locks never span more than one byte */\n  assert( n==1 || lockType!=F_RDLCK );\n\n  /* Locks are within range */\n  assert( n>=1 && n<SQLITE_SHM_NLOCK );\n\n  if( pShmNode->h>=0 ){\n    /* Initialize the locking parameters */\n    memset(&f, 0, sizeof(f));\n    f.l_type = lockType;\n    f.l_whence = SEEK_SET;\n    f.l_start = ofst;\n    f.l_len = n;\n\n    rc = osFcntl(pShmNode->h, F_SETLK, &f);\n    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;\n  }\n\n  /* Update the global lock state and do debug tracing */\n#ifdef SQLITE_DEBUG\n  { u16 mask;\n  OSTRACE((\"SHM-LOCK \"));\n  mask = (1<<(ofst+n)) - (1<<ofst);\n  if( rc==SQLITE_OK ){\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask &= ~mask;\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask |= mask;\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d ok\", ofst));\n      pShmNode->exclMask |= mask;\n      pShmNode->sharedMask &= ~mask;\n    }\n  }else{\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d failed\", ofst));\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock failed\"));\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d failed\", ofst));\n    }\n  }\n  OSTRACE((\" - afterwards %03x,%03x\\n\",\n           pShmNode->sharedMask, pShmNode->exclMask));\n  }\n#endif\n\n  return rc;        \n}\n\n\n/*\n** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void unixShmPurge(unixFile *pFd){\n  unixShmNode *p = pFd->pInode->pShmNode;\n  assert( unixMutexHeld() );\n  if( p && p->nRef==0 ){\n    int i;\n    assert( p->pInode==pFd->pInode );\n    sqlite3_mutex_free(p->mutex);\n    for(i=0; i<p->nRegion; i++){\n      if( p->h>=0 ){\n        osMunmap(p->apRegion[i], p->szRegion);\n      }else{\n        sqlite3_free(p->apRegion[i]);\n      }\n    }\n    sqlite3_free(p->apRegion);\n    if( p->h>=0 ){\n      robust_close(pFd, p->h, __LINE__);\n      p->h = -1;\n    }\n    p->pInode->pShmNode = 0;\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Open a shared-memory area associated with open database file pDbFd.  \n** This particular implementation uses mmapped files.\n**\n** The file used to implement shared-memory is in the same directory\n** as the open database file and has the same name as the open database\n** file with the \"-shm\" suffix added.  For example, if the database file\n** is \"/home/user1/config.db\" then the file that is created and mmapped\n** for shared memory will be called \"/home/user1/config.db-shm\".  \n**\n** Another approach to is to use files in /dev/shm or /dev/tmp or an\n** some other tmpfs mount. But if a file in a different directory\n** from the database file is used, then differing access permissions\n** or a chroot() might cause two different processes on the same\n** database to end up using different files for shared memory - \n** meaning that their memory would not really be shared - resulting\n** in database corruption.  Nevertheless, this tmpfs file usage\n** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY=\"/dev/shm\"\n** or the equivalent.  The use of the SQLITE_SHM_DIRECTORY compile-time\n** option results in an incompatible build of SQLite;  builds of SQLite\n** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the\n** same database file at the same time, database corruption will likely\n** result. The SQLITE_SHM_DIRECTORY compile-time option is considered\n** \"unsupported\" and may go away in a future SQLite release.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n**\n** If the original database file (pDbFd) is using the \"unix-excl\" VFS\n** that means that an exclusive lock is held on the database file and\n** that no other processes are able to read or write the database.  In\n** that case, we do not really need shared memory.  No shared memory\n** file is created.  The shared memory will be simulated with heap memory.\n*/\nstatic int unixOpenSharedMemory(unixFile *pDbFd){\n  struct unixShm *p = 0;          /* The connection to be opened */\n  struct unixShmNode *pShmNode;   /* The underlying mmapped file */\n  int rc;                         /* Result code */\n  unixInodeInfo *pInode;          /* The inode of fd */\n  char *zShmFilename;             /* Name of the file used for SHM */\n  int nShmFilename;               /* Size of the SHM filename in bytes */\n\n  /* Allocate space for the new unixShm object. */\n  p = sqlite3_malloc( sizeof(*p) );\n  if( p==0 ) return SQLITE_NOMEM;\n  memset(p, 0, sizeof(*p));\n  assert( pDbFd->pShm==0 );\n\n  /* Check to see if a unixShmNode object already exists. Reuse an existing\n  ** one if present. Create a new one if necessary.\n  */\n  unixEnterMutex();\n  pInode = pDbFd->pInode;\n  pShmNode = pInode->pShmNode;\n  if( pShmNode==0 ){\n    struct stat sStat;                 /* fstat() info for database file */\n\n    /* Call fstat() to figure out the permissions on the database file. If\n    ** a new *-shm file is created, an attempt will be made to create it\n    ** with the same permissions.\n    */\n    if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){\n      rc = SQLITE_IOERR_FSTAT;\n      goto shm_open_err;\n    }\n\n#ifdef SQLITE_SHM_DIRECTORY\n    nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;\n#else\n    nShmFilename = 6 + (int)strlen(pDbFd->zPath);\n#endif\n    pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );\n    if( pShmNode==0 ){\n      rc = SQLITE_NOMEM;\n      goto shm_open_err;\n    }\n    memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);\n    zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1];\n#ifdef SQLITE_SHM_DIRECTORY\n    sqlite3_snprintf(nShmFilename, zShmFilename, \n                     SQLITE_SHM_DIRECTORY \"/sqlite-shm-%x-%x\",\n                     (u32)sStat.st_ino, (u32)sStat.st_dev);\n#else\n    sqlite3_snprintf(nShmFilename, zShmFilename, \"%s-shm\", pDbFd->zPath);\n    sqlite3FileSuffix3(pDbFd->zPath, zShmFilename);\n#endif\n    pShmNode->h = -1;\n    pDbFd->pInode->pShmNode = pShmNode;\n    pShmNode->pInode = pDbFd->pInode;\n    pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n    if( pShmNode->mutex==0 ){\n      rc = SQLITE_NOMEM;\n      goto shm_open_err;\n    }\n\n    if( pInode->bProcessLock==0 ){\n      int openFlags = O_RDWR | O_CREAT;\n      if( sqlite3_uri_boolean(pDbFd->zPath, \"readonly_shm\", 0) ){\n        openFlags = O_RDONLY;\n        pShmNode->isReadonly = 1;\n      }\n      pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777));\n      if( pShmNode->h<0 ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zShmFilename);\n        goto shm_open_err;\n      }\n\n      /* If this process is running as root, make sure that the SHM file\n      ** is owned by the same user that owns the original database.  Otherwise,\n      ** the original owner will not be able to connect.\n      */\n      osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);\n  \n      /* Check to see if another process is holding the dead-man switch.\n      ** If not, truncate the file to zero length. \n      */\n      rc = SQLITE_OK;\n      if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){\n        if( robust_ftruncate(pShmNode->h, 0) ){\n          rc = unixLogError(SQLITE_IOERR_SHMOPEN, \"ftruncate\", zShmFilename);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);\n      }\n      if( rc ) goto shm_open_err;\n    }\n  }\n\n  /* Make the new connection a child of the unixShmNode */\n  p->pShmNode = pShmNode;\n#ifdef SQLITE_DEBUG\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  unixLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the unixEnterMutex() mutex and the pointer from the\n  ** new (struct unixShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex \n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  unixShmPurge(pDbFd);       /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  unixLeaveMutex();\n  return rc;\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the \n** shared-memory associated with the database file fd. Shared-memory regions \n** are numbered starting from zero. Each shared-memory region is szRegion \n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the bExtend parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If \n** bExtend is non-zero and the requested shared-memory region has not yet \n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes \n** address space (if it is not already), *pp is set to point to the mapped \n** memory and SQLITE_OK returned.\n*/\nstatic int unixShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  unixFile *pDbFd = (unixFile*)fd;\n  unixShm *p;\n  unixShmNode *pShmNode;\n  int rc = SQLITE_OK;\n\n  /* If the shared-memory file has not yet been opened, open it now. */\n  if( pDbFd->pShm==0 ){\n    rc = unixOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  p = pDbFd->pShm;\n  pShmNode = p->pShmNode;\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  if( pShmNode->nRegion<=iRegion ){\n    char **apNew;                      /* New apRegion[] array */\n    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */\n    struct stat sStat;                 /* Used by fstat() */\n\n    pShmNode->szRegion = szRegion;\n\n    if( pShmNode->h>=0 ){\n      /* The requested region is not mapped into this processes address space.\n      ** Check to see if it has been allocated (i.e. if the wal-index file is\n      ** large enough to contain the requested region).\n      */\n      if( osFstat(pShmNode->h, &sStat) ){\n        rc = SQLITE_IOERR_SHMSIZE;\n        goto shmpage_out;\n      }\n  \n      if( sStat.st_size<nByte ){\n        /* The requested memory region does not exist. If bExtend is set to\n        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.\n        */\n        if( !bExtend ){\n          goto shmpage_out;\n        }\n\n        /* Alternatively, if bExtend is true, extend the file. Do this by\n        ** writing a single byte to the end of each (OS) page being\n        ** allocated or extended. Technically, we need only write to the\n        ** last page in order to extend the file. But writing to all new\n        ** pages forces the OS to allocate them immediately, which reduces\n        ** the chances of SIGBUS while accessing the mapped region later on.\n        */\n        else{\n          static const int pgsz = 4096;\n          int iPg;\n\n          /* Write to the last byte of each newly allocated or extended page */\n          assert( (nByte % pgsz)==0 );\n          for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){\n            if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, \"\", 1, 0)!=1 ){\n              const char *zFile = pShmNode->zFilename;\n              rc = unixLogError(SQLITE_IOERR_SHMSIZE, \"write\", zFile);\n              goto shmpage_out;\n            }\n          }\n        }\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (char **)sqlite3_realloc(\n        pShmNode->apRegion, (iRegion+1)*sizeof(char *)\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM;\n      goto shmpage_out;\n    }\n    pShmNode->apRegion = apNew;\n    while(pShmNode->nRegion<=iRegion){\n      void *pMem;\n      if( pShmNode->h>=0 ){\n        pMem = osMmap(0, szRegion,\n            pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, \n            MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion\n        );\n        if( pMem==MAP_FAILED ){\n          rc = unixLogError(SQLITE_IOERR_SHMMAP, \"mmap\", pShmNode->zFilename);\n          goto shmpage_out;\n        }\n      }else{\n        pMem = sqlite3_malloc(szRegion);\n        if( pMem==0 ){\n          rc = SQLITE_NOMEM;\n          goto shmpage_out;\n        }\n        memset(pMem, 0, szRegion);\n      }\n      pShmNode->apRegion[pShmNode->nRegion] = pMem;\n      pShmNode->nRegion++;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    *pp = pShmNode->apRegion[iRegion];\n  }else{\n    *pp = 0;\n  }\n  if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n**\n** Note that the relationship between SHAREd and EXCLUSIVE locks is a little\n** different here than in posix.  In xShmLock(), one can go from unlocked\n** to shared and back or from unlocked to exclusive and back.  But one may\n** not go from shared to exclusive or from exclusive to shared.\n*/\nstatic int unixShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  unixFile *pDbFd = (unixFile*)fd;      /* Connection holding shared memory */\n  unixShm *p = pDbFd->pShm;             /* The shared memory being locked */\n  unixShm *pX;                          /* For looping over all siblings */\n  unixShmNode *pShmNode = p->pShmNode;  /* The underlying file iNode */\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  mask = (1<<(ofst+n)) - (1<<ofst);\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    } \n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n  \n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK shmid-%d, pid-%d got %03x,%03x\\n\",\n           p->id, getpid(), p->sharedMask, p->exclMask));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.  \n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void unixShmBarrier(\n  sqlite3_file *fd                /* Database file holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  unixEnterMutex();\n  unixLeaveMutex();\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying \n** storage if deleteFlag is true.\n**\n** If there is no shared memory associated with the connection then this\n** routine is a harmless no-op.\n*/\nstatic int unixShmUnmap(\n  sqlite3_file *fd,               /* The underlying database file */\n  int deleteFlag                  /* Delete shared-memory if true */\n){\n  unixShm *p;                     /* The connection to be closed */\n  unixShmNode *pShmNode;          /* The underlying shared-memory file */\n  unixShm **pp;                   /* For looping over sibling connections */\n  unixFile *pDbFd;                /* The underlying database file */\n\n  pDbFd = (unixFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  unixEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    if( deleteFlag && pShmNode->h>=0 ) osUnlink(pShmNode->zFilename);\n    unixShmPurge(pDbFd);\n  }\n  unixLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n\n#else\n# define unixShmMap     0\n# define unixShmLock    0\n# define unixShmBarrier 0\n# define unixShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/*\n** If it is currently memory mapped, unmap file pFd.\n*/\nstatic void unixUnmapfile(unixFile *pFd){\n  assert( pFd->nFetchOut==0 );\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->pMapRegion ){\n    osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);\n    pFd->pMapRegion = 0;\n    pFd->mmapSize = 0;\n    pFd->mmapSizeActual = 0;\n  }\n#endif\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Return the system page size.\n*/\nstatic int unixGetPagesize(void){\n#if HAVE_MREMAP\n  return 512;\n#elif defined(_BSD_SOURCE)\n  return getpagesize();\n#else\n  return (int)sysconf(_SC_PAGESIZE);\n#endif\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Attempt to set the size of the memory mapping maintained by file \n** descriptor pFd to nNew bytes. Any existing mapping is discarded.\n**\n** If successful, this function sets the following variables:\n**\n**       unixFile.pMapRegion\n**       unixFile.mmapSize\n**       unixFile.mmapSizeActual\n**\n** If unsuccessful, an error message is logged via sqlite3_log() and\n** the three variables above are zeroed. In this case SQLite should\n** continue accessing the database using the xRead() and xWrite()\n** methods.\n*/\nstatic void unixRemapfile(\n  unixFile *pFd,                  /* File descriptor object */\n  i64 nNew                        /* Required mapping size */\n){\n  const char *zErr = \"mmap\";\n  int h = pFd->h;                      /* File descriptor open on db file */\n  u8 *pOrig = (u8 *)pFd->pMapRegion;   /* Pointer to current file mapping */\n  i64 nOrig = pFd->mmapSizeActual;     /* Size of pOrig region in bytes */\n  u8 *pNew = 0;                        /* Location of new mapping */\n  int flags = PROT_READ;               /* Flags to pass to mmap() */\n\n  assert( pFd->nFetchOut==0 );\n  assert( nNew>pFd->mmapSize );\n  assert( nNew<=pFd->mmapSizeMax );\n  assert( nNew>0 );\n  assert( pFd->mmapSizeActual>=pFd->mmapSize );\n  assert( MAP_FAILED!=0 );\n\n  if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;\n\n  if( pOrig ){\n    const int szSyspage = unixGetPagesize();\n    i64 nReuse = (pFd->mmapSize & ~(szSyspage-1));\n    u8 *pReq = &pOrig[nReuse];\n\n    /* Unmap any pages of the existing mapping that cannot be reused. */\n    if( nReuse!=nOrig ){\n      osMunmap(pReq, nOrig-nReuse);\n    }\n\n#if HAVE_MREMAP\n    pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE);\n    zErr = \"mremap\";\n#else\n    pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse);\n    if( pNew!=MAP_FAILED ){\n      if( pNew!=pReq ){\n        osMunmap(pNew, nNew - nReuse);\n        pNew = 0;\n      }else{\n        pNew = pOrig;\n      }\n    }\n#endif\n\n    /* The attempt to extend the existing mapping failed. Free it. */\n    if( pNew==MAP_FAILED || pNew==0 ){\n      osMunmap(pOrig, nReuse);\n    }\n  }\n\n  /* If pNew is still NULL, try to create an entirely new mapping. */\n  if( pNew==0 ){\n    pNew = osMmap(0, nNew, flags, MAP_SHARED, h, 0);\n  }\n\n  if( pNew==MAP_FAILED ){\n    pNew = 0;\n    nNew = 0;\n    unixLogError(SQLITE_OK, zErr, pFd->zPath);\n\n    /* If the mmap() above failed, assume that all subsequent mmap() calls\n    ** will probably fail too. Fall back to using xRead/xWrite exclusively\n    ** in this case.  */\n    pFd->mmapSizeMax = 0;\n  }\n  pFd->pMapRegion = (void *)pNew;\n  pFd->mmapSize = pFd->mmapSizeActual = nNew;\n}\n#endif\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if \n** there already exists a mapping for this file, and there are still \n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of \n** the mapping to create. Otherwise, if nByte is less than zero, then the \n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured \n** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int unixMapfile(unixFile *pFd, i64 nByte){\n#if SQLITE_MAX_MMAP_SIZE>0\n  i64 nMap = nByte;\n  int rc;\n\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    struct stat statbuf;          /* Low-level file information */\n    rc = osFstat(pFd->h, &statbuf);\n    if( rc!=SQLITE_OK ){\n      return SQLITE_IOERR_FSTAT;\n    }\n    nMap = statbuf.st_size;\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n\n  if( nMap!=pFd->mmapSize ){\n    if( nMap>0 ){\n      unixRemapfile(pFd, nMap);\n    }else{\n      unixUnmapfile(pFd);\n    }\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually \n** release the reference by calling unixUnfetch().\n*/\nstatic int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = unixMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a \n** reference obtained by an earlier call to unixFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the unixFetch() invocation. \n**\n** Or, if the third argument is NULL, then this function is being called \n** to inform the VFS layer that, according to POSIX, any existing mapping \n** may now be invalid and should be unmapped.\n*/\nstatic int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n  UNUSED_PARAMETER(iOff);\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding \n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    unixUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This division contains definitions of sqlite3_io_methods objects that\n** implement various file locking strategies.  It also contains definitions\n** of \"finder\" functions.  A finder-function is used to locate the appropriate\n** sqlite3_io_methods object for a particular database file.  The pAppData\n** field of the sqlite3_vfs VFS objects are initialized to be pointers to\n** the correct finder-function for that VFS.\n**\n** Most finder functions return a pointer to a fixed sqlite3_io_methods\n** object.  The only interesting finder-function is autolockIoFinder, which\n** looks at the filesystem type and tries to guess the best locking\n** strategy from that.\n**\n** For finder-funtion F, two objects are created:\n**\n**    (1) The real finder-function named \"FImpt()\".\n**\n**    (2) A constant pointer to this function named just \"F\".\n**\n**\n** A pointer to the F pointer is used as the pAppData value for VFS\n** objects.  We have to do this instead of letting pAppData point\n** directly at the finder-function since C90 rules prevent a void*\n** from be cast into a function pointer.\n**\n**\n** Each instance of this macro generates two objects:\n**\n**   *  A constant sqlite3_io_methods object call METHOD that has locking\n**      methods CLOSE, LOCK, UNLOCK, CKRESLOCK.\n**\n**   *  An I/O method finder function called FINDER that returns a pointer\n**      to the METHOD object in the previous bullet.\n*/\n#define IOMETHODS(FINDER, METHOD, VERSION, CLOSE, LOCK, UNLOCK, CKLOCK)      \\\nstatic const sqlite3_io_methods METHOD = {                                   \\\n   VERSION,                    /* iVersion */                                \\\n   CLOSE,                      /* xClose */                                  \\\n   unixRead,                   /* xRead */                                   \\\n   unixWrite,                  /* xWrite */                                  \\\n   unixTruncate,               /* xTruncate */                               \\\n   unixSync,                   /* xSync */                                   \\\n   unixFileSize,               /* xFileSize */                               \\\n   LOCK,                       /* xLock */                                   \\\n   UNLOCK,                     /* xUnlock */                                 \\\n   CKLOCK,                     /* xCheckReservedLock */                      \\\n   unixFileControl,            /* xFileControl */                            \\\n   unixSectorSize,             /* xSectorSize */                             \\\n   unixDeviceCharacteristics,  /* xDeviceCapabilities */                     \\\n   unixShmMap,                 /* xShmMap */                                 \\\n   unixShmLock,                /* xShmLock */                                \\\n   unixShmBarrier,             /* xShmBarrier */                             \\\n   unixShmUnmap,               /* xShmUnmap */                               \\\n   unixFetch,                  /* xFetch */                                  \\\n   unixUnfetch,                /* xUnfetch */                                \\\n};                                                                           \\\nstatic const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){   \\\n  UNUSED_PARAMETER(z); UNUSED_PARAMETER(p);                                  \\\n  return &METHOD;                                                            \\\n}                                                                            \\\nstatic const sqlite3_io_methods *(*const FINDER)(const char*,unixFile *p)    \\\n    = FINDER##Impl;\n\n/*\n** Here are all of the sqlite3_io_methods objects for each of the\n** locking strategies.  Functions that return pointers to these methods\n** are also created.\n*/\nIOMETHODS(\n  posixIoFinder,            /* Finder function name */\n  posixIoMethods,           /* sqlite3_io_methods object name */\n  3,                        /* shared memory and mmap are enabled */\n  unixClose,                /* xClose method */\n  unixLock,                 /* xLock method */\n  unixUnlock,               /* xUnlock method */\n  unixCheckReservedLock     /* xCheckReservedLock method */\n)\nIOMETHODS(\n  nolockIoFinder,           /* Finder function name */\n  nolockIoMethods,          /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  nolockClose,              /* xClose method */\n  nolockLock,               /* xLock method */\n  nolockUnlock,             /* xUnlock method */\n  nolockCheckReservedLock   /* xCheckReservedLock method */\n)\nIOMETHODS(\n  dotlockIoFinder,          /* Finder function name */\n  dotlockIoMethods,         /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  dotlockClose,             /* xClose method */\n  dotlockLock,              /* xLock method */\n  dotlockUnlock,            /* xUnlock method */\n  dotlockCheckReservedLock  /* xCheckReservedLock method */\n)\n\n#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS\nIOMETHODS(\n  flockIoFinder,            /* Finder function name */\n  flockIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  flockClose,               /* xClose method */\n  flockLock,                /* xLock method */\n  flockUnlock,              /* xUnlock method */\n  flockCheckReservedLock    /* xCheckReservedLock method */\n)\n#endif\n\n#if OS_VXWORKS\nIOMETHODS(\n  semIoFinder,              /* Finder function name */\n  semIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  semClose,                 /* xClose method */\n  semLock,                  /* xLock method */\n  semUnlock,                /* xUnlock method */\n  semCheckReservedLock      /* xCheckReservedLock method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  afpIoFinder,              /* Finder function name */\n  afpIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  afpClose,                 /* xClose method */\n  afpLock,                  /* xLock method */\n  afpUnlock,                /* xUnlock method */\n  afpCheckReservedLock      /* xCheckReservedLock method */\n)\n#endif\n\n/*\n** The proxy locking method is a \"super-method\" in the sense that it\n** opens secondary file descriptors for the conch and lock files and\n** it uses proxy, dot-file, AFP, and flock() locking methods on those\n** secondary files.  For this reason, the division that implements\n** proxy locking is located much further down in the file.  But we need\n** to go ahead and define the sqlite3_io_methods and finder function\n** for proxy locking here.  So we forward declare the I/O methods.\n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nstatic int proxyClose(sqlite3_file*);\nstatic int proxyLock(sqlite3_file*, int);\nstatic int proxyUnlock(sqlite3_file*, int);\nstatic int proxyCheckReservedLock(sqlite3_file*, int*);\nIOMETHODS(\n  proxyIoFinder,            /* Finder function name */\n  proxyIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  proxyClose,               /* xClose method */\n  proxyLock,                /* xLock method */\n  proxyUnlock,              /* xUnlock method */\n  proxyCheckReservedLock    /* xCheckReservedLock method */\n)\n#endif\n\n/* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  nfsIoFinder,               /* Finder function name */\n  nfsIoMethods,              /* sqlite3_io_methods object name */\n  1,                         /* shared memory is disabled */\n  unixClose,                 /* xClose method */\n  unixLock,                  /* xLock method */\n  nfsUnlock,                 /* xUnlock method */\n  unixCheckReservedLock      /* xCheckReservedLock method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/* \n** This \"finder\" function attempts to determine the best locking strategy \n** for the database file \"filePath\".  It then returns the sqlite3_io_methods\n** object that implements that strategy.\n**\n** This is for MacOSX only.\n*/\nstatic const sqlite3_io_methods *autolockIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* open file object for the database file */\n){\n  static const struct Mapping {\n    const char *zFilesystem;              /* Filesystem type name */\n    const sqlite3_io_methods *pMethods;   /* Appropriate locking method */\n  } aMap[] = {\n    { \"hfs\",    &posixIoMethods },\n    { \"ufs\",    &posixIoMethods },\n    { \"afpfs\",  &afpIoMethods },\n    { \"smbfs\",  &afpIoMethods },\n    { \"webdav\", &nolockIoMethods },\n    { 0, 0 }\n  };\n  int i;\n  struct statfs fsInfo;\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n  if( statfs(filePath, &fsInfo) != -1 ){\n    if( fsInfo.f_flags & MNT_RDONLY ){\n      return &nolockIoMethods;\n    }\n    for(i=0; aMap[i].zFilesystem; i++){\n      if( strcmp(fsInfo.f_fstypename, aMap[i].zFilesystem)==0 ){\n        return aMap[i].pMethods;\n      }\n    }\n  }\n\n  /* Default case. Handles, amongst others, \"nfs\".\n  ** Test byte-range lock using fcntl(). If the call succeeds, \n  ** assume that the file-system supports POSIX style locks. \n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    if( strcmp(fsInfo.f_fstypename, \"nfs\")==0 ){\n      return &nfsIoMethods;\n    } else {\n      return &posixIoMethods;\n    }\n  }else{\n    return &dotlockIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n\n#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE\n/* \n** This \"finder\" function attempts to determine the best locking strategy \n** for the database file \"filePath\".  It then returns the sqlite3_io_methods\n** object that implements that strategy.\n**\n** This is for VXWorks only.\n*/\nstatic const sqlite3_io_methods *autolockIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* the open file object */\n){\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n\n  /* Test if fcntl() is supported and use POSIX style locks.\n  ** Otherwise fall back to the named semaphore method.\n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    return &posixIoMethods;\n  }else{\n    return &semIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;\n\n#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */\n\n/*\n** An abstract type for a pointer to a IO method finder function:\n*/\ntypedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);\n\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n/*\n** Initialize the contents of the unixFile structure pointed to by pId.\n*/\nstatic int fillInUnixFile(\n  sqlite3_vfs *pVfs,      /* Pointer to vfs object */\n  int h,                  /* Open file descriptor of file being opened */\n  sqlite3_file *pId,      /* Write to the unixFile structure here */\n  const char *zFilename,  /* Name of the file being opened */\n  int ctrlFlags           /* Zero or more UNIXFILE_* values */\n){\n  const sqlite3_io_methods *pLockingStyle;\n  unixFile *pNew = (unixFile *)pId;\n  int rc = SQLITE_OK;\n\n  assert( pNew->pInode==NULL );\n\n  /* Usually the path zFilename should not be a relative pathname. The\n  ** exception is when opening the proxy \"conch\" file in builds that\n  ** include the special Apple locking styles.\n  */\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n  assert( zFilename==0 || zFilename[0]=='/' \n    || pVfs->pAppData==(void*)&autolockIoFinder );\n#else\n  assert( zFilename==0 || zFilename[0]=='/' );\n#endif\n\n  /* No locking occurs in temporary files */\n  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );\n\n  OSTRACE((\"OPEN    %-3d %s\\n\", h, zFilename));\n  pNew->h = h;\n  pNew->pVfs = pVfs;\n  pNew->zPath = zFilename;\n  pNew->ctrlFlags = (u8)ctrlFlags;\n  pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),\n                           \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pNew->ctrlFlags |= UNIXFILE_PSOW;\n  }\n  if( strcmp(pVfs->zName,\"unix-excl\")==0 ){\n    pNew->ctrlFlags |= UNIXFILE_EXCL;\n  }\n\n#if OS_VXWORKS\n  pNew->pId = vxworksFindFileId(zFilename);\n  if( pNew->pId==0 ){\n    ctrlFlags |= UNIXFILE_NOLOCK;\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( ctrlFlags & UNIXFILE_NOLOCK ){\n    pLockingStyle = &nolockIoMethods;\n  }else{\n    pLockingStyle = (**(finder_type*)pVfs->pAppData)(zFilename, pNew);\n#if SQLITE_ENABLE_LOCKING_STYLE\n    /* Cache zFilename in the locking context (AFP and dotlock override) for\n    ** proxyLock activation is possible (remote proxy is based on db name)\n    ** zFilename remains valid until file is closed, to support */\n    pNew->lockingContext = (void*)zFilename;\n#endif\n  }\n\n  if( pLockingStyle == &posixIoMethods\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n    || pLockingStyle == &nfsIoMethods\n#endif\n  ){\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( rc!=SQLITE_OK ){\n      /* If an error occurred in findInodeInfo(), close the file descriptor\n      ** immediately, before releasing the mutex. findInodeInfo() may fail\n      ** in two scenarios:\n      **\n      **   (a) A call to fstat() failed.\n      **   (b) A malloc failed.\n      **\n      ** Scenario (b) may only occur if the process is holding no other\n      ** file descriptors open on the same file. If there were other file\n      ** descriptors on this file, then no malloc would be required by\n      ** findInodeInfo(). If this is the case, it is quite safe to close\n      ** handle h - as it is guaranteed that no posix locks will be released\n      ** by doing so.\n      **\n      ** If scenario (a) caused the error then things are not so safe. The\n      ** implicit assumption here is that if fstat() fails, things are in\n      ** such bad shape that dropping a lock or two doesn't matter much.\n      */\n      robust_close(pNew, h, __LINE__);\n      h = -1;\n    }\n    unixLeaveMutex();\n  }\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  else if( pLockingStyle == &afpIoMethods ){\n    /* AFP locking uses the file path so it needs to be included in\n    ** the afpLockingContext.\n    */\n    afpLockingContext *pCtx;\n    pNew->lockingContext = pCtx = sqlite3_malloc( sizeof(*pCtx) );\n    if( pCtx==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      /* NB: zFilename exists and remains valid until the file is closed\n      ** according to requirement F11141.  So we do not need to make a\n      ** copy of the filename. */\n      pCtx->dbPath = zFilename;\n      pCtx->reserved = 0;\n      srandomdev();\n      unixEnterMutex();\n      rc = findInodeInfo(pNew, &pNew->pInode);\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pNew->lockingContext);\n        robust_close(pNew, h, __LINE__);\n        h = -1;\n      }\n      unixLeaveMutex();        \n    }\n  }\n#endif\n\n  else if( pLockingStyle == &dotlockIoMethods ){\n    /* Dotfile locking uses the file path so it needs to be included in\n    ** the dotlockLockingContext \n    */\n    char *zLockFile;\n    int nFilename;\n    assert( zFilename!=0 );\n    nFilename = (int)strlen(zFilename) + 6;\n    zLockFile = (char *)sqlite3_malloc(nFilename);\n    if( zLockFile==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_snprintf(nFilename, zLockFile, \"%s\" DOTLOCK_SUFFIX, zFilename);\n    }\n    pNew->lockingContext = zLockFile;\n  }\n\n#if OS_VXWORKS\n  else if( pLockingStyle == &semIoMethods ){\n    /* Named semaphore locking uses the file path so it needs to be\n    ** included in the semLockingContext\n    */\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){\n      char *zSemName = pNew->pInode->aSemName;\n      int n;\n      sqlite3_snprintf(MAX_PATHNAME, zSemName, \"/%s.sem\",\n                       pNew->pId->zCanonicalName);\n      for( n=1; zSemName[n]; n++ )\n        if( zSemName[n]=='/' ) zSemName[n] = '_';\n      pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1);\n      if( pNew->pInode->pSem == SEM_FAILED ){\n        rc = SQLITE_NOMEM;\n        pNew->pInode->aSemName[0] = '\\0';\n      }\n    }\n    unixLeaveMutex();\n  }\n#endif\n  \n  pNew->lastErrno = 0;\n#if OS_VXWORKS\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n    h = -1;\n    osUnlink(zFilename);\n    pNew->ctrlFlags |= UNIXFILE_DELETE;\n  }\n#endif\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n  }else{\n    pNew->pMethod = pLockingStyle;\n    OpenCounter(+1);\n    verifyDbFile(pNew);\n  }\n  return rc;\n}\n\n/*\n** Return the name of a directory in which to put temporary files.\n** If no suitable temporary file directory can be found, return NULL.\n*/\nstatic const char *unixTempFileDir(void){\n  static const char *azDirs[] = {\n     0,\n     0,\n     \"/var/tmp\",\n     \"/usr/tmp\",\n     \"/tmp\",\n     0        /* List terminator */\n  };\n  unsigned int i;\n  struct stat buf;\n  const char *zDir = 0;\n\n  azDirs[0] = sqlite3_temp_directory;\n  if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n  for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){\n    if( zDir==0 ) continue;\n    if( osStat(zDir, &buf) ) continue;\n    if( !S_ISDIR(buf.st_mode) ) continue;\n    if( osAccess(zDir, 07) ) continue;\n    break;\n  }\n  return zDir;\n}\n\n/*\n** Create a temporary file name in zBuf.  zBuf must be allocated\n** by the calling process and must be big enough to hold at least\n** pVfs->mxPathname bytes.\n*/\nstatic int unixGetTempname(int nBuf, char *zBuf){\n  static const unsigned char zChars[] =\n    \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"0123456789\";\n  unsigned int i, j;\n  const char *zDir;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. \n  */\n  SimulateIOError( return SQLITE_IOERR );\n\n  zDir = unixTempFileDir();\n  if( zDir==0 ) zDir = \".\";\n\n  /* Check that the output buffer is large enough for the temporary file \n  ** name. If it is not, return SQLITE_ERROR.\n  */\n  if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){\n    return SQLITE_ERROR;\n  }\n\n  do{\n    sqlite3_snprintf(nBuf-18, zBuf, \"%s/\"SQLITE_TEMP_FILE_PREFIX, zDir);\n    j = (int)strlen(zBuf);\n    sqlite3_randomness(15, &zBuf[j]);\n    for(i=0; i<15; i++, j++){\n      zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];\n    }\n    zBuf[j] = 0;\n    zBuf[j+1] = 0;\n  }while( osAccess(zBuf,0)==0 );\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Routine to transform a unixFile into a proxy-locking unixFile.\n** Implementation in the proxy-lock division, but used by unixOpen()\n** if SQLITE_PREFER_PROXY_LOCKING is defined.\n*/\nstatic int proxyTransformUnixFile(unixFile*, const char*);\n#endif\n\n/*\n** Search for an unused file descriptor that was opened on the database \n** file (not a journal or master-journal file) identified by pathname\n** zPath with SQLITE_OPEN_XXX flags matching those passed as the second\n** argument to this function.\n**\n** Such a file descriptor may exist if a database connection was closed\n** but the associated file descriptor could not be closed because some\n** other file descriptor open on the same file is holding a file-lock.\n** Refer to comments in the unixClose() function and the lengthy comment\n** describing \"Posix Advisory Locking\" at the start of this file for \n** further details. Also, ticket #4018.\n**\n** If a suitable file descriptor is found, then it is returned. If no\n** such file descriptor is located, -1 is returned.\n*/\nstatic UnixUnusedFd *findReusableFd(const char *zPath, int flags){\n  UnixUnusedFd *pUnused = 0;\n\n  /* Do not search for an unused file descriptor on vxworks. Not because\n  ** vxworks would not benefit from the change (it might, we're not sure),\n  ** but because no way to test it is currently available. It is better \n  ** not to risk breaking vxworks support for the sake of such an obscure \n  ** feature.  */\n#if !OS_VXWORKS\n  struct stat sStat;                   /* Results of stat() call */\n\n  /* A stat() call may fail for various reasons. If this happens, it is\n  ** almost certain that an open() call on the same path will also fail.\n  ** For this reason, if an error occurs in the stat() call here, it is\n  ** ignored and -1 is returned. The caller will try to open a new file\n  ** descriptor on the same path, fail, and return an error to SQLite.\n  **\n  ** Even if a subsequent open() call does succeed, the consequences of\n  ** not searching for a resusable file descriptor are not dire.  */\n  if( 0==osStat(zPath, &sStat) ){\n    unixInodeInfo *pInode;\n\n    unixEnterMutex();\n    pInode = inodeList;\n    while( pInode && (pInode->fileId.dev!=sStat.st_dev\n                     || pInode->fileId.ino!=sStat.st_ino) ){\n       pInode = pInode->pNext;\n    }\n    if( pInode ){\n      UnixUnusedFd **pp;\n      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));\n      pUnused = *pp;\n      if( pUnused ){\n        *pp = pUnused->pNext;\n      }\n    }\n    unixLeaveMutex();\n  }\n#endif    /* if !OS_VXWORKS */\n  return pUnused;\n}\n\n/*\n** This function is called by unixOpen() to determine the unix permissions\n** to create new files with. If no error occurs, then SQLITE_OK is returned\n** and a value suitable for passing as the third argument to open(2) is\n** written to *pMode. If an IO error occurs, an SQLite error code is \n** returned and the value of *pMode is not modified.\n**\n** In most cases cases, this routine sets *pMode to 0, which will become\n** an indication to robust_open() to create the file using\n** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.\n** But if the file being opened is a WAL or regular journal file, then \n** this function queries the file-system for the permissions on the \n** corresponding database file and sets *pMode to this value. Whenever \n** possible, WAL and journal files are created using the same permissions \n** as the associated database file.\n**\n** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the\n** original filename is unavailable.  But 8_3_NAMES is only used for\n** FAT filesystems and permissions do not matter there, so just use\n** the default permissions.\n*/\nstatic int findCreateFileMode(\n  const char *zPath,              /* Path of file (possibly) being created */\n  int flags,                      /* Flags passed as 4th argument to xOpen() */\n  mode_t *pMode,                  /* OUT: Permissions to open file with */\n  uid_t *pUid,                    /* OUT: uid to set on the file */\n  gid_t *pGid                     /* OUT: gid to set on the file */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  *pMode = 0;\n  *pUid = 0;\n  *pGid = 0;\n  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n    char zDb[MAX_PATHNAME+1];     /* Database file path */\n    int nDb;                      /* Number of valid bytes in zDb */\n    struct stat sStat;            /* Output of stat() on database file */\n\n    /* zPath is a path to a WAL or journal file. The following block derives\n    ** the path to the associated database file from zPath. This block handles\n    ** the following naming conventions:\n    **\n    **   \"<path to db>-journal\"\n    **   \"<path to db>-wal\"\n    **   \"<path to db>-journalNN\"\n    **   \"<path to db>-walNN\"\n    **\n    ** where NN is a decimal number. The NN naming schemes are \n    ** used by the test_multiplex.c module.\n    */\n    nDb = sqlite3Strlen30(zPath) - 1; \n#ifdef SQLITE_ENABLE_8_3_NAMES\n    while( nDb>0 && sqlite3Isalnum(zPath[nDb]) ) nDb--;\n    if( nDb==0 || zPath[nDb]!='-' ) return SQLITE_OK;\n#else\n    while( zPath[nDb]!='-' ){\n      assert( nDb>0 );\n      assert( zPath[nDb]!='\\n' );\n      nDb--;\n    }\n#endif\n    memcpy(zDb, zPath, nDb);\n    zDb[nDb] = '\\0';\n\n    if( 0==osStat(zDb, &sStat) ){\n      *pMode = sStat.st_mode & 0777;\n      *pUid = sStat.st_uid;\n      *pGid = sStat.st_gid;\n    }else{\n      rc = SQLITE_IOERR_FSTAT;\n    }\n  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){\n    *pMode = 0600;\n  }\n  return rc;\n}\n\n/*\n** Open the file zPath.\n** \n** Previously, the SQLite OS layer used three functions in place of this\n** one:\n**\n**     sqlite3OsOpenReadWrite();\n**     sqlite3OsOpenReadOnly();\n**     sqlite3OsOpenExclusive();\n**\n** These calls correspond to the following combinations of flags:\n**\n**     ReadWrite() ->     (READWRITE | CREATE)\n**     ReadOnly()  ->     (READONLY) \n**     OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE)\n**\n** The old OpenExclusive() accepted a boolean argument - \"delFlag\". If\n** true, the file was configured to be automatically deleted when the\n** file handle closed. To achieve the same effect using this new \n** interface, add the DELETEONCLOSE flag to those specified above for \n** OpenExclusive().\n*/\nstatic int unixOpen(\n  sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */\n  const char *zPath,           /* Pathname of file to be opened */\n  sqlite3_file *pFile,         /* The file descriptor to be filled in */\n  int flags,                   /* Input flags to control the opening */\n  int *pOutFlags               /* Output flags returned to SQLite core */\n){\n  unixFile *p = (unixFile *)pFile;\n  int fd = -1;                   /* File descriptor returned by open() */\n  int openFlags = 0;             /* Flags to pass to open() */\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n  int noLock;                    /* True to omit locking primitives */\n  int rc = SQLITE_OK;            /* Function Return Code */\n  int ctrlFlags = 0;             /* UNIXFILE_* flags */\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int isAutoProxy  = (flags & SQLITE_OPEN_AUTOPROXY);\n#endif\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  struct statfs fsInfo;\n#endif\n\n  /* If creating a master or main-file journal, this function will open\n  ** a file-descriptor on the directory too. The first time unixSync()\n  ** is called the directory file descriptor will be fsync()ed and close()d.\n  */\n  int syncDir = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL \n     || eType==SQLITE_OPEN_MAIN_JOURNAL \n     || eType==SQLITE_OPEN_WAL\n  ));\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char zTmpname[MAX_PATHNAME+2];\n  const char *zName = zPath;\n\n  /* Check the following statements are true: \n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and \n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never \n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB \n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL \n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL \n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  memset(p, 0, sizeof(unixFile));\n\n  if( eType==SQLITE_OPEN_MAIN_DB ){\n    UnixUnusedFd *pUnused;\n    pUnused = findReusableFd(zName, flags);\n    if( pUnused ){\n      fd = pUnused->fd;\n    }else{\n      pUnused = sqlite3_malloc(sizeof(*pUnused));\n      if( !pUnused ){\n        return SQLITE_NOMEM;\n      }\n    }\n    p->pUnused = pUnused;\n\n    /* Database filenames are double-zero terminated if they are not\n    ** URIs with parameters.  Hence, they can always be passed into\n    ** sqlite3_uri_parameter(). */\n    assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );\n\n  }else if( !zName ){\n    /* If zName is NULL, the upper layer is requesting a temp file. */\n    assert(isDelete && !syncDir);\n    rc = unixGetTempname(MAX_PATHNAME+2, zTmpname);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    zName = zTmpname;\n\n    /* Generated temporary filenames are always double-zero terminated\n    ** for use by sqlite3_uri_parameter(). */\n    assert( zName[strlen(zName)+1]==0 );\n  }\n\n  /* Determine the value of the flags parameter passed to POSIX function\n  ** open(). These must be calculated even if open() is not called, as\n  ** they may be stored as part of the file handle and used by the \n  ** 'conch file' locking functions later on.  */\n  if( isReadonly )  openFlags |= O_RDONLY;\n  if( isReadWrite ) openFlags |= O_RDWR;\n  if( isCreate )    openFlags |= O_CREAT;\n  if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);\n  openFlags |= (O_LARGEFILE|O_BINARY);\n\n  if( fd<0 ){\n    mode_t openMode;              /* Permissions to create file with */\n    uid_t uid;                    /* Userid for the file */\n    gid_t gid;                    /* Groupid for the file */\n    rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);\n    if( rc!=SQLITE_OK ){\n      assert( !p->pUnused );\n      assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );\n      return rc;\n    }\n    fd = robust_open(zName, openFlags, openMode);\n    OSTRACE((\"OPENX   %-3d %s 0%o\\n\", fd, zName, openFlags));\n    if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){\n      /* Failed to open the file for read/write access. Try read-only. */\n      flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);\n      openFlags &= ~(O_RDWR|O_CREAT);\n      flags |= SQLITE_OPEN_READONLY;\n      openFlags |= O_RDONLY;\n      isReadonly = 1;\n      fd = robust_open(zName, openFlags, openMode);\n    }\n    if( fd<0 ){\n      rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zName);\n      goto open_finished;\n    }\n\n    /* If this process is running as root and if creating a new rollback\n    ** journal or WAL file, set the ownership of the journal or WAL to be\n    ** the same as the original database.\n    */\n    if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n      osFchown(fd, uid, gid);\n    }\n  }\n  assert( fd>=0 );\n  if( pOutFlags ){\n    *pOutFlags = flags;\n  }\n\n  if( p->pUnused ){\n    p->pUnused->fd = fd;\n    p->pUnused->flags = flags;\n  }\n\n  if( isDelete ){\n#if OS_VXWORKS\n    zPath = zName;\n#else\n    osUnlink(zName);\n#endif\n  }\n#if SQLITE_ENABLE_LOCKING_STYLE\n  else{\n    p->openFlags = openFlags;\n  }\n#endif\n\n  noLock = eType!=SQLITE_OPEN_MAIN_DB;\n\n  \n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  if( fstatfs(fd, &fsInfo) == -1 ){\n    ((unixFile*)pFile)->lastErrno = errno;\n    robust_close(p, fd, __LINE__);\n    return SQLITE_IOERR_ACCESS;\n  }\n  if (0 == strncmp(\"msdos\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n#endif\n\n  /* Set up appropriate ctrlFlags */\n  if( isDelete )                ctrlFlags |= UNIXFILE_DELETE;\n  if( isReadonly )              ctrlFlags |= UNIXFILE_RDONLY;\n  if( noLock )                  ctrlFlags |= UNIXFILE_NOLOCK;\n  if( syncDir )                 ctrlFlags |= UNIXFILE_DIRSYNC;\n  if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n#if SQLITE_PREFER_PROXY_LOCKING\n  isAutoProxy = 1;\n#endif\n  if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){\n    char *envforce = getenv(\"SQLITE_FORCE_PROXY_LOCKING\");\n    int useProxy = 0;\n\n    /* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means \n    ** never use proxy, NULL means use proxy for non-local files only.  */\n    if( envforce!=NULL ){\n      useProxy = atoi(envforce)>0;\n    }else{\n      if( statfs(zPath, &fsInfo) == -1 ){\n        /* In theory, the close(fd) call is sub-optimal. If the file opened\n        ** with fd is a database file, and there are other connections open\n        ** on that file that are currently holding advisory locks on it,\n        ** then the call to close() will cancel those locks. In practice,\n        ** we're assuming that statfs() doesn't fail very often. At least\n        ** not while other file descriptors opened by the same process on\n        ** the same file are working.  */\n        p->lastErrno = errno;\n        robust_close(p, fd, __LINE__);\n        rc = SQLITE_IOERR_ACCESS;\n        goto open_finished;\n      }\n      useProxy = !(fsInfo.f_flags&MNT_LOCAL);\n    }\n    if( useProxy ){\n      rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n      if( rc==SQLITE_OK ){\n        rc = proxyTransformUnixFile((unixFile*)pFile, \":auto:\");\n        if( rc!=SQLITE_OK ){\n          /* Use unixClose to clean up the resources added in fillInUnixFile \n          ** and clear all the structure's references.  Specifically, \n          ** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op \n          */\n          unixClose(pFile);\n          return rc;\n        }\n      }\n      goto open_finished;\n    }\n  }\n#endif\n  \n  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n\nopen_finished:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(p->pUnused);\n  }\n  return rc;\n}\n\n\n/*\n** Delete the file at zPath. If the dirSync argument is true, fsync()\n** the directory after deleting the file.\n*/\nstatic int unixDelete(\n  sqlite3_vfs *NotUsed,     /* VFS containing this as the xDelete method */\n  const char *zPath,        /* Name of file to be deleted */\n  int dirSync               /* If true, fsync() directory after deleting file */\n){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  if( osUnlink(zPath)==(-1) ){\n    if( errno==ENOENT ){\n      rc = SQLITE_IOERR_DELETE_NOENT;\n    }else{\n      rc = unixLogError(SQLITE_IOERR_DELETE, \"unlink\", zPath);\n    }\n    return rc;\n  }\n#ifndef SQLITE_DISABLE_DIRSYNC\n  if( (dirSync & 1)!=0 ){\n    int fd;\n    rc = osOpenDirectory(zPath, &fd);\n    if( rc==SQLITE_OK ){\n#if OS_VXWORKS\n      if( fsync(fd)==-1 )\n#else\n      if( fsync(fd) )\n#endif\n      {\n        rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, \"fsync\", zPath);\n      }\n      robust_close(0, fd, __LINE__);\n    }else if( rc==SQLITE_CANTOPEN ){\n      rc = SQLITE_OK;\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Test the existence of or access permissions of file zPath. The\n** test performed depends on the value of flags:\n**\n**     SQLITE_ACCESS_EXISTS: Return 1 if the file exists\n**     SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable.\n**     SQLITE_ACCESS_READONLY: Return 1 if the file is readable.\n**\n** Otherwise return 0.\n*/\nstatic int unixAccess(\n  sqlite3_vfs *NotUsed,   /* The VFS containing this xAccess method */\n  const char *zPath,      /* Path of the file to examine */\n  int flags,              /* What do we want to learn about the zPath file? */\n  int *pResOut            /* Write result boolean here */\n){\n  int amode = 0;\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  switch( flags ){\n    case SQLITE_ACCESS_EXISTS:\n      amode = F_OK;\n      break;\n    case SQLITE_ACCESS_READWRITE:\n      amode = W_OK|R_OK;\n      break;\n    case SQLITE_ACCESS_READ:\n      amode = R_OK;\n      break;\n\n    default:\n      assert(!\"Invalid flags argument\");\n  }\n  *pResOut = (osAccess(zPath, amode)==0);\n  if( flags==SQLITE_ACCESS_EXISTS && *pResOut ){\n    struct stat buf;\n    if( 0==osStat(zPath, &buf) && buf.st_size==0 ){\n      *pResOut = 0;\n    }\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Turn a relative pathname into a full pathname. The relative path\n** is stored as a nul-terminated string in the buffer pointed to by\n** zPath. \n**\n** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes \n** (in this case, MAX_PATHNAME bytes). The full-path is written to\n** this buffer before returning.\n*/\nstatic int unixFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zPath,            /* Possibly relative input path */\n  int nOut,                     /* Size of output buffer in bytes */\n  char *zOut                    /* Output buffer */\n){\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n\n  assert( pVfs->mxPathname==MAX_PATHNAME );\n  UNUSED_PARAMETER(pVfs);\n\n  zOut[nOut-1] = '\\0';\n  if( zPath[0]=='/' ){\n    sqlite3_snprintf(nOut, zOut, \"%s\", zPath);\n  }else{\n    int nCwd;\n    if( osGetcwd(zOut, nOut-1)==0 ){\n      return unixLogError(SQLITE_CANTOPEN_BKPT, \"getcwd\", zPath);\n    }\n    nCwd = (int)strlen(zOut);\n    sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], \"/%s\", zPath);\n  }\n  return SQLITE_OK;\n}\n\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\n#include <dlfcn.h>\nstatic void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){\n  UNUSED_PARAMETER(NotUsed);\n  return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);\n}\n\n/*\n** SQLite calls this function immediately after a call to unixDlSym() or\n** unixDlOpen() fails (returns a null pointer). If a more detailed error\n** message is available, it is written to zBufOut. If no error message\n** is available, zBufOut is left unmodified and SQLite uses a default\n** error message.\n*/\nstatic void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){\n  const char *zErr;\n  UNUSED_PARAMETER(NotUsed);\n  unixEnterMutex();\n  zErr = dlerror();\n  if( zErr ){\n    sqlite3_snprintf(nBuf, zBufOut, \"%s\", zErr);\n  }\n  unixLeaveMutex();\n}\nstatic void (*unixDlSym(sqlite3_vfs *NotUsed, void *p, const char*zSym))(void){\n  /* \n  ** GCC with -pedantic-errors says that C90 does not allow a void* to be\n  ** cast into a pointer to a function.  And yet the library dlsym() routine\n  ** returns a void* which is really a pointer to a function.  So how do we\n  ** use dlsym() with -pedantic-errors?\n  **\n  ** Variable x below is defined to be a pointer to a function taking\n  ** parameters void* and const char* and returning a pointer to a function.\n  ** We initialize x by assigning it a pointer to the dlsym() function.\n  ** (That assignment requires a cast.)  Then we call the function that\n  ** x points to.  \n  **\n  ** This work-around is unlikely to work correctly on any system where\n  ** you really cannot cast a function pointer into void*.  But then, on the\n  ** other hand, dlsym() will not work on such a system either, so we have\n  ** not really lost anything.\n  */\n  void (*(*x)(void*,const char*))(void);\n  UNUSED_PARAMETER(NotUsed);\n  x = (void(*(*)(void*,const char*))(void))dlsym;\n  return (*x)(p, zSym);\n}\nstatic void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle){\n  UNUSED_PARAMETER(NotUsed);\n  dlclose(pHandle);\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define unixDlOpen  0\n  #define unixDlError 0\n  #define unixDlSym   0\n  #define unixDlClose 0\n#endif\n\n/*\n** Write nBuf bytes of random data to the supplied buffer zBuf.\n*/\nstatic int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){\n  UNUSED_PARAMETER(NotUsed);\n  assert((size_t)nBuf>=(sizeof(time_t)+sizeof(int)));\n\n  /* We have to initialize zBuf to prevent valgrind from reporting\n  ** errors.  The reports issued by valgrind are incorrect - we would\n  ** prefer that the randomness be increased by making use of the\n  ** uninitialized space in zBuf - but valgrind errors tend to worry\n  ** some users.  Rather than argue, it seems easier just to initialize\n  ** the whole array and silence valgrind, even if that means less randomness\n  ** in the random seed.\n  **\n  ** When testing, initializing zBuf[] to zero is all we do.  That means\n  ** that we always use the same random number sequence.  This makes the\n  ** tests repeatable.\n  */\n  memset(zBuf, 0, nBuf);\n#if !defined(SQLITE_TEST)\n  {\n    int pid, fd, got;\n    fd = robust_open(\"/dev/urandom\", O_RDONLY, 0);\n    if( fd<0 ){\n      time_t t;\n      time(&t);\n      memcpy(zBuf, &t, sizeof(t));\n      pid = getpid();\n      memcpy(&zBuf[sizeof(t)], &pid, sizeof(pid));\n      assert( sizeof(t)+sizeof(pid)<=(size_t)nBuf );\n      nBuf = sizeof(t) + sizeof(pid);\n    }else{\n      do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR );\n      robust_close(0, fd, __LINE__);\n    }\n  }\n#endif\n  return nBuf;\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n** The argument is the number of microseconds we want to sleep.\n** The return value is the number of microseconds of sleep actually\n** requested from the underlying operating system, a number which\n** might be greater than or equal to the argument, but not less\n** than the argument.\n*/\nstatic int unixSleep(sqlite3_vfs *NotUsed, int microseconds){\n#if OS_VXWORKS\n  struct timespec sp;\n\n  sp.tv_sec = microseconds / 1000000;\n  sp.tv_nsec = (microseconds % 1000000) * 1000;\n  nanosleep(&sp, NULL);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#elif defined(HAVE_USLEEP) && HAVE_USLEEP\n  usleep(microseconds);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#else\n  int seconds = (microseconds+999999)/1000000;\n  sleep(seconds);\n  UNUSED_PARAMETER(NotUsed);\n  return seconds*1000000;\n#endif\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date \n** cannot be found.\n*/\nstatic int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n  int rc = SQLITE_OK;\n#if defined(NO_GETTOD)\n  time_t t;\n  time(&t);\n  *piNow = ((sqlite3_int64)t)*1000 + unixEpoch;\n#elif OS_VXWORKS\n  struct timespec sNow;\n  clock_gettime(CLOCK_REALTIME, &sNow);\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;\n#else\n  struct timeval sNow;\n  if( gettimeofday(&sNow, 0)==0 ){\n    *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;\n  }else{\n    rc = SQLITE_ERROR;\n  }\n#endif\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(NotUsed);\n  return rc;\n}\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){\n  sqlite3_int64 i = 0;\n  int rc;\n  UNUSED_PARAMETER(NotUsed);\n  rc = unixCurrentTimeInt64(0, &i);\n  *prNow = i/86400000.0;\n  return rc;\n}\n\n/*\n** We added the xGetLastError() method with the intention of providing\n** better low-level error messages when operating-system problems come up\n** during SQLite operation.  But so far, none of that has been implemented\n** in the core.  So this routine is never called.  For now, it is merely\n** a place-holder.\n*/\nstatic int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){\n  UNUSED_PARAMETER(NotUsed);\n  UNUSED_PARAMETER(NotUsed2);\n  UNUSED_PARAMETER(NotUsed3);\n  return 0;\n}\n\n\n/*\n************************ End of sqlite3_vfs methods ***************************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin Proxy Locking ********************************\n**\n** Proxy locking is a \"uber-locking-method\" in this sense:  It uses the\n** other locking methods on secondary lock files.  Proxy locking is a\n** meta-layer over top of the primitive locking implemented above.  For\n** this reason, the division that implements of proxy locking is deferred\n** until late in the file (here) after all of the other I/O methods have\n** been defined - so that the primitive locking methods are available\n** as services to help with the implementation of proxy locking.\n**\n****\n**\n** The default locking schemes in SQLite use byte-range locks on the\n** database file to coordinate safe, concurrent access by multiple readers\n** and writers [http://sqlite.org/lockingv3.html].  The five file locking\n** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented\n** as POSIX read & write locks over fixed set of locations (via fsctl),\n** on AFP and SMB only exclusive byte-range locks are available via fsctl\n** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states.\n** To simulate a F_RDLCK on the shared range, on AFP a randomly selected\n** address in the shared range is taken for a SHARED lock, the entire\n** shared range is taken for an EXCLUSIVE lock):\n**\n**      PENDING_BYTE        0x40000000\n**      RESERVED_BYTE       0x40000001\n**      SHARED_RANGE        0x40000002 -> 0x40000200\n**\n** This works well on the local file system, but shows a nearly 100x\n** slowdown in read performance on AFP because the AFP client disables\n** the read cache when byte-range locks are present.  Enabling the read\n** cache exposes a cache coherency problem that is present on all OS X\n** supported network file systems.  NFS and AFP both observe the\n** close-to-open semantics for ensuring cache coherency\n** [http://nfs.sourceforge.net/#faq_a8], which does not effectively\n** address the requirements for concurrent database access by multiple\n** readers and writers\n** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html].\n**\n** To address the performance and cache coherency issues, proxy file locking\n** changes the way database access is controlled by limiting access to a\n** single host at a time and moving file locks off of the database file\n** and onto a proxy file on the local file system.  \n**\n**\n** Using proxy locks\n** -----------------\n**\n** C APIs\n**\n**  sqlite3_file_control(db, dbname, SQLITE_SET_LOCKPROXYFILE,\n**                       <proxy_path> | \":auto:\");\n**  sqlite3_file_control(db, dbname, SQLITE_GET_LOCKPROXYFILE, &<proxy_path>);\n**\n**\n** SQL pragmas\n**\n**  PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:\n**  PRAGMA [database.]lock_proxy_file\n**\n** Specifying \":auto:\" means that if there is a conch file with a matching\n** host ID in it, the proxy path in the conch file will be used, otherwise\n** a proxy path based on the user's temp dir\n** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the\n** actual proxy file name is generated from the name and path of the\n** database file.  For example:\n**\n**       For database path \"/Users/me/foo.db\" \n**       The lock path will be \"<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:\")\n**\n** Once a lock proxy is configured for a database connection, it can not\n** be removed, however it may be switched to a different proxy path via\n** the above APIs (assuming the conch file is not being held by another\n** connection or process). \n**\n**\n** How proxy locking works\n** -----------------------\n**\n** Proxy file locking relies primarily on two new supporting files: \n**\n**   *  conch file to limit access to the database file to a single host\n**      at a time\n**\n**   *  proxy file to act as a proxy for the advisory locks normally\n**      taken on the database\n**\n** The conch file - to use a proxy file, sqlite must first \"hold the conch\"\n** by taking an sqlite-style shared lock on the conch file, reading the\n** contents and comparing the host's unique host ID (see below) and lock\n** proxy path against the values stored in the conch.  The conch file is\n** stored in the same directory as the database file and the file name\n** is patterned after the database file name as \".<databasename>-conch\".\n** If the conch file does not exist, or it's contents do not match the\n** host ID and/or proxy path, then the lock is escalated to an exclusive\n** lock and the conch file contents is updated with the host ID and proxy\n** path and the lock is downgraded to a shared lock again.  If the conch\n** is held by another process (with a shared lock), the exclusive lock\n** will fail and SQLITE_BUSY is returned.\n**\n** The proxy file - a single-byte file used for all advisory file locks\n** normally taken on the database file.   This allows for safe sharing\n** of the database file for multiple readers and writers on the same\n** host (the conch ensures that they all use the same local lock file).\n**\n** Requesting the lock proxy does not immediately take the conch, it is\n** only taken when the first request to lock database file is made.  \n** This matches the semantics of the traditional locking behavior, where\n** opening a connection to a database file does not take a lock on it.\n** The shared lock and an open file descriptor are maintained until \n** the connection to the database is closed. \n**\n** The proxy file and the lock file are never deleted so they only need\n** to be created the first time they are used.\n**\n** Configuration options\n** ---------------------\n**\n**  SQLITE_PREFER_PROXY_LOCKING\n**\n**       Database files accessed on non-local file systems are\n**       automatically configured for proxy locking, lock files are\n**       named automatically using the same logic as\n**       PRAGMA lock_proxy_file=\":auto:\"\n**    \n**  SQLITE_PROXY_DEBUG\n**\n**       Enables the logging of error messages during host id file\n**       retrieval and creation\n**\n**  LOCKPROXYDIR\n**\n**       Overrides the default directory used for lock proxy files that\n**       are named automatically via the \":auto:\" setting\n**\n**  SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n**\n**       Permissions to use when creating a directory for storing the\n**       lock proxy files, only used when LOCKPROXYDIR is not set.\n**    \n**    \n** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,\n** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will\n** force proxy locking to be used for every database file opened, and 0\n** will force automatic proxy locking to be disabled for all database\n** files (explicity calling the SQLITE_SET_LOCKPROXYFILE pragma or\n** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).\n*/\n\n/*\n** Proxy locking is only available on MacOSX \n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** The proxyLockingContext has the path and file structures for the remote \n** and local proxy files in it\n*/\ntypedef struct proxyLockingContext proxyLockingContext;\nstruct proxyLockingContext {\n  unixFile *conchFile;         /* Open conch file */\n  char *conchFilePath;         /* Name of the conch file */\n  unixFile *lockProxy;         /* Open proxy lock file */\n  char *lockProxyPath;         /* Name of the proxy lock file */\n  char *dbPath;                /* Name of the open file */\n  int conchHeld;               /* 1 if the conch is held, -1 if lockless */\n  void *oldLockingContext;     /* Original lockingcontext to restore on close */\n  sqlite3_io_methods const *pOldMethod;     /* Original I/O methods for close */\n};\n\n/* \n** The proxy lock file path for the database at dbPath is written into lPath, \n** which must point to valid, writable memory large enough for a maxLen length\n** file path. \n*/\nstatic int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){\n  int len;\n  int dbLen;\n  int i;\n\n#ifdef LOCKPROXYDIR\n  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);\n#else\n# ifdef _CS_DARWIN_USER_TEMP_DIR\n  {\n    if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){\n      OSTRACE((\"GETLOCKPATH  failed %s errno=%d pid=%d\\n\",\n               lPath, errno, getpid()));\n      return SQLITE_IOERR_LOCK;\n    }\n    len = strlcat(lPath, \"sqliteplocks\", maxLen);    \n  }\n# else\n  len = strlcpy(lPath, \"/tmp/\", maxLen);\n# endif\n#endif\n\n  if( lPath[len-1]!='/' ){\n    len = strlcat(lPath, \"/\", maxLen);\n  }\n  \n  /* transform the db path to a unique cache name */\n  dbLen = (int)strlen(dbPath);\n  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){\n    char c = dbPath[i];\n    lPath[i+len] = (c=='/')?'_':c;\n  }\n  lPath[i+len]='\\0';\n  strlcat(lPath, \":auto:\", maxLen);\n  OSTRACE((\"GETLOCKPATH  proxy lock path=%s pid=%d\\n\", lPath, getpid()));\n  return SQLITE_OK;\n}\n\n/* \n ** Creates the lock file and any missing directories in lockPath\n */\nstatic int proxyCreateLockPath(const char *lockPath){\n  int i, len;\n  char buf[MAXPATHLEN];\n  int start = 0;\n  \n  assert(lockPath!=NULL);\n  /* try to create all the intermediate directories */\n  len = (int)strlen(lockPath);\n  buf[0] = lockPath[0];\n  for( i=1; i<len; i++ ){\n    if( lockPath[i] == '/' && (i - start > 0) ){\n      /* only mkdir if leaf dir != \".\" or \"/\" or \"..\" */\n      if( i-start>2 || (i-start==1 && buf[start] != '.' && buf[start] != '/') \n         || (i-start==2 && buf[start] != '.' && buf[start+1] != '.') ){\n        buf[i]='\\0';\n        if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){\n          int err=errno;\n          if( err!=EEXIST ) {\n            OSTRACE((\"CREATELOCKPATH  FAILED creating %s, \"\n                     \"'%s' proxy lock path=%s pid=%d\\n\",\n                     buf, strerror(err), lockPath, getpid()));\n            return err;\n          }\n        }\n      }\n      start=i+1;\n    }\n    buf[i] = lockPath[i];\n  }\n  OSTRACE((\"CREATELOCKPATH  proxy lock path=%s pid=%d\\n\", lockPath, getpid()));\n  return 0;\n}\n\n/*\n** Create a new VFS file descriptor (stored in memory obtained from\n** sqlite3_malloc) and open the file named \"path\" in the file descriptor.\n**\n** The caller is responsible not only for closing the file descriptor\n** but also for freeing the memory associated with the file descriptor.\n*/\nstatic int proxyCreateUnixFile(\n    const char *path,        /* path for the new unixFile */\n    unixFile **ppFile,       /* unixFile created and returned by ref */\n    int islockfile           /* if non zero missing dirs will be created */\n) {\n  int fd = -1;\n  unixFile *pNew;\n  int rc = SQLITE_OK;\n  int openFlags = O_RDWR | O_CREAT;\n  sqlite3_vfs dummyVfs;\n  int terrno = 0;\n  UnixUnusedFd *pUnused = NULL;\n\n  /* 1. first try to open/create the file\n  ** 2. if that fails, and this is a lock file (not-conch), try creating\n  ** the parent directories and then try again.\n  ** 3. if that fails, try to open the file read-only\n  ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file\n  */\n  pUnused = findReusableFd(path, openFlags);\n  if( pUnused ){\n    fd = pUnused->fd;\n  }else{\n    pUnused = sqlite3_malloc(sizeof(*pUnused));\n    if( !pUnused ){\n      return SQLITE_NOMEM;\n    }\n  }\n  if( fd<0 ){\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n    if( fd<0 && errno==ENOENT && islockfile ){\n      if( proxyCreateLockPath(path) == SQLITE_OK ){\n        fd = robust_open(path, openFlags, 0);\n      }\n    }\n  }\n  if( fd<0 ){\n    openFlags = O_RDONLY;\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n  }\n  if( fd<0 ){\n    if( islockfile ){\n      return SQLITE_BUSY;\n    }\n    switch (terrno) {\n      case EACCES:\n        return SQLITE_PERM;\n      case EIO: \n        return SQLITE_IOERR_LOCK; /* even though it is the conch */\n      default:\n        return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n  \n  pNew = (unixFile *)sqlite3_malloc(sizeof(*pNew));\n  if( pNew==NULL ){\n    rc = SQLITE_NOMEM;\n    goto end_create_proxy;\n  }\n  memset(pNew, 0, sizeof(unixFile));\n  pNew->openFlags = openFlags;\n  memset(&dummyVfs, 0, sizeof(dummyVfs));\n  dummyVfs.pAppData = (void*)&autolockIoFinder;\n  dummyVfs.zName = \"dummy\";\n  pUnused->fd = fd;\n  pUnused->flags = openFlags;\n  pNew->pUnused = pUnused;\n  \n  rc = fillInUnixFile(&dummyVfs, fd, (sqlite3_file*)pNew, path, 0);\n  if( rc==SQLITE_OK ){\n    *ppFile = pNew;\n    return SQLITE_OK;\n  }\nend_create_proxy:    \n  robust_close(pNew, fd, __LINE__);\n  sqlite3_free(pNew);\n  sqlite3_free(pUnused);\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/* simulate multiple hosts by creating unique hostid file paths */\nSQLITE_API int sqlite3_hostid_num = 0;\n#endif\n\n#define PROXY_HOSTIDLEN    16  /* conch file host id length */\n\n/* Not always defined in the headers as it ought to be */\nextern int gethostuuid(uuid_t id, const struct timespec *wait);\n\n/* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN \n** bytes of writable memory.\n*/\nstatic int proxyGetHostID(unsigned char *pHostID, int *pError){\n  assert(PROXY_HOSTIDLEN == sizeof(uuid_t));\n  memset(pHostID, 0, PROXY_HOSTIDLEN);\n#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\\\n               && __MAC_OS_X_VERSION_MIN_REQUIRED<1050\n  {\n    static const struct timespec timeout = {1, 0}; /* 1 sec timeout */\n    if( gethostuuid(pHostID, &timeout) ){\n      int err = errno;\n      if( pError ){\n        *pError = err;\n      }\n      return SQLITE_IOERR;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pError);\n#endif\n#ifdef SQLITE_TEST\n  /* simulate multiple hosts by creating unique hostid file paths */\n  if( sqlite3_hostid_num != 0){\n    pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF));\n  }\n#endif\n  \n  return SQLITE_OK;\n}\n\n/* The conch file contains the header, host id and lock file path\n */\n#define PROXY_CONCHVERSION 2   /* 1-byte header, 16-byte host id, path */\n#define PROXY_HEADERLEN    1   /* conch file header length */\n#define PROXY_PATHINDEX    (PROXY_HEADERLEN+PROXY_HOSTIDLEN)\n#define PROXY_MAXCONCHLEN  (PROXY_HEADERLEN+PROXY_HOSTIDLEN+MAXPATHLEN)\n\n/* \n** Takes an open conch file, copies the contents to a new path and then moves \n** it back.  The newly created file's file descriptor is assigned to the\n** conch file structure and finally the original conch file descriptor is \n** closed.  Returns zero if successful.\n*/\nstatic int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  char tPath[MAXPATHLEN];\n  char buf[PROXY_MAXCONCHLEN];\n  char *cPath = pCtx->conchFilePath;\n  size_t readLen = 0;\n  size_t pathLen = 0;\n  char errmsg[64] = \"\";\n  int fd = -1;\n  int rc = -1;\n  UNUSED_PARAMETER(myHostID);\n\n  /* create a new path by replace the trailing '-conch' with '-break' */\n  pathLen = strlcpy(tPath, cPath, MAXPATHLEN);\n  if( pathLen>MAXPATHLEN || pathLen<6 || \n     (strlcpy(&tPath[pathLen-5], \"break\", 6) != 5) ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"path error (len %d)\",(int)pathLen);\n    goto end_breaklock;\n  }\n  /* read the conch content */\n  readLen = osPread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);\n  if( readLen<PROXY_PATHINDEX ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"read error (len %d)\",(int)readLen);\n    goto end_breaklock;\n  }\n  /* write it out to the temporary break file */\n  fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);\n  if( fd<0 ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"create failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"write failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( rename(tPath, cPath) ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"rename failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  rc = 0;\n  fprintf(stderr, \"broke stale lock on %s\\n\", cPath);\n  robust_close(pFile, conchFile->h, __LINE__);\n  conchFile->h = fd;\n  conchFile->openFlags = O_RDWR | O_CREAT;\n\nend_breaklock:\n  if( rc ){\n    if( fd>=0 ){\n      osUnlink(tPath);\n      robust_close(pFile, fd, __LINE__);\n    }\n    fprintf(stderr, \"failed to break stale lock on %s, %s\\n\", cPath, errmsg);\n  }\n  return rc;\n}\n\n/* Take the requested lock on the conch file and break a stale lock if the \n** host id matches.\n*/\nstatic int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  int rc = SQLITE_OK;\n  int nTries = 0;\n  struct timespec conchModTime;\n  \n  memset(&conchModTime, 0, sizeof(conchModTime));\n  do {\n    rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n    nTries ++;\n    if( rc==SQLITE_BUSY ){\n      /* If the lock failed (busy):\n       * 1st try: get the mod time of the conch, wait 0.5s and try again. \n       * 2nd try: fail if the mod time changed or host id is different, wait \n       *           10 sec and try again\n       * 3rd try: break the lock unless the mod time has changed.\n       */\n      struct stat buf;\n      if( osFstat(conchFile->h, &buf) ){\n        pFile->lastErrno = errno;\n        return SQLITE_IOERR_LOCK;\n      }\n      \n      if( nTries==1 ){\n        conchModTime = buf.st_mtimespec;\n        usleep(500000); /* wait 0.5 sec and try the lock again*/\n        continue;  \n      }\n\n      assert( nTries>1 );\n      if( conchModTime.tv_sec != buf.st_mtimespec.tv_sec || \n         conchModTime.tv_nsec != buf.st_mtimespec.tv_nsec ){\n        return SQLITE_BUSY;\n      }\n      \n      if( nTries==2 ){  \n        char tBuf[PROXY_MAXCONCHLEN];\n        int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);\n        if( len<0 ){\n          pFile->lastErrno = errno;\n          return SQLITE_IOERR_LOCK;\n        }\n        if( len>PROXY_PATHINDEX && tBuf[0]==(char)PROXY_CONCHVERSION){\n          /* don't break the lock if the host id doesn't match */\n          if( 0!=memcmp(&tBuf[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN) ){\n            return SQLITE_BUSY;\n          }\n        }else{\n          /* don't break the lock on short read or a version mismatch */\n          return SQLITE_BUSY;\n        }\n        usleep(10000000); /* wait 10 sec and try the lock again */\n        continue; \n      }\n      \n      assert( nTries==3 );\n      if( 0==proxyBreakConchLock(pFile, myHostID) ){\n        rc = SQLITE_OK;\n        if( lockType==EXCLUSIVE_LOCK ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);          \n        }\n        if( !rc ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n        }\n      }\n    }\n  } while( rc==SQLITE_BUSY && nTries<3 );\n  \n  return rc;\n}\n\n/* Takes the conch by taking a shared lock and read the contents conch, if \n** lockPath is non-NULL, the host ID and lock file path must match.  A NULL \n** lockPath means that the lockPath in the conch file will be used if the \n** host IDs match, or a new lock path will be generated automatically \n** and written to the conch file.\n*/\nstatic int proxyTakeConch(unixFile *pFile){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  \n  if( pCtx->conchHeld!=0 ){\n    return SQLITE_OK;\n  }else{\n    unixFile *conchFile = pCtx->conchFile;\n    uuid_t myHostID;\n    int pError = 0;\n    char readBuf[PROXY_MAXCONCHLEN];\n    char lockPath[MAXPATHLEN];\n    char *tempLockPath = NULL;\n    int rc = SQLITE_OK;\n    int createConch = 0;\n    int hostIdMatch = 0;\n    int readLen = 0;\n    int tryOldLockPath = 0;\n    int forceNewLockPath = 0;\n    \n    OSTRACE((\"TAKECONCH  %d for %s pid=%d\\n\", conchFile->h,\n             (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"), getpid()));\n\n    rc = proxyGetHostID(myHostID, &pError);\n    if( (rc&0xff)==SQLITE_IOERR ){\n      pFile->lastErrno = pError;\n      goto end_takeconch;\n    }\n    rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      goto end_takeconch;\n    }\n    /* read the existing conch file */\n    readLen = seekAndRead((unixFile*)conchFile, 0, readBuf, PROXY_MAXCONCHLEN);\n    if( readLen<0 ){\n      /* I/O error: lastErrno set by seekAndRead */\n      pFile->lastErrno = conchFile->lastErrno;\n      rc = SQLITE_IOERR_READ;\n      goto end_takeconch;\n    }else if( readLen<=(PROXY_HEADERLEN+PROXY_HOSTIDLEN) || \n             readBuf[0]!=(char)PROXY_CONCHVERSION ){\n      /* a short read or version format mismatch means we need to create a new \n      ** conch file. \n      */\n      createConch = 1;\n    }\n    /* if the host id matches and the lock path already exists in the conch\n    ** we'll try to use the path there, if we can't open that path, we'll \n    ** retry with a new auto-generated path \n    */\n    do { /* in case we need to try again for an :auto: named lock file */\n\n      if( !createConch && !forceNewLockPath ){\n        hostIdMatch = !memcmp(&readBuf[PROXY_HEADERLEN], myHostID, \n                                  PROXY_HOSTIDLEN);\n        /* if the conch has data compare the contents */\n        if( !pCtx->lockProxyPath ){\n          /* for auto-named local lock file, just check the host ID and we'll\n           ** use the local lock file path that's already in there\n           */\n          if( hostIdMatch ){\n            size_t pathLen = (readLen - PROXY_PATHINDEX);\n            \n            if( pathLen>=MAXPATHLEN ){\n              pathLen=MAXPATHLEN-1;\n            }\n            memcpy(lockPath, &readBuf[PROXY_PATHINDEX], pathLen);\n            lockPath[pathLen] = 0;\n            tempLockPath = lockPath;\n            tryOldLockPath = 1;\n            /* create a copy of the lock path if the conch is taken */\n            goto end_takeconch;\n          }\n        }else if( hostIdMatch\n               && !strncmp(pCtx->lockProxyPath, &readBuf[PROXY_PATHINDEX],\n                           readLen-PROXY_PATHINDEX)\n        ){\n          /* conch host and lock path match */\n          goto end_takeconch; \n        }\n      }\n      \n      /* if the conch isn't writable and doesn't match, we can't take it */\n      if( (conchFile->openFlags&O_RDWR) == 0 ){\n        rc = SQLITE_BUSY;\n        goto end_takeconch;\n      }\n      \n      /* either the conch didn't match or we need to create a new one */\n      if( !pCtx->lockProxyPath ){\n        proxyGetLockPath(pCtx->dbPath, lockPath, MAXPATHLEN);\n        tempLockPath = lockPath;\n        /* create a copy of the lock path _only_ if the conch is taken */\n      }\n      \n      /* update conch with host and path (this will fail if other process\n      ** has a shared lock already), if the host id matches, use the big\n      ** stick.\n      */\n      futimes(conchFile->h, NULL);\n      if( hostIdMatch && !createConch ){\n        if( conchFile->pInode && conchFile->pInode->nShared>1 ){\n          /* We are trying for an exclusive lock but another thread in this\n           ** same process is still holding a shared lock. */\n          rc = SQLITE_BUSY;\n        } else {          \n          rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n        }\n      }else{\n        rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, EXCLUSIVE_LOCK);\n      }\n      if( rc==SQLITE_OK ){\n        char writeBuffer[PROXY_MAXCONCHLEN];\n        int writeSize = 0;\n        \n        writeBuffer[0] = (char)PROXY_CONCHVERSION;\n        memcpy(&writeBuffer[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN);\n        if( pCtx->lockProxyPath!=NULL ){\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath, MAXPATHLEN);\n        }else{\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], tempLockPath, MAXPATHLEN);\n        }\n        writeSize = PROXY_PATHINDEX + strlen(&writeBuffer[PROXY_PATHINDEX]);\n        robust_ftruncate(conchFile->h, writeSize);\n        rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0);\n        fsync(conchFile->h);\n        /* If we created a new conch file (not just updated the contents of a \n         ** valid conch file), try to match the permissions of the database \n         */\n        if( rc==SQLITE_OK && createConch ){\n          struct stat buf;\n          int err = osFstat(pFile->h, &buf);\n          if( err==0 ){\n            mode_t cmode = buf.st_mode&(S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP |\n                                        S_IROTH|S_IWOTH);\n            /* try to match the database file R/W permissions, ignore failure */\n#ifndef SQLITE_PROXY_DEBUG\n            osFchmod(conchFile->h, cmode);\n#else\n            do{\n              rc = osFchmod(conchFile->h, cmode);\n            }while( rc==(-1) && errno==EINTR );\n            if( rc!=0 ){\n              int code = errno;\n              fprintf(stderr, \"fchmod %o FAILED with %d %s\\n\",\n                      cmode, code, strerror(code));\n            } else {\n              fprintf(stderr, \"fchmod %o SUCCEDED\\n\",cmode);\n            }\n          }else{\n            int code = errno;\n            fprintf(stderr, \"STAT FAILED[%d] with %d %s\\n\", \n                    err, code, strerror(code));\n#endif\n          }\n        }\n      }\n      conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);\n      \n    end_takeconch:\n      OSTRACE((\"TRANSPROXY: CLOSE  %d\\n\", pFile->h));\n      if( rc==SQLITE_OK && pFile->openFlags ){\n        int fd;\n        if( pFile->h>=0 ){\n          robust_close(pFile, pFile->h, __LINE__);\n        }\n        pFile->h = -1;\n        fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);\n        OSTRACE((\"TRANSPROXY: OPEN  %d\\n\", fd));\n        if( fd>=0 ){\n          pFile->h = fd;\n        }else{\n          rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called\n           during locking */\n        }\n      }\n      if( rc==SQLITE_OK && !pCtx->lockProxy ){\n        char *path = tempLockPath ? tempLockPath : pCtx->lockProxyPath;\n        rc = proxyCreateUnixFile(path, &pCtx->lockProxy, 1);\n        if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM && tryOldLockPath ){\n          /* we couldn't create the proxy lock file with the old lock file path\n           ** so try again via auto-naming \n           */\n          forceNewLockPath = 1;\n          tryOldLockPath = 0;\n          continue; /* go back to the do {} while start point, try again */\n        }\n      }\n      if( rc==SQLITE_OK ){\n        /* Need to make a copy of path if we extracted the value\n         ** from the conch file or the path was allocated on the stack\n         */\n        if( tempLockPath ){\n          pCtx->lockProxyPath = sqlite3DbStrDup(0, tempLockPath);\n          if( !pCtx->lockProxyPath ){\n            rc = SQLITE_NOMEM;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        pCtx->conchHeld = 1;\n        \n        if( pCtx->lockProxy->pMethod == &afpIoMethods ){\n          afpLockingContext *afpCtx;\n          afpCtx = (afpLockingContext *)pCtx->lockProxy->lockingContext;\n          afpCtx->dbPath = pCtx->lockProxyPath;\n        }\n      } else {\n        conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n      }\n      OSTRACE((\"TAKECONCH  %d %s\\n\", conchFile->h,\n               rc==SQLITE_OK?\"ok\":\"failed\"));\n      return rc;\n    } while (1); /* in case we need to retry the :auto: lock file - \n                 ** we should never get here except via the 'continue' call. */\n  }\n}\n\n/*\n** If pFile holds a lock on a conch file, then release that lock.\n*/\nstatic int proxyReleaseConch(unixFile *pFile){\n  int rc = SQLITE_OK;         /* Subroutine return code */\n  proxyLockingContext *pCtx;  /* The locking context for the proxy lock */\n  unixFile *conchFile;        /* Name of the conch file */\n\n  pCtx = (proxyLockingContext *)pFile->lockingContext;\n  conchFile = pCtx->conchFile;\n  OSTRACE((\"RELEASECONCH  %d for %s pid=%d\\n\", conchFile->h,\n           (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"), \n           getpid()));\n  if( pCtx->conchHeld>0 ){\n    rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n  }\n  pCtx->conchHeld = 0;\n  OSTRACE((\"RELEASECONCH  %d %s\\n\", conchFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n/*\n** Given the name of a database file, compute the name of its conch file.\n** Store the conch filename in memory obtained from sqlite3_malloc().\n** Make *pConchPath point to the new name.  Return SQLITE_OK on success\n** or SQLITE_NOMEM if unable to obtain memory.\n**\n** The caller is responsible for ensuring that the allocated memory\n** space is eventually freed.\n**\n** *pConchPath is set to NULL if a memory allocation error occurs.\n*/\nstatic int proxyCreateConchPathname(char *dbPath, char **pConchPath){\n  int i;                        /* Loop counter */\n  int len = (int)strlen(dbPath); /* Length of database filename - dbPath */\n  char *conchPath;              /* buffer in which to construct conch name */\n\n  /* Allocate space for the conch filename and initialize the name to\n  ** the name of the original database file. */  \n  *pConchPath = conchPath = (char *)sqlite3_malloc(len + 8);\n  if( conchPath==0 ){\n    return SQLITE_NOMEM;\n  }\n  memcpy(conchPath, dbPath, len+1);\n  \n  /* now insert a \".\" before the last / character */\n  for( i=(len-1); i>=0; i-- ){\n    if( conchPath[i]=='/' ){\n      i++;\n      break;\n    }\n  }\n  conchPath[i]='.';\n  while ( i<len ){\n    conchPath[i+1]=dbPath[i];\n    i++;\n  }\n\n  /* append the \"-conch\" suffix to the file */\n  memcpy(&conchPath[i+1], \"-conch\", 7);\n  assert( (int)strlen(conchPath) == len+7 );\n\n  return SQLITE_OK;\n}\n\n\n/* Takes a fully configured proxy locking-style unix file and switches\n** the local lock file path \n*/\nstatic int switchLockProxyPath(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n  char *oldPath = pCtx->lockProxyPath;\n  int rc = SQLITE_OK;\n\n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }  \n\n  /* nothing to do if the path is NULL, :auto: or matches the existing path */\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ||\n    (oldPath && !strncmp(oldPath, path, MAXPATHLEN)) ){\n    return SQLITE_OK;\n  }else{\n    unixFile *lockProxy = pCtx->lockProxy;\n    pCtx->lockProxy=NULL;\n    pCtx->conchHeld = 0;\n    if( lockProxy!=NULL ){\n      rc=lockProxy->pMethod->xClose((sqlite3_file *)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n    }\n    sqlite3_free(oldPath);\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, path);\n  }\n  \n  return rc;\n}\n\n/*\n** pFile is a file that has been opened by a prior xOpen call.  dbPath\n** is a string buffer at least MAXPATHLEN+1 characters in size.\n**\n** This routine find the filename associated with pFile and writes it\n** int dbPath.\n*/\nstatic int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){\n#if defined(__APPLE__)\n  if( pFile->pMethod == &afpIoMethods ){\n    /* afp style keeps a reference to the db path in the filePath field \n    ** of the struct */\n    assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath, MAXPATHLEN);\n  } else\n#endif\n  if( pFile->pMethod == &dotlockIoMethods ){\n    /* dot lock style uses the locking context to store the dot lock\n    ** file path */\n    int len = strlen((char *)pFile->lockingContext) - strlen(DOTLOCK_SUFFIX);\n    memcpy(dbPath, (char *)pFile->lockingContext, len + 1);\n  }else{\n    /* all other styles use the locking context to store the db file path */\n    assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, (char *)pFile->lockingContext, MAXPATHLEN);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Takes an already filled in unix file and alters it so all file locking \n** will be performed on the local proxy lock file.  The following fields\n** are preserved in the locking context so that they can be restored and \n** the unix structure properly cleaned up at close time:\n**  ->lockingContext\n**  ->pMethod\n*/\nstatic int proxyTransformUnixFile(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx;\n  char dbPath[MAXPATHLEN+1];       /* Name of the database file */\n  char *lockPath=NULL;\n  int rc = SQLITE_OK;\n  \n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }\n  proxyGetDbPathForUnixFile(pFile, dbPath);\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ){\n    lockPath=NULL;\n  }else{\n    lockPath=(char *)path;\n  }\n  \n  OSTRACE((\"TRANSPROXY  %d for %s pid=%d\\n\", pFile->h,\n           (lockPath ? lockPath : \":auto:\"), getpid()));\n\n  pCtx = sqlite3_malloc( sizeof(*pCtx) );\n  if( pCtx==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCtx, 0, sizeof(*pCtx));\n\n  rc = proxyCreateConchPathname(dbPath, &pCtx->conchFilePath);\n  if( rc==SQLITE_OK ){\n    rc = proxyCreateUnixFile(pCtx->conchFilePath, &pCtx->conchFile, 0);\n    if( rc==SQLITE_CANTOPEN && ((pFile->openFlags&O_RDWR) == 0) ){\n      /* if (a) the open flags are not O_RDWR, (b) the conch isn't there, and\n      ** (c) the file system is read-only, then enable no-locking access.\n      ** Ugh, since O_RDONLY==0x0000 we test for !O_RDWR since unixOpen asserts\n      ** that openFlags will have only one of O_RDONLY or O_RDWR.\n      */\n      struct statfs fsInfo;\n      struct stat conchInfo;\n      int goLockless = 0;\n\n      if( osStat(pCtx->conchFilePath, &conchInfo) == -1 ) {\n        int err = errno;\n        if( (err==ENOENT) && (statfs(dbPath, &fsInfo) != -1) ){\n          goLockless = (fsInfo.f_flags&MNT_RDONLY) == MNT_RDONLY;\n        }\n      }\n      if( goLockless ){\n        pCtx->conchHeld = -1; /* read only FS/ lockless */\n        rc = SQLITE_OK;\n      }\n    }\n  }  \n  if( rc==SQLITE_OK && lockPath ){\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, lockPath);\n  }\n\n  if( rc==SQLITE_OK ){\n    pCtx->dbPath = sqlite3DbStrDup(0, dbPath);\n    if( pCtx->dbPath==NULL ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    /* all memory is allocated, proxys are created and assigned, \n    ** switch the locking context and pMethod then return.\n    */\n    pCtx->oldLockingContext = pFile->lockingContext;\n    pFile->lockingContext = pCtx;\n    pCtx->pOldMethod = pFile->pMethod;\n    pFile->pMethod = &proxyIoMethods;\n  }else{\n    if( pCtx->conchFile ){ \n      pCtx->conchFile->pMethod->xClose((sqlite3_file *)pCtx->conchFile);\n      sqlite3_free(pCtx->conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath); \n    sqlite3_free(pCtx);\n  }\n  OSTRACE((\"TRANSPROXY  %d %s\\n\", pFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n\n/*\n** This routine handles sqlite3_file_control() calls that are specific\n** to proxy locking.\n*/\nstatic int proxyFileControl(sqlite3_file *id, int op, void *pArg){\n  switch( op ){\n    case SQLITE_GET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      if( pFile->pMethod == &proxyIoMethods ){\n        proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n        proxyTakeConch(pFile);\n        if( pCtx->lockProxyPath ){\n          *(const char **)pArg = pCtx->lockProxyPath;\n        }else{\n          *(const char **)pArg = \":auto: (not held)\";\n        }\n      } else {\n        *(const char **)pArg = NULL;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_SET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      int rc = SQLITE_OK;\n      int isProxyStyle = (pFile->pMethod == &proxyIoMethods);\n      if( pArg==NULL || (const char *)pArg==0 ){\n        if( isProxyStyle ){\n          /* turn off proxy locking - not supported */\n          rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;\n        }else{\n          /* turn off proxy locking - already off - NOOP */\n          rc = SQLITE_OK;\n        }\n      }else{\n        const char *proxyPath = (const char *)pArg;\n        if( isProxyStyle ){\n          proxyLockingContext *pCtx = \n            (proxyLockingContext*)pFile->lockingContext;\n          if( !strcmp(pArg, \":auto:\") \n           || (pCtx->lockProxyPath &&\n               !strncmp(pCtx->lockProxyPath, proxyPath, MAXPATHLEN))\n          ){\n            rc = SQLITE_OK;\n          }else{\n            rc = switchLockProxyPath(pFile, proxyPath);\n          }\n        }else{\n          /* turn on proxy file locking */\n          rc = proxyTransformUnixFile(pFile, proxyPath);\n        }\n      }\n      return rc;\n    }\n    default: {\n      assert( 0 );  /* The call assures that only valid opcodes are sent */\n    }\n  }\n  /*NOTREACHED*/\n  return SQLITE_ERROR;\n}\n\n/*\n** Within this division (the proxying locking implementation) the procedures\n** above this point are all utilities.  The lock-related methods of the\n** proxy-locking sqlite3_io_method object follow.\n*/\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      return proxy->pMethod->xCheckReservedLock((sqlite3_file*)proxy, pResOut);\n    }else{ /* conchHeld < 0 is lockless */\n      pResOut=0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int proxyLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int proxyUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n/*\n** Close a file that uses proxy locks.\n*/\nstatic int proxyClose(sqlite3_file *id) {\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    unixFile *lockProxy = pCtx->lockProxy;\n    unixFile *conchFile = pCtx->conchFile;\n    int rc = SQLITE_OK;\n    \n    if( lockProxy ){\n      rc = lockProxy->pMethod->xUnlock((sqlite3_file*)lockProxy, NO_LOCK);\n      if( rc ) return rc;\n      rc = lockProxy->pMethod->xClose((sqlite3_file*)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n      pCtx->lockProxy = 0;\n    }\n    if( conchFile ){\n      if( pCtx->conchHeld ){\n        rc = proxyReleaseConch(pFile);\n        if( rc ) return rc;\n      }\n      rc = conchFile->pMethod->xClose((sqlite3_file*)conchFile);\n      if( rc ) return rc;\n      sqlite3_free(conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath);\n    sqlite3DbFree(0, pCtx->dbPath);\n    /* restore the original locking context and pMethod then close it */\n    pFile->lockingContext = pCtx->oldLockingContext;\n    pFile->pMethod = pCtx->pOldMethod;\n    sqlite3_free(pCtx);\n    return pFile->pMethod->xClose(id);\n  }\n  return SQLITE_OK;\n}\n\n\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The proxy locking style is intended for use with AFP filesystems.\n** And since AFP is only supported on MacOSX, the proxy locking is also\n** restricted to MacOSX.\n** \n**\n******************* End of the proxy lock implementation **********************\n******************************************************************************/\n\n/*\n** Initialize the operating system interface.\n**\n** This routine registers all VFS implementations for unix-like operating\n** systems.  This routine, and the sqlite3_os_end() routine that follows,\n** should be the only routines in this file that are visible from other\n** files.\n**\n** This routine is called once during SQLite initialization and by a\n** single thread.  The memory allocation and mutex subsystems have not\n** necessarily been initialized when this routine is called, and so they\n** should not be used.\n*/\nSQLITE_API int sqlite3_os_init(void){ \n  /* \n  ** The following macro defines an initializer for an sqlite3_vfs object.\n  ** The name of the VFS is NAME.  The pAppData is a pointer to a pointer\n  ** to the \"finder\" function.  (pAppData is a pointer to a pointer because\n  ** silly C90 rules prohibit a void* from being cast to a function pointer\n  ** and so we have to go through the intermediate pointer to avoid problems\n  ** when compiling with -pedantic-errors on GCC.)\n  **\n  ** The FINDER parameter to this macro is the name of the pointer to the\n  ** finder-function.  The finder-function returns a pointer to the\n  ** sqlite_io_methods object that implements the desired locking\n  ** behaviors.  See the division above that contains the IOMETHODS\n  ** macro for addition information on finder-functions.\n  **\n  ** Most finders simply return a pointer to a fixed sqlite3_io_methods\n  ** object.  But the \"autolockIoFinder\" available on MacOSX does a little\n  ** more than that; it looks at the filesystem type that hosts the \n  ** database file and tries to choose an locking method appropriate for\n  ** that filesystem time.\n  */\n  #define UNIXVFS(VFSNAME, FINDER) {                        \\\n    3,                    /* iVersion */                    \\\n    sizeof(unixFile),     /* szOsFile */                    \\\n    MAX_PATHNAME,         /* mxPathname */                  \\\n    0,                    /* pNext */                       \\\n    VFSNAME,              /* zName */                       \\\n    (void*)&FINDER,       /* pAppData */                    \\\n    unixOpen,             /* xOpen */                       \\\n    unixDelete,           /* xDelete */                     \\\n    unixAccess,           /* xAccess */                     \\\n    unixFullPathname,     /* xFullPathname */               \\\n    unixDlOpen,           /* xDlOpen */                     \\\n    unixDlError,          /* xDlError */                    \\\n    unixDlSym,            /* xDlSym */                      \\\n    unixDlClose,          /* xDlClose */                    \\\n    unixRandomness,       /* xRandomness */                 \\\n    unixSleep,            /* xSleep */                      \\\n    unixCurrentTime,      /* xCurrentTime */                \\\n    unixGetLastError,     /* xGetLastError */               \\\n    unixCurrentTimeInt64, /* xCurrentTimeInt64 */           \\\n    unixSetSystemCall,    /* xSetSystemCall */              \\\n    unixGetSystemCall,    /* xGetSystemCall */              \\\n    unixNextSystemCall,   /* xNextSystemCall */             \\\n  }\n\n  /*\n  ** All default VFSes for unix are contained in the following array.\n  **\n  ** Note that the sqlite3_vfs.pNext field of the VFS object is modified\n  ** by the SQLite core when the VFS is registered.  So the following\n  ** array cannot be const.\n  */\n  static sqlite3_vfs aVfs[] = {\n#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))\n    UNIXVFS(\"unix\",          autolockIoFinder ),\n#else\n    UNIXVFS(\"unix\",          posixIoFinder ),\n#endif\n    UNIXVFS(\"unix-none\",     nolockIoFinder ),\n    UNIXVFS(\"unix-dotfile\",  dotlockIoFinder ),\n    UNIXVFS(\"unix-excl\",     posixIoFinder ),\n#if OS_VXWORKS\n    UNIXVFS(\"unix-namedsem\", semIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n    UNIXVFS(\"unix-posix\",    posixIoFinder ),\n#if !OS_VXWORKS\n    UNIXVFS(\"unix-flock\",    flockIoFinder ),\n#endif\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix-afp\",      afpIoFinder ),\n    UNIXVFS(\"unix-nfs\",      nfsIoFinder ),\n    UNIXVFS(\"unix-proxy\",    proxyIoFinder ),\n#endif\n  };\n  unsigned int i;          /* Loop counter */\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==24 );\n\n  /* Register all VFSes defined in the aVfs[] array */\n  for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){\n    sqlite3_vfs_register(&aVfs[i], i==0);\n  }\n  return SQLITE_OK; \n}\n\n/*\n** Shutdown the operating system interface.\n**\n** Some operating systems might need to do some cleanup in this routine,\n** to release dynamically allocated objects.  But not on unix.\n** This routine is a no-op for unix.\n*/\nSQLITE_API int sqlite3_os_end(void){ \n  return SQLITE_OK; \n}\n \n#endif /* SQLITE_OS_UNIX */\n\n/************** End of os_unix.c *********************************************/\n/************** Begin file os_win.c ******************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n#if SQLITE_OS_WIN               /* This file is used for Windows only */\n\n#ifdef __CYGWIN__\n# include <sys/cygwin.h>\n#endif\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_win.c ****************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n# ifndef SQLITE_DEBUG_OS_TRACE\n#   define SQLITE_DEBUG_OS_TRACE 0\n# endif\n  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;\n# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X\n#else\n# define OSTRACE(X)\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef _HWTIME_H_\n#define _HWTIME_H_\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(_HWTIME_H_) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_io_error_hit = 0;            /* Total number of I/O Errors */\nSQLITE_API int sqlite3_io_error_hardhit = 0;        /* Number of non-benign errors */\nSQLITE_API int sqlite3_io_error_pending = 0;        /* Count down to first I/O error */\nSQLITE_API int sqlite3_io_error_persist = 0;        /* True if I/O errors persist */\nSQLITE_API int sqlite3_io_error_benign = 0;         /* True if errors are benign */\nSQLITE_API int sqlite3_diskfull_pending = 0;\nSQLITE_API int sqlite3_diskfull = 0;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_open_file_count = 0;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_win.c *********************/\n\n/*\n** Compiling and using WAL mode requires several APIs that are only\n** available in Windows platforms based on the NT kernel.\n*/\n#if !SQLITE_OS_WINNT && !defined(SQLITE_OMIT_WAL)\n# error \"WAL mode requires support from the Windows NT kernel, compile\\\n with SQLITE_OMIT_WAL.\"\n#endif\n\n/*\n** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n#  define SQLITE_WIN32_HAS_ANSI\n#endif\n\n/*\n** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT\n#  define SQLITE_WIN32_HAS_WIDE\n#endif\n\n/*\n** Do we need to manually define the Win32 file mapping APIs for use with WAL\n** mode (e.g. these APIs are available in the Windows CE SDK; however, they\n** are not present in the header file)?\n*/\n#if SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL)\n/*\n** Two of the file mapping APIs are different under WinRT.  Figure out which\n** set we need.\n*/\n#if SQLITE_OS_WINRT\nWINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \\\n        LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);\n\nWINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);\n#else\n#if defined(SQLITE_WIN32_HAS_ANSI)\nWINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCSTR);\n#endif /* defined(SQLITE_WIN32_HAS_ANSI) */\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\nWINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCWSTR);\n#endif /* defined(SQLITE_WIN32_HAS_WIDE) */\n\nWINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);\n#endif /* SQLITE_OS_WINRT */\n\n/*\n** This file mapping API is common to both Win32 and WinRT.\n*/\nWINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);\n#endif /* SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL) */\n\n/*\n** Macro to find the minimum of two numeric values.\n*/\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_FILE_ATTRIBUTES\n# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) \n#endif\n\n#ifndef FILE_FLAG_MASK\n# define FILE_FLAG_MASK          (0xFF3C0000)\n#endif\n\n#ifndef FILE_ATTRIBUTE_MASK\n# define FILE_ATTRIBUTE_MASK     (0x0003FFF7)\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/* Forward references */\ntypedef struct winShm winShm;           /* A connection to shared-memory */\ntypedef struct winShmNode winShmNode;   /* A region of shared-memory */\n#endif\n\n/*\n** WinCE lacks native support for file locking so we have to fake it\n** with some code of our own.\n*/\n#if SQLITE_OS_WINCE\ntypedef struct winceLock {\n  int nReaders;       /* Number of reader locks obtained */\n  BOOL bPending;      /* Indicates a pending lock has been obtained */\n  BOOL bReserved;     /* Indicates a reserved lock has been obtained */\n  BOOL bExclusive;    /* Indicates an exclusive lock has been obtained */\n} winceLock;\n#endif\n\n/*\n** The winFile structure is a subclass of sqlite3_file* specific to the win32\n** portability layer.\n*/\ntypedef struct winFile winFile;\nstruct winFile {\n  const sqlite3_io_methods *pMethod; /*** Must be first ***/\n  sqlite3_vfs *pVfs;      /* The VFS used to open this file */\n  HANDLE h;               /* Handle for accessing the file */\n  u8 locktype;            /* Type of lock currently held on this file */\n  short sharedLockByte;   /* Randomly chosen byte used as a shared lock */\n  u8 ctrlFlags;           /* Flags.  See WINFILE_* below */\n  DWORD lastErrno;        /* The Windows errno from the last I/O error */\n#ifndef SQLITE_OMIT_WAL\n  winShm *pShm;           /* Instance of shared memory on this file */\n#endif\n  const char *zPath;      /* Full pathname of this file */\n  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_OS_WINCE\n  LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */\n  HANDLE hMutex;          /* Mutex used to control access to shared lock */  \n  HANDLE hShared;         /* Shared memory segment used for locking */\n  winceLock local;        /* Locks obtained by this instance of winFile */\n  winceLock *shared;      /* Global shared lock memory for the file  */\n#endif\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                /* Number of outstanding xFetch references */\n  HANDLE hMap;                  /* Handle for accessing memory mapping */\n  void *pMapRegion;             /* Area memory mapped */\n  sqlite3_int64 mmapSize;       /* Usable size of mapped region */\n  sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */\n  sqlite3_int64 mmapSizeMax;    /* Configured FCNTL_MMAP_SIZE value */\n#endif\n};\n\n/*\n** Allowed values for winFile.ctrlFlags\n*/\n#define WINFILE_RDONLY          0x02   /* Connection is read only */\n#define WINFILE_PERSIST_WAL     0x04   /* Persistent WAL mode */\n#define WINFILE_PSOW            0x10   /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n\n/*\n * The size of the buffer used by sqlite3_win32_write_debug().\n */\n#ifndef SQLITE_WIN32_DBG_BUF_SIZE\n#  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the data directory should be changed.\n */\n#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE\n#  define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1)\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the temporary directory should be changed.\n */\n#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n#  define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2)\n#endif\n\n/*\n * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the\n * various Win32 API heap functions instead of our own.\n */\n#ifdef SQLITE_WIN32_MALLOC\n\n/*\n * If this is non-zero, an isolated heap will be created by the native Win32\n * allocator subsystem; otherwise, the default process heap will be used.  This\n * setting has no effect when compiling for WinRT.  By default, this is enabled\n * and an isolated heap will be created to store all allocated data.\n *\n ******************************************************************************\n * WARNING: It is important to note that when this setting is non-zero and the\n *          winMemShutdown function is called (e.g. by the sqlite3_shutdown\n *          function), all data that was allocated using the isolated heap will\n *          be freed immediately and any attempt to access any of that freed\n *          data will almost certainly result in an immediate access violation.\n ******************************************************************************\n */\n#ifndef SQLITE_WIN32_HEAP_CREATE\n#  define SQLITE_WIN32_HEAP_CREATE    (TRUE)\n#endif\n\n/*\n * The initial size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_DEFAULT_CACHE_SIZE) * \\\n                                       (SQLITE_DEFAULT_PAGE_SIZE) + 4194304)\n#endif\n\n/*\n * The maximum size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_SIZE  (0)\n#endif\n\n/*\n * The extra flags to use in calls to the Win32 heap APIs.  This value may be\n * zero for the default behavior.\n */\n#ifndef SQLITE_WIN32_HEAP_FLAGS\n#  define SQLITE_WIN32_HEAP_FLAGS     (0)\n#endif\n\n/*\n** The winMemData structure stores information required by the Win32-specific\n** sqlite3_mem_methods implementation.\n*/\ntypedef struct winMemData winMemData;\nstruct winMemData {\n#ifndef NDEBUG\n  u32 magic;    /* Magic number to detect structure corruption. */\n#endif\n  HANDLE hHeap; /* The handle to our heap. */\n  BOOL bOwned;  /* Do we own the heap (i.e. destroy it on shutdown)? */\n};\n\n#ifndef NDEBUG\n#define WINMEM_MAGIC     0x42b2830b\n#endif\n\nstatic struct winMemData win_mem_data = {\n#ifndef NDEBUG\n  WINMEM_MAGIC,\n#endif\n  NULL, FALSE\n};\n\n#ifndef NDEBUG\n#define winMemAssertMagic() assert( win_mem_data.magic==WINMEM_MAGIC )\n#else\n#define winMemAssertMagic()\n#endif\n\n#define winMemGetHeap() win_mem_data.hHeap\n\nstatic void *winMemMalloc(int nBytes);\nstatic void winMemFree(void *pPrior);\nstatic void *winMemRealloc(void *pPrior, int nBytes);\nstatic int winMemSize(void *p);\nstatic int winMemRoundup(int n);\nstatic int winMemInit(void *pAppData);\nstatic void winMemShutdown(void *pAppData);\n\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** The following variable is (normally) set once and never changes\n** thereafter.  It records whether the operating system is Win9x\n** or WinNT.\n**\n** 0:   Operating system unknown.\n** 1:   Operating system is Win9x.\n** 2:   Operating system is WinNT.\n**\n** In order to facilitate testing on a WinNT system, the test fixture\n** can manually set this value to 1 to emulate Win98 behavior.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_os_type = 0;\n#else\nstatic int sqlite3_os_type = 0;\n#endif\n\n#ifndef SYSCALL\n#  define SYSCALL sqlite3_syscall_ptr\n#endif\n\n/*\n** This function is not available on Windows CE or WinRT.\n */\n\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n#  define osAreFileApisANSI()       1\n#endif\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct win_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"AreFileApisANSI\",         (SYSCALL)AreFileApisANSI,         0 },\n#else\n  { \"AreFileApisANSI\",         (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osAreFileApisANSI\n#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharLowerW\",              (SYSCALL)CharLowerW,              0 },\n#else\n  { \"CharLowerW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharLowerW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[1].pCurrent)\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharUpperW\",              (SYSCALL)CharUpperW,              0 },\n#else\n  { \"CharUpperW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharUpperW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[2].pCurrent)\n\n  { \"CloseHandle\",             (SYSCALL)CloseHandle,             0 },\n\n#define osCloseHandle ((BOOL(WINAPI*)(HANDLE))aSyscall[3].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"CreateFileA\",             (SYSCALL)CreateFileA,             0 },\n#else\n  { \"CreateFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateFileW\",             (SYSCALL)CreateFileW,             0 },\n#else\n  { \"CreateFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)\n\n#if (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \\\n        !defined(SQLITE_OMIT_WAL))\n  { \"CreateFileMappingA\",      (SYSCALL)CreateFileMappingA,      0 },\n#else\n  { \"CreateFileMappingA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        !defined(SQLITE_OMIT_WAL))\n  { \"CreateFileMappingW\",      (SYSCALL)CreateFileMappingW,      0 },\n#else\n  { \"CreateFileMappingW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateMutexW\",            (SYSCALL)CreateMutexW,            0 },\n#else\n  { \"CreateMutexW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \\\n        LPCWSTR))aSyscall[8].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"DeleteFileA\",             (SYSCALL)DeleteFileA,             0 },\n#else\n  { \"DeleteFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"DeleteFileW\",             (SYSCALL)DeleteFileW,             0 },\n#else\n  { \"DeleteFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToLocalFileTime\", (SYSCALL)FileTimeToLocalFileTime, 0 },\n#else\n  { \"FileTimeToLocalFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPFILETIME))aSyscall[11].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToSystemTime\",    (SYSCALL)FileTimeToSystemTime,    0 },\n#else\n  { \"FileTimeToSystemTime\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPSYSTEMTIME))aSyscall[12].pCurrent)\n\n  { \"FlushFileBuffers\",        (SYSCALL)FlushFileBuffers,        0 },\n\n#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"FormatMessageA\",          (SYSCALL)FormatMessageA,          0 },\n#else\n  { \"FormatMessageA\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \\\n        DWORD,va_list*))aSyscall[14].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"FormatMessageW\",          (SYSCALL)FormatMessageW,          0 },\n#else\n  { \"FormatMessageW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \\\n        DWORD,va_list*))aSyscall[15].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"FreeLibrary\",             (SYSCALL)FreeLibrary,             0 },\n#else\n  { \"FreeLibrary\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent)\n\n  { \"GetCurrentProcessId\",     (SYSCALL)GetCurrentProcessId,     0 },\n\n#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)GetDiskFreeSpaceA,       0 },\n#else\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[18].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)GetDiskFreeSpaceW,       0 },\n#else\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[19].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFileAttributesA\",      (SYSCALL)GetFileAttributesA,      0 },\n#else\n  { \"GetFileAttributesA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesW\",      (SYSCALL)GetFileAttributesW,      0 },\n#else\n  { \"GetFileAttributesW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesExW\",    (SYSCALL)GetFileAttributesExW,    0 },\n#else\n  { \"GetFileAttributesExW\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \\\n        LPVOID))aSyscall[22].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetFileSize\",             (SYSCALL)GetFileSize,             0 },\n#else\n  { \"GetFileSize\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFullPathNameA\",        (SYSCALL)GetFullPathNameA,        0 },\n#else\n  { \"GetFullPathNameA\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \\\n        LPSTR*))aSyscall[24].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFullPathNameW\",        (SYSCALL)GetFullPathNameW,        0 },\n#else\n  { \"GetFullPathNameW\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \\\n        LPWSTR*))aSyscall[25].pCurrent)\n\n  { \"GetLastError\",            (SYSCALL)GetLastError,            0 },\n\n#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#if SQLITE_OS_WINCE\n  /* The GetProcAddressA() routine is only available on Windows CE. */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddressA,         0 },\n#else\n  /* All other Windows platforms expect GetProcAddress() to take\n  ** an ANSI string regardless of the _UNICODE setting */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddress,          0 },\n#endif\n#else\n  { \"GetProcAddressA\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \\\n        LPCSTR))aSyscall[27].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetSystemInfo\",           (SYSCALL)GetSystemInfo,           0 },\n#else\n  { \"GetSystemInfo\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)\n\n  { \"GetSystemTime\",           (SYSCALL)GetSystemTime,           0 },\n\n#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)GetSystemTimeAsFileTime, 0 },\n#else\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \\\n        LPFILETIME))aSyscall[30].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetTempPathA\",            (SYSCALL)GetTempPathA,            0 },\n#else\n  { \"GetTempPathA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetTempPathW\",            (SYSCALL)GetTempPathW,            0 },\n#else\n  { \"GetTempPathW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetTickCount\",            (SYSCALL)GetTickCount,            0 },\n#else\n  { \"GetTickCount\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetVersionExA\",           (SYSCALL)GetVersionExA,           0 },\n#else\n  { \"GetVersionExA\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExA ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOA))aSyscall[34].pCurrent)\n\n  { \"HeapAlloc\",               (SYSCALL)HeapAlloc,               0 },\n\n#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \\\n        SIZE_T))aSyscall[35].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapCreate\",              (SYSCALL)HeapCreate,              0 },\n#else\n  { \"HeapCreate\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \\\n        SIZE_T))aSyscall[36].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapDestroy\",             (SYSCALL)HeapDestroy,             0 },\n#else\n  { \"HeapDestroy\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[37].pCurrent)\n\n  { \"HeapFree\",                (SYSCALL)HeapFree,                0 },\n\n#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[38].pCurrent)\n\n  { \"HeapReAlloc\",             (SYSCALL)HeapReAlloc,             0 },\n\n#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \\\n        SIZE_T))aSyscall[39].pCurrent)\n\n  { \"HeapSize\",                (SYSCALL)HeapSize,                0 },\n\n#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[40].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapValidate\",            (SYSCALL)HeapValidate,            0 },\n#else\n  { \"HeapValidate\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[41].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryA\",            (SYSCALL)LoadLibraryA,            0 },\n#else\n  { \"LoadLibraryA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[42].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryW\",            (SYSCALL)LoadLibraryW,            0 },\n#else\n  { \"LoadLibraryW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[43].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"LocalFree\",               (SYSCALL)LocalFree,               0 },\n#else\n  { \"LocalFree\",               (SYSCALL)0,                       0 },\n#endif\n\n#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[44].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"LockFile\",                (SYSCALL)LockFile,                0 },\n#else\n  { \"LockFile\",                (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFile\n#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[45].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"LockFileEx\",              (SYSCALL)LockFileEx,              0 },\n#else\n  { \"LockFileEx\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFileEx\n#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[46].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL))\n  { \"MapViewOfFile\",           (SYSCALL)MapViewOfFile,           0 },\n#else\n  { \"MapViewOfFile\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        SIZE_T))aSyscall[47].pCurrent)\n\n  { \"MultiByteToWideChar\",     (SYSCALL)MultiByteToWideChar,     0 },\n\n#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \\\n        int))aSyscall[48].pCurrent)\n\n  { \"QueryPerformanceCounter\", (SYSCALL)QueryPerformanceCounter, 0 },\n\n#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \\\n        LARGE_INTEGER*))aSyscall[49].pCurrent)\n\n  { \"ReadFile\",                (SYSCALL)ReadFile,                0 },\n\n#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[50].pCurrent)\n\n  { \"SetEndOfFile\",            (SYSCALL)SetEndOfFile,            0 },\n\n#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[51].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"SetFilePointer\",          (SYSCALL)SetFilePointer,          0 },\n#else\n  { \"SetFilePointer\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \\\n        DWORD))aSyscall[52].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"Sleep\",                   (SYSCALL)Sleep,                   0 },\n#else\n  { \"Sleep\",                   (SYSCALL)0,                       0 },\n#endif\n\n#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[53].pCurrent)\n\n  { \"SystemTimeToFileTime\",    (SYSCALL)SystemTimeToFileTime,    0 },\n\n#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \\\n        LPFILETIME))aSyscall[54].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"UnlockFile\",              (SYSCALL)UnlockFile,              0 },\n#else\n  { \"UnlockFile\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osUnlockFile\n#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[55].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"UnlockFileEx\",            (SYSCALL)UnlockFileEx,            0 },\n#else\n  { \"UnlockFileEx\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[56].pCurrent)\n\n#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL)\n  { \"UnmapViewOfFile\",         (SYSCALL)UnmapViewOfFile,         0 },\n#else\n  { \"UnmapViewOfFile\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[57].pCurrent)\n\n  { \"WideCharToMultiByte\",     (SYSCALL)WideCharToMultiByte,     0 },\n\n#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \\\n        LPCSTR,LPBOOL))aSyscall[58].pCurrent)\n\n  { \"WriteFile\",               (SYSCALL)WriteFile,               0 },\n\n#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[59].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateEventExW\",          (SYSCALL)CreateEventExW,          0 },\n#else\n  { \"CreateEventExW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \\\n        DWORD,DWORD))aSyscall[60].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"WaitForSingleObject\",     (SYSCALL)WaitForSingleObject,     0 },\n#else\n  { \"WaitForSingleObject\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \\\n        DWORD))aSyscall[61].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"WaitForSingleObjectEx\",   (SYSCALL)WaitForSingleObjectEx,   0 },\n#else\n  { \"WaitForSingleObjectEx\",   (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \\\n        BOOL))aSyscall[62].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"SetFilePointerEx\",        (SYSCALL)SetFilePointerEx,        0 },\n#else\n  { \"SetFilePointerEx\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \\\n        PLARGE_INTEGER,DWORD))aSyscall[63].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetFileInformationByHandleEx\", (SYSCALL)GetFileInformationByHandleEx, 0 },\n#else\n  { \"GetFileInformationByHandleEx\", (SYSCALL)0,                  0 },\n#endif\n\n#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \\\n        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[64].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)\n  { \"MapViewOfFileFromApp\",    (SYSCALL)MapViewOfFileFromApp,    0 },\n#else\n  { \"MapViewOfFileFromApp\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \\\n        SIZE_T))aSyscall[65].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateFile2\",             (SYSCALL)CreateFile2,             0 },\n#else\n  { \"CreateFile2\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \\\n        LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[66].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadPackagedLibrary\",     (SYSCALL)LoadPackagedLibrary,     0 },\n#else\n  { \"LoadPackagedLibrary\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \\\n        DWORD))aSyscall[67].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetTickCount64\",          (SYSCALL)GetTickCount64,          0 },\n#else\n  { \"GetTickCount64\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[68].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetNativeSystemInfo\",     (SYSCALL)GetNativeSystemInfo,     0 },\n#else\n  { \"GetNativeSystemInfo\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osGetNativeSystemInfo ((VOID(WINAPI*)( \\\n        LPSYSTEM_INFO))aSyscall[69].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"OutputDebugStringA\",      (SYSCALL)OutputDebugStringA,      0 },\n#else\n  { \"OutputDebugStringA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[70].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"OutputDebugStringW\",      (SYSCALL)OutputDebugStringW,      0 },\n#else\n  { \"OutputDebugStringW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[71].pCurrent)\n\n  { \"GetProcessHeap\",          (SYSCALL)GetProcessHeap,          0 },\n\n#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[72].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)\n  { \"CreateFileMappingFromApp\", (SYSCALL)CreateFileMappingFromApp, 0 },\n#else\n  { \"CreateFileMappingFromApp\", (SYSCALL)0,                      0 },\n#endif\n\n#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \\\n        LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[73].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"win32\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int winSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr winGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n/*\n** This function outputs the specified (ANSI) string to the Win32 debugger\n** (if available).\n*/\n\nSQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){\n  char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];\n  int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */\n  if( nMin<-1 ) nMin = -1; /* all negative values become -1. */\n  assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    osOutputDebugStringA(zDbgBuf);\n  }else{\n    osOutputDebugStringA(zBuf);\n  }\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n  memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n  if ( osMultiByteToWideChar(\n          osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf,\n          nMin, (LPWSTR)zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){\n    return;\n  }\n  osOutputDebugStringW((LPCWSTR)zDbgBuf);\n#else\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    fprintf(stderr, \"%s\", zDbgBuf);\n  }else{\n    fprintf(stderr, \"%s\", zBuf);\n  }\n#endif\n}\n\n/*\n** The following routine suspends the current thread for at least ms\n** milliseconds.  This is equivalent to the Win32 Sleep() interface.\n*/\n#if SQLITE_OS_WINRT\nstatic HANDLE sleepObj = NULL;\n#endif\n\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){\n#if SQLITE_OS_WINRT\n  if ( sleepObj==NULL ){\n    sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,\n                                SYNCHRONIZE);\n  }\n  assert( sleepObj!=NULL );\n  osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);\n#else\n  osSleep(milliseconds);\n#endif\n}\n\n/*\n** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,\n** or WinCE.  Return false (zero) for Win95, Win98, or WinME.\n**\n** Here is an interesting observation:  Win95, Win98, and WinME lack\n** the LockFileEx() API.  But we can still statically link against that\n** API as long as we don't call it when running Win95/98/ME.  A call to\n** this routine is used to determine if the host is Win95/98/ME or\n** WinNT/2K/XP so that we will know whether or not we can safely call\n** the LockFileEx() API.\n*/\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n# define isNT()  (1)\n#elif !defined(SQLITE_WIN32_HAS_WIDE)\n# define isNT()  (0)\n#else\n  static int isNT(void){\n    if( sqlite3_os_type==0 ){\n      OSVERSIONINFOA sInfo;\n      sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n      osGetVersionExA(&sInfo);\n      sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;\n    }\n    return sqlite3_os_type==2;\n  }\n#endif\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *winMemMalloc(int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  assert( nBytes>=0 );\n  p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapAlloc %u bytes (%d), heap=%p\",\n                nBytes, osGetLastError(), (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Free memory.\n*/\nstatic void winMemFree(void *pPrior){\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */\n  if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapFree block %p (%d), heap=%p\",\n                pPrior, osGetLastError(), (void*)hHeap);\n  }\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *winMemRealloc(void *pPrior, int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  assert( nBytes>=0 );\n  if( !pPrior ){\n    p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  }else{\n    p = osHeapReAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior, (SIZE_T)nBytes);\n  }\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to %s %u bytes (%d), heap=%p\",\n                pPrior ? \"HeapReAlloc\" : \"HeapAlloc\", nBytes, osGetLastError(),\n                (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n*/\nstatic int winMemSize(void *p){\n  HANDLE hHeap;\n  SIZE_T n;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  if( !p ) return 0;\n  n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);\n  if( n==(SIZE_T)-1 ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapSize block %p (%d), heap=%p\",\n                p, osGetLastError(), (void*)hHeap);\n    return 0;\n  }\n  return (int)n;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int winMemRoundup(int n){\n  return n;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int winMemInit(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return SQLITE_ERROR;\n  assert( pWinMemData->magic==WINMEM_MAGIC );\n\n#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE\n  if( !pWinMemData->hHeap ){\n    pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS,\n                                      SQLITE_WIN32_HEAP_INIT_SIZE,\n                                      SQLITE_WIN32_HEAP_MAX_SIZE);\n    if( !pWinMemData->hHeap ){\n      sqlite3_log(SQLITE_NOMEM,\n          \"failed to HeapCreate (%d), flags=%u, initSize=%u, maxSize=%u\",\n          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS,\n          SQLITE_WIN32_HEAP_INIT_SIZE, SQLITE_WIN32_HEAP_MAX_SIZE);\n      return SQLITE_NOMEM;\n    }\n    pWinMemData->bOwned = TRUE;\n    assert( pWinMemData->bOwned );\n  }\n#else\n  pWinMemData->hHeap = osGetProcessHeap();\n  if( !pWinMemData->hHeap ){\n    sqlite3_log(SQLITE_NOMEM,\n        \"failed to GetProcessHeap (%d)\", osGetLastError());\n    return SQLITE_NOMEM;\n  }\n  pWinMemData->bOwned = FALSE;\n  assert( !pWinMemData->bOwned );\n#endif\n  assert( pWinMemData->hHeap!=0 );\n  assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void winMemShutdown(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return;\n  if( pWinMemData->hHeap ){\n    assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n    assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n    if( pWinMemData->bOwned ){\n      if( !osHeapDestroy(pWinMemData->hHeap) ){\n        sqlite3_log(SQLITE_NOMEM, \"failed to HeapDestroy (%d), heap=%p\",\n                    osGetLastError(), (void*)pWinMemData->hHeap);\n      }\n      pWinMemData->bOwned = FALSE;\n    }\n    pWinMemData->hHeap = NULL;\n  }\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void){\n  static const sqlite3_mem_methods winMemMethods = {\n    winMemMalloc,\n    winMemFree,\n    winMemRealloc,\n    winMemSize,\n    winMemRoundup,\n    winMemInit,\n    winMemShutdown,\n    &win_mem_data\n  };\n  return &winMemMethods;\n}\n\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** Convert a UTF-8 string to Microsoft Unicode (UTF-16?). \n**\n** Space to hold the returned string is obtained from malloc.\n*/\nstatic LPWSTR utf8ToUnicode(const char *zFilename){\n  int nChar;\n  LPWSTR zWideFilename;\n\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideFilename = sqlite3MallocZero( nChar*sizeof(zWideFilename[0]) );\n  if( zWideFilename==0 ){\n    return 0;\n  }\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideFilename);\n    zWideFilename = 0;\n  }\n  return zWideFilename;\n}\n\n/*\n** Convert Microsoft Unicode to UTF-8.  Space to hold the returned string is\n** obtained from sqlite3_malloc().\n*/\nstatic char *unicodeToUtf8(LPCWSTR zWideFilename){\n  int nByte;\n  char *zFilename;\n\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zFilename = sqlite3MallocZero( nByte );\n  if( zFilename==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte,\n                                0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zFilename);\n    zFilename = 0;\n  }\n  return zFilename;\n}\n\n/*\n** Convert an ANSI string to Microsoft Unicode, based on the\n** current codepage settings for file apis.\n** \n** Space to hold the returned string is obtained\n** from sqlite3_malloc.\n*/\nstatic LPWSTR mbcsToUnicode(const char *zFilename){\n  int nByte;\n  LPWSTR zMbcsFilename;\n  int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP;\n\n  nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, NULL,\n                                0)*sizeof(WCHAR);\n  if( nByte==0 ){\n    return 0;\n  }\n  zMbcsFilename = sqlite3MallocZero( nByte*sizeof(zMbcsFilename[0]) );\n  if( zMbcsFilename==0 ){\n    return 0;\n  }\n  nByte = osMultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename,\n                                nByte);\n  if( nByte==0 ){\n    sqlite3_free(zMbcsFilename);\n    zMbcsFilename = 0;\n  }\n  return zMbcsFilename;\n}\n\n/*\n** Convert Microsoft Unicode to multi-byte character string, based on the\n** user's ANSI codepage.\n**\n** Space to hold the returned string is obtained from\n** sqlite3_malloc().\n*/\nstatic char *unicodeToMbcs(LPCWSTR zWideFilename){\n  int nByte;\n  char *zFilename;\n  int codepage = osAreFileApisANSI() ? CP_ACP : CP_OEMCP;\n\n  nByte = osWideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zFilename = sqlite3MallocZero( nByte );\n  if( zFilename==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename,\n                                nByte, 0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zFilename);\n    zFilename = 0;\n  }\n  return zFilename;\n}\n\n/*\n** Convert multibyte character string to UTF-8.  Space to hold the\n** returned string is obtained from sqlite3_malloc().\n*/\nSQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){\n  char *zFilenameUtf8;\n  LPWSTR zTmpWide;\n\n  zTmpWide = mbcsToUnicode(zFilename);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zFilenameUtf8 = unicodeToUtf8(zTmpWide);\n  sqlite3_free(zTmpWide);\n  return zFilenameUtf8;\n}\n\n/*\n** Convert UTF-8 to multibyte character string.  Space to hold the \n** returned string is obtained from sqlite3_malloc().\n*/\nSQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){\n  char *zFilenameMbcs;\n  LPWSTR zTmpWide;\n\n  zTmpWide = utf8ToUnicode(zFilename);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zFilenameMbcs = unicodeToMbcs(zTmpWide);\n  sqlite3_free(zTmpWide);\n  return zFilenameMbcs;\n}\n\n/*\n** This function sets the data directory or the temporary directory based on\n** the provided arguments.  The type argument must be 1 in order to set the\n** data directory or 2 in order to set the temporary directory.  The zValue\n** argument is the name of the directory to use.  The return value will be\n** SQLITE_OK if successful.\n*/\nSQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){\n  char **ppDirectory = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_data_directory;\n  }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_temp_directory;\n  }\n  assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE\n          || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n  );\n  assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );\n  if( ppDirectory ){\n    char *zValueUtf8 = 0;\n    if( zValue && zValue[0] ){\n      zValueUtf8 = unicodeToUtf8(zValue);\n      if ( zValueUtf8==0 ){\n        return SQLITE_NOMEM;\n      }\n    }\n    sqlite3_free(*ppDirectory);\n    *ppDirectory = zValueUtf8;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** The return value of getLastErrorMsg\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated).\n*/\nstatic int getLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){\n  /* FormatMessage returns 0 on failure.  Otherwise it\n  ** returns the number of TCHARs written to the output\n  ** buffer, excluding the terminating null char.\n  */\n  DWORD dwLen = 0;\n  char *zOut = 0;\n\n  if( isNT() ){\n#if SQLITE_OS_WINRT\n    WCHAR zTempWide[MAX_PATH+1]; /* NOTE: Somewhat arbitrary. */\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             zTempWide,\n                             MAX_PATH,\n                             0);\n#else\n    LPWSTR zTempWide = NULL;\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPWSTR) &zTempWide,\n                             0,\n                             0);\n#endif\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = unicodeToUtf8(zTempWide);\n      sqlite3EndBenignMalloc();\n#if !SQLITE_OS_WINRT\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTempWide);\n#endif\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp = NULL;\n    dwLen = osFormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPSTR) &zTemp,\n                             0,\n                             0);\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = sqlite3_win32_mbcs_to_utf8(zTemp);\n      sqlite3EndBenignMalloc();\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTemp);\n    }\n  }\n#endif\n  if( 0 == dwLen ){\n    sqlite3_snprintf(nBuf, zBuf, \"OsError 0x%lx (%lu)\", lastErrno, lastErrno);\n  }else{\n    /* copy a maximum of nBuf chars to output buffer */\n    sqlite3_snprintf(nBuf, zBuf, \"%s\", zOut);\n    /* free the UTF8 buffer */\n    sqlite3_free(zOut);\n  }\n  return 0;\n}\n\n/*\n**\n** This function - winLogErrorAtLine() - is only ever called via the macro\n** winLogError().\n**\n** This routine is invoked after an error occurs in an OS function.\n** It logs a message using sqlite3_log() containing the current value of\n** error code and, if possible, the human-readable equivalent from \n** FormatMessage.\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). \n** The two subsequent arguments should be the name of the OS function that\n** failed and the associated file-system path, if any.\n*/\n#define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)\nstatic int winLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  DWORD lastErrno,                /* Win32 last error */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char zMsg[500];                 /* Human readable error text */\n  int i;                          /* Loop counter */\n\n  zMsg[0] = 0;\n  getLastErrorMsg(lastErrno, sizeof(zMsg), zMsg);\n  assert( errcode!=SQLITE_OK );\n  if( zPath==0 ) zPath = \"\";\n  for(i=0; zMsg[i] && zMsg[i]!='\\r' && zMsg[i]!='\\n'; i++){}\n  zMsg[i] = 0;\n  sqlite3_log(errcode,\n      \"os_win.c:%d: (%lu) %s(%s) - %s\",\n      iLine, lastErrno, zFunc, zPath, zMsg\n  );\n\n  return errcode;\n}\n\n/*\n** The number of times that a ReadFile(), WriteFile(), and DeleteFile()\n** will be retried following a locking error - probably caused by \n** antivirus software.  Also the initial delay before the first retry.\n** The delay increases linearly with each retry.\n*/\n#ifndef SQLITE_WIN32_IOERR_RETRY\n# define SQLITE_WIN32_IOERR_RETRY 10\n#endif\n#ifndef SQLITE_WIN32_IOERR_RETRY_DELAY\n# define SQLITE_WIN32_IOERR_RETRY_DELAY 25\n#endif\nstatic int win32IoerrRetry = SQLITE_WIN32_IOERR_RETRY;\nstatic int win32IoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY;\n\n/*\n** If a ReadFile() or WriteFile() error occurs, invoke this routine\n** to see if it should be retried.  Return TRUE to retry.  Return FALSE\n** to give up with an error.\n*/\nstatic int retryIoerr(int *pnRetry, DWORD *pError){\n  DWORD e = osGetLastError();\n  if( *pnRetry>=win32IoerrRetry ){\n    if( pError ){\n      *pError = e;\n    }\n    return 0;\n  }\n  if( e==ERROR_ACCESS_DENIED ||\n      e==ERROR_LOCK_VIOLATION ||\n      e==ERROR_SHARING_VIOLATION ){\n    sqlite3_win32_sleep(win32IoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n  if( pError ){\n    *pError = e;\n  }\n  return 0;\n}\n\n/*\n** Log a I/O error retry episode.\n*/\nstatic void logIoerr(int nRetry){\n  if( nRetry ){\n    sqlite3_log(SQLITE_IOERR, \n      \"delayed %dms for lock/sharing conflict\",\n      win32IoerrRetryDelay*nRetry*(nRetry+1)/2\n    );\n  }\n}\n\n#if SQLITE_OS_WINCE\n/*************************************************************************\n** This section contains code for WinCE only.\n*/\n#if !defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.  So\n** create a substitute.\n*/\n/* #include <time.h> */\nstruct tm *__cdecl localtime(const time_t *t)\n{\n  static struct tm y;\n  FILETIME uTm, lTm;\n  SYSTEMTIME pTm;\n  sqlite3_int64 t64;\n  t64 = *t;\n  t64 = (t64 + 11644473600)*10000000;\n  uTm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);\n  uTm.dwHighDateTime= (DWORD)(t64 >> 32);\n  osFileTimeToLocalFileTime(&uTm,&lTm);\n  osFileTimeToSystemTime(&lTm,&pTm);\n  y.tm_year = pTm.wYear - 1900;\n  y.tm_mon = pTm.wMonth - 1;\n  y.tm_wday = pTm.wDayOfWeek;\n  y.tm_mday = pTm.wDay;\n  y.tm_hour = pTm.wHour;\n  y.tm_min = pTm.wMinute;\n  y.tm_sec = pTm.wSecond;\n  return &y;\n}\n#endif\n\n#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]\n\n/*\n** Acquire a lock on the handle h\n*/\nstatic void winceMutexAcquire(HANDLE h){\n   DWORD dwErr;\n   do {\n     dwErr = osWaitForSingleObject(h, INFINITE);\n   } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED);\n}\n/*\n** Release a lock acquired by winceMutexAcquire()\n*/\n#define winceMutexRelease(h) ReleaseMutex(h)\n\n/*\n** Create the mutex and shared memory used for locking in the file\n** descriptor pFile\n*/\nstatic int winceCreateLock(const char *zFilename, winFile *pFile){\n  LPWSTR zTok;\n  LPWSTR zName;\n  DWORD lastErrno;\n  BOOL bLogged = FALSE;\n  BOOL bInit = TRUE;\n\n  zName = utf8ToUnicode(zFilename);\n  if( zName==0 ){\n    /* out of memory */\n    return SQLITE_IOERR_NOMEM;\n  }\n\n  /* Initialize the local lockdata */\n  memset(&pFile->local, 0, sizeof(pFile->local));\n\n  /* Replace the backslashes from the filename and lowercase it\n  ** to derive a mutex name. */\n  zTok = osCharLowerW(zName);\n  for (;*zTok;zTok++){\n    if (*zTok == '\\\\') *zTok = '_';\n  }\n\n  /* Create/open the named mutex */\n  pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);\n  if (!pFile->hMutex){\n    pFile->lastErrno = osGetLastError();\n    winLogError(SQLITE_IOERR, pFile->lastErrno,\n                \"winceCreateLock1\", zFilename);\n    sqlite3_free(zName);\n    return SQLITE_IOERR;\n  }\n\n  /* Acquire the mutex before continuing */\n  winceMutexAcquire(pFile->hMutex);\n  \n  /* Since the names of named mutexes, semaphores, file mappings etc are \n  ** case-sensitive, take advantage of that by uppercasing the mutex name\n  ** and using that as the shared filemapping name.\n  */\n  osCharUpperW(zName);\n  pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,\n                                        PAGE_READWRITE, 0, sizeof(winceLock),\n                                        zName);  \n\n  /* Set a flag that indicates we're the first to create the memory so it \n  ** must be zero-initialized */\n  lastErrno = osGetLastError();\n  if (lastErrno == ERROR_ALREADY_EXISTS){\n    bInit = FALSE;\n  }\n\n  sqlite3_free(zName);\n\n  /* If we succeeded in making the shared memory handle, map it. */\n  if( pFile->hShared ){\n    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared, \n             FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));\n    /* If mapping failed, close the shared memory handle and erase it */\n    if( !pFile->shared ){\n      pFile->lastErrno = osGetLastError();\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock2\", zFilename);\n      bLogged = TRUE;\n      osCloseHandle(pFile->hShared);\n      pFile->hShared = NULL;\n    }\n  }\n\n  /* If shared memory could not be created, then close the mutex and fail */\n  if( pFile->hShared==NULL ){\n    if( !bLogged ){\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock3\", zFilename);\n      bLogged = TRUE;\n    }\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n    return SQLITE_IOERR;\n  }\n  \n  /* Initialize the shared memory if we're supposed to */\n  if( bInit ){\n    memset(pFile->shared, 0, sizeof(winceLock));\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return SQLITE_OK;\n}\n\n/*\n** Destroy the part of winFile that deals with wince locks\n*/\nstatic void winceDestroyLock(winFile *pFile){\n  if (pFile->hMutex){\n    /* Acquire the mutex */\n    winceMutexAcquire(pFile->hMutex);\n\n    /* The following blocks should probably assert in debug mode, but they\n       are to cleanup in case any locks remained open */\n    if (pFile->local.nReaders){\n      pFile->shared->nReaders --;\n    }\n    if (pFile->local.bReserved){\n      pFile->shared->bReserved = FALSE;\n    }\n    if (pFile->local.bPending){\n      pFile->shared->bPending = FALSE;\n    }\n    if (pFile->local.bExclusive){\n      pFile->shared->bExclusive = FALSE;\n    }\n\n    /* De-reference and close our copy of the shared memory handle */\n    osUnmapViewOfFile(pFile->shared);\n    osCloseHandle(pFile->hShared);\n\n    /* Done with the mutex */\n    winceMutexRelease(pFile->hMutex);    \n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n  }\n}\n\n/* \n** An implementation of the LockFile() API of Windows for CE\n*/\nstatic BOOL winceLockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToLockLow,\n  DWORD nNumberOfBytesToLockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToLockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Wanting an exclusive lock? */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST\n       && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){\n    if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){\n       pFile->shared->bExclusive = TRUE;\n       pFile->local.bExclusive = TRUE;\n       bReturn = TRUE;\n    }\n  }\n\n  /* Want a read-only lock? */\n  else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&\n           nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bExclusive == 0){\n      pFile->local.nReaders ++;\n      if (pFile->local.nReaders == 1){\n        pFile->shared->nReaders ++;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a pending lock? */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    /* If no pending lock has been acquired, then acquire it */\n    if (pFile->shared->bPending == 0) {\n      pFile->shared->bPending = TRUE;\n      pFile->local.bPending = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a reserved lock? */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bReserved == 0) {\n      pFile->shared->bReserved = TRUE;\n      pFile->local.bReserved = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n\n/*\n** An implementation of the UnlockFile API of Windows for CE\n*/\nstatic BOOL winceUnlockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToUnlockLow,\n  DWORD nNumberOfBytesToUnlockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToUnlockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Releasing a reader lock or an exclusive lock */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST){\n    /* Did we have an exclusive lock? */\n    if (pFile->local.bExclusive){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);\n      pFile->local.bExclusive = FALSE;\n      pFile->shared->bExclusive = FALSE;\n      bReturn = TRUE;\n    }\n\n    /* Did we just have a reader lock? */\n    else if (pFile->local.nReaders){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE\n             || nNumberOfBytesToUnlockLow == 1);\n      pFile->local.nReaders --;\n      if (pFile->local.nReaders == 0)\n      {\n        pFile->shared->nReaders --;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Releasing a pending lock */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bPending){\n      pFile->local.bPending = FALSE;\n      pFile->shared->bPending = FALSE;\n      bReturn = TRUE;\n    }\n  }\n  /* Releasing a reserved lock */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bReserved) {\n      pFile->local.bReserved = FALSE;\n      pFile->shared->bReserved = FALSE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n/*\n** End of the special code for wince\n*****************************************************************************/\n#endif /* SQLITE_OS_WINCE */\n\n/*\n** Lock a file region.\n*/\nstatic BOOL winLockFile(\n  LPHANDLE phFile,\n  DWORD flags,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API LockFile.\n  */\n  return winceLockFile(phFile, offsetLow, offsetHigh,\n                       numBytesLow, numBytesHigh);\n#else\n  if( isNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osLockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                      numBytesHigh);\n  }\n#endif\n}\n\n/*\n** Unlock a file region.\n */\nstatic BOOL winUnlockFile(\n  LPHANDLE phFile,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API UnlockFile.\n  */\n  return winceUnlockFile(phFile, offsetLow, offsetHigh,\n                         numBytesLow, numBytesHigh);\n#else\n  if( isNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osUnlockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                        numBytesHigh);\n  }\n#endif\n}\n\n/*****************************************************************************\n** The next group of routines implement the I/O methods specified\n** by the sqlite3_io_methods object.\n******************************************************************************/\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_SET_FILE_POINTER\n# define INVALID_SET_FILE_POINTER ((DWORD)-1)\n#endif\n\n/*\n** Move the current position of the file handle passed as the first \n** argument to offset iOffset within the file. If successful, return 0. \n** Otherwise, set pFile->lastErrno and return non-zero.\n*/\nstatic int seekWinFile(winFile *pFile, sqlite3_int64 iOffset){\n#if !SQLITE_OS_WINRT\n  LONG upperBits;                 /* Most sig. 32 bits of new offset */\n  LONG lowerBits;                 /* Least sig. 32 bits of new offset */\n  DWORD dwRet;                    /* Value returned by SetFilePointer() */\n  DWORD lastErrno;                /* Value returned by GetLastError() */\n\n  OSTRACE((\"SEEK file=%p, offset=%lld\\n\", pFile->h, iOffset));\n\n  upperBits = (LONG)((iOffset>>32) & 0x7fffffff);\n  lowerBits = (LONG)(iOffset & 0xffffffff);\n\n  /* API oddity: If successful, SetFilePointer() returns a dword \n  ** containing the lower 32-bits of the new file-offset. Or, if it fails,\n  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN, \n  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine \n  ** whether an error has actually occurred, it is also necessary to call \n  ** GetLastError().\n  */\n  dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);\n\n  if( (dwRet==INVALID_SET_FILE_POINTER\n      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n             \"seekWinFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#else\n  /*\n  ** Same as above, except that this implementation works for WinRT.\n  */\n\n  LARGE_INTEGER x;                /* The new offset */\n  BOOL bRet;                      /* Value returned by SetFilePointerEx() */\n\n  x.QuadPart = iOffset;\n  bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);\n\n  if(!bRet){\n    pFile->lastErrno = osGetLastError();\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n             \"seekWinFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#endif\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* Forward references to VFS methods */\nstatic int winUnmapfile(winFile*);\n#endif\n\n/*\n** Close a file.\n**\n** It is reported that an attempt to close a handle might sometimes\n** fail.  This is a very unreasonable result, but Windows is notorious\n** for being unreasonable so I do not doubt that it might happen.  If\n** the close fails, we pause for 100 milliseconds and try again.  As\n** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before\n** giving up and returning an error.\n*/\n#define MX_CLOSE_ATTEMPT 3\nstatic int winClose(sqlite3_file *id){\n  int rc, cnt = 0;\n  winFile *pFile = (winFile*)id;\n\n  assert( id!=0 );\n#ifndef SQLITE_OMIT_WAL\n  assert( pFile->pShm==0 );\n#endif\n  assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );\n  OSTRACE((\"CLOSE file=%p\\n\", pFile->h));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  rc = winUnmapfile(pFile);\n  if( rc!=SQLITE_OK ) return rc;\n#endif\n\n  do{\n    rc = osCloseHandle(pFile->h);\n    /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */\n  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );\n#if SQLITE_OS_WINCE\n#define WINCE_DELETION_ATTEMPTS 3\n  winceDestroyLock(pFile);\n  if( pFile->zDeleteOnClose ){\n    int cnt = 0;\n    while(\n           osDeleteFileW(pFile->zDeleteOnClose)==0\n        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff \n        && cnt++ < WINCE_DELETION_ATTEMPTS\n    ){\n       sqlite3_win32_sleep(100);  /* Wait a little before trying again */\n    }\n    sqlite3_free(pFile->zDeleteOnClose);\n  }\n#endif\n  if( rc ){\n    pFile->h = NULL;\n  }\n  OpenCounter(-1);\n  OSTRACE((\"CLOSE file=%p, rc=%s\\n\", pFile->h, rc ? \"ok\" : \"failed\"));\n  return rc ? SQLITE_OK\n            : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),\n                          \"winClose\", pFile->zPath);\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int winRead(\n  sqlite3_file *id,          /* File to read from */\n  void *pBuf,                /* Write content into this buffer */\n  int amt,                   /* Number of bytes to read */\n  sqlite3_int64 offset       /* Begin reading at this offset */\n){\n#if !SQLITE_OS_WINCE\n  OVERLAPPED overlapped;          /* The offset for ReadFile. */\n#endif\n  winFile *pFile = (winFile*)id;  /* file handle */\n  DWORD nRead;                    /* Number of bytes actually read from file */\n  int nRetry = 0;                 /* Number of retrys */\n\n  assert( id!=0 );\n  assert( amt>0 );\n  assert( offset>=0 );\n  SimulateIOError(return SQLITE_IOERR_READ);\n  OSTRACE((\"READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\\n\",\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      OSTRACE((\"READ-MMAP file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE\n  if( seekWinFile(pFile, offset) ){\n    OSTRACE((\"READ file=%p, rc=SQLITE_FULL\\n\", pFile->h));\n    return SQLITE_FULL;\n  }\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){\n#else\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(offset & 0xffffffff);\n  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&\n         osGetLastError()!=ERROR_HANDLE_EOF ){\n#endif\n    DWORD lastErrno;\n    if( retryIoerr(&nRetry, &lastErrno) ) continue;\n    pFile->lastErrno = lastErrno;\n    OSTRACE((\"READ file=%p, rc=SQLITE_IOERR_READ\\n\", pFile->h));\n    return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,\n             \"winRead\", pFile->zPath);\n  }\n  logIoerr(nRetry);\n  if( nRead<(DWORD)amt ){\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[nRead], 0, amt-nRead);\n    OSTRACE((\"READ file=%p, rc=SQLITE_IOERR_SHORT_READ\\n\", pFile->h));\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  OSTRACE((\"READ file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int winWrite(\n  sqlite3_file *id,               /* File to write into */\n  const void *pBuf,               /* The bytes to be written */\n  int amt,                        /* Number of bytes to write */\n  sqlite3_int64 offset            /* Offset into the file to begin writing at */\n){\n  int rc = 0;                     /* True if error has occurred, else false */\n  winFile *pFile = (winFile*)id;  /* File handle */\n  int nRetry = 0;                 /* Number of retries */\n\n  assert( amt>0 );\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_WRITE);\n  SimulateDiskfullError(return SQLITE_FULL);\n\n  OSTRACE((\"WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\\n\",\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      OSTRACE((\"WRITE-MMAP file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE\n  rc = seekWinFile(pFile, offset);\n  if( rc==0 ){\n#else\n  {\n#endif\n#if !SQLITE_OS_WINCE\n    OVERLAPPED overlapped;        /* The offset for WriteFile. */\n#endif\n    u8 *aRem = (u8 *)pBuf;        /* Data yet to be written */\n    int nRem = amt;               /* Number of bytes yet to be written */\n    DWORD nWrite;                 /* Bytes written by each WriteFile() call */\n    DWORD lastErrno = NO_ERROR;   /* Value returned by GetLastError() */\n\n#if !SQLITE_OS_WINCE\n    memset(&overlapped, 0, sizeof(OVERLAPPED));\n    overlapped.Offset = (LONG)(offset & 0xffffffff);\n    overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n\n    while( nRem>0 ){\n#if SQLITE_OS_WINCE\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){\n#else\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){\n#endif\n        if( retryIoerr(&nRetry, &lastErrno) ) continue;\n        break;\n      }\n      assert( nWrite==0 || nWrite<=(DWORD)nRem );\n      if( nWrite==0 || nWrite>(DWORD)nRem ){\n        lastErrno = osGetLastError();\n        break;\n      }\n#if !SQLITE_OS_WINCE\n      offset += nWrite;\n      overlapped.Offset = (LONG)(offset & 0xffffffff);\n      overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n      aRem += nWrite;\n      nRem -= nWrite;\n    }\n    if( nRem>0 ){\n      pFile->lastErrno = lastErrno;\n      rc = 1;\n    }\n  }\n\n  if( rc ){\n    if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )\n       || ( pFile->lastErrno==ERROR_DISK_FULL )){\n      OSTRACE((\"WRITE file=%p, rc=SQLITE_FULL\\n\", pFile->h));\n      return SQLITE_FULL;\n    }\n    OSTRACE((\"WRITE file=%p, rc=SQLITE_IOERR_WRITE\\n\", pFile->h));\n    return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,\n             \"winWrite\", pFile->zPath);\n  }else{\n    logIoerr(nRetry);\n  }\n  OSTRACE((\"WRITE file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){\n  winFile *pFile = (winFile*)id;  /* File handle object */\n  int rc = SQLITE_OK;             /* Return code for this function */\n  DWORD lastErrno;\n\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_TRUNCATE);\n  OSTRACE((\"TRUNCATE file=%p, size=%lld, lock=%d\\n\",\n           pFile->h, nByte, pFile->locktype));\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */\n  if( seekWinFile(pFile, nByte) ){\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate1\", pFile->zPath);\n  }else if( 0==osSetEndOfFile(pFile->h) &&\n            ((lastErrno = osGetLastError())!=ERROR_USER_MAPPED_FILE) ){\n    pFile->lastErrno = lastErrno;\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate2\", pFile->zPath);\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* If the file was truncated to a size smaller than the currently\n  ** mapped region, reduce the effective mapping size as well. SQLite will\n  ** use read() and write() to access data beyond this point from now on.\n  */\n  if( pFile->pMapRegion && nByte<pFile->mmapSize ){\n    pFile->mmapSize = nByte;\n  }\n#endif\n\n  OSTRACE((\"TRUNCATE file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occuring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n*/\nstatic int winSync(sqlite3_file *id, int flags){\n#ifndef SQLITE_NO_SYNC\n  /*\n  ** Used only when SQLITE_NO_SYNC is not defined.\n   */\n  BOOL rc;\n#endif\n#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \\\n    (defined(SQLITE_TEST) && defined(SQLITE_DEBUG))\n  /*\n  ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or\n  ** OSTRACE() macros.\n   */\n  winFile *pFile = (winFile*)id;\n#else\n  UNUSED_PARAMETER(id);\n#endif\n\n  assert( pFile );\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  OSTRACE((\"SYNC file=%p, flags=%x, lock=%d\\n\",\n           pFile->h, flags, pFile->locktype));\n\n#ifndef SQLITE_TEST\n  UNUSED_PARAMETER(flags);\n#else\n  if( (flags&0x0F)==SQLITE_SYNC_FULL ){\n    sqlite3_fullsync_count++;\n  }\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op\n  */\n#ifdef SQLITE_NO_SYNC\n  return SQLITE_OK;\n#else\n  rc = osFlushFileBuffers(pFile->h);\n  SimulateIOError( rc=FALSE );\n  if( rc ){\n    OSTRACE((\"SYNC file=%p, rc=SQLITE_OK\\n\", pFile->h));\n    return SQLITE_OK;\n  }else{\n    pFile->lastErrno = osGetLastError();\n    OSTRACE((\"SYNC file=%p, rc=SQLITE_IOERR_FSYNC\\n\", pFile->h));\n    return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,\n             \"winSync\", pFile->zPath);\n  }\n#endif\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n\n  assert( id!=0 );\n  assert( pSize!=0 );\n  SimulateIOError(return SQLITE_IOERR_FSTAT);\n  OSTRACE((\"SIZE file=%p, pSize=%p\\n\", pFile->h, pSize));\n\n#if SQLITE_OS_WINRT\n  {\n    FILE_STANDARD_INFO info;\n    if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,\n                                     &info, sizeof(info)) ){\n      *pSize = info.EndOfFile.QuadPart;\n    }else{\n      pFile->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#else\n  {\n    DWORD upperBits;\n    DWORD lowerBits;\n    DWORD lastErrno;\n\n    lowerBits = osGetFileSize(pFile->h, &upperBits);\n    *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;\n    if(   (lowerBits == INVALID_FILE_SIZE)\n       && ((lastErrno = osGetLastError())!=NO_ERROR) ){\n      pFile->lastErrno = lastErrno;\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n             \"winFileSize\", pFile->zPath);\n    }\n  }\n#endif\n  OSTRACE((\"SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\\n\",\n           pFile->h, pSize, *pSize, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.\n*/\n#ifndef LOCKFILE_FAIL_IMMEDIATELY\n# define LOCKFILE_FAIL_IMMEDIATELY 1\n#endif\n\n#ifndef LOCKFILE_EXCLUSIVE_LOCK\n# define LOCKFILE_EXCLUSIVE_LOCK 2\n#endif\n\n/*\n** Historically, SQLite has used both the LockFile and LockFileEx functions.\n** When the LockFile function was used, it was always expected to fail\n** immediately if the lock could not be obtained.  Also, it always expected to\n** obtain an exclusive lock.  These flags are used with the LockFileEx function\n** and reflect those expectations; therefore, they should not be changed.\n*/\n#ifndef SQLITE_LOCKFILE_FLAGS\n# define SQLITE_LOCKFILE_FLAGS   (LOCKFILE_FAIL_IMMEDIATELY | \\\n                                  LOCKFILE_EXCLUSIVE_LOCK)\n#endif\n\n/*\n** Currently, SQLite never calls the LockFileEx function without wanting the\n** call to fail immediately if the lock cannot be obtained.\n*/\n#ifndef SQLITE_LOCKFILEEX_FLAGS\n# define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY)\n#endif\n\n/*\n** Acquire a reader lock.\n** Different API routines are called depending on whether or not this\n** is Win9x or WinNT.\n*/\nstatic int getReadLock(winFile *pFile){\n  int res;\n  OSTRACE((\"READ-LOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( isNT() ){\n#if SQLITE_OS_WINCE\n    /*\n    ** NOTE: Windows CE is handled differently here due its lack of the Win32\n    **       API LockFileEx.\n    */\n    res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);\n#else\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    int lk;\n    sqlite3_randomness(sizeof(lk), &lk);\n    pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1));\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                      SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res == 0 ){\n    pFile->lastErrno = osGetLastError();\n    /* No need to log a failure to lock */\n  }\n  OSTRACE((\"READ-LOCK file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(res)));\n  return res;\n}\n\n/*\n** Undo a readlock\n*/\nstatic int unlockReadLock(winFile *pFile){\n  int res;\n  DWORD lastErrno;\n  OSTRACE((\"READ-UNLOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( isNT() ){\n    res = winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,\n             \"unlockReadLock\", pFile->zPath);\n  }\n  OSTRACE((\"READ-UNLOCK file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(res)));\n  return res;\n}\n\n/*\n** Lock the file with the lock specified by parameter locktype - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  The winUnlock() routine\n** erases all locks at once and returns us immediately to locking level 0.\n** It is not possible to lower the locking level one step at a time.  You\n** must go straight to locking level 0.\n*/\nstatic int winLock(sqlite3_file *id, int locktype){\n  int rc = SQLITE_OK;    /* Return code from subroutines */\n  int res = 1;           /* Result of a Windows lock call */\n  int newLocktype;       /* Set pFile->locktype to this value before exiting */\n  int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */\n  winFile *pFile = (winFile*)id;\n  DWORD lastErrno = NO_ERROR;\n\n  assert( id!=0 );\n  OSTRACE((\"LOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** OsFile, do nothing. Don't use the end_lock: exit path, as\n  ** sqlite3OsEnterMutex() hasn't been called yet.\n  */\n  if( pFile->locktype>=locktype ){\n    OSTRACE((\"LOCK-HELD file=%p, rc=SQLITE_OK\\n\", pFile->h));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct\n  */\n  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );\n  assert( locktype!=PENDING_LOCK );\n  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );\n\n  /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or\n  ** a SHARED lock.  If we are acquiring a SHARED lock, the acquisition of\n  ** the PENDING_LOCK byte is temporary.\n  */\n  newLocktype = pFile->locktype;\n  if(   (pFile->locktype==NO_LOCK)\n     || (   (locktype==EXCLUSIVE_LOCK)\n         && (pFile->locktype==RESERVED_LOCK))\n  ){\n    int cnt = 3;\n    while( cnt-->0 && (res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                                         PENDING_BYTE, 0, 1, 0))==0 ){\n      /* Try 3 times to get the pending lock.  This is needed to work\n      ** around problems caused by indexing and/or anti-virus software on\n      ** Windows systems.\n      ** If you are using this code as a model for alternative VFSes, do not\n      ** copy this retry logic.  It is a hack intended for Windows only.\n      */\n      OSTRACE((\"LOCK-PENDING-FAIL file=%p, count=%d, rc=%s\\n\",\n               pFile->h, cnt, sqlite3ErrName(res)));\n      if( cnt ) sqlite3_win32_sleep(1);\n    }\n    gotPendingLock = res;\n    if( !res ){\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a shared lock\n  */\n  if( locktype==SHARED_LOCK && res ){\n    assert( pFile->locktype==NO_LOCK );\n    res = getReadLock(pFile);\n    if( res ){\n      newLocktype = SHARED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a RESERVED lock\n  */\n  if( locktype==RESERVED_LOCK && res ){\n    assert( pFile->locktype==SHARED_LOCK );\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);\n    if( res ){\n      newLocktype = RESERVED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a PENDING lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    newLocktype = PENDING_LOCK;\n    gotPendingLock = 0;\n  }\n\n  /* Acquire an EXCLUSIVE lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    assert( pFile->locktype>=SHARED_LOCK );\n    res = unlockReadLock(pFile);\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n    if( res ){\n      newLocktype = EXCLUSIVE_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n      getReadLock(pFile);\n    }\n  }\n\n  /* If we are holding a PENDING lock that ought to be released, then\n  ** release it now.\n  */\n  if( gotPendingLock && locktype==SHARED_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n\n  /* Update the state of the lock has held in the file descriptor then\n  ** return the appropriate result code.\n  */\n  if( res ){\n    rc = SQLITE_OK;\n  }else{\n    OSTRACE((\"LOCK-FAIL file=%p, wanted=%d, got=%d\\n\",\n             pFile->h, locktype, newLocktype));\n    pFile->lastErrno = lastErrno;\n    rc = SQLITE_BUSY;\n  }\n  pFile->locktype = (u8)newLocktype;\n  OSTRACE((\"LOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, return\n** non-zero, otherwise zero.\n*/\nstatic int winCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc;\n  winFile *pFile = (winFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p\\n\", pFile->h, pResOut));\n\n  assert( id!=0 );\n  if( pFile->locktype>=RESERVED_LOCK ){\n    rc = 1;\n    OSTRACE((\"TEST-WR-LOCK file=%p, rc=%d (local)\\n\", pFile->h, rc));\n  }else{\n    rc = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE, 0, 1, 0);\n    if( rc ){\n      winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n    }\n    rc = !rc;\n    OSTRACE((\"TEST-WR-LOCK file=%p, rc=%d (remote)\\n\", pFile->h, rc));\n  }\n  *pResOut = rc;\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           pFile->h, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Lower the locking level on file descriptor id to locktype.  locktype\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** It is not possible for this routine to fail if the second argument\n** is NO_LOCK.  If the second argument is SHARED_LOCK then this routine\n** might return SQLITE_IOERR;\n*/\nstatic int winUnlock(sqlite3_file *id, int locktype){\n  int type;\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n  assert( pFile!=0 );\n  assert( locktype<=SHARED_LOCK );\n  OSTRACE((\"UNLOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n  type = pFile->locktype;\n  if( type>=EXCLUSIVE_LOCK ){\n    winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n    if( locktype==SHARED_LOCK && !getReadLock(pFile) ){\n      /* This should never happen.  We should always be able to\n      ** reacquire the read lock */\n      rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),\n               \"winUnlock\", pFile->zPath);\n    }\n  }\n  if( type>=RESERVED_LOCK ){\n    winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n  }\n  if( locktype==NO_LOCK && type>=SHARED_LOCK ){\n    unlockReadLock(pFile);\n  }\n  if( type>=PENDING_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n  pFile->locktype = (u8)locktype;\n  OSTRACE((\"UNLOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** If *pArg is inititially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void winModeBit(winFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward declaration */\nstatic int getTempname(int nBuf, char *zBuf);\n\n/*\n** Control and query of the open file handle.\n*/\nstatic int winFileControl(sqlite3_file *id, int op, void *pArg){\n  winFile *pFile = (winFile*)id;\n  OSTRACE((\"FCNTL file=%p, op=%d, pArg=%p\\n\", pFile->h, op, pArg));\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->locktype;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_LAST_ERRNO: {\n      *(int*)pArg = (int)pFile->lastErrno;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      if( pFile->szChunk>0 ){\n        sqlite3_int64 oldSz;\n        int rc = winFileSize(id, &oldSz);\n        if( rc==SQLITE_OK ){\n          sqlite3_int64 newSz = *(sqlite3_int64*)pArg;\n          if( newSz>oldSz ){\n            SimulateIOErrorBenign(1);\n            rc = winTruncate(id, newSz);\n            SimulateIOErrorBenign(0);\n          }\n        }\n        OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n        return rc;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      winModeBit(pFile, WINFILE_PSOW, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"win32\");\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_AV_RETRY: {\n      int *a = (int*)pArg;\n      if( a[0]>0 ){\n        win32IoerrRetry = a[0];\n      }else{\n        a[0] = win32IoerrRetry;\n      }\n      if( a[1]>0 ){\n        win32IoerrRetryDelay = a[1];\n      }else{\n        a[1] = win32IoerrRetryDelay;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = sqlite3MallocZero( pFile->pVfs->mxPathname );\n      if( zTFile ){\n        getTempname(pFile->pVfs->mxPathname, zTFile);\n        *(char**)pArg = zTFile;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 ) pFile->mmapSizeMax = newLimit;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n#endif\n  }\n  OSTRACE((\"FCNTL file=%p, rc=SQLITE_NOTFOUND\\n\", pFile->h));\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int winSectorSize(sqlite3_file *id){\n  (void)id;\n  return SQLITE_DEFAULT_SECTOR_SIZE;\n}\n\n/*\n** Return a vector of device characteristics.\n*/\nstatic int winDeviceCharacteristics(sqlite3_file *id){\n  winFile *p = (winFile*)id;\n  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n         ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);\n}\n\n/* \n** Windows will only let you create file view mappings\n** on allocation size granularity boundaries.\n** During sqlite3_os_init() we do a GetSystemInfo()\n** to get the granularity size.\n*/\nSYSTEM_INFO winSysInfo;\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the winLockInfo objects used by \n** this file, all of which may be shared by multiple threads.\n**\n** Function winShmMutexHeld() is used to assert() that the global mutex \n** is held when required. This function is only used as part of assert() \n** statements. e.g.\n**\n**   winShmEnterMutex()\n**     assert( winShmMutexHeld() );\n**   winShmLeaveMutex()\n*/\nstatic void winShmEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\nstatic void winShmLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n#ifdef SQLITE_DEBUG\nstatic int winShmMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n#endif\n\n/*\n** Object used to represent a single file opened and mmapped to provide\n** shared memory.  When multiple threads all reference the same\n** log-summary, each thread has its own winFile object, but they all\n** point to a single instance of this object.  In other words, each\n** log-summary is opened only once per process.\n**\n** winShmMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**      pNext \n**\n** The following fields are read-only after the object is created:\n** \n**      fid\n**      zFilename\n**\n** Either winShmNode.mutex must be held or winShmNode.nRef==0 and\n** winShmMutexHeld() is true when reading or writing any other field\n** in this structure.\n**\n*/\nstruct winShmNode {\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the file */\n  winFile hFile;             /* File handle from winOpen */\n\n  int szRegion;              /* Size of shared-memory regions */\n  int nRegion;               /* Size of array apRegion */\n  struct ShmRegion {\n    HANDLE hMap;             /* File handle from CreateFileMapping */\n    void *pMap;\n  } *aRegion;\n  DWORD lastErrno;           /* The Windows errno from the last I/O error */\n\n  int nRef;                  /* Number of winShm objects pointing to this */\n  winShm *pFirst;            /* All winShm objects pointing to this */\n  winShmNode *pNext;         /* Next in list of all winShmNode objects */\n#ifdef SQLITE_DEBUG\n  u8 nextShmId;              /* Next available winShm.id value */\n#endif\n};\n\n/*\n** A global array of all winShmNode objects.\n**\n** The winShmMutexHeld() must be true while reading or writing this list.\n*/\nstatic winShmNode *winShmNodeList = 0;\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    winShm.pShmNode\n**    winShm.id\n**\n** All other fields are read/write.  The winShm.pShmNode->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct winShm {\n  winShmNode *pShmNode;      /* The underlying winShmNode object */\n  winShm *pNext;             /* Next winShm with the same winShmNode */\n  u8 hasMutex;               /* True if holding the winShmNode mutex */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n#ifdef SQLITE_DEBUG\n  u8 id;                     /* Id of this connection with its winShmNode */\n#endif\n};\n\n/*\n** Constants used for locking\n*/\n#define WIN_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)        /* first lock byte */\n#define WIN_SHM_DMS    (WIN_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply advisory locks for all n bytes beginning at ofst.\n*/\n#define _SHM_UNLCK  1\n#define _SHM_RDLCK  2\n#define _SHM_WRLCK  3\nstatic int winShmSystemLock(\n  winShmNode *pFile,    /* Apply locks to this open shared-memory segment */\n  int lockType,         /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */\n  int ofst,             /* Offset to first byte to be locked/unlocked */\n  int nByte             /* Number of bytes to lock or unlock */\n){\n  int rc = 0;           /* Result code form Lock/UnlockFileEx() */\n\n  /* Access to the winShmNode object is serialized by the caller */\n  assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );\n\n  OSTRACE((\"SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\\n\",\n           pFile->hFile.h, lockType, ofst, nByte));\n\n  /* Release/Acquire the system-level lock */\n  if( lockType==_SHM_UNLCK ){\n    rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);\n  }else{\n    /* Initialize the locking parameters */\n    DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;\n    if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;\n    rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);\n  }\n  \n  if( rc!= 0 ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno =  osGetLastError();\n    rc = SQLITE_BUSY;\n  }\n\n  OSTRACE((\"SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\\n\",\n           pFile->hFile.h, (lockType == _SHM_UNLCK) ? \"winUnlockFile\" :\n           \"winLockFile\", pFile->lastErrno, sqlite3ErrName(rc)));\n\n  return rc;\n}\n\n/* Forward references to VFS methods */\nstatic int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);\nstatic int winDelete(sqlite3_vfs *,const char*,int);\n\n/*\n** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){\n  winShmNode **pp;\n  winShmNode *p;\n  BOOL bRc;\n  assert( winShmMutexHeld() );\n  OSTRACE((\"SHM-PURGE pid=%lu, deleteFlag=%d\\n\",\n           osGetCurrentProcessId(), deleteFlag));\n  pp = &winShmNodeList;\n  while( (p = *pp)!=0 ){\n    if( p->nRef==0 ){\n      int i;\n      if( p->mutex ) sqlite3_mutex_free(p->mutex);\n      for(i=0; i<p->nRegion; i++){\n        bRc = osUnmapViewOfFile(p->aRegion[i].pMap);\n        OSTRACE((\"SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        bRc = osCloseHandle(p->aRegion[i].hMap);\n        OSTRACE((\"SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n      }\n      if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){\n        SimulateIOErrorBenign(1);\n        winClose((sqlite3_file *)&p->hFile);\n        SimulateIOErrorBenign(0);\n      }\n      if( deleteFlag ){\n        SimulateIOErrorBenign(1);\n        sqlite3BeginBenignMalloc();\n        winDelete(pVfs, p->zFilename, 0);\n        sqlite3EndBenignMalloc();\n        SimulateIOErrorBenign(0);\n      }\n      *pp = p->pNext;\n      sqlite3_free(p->aRegion);\n      sqlite3_free(p);\n    }else{\n      pp = &p->pNext;\n    }\n  }\n}\n\n/*\n** Open the shared-memory area associated with database file pDbFd.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n*/\nstatic int winOpenSharedMemory(winFile *pDbFd){\n  struct winShm *p;                  /* The connection to be opened */\n  struct winShmNode *pShmNode = 0;   /* The underlying mmapped file */\n  int rc;                            /* Result code */\n  struct winShmNode *pNew;           /* Newly allocated winShmNode */\n  int nName;                         /* Size of zName in bytes */\n\n  assert( pDbFd->pShm==0 );    /* Not previously opened */\n\n  /* Allocate space for the new sqlite3_shm object.  Also speculatively\n  ** allocate space for a new winShmNode and filename.\n  */\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p==0 ) return SQLITE_IOERR_NOMEM;\n  nName = sqlite3Strlen30(pDbFd->zPath);\n  pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );\n  if( pNew==0 ){\n    sqlite3_free(p);\n    return SQLITE_IOERR_NOMEM;\n  }\n  pNew->zFilename = (char*)&pNew[1];\n  sqlite3_snprintf(nName+15, pNew->zFilename, \"%s-shm\", pDbFd->zPath);\n  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename); \n\n  /* Look to see if there is an existing winShmNode that can be used.\n  ** If no matching winShmNode currently exists, create a new one.\n  */\n  winShmEnterMutex();\n  for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){\n    /* TBD need to come up with better match here.  Perhaps\n    ** use FILE_ID_BOTH_DIR_INFO Structure.\n    */\n    if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;\n  }\n  if( pShmNode ){\n    sqlite3_free(pNew);\n  }else{\n    pShmNode = pNew;\n    pNew = 0;\n    ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE;\n    pShmNode->pNext = winShmNodeList;\n    winShmNodeList = pShmNode;\n\n    pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n    if( pShmNode->mutex==0 ){\n      rc = SQLITE_IOERR_NOMEM;\n      goto shm_open_err;\n    }\n\n    rc = winOpen(pDbFd->pVfs,\n                 pShmNode->zFilename,             /* Name of the file (UTF-8) */\n                 (sqlite3_file*)&pShmNode->hFile,  /* File handle here */\n                 SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,\n                 0);\n    if( SQLITE_OK!=rc ){\n      goto shm_open_err;\n    }\n\n    /* Check to see if another process is holding the dead-man switch.\n    ** If not, truncate the file to zero length. \n    */\n    if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),\n                 \"winOpenShm\", pDbFd->zPath);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);\n      rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);\n    }\n    if( rc ) goto shm_open_err;\n  }\n\n  /* Make the new connection a child of the winShmNode */\n  p->pShmNode = pShmNode;\n#ifdef SQLITE_DEBUG\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  winShmLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the winShmEnterMutex() mutex and the pointer from the\n  ** new (struct winShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex \n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);\n  winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  sqlite3_free(pNew);\n  winShmLeaveMutex();\n  return rc;\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying \n** storage if deleteFlag is true.\n*/\nstatic int winShmUnmap(\n  sqlite3_file *fd,          /* Database holding shared memory */\n  int deleteFlag             /* Delete after closing if true */\n){\n  winFile *pDbFd;       /* Database holding shared-memory */\n  winShm *p;            /* The connection to be closed */\n  winShmNode *pShmNode; /* The underlying shared-memory file */\n  winShm **pp;          /* For looping over sibling connections */\n\n  pDbFd = (winFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  winShmEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    winShmPurge(pDbFd->pVfs, deleteFlag);\n  }\n  winShmLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n*/\nstatic int winShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  winFile *pDbFd = (winFile*)fd;        /* Connection holding shared memory */\n  winShm *p = pDbFd->pShm;              /* The shared memory being locked */\n  winShm *pX;                           /* For looping over all siblings */\n  winShmNode *pShmNode = p->pShmNode;\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n\n  mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    } \n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n  \n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\\n\",\n           osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,\n           sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.  \n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void winShmBarrier(\n  sqlite3_file *fd          /* Database holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  /* MemoryBarrier(); // does not work -- do not know why not */\n  winShmEnterMutex();\n  winShmLeaveMutex();\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the \n** shared-memory associated with the database file fd. Shared-memory regions \n** are numbered starting from zero. Each shared-memory region is szRegion \n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the isWrite parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If \n** isWrite is non-zero and the requested shared-memory region has not yet \n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes \n** address space (if it is not already), *pp is set to point to the mapped \n** memory and SQLITE_OK returned.\n*/\nstatic int winShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int isWrite,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  winFile *pDbFd = (winFile*)fd;\n  winShm *p = pDbFd->pShm;\n  winShmNode *pShmNode;\n  int rc = SQLITE_OK;\n\n  if( !p ){\n    rc = winOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n    p = pDbFd->pShm;\n  }\n  pShmNode = p->pShmNode;\n\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n\n  if( pShmNode->nRegion<=iRegion ){\n    struct ShmRegion *apNew;           /* New aRegion[] array */\n    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */\n    sqlite3_int64 sz;                  /* Current size of wal-index file */\n\n    pShmNode->szRegion = szRegion;\n\n    /* The requested region is not mapped into this processes address space.\n    ** Check to see if it has been allocated (i.e. if the wal-index file is\n    ** large enough to contain the requested region).\n    */\n    rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);\n    if( rc!=SQLITE_OK ){\n      rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n               \"winShmMap1\", pDbFd->zPath);\n      goto shmpage_out;\n    }\n\n    if( sz<nByte ){\n      /* The requested memory region does not exist. If isWrite is set to\n      ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.\n      **\n      ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate\n      ** the requested memory region.\n      */\n      if( !isWrite ) goto shmpage_out;\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                 \"winShmMap2\", pDbFd->zPath);\n        goto shmpage_out;\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (struct ShmRegion *)sqlite3_realloc(\n        pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM;\n      goto shmpage_out;\n    }\n    pShmNode->aRegion = apNew;\n\n    while( pShmNode->nRegion<=iRegion ){\n      HANDLE hMap = NULL;         /* file-mapping handle */\n      void *pMap = 0;             /* Mapped memory region */\n     \n#if SQLITE_OS_WINRT\n      hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n      hMap = osCreateFileMappingW(pShmNode->hFile.h, \n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_ANSI)\n      hMap = osCreateFileMappingA(pShmNode->hFile.h, \n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#endif\n      OSTRACE((\"SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\\n\",\n               osGetCurrentProcessId(), pShmNode->nRegion, nByte,\n               hMap ? \"ok\" : \"failed\"));\n      if( hMap ){\n        int iOffset = pShmNode->nRegion*szRegion;\n        int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n#if SQLITE_OS_WINRT\n        pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#else\n        pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            0, iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#endif\n        OSTRACE((\"SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,\n                 szRegion, pMap ? \"ok\" : \"failed\"));\n      }\n      if( !pMap ){\n        pShmNode->lastErrno = osGetLastError();\n        rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,\n                 \"winShmMap3\", pDbFd->zPath);\n        if( hMap ) osCloseHandle(hMap);\n        goto shmpage_out;\n      }\n\n      pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;\n      pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;\n      pShmNode->nRegion++;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    int iOffset = iRegion*szRegion;\n    int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n    char *p = (char *)pShmNode->aRegion[iRegion].pMap;\n    *pp = (void *)&p[iOffsetShift];\n  }else{\n    *pp = 0;\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n#else\n# define winShmMap     0\n# define winShmLock    0\n# define winShmBarrier 0\n# define winShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/*\n** Cleans up the mapped region of the specified file, if any.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int winUnmapfile(winFile *pFile){\n  assert( pFile!=0 );\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, pMapRegion=%p, \"\n           \"mmapSize=%lld, mmapSizeActual=%lld, mmapSizeMax=%lld\\n\",\n           osGetCurrentProcessId(), pFile, pFile->hMap, pFile->pMapRegion,\n           pFile->mmapSize, pFile->mmapSizeActual, pFile->mmapSizeMax));\n  if( pFile->pMapRegion ){\n    if( !osUnmapViewOfFile(pFile->pMapRegion) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(), pFile,\n               pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmap1\", pFile->zPath);\n    }\n    pFile->pMapRegion = 0;\n    pFile->mmapSize = 0;\n    pFile->mmapSizeActual = 0;\n  }\n  if( pFile->hMap!=NULL ){\n    if( !osCloseHandle(pFile->hMap) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFile, pFile->hMap));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmap2\", pFile->zPath);\n    }\n    pFile->hMap = NULL;\n  }\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile));\n  return SQLITE_OK;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if \n** there already exists a mapping for this file, and there are still \n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of \n** the mapping to create. Otherwise, if nByte is less than zero, then the \n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured \n** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int winMapfile(winFile *pFd, sqlite3_int64 nByte){\n  sqlite3_int64 nMap = nByte;\n  int rc;\n\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, size=%lld\\n\",\n           osGetCurrentProcessId(), pFd, nByte));\n\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    rc = winFileSize((sqlite3_file*)pFd, &nMap);\n    if( rc ){\n      OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_IOERR_FSTAT\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_IOERR_FSTAT;\n    }\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n  nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);\n \n  if( nMap==0 && pFd->mmapSize>0 ){\n    winUnmapfile(pFd);\n  }\n  if( nMap!=pFd->mmapSize ){\n    void *pNew = 0;\n    DWORD protect = PAGE_READONLY;\n    DWORD flags = FILE_MAP_READ;\n\n    winUnmapfile(pFd);\n    if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){\n      protect = PAGE_READWRITE;\n      flags |= FILE_MAP_WRITE;\n    }\n#if SQLITE_OS_WINRT\n    pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#elif defined(SQLITE_WIN32_HAS_ANSI)\n    pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#endif\n    if( pFd->hMap==NULL ){\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_OK;\n    }\n    assert( (nMap % winSysInfo.dwPageSize)==0 );\n#if SQLITE_OS_WINRT\n    pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);\n#else\n    assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );\n    pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);\n#endif\n    if( pNew==NULL ){\n      osCloseHandle(pFd->hMap);\n      pFd->hMap = NULL;\n      pFd->lastErrno = osGetLastError();\n      winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                  \"winMapfile\", pFd->zPath);\n      OSTRACE((\"MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_OK;\n    }\n    pFd->pMapRegion = pNew;\n    pFd->mmapSize = nMap;\n    pFd->mmapSizeActual = nMap;\n  }\n\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFd));\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually \n** release the reference by calling winUnfetch().\n*/\nstatic int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, offset=%lld, amount=%d, pp=%p\\n\",\n           osGetCurrentProcessId(), fd, iOff, nAmt, pp));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = winMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ){\n        OSTRACE((\"FETCH pid=%lu, pFile=%p, rc=%s\\n\",\n                 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n        return rc;\n      }\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd, pp, *pp));\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a \n** reference obtained by an earlier call to winFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the winFetch() invocation. \n**\n** Or, if the third argument is NULL, then this function is being called \n** to inform the VFS layer that, according to POSIX, any existing mapping \n** may now be invalid and should be unmapped.\n*/\nstatic int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding \n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, offset=%lld, p=%p\\n\",\n           osGetCurrentProcessId(), pFd, iOff, p));\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    /* FIXME:  If Windows truly always prevents truncating or deleting a\n    ** file while a mapping is held, then the following winUnmapfile() call\n    ** is unnecessary can can be omitted - potentially improving\n    ** performance.  */\n    winUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#endif\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd));\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32.\n*/\nstatic const sqlite3_io_methods winIoMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winLock,                        /* xLock */\n  winUnlock,                      /* xUnlock */\n  winCheckReservedLock,           /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n/*\n** Convert a UTF-8 filename into whatever form the underlying\n** operating system wants filenames in.  Space to hold the result\n** is obtained from malloc and must be freed by the calling\n** function.\n*/\nstatic void *convertUtf8Filename(const char *zFilename){\n  void *zConverted = 0;\n  if( isNT() ){\n    zConverted = utf8ToUnicode(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = sqlite3_win32_utf8_to_mbcs(zFilename);\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n\n/*\n** Create a temporary file name in zBuf.  zBuf must be big enough to\n** hold at pVfs->mxPathname characters.\n*/\nstatic int getTempname(int nBuf, char *zBuf){\n  static char zChars[] =\n    \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"0123456789\";\n  size_t i, j;\n  int nTempPath;\n  char zTempPath[MAX_PATH+2];\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. \n  */\n  SimulateIOError( return SQLITE_IOERR );\n\n  memset(zTempPath, 0, MAX_PATH+2);\n\n  if( sqlite3_temp_directory ){\n    sqlite3_snprintf(MAX_PATH-30, zTempPath, \"%s\", sqlite3_temp_directory);\n  }\n#if !SQLITE_OS_WINRT\n  else if( isNT() ){\n    char *zMulti;\n    WCHAR zWidePath[MAX_PATH];\n    osGetTempPathW(MAX_PATH-30, zWidePath);\n    zMulti = unicodeToUtf8(zWidePath);\n    if( zMulti ){\n      sqlite3_snprintf(MAX_PATH-30, zTempPath, \"%s\", zMulti);\n      sqlite3_free(zMulti);\n    }else{\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM;\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zUtf8;\n    char zMbcsPath[MAX_PATH];\n    osGetTempPathA(MAX_PATH-30, zMbcsPath);\n    zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);\n    if( zUtf8 ){\n      sqlite3_snprintf(MAX_PATH-30, zTempPath, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n    }else{\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM;\n    }\n  }\n#endif\n#endif\n\n  /* Check that the output buffer is large enough for the temporary file \n  ** name. If it is not, return SQLITE_ERROR.\n  */\n  nTempPath = sqlite3Strlen30(zTempPath);\n\n  if( (nTempPath + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return SQLITE_ERROR;\n  }\n\n  for(i=nTempPath; i>0 && zTempPath[i-1]=='\\\\'; i--){}\n  zTempPath[i] = 0;\n\n  sqlite3_snprintf(nBuf-18, zBuf, (nTempPath > 0) ?\n                       \"%s\\\\\"SQLITE_TEMP_FILE_PREFIX : SQLITE_TEMP_FILE_PREFIX,\n                   zTempPath);\n  j = sqlite3Strlen30(zBuf);\n  sqlite3_randomness(15, &zBuf[j]);\n  for(i=0; i<15; i++, j++){\n    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];\n  }\n  zBuf[j] = 0;\n  zBuf[j+1] = 0;\n\n  OSTRACE((\"TEMP-FILENAME name=%s, rc=SQLITE_OK\\n\", zBuf));\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the named file is really a directory.  Return false if\n** it is something other than a directory, or if there is any kind of memory\n** allocation failure.\n*/\nstatic int winIsDir(const void *zConverted){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno;\n\n  if( isNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && retryIoerr(&cnt, &lastErrno) ){}\n    if( !rc ){\n      return 0; /* Invalid name? */\n    }\n    attr = sAttrData.dwFileAttributes;\n#if SQLITE_OS_WINCE==0\n  }else{\n    attr = osGetFileAttributesA((char*)zConverted);\n#endif\n  }\n  return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);\n}\n\n/*\n** Open a file.\n*/\nstatic int winOpen(\n  sqlite3_vfs *pVfs,        /* Not used */\n  const char *zName,        /* Name of the file (UTF-8) */\n  sqlite3_file *id,         /* Write the SQLite file handle here */\n  int flags,                /* Open mode flags */\n  int *pOutFlags            /* Status return flags */\n){\n  HANDLE h;\n  DWORD lastErrno;\n  DWORD dwDesiredAccess;\n  DWORD dwShareMode;\n  DWORD dwCreationDisposition;\n  DWORD dwFlagsAndAttributes = 0;\n#if SQLITE_OS_WINCE\n  int isTemp = 0;\n#endif\n  winFile *pFile = (winFile*)id;\n  void *zConverted;              /* Filename in OS encoding */\n  const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */\n  int cnt = 0;\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char zTmpname[MAX_PATH+2];     /* Buffer used to create temp filename */\n\n  int rc = SQLITE_OK;            /* Function Return Code */\n#if !defined(NDEBUG) || SQLITE_OS_WINCE\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n#endif\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n\n#ifndef NDEBUG\n  int isOpenJournal = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL \n     || eType==SQLITE_OPEN_MAIN_JOURNAL \n     || eType==SQLITE_OPEN_WAL\n  ));\n#endif\n\n  OSTRACE((\"OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\\n\",\n           zUtf8Name, id, flags, pOutFlags));\n\n  /* Check the following statements are true: \n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and \n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never \n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB \n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL \n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL \n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  assert( pFile!=0 );\n  memset(pFile, 0, sizeof(winFile));\n  pFile->h = INVALID_HANDLE_VALUE;\n\n#if SQLITE_OS_WINRT\n  if( !sqlite3_temp_directory ){\n    sqlite3_log(SQLITE_ERROR,\n        \"sqlite3_temp_directory variable should be set for WinRT\");\n  }\n#endif\n\n  /* If the second argument to this function is NULL, generate a \n  ** temporary file name to use \n  */\n  if( !zUtf8Name ){\n    assert(isDelete && !isOpenJournal);\n    memset(zTmpname, 0, MAX_PATH+2);\n    rc = getTempname(MAX_PATH+2, zTmpname);\n    if( rc!=SQLITE_OK ){\n      OSTRACE((\"OPEN name=%s, rc=%s\", zUtf8Name, sqlite3ErrName(rc)));\n      return rc;\n    }\n    zUtf8Name = zTmpname;\n  }\n\n  /* Database filenames are double-zero terminated if they are not\n  ** URIs with parameters.  Hence, they can always be passed into\n  ** sqlite3_uri_parameter().\n  */\n  assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||\n        zUtf8Name[strlen(zUtf8Name)+1]==0 );\n\n  /* Convert the filename to the system encoding. */\n  zConverted = convertUtf8Filename(zUtf8Name);\n  if( zConverted==0 ){\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_IOERR_NOMEM\", zUtf8Name));\n    return SQLITE_IOERR_NOMEM;\n  }\n\n  if( winIsDir(zConverted) ){\n    sqlite3_free(zConverted);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_CANTOPEN_ISDIR\", zUtf8Name));\n    return SQLITE_CANTOPEN_ISDIR;\n  }\n\n  if( isReadWrite ){\n    dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;\n  }else{\n    dwDesiredAccess = GENERIC_READ;\n  }\n\n  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is \n  ** created. SQLite doesn't use it to indicate \"exclusive access\" \n  ** as it is usually understood.\n  */\n  if( isExclusive ){\n    /* Creates a new file, only if it does not already exist. */\n    /* If the file exists, it fails. */\n    dwCreationDisposition = CREATE_NEW;\n  }else if( isCreate ){\n    /* Open existing file, or create if it doesn't exist */\n    dwCreationDisposition = OPEN_ALWAYS;\n  }else{\n    /* Opens a file, only if it exists. */\n    dwCreationDisposition = OPEN_EXISTING;\n  }\n\n  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;\n\n  if( isDelete ){\n#if SQLITE_OS_WINCE\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;\n    isTemp = 1;\n#else\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY\n                               | FILE_ATTRIBUTE_HIDDEN\n                               | FILE_FLAG_DELETE_ON_CLOSE;\n#endif\n  }else{\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;\n  }\n  /* Reports from the internet are that performance is always\n  ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */\n#if SQLITE_OS_WINCE\n  dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;\n#endif\n\n  if( isNT() ){\n#if SQLITE_OS_WINRT\n    CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;\n    extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);\n    extendedParameters.dwFileAttributes =\n            dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;\n    extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;\n    extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;\n    extendedParameters.lpSecurityAttributes = NULL;\n    extendedParameters.hTemplateFile = NULL;\n    while( (h = osCreateFile2((LPCWSTR)zConverted,\n                              dwDesiredAccess,\n                              dwShareMode,\n                              dwCreationDisposition,\n                              &extendedParameters))==INVALID_HANDLE_VALUE &&\n                              retryIoerr(&cnt, &lastErrno) ){\n               /* Noop */\n    }\n#else\n    while( (h = osCreateFileW((LPCWSTR)zConverted,\n                              dwDesiredAccess,\n                              dwShareMode, NULL,\n                              dwCreationDisposition,\n                              dwFlagsAndAttributes,\n                              NULL))==INVALID_HANDLE_VALUE &&\n                              retryIoerr(&cnt, &lastErrno) ){\n               /* Noop */\n    }\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    while( (h = osCreateFileA((LPCSTR)zConverted,\n                              dwDesiredAccess,\n                              dwShareMode, NULL,\n                              dwCreationDisposition,\n                              dwFlagsAndAttributes,\n                              NULL))==INVALID_HANDLE_VALUE &&\n                              retryIoerr(&cnt, &lastErrno) ){\n               /* Noop */\n    }\n  }\n#endif\n  logIoerr(cnt);\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, rc=%s\\n\", h, zUtf8Name,\n           dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  if( h==INVALID_HANDLE_VALUE ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_CANTOPEN, pFile->lastErrno, \"winOpen\", zUtf8Name);\n    sqlite3_free(zConverted);\n    if( isReadWrite && !isExclusive ){\n      return winOpen(pVfs, zName, id, \n         ((flags|SQLITE_OPEN_READONLY) &\n                     ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),\n         pOutFlags);\n    }else{\n      return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n\n  if( pOutFlags ){\n    if( isReadWrite ){\n      *pOutFlags = SQLITE_OPEN_READWRITE;\n    }else{\n      *pOutFlags = SQLITE_OPEN_READONLY;\n    }\n  }\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, \"\n           \"rc=%s\\n\", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?\n           *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n#if SQLITE_OS_WINCE\n  if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB\n       && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK\n  ){\n    osCloseHandle(h);\n    sqlite3_free(zConverted);\n    OSTRACE((\"OPEN-CE-LOCK name=%s, rc=%s\\n\", zName, sqlite3ErrName(rc)));\n    return rc;\n  }\n  if( isTemp ){\n    pFile->zDeleteOnClose = zConverted;\n  }else\n#endif\n  {\n    sqlite3_free(zConverted);\n  }\n\n  pFile->pMethod = &winIoMethod;\n  pFile->pVfs = pVfs;\n  pFile->h = h;\n  if( isReadonly ){\n    pFile->ctrlFlags |= WINFILE_RDONLY;\n  }\n  if( sqlite3_uri_boolean(zName, \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pFile->ctrlFlags |= WINFILE_PSOW;\n  }\n  pFile->lastErrno = NO_ERROR;\n  pFile->zPath = zName;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pFile->hMap = NULL;\n  pFile->pMapRegion = 0;\n  pFile->mmapSize = 0;\n  pFile->mmapSizeActual = 0;\n  pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n\n  OpenCounter(+1);\n  return rc;\n}\n\n/*\n** Delete the named file.\n**\n** Note that Windows does not allow a file to be deleted if some other\n** process has it open.  Sometimes a virus scanner or indexing program\n** will open a journal file shortly after it is created in order to do\n** whatever it does.  While this other process is holding the\n** file open, we will be unable to delete it.  To work around this\n** problem, we delay 100 milliseconds and try to delete again.  Up\n** to MX_DELETION_ATTEMPTs deletion attempts are run before giving\n** up and returning an error.\n*/\nstatic int winDelete(\n  sqlite3_vfs *pVfs,          /* Not used on win32 */\n  const char *zFilename,      /* Name of file to delete */\n  int syncDir                 /* Not used on win32 */\n){\n  int cnt = 0;\n  int rc;\n  DWORD attr;\n  DWORD lastErrno;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n  UNUSED_PARAMETER(syncDir);\n\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  OSTRACE((\"DELETE name=%s, syncDir=%d\\n\", zFilename, syncDir));\n\n  zConverted = convertUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    return SQLITE_IOERR_NOMEM;\n  }\n  if( isNT() ){\n    do {\n#if SQLITE_OS_WINRT\n      WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n      memset(&sAttrData, 0, sizeof(sAttrData));\n      if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,\n                                  &sAttrData) ){\n        attr = sAttrData.dwFileAttributes;\n      }else{\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n#else\n      attr = osGetFileAttributesW(zConverted);\n#endif\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileW(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !retryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do {\n      attr = osGetFileAttributesA(zConverted);\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileA(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !retryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#endif\n  if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){\n    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,\n             \"winDelete\", zFilename);\n  }else{\n    logIoerr(cnt);\n  }\n  sqlite3_free(zConverted);\n  OSTRACE((\"DELETE name=%s, rc=%s\\n\", zFilename, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Check the existence and status of a file.\n*/\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  OSTRACE((\"ACCESS name=%s, flags=%x, pResOut=%p\\n\",\n           zFilename, flags, pResOut));\n\n  zConverted = convertUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM;\n  }\n  if( isNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard, \n                             &sAttrData)) && retryIoerr(&cnt, &lastErrno) ){}\n    if( rc ){\n      /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file\n      ** as if it does not exist.\n      */\n      if(    flags==SQLITE_ACCESS_EXISTS\n          && sAttrData.nFileSizeHigh==0 \n          && sAttrData.nFileSizeLow==0 ){\n        attr = INVALID_FILE_ATTRIBUTES;\n      }else{\n        attr = sAttrData.dwFileAttributes;\n      }\n    }else{\n      logIoerr(cnt);\n      if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){\n        winLogError(SQLITE_IOERR_ACCESS, lastErrno, \"winAccess\", zFilename);\n        sqlite3_free(zConverted);\n        return SQLITE_IOERR_ACCESS;\n      }else{\n        attr = INVALID_FILE_ATTRIBUTES;\n      }\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    attr = osGetFileAttributesA((char*)zConverted);\n  }\n#endif\n  sqlite3_free(zConverted);\n  switch( flags ){\n    case SQLITE_ACCESS_READ:\n    case SQLITE_ACCESS_EXISTS:\n      rc = attr!=INVALID_FILE_ATTRIBUTES;\n      break;\n    case SQLITE_ACCESS_READWRITE:\n      rc = attr!=INVALID_FILE_ATTRIBUTES &&\n             (attr & FILE_ATTRIBUTE_READONLY)==0;\n      break;\n    default:\n      assert(!\"Invalid flags argument\");\n  }\n  *pResOut = rc;\n  OSTRACE((\"ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           zFilename, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n\n/*\n** Returns non-zero if the specified path name should be used verbatim.  If\n** non-zero is returned from this function, the calling function must simply\n** use the provided path name verbatim -OR- resolve it into a full path name\n** using the GetFullPathName Win32 API function (if available).\n*/\nstatic BOOL winIsVerbatimPathname(\n  const char *zPathname\n){\n  /*\n  ** If the path name starts with a forward slash or a backslash, it is either\n  ** a legal UNC name, a volume relative path, or an absolute path name in the\n  ** \"Unix\" format on Windows.  There is no easy way to differentiate between\n  ** the final two cases; therefore, we return the safer return value of TRUE\n  ** so that callers of this function will simply use it verbatim.\n  */\n  if ( zPathname[0]=='/' || zPathname[0]=='\\\\' ){\n    return TRUE;\n  }\n\n  /*\n  ** If the path name starts with a letter and a colon it is either a volume\n  ** relative path or an absolute path.  Callers of this function must not\n  ** attempt to treat it as a relative path name (i.e. they should simply use\n  ** it verbatim).\n  */\n  if ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ){\n    return TRUE;\n  }\n\n  /*\n  ** If we get to this point, the path name should almost certainly be a purely\n  ** relative one (i.e. not a UNC name, not absolute, and not volume relative).\n  */\n  return FALSE;\n}\n\n/*\n** Turn a relative pathname into a full pathname.  Write the full\n** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname\n** bytes in size.\n*/\nstatic int winFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zRelative,        /* Possibly relative input path */\n  int nFull,                    /* Size of output buffer in bytes */\n  char *zFull                   /* Output buffer */\n){\n  \n#if defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  UNUSED_PARAMETER(nFull);\n  assert( pVfs->mxPathname>=MAX_PATH );\n  assert( nFull>=pVfs->mxPathname );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a slash.\n    */\n    char zOut[MAX_PATH+1];\n    memset(zOut, 0, MAX_PATH+1);\n    cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,\n                     MAX_PATH+1);\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\\\\%s\",\n                     sqlite3_data_directory, zOut);\n  }else{\n    cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);\n  }\n  return SQLITE_OK;\n#endif\n\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  /* WinCE has no concept of a relative pathname, or so I am told. */\n  /* WinRT has no way to convert a relative path to an absolute one. */\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\\\\%s\",\n                     sqlite3_data_directory, zRelative);\n  }else{\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zRelative);\n  }\n  return SQLITE_OK;\n#endif\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  DWORD nByte;\n  void *zConverted;\n  char *zOut;\n\n  /* If this path name begins with \"/X:\", where \"X\" is any alphabetic\n  ** character, discard the initial \"/\" from the pathname.\n  */\n  if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){\n    zRelative++;\n  }\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\\\\%s\",\n                     sqlite3_data_directory, zRelative);\n    return SQLITE_OK;\n  }\n  zConverted = convertUtf8Filename(zRelative);\n  if( zConverted==0 ){\n    return SQLITE_IOERR_NOMEM;\n  }\n  if( isNT() ){\n    LPWSTR zTemp;\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      winLogError(SQLITE_ERROR, osGetLastError(),\n                  \"GetFullPathNameW1\", zConverted);\n      sqlite3_free(zConverted);\n      return SQLITE_CANTOPEN_FULLPATH;\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM;\n    }\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      winLogError(SQLITE_ERROR, osGetLastError(),\n                  \"GetFullPathNameW2\", zConverted);\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return SQLITE_CANTOPEN_FULLPATH;\n    }\n    sqlite3_free(zConverted);\n    zOut = unicodeToUtf8(zTemp);\n    sqlite3_free(zTemp);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp;\n    nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      winLogError(SQLITE_ERROR, osGetLastError(),\n                  \"GetFullPathNameA1\", zConverted);\n      sqlite3_free(zConverted);\n      return SQLITE_CANTOPEN_FULLPATH;\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM;\n    }\n    nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      winLogError(SQLITE_ERROR, osGetLastError(),\n                  \"GetFullPathNameA2\", zConverted);\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return SQLITE_CANTOPEN_FULLPATH;\n    }\n    sqlite3_free(zConverted);\n    zOut = sqlite3_win32_mbcs_to_utf8(zTemp);\n    sqlite3_free(zTemp);\n  }\n#endif\n  if( zOut ){\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zOut);\n    sqlite3_free(zOut);\n    return SQLITE_OK;\n  }else{\n    return SQLITE_IOERR_NOMEM;\n  }\n#endif\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\nstatic void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){\n  HANDLE h;\n  void *zConverted = convertUtf8Filename(zFilename);\n  UNUSED_PARAMETER(pVfs);\n  if( zConverted==0 ){\n    return 0;\n  }\n  if( isNT() ){\n#if SQLITE_OS_WINRT\n    h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);\n#else\n    h = osLoadLibraryW((LPCWSTR)zConverted);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    h = osLoadLibraryA((char*)zConverted);\n  }\n#endif\n  sqlite3_free(zConverted);\n  return (void*)h;\n}\nstatic void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){\n  UNUSED_PARAMETER(pVfs);\n  getLastErrorMsg(osGetLastError(), nBuf, zBufOut);\n}\nstatic void (*winDlSym(sqlite3_vfs *pVfs,void *pH,const char *zSym))(void){\n  UNUSED_PARAMETER(pVfs);\n  return (void(*)(void))osGetProcAddressA((HANDLE)pH, zSym);\n}\nstatic void winDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  UNUSED_PARAMETER(pVfs);\n  osFreeLibrary((HANDLE)pHandle);\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define winDlOpen  0\n  #define winDlError 0\n  #define winDlSym   0\n  #define winDlClose 0\n#endif\n\n\n/*\n** Write up to nBuf bytes of randomness into zBuf.\n*/\nstatic int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n  int n = 0;\n  UNUSED_PARAMETER(pVfs);\n#if defined(SQLITE_TEST)\n  n = nBuf;\n  memset(zBuf, 0, nBuf);\n#else\n  if( sizeof(SYSTEMTIME)<=nBuf-n ){\n    SYSTEMTIME x;\n    osGetSystemTime(&x);\n    memcpy(&zBuf[n], &x, sizeof(x));\n    n += sizeof(x);\n  }\n  if( sizeof(DWORD)<=nBuf-n ){\n    DWORD pid = osGetCurrentProcessId();\n    memcpy(&zBuf[n], &pid, sizeof(pid));\n    n += sizeof(pid);\n  }\n#if SQLITE_OS_WINRT\n  if( sizeof(ULONGLONG)<=nBuf-n ){\n    ULONGLONG cnt = osGetTickCount64();\n    memcpy(&zBuf[n], &cnt, sizeof(cnt));\n    n += sizeof(cnt);\n  }\n#else\n  if( sizeof(DWORD)<=nBuf-n ){\n    DWORD cnt = osGetTickCount();\n    memcpy(&zBuf[n], &cnt, sizeof(cnt));\n    n += sizeof(cnt);\n  }\n#endif\n  if( sizeof(LARGE_INTEGER)<=nBuf-n ){\n    LARGE_INTEGER i;\n    osQueryPerformanceCounter(&i);\n    memcpy(&zBuf[n], &i, sizeof(i));\n    n += sizeof(i);\n  }\n#endif\n  return n;\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nstatic int winSleep(sqlite3_vfs *pVfs, int microsec){\n  sqlite3_win32_sleep((microsec+999)/1000);\n  UNUSED_PARAMETER(pVfs);\n  return ((microsec+999)/1000)*1000;\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date \n** cannot be found.\n*/\nstatic int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){\n  /* FILETIME structure is a 64-bit value representing the number of \n     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). \n  */\n  FILETIME ft;\n  static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;\n#ifdef SQLITE_TEST\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n#endif\n  /* 2^32 - to avoid use of LL and warnings in gcc */\n  static const sqlite3_int64 max32BitValue = \n      (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +\n      (sqlite3_int64)294967296;\n\n#if SQLITE_OS_WINCE\n  SYSTEMTIME time;\n  osGetSystemTime(&time);\n  /* if SystemTimeToFileTime() fails, it returns zero. */\n  if (!osSystemTimeToFileTime(&time,&ft)){\n    return SQLITE_ERROR;\n  }\n#else\n  osGetSystemTimeAsFileTime( &ft );\n#endif\n\n  *piNow = winFiletimeEpoch +\n            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) + \n               (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(pVfs);\n  return SQLITE_OK;\n}\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){\n  int rc;\n  sqlite3_int64 i;\n  rc = winCurrentTimeInt64(pVfs, &i);\n  if( !rc ){\n    *prNow = i/86400000.0;\n  }\n  return rc;\n}\n\n/*\n** The idea is that this function works like a combination of\n** GetLastError() and FormatMessage() on Windows (or errno and\n** strerror_r() on Unix). After an error is returned by an OS\n** function, SQLite calls this function with zBuf pointing to\n** a buffer of nBuf bytes. The OS layer should populate the\n** buffer with a nul-terminated UTF-8 encoded error message\n** describing the last IO error to have occurred within the calling\n** thread.\n**\n** If the error message is too large for the supplied buffer,\n** it should be truncated. The return value of xGetLastError\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated). If non-zero is returned,\n** then it is not necessary to include the nul-terminator character\n** in the output buffer.\n**\n** Not supplying an error message will have no adverse effect\n** on SQLite. It is fine to have an implementation that never\n** returns an error message:\n**\n**   int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n**     assert(zBuf[0]=='\\0');\n**     return 0;\n**   }\n**\n** However if an error message is supplied, it will be incorporated\n** by sqlite into the error message available to the user using\n** sqlite3_errmsg(), possibly making IO errors easier to debug.\n*/\nstatic int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n  UNUSED_PARAMETER(pVfs);\n  return getLastErrorMsg(osGetLastError(), nBuf, zBuf);\n}\n\n/*\n** Initialize and deinitialize the operating system interface.\n*/\nSQLITE_API int sqlite3_os_init(void){\n  static sqlite3_vfs winVfs = {\n    3,                   /* iVersion */\n    sizeof(winFile),     /* szOsFile */\n    MAX_PATH,            /* mxPathname */\n    0,                   /* pNext */\n    \"win32\",             /* zName */\n    0,                   /* pAppData */\n    winOpen,             /* xOpen */\n    winDelete,           /* xDelete */\n    winAccess,           /* xAccess */\n    winFullPathname,     /* xFullPathname */\n    winDlOpen,           /* xDlOpen */\n    winDlError,          /* xDlError */\n    winDlSym,            /* xDlSym */\n    winDlClose,          /* xDlClose */\n    winRandomness,       /* xRandomness */\n    winSleep,            /* xSleep */\n    winCurrentTime,      /* xCurrentTime */\n    winGetLastError,     /* xGetLastError */\n    winCurrentTimeInt64, /* xCurrentTimeInt64 */\n    winSetSystemCall,    /* xSetSystemCall */\n    winGetSystemCall,    /* xGetSystemCall */\n    winNextSystemCall,   /* xNextSystemCall */\n  };\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==74 );\n\n  /* get memory map allocation granularity */\n  memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));\n#if SQLITE_OS_WINRT\n  osGetNativeSystemInfo(&winSysInfo);\n#else\n  osGetSystemInfo(&winSysInfo);\n#endif\n  assert( winSysInfo.dwAllocationGranularity>0 );\n  assert( winSysInfo.dwPageSize>0 );\n\n  sqlite3_vfs_register(&winVfs, 1);\n  return SQLITE_OK; \n}\n\nSQLITE_API int sqlite3_os_end(void){ \n#if SQLITE_OS_WINRT\n  if( sleepObj!=NULL ){\n    osCloseHandle(sleepObj);\n    sleepObj = NULL;\n  }\n#endif\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OS_WIN */\n\n/************** End of os_win.c **********************************************/\n/************** Begin file bitvec.c ******************************************/\n/*\n** 2008 February 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an object that represents a fixed-length\n** bitmap.  Bits are numbered starting with 1.\n**\n** A bitmap is used to record which pages of a database file have been\n** journalled during a transaction, or which pages have the \"dont-write\"\n** property.  Usually only a few pages are meet either condition.\n** So the bitmap is usually sparse and has low cardinality.\n** But sometimes (for example when during a DROP of a large table) most\n** or all of the pages in a database can get journalled.  In those cases, \n** the bitmap becomes dense with high cardinality.  The algorithm needs \n** to handle both cases well.\n**\n** The size of the bitmap is fixed when the object is created.\n**\n** All bits are clear when the bitmap is created.  Individual bits\n** may be set or cleared one at a time.\n**\n** Test operations are about 100 times more common that set operations.\n** Clear operations are exceedingly rare.  There are usually between\n** 5 and 500 set operations per Bitvec object, though the number of sets can\n** sometimes grow into tens of thousands or larger.  The size of the\n** Bitvec object is the number of pages in the database file at the\n** start of a transaction, and is thus usually less than a few thousand,\n** but can be as large as 2 billion for a really big database.\n*/\n\n/* Size of the Bitvec structure in bytes. */\n#define BITVEC_SZ        512\n\n/* Round the union size down to the nearest pointer boundary, since that's how \n** it will be aligned within the Bitvec struct. */\n#define BITVEC_USIZE     (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*))\n\n/* Type of the array \"element\" for the bitmap representation. \n** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. \n** Setting this to the \"natural word\" size of your CPU may improve\n** performance. */\n#define BITVEC_TELEM     u8\n/* Size, in bits, of the bitmap element. */\n#define BITVEC_SZELEM    8\n/* Number of elements in a bitmap array. */\n#define BITVEC_NELEM     (BITVEC_USIZE/sizeof(BITVEC_TELEM))\n/* Number of bits in the bitmap array. */\n#define BITVEC_NBIT      (BITVEC_NELEM*BITVEC_SZELEM)\n\n/* Number of u32 values in hash table. */\n#define BITVEC_NINT      (BITVEC_USIZE/sizeof(u32))\n/* Maximum number of entries in hash table before \n** sub-dividing and re-hashing. */\n#define BITVEC_MXHASH    (BITVEC_NINT/2)\n/* Hashing function for the aHash representation.\n** Empirical testing showed that the *37 multiplier \n** (an arbitrary prime)in the hash function provided \n** no fewer collisions than the no-op *1. */\n#define BITVEC_HASH(X)   (((X)*1)%BITVEC_NINT)\n\n#define BITVEC_NPTR      (BITVEC_USIZE/sizeof(Bitvec *))\n\n\n/*\n** A bitmap is an instance of the following structure.\n**\n** This bitmap records the existence of zero or more bits\n** with values between 1 and iSize, inclusive.\n**\n** There are three possible representations of the bitmap.\n** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight\n** bitmap.  The least significant bit is bit 1.\n**\n** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is\n** a hash table that will hold up to BITVEC_MXHASH distinct values.\n**\n** Otherwise, the value i is redirected into one of BITVEC_NPTR\n** sub-bitmaps pointed to by Bitvec.u.apSub[].  Each subbitmap\n** handles up to iDivisor separate values of i.  apSub[0] holds\n** values between 1 and iDivisor.  apSub[1] holds values between\n** iDivisor+1 and 2*iDivisor.  apSub[N] holds values between\n** N*iDivisor+1 and (N+1)*iDivisor.  Each subbitmap is normalized\n** to hold deal with values between 1 and iDivisor.\n*/\nstruct Bitvec {\n  u32 iSize;      /* Maximum bit index.  Max iSize is 4,294,967,296. */\n  u32 nSet;       /* Number of bits that are set - only valid for aHash\n                  ** element.  Max is BITVEC_NINT.  For BITVEC_SZ of 512,\n                  ** this would be 125. */\n  u32 iDivisor;   /* Number of bits handled by each apSub[] entry. */\n                  /* Should >=0 for apSub element. */\n                  /* Max iDivisor is max(u32) / BITVEC_NPTR + 1.  */\n                  /* For a BITVEC_SZ of 512, this would be 34,359,739. */\n  union {\n    BITVEC_TELEM aBitmap[BITVEC_NELEM];    /* Bitmap representation */\n    u32 aHash[BITVEC_NINT];      /* Hash table representation */\n    Bitvec *apSub[BITVEC_NPTR];  /* Recursive representation */\n  } u;\n};\n\n/*\n** Create a new bitmap object able to handle bits between 0 and iSize,\n** inclusive.  Return a pointer to the new object.  Return NULL if \n** malloc fails.\n*/\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32 iSize){\n  Bitvec *p;\n  assert( sizeof(*p)==BITVEC_SZ );\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p ){\n    p->iSize = iSize;\n  }\n  return p;\n}\n\n/*\n** Check to see if the i-th bit is set.  Return true or false.\n** If p is NULL (if the bitmap has not been created) or if\n** i is out of range, then return false.\n*/\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec *p, u32 i){\n  if( p==0 ) return 0;\n  if( i>p->iSize || i==0 ) return 0;\n  i--;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return 0;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    return (p->u.aBitmap[i/BITVEC_SZELEM] & (1<<(i&(BITVEC_SZELEM-1))))!=0;\n  } else{\n    u32 h = BITVEC_HASH(i++);\n    while( p->u.aHash[h] ){\n      if( p->u.aHash[h]==i ) return 1;\n      h = (h+1) % BITVEC_NINT;\n    }\n    return 0;\n  }\n}\n\n/*\n** Set the i-th bit.  Return 0 on success and an error code if\n** anything goes wrong.\n**\n** This routine might cause sub-bitmaps to be allocated.  Failing\n** to get the memory needed to hold the sub-bitmap is the only\n** that can go wrong with an insert, assuming p and i are valid.\n**\n** The calling function must ensure that p is a valid Bitvec object\n** and that the value for \"i\" is within range of the Bitvec object.\n** Otherwise the behavior is undefined.\n*/\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){\n  u32 h;\n  if( p==0 ) return SQLITE_OK;\n  assert( i>0 );\n  assert( i<=p->iSize );\n  i--;\n  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    if( p->u.apSub[bin]==0 ){\n      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );\n      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM;\n    }\n    p = p->u.apSub[bin];\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] |= 1 << (i&(BITVEC_SZELEM-1));\n    return SQLITE_OK;\n  }\n  h = BITVEC_HASH(i++);\n  /* if there wasn't a hash collision, and this doesn't */\n  /* completely fill the hash, then just add it without */\n  /* worring about sub-dividing and re-hashing. */\n  if( !p->u.aHash[h] ){\n    if (p->nSet<(BITVEC_NINT-1)) {\n      goto bitvec_set_end;\n    } else {\n      goto bitvec_set_rehash;\n    }\n  }\n  /* there was a collision, check to see if it's already */\n  /* in hash, if not, try to find a spot for it */\n  do {\n    if( p->u.aHash[h]==i ) return SQLITE_OK;\n    h++;\n    if( h>=BITVEC_NINT ) h = 0;\n  } while( p->u.aHash[h] );\n  /* we didn't find it in the hash.  h points to the first */\n  /* available free spot. check to see if this is going to */\n  /* make our hash too \"full\".  */\nbitvec_set_rehash:\n  if( p->nSet>=BITVEC_MXHASH ){\n    unsigned int j;\n    int rc;\n    u32 *aiValues = sqlite3StackAllocRaw(0, sizeof(p->u.aHash));\n    if( aiValues==0 ){\n      return SQLITE_NOMEM;\n    }else{\n      memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n      memset(p->u.apSub, 0, sizeof(p->u.apSub));\n      p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;\n      rc = sqlite3BitvecSet(p, i);\n      for(j=0; j<BITVEC_NINT; j++){\n        if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);\n      }\n      sqlite3StackFree(0, aiValues);\n      return rc;\n    }\n  }\nbitvec_set_end:\n  p->nSet++;\n  p->u.aHash[h] = i;\n  return SQLITE_OK;\n}\n\n/*\n** Clear the i-th bit.\n**\n** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage\n** that BitvecClear can use to rebuilt its hash table.\n*/\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec *p, u32 i, void *pBuf){\n  if( p==0 ) return;\n  assert( i>0 );\n  i--;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] &= ~(1 << (i&(BITVEC_SZELEM-1)));\n  }else{\n    unsigned int j;\n    u32 *aiValues = pBuf;\n    memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n    memset(p->u.aHash, 0, sizeof(p->u.aHash));\n    p->nSet = 0;\n    for(j=0; j<BITVEC_NINT; j++){\n      if( aiValues[j] && aiValues[j]!=(i+1) ){\n        u32 h = BITVEC_HASH(aiValues[j]-1);\n        p->nSet++;\n        while( p->u.aHash[h] ){\n          h++;\n          if( h>=BITVEC_NINT ) h = 0;\n        }\n        p->u.aHash[h] = aiValues[j];\n      }\n    }\n  }\n}\n\n/*\n** Destroy a bitmap object.  Reclaim all memory used.\n*/\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec *p){\n  if( p==0 ) return;\n  if( p->iDivisor ){\n    unsigned int i;\n    for(i=0; i<BITVEC_NPTR; i++){\n      sqlite3BitvecDestroy(p->u.apSub[i]);\n    }\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Return the value of the iSize parameter specified when Bitvec *p\n** was created.\n*/\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec *p){\n  return p->iSize;\n}\n\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n/*\n** Let V[] be an array of unsigned characters sufficient to hold\n** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.\n** Then the following macros can be used to set, clear, or test\n** individual bits within V.\n*/\n#define SETBIT(V,I)      V[I>>3] |= (1<<(I&7))\n#define CLEARBIT(V,I)    V[I>>3] &= ~(1<<(I&7))\n#define TESTBIT(V,I)     (V[I>>3]&(1<<(I&7)))!=0\n\n/*\n** This routine runs an extensive test of the Bitvec code.\n**\n** The input is an array of integers that acts as a program\n** to test the Bitvec.  The integers are opcodes followed\n** by 0, 1, or 3 operands, depending on the opcode.  Another\n** opcode follows immediately after the last operand.\n**\n** There are 6 opcodes numbered from 0 through 5.  0 is the\n** \"halt\" opcode and causes the test to end.\n**\n**    0          Halt and return the number of errors\n**    1 N S X    Set N bits beginning with S and incrementing by X\n**    2 N S X    Clear N bits beginning with S and incrementing by X\n**    3 N        Set N randomly chosen bits\n**    4 N        Clear N randomly chosen bits\n**    5 N S X    Set N bits from S increment X in array only, not in bitvec\n**\n** The opcodes 1 through 4 perform set and clear operations are performed\n** on both a Bitvec object and on a linear array of bits obtained from malloc.\n** Opcode 5 works on the linear array only, not on the Bitvec.\n** Opcode 5 is used to deliberately induce a fault in order to\n** confirm that error detection works.\n**\n** At the conclusion of the test the linear array is compared\n** against the Bitvec object.  If there are any differences,\n** an error is returned.  If they are the same, zero is returned.\n**\n** If a memory allocation error occurs, return -1.\n*/\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){\n  Bitvec *pBitvec = 0;\n  unsigned char *pV = 0;\n  int rc = -1;\n  int i, nx, pc, op;\n  void *pTmpSpace;\n\n  /* Allocate the Bitvec to be tested and a linear array of\n  ** bits to act as the reference */\n  pBitvec = sqlite3BitvecCreate( sz );\n  pV = sqlite3MallocZero( (sz+7)/8 + 1 );\n  pTmpSpace = sqlite3_malloc(BITVEC_SZ);\n  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;\n\n  /* NULL pBitvec tests */\n  sqlite3BitvecSet(0, 1);\n  sqlite3BitvecClear(0, 1, pTmpSpace);\n\n  /* Run the program */\n  pc = 0;\n  while( (op = aOp[pc])!=0 ){\n    switch( op ){\n      case 1:\n      case 2:\n      case 5: {\n        nx = 4;\n        i = aOp[pc+2] - 1;\n        aOp[pc+2] += aOp[pc+3];\n        break;\n      }\n      case 3:\n      case 4: \n      default: {\n        nx = 2;\n        sqlite3_randomness(sizeof(i), &i);\n        break;\n      }\n    }\n    if( (--aOp[pc+1]) > 0 ) nx = 0;\n    pc += nx;\n    i = (i & 0x7fffffff)%sz;\n    if( (op & 1)!=0 ){\n      SETBIT(pV, (i+1));\n      if( op!=5 ){\n        if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;\n      }\n    }else{\n      CLEARBIT(pV, (i+1));\n      sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);\n    }\n  }\n\n  /* Test to make sure the linear array exactly matches the\n  ** Bitvec object.  Start with the assumption that they do\n  ** match (rc==0).  Change rc to non-zero if a discrepancy\n  ** is found.\n  */\n  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)\n          + sqlite3BitvecTest(pBitvec, 0)\n          + (sqlite3BitvecSize(pBitvec) - sz);\n  for(i=1; i<=sz; i++){\n    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){\n      rc = i;\n      break;\n    }\n  }\n\n  /* Free allocated structure */\nbitvec_end:\n  sqlite3_free(pTmpSpace);\n  sqlite3_free(pV);\n  sqlite3BitvecDestroy(pBitvec);\n  return rc;\n}\n#endif /* SQLITE_OMIT_BUILTIN_TEST */\n\n/************** End of bitvec.c **********************************************/\n/************** Begin file pcache.c ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements that page cache.\n*/\n\n/*\n** A complete page cache is an instance of this structure.\n*/\nstruct PCache {\n  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */\n  PgHdr *pSynced;                     /* Last synced page in dirty page list */\n  int nRef;                           /* Number of referenced pages */\n  int szCache;                        /* Configured cache size */\n  int szPage;                         /* Size of every page in this cache */\n  int szExtra;                        /* Size of extra space for each page */\n  int bPurgeable;                     /* True if pages are on backing store */\n  int (*xStress)(void*,PgHdr*);       /* Call to try make a page clean */\n  void *pStress;                      /* Argument to xStress */\n  sqlite3_pcache *pCache;             /* Pluggable cache module */\n  PgHdr *pPage1;                      /* Reference to page 1 */\n};\n\n/*\n** Some of the assert() macros in this code are too expensive to run\n** even during normal debugging.  Use them only rarely on long-running\n** tests.  Enable the expensive asserts using the\n** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option.\n*/\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n# define expensive_assert(X)  assert(X)\n#else\n# define expensive_assert(X)\n#endif\n\n/********************************** Linked List Management ********************/\n\n#if !defined(NDEBUG) && defined(SQLITE_ENABLE_EXPENSIVE_ASSERT)\n/*\n** Check that the pCache->pSynced variable is set correctly. If it\n** is not, either fail an assert or return zero. Otherwise, return\n** non-zero. This is only used in debugging builds, as follows:\n**\n**   expensive_assert( pcacheCheckSynced(pCache) );\n*/\nstatic int pcacheCheckSynced(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirtyTail; p!=pCache->pSynced; p=p->pDirtyPrev){\n    assert( p->nRef || (p->flags&PGHDR_NEED_SYNC) );\n  }\n  return (p==0 || p->nRef || (p->flags&PGHDR_NEED_SYNC)==0);\n}\n#endif /* !NDEBUG && SQLITE_ENABLE_EXPENSIVE_ASSERT */\n\n/*\n** Remove page pPage from the list of dirty pages.\n*/\nstatic void pcacheRemoveFromDirtyList(PgHdr *pPage){\n  PCache *p = pPage->pCache;\n\n  assert( pPage->pDirtyNext || pPage==p->pDirtyTail );\n  assert( pPage->pDirtyPrev || pPage==p->pDirty );\n\n  /* Update the PCache1.pSynced variable if necessary. */\n  if( p->pSynced==pPage ){\n    PgHdr *pSynced = pPage->pDirtyPrev;\n    while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){\n      pSynced = pSynced->pDirtyPrev;\n    }\n    p->pSynced = pSynced;\n  }\n\n  if( pPage->pDirtyNext ){\n    pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;\n  }else{\n    assert( pPage==p->pDirtyTail );\n    p->pDirtyTail = pPage->pDirtyPrev;\n  }\n  if( pPage->pDirtyPrev ){\n    pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;\n  }else{\n    assert( pPage==p->pDirty );\n    p->pDirty = pPage->pDirtyNext;\n  }\n  pPage->pDirtyNext = 0;\n  pPage->pDirtyPrev = 0;\n\n  expensive_assert( pcacheCheckSynced(p) );\n}\n\n/*\n** Add page pPage to the head of the dirty list (PCache1.pDirty is set to\n** pPage).\n*/\nstatic void pcacheAddToDirtyList(PgHdr *pPage){\n  PCache *p = pPage->pCache;\n\n  assert( pPage->pDirtyNext==0 && pPage->pDirtyPrev==0 && p->pDirty!=pPage );\n\n  pPage->pDirtyNext = p->pDirty;\n  if( pPage->pDirtyNext ){\n    assert( pPage->pDirtyNext->pDirtyPrev==0 );\n    pPage->pDirtyNext->pDirtyPrev = pPage;\n  }\n  p->pDirty = pPage;\n  if( !p->pDirtyTail ){\n    p->pDirtyTail = pPage;\n  }\n  if( !p->pSynced && 0==(pPage->flags&PGHDR_NEED_SYNC) ){\n    p->pSynced = pPage;\n  }\n  expensive_assert( pcacheCheckSynced(p) );\n}\n\n/*\n** Wrapper around the pluggable caches xUnpin method. If the cache is\n** being used for an in-memory database, this function is a no-op.\n*/\nstatic void pcacheUnpin(PgHdr *p){\n  PCache *pCache = p->pCache;\n  if( pCache->bPurgeable ){\n    if( p->pgno==1 ){\n      pCache->pPage1 = 0;\n    }\n    sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, p->pPage, 0);\n  }\n}\n\n/*************************************************** General Interfaces ******\n**\n** Initialize and shutdown the page cache subsystem. Neither of these \n** functions are threadsafe.\n*/\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void){\n  if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n    /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the\n    ** built-in default page cache is used instead of the application defined\n    ** page cache. */\n    sqlite3PCacheSetDefault();\n  }\n  return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);\n}\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void){\n  if( sqlite3GlobalConfig.pcache2.xShutdown ){\n    /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */\n    sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg);\n  }\n}\n\n/*\n** Return the size in bytes of a PCache object.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void){ return sizeof(PCache); }\n\n/*\n** Create a new PCache object. Storage space to hold the object\n** has already been allocated and is passed in as the p pointer. \n** The caller discovers how much space needs to be allocated by \n** calling sqlite3PcacheSize().\n*/\nSQLITE_PRIVATE void sqlite3PcacheOpen(\n  int szPage,                  /* Size of every page */\n  int szExtra,                 /* Extra space associated with each page */\n  int bPurgeable,              /* True if pages are on backing store */\n  int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */\n  void *pStress,               /* Argument to xStress */\n  PCache *p                    /* Preallocated space for the PCache */\n){\n  memset(p, 0, sizeof(PCache));\n  p->szPage = szPage;\n  p->szExtra = szExtra;\n  p->bPurgeable = bPurgeable;\n  p->xStress = xStress;\n  p->pStress = pStress;\n  p->szCache = 100;\n}\n\n/*\n** Change the page size for PCache object. The caller must ensure that there\n** are no outstanding page references when this function is called.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *pCache, int szPage){\n  assert( pCache->nRef==0 && pCache->pDirty==0 );\n  if( pCache->pCache ){\n    sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n    pCache->pCache = 0;\n    pCache->pPage1 = 0;\n  }\n  pCache->szPage = szPage;\n}\n\n/*\n** Compute the number of pages of cache requested.\n*/\nstatic int numberOfCachePages(PCache *p){\n  if( p->szCache>=0 ){\n    return p->szCache;\n  }else{\n    return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));\n  }\n}\n\n/*\n** Try to obtain a page from the cache.\n*/\nSQLITE_PRIVATE int sqlite3PcacheFetch(\n  PCache *pCache,       /* Obtain the page from this cache */\n  Pgno pgno,            /* Page number to obtain */\n  int createFlag,       /* If true, create page if it does not exist already */\n  PgHdr **ppPage        /* Write the page here */\n){\n  sqlite3_pcache_page *pPage = 0;\n  PgHdr *pPgHdr = 0;\n  int eCreate;\n\n  assert( pCache!=0 );\n  assert( createFlag==1 || createFlag==0 );\n  assert( pgno>0 );\n\n  /* If the pluggable cache (sqlite3_pcache*) has not been allocated,\n  ** allocate it now.\n  */\n  if( !pCache->pCache && createFlag ){\n    sqlite3_pcache *p;\n    p = sqlite3GlobalConfig.pcache2.xCreate(\n        pCache->szPage, pCache->szExtra + sizeof(PgHdr), pCache->bPurgeable\n    );\n    if( !p ){\n      return SQLITE_NOMEM;\n    }\n    sqlite3GlobalConfig.pcache2.xCachesize(p, numberOfCachePages(pCache));\n    pCache->pCache = p;\n  }\n\n  eCreate = createFlag * (1 + (!pCache->bPurgeable || !pCache->pDirty));\n  if( pCache->pCache ){\n    pPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);\n  }\n\n  if( !pPage && eCreate==1 ){\n    PgHdr *pPg;\n\n    /* Find a dirty page to write-out and recycle. First try to find a \n    ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC\n    ** cleared), but if that is not possible settle for any other \n    ** unreferenced dirty page.\n    */\n    expensive_assert( pcacheCheckSynced(pCache) );\n    for(pPg=pCache->pSynced; \n        pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); \n        pPg=pPg->pDirtyPrev\n    );\n    pCache->pSynced = pPg;\n    if( !pPg ){\n      for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);\n    }\n    if( pPg ){\n      int rc;\n#ifdef SQLITE_LOG_CACHE_SPILL\n      sqlite3_log(SQLITE_FULL, \n                  \"spill page %d making room for %d - cache used: %d/%d\",\n                  pPg->pgno, pgno,\n                  sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),\n                  numberOfCachePages(pCache));\n#endif\n      rc = pCache->xStress(pCache->pStress, pPg);\n      if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n\n    pPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);\n  }\n\n  if( pPage ){\n    pPgHdr = (PgHdr *)pPage->pExtra;\n\n    if( !pPgHdr->pPage ){\n      memset(pPgHdr, 0, sizeof(PgHdr));\n      pPgHdr->pPage = pPage;\n      pPgHdr->pData = pPage->pBuf;\n      pPgHdr->pExtra = (void *)&pPgHdr[1];\n      memset(pPgHdr->pExtra, 0, pCache->szExtra);\n      pPgHdr->pCache = pCache;\n      pPgHdr->pgno = pgno;\n    }\n    assert( pPgHdr->pCache==pCache );\n    assert( pPgHdr->pgno==pgno );\n    assert( pPgHdr->pData==pPage->pBuf );\n    assert( pPgHdr->pExtra==(void *)&pPgHdr[1] );\n\n    if( 0==pPgHdr->nRef ){\n      pCache->nRef++;\n    }\n    pPgHdr->nRef++;\n    if( pgno==1 ){\n      pCache->pPage1 = pPgHdr;\n    }\n  }\n  *ppPage = pPgHdr;\n  return (pPgHdr==0 && eCreate) ? SQLITE_NOMEM : SQLITE_OK;\n}\n\n/*\n** Decrement the reference count on a page. If the page is clean and the\n** reference count drops to 0, then it is made elible for recycling.\n*/\nSQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr *p){\n  assert( p->nRef>0 );\n  p->nRef--;\n  if( p->nRef==0 ){\n    PCache *pCache = p->pCache;\n    pCache->nRef--;\n    if( (p->flags&PGHDR_DIRTY)==0 ){\n      pcacheUnpin(p);\n    }else{\n      /* Move the page to the head of the dirty list. */\n      pcacheRemoveFromDirtyList(p);\n      pcacheAddToDirtyList(p);\n    }\n  }\n}\n\n/*\n** Increase the reference count of a supplied page by 1.\n*/\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr *p){\n  assert(p->nRef>0);\n  p->nRef++;\n}\n\n/*\n** Drop a page from the cache. There must be exactly one reference to the\n** page. This function deletes that reference, so after it returns the\n** page pointed to by p is invalid.\n*/\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){\n  PCache *pCache;\n  assert( p->nRef==1 );\n  if( p->flags&PGHDR_DIRTY ){\n    pcacheRemoveFromDirtyList(p);\n  }\n  pCache = p->pCache;\n  pCache->nRef--;\n  if( p->pgno==1 ){\n    pCache->pPage1 = 0;\n  }\n  sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, p->pPage, 1);\n}\n\n/*\n** Make sure the page is marked as dirty. If it isn't dirty already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){\n  p->flags &= ~PGHDR_DONT_WRITE;\n  assert( p->nRef>0 );\n  if( 0==(p->flags & PGHDR_DIRTY) ){\n    p->flags |= PGHDR_DIRTY;\n    pcacheAddToDirtyList( p);\n  }\n}\n\n/*\n** Make sure the page is marked as clean. If it isn't clean already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr *p){\n  if( (p->flags & PGHDR_DIRTY) ){\n    pcacheRemoveFromDirtyList(p);\n    p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC);\n    if( p->nRef==0 ){\n      pcacheUnpin(p);\n    }\n  }\n}\n\n/*\n** Make every page in the cache clean.\n*/\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){\n  PgHdr *p;\n  while( (p = pCache->pDirty)!=0 ){\n    sqlite3PcacheMakeClean(p);\n  }\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC flag from all dirty pages.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~PGHDR_NEED_SYNC;\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Change the page number of page p to newPgno. \n*/\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){\n  PCache *pCache = p->pCache;\n  assert( p->nRef>0 );\n  assert( newPgno>0 );\n  sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);\n  p->pgno = newPgno;\n  if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){\n    pcacheRemoveFromDirtyList(p);\n    pcacheAddToDirtyList(p);\n  }\n}\n\n/*\n** Drop every cache entry whose page number is greater than \"pgno\". The\n** caller must ensure that there are no outstanding references to any pages\n** other than page 1 with a page number greater than pgno.\n**\n** If there is a reference to page 1 and the pgno parameter passed to this\n** function is 0, then the data area associated with page 1 is zeroed, but\n** the page object is not dropped.\n*/\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){\n  if( pCache->pCache ){\n    PgHdr *p;\n    PgHdr *pNext;\n    for(p=pCache->pDirty; p; p=pNext){\n      pNext = p->pDirtyNext;\n      /* This routine never gets call with a positive pgno except right\n      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,\n      ** it must be that pgno==0.\n      */\n      assert( p->pgno>0 );\n      if( ALWAYS(p->pgno>pgno) ){\n        assert( p->flags&PGHDR_DIRTY );\n        sqlite3PcacheMakeClean(p);\n      }\n    }\n    if( pgno==0 && pCache->pPage1 ){\n      memset(pCache->pPage1->pData, 0, pCache->szPage);\n      pgno = 1;\n    }\n    sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);\n  }\n}\n\n/*\n** Close a cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){\n  if( pCache->pCache ){\n    sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n  }\n}\n\n/* \n** Discard the contents of the cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){\n  sqlite3PcacheTruncate(pCache, 0);\n}\n\n/*\n** Merge two lists of pages connected by pDirty and in pgno order.\n** Do not both fixing the pDirtyPrev pointers.\n*/\nstatic PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){\n  PgHdr result, *pTail;\n  pTail = &result;\n  while( pA && pB ){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n    }\n  }\n  if( pA ){\n    pTail->pDirty = pA;\n  }else if( pB ){\n    pTail->pDirty = pB;\n  }else{\n    pTail->pDirty = 0;\n  }\n  return result.pDirty;\n}\n\n/*\n** Sort the list of pages in accending order by pgno.  Pages are\n** connected by pDirty pointers.  The pDirtyPrev pointers are\n** corrupted by this sort.\n**\n** Since there cannot be more than 2^31 distinct pages in a database,\n** there cannot be more than 31 buckets required by the merge sorter.\n** One extra bucket is added to catch overflow in case something\n** ever changes to make the previous sentence incorrect.\n*/\n#define N_SORT_BUCKET  32\nstatic PgHdr *pcacheSortDirtyList(PgHdr *pIn){\n  PgHdr *a[N_SORT_BUCKET], *p;\n  int i;\n  memset(a, 0, sizeof(a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = pcacheMergeDirtyList(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( NEVER(i==N_SORT_BUCKET-1) ){\n      /* To get here, there need to be 2^(N_SORT_BUCKET) elements in\n      ** the input list.  But that is impossible.\n      */\n      a[i] = pcacheMergeDirtyList(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<N_SORT_BUCKET; i++){\n    p = pcacheMergeDirtyList(p, a[i]);\n  }\n  return p;\n}\n\n/*\n** Return a list of all dirty pages in the cache, sorted by page number.\n*/\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->pDirty = p->pDirtyNext;\n  }\n  return pcacheSortDirtyList(pCache->pDirty);\n}\n\n/* \n** Return the total number of referenced pages held by the cache.\n*/\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){\n  return pCache->nRef;\n}\n\n/*\n** Return the number of references to the page supplied as an argument.\n*/\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr *p){\n  return p->nRef;\n}\n\n/* \n** Return the total number of pages in the cache.\n*/\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){\n  int nPage = 0;\n  if( pCache->pCache ){\n    nPage = sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);\n  }\n  return nPage;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Get the suggested cache-size value.\n*/\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){\n  return numberOfCachePages(pCache);\n}\n#endif\n\n/*\n** Set the suggested cache-size value.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){\n  pCache->szCache = mxPage;\n  if( pCache->pCache ){\n    sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,\n                                           numberOfCachePages(pCache));\n  }\n}\n\n/*\n** Free up as much memory as possible from the page cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){\n  if( pCache->pCache ){\n    sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);\n  }\n}\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/*\n** For all dirty pages currently in the cache, invoke the specified\n** callback. This is only used if the SQLITE_CHECK_PAGES macro is\n** defined.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){\n  PgHdr *pDirty;\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){\n    xIter(pDirty);\n  }\n}\n#endif\n\n/************** End of pcache.c **********************************************/\n/************** Begin file pcache1.c *****************************************/\n/*\n** 2008 November 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements the default page cache implementation (the\n** sqlite3_pcache interface). It also contains part of the implementation\n** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.\n** If the default page cache implementation is overriden, then neither of\n** these two features are available.\n*/\n\n\ntypedef struct PCache1 PCache1;\ntypedef struct PgHdr1 PgHdr1;\ntypedef struct PgFreeslot PgFreeslot;\ntypedef struct PGroup PGroup;\n\n/* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set \n** of one or more PCaches that are able to recycle each others unpinned\n** pages when they are under memory pressure.  A PGroup is an instance of\n** the following object.\n**\n** This page cache implementation works in one of two modes:\n**\n**   (1)  Every PCache is the sole member of its own PGroup.  There is\n**        one PGroup per PCache.\n**\n**   (2)  There is a single global PGroup that all PCaches are a member\n**        of.\n**\n** Mode 1 uses more memory (since PCache instances are not able to rob\n** unused pages from other PCaches) but it also operates without a mutex,\n** and is therefore often faster.  Mode 2 requires a mutex in order to be\n** threadsafe, but recycles pages more efficiently.\n**\n** For mode (1), PGroup.mutex is NULL.  For mode (2) there is only a single\n** PGroup which is the pcache1.grp global variable and its mutex is\n** SQLITE_MUTEX_STATIC_LRU.\n*/\nstruct PGroup {\n  sqlite3_mutex *mutex;          /* MUTEX_STATIC_LRU or NULL */\n  unsigned int nMaxPage;         /* Sum of nMax for purgeable caches */\n  unsigned int nMinPage;         /* Sum of nMin for purgeable caches */\n  unsigned int mxPinned;         /* nMaxpage + 10 - nMinPage */\n  unsigned int nCurrentPage;     /* Number of purgeable pages allocated */\n  PgHdr1 *pLruHead, *pLruTail;   /* LRU list of unpinned pages */\n};\n\n/* Each page cache is an instance of the following object.  Every\n** open database file (including each in-memory database and each\n** temporary or transient database) has a single page cache which\n** is an instance of this object.\n**\n** Pointers to structures of this type are cast and returned as \n** opaque sqlite3_pcache* handles.\n*/\nstruct PCache1 {\n  /* Cache configuration parameters. Page size (szPage) and the purgeable\n  ** flag (bPurgeable) are set when the cache is created. nMax may be \n  ** modified at any time by a call to the pcache1Cachesize() method.\n  ** The PGroup mutex must be held when accessing nMax.\n  */\n  PGroup *pGroup;                     /* PGroup this cache belongs to */\n  int szPage;                         /* Size of allocated pages in bytes */\n  int szExtra;                        /* Size of extra space in bytes */\n  int bPurgeable;                     /* True if cache is purgeable */\n  unsigned int nMin;                  /* Minimum number of pages reserved */\n  unsigned int nMax;                  /* Configured \"cache_size\" value */\n  unsigned int n90pct;                /* nMax*9/10 */\n  unsigned int iMaxKey;               /* Largest key seen since xTruncate() */\n\n  /* Hash table of all pages. The following variables may only be accessed\n  ** when the accessor is holding the PGroup mutex.\n  */\n  unsigned int nRecyclable;           /* Number of pages in the LRU list */\n  unsigned int nPage;                 /* Total number of pages in apHash */\n  unsigned int nHash;                 /* Number of slots in apHash[] */\n  PgHdr1 **apHash;                    /* Hash table for fast lookup by key */\n};\n\n/*\n** Each cache entry is represented by an instance of the following \n** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of\n** PgHdr1.pCache->szPage bytes is allocated directly before this structure \n** in memory.\n*/\nstruct PgHdr1 {\n  sqlite3_pcache_page page;\n  unsigned int iKey;             /* Key value (page number) */\n  PgHdr1 *pNext;                 /* Next in hash table chain */\n  PCache1 *pCache;               /* Cache that currently owns this page */\n  PgHdr1 *pLruNext;              /* Next in LRU list of unpinned pages */\n  PgHdr1 *pLruPrev;              /* Previous in LRU list of unpinned pages */\n};\n\n/*\n** Free slots in the allocator used to divide up the buffer provided using\n** the SQLITE_CONFIG_PAGECACHE mechanism.\n*/\nstruct PgFreeslot {\n  PgFreeslot *pNext;  /* Next free slot */\n};\n\n/*\n** Global data used by this cache.\n*/\nstatic SQLITE_WSD struct PCacheGlobal {\n  PGroup grp;                    /* The global PGroup for mode (2) */\n\n  /* Variables related to SQLITE_CONFIG_PAGECACHE settings.  The\n  ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all\n  ** fixed at sqlite3_initialize() time and do not require mutex protection.\n  ** The nFreeSlot and pFree values do require mutex protection.\n  */\n  int isInit;                    /* True if initialized */\n  int szSlot;                    /* Size of each free slot */\n  int nSlot;                     /* The number of pcache slots */\n  int nReserve;                  /* Try to keep nFreeSlot above this */\n  void *pStart, *pEnd;           /* Bounds of pagecache malloc range */\n  /* Above requires no mutex.  Use mutex below for variable that follow. */\n  sqlite3_mutex *mutex;          /* Mutex for accessing the following: */\n  PgFreeslot *pFree;             /* Free page blocks */\n  int nFreeSlot;                 /* Number of unused pcache slots */\n  /* The following value requires a mutex to change.  We skip the mutex on\n  ** reading because (1) most platforms read a 32-bit integer atomically and\n  ** (2) even if an incorrect value is read, no great harm is done since this\n  ** is really just an optimization. */\n  int bUnderPressure;            /* True if low on PAGECACHE memory */\n} pcache1_g;\n\n/*\n** All code in this file should access the global structure above via the\n** alias \"pcache1\". This ensures that the WSD emulation is used when\n** compiling for systems that do not support real WSD.\n*/\n#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g))\n\n/*\n** Macros to enter and leave the PCache LRU mutex.\n*/\n#define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)\n#define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)\n\n/******************************************************************************/\n/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/\n\n/*\n** This function is called during initialization if a static buffer is \n** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE\n** verb to sqlite3_config(). Parameter pBuf points to an allocation large\n** enough to contain 'n' buffers of 'sz' bytes each.\n**\n** This routine is called from sqlite3_initialize() and so it is guaranteed\n** to be serialized already.  There is no need for further mutexing.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){\n  if( pcache1.isInit ){\n    PgFreeslot *p;\n    sz = ROUNDDOWN8(sz);\n    pcache1.szSlot = sz;\n    pcache1.nSlot = pcache1.nFreeSlot = n;\n    pcache1.nReserve = n>90 ? 10 : (n/10 + 1);\n    pcache1.pStart = pBuf;\n    pcache1.pFree = 0;\n    pcache1.bUnderPressure = 0;\n    while( n-- ){\n      p = (PgFreeslot*)pBuf;\n      p->pNext = pcache1.pFree;\n      pcache1.pFree = p;\n      pBuf = (void*)&((char*)pBuf)[sz];\n    }\n    pcache1.pEnd = pBuf;\n  }\n}\n\n/*\n** Malloc function used within this file to allocate space from the buffer\n** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no \n** such buffer exists or there is no space left in it, this function falls \n** back to sqlite3Malloc().\n**\n** Multiple threads can run this routine at the same time.  Global variables\n** in pcache1 need to be protected via mutex.\n*/\nstatic void *pcache1Alloc(int nByte){\n  void *p = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n  if( nByte<=pcache1.szSlot ){\n    sqlite3_mutex_enter(pcache1.mutex);\n    p = (PgHdr1 *)pcache1.pFree;\n    if( p ){\n      pcache1.pFree = pcache1.pFree->pNext;\n      pcache1.nFreeSlot--;\n      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n      assert( pcache1.nFreeSlot>=0 );\n      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);\n    }\n    sqlite3_mutex_leave(pcache1.mutex);\n  }\n  if( p==0 ){\n    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get\n    ** it from sqlite3Malloc instead.\n    */\n    p = sqlite3Malloc(nByte);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    if( p ){\n      int sz = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n  }\n  return p;\n}\n\n/*\n** Free an allocated buffer obtained from pcache1Alloc().\n*/\nstatic int pcache1Free(void *p){\n  int nFreed = 0;\n  if( p==0 ) return 0;\n  if( p>=pcache1.pStart && p<pcache1.pEnd ){\n    PgFreeslot *pSlot;\n    sqlite3_mutex_enter(pcache1.mutex);\n    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);\n    pSlot = (PgFreeslot*)p;\n    pSlot->pNext = pcache1.pFree;\n    pcache1.pFree = pSlot;\n    pcache1.nFreeSlot++;\n    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n    assert( pcache1.nFreeSlot<=pcache1.nSlot );\n    sqlite3_mutex_leave(pcache1.mutex);\n  }else{\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n    nFreed = sqlite3MallocSize(p);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    sqlite3_mutex_enter(pcache1.mutex);\n    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);\n    sqlite3_mutex_leave(pcache1.mutex);\n#endif\n    sqlite3_free(p);\n  }\n  return nFreed;\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** Return the size of a pcache allocation\n*/\nstatic int pcache1MemSize(void *p){\n  if( p>=pcache1.pStart && p<pcache1.pEnd ){\n    return pcache1.szSlot;\n  }else{\n    int iSize;\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n    iSize = sqlite3MallocSize(p);\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n    return iSize;\n  }\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n/*\n** Allocate a new page object initially associated with cache pCache.\n*/\nstatic PgHdr1 *pcache1AllocPage(PCache1 *pCache){\n  PgHdr1 *p = 0;\n  void *pPg;\n\n  /* The group mutex must be released before pcache1Alloc() is called. This\n  ** is because it may call sqlite3_release_memory(), which assumes that \n  ** this mutex is not held. */\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  pcache1LeaveMutex(pCache->pGroup);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n  pPg = pcache1Alloc(pCache->szPage);\n  p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);\n  if( !pPg || !p ){\n    pcache1Free(pPg);\n    sqlite3_free(p);\n    pPg = 0;\n  }\n#else\n  pPg = pcache1Alloc(sizeof(PgHdr1) + pCache->szPage + pCache->szExtra);\n  p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];\n#endif\n  pcache1EnterMutex(pCache->pGroup);\n\n  if( pPg ){\n    p->page.pBuf = pPg;\n    p->page.pExtra = &p[1];\n    if( pCache->bPurgeable ){\n      pCache->pGroup->nCurrentPage++;\n    }\n    return p;\n  }\n  return 0;\n}\n\n/*\n** Free a page object allocated by pcache1AllocPage().\n**\n** The pointer is allowed to be NULL, which is prudent.  But it turns out\n** that the current implementation happens to never call this routine\n** with a NULL pointer, so we mark the NULL test with ALWAYS().\n*/\nstatic void pcache1FreePage(PgHdr1 *p){\n  if( ALWAYS(p) ){\n    PCache1 *pCache = p->pCache;\n    assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );\n    pcache1Free(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    sqlite3_free(p);\n#endif\n    if( pCache->bPurgeable ){\n      pCache->pGroup->nCurrentPage--;\n    }\n  }\n}\n\n/*\n** Malloc function used by SQLite to obtain space from the buffer configured\n** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer\n** exists, this function falls back to sqlite3Malloc().\n*/\nSQLITE_PRIVATE void *sqlite3PageMalloc(int sz){\n  return pcache1Alloc(sz);\n}\n\n/*\n** Free an allocated buffer obtained from sqlite3PageMalloc().\n*/\nSQLITE_PRIVATE void sqlite3PageFree(void *p){\n  pcache1Free(p);\n}\n\n\n/*\n** Return true if it desirable to avoid allocating a new page cache\n** entry.\n**\n** If memory was allocated specifically to the page cache using\n** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then\n** it is desirable to avoid allocating a new page cache entry because\n** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient\n** for all page cache needs and we should not need to spill the\n** allocation onto the heap.\n**\n** Or, the heap is used for all page cache memory but the heap is\n** under memory pressure, then again it is desirable to avoid\n** allocating a new page cache entry in order to avoid stressing\n** the heap even further.\n*/\nstatic int pcache1UnderMemoryPressure(PCache1 *pCache){\n  if( pcache1.nSlot && (pCache->szPage+pCache->szExtra)<=pcache1.szSlot ){\n    return pcache1.bUnderPressure;\n  }else{\n    return sqlite3HeapNearlyFull();\n  }\n}\n\n/******************************************************************************/\n/******** General Implementation Functions ************************************/\n\n/*\n** This function is used to resize the hash table used by the cache passed\n** as the first argument.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic int pcache1ResizeHash(PCache1 *p){\n  PgHdr1 **apNew;\n  unsigned int nNew;\n  unsigned int i;\n\n  assert( sqlite3_mutex_held(p->pGroup->mutex) );\n\n  nNew = p->nHash*2;\n  if( nNew<256 ){\n    nNew = 256;\n  }\n\n  pcache1LeaveMutex(p->pGroup);\n  if( p->nHash ){ sqlite3BeginBenignMalloc(); }\n  apNew = (PgHdr1 **)sqlite3MallocZero(sizeof(PgHdr1 *)*nNew);\n  if( p->nHash ){ sqlite3EndBenignMalloc(); }\n  pcache1EnterMutex(p->pGroup);\n  if( apNew ){\n    for(i=0; i<p->nHash; i++){\n      PgHdr1 *pPage;\n      PgHdr1 *pNext = p->apHash[i];\n      while( (pPage = pNext)!=0 ){\n        unsigned int h = pPage->iKey % nNew;\n        pNext = pPage->pNext;\n        pPage->pNext = apNew[h];\n        apNew[h] = pPage;\n      }\n    }\n    sqlite3_free(p->apHash);\n    p->apHash = apNew;\n    p->nHash = nNew;\n  }\n\n  return (p->apHash ? SQLITE_OK : SQLITE_NOMEM);\n}\n\n/*\n** This function is used internally to remove the page pPage from the \n** PGroup LRU list, if is part of it. If pPage is not part of the PGroup\n** LRU list, then this function is a no-op.\n**\n** The PGroup mutex must be held when this function is called.\n**\n** If pPage is NULL then this routine is a no-op.\n*/\nstatic void pcache1PinPage(PgHdr1 *pPage){\n  PCache1 *pCache;\n  PGroup *pGroup;\n\n  if( pPage==0 ) return;\n  pCache = pPage->pCache;\n  pGroup = pCache->pGroup;\n  assert( sqlite3_mutex_held(pGroup->mutex) );\n  if( pPage->pLruNext || pPage==pGroup->pLruTail ){\n    if( pPage->pLruPrev ){\n      pPage->pLruPrev->pLruNext = pPage->pLruNext;\n    }\n    if( pPage->pLruNext ){\n      pPage->pLruNext->pLruPrev = pPage->pLruPrev;\n    }\n    if( pGroup->pLruHead==pPage ){\n      pGroup->pLruHead = pPage->pLruNext;\n    }\n    if( pGroup->pLruTail==pPage ){\n      pGroup->pLruTail = pPage->pLruPrev;\n    }\n    pPage->pLruNext = 0;\n    pPage->pLruPrev = 0;\n    pPage->pCache->nRecyclable--;\n  }\n}\n\n\n/*\n** Remove the page supplied as an argument from the hash table \n** (PCache1.apHash structure) that it is currently stored in.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic void pcache1RemoveFromHash(PgHdr1 *pPage){\n  unsigned int h;\n  PCache1 *pCache = pPage->pCache;\n  PgHdr1 **pp;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  h = pPage->iKey % pCache->nHash;\n  for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);\n  *pp = (*pp)->pNext;\n\n  pCache->nPage--;\n}\n\n/*\n** If there are currently more than nMaxPage pages allocated, try\n** to recycle pages to reduce the number allocated to nMaxPage.\n*/\nstatic void pcache1EnforceMaxPage(PGroup *pGroup){\n  assert( sqlite3_mutex_held(pGroup->mutex) );\n  while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){\n    PgHdr1 *p = pGroup->pLruTail;\n    assert( p->pCache->pGroup==pGroup );\n    pcache1PinPage(p);\n    pcache1RemoveFromHash(p);\n    pcache1FreePage(p);\n  }\n}\n\n/*\n** Discard all pages from cache pCache with a page number (key value) \n** greater than or equal to iLimit. Any pinned pages that meet this \n** criteria are unpinned before they are discarded.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1TruncateUnsafe(\n  PCache1 *pCache,             /* The cache to truncate */\n  unsigned int iLimit          /* Drop pages with this pgno or larger */\n){\n  TESTONLY( unsigned int nPage = 0; )  /* To assert pCache->nPage is correct */\n  unsigned int h;\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  for(h=0; h<pCache->nHash; h++){\n    PgHdr1 **pp = &pCache->apHash[h]; \n    PgHdr1 *pPage;\n    while( (pPage = *pp)!=0 ){\n      if( pPage->iKey>=iLimit ){\n        pCache->nPage--;\n        *pp = pPage->pNext;\n        pcache1PinPage(pPage);\n        pcache1FreePage(pPage);\n      }else{\n        pp = &pPage->pNext;\n        TESTONLY( nPage++; )\n      }\n    }\n  }\n  assert( pCache->nPage==nPage );\n}\n\n/******************************************************************************/\n/******** sqlite3_pcache Methods **********************************************/\n\n/*\n** Implementation of the sqlite3_pcache.xInit method.\n*/\nstatic int pcache1Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit==0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n  if( sqlite3GlobalConfig.bCoreMutex ){\n    pcache1.grp.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);\n    pcache1.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PMEM);\n  }\n  pcache1.grp.mxPinned = 10;\n  pcache1.isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShutdown method.\n** Note that the static mutex allocated in xInit does \n** not need to be freed.\n*/\nstatic void pcache1Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit!=0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n}\n\n/*\n** Implementation of the sqlite3_pcache.xCreate method.\n**\n** Allocate a new cache.\n*/\nstatic sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){\n  PCache1 *pCache;      /* The newly created page cache */\n  PGroup *pGroup;       /* The group the new page cache will belong to */\n  int sz;               /* Bytes of memory required to allocate the new cache */\n\n  /*\n  ** The seperateCache variable is true if each PCache has its own private\n  ** PGroup.  In other words, separateCache is true for mode (1) where no\n  ** mutexing is required.\n  **\n  **   *  Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT\n  **\n  **   *  Always use a unified cache in single-threaded applications\n  **\n  **   *  Otherwise (if multi-threaded and ENABLE_MEMORY_MANAGEMENT is off)\n  **      use separate caches (mode-1)\n  */\n#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0\n  const int separateCache = 0;\n#else\n  int separateCache = sqlite3GlobalConfig.bCoreMutex>0;\n#endif\n\n  assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );\n  assert( szExtra < 300 );\n\n  sz = sizeof(PCache1) + sizeof(PGroup)*separateCache;\n  pCache = (PCache1 *)sqlite3MallocZero(sz);\n  if( pCache ){\n    if( separateCache ){\n      pGroup = (PGroup*)&pCache[1];\n      pGroup->mxPinned = 10;\n    }else{\n      pGroup = &pcache1.grp;\n    }\n    pCache->pGroup = pGroup;\n    pCache->szPage = szPage;\n    pCache->szExtra = szExtra;\n    pCache->bPurgeable = (bPurgeable ? 1 : 0);\n    if( bPurgeable ){\n      pCache->nMin = 10;\n      pcache1EnterMutex(pGroup);\n      pGroup->nMinPage += pCache->nMin;\n      pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n      pcache1LeaveMutex(pGroup);\n    }\n  }\n  return (sqlite3_pcache *)pCache;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xCachesize method. \n**\n** Configure the cache_size limit for a cache.\n*/\nstatic void pcache1Cachesize(sqlite3_pcache *p, int nMax){\n  PCache1 *pCache = (PCache1 *)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    pcache1EnterMutex(pGroup);\n    pGroup->nMaxPage += (nMax - pCache->nMax);\n    pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n    pCache->nMax = nMax;\n    pCache->n90pct = pCache->nMax*9/10;\n    pcache1EnforceMaxPage(pGroup);\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShrink method. \n**\n** Free up as much memory as possible.\n*/\nstatic void pcache1Shrink(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1*)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    int savedMaxPage;\n    pcache1EnterMutex(pGroup);\n    savedMaxPage = pGroup->nMaxPage;\n    pGroup->nMaxPage = 0;\n    pcache1EnforceMaxPage(pGroup);\n    pGroup->nMaxPage = savedMaxPage;\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xPagecount method. \n*/\nstatic int pcache1Pagecount(sqlite3_pcache *p){\n  int n;\n  PCache1 *pCache = (PCache1*)p;\n  pcache1EnterMutex(pCache->pGroup);\n  n = pCache->nPage;\n  pcache1LeaveMutex(pCache->pGroup);\n  return n;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xFetch method. \n**\n** Fetch a page by key value.\n**\n** Whether or not a new page may be allocated by this function depends on\n** the value of the createFlag argument.  0 means do not allocate a new\n** page.  1 means allocate a new page if space is easily available.  2 \n** means to try really hard to allocate a new page.\n**\n** For a non-purgeable cache (a cache used as the storage for an in-memory\n** database) there is really no difference between createFlag 1 and 2.  So\n** the calling function (pcache.c) will never have a createFlag of 1 on\n** a non-purgeable cache.\n**\n** There are three different approaches to obtaining space for a page,\n** depending on the value of parameter createFlag (which may be 0, 1 or 2).\n**\n**   1. Regardless of the value of createFlag, the cache is searched for a \n**      copy of the requested page. If one is found, it is returned.\n**\n**   2. If createFlag==0 and the page is not already in the cache, NULL is\n**      returned.\n**\n**   3. If createFlag is 1, and the page is not already in the cache, then\n**      return NULL (do not allocate a new page) if any of the following\n**      conditions are true:\n**\n**       (a) the number of pages pinned by the cache is greater than\n**           PCache1.nMax, or\n**\n**       (b) the number of pages pinned by the cache is greater than\n**           the sum of nMax for all purgeable caches, less the sum of \n**           nMin for all other purgeable caches, or\n**\n**   4. If none of the first three conditions apply and the cache is marked\n**      as purgeable, and if one of the following is true:\n**\n**       (a) The number of pages allocated for the cache is already \n**           PCache1.nMax, or\n**\n**       (b) The number of pages allocated for all purgeable caches is\n**           already equal to or greater than the sum of nMax for all\n**           purgeable caches,\n**\n**       (c) The system is under memory pressure and wants to avoid\n**           unnecessary pages cache entry allocations\n**\n**      then attempt to recycle a page from the LRU list. If it is the right\n**      size, return the recycled buffer. Otherwise, free the buffer and\n**      proceed to step 5. \n**\n**   5. Otherwise, allocate and return a new page buffer.\n*/\nstatic sqlite3_pcache_page *pcache1Fetch(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  unsigned int nPinned;\n  PCache1 *pCache = (PCache1 *)p;\n  PGroup *pGroup;\n  PgHdr1 *pPage = 0;\n\n  assert( pCache->bPurgeable || createFlag!=1 );\n  assert( pCache->bPurgeable || pCache->nMin==0 );\n  assert( pCache->bPurgeable==0 || pCache->nMin==10 );\n  assert( pCache->nMin==0 || pCache->bPurgeable );\n  pcache1EnterMutex(pGroup = pCache->pGroup);\n\n  /* Step 1: Search the hash table for an existing entry. */\n  if( pCache->nHash>0 ){\n    unsigned int h = iKey % pCache->nHash;\n    for(pPage=pCache->apHash[h]; pPage&&pPage->iKey!=iKey; pPage=pPage->pNext);\n  }\n\n  /* Step 2: Abort if no existing page is found and createFlag is 0 */\n  if( pPage || createFlag==0 ){\n    pcache1PinPage(pPage);\n    goto fetch_out;\n  }\n\n  /* The pGroup local variable will normally be initialized by the\n  ** pcache1EnterMutex() macro above.  But if SQLITE_MUTEX_OMIT is defined,\n  ** then pcache1EnterMutex() is a no-op, so we have to initialize the\n  ** local variable here.  Delaying the initialization of pGroup is an\n  ** optimization:  The common case is to exit the module before reaching\n  ** this point.\n  */\n#ifdef SQLITE_MUTEX_OMIT\n  pGroup = pCache->pGroup;\n#endif\n\n  /* Step 3: Abort if createFlag is 1 but the cache is nearly full */\n  assert( pCache->nPage >= pCache->nRecyclable );\n  nPinned = pCache->nPage - pCache->nRecyclable;\n  assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );\n  assert( pCache->n90pct == pCache->nMax*9/10 );\n  if( createFlag==1 && (\n        nPinned>=pGroup->mxPinned\n     || nPinned>=pCache->n90pct\n     || pcache1UnderMemoryPressure(pCache)\n  )){\n    goto fetch_out;\n  }\n\n  if( pCache->nPage>=pCache->nHash && pcache1ResizeHash(pCache) ){\n    goto fetch_out;\n  }\n\n  /* Step 4. Try to recycle a page. */\n  if( pCache->bPurgeable && pGroup->pLruTail && (\n         (pCache->nPage+1>=pCache->nMax)\n      || pGroup->nCurrentPage>=pGroup->nMaxPage\n      || pcache1UnderMemoryPressure(pCache)\n  )){\n    PCache1 *pOther;\n    pPage = pGroup->pLruTail;\n    pcache1RemoveFromHash(pPage);\n    pcache1PinPage(pPage);\n    pOther = pPage->pCache;\n\n    /* We want to verify that szPage and szExtra are the same for pOther\n    ** and pCache.  Assert that we can verify this by comparing sums. */\n    assert( (pCache->szPage & (pCache->szPage-1))==0 && pCache->szPage>=512 );\n    assert( pCache->szExtra<512 );\n    assert( (pOther->szPage & (pOther->szPage-1))==0 && pOther->szPage>=512 );\n    assert( pOther->szExtra<512 );\n\n    if( pOther->szPage+pOther->szExtra != pCache->szPage+pCache->szExtra ){\n      pcache1FreePage(pPage);\n      pPage = 0;\n    }else{\n      pGroup->nCurrentPage -= (pOther->bPurgeable - pCache->bPurgeable);\n    }\n  }\n\n  /* Step 5. If a usable page buffer has still not been found, \n  ** attempt to allocate a new one. \n  */\n  if( !pPage ){\n    if( createFlag==1 ) sqlite3BeginBenignMalloc();\n    pPage = pcache1AllocPage(pCache);\n    if( createFlag==1 ) sqlite3EndBenignMalloc();\n  }\n\n  if( pPage ){\n    unsigned int h = iKey % pCache->nHash;\n    pCache->nPage++;\n    pPage->iKey = iKey;\n    pPage->pNext = pCache->apHash[h];\n    pPage->pCache = pCache;\n    pPage->pLruPrev = 0;\n    pPage->pLruNext = 0;\n    *(void **)pPage->page.pExtra = 0;\n    pCache->apHash[h] = pPage;\n  }\n\nfetch_out:\n  if( pPage && iKey>pCache->iMaxKey ){\n    pCache->iMaxKey = iKey;\n  }\n  pcache1LeaveMutex(pGroup);\n  return &pPage->page;\n}\n\n\n/*\n** Implementation of the sqlite3_pcache.xUnpin method.\n**\n** Mark a page as unpinned (eligible for asynchronous recycling).\n*/\nstatic void pcache1Unpin(\n  sqlite3_pcache *p, \n  sqlite3_pcache_page *pPg, \n  int reuseUnlikely\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PGroup *pGroup = pCache->pGroup;\n \n  assert( pPage->pCache==pCache );\n  pcache1EnterMutex(pGroup);\n\n  /* It is an error to call this function if the page is already \n  ** part of the PGroup LRU list.\n  */\n  assert( pPage->pLruPrev==0 && pPage->pLruNext==0 );\n  assert( pGroup->pLruHead!=pPage && pGroup->pLruTail!=pPage );\n\n  if( reuseUnlikely || pGroup->nCurrentPage>pGroup->nMaxPage ){\n    pcache1RemoveFromHash(pPage);\n    pcache1FreePage(pPage);\n  }else{\n    /* Add the page to the PGroup LRU list. */\n    if( pGroup->pLruHead ){\n      pGroup->pLruHead->pLruPrev = pPage;\n      pPage->pLruNext = pGroup->pLruHead;\n      pGroup->pLruHead = pPage;\n    }else{\n      pGroup->pLruTail = pPage;\n      pGroup->pLruHead = pPage;\n    }\n    pCache->nRecyclable++;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xRekey method. \n*/\nstatic void pcache1Rekey(\n  sqlite3_pcache *p,\n  sqlite3_pcache_page *pPg,\n  unsigned int iOld,\n  unsigned int iNew\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PgHdr1 **pp;\n  unsigned int h; \n  assert( pPage->iKey==iOld );\n  assert( pPage->pCache==pCache );\n\n  pcache1EnterMutex(pCache->pGroup);\n\n  h = iOld%pCache->nHash;\n  pp = &pCache->apHash[h];\n  while( (*pp)!=pPage ){\n    pp = &(*pp)->pNext;\n  }\n  *pp = pPage->pNext;\n\n  h = iNew%pCache->nHash;\n  pPage->iKey = iNew;\n  pPage->pNext = pCache->apHash[h];\n  pCache->apHash[h] = pPage;\n  if( iNew>pCache->iMaxKey ){\n    pCache->iMaxKey = iNew;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xTruncate method. \n**\n** Discard all unpinned pages in the cache with a page number equal to\n** or greater than parameter iLimit. Any pinned pages with a page number\n** equal to or greater than iLimit are implicitly unpinned.\n*/\nstatic void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){\n  PCache1 *pCache = (PCache1 *)p;\n  pcache1EnterMutex(pCache->pGroup);\n  if( iLimit<=pCache->iMaxKey ){\n    pcache1TruncateUnsafe(pCache, iLimit);\n    pCache->iMaxKey = iLimit-1;\n  }\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xDestroy method. \n**\n** Destroy a cache allocated using pcache1Create().\n*/\nstatic void pcache1Destroy(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1 *)p;\n  PGroup *pGroup = pCache->pGroup;\n  assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );\n  pcache1EnterMutex(pGroup);\n  pcache1TruncateUnsafe(pCache, 0);\n  assert( pGroup->nMaxPage >= pCache->nMax );\n  pGroup->nMaxPage -= pCache->nMax;\n  assert( pGroup->nMinPage >= pCache->nMin );\n  pGroup->nMinPage -= pCache->nMin;\n  pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n  pcache1EnforceMaxPage(pGroup);\n  pcache1LeaveMutex(pGroup);\n  sqlite3_free(pCache->apHash);\n  sqlite3_free(pCache);\n}\n\n/*\n** This function is called during initialization (sqlite3_initialize()) to\n** install the default pluggable cache module, assuming the user has not\n** already provided an alternative.\n*/\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void){\n  static const sqlite3_pcache_methods2 defaultMethods = {\n    1,                       /* iVersion */\n    0,                       /* pArg */\n    pcache1Init,             /* xInit */\n    pcache1Shutdown,         /* xShutdown */\n    pcache1Create,           /* xCreate */\n    pcache1Cachesize,        /* xCachesize */\n    pcache1Pagecount,        /* xPagecount */\n    pcache1Fetch,            /* xFetch */\n    pcache1Unpin,            /* xUnpin */\n    pcache1Rekey,            /* xRekey */\n    pcache1Truncate,         /* xTruncate */\n    pcache1Destroy,          /* xDestroy */\n    pcache1Shrink            /* xShrink */\n  };\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** This function is called to free superfluous dynamically allocated memory\n** held by the pager system. Memory in use by any SQLite pager allocated\n** by the current thread may be sqlite3_free()ed.\n**\n** nReq is the number of bytes of memory required. Once this much has\n** been released, the function returns. The return value is the total number \n** of bytes of memory released.\n*/\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){\n  int nFree = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  assert( sqlite3_mutex_notheld(pcache1.mutex) );\n  if( pcache1.pStart==0 ){\n    PgHdr1 *p;\n    pcache1EnterMutex(&pcache1.grp);\n    while( (nReq<0 || nFree<nReq) && ((p=pcache1.grp.pLruTail)!=0) ){\n      nFree += pcache1MemSize(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n      nFree += sqlite3MemSize(p);\n#endif\n      pcache1PinPage(p);\n      pcache1RemoveFromHash(p);\n      pcache1FreePage(p);\n    }\n    pcache1LeaveMutex(&pcache1.grp);\n  }\n  return nFree;\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n#ifdef SQLITE_TEST\n/*\n** This function is used by test procedures to inspect the internal state\n** of the global cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheStats(\n  int *pnCurrent,      /* OUT: Total number of pages cached */\n  int *pnMax,          /* OUT: Global maximum cache size */\n  int *pnMin,          /* OUT: Sum of PCache1.nMin for purgeable caches */\n  int *pnRecyclable    /* OUT: Total number of pages available for recycling */\n){\n  PgHdr1 *p;\n  int nRecyclable = 0;\n  for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){\n    nRecyclable++;\n  }\n  *pnCurrent = pcache1.grp.nCurrentPage;\n  *pnMax = (int)pcache1.grp.nMaxPage;\n  *pnMin = (int)pcache1.grp.nMinPage;\n  *pnRecyclable = nRecyclable;\n}\n#endif\n\n/************** End of pcache1.c *********************************************/\n/************** Begin file rowset.c ******************************************/\n/*\n** 2008 December 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements an object we call a \"RowSet\".\n**\n** The RowSet object is a collection of rowids.  Rowids\n** are inserted into the RowSet in an arbitrary order.  Inserts\n** can be intermixed with tests to see if a given rowid has been\n** previously inserted into the RowSet.\n**\n** After all inserts are finished, it is possible to extract the\n** elements of the RowSet in sorted order.  Once this extraction\n** process has started, no new elements may be inserted.\n**\n** Hence, the primitive operations for a RowSet are:\n**\n**    CREATE\n**    INSERT\n**    TEST\n**    SMALLEST\n**    DESTROY\n**\n** The CREATE and DESTROY primitives are the constructor and destructor,\n** obviously.  The INSERT primitive adds a new element to the RowSet.\n** TEST checks to see if an element is already in the RowSet.  SMALLEST\n** extracts the least value from the RowSet.\n**\n** The INSERT primitive might allocate additional memory.  Memory is\n** allocated in chunks so most INSERTs do no allocation.  There is an \n** upper bound on the size of allocated memory.  No memory is freed\n** until DESTROY.\n**\n** The TEST primitive includes a \"batch\" number.  The TEST primitive\n** will only see elements that were inserted before the last change\n** in the batch number.  In other words, if an INSERT occurs between\n** two TESTs where the TESTs have the same batch nubmer, then the\n** value added by the INSERT will not be visible to the second TEST.\n** The initial batch number is zero, so if the very first TEST contains\n** a non-zero batch number, it will see all prior INSERTs.\n**\n** No INSERTs may occurs after a SMALLEST.  An assertion will fail if\n** that is attempted.\n**\n** The cost of an INSERT is roughly constant.  (Sometime new memory\n** has to be allocated on an INSERT.)  The cost of a TEST with a new\n** batch number is O(NlogN) where N is the number of elements in the RowSet.\n** The cost of a TEST using the same batch number is O(logN).  The cost\n** of the first SMALLEST is O(NlogN).  Second and subsequent SMALLEST\n** primitives are constant time.  The cost of DESTROY is O(N).\n**\n** There is an added cost of O(N) when switching between TEST and\n** SMALLEST primitives.\n*/\n\n\n/*\n** Target size for allocation chunks.\n*/\n#define ROWSET_ALLOCATION_SIZE 1024\n\n/*\n** The number of rowset entries per allocation chunk.\n*/\n#define ROWSET_ENTRY_PER_CHUNK  \\\n                       ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry))\n\n/*\n** Each entry in a RowSet is an instance of the following object.\n**\n** This same object is reused to store a linked list of trees of RowSetEntry\n** objects.  In that alternative use, pRight points to the next entry\n** in the list, pLeft points to the tree, and v is unused.  The\n** RowSet.pForest value points to the head of this forest list.\n*/\nstruct RowSetEntry {            \n  i64 v;                        /* ROWID value for this entry */\n  struct RowSetEntry *pRight;   /* Right subtree (larger entries) or list */\n  struct RowSetEntry *pLeft;    /* Left subtree (smaller entries) */\n};\n\n/*\n** RowSetEntry objects are allocated in large chunks (instances of the\n** following structure) to reduce memory allocation overhead.  The\n** chunks are kept on a linked list so that they can be deallocated\n** when the RowSet is destroyed.\n*/\nstruct RowSetChunk {\n  struct RowSetChunk *pNextChunk;        /* Next chunk on list of them all */\n  struct RowSetEntry aEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */\n};\n\n/*\n** A RowSet in an instance of the following structure.\n**\n** A typedef of this structure if found in sqliteInt.h.\n*/\nstruct RowSet {\n  struct RowSetChunk *pChunk;    /* List of all chunk allocations */\n  sqlite3 *db;                   /* The database connection */\n  struct RowSetEntry *pEntry;    /* List of entries using pRight */\n  struct RowSetEntry *pLast;     /* Last entry on the pEntry list */\n  struct RowSetEntry *pFresh;    /* Source of new entry objects */\n  struct RowSetEntry *pForest;   /* List of binary trees of entries */\n  u16 nFresh;                    /* Number of objects on pFresh */\n  u8 rsFlags;                    /* Various flags */\n  u8 iBatch;                     /* Current insert batch */\n};\n\n/*\n** Allowed values for RowSet.rsFlags\n*/\n#define ROWSET_SORTED  0x01   /* True if RowSet.pEntry is sorted */\n#define ROWSET_NEXT    0x02   /* True if sqlite3RowSetNext() has been called */\n\n/*\n** Turn bulk memory into a RowSet object.  N bytes of memory\n** are available at pSpace.  The db pointer is used as a memory context\n** for any subsequent allocations that need to occur.\n** Return a pointer to the new RowSet object.\n**\n** It must be the case that N is sufficient to make a Rowset.  If not\n** an assertion fault occurs.\n** \n** If N is larger than the minimum, use the surplus as an initial\n** allocation of entries available to be filled.\n*/\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsigned int N){\n  RowSet *p;\n  assert( N >= ROUND8(sizeof(*p)) );\n  p = pSpace;\n  p->pChunk = 0;\n  p->db = db;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p);\n  p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry));\n  p->rsFlags = ROWSET_SORTED;\n  p->iBatch = 0;\n  return p;\n}\n\n/*\n** Deallocate all chunks from a RowSet.  This frees all memory that\n** the RowSet has allocated over its lifetime.  This routine is\n** the destructor for the RowSet.\n*/\nSQLITE_PRIVATE void sqlite3RowSetClear(RowSet *p){\n  struct RowSetChunk *pChunk, *pNextChunk;\n  for(pChunk=p->pChunk; pChunk; pChunk = pNextChunk){\n    pNextChunk = pChunk->pNextChunk;\n    sqlite3DbFree(p->db, pChunk);\n  }\n  p->pChunk = 0;\n  p->nFresh = 0;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->rsFlags = ROWSET_SORTED;\n}\n\n/*\n** Allocate a new RowSetEntry object that is associated with the\n** given RowSet.  Return a pointer to the new and completely uninitialized\n** objected.\n**\n** In an OOM situation, the RowSet.db->mallocFailed flag is set and this\n** routine returns NULL.\n*/\nstatic struct RowSetEntry *rowSetEntryAlloc(RowSet *p){\n  assert( p!=0 );\n  if( p->nFresh==0 ){\n    struct RowSetChunk *pNew;\n    pNew = sqlite3DbMallocRaw(p->db, sizeof(*pNew));\n    if( pNew==0 ){\n      return 0;\n    }\n    pNew->pNextChunk = p->pChunk;\n    p->pChunk = pNew;\n    p->pFresh = pNew->aEntry;\n    p->nFresh = ROWSET_ENTRY_PER_CHUNK;\n  }\n  p->nFresh--;\n  return p->pFresh++;\n}\n\n/*\n** Insert a new value into a RowSet.\n**\n** The mallocFailed flag of the database connection is set if a\n** memory allocation fails.\n*/\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){\n  struct RowSetEntry *pEntry;  /* The new entry */\n  struct RowSetEntry *pLast;   /* The last prior entry */\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );\n\n  pEntry = rowSetEntryAlloc(p);\n  if( pEntry==0 ) return;\n  pEntry->v = rowid;\n  pEntry->pRight = 0;\n  pLast = p->pLast;\n  if( pLast ){\n    if( (p->rsFlags & ROWSET_SORTED)!=0 && rowid<=pLast->v ){\n      p->rsFlags &= ~ROWSET_SORTED;\n    }\n    pLast->pRight = pEntry;\n  }else{\n    p->pEntry = pEntry;\n  }\n  p->pLast = pEntry;\n}\n\n/*\n** Merge two lists of RowSetEntry objects.  Remove duplicates.\n**\n** The input lists are connected via pRight pointers and are \n** assumed to each already be in sorted order.\n*/\nstatic struct RowSetEntry *rowSetEntryMerge(\n  struct RowSetEntry *pA,    /* First sorted list to be merged */\n  struct RowSetEntry *pB     /* Second sorted list to be merged */\n){\n  struct RowSetEntry head;\n  struct RowSetEntry *pTail;\n\n  pTail = &head;\n  while( pA && pB ){\n    assert( pA->pRight==0 || pA->v<=pA->pRight->v );\n    assert( pB->pRight==0 || pB->v<=pB->pRight->v );\n    if( pA->v<pB->v ){\n      pTail->pRight = pA;\n      pA = pA->pRight;\n      pTail = pTail->pRight;\n    }else if( pB->v<pA->v ){\n      pTail->pRight = pB;\n      pB = pB->pRight;\n      pTail = pTail->pRight;\n    }else{\n      pA = pA->pRight;\n    }\n  }\n  if( pA ){\n    assert( pA->pRight==0 || pA->v<=pA->pRight->v );\n    pTail->pRight = pA;\n  }else{\n    assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v );\n    pTail->pRight = pB;\n  }\n  return head.pRight;\n}\n\n/*\n** Sort all elements on the list of RowSetEntry objects into order of\n** increasing v.\n*/ \nstatic struct RowSetEntry *rowSetEntrySort(struct RowSetEntry *pIn){\n  unsigned int i;\n  struct RowSetEntry *pNext, *aBucket[40];\n\n  memset(aBucket, 0, sizeof(aBucket));\n  while( pIn ){\n    pNext = pIn->pRight;\n    pIn->pRight = 0;\n    for(i=0; aBucket[i]; i++){\n      pIn = rowSetEntryMerge(aBucket[i], pIn);\n      aBucket[i] = 0;\n    }\n    aBucket[i] = pIn;\n    pIn = pNext;\n  }\n  pIn = 0;\n  for(i=0; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){\n    pIn = rowSetEntryMerge(pIn, aBucket[i]);\n  }\n  return pIn;\n}\n\n\n/*\n** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects.\n** Convert this tree into a linked list connected by the pRight pointers\n** and return pointers to the first and last elements of the new list.\n*/\nstatic void rowSetTreeToList(\n  struct RowSetEntry *pIn,         /* Root of the input tree */\n  struct RowSetEntry **ppFirst,    /* Write head of the output list here */\n  struct RowSetEntry **ppLast      /* Write tail of the output list here */\n){\n  assert( pIn!=0 );\n  if( pIn->pLeft ){\n    struct RowSetEntry *p;\n    rowSetTreeToList(pIn->pLeft, ppFirst, &p);\n    p->pRight = pIn;\n  }else{\n    *ppFirst = pIn;\n  }\n  if( pIn->pRight ){\n    rowSetTreeToList(pIn->pRight, &pIn->pRight, ppLast);\n  }else{\n    *ppLast = pIn;\n  }\n  assert( (*ppLast)->pRight==0 );\n}\n\n\n/*\n** Convert a sorted list of elements (connected by pRight) into a binary\n** tree with depth of iDepth.  A depth of 1 means the tree contains a single\n** node taken from the head of *ppList.  A depth of 2 means a tree with\n** three nodes.  And so forth.\n**\n** Use as many entries from the input list as required and update the\n** *ppList to point to the unused elements of the list.  If the input\n** list contains too few elements, then construct an incomplete tree\n** and leave *ppList set to NULL.\n**\n** Return a pointer to the root of the constructed binary tree.\n*/\nstatic struct RowSetEntry *rowSetNDeepTree(\n  struct RowSetEntry **ppList,\n  int iDepth\n){\n  struct RowSetEntry *p;         /* Root of the new tree */\n  struct RowSetEntry *pLeft;     /* Left subtree */\n  if( *ppList==0 ){\n    return 0;\n  }\n  if( iDepth==1 ){\n    p = *ppList;\n    *ppList = p->pRight;\n    p->pLeft = p->pRight = 0;\n    return p;\n  }\n  pLeft = rowSetNDeepTree(ppList, iDepth-1);\n  p = *ppList;\n  if( p==0 ){\n    return pLeft;\n  }\n  p->pLeft = pLeft;\n  *ppList = p->pRight;\n  p->pRight = rowSetNDeepTree(ppList, iDepth-1);\n  return p;\n}\n\n/*\n** Convert a sorted list of elements into a binary tree. Make the tree\n** as deep as it needs to be in order to contain the entire list.\n*/\nstatic struct RowSetEntry *rowSetListToTree(struct RowSetEntry *pList){\n  int iDepth;           /* Depth of the tree so far */\n  struct RowSetEntry *p;       /* Current tree root */\n  struct RowSetEntry *pLeft;   /* Left subtree */\n\n  assert( pList!=0 );\n  p = pList;\n  pList = p->pRight;\n  p->pLeft = p->pRight = 0;\n  for(iDepth=1; pList; iDepth++){\n    pLeft = p;\n    p = pList;\n    pList = p->pRight;\n    p->pLeft = pLeft;\n    p->pRight = rowSetNDeepTree(&pList, iDepth);\n  }\n  return p;\n}\n\n/*\n** Take all the entries on p->pEntry and on the trees in p->pForest and\n** sort them all together into one big ordered list on p->pEntry.\n**\n** This routine should only be called once in the life of a RowSet.\n*/\nstatic void rowSetToList(RowSet *p){\n\n  /* This routine is called only once */\n  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );\n\n  if( (p->rsFlags & ROWSET_SORTED)==0 ){\n    p->pEntry = rowSetEntrySort(p->pEntry);\n  }\n\n  /* While this module could theoretically support it, sqlite3RowSetNext()\n  ** is never called after sqlite3RowSetText() for the same RowSet.  So\n  ** there is never a forest to deal with.  Should this change, simply\n  ** remove the assert() and the #if 0. */\n  assert( p->pForest==0 );\n#if 0\n  while( p->pForest ){\n    struct RowSetEntry *pTree = p->pForest->pLeft;\n    if( pTree ){\n      struct RowSetEntry *pHead, *pTail;\n      rowSetTreeToList(pTree, &pHead, &pTail);\n      p->pEntry = rowSetEntryMerge(p->pEntry, pHead);\n    }\n    p->pForest = p->pForest->pRight;\n  }\n#endif\n  p->rsFlags |= ROWSET_NEXT;  /* Verify this routine is never called again */\n}\n\n/*\n** Extract the smallest element from the RowSet.\n** Write the element into *pRowid.  Return 1 on success.  Return\n** 0 if the RowSet is already empty.\n**\n** After this routine has been called, the sqlite3RowSetInsert()\n** routine may not be called again.  \n*/\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet *p, i64 *pRowid){\n  assert( p!=0 );\n\n  /* Merge the forest into a single sorted list on first call */\n  if( (p->rsFlags & ROWSET_NEXT)==0 ) rowSetToList(p);\n\n  /* Return the next entry on the list */\n  if( p->pEntry ){\n    *pRowid = p->pEntry->v;\n    p->pEntry = p->pEntry->pRight;\n    if( p->pEntry==0 ){\n      sqlite3RowSetClear(p);\n    }\n    return 1;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Check to see if element iRowid was inserted into the rowset as\n** part of any insert batch prior to iBatch.  Return 1 or 0.\n**\n** If this is the first test of a new batch and if there exist entires\n** on pRowSet->pEntry, then sort those entires into the forest at\n** pRowSet->pForest so that they can be tested.\n*/\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, u8 iBatch, sqlite3_int64 iRowid){\n  struct RowSetEntry *p, *pTree;\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );\n\n  /* Sort entries into the forest on the first test of a new batch \n  */\n  if( iBatch!=pRowSet->iBatch ){\n    p = pRowSet->pEntry;\n    if( p ){\n      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;\n      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){\n        p = rowSetEntrySort(p);\n      }\n      for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n        ppPrevTree = &pTree->pRight;\n        if( pTree->pLeft==0 ){\n          pTree->pLeft = rowSetListToTree(p);\n          break;\n        }else{\n          struct RowSetEntry *pAux, *pTail;\n          rowSetTreeToList(pTree->pLeft, &pAux, &pTail);\n          pTree->pLeft = 0;\n          p = rowSetEntryMerge(pAux, p);\n        }\n      }\n      if( pTree==0 ){\n        *ppPrevTree = pTree = rowSetEntryAlloc(pRowSet);\n        if( pTree ){\n          pTree->v = 0;\n          pTree->pRight = 0;\n          pTree->pLeft = rowSetListToTree(p);\n        }\n      }\n      pRowSet->pEntry = 0;\n      pRowSet->pLast = 0;\n      pRowSet->rsFlags |= ROWSET_SORTED;\n    }\n    pRowSet->iBatch = iBatch;\n  }\n\n  /* Test to see if the iRowid value appears anywhere in the forest.\n  ** Return 1 if it does and 0 if not.\n  */\n  for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n    p = pTree->pLeft;\n    while( p ){\n      if( p->v<iRowid ){\n        p = p->pRight;\n      }else if( p->v>iRowid ){\n        p = p->pLeft;\n      }else{\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/************** End of rowset.c **********************************************/\n/************** Begin file pager.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of the page cache subsystem or \"pager\".\n** \n** The pager is used to access a database disk file.  It implements\n** atomic commit and rollback through the use of a journal file that\n** is separate from the database file.  The pager also implements file\n** locking to prevent two processes from writing the same database\n** file simultaneously, or one process from reading the database while\n** another is writing.\n*/\n#ifndef SQLITE_OMIT_DISKIO\n/************** Include wal.h in the middle of pager.c ***********************/\n/************** Begin file wal.h *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface to the write-ahead logging \n** system. Refer to the comments below and the header comment attached to \n** the implementation of each function in log.c for further details.\n*/\n\n#ifndef _WAL_H_\n#define _WAL_H_\n\n\n/* Additional values that can be added to the sync_flags argument of\n** sqlite3WalFrames():\n*/\n#define WAL_SYNC_TRANSACTIONS  0x20   /* Sync at the end of each transaction */\n#define SQLITE_SYNC_MASK       0x13   /* Mask off the SQLITE_SYNC_* values */\n\n#ifdef SQLITE_OMIT_WAL\n# define sqlite3WalOpen(x,y,z)                   0\n# define sqlite3WalLimit(x,y)\n# define sqlite3WalClose(w,x,y,z)                0\n# define sqlite3WalBeginReadTransaction(y,z)     0\n# define sqlite3WalEndReadTransaction(z)\n# define sqlite3WalDbsize(y)                     0\n# define sqlite3WalBeginWriteTransaction(y)      0\n# define sqlite3WalEndWriteTransaction(x)        0\n# define sqlite3WalUndo(x,y,z)                   0\n# define sqlite3WalSavepoint(y,z)\n# define sqlite3WalSavepointUndo(y,z)            0\n# define sqlite3WalFrames(u,v,w,x,y,z)           0\n# define sqlite3WalCheckpoint(r,s,t,u,v,w,x,y,z) 0\n# define sqlite3WalCallback(z)                   0\n# define sqlite3WalExclusiveMode(y,z)            0\n# define sqlite3WalHeapMemory(z)                 0\n# define sqlite3WalFramesize(z)                  0\n# define sqlite3WalFindFrame(x,y,z)              0\n#else\n\n#define WAL_SAVEPOINT_NDATA 4\n\n/* Connection to a write-ahead log (WAL) file. \n** There is one object of this type for each pager. \n*/\ntypedef struct Wal Wal;\n\n/* Open and close a connection to a write-ahead log. */\nSQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);\nSQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, int sync_flags, int, u8 *);\n\n/* Set the limiting size of a WAL file. */\nSQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);\n\n/* Used by readers to open (lock) and close (unlock) a snapshot.  A \n** snapshot is like a read-transaction.  It is the state of the database\n** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and\n** preserves the current state even if the other threads or processes\n** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the\n** transaction and releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *);\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal);\n\n/* Read a page from the write-ahead log, if it is present. */\nSQLITE_PRIVATE int sqlite3WalFindFrame(Wal *, Pgno, u32 *);\nSQLITE_PRIVATE int sqlite3WalReadFrame(Wal *, u32, int, u8 *);\n\n/* If the WAL is not empty, return the size of the database. */\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal);\n\n/* Obtain or release the WRITER lock. */\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal);\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal);\n\n/* Undo any frames written (but not committed) to the log */\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);\n\n/* Return an integer that records the current (uncommitted) write\n** position in the WAL */\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);\n\n/* Move the write position of the WAL back to iFrame.  Called in\n** response to a ROLLBACK TO command. */\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);\n\n/* Write a frame or frames to the log. */\nSQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);\n\n/* Copy pages from the log to the database file */ \nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Write-ahead log connection */\n  int eMode,                      /* One of PASSIVE, FULL and RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of buffer nBuf */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n);\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal);\n\n/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)\n** by the pager layer on the database file.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op);\n\n/* Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal);\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/* If the WAL file is not empty, return the number of bytes of content\n** stored in each frame (i.e. the db page-size when the WAL was created).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal);\n#endif\n\n#endif /* ifndef SQLITE_OMIT_WAL */\n#endif /* _WAL_H_ */\n\n/************** End of wal.h *************************************************/\n/************** Continuing where we left off in pager.c **********************/\n\n\n/******************* NOTES ON THE DESIGN OF THE PAGER ************************\n**\n** This comment block describes invariants that hold when using a rollback\n** journal.  These invariants do not apply for journal_mode=WAL,\n** journal_mode=MEMORY, or journal_mode=OFF.\n**\n** Within this comment block, a page is deemed to have been synced\n** automatically as soon as it is written when PRAGMA synchronous=OFF.\n** Otherwise, the page is not synced until the xSync method of the VFS\n** is called successfully on the file containing the page.\n**\n** Definition:  A page of the database file is said to be \"overwriteable\" if\n** one or more of the following are true about the page:\n** \n**     (a)  The original content of the page as it was at the beginning of\n**          the transaction has been written into the rollback journal and\n**          synced.\n** \n**     (b)  The page was a freelist leaf page at the start of the transaction.\n** \n**     (c)  The page number is greater than the largest page that existed in\n**          the database file at the start of the transaction.\n** \n** (1) A page of the database file is never overwritten unless one of the\n**     following are true:\n** \n**     (a) The page and all other pages on the same sector are overwriteable.\n** \n**     (b) The atomic page write optimization is enabled, and the entire\n**         transaction other than the update of the transaction sequence\n**         number consists of a single page change.\n** \n** (2) The content of a page written into the rollback journal exactly matches\n**     both the content in the database when the rollback journal was written\n**     and the content in the database at the beginning of the current\n**     transaction.\n** \n** (3) Writes to the database file are an integer multiple of the page size\n**     in length and are aligned on a page boundary.\n** \n** (4) Reads from the database file are either aligned on a page boundary and\n**     an integer multiple of the page size in length or are taken from the\n**     first 100 bytes of the database file.\n** \n** (5) All writes to the database file are synced prior to the rollback journal\n**     being deleted, truncated, or zeroed.\n** \n** (6) If a master journal file is used, then all writes to the database file\n**     are synced prior to the master journal being deleted.\n** \n** Definition: Two databases (or the same database at two points it time)\n** are said to be \"logically equivalent\" if they give the same answer to\n** all queries.  Note in particular the content of freelist leaf\n** pages can be changed arbitarily without effecting the logical equivalence\n** of the database.\n** \n** (7) At any time, if any subset, including the empty set and the total set,\n**     of the unsynced changes to a rollback journal are removed and the \n**     journal is rolled back, the resulting database file will be logical\n**     equivalent to the database file at the beginning of the transaction.\n** \n** (8) When a transaction is rolled back, the xTruncate method of the VFS\n**     is called to restore the database file to the same size it was at\n**     the beginning of the transaction.  (In some VFSes, the xTruncate\n**     method is a no-op, but that does not change the fact the SQLite will\n**     invoke it.)\n** \n** (9) Whenever the database file is modified, at least one bit in the range\n**     of bytes from 24 through 39 inclusive will be changed prior to releasing\n**     the EXCLUSIVE lock, thus signaling other connections on the same\n**     database to flush their caches.\n**\n** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less\n**      than one billion transactions.\n**\n** (11) A database file is well-formed at the beginning and at the conclusion\n**      of every transaction.\n**\n** (12) An EXCLUSIVE lock is held on the database file when writing to\n**      the database file.\n**\n** (13) A SHARED lock is held on the database file while reading any\n**      content out of the database file.\n**\n******************************************************************************/\n\n/*\n** Macros for troubleshooting.  Normally turned off\n*/\n#if 0\nint sqlite3PagerTrace=1;  /* True to enable tracing */\n#define sqlite3DebugPrintf printf\n#define PAGERTRACE(X)     if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; }\n#else\n#define PAGERTRACE(X)\n#endif\n\n/*\n** The following two macros are used within the PAGERTRACE() macros above\n** to print out file-descriptors. \n**\n** PAGERID() takes a pointer to a Pager struct as its argument. The\n** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file\n** struct as its argument.\n*/\n#define PAGERID(p) ((int)(p->fd))\n#define FILEHANDLEID(fd) ((int)fd)\n\n/*\n** The Pager.eState variable stores the current 'state' of a pager. A\n** pager may be in any one of the seven states shown in the following\n** state diagram.\n**\n**                            OPEN <------+------+\n**                              |         |      |\n**                              V         |      |\n**               +---------> READER-------+      |\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_LOCKED------> ERROR\n**               |              |                ^  \n**               |              V                |\n**               |<------WRITER_CACHEMOD-------->|\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_DBMOD---------->|\n**               |              |                |\n**               |              V                |\n**               +<------WRITER_FINISHED-------->+\n**\n**\n** List of state transitions and the C [function] that performs each:\n** \n**   OPEN              -> READER              [sqlite3PagerSharedLock]\n**   READER            -> OPEN                [pager_unlock]\n**\n**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]\n**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]\n**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]\n**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]\n**   WRITER_***        -> READER              [pager_end_transaction]\n**\n**   WRITER_***        -> ERROR               [pager_error]\n**   ERROR             -> OPEN                [pager_unlock]\n** \n**\n**  OPEN:\n**\n**    The pager starts up in this state. Nothing is guaranteed in this\n**    state - the file may or may not be locked and the database size is\n**    unknown. The database may not be read or written.\n**\n**    * No read or write transaction is active.\n**    * Any lock, or no lock at all, may be held on the database file.\n**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.\n**\n**  READER:\n**\n**    In this state all the requirements for reading the database in \n**    rollback (non-WAL) mode are met. Unless the pager is (or recently\n**    was) in exclusive-locking mode, a user-level read transaction is \n**    open. The database size is known in this state.\n**\n**    A connection running with locking_mode=normal enters this state when\n**    it opens a read-transaction on the database and returns to state\n**    OPEN after the read-transaction is completed. However a connection\n**    running in locking_mode=exclusive (including temp databases) remains in\n**    this state even after the read-transaction is closed. The only way\n**    a locking_mode=exclusive connection can transition from READER to OPEN\n**    is via the ERROR state (see below).\n** \n**    * A read transaction may be active (but a write-transaction cannot).\n**    * A SHARED or greater lock is held on the database file.\n**    * The dbSize variable may be trusted (even if a user-level read \n**      transaction is not active). The dbOrigSize and dbFileSize variables\n**      may not be trusted at this point.\n**    * If the database is a WAL database, then the WAL connection is open.\n**    * Even if a read-transaction is not open, it is guaranteed that \n**      there is no hot-journal in the file-system.\n**\n**  WRITER_LOCKED:\n**\n**    The pager moves to this state from READER when a write-transaction\n**    is first opened on the database. In WRITER_LOCKED state, all locks \n**    required to start a write-transaction are held, but no actual \n**    modifications to the cache or database have taken place.\n**\n**    In rollback mode, a RESERVED or (if the transaction was opened with \n**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when\n**    moving to this state, but the journal file is not written to or opened \n**    to in this state. If the transaction is committed or rolled back while \n**    in WRITER_LOCKED state, all that is required is to unlock the database \n**    file.\n**\n**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.\n**    If the connection is running with locking_mode=exclusive, an attempt\n**    is made to obtain an EXCLUSIVE lock on the database file.\n**\n**    * A write transaction is active.\n**    * If the connection is open in rollback-mode, a RESERVED or greater \n**      lock is held on the database file.\n**    * If the connection is open in WAL-mode, a WAL write transaction\n**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully\n**      called).\n**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.\n**    * The contents of the pager cache have not been modified.\n**    * The journal file may or may not be open.\n**    * Nothing (not even the first header) has been written to the journal.\n**\n**  WRITER_CACHEMOD:\n**\n**    A pager moves from WRITER_LOCKED state to this state when a page is\n**    first modified by the upper layer. In rollback mode the journal file\n**    is opened (if it is not already open) and a header written to the\n**    start of it. The database file on disk has not been modified.\n**\n**    * A write transaction is active.\n**    * A RESERVED or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      to it, but the header has not been synced to disk.\n**    * The contents of the page cache have been modified.\n**\n**  WRITER_DBMOD:\n**\n**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state\n**    when it modifies the contents of the database file. WAL connections\n**    never enter this state (since they do not modify the database file,\n**    just the log file).\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      and synced to disk.\n**    * The contents of the page cache have been modified (and possibly\n**      written to disk).\n**\n**  WRITER_FINISHED:\n**\n**    It is not possible for a WAL connection to enter this state.\n**\n**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD\n**    state after the entire transaction has been successfully written into the\n**    database file. In this state the transaction may be committed simply\n**    by finalizing the journal file. Once in WRITER_FINISHED state, it is \n**    not possible to modify the database further. At this point, the upper \n**    layer must either commit or rollback the transaction.\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * All writing and syncing of journal and database data has finished.\n**      If no error occurred, all that remains is to finalize the journal to\n**      commit the transaction. If an error did occur, the caller will need\n**      to rollback the transaction. \n**\n**  ERROR:\n**\n**    The ERROR state is entered when an IO or disk-full error (including\n**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it \n**    difficult to be sure that the in-memory pager state (cache contents, \n**    db size etc.) are consistent with the contents of the file-system.\n**\n**    Temporary pager files may enter the ERROR state, but in-memory pagers\n**    cannot.\n**\n**    For example, if an IO error occurs while performing a rollback, \n**    the contents of the page-cache may be left in an inconsistent state.\n**    At this point it would be dangerous to change back to READER state\n**    (as usually happens after a rollback). Any subsequent readers might\n**    report database corruption (due to the inconsistent cache), and if\n**    they upgrade to writers, they may inadvertently corrupt the database\n**    file. To avoid this hazard, the pager switches into the ERROR state\n**    instead of READER following such an error.\n**\n**    Once it has entered the ERROR state, any attempt to use the pager\n**    to read or write data returns an error. Eventually, once all \n**    outstanding transactions have been abandoned, the pager is able to\n**    transition back to OPEN state, discarding the contents of the \n**    page-cache and any other in-memory state at the same time. Everything\n**    is reloaded from disk (and, if necessary, hot-journal rollback peformed)\n**    when a read-transaction is next opened on the pager (transitioning\n**    the pager into READER state). At that point the system has recovered \n**    from the error.\n**\n**    Specifically, the pager jumps into the ERROR state if:\n**\n**      1. An error occurs while attempting a rollback. This happens in\n**         function sqlite3PagerRollback().\n**\n**      2. An error occurs while attempting to finalize a journal file\n**         following a commit in function sqlite3PagerCommitPhaseTwo().\n**\n**      3. An error occurs while attempting to write to the journal or\n**         database file in function pagerStress() in order to free up\n**         memory.\n**\n**    In other cases, the error is returned to the b-tree layer. The b-tree\n**    layer then attempts a rollback operation. If the error condition \n**    persists, the pager enters the ERROR state via condition (1) above.\n**\n**    Condition (3) is necessary because it can be triggered by a read-only\n**    statement executed within a transaction. In this case, if the error\n**    code were simply returned to the user, the b-tree layer would not\n**    automatically attempt a rollback, as it assumes that an error in a\n**    read-only statement cannot leave the pager in an internally inconsistent \n**    state.\n**\n**    * The Pager.errCode variable is set to something other than SQLITE_OK.\n**    * There are one or more outstanding references to pages (after the\n**      last reference is dropped the pager should move back to OPEN state).\n**    * The pager is not an in-memory pager.\n**    \n**\n** Notes:\n**\n**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the\n**     connection is open in WAL mode. A WAL connection is always in one\n**     of the first four states.\n**\n**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN\n**     state. There are two exceptions: immediately after exclusive-mode has\n**     been turned on (and before any read or write transactions are \n**     executed), and when the pager is leaving the \"error state\".\n**\n**   * See also: assert_pager_state().\n*/\n#define PAGER_OPEN                  0\n#define PAGER_READER                1\n#define PAGER_WRITER_LOCKED         2\n#define PAGER_WRITER_CACHEMOD       3\n#define PAGER_WRITER_DBMOD          4\n#define PAGER_WRITER_FINISHED       5\n#define PAGER_ERROR                 6\n\n/*\n** The Pager.eLock variable is almost always set to one of the \n** following locking-states, according to the lock currently held on\n** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n** This variable is kept up to date as locks are taken and released by\n** the pagerLockDb() and pagerUnlockDb() wrappers.\n**\n** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY\n** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not\n** the operation was successful. In these circumstances pagerLockDb() and\n** pagerUnlockDb() take a conservative approach - eLock is always updated\n** when unlocking the file, and only updated when locking the file if the\n** VFS call is successful. This way, the Pager.eLock variable may be set\n** to a less exclusive (lower) value than the lock that is actually held\n** at the system level, but it is never set to a more exclusive value.\n**\n** This is usually safe. If an xUnlock fails or appears to fail, there may \n** be a few redundant xLock() calls or a lock may be held for longer than\n** required, but nothing really goes wrong.\n**\n** The exception is when the database file is unlocked as the pager moves\n** from ERROR to OPEN state. At this point there may be a hot-journal file \n** in the file-system that needs to be rolled back (as part of a OPEN->SHARED\n** transition, by the same pager or any other). If the call to xUnlock()\n** fails at this point and the pager is left holding an EXCLUSIVE lock, this\n** can confuse the call to xCheckReservedLock() call made later as part\n** of hot-journal detection.\n**\n** xCheckReservedLock() is defined as returning true \"if there is a RESERVED \n** lock held by this process or any others\". So xCheckReservedLock may \n** return true because the caller itself is holding an EXCLUSIVE lock (but\n** doesn't know it because of a previous error in xUnlock). If this happens\n** a hot-journal may be mistaken for a journal being created by an active\n** transaction in another process, causing SQLite to read from the database\n** without rolling it back.\n**\n** To work around this, if a call to xUnlock() fails when unlocking the\n** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It\n** is only changed back to a real locking state after a successful call\n** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition\n** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK \n** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE\n** lock on the database file before attempting to roll it back. See function\n** PagerSharedLock() for more detail.\n**\n** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in \n** PAGER_OPEN state.\n*/\n#define UNKNOWN_LOCK                (EXCLUSIVE_LOCK+1)\n\n/*\n** A macro used for invoking the codec if there is one\n*/\n#ifdef SQLITE_HAS_CODEC\n# define CODEC1(P,D,N,X,E) \\\n    if( P->xCodec && P->xCodec(P->pCodec,D,N,X)==0 ){ E; }\n# define CODEC2(P,D,N,X,E,O) \\\n    if( P->xCodec==0 ){ O=(char*)D; }else \\\n    if( (O=(char*)(P->xCodec(P->pCodec,D,N,X)))==0 ){ E; }\n#else\n# define CODEC1(P,D,N,X,E)   /* NO-OP */\n# define CODEC2(P,D,N,X,E,O) O=(char*)D\n#endif\n\n/*\n** The maximum allowed sector size. 64KiB. If the xSectorsize() method \n** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.\n** This could conceivably cause corruption following a power failure on\n** such a system. This is currently an undocumented limit.\n*/\n#define MAX_SECTOR_SIZE 0x10000\n\n/*\n** An instance of the following structure is allocated for each active\n** savepoint and statement transaction in the system. All such structures\n** are stored in the Pager.aSavepoint[] array, which is allocated and\n** resized using sqlite3Realloc().\n**\n** When a savepoint is created, the PagerSavepoint.iHdrOffset field is\n** set to 0. If a journal-header is written into the main journal while\n** the savepoint is active, then iHdrOffset is set to the byte offset \n** immediately following the last journal record written into the main\n** journal before the journal-header. This is required during savepoint\n** rollback (see pagerPlaybackSavepoint()).\n*/\ntypedef struct PagerSavepoint PagerSavepoint;\nstruct PagerSavepoint {\n  i64 iOffset;                 /* Starting offset in main journal */\n  i64 iHdrOffset;              /* See above */\n  Bitvec *pInSavepoint;        /* Set of pages in this savepoint */\n  Pgno nOrig;                  /* Original number of pages in file */\n  Pgno iSubRec;                /* Index of first record in sub-journal */\n#ifndef SQLITE_OMIT_WAL\n  u32 aWalData[WAL_SAVEPOINT_NDATA];        /* WAL savepoint context */\n#endif\n};\n\n/*\n** A open page cache is an instance of struct Pager. A description of\n** some of the more important member variables follows:\n**\n** eState\n**\n**   The current 'state' of the pager object. See the comment and state\n**   diagram above for a description of the pager state.\n**\n** eLock\n**\n**   For a real on-disk database, the current lock held on the database file -\n**   NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n**\n**   For a temporary or in-memory database (neither of which require any\n**   locks), this variable is always set to EXCLUSIVE_LOCK. Since such\n**   databases always have Pager.exclusiveMode==1, this tricks the pager\n**   logic into thinking that it already has all the locks it will ever\n**   need (and no reason to release them).\n**\n**   In some (obscure) circumstances, this variable may also be set to\n**   UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for\n**   details.\n**\n** changeCountDone\n**\n**   This boolean variable is used to make sure that the change-counter \n**   (the 4-byte header field at byte offset 24 of the database file) is \n**   not updated more often than necessary. \n**\n**   It is set to true when the change-counter field is updated, which \n**   can only happen if an exclusive lock is held on the database file.\n**   It is cleared (set to false) whenever an exclusive lock is \n**   relinquished on the database file. Each time a transaction is committed,\n**   The changeCountDone flag is inspected. If it is true, the work of\n**   updating the change-counter is omitted for the current transaction.\n**\n**   This mechanism means that when running in exclusive mode, a connection \n**   need only update the change-counter once, for the first transaction\n**   committed.\n**\n** setMaster\n**\n**   When PagerCommitPhaseOne() is called to commit a transaction, it may\n**   (or may not) specify a master-journal name to be written into the \n**   journal file before it is synced to disk.\n**\n**   Whether or not a journal file contains a master-journal pointer affects \n**   the way in which the journal file is finalized after the transaction is \n**   committed or rolled back when running in \"journal_mode=PERSIST\" mode.\n**   If a journal file does not contain a master-journal pointer, it is\n**   finalized by overwriting the first journal header with zeroes. If\n**   it does contain a master-journal pointer the journal file is finalized \n**   by truncating it to zero bytes, just as if the connection were \n**   running in \"journal_mode=truncate\" mode.\n**\n**   Journal files that contain master journal pointers cannot be finalized\n**   simply by overwriting the first journal-header with zeroes, as the\n**   master journal pointer could interfere with hot-journal rollback of any\n**   subsequently interrupted transaction that reuses the journal file.\n**\n**   The flag is cleared as soon as the journal file is finalized (either\n**   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the\n**   journal file from being successfully finalized, the setMaster flag\n**   is cleared anyway (and the pager will move to ERROR state).\n**\n** doNotSpill, doNotSyncSpill\n**\n**   These two boolean variables control the behavior of cache-spills\n**   (calls made by the pcache module to the pagerStress() routine to\n**   write cached data to the file-system in order to free up memory).\n**\n**   When doNotSpill is non-zero, writing to the database from pagerStress()\n**   is disabled altogether. This is done in a very obscure case that\n**   comes up during savepoint rollback that requires the pcache module\n**   to allocate a new page to prevent the journal file from being written\n**   while it is being traversed by code in pager_playback().\n** \n**   If doNotSyncSpill is non-zero, writing to the database from pagerStress()\n**   is permitted, but syncing the journal file is not. This flag is set\n**   by sqlite3PagerWrite() when the file-system sector-size is larger than\n**   the database page-size in order to prevent a journal sync from happening \n**   in between the journalling of two pages on the same sector. \n**\n** subjInMemory\n**\n**   This is a boolean variable. If true, then any required sub-journal\n**   is opened as an in-memory journal file. If false, then in-memory\n**   sub-journals are only used for in-memory pager files.\n**\n**   This variable is updated by the upper layer each time a new \n**   write-transaction is opened.\n**\n** dbSize, dbOrigSize, dbFileSize\n**\n**   Variable dbSize is set to the number of pages in the database file.\n**   It is valid in PAGER_READER and higher states (all states except for\n**   OPEN and ERROR). \n**\n**   dbSize is set based on the size of the database file, which may be \n**   larger than the size of the database (the value stored at offset\n**   28 of the database header by the btree). If the size of the file\n**   is not an integer multiple of the page-size, the value stored in\n**   dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).\n**   Except, any file that is greater than 0 bytes in size is considered\n**   to have at least one page. (i.e. a 1KB file with 2K page-size leads\n**   to dbSize==1).\n**\n**   During a write-transaction, if pages with page-numbers greater than\n**   dbSize are modified in the cache, dbSize is updated accordingly.\n**   Similarly, if the database is truncated using PagerTruncateImage(), \n**   dbSize is updated.\n**\n**   Variables dbOrigSize and dbFileSize are valid in states \n**   PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize\n**   variable at the start of the transaction. It is used during rollback,\n**   and to determine whether or not pages need to be journalled before\n**   being modified.\n**\n**   Throughout a write-transaction, dbFileSize contains the size of\n**   the file on disk in pages. It is set to a copy of dbSize when the\n**   write-transaction is first opened, and updated when VFS calls are made\n**   to write or truncate the database file on disk. \n**\n**   The only reason the dbFileSize variable is required is to suppress \n**   unnecessary calls to xTruncate() after committing a transaction. If, \n**   when a transaction is committed, the dbFileSize variable indicates \n**   that the database file is larger than the database image (Pager.dbSize), \n**   pager_truncate() is called. The pager_truncate() call uses xFilesize()\n**   to measure the database file on disk, and then truncates it if required.\n**   dbFileSize is not used when rolling back a transaction. In this case\n**   pager_truncate() is called unconditionally (which means there may be\n**   a call to xFilesize() that is not strictly required). In either case,\n**   pager_truncate() may cause the file to become smaller or larger.\n**\n** dbHintSize\n**\n**   The dbHintSize variable is used to limit the number of calls made to\n**   the VFS xFileControl(FCNTL_SIZE_HINT) method. \n**\n**   dbHintSize is set to a copy of the dbSize variable when a\n**   write-transaction is opened (at the same time as dbFileSize and\n**   dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,\n**   dbHintSize is increased to the number of pages that correspond to the\n**   size-hint passed to the method call. See pager_write_pagelist() for \n**   details.\n**\n** errCode\n**\n**   The Pager.errCode variable is only ever used in PAGER_ERROR state. It\n**   is set to zero in all other states. In PAGER_ERROR state, Pager.errCode \n**   is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX \n**   sub-codes.\n*/\nstruct Pager {\n  sqlite3_vfs *pVfs;          /* OS functions to use for IO */\n  u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */\n  u8 journalMode;             /* One of the PAGER_JOURNALMODE_* values */\n  u8 useJournal;              /* Use a rollback journal on this file */\n  u8 noSync;                  /* Do not sync the journal if true */\n  u8 fullSync;                /* Do extra syncs of the journal for robustness */\n  u8 ckptSyncFlags;           /* SYNC_NORMAL or SYNC_FULL for checkpoint */\n  u8 walSyncFlags;            /* SYNC_NORMAL or SYNC_FULL for wal writes */\n  u8 syncFlags;               /* SYNC_NORMAL or SYNC_FULL otherwise */\n  u8 tempFile;                /* zFilename is a temporary file */\n  u8 readOnly;                /* True for a read-only database */\n  u8 memDb;                   /* True to inhibit all file I/O */\n\n  /**************************************************************************\n  ** The following block contains those class members that change during\n  ** routine opertion.  Class members not in this block are either fixed\n  ** when the pager is first created or else only change when there is a\n  ** significant mode change (such as changing the page_size, locking_mode,\n  ** or the journal_mode).  From another view, these class members describe\n  ** the \"state\" of the pager, while other class members describe the\n  ** \"configuration\" of the pager.\n  */\n  u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */\n  u8 eLock;                   /* Current lock held on database file */\n  u8 changeCountDone;         /* Set after incrementing the change-counter */\n  u8 setMaster;               /* True if a m-j name has been written to jrnl */\n  u8 doNotSpill;              /* Do not spill the cache when non-zero */\n  u8 doNotSyncSpill;          /* Do not do a spill that requires jrnl sync */\n  u8 subjInMemory;            /* True to use in-memory sub-journals */\n  Pgno dbSize;                /* Number of pages in the database */\n  Pgno dbOrigSize;            /* dbSize before the current transaction */\n  Pgno dbFileSize;            /* Number of pages in the database file */\n  Pgno dbHintSize;            /* Value passed to FCNTL_SIZE_HINT call */\n  int errCode;                /* One of several kinds of errors */\n  int nRec;                   /* Pages journalled since last j-header written */\n  u32 cksumInit;              /* Quasi-random value added to every checksum */\n  u32 nSubRec;                /* Number of records written to sub-journal */\n  Bitvec *pInJournal;         /* One bit for each page in the database file */\n  sqlite3_file *fd;           /* File descriptor for database */\n  sqlite3_file *jfd;          /* File descriptor for main journal */\n  sqlite3_file *sjfd;         /* File descriptor for sub-journal */\n  i64 journalOff;             /* Current write offset in the journal file */\n  i64 journalHdr;             /* Byte offset to previous journal header */\n  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */\n  PagerSavepoint *aSavepoint; /* Array of active savepoints */\n  int nSavepoint;             /* Number of elements in aSavepoint[] */\n  char dbFileVers[16];        /* Changes whenever database file changes */\n\n  u8 bUseFetch;               /* True to use xFetch() */\n  int nMmapOut;               /* Number of mmap pages currently outstanding */\n  sqlite3_int64 szMmap;       /* Desired maximum mmap size */\n  PgHdr *pMmapFreelist;       /* List of free mmap page headers (pDirty) */\n  /*\n  ** End of the routinely-changing class members\n  ***************************************************************************/\n\n  u16 nExtra;                 /* Add this many bytes to each in-memory page */\n  i16 nReserve;               /* Number of unused bytes at end of each page */\n  u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */\n  u32 sectorSize;             /* Assumed sector size during rollback */\n  int pageSize;               /* Number of bytes in a page */\n  Pgno mxPgno;                /* Maximum allowed size of the database */\n  i64 journalSizeLimit;       /* Size limit for persistent journal files */\n  char *zFilename;            /* Name of the database file */\n  char *zJournal;             /* Name of the journal file */\n  int (*xBusyHandler)(void*); /* Function to call when busy */\n  void *pBusyHandlerArg;      /* Context argument for xBusyHandler */\n  int aStat[3];               /* Total cache hits, misses and writes */\n#ifdef SQLITE_TEST\n  int nRead;                  /* Database pages read */\n#endif\n  void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */\n#ifdef SQLITE_HAS_CODEC\n  void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */\n  void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */\n  void (*xCodecFree)(void*);             /* Destructor for the codec */\n  void *pCodec;               /* First argument to xCodec... methods */\n#endif\n  char *pTmpSpace;            /* Pager.pageSize bytes of space for tmp use */\n  PCache *pPCache;            /* Pointer to page cache object */\n#ifndef SQLITE_OMIT_WAL\n  Wal *pWal;                  /* Write-ahead log used by \"journal_mode=wal\" */\n  char *zWal;                 /* File name for write-ahead log */\n#endif\n};\n\n/*\n** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains\n** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS \n** or CACHE_WRITE to sqlite3_db_status().\n*/\n#define PAGER_STAT_HIT   0\n#define PAGER_STAT_MISS  1\n#define PAGER_STAT_WRITE 2\n\n/*\n** The following global variables hold counters used for\n** testing purposes only.  These variables do not exist in\n** a non-testing build.  These variables are not thread-safe.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_pager_readdb_count = 0;    /* Number of full pages read from DB */\nSQLITE_API int sqlite3_pager_writedb_count = 0;   /* Number of full pages written to DB */\nSQLITE_API int sqlite3_pager_writej_count = 0;    /* Number of pages written to journal */\n# define PAGER_INCR(v)  v++\n#else\n# define PAGER_INCR(v)\n#endif\n\n\n\n/*\n** Journal files begin with the following magic string.  The data\n** was obtained from /dev/random.  It is used only as a sanity check.\n**\n** Since version 2.8.0, the journal format contains additional sanity\n** checking information.  If the power fails while the journal is being\n** written, semi-random garbage data might appear in the journal\n** file after power is restored.  If an attempt is then made\n** to roll the journal back, the database could be corrupted.  The additional\n** sanity checking data is an attempt to discover the garbage in the\n** journal and ignore it.\n**\n** The sanity checking information for the new journal format consists\n** of a 32-bit checksum on each page of data.  The checksum covers both\n** the page number and the pPager->pageSize bytes of data for the page.\n** This cksum is initialized to a 32-bit random value that appears in the\n** journal file right after the header.  The random initializer is important,\n** because garbage data that appears at the end of a journal is likely\n** data that was once in other files that have now been deleted.  If the\n** garbage data came from an obsolete journal file, the checksums might\n** be correct.  But by initializing the checksum to random value which\n** is different for every journal, we minimize that risk.\n*/\nstatic const unsigned char aJournalMagic[] = {\n  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7,\n};\n\n/*\n** The size of the of each page record in the journal is given by\n** the following macro.\n*/\n#define JOURNAL_PG_SZ(pPager)  ((pPager->pageSize) + 8)\n\n/*\n** The journal header size for this pager. This is usually the same \n** size as a single disk sector. See also setSectorSize().\n*/\n#define JOURNAL_HDR_SZ(pPager) (pPager->sectorSize)\n\n/*\n** The macro MEMDB is true if we are dealing with an in-memory database.\n** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,\n** the value of MEMDB will be a constant and the compiler will optimize\n** out code that would never execute.\n*/\n#ifdef SQLITE_OMIT_MEMORYDB\n# define MEMDB 0\n#else\n# define MEMDB pPager->memDb\n#endif\n\n/*\n** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch\n** interfaces to access the database using memory-mapped I/O.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\n# define USEFETCH(x) ((x)->bUseFetch)\n#else\n# define USEFETCH(x) 0\n#endif\n\n/*\n** The maximum legal page number is (2^31 - 1).\n*/\n#define PAGER_MAX_PGNO 2147483647\n\n/*\n** The argument to this macro is a file descriptor (type sqlite3_file*).\n** Return 0 if it is not open, or non-zero (but not 1) if it is.\n**\n** This is so that expressions can be written as:\n**\n**   if( isOpen(pPager->jfd) ){ ...\n**\n** instead of\n**\n**   if( pPager->jfd->pMethods ){ ...\n*/\n#define isOpen(pFd) ((pFd)->pMethods)\n\n/*\n** Return true if this pager uses a write-ahead log instead of the usual\n** rollback journal. Otherwise false.\n*/\n#ifndef SQLITE_OMIT_WAL\nstatic int pagerUseWal(Pager *pPager){\n  return (pPager->pWal!=0);\n}\n#else\n# define pagerUseWal(x) 0\n# define pagerRollbackWal(x) 0\n# define pagerWalFrames(v,w,x,y) 0\n# define pagerOpenWalIfPresent(z) SQLITE_OK\n# define pagerBeginReadTransaction(z) SQLITE_OK\n#endif\n\n#ifndef NDEBUG \n/*\n** Usage:\n**\n**   assert( assert_pager_state(pPager) );\n**\n** This function runs many asserts to try to find inconsistencies in\n** the internal state of the Pager object.\n*/\nstatic int assert_pager_state(Pager *p){\n  Pager *pPager = p;\n\n  /* State must be valid. */\n  assert( p->eState==PAGER_OPEN\n       || p->eState==PAGER_READER\n       || p->eState==PAGER_WRITER_LOCKED\n       || p->eState==PAGER_WRITER_CACHEMOD\n       || p->eState==PAGER_WRITER_DBMOD\n       || p->eState==PAGER_WRITER_FINISHED\n       || p->eState==PAGER_ERROR\n  );\n\n  /* Regardless of the current state, a temp-file connection always behaves\n  ** as if it has an exclusive lock on the database file. It never updates\n  ** the change-counter field, so the changeCountDone flag is always set.\n  */\n  assert( p->tempFile==0 || p->eLock==EXCLUSIVE_LOCK );\n  assert( p->tempFile==0 || pPager->changeCountDone );\n\n  /* If the useJournal flag is clear, the journal-mode must be \"OFF\". \n  ** And if the journal-mode is \"OFF\", the journal file must not be open.\n  */\n  assert( p->journalMode==PAGER_JOURNALMODE_OFF || p->useJournal );\n  assert( p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd) );\n\n  /* Check that MEMDB implies noSync. And an in-memory journal. Since \n  ** this means an in-memory pager performs no IO at all, it cannot encounter \n  ** either SQLITE_IOERR or SQLITE_FULL during rollback or while finalizing \n  ** a journal file. (although the in-memory journal implementation may \n  ** return SQLITE_IOERR_NOMEM while the journal file is being written). It \n  ** is therefore not possible for an in-memory pager to enter the ERROR \n  ** state.\n  */\n  if( MEMDB ){\n    assert( p->noSync );\n    assert( p->journalMode==PAGER_JOURNALMODE_OFF \n         || p->journalMode==PAGER_JOURNALMODE_MEMORY \n    );\n    assert( p->eState!=PAGER_ERROR && p->eState!=PAGER_OPEN );\n    assert( pagerUseWal(p)==0 );\n  }\n\n  /* If changeCountDone is set, a RESERVED lock or greater must be held\n  ** on the file.\n  */\n  assert( pPager->changeCountDone==0 || pPager->eLock>=RESERVED_LOCK );\n  assert( p->eLock!=PENDING_LOCK );\n\n  switch( p->eState ){\n    case PAGER_OPEN:\n      assert( !MEMDB );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)==0 || pPager->tempFile );\n      break;\n\n    case PAGER_READER:\n      assert( pPager->errCode==SQLITE_OK );\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( p->eLock>=SHARED_LOCK );\n      break;\n\n    case PAGER_WRITER_LOCKED:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        assert( p->eLock>=RESERVED_LOCK );\n      }\n      assert( pPager->dbSize==pPager->dbOrigSize );\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      assert( pPager->setMaster==0 );\n      break;\n\n    case PAGER_WRITER_CACHEMOD:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        /* It is possible that if journal_mode=wal here that neither the\n        ** journal file nor the WAL file are open. This happens during\n        ** a rollback transaction that switches from journal_mode=off\n        ** to journal_mode=wal.\n        */\n        assert( p->eLock>=RESERVED_LOCK );\n        assert( isOpen(p->jfd) \n             || p->journalMode==PAGER_JOURNALMODE_OFF \n             || p->journalMode==PAGER_JOURNALMODE_WAL \n        );\n      }\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_DBMOD:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( p->eLock>=EXCLUSIVE_LOCK );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      assert( pPager->dbOrigSize<=pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_FINISHED:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      break;\n\n    case PAGER_ERROR:\n      /* There must be at least one outstanding reference to the pager if\n      ** in ERROR state. Otherwise the pager should have already dropped\n      ** back to OPEN state.\n      */\n      assert( pPager->errCode!=SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );\n      break;\n  }\n\n  return 1;\n}\n#endif /* ifndef NDEBUG */\n\n#ifdef SQLITE_DEBUG \n/*\n** Return a pointer to a human readable string in a static buffer\n** containing the state of the Pager object passed as an argument. This\n** is intended to be used within debuggers. For example, as an alternative\n** to \"print *pPager\" in gdb:\n**\n** (gdb) printf \"%s\", print_pager_state(pPager)\n*/\nstatic char *print_pager_state(Pager *p){\n  static char zRet[1024];\n\n  sqlite3_snprintf(1024, zRet,\n      \"Filename:      %s\\n\"\n      \"State:         %s errCode=%d\\n\"\n      \"Lock:          %s\\n\"\n      \"Locking mode:  locking_mode=%s\\n\"\n      \"Journal mode:  journal_mode=%s\\n\"\n      \"Backing store: tempFile=%d memDb=%d useJournal=%d\\n\"\n      \"Journal:       journalOff=%lld journalHdr=%lld\\n\"\n      \"Size:          dbsize=%d dbOrigSize=%d dbFileSize=%d\\n\"\n      , p->zFilename\n      , p->eState==PAGER_OPEN            ? \"OPEN\" :\n        p->eState==PAGER_READER          ? \"READER\" :\n        p->eState==PAGER_WRITER_LOCKED   ? \"WRITER_LOCKED\" :\n        p->eState==PAGER_WRITER_CACHEMOD ? \"WRITER_CACHEMOD\" :\n        p->eState==PAGER_WRITER_DBMOD    ? \"WRITER_DBMOD\" :\n        p->eState==PAGER_WRITER_FINISHED ? \"WRITER_FINISHED\" :\n        p->eState==PAGER_ERROR           ? \"ERROR\" : \"?error?\"\n      , (int)p->errCode\n      , p->eLock==NO_LOCK         ? \"NO_LOCK\" :\n        p->eLock==RESERVED_LOCK   ? \"RESERVED\" :\n        p->eLock==EXCLUSIVE_LOCK  ? \"EXCLUSIVE\" :\n        p->eLock==SHARED_LOCK     ? \"SHARED\" :\n        p->eLock==UNKNOWN_LOCK    ? \"UNKNOWN\" : \"?error?\"\n      , p->exclusiveMode ? \"exclusive\" : \"normal\"\n      , p->journalMode==PAGER_JOURNALMODE_MEMORY   ? \"memory\" :\n        p->journalMode==PAGER_JOURNALMODE_OFF      ? \"off\" :\n        p->journalMode==PAGER_JOURNALMODE_DELETE   ? \"delete\" :\n        p->journalMode==PAGER_JOURNALMODE_PERSIST  ? \"persist\" :\n        p->journalMode==PAGER_JOURNALMODE_TRUNCATE ? \"truncate\" :\n        p->journalMode==PAGER_JOURNALMODE_WAL      ? \"wal\" : \"?error?\"\n      , (int)p->tempFile, (int)p->memDb, (int)p->useJournal\n      , p->journalOff, p->journalHdr\n      , (int)p->dbSize, (int)p->dbOrigSize, (int)p->dbFileSize\n  );\n\n  return zRet;\n}\n#endif\n\n/*\n** Return true if it is necessary to write page *pPg into the sub-journal.\n** A page needs to be written into the sub-journal if there exists one\n** or more open savepoints for which:\n**\n**   * The page-number is less than or equal to PagerSavepoint.nOrig, and\n**   * The bit corresponding to the page-number is not set in\n**     PagerSavepoint.pInSavepoint.\n*/\nstatic int subjRequiresPage(PgHdr *pPg){\n  Pgno pgno = pPg->pgno;\n  Pager *pPager = pPg->pPager;\n  int i;\n  for(i=0; i<pPager->nSavepoint; i++){\n    PagerSavepoint *p = &pPager->aSavepoint[i];\n    if( p->nOrig>=pgno && 0==sqlite3BitvecTest(p->pInSavepoint, pgno) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return true if the page is already in the journal file.\n*/\nstatic int pageInJournal(PgHdr *pPg){\n  return sqlite3BitvecTest(pPg->pPager->pInJournal, pPg->pgno);\n}\n\n/*\n** Read a 32-bit integer from the given file descriptor.  Store the integer\n** that is read in *pRes.  Return SQLITE_OK if everything worked, or an\n** error code is something goes wrong.\n**\n** All values are stored on disk as big-endian.\n*/\nstatic int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){\n  unsigned char ac[4];\n  int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);\n  if( rc==SQLITE_OK ){\n    *pRes = sqlite3Get4byte(ac);\n  }\n  return rc;\n}\n\n/*\n** Write a 32-bit integer into a string buffer in big-endian byte order.\n*/\n#define put32bits(A,B)  sqlite3Put4byte((u8*)A,B)\n\n\n/*\n** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK\n** on success or an error code is something goes wrong.\n*/\nstatic int write32bits(sqlite3_file *fd, i64 offset, u32 val){\n  char ac[4];\n  put32bits(ac, val);\n  return sqlite3OsWrite(fd, ac, 4, offset);\n}\n\n/*\n** Unlock the database file to level eLock, which must be either NO_LOCK\n** or SHARED_LOCK. Regardless of whether or not the call to xUnlock()\n** succeeds, set the Pager.eLock variable to match the (attempted) new lock.\n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is\n** called, do not modify it. See the comment above the #define of \n** UNKNOWN_LOCK for an explanation of this.\n*/\nstatic int pagerUnlockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( !pPager->exclusiveMode || pPager->eLock==eLock );\n  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );\n  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );\n  if( isOpen(pPager->fd) ){\n    assert( pPager->eLock>=eLock );\n    rc = sqlite3OsUnlock(pPager->fd, eLock);\n    if( pPager->eLock!=UNKNOWN_LOCK ){\n      pPager->eLock = (u8)eLock;\n    }\n    IOTRACE((\"UNLOCK %p %d\\n\", pPager, eLock))\n  }\n  return rc;\n}\n\n/*\n** Lock the database file to level eLock, which must be either SHARED_LOCK,\n** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the\n** Pager.eLock variable to the new locking state. \n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is \n** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. \n** See the comment above the #define of UNKNOWN_LOCK for an explanation \n** of this.\n*/\nstatic int pagerLockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );\n  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){\n    rc = sqlite3OsLock(pPager->fd, eLock);\n    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){\n      pPager->eLock = (u8)eLock;\n      IOTRACE((\"LOCK %p %d\\n\", pPager, eLock))\n    }\n  }\n  return rc;\n}\n\n/*\n** This function determines whether or not the atomic-write optimization\n** can be used with this pager. The optimization can be used if:\n**\n**  (a) the value returned by OsDeviceCharacteristics() indicates that\n**      a database page may be written atomically, and\n**  (b) the value returned by OsSectorSize() is less than or equal\n**      to the page size.\n**\n** The optimization is also always enabled for temporary files. It is\n** an error to call this function if pPager is opened on an in-memory\n** database.\n**\n** If the optimization cannot be used, 0 is returned. If it can be used,\n** then the value returned is the size of the journal file when it\n** contains rollback data for exactly one page.\n*/\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\nstatic int jrnlBufferSize(Pager *pPager){\n  assert( !MEMDB );\n  if( !pPager->tempFile ){\n    int dc;                           /* Device characteristics */\n    int nSector;                      /* Sector size */\n    int szPage;                       /* Page size */\n\n    assert( isOpen(pPager->fd) );\n    dc = sqlite3OsDeviceCharacteristics(pPager->fd);\n    nSector = pPager->sectorSize;\n    szPage = pPager->pageSize;\n\n    assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n    assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n    if( 0==(dc&(SQLITE_IOCAP_ATOMIC|(szPage>>8)) || nSector>szPage) ){\n      return 0;\n    }\n  }\n\n  return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager);\n}\n#endif\n\n/*\n** If SQLITE_CHECK_PAGES is defined then we do some sanity checking\n** on the cache using a hash function.  This is used for testing\n** and debugging only.\n*/\n#ifdef SQLITE_CHECK_PAGES\n/*\n** Return a 32-bit hash of the page data for pPage.\n*/\nstatic u32 pager_datahash(int nByte, unsigned char *pData){\n  u32 hash = 0;\n  int i;\n  for(i=0; i<nByte; i++){\n    hash = (hash*1039) + pData[i];\n  }\n  return hash;\n}\nstatic u32 pager_pagehash(PgHdr *pPage){\n  return pager_datahash(pPage->pPager->pageSize, (unsigned char *)pPage->pData);\n}\nstatic void pager_set_pagehash(PgHdr *pPage){\n  pPage->pageHash = pager_pagehash(pPage);\n}\n\n/*\n** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES\n** is defined, and NDEBUG is not defined, an assert() statement checks\n** that the page is either dirty or still matches the calculated page-hash.\n*/\n#define CHECK_PAGE(x) checkPage(x)\nstatic void checkPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );\n}\n\n#else\n#define pager_datahash(X,Y)  0\n#define pager_pagehash(X)  0\n#define pager_set_pagehash(X)\n#define CHECK_PAGE(x)\n#endif  /* SQLITE_CHECK_PAGES */\n\n/*\n** When this is called the journal file for pager pPager must be open.\n** This function attempts to read a master journal file name from the \n** end of the file and, if successful, copies it into memory supplied \n** by the caller. See comments above writeMasterJournal() for the format\n** used to store a master journal file name at the end of a journal file.\n**\n** zMaster must point to a buffer of at least nMaster bytes allocated by\n** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is\n** enough space to write the master journal name). If the master journal\n** name in the journal is longer than nMaster bytes (including a\n** nul-terminator), then this is handled as if no master journal name\n** were present in the journal.\n**\n** If a master journal file name is present at the end of the journal\n** file, then it is copied into the buffer pointed to by zMaster. A\n** nul-terminator byte is appended to the buffer following the master\n** journal file name.\n**\n** If it is determined that no master journal file name is present \n** zMaster[0] is set to 0 and SQLITE_OK returned.\n**\n** If an error occurs while reading from the journal file, an SQLite\n** error code is returned.\n*/\nstatic int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){\n  int rc;                    /* Return code */\n  u32 len;                   /* Length in bytes of master journal name */\n  i64 szJ;                   /* Total size in bytes of journal file pJrnl */\n  u32 cksum;                 /* MJ checksum value read from journal */\n  u32 u;                     /* Unsigned loop counter */\n  unsigned char aMagic[8];   /* A buffer to hold the magic header */\n  zMaster[0] = '\\0';\n\n  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))\n   || szJ<16\n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))\n   || len>=nMaster \n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))\n   || memcmp(aMagic, aJournalMagic, 8)\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))\n  ){\n    return rc;\n  }\n\n  /* See if the checksum matches the master journal name */\n  for(u=0; u<len; u++){\n    cksum -= zMaster[u];\n  }\n  if( cksum ){\n    /* If the checksum doesn't add up, then one or more of the disk sectors\n    ** containing the master journal filename is corrupted. This means\n    ** definitely roll back, so just return SQLITE_OK and report a (nul)\n    ** master-journal filename.\n    */\n    len = 0;\n  }\n  zMaster[len] = '\\0';\n   \n  return SQLITE_OK;\n}\n\n/*\n** Return the offset of the sector boundary at or immediately \n** following the value in pPager->journalOff, assuming a sector \n** size of pPager->sectorSize bytes.\n**\n** i.e for a sector size of 512:\n**\n**   Pager.journalOff          Return value\n**   ---------------------------------------\n**   0                         0\n**   512                       512\n**   100                       512\n**   2000                      2048\n** \n*/\nstatic i64 journalHdrOffset(Pager *pPager){\n  i64 offset = 0;\n  i64 c = pPager->journalOff;\n  if( c ){\n    offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);\n  }\n  assert( offset%JOURNAL_HDR_SZ(pPager)==0 );\n  assert( offset>=c );\n  assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );\n  return offset;\n}\n\n/*\n** The journal file must be open when this function is called.\n**\n** This function is a no-op if the journal file has not been written to\n** within the current transaction (i.e. if Pager.journalOff==0).\n**\n** If doTruncate is non-zero or the Pager.journalSizeLimit variable is\n** set to 0, then truncate the journal file to zero bytes in size. Otherwise,\n** zero the 28-byte header at the start of the journal file. In either case, \n** if the pager is not in no-sync mode, sync the journal file immediately \n** after writing or truncating it.\n**\n** If Pager.journalSizeLimit is set to a positive, non-zero value, and\n** following the truncation or zeroing described above the size of the \n** journal file in bytes is larger than this value, then truncate the\n** journal file to Pager.journalSizeLimit bytes. The journal file does\n** not need to be synced following this operation.\n**\n** If an IO error occurs, abandon processing and return the IO error code.\n** Otherwise, return SQLITE_OK.\n*/\nstatic int zeroJournalHdr(Pager *pPager, int doTruncate){\n  int rc = SQLITE_OK;                               /* Return code */\n  assert( isOpen(pPager->jfd) );\n  if( pPager->journalOff ){\n    const i64 iLimit = pPager->journalSizeLimit;    /* Local cache of jsl */\n\n    IOTRACE((\"JZEROHDR %p\\n\", pPager))\n    if( doTruncate || iLimit==0 ){\n      rc = sqlite3OsTruncate(pPager->jfd, 0);\n    }else{\n      static const char zeroHdr[28] = {0};\n      rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);\n    }\n    if( rc==SQLITE_OK && !pPager->noSync ){\n      rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);\n    }\n\n    /* At this point the transaction is committed but the write lock \n    ** is still held on the file. If there is a size limit configured for \n    ** the persistent journal and the journal file currently consumes more\n    ** space than that limit allows for, truncate it now. There is no need\n    ** to sync the file following this operation.\n    */\n    if( rc==SQLITE_OK && iLimit>0 ){\n      i64 sz;\n      rc = sqlite3OsFileSize(pPager->jfd, &sz);\n      if( rc==SQLITE_OK && sz>iLimit ){\n        rc = sqlite3OsTruncate(pPager->jfd, iLimit);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The journal file must be open when this routine is called. A journal\n** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the\n** current location.\n**\n** The format for the journal header is as follows:\n** - 8 bytes: Magic identifying journal format.\n** - 4 bytes: Number of records in journal, or -1 no-sync mode is on.\n** - 4 bytes: Random number used for page hash.\n** - 4 bytes: Initial database page count.\n** - 4 bytes: Sector size used by the process that wrote this journal.\n** - 4 bytes: Database page size.\n** \n** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.\n*/\nstatic int writeJournalHdr(Pager *pPager){\n  int rc = SQLITE_OK;                 /* Return code */\n  char *zHeader = pPager->pTmpSpace;  /* Temporary space used to build header */\n  u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */\n  u32 nWrite;                         /* Bytes of header sector written */\n  int ii;                             /* Loop counter */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  if( nHeader>JOURNAL_HDR_SZ(pPager) ){\n    nHeader = JOURNAL_HDR_SZ(pPager);\n  }\n\n  /* If there are active savepoints and any of them were created \n  ** since the most recent journal header was written, update the \n  ** PagerSavepoint.iHdrOffset fields now.\n  */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    if( pPager->aSavepoint[ii].iHdrOffset==0 ){\n      pPager->aSavepoint[ii].iHdrOffset = pPager->journalOff;\n    }\n  }\n\n  pPager->journalHdr = pPager->journalOff = journalHdrOffset(pPager);\n\n  /* \n  ** Write the nRec Field - the number of page records that follow this\n  ** journal header. Normally, zero is written to this value at this time.\n  ** After the records are added to the journal (and the journal synced, \n  ** if in full-sync mode), the zero is overwritten with the true number\n  ** of records (see syncJournal()).\n  **\n  ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When\n  ** reading the journal this value tells SQLite to assume that the\n  ** rest of the journal file contains valid page records. This assumption\n  ** is dangerous, as if a failure occurred whilst writing to the journal\n  ** file it may contain some garbage data. There are two scenarios\n  ** where this risk can be ignored:\n  **\n  **   * When the pager is in no-sync mode. Corruption can follow a\n  **     power failure in this case anyway.\n  **\n  **   * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees\n  **     that garbage data is never appended to the journal file.\n  */\n  assert( isOpen(pPager->fd) || pPager->noSync );\n  if( pPager->noSync || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)\n   || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND) \n  ){\n    memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n    put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff);\n  }else{\n    memset(zHeader, 0, sizeof(aJournalMagic)+4);\n  }\n\n  /* The random check-hash initializer */ \n  sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);\n  put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);\n  /* The initial database size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);\n  /* The assumed sector size for this process */\n  put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);\n\n  /* The page size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);\n\n  /* Initializing the tail of the buffer is not necessary.  Everything\n  ** works find if the following memset() is omitted.  But initializing\n  ** the memory prevents valgrind from complaining, so we are willing to\n  ** take the performance hit.\n  */\n  memset(&zHeader[sizeof(aJournalMagic)+20], 0,\n         nHeader-(sizeof(aJournalMagic)+20));\n\n  /* In theory, it is only necessary to write the 28 bytes that the \n  ** journal header consumes to the journal file here. Then increment the \n  ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next \n  ** record is written to the following sector (leaving a gap in the file\n  ** that will be implicitly filled in by the OS).\n  **\n  ** However it has been discovered that on some systems this pattern can \n  ** be significantly slower than contiguously writing data to the file,\n  ** even if that means explicitly writing data to the block of \n  ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what\n  ** is done. \n  **\n  ** The loop is required here in case the sector-size is larger than the \n  ** database page size. Since the zHeader buffer is only Pager.pageSize\n  ** bytes in size, more than one call to sqlite3OsWrite() may be required\n  ** to populate the entire journal header sector.\n  */ \n  for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){\n    IOTRACE((\"JHDR %p %lld %d\\n\", pPager, pPager->journalHdr, nHeader))\n    rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);\n    assert( pPager->journalHdr <= pPager->journalOff );\n    pPager->journalOff += nHeader;\n  }\n\n  return rc;\n}\n\n/*\n** The journal file must be open when this is called. A journal header file\n** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal\n** file. The current location in the journal file is given by\n** pPager->journalOff. See comments above function writeJournalHdr() for\n** a description of the journal header format.\n**\n** If the header is read successfully, *pNRec is set to the number of\n** page records following this header and *pDbSize is set to the size of the\n** database before the transaction began, in pages. Also, pPager->cksumInit\n** is set to the value read from the journal header. SQLITE_OK is returned\n** in this case.\n**\n** If the journal header file appears to be corrupted, SQLITE_DONE is\n** returned and *pNRec and *PDbSize are undefined.  If JOURNAL_HDR_SZ bytes\n** cannot be read from the journal file an error code is returned.\n*/\nstatic int readJournalHdr(\n  Pager *pPager,               /* Pager object */\n  int isHot,\n  i64 journalSize,             /* Size of the open journal file in bytes */\n  u32 *pNRec,                  /* OUT: Value read from the nRec field */\n  u32 *pDbSize                 /* OUT: Value of original database size field */\n){\n  int rc;                      /* Return code */\n  unsigned char aMagic[8];     /* A buffer to hold the magic header */\n  i64 iHdrOff;                 /* Offset of journal header being read */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  /* Advance Pager.journalOff to the start of the next sector. If the\n  ** journal file is too small for there to be a header stored at this\n  ** point, return SQLITE_DONE.\n  */\n  pPager->journalOff = journalHdrOffset(pPager);\n  if( pPager->journalOff+JOURNAL_HDR_SZ(pPager) > journalSize ){\n    return SQLITE_DONE;\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Read in the first 8 bytes of the journal header. If they do not match\n  ** the  magic string found at the start of each journal header, return\n  ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,\n  ** proceed.\n  */\n  if( isHot || iHdrOff!=pPager->journalHdr ){\n    rc = sqlite3OsRead(pPager->jfd, aMagic, sizeof(aMagic), iHdrOff);\n    if( rc ){\n      return rc;\n    }\n    if( memcmp(aMagic, aJournalMagic, sizeof(aMagic))!=0 ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* Read the first three 32-bit fields of the journal header: The nRec\n  ** field, the checksum-initializer and the database size at the start\n  ** of the transaction. Return an error code if anything goes wrong.\n  */\n  if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+8, pNRec))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+12, &pPager->cksumInit))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+16, pDbSize))\n  ){\n    return rc;\n  }\n\n  if( pPager->journalOff==0 ){\n    u32 iPageSize;               /* Page-size field of journal header */\n    u32 iSectorSize;             /* Sector-size field of journal header */\n\n    /* Read the page-size and sector-size journal header fields. */\n    if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))\n     || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+24, &iPageSize))\n    ){\n      return rc;\n    }\n\n    /* Versions of SQLite prior to 3.5.8 set the page-size field of the\n    ** journal header to zero. In this case, assume that the Pager.pageSize\n    ** variable is already set to the correct page size.\n    */\n    if( iPageSize==0 ){\n      iPageSize = pPager->pageSize;\n    }\n\n    /* Check that the values read from the page-size and sector-size fields\n    ** are within range. To be 'in range', both values need to be a power\n    ** of two greater than or equal to 512 or 32, and not greater than their \n    ** respective compile time maximum limits.\n    */\n    if( iPageSize<512                  || iSectorSize<32\n     || iPageSize>SQLITE_MAX_PAGE_SIZE || iSectorSize>MAX_SECTOR_SIZE\n     || ((iPageSize-1)&iPageSize)!=0   || ((iSectorSize-1)&iSectorSize)!=0 \n    ){\n      /* If the either the page-size or sector-size in the journal-header is \n      ** invalid, then the process that wrote the journal-header must have \n      ** crashed before the header was synced. In this case stop reading \n      ** the journal file here.\n      */\n      return SQLITE_DONE;\n    }\n\n    /* Update the page-size to match the value read from the journal. \n    ** Use a testcase() macro to make sure that malloc failure within \n    ** PagerSetPagesize() is tested.\n    */\n    rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);\n    testcase( rc!=SQLITE_OK );\n\n    /* Update the assumed sector-size to match the value used by \n    ** the process that created this journal. If this journal was\n    ** created by a process other than this one, then this routine\n    ** is being called from within pager_playback(). The local value\n    ** of Pager.sectorSize is restored at the end of that routine.\n    */\n    pPager->sectorSize = iSectorSize;\n  }\n\n  pPager->journalOff += JOURNAL_HDR_SZ(pPager);\n  return rc;\n}\n\n\n/*\n** Write the supplied master journal name into the journal file for pager\n** pPager at the current location. The master journal name must be the last\n** thing written to a journal file. If the pager is in full-sync mode, the\n** journal file descriptor is advanced to the next sector boundary before\n** anything is written. The format is:\n**\n**   + 4 bytes: PAGER_MJ_PGNO.\n**   + N bytes: Master journal filename in utf-8.\n**   + 4 bytes: N (length of master journal name in bytes, no nul-terminator).\n**   + 4 bytes: Master journal name checksum.\n**   + 8 bytes: aJournalMagic[].\n**\n** The master journal page checksum is the sum of the bytes in the master\n** journal name, where each byte is interpreted as a signed 8-bit integer.\n**\n** If zMaster is a NULL pointer (occurs for a single database transaction), \n** this call is a no-op.\n*/\nstatic int writeMasterJournal(Pager *pPager, const char *zMaster){\n  int rc;                          /* Return code */\n  int nMaster;                     /* Length of string zMaster */\n  i64 iHdrOff;                     /* Offset of header in journal file */\n  i64 jrnlSize;                    /* Size of journal file on disk */\n  u32 cksum = 0;                   /* Checksum of string zMaster */\n\n  assert( pPager->setMaster==0 );\n  assert( !pagerUseWal(pPager) );\n\n  if( !zMaster \n   || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n   || pPager->journalMode==PAGER_JOURNALMODE_OFF \n  ){\n    return SQLITE_OK;\n  }\n  pPager->setMaster = 1;\n  assert( isOpen(pPager->jfd) );\n  assert( pPager->journalHdr <= pPager->journalOff );\n\n  /* Calculate the length in bytes and the checksum of zMaster */\n  for(nMaster=0; zMaster[nMaster]; nMaster++){\n    cksum += zMaster[nMaster];\n  }\n\n  /* If in full-sync mode, advance to the next disk sector before writing\n  ** the master journal name. This is in case the previous page written to\n  ** the journal has already been synced.\n  */\n  if( pPager->fullSync ){\n    pPager->journalOff = journalHdrOffset(pPager);\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Write the master journal data to the end of the journal file. If\n  ** an error occurs, return the error code to the caller.\n  */\n  if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, zMaster, nMaster, iHdrOff+4)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster, nMaster)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster+4, cksum)))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8, iHdrOff+4+nMaster+8)))\n  ){\n    return rc;\n  }\n  pPager->journalOff += (nMaster+20);\n\n  /* If the pager is in peristent-journal mode, then the physical \n  ** journal-file may extend past the end of the master-journal name\n  ** and 8 bytes of magic data just written to the file. This is \n  ** dangerous because the code to rollback a hot-journal file\n  ** will not be able to find the master-journal name to determine \n  ** whether or not the journal is hot. \n  **\n  ** Easiest thing to do in this scenario is to truncate the journal \n  ** file to the required size.\n  */ \n  if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))\n   && jrnlSize>pPager->journalOff\n  ){\n    rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);\n  }\n  return rc;\n}\n\n/*\n** Find a page in the hash table given its page number. Return\n** a pointer to the page or NULL if the requested page is not \n** already in memory.\n*/\nstatic PgHdr *pager_lookup(Pager *pPager, Pgno pgno){\n  PgHdr *p;                         /* Return value */\n\n  /* It is not possible for a call to PcacheFetch() with createFlag==0 to\n  ** fail, since no attempt to allocate dynamic memory will be made.\n  */\n  (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &p);\n  return p;\n}\n\n/*\n** Discard the entire contents of the in-memory page-cache.\n*/\nstatic void pager_reset(Pager *pPager){\n  sqlite3BackupRestart(pPager->pBackup);\n  sqlite3PcacheClear(pPager->pPCache);\n}\n\n/*\n** Free all structures in the Pager.aSavepoint[] array and set both\n** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal\n** if it is open and the pager is not in exclusive mode.\n*/\nstatic void releaseAllSavepoints(Pager *pPager){\n  int ii;               /* Iterator for looping through Pager.aSavepoint */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n  }\n  if( !pPager->exclusiveMode || sqlite3IsMemJournal(pPager->sjfd) ){\n    sqlite3OsClose(pPager->sjfd);\n  }\n  sqlite3_free(pPager->aSavepoint);\n  pPager->aSavepoint = 0;\n  pPager->nSavepoint = 0;\n  pPager->nSubRec = 0;\n}\n\n/*\n** Set the bit number pgno in the PagerSavepoint.pInSavepoint \n** bitvecs of all open savepoints. Return SQLITE_OK if successful\n** or SQLITE_NOMEM if a malloc failure occurs.\n*/\nstatic int addToSavepointBitvecs(Pager *pPager, Pgno pgno){\n  int ii;                   /* Loop counter */\n  int rc = SQLITE_OK;       /* Result code */\n\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    PagerSavepoint *p = &pPager->aSavepoint[ii];\n    if( pgno<=p->nOrig ){\n      rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);\n      testcase( rc==SQLITE_NOMEM );\n      assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if the pager is in exclusive mode and not\n** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN\n** state.\n**\n** If the pager is not in exclusive-access mode, the database file is\n** completely unlocked. If the file is unlocked and the file-system does\n** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is\n** closed (if it is open).\n**\n** If the pager is in ERROR state when this function is called, the \n** contents of the pager cache are discarded before switching back to \n** the OPEN state. Regardless of whether the pager is in exclusive-mode\n** or not, any journal file left in the file-system will be treated\n** as a hot-journal and rolled back the next time a read-transaction\n** is opened (by this or by any other connection).\n*/\nstatic void pager_unlock(Pager *pPager){\n\n  assert( pPager->eState==PAGER_READER \n       || pPager->eState==PAGER_OPEN \n       || pPager->eState==PAGER_ERROR \n  );\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  releaseAllSavepoints(pPager);\n\n  if( pagerUseWal(pPager) ){\n    assert( !isOpen(pPager->jfd) );\n    sqlite3WalEndReadTransaction(pPager->pWal);\n    pPager->eState = PAGER_OPEN;\n  }else if( !pPager->exclusiveMode ){\n    int rc;                       /* Error code returned by pagerUnlockDb() */\n    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;\n\n    /* If the operating system support deletion of open files, then\n    ** close the journal file when dropping the database lock.  Otherwise\n    ** another connection with journal_mode=delete might delete the file\n    ** out from under us.\n    */\n    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );\n    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)\n     || 1!=(pPager->journalMode & 5)\n    ){\n      sqlite3OsClose(pPager->jfd);\n    }\n\n    /* If the pager is in the ERROR state and the call to unlock the database\n    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment\n    ** above the #define for UNKNOWN_LOCK for an explanation of why this\n    ** is necessary.\n    */\n    rc = pagerUnlockDb(pPager, NO_LOCK);\n    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){\n      pPager->eLock = UNKNOWN_LOCK;\n    }\n\n    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here\n    ** without clearing the error code. This is intentional - the error\n    ** code is cleared and the cache reset in the block below.\n    */\n    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );\n    pPager->changeCountDone = 0;\n    pPager->eState = PAGER_OPEN;\n  }\n\n  /* If Pager.errCode is set, the contents of the pager cache cannot be\n  ** trusted. Now that there are no outstanding references to the pager,\n  ** it can safely move back to PAGER_OPEN state. This happens in both\n  ** normal and exclusive-locking mode.\n  */\n  if( pPager->errCode ){\n    assert( !MEMDB );\n    pager_reset(pPager);\n    pPager->changeCountDone = pPager->tempFile;\n    pPager->eState = PAGER_OPEN;\n    pPager->errCode = SQLITE_OK;\n  }\n\n  pPager->journalOff = 0;\n  pPager->journalHdr = 0;\n  pPager->setMaster = 0;\n}\n\n/*\n** This function is called whenever an IOERR or FULL error that requires\n** the pager to transition into the ERROR state may ahve occurred.\n** The first argument is a pointer to the pager structure, the second \n** the error-code about to be returned by a pager API function. The \n** value returned is a copy of the second argument to this function. \n**\n** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the\n** IOERR sub-codes, the pager enters the ERROR state and the error code\n** is stored in Pager.errCode. While the pager remains in the ERROR state,\n** all major API calls on the Pager will immediately return Pager.errCode.\n**\n** The ERROR state indicates that the contents of the pager-cache \n** cannot be trusted. This state can be cleared by completely discarding \n** the contents of the pager-cache. If a transaction was active when\n** the persistent error occurred, then the rollback journal may need\n** to be replayed to restore the contents of the database file (as if\n** it were a hot-journal).\n*/\nstatic int pager_error(Pager *pPager, int rc){\n  int rc2 = rc & 0xff;\n  assert( rc==SQLITE_OK || !MEMDB );\n  assert(\n       pPager->errCode==SQLITE_FULL ||\n       pPager->errCode==SQLITE_OK ||\n       (pPager->errCode & 0xff)==SQLITE_IOERR\n  );\n  if( rc2==SQLITE_FULL || rc2==SQLITE_IOERR ){\n    pPager->errCode = rc;\n    pPager->eState = PAGER_ERROR;\n  }\n  return rc;\n}\n\nstatic int pager_truncate(Pager *pPager, Pgno nPage);\n\n/*\n** This routine ends a transaction. A transaction is usually ended by \n** either a COMMIT or a ROLLBACK operation. This routine may be called \n** after rollback of a hot-journal, or if an error occurs while opening\n** the journal file or writing the very first journal-header of a\n** database transaction.\n** \n** This routine is never called in PAGER_ERROR state. If it is called\n** in PAGER_NONE or PAGER_SHARED state and the lock held is less\n** exclusive than a RESERVED lock, it is a no-op.\n**\n** Otherwise, any active savepoints are released.\n**\n** If the journal file is open, then it is \"finalized\". Once a journal \n** file has been finalized it is not possible to use it to roll back a \n** transaction. Nor will it be considered to be a hot-journal by this\n** or any other database connection. Exactly how a journal is finalized\n** depends on whether or not the pager is running in exclusive mode and\n** the current journal-mode (Pager.journalMode value), as follows:\n**\n**   journalMode==MEMORY\n**     Journal file descriptor is simply closed. This destroys an \n**     in-memory journal.\n**\n**   journalMode==TRUNCATE\n**     Journal file is truncated to zero bytes in size.\n**\n**   journalMode==PERSIST\n**     The first 28 bytes of the journal file are zeroed. This invalidates\n**     the first journal header in the file, and hence the entire journal\n**     file. An invalid journal file cannot be rolled back.\n**\n**   journalMode==DELETE\n**     The journal file is closed and deleted using sqlite3OsDelete().\n**\n**     If the pager is running in exclusive mode, this method of finalizing\n**     the journal file is never used. Instead, if the journalMode is\n**     DELETE and the pager is in exclusive mode, the method described under\n**     journalMode==PERSIST is used instead.\n**\n** After the journal is finalized, the pager moves to PAGER_READER state.\n** If running in non-exclusive rollback mode, the lock on the file is \n** downgraded to a SHARED_LOCK.\n**\n** SQLITE_OK is returned if no error occurs. If an error occurs during\n** any of the IO operations to finalize the journal file or unlock the\n** database then the IO error code is returned to the user. If the \n** operation to finalize the journal file fails, then the code still\n** tries to unlock the database file if not in exclusive mode. If the\n** unlock operation fails as well, then the first error code related\n** to the first error encountered (the journal finalization one) is\n** returned.\n*/\nstatic int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){\n  int rc = SQLITE_OK;      /* Error code from journal finalization operation */\n  int rc2 = SQLITE_OK;     /* Error code from db file unlock operation */\n\n  /* Do nothing if the pager does not have an open write transaction\n  ** or at least a RESERVED lock. This function may be called when there\n  ** is no write-transaction active but a RESERVED or greater lock is\n  ** held under two circumstances:\n  **\n  **   1. After a successful hot-journal rollback, it is called with\n  **      eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK.\n  **\n  **   2. If a connection with locking_mode=exclusive holding an EXCLUSIVE \n  **      lock switches back to locking_mode=normal and then executes a\n  **      read-transaction, this function is called with eState==PAGER_READER \n  **      and eLock==EXCLUSIVE_LOCK when the read-transaction is closed.\n  */\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState!=PAGER_ERROR );\n  if( pPager->eState<PAGER_WRITER_LOCKED && pPager->eLock<RESERVED_LOCK ){\n    return SQLITE_OK;\n  }\n\n  releaseAllSavepoints(pPager);\n  assert( isOpen(pPager->jfd) || pPager->pInJournal==0 );\n  if( isOpen(pPager->jfd) ){\n    assert( !pagerUseWal(pPager) );\n\n    /* Finalize the journal file. */\n    if( sqlite3IsMemJournal(pPager->jfd) ){\n      assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY );\n      sqlite3OsClose(pPager->jfd);\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_TRUNCATE ){\n      if( pPager->journalOff==0 ){\n        rc = SQLITE_OK;\n      }else{\n        rc = sqlite3OsTruncate(pPager->jfd, 0);\n      }\n      pPager->journalOff = 0;\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)\n    ){\n      rc = zeroJournalHdr(pPager, hasMaster);\n      pPager->journalOff = 0;\n    }else{\n      /* This branch may be executed with Pager.journalMode==MEMORY if\n      ** a hot-journal was just rolled back. In this case the journal\n      ** file should be closed and deleted. If this connection writes to\n      ** the database file, it will do so using an in-memory journal. \n      */\n      int bDelete = (!pPager->tempFile && sqlite3JournalExists(pPager->jfd));\n      assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE \n           || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n           || pPager->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      sqlite3OsClose(pPager->jfd);\n      if( bDelete ){\n        rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n      }\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);\n  if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){\n    PgHdr *p = pager_lookup(pPager, 1);\n    if( p ){\n      p->pageHash = 0;\n      sqlite3PagerUnref(p);\n    }\n  }\n#endif\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  pPager->nRec = 0;\n  sqlite3PcacheCleanAll(pPager->pPCache);\n  sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);\n\n  if( pagerUseWal(pPager) ){\n    /* Drop the WAL write-lock, if any. Also, if the connection was in \n    ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE \n    ** lock held on the database file.\n    */\n    rc2 = sqlite3WalEndWriteTransaction(pPager->pWal);\n    assert( rc2==SQLITE_OK );\n  }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){\n    /* This branch is taken when committing a transaction in rollback-journal\n    ** mode if the database file on disk is larger than the database image.\n    ** At this point the journal has been finalized and the transaction \n    ** successfully committed, but the EXCLUSIVE lock is still held on the\n    ** file. So it is safe to truncate the database file to its minimum\n    ** required size.  */\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    rc = pager_truncate(pPager, pPager->dbSize);\n  }\n\n  if( !pPager->exclusiveMode \n   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))\n  ){\n    rc2 = pagerUnlockDb(pPager, SHARED_LOCK);\n    pPager->changeCountDone = 0;\n  }\n  pPager->eState = PAGER_READER;\n  pPager->setMaster = 0;\n\n  return (rc==SQLITE_OK?rc2:rc);\n}\n\n/*\n** Execute a rollback if a transaction is active and unlock the \n** database file. \n**\n** If the pager has already entered the ERROR state, do not attempt \n** the rollback at this time. Instead, pager_unlock() is called. The\n** call to pager_unlock() will discard all in-memory pages, unlock\n** the database file and move the pager back to OPEN state. If this \n** means that there is a hot-journal left in the file-system, the next \n** connection to obtain a shared lock on the pager (which may be this one) \n** will roll it back.\n**\n** If the pager has not already entered the ERROR state, but an IO or\n** malloc error occurs during a rollback, then this will itself cause \n** the pager to enter the ERROR state. Which will be cleared by the\n** call to pager_unlock(), as described above.\n*/\nstatic void pagerUnlockAndRollback(Pager *pPager){\n  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){\n    assert( assert_pager_state(pPager) );\n    if( pPager->eState>=PAGER_WRITER_LOCKED ){\n      sqlite3BeginBenignMalloc();\n      sqlite3PagerRollback(pPager);\n      sqlite3EndBenignMalloc();\n    }else if( !pPager->exclusiveMode ){\n      assert( pPager->eState==PAGER_READER );\n      pager_end_transaction(pPager, 0, 0);\n    }\n  }\n  pager_unlock(pPager);\n}\n\n/*\n** Parameter aData must point to a buffer of pPager->pageSize bytes\n** of data. Compute and return a checksum based ont the contents of the \n** page of data and the current value of pPager->cksumInit.\n**\n** This is not a real checksum. It is really just the sum of the \n** random initial value (pPager->cksumInit) and every 200th byte\n** of the page data, starting with byte offset (pPager->pageSize%200).\n** Each byte is interpreted as an 8-bit unsigned integer.\n**\n** Changing the formula used to compute this checksum results in an\n** incompatible journal file format.\n**\n** If journal corruption occurs due to a power failure, the most likely \n** scenario is that one end or the other of the record will be changed. \n** It is much less likely that the two ends of the journal record will be\n** correct and the middle be corrupt.  Thus, this \"checksum\" scheme,\n** though fast and simple, catches the mostly likely kind of corruption.\n*/\nstatic u32 pager_cksum(Pager *pPager, const u8 *aData){\n  u32 cksum = pPager->cksumInit;         /* Checksum value to return */\n  int i = pPager->pageSize-200;          /* Loop counter */\n  while( i>0 ){\n    cksum += aData[i];\n    i -= 200;\n  }\n  return cksum;\n}\n\n/*\n** Report the current page size and number of reserved bytes back\n** to the codec.\n*/\n#ifdef SQLITE_HAS_CODEC\nstatic void pagerReportSize(Pager *pPager){\n  if( pPager->xCodecSizeChng ){\n    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,\n                           (int)pPager->nReserve);\n  }\n}\n#else\n# define pagerReportSize(X)     /* No-op if we do not support a codec */\n#endif\n\n/*\n** Read a single page from either the journal file (if isMainJrnl==1) or\n** from the sub-journal (if isMainJrnl==0) and playback that page.\n** The page begins at offset *pOffset into the file. The *pOffset\n** value is increased to the start of the next page in the journal.\n**\n** The main rollback journal uses checksums - the statement journal does \n** not.\n**\n** If the page number of the page record read from the (sub-)journal file\n** is greater than the current value of Pager.dbSize, then playback is\n** skipped and SQLITE_OK is returned.\n**\n** If pDone is not NULL, then it is a record of pages that have already\n** been played back.  If the page at *pOffset has already been played back\n** (if the corresponding pDone bit is set) then skip the playback.\n** Make sure the pDone bit corresponding to the *pOffset page is set\n** prior to returning.\n**\n** If the page record is successfully read from the (sub-)journal file\n** and played back, then SQLITE_OK is returned. If an IO error occurs\n** while reading the record from the (sub-)journal file or while writing\n** to the database file, then the IO error code is returned. If data\n** is successfully read from the (sub-)journal file but appears to be\n** corrupted, SQLITE_DONE is returned. Data is considered corrupted in\n** two circumstances:\n** \n**   * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or\n**   * If the record is being rolled back from the main journal file\n**     and the checksum field does not match the record content.\n**\n** Neither of these two scenarios are possible during a savepoint rollback.\n**\n** If this is a savepoint rollback, then memory may have to be dynamically\n** allocated by this function. If this is the case and an allocation fails,\n** SQLITE_NOMEM is returned.\n*/\nstatic int pager_playback_one_page(\n  Pager *pPager,                /* The pager being played back */\n  i64 *pOffset,                 /* Offset of record to playback */\n  Bitvec *pDone,                /* Bitvec of pages already played back */\n  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */\n  int isSavepnt                 /* True for a savepoint rollback */\n){\n  int rc;\n  PgHdr *pPg;                   /* An existing page in the cache */\n  Pgno pgno;                    /* The page number of a page in journal */\n  u32 cksum;                    /* Checksum used for sanity checking */\n  char *aData;                  /* Temporary storage for the page */\n  sqlite3_file *jfd;            /* The file descriptor for the journal file */\n  int isSynced;                 /* True if journal page is synced */\n\n  assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */\n  assert( (isSavepnt&~1)==0 );       /* isSavepnt is 0 or 1 */\n  assert( isMainJrnl || pDone );     /* pDone always used on sub-journals */\n  assert( isSavepnt || pDone==0 );   /* pDone never used on non-savepoint */\n\n  aData = pPager->pTmpSpace;\n  assert( aData );         /* Temp storage must have already been allocated */\n  assert( pagerUseWal(pPager)==0 || (!isMainJrnl && isSavepnt) );\n\n  /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction \n  ** or savepoint rollback done at the request of the caller) or this is\n  ** a hot-journal rollback. If it is a hot-journal rollback, the pager\n  ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback\n  ** only reads from the main journal, not the sub-journal.\n  */\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD\n       || (pPager->eState==PAGER_OPEN && pPager->eLock==EXCLUSIVE_LOCK)\n  );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD || isMainJrnl );\n\n  /* Read the page number and page data from the journal or sub-journal\n  ** file. Return an error code to the caller if an IO error occurs.\n  */\n  jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;\n  rc = read32bits(jfd, *pOffset, &pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);\n  if( rc!=SQLITE_OK ) return rc;\n  *pOffset += pPager->pageSize + 4 + isMainJrnl*4;\n\n  /* Sanity checking on the page.  This is more important that I originally\n  ** thought.  If a power failure occurs while the journal is being written,\n  ** it could cause invalid data to be written into the journal.  We need to\n  ** detect this invalid data (with high probability) and ignore it.\n  */\n  if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){\n    assert( !isSavepnt );\n    return SQLITE_DONE;\n  }\n  if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){\n    return SQLITE_OK;\n  }\n  if( isMainJrnl ){\n    rc = read32bits(jfd, (*pOffset)-4, &cksum);\n    if( rc ) return rc;\n    if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If this page has already been played by before during the current\n  ** rollback, then don't bother to play it back again.\n  */\n  if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* When playing back page 1, restore the nReserve setting\n  */\n  if( pgno==1 && pPager->nReserve!=((u8*)aData)[20] ){\n    pPager->nReserve = ((u8*)aData)[20];\n    pagerReportSize(pPager);\n  }\n\n  /* If the pager is in CACHEMOD state, then there must be a copy of this\n  ** page in the pager cache. In this case just update the pager cache,\n  ** not the database file. The page is left marked dirty in this case.\n  **\n  ** An exception to the above rule: If the database is in no-sync mode\n  ** and a page is moved during an incremental vacuum then the page may\n  ** not be in the pager cache. Later: if a malloc() or IO error occurs\n  ** during a Movepage() call, then the page may not be in the cache\n  ** either. So the condition described in the above paragraph is not\n  ** assert()able.\n  **\n  ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the\n  ** pager cache if it exists and the main file. The page is then marked \n  ** not dirty. Since this code is only executed in PAGER_OPEN state for\n  ** a hot-journal rollback, it is guaranteed that the page-cache is empty\n  ** if the pager is in OPEN state.\n  **\n  ** Ticket #1171:  The statement journal might contain page content that is\n  ** different from the page content at the start of the transaction.\n  ** This occurs when a page is changed prior to the start of a statement\n  ** then changed again within the statement.  When rolling back such a\n  ** statement we must not write to the original database unless we know\n  ** for certain that original page contents are synced into the main rollback\n  ** journal.  Otherwise, a power loss might leave modified data in the\n  ** database file without an entry in the rollback journal that can\n  ** restore the database to its original form.  Two conditions must be\n  ** met before writing to the database files. (1) the database must be\n  ** locked.  (2) we know that the original page content is fully synced\n  ** in the main journal either because the page is not in cache or else\n  ** the page is marked as needSync==0.\n  **\n  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it\n  ** is possible to fail a statement on a database that does not yet exist.\n  ** Do not attempt to write if database file has never been opened.\n  */\n  if( pagerUseWal(pPager) ){\n    pPg = 0;\n  }else{\n    pPg = pager_lookup(pPager, pgno);\n  }\n  assert( pPg || !MEMDB );\n  assert( pPager->eState!=PAGER_OPEN || pPg==0 );\n  PAGERTRACE((\"PLAYBACK %d page %d hash(%08x) %s\\n\",\n           PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),\n           (isMainJrnl?\"main-journal\":\"sub-journal\")\n  ));\n  if( isMainJrnl ){\n    isSynced = pPager->noSync || (*pOffset <= pPager->journalHdr);\n  }else{\n    isSynced = (pPg==0 || 0==(pPg->flags & PGHDR_NEED_SYNC));\n  }\n  if( isOpen(pPager->fd)\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n   && isSynced\n  ){\n    i64 ofst = (pgno-1)*(i64)pPager->pageSize;\n    testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 );\n    assert( !pagerUseWal(pPager) );\n    rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n    if( pgno>pPager->dbFileSize ){\n      pPager->dbFileSize = pgno;\n    }\n    if( pPager->pBackup ){\n      CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM);\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n      CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM, aData);\n    }\n  }else if( !isMainJrnl && pPg==0 ){\n    /* If this is a rollback of a savepoint and data was not written to\n    ** the database and the page is not in-memory, there is a potential\n    ** problem. When the page is next fetched by the b-tree layer, it \n    ** will be read from the database file, which may or may not be \n    ** current. \n    **\n    ** There are a couple of different ways this can happen. All are quite\n    ** obscure. When running in synchronous mode, this can only happen \n    ** if the page is on the free-list at the start of the transaction, then\n    ** populated, then moved using sqlite3PagerMovepage().\n    **\n    ** The solution is to add an in-memory page to the cache containing\n    ** the data just read from the sub-journal. Mark the page as dirty \n    ** and if the pager requires a journal-sync, then mark the page as \n    ** requiring a journal-sync before it is written.\n    */\n    assert( isSavepnt );\n    assert( pPager->doNotSpill==0 );\n    pPager->doNotSpill++;\n    rc = sqlite3PagerAcquire(pPager, pgno, &pPg, 1);\n    assert( pPager->doNotSpill==1 );\n    pPager->doNotSpill--;\n    if( rc!=SQLITE_OK ) return rc;\n    pPg->flags &= ~PGHDR_NEED_READ;\n    sqlite3PcacheMakeDirty(pPg);\n  }\n  if( pPg ){\n    /* No page should ever be explicitly rolled back that is in use, except\n    ** for page 1 which is held in use in order to keep the lock on the\n    ** database active. However such a page may be rolled back as a result\n    ** of an internal error resulting in an automatic call to\n    ** sqlite3PagerRollback().\n    */\n    void *pData;\n    pData = pPg->pData;\n    memcpy(pData, (u8*)aData, pPager->pageSize);\n    pPager->xReiniter(pPg);\n    if( isMainJrnl && (!isSavepnt || *pOffset<=pPager->journalHdr) ){\n      /* If the contents of this page were just restored from the main \n      ** journal file, then its content must be as they were when the \n      ** transaction was first opened. In this case we can mark the page\n      ** as clean, since there will be no need to write it out to the\n      ** database.\n      **\n      ** There is one exception to this rule. If the page is being rolled\n      ** back as part of a savepoint (or statement) rollback from an \n      ** unsynced portion of the main journal file, then it is not safe\n      ** to mark the page as clean. This is because marking the page as\n      ** clean will clear the PGHDR_NEED_SYNC flag. Since the page is\n      ** already in the journal file (recorded in Pager.pInJournal) and\n      ** the PGHDR_NEED_SYNC flag is cleared, if the page is written to\n      ** again within this transaction, it will be marked as dirty but\n      ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially\n      ** be written out into the database file before its journal file\n      ** segment is synced. If a crash occurs during or following this,\n      ** database corruption may ensue.\n      */\n      assert( !pagerUseWal(pPager) );\n      sqlite3PcacheMakeClean(pPg);\n    }\n    pager_set_pagehash(pPg);\n\n    /* If this was page 1, then restore the value of Pager.dbFileVers.\n    ** Do this before any decoding. */\n    if( pgno==1 ){\n      memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers));\n    }\n\n    /* Decode the page just read from disk */\n    CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM);\n    sqlite3PcacheRelease(pPg);\n  }\n  return rc;\n}\n\n/*\n** Parameter zMaster is the name of a master journal file. A single journal\n** file that referred to the master journal file has just been rolled back.\n** This routine checks if it is possible to delete the master journal file,\n** and does so if it is.\n**\n** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not \n** available for use within this function.\n**\n** When a master journal file is created, it is populated with the names \n** of all of its child journals, one after another, formatted as utf-8 \n** encoded text. The end of each child journal file is marked with a \n** nul-terminator byte (0x00). i.e. the entire contents of a master journal\n** file for a transaction involving two databases might be:\n**\n**   \"/home/bill/a.db-journal\\x00/home/bill/b.db-journal\\x00\"\n**\n** A master journal file may only be deleted once all of its child \n** journals have been rolled back.\n**\n** This function reads the contents of the master-journal file into \n** memory and loops through each of the child journal names. For\n** each child journal, it checks if:\n**\n**   * if the child journal exists, and if so\n**   * if the child journal contains a reference to master journal \n**     file zMaster\n**\n** If a child journal can be found that matches both of the criteria\n** above, this function returns without doing anything. Otherwise, if\n** no such child journal can be found, file zMaster is deleted from\n** the file-system using sqlite3OsDelete().\n**\n** If an IO error within this function, an error code is returned. This\n** function allocates memory by calling sqlite3Malloc(). If an allocation\n** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors \n** occur, SQLITE_OK is returned.\n**\n** TODO: This function allocates a single block of memory to load\n** the entire contents of the master journal file. This could be\n** a couple of kilobytes or so - potentially larger than the page \n** size.\n*/\nstatic int pager_delmaster(Pager *pPager, const char *zMaster){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  int rc;                   /* Return code */\n  sqlite3_file *pMaster;    /* Malloc'd master-journal file descriptor */\n  sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */\n  char *zMasterJournal = 0; /* Contents of master journal file */\n  i64 nMasterJournal;       /* Size of master journal file */\n  char *zJournal;           /* Pointer to one journal within MJ file */\n  char *zMasterPtr;         /* Space to hold MJ filename from a journal file */\n  int nMasterPtr;           /* Amount of space allocated to zMasterPtr[] */\n\n  /* Allocate space for both the pJournal and pMaster file descriptors.\n  ** If successful, open the master journal file for reading.\n  */\n  pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);\n  pJournal = (sqlite3_file *)(((u8 *)pMaster) + pVfs->szOsFile);\n  if( !pMaster ){\n    rc = SQLITE_NOMEM;\n  }else{\n    const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);\n    rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);\n  }\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n\n  /* Load the entire master journal file into space obtained from\n  ** sqlite3_malloc() and pointed to by zMasterJournal.   Also obtain\n  ** sufficient space (in zMasterPtr) to hold the names of master\n  ** journal files extracted from regular rollback-journals.\n  */\n  rc = sqlite3OsFileSize(pMaster, &nMasterJournal);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  nMasterPtr = pVfs->mxPathname+1;\n  zMasterJournal = sqlite3Malloc((int)nMasterJournal + nMasterPtr + 1);\n  if( !zMasterJournal ){\n    rc = SQLITE_NOMEM;\n    goto delmaster_out;\n  }\n  zMasterPtr = &zMasterJournal[nMasterJournal+1];\n  rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  zMasterJournal[nMasterJournal] = 0;\n\n  zJournal = zMasterJournal;\n  while( (zJournal-zMasterJournal)<nMasterJournal ){\n    int exists;\n    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);\n    if( rc!=SQLITE_OK ){\n      goto delmaster_out;\n    }\n    if( exists ){\n      /* One of the journals pointed to by the master journal exists.\n      ** Open it and check if it points at the master journal. If\n      ** so, return without deleting the master journal file.\n      */\n      int c;\n      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);\n      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);\n      sqlite3OsClose(pJournal);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;\n      if( c ){\n        /* We have a match. Do not delete the master journal file. */\n        goto delmaster_out;\n      }\n    }\n    zJournal += (sqlite3Strlen30(zJournal)+1);\n  }\n \n  sqlite3OsClose(pMaster);\n  rc = sqlite3OsDelete(pVfs, zMaster, 0);\n\ndelmaster_out:\n  sqlite3_free(zMasterJournal);\n  if( pMaster ){\n    sqlite3OsClose(pMaster);\n    assert( !isOpen(pJournal) );\n    sqlite3_free(pMaster);\n  }\n  return rc;\n}\n\n\n/*\n** This function is used to change the actual size of the database \n** file in the file-system. This only happens when committing a transaction,\n** or rolling back a transaction (including rolling back a hot-journal).\n**\n** If the main database file is not open, or the pager is not in either\n** DBMOD or OPEN state, this function is a no-op. Otherwise, the size \n** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). \n** If the file on disk is currently larger than nPage pages, then use the VFS\n** xTruncate() method to truncate it.\n**\n** Or, it might might be the case that the file on disk is smaller than \n** nPage pages. Some operating system implementations can get confused if \n** you try to truncate a file to some size that is larger than it \n** currently is, so detect this case and write a single zero byte to \n** the end of the new file instead.\n**\n** If successful, return SQLITE_OK. If an IO error occurs while modifying\n** the database file, return the error code to the caller.\n*/\nstatic int pager_truncate(Pager *pPager, Pgno nPage){\n  int rc = SQLITE_OK;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState!=PAGER_READER );\n  \n  if( isOpen(pPager->fd) \n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) \n  ){\n    i64 currentSize, newSize;\n    int szPage = pPager->pageSize;\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    /* TODO: Is it safe to use Pager.dbFileSize here? */\n    rc = sqlite3OsFileSize(pPager->fd, &currentSize);\n    newSize = szPage*(i64)nPage;\n    if( rc==SQLITE_OK && currentSize!=newSize ){\n      if( currentSize>newSize ){\n        rc = sqlite3OsTruncate(pPager->fd, newSize);\n      }else if( (currentSize+szPage)<=newSize ){\n        char *pTmp = pPager->pTmpSpace;\n        memset(pTmp, 0, szPage);\n        testcase( (newSize-szPage) == currentSize );\n        testcase( (newSize-szPage) >  currentSize );\n        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);\n      }\n      if( rc==SQLITE_OK ){\n        pPager->dbFileSize = nPage;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return a sanitized version of the sector-size of OS file pFile. The\n** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.\n*/\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *pFile){\n  int iRet = sqlite3OsSectorSize(pFile);\n  if( iRet<32 ){\n    iRet = 512;\n  }else if( iRet>MAX_SECTOR_SIZE ){\n    assert( MAX_SECTOR_SIZE>=512 );\n    iRet = MAX_SECTOR_SIZE;\n  }\n  return iRet;\n}\n\n/*\n** Set the value of the Pager.sectorSize variable for the given\n** pager based on the value returned by the xSectorSize method\n** of the open database file. The sector size will be used used \n** to determine the size and alignment of journal header and \n** master journal pointers within created journal files.\n**\n** For temporary files the effective sector size is always 512 bytes.\n**\n** Otherwise, for non-temporary files, the effective sector size is\n** the value returned by the xSectorSize() method rounded up to 32 if\n** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it\n** is greater than MAX_SECTOR_SIZE.\n**\n** If the file has the SQLITE_IOCAP_POWERSAFE_OVERWRITE property, then set\n** the effective sector size to its minimum value (512).  The purpose of\n** pPager->sectorSize is to define the \"blast radius\" of bytes that\n** might change if a crash occurs while writing to a single byte in\n** that range.  But with POWERSAFE_OVERWRITE, the blast radius is zero\n** (that is what POWERSAFE_OVERWRITE means), so we minimize the sector\n** size.  For backwards compatibility of the rollback journal file format,\n** we cannot reduce the effective sector size below 512.\n*/\nstatic void setSectorSize(Pager *pPager){\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  if( pPager->tempFile\n   || (sqlite3OsDeviceCharacteristics(pPager->fd) & \n              SQLITE_IOCAP_POWERSAFE_OVERWRITE)!=0\n  ){\n    /* Sector size doesn't matter for temporary files. Also, the file\n    ** may not have been opened yet, in which case the OsSectorSize()\n    ** call will segfault. */\n    pPager->sectorSize = 512;\n  }else{\n    pPager->sectorSize = sqlite3SectorSize(pPager->fd);\n  }\n}\n\n/*\n** Playback the journal and thus restore the database file to\n** the state it was in before we started making changes.  \n**\n** The journal file format is as follows: \n**\n**  (1)  8 byte prefix.  A copy of aJournalMagic[].\n**  (2)  4 byte big-endian integer which is the number of valid page records\n**       in the journal.  If this value is 0xffffffff, then compute the\n**       number of page records from the journal size.\n**  (3)  4 byte big-endian integer which is the initial value for the \n**       sanity checksum.\n**  (4)  4 byte integer which is the number of pages to truncate the\n**       database to during a rollback.\n**  (5)  4 byte big-endian integer which is the sector size.  The header\n**       is this many bytes in size.\n**  (6)  4 byte big-endian integer which is the page size.\n**  (7)  zero padding out to the next sector size.\n**  (8)  Zero or more pages instances, each as follows:\n**        +  4 byte page number.\n**        +  pPager->pageSize bytes of data.\n**        +  4 byte checksum\n**\n** When we speak of the journal header, we mean the first 7 items above.\n** Each entry in the journal is an instance of the 8th item.\n**\n** Call the value from the second bullet \"nRec\".  nRec is the number of\n** valid page entries in the journal.  In most cases, you can compute the\n** value of nRec from the size of the journal file.  But if a power\n** failure occurred while the journal was being written, it could be the\n** case that the size of the journal file had already been increased but\n** the extra entries had not yet made it safely to disk.  In such a case,\n** the value of nRec computed from the file size would be too large.  For\n** that reason, we always use the nRec value in the header.\n**\n** If the nRec value is 0xffffffff it means that nRec should be computed\n** from the file size.  This value is used when the user selects the\n** no-sync option for the journal.  A power failure could lead to corruption\n** in this case.  But for things like temporary table (which will be\n** deleted when the power is restored) we don't care.  \n**\n** If the file opened as the journal file is not a well-formed\n** journal file then all pages up to the first corrupted page are rolled\n** back (or no pages if the journal header is corrupted). The journal file\n** is then deleted and SQLITE_OK returned, just as if no corruption had\n** been encountered.\n**\n** If an I/O or malloc() error occurs, the journal-file is not deleted\n** and an error code is returned.\n**\n** The isHot parameter indicates that we are trying to rollback a journal\n** that might be a hot journal.  Or, it could be that the journal is \n** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE.\n** If the journal really is hot, reset the pager cache prior rolling\n** back any content.  If the journal is merely persistent, no reset is\n** needed.\n*/\nstatic int pager_playback(Pager *pPager, int isHot){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  i64 szJ;                 /* Size of the journal file in bytes */\n  u32 nRec;                /* Number of Records in the journal */\n  u32 u;                   /* Unsigned loop counter */\n  Pgno mxPg = 0;           /* Size of the original file in pages */\n  int rc;                  /* Result code of a subroutine */\n  int res = 1;             /* Value returned by sqlite3OsAccess() */\n  char *zMaster = 0;       /* Name of master journal file if any */\n  int needPagerReset;      /* True to reset page prior to first page rollback */\n  int nPlayback = 0;       /* Total number of pages restored from journal */\n\n  /* Figure out how many records are in the journal.  Abort early if\n  ** the journal is empty.\n  */\n  assert( isOpen(pPager->jfd) );\n  rc = sqlite3OsFileSize(pPager->jfd, &szJ);\n  if( rc!=SQLITE_OK ){\n    goto end_playback;\n  }\n\n  /* Read the master journal name from the journal, if it is present.\n  ** If a master journal file name is specified, but the file is not\n  ** present on disk, then the journal is not hot and does not need to be\n  ** played back.\n  **\n  ** TODO: Technically the following is an error because it assumes that\n  ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that\n  ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,\n  **  mxPathname is 512, which is the same as the minimum allowable value\n  ** for pageSize.\n  */\n  zMaster = pPager->pTmpSpace;\n  rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n  if( rc==SQLITE_OK && zMaster[0] ){\n    rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n  }\n  zMaster = 0;\n  if( rc!=SQLITE_OK || !res ){\n    goto end_playback;\n  }\n  pPager->journalOff = 0;\n  needPagerReset = isHot;\n\n  /* This loop terminates either when a readJournalHdr() or \n  ** pager_playback_one_page() call returns SQLITE_DONE or an IO error \n  ** occurs. \n  */\n  while( 1 ){\n    /* Read the next journal header from the journal file.  If there are\n    ** not enough bytes left in the journal file for a complete header, or\n    ** it is corrupted, then a process must have failed while writing it.\n    ** This indicates nothing more needs to be rolled back.\n    */\n    rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);\n    if( rc!=SQLITE_OK ){ \n      if( rc==SQLITE_DONE ){\n        rc = SQLITE_OK;\n      }\n      goto end_playback;\n    }\n\n    /* If nRec is 0xffffffff, then this journal was created by a process\n    ** working in no-sync mode. This means that the rest of the journal\n    ** file consists of pages, there are no more journal headers. Compute\n    ** the value of nRec based on this assumption.\n    */\n    if( nRec==0xffffffff ){\n      assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );\n      nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If nRec is 0 and this rollback is of a transaction created by this\n    ** process and if this is the final header in the journal, then it means\n    ** that this part of the journal was being filled but has not yet been\n    ** synced to disk.  Compute the number of pages based on the remaining\n    ** size of the file.\n    **\n    ** The third term of the test was added to fix ticket #2565.\n    ** When rolling back a hot journal, nRec==0 always means that the next\n    ** chunk of the journal contains zero pages to be rolled back.  But\n    ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in\n    ** the journal, it means that the journal might contain additional\n    ** pages that need to be rolled back and that the number of pages \n    ** should be computed based on the journal file size.\n    */\n    if( nRec==0 && !isHot &&\n        pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){\n      nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If this is the first header read from the journal, truncate the\n    ** database file back to its original size.\n    */\n    if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){\n      rc = pager_truncate(pPager, mxPg);\n      if( rc!=SQLITE_OK ){\n        goto end_playback;\n      }\n      pPager->dbSize = mxPg;\n    }\n\n    /* Copy original pages out of the journal and back into the \n    ** database file and/or page cache.\n    */\n    for(u=0; u<nRec; u++){\n      if( needPagerReset ){\n        pager_reset(pPager);\n        needPagerReset = 0;\n      }\n      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);\n      if( rc==SQLITE_OK ){\n        nPlayback++;\n      }else{\n        if( rc==SQLITE_DONE ){\n          pPager->journalOff = szJ;\n          break;\n        }else if( rc==SQLITE_IOERR_SHORT_READ ){\n          /* If the journal has been truncated, simply stop reading and\n          ** processing the journal. This might happen if the journal was\n          ** not completely written and synced prior to a crash.  In that\n          ** case, the database should have never been written in the\n          ** first place so it is OK to simply abandon the rollback. */\n          rc = SQLITE_OK;\n          goto end_playback;\n        }else{\n          /* If we are unable to rollback, quit and return the error\n          ** code.  This will cause the pager to enter the error state\n          ** so that no further harm will be done.  Perhaps the next\n          ** process to come along will be able to rollback the database.\n          */\n          goto end_playback;\n        }\n      }\n    }\n  }\n  /*NOTREACHED*/\n  assert( 0 );\n\nend_playback:\n  /* Following a rollback, the database file should be back in its original\n  ** state prior to the start of the transaction, so invoke the\n  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the\n  ** assertion that the transaction counter was modified.\n  */\n#ifdef SQLITE_DEBUG\n  if( pPager->fd->pMethods ){\n    sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);\n  }\n#endif\n\n  /* If this playback is happening automatically as a result of an IO or \n  ** malloc error that occurred after the change-counter was updated but \n  ** before the transaction was committed, then the change-counter \n  ** modification may just have been reverted. If this happens in exclusive \n  ** mode, then subsequent transactions performed by the connection will not\n  ** update the change-counter at all. This may lead to cache inconsistency\n  ** problems for other processes at some point in the future. So, just\n  ** in case this has happened, clear the changeCountDone flag now.\n  */\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( rc==SQLITE_OK ){\n    zMaster = pPager->pTmpSpace;\n    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n  ){\n    rc = sqlite3PagerSync(pPager);\n  }\n  if( rc==SQLITE_OK ){\n    rc = pager_end_transaction(pPager, zMaster[0]!='\\0', 0);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK && zMaster[0] && res ){\n    /* If there was a master journal and this routine will return success,\n    ** see if it is possible to delete the master journal.\n    */\n    rc = pager_delmaster(pPager, zMaster);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( isHot && nPlayback ){\n    sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, \"recovered %d pages from %s\",\n                nPlayback, pPager->zJournal);\n  }\n\n  /* The Pager.sectorSize variable may have been updated while rolling\n  ** back a journal created by a process with a different sector size\n  ** value. Reset it to the correct value for this process.\n  */\n  setSectorSize(pPager);\n  return rc;\n}\n\n\n/*\n** Read the content for page pPg out of the database file and into \n** pPg->pData. A shared lock or greater must be held on the database\n** file before this function is called.\n**\n** If page 1 is read, then the value of Pager.dbFileVers[] is set to\n** the value read from the database file.\n**\n** If an IO error occurs, then the IO error is returned to the caller.\n** Otherwise, SQLITE_OK is returned.\n*/\nstatic int readDbPage(PgHdr *pPg, u32 iFrame){\n  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */\n  Pgno pgno = pPg->pgno;       /* Page number to read */\n  int rc = SQLITE_OK;          /* Return code */\n  int pgsz = pPager->pageSize; /* Number of bytes to read */\n\n  assert( pPager->eState>=PAGER_READER && !MEMDB );\n  assert( isOpen(pPager->fd) );\n\n  if( NEVER(!isOpen(pPager->fd)) ){\n    assert( pPager->tempFile );\n    memset(pPg->pData, 0, pPager->pageSize);\n    return SQLITE_OK;\n  }\n\n#ifndef SQLITE_OMIT_WAL\n  if( iFrame ){\n    /* Try to pull the page from the write-ahead log. */\n    rc = sqlite3WalReadFrame(pPager->pWal, iFrame, pgsz, pPg->pData);\n  }else\n#endif\n  {\n    i64 iOffset = (pgno-1)*(i64)pPager->pageSize;\n    rc = sqlite3OsRead(pPager->fd, pPg->pData, pgsz, iOffset);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n\n  if( pgno==1 ){\n    if( rc ){\n      /* If the read is unsuccessful, set the dbFileVers[] to something\n      ** that will never be a valid file version.  dbFileVers[] is a copy\n      ** of bytes 24..39 of the database.  Bytes 28..31 should always be\n      ** zero or the size of the database in page. Bytes 32..35 and 35..39\n      ** should be page numbers which are never 0xffffffff.  So filling\n      ** pPager->dbFileVers[] with all 0xff bytes should suffice.\n      **\n      ** For an encrypted database, the situation is more complex:  bytes\n      ** 24..39 of the database are white noise.  But the probability of\n      ** white noising equaling 16 bytes of 0xff is vanishingly small so\n      ** we should still be ok.\n      */\n      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));\n    }else{\n      u8 *dbFileVers = &((u8*)pPg->pData)[24];\n      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));\n    }\n  }\n  CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);\n\n  PAGER_INCR(sqlite3_pager_readdb_count);\n  PAGER_INCR(pPager->nRead);\n  IOTRACE((\"PGIN %p %d\\n\", pPager, pgno));\n  PAGERTRACE((\"FETCH %d page %d hash(%08x)\\n\",\n               PAGERID(pPager), pgno, pager_pagehash(pPg)));\n\n  return rc;\n}\n\n/*\n** Update the value of the change-counter at offsets 24 and 92 in\n** the header and the sqlite version number at offset 96.\n**\n** This is an unconditional update.  See also the pager_incr_changecounter()\n** routine which only updates the change-counter if the update is actually\n** needed, as determined by the pPager->changeCountDone state variable.\n*/\nstatic void pager_write_changecounter(PgHdr *pPg){\n  u32 change_counter;\n\n  /* Increment the value just read and write it back to byte 24. */\n  change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;\n  put32bits(((char*)pPg->pData)+24, change_counter);\n\n  /* Also store the SQLite version number in bytes 96..99 and in\n  ** bytes 92..95 store the change counter for which the version number\n  ** is valid. */\n  put32bits(((char*)pPg->pData)+92, change_counter);\n  put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is invoked once for each page that has already been \n** written into the log file when a WAL transaction is rolled back.\n** Parameter iPg is the page number of said page. The pCtx argument \n** is actually a pointer to the Pager structure.\n**\n** If page iPg is present in the cache, and has no outstanding references,\n** it is discarded. Otherwise, if there are one or more outstanding\n** references, the page content is reloaded from the database. If the\n** attempt to reload content from the database is required and fails, \n** return an SQLite error code. Otherwise, SQLITE_OK.\n*/\nstatic int pagerUndoCallback(void *pCtx, Pgno iPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = (Pager *)pCtx;\n  PgHdr *pPg;\n\n  assert( pagerUseWal(pPager) );\n  pPg = sqlite3PagerLookup(pPager, iPg);\n  if( pPg ){\n    if( sqlite3PcachePageRefcount(pPg)==1 ){\n      sqlite3PcacheDrop(pPg);\n    }else{\n      u32 iFrame = 0;\n      rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);\n      if( rc==SQLITE_OK ){\n        rc = readDbPage(pPg, iFrame);\n      }\n      if( rc==SQLITE_OK ){\n        pPager->xReiniter(pPg);\n      }\n      sqlite3PagerUnref(pPg);\n    }\n  }\n\n  /* Normally, if a transaction is rolled back, any backup processes are\n  ** updated as data is copied out of the rollback journal and into the\n  ** database. This is not generally possible with a WAL database, as\n  ** rollback involves simply truncating the log file. Therefore, if one\n  ** or more frames have already been written to the log (and therefore \n  ** also copied into the backup databases) as part of this transaction,\n  ** the backups must be restarted.\n  */\n  sqlite3BackupRestart(pPager->pBackup);\n\n  return rc;\n}\n\n/*\n** This function is called to rollback a transaction on a WAL database.\n*/\nstatic int pagerRollbackWal(Pager *pPager){\n  int rc;                         /* Return Code */\n  PgHdr *pList;                   /* List of dirty pages to revert */\n\n  /* For all pages in the cache that are currently dirty or have already\n  ** been written (but not committed) to the log file, do one of the \n  ** following:\n  **\n  **   + Discard the cached page (if refcount==0), or\n  **   + Reload page content from the database (if refcount>0).\n  */\n  pPager->dbSize = pPager->dbOrigSize;\n  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  while( pList && rc==SQLITE_OK ){\n    PgHdr *pNext = pList->pDirty;\n    rc = pagerUndoCallback((void *)pPager, pList->pgno);\n    pList = pNext;\n  }\n\n  return rc;\n}\n\n/*\n** This function is a wrapper around sqlite3WalFrames(). As well as logging\n** the contents of the list of pages headed by pList (connected by pDirty),\n** this function notifies any active backup processes that the pages have\n** changed. \n**\n** The list of pages passed into this routine is always sorted by page number.\n** Hence, if page 1 appears anywhere on the list, it will be the first page.\n*/ \nstatic int pagerWalFrames(\n  Pager *pPager,                  /* Pager object */\n  PgHdr *pList,                   /* List of frames to log */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit                    /* True if this is a commit */\n){\n  int rc;                         /* Return code */\n  int nList;                      /* Number of pages in pList */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)\n  PgHdr *p;                       /* For looping over pages */\n#endif\n\n  assert( pPager->pWal );\n  assert( pList );\n#ifdef SQLITE_DEBUG\n  /* Verify that the page list is in accending order */\n  for(p=pList; p && p->pDirty; p=p->pDirty){\n    assert( p->pgno < p->pDirty->pgno );\n  }\n#endif\n\n  assert( pList->pDirty==0 || isCommit );\n  if( isCommit ){\n    /* If a WAL transaction is being committed, there is no point in writing\n    ** any pages with page numbers greater than nTruncate into the WAL file.\n    ** They will never be read by any client. So remove them from the pDirty\n    ** list here. */\n    PgHdr *p;\n    PgHdr **ppNext = &pList;\n    nList = 0;\n    for(p=pList; (*ppNext = p)!=0; p=p->pDirty){\n      if( p->pgno<=nTruncate ){\n        ppNext = &p->pDirty;\n        nList++;\n      }\n    }\n    assert( pList );\n  }else{\n    nList = 1;\n  }\n  pPager->aStat[PAGER_STAT_WRITE] += nList;\n\n  if( pList->pgno==1 ) pager_write_changecounter(pList);\n  rc = sqlite3WalFrames(pPager->pWal, \n      pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags\n  );\n  if( rc==SQLITE_OK && pPager->pBackup ){\n    PgHdr *p;\n    for(p=pList; p; p=p->pDirty){\n      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  for(p=pList; p; p=p->pDirty){\n    pager_set_pagehash(p);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Begin a read transaction on the WAL.\n**\n** This routine used to be called \"pagerOpenSnapshot()\" because it essentially\n** makes a snapshot of the database at the current point in time and preserves\n** that snapshot for use by the reader in spite of concurrently changes by\n** other writers or checkpointers.\n*/\nstatic int pagerBeginReadTransaction(Pager *pPager){\n  int rc;                         /* Return code */\n  int changed = 0;                /* True if cache must be reset */\n\n  assert( pagerUseWal(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n\n  /* sqlite3WalEndReadTransaction() was not called for the previous\n  ** transaction in locking_mode=EXCLUSIVE.  So call it now.  If we\n  ** are in locking_mode=NORMAL and EndRead() was previously called,\n  ** the duplicate call is harmless.\n  */\n  sqlite3WalEndReadTransaction(pPager->pWal);\n\n  rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);\n  if( rc!=SQLITE_OK || changed ){\n    pager_reset(pPager);\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n  }\n\n  return rc;\n}\n#endif\n\n/*\n** This function is called as part of the transition from PAGER_OPEN\n** to PAGER_READER state to determine the size of the database file\n** in pages (assuming the page size currently stored in Pager.pageSize).\n**\n** If no error occurs, SQLITE_OK is returned and the size of the database\n** in pages is stored in *pnPage. Otherwise, an error code (perhaps\n** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified.\n*/\nstatic int pagerPagecount(Pager *pPager, Pgno *pnPage){\n  Pgno nPage;                     /* Value to return via *pnPage */\n\n  /* Query the WAL sub-system for the database size. The WalDbsize()\n  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or\n  ** if the database size is not available. The database size is not\n  ** available from the WAL sub-system if the log file is empty or\n  ** contains no valid committed transactions.\n  */\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n  nPage = sqlite3WalDbsize(pPager->pWal);\n\n  /* If the database size was not available from the WAL sub-system,\n  ** determine it based on the size of the database file. If the size\n  ** of the database file is not an integer multiple of the page-size,\n  ** round down to the nearest page. Except, any file larger than 0\n  ** bytes in size is considered to contain at least one page.\n  */\n  if( nPage==0 ){\n    i64 n = 0;                    /* Size of db file in bytes */\n    assert( isOpen(pPager->fd) || pPager->tempFile );\n    if( isOpen(pPager->fd) ){\n      int rc = sqlite3OsFileSize(pPager->fd, &n);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n    nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);\n  }\n\n  /* If the current number of pages in the file is greater than the\n  ** configured maximum pager number, increase the allowed limit so\n  ** that the file can be read.\n  */\n  if( nPage>pPager->mxPgno ){\n    pPager->mxPgno = (Pgno)nPage;\n  }\n\n  *pnPage = nPage;\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Check if the *-wal file that corresponds to the database opened by pPager\n** exists if the database is not empy, or verify that the *-wal file does\n** not exist (by deleting it) if the database file is empty.\n**\n** If the database is not empty and the *-wal file exists, open the pager\n** in WAL mode.  If the database is empty or if no *-wal file exists and\n** if no error occurs, make sure Pager.journalMode is not set to\n** PAGER_JOURNALMODE_WAL.\n**\n** Return SQLITE_OK or an error code.\n**\n** The caller must hold a SHARED lock on the database file to call this\n** function. Because an EXCLUSIVE lock on the db file is required to delete \n** a WAL on a none-empty database, this ensures there is no race condition \n** between the xAccess() below and an xDelete() being executed by some \n** other connection.\n*/\nstatic int pagerOpenWalIfPresent(Pager *pPager){\n  int rc = SQLITE_OK;\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n\n  if( !pPager->tempFile ){\n    int isWal;                    /* True if WAL file exists */\n    Pgno nPage;                   /* Size of the database file */\n\n    rc = pagerPagecount(pPager, &nPage);\n    if( rc ) return rc;\n    if( nPage==0 ){\n      rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);\n      if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;\n      isWal = 0;\n    }else{\n      rc = sqlite3OsAccess(\n          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal\n      );\n    }\n    if( rc==SQLITE_OK ){\n      if( isWal ){\n        testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );\n        rc = sqlite3PagerOpenWal(pPager, 0);\n      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){\n        pPager->journalMode = PAGER_JOURNALMODE_DELETE;\n      }\n    }\n  }\n  return rc;\n}\n#endif\n\n/*\n** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback\n** the entire master journal file. The case pSavepoint==NULL occurs when \n** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction \n** savepoint.\n**\n** When pSavepoint is not NULL (meaning a non-transaction savepoint is \n** being rolled back), then the rollback consists of up to three stages,\n** performed in the order specified:\n**\n**   * Pages are played back from the main journal starting at byte\n**     offset PagerSavepoint.iOffset and continuing to \n**     PagerSavepoint.iHdrOffset, or to the end of the main journal\n**     file if PagerSavepoint.iHdrOffset is zero.\n**\n**   * If PagerSavepoint.iHdrOffset is not zero, then pages are played\n**     back starting from the journal header immediately following \n**     PagerSavepoint.iHdrOffset to the end of the main journal file.\n**\n**   * Pages are then played back from the sub-journal file, starting\n**     with the PagerSavepoint.iSubRec and continuing to the end of\n**     the journal file.\n**\n** Throughout the rollback process, each time a page is rolled back, the\n** corresponding bit is set in a bitvec structure (variable pDone in the\n** implementation below). This is used to ensure that a page is only\n** rolled back the first time it is encountered in either journal.\n**\n** If pSavepoint is NULL, then pages are only played back from the main\n** journal file. There is no need for a bitvec in this case.\n**\n** In either case, before playback commences the Pager.dbSize variable\n** is reset to the value that it held at the start of the savepoint \n** (or transaction). No page with a page-number greater than this value\n** is played back. If one is encountered it is simply skipped.\n*/\nstatic int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){\n  i64 szJ;                 /* Effective size of the main journal */\n  i64 iHdrOff;             /* End of first segment of main-journal records */\n  int rc = SQLITE_OK;      /* Return code */\n  Bitvec *pDone = 0;       /* Bitvec to ensure pages played back only once */\n\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n\n  /* Allocate a bitvec to use to store the set of pages rolled back */\n  if( pSavepoint ){\n    pDone = sqlite3BitvecCreate(pSavepoint->nOrig);\n    if( !pDone ){\n      return SQLITE_NOMEM;\n    }\n  }\n\n  /* Set the database size back to the value it was before the savepoint \n  ** being reverted was opened.\n  */\n  pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( !pSavepoint && pagerUseWal(pPager) ){\n    return pagerRollbackWal(pPager);\n  }\n\n  /* Use pPager->journalOff as the effective size of the main rollback\n  ** journal.  The actual file might be larger than this in\n  ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST.  But anything\n  ** past pPager->journalOff is off-limits to us.\n  */\n  szJ = pPager->journalOff;\n  assert( pagerUseWal(pPager)==0 || szJ==0 );\n\n  /* Begin by rolling back records from the main journal starting at\n  ** PagerSavepoint.iOffset and continuing to the next journal header.\n  ** There might be records in the main journal that have a page number\n  ** greater than the current database size (pPager->dbSize) but those\n  ** will be skipped automatically.  Pages are added to pDone as they\n  ** are played back.\n  */\n  if( pSavepoint && !pagerUseWal(pPager) ){\n    iHdrOff = pSavepoint->iHdrOffset ? pSavepoint->iHdrOffset : szJ;\n    pPager->journalOff = pSavepoint->iOffset;\n    while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }else{\n    pPager->journalOff = 0;\n  }\n\n  /* Continue rolling back records out of the main journal starting at\n  ** the first journal header seen and continuing until the effective end\n  ** of the main journal file.  Continue to skip out-of-range pages and\n  ** continue adding pages rolled back to pDone.\n  */\n  while( rc==SQLITE_OK && pPager->journalOff<szJ ){\n    u32 ii;            /* Loop counter */\n    u32 nJRec = 0;     /* Number of Journal Records */\n    u32 dummy;\n    rc = readJournalHdr(pPager, 0, szJ, &nJRec, &dummy);\n    assert( rc!=SQLITE_DONE );\n\n    /*\n    ** The \"pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\"\n    ** test is related to ticket #2565.  See the discussion in the\n    ** pager_playback() function for additional information.\n    */\n    if( nJRec==0 \n     && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\n    ){\n      nJRec = (u32)((szJ - pPager->journalOff)/JOURNAL_PG_SZ(pPager));\n    }\n    for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n  assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );\n\n  /* Finally,  rollback pages from the sub-journal.  Page that were\n  ** previously rolled back out of the main journal (and are hence in pDone)\n  ** will be skipped.  Out-of-range pages are also skipped.\n  */\n  if( pSavepoint ){\n    u32 ii;            /* Loop counter */\n    i64 offset = (i64)pSavepoint->iSubRec*(4+pPager->pageSize);\n\n    if( pagerUseWal(pPager) ){\n      rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);\n    }\n    for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){\n      assert( offset==(i64)ii*(4+pPager->pageSize) );\n      rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n\n  sqlite3BitvecDestroy(pDone);\n  if( rc==SQLITE_OK ){\n    pPager->journalOff = szJ;\n  }\n\n  return rc;\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){\n  sqlite3PcacheSetCachesize(pPager->pPCache, mxPage);\n}\n\n/*\n** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.\n*/\nstatic void pagerFixMaplimit(Pager *pPager){\n#if SQLITE_MAX_MMAP_SIZE>0\n  sqlite3_file *fd = pPager->fd;\n  if( isOpen(fd) ){\n    sqlite3_int64 sz;\n    pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->szMmap>0;\n    sz = pPager->szMmap;\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);\n  }\n#endif\n}\n\n/*\n** Change the maximum size of any memory mapping made of the database file.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 szMmap){\n  pPager->szMmap = szMmap;\n  pagerFixMaplimit(pPager);\n}\n\n/*\n** Free as much memory as possible from the pager.\n*/\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager *pPager){\n  sqlite3PcacheShrink(pPager->pPCache);\n}\n\n/*\n** Adjust the robustness of the database to damage due to OS crashes\n** or power failures by changing the number of syncs()s when writing\n** the rollback journal.  There are three levels:\n**\n**    OFF       sqlite3OsSync() is never called.  This is the default\n**              for temporary and transient files.\n**\n**    NORMAL    The journal is synced once before writes begin on the\n**              database.  This is normally adequate protection, but\n**              it is theoretically possible, though very unlikely,\n**              that an inopertune power failure could leave the journal\n**              in a state which would cause damage to the database\n**              when it is rolled back.\n**\n**    FULL      The journal is synced twice before writes begin on the\n**              database (with some additional information - the nRec field\n**              of the journal header - being written in between the two\n**              syncs).  If we assume that writing a\n**              single disk sector is atomic, then this mode provides\n**              assurance that the journal will not be corrupted to the\n**              point of causing damage to the database during rollback.\n**\n** The above is for a rollback-journal mode.  For WAL mode, OFF continues\n** to mean that no syncs ever occur.  NORMAL means that the WAL is synced\n** prior to the start of checkpoint and that the database file is synced\n** at the conclusion of the checkpoint if the entire content of the WAL\n** was written back into the database.  But no sync operations occur for\n** an ordinary commit in NORMAL mode with WAL.  FULL means that the WAL\n** file is synced following each commit operation, in addition to the\n** syncs associated with NORMAL.\n**\n** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL.  The\n** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync\n** using fcntl(F_FULLFSYNC).  SQLITE_SYNC_NORMAL means to do an\n** ordinary fsync() call.  There is no difference between SQLITE_SYNC_FULL\n** and SQLITE_SYNC_NORMAL on platforms other than MacOSX.  But the\n** synchronous=FULL versus synchronous=NORMAL setting determines when\n** the xSync primitive is called and is relevant to all platforms.\n**\n** Numeric values associated with these states are OFF==1, NORMAL=2,\n** and FULL=3.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(\n  Pager *pPager,        /* The pager to set safety level for */\n  int level,            /* PRAGMA synchronous.  1=OFF, 2=NORMAL, 3=FULL */  \n  int bFullFsync,       /* PRAGMA fullfsync */\n  int bCkptFullFsync    /* PRAGMA checkpoint_fullfsync */\n){\n  assert( level>=1 && level<=3 );\n  pPager->noSync =  (level==1 || pPager->tempFile) ?1:0;\n  pPager->fullSync = (level==3 && !pPager->tempFile) ?1:0;\n  if( pPager->noSync ){\n    pPager->syncFlags = 0;\n    pPager->ckptSyncFlags = 0;\n  }else if( bFullFsync ){\n    pPager->syncFlags = SQLITE_SYNC_FULL;\n    pPager->ckptSyncFlags = SQLITE_SYNC_FULL;\n  }else if( bCkptFullFsync ){\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->ckptSyncFlags = SQLITE_SYNC_FULL;\n  }else{\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->ckptSyncFlags = SQLITE_SYNC_NORMAL;\n  }\n  pPager->walSyncFlags = pPager->syncFlags;\n  if( pPager->fullSync ){\n    pPager->walSyncFlags |= WAL_SYNC_TRANSACTIONS;\n  }\n}\n#endif\n\n/*\n** The following global variable is incremented whenever the library\n** attempts to open a temporary file.  This information is used for\n** testing and analysis only.  \n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_opentemp_count = 0;\n#endif\n\n/*\n** Open a temporary file.\n**\n** Write the file descriptor into *pFile. Return SQLITE_OK on success \n** or some other error code if we fail. The OS will automatically \n** delete the temporary file when it is closed.\n**\n** The flags passed to the VFS layer xOpen() call are those specified\n** by parameter vfsFlags ORed with the following:\n**\n**     SQLITE_OPEN_READWRITE\n**     SQLITE_OPEN_CREATE\n**     SQLITE_OPEN_EXCLUSIVE\n**     SQLITE_OPEN_DELETEONCLOSE\n*/\nstatic int pagerOpentemp(\n  Pager *pPager,        /* The pager object */\n  sqlite3_file *pFile,  /* Write the file descriptor here */\n  int vfsFlags          /* Flags passed through to the VFS */\n){\n  int rc;               /* Return code */\n\n#ifdef SQLITE_TEST\n  sqlite3_opentemp_count++;  /* Used for testing and analysis only */\n#endif\n\n  vfsFlags |=  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n            SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n  rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);\n  assert( rc!=SQLITE_OK || isOpen(pFile) );\n  return rc;\n}\n\n/*\n** Set the busy handler function.\n**\n** The pager invokes the busy-handler if sqlite3OsLock() returns \n** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,\n** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE \n** lock. It does *not* invoke the busy handler when upgrading from\n** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE\n** (which occurs during hot-journal rollback). Summary:\n**\n**   Transition                        | Invokes xBusyHandler\n**   --------------------------------------------------------\n**   NO_LOCK       -> SHARED_LOCK      | Yes\n**   SHARED_LOCK   -> RESERVED_LOCK    | No\n**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No\n**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes\n**\n** If the busy-handler callback returns non-zero, the lock is \n** retried. If it returns zero, then the SQLITE_BUSY error is\n** returned to the caller of the pager API function.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetBusyhandler(\n  Pager *pPager,                       /* Pager object */\n  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */\n  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */\n){\n  pPager->xBusyHandler = xBusyHandler;\n  pPager->pBusyHandlerArg = pBusyHandlerArg;\n\n  if( isOpen(pPager->fd) ){\n    void **ap = (void **)&pPager->xBusyHandler;\n    assert( ((int(*)(void *))(ap[0]))==xBusyHandler );\n    assert( ap[1]==pBusyHandlerArg );\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);\n  }\n}\n\n/*\n** Change the page size used by the Pager object. The new page size \n** is passed in *pPageSize.\n**\n** If the pager is in the error state when this function is called, it\n** is a no-op. The value returned is the error state error code (i.e. \n** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).\n**\n** Otherwise, if all of the following are true:\n**\n**   * the new page size (value of *pPageSize) is valid (a power \n**     of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and\n**\n**   * there are no outstanding page references, and\n**\n**   * the database is either not an in-memory database or it is\n**     an in-memory database that currently consists of zero pages.\n**\n** then the pager object page size is set to *pPageSize.\n**\n** If the page size is changed, then this function uses sqlite3PagerMalloc() \n** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt \n** fails, SQLITE_NOMEM is returned and the page size remains unchanged. \n** In all other cases, SQLITE_OK is returned.\n**\n** If the page size is not changed, either because one of the enumerated\n** conditions above is not true, the pager was in error state when this\n** function was called, or because the memory allocation attempt failed, \n** then *pPageSize is set to the old, retained page size before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){\n  int rc = SQLITE_OK;\n\n  /* It is not possible to do a full assert_pager_state() here, as this\n  ** function may be called from within PagerOpen(), before the state\n  ** of the Pager object is internally consistent.\n  **\n  ** At one point this function returned an error if the pager was in \n  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that\n  ** there is at least one outstanding page reference, this function\n  ** is a no-op for that case anyhow.\n  */\n\n  u32 pageSize = *pPageSize;\n  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );\n  if( (pPager->memDb==0 || pPager->dbSize==0)\n   && sqlite3PcacheRefCount(pPager->pPCache)==0 \n   && pageSize && pageSize!=(u32)pPager->pageSize \n  ){\n    char *pNew = NULL;             /* New temp space */\n    i64 nByte = 0;\n\n    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){\n      rc = sqlite3OsFileSize(pPager->fd, &nByte);\n    }\n    if( rc==SQLITE_OK ){\n      pNew = (char *)sqlite3PageMalloc(pageSize);\n      if( !pNew ) rc = SQLITE_NOMEM;\n    }\n\n    if( rc==SQLITE_OK ){\n      pager_reset(pPager);\n      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);\n      pPager->pageSize = pageSize;\n      sqlite3PageFree(pPager->pTmpSpace);\n      pPager->pTmpSpace = pNew;\n      sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);\n    }\n  }\n\n  *pPageSize = pPager->pageSize;\n  if( rc==SQLITE_OK ){\n    if( nReserve<0 ) nReserve = pPager->nReserve;\n    assert( nReserve>=0 && nReserve<1000 );\n    pPager->nReserve = (i16)nReserve;\n    pagerReportSize(pPager);\n    pagerFixMaplimit(pPager);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to the \"temporary page\" buffer held internally\n** by the pager.  This is a buffer that is big enough to hold the\n** entire content of a database page.  This buffer is used internally\n** during rollback and will be overwritten whenever a rollback\n** occurs.  But other modules are free to use it too, as long as\n** no rollbacks are happening.\n*/\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager *pPager){\n  return pPager->pTmpSpace;\n}\n\n/*\n** Attempt to set the maximum database page count if mxPage is positive. \n** Make no changes if mxPage is zero or negative.  And never reduce the\n** maximum page count below the current size of the database.\n**\n** Regardless of mxPage, return the current maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){\n  if( mxPage>0 ){\n    pPager->mxPgno = mxPage;\n  }\n  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */\n  assert( pPager->mxPgno>=pPager->dbSize );  /* OP_MaxPgcnt enforces this */\n  return pPager->mxPgno;\n}\n\n/*\n** The following set of routines are used to disable the simulated\n** I/O error mechanism.  These routines are used to avoid simulated\n** errors in places where we do not care about errors.\n**\n** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops\n** and generate no code.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_hit;\nstatic int saved_cnt;\nvoid disable_simulated_io_errors(void){\n  saved_cnt = sqlite3_io_error_pending;\n  sqlite3_io_error_pending = -1;\n}\nvoid enable_simulated_io_errors(void){\n  sqlite3_io_error_pending = saved_cnt;\n}\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n/*\n** Read the first N bytes from the beginning of the file into memory\n** that pDest points to. \n**\n** If the pager was opened on a transient file (zFilename==\"\"), or\n** opened on a file less than N bytes in size, the output buffer is\n** zeroed and SQLITE_OK returned. The rationale for this is that this \n** function is used to read database headers, and a new transient or\n** zero sized database has a header than consists entirely of zeroes.\n**\n** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered,\n** the error code is returned to the caller and the contents of the\n** output buffer undefined.\n*/\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){\n  int rc = SQLITE_OK;\n  memset(pDest, 0, N);\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  /* This routine is only called by btree immediately after creating\n  ** the Pager object.  There has not been an opportunity to transition\n  ** to WAL mode yet.\n  */\n  assert( !pagerUseWal(pPager) );\n\n  if( isOpen(pPager->fd) ){\n    IOTRACE((\"DBHDR %p 0 %d\\n\", pPager, N))\n    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function may only be called when a read-transaction is open on\n** the pager. It returns the total number of pages in the database.\n**\n** However, if the file is between 1 and <page-size> bytes in size, then \n** this is considered a 1 page file.\n*/\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){\n  assert( pPager->eState>=PAGER_READER );\n  assert( pPager->eState!=PAGER_WRITER_FINISHED );\n  *pnPage = (int)pPager->dbSize;\n}\n\n\n/*\n** Try to obtain a lock of type locktype on the database file. If\n** a similar or greater lock is already held, this function is a no-op\n** (returning SQLITE_OK immediately).\n**\n** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke \n** the busy callback if the lock is currently not available. Repeat \n** until the busy callback returns false or until the attempt to \n** obtain the lock succeeds.\n**\n** Return SQLITE_OK on success and an error code if we cannot obtain\n** the lock. If the lock is obtained successfully, set the Pager.state \n** variable to locktype before returning.\n*/\nstatic int pager_wait_on_lock(Pager *pPager, int locktype){\n  int rc;                              /* Return code */\n\n  /* Check that this is either a no-op (because the requested lock is \n  ** already held, or one of the transistions that the busy-handler\n  ** may be invoked during, according to the comment above\n  ** sqlite3PagerSetBusyhandler().\n  */\n  assert( (pPager->eLock>=locktype)\n       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)\n       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)\n  );\n\n  do {\n    rc = pagerLockDb(pPager, locktype);\n  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );\n  return rc;\n}\n\n/*\n** Function assertTruncateConstraint(pPager) checks that one of the \n** following is true for all dirty pages currently in the page-cache:\n**\n**   a) The page number is less than or equal to the size of the \n**      current database image, in pages, OR\n**\n**   b) if the page content were written at this time, it would not\n**      be necessary to write the current content out to the sub-journal\n**      (as determined by function subjRequiresPage()).\n**\n** If the condition asserted by this function were not true, and the\n** dirty page were to be discarded from the cache via the pagerStress()\n** routine, pagerStress() would not write the current page content to\n** the database file. If a savepoint transaction were rolled back after\n** this happened, the correct behavior would be to restore the current\n** content of the page. However, since this content is not present in either\n** the database file or the portion of the rollback journal and \n** sub-journal rolled back the content could not be restored and the\n** database image would become corrupt. It is therefore fortunate that \n** this circumstance cannot arise.\n*/\n#if defined(SQLITE_DEBUG)\nstatic void assertTruncateConstraintCb(PgHdr *pPg){\n  assert( pPg->flags&PGHDR_DIRTY );\n  assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );\n}\nstatic void assertTruncateConstraint(Pager *pPager){\n  sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);\n}\n#else\n# define assertTruncateConstraint(pPager)\n#endif\n\n/*\n** Truncate the in-memory database file image to nPage pages. This \n** function does not actually modify the database file on disk. It \n** just sets the internal state of the pager object so that the \n** truncation will be done when the current transaction is committed.\n**\n** This function is only called right before committing a transaction.\n** Once this function has been called, the transaction must either be\n** rolled back or committed. It is not safe to call this function and\n** then continue writing to the database.\n*/\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){\n  assert( pPager->dbSize>=nPage );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  pPager->dbSize = nPage;\n\n  /* At one point the code here called assertTruncateConstraint() to\n  ** ensure that all pages being truncated away by this operation are,\n  ** if one or more savepoints are open, present in the savepoint \n  ** journal so that they can be restored if the savepoint is rolled\n  ** back. This is no longer necessary as this function is now only\n  ** called right before committing a transaction. So although the \n  ** Pager object may still have open savepoints (Pager.nSavepoint!=0), \n  ** they cannot be rolled back. So the assertTruncateConstraint() call\n  ** is no longer correct. */\n}\n\n\n/*\n** This function is called before attempting a hot-journal rollback. It\n** syncs the journal file to disk, then sets pPager->journalHdr to the\n** size of the journal file so that the pager_playback() routine knows\n** that the entire journal file has been synced.\n**\n** Syncing a hot-journal to disk before attempting to roll it back ensures \n** that if a power-failure occurs during the rollback, the process that\n** attempts rollback following system recovery sees the same journal\n** content as this process.\n**\n** If everything goes as planned, SQLITE_OK is returned. Otherwise, \n** an SQLite error code.\n*/\nstatic int pagerSyncHotJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !pPager->noSync ){\n    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);\n  }\n  return rc;\n}\n\n/*\n** Obtain a reference to a memory mapped page object for page number pgno. \n** The new object will use the pointer pData, obtained from xFetch().\n** If successful, set *ppPage to point to the new page reference\n** and return SQLITE_OK. Otherwise, return an SQLite error code and set\n** *ppPage to zero.\n**\n** Page references obtained by calling this function should be released\n** by calling pagerReleaseMapPage().\n*/\nstatic int pagerAcquireMapPage(\n  Pager *pPager,                  /* Pager object */\n  Pgno pgno,                      /* Page number */\n  void *pData,                    /* xFetch()'d data for this page */\n  PgHdr **ppPage                  /* OUT: Acquired page object */\n){\n  PgHdr *p;                       /* Memory mapped page to return */\n\n  if( pPager->pMmapFreelist ){\n    *ppPage = p = pPager->pMmapFreelist;\n    pPager->pMmapFreelist = p->pDirty;\n    p->pDirty = 0;\n    memset(p->pExtra, 0, pPager->nExtra);\n  }else{\n    *ppPage = p = (PgHdr *)sqlite3MallocZero(sizeof(PgHdr) + pPager->nExtra);\n    if( p==0 ){\n      sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1) * pPager->pageSize, pData);\n      return SQLITE_NOMEM;\n    }\n    p->pExtra = (void *)&p[1];\n    p->flags = PGHDR_MMAP;\n    p->nRef = 1;\n    p->pPager = pPager;\n  }\n\n  assert( p->pExtra==(void *)&p[1] );\n  assert( p->pPage==0 );\n  assert( p->flags==PGHDR_MMAP );\n  assert( p->pPager==pPager );\n  assert( p->nRef==1 );\n\n  p->pgno = pgno;\n  p->pData = pData;\n  pPager->nMmapOut++;\n\n  return SQLITE_OK;\n}\n\n/*\n** Release a reference to page pPg. pPg must have been returned by an \n** earlier call to pagerAcquireMapPage().\n*/\nstatic void pagerReleaseMapPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  pPager->nMmapOut--;\n  pPg->pDirty = pPager->pMmapFreelist;\n  pPager->pMmapFreelist = pPg;\n\n  assert( pPager->fd->pMethods->iVersion>=3 );\n  sqlite3OsUnfetch(pPager->fd, (i64)(pPg->pgno-1)*pPager->pageSize, pPg->pData);\n}\n\n/*\n** Free all PgHdr objects stored in the Pager.pMmapFreelist list.\n*/\nstatic void pagerFreeMapHdrs(Pager *pPager){\n  PgHdr *p;\n  PgHdr *pNext;\n  for(p=pPager->pMmapFreelist; p; p=pNext){\n    pNext = p->pDirty;\n    sqlite3_free(p);\n  }\n}\n\n\n/*\n** Shutdown the page cache.  Free all memory and close all files.\n**\n** If a transaction was in progress when this routine is called, that\n** transaction is rolled back.  All outstanding pages are invalidated\n** and their memory is freed.  Any attempt to use a page associated\n** with this page cache after this function returns will likely\n** result in a coredump.\n**\n** This function always succeeds. If a transaction is active an attempt\n** is made to roll it back. If an error occurs during the rollback \n** a hot journal may be left in the filesystem but no error is returned\n** to the caller.\n*/\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){\n  u8 *pTmp = (u8 *)pPager->pTmpSpace;\n\n  assert( assert_pager_state(pPager) );\n  disable_simulated_io_errors();\n  sqlite3BeginBenignMalloc();\n  pagerFreeMapHdrs(pPager);\n  /* pPager->errCode = 0; */\n  pPager->exclusiveMode = 0;\n#ifndef SQLITE_OMIT_WAL\n  sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp);\n  pPager->pWal = 0;\n#endif\n  pager_reset(pPager);\n  if( MEMDB ){\n    pager_unlock(pPager);\n  }else{\n    /* If it is open, sync the journal file before calling UnlockAndRollback.\n    ** If this is not done, then an unsynced portion of the open journal \n    ** file may be played back into the database. If a power failure occurs \n    ** while this is happening, the database could become corrupt.\n    **\n    ** If an error occurs while trying to sync the journal, shift the pager\n    ** into the ERROR state. This causes UnlockAndRollback to unlock the\n    ** database and close the journal file without attempting to roll it\n    ** back or finalize it. The next database user will have to do hot-journal\n    ** rollback before accessing the database file.\n    */\n    if( isOpen(pPager->jfd) ){\n      pager_error(pPager, pagerSyncHotJournal(pPager));\n    }\n    pagerUnlockAndRollback(pPager);\n  }\n  sqlite3EndBenignMalloc();\n  enable_simulated_io_errors();\n  PAGERTRACE((\"CLOSE %d\\n\", PAGERID(pPager)));\n  IOTRACE((\"CLOSE %p\\n\", pPager))\n  sqlite3OsClose(pPager->jfd);\n  sqlite3OsClose(pPager->fd);\n  sqlite3PageFree(pTmp);\n  sqlite3PcacheClose(pPager->pPCache);\n\n#ifdef SQLITE_HAS_CODEC\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n#endif\n\n  assert( !pPager->aSavepoint && !pPager->pInJournal );\n  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );\n\n  sqlite3_free(pPager);\n  return SQLITE_OK;\n}\n\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\n/*\n** Return the page number for page pPg.\n*/\nSQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage *pPg){\n  return pPg->pgno;\n}\n#endif\n\n/*\n** Increment the reference count for page pPg.\n*/\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){\n  sqlite3PcacheRef(pPg);\n}\n\n/*\n** Sync the journal. In other words, make sure all the pages that have\n** been written to the journal have actually reached the surface of the\n** disk and can be restored in the event of a hot-journal rollback.\n**\n** If the Pager.noSync flag is set, then this function is a no-op.\n** Otherwise, the actions required depend on the journal-mode and the \n** device characteristics of the file-system, as follows:\n**\n**   * If the journal file is an in-memory journal file, no action need\n**     be taken.\n**\n**   * Otherwise, if the device does not support the SAFE_APPEND property,\n**     then the nRec field of the most recently written journal header\n**     is updated to contain the number of journal records that have\n**     been written following it. If the pager is operating in full-sync\n**     mode, then the journal file is synced before this field is updated.\n**\n**   * If the device does not support the SEQUENTIAL property, then \n**     journal file is synced.\n**\n** Or, in pseudo-code:\n**\n**   if( NOT <in-memory journal> ){\n**     if( NOT SAFE_APPEND ){\n**       if( <full-sync mode> ) xSync(<journal file>);\n**       <update nRec field>\n**     } \n**     if( NOT SEQUENTIAL ) xSync(<journal file>);\n**   }\n**\n** If successful, this routine clears the PGHDR_NEED_SYNC flag of every \n** page currently held in memory before returning SQLITE_OK. If an IO\n** error is encountered, then the IO error code is returned to the caller.\n*/\nstatic int syncJournal(Pager *pPager, int newHdr){\n  int rc;                         /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( !pagerUseWal(pPager) );\n\n  rc = sqlite3PagerExclusiveLock(pPager);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( !pPager->noSync ){\n    assert( !pPager->tempFile );\n    if( isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){\n      const int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      assert( isOpen(pPager->jfd) );\n\n      if( 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        /* This block deals with an obscure problem. If the last connection\n        ** that wrote to this database was operating in persistent-journal\n        ** mode, then the journal file may at this point actually be larger\n        ** than Pager.journalOff bytes. If the next thing in the journal\n        ** file happens to be a journal-header (written as part of the\n        ** previous connection's transaction), and a crash or power-failure \n        ** occurs after nRec is updated but before this connection writes \n        ** anything else to the journal file (or commits/rolls back its \n        ** transaction), then SQLite may become confused when doing the \n        ** hot-journal rollback following recovery. It may roll back all\n        ** of this connections data, then proceed to rolling back the old,\n        ** out-of-date data that follows it. Database corruption.\n        **\n        ** To work around this, if the journal file does appear to contain\n        ** a valid header following Pager.journalOff, then write a 0x00\n        ** byte to the start of it to prevent it from being recognized.\n        **\n        ** Variable iNextHdrOffset is set to the offset at which this\n        ** problematic header will occur, if it exists. aMagic is used \n        ** as a temporary buffer to inspect the first couple of bytes of\n        ** the potential journal header.\n        */\n        i64 iNextHdrOffset;\n        u8 aMagic[8];\n        u8 zHeader[sizeof(aJournalMagic)+4];\n\n        memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n        put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);\n\n        iNextHdrOffset = journalHdrOffset(pPager);\n        rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);\n        if( rc==SQLITE_OK && 0==memcmp(aMagic, aJournalMagic, 8) ){\n          static const u8 zerobyte = 0;\n          rc = sqlite3OsWrite(pPager->jfd, &zerobyte, 1, iNextHdrOffset);\n        }\n        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){\n          return rc;\n        }\n\n        /* Write the nRec value into the journal file header. If in\n        ** full-synchronous mode, sync the journal first. This ensures that\n        ** all data has really hit the disk before nRec is updated to mark\n        ** it as a candidate for rollback.\n        **\n        ** This is not required if the persistent media supports the\n        ** SAFE_APPEND property. Because in this case it is not possible \n        ** for garbage data to be appended to the file, the nRec field\n        ** is populated with 0xFFFFFFFF when the journal header is written\n        ** and never needs to be updated.\n        */\n        if( pPager->fullSync && 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n          PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n          IOTRACE((\"JSYNC %p\\n\", pPager))\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n        IOTRACE((\"JHDR %p %lld\\n\", pPager, pPager->journalHdr));\n        rc = sqlite3OsWrite(\n            pPager->jfd, zHeader, sizeof(zHeader), pPager->journalHdr\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n      if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n        PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n        IOTRACE((\"JSYNC %p\\n\", pPager))\n        rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags| \n          (pPager->syncFlags==SQLITE_SYNC_FULL?SQLITE_SYNC_DATAONLY:0)\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n\n      pPager->journalHdr = pPager->journalOff;\n      if( newHdr && 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        pPager->nRec = 0;\n        rc = writeJournalHdr(pPager);\n        if( rc!=SQLITE_OK ) return rc;\n      }\n    }else{\n      pPager->journalHdr = pPager->journalOff;\n    }\n  }\n\n  /* Unless the pager is in noSync mode, the journal file was just \n  ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on \n  ** all pages.\n  */\n  sqlite3PcacheClearSyncFlags(pPager->pPCache);\n  pPager->eState = PAGER_WRITER_DBMOD;\n  assert( assert_pager_state(pPager) );\n  return SQLITE_OK;\n}\n\n/*\n** The argument is the first in a linked list of dirty pages connected\n** by the PgHdr.pDirty pointer. This function writes each one of the\n** in-memory pages in the list to the database file. The argument may\n** be NULL, representing an empty list. In this case this function is\n** a no-op.\n**\n** The pager must hold at least a RESERVED lock when this function\n** is called. Before writing anything to the database file, this lock\n** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,\n** SQLITE_BUSY is returned and no data is written to the database file.\n** \n** If the pager is a temp-file pager and the actual file-system file\n** is not yet open, it is created and opened before any data is \n** written out.\n**\n** Once the lock has been upgraded and, if necessary, the file opened,\n** the pages are written out to the database file in list order. Writing\n** a page is skipped if it meets either of the following criteria:\n**\n**   * The page number is greater than Pager.dbSize, or\n**   * The PGHDR_DONT_WRITE flag is set on the page.\n**\n** If writing out a page causes the database file to grow, Pager.dbFileSize\n** is updated accordingly. If page 1 is written out, then the value cached\n** in Pager.dbFileVers[] is updated to match the new value stored in\n** the database file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot\n** be obtained, SQLITE_BUSY is returned.\n*/\nstatic int pager_write_pagelist(Pager *pPager, PgHdr *pList){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This function is only called for rollback pagers in WRITER_DBMOD state. */\n  assert( !pagerUseWal(pPager) );\n  assert( pPager->eState==PAGER_WRITER_DBMOD );\n  assert( pPager->eLock==EXCLUSIVE_LOCK );\n\n  /* If the file is a temp-file has not yet been opened, open it now. It\n  ** is not possible for rc to be other than SQLITE_OK if this branch\n  ** is taken, as pager_wait_on_lock() is a no-op for temp-files.\n  */\n  if( !isOpen(pPager->fd) ){\n    assert( pPager->tempFile && rc==SQLITE_OK );\n    rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);\n  }\n\n  /* Before the first write, give the VFS a hint of what the final\n  ** file size will be.\n  */\n  assert( rc!=SQLITE_OK || isOpen(pPager->fd) );\n  if( rc==SQLITE_OK \n   && (pList->pDirty ? pPager->dbSize : pList->pgno+1)>pPager->dbHintSize \n  ){\n    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);\n    pPager->dbHintSize = pPager->dbSize;\n  }\n\n  while( rc==SQLITE_OK && pList ){\n    Pgno pgno = pList->pgno;\n\n    /* If there are dirty pages in the page cache with page numbers greater\n    ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to\n    ** make the file smaller (presumably by auto-vacuum code). Do not write\n    ** any such pages to the file.\n    **\n    ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag\n    ** set (set by sqlite3PagerDontWrite()).\n    */\n    if( pgno<=pPager->dbSize && 0==(pList->flags&PGHDR_DONT_WRITE) ){\n      i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */\n      char *pData;                                   /* Data to write */    \n\n      assert( (pList->flags&PGHDR_NEED_SYNC)==0 );\n      if( pList->pgno==1 ) pager_write_changecounter(pList);\n\n      /* Encode the database */\n      CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM, pData);\n\n      /* Write out the page data. */\n      rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize, offset);\n\n      /* If page 1 was just written, update Pager.dbFileVers to match\n      ** the value now stored in the database file. If writing this \n      ** page caused the database file to grow, update dbFileSize. \n      */\n      if( pgno==1 ){\n        memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));\n      }\n      if( pgno>pPager->dbFileSize ){\n        pPager->dbFileSize = pgno;\n      }\n      pPager->aStat[PAGER_STAT_WRITE]++;\n\n      /* Update any backup objects copying the contents of this pager. */\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);\n\n      PAGERTRACE((\"STORE %d page %d hash(%08x)\\n\",\n                   PAGERID(pPager), pgno, pager_pagehash(pList)));\n      IOTRACE((\"PGOUT %p %d\\n\", pPager, pgno));\n      PAGER_INCR(sqlite3_pager_writedb_count);\n    }else{\n      PAGERTRACE((\"NOSTORE %d page %d\\n\", PAGERID(pPager), pgno));\n    }\n    pager_set_pagehash(pList);\n    pList = pList->pDirty;\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the sub-journal file is open. If it is already open, this \n** function is a no-op.\n**\n** SQLITE_OK is returned if everything goes according to plan. An \n** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() \n** fails.\n*/\nstatic int openSubJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !isOpen(pPager->sjfd) ){\n    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){\n      sqlite3MemJournalOpen(pPager->sjfd);\n    }else{\n      rc = pagerOpentemp(pPager, pPager->sjfd, SQLITE_OPEN_SUBJOURNAL);\n    }\n  }\n  return rc;\n}\n\n/*\n** Append a record of the current state of page pPg to the sub-journal. \n** It is the callers responsibility to use subjRequiresPage() to check \n** that it is really required before calling this function.\n**\n** If successful, set the bit corresponding to pPg->pgno in the bitvecs\n** for all open savepoints before returning.\n**\n** This function returns SQLITE_OK if everything is successful, an IO\n** error code if the attempt to write to the sub-journal fails, or \n** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint\n** bitvec.\n*/\nstatic int subjournalPage(PgHdr *pPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = pPg->pPager;\n  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n\n    /* Open the sub-journal, if it has not already been opened */\n    assert( pPager->useJournal );\n    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );\n    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );\n    assert( pagerUseWal(pPager) \n         || pageInJournal(pPg) \n         || pPg->pgno>pPager->dbOrigSize \n    );\n    rc = openSubJournal(pPager);\n\n    /* If the sub-journal was opened successfully (or was already open),\n    ** write the journal record into the file.  */\n    if( rc==SQLITE_OK ){\n      void *pData = pPg->pData;\n      i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize);\n      char *pData2;\n  \n      CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);\n      PAGERTRACE((\"STMT-JOURNAL %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n      rc = write32bits(pPager->sjfd, offset, pPg->pgno);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    pPager->nSubRec++;\n    assert( pPager->nSavepoint>0 );\n    rc = addToSavepointBitvecs(pPager, pPg->pgno);\n  }\n  return rc;\n}\n\n/*\n** This function is called by the pcache layer when it has reached some\n** soft memory limit. The first argument is a pointer to a Pager object\n** (cast as a void*). The pager is always 'purgeable' (not an in-memory\n** database). The second argument is a reference to a page that is \n** currently dirty but has no outstanding references. The page\n** is always associated with the Pager object passed as the first \n** argument.\n**\n** The job of this function is to make pPg clean by writing its contents\n** out to the database file, if possible. This may involve syncing the\n** journal file. \n**\n** If successful, sqlite3PcacheMakeClean() is called on the page and\n** SQLITE_OK returned. If an IO error occurs while trying to make the\n** page clean, the IO error code is returned. If the page cannot be\n** made clean for some other reason, but no error occurs, then SQLITE_OK\n** is returned by sqlite3PcacheMakeClean() is not called.\n*/\nstatic int pagerStress(void *p, PgHdr *pPg){\n  Pager *pPager = (Pager *)p;\n  int rc = SQLITE_OK;\n\n  assert( pPg->pPager==pPager );\n  assert( pPg->flags&PGHDR_DIRTY );\n\n  /* The doNotSyncSpill flag is set during times when doing a sync of\n  ** journal (and adding a new header) is not allowed.  This occurs\n  ** during calls to sqlite3PagerWrite() while trying to journal multiple\n  ** pages belonging to the same sector.\n  **\n  ** The doNotSpill flag inhibits all cache spilling regardless of whether\n  ** or not a sync is required.  This is set during a rollback.\n  **\n  ** Spilling is also prohibited when in an error state since that could\n  ** lead to database corruption.   In the current implementaton it \n  ** is impossible for sqlite3PcacheFetch() to be called with createFlag==1\n  ** while in the error state, hence it is impossible for this routine to\n  ** be called in the error state.  Nevertheless, we include a NEVER()\n  ** test for the error state as a safeguard against future changes.\n  */\n  if( NEVER(pPager->errCode) ) return SQLITE_OK;\n  if( pPager->doNotSpill ) return SQLITE_OK;\n  if( pPager->doNotSyncSpill && (pPg->flags & PGHDR_NEED_SYNC)!=0 ){\n    return SQLITE_OK;\n  }\n\n  pPg->pDirty = 0;\n  if( pagerUseWal(pPager) ){\n    /* Write a single frame for this page to the log. */\n    if( subjRequiresPage(pPg) ){ \n      rc = subjournalPage(pPg); \n    }\n    if( rc==SQLITE_OK ){\n      rc = pagerWalFrames(pPager, pPg, 0, 0);\n    }\n  }else{\n  \n    /* Sync the journal file if required. */\n    if( pPg->flags&PGHDR_NEED_SYNC \n     || pPager->eState==PAGER_WRITER_CACHEMOD\n    ){\n      rc = syncJournal(pPager, 1);\n    }\n  \n    /* If the page number of this page is larger than the current size of\n    ** the database image, it may need to be written to the sub-journal.\n    ** This is because the call to pager_write_pagelist() below will not\n    ** actually write data to the file in this case.\n    **\n    ** Consider the following sequence of events:\n    **\n    **   BEGIN;\n    **     <journal page X>\n    **     <modify page X>\n    **     SAVEPOINT sp;\n    **       <shrink database file to Y pages>\n    **       pagerStress(page X)\n    **     ROLLBACK TO sp;\n    **\n    ** If (X>Y), then when pagerStress is called page X will not be written\n    ** out to the database file, but will be dropped from the cache. Then,\n    ** following the \"ROLLBACK TO sp\" statement, reading page X will read\n    ** data from the database file. This will be the copy of page X as it\n    ** was when the transaction started, not as it was when \"SAVEPOINT sp\"\n    ** was executed.\n    **\n    ** The solution is to write the current data for page X into the \n    ** sub-journal file now (if it is not already there), so that it will\n    ** be restored to its current value when the \"ROLLBACK TO sp\" is \n    ** executed.\n    */\n    if( NEVER(\n        rc==SQLITE_OK && pPg->pgno>pPager->dbSize && subjRequiresPage(pPg)\n    ) ){\n      rc = subjournalPage(pPg);\n    }\n  \n    /* Write the contents of the page out to the database file. */\n    if( rc==SQLITE_OK ){\n      assert( (pPg->flags&PGHDR_NEED_SYNC)==0 );\n      rc = pager_write_pagelist(pPager, pPg);\n    }\n  }\n\n  /* Mark the page as clean. */\n  if( rc==SQLITE_OK ){\n    PAGERTRACE((\"STRESS %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n    sqlite3PcacheMakeClean(pPg);\n  }\n\n  return pager_error(pPager, rc); \n}\n\n\n/*\n** Allocate and initialize a new Pager object and put a pointer to it\n** in *ppPager. The pager should eventually be freed by passing it\n** to sqlite3PagerClose().\n**\n** The zFilename argument is the path to the database file to open.\n** If zFilename is NULL then a randomly-named temporary file is created\n** and used as the file to be cached. Temporary files are be deleted\n** automatically when they are closed. If zFilename is \":memory:\" then \n** all information is held in cache. It is never written to disk. \n** This can be used to implement an in-memory database.\n**\n** The nExtra parameter specifies the number of bytes of space allocated\n** along with each page reference. This space is available to the user\n** via the sqlite3PagerGetExtra() API.\n**\n** The flags argument is used to specify properties that affect the\n** operation of the pager. It should be passed some bitwise combination\n** of the PAGER_* flags.\n**\n** The vfsFlags parameter is a bitmask to pass to the flags parameter\n** of the xOpen() method of the supplied VFS when opening files. \n**\n** If the pager object is allocated and the specified file opened \n** successfully, SQLITE_OK is returned and *ppPager set to point to\n** the new pager object. If an error occurs, *ppPager is set to NULL\n** and error code returned. This function may return SQLITE_NOMEM\n** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or \n** various SQLITE_IO_XXX errors.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs *pVfs,       /* The virtual file system to use */\n  Pager **ppPager,         /* OUT: Return the Pager structure here */\n  const char *zFilename,   /* Name of the database file to open */\n  int nExtra,              /* Extra bytes append to each in-memory page */\n  int flags,               /* flags controlling this file */\n  int vfsFlags,            /* flags passed through to sqlite3_vfs.xOpen() */\n  void (*xReinit)(DbPage*) /* Function to reinitialize pages */\n){\n  u8 *pPtr;\n  Pager *pPager = 0;       /* Pager object to allocate and return */\n  int rc = SQLITE_OK;      /* Return code */\n  int tempFile = 0;        /* True for temp files (incl. in-memory files) */\n  int memDb = 0;           /* True if this is an in-memory file */\n  int readOnly = 0;        /* True if this is a read-only file */\n  int journalFileSize;     /* Bytes to allocate for each journal fd */\n  char *zPathname = 0;     /* Full path to database file */\n  int nPathname = 0;       /* Number of bytes in zPathname */\n  int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */\n  int pcacheSize = sqlite3PcacheSize();       /* Bytes to allocate for PCache */\n  u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */\n  const char *zUri = 0;    /* URI args to copy */\n  int nUri = 0;            /* Number of bytes of URI args at *zUri */\n\n  /* Figure out how much space is required for each journal file-handle\n  ** (there are two of them, the main journal and the sub-journal). This\n  ** is the maximum space required for an in-memory journal file handle \n  ** and a regular journal file-handle. Note that a \"regular journal-handle\"\n  ** may be a wrapper capable of caching the first portion of the journal\n  ** file in memory to implement the atomic-write optimization (see \n  ** source file journal.c).\n  */\n  if( sqlite3JournalSize(pVfs)>sqlite3MemJournalSize() ){\n    journalFileSize = ROUND8(sqlite3JournalSize(pVfs));\n  }else{\n    journalFileSize = ROUND8(sqlite3MemJournalSize());\n  }\n\n  /* Set the output variable to NULL in case an error occurs. */\n  *ppPager = 0;\n\n#ifndef SQLITE_OMIT_MEMORYDB\n  if( flags & PAGER_MEMORY ){\n    memDb = 1;\n    if( zFilename && zFilename[0] ){\n      zPathname = sqlite3DbStrDup(0, zFilename);\n      if( zPathname==0  ) return SQLITE_NOMEM;\n      nPathname = sqlite3Strlen30(zPathname);\n      zFilename = 0;\n    }\n  }\n#endif\n\n  /* Compute and store the full pathname in an allocated buffer pointed\n  ** to by zPathname, length nPathname. Or, if this is a temporary file,\n  ** leave both nPathname and zPathname set to 0.\n  */\n  if( zFilename && zFilename[0] ){\n    const char *z;\n    nPathname = pVfs->mxPathname+1;\n    zPathname = sqlite3DbMallocRaw(0, nPathname*2);\n    if( zPathname==0 ){\n      return SQLITE_NOMEM;\n    }\n    zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */\n    rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);\n    nPathname = sqlite3Strlen30(zPathname);\n    z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];\n    while( *z ){\n      z += sqlite3Strlen30(z)+1;\n      z += sqlite3Strlen30(z)+1;\n    }\n    nUri = (int)(&z[1] - zUri);\n    assert( nUri>=0 );\n    if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){\n      /* This branch is taken when the journal path required by\n      ** the database being opened will be more than pVfs->mxPathname\n      ** bytes in length. This means the database cannot be opened,\n      ** as it will not be possible to open the journal file or even\n      ** check for a hot-journal before reading.\n      */\n      rc = SQLITE_CANTOPEN_BKPT;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(0, zPathname);\n      return rc;\n    }\n  }\n\n  /* Allocate memory for the Pager structure, PCache object, the\n  ** three file descriptors, the database file name and the journal \n  ** file name. The layout in memory is as follows:\n  **\n  **     Pager object                    (sizeof(Pager) bytes)\n  **     PCache object                   (sqlite3PcacheSize() bytes)\n  **     Database file handle            (pVfs->szOsFile bytes)\n  **     Sub-journal file handle         (journalFileSize bytes)\n  **     Main journal file handle        (journalFileSize bytes)\n  **     Database file name              (nPathname+1 bytes)\n  **     Journal file name               (nPathname+8+1 bytes)\n  */\n  pPtr = (u8 *)sqlite3MallocZero(\n    ROUND8(sizeof(*pPager)) +      /* Pager structure */\n    ROUND8(pcacheSize) +           /* PCache object */\n    ROUND8(pVfs->szOsFile) +       /* The main db file */\n    journalFileSize * 2 +          /* The two journal files */ \n    nPathname + 1 + nUri +         /* zFilename */\n    nPathname + 8 + 2              /* zJournal */\n#ifndef SQLITE_OMIT_WAL\n    + nPathname + 4 + 2            /* zWal */\n#endif\n  );\n  assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );\n  if( !pPtr ){\n    sqlite3DbFree(0, zPathname);\n    return SQLITE_NOMEM;\n  }\n  pPager =              (Pager*)(pPtr);\n  pPager->pPCache =    (PCache*)(pPtr += ROUND8(sizeof(*pPager)));\n  pPager->fd =   (sqlite3_file*)(pPtr += ROUND8(pcacheSize));\n  pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));\n  pPager->jfd =  (sqlite3_file*)(pPtr += journalFileSize);\n  pPager->zFilename =    (char*)(pPtr += journalFileSize);\n  assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );\n\n  /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */\n  if( zPathname ){\n    assert( nPathname>0 );\n    pPager->zJournal =   (char*)(pPtr += nPathname + 1 + nUri);\n    memcpy(pPager->zFilename, zPathname, nPathname);\n    if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);\n    memcpy(pPager->zJournal, zPathname, nPathname);\n    memcpy(&pPager->zJournal[nPathname], \"-journal\\000\", 8+2);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);\n#ifndef SQLITE_OMIT_WAL\n    pPager->zWal = &pPager->zJournal[nPathname+8+1];\n    memcpy(pPager->zWal, zPathname, nPathname);\n    memcpy(&pPager->zWal[nPathname], \"-wal\\000\", 4+1);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);\n#endif\n    sqlite3DbFree(0, zPathname);\n  }\n  pPager->pVfs = pVfs;\n  pPager->vfsFlags = vfsFlags;\n\n  /* Open the pager file.\n  */\n  if( zFilename && zFilename[0] ){\n    int fout = 0;                    /* VFS flags returned by xOpen() */\n    rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);\n    assert( !memDb );\n    readOnly = (fout&SQLITE_OPEN_READONLY);\n\n    /* If the file was successfully opened for read/write access,\n    ** choose a default page size in case we have to create the\n    ** database file. The default page size is the maximum of:\n    **\n    **    + SQLITE_DEFAULT_PAGE_SIZE,\n    **    + The value returned by sqlite3OsSectorSize()\n    **    + The largest page size that can be written atomically.\n    */\n    if( rc==SQLITE_OK && !readOnly ){\n      setSectorSize(pPager);\n      assert(SQLITE_DEFAULT_PAGE_SIZE<=SQLITE_MAX_DEFAULT_PAGE_SIZE);\n      if( szPageDflt<pPager->sectorSize ){\n        if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){\n          szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;\n        }else{\n          szPageDflt = (u32)pPager->sectorSize;\n        }\n      }\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n      {\n        int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n        int ii;\n        assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n        assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n        assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);\n        for(ii=szPageDflt; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){\n          if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ){\n            szPageDflt = ii;\n          }\n        }\n      }\n#endif\n    }\n  }else{\n    /* If a temporary file is requested, it is not opened immediately.\n    ** In this case we accept the default page size and delay actually\n    ** opening the file until the first call to OsWrite().\n    **\n    ** This branch is also run for an in-memory database. An in-memory\n    ** database is the same as a temp-file that is never written out to\n    ** disk and uses an in-memory rollback journal.\n    */ \n    tempFile = 1;\n    pPager->eState = PAGER_READER;\n    pPager->eLock = EXCLUSIVE_LOCK;\n    readOnly = (vfsFlags&SQLITE_OPEN_READONLY);\n  }\n\n  /* The following call to PagerSetPagesize() serves to set the value of \n  ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer.\n  */\n  if( rc==SQLITE_OK ){\n    assert( pPager->memDb==0 );\n    rc = sqlite3PagerSetPagesize(pPager, &szPageDflt, -1);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  /* If an error occurred in either of the blocks above, free the \n  ** Pager structure and close the file.\n  */\n  if( rc!=SQLITE_OK ){\n    assert( !pPager->pTmpSpace );\n    sqlite3OsClose(pPager->fd);\n    sqlite3_free(pPager);\n    return rc;\n  }\n\n  /* Initialize the PCache object. */\n  assert( nExtra<1000 );\n  nExtra = ROUND8(nExtra);\n  sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,\n                    !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);\n\n  PAGERTRACE((\"OPEN %d %s\\n\", FILEHANDLEID(pPager->fd), pPager->zFilename));\n  IOTRACE((\"OPEN %p %s\\n\", pPager, pPager->zFilename))\n\n  pPager->useJournal = (u8)useJournal;\n  /* pPager->stmtOpen = 0; */\n  /* pPager->stmtInUse = 0; */\n  /* pPager->nRef = 0; */\n  /* pPager->stmtSize = 0; */\n  /* pPager->stmtJSize = 0; */\n  /* pPager->nPage = 0; */\n  pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;\n  /* pPager->state = PAGER_UNLOCK; */\n#if 0\n  assert( pPager->state == (tempFile ? PAGER_EXCLUSIVE : PAGER_UNLOCK) );\n#endif\n  /* pPager->errMask = 0; */\n  pPager->tempFile = (u8)tempFile;\n  assert( tempFile==PAGER_LOCKINGMODE_NORMAL \n          || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 );\n  pPager->exclusiveMode = (u8)tempFile; \n  pPager->changeCountDone = pPager->tempFile;\n  pPager->memDb = (u8)memDb;\n  pPager->readOnly = (u8)readOnly;\n  assert( useJournal || pPager->tempFile );\n  pPager->noSync = pPager->tempFile;\n  if( pPager->noSync ){\n    assert( pPager->fullSync==0 );\n    assert( pPager->syncFlags==0 );\n    assert( pPager->walSyncFlags==0 );\n    assert( pPager->ckptSyncFlags==0 );\n  }else{\n    pPager->fullSync = 1;\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->walSyncFlags = SQLITE_SYNC_NORMAL | WAL_SYNC_TRANSACTIONS;\n    pPager->ckptSyncFlags = SQLITE_SYNC_NORMAL;\n  }\n  /* pPager->pFirst = 0; */\n  /* pPager->pFirstSynced = 0; */\n  /* pPager->pLast = 0; */\n  pPager->nExtra = (u16)nExtra;\n  pPager->journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT;\n  assert( isOpen(pPager->fd) || tempFile );\n  setSectorSize(pPager);\n  if( !useJournal ){\n    pPager->journalMode = PAGER_JOURNALMODE_OFF;\n  }else if( memDb ){\n    pPager->journalMode = PAGER_JOURNALMODE_MEMORY;\n  }\n  /* pPager->xBusyHandler = 0; */\n  /* pPager->pBusyHandlerArg = 0; */\n  pPager->xReiniter = xReinit;\n  /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */\n  /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */\n\n  *ppPager = pPager;\n  return SQLITE_OK;\n}\n\n\n\n/*\n** This function is called after transitioning from PAGER_UNLOCK to\n** PAGER_SHARED state. It tests if there is a hot journal present in\n** the file-system for the given pager. A hot journal is one that \n** needs to be played back. According to this function, a hot-journal\n** file exists if the following criteria are met:\n**\n**   * The journal file exists in the file system, and\n**   * No process holds a RESERVED or greater lock on the database file, and\n**   * The database file itself is greater than 0 bytes in size, and\n**   * The first byte of the journal file exists and is not 0x00.\n**\n** If the current size of the database file is 0 but a journal file\n** exists, that is probably an old journal left over from a prior\n** database with the same name. In this case the journal file is\n** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK\n** is returned.\n**\n** This routine does not check if there is a master journal filename\n** at the end of the file. If there is, and that master journal file\n** does not exist, then the journal file is not really hot. In this\n** case this routine will return a false-positive. The pager_playback()\n** routine will discover that the journal file is not really hot and \n** will not roll it back. \n**\n** If a hot-journal file is found to exist, *pExists is set to 1 and \n** SQLITE_OK returned. If no hot-journal file is present, *pExists is\n** set to 0 and SQLITE_OK returned. If an IO error occurs while trying\n** to determine whether or not a hot-journal file exists, the IO error\n** code is returned and the value of *pExists is undefined.\n*/\nstatic int hasHotJournal(Pager *pPager, int *pExists){\n  sqlite3_vfs * const pVfs = pPager->pVfs;\n  int rc = SQLITE_OK;           /* Return code */\n  int exists = 1;               /* True if a journal file is present */\n  int jrnlOpen = !!isOpen(pPager->jfd);\n\n  assert( pPager->useJournal );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->eState==PAGER_OPEN );\n\n  assert( jrnlOpen==0 || ( sqlite3OsDeviceCharacteristics(pPager->jfd) &\n    SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n  ));\n\n  *pExists = 0;\n  if( !jrnlOpen ){\n    rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);\n  }\n  if( rc==SQLITE_OK && exists ){\n    int locked = 0;             /* True if some process holds a RESERVED lock */\n\n    /* Race condition here:  Another process might have been holding the\n    ** the RESERVED lock and have a journal open at the sqlite3OsAccess() \n    ** call above, but then delete the journal and drop the lock before\n    ** we get to the following sqlite3OsCheckReservedLock() call.  If that\n    ** is the case, this routine might think there is a hot journal when\n    ** in fact there is none.  This results in a false-positive which will\n    ** be dealt with by the playback routine.  Ticket #3883.\n    */\n    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);\n    if( rc==SQLITE_OK && !locked ){\n      Pgno nPage;                 /* Number of pages in database file */\n\n      /* Check the size of the database file. If it consists of 0 pages,\n      ** then delete the journal file. See the header comment above for \n      ** the reasoning here.  Delete the obsolete journal file under\n      ** a RESERVED lock to avoid race conditions and to avoid violating\n      ** [H33020].\n      */\n      rc = pagerPagecount(pPager, &nPage);\n      if( rc==SQLITE_OK ){\n        if( nPage==0 ){\n          sqlite3BeginBenignMalloc();\n          if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){\n            sqlite3OsDelete(pVfs, pPager->zJournal, 0);\n            if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n          }\n          sqlite3EndBenignMalloc();\n        }else{\n          /* The journal file exists and no other connection has a reserved\n          ** or greater lock on the database file. Now check that there is\n          ** at least one non-zero bytes at the start of the journal file.\n          ** If there is, then we consider this journal to be hot. If not, \n          ** it can be ignored.\n          */\n          if( !jrnlOpen ){\n            int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;\n            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);\n          }\n          if( rc==SQLITE_OK ){\n            u8 first = 0;\n            rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);\n            if( rc==SQLITE_IOERR_SHORT_READ ){\n              rc = SQLITE_OK;\n            }\n            if( !jrnlOpen ){\n              sqlite3OsClose(pPager->jfd);\n            }\n            *pExists = (first!=0);\n          }else if( rc==SQLITE_CANTOPEN ){\n            /* If we cannot open the rollback journal file in order to see if\n            ** its has a zero header, that might be due to an I/O error, or\n            ** it might be due to the race condition described above and in\n            ** ticket #3883.  Either way, assume that the journal is hot.\n            ** This might be a false positive.  But if it is, then the\n            ** automatic journal playback and recovery mechanism will deal\n            ** with it under an EXCLUSIVE lock where we do not need to\n            ** worry so much with race conditions.\n            */\n            *pExists = 1;\n            rc = SQLITE_OK;\n          }\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to obtain a shared lock on the database file.\n** It is illegal to call sqlite3PagerAcquire() until after this function\n** has been successfully called. If a shared-lock is already held when\n** this function is called, it is a no-op.\n**\n** The following operations are also performed by this function.\n**\n**   1) If the pager is currently in PAGER_OPEN state (no lock held\n**      on the database file), then an attempt is made to obtain a\n**      SHARED lock on the database file. Immediately after obtaining\n**      the SHARED lock, the file-system is checked for a hot-journal,\n**      which is played back if present. Following any hot-journal \n**      rollback, the contents of the cache are validated by checking\n**      the 'change-counter' field of the database file header and\n**      discarded if they are found to be invalid.\n**\n**   2) If the pager is running in exclusive-mode, and there are currently\n**      no outstanding references to any pages, and is in the error state,\n**      then an attempt is made to clear the error state by discarding\n**      the contents of the page cache and rolling back any open journal\n**      file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs while locking the database, checking for a hot-journal file or \n** rolling back a journal file, the IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){\n  int rc = SQLITE_OK;                /* Return code */\n\n  /* This routine is only called from b-tree and only when there are no\n  ** outstanding pages. This implies that the pager state should either\n  ** be OPEN or READER. READER is only possible if the pager is or was in \n  ** exclusive access mode.\n  */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n  if( NEVER(MEMDB && pPager->errCode) ){ return pPager->errCode; }\n\n  if( !pagerUseWal(pPager) && pPager->eState==PAGER_OPEN ){\n    int bHotJournal = 1;          /* True if there exists a hot journal-file */\n\n    assert( !MEMDB );\n\n    rc = pager_wait_on_lock(pPager, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK );\n      goto failed;\n    }\n\n    /* If a journal file exists, and there is no RESERVED lock on the\n    ** database file, then it either needs to be played back or deleted.\n    */\n    if( pPager->eLock<=SHARED_LOCK ){\n      rc = hasHotJournal(pPager, &bHotJournal);\n    }\n    if( rc!=SQLITE_OK ){\n      goto failed;\n    }\n    if( bHotJournal ){\n      if( pPager->readOnly ){\n        rc = SQLITE_READONLY_ROLLBACK;\n        goto failed;\n      }\n\n      /* Get an EXCLUSIVE lock on the database file. At this point it is\n      ** important that a RESERVED lock is not obtained on the way to the\n      ** EXCLUSIVE lock. If it were, another process might open the\n      ** database file, detect the RESERVED lock, and conclude that the\n      ** database is safe to read while this process is still rolling the \n      ** hot-journal back.\n      ** \n      ** Because the intermediate RESERVED lock is not requested, any\n      ** other process attempting to access the database file will get to \n      ** this point in the code and fail to obtain its own EXCLUSIVE lock \n      ** on the database file.\n      **\n      ** Unless the pager is in locking_mode=exclusive mode, the lock is\n      ** downgraded to SHARED_LOCK before this function returns.\n      */\n      rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n      if( rc!=SQLITE_OK ){\n        goto failed;\n      }\n \n      /* If it is not already open and the file exists on disk, open the \n      ** journal for read/write access. Write access is required because \n      ** in exclusive-access mode the file descriptor will be kept open \n      ** and possibly used for a transaction later on. Also, write-access \n      ** is usually required to finalize the journal in journal_mode=persist \n      ** mode (and also for journal_mode=truncate on some systems).\n      **\n      ** If the journal does not exist, it usually means that some \n      ** other connection managed to get in and roll it back before \n      ** this connection obtained the exclusive lock above. Or, it \n      ** may mean that the pager was in the error-state when this\n      ** function was called and the journal file does not exist.\n      */\n      if( !isOpen(pPager->jfd) ){\n        sqlite3_vfs * const pVfs = pPager->pVfs;\n        int bExists;              /* True if journal file exists */\n        rc = sqlite3OsAccess(\n            pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);\n        if( rc==SQLITE_OK && bExists ){\n          int fout = 0;\n          int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;\n          assert( !pPager->tempFile );\n          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);\n          assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n          if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){\n            rc = SQLITE_CANTOPEN_BKPT;\n            sqlite3OsClose(pPager->jfd);\n          }\n        }\n      }\n \n      /* Playback and delete the journal.  Drop the database write\n      ** lock and reacquire the read lock. Purge the cache before\n      ** playing back the hot-journal so that we don't end up with\n      ** an inconsistent cache.  Sync the hot journal before playing\n      ** it back since the process that crashed and left the hot journal\n      ** probably did not sync it and we are required to always sync\n      ** the journal before playing it back.\n      */\n      if( isOpen(pPager->jfd) ){\n        assert( rc==SQLITE_OK );\n        rc = pagerSyncHotJournal(pPager);\n        if( rc==SQLITE_OK ){\n          rc = pager_playback(pPager, 1);\n          pPager->eState = PAGER_OPEN;\n        }\n      }else if( !pPager->exclusiveMode ){\n        pagerUnlockDb(pPager, SHARED_LOCK);\n      }\n\n      if( rc!=SQLITE_OK ){\n        /* This branch is taken if an error occurs while trying to open\n        ** or roll back a hot-journal while holding an EXCLUSIVE lock. The\n        ** pager_unlock() routine will be called before returning to unlock\n        ** the file. If the unlock attempt fails, then Pager.eLock must be\n        ** set to UNKNOWN_LOCK (see the comment above the #define for \n        ** UNKNOWN_LOCK above for an explanation). \n        **\n        ** In order to get pager_unlock() to do this, set Pager.eState to\n        ** PAGER_ERROR now. This is not actually counted as a transition\n        ** to ERROR state in the state diagram at the top of this file,\n        ** since we know that the same call to pager_unlock() will very\n        ** shortly transition the pager object to the OPEN state. Calling\n        ** assert_pager_state() would fail now, as it should not be possible\n        ** to be in ERROR state when there are zero outstanding page \n        ** references.\n        */\n        pager_error(pPager, rc);\n        goto failed;\n      }\n\n      assert( pPager->eState==PAGER_OPEN );\n      assert( (pPager->eLock==SHARED_LOCK)\n           || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK)\n      );\n    }\n\n    if( !pPager->tempFile && (\n        pPager->pBackup \n     || sqlite3PcachePagecount(pPager->pPCache)>0 \n     || USEFETCH(pPager)\n    )){\n      /* The shared-lock has just been acquired on the database file\n      ** and there are already pages in the cache (from a previous\n      ** read or write transaction).  Check to see if the database\n      ** has been modified.  If the database has changed, flush the\n      ** cache.\n      **\n      ** Database changes is detected by looking at 15 bytes beginning\n      ** at offset 24 into the file.  The first 4 of these 16 bytes are\n      ** a 32-bit counter that is incremented with each change.  The\n      ** other bytes change randomly with each file change when\n      ** a codec is in use.\n      ** \n      ** There is a vanishingly small chance that a change will not be \n      ** detected.  The chance of an undetected change is so small that\n      ** it can be neglected.\n      */\n      Pgno nPage = 0;\n      char dbFileVers[sizeof(pPager->dbFileVers)];\n\n      rc = pagerPagecount(pPager, &nPage);\n      if( rc ) goto failed;\n\n      if( nPage>0 ){\n        IOTRACE((\"CKVERS %p %d\\n\", pPager, sizeof(dbFileVers)));\n        rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);\n        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){\n          goto failed;\n        }\n      }else{\n        memset(dbFileVers, 0, sizeof(dbFileVers));\n      }\n\n      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){\n        pager_reset(pPager);\n\n        /* Unmap the database file. It is possible that external processes\n        ** may have truncated the database file and then extended it back\n        ** to its original size while this process was not holding a lock.\n        ** In this case there may exist a Pager.pMap mapping that appears\n        ** to be the right size but is not actually valid. Avoid this\n        ** possibility by unmapping the db here. */\n        if( USEFETCH(pPager) ){\n          sqlite3OsUnfetch(pPager->fd, 0, 0);\n        }\n      }\n    }\n\n    /* If there is a WAL file in the file-system, open this database in WAL\n    ** mode. Otherwise, the following function call is a no-op.\n    */\n    rc = pagerOpenWalIfPresent(pPager);\n#ifndef SQLITE_OMIT_WAL\n    assert( pPager->pWal==0 || rc==SQLITE_OK );\n#endif\n  }\n\n  if( pagerUseWal(pPager) ){\n    assert( rc==SQLITE_OK );\n    rc = pagerBeginReadTransaction(pPager);\n  }\n\n  if( pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){\n    rc = pagerPagecount(pPager, &pPager->dbSize);\n  }\n\n failed:\n  if( rc!=SQLITE_OK ){\n    assert( !MEMDB );\n    pager_unlock(pPager);\n    assert( pPager->eState==PAGER_OPEN );\n  }else{\n    pPager->eState = PAGER_READER;\n  }\n  return rc;\n}\n\n/*\n** If the reference count has reached zero, rollback any active\n** transaction and unlock the pager.\n**\n** Except, in locking_mode=EXCLUSIVE when there is nothing to in\n** the rollback journal, the unlock is not performed and there is\n** nothing to rollback, so this routine is a no-op.\n*/ \nstatic void pagerUnlockIfUnused(Pager *pPager){\n  if( pPager->nMmapOut==0 && (sqlite3PcacheRefCount(pPager->pPCache)==0) ){\n    pagerUnlockAndRollback(pPager);\n  }\n}\n\n/*\n** Acquire a reference to page number pgno in pager pPager (a page\n** reference has type DbPage*). If the requested reference is \n** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.\n**\n** If the requested page is already in the cache, it is returned. \n** Otherwise, a new page object is allocated and populated with data\n** read from the database file. In some cases, the pcache module may\n** choose not to allocate a new page object and may reuse an existing\n** object with no outstanding references.\n**\n** The extra data appended to a page is always initialized to zeros the \n** first time a page is loaded into memory. If the page requested is \n** already in the cache when this function is called, then the extra\n** data is left as it was when the page object was last used.\n**\n** If the database image is smaller than the requested page or if a \n** non-zero value is passed as the noContent parameter and the \n** requested page is not already stored in the cache, then no \n** actual disk read occurs. In this case the memory image of the \n** page is initialized to all zeros. \n**\n** If noContent is true, it means that we do not care about the contents\n** of the page. This occurs in two seperate scenarios:\n**\n**   a) When reading a free-list leaf page from the database, and\n**\n**   b) When a savepoint is being rolled back and we need to load\n**      a new page into the cache to be filled with the data read\n**      from the savepoint journal.\n**\n** If noContent is true, then the data returned is zeroed instead of\n** being read from the database. Additionally, the bits corresponding\n** to pgno in Pager.pInJournal (bitvec of pages already written to the\n** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open\n** savepoints are set. This means if the page is made writable at any\n** point in the future, using a call to sqlite3PagerWrite(), its contents\n** will not be journaled. This saves IO.\n**\n** The acquisition might fail for several reasons.  In all cases,\n** an appropriate error code is returned and *ppPage is set to NULL.\n**\n** See also sqlite3PagerLookup().  Both this routine and Lookup() attempt\n** to find a page in the in-memory cache first.  If the page is not already\n** in memory, this routine goes to disk to read it in whereas Lookup()\n** just returns 0.  This routine acquires a read-lock the first time it\n** has to go to disk, and could also playback an old journal if necessary.\n** Since Lookup() never goes to disk, it never has to deal with locks\n** or journal files.\n*/\nSQLITE_PRIVATE int sqlite3PagerAcquire(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_ACQUIRE_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg = 0;\n  u32 iFrame = 0;                 /* Frame to read from WAL file */\n  const int noContent = (flags & PAGER_ACQUIRE_NOCONTENT);\n\n  /* It is acceptable to use a read-only (mmap) page for any page except\n  ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY\n  ** flag was specified by the caller. And so long as the db is not a \n  ** temporary or in-memory database.  */\n  const int bMmapOk = (pgno!=1 && USEFETCH(pPager)\n   && (pPager->eState==PAGER_READER || (flags & PAGER_ACQUIRE_READONLY))\n#ifdef SQLITE_HAS_CODEC\n   && pPager->xCodec==0\n#endif\n  );\n\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( noContent==0 || bMmapOk==0 );\n\n  if( pgno==0 ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n\n  /* If the pager is in the error state, return an error immediately. \n  ** Otherwise, request the page from the PCache layer. */\n  if( pPager->errCode!=SQLITE_OK ){\n    rc = pPager->errCode;\n  }else{\n\n    if( bMmapOk && pagerUseWal(pPager) ){\n      rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);\n      if( rc!=SQLITE_OK ) goto pager_acquire_err;\n    }\n\n    if( iFrame==0 && bMmapOk ){\n      void *pData = 0;\n\n      rc = sqlite3OsFetch(pPager->fd, \n          (i64)(pgno-1) * pPager->pageSize, pPager->pageSize, &pData\n      );\n\n      if( rc==SQLITE_OK && pData ){\n        if( pPager->eState>PAGER_READER ){\n          (void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);\n        }\n        if( pPg==0 ){\n          rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);\n        }else{\n          sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1)*pPager->pageSize, pData);\n        }\n        if( pPg ){\n          assert( rc==SQLITE_OK );\n          *ppPage = pPg;\n          return SQLITE_OK;\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        goto pager_acquire_err;\n      }\n    }\n\n    rc = sqlite3PcacheFetch(pPager->pPCache, pgno, 1, ppPage);\n  }\n\n  if( rc!=SQLITE_OK ){\n    /* Either the call to sqlite3PcacheFetch() returned an error or the\n    ** pager was already in the error-state when this function was called.\n    ** Set pPg to 0 and jump to the exception handler.  */\n    pPg = 0;\n    goto pager_acquire_err;\n  }\n  assert( (*ppPage)->pgno==pgno );\n  assert( (*ppPage)->pPager==pPager || (*ppPage)->pPager==0 );\n\n  if( (*ppPage)->pPager && !noContent ){\n    /* In this case the pcache already contains an initialized copy of\n    ** the page. Return without further ado.  */\n    assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );\n    pPager->aStat[PAGER_STAT_HIT]++;\n    return SQLITE_OK;\n\n  }else{\n    /* The pager cache has created a new page. Its content needs to \n    ** be initialized.  */\n\n    pPg = *ppPage;\n    pPg->pPager = pPager;\n\n    /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page\n    ** number greater than this, or the unused locking-page, is requested. */\n    if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto pager_acquire_err;\n    }\n\n    if( MEMDB || pPager->dbSize<pgno || noContent || !isOpen(pPager->fd) ){\n      if( pgno>pPager->mxPgno ){\n        rc = SQLITE_FULL;\n        goto pager_acquire_err;\n      }\n      if( noContent ){\n        /* Failure to set the bits in the InJournal bit-vectors is benign.\n        ** It merely means that we might do some extra work to journal a \n        ** page that does not need to be journaled.  Nevertheless, be sure \n        ** to test the case where a malloc error occurs while trying to set \n        ** a bit in a bit vector.\n        */\n        sqlite3BeginBenignMalloc();\n        if( pgno<=pPager->dbOrigSize ){\n          TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);\n          testcase( rc==SQLITE_NOMEM );\n        }\n        TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);\n        testcase( rc==SQLITE_NOMEM );\n        sqlite3EndBenignMalloc();\n      }\n      memset(pPg->pData, 0, pPager->pageSize);\n      IOTRACE((\"ZERO %p %d\\n\", pPager, pgno));\n    }else{\n      if( pagerUseWal(pPager) && bMmapOk==0 ){\n        rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);\n        if( rc!=SQLITE_OK ) goto pager_acquire_err;\n      }\n      assert( pPg->pPager==pPager );\n      pPager->aStat[PAGER_STAT_MISS]++;\n      rc = readDbPage(pPg, iFrame);\n      if( rc!=SQLITE_OK ){\n        goto pager_acquire_err;\n      }\n    }\n    pager_set_pagehash(pPg);\n  }\n\n  return SQLITE_OK;\n\npager_acquire_err:\n  assert( rc!=SQLITE_OK );\n  if( pPg ){\n    sqlite3PcacheDrop(pPg);\n  }\n  pagerUnlockIfUnused(pPager);\n\n  *ppPage = 0;\n  return rc;\n}\n\n/*\n** Acquire a page if it is already in the in-memory cache.  Do\n** not read the page from disk.  Return a pointer to the page,\n** or 0 if the page is not in cache. \n**\n** See also sqlite3PagerGet().  The difference between this routine\n** and sqlite3PagerGet() is that _get() will go to the disk and read\n** in the page if the page is not already in cache.  This routine\n** returns NULL if the page is not in cache or if a disk I/O error \n** has ever happened.\n*/\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){\n  PgHdr *pPg = 0;\n  assert( pPager!=0 );\n  assert( pgno!=0 );\n  assert( pPager->pPCache!=0 );\n  assert( pPager->eState>=PAGER_READER && pPager->eState!=PAGER_ERROR );\n  sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);\n  return pPg;\n}\n\n/*\n** Release a page reference.\n**\n** If the number of references to the page drop to zero, then the\n** page is added to the LRU list.  When all references to all pages\n** are released, a rollback occurs and the lock on the database is\n** removed.\n*/\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){\n  if( pPg ){\n    Pager *pPager = pPg->pPager;\n    if( pPg->flags & PGHDR_MMAP ){\n      pagerReleaseMapPage(pPg);\n    }else{\n      sqlite3PcacheRelease(pPg);\n    }\n    pagerUnlockIfUnused(pPager);\n  }\n}\n\n/*\n** This function is called at the start of every write transaction.\n** There must already be a RESERVED or EXCLUSIVE lock on the database \n** file when this routine is called.\n**\n** Open the journal file for pager pPager and write a journal header\n** to the start of it. If there are active savepoints, open the sub-journal\n** as well. This function is only used when the journal file is being \n** opened to write a rollback log for a transaction. It is not used \n** when opening a hot journal file to roll it back.\n**\n** If the journal file is already open (as it may be in exclusive mode),\n** then this function just writes a journal header to the start of the\n** already open file. \n**\n** Whether or not the journal file is opened by this function, the\n** Pager.pInJournal bitvec structure is allocated.\n**\n** Return SQLITE_OK if everything is successful. Otherwise, return \n** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or \n** an IO error code if opening or writing the journal file fails.\n*/\nstatic int pager_open_journal(Pager *pPager){\n  int rc = SQLITE_OK;                        /* Return code */\n  sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->pInJournal==0 );\n  \n  /* If already in the error state, this function is a no-op.  But on\n  ** the other hand, this routine is never called if we are already in\n  ** an error state. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);\n    if( pPager->pInJournal==0 ){\n      return SQLITE_NOMEM;\n    }\n  \n    /* Open the journal file if it is not already open. */\n    if( !isOpen(pPager->jfd) ){\n      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){\n        sqlite3MemJournalOpen(pPager->jfd);\n      }else{\n        const int flags =                   /* VFS flags to open journal file */\n          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|\n          (pPager->tempFile ? \n            (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):\n            (SQLITE_OPEN_MAIN_JOURNAL)\n          );\n  #ifdef SQLITE_ENABLE_ATOMIC_WRITE\n        rc = sqlite3JournalOpen(\n            pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)\n        );\n  #else\n        rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);\n  #endif\n      }\n      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n    }\n  \n  \n    /* Write the first journal header to the journal file and open \n    ** the sub-journal if necessary.\n    */\n    if( rc==SQLITE_OK ){\n      /* TODO: Check if all of these are really required. */\n      pPager->nRec = 0;\n      pPager->journalOff = 0;\n      pPager->setMaster = 0;\n      pPager->journalHdr = 0;\n      rc = writeJournalHdr(pPager);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3BitvecDestroy(pPager->pInJournal);\n    pPager->pInJournal = 0;\n  }else{\n    assert( pPager->eState==PAGER_WRITER_LOCKED );\n    pPager->eState = PAGER_WRITER_CACHEMOD;\n  }\n\n  return rc;\n}\n\n/*\n** Begin a write-transaction on the specified pager object. If a \n** write-transaction has already been opened, this function is a no-op.\n**\n** If the exFlag argument is false, then acquire at least a RESERVED\n** lock on the database file. If exFlag is true, then acquire at least\n** an EXCLUSIVE lock. If such a lock is already held, no locking \n** functions need be called.\n**\n** If the subjInMemory argument is non-zero, then any sub-journal opened\n** within this transaction will be opened as an in-memory file. This\n** has no effect if the sub-journal is already opened (as it may be when\n** running in exclusive mode) or if the transaction does not require a\n** sub-journal. If the subjInMemory argument is zero, then any required\n** sub-journal is implemented in-memory if pPager is an in-memory database, \n** or using a temporary file otherwise.\n*/\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){\n  int rc = SQLITE_OK;\n\n  if( pPager->errCode ) return pPager->errCode;\n  assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );\n  pPager->subjInMemory = (u8)subjInMemory;\n\n  if( ALWAYS(pPager->eState==PAGER_READER) ){\n    assert( pPager->pInJournal==0 );\n\n    if( pagerUseWal(pPager) ){\n      /* If the pager is configured to use locking_mode=exclusive, and an\n      ** exclusive lock on the database is not already held, obtain it now.\n      */\n      if( pPager->exclusiveMode && sqlite3WalExclusiveMode(pPager->pWal, -1) ){\n        rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        sqlite3WalExclusiveMode(pPager->pWal, 1);\n      }\n\n      /* Grab the write lock on the log file. If successful, upgrade to\n      ** PAGER_RESERVED state. Otherwise, return an error code to the caller.\n      ** The busy-handler is not invoked if another connection already\n      ** holds the write-lock. If possible, the upper layer will call it.\n      */\n      rc = sqlite3WalBeginWriteTransaction(pPager->pWal);\n    }else{\n      /* Obtain a RESERVED lock on the database file. If the exFlag parameter\n      ** is true, then immediately upgrade this to an EXCLUSIVE lock. The\n      ** busy-handler callback can be used when upgrading to the EXCLUSIVE\n      ** lock, but not when obtaining the RESERVED lock.\n      */\n      rc = pagerLockDb(pPager, RESERVED_LOCK);\n      if( rc==SQLITE_OK && exFlag ){\n        rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Change to WRITER_LOCKED state.\n      **\n      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD\n      ** when it has an open transaction, but never to DBMOD or FINISHED.\n      ** This is because in those states the code to roll back savepoint \n      ** transactions may copy data from the sub-journal into the database \n      ** file as well as into the page cache. Which would be incorrect in \n      ** WAL mode.\n      */\n      pPager->eState = PAGER_WRITER_LOCKED;\n      pPager->dbHintSize = pPager->dbSize;\n      pPager->dbFileSize = pPager->dbSize;\n      pPager->dbOrigSize = pPager->dbSize;\n      pPager->journalOff = 0;\n    }\n\n    assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );\n    assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );\n    assert( assert_pager_state(pPager) );\n  }\n\n  PAGERTRACE((\"TRANSACTION %d\\n\", PAGERID(pPager)));\n  return rc;\n}\n\n/*\n** Mark a single data page as writeable. The page is written into the \n** main journal or sub-journal as required. If the page is written into\n** one of the journals, the corresponding bit is set in the \n** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs\n** of any open savepoints as appropriate.\n*/\nstatic int pager_write(PgHdr *pPg){\n  void *pData = pPg->pData;\n  Pager *pPager = pPg->pPager;\n  int rc = SQLITE_OK;\n\n  /* This routine is not called unless a write-transaction has already \n  ** been started. The journal file may or may not be open at this point.\n  ** It is never called in the ERROR state.\n  */\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* If an error has been previously detected, report the same error\n  ** again. This should not happen, but the check provides robustness. */\n  if( NEVER(pPager->errCode) )  return pPager->errCode;\n\n  /* Higher-level routines never call this function if database is not\n  ** writable.  But check anyway, just for robustness. */\n  if( NEVER(pPager->readOnly) ) return SQLITE_PERM;\n\n  CHECK_PAGE(pPg);\n\n  /* The journal file needs to be opened. Higher level routines have already\n  ** obtained the necessary locks to begin the write-transaction, but the\n  ** rollback journal might not yet be open. Open it now if this is the case.\n  **\n  ** This is done before calling sqlite3PcacheMakeDirty() on the page. \n  ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then\n  ** an error might occur and the pager would end up in WRITER_LOCKED state\n  ** with pages marked as dirty in the cache.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED ){\n    rc = pager_open_journal(pPager);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  assert( assert_pager_state(pPager) );\n\n  /* Mark the page as dirty.  If the page has already been written\n  ** to the journal then we can return right away.\n  */\n  sqlite3PcacheMakeDirty(pPg);\n  if( pageInJournal(pPg) && !subjRequiresPage(pPg) ){\n    assert( !pagerUseWal(pPager) );\n  }else{\n  \n    /* The transaction journal now exists and we have a RESERVED or an\n    ** EXCLUSIVE lock on the main database file.  Write the current page to\n    ** the transaction journal if it is not there already.\n    */\n    if( !pageInJournal(pPg) && !pagerUseWal(pPager) ){\n      assert( pagerUseWal(pPager)==0 );\n      if( pPg->pgno<=pPager->dbOrigSize && isOpen(pPager->jfd) ){\n        u32 cksum;\n        char *pData2;\n        i64 iOff = pPager->journalOff;\n\n        /* We should never write to the journal file the page that\n        ** contains the database locks.  The following assert verifies\n        ** that we do not. */\n        assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );\n\n        assert( pPager->journalHdr<=pPager->journalOff );\n        CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM, pData2);\n        cksum = pager_cksum(pPager, (u8*)pData2);\n\n        /* Even if an IO or diskfull error occurs while journalling the\n        ** page in the block above, set the need-sync flag for the page.\n        ** Otherwise, when the transaction is rolled back, the logic in\n        ** playback_one_page() will think that the page needs to be restored\n        ** in the database file. And if an IO error occurs while doing so,\n        ** then corruption may follow.\n        */\n        pPg->flags |= PGHDR_NEED_SYNC;\n\n        rc = write32bits(pPager->jfd, iOff, pPg->pgno);\n        if( rc!=SQLITE_OK ) return rc;\n        rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);\n        if( rc!=SQLITE_OK ) return rc;\n        rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);\n        if( rc!=SQLITE_OK ) return rc;\n\n        IOTRACE((\"JOUT %p %d %lld %d\\n\", pPager, pPg->pgno, \n                 pPager->journalOff, pPager->pageSize));\n        PAGER_INCR(sqlite3_pager_writej_count);\n        PAGERTRACE((\"JOURNAL %d page %d needSync=%d hash(%08x)\\n\",\n             PAGERID(pPager), pPg->pgno, \n             ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));\n\n        pPager->journalOff += 8 + pPager->pageSize;\n        pPager->nRec++;\n        assert( pPager->pInJournal!=0 );\n        rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);\n        testcase( rc==SQLITE_NOMEM );\n        assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n        rc |= addToSavepointBitvecs(pPager, pPg->pgno);\n        if( rc!=SQLITE_OK ){\n          assert( rc==SQLITE_NOMEM );\n          return rc;\n        }\n      }else{\n        if( pPager->eState!=PAGER_WRITER_DBMOD ){\n          pPg->flags |= PGHDR_NEED_SYNC;\n        }\n        PAGERTRACE((\"APPEND %d page %d needSync=%d\\n\",\n                PAGERID(pPager), pPg->pgno,\n               ((pPg->flags&PGHDR_NEED_SYNC)?1:0)));\n      }\n    }\n  \n    /* If the statement journal is open and the page is not in it,\n    ** then write the current page to the statement journal.  Note that\n    ** the statement journal format differs from the standard journal format\n    ** in that it omits the checksums and the header.\n    */\n    if( subjRequiresPage(pPg) ){\n      rc = subjournalPage(pPg);\n    }\n  }\n\n  /* Update the database size and return.\n  */\n  if( pPager->dbSize<pPg->pgno ){\n    pPager->dbSize = pPg->pgno;\n  }\n  return rc;\n}\n\n/*\n** Mark a data page as writeable. This routine must be called before \n** making changes to a page. The caller must check the return value \n** of this function and be careful not to change any page data unless \n** this routine returns SQLITE_OK.\n**\n** The difference between this function and pager_write() is that this\n** function also deals with the special case where 2 or more pages\n** fit on a single disk sector. In this case all co-resident pages\n** must have been written to the journal file before returning.\n**\n** If an error occurs, SQLITE_NOMEM or an IO error code is returned\n** as appropriate. Otherwise, SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerWrite(DbPage *pDbPage){\n  int rc = SQLITE_OK;\n\n  PgHdr *pPg = pDbPage;\n  Pager *pPager = pPg->pPager;\n  Pgno nPagePerSector = (pPager->sectorSize/pPager->pageSize);\n\n  assert( (pPg->flags & PGHDR_MMAP)==0 );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( assert_pager_state(pPager) );\n\n  if( nPagePerSector>1 ){\n    Pgno nPageCount;          /* Total number of pages in database file */\n    Pgno pg1;                 /* First page of the sector pPg is located on. */\n    int nPage = 0;            /* Number of pages starting at pg1 to journal */\n    int ii;                   /* Loop counter */\n    int needSync = 0;         /* True if any page has PGHDR_NEED_SYNC */\n\n    /* Set the doNotSyncSpill flag to 1. This is because we cannot allow\n    ** a journal header to be written between the pages journaled by\n    ** this function.\n    */\n    assert( !MEMDB );\n    assert( pPager->doNotSyncSpill==0 );\n    pPager->doNotSyncSpill++;\n\n    /* This trick assumes that both the page-size and sector-size are\n    ** an integer power of 2. It sets variable pg1 to the identifier\n    ** of the first page of the sector pPg is located on.\n    */\n    pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;\n\n    nPageCount = pPager->dbSize;\n    if( pPg->pgno>nPageCount ){\n      nPage = (pPg->pgno - pg1)+1;\n    }else if( (pg1+nPagePerSector-1)>nPageCount ){\n      nPage = nPageCount+1-pg1;\n    }else{\n      nPage = nPagePerSector;\n    }\n    assert(nPage>0);\n    assert(pg1<=pPg->pgno);\n    assert((pg1+nPage)>pPg->pgno);\n\n    for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){\n      Pgno pg = pg1+ii;\n      PgHdr *pPage;\n      if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){\n        if( pg!=PAGER_MJ_PGNO(pPager) ){\n          rc = sqlite3PagerGet(pPager, pg, &pPage);\n          if( rc==SQLITE_OK ){\n            rc = pager_write(pPage);\n            if( pPage->flags&PGHDR_NEED_SYNC ){\n              needSync = 1;\n            }\n            sqlite3PagerUnref(pPage);\n          }\n        }\n      }else if( (pPage = pager_lookup(pPager, pg))!=0 ){\n        if( pPage->flags&PGHDR_NEED_SYNC ){\n          needSync = 1;\n        }\n        sqlite3PagerUnref(pPage);\n      }\n    }\n\n    /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages \n    ** starting at pg1, then it needs to be set for all of them. Because\n    ** writing to any of these nPage pages may damage the others, the\n    ** journal file must contain sync()ed copies of all of them\n    ** before any of them can be written out to the database file.\n    */\n    if( rc==SQLITE_OK && needSync ){\n      assert( !MEMDB );\n      for(ii=0; ii<nPage; ii++){\n        PgHdr *pPage = pager_lookup(pPager, pg1+ii);\n        if( pPage ){\n          pPage->flags |= PGHDR_NEED_SYNC;\n          sqlite3PagerUnref(pPage);\n        }\n      }\n    }\n\n    assert( pPager->doNotSyncSpill==1 );\n    pPager->doNotSyncSpill--;\n  }else{\n    rc = pager_write(pDbPage);\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if the page given in the argument was previously passed\n** to sqlite3PagerWrite().  In other words, return TRUE if it is ok\n** to change the content of the page.\n*/\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage *pPg){\n  return pPg->flags&PGHDR_DIRTY;\n}\n#endif\n\n/*\n** A call to this routine tells the pager that it is not necessary to\n** write the information on page pPg back to the disk, even though\n** that page might be marked as dirty.  This happens, for example, when\n** the page has been added as a leaf of the freelist and so its\n** content no longer matters.\n**\n** The overlying software layer calls this routine when all of the data\n** on the given page is unused. The pager marks the page as clean so\n** that it does not get written to disk.\n**\n** Tests show that this optimization can quadruple the speed of large \n** DELETE operations.\n*/\nSQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  if( (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){\n    PAGERTRACE((\"DONT_WRITE page %d of %d\\n\", pPg->pgno, PAGERID(pPager)));\n    IOTRACE((\"CLEAN %p %d\\n\", pPager, pPg->pgno))\n    pPg->flags |= PGHDR_DONT_WRITE;\n    pager_set_pagehash(pPg);\n  }\n}\n\n/*\n** This routine is called to increment the value of the database file \n** change-counter, stored as a 4-byte big-endian integer starting at \n** byte offset 24 of the pager file.  The secondary change counter at\n** 92 is also updated, as is the SQLite version number at offset 96.\n**\n** But this only happens if the pPager->changeCountDone flag is false.\n** To avoid excess churning of page 1, the update only happens once.\n** See also the pager_write_changecounter() routine that does an \n** unconditional update of the change counters.\n**\n** If the isDirectMode flag is zero, then this is done by calling \n** sqlite3PagerWrite() on page 1, then modifying the contents of the\n** page data. In this case the file will be updated when the current\n** transaction is committed.\n**\n** The isDirectMode flag may only be non-zero if the library was compiled\n** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,\n** if isDirect is non-zero, then the database file is updated directly\n** by writing an updated version of page 1 using a call to the \n** sqlite3OsWrite() function.\n*/\nstatic int pager_incr_changecounter(Pager *pPager, int isDirectMode){\n  int rc = SQLITE_OK;\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* Declare and initialize constant integer 'isDirect'. If the\n  ** atomic-write optimization is enabled in this build, then isDirect\n  ** is initialized to the value passed as the isDirectMode parameter\n  ** to this function. Otherwise, it is always set to zero.\n  **\n  ** The idea is that if the atomic-write optimization is not\n  ** enabled at compile time, the compiler can omit the tests of\n  ** 'isDirect' below, as well as the block enclosed in the\n  ** \"if( isDirect )\" condition.\n  */\n#ifndef SQLITE_ENABLE_ATOMIC_WRITE\n# define DIRECT_MODE 0\n  assert( isDirectMode==0 );\n  UNUSED_PARAMETER(isDirectMode);\n#else\n# define DIRECT_MODE isDirectMode\n#endif\n\n  if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){\n    PgHdr *pPgHdr;                /* Reference to page 1 */\n\n    assert( !pPager->tempFile && isOpen(pPager->fd) );\n\n    /* Open page 1 of the file for writing. */\n    rc = sqlite3PagerGet(pPager, 1, &pPgHdr);\n    assert( pPgHdr==0 || rc==SQLITE_OK );\n\n    /* If page one was fetched successfully, and this function is not\n    ** operating in direct-mode, make page 1 writable.  When not in \n    ** direct mode, page 1 is always held in cache and hence the PagerGet()\n    ** above is always successful - hence the ALWAYS on rc==SQLITE_OK.\n    */\n    if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){\n      rc = sqlite3PagerWrite(pPgHdr);\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Actually do the update of the change counter */\n      pager_write_changecounter(pPgHdr);\n\n      /* If running in direct mode, write the contents of page 1 to the file. */\n      if( DIRECT_MODE ){\n        const void *zBuf;\n        assert( pPager->dbFileSize>0 );\n        CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);\n          pPager->aStat[PAGER_STAT_WRITE]++;\n        }\n        if( rc==SQLITE_OK ){\n          /* Update the pager's copy of the change-counter. Otherwise, the\n          ** next time a read transaction is opened the cache will be\n          ** flushed (as the change-counter values will not match).  */\n          const void *pCopy = (const void *)&((const char *)zBuf)[24];\n          memcpy(&pPager->dbFileVers, pCopy, sizeof(pPager->dbFileVers));\n          pPager->changeCountDone = 1;\n        }\n      }else{\n        pPager->changeCountDone = 1;\n      }\n    }\n\n    /* Release the page reference. */\n    sqlite3PagerUnref(pPgHdr);\n  }\n  return rc;\n}\n\n/*\n** Sync the database file to disk. This is a no-op for in-memory databases\n** or pages with the Pager.noSync flag set.\n**\n** If successful, or if called on a pager for which it is a no-op, this\n** function returns SQLITE_OK. Otherwise, an IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !pPager->noSync ){\n    assert( !MEMDB );\n    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);\n  }else if( isOpen(pPager->fd) ){\n    assert( !MEMDB );\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC_OMITTED, 0);\n    if( rc==SQLITE_NOTFOUND ){\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function may only be called while a write-transaction is active in\n** rollback. If the connection is in WAL mode, this call is a no-op. \n** Otherwise, if the connection does not already have an EXCLUSIVE lock on \n** the database file, an attempt is made to obtain one.\n**\n** If the EXCLUSIVE lock is already held or the attempt to obtain it is\n** successful, or the connection is in WAL mode, SQLITE_OK is returned.\n** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is \n** returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){\n  int rc = SQLITE_OK;\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD \n       || pPager->eState==PAGER_WRITER_DBMOD \n       || pPager->eState==PAGER_WRITER_LOCKED \n  );\n  assert( assert_pager_state(pPager) );\n  if( 0==pagerUseWal(pPager) ){\n    rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n  }\n  return rc;\n}\n\n/*\n** Sync the database file for the pager pPager. zMaster points to the name\n** of a master journal file that should be written into the individual\n** journal file. zMaster may be NULL, which is interpreted as no master\n** journal (a single database transaction).\n**\n** This routine ensures that:\n**\n**   * The database file change-counter is updated,\n**   * the journal is synced (unless the atomic-write optimization is used),\n**   * all dirty pages are written to the database file, \n**   * the database file is truncated (if required), and\n**   * the database file synced. \n**\n** The only thing that remains to commit the transaction is to finalize \n** (delete, truncate or zero the first part of) the journal file (or \n** delete the master journal file if specified).\n**\n** Note that if zMaster==NULL, this does not overwrite a previous value\n** passed to an sqlite3PagerCommitPhaseOne() call.\n**\n** If the final parameter - noSync - is true, then the database file itself\n** is not synced. The caller must call sqlite3PagerSync() directly to\n** sync the database file before calling CommitPhaseTwo() to delete the\n** journal file in this case.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(\n  Pager *pPager,                  /* Pager object */\n  const char *zMaster,            /* If not NULL, the master journal name */\n  int noSync                      /* True to omit the xSync on the db file */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n       || pPager->eState==PAGER_ERROR\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* If a prior error occurred, report that error again. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  PAGERTRACE((\"DATABASE SYNC: File=%s zMaster=%s nSize=%d\\n\", \n      pPager->zFilename, zMaster, pPager->dbSize));\n\n  /* If no database changes have been made, return early. */\n  if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;\n\n  if( MEMDB ){\n    /* If this is an in-memory db, or no pages have been written to, or this\n    ** function has already been called, it is mostly a no-op.  However, any\n    ** backup in progress needs to be restarted.\n    */\n    sqlite3BackupRestart(pPager->pBackup);\n  }else{\n    if( pagerUseWal(pPager) ){\n      PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n      PgHdr *pPageOne = 0;\n      if( pList==0 ){\n        /* Must have at least one page for the WAL commit flag.\n        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */\n        rc = sqlite3PagerGet(pPager, 1, &pPageOne);\n        pList = pPageOne;\n        pList->pDirty = 0;\n      }\n      assert( rc==SQLITE_OK );\n      if( ALWAYS(pList) ){\n        rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);\n      }\n      sqlite3PagerUnref(pPageOne);\n      if( rc==SQLITE_OK ){\n        sqlite3PcacheCleanAll(pPager->pPCache);\n      }\n    }else{\n      /* The following block updates the change-counter. Exactly how it\n      ** does this depends on whether or not the atomic-update optimization\n      ** was enabled at compile time, and if this transaction meets the \n      ** runtime criteria to use the operation: \n      **\n      **    * The file-system supports the atomic-write property for\n      **      blocks of size page-size, and \n      **    * This commit is not part of a multi-file transaction, and\n      **    * Exactly one page has been modified and store in the journal file.\n      **\n      ** If the optimization was not enabled at compile time, then the\n      ** pager_incr_changecounter() function is called to update the change\n      ** counter in 'indirect-mode'. If the optimization is compiled in but\n      ** is not applicable to this transaction, call sqlite3JournalCreate()\n      ** to make sure the journal file has actually been created, then call\n      ** pager_incr_changecounter() to update the change-counter in indirect\n      ** mode. \n      **\n      ** Otherwise, if the optimization is both enabled and applicable,\n      ** then call pager_incr_changecounter() to update the change-counter\n      ** in 'direct' mode. In this case the journal file will never be\n      ** created for this transaction.\n      */\n  #ifdef SQLITE_ENABLE_ATOMIC_WRITE\n      PgHdr *pPg;\n      assert( isOpen(pPager->jfd) \n           || pPager->journalMode==PAGER_JOURNALMODE_OFF \n           || pPager->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      if( !zMaster && isOpen(pPager->jfd) \n       && pPager->journalOff==jrnlBufferSize(pPager) \n       && pPager->dbSize>=pPager->dbOrigSize\n       && (0==(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)\n      ){\n        /* Update the db file change counter via the direct-write method. The \n        ** following call will modify the in-memory representation of page 1 \n        ** to include the updated change counter and then write page 1 \n        ** directly to the database file. Because of the atomic-write \n        ** property of the host file-system, this is safe.\n        */\n        rc = pager_incr_changecounter(pPager, 1);\n      }else{\n        rc = sqlite3JournalCreate(pPager->jfd);\n        if( rc==SQLITE_OK ){\n          rc = pager_incr_changecounter(pPager, 0);\n        }\n      }\n  #else\n      rc = pager_incr_changecounter(pPager, 0);\n  #endif\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Write the master journal name into the journal file. If a master \n      ** journal file name has already been written to the journal file, \n      ** or if zMaster is NULL (no master journal), then this call is a no-op.\n      */\n      rc = writeMasterJournal(pPager, zMaster);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Sync the journal file and write all dirty pages to the database.\n      ** If the atomic-update optimization is being used, this sync will not \n      ** create the journal file or perform any real IO.\n      **\n      ** Because the change-counter page was just modified, unless the\n      ** atomic-update optimization is used it is almost certain that the\n      ** journal requires a sync here. However, in locking_mode=exclusive\n      ** on a system under memory pressure it is just possible that this is \n      ** not the case. In this case it is likely enough that the redundant\n      ** xSync() call will be changed to a no-op by the OS anyhow. \n      */\n      rc = syncJournal(pPager, 0);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));\n      if( rc!=SQLITE_OK ){\n        assert( rc!=SQLITE_IOERR_BLOCKED );\n        goto commit_phase_one_exit;\n      }\n      sqlite3PcacheCleanAll(pPager->pPCache);\n\n      /* If the file on disk is smaller than the database image, use \n      ** pager_truncate to grow the file here. This can happen if the database\n      ** image was extended as part of the current transaction and then the\n      ** last page in the db image moved to the free-list. In this case the\n      ** last page is never written out to disk, leaving the database file\n      ** undersized. Fix this now if it is the case.  */\n      if( pPager->dbSize>pPager->dbFileSize ){\n        Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));\n        assert( pPager->eState==PAGER_WRITER_DBMOD );\n        rc = pager_truncate(pPager, nNew);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n  \n      /* Finally, sync the database file. */\n      if( !noSync ){\n        rc = sqlite3PagerSync(pPager);\n      }\n      IOTRACE((\"DBSYNC %p\\n\", pPager))\n    }\n  }\n\ncommit_phase_one_exit:\n  if( rc==SQLITE_OK && !pagerUseWal(pPager) ){\n    pPager->eState = PAGER_WRITER_FINISHED;\n  }\n  return rc;\n}\n\n\n/*\n** When this function is called, the database file has been completely\n** updated to reflect the changes made by the current transaction and\n** synced to disk. The journal file still exists in the file-system \n** though, and if a failure occurs at this point it will eventually\n** be used as a hot-journal and the current transaction rolled back.\n**\n** This function finalizes the journal file, either by deleting, \n** truncating or partially zeroing it, so that it cannot be used \n** for hot-journal rollback. Once this is done the transaction is\n** irrevocably committed.\n**\n** If an error occurs, an IO error code is returned and the pager\n** moves into the error state. Otherwise, SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This routine should not be called if a prior error has occurred.\n  ** But if (due to a coding error elsewhere in the system) it does get\n  ** called, just return the same error code without doing anything. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_FINISHED\n       || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* An optimization. If the database was not actually modified during\n  ** this transaction, the pager is running in exclusive-mode and is\n  ** using persistent journals, then this function is a no-op.\n  **\n  ** The start of the journal file currently contains a single journal \n  ** header with the nRec field set to 0. If such a journal is used as\n  ** a hot-journal during hot-journal rollback, 0 changes will be made\n  ** to the database file. So there is no need to zero the journal \n  ** header. Since the pager is in exclusive mode, there is no need\n  ** to drop any locks either.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED \n   && pPager->exclusiveMode \n   && pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n  ){\n    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );\n    pPager->eState = PAGER_READER;\n    return SQLITE_OK;\n  }\n\n  PAGERTRACE((\"COMMIT %d\\n\", PAGERID(pPager)));\n  rc = pager_end_transaction(pPager, pPager->setMaster, 1);\n  return pager_error(pPager, rc);\n}\n\n/*\n** If a write transaction is open, then all changes made within the \n** transaction are reverted and the current write-transaction is closed.\n** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR\n** state if an error occurs.\n**\n** If the pager is already in PAGER_ERROR state when this function is called,\n** it returns Pager.errCode immediately. No work is performed in this case.\n**\n** Otherwise, in rollback mode, this function performs two functions:\n**\n**   1) It rolls back the journal file, restoring all database file and \n**      in-memory cache pages to the state they were in when the transaction\n**      was opened, and\n**\n**   2) It finalizes the journal file, so that it is not used for hot\n**      rollback at any point in the future.\n**\n** Finalization of the journal file (task 2) is only performed if the \n** rollback is successful.\n**\n** In WAL mode, all cache-entries containing data modified within the\n** current transaction are either expelled from the cache or reverted to\n** their pre-transaction state by re-reading data from the database or\n** WAL files. The WAL transaction is then closed.\n*/\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n  PAGERTRACE((\"ROLLBACK %d\\n\", PAGERID(pPager)));\n\n  /* PagerRollback() is a no-op if called in READER or OPEN state. If\n  ** the pager is already in the ERROR state, the rollback is not \n  ** attempted here. Instead, the error code is returned to the caller.\n  */\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;\n  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;\n\n  if( pagerUseWal(pPager) ){\n    int rc2;\n    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);\n    rc2 = pager_end_transaction(pPager, pPager->setMaster, 0);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){\n    int eState = pPager->eState;\n    rc = pager_end_transaction(pPager, 0, 0);\n    if( !MEMDB && eState>PAGER_WRITER_LOCKED ){\n      /* This can happen using journal_mode=off. Move the pager to the error \n      ** state to indicate that the contents of the cache may not be trusted.\n      ** Any active readers will get SQLITE_ABORT.\n      */\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      return rc;\n    }\n  }else{\n    rc = pager_playback(pPager, 0);\n  }\n\n  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );\n  assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT\n          || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR );\n\n  /* If an error occurs during a ROLLBACK, we can no longer trust the pager\n  ** cache. So call pager_error() on the way out to make any error persistent.\n  */\n  return pager_error(pPager, rc);\n}\n\n/*\n** Return TRUE if the database file is opened read-only.  Return FALSE\n** if the database is (in theory) writable.\n*/\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager *pPager){\n  return pPager->readOnly;\n}\n\n/*\n** Return the number of references to the pager.\n*/\nSQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){\n  return sqlite3PcacheRefCount(pPager->pPCache);\n}\n\n/*\n** Return the approximate number of bytes of memory currently\n** used by the pager and its associated cache.\n*/\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){\n  int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)\n                                     + 5*sizeof(void*);\n  return perPageSize*sqlite3PcachePagecount(pPager->pPCache)\n           + sqlite3MallocSize(pPager)\n           + pPager->pageSize;\n}\n\n/*\n** Return the number of references to the specified page.\n*/\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage *pPage){\n  return sqlite3PcachePageRefcount(pPage);\n}\n\n#ifdef SQLITE_TEST\n/*\n** This routine is used for testing and analysis only.\n*/\nSQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){\n  static int a[11];\n  a[0] = sqlite3PcacheRefCount(pPager->pPCache);\n  a[1] = sqlite3PcachePagecount(pPager->pPCache);\n  a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);\n  a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;\n  a[4] = pPager->eState;\n  a[5] = pPager->errCode;\n  a[6] = pPager->aStat[PAGER_STAT_HIT];\n  a[7] = pPager->aStat[PAGER_STAT_MISS];\n  a[8] = 0;  /* Used to be pPager->nOvfl */\n  a[9] = pPager->nRead;\n  a[10] = pPager->aStat[PAGER_STAT_WRITE];\n  return a;\n}\n#endif\n\n/*\n** Parameter eStat must be either SQLITE_DBSTATUS_CACHE_HIT or\n** SQLITE_DBSTATUS_CACHE_MISS. Before returning, *pnVal is incremented by the\n** current cache hit or miss count, according to the value of eStat. If the \n** reset parameter is non-zero, the cache hit or miss count is zeroed before \n** returning.\n*/\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){\n\n  assert( eStat==SQLITE_DBSTATUS_CACHE_HIT\n       || eStat==SQLITE_DBSTATUS_CACHE_MISS\n       || eStat==SQLITE_DBSTATUS_CACHE_WRITE\n  );\n\n  assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );\n  assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );\n  assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );\n\n  *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];\n  if( reset ){\n    pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;\n  }\n}\n\n/*\n** Return true if this is an in-memory pager.\n*/\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){\n  return MEMDB;\n}\n\n/*\n** Check that there are at least nSavepoint savepoints open. If there are\n** currently less than nSavepoints open, then open one or more savepoints\n** to make up the difference. If the number of savepoints is already\n** equal to nSavepoint, then this function is a no-op.\n**\n** If a memory allocation fails, SQLITE_NOMEM is returned. If an error \n** occurs while opening the sub-journal file, then an IO error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  int rc = SQLITE_OK;                       /* Return code */\n  int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */\n\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n\n  if( nSavepoint>nCurrent && pPager->useJournal ){\n    int ii;                                 /* Iterator variable */\n    PagerSavepoint *aNew;                   /* New Pager.aSavepoint array */\n\n    /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM\n    ** if the allocation fails. Otherwise, zero the new portion in case a \n    ** malloc failure occurs while populating it in the for(...) loop below.\n    */\n    aNew = (PagerSavepoint *)sqlite3Realloc(\n        pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint\n    );\n    if( !aNew ){\n      return SQLITE_NOMEM;\n    }\n    memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));\n    pPager->aSavepoint = aNew;\n\n    /* Populate the PagerSavepoint structures just allocated. */\n    for(ii=nCurrent; ii<nSavepoint; ii++){\n      aNew[ii].nOrig = pPager->dbSize;\n      if( isOpen(pPager->jfd) && pPager->journalOff>0 ){\n        aNew[ii].iOffset = pPager->journalOff;\n      }else{\n        aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);\n      }\n      aNew[ii].iSubRec = pPager->nSubRec;\n      aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);\n      if( !aNew[ii].pInSavepoint ){\n        return SQLITE_NOMEM;\n      }\n      if( pagerUseWal(pPager) ){\n        sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);\n      }\n      pPager->nSavepoint = ii+1;\n    }\n    assert( pPager->nSavepoint==nSavepoint );\n    assertTruncateConstraint(pPager);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to rollback or release (commit) a savepoint.\n** The savepoint to release or rollback need not be the most recently \n** created savepoint.\n**\n** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.\n** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with\n** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes\n** that have occurred since the specified savepoint was created.\n**\n** The savepoint to rollback or release is identified by parameter \n** iSavepoint. A value of 0 means to operate on the outermost savepoint\n** (the first created). A value of (Pager.nSavepoint-1) means operate\n** on the most recently created savepoint. If iSavepoint is greater than\n** (Pager.nSavepoint-1), then this function is a no-op.\n**\n** If a negative value is passed to this function, then the current\n** transaction is rolled back. This is different to calling \n** sqlite3PagerRollback() because this function does not terminate\n** the transaction or unlock the database, it just restores the \n** contents of the database to its original state. \n**\n** In any case, all savepoints with an index greater than iSavepoint \n** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),\n** then savepoint iSavepoint is also destroyed.\n**\n** This function may return SQLITE_NOMEM if a memory allocation fails,\n** or an IO error code if an IO error occurs while rolling back a \n** savepoint. If no errors occur, SQLITE_OK is returned.\n*/ \nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){\n  int rc = pPager->errCode;       /* Return code */\n\n  assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n  assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );\n\n  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){\n    int ii;            /* Iterator variable */\n    int nNew;          /* Number of remaining savepoints after this op. */\n\n    /* Figure out how many savepoints will still be active after this\n    ** operation. Store this value in nNew. Then free resources associated \n    ** with any savepoints that are destroyed by this operation.\n    */\n    nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);\n    for(ii=nNew; ii<pPager->nSavepoint; ii++){\n      sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n    }\n    pPager->nSavepoint = nNew;\n\n    /* If this is a release of the outermost savepoint, truncate \n    ** the sub-journal to zero bytes in size. */\n    if( op==SAVEPOINT_RELEASE ){\n      if( nNew==0 && isOpen(pPager->sjfd) ){\n        /* Only truncate if it is an in-memory sub-journal. */\n        if( sqlite3IsMemJournal(pPager->sjfd) ){\n          rc = sqlite3OsTruncate(pPager->sjfd, 0);\n          assert( rc==SQLITE_OK );\n        }\n        pPager->nSubRec = 0;\n      }\n    }\n    /* Else this is a rollback operation, playback the specified savepoint.\n    ** If this is a temp-file, it is possible that the journal file has\n    ** not yet been opened. In this case there have been no changes to\n    ** the database file, so the playback operation can be skipped.\n    */\n    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){\n      PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];\n      rc = pagerPlaybackSavepoint(pPager, pSavepoint);\n      assert(rc!=SQLITE_DONE);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return the full pathname of the database file.\n**\n** Except, if the pager is in-memory only, then return an empty string if\n** nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when\n** used to report the filename to the user, for compatibility with legacy\n** behavior.  But when the Btree needs to know the filename for matching to\n** shared cache, it uses nullIfMemDb==0 so that in-memory databases can\n** participate in shared-cache.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){\n  return (nullIfMemDb && pPager->memDb) ? \"\" : pPager->zFilename;\n}\n\n/*\n** Return the VFS structure for the pager.\n*/\nSQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){\n  return pPager->pVfs;\n}\n\n/*\n** Return the file handle for the database file associated\n** with the pager.  This might return NULL if the file has\n** not yet been opened.\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){\n  return pPager->fd;\n}\n\n/*\n** Return the full pathname of the journal file.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager *pPager){\n  return pPager->zJournal;\n}\n\n/*\n** Return true if fsync() calls are disabled for this pager.  Return FALSE\n** if fsync()s are executed normally.\n*/\nSQLITE_PRIVATE int sqlite3PagerNosync(Pager *pPager){\n  return pPager->noSync;\n}\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Set or retrieve the codec for this pager\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCodec(\n  Pager *pPager,\n  void *(*xCodec)(void*,void*,Pgno,int),\n  void (*xCodecSizeChng)(void*,int,int),\n  void (*xCodecFree)(void*),\n  void *pCodec\n){\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n  pPager->xCodec = pPager->memDb ? 0 : xCodec;\n  pPager->xCodecSizeChng = xCodecSizeChng;\n  pPager->xCodecFree = xCodecFree;\n  pPager->pCodec = pCodec;\n  pagerReportSize(pPager);\n}\nSQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){\n  return pPager->pCodec;\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Move the page pPg to location pgno in the file.\n**\n** There must be no references to the page previously located at\n** pgno (which we call pPgOld) though that page is allowed to be\n** in cache.  If the page previously located at pgno is not already\n** in the rollback journal, it is not put there by by this routine.\n**\n** References to the page pPg remain valid. Updating any\n** meta-data associated with pPg (i.e. data stored in the nExtra bytes\n** allocated along with the page) is the responsibility of the caller.\n**\n** A transaction must be active when this routine is called. It used to be\n** required that a statement transaction was not active, but this restriction\n** has been removed (CREATE INDEX needs to move a page when a statement\n** transaction is active).\n**\n** If the fourth argument, isCommit, is non-zero, then this page is being\n** moved as part of a database reorganization just before the transaction \n** is being committed. In this case, it is guaranteed that the database page \n** pPg refers to will not be written to again within this transaction.\n**\n** This function may return SQLITE_NOMEM or an IO error code if an error\n** occurs. Otherwise, it returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){\n  PgHdr *pPgOld;               /* The page being overwritten. */\n  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */\n  int rc;                      /* Return code */\n  Pgno origPgno;               /* The original page number */\n\n  assert( pPg->nRef>0 );\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* In order to be able to rollback, an in-memory database must journal\n  ** the page we are moving from.\n  */\n  if( MEMDB ){\n    rc = sqlite3PagerWrite(pPg);\n    if( rc ) return rc;\n  }\n\n  /* If the page being moved is dirty and has not been saved by the latest\n  ** savepoint, then save the current contents of the page into the \n  ** sub-journal now. This is required to handle the following scenario:\n  **\n  **   BEGIN;\n  **     <journal page X, then modify it in memory>\n  **     SAVEPOINT one;\n  **       <Move page X to location Y>\n  **     ROLLBACK TO one;\n  **\n  ** If page X were not written to the sub-journal here, it would not\n  ** be possible to restore its contents when the \"ROLLBACK TO one\"\n  ** statement were is processed.\n  **\n  ** subjournalPage() may need to allocate space to store pPg->pgno into\n  ** one or more savepoint bitvecs. This is the reason this function\n  ** may return SQLITE_NOMEM.\n  */\n  if( pPg->flags&PGHDR_DIRTY\n   && subjRequiresPage(pPg)\n   && SQLITE_OK!=(rc = subjournalPage(pPg))\n  ){\n    return rc;\n  }\n\n  PAGERTRACE((\"MOVE %d page %d (needSync=%d) moves to %d\\n\", \n      PAGERID(pPager), pPg->pgno, (pPg->flags&PGHDR_NEED_SYNC)?1:0, pgno));\n  IOTRACE((\"MOVE %p %d %d\\n\", pPager, pPg->pgno, pgno))\n\n  /* If the journal needs to be sync()ed before page pPg->pgno can\n  ** be written to, store pPg->pgno in local variable needSyncPgno.\n  **\n  ** If the isCommit flag is set, there is no need to remember that\n  ** the journal needs to be sync()ed before database page pPg->pgno \n  ** can be written to. The caller has already promised not to write to it.\n  */\n  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit ){\n    needSyncPgno = pPg->pgno;\n    assert( pPager->journalMode==PAGER_JOURNALMODE_OFF ||\n            pageInJournal(pPg) || pPg->pgno>pPager->dbOrigSize );\n    assert( pPg->flags&PGHDR_DIRTY );\n  }\n\n  /* If the cache contains a page with page-number pgno, remove it\n  ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for \n  ** page pgno before the 'move' operation, it needs to be retained \n  ** for the page moved there.\n  */\n  pPg->flags &= ~PGHDR_NEED_SYNC;\n  pPgOld = pager_lookup(pPager, pgno);\n  assert( !pPgOld || pPgOld->nRef==1 );\n  if( pPgOld ){\n    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);\n    if( MEMDB ){\n      /* Do not discard pages from an in-memory database since we might\n      ** need to rollback later.  Just move the page out of the way. */\n      sqlite3PcacheMove(pPgOld, pPager->dbSize+1);\n    }else{\n      sqlite3PcacheDrop(pPgOld);\n    }\n  }\n\n  origPgno = pPg->pgno;\n  sqlite3PcacheMove(pPg, pgno);\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* For an in-memory database, make sure the original page continues\n  ** to exist, in case the transaction needs to roll back.  Use pPgOld\n  ** as the original page since it has already been allocated.\n  */\n  if( MEMDB ){\n    assert( pPgOld );\n    sqlite3PcacheMove(pPgOld, origPgno);\n    sqlite3PagerUnref(pPgOld);\n  }\n\n  if( needSyncPgno ){\n    /* If needSyncPgno is non-zero, then the journal file needs to be \n    ** sync()ed before any data is written to database file page needSyncPgno.\n    ** Currently, no such page exists in the page-cache and the \n    ** \"is journaled\" bitvec flag has been set. This needs to be remedied by\n    ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC\n    ** flag.\n    **\n    ** If the attempt to load the page into the page-cache fails, (due\n    ** to a malloc() or IO failure), clear the bit in the pInJournal[]\n    ** array. Otherwise, if the page is loaded and written again in\n    ** this transaction, it may be written to the database file before\n    ** it is synced into the journal file. This way, it may end up in\n    ** the journal file twice, but that is not a problem.\n    */\n    PgHdr *pPgHdr;\n    rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr);\n    if( rc!=SQLITE_OK ){\n      if( needSyncPgno<=pPager->dbOrigSize ){\n        assert( pPager->pTmpSpace!=0 );\n        sqlite3BitvecClear(pPager->pInJournal, needSyncPgno, pPager->pTmpSpace);\n      }\n      return rc;\n    }\n    pPgHdr->flags |= PGHDR_NEED_SYNC;\n    sqlite3PcacheMakeDirty(pPgHdr);\n    sqlite3PagerUnref(pPgHdr);\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Return a pointer to the data for the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *pPg){\n  assert( pPg->nRef>0 || pPg->pPager->memDb );\n  return pPg->pData;\n}\n\n/*\n** Return a pointer to the Pager.nExtra bytes of \"extra\" space \n** allocated along with the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *pPg){\n  return pPg->pExtra;\n}\n\n/*\n** Get/set the locking-mode for this pager. Parameter eMode must be one\n** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or \n** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then\n** the locking-mode is set to the value specified.\n**\n** The returned value is either PAGER_LOCKINGMODE_NORMAL or\n** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated)\n** locking-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){\n  assert( eMode==PAGER_LOCKINGMODE_QUERY\n            || eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_QUERY<0 );\n  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );\n  assert( pPager->exclusiveMode || 0==sqlite3WalHeapMemory(pPager->pWal) );\n  if( eMode>=0 && !pPager->tempFile && !sqlite3WalHeapMemory(pPager->pWal) ){\n    pPager->exclusiveMode = (u8)eMode;\n  }\n  return (int)pPager->exclusiveMode;\n}\n\n/*\n** Set the journal-mode for this pager. Parameter eMode must be one of:\n**\n**    PAGER_JOURNALMODE_DELETE\n**    PAGER_JOURNALMODE_TRUNCATE\n**    PAGER_JOURNALMODE_PERSIST\n**    PAGER_JOURNALMODE_OFF\n**    PAGER_JOURNALMODE_MEMORY\n**    PAGER_JOURNALMODE_WAL\n**\n** The journalmode is set to the value specified if the change is allowed.\n** The change may be disallowed for the following reasons:\n**\n**   *  An in-memory database can only have its journal_mode set to _OFF\n**      or _MEMORY.\n**\n**   *  Temporary databases cannot have _WAL journalmode.\n**\n** The returned indicate the current (possibly updated) journal-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){\n  u8 eOld = pPager->journalMode;    /* Prior journalmode */\n\n#ifdef SQLITE_DEBUG\n  /* The print_pager_state() routine is intended to be used by the debugger\n  ** only.  We invoke it once here to suppress a compiler warning. */\n  print_pager_state(pPager);\n#endif\n\n\n  /* The eMode parameter is always valid */\n  assert(      eMode==PAGER_JOURNALMODE_DELETE\n            || eMode==PAGER_JOURNALMODE_TRUNCATE\n            || eMode==PAGER_JOURNALMODE_PERSIST\n            || eMode==PAGER_JOURNALMODE_OFF \n            || eMode==PAGER_JOURNALMODE_WAL \n            || eMode==PAGER_JOURNALMODE_MEMORY );\n\n  /* This routine is only called from the OP_JournalMode opcode, and\n  ** the logic there will never allow a temporary file to be changed\n  ** to WAL mode.\n  */\n  assert( pPager->tempFile==0 || eMode!=PAGER_JOURNALMODE_WAL );\n\n  /* Do allow the journalmode of an in-memory database to be set to\n  ** anything other than MEMORY or OFF\n  */\n  if( MEMDB ){\n    assert( eOld==PAGER_JOURNALMODE_MEMORY || eOld==PAGER_JOURNALMODE_OFF );\n    if( eMode!=PAGER_JOURNALMODE_MEMORY && eMode!=PAGER_JOURNALMODE_OFF ){\n      eMode = eOld;\n    }\n  }\n\n  if( eMode!=eOld ){\n\n    /* Change the journal mode. */\n    assert( pPager->eState!=PAGER_ERROR );\n    pPager->journalMode = (u8)eMode;\n\n    /* When transistioning from TRUNCATE or PERSIST to any other journal\n    ** mode except WAL, unless the pager is in locking_mode=exclusive mode,\n    ** delete the journal file.\n    */\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );\n    assert( (PAGER_JOURNALMODE_DELETE & 5)==0 );\n    assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );\n    assert( (PAGER_JOURNALMODE_OFF & 5)==0 );\n    assert( (PAGER_JOURNALMODE_WAL & 5)==5 );\n\n    assert( isOpen(pPager->fd) || pPager->exclusiveMode );\n    if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){\n\n      /* In this case we would like to delete the journal file. If it is\n      ** not possible, then that is not a problem. Deleting the journal file\n      ** here is an optimization only.\n      **\n      ** Before deleting the journal file, obtain a RESERVED lock on the\n      ** database file. This ensures that the journal file is not deleted\n      ** while it is in use by some other client.\n      */\n      sqlite3OsClose(pPager->jfd);\n      if( pPager->eLock>=RESERVED_LOCK ){\n        sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n      }else{\n        int rc = SQLITE_OK;\n        int state = pPager->eState;\n        assert( state==PAGER_OPEN || state==PAGER_READER );\n        if( state==PAGER_OPEN ){\n          rc = sqlite3PagerSharedLock(pPager);\n        }\n        if( pPager->eState==PAGER_READER ){\n          assert( rc==SQLITE_OK );\n          rc = pagerLockDb(pPager, RESERVED_LOCK);\n        }\n        if( rc==SQLITE_OK ){\n          sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n        }\n        if( rc==SQLITE_OK && state==PAGER_READER ){\n          pagerUnlockDb(pPager, SHARED_LOCK);\n        }else if( state==PAGER_OPEN ){\n          pager_unlock(pPager);\n        }\n        assert( state==pPager->eState );\n      }\n    }\n  }\n\n  /* Return the new journal mode */\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return the current journal mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return TRUE if the pager is in a state where it is OK to change the\n** journalmode.  Journalmode changes can only happen when the database\n** is unmodified.\n*/\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;\n  if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;\n  return 1;\n}\n\n/*\n** Get/set the size-limit used for persistent journal files.\n**\n** Setting the size limit to -1 means no limit is enforced.\n** An attempt to set a limit smaller than -1 is a no-op.\n*/\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){\n  if( iLimit>=-1 ){\n    pPager->journalSizeLimit = iLimit;\n    sqlite3WalLimit(pPager->pWal, iLimit);\n  }\n  return pPager->journalSizeLimit;\n}\n\n/*\n** Return a pointer to the pPager->pBackup variable. The backup module\n** in backup.c maintains the content of this variable. This module\n** uses it opaquely as an argument to sqlite3BackupRestart() and\n** sqlite3BackupUpdate() only.\n*/\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){\n  return &pPager->pBackup;\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Unless this is an in-memory or temporary database, clear the pager cache.\n*/\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){\n  if( !MEMDB && pPager->tempFile==0 ) pager_reset(pPager);\n}\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is called when the user invokes \"PRAGMA wal_checkpoint\",\n** \"PRAGMA wal_blocking_checkpoint\" or calls the sqlite3_wal_checkpoint()\n** or wal_blocking_checkpoint() API functions.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    rc = sqlite3WalCheckpoint(pPager->pWal, eMode,\n        pPager->xBusyHandler, pPager->pBusyHandlerArg,\n        pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,\n        pnLog, pnCkpt\n    );\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){\n  return sqlite3WalCallback(pPager->pWal);\n}\n\n/*\n** Return true if the underlying VFS for the given pager supports the\n** primitives necessary for write-ahead logging.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){\n  const sqlite3_io_methods *pMethods = pPager->fd->pMethods;\n  return pPager->exclusiveMode || (pMethods->iVersion>=2 && pMethods->xShmMap);\n}\n\n/*\n** Attempt to take an exclusive lock on the database file. If a PENDING lock\n** is obtained instead, immediately release it.\n*/\nstatic int pagerExclusiveLock(Pager *pPager){\n  int rc;                         /* Return code */\n\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n  rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n  if( rc!=SQLITE_OK ){\n    /* If the attempt to grab the exclusive lock failed, release the \n    ** pending lock that may have been obtained instead.  */\n    pagerUnlockDb(pPager, SHARED_LOCK);\n  }\n\n  return rc;\n}\n\n/*\n** Call sqlite3WalOpen() to open the WAL handle. If the pager is in \n** exclusive-locking mode when this function is called, take an EXCLUSIVE\n** lock on the database file and use heap-memory to store the wal-index\n** in. Otherwise, use the normal shared-memory.\n*/\nstatic int pagerOpenWal(Pager *pPager){\n  int rc = SQLITE_OK;\n\n  assert( pPager->pWal==0 && pPager->tempFile==0 );\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n\n  /* If the pager is already in exclusive-mode, the WAL module will use \n  ** heap-memory for the wal-index instead of the VFS shared-memory \n  ** implementation. Take the exclusive lock now, before opening the WAL\n  ** file, to make sure this is safe.\n  */\n  if( pPager->exclusiveMode ){\n    rc = pagerExclusiveLock(pPager);\n  }\n\n  /* Open the connection to the log file. If this operation fails, \n  ** (e.g. due to malloc() failure), return an error code.\n  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3WalOpen(pPager->pVfs,\n        pPager->fd, pPager->zWal, pPager->exclusiveMode,\n        pPager->journalSizeLimit, &pPager->pWal\n    );\n  }\n  pagerFixMaplimit(pPager);\n\n  return rc;\n}\n\n\n/*\n** The caller must be holding a SHARED lock on the database file to call\n** this function.\n**\n** If the pager passed as the first argument is open on a real database\n** file (not a temp file or an in-memory database), and the WAL file\n** is not already open, make an attempt to open it now. If successful,\n** return SQLITE_OK. If an error occurs or the VFS used by the pager does \n** not support the xShmXXX() methods, return an error code. *pbOpen is\n** not modified in either case.\n**\n** If the pager is open on a temp-file (or in-memory database), or if\n** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK\n** without doing anything.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpenWal(\n  Pager *pPager,                  /* Pager object */\n  int *pbOpen                     /* OUT: Set to true if call is a no-op */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN   || pbOpen );\n  assert( pPager->eState==PAGER_READER || !pbOpen );\n  assert( pbOpen==0 || *pbOpen==0 );\n  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );\n\n  if( !pPager->tempFile && !pPager->pWal ){\n    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;\n\n    /* Close any rollback journal previously open */\n    sqlite3OsClose(pPager->jfd);\n\n    rc = pagerOpenWal(pPager);\n    if( rc==SQLITE_OK ){\n      pPager->journalMode = PAGER_JOURNALMODE_WAL;\n      pPager->eState = PAGER_OPEN;\n    }\n  }else{\n    *pbOpen = 1;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to close the connection to the log file prior\n** to switching from WAL to rollback mode.\n**\n** Before closing the log file, this function attempts to take an \n** EXCLUSIVE lock on the database file. If this cannot be obtained, an\n** error (SQLITE_BUSY) is returned and the log connection is not closed.\n** If successful, the EXCLUSIVE lock is not released before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager){\n  int rc = SQLITE_OK;\n\n  assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );\n\n  /* If the log file is not already open, but does exist in the file-system,\n  ** it may need to be checkpointed before the connection can switch to\n  ** rollback mode. Open it now so this can happen.\n  */\n  if( !pPager->pWal ){\n    int logexists = 0;\n    rc = pagerLockDb(pPager, SHARED_LOCK);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsAccess(\n          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists\n      );\n    }\n    if( rc==SQLITE_OK && logexists ){\n      rc = pagerOpenWal(pPager);\n    }\n  }\n    \n  /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on\n  ** the database file, the log and log-summary files will be deleted.\n  */\n  if( rc==SQLITE_OK && pPager->pWal ){\n    rc = pagerExclusiveLock(pPager);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags,\n                           pPager->pageSize, (u8*)pPager->pTmpSpace);\n      pPager->pWal = 0;\n      pagerFixMaplimit(pPager);\n    }\n  }\n  return rc;\n}\n\n#endif /* !SQLITE_OMIT_WAL */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** A read-lock must be held on the pager when this function is called. If\n** the pager is in WAL mode and the WAL file currently contains one or more\n** frames, return the size in bytes of the page images stored within the\n** WAL frames. Otherwise, if this is not a WAL database or the WAL file\n** is empty, return 0.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){\n  assert( pPager->eState==PAGER_READER );\n  return sqlite3WalFramesize(pPager->pWal);\n}\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** This function is called by the wal module when writing page content\n** into the log file.\n**\n** This function returns a pointer to a buffer containing the encrypted\n** page content. If a malloc fails, this function may return NULL.\n*/\nSQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){\n  void *aData = 0;\n  CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);\n  return aData;\n}\n#endif /* SQLITE_HAS_CODEC */\n\n#endif /* SQLITE_OMIT_DISKIO */\n\n/************** End of pager.c ***********************************************/\n/************** Begin file wal.c *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of a write-ahead log (WAL) used in \n** \"journal_mode=WAL\" mode.\n**\n** WRITE-AHEAD LOG (WAL) FILE FORMAT\n**\n** A WAL file consists of a header followed by zero or more \"frames\".\n** Each frame records the revised content of a single page from the\n** database file.  All changes to the database are recorded by writing\n** frames into the WAL.  Transactions commit when a frame is written that\n** contains a commit marker.  A single WAL can and usually does record \n** multiple transactions.  Periodically, the content of the WAL is\n** transferred back into the database file in an operation called a\n** \"checkpoint\".\n**\n** A single WAL file can be used multiple times.  In other words, the\n** WAL can fill up with frames and then be checkpointed and then new\n** frames can overwrite the old ones.  A WAL always grows from beginning\n** toward the end.  Checksums and counters attached to each frame are\n** used to determine which frames within the WAL are valid and which\n** are leftovers from prior checkpoints.\n**\n** The WAL header is 32 bytes in size and consists of the following eight\n** big-endian 32-bit unsigned integer values:\n**\n**     0: Magic number.  0x377f0682 or 0x377f0683\n**     4: File format version.  Currently 3007000\n**     8: Database page size.  Example: 1024\n**    12: Checkpoint sequence number\n**    16: Salt-1, random integer incremented with each checkpoint\n**    20: Salt-2, a different random integer changing with each ckpt\n**    24: Checksum-1 (first part of checksum for first 24 bytes of header).\n**    28: Checksum-2 (second part of checksum for first 24 bytes of header).\n**\n** Immediately following the wal-header are zero or more frames. Each\n** frame consists of a 24-byte frame-header followed by a <page-size> bytes\n** of page data. The frame-header is six big-endian 32-bit unsigned \n** integer values, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the header)\n**    12: Salt-2 (copied from the header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n**\n** A frame is considered valid if and only if the following conditions are\n** true:\n**\n**    (1) The salt-1 and salt-2 values in the frame-header match\n**        salt values in the wal-header\n**\n**    (2) The checksum values in the final 8 bytes of the frame-header\n**        exactly match the checksum computed consecutively on the\n**        WAL header and the first 8 bytes and the content of all frames\n**        up to and including the current frame.\n**\n** The checksum is computed using 32-bit big-endian integers if the\n** magic number in the first 4 bytes of the WAL is 0x377f0683 and it\n** is computed using little-endian if the magic number is 0x377f0682.\n** The checksum values are always stored in the frame header in a\n** big-endian format regardless of which byte order is used to compute\n** the checksum.  The checksum is computed by interpreting the input as\n** an even number of unsigned 32-bit integers: x[0] through x[N].  The\n** algorithm used for the checksum is as follows:\n** \n**   for i from 0 to n-1 step 2:\n**     s0 += x[i] + s1;\n**     s1 += x[i+1] + s0;\n**   endfor\n**\n** Note that s0 and s1 are both weighted checksums using fibonacci weights\n** in reverse order (the largest fibonacci weight occurs on the first element\n** of the sequence being summed.)  The s1 value spans all 32-bit \n** terms of the sequence whereas s0 omits the final term.\n**\n** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the\n** WAL is transferred into the database, then the database is VFS.xSync-ed.\n** The VFS.xSync operations serve as write barriers - all writes launched\n** before the xSync must complete before any write that launches after the\n** xSync begins.\n**\n** After each checkpoint, the salt-1 value is incremented and the salt-2\n** value is randomized.  This prevents old and new frames in the WAL from\n** being considered valid at the same time and being checkpointing together\n** following a crash.\n**\n** READER ALGORITHM\n**\n** To read a page from the database (call it page number P), a reader\n** first checks the WAL to see if it contains page P.  If so, then the\n** last valid instance of page P that is a followed by a commit frame\n** or is a commit frame itself becomes the value read.  If the WAL\n** contains no copies of page P that are valid and which are a commit\n** frame or are followed by a commit frame, then page P is read from\n** the database file.\n**\n** To start a read transaction, the reader records the index of the last\n** valid frame in the WAL.  The reader uses this recorded \"mxFrame\" value\n** for all subsequent read operations.  New transactions can be appended\n** to the WAL, but as long as the reader uses its original mxFrame value\n** and ignores the newly appended content, it will see a consistent snapshot\n** of the database from a single point in time.  This technique allows\n** multiple concurrent readers to view different versions of the database\n** content simultaneously.\n**\n** The reader algorithm in the previous paragraphs works correctly, but \n** because frames for page P can appear anywhere within the WAL, the\n** reader has to scan the entire WAL looking for page P frames.  If the\n** WAL is large (multiple megabytes is typical) that scan can be slow,\n** and read performance suffers.  To overcome this problem, a separate\n** data structure called the wal-index is maintained to expedite the\n** search for frames of a particular page.\n** \n** WAL-INDEX FORMAT\n**\n** Conceptually, the wal-index is shared memory, though VFS implementations\n** might choose to implement the wal-index using a mmapped file.  Because\n** the wal-index is shared memory, SQLite does not support journal_mode=WAL \n** on a network filesystem.  All users of the database must be able to\n** share memory.\n**\n** The wal-index is transient.  After a crash, the wal-index can (and should\n** be) reconstructed from the original WAL file.  In fact, the VFS is required\n** to either truncate or zero the header of the wal-index when the last\n** connection to it closes.  Because the wal-index is transient, it can\n** use an architecture-specific format; it does not have to be cross-platform.\n** Hence, unlike the database and WAL file formats which store all values\n** as big endian, the wal-index can store multi-byte values in the native\n** byte order of the host computer.\n**\n** The purpose of the wal-index is to answer this question quickly:  Given\n** a page number P and a maximum frame index M, return the index of the \n** last frame in the wal before frame M for page P in the WAL, or return\n** NULL if there are no frames for page P in the WAL prior to M.\n**\n** The wal-index consists of a header region, followed by an one or\n** more index blocks.  \n**\n** The wal-index header contains the total number of frames within the WAL\n** in the mxFrame field.\n**\n** Each index block except for the first contains information on \n** HASHTABLE_NPAGE frames. The first index block contains information on\n** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and \n** HASHTABLE_NPAGE are selected so that together the wal-index header and\n** first index block are the same size as all other index blocks in the\n** wal-index.\n**\n** Each index block contains two sections, a page-mapping that contains the\n** database page number associated with each wal frame, and a hash-table \n** that allows readers to query an index block for a specific page number.\n** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE\n** for the first index block) 32-bit page numbers. The first entry in the \n** first index-block contains the database page number corresponding to the\n** first frame in the WAL file. The first entry in the second index block\n** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in\n** the log, and so on.\n**\n** The last index block in a wal-index usually contains less than the full\n** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,\n** depending on the contents of the WAL file. This does not change the\n** allocated size of the page-mapping array - the page-mapping array merely\n** contains unused entries.\n**\n** Even without using the hash table, the last frame for page P\n** can be found by scanning the page-mapping sections of each index block\n** starting with the last index block and moving toward the first, and\n** within each index block, starting at the end and moving toward the\n** beginning.  The first entry that equals P corresponds to the frame\n** holding the content for that page.\n**\n** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.\n** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the\n** hash table for each page number in the mapping section, so the hash \n** table is never more than half full.  The expected number of collisions \n** prior to finding a match is 1.  Each entry of the hash table is an\n** 1-based index of an entry in the mapping section of the same\n** index block.   Let K be the 1-based index of the largest entry in\n** the mapping section.  (For index blocks other than the last, K will\n** always be exactly HASHTABLE_NPAGE (4096) and for the last index block\n** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table\n** contain a value of 0.\n**\n** To look for page P in the hash table, first compute a hash iKey on\n** P as follows:\n**\n**      iKey = (P * 383) % HASHTABLE_NSLOT\n**\n** Then start scanning entries of the hash table, starting with iKey\n** (wrapping around to the beginning when the end of the hash table is\n** reached) until an unused hash slot is found. Let the first unused slot\n** be at index iUnused.  (iUnused might be less than iKey if there was\n** wrap-around.) Because the hash table is never more than half full,\n** the search is guaranteed to eventually hit an unused entry.  Let \n** iMax be the value between iKey and iUnused, closest to iUnused,\n** where aHash[iMax]==P.  If there is no iMax entry (if there exists\n** no hash slot such that aHash[i]==p) then page P is not in the\n** current index block.  Otherwise the iMax-th mapping entry of the\n** current index block corresponds to the last entry that references \n** page P.\n**\n** A hash search begins with the last index block and moves toward the\n** first index block, looking for entries corresponding to page P.  On\n** average, only two or three slots in each index block need to be\n** examined in order to either find the last entry for page P, or to\n** establish that no such entry exists in the block.  Each index block\n** holds over 4000 entries.  So two or three index blocks are sufficient\n** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10\n** comparisons (on average) suffice to either locate a frame in the\n** WAL or to establish that the frame does not exist in the WAL.  This\n** is much faster than scanning the entire 10MB WAL.\n**\n** Note that entries are added in order of increasing K.  Hence, one\n** reader might be using some value K0 and a second reader that started\n** at a later time (after additional transactions were added to the WAL\n** and to the wal-index) might be using a different value K1, where K1>K0.\n** Both readers can use the same hash table and mapping section to get\n** the correct result.  There may be entries in the hash table with\n** K>K0 but to the first reader, those entries will appear to be unused\n** slots in the hash table and so the first reader will get an answer as\n** if no values greater than K0 had ever been inserted into the hash table\n** in the first place - which is what reader one wants.  Meanwhile, the\n** second reader using K1 will see additional values that were inserted\n** later, which is exactly what reader two wants.  \n**\n** When a rollback occurs, the value of K is decreased. Hash table entries\n** that correspond to frames greater than the new K value are removed\n** from the hash table at this point.\n*/\n#ifndef SQLITE_OMIT_WAL\n\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3WalTrace = 0;\n# define WALTRACE(X)  if(sqlite3WalTrace) sqlite3DebugPrintf X\n#else\n# define WALTRACE(X)\n#endif\n\n/*\n** The maximum (and only) versions of the wal and wal-index formats\n** that may be interpreted by this version of SQLite.\n**\n** If a client begins recovering a WAL file and finds that (a) the checksum\n** values in the wal-header are correct and (b) the version field is not\n** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.\n**\n** Similarly, if a client successfully reads a wal-index header (i.e. the \n** checksum test is successful) and finds that the version field is not\n** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite\n** returns SQLITE_CANTOPEN.\n*/\n#define WAL_MAX_VERSION      3007000\n#define WALINDEX_MAX_VERSION 3007000\n\n/*\n** Indices of various locking bytes.   WAL_NREADER is the number\n** of available reader locks and should be at least 3.\n*/\n#define WAL_WRITE_LOCK         0\n#define WAL_ALL_BUT_WRITE      1\n#define WAL_CKPT_LOCK          1\n#define WAL_RECOVER_LOCK       2\n#define WAL_READ_LOCK(I)       (3+(I))\n#define WAL_NREADER            (SQLITE_SHM_NLOCK-3)\n\n\n/* Object declarations */\ntypedef struct WalIndexHdr WalIndexHdr;\ntypedef struct WalIterator WalIterator;\ntypedef struct WalCkptInfo WalCkptInfo;\n\n\n/*\n** The following object holds a copy of the wal-index header content.\n**\n** The actual header in the wal-index consists of two copies of this\n** object.\n**\n** The szPage value can be any power of 2 between 512 and 32768, inclusive.\n** Or it can be 1 to represent a 65536-byte page.  The latter case was\n** added in 3.7.1 when support for 64K pages was added.  \n*/\nstruct WalIndexHdr {\n  u32 iVersion;                   /* Wal-index version */\n  u32 unused;                     /* Unused (padding) field */\n  u32 iChange;                    /* Counter incremented each transaction */\n  u8 isInit;                      /* 1 when initialized */\n  u8 bigEndCksum;                 /* True if checksums in WAL are big-endian */\n  u16 szPage;                     /* Database page size in bytes. 1==64K */\n  u32 mxFrame;                    /* Index of last valid frame in the WAL */\n  u32 nPage;                      /* Size of database in pages */\n  u32 aFrameCksum[2];             /* Checksum of last frame in log */\n  u32 aSalt[2];                   /* Two salt values copied from WAL header */\n  u32 aCksum[2];                  /* Checksum over all prior fields */\n};\n\n/*\n** A copy of the following object occurs in the wal-index immediately\n** following the second copy of the WalIndexHdr.  This object stores\n** information used by checkpoint.\n**\n** nBackfill is the number of frames in the WAL that have been written\n** back into the database. (We call the act of moving content from WAL to\n** database \"backfilling\".)  The nBackfill number is never greater than\n** WalIndexHdr.mxFrame.  nBackfill can only be increased by threads\n** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).\n** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from\n** mxFrame back to zero when the WAL is reset.\n**\n** There is one entry in aReadMark[] for each reader lock.  If a reader\n** holds read-lock K, then the value in aReadMark[K] is no greater than\n** the mxFrame for that reader.  The value READMARK_NOT_USED (0xffffffff)\n** for any aReadMark[] means that entry is unused.  aReadMark[0] is \n** a special case; its value is never used and it exists as a place-holder\n** to avoid having to offset aReadMark[] indexs by one.  Readers holding\n** WAL_READ_LOCK(0) always ignore the entire WAL and read all content\n** directly from the database.\n**\n** The value of aReadMark[K] may only be changed by a thread that\n** is holding an exclusive lock on WAL_READ_LOCK(K).  Thus, the value of\n** aReadMark[K] cannot changed while there is a reader is using that mark\n** since the reader will be holding a shared lock on WAL_READ_LOCK(K).\n**\n** The checkpointer may only transfer frames from WAL to database where\n** the frame numbers are less than or equal to every aReadMark[] that is\n** in use (that is, every aReadMark[j] for which there is a corresponding\n** WAL_READ_LOCK(j)).  New readers (usually) pick the aReadMark[] with the\n** largest value and will increase an unused aReadMark[] to mxFrame if there\n** is not already an aReadMark[] equal to mxFrame.  The exception to the\n** previous sentence is when nBackfill equals mxFrame (meaning that everything\n** in the WAL has been backfilled into the database) then new readers\n** will choose aReadMark[0] which has value 0 and hence such reader will\n** get all their all content directly from the database file and ignore \n** the WAL.\n**\n** Writers normally append new frames to the end of the WAL.  However,\n** if nBackfill equals mxFrame (meaning that all WAL content has been\n** written back into the database) and if no readers are using the WAL\n** (in other words, if there are no WAL_READ_LOCK(i) where i>0) then\n** the writer will first \"reset\" the WAL back to the beginning and start\n** writing new content beginning at frame 1.\n**\n** We assume that 32-bit loads are atomic and so no locks are needed in\n** order to read from any aReadMark[] entries.\n*/\nstruct WalCkptInfo {\n  u32 nBackfill;                  /* Number of WAL frames backfilled into DB */\n  u32 aReadMark[WAL_NREADER];     /* Reader marks */\n};\n#define READMARK_NOT_USED  0xffffffff\n\n\n/* A block of WALINDEX_LOCK_RESERVED bytes beginning at\n** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems\n** only support mandatory file-locks, we do not read or write data\n** from the region of the file on which locks are applied.\n*/\n#define WALINDEX_LOCK_OFFSET   (sizeof(WalIndexHdr)*2 + sizeof(WalCkptInfo))\n#define WALINDEX_LOCK_RESERVED 16\n#define WALINDEX_HDR_SIZE      (WALINDEX_LOCK_OFFSET+WALINDEX_LOCK_RESERVED)\n\n/* Size of header before each frame in wal */\n#define WAL_FRAME_HDRSIZE 24\n\n/* Size of write ahead log header, including checksum. */\n/* #define WAL_HDRSIZE 24 */\n#define WAL_HDRSIZE 32\n\n/* WAL magic value. Either this value, or the same value with the least\n** significant bit also set (WAL_MAGIC | 0x00000001) is stored in 32-bit\n** big-endian format in the first 4 bytes of a WAL file.\n**\n** If the LSB is set, then the checksums for each frame within the WAL\n** file are calculated by treating all data as an array of 32-bit \n** big-endian words. Otherwise, they are calculated by interpreting \n** all data as 32-bit little-endian words.\n*/\n#define WAL_MAGIC 0x377f0682\n\n/*\n** Return the offset of frame iFrame in the write-ahead log file, \n** assuming a database page size of szPage bytes. The offset returned\n** is to the start of the write-ahead log frame-header.\n*/\n#define walFrameOffset(iFrame, szPage) (                               \\\n  WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE)         \\\n)\n\n/*\n** An open write-ahead log file is represented by an instance of the\n** following object.\n*/\nstruct Wal {\n  sqlite3_vfs *pVfs;         /* The VFS used to create pDbFd */\n  sqlite3_file *pDbFd;       /* File handle for the database file */\n  sqlite3_file *pWalFd;      /* File handle for WAL file */\n  u32 iCallback;             /* Value to pass to log callback (or 0) */\n  i64 mxWalSize;             /* Truncate WAL to this size upon reset */\n  int nWiData;               /* Size of array apWiData */\n  int szFirstBlock;          /* Size of first block written to WAL file */\n  volatile u32 **apWiData;   /* Pointer to wal-index content in memory */\n  u32 szPage;                /* Database page size */\n  i16 readLock;              /* Which read lock is being held.  -1 for none */\n  u8 syncFlags;              /* Flags to use to sync header writes */\n  u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */\n  u8 writeLock;              /* True if in a write transaction */\n  u8 ckptLock;               /* True if holding a checkpoint lock */\n  u8 readOnly;               /* WAL_RDWR, WAL_RDONLY, or WAL_SHM_RDONLY */\n  u8 truncateOnCommit;       /* True to truncate WAL file on commit */\n  u8 syncHeader;             /* Fsync the WAL header if true */\n  u8 padToSectorBoundary;    /* Pad transactions out to the next sector */\n  WalIndexHdr hdr;           /* Wal-index header for current transaction */\n  const char *zWalName;      /* Name of WAL file */\n  u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */\n#ifdef SQLITE_DEBUG\n  u8 lockError;              /* True if a locking error has occurred */\n#endif\n};\n\n/*\n** Candidate values for Wal.exclusiveMode.\n*/\n#define WAL_NORMAL_MODE     0\n#define WAL_EXCLUSIVE_MODE  1     \n#define WAL_HEAPMEMORY_MODE 2\n\n/*\n** Possible values for WAL.readOnly\n*/\n#define WAL_RDWR        0    /* Normal read/write connection */\n#define WAL_RDONLY      1    /* The WAL file is readonly */\n#define WAL_SHM_RDONLY  2    /* The SHM file is readonly */\n\n/*\n** Each page of the wal-index mapping contains a hash-table made up of\n** an array of HASHTABLE_NSLOT elements of the following type.\n*/\ntypedef u16 ht_slot;\n\n/*\n** This structure is used to implement an iterator that loops through\n** all frames in the WAL in database page order. Where two or more frames\n** correspond to the same database page, the iterator visits only the \n** frame most recently written to the WAL (in other words, the frame with\n** the largest index).\n**\n** The internals of this structure are only accessed by:\n**\n**   walIteratorInit() - Create a new iterator,\n**   walIteratorNext() - Step an iterator,\n**   walIteratorFree() - Free an iterator.\n**\n** This functionality is used by the checkpoint code (see walCheckpoint()).\n*/\nstruct WalIterator {\n  int iPrior;                     /* Last result returned from the iterator */\n  int nSegment;                   /* Number of entries in aSegment[] */\n  struct WalSegment {\n    int iNext;                    /* Next slot in aIndex[] not yet returned */\n    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */\n    u32 *aPgno;                   /* Array of page numbers. */\n    int nEntry;                   /* Nr. of entries in aPgno[] and aIndex[] */\n    int iZero;                    /* Frame number associated with aPgno[0] */\n  } aSegment[1];                  /* One for every 32KB page in the wal-index */\n};\n\n/*\n** Define the parameters of the hash tables in the wal-index file. There\n** is a hash-table following every HASHTABLE_NPAGE page numbers in the\n** wal-index.\n**\n** Changing any of these constants will alter the wal-index format and\n** create incompatibilities.\n*/\n#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */\n#define HASHTABLE_HASH_1     383                  /* Should be prime */\n#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */\n\n/* \n** The block of page numbers associated with the first hash-table in a\n** wal-index is smaller than usual. This is so that there is a complete\n** hash-table on each aligned 32KB page of the wal-index.\n*/\n#define HASHTABLE_NPAGE_ONE  (HASHTABLE_NPAGE - (WALINDEX_HDR_SIZE/sizeof(u32)))\n\n/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */\n#define WALINDEX_PGSZ   (                                         \\\n    sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \\\n)\n\n/*\n** Obtain a pointer to the iPage'th page of the wal-index. The wal-index\n** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are\n** numbered from zero.\n**\n** If this call is successful, *ppPage is set to point to the wal-index\n** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,\n** then an SQLite error code is returned and *ppPage is set to 0.\n*/\nstatic int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){\n  int rc = SQLITE_OK;\n\n  /* Enlarge the pWal->apWiData[] array if required */\n  if( pWal->nWiData<=iPage ){\n    int nByte = sizeof(u32*)*(iPage+1);\n    volatile u32 **apNew;\n    apNew = (volatile u32 **)sqlite3_realloc((void *)pWal->apWiData, nByte);\n    if( !apNew ){\n      *ppPage = 0;\n      return SQLITE_NOMEM;\n    }\n    memset((void*)&apNew[pWal->nWiData], 0,\n           sizeof(u32*)*(iPage+1-pWal->nWiData));\n    pWal->apWiData = apNew;\n    pWal->nWiData = iPage+1;\n  }\n\n  /* Request a pointer to the required page from the VFS */\n  if( pWal->apWiData[iPage]==0 ){\n    if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n      pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);\n      if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, \n          pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]\n      );\n      if( rc==SQLITE_READONLY ){\n        pWal->readOnly |= WAL_SHM_RDONLY;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  *ppPage = pWal->apWiData[iPage];\n  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );\n  return rc;\n}\n\n/*\n** Return a pointer to the WalCkptInfo structure in the wal-index.\n*/\nstatic volatile WalCkptInfo *walCkptInfo(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]);\n}\n\n/*\n** Return a pointer to the WalIndexHdr structure in the wal-index.\n*/\nstatic volatile WalIndexHdr *walIndexHdr(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalIndexHdr*)pWal->apWiData[0];\n}\n\n/*\n** The argument to this macro must be of type u32. On a little-endian\n** architecture, it returns the u32 value that results from interpreting\n** the 4 bytes as a big-endian value. On a big-endian architecture, it\n** returns the value that would be produced by intepreting the 4 bytes\n** of the input value as a little-endian integer.\n*/\n#define BYTESWAP32(x) ( \\\n    (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \\\n  + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \\\n)\n\n/*\n** Generate or extend an 8 byte checksum based on the data in \n** array aByte[] and the initial values of aIn[0] and aIn[1] (or\n** initial values of 0 and 0 if aIn==NULL).\n**\n** The checksum is written back into aOut[] before returning.\n**\n** nByte must be a positive multiple of 8.\n*/\nstatic void walChecksumBytes(\n  int nativeCksum, /* True for native byte-order, false for non-native */\n  u8 *a,           /* Content to be checksummed */\n  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */\n  const u32 *aIn,  /* Initial checksum value input */\n  u32 *aOut        /* OUT: Final checksum value output */\n){\n  u32 s1, s2;\n  u32 *aData = (u32 *)a;\n  u32 *aEnd = (u32 *)&a[nByte];\n\n  if( aIn ){\n    s1 = aIn[0];\n    s2 = aIn[1];\n  }else{\n    s1 = s2 = 0;\n  }\n\n  assert( nByte>=8 );\n  assert( (nByte&0x00000007)==0 );\n\n  if( nativeCksum ){\n    do {\n      s1 += *aData++ + s2;\n      s2 += *aData++ + s1;\n    }while( aData<aEnd );\n  }else{\n    do {\n      s1 += BYTESWAP32(aData[0]) + s2;\n      s2 += BYTESWAP32(aData[1]) + s1;\n      aData += 2;\n    }while( aData<aEnd );\n  }\n\n  aOut[0] = s1;\n  aOut[1] = s2;\n}\n\nstatic void walShmBarrier(Wal *pWal){\n  if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){\n    sqlite3OsShmBarrier(pWal->pDbFd);\n  }\n}\n\n/*\n** Write the header information in pWal->hdr into the wal-index.\n**\n** The checksum on pWal->hdr is updated before it is written.\n*/\nstatic void walIndexWriteHdr(Wal *pWal){\n  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);\n  const int nCksum = offsetof(WalIndexHdr, aCksum);\n\n  assert( pWal->writeLock );\n  pWal->hdr.isInit = 1;\n  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;\n  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);\n  memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));\n  walShmBarrier(pWal);\n  memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));\n}\n\n/*\n** This function encodes a single frame header and writes it to a buffer\n** supplied by the caller. A frame-header is made up of a series of \n** 4-byte big-endian integers, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the wal-header)\n**    12: Salt-2 (copied from the wal-header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n*/\nstatic void walEncodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 iPage,                      /* Database page number for frame */\n  u32 nTruncate,                  /* New db size (or 0 for non-commit frames) */\n  u8 *aData,                      /* Pointer to page data */\n  u8 *aFrame                      /* OUT: Write encoded frame here */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  assert( WAL_FRAME_HDRSIZE==24 );\n  sqlite3Put4byte(&aFrame[0], iPage);\n  sqlite3Put4byte(&aFrame[4], nTruncate);\n  memcpy(&aFrame[8], pWal->hdr.aSalt, 8);\n\n  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n\n  sqlite3Put4byte(&aFrame[16], aCksum[0]);\n  sqlite3Put4byte(&aFrame[20], aCksum[1]);\n}\n\n/*\n** Check to see if the frame with header in aFrame[] and content\n** in aData[] is valid.  If it is a valid frame, fill *piPage and\n** *pnTruncate and return true.  Return if the frame is not valid.\n*/\nstatic int walDecodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 *piPage,                    /* OUT: Database page number for frame */\n  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */\n  u8 *aData,                      /* Pointer to page data (for checksum) */\n  u8 *aFrame                      /* Frame data */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  u32 pgno;                       /* Page number of the frame */\n  assert( WAL_FRAME_HDRSIZE==24 );\n\n  /* A frame is only valid if the salt values in the frame-header\n  ** match the salt values in the wal-header. \n  */\n  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if the page number is creater than zero.\n  */\n  pgno = sqlite3Get4byte(&aFrame[0]);\n  if( pgno==0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if a checksum of the WAL header,\n  ** all prior frams, the first 16 bytes of this frame-header, \n  ** and the frame-data matches the checksum in the last 8 \n  ** bytes of this frame-header.\n  */\n  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) \n   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) \n  ){\n    /* Checksum failed. */\n    return 0;\n  }\n\n  /* If we reach this point, the frame is valid.  Return the page number\n  ** and the new database size.\n  */\n  *piPage = pgno;\n  *pnTruncate = sqlite3Get4byte(&aFrame[4]);\n  return 1;\n}\n\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Names of locks.  This routine is used to provide debugging output and is not\n** a part of an ordinary build.\n*/\nstatic const char *walLockName(int lockIdx){\n  if( lockIdx==WAL_WRITE_LOCK ){\n    return \"WRITE-LOCK\";\n  }else if( lockIdx==WAL_CKPT_LOCK ){\n    return \"CKPT-LOCK\";\n  }else if( lockIdx==WAL_RECOVER_LOCK ){\n    return \"RECOVER-LOCK\";\n  }else{\n    static char zName[15];\n    sqlite3_snprintf(sizeof(zName), zName, \"READ-LOCK[%d]\",\n                     lockIdx-WAL_READ_LOCK(0));\n    return zName;\n  }\n}\n#endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */\n    \n\n/*\n** Set or release locks on the WAL.  Locks are either shared or exclusive.\n** A lock cannot be moved directly between shared and exclusive - it must go\n** through the unlocked state first.\n**\n** In locking_mode=EXCLUSIVE, all of these routines become no-ops.\n*/\nstatic int walLockShared(Wal *pWal, int lockIdx){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: acquire SHARED-%s %s\\n\", pWal,\n            walLockName(lockIdx), rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockShared(Wal *pWal, int lockIdx){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: release SHARED-%s\\n\", pWal, walLockName(lockIdx)));\n}\nstatic int walLockExclusive(Wal *pWal, int lockIdx, int n){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\\n\", pWal,\n            walLockName(lockIdx), n, rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockExclusive(Wal *pWal, int lockIdx, int n){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: release EXCLUSIVE-%s cnt=%d\\n\", pWal,\n             walLockName(lockIdx), n));\n}\n\n/*\n** Compute a hash on a page number.  The resulting hash value must land\n** between 0 and (HASHTABLE_NSLOT-1).  The walHashNext() function advances\n** the hash to the next value in the event of a collision.\n*/\nstatic int walHash(u32 iPage){\n  assert( iPage>0 );\n  assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );\n  return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);\n}\nstatic int walNextHash(int iPriorHash){\n  return (iPriorHash+1)&(HASHTABLE_NSLOT-1);\n}\n\n/* \n** Return pointers to the hash table and page number array stored on\n** page iHash of the wal-index. The wal-index is broken into 32KB pages\n** numbered starting from 0.\n**\n** Set output variable *paHash to point to the start of the hash table\n** in the wal-index file. Set *piZero to one less than the frame \n** number of the first frame indexed by this hash table. If a\n** slot in the hash table is set to N, it refers to frame number \n** (*piZero+N) in the log.\n**\n** Finally, set *paPgno so that *paPgno[1] is the page number of the\n** first frame indexed by the hash table, frame (*piZero+1).\n*/\nstatic int walHashGet(\n  Wal *pWal,                      /* WAL handle */\n  int iHash,                      /* Find the iHash'th table */\n  volatile ht_slot **paHash,      /* OUT: Pointer to hash index */\n  volatile u32 **paPgno,          /* OUT: Pointer to page number array */\n  u32 *piZero                     /* OUT: Frame associated with *paPgno[0] */\n){\n  int rc;                         /* Return code */\n  volatile u32 *aPgno;\n\n  rc = walIndexPage(pWal, iHash, &aPgno);\n  assert( rc==SQLITE_OK || iHash>0 );\n\n  if( rc==SQLITE_OK ){\n    u32 iZero;\n    volatile ht_slot *aHash;\n\n    aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];\n    if( iHash==0 ){\n      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];\n      iZero = 0;\n    }else{\n      iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;\n    }\n  \n    *paPgno = &aPgno[-1];\n    *paHash = aHash;\n    *piZero = iZero;\n  }\n  return rc;\n}\n\n/*\n** Return the number of the wal-index page that contains the hash-table\n** and page-number array that contain entries corresponding to WAL frame\n** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages \n** are numbered starting from 0.\n*/\nstatic int walFramePage(u32 iFrame){\n  int iHash = (iFrame+HASHTABLE_NPAGE-HASHTABLE_NPAGE_ONE-1) / HASHTABLE_NPAGE;\n  assert( (iHash==0 || iFrame>HASHTABLE_NPAGE_ONE)\n       && (iHash>=1 || iFrame<=HASHTABLE_NPAGE_ONE)\n       && (iHash<=1 || iFrame>(HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE))\n       && (iHash>=2 || iFrame<=HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE)\n       && (iHash<=2 || iFrame>(HASHTABLE_NPAGE_ONE+2*HASHTABLE_NPAGE))\n  );\n  return iHash;\n}\n\n/*\n** Return the page number associated with frame iFrame in this WAL.\n*/\nstatic u32 walFramePgno(Wal *pWal, u32 iFrame){\n  int iHash = walFramePage(iFrame);\n  if( iHash==0 ){\n    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];\n  }\n  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];\n}\n\n/*\n** Remove entries from the hash table that point to WAL slots greater\n** than pWal->hdr.mxFrame.\n**\n** This function is called whenever pWal->hdr.mxFrame is decreased due\n** to a rollback or savepoint.\n**\n** At most only the hash table containing pWal->hdr.mxFrame needs to be\n** updated.  Any later hash tables will be automatically cleared when\n** pWal->hdr.mxFrame advances to the point where those hash tables are\n** actually needed.\n*/\nstatic void walCleanupHash(Wal *pWal){\n  volatile ht_slot *aHash = 0;    /* Pointer to hash table to clear */\n  volatile u32 *aPgno = 0;        /* Page number array for hash table */\n  u32 iZero = 0;                  /* frame == (aHash[x]+iZero) */\n  int iLimit = 0;                 /* Zero values greater than this */\n  int nByte;                      /* Number of bytes to zero in aPgno[] */\n  int i;                          /* Used to iterate through aHash[] */\n\n  assert( pWal->writeLock );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );\n\n  if( pWal->hdr.mxFrame==0 ) return;\n\n  /* Obtain pointers to the hash-table and page-number array containing \n  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed\n  ** that the page said hash-table and array reside on is already mapped.\n  */\n  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );\n  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );\n  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);\n\n  /* Zero all hash-table entries that correspond to frame numbers greater\n  ** than pWal->hdr.mxFrame.\n  */\n  iLimit = pWal->hdr.mxFrame - iZero;\n  assert( iLimit>0 );\n  for(i=0; i<HASHTABLE_NSLOT; i++){\n    if( aHash[i]>iLimit ){\n      aHash[i] = 0;\n    }\n  }\n  \n  /* Zero the entries in the aPgno array that correspond to frames with\n  ** frame numbers greater than pWal->hdr.mxFrame. \n  */\n  nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);\n  memset((void *)&aPgno[iLimit+1], 0, nByte);\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* Verify that the every entry in the mapping region is still reachable\n  ** via the hash table even after the cleanup.\n  */\n  if( iLimit ){\n    int i;           /* Loop counter */\n    int iKey;        /* Hash key */\n    for(i=1; i<=iLimit; i++){\n      for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){\n        if( aHash[iKey]==i ) break;\n      }\n      assert( aHash[iKey]==i );\n    }\n  }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n}\n\n\n/*\n** Set an entry in the wal-index that will map database page number\n** pPage into WAL frame iFrame.\n*/\nstatic int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){\n  int rc;                         /* Return code */\n  u32 iZero = 0;                  /* One less than frame number of aPgno[1] */\n  volatile u32 *aPgno = 0;        /* Page number array */\n  volatile ht_slot *aHash = 0;    /* Hash table */\n\n  rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);\n\n  /* Assuming the wal-index file was successfully mapped, populate the\n  ** page number array and hash table entry.\n  */\n  if( rc==SQLITE_OK ){\n    int iKey;                     /* Hash table key */\n    int idx;                      /* Value to write to hash-table slot */\n    int nCollide;                 /* Number of hash collisions */\n\n    idx = iFrame - iZero;\n    assert( idx <= HASHTABLE_NSLOT/2 + 1 );\n    \n    /* If this is the first entry to be added to this hash-table, zero the\n    ** entire hash table and aPgno[] array before proceding. \n    */\n    if( idx==1 ){\n      int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);\n      memset((void*)&aPgno[1], 0, nByte);\n    }\n\n    /* If the entry in aPgno[] is already set, then the previous writer\n    ** must have exited unexpectedly in the middle of a transaction (after\n    ** writing one or more dirty pages to the WAL to free up memory). \n    ** Remove the remnants of that writers uncommitted transaction from \n    ** the hash-table before writing any new entries.\n    */\n    if( aPgno[idx] ){\n      walCleanupHash(pWal);\n      assert( !aPgno[idx] );\n    }\n\n    /* Write the aPgno[] array entry and the hash-table slot. */\n    nCollide = idx;\n    for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){\n      if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;\n    }\n    aPgno[idx] = iPage;\n    aHash[iKey] = (ht_slot)idx;\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n    /* Verify that the number of entries in the hash table exactly equals\n    ** the number of entries in the mapping region.\n    */\n    {\n      int i;           /* Loop counter */\n      int nEntry = 0;  /* Number of entries in the hash table */\n      for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }\n      assert( nEntry==idx );\n    }\n\n    /* Verify that the every entry in the mapping region is reachable\n    ** via the hash table.  This turns out to be a really, really expensive\n    ** thing to check, so only do this occasionally - not on every\n    ** iteration.\n    */\n    if( (idx&0x3ff)==0 ){\n      int i;           /* Loop counter */\n      for(i=1; i<=idx; i++){\n        for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){\n          if( aHash[iKey]==i ) break;\n        }\n        assert( aHash[iKey]==i );\n      }\n    }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n  }\n\n\n  return rc;\n}\n\n\n/*\n** Recover the wal-index by reading the write-ahead log file. \n**\n** This routine first tries to establish an exclusive lock on the\n** wal-index to prevent other threads/processes from doing anything\n** with the WAL or wal-index while recovery is running.  The\n** WAL_RECOVER_LOCK is also held so that other threads will know\n** that this thread is running recovery.  If unable to establish\n** the necessary locks, this routine returns SQLITE_BUSY.\n*/\nstatic int walIndexRecover(Wal *pWal){\n  int rc;                         /* Return Code */\n  i64 nSize;                      /* Size of log file */\n  u32 aFrameCksum[2] = {0, 0};\n  int iLock;                      /* Lock offset to lock for checkpoint */\n  int nLock;                      /* Number of locks to hold */\n\n  /* Obtain an exclusive lock on all byte in the locking range not already\n  ** locked by the caller. The caller is guaranteed to have locked the\n  ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.\n  ** If successful, the same bytes that are locked here are unlocked before\n  ** this function returns.\n  */\n  assert( pWal->ckptLock==1 || pWal->ckptLock==0 );\n  assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );\n  assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );\n  assert( pWal->writeLock );\n  iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;\n  nLock = SQLITE_SHM_NLOCK - iLock;\n  rc = walLockExclusive(pWal, iLock, nLock);\n  if( rc ){\n    return rc;\n  }\n  WALTRACE((\"WAL%p: recovery begin...\\n\", pWal));\n\n  memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n\n  rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n  if( rc!=SQLITE_OK ){\n    goto recovery_error;\n  }\n\n  if( nSize>WAL_HDRSIZE ){\n    u8 aBuf[WAL_HDRSIZE];         /* Buffer to load WAL header into */\n    u8 *aFrame = 0;               /* Malloc'd buffer to load entire frame */\n    int szFrame;                  /* Number of bytes in buffer aFrame[] */\n    u8 *aData;                    /* Pointer to data part of aFrame buffer */\n    int iFrame;                   /* Index of last frame read */\n    i64 iOffset;                  /* Next offset to read from log file */\n    int szPage;                   /* Page size according to the log */\n    u32 magic;                    /* Magic value read from WAL header */\n    u32 version;                  /* Magic value read from WAL header */\n    int isValid;                  /* True if this frame is valid */\n\n    /* Read in the WAL header. */\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);\n    if( rc!=SQLITE_OK ){\n      goto recovery_error;\n    }\n\n    /* If the database page size is not a power of two, or is greater than\n    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid \n    ** data. Similarly, if the 'magic' value is invalid, ignore the whole\n    ** WAL file.\n    */\n    magic = sqlite3Get4byte(&aBuf[0]);\n    szPage = sqlite3Get4byte(&aBuf[8]);\n    if( (magic&0xFFFFFFFE)!=WAL_MAGIC \n     || szPage&(szPage-1) \n     || szPage>SQLITE_MAX_PAGE_SIZE \n     || szPage<512 \n    ){\n      goto finished;\n    }\n    pWal->hdr.bigEndCksum = (u8)(magic&0x00000001);\n    pWal->szPage = szPage;\n    pWal->nCkpt = sqlite3Get4byte(&aBuf[12]);\n    memcpy(&pWal->hdr.aSalt, &aBuf[16], 8);\n\n    /* Verify that the WAL header checksum is correct */\n    walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, \n        aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum\n    );\n    if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24])\n     || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28])\n    ){\n      goto finished;\n    }\n\n    /* Verify that the version number on the WAL format is one that\n    ** are able to understand */\n    version = sqlite3Get4byte(&aBuf[4]);\n    if( version!=WAL_MAX_VERSION ){\n      rc = SQLITE_CANTOPEN_BKPT;\n      goto finished;\n    }\n\n    /* Malloc a buffer to read frames into. */\n    szFrame = szPage + WAL_FRAME_HDRSIZE;\n    aFrame = (u8 *)sqlite3_malloc(szFrame);\n    if( !aFrame ){\n      rc = SQLITE_NOMEM;\n      goto recovery_error;\n    }\n    aData = &aFrame[WAL_FRAME_HDRSIZE];\n\n    /* Read all frames from the log file. */\n    iFrame = 0;\n    for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){\n      u32 pgno;                   /* Database page number for frame */\n      u32 nTruncate;              /* dbsize field from frame header */\n\n      /* Read and decode the next log frame. */\n      iFrame++;\n      rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);\n      if( rc!=SQLITE_OK ) break;\n      isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);\n      if( !isValid ) break;\n      rc = walIndexAppend(pWal, iFrame, pgno);\n      if( rc!=SQLITE_OK ) break;\n\n      /* If nTruncate is non-zero, this is a commit record. */\n      if( nTruncate ){\n        pWal->hdr.mxFrame = iFrame;\n        pWal->hdr.nPage = nTruncate;\n        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n        testcase( szPage<=32768 );\n        testcase( szPage>=65536 );\n        aFrameCksum[0] = pWal->hdr.aFrameCksum[0];\n        aFrameCksum[1] = pWal->hdr.aFrameCksum[1];\n      }\n    }\n\n    sqlite3_free(aFrame);\n  }\n\nfinished:\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo;\n    int i;\n    pWal->hdr.aFrameCksum[0] = aFrameCksum[0];\n    pWal->hdr.aFrameCksum[1] = aFrameCksum[1];\n    walIndexWriteHdr(pWal);\n\n    /* Reset the checkpoint-header. This is safe because this thread is \n    ** currently holding locks that exclude all other readers, writers and\n    ** checkpointers.\n    */\n    pInfo = walCkptInfo(pWal);\n    pInfo->nBackfill = 0;\n    pInfo->aReadMark[0] = 0;\n    for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n    if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame;\n\n    /* If more than one frame was recovered from the log file, report an\n    ** event via sqlite3_log(). This is to help with identifying performance\n    ** problems caused by applications routinely shutting down without\n    ** checkpointing the log file.\n    */\n    if( pWal->hdr.nPage ){\n      sqlite3_log(SQLITE_NOTICE_RECOVER_WAL,\n          \"recovered %d frames from WAL file %s\",\n          pWal->hdr.mxFrame, pWal->zWalName\n      );\n    }\n  }\n\nrecovery_error:\n  WALTRACE((\"WAL%p: recovery %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  walUnlockExclusive(pWal, iLock, nLock);\n  return rc;\n}\n\n/*\n** Close an open wal-index.\n*/\nstatic void walIndexClose(Wal *pWal, int isDelete){\n  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n    int i;\n    for(i=0; i<pWal->nWiData; i++){\n      sqlite3_free((void *)pWal->apWiData[i]);\n      pWal->apWiData[i] = 0;\n    }\n  }else{\n    sqlite3OsShmUnmap(pWal->pDbFd, isDelete);\n  }\n}\n\n/* \n** Open a connection to the WAL file zWalName. The database file must \n** already be opened on connection pDbFd. The buffer that zWalName points\n** to must remain valid for the lifetime of the returned Wal* handle.\n**\n** A SHARED lock should be held on the database file when this function\n** is called. The purpose of this SHARED lock is to prevent any other\n** client from unlinking the WAL or wal-index file. If another process\n** were to do this just after this client opened one of these files, the\n** system would be badly broken.\n**\n** If the log file is successfully opened, SQLITE_OK is returned and \n** *ppWal is set to point to a new WAL handle. If an error occurs,\n** an SQLite error code is returned and *ppWal is left unmodified.\n*/\nSQLITE_PRIVATE int sqlite3WalOpen(\n  sqlite3_vfs *pVfs,              /* vfs module to open wal and wal-index */\n  sqlite3_file *pDbFd,            /* The open database file */\n  const char *zWalName,           /* Name of the WAL file */\n  int bNoShm,                     /* True to run in heap-memory mode */\n  i64 mxWalSize,                  /* Truncate WAL to this size on reset */\n  Wal **ppWal                     /* OUT: Allocated Wal handle */\n){\n  int rc;                         /* Return Code */\n  Wal *pRet;                      /* Object to allocate and return */\n  int flags;                      /* Flags passed to OsOpen() */\n\n  assert( zWalName && zWalName[0] );\n  assert( pDbFd );\n\n  /* In the amalgamation, the os_unix.c and os_win.c source files come before\n  ** this source file.  Verify that the #defines of the locking byte offsets\n  ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.\n  */\n#ifdef WIN_SHM_BASE\n  assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n#ifdef UNIX_SHM_BASE\n  assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n\n\n  /* Allocate an instance of struct Wal to return. */\n  *ppWal = 0;\n  pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile);\n  if( !pRet ){\n    return SQLITE_NOMEM;\n  }\n\n  pRet->pVfs = pVfs;\n  pRet->pWalFd = (sqlite3_file *)&pRet[1];\n  pRet->pDbFd = pDbFd;\n  pRet->readLock = -1;\n  pRet->mxWalSize = mxWalSize;\n  pRet->zWalName = zWalName;\n  pRet->syncHeader = 1;\n  pRet->padToSectorBoundary = 1;\n  pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);\n\n  /* Open file handle on the write-ahead log file. */\n  flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);\n  rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);\n  if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){\n    pRet->readOnly = WAL_RDONLY;\n  }\n\n  if( rc!=SQLITE_OK ){\n    walIndexClose(pRet, 0);\n    sqlite3OsClose(pRet->pWalFd);\n    sqlite3_free(pRet);\n  }else{\n    int iDC = sqlite3OsDeviceCharacteristics(pRet->pWalFd);\n    if( iDC & SQLITE_IOCAP_SEQUENTIAL ){ pRet->syncHeader = 0; }\n    if( iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE ){\n      pRet->padToSectorBoundary = 0;\n    }\n    *ppWal = pRet;\n    WALTRACE((\"WAL%d: opened\\n\", pRet));\n  }\n  return rc;\n}\n\n/*\n** Change the size to which the WAL file is trucated on each reset.\n*/\nSQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){\n  if( pWal ) pWal->mxWalSize = iLimit;\n}\n\n/*\n** Find the smallest page number out of all pages held in the WAL that\n** has not been returned by any prior invocation of this method on the\n** same WalIterator object.   Write into *piFrame the frame index where\n** that page was last written into the WAL.  Write into *piPage the page\n** number.\n**\n** Return 0 on success.  If there are no pages in the WAL with a page\n** number larger than *piPage, then return 1.\n*/\nstatic int walIteratorNext(\n  WalIterator *p,               /* Iterator */\n  u32 *piPage,                  /* OUT: The page number of the next page */\n  u32 *piFrame                  /* OUT: Wal frame index of next page */\n){\n  u32 iMin;                     /* Result pgno must be greater than iMin */\n  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */\n  int i;                        /* For looping through segments */\n\n  iMin = p->iPrior;\n  assert( iMin<0xffffffff );\n  for(i=p->nSegment-1; i>=0; i--){\n    struct WalSegment *pSegment = &p->aSegment[i];\n    while( pSegment->iNext<pSegment->nEntry ){\n      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];\n      if( iPg>iMin ){\n        if( iPg<iRet ){\n          iRet = iPg;\n          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];\n        }\n        break;\n      }\n      pSegment->iNext++;\n    }\n  }\n\n  *piPage = p->iPrior = iRet;\n  return (iRet==0xFFFFFFFF);\n}\n\n/*\n** This function merges two sorted lists into a single sorted list.\n**\n** aLeft[] and aRight[] are arrays of indices.  The sort key is\n** aContent[aLeft[]] and aContent[aRight[]].  Upon entry, the following\n** is guaranteed for all J<K:\n**\n**        aContent[aLeft[J]] < aContent[aLeft[K]]\n**        aContent[aRight[J]] < aContent[aRight[K]]\n**\n** This routine overwrites aRight[] with a new (probably longer) sequence\n** of indices such that the aRight[] contains every index that appears in\n** either aLeft[] or the old aRight[] and such that the second condition\n** above is still met.\n**\n** The aContent[aLeft[X]] values will be unique for all X.  And the\n** aContent[aRight[X]] values will be unique too.  But there might be\n** one or more combinations of X and Y such that\n**\n**      aLeft[X]!=aRight[Y]  &&  aContent[aLeft[X]] == aContent[aRight[Y]]\n**\n** When that happens, omit the aLeft[X] and use the aRight[Y] index.\n*/\nstatic void walMerge(\n  const u32 *aContent,            /* Pages in wal - keys for the sort */\n  ht_slot *aLeft,                 /* IN: Left hand input list */\n  int nLeft,                      /* IN: Elements in array *paLeft */\n  ht_slot **paRight,              /* IN/OUT: Right hand input list */\n  int *pnRight,                   /* IN/OUT: Elements in *paRight */\n  ht_slot *aTmp                   /* Temporary buffer */\n){\n  int iLeft = 0;                  /* Current index in aLeft */\n  int iRight = 0;                 /* Current index in aRight */\n  int iOut = 0;                   /* Current index in output buffer */\n  int nRight = *pnRight;\n  ht_slot *aRight = *paRight;\n\n  assert( nLeft>0 && nRight>0 );\n  while( iRight<nRight || iLeft<nLeft ){\n    ht_slot logpage;\n    Pgno dbpage;\n\n    if( (iLeft<nLeft) \n     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])\n    ){\n      logpage = aLeft[iLeft++];\n    }else{\n      logpage = aRight[iRight++];\n    }\n    dbpage = aContent[logpage];\n\n    aTmp[iOut++] = logpage;\n    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;\n\n    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );\n    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );\n  }\n\n  *paRight = aLeft;\n  *pnRight = iOut;\n  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);\n}\n\n/*\n** Sort the elements in list aList using aContent[] as the sort key.\n** Remove elements with duplicate keys, preferring to keep the\n** larger aList[] values.\n**\n** The aList[] entries are indices into aContent[].  The values in\n** aList[] are to be sorted so that for all J<K:\n**\n**      aContent[aList[J]] < aContent[aList[K]]\n**\n** For any X and Y such that\n**\n**      aContent[aList[X]] == aContent[aList[Y]]\n**\n** Keep the larger of the two values aList[X] and aList[Y] and discard\n** the smaller.\n*/\nstatic void walMergesort(\n  const u32 *aContent,            /* Pages in wal */\n  ht_slot *aBuffer,               /* Buffer of at least *pnList items to use */\n  ht_slot *aList,                 /* IN/OUT: List to sort */\n  int *pnList                     /* IN/OUT: Number of elements in aList[] */\n){\n  struct Sublist {\n    int nList;                    /* Number of elements in aList */\n    ht_slot *aList;               /* Pointer to sub-list content */\n  };\n\n  const int nList = *pnList;      /* Size of input list */\n  int nMerge = 0;                 /* Number of elements in list aMerge */\n  ht_slot *aMerge = 0;            /* List to be merged */\n  int iList;                      /* Index into input list */\n  int iSub = 0;                   /* Index into aSub array */\n  struct Sublist aSub[13];        /* Array of sub-lists */\n\n  memset(aSub, 0, sizeof(aSub));\n  assert( nList<=HASHTABLE_NPAGE && nList>0 );\n  assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );\n\n  for(iList=0; iList<nList; iList++){\n    nMerge = 1;\n    aMerge = &aList[iList];\n    for(iSub=0; iList & (1<<iSub); iSub++){\n      struct Sublist *p = &aSub[iSub];\n      assert( p->aList && p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[iList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n    aSub[iSub].aList = aMerge;\n    aSub[iSub].nList = nMerge;\n  }\n\n  for(iSub++; iSub<ArraySize(aSub); iSub++){\n    if( nList & (1<<iSub) ){\n      struct Sublist *p = &aSub[iSub];\n      assert( p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[nList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n  }\n  assert( aMerge==aList );\n  *pnList = nMerge;\n\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=1; i<*pnList; i++){\n      assert( aContent[aList[i]] > aContent[aList[i-1]] );\n    }\n  }\n#endif\n}\n\n/* \n** Free an iterator allocated by walIteratorInit().\n*/\nstatic void walIteratorFree(WalIterator *p){\n  sqlite3ScratchFree(p);\n}\n\n/*\n** Construct a WalInterator object that can be used to loop over all \n** pages in the WAL in ascending order. The caller must hold the checkpoint\n** lock.\n**\n** On success, make *pp point to the newly allocated WalInterator object\n** return SQLITE_OK. Otherwise, return an error code. If this routine\n** returns an error, the value of *pp is undefined.\n**\n** The calling routine should invoke walIteratorFree() to destroy the\n** WalIterator object when it has finished with it.\n*/\nstatic int walIteratorInit(Wal *pWal, WalIterator **pp){\n  WalIterator *p;                 /* Return value */\n  int nSegment;                   /* Number of segments to merge */\n  u32 iLast;                      /* Last frame in log */\n  int nByte;                      /* Number of bytes to allocate */\n  int i;                          /* Iterator variable */\n  ht_slot *aTmp;                  /* Temp space used by merge-sort */\n  int rc = SQLITE_OK;             /* Return Code */\n\n  /* This routine only runs while holding the checkpoint lock. And\n  ** it only runs if there is actually content in the log (mxFrame>0).\n  */\n  assert( pWal->ckptLock && pWal->hdr.mxFrame>0 );\n  iLast = pWal->hdr.mxFrame;\n\n  /* Allocate space for the WalIterator object. */\n  nSegment = walFramePage(iLast) + 1;\n  nByte = sizeof(WalIterator) \n        + (nSegment-1)*sizeof(struct WalSegment)\n        + iLast*sizeof(ht_slot);\n  p = (WalIterator *)sqlite3ScratchMalloc(nByte);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, nByte);\n  p->nSegment = nSegment;\n\n  /* Allocate temporary space used by the merge-sort routine. This block\n  ** of memory will be freed before this function returns.\n  */\n  aTmp = (ht_slot *)sqlite3ScratchMalloc(\n      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)\n  );\n  if( !aTmp ){\n    rc = SQLITE_NOMEM;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nSegment; i++){\n    volatile ht_slot *aHash;\n    u32 iZero;\n    volatile u32 *aPgno;\n\n    rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);\n    if( rc==SQLITE_OK ){\n      int j;                      /* Counter variable */\n      int nEntry;                 /* Number of entries in this segment */\n      ht_slot *aIndex;            /* Sorted index for this segment */\n\n      aPgno++;\n      if( (i+1)==nSegment ){\n        nEntry = (int)(iLast - iZero);\n      }else{\n        nEntry = (int)((u32*)aHash - (u32*)aPgno);\n      }\n      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];\n      iZero++;\n  \n      for(j=0; j<nEntry; j++){\n        aIndex[j] = (ht_slot)j;\n      }\n      walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);\n      p->aSegment[i].iZero = iZero;\n      p->aSegment[i].nEntry = nEntry;\n      p->aSegment[i].aIndex = aIndex;\n      p->aSegment[i].aPgno = (u32 *)aPgno;\n    }\n  }\n  sqlite3ScratchFree(aTmp);\n\n  if( rc!=SQLITE_OK ){\n    walIteratorFree(p);\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and\n** n. If the attempt fails and parameter xBusy is not NULL, then it is a\n** busy-handler function. Invoke it and retry the lock until either the\n** lock is successfully obtained or the busy-handler returns 0.\n*/\nstatic int walBusyLock(\n  Wal *pWal,                      /* WAL connection */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int lockIdx,                    /* Offset of first byte to lock */\n  int n                           /* Number of bytes to lock */\n){\n  int rc;\n  do {\n    rc = walLockExclusive(pWal, lockIdx, n);\n  }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );\n  return rc;\n}\n\n/*\n** The cache of the wal-index header must be valid to call this function.\n** Return the page-size in bytes used by the database.\n*/\nstatic int walPagesize(Wal *pWal){\n  return (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n}\n\n/*\n** Copy as much content as we can from the WAL back into the database file\n** in response to an sqlite3_wal_checkpoint() request or the equivalent.\n**\n** The amount of information copies from WAL to database might be limited\n** by active readers.  This routine will never overwrite a database page\n** that a concurrent reader might be using.\n**\n** All I/O barrier operations (a.k.a fsyncs) occur in this routine when\n** SQLite is in WAL-mode in synchronous=NORMAL.  That means that if \n** checkpoints are always run by a background thread or background \n** process, foreground threads will never block on a lengthy fsync call.\n**\n** Fsync is called on the WAL before writing content out of the WAL and\n** into the database.  This ensures that if the new content is persistent\n** in the WAL and can be recovered following a power-loss or hard reset.\n**\n** Fsync is also called on the database file if (and only if) the entire\n** WAL content is copied into the database file.  This second fsync makes\n** it safe to delete the WAL since the new content will persist in the\n** database file.\n**\n** This routine uses and updates the nBackfill field of the wal-index header.\n** This is the only routine tha will increase the value of nBackfill.  \n** (A WAL reset or recovery will revert nBackfill to zero, but not increase\n** its value.)\n**\n** The caller must be holding sufficient locks to ensure that no other\n** checkpoint is running (in any other thread or process) at the same\n** time.\n*/\nstatic int walCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  int eMode,                      /* One of PASSIVE, FULL or RESTART */\n  int (*xBusyCall)(void*),        /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags for OsSync() (or 0) */\n  u8 *zBuf                        /* Temporary buffer to use */\n){\n  int rc;                         /* Return code */\n  int szPage;                     /* Database page-size */\n  WalIterator *pIter = 0;         /* Wal iterator context */\n  u32 iDbpage = 0;                /* Next database page to write */\n  u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */\n  u32 mxSafeFrame;                /* Max frame that can be backfilled */\n  u32 mxPage;                     /* Max database page to write */\n  int i;                          /* Loop counter */\n  volatile WalCkptInfo *pInfo;    /* The checkpoint status information */\n  int (*xBusy)(void*) = 0;        /* Function to call when waiting for locks */\n\n  szPage = walPagesize(pWal);\n  testcase( szPage<=32768 );\n  testcase( szPage>=65536 );\n  pInfo = walCkptInfo(pWal);\n  if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;\n\n  /* Allocate the iterator */\n  rc = walIteratorInit(pWal, &pIter);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pIter );\n\n  if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;\n\n  /* Compute in mxSafeFrame the index of the last frame of the WAL that is\n  ** safe to write into the database.  Frames beyond mxSafeFrame might\n  ** overwrite database pages that are in use by active readers and thus\n  ** cannot be backfilled from the WAL.\n  */\n  mxSafeFrame = pWal->hdr.mxFrame;\n  mxPage = pWal->hdr.nPage;\n  for(i=1; i<WAL_NREADER; i++){\n    u32 y = pInfo->aReadMark[i];\n    if( mxSafeFrame>y ){\n      assert( y<=pWal->hdr.mxFrame );\n      rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);\n      if( rc==SQLITE_OK ){\n        pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);\n        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n      }else if( rc==SQLITE_BUSY ){\n        mxSafeFrame = y;\n        xBusy = 0;\n      }else{\n        goto walcheckpoint_out;\n      }\n    }\n  }\n\n  if( pInfo->nBackfill<mxSafeFrame\n   && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0), 1))==SQLITE_OK\n  ){\n    i64 nSize;                    /* Current size of database file */\n    u32 nBackfill = pInfo->nBackfill;\n\n    /* Sync the WAL to disk */\n    if( sync_flags ){\n      rc = sqlite3OsSync(pWal->pWalFd, sync_flags);\n    }\n\n    /* If the database may grow as a result of this checkpoint, hint\n    ** about the eventual size of the db file to the VFS layer.\n    */\n    if( rc==SQLITE_OK ){\n      i64 nReq = ((i64)mxPage * szPage);\n      rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);\n      if( rc==SQLITE_OK && nSize<nReq ){\n        sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);\n      }\n    }\n\n\n    /* Iterate through the contents of the WAL, copying data to the db file. */\n    while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){\n      i64 iOffset;\n      assert( walFramePgno(pWal, iFrame)==iDbpage );\n      if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue;\n      iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;\n      /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */\n      rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);\n      if( rc!=SQLITE_OK ) break;\n      iOffset = (iDbpage-1)*(i64)szPage;\n      testcase( IS_BIG_INT(iOffset) );\n      rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);\n      if( rc!=SQLITE_OK ) break;\n    }\n\n    /* If work was actually accomplished... */\n    if( rc==SQLITE_OK ){\n      if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){\n        i64 szDb = pWal->hdr.nPage*(i64)szPage;\n        testcase( IS_BIG_INT(szDb) );\n        rc = sqlite3OsTruncate(pWal->pDbFd, szDb);\n        if( rc==SQLITE_OK && sync_flags ){\n          rc = sqlite3OsSync(pWal->pDbFd, sync_flags);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        pInfo->nBackfill = mxSafeFrame;\n      }\n    }\n\n    /* Release the reader lock held while backfilling */\n    walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);\n  }\n\n  if( rc==SQLITE_BUSY ){\n    /* Reset the return code so as not to report a checkpoint failure\n    ** just because there are active readers.  */\n    rc = SQLITE_OK;\n  }\n\n  /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal\n  ** file has been copied into the database file, then block until all\n  ** readers have finished using the wal file. This ensures that the next\n  ** process to write to the database restarts the wal file.\n  */\n  if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    assert( pWal->writeLock );\n    if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n      rc = SQLITE_BUSY;\n    }else if( eMode==SQLITE_CHECKPOINT_RESTART ){\n      assert( mxSafeFrame==pWal->hdr.mxFrame );\n      rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }\n    }\n  }\n\n walcheckpoint_out:\n  walIteratorFree(pIter);\n  return rc;\n}\n\n/*\n** If the WAL file is currently larger than nMax bytes in size, truncate\n** it to exactly nMax bytes. If an error occurs while doing so, ignore it.\n*/\nstatic void walLimitSize(Wal *pWal, i64 nMax){\n  i64 sz;\n  int rx;\n  sqlite3BeginBenignMalloc();\n  rx = sqlite3OsFileSize(pWal->pWalFd, &sz);\n  if( rx==SQLITE_OK && (sz > nMax ) ){\n    rx = sqlite3OsTruncate(pWal->pWalFd, nMax);\n  }\n  sqlite3EndBenignMalloc();\n  if( rx ){\n    sqlite3_log(rx, \"cannot limit WAL size: %s\", pWal->zWalName);\n  }\n}\n\n/*\n** Close a connection to a log file.\n*/\nSQLITE_PRIVATE int sqlite3WalClose(\n  Wal *pWal,                      /* Wal to close */\n  int sync_flags,                 /* Flags to pass to OsSync() (or 0) */\n  int nBuf,\n  u8 *zBuf                        /* Buffer of at least nBuf bytes */\n){\n  int rc = SQLITE_OK;\n  if( pWal ){\n    int isDelete = 0;             /* True to unlink wal and wal-index files */\n\n    /* If an EXCLUSIVE lock can be obtained on the database file (using the\n    ** ordinary, rollback-mode locking methods, this guarantees that the\n    ** connection associated with this log file is the only connection to\n    ** the database. In this case checkpoint the database and unlink both\n    ** the wal and wal-index files.\n    **\n    ** The EXCLUSIVE lock is not released before returning.\n    */\n    rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);\n    if( rc==SQLITE_OK ){\n      if( pWal->exclusiveMode==WAL_NORMAL_MODE ){\n        pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n      }\n      rc = sqlite3WalCheckpoint(\n          pWal, SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0\n      );\n      if( rc==SQLITE_OK ){\n        int bPersist = -1;\n        sqlite3OsFileControlHint(\n            pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist\n        );\n        if( bPersist!=1 ){\n          /* Try to delete the WAL file if the checkpoint completed and\n          ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal\n          ** mode (!bPersist) */\n          isDelete = 1;\n        }else if( pWal->mxWalSize>=0 ){\n          /* Try to truncate the WAL file to zero bytes if the checkpoint\n          ** completed and fsynced (rc==SQLITE_OK) and we are in persistent\n          ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a\n          ** non-negative value (pWal->mxWalSize>=0).  Note that we truncate\n          ** to zero bytes as truncating to the journal_size_limit might\n          ** leave a corrupt WAL file on disk. */\n          walLimitSize(pWal, 0);\n        }\n      }\n    }\n\n    walIndexClose(pWal, isDelete);\n    sqlite3OsClose(pWal->pWalFd);\n    if( isDelete ){\n      sqlite3BeginBenignMalloc();\n      sqlite3OsDelete(pWal->pVfs, pWal->zWalName, 0);\n      sqlite3EndBenignMalloc();\n    }\n    WALTRACE((\"WAL%p: closed\\n\", pWal));\n    sqlite3_free((void *)pWal->apWiData);\n    sqlite3_free(pWal);\n  }\n  return rc;\n}\n\n/*\n** Try to read the wal-index header.  Return 0 on success and 1 if\n** there is a problem.\n**\n** The wal-index is in shared memory.  Another thread or process might\n** be writing the header at the same time this procedure is trying to\n** read it, which might result in inconsistency.  A dirty read is detected\n** by verifying that both copies of the header are the same and also by\n** a checksum on the header.\n**\n** If and only if the read is consistent and the header is different from\n** pWal->hdr, then pWal->hdr is updated to the content of the new header\n** and *pChanged is set to 1.\n**\n** If the checksum cannot be verified return non-zero. If the header\n** is read successfully and the checksum verified, return zero.\n*/\nstatic int walIndexTryHdr(Wal *pWal, int *pChanged){\n  u32 aCksum[2];                  /* Checksum on the header content */\n  WalIndexHdr h1, h2;             /* Two copies of the header content */\n  WalIndexHdr volatile *aHdr;     /* Header in shared memory */\n\n  /* The first page of the wal-index must be mapped at this point. */\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n\n  /* Read the header. This might happen concurrently with a write to the\n  ** same area of shared memory on a different CPU in a SMP,\n  ** meaning it is possible that an inconsistent snapshot is read\n  ** from the file. If this happens, return non-zero.\n  **\n  ** There are two copies of the header at the beginning of the wal-index.\n  ** When reading, read [0] first then [1].  Writes are in the reverse order.\n  ** Memory barriers are used to prevent the compiler or the hardware from\n  ** reordering the reads and writes.\n  */\n  aHdr = walIndexHdr(pWal);\n  memcpy(&h1, (void *)&aHdr[0], sizeof(h1));\n  walShmBarrier(pWal);\n  memcpy(&h2, (void *)&aHdr[1], sizeof(h2));\n\n  if( memcmp(&h1, &h2, sizeof(h1))!=0 ){\n    return 1;   /* Dirty read */\n  }  \n  if( h1.isInit==0 ){\n    return 1;   /* Malformed header - probably all zeros */\n  }\n  walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);\n  if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){\n    return 1;   /* Checksum does not match */\n  }\n\n  if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){\n    *pChanged = 1;\n    memcpy(&pWal->hdr, &h1, sizeof(WalIndexHdr));\n    pWal->szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n    testcase( pWal->szPage<=32768 );\n    testcase( pWal->szPage>=65536 );\n  }\n\n  /* The header was successfully read. Return zero. */\n  return 0;\n}\n\n/*\n** Read the wal-index header from the wal-index and into pWal->hdr.\n** If the wal-header appears to be corrupt, try to reconstruct the\n** wal-index from the WAL before returning.\n**\n** Set *pChanged to 1 if the wal-index header value in pWal->hdr is\n** changed by this opertion.  If pWal->hdr is unchanged, set *pChanged\n** to 0.\n**\n** If the wal-index header is successfully read, return SQLITE_OK. \n** Otherwise an SQLite error code.\n*/\nstatic int walIndexReadHdr(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int badHdr;                     /* True if a header read failed */\n  volatile u32 *page0;            /* Chunk of wal-index containing header */\n\n  /* Ensure that page 0 of the wal-index (the page that contains the \n  ** wal-index header) is mapped. Return early if an error occurs here.\n  */\n  assert( pChanged );\n  rc = walIndexPage(pWal, 0, &page0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  };\n  assert( page0 || pWal->writeLock==0 );\n\n  /* If the first page of the wal-index has been mapped, try to read the\n  ** wal-index header immediately, without holding any lock. This usually\n  ** works, but may fail if the wal-index header is corrupt or currently \n  ** being modified by another thread or process.\n  */\n  badHdr = (page0 ? walIndexTryHdr(pWal, pChanged) : 1);\n\n  /* If the first attempt failed, it might have been due to a race\n  ** with a writer.  So get a WRITE lock and try again.\n  */\n  assert( badHdr==0 || pWal->writeLock==0 );\n  if( badHdr ){\n    if( pWal->readOnly & WAL_SHM_RDONLY ){\n      if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){\n        walUnlockShared(pWal, WAL_WRITE_LOCK);\n        rc = SQLITE_READONLY_RECOVERY;\n      }\n    }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){\n      pWal->writeLock = 1;\n      if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){\n        badHdr = walIndexTryHdr(pWal, pChanged);\n        if( badHdr ){\n          /* If the wal-index header is still malformed even while holding\n          ** a WRITE lock, it can only mean that the header is corrupted and\n          ** needs to be reconstructed.  So run recovery to do exactly that.\n          */\n          rc = walIndexRecover(pWal);\n          *pChanged = 1;\n        }\n      }\n      pWal->writeLock = 0;\n      walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    }\n  }\n\n  /* If the header is read successfully, check the version number to make\n  ** sure the wal-index was not constructed with some future format that\n  ** this version of SQLite cannot understand.\n  */\n  if( badHdr==0 && pWal->hdr.iVersion!=WALINDEX_MAX_VERSION ){\n    rc = SQLITE_CANTOPEN_BKPT;\n  }\n\n  return rc;\n}\n\n/*\n** This is the value that walTryBeginRead returns when it needs to\n** be retried.\n*/\n#define WAL_RETRY  (-1)\n\n/*\n** Attempt to start a read transaction.  This might fail due to a race or\n** other transient condition.  When that happens, it returns WAL_RETRY to\n** indicate to the caller that it is safe to retry immediately.\n**\n** On success return SQLITE_OK.  On a permanent failure (such an\n** I/O error or an SQLITE_BUSY because another process is running\n** recovery) return a positive error code.\n**\n** The useWal parameter is true to force the use of the WAL and disable\n** the case where the WAL is bypassed because it has been completely\n** checkpointed.  If useWal==0 then this routine calls walIndexReadHdr() \n** to make a copy of the wal-index header into pWal->hdr.  If the \n** wal-index header has changed, *pChanged is set to 1 (as an indication \n** to the caller that the local paget cache is obsolete and needs to be \n** flushed.)  When useWal==1, the wal-index header is assumed to already\n** be loaded and the pChanged parameter is unused.\n**\n** The caller must set the cnt parameter to the number of prior calls to\n** this routine during the current read attempt that returned WAL_RETRY.\n** This routine will start taking more aggressive measures to clear the\n** race conditions after multiple WAL_RETRY returns, and after an excessive\n** number of errors will ultimately return SQLITE_PROTOCOL.  The\n** SQLITE_PROTOCOL return indicates that some other process has gone rogue\n** and is not honoring the locking protocol.  There is a vanishingly small\n** chance that SQLITE_PROTOCOL could be returned because of a run of really\n** bad luck when there is lots of contention for the wal-index, but that\n** possibility is so small that it can be safely neglected, we believe.\n**\n** On success, this routine obtains a read lock on \n** WAL_READ_LOCK(pWal->readLock).  The pWal->readLock integer is\n** in the range 0 <= pWal->readLock < WAL_NREADER.  If pWal->readLock==(-1)\n** that means the Wal does not hold any read lock.  The reader must not\n** access any database page that is modified by a WAL frame up to and\n** including frame number aReadMark[pWal->readLock].  The reader will\n** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0\n** Or if pWal->readLock==0, then the reader will ignore the WAL\n** completely and get all content directly from the database file.\n** If the useWal parameter is 1 then the WAL will never be ignored and\n** this routine will always set pWal->readLock>0 on success.\n** When the read transaction is completed, the caller must release the\n** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.\n**\n** This routine uses the nBackfill and aReadMark[] fields of the header\n** to select a particular WAL_READ_LOCK() that strives to let the\n** checkpoint process do as much work as possible.  This routine might\n** update values of the aReadMark[] array in the header, but if it does\n** so it takes care to hold an exclusive lock on the corresponding\n** WAL_READ_LOCK() while changing values.\n*/\nstatic int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){\n  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */\n  u32 mxReadMark;                 /* Largest aReadMark[] value */\n  int mxI;                        /* Index of largest aReadMark[] value */\n  int i;                          /* Loop counter */\n  int rc = SQLITE_OK;             /* Return code  */\n\n  assert( pWal->readLock<0 );     /* Not currently locked */\n\n  /* Take steps to avoid spinning forever if there is a protocol error.\n  **\n  ** Circumstances that cause a RETRY should only last for the briefest\n  ** instances of time.  No I/O or other system calls are done while the\n  ** locks are held, so the locks should not be held for very long. But \n  ** if we are unlucky, another process that is holding a lock might get\n  ** paged out or take a page-fault that is time-consuming to resolve, \n  ** during the few nanoseconds that it is holding the lock.  In that case,\n  ** it might take longer than normal for the lock to free.\n  **\n  ** After 5 RETRYs, we begin calling sqlite3OsSleep().  The first few\n  ** calls to sqlite3OsSleep() have a delay of 1 microsecond.  Really this\n  ** is more of a scheduler yield than an actual delay.  But on the 10th\n  ** an subsequent retries, the delays start becoming longer and longer, \n  ** so that on the 100th (and last) RETRY we delay for 21 milliseconds.\n  ** The total delay time before giving up is less than 1 second.\n  */\n  if( cnt>5 ){\n    int nDelay = 1;                      /* Pause time in microseconds */\n    if( cnt>100 ){\n      VVA_ONLY( pWal->lockError = 1; )\n      return SQLITE_PROTOCOL;\n    }\n    if( cnt>=10 ) nDelay = (cnt-9)*238;  /* Max delay 21ms. Total delay 996ms */\n    sqlite3OsSleep(pWal->pVfs, nDelay);\n  }\n\n  if( !useWal ){\n    rc = walIndexReadHdr(pWal, pChanged);\n    if( rc==SQLITE_BUSY ){\n      /* If there is not a recovery running in another thread or process\n      ** then convert BUSY errors to WAL_RETRY.  If recovery is known to\n      ** be running, convert BUSY to BUSY_RECOVERY.  There is a race here\n      ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY\n      ** would be technically correct.  But the race is benign since with\n      ** WAL_RETRY this routine will be called again and will probably be\n      ** right on the second iteration.\n      */\n      if( pWal->apWiData[0]==0 ){\n        /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.\n        ** We assume this is a transient condition, so return WAL_RETRY. The\n        ** xShmMap() implementation used by the default unix and win32 VFS \n        ** modules may return SQLITE_BUSY due to a race condition in the \n        ** code that determines whether or not the shared-memory region \n        ** must be zeroed before the requested page is returned.\n        */\n        rc = WAL_RETRY;\n      }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){\n        walUnlockShared(pWal, WAL_RECOVER_LOCK);\n        rc = WAL_RETRY;\n      }else if( rc==SQLITE_BUSY ){\n        rc = SQLITE_BUSY_RECOVERY;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  pInfo = walCkptInfo(pWal);\n  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame ){\n    /* The WAL has been completely backfilled (or it is empty).\n    ** and can be safely ignored.\n    */\n    rc = walLockShared(pWal, WAL_READ_LOCK(0));\n    walShmBarrier(pWal);\n    if( rc==SQLITE_OK ){\n      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){\n        /* It is not safe to allow the reader to continue here if frames\n        ** may have been appended to the log before READ_LOCK(0) was obtained.\n        ** When holding READ_LOCK(0), the reader ignores the entire log file,\n        ** which implies that the database file contains a trustworthy\n        ** snapshoT. Since holding READ_LOCK(0) prevents a checkpoint from\n        ** happening, this is usually correct.\n        **\n        ** However, if frames have been appended to the log (or if the log \n        ** is wrapped and written for that matter) before the READ_LOCK(0)\n        ** is obtained, that is not necessarily true. A checkpointer may\n        ** have started to backfill the appended frames but crashed before\n        ** it finished. Leaving a corrupt image in the database file.\n        */\n        walUnlockShared(pWal, WAL_READ_LOCK(0));\n        return WAL_RETRY;\n      }\n      pWal->readLock = 0;\n      return SQLITE_OK;\n    }else if( rc!=SQLITE_BUSY ){\n      return rc;\n    }\n  }\n\n  /* If we get this far, it means that the reader will want to use\n  ** the WAL to get at content from recent commits.  The job now is\n  ** to select one of the aReadMark[] entries that is closest to\n  ** but not exceeding pWal->hdr.mxFrame and lock that entry.\n  */\n  mxReadMark = 0;\n  mxI = 0;\n  for(i=1; i<WAL_NREADER; i++){\n    u32 thisMark = pInfo->aReadMark[i];\n    if( mxReadMark<=thisMark && thisMark<=pWal->hdr.mxFrame ){\n      assert( thisMark!=READMARK_NOT_USED );\n      mxReadMark = thisMark;\n      mxI = i;\n    }\n  }\n  /* There was once an \"if\" here. The extra \"{\" is to preserve indentation. */\n  {\n    if( (pWal->readOnly & WAL_SHM_RDONLY)==0\n     && (mxReadMark<pWal->hdr.mxFrame || mxI==0)\n    ){\n      for(i=1; i<WAL_NREADER; i++){\n        rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        if( rc==SQLITE_OK ){\n          mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;\n          mxI = i;\n          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n          break;\n        }else if( rc!=SQLITE_BUSY ){\n          return rc;\n        }\n      }\n    }\n    if( mxI==0 ){\n      assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );\n      return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK;\n    }\n\n    rc = walLockShared(pWal, WAL_READ_LOCK(mxI));\n    if( rc ){\n      return rc==SQLITE_BUSY ? WAL_RETRY : rc;\n    }\n    /* Now that the read-lock has been obtained, check that neither the\n    ** value in the aReadMark[] array or the contents of the wal-index\n    ** header have changed.\n    **\n    ** It is necessary to check that the wal-index header did not change\n    ** between the time it was read and when the shared-lock was obtained\n    ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility\n    ** that the log file may have been wrapped by a writer, or that frames\n    ** that occur later in the log than pWal->hdr.mxFrame may have been\n    ** copied into the database by a checkpointer. If either of these things\n    ** happened, then reading the database with the current value of\n    ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry\n    ** instead.\n    **\n    ** This does not guarantee that the copy of the wal-index header is up to\n    ** date before proceeding. That would not be possible without somehow\n    ** blocking writers. It only guarantees that a dangerous checkpoint or \n    ** log-wrap (either of which would require an exclusive lock on\n    ** WAL_READ_LOCK(mxI)) has not occurred since the snapshot was valid.\n    */\n    walShmBarrier(pWal);\n    if( pInfo->aReadMark[mxI]!=mxReadMark\n     || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))\n    ){\n      walUnlockShared(pWal, WAL_READ_LOCK(mxI));\n      return WAL_RETRY;\n    }else{\n      assert( mxReadMark<=pWal->hdr.mxFrame );\n      pWal->readLock = (i16)mxI;\n    }\n  }\n  return rc;\n}\n\n/*\n** Begin a read transaction on the database.\n**\n** This routine used to be called sqlite3OpenSnapshot() and with good reason:\n** it takes a snapshot of the state of the WAL and wal-index for the current\n** instant in time.  The current thread will continue to use this snapshot.\n** Other threads might append new content to the WAL and wal-index but\n** that extra content is ignored by the current thread.\n**\n** If the database contents have changes since the previous read\n** transaction, then *pChanged is set to 1 before returning.  The\n** Pager layer will use this to know that is cache is stale and\n** needs to be flushed.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int cnt = 0;                    /* Number of TryBeginRead attempts */\n\n  do{\n    rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);\n  }while( rc==WAL_RETRY );\n  testcase( (rc&0xff)==SQLITE_BUSY );\n  testcase( (rc&0xff)==SQLITE_IOERR );\n  testcase( rc==SQLITE_PROTOCOL );\n  testcase( rc==SQLITE_OK );\n  return rc;\n}\n\n/*\n** Finish with a read transaction.  All this does is release the\n** read-lock.\n*/\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){\n  sqlite3WalEndWriteTransaction(pWal);\n  if( pWal->readLock>=0 ){\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->readLock = -1;\n  }\n}\n\n/*\n** Search the wal file for page pgno. If found, set *piRead to the frame that\n** contains the page. Otherwise, if pgno is not in the wal file, set *piRead\n** to zero.\n**\n** Return SQLITE_OK if successful, or an error code if an error occurs. If an\n** error does occur, the final value of *piRead is undefined.\n*/\nSQLITE_PRIVATE int sqlite3WalFindFrame(\n  Wal *pWal,                      /* WAL handle */\n  Pgno pgno,                      /* Database page number to read data for */\n  u32 *piRead                     /* OUT: Frame number (or zero) */\n){\n  u32 iRead = 0;                  /* If !=0, WAL frame to return data from */\n  u32 iLast = pWal->hdr.mxFrame;  /* Last page in WAL for this reader */\n  int iHash;                      /* Used to loop through N hash tables */\n\n  /* This routine is only be called from within a read transaction. */\n  assert( pWal->readLock>=0 || pWal->lockError );\n\n  /* If the \"last page\" field of the wal-index header snapshot is 0, then\n  ** no data will be read from the wal under any circumstances. Return early\n  ** in this case as an optimization.  Likewise, if pWal->readLock==0, \n  ** then the WAL is ignored by the reader so return early, as if the \n  ** WAL were empty.\n  */\n  if( iLast==0 || pWal->readLock==0 ){\n    *piRead = 0;\n    return SQLITE_OK;\n  }\n\n  /* Search the hash table or tables for an entry matching page number\n  ** pgno. Each iteration of the following for() loop searches one\n  ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).\n  **\n  ** This code might run concurrently to the code in walIndexAppend()\n  ** that adds entries to the wal-index (and possibly to this hash \n  ** table). This means the value just read from the hash \n  ** slot (aHash[iKey]) may have been added before or after the \n  ** current read transaction was opened. Values added after the\n  ** read transaction was opened may have been written incorrectly -\n  ** i.e. these slots may contain garbage data. However, we assume\n  ** that any slots written before the current read transaction was\n  ** opened remain unmodified.\n  **\n  ** For the reasons above, the if(...) condition featured in the inner\n  ** loop of the following block is more stringent that would be required \n  ** if we had exclusive access to the hash-table:\n  **\n  **   (aPgno[iFrame]==pgno): \n  **     This condition filters out normal hash-table collisions.\n  **\n  **   (iFrame<=iLast): \n  **     This condition filters out entries that were added to the hash\n  **     table after the current read-transaction had started.\n  */\n  for(iHash=walFramePage(iLast); iHash>=0 && iRead==0; iHash--){\n    volatile ht_slot *aHash;      /* Pointer to hash table */\n    volatile u32 *aPgno;          /* Pointer to array of page numbers */\n    u32 iZero;                    /* Frame number corresponding to aPgno[0] */\n    int iKey;                     /* Hash slot index */\n    int nCollide;                 /* Number of hash collisions remaining */\n    int rc;                       /* Error code */\n\n    rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nCollide = HASHTABLE_NSLOT;\n    for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){\n      u32 iFrame = aHash[iKey] + iZero;\n      if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){\n        /* assert( iFrame>iRead ); -- not true if there is corruption */\n        iRead = iFrame;\n      }\n      if( (nCollide--)==0 ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n    }\n  }\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* If expensive assert() statements are available, do a linear search\n  ** of the wal-index file content. Make sure the results agree with the\n  ** result obtained using the hash indexes above.  */\n  {\n    u32 iRead2 = 0;\n    u32 iTest;\n    for(iTest=iLast; iTest>0; iTest--){\n      if( walFramePgno(pWal, iTest)==pgno ){\n        iRead2 = iTest;\n        break;\n      }\n    }\n    assert( iRead==iRead2 );\n  }\n#endif\n\n  *piRead = iRead;\n  return SQLITE_OK;\n}\n\n/*\n** Read the contents of frame iRead from the wal file into buffer pOut\n** (which is nOut bytes in size). Return SQLITE_OK if successful, or an\n** error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3WalReadFrame(\n  Wal *pWal,                      /* WAL handle */\n  u32 iRead,                      /* Frame to read */\n  int nOut,                       /* Size of buffer pOut in bytes */\n  u8 *pOut                        /* Buffer to write page data to */\n){\n  int sz;\n  i64 iOffset;\n  sz = pWal->hdr.szPage;\n  sz = (sz&0xfe00) + ((sz&0x0001)<<16);\n  testcase( sz<=32768 );\n  testcase( sz>=65536 );\n  iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;\n  /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */\n  return sqlite3OsRead(pWal->pWalFd, pOut, (nOut>sz ? sz : nOut), iOffset);\n}\n\n/* \n** Return the size of the database in pages (or zero, if unknown).\n*/\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal){\n  if( pWal && ALWAYS(pWal->readLock>=0) ){\n    return pWal->hdr.nPage;\n  }\n  return 0;\n}\n\n\n/* \n** This function starts a write transaction on the WAL.\n**\n** A read transaction must have already been started by a prior call\n** to sqlite3WalBeginReadTransaction().\n**\n** If another thread or process has written into the database since\n** the read transaction was started, then it is not possible for this\n** thread to write as doing so would cause a fork.  So this routine\n** returns SQLITE_BUSY in that case and no write transaction is started.\n**\n** There can only be a single writer active at a time.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){\n  int rc;\n\n  /* Cannot start a write transaction without first holding a read\n  ** transaction. */\n  assert( pWal->readLock>=0 );\n\n  if( pWal->readOnly ){\n    return SQLITE_READONLY;\n  }\n\n  /* Only one writer allowed at a time.  Get the write lock.  Return\n  ** SQLITE_BUSY if unable.\n  */\n  rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);\n  if( rc ){\n    return rc;\n  }\n  pWal->writeLock = 1;\n\n  /* If another connection has written to the database file since the\n  ** time the read transaction on this connection was started, then\n  ** the write is disallowed.\n  */\n  if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    rc = SQLITE_BUSY;\n  }\n\n  return rc;\n}\n\n/*\n** End a write transaction.  The commit has already been done.  This\n** routine merely releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){\n  if( pWal->writeLock ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    pWal->truncateOnCommit = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** If any data has been written (but not committed) to the log file, this\n** function moves the write-pointer back to the start of the transaction.\n**\n** Additionally, the callback function is invoked for each frame written\n** to the WAL since the start of the transaction. If the callback returns\n** other than SQLITE_OK, it is not invoked again and the error code is\n** returned to the caller.\n**\n** Otherwise, if the callback function does not return an error, this\n** function returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pWal->writeLock) ){\n    Pgno iMax = pWal->hdr.mxFrame;\n    Pgno iFrame;\n  \n    /* Restore the clients cache of the wal-index header to the state it\n    ** was in before the client began writing to the database. \n    */\n    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));\n\n    for(iFrame=pWal->hdr.mxFrame+1; \n        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; \n        iFrame++\n    ){\n      /* This call cannot fail. Unless the page for which the page number\n      ** is passed as the second argument is (a) in the cache and \n      ** (b) has an outstanding reference, then xUndo is either a no-op\n      ** (if (a) is false) or simply expels the page from the cache (if (b)\n      ** is false).\n      **\n      ** If the upper layer is doing a rollback, it is guaranteed that there\n      ** are no outstanding references to any page other than page 1. And\n      ** page 1 is never written to the log until the transaction is\n      ** committed. As a result, the call to xUndo may not fail.\n      */\n      assert( walFramePgno(pWal, iFrame)!=1 );\n      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));\n    }\n    if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);\n  }\n  assert( rc==SQLITE_OK );\n  return rc;\n}\n\n/* \n** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 \n** values. This function populates the array with values required to \n** \"rollback\" the write position of the WAL handle back to the current \n** point in the event of a savepoint rollback (via WalSavepointUndo()).\n*/\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){\n  assert( pWal->writeLock );\n  aWalData[0] = pWal->hdr.mxFrame;\n  aWalData[1] = pWal->hdr.aFrameCksum[0];\n  aWalData[2] = pWal->hdr.aFrameCksum[1];\n  aWalData[3] = pWal->nCkpt;\n}\n\n/* \n** Move the write position of the WAL back to the point identified by\n** the values in the aWalData[] array. aWalData must point to an array\n** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated\n** by a call to WalSavepoint().\n*/\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){\n  int rc = SQLITE_OK;\n\n  assert( pWal->writeLock );\n  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );\n\n  if( aWalData[3]!=pWal->nCkpt ){\n    /* This savepoint was opened immediately after the write-transaction\n    ** was started. Right after that, the writer decided to wrap around\n    ** to the start of the log. Update the savepoint values to match.\n    */\n    aWalData[0] = 0;\n    aWalData[3] = pWal->nCkpt;\n  }\n\n  if( aWalData[0]<pWal->hdr.mxFrame ){\n    pWal->hdr.mxFrame = aWalData[0];\n    pWal->hdr.aFrameCksum[0] = aWalData[1];\n    pWal->hdr.aFrameCksum[1] = aWalData[2];\n    walCleanupHash(pWal);\n  }\n\n  return rc;\n}\n\n\n/*\n** This function is called just before writing a set of frames to the log\n** file (see sqlite3WalFrames()). It checks to see if, instead of appending\n** to the current log file, it is possible to overwrite the start of the\n** existing log file with the new frames (i.e. \"reset\" the log). If so,\n** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left\n** unchanged.\n**\n** SQLITE_OK is returned if no error is encountered (regardless of whether\n** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned\n** if an error occurs.\n*/\nstatic int walRestartLog(Wal *pWal){\n  int rc = SQLITE_OK;\n  int cnt;\n\n  if( pWal->readLock==0 ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n    if( pInfo->nBackfill>0 ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        /* If all readers are using WAL_READ_LOCK(0) (in other words if no\n        ** readers are currently using the WAL), then the transactions\n        ** frames will overwrite the start of the existing log. Update the\n        ** wal-index header to reflect this.\n        **\n        ** In theory it would be Ok to update the cache of the header only\n        ** at this point. But updating the actual wal-index header is also\n        ** safe and means there is no special case for sqlite3WalUndo()\n        ** to handle if this transaction is rolled back.\n        */\n        int i;                    /* Loop counter */\n        u32 *aSalt = pWal->hdr.aSalt;       /* Big-endian salt values */\n\n        pWal->nCkpt++;\n        pWal->hdr.mxFrame = 0;\n        sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));\n        aSalt[1] = salt1;\n        walIndexWriteHdr(pWal);\n        pInfo->nBackfill = 0;\n        pInfo->aReadMark[1] = 0;\n        for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n        assert( pInfo->aReadMark[0]==0 );\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n    walUnlockShared(pWal, WAL_READ_LOCK(0));\n    pWal->readLock = -1;\n    cnt = 0;\n    do{\n      int notUsed;\n      rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);\n    }while( rc==WAL_RETRY );\n    assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */\n    testcase( (rc&0xff)==SQLITE_IOERR );\n    testcase( rc==SQLITE_PROTOCOL );\n    testcase( rc==SQLITE_OK );\n  }\n  return rc;\n}\n\n/*\n** Information about the current state of the WAL file and where\n** the next fsync should occur - passed from sqlite3WalFrames() into\n** walWriteToLog().\n*/\ntypedef struct WalWriter {\n  Wal *pWal;                   /* The complete WAL information */\n  sqlite3_file *pFd;           /* The WAL file to which we write */\n  sqlite3_int64 iSyncPoint;    /* Fsync at this offset */\n  int syncFlags;               /* Flags for the fsync */\n  int szPage;                  /* Size of one page */\n} WalWriter;\n\n/*\n** Write iAmt bytes of content into the WAL file beginning at iOffset.\n** Do a sync when crossing the p->iSyncPoint boundary.\n**\n** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt,\n** first write the part before iSyncPoint, then sync, then write the\n** rest.\n*/\nstatic int walWriteToLog(\n  WalWriter *p,              /* WAL to write to */\n  void *pContent,            /* Content to be written */\n  int iAmt,                  /* Number of bytes to write */\n  sqlite3_int64 iOffset      /* Start writing at this offset */\n){\n  int rc;\n  if( iOffset<p->iSyncPoint && iOffset+iAmt>=p->iSyncPoint ){\n    int iFirstAmt = (int)(p->iSyncPoint - iOffset);\n    rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);\n    if( rc ) return rc;\n    iOffset += iFirstAmt;\n    iAmt -= iFirstAmt;\n    pContent = (void*)(iFirstAmt + (char*)pContent);\n    assert( p->syncFlags & (SQLITE_SYNC_NORMAL|SQLITE_SYNC_FULL) );\n    rc = sqlite3OsSync(p->pFd, p->syncFlags);\n    if( iAmt==0 || rc ) return rc;\n  }\n  rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);\n  return rc;\n}\n\n/*\n** Write out a single frame of the WAL\n*/\nstatic int walWriteOneFrame(\n  WalWriter *p,               /* Where to write the frame */\n  PgHdr *pPage,               /* The page of the frame to be written */\n  int nTruncate,              /* The commit flag.  Usually 0.  >0 for commit */\n  sqlite3_int64 iOffset       /* Byte offset at which to write */\n){\n  int rc;                         /* Result code from subfunctions */\n  void *pData;                    /* Data actually written */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */\n#if defined(SQLITE_HAS_CODEC)\n  if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM;\n#else\n  pData = pPage->pData;\n#endif\n  walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);\n  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);\n  if( rc ) return rc;\n  /* Write the page data */\n  rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));\n  return rc;\n}\n\n/* \n** Write a set of frames to the log. The caller must hold the write-lock\n** on the log file (obtained using sqlite3WalBeginWriteTransaction()).\n*/\nSQLITE_PRIVATE int sqlite3WalFrames(\n  Wal *pWal,                      /* Wal handle to write to */\n  int szPage,                     /* Database page-size in bytes */\n  PgHdr *pList,                   /* List of dirty pages to write */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit,                   /* True if this is a commit */\n  int sync_flags                  /* Flags to pass to OsSync() (or 0) */\n){\n  int rc;                         /* Used to catch return codes */\n  u32 iFrame;                     /* Next frame address */\n  PgHdr *p;                       /* Iterator to run through pList with. */\n  PgHdr *pLast = 0;               /* Last frame in list */\n  int nExtra = 0;                 /* Number of extra copies of last page */\n  int szFrame;                    /* The size of a single frame */\n  i64 iOffset;                    /* Next byte to write in WAL file */\n  WalWriter w;                    /* The writer */\n\n  assert( pList );\n  assert( pWal->writeLock );\n\n  /* If this frame set completes a transaction, then nTruncate>0.  If\n  ** nTruncate==0 then this frame set does not complete the transaction. */\n  assert( (isCommit!=0)==(nTruncate!=0) );\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}\n    WALTRACE((\"WAL%p: frame write begin. %d frames. mxFrame=%d. %s\\n\",\n              pWal, cnt, pWal->hdr.mxFrame, isCommit ? \"Commit\" : \"Spill\"));\n  }\n#endif\n\n  /* See if it is possible to write these frames into the start of the\n  ** log file, instead of appending to it at pWal->hdr.mxFrame.\n  */\n  if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){\n    return rc;\n  }\n\n  /* If this is the first frame written into the log, write the WAL\n  ** header to the start of the WAL file. See comments at the top of\n  ** this source file for a description of the WAL header format.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  if( iFrame==0 ){\n    u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */\n    u32 aCksum[2];                /* Checksum for wal-header */\n\n    sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));\n    sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);\n    sqlite3Put4byte(&aWalHdr[8], szPage);\n    sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);\n    if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);\n    memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);\n    walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);\n    sqlite3Put4byte(&aWalHdr[24], aCksum[0]);\n    sqlite3Put4byte(&aWalHdr[28], aCksum[1]);\n    \n    pWal->szPage = szPage;\n    pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;\n    pWal->hdr.aFrameCksum[0] = aCksum[0];\n    pWal->hdr.aFrameCksum[1] = aCksum[1];\n    pWal->truncateOnCommit = 1;\n\n    rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);\n    WALTRACE((\"WAL%p: wal-header write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless\n    ** all syncing is turned off by PRAGMA synchronous=OFF).  Otherwise\n    ** an out-of-order write following a WAL restart could result in\n    ** database corruption.  See the ticket:\n    **\n    **     http://localhost:591/sqlite/info/ff5be73dee\n    */\n    if( pWal->syncHeader && sync_flags ){\n      rc = sqlite3OsSync(pWal->pWalFd, sync_flags & SQLITE_SYNC_MASK);\n      if( rc ) return rc;\n    }\n  }\n  assert( (int)pWal->szPage==szPage );\n\n  /* Setup information needed to write frames into the WAL */\n  w.pWal = pWal;\n  w.pFd = pWal->pWalFd;\n  w.iSyncPoint = 0;\n  w.syncFlags = sync_flags;\n  w.szPage = szPage;\n  iOffset = walFrameOffset(iFrame+1, szPage);\n  szFrame = szPage + WAL_FRAME_HDRSIZE;\n\n  /* Write all frames into the log file exactly once */\n  for(p=pList; p; p=p->pDirty){\n    int nDbSize;   /* 0 normally.  Positive == commit flag */\n    iFrame++;\n    assert( iOffset==walFrameOffset(iFrame, szPage) );\n    nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0;\n    rc = walWriteOneFrame(&w, p, nDbSize, iOffset);\n    if( rc ) return rc;\n    pLast = p;\n    iOffset += szFrame;\n  }\n\n  /* If this is the end of a transaction, then we might need to pad\n  ** the transaction and/or sync the WAL file.\n  **\n  ** Padding and syncing only occur if this set of frames complete a\n  ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL\n  ** or synchonous==OFF, then no padding or syncing are needed.\n  **\n  ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not\n  ** needed and only the sync is done.  If padding is needed, then the\n  ** final frame is repeated (with its commit mark) until the next sector\n  ** boundary is crossed.  Only the part of the WAL prior to the last\n  ** sector boundary is synced; the part of the last frame that extends\n  ** past the sector boundary is written after the sync.\n  */\n  if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){\n    if( pWal->padToSectorBoundary ){\n      int sectorSize = sqlite3SectorSize(pWal->pWalFd);\n      w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;\n      while( iOffset<w.iSyncPoint ){\n        rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);\n        if( rc ) return rc;\n        iOffset += szFrame;\n        nExtra++;\n      }\n    }else{\n      rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK);\n    }\n  }\n\n  /* If this frame set completes the first transaction in the WAL and\n  ** if PRAGMA journal_size_limit is set, then truncate the WAL to the\n  ** journal size limit, if possible.\n  */\n  if( isCommit && pWal->truncateOnCommit && pWal->mxWalSize>=0 ){\n    i64 sz = pWal->mxWalSize;\n    if( walFrameOffset(iFrame+nExtra+1, szPage)>pWal->mxWalSize ){\n      sz = walFrameOffset(iFrame+nExtra+1, szPage);\n    }\n    walLimitSize(pWal, sz);\n    pWal->truncateOnCommit = 0;\n  }\n\n  /* Append data to the wal-index. It is not necessary to lock the \n  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index\n  ** guarantees that there are no other writers, and no data that may\n  ** be in use by existing readers is being overwritten.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){\n    iFrame++;\n    rc = walIndexAppend(pWal, iFrame, p->pgno);\n  }\n  while( rc==SQLITE_OK && nExtra>0 ){\n    iFrame++;\n    nExtra--;\n    rc = walIndexAppend(pWal, iFrame, pLast->pgno);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* Update the private copy of the header. */\n    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n    testcase( szPage<=32768 );\n    testcase( szPage>=65536 );\n    pWal->hdr.mxFrame = iFrame;\n    if( isCommit ){\n      pWal->hdr.iChange++;\n      pWal->hdr.nPage = nTruncate;\n    }\n    /* If this is a commit, update the wal-index header too. */\n    if( isCommit ){\n      walIndexWriteHdr(pWal);\n      pWal->iCallback = iFrame;\n    }\n  }\n\n  WALTRACE((\"WAL%p: frame write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return rc;\n}\n\n/* \n** This routine is called to implement sqlite3_wal_checkpoint() and\n** related interfaces.\n**\n** Obtain a CHECKPOINT lock and then backfill as much information as\n** we can from WAL into the database.\n**\n** If parameter xBusy is not NULL, it is a pointer to a busy-handler\n** callback. In this case this function runs a blocking checkpoint.\n*/\nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  int eMode,                      /* PASSIVE, FULL or RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of temporary buffer */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n){\n  int rc;                         /* Return code */\n  int isChanged = 0;              /* True if a new wal-index header is loaded */\n  int eMode2 = eMode;             /* Mode to pass to walCheckpoint() */\n\n  assert( pWal->ckptLock==0 );\n  assert( pWal->writeLock==0 );\n\n  if( pWal->readOnly ) return SQLITE_READONLY;\n  WALTRACE((\"WAL%p: checkpoint begins\\n\", pWal));\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc ){\n    /* Usually this is SQLITE_BUSY meaning that another thread or process\n    ** is already running a checkpoint, or maybe a recovery.  But it might\n    ** also be SQLITE_IOERR. */\n    return rc;\n  }\n  pWal->ckptLock = 1;\n\n  /* If this is a blocking-checkpoint, then obtain the write-lock as well\n  ** to prevent any writers from running while the checkpoint is underway.\n  ** This has to be done before the call to walIndexReadHdr() below.\n  **\n  ** If the writer lock cannot be obtained, then a passive checkpoint is\n  ** run instead. Since the checkpointer is not holding the writer lock,\n  ** there is no point in blocking waiting for any readers. Assuming no \n  ** other error occurs, this function will return SQLITE_BUSY to the caller.\n  */\n  if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);\n    if( rc==SQLITE_OK ){\n      pWal->writeLock = 1;\n    }else if( rc==SQLITE_BUSY ){\n      eMode2 = SQLITE_CHECKPOINT_PASSIVE;\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* Read the wal-index header. */\n  if( rc==SQLITE_OK ){\n    rc = walIndexReadHdr(pWal, &isChanged);\n    if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){\n      sqlite3OsUnfetch(pWal->pDbFd, 0, 0);\n    }\n  }\n\n  /* Copy data from the log to the database file. */\n  if( rc==SQLITE_OK ){\n    if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = walCheckpoint(pWal, eMode2, xBusy, pBusyArg, sync_flags, zBuf);\n    }\n\n    /* If no error occurred, set the output variables. */\n    if( rc==SQLITE_OK || rc==SQLITE_BUSY ){\n      if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;\n      if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);\n    }\n  }\n\n  if( isChanged ){\n    /* If a new wal-index header was loaded before the checkpoint was \n    ** performed, then the pager-cache associated with pWal is now\n    ** out of date. So zero the cached wal-index header to ensure that\n    ** next time the pager opens a snapshot on this database it knows that\n    ** the cache needs to be reset.\n    */\n    memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n  }\n\n  /* Release the locks. */\n  sqlite3WalEndWriteTransaction(pWal);\n  walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  pWal->ckptLock = 0;\n  WALTRACE((\"WAL%p: checkpoint %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return (rc==SQLITE_OK && eMode!=eMode2 ? SQLITE_BUSY : rc);\n}\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal){\n  u32 ret = 0;\n  if( pWal ){\n    ret = pWal->iCallback;\n    pWal->iCallback = 0;\n  }\n  return (int)ret;\n}\n\n/*\n** This function is called to change the WAL subsystem into or out\n** of locking_mode=EXCLUSIVE.\n**\n** If op is zero, then attempt to change from locking_mode=EXCLUSIVE\n** into locking_mode=NORMAL.  This means that we must acquire a lock\n** on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL\n** or if the acquisition of the lock fails, then return 0.  If the\n** transition out of exclusive-mode is successful, return 1.  This\n** operation must occur while the pager is still holding the exclusive\n** lock on the main database file.\n**\n** If op is one, then change from locking_mode=NORMAL into \n** locking_mode=EXCLUSIVE.  This means that the pWal->readLock must\n** be released.  Return 1 if the transition is made and 0 if the\n** WAL is already in exclusive-locking mode - meaning that this\n** routine is a no-op.  The pager must already hold the exclusive lock\n** on the main database file before invoking this operation.\n**\n** If op is negative, then do a dry-run of the op==1 case but do\n** not actually change anything. The pager uses this to see if it\n** should acquire the database exclusive lock prior to invoking\n** the op==1 case.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){\n  int rc;\n  assert( pWal->writeLock==0 );\n  assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 );\n\n  /* pWal->readLock is usually set, but might be -1 if there was a \n  ** prior error while attempting to acquire are read-lock. This cannot \n  ** happen if the connection is actually in exclusive mode (as no xShmLock\n  ** locks are taken in this case). Nor should the pager attempt to\n  ** upgrade to exclusive-mode following such an error.\n  */\n  assert( pWal->readLock>=0 || pWal->lockError );\n  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );\n\n  if( op==0 ){\n    if( pWal->exclusiveMode ){\n      pWal->exclusiveMode = 0;\n      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){\n        pWal->exclusiveMode = 1;\n      }\n      rc = pWal->exclusiveMode==0;\n    }else{\n      /* Already in locking_mode=NORMAL */\n      rc = 0;\n    }\n  }else if( op>0 ){\n    assert( pWal->exclusiveMode==0 );\n    assert( pWal->readLock>=0 );\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->exclusiveMode = 1;\n    rc = 1;\n  }else{\n    rc = pWal->exclusiveMode==0;\n  }\n  return rc;\n}\n\n/* \n** Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal){\n  return (pWal && pWal->exclusiveMode==WAL_HEAPMEMORY_MODE );\n}\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** If the argument is not NULL, it points to a Wal object that holds a\n** read-lock. This function returns the database page-size if it is known,\n** or zero if it is not (or if pWal is NULL).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal){\n  assert( pWal==0 || pWal->readLock>=0 );\n  return (pWal ? pWal->szPage : 0);\n}\n#endif\n\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/************** End of wal.c *************************************************/\n/************** Begin file btmutex.c *****************************************/\n/*\n** 2007 August 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement mutexes on Btree objects.\n** This code really belongs in btree.c.  But btree.c is getting too\n** big and we want to break it down some.  This packaged seemed like\n** a good breakout.\n*/\n/************** Include btreeInt.h in the middle of btmutex.c ****************/\n/************** Begin file btreeInt.h ****************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a external (disk-based) database using BTrees.\n** For a detailed discussion of BTrees, refer to\n**\n**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:\n**     \"Sorting And Searching\", pages 473-480. Addison-Wesley\n**     Publishing Company, Reading, Massachusetts.\n**\n** The basic idea is that each page of the file contains N database\n** entries and N+1 pointers to subpages.\n**\n**   ----------------------------------------------------------------\n**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |\n**   ----------------------------------------------------------------\n**\n** All of the keys on the page that Ptr(0) points to have values less\n** than Key(0).  All of the keys on page Ptr(1) and its subpages have\n** values greater than Key(0) and less than Key(1).  All of the keys\n** on Ptr(N) and its subpages have values greater than Key(N-1).  And\n** so forth.\n**\n** Finding a particular key requires reading O(log(M)) pages from the \n** disk where M is the number of entries in the tree.\n**\n** In this implementation, a single file can hold one or more separate \n** BTrees.  Each BTree is identified by the index of its root page.  The\n** key and data for any entry are combined to form the \"payload\".  A\n** fixed amount of payload can be carried directly on the database\n** page.  If the payload is larger than the preset amount then surplus\n** bytes are stored on overflow pages.  The payload for an entry\n** and the preceding pointer are combined to form a \"Cell\".  Each \n** page has a small header which contains the Ptr(N) pointer and other\n** information such as the size of key and data.\n**\n** FORMAT DETAILS\n**\n** The file is divided into pages.  The first page is called page 1,\n** the second is page 2, and so forth.  A page number of zero indicates\n** \"no such page\".  The page size can be any power of 2 between 512 and 65536.\n** Each page can be either a btree page, a freelist page, an overflow\n** page, or a pointer-map page.\n**\n** The first page is always a btree page.  The first 100 bytes of the first\n** page contain a special header (the \"file header\") that describes the file.\n** The format of the file header is as follows:\n**\n**   OFFSET   SIZE    DESCRIPTION\n**      0      16     Header string: \"SQLite format 3\\000\"\n**     16       2     Page size in bytes.  \n**     18       1     File format write version\n**     19       1     File format read version\n**     20       1     Bytes of unused space at the end of each page\n**     21       1     Max embedded payload fraction\n**     22       1     Min embedded payload fraction\n**     23       1     Min leaf payload fraction\n**     24       4     File change counter\n**     28       4     Reserved for future use\n**     32       4     First freelist page\n**     36       4     Number of freelist pages in the file\n**     40      60     15 4-byte meta values passed to higher layers\n**\n**     40       4     Schema cookie\n**     44       4     File format of schema layer\n**     48       4     Size of page cache\n**     52       4     Largest root-page (auto/incr_vacuum)\n**     56       4     1=UTF-8 2=UTF16le 3=UTF16be\n**     60       4     User version\n**     64       4     Incremental vacuum mode\n**     68       4     unused\n**     72       4     unused\n**     76       4     unused\n**\n** All of the integer values are big-endian (most significant byte first).\n**\n** The file change counter is incremented when the database is changed\n** This counter allows other processes to know when the file has changed\n** and thus when they need to flush their cache.\n**\n** The max embedded payload fraction is the amount of the total usable\n** space in a page that can be consumed by a single cell for standard\n** B-tree (non-LEAFDATA) tables.  A value of 255 means 100%.  The default\n** is to limit the maximum cell size so that at least 4 cells will fit\n** on one page.  Thus the default max embedded payload fraction is 64.\n**\n** If the payload for a cell is larger than the max payload, then extra\n** payload is spilled to overflow pages.  Once an overflow page is allocated,\n** as many bytes as possible are moved into the overflow pages without letting\n** the cell size drop below the min embedded payload fraction.\n**\n** The min leaf payload fraction is like the min embedded payload fraction\n** except that it applies to leaf nodes in a LEAFDATA tree.  The maximum\n** payload fraction for a LEAFDATA tree is always 100% (or 255) and it\n** not specified in the header.\n**\n** Each btree pages is divided into three sections:  The header, the\n** cell pointer array, and the cell content area.  Page 1 also has a 100-byte\n** file header that occurs before the page header.\n**\n**      |----------------|\n**      | file header    |   100 bytes.  Page 1 only.\n**      |----------------|\n**      | page header    |   8 bytes for leaves.  12 bytes for interior nodes\n**      |----------------|\n**      | cell pointer   |   |  2 bytes per cell.  Sorted order.\n**      | array          |   |  Grows downward\n**      |                |   v\n**      |----------------|\n**      | unallocated    |\n**      | space          |\n**      |----------------|   ^  Grows upwards\n**      | cell content   |   |  Arbitrary order interspersed with freeblocks.\n**      | area           |   |  and free space fragments.\n**      |----------------|\n**\n** The page headers looks like this:\n**\n**   OFFSET   SIZE     DESCRIPTION\n**      0       1      Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf\n**      1       2      byte offset to the first freeblock\n**      3       2      number of cells on this page\n**      5       2      first byte of the cell content area\n**      7       1      number of fragmented free bytes\n**      8       4      Right child (the Ptr(N) value).  Omitted on leaves.\n**\n** The flags define the format of this btree page.  The leaf flag means that\n** this page has no children.  The zerodata flag means that this page carries\n** only keys and no data.  The intkey flag means that the key is a integer\n** which is stored in the key size entry of the cell header rather than in\n** the payload area.\n**\n** The cell pointer array begins on the first byte after the page header.\n** The cell pointer array contains zero or more 2-byte numbers which are\n** offsets from the beginning of the page to the cell content in the cell\n** content area.  The cell pointers occur in sorted order.  The system strives\n** to keep free space after the last cell pointer so that new cells can\n** be easily added without having to defragment the page.\n**\n** Cell content is stored at the very end of the page and grows toward the\n** beginning of the page.\n**\n** Unused space within the cell content area is collected into a linked list of\n** freeblocks.  Each freeblock is at least 4 bytes in size.  The byte offset\n** to the first freeblock is given in the header.  Freeblocks occur in\n** increasing order.  Because a freeblock must be at least 4 bytes in size,\n** any group of 3 or fewer unused bytes in the cell content area cannot\n** exist on the freeblock chain.  A group of 3 or fewer free bytes is called\n** a fragment.  The total number of bytes in all fragments is recorded.\n** in the page header at offset 7.\n**\n**    SIZE    DESCRIPTION\n**      2     Byte offset of the next freeblock\n**      2     Bytes in this freeblock\n**\n** Cells are of variable length.  Cells are stored in the cell content area at\n** the end of the page.  Pointers to the cells are in the cell pointer array\n** that immediately follows the page header.  Cells is not necessarily\n** contiguous or in order, but cell pointers are contiguous and in order.\n**\n** Cell content makes use of variable length integers.  A variable\n** length integer is 1 to 9 bytes where the lower 7 bits of each \n** byte are used.  The integer consists of all bytes that have bit 8 set and\n** the first byte with bit 8 clear.  The most significant byte of the integer\n** appears first.  A variable-length integer may not be more than 9 bytes long.\n** As a special case, all 8 bytes of the 9th byte are used as data.  This\n** allows a 64-bit integer to be encoded in 9 bytes.\n**\n**    0x00                      becomes  0x00000000\n**    0x7f                      becomes  0x0000007f\n**    0x81 0x00                 becomes  0x00000080\n**    0x82 0x00                 becomes  0x00000100\n**    0x80 0x7f                 becomes  0x0000007f\n**    0x8a 0x91 0xd1 0xac 0x78  becomes  0x12345678\n**    0x81 0x81 0x81 0x81 0x01  becomes  0x10204081\n**\n** Variable length integers are used for rowids and to hold the number of\n** bytes of key and data in a btree cell.\n**\n** The content of a cell looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of the left child. Omitted if leaf flag is set.\n**     var    Number of bytes of data. Omitted if the zerodata flag is set.\n**     var    Number of bytes of key. Or the key itself if intkey flag is set.\n**      *     Payload\n**      4     First page of the overflow chain.  Omitted if no overflow\n**\n** Overflow pages form a linked list.  Each page except the last is completely\n** filled with data (pagesize - 4 bytes).  The last page can have as little\n** as 1 byte of data.\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next overflow page\n**      *     Data\n**\n** Freelist pages come in two subtypes: trunk pages and leaf pages.  The\n** file header points to the first in a linked list of trunk page.  Each trunk\n** page points to multiple leaf pages.  The content of a leaf page is\n** unspecified.  A trunk page looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next trunk page\n**      4     Number of leaf pointers on this page\n**      *     zero or more pages numbers of leaves\n*/\n\n\n/* The following value is the maximum cell size assuming a maximum page\n** size give above.\n*/\n#define MX_CELL_SIZE(pBt)  ((int)(pBt->pageSize-8))\n\n/* The maximum number of cells on a single page of the database.  This\n** assumes a minimum cell size of 6 bytes  (4 bytes for the cell itself\n** plus 2 bytes for the index to the cell in the page header).  Such\n** small cells will be rare, but they are possible.\n*/\n#define MX_CELL(pBt) ((pBt->pageSize-8)/6)\n\n/* Forward declarations */\ntypedef struct MemPage MemPage;\ntypedef struct BtLock BtLock;\n\n/*\n** This is a magic string that appears at the beginning of every\n** SQLite database in order to identify the file as a real database.\n**\n** You can change this value at compile-time by specifying a\n** -DSQLITE_FILE_HEADER=\"...\" on the compiler command-line.  The\n** header must be exactly 16 bytes including the zero-terminator so\n** the string itself should be 15 characters long.  If you change\n** the header, then your custom library will not be able to read \n** databases generated by the standard tools and the standard tools\n** will not be able to read databases created by your custom library.\n*/\n#ifndef SQLITE_FILE_HEADER /* 123456789 123456 */\n#  define SQLITE_FILE_HEADER \"SQLite format 3\"\n#endif\n\n/*\n** Page type flags.  An ORed combination of these flags appear as the\n** first byte of on-disk image of every BTree page.\n*/\n#define PTF_INTKEY    0x01\n#define PTF_ZERODATA  0x02\n#define PTF_LEAFDATA  0x04\n#define PTF_LEAF      0x08\n\n/*\n** As each page of the file is loaded into memory, an instance of the following\n** structure is appended and initialized to zero.  This structure stores\n** information about the page that is decoded from the raw file page.\n**\n** The pParent field points back to the parent page.  This allows us to\n** walk up the BTree from any leaf to the root.  Care must be taken to\n** unref() the parent page pointer when this page is no longer referenced.\n** The pageDestructor() routine handles that chore.\n**\n** Access to all fields of this structure is controlled by the mutex\n** stored in MemPage.pBt->mutex.\n*/\nstruct MemPage {\n  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */\n  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */\n  u8 intKey;           /* True if intkey flag is set */\n  u8 leaf;             /* True if leaf flag is set */\n  u8 hasData;          /* True if this page stores data */\n  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */\n  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */\n  u8 max1bytePayload;  /* min(maxLocal,127) */\n  u16 maxLocal;        /* Copy of BtShared.maxLocal or BtShared.maxLeaf */\n  u16 minLocal;        /* Copy of BtShared.minLocal or BtShared.minLeaf */\n  u16 cellOffset;      /* Index in aData of first cell pointer */\n  u16 nFree;           /* Number of free bytes on the page */\n  u16 nCell;           /* Number of cells on this page, local and ovfl */\n  u16 maskPage;        /* Mask for page offset */\n  u16 aiOvfl[5];       /* Insert the i-th overflow cell before the aiOvfl-th\n                       ** non-overflow cell */\n  u8 *apOvfl[5];       /* Pointers to the body of overflow cells */\n  BtShared *pBt;       /* Pointer to BtShared that this page is part of */\n  u8 *aData;           /* Pointer to disk image of the page data */\n  u8 *aDataEnd;        /* One byte past the end of usable data */\n  u8 *aCellIdx;        /* The cell index area */\n  DbPage *pDbPage;     /* Pager page handle */\n  Pgno pgno;           /* Page number for this page */\n};\n\n/*\n** The in-memory image of a disk page has the auxiliary information appended\n** to the end.  EXTRA_SIZE is the number of bytes of space needed to hold\n** that extra information.\n*/\n#define EXTRA_SIZE sizeof(MemPage)\n\n/*\n** A linked list of the following structures is stored at BtShared.pLock.\n** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor \n** is opened on the table with root page BtShared.iTable. Locks are removed\n** from this list when a transaction is committed or rolled back, or when\n** a btree handle is closed.\n*/\nstruct BtLock {\n  Btree *pBtree;        /* Btree handle holding this lock */\n  Pgno iTable;          /* Root page of table */\n  u8 eLock;             /* READ_LOCK or WRITE_LOCK */\n  BtLock *pNext;        /* Next in BtShared.pLock list */\n};\n\n/* Candidate values for BtLock.eLock */\n#define READ_LOCK     1\n#define WRITE_LOCK    2\n\n/* A Btree handle\n**\n** A database connection contains a pointer to an instance of\n** this object for every database file that it has open.  This structure\n** is opaque to the database connection.  The database connection cannot\n** see the internals of this structure and only deals with pointers to\n** this structure.\n**\n** For some database files, the same underlying database cache might be \n** shared between multiple connections.  In that case, each connection\n** has it own instance of this object.  But each instance of this object\n** points to the same BtShared object.  The database cache and the\n** schema associated with the database file are all contained within\n** the BtShared object.\n**\n** All fields in this structure are accessed under sqlite3.mutex.\n** The pBt pointer itself may not be changed while there exists cursors \n** in the referenced BtShared that point back to this Btree since those\n** cursors have to go through this Btree to find their BtShared and\n** they often do so without holding sqlite3.mutex.\n*/\nstruct Btree {\n  sqlite3 *db;       /* The database connection holding this btree */\n  BtShared *pBt;     /* Sharable content of this btree */\n  u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */\n  u8 sharable;       /* True if we can share pBt with another db */\n  u8 locked;         /* True if db currently has pBt locked */\n  int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */\n  int nBackup;       /* Number of backup operations reading this btree */\n  Btree *pNext;      /* List of other sharable Btrees from the same db */\n  Btree *pPrev;      /* Back pointer of the same list */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  BtLock lock;       /* Object used to lock page 1 */\n#endif\n};\n\n/*\n** Btree.inTrans may take one of the following values.\n**\n** If the shared-data extension is enabled, there may be multiple users\n** of the Btree structure. At most one of these may open a write transaction,\n** but any number may have active read transactions.\n*/\n#define TRANS_NONE  0\n#define TRANS_READ  1\n#define TRANS_WRITE 2\n\n/*\n** An instance of this object represents a single database file.\n** \n** A single database file can be in use at the same time by two\n** or more database connections.  When two or more connections are\n** sharing the same database file, each connection has it own\n** private Btree object for the file and each of those Btrees points\n** to this one BtShared object.  BtShared.nRef is the number of\n** connections currently sharing this database file.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** mutex, except for nRef and pNext which are accessed under the\n** global SQLITE_MUTEX_STATIC_MASTER mutex.  The pPager field\n** may not be modified once it is initially set as long as nRef>0.\n** The pSchema field may be set once under BtShared.mutex and\n** thereafter is unchanged as long as nRef>0.\n**\n** isPending:\n**\n**   If a BtShared client fails to obtain a write-lock on a database\n**   table (because there exists one or more read-locks on the table),\n**   the shared-cache enters 'pending-lock' state and isPending is\n**   set to true.\n**\n**   The shared-cache leaves the 'pending lock' state when either of\n**   the following occur:\n**\n**     1) The current writer (BtShared.pWriter) concludes its transaction, OR\n**     2) The number of locks held by other connections drops to zero.\n**\n**   while in the 'pending-lock' state, no connection may start a new\n**   transaction.\n**\n**   This feature is included to help prevent writer-starvation.\n*/\nstruct BtShared {\n  Pager *pPager;        /* The page cache */\n  sqlite3 *db;          /* Database connection currently using this Btree */\n  BtCursor *pCursor;    /* A list of all open cursors */\n  MemPage *pPage1;      /* First page of the database */\n  u8 openFlags;         /* Flags to sqlite3BtreeOpen() */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  u8 autoVacuum;        /* True if auto-vacuum is enabled */\n  u8 incrVacuum;        /* True if incr-vacuum is enabled */\n  u8 bDoTruncate;       /* True to truncate db on commit */\n#endif\n  u8 inTransaction;     /* Transaction state */\n  u8 max1bytePayload;   /* Maximum first byte of cell for a 1-byte payload */\n  u16 btsFlags;         /* Boolean parameters.  See BTS_* macros below */\n  u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */\n  u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */\n  u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */\n  u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */\n  u32 pageSize;         /* Total number of bytes on a page */\n  u32 usableSize;       /* Number of usable bytes on each page */\n  int nTransaction;     /* Number of open transactions (read + write) */\n  u32 nPage;            /* Number of pages in the database */\n  void *pSchema;        /* Pointer to space allocated by sqlite3BtreeSchema() */\n  void (*xFreeSchema)(void*);  /* Destructor for BtShared.pSchema */\n  sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */\n  Bitvec *pHasContent;  /* Set of pages moved to free-list this transaction */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nRef;             /* Number of references to this structure */\n  BtShared *pNext;      /* Next on a list of sharable BtShared structs */\n  BtLock *pLock;        /* List of locks held on this shared-btree struct */\n  Btree *pWriter;       /* Btree with currently open write transaction */\n#endif\n  u8 *pTmpSpace;        /* BtShared.pageSize bytes of space for tmp use */\n};\n\n/*\n** Allowed values for BtShared.btsFlags\n*/\n#define BTS_READ_ONLY        0x0001   /* Underlying file is readonly */\n#define BTS_PAGESIZE_FIXED   0x0002   /* Page size can no longer be changed */\n#define BTS_SECURE_DELETE    0x0004   /* PRAGMA secure_delete is enabled */\n#define BTS_INITIALLY_EMPTY  0x0008   /* Database was empty at trans start */\n#define BTS_NO_WAL           0x0010   /* Do not open write-ahead-log files */\n#define BTS_EXCLUSIVE        0x0020   /* pWriter has an exclusive lock */\n#define BTS_PENDING          0x0040   /* Waiting for read-locks to clear */\n\n/*\n** An instance of the following structure is used to hold information\n** about a cell.  The parseCellPtr() function fills in this structure\n** based on information extract from the raw disk page.\n*/\ntypedef struct CellInfo CellInfo;\nstruct CellInfo {\n  i64 nKey;      /* The key for INTKEY tables, or number of bytes in key */\n  u8 *pCell;     /* Pointer to the start of cell content */\n  u32 nData;     /* Number of bytes of data */\n  u32 nPayload;  /* Total amount of payload */\n  u16 nHeader;   /* Size of the cell content header in bytes */\n  u16 nLocal;    /* Amount of payload held locally */\n  u16 iOverflow; /* Offset to overflow page number.  Zero if no overflow */\n  u16 nSize;     /* Size of the cell content on the main b-tree page */\n};\n\n/*\n** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than\n** this will be declared corrupt. This value is calculated based on a\n** maximum database size of 2^31 pages a minimum fanout of 2 for a\n** root-node and 3 for all other internal nodes.\n**\n** If a tree that appears to be taller than this is encountered, it is\n** assumed that the database is corrupt.\n*/\n#define BTCURSOR_MAX_DEPTH 20\n\n/*\n** A cursor is a pointer to a particular entry within a particular\n** b-tree within a database file.\n**\n** The entry is identified by its MemPage and the index in\n** MemPage.aCell[] of the entry.\n**\n** A single database file can be shared by two more database connections,\n** but cursors cannot be shared.  Each cursor is associated with a\n** particular database connection identified BtCursor.pBtree.db.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** found at self->pBt->mutex. \n*/\nstruct BtCursor {\n  Btree *pBtree;            /* The Btree to which this cursor belongs */\n  BtShared *pBt;            /* The BtShared this cursor points to */\n  BtCursor *pNext, *pPrev;  /* Forms a linked list of all cursors */\n  struct KeyInfo *pKeyInfo; /* Argument passed to comparison function */\n#ifndef SQLITE_OMIT_INCRBLOB\n  Pgno *aOverflow;          /* Cache of overflow page locations */\n#endif\n  Pgno pgnoRoot;            /* The root page of this tree */\n  sqlite3_int64 cachedRowid; /* Next rowid cache.  0 means not valid */\n  CellInfo info;            /* A parse of the cell we are pointing at */\n  i64 nKey;        /* Size of pKey, or last integer key */\n  void *pKey;      /* Saved key that was cursor's last known position */\n  int skipNext;    /* Prev() is noop if negative. Next() is noop if positive */\n  u8 wrFlag;                /* True if writable */\n  u8 atLast;                /* Cursor pointing to the last entry */\n  u8 validNKey;             /* True if info.nKey is valid */\n  u8 eState;                /* One of the CURSOR_XXX constants (see below) */\n#ifndef SQLITE_OMIT_INCRBLOB\n  u8 isIncrblobHandle;      /* True if this cursor is an incr. io handle */\n#endif\n  u8 hints;                             /* As configured by CursorSetHints() */\n  i16 iPage;                            /* Index of current page in apPage */\n  u16 aiIdx[BTCURSOR_MAX_DEPTH];        /* Current index in apPage[i] */\n  MemPage *apPage[BTCURSOR_MAX_DEPTH];  /* Pages from root to current page */\n};\n\n/*\n** Potential values for BtCursor.eState.\n**\n** CURSOR_VALID:\n**   Cursor points to a valid entry. getPayload() etc. may be called.\n**\n** CURSOR_INVALID:\n**   Cursor does not point to a valid entry. This can happen (for example) \n**   because the table is empty or because BtreeCursorFirst() has not been\n**   called.\n**\n** CURSOR_REQUIRESEEK:\n**   The table that this cursor was opened on still exists, but has been \n**   modified since the cursor was last used. The cursor position is saved\n**   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in \n**   this state, restoreCursorPosition() can be called to attempt to\n**   seek the cursor to the saved position.\n**\n** CURSOR_FAULT:\n**   A unrecoverable error (an I/O error or a malloc failure) has occurred\n**   on a different connection that shares the BtShared cache with this\n**   cursor.  The error has left the cache in an inconsistent state.\n**   Do nothing else with this cursor.  Any attempt to use the cursor\n**   should return the error code stored in BtCursor.skip\n*/\n#define CURSOR_INVALID           0\n#define CURSOR_VALID             1\n#define CURSOR_REQUIRESEEK       2\n#define CURSOR_FAULT             3\n\n/* \n** The database page the PENDING_BYTE occupies. This page is never used.\n*/\n# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)\n\n/*\n** These macros define the location of the pointer-map entry for a \n** database page. The first argument to each is the number of usable\n** bytes on each page of the database (often 1024). The second is the\n** page number to look up in the pointer map.\n**\n** PTRMAP_PAGENO returns the database page number of the pointer-map\n** page that stores the required pointer. PTRMAP_PTROFFSET returns\n** the offset of the requested map entry.\n**\n** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,\n** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be\n** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements\n** this test.\n*/\n#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)\n#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1))\n#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno))\n\n/*\n** The pointer map is a lookup table that identifies the parent page for\n** each child page in the database file.  The parent page is the page that\n** contains a pointer to the child.  Every page in the database contains\n** 0 or 1 parent pages.  (In this context 'database page' refers\n** to any page that is not part of the pointer map itself.)  Each pointer map\n** entry consists of a single byte 'type' and a 4 byte parent page number.\n** The PTRMAP_XXX identifiers below are the valid types.\n**\n** The purpose of the pointer map is to facility moving pages from one\n** position in the file to another as part of autovacuum.  When a page\n** is moved, the pointer in its parent must be updated to point to the\n** new location.  The pointer map is used to locate the parent page quickly.\n**\n** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not\n**                  used in this case.\n**\n** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number \n**                  is not used in this case.\n**\n** PTRMAP_OVERFLOW1: The database page is the first page in a list of \n**                   overflow pages. The page number identifies the page that\n**                   contains the cell with a pointer to this overflow page.\n**\n** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of\n**                   overflow pages. The page-number identifies the previous\n**                   page in the overflow page list.\n**\n** PTRMAP_BTREE: The database page is a non-root btree page. The page number\n**               identifies the parent page in the btree.\n*/\n#define PTRMAP_ROOTPAGE 1\n#define PTRMAP_FREEPAGE 2\n#define PTRMAP_OVERFLOW1 3\n#define PTRMAP_OVERFLOW2 4\n#define PTRMAP_BTREE 5\n\n/* A bunch of assert() statements to check the transaction state variables\n** of handle p (type Btree*) are internally consistent.\n*/\n#define btreeIntegrity(p) \\\n  assert( p->pBt->inTransaction!=TRANS_NONE || p->pBt->nTransaction==0 ); \\\n  assert( p->pBt->inTransaction>=p->inTrans ); \n\n\n/*\n** The ISAUTOVACUUM macro is used within balance_nonroot() to determine\n** if the database supports auto-vacuum or not. Because it is used\n** within an expression that is an argument to another macro \n** (sqliteMallocRaw), it is not possible to use conditional compilation.\n** So, this macro is defined instead.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define ISAUTOVACUUM (pBt->autoVacuum)\n#else\n#define ISAUTOVACUUM 0\n#endif\n\n\n/*\n** This structure is passed around through all the sanity checking routines\n** in order to keep track of some global state information.\n**\n** The aRef[] array is allocated so that there is 1 bit for each page in\n** the database. As the integrity-check proceeds, for each page used in\n** the database the corresponding bit is set. This allows integrity-check to \n** detect pages that are used twice and orphaned pages (both of which \n** indicate corruption).\n*/\ntypedef struct IntegrityCk IntegrityCk;\nstruct IntegrityCk {\n  BtShared *pBt;    /* The tree being checked out */\n  Pager *pPager;    /* The associated pager.  Also accessible by pBt->pPager */\n  u8 *aPgRef;       /* 1 bit per page in the db (see above) */\n  Pgno nPage;       /* Number of pages in the database */\n  int mxErr;        /* Stop accumulating errors when this reaches zero */\n  int nErr;         /* Number of messages written to zErrMsg so far */\n  int mallocFailed; /* A memory allocation error has occurred */\n  StrAccum errMsg;  /* Accumulate the error message text here */\n};\n\n/*\n** Routines to read or write a two- and four-byte big-endian integer values.\n*/\n#define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))\n#define get4byte sqlite3Get4byte\n#define put4byte sqlite3Put4byte\n\n/************** End of btreeInt.h ********************************************/\n/************** Continuing where we left off in btmutex.c ********************/\n#ifndef SQLITE_OMIT_SHARED_CACHE\n#if SQLITE_THREADSAFE\n\n/*\n** Obtain the BtShared mutex associated with B-Tree handle p. Also,\n** set BtShared.db to the database handle associated with p and the\n** p->locked boolean to true.\n*/\nstatic void lockBtreeMutex(Btree *p){\n  assert( p->locked==0 );\n  assert( sqlite3_mutex_notheld(p->pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  sqlite3_mutex_enter(p->pBt->mutex);\n  p->pBt->db = p->db;\n  p->locked = 1;\n}\n\n/*\n** Release the BtShared mutex associated with B-Tree handle p and\n** clear the p->locked boolean.\n*/\nstatic void unlockBtreeMutex(Btree *p){\n  BtShared *pBt = p->pBt;\n  assert( p->locked==1 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  assert( p->db==pBt->db );\n\n  sqlite3_mutex_leave(pBt->mutex);\n  p->locked = 0;\n}\n\n/*\n** Enter a mutex on the given BTree object.\n**\n** If the object is not sharable, then no mutex is ever required\n** and this routine is a no-op.  The underlying mutex is non-recursive.\n** But we keep a reference count in Btree.wantToLock so the behavior\n** of this interface is recursive.\n**\n** To avoid deadlocks, multiple Btrees are locked in the same order\n** by all database connections.  The p->pNext is a list of other\n** Btrees belonging to the same database connection as the p Btree\n** which need to be locked after p.  If we cannot get a lock on\n** p, then first unlock all of the others on p->pNext, then wait\n** for the lock to become available on p, then relock all of the\n** subsequent Btrees that desire a lock.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  Btree *pLater;\n\n  /* Some basic sanity checking on the Btree.  The list of Btrees\n  ** connected by pNext and pPrev should be in sorted order by\n  ** Btree.pBt value. All elements of the list should belong to\n  ** the same connection. Only shared Btrees are on the list. */\n  assert( p->pNext==0 || p->pNext->pBt>p->pBt );\n  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );\n  assert( p->pNext==0 || p->pNext->db==p->db );\n  assert( p->pPrev==0 || p->pPrev->db==p->db );\n  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );\n\n  /* Check for locking consistency */\n  assert( !p->locked || p->wantToLock>0 );\n  assert( p->sharable || p->wantToLock==0 );\n\n  /* We should already hold a lock on the database connection */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  /* Unless the database is sharable and unlocked, then BtShared.db\n  ** should already be set correctly. */\n  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );\n\n  if( !p->sharable ) return;\n  p->wantToLock++;\n  if( p->locked ) return;\n\n  /* In most cases, we should be able to acquire the lock we\n  ** want without having to go throught the ascending lock\n  ** procedure that follows.  Just be sure not to block.\n  */\n  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){\n    p->pBt->db = p->db;\n    p->locked = 1;\n    return;\n  }\n\n  /* To avoid deadlock, first release all locks with a larger\n  ** BtShared address.  Then acquire our lock.  Then reacquire\n  ** the other BtShared locks that we used to hold in ascending\n  ** order.\n  */\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    assert( pLater->sharable );\n    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );\n    assert( !pLater->locked || pLater->wantToLock>0 );\n    if( pLater->locked ){\n      unlockBtreeMutex(pLater);\n    }\n  }\n  lockBtreeMutex(p);\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    if( pLater->wantToLock ){\n      lockBtreeMutex(pLater);\n    }\n  }\n}\n\n/*\n** Exit the recursive mutex on a Btree.\n*/\nSQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){\n  if( p->sharable ){\n    assert( p->wantToLock>0 );\n    p->wantToLock--;\n    if( p->wantToLock==0 ){\n      unlockBtreeMutex(p);\n    }\n  }\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the BtShared mutex is held on the btree, or if the\n** B-Tree is not marked as sharable.\n**\n** This routine is used only from within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){\n  assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );\n  assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );\n\n  return (p->sharable==0 || p->locked);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Enter and leave a mutex on a Btree given a cursor owned by that\n** Btree.  These entry points are used by incremental I/O and can be\n** omitted if that module is not used.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor *pCur){\n  sqlite3BtreeEnter(pCur->pBtree);\n}\nSQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){\n  sqlite3BtreeLeave(pCur->pBtree);\n}\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n\n/*\n** Enter the mutex on every Btree associated with a database\n** connection.  This is needed (for example) prior to parsing\n** a statement since we will be comparing table and column names\n** against all schemas and we do not want those schemas being\n** reset out from under us.\n**\n** There is a corresponding leave-all procedures.\n**\n** Enter the mutexes in accending order by BtShared pointer address\n** to avoid the possibility of deadlock when two threads with\n** two or more btrees in common both try to lock all their btrees\n** at the same instant.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  int i;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p ) sqlite3BtreeEnter(p);\n  }\n}\nSQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){\n  int i;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p ) sqlite3BtreeLeave(p);\n  }\n}\n\n/*\n** Return true if a particular Btree requires a lock.  Return FALSE if\n** no lock is ever required since it is not sharable.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){\n  return p->sharable;\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the current thread holds the database connection\n** mutex and all required BtShared mutexes.\n**\n** This routine is used inside assert() statements only.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3 *db){\n  int i;\n  if( !sqlite3_mutex_held(db->mutex) ){\n    return 0;\n  }\n  for(i=0; i<db->nDb; i++){\n    Btree *p;\n    p = db->aDb[i].pBt;\n    if( p && p->sharable &&\n         (p->wantToLock==0 || !sqlite3_mutex_held(p->pBt->mutex)) ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/*\n** Return true if the correct mutexes are held for accessing the\n** db->aDb[iDb].pSchema structure.  The mutexes required for schema\n** access are:\n**\n**   (1) The mutex on db\n**   (2) if iDb!=1, then the mutex on db->aDb[iDb].pBt.\n**\n** If pSchema is not NULL, then iDb is computed from pSchema and\n** db using sqlite3SchemaToIndex().\n*/\nSQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){\n  Btree *p;\n  assert( db!=0 );\n  if( pSchema ) iDb = sqlite3SchemaToIndex(db, pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  if( !sqlite3_mutex_held(db->mutex) ) return 0;\n  if( iDb==1 ) return 1;\n  p = db->aDb[iDb].pBt;\n  assert( p!=0 );\n  return p->sharable==0 || p->locked==1;\n}\n#endif /* NDEBUG */\n\n#else /* SQLITE_THREADSAFE>0 above.  SQLITE_THREADSAFE==0 below */\n/*\n** The following are special cases for mutex enter routines for use\n** in single threaded applications that use shared cache.  Except for\n** these two routines, all mutex operations are no-ops in that case and\n** are null #defines in btree.h.\n**\n** If shared cache is disabled, then all btree mutex routines, including\n** the ones below, are no-ops and are null #defines in btree.h.\n*/\n\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  p->pBt->db = p->db;\n}\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      p->pBt->db = p->db;\n    }\n  }\n}\n#endif /* if SQLITE_THREADSAFE */\n#endif /* ifndef SQLITE_OMIT_SHARED_CACHE */\n\n/************** End of btmutex.c *********************************************/\n/************** Begin file btree.c *******************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a external (disk-based) database using BTrees.\n** See the header comment on \"btreeInt.h\" for additional information.\n** Including a description of file format and an overview of operation.\n*/\n\n/*\n** The header string that appears at the beginning of every\n** SQLite database.\n*/\nstatic const char zMagicHeader[] = SQLITE_FILE_HEADER;\n\n/*\n** Set this global variable to 1 to enable tracing using the TRACE\n** macro.\n*/\n#if 0\nint sqlite3BtreeTrace=1;  /* True to enable tracing */\n# define TRACE(X)  if(sqlite3BtreeTrace){printf X;fflush(stdout);}\n#else\n# define TRACE(X)\n#endif\n\n/*\n** Extract a 2-byte big-endian integer from an array of unsigned bytes.\n** But if the value is zero, make it 65536.\n**\n** This routine is used to extract the \"offset to cell content area\" value\n** from the header of a btree page.  If the page size is 65536 and the page\n** is empty, the offset should be 65536, but the 2-byte value stores zero.\n** This routine makes the necessary adjustment to 65536.\n*/\n#define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)\n\n/*\n** Values passed as the 5th argument to allocateBtreePage()\n*/\n#define BTALLOC_ANY   0           /* Allocate any page */\n#define BTALLOC_EXACT 1           /* Allocate exact page if possible */\n#define BTALLOC_LE    2           /* Allocate any page <= the parameter */\n\n/*\n** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not \n** defined, or 0 if it is. For example:\n**\n**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define IfNotOmitAV(expr) (expr)\n#else\n#define IfNotOmitAV(expr) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** A list of BtShared objects that are eligible for participation\n** in shared cache.  This variable has file scope during normal builds,\n** but the test harness needs to access it so we make it global for \n** test builds.\n**\n** Access to this variable is protected by SQLITE_MUTEX_STATIC_MASTER.\n*/\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#else\nstatic BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#endif\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Enable or disable the shared pager and schema features.\n**\n** This routine has no effect on existing database connections.\n** The shared cache setting effects only future calls to\n** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int enable){\n  sqlite3GlobalConfig.sharedCacheEnabled = enable;\n  return SQLITE_OK;\n}\n#endif\n\n\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n  /*\n  ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(),\n  ** and clearAllSharedCacheTableLocks()\n  ** manipulate entries in the BtShared.pLock linked list used to store\n  ** shared-cache table level locks. If the library is compiled with the\n  ** shared-cache feature disabled, then there is only ever one user\n  ** of each BtShared structure and so this locking is not necessary. \n  ** So define the lock related functions as no-ops.\n  */\n  #define querySharedCacheTableLock(a,b,c) SQLITE_OK\n  #define setSharedCacheTableLock(a,b,c) SQLITE_OK\n  #define clearAllSharedCacheTableLocks(a)\n  #define downgradeAllSharedCacheTableLocks(a)\n  #define hasSharedCacheTableLock(a,b,c,d) 1\n  #define hasReadConflicts(a, b) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function is only used as part of an assert() statement. ***\n**\n** Check to see if pBtree holds the required locks to read or write to the \n** table with root page iRoot.   Return 1 if it does and 0 if not.\n**\n** For example, when writing to a table with root-page iRoot via \n** Btree connection pBtree:\n**\n**    assert( hasSharedCacheTableLock(pBtree, iRoot, 0, WRITE_LOCK) );\n**\n** When writing to an index that resides in a sharable database, the \n** caller should have first obtained a lock specifying the root page of\n** the corresponding table. This makes things a bit more complicated,\n** as this module treats each table as a separate structure. To determine\n** the table corresponding to the index being written, this\n** function has to search through the database schema.\n**\n** Instead of a lock on the table/index rooted at page iRoot, the caller may\n** hold a write-lock on the schema table (root page 1). This is also\n** acceptable.\n*/\nstatic int hasSharedCacheTableLock(\n  Btree *pBtree,         /* Handle that must hold lock */\n  Pgno iRoot,            /* Root page of b-tree */\n  int isIndex,           /* True if iRoot is the root of an index b-tree */\n  int eLockType          /* Required lock type (READ_LOCK or WRITE_LOCK) */\n){\n  Schema *pSchema = (Schema *)pBtree->pBt->pSchema;\n  Pgno iTab = 0;\n  BtLock *pLock;\n\n  /* If this database is not shareable, or if the client is reading\n  ** and has the read-uncommitted flag set, then no lock is required. \n  ** Return true immediately.\n  */\n  if( (pBtree->sharable==0)\n   || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommitted))\n  ){\n    return 1;\n  }\n\n  /* If the client is reading  or writing an index and the schema is\n  ** not loaded, then it is too difficult to actually check to see if\n  ** the correct locks are held.  So do not bother - just return true.\n  ** This case does not come up very often anyhow.\n  */\n  if( isIndex && (!pSchema || (pSchema->flags&DB_SchemaLoaded)==0) ){\n    return 1;\n  }\n\n  /* Figure out the root-page that the lock should be held on. For table\n  ** b-trees, this is just the root page of the b-tree being read or\n  ** written. For index b-trees, it is the root page of the associated\n  ** table.  */\n  if( isIndex ){\n    HashElem *p;\n    for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){\n      Index *pIdx = (Index *)sqliteHashData(p);\n      if( pIdx->tnum==(int)iRoot ){\n        iTab = pIdx->pTable->tnum;\n      }\n    }\n  }else{\n    iTab = iRoot;\n  }\n\n  /* Search for the required lock. Either a write-lock on root-page iTab, a \n  ** write-lock on the schema table, or (if the client is reading) a\n  ** read-lock on iTab will suffice. Return 1 if any of these are found.  */\n  for(pLock=pBtree->pBt->pLock; pLock; pLock=pLock->pNext){\n    if( pLock->pBtree==pBtree \n     && (pLock->iTable==iTab || (pLock->eLock==WRITE_LOCK && pLock->iTable==1))\n     && pLock->eLock>=eLockType \n    ){\n      return 1;\n    }\n  }\n\n  /* Failed to find the required lock. */\n  return 0;\n}\n#endif /* SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function may be used as part of assert() statements only. ****\n**\n** Return true if it would be illegal for pBtree to write into the\n** table or index rooted at iRoot because other shared connections are\n** simultaneously reading that same table or index.\n**\n** It is illegal for pBtree to write if some other Btree object that\n** shares the same BtShared object is currently reading or writing\n** the iRoot table.  Except, if the other Btree object has the\n** read-uncommitted flag set, then it is OK for the other object to\n** have a read cursor.\n**\n** For example, before writing to any part of the table or index\n** rooted at page iRoot, one should call:\n**\n**    assert( !hasReadConflicts(pBtree, iRoot) );\n*/\nstatic int hasReadConflicts(Btree *pBtree, Pgno iRoot){\n  BtCursor *p;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( p->pgnoRoot==iRoot \n     && p->pBtree!=pBtree\n     && 0==(p->pBtree->db->flags & SQLITE_ReadUncommitted)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif    /* #ifdef SQLITE_DEBUG */\n\n/*\n** Query to see if Btree handle p may obtain a lock of type eLock \n** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return\n** SQLITE_OK if the lock may be obtained (by calling\n** setSharedCacheTableLock()), or SQLITE_LOCKED if not.\n*/\nstatic int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n  assert( !(p->db->flags&SQLITE_ReadUncommitted)||eLock==WRITE_LOCK||iTab==1 );\n  \n  /* If requesting a write-lock, then the Btree must have an open write\n  ** transaction on this file. And, obviously, for this to be so there \n  ** must be an open write transaction on the file itself.\n  */\n  assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );\n  assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );\n  \n  /* This routine is a no-op if the shared-cache is not enabled */\n  if( !p->sharable ){\n    return SQLITE_OK;\n  }\n\n  /* If some other connection is holding an exclusive lock, the\n  ** requested lock may not be obtained.\n  */\n  if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){\n    sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);\n    return SQLITE_LOCKED_SHAREDCACHE;\n  }\n\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    /* The condition (pIter->eLock!=eLock) in the following if(...) \n    ** statement is a simplification of:\n    **\n    **   (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)\n    **\n    ** since we know that if eLock==WRITE_LOCK, then no other connection\n    ** may hold a WRITE_LOCK on any table in this file (since there can\n    ** only be a single writer).\n    */\n    assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );\n    assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);\n    if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){\n      sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);\n      if( eLock==WRITE_LOCK ){\n        assert( p==pBt->pWriter );\n        pBt->btsFlags |= BTS_PENDING;\n      }\n      return SQLITE_LOCKED_SHAREDCACHE;\n    }\n  }\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Add a lock on the table with root-page iTable to the shared-btree used\n** by Btree handle p. Parameter eLock must be either READ_LOCK or \n** WRITE_LOCK.\n**\n** This function assumes the following:\n**\n**   (a) The specified Btree object p is connected to a sharable\n**       database (one with the BtShared.sharable flag set), and\n**\n**   (b) No other Btree objects hold a lock that conflicts\n**       with the requested lock (i.e. querySharedCacheTableLock() has\n**       already been called and returned SQLITE_OK).\n**\n** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM \n** is returned if a malloc attempt fails.\n*/\nstatic int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pLock = 0;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n\n  /* A connection with the read-uncommitted flag set will never try to\n  ** obtain a read-lock using this function. The only read-lock obtained\n  ** by a connection in read-uncommitted mode is on the sqlite_master \n  ** table, and that lock is obtained in BtreeBeginTrans().  */\n  assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );\n\n  /* This function should only be called on a sharable b-tree after it \n  ** has been determined that no other b-tree holds a conflicting lock.  */\n  assert( p->sharable );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );\n\n  /* First search the list for an existing lock on this table. */\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    if( pIter->iTable==iTable && pIter->pBtree==p ){\n      pLock = pIter;\n      break;\n    }\n  }\n\n  /* If the above search did not find a BtLock struct associating Btree p\n  ** with table iTable, allocate one and link it into the list.\n  */\n  if( !pLock ){\n    pLock = (BtLock *)sqlite3MallocZero(sizeof(BtLock));\n    if( !pLock ){\n      return SQLITE_NOMEM;\n    }\n    pLock->iTable = iTable;\n    pLock->pBtree = p;\n    pLock->pNext = pBt->pLock;\n    pBt->pLock = pLock;\n  }\n\n  /* Set the BtLock.eLock variable to the maximum of the current lock\n  ** and the requested lock. This means if a write-lock was already held\n  ** and a read-lock requested, we don't incorrectly downgrade the lock.\n  */\n  assert( WRITE_LOCK>READ_LOCK );\n  if( eLock>pLock->eLock ){\n    pLock->eLock = eLock;\n  }\n\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Release all the table locks (locks obtained via calls to\n** the setSharedCacheTableLock() procedure) held by Btree object p.\n**\n** This function assumes that Btree p has an open read or write \n** transaction. If it does not, then the BTS_PENDING flag\n** may be incorrectly cleared.\n*/\nstatic void clearAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtLock **ppIter = &pBt->pLock;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->sharable || 0==*ppIter );\n  assert( p->inTrans>0 );\n\n  while( *ppIter ){\n    BtLock *pLock = *ppIter;\n    assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );\n    assert( pLock->pBtree->inTrans>=pLock->eLock );\n    if( pLock->pBtree==p ){\n      *ppIter = pLock->pNext;\n      assert( pLock->iTable!=1 || pLock==&p->lock );\n      if( pLock->iTable!=1 ){\n        sqlite3_free(pLock);\n      }\n    }else{\n      ppIter = &pLock->pNext;\n    }\n  }\n\n  assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );\n  if( pBt->pWriter==p ){\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n  }else if( pBt->nTransaction==2 ){\n    /* This function is called when Btree p is concluding its \n    ** transaction. If there currently exists a writer, and p is not\n    ** that writer, then the number of locks held by connections other\n    ** than the writer must be about to drop to zero. In this case\n    ** set the BTS_PENDING flag to 0.\n    **\n    ** If there is not currently a writer, then BTS_PENDING must\n    ** be zero already. So this next line is harmless in that case.\n    */\n    pBt->btsFlags &= ~BTS_PENDING;\n  }\n}\n\n/*\n** This function changes all write-locks held by Btree p into read-locks.\n*/\nstatic void downgradeAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  if( pBt->pWriter==p ){\n    BtLock *pLock;\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n    for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){\n      assert( pLock->eLock==READ_LOCK || pLock->pBtree==p );\n      pLock->eLock = READ_LOCK;\n    }\n  }\n}\n\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\nstatic void releasePage(MemPage *pPage);  /* Forward reference */\n\n/*\n***** This routine is used inside of assert() only ****\n**\n** Verify that the cursor holds the mutex on its BtShared\n*/\n#ifdef SQLITE_DEBUG\nstatic int cursorHoldsMutex(BtCursor *p){\n  return sqlite3_mutex_held(p->pBt->mutex);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Invalidate the overflow page-list cache for cursor pCur, if any.\n*/\nstatic void invalidateOverflowCache(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  sqlite3_free(pCur->aOverflow);\n  pCur->aOverflow = 0;\n}\n\n/*\n** Invalidate the overflow page-list cache for all cursors opened\n** on the shared btree structure pBt.\n*/\nstatic void invalidateAllOverflowCache(BtShared *pBt){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    invalidateOverflowCache(p);\n  }\n}\n\n/*\n** This function is called before modifying the contents of a table\n** to invalidate any incrblob cursors that are open on the\n** row or one of the rows being modified.\n**\n** If argument isClearTable is true, then the entire contents of the\n** table is about to be deleted. In this case invalidate all incrblob\n** cursors open on any row within the table with root-page pgnoRoot.\n**\n** Otherwise, if argument isClearTable is false, then the row with\n** rowid iRow is being replaced or deleted. In this case invalidate\n** only those incrblob cursors open on that specific row.\n*/\nstatic void invalidateIncrblobCursors(\n  Btree *pBtree,          /* The database file to check */\n  i64 iRow,               /* The rowid that might be changing */\n  int isClearTable        /* True if all rows are being deleted */\n){\n  BtCursor *p;\n  BtShared *pBt = pBtree->pBt;\n  assert( sqlite3BtreeHoldsMutex(pBtree) );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    if( p->isIncrblobHandle && (isClearTable || p->info.nKey==iRow) ){\n      p->eState = CURSOR_INVALID;\n    }\n  }\n}\n\n#else\n  /* Stub functions when INCRBLOB is omitted */\n  #define invalidateOverflowCache(x)\n  #define invalidateAllOverflowCache(x)\n  #define invalidateIncrblobCursors(x,y,z)\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Set bit pgno of the BtShared.pHasContent bitvec. This is called \n** when a page that previously contained data becomes a free-list leaf \n** page.\n**\n** The BtShared.pHasContent bitvec exists to work around an obscure\n** bug caused by the interaction of two useful IO optimizations surrounding\n** free-list leaf pages:\n**\n**   1) When all data is deleted from a page and the page becomes\n**      a free-list leaf page, the page is not written to the database\n**      (as free-list leaf pages contain no meaningful data). Sometimes\n**      such a page is not even journalled (as it will not be modified,\n**      why bother journalling it?).\n**\n**   2) When a free-list leaf page is reused, its content is not read\n**      from the database or written to the journal file (why should it\n**      be, if it is not at all meaningful?).\n**\n** By themselves, these optimizations work fine and provide a handy\n** performance boost to bulk delete or insert operations. However, if\n** a page is moved to the free-list and then reused within the same\n** transaction, a problem comes up. If the page is not journalled when\n** it is moved to the free-list and it is also not journalled when it\n** is extracted from the free-list and reused, then the original data\n** may be lost. In the event of a rollback, it may not be possible\n** to restore the database to its original configuration.\n**\n** The solution is the BtShared.pHasContent bitvec. Whenever a page is \n** moved to become a free-list leaf page, the corresponding bit is\n** set in the bitvec. Whenever a leaf page is extracted from the free-list,\n** optimization 2 above is omitted if the corresponding bit is already\n** set in BtShared.pHasContent. The contents of the bitvec are cleared\n** at the end of every transaction.\n*/\nstatic int btreeSetHasContent(BtShared *pBt, Pgno pgno){\n  int rc = SQLITE_OK;\n  if( !pBt->pHasContent ){\n    assert( pgno<=pBt->nPage );\n    pBt->pHasContent = sqlite3BitvecCreate(pBt->nPage);\n    if( !pBt->pHasContent ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){\n    rc = sqlite3BitvecSet(pBt->pHasContent, pgno);\n  }\n  return rc;\n}\n\n/*\n** Query the BtShared.pHasContent vector.\n**\n** This function is called when a free-list leaf page is removed from the\n** free-list for reuse. It returns false if it is safe to retrieve the\n** page from the pager layer with the 'no-content' flag set. True otherwise.\n*/\nstatic int btreeGetHasContent(BtShared *pBt, Pgno pgno){\n  Bitvec *p = pBt->pHasContent;\n  return (p && (pgno>sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno)));\n}\n\n/*\n** Clear (destroy) the BtShared.pHasContent bitvec. This should be\n** invoked at the conclusion of each write-transaction.\n*/\nstatic void btreeClearHasContent(BtShared *pBt){\n  sqlite3BitvecDestroy(pBt->pHasContent);\n  pBt->pHasContent = 0;\n}\n\n/*\n** Release all of the apPage[] pages for a cursor.\n*/\nstatic void btreeReleaseAllCursorPages(BtCursor *pCur){\n  int i;\n  for(i=0; i<=pCur->iPage; i++){\n    releasePage(pCur->apPage[i]);\n    pCur->apPage[i] = 0;\n  }\n  pCur->iPage = -1;\n}\n\n\n/*\n** Save the current cursor position in the variables BtCursor.nKey \n** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.\n**\n** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID)\n** prior to calling this routine.  \n*/\nstatic int saveCursorPosition(BtCursor *pCur){\n  int rc;\n\n  assert( CURSOR_VALID==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);\n  assert( rc==SQLITE_OK );  /* KeySize() cannot fail */\n\n  /* If this is an intKey table, then the above call to BtreeKeySize()\n  ** stores the integer key in pCur->nKey. In this case this value is\n  ** all that is required. Otherwise, if pCur is not open on an intKey\n  ** table, then malloc space for and store the pCur->nKey bytes of key \n  ** data.\n  */\n  if( 0==pCur->apPage[0]->intKey ){\n    void *pKey = sqlite3Malloc( (int)pCur->nKey );\n    if( pKey ){\n      rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);\n      if( rc==SQLITE_OK ){\n        pCur->pKey = pKey;\n      }else{\n        sqlite3_free(pKey);\n      }\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  assert( !pCur->apPage[0]->intKey || !pCur->pKey );\n\n  if( rc==SQLITE_OK ){\n    btreeReleaseAllCursorPages(pCur);\n    pCur->eState = CURSOR_REQUIRESEEK;\n  }\n\n  invalidateOverflowCache(pCur);\n  return rc;\n}\n\n/*\n** Save the positions of all cursors (except pExcept) that are open on\n** the table  with root-page iRoot. Usually, this is called just before cursor\n** pExcept is used to modify the table (BtreeDelete() or BtreeInsert()).\n*/\nstatic int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pExcept==0 || pExcept->pBt==pBt );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){\n      if( p->eState==CURSOR_VALID ){\n        int rc = saveCursorPosition(p);\n        if( SQLITE_OK!=rc ){\n          return rc;\n        }\n      }else{\n        testcase( p->iPage>0 );\n        btreeReleaseAllCursorPages(p);\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Clear the current cursor position.\n*/\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  sqlite3_free(pCur->pKey);\n  pCur->pKey = 0;\n  pCur->eState = CURSOR_INVALID;\n}\n\n/*\n** In this version of BtreeMoveto, pKey is a packed index record\n** such as is generated by the OP_MakeRecord opcode.  Unpack the\n** record and then call BtreeMovetoUnpacked() to do the work.\n*/\nstatic int btreeMoveto(\n  BtCursor *pCur,     /* Cursor open on the btree to be searched */\n  const void *pKey,   /* Packed key if the btree is an index */\n  i64 nKey,           /* Integer key for tables.  Size of pKey for indices */\n  int bias,           /* Bias search to the high end */\n  int *pRes           /* Write search results here */\n){\n  int rc;                    /* Status code */\n  UnpackedRecord *pIdxKey;   /* Unpacked index key */\n  char aSpace[150];          /* Temp space for pIdxKey - to avoid a malloc */\n  char *pFree = 0;\n\n  if( pKey ){\n    assert( nKey==(i64)(int)nKey );\n    pIdxKey = sqlite3VdbeAllocUnpackedRecord(\n        pCur->pKeyInfo, aSpace, sizeof(aSpace), &pFree\n    );\n    if( pIdxKey==0 ) return SQLITE_NOMEM;\n    sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);\n  }else{\n    pIdxKey = 0;\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);\n  if( pFree ){\n    sqlite3DbFree(pCur->pKeyInfo->db, pFree);\n  }\n  return rc;\n}\n\n/*\n** Restore the cursor to the position it was in (or as close to as possible)\n** when saveCursorPosition() was called. Note that this call deletes the \n** saved position info stored by saveCursorPosition(), so there can be\n** at most one effective restoreCursorPosition() call after each \n** saveCursorPosition().\n*/\nstatic int btreeRestoreCursorPosition(BtCursor *pCur){\n  int rc;\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState>=CURSOR_REQUIRESEEK );\n  if( pCur->eState==CURSOR_FAULT ){\n    return pCur->skipNext;\n  }\n  pCur->eState = CURSOR_INVALID;\n  rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);\n  if( rc==SQLITE_OK ){\n    sqlite3_free(pCur->pKey);\n    pCur->pKey = 0;\n    assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );\n  }\n  return rc;\n}\n\n#define restoreCursorPosition(p) \\\n  (p->eState>=CURSOR_REQUIRESEEK ? \\\n         btreeRestoreCursorPosition(p) : \\\n         SQLITE_OK)\n\n/*\n** Determine whether or not a cursor has moved from the position it\n** was last placed at.  Cursors can move when the row they are pointing\n** at is deleted out from under them.\n**\n** This routine returns an error code if something goes wrong.  The\n** integer *pHasMoved is set to one if the cursor has moved and 0 if not.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){\n  int rc;\n\n  rc = restoreCursorPosition(pCur);\n  if( rc ){\n    *pHasMoved = 1;\n    return rc;\n  }\n  if( pCur->eState!=CURSOR_VALID || pCur->skipNext!=0 ){\n    *pHasMoved = 1;\n  }else{\n    *pHasMoved = 0;\n  }\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Given a page number of a regular database page, return the page\n** number for the pointer-map page that contains the entry for the\n** input page number.\n**\n** Return 0 (not a valid page) for pgno==1 since there is\n** no pointer map associated with page 1.  The integrity_check logic\n** requires that ptrmapPageno(*,1)!=1.\n*/\nstatic Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){\n  int nPagesPerMapPage;\n  Pgno iPtrMap, ret;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno<2 ) return 0;\n  nPagesPerMapPage = (pBt->usableSize/5)+1;\n  iPtrMap = (pgno-2)/nPagesPerMapPage;\n  ret = (iPtrMap*nPagesPerMapPage) + 2; \n  if( ret==PENDING_BYTE_PAGE(pBt) ){\n    ret++;\n  }\n  return ret;\n}\n\n/*\n** Write an entry into the pointer map.\n**\n** This routine updates the pointer map entry for page number 'key'\n** so that it maps to type 'eType' and parent page number 'pgno'.\n**\n** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is\n** a no-op.  If an error occurs, the appropriate error code is written\n** into *pRC.\n*/\nstatic void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){\n  DbPage *pDbPage;  /* The pointer map page */\n  u8 *pPtrmap;      /* The pointer map data */\n  Pgno iPtrmap;     /* The pointer map page number */\n  int offset;       /* Offset in pointer map page */\n  int rc;           /* Return code from subfunctions */\n\n  if( *pRC ) return;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  /* The master-journal page number must never be used as a pointer map page */\n  assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );\n\n  assert( pBt->autoVacuum );\n  if( key==0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage);\n  if( rc!=SQLITE_OK ){\n    *pRC = rc;\n    return;\n  }\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    goto ptrmap_exit;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){\n    TRACE((\"PTRMAP_UPDATE: %d->(%d,%d)\\n\", key, eType, parent));\n    *pRC= rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      pPtrmap[offset] = eType;\n      put4byte(&pPtrmap[offset+1], parent);\n    }\n  }\n\nptrmap_exit:\n  sqlite3PagerUnref(pDbPage);\n}\n\n/*\n** Read an entry from the pointer map.\n**\n** This routine retrieves the pointer map entry for page 'key', writing\n** the type and parent page number to *pEType and *pPgno respectively.\n** An error code is returned if something goes wrong, otherwise SQLITE_OK.\n*/\nstatic int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){\n  DbPage *pDbPage;   /* The pointer map page */\n  int iPtrmap;       /* Pointer map page index */\n  u8 *pPtrmap;       /* Pointer map page data */\n  int offset;        /* Offset of entry in pointer map */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage);\n  if( rc!=0 ){\n    return rc;\n  }\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    sqlite3PagerUnref(pDbPage);\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  assert( pEType!=0 );\n  *pEType = pPtrmap[offset];\n  if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);\n\n  sqlite3PagerUnref(pDbPage);\n  if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_BKPT;\n  return SQLITE_OK;\n}\n\n#else /* if defined SQLITE_OMIT_AUTOVACUUM */\n  #define ptrmapPut(w,x,y,z,rc)\n  #define ptrmapGet(w,x,y,z) SQLITE_OK\n  #define ptrmapPutOvflPtr(x, y, rc)\n#endif\n\n/*\n** Given a btree page and a cell index (0 means the first cell on\n** the page, 1 means the second cell, and so forth) return a pointer\n** to the cell content.\n**\n** This routine works only for pages that do not contain overflow cells.\n*/\n#define findCell(P,I) \\\n  ((P)->aData + ((P)->maskPage & get2byte(&(P)->aCellIdx[2*(I)])))\n#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I)))))\n\n\n/*\n** This a more complex version of findCell() that works for\n** pages that do contain overflow cells.\n*/\nstatic u8 *findOverflowCell(MemPage *pPage, int iCell){\n  int i;\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  for(i=pPage->nOverflow-1; i>=0; i--){\n    int k;\n    k = pPage->aiOvfl[i];\n    if( k<=iCell ){\n      if( k==iCell ){\n        return pPage->apOvfl[i];\n      }\n      iCell--;\n    }\n  }\n  return findCell(pPage, iCell);\n}\n\n/*\n** Parse a cell content block and fill in the CellInfo structure.  There\n** are two versions of this function.  btreeParseCell() takes a \n** cell index as the second argument and btreeParseCellPtr() \n** takes a pointer to the body of the cell as its second argument.\n**\n** Within this file, the parseCell() macro can be called instead of\n** btreeParseCellPtr(). Using some compilers, this will be faster.\n*/\nstatic void btreeParseCellPtr(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u16 n;                  /* Number bytes in cell content header */\n  u32 nPayload;           /* Number of bytes of cell payload */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n\n  pInfo->pCell = pCell;\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  n = pPage->childPtrSize;\n  assert( n==4-4*pPage->leaf );\n  if( pPage->intKey ){\n    if( pPage->hasData ){\n      n += getVarint32(&pCell[n], nPayload);\n    }else{\n      nPayload = 0;\n    }\n    n += getVarint(&pCell[n], (u64*)&pInfo->nKey);\n    pInfo->nData = nPayload;\n  }else{\n    pInfo->nData = 0;\n    n += getVarint32(&pCell[n], nPayload);\n    pInfo->nKey = nPayload;\n  }\n  pInfo->nPayload = nPayload;\n  pInfo->nHeader = n;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( likely(nPayload<=pPage->maxLocal) ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    if( (pInfo->nSize = (u16)(n+nPayload))<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n    pInfo->iOverflow = 0;\n  }else{\n    /* If the payload will not fit completely on the local page, we have\n    ** to decide how much to store locally and how much to spill onto\n    ** overflow pages.  The strategy is to minimize the amount of unused\n    ** space on overflow pages while keeping the amount of local storage\n    ** in between minLocal and maxLocal.\n    **\n    ** Warning:  changing the way overflow payload is distributed in any\n    ** way will result in an incompatible file format.\n    */\n    int minLocal;  /* Minimum amount of payload held locally */\n    int maxLocal;  /* Maximum amount of payload held locally */\n    int surplus;   /* Overflow payload available for local storage */\n\n    minLocal = pPage->minLocal;\n    maxLocal = pPage->maxLocal;\n    surplus = minLocal + (nPayload - minLocal)%(pPage->pBt->usableSize - 4);\n    testcase( surplus==maxLocal );\n    testcase( surplus==maxLocal+1 );\n    if( surplus <= maxLocal ){\n      pInfo->nLocal = (u16)surplus;\n    }else{\n      pInfo->nLocal = (u16)minLocal;\n    }\n    pInfo->iOverflow = (u16)(pInfo->nLocal + n);\n    pInfo->nSize = pInfo->iOverflow + 4;\n  }\n}\n#define parseCell(pPage, iCell, pInfo) \\\n  btreeParseCellPtr((pPage), findCell((pPage), (iCell)), (pInfo))\nstatic void btreeParseCell(\n  MemPage *pPage,         /* Page containing the cell */\n  int iCell,              /* The cell index.  First cell is 0 */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  parseCell(pPage, iCell, pInfo);\n}\n\n/*\n** Compute the total number of bytes that a Cell needs in the cell\n** data area of the btree-page.  The return number includes the cell\n** data header and the local payload, but not any overflow page or\n** the space used by the cell pointer.\n*/\nstatic u16 cellSizePtr(MemPage *pPage, u8 *pCell){\n  u8 *pIter = &pCell[pPage->childPtrSize];\n  u32 nSize;\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  btreeParseCellPtr(pPage, pCell, &debuginfo);\n#endif\n\n  if( pPage->intKey ){\n    u8 *pEnd;\n    if( pPage->hasData ){\n      pIter += getVarint32(pIter, nSize);\n    }else{\n      nSize = 0;\n    }\n\n    /* pIter now points at the 64-bit integer key value, a variable length \n    ** integer. The following block moves pIter to point at the first byte\n    ** past the end of the key value. */\n    pEnd = &pIter[9];\n    while( (*pIter++)&0x80 && pIter<pEnd );\n  }else{\n    pIter += getVarint32(pIter, nSize);\n  }\n\n  testcase( nSize==pPage->maxLocal );\n  testcase( nSize==pPage->maxLocal+1 );\n  if( nSize>pPage->maxLocal ){\n    int minLocal = pPage->minLocal;\n    nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);\n    testcase( nSize==pPage->maxLocal );\n    testcase( nSize==pPage->maxLocal+1 );\n    if( nSize>pPage->maxLocal ){\n      nSize = minLocal;\n    }\n    nSize += 4;\n  }\n  nSize += (u32)(pIter - pCell);\n\n  /* The minimum size of any cell is 4 bytes. */\n  if( nSize<4 ){\n    nSize = 4;\n  }\n\n  assert( nSize==debuginfo.nSize );\n  return (u16)nSize;\n}\n\n#ifdef SQLITE_DEBUG\n/* This variation on cellSizePtr() is used inside of assert() statements\n** only. */\nstatic u16 cellSize(MemPage *pPage, int iCell){\n  return cellSizePtr(pPage, findCell(pPage, iCell));\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** If the cell pCell, part of page pPage contains a pointer\n** to an overflow page, insert an entry into the pointer-map\n** for the overflow page.\n*/\nstatic void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){\n  CellInfo info;\n  if( *pRC ) return;\n  assert( pCell!=0 );\n  btreeParseCellPtr(pPage, pCell, &info);\n  assert( (info.nData+(pPage->intKey?0:info.nKey))==info.nPayload );\n  if( info.iOverflow ){\n    Pgno ovfl = get4byte(&pCell[info.iOverflow]);\n    ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);\n  }\n}\n#endif\n\n\n/*\n** Defragment the page given.  All Cells are moved to the\n** end of the page and all free space is collected into one\n** big FreeBlk that occurs in between the header and cell\n** pointer array and the cell content area.\n*/\nstatic int defragmentPage(MemPage *pPage){\n  int i;                     /* Loop counter */\n  int pc;                    /* Address of a i-th cell */\n  int hdr;                   /* Offset to the page header */\n  int size;                  /* Size of a cell */\n  int usableSize;            /* Number of usable bytes on a page */\n  int cellOffset;            /* Offset to the cell pointer array */\n  int cbrk;                  /* Offset to the cell content area */\n  int nCell;                 /* Number of cells on the page */\n  unsigned char *data;       /* The page data */\n  unsigned char *temp;       /* Temp area for cell content */\n  int iCellFirst;            /* First allowable cell index */\n  int iCellLast;             /* Last possible cell index */\n\n\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );\n  assert( pPage->nOverflow==0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  temp = sqlite3PagerTempSpace(pPage->pBt->pPager);\n  data = pPage->aData;\n  hdr = pPage->hdrOffset;\n  cellOffset = pPage->cellOffset;\n  nCell = pPage->nCell;\n  assert( nCell==get2byte(&data[hdr+3]) );\n  usableSize = pPage->pBt->usableSize;\n  cbrk = get2byte(&data[hdr+5]);\n  memcpy(&temp[cbrk], &data[cbrk], usableSize - cbrk);\n  cbrk = usableSize;\n  iCellFirst = cellOffset + 2*nCell;\n  iCellLast = usableSize - 4;\n  for(i=0; i<nCell; i++){\n    u8 *pAddr;     /* The i-th cell pointer */\n    pAddr = &data[cellOffset + i*2];\n    pc = get2byte(pAddr);\n    testcase( pc==iCellFirst );\n    testcase( pc==iCellLast );\n#if !defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n    /* These conditions have already been verified in btreeInitPage()\n    ** if SQLITE_ENABLE_OVERSIZE_CELL_CHECK is defined \n    */\n    if( pc<iCellFirst || pc>iCellLast ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n#endif\n    assert( pc>=iCellFirst && pc<=iCellLast );\n    size = cellSizePtr(pPage, &temp[pc]);\n    cbrk -= size;\n#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n    if( cbrk<iCellFirst ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n#else\n    if( cbrk<iCellFirst || pc+size>usableSize ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n#endif\n    assert( cbrk+size<=usableSize && cbrk>=iCellFirst );\n    testcase( cbrk+size==usableSize );\n    testcase( pc+size==usableSize );\n    memcpy(&data[cbrk], &temp[pc], size);\n    put2byte(pAddr, cbrk);\n  }\n  assert( cbrk>=iCellFirst );\n  put2byte(&data[hdr+5], cbrk);\n  data[hdr+1] = 0;\n  data[hdr+2] = 0;\n  data[hdr+7] = 0;\n  memset(&data[iCellFirst], 0, cbrk-iCellFirst);\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  if( cbrk-iCellFirst!=pPage->nFree ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Allocate nByte bytes of space from within the B-Tree page passed\n** as the first argument. Write into *pIdx the index into pPage->aData[]\n** of the first byte of allocated space. Return either SQLITE_OK or\n** an error code (usually SQLITE_CORRUPT).\n**\n** The caller guarantees that there is sufficient space to make the\n** allocation.  This routine might need to defragment in order to bring\n** all the space together, however.  This routine will avoid using\n** the first two bytes past the cell pointer area since presumably this\n** allocation is being made in order to insert a new cell, so we will\n** also end up needing a new cell pointer.\n*/\nstatic int allocateSpace(MemPage *pPage, int nByte, int *pIdx){\n  const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */\n  u8 * const data = pPage->aData;      /* Local cache of pPage->aData */\n  int nFrag;                           /* Number of fragmented bytes on pPage */\n  int top;                             /* First byte of cell content area */\n  int gap;        /* First byte of gap between cell pointers and cell content */\n  int rc;         /* Integer return code */\n  int usableSize; /* Usable size of the page */\n  \n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( nByte>=0 );  /* Minimum cell size is 4 */\n  assert( pPage->nFree>=nByte );\n  assert( pPage->nOverflow==0 );\n  usableSize = pPage->pBt->usableSize;\n  assert( nByte < usableSize-8 );\n\n  nFrag = data[hdr+7];\n  assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );\n  gap = pPage->cellOffset + 2*pPage->nCell;\n  top = get2byteNotZero(&data[hdr+5]);\n  if( gap>top ) return SQLITE_CORRUPT_BKPT;\n  testcase( gap+2==top );\n  testcase( gap+1==top );\n  testcase( gap==top );\n\n  if( nFrag>=60 ){\n    /* Always defragment highly fragmented pages */\n    rc = defragmentPage(pPage);\n    if( rc ) return rc;\n    top = get2byteNotZero(&data[hdr+5]);\n  }else if( gap+2<=top ){\n    /* Search the freelist looking for a free slot big enough to satisfy \n    ** the request. The allocation is made from the first free slot in \n    ** the list that is large enough to accomadate it.\n    */\n    int pc, addr;\n    for(addr=hdr+1; (pc = get2byte(&data[addr]))>0; addr=pc){\n      int size;            /* Size of the free slot */\n      if( pc>usableSize-4 || pc<addr+4 ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n      size = get2byte(&data[pc+2]);\n      if( size>=nByte ){\n        int x = size - nByte;\n        testcase( x==4 );\n        testcase( x==3 );\n        if( x<4 ){\n          /* Remove the slot from the free-list. Update the number of\n          ** fragmented bytes within the page. */\n          memcpy(&data[addr], &data[pc], 2);\n          data[hdr+7] = (u8)(nFrag + x);\n        }else if( size+pc > usableSize ){\n          return SQLITE_CORRUPT_BKPT;\n        }else{\n          /* The slot remains on the free-list. Reduce its size to account\n          ** for the portion used by the new allocation. */\n          put2byte(&data[pc+2], x);\n        }\n        *pIdx = pc + x;\n        return SQLITE_OK;\n      }\n    }\n  }\n\n  /* Check to make sure there is enough space in the gap to satisfy\n  ** the allocation.  If not, defragment.\n  */\n  testcase( gap+2+nByte==top );\n  if( gap+2+nByte>top ){\n    rc = defragmentPage(pPage);\n    if( rc ) return rc;\n    top = get2byteNotZero(&data[hdr+5]);\n    assert( gap+nByte<=top );\n  }\n\n\n  /* Allocate memory from the gap in between the cell pointer array\n  ** and the cell content area.  The btreeInitPage() call has already\n  ** validated the freelist.  Given that the freelist is valid, there\n  ** is no way that the allocation can extend off the end of the page.\n  ** The assert() below verifies the previous sentence.\n  */\n  top -= nByte;\n  put2byte(&data[hdr+5], top);\n  assert( top+nByte <= (int)pPage->pBt->usableSize );\n  *pIdx = top;\n  return SQLITE_OK;\n}\n\n/*\n** Return a section of the pPage->aData to the freelist.\n** The first byte of the new free block is pPage->aDisk[start]\n** and the size of the block is \"size\" bytes.\n**\n** Most of the effort here is involved in coalesing adjacent\n** free blocks into a single big free block.\n*/\nstatic int freeSpace(MemPage *pPage, int start, int size){\n  int addr, pbegin, hdr;\n  int iLast;                        /* Largest possible freeblock offset */\n  unsigned char *data = pPage->aData;\n\n  assert( pPage->pBt!=0 );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( start>=pPage->hdrOffset+6+pPage->childPtrSize );\n  assert( (start + size) <= (int)pPage->pBt->usableSize );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( size>=0 );   /* Minimum cell size is 4 */\n\n  if( pPage->pBt->btsFlags & BTS_SECURE_DELETE ){\n    /* Overwrite deleted information with zeros when the secure_delete\n    ** option is enabled */\n    memset(&data[start], 0, size);\n  }\n\n  /* Add the space back into the linked list of freeblocks.  Note that\n  ** even though the freeblock list was checked by btreeInitPage(),\n  ** btreeInitPage() did not detect overlapping cells or\n  ** freeblocks that overlapped cells.   Nor does it detect when the\n  ** cell content area exceeds the value in the page header.  If these\n  ** situations arise, then subsequent insert operations might corrupt\n  ** the freelist.  So we do need to check for corruption while scanning\n  ** the freelist.\n  */\n  hdr = pPage->hdrOffset;\n  addr = hdr + 1;\n  iLast = pPage->pBt->usableSize - 4;\n  assert( start<=iLast );\n  while( (pbegin = get2byte(&data[addr]))<start && pbegin>0 ){\n    if( pbegin<addr+4 ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n    addr = pbegin;\n  }\n  if( pbegin>iLast ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( pbegin>addr || pbegin==0 );\n  put2byte(&data[addr], start);\n  put2byte(&data[start], pbegin);\n  put2byte(&data[start+2], size);\n  pPage->nFree = pPage->nFree + (u16)size;\n\n  /* Coalesce adjacent free blocks */\n  addr = hdr + 1;\n  while( (pbegin = get2byte(&data[addr]))>0 ){\n    int pnext, psize, x;\n    assert( pbegin>addr );\n    assert( pbegin <= (int)pPage->pBt->usableSize-4 );\n    pnext = get2byte(&data[pbegin]);\n    psize = get2byte(&data[pbegin+2]);\n    if( pbegin + psize + 3 >= pnext && pnext>0 ){\n      int frag = pnext - (pbegin+psize);\n      if( (frag<0) || (frag>(int)data[hdr+7]) ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n      data[hdr+7] -= (u8)frag;\n      x = get2byte(&data[pnext]);\n      put2byte(&data[pbegin], x);\n      x = pnext + get2byte(&data[pnext+2]) - pbegin;\n      put2byte(&data[pbegin+2], x);\n    }else{\n      addr = pbegin;\n    }\n  }\n\n  /* If the cell content area begins with a freeblock, remove it. */\n  if( data[hdr+1]==data[hdr+5] && data[hdr+2]==data[hdr+6] ){\n    int top;\n    pbegin = get2byte(&data[hdr+1]);\n    memcpy(&data[hdr+1], &data[pbegin], 2);\n    top = get2byte(&data[hdr+5]) + get2byte(&data[pbegin+2]);\n    put2byte(&data[hdr+5], top);\n  }\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  return SQLITE_OK;\n}\n\n/*\n** Decode the flags byte (the first byte of the header) for a page\n** and initialize fields of the MemPage structure accordingly.\n**\n** Only the following combinations are supported.  Anything different\n** indicates a corrupt database files:\n**\n**         PTF_ZERODATA\n**         PTF_ZERODATA | PTF_LEAF\n**         PTF_LEAFDATA | PTF_INTKEY\n**         PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF\n*/\nstatic int decodeFlags(MemPage *pPage, int flagByte){\n  BtShared *pBt;     /* A copy of pPage->pBt */\n\n  assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->leaf = (u8)(flagByte>>3);  assert( PTF_LEAF == 1<<3 );\n  flagByte &= ~PTF_LEAF;\n  pPage->childPtrSize = 4-4*pPage->leaf;\n  pBt = pPage->pBt;\n  if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){\n    pPage->intKey = 1;\n    pPage->hasData = pPage->leaf;\n    pPage->maxLocal = pBt->maxLeaf;\n    pPage->minLocal = pBt->minLeaf;\n  }else if( flagByte==PTF_ZERODATA ){\n    pPage->intKey = 0;\n    pPage->hasData = 0;\n    pPage->maxLocal = pBt->maxLocal;\n    pPage->minLocal = pBt->minLocal;\n  }else{\n    return SQLITE_CORRUPT_BKPT;\n  }\n  pPage->max1bytePayload = pBt->max1bytePayload;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the auxiliary information for a disk block.\n**\n** Return SQLITE_OK on success.  If we see that the page does\n** not contain a well-formed database page, then return \n** SQLITE_CORRUPT.  Note that a return of SQLITE_OK does not\n** guarantee that the page is well-formed.  It only shows that\n** we failed to detect any corruption.\n*/\nstatic int btreeInitPage(MemPage *pPage){\n\n  assert( pPage->pBt!=0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );\n  assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );\n  assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );\n\n  if( !pPage->isInit ){\n    u16 pc;            /* Address of a freeblock within pPage->aData[] */\n    u8 hdr;            /* Offset to beginning of page header */\n    u8 *data;          /* Equal to pPage->aData */\n    BtShared *pBt;        /* The main btree structure */\n    int usableSize;    /* Amount of usable space on each page */\n    u16 cellOffset;    /* Offset from start of page to first cell pointer */\n    int nFree;         /* Number of unused bytes on the page */\n    int top;           /* First byte of the cell content area */\n    int iCellFirst;    /* First allowable cell or freeblock offset */\n    int iCellLast;     /* Last possible cell or freeblock offset */\n\n    pBt = pPage->pBt;\n\n    hdr = pPage->hdrOffset;\n    data = pPage->aData;\n    if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;\n    assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n    pPage->maskPage = (u16)(pBt->pageSize - 1);\n    pPage->nOverflow = 0;\n    usableSize = pBt->usableSize;\n    pPage->cellOffset = cellOffset = hdr + 12 - 4*pPage->leaf;\n    pPage->aDataEnd = &data[usableSize];\n    pPage->aCellIdx = &data[cellOffset];\n    top = get2byteNotZero(&data[hdr+5]);\n    pPage->nCell = get2byte(&data[hdr+3]);\n    if( pPage->nCell>MX_CELL(pBt) ){\n      /* To many cells for a single page.  The page must be corrupt */\n      return SQLITE_CORRUPT_BKPT;\n    }\n    testcase( pPage->nCell==MX_CELL(pBt) );\n\n    /* A malformed database page might cause us to read past the end\n    ** of page when parsing a cell.  \n    **\n    ** The following block of code checks early to see if a cell extends\n    ** past the end of a page boundary and causes SQLITE_CORRUPT to be \n    ** returned if it does.\n    */\n    iCellFirst = cellOffset + 2*pPage->nCell;\n    iCellLast = usableSize - 4;\n#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n    {\n      int i;            /* Index into the cell pointer array */\n      int sz;           /* Size of a cell */\n\n      if( !pPage->leaf ) iCellLast--;\n      for(i=0; i<pPage->nCell; i++){\n        pc = get2byte(&data[cellOffset+i*2]);\n        testcase( pc==iCellFirst );\n        testcase( pc==iCellLast );\n        if( pc<iCellFirst || pc>iCellLast ){\n          return SQLITE_CORRUPT_BKPT;\n        }\n        sz = cellSizePtr(pPage, &data[pc]);\n        testcase( pc+sz==usableSize );\n        if( pc+sz>usableSize ){\n          return SQLITE_CORRUPT_BKPT;\n        }\n      }\n      if( !pPage->leaf ) iCellLast++;\n    }  \n#endif\n\n    /* Compute the total free space on the page */\n    pc = get2byte(&data[hdr+1]);\n    nFree = data[hdr+7] + top;\n    while( pc>0 ){\n      u16 next, size;\n      if( pc<iCellFirst || pc>iCellLast ){\n        /* Start of free block is off the page */\n        return SQLITE_CORRUPT_BKPT; \n      }\n      next = get2byte(&data[pc]);\n      size = get2byte(&data[pc+2]);\n      if( (next>0 && next<=pc+size+3) || pc+size>usableSize ){\n        /* Free blocks must be in ascending order. And the last byte of\n        ** the free-block must lie on the database page.  */\n        return SQLITE_CORRUPT_BKPT; \n      }\n      nFree = nFree + size;\n      pc = next;\n    }\n\n    /* At this point, nFree contains the sum of the offset to the start\n    ** of the cell-content area plus the number of free bytes within\n    ** the cell-content area. If this is greater than the usable-size\n    ** of the page, then the page must be corrupted. This check also\n    ** serves to verify that the offset to the start of the cell-content\n    ** area, according to the page header, lies within the page.\n    */\n    if( nFree>usableSize ){\n      return SQLITE_CORRUPT_BKPT; \n    }\n    pPage->nFree = (u16)(nFree - iCellFirst);\n    pPage->isInit = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set up a raw page so that it looks like a database page holding\n** no entries.\n*/\nstatic void zeroPage(MemPage *pPage, int flags){\n  unsigned char *data = pPage->aData;\n  BtShared *pBt = pPage->pBt;\n  u8 hdr = pPage->hdrOffset;\n  u16 first;\n\n  assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage) == data );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->btsFlags & BTS_SECURE_DELETE ){\n    memset(&data[hdr], 0, pBt->usableSize - hdr);\n  }\n  data[hdr] = (char)flags;\n  first = hdr + 8 + 4*((flags&PTF_LEAF)==0 ?1:0);\n  memset(&data[hdr+1], 0, 4);\n  data[hdr+7] = 0;\n  put2byte(&data[hdr+5], pBt->usableSize);\n  pPage->nFree = (u16)(pBt->usableSize - first);\n  decodeFlags(pPage, flags);\n  pPage->hdrOffset = hdr;\n  pPage->cellOffset = first;\n  pPage->aDataEnd = &data[pBt->usableSize];\n  pPage->aCellIdx = &data[first];\n  pPage->nOverflow = 0;\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nCell = 0;\n  pPage->isInit = 1;\n}\n\n\n/*\n** Convert a DbPage obtained from the pager into a MemPage used by\n** the btree layer.\n*/\nstatic MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared *pBt){\n  MemPage *pPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  pPage->aData = sqlite3PagerGetData(pDbPage);\n  pPage->pDbPage = pDbPage;\n  pPage->pBt = pBt;\n  pPage->pgno = pgno;\n  pPage->hdrOffset = pPage->pgno==1 ? 100 : 0;\n  return pPage; \n}\n\n/*\n** Get a page from the pager.  Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.\n**\n** If the noContent flag is set, it means that we do not care about\n** the content of the page at this time.  So do not go to the disk\n** to fetch the content.  Just fill in the content with zeros for now.\n** If in the future we call sqlite3PagerWrite() on this page, that\n** means we have started to be concerned about content and the disk\n** read should occur at that point.\n*/\nstatic int btreeGetPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int noContent,       /* Do not load page content if true */\n  int bReadonly        /* True if a read-only (mmap) page is ok */\n){\n  int rc;\n  DbPage *pDbPage;\n  int flags = (noContent ? PAGER_ACQUIRE_NOCONTENT : 0) \n            | (bReadonly ? PAGER_ACQUIRE_READONLY : 0);\n\n  assert( noContent==0 || bReadonly==0 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  rc = sqlite3PagerAcquire(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);\n  if( rc ) return rc;\n  *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a page from the pager cache. If the requested page is not\n** already in the pager cache return NULL. Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.\n*/\nstatic MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);\n  if( pDbPage ){\n    return btreePageFromDbPage(pDbPage, pgno, pBt);\n  }\n  return 0;\n}\n\n/*\n** Return the size of the database file in pages. If there is any kind of\n** error, return ((unsigned int)-1).\n*/\nstatic Pgno btreePagecount(BtShared *pBt){\n  return pBt->nPage;\n}\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( ((p->pBt->nPage)&0x8000000)==0 );\n  return (int)btreePagecount(p->pBt);\n}\n\n/*\n** Get a page from the pager and initialize it.  This routine is just a\n** convenience wrapper around separate calls to btreeGetPage() and \n** btreeInitPage().\n**\n** If an error occurs, then the value *ppPage is set to is undefined. It\n** may remain unchanged, or it may be set to an invalid value.\n*/\nstatic int getAndInitPage(\n  BtShared *pBt,                  /* The database file */\n  Pgno pgno,                      /* Number of the page to get */\n  MemPage **ppPage,               /* Write the page pointer here */\n  int bReadonly                   /* True if a read-only (mmap) page is ok */\n){\n  int rc;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  if( pgno>btreePagecount(pBt) ){\n    rc = SQLITE_CORRUPT_BKPT;\n  }else{\n    rc = btreeGetPage(pBt, pgno, ppPage, 0, bReadonly);\n    if( rc==SQLITE_OK ){\n      rc = btreeInitPage(*ppPage);\n      if( rc!=SQLITE_OK ){\n        releasePage(*ppPage);\n      }\n    }\n  }\n\n  testcase( pgno==0 );\n  assert( pgno!=0 || rc==SQLITE_CORRUPT );\n  return rc;\n}\n\n/*\n** Release a MemPage.  This should be called once for each prior\n** call to btreeGetPage.\n*/\nstatic void releasePage(MemPage *pPage){\n  if( pPage ){\n    assert( pPage->aData );\n    assert( pPage->pBt );\n    assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n    assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n    assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n    sqlite3PagerUnref(pPage->pDbPage);\n  }\n}\n\n/*\n** During a rollback, when the pager reloads information into the cache\n** so that the cache is restored to its original state at the start of\n** the transaction, for each page restored this routine is called.\n**\n** This routine needs to reset the extra data section at the end of the\n** page to agree with the restored data.\n*/\nstatic void pageReinit(DbPage *pData){\n  MemPage *pPage;\n  pPage = (MemPage *)sqlite3PagerGetExtra(pData);\n  assert( sqlite3PagerPageRefcount(pData)>0 );\n  if( pPage->isInit ){\n    assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n    pPage->isInit = 0;\n    if( sqlite3PagerPageRefcount(pData)>1 ){\n      /* pPage might not be a btree page;  it might be an overflow page\n      ** or ptrmap page or a free page.  In those cases, the following\n      ** call to btreeInitPage() will likely return SQLITE_CORRUPT.\n      ** But no harm is done by this.  And it is very important that\n      ** btreeInitPage() be called on every btree page so we make\n      ** the call for every page that comes in for re-initing. */\n      btreeInitPage(pPage);\n    }\n  }\n}\n\n/*\n** Invoke the busy handler for a btree.\n*/\nstatic int btreeInvokeBusyHandler(void *pArg){\n  BtShared *pBt = (BtShared*)pArg;\n  assert( pBt->db );\n  assert( sqlite3_mutex_held(pBt->db->mutex) );\n  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);\n}\n\n/*\n** Open a database file.\n** \n** zFilename is the name of the database file.  If zFilename is NULL\n** then an ephemeral database is created.  The ephemeral database might\n** be exclusively in memory, or it might use a disk-based memory cache.\n** Either way, the ephemeral database will be automatically deleted \n** when sqlite3BtreeClose() is called.\n**\n** If zFilename is \":memory:\" then an in-memory database is created\n** that is automatically destroyed when it is closed.\n**\n** The \"flags\" parameter is a bitmask that might contain bits like\n** BTREE_OMIT_JOURNAL and/or BTREE_MEMORY.\n**\n** If the database is already opened in the same database connection\n** and we are in shared cache mode, then the open will fail with an\n** SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared\n** objects in the same database connection since doing so will lead\n** to problems with locking.\n*/\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,      /* VFS to use for this b-tree */\n  const char *zFilename,  /* Name of the file containing the BTree database */\n  sqlite3 *db,            /* Associated database handle */\n  Btree **ppBtree,        /* Pointer to new Btree object written here */\n  int flags,              /* Options */\n  int vfsFlags            /* Flags passed through to sqlite3_vfs.xOpen() */\n){\n  BtShared *pBt = 0;             /* Shared part of btree structure */\n  Btree *p;                      /* Handle to return */\n  sqlite3_mutex *mutexOpen = 0;  /* Prevents a race condition. Ticket #3537 */\n  int rc = SQLITE_OK;            /* Result code from this function */\n  u8 nReserve;                   /* Byte of unused space on each page */\n  unsigned char zDbHeader[100];  /* Database header content */\n\n  /* True if opening an ephemeral, temporary database */\n  const int isTempDb = zFilename==0 || zFilename[0]==0;\n\n  /* Set the variable isMemdb to true for an in-memory database, or \n  ** false for a file-based database.\n  */\n#ifdef SQLITE_OMIT_MEMORYDB\n  const int isMemdb = 0;\n#else\n  const int isMemdb = (zFilename && strcmp(zFilename, \":memory:\")==0)\n                       || (isTempDb && sqlite3TempInMemory(db))\n                       || (vfsFlags & SQLITE_OPEN_MEMORY)!=0;\n#endif\n\n  assert( db!=0 );\n  assert( pVfs!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( (flags&0xff)==flags );   /* flags fit in 8 bits */\n\n  /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */\n  assert( (flags & BTREE_UNORDERED)==0 || (flags & BTREE_SINGLE)!=0 );\n\n  /* A BTREE_SINGLE database is always a temporary and/or ephemeral */\n  assert( (flags & BTREE_SINGLE)==0 || isTempDb );\n\n  if( isMemdb ){\n    flags |= BTREE_MEMORY;\n  }\n  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){\n    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;\n  }\n  p = sqlite3MallocZero(sizeof(Btree));\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  p->inTrans = TRANS_NONE;\n  p->db = db;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  p->lock.pBtree = p;\n  p->lock.iTable = 1;\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /*\n  ** If this Btree is a candidate for shared cache, try to find an\n  ** existing BtShared object that we can share with\n  */\n  if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){\n    if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){\n      int nFullPathname = pVfs->mxPathname+1;\n      char *zFullPathname = sqlite3Malloc(nFullPathname);\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n      p->sharable = 1;\n      if( !zFullPathname ){\n        sqlite3_free(p);\n        return SQLITE_NOMEM;\n      }\n      if( isMemdb ){\n        memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1);\n      }else{\n        rc = sqlite3OsFullPathname(pVfs, zFilename,\n                                   nFullPathname, zFullPathname);\n        if( rc ){\n          sqlite3_free(zFullPathname);\n          sqlite3_free(p);\n          return rc;\n        }\n      }\n#if SQLITE_THREADSAFE\n      mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);\n      sqlite3_mutex_enter(mutexOpen);\n      mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n      sqlite3_mutex_enter(mutexShared);\n#endif\n      for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){\n        assert( pBt->nRef>0 );\n        if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager, 0))\n                 && sqlite3PagerVfs(pBt->pPager)==pVfs ){\n          int iDb;\n          for(iDb=db->nDb-1; iDb>=0; iDb--){\n            Btree *pExisting = db->aDb[iDb].pBt;\n            if( pExisting && pExisting->pBt==pBt ){\n              sqlite3_mutex_leave(mutexShared);\n              sqlite3_mutex_leave(mutexOpen);\n              sqlite3_free(zFullPathname);\n              sqlite3_free(p);\n              return SQLITE_CONSTRAINT;\n            }\n          }\n          p->pBt = pBt;\n          pBt->nRef++;\n          break;\n        }\n      }\n      sqlite3_mutex_leave(mutexShared);\n      sqlite3_free(zFullPathname);\n    }\n#ifdef SQLITE_DEBUG\n    else{\n      /* In debug mode, we mark all persistent databases as sharable\n      ** even when they are not.  This exercises the locking code and\n      ** gives more opportunity for asserts(sqlite3_mutex_held())\n      ** statements to find locking problems.\n      */\n      p->sharable = 1;\n    }\n#endif\n  }\n#endif\n  if( pBt==0 ){\n    /*\n    ** The following asserts make sure that structures used by the btree are\n    ** the right size.  This is to guard against size changes that result\n    ** when compiling on a different architecture.\n    */\n    assert( sizeof(i64)==8 || sizeof(i64)==4 );\n    assert( sizeof(u64)==8 || sizeof(u64)==4 );\n    assert( sizeof(u32)==4 );\n    assert( sizeof(u16)==2 );\n    assert( sizeof(Pgno)==4 );\n  \n    pBt = sqlite3MallocZero( sizeof(*pBt) );\n    if( pBt==0 ){\n      rc = SQLITE_NOMEM;\n      goto btree_open_out;\n    }\n    rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,\n                          EXTRA_SIZE, flags, vfsFlags, pageReinit);\n    if( rc==SQLITE_OK ){\n      sqlite3PagerSetMmapLimit(pBt->pPager, db->szMmap);\n      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);\n    }\n    if( rc!=SQLITE_OK ){\n      goto btree_open_out;\n    }\n    pBt->openFlags = (u8)flags;\n    pBt->db = db;\n    sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);\n    p->pBt = pBt;\n  \n    pBt->pCursor = 0;\n    pBt->pPage1 = 0;\n    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;\n#ifdef SQLITE_SECURE_DELETE\n    pBt->btsFlags |= BTS_SECURE_DELETE;\n#endif\n    pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);\n    if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE\n         || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){\n      pBt->pageSize = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the magic name \":memory:\" will create an in-memory database, then\n      ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if\n      ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if\n      ** SQLITE_OMIT_MEMORYDB has been defined, then \":memory:\" is just a\n      ** regular file-name. In this case the auto-vacuum applies as per normal.\n      */\n      if( zFilename && !isMemdb ){\n        pBt->autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM ? 1 : 0);\n        pBt->incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM==2 ? 1 : 0);\n      }\n#endif\n      nReserve = 0;\n    }else{\n      nReserve = zDbHeader[20];\n      pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);\n      pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);\n#endif\n    }\n    rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n    if( rc ) goto btree_open_out;\n    pBt->usableSize = pBt->pageSize - nReserve;\n    assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */\n   \n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n    /* Add the new BtShared object to the linked list sharable BtShareds.\n    */\n    if( p->sharable ){\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n      pBt->nRef = 1;\n      MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)\n      if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){\n        pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);\n        if( pBt->mutex==0 ){\n          rc = SQLITE_NOMEM;\n          db->mallocFailed = 0;\n          goto btree_open_out;\n        }\n      }\n      sqlite3_mutex_enter(mutexShared);\n      pBt->pNext = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt;\n      sqlite3_mutex_leave(mutexShared);\n    }\n#endif\n  }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /* If the new Btree uses a sharable pBtShared, then link the new\n  ** Btree into the list of all sharable Btrees for the same connection.\n  ** The list is kept in ascending order by pBt address.\n  */\n  if( p->sharable ){\n    int i;\n    Btree *pSib;\n    for(i=0; i<db->nDb; i++){\n      if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){\n        while( pSib->pPrev ){ pSib = pSib->pPrev; }\n        if( p->pBt<pSib->pBt ){\n          p->pNext = pSib;\n          p->pPrev = 0;\n          pSib->pPrev = p;\n        }else{\n          while( pSib->pNext && pSib->pNext->pBt<p->pBt ){\n            pSib = pSib->pNext;\n          }\n          p->pNext = pSib->pNext;\n          p->pPrev = pSib;\n          if( p->pNext ){\n            p->pNext->pPrev = p;\n          }\n          pSib->pNext = p;\n        }\n        break;\n      }\n    }\n  }\n#endif\n  *ppBtree = p;\n\nbtree_open_out:\n  if( rc!=SQLITE_OK ){\n    if( pBt && pBt->pPager ){\n      sqlite3PagerClose(pBt->pPager);\n    }\n    sqlite3_free(pBt);\n    sqlite3_free(p);\n    *ppBtree = 0;\n  }else{\n    /* If the B-Tree was successfully opened, set the pager-cache size to the\n    ** default value. Except, when opening on an existing shared pager-cache,\n    ** do not change the pager-cache size.\n    */\n    if( sqlite3BtreeSchema(p, 0, 0)==0 ){\n      sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);\n    }\n  }\n  if( mutexOpen ){\n    assert( sqlite3_mutex_held(mutexOpen) );\n    sqlite3_mutex_leave(mutexOpen);\n  }\n  return rc;\n}\n\n/*\n** Decrement the BtShared.nRef counter.  When it reaches zero,\n** remove the BtShared structure from the sharing list.  Return\n** true if the BtShared.nRef counter reaches zero and return\n** false if it is still positive.\n*/\nstatic int removeFromSharingList(BtShared *pBt){\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )\n  BtShared *pList;\n  int removed = 0;\n\n  assert( sqlite3_mutex_notheld(pBt->mutex) );\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  pBt->nRef--;\n  if( pBt->nRef<=0 ){\n    if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;\n    }else{\n      pList = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      while( ALWAYS(pList) && pList->pNext!=pBt ){\n        pList=pList->pNext;\n      }\n      if( ALWAYS(pList) ){\n        pList->pNext = pBt->pNext;\n      }\n    }\n    if( SQLITE_THREADSAFE ){\n      sqlite3_mutex_free(pBt->mutex);\n    }\n    removed = 1;\n  }\n  sqlite3_mutex_leave(pMaster);\n  return removed;\n#else\n  return 1;\n#endif\n}\n\n/*\n** Make sure pBt->pTmpSpace points to an allocation of \n** MX_CELL_SIZE(pBt) bytes.\n*/\nstatic void allocateTempSpace(BtShared *pBt){\n  if( !pBt->pTmpSpace ){\n    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );\n  }\n}\n\n/*\n** Free the pBt->pTmpSpace allocation\n*/\nstatic void freeTempSpace(BtShared *pBt){\n  sqlite3PageFree( pBt->pTmpSpace);\n  pBt->pTmpSpace = 0;\n}\n\n/*\n** Close an open database and invalidate all cursors.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtCursor *pCur;\n\n  /* Close all cursors opened via this handle.  */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  pCur = pBt->pCursor;\n  while( pCur ){\n    BtCursor *pTmp = pCur;\n    pCur = pCur->pNext;\n    if( pTmp->pBtree==p ){\n      sqlite3BtreeCloseCursor(pTmp);\n    }\n  }\n\n  /* Rollback any active transaction and free the handle structure.\n  ** The call to sqlite3BtreeRollback() drops any table-locks held by\n  ** this handle.\n  */\n  sqlite3BtreeRollback(p, SQLITE_OK);\n  sqlite3BtreeLeave(p);\n\n  /* If there are still other outstanding references to the shared-btree\n  ** structure, return now. The remainder of this procedure cleans \n  ** up the shared-btree.\n  */\n  assert( p->wantToLock==0 && p->locked==0 );\n  if( !p->sharable || removeFromSharingList(pBt) ){\n    /* The pBt is no longer on the sharing list, so we can access\n    ** it without having to hold the mutex.\n    **\n    ** Clean out and delete the BtShared object.\n    */\n    assert( !pBt->pCursor );\n    sqlite3PagerClose(pBt->pPager);\n    if( pBt->xFreeSchema && pBt->pSchema ){\n      pBt->xFreeSchema(pBt->pSchema);\n    }\n    sqlite3DbFree(0, pBt->pSchema);\n    freeTempSpace(pBt);\n    sqlite3_free(pBt);\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  assert( p->wantToLock==0 );\n  assert( p->locked==0 );\n  if( p->pPrev ) p->pPrev->pNext = p->pNext;\n  if( p->pNext ) p->pNext->pPrev = p->pPrev;\n#endif\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the limit on the number of pages allowed in the cache.\n**\n** The maximum number of cache pages is set to the absolute\n** value of mxPage.  If mxPage is negative, the pager will\n** operate asynchronously - it will not stop to do fsync()s\n** to insure data is written to the disk surface before\n** continuing.  Transactions still work if synchronous is off,\n** and the database cannot be corrupted if this program\n** crashes.  But if the operating system crashes or there is\n** an abrupt power failure when synchronous is off, the database\n** could be left in an inconsistent and unrecoverable state.\n** Synchronous is on by default so database corruption is not\n** normally a worry.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetCachesize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the limit on the amount of the database file that may be\n** memory mapped.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetMmapLimit(pBt->pPager, szMmap);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the way data is synced to disk in order to increase or decrease\n** how well the database resists damage due to OS crashes and power\n** failures.  Level 1 is the same as asynchronous (no syncs() occur and\n** there is a high probability of damage)  Level 2 is the default.  There\n** is a very low but non-zero probability of damage.  Level 3 reduces the\n** probability of damage to near zero but with a write performance reduction.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(\n  Btree *p,              /* The btree to set the safety level on */\n  int level,             /* PRAGMA synchronous.  1=OFF, 2=NORMAL, 3=FULL */\n  int fullSync,          /* PRAGMA fullfsync. */\n  int ckptFullSync       /* PRAGMA checkpoint_fullfync */\n){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  assert( level>=1 && level<=3 );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetSafetyLevel(pBt->pPager, level, fullSync, ckptFullSync);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Return TRUE if the given btree is set to safety level 1.  In other\n** words, return TRUE if no sync() occurs on the disk files.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree *p){\n  BtShared *pBt = p->pBt;\n  int rc;\n  assert( sqlite3_mutex_held(p->db->mutex) );  \n  sqlite3BtreeEnter(p);\n  assert( pBt && pBt->pPager );\n  rc = sqlite3PagerNosync(pBt->pPager);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Change the default pages size and the number of reserved bytes per page.\n** Or, if the page size has already been fixed, return SQLITE_READONLY \n** without changing anything.\n**\n** The page size must be a power of 2 between 512 and 65536.  If the page\n** size supplied does not meet this constraint then the page size is not\n** changed.\n**\n** Page sizes are constrained to be a power of two so that the region\n** of the database file used for locking (beginning at PENDING_BYTE,\n** the first byte past the 1GB boundary, 0x40000000) needs to occur\n** at the beginning of a page.\n**\n** If parameter nReserve is less than zero, then the number of reserved\n** bytes per page is left unchanged.\n**\n** If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size\n** and autovacuum mode can no longer be changed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){\n  int rc = SQLITE_OK;\n  BtShared *pBt = p->pBt;\n  assert( nReserve>=-1 && nReserve<=255 );\n  sqlite3BtreeEnter(p);\n  if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){\n    sqlite3BtreeLeave(p);\n    return SQLITE_READONLY;\n  }\n  if( nReserve<0 ){\n    nReserve = pBt->pageSize - pBt->usableSize;\n  }\n  assert( nReserve>=0 && nReserve<=255 );\n  if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&\n        ((pageSize-1)&pageSize)==0 ){\n    assert( (pageSize & 7)==0 );\n    assert( !pBt->pPage1 && !pBt->pCursor );\n    pBt->pageSize = (u32)pageSize;\n    freeTempSpace(pBt);\n  }\n  rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n  pBt->usableSize = pBt->pageSize - (u16)nReserve;\n  if( iFix ) pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Return the currently defined page size\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){\n  return p->pBt->pageSize;\n}\n\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)\n/*\n** This function is similar to sqlite3BtreeGetReserve(), except that it\n** may only be called if it is guaranteed that the b-tree mutex is already\n** held.\n**\n** This is useful in one special case in the backup API code where it is\n** known that the shared b-tree mutex is held, but the mutex on the \n** database handle that owns *p is not. In this case if sqlite3BtreeEnter()\n** were to be called, it might collide with some other operation on the\n** database handle that owns *p, causing undefined behavior.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){\n  assert( sqlite3_mutex_held(p->pBt->mutex) );\n  return p->pBt->pageSize - p->pBt->usableSize;\n}\n#endif /* SQLITE_HAS_CODEC || SQLITE_DEBUG */\n\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)\n/*\n** Return the number of bytes of space at the end of every page that\n** are intentually left unused.  This is the \"reserved\" space that is\n** sometimes used by extensions.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree *p){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = p->pBt->pageSize - p->pBt->usableSize;\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n/*\n** Set the maximum page count for a database if mxPage is positive.\n** No changes are made if mxPage is 0 or negative.\n** Regardless of the value of mxPage, return the maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n/*\n** Set the BTS_SECURE_DELETE flag if newFlag is 0 or 1.  If newFlag is -1,\n** then make no changes.  Always return the value of the BTS_SECURE_DELETE\n** setting after the change.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){\n  int b;\n  if( p==0 ) return 0;\n  sqlite3BtreeEnter(p);\n  if( newFlag>=0 ){\n    p->pBt->btsFlags &= ~BTS_SECURE_DELETE;\n    if( newFlag ) p->pBt->btsFlags |= BTS_SECURE_DELETE;\n  } \n  b = (p->pBt->btsFlags & BTS_SECURE_DELETE)!=0;\n  sqlite3BtreeLeave(p);\n  return b;\n}\n#endif /* !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM) */\n\n/*\n** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'\n** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it\n** is disabled. The default value for the auto-vacuum property is \n** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return SQLITE_READONLY;\n#else\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n  u8 av = (u8)autoVacuum;\n\n  sqlite3BtreeEnter(p);\n  if( (pBt->btsFlags & BTS_PAGESIZE_FIXED)!=0 && (av ?1:0)!=pBt->autoVacuum ){\n    rc = SQLITE_READONLY;\n  }else{\n    pBt->autoVacuum = av ?1:0;\n    pBt->incrVacuum = av==2 ?1:0;\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** Return the value of the 'auto-vacuum' property. If auto-vacuum is \n** enabled 1 is returned. Otherwise 0.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return BTREE_AUTOVACUUM_NONE;\n#else\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = (\n    (!p->pBt->autoVacuum)?BTREE_AUTOVACUUM_NONE:\n    (!p->pBt->incrVacuum)?BTREE_AUTOVACUUM_FULL:\n    BTREE_AUTOVACUUM_INCR\n  );\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n\n/*\n** Get a reference to pPage1 of the database file.  This will\n** also acquire a readlock on that file.\n**\n** SQLITE_OK is returned on success.  If the file is not a\n** well-formed database file, then SQLITE_CORRUPT is returned.\n** SQLITE_BUSY is returned if the database is locked.  SQLITE_NOMEM\n** is returned if we run out of memory. \n*/\nstatic int lockBtree(BtShared *pBt){\n  int rc;              /* Result code from subfunctions */\n  MemPage *pPage1;     /* Page 1 of the database file */\n  int nPage;           /* Number of pages in the database */\n  int nPageFile = 0;   /* Number of pages in the database file */\n  int nPageHeader;     /* Number of pages in the database according to hdr */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pBt->pPage1==0 );\n  rc = sqlite3PagerSharedLock(pBt->pPager);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = btreeGetPage(pBt, 1, &pPage1, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Do some checking to help insure the file we opened really is\n  ** a valid database file. \n  */\n  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);\n  sqlite3PagerPagecount(pBt->pPager, &nPageFile);\n  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){\n    nPage = nPageFile;\n  }\n  if( nPage>0 ){\n    u32 pageSize;\n    u32 usableSize;\n    u8 *page1 = pPage1->aData;\n    rc = SQLITE_NOTADB;\n    if( memcmp(page1, zMagicHeader, 16)!=0 ){\n      goto page1_init_failed;\n    }\n\n#ifdef SQLITE_OMIT_WAL\n    if( page1[18]>1 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>1 ){\n      goto page1_init_failed;\n    }\n#else\n    if( page1[18]>2 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>2 ){\n      goto page1_init_failed;\n    }\n\n    /* If the write version is set to 2, this database should be accessed\n    ** in WAL mode. If the log is not already open, open it now. Then \n    ** return SQLITE_OK and return without populating BtShared.pPage1.\n    ** The caller detects this and calls this function again. This is\n    ** required as the version of page 1 currently in the page1 buffer\n    ** may not be the latest version - there may be a newer one in the log\n    ** file.\n    */\n    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){\n      int isOpen = 0;\n      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);\n      if( rc!=SQLITE_OK ){\n        goto page1_init_failed;\n      }else if( isOpen==0 ){\n        releasePage(pPage1);\n        return SQLITE_OK;\n      }\n      rc = SQLITE_NOTADB;\n    }\n#endif\n\n    /* The maximum embedded fraction must be exactly 25%.  And the minimum\n    ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data.\n    ** The original design allowed these amounts to vary, but as of\n    ** version 3.6.0, we require them to be fixed.\n    */\n    if( memcmp(&page1[21], \"\\100\\040\\040\",3)!=0 ){\n      goto page1_init_failed;\n    }\n    pageSize = (page1[16]<<8) | (page1[17]<<16);\n    if( ((pageSize-1)&pageSize)!=0\n     || pageSize>SQLITE_MAX_PAGE_SIZE \n     || pageSize<=256 \n    ){\n      goto page1_init_failed;\n    }\n    assert( (pageSize & 7)==0 );\n    usableSize = pageSize - page1[20];\n    if( (u32)pageSize!=pBt->pageSize ){\n      /* After reading the first page of the database assuming a page size\n      ** of BtShared.pageSize, we have discovered that the page-size is\n      ** actually pageSize. Unlock the database, leave pBt->pPage1 at\n      ** zero and return SQLITE_OK. The caller will call this function\n      ** again with the correct page-size.\n      */\n      releasePage(pPage1);\n      pBt->usableSize = usableSize;\n      pBt->pageSize = pageSize;\n      freeTempSpace(pBt);\n      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,\n                                   pageSize-usableSize);\n      return rc;\n    }\n    if( (pBt->db->flags & SQLITE_RecoveryMode)==0 && nPage>nPageFile ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto page1_init_failed;\n    }\n    if( usableSize<480 ){\n      goto page1_init_failed;\n    }\n    pBt->pageSize = pageSize;\n    pBt->usableSize = usableSize;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);\n    pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);\n#endif\n  }\n\n  /* maxLocal is the maximum amount of payload to store locally for\n  ** a cell.  Make sure it is small enough so that at least minFanout\n  ** cells can will fit on one page.  We assume a 10-byte page header.\n  ** Besides the payload, the cell must store:\n  **     2-byte pointer to the cell\n  **     4-byte child pointer\n  **     9-byte nKey value\n  **     4-byte nData value\n  **     4-byte overflow page pointer\n  ** So a cell consists of a 2-byte pointer, a header which is as much as\n  ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow\n  ** page pointer.\n  */\n  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);\n  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);\n  pBt->maxLeaf = (u16)(pBt->usableSize - 35);\n  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);\n  if( pBt->maxLocal>127 ){\n    pBt->max1bytePayload = 127;\n  }else{\n    pBt->max1bytePayload = (u8)pBt->maxLocal;\n  }\n  assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );\n  pBt->pPage1 = pPage1;\n  pBt->nPage = nPage;\n  return SQLITE_OK;\n\npage1_init_failed:\n  releasePage(pPage1);\n  pBt->pPage1 = 0;\n  return rc;\n}\n\n#ifndef NDEBUG\n/*\n** Return the number of cursors open on pBt. This is for use\n** in assert() expressions, so it is only compiled if NDEBUG is not\n** defined.\n**\n** Only write cursors are counted if wrOnly is true.  If wrOnly is\n** false then all cursors are counted.\n**\n** For the purposes of this routine, a cursor is any cursor that\n** is capable of reading or writing to the databse.  Cursors that\n** have been tripped into the CURSOR_FAULT state are not counted.\n*/\nstatic int countValidCursors(BtShared *pBt, int wrOnly){\n  BtCursor *pCur;\n  int r = 0;\n  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){\n    if( (wrOnly==0 || pCur->wrFlag) && pCur->eState!=CURSOR_FAULT ) r++; \n  }\n  return r;\n}\n#endif\n\n/*\n** If there are no outstanding cursors and we are not in the middle\n** of a transaction but there is a read lock on the database, then\n** this routine unrefs the first page of the database file which \n** has the effect of releasing the read lock.\n**\n** If there is a transaction in progress, this routine is a no-op.\n*/\nstatic void unlockBtreeIfUnused(BtShared *pBt){\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );\n  if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){\n    assert( pBt->pPage1->aData );\n    assert( sqlite3PagerRefcount(pBt->pPager)==1 );\n    assert( pBt->pPage1->aData );\n    releasePage(pBt->pPage1);\n    pBt->pPage1 = 0;\n  }\n}\n\n/*\n** If pBt points to an empty file then convert that empty file\n** into a new empty database by initializing the first page of\n** the database.\n*/\nstatic int newDatabase(BtShared *pBt){\n  MemPage *pP1;\n  unsigned char *data;\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->nPage>0 ){\n    return SQLITE_OK;\n  }\n  pP1 = pBt->pPage1;\n  assert( pP1!=0 );\n  data = pP1->aData;\n  rc = sqlite3PagerWrite(pP1->pDbPage);\n  if( rc ) return rc;\n  memcpy(data, zMagicHeader, sizeof(zMagicHeader));\n  assert( sizeof(zMagicHeader)==16 );\n  data[16] = (u8)((pBt->pageSize>>8)&0xff);\n  data[17] = (u8)((pBt->pageSize>>16)&0xff);\n  data[18] = 1;\n  data[19] = 1;\n  assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);\n  data[20] = (u8)(pBt->pageSize - pBt->usableSize);\n  data[21] = 64;\n  data[22] = 32;\n  data[23] = 32;\n  memset(&data[24], 0, 100-24);\n  zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );\n  pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );\n  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );\n  put4byte(&data[36 + 4*4], pBt->autoVacuum);\n  put4byte(&data[36 + 7*4], pBt->incrVacuum);\n#endif\n  pBt->nPage = 1;\n  data[31] = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the first page of the database file (creating a database\n** consisting of a single page and no schema objects). Return SQLITE_OK\n** if successful, or an SQLite error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  p->pBt->nPage = 0;\n  rc = newDatabase(p->pBt);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Attempt to start a new transaction. A write-transaction\n** is started if the second argument is nonzero, otherwise a read-\n** transaction.  If the second argument is 2 or more and exclusive\n** transaction is started, meaning that no other process is allowed\n** to access the database.  A preexisting transaction may not be\n** upgraded to exclusive by calling this routine a second time - the\n** exclusivity flag only works for a new transaction.\n**\n** A write-transaction must be started before attempting any \n** changes to the database.  None of the following routines \n** will work unless a transaction is started first:\n**\n**      sqlite3BtreeCreateTable()\n**      sqlite3BtreeCreateIndex()\n**      sqlite3BtreeClearTable()\n**      sqlite3BtreeDropTable()\n**      sqlite3BtreeInsert()\n**      sqlite3BtreeDelete()\n**      sqlite3BtreeUpdateMeta()\n**\n** If an initial attempt to acquire the lock fails because of lock contention\n** and the database was previously unlocked, then invoke the busy handler\n** if there is one.  But if there was previously a read-lock, do not\n** invoke the busy handler - just return SQLITE_BUSY.  SQLITE_BUSY is \n** returned when there is already a read-lock in order to avoid a deadlock.\n**\n** Suppose there are two processes A and B.  A has a read lock and B has\n** a reserved lock.  B tries to promote to exclusive but is blocked because\n** of A's read lock.  A tries to promote to reserved but is blocked by B.\n** One or the other of the two processes must give way or there can be\n** no progress.  By returning SQLITE_BUSY and not invoking the busy callback\n** when A already has a read lock, we encourage A to give up and let B\n** proceed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){\n  sqlite3 *pBlock = 0;\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the btree is already in a write-transaction, or it\n  ** is already in a read-transaction and a read-transaction\n  ** is requested, this is a no-op.\n  */\n  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){\n    goto trans_begun;\n  }\n  assert( IfNotOmitAV(pBt->bDoTruncate)==0 );\n\n  /* Write transactions are not possible on a read-only database */\n  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){\n    rc = SQLITE_READONLY;\n    goto trans_begun;\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  /* If another database handle has already opened a write transaction \n  ** on this shared-btree structure and a second write transaction is\n  ** requested, return SQLITE_LOCKED.\n  */\n  if( (wrflag && pBt->inTransaction==TRANS_WRITE)\n   || (pBt->btsFlags & BTS_PENDING)!=0\n  ){\n    pBlock = pBt->pWriter->db;\n  }else if( wrflag>1 ){\n    BtLock *pIter;\n    for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n      if( pIter->pBtree!=p ){\n        pBlock = pIter->pBtree->db;\n        break;\n      }\n    }\n  }\n  if( pBlock ){\n    sqlite3ConnectionBlocked(p->db, pBlock);\n    rc = SQLITE_LOCKED_SHAREDCACHE;\n    goto trans_begun;\n  }\n#endif\n\n  /* Any read-only or read-write transaction implies a read-lock on \n  ** page 1. So if some other shared-cache client already has a write-lock \n  ** on page 1, the transaction cannot be opened. */\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  if( SQLITE_OK!=rc ) goto trans_begun;\n\n  pBt->btsFlags &= ~BTS_INITIALLY_EMPTY;\n  if( pBt->nPage==0 ) pBt->btsFlags |= BTS_INITIALLY_EMPTY;\n  do {\n    /* Call lockBtree() until either pBt->pPage1 is populated or\n    ** lockBtree() returns something other than SQLITE_OK. lockBtree()\n    ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after\n    ** reading page 1 it discovers that the page-size of the database \n    ** file is not pBt->pageSize. In this case lockBtree() will update\n    ** pBt->pageSize to the page-size of the file on disk.\n    */\n    while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );\n\n    if( rc==SQLITE_OK && wrflag ){\n      if( (pBt->btsFlags & BTS_READ_ONLY)!=0 ){\n        rc = SQLITE_READONLY;\n      }else{\n        rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));\n        if( rc==SQLITE_OK ){\n          rc = newDatabase(pBt);\n        }\n      }\n    }\n  \n    if( rc!=SQLITE_OK ){\n      unlockBtreeIfUnused(pBt);\n    }\n  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&\n          btreeInvokeBusyHandler(pBt) );\n\n  if( rc==SQLITE_OK ){\n    if( p->inTrans==TRANS_NONE ){\n      pBt->nTransaction++;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      if( p->sharable ){\n        assert( p->lock.pBtree==p && p->lock.iTable==1 );\n        p->lock.eLock = READ_LOCK;\n        p->lock.pNext = pBt->pLock;\n        pBt->pLock = &p->lock;\n      }\n#endif\n    }\n    p->inTrans = (wrflag?TRANS_WRITE:TRANS_READ);\n    if( p->inTrans>pBt->inTransaction ){\n      pBt->inTransaction = p->inTrans;\n    }\n    if( wrflag ){\n      MemPage *pPage1 = pBt->pPage1;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      assert( !pBt->pWriter );\n      pBt->pWriter = p;\n      pBt->btsFlags &= ~BTS_EXCLUSIVE;\n      if( wrflag>1 ) pBt->btsFlags |= BTS_EXCLUSIVE;\n#endif\n\n      /* If the db-size header field is incorrect (as it may be if an old\n      ** client has been writing the database file), update it now. Doing\n      ** this sooner rather than later means the database size can safely \n      ** re-read the database size from page 1 if a savepoint or transaction\n      ** rollback occurs within the transaction.\n      */\n      if( pBt->nPage!=get4byte(&pPage1->aData[28]) ){\n        rc = sqlite3PagerWrite(pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          put4byte(&pPage1->aData[28], pBt->nPage);\n        }\n      }\n    }\n  }\n\n\ntrans_begun:\n  if( rc==SQLITE_OK && wrflag ){\n    /* This call makes sure that the pager has the correct number of\n    ** open savepoints. If the second parameter is greater than 0 and\n    ** the sub-journal is not already open, then it will be opened here.\n    */\n    rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);\n  }\n\n  btreeIntegrity(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n\n/*\n** Set the pointer-map entries for all children of page pPage. Also, if\n** pPage contains cells that point to overflow pages, set the pointer\n** map entries for the overflow pages as well.\n*/\nstatic int setChildPtrmaps(MemPage *pPage){\n  int i;                             /* Counter variable */\n  int nCell;                         /* Number of cells in page pPage */\n  int rc;                            /* Return code */\n  BtShared *pBt = pPage->pBt;\n  u8 isInitOrig = pPage->isInit;\n  Pgno pgno = pPage->pgno;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  rc = btreeInitPage(pPage);\n  if( rc!=SQLITE_OK ){\n    goto set_child_ptrmaps_out;\n  }\n  nCell = pPage->nCell;\n\n  for(i=0; i<nCell; i++){\n    u8 *pCell = findCell(pPage, i);\n\n    ptrmapPutOvflPtr(pPage, pCell, &rc);\n\n    if( !pPage->leaf ){\n      Pgno childPgno = get4byte(pCell);\n      ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n    }\n  }\n\n  if( !pPage->leaf ){\n    Pgno childPgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n  }\n\nset_child_ptrmaps_out:\n  pPage->isInit = isInitOrig;\n  return rc;\n}\n\n/*\n** Somewhere on pPage is a pointer to page iFrom.  Modify this pointer so\n** that it points to iTo. Parameter eType describes the type of pointer to\n** be modified, as  follows:\n**\n** PTRMAP_BTREE:     pPage is a btree-page. The pointer points at a child \n**                   page of pPage.\n**\n** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow\n**                   page pointed to by one of the cells on pPage.\n**\n** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next\n**                   overflow page in the list.\n*/\nstatic int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  if( eType==PTRMAP_OVERFLOW2 ){\n    /* The pointer is always the first 4 bytes of the page in this case.  */\n    if( get4byte(pPage->aData)!=iFrom ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n    put4byte(pPage->aData, iTo);\n  }else{\n    u8 isInitOrig = pPage->isInit;\n    int i;\n    int nCell;\n\n    btreeInitPage(pPage);\n    nCell = pPage->nCell;\n\n    for(i=0; i<nCell; i++){\n      u8 *pCell = findCell(pPage, i);\n      if( eType==PTRMAP_OVERFLOW1 ){\n        CellInfo info;\n        btreeParseCellPtr(pPage, pCell, &info);\n        if( info.iOverflow\n         && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage\n         && iFrom==get4byte(&pCell[info.iOverflow])\n        ){\n          put4byte(&pCell[info.iOverflow], iTo);\n          break;\n        }\n      }else{\n        if( get4byte(pCell)==iFrom ){\n          put4byte(pCell, iTo);\n          break;\n        }\n      }\n    }\n  \n    if( i==nCell ){\n      if( eType!=PTRMAP_BTREE || \n          get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);\n    }\n\n    pPage->isInit = isInitOrig;\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Move the open database page pDbPage to location iFreePage in the \n** database. The pDbPage reference remains valid.\n**\n** The isCommit flag indicates that there is no need to remember that\n** the journal needs to be sync()ed before database page pDbPage->pgno \n** can be written to. The caller has already promised not to write to that\n** page.\n*/\nstatic int relocatePage(\n  BtShared *pBt,           /* Btree */\n  MemPage *pDbPage,        /* Open page to move */\n  u8 eType,                /* Pointer map 'type' entry for pDbPage */\n  Pgno iPtrPage,           /* Pointer map 'page-no' entry for pDbPage */\n  Pgno iFreePage,          /* The location to move pDbPage to */\n  int isCommit             /* isCommit flag passed to sqlite3PagerMovepage */\n){\n  MemPage *pPtrPage;   /* The page that contains a pointer to pDbPage */\n  Pgno iDbPage = pDbPage->pgno;\n  Pager *pPager = pBt->pPager;\n  int rc;\n\n  assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || \n      eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pDbPage->pBt==pBt );\n\n  /* Move page iDbPage from its current location to page number iFreePage */\n  TRACE((\"AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\\n\", \n      iDbPage, iFreePage, iPtrPage, eType));\n  rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  pDbPage->pgno = iFreePage;\n\n  /* If pDbPage was a btree-page, then it may have child pages and/or cells\n  ** that point to overflow pages. The pointer map entries for all these\n  ** pages need to be changed.\n  **\n  ** If pDbPage is an overflow page, then the first 4 bytes may store a\n  ** pointer to a subsequent overflow page. If this is the case, then\n  ** the pointer map needs to be updated for the subsequent overflow page.\n  */\n  if( eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ){\n    rc = setChildPtrmaps(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }else{\n    Pgno nextOvfl = get4byte(pDbPage->aData);\n    if( nextOvfl!=0 ){\n      ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  /* Fix the database pointer on page iPtrPage that pointed at iDbPage so\n  ** that it points at iFreePage. Also fix the pointer map entry for\n  ** iPtrPage.\n  */\n  if( eType!=PTRMAP_ROOTPAGE ){\n    rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0, 0);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    rc = sqlite3PagerWrite(pPtrPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(pPtrPage);\n      return rc;\n    }\n    rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);\n    releasePage(pPtrPage);\n    if( rc==SQLITE_OK ){\n      ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);\n    }\n  }\n  return rc;\n}\n\n/* Forward declaration required by incrVacuumStep(). */\nstatic int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);\n\n/*\n** Perform a single step of an incremental-vacuum. If successful, return\n** SQLITE_OK. If there is no work to do (and therefore no point in \n** calling this function again), return SQLITE_DONE. Or, if an error \n** occurs, return some other error code.\n**\n** More specificly, this function attempts to re-organize the database so \n** that the last page of the file currently in use is no longer in use.\n**\n** Parameter nFin is the number of pages that this database would contain\n** were this function called until it returns SQLITE_DONE.\n**\n** If the bCommit parameter is non-zero, this function assumes that the \n** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE \n** or an error. bCommit is passed true for an auto-vacuum-on-commmit \n** operation, or false for an incremental vacuum.\n*/\nstatic int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){\n  Pgno nFreeList;           /* Number of pages still on the free-list */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( iLastPg>nFin );\n\n  if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){\n    u8 eType;\n    Pgno iPtrPage;\n\n    nFreeList = get4byte(&pBt->pPage1->aData[36]);\n    if( nFreeList==0 ){\n      return SQLITE_DONE;\n    }\n\n    rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( eType==PTRMAP_ROOTPAGE ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    if( eType==PTRMAP_FREEPAGE ){\n      if( bCommit==0 ){\n        /* Remove the page from the files free-list. This is not required\n        ** if bCommit is non-zero. In that case, the free-list will be\n        ** truncated to zero after this function returns, so it doesn't \n        ** matter if it still contains some garbage entries.\n        */\n        Pgno iFreePg;\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        assert( iFreePg==iLastPg );\n        releasePage(pFreePg);\n      }\n    } else {\n      Pgno iFreePg;             /* Index of free page to move pLastPg to */\n      MemPage *pLastPg;\n      u8 eMode = BTALLOC_ANY;   /* Mode parameter for allocateBtreePage() */\n      Pgno iNear = 0;           /* nearby parameter for allocateBtreePage() */\n\n      rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* If bCommit is zero, this loop runs exactly once and page pLastPg\n      ** is swapped with the first free page pulled off the free list.\n      **\n      ** On the other hand, if bCommit is greater than zero, then keep\n      ** looping until a free-page located within the first nFin pages\n      ** of the file is found.\n      */\n      if( bCommit==0 ){\n        eMode = BTALLOC_LE;\n        iNear = nFin;\n      }\n      do {\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode);\n        if( rc!=SQLITE_OK ){\n          releasePage(pLastPg);\n          return rc;\n        }\n        releasePage(pFreePg);\n      }while( bCommit && iFreePg>nFin );\n      assert( iFreePg<iLastPg );\n      \n      rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, bCommit);\n      releasePage(pLastPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  if( bCommit==0 ){\n    do {\n      iLastPg--;\n    }while( iLastPg==PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg) );\n    pBt->bDoTruncate = 1;\n    pBt->nPage = iLastPg;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The database opened by the first argument is an auto-vacuum database\n** nOrig pages in size containing nFree free pages. Return the expected \n** size of the database in pages following an auto-vacuum operation.\n*/\nstatic Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){\n  int nEntry;                     /* Number of entries on one ptrmap page */\n  Pgno nPtrmap;                   /* Number of PtrMap pages to be freed */\n  Pgno nFin;                      /* Return value */\n\n  nEntry = pBt->usableSize/5;\n  nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry;\n  nFin = nOrig - nFree - nPtrmap;\n  if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n  while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n\n  return nFin;\n}\n\n/*\n** A write-transaction must be opened before calling this function.\n** It performs a single unit of work towards an incremental vacuum.\n**\n** If the incremental vacuum is finished after this function has run,\n** SQLITE_DONE is returned. If it is not finished, but no error occurred,\n** SQLITE_OK is returned. Otherwise an SQLite error code. \n*/\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){\n  int rc;\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );\n  if( !pBt->autoVacuum ){\n    rc = SQLITE_DONE;\n  }else{\n    Pgno nOrig = btreePagecount(pBt);\n    Pgno nFree = get4byte(&pBt->pPage1->aData[36]);\n    Pgno nFin = finalDbSize(pBt, nOrig, nFree);\n\n    if( nOrig<nFin ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else if( nFree>0 ){\n      rc = saveAllCursors(pBt, 0, 0);\n      if( rc==SQLITE_OK ){\n        invalidateAllOverflowCache(pBt);\n        rc = incrVacuumStep(pBt, nFin, nOrig, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        put4byte(&pBt->pPage1->aData[28], pBt->nPage);\n      }\n    }else{\n      rc = SQLITE_DONE;\n    }\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine is called prior to sqlite3PagerCommit when a transaction\n** is commited for an auto-vacuum database.\n**\n** If SQLITE_OK is returned, then *pnTrunc is set to the number of pages\n** the database file should be truncated to during the commit process. \n** i.e. the database has been reorganized so that only the first *pnTrunc\n** pages are in use.\n*/\nstatic int autoVacuumCommit(BtShared *pBt){\n  int rc = SQLITE_OK;\n  Pager *pPager = pBt->pPager;\n  VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager) );\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  invalidateAllOverflowCache(pBt);\n  assert(pBt->autoVacuum);\n  if( !pBt->incrVacuum ){\n    Pgno nFin;         /* Number of pages in database after autovacuuming */\n    Pgno nFree;        /* Number of pages on the freelist initially */\n    Pgno iFree;        /* The next page to be freed */\n    Pgno nOrig;        /* Database size before freeing */\n\n    nOrig = btreePagecount(pBt);\n    if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){\n      /* It is not possible to create a database for which the final page\n      ** is either a pointer-map page or the pending-byte page. If one\n      ** is encountered, this indicates corruption.\n      */\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    nFree = get4byte(&pBt->pPage1->aData[36]);\n    nFin = finalDbSize(pBt, nOrig, nFree);\n    if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT;\n    if( nFin<nOrig ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){\n      rc = incrVacuumStep(pBt, nFin, iFree, 1);\n    }\n    if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){\n      rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n      put4byte(&pBt->pPage1->aData[32], 0);\n      put4byte(&pBt->pPage1->aData[36], 0);\n      put4byte(&pBt->pPage1->aData[28], nFin);\n      pBt->bDoTruncate = 1;\n      pBt->nPage = nFin;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3PagerRollback(pPager);\n    }\n  }\n\n  assert( nRef>=sqlite3PagerRefcount(pPager) );\n  return rc;\n}\n\n#else /* ifndef SQLITE_OMIT_AUTOVACUUM */\n# define setChildPtrmaps(x) SQLITE_OK\n#endif\n\n/*\n** This routine does the first phase of a two-phase commit.  This routine\n** causes a rollback journal to be created (if it does not already exist)\n** and populated with enough information so that if a power loss occurs\n** the database can be restored to its original state by playing back\n** the journal.  Then the contents of the journal are flushed out to\n** the disk.  After the journal is safely on oxide, the changes to the\n** database are written into the database file and flushed to oxide.\n** At the end of this call, the rollback journal still exists on the\n** disk and we are still holding all locks, so the transaction has not\n** committed.  See sqlite3BtreeCommitPhaseTwo() for the second phase of the\n** commit process.\n**\n** This call is a no-op if no write-transaction is currently active on pBt.\n**\n** Otherwise, sync the database file for the btree pBt. zMaster points to\n** the name of a master journal file that should be written into the\n** individual journal file, or is NULL, indicating no master journal file \n** (single database transaction).\n**\n** When this is called, the master journal should already have been\n** created, populated with this journal pointer and synced to disk.\n**\n** Once this is routine has returned, the only thing required to commit\n** the write-transaction for this database file is to delete the journal.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){\n  int rc = SQLITE_OK;\n  if( p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      rc = autoVacuumCommit(pBt);\n      if( rc!=SQLITE_OK ){\n        sqlite3BtreeLeave(p);\n        return rc;\n      }\n    }\n    if( pBt->bDoTruncate ){\n      sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage);\n    }\n#endif\n    rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()\n** at the conclusion of a transaction.\n*/\nstatic void btreeEndTransaction(Btree *p){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3BtreeHoldsMutex(p) );\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  pBt->bDoTruncate = 0;\n#endif\n  if( p->inTrans>TRANS_NONE && p->db->activeVdbeCnt>1 ){\n    /* If there are other active statements that belong to this database\n    ** handle, downgrade to a read-only transaction. The other statements\n    ** may still be reading from the database.  */\n    downgradeAllSharedCacheTableLocks(p);\n    p->inTrans = TRANS_READ;\n  }else{\n    /* If the handle had any kind of transaction open, decrement the \n    ** transaction count of the shared btree. If the transaction count \n    ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused()\n    ** call below will unlock the pager.  */\n    if( p->inTrans!=TRANS_NONE ){\n      clearAllSharedCacheTableLocks(p);\n      pBt->nTransaction--;\n      if( 0==pBt->nTransaction ){\n        pBt->inTransaction = TRANS_NONE;\n      }\n    }\n\n    /* Set the current transaction state to TRANS_NONE and unlock the \n    ** pager if this call closed the only read or write transaction.  */\n    p->inTrans = TRANS_NONE;\n    unlockBtreeIfUnused(pBt);\n  }\n\n  btreeIntegrity(p);\n}\n\n/*\n** Commit the transaction currently in progress.\n**\n** This routine implements the second phase of a 2-phase commit.  The\n** sqlite3BtreeCommitPhaseOne() routine does the first phase and should\n** be invoked prior to calling this routine.  The sqlite3BtreeCommitPhaseOne()\n** routine did all the work of writing information out to disk and flushing the\n** contents so that they are written onto the disk platter.  All this\n** routine has to do is delete or truncate or zero the header in the\n** the rollback journal (which causes the transaction to commit) and\n** drop locks.\n**\n** Normally, if an error occurs while the pager layer is attempting to \n** finalize the underlying journal file, this function returns an error and\n** the upper layer will attempt a rollback. However, if the second argument\n** is non-zero then this b-tree transaction is part of a multi-file \n** transaction. In this case, the transaction has already been committed \n** (by deleting a master journal file) and the caller will ignore this \n** functions return code. So, even if an error occurs in the pager layer,\n** reset the b-tree objects internal state to indicate that the write\n** transaction has been closed. This is quite safe, as the pager will have\n** transitioned to the error state.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){\n\n  if( p->inTrans==TRANS_NONE ) return SQLITE_OK;\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the handle has a write-transaction open, commit the shared-btrees \n  ** transaction and set the shared state to TRANS_READ.\n  */\n  if( p->inTrans==TRANS_WRITE ){\n    int rc;\n    BtShared *pBt = p->pBt;\n    assert( pBt->inTransaction==TRANS_WRITE );\n    assert( pBt->nTransaction>0 );\n    rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);\n    if( rc!=SQLITE_OK && bCleanup==0 ){\n      sqlite3BtreeLeave(p);\n      return rc;\n    }\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Do both phases of a commit.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = sqlite3BtreeCommitPhaseOne(p, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeCommitPhaseTwo(p, 0);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine sets the state to CURSOR_FAULT and the error\n** code to errCode for every cursor on BtShared that pBtree\n** references.\n**\n** Every cursor is tripped, including cursors that belong\n** to other database connections that happen to be sharing\n** the cache with pBtree.\n**\n** This routine gets called when a rollback occurs.\n** All cursors using the same cache must be tripped\n** to prevent them from trying to use the btree after\n** the rollback.  The rollback may have deleted tables\n** or moved root pages, so it is not sufficient to\n** save the state of the cursor.  The cursor must be\n** invalidated.\n*/\nSQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode){\n  BtCursor *p;\n  if( pBtree==0 ) return;\n  sqlite3BtreeEnter(pBtree);\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    int i;\n    sqlite3BtreeClearCursor(p);\n    p->eState = CURSOR_FAULT;\n    p->skipNext = errCode;\n    for(i=0; i<=p->iPage; i++){\n      releasePage(p->apPage[i]);\n      p->apPage[i] = 0;\n    }\n  }\n  sqlite3BtreeLeave(pBtree);\n}\n\n/*\n** Rollback the transaction in progress.  All cursors will be\n** invalided by this operation.  Any attempt to use a cursor\n** that was open at the beginning of this operation will result\n** in an error.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p, int tripCode){\n  int rc;\n  BtShared *pBt = p->pBt;\n  MemPage *pPage1;\n\n  sqlite3BtreeEnter(p);\n  if( tripCode==SQLITE_OK ){\n    rc = tripCode = saveAllCursors(pBt, 0, 0);\n  }else{\n    rc = SQLITE_OK;\n  }\n  if( tripCode ){\n    sqlite3BtreeTripAllCursors(p, tripCode);\n  }\n  btreeIntegrity(p);\n\n  if( p->inTrans==TRANS_WRITE ){\n    int rc2;\n\n    assert( TRANS_WRITE==pBt->inTransaction );\n    rc2 = sqlite3PagerRollback(pBt->pPager);\n    if( rc2!=SQLITE_OK ){\n      rc = rc2;\n    }\n\n    /* The rollback may have destroyed the pPage1->aData value.  So\n    ** call btreeGetPage() on page 1 again to make\n    ** sure pPage1->aData is set correctly. */\n    if( btreeGetPage(pBt, 1, &pPage1, 0, 0)==SQLITE_OK ){\n      int nPage = get4byte(28+(u8*)pPage1->aData);\n      testcase( nPage==0 );\n      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);\n      testcase( pBt->nPage!=nPage );\n      pBt->nPage = nPage;\n      releasePage(pPage1);\n    }\n    assert( countValidCursors(pBt, 1)==0 );\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Start a statement subtransaction. The subtransaction can can be rolled\n** back independently of the main transaction. You must start a transaction \n** before starting a subtransaction. The subtransaction is ended automatically \n** if the main transaction commits or rolls back.\n**\n** Statement subtransactions are used around individual SQL statements\n** that are contained within a BEGIN...COMMIT block.  If a constraint\n** error occurs within the statement, the effect of that one statement\n** can be rolled back without having to rollback the entire transaction.\n**\n** A statement sub-transaction is implemented as an anonymous savepoint. The\n** value passed as the second parameter is the total number of savepoints,\n** including the new anonymous savepoint, open on the B-Tree. i.e. if there\n** are no active savepoints and no other statement-transactions open,\n** iStatement is 1. This anonymous savepoint can be released or rolled back\n** using the sqlite3BtreeSavepoint() function.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( iStatement>0 );\n  assert( iStatement>p->db->nSavepoint );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  /* At the pager level, a statement transaction is a savepoint with\n  ** an index greater than all savepoints created explicitly using\n  ** SQL statements. It is illegal to open, release or rollback any\n  ** such savepoints while the statement transaction savepoint is active.\n  */\n  rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** The second argument to this function, op, is always SAVEPOINT_ROLLBACK\n** or SAVEPOINT_RELEASE. This function either releases or rolls back the\n** savepoint identified by parameter iSavepoint, depending on the value \n** of op.\n**\n** Normally, iSavepoint is greater than or equal to zero. However, if op is\n** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the \n** contents of the entire transaction are rolled back. This is different\n** from a normal transaction rollback, as no locks are released and the\n** transaction remains open.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n  if( p && p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n    assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );\n    sqlite3BtreeEnter(p);\n    rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);\n    if( rc==SQLITE_OK ){\n      if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){\n        pBt->nPage = 0;\n      }\n      rc = newDatabase(pBt);\n      pBt->nPage = get4byte(28 + pBt->pPage1->aData);\n\n      /* The database size was written into the offset 28 of the header\n      ** when the transaction started, so we know that the value at offset\n      ** 28 is nonzero. */\n      assert( pBt->nPage>0 );\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Create a new cursor for the BTree whose root is on the page\n** iTable. If a read-only cursor is requested, it is assumed that\n** the caller already has at least a read-only transaction open\n** on the database already. If a write-cursor is requested, then\n** the caller is assumed to have an open write transaction.\n**\n** If wrFlag==0, then the cursor can only be used for reading.\n** If wrFlag==1, then the cursor can be used for reading or for\n** writing if other conditions for writing are also met.  These\n** are the conditions that must be met in order for writing to\n** be allowed:\n**\n** 1:  The cursor must have been opened with wrFlag==1\n**\n** 2:  Other database connections that share the same pager cache\n**     but which are not in the READ_UNCOMMITTED state may not have\n**     cursors open with wrFlag==0 on the same table.  Otherwise\n**     the changes made by this write cursor would be visible to\n**     the read cursors in the other database connection.\n**\n** 3:  The database must be writable (not on read-only media)\n**\n** 4:  There must be an active transaction.\n**\n** No checking is done to make sure that page iTable really is the\n** root page of a b-tree.  If it is not, then the cursor acquired\n** will not work correctly.\n**\n** It is assumed that the sqlite3BtreeCursorZero() has been called\n** on pCur to initialize the memory space prior to invoking this routine.\n*/\nstatic int btreeCursor(\n  Btree *p,                              /* The btree */\n  int iTable,                            /* Root page of table to open */\n  int wrFlag,                            /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,              /* First arg to comparison function */\n  BtCursor *pCur                         /* Space for new cursor */\n){\n  BtShared *pBt = p->pBt;                /* Shared b-tree handle */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( wrFlag==0 || wrFlag==1 );\n\n  /* The following assert statements verify that if this is a sharable \n  ** b-tree database, the connection is holding the required table locks, \n  ** and that no other connection has any open cursor that conflicts with \n  ** this lock.  */\n  assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, wrFlag+1) );\n  assert( wrFlag==0 || !hasReadConflicts(p, iTable) );\n\n  /* Assert that the caller has opened the required transaction. */\n  assert( p->inTrans>TRANS_NONE );\n  assert( wrFlag==0 || p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1 && pBt->pPage1->aData );\n\n  if( NEVER(wrFlag && (pBt->btsFlags & BTS_READ_ONLY)!=0) ){\n    return SQLITE_READONLY;\n  }\n  if( iTable==1 && btreePagecount(pBt)==0 ){\n    assert( wrFlag==0 );\n    iTable = 0;\n  }\n\n  /* Now that no other errors can occur, finish filling in the BtCursor\n  ** variables and link the cursor into the BtShared list.  */\n  pCur->pgnoRoot = (Pgno)iTable;\n  pCur->iPage = -1;\n  pCur->pKeyInfo = pKeyInfo;\n  pCur->pBtree = p;\n  pCur->pBt = pBt;\n  pCur->wrFlag = (u8)wrFlag;\n  pCur->pNext = pBt->pCursor;\n  if( pCur->pNext ){\n    pCur->pNext->pPrev = pCur;\n  }\n  pBt->pCursor = pCur;\n  pCur->eState = CURSOR_INVALID;\n  pCur->cachedRowid = 0;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree *p,                                   /* The btree */\n  int iTable,                                 /* Root page of table to open */\n  int wrFlag,                                 /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,                   /* First arg to xCompare() */\n  BtCursor *pCur                              /* Write new cursor here */\n){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Return the size of a BtCursor object in bytes.\n**\n** This interfaces is needed so that users of cursors can preallocate\n** sufficient storage to hold a cursor.  The BtCursor object is opaque\n** to users so they cannot do the sizeof() themselves - they must call\n** this routine.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void){\n  return ROUND8(sizeof(BtCursor));\n}\n\n/*\n** Initialize memory that will be converted into a BtCursor object.\n**\n** The simple approach here would be to memset() the entire object\n** to zero.  But it turns out that the apPage[] and aiIdx[] arrays\n** do not need to be zeroed and they are large, so we can save a lot\n** of run-time by skipping the initialization of those elements.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){\n  memset(p, 0, offsetof(BtCursor, iPage));\n}\n\n/*\n** Set the cached rowid value of every cursor in the same database file\n** as pCur and having the same root page number as pCur.  The value is\n** set to iRowid.\n**\n** Only positive rowid values are considered valid for this cache.\n** The cache is initialized to zero, indicating an invalid cache.\n** A btree will work fine with zero or negative rowids.  We just cannot\n** cache zero or negative rowids, which means tables that use zero or\n** negative rowids might run a little slower.  But in practice, zero\n** or negative rowids are very uncommon so this should not be a problem.\n*/\nSQLITE_PRIVATE void sqlite3BtreeSetCachedRowid(BtCursor *pCur, sqlite3_int64 iRowid){\n  BtCursor *p;\n  for(p=pCur->pBt->pCursor; p; p=p->pNext){\n    if( p->pgnoRoot==pCur->pgnoRoot ) p->cachedRowid = iRowid;\n  }\n  assert( pCur->cachedRowid==iRowid );\n}\n\n/*\n** Return the cached rowid for the given cursor.  A negative or zero\n** return value indicates that the rowid cache is invalid and should be\n** ignored.  If the rowid cache has never before been set, then a\n** zero is returned.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor *pCur){\n  return pCur->cachedRowid;\n}\n\n/*\n** Close a cursor.  The read lock on the database file is released\n** when the last cursor is closed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){\n  Btree *pBtree = pCur->pBtree;\n  if( pBtree ){\n    int i;\n    BtShared *pBt = pCur->pBt;\n    sqlite3BtreeEnter(pBtree);\n    sqlite3BtreeClearCursor(pCur);\n    if( pCur->pPrev ){\n      pCur->pPrev->pNext = pCur->pNext;\n    }else{\n      pBt->pCursor = pCur->pNext;\n    }\n    if( pCur->pNext ){\n      pCur->pNext->pPrev = pCur->pPrev;\n    }\n    for(i=0; i<=pCur->iPage; i++){\n      releasePage(pCur->apPage[i]);\n    }\n    unlockBtreeIfUnused(pBt);\n    invalidateOverflowCache(pCur);\n    /* sqlite3_free(pCur); */\n    sqlite3BtreeLeave(pBtree);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the BtCursor* given in the argument has a valid\n** BtCursor.info structure.  If it is not already valid, call\n** btreeParseCell() to fill it in.\n**\n** BtCursor.info is a cache of the information in the current cell.\n** Using this cache reduces the number of calls to btreeParseCell().\n**\n** 2007-06-25:  There is a bug in some versions of MSVC that cause the\n** compiler to crash when getCellInfo() is implemented as a macro.\n** But there is a measureable speed advantage to using the macro on gcc\n** (when less compiler optimizations like -Os or -O0 are used and the\n** compiler is not doing agressive inlining.)  So we use a real function\n** for MSVC and a macro for everything else.  Ticket #2457.\n*/\n#ifndef NDEBUG\n  static void assertCellInfo(BtCursor *pCur){\n    CellInfo info;\n    int iPage = pCur->iPage;\n    memset(&info, 0, sizeof(info));\n    btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info);\n    assert( memcmp(&info, &pCur->info, sizeof(info))==0 );\n  }\n#else\n  #define assertCellInfo(x)\n#endif\n#ifdef _MSC_VER\n  /* Use a real function in MSVC to work around bugs in that compiler. */\n  static void getCellInfo(BtCursor *pCur){\n    if( pCur->info.nSize==0 ){\n      int iPage = pCur->iPage;\n      btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info);\n      pCur->validNKey = 1;\n    }else{\n      assertCellInfo(pCur);\n    }\n  }\n#else /* if not _MSC_VER */\n  /* Use a macro in all other compilers so that the function is inlined */\n#define getCellInfo(pCur)                                                      \\\n  if( pCur->info.nSize==0 ){                                                   \\\n    int iPage = pCur->iPage;                                                   \\\n    btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info); \\\n    pCur->validNKey = 1;                                                       \\\n  }else{                                                                       \\\n    assertCellInfo(pCur);                                                      \\\n  }\n#endif /* _MSC_VER */\n\n#ifndef NDEBUG  /* The next routine used only within assert() statements */\n/*\n** Return true if the given BtCursor is valid.  A valid cursor is one\n** that is currently pointing to a row in a (non-empty) table.\n** This is a verification routine is used only within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor *pCur){\n  return pCur && pCur->eState==CURSOR_VALID;\n}\n#endif /* NDEBUG */\n\n/*\n** Set *pSize to the size of the buffer needed to hold the value of\n** the key for the current entry.  If the cursor is not pointing\n** to a valid entry, *pSize is set to 0. \n**\n** For a table with the INTKEY flag set, this routine returns the key\n** itself, not the number of bytes in the key.\n**\n** The caller must position the cursor prior to invoking this routine.\n** \n** This routine cannot fail.  It always returns SQLITE_OK.  \n*/\nSQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_INVALID || pCur->eState==CURSOR_VALID );\n  if( pCur->eState!=CURSOR_VALID ){\n    *pSize = 0;\n  }else{\n    getCellInfo(pCur);\n    *pSize = pCur->info.nKey;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set *pSize to the number of bytes of data in the entry the\n** cursor currently points to.\n**\n** The caller must guarantee that the cursor is pointing to a non-NULL\n** valid entry.  In other words, the calling procedure must guarantee\n** that the cursor has Cursor.eState==CURSOR_VALID.\n**\n** Failure is not possible.  This function always returns SQLITE_OK.\n** It might just as well be a procedure (returning void) but we continue\n** to return an integer result code for historical reasons.\n*/\nSQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  getCellInfo(pCur);\n  *pSize = pCur->info.nData;\n  return SQLITE_OK;\n}\n\n/*\n** Given the page number of an overflow page in the database (parameter\n** ovfl), this function finds the page number of the next page in the \n** linked list of overflow pages. If possible, it uses the auto-vacuum\n** pointer-map data instead of reading the content of page ovfl to do so. \n**\n** If an error occurs an SQLite error code is returned. Otherwise:\n**\n** The page number of the next overflow page in the linked list is \n** written to *pPgnoNext. If page ovfl is the last page in its linked \n** list, *pPgnoNext is set to zero. \n**\n** If ppPage is not NULL, and a reference to the MemPage object corresponding\n** to page number pOvfl was obtained, then *ppPage is set to point to that\n** reference. It is the responsibility of the caller to call releasePage()\n** on *ppPage to free the reference. In no reference was obtained (because\n** the pointer-map was used to obtain the value for *pPgnoNext), then\n** *ppPage is set to zero.\n*/\nstatic int getOverflowPage(\n  BtShared *pBt,               /* The database file */\n  Pgno ovfl,                   /* Current overflow page number */\n  MemPage **ppPage,            /* OUT: MemPage handle (may be NULL) */\n  Pgno *pPgnoNext              /* OUT: Next overflow page number */\n){\n  Pgno next = 0;\n  MemPage *pPage = 0;\n  int rc = SQLITE_OK;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert(pPgnoNext);\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* Try to find the next page in the overflow list using the\n  ** autovacuum pointer-map pages. Guess that the next page in \n  ** the overflow list is page number (ovfl+1). If that guess turns \n  ** out to be wrong, fall back to loading the data of page \n  ** number ovfl to determine the next page number.\n  */\n  if( pBt->autoVacuum ){\n    Pgno pgno;\n    Pgno iGuess = ovfl+1;\n    u8 eType;\n\n    while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){\n      iGuess++;\n    }\n\n    if( iGuess<=btreePagecount(pBt) ){\n      rc = ptrmapGet(pBt, iGuess, &eType, &pgno);\n      if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){\n        next = iGuess;\n        rc = SQLITE_DONE;\n      }\n    }\n  }\n#endif\n\n  assert( next==0 || rc==SQLITE_DONE );\n  if( rc==SQLITE_OK ){\n    rc = btreeGetPage(pBt, ovfl, &pPage, 0, (ppPage==0));\n    assert( rc==SQLITE_OK || pPage==0 );\n    if( rc==SQLITE_OK ){\n      next = get4byte(pPage->aData);\n    }\n  }\n\n  *pPgnoNext = next;\n  if( ppPage ){\n    *ppPage = pPage;\n  }else{\n    releasePage(pPage);\n  }\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/*\n** Copy data from a buffer to a page, or from a page to a buffer.\n**\n** pPayload is a pointer to data stored on database page pDbPage.\n** If argument eOp is false, then nByte bytes of data are copied\n** from pPayload to the buffer pointed at by pBuf. If eOp is true,\n** then sqlite3PagerWrite() is called on pDbPage and nByte bytes\n** of data are copied from the buffer pBuf to pPayload.\n**\n** SQLITE_OK is returned on success, otherwise an error code.\n*/\nstatic int copyPayload(\n  void *pPayload,           /* Pointer to page data */\n  void *pBuf,               /* Pointer to buffer */\n  int nByte,                /* Number of bytes to copy */\n  int eOp,                  /* 0 -> copy from page, 1 -> copy to page */\n  DbPage *pDbPage           /* Page containing pPayload */\n){\n  if( eOp ){\n    /* Copy data from buffer to page (a write operation) */\n    int rc = sqlite3PagerWrite(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    memcpy(pPayload, pBuf, nByte);\n  }else{\n    /* Copy data from page to buffer (a read operation) */\n    memcpy(pBuf, pPayload, nByte);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is used to read or overwrite payload information\n** for the entry that the pCur cursor is pointing to. If the eOp\n** parameter is 0, this is a read operation (data copied into\n** buffer pBuf). If it is non-zero, a write (data copied from\n** buffer pBuf).\n**\n** A total of \"amt\" bytes are read or written beginning at \"offset\".\n** Data is read to or from the buffer pBuf.\n**\n** The content being read or written might appear on the main page\n** or be scattered out on multiple overflow pages.\n**\n** If the BtCursor.isIncrblobHandle flag is set, and the current\n** cursor entry uses one or more overflow pages, this function\n** allocates space for and lazily popluates the overflow page-list \n** cache array (BtCursor.aOverflow). Subsequent calls use this\n** cache to make seeking to the supplied offset more efficient.\n**\n** Once an overflow page-list cache has been allocated, it may be\n** invalidated if some other cursor writes to the same table, or if\n** the cursor is moved to a different row. Additionally, in auto-vacuum\n** mode, the following events may invalidate an overflow page-list cache.\n**\n**   * An incremental vacuum,\n**   * A commit in auto_vacuum=\"full\" mode,\n**   * Creating a table (may require moving an overflow page).\n*/\nstatic int accessPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 offset,          /* Begin reading this far into payload */\n  u32 amt,             /* Read this many bytes */\n  unsigned char *pBuf, /* Write the bytes into this buffer */ \n  int eOp              /* zero to read. non-zero to write. */\n){\n  unsigned char *aPayload;\n  int rc = SQLITE_OK;\n  u32 nKey;\n  int iIdx = 0;\n  MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */\n  BtShared *pBt = pCur->pBt;                  /* Btree this cursor belongs to */\n\n  assert( pPage );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );\n  assert( cursorHoldsMutex(pCur) );\n\n  getCellInfo(pCur);\n  aPayload = pCur->info.pCell + pCur->info.nHeader;\n  nKey = (pPage->intKey ? 0 : (int)pCur->info.nKey);\n\n  if( NEVER(offset+amt > nKey+pCur->info.nData) \n   || &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]\n  ){\n    /* Trying to read or write past the end of the data is an error */\n    return SQLITE_CORRUPT_BKPT;\n  }\n\n  /* Check if data must be read/written to/from the btree page itself. */\n  if( offset<pCur->info.nLocal ){\n    int a = amt;\n    if( a+offset>pCur->info.nLocal ){\n      a = pCur->info.nLocal - offset;\n    }\n    rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);\n    offset = 0;\n    pBuf += a;\n    amt -= a;\n  }else{\n    offset -= pCur->info.nLocal;\n  }\n\n  if( rc==SQLITE_OK && amt>0 ){\n    const u32 ovflSize = pBt->usableSize - 4;  /* Bytes content per ovfl page */\n    Pgno nextPage;\n\n    nextPage = get4byte(&aPayload[pCur->info.nLocal]);\n\n#ifndef SQLITE_OMIT_INCRBLOB\n    /* If the isIncrblobHandle flag is set and the BtCursor.aOverflow[]\n    ** has not been allocated, allocate it now. The array is sized at\n    ** one entry for each overflow page in the overflow chain. The\n    ** page number of the first overflow page is stored in aOverflow[0],\n    ** etc. A value of 0 in the aOverflow[] array means \"not yet known\"\n    ** (the cache is lazily populated).\n    */\n    if( pCur->isIncrblobHandle && !pCur->aOverflow ){\n      int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;\n      pCur->aOverflow = (Pgno *)sqlite3MallocZero(sizeof(Pgno)*nOvfl);\n      /* nOvfl is always positive.  If it were zero, fetchPayload would have\n      ** been used instead of this routine. */\n      if( ALWAYS(nOvfl) && !pCur->aOverflow ){\n        rc = SQLITE_NOMEM;\n      }\n    }\n\n    /* If the overflow page-list cache has been allocated and the\n    ** entry for the first required overflow page is valid, skip\n    ** directly to it.\n    */\n    if( pCur->aOverflow && pCur->aOverflow[offset/ovflSize] ){\n      iIdx = (offset/ovflSize);\n      nextPage = pCur->aOverflow[iIdx];\n      offset = (offset%ovflSize);\n    }\n#endif\n\n    for( ; rc==SQLITE_OK && amt>0 && nextPage; iIdx++){\n\n#ifndef SQLITE_OMIT_INCRBLOB\n      /* If required, populate the overflow page-list cache. */\n      if( pCur->aOverflow ){\n        assert(!pCur->aOverflow[iIdx] || pCur->aOverflow[iIdx]==nextPage);\n        pCur->aOverflow[iIdx] = nextPage;\n      }\n#endif\n\n      if( offset>=ovflSize ){\n        /* The only reason to read this page is to obtain the page\n        ** number for the next page in the overflow chain. The page\n        ** data is not required. So first try to lookup the overflow\n        ** page-list cache, if any, then fall back to the getOverflowPage()\n        ** function.\n        */\n#ifndef SQLITE_OMIT_INCRBLOB\n        if( pCur->aOverflow && pCur->aOverflow[iIdx+1] ){\n          nextPage = pCur->aOverflow[iIdx+1];\n        } else \n#endif\n          rc = getOverflowPage(pBt, nextPage, 0, &nextPage);\n        offset -= ovflSize;\n      }else{\n        /* Need to read this page properly. It contains some of the\n        ** range of data that is being read (eOp==0) or written (eOp!=0).\n        */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        sqlite3_file *fd;\n#endif\n        int a = amt;\n        if( a + offset > ovflSize ){\n          a = ovflSize - offset;\n        }\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        /* If all the following are true:\n        **\n        **   1) this is a read operation, and \n        **   2) data is required from the start of this overflow page, and\n        **   3) the database is file-backed, and\n        **   4) there is no open write-transaction, and\n        **   5) the database is not a WAL database,\n        **\n        ** then data can be read directly from the database file into the\n        ** output buffer, bypassing the page-cache altogether. This speeds\n        ** up loading large records that span many overflow pages.\n        */\n        if( eOp==0                                             /* (1) */\n         && offset==0                                          /* (2) */\n         && pBt->inTransaction==TRANS_READ                     /* (4) */\n         && (fd = sqlite3PagerFile(pBt->pPager))->pMethods     /* (3) */\n         && pBt->pPage1->aData[19]==0x01                       /* (5) */\n        ){\n          u8 aSave[4];\n          u8 *aWrite = &pBuf[-4];\n          memcpy(aSave, aWrite, 4);\n          rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));\n          nextPage = get4byte(aWrite);\n          memcpy(aWrite, aSave, 4);\n        }else\n#endif\n\n        {\n          DbPage *pDbPage;\n          rc = sqlite3PagerAcquire(pBt->pPager, nextPage, &pDbPage,\n              (eOp==0 ? PAGER_ACQUIRE_READONLY : 0)\n          );\n          if( rc==SQLITE_OK ){\n            aPayload = sqlite3PagerGetData(pDbPage);\n            nextPage = get4byte(aPayload);\n            rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);\n            sqlite3PagerUnref(pDbPage);\n            offset = 0;\n          }\n        }\n        amt -= a;\n        pBuf += a;\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK && amt>0 ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  return rc;\n}\n\n/*\n** Read part of the key associated with cursor pCur.  Exactly\n** \"amt\" bytes will be transfered into pBuf[].  The transfer\n** begins at \"offset\".\n**\n** The caller must ensure that pCur is pointing to a valid row\n** in the table.\n**\n** Return SQLITE_OK on success or an error code if anything goes\n** wrong.  An error is returned if \"offset+amt\" is larger than\n** the available payload.\n*/\nSQLITE_PRIVATE int sqlite3BtreeKey(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );\n  assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );\n  return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);\n}\n\n/*\n** Read part of the data associated with cursor pCur.  Exactly\n** \"amt\" bytes will be transfered into pBuf[].  The transfer\n** begins at \"offset\".\n**\n** Return SQLITE_OK on success or an error code if anything goes\n** wrong.  An error is returned if \"offset+amt\" is larger than\n** the available payload.\n*/\nSQLITE_PRIVATE int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  int rc;\n\n#ifndef SQLITE_OMIT_INCRBLOB\n  if ( pCur->eState==CURSOR_INVALID ){\n    return SQLITE_ABORT;\n  }\n#endif\n\n  assert( cursorHoldsMutex(pCur) );\n  rc = restoreCursorPosition(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->eState==CURSOR_VALID );\n    assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );\n    assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );\n    rc = accessPayload(pCur, offset, amt, pBuf, 0);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to payload information from the entry that the \n** pCur cursor is pointing to.  The pointer is to the beginning of\n** the key if skipKey==0 and it points to the beginning of data if\n** skipKey==1.  The number of bytes of available key/data is written\n** into *pAmt.  If *pAmt==0, then the value returned will not be\n** a valid pointer.\n**\n** This routine is an optimization.  It is common for the entire key\n** and data to fit on the local page and for there to be no overflow\n** pages.  When that is so, this routine can be used to access the\n** key and data without making a copy.  If the key and/or data spills\n** onto overflow pages, then accessPayload() must be used to reassemble\n** the key/data and copy it into a preallocated buffer.\n**\n** The pointer returned by this routine looks directly into the cached\n** page of the database.  The data might change or move the next time\n** any btree routine is called.\n*/\nstatic const unsigned char *fetchPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  int *pAmt,           /* Write the number of available bytes here */\n  int skipKey          /* read beginning at data if this is true */\n){\n  unsigned char *aPayload;\n  MemPage *pPage;\n  u32 nKey;\n  u32 nLocal;\n\n  assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);\n  assert( pCur->eState==CURSOR_VALID );\n  assert( cursorHoldsMutex(pCur) );\n  pPage = pCur->apPage[pCur->iPage];\n  assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );\n  if( NEVER(pCur->info.nSize==0) ){\n    btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],\n                   &pCur->info);\n  }\n  aPayload = pCur->info.pCell;\n  aPayload += pCur->info.nHeader;\n  if( pPage->intKey ){\n    nKey = 0;\n  }else{\n    nKey = (int)pCur->info.nKey;\n  }\n  if( skipKey ){\n    aPayload += nKey;\n    nLocal = pCur->info.nLocal - nKey;\n  }else{\n    nLocal = pCur->info.nLocal;\n    assert( nLocal<=nKey );\n  }\n  *pAmt = nLocal;\n  return aPayload;\n}\n\n\n/*\n** For the entry that cursor pCur is point to, return as\n** many bytes of the key or data as are available on the local\n** b-tree page.  Write the number of available bytes into *pAmt.\n**\n** The pointer returned is ephemeral.  The key/data may move\n** or be destroyed on the next call to any Btree routine,\n** including calls from other threads against the same cache.\n** Hence, a mutex on the BtShared should be held prior to calling\n** this routine.\n**\n** These routines is used to get quick access to key and data\n** in the common case where no overflow pages are used.\n*/\nSQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){\n  const void *p = 0;\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( cursorHoldsMutex(pCur) );\n  if( ALWAYS(pCur->eState==CURSOR_VALID) ){\n    p = (const void*)fetchPayload(pCur, pAmt, 0);\n  }\n  return p;\n}\nSQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){\n  const void *p = 0;\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( cursorHoldsMutex(pCur) );\n  if( ALWAYS(pCur->eState==CURSOR_VALID) ){\n    p = (const void*)fetchPayload(pCur, pAmt, 1);\n  }\n  return p;\n}\n\n\n/*\n** Move the cursor down to a new child page.  The newPgno argument is the\n** page number of the child page to move to.\n**\n** This function returns SQLITE_CORRUPT if the page-header flags field of\n** the new child page does not match the flags field of the parent (i.e.\n** if an intkey page appears to be the parent of a non-intkey page, or\n** vice-versa).\n*/\nstatic int moveToChild(BtCursor *pCur, u32 newPgno){\n  int rc;\n  int i = pCur->iPage;\n  MemPage *pNewPage;\n  BtShared *pBt = pCur->pBt;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage<BTCURSOR_MAX_DEPTH );\n  assert( pCur->iPage>=0 );\n  if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  rc = getAndInitPage(pBt, newPgno, &pNewPage, (pCur->wrFlag==0));\n  if( rc ) return rc;\n  pCur->apPage[i+1] = pNewPage;\n  pCur->aiIdx[i+1] = 0;\n  pCur->iPage++;\n\n  pCur->info.nSize = 0;\n  pCur->validNKey = 0;\n  if( pNewPage->nCell<1 || pNewPage->intKey!=pCur->apPage[i]->intKey ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  return SQLITE_OK;\n}\n\n#if 0\n/*\n** Page pParent is an internal (non-leaf) tree page. This function \n** asserts that page number iChild is the left-child if the iIdx'th\n** cell in page pParent. Or, if iIdx is equal to the total number of\n** cells in pParent, that page number iChild is the right-child of\n** the page.\n*/\nstatic void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){\n  assert( iIdx<=pParent->nCell );\n  if( iIdx==pParent->nCell ){\n    assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );\n  }else{\n    assert( get4byte(findCell(pParent, iIdx))==iChild );\n  }\n}\n#else\n#  define assertParentIndex(x,y,z) \n#endif\n\n/*\n** Move the cursor up to the parent page.\n**\n** pCur->idx is set to the cell index that contains the pointer\n** to the page we are coming from.  If we are coming from the\n** right-most child page then pCur->idx is set to one more than\n** the largest cell index.\n*/\nstatic void moveToParent(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>0 );\n  assert( pCur->apPage[pCur->iPage] );\n\n  /* UPDATE: It is actually possible for the condition tested by the assert\n  ** below to be untrue if the database file is corrupt. This can occur if\n  ** one cursor has modified page pParent while a reference to it is held \n  ** by a second cursor. Which can only happen if a single page is linked\n  ** into more than one b-tree structure in a corrupt database.  */\n#if 0\n  assertParentIndex(\n    pCur->apPage[pCur->iPage-1], \n    pCur->aiIdx[pCur->iPage-1], \n    pCur->apPage[pCur->iPage]->pgno\n  );\n#endif\n  testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );\n\n  releasePage(pCur->apPage[pCur->iPage]);\n  pCur->iPage--;\n  pCur->info.nSize = 0;\n  pCur->validNKey = 0;\n}\n\n/*\n** Move the cursor to point to the root page of its b-tree structure.\n**\n** If the table has a virtual root page, then the cursor is moved to point\n** to the virtual root page instead of the actual root page. A table has a\n** virtual root page when the actual root page contains no cells and a \n** single child page. This can only happen with the table rooted at page 1.\n**\n** If the b-tree structure is empty, the cursor state is set to \n** CURSOR_INVALID. Otherwise, the cursor is set to point to the first\n** cell located on the root (or virtual root) page and the cursor state\n** is set to CURSOR_VALID.\n**\n** If this function returns successfully, it may be assumed that the\n** page-header flags indicate that the [virtual] root-page is the expected \n** kind of b-tree page (i.e. if when opening the cursor the caller did not\n** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D,\n** indicating a table b-tree, or if the caller did specify a KeyInfo \n** structure the flags byte is set to 0x02 or 0x0A, indicating an index\n** b-tree).\n*/\nstatic int moveToRoot(BtCursor *pCur){\n  MemPage *pRoot;\n  int rc = SQLITE_OK;\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );\n  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );\n  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );\n  if( pCur->eState>=CURSOR_REQUIRESEEK ){\n    if( pCur->eState==CURSOR_FAULT ){\n      assert( pCur->skipNext!=SQLITE_OK );\n      return pCur->skipNext;\n    }\n    sqlite3BtreeClearCursor(pCur);\n  }\n\n  if( pCur->iPage>=0 ){\n    int i;\n    for(i=1; i<=pCur->iPage; i++){\n      releasePage(pCur->apPage[i]);\n    }\n    pCur->iPage = 0;\n  }else if( pCur->pgnoRoot==0 ){\n    pCur->eState = CURSOR_INVALID;\n    return SQLITE_OK;\n  }else{\n    rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0], pCur->wrFlag==0);\n    if( rc!=SQLITE_OK ){\n      pCur->eState = CURSOR_INVALID;\n      return rc;\n    }\n    pCur->iPage = 0;\n\n    /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor\n    ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is\n    ** NULL, the caller expects a table b-tree. If this is not the case,\n    ** return an SQLITE_CORRUPT error.  */\n    assert( pCur->apPage[0]->intKey==1 || pCur->apPage[0]->intKey==0 );\n    if( (pCur->pKeyInfo==0)!=pCur->apPage[0]->intKey ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n  }\n\n  /* Assert that the root page is of the correct type. This must be the\n  ** case as the call to this function that loaded the root-page (either\n  ** this call or a previous invocation) would have detected corruption \n  ** if the assumption were not true, and it is not possible for the flags \n  ** byte to have been modified while this cursor is holding a reference\n  ** to the page.  */\n  pRoot = pCur->apPage[0];\n  assert( pRoot->pgno==pCur->pgnoRoot );\n  assert( pRoot->isInit && (pCur->pKeyInfo==0)==pRoot->intKey );\n\n  pCur->aiIdx[0] = 0;\n  pCur->info.nSize = 0;\n  pCur->atLast = 0;\n  pCur->validNKey = 0;\n\n  if( pRoot->nCell==0 && !pRoot->leaf ){\n    Pgno subpage;\n    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;\n    subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);\n    pCur->eState = CURSOR_VALID;\n    rc = moveToChild(pCur, subpage);\n  }else{\n    pCur->eState = ((pRoot->nCell>0)?CURSOR_VALID:CURSOR_INVALID);\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the left-most leaf entry beneath the\n** entry to which it is currently pointing.\n**\n** The left-most leaf is the one with the smallest key - the first\n** in ascending order.\n*/\nstatic int moveToLeftmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){\n    assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );\n    pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage]));\n    rc = moveToChild(pCur, pgno);\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the right-most leaf entry beneath the\n** page to which it is currently pointing.  Notice the difference\n** between moveToLeftmost() and moveToRightmost().  moveToLeftmost()\n** finds the left-most entry beneath the *entry* whereas moveToRightmost()\n** finds the right-most entry beneath the *page*.\n**\n** The right-most entry is the one with the largest key - the last\n** key in ascending order.\n*/\nstatic int moveToRightmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage = 0;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){\n    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    pCur->aiIdx[pCur->iPage] = pPage->nCell;\n    rc = moveToChild(pCur, pgno);\n  }\n  if( rc==SQLITE_OK ){\n    pCur->aiIdx[pCur->iPage] = pPage->nCell-1;\n    pCur->info.nSize = 0;\n    pCur->validNKey = 0;\n  }\n  return rc;\n}\n\n/* Move the cursor to the first entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){\n  int rc;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    if( pCur->eState==CURSOR_INVALID ){\n      assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );\n      *pRes = 1;\n    }else{\n      assert( pCur->apPage[pCur->iPage]->nCell>0 );\n      *pRes = 0;\n      rc = moveToLeftmost(pCur);\n    }\n  }\n  return rc;\n}\n\n/* Move the cursor to the last entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){\n  int rc;\n \n  assert( cursorHoldsMutex(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* If the cursor already points to the last entry, this is a no-op. */\n  if( CURSOR_VALID==pCur->eState && pCur->atLast ){\n#ifdef SQLITE_DEBUG\n    /* This block serves to assert() that the cursor really does point \n    ** to the last entry in the b-tree. */\n    int ii;\n    for(ii=0; ii<pCur->iPage; ii++){\n      assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );\n    }\n    assert( pCur->aiIdx[pCur->iPage]==pCur->apPage[pCur->iPage]->nCell-1 );\n    assert( pCur->apPage[pCur->iPage]->leaf );\n#endif\n    return SQLITE_OK;\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    if( CURSOR_INVALID==pCur->eState ){\n      assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );\n      *pRes = 1;\n    }else{\n      assert( pCur->eState==CURSOR_VALID );\n      *pRes = 0;\n      rc = moveToRightmost(pCur);\n      pCur->atLast = rc==SQLITE_OK ?1:0;\n    }\n  }\n  return rc;\n}\n\n/* Move the cursor so that it points to an entry near the key \n** specified by pIdxKey or intKey.   Return a success code.\n**\n** For INTKEY tables, the intKey parameter is used.  pIdxKey \n** must be NULL.  For index tables, pIdxKey is used and intKey\n** is ignored.\n**\n** If an exact match is not found, then the cursor is always\n** left pointing at a leaf page which would hold the entry if it\n** were present.  The cursor might point to an entry that comes\n** before or after the key.\n**\n** An integer is written into *pRes which is the result of\n** comparing the key with the entry to which the cursor is \n** pointing.  The meaning of the integer written into\n** *pRes is as follows:\n**\n**     *pRes<0      The cursor is left pointing at an entry that\n**                  is smaller than intKey/pIdxKey or if the table is empty\n**                  and the cursor is therefore left point to nothing.\n**\n**     *pRes==0     The cursor is left pointing at an entry that\n**                  exactly matches intKey/pIdxKey.\n**\n**     *pRes>0      The cursor is left pointing at an entry that\n**                  is larger than intKey/pIdxKey.\n**\n*/\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor *pCur,          /* The cursor to be moved */\n  UnpackedRecord *pIdxKey, /* Unpacked index key */\n  i64 intKey,              /* The table key */\n  int biasRight,           /* If true, bias the search to the high end */\n  int *pRes                /* Write search results here */\n){\n  int rc;\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( pRes );\n  assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );\n\n  /* If the cursor is already positioned at the point we are trying\n  ** to move to, then just return without doing any work */\n  if( pCur->eState==CURSOR_VALID && pCur->validNKey \n   && pCur->apPage[0]->intKey \n  ){\n    if( pCur->info.nKey==intKey ){\n      *pRes = 0;\n      return SQLITE_OK;\n    }\n    if( pCur->atLast && pCur->info.nKey<intKey ){\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc ){\n    return rc;\n  }\n  assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage] );\n  assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->isInit );\n  assert( pCur->eState==CURSOR_INVALID || pCur->apPage[pCur->iPage]->nCell>0 );\n  if( pCur->eState==CURSOR_INVALID ){\n    *pRes = -1;\n    assert( pCur->pgnoRoot==0 || pCur->apPage[pCur->iPage]->nCell==0 );\n    return SQLITE_OK;\n  }\n  assert( pCur->apPage[0]->intKey || pIdxKey );\n  for(;;){\n    int lwr, upr, idx;\n    Pgno chldPg;\n    MemPage *pPage = pCur->apPage[pCur->iPage];\n    int c;\n\n    /* pPage->nCell must be greater than zero. If this is the root-page\n    ** the cursor would have been INVALID above and this for(;;) loop\n    ** not run. If this is not the root-page, then the moveToChild() routine\n    ** would have already detected db corruption. Similarly, pPage must\n    ** be the right kind (index or table) of b-tree page. Otherwise\n    ** a moveToChild() or moveToRoot() call would have detected corruption.  */\n    assert( pPage->nCell>0 );\n    assert( pPage->intKey==(pIdxKey==0) );\n    lwr = 0;\n    upr = pPage->nCell-1;\n    if( biasRight ){\n      pCur->aiIdx[pCur->iPage] = (u16)(idx = upr);\n    }else{\n      pCur->aiIdx[pCur->iPage] = (u16)(idx = (upr+lwr)/2);\n    }\n    for(;;){\n      u8 *pCell;                          /* Pointer to current cell in pPage */\n\n      assert( idx==pCur->aiIdx[pCur->iPage] );\n      pCur->info.nSize = 0;\n      pCell = findCell(pPage, idx) + pPage->childPtrSize;\n      if( pPage->intKey ){\n        i64 nCellKey;\n        if( pPage->hasData ){\n          u32 dummy;\n          pCell += getVarint32(pCell, dummy);\n        }\n        getVarint(pCell, (u64*)&nCellKey);\n        if( nCellKey==intKey ){\n          c = 0;\n        }else if( nCellKey<intKey ){\n          c = -1;\n        }else{\n          assert( nCellKey>intKey );\n          c = +1;\n        }\n        pCur->validNKey = 1;\n        pCur->info.nKey = nCellKey;\n      }else{\n        /* The maximum supported page-size is 65536 bytes. This means that\n        ** the maximum number of record bytes stored on an index B-Tree\n        ** page is less than 16384 bytes and may be stored as a 2-byte\n        ** varint. This information is used to attempt to avoid parsing \n        ** the entire cell by checking for the cases where the record is \n        ** stored entirely within the b-tree page by inspecting the first \n        ** 2 bytes of the cell.\n        */\n        int nCell = pCell[0];\n        if( nCell<=pPage->max1bytePayload\n         /* && (pCell+nCell)<pPage->aDataEnd */\n        ){\n          /* This branch runs if the record-size field of the cell is a\n          ** single byte varint and the record fits entirely on the main\n          ** b-tree page.  */\n          testcase( pCell+nCell+1==pPage->aDataEnd );\n          c = sqlite3VdbeRecordCompare(nCell, (void*)&pCell[1], pIdxKey);\n        }else if( !(pCell[1] & 0x80) \n          && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal\n          /* && (pCell+nCell+2)<=pPage->aDataEnd */\n        ){\n          /* The record-size field is a 2 byte varint and the record \n          ** fits entirely on the main b-tree page.  */\n          testcase( pCell+nCell+2==pPage->aDataEnd );\n          c = sqlite3VdbeRecordCompare(nCell, (void*)&pCell[2], pIdxKey);\n        }else{\n          /* The record flows over onto one or more overflow pages. In\n          ** this case the whole cell needs to be parsed, a buffer allocated\n          ** and accessPayload() used to retrieve the record into the\n          ** buffer before VdbeRecordCompare() can be called. */\n          void *pCellKey;\n          u8 * const pCellBody = pCell - pPage->childPtrSize;\n          btreeParseCellPtr(pPage, pCellBody, &pCur->info);\n          nCell = (int)pCur->info.nKey;\n          pCellKey = sqlite3Malloc( nCell );\n          if( pCellKey==0 ){\n            rc = SQLITE_NOMEM;\n            goto moveto_finish;\n          }\n          rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);\n          if( rc ){\n            sqlite3_free(pCellKey);\n            goto moveto_finish;\n          }\n          c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);\n          sqlite3_free(pCellKey);\n        }\n      }\n      if( c==0 ){\n        if( pPage->intKey && !pPage->leaf ){\n          lwr = idx;\n          break;\n        }else{\n          *pRes = 0;\n          rc = SQLITE_OK;\n          goto moveto_finish;\n        }\n      }\n      if( c<0 ){\n        lwr = idx+1;\n      }else{\n        upr = idx-1;\n      }\n      if( lwr>upr ){\n        break;\n      }\n      pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2);\n    }\n    assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );\n    assert( pPage->isInit );\n    if( pPage->leaf ){\n      chldPg = 0;\n    }else if( lwr>=pPage->nCell ){\n      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    }else{\n      chldPg = get4byte(findCell(pPage, lwr));\n    }\n    if( chldPg==0 ){\n      assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );\n      *pRes = c;\n      rc = SQLITE_OK;\n      goto moveto_finish;\n    }\n    pCur->aiIdx[pCur->iPage] = (u16)lwr;\n    pCur->info.nSize = 0;\n    pCur->validNKey = 0;\n    rc = moveToChild(pCur, chldPg);\n    if( rc ) goto moveto_finish;\n  }\nmoveto_finish:\n  return rc;\n}\n\n\n/*\n** Return TRUE if the cursor is not pointing at an entry of the table.\n**\n** TRUE will be returned after a call to sqlite3BtreeNext() moves\n** past the last entry in the table or sqlite3BtreePrev() moves past\n** the first entry.  TRUE is also returned if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){\n  /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries\n  ** have been deleted? This API will need to change to return an error code\n  ** as well as the boolean result value.\n  */\n  return (CURSOR_VALID!=pCur->eState);\n}\n\n/*\n** Advance the cursor to the next entry in the database.  If\n** successful then set *pRes=0.  If the cursor\n** was already pointing to the last entry in the database before\n** this routine was called, then set *pRes=1.\n*/\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int *pRes){\n  int rc;\n  int idx;\n  MemPage *pPage;\n\n  assert( cursorHoldsMutex(pCur) );\n  rc = restoreCursorPosition(pCur);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pRes!=0 );\n  if( CURSOR_INVALID==pCur->eState ){\n    *pRes = 1;\n    return SQLITE_OK;\n  }\n  if( pCur->skipNext>0 ){\n    pCur->skipNext = 0;\n    *pRes = 0;\n    return SQLITE_OK;\n  }\n  pCur->skipNext = 0;\n\n  pPage = pCur->apPage[pCur->iPage];\n  idx = ++pCur->aiIdx[pCur->iPage];\n  assert( pPage->isInit );\n\n  /* If the database file is corrupt, it is possible for the value of idx \n  ** to be invalid here. This can only occur if a second cursor modifies\n  ** the page while cursor pCur is holding a reference to it. Which can\n  ** only happen if the database is corrupt in such a way as to link the\n  ** page into more than one b-tree structure. */\n  testcase( idx>pPage->nCell );\n\n  pCur->info.nSize = 0;\n  pCur->validNKey = 0;\n  if( idx>=pPage->nCell ){\n    if( !pPage->leaf ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n      if( rc ) return rc;\n      rc = moveToLeftmost(pCur);\n      *pRes = 0;\n      return rc;\n    }\n    do{\n      if( pCur->iPage==0 ){\n        *pRes = 1;\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_OK;\n      }\n      moveToParent(pCur);\n      pPage = pCur->apPage[pCur->iPage];\n    }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell );\n    *pRes = 0;\n    if( pPage->intKey ){\n      rc = sqlite3BtreeNext(pCur, pRes);\n    }else{\n      rc = SQLITE_OK;\n    }\n    return rc;\n  }\n  *pRes = 0;\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }\n  rc = moveToLeftmost(pCur);\n  return rc;\n}\n\n\n/*\n** Step the cursor to the back to the previous entry in the database.  If\n** successful then set *pRes=0.  If the cursor\n** was already pointing to the first entry in the database before\n** this routine was called, then set *pRes=1.\n*/\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){\n  int rc;\n  MemPage *pPage;\n\n  assert( cursorHoldsMutex(pCur) );\n  rc = restoreCursorPosition(pCur);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  pCur->atLast = 0;\n  if( CURSOR_INVALID==pCur->eState ){\n    *pRes = 1;\n    return SQLITE_OK;\n  }\n  if( pCur->skipNext<0 ){\n    pCur->skipNext = 0;\n    *pRes = 0;\n    return SQLITE_OK;\n  }\n  pCur->skipNext = 0;\n\n  pPage = pCur->apPage[pCur->iPage];\n  assert( pPage->isInit );\n  if( !pPage->leaf ){\n    int idx = pCur->aiIdx[pCur->iPage];\n    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));\n    if( rc ){\n      return rc;\n    }\n    rc = moveToRightmost(pCur);\n  }else{\n    while( pCur->aiIdx[pCur->iPage]==0 ){\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        *pRes = 1;\n        return SQLITE_OK;\n      }\n      moveToParent(pCur);\n    }\n    pCur->info.nSize = 0;\n    pCur->validNKey = 0;\n\n    pCur->aiIdx[pCur->iPage]--;\n    pPage = pCur->apPage[pCur->iPage];\n    if( pPage->intKey && !pPage->leaf ){\n      rc = sqlite3BtreePrevious(pCur, pRes);\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n  *pRes = 0;\n  return rc;\n}\n\n/*\n** Allocate a new page from the database file.\n**\n** The new page is marked as dirty.  (In other words, sqlite3PagerWrite()\n** has already been called on the new page.)  The new page has also\n** been referenced and the calling routine is responsible for calling\n** sqlite3PagerUnref() on the new page when it is done.\n**\n** SQLITE_OK is returned on success.  Any other return value indicates\n** an error.  *ppPage and *pPgno are undefined in the event of an error.\n** Do not invoke sqlite3PagerUnref() on *ppPage if an error is returned.\n**\n** If the \"nearby\" parameter is not 0, then an effort is made to \n** locate a page close to the page number \"nearby\".  This can be used in an\n** attempt to keep related pages close to each other in the database file,\n** which in turn can make database access faster.\n**\n** If the eMode parameter is BTALLOC_EXACT and the nearby page exists\n** anywhere on the free-list, then it is guaranteed to be returned.  If\n** eMode is BTALLOC_LT then the page returned will be less than or equal\n** to nearby if any such page exists.  If eMode is BTALLOC_ANY then there\n** are no restrictions on which page is returned.\n*/\nstatic int allocateBtreePage(\n  BtShared *pBt,         /* The btree */\n  MemPage **ppPage,      /* Store pointer to the allocated page here */\n  Pgno *pPgno,           /* Store the page number here */\n  Pgno nearby,           /* Search for a page near this one */\n  u8 eMode               /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */\n){\n  MemPage *pPage1;\n  int rc;\n  u32 n;     /* Number of pages on the freelist */\n  u32 k;     /* Number of leaves on the trunk of the freelist */\n  MemPage *pTrunk = 0;\n  MemPage *pPrevTrunk = 0;\n  Pgno mxPage;     /* Total size of the database file */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );\n  pPage1 = pBt->pPage1;\n  mxPage = btreePagecount(pBt);\n  n = get4byte(&pPage1->aData[36]);\n  testcase( n==mxPage-1 );\n  if( n>=mxPage ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  if( n>0 ){\n    /* There are pages on the freelist.  Reuse one of those pages. */\n    Pgno iTrunk;\n    u8 searchList = 0; /* If the free-list must be searched for 'nearby' */\n    \n    /* If eMode==BTALLOC_EXACT and a query of the pointer-map\n    ** shows that the page 'nearby' is somewhere on the free-list, then\n    ** the entire-list will be searched for that page.\n    */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( eMode==BTALLOC_EXACT ){\n      if( nearby<=mxPage ){\n        u8 eType;\n        assert( nearby>0 );\n        assert( pBt->autoVacuum );\n        rc = ptrmapGet(pBt, nearby, &eType, 0);\n        if( rc ) return rc;\n        if( eType==PTRMAP_FREEPAGE ){\n          searchList = 1;\n        }\n      }\n    }else if( eMode==BTALLOC_LE ){\n      searchList = 1;\n    }\n#endif\n\n    /* Decrement the free-list count by 1. Set iTrunk to the index of the\n    ** first free-list trunk page. iPrevTrunk is initially 1.\n    */\n    rc = sqlite3PagerWrite(pPage1->pDbPage);\n    if( rc ) return rc;\n    put4byte(&pPage1->aData[36], n-1);\n\n    /* The code within this loop is run only once if the 'searchList' variable\n    ** is not true. Otherwise, it runs once for each trunk-page on the\n    ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT)\n    ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT)\n    */\n    do {\n      pPrevTrunk = pTrunk;\n      if( pPrevTrunk ){\n        iTrunk = get4byte(&pPrevTrunk->aData[0]);\n      }else{\n        iTrunk = get4byte(&pPage1->aData[32]);\n      }\n      testcase( iTrunk==mxPage );\n      if( iTrunk>mxPage ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }else{\n        rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0, 0);\n      }\n      if( rc ){\n        pTrunk = 0;\n        goto end_allocate_page;\n      }\n      assert( pTrunk!=0 );\n      assert( pTrunk->aData!=0 );\n\n      k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */\n      if( k==0 && !searchList ){\n        /* The trunk has no leaves and the list is not being searched. \n        ** So extract the trunk page itself and use it as the newly \n        ** allocated page */\n        assert( pPrevTrunk==0 );\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        *pPgno = iTrunk;\n        memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n        *ppPage = pTrunk;\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n      }else if( k>(u32)(pBt->usableSize/4 - 2) ){\n        /* Value of k is out of range.  Database corruption */\n        rc = SQLITE_CORRUPT_BKPT;\n        goto end_allocate_page;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      }else if( searchList \n            && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE)) \n      ){\n        /* The list is being searched and this trunk page is the page\n        ** to allocate, regardless of whether it has leaves.\n        */\n        *pPgno = iTrunk;\n        *ppPage = pTrunk;\n        searchList = 0;\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        if( k==0 ){\n          if( !pPrevTrunk ){\n            memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc!=SQLITE_OK ){\n              goto end_allocate_page;\n            }\n            memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);\n          }\n        }else{\n          /* The trunk page is required by the caller but it contains \n          ** pointers to free-list leaves. The first leaf becomes a trunk\n          ** page in this case.\n          */\n          MemPage *pNewTrunk;\n          Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);\n          if( iNewTrunk>mxPage ){ \n            rc = SQLITE_CORRUPT_BKPT;\n            goto end_allocate_page;\n          }\n          testcase( iNewTrunk==mxPage );\n          rc = btreeGetPage(pBt, iNewTrunk, &pNewTrunk, 0, 0);\n          if( rc!=SQLITE_OK ){\n            goto end_allocate_page;\n          }\n          rc = sqlite3PagerWrite(pNewTrunk->pDbPage);\n          if( rc!=SQLITE_OK ){\n            releasePage(pNewTrunk);\n            goto end_allocate_page;\n          }\n          memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);\n          put4byte(&pNewTrunk->aData[4], k-1);\n          memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);\n          releasePage(pNewTrunk);\n          if( !pPrevTrunk ){\n            assert( sqlite3PagerIswriteable(pPage1->pDbPage) );\n            put4byte(&pPage1->aData[32], iNewTrunk);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc ){\n              goto end_allocate_page;\n            }\n            put4byte(&pPrevTrunk->aData[0], iNewTrunk);\n          }\n        }\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n#endif\n      }else if( k>0 ){\n        /* Extract a leaf from the trunk */\n        u32 closest;\n        Pgno iPage;\n        unsigned char *aData = pTrunk->aData;\n        if( nearby>0 ){\n          u32 i;\n          closest = 0;\n          if( eMode==BTALLOC_LE ){\n            for(i=0; i<k; i++){\n              iPage = get4byte(&aData[8+i*4]);\n              if( iPage<=nearby ){\n                closest = i;\n                break;\n              }\n            }\n          }else{\n            int dist;\n            dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);\n            for(i=1; i<k; i++){\n              int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);\n              if( d2<dist ){\n                closest = i;\n                dist = d2;\n              }\n            }\n          }\n        }else{\n          closest = 0;\n        }\n\n        iPage = get4byte(&aData[8+closest*4]);\n        testcase( iPage==mxPage );\n        if( iPage>mxPage ){\n          rc = SQLITE_CORRUPT_BKPT;\n          goto end_allocate_page;\n        }\n        testcase( iPage==mxPage );\n        if( !searchList \n         || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE)) \n        ){\n          int noContent;\n          *pPgno = iPage;\n          TRACE((\"ALLOCATE: %d was leaf %d of %d on trunk %d\"\n                 \": %d more free pages\\n\",\n                 *pPgno, closest+1, k, pTrunk->pgno, n-1));\n          rc = sqlite3PagerWrite(pTrunk->pDbPage);\n          if( rc ) goto end_allocate_page;\n          if( closest<k-1 ){\n            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);\n          }\n          put4byte(&aData[4], k-1);\n          noContent = !btreeGetHasContent(pBt, *pPgno);\n          rc = btreeGetPage(pBt, *pPgno, ppPage, noContent, 0);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n            if( rc!=SQLITE_OK ){\n              releasePage(*ppPage);\n            }\n          }\n          searchList = 0;\n        }\n      }\n      releasePage(pPrevTrunk);\n      pPrevTrunk = 0;\n    }while( searchList );\n  }else{\n    /* There are no pages on the freelist, so append a new page to the\n    ** database image.\n    **\n    ** Normally, new pages allocated by this block can be requested from the\n    ** pager layer with the 'no-content' flag set. This prevents the pager\n    ** from trying to read the pages content from disk. However, if the\n    ** current transaction has already run one or more incremental-vacuum\n    ** steps, then the page we are about to allocate may contain content\n    ** that is required in the event of a rollback. In this case, do\n    ** not set the no-content flag. This causes the pager to load and journal\n    ** the current page content before overwriting it.\n    **\n    ** Note that the pager will not actually attempt to load or journal \n    ** content for any page that really does lie past the end of the database\n    ** file on disk. So the effects of disabling the no-content optimization\n    ** here are confined to those pages that lie between the end of the\n    ** database image and the end of the database file.\n    */\n    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate));\n\n    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n    if( rc ) return rc;\n    pBt->nPage++;\n    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){\n      /* If *pPgno refers to a pointer-map page, allocate two new pages\n      ** at the end of the file instead of one. The first allocated page\n      ** becomes a new pointer-map page, the second is used by the caller.\n      */\n      MemPage *pPg = 0;\n      TRACE((\"ALLOCATE: %d from end of file (pointer-map page)\\n\", pBt->nPage));\n      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );\n      rc = btreeGetPage(pBt, pBt->nPage, &pPg, bNoContent, 0);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pPg->pDbPage);\n        releasePage(pPg);\n      }\n      if( rc ) return rc;\n      pBt->nPage++;\n      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }\n    }\n#endif\n    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);\n    *pPgno = pBt->nPage;\n\n    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n    rc = btreeGetPage(pBt, *pPgno, ppPage, bNoContent, 0);\n    if( rc ) return rc;\n    rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n    }\n    TRACE((\"ALLOCATE: %d from end of file\\n\", *pPgno));\n  }\n\n  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n\nend_allocate_page:\n  releasePage(pTrunk);\n  releasePage(pPrevTrunk);\n  if( rc==SQLITE_OK ){\n    if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){\n      releasePage(*ppPage);\n      return SQLITE_CORRUPT_BKPT;\n    }\n    (*ppPage)->isInit = 0;\n  }else{\n    *ppPage = 0;\n  }\n  assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );\n  return rc;\n}\n\n/*\n** This function is used to add page iPage to the database file free-list. \n** It is assumed that the page is not already a part of the free-list.\n**\n** The value passed as the second argument to this function is optional.\n** If the caller happens to have a pointer to the MemPage object \n** corresponding to page iPage handy, it may pass it as the second value. \n** Otherwise, it may pass NULL.\n**\n** If a pointer to a MemPage object is passed as the second argument,\n** its reference count is not altered by this function.\n*/\nstatic int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){\n  MemPage *pTrunk = 0;                /* Free-list trunk page */\n  Pgno iTrunk = 0;                    /* Page number of free-list trunk page */ \n  MemPage *pPage1 = pBt->pPage1;      /* Local reference to page 1 */\n  MemPage *pPage;                     /* Page being freed. May be NULL. */\n  int rc;                             /* Return Code */\n  int nFree;                          /* Initial number of pages on free-list */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( iPage>1 );\n  assert( !pMemPage || pMemPage->pgno==iPage );\n\n  if( pMemPage ){\n    pPage = pMemPage;\n    sqlite3PagerRef(pPage->pDbPage);\n  }else{\n    pPage = btreePageLookup(pBt, iPage);\n  }\n\n  /* Increment the free page count on pPage1 */\n  rc = sqlite3PagerWrite(pPage1->pDbPage);\n  if( rc ) goto freepage_out;\n  nFree = get4byte(&pPage1->aData[36]);\n  put4byte(&pPage1->aData[36], nFree+1);\n\n  if( pBt->btsFlags & BTS_SECURE_DELETE ){\n    /* If the secure_delete option is enabled, then\n    ** always fully overwrite deleted information with zeros.\n    */\n    if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0, 0))!=0) )\n     ||            ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0)\n    ){\n      goto freepage_out;\n    }\n    memset(pPage->aData, 0, pPage->pBt->pageSize);\n  }\n\n  /* If the database supports auto-vacuum, write an entry in the pointer-map\n  ** to indicate that the page is free.\n  */\n  if( ISAUTOVACUUM ){\n    ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);\n    if( rc ) goto freepage_out;\n  }\n\n  /* Now manipulate the actual database free-list structure. There are two\n  ** possibilities. If the free-list is currently empty, or if the first\n  ** trunk page in the free-list is full, then this page will become a\n  ** new free-list trunk page. Otherwise, it will become a leaf of the\n  ** first trunk page in the current free-list. This block tests if it\n  ** is possible to add the page as a new free-list leaf.\n  */\n  if( nFree!=0 ){\n    u32 nLeaf;                /* Initial number of leaf cells on trunk page */\n\n    iTrunk = get4byte(&pPage1->aData[32]);\n    rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0, 0);\n    if( rc!=SQLITE_OK ){\n      goto freepage_out;\n    }\n\n    nLeaf = get4byte(&pTrunk->aData[4]);\n    assert( pBt->usableSize>32 );\n    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto freepage_out;\n    }\n    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){\n      /* In this case there is room on the trunk page to insert the page\n      ** being freed as a new leaf.\n      **\n      ** Note that the trunk page is not really full until it contains\n      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have\n      ** coded.  But due to a coding error in versions of SQLite prior to\n      ** 3.6.0, databases with freelist trunk pages holding more than\n      ** usableSize/4 - 8 entries will be reported as corrupt.  In order\n      ** to maintain backwards compatibility with older versions of SQLite,\n      ** we will continue to restrict the number of entries to usableSize/4 - 8\n      ** for now.  At some point in the future (once everyone has upgraded\n      ** to 3.6.0 or later) we should consider fixing the conditional above\n      ** to read \"usableSize/4-2\" instead of \"usableSize/4-8\".\n      */\n      rc = sqlite3PagerWrite(pTrunk->pDbPage);\n      if( rc==SQLITE_OK ){\n        put4byte(&pTrunk->aData[4], nLeaf+1);\n        put4byte(&pTrunk->aData[8+nLeaf*4], iPage);\n        if( pPage && (pBt->btsFlags & BTS_SECURE_DELETE)==0 ){\n          sqlite3PagerDontWrite(pPage->pDbPage);\n        }\n        rc = btreeSetHasContent(pBt, iPage);\n      }\n      TRACE((\"FREE-PAGE: %d leaf on trunk page %d\\n\",pPage->pgno,pTrunk->pgno));\n      goto freepage_out;\n    }\n  }\n\n  /* If control flows to this point, then it was not possible to add the\n  ** the page being freed as a leaf page of the first trunk in the free-list.\n  ** Possibly because the free-list is empty, or possibly because the \n  ** first trunk in the free-list is full. Either way, the page being freed\n  ** will become the new first trunk page in the free-list.\n  */\n  if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0, 0)) ){\n    goto freepage_out;\n  }\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc!=SQLITE_OK ){\n    goto freepage_out;\n  }\n  put4byte(pPage->aData, iTrunk);\n  put4byte(&pPage->aData[4], 0);\n  put4byte(&pPage1->aData[32], iPage);\n  TRACE((\"FREE-PAGE: %d new trunk page replacing %d\\n\", pPage->pgno, iTrunk));\n\nfreepage_out:\n  if( pPage ){\n    pPage->isInit = 0;\n  }\n  releasePage(pPage);\n  releasePage(pTrunk);\n  return rc;\n}\nstatic void freePage(MemPage *pPage, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);\n  }\n}\n\n/*\n** Free any overflow pages associated with the given Cell.\n*/\nstatic int clearCell(MemPage *pPage, unsigned char *pCell){\n  BtShared *pBt = pPage->pBt;\n  CellInfo info;\n  Pgno ovflPgno;\n  int rc;\n  int nOvfl;\n  u32 ovflPageSize;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  btreeParseCellPtr(pPage, pCell, &info);\n  if( info.iOverflow==0 ){\n    return SQLITE_OK;  /* No overflow pages. Return without doing anything */\n  }\n  if( pCell+info.iOverflow+3 > pPage->aData+pPage->maskPage ){\n    return SQLITE_CORRUPT_BKPT;  /* Cell extends past end of page */\n  }\n  ovflPgno = get4byte(&pCell[info.iOverflow]);\n  assert( pBt->usableSize > 4 );\n  ovflPageSize = pBt->usableSize - 4;\n  nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;\n  assert( ovflPgno==0 || nOvfl>0 );\n  while( nOvfl-- ){\n    Pgno iNext = 0;\n    MemPage *pOvfl = 0;\n    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){\n      /* 0 is not a legal page number and page 1 cannot be an \n      ** overflow page. Therefore if ovflPgno<2 or past the end of the \n      ** file the database must be corrupt. */\n      return SQLITE_CORRUPT_BKPT;\n    }\n    if( nOvfl ){\n      rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);\n      if( rc ) return rc;\n    }\n\n    if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )\n     && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1\n    ){\n      /* There is no reason any cursor should have an outstanding reference \n      ** to an overflow page belonging to a cell that is being deleted/updated.\n      ** So if there exists more than one reference to this page, then it \n      ** must not really be an overflow page and the database must be corrupt. \n      ** It is helpful to detect this before calling freePage2(), as \n      ** freePage2() may zero the page contents if secure-delete mode is\n      ** enabled. If this 'overflow' page happens to be a page that the\n      ** caller is iterating through or using in some other way, this\n      ** can be problematic.\n      */\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = freePage2(pBt, pOvfl, ovflPgno);\n    }\n\n    if( pOvfl ){\n      sqlite3PagerUnref(pOvfl->pDbPage);\n    }\n    if( rc ) return rc;\n    ovflPgno = iNext;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create the byte sequence used to represent a cell on page pPage\n** and write that byte sequence into pCell[].  Overflow pages are\n** allocated and filled in as necessary.  The calling procedure\n** is responsible for making sure sufficient space has been allocated\n** for pCell[].\n**\n** Note that pCell does not necessary need to point to the pPage->aData\n** area.  pCell might point to some temporary storage.  The cell will\n** be constructed in this temporary area then copied into pPage->aData\n** later.\n*/\nstatic int fillInCell(\n  MemPage *pPage,                /* The page that contains the cell */\n  unsigned char *pCell,          /* Complete text of the cell */\n  const void *pKey, i64 nKey,    /* The key */\n  const void *pData,int nData,   /* The data */\n  int nZero,                     /* Extra zero bytes to append to pData */\n  int *pnSize                    /* Write cell size here */\n){\n  int nPayload;\n  const u8 *pSrc;\n  int nSrc, n, rc;\n  int spaceLeft;\n  MemPage *pOvfl = 0;\n  MemPage *pToRelease = 0;\n  unsigned char *pPrior;\n  unsigned char *pPayload;\n  BtShared *pBt = pPage->pBt;\n  Pgno pgnoOvfl = 0;\n  int nHeader;\n  CellInfo info;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n\n  /* pPage is not necessarily writeable since pCell might be auxiliary\n  ** buffer space that is separate from the pPage buffer area */\n  assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n  /* Fill in the header. */\n  nHeader = 0;\n  if( !pPage->leaf ){\n    nHeader += 4;\n  }\n  if( pPage->hasData ){\n    nHeader += putVarint(&pCell[nHeader], nData+nZero);\n  }else{\n    nData = nZero = 0;\n  }\n  nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey);\n  btreeParseCellPtr(pPage, pCell, &info);\n  assert( info.nHeader==nHeader );\n  assert( info.nKey==nKey );\n  assert( info.nData==(u32)(nData+nZero) );\n  \n  /* Fill in the payload */\n  nPayload = nData + nZero;\n  if( pPage->intKey ){\n    pSrc = pData;\n    nSrc = nData;\n    nData = 0;\n  }else{ \n    if( NEVER(nKey>0x7fffffff || pKey==0) ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n    nPayload += (int)nKey;\n    pSrc = pKey;\n    nSrc = (int)nKey;\n  }\n  *pnSize = info.nSize;\n  spaceLeft = info.nLocal;\n  pPayload = &pCell[nHeader];\n  pPrior = &pCell[info.iOverflow];\n\n  while( nPayload>0 ){\n    if( spaceLeft==0 ){\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */\n      if( pBt->autoVacuum ){\n        do{\n          pgnoOvfl++;\n        } while( \n          PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) \n        );\n      }\n#endif\n      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the database supports auto-vacuum, and the second or subsequent\n      ** overflow page is being allocated, add an entry to the pointer-map\n      ** for that page now. \n      **\n      ** If this is the first overflow page, then write a partial entry \n      ** to the pointer-map. If we write nothing to this pointer-map slot,\n      ** then the optimistic overflow chain processing in clearCell()\n      ** may misinterpret the uninitialized values and delete the\n      ** wrong pages from the database.\n      */\n      if( pBt->autoVacuum && rc==SQLITE_OK ){\n        u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);\n        ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);\n        if( rc ){\n          releasePage(pOvfl);\n        }\n      }\n#endif\n      if( rc ){\n        releasePage(pToRelease);\n        return rc;\n      }\n\n      /* If pToRelease is not zero than pPrior points into the data area\n      ** of pToRelease.  Make sure pToRelease is still writeable. */\n      assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n      /* If pPrior is part of the data area of pPage, then make sure pPage\n      ** is still writeable */\n      assert( pPrior<pPage->aData || pPrior>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n      put4byte(pPrior, pgnoOvfl);\n      releasePage(pToRelease);\n      pToRelease = pOvfl;\n      pPrior = pOvfl->aData;\n      put4byte(pPrior, 0);\n      pPayload = &pOvfl->aData[4];\n      spaceLeft = pBt->usableSize - 4;\n    }\n    n = nPayload;\n    if( n>spaceLeft ) n = spaceLeft;\n\n    /* If pToRelease is not zero than pPayload points into the data area\n    ** of pToRelease.  Make sure pToRelease is still writeable. */\n    assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n    /* If pPayload is part of the data area of pPage, then make sure pPage\n    ** is still writeable */\n    assert( pPayload<pPage->aData || pPayload>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n    if( nSrc>0 ){\n      if( n>nSrc ) n = nSrc;\n      assert( pSrc );\n      memcpy(pPayload, pSrc, n);\n    }else{\n      memset(pPayload, 0, n);\n    }\n    nPayload -= n;\n    pPayload += n;\n    pSrc += n;\n    nSrc -= n;\n    spaceLeft -= n;\n    if( nSrc==0 ){\n      nSrc = nData;\n      pSrc = pData;\n    }\n  }\n  releasePage(pToRelease);\n  return SQLITE_OK;\n}\n\n/*\n** Remove the i-th cell from pPage.  This routine effects pPage only.\n** The cell content is not freed or deallocated.  It is assumed that\n** the cell content has been copied someplace else.  This routine just\n** removes the reference to the cell from pPage.\n**\n** \"sz\" must be the number of bytes in the cell.\n*/\nstatic void dropCell(MemPage *pPage, int idx, int sz, int *pRC){\n  u32 pc;         /* Offset to cell content of cell being deleted */\n  u8 *data;       /* pPage->aData */\n  u8 *ptr;        /* Used to move bytes around within data[] */\n  u8 *endPtr;     /* End of loop */\n  int rc;         /* The return code */\n  int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */\n\n  if( *pRC ) return;\n\n  assert( idx>=0 && idx<pPage->nCell );\n  assert( sz==cellSize(pPage, idx) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  data = pPage->aData;\n  ptr = &pPage->aCellIdx[2*idx];\n  pc = get2byte(ptr);\n  hdr = pPage->hdrOffset;\n  testcase( pc==get2byte(&data[hdr+5]) );\n  testcase( pc+sz==pPage->pBt->usableSize );\n  if( pc < (u32)get2byte(&data[hdr+5]) || pc+sz > pPage->pBt->usableSize ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  rc = freeSpace(pPage, pc, sz);\n  if( rc ){\n    *pRC = rc;\n    return;\n  }\n  endPtr = &pPage->aCellIdx[2*pPage->nCell - 2];\n  assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 );  /* ptr is always 2-byte aligned */\n  while( ptr<endPtr ){\n    *(u16*)ptr = *(u16*)&ptr[2];\n    ptr += 2;\n  }\n  pPage->nCell--;\n  put2byte(&data[hdr+3], pPage->nCell);\n  pPage->nFree += 2;\n}\n\n/*\n** Insert a new cell on pPage at cell index \"i\".  pCell points to the\n** content of the cell.\n**\n** If the cell content will fit on the page, then put it there.  If it\n** will not fit, then make a copy of the cell content into pTemp if\n** pTemp is not null.  Regardless of pTemp, allocate a new entry\n** in pPage->apOvfl[] and make it point to the cell content (either\n** in pTemp or the original pCell) and also record its index. \n** Allocating a new entry in pPage->aCell[] implies that \n** pPage->nOverflow is incremented.\n**\n** If nSkip is non-zero, then do not copy the first nSkip bytes of the\n** cell. The caller will overwrite them after this function returns. If\n** nSkip is non-zero, then pCell may not point to an invalid memory location \n** (but pCell+nSkip is always valid).\n*/\nstatic void insertCell(\n  MemPage *pPage,   /* Page into which we are copying */\n  int i,            /* New cell becomes the i-th cell of the page */\n  u8 *pCell,        /* Content of the new cell */\n  int sz,           /* Bytes of content in pCell */\n  u8 *pTemp,        /* Temp storage space for pCell, if needed */\n  Pgno iChild,      /* If non-zero, replace first 4 bytes with this value */\n  int *pRC          /* Read and write return code from here */\n){\n  int idx = 0;      /* Where to write new cell content in data[] */\n  int j;            /* Loop counter */\n  int end;          /* First byte past the last cell pointer in data[] */\n  int ins;          /* Index in data[] where new cell pointer is inserted */\n  int cellOffset;   /* Address of first cell pointer in data[] */\n  u8 *data;         /* The content of the whole page */\n  u8 *ptr;          /* Used for moving information around in data[] */\n  u8 *endPtr;       /* End of the loop */\n\n  int nSkip = (iChild ? 4 : 0);\n\n  if( *pRC ) return;\n\n  assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );\n  assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=10921 );\n  assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );\n  assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  /* The cell should normally be sized correctly.  However, when moving a\n  ** malformed cell from a leaf page to an interior page, if the cell size\n  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size\n  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence\n  ** the term after the || in the following assert(). */\n  assert( sz==cellSizePtr(pPage, pCell) || (sz==8 && iChild>0) );\n  if( pPage->nOverflow || sz+2>pPage->nFree ){\n    if( pTemp ){\n      memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip);\n      pCell = pTemp;\n    }\n    if( iChild ){\n      put4byte(pCell, iChild);\n    }\n    j = pPage->nOverflow++;\n    assert( j<(int)(sizeof(pPage->apOvfl)/sizeof(pPage->apOvfl[0])) );\n    pPage->apOvfl[j] = pCell;\n    pPage->aiOvfl[j] = (u16)i;\n  }else{\n    int rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n    assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n    data = pPage->aData;\n    cellOffset = pPage->cellOffset;\n    end = cellOffset + 2*pPage->nCell;\n    ins = cellOffset + 2*i;\n    rc = allocateSpace(pPage, sz, &idx);\n    if( rc ){ *pRC = rc; return; }\n    /* The allocateSpace() routine guarantees the following two properties\n    ** if it returns success */\n    assert( idx >= end+2 );\n    assert( idx+sz <= (int)pPage->pBt->usableSize );\n    pPage->nCell++;\n    pPage->nFree -= (u16)(2 + sz);\n    memcpy(&data[idx+nSkip], pCell+nSkip, sz-nSkip);\n    if( iChild ){\n      put4byte(&data[idx], iChild);\n    }\n    ptr = &data[end];\n    endPtr = &data[ins];\n    assert( (SQLITE_PTR_TO_INT(ptr)&1)==0 );  /* ptr is always 2-byte aligned */\n    while( ptr>endPtr ){\n      *(u16*)ptr = *(u16*)&ptr[-2];\n      ptr -= 2;\n    }\n    put2byte(&data[ins], idx);\n    put2byte(&data[pPage->hdrOffset+3], pPage->nCell);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pPage->pBt->autoVacuum ){\n      /* The cell may contain a pointer to an overflow page. If so, write\n      ** the entry for the overflow page into the pointer map.\n      */\n      ptrmapPutOvflPtr(pPage, pCell, pRC);\n    }\n#endif\n  }\n}\n\n/*\n** Add a list of cells to a page.  The page should be initially empty.\n** The cells are guaranteed to fit on the page.\n*/\nstatic void assemblePage(\n  MemPage *pPage,   /* The page to be assemblied */\n  int nCell,        /* The number of cells to add to this page */\n  u8 **apCell,      /* Pointers to cell bodies */\n  u16 *aSize        /* Sizes of the cells */\n){\n  int i;            /* Loop counter */\n  u8 *pCellptr;     /* Address of next cell pointer */\n  int cellbody;     /* Address of next cell body */\n  u8 * const data = pPage->aData;             /* Pointer to data for pPage */\n  const int hdr = pPage->hdrOffset;           /* Offset of header on pPage */\n  const int nUsable = pPage->pBt->usableSize; /* Usable size of page */\n\n  assert( pPage->nOverflow==0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( nCell>=0 && nCell<=(int)MX_CELL(pPage->pBt)\n            && (int)MX_CELL(pPage->pBt)<=10921);\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n\n  /* Check that the page has just been zeroed by zeroPage() */\n  assert( pPage->nCell==0 );\n  assert( get2byteNotZero(&data[hdr+5])==nUsable );\n\n  pCellptr = &pPage->aCellIdx[nCell*2];\n  cellbody = nUsable;\n  for(i=nCell-1; i>=0; i--){\n    u16 sz = aSize[i];\n    pCellptr -= 2;\n    cellbody -= sz;\n    put2byte(pCellptr, cellbody);\n    memcpy(&data[cellbody], apCell[i], sz);\n  }\n  put2byte(&data[hdr+3], nCell);\n  put2byte(&data[hdr+5], cellbody);\n  pPage->nFree -= (nCell*2 + nUsable - cellbody);\n  pPage->nCell = (u16)nCell;\n}\n\n/*\n** The following parameters determine how many adjacent pages get involved\n** in a balancing operation.  NN is the number of neighbors on either side\n** of the page that participate in the balancing operation.  NB is the\n** total number of pages that participate, including the target page and\n** NN neighbors on either side.\n**\n** The minimum value of NN is 1 (of course).  Increasing NN above 1\n** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance\n** in exchange for a larger degradation in INSERT and UPDATE performance.\n** The value of NN appears to give the best results overall.\n*/\n#define NN 1             /* Number of neighbors on either side of pPage */\n#define NB (NN*2+1)      /* Total pages involved in the balance */\n\n\n#ifndef SQLITE_OMIT_QUICKBALANCE\n/*\n** This version of balance() handles the common special case where\n** a new entry is being inserted on the extreme right-end of the\n** tree, in other words, when the new entry will become the largest\n** entry in the tree.\n**\n** Instead of trying to balance the 3 right-most leaf pages, just add\n** a new page to the right-hand side and put the one new entry in\n** that page.  This leaves the right side of the tree somewhat\n** unbalanced.  But odds are that we will be inserting new entries\n** at the end soon afterwards so the nearly empty page will quickly\n** fill up.  On average.\n**\n** pPage is the leaf page which is the right-most page in the tree.\n** pParent is its parent.  pPage must have a single overflow entry\n** which is also the right-most entry on the page.\n**\n** The pSpace buffer is used to store a temporary copy of the divider\n** cell that will be inserted into pParent. Such a cell consists of a 4\n** byte page number followed by a variable length integer. In other\n** words, at most 13 bytes. Hence the pSpace buffer must be at\n** least 13 bytes in size.\n*/\nstatic int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){\n  BtShared *const pBt = pPage->pBt;    /* B-Tree Database */\n  MemPage *pNew;                       /* Newly allocated page */\n  int rc;                              /* Return Code */\n  Pgno pgnoNew;                        /* Page number of pNew */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  assert( pPage->nOverflow==1 );\n\n  /* This error condition is now caught prior to reaching this function */\n  if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;\n\n  /* Allocate a new page. This page will become the right-sibling of \n  ** pPage. Make the parent page writable, so that the new divider cell\n  ** may be inserted. If both these operations are successful, proceed.\n  */\n  rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);\n\n  if( rc==SQLITE_OK ){\n\n    u8 *pOut = &pSpace[4];\n    u8 *pCell = pPage->apOvfl[0];\n    u16 szCell = cellSizePtr(pPage, pCell);\n    u8 *pStop;\n\n    assert( sqlite3PagerIswriteable(pNew->pDbPage) );\n    assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );\n    zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);\n    assemblePage(pNew, 1, &pCell, &szCell);\n\n    /* If this is an auto-vacuum database, update the pointer map\n    ** with entries for the new page, and any pointer from the \n    ** cell on the page to an overflow page. If either of these\n    ** operations fails, the return code is set, but the contents\n    ** of the parent page are still manipulated by thh code below.\n    ** That is Ok, at this point the parent page is guaranteed to\n    ** be marked as dirty. Returning an error code will cause a\n    ** rollback, undoing any changes made to the parent page.\n    */\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);\n      if( szCell>pNew->minLocal ){\n        ptrmapPutOvflPtr(pNew, pCell, &rc);\n      }\n    }\n  \n    /* Create a divider cell to insert into pParent. The divider cell\n    ** consists of a 4-byte page number (the page number of pPage) and\n    ** a variable length key value (which must be the same value as the\n    ** largest key on pPage).\n    **\n    ** To find the largest key value on pPage, first find the right-most \n    ** cell on pPage. The first two fields of this cell are the \n    ** record-length (a variable length integer at most 32-bits in size)\n    ** and the key value (a variable length integer, may have any value).\n    ** The first of the while(...) loops below skips over the record-length\n    ** field. The second while(...) loop copies the key value from the\n    ** cell on pPage into the pSpace buffer.\n    */\n    pCell = findCell(pPage, pPage->nCell-1);\n    pStop = &pCell[9];\n    while( (*(pCell++)&0x80) && pCell<pStop );\n    pStop = &pCell[9];\n    while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );\n\n    /* Insert the new divider cell into pParent. */\n    insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),\n               0, pPage->pgno, &rc);\n\n    /* Set the right-child pointer of pParent to point to the new page. */\n    put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);\n  \n    /* Release the reference to the new page. */\n    releasePage(pNew);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_OMIT_QUICKBALANCE */\n\n#if 0\n/*\n** This function does not contribute anything to the operation of SQLite.\n** it is sometimes activated temporarily while debugging code responsible \n** for setting pointer-map entries.\n*/\nstatic int ptrmapCheckPages(MemPage **apPage, int nPage){\n  int i, j;\n  for(i=0; i<nPage; i++){\n    Pgno n;\n    u8 e;\n    MemPage *pPage = apPage[i];\n    BtShared *pBt = pPage->pBt;\n    assert( pPage->isInit );\n\n    for(j=0; j<pPage->nCell; j++){\n      CellInfo info;\n      u8 *z;\n     \n      z = findCell(pPage, j);\n      btreeParseCellPtr(pPage, z, &info);\n      if( info.iOverflow ){\n        Pgno ovfl = get4byte(&z[info.iOverflow]);\n        ptrmapGet(pBt, ovfl, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );\n      }\n      if( !pPage->leaf ){\n        Pgno child = get4byte(z);\n        ptrmapGet(pBt, child, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_BTREE );\n      }\n    }\n    if( !pPage->leaf ){\n      Pgno child = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n      ptrmapGet(pBt, child, &e, &n);\n      assert( n==pPage->pgno && e==PTRMAP_BTREE );\n    }\n  }\n  return 1;\n}\n#endif\n\n/*\n** This function is used to copy the contents of the b-tree node stored \n** on page pFrom to page pTo. If page pFrom was not a leaf page, then\n** the pointer-map entries for each child page are updated so that the\n** parent page stored in the pointer map is page pTo. If pFrom contained\n** any cells with overflow page pointers, then the corresponding pointer\n** map entries are also updated so that the parent page is page pTo.\n**\n** If pFrom is currently carrying any overflow cells (entries in the\n** MemPage.apOvfl[] array), they are not copied to pTo. \n**\n** Before returning, page pTo is reinitialized using btreeInitPage().\n**\n** The performance of this function is not critical. It is only used by \n** the balance_shallower() and balance_deeper() procedures, neither of\n** which are called often under normal circumstances.\n*/\nstatic void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    BtShared * const pBt = pFrom->pBt;\n    u8 * const aFrom = pFrom->aData;\n    u8 * const aTo = pTo->aData;\n    int const iFromHdr = pFrom->hdrOffset;\n    int const iToHdr = ((pTo->pgno==1) ? 100 : 0);\n    int rc;\n    int iData;\n  \n  \n    assert( pFrom->isInit );\n    assert( pFrom->nFree>=iToHdr );\n    assert( get2byte(&aFrom[iFromHdr+5]) <= (int)pBt->usableSize );\n  \n    /* Copy the b-tree node content from page pFrom to page pTo. */\n    iData = get2byte(&aFrom[iFromHdr+5]);\n    memcpy(&aTo[iData], &aFrom[iData], pBt->usableSize-iData);\n    memcpy(&aTo[iToHdr], &aFrom[iFromHdr], pFrom->cellOffset + 2*pFrom->nCell);\n  \n    /* Reinitialize page pTo so that the contents of the MemPage structure\n    ** match the new data. The initialization of pTo can actually fail under\n    ** fairly obscure circumstances, even though it is a copy of initialized \n    ** page pFrom.\n    */\n    pTo->isInit = 0;\n    rc = btreeInitPage(pTo);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n  \n    /* If this is an auto-vacuum database, update the pointer-map entries\n    ** for any b-tree or overflow pages that pTo now contains the pointers to.\n    */\n    if( ISAUTOVACUUM ){\n      *pRC = setChildPtrmaps(pTo);\n    }\n  }\n}\n\n/*\n** This routine redistributes cells on the iParentIdx'th child of pParent\n** (hereafter \"the page\") and up to 2 siblings so that all pages have about the\n** same amount of free space. Usually a single sibling on either side of the\n** page are used in the balancing, though both siblings might come from one\n** side if the page is the first or last child of its parent. If the page \n** has fewer than 2 siblings (something which can only happen if the page\n** is a root page or a child of a root page) then all available siblings\n** participate in the balancing.\n**\n** The number of siblings of the page might be increased or decreased by \n** one or two in an effort to keep pages nearly full but not over full. \n**\n** Note that when this routine is called, some of the cells on the page\n** might not actually be stored in MemPage.aData[]. This can happen\n** if the page is overfull. This routine ensures that all cells allocated\n** to the page and its siblings fit into MemPage.aData[] before returning.\n**\n** In the course of balancing the page and its siblings, cells may be\n** inserted into or removed from the parent page (pParent). Doing so\n** may cause the parent page to become overfull or underfull. If this\n** happens, it is the responsibility of the caller to invoke the correct\n** balancing routine to fix this problem (see the balance() routine). \n**\n** If this routine fails for any reason, it might leave the database\n** in a corrupted state. So if this routine fails, the database should\n** be rolled back.\n**\n** The third argument to this function, aOvflSpace, is a pointer to a\n** buffer big enough to hold one page. If while inserting cells into the parent\n** page (pParent) the parent page becomes overfull, this buffer is\n** used to store the parent's overflow cells. Because this function inserts\n** a maximum of four divider cells into the parent page, and the maximum\n** size of a cell stored within an internal node is always less than 1/4\n** of the page-size, the aOvflSpace[] buffer is guaranteed to be large\n** enough for all overflow cells.\n**\n** If aOvflSpace is set to a null pointer, this function returns \n** SQLITE_NOMEM.\n*/\n#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)\n#pragma optimize(\"\", off)\n#endif\nstatic int balance_nonroot(\n  MemPage *pParent,               /* Parent page of siblings being balanced */\n  int iParentIdx,                 /* Index of \"the page\" in pParent */\n  u8 *aOvflSpace,                 /* page-size bytes of space for parent ovfl */\n  int isRoot,                     /* True if pParent is a root-page */\n  int bBulk                       /* True if this call is part of a bulk load */\n){\n  BtShared *pBt;               /* The whole database */\n  int nCell = 0;               /* Number of cells in apCell[] */\n  int nMaxCells = 0;           /* Allocated size of apCell, szCell, aFrom. */\n  int nNew = 0;                /* Number of pages in apNew[] */\n  int nOld;                    /* Number of pages in apOld[] */\n  int i, j, k;                 /* Loop counters */\n  int nxDiv;                   /* Next divider slot in pParent->aCell[] */\n  int rc = SQLITE_OK;          /* The return code */\n  u16 leafCorrection;          /* 4 if pPage is a leaf.  0 if not */\n  int leafData;                /* True if pPage is a leaf of a LEAFDATA tree */\n  int usableSpace;             /* Bytes in pPage beyond the header */\n  int pageFlags;               /* Value of pPage->aData[0] */\n  int subtotal;                /* Subtotal of bytes in cells on one page */\n  int iSpace1 = 0;             /* First unused byte of aSpace1[] */\n  int iOvflSpace = 0;          /* First unused byte of aOvflSpace[] */\n  int szScratch;               /* Size of scratch memory requested */\n  MemPage *apOld[NB];          /* pPage and up to two siblings */\n  MemPage *apCopy[NB];         /* Private copies of apOld[] pages */\n  MemPage *apNew[NB+2];        /* pPage and up to NB siblings after balancing */\n  u8 *pRight;                  /* Location in parent of right-sibling pointer */\n  u8 *apDiv[NB-1];             /* Divider cells in pParent */\n  int cntNew[NB+2];            /* Index in aCell[] of cell after i-th page */\n  int szNew[NB+2];             /* Combined size of cells place on i-th page */\n  u8 **apCell = 0;             /* All cells begin balanced */\n  u16 *szCell;                 /* Local size of all cells in apCell[] */\n  u8 *aSpace1;                 /* Space for copies of dividers cells */\n  Pgno pgno;                   /* Temp var to store a page number in */\n\n  pBt = pParent->pBt;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n\n#if 0\n  TRACE((\"BALANCE: begin page %d child of %d\\n\", pPage->pgno, pParent->pgno));\n#endif\n\n  /* At this point pParent may have at most one overflow cell. And if\n  ** this overflow cell is present, it must be the cell with \n  ** index iParentIdx. This scenario comes about when this function\n  ** is called (indirectly) from sqlite3BtreeDelete().\n  */\n  assert( pParent->nOverflow==0 || pParent->nOverflow==1 );\n  assert( pParent->nOverflow==0 || pParent->aiOvfl[0]==iParentIdx );\n\n  if( !aOvflSpace ){\n    return SQLITE_NOMEM;\n  }\n\n  /* Find the sibling pages to balance. Also locate the cells in pParent \n  ** that divide the siblings. An attempt is made to find NN siblings on \n  ** either side of pPage. More siblings are taken from one side, however, \n  ** if there are fewer than NN siblings on the other side. If pParent\n  ** has NB or fewer children then all children of pParent are taken.  \n  **\n  ** This loop also drops the divider cells from the parent page. This\n  ** way, the remainder of the function does not have to deal with any\n  ** overflow cells in the parent page, since if any existed they will\n  ** have already been removed.\n  */\n  i = pParent->nOverflow + pParent->nCell;\n  if( i<2 ){\n    nxDiv = 0;\n  }else{\n    assert( bBulk==0 || bBulk==1 );\n    if( iParentIdx==0 ){                 \n      nxDiv = 0;\n    }else if( iParentIdx==i ){\n      nxDiv = i-2+bBulk;\n    }else{\n      assert( bBulk==0 );\n      nxDiv = iParentIdx-1;\n    }\n    i = 2-bBulk;\n  }\n  nOld = i+1;\n  if( (i+nxDiv-pParent->nOverflow)==pParent->nCell ){\n    pRight = &pParent->aData[pParent->hdrOffset+8];\n  }else{\n    pRight = findCell(pParent, i+nxDiv-pParent->nOverflow);\n  }\n  pgno = get4byte(pRight);\n  while( 1 ){\n    rc = getAndInitPage(pBt, pgno, &apOld[i], 0);\n    if( rc ){\n      memset(apOld, 0, (i+1)*sizeof(MemPage*));\n      goto balance_cleanup;\n    }\n    nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;\n    if( (i--)==0 ) break;\n\n    if( i+nxDiv==pParent->aiOvfl[0] && pParent->nOverflow ){\n      apDiv[i] = pParent->apOvfl[0];\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = cellSizePtr(pParent, apDiv[i]);\n      pParent->nOverflow = 0;\n    }else{\n      apDiv[i] = findCell(pParent, i+nxDiv-pParent->nOverflow);\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = cellSizePtr(pParent, apDiv[i]);\n\n      /* Drop the cell from the parent page. apDiv[i] still points to\n      ** the cell within the parent, even though it has been dropped.\n      ** This is safe because dropping a cell only overwrites the first\n      ** four bytes of it, and this function does not need the first\n      ** four bytes of the divider cell. So the pointer is safe to use\n      ** later on.  \n      **\n      ** But not if we are in secure-delete mode. In secure-delete mode,\n      ** the dropCell() routine will overwrite the entire cell with zeroes.\n      ** In this case, temporarily copy the cell into the aOvflSpace[]\n      ** buffer. It will be copied out again as soon as the aSpace[] buffer\n      ** is allocated.  */\n      if( pBt->btsFlags & BTS_SECURE_DELETE ){\n        int iOff;\n\n        iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);\n        if( (iOff+szNew[i])>(int)pBt->usableSize ){\n          rc = SQLITE_CORRUPT_BKPT;\n          memset(apOld, 0, (i+1)*sizeof(MemPage*));\n          goto balance_cleanup;\n        }else{\n          memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]);\n          apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData];\n        }\n      }\n      dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);\n    }\n  }\n\n  /* Make nMaxCells a multiple of 4 in order to preserve 8-byte\n  ** alignment */\n  nMaxCells = (nMaxCells + 3)&~3;\n\n  /*\n  ** Allocate space for memory structures\n  */\n  k = pBt->pageSize + ROUND8(sizeof(MemPage));\n  szScratch =\n       nMaxCells*sizeof(u8*)                       /* apCell */\n     + nMaxCells*sizeof(u16)                       /* szCell */\n     + pBt->pageSize                               /* aSpace1 */\n     + k*nOld;                                     /* Page copies (apCopy) */\n  apCell = sqlite3ScratchMalloc( szScratch ); \n  if( apCell==0 ){\n    rc = SQLITE_NOMEM;\n    goto balance_cleanup;\n  }\n  szCell = (u16*)&apCell[nMaxCells];\n  aSpace1 = (u8*)&szCell[nMaxCells];\n  assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );\n\n  /*\n  ** Load pointers to all cells on sibling pages and the divider cells\n  ** into the local apCell[] array.  Make copies of the divider cells\n  ** into space obtained from aSpace1[] and remove the divider cells\n  ** from pParent.\n  **\n  ** If the siblings are on leaf pages, then the child pointers of the\n  ** divider cells are stripped from the cells before they are copied\n  ** into aSpace1[].  In this way, all cells in apCell[] are without\n  ** child pointers.  If siblings are not leaves, then all cell in\n  ** apCell[] include child pointers.  Either way, all cells in apCell[]\n  ** are alike.\n  **\n  ** leafCorrection:  4 if pPage is a leaf.  0 if pPage is not a leaf.\n  **       leafData:  1 if pPage holds key+data and pParent holds only keys.\n  */\n  leafCorrection = apOld[0]->leaf*4;\n  leafData = apOld[0]->hasData;\n  for(i=0; i<nOld; i++){\n    int limit;\n    \n    /* Before doing anything else, take a copy of the i'th original sibling\n    ** The rest of this function will use data from the copies rather\n    ** that the original pages since the original pages will be in the\n    ** process of being overwritten.  */\n    MemPage *pOld = apCopy[i] = (MemPage*)&aSpace1[pBt->pageSize + k*i];\n    memcpy(pOld, apOld[i], sizeof(MemPage));\n    pOld->aData = (void*)&pOld[1];\n    memcpy(pOld->aData, apOld[i]->aData, pBt->pageSize);\n\n    limit = pOld->nCell+pOld->nOverflow;\n    if( pOld->nOverflow>0 ){\n      for(j=0; j<limit; j++){\n        assert( nCell<nMaxCells );\n        apCell[nCell] = findOverflowCell(pOld, j);\n        szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);\n        nCell++;\n      }\n    }else{\n      u8 *aData = pOld->aData;\n      u16 maskPage = pOld->maskPage;\n      u16 cellOffset = pOld->cellOffset;\n      for(j=0; j<limit; j++){\n        assert( nCell<nMaxCells );\n        apCell[nCell] = findCellv2(aData, maskPage, cellOffset, j);\n        szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);\n        nCell++;\n      }\n    }       \n    if( i<nOld-1 && !leafData){\n      u16 sz = (u16)szNew[i];\n      u8 *pTemp;\n      assert( nCell<nMaxCells );\n      szCell[nCell] = sz;\n      pTemp = &aSpace1[iSpace1];\n      iSpace1 += sz;\n      assert( sz<=pBt->maxLocal+23 );\n      assert( iSpace1 <= (int)pBt->pageSize );\n      memcpy(pTemp, apDiv[i], sz);\n      apCell[nCell] = pTemp+leafCorrection;\n      assert( leafCorrection==0 || leafCorrection==4 );\n      szCell[nCell] = szCell[nCell] - leafCorrection;\n      if( !pOld->leaf ){\n        assert( leafCorrection==0 );\n        assert( pOld->hdrOffset==0 );\n        /* The right pointer of the child page pOld becomes the left\n        ** pointer of the divider cell */\n        memcpy(apCell[nCell], &pOld->aData[8], 4);\n      }else{\n        assert( leafCorrection==4 );\n        if( szCell[nCell]<4 ){\n          /* Do not allow any cells smaller than 4 bytes. */\n          szCell[nCell] = 4;\n        }\n      }\n      nCell++;\n    }\n  }\n\n  /*\n  ** Figure out the number of pages needed to hold all nCell cells.\n  ** Store this number in \"k\".  Also compute szNew[] which is the total\n  ** size of all cells on the i-th page and cntNew[] which is the index\n  ** in apCell[] of the cell that divides page i from page i+1.  \n  ** cntNew[k] should equal nCell.\n  **\n  ** Values computed by this block:\n  **\n  **           k: The total number of sibling pages\n  **    szNew[i]: Spaced used on the i-th sibling page.\n  **   cntNew[i]: Index in apCell[] and szCell[] for the first cell to\n  **              the right of the i-th sibling page.\n  ** usableSpace: Number of bytes of space available on each sibling.\n  ** \n  */\n  usableSpace = pBt->usableSize - 12 + leafCorrection;\n  for(subtotal=k=i=0; i<nCell; i++){\n    assert( i<nMaxCells );\n    subtotal += szCell[i] + 2;\n    if( subtotal > usableSpace ){\n      szNew[k] = subtotal - szCell[i];\n      cntNew[k] = i;\n      if( leafData ){ i--; }\n      subtotal = 0;\n      k++;\n      if( k>NB+1 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }\n    }\n  }\n  szNew[k] = subtotal;\n  cntNew[k] = nCell;\n  k++;\n\n  /*\n  ** The packing computed by the previous block is biased toward the siblings\n  ** on the left side.  The left siblings are always nearly full, while the\n  ** right-most sibling might be nearly empty.  This block of code attempts\n  ** to adjust the packing of siblings to get a better balance.\n  **\n  ** This adjustment is more than an optimization.  The packing above might\n  ** be so out of balance as to be illegal.  For example, the right-most\n  ** sibling might be completely empty.  This adjustment is not optional.\n  */\n  for(i=k-1; i>0; i--){\n    int szRight = szNew[i];  /* Size of sibling on the right */\n    int szLeft = szNew[i-1]; /* Size of sibling on the left */\n    int r;              /* Index of right-most cell in left sibling */\n    int d;              /* Index of first cell to the left of right sibling */\n\n    r = cntNew[i-1] - 1;\n    d = r + 1 - leafData;\n    assert( d<nMaxCells );\n    assert( r<nMaxCells );\n    while( szRight==0 \n       || (!bBulk && szRight+szCell[d]+2<=szLeft-(szCell[r]+2)) \n    ){\n      szRight += szCell[d] + 2;\n      szLeft -= szCell[r] + 2;\n      cntNew[i-1]--;\n      r = cntNew[i-1] - 1;\n      d = r + 1 - leafData;\n    }\n    szNew[i] = szRight;\n    szNew[i-1] = szLeft;\n  }\n\n  /* Either we found one or more cells (cntnew[0])>0) or pPage is\n  ** a virtual root page.  A virtual root page is when the real root\n  ** page is page 1 and we are the only child of that page.\n  **\n  ** UPDATE:  The assert() below is not necessarily true if the database\n  ** file is corrupt.  The corruption will be detected and reported later\n  ** in this procedure so there is no need to act upon it now.\n  */\n#if 0\n  assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );\n#endif\n\n  TRACE((\"BALANCE: old: %d %d %d  \",\n    apOld[0]->pgno, \n    nOld>=2 ? apOld[1]->pgno : 0,\n    nOld>=3 ? apOld[2]->pgno : 0\n  ));\n\n  /*\n  ** Allocate k new pages.  Reuse old pages where possible.\n  */\n  if( apOld[0]->pgno<=1 ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto balance_cleanup;\n  }\n  pageFlags = apOld[0]->aData[0];\n  for(i=0; i<k; i++){\n    MemPage *pNew;\n    if( i<nOld ){\n      pNew = apNew[i] = apOld[i];\n      apOld[i] = 0;\n      rc = sqlite3PagerWrite(pNew->pDbPage);\n      nNew++;\n      if( rc ) goto balance_cleanup;\n    }else{\n      assert( i>0 );\n      rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);\n      if( rc ) goto balance_cleanup;\n      apNew[i] = pNew;\n      nNew++;\n\n      /* Set the pointer-map entry for the new sibling page. */\n      if( ISAUTOVACUUM ){\n        ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);\n        if( rc!=SQLITE_OK ){\n          goto balance_cleanup;\n        }\n      }\n    }\n  }\n\n  /* Free any old pages that were not reused as new pages.\n  */\n  while( i<nOld ){\n    freePage(apOld[i], &rc);\n    if( rc ) goto balance_cleanup;\n    releasePage(apOld[i]);\n    apOld[i] = 0;\n    i++;\n  }\n\n  /*\n  ** Put the new pages in accending order.  This helps to\n  ** keep entries in the disk file in order so that a scan\n  ** of the table is a linear scan through the file.  That\n  ** in turn helps the operating system to deliver pages\n  ** from the disk more rapidly.\n  **\n  ** An O(n^2) insertion sort algorithm is used, but since\n  ** n is never more than NB (a small constant), that should\n  ** not be a problem.\n  **\n  ** When NB==3, this one optimization makes the database\n  ** about 25% faster for large insertions and deletions.\n  */\n  for(i=0; i<k-1; i++){\n    int minV = apNew[i]->pgno;\n    int minI = i;\n    for(j=i+1; j<k; j++){\n      if( apNew[j]->pgno<(unsigned)minV ){\n        minI = j;\n        minV = apNew[j]->pgno;\n      }\n    }\n    if( minI>i ){\n      MemPage *pT;\n      pT = apNew[i];\n      apNew[i] = apNew[minI];\n      apNew[minI] = pT;\n    }\n  }\n  TRACE((\"new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\\n\",\n    apNew[0]->pgno, szNew[0],\n    nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,\n    nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,\n    nNew>=4 ? apNew[3]->pgno : 0, nNew>=4 ? szNew[3] : 0,\n    nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0));\n\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  put4byte(pRight, apNew[nNew-1]->pgno);\n\n  /*\n  ** Evenly distribute the data in apCell[] across the new pages.\n  ** Insert divider cells into pParent as necessary.\n  */\n  j = 0;\n  for(i=0; i<nNew; i++){\n    /* Assemble the new sibling page. */\n    MemPage *pNew = apNew[i];\n    assert( j<nMaxCells );\n    zeroPage(pNew, pageFlags);\n    assemblePage(pNew, cntNew[i]-j, &apCell[j], &szCell[j]);\n    assert( pNew->nCell>0 || (nNew==1 && cntNew[0]==0) );\n    assert( pNew->nOverflow==0 );\n\n    j = cntNew[i];\n\n    /* If the sibling page assembled above was not the right-most sibling,\n    ** insert a divider cell into the parent page.\n    */\n    assert( i<nNew-1 || j==nCell );\n    if( j<nCell ){\n      u8 *pCell;\n      u8 *pTemp;\n      int sz;\n\n      assert( j<nMaxCells );\n      pCell = apCell[j];\n      sz = szCell[j] + leafCorrection;\n      pTemp = &aOvflSpace[iOvflSpace];\n      if( !pNew->leaf ){\n        memcpy(&pNew->aData[8], pCell, 4);\n      }else if( leafData ){\n        /* If the tree is a leaf-data tree, and the siblings are leaves, \n        ** then there is no divider cell in apCell[]. Instead, the divider \n        ** cell consists of the integer key for the right-most cell of \n        ** the sibling-page assembled above only.\n        */\n        CellInfo info;\n        j--;\n        btreeParseCellPtr(pNew, apCell[j], &info);\n        pCell = pTemp;\n        sz = 4 + putVarint(&pCell[4], info.nKey);\n        pTemp = 0;\n      }else{\n        pCell -= 4;\n        /* Obscure case for non-leaf-data trees: If the cell at pCell was\n        ** previously stored on a leaf node, and its reported size was 4\n        ** bytes, then it may actually be smaller than this \n        ** (see btreeParseCellPtr(), 4 bytes is the minimum size of\n        ** any cell). But it is important to pass the correct size to \n        ** insertCell(), so reparse the cell now.\n        **\n        ** Note that this can never happen in an SQLite data file, as all\n        ** cells are at least 4 bytes. It only happens in b-trees used\n        ** to evaluate \"IN (SELECT ...)\" and similar clauses.\n        */\n        if( szCell[j]==4 ){\n          assert(leafCorrection==4);\n          sz = cellSizePtr(pParent, pCell);\n        }\n      }\n      iOvflSpace += sz;\n      assert( sz<=pBt->maxLocal+23 );\n      assert( iOvflSpace <= (int)pBt->pageSize );\n      insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew->pgno, &rc);\n      if( rc!=SQLITE_OK ) goto balance_cleanup;\n      assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n\n      j++;\n      nxDiv++;\n    }\n  }\n  assert( j==nCell );\n  assert( nOld>0 );\n  assert( nNew>0 );\n  if( (pageFlags & PTF_LEAF)==0 ){\n    u8 *zChild = &apCopy[nOld-1]->aData[8];\n    memcpy(&apNew[nNew-1]->aData[8], zChild, 4);\n  }\n\n  if( isRoot && pParent->nCell==0 && pParent->hdrOffset<=apNew[0]->nFree ){\n    /* The root page of the b-tree now contains no cells. The only sibling\n    ** page is the right-child of the parent. Copy the contents of the\n    ** child page into the parent, decreasing the overall height of the\n    ** b-tree structure by one. This is described as the \"balance-shallower\"\n    ** sub-algorithm in some documentation.\n    **\n    ** If this is an auto-vacuum database, the call to copyNodeContent() \n    ** sets all pointer-map entries corresponding to database image pages \n    ** for which the pointer is stored within the content being copied.\n    **\n    ** The second assert below verifies that the child page is defragmented\n    ** (it must be, as it was just reconstructed using assemblePage()). This\n    ** is important if the parent page happens to be page 1 of the database\n    ** image.  */\n    assert( nNew==1 );\n    assert( apNew[0]->nFree == \n        (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2) \n    );\n    copyNodeContent(apNew[0], pParent, &rc);\n    freePage(apNew[0], &rc);\n  }else if( ISAUTOVACUUM ){\n    /* Fix the pointer-map entries for all the cells that were shifted around. \n    ** There are several different types of pointer-map entries that need to\n    ** be dealt with by this routine. Some of these have been set already, but\n    ** many have not. The following is a summary:\n    **\n    **   1) The entries associated with new sibling pages that were not\n    **      siblings when this function was called. These have already\n    **      been set. We don't need to worry about old siblings that were\n    **      moved to the free-list - the freePage() code has taken care\n    **      of those.\n    **\n    **   2) The pointer-map entries associated with the first overflow\n    **      page in any overflow chains used by new divider cells. These \n    **      have also already been taken care of by the insertCell() code.\n    **\n    **   3) If the sibling pages are not leaves, then the child pages of\n    **      cells stored on the sibling pages may need to be updated.\n    **\n    **   4) If the sibling pages are not internal intkey nodes, then any\n    **      overflow pages used by these cells may need to be updated\n    **      (internal intkey nodes never contain pointers to overflow pages).\n    **\n    **   5) If the sibling pages are not leaves, then the pointer-map\n    **      entries for the right-child pages of each sibling may need\n    **      to be updated.\n    **\n    ** Cases 1 and 2 are dealt with above by other code. The next\n    ** block deals with cases 3 and 4 and the one after that, case 5. Since\n    ** setting a pointer map entry is a relatively expensive operation, this\n    ** code only sets pointer map entries for child or overflow pages that have\n    ** actually moved between pages.  */\n    MemPage *pNew = apNew[0];\n    MemPage *pOld = apCopy[0];\n    int nOverflow = pOld->nOverflow;\n    int iNextOld = pOld->nCell + nOverflow;\n    int iOverflow = (nOverflow ? pOld->aiOvfl[0] : -1);\n    j = 0;                             /* Current 'old' sibling page */\n    k = 0;                             /* Current 'new' sibling page */\n    for(i=0; i<nCell; i++){\n      int isDivider = 0;\n      while( i==iNextOld ){\n        /* Cell i is the cell immediately following the last cell on old\n        ** sibling page j. If the siblings are not leaf pages of an\n        ** intkey b-tree, then cell i was a divider cell. */\n        assert( j+1 < ArraySize(apCopy) );\n        assert( j+1 < nOld );\n        pOld = apCopy[++j];\n        iNextOld = i + !leafData + pOld->nCell + pOld->nOverflow;\n        if( pOld->nOverflow ){\n          nOverflow = pOld->nOverflow;\n          iOverflow = i + !leafData + pOld->aiOvfl[0];\n        }\n        isDivider = !leafData;  \n      }\n\n      assert(nOverflow>0 || iOverflow<i );\n      assert(nOverflow<2 || pOld->aiOvfl[0]==pOld->aiOvfl[1]-1);\n      assert(nOverflow<3 || pOld->aiOvfl[1]==pOld->aiOvfl[2]-1);\n      if( i==iOverflow ){\n        isDivider = 1;\n        if( (--nOverflow)>0 ){\n          iOverflow++;\n        }\n      }\n\n      if( i==cntNew[k] ){\n        /* Cell i is the cell immediately following the last cell on new\n        ** sibling page k. If the siblings are not leaf pages of an\n        ** intkey b-tree, then cell i is a divider cell.  */\n        pNew = apNew[++k];\n        if( !leafData ) continue;\n      }\n      assert( j<nOld );\n      assert( k<nNew );\n\n      /* If the cell was originally divider cell (and is not now) or\n      ** an overflow cell, or if the cell was located on a different sibling\n      ** page before the balancing, then the pointer map entries associated\n      ** with any child or overflow pages need to be updated.  */\n      if( isDivider || pOld->pgno!=pNew->pgno ){\n        if( !leafCorrection ){\n          ptrmapPut(pBt, get4byte(apCell[i]), PTRMAP_BTREE, pNew->pgno, &rc);\n        }\n        if( szCell[i]>pNew->minLocal ){\n          ptrmapPutOvflPtr(pNew, apCell[i], &rc);\n        }\n      }\n    }\n\n    if( !leafCorrection ){\n      for(i=0; i<nNew; i++){\n        u32 key = get4byte(&apNew[i]->aData[8]);\n        ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);\n      }\n    }\n\n#if 0\n    /* The ptrmapCheckPages() contains assert() statements that verify that\n    ** all pointer map pages are set correctly. This is helpful while \n    ** debugging. This is usually disabled because a corrupt database may\n    ** cause an assert() statement to fail.  */\n    ptrmapCheckPages(apNew, nNew);\n    ptrmapCheckPages(&pParent, 1);\n#endif\n  }\n\n  assert( pParent->isInit );\n  TRACE((\"BALANCE: finished: old=%d new=%d cells=%d\\n\",\n          nOld, nNew, nCell));\n\n  /*\n  ** Cleanup before returning.\n  */\nbalance_cleanup:\n  sqlite3ScratchFree(apCell);\n  for(i=0; i<nOld; i++){\n    releasePage(apOld[i]);\n  }\n  for(i=0; i<nNew; i++){\n    releasePage(apNew[i]);\n  }\n\n  return rc;\n}\n#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_M_ARM)\n#pragma optimize(\"\", on)\n#endif\n\n\n/*\n** This function is called when the root page of a b-tree structure is\n** overfull (has one or more overflow pages).\n**\n** A new child page is allocated and the contents of the current root\n** page, including overflow cells, are copied into the child. The root\n** page is then overwritten to make it an empty page with the right-child \n** pointer pointing to the new page.\n**\n** Before returning, all pointer-map entries corresponding to pages \n** that the new child-page now contains pointers to are updated. The\n** entry corresponding to the new right-child pointer of the root\n** page is also updated.\n**\n** If successful, *ppChild is set to contain a reference to the child \n** page and SQLITE_OK is returned. In this case the caller is required\n** to call releasePage() on *ppChild exactly once. If an error occurs,\n** an error code is returned and *ppChild is set to 0.\n*/\nstatic int balance_deeper(MemPage *pRoot, MemPage **ppChild){\n  int rc;                        /* Return value from subprocedures */\n  MemPage *pChild = 0;           /* Pointer to a new child page */\n  Pgno pgnoChild = 0;            /* Page number of the new child page */\n  BtShared *pBt = pRoot->pBt;    /* The BTree */\n\n  assert( pRoot->nOverflow>0 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  /* Make pRoot, the root page of the b-tree, writable. Allocate a new \n  ** page that will become the new right-child of pPage. Copy the contents\n  ** of the node stored on pRoot into the new child page.\n  */\n  rc = sqlite3PagerWrite(pRoot->pDbPage);\n  if( rc==SQLITE_OK ){\n    rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);\n    copyNodeContent(pRoot, pChild, &rc);\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);\n    }\n  }\n  if( rc ){\n    *ppChild = 0;\n    releasePage(pChild);\n    return rc;\n  }\n  assert( sqlite3PagerIswriteable(pChild->pDbPage) );\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  assert( pChild->nCell==pRoot->nCell );\n\n  TRACE((\"BALANCE: copy root %d into %d\\n\", pRoot->pgno, pChild->pgno));\n\n  /* Copy the overflow cells from pRoot to pChild */\n  memcpy(pChild->aiOvfl, pRoot->aiOvfl,\n         pRoot->nOverflow*sizeof(pRoot->aiOvfl[0]));\n  memcpy(pChild->apOvfl, pRoot->apOvfl,\n         pRoot->nOverflow*sizeof(pRoot->apOvfl[0]));\n  pChild->nOverflow = pRoot->nOverflow;\n\n  /* Zero the contents of pRoot. Then install pChild as the right-child. */\n  zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);\n  put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild);\n\n  *ppChild = pChild;\n  return SQLITE_OK;\n}\n\n/*\n** The page that pCur currently points to has just been modified in\n** some way. This function figures out if this modification means the\n** tree needs to be balanced, and if so calls the appropriate balancing \n** routine. Balancing routines are:\n**\n**   balance_quick()\n**   balance_deeper()\n**   balance_nonroot()\n*/\nstatic int balance(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  const int nMin = pCur->pBt->usableSize * 2 / 3;\n  u8 aBalanceQuickSpace[13];\n  u8 *pFree = 0;\n\n  TESTONLY( int balance_quick_called = 0 );\n  TESTONLY( int balance_deeper_called = 0 );\n\n  do {\n    int iPage = pCur->iPage;\n    MemPage *pPage = pCur->apPage[iPage];\n\n    if( iPage==0 ){\n      if( pPage->nOverflow ){\n        /* The root page of the b-tree is overfull. In this case call the\n        ** balance_deeper() function to create a new child for the root-page\n        ** and copy the current contents of the root-page to it. The\n        ** next iteration of the do-loop will balance the child page.\n        */ \n        assert( (balance_deeper_called++)==0 );\n        rc = balance_deeper(pPage, &pCur->apPage[1]);\n        if( rc==SQLITE_OK ){\n          pCur->iPage = 1;\n          pCur->aiIdx[0] = 0;\n          pCur->aiIdx[1] = 0;\n          assert( pCur->apPage[1]->nOverflow );\n        }\n      }else{\n        break;\n      }\n    }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){\n      break;\n    }else{\n      MemPage * const pParent = pCur->apPage[iPage-1];\n      int const iIdx = pCur->aiIdx[iPage-1];\n\n      rc = sqlite3PagerWrite(pParent->pDbPage);\n      if( rc==SQLITE_OK ){\n#ifndef SQLITE_OMIT_QUICKBALANCE\n        if( pPage->hasData\n         && pPage->nOverflow==1\n         && pPage->aiOvfl[0]==pPage->nCell\n         && pParent->pgno!=1\n         && pParent->nCell==iIdx\n        ){\n          /* Call balance_quick() to create a new sibling of pPage on which\n          ** to store the overflow cell. balance_quick() inserts a new cell\n          ** into pParent, which may cause pParent overflow. If this\n          ** happens, the next interation of the do-loop will balance pParent \n          ** use either balance_nonroot() or balance_deeper(). Until this\n          ** happens, the overflow cell is stored in the aBalanceQuickSpace[]\n          ** buffer. \n          **\n          ** The purpose of the following assert() is to check that only a\n          ** single call to balance_quick() is made for each call to this\n          ** function. If this were not verified, a subtle bug involving reuse\n          ** of the aBalanceQuickSpace[] might sneak in.\n          */\n          assert( (balance_quick_called++)==0 );\n          rc = balance_quick(pParent, pPage, aBalanceQuickSpace);\n        }else\n#endif\n        {\n          /* In this case, call balance_nonroot() to redistribute cells\n          ** between pPage and up to 2 of its sibling pages. This involves\n          ** modifying the contents of pParent, which may cause pParent to\n          ** become overfull or underfull. The next iteration of the do-loop\n          ** will balance the parent page to correct this.\n          ** \n          ** If the parent page becomes overfull, the overflow cell or cells\n          ** are stored in the pSpace buffer allocated immediately below. \n          ** A subsequent iteration of the do-loop will deal with this by\n          ** calling balance_nonroot() (balance_deeper() may be called first,\n          ** but it doesn't deal with overflow cells - just moves them to a\n          ** different page). Once this subsequent call to balance_nonroot() \n          ** has completed, it is safe to release the pSpace buffer used by\n          ** the previous call, as the overflow cell data will have been \n          ** copied either into the body of a database page or into the new\n          ** pSpace buffer passed to the latter call to balance_nonroot().\n          */\n          u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);\n          rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints);\n          if( pFree ){\n            /* If pFree is not NULL, it points to the pSpace buffer used \n            ** by a previous call to balance_nonroot(). Its contents are\n            ** now stored either on real database pages or within the \n            ** new pSpace buffer, so it may be safely freed here. */\n            sqlite3PageFree(pFree);\n          }\n\n          /* The pSpace buffer will be freed after the next call to\n          ** balance_nonroot(), or just before this function returns, whichever\n          ** comes first. */\n          pFree = pSpace;\n        }\n      }\n\n      pPage->nOverflow = 0;\n\n      /* The next iteration of the do-loop balances the parent page. */\n      releasePage(pPage);\n      pCur->iPage--;\n    }\n  }while( rc==SQLITE_OK );\n\n  if( pFree ){\n    sqlite3PageFree(pFree);\n  }\n  return rc;\n}\n\n\n/*\n** Insert a new record into the BTree.  The key is given by (pKey,nKey)\n** and the data is given by (pData,nData).  The cursor is used only to\n** define what table the record should be inserted into.  The cursor\n** is left pointing at a random location.\n**\n** For an INTKEY table, only the nKey value of the key is used.  pKey is\n** ignored.  For a ZERODATA table, the pData and nData are both ignored.\n**\n** If the seekResult parameter is non-zero, then a successful call to\n** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already\n** been performed. seekResult is the search result returned (a negative\n** number if pCur points at an entry that is smaller than (pKey, nKey), or\n** a positive value if pCur points at an etry that is larger than \n** (pKey, nKey)). \n**\n** If the seekResult parameter is non-zero, then the caller guarantees that\n** cursor pCur is pointing at the existing copy of a row that is to be\n** overwritten.  If the seekResult parameter is 0, then cursor pCur may\n** point to any entry or to no entry at all and so this function has to seek\n** the cursor before the new key can be inserted.\n*/\nSQLITE_PRIVATE int sqlite3BtreeInsert(\n  BtCursor *pCur,                /* Insert data into the table of this cursor */\n  const void *pKey, i64 nKey,    /* The key of the new record */\n  const void *pData, int nData,  /* The data of the new record */\n  int nZero,                     /* Number of extra 0 bytes to append to data */\n  int appendBias,                /* True if this is likely an append */\n  int seekResult                 /* Result of prior MovetoUnpacked() call */\n){\n  int rc;\n  int loc = seekResult;          /* -1: before desired location  +1: after */\n  int szNew = 0;\n  int idx;\n  MemPage *pPage;\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;\n  unsigned char *oldCell;\n  unsigned char *newCell = 0;\n\n  if( pCur->eState==CURSOR_FAULT ){\n    assert( pCur->skipNext!=SQLITE_OK );\n    return pCur->skipNext;\n  }\n\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->wrFlag && pBt->inTransaction==TRANS_WRITE\n              && (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n\n  /* Assert that the caller has been consistent. If this cursor was opened\n  ** expecting an index b-tree, then the caller should be inserting blob\n  ** keys with no associated data. If the cursor was opened expecting an\n  ** intkey table, the caller should be inserting integer keys with a\n  ** blob of associated data.  */\n  assert( (pKey==0)==(pCur->pKeyInfo==0) );\n\n  /* Save the positions of any other cursors open on this table.\n  **\n  ** In some cases, the call to btreeMoveto() below is a no-op. For\n  ** example, when inserting data into a table with auto-generated integer\n  ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the \n  ** integer key to use. It then calls this function to actually insert the \n  ** data into the intkey B-Tree. In this case btreeMoveto() recognizes\n  ** that the cursor is already where it needs to be and returns without\n  ** doing any work. To avoid thwarting these optimizations, it is important\n  ** not to clear the cursor here.\n  */\n  rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n  if( rc ) return rc;\n\n  /* If this is an insert into a table b-tree, invalidate any incrblob \n  ** cursors open on the row being replaced (assuming this is a replace\n  ** operation - if it is not, the following is a no-op).  */\n  if( pCur->pKeyInfo==0 ){\n    invalidateIncrblobCursors(p, nKey, 0);\n  }\n\n  if( !loc ){\n    rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);\n    if( rc ) return rc;\n  }\n  assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );\n\n  pPage = pCur->apPage[pCur->iPage];\n  assert( pPage->intKey || nKey>=0 );\n  assert( pPage->leaf || !pPage->intKey );\n\n  TRACE((\"INSERT: table=%d nkey=%lld ndata=%d page=%d %s\\n\",\n          pCur->pgnoRoot, nKey, nData, pPage->pgno,\n          loc==0 ? \"overwrite\" : \"new entry\"));\n  assert( pPage->isInit );\n  allocateTempSpace(pBt);\n  newCell = pBt->pTmpSpace;\n  if( newCell==0 ) return SQLITE_NOMEM;\n  rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew);\n  if( rc ) goto end_insert;\n  assert( szNew==cellSizePtr(pPage, newCell) );\n  assert( szNew <= MX_CELL_SIZE(pBt) );\n  idx = pCur->aiIdx[pCur->iPage];\n  if( loc==0 ){\n    u16 szOld;\n    assert( idx<pPage->nCell );\n    rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc ){\n      goto end_insert;\n    }\n    oldCell = findCell(pPage, idx);\n    if( !pPage->leaf ){\n      memcpy(newCell, oldCell, 4);\n    }\n    szOld = cellSizePtr(pPage, oldCell);\n    rc = clearCell(pPage, oldCell);\n    dropCell(pPage, idx, szOld, &rc);\n    if( rc ) goto end_insert;\n  }else if( loc<0 && pPage->nCell>0 ){\n    assert( pPage->leaf );\n    idx = ++pCur->aiIdx[pCur->iPage];\n  }else{\n    assert( pPage->leaf );\n  }\n  insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);\n  assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );\n\n  /* If no error has occurred and pPage has an overflow cell, call balance() \n  ** to redistribute the cells within the tree. Since balance() may move\n  ** the cursor, zero the BtCursor.info.nSize and BtCursor.validNKey\n  ** variables.\n  **\n  ** Previous versions of SQLite called moveToRoot() to move the cursor\n  ** back to the root page as balance() used to invalidate the contents\n  ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that,\n  ** set the cursor state to \"invalid\". This makes common insert operations\n  ** slightly faster.\n  **\n  ** There is a subtle but important optimization here too. When inserting\n  ** multiple records into an intkey b-tree using a single cursor (as can\n  ** happen while processing an \"INSERT INTO ... SELECT\" statement), it\n  ** is advantageous to leave the cursor pointing to the last entry in\n  ** the b-tree if possible. If the cursor is left pointing to the last\n  ** entry in the table, and the next row inserted has an integer key\n  ** larger than the largest existing key, it is possible to insert the\n  ** row without seeking the cursor. This can be a big performance boost.\n  */\n  pCur->info.nSize = 0;\n  pCur->validNKey = 0;\n  if( rc==SQLITE_OK && pPage->nOverflow ){\n    rc = balance(pCur);\n\n    /* Must make sure nOverflow is reset to zero even if the balance()\n    ** fails. Internal data structure corruption will result otherwise. \n    ** Also, set the cursor state to invalid. This stops saveCursorPosition()\n    ** from trying to save the current position of the cursor.  */\n    pCur->apPage[pCur->iPage]->nOverflow = 0;\n    pCur->eState = CURSOR_INVALID;\n  }\n  assert( pCur->apPage[pCur->iPage]->nOverflow==0 );\n\nend_insert:\n  return rc;\n}\n\n/*\n** Delete the entry that the cursor is pointing to.  The cursor\n** is left pointing at a arbitrary location.\n*/\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur){\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;              \n  int rc;                              /* Return code */\n  MemPage *pPage;                      /* Page to delete cell from */\n  unsigned char *pCell;                /* Pointer to cell to delete */\n  int iCellIdx;                        /* Index of cell to delete */\n  int iCellDepth;                      /* Depth of node containing pCell */ \n\n  assert( cursorHoldsMutex(pCur) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( pCur->wrFlag );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n  assert( !hasReadConflicts(p, pCur->pgnoRoot) );\n\n  if( NEVER(pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell) \n   || NEVER(pCur->eState!=CURSOR_VALID)\n  ){\n    return SQLITE_ERROR;  /* Something has gone awry. */\n  }\n\n  iCellDepth = pCur->iPage;\n  iCellIdx = pCur->aiIdx[iCellDepth];\n  pPage = pCur->apPage[iCellDepth];\n  pCell = findCell(pPage, iCellIdx);\n\n  /* If the page containing the entry to delete is not a leaf page, move\n  ** the cursor to the largest entry in the tree that is smaller than\n  ** the entry being deleted. This cell will replace the cell being deleted\n  ** from the internal node. The 'previous' entry is used for this instead\n  ** of the 'next' entry, as the previous entry is always a part of the\n  ** sub-tree headed by the child page of the cell being deleted. This makes\n  ** balancing the tree following the delete operation easier.  */\n  if( !pPage->leaf ){\n    int notUsed;\n    rc = sqlite3BtreePrevious(pCur, &notUsed);\n    if( rc ) return rc;\n  }\n\n  /* Save the positions of any other cursors open on this table before\n  ** making any modifications. Make the page containing the entry to be \n  ** deleted writable. Then free any overflow pages associated with the \n  ** entry and finally remove the cell itself from within the page.  \n  */\n  rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n  if( rc ) return rc;\n\n  /* If this is a delete operation to remove a row from a table b-tree,\n  ** invalidate any incrblob cursors open on the row being deleted.  */\n  if( pCur->pKeyInfo==0 ){\n    invalidateIncrblobCursors(p, pCur->info.nKey, 0);\n  }\n\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc ) return rc;\n  rc = clearCell(pPage, pCell);\n  dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);\n  if( rc ) return rc;\n\n  /* If the cell deleted was not located on a leaf page, then the cursor\n  ** is currently pointing to the largest entry in the sub-tree headed\n  ** by the child-page of the cell that was just deleted from an internal\n  ** node. The cell from the leaf node needs to be moved to the internal\n  ** node to replace the deleted cell.  */\n  if( !pPage->leaf ){\n    MemPage *pLeaf = pCur->apPage[pCur->iPage];\n    int nCell;\n    Pgno n = pCur->apPage[iCellDepth+1]->pgno;\n    unsigned char *pTmp;\n\n    pCell = findCell(pLeaf, pLeaf->nCell-1);\n    nCell = cellSizePtr(pLeaf, pCell);\n    assert( MX_CELL_SIZE(pBt) >= nCell );\n\n    allocateTempSpace(pBt);\n    pTmp = pBt->pTmpSpace;\n\n    rc = sqlite3PagerWrite(pLeaf->pDbPage);\n    insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);\n    dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);\n    if( rc ) return rc;\n  }\n\n  /* Balance the tree. If the entry deleted was located on a leaf page,\n  ** then the cursor still points to that page. In this case the first\n  ** call to balance() repairs the tree, and the if(...) condition is\n  ** never true.\n  **\n  ** Otherwise, if the entry deleted was on an internal node page, then\n  ** pCur is pointing to the leaf page from which a cell was removed to\n  ** replace the cell deleted from the internal node. This is slightly\n  ** tricky as the leaf node may be underfull, and the internal node may\n  ** be either under or overfull. In this case run the balancing algorithm\n  ** on the leaf node first. If the balance proceeds far enough up the\n  ** tree that we can be sure that any problem in the internal node has\n  ** been corrected, so be it. Otherwise, after balancing the leaf node,\n  ** walk the cursor up the tree to the internal node and balance it as \n  ** well.  */\n  rc = balance(pCur);\n  if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){\n    while( pCur->iPage>iCellDepth ){\n      releasePage(pCur->apPage[pCur->iPage--]);\n    }\n    rc = balance(pCur);\n  }\n\n  if( rc==SQLITE_OK ){\n    moveToRoot(pCur);\n  }\n  return rc;\n}\n\n/*\n** Create a new BTree table.  Write into *piTable the page\n** number for the root page of the new table.\n**\n** The type of type is determined by the flags parameter.  Only the\n** following values of flags are currently in use.  Other values for\n** flags might not work:\n**\n**     BTREE_INTKEY|BTREE_LEAFDATA     Used for SQL tables with rowid keys\n**     BTREE_ZERODATA                  Used for SQL indices\n*/\nstatic int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){\n  BtShared *pBt = p->pBt;\n  MemPage *pRoot;\n  Pgno pgnoRoot;\n  int rc;\n  int ptfFlags;          /* Page-type flage for the root page of new table */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n  if( rc ){\n    return rc;\n  }\n#else\n  if( pBt->autoVacuum ){\n    Pgno pgnoMove;      /* Move a page here to make room for the root-page */\n    MemPage *pPageMove; /* The page to move to. */\n\n    /* Creating a new table may probably require moving an existing database\n    ** to make room for the new tables root page. In case this page turns\n    ** out to be an overflow page, delete all overflow page-map caches\n    ** held by open cursors.\n    */\n    invalidateAllOverflowCache(pBt);\n\n    /* Read the value of meta[3] from the database to determine where the\n    ** root page of the new table should go. meta[3] is the largest root-page\n    ** created so far, so the new root-page is (meta[3]+1).\n    */\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);\n    pgnoRoot++;\n\n    /* The new root-page may not be allocated on a pointer-map page, or the\n    ** PENDING_BYTE page.\n    */\n    while( pgnoRoot==PTRMAP_PAGENO(pBt, pgnoRoot) ||\n        pgnoRoot==PENDING_BYTE_PAGE(pBt) ){\n      pgnoRoot++;\n    }\n    assert( pgnoRoot>=3 );\n\n    /* Allocate a page. The page that currently resides at pgnoRoot will\n    ** be moved to the allocated page (unless the allocated page happens\n    ** to reside at pgnoRoot).\n    */\n    rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, BTALLOC_EXACT);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    if( pgnoMove!=pgnoRoot ){\n      /* pgnoRoot is the page that will be used for the root-page of\n      ** the new table (assuming an error did not occur). But we were\n      ** allocated pgnoMove. If required (i.e. if it was not allocated\n      ** by extending the file), the current page at position pgnoMove\n      ** is already journaled.\n      */\n      u8 eType = 0;\n      Pgno iPtrPage = 0;\n\n      /* Save the positions of any open cursors. This is required in\n      ** case they are holding a reference to an xFetch reference\n      ** corresponding to page pgnoRoot.  */\n      rc = saveAllCursors(pBt, 0, 0);\n      releasePage(pPageMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* Move the page currently at pgnoRoot to pgnoMove. */\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);\n      if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n      assert( eType!=PTRMAP_ROOTPAGE );\n      assert( eType!=PTRMAP_FREEPAGE );\n      rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);\n      releasePage(pRoot);\n\n      /* Obtain the page at pgnoRoot */\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = sqlite3PagerWrite(pRoot->pDbPage);\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n    }else{\n      pRoot = pPageMove;\n    } \n\n    /* Update the pointer-map and meta-data with the new root-page number. */\n    ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);\n    if( rc ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n    /* When the new root page was allocated, page 1 was made writable in\n    ** order either to increase the database filesize, or to decrement the\n    ** freelist count.  Hence, the sqlite3BtreeUpdateMeta() call cannot fail.\n    */\n    assert( sqlite3PagerIswriteable(pBt->pPage1->pDbPage) );\n    rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);\n    if( NEVER(rc) ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n  }else{\n    rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n    if( rc ) return rc;\n  }\n#endif\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  if( createTabFlags & BTREE_INTKEY ){\n    ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF;\n  }else{\n    ptfFlags = PTF_ZERODATA | PTF_LEAF;\n  }\n  zeroPage(pRoot, ptfFlags);\n  sqlite3PagerUnref(pRoot->pDbPage);\n  assert( (pBt->openFlags & BTREE_SINGLE)==0 || pgnoRoot==2 );\n  *piTable = (int)pgnoRoot;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeCreateTable(p, piTable, flags);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Erase the given database page and all its children.  Return\n** the page to the freelist.\n*/\nstatic int clearDatabasePage(\n  BtShared *pBt,           /* The BTree that contains the table */\n  Pgno pgno,               /* Page number to clear */\n  int freePageFlag,        /* Deallocate page if true */\n  int *pnChange            /* Add number of Cells freed to this counter */\n){\n  MemPage *pPage;\n  int rc;\n  unsigned char *pCell;\n  int i;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno>btreePagecount(pBt) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n\n  rc = getAndInitPage(pBt, pgno, &pPage, 0);\n  if( rc ) return rc;\n  for(i=0; i<pPage->nCell; i++){\n    pCell = findCell(pPage, i);\n    if( !pPage->leaf ){\n      rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);\n      if( rc ) goto cleardatabasepage_out;\n    }\n    rc = clearCell(pPage, pCell);\n    if( rc ) goto cleardatabasepage_out;\n  }\n  if( !pPage->leaf ){\n    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[8]), 1, pnChange);\n    if( rc ) goto cleardatabasepage_out;\n  }else if( pnChange ){\n    assert( pPage->intKey );\n    *pnChange += pPage->nCell;\n  }\n  if( freePageFlag ){\n    freePage(pPage, &rc);\n  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){\n    zeroPage(pPage, pPage->aData[0] | PTF_LEAF);\n  }\n\ncleardatabasepage_out:\n  releasePage(pPage);\n  return rc;\n}\n\n/*\n** Delete all information from a single table in the database.  iTable is\n** the page number of the root of the table.  After this routine returns,\n** the root page is empty, but still exists.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** read cursors on the table.  Open write cursors are moved to the\n** root of the table.\n**\n** If pnChange is not NULL, then table iTable must be an intkey table. The\n** integer value pointed to by pnChange is incremented by the number of\n** entries in the table.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n\n  rc = saveAllCursors(pBt, (Pgno)iTable, 0);\n\n  if( SQLITE_OK==rc ){\n    /* Invalidate all incrblob cursors open on table iTable (assuming iTable\n    ** is the root of a table b-tree - if it is not, the following call is\n    ** a no-op).  */\n    invalidateIncrblobCursors(p, 0, 1);\n    rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Erase all information in a table and add the root of the table to\n** the freelist.  Except, the root of the principle table (the one on\n** page 1) is never added to the freelist.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** cursors on the table.\n**\n** If AUTOVACUUM is enabled and the page at iTable is not the last\n** root page in the database file, then the last root page \n** in the database file is moved into the slot formerly occupied by\n** iTable and that last slot formerly occupied by the last root page\n** is added to the freelist instead of iTable.  In this say, all\n** root pages are kept at the beginning of the database file, which\n** is necessary for AUTOVACUUM to work right.  *piMoved is set to the \n** page number that used to be the last root page in the file before\n** the move.  If no page gets moved, *piMoved is set to 0.\n** The last root page is recorded in meta[3] and the value of\n** meta[3] is updated by this procedure.\n*/\nstatic int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){\n  int rc;\n  MemPage *pPage = 0;\n  BtShared *pBt = p->pBt;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->inTrans==TRANS_WRITE );\n\n  /* It is illegal to drop a table if any cursors are open on the\n  ** database. This is because in auto-vacuum mode the backend may\n  ** need to move another root-page to fill a gap left by the deleted\n  ** root page. If an open cursor was using this page a problem would \n  ** occur.\n  **\n  ** This error is caught long before control reaches this point.\n  */\n  if( NEVER(pBt->pCursor) ){\n    sqlite3ConnectionBlocked(p->db, pBt->pCursor->pBtree->db);\n    return SQLITE_LOCKED_SHAREDCACHE;\n  }\n\n  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0, 0);\n  if( rc ) return rc;\n  rc = sqlite3BtreeClearTable(p, iTable, 0);\n  if( rc ){\n    releasePage(pPage);\n    return rc;\n  }\n\n  *piMoved = 0;\n\n  if( iTable>1 ){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n    freePage(pPage, &rc);\n    releasePage(pPage);\n#else\n    if( pBt->autoVacuum ){\n      Pgno maxRootPgno;\n      sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno);\n\n      if( iTable==maxRootPgno ){\n        /* If the table being dropped is the table with the largest root-page\n        ** number in the database, put the root page on the free list. \n        */\n        freePage(pPage, &rc);\n        releasePage(pPage);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      }else{\n        /* The table being dropped does not have the largest root-page\n        ** number in the database. So move the page that does into the \n        ** gap left by the deleted root-page.\n        */\n        MemPage *pMove;\n        releasePage(pPage);\n        rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0, 0);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);\n        releasePage(pMove);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        pMove = 0;\n        rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0, 0);\n        freePage(pMove, &rc);\n        releasePage(pMove);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        *piMoved = maxRootPgno;\n      }\n\n      /* Set the new 'max-root-page' value in the database header. This\n      ** is the old value less one, less one more if that happens to\n      ** be a root-page number, less one again if that is the\n      ** PENDING_BYTE_PAGE.\n      */\n      maxRootPgno--;\n      while( maxRootPgno==PENDING_BYTE_PAGE(pBt)\n             || PTRMAP_ISPAGE(pBt, maxRootPgno) ){\n        maxRootPgno--;\n      }\n      assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );\n\n      rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);\n    }else{\n      freePage(pPage, &rc);\n      releasePage(pPage);\n    }\n#endif\n  }else{\n    /* If sqlite3BtreeDropTable was called on page 1.\n    ** This really never should happen except in a corrupt\n    ** database. \n    */\n    zeroPage(pPage, PTF_INTKEY|PTF_LEAF );\n    releasePage(pPage);\n  }\n  return rc;  \n}\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeDropTable(p, iTable, piMoved);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n/*\n** This function may only be called if the b-tree connection already\n** has a read or write transaction open on the database.\n**\n** Read the meta-information out of a database file.  Meta[0]\n** is the number of free pages currently in the database.  Meta[1]\n** through meta[15] are available for use by higher layers.  Meta[0]\n** is read-only, the others are read/write.\n** \n** The schema layer numbers meta values differently.  At the schema\n** layer (and the SetCookie and ReadCookie opcodes) the number of\n** free pages is not visible.  So Cookie[0] is the same as Meta[1].\n*/\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK) );\n  assert( pBt->pPage1 );\n  assert( idx>=0 && idx<=15 );\n\n  *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);\n\n  /* If auto-vacuum is disabled in this build and this is an auto-vacuum\n  ** database, mark the database as read-only.  */\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  if( idx==BTREE_LARGEST_ROOT_PAGE && *pMeta>0 ){\n    pBt->btsFlags |= BTS_READ_ONLY;\n  }\n#endif\n\n  sqlite3BtreeLeave(p);\n}\n\n/*\n** Write meta-information back into the database.  Meta[0] is\n** read-only and may not be written.\n*/\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){\n  BtShared *pBt = p->pBt;\n  unsigned char *pP1;\n  int rc;\n  assert( idx>=1 && idx<=15 );\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1!=0 );\n  pP1 = pBt->pPage1->aData;\n  rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n  if( rc==SQLITE_OK ){\n    put4byte(&pP1[36 + idx*4], iMeta);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( idx==BTREE_INCR_VACUUM ){\n      assert( pBt->autoVacuum || iMeta==0 );\n      assert( iMeta==0 || iMeta==1 );\n      pBt->incrVacuum = (u8)iMeta;\n    }\n#endif\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_BTREECOUNT\n/*\n** The first argument, pCur, is a cursor opened on some b-tree. Count the\n** number of entries in the b-tree and write the result to *pnEntry.\n**\n** SQLITE_OK is returned if the operation is successfully executed. \n** Otherwise, if an error is encountered (i.e. an IO error or database\n** corruption) an SQLite error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){\n  i64 nEntry = 0;                      /* Value to return in *pnEntry */\n  int rc;                              /* Return code */\n\n  if( pCur->pgnoRoot==0 ){\n    *pnEntry = 0;\n    return SQLITE_OK;\n  }\n  rc = moveToRoot(pCur);\n\n  /* Unless an error occurs, the following loop runs one iteration for each\n  ** page in the B-Tree structure (not including overflow pages). \n  */\n  while( rc==SQLITE_OK ){\n    int iIdx;                          /* Index of child node in parent */\n    MemPage *pPage;                    /* Current page of the b-tree */\n\n    /* If this is a leaf page or the tree is not an int-key tree, then \n    ** this page contains countable entries. Increment the entry counter\n    ** accordingly.\n    */\n    pPage = pCur->apPage[pCur->iPage];\n    if( pPage->leaf || !pPage->intKey ){\n      nEntry += pPage->nCell;\n    }\n\n    /* pPage is a leaf node. This loop navigates the cursor so that it \n    ** points to the first interior cell that it points to the parent of\n    ** the next page in the tree that has not yet been visited. The\n    ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell\n    ** of the page, or to the number of cells in the page if the next page\n    ** to visit is the right-child of its parent.\n    **\n    ** If all pages in the tree have been visited, return SQLITE_OK to the\n    ** caller.\n    */\n    if( pPage->leaf ){\n      do {\n        if( pCur->iPage==0 ){\n          /* All pages of the b-tree have been visited. Return successfully. */\n          *pnEntry = nEntry;\n          return SQLITE_OK;\n        }\n        moveToParent(pCur);\n      }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell );\n\n      pCur->aiIdx[pCur->iPage]++;\n      pPage = pCur->apPage[pCur->iPage];\n    }\n\n    /* Descend to the child node of the cell that the cursor currently \n    ** points at. This is the right-child if (iIdx==pPage->nCell).\n    */\n    iIdx = pCur->aiIdx[pCur->iPage];\n    if( iIdx==pPage->nCell ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n    }else{\n      rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));\n    }\n  }\n\n  /* An error has occurred. Return an error code. */\n  return rc;\n}\n#endif\n\n/*\n** Return the pager associated with a BTree.  This routine is used for\n** testing and debugging only.\n*/\nSQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){\n  return p->pBt->pPager;\n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Append a message to the error message string.\n*/\nstatic void checkAppendMsg(\n  IntegrityCk *pCheck,\n  char *zMsg1,\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  if( !pCheck->mxErr ) return;\n  pCheck->mxErr--;\n  pCheck->nErr++;\n  va_start(ap, zFormat);\n  if( pCheck->errMsg.nChar ){\n    sqlite3StrAccumAppend(&pCheck->errMsg, \"\\n\", 1);\n  }\n  if( zMsg1 ){\n    sqlite3StrAccumAppend(&pCheck->errMsg, zMsg1, -1);\n  }\n  sqlite3VXPrintf(&pCheck->errMsg, 1, zFormat, ap);\n  va_end(ap);\n  if( pCheck->errMsg.mallocFailed ){\n    pCheck->mallocFailed = 1;\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n\n/*\n** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that\n** corresponds to page iPg is already set.\n*/\nstatic int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));\n}\n\n/*\n** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.\n*/\nstatic void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));\n}\n\n\n/*\n** Add 1 to the reference count for page iPage.  If this is the second\n** reference to the page, add an error message to pCheck->zErrMsg.\n** Return 1 if there are 2 ore more references to the page and 0 if\n** if this is the first reference to the page.\n**\n** Also check that the page number is in bounds.\n*/\nstatic int checkRef(IntegrityCk *pCheck, Pgno iPage, char *zContext){\n  if( iPage==0 ) return 1;\n  if( iPage>pCheck->nPage ){\n    checkAppendMsg(pCheck, zContext, \"invalid page number %d\", iPage);\n    return 1;\n  }\n  if( getPageReferenced(pCheck, iPage) ){\n    checkAppendMsg(pCheck, zContext, \"2nd reference to page %d\", iPage);\n    return 1;\n  }\n  setPageReferenced(pCheck, iPage);\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Check that the entry in the pointer-map for page iChild maps to \n** page iParent, pointer type ptrType. If not, append an error message\n** to pCheck.\n*/\nstatic void checkPtrmap(\n  IntegrityCk *pCheck,   /* Integrity check context */\n  Pgno iChild,           /* Child page number */\n  u8 eType,              /* Expected pointer map type */\n  Pgno iParent,          /* Expected pointer map parent page number */\n  char *zContext         /* Context description (used for error msg) */\n){\n  int rc;\n  u8 ePtrmapType;\n  Pgno iPtrmapParent;\n\n  rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;\n    checkAppendMsg(pCheck, zContext, \"Failed to read ptrmap key=%d\", iChild);\n    return;\n  }\n\n  if( ePtrmapType!=eType || iPtrmapParent!=iParent ){\n    checkAppendMsg(pCheck, zContext, \n      \"Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)\", \n      iChild, eType, iParent, ePtrmapType, iPtrmapParent);\n  }\n}\n#endif\n\n/*\n** Check the integrity of the freelist or of an overflow page list.\n** Verify that the number of pages on the list is N.\n*/\nstatic void checkList(\n  IntegrityCk *pCheck,  /* Integrity checking context */\n  int isFreeList,       /* True for a freelist.  False for overflow page list */\n  int iPage,            /* Page number for first page in the list */\n  int N,                /* Expected number of pages in the list */\n  char *zContext        /* Context for error messages */\n){\n  int i;\n  int expected = N;\n  int iFirst = iPage;\n  while( N-- > 0 && pCheck->mxErr ){\n    DbPage *pOvflPage;\n    unsigned char *pOvflData;\n    if( iPage<1 ){\n      checkAppendMsg(pCheck, zContext,\n         \"%d of %d pages missing from overflow list starting at %d\",\n          N+1, expected, iFirst);\n      break;\n    }\n    if( checkRef(pCheck, iPage, zContext) ) break;\n    if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage) ){\n      checkAppendMsg(pCheck, zContext, \"failed to get page %d\", iPage);\n      break;\n    }\n    pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);\n    if( isFreeList ){\n      int n = get4byte(&pOvflData[4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pCheck->pBt->autoVacuum ){\n        checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0, zContext);\n      }\n#endif\n      if( n>(int)pCheck->pBt->usableSize/4-2 ){\n        checkAppendMsg(pCheck, zContext,\n           \"freelist leaf count too big on page %d\", iPage);\n        N--;\n      }else{\n        for(i=0; i<n; i++){\n          Pgno iFreePage = get4byte(&pOvflData[8+i*4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n          if( pCheck->pBt->autoVacuum ){\n            checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0, zContext);\n          }\n#endif\n          checkRef(pCheck, iFreePage, zContext);\n        }\n        N -= n;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    else{\n      /* If this database supports auto-vacuum and iPage is not the last\n      ** page in this overflow list, check that the pointer-map entry for\n      ** the following page matches iPage.\n      */\n      if( pCheck->pBt->autoVacuum && N>0 ){\n        i = get4byte(pOvflData);\n        checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage, zContext);\n      }\n    }\n#endif\n    iPage = get4byte(pOvflData);\n    sqlite3PagerUnref(pOvflPage);\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Do various sanity checks on a single page of a tree.  Return\n** the tree depth.  Root pages return 0.  Parents of root pages\n** return 1, and so forth.\n** \n** These checks are done:\n**\n**      1.  Make sure that cells and freeblocks do not overlap\n**          but combine to completely cover the page.\n**  NO  2.  Make sure cell keys are in order.\n**  NO  3.  Make sure no key is less than or equal to zLowerBound.\n**  NO  4.  Make sure no key is greater than or equal to zUpperBound.\n**      5.  Check the integrity of overflow pages.\n**      6.  Recursively call checkTreePage on all children.\n**      7.  Verify that the depth of all children is the same.\n**      8.  Make sure this page is at least 33% full or else it is\n**          the root of the tree.\n*/\nstatic int checkTreePage(\n  IntegrityCk *pCheck,  /* Context for the sanity check */\n  int iPage,            /* Page number of the page to check */\n  char *zParentContext, /* Parent context */\n  i64 *pnParentMinKey, \n  i64 *pnParentMaxKey\n){\n  MemPage *pPage;\n  int i, rc, depth, d2, pgno, cnt;\n  int hdr, cellStart;\n  int nCell;\n  u8 *data;\n  BtShared *pBt;\n  int usableSize;\n  char zContext[100];\n  char *hit = 0;\n  i64 nMinKey = 0;\n  i64 nMaxKey = 0;\n\n  sqlite3_snprintf(sizeof(zContext), zContext, \"Page %d: \", iPage);\n\n  /* Check that the page exists\n  */\n  pBt = pCheck->pBt;\n  usableSize = pBt->usableSize;\n  if( iPage==0 ) return 0;\n  if( checkRef(pCheck, iPage, zParentContext) ) return 0;\n  if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0, 0))!=0 ){\n    checkAppendMsg(pCheck, zContext,\n       \"unable to get the page. error code=%d\", rc);\n    return 0;\n  }\n\n  /* Clear MemPage.isInit to make sure the corruption detection code in\n  ** btreeInitPage() is executed.  */\n  pPage->isInit = 0;\n  if( (rc = btreeInitPage(pPage))!=0 ){\n    assert( rc==SQLITE_CORRUPT );  /* The only possible error from InitPage */\n    checkAppendMsg(pCheck, zContext, \n                   \"btreeInitPage() returns error code %d\", rc);\n    releasePage(pPage);\n    return 0;\n  }\n\n  /* Check out all the cells.\n  */\n  depth = 0;\n  for(i=0; i<pPage->nCell && pCheck->mxErr; i++){\n    u8 *pCell;\n    u32 sz;\n    CellInfo info;\n\n    /* Check payload overflow pages\n    */\n    sqlite3_snprintf(sizeof(zContext), zContext,\n             \"On tree page %d cell %d: \", iPage, i);\n    pCell = findCell(pPage,i);\n    btreeParseCellPtr(pPage, pCell, &info);\n    sz = info.nData;\n    if( !pPage->intKey ) sz += (int)info.nKey;\n    /* For intKey pages, check that the keys are in order.\n    */\n    else if( i==0 ) nMinKey = nMaxKey = info.nKey;\n    else{\n      if( info.nKey <= nMaxKey ){\n        checkAppendMsg(pCheck, zContext, \n            \"Rowid %lld out of order (previous was %lld)\", info.nKey, nMaxKey);\n      }\n      nMaxKey = info.nKey;\n    }\n    assert( sz==info.nPayload );\n    if( (sz>info.nLocal) \n     && (&pCell[info.iOverflow]<=&pPage->aData[pBt->usableSize])\n    ){\n      int nPage = (sz - info.nLocal + usableSize - 5)/(usableSize - 4);\n      Pgno pgnoOvfl = get4byte(&pCell[info.iOverflow]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage, zContext);\n      }\n#endif\n      checkList(pCheck, 0, pgnoOvfl, nPage, zContext);\n    }\n\n    /* Check sanity of left child page.\n    */\n    if( !pPage->leaf ){\n      pgno = get4byte(pCell);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext);\n      }\n#endif\n      d2 = checkTreePage(pCheck, pgno, zContext, &nMinKey, i==0 ? NULL : &nMaxKey);\n      if( i>0 && d2!=depth ){\n        checkAppendMsg(pCheck, zContext, \"Child page depth differs\");\n      }\n      depth = d2;\n    }\n  }\n\n  if( !pPage->leaf ){\n    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    sqlite3_snprintf(sizeof(zContext), zContext, \n                     \"On page %d at right child: \", iPage);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext);\n    }\n#endif\n    checkTreePage(pCheck, pgno, zContext, NULL, !pPage->nCell ? NULL : &nMaxKey);\n  }\n \n  /* For intKey leaf pages, check that the min/max keys are in order\n  ** with any left/parent/right pages.\n  */\n  if( pPage->leaf && pPage->intKey ){\n    /* if we are a left child page */\n    if( pnParentMinKey ){\n      /* if we are the left most child page */\n      if( !pnParentMaxKey ){\n        if( nMaxKey > *pnParentMinKey ){\n          checkAppendMsg(pCheck, zContext, \n              \"Rowid %lld out of order (max larger than parent min of %lld)\",\n              nMaxKey, *pnParentMinKey);\n        }\n      }else{\n        if( nMinKey <= *pnParentMinKey ){\n          checkAppendMsg(pCheck, zContext, \n              \"Rowid %lld out of order (min less than parent min of %lld)\",\n              nMinKey, *pnParentMinKey);\n        }\n        if( nMaxKey > *pnParentMaxKey ){\n          checkAppendMsg(pCheck, zContext, \n              \"Rowid %lld out of order (max larger than parent max of %lld)\",\n              nMaxKey, *pnParentMaxKey);\n        }\n        *pnParentMinKey = nMaxKey;\n      }\n    /* else if we're a right child page */\n    } else if( pnParentMaxKey ){\n      if( nMinKey <= *pnParentMaxKey ){\n        checkAppendMsg(pCheck, zContext, \n            \"Rowid %lld out of order (min less than parent max of %lld)\",\n            nMinKey, *pnParentMaxKey);\n      }\n    }\n  }\n\n  /* Check for complete coverage of the page\n  */\n  data = pPage->aData;\n  hdr = pPage->hdrOffset;\n  hit = sqlite3PageMalloc( pBt->pageSize );\n  if( hit==0 ){\n    pCheck->mallocFailed = 1;\n  }else{\n    int contentOffset = get2byteNotZero(&data[hdr+5]);\n    assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */\n    memset(hit+contentOffset, 0, usableSize-contentOffset);\n    memset(hit, 1, contentOffset);\n    nCell = get2byte(&data[hdr+3]);\n    cellStart = hdr + 12 - 4*pPage->leaf;\n    for(i=0; i<nCell; i++){\n      int pc = get2byte(&data[cellStart+i*2]);\n      u32 size = 65536;\n      int j;\n      if( pc<=usableSize-4 ){\n        size = cellSizePtr(pPage, &data[pc]);\n      }\n      if( (int)(pc+size-1)>=usableSize ){\n        checkAppendMsg(pCheck, 0, \n            \"Corruption detected in cell %d on page %d\",i,iPage);\n      }else{\n        for(j=pc+size-1; j>=pc; j--) hit[j]++;\n      }\n    }\n    i = get2byte(&data[hdr+1]);\n    while( i>0 ){\n      int size, j;\n      assert( i<=usableSize-4 );     /* Enforced by btreeInitPage() */\n      size = get2byte(&data[i+2]);\n      assert( i+size<=usableSize );  /* Enforced by btreeInitPage() */\n      for(j=i+size-1; j>=i; j--) hit[j]++;\n      j = get2byte(&data[i]);\n      assert( j==0 || j>i+size );  /* Enforced by btreeInitPage() */\n      assert( j<=usableSize-4 );   /* Enforced by btreeInitPage() */\n      i = j;\n    }\n    for(i=cnt=0; i<usableSize; i++){\n      if( hit[i]==0 ){\n        cnt++;\n      }else if( hit[i]>1 ){\n        checkAppendMsg(pCheck, 0,\n          \"Multiple uses for byte %d of page %d\", i, iPage);\n        break;\n      }\n    }\n    if( cnt!=data[hdr+7] ){\n      checkAppendMsg(pCheck, 0, \n          \"Fragmentation of %d bytes reported as %d on page %d\",\n          cnt, data[hdr+7], iPage);\n    }\n  }\n  sqlite3PageFree(hit);\n  releasePage(pPage);\n  return depth+1;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** This routine does a complete check of the given BTree file.  aRoot[] is\n** an array of pages numbers were each page number is the root page of\n** a table.  nRoot is the number of entries in aRoot.\n**\n** A read-only or read-write transaction must be opened before calling\n** this function.\n**\n** Write the number of error seen in *pnErr.  Except for some memory\n** allocation errors,  an error message held in memory obtained from\n** malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is\n** returned.  If a memory allocation error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(\n  Btree *p,     /* The btree to be checked */\n  int *aRoot,   /* An array of root pages numbers for individual trees */\n  int nRoot,    /* Number of entries in aRoot[] */\n  int mxErr,    /* Stop reporting errors after this many */\n  int *pnErr    /* Write number of errors seen to this variable */\n){\n  Pgno i;\n  int nRef;\n  IntegrityCk sCheck;\n  BtShared *pBt = p->pBt;\n  char zErr[100];\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );\n  nRef = sqlite3PagerRefcount(pBt->pPager);\n  sCheck.pBt = pBt;\n  sCheck.pPager = pBt->pPager;\n  sCheck.nPage = btreePagecount(sCheck.pBt);\n  sCheck.mxErr = mxErr;\n  sCheck.nErr = 0;\n  sCheck.mallocFailed = 0;\n  *pnErr = 0;\n  if( sCheck.nPage==0 ){\n    sqlite3BtreeLeave(p);\n    return 0;\n  }\n\n  sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1);\n  if( !sCheck.aPgRef ){\n    *pnErr = 1;\n    sqlite3BtreeLeave(p);\n    return 0;\n  }\n  i = PENDING_BYTE_PAGE(pBt);\n  if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);\n  sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);\n  sCheck.errMsg.useMalloc = 2;\n\n  /* Check the integrity of the freelist\n  */\n  checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),\n            get4byte(&pBt->pPage1->aData[36]), \"Main freelist: \");\n\n  /* Check all the tables.\n  */\n  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){\n    if( aRoot[i]==0 ) continue;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && aRoot[i]>1 ){\n      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0);\n    }\n#endif\n    checkTreePage(&sCheck, aRoot[i], \"List of tree roots: \", NULL, NULL);\n  }\n\n  /* Make sure every page in the file is referenced\n  */\n  for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n    if( getPageReferenced(&sCheck, i)==0 ){\n      checkAppendMsg(&sCheck, 0, \"Page %d is never used\", i);\n    }\n#else\n    /* If the database supports auto-vacuum, make sure no tables contain\n    ** references to pointer-map pages.\n    */\n    if( getPageReferenced(&sCheck, i)==0 && \n       (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, 0, \"Page %d is never used\", i);\n    }\n    if( getPageReferenced(&sCheck, i)!=0 && \n       (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, 0, \"Pointer map page %d is referenced\", i);\n    }\n#endif\n  }\n\n  /* Make sure this analysis did not leave any unref() pages.\n  ** This is an internal consistency check; an integrity check\n  ** of the integrity check.\n  */\n  if( NEVER(nRef != sqlite3PagerRefcount(pBt->pPager)) ){\n    checkAppendMsg(&sCheck, 0, \n      \"Outstanding page count goes from %d to %d during this analysis\",\n      nRef, sqlite3PagerRefcount(pBt->pPager)\n    );\n  }\n\n  /* Clean  up and report errors.\n  */\n  sqlite3BtreeLeave(p);\n  sqlite3_free(sCheck.aPgRef);\n  if( sCheck.mallocFailed ){\n    sqlite3StrAccumReset(&sCheck.errMsg);\n    *pnErr = sCheck.nErr+1;\n    return 0;\n  }\n  *pnErr = sCheck.nErr;\n  if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);\n  return sqlite3StrAccumFinish(&sCheck.errMsg);\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** Return the full pathname of the underlying database file.  Return\n** an empty string if the database is in-memory or a TEMP database.\n**\n** The pager filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerFilename(p->pBt->pPager, 1);\n}\n\n/*\n** Return the pathname of the journal file for this database. The return\n** value of this routine is the same regardless of whether the journal file\n** has been created or not.\n**\n** The pager journal filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerJournalname(p->pBt->pPager);\n}\n\n/*\n** Return non-zero if a transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree *p){\n  assert( p==0 || sqlite3_mutex_held(p->db->mutex) );\n  return (p && (p->inTrans==TRANS_WRITE));\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on the Btree passed as the first argument.\n**\n** Return SQLITE_LOCKED if this or any other connection has an open \n** transaction on the shared-cache the argument Btree is connected to.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;\n  if( p ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n    if( pBt->inTransaction!=TRANS_NONE ){\n      rc = SQLITE_LOCKED;\n    }else{\n      rc = sqlite3PagerCheckpoint(pBt->pPager, eMode, pnLog, pnCkpt);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** Return non-zero if a read (or write) transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->inTrans!=TRANS_NONE;\n}\n\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->nBackup!=0;\n}\n\n/*\n** This function returns a pointer to a blob of memory associated with\n** a single shared-btree. The memory is used by client code for its own\n** purposes (for example, to store a high-level schema associated with \n** the shared-btree). The btree layer manages reference counting issues.\n**\n** The first time this is called on a shared-btree, nBytes bytes of memory\n** are allocated, zeroed, and returned to the caller. For each subsequent \n** call the nBytes parameter is ignored and a pointer to the same blob\n** of memory returned. \n**\n** If the nBytes parameter is 0 and the blob of memory has not yet been\n** allocated, a null pointer is returned. If the blob has already been\n** allocated, it is returned as normal.\n**\n** Just before the shared-btree is closed, the function passed as the \n** xFree argument when the memory allocation was made is invoked on the \n** blob of allocated memory. The xFree function should not call sqlite3_free()\n** on the memory, the btree layer does that.\n*/\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  if( !pBt->pSchema && nBytes ){\n    pBt->pSchema = sqlite3DbMallocZero(0, nBytes);\n    pBt->xFreeSchema = xFree;\n  }\n  sqlite3BtreeLeave(p);\n  return pBt->pSchema;\n}\n\n/*\n** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared \n** btree as the argument handle holds an exclusive lock on the \n** sqlite_master table. Otherwise SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){\n  int rc;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE );\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Obtain a lock on the table whose root page is iTab.  The\n** lock is a write lock if isWritelock is true or a read lock\n** if it is false.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){\n  int rc = SQLITE_OK;\n  assert( p->inTrans!=TRANS_NONE );\n  if( p->sharable ){\n    u8 lockType = READ_LOCK + isWriteLock;\n    assert( READ_LOCK+1==WRITE_LOCK );\n    assert( isWriteLock==0 || isWriteLock==1 );\n\n    sqlite3BtreeEnter(p);\n    rc = querySharedCacheTableLock(p, iTab, lockType);\n    if( rc==SQLITE_OK ){\n      rc = setSharedCacheTableLock(p, iTab, lockType);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Argument pCsr must be a cursor opened for writing on an \n** INTKEY table currently pointing at a valid table entry. \n** This function modifies the data stored as part of that entry.\n**\n** Only the data content may only be modified, it is not possible to \n** change the length of the data stored. If this function is called with\n** parameters that attempt to write past the end of the existing data,\n** no modifications are made and SQLITE_CORRUPT is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){\n  int rc;\n  assert( cursorHoldsMutex(pCsr) );\n  assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );\n  assert( pCsr->isIncrblobHandle );\n\n  rc = restoreCursorPosition(pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pCsr->eState!=CURSOR_REQUIRESEEK );\n  if( pCsr->eState!=CURSOR_VALID ){\n    return SQLITE_ABORT;\n  }\n\n  /* Save the positions of all other cursors open on this table. This is\n  ** required in case any of them are holding references to an xFetch\n  ** version of the b-tree page modified by the accessPayload call below.\n  **\n  ** Note that pCsr must be open on a BTREE_INTKEY table and saveCursorPosition()\n  ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence\n  ** saveAllCursors can only return SQLITE_OK.\n  */\n  VVA_ONLY(rc =) saveAllCursors(pCsr->pBt, pCsr->pgnoRoot, pCsr);\n  assert( rc==SQLITE_OK );\n\n  /* Check some assumptions: \n  **   (a) the cursor is open for writing,\n  **   (b) there is a read/write transaction open,\n  **   (c) the connection holds a write-lock on the table (if required),\n  **   (d) there are no conflicting read-locks, and\n  **   (e) the cursor points at a valid row of an intKey table.\n  */\n  if( !pCsr->wrFlag ){\n    return SQLITE_READONLY;\n  }\n  assert( (pCsr->pBt->btsFlags & BTS_READ_ONLY)==0\n              && pCsr->pBt->inTransaction==TRANS_WRITE );\n  assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );\n  assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );\n  assert( pCsr->apPage[pCsr->iPage]->intKey );\n\n  return accessPayload(pCsr, offset, amt, (unsigned char *)z, 1);\n}\n\n/* \n** Set a flag on this cursor to cache the locations of pages from the \n** overflow list for the current row. This is used by cursors opened\n** for incremental blob IO only.\n**\n** This function sets a flag only. The actual page location cache\n** (stored in BtCursor.aOverflow[]) is allocated and used by function\n** accessPayload() (the worker function for sqlite3BtreeData() and\n** sqlite3BtreePutData()).\n*/\nSQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  invalidateOverflowCache(pCur);\n  pCur->isIncrblobHandle = 1;\n}\n#endif\n\n/*\n** Set both the \"read version\" (single byte at byte offset 18) and \n** \"write version\" (single byte at byte offset 19) fields in the database\n** header to iVersion.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){\n  BtShared *pBt = pBtree->pBt;\n  int rc;                         /* Return code */\n \n  assert( iVersion==1 || iVersion==2 );\n\n  /* If setting the version fields to 1, do not automatically open the\n  ** WAL connection, even if the version fields are currently set to 2.\n  */\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;\n\n  rc = sqlite3BtreeBeginTrans(pBtree, 0);\n  if( rc==SQLITE_OK ){\n    u8 *aData = pBt->pPage1->aData;\n    if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){\n      rc = sqlite3BtreeBeginTrans(pBtree, 2);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          aData[18] = (u8)iVersion;\n          aData[19] = (u8)iVersion;\n        }\n      }\n    }\n  }\n\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  return rc;\n}\n\n/*\n** set the mask of hint flags for cursor pCsr. Currently the only valid\n** values are 0 and BTREE_BULKLOAD.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){\n  assert( mask==BTREE_BULKLOAD || mask==0 );\n  pCsr->hints = mask;\n}\n\n/************** End of btree.c ***********************************************/\n/************** Begin file backup.c ******************************************/\n/*\n** 2009 January 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_backup_XXX() \n** API functions and the related features.\n*/\n\n/* Macro to find the minimum of two numeric values.\n*/\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n\n/*\n** Structure allocated for each backup operation.\n*/\nstruct sqlite3_backup {\n  sqlite3* pDestDb;        /* Destination database handle */\n  Btree *pDest;            /* Destination b-tree file */\n  u32 iDestSchema;         /* Original schema cookie in destination */\n  int bDestLocked;         /* True once a write-transaction is open on pDest */\n\n  Pgno iNext;              /* Page number of the next source page to copy */\n  sqlite3* pSrcDb;         /* Source database handle */\n  Btree *pSrc;             /* Source b-tree file */\n\n  int rc;                  /* Backup process error code */\n\n  /* These two variables are set by every call to backup_step(). They are\n  ** read by calls to backup_remaining() and backup_pagecount().\n  */\n  Pgno nRemaining;         /* Number of pages left to copy */\n  Pgno nPagecount;         /* Total number of pages to copy */\n\n  int isAttached;          /* True once backup has been registered with pager */\n  sqlite3_backup *pNext;   /* Next backup associated with source pager */\n};\n\n/*\n** THREAD SAFETY NOTES:\n**\n**   Once it has been created using backup_init(), a single sqlite3_backup\n**   structure may be accessed via two groups of thread-safe entry points:\n**\n**     * Via the sqlite3_backup_XXX() API function backup_step() and \n**       backup_finish(). Both these functions obtain the source database\n**       handle mutex and the mutex associated with the source BtShared \n**       structure, in that order.\n**\n**     * Via the BackupUpdate() and BackupRestart() functions, which are\n**       invoked by the pager layer to report various state changes in\n**       the page cache associated with the source database. The mutex\n**       associated with the source database BtShared structure will always \n**       be held when either of these functions are invoked.\n**\n**   The other sqlite3_backup_XXX() API functions, backup_remaining() and\n**   backup_pagecount() are not thread-safe functions. If they are called\n**   while some other thread is calling backup_step() or backup_finish(),\n**   the values returned may be invalid. There is no way for a call to\n**   BackupUpdate() or BackupRestart() to interfere with backup_remaining()\n**   or backup_pagecount().\n**\n**   Depending on the SQLite configuration, the database handles and/or\n**   the Btree objects may have their own mutexes that require locking.\n**   Non-sharable Btrees (in-memory databases for example), do not have\n**   associated mutexes.\n*/\n\n/*\n** Return a pointer corresponding to database zDb (i.e. \"main\", \"temp\")\n** in connection handle pDb. If such a database cannot be found, return\n** a NULL pointer and write an error message to pErrorDb.\n**\n** If the \"temp\" database is requested, it may need to be opened by this \n** function. If an error occurs while doing so, return 0 and write an \n** error message to pErrorDb.\n*/\nstatic Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){\n  int i = sqlite3FindDbName(pDb, zDb);\n\n  if( i==1 ){\n    Parse *pParse;\n    int rc = 0;\n    pParse = sqlite3StackAllocZero(pErrorDb, sizeof(*pParse));\n    if( pParse==0 ){\n      sqlite3Error(pErrorDb, SQLITE_NOMEM, \"out of memory\");\n      rc = SQLITE_NOMEM;\n    }else{\n      pParse->db = pDb;\n      if( sqlite3OpenTempDatabase(pParse) ){\n        sqlite3Error(pErrorDb, pParse->rc, \"%s\", pParse->zErrMsg);\n        rc = SQLITE_ERROR;\n      }\n      sqlite3DbFree(pErrorDb, pParse->zErrMsg);\n      sqlite3StackFree(pErrorDb, pParse);\n    }\n    if( rc ){\n      return 0;\n    }\n  }\n\n  if( i<0 ){\n    sqlite3Error(pErrorDb, SQLITE_ERROR, \"unknown database %s\", zDb);\n    return 0;\n  }\n\n  return pDb->aDb[i].pBt;\n}\n\n/*\n** Attempt to set the page size of the destination to match the page size\n** of the source.\n*/\nstatic int setDestPgsz(sqlite3_backup *p){\n  int rc;\n  rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0);\n  return rc;\n}\n\n/*\n** Create an sqlite3_backup process to copy the contents of zSrcDb from\n** connection handle pSrcDb to zDestDb in pDestDb. If successful, return\n** a pointer to the new sqlite3_backup object.\n**\n** If an error occurs, NULL is returned and an error code and error message\n** stored in database handle pDestDb.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3* pDestDb,                     /* Database to write to */\n  const char *zDestDb,                  /* Name of database within pDestDb */\n  sqlite3* pSrcDb,                      /* Database connection to read from */\n  const char *zSrcDb                    /* Name of database within pSrcDb */\n){\n  sqlite3_backup *p;                    /* Value to return */\n\n  /* Lock the source database handle. The destination database\n  ** handle is not locked in this routine, but it is locked in\n  ** sqlite3_backup_step(). The user is required to ensure that no\n  ** other thread accesses the destination handle for the duration\n  ** of the backup operation.  Any attempt to use the destination\n  ** database connection while a backup is in progress may cause\n  ** a malfunction or a deadlock.\n  */\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3_mutex_enter(pDestDb->mutex);\n\n  if( pSrcDb==pDestDb ){\n    sqlite3Error(\n        pDestDb, SQLITE_ERROR, \"source and destination must be distinct\"\n    );\n    p = 0;\n  }else {\n    /* Allocate space for a new sqlite3_backup object...\n    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup));\n    if( !p ){\n      sqlite3Error(pDestDb, SQLITE_NOMEM, 0);\n    }\n  }\n\n  /* If the allocation succeeded, populate the new object. */\n  if( p ){\n    p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb);\n    p->pDest = findBtree(pDestDb, pDestDb, zDestDb);\n    p->pDestDb = pDestDb;\n    p->pSrcDb = pSrcDb;\n    p->iNext = 1;\n    p->isAttached = 0;\n\n    if( 0==p->pSrc || 0==p->pDest || setDestPgsz(p)==SQLITE_NOMEM ){\n      /* One (or both) of the named databases did not exist or an OOM\n      ** error was hit.  The error has already been written into the\n      ** pDestDb handle.  All that is left to do here is free the\n      ** sqlite3_backup structure.\n      */\n      sqlite3_free(p);\n      p = 0;\n    }\n  }\n  if( p ){\n    p->pSrc->nBackup++;\n  }\n\n  sqlite3_mutex_leave(pDestDb->mutex);\n  sqlite3_mutex_leave(pSrcDb->mutex);\n  return p;\n}\n\n/*\n** Argument rc is an SQLite error code. Return true if this error is \n** considered fatal if encountered during a backup operation. All errors\n** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED.\n*/\nstatic int isFatalError(int rc){\n  return (rc!=SQLITE_OK && rc!=SQLITE_BUSY && ALWAYS(rc!=SQLITE_LOCKED));\n}\n\n/*\n** Parameter zSrcData points to a buffer containing the data for \n** page iSrcPg from the source database. Copy this data into the \n** destination database.\n*/\nstatic int backupOnePage(\n  sqlite3_backup *p,              /* Backup handle */\n  Pgno iSrcPg,                    /* Source database page to backup */\n  const u8 *zSrcData,             /* Source database page data */\n  int bUpdate                     /* True for an update, false otherwise */\n){\n  Pager * const pDestPager = sqlite3BtreePager(p->pDest);\n  const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);\n  int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);\n  const int nCopy = MIN(nSrcPgsz, nDestPgsz);\n  const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;\n#ifdef SQLITE_HAS_CODEC\n  /* Use BtreeGetReserveNoMutex() for the source b-tree, as although it is\n  ** guaranteed that the shared-mutex is held by this thread, handle\n  ** p->pSrc may not actually be the owner.  */\n  int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);\n  int nDestReserve = sqlite3BtreeGetReserve(p->pDest);\n#endif\n  int rc = SQLITE_OK;\n  i64 iOff;\n\n  assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );\n  assert( p->bDestLocked );\n  assert( !isFatalError(p->rc) );\n  assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );\n  assert( zSrcData );\n\n  /* Catch the case where the destination is an in-memory database and the\n  ** page sizes of the source and destination differ. \n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){\n    rc = SQLITE_READONLY;\n  }\n\n#ifdef SQLITE_HAS_CODEC\n  /* Backup is not possible if the page size of the destination is changing\n  ** and a codec is in use.\n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){\n    rc = SQLITE_READONLY;\n  }\n\n  /* Backup is not possible if the number of bytes of reserve space differ\n  ** between source and destination.  If there is a difference, try to\n  ** fix the destination to agree with the source.  If that is not possible,\n  ** then the backup cannot proceed.\n  */\n  if( nSrcReserve!=nDestReserve ){\n    u32 newPgsz = nSrcPgsz;\n    rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve);\n    if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY;\n  }\n#endif\n\n  /* This loop runs once for each destination page spanned by the source \n  ** page. For each iteration, variable iOff is set to the byte offset\n  ** of the destination page.\n  */\n  for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){\n    DbPage *pDestPg = 0;\n    Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;\n    if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;\n    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg))\n     && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))\n    ){\n      const u8 *zIn = &zSrcData[iOff%nSrcPgsz];\n      u8 *zDestData = sqlite3PagerGetData(pDestPg);\n      u8 *zOut = &zDestData[iOff%nDestPgsz];\n\n      /* Copy the data from the source page into the destination page.\n      ** Then clear the Btree layer MemPage.isInit flag. Both this module\n      ** and the pager code use this trick (clearing the first byte\n      ** of the page 'extra' space to invalidate the Btree layers\n      ** cached parse of the page). MemPage.isInit is marked \n      ** \"MUST BE FIRST\" for this purpose.\n      */\n      memcpy(zOut, zIn, nCopy);\n      ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;\n      if( iOff==0 && bUpdate==0 ){\n        sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));\n      }\n    }\n    sqlite3PagerUnref(pDestPg);\n  }\n\n  return rc;\n}\n\n/*\n** If pFile is currently larger than iSize bytes, then truncate it to\n** exactly iSize bytes. If pFile is not larger than iSize bytes, then\n** this function is a no-op.\n**\n** Return SQLITE_OK if everything is successful, or an SQLite error \n** code if an error occurs.\n*/\nstatic int backupTruncateFile(sqlite3_file *pFile, i64 iSize){\n  i64 iCurrent;\n  int rc = sqlite3OsFileSize(pFile, &iCurrent);\n  if( rc==SQLITE_OK && iCurrent>iSize ){\n    rc = sqlite3OsTruncate(pFile, iSize);\n  }\n  return rc;\n}\n\n/*\n** Register this backup object with the associated source pager for\n** callbacks when pages are changed or the cache invalidated.\n*/\nstatic void attachBackupObject(sqlite3_backup *p){\n  sqlite3_backup **pp;\n  assert( sqlite3BtreeHoldsMutex(p->pSrc) );\n  pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n  p->pNext = *pp;\n  *pp = p;\n  p->isAttached = 1;\n}\n\n/*\n** Copy nPage pages from the source b-tree to the destination.\n*/\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){\n  int rc;\n  int destMode;       /* Destination journal mode */\n  int pgszSrc = 0;    /* Source page size */\n  int pgszDest = 0;   /* Destination page size */\n\n  sqlite3_mutex_enter(p->pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  rc = p->rc;\n  if( !isFatalError(rc) ){\n    Pager * const pSrcPager = sqlite3BtreePager(p->pSrc);     /* Source pager */\n    Pager * const pDestPager = sqlite3BtreePager(p->pDest);   /* Dest pager */\n    int ii;                            /* Iterator variable */\n    int nSrcPage = -1;                 /* Size of source db in pages */\n    int bCloseTrans = 0;               /* True if src db requires unlocking */\n\n    /* If the source pager is currently in a write-transaction, return\n    ** SQLITE_BUSY immediately.\n    */\n    if( p->pDestDb && p->pSrc->pBt->inTransaction==TRANS_WRITE ){\n      rc = SQLITE_BUSY;\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Lock the destination database, if it is not locked already. */\n    if( SQLITE_OK==rc && p->bDestLocked==0\n     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2)) \n    ){\n      p->bDestLocked = 1;\n      sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);\n    }\n\n    /* If there is no open read-transaction on the source database, open\n    ** one now. If a transaction is opened here, then it will be closed\n    ** before this function exits.\n    */\n    if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){\n      rc = sqlite3BtreeBeginTrans(p->pSrc, 0);\n      bCloseTrans = 1;\n    }\n\n    /* Do not allow backup if the destination database is in WAL mode\n    ** and the page sizes are different between source and destination */\n    pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);\n    pgszDest = sqlite3BtreeGetPageSize(p->pDest);\n    destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));\n    if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){\n      rc = SQLITE_READONLY;\n    }\n  \n    /* Now that there is a read-lock on the source database, query the\n    ** source pager for the number of pages in the database.\n    */\n    nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);\n    assert( nSrcPage>=0 );\n    for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){\n      const Pgno iSrcPg = p->iNext;                 /* Source page number */\n      if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){\n        DbPage *pSrcPg;                             /* Source page object */\n        rc = sqlite3PagerAcquire(pSrcPager, iSrcPg, &pSrcPg,\n                                 PAGER_ACQUIRE_READONLY);\n        if( rc==SQLITE_OK ){\n          rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);\n          sqlite3PagerUnref(pSrcPg);\n        }\n      }\n      p->iNext++;\n    }\n    if( rc==SQLITE_OK ){\n      p->nPagecount = nSrcPage;\n      p->nRemaining = nSrcPage+1-p->iNext;\n      if( p->iNext>(Pgno)nSrcPage ){\n        rc = SQLITE_DONE;\n      }else if( !p->isAttached ){\n        attachBackupObject(p);\n      }\n    }\n  \n    /* Update the schema version field in the destination database. This\n    ** is to make sure that the schema-version really does change in\n    ** the case where the source and destination databases have the\n    ** same schema version.\n    */\n    if( rc==SQLITE_DONE ){\n      if( nSrcPage==0 ){\n        rc = sqlite3BtreeNewDb(p->pDest);\n        nSrcPage = 1;\n      }\n      if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n        rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);\n      }\n      if( rc==SQLITE_OK ){\n        if( p->pDestDb ){\n          sqlite3ResetAllSchemasOfConnection(p->pDestDb);\n        }\n        if( destMode==PAGER_JOURNALMODE_WAL ){\n          rc = sqlite3BtreeSetVersion(p->pDest, 2);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        int nDestTruncate;\n        /* Set nDestTruncate to the final number of pages in the destination\n        ** database. The complication here is that the destination page\n        ** size may be different to the source page size. \n        **\n        ** If the source page size is smaller than the destination page size, \n        ** round up. In this case the call to sqlite3OsTruncate() below will\n        ** fix the size of the file. However it is important to call\n        ** sqlite3PagerTruncateImage() here so that any pages in the \n        ** destination file that lie beyond the nDestTruncate page mark are\n        ** journalled by PagerCommitPhaseOne() before they are destroyed\n        ** by the file truncation.\n        */\n        assert( pgszSrc==sqlite3BtreeGetPageSize(p->pSrc) );\n        assert( pgszDest==sqlite3BtreeGetPageSize(p->pDest) );\n        if( pgszSrc<pgszDest ){\n          int ratio = pgszDest/pgszSrc;\n          nDestTruncate = (nSrcPage+ratio-1)/ratio;\n          if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){\n            nDestTruncate--;\n          }\n        }else{\n          nDestTruncate = nSrcPage * (pgszSrc/pgszDest);\n        }\n        assert( nDestTruncate>0 );\n\n        if( pgszSrc<pgszDest ){\n          /* If the source page-size is smaller than the destination page-size,\n          ** two extra things may need to happen:\n          **\n          **   * The destination may need to be truncated, and\n          **\n          **   * Data stored on the pages immediately following the \n          **     pending-byte page in the source database may need to be\n          **     copied into the destination database.\n          */\n          const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;\n          sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);\n          Pgno iPg;\n          int nDstPage;\n          i64 iOff;\n          i64 iEnd;\n\n          assert( pFile );\n          assert( nDestTruncate==0 \n              || (i64)nDestTruncate*(i64)pgszDest >= iSize || (\n                nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)\n             && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest\n          ));\n\n          /* This block ensures that all data required to recreate the original\n          ** database has been stored in the journal for pDestPager and the\n          ** journal synced to disk. So at this point we may safely modify\n          ** the database file in any way, knowing that if a power failure\n          ** occurs, the original database will be reconstructed from the \n          ** journal file.  */\n          sqlite3PagerPagecount(pDestPager, &nDstPage);\n          for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){\n            if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){\n              DbPage *pPg;\n              rc = sqlite3PagerGet(pDestPager, iPg, &pPg);\n              if( rc==SQLITE_OK ){\n                rc = sqlite3PagerWrite(pPg);\n                sqlite3PagerUnref(pPg);\n              }\n            }\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);\n          }\n\n          /* Write the extra pages and truncate the database file as required */\n          iEnd = MIN(PENDING_BYTE + pgszDest, iSize);\n          for(\n            iOff=PENDING_BYTE+pgszSrc; \n            rc==SQLITE_OK && iOff<iEnd; \n            iOff+=pgszSrc\n          ){\n            PgHdr *pSrcPg = 0;\n            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);\n            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);\n            if( rc==SQLITE_OK ){\n              u8 *zData = sqlite3PagerGetData(pSrcPg);\n              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);\n            }\n            sqlite3PagerUnref(pSrcPg);\n          }\n          if( rc==SQLITE_OK ){\n            rc = backupTruncateFile(pFile, iSize);\n          }\n\n          /* Sync the database file to disk. */\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerSync(pDestPager);\n          }\n        }else{\n          sqlite3PagerTruncateImage(pDestPager, nDestTruncate);\n          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);\n        }\n    \n        /* Finish committing the transaction to the destination database. */\n        if( SQLITE_OK==rc\n         && SQLITE_OK==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))\n        ){\n          rc = SQLITE_DONE;\n        }\n      }\n    }\n  \n    /* If bCloseTrans is true, then this function opened a read transaction\n    ** on the source database. Close the read transaction here. There is\n    ** no need to check the return values of the btree methods here, as\n    ** \"committing\" a read-only transaction cannot fail.\n    */\n    if( bCloseTrans ){\n      TESTONLY( int rc2 );\n      TESTONLY( rc2  = ) sqlite3BtreeCommitPhaseOne(p->pSrc, 0);\n      TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p->pSrc, 0);\n      assert( rc2==SQLITE_OK );\n    }\n  \n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM;\n    }\n    p->rc = rc;\n  }\n  if( p->pDestDb ){\n    sqlite3_mutex_leave(p->pDestDb->mutex);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  sqlite3_mutex_leave(p->pSrcDb->mutex);\n  return rc;\n}\n\n/*\n** Release all resources associated with an sqlite3_backup* handle.\n*/\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){\n  sqlite3_backup **pp;                 /* Ptr to head of pagers backup list */\n  sqlite3 *pSrcDb;                     /* Source database connection */\n  int rc;                              /* Value to return */\n\n  /* Enter the mutexes */\n  if( p==0 ) return SQLITE_OK;\n  pSrcDb = p->pSrcDb;\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  /* Detach this backup from the source pager. */\n  if( p->pDestDb ){\n    p->pSrc->nBackup--;\n  }\n  if( p->isAttached ){\n    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n    while( *pp!=p ){\n      pp = &(*pp)->pNext;\n    }\n    *pp = p->pNext;\n  }\n\n  /* If a transaction is still open on the Btree, roll it back. */\n  sqlite3BtreeRollback(p->pDest, SQLITE_OK);\n\n  /* Set the error code of the destination database handle. */\n  rc = (p->rc==SQLITE_DONE) ? SQLITE_OK : p->rc;\n  sqlite3Error(p->pDestDb, rc, 0);\n\n  /* Exit the mutexes and free the backup context structure. */\n  if( p->pDestDb ){\n    sqlite3LeaveMutexAndCloseZombie(p->pDestDb);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  if( p->pDestDb ){\n    /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    sqlite3_free(p);\n  }\n  sqlite3LeaveMutexAndCloseZombie(pSrcDb);\n  return rc;\n}\n\n/*\n** Return the number of pages still to be backed up as of the most recent\n** call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){\n  return p->nRemaining;\n}\n\n/*\n** Return the total number of pages in the source database as of the most \n** recent call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){\n  return p->nPagecount;\n}\n\n/*\n** This function is called after the contents of page iPage of the\n** source database have been modified. If page iPage has already been \n** copied into the destination database, then the data written to the\n** destination is now invalidated. The destination copy of iPage needs\n** to be updated with the new data before the backup operation is\n** complete.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){\n  sqlite3_backup *p;                   /* Iterator variable */\n  for(p=pBackup; p; p=p->pNext){\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    if( !isFatalError(p->rc) && iPage<p->iNext ){\n      /* The backup process p has already copied page iPage. But now it\n      ** has been modified by a transaction on the source pager. Copy\n      ** the new data into the backup.\n      */\n      int rc;\n      assert( p->pDestDb );\n      sqlite3_mutex_enter(p->pDestDb->mutex);\n      rc = backupOnePage(p, iPage, aData, 1);\n      sqlite3_mutex_leave(p->pDestDb->mutex);\n      assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );\n      if( rc!=SQLITE_OK ){\n        p->rc = rc;\n      }\n    }\n  }\n}\n\n/*\n** Restart the backup process. This is called when the pager layer\n** detects that the database has been modified by an external database\n** connection. In this case there is no way of knowing which of the\n** pages that have been copied into the destination database are still \n** valid and which are not, so the entire process needs to be restarted.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *pBackup){\n  sqlite3_backup *p;                   /* Iterator variable */\n  for(p=pBackup; p; p=p->pNext){\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    p->iNext = 1;\n  }\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Copy the complete content of pBtFrom into pBtTo.  A transaction\n** must be active for both files.\n**\n** The size of file pTo may be reduced by this operation. If anything \n** goes wrong, the transaction on pTo is rolled back. If successful, the \n** transaction is committed before returning.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){\n  int rc;\n  sqlite3_file *pFd;              /* File descriptor for database pTo */\n  sqlite3_backup b;\n  sqlite3BtreeEnter(pTo);\n  sqlite3BtreeEnter(pFrom);\n\n  assert( sqlite3BtreeIsInTrans(pTo) );\n  pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));\n  if( pFd->pMethods ){\n    i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);\n    rc = sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n    if( rc ) goto copy_finished;\n  }\n\n  /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set\n  ** to 0. This is used by the implementations of sqlite3_backup_step()\n  ** and sqlite3_backup_finish() to detect that they are being called\n  ** from this function, not directly by the user.\n  */\n  memset(&b, 0, sizeof(b));\n  b.pSrcDb = pFrom->db;\n  b.pSrc = pFrom;\n  b.pDest = pTo;\n  b.iNext = 1;\n\n  /* 0x7FFFFFFF is the hard limit for the number of pages in a database\n  ** file. By passing this as the number of pages to copy to\n  ** sqlite3_backup_step(), we can guarantee that the copy finishes \n  ** within a single call (unless an error occurs). The assert() statement\n  ** checks this assumption - (p->rc) should be set to either SQLITE_DONE \n  ** or an error code.\n  */\n  sqlite3_backup_step(&b, 0x7FFFFFFF);\n  assert( b.rc!=SQLITE_OK );\n  rc = sqlite3_backup_finish(&b);\n  if( rc==SQLITE_OK ){\n    pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;\n  }else{\n    sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));\n  }\n\n  assert( sqlite3BtreeIsInTrans(pTo)==0 );\ncopy_finished:\n  sqlite3BtreeLeave(pFrom);\n  sqlite3BtreeLeave(pTo);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VACUUM */\n\n/************** End of backup.c **********************************************/\n/************** Begin file vdbemem.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to manipulate \"Mem\" structure.  A \"Mem\"\n** stores a single value in the VDBE.  Mem is an opaque structure visible\n** only within the VDBE.  Interface routines refer to a Mem using the\n** name sqlite_value\n*/\n\n/*\n** If pMem is an object with a valid string representation, this routine\n** ensures the internal encoding for the string representation is\n** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.\n**\n** If pMem is not a string object, or the encoding of the string\n** representation is already stored using the requested encoding, then this\n** routine is a no-op.\n**\n** SQLITE_OK is returned if the conversion is successful (or not required).\n** SQLITE_NOMEM may be returned if a malloc() fails during conversion\n** between formats.\n*/\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){\n#ifndef SQLITE_OMIT_UTF16\n  int rc;\n#endif\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE\n           || desiredEnc==SQLITE_UTF16BE );\n  if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){\n    return SQLITE_OK;\n  }\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n#ifdef SQLITE_OMIT_UTF16\n  return SQLITE_ERROR;\n#else\n\n  /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,\n  ** then the encoding of the value may not have changed.\n  */\n  rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);\n  assert(rc==SQLITE_OK    || rc==SQLITE_NOMEM);\n  assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);\n  assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);\n  return rc;\n#endif\n}\n\n/*\n** Make sure pMem->z points to a writable allocation of at least \n** n bytes.\n**\n** If the third argument passed to this function is true, then memory\n** cell pMem must contain a string or blob. In this case the content is\n** preserved. Otherwise, if the third parameter to this function is false,\n** any current string or blob value may be discarded.\n**\n** This function sets the MEM_Dyn flag and clears any xDel callback.\n** It also clears MEM_Ephem and MEM_Static. If the preserve flag is \n** not set, Mem.n is zeroed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){\n  assert( 1 >=\n    ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) +\n    (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + \n    ((pMem->flags&MEM_Ephem) ? 1 : 0) + \n    ((pMem->flags&MEM_Static) ? 1 : 0)\n  );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n\n  /* If the preserve flag is set to true, then the memory cell must already\n  ** contain a valid string or blob value.  */\n  assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );\n\n  if( n<32 ) n = 32;\n  if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){\n    if( preserve && pMem->z==pMem->zMalloc ){\n      pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);\n      preserve = 0;\n    }else{\n      sqlite3DbFree(pMem->db, pMem->zMalloc);\n      pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);\n    }\n  }\n\n  if( pMem->z && preserve && pMem->zMalloc && pMem->z!=pMem->zMalloc ){\n    memcpy(pMem->zMalloc, pMem->z, pMem->n);\n  }\n  if( pMem->flags&MEM_Dyn && pMem->xDel ){\n    assert( pMem->xDel!=SQLITE_DYNAMIC );\n    pMem->xDel((void *)(pMem->z));\n  }\n\n  pMem->z = pMem->zMalloc;\n  if( pMem->z==0 ){\n    pMem->flags = MEM_Null;\n  }else{\n    pMem->flags &= ~(MEM_Ephem|MEM_Static);\n  }\n  pMem->xDel = 0;\n  return (pMem->z ? SQLITE_OK : SQLITE_NOMEM);\n}\n\n/*\n** Make the given Mem object MEM_Dyn.  In other words, make it so\n** that any TEXT or BLOB content is stored in memory obtained from\n** malloc().  In this way, we know that the memory is safe to be\n** overwritten or altered.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){\n  int f;\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  ExpandBlob(pMem);\n  f = pMem->flags;\n  if( (f&(MEM_Str|MEM_Blob)) && pMem->z!=pMem->zMalloc ){\n    if( sqlite3VdbeMemGrow(pMem, pMem->n + 2, 1) ){\n      return SQLITE_NOMEM;\n    }\n    pMem->z[pMem->n] = 0;\n    pMem->z[pMem->n+1] = 0;\n    pMem->flags |= MEM_Term;\n#ifdef SQLITE_DEBUG\n    pMem->pScopyFrom = 0;\n#endif\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** If the given Mem* has a zero-filled tail, turn it into an ordinary\n** blob stored in dynamically allocated space.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){\n  if( pMem->flags & MEM_Zero ){\n    int nByte;\n    assert( pMem->flags&MEM_Blob );\n    assert( (pMem->flags&MEM_RowSet)==0 );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n\n    /* Set nByte to the number of bytes required to store the expanded blob. */\n    nByte = pMem->n + pMem->u.nZero;\n    if( nByte<=0 ){\n      nByte = 1;\n    }\n    if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){\n      return SQLITE_NOMEM;\n    }\n\n    memset(&pMem->z[pMem->n], 0, pMem->u.nZero);\n    pMem->n += pMem->u.nZero;\n    pMem->flags &= ~(MEM_Zero|MEM_Term);\n  }\n  return SQLITE_OK;\n}\n#endif\n\n\n/*\n** Make sure the given Mem is \\u0000 terminated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){\n    return SQLITE_OK;   /* Nothing to do */\n  }\n  if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){\n    return SQLITE_NOMEM;\n  }\n  pMem->z[pMem->n] = 0;\n  pMem->z[pMem->n+1] = 0;\n  pMem->flags |= MEM_Term;\n  return SQLITE_OK;\n}\n\n/*\n** Add MEM_Str to the set of representations for the given Mem.  Numbers\n** are converted using sqlite3_snprintf().  Converting a BLOB to a string\n** is a no-op.\n**\n** Existing representations MEM_Int and MEM_Real are *not* invalidated.\n**\n** A MEM_Null value will never be passed to this function. This function is\n** used for converting values to text for returning to the user (i.e. via\n** sqlite3_value_text()), or for ensuring that values to be used as btree\n** keys are strings. In the former case a NULL pointer is returned the\n** user and the later is an internal programming error.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, int enc){\n  int rc = SQLITE_OK;\n  int fg = pMem->flags;\n  const int nByte = 32;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !(fg&MEM_Zero) );\n  assert( !(fg&(MEM_Str|MEM_Blob)) );\n  assert( fg&(MEM_Int|MEM_Real) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n\n  if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){\n    return SQLITE_NOMEM;\n  }\n\n  /* For a Real or Integer, use sqlite3_mprintf() to produce the UTF-8\n  ** string representation of the value. Then, if the required encoding\n  ** is UTF-16le or UTF-16be do a translation.\n  ** \n  ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.\n  */\n  if( fg & MEM_Int ){\n    sqlite3_snprintf(nByte, pMem->z, \"%lld\", pMem->u.i);\n  }else{\n    assert( fg & MEM_Real );\n    sqlite3_snprintf(nByte, pMem->z, \"%!.15g\", pMem->r);\n  }\n  pMem->n = sqlite3Strlen30(pMem->z);\n  pMem->enc = SQLITE_UTF8;\n  pMem->flags |= MEM_Str|MEM_Term;\n  sqlite3VdbeChangeEncoding(pMem, enc);\n  return rc;\n}\n\n/*\n** Memory cell pMem contains the context of an aggregate function.\n** This routine calls the finalize method for that function.  The\n** result of the aggregate is stored back into pMem.\n**\n** Return SQLITE_ERROR if the finalizer reports an error.  SQLITE_OK\n** otherwise.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pFunc && pFunc->xFinalize) ){\n    sqlite3_context ctx;\n    assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    memset(&ctx, 0, sizeof(ctx));\n    ctx.s.flags = MEM_Null;\n    ctx.s.db = pMem->db;\n    ctx.pMem = pMem;\n    ctx.pFunc = pFunc;\n    pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */\n    assert( 0==(pMem->flags&MEM_Dyn) && !pMem->xDel );\n    sqlite3DbFree(pMem->db, pMem->zMalloc);\n    memcpy(pMem, &ctx.s, sizeof(ctx.s));\n    rc = ctx.isError;\n  }\n  return rc;\n}\n\n/*\n** If the memory cell contains a string value that must be freed by\n** invoking an external callback, free it now. Calling this function\n** does not free any Mem.zMalloc buffer.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemReleaseExternal(Mem *p){\n  assert( p->db==0 || sqlite3_mutex_held(p->db->mutex) );\n  if( p->flags&MEM_Agg ){\n    sqlite3VdbeMemFinalize(p, p->u.pDef);\n    assert( (p->flags & MEM_Agg)==0 );\n    sqlite3VdbeMemRelease(p);\n  }else if( p->flags&MEM_Dyn && p->xDel ){\n    assert( (p->flags&MEM_RowSet)==0 );\n    assert( p->xDel!=SQLITE_DYNAMIC );\n    p->xDel((void *)p->z);\n    p->xDel = 0;\n  }else if( p->flags&MEM_RowSet ){\n    sqlite3RowSetClear(p->u.pRowSet);\n  }else if( p->flags&MEM_Frame ){\n    sqlite3VdbeMemSetNull(p);\n  }\n}\n\n/*\n** Release any memory held by the Mem. This may leave the Mem in an\n** inconsistent state, for example with (Mem.z==0) and\n** (Mem.type==SQLITE_TEXT).\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){\n  VdbeMemRelease(p);\n  sqlite3DbFree(p->db, p->zMalloc);\n  p->z = 0;\n  p->zMalloc = 0;\n  p->xDel = 0;\n}\n\n/*\n** Convert a 64-bit IEEE double into a 64-bit signed integer.\n** If the double is too large, return 0x8000000000000000.\n**\n** Most systems appear to do this simply by assigning\n** variables and without the extra range tests.  But\n** there are reports that windows throws an expection\n** if the floating point value is out of range. (See ticket #2880.)\n** Because we do not completely understand the problem, we will\n** take the conservative approach and always do range tests\n** before attempting the conversion.\n*/\nstatic i64 doubleToInt64(double r){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  /* When floating-point is omitted, double and int64 are the same thing */\n  return r;\n#else\n  /*\n  ** Many compilers we encounter do not define constants for the\n  ** minimum and maximum 64-bit integers, or they define them\n  ** inconsistently.  And many do not understand the \"LL\" notation.\n  ** So we define our own static constants here using nothing\n  ** larger than a 32-bit integer constant.\n  */\n  static const i64 maxInt = LARGEST_INT64;\n  static const i64 minInt = SMALLEST_INT64;\n\n  if( r<(double)minInt ){\n    return minInt;\n  }else if( r>(double)maxInt ){\n    /* minInt is correct here - not maxInt.  It turns out that assigning\n    ** a very large positive number to an integer results in a very large\n    ** negative integer.  This makes no sense, but it is what x86 hardware\n    ** does so for compatibility we will do the same in software. */\n    return minInt;\n  }else{\n    return (i64)r;\n  }\n#endif\n}\n\n/*\n** Return some kind of integer value which is the best we can do\n** at representing the value that *pMem describes as an integer.\n** If pMem is an integer, then the value is exact.  If pMem is\n** a floating-point then the value returned is the integer part.\n** If pMem is a string or blob, then we make an attempt to convert\n** it into a integer and return that.  If pMem represents an\n** an SQL-NULL value, return 0.\n**\n** If pMem represents a string value, its encoding might be changed.\n*/\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){\n  int flags;\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  flags = pMem->flags;\n  if( flags & MEM_Int ){\n    return pMem->u.i;\n  }else if( flags & MEM_Real ){\n    return doubleToInt64(pMem->r);\n  }else if( flags & (MEM_Str|MEM_Blob) ){\n    i64 value = 0;\n    assert( pMem->z || pMem->n==0 );\n    testcase( pMem->z==0 );\n    sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);\n    return value;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Return the best representation of pMem that we can get into a\n** double.  If pMem is already a double or an integer, return its\n** value.  If it is a string or blob, try to convert it to a double.\n** If it is a NULL, return 0.0.\n*/\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  if( pMem->flags & MEM_Real ){\n    return pMem->r;\n  }else if( pMem->flags & MEM_Int ){\n    return (double)pMem->u.i;\n  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    double val = (double)0;\n    sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);\n    return val;\n  }else{\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    return (double)0;\n  }\n}\n\n/*\n** The MEM structure is already a MEM_Real.  Try to also make it a\n** MEM_Int if we can.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){\n  assert( pMem->flags & MEM_Real );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.i = doubleToInt64(pMem->r);\n\n  /* Only mark the value as an integer if\n  **\n  **    (1) the round-trip conversion real->int->real is a no-op, and\n  **    (2) The integer is neither the largest nor the smallest\n  **        possible integer (ticket #3922)\n  **\n  ** The second and third terms in the following conditional enforces\n  ** the second condition under the assumption that addition overflow causes\n  ** values to wrap around.  On x86 hardware, the third term is always\n  ** true and could be omitted.  But we leave it in because other\n  ** architectures might behave differently.\n  */\n  if( pMem->r==(double)pMem->u.i\n   && pMem->u.i>SMALLEST_INT64\n#if defined(__i486__) || defined(__x86_64__)\n   && ALWAYS(pMem->u.i<LARGEST_INT64)\n#else\n   && pMem->u.i<LARGEST_INT64\n#endif\n  ){\n    pMem->flags |= MEM_Int;\n  }\n}\n\n/*\n** Convert pMem to type integer.  Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.i = sqlite3VdbeIntValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Int);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it is of type MEM_Real.\n** Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->r = sqlite3VdbeRealValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it has types MEM_Real or MEM_Int or both.\n** Invalidate any prior representations.\n**\n** Every effort is made to force the conversion, even if the input\n** is a string that does not look completely like a number.  Convert\n** as much of the string as we can and ignore the rest.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){\n  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){\n    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    if( 0==sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc) ){\n      MemSetTypeFlag(pMem, MEM_Int);\n    }else{\n      pMem->r = sqlite3VdbeRealValue(pMem);\n      MemSetTypeFlag(pMem, MEM_Real);\n      sqlite3VdbeIntegerAffinity(pMem);\n    }\n  }\n  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );\n  pMem->flags &= ~(MEM_Str|MEM_Blob);\n  return SQLITE_OK;\n}\n\n/*\n** Delete any previous value and set the value stored in *pMem to NULL.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){\n  if( pMem->flags & MEM_Frame ){\n    VdbeFrame *pFrame = pMem->u.pFrame;\n    pFrame->pParent = pFrame->v->pDelFrame;\n    pFrame->v->pDelFrame = pFrame;\n  }\n  if( pMem->flags & MEM_RowSet ){\n    sqlite3RowSetClear(pMem->u.pRowSet);\n  }\n  MemSetTypeFlag(pMem, MEM_Null);\n  pMem->type = SQLITE_NULL;\n}\n\n/*\n** Delete any previous value and set the value to be a BLOB of length\n** n containing all zeros.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Blob|MEM_Zero;\n  pMem->type = SQLITE_BLOB;\n  pMem->n = 0;\n  if( n<0 ) n = 0;\n  pMem->u.nZero = n;\n  pMem->enc = SQLITE_UTF8;\n\n#ifdef SQLITE_OMIT_INCRBLOB\n  sqlite3VdbeMemGrow(pMem, n, 0);\n  if( pMem->z ){\n    pMem->n = n;\n    memset(pMem->z, 0, n);\n  }\n#endif\n}\n\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type INTEGER.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){\n  sqlite3VdbeMemRelease(pMem);\n  pMem->u.i = val;\n  pMem->flags = MEM_Int;\n  pMem->type = SQLITE_INTEGER;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type REAL.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){\n  if( sqlite3IsNaN(val) ){\n    sqlite3VdbeMemSetNull(pMem);\n  }else{\n    sqlite3VdbeMemRelease(pMem);\n    pMem->r = val;\n    pMem->flags = MEM_Real;\n    pMem->type = SQLITE_FLOAT;\n  }\n}\n#endif\n\n/*\n** Delete any previous value and set the value of pMem to be an\n** empty boolean index.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){\n  sqlite3 *db = pMem->db;\n  assert( db!=0 );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  sqlite3VdbeMemRelease(pMem);\n  pMem->zMalloc = sqlite3DbMallocRaw(db, 64);\n  if( db->mallocFailed ){\n    pMem->flags = MEM_Null;\n  }else{\n    assert( pMem->zMalloc );\n    pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, \n                                       sqlite3DbMallocSize(db, pMem->zMalloc));\n    assert( pMem->u.pRowSet!=0 );\n    pMem->flags = MEM_RowSet;\n  }\n}\n\n/*\n** Return true if the Mem object contains a TEXT or BLOB that is\n** too large - whose size exceeds SQLITE_MAX_LENGTH.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){\n  assert( p->db!=0 );\n  if( p->flags & (MEM_Str|MEM_Blob) ){\n    int n = p->n;\n    if( p->flags & MEM_Zero ){\n      n += p->u.nZero;\n    }\n    return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  return 0; \n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This routine prepares a memory cell for modication by breaking\n** its link to a shallow copy and by marking any current shallow\n** copies of this cell as invalid.\n**\n** This is used for testing and debugging only - to make sure shallow\n** copies are not misused.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){\n  int i;\n  Mem *pX;\n  for(i=1, pX=&pVdbe->aMem[1]; i<=pVdbe->nMem; i++, pX++){\n    if( pX->pScopyFrom==pMem ){\n      pX->flags |= MEM_Invalid;\n      pX->pScopyFrom = 0;\n    }\n  }\n  pMem->pScopyFrom = 0;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** Size of struct Mem not including the Mem.zMalloc member.\n*/\n#define MEMCELLSIZE (size_t)(&(((Mem *)0)->zMalloc))\n\n/*\n** Make an shallow copy of pFrom into pTo.  Prior contents of\n** pTo are freed.  The pFrom->z field is not duplicated.  If\n** pFrom->z is used, then pTo->z points to the same thing as pFrom->z\n** and flags gets srcType (either MEM_Ephem or MEM_Static).\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  pTo->xDel = 0;\n  if( (pFrom->flags&MEM_Static)==0 ){\n    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);\n    assert( srcType==MEM_Ephem || srcType==MEM_Static );\n    pTo->flags |= srcType;\n  }\n}\n\n/*\n** Make a full copy of pFrom into pTo.  Prior contents of pTo are\n** freed before the copy is made.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){\n  int rc = SQLITE_OK;\n\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  pTo->flags &= ~MEM_Dyn;\n\n  if( pTo->flags&(MEM_Str|MEM_Blob) ){\n    if( 0==(pFrom->flags&MEM_Static) ){\n      pTo->flags |= MEM_Ephem;\n      rc = sqlite3VdbeMemMakeWriteable(pTo);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Transfer the contents of pFrom to pTo. Any existing value in pTo is\n** freed. If pFrom contains ephemeral data, a copy is made.\n**\n** pFrom contains an SQL NULL when this routine returns.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){\n  assert( pFrom->db==0 || sqlite3_mutex_held(pFrom->db->mutex) );\n  assert( pTo->db==0 || sqlite3_mutex_held(pTo->db->mutex) );\n  assert( pFrom->db==0 || pTo->db==0 || pFrom->db==pTo->db );\n\n  sqlite3VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, sizeof(Mem));\n  pFrom->flags = MEM_Null;\n  pFrom->xDel = 0;\n  pFrom->zMalloc = 0;\n}\n\n/*\n** Change the value of a Mem to be a string or a BLOB.\n**\n** The memory management strategy depends on the value of the xDel\n** parameter. If the value passed is SQLITE_TRANSIENT, then the \n** string is copied into a (possibly existing) buffer managed by the \n** Mem structure. Otherwise, any existing buffer is freed and the\n** pointer copied.\n**\n** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH\n** size limit) then no memory allocation occurs.  If the string can be\n** stored without allocating memory, then it is.  If a memory allocation\n** is required to store the string, then value of pMem is unchanged.  In\n** either case, SQLITE_TOOBIG is returned.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(\n  Mem *pMem,          /* Memory cell to set to string value */\n  const char *z,      /* String pointer */\n  int n,              /* Bytes in string, or negative */\n  u8 enc,             /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*) /* Destructor function */\n){\n  int nByte = n;      /* New value for pMem->n */\n  int iLimit;         /* Maximum allowed string or blob size */\n  u16 flags = 0;      /* New value for pMem->flags */\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n\n  /* If z is a NULL pointer, set pMem to contain an SQL NULL. */\n  if( !z ){\n    sqlite3VdbeMemSetNull(pMem);\n    return SQLITE_OK;\n  }\n\n  if( pMem->db ){\n    iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }else{\n    iLimit = SQLITE_MAX_LENGTH;\n  }\n  flags = (enc==0?MEM_Blob:MEM_Str);\n  if( nByte<0 ){\n    assert( enc!=0 );\n    if( enc==SQLITE_UTF8 ){\n      for(nByte=0; nByte<=iLimit && z[nByte]; nByte++){}\n    }else{\n      for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}\n    }\n    flags |= MEM_Term;\n  }\n\n  /* The following block sets the new values of Mem.z and Mem.xDel. It\n  ** also sets a flag in local variable \"flags\" to indicate the memory\n  ** management (one of MEM_Dyn or MEM_Static).\n  */\n  if( xDel==SQLITE_TRANSIENT ){\n    int nAlloc = nByte;\n    if( flags&MEM_Term ){\n      nAlloc += (enc==SQLITE_UTF8?1:2);\n    }\n    if( nByte>iLimit ){\n      return SQLITE_TOOBIG;\n    }\n    if( sqlite3VdbeMemGrow(pMem, nAlloc, 0) ){\n      return SQLITE_NOMEM;\n    }\n    memcpy(pMem->z, z, nAlloc);\n  }else if( xDel==SQLITE_DYNAMIC ){\n    sqlite3VdbeMemRelease(pMem);\n    pMem->zMalloc = pMem->z = (char *)z;\n    pMem->xDel = 0;\n  }else{\n    sqlite3VdbeMemRelease(pMem);\n    pMem->z = (char *)z;\n    pMem->xDel = xDel;\n    flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);\n  }\n\n  pMem->n = nByte;\n  pMem->flags = flags;\n  pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);\n  pMem->type = (enc==0 ? SQLITE_BLOB : SQLITE_TEXT);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){\n    return SQLITE_NOMEM;\n  }\n#endif\n\n  if( nByte>iLimit ){\n    return SQLITE_TOOBIG;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Compare the values contained by the two memory cells, returning\n** negative, zero or positive if pMem1 is less than, equal to, or greater\n** than pMem2. Sorting order is NULL's first, followed by numbers (integers\n** and reals) sorted numerically, followed by text ordered by the collating\n** sequence pColl and finally blob's ordered by memcmp().\n**\n** Two NULL values are considered equal by this function.\n*/\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){\n  int rc;\n  int f1, f2;\n  int combined_flags;\n\n  f1 = pMem1->flags;\n  f2 = pMem2->flags;\n  combined_flags = f1|f2;\n  assert( (combined_flags & MEM_RowSet)==0 );\n \n  /* If one value is NULL, it is less than the other. If both values\n  ** are NULL, return 0.\n  */\n  if( combined_flags&MEM_Null ){\n    return (f2&MEM_Null) - (f1&MEM_Null);\n  }\n\n  /* If one value is a number and the other is not, the number is less.\n  ** If both are numbers, compare as reals if one is a real, or as integers\n  ** if both values are integers.\n  */\n  if( combined_flags&(MEM_Int|MEM_Real) ){\n    if( !(f1&(MEM_Int|MEM_Real)) ){\n      return 1;\n    }\n    if( !(f2&(MEM_Int|MEM_Real)) ){\n      return -1;\n    }\n    if( (f1 & f2 & MEM_Int)==0 ){\n      double r1, r2;\n      if( (f1&MEM_Real)==0 ){\n        r1 = (double)pMem1->u.i;\n      }else{\n        r1 = pMem1->r;\n      }\n      if( (f2&MEM_Real)==0 ){\n        r2 = (double)pMem2->u.i;\n      }else{\n        r2 = pMem2->r;\n      }\n      if( r1<r2 ) return -1;\n      if( r1>r2 ) return 1;\n      return 0;\n    }else{\n      assert( f1&MEM_Int );\n      assert( f2&MEM_Int );\n      if( pMem1->u.i < pMem2->u.i ) return -1;\n      if( pMem1->u.i > pMem2->u.i ) return 1;\n      return 0;\n    }\n  }\n\n  /* If one value is a string and the other is a blob, the string is less.\n  ** If both are strings, compare using the collating functions.\n  */\n  if( combined_flags&MEM_Str ){\n    if( (f1 & MEM_Str)==0 ){\n      return 1;\n    }\n    if( (f2 & MEM_Str)==0 ){\n      return -1;\n    }\n\n    assert( pMem1->enc==pMem2->enc );\n    assert( pMem1->enc==SQLITE_UTF8 || \n            pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );\n\n    /* The collation sequence must be defined at this point, even if\n    ** the user deletes the collation sequence after the vdbe program is\n    ** compiled (this was not always the case).\n    */\n    assert( !pColl || pColl->xCmp );\n\n    if( pColl ){\n      if( pMem1->enc==pColl->enc ){\n        /* The strings are already in the correct encoding.  Call the\n        ** comparison function directly */\n        return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);\n      }else{\n        const void *v1, *v2;\n        int n1, n2;\n        Mem c1;\n        Mem c2;\n        memset(&c1, 0, sizeof(c1));\n        memset(&c2, 0, sizeof(c2));\n        sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);\n        sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);\n        v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);\n        n1 = v1==0 ? 0 : c1.n;\n        v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);\n        n2 = v2==0 ? 0 : c2.n;\n        rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);\n        sqlite3VdbeMemRelease(&c1);\n        sqlite3VdbeMemRelease(&c2);\n        return rc;\n      }\n    }\n    /* If a NULL pointer was passed as the collate function, fall through\n    ** to the blob case and use memcmp().  */\n  }\n \n  /* Both values must be blobs.  Compare using memcmp().  */\n  rc = memcmp(pMem1->z, pMem2->z, (pMem1->n>pMem2->n)?pMem2->n:pMem1->n);\n  if( rc==0 ){\n    rc = pMem1->n - pMem2->n;\n  }\n  return rc;\n}\n\n/*\n** Move data out of a btree key or data field and into a Mem structure.\n** The data or key is taken from the entry that pCur is currently pointing\n** to.  offset and amt determine what portion of the data or key to retrieve.\n** key is true to get the key or false to get data.  The result is written\n** into the pMem element.\n**\n** The pMem structure is assumed to be uninitialized.  Any prior content\n** is overwritten without being freed.\n**\n** If this routine fails for any reason (malloc returns NULL or unable\n** to read from the disk) then the pMem is left in an inconsistent state.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  int offset,       /* Offset from the start of data to return bytes from. */\n  int amt,          /* Number of bytes to return. */\n  int key,          /* If true, retrieve from the btree key, not data. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  char *zData;        /* Data from the btree layer */\n  int available = 0;  /* Number of bytes available on the local btree page */\n  int rc = SQLITE_OK; /* Return code */\n\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n\n  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() \n  ** that both the BtShared and database handle mutexes are held. */\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  if( key ){\n    zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);\n  }else{\n    zData = (char *)sqlite3BtreeDataFetch(pCur, &available);\n  }\n  assert( zData!=0 );\n\n  if( offset+amt<=available && (pMem->flags&MEM_Dyn)==0 ){\n    sqlite3VdbeMemRelease(pMem);\n    pMem->z = &zData[offset];\n    pMem->flags = MEM_Blob|MEM_Ephem;\n  }else if( SQLITE_OK==(rc = sqlite3VdbeMemGrow(pMem, amt+2, 0)) ){\n    pMem->flags = MEM_Blob|MEM_Dyn|MEM_Term;\n    pMem->enc = 0;\n    pMem->type = SQLITE_BLOB;\n    if( key ){\n      rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);\n    }else{\n      rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);\n    }\n    pMem->z[amt] = 0;\n    pMem->z[amt+1] = 0;\n    if( rc!=SQLITE_OK ){\n      sqlite3VdbeMemRelease(pMem);\n    }\n  }\n  pMem->n = amt;\n\n  return rc;\n}\n\n/* This function is only available internally, it is not part of the\n** external API. It works in a similar way to sqlite3_value_text(),\n** except the data returned is in the encoding specified by the second\n** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or\n** SQLITE_UTF8.\n**\n** (2006-02-16:)  The enc value can be or-ed with SQLITE_UTF16_ALIGNED.\n** If that is the case, then the result must be aligned on an even byte\n** boundary.\n*/\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){\n  if( !pVal ) return 0;\n\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( (pVal->flags & MEM_RowSet)==0 );\n\n  if( pVal->flags&MEM_Null ){\n    return 0;\n  }\n  assert( (MEM_Blob>>3) == MEM_Str );\n  pVal->flags |= (pVal->flags & MEM_Blob)>>3;\n  ExpandBlob(pVal);\n  if( pVal->flags&MEM_Str ){\n    sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);\n    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&SQLITE_PTR_TO_INT(pVal->z)) ){\n      assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );\n      if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){\n        return 0;\n      }\n    }\n    sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */\n  }else{\n    assert( (pVal->flags&MEM_Blob)==0 );\n    sqlite3VdbeMemStringify(pVal, enc);\n    assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );\n  }\n  assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0\n              || pVal->db->mallocFailed );\n  if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){\n    return pVal->z;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Create a new sqlite3_value object.\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){\n  Mem *p = sqlite3DbMallocZero(db, sizeof(*p));\n  if( p ){\n    p->flags = MEM_Null;\n    p->type = SQLITE_NULL;\n    p->db = db;\n  }\n  return p;\n}\n\n/*\n** Create a new sqlite3_value object, containing the value of pExpr.\n**\n** This only works for very simple expressions that consist of one constant\n** token (i.e. \"5\", \"5.1\", \"'a string'\"). If the expression can\n** be converted directly into a value, then the value is allocated and\n** a pointer written to *ppVal. The caller is responsible for deallocating\n** the value by passing it to sqlite3ValueFree() later on. If the expression\n** cannot be converted to a value, then *ppVal is set to NULL.\n*/\nSQLITE_PRIVATE int sqlite3ValueFromExpr(\n  sqlite3 *db,              /* The database connection */\n  Expr *pExpr,              /* The expression to evaluate */\n  u8 enc,                   /* Encoding to use */\n  u8 affinity,              /* Affinity to use */\n  sqlite3_value **ppVal     /* Write the new value here */\n){\n  int op;\n  char *zVal = 0;\n  sqlite3_value *pVal = 0;\n  int negInt = 1;\n  const char *zNeg = \"\";\n\n  if( !pExpr ){\n    *ppVal = 0;\n    return SQLITE_OK;\n  }\n  op = pExpr->op;\n\n  /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT3.\n  ** The ifdef here is to enable us to achieve 100% branch test coverage even\n  ** when SQLITE_ENABLE_STAT3 is omitted.\n  */\n#ifdef SQLITE_ENABLE_STAT3\n  if( op==TK_REGISTER ) op = pExpr->op2;\n#else\n  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;\n#endif\n\n  /* Handle negative integers in a single step.  This is needed in the\n  ** case when the value is -9223372036854775808.\n  */\n  if( op==TK_UMINUS\n   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){\n    pExpr = pExpr->pLeft;\n    op = pExpr->op;\n    negInt = -1;\n    zNeg = \"-\";\n  }\n\n  if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){\n    pVal = sqlite3ValueNew(db);\n    if( pVal==0 ) goto no_mem;\n    if( ExprHasProperty(pExpr, EP_IntValue) ){\n      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);\n    }else{\n      zVal = sqlite3MPrintf(db, \"%s%s\", zNeg, pExpr->u.zToken);\n      if( zVal==0 ) goto no_mem;\n      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);\n      if( op==TK_FLOAT ) pVal->type = SQLITE_FLOAT;\n    }\n    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){\n      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);\n    }else{\n      sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);\n    }\n    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;\n    if( enc!=SQLITE_UTF8 ){\n      sqlite3VdbeChangeEncoding(pVal, enc);\n    }\n  }else if( op==TK_UMINUS ) {\n    /* This branch happens for multiple negative signs.  Ex: -(-5) */\n    if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){\n      sqlite3VdbeMemNumerify(pVal);\n      if( pVal->u.i==SMALLEST_INT64 ){\n        pVal->flags &= MEM_Int;\n        pVal->flags |= MEM_Real;\n        pVal->r = (double)LARGEST_INT64;\n      }else{\n        pVal->u.i = -pVal->u.i;\n      }\n      pVal->r = -pVal->r;\n      sqlite3ValueApplyAffinity(pVal, affinity, enc);\n    }\n  }else if( op==TK_NULL ){\n    pVal = sqlite3ValueNew(db);\n    if( pVal==0 ) goto no_mem;\n  }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n  else if( op==TK_BLOB ){\n    int nVal;\n    assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n    assert( pExpr->u.zToken[1]=='\\'' );\n    pVal = sqlite3ValueNew(db);\n    if( !pVal ) goto no_mem;\n    zVal = &pExpr->u.zToken[2];\n    nVal = sqlite3Strlen30(zVal)-1;\n    assert( zVal[nVal]=='\\'' );\n    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,\n                         0, SQLITE_DYNAMIC);\n  }\n#endif\n\n  if( pVal ){\n    sqlite3VdbeMemStoreType(pVal);\n  }\n  *ppVal = pVal;\n  return SQLITE_OK;\n\nno_mem:\n  db->mallocFailed = 1;\n  sqlite3DbFree(db, zVal);\n  sqlite3ValueFree(pVal);\n  *ppVal = 0;\n  return SQLITE_NOMEM;\n}\n\n/*\n** Change the string value of an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueSetStr(\n  sqlite3_value *v,     /* Value to be set */\n  int n,                /* Length of string z */\n  const void *z,        /* Text of the new string */\n  u8 enc,               /* Encoding to use */\n  void (*xDel)(void*)   /* Destructor for the string */\n){\n  if( v ) sqlite3VdbeMemSetStr((Mem *)v, z, n, enc, xDel);\n}\n\n/*\n** Free an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){\n  if( !v ) return;\n  sqlite3VdbeMemRelease((Mem *)v);\n  sqlite3DbFree(((Mem*)v)->db, v);\n}\n\n/*\n** Return the number of bytes in the sqlite3_value object assuming\n** that it uses the encoding \"enc\"\n*/\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){\n  Mem *p = (Mem*)pVal;\n  if( (p->flags & MEM_Blob)!=0 || sqlite3ValueText(pVal, enc) ){\n    if( p->flags & MEM_Zero ){\n      return p->n + p->u.nZero;\n    }else{\n      return p->n;\n    }\n  }\n  return 0;\n}\n\n/************** End of vdbemem.c *********************************************/\n/************** Begin file vdbeaux.c *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used for creating, destroying, and populating\n** a VDBE (or an \"sqlite3_stmt\" as it is known to the outside world.)  Prior\n** to version 2.8.7, all this code was combined into the vdbe.c source file.\n** But that file was getting too big so this subroutines were split out.\n*/\n\n/*\n** Create a new virtual database engine.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(sqlite3 *db){\n  Vdbe *p;\n  p = sqlite3DbMallocZero(db, sizeof(Vdbe) );\n  if( p==0 ) return 0;\n  p->db = db;\n  if( db->pVdbe ){\n    db->pVdbe->pPrev = p;\n  }\n  p->pNext = db->pVdbe;\n  p->pPrev = 0;\n  db->pVdbe = p;\n  p->magic = VDBE_MAGIC_INIT;\n  return p;\n}\n\n/*\n** Remember the SQL string for a prepared statement.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){\n  assert( isPrepareV2==1 || isPrepareV2==0 );\n  if( p==0 ) return;\n#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)\n  if( !isPrepareV2 ) return;\n#endif\n  assert( p->zSql==0 );\n  p->zSql = sqlite3DbStrNDup(p->db, z, n);\n  p->isPrepareV2 = (u8)isPrepareV2;\n}\n\n/*\n** Return the SQL associated with a prepared statement\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe *)pStmt;\n  return (p && p->isPrepareV2) ? p->zSql : 0;\n}\n\n/*\n** Swap all content between two VDBE structures.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){\n  Vdbe tmp, *pTmp;\n  char *zTmp;\n  tmp = *pA;\n  *pA = *pB;\n  *pB = tmp;\n  pTmp = pA->pNext;\n  pA->pNext = pB->pNext;\n  pB->pNext = pTmp;\n  pTmp = pA->pPrev;\n  pA->pPrev = pB->pPrev;\n  pB->pPrev = pTmp;\n  zTmp = pA->zSql;\n  pA->zSql = pB->zSql;\n  pB->zSql = zTmp;\n  pB->isPrepareV2 = pA->isPrepareV2;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Turn tracing on or off\n*/\nSQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe *p, FILE *trace){\n  p->trace = trace;\n}\n#endif\n\n/*\n** Resize the Vdbe.aOp array so that it is at least one op larger than \n** it was.\n**\n** If an out-of-memory error occurs while resizing the array, return\n** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain \n** unchanged (this is so that any opcodes already allocated can be \n** correctly deallocated along with the rest of the Vdbe).\n*/\nstatic int growOpArray(Vdbe *p){\n  VdbeOp *pNew;\n  int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));\n  pNew = sqlite3DbRealloc(p->db, p->aOp, nNew*sizeof(Op));\n  if( pNew ){\n    p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op);\n    p->aOp = pNew;\n  }\n  return (pNew ? SQLITE_OK : SQLITE_NOMEM);\n}\n\n/*\n** Add a new instruction to the list of instructions current in the\n** VDBE.  Return the address of the new instruction.\n**\n** Parameters:\n**\n**    p               Pointer to the VDBE\n**\n**    op              The opcode for this instruction\n**\n**    p1, p2, p3      Operands\n**\n** Use the sqlite3VdbeResolveLabel() function to fix an address and\n** the sqlite3VdbeChangeP4() function to change the value of the P4\n** operand.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  int i;\n  VdbeOp *pOp;\n\n  i = p->nOp;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( op>0 && op<0xff );\n  if( p->nOpAlloc<=i ){\n    if( growOpArray(p) ){\n      return 1;\n    }\n  }\n  p->nOp++;\n  pOp = &p->aOp[i];\n  pOp->opcode = (u8)op;\n  pOp->p5 = 0;\n  pOp->p1 = p1;\n  pOp->p2 = p2;\n  pOp->p3 = p3;\n  pOp->p4.p = 0;\n  pOp->p4type = P4_NOTUSED;\n#ifdef SQLITE_DEBUG\n  pOp->zComment = 0;\n  if( p->db->flags & SQLITE_VdbeAddopTrace ){\n    sqlite3VdbePrintOp(0, i, &p->aOp[i]);\n  }\n#endif\n#ifdef VDBE_PROFILE\n  pOp->cycles = 0;\n  pOp->cnt = 0;\n#endif\n  return i;\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){\n  return sqlite3VdbeAddOp3(p, op, 0, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){\n  return sqlite3VdbeAddOp3(p, op, p1, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){\n  return sqlite3VdbeAddOp3(p, op, p1, p2, 0);\n}\n\n\n/*\n** Add an opcode that includes the p4 value as a pointer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const char *zP4,    /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  sqlite3VdbeChangeP4(p, addr, zP4, p4type);\n  return addr;\n}\n\n/*\n** Add an OP_ParseSchema opcode.  This routine is broken out from\n** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees\n** as having been used.\n**\n** The zWhere string must have been obtained from sqlite3_malloc().\n** This routine will take ownership of the allocated memory.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){\n  int j;\n  int addr = sqlite3VdbeAddOp3(p, OP_ParseSchema, iDb, 0, 0);\n  sqlite3VdbeChangeP4(p, addr, zWhere, P4_DYNAMIC);\n  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);\n}\n\n/*\n** Add an opcode that includes the p4 value as an integer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  int p4              /* The P4 operand as an integer */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  sqlite3VdbeChangeP4(p, addr, SQLITE_INT_TO_PTR(p4), P4_INT32);\n  return addr;\n}\n\n/*\n** Create a new symbolic label for an instruction that has yet to be\n** coded.  The symbolic label is really just a negative number.  The\n** label can be used as the P2 value of an operation.  Later, when\n** the label is resolved to a specific address, the VDBE will scan\n** through its operation list and change all values of P2 which match\n** the label into the resolved address.\n**\n** The VDBE knows that a P2 value is a label because labels are\n** always negative and P2 values are suppose to be non-negative.\n** Hence, a negative P2 value is a label that has yet to be resolved.\n**\n** Zero is returned if a malloc() fails.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe *p){\n  int i = p->nLabel++;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( (i & (i-1))==0 ){\n    p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel, \n                                       (i*2+1)*sizeof(p->aLabel[0]));\n  }\n  if( p->aLabel ){\n    p->aLabel[i] = -1;\n  }\n  return -1-i;\n}\n\n/*\n** Resolve label \"x\" to be the address of the next instruction to\n** be inserted.  The parameter \"x\" must have been obtained from\n** a prior call to sqlite3VdbeMakeLabel().\n*/\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){\n  int j = -1-x;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( j>=0 && j<p->nLabel );\n  if( p->aLabel ){\n    p->aLabel[j] = p->nOp;\n  }\n}\n\n/*\n** Mark the VDBE as one that can only be run one time.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){\n  p->runOnlyOnce = 1;\n}\n\n#ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */\n\n/*\n** The following type and function are used to iterate through all opcodes\n** in a Vdbe main program and each of the sub-programs (triggers) it may \n** invoke directly or indirectly. It should be used as follows:\n**\n**   Op *pOp;\n**   VdbeOpIter sIter;\n**\n**   memset(&sIter, 0, sizeof(sIter));\n**   sIter.v = v;                            // v is of type Vdbe* \n**   while( (pOp = opIterNext(&sIter)) ){\n**     // Do something with pOp\n**   }\n**   sqlite3DbFree(v->db, sIter.apSub);\n** \n*/\ntypedef struct VdbeOpIter VdbeOpIter;\nstruct VdbeOpIter {\n  Vdbe *v;                   /* Vdbe to iterate through the opcodes of */\n  SubProgram **apSub;        /* Array of subprograms */\n  int nSub;                  /* Number of entries in apSub */\n  int iAddr;                 /* Address of next instruction to return */\n  int iSub;                  /* 0 = main program, 1 = first sub-program etc. */\n};\nstatic Op *opIterNext(VdbeOpIter *p){\n  Vdbe *v = p->v;\n  Op *pRet = 0;\n  Op *aOp;\n  int nOp;\n\n  if( p->iSub<=p->nSub ){\n\n    if( p->iSub==0 ){\n      aOp = v->aOp;\n      nOp = v->nOp;\n    }else{\n      aOp = p->apSub[p->iSub-1]->aOp;\n      nOp = p->apSub[p->iSub-1]->nOp;\n    }\n    assert( p->iAddr<nOp );\n\n    pRet = &aOp[p->iAddr];\n    p->iAddr++;\n    if( p->iAddr==nOp ){\n      p->iSub++;\n      p->iAddr = 0;\n    }\n  \n    if( pRet->p4type==P4_SUBPROGRAM ){\n      int nByte = (p->nSub+1)*sizeof(SubProgram*);\n      int j;\n      for(j=0; j<p->nSub; j++){\n        if( p->apSub[j]==pRet->p4.pProgram ) break;\n      }\n      if( j==p->nSub ){\n        p->apSub = sqlite3DbReallocOrFree(v->db, p->apSub, nByte);\n        if( !p->apSub ){\n          pRet = 0;\n        }else{\n          p->apSub[p->nSub++] = pRet->p4.pProgram;\n        }\n      }\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Check if the program stored in the VM associated with pParse may\n** throw an ABORT exception (causing the statement, but not entire transaction\n** to be rolled back). This condition is true if the main program or any\n** sub-programs contains any of the following:\n**\n**   *  OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_Destroy\n**   *  OP_VUpdate\n**   *  OP_VRename\n**   *  OP_FkCounter with P2==0 (immediate foreign key constraint)\n**\n** Then check that the value of Parse.mayAbort is true if an\n** ABORT may be thrown, or false otherwise. Return true if it does\n** match, or false otherwise. This function is intended to be used as\n** part of an assert statement in the compiler. Similar to:\n**\n**   assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );\n*/\nSQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){\n  int hasAbort = 0;\n  Op *pOp;\n  VdbeOpIter sIter;\n  memset(&sIter, 0, sizeof(sIter));\n  sIter.v = v;\n\n  while( (pOp = opIterNext(&sIter))!=0 ){\n    int opcode = pOp->opcode;\n    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename \n#ifndef SQLITE_OMIT_FOREIGN_KEY\n     || (opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1) \n#endif\n     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) \n      && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))\n    ){\n      hasAbort = 1;\n      break;\n    }\n  }\n  sqlite3DbFree(v->db, sIter.apSub);\n\n  /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.\n  ** If malloc failed, then the while() loop above may not have iterated\n  ** through all opcodes and hasAbort may be set incorrectly. Return\n  ** true for this case to prevent the assert() in the callers frame\n  ** from failing.  */\n  return ( v->db->mallocFailed || hasAbort==mayAbort );\n}\n#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */\n\n/*\n** Loop through the program looking for P2 values that are negative\n** on jump instructions.  Each such value is a label.  Resolve the\n** label by setting the P2 value to its correct non-zero value.\n**\n** This routine is called once after all opcodes have been inserted.\n**\n** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument \n** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by \n** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array.\n**\n** The Op.opflags field is set on all opcodes.\n*/\nstatic void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){\n  int i;\n  int nMaxArgs = *pMaxFuncArgs;\n  Op *pOp;\n  int *aLabel = p->aLabel;\n  p->readOnly = 1;\n  for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){\n    u8 opcode = pOp->opcode;\n\n    pOp->opflags = sqlite3OpcodeProperty[opcode];\n    if( opcode==OP_Function || opcode==OP_AggStep ){\n      if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5;\n    }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){\n      p->readOnly = 0;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    }else if( opcode==OP_VUpdate ){\n      if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;\n    }else if( opcode==OP_VFilter ){\n      int n;\n      assert( p->nOp - i >= 3 );\n      assert( pOp[-1].opcode==OP_Integer );\n      n = pOp[-1].p1;\n      if( n>nMaxArgs ) nMaxArgs = n;\n#endif\n    }else if( opcode==OP_Next || opcode==OP_SorterNext ){\n      pOp->p4.xAdvance = sqlite3BtreeNext;\n      pOp->p4type = P4_ADVANCE;\n    }else if( opcode==OP_Prev ){\n      pOp->p4.xAdvance = sqlite3BtreePrevious;\n      pOp->p4type = P4_ADVANCE;\n    }\n\n    if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){\n      assert( -1-pOp->p2<p->nLabel );\n      pOp->p2 = aLabel[-1-pOp->p2];\n    }\n  }\n  sqlite3DbFree(p->db, p->aLabel);\n  p->aLabel = 0;\n\n  *pMaxFuncArgs = nMaxArgs;\n}\n\n/*\n** Return the address of the next instruction to be inserted.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){\n  assert( p->magic==VDBE_MAGIC_INIT );\n  return p->nOp;\n}\n\n/*\n** This function returns a pointer to the array of opcodes associated with\n** the Vdbe passed as the first argument. It is the callers responsibility\n** to arrange for the returned array to be eventually freed using the \n** vdbeFreeOpArray() function.\n**\n** Before returning, *pnOp is set to the number of entries in the returned\n** array. Also, *pnMaxArg is set to the larger of its current value and \n** the number of entries in the Vdbe.apArg[] array required to execute the \n** returned program.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){\n  VdbeOp *aOp = p->aOp;\n  assert( aOp && !p->db->mallocFailed );\n\n  /* Check that sqlite3VdbeUsesBtree() was not called on this VM */\n  assert( p->btreeMask==0 );\n\n  resolveP2Values(p, pnMaxArg);\n  *pnOp = p->nOp;\n  p->aOp = 0;\n  return aOp;\n}\n\n/*\n** Add a whole list of operations to the operation stack.  Return the\n** address of the first operation added.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp){\n  int addr;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( p->nOp + nOp > p->nOpAlloc && growOpArray(p) ){\n    return 0;\n  }\n  addr = p->nOp;\n  if( ALWAYS(nOp>0) ){\n    int i;\n    VdbeOpList const *pIn = aOp;\n    for(i=0; i<nOp; i++, pIn++){\n      int p2 = pIn->p2;\n      VdbeOp *pOut = &p->aOp[i+addr];\n      pOut->opcode = pIn->opcode;\n      pOut->p1 = pIn->p1;\n      if( p2<0 && (sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP)!=0 ){\n        pOut->p2 = addr + ADDR(p2);\n      }else{\n        pOut->p2 = p2;\n      }\n      pOut->p3 = pIn->p3;\n      pOut->p4type = P4_NOTUSED;\n      pOut->p4.p = 0;\n      pOut->p5 = 0;\n#ifdef SQLITE_DEBUG\n      pOut->zComment = 0;\n      if( p->db->flags & SQLITE_VdbeAddopTrace ){\n        sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]);\n      }\n#endif\n    }\n    p->nOp += nOp;\n  }\n  return addr;\n}\n\n/*\n** Change the value of the P1 operand for a specific instruction.\n** This routine is useful when a large program is loaded from a\n** static array using sqlite3VdbeAddOpList but we want to make a\n** few minor changes to the program.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){\n  assert( p!=0 );\n  if( ((u32)p->nOp)>addr ){\n    p->aOp[addr].p1 = val;\n  }\n}\n\n/*\n** Change the value of the P2 operand for a specific instruction.\n** This routine is useful for setting a jump destination.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){\n  assert( p!=0 );\n  if( ((u32)p->nOp)>addr ){\n    p->aOp[addr].p2 = val;\n  }\n}\n\n/*\n** Change the value of the P3 operand for a specific instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){\n  assert( p!=0 );\n  if( ((u32)p->nOp)>addr ){\n    p->aOp[addr].p3 = val;\n  }\n}\n\n/*\n** Change the value of the P5 operand for the most recently\n** added operation.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u8 val){\n  assert( p!=0 );\n  if( p->aOp ){\n    assert( p->nOp>0 );\n    p->aOp[p->nOp-1].p5 = val;\n  }\n}\n\n/*\n** Change the P2 operand of instruction addr so that it points to\n** the address of the next instruction to be coded.\n*/\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){\n  assert( addr>=0 || p->db->mallocFailed );\n  if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp);\n}\n\n\n/*\n** If the input FuncDef structure is ephemeral, then free it.  If\n** the FuncDef is not ephermal, then do nothing.\n*/\nstatic void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){\n  if( ALWAYS(pDef) && (pDef->flags & SQLITE_FUNC_EPHEM)!=0 ){\n    sqlite3DbFree(db, pDef);\n  }\n}\n\nstatic void vdbeFreeOpArray(sqlite3 *, Op *, int);\n\n/*\n** Delete a P4 value if necessary.\n*/\nstatic void freeP4(sqlite3 *db, int p4type, void *p4){\n  if( p4 ){\n    assert( db );\n    switch( p4type ){\n      case P4_REAL:\n      case P4_INT64:\n      case P4_DYNAMIC:\n      case P4_KEYINFO:\n      case P4_INTARRAY:\n      case P4_KEYINFO_HANDOFF: {\n        sqlite3DbFree(db, p4);\n        break;\n      }\n      case P4_MPRINTF: {\n        if( db->pnBytesFreed==0 ) sqlite3_free(p4);\n        break;\n      }\n      case P4_VDBEFUNC: {\n        VdbeFunc *pVdbeFunc = (VdbeFunc *)p4;\n        freeEphemeralFunction(db, pVdbeFunc->pFunc);\n        if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0);\n        sqlite3DbFree(db, pVdbeFunc);\n        break;\n      }\n      case P4_FUNCDEF: {\n        freeEphemeralFunction(db, (FuncDef*)p4);\n        break;\n      }\n      case P4_MEM: {\n        if( db->pnBytesFreed==0 ){\n          sqlite3ValueFree((sqlite3_value*)p4);\n        }else{\n          Mem *p = (Mem*)p4;\n          sqlite3DbFree(db, p->zMalloc);\n          sqlite3DbFree(db, p);\n        }\n        break;\n      }\n      case P4_VTAB : {\n        if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);\n        break;\n      }\n    }\n  }\n}\n\n/*\n** Free the space allocated for aOp and any p4 values allocated for the\n** opcodes contained within. If aOp is not NULL it is assumed to contain \n** nOp entries. \n*/\nstatic void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){\n  if( aOp ){\n    Op *pOp;\n    for(pOp=aOp; pOp<&aOp[nOp]; pOp++){\n      freeP4(db, pOp->p4type, pOp->p4.p);\n#ifdef SQLITE_DEBUG\n      sqlite3DbFree(db, pOp->zComment);\n#endif     \n    }\n  }\n  sqlite3DbFree(db, aOp);\n}\n\n/*\n** Link the SubProgram object passed as the second argument into the linked\n** list at Vdbe.pSubProgram. This list is used to delete all sub-program\n** objects when the VM is no longer required.\n*/\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){\n  p->pNext = pVdbe->pProgram;\n  pVdbe->pProgram = p;\n}\n\n/*\n** Change the opcode at addr into OP_Noop\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe *p, int addr){\n  if( p->aOp ){\n    VdbeOp *pOp = &p->aOp[addr];\n    sqlite3 *db = p->db;\n    freeP4(db, pOp->p4type, pOp->p4.p);\n    memset(pOp, 0, sizeof(pOp[0]));\n    pOp->opcode = OP_Noop;\n  }\n}\n\n/*\n** Change the value of the P4 operand for a specific instruction.\n** This routine is useful when a large program is loaded from a\n** static array using sqlite3VdbeAddOpList but we want to make a\n** few minor changes to the program.\n**\n** If n>=0 then the P4 operand is dynamic, meaning that a copy of\n** the string is made into memory obtained from sqlite3_malloc().\n** A value of n==0 means copy bytes of zP4 up to and including the\n** first null byte.  If n>0 then copy n+1 bytes of zP4.\n**\n** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure.\n** A copy is made of the KeyInfo structure into memory obtained from\n** sqlite3_malloc, to be freed when the Vdbe is finalized.\n** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure\n** stored in memory that the caller has obtained from sqlite3_malloc. The \n** caller should not free the allocation, it will be freed when the Vdbe is\n** finalized.\n** \n** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points\n** to a string or structure that is guaranteed to exist for the lifetime of\n** the Vdbe. In these cases we can just copy the pointer.\n**\n** If addr<0 then change P4 on the most recently inserted instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){\n  Op *pOp;\n  sqlite3 *db;\n  assert( p!=0 );\n  db = p->db;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( p->aOp==0 || db->mallocFailed ){\n    if ( n!=P4_KEYINFO && n!=P4_VTAB ) {\n      freeP4(db, n, (void*)*(char**)&zP4);\n    }\n    return;\n  }\n  assert( p->nOp>0 );\n  assert( addr<p->nOp );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  pOp = &p->aOp[addr];\n  assert( pOp->p4type==P4_NOTUSED || pOp->p4type==P4_INT32 );\n  freeP4(db, pOp->p4type, pOp->p4.p);\n  pOp->p4.p = 0;\n  if( n==P4_INT32 ){\n    /* Note: this cast is safe, because the origin data point was an int\n    ** that was cast to a (const char *). */\n    pOp->p4.i = SQLITE_PTR_TO_INT(zP4);\n    pOp->p4type = P4_INT32;\n  }else if( zP4==0 ){\n    pOp->p4.p = 0;\n    pOp->p4type = P4_NOTUSED;\n  }else if( n==P4_KEYINFO ){\n    KeyInfo *pKeyInfo;\n    int nField, nByte;\n\n    nField = ((KeyInfo*)zP4)->nField;\n    nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField;\n    pKeyInfo = sqlite3DbMallocRaw(0, nByte);\n    pOp->p4.pKeyInfo = pKeyInfo;\n    if( pKeyInfo ){\n      u8 *aSortOrder;\n      memcpy((char*)pKeyInfo, zP4, nByte - nField);\n      aSortOrder = pKeyInfo->aSortOrder;\n      assert( aSortOrder!=0 );\n      pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField];\n      memcpy(pKeyInfo->aSortOrder, aSortOrder, nField);\n      pOp->p4type = P4_KEYINFO;\n    }else{\n      p->db->mallocFailed = 1;\n      pOp->p4type = P4_NOTUSED;\n    }\n  }else if( n==P4_KEYINFO_HANDOFF ){\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = P4_KEYINFO;\n  }else if( n==P4_VTAB ){\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = P4_VTAB;\n    sqlite3VtabLock((VTable *)zP4);\n    assert( ((VTable *)zP4)->db==p->db );\n  }else if( n<0 ){\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = (signed char)n;\n  }else{\n    if( n==0 ) n = sqlite3Strlen30(zP4);\n    pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);\n    pOp->p4type = P4_DYNAMIC;\n  }\n}\n\n#ifndef NDEBUG\n/*\n** Change the comment on the most recently coded instruction.  Or\n** insert a No-op and add the comment to that new instruction.  This\n** makes the code easier to read during debugging.  None of this happens\n** in a production build.\n*/\nstatic void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){\n  assert( p->nOp>0 || p->aOp==0 );\n  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );\n  if( p->nOp ){\n    assert( p->aOp );\n    sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);\n    p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    sqlite3VdbeAddOp0(p, OP_Noop);\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\n#endif  /* NDEBUG */\n\n/*\n** Return the opcode for a given address.  If the address is -1, then\n** return the most recently inserted opcode.\n**\n** If a memory allocation error has occurred prior to the calling of this\n** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode\n** is readable but not writable, though it is cast to a writable value.\n** The return of a dummy opcode allows the call to continue functioning\n** after a OOM fault without having to check to see if the return from \n** this routine is a valid pointer.  But because the dummy.opcode is 0,\n** dummy will never be written to.  This is verified by code inspection and\n** by running with Valgrind.\n**\n** About the #ifdef SQLITE_OMIT_TRACE:  Normally, this routine is never called\n** unless p->nOp>0.  This is because in the absense of SQLITE_OMIT_TRACE,\n** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as\n** a new VDBE is created.  So we are free to set addr to p->nOp-1 without\n** having to double-check to make sure that the result is non-negative. But\n** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to\n** check the value of p->nOp-1 before continuing.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){\n  /* C89 specifies that the constant \"dummy\" will be initialized to all\n  ** zeros, which is correct.  MSVC generates a warning, nevertheless. */\n  static VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( addr<0 ){\n#ifdef SQLITE_OMIT_TRACE\n    if( p->nOp==0 ) return (VdbeOp*)&dummy;\n#endif\n    addr = p->nOp - 1;\n  }\n  assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );\n  if( p->db->mallocFailed ){\n    return (VdbeOp*)&dummy;\n  }else{\n    return &p->aOp[addr];\n  }\n}\n\n#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \\\n     || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n/*\n** Compute a string that describes the P4 parameter for an opcode.\n** Use zTemp for any required temporary buffer space.\n*/\nstatic char *displayP4(Op *pOp, char *zTemp, int nTemp){\n  char *zP4 = zTemp;\n  assert( nTemp>=20 );\n  switch( pOp->p4type ){\n    case P4_KEYINFO_STATIC:\n    case P4_KEYINFO: {\n      int i, j;\n      KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;\n      assert( pKeyInfo->aSortOrder!=0 );\n      sqlite3_snprintf(nTemp, zTemp, \"keyinfo(%d\", pKeyInfo->nField);\n      i = sqlite3Strlen30(zTemp);\n      for(j=0; j<pKeyInfo->nField; j++){\n        CollSeq *pColl = pKeyInfo->aColl[j];\n        const char *zColl = pColl ? pColl->zName : \"nil\";\n        int n = sqlite3Strlen30(zColl);\n        if( i+n>nTemp-6 ){\n          memcpy(&zTemp[i],\",...\",4);\n          break;\n        }\n        zTemp[i++] = ',';\n        if( pKeyInfo->aSortOrder[j] ){\n          zTemp[i++] = '-';\n        }\n        memcpy(&zTemp[i], zColl, n+1);\n        i += n;\n      }\n      zTemp[i++] = ')';\n      zTemp[i] = 0;\n      assert( i<nTemp );\n      break;\n    }\n    case P4_COLLSEQ: {\n      CollSeq *pColl = pOp->p4.pColl;\n      sqlite3_snprintf(nTemp, zTemp, \"collseq(%.20s)\", pColl->zName);\n      break;\n    }\n    case P4_FUNCDEF: {\n      FuncDef *pDef = pOp->p4.pFunc;\n      sqlite3_snprintf(nTemp, zTemp, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n    case P4_INT64: {\n      sqlite3_snprintf(nTemp, zTemp, \"%lld\", *pOp->p4.pI64);\n      break;\n    }\n    case P4_INT32: {\n      sqlite3_snprintf(nTemp, zTemp, \"%d\", pOp->p4.i);\n      break;\n    }\n    case P4_REAL: {\n      sqlite3_snprintf(nTemp, zTemp, \"%.16g\", *pOp->p4.pReal);\n      break;\n    }\n    case P4_MEM: {\n      Mem *pMem = pOp->p4.pMem;\n      if( pMem->flags & MEM_Str ){\n        zP4 = pMem->z;\n      }else if( pMem->flags & MEM_Int ){\n        sqlite3_snprintf(nTemp, zTemp, \"%lld\", pMem->u.i);\n      }else if( pMem->flags & MEM_Real ){\n        sqlite3_snprintf(nTemp, zTemp, \"%.16g\", pMem->r);\n      }else if( pMem->flags & MEM_Null ){\n        sqlite3_snprintf(nTemp, zTemp, \"NULL\");\n      }else{\n        assert( pMem->flags & MEM_Blob );\n        zP4 = \"(blob)\";\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case P4_VTAB: {\n      sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;\n      sqlite3_snprintf(nTemp, zTemp, \"vtab:%p:%p\", pVtab, pVtab->pModule);\n      break;\n    }\n#endif\n    case P4_INTARRAY: {\n      sqlite3_snprintf(nTemp, zTemp, \"intarray\");\n      break;\n    }\n    case P4_SUBPROGRAM: {\n      sqlite3_snprintf(nTemp, zTemp, \"program\");\n      break;\n    }\n    case P4_ADVANCE: {\n      zTemp[0] = 0;\n      break;\n    }\n    default: {\n      zP4 = pOp->p4.z;\n      if( zP4==0 ){\n        zP4 = zTemp;\n        zTemp[0] = 0;\n      }\n    }\n  }\n  assert( zP4!=0 );\n  return zP4;\n}\n#endif\n\n/*\n** Declare to the Vdbe that the BTree object at db->aDb[i] is used.\n**\n** The prepared statements need to know in advance the complete set of\n** attached databases that will be use.  A mask of these databases\n** is maintained in p->btreeMask.  The p->lockMask value is the subset of\n** p->btreeMask of databases that will require a lock.\n*/\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){\n  assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );\n  assert( i<(int)sizeof(p->btreeMask)*8 );\n  p->btreeMask |= ((yDbMask)1)<<i;\n  if( i!=1 && sqlite3BtreeSharable(p->db->aDb[i].pBt) ){\n    p->lockMask |= ((yDbMask)1)<<i;\n  }\n}\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n/*\n** If SQLite is compiled to support shared-cache mode and to be threadsafe,\n** this routine obtains the mutex associated with each BtShared structure\n** that may be accessed by the VM passed as an argument. In doing so it also\n** sets the BtShared.db member of each of the BtShared structures, ensuring\n** that the correct busy-handler callback is invoked if required.\n**\n** If SQLite is not threadsafe but does support shared-cache mode, then\n** sqlite3BtreeEnter() is invoked to set the BtShared.db variables\n** of all of BtShared structures accessible via the database handle \n** associated with the VM.\n**\n** If SQLite is not threadsafe and does not support shared-cache mode, this\n** function is a no-op.\n**\n** The p->btreeMask field is a bitmask of all btrees that the prepared \n** statement p will ever use.  Let N be the number of bits in p->btreeMask\n** corresponding to btrees that use shared cache.  Then the runtime of\n** this routine is N*N.  But as N is rarely more than 1, this should not\n** be a problem.\n*/\nSQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe *p){\n  int i;\n  yDbMask mask;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  if( p->lockMask==0 ) return;  /* The common case */\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0, mask=1; i<nDb; i++, mask += mask){\n    if( i!=1 && (mask & p->lockMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeEnter(aDb[i].pBt);\n    }\n  }\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n/*\n** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter().\n*/\nSQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe *p){\n  int i;\n  yDbMask mask;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  if( p->lockMask==0 ) return;  /* The common case */\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0, mask=1; i<nDb; i++, mask += mask){\n    if( i!=1 && (mask & p->lockMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeLeave(aDb[i].pBt);\n    }\n  }\n}\n#endif\n\n#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n/*\n** Print a single opcode.  This routine is used for debugging only.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){\n  char *zP4;\n  char zPtr[50];\n  static const char *zFormat1 = \"%4d %-13s %4d %4d %4d %-4s %.2X %s\\n\";\n  if( pOut==0 ) pOut = stdout;\n  zP4 = displayP4(pOp, zPtr, sizeof(zPtr));\n  fprintf(pOut, zFormat1, pc, \n      sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5,\n#ifdef SQLITE_DEBUG\n      pOp->zComment ? pOp->zComment : \"\"\n#else\n      \"\"\n#endif\n  );\n  fflush(pOut);\n}\n#endif\n\n/*\n** Release an array of N Mem elements\n*/\nstatic void releaseMemArray(Mem *p, int N){\n  if( p && N ){\n    Mem *pEnd;\n    sqlite3 *db = p->db;\n    u8 malloc_failed = db->mallocFailed;\n    if( db->pnBytesFreed ){\n      for(pEnd=&p[N]; p<pEnd; p++){\n        sqlite3DbFree(db, p->zMalloc);\n      }\n      return;\n    }\n    for(pEnd=&p[N]; p<pEnd; p++){\n      assert( (&p[1])==pEnd || p[0].db==p[1].db );\n\n      /* This block is really an inlined version of sqlite3VdbeMemRelease()\n      ** that takes advantage of the fact that the memory cell value is \n      ** being set to NULL after releasing any dynamic resources.\n      **\n      ** The justification for duplicating code is that according to \n      ** callgrind, this causes a certain test case to hit the CPU 4.7 \n      ** percent less (x86 linux, gcc version 4.1.2, -O6) than if \n      ** sqlite3MemRelease() were called from here. With -O2, this jumps\n      ** to 6.6 percent. The test case is inserting 1000 rows into a table \n      ** with no indexes using a single prepared INSERT statement, bind() \n      ** and reset(). Inserts are grouped into a transaction.\n      */\n      if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){\n        sqlite3VdbeMemRelease(p);\n      }else if( p->zMalloc ){\n        sqlite3DbFree(db, p->zMalloc);\n        p->zMalloc = 0;\n      }\n\n      p->flags = MEM_Invalid;\n    }\n    db->mallocFailed = malloc_failed;\n  }\n}\n\n/*\n** Delete a VdbeFrame object and its contents. VdbeFrame objects are\n** allocated by the OP_Program opcode in sqlite3VdbeExec().\n*/\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){\n  int i;\n  Mem *aMem = VdbeFrameMem(p);\n  VdbeCursor **apCsr = (VdbeCursor **)&aMem[p->nChildMem];\n  for(i=0; i<p->nChildCsr; i++){\n    sqlite3VdbeFreeCursor(p->v, apCsr[i]);\n  }\n  releaseMemArray(aMem, p->nChildMem);\n  sqlite3DbFree(p->v->db, p);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Give a listing of the program in the virtual machine.\n**\n** The interface is the same as sqlite3VdbeExec().  But instead of\n** running the code, it invokes the callback once for each instruction.\n** This feature is used to implement \"EXPLAIN\".\n**\n** When p->explain==1, each instruction is listed.  When\n** p->explain==2, only OP_Explain instructions are listed and these\n** are shown in a different format.  p->explain==2 is used to implement\n** EXPLAIN QUERY PLAN.\n**\n** When p->explain==1, first the main program is listed, then each of\n** the trigger subprograms are listed one by one.\n*/\nSQLITE_PRIVATE int sqlite3VdbeList(\n  Vdbe *p                   /* The VDBE */\n){\n  int nRow;                            /* Stop when row count reaches this */\n  int nSub = 0;                        /* Number of sub-vdbes seen so far */\n  SubProgram **apSub = 0;              /* Array of sub-vdbes */\n  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */\n  sqlite3 *db = p->db;                 /* The database connection */\n  int i;                               /* Loop counter */\n  int rc = SQLITE_OK;                  /* Return code */\n  Mem *pMem = &p->aMem[1];             /* First Mem of result set */\n\n  assert( p->explain );\n  assert( p->magic==VDBE_MAGIC_RUN );\n  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );\n\n  /* Even though this opcode does not use dynamic strings for\n  ** the result, result columns may become dynamic if the user calls\n  ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.\n  */\n  releaseMemArray(pMem, 8);\n  p->pResultSet = 0;\n\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    db->mallocFailed = 1;\n    return SQLITE_ERROR;\n  }\n\n  /* When the number of output rows reaches nRow, that means the\n  ** listing has finished and sqlite3_step() should return SQLITE_DONE.\n  ** nRow is the sum of the number of rows in the main program, plus\n  ** the sum of the number of rows in all trigger subprograms encountered\n  ** so far.  The nRow value will increase as new trigger subprograms are\n  ** encountered, but p->pc will eventually catch up to nRow.\n  */\n  nRow = p->nOp;\n  if( p->explain==1 ){\n    /* The first 8 memory cells are used for the result set.  So we will\n    ** commandeer the 9th cell to use as storage for an array of pointers\n    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9\n    ** cells.  */\n    assert( p->nMem>9 );\n    pSub = &p->aMem[9];\n    if( pSub->flags&MEM_Blob ){\n      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is\n      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */\n      nSub = pSub->n/sizeof(Vdbe*);\n      apSub = (SubProgram **)pSub->z;\n    }\n    for(i=0; i<nSub; i++){\n      nRow += apSub[i]->nOp;\n    }\n  }\n\n  do{\n    i = p->pc++;\n  }while( i<nRow && p->explain==2 && p->aOp[i].opcode!=OP_Explain );\n  if( i>=nRow ){\n    p->rc = SQLITE_OK;\n    rc = SQLITE_DONE;\n  }else if( db->u1.isInterrupted ){\n    p->rc = SQLITE_INTERRUPT;\n    rc = SQLITE_ERROR;\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3ErrStr(p->rc));\n  }else{\n    char *z;\n    Op *pOp;\n    if( i<p->nOp ){\n      /* The output line number is small enough that we are still in the\n      ** main program. */\n      pOp = &p->aOp[i];\n    }else{\n      /* We are currently listing subprograms.  Figure out which one and\n      ** pick up the appropriate opcode. */\n      int j;\n      i -= p->nOp;\n      for(j=0; i>=apSub[j]->nOp; j++){\n        i -= apSub[j]->nOp;\n      }\n      pOp = &apSub[j]->aOp[i];\n    }\n    if( p->explain==1 ){\n      pMem->flags = MEM_Int;\n      pMem->type = SQLITE_INTEGER;\n      pMem->u.i = i;                                /* Program counter */\n      pMem++;\n  \n      pMem->flags = MEM_Static|MEM_Str|MEM_Term;\n      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode);  /* Opcode */\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->type = SQLITE_TEXT;\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n\n      /* When an OP_Program opcode is encounter (the only opcode that has\n      ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms\n      ** kept in p->aMem[9].z to hold the new program - assuming this subprogram\n      ** has not already been seen.\n      */\n      if( pOp->p4type==P4_SUBPROGRAM ){\n        int nByte = (nSub+1)*sizeof(SubProgram*);\n        int j;\n        for(j=0; j<nSub; j++){\n          if( apSub[j]==pOp->p4.pProgram ) break;\n        }\n        if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){\n          apSub = (SubProgram **)pSub->z;\n          apSub[nSub++] = pOp->p4.pProgram;\n          pSub->flags |= MEM_Blob;\n          pSub->n = nSub*sizeof(SubProgram*);\n        }\n      }\n    }\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p1;                          /* P1 */\n    pMem->type = SQLITE_INTEGER;\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p2;                          /* P2 */\n    pMem->type = SQLITE_INTEGER;\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p3;                          /* P3 */\n    pMem->type = SQLITE_INTEGER;\n    pMem++;\n\n    if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */\n      assert( p->db->mallocFailed );\n      return SQLITE_ERROR;\n    }\n    pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;\n    z = displayP4(pOp, pMem->z, 32);\n    if( z!=pMem->z ){\n      sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);\n    }else{\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->enc = SQLITE_UTF8;\n    }\n    pMem->type = SQLITE_TEXT;\n    pMem++;\n\n    if( p->explain==1 ){\n      if( sqlite3VdbeMemGrow(pMem, 4, 0) ){\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;\n      pMem->n = 2;\n      sqlite3_snprintf(3, pMem->z, \"%.2x\", pOp->p5);   /* P5 */\n      pMem->type = SQLITE_TEXT;\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n  \n#ifdef SQLITE_DEBUG\n      if( pOp->zComment ){\n        pMem->flags = MEM_Str|MEM_Term;\n        pMem->z = pOp->zComment;\n        pMem->n = sqlite3Strlen30(pMem->z);\n        pMem->enc = SQLITE_UTF8;\n        pMem->type = SQLITE_TEXT;\n      }else\n#endif\n      {\n        pMem->flags = MEM_Null;                       /* Comment */\n        pMem->type = SQLITE_NULL;\n      }\n    }\n\n    p->nResColumn = 8 - 4*(p->explain-1);\n    p->pResultSet = &p->aMem[1];\n    p->rc = SQLITE_OK;\n    rc = SQLITE_ROW;\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the SQL that was used to generate a VDBE program.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){\n  int nOp = p->nOp;\n  VdbeOp *pOp;\n  if( nOp<1 ) return;\n  pOp = &p->aOp[0];\n  if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){\n    const char *z = pOp->p4.z;\n    while( sqlite3Isspace(*z) ) z++;\n    printf(\"SQL: [%s]\\n\", z);\n  }\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** Print an IOTRACE message showing SQL content.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe *p){\n  int nOp = p->nOp;\n  VdbeOp *pOp;\n  if( sqlite3IoTrace==0 ) return;\n  if( nOp<1 ) return;\n  pOp = &p->aOp[0];\n  if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){\n    int i, j;\n    char z[1000];\n    sqlite3_snprintf(sizeof(z), z, \"%s\", pOp->p4.z);\n    for(i=0; sqlite3Isspace(z[i]); i++){}\n    for(j=0; z[i]; i++){\n      if( sqlite3Isspace(z[i]) ){\n        if( z[i-1]!=' ' ){\n          z[j++] = ' ';\n        }\n      }else{\n        z[j++] = z[i];\n      }\n    }\n    z[j] = 0;\n    sqlite3IoTrace(\"SQL %s\\n\", z);\n  }\n}\n#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */\n\n/*\n** Allocate space from a fixed size buffer and return a pointer to\n** that space.  If insufficient space is available, return NULL.\n**\n** The pBuf parameter is the initial value of a pointer which will\n** receive the new memory.  pBuf is normally NULL.  If pBuf is not\n** NULL, it means that memory space has already been allocated and that\n** this routine should not allocate any new memory.  When pBuf is not\n** NULL simply return pBuf.  Only allocate new memory space when pBuf\n** is NULL.\n**\n** nByte is the number of bytes of space needed.\n**\n** *ppFrom points to available space and pEnd points to the end of the\n** available space.  When space is allocated, *ppFrom is advanced past\n** the end of the allocated space.\n**\n** *pnByte is a counter of the number of bytes of space that have failed\n** to allocate.  If there is insufficient space in *ppFrom to satisfy the\n** request, then increment *pnByte by the amount of the request.\n*/\nstatic void *allocSpace(\n  void *pBuf,          /* Where return pointer will be stored */\n  int nByte,           /* Number of bytes to allocate */\n  u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */\n  u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */\n  int *pnByte          /* If allocation cannot be made, increment *pnByte */\n){\n  assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );\n  if( pBuf ) return pBuf;\n  nByte = ROUND8(nByte);\n  if( &(*ppFrom)[nByte] <= pEnd ){\n    pBuf = (void*)*ppFrom;\n    *ppFrom += nByte;\n  }else{\n    *pnByte += nByte;\n  }\n  return pBuf;\n}\n\n/*\n** Rewind the VDBE back to the beginning in preparation for\n** running it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n  assert( p!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n\n  /* There should be at least one opcode.\n  */\n  assert( p->nOp>0 );\n\n  /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */\n  p->magic = VDBE_MAGIC_RUN;\n\n#ifdef SQLITE_DEBUG\n  for(i=1; i<p->nMem; i++){\n    assert( p->aMem[i].db==p->db );\n  }\n#endif\n  p->pc = -1;\n  p->rc = SQLITE_OK;\n  p->errorAction = OE_Abort;\n  p->magic = VDBE_MAGIC_RUN;\n  p->nChange = 0;\n  p->cacheCtr = 1;\n  p->minWriteFileFormat = 255;\n  p->iStatement = 0;\n  p->nFkConstraint = 0;\n#ifdef VDBE_PROFILE\n  for(i=0; i<p->nOp; i++){\n    p->aOp[i].cnt = 0;\n    p->aOp[i].cycles = 0;\n  }\n#endif\n}\n\n/*\n** Prepare a virtual machine for execution for the first time after\n** creating the virtual machine.  This involves things such\n** as allocating stack space and initializing the program counter.\n** After the VDBE has be prepped, it can be executed by one or more\n** calls to sqlite3VdbeExec().  \n**\n** This function may be called exact once on a each virtual machine.\n** After this routine is called the VM has been \"packaged\" and is ready\n** to run.  After this routine is called, futher calls to \n** sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects\n** the Vdbe from the Parse object that helped generate it so that the\n** the Vdbe becomes an independent entity and the Parse object can be\n** destroyed.\n**\n** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back\n** to its initial state after it has been run.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(\n  Vdbe *p,                       /* The VDBE */\n  Parse *pParse                  /* Parsing context */\n){\n  sqlite3 *db;                   /* The database connection */\n  int nVar;                      /* Number of parameters */\n  int nMem;                      /* Number of VM memory registers */\n  int nCursor;                   /* Number of cursors required */\n  int nArg;                      /* Number of arguments in subprograms */\n  int nOnce;                     /* Number of OP_Once instructions */\n  int n;                         /* Loop counter */\n  u8 *zCsr;                      /* Memory available for allocation */\n  u8 *zEnd;                      /* First byte past allocated memory */\n  int nByte;                     /* How much extra memory is needed */\n\n  assert( p!=0 );\n  assert( p->nOp>0 );\n  assert( pParse!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  db = p->db;\n  assert( db->mallocFailed==0 );\n  nVar = pParse->nVar;\n  nMem = pParse->nMem;\n  nCursor = pParse->nTab;\n  nArg = pParse->nMaxArg;\n  nOnce = pParse->nOnce;\n  if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */\n  \n  /* For each cursor required, also allocate a memory cell. Memory\n  ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by\n  ** the vdbe program. Instead they are used to allocate space for\n  ** VdbeCursor/BtCursor structures. The blob of memory associated with \n  ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1)\n  ** stores the blob of memory associated with cursor 1, etc.\n  **\n  ** See also: allocateCursor().\n  */\n  nMem += nCursor;\n\n  /* Allocate space for memory registers, SQL variables, VDBE cursors and \n  ** an array to marshal SQL function arguments in.\n  */\n  zCsr = (u8*)&p->aOp[p->nOp];       /* Memory avaliable for allocation */\n  zEnd = (u8*)&p->aOp[p->nOpAlloc];  /* First byte past end of zCsr[] */\n\n  resolveP2Values(p, &nArg);\n  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);\n  if( pParse->explain && nMem<10 ){\n    nMem = 10;\n  }\n  memset(zCsr, 0, zEnd-zCsr);\n  zCsr += (zCsr - (u8*)0)&7;\n  assert( EIGHT_BYTE_ALIGNMENT(zCsr) );\n  p->expired = 0;\n\n  /* Memory for registers, parameters, cursor, etc, is allocated in two\n  ** passes.  On the first pass, we try to reuse unused space at the \n  ** end of the opcode array.  If we are unable to satisfy all memory\n  ** requirements by reusing the opcode array tail, then the second\n  ** pass will fill in the rest using a fresh allocation.  \n  **\n  ** This two-pass approach that reuses as much memory as possible from\n  ** the leftover space at the end of the opcode array can significantly\n  ** reduce the amount of memory held by a prepared statement.\n  */\n  do {\n    nByte = 0;\n    p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);\n    p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);\n    p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);\n    p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);\n    p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),\n                          &zCsr, zEnd, &nByte);\n    p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte);\n    if( nByte ){\n      p->pFree = sqlite3DbMallocZero(db, nByte);\n    }\n    zCsr = p->pFree;\n    zEnd = &zCsr[nByte];\n  }while( nByte && !db->mallocFailed );\n\n  p->nCursor = nCursor;\n  p->nOnceFlag = nOnce;\n  if( p->aVar ){\n    p->nVar = (ynVar)nVar;\n    for(n=0; n<nVar; n++){\n      p->aVar[n].flags = MEM_Null;\n      p->aVar[n].db = db;\n    }\n  }\n  if( p->azVar ){\n    p->nzVar = pParse->nzVar;\n    memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0]));\n    memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0]));\n  }\n  if( p->aMem ){\n    p->aMem--;                      /* aMem[] goes from 1..nMem */\n    p->nMem = nMem;                 /*       not from 0..nMem-1 */\n    for(n=1; n<=nMem; n++){\n      p->aMem[n].flags = MEM_Invalid;\n      p->aMem[n].db = db;\n    }\n  }\n  p->explain = pParse->explain;\n  sqlite3VdbeRewind(p);\n}\n\n/*\n** Close a VDBE cursor and release all the resources that cursor \n** happens to hold.\n*/\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){\n  if( pCx==0 ){\n    return;\n  }\n  sqlite3VdbeSorterClose(p->db, pCx);\n  if( pCx->pBt ){\n    sqlite3BtreeClose(pCx->pBt);\n    /* The pCx->pCursor will be close automatically, if it exists, by\n    ** the call above. */\n  }else if( pCx->pCursor ){\n    sqlite3BtreeCloseCursor(pCx->pCursor);\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pCx->pVtabCursor ){\n    sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;\n    const sqlite3_module *pModule = pCx->pModule;\n    p->inVtabMethod = 1;\n    pModule->xClose(pVtabCursor);\n    p->inVtabMethod = 0;\n  }\n#endif\n}\n\n/*\n** Copy the values stored in the VdbeFrame structure to its Vdbe. This\n** is used, for example, when a trigger sub-program is halted to restore\n** control to the main program.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){\n  Vdbe *v = pFrame->v;\n  v->aOnceFlag = pFrame->aOnceFlag;\n  v->nOnceFlag = pFrame->nOnceFlag;\n  v->aOp = pFrame->aOp;\n  v->nOp = pFrame->nOp;\n  v->aMem = pFrame->aMem;\n  v->nMem = pFrame->nMem;\n  v->apCsr = pFrame->apCsr;\n  v->nCursor = pFrame->nCursor;\n  v->db->lastRowid = pFrame->lastRowid;\n  v->nChange = pFrame->nChange;\n  return pFrame->pc;\n}\n\n/*\n** Close all cursors.\n**\n** Also release any dynamic memory held by the VM in the Vdbe.aMem memory \n** cell array. This is necessary as the memory cell array may contain\n** pointers to VdbeFrame objects, which may in turn contain pointers to\n** open cursors.\n*/\nstatic void closeAllCursors(Vdbe *p){\n  if( p->pFrame ){\n    VdbeFrame *pFrame;\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    sqlite3VdbeFrameRestore(pFrame);\n  }\n  p->pFrame = 0;\n  p->nFrame = 0;\n\n  if( p->apCsr ){\n    int i;\n    for(i=0; i<p->nCursor; i++){\n      VdbeCursor *pC = p->apCsr[i];\n      if( pC ){\n        sqlite3VdbeFreeCursor(p, pC);\n        p->apCsr[i] = 0;\n      }\n    }\n  }\n  if( p->aMem ){\n    releaseMemArray(&p->aMem[1], p->nMem);\n  }\n  while( p->pDelFrame ){\n    VdbeFrame *pDel = p->pDelFrame;\n    p->pDelFrame = pDel->pParent;\n    sqlite3VdbeFrameDelete(pDel);\n  }\n}\n\n/*\n** Clean up the VM after execution.\n**\n** This routine will automatically close any cursors, lists, and/or\n** sorters that were left open.  It also deletes the values of\n** variables in the aVar[] array.\n*/\nstatic void Cleanup(Vdbe *p){\n  sqlite3 *db = p->db;\n\n#ifdef SQLITE_DEBUG\n  /* Execute assert() statements to ensure that the Vdbe.apCsr[] and \n  ** Vdbe.aMem[] arrays have already been cleaned up.  */\n  int i;\n  if( p->apCsr ) for(i=0; i<p->nCursor; i++) assert( p->apCsr[i]==0 );\n  if( p->aMem ){\n    for(i=1; i<=p->nMem; i++) assert( p->aMem[i].flags==MEM_Invalid );\n  }\n#endif\n\n  sqlite3DbFree(db, p->zErrMsg);\n  p->zErrMsg = 0;\n  p->pResultSet = 0;\n}\n\n/*\n** Set the number of result columns that will be returned by this SQL\n** statement. This is now set at compile time, rather than during\n** execution of the vdbe program so that sqlite3_column_count() can\n** be called on an SQL statement before sqlite3_step().\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){\n  Mem *pColName;\n  int n;\n  sqlite3 *db = p->db;\n\n  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n  sqlite3DbFree(db, p->aColName);\n  n = nResColumn*COLNAME_N;\n  p->nResColumn = (u16)nResColumn;\n  p->aColName = pColName = (Mem*)sqlite3DbMallocZero(db, sizeof(Mem)*n );\n  if( p->aColName==0 ) return;\n  while( n-- > 0 ){\n    pColName->flags = MEM_Null;\n    pColName->db = p->db;\n    pColName++;\n  }\n}\n\n/*\n** Set the name of the idx'th column to be returned by the SQL statement.\n** zName must be a pointer to a nul terminated string.\n**\n** This call must be made after a call to sqlite3VdbeSetNumCols().\n**\n** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC\n** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed\n** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSetColName(\n  Vdbe *p,                         /* Vdbe being configured */\n  int idx,                         /* Index of column zName applies to */\n  int var,                         /* One of the COLNAME_* constants */\n  const char *zName,               /* Pointer to buffer containing name */\n  void (*xDel)(void*)              /* Memory management strategy for zName */\n){\n  int rc;\n  Mem *pColName;\n  assert( idx<p->nResColumn );\n  assert( var<COLNAME_N );\n  if( p->db->mallocFailed ){\n    assert( !zName || xDel!=SQLITE_DYNAMIC );\n    return SQLITE_NOMEM;\n  }\n  assert( p->aColName!=0 );\n  pColName = &(p->aColName[idx+var*p->nResColumn]);\n  rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel);\n  assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 );\n  return rc;\n}\n\n/*\n** A read or write transaction may or may not be active on database handle\n** db. If a transaction is active, commit it. If there is a\n** write-transaction spanning more than one database file, this routine\n** takes care of the master journal trickery.\n*/\nstatic int vdbeCommit(sqlite3 *db, Vdbe *p){\n  int i;\n  int nTrans = 0;  /* Number of databases with an active write-transaction */\n  int rc = SQLITE_OK;\n  int needXcommit = 0;\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  /* With this option, sqlite3VtabSync() is defined to be simply \n  ** SQLITE_OK so p is not used. \n  */\n  UNUSED_PARAMETER(p);\n#endif\n\n  /* Before doing anything else, call the xSync() callback for any\n  ** virtual module tables written in this transaction. This has to\n  ** be done before determining whether a master journal file is \n  ** required, as an xSync() callback may add an attached database\n  ** to the transaction.\n  */\n  rc = sqlite3VtabSync(db, &p->zErrMsg);\n\n  /* This loop determines (a) if the commit hook should be invoked and\n  ** (b) how many database files have open write transactions, not \n  ** including the temp database. (b) is important because if more than \n  ** one database file has an open write transaction, a master journal\n  ** file is required for an atomic commit.\n  */ \n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n    Btree *pBt = db->aDb[i].pBt;\n    if( sqlite3BtreeIsInTrans(pBt) ){\n      needXcommit = 1;\n      if( i!=1 ) nTrans++;\n      sqlite3BtreeEnter(pBt);\n      rc = sqlite3PagerExclusiveLock(sqlite3BtreePager(pBt));\n      sqlite3BtreeLeave(pBt);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* If there are any write-transactions at all, invoke the commit hook */\n  if( needXcommit && db->xCommitCallback ){\n    rc = db->xCommitCallback(db->pCommitArg);\n    if( rc ){\n      return SQLITE_CONSTRAINT_COMMITHOOK;\n    }\n  }\n\n  /* The simple case - no more than one database file (not counting the\n  ** TEMP database) has a transaction active.   There is no need for the\n  ** master-journal.\n  **\n  ** If the return value of sqlite3BtreeGetFilename() is a zero length\n  ** string, it means the main database is :memory: or a temp file.  In \n  ** that case we do not support atomic multi-file commits, so use the \n  ** simple case then too.\n  */\n  if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))\n   || nTrans<=1\n  ){\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, 0);\n      }\n    }\n\n    /* Do the commit only if all databases successfully complete phase 1. \n    ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an\n    ** IO error while deleting or truncating a journal file. It is unlikely,\n    ** but could happen. In this case abandon processing and return the error.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3VtabCommit(db);\n    }\n  }\n\n  /* The complex case - There is a multi-file write-transaction active.\n  ** This requires a master journal file to ensure the transaction is\n  ** committed atomicly.\n  */\n#ifndef SQLITE_OMIT_DISKIO\n  else{\n    sqlite3_vfs *pVfs = db->pVfs;\n    int needSync = 0;\n    char *zMaster = 0;   /* File-name for the master journal */\n    char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);\n    sqlite3_file *pMaster = 0;\n    i64 offset = 0;\n    int res;\n    int retryCount = 0;\n    int nMainFile;\n\n    /* Select a master journal file name */\n    nMainFile = sqlite3Strlen30(zMainFile);\n    zMaster = sqlite3MPrintf(db, \"%s-mjXXXXXX9XXz\", zMainFile);\n    if( zMaster==0 ) return SQLITE_NOMEM;\n    do {\n      u32 iRandom;\n      if( retryCount ){\n        if( retryCount>100 ){\n          sqlite3_log(SQLITE_FULL, \"MJ delete: %s\", zMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          break;\n        }else if( retryCount==1 ){\n          sqlite3_log(SQLITE_FULL, \"MJ collide: %s\", zMaster);\n        }\n      }\n      retryCount++;\n      sqlite3_randomness(sizeof(iRandom), &iRandom);\n      sqlite3_snprintf(13, &zMaster[nMainFile], \"-mj%06X9%02X\",\n                               (iRandom>>8)&0xffffff, iRandom&0xff);\n      /* The antipenultimate character of the master journal name must\n      ** be \"9\" to avoid name collisions when using 8+3 filenames. */\n      assert( zMaster[sqlite3Strlen30(zMaster)-3]=='9' );\n      sqlite3FileSuffix3(zMainFile, zMaster);\n      rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n    }while( rc==SQLITE_OK && res );\n    if( rc==SQLITE_OK ){\n      /* Open the master journal. */\n      rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, \n          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|\n          SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0\n      );\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n \n    /* Write the name of each database file in the transaction into the new\n    ** master journal file. If an error occurs at this point close\n    ** and delete the master journal file. All the individual journal files\n    ** still have 'null' as the master journal pointer, so they will roll\n    ** back independently if a failure occurs.\n    */\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( sqlite3BtreeIsInTrans(pBt) ){\n        char const *zFile = sqlite3BtreeGetJournalname(pBt);\n        if( zFile==0 ){\n          continue;  /* Ignore TEMP and :memory: databases */\n        }\n        assert( zFile[0]!=0 );\n        if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){\n          needSync = 1;\n        }\n        rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);\n        offset += sqlite3Strlen30(zFile)+1;\n        if( rc!=SQLITE_OK ){\n          sqlite3OsCloseFree(pMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          sqlite3DbFree(db, zMaster);\n          return rc;\n        }\n      }\n    }\n\n    /* Sync the master journal file. If the IOCAP_SEQUENTIAL device\n    ** flag is set this is not required.\n    */\n    if( needSync \n     && 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)\n     && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))\n    ){\n      sqlite3OsCloseFree(pMaster);\n      sqlite3OsDelete(pVfs, zMaster, 0);\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Sync all the db files involved in the transaction. The same call\n    ** sets the master journal pointer in each individual journal. If\n    ** an error occurs here, do not delete the master journal file.\n    **\n    ** If the error occurs during the first call to\n    ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the\n    ** master journal file will be orphaned. But we cannot delete it,\n    ** in case the master journal file name was written into the journal\n    ** file before the failure occurred.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);\n      }\n    }\n    sqlite3OsCloseFree(pMaster);\n    assert( rc!=SQLITE_BUSY );\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Delete the master journal file. This commits the transaction. After\n    ** doing this the directory is synced again before any individual\n    ** transaction files are deleted.\n    */\n    rc = sqlite3OsDelete(pVfs, zMaster, 1);\n    sqlite3DbFree(db, zMaster);\n    zMaster = 0;\n    if( rc ){\n      return rc;\n    }\n\n    /* All files and directories have already been synced, so the following\n    ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and\n    ** deleting or truncating journals. If something goes wrong while\n    ** this is happening we don't really care. The integrity of the\n    ** transaction is already guaranteed, but some stray 'cold' journals\n    ** may be lying around. Returning an error code won't help matters.\n    */\n    disable_simulated_io_errors();\n    sqlite3BeginBenignMalloc();\n    for(i=0; i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        sqlite3BtreeCommitPhaseTwo(pBt, 1);\n      }\n    }\n    sqlite3EndBenignMalloc();\n    enable_simulated_io_errors();\n\n    sqlite3VtabCommit(db);\n  }\n#endif\n\n  return rc;\n}\n\n/* \n** This routine checks that the sqlite3.activeVdbeCnt count variable\n** matches the number of vdbe's in the list sqlite3.pVdbe that are\n** currently active. An assertion fails if the two counts do not match.\n** This is an internal self-check only - it is not an essential processing\n** step.\n**\n** This is a no-op if NDEBUG is defined.\n*/\n#ifndef NDEBUG\nstatic void checkActiveVdbeCnt(sqlite3 *db){\n  Vdbe *p;\n  int cnt = 0;\n  int nWrite = 0;\n  p = db->pVdbe;\n  while( p ){\n    if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){\n      cnt++;\n      if( p->readOnly==0 ) nWrite++;\n    }\n    p = p->pNext;\n  }\n  assert( cnt==db->activeVdbeCnt );\n  assert( nWrite==db->writeVdbeCnt );\n}\n#else\n#define checkActiveVdbeCnt(x)\n#endif\n\n/*\n** If the Vdbe passed as the first argument opened a statement-transaction,\n** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or\n** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement\n** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the \n** statement transaction is commtted.\n**\n** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. \n** Otherwise SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){\n  sqlite3 *const db = p->db;\n  int rc = SQLITE_OK;\n\n  /* If p->iStatement is greater than zero, then this Vdbe opened a \n  ** statement transaction that should be closed here. The only exception\n  ** is that an IO error may have occurred, causing an emergency rollback.\n  ** In this case (db->nStatement==0), and there is nothing to do.\n  */\n  if( db->nStatement && p->iStatement ){\n    int i;\n    const int iSavepoint = p->iStatement-1;\n\n    assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);\n    assert( db->nStatement>0 );\n    assert( p->iStatement==(db->nStatement+db->nSavepoint) );\n\n    for(i=0; i<db->nDb; i++){ \n      int rc2 = SQLITE_OK;\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        if( eOp==SAVEPOINT_ROLLBACK ){\n          rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);\n        }\n        if( rc2==SQLITE_OK ){\n          rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);\n        }\n        if( rc==SQLITE_OK ){\n          rc = rc2;\n        }\n      }\n    }\n    db->nStatement--;\n    p->iStatement = 0;\n\n    if( rc==SQLITE_OK ){\n      if( eOp==SAVEPOINT_ROLLBACK ){\n        rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);\n      }\n    }\n\n    /* If the statement transaction is being rolled back, also restore the \n    ** database handles deferred constraint counter to the value it had when \n    ** the statement transaction was opened.  */\n    if( eOp==SAVEPOINT_ROLLBACK ){\n      db->nDeferredCons = p->nStmtDefCons;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called when a transaction opened by the database \n** handle associated with the VM passed as an argument is about to be \n** committed. If there are outstanding deferred foreign key constraint\n** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.\n**\n** If there are outstanding FK violations and this function returns \n** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY\n** and write an error message to it. Then return SQLITE_ERROR.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){\n  sqlite3 *db = p->db;\n  if( (deferred && db->nDeferredCons>0) || (!deferred && p->nFkConstraint>0) ){\n    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n    p->errorAction = OE_Abort;\n    sqlite3SetString(&p->zErrMsg, db, \"foreign key constraint failed\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** This routine is called the when a VDBE tries to halt.  If the VDBE\n** has made changes and is in autocommit mode, then commit those\n** changes.  If a rollback is needed, then do the rollback.\n**\n** This routine is the only way to move the state of a VM from\n** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT.  It is harmless to\n** call this on a VM that is in the SQLITE_MAGIC_HALT state.\n**\n** Return an error code.  If the commit could not complete because of\n** lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it\n** means the close did not happen and needs to be repeated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){\n  int rc;                         /* Used to store transient return codes */\n  sqlite3 *db = p->db;\n\n  /* This function contains the logic that determines if a statement or\n  ** transaction will be committed or rolled back as a result of the\n  ** execution of this virtual machine. \n  **\n  ** If any of the following errors occur:\n  **\n  **     SQLITE_NOMEM\n  **     SQLITE_IOERR\n  **     SQLITE_FULL\n  **     SQLITE_INTERRUPT\n  **\n  ** Then the internal cache might have been left in an inconsistent\n  ** state.  We need to rollback the statement transaction, if there is\n  ** one, or the complete transaction if there is no statement transaction.\n  */\n\n  if( p->db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n  }\n  if( p->aOnceFlag ) memset(p->aOnceFlag, 0, p->nOnceFlag);\n  closeAllCursors(p);\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    return SQLITE_OK;\n  }\n  checkActiveVdbeCnt(db);\n\n  /* No commit or rollback needed if the program never started */\n  if( p->pc>=0 ){\n    int mrc;   /* Primary error code from p->rc */\n    int eStatementOp = 0;\n    int isSpecialError;            /* Set to true if a 'special' error */\n\n    /* Lock all btrees used by the statement */\n    sqlite3VdbeEnter(p);\n\n    /* Check for one of the special errors */\n    mrc = p->rc & 0xff;\n    assert( p->rc!=SQLITE_IOERR_BLOCKED );  /* This error no longer exists */\n    isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR\n                     || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;\n    if( isSpecialError ){\n      /* If the query was read-only and the error code is SQLITE_INTERRUPT, \n      ** no rollback is necessary. Otherwise, at least a savepoint \n      ** transaction must be rolled back to restore the database to a \n      ** consistent state.\n      **\n      ** Even if the statement is read-only, it is important to perform\n      ** a statement or transaction rollback operation. If the error \n      ** occurred while writing to the journal, sub-journal or database\n      ** file as part of an effort to free up cache space (see function\n      ** pagerStress() in pager.c), the rollback is required to restore \n      ** the pager to a consistent state.\n      */\n      if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){\n        if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){\n          eStatementOp = SAVEPOINT_ROLLBACK;\n        }else{\n          /* We are forced to roll back the active transaction. Before doing\n          ** so, abort any other statements this handle currently has active.\n          */\n          sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n          sqlite3CloseSavepoints(db);\n          db->autoCommit = 1;\n        }\n      }\n    }\n\n    /* Check for immediate foreign key violations. */\n    if( p->rc==SQLITE_OK ){\n      sqlite3VdbeCheckFk(p, 0);\n    }\n  \n    /* If the auto-commit flag is set and this is the only active writer \n    ** VM, then we do either a commit or rollback of the current transaction. \n    **\n    ** Note: This block also runs if one of the special errors handled \n    ** above has occurred. \n    */\n    if( !sqlite3VtabInSync(db) \n     && db->autoCommit \n     && db->writeVdbeCnt==(p->readOnly==0) \n    ){\n      if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){\n        rc = sqlite3VdbeCheckFk(p, 1);\n        if( rc!=SQLITE_OK ){\n          if( NEVER(p->readOnly) ){\n            sqlite3VdbeLeave(p);\n            return SQLITE_ERROR;\n          }\n          rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n        }else{ \n          /* The auto-commit flag is true, the vdbe program was successful \n          ** or hit an 'OR FAIL' constraint and there are no deferred foreign\n          ** key constraints to hold up the transaction. This means a commit \n          ** is required. */\n          rc = vdbeCommit(db, p);\n        }\n        if( rc==SQLITE_BUSY && p->readOnly ){\n          sqlite3VdbeLeave(p);\n          return SQLITE_BUSY;\n        }else if( rc!=SQLITE_OK ){\n          p->rc = rc;\n          sqlite3RollbackAll(db, SQLITE_OK);\n        }else{\n          db->nDeferredCons = 0;\n          sqlite3CommitInternalChanges(db);\n        }\n      }else{\n        sqlite3RollbackAll(db, SQLITE_OK);\n      }\n      db->nStatement = 0;\n    }else if( eStatementOp==0 ){\n      if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){\n        eStatementOp = SAVEPOINT_RELEASE;\n      }else if( p->errorAction==OE_Abort ){\n        eStatementOp = SAVEPOINT_ROLLBACK;\n      }else{\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n      }\n    }\n  \n    /* If eStatementOp is non-zero, then a statement transaction needs to\n    ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to\n    ** do so. If this operation returns an error, and the current statement\n    ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the\n    ** current statement error code.\n    */\n    if( eStatementOp ){\n      rc = sqlite3VdbeCloseStatement(p, eStatementOp);\n      if( rc ){\n        if( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ){\n          p->rc = rc;\n          sqlite3DbFree(db, p->zErrMsg);\n          p->zErrMsg = 0;\n        }\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n      }\n    }\n  \n    /* If this was an INSERT, UPDATE or DELETE and no statement transaction\n    ** has been rolled back, update the database connection change-counter. \n    */\n    if( p->changeCntOn ){\n      if( eStatementOp!=SAVEPOINT_ROLLBACK ){\n        sqlite3VdbeSetChanges(db, p->nChange);\n      }else{\n        sqlite3VdbeSetChanges(db, 0);\n      }\n      p->nChange = 0;\n    }\n\n    /* Release the locks */\n    sqlite3VdbeLeave(p);\n  }\n\n  /* We have successfully halted and closed the VM.  Record this fact. */\n  if( p->pc>=0 ){\n    db->activeVdbeCnt--;\n    if( !p->readOnly ){\n      db->writeVdbeCnt--;\n    }\n    assert( db->activeVdbeCnt>=db->writeVdbeCnt );\n  }\n  p->magic = VDBE_MAGIC_HALT;\n  checkActiveVdbeCnt(db);\n  if( p->db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n  }\n\n  /* If the auto-commit flag is set to true, then any locks that were held\n  ** by connection db have now been released. Call sqlite3ConnectionUnlocked() \n  ** to invoke any required unlock-notify callbacks.\n  */\n  if( db->autoCommit ){\n    sqlite3ConnectionUnlocked(db);\n  }\n\n  assert( db->activeVdbeCnt>0 || db->autoCommit==0 || db->nStatement==0 );\n  return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);\n}\n\n\n/*\n** Each VDBE holds the result of the most recent sqlite3_step() call\n** in p->rc.  This routine sets that result back to SQLITE_OK.\n*/\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){\n  p->rc = SQLITE_OK;\n}\n\n/*\n** Copy the error code and error message belonging to the VDBE passed\n** as the first argument to its database handle (so that they will be \n** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).\n**\n** This function does not clear the VDBE error code or message, just\n** copies them to the database handle.\n*/\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){\n  sqlite3 *db = p->db;\n  int rc = p->rc;\n  if( p->zErrMsg ){\n    u8 mallocFailed = db->mallocFailed;\n    sqlite3BeginBenignMalloc();\n    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);\n    sqlite3EndBenignMalloc();\n    db->mallocFailed = mallocFailed;\n    db->errCode = rc;\n  }else{\n    sqlite3Error(db, rc, 0);\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SQLLOG\n/*\n** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run, \n** invoke it.\n*/\nstatic void vdbeInvokeSqllog(Vdbe *v){\n  if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){\n    char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);\n    assert( v->db->init.busy==0 );\n    if( zExpanded ){\n      sqlite3GlobalConfig.xSqllog(\n          sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1\n      );\n      sqlite3DbFree(v->db, zExpanded);\n    }\n  }\n}\n#else\n# define vdbeInvokeSqllog(x)\n#endif\n\n/*\n** Clean up a VDBE after execution but do not delete the VDBE just yet.\n** Write any error messages into *pzErrMsg.  Return the result code.\n**\n** After this routine is run, the VDBE should be ready to be executed\n** again.\n**\n** To look at it another way, this routine resets the state of the\n** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to\n** VDBE_MAGIC_INIT.\n*/\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){\n  sqlite3 *db;\n  db = p->db;\n\n  /* If the VM did not run to completion or if it encountered an\n  ** error, then it might not have been halted properly.  So halt\n  ** it now.\n  */\n  sqlite3VdbeHalt(p);\n\n  /* If the VDBE has be run even partially, then transfer the error code\n  ** and error message from the VDBE into the main database structure.  But\n  ** if the VDBE has just been set to run but has not actually executed any\n  ** instructions yet, leave the main database error information unchanged.\n  */\n  if( p->pc>=0 ){\n    vdbeInvokeSqllog(p);\n    sqlite3VdbeTransferError(p);\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = 0;\n    if( p->runOnlyOnce ) p->expired = 1;\n  }else if( p->rc && p->expired ){\n    /* The expired flag was set on the VDBE before the first call\n    ** to sqlite3_step(). For consistency (since sqlite3_step() was\n    ** called), set the database error in this case as well.\n    */\n    sqlite3Error(db, p->rc, 0);\n    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = 0;\n  }\n\n  /* Reclaim all memory used by the VDBE\n  */\n  Cleanup(p);\n\n  /* Save profiling information from this VDBE run.\n  */\n#ifdef VDBE_PROFILE\n  {\n    FILE *out = fopen(\"vdbe_profile.out\", \"a\");\n    if( out ){\n      int i;\n      fprintf(out, \"---- \");\n      for(i=0; i<p->nOp; i++){\n        fprintf(out, \"%02x\", p->aOp[i].opcode);\n      }\n      fprintf(out, \"\\n\");\n      for(i=0; i<p->nOp; i++){\n        fprintf(out, \"%6d %10lld %8lld \",\n           p->aOp[i].cnt,\n           p->aOp[i].cycles,\n           p->aOp[i].cnt>0 ? p->aOp[i].cycles/p->aOp[i].cnt : 0\n        );\n        sqlite3VdbePrintOp(out, i, &p->aOp[i]);\n      }\n      fclose(out);\n    }\n  }\n#endif\n  p->magic = VDBE_MAGIC_INIT;\n  return p->rc & db->errMask;\n}\n \n/*\n** Clean up and delete a VDBE after execution.  Return an integer which is\n** the result code.  Write any error message text into *pzErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){\n  int rc = SQLITE_OK;\n  if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){\n    rc = sqlite3VdbeReset(p);\n    assert( (rc & p->db->errMask)==rc );\n  }\n  sqlite3VdbeDelete(p);\n  return rc;\n}\n\n/*\n** Call the destructor for each auxdata entry in pVdbeFunc for which\n** the corresponding bit in mask is clear.  Auxdata entries beyond 31\n** are always destroyed.  To destroy all auxdata entries, call this\n** routine with mask==0.\n*/\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){\n  int i;\n  for(i=0; i<pVdbeFunc->nAux; i++){\n    struct AuxData *pAux = &pVdbeFunc->apAux[i];\n    if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){\n      if( pAux->xDelete ){\n        pAux->xDelete(pAux->pAux);\n      }\n      pAux->pAux = 0;\n    }\n  }\n}\n\n/*\n** Free all memory associated with the Vdbe passed as the second argument,\n** except for object itself, which is preserved.\n**\n** The difference between this function and sqlite3VdbeDelete() is that\n** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with\n** the database connection and frees the object itself.\n*/\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){\n  SubProgram *pSub, *pNext;\n  int i;\n  assert( p->db==0 || p->db==db );\n  releaseMemArray(p->aVar, p->nVar);\n  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n  for(pSub=p->pProgram; pSub; pSub=pNext){\n    pNext = pSub->pNext;\n    vdbeFreeOpArray(db, pSub->aOp, pSub->nOp);\n    sqlite3DbFree(db, pSub);\n  }\n  for(i=p->nzVar-1; i>=0; i--) sqlite3DbFree(db, p->azVar[i]);\n  vdbeFreeOpArray(db, p->aOp, p->nOp);\n  sqlite3DbFree(db, p->aLabel);\n  sqlite3DbFree(db, p->aColName);\n  sqlite3DbFree(db, p->zSql);\n  sqlite3DbFree(db, p->pFree);\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n  sqlite3DbFree(db, p->zExplain);\n  sqlite3DbFree(db, p->pExplain);\n#endif\n}\n\n/*\n** Delete an entire VDBE.\n*/\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){\n  sqlite3 *db;\n\n  if( NEVER(p==0) ) return;\n  db = p->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3VdbeClearObject(db, p);\n  if( p->pPrev ){\n    p->pPrev->pNext = p->pNext;\n  }else{\n    assert( db->pVdbe==p );\n    db->pVdbe = p->pNext;\n  }\n  if( p->pNext ){\n    p->pNext->pPrev = p->pPrev;\n  }\n  p->magic = VDBE_MAGIC_DEAD;\n  p->db = 0;\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Make sure the cursor p is ready to read or write the row to which it\n** was last positioned.  Return an error code if an OOM fault or I/O error\n** prevents us from positioning the cursor to its correct position.\n**\n** If a MoveTo operation is pending on the given cursor, then do that\n** MoveTo now.  If no move is pending, check to see if the row has been\n** deleted out from under the cursor and if it has, mark the row as\n** a NULL row.\n**\n** If the cursor is already pointing to the correct row and that row has\n** not been deleted out from under the cursor, then this routine is a no-op.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor *p){\n  if( p->deferredMoveto ){\n    int res, rc;\n#ifdef SQLITE_TEST\n    extern int sqlite3_search_count;\n#endif\n    assert( p->isTable );\n    rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);\n    if( rc ) return rc;\n    p->lastRowid = p->movetoTarget;\n    if( res!=0 ) return SQLITE_CORRUPT_BKPT;\n    p->rowidIsValid = 1;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n    p->deferredMoveto = 0;\n    p->cacheStatus = CACHE_STALE;\n  }else if( ALWAYS(p->pCursor) ){\n    int hasMoved;\n    int rc = sqlite3BtreeCursorHasMoved(p->pCursor, &hasMoved);\n    if( rc ) return rc;\n    if( hasMoved ){\n      p->cacheStatus = CACHE_STALE;\n      p->nullRow = 1;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The following functions:\n**\n** sqlite3VdbeSerialType()\n** sqlite3VdbeSerialTypeLen()\n** sqlite3VdbeSerialLen()\n** sqlite3VdbeSerialPut()\n** sqlite3VdbeSerialGet()\n**\n** encapsulate the code that serializes values for storage in SQLite\n** data and index records. Each serialized value consists of a\n** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned\n** integer, stored as a varint.\n**\n** In an SQLite index record, the serial type is stored directly before\n** the blob of data that it corresponds to. In a table record, all serial\n** types are stored at the start of the record, and the blobs of data at\n** the end. Hence these functions allow the caller to handle the\n** serial-type and data blob separately.\n**\n** The following table describes the various storage classes for data:\n**\n**   serial type        bytes of data      type\n**   --------------     ---------------    ---------------\n**      0                     0            NULL\n**      1                     1            signed integer\n**      2                     2            signed integer\n**      3                     3            signed integer\n**      4                     4            signed integer\n**      5                     6            signed integer\n**      6                     8            signed integer\n**      7                     8            IEEE float\n**      8                     0            Integer constant 0\n**      9                     0            Integer constant 1\n**     10,11                               reserved for expansion\n**    N>=12 and even       (N-12)/2        BLOB\n**    N>=13 and odd        (N-13)/2        text\n**\n** The 8 and 9 types were added in 3.3.0, file format 4.  Prior versions\n** of SQLite will not understand those serial types.\n*/\n\n/*\n** Return the serial-type for the value stored in pMem.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){\n  int flags = pMem->flags;\n  int n;\n\n  if( flags&MEM_Null ){\n    return 0;\n  }\n  if( flags&MEM_Int ){\n    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */\n#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)\n    i64 i = pMem->u.i;\n    u64 u;\n    if( i<0 ){\n      if( i<(-MAX_6BYTE) ) return 6;\n      /* Previous test prevents:  u = -(-9223372036854775808) */\n      u = -i;\n    }else{\n      u = i;\n    }\n    if( u<=127 ){\n      return ((i&1)==i && file_format>=4) ? 8+(u32)u : 1;\n    }\n    if( u<=32767 ) return 2;\n    if( u<=8388607 ) return 3;\n    if( u<=2147483647 ) return 4;\n    if( u<=MAX_6BYTE ) return 5;\n    return 6;\n  }\n  if( flags&MEM_Real ){\n    return 7;\n  }\n  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );\n  n = pMem->n;\n  if( flags & MEM_Zero ){\n    n += pMem->u.nZero;\n  }\n  assert( n>=0 );\n  return ((n*2) + 12 + ((flags&MEM_Str)!=0));\n}\n\n/*\n** Return the length of the data corresponding to the supplied serial-type.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32 serial_type){\n  if( serial_type>=12 ){\n    return (serial_type-12)/2;\n  }else{\n    static const u8 aSize[] = { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 };\n    return aSize[serial_type];\n  }\n}\n\n/*\n** If we are on an architecture with mixed-endian floating \n** points (ex: ARM7) then swap the lower 4 bytes with the \n** upper 4 bytes.  Return the result.\n**\n** For most architectures, this is a no-op.\n**\n** (later):  It is reported to me that the mixed-endian problem\n** on ARM7 is an issue with GCC, not with the ARM7 chip.  It seems\n** that early versions of GCC stored the two words of a 64-bit\n** float in the wrong order.  And that error has been propagated\n** ever since.  The blame is not necessarily with GCC, though.\n** GCC might have just copying the problem from a prior compiler.\n** I am also told that newer versions of GCC that follow a different\n** ABI get the byte order right.\n**\n** Developers using SQLite on an ARM7 should compile and run their\n** application using -DSQLITE_DEBUG=1 at least once.  With DEBUG\n** enabled, some asserts below will ensure that the byte order of\n** floating point values is correct.\n**\n** (2007-08-30)  Frank van Vugt has studied this problem closely\n** and has send his findings to the SQLite developers.  Frank\n** writes that some Linux kernels offer floating point hardware\n** emulation that uses only 32-bit mantissas instead of a full \n** 48-bits as required by the IEEE standard.  (This is the\n** CONFIG_FPE_FASTFPE option.)  On such systems, floating point\n** byte swapping becomes very complicated.  To avoid problems,\n** the necessary byte swapping is carried out using a 64-bit integer\n** rather than a 64-bit float.  Frank assures us that the code here\n** works for him.  We, the developers, have no way to independently\n** verify this, but Frank seems to know what he is talking about\n** so we trust him.\n*/\n#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\nstatic u64 floatSwap(u64 in){\n  union {\n    u64 r;\n    u32 i[2];\n  } u;\n  u32 t;\n\n  u.r = in;\n  t = u.i[0];\n  u.i[0] = u.i[1];\n  u.i[1] = t;\n  return u.r;\n}\n# define swapMixedEndianFloat(X)  X = floatSwap(X)\n#else\n# define swapMixedEndianFloat(X)\n#endif\n\n/*\n** Write the serialized data blob for the value stored in pMem into \n** buf. It is assumed that the caller has allocated sufficient space.\n** Return the number of bytes written.\n**\n** nBuf is the amount of space left in buf[].  nBuf must always be\n** large enough to hold the entire field.  Except, if the field is\n** a blob with a zero-filled tail, then buf[] might be just the right\n** size to hold everything except for the zero-filled tail.  If buf[]\n** is only big enough to hold the non-zero prefix, then only write that\n** prefix into buf[].  But if buf[] is large enough to hold both the\n** prefix and the tail then write the prefix and set the tail to all\n** zeros.\n**\n** Return the number of bytes actually written into buf[].  The number\n** of bytes in the zero-filled tail is included in the return value only\n** if those bytes were zeroed in buf[].\n*/ \nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, int nBuf, Mem *pMem, int file_format){\n  u32 serial_type = sqlite3VdbeSerialType(pMem, file_format);\n  u32 len;\n\n  /* Integer and Real */\n  if( serial_type<=7 && serial_type>0 ){\n    u64 v;\n    u32 i;\n    if( serial_type==7 ){\n      assert( sizeof(v)==sizeof(pMem->r) );\n      memcpy(&v, &pMem->r, sizeof(v));\n      swapMixedEndianFloat(v);\n    }else{\n      v = pMem->u.i;\n    }\n    len = i = sqlite3VdbeSerialTypeLen(serial_type);\n    assert( len<=(u32)nBuf );\n    while( i-- ){\n      buf[i] = (u8)(v&0xFF);\n      v >>= 8;\n    }\n    return len;\n  }\n\n  /* String or blob */\n  if( serial_type>=12 ){\n    assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)\n             == (int)sqlite3VdbeSerialTypeLen(serial_type) );\n    assert( pMem->n<=nBuf );\n    len = pMem->n;\n    memcpy(buf, pMem->z, len);\n    if( pMem->flags & MEM_Zero ){\n      len += pMem->u.nZero;\n      assert( nBuf>=0 );\n      if( len > (u32)nBuf ){\n        len = (u32)nBuf;\n      }\n      memset(&buf[pMem->n], 0, len-pMem->n);\n    }\n    return len;\n  }\n\n  /* NULL or constants 0 or 1 */\n  return 0;\n}\n\n/*\n** Deserialize the data blob pointed to by buf as serial type serial_type\n** and store the result in pMem.  Return the number of bytes read.\n*/ \nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  switch( serial_type ){\n    case 10:   /* Reserved for future use */\n    case 11:   /* Reserved for future use */\n    case 0: {  /* NULL */\n      pMem->flags = MEM_Null;\n      break;\n    }\n    case 1: { /* 1-byte signed integer */\n      pMem->u.i = (signed char)buf[0];\n      pMem->flags = MEM_Int;\n      return 1;\n    }\n    case 2: { /* 2-byte signed integer */\n      pMem->u.i = (((signed char)buf[0])<<8) | buf[1];\n      pMem->flags = MEM_Int;\n      return 2;\n    }\n    case 3: { /* 3-byte signed integer */\n      pMem->u.i = (((signed char)buf[0])<<16) | (buf[1]<<8) | buf[2];\n      pMem->flags = MEM_Int;\n      return 3;\n    }\n    case 4: { /* 4-byte signed integer */\n      pMem->u.i = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];\n      pMem->flags = MEM_Int;\n      return 4;\n    }\n    case 5: { /* 6-byte signed integer */\n      u64 x = (((signed char)buf[0])<<8) | buf[1];\n      u32 y = (buf[2]<<24) | (buf[3]<<16) | (buf[4]<<8) | buf[5];\n      x = (x<<32) | y;\n      pMem->u.i = *(i64*)&x;\n      pMem->flags = MEM_Int;\n      return 6;\n    }\n    case 6:   /* 8-byte signed integer */\n    case 7: { /* IEEE floating point */\n      u64 x;\n      u32 y;\n#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)\n      /* Verify that integers and floating point values use the same\n      ** byte order.  Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is\n      ** defined that 64-bit floating point values really are mixed\n      ** endian.\n      */\n      static const u64 t1 = ((u64)0x3ff00000)<<32;\n      static const double r1 = 1.0;\n      u64 t2 = t1;\n      swapMixedEndianFloat(t2);\n      assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );\n#endif\n\n      x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];\n      y = (buf[4]<<24) | (buf[5]<<16) | (buf[6]<<8) | buf[7];\n      x = (x<<32) | y;\n      if( serial_type==6 ){\n        pMem->u.i = *(i64*)&x;\n        pMem->flags = MEM_Int;\n      }else{\n        assert( sizeof(x)==8 && sizeof(pMem->r)==8 );\n        swapMixedEndianFloat(x);\n        memcpy(&pMem->r, &x, sizeof(x));\n        pMem->flags = sqlite3IsNaN(pMem->r) ? MEM_Null : MEM_Real;\n      }\n      return 8;\n    }\n    case 8:    /* Integer 0 */\n    case 9: {  /* Integer 1 */\n      pMem->u.i = serial_type-8;\n      pMem->flags = MEM_Int;\n      return 0;\n    }\n    default: {\n      u32 len = (serial_type-12)/2;\n      pMem->z = (char *)buf;\n      pMem->n = len;\n      pMem->xDel = 0;\n      if( serial_type&0x01 ){\n        pMem->flags = MEM_Str | MEM_Ephem;\n      }else{\n        pMem->flags = MEM_Blob | MEM_Ephem;\n      }\n      return len;\n    }\n  }\n  return 0;\n}\n\n/*\n** This routine is used to allocate sufficient space for an UnpackedRecord\n** structure large enough to be used with sqlite3VdbeRecordUnpack() if\n** the first argument is a pointer to KeyInfo structure pKeyInfo.\n**\n** The space is either allocated using sqlite3DbMallocRaw() or from within\n** the unaligned buffer passed via the second and third arguments (presumably\n** stack space). If the former, then *ppFree is set to a pointer that should\n** be eventually freed by the caller using sqlite3DbFree(). Or, if the \n** allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL\n** before returning.\n**\n** If an OOM error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(\n  KeyInfo *pKeyInfo,              /* Description of the record */\n  char *pSpace,                   /* Unaligned space available */\n  int szSpace,                    /* Size of pSpace[] in bytes */\n  char **ppFree                   /* OUT: Caller should free this pointer */\n){\n  UnpackedRecord *p;              /* Unpacked record to return */\n  int nOff;                       /* Increment pSpace by nOff to align it */\n  int nByte;                      /* Number of bytes required for *p */\n\n  /* We want to shift the pointer pSpace up such that it is 8-byte aligned.\n  ** Thus, we need to calculate a value, nOff, between 0 and 7, to shift \n  ** it by.  If pSpace is already 8-byte aligned, nOff should be zero.\n  */\n  nOff = (8 - (SQLITE_PTR_TO_INT(pSpace) & 7)) & 7;\n  nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nField+1);\n  if( nByte>szSpace+nOff ){\n    p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);\n    *ppFree = (char *)p;\n    if( !p ) return 0;\n  }else{\n    p = (UnpackedRecord*)&pSpace[nOff];\n    *ppFree = 0;\n  }\n\n  p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];\n  assert( pKeyInfo->aSortOrder!=0 );\n  p->pKeyInfo = pKeyInfo;\n  p->nField = pKeyInfo->nField + 1;\n  return p;\n}\n\n/*\n** Given the nKey-byte encoding of a record in pKey[], populate the \n** UnpackedRecord structure indicated by the fourth argument with the\n** contents of the decoded record.\n*/ \nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(\n  KeyInfo *pKeyInfo,     /* Information about the record format */\n  int nKey,              /* Size of the binary record */\n  const void *pKey,      /* The binary record */\n  UnpackedRecord *p      /* Populate this structure before returning. */\n){\n  const unsigned char *aKey = (const unsigned char *)pKey;\n  int d; \n  u32 idx;                        /* Offset in aKey[] to read from */\n  u16 u;                          /* Unsigned loop counter */\n  u32 szHdr;\n  Mem *pMem = p->aMem;\n\n  p->flags = 0;\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  idx = getVarint32(aKey, szHdr);\n  d = szHdr;\n  u = 0;\n  while( idx<szHdr && u<p->nField && d<=nKey ){\n    u32 serial_type;\n\n    idx += getVarint32(&aKey[idx], serial_type);\n    pMem->enc = pKeyInfo->enc;\n    pMem->db = pKeyInfo->db;\n    /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */\n    pMem->zMalloc = 0;\n    d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);\n    pMem++;\n    u++;\n  }\n  assert( u<=pKeyInfo->nField + 1 );\n  p->nField = u;\n}\n\n/*\n** This function compares the two table rows or index records\n** specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero\n** or positive integer if key1 is less than, equal to or \n** greater than key2.  The {nKey1, pKey1} key must be a blob\n** created by th OP_MakeRecord opcode of the VDBE.  The pPKey2\n** key must be a parsed key such as obtained from\n** sqlite3VdbeParseRecord.\n**\n** Key1 and Key2 do not have to contain the same number of fields.\n** The key with fewer fields is usually compares less than the \n** longer key.  However if the UNPACKED_INCRKEY flags in pPKey2 is set\n** and the common prefixes are equal, then key1 is less than key2.\n** Or if the UNPACKED_MATCH_PREFIX flag is set and the prefixes are\n** equal, then the keys are considered to be equal and\n** the parts beyond the common prefix are ignored.\n*/\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  int d1;            /* Offset into aKey[] of next data element */\n  u32 idx1;          /* Offset into aKey[] of next header element */\n  u32 szHdr1;        /* Number of bytes in header */\n  int i = 0;\n  int nField;\n  int rc = 0;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  KeyInfo *pKeyInfo;\n  Mem mem1;\n\n  pKeyInfo = pPKey2->pKeyInfo;\n  mem1.enc = pKeyInfo->enc;\n  mem1.db = pKeyInfo->db;\n  /* mem1.flags = 0;  // Will be initialized by sqlite3VdbeSerialGet() */\n  VVA_ONLY( mem1.zMalloc = 0; ) /* Only needed by assert() statements */\n\n  /* Compilers may complain that mem1.u.i is potentially uninitialized.\n  ** We could initialize it, as shown here, to silence those complaints.\n  ** But in fact, mem1.u.i will never actually be used uninitialized, and doing \n  ** the unnecessary initialization has a measurable negative performance\n  ** impact, since this routine is a very high runner.  And so, we choose\n  ** to ignore the compiler warnings and leave this variable uninitialized.\n  */\n  /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */\n  \n  idx1 = getVarint32(aKey1, szHdr1);\n  d1 = szHdr1;\n  nField = pKeyInfo->nField;\n  assert( pKeyInfo->aSortOrder!=0 );\n  while( idx1<szHdr1 && i<pPKey2->nField ){\n    u32 serial_type1;\n\n    /* Read the serial types for the next element in each key. */\n    idx1 += getVarint32( aKey1+idx1, serial_type1 );\n    if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break;\n\n    /* Extract the values to be compared.\n    */\n    d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);\n\n    /* Do the comparison\n    */\n    rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],\n                           i<nField ? pKeyInfo->aColl[i] : 0);\n    if( rc!=0 ){\n      assert( mem1.zMalloc==0 );  /* See comment below */\n\n      /* Invert the result if we are using DESC sort order. */\n      if( i<nField && pKeyInfo->aSortOrder[i] ){\n        rc = -rc;\n      }\n    \n      /* If the PREFIX_SEARCH flag is set and all fields except the final\n      ** rowid field were equal, then clear the PREFIX_SEARCH flag and set \n      ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1).\n      ** This is used by the OP_IsUnique opcode.\n      */\n      if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){\n        assert( idx1==szHdr1 && rc );\n        assert( mem1.flags & MEM_Int );\n        pPKey2->flags &= ~UNPACKED_PREFIX_SEARCH;\n        pPKey2->rowid = mem1.u.i;\n      }\n    \n      return rc;\n    }\n    i++;\n  }\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).\n  */\n  assert( mem1.zMalloc==0 );\n\n  /* rc==0 here means that one of the keys ran out of fields and\n  ** all the fields up to that point were equal. If the UNPACKED_INCRKEY\n  ** flag is set, then break the tie by treating key2 as larger.\n  ** If the UPACKED_PREFIX_MATCH flag is set, then keys with common prefixes\n  ** are considered to be equal.  Otherwise, the longer key is the \n  ** larger.  As it happens, the pPKey2 will always be the longer\n  ** if there is a difference.\n  */\n  assert( rc==0 );\n  if( pPKey2->flags & UNPACKED_INCRKEY ){\n    rc = -1;\n  }else if( pPKey2->flags & UNPACKED_PREFIX_MATCH ){\n    /* Leave rc==0 */\n  }else if( idx1<szHdr1 ){\n    rc = 1;\n  }\n  return rc;\n}\n \n\n/*\n** pCur points at an index entry created using the OP_MakeRecord opcode.\n** Read the rowid (the last field in the record) and store it in *rowid.\n** Return SQLITE_OK if everything works, or an error code otherwise.\n**\n** pCur might be pointing to text obtained from a corrupt database file.\n** So the content cannot be trusted.  Do appropriate checks on the content.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){\n  i64 nCellKey = 0;\n  int rc;\n  u32 szHdr;        /* Size of the header */\n  u32 typeRowid;    /* Serial type of the rowid */\n  u32 lenRowid;     /* Size of the rowid */\n  Mem m, v;\n\n  UNUSED_PARAMETER(db);\n\n  /* Get the size of the index entry.  Only indices entries of less\n  ** than 2GiB are support - anything large must be database corruption.\n  ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so\n  ** this code can safely assume that nCellKey is 32-bits  \n  */\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);\n  assert( rc==SQLITE_OK );     /* pCur is always valid so KeySize cannot fail */\n  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );\n\n  /* Read in the complete content of the index entry */\n  memset(&m, 0, sizeof(m));\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (int)nCellKey, 1, &m);\n  if( rc ){\n    return rc;\n  }\n\n  /* The index entry must begin with a header size */\n  (void)getVarint32((u8*)m.z, szHdr);\n  testcase( szHdr==3 );\n  testcase( szHdr==m.n );\n  if( unlikely(szHdr<3 || (int)szHdr>m.n) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* The last field of the index should be an integer - the ROWID.\n  ** Verify that the last entry really is an integer. */\n  (void)getVarint32((u8*)&m.z[szHdr-1], typeRowid);\n  testcase( typeRowid==1 );\n  testcase( typeRowid==2 );\n  testcase( typeRowid==3 );\n  testcase( typeRowid==4 );\n  testcase( typeRowid==5 );\n  testcase( typeRowid==6 );\n  testcase( typeRowid==8 );\n  testcase( typeRowid==9 );\n  if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){\n    goto idx_rowid_corruption;\n  }\n  lenRowid = sqlite3VdbeSerialTypeLen(typeRowid);\n  testcase( (u32)m.n==szHdr+lenRowid );\n  if( unlikely((u32)m.n<szHdr+lenRowid) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* Fetch the integer off the end of the index record */\n  sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);\n  *rowid = v.u.i;\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n\n  /* Jump here if database corruption is detected after m has been\n  ** allocated.  Free the m object and return SQLITE_CORRUPT. */\nidx_rowid_corruption:\n  testcase( m.zMalloc!=0 );\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** Compare the key of the index entry that cursor pC is pointing to against\n** the key string in pUnpacked.  Write into *pRes a number\n** that is negative, zero, or positive if pC is less than, equal to,\n** or greater than pUnpacked.  Return SQLITE_OK on success.\n**\n** pUnpacked is either created without a rowid or is truncated so that it\n** omits the rowid at the end.  The rowid at the end of the index entry\n** is ignored as well.  Hence, this routine only compares the prefixes \n** of the keys prior to the final rowid, not the entire key.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(\n  VdbeCursor *pC,             /* The cursor to compare against */\n  UnpackedRecord *pUnpacked,  /* Unpacked version of key to compare against */\n  int *res                    /* Write the comparison result here */\n){\n  i64 nCellKey = 0;\n  int rc;\n  BtCursor *pCur = pC->pCursor;\n  Mem m;\n\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey);\n  assert( rc==SQLITE_OK );    /* pCur is always valid so KeySize cannot fail */\n  /* nCellKey will always be between 0 and 0xffffffff because of the say\n  ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */\n  if( nCellKey<=0 || nCellKey>0x7fffffff ){\n    *res = 0;\n    return SQLITE_CORRUPT_BKPT;\n  }\n  memset(&m, 0, sizeof(m));\n  rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, (int)nCellKey, 1, &m);\n  if( rc ){\n    return rc;\n  }\n  assert( pUnpacked->flags & UNPACKED_PREFIX_MATCH );\n  *res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n}\n\n/*\n** This routine sets the value to be returned by subsequent calls to\n** sqlite3_changes() on the database handle 'db'. \n*/\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){\n  assert( sqlite3_mutex_held(db->mutex) );\n  db->nChange = nChange;\n  db->nTotalChange += nChange;\n}\n\n/*\n** Set a flag in the vdbe to update the change counter when it is finalised\n** or reset.\n*/\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe *v){\n  v->changeCntOn = 1;\n}\n\n/*\n** Mark every prepared statement associated with a database connection\n** as expired.\n**\n** An expired statement means that recompilation of the statement is\n** recommend.  Statements expire when things happen that make their\n** programs obsolete.  Removing user-defined functions or collating\n** sequences, or changing an authorization function are the types of\n** things that make prepared statements obsolete.\n*/\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db){\n  Vdbe *p;\n  for(p = db->pVdbe; p; p=p->pNext){\n    p->expired = 1;\n  }\n}\n\n/*\n** Return the database associated with the Vdbe.\n*/\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){\n  return v->db;\n}\n\n/*\n** Return a pointer to an sqlite3_value structure containing the value bound\n** parameter iVar of VM v. Except, if the value is an SQL NULL, return \n** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*\n** constants) to the value before returning it.\n**\n** The returned value must be freed by the caller using sqlite3ValueFree().\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){\n  assert( iVar>0 );\n  if( v ){\n    Mem *pMem = &v->aVar[iVar-1];\n    if( 0==(pMem->flags & MEM_Null) ){\n      sqlite3_value *pRet = sqlite3ValueNew(v->db);\n      if( pRet ){\n        sqlite3VdbeMemCopy((Mem *)pRet, pMem);\n        sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);\n        sqlite3VdbeMemStoreType((Mem *)pRet);\n      }\n      return pRet;\n    }\n  }\n  return 0;\n}\n\n/*\n** Configure SQL variable iVar so that binding a new value to it signals\n** to sqlite3_reoptimize() that re-preparing the statement may result\n** in a better query plan.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){\n  assert( iVar>0 );\n  if( iVar>32 ){\n    v->expmask = 0xffffffff;\n  }else{\n    v->expmask |= ((u32)1 << (iVar-1));\n  }\n}\n\n/************** End of vdbeaux.c *********************************************/\n/************** Begin file vdbeapi.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement APIs that are part of the\n** VDBE.\n*/\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return TRUE (non-zero) of the statement supplied as an argument needs\n** to be recompiled.  A statement needs to be recompiled whenever the\n** execution environment changes in a way that would alter the program\n** that sqlite3_prepare() generates.  For example, if new functions or\n** collating sequences are registered or if an authorizer function is\n** added or changed.\n*/\nSQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p==0 || p->expired;\n}\n#endif\n\n/*\n** Check on a Vdbe to make sure it has not been finalized.  Log\n** an error and return true if it has been finalized (or is otherwise\n** invalid).  Return false if it is ok.\n*/\nstatic int vdbeSafety(Vdbe *p){\n  if( p->db==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with finalized prepared statement\");\n    return 1;\n  }else{\n    return 0;\n  }\n}\nstatic int vdbeSafetyNotNull(Vdbe *p){\n  if( p==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with NULL prepared statement\");\n    return 1;\n  }else{\n    return vdbeSafety(p);\n  }\n}\n\n/*\n** The following routine destroys a virtual machine that is created by\n** the sqlite3_compile() routine. The integer returned is an SQLITE_\n** success/failure code that describes the result of executing the virtual\n** machine.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL\n    ** pointer is a harmless no-op. */\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;\n    sqlite3_mutex_enter(db->mutex);\n    rc = sqlite3VdbeFinalize(v);\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3LeaveMutexAndCloseZombie(db);\n  }\n  return rc;\n}\n\n/*\n** Terminate the current execution of an SQL statement and reset it\n** back to its starting state so that it can be reused. A success code from\n** the prior execution is returned.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3_mutex_enter(v->db->mutex);\n    rc = sqlite3VdbeReset(v);\n    sqlite3VdbeRewind(v);\n    assert( (rc & (v->db->errMask))==rc );\n    rc = sqlite3ApiExit(v->db, rc);\n    sqlite3_mutex_leave(v->db->mutex);\n  }\n  return rc;\n}\n\n/*\n** Set all the parameters in the compiled SQL statement to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){\n  int i;\n  int rc = SQLITE_OK;\n  Vdbe *p = (Vdbe*)pStmt;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(i=0; i<p->nVar; i++){\n    sqlite3VdbeMemRelease(&p->aVar[i]);\n    p->aVar[i].flags = MEM_Null;\n  }\n  if( p->isPrepareV2 && p->expmask ){\n    p->expired = 1;\n  }\n  sqlite3_mutex_leave(mutex);\n  return rc;\n}\n\n\n/**************************** sqlite3_value_  *******************************\n** The following routines extract information from a Mem or sqlite3_value\n** structure.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){\n  Mem *p = (Mem*)pVal;\n  if( p->flags & (MEM_Blob|MEM_Str) ){\n    sqlite3VdbeMemExpandBlob(p);\n    p->flags &= ~MEM_Str;\n    p->flags |= MEM_Blob;\n    return p->n ? p->z : 0;\n  }else{\n    return sqlite3_value_text(pVal);\n  }\n}\nSQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF8);\n}\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API double sqlite3_value_double(sqlite3_value *pVal){\n  return sqlite3VdbeRealValue((Mem*)pVal);\n}\nSQLITE_API int sqlite3_value_int(sqlite3_value *pVal){\n  return (int)sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){\n  return sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){\n  return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16BE);\n}\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16LE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_value_type(sqlite3_value* pVal){\n  return pVal->type;\n}\n\n/**************************** sqlite3_result_  *******************************\n** The following routines are used by user-defined functions to specify\n** the function result.\n**\n** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the\n** result as a string or blob but if the string or blob is too large, it\n** then sets the error code to SQLITE_TOOBIG\n*/\nstatic void setResultStrOrError(\n  sqlite3_context *pCtx,  /* Function context */\n  const char *z,          /* String pointer */\n  int n,                  /* Bytes in string, or negative */\n  u8 enc,                 /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*)     /* Destructor function */\n){\n  if( sqlite3VdbeMemSetStr(&pCtx->s, z, n, enc, xDel)==SQLITE_TOOBIG ){\n    sqlite3_result_error_toobig(pCtx);\n  }\n}\nSQLITE_API void sqlite3_result_blob(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( n>=0 );\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  setResultStrOrError(pCtx, z, n, 0, xDel);\n}\nSQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetDouble(&pCtx->s, rVal);\n}\nSQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);\n}\n#endif\nSQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetInt64(&pCtx->s, (i64)iVal);\n}\nSQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetInt64(&pCtx->s, iVal);\n}\nSQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetNull(&pCtx->s);\n}\nSQLITE_API void sqlite3_result_text(\n  sqlite3_context *pCtx, \n  const char *z, \n  int n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_text16(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);\n}\nSQLITE_API void sqlite3_result_text16be(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);\n}\nSQLITE_API void sqlite3_result_text16le(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemCopy(&pCtx->s, pValue);\n}\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetZeroBlob(&pCtx->s, n);\n}\nSQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){\n  pCtx->isError = errCode;\n  if( pCtx->s.flags & MEM_Null ){\n    sqlite3VdbeMemSetStr(&pCtx->s, sqlite3ErrStr(errCode), -1, \n                         SQLITE_UTF8, SQLITE_STATIC);\n  }\n}\n\n/* Force an SQLITE_TOOBIG error. */\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  pCtx->isError = SQLITE_TOOBIG;\n  sqlite3VdbeMemSetStr(&pCtx->s, \"string or blob too big\", -1, \n                       SQLITE_UTF8, SQLITE_STATIC);\n}\n\n/* An SQLITE_NOMEM error. */\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  sqlite3VdbeMemSetNull(&pCtx->s);\n  pCtx->isError = SQLITE_NOMEM;\n  pCtx->s.db->mallocFailed = 1;\n}\n\n/*\n** This function is called after a transaction has been committed. It \n** invokes callbacks registered with sqlite3_wal_hook() as required.\n*/\nstatic int doWalCallbacks(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_WAL\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      int nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));\n      if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK ){\n        rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Execute the statement pStmt, either until a row of data is ready, the\n** statement is completely executed or an error occurs.\n**\n** This routine implements the bulk of the logic behind the sqlite_step()\n** API.  The only thing omitted is the automatic recompile if a \n** schema change has occurred.  That detail is handled by the\n** outer sqlite3_step() wrapper procedure.\n*/\nstatic int sqlite3Step(Vdbe *p){\n  sqlite3 *db;\n  int rc;\n\n  assert(p);\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    /* We used to require that sqlite3_reset() be called before retrying\n    ** sqlite3_step() after any error or after SQLITE_DONE.  But beginning\n    ** with version 3.7.0, we changed this so that sqlite3_reset() would\n    ** be called automatically instead of throwing the SQLITE_MISUSE error.\n    ** This \"automatic-reset\" change is not technically an incompatibility, \n    ** since any application that receives an SQLITE_MISUSE is broken by\n    ** definition.\n    **\n    ** Nevertheless, some published applications that were originally written\n    ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE \n    ** returns, and those were broken by the automatic-reset change.  As a\n    ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the\n    ** legacy behavior of returning SQLITE_MISUSE for cases where the \n    ** previous sqlite3_step() returned something other than a SQLITE_LOCKED\n    ** or SQLITE_BUSY error.\n    */\n#ifdef SQLITE_OMIT_AUTORESET\n    if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){\n      sqlite3_reset((sqlite3_stmt*)p);\n    }else{\n      return SQLITE_MISUSE_BKPT;\n    }\n#else\n    sqlite3_reset((sqlite3_stmt*)p);\n#endif\n  }\n\n  /* Check that malloc() has not failed. If it has, return early. */\n  db = p->db;\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n    return SQLITE_NOMEM;\n  }\n\n  if( p->pc<=0 && p->expired ){\n    p->rc = SQLITE_SCHEMA;\n    rc = SQLITE_ERROR;\n    goto end_of_step;\n  }\n  if( p->pc<0 ){\n    /* If there are no other statements currently running, then\n    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt\n    ** from interrupting a statement that has not yet started.\n    */\n    if( db->activeVdbeCnt==0 ){\n      db->u1.isInterrupted = 0;\n    }\n\n    assert( db->writeVdbeCnt>0 || db->autoCommit==0 || db->nDeferredCons==0 );\n\n#ifndef SQLITE_OMIT_TRACE\n    if( db->xProfile && !db->init.busy ){\n      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);\n    }\n#endif\n\n    db->activeVdbeCnt++;\n    if( p->readOnly==0 ) db->writeVdbeCnt++;\n    p->pc = 0;\n  }\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( p->explain ){\n    rc = sqlite3VdbeList(p);\n  }else\n#endif /* SQLITE_OMIT_EXPLAIN */\n  {\n    db->vdbeExecCnt++;\n    rc = sqlite3VdbeExec(p);\n    db->vdbeExecCnt--;\n  }\n\n#ifndef SQLITE_OMIT_TRACE\n  /* Invoke the profile callback if there is one\n  */\n  if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){\n    sqlite3_int64 iNow;\n    sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);\n    db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);\n  }\n#endif\n\n  if( rc==SQLITE_DONE ){\n    assert( p->rc==SQLITE_OK );\n    p->rc = doWalCallbacks(db);\n    if( p->rc!=SQLITE_OK ){\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  db->errCode = rc;\n  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){\n    p->rc = SQLITE_NOMEM;\n  }\nend_of_step:\n  /* At this point local variable rc holds the value that should be \n  ** returned if this statement was compiled using the legacy \n  ** sqlite3_prepare() interface. According to the docs, this can only\n  ** be one of the values in the first assert() below. Variable p->rc \n  ** contains the value that would be returned if sqlite3_finalize() \n  ** were called on statement p.\n  */\n  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR \n       || rc==SQLITE_BUSY || rc==SQLITE_MISUSE\n  );\n  assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );\n  if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){\n    /* If this statement was prepared using sqlite3_prepare_v2(), and an\n    ** error has occurred, then return the error code in p->rc to the\n    ** caller. Set the error code in the database handle to the same value.\n    */ \n    rc = sqlite3VdbeTransferError(p);\n  }\n  return (rc&db->errMask);\n}\n\n/*\n** This is the top-level implementation of sqlite3_step().  Call\n** sqlite3Step() to do most of the work.  If a schema error occurs,\n** call sqlite3Reprepare() and try again.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){\n  int rc = SQLITE_OK;      /* Result from sqlite3Step() */\n  int rc2 = SQLITE_OK;     /* Result from sqlite3Reprepare() */\n  Vdbe *v = (Vdbe*)pStmt;  /* the prepared statement */\n  int cnt = 0;             /* Counter to prevent infinite loop of reprepares */\n  sqlite3 *db;             /* The database connection */\n\n  if( vdbeSafetyNotNull(v) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  db = v->db;\n  sqlite3_mutex_enter(db->mutex);\n  v->doingRerun = 0;\n  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA\n         && cnt++ < SQLITE_MAX_SCHEMA_RETRY\n         && (rc2 = rc = sqlite3Reprepare(v))==SQLITE_OK ){\n    sqlite3_reset(pStmt);\n    v->doingRerun = 1;\n    assert( v->expired==0 );\n  }\n  if( rc2!=SQLITE_OK && ALWAYS(v->isPrepareV2) && ALWAYS(db->pErr) ){\n    /* This case occurs after failing to recompile an sql statement. \n    ** The error message from the SQL compiler has already been loaded \n    ** into the database handle. This block copies the error message \n    ** from the database handle into the statement and sets the statement\n    ** program counter to 0 to ensure that when the statement is \n    ** finalized or reset the parser error message is available via\n    ** sqlite3_errmsg() and sqlite3_errcode().\n    */\n    const char *zErr = (const char *)sqlite3_value_text(db->pErr); \n    sqlite3DbFree(db, v->zErrMsg);\n    if( !db->mallocFailed ){\n      v->zErrMsg = sqlite3DbStrDup(db, zErr);\n      v->rc = rc2;\n    } else {\n      v->zErrMsg = 0;\n      v->rc = rc = SQLITE_NOMEM;\n    }\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context *p){\n  assert( p && p->pFunc );\n  return p->pFunc->pUserData;\n}\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n**\n** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface\n** returns a copy of the pointer to the database connection (the 1st\n** parameter) of the sqlite3_create_function() and\n** sqlite3_create_function16() routines that originally registered the\n** application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){\n  assert( p && p->pFunc );\n  return p->s.db;\n}\n\n/*\n** The following is the implementation of an SQL function that always\n** fails with an error message stating that the function is used in the\n** wrong context.  The sqlite3_overload_function() API might construct\n** SQL function that use this routine so that the functions will exist\n** for name resolution but are actually overloaded by the xFindFunction\n** method of virtual tables.\n*/\nSQLITE_PRIVATE void sqlite3InvalidFunction(\n  sqlite3_context *context,  /* The function calling context */\n  int NotUsed,               /* Number of arguments to the function */\n  sqlite3_value **NotUsed2   /* Value of each argument */\n){\n  const char *zName = context->pFunc->zName;\n  char *zErr;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  zErr = sqlite3_mprintf(\n      \"unable to use function %s in the requested context\", zName);\n  sqlite3_result_error(context, zErr, -1);\n  sqlite3_free(zErr);\n}\n\n/*\n** Allocate or return the aggregate context for a user function.  A new\n** context is allocated on the first call.  Subsequent calls return the\n** same context that was returned on prior calls.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){\n  Mem *pMem;\n  assert( p && p->pFunc && p->pFunc->xStep );\n  assert( sqlite3_mutex_held(p->s.db->mutex) );\n  pMem = p->pMem;\n  testcase( nByte<0 );\n  if( (pMem->flags & MEM_Agg)==0 ){\n    if( nByte<=0 ){\n      sqlite3VdbeMemReleaseExternal(pMem);\n      pMem->flags = MEM_Null;\n      pMem->z = 0;\n    }else{\n      sqlite3VdbeMemGrow(pMem, nByte, 0);\n      pMem->flags = MEM_Agg;\n      pMem->u.pDef = p->pFunc;\n      if( pMem->z ){\n        memset(pMem->z, 0, nByte);\n      }\n    }\n  }\n  return (void*)pMem->z;\n}\n\n/*\n** Return the auxilary data pointer, if any, for the iArg'th argument to\n** the user-function defined by pCtx.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){\n  VdbeFunc *pVdbeFunc;\n\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  pVdbeFunc = pCtx->pVdbeFunc;\n  if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){\n    return 0;\n  }\n  return pVdbeFunc->apAux[iArg].pAux;\n}\n\n/*\n** Set the auxilary data pointer and delete function, for the iArg'th\n** argument to the user-function defined by pCtx. Any previous value is\n** deleted by calling the delete function specified when it was set.\n*/\nSQLITE_API void sqlite3_set_auxdata(\n  sqlite3_context *pCtx, \n  int iArg, \n  void *pAux, \n  void (*xDelete)(void*)\n){\n  struct AuxData *pAuxData;\n  VdbeFunc *pVdbeFunc;\n  if( iArg<0 ) goto failed;\n\n  assert( sqlite3_mutex_held(pCtx->s.db->mutex) );\n  pVdbeFunc = pCtx->pVdbeFunc;\n  if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){\n    int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);\n    int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;\n    pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc);\n    if( !pVdbeFunc ){\n      goto failed;\n    }\n    pCtx->pVdbeFunc = pVdbeFunc;\n    memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));\n    pVdbeFunc->nAux = iArg+1;\n    pVdbeFunc->pFunc = pCtx->pFunc;\n  }\n\n  pAuxData = &pVdbeFunc->apAux[iArg];\n  if( pAuxData->pAux && pAuxData->xDelete ){\n    pAuxData->xDelete(pAuxData->pAux);\n  }\n  pAuxData->pAux = pAux;\n  pAuxData->xDelete = xDelete;\n  return;\n\nfailed:\n  if( xDelete ){\n    xDelete(pAux);\n  }\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return the number of times the Step function of a aggregate has been \n** called.\n**\n** This function is deprecated.  Do not use it for new code.  It is\n** provide only to avoid breaking legacy code.  New aggregate function\n** implementations should keep their own counts within their aggregate\n** context.\n*/\nSQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){\n  assert( p && p->pMem && p->pFunc && p->pFunc->xStep );\n  return p->pMem->n;\n}\n#endif\n\n/*\n** Return the number of columns in the result set for the statement pStmt.\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  return pVm ? pVm->nResColumn : 0;\n}\n\n/*\n** Return the number of values available from the current row of the\n** currently executing statement pStmt.\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  if( pVm==0 || pVm->pResultSet==0 ) return 0;\n  return pVm->nResColumn;\n}\n\n\n/*\n** Check to see if column iCol of the given statement is valid.  If\n** it is, return a pointer to the Mem for the value of that column.\n** If iCol is not valid, return a pointer to a Mem which has a value\n** of NULL.\n*/\nstatic Mem *columnMem(sqlite3_stmt *pStmt, int i){\n  Vdbe *pVm;\n  Mem *pOut;\n\n  pVm = (Vdbe *)pStmt;\n  if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){\n    sqlite3_mutex_enter(pVm->db->mutex);\n    pOut = &pVm->pResultSet[i];\n  }else{\n    /* If the value passed as the second argument is out of range, return\n    ** a pointer to the following static Mem object which contains the\n    ** value SQL NULL. Even though the Mem structure contains an element\n    ** of type i64, on certain architectures (x86) with certain compiler\n    ** switches (-Os), gcc may align this Mem object on a 4-byte boundary\n    ** instead of an 8-byte one. This all works fine, except that when\n    ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s\n    ** that a Mem structure is located on an 8-byte boundary. To prevent\n    ** these assert()s from failing, when building with SQLITE_DEBUG defined\n    ** using gcc, we force nullMem to be 8-byte aligned using the magical\n    ** __attribute__((aligned(8))) macro.  */\n    static const Mem nullMem \n#if defined(SQLITE_DEBUG) && defined(__GNUC__)\n      __attribute__((aligned(8))) \n#endif\n      = {0, \"\", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0,\n#ifdef SQLITE_DEBUG\n         0, 0,  /* pScopyFrom, pFiller */\n#endif\n         0, 0 };\n\n    if( pVm && ALWAYS(pVm->db) ){\n      sqlite3_mutex_enter(pVm->db->mutex);\n      sqlite3Error(pVm->db, SQLITE_RANGE, 0);\n    }\n    pOut = (Mem*)&nullMem;\n  }\n  return pOut;\n}\n\n/*\n** This function is called after invoking an sqlite3_value_XXX function on a \n** column value (i.e. a value returned by evaluating an SQL expression in the\n** select list of a SELECT statement) that may cause a malloc() failure. If \n** malloc() has failed, the threads mallocFailed flag is cleared and the result\n** code of statement pStmt set to SQLITE_NOMEM.\n**\n** Specifically, this is called from within:\n**\n**     sqlite3_column_int()\n**     sqlite3_column_int64()\n**     sqlite3_column_text()\n**     sqlite3_column_text16()\n**     sqlite3_column_real()\n**     sqlite3_column_bytes()\n**     sqlite3_column_bytes16()\n**     sqiite3_column_blob()\n*/\nstatic void columnMallocFailure(sqlite3_stmt *pStmt)\n{\n  /* If malloc() failed during an encoding conversion within an\n  ** sqlite3_column_XXX API, then set the return code of the statement to\n  ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR\n  ** and _finalize() will return NOMEM.\n  */\n  Vdbe *p = (Vdbe *)pStmt;\n  if( p ){\n    p->rc = sqlite3ApiExit(p->db, p->rc);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n}\n\n/**************************** sqlite3_column_  *******************************\n** The following routines are used to access elements of the current row\n** in the result set.\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){\n  const void *val;\n  val = sqlite3_value_blob( columnMem(pStmt,i) );\n  /* Even though there is no encoding conversion, value_blob() might\n  ** need to call malloc() to expand the result of a zeroblob() \n  ** expression. \n  */\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){\n  double val = sqlite3_value_double( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_int( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){\n  sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){\n  const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){\n  Mem *pOut = columnMem(pStmt, i);\n  if( pOut->flags&MEM_Static ){\n    pOut->flags &= ~MEM_Static;\n    pOut->flags |= MEM_Ephem;\n  }\n  columnMallocFailure(pStmt);\n  return (sqlite3_value *)pOut;\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){\n  const void *val = sqlite3_value_text16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){\n  int iType = sqlite3_value_type( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return iType;\n}\n\n/* The following function is experimental and subject to change or\n** removal */\n/*int sqlite3_column_numeric_type(sqlite3_stmt *pStmt, int i){\n**  return sqlite3_value_numeric_type( columnMem(pStmt,i) );\n**}\n*/\n\n/*\n** Convert the N-th element of pStmt->pColName[] into a string using\n** xFunc() then return that string.  If N is out of range, return 0.\n**\n** There are up to 5 names for each column.  useType determines which\n** name is returned.  Here are the names:\n**\n**    0      The column name as it should be displayed for output\n**    1      The datatype name for the column\n**    2      The name of the database that the column derives from\n**    3      The name of the table that the column derives from\n**    4      The name of the table column that the result column derives from\n**\n** If the result is not a simple column reference (if it is an expression\n** or a constant) then useTypes 2, 3, and 4 return NULL.\n*/\nstatic const void *columnName(\n  sqlite3_stmt *pStmt,\n  int N,\n  const void *(*xFunc)(Mem*),\n  int useType\n){\n  const void *ret = 0;\n  Vdbe *p = (Vdbe *)pStmt;\n  int n;\n  sqlite3 *db = p->db;\n  \n  assert( db!=0 );\n  n = sqlite3_column_count(pStmt);\n  if( N<n && N>=0 ){\n    N += useType*n;\n    sqlite3_mutex_enter(db->mutex);\n    assert( db->mallocFailed==0 );\n    ret = xFunc(&p->aColName[N]);\n     /* A malloc may have failed inside of the xFunc() call. If this\n    ** is the case, clear the mallocFailed flag and return NULL.\n    */\n    if( db->mallocFailed ){\n      db->mallocFailed = 0;\n      ret = 0;\n    }\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return ret;\n}\n\n/*\n** Return the name of the Nth column of the result set returned by SQL\n** statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);\n}\n#endif\n\n/*\n** Constraint:  If you have ENABLE_COLUMN_METADATA then you must\n** not define OMIT_DECLTYPE.\n*/\n#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METADATA)\n# error \"Must not define both SQLITE_OMIT_DECLTYPE \\\n         and SQLITE_ENABLE_COLUMN_METADATA\"\n#endif\n\n#ifndef SQLITE_OMIT_DECLTYPE\n/*\n** Return the column declaration type (if applicable) of the 'i'th column\n** of the result set of SQL statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_DECLTYPE */\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n/*\n** Return the name of the database from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unabiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unabiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table column from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unabiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_ENABLE_COLUMN_METADATA */\n\n\n/******************************* sqlite3_bind_  ***************************\n** \n** Routines used to attach values to wildcards in a compiled SQL statement.\n*/\n/*\n** Unbind the value bound to variable i in virtual machine p. This is the \n** the same as binding a NULL value to the column. If the \"i\" parameter is\n** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK.\n**\n** A successful evaluation of this routine acquires the mutex on p.\n** the mutex is released if any kind of error occurs.\n**\n** The error code stored in database p->db is overwritten with the return\n** value in any case.\n*/\nstatic int vdbeUnbind(Vdbe *p, int i){\n  Mem *pVar;\n  if( vdbeSafetyNotNull(p) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(p->db->mutex);\n  if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){\n    sqlite3Error(p->db, SQLITE_MISUSE, 0);\n    sqlite3_mutex_leave(p->db->mutex);\n    sqlite3_log(SQLITE_MISUSE, \n        \"bind on a busy prepared statement: [%s]\", p->zSql);\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( i<1 || i>p->nVar ){\n    sqlite3Error(p->db, SQLITE_RANGE, 0);\n    sqlite3_mutex_leave(p->db->mutex);\n    return SQLITE_RANGE;\n  }\n  i--;\n  pVar = &p->aVar[i];\n  sqlite3VdbeMemRelease(pVar);\n  pVar->flags = MEM_Null;\n  sqlite3Error(p->db, SQLITE_OK, 0);\n\n  /* If the bit corresponding to this variable in Vdbe.expmask is set, then \n  ** binding a new value to this variable invalidates the current query plan.\n  **\n  ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host\n  ** parameter in the WHERE clause might influence the choice of query plan\n  ** for a statement, then the statement will be automatically recompiled,\n  ** as if there had been a schema change, on the first sqlite3_step() call\n  ** following any change to the bindings of that parameter.\n  */\n  if( p->isPrepareV2 &&\n     ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)\n  ){\n    p->expired = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Bind a text or BLOB value.\n*/\nstatic int bindText(\n  sqlite3_stmt *pStmt,   /* The statement to bind against */\n  int i,                 /* Index of the parameter to bind */\n  const void *zData,     /* Pointer to the data to be bound */\n  int nData,             /* Number of bytes of data to be bound */\n  void (*xDel)(void*),   /* Destructor for the data */\n  u8 encoding            /* Encoding for the data */\n){\n  Vdbe *p = (Vdbe *)pStmt;\n  Mem *pVar;\n  int rc;\n\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    if( zData!=0 ){\n      pVar = &p->aVar[i-1];\n      rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);\n      if( rc==SQLITE_OK && encoding!=0 ){\n        rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));\n      }\n      sqlite3Error(p->db, rc, 0);\n      rc = sqlite3ApiExit(p->db, rc);\n    }\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){\n    xDel((void*)zData);\n  }\n  return rc;\n}\n\n\n/*\n** Bind a blob value to an SQL statement variable.\n*/\nSQLITE_API int sqlite3_bind_blob(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, 0);\n}\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){\n  return sqlite3_bind_int64(p, i, (i64)iValue);\n}\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_text( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_bind_text16(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){\n  int rc;\n  switch( pValue->type ){\n    case SQLITE_INTEGER: {\n      rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);\n      break;\n    }\n    case SQLITE_FLOAT: {\n      rc = sqlite3_bind_double(pStmt, i, pValue->r);\n      break;\n    }\n    case SQLITE_BLOB: {\n      if( pValue->flags & MEM_Zero ){\n        rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);\n      }else{\n        rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      rc = bindText(pStmt,i,  pValue->z, pValue->n, SQLITE_TRANSIENT,\n                              pValue->enc);\n      break;\n    }\n    default: {\n      rc = sqlite3_bind_null(pStmt, i);\n      break;\n    }\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\n\n/*\n** Return the number of wildcards that can be potentially bound to.\n** This routine is added to support DBD::SQLite.  \n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p ? p->nVar : 0;\n}\n\n/*\n** Return the name of a wildcard parameter.  Return NULL if the index\n** is out of range or if the wildcard is unnamed.\n**\n** The result is always UTF-8.\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){\n  Vdbe *p = (Vdbe*)pStmt;\n  if( p==0 || i<1 || i>p->nzVar ){\n    return 0;\n  }\n  return p->azVar[i-1];\n}\n\n/*\n** Given a wildcard parameter name, return the index of the variable\n** with that name.  If there is no variable with the given name,\n** return 0.\n*/\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){\n  int i;\n  if( p==0 ){\n    return 0;\n  }\n  if( zName ){\n    for(i=0; i<p->nzVar; i++){\n      const char *z = p->azVar[i];\n      if( z && strncmp(z,zName,nName)==0 && z[nName]==0 ){\n        return i+1;\n      }\n    }\n  }\n  return 0;\n}\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){\n  return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));\n}\n\n/*\n** Transfer all bindings from the first statement over to the second.\n*/\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  int i;\n  assert( pTo->db==pFrom->db );\n  assert( pTo->nVar==pFrom->nVar );\n  sqlite3_mutex_enter(pTo->db->mutex);\n  for(i=0; i<pFrom->nVar; i++){\n    sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);\n  }\n  sqlite3_mutex_leave(pTo->db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  Internal/core SQLite code\n** should call sqlite3TransferBindings.\n**\n** Is is misuse to call this routine with statements from different\n** database connections.  But as this is a deprecated interface, we\n** will not bother to check for that condition.\n**\n** If the two statements contain a different number of bindings, then\n** an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise\n** SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  if( pFrom->nVar!=pTo->nVar ){\n    return SQLITE_ERROR;\n  }\n  if( pTo->isPrepareV2 && pTo->expmask ){\n    pTo->expired = 1;\n  }\n  if( pFrom->isPrepareV2 && pFrom->expmask ){\n    pFrom->expired = 1;\n  }\n  return sqlite3TransferBindings(pFromStmt, pToStmt);\n}\n#endif\n\n/*\n** Return the sqlite3* database handle to which the prepared statement given\n** in the argument belongs.  This is the same database handle that was\n** the first argument to the sqlite3_prepare() that was used to create\n** the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->db : 0;\n}\n\n/*\n** Return true if the prepared statement is guaranteed to not modify the\n** database.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;\n}\n\n/*\n** Return true if the prepared statement is in need of being reset.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){\n  Vdbe *v = (Vdbe*)pStmt;\n  return v!=0 && v->pc>0 && v->magic==VDBE_MAGIC_RUN;\n}\n\n/*\n** Return a pointer to the next prepared statement after pStmt associated\n** with database connection pDb.  If pStmt is NULL, return the first\n** prepared statement for the database connection.  Return NULL if there\n** are no more.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){\n  sqlite3_stmt *pNext;\n  sqlite3_mutex_enter(pDb->mutex);\n  if( pStmt==0 ){\n    pNext = (sqlite3_stmt*)pDb->pVdbe;\n  }else{\n    pNext = (sqlite3_stmt*)((Vdbe*)pStmt)->pNext;\n  }\n  sqlite3_mutex_leave(pDb->mutex);\n  return pNext;\n}\n\n/*\n** Return the value of a status counter for a prepared statement\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){\n  Vdbe *pVdbe = (Vdbe*)pStmt;\n  int v = pVdbe->aCounter[op-1];\n  if( resetFlag ) pVdbe->aCounter[op-1] = 0;\n  return v;\n}\n\n/************** End of vdbeapi.c *********************************************/\n/************** Begin file vdbetrace.c ***************************************/\n/*\n** 2009 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to insert the values of host parameters\n** (aka \"wildcards\") into the SQL text output by sqlite3_trace().\n**\n** The Vdbe parse-tree explainer is also found here.\n*/\n\n#ifndef SQLITE_OMIT_TRACE\n\n/*\n** zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of\n** bytes in this text up to but excluding the first character in\n** a host parameter.  If the text contains no host parameters, return\n** the total number of bytes in the text.\n*/\nstatic int findNextHostParameter(const char *zSql, int *pnToken){\n  int tokenType;\n  int nTotal = 0;\n  int n;\n\n  *pnToken = 0;\n  while( zSql[0] ){\n    n = sqlite3GetToken((u8*)zSql, &tokenType);\n    assert( n>0 && tokenType!=TK_ILLEGAL );\n    if( tokenType==TK_VARIABLE ){\n      *pnToken = n;\n      break;\n    }\n    nTotal += n;\n    zSql += n;\n  }\n  return nTotal;\n}\n\n/*\n** This function returns a pointer to a nul-terminated string in memory\n** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the\n** string contains a copy of zRawSql but with host parameters expanded to \n** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1, \n** then the returned string holds a copy of zRawSql with \"-- \" prepended\n** to each line of text.\n**\n** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then\n** then long strings and blobs are truncated to that many bytes.  This\n** can be used to prevent unreasonably large trace strings when dealing\n** with large (multi-megabyte) strings and blobs.\n**\n** The calling function is responsible for making sure the memory returned\n** is eventually freed.\n**\n** ALGORITHM:  Scan the input string looking for host parameters in any of\n** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within\n** string literals, quoted identifier names, and comments.  For text forms,\n** the host parameter index is found by scanning the perpared\n** statement for the corresponding OP_Variable opcode.  Once the host\n** parameter index is known, locate the value in p->aVar[].  Then render\n** the value as a literal in place of the host parameter name.\n*/\nSQLITE_PRIVATE char *sqlite3VdbeExpandSql(\n  Vdbe *p,                 /* The prepared statement being evaluated */\n  const char *zRawSql      /* Raw text of the SQL statement */\n){\n  sqlite3 *db;             /* The database connection */\n  int idx = 0;             /* Index of a host parameter */\n  int nextIndex = 1;       /* Index of next ? host parameter */\n  int n;                   /* Length of a token prefix */\n  int nToken;              /* Length of the parameter token */\n  int i;                   /* Loop counter */\n  Mem *pVar;               /* Value of a host parameter */\n  StrAccum out;            /* Accumulate the output here */\n  char zBase[100];         /* Initial working space */\n\n  db = p->db;\n  sqlite3StrAccumInit(&out, zBase, sizeof(zBase), \n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  out.db = db;\n  if( db->vdbeExecCnt>1 ){\n    while( *zRawSql ){\n      const char *zStart = zRawSql;\n      while( *(zRawSql++)!='\\n' && *zRawSql );\n      sqlite3StrAccumAppend(&out, \"-- \", 3);\n      sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));\n    }\n  }else{\n    while( zRawSql[0] ){\n      n = findNextHostParameter(zRawSql, &nToken);\n      assert( n>0 );\n      sqlite3StrAccumAppend(&out, zRawSql, n);\n      zRawSql += n;\n      assert( zRawSql[0] || nToken==0 );\n      if( nToken==0 ) break;\n      if( zRawSql[0]=='?' ){\n        if( nToken>1 ){\n          assert( sqlite3Isdigit(zRawSql[1]) );\n          sqlite3GetInt32(&zRawSql[1], &idx);\n        }else{\n          idx = nextIndex;\n        }\n      }else{\n        assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );\n        testcase( zRawSql[0]==':' );\n        testcase( zRawSql[0]=='$' );\n        testcase( zRawSql[0]=='@' );\n        idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);\n        assert( idx>0 );\n      }\n      zRawSql += nToken;\n      nextIndex = idx + 1;\n      assert( idx>0 && idx<=p->nVar );\n      pVar = &p->aVar[idx-1];\n      if( pVar->flags & MEM_Null ){\n        sqlite3StrAccumAppend(&out, \"NULL\", 4);\n      }else if( pVar->flags & MEM_Int ){\n        sqlite3XPrintf(&out, \"%lld\", pVar->u.i);\n      }else if( pVar->flags & MEM_Real ){\n        sqlite3XPrintf(&out, \"%!.15g\", pVar->r);\n      }else if( pVar->flags & MEM_Str ){\n        int nOut;  /* Number of bytes of the string text to include in output */\n#ifndef SQLITE_OMIT_UTF16\n        u8 enc = ENC(db);\n        Mem utf8;\n        if( enc!=SQLITE_UTF8 ){\n          memset(&utf8, 0, sizeof(utf8));\n          utf8.db = db;\n          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);\n          sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);\n          pVar = &utf8;\n        }\n#endif\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){\n          nOut = SQLITE_TRACE_SIZE_LIMIT;\n          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }\n        }\n#endif    \n        sqlite3XPrintf(&out, \"'%.*q'\", nOut, pVar->z);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ) sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n#endif\n#ifndef SQLITE_OMIT_UTF16\n        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);\n#endif\n      }else if( pVar->flags & MEM_Zero ){\n        sqlite3XPrintf(&out, \"zeroblob(%d)\", pVar->u.nZero);\n      }else{\n        int nOut;  /* Number of bytes of the blob to include in output */\n        assert( pVar->flags & MEM_Blob );\n        sqlite3StrAccumAppend(&out, \"x'\", 2);\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;\n#endif\n        for(i=0; i<nOut; i++){\n          sqlite3XPrintf(&out, \"%02x\", pVar->z[i]&0xff);\n        }\n        sqlite3StrAccumAppend(&out, \"'\", 1);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ) sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n#endif\n      }\n    }\n  }\n  return sqlite3StrAccumFinish(&out);\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRACE */\n\n/*****************************************************************************\n** The following code implements the data-structure explaining logic\n** for the Vdbe.\n*/\n\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n\n/*\n** Allocate a new Explain object\n*/\nSQLITE_PRIVATE void sqlite3ExplainBegin(Vdbe *pVdbe){\n  if( pVdbe ){\n    Explain *p;\n    sqlite3BeginBenignMalloc();\n    p = (Explain *)sqlite3MallocZero( sizeof(Explain) );\n    if( p ){\n      p->pVdbe = pVdbe;\n      sqlite3_free(pVdbe->pExplain);\n      pVdbe->pExplain = p;\n      sqlite3StrAccumInit(&p->str, p->zBase, sizeof(p->zBase),\n                          SQLITE_MAX_LENGTH);\n      p->str.useMalloc = 2;\n    }else{\n      sqlite3EndBenignMalloc();\n    }\n  }\n}\n\n/*\n** Return true if the Explain ends with a new-line.\n*/\nstatic int endsWithNL(Explain *p){\n  return p && p->str.zText && p->str.nChar\n           && p->str.zText[p->str.nChar-1]=='\\n';\n}\n    \n/*\n** Append text to the indentation\n*/\nSQLITE_PRIVATE void sqlite3ExplainPrintf(Vdbe *pVdbe, const char *zFormat, ...){\n  Explain *p;\n  if( pVdbe && (p = pVdbe->pExplain)!=0 ){\n    va_list ap;\n    if( p->nIndent && endsWithNL(p) ){\n      int n = p->nIndent;\n      if( n>ArraySize(p->aIndent) ) n = ArraySize(p->aIndent);\n      sqlite3AppendSpace(&p->str, p->aIndent[n-1]);\n    }   \n    va_start(ap, zFormat);\n    sqlite3VXPrintf(&p->str, 1, zFormat, ap);\n    va_end(ap);\n  }\n}\n\n/*\n** Append a '\\n' if there is not already one.\n*/\nSQLITE_PRIVATE void sqlite3ExplainNL(Vdbe *pVdbe){\n  Explain *p;\n  if( pVdbe && (p = pVdbe->pExplain)!=0 && !endsWithNL(p) ){\n    sqlite3StrAccumAppend(&p->str, \"\\n\", 1);\n  }\n}\n\n/*\n** Push a new indentation level.  Subsequent lines will be indented\n** so that they begin at the current cursor position.\n*/\nSQLITE_PRIVATE void sqlite3ExplainPush(Vdbe *pVdbe){\n  Explain *p;\n  if( pVdbe && (p = pVdbe->pExplain)!=0 ){\n    if( p->str.zText && p->nIndent<ArraySize(p->aIndent) ){\n      const char *z = p->str.zText;\n      int i = p->str.nChar-1;\n      int x;\n      while( i>=0 && z[i]!='\\n' ){ i--; }\n      x = (p->str.nChar - 1) - i;\n      if( p->nIndent && x<p->aIndent[p->nIndent-1] ){\n        x = p->aIndent[p->nIndent-1];\n      }\n      p->aIndent[p->nIndent] = x;\n    }\n    p->nIndent++;\n  }\n}\n\n/*\n** Pop the indentation stack by one level.\n*/\nSQLITE_PRIVATE void sqlite3ExplainPop(Vdbe *p){\n  if( p && p->pExplain ) p->pExplain->nIndent--;\n}\n\n/*\n** Free the indentation structure\n*/\nSQLITE_PRIVATE void sqlite3ExplainFinish(Vdbe *pVdbe){\n  if( pVdbe && pVdbe->pExplain ){\n    sqlite3_free(pVdbe->zExplain);\n    sqlite3ExplainNL(pVdbe);\n    pVdbe->zExplain = sqlite3StrAccumFinish(&pVdbe->pExplain->str);\n    sqlite3_free(pVdbe->pExplain);\n    pVdbe->pExplain = 0;\n    sqlite3EndBenignMalloc();\n  }\n}\n\n/*\n** Return the explanation of a virtual machine.\n*/\nSQLITE_PRIVATE const char *sqlite3VdbeExplanation(Vdbe *pVdbe){\n  return (pVdbe && pVdbe->zExplain) ? pVdbe->zExplain : 0;\n}\n#endif /* defined(SQLITE_DEBUG) */\n\n/************** End of vdbetrace.c *******************************************/\n/************** Begin file vdbe.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** The code in this file implements execution method of the \n** Virtual Database Engine (VDBE).  A separate file (\"vdbeaux.c\")\n** handles housekeeping details such as creating and deleting\n** VDBE instances.  This file is solely interested in executing\n** the VDBE program.\n**\n** In the external interface, an \"sqlite3_stmt*\" is an opaque pointer\n** to a VDBE.\n**\n** The SQL parser generates a program which is then executed by\n** the VDBE to do the work of the SQL statement.  VDBE programs are \n** similar in form to assembly language.  The program consists of\n** a linear sequence of operations.  Each operation has an opcode \n** and 5 operands.  Operands P1, P2, and P3 are integers.  Operand P4 \n** is a null-terminated string.  Operand P5 is an unsigned character.\n** Few opcodes use all 5 operands.\n**\n** Computation results are stored on a set of registers numbered beginning\n** with 1 and going up to Vdbe.nMem.  Each register can store\n** either an integer, a null-terminated string, a floating point\n** number, or the SQL \"NULL\" value.  An implicit conversion from one\n** type to the other occurs as necessary.\n** \n** Most of the code in this file is taken up by the sqlite3VdbeExec()\n** function which does the work of interpreting a VDBE program.\n** But other routines are also provided to help in building up\n** a program instruction by instruction.\n**\n** Various scripts scan this source file in order to generate HTML\n** documentation, headers files, or other derived files.  The formatting\n** of the code in this file is, therefore, important.  See other comments\n** in this file for details.  If in doubt, do not deviate from existing\n** commenting and indentation practices when changing or adding code.\n*/\n\n/*\n** Invoke this macro on memory cells just prior to changing the\n** value of the cell.  This macro verifies that shallow copies are\n** not misused.\n*/\n#ifdef SQLITE_DEBUG\n# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)\n#else\n# define memAboutToChange(P,M)\n#endif\n\n/*\n** The following global variable is incremented every time a cursor\n** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test\n** procedures use this information to make sure that indices are\n** working correctly.  This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_search_count = 0;\n#endif\n\n/*\n** When this global variable is positive, it gets decremented once before\n** each instruction in the VDBE.  When it reaches zero, the u1.isInterrupted\n** field of the sqlite3 structure is set in order to simulate an interrupt.\n**\n** This facility is used for testing purposes only.  It does not function\n** in an ordinary build.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_interrupt_count = 0;\n#endif\n\n/*\n** The next global variable is incremented each type the OP_Sort opcode\n** is executed.  The test procedures use this information to make sure that\n** sorting is occurring or not occurring at appropriate times.   This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_sort_count = 0;\n#endif\n\n/*\n** The next global variable records the size of the largest MEM_Blob\n** or MEM_Str that has been used by a VDBE opcode.  The test procedures\n** use this information to make sure that the zero-blob functionality\n** is working correctly.   This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_max_blobsize = 0;\nstatic void updateMaxBlobsize(Mem *p){\n  if( (p->flags & (MEM_Str|MEM_Blob))!=0 && p->n>sqlite3_max_blobsize ){\n    sqlite3_max_blobsize = p->n;\n  }\n}\n#endif\n\n/*\n** The next global variable is incremented each type the OP_Found opcode\n** is executed. This is used to test whether or not the foreign key\n** operation implemented using OP_FkIsZero is working. This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_found_count = 0;\n#endif\n\n/*\n** Test a register to see if it exceeds the current maximum blob size.\n** If it does, record the new maximum blob size.\n*/\n#if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_BUILTIN_TEST)\n# define UPDATE_MAX_BLOBSIZE(P)  updateMaxBlobsize(P)\n#else\n# define UPDATE_MAX_BLOBSIZE(P)\n#endif\n\n/*\n** Convert the given register into a string if it isn't one\n** already. Return non-zero if a malloc() fails.\n*/\n#define Stringify(P, enc) \\\n   if(((P)->flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc)) \\\n     { goto no_mem; }\n\n/*\n** An ephemeral string value (signified by the MEM_Ephem flag) contains\n** a pointer to a dynamically allocated string where some other entity\n** is responsible for deallocating that string.  Because the register\n** does not control the string, it might be deleted without the register\n** knowing it.\n**\n** This routine converts an ephemeral string into a dynamically allocated\n** string that the register itself controls.  In other words, it\n** converts an MEM_Ephem string into an MEM_Dyn string.\n*/\n#define Deephemeralize(P) \\\n   if( ((P)->flags&MEM_Ephem)!=0 \\\n       && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;}\n\n/* Return true if the cursor was opened using the OP_OpenSorter opcode. */\n# define isSorter(x) ((x)->pSorter!=0)\n\n/*\n** Argument pMem points at a register that will be passed to a\n** user-defined function or returned to the user as the result of a query.\n** This routine sets the pMem->type variable used by the sqlite3_value_*() \n** routines.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemStoreType(Mem *pMem){\n  int flags = pMem->flags;\n  if( flags & MEM_Null ){\n    pMem->type = SQLITE_NULL;\n  }\n  else if( flags & MEM_Int ){\n    pMem->type = SQLITE_INTEGER;\n  }\n  else if( flags & MEM_Real ){\n    pMem->type = SQLITE_FLOAT;\n  }\n  else if( flags & MEM_Str ){\n    pMem->type = SQLITE_TEXT;\n  }else{\n    pMem->type = SQLITE_BLOB;\n  }\n}\n\n/*\n** Allocate VdbeCursor number iCur.  Return a pointer to it.  Return NULL\n** if we run out of memory.\n*/\nstatic VdbeCursor *allocateCursor(\n  Vdbe *p,              /* The virtual machine */\n  int iCur,             /* Index of the new VdbeCursor */\n  int nField,           /* Number of fields in the table or index */\n  int iDb,              /* Database the cursor belongs to, or -1 */\n  int isBtreeCursor     /* True for B-Tree.  False for pseudo-table or vtab */\n){\n  /* Find the memory cell that will be used to store the blob of memory\n  ** required for this VdbeCursor structure. It is convenient to use a \n  ** vdbe memory cell to manage the memory allocation required for a\n  ** VdbeCursor structure for the following reasons:\n  **\n  **   * Sometimes cursor numbers are used for a couple of different\n  **     purposes in a vdbe program. The different uses might require\n  **     different sized allocations. Memory cells provide growable\n  **     allocations.\n  **\n  **   * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can\n  **     be freed lazily via the sqlite3_release_memory() API. This\n  **     minimizes the number of malloc calls made by the system.\n  **\n  ** Memory cells for cursors are allocated at the top of the address\n  ** space. Memory cell (p->nMem) corresponds to cursor 0. Space for\n  ** cursor 1 is managed by memory cell (p->nMem-1), etc.\n  */\n  Mem *pMem = &p->aMem[p->nMem-iCur];\n\n  int nByte;\n  VdbeCursor *pCx = 0;\n  nByte = \n      ROUND8(sizeof(VdbeCursor)) + \n      (isBtreeCursor?sqlite3BtreeCursorSize():0) + \n      2*nField*sizeof(u32);\n\n  assert( iCur<p->nCursor );\n  if( p->apCsr[iCur] ){\n    sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);\n    p->apCsr[iCur] = 0;\n  }\n  if( SQLITE_OK==sqlite3VdbeMemGrow(pMem, nByte, 0) ){\n    p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;\n    memset(pCx, 0, sizeof(VdbeCursor));\n    pCx->iDb = iDb;\n    pCx->nField = nField;\n    if( nField ){\n      pCx->aType = (u32 *)&pMem->z[ROUND8(sizeof(VdbeCursor))];\n    }\n    if( isBtreeCursor ){\n      pCx->pCursor = (BtCursor*)\n          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*nField*sizeof(u32)];\n      sqlite3BtreeCursorZero(pCx->pCursor);\n    }\n  }\n  return pCx;\n}\n\n/*\n** Try to convert a value into a numeric representation if we can\n** do so without loss of information.  In other words, if the string\n** looks like a number, convert it into a number.  If it does not\n** look like a number, leave it alone.\n*/\nstatic void applyNumericAffinity(Mem *pRec){\n  if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){\n    double rValue;\n    i64 iValue;\n    u8 enc = pRec->enc;\n    if( (pRec->flags&MEM_Str)==0 ) return;\n    if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;\n    if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){\n      pRec->u.i = iValue;\n      pRec->flags |= MEM_Int;\n    }else{\n      pRec->r = rValue;\n      pRec->flags |= MEM_Real;\n    }\n  }\n}\n\n/*\n** Processing is determine by the affinity parameter:\n**\n** SQLITE_AFF_INTEGER:\n** SQLITE_AFF_REAL:\n** SQLITE_AFF_NUMERIC:\n**    Try to convert pRec to an integer representation or a \n**    floating-point representation if an integer representation\n**    is not possible.  Note that the integer representation is\n**    always preferred, even if the affinity is REAL, because\n**    an integer representation is more space efficient on disk.\n**\n** SQLITE_AFF_TEXT:\n**    Convert pRec to a text representation.\n**\n** SQLITE_AFF_NONE:\n**    No-op.  pRec is unchanged.\n*/\nstatic void applyAffinity(\n  Mem *pRec,          /* The value to apply affinity to */\n  char affinity,      /* The affinity to be applied */\n  u8 enc              /* Use this text encoding */\n){\n  if( affinity==SQLITE_AFF_TEXT ){\n    /* Only attempt the conversion to TEXT if there is an integer or real\n    ** representation (blob and NULL do not get converted) but no string\n    ** representation.\n    */\n    if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){\n      sqlite3VdbeMemStringify(pRec, enc);\n    }\n    pRec->flags &= ~(MEM_Real|MEM_Int);\n  }else if( affinity!=SQLITE_AFF_NONE ){\n    assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL\n             || affinity==SQLITE_AFF_NUMERIC );\n    applyNumericAffinity(pRec);\n    if( pRec->flags & MEM_Real ){\n      sqlite3VdbeIntegerAffinity(pRec);\n    }\n  }\n}\n\n/*\n** Try to convert the type of a function argument or a result column\n** into a numeric representation.  Use either INTEGER or REAL whichever\n** is appropriate.  But only do the conversion if it is possible without\n** loss of information and return the revised type of the argument.\n*/\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){\n  Mem *pMem = (Mem*)pVal;\n  if( pMem->type==SQLITE_TEXT ){\n    applyNumericAffinity(pMem);\n    sqlite3VdbeMemStoreType(pMem);\n  }\n  return pMem->type;\n}\n\n/*\n** Exported version of applyAffinity(). This one works on sqlite3_value*, \n** not the internal Mem* type.\n*/\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(\n  sqlite3_value *pVal, \n  u8 affinity, \n  u8 enc\n){\n  applyAffinity((Mem *)pVal, affinity, enc);\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Write a nice string representation of the contents of cell pMem\n** into buffer zBuf, length nBuf.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){\n  char *zCsr = zBuf;\n  int f = pMem->flags;\n\n  static const char *const encnames[] = {\"(X)\", \"(8)\", \"(16LE)\", \"(16BE)\"};\n\n  if( f&MEM_Blob ){\n    int i;\n    char c;\n    if( f & MEM_Dyn ){\n      c = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      c = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      c = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      c = 's';\n    }\n\n    sqlite3_snprintf(100, zCsr, \"%c\", c);\n    zCsr += sqlite3Strlen30(zCsr);\n    sqlite3_snprintf(100, zCsr, \"%d[\", pMem->n);\n    zCsr += sqlite3Strlen30(zCsr);\n    for(i=0; i<16 && i<pMem->n; i++){\n      sqlite3_snprintf(100, zCsr, \"%02X\", ((int)pMem->z[i] & 0xFF));\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    for(i=0; i<16 && i<pMem->n; i++){\n      char z = pMem->z[i];\n      if( z<32 || z>126 ) *zCsr++ = '.';\n      else *zCsr++ = z;\n    }\n\n    sqlite3_snprintf(100, zCsr, \"]%s\", encnames[pMem->enc]);\n    zCsr += sqlite3Strlen30(zCsr);\n    if( f & MEM_Zero ){\n      sqlite3_snprintf(100, zCsr,\"+%dz\",pMem->u.nZero);\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    *zCsr = '\\0';\n  }else if( f & MEM_Str ){\n    int j, k;\n    zBuf[0] = ' ';\n    if( f & MEM_Dyn ){\n      zBuf[1] = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      zBuf[1] = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      zBuf[1] = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      zBuf[1] = 's';\n    }\n    k = 2;\n    sqlite3_snprintf(100, &zBuf[k], \"%d\", pMem->n);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = '[';\n    for(j=0; j<15 && j<pMem->n; j++){\n      u8 c = pMem->z[j];\n      if( c>=0x20 && c<0x7f ){\n        zBuf[k++] = c;\n      }else{\n        zBuf[k++] = '.';\n      }\n    }\n    zBuf[k++] = ']';\n    sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = 0;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the value of a register for tracing purposes:\n*/\nstatic void memTracePrint(FILE *out, Mem *p){\n  if( p->flags & MEM_Invalid ){\n    fprintf(out, \" undefined\");\n  }else if( p->flags & MEM_Null ){\n    fprintf(out, \" NULL\");\n  }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){\n    fprintf(out, \" si:%lld\", p->u.i);\n  }else if( p->flags & MEM_Int ){\n    fprintf(out, \" i:%lld\", p->u.i);\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  }else if( p->flags & MEM_Real ){\n    fprintf(out, \" r:%g\", p->r);\n#endif\n  }else if( p->flags & MEM_RowSet ){\n    fprintf(out, \" (rowset)\");\n  }else{\n    char zBuf[200];\n    sqlite3VdbeMemPrettyPrint(p, zBuf);\n    fprintf(out, \" \");\n    fprintf(out, \"%s\", zBuf);\n  }\n}\nstatic void registerTrace(FILE *out, int iReg, Mem *p){\n  fprintf(out, \"REG[%d] = \", iReg);\n  memTracePrint(out, p);\n  fprintf(out, \"\\n\");\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n#  define REGISTER_TRACE(R,M) if(p->trace)registerTrace(p->trace,R,M)\n#else\n#  define REGISTER_TRACE(R,M)\n#endif\n\n\n#ifdef VDBE_PROFILE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of vdbe.c *********************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef _HWTIME_H_\n#define _HWTIME_H_\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(_HWTIME_H_) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in vdbe.c ***********************/\n\n#endif\n\n/*\n** The CHECK_FOR_INTERRUPT macro defined here looks to see if the\n** sqlite3_interrupt() routine has been called.  If it has been, then\n** processing of the VDBE program is interrupted.\n**\n** This macro added to every instruction that does a jump in order to\n** implement a loop.  This test used to be on every single instruction,\n** but that meant we more testing than we needed.  By only testing the\n** flag on jump instructions, we get a (small) speed improvement.\n*/\n#define CHECK_FOR_INTERRUPT \\\n   if( db->u1.isInterrupted ) goto abort_due_to_interrupt;\n\n\n#ifndef NDEBUG\n/*\n** This function is only called from within an assert() expression. It\n** checks that the sqlite3.nTransaction variable is correctly set to\n** the number of non-transaction savepoints currently in the \n** linked list starting at sqlite3.pSavepoint.\n** \n** Usage:\n**\n**     assert( checkSavepointCount(db) );\n*/\nstatic int checkSavepointCount(sqlite3 *db){\n  int n = 0;\n  Savepoint *p;\n  for(p=db->pSavepoint; p; p=p->pNext) n++;\n  assert( n==(db->nSavepoint + db->isTransactionSavepoint) );\n  return 1;\n}\n#endif\n\n/*\n** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored\n** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored\n** in memory obtained from sqlite3DbMalloc).\n*/\nstatic void importVtabErrMsg(Vdbe *p, sqlite3_vtab *pVtab){\n  sqlite3 *db = p->db;\n  sqlite3DbFree(db, p->zErrMsg);\n  p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg);\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = 0;\n}\n\n\n/*\n** Execute as much of a VDBE program as we can then return.\n**\n** sqlite3VdbeMakeReady() must be called before this routine in order to\n** close the program with a final OP_Halt and to set up the callbacks\n** and the error message pointer.\n**\n** Whenever a row or result data is available, this routine will either\n** invoke the result callback (if there is one) or return with\n** SQLITE_ROW.\n**\n** If an attempt is made to open a locked database, then this routine\n** will either invoke the busy callback (if there is one) or it will\n** return SQLITE_BUSY.\n**\n** If an error occurs, an error message is written to memory obtained\n** from sqlite3_malloc() and p->zErrMsg is made to point to that memory.\n** The error code is stored in p->rc and this routine returns SQLITE_ERROR.\n**\n** If the callback ever returns non-zero, then the program exits\n** immediately.  There will be no error message but the p->rc field is\n** set to SQLITE_ABORT and this routine will return SQLITE_ERROR.\n**\n** A memory allocation error causes p->rc to be set to SQLITE_NOMEM and this\n** routine to return SQLITE_ERROR.\n**\n** Other fatal errors return SQLITE_ERROR.\n**\n** After this routine has finished, sqlite3VdbeFinalize() should be\n** used to clean up the mess that was left behind.\n*/\nSQLITE_PRIVATE int sqlite3VdbeExec(\n  Vdbe *p                    /* The VDBE */\n){\n  int pc=0;                  /* The program counter */\n  Op *aOp = p->aOp;          /* Copy of p->aOp */\n  Op *pOp;                   /* Current operation */\n  int rc = SQLITE_OK;        /* Value to return */\n  sqlite3 *db = p->db;       /* The database */\n  u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */\n  u8 encoding = ENC(db);     /* The database encoding */\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  int checkProgress;         /* True if progress callbacks are enabled */\n  int nProgressOps = 0;      /* Opcodes executed since progress callback. */\n#endif\n  Mem *aMem = p->aMem;       /* Copy of p->aMem */\n  Mem *pIn1 = 0;             /* 1st input operand */\n  Mem *pIn2 = 0;             /* 2nd input operand */\n  Mem *pIn3 = 0;             /* 3rd input operand */\n  Mem *pOut = 0;             /* Output operand */\n  int iCompare = 0;          /* Result of last OP_Compare operation */\n  int *aPermute = 0;         /* Permutation of columns for OP_Compare */\n  i64 lastRowid = db->lastRowid;  /* Saved value of the last insert ROWID */\n#ifdef VDBE_PROFILE\n  u64 start;                 /* CPU clock count at start of opcode */\n  int origPc;                /* Program counter at start of opcode */\n#endif\n  /********************************************************************\n  ** Automatically generated code\n  **\n  ** The following union is automatically generated by the\n  ** vdbe-compress.tcl script.  The purpose of this union is to\n  ** reduce the amount of stack space required by this function.\n  ** See comments in the vdbe-compress.tcl script for details.\n  */\n  union vdbeExecUnion {\n    struct OP_Yield_stack_vars {\n      int pcDest;\n    } aa;\n    struct OP_Null_stack_vars {\n      int cnt;\n      u16 nullFlag;\n    } ab;\n    struct OP_Variable_stack_vars {\n      Mem *pVar;       /* Value being transferred */\n    } ac;\n    struct OP_Move_stack_vars {\n      char *zMalloc;   /* Holding variable for allocated memory */\n      int n;           /* Number of registers left to copy */\n      int p1;          /* Register to copy from */\n      int p2;          /* Register to copy to */\n    } ad;\n    struct OP_Copy_stack_vars {\n      int n;\n    } ae;\n    struct OP_ResultRow_stack_vars {\n      Mem *pMem;\n      int i;\n    } af;\n    struct OP_Concat_stack_vars {\n      i64 nByte;\n    } ag;\n    struct OP_Remainder_stack_vars {\n      char bIntint;   /* Started out as two integer operands */\n      int flags;      /* Combined MEM_* flags from both inputs */\n      i64 iA;         /* Integer value of left operand */\n      i64 iB;         /* Integer value of right operand */\n      double rA;      /* Real value of left operand */\n      double rB;      /* Real value of right operand */\n    } ah;\n    struct OP_Function_stack_vars {\n      int i;\n      Mem *pArg;\n      sqlite3_context ctx;\n      sqlite3_value **apVal;\n      int n;\n    } ai;\n    struct OP_ShiftRight_stack_vars {\n      i64 iA;\n      u64 uA;\n      i64 iB;\n      u8 op;\n    } aj;\n    struct OP_Ge_stack_vars {\n      int res;            /* Result of the comparison of pIn1 against pIn3 */\n      char affinity;      /* Affinity to use for comparison */\n      u16 flags1;         /* Copy of initial value of pIn1->flags */\n      u16 flags3;         /* Copy of initial value of pIn3->flags */\n    } ak;\n    struct OP_Compare_stack_vars {\n      int n;\n      int i;\n      int p1;\n      int p2;\n      const KeyInfo *pKeyInfo;\n      int idx;\n      CollSeq *pColl;    /* Collating sequence to use on this term */\n      int bRev;          /* True for DESCENDING sort order */\n    } al;\n    struct OP_Or_stack_vars {\n      int v1;    /* Left operand:  0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n      int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n    } am;\n    struct OP_IfNot_stack_vars {\n      int c;\n    } an;\n    struct OP_Column_stack_vars {\n      u32 payloadSize;   /* Number of bytes in the record */\n      i64 payloadSize64; /* Number of bytes in the record */\n      int p1;            /* P1 value of the opcode */\n      int p2;            /* column number to retrieve */\n      VdbeCursor *pC;    /* The VDBE cursor */\n      char *zRec;        /* Pointer to complete record-data */\n      BtCursor *pCrsr;   /* The BTree cursor */\n      u32 *aType;        /* aType[i] holds the numeric type of the i-th column */\n      u32 *aOffset;      /* aOffset[i] is offset to start of data for i-th column */\n      int nField;        /* number of fields in the record */\n      int len;           /* The length of the serialized data for the column */\n      int i;             /* Loop counter */\n      char *zData;       /* Part of the record being decoded */\n      Mem *pDest;        /* Where to write the extracted value */\n      Mem sMem;          /* For storing the record being decoded */\n      u8 *zIdx;          /* Index into header */\n      u8 *zEndHdr;       /* Pointer to first byte after the header */\n      u32 offset;        /* Offset into the data */\n      u32 szField;       /* Number of bytes in the content of a field */\n      int szHdr;         /* Size of the header size field at start of record */\n      int avail;         /* Number of bytes of available data */\n      u32 t;             /* A type code from the record header */\n      Mem *pReg;         /* PseudoTable input register */\n    } ao;\n    struct OP_Affinity_stack_vars {\n      const char *zAffinity;   /* The affinity to be applied */\n      char cAff;               /* A single character of affinity */\n    } ap;\n    struct OP_MakeRecord_stack_vars {\n      u8 *zNewRecord;        /* A buffer to hold the data for the new record */\n      Mem *pRec;             /* The new record */\n      u64 nData;             /* Number of bytes of data space */\n      int nHdr;              /* Number of bytes of header space */\n      i64 nByte;             /* Data space required for this record */\n      int nZero;             /* Number of zero bytes at the end of the record */\n      int nVarint;           /* Number of bytes in a varint */\n      u32 serial_type;       /* Type field */\n      Mem *pData0;           /* First field to be combined into the record */\n      Mem *pLast;            /* Last field of the record */\n      int nField;            /* Number of fields in the record */\n      char *zAffinity;       /* The affinity string for the record */\n      int file_format;       /* File format to use for encoding */\n      int i;                 /* Space used in zNewRecord[] */\n      int len;               /* Length of a field */\n    } aq;\n    struct OP_Count_stack_vars {\n      i64 nEntry;\n      BtCursor *pCrsr;\n    } ar;\n    struct OP_Savepoint_stack_vars {\n      int p1;                         /* Value of P1 operand */\n      char *zName;                    /* Name of savepoint */\n      int nName;\n      Savepoint *pNew;\n      Savepoint *pSavepoint;\n      Savepoint *pTmp;\n      int iSavepoint;\n      int ii;\n    } as;\n    struct OP_AutoCommit_stack_vars {\n      int desiredAutoCommit;\n      int iRollback;\n      int turnOnAC;\n    } at;\n    struct OP_Transaction_stack_vars {\n      Btree *pBt;\n    } au;\n    struct OP_ReadCookie_stack_vars {\n      int iMeta;\n      int iDb;\n      int iCookie;\n    } av;\n    struct OP_SetCookie_stack_vars {\n      Db *pDb;\n    } aw;\n    struct OP_VerifyCookie_stack_vars {\n      int iMeta;\n      int iGen;\n      Btree *pBt;\n    } ax;\n    struct OP_OpenWrite_stack_vars {\n      int nField;\n      KeyInfo *pKeyInfo;\n      int p2;\n      int iDb;\n      int wrFlag;\n      Btree *pX;\n      VdbeCursor *pCur;\n      Db *pDb;\n    } ay;\n    struct OP_OpenEphemeral_stack_vars {\n      VdbeCursor *pCx;\n    } az;\n    struct OP_SorterOpen_stack_vars {\n      VdbeCursor *pCx;\n    } ba;\n    struct OP_OpenPseudo_stack_vars {\n      VdbeCursor *pCx;\n    } bb;\n    struct OP_SeekGt_stack_vars {\n      int res;\n      int oc;\n      VdbeCursor *pC;\n      UnpackedRecord r;\n      int nField;\n      i64 iKey;      /* The rowid we are to seek to */\n    } bc;\n    struct OP_Seek_stack_vars {\n      VdbeCursor *pC;\n    } bd;\n    struct OP_Found_stack_vars {\n      int alreadyExists;\n      VdbeCursor *pC;\n      int res;\n      char *pFree;\n      UnpackedRecord *pIdxKey;\n      UnpackedRecord r;\n      char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];\n    } be;\n    struct OP_IsUnique_stack_vars {\n      u16 ii;\n      VdbeCursor *pCx;\n      BtCursor *pCrsr;\n      u16 nField;\n      Mem *aMx;\n      UnpackedRecord r;                  /* B-Tree index search key */\n      i64 R;                             /* Rowid stored in register P3 */\n    } bf;\n    struct OP_NotExists_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      int res;\n      u64 iKey;\n    } bg;\n    struct OP_NewRowid_stack_vars {\n      i64 v;                 /* The new rowid */\n      VdbeCursor *pC;        /* Cursor of table to get the new rowid */\n      int res;               /* Result of an sqlite3BtreeLast() */\n      int cnt;               /* Counter to limit the number of searches */\n      Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */\n      VdbeFrame *pFrame;     /* Root frame of VDBE */\n    } bh;\n    struct OP_InsertInt_stack_vars {\n      Mem *pData;       /* MEM cell holding data for the record to be inserted */\n      Mem *pKey;        /* MEM cell holding key  for the record */\n      i64 iKey;         /* The integer ROWID or key for the record to be inserted */\n      VdbeCursor *pC;   /* Cursor to table into which insert is written */\n      int nZero;        /* Number of zero-bytes to append */\n      int seekResult;   /* Result of prior seek or 0 if no USESEEKRESULT flag */\n      const char *zDb;  /* database name - used by the update hook */\n      const char *zTbl; /* Table name - used by the opdate hook */\n      int op;           /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */\n    } bi;\n    struct OP_Delete_stack_vars {\n      i64 iKey;\n      VdbeCursor *pC;\n    } bj;\n    struct OP_SorterCompare_stack_vars {\n      VdbeCursor *pC;\n      int res;\n    } bk;\n    struct OP_SorterData_stack_vars {\n      VdbeCursor *pC;\n    } bl;\n    struct OP_RowData_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      u32 n;\n      i64 n64;\n    } bm;\n    struct OP_Rowid_stack_vars {\n      VdbeCursor *pC;\n      i64 v;\n      sqlite3_vtab *pVtab;\n      const sqlite3_module *pModule;\n    } bn;\n    struct OP_NullRow_stack_vars {\n      VdbeCursor *pC;\n    } bo;\n    struct OP_Last_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      int res;\n    } bp;\n    struct OP_Rewind_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      int res;\n    } bq;\n    struct OP_Next_stack_vars {\n      VdbeCursor *pC;\n      int res;\n    } br;\n    struct OP_IdxInsert_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      int nKey;\n      const char *zKey;\n    } bs;\n    struct OP_IdxDelete_stack_vars {\n      VdbeCursor *pC;\n      BtCursor *pCrsr;\n      int res;\n      UnpackedRecord r;\n    } bt;\n    struct OP_IdxRowid_stack_vars {\n      BtCursor *pCrsr;\n      VdbeCursor *pC;\n      i64 rowid;\n    } bu;\n    struct OP_IdxGE_stack_vars {\n      VdbeCursor *pC;\n      int res;\n      UnpackedRecord r;\n    } bv;\n    struct OP_Destroy_stack_vars {\n      int iMoved;\n      int iCnt;\n      Vdbe *pVdbe;\n      int iDb;\n    } bw;\n    struct OP_Clear_stack_vars {\n      int nChange;\n    } bx;\n    struct OP_CreateTable_stack_vars {\n      int pgno;\n      int flags;\n      Db *pDb;\n    } by;\n    struct OP_ParseSchema_stack_vars {\n      int iDb;\n      const char *zMaster;\n      char *zSql;\n      InitData initData;\n    } bz;\n    struct OP_IntegrityCk_stack_vars {\n      int nRoot;      /* Number of tables to check.  (Number of root pages.) */\n      int *aRoot;     /* Array of rootpage numbers for tables to be checked */\n      int j;          /* Loop counter */\n      int nErr;       /* Number of errors reported */\n      char *z;        /* Text of the error report */\n      Mem *pnErr;     /* Register keeping track of errors remaining */\n    } ca;\n    struct OP_RowSetRead_stack_vars {\n      i64 val;\n    } cb;\n    struct OP_RowSetTest_stack_vars {\n      int iSet;\n      int exists;\n    } cc;\n    struct OP_Program_stack_vars {\n      int nMem;               /* Number of memory registers for sub-program */\n      int nByte;              /* Bytes of runtime space required for sub-program */\n      Mem *pRt;               /* Register to allocate runtime space */\n      Mem *pMem;              /* Used to iterate through memory cells */\n      Mem *pEnd;              /* Last memory cell in new array */\n      VdbeFrame *pFrame;      /* New vdbe frame to execute in */\n      SubProgram *pProgram;   /* Sub-program to execute */\n      void *t;                /* Token identifying trigger */\n    } cd;\n    struct OP_Param_stack_vars {\n      VdbeFrame *pFrame;\n      Mem *pIn;\n    } ce;\n    struct OP_MemMax_stack_vars {\n      Mem *pIn1;\n      VdbeFrame *pFrame;\n    } cf;\n    struct OP_AggStep_stack_vars {\n      int n;\n      int i;\n      Mem *pMem;\n      Mem *pRec;\n      sqlite3_context ctx;\n      sqlite3_value **apVal;\n    } cg;\n    struct OP_AggFinal_stack_vars {\n      Mem *pMem;\n    } ch;\n    struct OP_Checkpoint_stack_vars {\n      int i;                          /* Loop counter */\n      int aRes[3];                    /* Results */\n      Mem *pMem;                      /* Write results here */\n    } ci;\n    struct OP_JournalMode_stack_vars {\n      Btree *pBt;                     /* Btree to change journal mode of */\n      Pager *pPager;                  /* Pager associated with pBt */\n      int eNew;                       /* New journal mode */\n      int eOld;                       /* The old journal mode */\n#ifndef SQLITE_OMIT_WAL\n      const char *zFilename;          /* Name of database file for pPager */\n#endif\n    } cj;\n    struct OP_IncrVacuum_stack_vars {\n      Btree *pBt;\n    } ck;\n    struct OP_VBegin_stack_vars {\n      VTable *pVTab;\n    } cl;\n    struct OP_VOpen_stack_vars {\n      VdbeCursor *pCur;\n      sqlite3_vtab_cursor *pVtabCursor;\n      sqlite3_vtab *pVtab;\n      sqlite3_module *pModule;\n    } cm;\n    struct OP_VFilter_stack_vars {\n      int nArg;\n      int iQuery;\n      const sqlite3_module *pModule;\n      Mem *pQuery;\n      Mem *pArgc;\n      sqlite3_vtab_cursor *pVtabCursor;\n      sqlite3_vtab *pVtab;\n      VdbeCursor *pCur;\n      int res;\n      int i;\n      Mem **apArg;\n    } cn;\n    struct OP_VColumn_stack_vars {\n      sqlite3_vtab *pVtab;\n      const sqlite3_module *pModule;\n      Mem *pDest;\n      sqlite3_context sContext;\n    } co;\n    struct OP_VNext_stack_vars {\n      sqlite3_vtab *pVtab;\n      const sqlite3_module *pModule;\n      int res;\n      VdbeCursor *pCur;\n    } cp;\n    struct OP_VRename_stack_vars {\n      sqlite3_vtab *pVtab;\n      Mem *pName;\n    } cq;\n    struct OP_VUpdate_stack_vars {\n      sqlite3_vtab *pVtab;\n      sqlite3_module *pModule;\n      int nArg;\n      int i;\n      sqlite_int64 rowid;\n      Mem **apArg;\n      Mem *pX;\n    } cr;\n    struct OP_Trace_stack_vars {\n      char *zTrace;\n      char *z;\n    } cs;\n  } u;\n  /* End automatically generated code\n  ********************************************************************/\n\n  assert( p->magic==VDBE_MAGIC_RUN );  /* sqlite3_step() verifies this */\n  sqlite3VdbeEnter(p);\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    goto no_mem;\n  }\n  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY );\n  p->rc = SQLITE_OK;\n  assert( p->explain==0 );\n  p->pResultSet = 0;\n  db->busyHandler.nBusy = 0;\n  CHECK_FOR_INTERRUPT;\n  sqlite3VdbeIOTraceSql(p);\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  checkProgress = db->xProgress!=0;\n#endif\n#ifdef SQLITE_DEBUG\n  sqlite3BeginBenignMalloc();\n  if( p->pc==0  && (p->db->flags & SQLITE_VdbeListing)!=0 ){\n    int i;\n    printf(\"VDBE Program Listing:\\n\");\n    sqlite3VdbePrintSql(p);\n    for(i=0; i<p->nOp; i++){\n      sqlite3VdbePrintOp(stdout, i, &aOp[i]);\n    }\n  }\n  sqlite3EndBenignMalloc();\n#endif\n  for(pc=p->pc; rc==SQLITE_OK; pc++){\n    assert( pc>=0 && pc<p->nOp );\n    if( db->mallocFailed ) goto no_mem;\n#ifdef VDBE_PROFILE\n    origPc = pc;\n    start = sqlite3Hwtime();\n#endif\n    pOp = &aOp[pc];\n\n    /* Only allow tracing if SQLITE_DEBUG is defined.\n    */\n#ifdef SQLITE_DEBUG\n    if( p->trace ){\n      if( pc==0 ){\n        printf(\"VDBE Execution Trace:\\n\");\n        sqlite3VdbePrintSql(p);\n      }\n      sqlite3VdbePrintOp(p->trace, pc, pOp);\n    }\n#endif\n      \n\n    /* Check to see if we need to simulate an interrupt.  This only happens\n    ** if we have a special test build.\n    */\n#ifdef SQLITE_TEST\n    if( sqlite3_interrupt_count>0 ){\n      sqlite3_interrupt_count--;\n      if( sqlite3_interrupt_count==0 ){\n        sqlite3_interrupt(db);\n      }\n    }\n#endif\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n    /* Call the progress callback if it is configured and the required number\n    ** of VDBE ops have been executed (either since this invocation of\n    ** sqlite3VdbeExec() or since last time the progress callback was called).\n    ** If the progress callback returns non-zero, exit the virtual machine with\n    ** a return code SQLITE_ABORT.\n    */\n    if( checkProgress ){\n      if( db->nProgressOps==nProgressOps ){\n        int prc;\n        prc = db->xProgress(db->pProgressArg);\n        if( prc!=0 ){\n          rc = SQLITE_INTERRUPT;\n          goto vdbe_error_halt;\n        }\n        nProgressOps = 0;\n      }\n      nProgressOps++;\n    }\n#endif\n\n    /* On any opcode with the \"out2-prerelease\" tag, free any\n    ** external allocations out of mem[p2] and set mem[p2] to be\n    ** an undefined integer.  Opcodes will either fill in the integer\n    ** value or convert mem[p2] to a different type.\n    */\n    assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );\n    if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){\n      assert( pOp->p2>0 );\n      assert( pOp->p2<=p->nMem );\n      pOut = &aMem[pOp->p2];\n      memAboutToChange(p, pOut);\n      VdbeMemRelease(pOut);\n      pOut->flags = MEM_Int;\n    }\n\n    /* Sanity checking on other operands */\n#ifdef SQLITE_DEBUG\n    if( (pOp->opflags & OPFLG_IN1)!=0 ){\n      assert( pOp->p1>0 );\n      assert( pOp->p1<=p->nMem );\n      assert( memIsValid(&aMem[pOp->p1]) );\n      REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);\n    }\n    if( (pOp->opflags & OPFLG_IN2)!=0 ){\n      assert( pOp->p2>0 );\n      assert( pOp->p2<=p->nMem );\n      assert( memIsValid(&aMem[pOp->p2]) );\n      REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);\n    }\n    if( (pOp->opflags & OPFLG_IN3)!=0 ){\n      assert( pOp->p3>0 );\n      assert( pOp->p3<=p->nMem );\n      assert( memIsValid(&aMem[pOp->p3]) );\n      REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);\n    }\n    if( (pOp->opflags & OPFLG_OUT2)!=0 ){\n      assert( pOp->p2>0 );\n      assert( pOp->p2<=p->nMem );\n      memAboutToChange(p, &aMem[pOp->p2]);\n    }\n    if( (pOp->opflags & OPFLG_OUT3)!=0 ){\n      assert( pOp->p3>0 );\n      assert( pOp->p3<=p->nMem );\n      memAboutToChange(p, &aMem[pOp->p3]);\n    }\n#endif\n  \n    switch( pOp->opcode ){\n\n/*****************************************************************************\n** What follows is a massive switch statement where each case implements a\n** separate instruction in the virtual machine.  If we follow the usual\n** indentation conventions, each case should be indented by 6 spaces.  But\n** that is a lot of wasted space on the left margin.  So the code within\n** the switch statement will break with convention and be flush-left. Another\n** big comment (similar to this one) will mark the point in the code where\n** we transition back to normal indentation.\n**\n** The formatting of each case is important.  The makefile for SQLite\n** generates two C files \"opcodes.h\" and \"opcodes.c\" by scanning this\n** file looking for lines that begin with \"case OP_\".  The opcodes.h files\n** will be filled with #defines that give unique integer values to each\n** opcode and the opcodes.c file is filled with an array of strings where\n** each string is the symbolic name for the corresponding opcode.  If the\n** case statement is followed by a comment of the form \"/# same as ... #/\"\n** that comment is used to determine the particular value of the opcode.\n**\n** Other keywords in the comment that follows each case are used to\n** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].\n** Keywords include: in1, in2, in3, out2_prerelease, out2, out3.  See\n** the mkopcodeh.awk script for additional information.\n**\n** Documentation about VDBE opcodes is generated by scanning this file\n** for lines of that contain \"Opcode:\".  That line and all subsequent\n** comment lines are used in the generation of the opcode.html documentation\n** file.\n**\n** SUMMARY:\n**\n**     Formatting is important to scripts that scan this file.\n**     Do not deviate from the formatting style currently in use.\n**\n*****************************************************************************/\n\n/* Opcode:  Goto * P2 * * *\n**\n** An unconditional jump to address P2.\n** The next instruction executed will be \n** the one at index P2 from the beginning of\n** the program.\n*/\ncase OP_Goto: {             /* jump */\n  CHECK_FOR_INTERRUPT;\n  pc = pOp->p2 - 1;\n  break;\n}\n\n/* Opcode:  Gosub P1 P2 * * *\n**\n** Write the current address onto register P1\n** and then jump to address P2.\n*/\ncase OP_Gosub: {            /* jump */\n  assert( pOp->p1>0 && pOp->p1<=p->nMem );\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Dyn)==0 );\n  memAboutToChange(p, pIn1);\n  pIn1->flags = MEM_Int;\n  pIn1->u.i = pc;\n  REGISTER_TRACE(pOp->p1, pIn1);\n  pc = pOp->p2 - 1;\n  break;\n}\n\n/* Opcode:  Return P1 * * * *\n**\n** Jump to the next instruction after the address in register P1.\n*/\ncase OP_Return: {           /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags & MEM_Int );\n  pc = (int)pIn1->u.i;\n  break;\n}\n\n/* Opcode:  Yield P1 * * * *\n**\n** Swap the program counter with the value in register P1.\n*/\ncase OP_Yield: {            /* in1 */\n#if 0  /* local variables moved into u.aa */\n  int pcDest;\n#endif /* local variables moved into u.aa */\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Dyn)==0 );\n  pIn1->flags = MEM_Int;\n  u.aa.pcDest = (int)pIn1->u.i;\n  pIn1->u.i = pc;\n  REGISTER_TRACE(pOp->p1, pIn1);\n  pc = u.aa.pcDest;\n  break;\n}\n\n/* Opcode:  HaltIfNull  P1 P2 P3 P4 *\n**\n** Check the value in register P3.  If it is NULL then Halt using\n** parameter P1, P2, and P4 as if this were a Halt instruction.  If the\n** value in register P3 is not NULL, then this routine is a no-op.\n*/\ncase OP_HaltIfNull: {      /* in3 */\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Null)==0 ) break;\n  /* Fall through into OP_Halt */\n}\n\n/* Opcode:  Halt P1 P2 * P4 *\n**\n** Exit immediately.  All open cursors, etc are closed\n** automatically.\n**\n** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),\n** or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).\n** For errors, it can be some other value.  If P1!=0 then P2 will determine\n** whether or not to rollback the current transaction.  Do not rollback\n** if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,\n** then back out all changes that have occurred during this execution of the\n** VDBE, but do not rollback the transaction. \n**\n** If P4 is not null then it is an error message string.\n**\n** There is an implied \"Halt 0 0 0\" instruction inserted at the very end of\n** every program.  So a jump past the last instruction of the program\n** is the same as executing Halt.\n*/\ncase OP_Halt: {\n  if( pOp->p1==SQLITE_OK && p->pFrame ){\n    /* Halt the sub-program. Return control to the parent frame. */\n    VdbeFrame *pFrame = p->pFrame;\n    p->pFrame = pFrame->pParent;\n    p->nFrame--;\n    sqlite3VdbeSetChanges(db, p->nChange);\n    pc = sqlite3VdbeFrameRestore(pFrame);\n    lastRowid = db->lastRowid;\n    if( pOp->p2==OE_Ignore ){\n      /* Instruction pc is the OP_Program that invoked the sub-program \n      ** currently being halted. If the p2 instruction of this OP_Halt\n      ** instruction is set to OE_Ignore, then the sub-program is throwing\n      ** an IGNORE exception. In this case jump to the address specified\n      ** as the p2 of the calling OP_Program.  */\n      pc = p->aOp[pc].p2-1;\n    }\n    aOp = p->aOp;\n    aMem = p->aMem;\n    break;\n  }\n\n  p->rc = pOp->p1;\n  p->errorAction = (u8)pOp->p2;\n  p->pc = pc;\n  if( pOp->p4.z ){\n    assert( p->rc!=SQLITE_OK );\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", pOp->p4.z);\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(pOp->p1, \"abort at %d in [%s]: %s\", pc, p->zSql, pOp->p4.z);\n  }else if( p->rc ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(pOp->p1, \"constraint failed at %d in [%s]\", pc, p->zSql);\n  }\n  rc = sqlite3VdbeHalt(p);\n  assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );\n  if( rc==SQLITE_BUSY ){\n    p->rc = rc = SQLITE_BUSY;\n  }else{\n    assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );\n    assert( rc==SQLITE_OK || db->nDeferredCons>0 );\n    rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;\n  }\n  goto vdbe_return;\n}\n\n/* Opcode: Integer P1 P2 * * *\n**\n** The 32-bit integer value P1 is written into register P2.\n*/\ncase OP_Integer: {         /* out2-prerelease */\n  pOut->u.i = pOp->p1;\n  break;\n}\n\n/* Opcode: Int64 * P2 * P4 *\n**\n** P4 is a pointer to a 64-bit integer value.\n** Write that value into register P2.\n*/\ncase OP_Int64: {           /* out2-prerelease */\n  assert( pOp->p4.pI64!=0 );\n  pOut->u.i = *pOp->p4.pI64;\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: Real * P2 * P4 *\n**\n** P4 is a pointer to a 64-bit floating point value.\n** Write that value into register P2.\n*/\ncase OP_Real: {            /* same as TK_FLOAT, out2-prerelease */\n  pOut->flags = MEM_Real;\n  assert( !sqlite3IsNaN(*pOp->p4.pReal) );\n  pOut->r = *pOp->p4.pReal;\n  break;\n}\n#endif\n\n/* Opcode: String8 * P2 * P4 *\n**\n** P4 points to a nul terminated UTF-8 string. This opcode is transformed \n** into an OP_String before it is executed for the first time.\n*/\ncase OP_String8: {         /* same as TK_STRING, out2-prerelease */\n  assert( pOp->p4.z!=0 );\n  pOp->opcode = OP_String;\n  pOp->p1 = sqlite3Strlen30(pOp->p4.z);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( encoding!=SQLITE_UTF8 ){\n    rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);\n    if( rc==SQLITE_TOOBIG ) goto too_big;\n    if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem;\n    assert( pOut->zMalloc==pOut->z );\n    assert( pOut->flags & MEM_Dyn );\n    pOut->zMalloc = 0;\n    pOut->flags |= MEM_Static;\n    pOut->flags &= ~MEM_Dyn;\n    if( pOp->p4type==P4_DYNAMIC ){\n      sqlite3DbFree(db, pOp->p4.z);\n    }\n    pOp->p4type = P4_DYNAMIC;\n    pOp->p4.z = pOut->z;\n    pOp->p1 = pOut->n;\n  }\n#endif\n  if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  /* Fall through to the next case, OP_String */\n}\n  \n/* Opcode: String P1 P2 * P4 *\n**\n** The string value P4 of length P1 (bytes) is stored in register P2.\n*/\ncase OP_String: {          /* out2-prerelease */\n  assert( pOp->p4.z!=0 );\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = pOp->p4.z;\n  pOut->n = pOp->p1;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Null P1 P2 P3 * *\n**\n** Write a NULL into registers P2.  If P3 greater than P2, then also write\n** NULL into register P3 and every register in between P2 and P3.  If P3\n** is less than P2 (typically P3 is zero) then only register P2 is\n** set to NULL.\n**\n** If the P1 value is non-zero, then also set the MEM_Cleared flag so that\n** NULL values will not compare equal even if SQLITE_NULLEQ is set on\n** OP_Ne or OP_Eq.\n*/\ncase OP_Null: {           /* out2-prerelease */\n#if 0  /* local variables moved into u.ab */\n  int cnt;\n  u16 nullFlag;\n#endif /* local variables moved into u.ab */\n  u.ab.cnt = pOp->p3-pOp->p2;\n  assert( pOp->p3<=p->nMem );\n  pOut->flags = u.ab.nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;\n  while( u.ab.cnt>0 ){\n    pOut++;\n    memAboutToChange(p, pOut);\n    VdbeMemRelease(pOut);\n    pOut->flags = u.ab.nullFlag;\n    u.ab.cnt--;\n  }\n  break;\n}\n\n\n/* Opcode: Blob P1 P2 * P4\n**\n** P4 points to a blob of data P1 bytes long.  Store this\n** blob in register P2.\n*/\ncase OP_Blob: {                /* out2-prerelease */\n  assert( pOp->p1 <= SQLITE_MAX_LENGTH );\n  sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Variable P1 P2 * P4 *\n**\n** Transfer the values of bound parameter P1 into register P2\n**\n** If the parameter is named, then its name appears in P4 and P3==1.\n** The P4 value is used by sqlite3_bind_parameter_name().\n*/\ncase OP_Variable: {            /* out2-prerelease */\n#if 0  /* local variables moved into u.ac */\n  Mem *pVar;       /* Value being transferred */\n#endif /* local variables moved into u.ac */\n\n  assert( pOp->p1>0 && pOp->p1<=p->nVar );\n  assert( pOp->p4.z==0 || pOp->p4.z==p->azVar[pOp->p1-1] );\n  u.ac.pVar = &p->aVar[pOp->p1 - 1];\n  if( sqlite3VdbeMemTooBig(u.ac.pVar) ){\n    goto too_big;\n  }\n  sqlite3VdbeMemShallowCopy(pOut, u.ac.pVar, MEM_Static);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Move P1 P2 P3 * *\n**\n** Move the values in register P1..P1+P3 over into\n** registers P2..P2+P3.  Registers P1..P1+P3 are\n** left holding a NULL.  It is an error for register ranges\n** P1..P1+P3 and P2..P2+P3 to overlap.\n*/\ncase OP_Move: {\n#if 0  /* local variables moved into u.ad */\n  char *zMalloc;   /* Holding variable for allocated memory */\n  int n;           /* Number of registers left to copy */\n  int p1;          /* Register to copy from */\n  int p2;          /* Register to copy to */\n#endif /* local variables moved into u.ad */\n\n  u.ad.n = pOp->p3 + 1;\n  u.ad.p1 = pOp->p1;\n  u.ad.p2 = pOp->p2;\n  assert( u.ad.n>0 && u.ad.p1>0 && u.ad.p2>0 );\n  assert( u.ad.p1+u.ad.n<=u.ad.p2 || u.ad.p2+u.ad.n<=u.ad.p1 );\n\n  pIn1 = &aMem[u.ad.p1];\n  pOut = &aMem[u.ad.p2];\n  while( u.ad.n-- ){\n    assert( pOut<=&aMem[p->nMem] );\n    assert( pIn1<=&aMem[p->nMem] );\n    assert( memIsValid(pIn1) );\n    memAboutToChange(p, pOut);\n    u.ad.zMalloc = pOut->zMalloc;\n    pOut->zMalloc = 0;\n    sqlite3VdbeMemMove(pOut, pIn1);\n#ifdef SQLITE_DEBUG\n    if( pOut->pScopyFrom>=&aMem[u.ad.p1] && pOut->pScopyFrom<&aMem[u.ad.p1+pOp->p3] ){\n      pOut->pScopyFrom += u.ad.p1 - pOp->p2;\n    }\n#endif\n    pIn1->zMalloc = u.ad.zMalloc;\n    REGISTER_TRACE(u.ad.p2++, pOut);\n    pIn1++;\n    pOut++;\n  }\n  break;\n}\n\n/* Opcode: Copy P1 P2 P3 * *\n**\n** Make a copy of registers P1..P1+P3 into registers P2..P2+P3.\n**\n** This instruction makes a deep copy of the value.  A duplicate\n** is made of any string or blob constant.  See also OP_SCopy.\n*/\ncase OP_Copy: {\n#if 0  /* local variables moved into u.ae */\n  int n;\n#endif /* local variables moved into u.ae */\n\n  u.ae.n = pOp->p3;\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  while( 1 ){\n    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n    Deephemeralize(pOut);\n#ifdef SQLITE_DEBUG\n    pOut->pScopyFrom = 0;\n#endif\n    REGISTER_TRACE(pOp->p2+pOp->p3-u.ae.n, pOut);\n    if( (u.ae.n--)==0 ) break;\n    pOut++;\n    pIn1++;\n  }\n  break;\n}\n\n/* Opcode: SCopy P1 P2 * * *\n**\n** Make a shallow copy of register P1 into register P2.\n**\n** This instruction makes a shallow copy of the value.  If the value\n** is a string or blob, then the copy is only a pointer to the\n** original and hence if the original changes so will the copy.\n** Worse, if the original is deallocated, the copy becomes invalid.\n** Thus the program must guarantee that the original will not change\n** during the lifetime of the copy.  Use OP_Copy to make a complete\n** copy.\n*/\ncase OP_SCopy: {            /* in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n#ifdef SQLITE_DEBUG\n  if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;\n#endif\n  REGISTER_TRACE(pOp->p2, pOut);\n  break;\n}\n\n/* Opcode: ResultRow P1 P2 * * *\n**\n** The registers P1 through P1+P2-1 contain a single row of\n** results. This opcode causes the sqlite3_step() call to terminate\n** with an SQLITE_ROW return code and it sets up the sqlite3_stmt\n** structure to provide access to the top P1 values as the result\n** row.\n*/\ncase OP_ResultRow: {\n#if 0  /* local variables moved into u.af */\n  Mem *pMem;\n  int i;\n#endif /* local variables moved into u.af */\n  assert( p->nResColumn==pOp->p2 );\n  assert( pOp->p1>0 );\n  assert( pOp->p1+pOp->p2<=p->nMem+1 );\n\n  /* If this statement has violated immediate foreign key constraints, do\n  ** not return the number of rows modified. And do not RELEASE the statement\n  ** transaction. It needs to be rolled back.  */\n  if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){\n    assert( db->flags&SQLITE_CountRows );\n    assert( p->usesStmtJournal );\n    break;\n  }\n\n  /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then\n  ** DML statements invoke this opcode to return the number of rows\n  ** modified to the user. This is the only way that a VM that\n  ** opens a statement transaction may invoke this opcode.\n  **\n  ** In case this is such a statement, close any statement transaction\n  ** opened by this VM before returning control to the user. This is to\n  ** ensure that statement-transactions are always nested, not overlapping.\n  ** If the open statement-transaction is not closed here, then the user\n  ** may step another VM that opens its own statement transaction. This\n  ** may lead to overlapping statement transactions.\n  **\n  ** The statement transaction is never a top-level transaction.  Hence\n  ** the RELEASE call below can never fail.\n  */\n  assert( p->iStatement==0 || db->flags&SQLITE_CountRows );\n  rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);\n  if( NEVER(rc!=SQLITE_OK) ){\n    break;\n  }\n\n  /* Invalidate all ephemeral cursor row caches */\n  p->cacheCtr = (p->cacheCtr + 2)|1;\n\n  /* Make sure the results of the current row are \\000 terminated\n  ** and have an assigned type.  The results are de-ephemeralized as\n  ** a side effect.\n  */\n  u.af.pMem = p->pResultSet = &aMem[pOp->p1];\n  for(u.af.i=0; u.af.i<pOp->p2; u.af.i++){\n    assert( memIsValid(&u.af.pMem[u.af.i]) );\n    Deephemeralize(&u.af.pMem[u.af.i]);\n    assert( (u.af.pMem[u.af.i].flags & MEM_Ephem)==0\n            || (u.af.pMem[u.af.i].flags & (MEM_Str|MEM_Blob))==0 );\n    sqlite3VdbeMemNulTerminate(&u.af.pMem[u.af.i]);\n    sqlite3VdbeMemStoreType(&u.af.pMem[u.af.i]);\n    REGISTER_TRACE(pOp->p1+u.af.i, &u.af.pMem[u.af.i]);\n  }\n  if( db->mallocFailed ) goto no_mem;\n\n  /* Return SQLITE_ROW\n  */\n  p->pc = pc + 1;\n  rc = SQLITE_ROW;\n  goto vdbe_return;\n}\n\n/* Opcode: Concat P1 P2 P3 * *\n**\n** Add the text in register P1 onto the end of the text in\n** register P2 and store the result in register P3.\n** If either the P1 or P2 text are NULL then store NULL in P3.\n**\n**   P3 = P2 || P1\n**\n** It is illegal for P1 and P3 to be the same register. Sometimes,\n** if P3 is the same register as P2, the implementation is able\n** to avoid a memcpy().\n*/\ncase OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */\n#if 0  /* local variables moved into u.ag */\n  i64 nByte;\n#endif /* local variables moved into u.ag */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  assert( pIn1!=pOut );\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  if( ExpandBlob(pIn1) || ExpandBlob(pIn2) ) goto no_mem;\n  Stringify(pIn1, encoding);\n  Stringify(pIn2, encoding);\n  u.ag.nByte = pIn1->n + pIn2->n;\n  if( u.ag.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  MemSetTypeFlag(pOut, MEM_Str);\n  if( sqlite3VdbeMemGrow(pOut, (int)u.ag.nByte+2, pOut==pIn2) ){\n    goto no_mem;\n  }\n  if( pOut!=pIn2 ){\n    memcpy(pOut->z, pIn2->z, pIn2->n);\n  }\n  memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);\n  pOut->z[u.ag.nByte] = 0;\n  pOut->z[u.ag.nByte+1] = 0;\n  pOut->flags |= MEM_Term;\n  pOut->n = (int)u.ag.nByte;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Add P1 P2 P3 * *\n**\n** Add the value in register P1 to the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Multiply P1 P2 P3 * *\n**\n**\n** Multiply the value in register P1 by the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Subtract P1 P2 P3 * *\n**\n** Subtract the value in register P1 from the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Divide P1 P2 P3 * *\n**\n** Divide the value in register P1 by the value in register P2\n** and store the result in register P3 (P3=P2/P1). If the value in \n** register P1 is zero, then the result is NULL. If either input is \n** NULL, the result is NULL.\n*/\n/* Opcode: Remainder P1 P2 P3 * *\n**\n** Compute the remainder after integer division of the value in\n** register P1 by the value in register P2 and store the result in P3. \n** If the value in register P2 is zero the result is NULL.\n** If either operand is NULL, the result is NULL.\n*/\ncase OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */\ncase OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */\ncase OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */\ncase OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */\ncase OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */\n#if 0  /* local variables moved into u.ah */\n  char bIntint;   /* Started out as two integer operands */\n  int flags;      /* Combined MEM_* flags from both inputs */\n  i64 iA;         /* Integer value of left operand */\n  i64 iB;         /* Integer value of right operand */\n  double rA;      /* Real value of left operand */\n  double rB;      /* Real value of right operand */\n#endif /* local variables moved into u.ah */\n\n  pIn1 = &aMem[pOp->p1];\n  applyNumericAffinity(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  applyNumericAffinity(pIn2);\n  pOut = &aMem[pOp->p3];\n  u.ah.flags = pIn1->flags | pIn2->flags;\n  if( (u.ah.flags & MEM_Null)!=0 ) goto arithmetic_result_is_null;\n  if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){\n    u.ah.iA = pIn1->u.i;\n    u.ah.iB = pIn2->u.i;\n    u.ah.bIntint = 1;\n    switch( pOp->opcode ){\n      case OP_Add:       if( sqlite3AddInt64(&u.ah.iB,u.ah.iA) ) goto fp_math;  break;\n      case OP_Subtract:  if( sqlite3SubInt64(&u.ah.iB,u.ah.iA) ) goto fp_math;  break;\n      case OP_Multiply:  if( sqlite3MulInt64(&u.ah.iB,u.ah.iA) ) goto fp_math;  break;\n      case OP_Divide: {\n        if( u.ah.iA==0 ) goto arithmetic_result_is_null;\n        if( u.ah.iA==-1 && u.ah.iB==SMALLEST_INT64 ) goto fp_math;\n        u.ah.iB /= u.ah.iA;\n        break;\n      }\n      default: {\n        if( u.ah.iA==0 ) goto arithmetic_result_is_null;\n        if( u.ah.iA==-1 ) u.ah.iA = 1;\n        u.ah.iB %= u.ah.iA;\n        break;\n      }\n    }\n    pOut->u.i = u.ah.iB;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }else{\n    u.ah.bIntint = 0;\nfp_math:\n    u.ah.rA = sqlite3VdbeRealValue(pIn1);\n    u.ah.rB = sqlite3VdbeRealValue(pIn2);\n    switch( pOp->opcode ){\n      case OP_Add:         u.ah.rB += u.ah.rA;       break;\n      case OP_Subtract:    u.ah.rB -= u.ah.rA;       break;\n      case OP_Multiply:    u.ah.rB *= u.ah.rA;       break;\n      case OP_Divide: {\n        /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n        if( u.ah.rA==(double)0 ) goto arithmetic_result_is_null;\n        u.ah.rB /= u.ah.rA;\n        break;\n      }\n      default: {\n        u.ah.iA = (i64)u.ah.rA;\n        u.ah.iB = (i64)u.ah.rB;\n        if( u.ah.iA==0 ) goto arithmetic_result_is_null;\n        if( u.ah.iA==-1 ) u.ah.iA = 1;\n        u.ah.rB = (double)(u.ah.iB % u.ah.iA);\n        break;\n      }\n    }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    pOut->u.i = u.ah.rB;\n    MemSetTypeFlag(pOut, MEM_Int);\n#else\n    if( sqlite3IsNaN(u.ah.rB) ){\n      goto arithmetic_result_is_null;\n    }\n    pOut->r = u.ah.rB;\n    MemSetTypeFlag(pOut, MEM_Real);\n    if( (u.ah.flags & MEM_Real)==0 && !u.ah.bIntint ){\n      sqlite3VdbeIntegerAffinity(pOut);\n    }\n#endif\n  }\n  break;\n\narithmetic_result_is_null:\n  sqlite3VdbeMemSetNull(pOut);\n  break;\n}\n\n/* Opcode: CollSeq P1 * * P4\n**\n** P4 is a pointer to a CollSeq struct. If the next call to a user function\n** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will\n** be returned. This is used by the built-in min(), max() and nullif()\n** functions.\n**\n** If P1 is not zero, then it is a register that a subsequent min() or\n** max() aggregate will set to 1 if the current row is not the minimum or\n** maximum.  The P1 register is initialized to 0 by this instruction.\n**\n** The interface used by the implementation of the aforementioned functions\n** to retrieve the collation sequence set by this opcode is not available\n** publicly, only to user functions defined in func.c.\n*/\ncase OP_CollSeq: {\n  assert( pOp->p4type==P4_COLLSEQ );\n  if( pOp->p1 ){\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);\n  }\n  break;\n}\n\n/* Opcode: Function P1 P2 P3 P4 P5\n**\n** Invoke a user function (P4 is a pointer to a Function structure that\n** defines the function) with P5 arguments taken from register P2 and\n** successors.  The result of the function is stored in register P3.\n** Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** See also: AggStep and AggFinal\n*/\ncase OP_Function: {\n#if 0  /* local variables moved into u.ai */\n  int i;\n  Mem *pArg;\n  sqlite3_context ctx;\n  sqlite3_value **apVal;\n  int n;\n#endif /* local variables moved into u.ai */\n\n  u.ai.n = pOp->p5;\n  u.ai.apVal = p->apArg;\n  assert( u.ai.apVal || u.ai.n==0 );\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  pOut = &aMem[pOp->p3];\n  memAboutToChange(p, pOut);\n\n  assert( u.ai.n==0 || (pOp->p2>0 && pOp->p2+u.ai.n<=p->nMem+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+u.ai.n );\n  u.ai.pArg = &aMem[pOp->p2];\n  for(u.ai.i=0; u.ai.i<u.ai.n; u.ai.i++, u.ai.pArg++){\n    assert( memIsValid(u.ai.pArg) );\n    u.ai.apVal[u.ai.i] = u.ai.pArg;\n    Deephemeralize(u.ai.pArg);\n    sqlite3VdbeMemStoreType(u.ai.pArg);\n    REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg);\n  }\n\n  assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC );\n  if( pOp->p4type==P4_FUNCDEF ){\n    u.ai.ctx.pFunc = pOp->p4.pFunc;\n    u.ai.ctx.pVdbeFunc = 0;\n  }else{\n    u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc;\n    u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc;\n  }\n\n  u.ai.ctx.s.flags = MEM_Null;\n  u.ai.ctx.s.db = db;\n  u.ai.ctx.s.xDel = 0;\n  u.ai.ctx.s.zMalloc = 0;\n\n  /* The output cell may already have a buffer allocated. Move\n  ** the pointer to u.ai.ctx.s so in case the user-function can use\n  ** the already allocated buffer instead of allocating a new one.\n  */\n  sqlite3VdbeMemMove(&u.ai.ctx.s, pOut);\n  MemSetTypeFlag(&u.ai.ctx.s, MEM_Null);\n\n  u.ai.ctx.isError = 0;\n  if( u.ai.ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){\n    assert( pOp>aOp );\n    assert( pOp[-1].p4type==P4_COLLSEQ );\n    assert( pOp[-1].opcode==OP_CollSeq );\n    u.ai.ctx.pColl = pOp[-1].p4.pColl;\n  }\n  db->lastRowid = lastRowid;\n  (*u.ai.ctx.pFunc->xFunc)(&u.ai.ctx, u.ai.n, u.ai.apVal); /* IMP: R-24505-23230 */\n  lastRowid = db->lastRowid;\n\n  /* If any auxiliary data functions have been called by this user function,\n  ** immediately call the destructor for any non-static values.\n  */\n  if( u.ai.ctx.pVdbeFunc ){\n    sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1);\n    pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc;\n    pOp->p4type = P4_VDBEFUNC;\n  }\n\n  if( db->mallocFailed ){\n    /* Even though a malloc() has failed, the implementation of the\n    ** user function may have called an sqlite3_result_XXX() function\n    ** to return a value. The following call releases any resources\n    ** associated with such a value.\n    */\n    sqlite3VdbeMemRelease(&u.ai.ctx.s);\n    goto no_mem;\n  }\n\n  /* If the function returned an error, throw an exception */\n  if( u.ai.ctx.isError ){\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3_value_text(&u.ai.ctx.s));\n    rc = u.ai.ctx.isError;\n  }\n\n  /* Copy the result of the function into register P3 */\n  sqlite3VdbeChangeEncoding(&u.ai.ctx.s, encoding);\n  sqlite3VdbeMemMove(pOut, &u.ai.ctx.s);\n  if( sqlite3VdbeMemTooBig(pOut) ){\n    goto too_big;\n  }\n\n#if 0\n  /* The app-defined function has done something that as caused this\n  ** statement to expire.  (Perhaps the function called sqlite3_exec()\n  ** with a CREATE TABLE statement.)\n  */\n  if( p->expired ) rc = SQLITE_ABORT;\n#endif\n\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: BitAnd P1 P2 P3 * *\n**\n** Take the bit-wise AND of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: BitOr P1 P2 P3 * *\n**\n** Take the bit-wise OR of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftLeft P1 P2 P3 * *\n**\n** Shift the integer value in register P2 to the left by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftRight P1 P2 P3 * *\n**\n** Shift the integer value in register P2 to the right by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\ncase OP_BitAnd:                 /* same as TK_BITAND, in1, in2, out3 */\ncase OP_BitOr:                  /* same as TK_BITOR, in1, in2, out3 */\ncase OP_ShiftLeft:              /* same as TK_LSHIFT, in1, in2, out3 */\ncase OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */\n#if 0  /* local variables moved into u.aj */\n  i64 iA;\n  u64 uA;\n  i64 iB;\n  u8 op;\n#endif /* local variables moved into u.aj */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  u.aj.iA = sqlite3VdbeIntValue(pIn2);\n  u.aj.iB = sqlite3VdbeIntValue(pIn1);\n  u.aj.op = pOp->opcode;\n  if( u.aj.op==OP_BitAnd ){\n    u.aj.iA &= u.aj.iB;\n  }else if( u.aj.op==OP_BitOr ){\n    u.aj.iA |= u.aj.iB;\n  }else if( u.aj.iB!=0 ){\n    assert( u.aj.op==OP_ShiftRight || u.aj.op==OP_ShiftLeft );\n\n    /* If shifting by a negative amount, shift in the other direction */\n    if( u.aj.iB<0 ){\n      assert( OP_ShiftRight==OP_ShiftLeft+1 );\n      u.aj.op = 2*OP_ShiftLeft + 1 - u.aj.op;\n      u.aj.iB = u.aj.iB>(-64) ? -u.aj.iB : 64;\n    }\n\n    if( u.aj.iB>=64 ){\n      u.aj.iA = (u.aj.iA>=0 || u.aj.op==OP_ShiftLeft) ? 0 : -1;\n    }else{\n      memcpy(&u.aj.uA, &u.aj.iA, sizeof(u.aj.uA));\n      if( u.aj.op==OP_ShiftLeft ){\n        u.aj.uA <<= u.aj.iB;\n      }else{\n        u.aj.uA >>= u.aj.iB;\n        /* Sign-extend on a right shift of a negative number */\n        if( u.aj.iA<0 ) u.aj.uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-u.aj.iB);\n      }\n      memcpy(&u.aj.iA, &u.aj.uA, sizeof(u.aj.iA));\n    }\n  }\n  pOut->u.i = u.aj.iA;\n  MemSetTypeFlag(pOut, MEM_Int);\n  break;\n}\n\n/* Opcode: AddImm  P1 P2 * * *\n** \n** Add the constant P2 to the value in register P1.\n** The result is always an integer.\n**\n** To force any register to be an integer, just add 0.\n*/\ncase OP_AddImm: {            /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn1->u.i += pOp->p2;\n  break;\n}\n\n/* Opcode: MustBeInt P1 P2 * * *\n** \n** Force the value in register P1 to be an integer.  If the value\n** in P1 is not an integer and cannot be converted into an integer\n** without data loss, then jump immediately to P2, or if P2==0\n** raise an SQLITE_MISMATCH exception.\n*/\ncase OP_MustBeInt: {            /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);\n  if( (pIn1->flags & MEM_Int)==0 ){\n    if( pOp->p2==0 ){\n      rc = SQLITE_MISMATCH;\n      goto abort_due_to_error;\n    }else{\n      pc = pOp->p2 - 1;\n    }\n  }else{\n    MemSetTypeFlag(pIn1, MEM_Int);\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: RealAffinity P1 * * * *\n**\n** If register P1 holds an integer convert it to a real value.\n**\n** This opcode is used when extracting information from a column that\n** has REAL affinity.  Such column values may still be stored as\n** integers, for space efficiency, but after extraction we want them\n** to have only a real value.\n*/\ncase OP_RealAffinity: {                  /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Int ){\n    sqlite3VdbeMemRealify(pIn1);\n  }\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CAST\n/* Opcode: ToText P1 * * * *\n**\n** Force the value in register P1 to be text.\n** If the value is numeric, convert it to a string using the\n** equivalent of printf().  Blob values are unchanged and\n** are afterwards simply interpreted as text.\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_ToText: {                  /* same as TK_TO_TEXT, in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  if( pIn1->flags & MEM_Null ) break;\n  assert( MEM_Str==(MEM_Blob>>3) );\n  pIn1->flags |= (pIn1->flags&MEM_Blob)>>3;\n  applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding);\n  rc = ExpandBlob(pIn1);\n  assert( pIn1->flags & MEM_Str || db->mallocFailed );\n  pIn1->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  break;\n}\n\n/* Opcode: ToBlob P1 * * * *\n**\n** Force the value in register P1 to be a BLOB.\n** If the value is numeric, convert it to a string first.\n** Strings are simply reinterpreted as blobs with no change\n** to the underlying data.\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_ToBlob: {                  /* same as TK_TO_BLOB, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ) break;\n  if( (pIn1->flags & MEM_Blob)==0 ){\n    applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding);\n    assert( pIn1->flags & MEM_Str || db->mallocFailed );\n    MemSetTypeFlag(pIn1, MEM_Blob);\n  }else{\n    pIn1->flags &= ~(MEM_TypeMask&~MEM_Blob);\n  }\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  break;\n}\n\n/* Opcode: ToNumeric P1 * * * *\n**\n** Force the value in register P1 to be numeric (either an\n** integer or a floating-point number.)\n** If the value is text or blob, try to convert it to an using the\n** equivalent of atoi() or atof() and store 0 if no such conversion \n** is possible.\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_ToNumeric: {                  /* same as TK_TO_NUMERIC, in1 */\n  pIn1 = &aMem[pOp->p1];\n  sqlite3VdbeMemNumerify(pIn1);\n  break;\n}\n#endif /* SQLITE_OMIT_CAST */\n\n/* Opcode: ToInt P1 * * * *\n**\n** Force the value in register P1 to be an integer.  If\n** The value is currently a real number, drop its fractional part.\n** If the value is text or blob, try to convert it to an integer using the\n** equivalent of atoi() and store 0 if no such conversion is possible.\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_ToInt: {                  /* same as TK_TO_INT, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Null)==0 ){\n    sqlite3VdbeMemIntegerify(pIn1);\n  }\n  break;\n}\n\n#if !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT)\n/* Opcode: ToReal P1 * * * *\n**\n** Force the value in register P1 to be a floating point number.\n** If The value is currently an integer, convert it.\n** If the value is text or blob, try to convert it to an integer using the\n** equivalent of atoi() and store 0.0 if no such conversion is possible.\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_ToReal: {                  /* same as TK_TO_REAL, in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    sqlite3VdbeMemRealify(pIn1);\n  }\n  break;\n}\n#endif /* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */\n\n/* Opcode: Lt P1 P2 P3 P4 P5\n**\n** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then\n** jump to address P2.  \n**\n** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or\n** reg(P3) is NULL then take the jump.  If the SQLITE_JUMPIFNULL \n** bit is clear then fall through if either operand is NULL.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is  used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n**\n** If the SQLITE_STOREP2 bit of P5 is set, then do not jump.  Instead,\n** store a boolean result (either 0, or 1, or NULL) in register P2.\n**\n** If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered\n** equal to one another, provided that they do not have their MEM_Cleared\n** bit set.\n*/\n/* Opcode: Ne P1 P2 P3 P4 P5\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the operands in registers P1 and P3 are not equal.  See the Lt opcode for\n** additional information.\n**\n** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either\n** true or false and is never NULL.  If both operands are NULL then the result\n** of comparison is false.  If either operand is NULL then the result is true.\n** If neither operand is NULL the result is the same as it would be if\n** the SQLITE_NULLEQ flag were omitted from P5.\n*/\n/* Opcode: Eq P1 P2 P3 P4 P5\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the operands in registers P1 and P3 are equal.\n** See the Lt opcode for additional information.\n**\n** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either\n** true or false and is never NULL.  If both operands are NULL then the result\n** of comparison is true.  If either operand is NULL then the result is false.\n** If neither operand is NULL the result is the same as it would be if\n** the SQLITE_NULLEQ flag were omitted from P5.\n*/\n/* Opcode: Le P1 P2 P3 P4 P5\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is less than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Gt P1 P2 P3 P4 P5\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Ge P1 P2 P3 P4 P5\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\ncase OP_Eq:               /* same as TK_EQ, jump, in1, in3 */\ncase OP_Ne:               /* same as TK_NE, jump, in1, in3 */\ncase OP_Lt:               /* same as TK_LT, jump, in1, in3 */\ncase OP_Le:               /* same as TK_LE, jump, in1, in3 */\ncase OP_Gt:               /* same as TK_GT, jump, in1, in3 */\ncase OP_Ge: {             /* same as TK_GE, jump, in1, in3 */\n#if 0  /* local variables moved into u.ak */\n  int res;            /* Result of the comparison of pIn1 against pIn3 */\n  char affinity;      /* Affinity to use for comparison */\n  u16 flags1;         /* Copy of initial value of pIn1->flags */\n  u16 flags3;         /* Copy of initial value of pIn3->flags */\n#endif /* local variables moved into u.ak */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  u.ak.flags1 = pIn1->flags;\n  u.ak.flags3 = pIn3->flags;\n  if( (u.ak.flags1 | u.ak.flags3)&MEM_Null ){\n    /* One or both operands are NULL */\n    if( pOp->p5 & SQLITE_NULLEQ ){\n      /* If SQLITE_NULLEQ is set (which will only happen if the operator is\n      ** OP_Eq or OP_Ne) then take the jump or not depending on whether\n      ** or not both operands are null.\n      */\n      assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );\n      assert( (u.ak.flags1 & MEM_Cleared)==0 );\n      if( (u.ak.flags1&MEM_Null)!=0\n       && (u.ak.flags3&MEM_Null)!=0\n       && (u.ak.flags3&MEM_Cleared)==0\n      ){\n        u.ak.res = 0;  /* Results are equal */\n      }else{\n        u.ak.res = 1;  /* Results are not equal */\n      }\n    }else{\n      /* SQLITE_NULLEQ is clear and at least one operand is NULL,\n      ** then the result is always NULL.\n      ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.\n      */\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        pOut = &aMem[pOp->p2];\n        MemSetTypeFlag(pOut, MEM_Null);\n        REGISTER_TRACE(pOp->p2, pOut);\n      }else if( pOp->p5 & SQLITE_JUMPIFNULL ){\n        pc = pOp->p2-1;\n      }\n      break;\n    }\n  }else{\n    /* Neither operand is NULL.  Do a comparison. */\n    u.ak.affinity = pOp->p5 & SQLITE_AFF_MASK;\n    if( u.ak.affinity ){\n      applyAffinity(pIn1, u.ak.affinity, encoding);\n      applyAffinity(pIn3, u.ak.affinity, encoding);\n      if( db->mallocFailed ) goto no_mem;\n    }\n\n    assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );\n    ExpandBlob(pIn1);\n    ExpandBlob(pIn3);\n    u.ak.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);\n  }\n  switch( pOp->opcode ){\n    case OP_Eq:    u.ak.res = u.ak.res==0;     break;\n    case OP_Ne:    u.ak.res = u.ak.res!=0;     break;\n    case OP_Lt:    u.ak.res = u.ak.res<0;      break;\n    case OP_Le:    u.ak.res = u.ak.res<=0;     break;\n    case OP_Gt:    u.ak.res = u.ak.res>0;      break;\n    default:       u.ak.res = u.ak.res>=0;     break;\n  }\n\n  if( pOp->p5 & SQLITE_STOREP2 ){\n    pOut = &aMem[pOp->p2];\n    memAboutToChange(p, pOut);\n    MemSetTypeFlag(pOut, MEM_Int);\n    pOut->u.i = u.ak.res;\n    REGISTER_TRACE(pOp->p2, pOut);\n  }else if( u.ak.res ){\n    pc = pOp->p2-1;\n  }\n\n  /* Undo any changes made by applyAffinity() to the input registers. */\n  pIn1->flags = (pIn1->flags&~MEM_TypeMask) | (u.ak.flags1&MEM_TypeMask);\n  pIn3->flags = (pIn3->flags&~MEM_TypeMask) | (u.ak.flags3&MEM_TypeMask);\n  break;\n}\n\n/* Opcode: Permutation * * * P4 *\n**\n** Set the permutation used by the OP_Compare operator to be the array\n** of integers in P4.\n**\n** The permutation is only valid until the next OP_Compare that has\n** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should \n** occur immediately prior to the OP_Compare.\n*/\ncase OP_Permutation: {\n  assert( pOp->p4type==P4_INTARRAY );\n  assert( pOp->p4.ai );\n  aPermute = pOp->p4.ai;\n  break;\n}\n\n/* Opcode: Compare P1 P2 P3 P4 P5\n**\n** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this\n** vector \"A\") and in reg(P2)..reg(P2+P3-1) (\"B\").  Save the result of\n** the comparison for use by the next OP_Jump instruct.\n**\n** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is\n** determined by the most recent OP_Permutation operator.  If the\n** OPFLAG_PERMUTE bit is clear, then register are compared in sequential\n** order.\n**\n** P4 is a KeyInfo structure that defines collating sequences and sort\n** orders for the comparison.  The permutation applies to registers\n** only.  The KeyInfo elements are used sequentially.\n**\n** The comparison is a sort comparison, so NULLs compare equal,\n** NULLs are less than numbers, numbers are less than strings,\n** and strings are less than blobs.\n*/\ncase OP_Compare: {\n#if 0  /* local variables moved into u.al */\n  int n;\n  int i;\n  int p1;\n  int p2;\n  const KeyInfo *pKeyInfo;\n  int idx;\n  CollSeq *pColl;    /* Collating sequence to use on this term */\n  int bRev;          /* True for DESCENDING sort order */\n#endif /* local variables moved into u.al */\n\n  if( (pOp->p5 & OPFLAG_PERMUTE)==0 ) aPermute = 0;\n  u.al.n = pOp->p3;\n  u.al.pKeyInfo = pOp->p4.pKeyInfo;\n  assert( u.al.n>0 );\n  assert( u.al.pKeyInfo!=0 );\n  u.al.p1 = pOp->p1;\n  u.al.p2 = pOp->p2;\n#if SQLITE_DEBUG\n  if( aPermute ){\n    int k, mx = 0;\n    for(k=0; k<u.al.n; k++) if( aPermute[k]>mx ) mx = aPermute[k];\n    assert( u.al.p1>0 && u.al.p1+mx<=p->nMem+1 );\n    assert( u.al.p2>0 && u.al.p2+mx<=p->nMem+1 );\n  }else{\n    assert( u.al.p1>0 && u.al.p1+u.al.n<=p->nMem+1 );\n    assert( u.al.p2>0 && u.al.p2+u.al.n<=p->nMem+1 );\n  }\n#endif /* SQLITE_DEBUG */\n  for(u.al.i=0; u.al.i<u.al.n; u.al.i++){\n    u.al.idx = aPermute ? aPermute[u.al.i] : u.al.i;\n    assert( memIsValid(&aMem[u.al.p1+u.al.idx]) );\n    assert( memIsValid(&aMem[u.al.p2+u.al.idx]) );\n    REGISTER_TRACE(u.al.p1+u.al.idx, &aMem[u.al.p1+u.al.idx]);\n    REGISTER_TRACE(u.al.p2+u.al.idx, &aMem[u.al.p2+u.al.idx]);\n    assert( u.al.i<u.al.pKeyInfo->nField );\n    u.al.pColl = u.al.pKeyInfo->aColl[u.al.i];\n    u.al.bRev = u.al.pKeyInfo->aSortOrder[u.al.i];\n    iCompare = sqlite3MemCompare(&aMem[u.al.p1+u.al.idx], &aMem[u.al.p2+u.al.idx], u.al.pColl);\n    if( iCompare ){\n      if( u.al.bRev ) iCompare = -iCompare;\n      break;\n    }\n  }\n  aPermute = 0;\n  break;\n}\n\n/* Opcode: Jump P1 P2 P3 * *\n**\n** Jump to the instruction at address P1, P2, or P3 depending on whether\n** in the most recent OP_Compare instruction the P1 vector was less than\n** equal to, or greater than the P2 vector, respectively.\n*/\ncase OP_Jump: {             /* jump */\n  if( iCompare<0 ){\n    pc = pOp->p1 - 1;\n  }else if( iCompare==0 ){\n    pc = pOp->p2 - 1;\n  }else{\n    pc = pOp->p3 - 1;\n  }\n  break;\n}\n\n/* Opcode: And P1 P2 P3 * *\n**\n** Take the logical AND of the values in registers P1 and P2 and\n** write the result into register P3.\n**\n** If either P1 or P2 is 0 (false) then the result is 0 even if\n** the other input is NULL.  A NULL and true or two NULLs give\n** a NULL output.\n*/\n/* Opcode: Or P1 P2 P3 * *\n**\n** Take the logical OR of the values in register P1 and P2 and\n** store the answer in register P3.\n**\n** If either P1 or P2 is nonzero (true) then the result is 1 (true)\n** even if the other input is NULL.  A NULL and false or two NULLs\n** give a NULL output.\n*/\ncase OP_And:              /* same as TK_AND, in1, in2, out3 */\ncase OP_Or: {             /* same as TK_OR, in1, in2, out3 */\n#if 0  /* local variables moved into u.am */\n  int v1;    /* Left operand:  0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n  int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n#endif /* local variables moved into u.am */\n\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    u.am.v1 = 2;\n  }else{\n    u.am.v1 = sqlite3VdbeIntValue(pIn1)!=0;\n  }\n  pIn2 = &aMem[pOp->p2];\n  if( pIn2->flags & MEM_Null ){\n    u.am.v2 = 2;\n  }else{\n    u.am.v2 = sqlite3VdbeIntValue(pIn2)!=0;\n  }\n  if( pOp->opcode==OP_And ){\n    static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 };\n    u.am.v1 = and_logic[u.am.v1*3+u.am.v2];\n  }else{\n    static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 };\n    u.am.v1 = or_logic[u.am.v1*3+u.am.v2];\n  }\n  pOut = &aMem[pOp->p3];\n  if( u.am.v1==2 ){\n    MemSetTypeFlag(pOut, MEM_Null);\n  }else{\n    pOut->u.i = u.am.v1;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }\n  break;\n}\n\n/* Opcode: Not P1 P2 * * *\n**\n** Interpret the value in register P1 as a boolean value.  Store the\n** boolean complement in register P2.  If the value in register P1 is \n** NULL, then a NULL is stored in P2.\n*/\ncase OP_Not: {                /* same as TK_NOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  if( pIn1->flags & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n  }else{\n    sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeIntValue(pIn1));\n  }\n  break;\n}\n\n/* Opcode: BitNot P1 P2 * * *\n**\n** Interpret the content of register P1 as an integer.  Store the\n** ones-complement of the P1 value into register P2.  If P1 holds\n** a NULL then store a NULL in P2.\n*/\ncase OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  if( pIn1->flags & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n  }else{\n    sqlite3VdbeMemSetInt64(pOut, ~sqlite3VdbeIntValue(pIn1));\n  }\n  break;\n}\n\n/* Opcode: Once P1 P2 * * *\n**\n** Check if OP_Once flag P1 is set. If so, jump to instruction P2. Otherwise,\n** set the flag and fall through to the next instruction.\n*/\ncase OP_Once: {             /* jump */\n  assert( pOp->p1<p->nOnceFlag );\n  if( p->aOnceFlag[pOp->p1] ){\n    pc = pOp->p2-1;\n  }else{\n    p->aOnceFlag[pOp->p1] = 1;\n  }\n  break;\n}\n\n/* Opcode: If P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is true.  The value\n** is considered true if it is numeric and non-zero.  If the value\n** in P1 is NULL then take the jump if P3 is non-zero.\n*/\n/* Opcode: IfNot P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is False.  The value\n** is considered false if it has a numeric value of zero.  If the value\n** in P1 is NULL then take the jump if P3 is zero.\n*/\ncase OP_If:                 /* jump, in1 */\ncase OP_IfNot: {            /* jump, in1 */\n#if 0  /* local variables moved into u.an */\n  int c;\n#endif /* local variables moved into u.an */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    u.an.c = pOp->p3;\n  }else{\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    u.an.c = sqlite3VdbeIntValue(pIn1)!=0;\n#else\n    u.an.c = sqlite3VdbeRealValue(pIn1)!=0.0;\n#endif\n    if( pOp->opcode==OP_IfNot ) u.an.c = !u.an.c;\n  }\n  if( u.an.c ){\n    pc = pOp->p2-1;\n  }\n  break;\n}\n\n/* Opcode: IsNull P1 P2 * * *\n**\n** Jump to P2 if the value in register P1 is NULL.\n*/\ncase OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Null)!=0 ){\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: NotNull P1 P2 * * *\n**\n** Jump to P2 if the value in register P1 is not NULL.  \n*/\ncase OP_NotNull: {            /* same as TK_NOTNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: Column P1 P2 P3 P4 P5\n**\n** Interpret the data that cursor P1 points to as a structure built using\n** the MakeRecord instruction.  (See the MakeRecord opcode for additional\n** information about the format of the data.)  Extract the P2-th column\n** from this record.  If there are less that (P2+1) \n** values in the record, extract a NULL.\n**\n** The value extracted is stored in register P3.\n**\n** If the column contains fewer than P2 fields, then extract a NULL.  Or,\n** if the P4 argument is a P4_MEM use the value of the P4 argument as\n** the result.\n**\n** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,\n** then the cache of the cursor is reset prior to extracting the column.\n** The first OP_Column against a pseudo-table after the value of the content\n** register has changed should have this bit set.\n**\n** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when\n** the result is guaranteed to only be used as the argument of a length()\n** or typeof() function, respectively.  The loading of large blobs can be\n** skipped for length() and all content loading can be skipped for typeof().\n*/\ncase OP_Column: {\n#if 0  /* local variables moved into u.ao */\n  u32 payloadSize;   /* Number of bytes in the record */\n  i64 payloadSize64; /* Number of bytes in the record */\n  int p1;            /* P1 value of the opcode */\n  int p2;            /* column number to retrieve */\n  VdbeCursor *pC;    /* The VDBE cursor */\n  char *zRec;        /* Pointer to complete record-data */\n  BtCursor *pCrsr;   /* The BTree cursor */\n  u32 *aType;        /* aType[i] holds the numeric type of the i-th column */\n  u32 *aOffset;      /* aOffset[i] is offset to start of data for i-th column */\n  int nField;        /* number of fields in the record */\n  int len;           /* The length of the serialized data for the column */\n  int i;             /* Loop counter */\n  char *zData;       /* Part of the record being decoded */\n  Mem *pDest;        /* Where to write the extracted value */\n  Mem sMem;          /* For storing the record being decoded */\n  u8 *zIdx;          /* Index into header */\n  u8 *zEndHdr;       /* Pointer to first byte after the header */\n  u32 offset;        /* Offset into the data */\n  u32 szField;       /* Number of bytes in the content of a field */\n  int szHdr;         /* Size of the header size field at start of record */\n  int avail;         /* Number of bytes of available data */\n  u32 t;             /* A type code from the record header */\n  Mem *pReg;         /* PseudoTable input register */\n#endif /* local variables moved into u.ao */\n\n\n  u.ao.p1 = pOp->p1;\n  u.ao.p2 = pOp->p2;\n  u.ao.pC = 0;\n  memset(&u.ao.sMem, 0, sizeof(u.ao.sMem));\n  assert( u.ao.p1<p->nCursor );\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  u.ao.pDest = &aMem[pOp->p3];\n  memAboutToChange(p, u.ao.pDest);\n  u.ao.zRec = 0;\n\n  /* This block sets the variable u.ao.payloadSize to be the total number of\n  ** bytes in the record.\n  **\n  ** u.ao.zRec is set to be the complete text of the record if it is available.\n  ** The complete record text is always available for pseudo-tables\n  ** If the record is stored in a cursor, the complete record text\n  ** might be available in the  u.ao.pC->aRow cache.  Or it might not be.\n  ** If the data is unavailable,  u.ao.zRec is set to NULL.\n  **\n  ** We also compute the number of columns in the record.  For cursors,\n  ** the number of columns is stored in the VdbeCursor.nField element.\n  */\n  u.ao.pC = p->apCsr[u.ao.p1];\n  assert( u.ao.pC!=0 );\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  assert( u.ao.pC->pVtabCursor==0 );\n#endif\n  u.ao.pCrsr = u.ao.pC->pCursor;\n  if( u.ao.pCrsr!=0 ){\n    /* The record is stored in a B-Tree */\n    rc = sqlite3VdbeCursorMoveto(u.ao.pC);\n    if( rc ) goto abort_due_to_error;\n    if( u.ao.pC->nullRow ){\n      u.ao.payloadSize = 0;\n    }else if( u.ao.pC->cacheStatus==p->cacheCtr ){\n      u.ao.payloadSize = u.ao.pC->payloadSize;\n      u.ao.zRec = (char*)u.ao.pC->aRow;\n    }else if( u.ao.pC->isIndex ){\n      assert( sqlite3BtreeCursorIsValid(u.ao.pCrsr) );\n      VVA_ONLY(rc =) sqlite3BtreeKeySize(u.ao.pCrsr, &u.ao.payloadSize64);\n      assert( rc==SQLITE_OK );   /* True because of CursorMoveto() call above */\n      /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the\n      ** payload size, so it is impossible for u.ao.payloadSize64 to be\n      ** larger than 32 bits. */\n      assert( (u.ao.payloadSize64 & SQLITE_MAX_U32)==(u64)u.ao.payloadSize64 );\n      u.ao.payloadSize = (u32)u.ao.payloadSize64;\n    }else{\n      assert( sqlite3BtreeCursorIsValid(u.ao.pCrsr) );\n      VVA_ONLY(rc =) sqlite3BtreeDataSize(u.ao.pCrsr, &u.ao.payloadSize);\n      assert( rc==SQLITE_OK );   /* DataSize() cannot fail */\n    }\n  }else if( ALWAYS(u.ao.pC->pseudoTableReg>0) ){\n    u.ao.pReg = &aMem[u.ao.pC->pseudoTableReg];\n    if( u.ao.pC->multiPseudo ){\n      sqlite3VdbeMemShallowCopy(u.ao.pDest, u.ao.pReg+u.ao.p2, MEM_Ephem);\n      Deephemeralize(u.ao.pDest);\n      goto op_column_out;\n    }\n    assert( u.ao.pReg->flags & MEM_Blob );\n    assert( memIsValid(u.ao.pReg) );\n    u.ao.payloadSize = u.ao.pReg->n;\n    u.ao.zRec = u.ao.pReg->z;\n    u.ao.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr;\n    assert( u.ao.payloadSize==0 || u.ao.zRec!=0 );\n  }else{\n    /* Consider the row to be NULL */\n    u.ao.payloadSize = 0;\n  }\n\n  /* If u.ao.payloadSize is 0, then just store a NULL.  This can happen because of\n  ** nullRow or because of a corrupt database. */\n  if( u.ao.payloadSize==0 ){\n    MemSetTypeFlag(u.ao.pDest, MEM_Null);\n    goto op_column_out;\n  }\n  assert( db->aLimit[SQLITE_LIMIT_LENGTH]>=0 );\n  if( u.ao.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n\n  u.ao.nField = u.ao.pC->nField;\n  assert( u.ao.p2<u.ao.nField );\n\n  /* Read and parse the table header.  Store the results of the parse\n  ** into the record header cache fields of the cursor.\n  */\n  u.ao.aType = u.ao.pC->aType;\n  if( u.ao.pC->cacheStatus==p->cacheCtr ){\n    u.ao.aOffset = u.ao.pC->aOffset;\n  }else{\n    assert(u.ao.aType);\n    u.ao.avail = 0;\n    u.ao.pC->aOffset = u.ao.aOffset = &u.ao.aType[u.ao.nField];\n    u.ao.pC->payloadSize = u.ao.payloadSize;\n    u.ao.pC->cacheStatus = p->cacheCtr;\n\n    /* Figure out how many bytes are in the header */\n    if( u.ao.zRec ){\n      u.ao.zData = u.ao.zRec;\n    }else{\n      if( u.ao.pC->isIndex ){\n        u.ao.zData = (char*)sqlite3BtreeKeyFetch(u.ao.pCrsr, &u.ao.avail);\n      }else{\n        u.ao.zData = (char*)sqlite3BtreeDataFetch(u.ao.pCrsr, &u.ao.avail);\n      }\n      /* If KeyFetch()/DataFetch() managed to get the entire payload,\n      ** save the payload in the u.ao.pC->aRow cache.  That will save us from\n      ** having to make additional calls to fetch the content portion of\n      ** the record.\n      */\n      assert( u.ao.avail>=0 );\n      if( u.ao.payloadSize <= (u32)u.ao.avail ){\n        u.ao.zRec = u.ao.zData;\n        u.ao.pC->aRow = (u8*)u.ao.zData;\n      }else{\n        u.ao.pC->aRow = 0;\n      }\n    }\n    /* The following assert is true in all cases except when\n    ** the database file has been corrupted externally.\n    **    assert( u.ao.zRec!=0 || u.ao.avail>=u.ao.payloadSize || u.ao.avail>=9 ); */\n    u.ao.szHdr = getVarint32((u8*)u.ao.zData, u.ao.offset);\n\n    /* Make sure a corrupt database has not given us an oversize header.\n    ** Do this now to avoid an oversize memory allocation.\n    **\n    ** Type entries can be between 1 and 5 bytes each.  But 4 and 5 byte\n    ** types use so much data space that there can only be 4096 and 32 of\n    ** them, respectively.  So the maximum header length results from a\n    ** 3-byte type for each of the maximum of 32768 columns plus three\n    ** extra bytes for the header length itself.  32768*3 + 3 = 98307.\n    */\n    if( u.ao.offset > 98307 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto op_column_out;\n    }\n\n    /* Compute in u.ao.len the number of bytes of data we need to read in order\n    ** to get u.ao.nField type values.  u.ao.offset is an upper bound on this.  But\n    ** u.ao.nField might be significantly less than the true number of columns\n    ** in the table, and in that case, 5*u.ao.nField+3 might be smaller than u.ao.offset.\n    ** We want to minimize u.ao.len in order to limit the size of the memory\n    ** allocation, especially if a corrupt database file has caused u.ao.offset\n    ** to be oversized. Offset is limited to 98307 above.  But 98307 might\n    ** still exceed Robson memory allocation limits on some configurations.\n    ** On systems that cannot tolerate large memory allocations, u.ao.nField*5+3\n    ** will likely be much smaller since u.ao.nField will likely be less than\n    ** 20 or so.  This insures that Robson memory allocation limits are\n    ** not exceeded even for corrupt database files.\n    */\n    u.ao.len = u.ao.nField*5 + 3;\n    if( u.ao.len > (int)u.ao.offset ) u.ao.len = (int)u.ao.offset;\n\n    /* The KeyFetch() or DataFetch() above are fast and will get the entire\n    ** record header in most cases.  But they will fail to get the complete\n    ** record header if the record header does not fit on a single page\n    ** in the B-Tree.  When that happens, use sqlite3VdbeMemFromBtree() to\n    ** acquire the complete header text.\n    */\n    if( !u.ao.zRec && u.ao.avail<u.ao.len ){\n      u.ao.sMem.flags = 0;\n      u.ao.sMem.db = 0;\n      rc = sqlite3VdbeMemFromBtree(u.ao.pCrsr, 0, u.ao.len, u.ao.pC->isIndex, &u.ao.sMem);\n      if( rc!=SQLITE_OK ){\n        goto op_column_out;\n      }\n      u.ao.zData = u.ao.sMem.z;\n    }\n    u.ao.zEndHdr = (u8 *)&u.ao.zData[u.ao.len];\n    u.ao.zIdx = (u8 *)&u.ao.zData[u.ao.szHdr];\n\n    /* Scan the header and use it to fill in the u.ao.aType[] and u.ao.aOffset[]\n    ** arrays.  u.ao.aType[u.ao.i] will contain the type integer for the u.ao.i-th\n    ** column and u.ao.aOffset[u.ao.i] will contain the u.ao.offset from the beginning\n    ** of the record to the start of the data for the u.ao.i-th column\n    */\n    for(u.ao.i=0; u.ao.i<u.ao.nField; u.ao.i++){\n      if( u.ao.zIdx<u.ao.zEndHdr ){\n        u.ao.aOffset[u.ao.i] = u.ao.offset;\n        if( u.ao.zIdx[0]<0x80 ){\n          u.ao.t = u.ao.zIdx[0];\n          u.ao.zIdx++;\n        }else{\n          u.ao.zIdx += sqlite3GetVarint32(u.ao.zIdx, &u.ao.t);\n        }\n        u.ao.aType[u.ao.i] = u.ao.t;\n        u.ao.szField = sqlite3VdbeSerialTypeLen(u.ao.t);\n        u.ao.offset += u.ao.szField;\n        if( u.ao.offset<u.ao.szField ){  /* True if u.ao.offset overflows */\n          u.ao.zIdx = &u.ao.zEndHdr[1];  /* Forces SQLITE_CORRUPT return below */\n          break;\n        }\n      }else{\n        /* If u.ao.i is less that u.ao.nField, then there are fewer fields in this\n        ** record than SetNumColumns indicated there are columns in the\n        ** table. Set the u.ao.offset for any extra columns not present in\n        ** the record to 0. This tells code below to store the default value\n        ** for the column instead of deserializing a value from the record.\n        */\n        u.ao.aOffset[u.ao.i] = 0;\n      }\n    }\n    sqlite3VdbeMemRelease(&u.ao.sMem);\n    u.ao.sMem.flags = MEM_Null;\n\n    /* If we have read more header data than was contained in the header,\n    ** or if the end of the last field appears to be past the end of the\n    ** record, or if the end of the last field appears to be before the end\n    ** of the record (when all fields present), then we must be dealing\n    ** with a corrupt database.\n    */\n    if( (u.ao.zIdx > u.ao.zEndHdr) || (u.ao.offset > u.ao.payloadSize)\n         || (u.ao.zIdx==u.ao.zEndHdr && u.ao.offset!=u.ao.payloadSize) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto op_column_out;\n    }\n  }\n\n  /* Get the column information. If u.ao.aOffset[u.ao.p2] is non-zero, then\n  ** deserialize the value from the record. If u.ao.aOffset[u.ao.p2] is zero,\n  ** then there are not enough fields in the record to satisfy the\n  ** request.  In this case, set the value NULL or to P4 if P4 is\n  ** a pointer to a Mem object.\n  */\n  if( u.ao.aOffset[u.ao.p2] ){\n    assert( rc==SQLITE_OK );\n    if( u.ao.zRec ){\n      /* This is the common case where the whole row fits on a single page */\n      VdbeMemRelease(u.ao.pDest);\n      sqlite3VdbeSerialGet((u8 *)&u.ao.zRec[u.ao.aOffset[u.ao.p2]], u.ao.aType[u.ao.p2], u.ao.pDest);\n    }else{\n      /* This branch happens only when the row overflows onto multiple pages */\n      u.ao.t = u.ao.aType[u.ao.p2];\n      if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0\n       && ((u.ao.t>=12 && (u.ao.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)\n      ){\n        /* Content is irrelevant for the typeof() function and for\n        ** the length(X) function if X is a blob.  So we might as well use\n        ** bogus content rather than reading content from disk.  NULL works\n        ** for text and blob and whatever is in the u.ao.payloadSize64 variable\n        ** will work for everything else. */\n        u.ao.zData = u.ao.t<12 ? (char*)&u.ao.payloadSize64 : 0;\n      }else{\n        u.ao.len = sqlite3VdbeSerialTypeLen(u.ao.t);\n        sqlite3VdbeMemMove(&u.ao.sMem, u.ao.pDest);\n        rc = sqlite3VdbeMemFromBtree(u.ao.pCrsr, u.ao.aOffset[u.ao.p2], u.ao.len,  u.ao.pC->isIndex,\n                                     &u.ao.sMem);\n        if( rc!=SQLITE_OK ){\n          goto op_column_out;\n        }\n        u.ao.zData = u.ao.sMem.z;\n      }\n      sqlite3VdbeSerialGet((u8*)u.ao.zData, u.ao.t, u.ao.pDest);\n    }\n    u.ao.pDest->enc = encoding;\n  }else{\n    if( pOp->p4type==P4_MEM ){\n      sqlite3VdbeMemShallowCopy(u.ao.pDest, pOp->p4.pMem, MEM_Static);\n    }else{\n      MemSetTypeFlag(u.ao.pDest, MEM_Null);\n    }\n  }\n\n  /* If we dynamically allocated space to hold the data (in the\n  ** sqlite3VdbeMemFromBtree() call above) then transfer control of that\n  ** dynamically allocated space over to the u.ao.pDest structure.\n  ** This prevents a memory copy.\n  */\n  if( u.ao.sMem.zMalloc ){\n    assert( u.ao.sMem.z==u.ao.sMem.zMalloc );\n    assert( !(u.ao.pDest->flags & MEM_Dyn) );\n    assert( !(u.ao.pDest->flags & (MEM_Blob|MEM_Str)) || u.ao.pDest->z==u.ao.sMem.z );\n    u.ao.pDest->flags &= ~(MEM_Ephem|MEM_Static);\n    u.ao.pDest->flags |= MEM_Term;\n    u.ao.pDest->z = u.ao.sMem.z;\n    u.ao.pDest->zMalloc = u.ao.sMem.zMalloc;\n  }\n\n  rc = sqlite3VdbeMemMakeWriteable(u.ao.pDest);\n\nop_column_out:\n  UPDATE_MAX_BLOBSIZE(u.ao.pDest);\n  REGISTER_TRACE(pOp->p3, u.ao.pDest);\n  break;\n}\n\n/* Opcode: Affinity P1 P2 * P4 *\n**\n** Apply affinities to a range of P2 registers starting with P1.\n**\n** P4 is a string that is P2 characters long. The nth character of the\n** string indicates the column affinity that should be used for the nth\n** memory cell in the range.\n*/\ncase OP_Affinity: {\n#if 0  /* local variables moved into u.ap */\n  const char *zAffinity;   /* The affinity to be applied */\n  char cAff;               /* A single character of affinity */\n#endif /* local variables moved into u.ap */\n\n  u.ap.zAffinity = pOp->p4.z;\n  assert( u.ap.zAffinity!=0 );\n  assert( u.ap.zAffinity[pOp->p2]==0 );\n  pIn1 = &aMem[pOp->p1];\n  while( (u.ap.cAff = *(u.ap.zAffinity++))!=0 ){\n    assert( pIn1 <= &p->aMem[p->nMem] );\n    assert( memIsValid(pIn1) );\n    ExpandBlob(pIn1);\n    applyAffinity(pIn1, u.ap.cAff, encoding);\n    pIn1++;\n  }\n  break;\n}\n\n/* Opcode: MakeRecord P1 P2 P3 P4 *\n**\n** Convert P2 registers beginning with P1 into the [record format]\n** use as a data record in a database table or as a key\n** in an index.  The OP_Column opcode can decode the record later.\n**\n** P4 may be a string that is P2 characters long.  The nth character of the\n** string indicates the column affinity that should be used for the nth\n** field of the index key.\n**\n** The mapping from character to affinity is given by the SQLITE_AFF_\n** macros defined in sqliteInt.h.\n**\n** If P4 is NULL then all index fields have the affinity NONE.\n*/\ncase OP_MakeRecord: {\n#if 0  /* local variables moved into u.aq */\n  u8 *zNewRecord;        /* A buffer to hold the data for the new record */\n  Mem *pRec;             /* The new record */\n  u64 nData;             /* Number of bytes of data space */\n  int nHdr;              /* Number of bytes of header space */\n  i64 nByte;             /* Data space required for this record */\n  int nZero;             /* Number of zero bytes at the end of the record */\n  int nVarint;           /* Number of bytes in a varint */\n  u32 serial_type;       /* Type field */\n  Mem *pData0;           /* First field to be combined into the record */\n  Mem *pLast;            /* Last field of the record */\n  int nField;            /* Number of fields in the record */\n  char *zAffinity;       /* The affinity string for the record */\n  int file_format;       /* File format to use for encoding */\n  int i;                 /* Space used in zNewRecord[] */\n  int len;               /* Length of a field */\n#endif /* local variables moved into u.aq */\n\n  /* Assuming the record contains N fields, the record format looks\n  ** like this:\n  **\n  ** ------------------------------------------------------------------------\n  ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 |\n  ** ------------------------------------------------------------------------\n  **\n  ** Data(0) is taken from register P1.  Data(1) comes from register P1+1\n  ** and so froth.\n  **\n  ** Each type field is a varint representing the serial type of the\n  ** corresponding data element (see sqlite3VdbeSerialType()). The\n  ** hdr-size field is also a varint which is the offset from the beginning\n  ** of the record to data0.\n  */\n  u.aq.nData = 0;         /* Number of bytes of data space */\n  u.aq.nHdr = 0;          /* Number of bytes of header space */\n  u.aq.nZero = 0;         /* Number of zero bytes at the end of the record */\n  u.aq.nField = pOp->p1;\n  u.aq.zAffinity = pOp->p4.z;\n  assert( u.aq.nField>0 && pOp->p2>0 && pOp->p2+u.aq.nField<=p->nMem+1 );\n  u.aq.pData0 = &aMem[u.aq.nField];\n  u.aq.nField = pOp->p2;\n  u.aq.pLast = &u.aq.pData0[u.aq.nField-1];\n  u.aq.file_format = p->minWriteFileFormat;\n\n  /* Identify the output register */\n  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );\n  pOut = &aMem[pOp->p3];\n  memAboutToChange(p, pOut);\n\n  /* Loop through the elements that will make up the record to figure\n  ** out how much space is required for the new record.\n  */\n  for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){\n    assert( memIsValid(u.aq.pRec) );\n    if( u.aq.zAffinity ){\n      applyAffinity(u.aq.pRec, u.aq.zAffinity[u.aq.pRec-u.aq.pData0], encoding);\n    }\n    if( u.aq.pRec->flags&MEM_Zero && u.aq.pRec->n>0 ){\n      sqlite3VdbeMemExpandBlob(u.aq.pRec);\n    }\n    u.aq.serial_type = sqlite3VdbeSerialType(u.aq.pRec, u.aq.file_format);\n    u.aq.len = sqlite3VdbeSerialTypeLen(u.aq.serial_type);\n    u.aq.nData += u.aq.len;\n    u.aq.nHdr += sqlite3VarintLen(u.aq.serial_type);\n    if( u.aq.pRec->flags & MEM_Zero ){\n      /* Only pure zero-filled BLOBs can be input to this Opcode.\n      ** We do not allow blobs with a prefix and a zero-filled tail. */\n      u.aq.nZero += u.aq.pRec->u.nZero;\n    }else if( u.aq.len ){\n      u.aq.nZero = 0;\n    }\n  }\n\n  /* Add the initial header varint and total the size */\n  u.aq.nHdr += u.aq.nVarint = sqlite3VarintLen(u.aq.nHdr);\n  if( u.aq.nVarint<sqlite3VarintLen(u.aq.nHdr) ){\n    u.aq.nHdr++;\n  }\n  u.aq.nByte = u.aq.nHdr+u.aq.nData-u.aq.nZero;\n  if( u.aq.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n\n  /* Make sure the output register has a buffer large enough to store\n  ** the new record. The output register (pOp->p3) is not allowed to\n  ** be one of the input registers (because the following call to\n  ** sqlite3VdbeMemGrow() could clobber the value before it is used).\n  */\n  if( sqlite3VdbeMemGrow(pOut, (int)u.aq.nByte, 0) ){\n    goto no_mem;\n  }\n  u.aq.zNewRecord = (u8 *)pOut->z;\n\n  /* Write the record */\n  u.aq.i = putVarint32(u.aq.zNewRecord, u.aq.nHdr);\n  for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){\n    u.aq.serial_type = sqlite3VdbeSerialType(u.aq.pRec, u.aq.file_format);\n    u.aq.i += putVarint32(&u.aq.zNewRecord[u.aq.i], u.aq.serial_type);      /* serial type */\n  }\n  for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){  /* serial data */\n    u.aq.i += sqlite3VdbeSerialPut(&u.aq.zNewRecord[u.aq.i], (int)(u.aq.nByte-u.aq.i), u.aq.pRec,u.aq.file_format);\n  }\n  assert( u.aq.i==u.aq.nByte );\n\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  pOut->n = (int)u.aq.nByte;\n  pOut->flags = MEM_Blob | MEM_Dyn;\n  pOut->xDel = 0;\n  if( u.aq.nZero ){\n    pOut->u.nZero = u.aq.nZero;\n    pOut->flags |= MEM_Zero;\n  }\n  pOut->enc = SQLITE_UTF8;  /* In case the blob is ever converted to text */\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Count P1 P2 * * *\n**\n** Store the number of entries (an integer value) in the table or index \n** opened by cursor P1 in register P2\n*/\n#ifndef SQLITE_OMIT_BTREECOUNT\ncase OP_Count: {         /* out2-prerelease */\n#if 0  /* local variables moved into u.ar */\n  i64 nEntry;\n  BtCursor *pCrsr;\n#endif /* local variables moved into u.ar */\n\n  u.ar.pCrsr = p->apCsr[pOp->p1]->pCursor;\n  if( ALWAYS(u.ar.pCrsr) ){\n    rc = sqlite3BtreeCount(u.ar.pCrsr, &u.ar.nEntry);\n  }else{\n    u.ar.nEntry = 0;\n  }\n  pOut->u.i = u.ar.nEntry;\n  break;\n}\n#endif\n\n/* Opcode: Savepoint P1 * * P4 *\n**\n** Open, release or rollback the savepoint named by parameter P4, depending\n** on the value of P1. To open a new savepoint, P1==0. To release (commit) an\n** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.\n*/\ncase OP_Savepoint: {\n#if 0  /* local variables moved into u.as */\n  int p1;                         /* Value of P1 operand */\n  char *zName;                    /* Name of savepoint */\n  int nName;\n  Savepoint *pNew;\n  Savepoint *pSavepoint;\n  Savepoint *pTmp;\n  int iSavepoint;\n  int ii;\n#endif /* local variables moved into u.as */\n\n  u.as.p1 = pOp->p1;\n  u.as.zName = pOp->p4.z;\n\n  /* Assert that the u.as.p1 parameter is valid. Also that if there is no open\n  ** transaction, then there cannot be any savepoints.\n  */\n  assert( db->pSavepoint==0 || db->autoCommit==0 );\n  assert( u.as.p1==SAVEPOINT_BEGIN||u.as.p1==SAVEPOINT_RELEASE||u.as.p1==SAVEPOINT_ROLLBACK );\n  assert( db->pSavepoint || db->isTransactionSavepoint==0 );\n  assert( checkSavepointCount(db) );\n\n  if( u.as.p1==SAVEPOINT_BEGIN ){\n    if( db->writeVdbeCnt>0 ){\n      /* A new savepoint cannot be created if there are active write\n      ** statements (i.e. open read/write incremental blob handles).\n      */\n      sqlite3SetString(&p->zErrMsg, db, \"cannot open savepoint - \"\n        \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n      u.as.nName = sqlite3Strlen30(u.as.zName);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* This call is Ok even if this savepoint is actually a transaction\n      ** savepoint (and therefore should not prompt xSavepoint()) callbacks.\n      ** If this is a transaction savepoint being opened, it is guaranteed\n      ** that the db->aVTrans[] array is empty.  */\n      assert( db->autoCommit==0 || db->nVTrans==0 );\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,\n                                db->nStatement+db->nSavepoint);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n      /* Create a new savepoint structure. */\n      u.as.pNew = sqlite3DbMallocRaw(db, sizeof(Savepoint)+u.as.nName+1);\n      if( u.as.pNew ){\n        u.as.pNew->zName = (char *)&u.as.pNew[1];\n        memcpy(u.as.pNew->zName, u.as.zName, u.as.nName+1);\n\n        /* If there is no open transaction, then mark this as a special\n        ** \"transaction savepoint\". */\n        if( db->autoCommit ){\n          db->autoCommit = 0;\n          db->isTransactionSavepoint = 1;\n        }else{\n          db->nSavepoint++;\n        }\n\n        /* Link the new savepoint into the database handle's list. */\n        u.as.pNew->pNext = db->pSavepoint;\n        db->pSavepoint = u.as.pNew;\n        u.as.pNew->nDeferredCons = db->nDeferredCons;\n      }\n    }\n  }else{\n    u.as.iSavepoint = 0;\n\n    /* Find the named savepoint. If there is no such savepoint, then an\n    ** an error is returned to the user.  */\n    for(\n      u.as.pSavepoint = db->pSavepoint;\n      u.as.pSavepoint && sqlite3StrICmp(u.as.pSavepoint->zName, u.as.zName);\n      u.as.pSavepoint = u.as.pSavepoint->pNext\n    ){\n      u.as.iSavepoint++;\n    }\n    if( !u.as.pSavepoint ){\n      sqlite3SetString(&p->zErrMsg, db, \"no such savepoint: %s\", u.as.zName);\n      rc = SQLITE_ERROR;\n    }else if( db->writeVdbeCnt>0 && u.as.p1==SAVEPOINT_RELEASE ){\n      /* It is not possible to release (commit) a savepoint if there are\n      ** active write statements.\n      */\n      sqlite3SetString(&p->zErrMsg, db,\n        \"cannot release savepoint - SQL statements in progress\"\n      );\n      rc = SQLITE_BUSY;\n    }else{\n\n      /* Determine whether or not this is a transaction savepoint. If so,\n      ** and this is a RELEASE command, then the current transaction\n      ** is committed.\n      */\n      int isTransaction = u.as.pSavepoint->pNext==0 && db->isTransactionSavepoint;\n      if( isTransaction && u.as.p1==SAVEPOINT_RELEASE ){\n        if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n          goto vdbe_return;\n        }\n        db->autoCommit = 1;\n        if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n          p->pc = pc;\n          db->autoCommit = 0;\n          p->rc = rc = SQLITE_BUSY;\n          goto vdbe_return;\n        }\n        db->isTransactionSavepoint = 0;\n        rc = p->rc;\n      }else{\n        u.as.iSavepoint = db->nSavepoint - u.as.iSavepoint - 1;\n        if( u.as.p1==SAVEPOINT_ROLLBACK ){\n          for(u.as.ii=0; u.as.ii<db->nDb; u.as.ii++){\n            sqlite3BtreeTripAllCursors(db->aDb[u.as.ii].pBt, SQLITE_ABORT);\n          }\n        }\n        for(u.as.ii=0; u.as.ii<db->nDb; u.as.ii++){\n          rc = sqlite3BtreeSavepoint(db->aDb[u.as.ii].pBt, u.as.p1, u.as.iSavepoint);\n          if( rc!=SQLITE_OK ){\n            goto abort_due_to_error;\n          }\n        }\n        if( u.as.p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){\n          sqlite3ExpirePreparedStatements(db);\n          sqlite3ResetAllSchemasOfConnection(db);\n          db->flags = (db->flags | SQLITE_InternChanges);\n        }\n      }\n\n      /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all\n      ** savepoints nested inside of the savepoint being operated on. */\n      while( db->pSavepoint!=u.as.pSavepoint ){\n        u.as.pTmp = db->pSavepoint;\n        db->pSavepoint = u.as.pTmp->pNext;\n        sqlite3DbFree(db, u.as.pTmp);\n        db->nSavepoint--;\n      }\n\n      /* If it is a RELEASE, then destroy the savepoint being operated on\n      ** too. If it is a ROLLBACK TO, then set the number of deferred\n      ** constraint violations present in the database to the value stored\n      ** when the savepoint was created.  */\n      if( u.as.p1==SAVEPOINT_RELEASE ){\n        assert( u.as.pSavepoint==db->pSavepoint );\n        db->pSavepoint = u.as.pSavepoint->pNext;\n        sqlite3DbFree(db, u.as.pSavepoint);\n        if( !isTransaction ){\n          db->nSavepoint--;\n        }\n      }else{\n        db->nDeferredCons = u.as.pSavepoint->nDeferredCons;\n      }\n\n      if( !isTransaction ){\n        rc = sqlite3VtabSavepoint(db, u.as.p1, u.as.iSavepoint);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      }\n    }\n  }\n\n  break;\n}\n\n/* Opcode: AutoCommit P1 P2 * * *\n**\n** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll\n** back any currently active btree transactions. If there are any active\n** VMs (apart from this one), then a ROLLBACK fails.  A COMMIT fails if\n** there are active writing VMs or active VMs that use shared cache.\n**\n** This instruction causes the VM to halt.\n*/\ncase OP_AutoCommit: {\n#if 0  /* local variables moved into u.at */\n  int desiredAutoCommit;\n  int iRollback;\n  int turnOnAC;\n#endif /* local variables moved into u.at */\n\n  u.at.desiredAutoCommit = pOp->p1;\n  u.at.iRollback = pOp->p2;\n  u.at.turnOnAC = u.at.desiredAutoCommit && !db->autoCommit;\n  assert( u.at.desiredAutoCommit==1 || u.at.desiredAutoCommit==0 );\n  assert( u.at.desiredAutoCommit==1 || u.at.iRollback==0 );\n  assert( db->activeVdbeCnt>0 );  /* At least this one VM is active */\n\n#if 0\n  if( u.at.turnOnAC && u.at.iRollback && db->activeVdbeCnt>1 ){\n    /* If this instruction implements a ROLLBACK and other VMs are\n    ** still running, and a transaction is active, return an error indicating\n    ** that the other VMs must complete first.\n    */\n    sqlite3SetString(&p->zErrMsg, db, \"cannot rollback transaction - \"\n        \"SQL statements in progress\");\n    rc = SQLITE_BUSY;\n  }else\n#endif\n  if( u.at.turnOnAC && !u.at.iRollback && db->writeVdbeCnt>0 ){\n    /* If this instruction implements a COMMIT and other VMs are writing\n    ** return an error indicating that the other VMs must complete first.\n    */\n    sqlite3SetString(&p->zErrMsg, db, \"cannot commit transaction - \"\n        \"SQL statements in progress\");\n    rc = SQLITE_BUSY;\n  }else if( u.at.desiredAutoCommit!=db->autoCommit ){\n    if( u.at.iRollback ){\n      assert( u.at.desiredAutoCommit==1 );\n      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n      db->autoCommit = 1;\n    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n      goto vdbe_return;\n    }else{\n      db->autoCommit = (u8)u.at.desiredAutoCommit;\n      if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n        p->pc = pc;\n        db->autoCommit = (u8)(1-u.at.desiredAutoCommit);\n        p->rc = rc = SQLITE_BUSY;\n        goto vdbe_return;\n      }\n    }\n    assert( db->nStatement==0 );\n    sqlite3CloseSavepoints(db);\n    if( p->rc==SQLITE_OK ){\n      rc = SQLITE_DONE;\n    }else{\n      rc = SQLITE_ERROR;\n    }\n    goto vdbe_return;\n  }else{\n    sqlite3SetString(&p->zErrMsg, db,\n        (!u.at.desiredAutoCommit)?\"cannot start a transaction within a transaction\":(\n        (u.at.iRollback)?\"cannot rollback - no transaction is active\":\n                   \"cannot commit - no transaction is active\"));\n\n    rc = SQLITE_ERROR;\n  }\n  break;\n}\n\n/* Opcode: Transaction P1 P2 * * *\n**\n** Begin a transaction.  The transaction ends when a Commit or Rollback\n** opcode is encountered.  Depending on the ON CONFLICT setting, the\n** transaction might also be rolled back if an error is encountered.\n**\n** P1 is the index of the database file on which the transaction is\n** started.  Index 0 is the main database file and index 1 is the\n** file used for temporary tables.  Indices of 2 or more are used for\n** attached databases.\n**\n** If P2 is non-zero, then a write-transaction is started.  A RESERVED lock is\n** obtained on the database file when a write-transaction is started.  No\n** other process can start another write transaction while this transaction is\n** underway.  Starting a write transaction also creates a rollback journal. A\n** write transaction must be started before any changes can be made to the\n** database.  If P2 is 2 or greater then an EXCLUSIVE lock is also obtained\n** on the file.\n**\n** If a write-transaction is started and the Vdbe.usesStmtJournal flag is\n** true (this flag is set if the Vdbe may modify more than one row and may\n** throw an ABORT exception), a statement transaction may also be opened.\n** More specifically, a statement transaction is opened iff the database\n** connection is currently not in autocommit mode, or if there are other\n** active statements. A statement transaction allows the changes made by this\n** VDBE to be rolled back after an error without having to roll back the\n** entire transaction. If no error is encountered, the statement transaction\n** will automatically commit when the VDBE halts.\n**\n** If P2 is zero, then a read-lock is obtained on the database file.\n*/\ncase OP_Transaction: {\n#if 0  /* local variables moved into u.au */\n  Btree *pBt;\n#endif /* local variables moved into u.au */\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );\n  u.au.pBt = db->aDb[pOp->p1].pBt;\n\n  if( u.au.pBt ){\n    rc = sqlite3BtreeBeginTrans(u.au.pBt, pOp->p2);\n    if( rc==SQLITE_BUSY ){\n      p->pc = pc;\n      p->rc = rc = SQLITE_BUSY;\n      goto vdbe_return;\n    }\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n\n    if( pOp->p2 && p->usesStmtJournal\n     && (db->autoCommit==0 || db->activeVdbeCnt>1)\n    ){\n      assert( sqlite3BtreeIsInTrans(u.au.pBt) );\n      if( p->iStatement==0 ){\n        assert( db->nStatement>=0 && db->nSavepoint>=0 );\n        db->nStatement++;\n        p->iStatement = db->nSavepoint + db->nStatement;\n      }\n\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeBeginStmt(u.au.pBt, p->iStatement);\n      }\n\n      /* Store the current value of the database handles deferred constraint\n      ** counter. If the statement transaction needs to be rolled back,\n      ** the value of this counter needs to be restored too.  */\n      p->nStmtDefCons = db->nDeferredCons;\n    }\n  }\n  break;\n}\n\n/* Opcode: ReadCookie P1 P2 P3 * *\n**\n** Read cookie number P3 from database P1 and write it into register P2.\n** P3==1 is the schema version.  P3==2 is the database format.\n** P3==3 is the recommended pager cache size, and so forth.  P1==0 is\n** the main database file and P1==1 is the database file used to store\n** temporary tables.\n**\n** There must be a read-lock on the database (either a transaction\n** must be started or there must be an open cursor) before\n** executing this instruction.\n*/\ncase OP_ReadCookie: {               /* out2-prerelease */\n#if 0  /* local variables moved into u.av */\n  int iMeta;\n  int iDb;\n  int iCookie;\n#endif /* local variables moved into u.av */\n\n  u.av.iDb = pOp->p1;\n  u.av.iCookie = pOp->p3;\n  assert( pOp->p3<SQLITE_N_BTREE_META );\n  assert( u.av.iDb>=0 && u.av.iDb<db->nDb );\n  assert( db->aDb[u.av.iDb].pBt!=0 );\n  assert( (p->btreeMask & (((yDbMask)1)<<u.av.iDb))!=0 );\n\n  sqlite3BtreeGetMeta(db->aDb[u.av.iDb].pBt, u.av.iCookie, (u32 *)&u.av.iMeta);\n  pOut->u.i = u.av.iMeta;\n  break;\n}\n\n/* Opcode: SetCookie P1 P2 P3 * *\n**\n** Write the content of register P3 (interpreted as an integer)\n** into cookie number P2 of database P1.  P2==1 is the schema version.  \n** P2==2 is the database format. P2==3 is the recommended pager cache \n** size, and so forth.  P1==0 is the main database file and P1==1 is the \n** database file used to store temporary tables.\n**\n** A transaction must be started before executing this opcode.\n*/\ncase OP_SetCookie: {       /* in3 */\n#if 0  /* local variables moved into u.aw */\n  Db *pDb;\n#endif /* local variables moved into u.aw */\n  assert( pOp->p2<SQLITE_N_BTREE_META );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );\n  u.aw.pDb = &db->aDb[pOp->p1];\n  assert( u.aw.pDb->pBt!=0 );\n  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );\n  pIn3 = &aMem[pOp->p3];\n  sqlite3VdbeMemIntegerify(pIn3);\n  /* See note about index shifting on OP_ReadCookie */\n  rc = sqlite3BtreeUpdateMeta(u.aw.pDb->pBt, pOp->p2, (int)pIn3->u.i);\n  if( pOp->p2==BTREE_SCHEMA_VERSION ){\n    /* When the schema cookie changes, record the new cookie internally */\n    u.aw.pDb->pSchema->schema_cookie = (int)pIn3->u.i;\n    db->flags |= SQLITE_InternChanges;\n  }else if( pOp->p2==BTREE_FILE_FORMAT ){\n    /* Record changes in the file format */\n    u.aw.pDb->pSchema->file_format = (u8)pIn3->u.i;\n  }\n  if( pOp->p1==1 ){\n    /* Invalidate all prepared statements whenever the TEMP database\n    ** schema is changed.  Ticket #1644 */\n    sqlite3ExpirePreparedStatements(db);\n    p->expired = 0;\n  }\n  break;\n}\n\n/* Opcode: VerifyCookie P1 P2 P3 * *\n**\n** Check the value of global database parameter number 0 (the\n** schema version) and make sure it is equal to P2 and that the\n** generation counter on the local schema parse equals P3.\n**\n** P1 is the database number which is 0 for the main database file\n** and 1 for the file holding temporary tables and some higher number\n** for auxiliary databases.\n**\n** The cookie changes its value whenever the database schema changes.\n** This operation is used to detect when that the cookie has changed\n** and that the current process needs to reread the schema.\n**\n** Either a transaction needs to have been started or an OP_Open needs\n** to be executed (to establish a read lock) before this opcode is\n** invoked.\n*/\ncase OP_VerifyCookie: {\n#if 0  /* local variables moved into u.ax */\n  int iMeta;\n  int iGen;\n  Btree *pBt;\n#endif /* local variables moved into u.ax */\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );\n  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );\n  u.ax.pBt = db->aDb[pOp->p1].pBt;\n  if( u.ax.pBt ){\n    sqlite3BtreeGetMeta(u.ax.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ax.iMeta);\n    u.ax.iGen = db->aDb[pOp->p1].pSchema->iGeneration;\n  }else{\n    u.ax.iGen = u.ax.iMeta = 0;\n  }\n  if( u.ax.iMeta!=pOp->p2 || u.ax.iGen!=pOp->p3 ){\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, \"database schema has changed\");\n    /* If the schema-cookie from the database file matches the cookie\n    ** stored with the in-memory representation of the schema, do\n    ** not reload the schema from the database file.\n    **\n    ** If virtual-tables are in use, this is not just an optimization.\n    ** Often, v-tables store their data in other SQLite tables, which\n    ** are queried from within xNext() and other v-table methods using\n    ** prepared queries. If such a query is out-of-date, we do not want to\n    ** discard the database schema, as the user code implementing the\n    ** v-table would have to be ready for the sqlite3_vtab structure itself\n    ** to be invalidated whenever sqlite3_step() is called from within\n    ** a v-table method.\n    */\n    if( db->aDb[pOp->p1].pSchema->schema_cookie!=u.ax.iMeta ){\n      sqlite3ResetOneSchema(db, pOp->p1);\n    }\n\n    p->expired = 1;\n    rc = SQLITE_SCHEMA;\n  }\n  break;\n}\n\n/* Opcode: OpenRead P1 P2 P3 P4 P5\n**\n** Open a read-only cursor for the database table whose root page is\n** P2 in a database file.  The database file is determined by P3. \n** P3==0 means the main database, P3==1 means the database used for \n** temporary tables, and P3>1 means used the corresponding attached\n** database.  Give the new cursor an identifier of P1.  The P1\n** values need not be contiguous but all P1 values should be small integers.\n** It is an error for P1 to be negative.\n**\n** If P5!=0 then use the content of register P2 as the root page, not\n** the value of P2 itself.\n**\n** There will be a read lock on the database whenever there is an\n** open cursor.  If the database was unlocked prior to this instruction\n** then a read lock is acquired as part of this instruction.  A read\n** lock allows other processes to read the database but prohibits\n** any other process from modifying the database.  The read lock is\n** released when all cursors are closed.  If this instruction attempts\n** to get a read lock but fails, the script terminates with an\n** SQLITE_BUSY error code.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table.\n**\n** See also OpenWrite.\n*/\n/* Opcode: OpenWrite P1 P2 P3 P4 P5\n**\n** Open a read/write cursor named P1 on the table or index whose root\n** page is P2.  Or if P5!=0 use the content of register P2 to find the\n** root page.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table, or to the\n** largest index of any column of the table that is actually used.\n**\n** This instruction works just like OpenRead except that it opens the cursor\n** in read/write mode.  For a given table, there can be one or more read-only\n** cursors or a single read/write cursor but not both.\n**\n** See also OpenRead.\n*/\ncase OP_OpenRead:\ncase OP_OpenWrite: {\n#if 0  /* local variables moved into u.ay */\n  int nField;\n  KeyInfo *pKeyInfo;\n  int p2;\n  int iDb;\n  int wrFlag;\n  Btree *pX;\n  VdbeCursor *pCur;\n  Db *pDb;\n#endif /* local variables moved into u.ay */\n\n  assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );\n  assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );\n\n  if( p->expired ){\n    rc = SQLITE_ABORT;\n    break;\n  }\n\n  u.ay.nField = 0;\n  u.ay.pKeyInfo = 0;\n  u.ay.p2 = pOp->p2;\n  u.ay.iDb = pOp->p3;\n  assert( u.ay.iDb>=0 && u.ay.iDb<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<u.ay.iDb))!=0 );\n  u.ay.pDb = &db->aDb[u.ay.iDb];\n  u.ay.pX = u.ay.pDb->pBt;\n  assert( u.ay.pX!=0 );\n  if( pOp->opcode==OP_OpenWrite ){\n    u.ay.wrFlag = 1;\n    assert( sqlite3SchemaMutexHeld(db, u.ay.iDb, 0) );\n    if( u.ay.pDb->pSchema->file_format < p->minWriteFileFormat ){\n      p->minWriteFileFormat = u.ay.pDb->pSchema->file_format;\n    }\n  }else{\n    u.ay.wrFlag = 0;\n  }\n  if( pOp->p5 & OPFLAG_P2ISREG ){\n    assert( u.ay.p2>0 );\n    assert( u.ay.p2<=p->nMem );\n    pIn2 = &aMem[u.ay.p2];\n    assert( memIsValid(pIn2) );\n    assert( (pIn2->flags & MEM_Int)!=0 );\n    sqlite3VdbeMemIntegerify(pIn2);\n    u.ay.p2 = (int)pIn2->u.i;\n    /* The u.ay.p2 value always comes from a prior OP_CreateTable opcode and\n    ** that opcode will always set the u.ay.p2 value to 2 or more or else fail.\n    ** If there were a failure, the prepared statement would have halted\n    ** before reaching this instruction. */\n    if( NEVER(u.ay.p2<2) ) {\n      rc = SQLITE_CORRUPT_BKPT;\n      goto abort_due_to_error;\n    }\n  }\n  if( pOp->p4type==P4_KEYINFO ){\n    u.ay.pKeyInfo = pOp->p4.pKeyInfo;\n    u.ay.pKeyInfo->enc = ENC(p->db);\n    u.ay.nField = u.ay.pKeyInfo->nField+1;\n  }else if( pOp->p4type==P4_INT32 ){\n    u.ay.nField = pOp->p4.i;\n  }\n  assert( pOp->p1>=0 );\n  u.ay.pCur = allocateCursor(p, pOp->p1, u.ay.nField, u.ay.iDb, 1);\n  if( u.ay.pCur==0 ) goto no_mem;\n  u.ay.pCur->nullRow = 1;\n  u.ay.pCur->isOrdered = 1;\n  rc = sqlite3BtreeCursor(u.ay.pX, u.ay.p2, u.ay.wrFlag, u.ay.pKeyInfo, u.ay.pCur->pCursor);\n  u.ay.pCur->pKeyInfo = u.ay.pKeyInfo;\n  assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );\n  sqlite3BtreeCursorHints(u.ay.pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR));\n\n  /* Since it performs no memory allocation or IO, the only value that\n  ** sqlite3BtreeCursor() may return is SQLITE_OK. */\n  assert( rc==SQLITE_OK );\n\n  /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of\n  ** SQLite used to check if the root-page flags were sane at this point\n  ** and report database corruption if they were not, but this check has\n  ** since moved into the btree layer.  */\n  u.ay.pCur->isTable = pOp->p4type!=P4_KEYINFO;\n  u.ay.pCur->isIndex = !u.ay.pCur->isTable;\n  break;\n}\n\n/* Opcode: OpenEphemeral P1 P2 * P4 P5\n**\n** Open a new cursor P1 to a transient table.\n** The cursor is always opened read/write even if \n** the main database is read-only.  The ephemeral\n** table is deleted automatically when the cursor is closed.\n**\n** P2 is the number of columns in the ephemeral table.\n** The cursor points to a BTree table if P4==0 and to a BTree index\n** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure\n** that defines the format of keys in the index.\n**\n** This opcode was once called OpenTemp.  But that created\n** confusion because the term \"temp table\", might refer either\n** to a TEMP table at the SQL level, or to a table opened by\n** this opcode.  Then this opcode was call OpenVirtual.  But\n** that created confusion with the whole virtual-table idea.\n**\n** The P5 parameter can be a mask of the BTREE_* flags defined\n** in btree.h.  These flags control aspects of the operation of\n** the btree.  The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are\n** added automatically.\n*/\n/* Opcode: OpenAutoindex P1 P2 * P4 *\n**\n** This opcode works the same as OP_OpenEphemeral.  It has a\n** different name to distinguish its use.  Tables created using\n** by this opcode will be used for automatically created transient\n** indices in joins.\n*/\ncase OP_OpenAutoindex: \ncase OP_OpenEphemeral: {\n#if 0  /* local variables moved into u.az */\n  VdbeCursor *pCx;\n#endif /* local variables moved into u.az */\n  static const int vfsFlags =\n      SQLITE_OPEN_READWRITE |\n      SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE |\n      SQLITE_OPEN_DELETEONCLOSE |\n      SQLITE_OPEN_TRANSIENT_DB;\n\n  assert( pOp->p1>=0 );\n  u.az.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1);\n  if( u.az.pCx==0 ) goto no_mem;\n  u.az.pCx->nullRow = 1;\n  rc = sqlite3BtreeOpen(db->pVfs, 0, db, &u.az.pCx->pBt,\n                        BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeBeginTrans(u.az.pCx->pBt, 1);\n  }\n  if( rc==SQLITE_OK ){\n    /* If a transient index is required, create it by calling\n    ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before\n    ** opening it. If a transient table is required, just use the\n    ** automatically created table with root-page 1 (an BLOB_INTKEY table).\n    */\n    if( pOp->p4.pKeyInfo ){\n      int pgno;\n      assert( pOp->p4type==P4_KEYINFO );\n      rc = sqlite3BtreeCreateTable(u.az.pCx->pBt, &pgno, BTREE_BLOBKEY | pOp->p5);\n      if( rc==SQLITE_OK ){\n        assert( pgno==MASTER_ROOT+1 );\n        rc = sqlite3BtreeCursor(u.az.pCx->pBt, pgno, 1,\n                                (KeyInfo*)pOp->p4.z, u.az.pCx->pCursor);\n        u.az.pCx->pKeyInfo = pOp->p4.pKeyInfo;\n        u.az.pCx->pKeyInfo->enc = ENC(p->db);\n      }\n      u.az.pCx->isTable = 0;\n    }else{\n      rc = sqlite3BtreeCursor(u.az.pCx->pBt, MASTER_ROOT, 1, 0, u.az.pCx->pCursor);\n      u.az.pCx->isTable = 1;\n    }\n  }\n  u.az.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);\n  u.az.pCx->isIndex = !u.az.pCx->isTable;\n  break;\n}\n\n/* Opcode: SorterOpen P1 P2 * P4 *\n**\n** This opcode works like OP_OpenEphemeral except that it opens\n** a transient index that is specifically designed to sort large\n** tables using an external merge-sort algorithm.\n*/\ncase OP_SorterOpen: {\n#if 0  /* local variables moved into u.ba */\n  VdbeCursor *pCx;\n#endif /* local variables moved into u.ba */\n\n  u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1);\n  if( u.ba.pCx==0 ) goto no_mem;\n  u.ba.pCx->pKeyInfo = pOp->p4.pKeyInfo;\n  u.ba.pCx->pKeyInfo->enc = ENC(p->db);\n  u.ba.pCx->isSorter = 1;\n  rc = sqlite3VdbeSorterInit(db, u.ba.pCx);\n  break;\n}\n\n/* Opcode: OpenPseudo P1 P2 P3 * P5\n**\n** Open a new cursor that points to a fake table that contains a single\n** row of data.  The content of that one row in the content of memory\n** register P2 when P5==0.  In other words, cursor P1 becomes an alias for the \n** MEM_Blob content contained in register P2.  When P5==1, then the\n** row is represented by P3 consecutive registers beginning with P2.\n**\n** A pseudo-table created by this opcode is used to hold a single\n** row output from the sorter so that the row can be decomposed into\n** individual columns using the OP_Column opcode.  The OP_Column opcode\n** is the only cursor opcode that works with a pseudo-table.\n**\n** P3 is the number of fields in the records that will be stored by\n** the pseudo-table.\n*/\ncase OP_OpenPseudo: {\n#if 0  /* local variables moved into u.bb */\n  VdbeCursor *pCx;\n#endif /* local variables moved into u.bb */\n\n  assert( pOp->p1>=0 );\n  u.bb.pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, 0);\n  if( u.bb.pCx==0 ) goto no_mem;\n  u.bb.pCx->nullRow = 1;\n  u.bb.pCx->pseudoTableReg = pOp->p2;\n  u.bb.pCx->isTable = 1;\n  u.bb.pCx->isIndex = 0;\n  u.bb.pCx->multiPseudo = pOp->p5;\n  break;\n}\n\n/* Opcode: Close P1 * * * *\n**\n** Close a cursor previously opened as P1.  If P1 is not\n** currently open, this instruction is a no-op.\n*/\ncase OP_Close: {\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  sqlite3VdbeFreeCursor(p, p->apCsr[pOp->p1]);\n  p->apCsr[pOp->p1] = 0;\n  break;\n}\n\n/* Opcode: SeekGe P1 P2 P3 P4 *\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as the key.  If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than or equal to the key value. If there are no records \n** greater than or equal to the key and P2 is not zero, then jump to P2.\n**\n** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe\n*/\n/* Opcode: SeekGt P1 P2 P3 P4 *\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than the key value. If there are no records greater than \n** the key and P2 is not zero, then jump to P2.\n**\n** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLt P1 P2 P3 P4 * \n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the largest entry that \n** is less than the key value. If there are no records less than \n** the key and P2 is not zero, then jump to P2.\n**\n** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLe P1 P2 P3 P4 *\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that it points to the largest entry that \n** is less than or equal to the key value. If there are no records \n** less than or equal to the key and P2 is not zero, then jump to P2.\n**\n** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLt\n*/\ncase OP_SeekLt:         /* jump, in3 */\ncase OP_SeekLe:         /* jump, in3 */\ncase OP_SeekGe:         /* jump, in3 */\ncase OP_SeekGt: {       /* jump, in3 */\n#if 0  /* local variables moved into u.bc */\n  int res;\n  int oc;\n  VdbeCursor *pC;\n  UnpackedRecord r;\n  int nField;\n  i64 iKey;      /* The rowid we are to seek to */\n#endif /* local variables moved into u.bc */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p2!=0 );\n  u.bc.pC = p->apCsr[pOp->p1];\n  assert( u.bc.pC!=0 );\n  assert( u.bc.pC->pseudoTableReg==0 );\n  assert( OP_SeekLe == OP_SeekLt+1 );\n  assert( OP_SeekGe == OP_SeekLt+2 );\n  assert( OP_SeekGt == OP_SeekLt+3 );\n  assert( u.bc.pC->isOrdered );\n  if( ALWAYS(u.bc.pC->pCursor!=0) ){\n    u.bc.oc = pOp->opcode;\n    u.bc.pC->nullRow = 0;\n    if( u.bc.pC->isTable ){\n      /* The input value in P3 might be of any type: integer, real, string,\n      ** blob, or NULL.  But it needs to be an integer before we can do\n      ** the seek, so covert it. */\n      pIn3 = &aMem[pOp->p3];\n      applyNumericAffinity(pIn3);\n      u.bc.iKey = sqlite3VdbeIntValue(pIn3);\n      u.bc.pC->rowidIsValid = 0;\n\n      /* If the P3 value could not be converted into an integer without\n      ** loss of information, then special processing is required... */\n      if( (pIn3->flags & MEM_Int)==0 ){\n        if( (pIn3->flags & MEM_Real)==0 ){\n          /* If the P3 value cannot be converted into any kind of a number,\n          ** then the seek is not possible, so jump to P2 */\n          pc = pOp->p2 - 1;\n          break;\n        }\n        /* If we reach this point, then the P3 value must be a floating\n        ** point number. */\n        assert( (pIn3->flags & MEM_Real)!=0 );\n\n        if( u.bc.iKey==SMALLEST_INT64 && (pIn3->r<(double)u.bc.iKey || pIn3->r>0) ){\n          /* The P3 value is too large in magnitude to be expressed as an\n          ** integer. */\n          u.bc.res = 1;\n          if( pIn3->r<0 ){\n            if( u.bc.oc>=OP_SeekGe ){  assert( u.bc.oc==OP_SeekGe || u.bc.oc==OP_SeekGt );\n              rc = sqlite3BtreeFirst(u.bc.pC->pCursor, &u.bc.res);\n              if( rc!=SQLITE_OK ) goto abort_due_to_error;\n            }\n          }else{\n            if( u.bc.oc<=OP_SeekLe ){  assert( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekLe );\n              rc = sqlite3BtreeLast(u.bc.pC->pCursor, &u.bc.res);\n              if( rc!=SQLITE_OK ) goto abort_due_to_error;\n            }\n          }\n          if( u.bc.res ){\n            pc = pOp->p2 - 1;\n          }\n          break;\n        }else if( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekGe ){\n          /* Use the ceiling() function to convert real->int */\n          if( pIn3->r > (double)u.bc.iKey ) u.bc.iKey++;\n        }else{\n          /* Use the floor() function to convert real->int */\n          assert( u.bc.oc==OP_SeekLe || u.bc.oc==OP_SeekGt );\n          if( pIn3->r < (double)u.bc.iKey ) u.bc.iKey--;\n        }\n      }\n      rc = sqlite3BtreeMovetoUnpacked(u.bc.pC->pCursor, 0, (u64)u.bc.iKey, 0, &u.bc.res);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      if( u.bc.res==0 ){\n        u.bc.pC->rowidIsValid = 1;\n        u.bc.pC->lastRowid = u.bc.iKey;\n      }\n    }else{\n      u.bc.nField = pOp->p4.i;\n      assert( pOp->p4type==P4_INT32 );\n      assert( u.bc.nField>0 );\n      u.bc.r.pKeyInfo = u.bc.pC->pKeyInfo;\n      u.bc.r.nField = (u16)u.bc.nField;\n\n      /* The next line of code computes as follows, only faster:\n      **   if( u.bc.oc==OP_SeekGt || u.bc.oc==OP_SeekLe ){\n      **     u.bc.r.flags = UNPACKED_INCRKEY;\n      **   }else{\n      **     u.bc.r.flags = 0;\n      **   }\n      */\n      u.bc.r.flags = (u8)(UNPACKED_INCRKEY * (1 & (u.bc.oc - OP_SeekLt)));\n      assert( u.bc.oc!=OP_SeekGt || u.bc.r.flags==UNPACKED_INCRKEY );\n      assert( u.bc.oc!=OP_SeekLe || u.bc.r.flags==UNPACKED_INCRKEY );\n      assert( u.bc.oc!=OP_SeekGe || u.bc.r.flags==0 );\n      assert( u.bc.oc!=OP_SeekLt || u.bc.r.flags==0 );\n\n      u.bc.r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n      { int i; for(i=0; i<u.bc.r.nField; i++) assert( memIsValid(&u.bc.r.aMem[i]) ); }\n#endif\n      ExpandBlob(u.bc.r.aMem);\n      rc = sqlite3BtreeMovetoUnpacked(u.bc.pC->pCursor, &u.bc.r, 0, 0, &u.bc.res);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      u.bc.pC->rowidIsValid = 0;\n    }\n    u.bc.pC->deferredMoveto = 0;\n    u.bc.pC->cacheStatus = CACHE_STALE;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n    if( u.bc.oc>=OP_SeekGe ){  assert( u.bc.oc==OP_SeekGe || u.bc.oc==OP_SeekGt );\n      if( u.bc.res<0 || (u.bc.res==0 && u.bc.oc==OP_SeekGt) ){\n        rc = sqlite3BtreeNext(u.bc.pC->pCursor, &u.bc.res);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n        u.bc.pC->rowidIsValid = 0;\n      }else{\n        u.bc.res = 0;\n      }\n    }else{\n      assert( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekLe );\n      if( u.bc.res>0 || (u.bc.res==0 && u.bc.oc==OP_SeekLt) ){\n        rc = sqlite3BtreePrevious(u.bc.pC->pCursor, &u.bc.res);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n        u.bc.pC->rowidIsValid = 0;\n      }else{\n        /* u.bc.res might be negative because the table is empty.  Check to\n        ** see if this is the case.\n        */\n        u.bc.res = sqlite3BtreeEof(u.bc.pC->pCursor);\n      }\n    }\n    assert( pOp->p2>0 );\n    if( u.bc.res ){\n      pc = pOp->p2 - 1;\n    }\n  }else{\n    /* This happens when attempting to open the sqlite3_master table\n    ** for read access returns SQLITE_EMPTY. In this case always\n    ** take the jump (since there are no records in the table).\n    */\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: Seek P1 P2 * * *\n**\n** P1 is an open table cursor and P2 is a rowid integer.  Arrange\n** for P1 to move so that it points to the rowid given by P2.\n**\n** This is actually a deferred seek.  Nothing actually happens until\n** the cursor is used to read a record.  That way, if no reads\n** occur, no unnecessary I/O happens.\n*/\ncase OP_Seek: {    /* in2 */\n#if 0  /* local variables moved into u.bd */\n  VdbeCursor *pC;\n#endif /* local variables moved into u.bd */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bd.pC = p->apCsr[pOp->p1];\n  assert( u.bd.pC!=0 );\n  if( ALWAYS(u.bd.pC->pCursor!=0) ){\n    assert( u.bd.pC->isTable );\n    u.bd.pC->nullRow = 0;\n    pIn2 = &aMem[pOp->p2];\n    u.bd.pC->movetoTarget = sqlite3VdbeIntValue(pIn2);\n    u.bd.pC->rowidIsValid = 0;\n    u.bd.pC->deferredMoveto = 1;\n  }\n  break;\n}\n  \n\n/* Opcode: Found P1 P2 P3 P4 *\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n**\n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is a prefix of any entry in P1 then a jump is made to P2 and\n** P1 is left pointing at the matching entry.\n*/\n/* Opcode: NotFound P1 P2 P3 P4 *\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 \n** does contain an entry whose prefix matches the P3/P4 record then control\n** falls through to the next instruction and P1 is left pointing at the\n** matching entry.\n**\n** See also: Found, NotExists, IsUnique\n*/\ncase OP_NotFound:       /* jump, in3 */\ncase OP_Found: {        /* jump, in3 */\n#if 0  /* local variables moved into u.be */\n  int alreadyExists;\n  VdbeCursor *pC;\n  int res;\n  char *pFree;\n  UnpackedRecord *pIdxKey;\n  UnpackedRecord r;\n  char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7];\n#endif /* local variables moved into u.be */\n\n#ifdef SQLITE_TEST\n  sqlite3_found_count++;\n#endif\n\n  u.be.alreadyExists = 0;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_INT32 );\n  u.be.pC = p->apCsr[pOp->p1];\n  assert( u.be.pC!=0 );\n  pIn3 = &aMem[pOp->p3];\n  if( ALWAYS(u.be.pC->pCursor!=0) ){\n\n    assert( u.be.pC->isTable==0 );\n    if( pOp->p4.i>0 ){\n      u.be.r.pKeyInfo = u.be.pC->pKeyInfo;\n      u.be.r.nField = (u16)pOp->p4.i;\n      u.be.r.aMem = pIn3;\n#ifdef SQLITE_DEBUG\n      { int i; for(i=0; i<u.be.r.nField; i++) assert( memIsValid(&u.be.r.aMem[i]) ); }\n#endif\n      u.be.r.flags = UNPACKED_PREFIX_MATCH;\n      u.be.pIdxKey = &u.be.r;\n    }else{\n      u.be.pIdxKey = sqlite3VdbeAllocUnpackedRecord(\n          u.be.pC->pKeyInfo, u.be.aTempRec, sizeof(u.be.aTempRec), &u.be.pFree\n      );\n      if( u.be.pIdxKey==0 ) goto no_mem;\n      assert( pIn3->flags & MEM_Blob );\n      assert( (pIn3->flags & MEM_Zero)==0 );  /* zeroblobs already expanded */\n      sqlite3VdbeRecordUnpack(u.be.pC->pKeyInfo, pIn3->n, pIn3->z, u.be.pIdxKey);\n      u.be.pIdxKey->flags |= UNPACKED_PREFIX_MATCH;\n    }\n    rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, u.be.pIdxKey, 0, 0, &u.be.res);\n    if( pOp->p4.i==0 ){\n      sqlite3DbFree(db, u.be.pFree);\n    }\n    if( rc!=SQLITE_OK ){\n      break;\n    }\n    u.be.alreadyExists = (u.be.res==0);\n    u.be.pC->deferredMoveto = 0;\n    u.be.pC->cacheStatus = CACHE_STALE;\n  }\n  if( pOp->opcode==OP_Found ){\n    if( u.be.alreadyExists ) pc = pOp->p2 - 1;\n  }else{\n    if( !u.be.alreadyExists ) pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: IsUnique P1 P2 P3 P4 *\n**\n** Cursor P1 is open on an index b-tree - that is to say, a btree which\n** no data and where the key are records generated by OP_MakeRecord with\n** the list field being the integer ROWID of the entry that the index\n** entry refers to.\n**\n** The P3 register contains an integer record number. Call this record \n** number R. Register P4 is the first in a set of N contiguous registers\n** that make up an unpacked index key that can be used with cursor P1.\n** The value of N can be inferred from the cursor. N includes the rowid\n** value appended to the end of the index record. This rowid value may\n** or may not be the same as R.\n**\n** If any of the N registers beginning with register P4 contains a NULL\n** value, jump immediately to P2.\n**\n** Otherwise, this instruction checks if cursor P1 contains an entry\n** where the first (N-1) fields match but the rowid value at the end\n** of the index entry is not R. If there is no such entry, control jumps\n** to instruction P2. Otherwise, the rowid of the conflicting index\n** entry is copied to register P3 and control falls through to the next\n** instruction.\n**\n** See also: NotFound, NotExists, Found\n*/\ncase OP_IsUnique: {        /* jump, in3 */\n#if 0  /* local variables moved into u.bf */\n  u16 ii;\n  VdbeCursor *pCx;\n  BtCursor *pCrsr;\n  u16 nField;\n  Mem *aMx;\n  UnpackedRecord r;                  /* B-Tree index search key */\n  i64 R;                             /* Rowid stored in register P3 */\n#endif /* local variables moved into u.bf */\n\n  pIn3 = &aMem[pOp->p3];\n  u.bf.aMx = &aMem[pOp->p4.i];\n  /* Assert that the values of parameters P1 and P4 are in range. */\n  assert( pOp->p4type==P4_INT32 );\n  assert( pOp->p4.i>0 && pOp->p4.i<=p->nMem );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n\n  /* Find the index cursor. */\n  u.bf.pCx = p->apCsr[pOp->p1];\n  assert( u.bf.pCx->deferredMoveto==0 );\n  u.bf.pCx->seekResult = 0;\n  u.bf.pCx->cacheStatus = CACHE_STALE;\n  u.bf.pCrsr = u.bf.pCx->pCursor;\n\n  /* If any of the values are NULL, take the jump. */\n  u.bf.nField = u.bf.pCx->pKeyInfo->nField;\n  for(u.bf.ii=0; u.bf.ii<u.bf.nField; u.bf.ii++){\n    if( u.bf.aMx[u.bf.ii].flags & MEM_Null ){\n      pc = pOp->p2 - 1;\n      u.bf.pCrsr = 0;\n      break;\n    }\n  }\n  assert( (u.bf.aMx[u.bf.nField].flags & MEM_Null)==0 );\n\n  if( u.bf.pCrsr!=0 ){\n    /* Populate the index search key. */\n    u.bf.r.pKeyInfo = u.bf.pCx->pKeyInfo;\n    u.bf.r.nField = u.bf.nField + 1;\n    u.bf.r.flags = UNPACKED_PREFIX_SEARCH;\n    u.bf.r.aMem = u.bf.aMx;\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<u.bf.r.nField; i++) assert( memIsValid(&u.bf.r.aMem[i]) ); }\n#endif\n\n    /* Extract the value of u.bf.R from register P3. */\n    sqlite3VdbeMemIntegerify(pIn3);\n    u.bf.R = pIn3->u.i;\n\n    /* Search the B-Tree index. If no conflicting record is found, jump\n    ** to P2. Otherwise, copy the rowid of the conflicting record to\n    ** register P3 and fall through to the next instruction.  */\n    rc = sqlite3BtreeMovetoUnpacked(u.bf.pCrsr, &u.bf.r, 0, 0, &u.bf.pCx->seekResult);\n    if( (u.bf.r.flags & UNPACKED_PREFIX_SEARCH) || u.bf.r.rowid==u.bf.R ){\n      pc = pOp->p2 - 1;\n    }else{\n      pIn3->u.i = u.bf.r.rowid;\n    }\n  }\n  break;\n}\n\n/* Opcode: NotExists P1 P2 P3 * *\n**\n** Use the content of register P3 as an integer key.  If a record \n** with that key does not exist in table of P1, then jump to P2. \n** If the record does exist, then fall through.  The cursor is left \n** pointing to the record if it exists.\n**\n** The difference between this operation and NotFound is that this\n** operation assumes the key is an integer and that P1 is a table whereas\n** NotFound assumes key is a blob constructed from MakeRecord and\n** P1 is an index.\n**\n** See also: Found, NotFound, IsUnique\n*/\ncase OP_NotExists: {        /* jump, in3 */\n#if 0  /* local variables moved into u.bg */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  u64 iKey;\n#endif /* local variables moved into u.bg */\n\n  pIn3 = &aMem[pOp->p3];\n  assert( pIn3->flags & MEM_Int );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bg.pC = p->apCsr[pOp->p1];\n  assert( u.bg.pC!=0 );\n  assert( u.bg.pC->isTable );\n  assert( u.bg.pC->pseudoTableReg==0 );\n  u.bg.pCrsr = u.bg.pC->pCursor;\n  if( ALWAYS(u.bg.pCrsr!=0) ){\n    u.bg.res = 0;\n    u.bg.iKey = pIn3->u.i;\n    rc = sqlite3BtreeMovetoUnpacked(u.bg.pCrsr, 0, u.bg.iKey, 0, &u.bg.res);\n    u.bg.pC->lastRowid = pIn3->u.i;\n    u.bg.pC->rowidIsValid = u.bg.res==0 ?1:0;\n    u.bg.pC->nullRow = 0;\n    u.bg.pC->cacheStatus = CACHE_STALE;\n    u.bg.pC->deferredMoveto = 0;\n    if( u.bg.res!=0 ){\n      pc = pOp->p2 - 1;\n      assert( u.bg.pC->rowidIsValid==0 );\n    }\n    u.bg.pC->seekResult = u.bg.res;\n  }else{\n    /* This happens when an attempt to open a read cursor on the\n    ** sqlite_master table returns SQLITE_EMPTY.\n    */\n    pc = pOp->p2 - 1;\n    assert( u.bg.pC->rowidIsValid==0 );\n    u.bg.pC->seekResult = 0;\n  }\n  break;\n}\n\n/* Opcode: Sequence P1 P2 * * *\n**\n** Find the next available sequence number for cursor P1.\n** Write the sequence number into register P2.\n** The sequence number on the cursor is incremented after this\n** instruction.  \n*/\ncase OP_Sequence: {           /* out2-prerelease */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  pOut->u.i = p->apCsr[pOp->p1]->seqCount++;\n  break;\n}\n\n\n/* Opcode: NewRowid P1 P2 P3 * *\n**\n** Get a new integer record number (a.k.a \"rowid\") used as the key to a table.\n** The record number is not previously used as a key in the database\n** table that cursor P1 points to.  The new record number is written\n** written to register P2.\n**\n** If P3>0 then P3 is a register in the root frame of this VDBE that holds \n** the largest previously generated record number. No new record numbers are\n** allowed to be less than this value. When this value reaches its maximum, \n** an SQLITE_FULL error is generated. The P3 register is updated with the '\n** generated record number. This P3 mechanism is used to help implement the\n** AUTOINCREMENT feature.\n*/\ncase OP_NewRowid: {           /* out2-prerelease */\n#if 0  /* local variables moved into u.bh */\n  i64 v;                 /* The new rowid */\n  VdbeCursor *pC;        /* Cursor of table to get the new rowid */\n  int res;               /* Result of an sqlite3BtreeLast() */\n  int cnt;               /* Counter to limit the number of searches */\n  Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */\n  VdbeFrame *pFrame;     /* Root frame of VDBE */\n#endif /* local variables moved into u.bh */\n\n  u.bh.v = 0;\n  u.bh.res = 0;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bh.pC = p->apCsr[pOp->p1];\n  assert( u.bh.pC!=0 );\n  if( NEVER(u.bh.pC->pCursor==0) ){\n    /* The zero initialization above is all that is needed */\n  }else{\n    /* The next rowid or record number (different terms for the same\n    ** thing) is obtained in a two-step algorithm.\n    **\n    ** First we attempt to find the largest existing rowid and add one\n    ** to that.  But if the largest existing rowid is already the maximum\n    ** positive integer, we have to fall through to the second\n    ** probabilistic algorithm\n    **\n    ** The second algorithm is to select a rowid at random and see if\n    ** it already exists in the table.  If it does not exist, we have\n    ** succeeded.  If the random rowid does exist, we select a new one\n    ** and try again, up to 100 times.\n    */\n    assert( u.bh.pC->isTable );\n\n#ifdef SQLITE_32BIT_ROWID\n#   define MAX_ROWID 0x7fffffff\n#else\n    /* Some compilers complain about constants of the form 0x7fffffffffffffff.\n    ** Others complain about 0x7ffffffffffffffffLL.  The following macro seems\n    ** to provide the constant while making all compilers happy.\n    */\n#   define MAX_ROWID  (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff )\n#endif\n\n    if( !u.bh.pC->useRandomRowid ){\n      u.bh.v = sqlite3BtreeGetCachedRowid(u.bh.pC->pCursor);\n      if( u.bh.v==0 ){\n        rc = sqlite3BtreeLast(u.bh.pC->pCursor, &u.bh.res);\n        if( rc!=SQLITE_OK ){\n          goto abort_due_to_error;\n        }\n        if( u.bh.res ){\n          u.bh.v = 1;   /* IMP: R-61914-48074 */\n        }else{\n          assert( sqlite3BtreeCursorIsValid(u.bh.pC->pCursor) );\n          rc = sqlite3BtreeKeySize(u.bh.pC->pCursor, &u.bh.v);\n          assert( rc==SQLITE_OK );   /* Cannot fail following BtreeLast() */\n          if( u.bh.v>=MAX_ROWID ){\n            u.bh.pC->useRandomRowid = 1;\n          }else{\n            u.bh.v++;   /* IMP: R-29538-34987 */\n          }\n        }\n      }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n      if( pOp->p3 ){\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3>0 );\n        if( p->pFrame ){\n          for(u.bh.pFrame=p->pFrame; u.bh.pFrame->pParent; u.bh.pFrame=u.bh.pFrame->pParent);\n          /* Assert that P3 is a valid memory cell. */\n          assert( pOp->p3<=u.bh.pFrame->nMem );\n          u.bh.pMem = &u.bh.pFrame->aMem[pOp->p3];\n        }else{\n          /* Assert that P3 is a valid memory cell. */\n          assert( pOp->p3<=p->nMem );\n          u.bh.pMem = &aMem[pOp->p3];\n          memAboutToChange(p, u.bh.pMem);\n        }\n        assert( memIsValid(u.bh.pMem) );\n\n        REGISTER_TRACE(pOp->p3, u.bh.pMem);\n        sqlite3VdbeMemIntegerify(u.bh.pMem);\n        assert( (u.bh.pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */\n        if( u.bh.pMem->u.i==MAX_ROWID || u.bh.pC->useRandomRowid ){\n          rc = SQLITE_FULL;   /* IMP: R-12275-61338 */\n          goto abort_due_to_error;\n        }\n        if( u.bh.v<u.bh.pMem->u.i+1 ){\n          u.bh.v = u.bh.pMem->u.i + 1;\n        }\n        u.bh.pMem->u.i = u.bh.v;\n      }\n#endif\n\n      sqlite3BtreeSetCachedRowid(u.bh.pC->pCursor, u.bh.v<MAX_ROWID ? u.bh.v+1 : 0);\n    }\n    if( u.bh.pC->useRandomRowid ){\n      /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the\n      ** largest possible integer (9223372036854775807) then the database\n      ** engine starts picking positive candidate ROWIDs at random until\n      ** it finds one that is not previously used. */\n      assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is\n                             ** an AUTOINCREMENT table. */\n      /* on the first attempt, simply do one more than previous */\n      u.bh.v = lastRowid;\n      u.bh.v &= (MAX_ROWID>>1); /* ensure doesn't go negative */\n      u.bh.v++; /* ensure non-zero */\n      u.bh.cnt = 0;\n      while(   ((rc = sqlite3BtreeMovetoUnpacked(u.bh.pC->pCursor, 0, (u64)u.bh.v,\n                                                 0, &u.bh.res))==SQLITE_OK)\n            && (u.bh.res==0)\n            && (++u.bh.cnt<100)){\n        /* collision - try another random rowid */\n        sqlite3_randomness(sizeof(u.bh.v), &u.bh.v);\n        if( u.bh.cnt<5 ){\n          /* try \"small\" random rowids for the initial attempts */\n          u.bh.v &= 0xffffff;\n        }else{\n          u.bh.v &= (MAX_ROWID>>1); /* ensure doesn't go negative */\n        }\n        u.bh.v++; /* ensure non-zero */\n      }\n      if( rc==SQLITE_OK && u.bh.res==0 ){\n        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */\n        goto abort_due_to_error;\n      }\n      assert( u.bh.v>0 );  /* EV: R-40812-03570 */\n    }\n    u.bh.pC->rowidIsValid = 0;\n    u.bh.pC->deferredMoveto = 0;\n    u.bh.pC->cacheStatus = CACHE_STALE;\n  }\n  pOut->u.i = u.bh.v;\n  break;\n}\n\n/* Opcode: Insert P1 P2 P3 P4 P5\n**\n** Write an entry into the table of cursor P1.  A new entry is\n** created if it doesn't already exist or the data for an existing\n** entry is overwritten.  The data is the value MEM_Blob stored in register\n** number P2. The key is stored in register P3. The key must\n** be a MEM_Int.\n**\n** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is\n** incremented (otherwise not).  If the OPFLAG_LASTROWID flag of P5 is set,\n** then rowid is stored for subsequent return by the\n** sqlite3_last_insert_rowid() function (otherwise it is unmodified).\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of\n** the last seek operation (OP_NotExists) was a success, then this\n** operation will not attempt to find the appropriate row before doing\n** the insert but will instead overwrite the row that the cursor is\n** currently pointing to.  Presumably, the prior OP_NotExists opcode\n** has already positioned the cursor correctly.  This is an optimization\n** that boosts performance by avoiding redundant seeks.\n**\n** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an\n** UPDATE operation.  Otherwise (if the flag is clear) then this opcode\n** is part of an INSERT operation.  The difference is only important to\n** the update hook.\n**\n** Parameter P4 may point to a string containing the table-name, or\n** may be NULL. If it is not NULL, then the update-hook \n** (sqlite3.xUpdateCallback) is invoked following a successful insert.\n**\n** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically\n** allocated, then ownership of P2 is transferred to the pseudo-cursor\n** and register P2 becomes ephemeral.  If the cursor is changed, the\n** value of register P2 will then change.  Make sure this does not\n** cause any problems.)\n**\n** This instruction only works on tables.  The equivalent instruction\n** for indices is OP_IdxInsert.\n*/\n/* Opcode: InsertInt P1 P2 P3 P4 P5\n**\n** This works exactly like OP_Insert except that the key is the\n** integer value P3, not the value of the integer stored in register P3.\n*/\ncase OP_Insert: \ncase OP_InsertInt: {\n#if 0  /* local variables moved into u.bi */\n  Mem *pData;       /* MEM cell holding data for the record to be inserted */\n  Mem *pKey;        /* MEM cell holding key  for the record */\n  i64 iKey;         /* The integer ROWID or key for the record to be inserted */\n  VdbeCursor *pC;   /* Cursor to table into which insert is written */\n  int nZero;        /* Number of zero-bytes to append */\n  int seekResult;   /* Result of prior seek or 0 if no USESEEKRESULT flag */\n  const char *zDb;  /* database name - used by the update hook */\n  const char *zTbl; /* Table name - used by the opdate hook */\n  int op;           /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */\n#endif /* local variables moved into u.bi */\n\n  u.bi.pData = &aMem[pOp->p2];\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( memIsValid(u.bi.pData) );\n  u.bi.pC = p->apCsr[pOp->p1];\n  assert( u.bi.pC!=0 );\n  assert( u.bi.pC->pCursor!=0 );\n  assert( u.bi.pC->pseudoTableReg==0 );\n  assert( u.bi.pC->isTable );\n  REGISTER_TRACE(pOp->p2, u.bi.pData);\n\n  if( pOp->opcode==OP_Insert ){\n    u.bi.pKey = &aMem[pOp->p3];\n    assert( u.bi.pKey->flags & MEM_Int );\n    assert( memIsValid(u.bi.pKey) );\n    REGISTER_TRACE(pOp->p3, u.bi.pKey);\n    u.bi.iKey = u.bi.pKey->u.i;\n  }else{\n    assert( pOp->opcode==OP_InsertInt );\n    u.bi.iKey = pOp->p3;\n  }\n\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = u.bi.iKey;\n  if( u.bi.pData->flags & MEM_Null ){\n    u.bi.pData->z = 0;\n    u.bi.pData->n = 0;\n  }else{\n    assert( u.bi.pData->flags & (MEM_Blob|MEM_Str) );\n  }\n  u.bi.seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? u.bi.pC->seekResult : 0);\n  if( u.bi.pData->flags & MEM_Zero ){\n    u.bi.nZero = u.bi.pData->u.nZero;\n  }else{\n    u.bi.nZero = 0;\n  }\n  sqlite3BtreeSetCachedRowid(u.bi.pC->pCursor, 0);\n  rc = sqlite3BtreeInsert(u.bi.pC->pCursor, 0, u.bi.iKey,\n                          u.bi.pData->z, u.bi.pData->n, u.bi.nZero,\n                          pOp->p5 & OPFLAG_APPEND, u.bi.seekResult\n  );\n  u.bi.pC->rowidIsValid = 0;\n  u.bi.pC->deferredMoveto = 0;\n  u.bi.pC->cacheStatus = CACHE_STALE;\n\n  /* Invoke the update-hook if required. */\n  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){\n    u.bi.zDb = db->aDb[u.bi.pC->iDb].zName;\n    u.bi.zTbl = pOp->p4.z;\n    u.bi.op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);\n    assert( u.bi.pC->isTable );\n    db->xUpdateCallback(db->pUpdateArg, u.bi.op, u.bi.zDb, u.bi.zTbl, u.bi.iKey);\n    assert( u.bi.pC->iDb>=0 );\n  }\n  break;\n}\n\n/* Opcode: Delete P1 P2 * P4 *\n**\n** Delete the record at which the P1 cursor is currently pointing.\n**\n** The cursor will be left pointing at either the next or the previous\n** record in the table. If it is left pointing at the next record, then\n** the next Next instruction will be a no-op.  Hence it is OK to delete\n** a record from within an Next loop.\n**\n** If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is\n** incremented (otherwise not).\n**\n** P1 must not be pseudo-table.  It has to be a real table with\n** multiple rows.\n**\n** If P4 is not NULL, then it is the name of the table that P1 is\n** pointing to.  The update hook will be invoked, if it exists.\n** If P4 is not NULL then the P1 cursor must have been positioned\n** using OP_NotFound prior to invoking this opcode.\n*/\ncase OP_Delete: {\n#if 0  /* local variables moved into u.bj */\n  i64 iKey;\n  VdbeCursor *pC;\n#endif /* local variables moved into u.bj */\n\n  u.bj.iKey = 0;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bj.pC = p->apCsr[pOp->p1];\n  assert( u.bj.pC!=0 );\n  assert( u.bj.pC->pCursor!=0 );  /* Only valid for real tables, no pseudotables */\n\n  /* If the update-hook will be invoked, set u.bj.iKey to the rowid of the\n  ** row being deleted.\n  */\n  if( db->xUpdateCallback && pOp->p4.z ){\n    assert( u.bj.pC->isTable );\n    assert( u.bj.pC->rowidIsValid );  /* lastRowid set by previous OP_NotFound */\n    u.bj.iKey = u.bj.pC->lastRowid;\n  }\n\n  /* The OP_Delete opcode always follows an OP_NotExists or OP_Last or\n  ** OP_Column on the same table without any intervening operations that\n  ** might move or invalidate the cursor.  Hence cursor u.bj.pC is always pointing\n  ** to the row to be deleted and the sqlite3VdbeCursorMoveto() operation\n  ** below is always a no-op and cannot fail.  We will run it anyhow, though,\n  ** to guard against future changes to the code generator.\n  **/\n  assert( u.bj.pC->deferredMoveto==0 );\n  rc = sqlite3VdbeCursorMoveto(u.bj.pC);\n  if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;\n\n  sqlite3BtreeSetCachedRowid(u.bj.pC->pCursor, 0);\n  rc = sqlite3BtreeDelete(u.bj.pC->pCursor);\n  u.bj.pC->cacheStatus = CACHE_STALE;\n\n  /* Invoke the update-hook if required. */\n  if( rc==SQLITE_OK && db->xUpdateCallback && pOp->p4.z ){\n    const char *zDb = db->aDb[u.bj.pC->iDb].zName;\n    const char *zTbl = pOp->p4.z;\n    db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, zTbl, u.bj.iKey);\n    assert( u.bj.pC->iDb>=0 );\n  }\n  if( pOp->p2 & OPFLAG_NCHANGE ) p->nChange++;\n  break;\n}\n/* Opcode: ResetCount * * * * *\n**\n** The value of the change counter is copied to the database handle\n** change counter (returned by subsequent calls to sqlite3_changes()).\n** Then the VMs internal change counter resets to 0.\n** This is used by trigger programs.\n*/\ncase OP_ResetCount: {\n  sqlite3VdbeSetChanges(db, p->nChange);\n  p->nChange = 0;\n  break;\n}\n\n/* Opcode: SorterCompare P1 P2 P3\n**\n** P1 is a sorter cursor. This instruction compares the record blob in \n** register P3 with the entry that the sorter cursor currently points to.\n** If, excluding the rowid fields at the end, the two records are a match,\n** fall through to the next instruction. Otherwise, jump to instruction P2.\n*/\ncase OP_SorterCompare: {\n#if 0  /* local variables moved into u.bk */\n  VdbeCursor *pC;\n  int res;\n#endif /* local variables moved into u.bk */\n\n  u.bk.pC = p->apCsr[pOp->p1];\n  assert( isSorter(u.bk.pC) );\n  pIn3 = &aMem[pOp->p3];\n  rc = sqlite3VdbeSorterCompare(u.bk.pC, pIn3, &u.bk.res);\n  if( u.bk.res ){\n    pc = pOp->p2-1;\n  }\n  break;\n};\n\n/* Opcode: SorterData P1 P2 * * *\n**\n** Write into register P2 the current sorter data for sorter cursor P1.\n*/\ncase OP_SorterData: {\n#if 0  /* local variables moved into u.bl */\n  VdbeCursor *pC;\n#endif /* local variables moved into u.bl */\n\n  pOut = &aMem[pOp->p2];\n  u.bl.pC = p->apCsr[pOp->p1];\n  assert( u.bl.pC->isSorter );\n  rc = sqlite3VdbeSorterRowkey(u.bl.pC, pOut);\n  break;\n}\n\n/* Opcode: RowData P1 P2 * * *\n**\n** Write into register P2 the complete row data for cursor P1.\n** There is no interpretation of the data.  \n** It is just copied onto the P2 register exactly as \n** it is found in the database file.\n**\n** If the P1 cursor must be pointing to a valid row (not a NULL row)\n** of a real table, not a pseudo-table.\n*/\n/* Opcode: RowKey P1 P2 * * *\n**\n** Write into register P2 the complete row key for cursor P1.\n** There is no interpretation of the data.  \n** The key is copied onto the P3 register exactly as \n** it is found in the database file.\n**\n** If the P1 cursor must be pointing to a valid row (not a NULL row)\n** of a real table, not a pseudo-table.\n*/\ncase OP_RowKey:\ncase OP_RowData: {\n#if 0  /* local variables moved into u.bm */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  u32 n;\n  i64 n64;\n#endif /* local variables moved into u.bm */\n\n  pOut = &aMem[pOp->p2];\n  memAboutToChange(p, pOut);\n\n  /* Note that RowKey and RowData are really exactly the same instruction */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bm.pC = p->apCsr[pOp->p1];\n  assert( u.bm.pC->isSorter==0 );\n  assert( u.bm.pC->isTable || pOp->opcode!=OP_RowData );\n  assert( u.bm.pC->isIndex || pOp->opcode==OP_RowData );\n  assert( u.bm.pC!=0 );\n  assert( u.bm.pC->nullRow==0 );\n  assert( u.bm.pC->pseudoTableReg==0 );\n  assert( u.bm.pC->pCursor!=0 );\n  u.bm.pCrsr = u.bm.pC->pCursor;\n  assert( sqlite3BtreeCursorIsValid(u.bm.pCrsr) );\n\n  /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or\n  ** OP_Rewind/Op_Next with no intervening instructions that might invalidate\n  ** the cursor.  Hence the following sqlite3VdbeCursorMoveto() call is always\n  ** a no-op and can never fail.  But we leave it in place as a safety.\n  */\n  assert( u.bm.pC->deferredMoveto==0 );\n  rc = sqlite3VdbeCursorMoveto(u.bm.pC);\n  if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;\n\n  if( u.bm.pC->isIndex ){\n    assert( !u.bm.pC->isTable );\n    VVA_ONLY(rc =) sqlite3BtreeKeySize(u.bm.pCrsr, &u.bm.n64);\n    assert( rc==SQLITE_OK );    /* True because of CursorMoveto() call above */\n    if( u.bm.n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n      goto too_big;\n    }\n    u.bm.n = (u32)u.bm.n64;\n  }else{\n    VVA_ONLY(rc =) sqlite3BtreeDataSize(u.bm.pCrsr, &u.bm.n);\n    assert( rc==SQLITE_OK );    /* DataSize() cannot fail */\n    if( u.bm.n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n      goto too_big;\n    }\n  }\n  if( sqlite3VdbeMemGrow(pOut, u.bm.n, 0) ){\n    goto no_mem;\n  }\n  pOut->n = u.bm.n;\n  MemSetTypeFlag(pOut, MEM_Blob);\n  if( u.bm.pC->isIndex ){\n    rc = sqlite3BtreeKey(u.bm.pCrsr, 0, u.bm.n, pOut->z);\n  }else{\n    rc = sqlite3BtreeData(u.bm.pCrsr, 0, u.bm.n, pOut->z);\n  }\n  pOut->enc = SQLITE_UTF8;  /* In case the blob is ever cast to text */\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Rowid P1 P2 * * *\n**\n** Store in register P2 an integer which is the key of the table entry that\n** P1 is currently point to.\n**\n** P1 can be either an ordinary table or a virtual table.  There used to\n** be a separate OP_VRowid opcode for use with virtual tables, but this\n** one opcode now works for both table types.\n*/\ncase OP_Rowid: {                 /* out2-prerelease */\n#if 0  /* local variables moved into u.bn */\n  VdbeCursor *pC;\n  i64 v;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n#endif /* local variables moved into u.bn */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bn.pC = p->apCsr[pOp->p1];\n  assert( u.bn.pC!=0 );\n  assert( u.bn.pC->pseudoTableReg==0 || u.bn.pC->nullRow );\n  if( u.bn.pC->nullRow ){\n    pOut->flags = MEM_Null;\n    break;\n  }else if( u.bn.pC->deferredMoveto ){\n    u.bn.v = u.bn.pC->movetoTarget;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  }else if( u.bn.pC->pVtabCursor ){\n    u.bn.pVtab = u.bn.pC->pVtabCursor->pVtab;\n    u.bn.pModule = u.bn.pVtab->pModule;\n    assert( u.bn.pModule->xRowid );\n    rc = u.bn.pModule->xRowid(u.bn.pC->pVtabCursor, &u.bn.v);\n    importVtabErrMsg(p, u.bn.pVtab);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  }else{\n    assert( u.bn.pC->pCursor!=0 );\n    rc = sqlite3VdbeCursorMoveto(u.bn.pC);\n    if( rc ) goto abort_due_to_error;\n    if( u.bn.pC->rowidIsValid ){\n      u.bn.v = u.bn.pC->lastRowid;\n    }else{\n      rc = sqlite3BtreeKeySize(u.bn.pC->pCursor, &u.bn.v);\n      assert( rc==SQLITE_OK );  /* Always so because of CursorMoveto() above */\n    }\n  }\n  pOut->u.i = u.bn.v;\n  break;\n}\n\n/* Opcode: NullRow P1 * * * *\n**\n** Move the cursor P1 to a null row.  Any OP_Column operations\n** that occur while the cursor is on the null row will always\n** write a NULL.\n*/\ncase OP_NullRow: {\n#if 0  /* local variables moved into u.bo */\n  VdbeCursor *pC;\n#endif /* local variables moved into u.bo */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bo.pC = p->apCsr[pOp->p1];\n  assert( u.bo.pC!=0 );\n  u.bo.pC->nullRow = 1;\n  u.bo.pC->rowidIsValid = 0;\n  assert( u.bo.pC->pCursor || u.bo.pC->pVtabCursor );\n  if( u.bo.pC->pCursor ){\n    sqlite3BtreeClearCursor(u.bo.pC->pCursor);\n  }\n  break;\n}\n\n/* Opcode: Last P1 P2 * * *\n**\n** The next use of the Rowid or Column or Next instruction for P1 \n** will refer to the last entry in the database table or index.\n** If the table or index is empty and P2>0, then jump immediately to P2.\n** If P2 is 0 or if the table or index is not empty, fall through\n** to the following instruction.\n*/\ncase OP_Last: {        /* jump */\n#if 0  /* local variables moved into u.bp */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n#endif /* local variables moved into u.bp */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bp.pC = p->apCsr[pOp->p1];\n  assert( u.bp.pC!=0 );\n  u.bp.pCrsr = u.bp.pC->pCursor;\n  u.bp.res = 0;\n  if( ALWAYS(u.bp.pCrsr!=0) ){\n    rc = sqlite3BtreeLast(u.bp.pCrsr, &u.bp.res);\n  }\n  u.bp.pC->nullRow = (u8)u.bp.res;\n  u.bp.pC->deferredMoveto = 0;\n  u.bp.pC->rowidIsValid = 0;\n  u.bp.pC->cacheStatus = CACHE_STALE;\n  if( pOp->p2>0 && u.bp.res ){\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n\n/* Opcode: Sort P1 P2 * * *\n**\n** This opcode does exactly the same thing as OP_Rewind except that\n** it increments an undocumented global variable used for testing.\n**\n** Sorting is accomplished by writing records into a sorting index,\n** then rewinding that index and playing it back from beginning to\n** end.  We use the OP_Sort opcode instead of OP_Rewind to do the\n** rewinding so that the global variable will be incremented and\n** regression tests can determine whether or not the optimizer is\n** correctly optimizing out sorts.\n*/\ncase OP_SorterSort:    /* jump */\ncase OP_Sort: {        /* jump */\n#ifdef SQLITE_TEST\n  sqlite3_sort_count++;\n  sqlite3_search_count--;\n#endif\n  p->aCounter[SQLITE_STMTSTATUS_SORT-1]++;\n  /* Fall through into OP_Rewind */\n}\n/* Opcode: Rewind P1 P2 * * *\n**\n** The next use of the Rowid or Column or Next instruction for P1 \n** will refer to the first entry in the database table or index.\n** If the table or index is empty and P2>0, then jump immediately to P2.\n** If P2 is 0 or if the table or index is not empty, fall through\n** to the following instruction.\n*/\ncase OP_Rewind: {        /* jump */\n#if 0  /* local variables moved into u.bq */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n#endif /* local variables moved into u.bq */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bq.pC = p->apCsr[pOp->p1];\n  assert( u.bq.pC!=0 );\n  assert( u.bq.pC->isSorter==(pOp->opcode==OP_SorterSort) );\n  u.bq.res = 1;\n  if( isSorter(u.bq.pC) ){\n    rc = sqlite3VdbeSorterRewind(db, u.bq.pC, &u.bq.res);\n  }else{\n    u.bq.pCrsr = u.bq.pC->pCursor;\n    assert( u.bq.pCrsr );\n    rc = sqlite3BtreeFirst(u.bq.pCrsr, &u.bq.res);\n    u.bq.pC->atFirst = u.bq.res==0 ?1:0;\n    u.bq.pC->deferredMoveto = 0;\n    u.bq.pC->cacheStatus = CACHE_STALE;\n    u.bq.pC->rowidIsValid = 0;\n  }\n  u.bq.pC->nullRow = (u8)u.bq.res;\n  assert( pOp->p2>0 && pOp->p2<p->nOp );\n  if( u.bq.res ){\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: Next P1 P2 * P4 P5\n**\n** Advance cursor P1 so that it points to the next key/data pair in its\n** table or index.  If there are no more key/value pairs then fall through\n** to the following instruction.  But if the cursor advance was successful,\n** jump immediately to P2.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreeNext().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n**\n** See also: Prev\n*/\n/* Opcode: Prev P1 P2 * * P5\n**\n** Back up cursor P1 so that it points to the previous key/data pair in its\n** table or index.  If there is no previous key/value pairs then fall through\n** to the following instruction.  But if the cursor backup was successful,\n** jump immediately to P2.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreePrevious().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n*/\ncase OP_SorterNext:    /* jump */\ncase OP_Prev:          /* jump */\ncase OP_Next: {        /* jump */\n#if 0  /* local variables moved into u.br */\n  VdbeCursor *pC;\n  int res;\n#endif /* local variables moved into u.br */\n\n  CHECK_FOR_INTERRUPT;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p5<=ArraySize(p->aCounter) );\n  u.br.pC = p->apCsr[pOp->p1];\n  if( u.br.pC==0 ){\n    break;  /* See ticket #2273 */\n  }\n  assert( u.br.pC->isSorter==(pOp->opcode==OP_SorterNext) );\n  if( isSorter(u.br.pC) ){\n    assert( pOp->opcode==OP_SorterNext );\n    rc = sqlite3VdbeSorterNext(db, u.br.pC, &u.br.res);\n  }else{\n    u.br.res = 1;\n    assert( u.br.pC->deferredMoveto==0 );\n    assert( u.br.pC->pCursor );\n    assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );\n    assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );\n    rc = pOp->p4.xAdvance(u.br.pC->pCursor, &u.br.res);\n  }\n  u.br.pC->nullRow = (u8)u.br.res;\n  u.br.pC->cacheStatus = CACHE_STALE;\n  if( u.br.res==0 ){\n    pc = pOp->p2 - 1;\n    if( pOp->p5 ) p->aCounter[pOp->p5-1]++;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n  }\n  u.br.pC->rowidIsValid = 0;\n  break;\n}\n\n/* Opcode: IdxInsert P1 P2 P3 * P5\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the index P1.  Data for the entry is nil.\n**\n** P3 is a flag that provides a hint to the b-tree layer that this\n** insert is likely to be an append.\n**\n** This instruction only works for indices.  The equivalent instruction\n** for tables is OP_Insert.\n*/\ncase OP_SorterInsert:       /* in2 */\ncase OP_IdxInsert: {        /* in2 */\n#if 0  /* local variables moved into u.bs */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int nKey;\n  const char *zKey;\n#endif /* local variables moved into u.bs */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bs.pC = p->apCsr[pOp->p1];\n  assert( u.bs.pC!=0 );\n  assert( u.bs.pC->isSorter==(pOp->opcode==OP_SorterInsert) );\n  pIn2 = &aMem[pOp->p2];\n  assert( pIn2->flags & MEM_Blob );\n  u.bs.pCrsr = u.bs.pC->pCursor;\n  if( ALWAYS(u.bs.pCrsr!=0) ){\n    assert( u.bs.pC->isTable==0 );\n    rc = ExpandBlob(pIn2);\n    if( rc==SQLITE_OK ){\n      if( isSorter(u.bs.pC) ){\n        rc = sqlite3VdbeSorterWrite(db, u.bs.pC, pIn2);\n      }else{\n        u.bs.nKey = pIn2->n;\n        u.bs.zKey = pIn2->z;\n        rc = sqlite3BtreeInsert(u.bs.pCrsr, u.bs.zKey, u.bs.nKey, \"\", 0, 0, pOp->p3,\n            ((pOp->p5 & OPFLAG_USESEEKRESULT) ? u.bs.pC->seekResult : 0)\n            );\n        assert( u.bs.pC->deferredMoveto==0 );\n        u.bs.pC->cacheStatus = CACHE_STALE;\n      }\n    }\n  }\n  break;\n}\n\n/* Opcode: IdxDelete P1 P2 P3 * *\n**\n** The content of P3 registers starting at register P2 form\n** an unpacked index key. This opcode removes that entry from the \n** index opened by cursor P1.\n*/\ncase OP_IdxDelete: {\n#if 0  /* local variables moved into u.bt */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  UnpackedRecord r;\n#endif /* local variables moved into u.bt */\n\n  assert( pOp->p3>0 );\n  assert( pOp->p2>0 && pOp->p2+pOp->p3<=p->nMem+1 );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bt.pC = p->apCsr[pOp->p1];\n  assert( u.bt.pC!=0 );\n  u.bt.pCrsr = u.bt.pC->pCursor;\n  if( ALWAYS(u.bt.pCrsr!=0) ){\n    u.bt.r.pKeyInfo = u.bt.pC->pKeyInfo;\n    u.bt.r.nField = (u16)pOp->p3;\n    u.bt.r.flags = 0;\n    u.bt.r.aMem = &aMem[pOp->p2];\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<u.bt.r.nField; i++) assert( memIsValid(&u.bt.r.aMem[i]) ); }\n#endif\n    rc = sqlite3BtreeMovetoUnpacked(u.bt.pCrsr, &u.bt.r, 0, 0, &u.bt.res);\n    if( rc==SQLITE_OK && u.bt.res==0 ){\n      rc = sqlite3BtreeDelete(u.bt.pCrsr);\n    }\n    assert( u.bt.pC->deferredMoveto==0 );\n    u.bt.pC->cacheStatus = CACHE_STALE;\n  }\n  break;\n}\n\n/* Opcode: IdxRowid P1 P2 * * *\n**\n** Write into register P2 an integer which is the last entry in the record at\n** the end of the index key pointed to by cursor P1.  This integer should be\n** the rowid of the table entry to which this index entry points.\n**\n** See also: Rowid, MakeRecord.\n*/\ncase OP_IdxRowid: {              /* out2-prerelease */\n#if 0  /* local variables moved into u.bu */\n  BtCursor *pCrsr;\n  VdbeCursor *pC;\n  i64 rowid;\n#endif /* local variables moved into u.bu */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bu.pC = p->apCsr[pOp->p1];\n  assert( u.bu.pC!=0 );\n  u.bu.pCrsr = u.bu.pC->pCursor;\n  pOut->flags = MEM_Null;\n  if( ALWAYS(u.bu.pCrsr!=0) ){\n    rc = sqlite3VdbeCursorMoveto(u.bu.pC);\n    if( NEVER(rc) ) goto abort_due_to_error;\n    assert( u.bu.pC->deferredMoveto==0 );\n    assert( u.bu.pC->isTable==0 );\n    if( !u.bu.pC->nullRow ){\n      rc = sqlite3VdbeIdxRowid(db, u.bu.pCrsr, &u.bu.rowid);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      pOut->u.i = u.bu.rowid;\n      pOut->flags = MEM_Int;\n    }\n  }\n  break;\n}\n\n/* Opcode: IdxGE P1 P2 P3 P4 P5\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the ROWID.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the ROWID on the P1 index.\n**\n** If the P1 index entry is greater than or equal to the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n**\n** If P5 is non-zero then the key value is increased by an epsilon \n** prior to the comparison.  This make the opcode work like IdxGT except\n** that if the key from register P3 is a prefix of the key in the cursor,\n** the result is false whereas it would be true with IdxGT.\n*/\n/* Opcode: IdxLT P1 P2 P3 P4 P5\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the ROWID.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the ROWID on the P1 index.\n**\n** If the P1 index entry is less than the key value then jump to P2.\n** Otherwise fall through to the next instruction.\n**\n** If P5 is non-zero then the key value is increased by an epsilon prior \n** to the comparison.  This makes the opcode work like IdxLE.\n*/\ncase OP_IdxLT:          /* jump */\ncase OP_IdxGE: {        /* jump */\n#if 0  /* local variables moved into u.bv */\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord r;\n#endif /* local variables moved into u.bv */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  u.bv.pC = p->apCsr[pOp->p1];\n  assert( u.bv.pC!=0 );\n  assert( u.bv.pC->isOrdered );\n  if( ALWAYS(u.bv.pC->pCursor!=0) ){\n    assert( u.bv.pC->deferredMoveto==0 );\n    assert( pOp->p5==0 || pOp->p5==1 );\n    assert( pOp->p4type==P4_INT32 );\n    u.bv.r.pKeyInfo = u.bv.pC->pKeyInfo;\n    u.bv.r.nField = (u16)pOp->p4.i;\n    if( pOp->p5 ){\n      u.bv.r.flags = UNPACKED_INCRKEY | UNPACKED_PREFIX_MATCH;\n    }else{\n      u.bv.r.flags = UNPACKED_PREFIX_MATCH;\n    }\n    u.bv.r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<u.bv.r.nField; i++) assert( memIsValid(&u.bv.r.aMem[i]) ); }\n#endif\n    rc = sqlite3VdbeIdxKeyCompare(u.bv.pC, &u.bv.r, &u.bv.res);\n    if( pOp->opcode==OP_IdxLT ){\n      u.bv.res = -u.bv.res;\n    }else{\n      assert( pOp->opcode==OP_IdxGE );\n      u.bv.res++;\n    }\n    if( u.bv.res>0 ){\n      pc = pOp->p2 - 1 ;\n    }\n  }\n  break;\n}\n\n/* Opcode: Destroy P1 P2 P3 * *\n**\n** Delete an entire database table or index whose root page in the database\n** file is given by P1.\n**\n** The table being destroyed is in the main database file if P3==0.  If\n** P3==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If AUTOVACUUM is enabled then it is possible that another root page\n** might be moved into the newly deleted root page in order to keep all\n** root pages contiguous at the beginning of the database.  The former\n** value of the root page that moved - its value before the move occurred -\n** is stored in register P2.  If no page \n** movement was required (because the table being dropped was already \n** the last one in the database) then a zero is stored in register P2.\n** If AUTOVACUUM is disabled then a zero is stored in register P2.\n**\n** See also: Clear\n*/\ncase OP_Destroy: {     /* out2-prerelease */\n#if 0  /* local variables moved into u.bw */\n  int iMoved;\n  int iCnt;\n  Vdbe *pVdbe;\n  int iDb;\n#endif /* local variables moved into u.bw */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  u.bw.iCnt = 0;\n  for(u.bw.pVdbe=db->pVdbe; u.bw.pVdbe; u.bw.pVdbe = u.bw.pVdbe->pNext){\n    if( u.bw.pVdbe->magic==VDBE_MAGIC_RUN && u.bw.pVdbe->inVtabMethod<2 && u.bw.pVdbe->pc>=0 ){\n      u.bw.iCnt++;\n    }\n  }\n#else\n  u.bw.iCnt = db->activeVdbeCnt;\n#endif\n  pOut->flags = MEM_Null;\n  if( u.bw.iCnt>1 ){\n    rc = SQLITE_LOCKED;\n    p->errorAction = OE_Abort;\n  }else{\n    u.bw.iDb = pOp->p3;\n    assert( u.bw.iCnt==1 );\n    assert( (p->btreeMask & (((yDbMask)1)<<u.bw.iDb))!=0 );\n    rc = sqlite3BtreeDropTable(db->aDb[u.bw.iDb].pBt, pOp->p1, &u.bw.iMoved);\n    pOut->flags = MEM_Int;\n    pOut->u.i = u.bw.iMoved;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( rc==SQLITE_OK && u.bw.iMoved!=0 ){\n      sqlite3RootPageMoved(db, u.bw.iDb, u.bw.iMoved, pOp->p1);\n      /* All OP_Destroy operations occur on the same btree */\n      assert( resetSchemaOnFault==0 || resetSchemaOnFault==u.bw.iDb+1 );\n      resetSchemaOnFault = u.bw.iDb+1;\n    }\n#endif\n  }\n  break;\n}\n\n/* Opcode: Clear P1 P2 P3\n**\n** Delete all contents of the database table or index whose root page\n** in the database file is given by P1.  But, unlike Destroy, do not\n** remove the table or index from the database file.\n**\n** The table being clear is in the main database file if P2==0.  If\n** P2==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If the P3 value is non-zero, then the table referred to must be an\n** intkey table (an SQL table, not an index). In this case the row change \n** count is incremented by the number of rows in the table being cleared. \n** If P3 is greater than zero, then the value stored in register P3 is\n** also incremented by the number of rows in the table being cleared.\n**\n** See also: Destroy\n*/\ncase OP_Clear: {\n#if 0  /* local variables moved into u.bx */\n  int nChange;\n#endif /* local variables moved into u.bx */\n\n  u.bx.nChange = 0;\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p2))!=0 );\n  rc = sqlite3BtreeClearTable(\n      db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &u.bx.nChange : 0)\n  );\n  if( pOp->p3 ){\n    p->nChange += u.bx.nChange;\n    if( pOp->p3>0 ){\n      assert( memIsValid(&aMem[pOp->p3]) );\n      memAboutToChange(p, &aMem[pOp->p3]);\n      aMem[pOp->p3].u.i += u.bx.nChange;\n    }\n  }\n  break;\n}\n\n/* Opcode: CreateTable P1 P2 * * *\n**\n** Allocate a new table in the main database file if P1==0 or in the\n** auxiliary database file if P1==1 or in an attached database if\n** P1>1.  Write the root page number of the new table into\n** register P2\n**\n** The difference between a table and an index is this:  A table must\n** have a 4-byte integer key and can have arbitrary data.  An index\n** has an arbitrary key but no data.\n**\n** See also: CreateIndex\n*/\n/* Opcode: CreateIndex P1 P2 * * *\n**\n** Allocate a new index in the main database file if P1==0 or in the\n** auxiliary database file if P1==1 or in an attached database if\n** P1>1.  Write the root page number of the new table into\n** register P2.\n**\n** See documentation on OP_CreateTable for additional information.\n*/\ncase OP_CreateIndex:            /* out2-prerelease */\ncase OP_CreateTable: {          /* out2-prerelease */\n#if 0  /* local variables moved into u.by */\n  int pgno;\n  int flags;\n  Db *pDb;\n#endif /* local variables moved into u.by */\n\n  u.by.pgno = 0;\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );\n  u.by.pDb = &db->aDb[pOp->p1];\n  assert( u.by.pDb->pBt!=0 );\n  if( pOp->opcode==OP_CreateTable ){\n    /* u.by.flags = BTREE_INTKEY; */\n    u.by.flags = BTREE_INTKEY;\n  }else{\n    u.by.flags = BTREE_BLOBKEY;\n  }\n  rc = sqlite3BtreeCreateTable(u.by.pDb->pBt, &u.by.pgno, u.by.flags);\n  pOut->u.i = u.by.pgno;\n  break;\n}\n\n/* Opcode: ParseSchema P1 * * P4 *\n**\n** Read and parse all entries from the SQLITE_MASTER table of database P1\n** that match the WHERE clause P4. \n**\n** This opcode invokes the parser to create a new virtual machine,\n** then runs the new virtual machine.  It is thus a re-entrant opcode.\n*/\ncase OP_ParseSchema: {\n#if 0  /* local variables moved into u.bz */\n  int iDb;\n  const char *zMaster;\n  char *zSql;\n  InitData initData;\n#endif /* local variables moved into u.bz */\n\n  /* Any prepared statement that invokes this opcode will hold mutexes\n  ** on every btree.  This is a prerequisite for invoking\n  ** sqlite3InitCallback().\n  */\n#ifdef SQLITE_DEBUG\n  for(u.bz.iDb=0; u.bz.iDb<db->nDb; u.bz.iDb++){\n    assert( u.bz.iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[u.bz.iDb].pBt) );\n  }\n#endif\n\n  u.bz.iDb = pOp->p1;\n  assert( u.bz.iDb>=0 && u.bz.iDb<db->nDb );\n  assert( DbHasProperty(db, u.bz.iDb, DB_SchemaLoaded) );\n  /* Used to be a conditional */ {\n    u.bz.zMaster = SCHEMA_TABLE(u.bz.iDb);\n    u.bz.initData.db = db;\n    u.bz.initData.iDb = pOp->p1;\n    u.bz.initData.pzErrMsg = &p->zErrMsg;\n    u.bz.zSql = sqlite3MPrintf(db,\n       \"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid\",\n       db->aDb[u.bz.iDb].zName, u.bz.zMaster, pOp->p4.z);\n    if( u.bz.zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      assert( db->init.busy==0 );\n      db->init.busy = 1;\n      u.bz.initData.rc = SQLITE_OK;\n      assert( !db->mallocFailed );\n      rc = sqlite3_exec(db, u.bz.zSql, sqlite3InitCallback, &u.bz.initData, 0);\n      if( rc==SQLITE_OK ) rc = u.bz.initData.rc;\n      sqlite3DbFree(db, u.bz.zSql);\n      db->init.busy = 0;\n    }\n  }\n  if( rc ) sqlite3ResetAllSchemasOfConnection(db);\n  if( rc==SQLITE_NOMEM ){\n    goto no_mem;\n  }\n  break;\n}\n\n#if !defined(SQLITE_OMIT_ANALYZE)\n/* Opcode: LoadAnalysis P1 * * * *\n**\n** Read the sqlite_stat1 table for database P1 and load the content\n** of that table into the internal index hash table.  This will cause\n** the analysis to be used when preparing all subsequent queries.\n*/\ncase OP_LoadAnalysis: {\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  rc = sqlite3AnalysisLoad(db, pOp->p1);\n  break;  \n}\n#endif /* !defined(SQLITE_OMIT_ANALYZE) */\n\n/* Opcode: DropTable P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the table named P4 in database P1.  This is called after a table\n** is dropped in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTable: {\n  sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropIndex P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the index named P4 in database P1.  This is called after an index\n** is dropped in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropIndex: {\n  sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropTrigger P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the trigger named P4 in database P1.  This is called after a trigger\n** is dropped in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTrigger: {\n  sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/* Opcode: IntegrityCk P1 P2 P3 * P5\n**\n** Do an analysis of the currently open database.  Store in\n** register P1 the text of an error message describing any problems.\n** If no problems are found, store a NULL in register P1.\n**\n** The register P3 contains the maximum number of allowed errors.\n** At most reg(P3) errors will be reported.\n** In other words, the analysis stops as soon as reg(P1) errors are \n** seen.  Reg(P1) is updated with the number of errors remaining.\n**\n** The root page numbers of all tables in the database are integer\n** stored in reg(P1), reg(P1+1), reg(P1+2), ....  There are P2 tables\n** total.\n**\n** If P5 is not zero, the check is done on the auxiliary database\n** file, not the main database file.\n**\n** This opcode is used to implement the integrity_check pragma.\n*/\ncase OP_IntegrityCk: {\n#if 0  /* local variables moved into u.ca */\n  int nRoot;      /* Number of tables to check.  (Number of root pages.) */\n  int *aRoot;     /* Array of rootpage numbers for tables to be checked */\n  int j;          /* Loop counter */\n  int nErr;       /* Number of errors reported */\n  char *z;        /* Text of the error report */\n  Mem *pnErr;     /* Register keeping track of errors remaining */\n#endif /* local variables moved into u.ca */\n\n  u.ca.nRoot = pOp->p2;\n  assert( u.ca.nRoot>0 );\n  u.ca.aRoot = sqlite3DbMallocRaw(db, sizeof(int)*(u.ca.nRoot+1) );\n  if( u.ca.aRoot==0 ) goto no_mem;\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  u.ca.pnErr = &aMem[pOp->p3];\n  assert( (u.ca.pnErr->flags & MEM_Int)!=0 );\n  assert( (u.ca.pnErr->flags & (MEM_Str|MEM_Blob))==0 );\n  pIn1 = &aMem[pOp->p1];\n  for(u.ca.j=0; u.ca.j<u.ca.nRoot; u.ca.j++){\n    u.ca.aRoot[u.ca.j] = (int)sqlite3VdbeIntValue(&pIn1[u.ca.j]);\n  }\n  u.ca.aRoot[u.ca.j] = 0;\n  assert( pOp->p5<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p5))!=0 );\n  u.ca.z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, u.ca.aRoot, u.ca.nRoot,\n                                 (int)u.ca.pnErr->u.i, &u.ca.nErr);\n  sqlite3DbFree(db, u.ca.aRoot);\n  u.ca.pnErr->u.i -= u.ca.nErr;\n  sqlite3VdbeMemSetNull(pIn1);\n  if( u.ca.nErr==0 ){\n    assert( u.ca.z==0 );\n  }else if( u.ca.z==0 ){\n    goto no_mem;\n  }else{\n    sqlite3VdbeMemSetStr(pIn1, u.ca.z, -1, SQLITE_UTF8, sqlite3_free);\n  }\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  sqlite3VdbeChangeEncoding(pIn1, encoding);\n  break;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/* Opcode: RowSetAdd P1 P2 * * *\n**\n** Insert the integer value held by register P2 into a boolean index\n** held in register P1.\n**\n** An assertion fails if P2 is not an integer.\n*/\ncase OP_RowSetAdd: {       /* in1, in2 */\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  assert( (pIn2->flags & MEM_Int)!=0 );\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n  sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);\n  break;\n}\n\n/* Opcode: RowSetRead P1 P2 P3 * *\n**\n** Extract the smallest value from boolean index P1 and put that value into\n** register P3.  Or, if boolean index P1 is initially empty, leave P3\n** unchanged and jump to instruction P2.\n*/\ncase OP_RowSetRead: {       /* jump, in1, out3 */\n#if 0  /* local variables moved into u.cb */\n  i64 val;\n#endif /* local variables moved into u.cb */\n  CHECK_FOR_INTERRUPT;\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_RowSet)==0\n   || sqlite3RowSetNext(pIn1->u.pRowSet, &u.cb.val)==0\n  ){\n    /* The boolean index is empty */\n    sqlite3VdbeMemSetNull(pIn1);\n    pc = pOp->p2 - 1;\n  }else{\n    /* A value was pulled from the index */\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p3], u.cb.val);\n  }\n  break;\n}\n\n/* Opcode: RowSetTest P1 P2 P3 P4\n**\n** Register P3 is assumed to hold a 64-bit integer value. If register P1\n** contains a RowSet object and that RowSet object contains\n** the value held in P3, jump to register P2. Otherwise, insert the\n** integer in P3 into the RowSet and continue on to the\n** next opcode.\n**\n** The RowSet object is optimized for the case where successive sets\n** of integers, where each set contains no duplicates. Each set\n** of values is identified by a unique P4 value. The first set\n** must have P4==0, the final set P4=-1.  P4 must be either -1 or\n** non-negative.  For non-negative values of P4 only the lower 4\n** bits are significant.\n**\n** This allows optimizations: (a) when P4==0 there is no need to test\n** the rowset object for P3, as it is guaranteed not to contain it,\n** (b) when P4==-1 there is no need to insert the value, as it will\n** never be tested for, and (c) when a value that is part of set X is\n** inserted, there is no need to search to see if the same value was\n** previously inserted as part of set X (only if it was previously\n** inserted as part of some other set).\n*/\ncase OP_RowSetTest: {                     /* jump, in1, in3 */\n#if 0  /* local variables moved into u.cc */\n  int iSet;\n  int exists;\n#endif /* local variables moved into u.cc */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  u.cc.iSet = pOp->p4.i;\n  assert( pIn3->flags&MEM_Int );\n\n  /* If there is anything other than a rowset object in memory cell P1,\n  ** delete it now and initialize P1 with an empty rowset\n  */\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n\n  assert( pOp->p4type==P4_INT32 );\n  assert( u.cc.iSet==-1 || u.cc.iSet>=0 );\n  if( u.cc.iSet ){\n    u.cc.exists = sqlite3RowSetTest(pIn1->u.pRowSet,\n                               (u8)(u.cc.iSet>=0 ? u.cc.iSet & 0xf : 0xff),\n                               pIn3->u.i);\n    if( u.cc.exists ){\n      pc = pOp->p2 - 1;\n      break;\n    }\n  }\n  if( u.cc.iSet>=0 ){\n    sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);\n  }\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_TRIGGER\n\n/* Opcode: Program P1 P2 P3 P4 *\n**\n** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). \n**\n** P1 contains the address of the memory cell that contains the first memory \n** cell in an array of values used as arguments to the sub-program. P2 \n** contains the address to jump to if the sub-program throws an IGNORE \n** exception using the RAISE() function. Register P3 contains the address \n** of a memory cell in this (the parent) VM that is used to allocate the \n** memory required by the sub-vdbe at runtime.\n**\n** P4 is a pointer to the VM containing the trigger program.\n*/\ncase OP_Program: {        /* jump */\n#if 0  /* local variables moved into u.cd */\n  int nMem;               /* Number of memory registers for sub-program */\n  int nByte;              /* Bytes of runtime space required for sub-program */\n  Mem *pRt;               /* Register to allocate runtime space */\n  Mem *pMem;              /* Used to iterate through memory cells */\n  Mem *pEnd;              /* Last memory cell in new array */\n  VdbeFrame *pFrame;      /* New vdbe frame to execute in */\n  SubProgram *pProgram;   /* Sub-program to execute */\n  void *t;                /* Token identifying trigger */\n#endif /* local variables moved into u.cd */\n\n  u.cd.pProgram = pOp->p4.pProgram;\n  u.cd.pRt = &aMem[pOp->p3];\n  assert( u.cd.pProgram->nOp>0 );\n\n  /* If the p5 flag is clear, then recursive invocation of triggers is\n  ** disabled for backwards compatibility (p5 is set if this sub-program\n  ** is really a trigger, not a foreign key action, and the flag set\n  ** and cleared by the \"PRAGMA recursive_triggers\" command is clear).\n  **\n  ** It is recursive invocation of triggers, at the SQL level, that is\n  ** disabled. In some cases a single trigger may generate more than one\n  ** SubProgram (if the trigger may be executed with more than one different\n  ** ON CONFLICT algorithm). SubProgram structures associated with a\n  ** single trigger all have the same value for the SubProgram.token\n  ** variable.  */\n  if( pOp->p5 ){\n    u.cd.t = u.cd.pProgram->token;\n    for(u.cd.pFrame=p->pFrame; u.cd.pFrame && u.cd.pFrame->token!=u.cd.t; u.cd.pFrame=u.cd.pFrame->pParent);\n    if( u.cd.pFrame ) break;\n  }\n\n  if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){\n    rc = SQLITE_ERROR;\n    sqlite3SetString(&p->zErrMsg, db, \"too many levels of trigger recursion\");\n    break;\n  }\n\n  /* Register u.cd.pRt is used to store the memory required to save the state\n  ** of the current program, and the memory required at runtime to execute\n  ** the trigger program. If this trigger has been fired before, then u.cd.pRt\n  ** is already allocated. Otherwise, it must be initialized.  */\n  if( (u.cd.pRt->flags&MEM_Frame)==0 ){\n    /* SubProgram.nMem is set to the number of memory cells used by the\n    ** program stored in SubProgram.aOp. As well as these, one memory\n    ** cell is required for each cursor used by the program. Set local\n    ** variable u.cd.nMem (and later, VdbeFrame.nChildMem) to this value.\n    */\n    u.cd.nMem = u.cd.pProgram->nMem + u.cd.pProgram->nCsr;\n    u.cd.nByte = ROUND8(sizeof(VdbeFrame))\n              + u.cd.nMem * sizeof(Mem)\n              + u.cd.pProgram->nCsr * sizeof(VdbeCursor *)\n              + u.cd.pProgram->nOnce * sizeof(u8);\n    u.cd.pFrame = sqlite3DbMallocZero(db, u.cd.nByte);\n    if( !u.cd.pFrame ){\n      goto no_mem;\n    }\n    sqlite3VdbeMemRelease(u.cd.pRt);\n    u.cd.pRt->flags = MEM_Frame;\n    u.cd.pRt->u.pFrame = u.cd.pFrame;\n\n    u.cd.pFrame->v = p;\n    u.cd.pFrame->nChildMem = u.cd.nMem;\n    u.cd.pFrame->nChildCsr = u.cd.pProgram->nCsr;\n    u.cd.pFrame->pc = pc;\n    u.cd.pFrame->aMem = p->aMem;\n    u.cd.pFrame->nMem = p->nMem;\n    u.cd.pFrame->apCsr = p->apCsr;\n    u.cd.pFrame->nCursor = p->nCursor;\n    u.cd.pFrame->aOp = p->aOp;\n    u.cd.pFrame->nOp = p->nOp;\n    u.cd.pFrame->token = u.cd.pProgram->token;\n    u.cd.pFrame->aOnceFlag = p->aOnceFlag;\n    u.cd.pFrame->nOnceFlag = p->nOnceFlag;\n\n    u.cd.pEnd = &VdbeFrameMem(u.cd.pFrame)[u.cd.pFrame->nChildMem];\n    for(u.cd.pMem=VdbeFrameMem(u.cd.pFrame); u.cd.pMem!=u.cd.pEnd; u.cd.pMem++){\n      u.cd.pMem->flags = MEM_Invalid;\n      u.cd.pMem->db = db;\n    }\n  }else{\n    u.cd.pFrame = u.cd.pRt->u.pFrame;\n    assert( u.cd.pProgram->nMem+u.cd.pProgram->nCsr==u.cd.pFrame->nChildMem );\n    assert( u.cd.pProgram->nCsr==u.cd.pFrame->nChildCsr );\n    assert( pc==u.cd.pFrame->pc );\n  }\n\n  p->nFrame++;\n  u.cd.pFrame->pParent = p->pFrame;\n  u.cd.pFrame->lastRowid = lastRowid;\n  u.cd.pFrame->nChange = p->nChange;\n  p->nChange = 0;\n  p->pFrame = u.cd.pFrame;\n  p->aMem = aMem = &VdbeFrameMem(u.cd.pFrame)[-1];\n  p->nMem = u.cd.pFrame->nChildMem;\n  p->nCursor = (u16)u.cd.pFrame->nChildCsr;\n  p->apCsr = (VdbeCursor **)&aMem[p->nMem+1];\n  p->aOp = aOp = u.cd.pProgram->aOp;\n  p->nOp = u.cd.pProgram->nOp;\n  p->aOnceFlag = (u8 *)&p->apCsr[p->nCursor];\n  p->nOnceFlag = u.cd.pProgram->nOnce;\n  pc = -1;\n  memset(p->aOnceFlag, 0, p->nOnceFlag);\n\n  break;\n}\n\n/* Opcode: Param P1 P2 * * *\n**\n** This opcode is only ever present in sub-programs called via the \n** OP_Program instruction. Copy a value currently stored in a memory \n** cell of the calling (parent) frame to cell P2 in the current frames \n** address space. This is used by trigger programs to access the new.* \n** and old.* values.\n**\n** The address of the cell in the parent frame is determined by adding\n** the value of the P1 argument to the value of the P1 argument to the\n** calling OP_Program instruction.\n*/\ncase OP_Param: {           /* out2-prerelease */\n#if 0  /* local variables moved into u.ce */\n  VdbeFrame *pFrame;\n  Mem *pIn;\n#endif /* local variables moved into u.ce */\n  u.ce.pFrame = p->pFrame;\n  u.ce.pIn = &u.ce.pFrame->aMem[pOp->p1 + u.ce.pFrame->aOp[u.ce.pFrame->pc].p1];\n  sqlite3VdbeMemShallowCopy(pOut, u.ce.pIn, MEM_Ephem);\n  break;\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRIGGER */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n/* Opcode: FkCounter P1 P2 * * *\n**\n** Increment a \"constraint counter\" by P2 (P2 may be negative or positive).\n** If P1 is non-zero, the database constraint counter is incremented \n** (deferred foreign key constraints). Otherwise, if P1 is zero, the \n** statement counter is incremented (immediate foreign key constraints).\n*/\ncase OP_FkCounter: {\n  if( pOp->p1 ){\n    db->nDeferredCons += pOp->p2;\n  }else{\n    p->nFkConstraint += pOp->p2;\n  }\n  break;\n}\n\n/* Opcode: FkIfZero P1 P2 * * *\n**\n** This opcode tests if a foreign key constraint-counter is currently zero.\n** If so, jump to instruction P2. Otherwise, fall through to the next \n** instruction.\n**\n** If P1 is non-zero, then the jump is taken if the database constraint-counter\n** is zero (the one that counts deferred constraint violations). If P1 is\n** zero, the jump is taken if the statement constraint-counter is zero\n** (immediate foreign key constraint violations).\n*/\ncase OP_FkIfZero: {         /* jump */\n  if( pOp->p1 ){\n    if( db->nDeferredCons==0 ) pc = pOp->p2-1;\n  }else{\n    if( p->nFkConstraint==0 ) pc = pOp->p2-1;\n  }\n  break;\n}\n#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/* Opcode: MemMax P1 P2 * * *\n**\n** P1 is a register in the root frame of this VM (the root frame is\n** different from the current frame if this instruction is being executed\n** within a sub-program). Set the value of register P1 to the maximum of \n** its current value and the value in register P2.\n**\n** This instruction throws an error if the memory cell is not initially\n** an integer.\n*/\ncase OP_MemMax: {        /* in2 */\n#if 0  /* local variables moved into u.cf */\n  Mem *pIn1;\n  VdbeFrame *pFrame;\n#endif /* local variables moved into u.cf */\n  if( p->pFrame ){\n    for(u.cf.pFrame=p->pFrame; u.cf.pFrame->pParent; u.cf.pFrame=u.cf.pFrame->pParent);\n    u.cf.pIn1 = &u.cf.pFrame->aMem[pOp->p1];\n  }else{\n    u.cf.pIn1 = &aMem[pOp->p1];\n  }\n  assert( memIsValid(u.cf.pIn1) );\n  sqlite3VdbeMemIntegerify(u.cf.pIn1);\n  pIn2 = &aMem[pOp->p2];\n  sqlite3VdbeMemIntegerify(pIn2);\n  if( u.cf.pIn1->u.i<pIn2->u.i){\n    u.cf.pIn1->u.i = pIn2->u.i;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n/* Opcode: IfPos P1 P2 * * *\n**\n** If the value of register P1 is 1 or greater, jump to P2.\n**\n** It is illegal to use this instruction on a register that does\n** not contain an integer.  An assertion fault will result if you try.\n*/\ncase OP_IfPos: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  if( pIn1->u.i>0 ){\n     pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: IfNeg P1 P2 * * *\n**\n** If the value of register P1 is less than zero, jump to P2. \n**\n** It is illegal to use this instruction on a register that does\n** not contain an integer.  An assertion fault will result if you try.\n*/\ncase OP_IfNeg: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  if( pIn1->u.i<0 ){\n     pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: IfZero P1 P2 P3 * *\n**\n** The register P1 must contain an integer.  Add literal P3 to the\n** value in register P1.  If the result is exactly 0, jump to P2. \n**\n** It is illegal to use this instruction on a register that does\n** not contain an integer.  An assertion fault will result if you try.\n*/\ncase OP_IfZero: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  pIn1->u.i += pOp->p3;\n  if( pIn1->u.i==0 ){\n     pc = pOp->p2 - 1;\n  }\n  break;\n}\n\n/* Opcode: AggStep * P2 P3 P4 P5\n**\n** Execute the step function for an aggregate.  The\n** function has P5 arguments.   P4 is a pointer to the FuncDef\n** structure that specifies the function.  Use register\n** P3 as the accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n*/\ncase OP_AggStep: {\n#if 0  /* local variables moved into u.cg */\n  int n;\n  int i;\n  Mem *pMem;\n  Mem *pRec;\n  sqlite3_context ctx;\n  sqlite3_value **apVal;\n#endif /* local variables moved into u.cg */\n\n  u.cg.n = pOp->p5;\n  assert( u.cg.n>=0 );\n  u.cg.pRec = &aMem[pOp->p2];\n  u.cg.apVal = p->apArg;\n  assert( u.cg.apVal || u.cg.n==0 );\n  for(u.cg.i=0; u.cg.i<u.cg.n; u.cg.i++, u.cg.pRec++){\n    assert( memIsValid(u.cg.pRec) );\n    u.cg.apVal[u.cg.i] = u.cg.pRec;\n    memAboutToChange(p, u.cg.pRec);\n    sqlite3VdbeMemStoreType(u.cg.pRec);\n  }\n  u.cg.ctx.pFunc = pOp->p4.pFunc;\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  u.cg.ctx.pMem = u.cg.pMem = &aMem[pOp->p3];\n  u.cg.pMem->n++;\n  u.cg.ctx.s.flags = MEM_Null;\n  u.cg.ctx.s.z = 0;\n  u.cg.ctx.s.zMalloc = 0;\n  u.cg.ctx.s.xDel = 0;\n  u.cg.ctx.s.db = db;\n  u.cg.ctx.isError = 0;\n  u.cg.ctx.pColl = 0;\n  u.cg.ctx.skipFlag = 0;\n  if( u.cg.ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){\n    assert( pOp>p->aOp );\n    assert( pOp[-1].p4type==P4_COLLSEQ );\n    assert( pOp[-1].opcode==OP_CollSeq );\n    u.cg.ctx.pColl = pOp[-1].p4.pColl;\n  }\n  (u.cg.ctx.pFunc->xStep)(&u.cg.ctx, u.cg.n, u.cg.apVal); /* IMP: R-24505-23230 */\n  if( u.cg.ctx.isError ){\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3_value_text(&u.cg.ctx.s));\n    rc = u.cg.ctx.isError;\n  }\n  if( u.cg.ctx.skipFlag ){\n    assert( pOp[-1].opcode==OP_CollSeq );\n    u.cg.i = pOp[-1].p1;\n    if( u.cg.i ) sqlite3VdbeMemSetInt64(&aMem[u.cg.i], 1);\n  }\n\n  sqlite3VdbeMemRelease(&u.cg.ctx.s);\n\n  break;\n}\n\n/* Opcode: AggFinal P1 P2 * P4 *\n**\n** Execute the finalizer function for an aggregate.  P1 is\n** the memory location that is the accumulator for the aggregate.\n**\n** P2 is the number of arguments that the step function takes and\n** P4 is a pointer to the FuncDef for this function.  The P2\n** argument is not used by this opcode.  It is only there to disambiguate\n** functions that can take varying numbers of arguments.  The\n** P4 argument is only needed for the degenerate case where\n** the step function was not previously called.\n*/\ncase OP_AggFinal: {\n#if 0  /* local variables moved into u.ch */\n  Mem *pMem;\n#endif /* local variables moved into u.ch */\n  assert( pOp->p1>0 && pOp->p1<=p->nMem );\n  u.ch.pMem = &aMem[pOp->p1];\n  assert( (u.ch.pMem->flags & ~(MEM_Null|MEM_Agg))==0 );\n  rc = sqlite3VdbeMemFinalize(u.ch.pMem, pOp->p4.pFunc);\n  if( rc ){\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3_value_text(u.ch.pMem));\n  }\n  sqlite3VdbeChangeEncoding(u.ch.pMem, encoding);\n  UPDATE_MAX_BLOBSIZE(u.ch.pMem);\n  if( sqlite3VdbeMemTooBig(u.ch.pMem) ){\n    goto too_big;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/* Opcode: Checkpoint P1 P2 P3 * *\n**\n** Checkpoint database P1. This is a no-op if P1 is not currently in\n** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL\n** or RESTART.  Write 1 or 0 into mem[P3] if the checkpoint returns\n** SQLITE_BUSY or not, respectively.  Write the number of pages in the\n** WAL after the checkpoint into mem[P3+1] and the number of pages\n** in the WAL that have been checkpointed after the checkpoint\n** completes into mem[P3+2].  However on an error, mem[P3+1] and\n** mem[P3+2] are initialized to -1.\n*/\ncase OP_Checkpoint: {\n#if 0  /* local variables moved into u.ci */\n  int i;                          /* Loop counter */\n  int aRes[3];                    /* Results */\n  Mem *pMem;                      /* Write results here */\n#endif /* local variables moved into u.ci */\n\n  u.ci.aRes[0] = 0;\n  u.ci.aRes[1] = u.ci.aRes[2] = -1;\n  assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE\n       || pOp->p2==SQLITE_CHECKPOINT_FULL\n       || pOp->p2==SQLITE_CHECKPOINT_RESTART\n  );\n  rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &u.ci.aRes[1], &u.ci.aRes[2]);\n  if( rc==SQLITE_BUSY ){\n    rc = SQLITE_OK;\n    u.ci.aRes[0] = 1;\n  }\n  for(u.ci.i=0, u.ci.pMem = &aMem[pOp->p3]; u.ci.i<3; u.ci.i++, u.ci.pMem++){\n    sqlite3VdbeMemSetInt64(u.ci.pMem, (i64)u.ci.aRes[u.ci.i]);\n  }\n  break;\n};  \n#endif\n\n#ifndef SQLITE_OMIT_PRAGMA\n/* Opcode: JournalMode P1 P2 P3 * P5\n**\n** Change the journal mode of database P1 to P3. P3 must be one of the\n** PAGER_JOURNALMODE_XXX values. If changing between the various rollback\n** modes (delete, truncate, persist, off and memory), this is a simple\n** operation. No IO is required.\n**\n** If changing into or out of WAL mode the procedure is more complicated.\n**\n** Write a string containing the final journal-mode to register P2.\n*/\ncase OP_JournalMode: {    /* out2-prerelease */\n#if 0  /* local variables moved into u.cj */\n  Btree *pBt;                     /* Btree to change journal mode of */\n  Pager *pPager;                  /* Pager associated with pBt */\n  int eNew;                       /* New journal mode */\n  int eOld;                       /* The old journal mode */\n#ifndef SQLITE_OMIT_WAL\n  const char *zFilename;          /* Name of database file for pPager */\n#endif\n#endif /* local variables moved into u.cj */\n\n  u.cj.eNew = pOp->p3;\n  assert( u.cj.eNew==PAGER_JOURNALMODE_DELETE\n       || u.cj.eNew==PAGER_JOURNALMODE_TRUNCATE\n       || u.cj.eNew==PAGER_JOURNALMODE_PERSIST\n       || u.cj.eNew==PAGER_JOURNALMODE_OFF\n       || u.cj.eNew==PAGER_JOURNALMODE_MEMORY\n       || u.cj.eNew==PAGER_JOURNALMODE_WAL\n       || u.cj.eNew==PAGER_JOURNALMODE_QUERY\n  );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n\n  u.cj.pBt = db->aDb[pOp->p1].pBt;\n  u.cj.pPager = sqlite3BtreePager(u.cj.pBt);\n  u.cj.eOld = sqlite3PagerGetJournalMode(u.cj.pPager);\n  if( u.cj.eNew==PAGER_JOURNALMODE_QUERY ) u.cj.eNew = u.cj.eOld;\n  if( !sqlite3PagerOkToChangeJournalMode(u.cj.pPager) ) u.cj.eNew = u.cj.eOld;\n\n#ifndef SQLITE_OMIT_WAL\n  u.cj.zFilename = sqlite3PagerFilename(u.cj.pPager, 1);\n\n  /* Do not allow a transition to journal_mode=WAL for a database\n  ** in temporary storage or if the VFS does not support shared memory\n  */\n  if( u.cj.eNew==PAGER_JOURNALMODE_WAL\n   && (sqlite3Strlen30(u.cj.zFilename)==0           /* Temp file */\n       || !sqlite3PagerWalSupported(u.cj.pPager))   /* No shared-memory support */\n  ){\n    u.cj.eNew = u.cj.eOld;\n  }\n\n  if( (u.cj.eNew!=u.cj.eOld)\n   && (u.cj.eOld==PAGER_JOURNALMODE_WAL || u.cj.eNew==PAGER_JOURNALMODE_WAL)\n  ){\n    if( !db->autoCommit || db->activeVdbeCnt>1 ){\n      rc = SQLITE_ERROR;\n      sqlite3SetString(&p->zErrMsg, db,\n          \"cannot change %s wal mode from within a transaction\",\n          (u.cj.eNew==PAGER_JOURNALMODE_WAL ? \"into\" : \"out of\")\n      );\n      break;\n    }else{\n\n      if( u.cj.eOld==PAGER_JOURNALMODE_WAL ){\n        /* If leaving WAL mode, close the log file. If successful, the call\n        ** to PagerCloseWal() checkpoints and deletes the write-ahead-log\n        ** file. An EXCLUSIVE lock may still be held on the database file\n        ** after a successful return.\n        */\n        rc = sqlite3PagerCloseWal(u.cj.pPager);\n        if( rc==SQLITE_OK ){\n          sqlite3PagerSetJournalMode(u.cj.pPager, u.cj.eNew);\n        }\n      }else if( u.cj.eOld==PAGER_JOURNALMODE_MEMORY ){\n        /* Cannot transition directly from MEMORY to WAL.  Use mode OFF\n        ** as an intermediate */\n        sqlite3PagerSetJournalMode(u.cj.pPager, PAGER_JOURNALMODE_OFF);\n      }\n\n      /* Open a transaction on the database file. Regardless of the journal\n      ** mode, this transaction always uses a rollback journal.\n      */\n      assert( sqlite3BtreeIsInTrans(u.cj.pBt)==0 );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeSetVersion(u.cj.pBt, (u.cj.eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));\n      }\n    }\n  }\n#endif /* ifndef SQLITE_OMIT_WAL */\n\n  if( rc ){\n    u.cj.eNew = u.cj.eOld;\n  }\n  u.cj.eNew = sqlite3PagerSetJournalMode(u.cj.pPager, u.cj.eNew);\n\n  pOut = &aMem[pOp->p2];\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = (char *)sqlite3JournalModename(u.cj.eNew);\n  pOut->n = sqlite3Strlen30(pOut->z);\n  pOut->enc = SQLITE_UTF8;\n  sqlite3VdbeChangeEncoding(pOut, encoding);\n  break;\n};\n#endif /* SQLITE_OMIT_PRAGMA */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n/* Opcode: Vacuum * * * * *\n**\n** Vacuum the entire database.  This opcode will cause other virtual\n** machines to be created and run.  It may not be called from within\n** a transaction.\n*/\ncase OP_Vacuum: {\n  rc = sqlite3RunVacuum(&p->zErrMsg, db);\n  break;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n/* Opcode: IncrVacuum P1 P2 * * *\n**\n** Perform a single step of the incremental vacuum procedure on\n** the P1 database. If the vacuum has finished, jump to instruction\n** P2. Otherwise, fall through to the next instruction.\n*/\ncase OP_IncrVacuum: {        /* jump */\n#if 0  /* local variables moved into u.ck */\n  Btree *pBt;\n#endif /* local variables moved into u.ck */\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 );\n  u.ck.pBt = db->aDb[pOp->p1].pBt;\n  rc = sqlite3BtreeIncrVacuum(u.ck.pBt);\n  if( rc==SQLITE_DONE ){\n    pc = pOp->p2 - 1;\n    rc = SQLITE_OK;\n  }\n  break;\n}\n#endif\n\n/* Opcode: Expire P1 * * * *\n**\n** Cause precompiled statements to become expired. An expired statement\n** fails with an error code of SQLITE_SCHEMA if it is ever executed \n** (via sqlite3_step()).\n** \n** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,\n** then only the currently executing statement is affected. \n*/\ncase OP_Expire: {\n  if( !pOp->p1 ){\n    sqlite3ExpirePreparedStatements(db);\n  }else{\n    p->expired = 1;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/* Opcode: TableLock P1 P2 P3 P4 *\n**\n** Obtain a lock on a particular table. This instruction is only used when\n** the shared-cache feature is enabled. \n**\n** P1 is the index of the database in sqlite3.aDb[] of the database\n** on which the lock is acquired.  A readlock is obtained if P3==0 or\n** a write lock if P3==1.\n**\n** P2 contains the root-page of the table to lock.\n**\n** P4 contains a pointer to the name of the table being locked. This is only\n** used to generate an error message if the lock cannot be obtained.\n*/\ncase OP_TableLock: {\n  u8 isWriteLock = (u8)pOp->p3;\n  if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){\n    int p1 = pOp->p1; \n    assert( p1>=0 && p1<db->nDb );\n    assert( (p->btreeMask & (((yDbMask)1)<<p1))!=0 );\n    assert( isWriteLock==0 || isWriteLock==1 );\n    rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);\n    if( (rc&0xFF)==SQLITE_LOCKED ){\n      const char *z = pOp->p4.z;\n      sqlite3SetString(&p->zErrMsg, db, \"database table is locked: %s\", z);\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VBegin * * * P4 *\n**\n** P4 may be a pointer to an sqlite3_vtab structure. If so, call the \n** xBegin method for that table.\n**\n** Also, whether or not P4 is set, check that this is not being called from\n** within a callback to a virtual table xSync() method. If it is, the error\n** code will be set to SQLITE_LOCKED.\n*/\ncase OP_VBegin: {\n#if 0  /* local variables moved into u.cl */\n  VTable *pVTab;\n#endif /* local variables moved into u.cl */\n  u.cl.pVTab = pOp->p4.pVtab;\n  rc = sqlite3VtabBegin(db, u.cl.pVTab);\n  if( u.cl.pVTab ) importVtabErrMsg(p, u.cl.pVTab->pVtab);\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VCreate P1 * * P4 *\n**\n** P4 is the name of a virtual table in database P1. Call the xCreate method\n** for that table.\n*/\ncase OP_VCreate: {\n  rc = sqlite3VtabCallCreate(db, pOp->p1, pOp->p4.z, &p->zErrMsg);\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VDestroy P1 * * P4 *\n**\n** P4 is the name of a virtual table in database P1.  Call the xDestroy method\n** of that table.\n*/\ncase OP_VDestroy: {\n  p->inVtabMethod = 2;\n  rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);\n  p->inVtabMethod = 0;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VOpen P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** P1 is a cursor number.  This opcode opens a cursor to the virtual\n** table and stores that cursor in P1.\n*/\ncase OP_VOpen: {\n#if 0  /* local variables moved into u.cm */\n  VdbeCursor *pCur;\n  sqlite3_vtab_cursor *pVtabCursor;\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pModule;\n#endif /* local variables moved into u.cm */\n\n  u.cm.pCur = 0;\n  u.cm.pVtabCursor = 0;\n  u.cm.pVtab = pOp->p4.pVtab->pVtab;\n  u.cm.pModule = (sqlite3_module *)u.cm.pVtab->pModule;\n  assert(u.cm.pVtab && u.cm.pModule);\n  rc = u.cm.pModule->xOpen(u.cm.pVtab, &u.cm.pVtabCursor);\n  importVtabErrMsg(p, u.cm.pVtab);\n  if( SQLITE_OK==rc ){\n    /* Initialize sqlite3_vtab_cursor base class */\n    u.cm.pVtabCursor->pVtab = u.cm.pVtab;\n\n    /* Initialize vdbe cursor object */\n    u.cm.pCur = allocateCursor(p, pOp->p1, 0, -1, 0);\n    if( u.cm.pCur ){\n      u.cm.pCur->pVtabCursor = u.cm.pVtabCursor;\n      u.cm.pCur->pModule = u.cm.pVtabCursor->pVtab->pModule;\n    }else{\n      db->mallocFailed = 1;\n      u.cm.pModule->xClose(u.cm.pVtabCursor);\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VFilter P1 P2 P3 P4 *\n**\n** P1 is a cursor opened using VOpen.  P2 is an address to jump to if\n** the filtered result set is empty.\n**\n** P4 is either NULL or a string that was generated by the xBestIndex\n** method of the module.  The interpretation of the P4 string is left\n** to the module implementation.\n**\n** This opcode invokes the xFilter method on the virtual table specified\n** by P1.  The integer query plan parameter to xFilter is stored in register\n** P3. Register P3+1 stores the argc parameter to be passed to the\n** xFilter method. Registers P3+2..P3+1+argc are the argc\n** additional parameters which are passed to\n** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter.\n**\n** A jump is made to P2 if the result set after filtering would be empty.\n*/\ncase OP_VFilter: {   /* jump */\n#if 0  /* local variables moved into u.cn */\n  int nArg;\n  int iQuery;\n  const sqlite3_module *pModule;\n  Mem *pQuery;\n  Mem *pArgc;\n  sqlite3_vtab_cursor *pVtabCursor;\n  sqlite3_vtab *pVtab;\n  VdbeCursor *pCur;\n  int res;\n  int i;\n  Mem **apArg;\n#endif /* local variables moved into u.cn */\n\n  u.cn.pQuery = &aMem[pOp->p3];\n  u.cn.pArgc = &u.cn.pQuery[1];\n  u.cn.pCur = p->apCsr[pOp->p1];\n  assert( memIsValid(u.cn.pQuery) );\n  REGISTER_TRACE(pOp->p3, u.cn.pQuery);\n  assert( u.cn.pCur->pVtabCursor );\n  u.cn.pVtabCursor = u.cn.pCur->pVtabCursor;\n  u.cn.pVtab = u.cn.pVtabCursor->pVtab;\n  u.cn.pModule = u.cn.pVtab->pModule;\n\n  /* Grab the index number and argc parameters */\n  assert( (u.cn.pQuery->flags&MEM_Int)!=0 && u.cn.pArgc->flags==MEM_Int );\n  u.cn.nArg = (int)u.cn.pArgc->u.i;\n  u.cn.iQuery = (int)u.cn.pQuery->u.i;\n\n  /* Invoke the xFilter method */\n  {\n    u.cn.res = 0;\n    u.cn.apArg = p->apArg;\n    for(u.cn.i = 0; u.cn.i<u.cn.nArg; u.cn.i++){\n      u.cn.apArg[u.cn.i] = &u.cn.pArgc[u.cn.i+1];\n      sqlite3VdbeMemStoreType(u.cn.apArg[u.cn.i]);\n    }\n\n    p->inVtabMethod = 1;\n    rc = u.cn.pModule->xFilter(u.cn.pVtabCursor, u.cn.iQuery, pOp->p4.z, u.cn.nArg, u.cn.apArg);\n    p->inVtabMethod = 0;\n    importVtabErrMsg(p, u.cn.pVtab);\n    if( rc==SQLITE_OK ){\n      u.cn.res = u.cn.pModule->xEof(u.cn.pVtabCursor);\n    }\n\n    if( u.cn.res ){\n      pc = pOp->p2 - 1;\n    }\n  }\n  u.cn.pCur->nullRow = 0;\n\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VColumn P1 P2 P3 * *\n**\n** Store the value of the P2-th column of\n** the row of the virtual-table that the \n** P1 cursor is pointing to into register P3.\n*/\ncase OP_VColumn: {\n#if 0  /* local variables moved into u.co */\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  Mem *pDest;\n  sqlite3_context sContext;\n#endif /* local variables moved into u.co */\n\n  VdbeCursor *pCur = p->apCsr[pOp->p1];\n  assert( pCur->pVtabCursor );\n  assert( pOp->p3>0 && pOp->p3<=p->nMem );\n  u.co.pDest = &aMem[pOp->p3];\n  memAboutToChange(p, u.co.pDest);\n  if( pCur->nullRow ){\n    sqlite3VdbeMemSetNull(u.co.pDest);\n    break;\n  }\n  u.co.pVtab = pCur->pVtabCursor->pVtab;\n  u.co.pModule = u.co.pVtab->pModule;\n  assert( u.co.pModule->xColumn );\n  memset(&u.co.sContext, 0, sizeof(u.co.sContext));\n\n  /* The output cell may already have a buffer allocated. Move\n  ** the current contents to u.co.sContext.s so in case the user-function\n  ** can use the already allocated buffer instead of allocating a\n  ** new one.\n  */\n  sqlite3VdbeMemMove(&u.co.sContext.s, u.co.pDest);\n  MemSetTypeFlag(&u.co.sContext.s, MEM_Null);\n\n  rc = u.co.pModule->xColumn(pCur->pVtabCursor, &u.co.sContext, pOp->p2);\n  importVtabErrMsg(p, u.co.pVtab);\n  if( u.co.sContext.isError ){\n    rc = u.co.sContext.isError;\n  }\n\n  /* Copy the result of the function to the P3 register. We\n  ** do this regardless of whether or not an error occurred to ensure any\n  ** dynamic allocation in u.co.sContext.s (a Mem struct) is  released.\n  */\n  sqlite3VdbeChangeEncoding(&u.co.sContext.s, encoding);\n  sqlite3VdbeMemMove(u.co.pDest, &u.co.sContext.s);\n  REGISTER_TRACE(pOp->p3, u.co.pDest);\n  UPDATE_MAX_BLOBSIZE(u.co.pDest);\n\n  if( sqlite3VdbeMemTooBig(u.co.pDest) ){\n    goto too_big;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VNext P1 P2 * * *\n**\n** Advance virtual table P1 to the next row in its result set and\n** jump to instruction P2.  Or, if the virtual table has reached\n** the end of its result set, then fall through to the next instruction.\n*/\ncase OP_VNext: {   /* jump */\n#if 0  /* local variables moved into u.cp */\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int res;\n  VdbeCursor *pCur;\n#endif /* local variables moved into u.cp */\n\n  u.cp.res = 0;\n  u.cp.pCur = p->apCsr[pOp->p1];\n  assert( u.cp.pCur->pVtabCursor );\n  if( u.cp.pCur->nullRow ){\n    break;\n  }\n  u.cp.pVtab = u.cp.pCur->pVtabCursor->pVtab;\n  u.cp.pModule = u.cp.pVtab->pModule;\n  assert( u.cp.pModule->xNext );\n\n  /* Invoke the xNext() method of the module. There is no way for the\n  ** underlying implementation to return an error if one occurs during\n  ** xNext(). Instead, if an error occurs, true is returned (indicating that\n  ** data is available) and the error code returned when xColumn or\n  ** some other method is next invoked on the save virtual table cursor.\n  */\n  p->inVtabMethod = 1;\n  rc = u.cp.pModule->xNext(u.cp.pCur->pVtabCursor);\n  p->inVtabMethod = 0;\n  importVtabErrMsg(p, u.cp.pVtab);\n  if( rc==SQLITE_OK ){\n    u.cp.res = u.cp.pModule->xEof(u.cp.pCur->pVtabCursor);\n  }\n\n  if( !u.cp.res ){\n    /* If there is data, jump to P2 */\n    pc = pOp->p2 - 1;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VRename P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xRename method. The value\n** in register P1 is passed as the zName argument to the xRename method.\n*/\ncase OP_VRename: {\n#if 0  /* local variables moved into u.cq */\n  sqlite3_vtab *pVtab;\n  Mem *pName;\n#endif /* local variables moved into u.cq */\n\n  u.cq.pVtab = pOp->p4.pVtab->pVtab;\n  u.cq.pName = &aMem[pOp->p1];\n  assert( u.cq.pVtab->pModule->xRename );\n  assert( memIsValid(u.cq.pName) );\n  REGISTER_TRACE(pOp->p1, u.cq.pName);\n  assert( u.cq.pName->flags & MEM_Str );\n  testcase( u.cq.pName->enc==SQLITE_UTF8 );\n  testcase( u.cq.pName->enc==SQLITE_UTF16BE );\n  testcase( u.cq.pName->enc==SQLITE_UTF16LE );\n  rc = sqlite3VdbeChangeEncoding(u.cq.pName, SQLITE_UTF8);\n  if( rc==SQLITE_OK ){\n    rc = u.cq.pVtab->pModule->xRename(u.cq.pVtab, u.cq.pName->z);\n    importVtabErrMsg(p, u.cq.pVtab);\n    p->expired = 0;\n  }\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VUpdate P1 P2 P3 P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xUpdate method. P2 values\n** are contiguous memory cells starting at P3 to pass to the xUpdate \n** invocation. The value in register (P3+P2-1) corresponds to the \n** p2th element of the argv array passed to xUpdate.\n**\n** The xUpdate method will do a DELETE or an INSERT or both.\n** The argv[0] element (which corresponds to memory cell P3)\n** is the rowid of a row to delete.  If argv[0] is NULL then no \n** deletion occurs.  The argv[1] element is the rowid of the new \n** row.  This can be NULL to have the virtual table select the new \n** rowid for itself.  The subsequent elements in the array are \n** the values of columns in the new row.\n**\n** If P2==1 then no insert is performed.  argv[0] is the rowid of\n** a row to delete.\n**\n** P1 is a boolean flag. If it is set to true and the xUpdate call\n** is successful, then the value returned by sqlite3_last_insert_rowid() \n** is set to the value of the rowid for the row just inserted.\n*/\ncase OP_VUpdate: {\n#if 0  /* local variables moved into u.cr */\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pModule;\n  int nArg;\n  int i;\n  sqlite_int64 rowid;\n  Mem **apArg;\n  Mem *pX;\n#endif /* local variables moved into u.cr */\n\n  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback\n       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace\n  );\n  u.cr.pVtab = pOp->p4.pVtab->pVtab;\n  u.cr.pModule = (sqlite3_module *)u.cr.pVtab->pModule;\n  u.cr.nArg = pOp->p2;\n  assert( pOp->p4type==P4_VTAB );\n  if( ALWAYS(u.cr.pModule->xUpdate) ){\n    u8 vtabOnConflict = db->vtabOnConflict;\n    u.cr.apArg = p->apArg;\n    u.cr.pX = &aMem[pOp->p3];\n    for(u.cr.i=0; u.cr.i<u.cr.nArg; u.cr.i++){\n      assert( memIsValid(u.cr.pX) );\n      memAboutToChange(p, u.cr.pX);\n      sqlite3VdbeMemStoreType(u.cr.pX);\n      u.cr.apArg[u.cr.i] = u.cr.pX;\n      u.cr.pX++;\n    }\n    db->vtabOnConflict = pOp->p5;\n    rc = u.cr.pModule->xUpdate(u.cr.pVtab, u.cr.nArg, u.cr.apArg, &u.cr.rowid);\n    db->vtabOnConflict = vtabOnConflict;\n    importVtabErrMsg(p, u.cr.pVtab);\n    if( rc==SQLITE_OK && pOp->p1 ){\n      assert( u.cr.nArg>1 && u.cr.apArg[0] && (u.cr.apArg[0]->flags&MEM_Null) );\n      db->lastRowid = lastRowid = u.cr.rowid;\n    }\n    if( (rc&0xff)==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){\n      if( pOp->p5==OE_Ignore ){\n        rc = SQLITE_OK;\n      }else{\n        p->errorAction = ((pOp->p5==OE_Replace) ? OE_Abort : pOp->p5);\n      }\n    }else{\n      p->nChange++;\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: Pagecount P1 P2 * * *\n**\n** Write the current number of pages in database P1 to memory cell P2.\n*/\ncase OP_Pagecount: {            /* out2-prerelease */\n  pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);\n  break;\n}\n#endif\n\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: MaxPgcnt P1 P2 P3 * *\n**\n** Try to set the maximum page count for database P1 to the value in P3.\n** Do not let the maximum page count fall below the current page count and\n** do not change the maximum page count value if P3==0.\n**\n** Store the maximum page count after the change in register P2.\n*/\ncase OP_MaxPgcnt: {            /* out2-prerelease */\n  unsigned int newMax;\n  Btree *pBt;\n\n  pBt = db->aDb[pOp->p1].pBt;\n  newMax = 0;\n  if( pOp->p3 ){\n    newMax = sqlite3BtreeLastPage(pBt);\n    if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;\n  }\n  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);\n  break;\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_TRACE\n/* Opcode: Trace * * * P4 *\n**\n** If tracing is enabled (by the sqlite3_trace()) interface, then\n** the UTF-8 string contained in P4 is emitted on the trace callback.\n*/\ncase OP_Trace: {\n#if 0  /* local variables moved into u.cs */\n  char *zTrace;\n  char *z;\n#endif /* local variables moved into u.cs */\n\n  if( db->xTrace\n   && !p->doingRerun\n   && (u.cs.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n    u.cs.z = sqlite3VdbeExpandSql(p, u.cs.zTrace);\n    db->xTrace(db->pTraceArg, u.cs.z);\n    sqlite3DbFree(db, u.cs.z);\n  }\n#ifdef SQLITE_DEBUG\n  if( (db->flags & SQLITE_SqlTrace)!=0\n   && (u.cs.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n    sqlite3DebugPrintf(\"SQL-trace: %s\\n\", u.cs.zTrace);\n  }\n#endif /* SQLITE_DEBUG */\n  break;\n}\n#endif\n\n\n/* Opcode: Noop * * * * *\n**\n** Do nothing.  This instruction is often useful as a jump\n** destination.\n*/\n/*\n** The magic Explain opcode are only inserted when explain==2 (which\n** is to say when the EXPLAIN QUERY PLAN syntax is used.)\n** This opcode records information from the optimizer.  It is the\n** the same as a no-op.  This opcodesnever appears in a real VM program.\n*/\ndefault: {          /* This is really OP_Noop and OP_Explain */\n  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );\n  break;\n}\n\n/*****************************************************************************\n** The cases of the switch statement above this line should all be indented\n** by 6 spaces.  But the left-most 6 spaces have been removed to improve the\n** readability.  From this point on down, the normal indentation rules are\n** restored.\n*****************************************************************************/\n    }\n\n#ifdef VDBE_PROFILE\n    {\n      u64 elapsed = sqlite3Hwtime() - start;\n      pOp->cycles += elapsed;\n      pOp->cnt++;\n#if 0\n        fprintf(stdout, \"%10llu \", elapsed);\n        sqlite3VdbePrintOp(stdout, origPc, &aOp[origPc]);\n#endif\n    }\n#endif\n\n    /* The following code adds nothing to the actual functionality\n    ** of the program.  It is only here for testing and debugging.\n    ** On the other hand, it does burn CPU cycles every time through\n    ** the evaluator loop.  So we can leave it out when NDEBUG is defined.\n    */\n#ifndef NDEBUG\n    assert( pc>=-1 && pc<p->nOp );\n\n#ifdef SQLITE_DEBUG\n    if( p->trace ){\n      if( rc!=0 ) fprintf(p->trace,\"rc=%d\\n\",rc);\n      if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){\n        registerTrace(p->trace, pOp->p2, &aMem[pOp->p2]);\n      }\n      if( pOp->opflags & OPFLG_OUT3 ){\n        registerTrace(p->trace, pOp->p3, &aMem[pOp->p3]);\n      }\n    }\n#endif  /* SQLITE_DEBUG */\n#endif  /* NDEBUG */\n  }  /* The end of the for(;;) loop the loops through opcodes */\n\n  /* If we reach this point, it means that execution is finished with\n  ** an error of some kind.\n  */\nvdbe_error_halt:\n  assert( rc );\n  p->rc = rc;\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(rc, \"statement aborts at %d: [%s] %s\", \n                   pc, p->zSql, p->zErrMsg);\n  sqlite3VdbeHalt(p);\n  if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1;\n  rc = SQLITE_ERROR;\n  if( resetSchemaOnFault>0 ){\n    sqlite3ResetOneSchema(db, resetSchemaOnFault-1);\n  }\n\n  /* This is the only way out of this procedure.  We have to\n  ** release the mutexes on btrees that were acquired at the\n  ** top. */\nvdbe_return:\n  db->lastRowid = lastRowid;\n  sqlite3VdbeLeave(p);\n  return rc;\n\n  /* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH\n  ** is encountered.\n  */\ntoo_big:\n  sqlite3SetString(&p->zErrMsg, db, \"string or blob too big\");\n  rc = SQLITE_TOOBIG;\n  goto vdbe_error_halt;\n\n  /* Jump to here if a malloc() fails.\n  */\nno_mem:\n  db->mallocFailed = 1;\n  sqlite3SetString(&p->zErrMsg, db, \"out of memory\");\n  rc = SQLITE_NOMEM;\n  goto vdbe_error_halt;\n\n  /* Jump to here for any other kind of fatal error.  The \"rc\" variable\n  ** should hold the error number.\n  */\nabort_due_to_error:\n  assert( p->zErrMsg==0 );\n  if( db->mallocFailed ) rc = SQLITE_NOMEM;\n  if( rc!=SQLITE_IOERR_NOMEM ){\n    sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3ErrStr(rc));\n  }\n  goto vdbe_error_halt;\n\n  /* Jump to here if the sqlite3_interrupt() API sets the interrupt\n  ** flag.\n  */\nabort_due_to_interrupt:\n  assert( db->u1.isInterrupted );\n  rc = SQLITE_INTERRUPT;\n  p->rc = rc;\n  sqlite3SetString(&p->zErrMsg, db, \"%s\", sqlite3ErrStr(rc));\n  goto vdbe_error_halt;\n}\n\n/************** End of vdbe.c ************************************************/\n/************** Begin file vdbeblob.c ****************************************/\n/*\n** 2007 May 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement incremental BLOB I/O.\n*/\n\n\n#ifndef SQLITE_OMIT_INCRBLOB\n\n/*\n** Valid sqlite3_blob* handles point to Incrblob structures.\n*/\ntypedef struct Incrblob Incrblob;\nstruct Incrblob {\n  int flags;              /* Copy of \"flags\" passed to sqlite3_blob_open() */\n  int nByte;              /* Size of open blob, in bytes */\n  int iOffset;            /* Byte offset of blob in cursor data */\n  int iCol;               /* Table column this handle is open on */\n  BtCursor *pCsr;         /* Cursor pointing at blob row */\n  sqlite3_stmt *pStmt;    /* Statement holding cursor open */\n  sqlite3 *db;            /* The associated database */\n};\n\n\n/*\n** This function is used by both blob_open() and blob_reopen(). It seeks\n** the b-tree cursor associated with blob handle p to point to row iRow.\n** If successful, SQLITE_OK is returned and subsequent calls to\n** sqlite3_blob_read() or sqlite3_blob_write() access the specified row.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a value of type TEXT or BLOB in the column nominated when the\n** blob handle was opened, then an error code is returned and *pzErr may\n** be set to point to a buffer containing an error message. It is the\n** responsibility of the caller to free the error message buffer using\n** sqlite3DbFree().\n**\n** If an error does occur, then the b-tree cursor is closed. All subsequent\n** calls to sqlite3_blob_read(), blob_write() or blob_reopen() will \n** immediately return SQLITE_ABORT.\n*/\nstatic int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){\n  int rc;                         /* Error code */\n  char *zErr = 0;                 /* Error message */\n  Vdbe *v = (Vdbe *)p->pStmt;\n\n  /* Set the value of the SQL statements only variable to integer iRow. \n  ** This is done directly instead of using sqlite3_bind_int64() to avoid \n  ** triggering asserts related to mutexes.\n  */\n  assert( v->aVar[0].flags&MEM_Int );\n  v->aVar[0].u.i = iRow;\n\n  rc = sqlite3_step(p->pStmt);\n  if( rc==SQLITE_ROW ){\n    u32 type = v->apCsr[0]->aType[p->iCol];\n    if( type<12 ){\n      zErr = sqlite3MPrintf(p->db, \"cannot open value of type %s\",\n          type==0?\"null\": type==7?\"real\": \"integer\"\n      );\n      rc = SQLITE_ERROR;\n      sqlite3_finalize(p->pStmt);\n      p->pStmt = 0;\n    }else{\n      p->iOffset = v->apCsr[0]->aOffset[p->iCol];\n      p->nByte = sqlite3VdbeSerialTypeLen(type);\n      p->pCsr =  v->apCsr[0]->pCursor;\n      sqlite3BtreeEnterCursor(p->pCsr);\n      sqlite3BtreeCacheOverflow(p->pCsr);\n      sqlite3BtreeLeaveCursor(p->pCsr);\n    }\n  }\n\n  if( rc==SQLITE_ROW ){\n    rc = SQLITE_OK;\n  }else if( p->pStmt ){\n    rc = sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n    if( rc==SQLITE_OK ){\n      zErr = sqlite3MPrintf(p->db, \"no such rowid: %lld\", iRow);\n      rc = SQLITE_ERROR;\n    }else{\n      zErr = sqlite3MPrintf(p->db, \"%s\", sqlite3_errmsg(p->db));\n    }\n  }\n\n  assert( rc!=SQLITE_OK || zErr==0 );\n  assert( rc!=SQLITE_ROW && rc!=SQLITE_DONE );\n\n  *pzErr = zErr;\n  return rc;\n}\n\n/*\n** Open a blob handle.\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3* db,            /* The database connection */\n  const char *zDb,        /* The attached database containing the blob */\n  const char *zTable,     /* The table containing the blob */\n  const char *zColumn,    /* The column containing the blob */\n  sqlite_int64 iRow,      /* The row containing the glob */\n  int flags,              /* True -> read/write access, false -> read-only */\n  sqlite3_blob **ppBlob   /* Handle for accessing the blob returned here */\n){\n  int nAttempt = 0;\n  int iCol;               /* Index of zColumn in row-record */\n\n  /* This VDBE program seeks a btree cursor to the identified \n  ** db/table/row entry. The reason for using a vdbe program instead\n  ** of writing code to use the b-tree layer directly is that the\n  ** vdbe program will take advantage of the various transaction,\n  ** locking and error handling infrastructure built into the vdbe.\n  **\n  ** After seeking the cursor, the vdbe executes an OP_ResultRow.\n  ** Code external to the Vdbe then \"borrows\" the b-tree cursor and\n  ** uses it to implement the blob_read(), blob_write() and \n  ** blob_bytes() functions.\n  **\n  ** The sqlite3_blob_close() function finalizes the vdbe program,\n  ** which closes the b-tree cursor and (possibly) commits the \n  ** transaction.\n  */\n  static const VdbeOpList openBlob[] = {\n    {OP_Transaction, 0, 0, 0},     /* 0: Start a transaction */\n    {OP_VerifyCookie, 0, 0, 0},    /* 1: Check the schema cookie */\n    {OP_TableLock, 0, 0, 0},       /* 2: Acquire a read or write lock */\n\n    /* One of the following two instructions is replaced by an OP_Noop. */\n    {OP_OpenRead, 0, 0, 0},        /* 3: Open cursor 0 for reading */\n    {OP_OpenWrite, 0, 0, 0},       /* 4: Open cursor 0 for read/write */\n\n    {OP_Variable, 1, 1, 1},        /* 5: Push the rowid to the stack */\n    {OP_NotExists, 0, 10, 1},      /* 6: Seek the cursor */\n    {OP_Column, 0, 0, 1},          /* 7  */\n    {OP_ResultRow, 1, 0, 0},       /* 8  */\n    {OP_Goto, 0, 5, 0},            /* 9  */\n    {OP_Close, 0, 0, 0},           /* 10 */\n    {OP_Halt, 0, 0, 0},            /* 11 */\n  };\n\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  Table *pTab;\n  Parse *pParse = 0;\n  Incrblob *pBlob = 0;\n\n  flags = !!flags;                /* flags = (flags ? 1 : 0); */\n  *ppBlob = 0;\n\n  sqlite3_mutex_enter(db->mutex);\n\n  pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));\n  if( !pBlob ) goto blob_open_out;\n  pParse = sqlite3StackAllocRaw(db, sizeof(*pParse));\n  if( !pParse ) goto blob_open_out;\n\n  do {\n    memset(pParse, 0, sizeof(Parse));\n    pParse->db = db;\n    sqlite3DbFree(db, zErr);\n    zErr = 0;\n\n    sqlite3BtreeEnterAll(db);\n    pTab = sqlite3LocateTable(pParse, 0, zTable, zDb);\n    if( pTab && IsVirtual(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(pParse, \"cannot open virtual table: %s\", zTable);\n    }\n#ifndef SQLITE_OMIT_VIEW\n    if( pTab && pTab->pSelect ){\n      pTab = 0;\n      sqlite3ErrorMsg(pParse, \"cannot open view: %s\", zTable);\n    }\n#endif\n    if( !pTab ){\n      if( pParse->zErrMsg ){\n        sqlite3DbFree(db, zErr);\n        zErr = pParse->zErrMsg;\n        pParse->zErrMsg = 0;\n      }\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n\n    /* Now search pTab for the exact column. */\n    for(iCol=0; iCol<pTab->nCol; iCol++) {\n      if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      sqlite3DbFree(db, zErr);\n      zErr = sqlite3MPrintf(db, \"no such column: \\\"%s\\\"\", zColumn);\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n\n    /* If the value is being opened for writing, check that the\n    ** column is not indexed, and that it is not part of a foreign key. \n    ** It is against the rules to open a column to which either of these\n    ** descriptions applies for writing.  */\n    if( flags ){\n      const char *zFault = 0;\n      Index *pIdx;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n      if( db->flags&SQLITE_ForeignKeys ){\n        /* Check that the column is not part of an FK child key definition. It\n        ** is not necessary to check if it is part of a parent key, as parent\n        ** key columns must be indexed. The check below will pick up this \n        ** case.  */\n        FKey *pFKey;\n        for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n          int j;\n          for(j=0; j<pFKey->nCol; j++){\n            if( pFKey->aCol[j].iFrom==iCol ){\n              zFault = \"foreign key\";\n            }\n          }\n        }\n      }\n#endif\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        int j;\n        for(j=0; j<pIdx->nColumn; j++){\n          if( pIdx->aiColumn[j]==iCol ){\n            zFault = \"indexed\";\n          }\n        }\n      }\n      if( zFault ){\n        sqlite3DbFree(db, zErr);\n        zErr = sqlite3MPrintf(db, \"cannot open %s column for writing\", zFault);\n        rc = SQLITE_ERROR;\n        sqlite3BtreeLeaveAll(db);\n        goto blob_open_out;\n      }\n    }\n\n    pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(db);\n    assert( pBlob->pStmt || db->mallocFailed );\n    if( pBlob->pStmt ){\n      Vdbe *v = (Vdbe *)pBlob->pStmt;\n      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n      sqlite3VdbeAddOpList(v, sizeof(openBlob)/sizeof(VdbeOpList), openBlob);\n\n\n      /* Configure the OP_Transaction */\n      sqlite3VdbeChangeP1(v, 0, iDb);\n      sqlite3VdbeChangeP2(v, 0, flags);\n\n      /* Configure the OP_VerifyCookie */\n      sqlite3VdbeChangeP1(v, 1, iDb);\n      sqlite3VdbeChangeP2(v, 1, pTab->pSchema->schema_cookie);\n      sqlite3VdbeChangeP3(v, 1, pTab->pSchema->iGeneration);\n\n      /* Make sure a mutex is held on the table to be accessed */\n      sqlite3VdbeUsesBtree(v, iDb); \n\n      /* Configure the OP_TableLock instruction */\n#ifdef SQLITE_OMIT_SHARED_CACHE\n      sqlite3VdbeChangeToNoop(v, 2);\n#else\n      sqlite3VdbeChangeP1(v, 2, iDb);\n      sqlite3VdbeChangeP2(v, 2, pTab->tnum);\n      sqlite3VdbeChangeP3(v, 2, flags);\n      sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);\n#endif\n\n      /* Remove either the OP_OpenWrite or OpenRead. Set the P2 \n      ** parameter of the other to pTab->tnum.  */\n      sqlite3VdbeChangeToNoop(v, 4 - flags);\n      sqlite3VdbeChangeP2(v, 3 + flags, pTab->tnum);\n      sqlite3VdbeChangeP3(v, 3 + flags, iDb);\n\n      /* Configure the number of columns. Configure the cursor to\n      ** think that the table has one more column than it really\n      ** does. An OP_Column to retrieve this imaginary column will\n      ** always return an SQL NULL. This is useful because it means\n      ** we can invoke OP_Column to fill in the vdbe cursors type \n      ** and offset cache without causing any IO.\n      */\n      sqlite3VdbeChangeP4(v, 3+flags, SQLITE_INT_TO_PTR(pTab->nCol+1),P4_INT32);\n      sqlite3VdbeChangeP2(v, 7, pTab->nCol);\n      if( !db->mallocFailed ){\n        pParse->nVar = 1;\n        pParse->nMem = 1;\n        pParse->nTab = 1;\n        sqlite3VdbeMakeReady(v, pParse);\n      }\n    }\n   \n    pBlob->flags = flags;\n    pBlob->iCol = iCol;\n    pBlob->db = db;\n    sqlite3BtreeLeaveAll(db);\n    if( db->mallocFailed ){\n      goto blob_open_out;\n    }\n    sqlite3_bind_int64(pBlob->pStmt, 1, iRow);\n    rc = blobSeekToRow(pBlob, iRow, &zErr);\n  } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );\n\nblob_open_out:\n  if( rc==SQLITE_OK && db->mallocFailed==0 ){\n    *ppBlob = (sqlite3_blob *)pBlob;\n  }else{\n    if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);\n    sqlite3DbFree(db, pBlob);\n  }\n  sqlite3Error(db, rc, (zErr ? \"%s\" : 0), zErr);\n  sqlite3DbFree(db, zErr);\n  sqlite3StackFree(db, pParse);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Close a blob handle that was previously created using\n** sqlite3_blob_open().\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  int rc;\n  sqlite3 *db;\n\n  if( p ){\n    db = p->db;\n    sqlite3_mutex_enter(db->mutex);\n    rc = sqlite3_finalize(p->pStmt);\n    sqlite3DbFree(db, p);\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Perform a read or write operation on a blob\n*/\nstatic int blobReadWrite(\n  sqlite3_blob *pBlob, \n  void *z, \n  int n, \n  int iOffset, \n  int (*xCall)(BtCursor*, u32, u32, void*)\n){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  Vdbe *v;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n  v = (Vdbe*)p->pStmt;\n\n  if( n<0 || iOffset<0 || (iOffset+n)>p->nByte ){\n    /* Request is out of range. Return a transient error. */\n    rc = SQLITE_ERROR;\n    sqlite3Error(db, SQLITE_ERROR, 0);\n  }else if( v==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is\n    ** returned, clean-up the statement handle.\n    */\n    assert( db == v->db );\n    sqlite3BtreeEnterCursor(p->pCsr);\n    rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);\n    sqlite3BtreeLeaveCursor(p->pCsr);\n    if( rc==SQLITE_ABORT ){\n      sqlite3VdbeFinalize(v);\n      p->pStmt = 0;\n    }else{\n      db->errCode = rc;\n      v->rc = rc;\n    }\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Read data from a blob handle.\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);\n}\n\n/*\n** Write data to a blob handle.\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);\n}\n\n/*\n** Query a blob handle for the size of the data.\n**\n** The Incrblob.nByte field is fixed for the lifetime of the Incrblob\n** so no mutex is required for access.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  return (p && p->pStmt) ? p->nByte : 0;\n}\n\n/*\n** Move an existing blob handle to point to a different row of the same\n** database table.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a blob or text value, then an error code is returned and the\n** database handle error code and message set. If this happens, then all \n** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) \n** immediately return SQLITE_ABORT.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n\n  if( p->pStmt==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    char *zErr;\n    rc = blobSeekToRow(p, iRow, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3Error(db, rc, (zErr ? \"%s\" : 0), zErr);\n      sqlite3DbFree(db, zErr);\n    }\n    assert( rc!=SQLITE_SCHEMA );\n  }\n\n  rc = sqlite3ApiExit(db, rc);\n  assert( rc==SQLITE_OK || p->pStmt==0 );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* #ifndef SQLITE_OMIT_INCRBLOB */\n\n/************** End of vdbeblob.c ********************************************/\n/************** Begin file vdbesort.c ****************************************/\n/*\n** 2011 July 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for the VdbeSorter object, used in concert with\n** a VdbeCursor to sort large numbers of keys (as may be required, for\n** example, by CREATE INDEX statements on tables too large to fit in main\n** memory).\n*/\n\n\n\ntypedef struct VdbeSorterIter VdbeSorterIter;\ntypedef struct SorterRecord SorterRecord;\ntypedef struct FileWriter FileWriter;\n\n/*\n** NOTES ON DATA STRUCTURE USED FOR N-WAY MERGES:\n**\n** As keys are added to the sorter, they are written to disk in a series\n** of sorted packed-memory-arrays (PMAs). The size of each PMA is roughly\n** the same as the cache-size allowed for temporary databases. In order\n** to allow the caller to extract keys from the sorter in sorted order,\n** all PMAs currently stored on disk must be merged together. This comment\n** describes the data structure used to do so. The structure supports \n** merging any number of arrays in a single pass with no redundant comparison \n** operations.\n**\n** The aIter[] array contains an iterator for each of the PMAs being merged.\n** An aIter[] iterator either points to a valid key or else is at EOF. For \n** the purposes of the paragraphs below, we assume that the array is actually \n** N elements in size, where N is the smallest power of 2 greater to or equal \n** to the number of iterators being merged. The extra aIter[] elements are \n** treated as if they are empty (always at EOF).\n**\n** The aTree[] array is also N elements in size. The value of N is stored in\n** the VdbeSorter.nTree variable.\n**\n** The final (N/2) elements of aTree[] contain the results of comparing\n** pairs of iterator keys together. Element i contains the result of \n** comparing aIter[2*i-N] and aIter[2*i-N+1]. Whichever key is smaller, the\n** aTree element is set to the index of it. \n**\n** For the purposes of this comparison, EOF is considered greater than any\n** other key value. If the keys are equal (only possible with two EOF\n** values), it doesn't matter which index is stored.\n**\n** The (N/4) elements of aTree[] that preceed the final (N/2) described \n** above contains the index of the smallest of each block of 4 iterators.\n** And so on. So that aTree[1] contains the index of the iterator that \n** currently points to the smallest key value. aTree[0] is unused.\n**\n** Example:\n**\n**     aIter[0] -> Banana\n**     aIter[1] -> Feijoa\n**     aIter[2] -> Elderberry\n**     aIter[3] -> Currant\n**     aIter[4] -> Grapefruit\n**     aIter[5] -> Apple\n**     aIter[6] -> Durian\n**     aIter[7] -> EOF\n**\n**     aTree[] = { X, 5   0, 5    0, 3, 5, 6 }\n**\n** The current element is \"Apple\" (the value of the key indicated by \n** iterator 5). When the Next() operation is invoked, iterator 5 will\n** be advanced to the next key in its segment. Say the next key is\n** \"Eggplant\":\n**\n**     aIter[5] -> Eggplant\n**\n** The contents of aTree[] are updated first by comparing the new iterator\n** 5 key to the current key of iterator 4 (still \"Grapefruit\"). The iterator\n** 5 value is still smaller, so aTree[6] is set to 5. And so on up the tree.\n** The value of iterator 6 - \"Durian\" - is now smaller than that of iterator\n** 5, so aTree[3] is set to 6. Key 0 is smaller than key 6 (Banana<Durian),\n** so the value written into element 1 of the array is 0. As follows:\n**\n**     aTree[] = { X, 0   0, 6    0, 3, 5, 6 }\n**\n** In other words, each time we advance to the next sorter element, log2(N)\n** key comparison operations are required, where N is the number of segments\n** being merged (rounded up to the next power of 2).\n*/\nstruct VdbeSorter {\n  i64 iWriteOff;                  /* Current write offset within file pTemp1 */\n  i64 iReadOff;                   /* Current read offset within file pTemp1 */\n  int nInMemory;                  /* Current size of pRecord list as PMA */\n  int nTree;                      /* Used size of aTree/aIter (power of 2) */\n  int nPMA;                       /* Number of PMAs stored in pTemp1 */\n  int mnPmaSize;                  /* Minimum PMA size, in bytes */\n  int mxPmaSize;                  /* Maximum PMA size, in bytes.  0==no limit */\n  VdbeSorterIter *aIter;          /* Array of iterators to merge */\n  int *aTree;                     /* Current state of incremental merge */\n  sqlite3_file *pTemp1;           /* PMA file 1 */\n  SorterRecord *pRecord;          /* Head of in-memory record list */\n  UnpackedRecord *pUnpacked;      /* Used to unpack keys */\n};\n\n/*\n** The following type is an iterator for a PMA. It caches the current key in \n** variables nKey/aKey. If the iterator is at EOF, pFile==0.\n*/\nstruct VdbeSorterIter {\n  i64 iReadOff;                   /* Current read offset */\n  i64 iEof;                       /* 1 byte past EOF for this iterator */\n  int nAlloc;                     /* Bytes of space at aAlloc */\n  int nKey;                       /* Number of bytes in key */\n  sqlite3_file *pFile;            /* File iterator is reading from */\n  u8 *aAlloc;                     /* Allocated space */\n  u8 *aKey;                       /* Pointer to current key */\n  u8 *aBuffer;                    /* Current read buffer */\n  int nBuffer;                    /* Size of read buffer in bytes */\n};\n\n/*\n** An instance of this structure is used to organize the stream of records\n** being written to files by the merge-sort code into aligned, page-sized\n** blocks.  Doing all I/O in aligned page-sized blocks helps I/O to go\n** faster on many operating systems.\n*/\nstruct FileWriter {\n  int eFWErr;                     /* Non-zero if in an error state */\n  u8 *aBuffer;                    /* Pointer to write buffer */\n  int nBuffer;                    /* Size of write buffer in bytes */\n  int iBufStart;                  /* First byte of buffer to write */\n  int iBufEnd;                    /* Last byte of buffer to write */\n  i64 iWriteOff;                  /* Offset of start of buffer in file */\n  sqlite3_file *pFile;            /* File to write to */\n};\n\n/*\n** A structure to store a single record. All in-memory records are connected\n** together into a linked list headed at VdbeSorter.pRecord using the \n** SorterRecord.pNext pointer.\n*/\nstruct SorterRecord {\n  void *pVal;\n  int nVal;\n  SorterRecord *pNext;\n};\n\n/* Minimum allowable value for the VdbeSorter.nWorking variable */\n#define SORTER_MIN_WORKING 10\n\n/* Maximum number of segments to merge in a single pass. */\n#define SORTER_MAX_MERGE_COUNT 16\n\n/*\n** Free all memory belonging to the VdbeSorterIter object passed as the second\n** argument. All structure fields are set to zero before returning.\n*/\nstatic void vdbeSorterIterZero(sqlite3 *db, VdbeSorterIter *pIter){\n  sqlite3DbFree(db, pIter->aAlloc);\n  sqlite3DbFree(db, pIter->aBuffer);\n  memset(pIter, 0, sizeof(VdbeSorterIter));\n}\n\n/*\n** Read nByte bytes of data from the stream of data iterated by object p.\n** If successful, set *ppOut to point to a buffer containing the data\n** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite\n** error code.\n**\n** The buffer indicated by *ppOut may only be considered valid until the\n** next call to this function.\n*/\nstatic int vdbeSorterIterRead(\n  sqlite3 *db,                    /* Database handle (for malloc) */\n  VdbeSorterIter *p,              /* Iterator */\n  int nByte,                      /* Bytes of data to read */\n  u8 **ppOut                      /* OUT: Pointer to buffer containing data */\n){\n  int iBuf;                       /* Offset within buffer to read from */\n  int nAvail;                     /* Bytes of data available in buffer */\n  assert( p->aBuffer );\n\n  /* If there is no more data to be read from the buffer, read the next \n  ** p->nBuffer bytes of data from the file into it. Or, if there are less\n  ** than p->nBuffer bytes remaining in the PMA, read all remaining data.  */\n  iBuf = p->iReadOff % p->nBuffer;\n  if( iBuf==0 ){\n    int nRead;                    /* Bytes to read from disk */\n    int rc;                       /* sqlite3OsRead() return code */\n\n    /* Determine how many bytes of data to read. */\n    if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){\n      nRead = p->nBuffer;\n    }else{\n      nRead = (int)(p->iEof - p->iReadOff);\n    }\n    assert( nRead>0 );\n\n    /* Read data from the file. Return early if an error occurs. */\n    rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff);\n    assert( rc!=SQLITE_IOERR_SHORT_READ );\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nAvail = p->nBuffer - iBuf; \n\n  if( nByte<=nAvail ){\n    /* The requested data is available in the in-memory buffer. In this\n    ** case there is no need to make a copy of the data, just return a \n    ** pointer into the buffer to the caller.  */\n    *ppOut = &p->aBuffer[iBuf];\n    p->iReadOff += nByte;\n  }else{\n    /* The requested data is not all available in the in-memory buffer.\n    ** In this case, allocate space at p->aAlloc[] to copy the requested\n    ** range into. Then return a copy of pointer p->aAlloc to the caller.  */\n    int nRem;                     /* Bytes remaining to copy */\n\n    /* Extend the p->aAlloc[] allocation if required. */\n    if( p->nAlloc<nByte ){\n      int nNew = p->nAlloc*2;\n      while( nByte>nNew ) nNew = nNew*2;\n      p->aAlloc = sqlite3DbReallocOrFree(db, p->aAlloc, nNew);\n      if( !p->aAlloc ) return SQLITE_NOMEM;\n      p->nAlloc = nNew;\n    }\n\n    /* Copy as much data as is available in the buffer into the start of\n    ** p->aAlloc[].  */\n    memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail);\n    p->iReadOff += nAvail;\n    nRem = nByte - nAvail;\n\n    /* The following loop copies up to p->nBuffer bytes per iteration into\n    ** the p->aAlloc[] buffer.  */\n    while( nRem>0 ){\n      int rc;                     /* vdbeSorterIterRead() return code */\n      int nCopy;                  /* Number of bytes to copy */\n      u8 *aNext;                  /* Pointer to buffer to copy data from */\n\n      nCopy = nRem;\n      if( nRem>p->nBuffer ) nCopy = p->nBuffer;\n      rc = vdbeSorterIterRead(db, p, nCopy, &aNext);\n      if( rc!=SQLITE_OK ) return rc;\n      assert( aNext!=p->aAlloc );\n      memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);\n      nRem -= nCopy;\n    }\n\n    *ppOut = p->aAlloc;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Read a varint from the stream of data accessed by p. Set *pnOut to\n** the value read.\n*/\nstatic int vdbeSorterIterVarint(sqlite3 *db, VdbeSorterIter *p, u64 *pnOut){\n  int iBuf;\n\n  iBuf = p->iReadOff % p->nBuffer;\n  if( iBuf && (p->nBuffer-iBuf)>=9 ){\n    p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut);\n  }else{\n    u8 aVarint[16], *a;\n    int i = 0, rc;\n    do{\n      rc = vdbeSorterIterRead(db, p, 1, &a);\n      if( rc ) return rc;\n      aVarint[(i++)&0xf] = a[0];\n    }while( (a[0]&0x80)!=0 );\n    sqlite3GetVarint(aVarint, pnOut);\n  }\n\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance iterator pIter to the next key in its PMA. Return SQLITE_OK if\n** no error occurs, or an SQLite error code if one does.\n*/\nstatic int vdbeSorterIterNext(\n  sqlite3 *db,                    /* Database handle (for sqlite3DbMalloc() ) */\n  VdbeSorterIter *pIter           /* Iterator to advance */\n){\n  int rc;                         /* Return Code */\n  u64 nRec = 0;                   /* Size of record in bytes */\n\n  if( pIter->iReadOff>=pIter->iEof ){\n    /* This is an EOF condition */\n    vdbeSorterIterZero(db, pIter);\n    return SQLITE_OK;\n  }\n\n  rc = vdbeSorterIterVarint(db, pIter, &nRec);\n  if( rc==SQLITE_OK ){\n    pIter->nKey = (int)nRec;\n    rc = vdbeSorterIterRead(db, pIter, (int)nRec, &pIter->aKey);\n  }\n\n  return rc;\n}\n\n/*\n** Initialize iterator pIter to scan through the PMA stored in file pFile\n** starting at offset iStart and ending at offset iEof-1. This function \n** leaves the iterator pointing to the first key in the PMA (or EOF if the \n** PMA is empty).\n*/\nstatic int vdbeSorterIterInit(\n  sqlite3 *db,                    /* Database handle */\n  const VdbeSorter *pSorter,      /* Sorter object */\n  i64 iStart,                     /* Start offset in pFile */\n  VdbeSorterIter *pIter,          /* Iterator to populate */\n  i64 *pnByte                     /* IN/OUT: Increment this value by PMA size */\n){\n  int rc = SQLITE_OK;\n  int nBuf;\n\n  nBuf = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n\n  assert( pSorter->iWriteOff>iStart );\n  assert( pIter->aAlloc==0 );\n  assert( pIter->aBuffer==0 );\n  pIter->pFile = pSorter->pTemp1;\n  pIter->iReadOff = iStart;\n  pIter->nAlloc = 128;\n  pIter->aAlloc = (u8 *)sqlite3DbMallocRaw(db, pIter->nAlloc);\n  pIter->nBuffer = nBuf;\n  pIter->aBuffer = (u8 *)sqlite3DbMallocRaw(db, nBuf);\n\n  if( !pIter->aBuffer ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int iBuf;\n\n    iBuf = iStart % nBuf;\n    if( iBuf ){\n      int nRead = nBuf - iBuf;\n      if( (iStart + nRead) > pSorter->iWriteOff ){\n        nRead = (int)(pSorter->iWriteOff - iStart);\n      }\n      rc = sqlite3OsRead(\n          pSorter->pTemp1, &pIter->aBuffer[iBuf], nRead, iStart\n      );\n      assert( rc!=SQLITE_IOERR_SHORT_READ );\n    }\n\n    if( rc==SQLITE_OK ){\n      u64 nByte;                       /* Size of PMA in bytes */\n      pIter->iEof = pSorter->iWriteOff;\n      rc = vdbeSorterIterVarint(db, pIter, &nByte);\n      pIter->iEof = pIter->iReadOff + nByte;\n      *pnByte += nByte;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterIterNext(db, pIter);\n  }\n  return rc;\n}\n\n\n/*\n** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2, \n** size nKey2 bytes).  Argument pKeyInfo supplies the collation functions\n** used by the comparison. If an error occurs, return an SQLite error code.\n** Otherwise, return SQLITE_OK and set *pRes to a negative, zero or positive\n** value, depending on whether key1 is smaller, equal to or larger than key2.\n**\n** If the bOmitRowid argument is non-zero, assume both keys end in a rowid\n** field. For the purposes of the comparison, ignore it. Also, if bOmitRowid\n** is true and key1 contains even a single NULL value, it is considered to\n** be less than key2. Even if key2 also contains NULL values.\n**\n** If pKey2 is passed a NULL pointer, then it is assumed that the pCsr->aSpace\n** has been allocated and contains an unpacked record that is used as key2.\n*/\nstatic void vdbeSorterCompare(\n  const VdbeCursor *pCsr,         /* Cursor object (for pKeyInfo) */\n  int bOmitRowid,                 /* Ignore rowid field at end of keys */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2,   /* Right side of comparison */\n  int *pRes                       /* OUT: Result of comparison */\n){\n  KeyInfo *pKeyInfo = pCsr->pKeyInfo;\n  VdbeSorter *pSorter = pCsr->pSorter;\n  UnpackedRecord *r2 = pSorter->pUnpacked;\n  int i;\n\n  if( pKey2 ){\n    sqlite3VdbeRecordUnpack(pKeyInfo, nKey2, pKey2, r2);\n  }\n\n  if( bOmitRowid ){\n    r2->nField = pKeyInfo->nField;\n    assert( r2->nField>0 );\n    for(i=0; i<r2->nField; i++){\n      if( r2->aMem[i].flags & MEM_Null ){\n        *pRes = -1;\n        return;\n      }\n    }\n    r2->flags |= UNPACKED_PREFIX_MATCH;\n  }\n\n  *pRes = sqlite3VdbeRecordCompare(nKey1, pKey1, r2);\n}\n\n/*\n** This function is called to compare two iterator keys when merging \n** multiple b-tree segments. Parameter iOut is the index of the aTree[] \n** value to recalculate.\n*/\nstatic int vdbeSorterDoCompare(const VdbeCursor *pCsr, int iOut){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  int i1;\n  int i2;\n  int iRes;\n  VdbeSorterIter *p1;\n  VdbeSorterIter *p2;\n\n  assert( iOut<pSorter->nTree && iOut>0 );\n\n  if( iOut>=(pSorter->nTree/2) ){\n    i1 = (iOut - pSorter->nTree/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pSorter->aTree[iOut*2];\n    i2 = pSorter->aTree[iOut*2+1];\n  }\n\n  p1 = &pSorter->aIter[i1];\n  p2 = &pSorter->aIter[i2];\n\n  if( p1->pFile==0 ){\n    iRes = i2;\n  }else if( p2->pFile==0 ){\n    iRes = i1;\n  }else{\n    int res;\n    assert( pCsr->pSorter->pUnpacked!=0 );  /* allocated in vdbeSorterMerge() */\n    vdbeSorterCompare(\n        pCsr, 0, p1->aKey, p1->nKey, p2->aKey, p2->nKey, &res\n    );\n    if( res<=0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pSorter->aTree[iOut] = iRes;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the temporary index cursor just opened as a sorter cursor.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *db, VdbeCursor *pCsr){\n  int pgsz;                       /* Page size of main database */\n  int mxCache;                    /* Cache size */\n  VdbeSorter *pSorter;            /* The new sorter */\n  char *d;                        /* Dummy */\n\n  assert( pCsr->pKeyInfo && pCsr->pBt==0 );\n  pCsr->pSorter = pSorter = sqlite3DbMallocZero(db, sizeof(VdbeSorter));\n  if( pSorter==0 ){\n    return SQLITE_NOMEM;\n  }\n  \n  pSorter->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pCsr->pKeyInfo, 0, 0, &d);\n  if( pSorter->pUnpacked==0 ) return SQLITE_NOMEM;\n  assert( pSorter->pUnpacked==(UnpackedRecord *)d );\n\n  if( !sqlite3TempInMemory(db) ){\n    pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n    pSorter->mnPmaSize = SORTER_MIN_WORKING * pgsz;\n    mxCache = db->aDb[0].pSchema->cache_size;\n    if( mxCache<SORTER_MIN_WORKING ) mxCache = SORTER_MIN_WORKING;\n    pSorter->mxPmaSize = mxCache * pgsz;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of sorted records starting at pRecord.\n*/\nstatic void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){\n  SorterRecord *p;\n  SorterRecord *pNext;\n  for(p=pRecord; p; p=pNext){\n    pNext = p->pNext;\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Free any cursor components allocated by sqlite3VdbeSorterXXX routines.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  if( pSorter ){\n    if( pSorter->aIter ){\n      int i;\n      for(i=0; i<pSorter->nTree; i++){\n        vdbeSorterIterZero(db, &pSorter->aIter[i]);\n      }\n      sqlite3DbFree(db, pSorter->aIter);\n    }\n    if( pSorter->pTemp1 ){\n      sqlite3OsCloseFree(pSorter->pTemp1);\n    }\n    vdbeSorterRecordFree(db, pSorter->pRecord);\n    sqlite3DbFree(db, pSorter->pUnpacked);\n    sqlite3DbFree(db, pSorter);\n    pCsr->pSorter = 0;\n  }\n}\n\n/*\n** Allocate space for a file-handle and open a temporary file. If successful,\n** set *ppFile to point to the malloc'd file-handle and return SQLITE_OK.\n** Otherwise, set *ppFile to 0 and return an SQLite error code.\n*/\nstatic int vdbeSorterOpenTempFile(sqlite3 *db, sqlite3_file **ppFile){\n  int dummy;\n  return sqlite3OsOpenMalloc(db->pVfs, 0, ppFile,\n      SQLITE_OPEN_TEMP_JOURNAL |\n      SQLITE_OPEN_READWRITE    | SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE    | SQLITE_OPEN_DELETEONCLOSE, &dummy\n  );\n}\n\n/*\n** Merge the two sorted lists p1 and p2 into a single list.\n** Set *ppOut to the head of the new list.\n*/\nstatic void vdbeSorterMerge(\n  const VdbeCursor *pCsr,         /* For pKeyInfo */\n  SorterRecord *p1,               /* First list to merge */\n  SorterRecord *p2,               /* Second list to merge */\n  SorterRecord **ppOut            /* OUT: Head of merged list */\n){\n  SorterRecord *pFinal = 0;\n  SorterRecord **pp = &pFinal;\n  void *pVal2 = p2 ? p2->pVal : 0;\n\n  while( p1 && p2 ){\n    int res;\n    vdbeSorterCompare(pCsr, 0, p1->pVal, p1->nVal, pVal2, p2->nVal, &res);\n    if( res<=0 ){\n      *pp = p1;\n      pp = &p1->pNext;\n      p1 = p1->pNext;\n      pVal2 = 0;\n    }else{\n      *pp = p2;\n       pp = &p2->pNext;\n      p2 = p2->pNext;\n      if( p2==0 ) break;\n      pVal2 = p2->pVal;\n    }\n  }\n  *pp = p1 ? p1 : p2;\n  *ppOut = pFinal;\n}\n\n/*\n** Sort the linked list of records headed at pCsr->pRecord. Return SQLITE_OK\n** if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if an error\n** occurs.\n*/\nstatic int vdbeSorterSort(const VdbeCursor *pCsr){\n  int i;\n  SorterRecord **aSlot;\n  SorterRecord *p;\n  VdbeSorter *pSorter = pCsr->pSorter;\n\n  aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));\n  if( !aSlot ){\n    return SQLITE_NOMEM;\n  }\n\n  p = pSorter->pRecord;\n  while( p ){\n    SorterRecord *pNext = p->pNext;\n    p->pNext = 0;\n    for(i=0; aSlot[i]; i++){\n      vdbeSorterMerge(pCsr, p, aSlot[i], &p);\n      aSlot[i] = 0;\n    }\n    aSlot[i] = p;\n    p = pNext;\n  }\n\n  p = 0;\n  for(i=0; i<64; i++){\n    vdbeSorterMerge(pCsr, p, aSlot[i], &p);\n  }\n  pSorter->pRecord = p;\n\n  sqlite3_free(aSlot);\n  return SQLITE_OK;\n}\n\n/*\n** Initialize a file-writer object.\n*/\nstatic void fileWriterInit(\n  sqlite3 *db,                    /* Database (for malloc) */\n  sqlite3_file *pFile,            /* File to write to */\n  FileWriter *p,                  /* Object to populate */\n  i64 iStart                      /* Offset of pFile to begin writing at */\n){\n  int nBuf = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n\n  memset(p, 0, sizeof(FileWriter));\n  p->aBuffer = (u8 *)sqlite3DbMallocRaw(db, nBuf);\n  if( !p->aBuffer ){\n    p->eFWErr = SQLITE_NOMEM;\n  }else{\n    p->iBufEnd = p->iBufStart = (iStart % nBuf);\n    p->iWriteOff = iStart - p->iBufStart;\n    p->nBuffer = nBuf;\n    p->pFile = pFile;\n  }\n}\n\n/*\n** Write nData bytes of data to the file-write object. Return SQLITE_OK\n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic void fileWriterWrite(FileWriter *p, u8 *pData, int nData){\n  int nRem = nData;\n  while( nRem>0 && p->eFWErr==0 ){\n    int nCopy = nRem;\n    if( nCopy>(p->nBuffer - p->iBufEnd) ){\n      nCopy = p->nBuffer - p->iBufEnd;\n    }\n\n    memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy);\n    p->iBufEnd += nCopy;\n    if( p->iBufEnd==p->nBuffer ){\n      p->eFWErr = sqlite3OsWrite(p->pFile, \n          &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n          p->iWriteOff + p->iBufStart\n      );\n      p->iBufStart = p->iBufEnd = 0;\n      p->iWriteOff += p->nBuffer;\n    }\n    assert( p->iBufEnd<p->nBuffer );\n\n    nRem -= nCopy;\n  }\n}\n\n/*\n** Flush any buffered data to disk and clean up the file-writer object.\n** The results of using the file-writer after this call are undefined.\n** Return SQLITE_OK if flushing the buffered data succeeds or is not \n** required. Otherwise, return an SQLite error code.\n**\n** Before returning, set *piEof to the offset immediately following the\n** last byte written to the file.\n*/\nstatic int fileWriterFinish(sqlite3 *db, FileWriter *p, i64 *piEof){\n  int rc;\n  if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){\n    p->eFWErr = sqlite3OsWrite(p->pFile, \n        &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n        p->iWriteOff + p->iBufStart\n    );\n  }\n  *piEof = (p->iWriteOff + p->iBufEnd);\n  sqlite3DbFree(db, p->aBuffer);\n  rc = p->eFWErr;\n  memset(p, 0, sizeof(FileWriter));\n  return rc;\n}\n\n/*\n** Write value iVal encoded as a varint to the file-write object. Return \n** SQLITE_OK if successful, or an SQLite error code if an error occurs.\n*/\nstatic void fileWriterWriteVarint(FileWriter *p, u64 iVal){\n  int nByte; \n  u8 aByte[10];\n  nByte = sqlite3PutVarint(aByte, iVal);\n  fileWriterWrite(p, aByte, nByte);\n}\n\n/*\n** Write the current contents of the in-memory linked-list to a PMA. Return\n** SQLITE_OK if successful, or an SQLite error code otherwise.\n**\n** The format of a PMA is:\n**\n**     * A varint. This varint contains the total number of bytes of content\n**       in the PMA (not including the varint itself).\n**\n**     * One or more records packed end-to-end in order of ascending keys. \n**       Each record consists of a varint followed by a blob of data (the \n**       key). The varint is the number of bytes in the blob of data.\n*/\nstatic int vdbeSorterListToPMA(sqlite3 *db, const VdbeCursor *pCsr){\n  int rc = SQLITE_OK;             /* Return code */\n  VdbeSorter *pSorter = pCsr->pSorter;\n  FileWriter writer;\n\n  memset(&writer, 0, sizeof(FileWriter));\n\n  if( pSorter->nInMemory==0 ){\n    assert( pSorter->pRecord==0 );\n    return rc;\n  }\n\n  rc = vdbeSorterSort(pCsr);\n\n  /* If the first temporary PMA file has not been opened, open it now. */\n  if( rc==SQLITE_OK && pSorter->pTemp1==0 ){\n    rc = vdbeSorterOpenTempFile(db, &pSorter->pTemp1);\n    assert( rc!=SQLITE_OK || pSorter->pTemp1 );\n    assert( pSorter->iWriteOff==0 );\n    assert( pSorter->nPMA==0 );\n  }\n\n  if( rc==SQLITE_OK ){\n    SorterRecord *p;\n    SorterRecord *pNext = 0;\n\n    fileWriterInit(db, pSorter->pTemp1, &writer, pSorter->iWriteOff);\n    pSorter->nPMA++;\n    fileWriterWriteVarint(&writer, pSorter->nInMemory);\n    for(p=pSorter->pRecord; p; p=pNext){\n      pNext = p->pNext;\n      fileWriterWriteVarint(&writer, p->nVal);\n      fileWriterWrite(&writer, p->pVal, p->nVal);\n      sqlite3DbFree(db, p);\n    }\n    pSorter->pRecord = p;\n    rc = fileWriterFinish(db, &writer, &pSorter->iWriteOff);\n  }\n\n  return rc;\n}\n\n/*\n** Add a record to the sorter.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(\n  sqlite3 *db,                    /* Database handle */\n  const VdbeCursor *pCsr,               /* Sorter cursor */\n  Mem *pVal                       /* Memory cell containing record */\n){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  int rc = SQLITE_OK;             /* Return Code */\n  SorterRecord *pNew;             /* New list element */\n\n  assert( pSorter );\n  pSorter->nInMemory += sqlite3VarintLen(pVal->n) + pVal->n;\n\n  pNew = (SorterRecord *)sqlite3DbMallocRaw(db, pVal->n + sizeof(SorterRecord));\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    pNew->pVal = (void *)&pNew[1];\n    memcpy(pNew->pVal, pVal->z, pVal->n);\n    pNew->nVal = pVal->n;\n    pNew->pNext = pSorter->pRecord;\n    pSorter->pRecord = pNew;\n  }\n\n  /* See if the contents of the sorter should now be written out. They\n  ** are written out when either of the following are true:\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * cache-size), or\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * 10) and sqlite3HeapNearlyFull() returns true.\n  */\n  if( rc==SQLITE_OK && pSorter->mxPmaSize>0 && (\n        (pSorter->nInMemory>pSorter->mxPmaSize)\n     || (pSorter->nInMemory>pSorter->mnPmaSize && sqlite3HeapNearlyFull())\n  )){\n#ifdef SQLITE_DEBUG\n    i64 nExpect = pSorter->iWriteOff\n                + sqlite3VarintLen(pSorter->nInMemory)\n                + pSorter->nInMemory;\n#endif\n    rc = vdbeSorterListToPMA(db, pCsr);\n    pSorter->nInMemory = 0;\n    assert( rc!=SQLITE_OK || (nExpect==pSorter->iWriteOff) );\n  }\n\n  return rc;\n}\n\n/*\n** Helper function for sqlite3VdbeSorterRewind(). \n*/\nstatic int vdbeSorterInitMerge(\n  sqlite3 *db,                    /* Database handle */\n  const VdbeCursor *pCsr,         /* Cursor handle for this sorter */\n  i64 *pnByte                     /* Sum of bytes in all opened PMAs */\n){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Used to iterator through aIter[] */\n  i64 nByte = 0;                  /* Total bytes in all opened PMAs */\n\n  /* Initialize the iterators. */\n  for(i=0; i<SORTER_MAX_MERGE_COUNT; i++){\n    VdbeSorterIter *pIter = &pSorter->aIter[i];\n    rc = vdbeSorterIterInit(db, pSorter, pSorter->iReadOff, pIter, &nByte);\n    pSorter->iReadOff = pIter->iEof;\n    assert( rc!=SQLITE_OK || pSorter->iReadOff<=pSorter->iWriteOff );\n    if( rc!=SQLITE_OK || pSorter->iReadOff>=pSorter->iWriteOff ) break;\n  }\n\n  /* Initialize the aTree[] array. */\n  for(i=pSorter->nTree-1; rc==SQLITE_OK && i>0; i--){\n    rc = vdbeSorterDoCompare(pCsr, i);\n  }\n\n  *pnByte = nByte;\n  return rc;\n}\n\n/*\n** Once the sorter has been populated, this function is called to prepare\n** for iterating through its contents in sorted order.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  int rc;                         /* Return code */\n  sqlite3_file *pTemp2 = 0;       /* Second temp file to use */\n  i64 iWrite2 = 0;                /* Write offset for pTemp2 */\n  int nIter;                      /* Number of iterators used */\n  int nByte;                      /* Bytes of space required for aIter/aTree */\n  int N = 2;                      /* Power of 2 >= nIter */\n\n  assert( pSorter );\n\n  /* If no data has been written to disk, then do not do so now. Instead,\n  ** sort the VdbeSorter.pRecord list. The vdbe layer will read data directly\n  ** from the in-memory list.  */\n  if( pSorter->nPMA==0 ){\n    *pbEof = !pSorter->pRecord;\n    assert( pSorter->aTree==0 );\n    return vdbeSorterSort(pCsr);\n  }\n\n  /* Write the current in-memory list to a PMA. */\n  rc = vdbeSorterListToPMA(db, pCsr);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Allocate space for aIter[] and aTree[]. */\n  nIter = pSorter->nPMA;\n  if( nIter>SORTER_MAX_MERGE_COUNT ) nIter = SORTER_MAX_MERGE_COUNT;\n  assert( nIter>0 );\n  while( N<nIter ) N += N;\n  nByte = N * (sizeof(int) + sizeof(VdbeSorterIter));\n  pSorter->aIter = (VdbeSorterIter *)sqlite3DbMallocZero(db, nByte);\n  if( !pSorter->aIter ) return SQLITE_NOMEM;\n  pSorter->aTree = (int *)&pSorter->aIter[N];\n  pSorter->nTree = N;\n\n  do {\n    int iNew;                     /* Index of new, merged, PMA */\n\n    for(iNew=0; \n        rc==SQLITE_OK && iNew*SORTER_MAX_MERGE_COUNT<pSorter->nPMA; \n        iNew++\n    ){\n      int rc2;                    /* Return code from fileWriterFinish() */\n      FileWriter writer;          /* Object used to write to disk */\n      i64 nWrite;                 /* Number of bytes in new PMA */\n\n      memset(&writer, 0, sizeof(FileWriter));\n\n      /* If there are SORTER_MAX_MERGE_COUNT or less PMAs in file pTemp1,\n      ** initialize an iterator for each of them and break out of the loop.\n      ** These iterators will be incrementally merged as the VDBE layer calls\n      ** sqlite3VdbeSorterNext().\n      **\n      ** Otherwise, if pTemp1 contains more than SORTER_MAX_MERGE_COUNT PMAs,\n      ** initialize interators for SORTER_MAX_MERGE_COUNT of them. These PMAs\n      ** are merged into a single PMA that is written to file pTemp2.\n      */\n      rc = vdbeSorterInitMerge(db, pCsr, &nWrite);\n      assert( rc!=SQLITE_OK || pSorter->aIter[ pSorter->aTree[1] ].pFile );\n      if( rc!=SQLITE_OK || pSorter->nPMA<=SORTER_MAX_MERGE_COUNT ){\n        break;\n      }\n\n      /* Open the second temp file, if it is not already open. */\n      if( pTemp2==0 ){\n        assert( iWrite2==0 );\n        rc = vdbeSorterOpenTempFile(db, &pTemp2);\n      }\n\n      if( rc==SQLITE_OK ){\n        int bEof = 0;\n        fileWriterInit(db, pTemp2, &writer, iWrite2);\n        fileWriterWriteVarint(&writer, nWrite);\n        while( rc==SQLITE_OK && bEof==0 ){\n          VdbeSorterIter *pIter = &pSorter->aIter[ pSorter->aTree[1] ];\n          assert( pIter->pFile );\n\n          fileWriterWriteVarint(&writer, pIter->nKey);\n          fileWriterWrite(&writer, pIter->aKey, pIter->nKey);\n          rc = sqlite3VdbeSorterNext(db, pCsr, &bEof);\n        }\n        rc2 = fileWriterFinish(db, &writer, &iWrite2);\n        if( rc==SQLITE_OK ) rc = rc2;\n      }\n    }\n\n    if( pSorter->nPMA<=SORTER_MAX_MERGE_COUNT ){\n      break;\n    }else{\n      sqlite3_file *pTmp = pSorter->pTemp1;\n      pSorter->nPMA = iNew;\n      pSorter->pTemp1 = pTemp2;\n      pTemp2 = pTmp;\n      pSorter->iWriteOff = iWrite2;\n      pSorter->iReadOff = 0;\n      iWrite2 = 0;\n    }\n  }while( rc==SQLITE_OK );\n\n  if( pTemp2 ){\n    sqlite3OsCloseFree(pTemp2);\n  }\n  *pbEof = (pSorter->aIter[pSorter->aTree[1]].pFile==0);\n  return rc;\n}\n\n/*\n** Advance to the next element in the sorter.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  int rc;                         /* Return code */\n\n  if( pSorter->aTree ){\n    int iPrev = pSorter->aTree[1];/* Index of iterator to advance */\n    int i;                        /* Index of aTree[] to recalculate */\n\n    rc = vdbeSorterIterNext(db, &pSorter->aIter[iPrev]);\n    for(i=(pSorter->nTree+iPrev)/2; rc==SQLITE_OK && i>0; i=i/2){\n      rc = vdbeSorterDoCompare(pCsr, i);\n    }\n\n    *pbEof = (pSorter->aIter[pSorter->aTree[1]].pFile==0);\n  }else{\n    SorterRecord *pFree = pSorter->pRecord;\n    pSorter->pRecord = pFree->pNext;\n    pFree->pNext = 0;\n    vdbeSorterRecordFree(db, pFree);\n    *pbEof = !pSorter->pRecord;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to a buffer owned by the sorter that contains the \n** current key.\n*/\nstatic void *vdbeSorterRowkey(\n  const VdbeSorter *pSorter,      /* Sorter object */\n  int *pnKey                      /* OUT: Size of current key in bytes */\n){\n  void *pKey;\n  if( pSorter->aTree ){\n    VdbeSorterIter *pIter;\n    pIter = &pSorter->aIter[ pSorter->aTree[1] ];\n    *pnKey = pIter->nKey;\n    pKey = pIter->aKey;\n  }else{\n    *pnKey = pSorter->pRecord->nVal;\n    pKey = pSorter->pRecord->pVal;\n  }\n  return pKey;\n}\n\n/*\n** Copy the current sorter key into the memory cell pOut.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *pOut){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  void *pKey; int nKey;           /* Sorter key to copy into pOut */\n\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  if( sqlite3VdbeMemGrow(pOut, nKey, 0) ){\n    return SQLITE_NOMEM;\n  }\n  pOut->n = nKey;\n  MemSetTypeFlag(pOut, MEM_Blob);\n  memcpy(pOut->z, pKey, nKey);\n\n  return SQLITE_OK;\n}\n\n/*\n** Compare the key in memory cell pVal with the key that the sorter cursor\n** passed as the first argument currently points to. For the purposes of\n** the comparison, ignore the rowid field at the end of each record.\n**\n** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).\n** Otherwise, set *pRes to a negative, zero or positive value if the\n** key in pVal is smaller than, equal to or larger than the current sorter\n** key.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal,                      /* Value to compare to current sorter key */\n  int *pRes                       /* OUT: Result of comparison */\n){\n  VdbeSorter *pSorter = pCsr->pSorter;\n  void *pKey; int nKey;           /* Sorter key to compare pVal with */\n\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes);\n  return SQLITE_OK;\n}\n\n/************** End of vdbesort.c ********************************************/\n/************** Begin file journal.c *****************************************/\n/*\n** 2007 August 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a special kind of sqlite3_file object used\n** by SQLite to create journal files if the atomic-write optimization\n** is enabled.\n**\n** The distinctive characteristic of this sqlite3_file is that the\n** actual on disk file is created lazily. When the file is created,\n** the caller specifies a buffer size for an in-memory buffer to\n** be used to service read() and write() requests. The actual file\n** on disk is not created or populated until either:\n**\n**   1) The in-memory representation grows too large for the allocated \n**      buffer, or\n**   2) The sqlite3JournalCreate() function is called.\n*/\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n\n\n/*\n** A JournalFile object is a subclass of sqlite3_file used by\n** as an open file handle for journal files.\n*/\nstruct JournalFile {\n  sqlite3_io_methods *pMethod;    /* I/O methods on journal files */\n  int nBuf;                       /* Size of zBuf[] in bytes */\n  char *zBuf;                     /* Space to buffer journal writes */\n  int iSize;                      /* Amount of zBuf[] currently used */\n  int flags;                      /* xOpen flags */\n  sqlite3_vfs *pVfs;              /* The \"real\" underlying VFS */\n  sqlite3_file *pReal;            /* The \"real\" underlying file descriptor */\n  const char *zJournal;           /* Name of the journal file */\n};\ntypedef struct JournalFile JournalFile;\n\n/*\n** If it does not already exists, create and populate the on-disk file \n** for JournalFile p.\n*/\nstatic int createFile(JournalFile *p){\n  int rc = SQLITE_OK;\n  if( !p->pReal ){\n    sqlite3_file *pReal = (sqlite3_file *)&p[1];\n    rc = sqlite3OsOpen(p->pVfs, p->zJournal, pReal, p->flags, 0);\n    if( rc==SQLITE_OK ){\n      p->pReal = pReal;\n      if( p->iSize>0 ){\n        assert(p->iSize<=p->nBuf);\n        rc = sqlite3OsWrite(p->pReal, p->zBuf, p->iSize, 0);\n      }\n      if( rc!=SQLITE_OK ){\n        /* If an error occurred while writing to the file, close it before\n        ** returning. This way, SQLite uses the in-memory journal data to \n        ** roll back changes made to the internal page-cache before this\n        ** function was called.  */\n        sqlite3OsClose(pReal);\n        p->pReal = 0;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Close the file.\n*/\nstatic int jrnlClose(sqlite3_file *pJfd){\n  JournalFile *p = (JournalFile *)pJfd;\n  if( p->pReal ){\n    sqlite3OsClose(p->pReal);\n  }\n  sqlite3_free(p->zBuf);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from the file.\n*/\nstatic int jrnlRead(\n  sqlite3_file *pJfd,    /* The journal file from which to read */\n  void *zBuf,            /* Put the results here */\n  int iAmt,              /* Number of bytes to read */\n  sqlite_int64 iOfst     /* Begin reading at this offset */\n){\n  int rc = SQLITE_OK;\n  JournalFile *p = (JournalFile *)pJfd;\n  if( p->pReal ){\n    rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);\n  }else if( (iAmt+iOfst)>p->iSize ){\n    rc = SQLITE_IOERR_SHORT_READ;\n  }else{\n    memcpy(zBuf, &p->zBuf[iOfst], iAmt);\n  }\n  return rc;\n}\n\n/*\n** Write data to the file.\n*/\nstatic int jrnlWrite(\n  sqlite3_file *pJfd,    /* The journal file into which to write */\n  const void *zBuf,      /* Take data to be written from here */\n  int iAmt,              /* Number of bytes to write */\n  sqlite_int64 iOfst     /* Begin writing at this offset into the file */\n){\n  int rc = SQLITE_OK;\n  JournalFile *p = (JournalFile *)pJfd;\n  if( !p->pReal && (iOfst+iAmt)>p->nBuf ){\n    rc = createFile(p);\n  }\n  if( rc==SQLITE_OK ){\n    if( p->pReal ){\n      rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);\n    }else{\n      memcpy(&p->zBuf[iOfst], zBuf, iAmt);\n      if( p->iSize<(iOfst+iAmt) ){\n        p->iSize = (iOfst+iAmt);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Truncate the file.\n*/\nstatic int jrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){\n  int rc = SQLITE_OK;\n  JournalFile *p = (JournalFile *)pJfd;\n  if( p->pReal ){\n    rc = sqlite3OsTruncate(p->pReal, size);\n  }else if( size<p->iSize ){\n    p->iSize = size;\n  }\n  return rc;\n}\n\n/*\n** Sync the file.\n*/\nstatic int jrnlSync(sqlite3_file *pJfd, int flags){\n  int rc;\n  JournalFile *p = (JournalFile *)pJfd;\n  if( p->pReal ){\n    rc = sqlite3OsSync(p->pReal, flags);\n  }else{\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Query the size of the file in bytes.\n*/\nstatic int jrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){\n  int rc = SQLITE_OK;\n  JournalFile *p = (JournalFile *)pJfd;\n  if( p->pReal ){\n    rc = sqlite3OsFileSize(p->pReal, pSize);\n  }else{\n    *pSize = (sqlite_int64) p->iSize;\n  }\n  return rc;\n}\n\n/*\n** Table of methods for JournalFile sqlite3_file object.\n*/\nstatic struct sqlite3_io_methods JournalFileMethods = {\n  1,             /* iVersion */\n  jrnlClose,     /* xClose */\n  jrnlRead,      /* xRead */\n  jrnlWrite,     /* xWrite */\n  jrnlTruncate,  /* xTruncate */\n  jrnlSync,      /* xSync */\n  jrnlFileSize,  /* xFileSize */\n  0,             /* xLock */\n  0,             /* xUnlock */\n  0,             /* xCheckReservedLock */\n  0,             /* xFileControl */\n  0,             /* xSectorSize */\n  0,             /* xDeviceCharacteristics */\n  0,             /* xShmMap */\n  0,             /* xShmLock */\n  0,             /* xShmBarrier */\n  0              /* xShmUnmap */\n};\n\n/* \n** Open a journal file.\n*/\nSQLITE_PRIVATE int sqlite3JournalOpen(\n  sqlite3_vfs *pVfs,         /* The VFS to use for actual file I/O */\n  const char *zName,         /* Name of the journal file */\n  sqlite3_file *pJfd,        /* Preallocated, blank file handle */\n  int flags,                 /* Opening flags */\n  int nBuf                   /* Bytes buffered before opening the file */\n){\n  JournalFile *p = (JournalFile *)pJfd;\n  memset(p, 0, sqlite3JournalSize(pVfs));\n  if( nBuf>0 ){\n    p->zBuf = sqlite3MallocZero(nBuf);\n    if( !p->zBuf ){\n      return SQLITE_NOMEM;\n    }\n  }else{\n    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);\n  }\n  p->pMethod = &JournalFileMethods;\n  p->nBuf = nBuf;\n  p->flags = flags;\n  p->zJournal = zName;\n  p->pVfs = pVfs;\n  return SQLITE_OK;\n}\n\n/*\n** If the argument p points to a JournalFile structure, and the underlying\n** file has not yet been created, create it now.\n*/\nSQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *p){\n  if( p->pMethods!=&JournalFileMethods ){\n    return SQLITE_OK;\n  }\n  return createFile((JournalFile *)p);\n}\n\n/*\n** The file-handle passed as the only argument is guaranteed to be an open\n** file. It may or may not be of class JournalFile. If the file is a\n** JournalFile, and the underlying file on disk has not yet been opened,\n** return 0. Otherwise, return 1.\n*/\nSQLITE_PRIVATE int sqlite3JournalExists(sqlite3_file *p){\n  return (p->pMethods!=&JournalFileMethods || ((JournalFile *)p)->pReal!=0);\n}\n\n/* \n** Return the number of bytes required to store a JournalFile that uses vfs\n** pVfs to create the underlying on-disk files.\n*/\nSQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){\n  return (pVfs->szOsFile+sizeof(JournalFile));\n}\n#endif\n\n/************** End of journal.c *********************************************/\n/************** Begin file memjournal.c **************************************/\n/*\n** 2008 October 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement an in-memory rollback journal.\n** The in-memory rollback journal is used to journal transactions for\n** \":memory:\" databases and when the journal_mode=MEMORY pragma is used.\n*/\n\n/* Forward references to internal structures */\ntypedef struct MemJournal MemJournal;\ntypedef struct FilePoint FilePoint;\ntypedef struct FileChunk FileChunk;\n\n/* Space to hold the rollback journal is allocated in increments of\n** this many bytes.\n**\n** The size chosen is a little less than a power of two.  That way,\n** the FileChunk object will have a size that almost exactly fills\n** a power-of-two allocation.  This mimimizes wasted space in power-of-two\n** memory allocators.\n*/\n#define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))\n\n/* Macro to find the minimum of two numeric values.\n*/\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n\n/*\n** The rollback journal is composed of a linked list of these structures.\n*/\nstruct FileChunk {\n  FileChunk *pNext;               /* Next chunk in the journal */\n  u8 zChunk[JOURNAL_CHUNKSIZE];   /* Content of this chunk */\n};\n\n/*\n** An instance of this object serves as a cursor into the rollback journal.\n** The cursor can be either for reading or writing.\n*/\nstruct FilePoint {\n  sqlite3_int64 iOffset;          /* Offset from the beginning of the file */\n  FileChunk *pChunk;              /* Specific chunk into which cursor points */\n};\n\n/*\n** This subclass is a subclass of sqlite3_file.  Each open memory-journal\n** is an instance of this class.\n*/\nstruct MemJournal {\n  sqlite3_io_methods *pMethod;    /* Parent class. MUST BE FIRST */\n  FileChunk *pFirst;              /* Head of in-memory chunk-list */\n  FilePoint endpoint;             /* Pointer to the end of the file */\n  FilePoint readpoint;            /* Pointer to the end of the last xRead() */\n};\n\n/*\n** Read data from the in-memory journal file.  This is the implementation\n** of the sqlite3_vfs.xRead method.\n*/\nstatic int memjrnlRead(\n  sqlite3_file *pJfd,    /* The journal file from which to read */\n  void *zBuf,            /* Put the results here */\n  int iAmt,              /* Number of bytes to read */\n  sqlite_int64 iOfst     /* Begin reading at this offset */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  u8 *zOut = zBuf;\n  int nRead = iAmt;\n  int iChunkOffset;\n  FileChunk *pChunk;\n\n  /* SQLite never tries to read past the end of a rollback journal file */\n  assert( iOfst+iAmt<=p->endpoint.iOffset );\n\n  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){\n    sqlite3_int64 iOff = 0;\n    for(pChunk=p->pFirst; \n        ALWAYS(pChunk) && (iOff+JOURNAL_CHUNKSIZE)<=iOfst;\n        pChunk=pChunk->pNext\n    ){\n      iOff += JOURNAL_CHUNKSIZE;\n    }\n  }else{\n    pChunk = p->readpoint.pChunk;\n  }\n\n  iChunkOffset = (int)(iOfst%JOURNAL_CHUNKSIZE);\n  do {\n    int iSpace = JOURNAL_CHUNKSIZE - iChunkOffset;\n    int nCopy = MIN(nRead, (JOURNAL_CHUNKSIZE - iChunkOffset));\n    memcpy(zOut, &pChunk->zChunk[iChunkOffset], nCopy);\n    zOut += nCopy;\n    nRead -= iSpace;\n    iChunkOffset = 0;\n  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );\n  p->readpoint.iOffset = iOfst+iAmt;\n  p->readpoint.pChunk = pChunk;\n\n  return SQLITE_OK;\n}\n\n/*\n** Write data to the file.\n*/\nstatic int memjrnlWrite(\n  sqlite3_file *pJfd,    /* The journal file into which to write */\n  const void *zBuf,      /* Take data to be written from here */\n  int iAmt,              /* Number of bytes to write */\n  sqlite_int64 iOfst     /* Begin writing at this offset into the file */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  int nWrite = iAmt;\n  u8 *zWrite = (u8 *)zBuf;\n\n  /* An in-memory journal file should only ever be appended to. Random\n  ** access writes are not required by sqlite.\n  */\n  assert( iOfst==p->endpoint.iOffset );\n  UNUSED_PARAMETER(iOfst);\n\n  while( nWrite>0 ){\n    FileChunk *pChunk = p->endpoint.pChunk;\n    int iChunkOffset = (int)(p->endpoint.iOffset%JOURNAL_CHUNKSIZE);\n    int iSpace = MIN(nWrite, JOURNAL_CHUNKSIZE - iChunkOffset);\n\n    if( iChunkOffset==0 ){\n      /* New chunk is required to extend the file. */\n      FileChunk *pNew = sqlite3_malloc(sizeof(FileChunk));\n      if( !pNew ){\n        return SQLITE_IOERR_NOMEM;\n      }\n      pNew->pNext = 0;\n      if( pChunk ){\n        assert( p->pFirst );\n        pChunk->pNext = pNew;\n      }else{\n        assert( !p->pFirst );\n        p->pFirst = pNew;\n      }\n      p->endpoint.pChunk = pNew;\n    }\n\n    memcpy(&p->endpoint.pChunk->zChunk[iChunkOffset], zWrite, iSpace);\n    zWrite += iSpace;\n    nWrite -= iSpace;\n    p->endpoint.iOffset += iSpace;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Truncate the file.\n*/\nstatic int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){\n  MemJournal *p = (MemJournal *)pJfd;\n  FileChunk *pChunk;\n  assert(size==0);\n  UNUSED_PARAMETER(size);\n  pChunk = p->pFirst;\n  while( pChunk ){\n    FileChunk *pTmp = pChunk;\n    pChunk = pChunk->pNext;\n    sqlite3_free(pTmp);\n  }\n  sqlite3MemJournalOpen(pJfd);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int memjrnlClose(sqlite3_file *pJfd){\n  memjrnlTruncate(pJfd, 0);\n  return SQLITE_OK;\n}\n\n\n/*\n** Sync the file.\n**\n** Syncing an in-memory journal is a no-op.  And, in fact, this routine\n** is never called in a working implementation.  This implementation\n** exists purely as a contingency, in case some malfunction in some other\n** part of SQLite causes Sync to be called by mistake.\n*/\nstatic int memjrnlSync(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\n\n/*\n** Query the size of the file in bytes.\n*/\nstatic int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){\n  MemJournal *p = (MemJournal *)pJfd;\n  *pSize = (sqlite_int64) p->endpoint.iOffset;\n  return SQLITE_OK;\n}\n\n/*\n** Table of methods for MemJournal sqlite3_file object.\n*/\nstatic const struct sqlite3_io_methods MemJournalMethods = {\n  1,                /* iVersion */\n  memjrnlClose,     /* xClose */\n  memjrnlRead,      /* xRead */\n  memjrnlWrite,     /* xWrite */\n  memjrnlTruncate,  /* xTruncate */\n  memjrnlSync,      /* xSync */\n  memjrnlFileSize,  /* xFileSize */\n  0,                /* xLock */\n  0,                /* xUnlock */\n  0,                /* xCheckReservedLock */\n  0,                /* xFileControl */\n  0,                /* xSectorSize */\n  0,                /* xDeviceCharacteristics */\n  0,                /* xShmMap */\n  0,                /* xShmLock */\n  0,                /* xShmBarrier */\n  0,                /* xShmUnmap */\n  0,                /* xFetch */\n  0                 /* xUnfetch */\n};\n\n/* \n** Open a journal file.\n*/\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){\n  MemJournal *p = (MemJournal *)pJfd;\n  assert( EIGHT_BYTE_ALIGNMENT(p) );\n  memset(p, 0, sqlite3MemJournalSize());\n  p->pMethod = (sqlite3_io_methods*)&MemJournalMethods;\n}\n\n/*\n** Return true if the file-handle passed as an argument is \n** an in-memory journal \n*/\nSQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *pJfd){\n  return pJfd->pMethods==&MemJournalMethods;\n}\n\n/* \n** Return the number of bytes required to store a MemJournal file descriptor.\n*/\nSQLITE_PRIVATE int sqlite3MemJournalSize(void){\n  return sizeof(MemJournal);\n}\n\n/************** End of memjournal.c ******************************************/\n/************** Begin file walker.c ******************************************/\n/*\n** 2008 August 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for walking the parser tree for\n** an SQL statement.\n*/\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n\n/*\n** Walk an expression tree.  Invoke the callback once for each node\n** of the expression, while decending.  (In other words, the callback\n** is invoked before visiting children.)\n**\n** The return value from the callback should be one of the WRC_*\n** constants to specify how to proceed with the walk.\n**\n**    WRC_Continue      Continue descending down the tree.\n**\n**    WRC_Prune         Do not descend into child nodes.  But allow\n**                      the walk to continue with sibling nodes.\n**\n**    WRC_Abort         Do no more callbacks.  Unwind the stack and\n**                      return the top-level walk call.\n**\n** The return value from this routine is WRC_Abort to abandon the tree walk\n** and WRC_Continue to continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){\n  int rc;\n  if( pExpr==0 ) return WRC_Continue;\n  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );\n  testcase( ExprHasProperty(pExpr, EP_Reduced) );\n  rc = pWalker->xExprCallback(pWalker, pExpr);\n  if( rc==WRC_Continue\n              && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){\n    if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;\n    if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;\n    }else{\n      if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;\n    }\n  }\n  return rc & WRC_Abort;\n}\n\n/*\n** Call sqlite3WalkExpr() for every expression in list p or until\n** an abort request is seen.\n*/\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker *pWalker, ExprList *p){\n  int i;\n  struct ExprList_item *pItem;\n  if( p ){\n    for(i=p->nExpr, pItem=p->a; i>0; i--, pItem++){\n      if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Walk all expressions associated with SELECT statement p.  Do\n** not invoke the SELECT callback on p, but do (of course) invoke\n** any expr callbacks and SELECT callbacks that come from subqueries.\n** Return WRC_Abort or WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){\n  if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pOffset) ) return WRC_Abort;\n  return WRC_Continue;\n}\n\n/*\n** Walk the parse trees associated with all subqueries in the\n** FROM clause of SELECT statement p.  Do not invoke the select\n** callback on p, but do invoke it on each FROM clause subquery\n** and on any subqueries further down in the tree.  Return \n** WRC_Abort or WRC_Continue;\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){\n  SrcList *pSrc;\n  int i;\n  struct SrcList_item *pItem;\n\n  pSrc = p->pSrc;\n  if( ALWAYS(pSrc) ){\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      if( sqlite3WalkSelect(pWalker, pItem->pSelect) ){\n        return WRC_Abort;\n      }\n    }\n  }\n  return WRC_Continue;\n} \n\n/*\n** Call sqlite3WalkExpr() for every expression in Select statement p.\n** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and\n** on the compound select chain, p->pPrior.  Invoke the xSelectCallback()\n** either before or after the walk of expressions and FROM clause, depending\n** on whether pWalker->bSelectDepthFirst is false or true, respectively.\n**\n** Return WRC_Continue under normal conditions.  Return WRC_Abort if\n** there is an abort request.\n**\n** If the Walker does not have an xSelectCallback() then this routine\n** is a no-op returning WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){\n  int rc;\n  if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;\n  rc = WRC_Continue;\n  pWalker->walkerDepth++;\n  while( p ){\n    if( !pWalker->bSelectDepthFirst ){\n       rc = pWalker->xSelectCallback(pWalker, p);\n       if( rc ) break;\n    }\n    if( sqlite3WalkSelectExpr(pWalker, p)\n     || sqlite3WalkSelectFrom(pWalker, p)\n    ){\n      pWalker->walkerDepth--;\n      return WRC_Abort;\n    }\n    if( pWalker->bSelectDepthFirst ){\n      rc = pWalker->xSelectCallback(pWalker, p);\n      /* Depth-first search is currently only used for\n      ** selectAddSubqueryTypeInfo() and that routine always returns\n      ** WRC_Continue (0).  So the following branch is never taken. */\n      if( NEVER(rc) ) break;\n    }\n    p = p->pPrior;\n  }\n  pWalker->walkerDepth--;\n  return rc & WRC_Abort;\n}\n\n/************** End of walker.c **********************************************/\n/************** Begin file resolve.c *****************************************/\n/*\n** 2008 August 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains routines used for walking the parser tree and\n** resolve all identifiers by associating them with a particular\n** table and column.\n*/\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n/*\n** Walk the expression tree pExpr and increase the aggregate function\n** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node.\n** This needs to occur when copying a TK_AGG_FUNCTION node from an\n** outer query into an inner subquery.\n**\n** incrAggFunctionDepth(pExpr,n) is the main routine.  incrAggDepth(..)\n** is a helper function - a callback for the tree walker.\n*/\nstatic int incrAggDepth(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.i;\n  return WRC_Continue;\n}\nstatic void incrAggFunctionDepth(Expr *pExpr, int N){\n  if( N>0 ){\n    Walker w;\n    memset(&w, 0, sizeof(w));\n    w.xExprCallback = incrAggDepth;\n    w.u.i = N;\n    sqlite3WalkExpr(&w, pExpr);\n  }\n}\n\n/*\n** Turn the pExpr expression into an alias for the iCol-th column of the\n** result set in pEList.\n**\n** If the result set column is a simple column reference, then this routine\n** makes an exact copy.  But for any other kind of expression, this\n** routine make a copy of the result set column as the argument to the\n** TK_AS operator.  The TK_AS operator causes the expression to be\n** evaluated just once and then reused for each alias.\n**\n** The reason for suppressing the TK_AS term when the expression is a simple\n** column reference is so that the column reference will be recognized as\n** usable by indices within the WHERE clause processing logic. \n**\n** Hack:  The TK_AS operator is inhibited if zType[0]=='G'.  This means\n** that in a GROUP BY clause, the expression is evaluated twice.  Hence:\n**\n**     SELECT random()%5 AS x, count(*) FROM tab GROUP BY x\n**\n** Is equivalent to:\n**\n**     SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5\n**\n** The result of random()%5 in the GROUP BY clause is probably different\n** from the result in the result-set.  We might fix this someday.  Or\n** then again, we might not...\n**\n** If the reference is followed by a COLLATE operator, then make sure\n** the COLLATE operator is preserved.  For example:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase;\n**\n** Should be transformed into:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;\n**\n** The nSubquery parameter specifies how many levels of subquery the\n** alias is removed from the original expression.  The usually value is\n** zero but it might be more if the alias is contained within a subquery\n** of the original expression.  The Expr.op2 field of TK_AGG_FUNCTION\n** structures must be increased by the nSubquery amount.\n*/\nstatic void resolveAlias(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pEList,      /* A result set */\n  int iCol,              /* A column in the result set.  0..pEList->nExpr-1 */\n  Expr *pExpr,           /* Transform this into an alias to the result set */\n  const char *zType,     /* \"GROUP\" or \"ORDER\" or \"\" */\n  int nSubquery          /* Number of subqueries that the label is moving */\n){\n  Expr *pOrig;           /* The iCol-th column of the result set */\n  Expr *pDup;            /* Copy of pOrig */\n  sqlite3 *db;           /* The database connection */\n\n  assert( iCol>=0 && iCol<pEList->nExpr );\n  pOrig = pEList->a[iCol].pExpr;\n  assert( pOrig!=0 );\n  assert( pOrig->flags & EP_Resolved );\n  db = pParse->db;\n  pDup = sqlite3ExprDup(db, pOrig, 0);\n  if( pDup==0 ) return;\n  if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){\n    incrAggFunctionDepth(pDup, nSubquery);\n    pDup = sqlite3PExpr(pParse, TK_AS, pDup, 0, 0);\n    if( pDup==0 ) return;\n    if( pEList->a[iCol].iAlias==0 ){\n      pEList->a[iCol].iAlias = (u16)(++pParse->nAlias);\n    }\n    pDup->iTable = pEList->a[iCol].iAlias;\n  }\n  if( pExpr->op==TK_COLLATE ){\n    pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);\n  }\n\n  /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This \n  ** prevents ExprDelete() from deleting the Expr structure itself,\n  ** allowing it to be repopulated by the memcpy() on the following line.\n  ** The pExpr->u.zToken might point into memory that will be freed by the\n  ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to\n  ** make a copy of the token before doing the sqlite3DbFree().\n  */\n  ExprSetProperty(pExpr, EP_Static);\n  sqlite3ExprDelete(db, pExpr);\n  memcpy(pExpr, pDup, sizeof(*pExpr));\n  if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){\n    assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );\n    pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);\n    pExpr->flags2 |= EP2_MallocedToken;\n  }\n  sqlite3DbFree(db, pDup);\n}\n\n\n/*\n** Return TRUE if the name zCol occurs anywhere in the USING clause.\n**\n** Return FALSE if the USING clause is NULL or if it does not contain\n** zCol.\n*/\nstatic int nameInUsingClause(IdList *pUsing, const char *zCol){\n  if( pUsing ){\n    int k;\n    for(k=0; k<pUsing->nId; k++){\n      if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Subqueries stores the original database, table and column names for their\n** result sets in ExprList.a[].zSpan, in the form \"DATABASE.TABLE.COLUMN\".\n** Check to see if the zSpan given to this routine matches the zDb, zTab,\n** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will\n** match anything.\n*/\nSQLITE_PRIVATE int sqlite3MatchSpanName(\n  const char *zSpan,\n  const char *zCol,\n  const char *zTab,\n  const char *zDb\n){\n  int n;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up\n** that name in the set of source tables in pSrcList and make the pExpr \n** expression node refer back to that source column.  The following changes\n** are made to pExpr:\n**\n**    pExpr->iDb           Set the index in db->aDb[] of the database X\n**                         (even if X is implied).\n**    pExpr->iTable        Set to the cursor number for the table obtained\n**                         from pSrcList.\n**    pExpr->pTab          Points to the Table structure of X.Y (even if\n**                         X and/or Y are implied.)\n**    pExpr->iColumn       Set to the column number within the table.\n**    pExpr->op            Set to TK_COLUMN.\n**    pExpr->pLeft         Any expression this points to is deleted\n**    pExpr->pRight        Any expression this points to is deleted.\n**\n** The zDb variable is the name of the database (the \"X\").  This value may be\n** NULL meaning that name is of the form Y.Z or Z.  Any available database\n** can be used.  The zTable variable is the name of the table (the \"Y\").  This\n** value can be NULL if zDb is also NULL.  If zTable is NULL it\n** means that the form of the name is Z and that columns from any table\n** can be used.\n**\n** If the name cannot be resolved unambiguously, leave an error message\n** in pParse and return WRC_Abort.  Return WRC_Prune on success.\n*/\nstatic int lookupName(\n  Parse *pParse,       /* The parsing context */\n  const char *zDb,     /* Name of the database containing table, or NULL */\n  const char *zTab,    /* Name of table containing column, or NULL */\n  const char *zCol,    /* Name of the column. */\n  NameContext *pNC,    /* The name context used to resolve the name */\n  Expr *pExpr          /* Make this EXPR node point to the selected column */\n){\n  int i, j;                         /* Loop counters */\n  int cnt = 0;                      /* Number of matching column names */\n  int cntTab = 0;                   /* Number of matching table names */\n  int nSubquery = 0;                /* How many levels of subquery */\n  sqlite3 *db = pParse->db;         /* The database connection */\n  struct SrcList_item *pItem;       /* Use for looping over pSrcList items */\n  struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */\n  NameContext *pTopNC = pNC;        /* First namecontext in the list */\n  Schema *pSchema = 0;              /* Schema of the expression */\n  int isTrigger = 0;\n\n  assert( pNC );     /* the name context cannot be NULL. */\n  assert( zCol );    /* The Z in X.Y.Z cannot be NULL */\n  assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n\n  /* Initialize the node to no-match */\n  pExpr->iTable = -1;\n  pExpr->pTab = 0;\n  ExprSetIrreducible(pExpr);\n\n  /* Translate the schema name in zDb into a pointer to the corresponding\n  ** schema.  If not found, pSchema will remain NULL and nothing will match\n  ** resulting in an appropriate error message toward the end of this routine\n  */\n  if( zDb ){\n    for(i=0; i<db->nDb; i++){\n      assert( db->aDb[i].zName );\n      if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){\n        pSchema = db->aDb[i].pSchema;\n        break;\n      }\n    }\n  }\n\n  /* Start at the inner-most context and move outward until a match is found */\n  while( pNC && cnt==0 ){\n    ExprList *pEList;\n    SrcList *pSrcList = pNC->pSrcList;\n\n    if( pSrcList ){\n      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){\n        Table *pTab;\n        Column *pCol;\n  \n        pTab = pItem->pTab;\n        assert( pTab!=0 && pTab->zName!=0 );\n        assert( pTab->nCol>0 );\n        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){\n          int hit = 0;\n          pEList = pItem->pSelect->pEList;\n          for(j=0; j<pEList->nExpr; j++){\n            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){\n              cnt++;\n              cntTab = 2;\n              pMatch = pItem;\n              pExpr->iColumn = j;\n              hit = 1;\n            }\n          }\n          if( hit || zTab==0 ) continue;\n        }\n        if( zDb && pTab->pSchema!=pSchema ){\n          continue;\n        }\n        if( zTab ){\n          const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;\n          assert( zTabName!=0 );\n          if( sqlite3StrICmp(zTabName, zTab)!=0 ){\n            continue;\n          }\n        }\n        if( 0==(cntTab++) ){\n          pMatch = pItem;\n        }\n        for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            /* If there has been exactly one prior match and this match\n            ** is for the right-hand table of a NATURAL JOIN or is in a \n            ** USING clause, then skip this match.\n            */\n            if( cnt==1 ){\n              if( pItem->jointype & JT_NATURAL ) continue;\n              if( nameInUsingClause(pItem->pUsing, zCol) ) continue;\n            }\n            cnt++;\n            pMatch = pItem;\n            /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */\n            pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;\n            break;\n          }\n        }\n      }\n      if( pMatch ){\n        pExpr->iTable = pMatch->iCursor;\n        pExpr->pTab = pMatch->pTab;\n        pSchema = pExpr->pTab->pSchema;\n      }\n    } /* if( pSrcList ) */\n\n#ifndef SQLITE_OMIT_TRIGGER\n    /* If we have not already resolved the name, then maybe \n    ** it is a new.* or old.* trigger argument reference\n    */\n    if( zDb==0 && zTab!=0 && cnt==0 && pParse->pTriggerTab!=0 ){\n      int op = pParse->eTriggerOp;\n      Table *pTab = 0;\n      assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );\n      if( op!=TK_DELETE && sqlite3StrICmp(\"new\",zTab) == 0 ){\n        pExpr->iTable = 1;\n        pTab = pParse->pTriggerTab;\n      }else if( op!=TK_INSERT && sqlite3StrICmp(\"old\",zTab)==0 ){\n        pExpr->iTable = 0;\n        pTab = pParse->pTriggerTab;\n      }\n\n      if( pTab ){ \n        int iCol;\n        pSchema = pTab->pSchema;\n        cntTab++;\n        for(iCol=0; iCol<pTab->nCol; iCol++){\n          Column *pCol = &pTab->aCol[iCol];\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            if( iCol==pTab->iPKey ){\n              iCol = -1;\n            }\n            break;\n          }\n        }\n        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){\n          iCol = -1;        /* IMP: R-44911-55124 */\n        }\n        if( iCol<pTab->nCol ){\n          cnt++;\n          if( iCol<0 ){\n            pExpr->affinity = SQLITE_AFF_INTEGER;\n          }else if( pExpr->iTable==0 ){\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }else{\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }\n          pExpr->iColumn = (i16)iCol;\n          pExpr->pTab = pTab;\n          isTrigger = 1;\n        }\n      }\n    }\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n    /*\n    ** Perhaps the name is a reference to the ROWID\n    */\n    if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){\n      cnt = 1;\n      pExpr->iColumn = -1;     /* IMP: R-44911-55124 */\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n\n    /*\n    ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z\n    ** might refer to an result-set alias.  This happens, for example, when\n    ** we are resolving names in the WHERE clause of the following command:\n    **\n    **     SELECT a+b AS x FROM table WHERE x<10;\n    **\n    ** In cases like this, replace pExpr with a copy of the expression that\n    ** forms the result set entry (\"a+b\" in the example) and return immediately.\n    ** Note that the expression in the result set should have already been\n    ** resolved by the time the WHERE clause is resolved.\n    */\n    if( (pEList = pNC->pEList)!=0\n     && zTab==0\n     && ((pNC->ncFlags & NC_AsMaybe)==0 || cnt==0)\n    ){\n      for(j=0; j<pEList->nExpr; j++){\n        char *zAs = pEList->a[j].zName;\n        if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n          Expr *pOrig;\n          assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n          assert( pExpr->x.pList==0 );\n          assert( pExpr->x.pSelect==0 );\n          pOrig = pEList->a[j].pExpr;\n          if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){\n            sqlite3ErrorMsg(pParse, \"misuse of aliased aggregate %s\", zAs);\n            return WRC_Abort;\n          }\n          resolveAlias(pParse, pEList, j, pExpr, \"\", nSubquery);\n          cnt = 1;\n          pMatch = 0;\n          assert( zTab==0 && zDb==0 );\n          goto lookupname_end;\n        }\n      } \n    }\n\n    /* Advance to the next name context.  The loop will exit when either\n    ** we have a match (cnt>0) or when we run out of name contexts.\n    */\n    if( cnt==0 ){\n      pNC = pNC->pNext;\n      nSubquery++;\n    }\n  }\n\n  /*\n  ** If X and Y are NULL (in other words if only the column name Z is\n  ** supplied) and the value of Z is enclosed in double-quotes, then\n  ** Z is a string literal if it doesn't match any column names.  In that\n  ** case, we need to return right away and not make any changes to\n  ** pExpr.\n  **\n  ** Because no reference was made to outer contexts, the pNC->nRef\n  ** fields are not changed in any context.\n  */\n  if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){\n    pExpr->op = TK_STRING;\n    pExpr->pTab = 0;\n    return WRC_Prune;\n  }\n\n  /*\n  ** cnt==0 means there was not match.  cnt>1 means there were two or\n  ** more matches.  Either way, we have an error.\n  */\n  if( cnt!=1 ){\n    const char *zErr;\n    zErr = cnt==0 ? \"no such column\" : \"ambiguous column name\";\n    if( zDb ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s.%s\", zErr, zDb, zTab, zCol);\n    }else if( zTab ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zErr, zTab, zCol);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zErr, zCol);\n    }\n    pParse->checkSchema = 1;\n    pTopNC->nErr++;\n  }\n\n  /* If a column from a table in pSrcList is referenced, then record\n  ** this fact in the pSrcList.a[].colUsed bitmask.  Column 0 causes\n  ** bit 0 to be set.  Column 1 sets bit 1.  And so forth.  If the\n  ** column number is greater than the number of bits in the bitmask\n  ** then set the high-order bit of the bitmask.\n  */\n  if( pExpr->iColumn>=0 && pMatch!=0 ){\n    int n = pExpr->iColumn;\n    testcase( n==BMS-1 );\n    if( n>=BMS ){\n      n = BMS-1;\n    }\n    assert( pMatch->iCursor==pExpr->iTable );\n    pMatch->colUsed |= ((Bitmask)1)<<n;\n  }\n\n  /* Clean up and return\n  */\n  sqlite3ExprDelete(db, pExpr->pLeft);\n  pExpr->pLeft = 0;\n  sqlite3ExprDelete(db, pExpr->pRight);\n  pExpr->pRight = 0;\n  pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);\nlookupname_end:\n  if( cnt==1 ){\n    assert( pNC!=0 );\n    if( pExpr->op!=TK_AS ){\n      sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);\n    }\n    /* Increment the nRef value on all name contexts from TopNC up to\n    ** the point where the name matched. */\n    for(;;){\n      assert( pTopNC!=0 );\n      pTopNC->nRef++;\n      if( pTopNC==pNC ) break;\n      pTopNC = pTopNC->pNext;\n    }\n    return WRC_Prune;\n  } else {\n    return WRC_Abort;\n  }\n}\n\n/*\n** Allocate and return a pointer to an expression to load the column iCol\n** from datasource iSrc in SrcList pSrc.\n*/\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){\n  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);\n  if( p ){\n    struct SrcList_item *pItem = &pSrc->a[iSrc];\n    p->pTab = pItem->pTab;\n    p->iTable = pItem->iCursor;\n    if( p->pTab->iPKey==iCol ){\n      p->iColumn = -1;\n    }else{\n      p->iColumn = (ynVar)iCol;\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);\n    }\n    ExprSetProperty(p, EP_Resolved);\n  }\n  return p;\n}\n\n/*\n** This routine is callback for sqlite3WalkExpr().\n**\n** Resolve symbolic names into TK_COLUMN operators for the current\n** node in the expression tree.  Return 0 to continue the search down\n** the tree or 2 to abort the tree walk.\n**\n** This routine also does error checking and name resolution for\n** function names.  The operator for aggregate functions is changed\n** to TK_AGG_FUNCTION.\n*/\nstatic int resolveExprStep(Walker *pWalker, Expr *pExpr){\n  NameContext *pNC;\n  Parse *pParse;\n\n  pNC = pWalker->u.pNC;\n  assert( pNC!=0 );\n  pParse = pNC->pParse;\n  assert( pParse==pWalker->pParse );\n\n  if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;\n  ExprSetProperty(pExpr, EP_Resolved);\n#ifndef NDEBUG\n  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){\n    SrcList *pSrcList = pNC->pSrcList;\n    int i;\n    for(i=0; i<pNC->pSrcList->nSrc; i++){\n      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);\n    }\n  }\n#endif\n  switch( pExpr->op ){\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n    /* The special operator TK_ROW means use the rowid for the first\n    ** column in the FROM clause.  This is used by the LIMIT and ORDER BY\n    ** clause processing on UPDATE and DELETE statements.\n    */\n    case TK_ROW: {\n      SrcList *pSrcList = pNC->pSrcList;\n      struct SrcList_item *pItem;\n      assert( pSrcList && pSrcList->nSrc==1 );\n      pItem = pSrcList->a; \n      pExpr->op = TK_COLUMN;\n      pExpr->pTab = pItem->pTab;\n      pExpr->iTable = pItem->iCursor;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n      break;\n    }\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */\n\n    /* A lone identifier is the name of a column.\n    */\n    case TK_ID: {\n      return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr);\n    }\n  \n    /* A table name and column name:     ID.ID\n    ** Or a database, table and column:  ID.ID.ID\n    */\n    case TK_DOT: {\n      const char *zColumn;\n      const char *zTable;\n      const char *zDb;\n      Expr *pRight;\n\n      /* if( pSrcList==0 ) break; */\n      pRight = pExpr->pRight;\n      if( pRight->op==TK_ID ){\n        zDb = 0;\n        zTable = pExpr->pLeft->u.zToken;\n        zColumn = pRight->u.zToken;\n      }else{\n        assert( pRight->op==TK_DOT );\n        zDb = pExpr->pLeft->u.zToken;\n        zTable = pRight->pLeft->u.zToken;\n        zColumn = pRight->pRight->u.zToken;\n      }\n      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);\n    }\n\n    /* Resolve function names\n    */\n    case TK_CONST_FUNC:\n    case TK_FUNCTION: {\n      ExprList *pList = pExpr->x.pList;    /* The argument list */\n      int n = pList ? pList->nExpr : 0;    /* Number of arguments */\n      int no_such_func = 0;       /* True if no such function exists */\n      int wrong_num_args = 0;     /* True if wrong number of arguments */\n      int is_agg = 0;             /* True if is an aggregate function */\n      int auth;                   /* Authorization to use the function */\n      int nId;                    /* Number of characters in function name */\n      const char *zId;            /* The function name. */\n      FuncDef *pDef;              /* Information about the function */\n      u8 enc = ENC(pParse->db);   /* The database encoding */\n\n      testcase( pExpr->op==TK_CONST_FUNC );\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      zId = pExpr->u.zToken;\n      nId = sqlite3Strlen30(zId);\n      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0);\n      if( pDef==0 ){\n        pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0);\n        if( pDef==0 ){\n          no_such_func = 1;\n        }else{\n          wrong_num_args = 1;\n        }\n      }else{\n        is_agg = pDef->xFunc==0;\n      }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      if( pDef ){\n        auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);\n        if( auth!=SQLITE_OK ){\n          if( auth==SQLITE_DENY ){\n            sqlite3ErrorMsg(pParse, \"not authorized to use function: %s\",\n                                    pDef->zName);\n            pNC->nErr++;\n          }\n          pExpr->op = TK_NULL;\n          return WRC_Prune;\n        }\n      }\n#endif\n      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate function %.*s()\", nId,zId);\n        pNC->nErr++;\n        is_agg = 0;\n      }else if( no_such_func && pParse->db->init.busy==0 ){\n        sqlite3ErrorMsg(pParse, \"no such function: %.*s\", nId, zId);\n        pNC->nErr++;\n      }else if( wrong_num_args ){\n        sqlite3ErrorMsg(pParse,\"wrong number of arguments to function %.*s()\",\n             nId, zId);\n        pNC->nErr++;\n      }\n      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;\n      sqlite3WalkExprList(pWalker, pList);\n      if( is_agg ){\n        NameContext *pNC2 = pNC;\n        pExpr->op = TK_AGG_FUNCTION;\n        pExpr->op2 = 0;\n        while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){\n          pExpr->op2++;\n          pNC2 = pNC2->pNext;\n        }\n        if( pNC2 ) pNC2->ncFlags |= NC_HasAgg;\n        pNC->ncFlags |= NC_AllowAgg;\n      }\n      /* FIX ME:  Compute pExpr->affinity based on the expected return\n      ** type of the function \n      */\n      return WRC_Prune;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT:\n    case TK_EXISTS:  testcase( pExpr->op==TK_EXISTS );\n#endif\n    case TK_IN: {\n      testcase( pExpr->op==TK_IN );\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        int nRef = pNC->nRef;\n#ifndef SQLITE_OMIT_CHECK\n        if( (pNC->ncFlags & NC_IsCheck)!=0 ){\n          sqlite3ErrorMsg(pParse,\"subqueries prohibited in CHECK constraints\");\n        }\n#endif\n        sqlite3WalkSelect(pWalker, pExpr->x.pSelect);\n        assert( pNC->nRef>=nRef );\n        if( nRef!=pNC->nRef ){\n          ExprSetProperty(pExpr, EP_VarSelect);\n        }\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_CHECK\n    case TK_VARIABLE: {\n      if( (pNC->ncFlags & NC_IsCheck)!=0 ){\n        sqlite3ErrorMsg(pParse,\"parameters prohibited in CHECK constraints\");\n      }\n      break;\n    }\n#endif\n  }\n  return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;\n}\n\n/*\n** pEList is a list of expressions which are really the result set of the\n** a SELECT statement.  pE is a term in an ORDER BY or GROUP BY clause.\n** This routine checks to see if pE is a simple identifier which corresponds\n** to the AS-name of one of the terms of the expression list.  If it is,\n** this routine return an integer between 1 and N where N is the number of\n** elements in pEList, corresponding to the matching entry.  If there is\n** no match, or if pE is not a simple identifier, then this routine\n** return 0.\n**\n** pEList has been resolved.  pE has not.\n*/\nstatic int resolveAsName(\n  Parse *pParse,     /* Parsing context for error messages */\n  ExprList *pEList,  /* List of expressions to scan */\n  Expr *pE           /* Expression we are trying to match */\n){\n  int i;             /* Loop counter */\n\n  UNUSED_PARAMETER(pParse);\n\n  if( pE->op==TK_ID ){\n    char *zCol = pE->u.zToken;\n    for(i=0; i<pEList->nExpr; i++){\n      char *zAs = pEList->a[i].zName;\n      if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n        return i+1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** pE is a pointer to an expression which is a single term in the\n** ORDER BY of a compound SELECT.  The expression has not been\n** name resolved.\n**\n** At the point this routine is called, we already know that the\n** ORDER BY term is not an integer index into the result set.  That\n** case is handled by the calling routine.\n**\n** Attempt to match pE against result set columns in the left-most\n** SELECT statement.  Return the index i of the matching column,\n** as an indication to the caller that it should sort by the i-th column.\n** The left-most column is 1.  In other words, the value returned is the\n** same integer value that would be used in the SQL statement to indicate\n** the column.\n**\n** If there is no match, return 0.  Return -1 if an error occurs.\n*/\nstatic int resolveOrderByTermToExprList(\n  Parse *pParse,     /* Parsing context for error messages */\n  Select *pSelect,   /* The SELECT statement with the ORDER BY clause */\n  Expr *pE           /* The specific ORDER BY term */\n){\n  int i;             /* Loop counter */\n  ExprList *pEList;  /* The columns of the result set */\n  NameContext nc;    /* Name context for resolving pE */\n  sqlite3 *db;       /* Database connection */\n  int rc;            /* Return code from subprocedures */\n  u8 savedSuppErr;   /* Saved value of db->suppressErr */\n\n  assert( sqlite3ExprIsInteger(pE, &i)==0 );\n  pEList = pSelect->pEList;\n\n  /* Resolve all names in the ORDER BY term expression\n  */\n  memset(&nc, 0, sizeof(nc));\n  nc.pParse = pParse;\n  nc.pSrcList = pSelect->pSrc;\n  nc.pEList = pEList;\n  nc.ncFlags = NC_AllowAgg;\n  nc.nErr = 0;\n  db = pParse->db;\n  savedSuppErr = db->suppressErr;\n  db->suppressErr = 1;\n  rc = sqlite3ResolveExprNames(&nc, pE);\n  db->suppressErr = savedSuppErr;\n  if( rc ) return 0;\n\n  /* Try to match the ORDER BY expression against an expression\n  ** in the result set.  Return an 1-based index of the matching\n  ** result-set entry.\n  */\n  for(i=0; i<pEList->nExpr; i++){\n    if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){\n      return i+1;\n    }\n  }\n\n  /* If no match, return 0. */\n  return 0;\n}\n\n/*\n** Generate an ORDER BY or GROUP BY term out-of-range error.\n*/\nstatic void resolveOutOfRangeError(\n  Parse *pParse,         /* The error context into which to write the error */\n  const char *zType,     /* \"ORDER\" or \"GROUP\" */\n  int i,                 /* The index (1-based) of the term out of range */\n  int mx                 /* Largest permissible value of i */\n){\n  sqlite3ErrorMsg(pParse, \n    \"%r %s BY term out of range - should be \"\n    \"between 1 and %d\", i, zType, mx);\n}\n\n/*\n** Analyze the ORDER BY clause in a compound SELECT statement.   Modify\n** each term of the ORDER BY clause is a constant integer between 1\n** and N where N is the number of columns in the compound SELECT.\n**\n** ORDER BY terms that are already an integer between 1 and N are\n** unmodified.  ORDER BY terms that are integers outside the range of\n** 1 through N generate an error.  ORDER BY terms that are expressions\n** are matched against result set expressions of compound SELECT\n** beginning with the left-most SELECT and working toward the right.\n** At the first match, the ORDER BY expression is transformed into\n** the integer column number.\n**\n** Return the number of errors seen.\n*/\nstatic int resolveCompoundOrderBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect       /* The SELECT statement containing the ORDER BY */\n){\n  int i;\n  ExprList *pOrderBy;\n  ExprList *pEList;\n  sqlite3 *db;\n  int moreToDo = 1;\n\n  pOrderBy = pSelect->pOrderBy;\n  if( pOrderBy==0 ) return 0;\n  db = pParse->db;\n#if SQLITE_MAX_COLUMN\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in ORDER BY clause\");\n    return 1;\n  }\n#endif\n  for(i=0; i<pOrderBy->nExpr; i++){\n    pOrderBy->a[i].done = 0;\n  }\n  pSelect->pNext = 0;\n  while( pSelect->pPrior ){\n    pSelect->pPrior->pNext = pSelect;\n    pSelect = pSelect->pPrior;\n  }\n  while( pSelect && moreToDo ){\n    struct ExprList_item *pItem;\n    moreToDo = 0;\n    pEList = pSelect->pEList;\n    assert( pEList!=0 );\n    for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n      int iCol = -1;\n      Expr *pE, *pDup;\n      if( pItem->done ) continue;\n      pE = sqlite3ExprSkipCollate(pItem->pExpr);\n      if( sqlite3ExprIsInteger(pE, &iCol) ){\n        if( iCol<=0 || iCol>pEList->nExpr ){\n          resolveOutOfRangeError(pParse, \"ORDER\", i+1, pEList->nExpr);\n          return 1;\n        }\n      }else{\n        iCol = resolveAsName(pParse, pEList, pE);\n        if( iCol==0 ){\n          pDup = sqlite3ExprDup(db, pE, 0);\n          if( !db->mallocFailed ){\n            assert(pDup);\n            iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);\n          }\n          sqlite3ExprDelete(db, pDup);\n        }\n      }\n      if( iCol>0 ){\n        /* Convert the ORDER BY term into an integer column number iCol,\n        ** taking care to preserve the COLLATE clause if it exists */\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return 1;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = iCol;\n        if( pItem->pExpr==pE ){\n          pItem->pExpr = pNew;\n        }else{\n          assert( pItem->pExpr->op==TK_COLLATE );\n          assert( pItem->pExpr->pLeft==pE );\n          pItem->pExpr->pLeft = pNew;\n        }\n        sqlite3ExprDelete(db, pE);\n        pItem->iOrderByCol = (u16)iCol;\n        pItem->done = 1;\n      }else{\n        moreToDo = 1;\n      }\n    }\n    pSelect = pSelect->pNext;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    if( pOrderBy->a[i].done==0 ){\n      sqlite3ErrorMsg(pParse, \"%r ORDER BY term does not match any \"\n            \"column in the result set\", i+1);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Check every term in the ORDER BY or GROUP BY clause pOrderBy of\n** the SELECT statement pSelect.  If any term is reference to a\n** result set expression (as determined by the ExprList.a.iCol field)\n** then convert that term into a copy of the corresponding result set\n** column.\n**\n** If any errors are detected, add an error message to pParse and\n** return non-zero.  Return zero if no errors are seen.\n*/\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect,      /* The SELECT statement containing the clause */\n  ExprList *pOrderBy,   /* The ORDER BY or GROUP BY clause to be processed */\n  const char *zType     /* \"ORDER\" or \"GROUP\" */\n){\n  int i;\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;\n  struct ExprList_item *pItem;\n\n  if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;\n#if SQLITE_MAX_COLUMN\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in %s BY clause\", zType);\n    return 1;\n  }\n#endif\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );  /* sqlite3SelectNew() guarantees this */\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    if( pItem->iOrderByCol ){\n      if( pItem->iOrderByCol>pEList->nExpr ){\n        resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);\n        return 1;\n      }\n      resolveAlias(pParse, pEList, pItem->iOrderByCol-1, pItem->pExpr, zType,0);\n    }\n  }\n  return 0;\n}\n\n/*\n** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.\n** The Name context of the SELECT statement is pNC.  zType is either\n** \"ORDER\" or \"GROUP\" depending on which type of clause pOrderBy is.\n**\n** This routine resolves each term of the clause into an expression.\n** If the order-by term is an integer I between 1 and N (where N is the\n** number of columns in the result set of the SELECT) then the expression\n** in the resolution is a copy of the I-th result-set expression.  If\n** the order-by term is an identify that corresponds to the AS-name of\n** a result-set expression, then the term resolves to a copy of the\n** result-set expression.  Otherwise, the expression is resolved in\n** the usual way - using sqlite3ResolveExprNames().\n**\n** This routine returns the number of errors.  If errors occur, then\n** an appropriate error message might be left in pParse.  (OOM errors\n** excepted.)\n*/\nstatic int resolveOrderGroupBy(\n  NameContext *pNC,     /* The name context of the SELECT statement */\n  Select *pSelect,      /* The SELECT statement holding pOrderBy */\n  ExprList *pOrderBy,   /* An ORDER BY or GROUP BY clause to resolve */\n  const char *zType     /* Either \"ORDER\" or \"GROUP\", as appropriate */\n){\n  int i, j;                      /* Loop counters */\n  int iCol;                      /* Column number */\n  struct ExprList_item *pItem;   /* A term of the ORDER BY clause */\n  Parse *pParse;                 /* Parsing context */\n  int nResult;                   /* Number of terms in the result set */\n\n  if( pOrderBy==0 ) return 0;\n  nResult = pSelect->pEList->nExpr;\n  pParse = pNC->pParse;\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    Expr *pE = pItem->pExpr;\n    iCol = resolveAsName(pParse, pSelect->pEList, pE);\n    if( iCol>0 ){\n      /* If an AS-name match is found, mark this ORDER BY column as being\n      ** a copy of the iCol-th result-set column.  The subsequent call to\n      ** sqlite3ResolveOrderGroupBy() will convert the expression to a\n      ** copy of the iCol-th result-set expression. */\n      pItem->iOrderByCol = (u16)iCol;\n      continue;\n    }\n    if( sqlite3ExprIsInteger(sqlite3ExprSkipCollate(pE), &iCol) ){\n      /* The ORDER BY term is an integer constant.  Again, set the column\n      ** number so that sqlite3ResolveOrderGroupBy() will convert the\n      ** order-by term to a copy of the result-set expression */\n      if( iCol<1 || iCol>0xffff ){\n        resolveOutOfRangeError(pParse, zType, i+1, nResult);\n        return 1;\n      }\n      pItem->iOrderByCol = (u16)iCol;\n      continue;\n    }\n\n    /* Otherwise, treat the ORDER BY term as an ordinary expression */\n    pItem->iOrderByCol = 0;\n    if( sqlite3ResolveExprNames(pNC, pE) ){\n      return 1;\n    }\n    for(j=0; j<pSelect->pEList->nExpr; j++){\n      if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){\n        pItem->iOrderByCol = j+1;\n      }\n    }\n  }\n  return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);\n}\n\n/*\n** Resolve names in the SELECT statement p and all of its descendents.\n*/\nstatic int resolveSelectStep(Walker *pWalker, Select *p){\n  NameContext *pOuterNC;  /* Context that contains this SELECT */\n  NameContext sNC;        /* Name context of this SELECT */\n  int isCompound;         /* True if p is a compound select */\n  int nCompound;          /* Number of compound terms processed so far */\n  Parse *pParse;          /* Parsing context */\n  ExprList *pEList;       /* Result set expression list */\n  int i;                  /* Loop counter */\n  ExprList *pGroupBy;     /* The GROUP BY clause */\n  Select *pLeftmost;      /* Left-most of SELECT of a compound */\n  sqlite3 *db;            /* Database connection */\n  \n\n  assert( p!=0 );\n  if( p->selFlags & SF_Resolved ){\n    return WRC_Prune;\n  }\n  pOuterNC = pWalker->u.pNC;\n  pParse = pWalker->pParse;\n  db = pParse->db;\n\n  /* Normally sqlite3SelectExpand() will be called first and will have\n  ** already expanded this SELECT.  However, if this is a subquery within\n  ** an expression, sqlite3ResolveExprNames() will be called without a\n  ** prior call to sqlite3SelectExpand().  When that happens, let\n  ** sqlite3SelectPrep() do all of the processing for this SELECT.\n  ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and\n  ** this routine in the correct order.\n  */\n  if( (p->selFlags & SF_Expanded)==0 ){\n    sqlite3SelectPrep(pParse, p, pOuterNC);\n    return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;\n  }\n\n  isCompound = p->pPrior!=0;\n  nCompound = 0;\n  pLeftmost = p;\n  while( p ){\n    assert( (p->selFlags & SF_Expanded)!=0 );\n    assert( (p->selFlags & SF_Resolved)==0 );\n    p->selFlags |= SF_Resolved;\n\n    /* Resolve the expressions in the LIMIT and OFFSET clauses. These\n    ** are not allowed to refer to any names, so pass an empty NameContext.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||\n        sqlite3ResolveExprNames(&sNC, p->pOffset) ){\n      return WRC_Abort;\n    }\n  \n    /* Recursively resolve names in all subqueries\n    */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->pSelect ){\n        NameContext *pNC;         /* Used to iterate name contexts */\n        int nRef = 0;             /* Refcount for pOuterNC and outer contexts */\n        const char *zSavedContext = pParse->zAuthContext;\n\n        /* Count the total number of references to pOuterNC and all of its\n        ** parent contexts. After resolving references to expressions in\n        ** pItem->pSelect, check if this value has changed. If so, then\n        ** SELECT statement pItem->pSelect must be correlated. Set the\n        ** pItem->isCorrelated flag if this is the case. */\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef;\n\n        if( pItem->zName ) pParse->zAuthContext = pItem->zName;\n        sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);\n        pParse->zAuthContext = zSavedContext;\n        if( pParse->nErr || db->mallocFailed ) return WRC_Abort;\n\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef;\n        assert( pItem->isCorrelated==0 && nRef<=0 );\n        pItem->isCorrelated = (nRef!=0);\n      }\n    }\n  \n    /* Set up the local name-context to pass to sqlite3ResolveExprNames() to\n    ** resolve the result-set expression list.\n    */\n    sNC.ncFlags = NC_AllowAgg;\n    sNC.pSrcList = p->pSrc;\n    sNC.pNext = pOuterNC;\n  \n    /* Resolve names in the result set. */\n    pEList = p->pEList;\n    assert( pEList!=0 );\n    for(i=0; i<pEList->nExpr; i++){\n      Expr *pX = pEList->a[i].pExpr;\n      if( sqlite3ResolveExprNames(&sNC, pX) ){\n        return WRC_Abort;\n      }\n    }\n  \n    /* If there are no aggregate functions in the result-set, and no GROUP BY \n    ** expression, do not allow aggregates in any of the other expressions.\n    */\n    assert( (p->selFlags & SF_Aggregate)==0 );\n    pGroupBy = p->pGroupBy;\n    if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){\n      p->selFlags |= SF_Aggregate;\n    }else{\n      sNC.ncFlags &= ~NC_AllowAgg;\n    }\n  \n    /* If a HAVING clause is present, then there must be a GROUP BY clause.\n    */\n    if( p->pHaving && !pGroupBy ){\n      sqlite3ErrorMsg(pParse, \"a GROUP BY clause is required before HAVING\");\n      return WRC_Abort;\n    }\n  \n    /* Add the expression list to the name-context before parsing the\n    ** other expressions in the SELECT statement. This is so that\n    ** expressions in the WHERE clause (etc.) can refer to expressions by\n    ** aliases in the result set.\n    **\n    ** Minor point: If this is the case, then the expression will be\n    ** re-evaluated for each reference to it.\n    */\n    sNC.pEList = p->pEList;\n    sNC.ncFlags |= NC_AsMaybe;\n    if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;\n    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;\n    sNC.ncFlags &= ~NC_AsMaybe;\n\n    /* The ORDER BY and GROUP BY clauses may not refer to terms in\n    ** outer queries \n    */\n    sNC.pNext = 0;\n    sNC.ncFlags |= NC_AllowAgg;\n\n    /* Process the ORDER BY clause for singleton SELECT statements.\n    ** The ORDER BY clause for compounds SELECT statements is handled\n    ** below, after all of the result-sets for all of the elements of\n    ** the compound have been resolved.\n    */\n    if( !isCompound && resolveOrderGroupBy(&sNC, p, p->pOrderBy, \"ORDER\") ){\n      return WRC_Abort;\n    }\n    if( db->mallocFailed ){\n      return WRC_Abort;\n    }\n  \n    /* Resolve the GROUP BY clause.  At the same time, make sure \n    ** the GROUP BY clause does not contain aggregate functions.\n    */\n    if( pGroupBy ){\n      struct ExprList_item *pItem;\n    \n      if( resolveOrderGroupBy(&sNC, p, pGroupBy, \"GROUP\") || db->mallocFailed ){\n        return WRC_Abort;\n      }\n      for(i=0, pItem=pGroupBy->a; i<pGroupBy->nExpr; i++, pItem++){\n        if( ExprHasProperty(pItem->pExpr, EP_Agg) ){\n          sqlite3ErrorMsg(pParse, \"aggregate functions are not allowed in \"\n              \"the GROUP BY clause\");\n          return WRC_Abort;\n        }\n      }\n    }\n\n    /* Advance to the next term of the compound\n    */\n    p = p->pPrior;\n    nCompound++;\n  }\n\n  /* Resolve the ORDER BY on a compound SELECT after all terms of\n  ** the compound have been resolved.\n  */\n  if( isCompound && resolveCompoundOrderBy(pParse, pLeftmost) ){\n    return WRC_Abort;\n  }\n\n  return WRC_Prune;\n}\n\n/*\n** This routine walks an expression tree and resolves references to\n** table columns and result-set columns.  At the same time, do error\n** checking on function usage and set a flag if any aggregate functions\n** are seen.\n**\n** To resolve table columns references we look for nodes (or subtrees) of the \n** form X.Y.Z or Y.Z or just Z where\n**\n**      X:   The name of a database.  Ex:  \"main\" or \"temp\" or\n**           the symbolic name assigned to an ATTACH-ed database.\n**\n**      Y:   The name of a table in a FROM clause.  Or in a trigger\n**           one of the special names \"old\" or \"new\".\n**\n**      Z:   The name of a column in table Y.\n**\n** The node at the root of the subtree is modified as follows:\n**\n**    Expr.op        Changed to TK_COLUMN\n**    Expr.pTab      Points to the Table object for X.Y\n**    Expr.iColumn   The column index in X.Y.  -1 for the rowid.\n**    Expr.iTable    The VDBE cursor number for X.Y\n**\n**\n** To resolve result-set references, look for expression nodes of the\n** form Z (with no X and Y prefix) where the Z matches the right-hand\n** size of an AS clause in the result-set of a SELECT.  The Z expression\n** is replaced by a copy of the left-hand side of the result-set expression.\n** Table-name and function resolution occurs on the substituted expression\n** tree.  For example, in:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;\n**\n** The \"x\" term of the order by is replaced by \"a+b\" to render:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;\n**\n** Function calls are checked to make sure that the function is \n** defined and that the correct number of arguments are specified.\n** If the function is an aggregate function, then the NC_HasAgg flag is\n** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.\n** If an expression contains aggregate functions then the EP_Agg\n** property on the expression is set.\n**\n** An error message is left in pParse if anything is amiss.  The number\n** if errors is returned.\n*/\nSQLITE_PRIVATE int sqlite3ResolveExprNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  Expr *pExpr             /* The expression to be analyzed. */\n){\n  u8 savedHasAgg;\n  Walker w;\n\n  if( pExpr==0 ) return 0;\n#if SQLITE_MAX_EXPR_DEPTH>0\n  {\n    Parse *pParse = pNC->pParse;\n    if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){\n      return 1;\n    }\n    pParse->nHeight += pExpr->nHeight;\n  }\n#endif\n  savedHasAgg = pNC->ncFlags & NC_HasAgg;\n  pNC->ncFlags &= ~NC_HasAgg;\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.pParse = pNC->pParse;\n  w.u.pNC = pNC;\n  sqlite3WalkExpr(&w, pExpr);\n#if SQLITE_MAX_EXPR_DEPTH>0\n  pNC->pParse->nHeight -= pExpr->nHeight;\n#endif\n  if( pNC->nErr>0 || w.pParse->nErr>0 ){\n    ExprSetProperty(pExpr, EP_Error);\n  }\n  if( pNC->ncFlags & NC_HasAgg ){\n    ExprSetProperty(pExpr, EP_Agg);\n  }else if( savedHasAgg ){\n    pNC->ncFlags |= NC_HasAgg;\n  }\n  return ExprHasProperty(pExpr, EP_Error);\n}\n\n\n/*\n** Resolve all names in all expressions of a SELECT and in all\n** decendents of the SELECT, including compounds off of p->pPrior,\n** subqueries in expressions, and subqueries used as FROM clause\n** terms.\n**\n** See sqlite3ResolveExprNames() for a description of the kinds of\n** transformations that occur.\n**\n** All SELECT statements should have been expanded using\n** sqlite3SelectExpand() prior to invoking this routine.\n*/\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for parent SELECT statement */\n){\n  Walker w;\n\n  assert( p!=0 );\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.pParse = pParse;\n  w.u.pNC = pOuterNC;\n  sqlite3WalkSelect(&w, p);\n}\n\n/************** End of resolve.c *********************************************/\n/************** Begin file expr.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for analyzing expressions and\n** for generating VDBE code that evaluates expressions in SQLite.\n*/\n\n/*\n** Return the 'affinity' of the expression pExpr if any.\n**\n** If pExpr is a column, a reference to a column via an 'AS' alias,\n** or a sub-select with a column as the return value, then the \n** affinity of that column is returned. Otherwise, 0x00 is returned,\n** indicating no affinity for the expression.\n**\n** i.e. the WHERE clause expresssions in the following statements all\n** have an affinity:\n**\n** CREATE TABLE t1(a);\n** SELECT * FROM t1 WHERE a;\n** SELECT a AS b FROM t1 WHERE b;\n** SELECT * FROM t1 WHERE (select a from t1);\n*/\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){\n  int op;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  op = pExpr->op;\n  if( op==TK_SELECT ){\n    assert( pExpr->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);\n  }\n#ifndef SQLITE_OMIT_CAST\n  if( op==TK_CAST ){\n    assert( !ExprHasProperty(pExpr, EP_IntValue) );\n    return sqlite3AffinityType(pExpr->u.zToken);\n  }\n#endif\n  if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER) \n   && pExpr->pTab!=0\n  ){\n    /* op==TK_REGISTER && pExpr->pTab!=0 happens when pExpr was originally\n    ** a TK_COLUMN but was previously evaluated and cached in a register */\n    int j = pExpr->iColumn;\n    if( j<0 ) return SQLITE_AFF_INTEGER;\n    assert( pExpr->pTab && j<pExpr->pTab->nCol );\n    return pExpr->pTab->aCol[j].affinity;\n  }\n  return pExpr->affinity;\n}\n\n/*\n** Set the collating sequence for expression pExpr to be the collating\n** sequence named by pToken.   Return a pointer to a new Expr node that\n** implements the COLLATE operator.\n**\n** If a memory allocation error occurs, that fact is recorded in pParse->db\n** and the pExpr parameter is returned unchanged.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr *pExpr, Token *pCollName){\n  if( pCollName->n>0 ){\n    Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1);\n    if( pNew ){\n      pNew->pLeft = pExpr;\n      pNew->flags |= EP_Collate;\n      pExpr = pNew;\n    }\n  }\n  return pExpr;\n}\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){\n  Token s;\n  assert( zC!=0 );\n  s.z = zC;\n  s.n = sqlite3Strlen30(s.z);\n  return sqlite3ExprAddCollateToken(pParse, pExpr, &s);\n}\n\n/*\n** Skip over any TK_COLLATE and/or TK_AS operators at the root of\n** an expression.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){\n  while( pExpr && (pExpr->op==TK_COLLATE || pExpr->op==TK_AS) ){\n    pExpr = pExpr->pLeft;\n  }\n  return pExpr;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return NULL.\n**\n** The collating sequence might be determined by a COLLATE operator\n** or by the presence of a column with a defined collating sequence.\n** COLLATE operators take first precedence.  Left operands take\n** precedence over right operands.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){\n  sqlite3 *db = pParse->db;\n  CollSeq *pColl = 0;\n  Expr *p = pExpr;\n  while( p ){\n    int op = p->op;\n    if( op==TK_CAST || op==TK_UPLUS ){\n      p = p->pLeft;\n      continue;\n    }\n    assert( op!=TK_REGISTER || p->op2!=TK_COLLATE );\n    if( op==TK_COLLATE ){\n      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);\n      break;\n    }\n    if( p->pTab!=0\n     && (op==TK_AGG_COLUMN || op==TK_COLUMN\n          || op==TK_REGISTER || op==TK_TRIGGER)\n    ){\n      /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally\n      ** a TK_COLUMN but was previously evaluated and cached in a register */\n      int j = p->iColumn;\n      if( j>=0 ){\n        const char *zColl = p->pTab->aCol[j].zColl;\n        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n      }\n      break;\n    }\n    if( p->flags & EP_Collate ){\n      if( ALWAYS(p->pLeft) && (p->pLeft->flags & EP_Collate)!=0 ){\n        p = p->pLeft;\n      }else{\n        p = p->pRight;\n      }\n    }else{\n      break;\n    }\n  }\n  if( sqlite3CheckCollSeq(pParse, pColl) ){ \n    pColl = 0;\n  }\n  return pColl;\n}\n\n/*\n** pExpr is an operand of a comparison operator.  aff2 is the\n** type affinity of the other operand.  This routine returns the\n** type affinity that should be used for the comparison operator.\n*/\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){\n  char aff1 = sqlite3ExprAffinity(pExpr);\n  if( aff1 && aff2 ){\n    /* Both sides of the comparison are columns. If one has numeric\n    ** affinity, use that. Otherwise use no affinity.\n    */\n    if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){\n      return SQLITE_AFF_NUMERIC;\n    }else{\n      return SQLITE_AFF_NONE;\n    }\n  }else if( !aff1 && !aff2 ){\n    /* Neither side of the comparison is a column.  Compare the\n    ** results directly.\n    */\n    return SQLITE_AFF_NONE;\n  }else{\n    /* One side is a column, the other is not. Use the columns affinity. */\n    assert( aff1==0 || aff2==0 );\n    return (aff1 + aff2);\n  }\n}\n\n/*\n** pExpr is a comparison operator.  Return the type affinity that should\n** be applied to both operands prior to doing the comparison.\n*/\nstatic char comparisonAffinity(Expr *pExpr){\n  char aff;\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||\n          pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||\n          pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );\n  assert( pExpr->pLeft );\n  aff = sqlite3ExprAffinity(pExpr->pLeft);\n  if( pExpr->pRight ){\n    aff = sqlite3CompareAffinity(pExpr->pRight, aff);\n  }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);\n  }else if( !aff ){\n    aff = SQLITE_AFF_NONE;\n  }\n  return aff;\n}\n\n/*\n** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.\n** idx_affinity is the affinity of an indexed column. Return true\n** if the index with affinity idx_affinity may be used to implement\n** the comparison in pExpr.\n*/\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){\n  char aff = comparisonAffinity(pExpr);\n  switch( aff ){\n    case SQLITE_AFF_NONE:\n      return 1;\n    case SQLITE_AFF_TEXT:\n      return idx_affinity==SQLITE_AFF_TEXT;\n    default:\n      return sqlite3IsNumericAffinity(idx_affinity);\n  }\n}\n\n/*\n** Return the P5 value that should be used for a binary comparison\n** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.\n*/\nstatic u8 binaryCompareP5(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){\n  u8 aff = (char)sqlite3ExprAffinity(pExpr2);\n  aff = (u8)sqlite3CompareAffinity(pExpr1, aff) | (u8)jumpIfNull;\n  return aff;\n}\n\n/*\n** Return a pointer to the collation sequence that should be used by\n** a binary comparison operator comparing pLeft and pRight.\n**\n** If the left hand expression has a collating sequence type, then it is\n** used. Otherwise the collation sequence for the right hand expression\n** is used, or the default (BINARY) if neither expression has a collating\n** type.\n**\n** Argument pRight (but not pLeft) may be a null pointer. In this case,\n** it is not considered.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(\n  Parse *pParse, \n  Expr *pLeft, \n  Expr *pRight\n){\n  CollSeq *pColl;\n  assert( pLeft );\n  if( pLeft->flags & EP_Collate ){\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n  }else if( pRight && (pRight->flags & EP_Collate)!=0 ){\n    pColl = sqlite3ExprCollSeq(pParse, pRight);\n  }else{\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n    if( !pColl ){\n      pColl = sqlite3ExprCollSeq(pParse, pRight);\n    }\n  }\n  return pColl;\n}\n\n/*\n** Generate code for a comparison operator.\n*/\nstatic int codeCompare(\n  Parse *pParse,    /* The parsing (and code generating) context */\n  Expr *pLeft,      /* The left operand */\n  Expr *pRight,     /* The right operand */\n  int opcode,       /* The comparison opcode */\n  int in1, int in2, /* Register holding operands */\n  int dest,         /* Jump here if true.  */\n  int jumpIfNull    /* If true, jump if either operand is NULL */\n){\n  int p5;\n  int addr;\n  CollSeq *p4;\n\n  p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);\n  p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);\n  addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,\n                           (void*)p4, P4_COLLSEQ);\n  sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);\n  return addr;\n}\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n/*\n** Check that argument nHeight is less than or equal to the maximum\n** expression depth allowed. If it is not, leave an error message in\n** pParse.\n*/\nSQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse *pParse, int nHeight){\n  int rc = SQLITE_OK;\n  int mxHeight = pParse->db->aLimit[SQLITE_LIMIT_EXPR_DEPTH];\n  if( nHeight>mxHeight ){\n    sqlite3ErrorMsg(pParse, \n       \"Expression tree is too large (maximum depth %d)\", mxHeight\n    );\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/* The following three functions, heightOfExpr(), heightOfExprList()\n** and heightOfSelect(), are used to determine the maximum height\n** of any expression tree referenced by the structure passed as the\n** first argument.\n**\n** If this maximum height is greater than the current value pointed\n** to by pnHeight, the second parameter, then set *pnHeight to that\n** value.\n*/\nstatic void heightOfExpr(Expr *p, int *pnHeight){\n  if( p ){\n    if( p->nHeight>*pnHeight ){\n      *pnHeight = p->nHeight;\n    }\n  }\n}\nstatic void heightOfExprList(ExprList *p, int *pnHeight){\n  if( p ){\n    int i;\n    for(i=0; i<p->nExpr; i++){\n      heightOfExpr(p->a[i].pExpr, pnHeight);\n    }\n  }\n}\nstatic void heightOfSelect(Select *p, int *pnHeight){\n  if( p ){\n    heightOfExpr(p->pWhere, pnHeight);\n    heightOfExpr(p->pHaving, pnHeight);\n    heightOfExpr(p->pLimit, pnHeight);\n    heightOfExpr(p->pOffset, pnHeight);\n    heightOfExprList(p->pEList, pnHeight);\n    heightOfExprList(p->pGroupBy, pnHeight);\n    heightOfExprList(p->pOrderBy, pnHeight);\n    heightOfSelect(p->pPrior, pnHeight);\n  }\n}\n\n/*\n** Set the Expr.nHeight variable in the structure passed as an \n** argument. An expression with no children, Expr.pList or \n** Expr.pSelect member has a height of 1. Any other expression\n** has a height equal to the maximum height of any other \n** referenced Expr plus one.\n*/\nstatic void exprSetHeight(Expr *p){\n  int nHeight = 0;\n  heightOfExpr(p->pLeft, &nHeight);\n  heightOfExpr(p->pRight, &nHeight);\n  if( ExprHasProperty(p, EP_xIsSelect) ){\n    heightOfSelect(p->x.pSelect, &nHeight);\n  }else{\n    heightOfExprList(p->x.pList, &nHeight);\n  }\n  p->nHeight = nHeight + 1;\n}\n\n/*\n** Set the Expr.nHeight variable using the exprSetHeight() function. If\n** the height is greater than the maximum allowed expression depth,\n** leave an error in pParse.\n*/\nSQLITE_PRIVATE void sqlite3ExprSetHeight(Parse *pParse, Expr *p){\n  exprSetHeight(p);\n  sqlite3ExprCheckHeight(pParse, p->nHeight);\n}\n\n/*\n** Return the maximum height of any expression tree referenced\n** by the select statement passed as an argument.\n*/\nSQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){\n  int nHeight = 0;\n  heightOfSelect(p, &nHeight);\n  return nHeight;\n}\n#else\n  #define exprSetHeight(y)\n#endif /* SQLITE_MAX_EXPR_DEPTH>0 */\n\n/*\n** This routine is the core allocator for Expr nodes.\n**\n** Construct a new expression node and return a pointer to it.  Memory\n** for this node and for the pToken argument is a single allocation\n** obtained from sqlite3DbMalloc().  The calling function\n** is responsible for making sure the node eventually gets freed.\n**\n** If dequote is true, then the token (if it exists) is dequoted.\n** If dequote is false, no dequoting is performance.  The deQuote\n** parameter is ignored if pToken is NULL or if the token does not\n** appear to be quoted.  If the quotes were of the form \"...\" (double-quotes)\n** then the EP_DblQuoted flag is set on the expression node.\n**\n** Special case:  If op==TK_INTEGER and pToken points to a string that\n** can be translated into a 32-bit integer, then the token is not\n** stored in u.zToken.  Instead, the integer values is written\n** into u.iValue and the EP_IntValue flag is set.  No extra storage\n** is allocated to hold the integer text and the dequote flag is ignored.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocZero() (may be null) */\n  int op,                 /* Expression opcode */\n  const Token *pToken,    /* Token argument.  Might be NULL */\n  int dequote             /* True to dequote */\n){\n  Expr *pNew;\n  int nExtra = 0;\n  int iValue = 0;\n\n  if( pToken ){\n    if( op!=TK_INTEGER || pToken->z==0\n          || sqlite3GetInt32(pToken->z, &iValue)==0 ){\n      nExtra = pToken->n+1;\n      assert( iValue>=0 );\n    }\n  }\n  pNew = sqlite3DbMallocZero(db, sizeof(Expr)+nExtra);\n  if( pNew ){\n    pNew->op = (u8)op;\n    pNew->iAgg = -1;\n    if( pToken ){\n      if( nExtra==0 ){\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = iValue;\n      }else{\n        int c;\n        pNew->u.zToken = (char*)&pNew[1];\n        assert( pToken->z!=0 || pToken->n==0 );\n        if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);\n        pNew->u.zToken[pToken->n] = 0;\n        if( dequote && nExtra>=3 \n             && ((c = pToken->z[0])=='\\'' || c=='\"' || c=='[' || c=='`') ){\n          sqlite3Dequote(pNew->u.zToken);\n          if( c=='\"' ) pNew->flags |= EP_DblQuoted;\n        }\n      }\n    }\n#if SQLITE_MAX_EXPR_DEPTH>0\n    pNew->nHeight = 1;\n#endif  \n  }\n  return pNew;\n}\n\n/*\n** Allocate a new expression node from a zero-terminated token that has\n** already been dequoted.\n*/\nSQLITE_PRIVATE Expr *sqlite3Expr(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocZero() (may be null) */\n  int op,                 /* Expression opcode */\n  const char *zToken      /* Token argument.  Might be NULL */\n){\n  Token x;\n  x.z = zToken;\n  x.n = zToken ? sqlite3Strlen30(zToken) : 0;\n  return sqlite3ExprAlloc(db, op, &x, 0);\n}\n\n/*\n** Attach subtrees pLeft and pRight to the Expr node pRoot.\n**\n** If pRoot==NULL that means that a memory allocation error has occurred.\n** In that case, delete the subtrees pLeft and pRight.\n*/\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(\n  sqlite3 *db,\n  Expr *pRoot,\n  Expr *pLeft,\n  Expr *pRight\n){\n  if( pRoot==0 ){\n    assert( db->mallocFailed );\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n  }else{\n    if( pRight ){\n      pRoot->pRight = pRight;\n      pRoot->flags |= EP_Collate & pRight->flags;\n    }\n    if( pLeft ){\n      pRoot->pLeft = pLeft;\n      pRoot->flags |= EP_Collate & pLeft->flags;\n    }\n    exprSetHeight(pRoot);\n  }\n}\n\n/*\n** Allocate a Expr node which joins as many as two subtrees.\n**\n** One or both of the subtrees can be NULL.  Return a pointer to the new\n** Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,\n** free the subtrees and return NULL.\n*/\nSQLITE_PRIVATE Expr *sqlite3PExpr(\n  Parse *pParse,          /* Parsing context */\n  int op,                 /* Expression opcode */\n  Expr *pLeft,            /* Left operand */\n  Expr *pRight,           /* Right operand */\n  const Token *pToken     /* Argument token */\n){\n  Expr *p;\n  if( op==TK_AND && pLeft && pRight ){\n    /* Take advantage of short-circuit false optimization for AND */\n    p = sqlite3ExprAnd(pParse->db, pLeft, pRight);\n  }else{\n    p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);\n    sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);\n  }\n  if( p ) {\n    sqlite3ExprCheckHeight(pParse, p->nHeight);\n  }\n  return p;\n}\n\n/*\n** Return 1 if an expression must be FALSE in all cases and 0 if the\n** expression might be true.  This is an optimization.  If is OK to\n** return 0 here even if the expression really is always false (a \n** false negative).  But it is a bug to return 1 if the expression\n** might be true in some rare circumstances (a false positive.)\n**\n** Note that if the expression is part of conditional for a\n** LEFT JOIN, then we cannot determine at compile-time whether or not\n** is it true or false, so always return 0.\n*/\nstatic int exprAlwaysFalse(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v==0;\n}\n\n/*\n** Join two expressions using an AND operator.  If either expression is\n** NULL, then just return the other expression.\n**\n** If one side or the other of the AND is known to be false, then instead\n** of returning an AND expression, just return a constant expression with\n** a value of false.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){\n  if( pLeft==0 ){\n    return pRight;\n  }else if( pRight==0 ){\n    return pLeft;\n  }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n    return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);\n  }else{\n    Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);\n    sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);\n    return pNew;\n  }\n}\n\n/*\n** Construct a new expression node for a function with multiple\n** arguments.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){\n  Expr *pNew;\n  sqlite3 *db = pParse->db;\n  assert( pToken );\n  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);\n  if( pNew==0 ){\n    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */\n    return 0;\n  }\n  pNew->x.pList = pList;\n  assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n  sqlite3ExprSetHeight(pParse, pNew);\n  return pNew;\n}\n\n/*\n** Assign a variable number to an expression that encodes a wildcard\n** in the original SQL statement.  \n**\n** Wildcards consisting of a single \"?\" are assigned the next sequential\n** variable number.\n**\n** Wildcards of the form \"?nnn\" are assigned the number \"nnn\".  We make\n** sure \"nnn\" is not too be to avoid a denial of service attack when\n** the SQL statement comes from an external source.\n**\n** Wildcards of the form \":aaa\", \"@aaa\", or \"$aaa\" are assigned the same number\n** as the previous instance of the same wildcard.  Or if this is the first\n** instance of the wildcard, the next sequenial variable number is\n** assigned.\n*/\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){\n  sqlite3 *db = pParse->db;\n  const char *z;\n\n  if( pExpr==0 ) return;\n  assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );\n  z = pExpr->u.zToken;\n  assert( z!=0 );\n  assert( z[0]!=0 );\n  if( z[1]==0 ){\n    /* Wildcard of the form \"?\".  Assign the next variable number */\n    assert( z[0]=='?' );\n    pExpr->iColumn = (ynVar)(++pParse->nVar);\n  }else{\n    ynVar x = 0;\n    u32 n = sqlite3Strlen30(z);\n    if( z[0]=='?' ){\n      /* Wildcard of the form \"?nnn\".  Convert \"nnn\" to an integer and\n      ** use it as the variable number */\n      i64 i;\n      int bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8);\n      pExpr->iColumn = x = (ynVar)i;\n      testcase( i==0 );\n      testcase( i==1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );\n      if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n        sqlite3ErrorMsg(pParse, \"variable number must be between ?1 and ?%d\",\n            db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);\n        x = 0;\n      }\n      if( i>pParse->nVar ){\n        pParse->nVar = (int)i;\n      }\n    }else{\n      /* Wildcards like \":aaa\", \"$aaa\" or \"@aaa\".  Reuse the same variable\n      ** number as the prior appearance of the same name, or if the name\n      ** has never appeared before, reuse the same variable number\n      */\n      ynVar i;\n      for(i=0; i<pParse->nzVar; i++){\n        if( pParse->azVar[i] && strcmp(pParse->azVar[i],z)==0 ){\n          pExpr->iColumn = x = (ynVar)i+1;\n          break;\n        }\n      }\n      if( x==0 ) x = pExpr->iColumn = (ynVar)(++pParse->nVar);\n    }\n    if( x>0 ){\n      if( x>pParse->nzVar ){\n        char **a;\n        a = sqlite3DbRealloc(db, pParse->azVar, x*sizeof(a[0]));\n        if( a==0 ) return;  /* Error reported through db->mallocFailed */\n        pParse->azVar = a;\n        memset(&a[pParse->nzVar], 0, (x-pParse->nzVar)*sizeof(a[0]));\n        pParse->nzVar = x;\n      }\n      if( z[0]!='?' || pParse->azVar[x-1]==0 ){\n        sqlite3DbFree(db, pParse->azVar[x-1]);\n        pParse->azVar[x-1] = sqlite3DbStrNDup(db, z, n);\n      }\n    }\n  } \n  if( !pParse->nErr && pParse->nVar>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n    sqlite3ErrorMsg(pParse, \"too many SQL variables\");\n  }\n}\n\n/*\n** Recursively delete an expression tree.\n*/\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){\n  if( p==0 ) return;\n  /* Sanity check: Assert that the IntValue is non-negative if it exists */\n  assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );\n  if( !ExprHasAnyProperty(p, EP_TokenOnly) ){\n    sqlite3ExprDelete(db, p->pLeft);\n    sqlite3ExprDelete(db, p->pRight);\n    if( !ExprHasProperty(p, EP_Reduced) && (p->flags2 & EP2_MallocedToken)!=0 ){\n      sqlite3DbFree(db, p->u.zToken);\n    }\n    if( ExprHasProperty(p, EP_xIsSelect) ){\n      sqlite3SelectDelete(db, p->x.pSelect);\n    }else{\n      sqlite3ExprListDelete(db, p->x.pList);\n    }\n  }\n  if( !ExprHasProperty(p, EP_Static) ){\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Return the number of bytes allocated for the expression structure \n** passed as the first argument. This is always one of EXPR_FULLSIZE,\n** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.\n*/\nstatic int exprStructSize(Expr *p){\n  if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;\n  if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;\n  return EXPR_FULLSIZE;\n}\n\n/*\n** The dupedExpr*Size() routines each return the number of bytes required\n** to store a copy of an expression or expression tree.  They differ in\n** how much of the tree is measured.\n**\n**     dupedExprStructSize()     Size of only the Expr structure \n**     dupedExprNodeSize()       Size of Expr + space for token\n**     dupedExprSize()           Expr + token + subtree components\n**\n***************************************************************************\n**\n** The dupedExprStructSize() function returns two values OR-ed together:  \n** (1) the space required for a copy of the Expr structure only and \n** (2) the EP_xxx flags that indicate what the structure size should be.\n** The return values is always one of:\n**\n**      EXPR_FULLSIZE\n**      EXPR_REDUCEDSIZE   | EP_Reduced\n**      EXPR_TOKENONLYSIZE | EP_TokenOnly\n**\n** The size of the structure can be found by masking the return value\n** of this routine with 0xfff.  The flags can be found by masking the\n** return value with EP_Reduced|EP_TokenOnly.\n**\n** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size\n** (unreduced) Expr objects as they or originally constructed by the parser.\n** During expression analysis, extra information is computed and moved into\n** later parts of teh Expr object and that extra information might get chopped\n** off if the expression is reduced.  Note also that it does not work to\n** make a EXPRDUP_REDUCE copy of a reduced expression.  It is only legal\n** to reduce a pristine expression tree from the parser.  The implementation\n** of dupedExprStructSize() contain multiple assert() statements that attempt\n** to enforce this constraint.\n*/\nstatic int dupedExprStructSize(Expr *p, int flags){\n  int nSize;\n  assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */\n  if( 0==(flags&EXPRDUP_REDUCE) ){\n    nSize = EXPR_FULLSIZE;\n  }else{\n    assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );\n    assert( !ExprHasProperty(p, EP_FromJoin) ); \n    assert( (p->flags2 & EP2_MallocedToken)==0 );\n    assert( (p->flags2 & EP2_Irreducible)==0 );\n    if( p->pLeft || p->pRight || p->x.pList ){\n      nSize = EXPR_REDUCEDSIZE | EP_Reduced;\n    }else{\n      nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly;\n    }\n  }\n  return nSize;\n}\n\n/*\n** This function returns the space in bytes required to store the copy \n** of the Expr structure and a copy of the Expr.u.zToken string (if that\n** string is defined.)\n*/\nstatic int dupedExprNodeSize(Expr *p, int flags){\n  int nByte = dupedExprStructSize(p, flags) & 0xfff;\n  if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n    nByte += sqlite3Strlen30(p->u.zToken)+1;\n  }\n  return ROUND8(nByte);\n}\n\n/*\n** Return the number of bytes required to create a duplicate of the \n** expression passed as the first argument. The second argument is a\n** mask containing EXPRDUP_XXX flags.\n**\n** The value returned includes space to create a copy of the Expr struct\n** itself and the buffer referred to by Expr.u.zToken, if any.\n**\n** If the EXPRDUP_REDUCE flag is set, then the return value includes \n** space to duplicate all Expr nodes in the tree formed by Expr.pLeft \n** and Expr.pRight variables (but not for any structures pointed to or \n** descended from the Expr.x.pList or Expr.x.pSelect variables).\n*/\nstatic int dupedExprSize(Expr *p, int flags){\n  int nByte = 0;\n  if( p ){\n    nByte = dupedExprNodeSize(p, flags);\n    if( flags&EXPRDUP_REDUCE ){\n      nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags);\n    }\n  }\n  return nByte;\n}\n\n/*\n** This function is similar to sqlite3ExprDup(), except that if pzBuffer \n** is not NULL then *pzBuffer is assumed to point to a buffer large enough \n** to store the copy of expression p, the copies of p->u.zToken\n** (if applicable), and the copies of the p->pLeft and p->pRight expressions,\n** if any. Before returning, *pzBuffer is set to the first byte passed the\n** portion of the buffer copied into by this function.\n*/\nstatic Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){\n  Expr *pNew = 0;                      /* Value to return */\n  if( p ){\n    const int isReduced = (flags&EXPRDUP_REDUCE);\n    u8 *zAlloc;\n    u32 staticFlag = 0;\n\n    assert( pzBuffer==0 || isReduced );\n\n    /* Figure out where to write the new Expr structure. */\n    if( pzBuffer ){\n      zAlloc = *pzBuffer;\n      staticFlag = EP_Static;\n    }else{\n      zAlloc = sqlite3DbMallocRaw(db, dupedExprSize(p, flags));\n    }\n    pNew = (Expr *)zAlloc;\n\n    if( pNew ){\n      /* Set nNewSize to the size allocated for the structure pointed to\n      ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or\n      ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed\n      ** by the copy of the p->u.zToken string (if any).\n      */\n      const unsigned nStructSize = dupedExprStructSize(p, flags);\n      const int nNewSize = nStructSize & 0xfff;\n      int nToken;\n      if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n        nToken = sqlite3Strlen30(p->u.zToken) + 1;\n      }else{\n        nToken = 0;\n      }\n      if( isReduced ){\n        assert( ExprHasProperty(p, EP_Reduced)==0 );\n        memcpy(zAlloc, p, nNewSize);\n      }else{\n        int nSize = exprStructSize(p);\n        memcpy(zAlloc, p, nSize);\n        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);\n      }\n\n      /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */\n      pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static);\n      pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);\n      pNew->flags |= staticFlag;\n\n      /* Copy the p->u.zToken string, if any. */\n      if( nToken ){\n        char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize];\n        memcpy(zToken, p->u.zToken, nToken);\n      }\n\n      if( 0==((p->flags|pNew->flags) & EP_TokenOnly) ){\n        /* Fill in the pNew->x.pSelect or pNew->x.pList member. */\n        if( ExprHasProperty(p, EP_xIsSelect) ){\n          pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, isReduced);\n        }else{\n          pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, isReduced);\n        }\n      }\n\n      /* Fill in pNew->pLeft and pNew->pRight. */\n      if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly) ){\n        zAlloc += dupedExprNodeSize(p, flags);\n        if( ExprHasProperty(pNew, EP_Reduced) ){\n          pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc);\n          pNew->pRight = exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc);\n        }\n        if( pzBuffer ){\n          *pzBuffer = zAlloc;\n        }\n      }else{\n        pNew->flags2 = 0;\n        if( !ExprHasAnyProperty(p, EP_TokenOnly) ){\n          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);\n          pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);\n        }\n      }\n\n    }\n  }\n  return pNew;\n}\n\n/*\n** The following group of routines make deep copies of expressions,\n** expression lists, ID lists, and select statements.  The copies can\n** be deleted (by being passed to their respective ...Delete() routines)\n** without effecting the originals.\n**\n** The expression list, ID, and source lists return by sqlite3ExprListDup(),\n** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded \n** by subsequent calls to sqlite*ListAppend() routines.\n**\n** Any tables that the SrcList might point to are not duplicated.\n**\n** The flags parameter contains a combination of the EXPRDUP_XXX flags.\n** If the EXPRDUP_REDUCE flag is set, then the structure returned is a\n** truncated version of the usual Expr structure that will be stored as\n** part of the in-memory representation of the database schema.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){\n  return exprDup(db, p, flags, 0);\n}\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){\n  ExprList *pNew;\n  struct ExprList_item *pItem, *pOldItem;\n  int i;\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  pNew->iECursor = 0;\n  pNew->nExpr = i = p->nExpr;\n  if( (flags & EXPRDUP_REDUCE)==0 ) for(i=1; i<p->nExpr; i+=i){}\n  pNew->a = pItem = sqlite3DbMallocRaw(db,  i*sizeof(p->a[0]) );\n  if( pItem==0 ){\n    sqlite3DbFree(db, pNew);\n    return 0;\n  } \n  pOldItem = p->a;\n  for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){\n    Expr *pOldExpr = pOldItem->pExpr;\n    pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);\n    pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);\n    pItem->sortOrder = pOldItem->sortOrder;\n    pItem->done = 0;\n    pItem->iOrderByCol = pOldItem->iOrderByCol;\n    pItem->iAlias = pOldItem->iAlias;\n  }\n  return pNew;\n}\n\n/*\n** If cursors, triggers, views and subqueries are all omitted from\n** the build, then none of the following routines, except for \n** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes\n** called with a NULL argument.\n*/\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \\\n || !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){\n  SrcList *pNew;\n  int i;\n  int nByte;\n  if( p==0 ) return 0;\n  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);\n  pNew = sqlite3DbMallocRaw(db, nByte );\n  if( pNew==0 ) return 0;\n  pNew->nSrc = pNew->nAlloc = p->nSrc;\n  for(i=0; i<p->nSrc; i++){\n    struct SrcList_item *pNewItem = &pNew->a[i];\n    struct SrcList_item *pOldItem = &p->a[i];\n    Table *pTab;\n    pNewItem->pSchema = pOldItem->pSchema;\n    pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase);\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);\n    pNewItem->jointype = pOldItem->jointype;\n    pNewItem->iCursor = pOldItem->iCursor;\n    pNewItem->addrFillSub = pOldItem->addrFillSub;\n    pNewItem->regReturn = pOldItem->regReturn;\n    pNewItem->isCorrelated = pOldItem->isCorrelated;\n    pNewItem->viaCoroutine = pOldItem->viaCoroutine;\n    pNewItem->zIndex = sqlite3DbStrDup(db, pOldItem->zIndex);\n    pNewItem->notIndexed = pOldItem->notIndexed;\n    pNewItem->pIndex = pOldItem->pIndex;\n    pTab = pNewItem->pTab = pOldItem->pTab;\n    if( pTab ){\n      pTab->nRef++;\n    }\n    pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags);\n    pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags);\n    pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing);\n    pNewItem->colUsed = pOldItem->colUsed;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){\n  IdList *pNew;\n  int i;\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  pNew->nId = p->nId;\n  pNew->a = sqlite3DbMallocRaw(db, p->nId*sizeof(p->a[0]) );\n  if( pNew->a==0 ){\n    sqlite3DbFree(db, pNew);\n    return 0;\n  }\n  /* Note that because the size of the allocation for p->a[] is not\n  ** necessarily a power of two, sqlite3IdListAppend() may not be called\n  ** on the duplicate created by this function. */\n  for(i=0; i<p->nId; i++){\n    struct IdList_item *pNewItem = &pNew->a[i];\n    struct IdList_item *pOldItem = &p->a[i];\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->idx = pOldItem->idx;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){\n  Select *pNew, *pPrior;\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRaw(db, sizeof(*p) );\n  if( pNew==0 ) return 0;\n  pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags);\n  pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags);\n  pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags);\n  pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags);\n  pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags);\n  pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags);\n  pNew->op = p->op;\n  pNew->pPrior = pPrior = sqlite3SelectDup(db, p->pPrior, flags);\n  if( pPrior ) pPrior->pNext = pNew;\n  pNew->pNext = 0;\n  pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags);\n  pNew->pOffset = sqlite3ExprDup(db, p->pOffset, flags);\n  pNew->iLimit = 0;\n  pNew->iOffset = 0;\n  pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;\n  pNew->pRightmost = 0;\n  pNew->addrOpenEphm[0] = -1;\n  pNew->addrOpenEphm[1] = -1;\n  pNew->addrOpenEphm[2] = -1;\n  return pNew;\n}\n#else\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){\n  assert( p==0 );\n  return 0;\n}\n#endif\n\n\n/*\n** Add a new element to the end of an expression list.  If pList is\n** initially NULL, then create a new expression list.\n**\n** If a memory allocation error occurs, the entire list is freed and\n** NULL is returned.  If non-NULL is returned, then it is guaranteed\n** that the new entry was successfully appended.\n*/\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to append. Might be NULL */\n  Expr *pExpr             /* Expression to be appended. Might be NULL */\n){\n  sqlite3 *db = pParse->db;\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(ExprList) );\n    if( pList==0 ){\n      goto no_mem;\n    }\n    pList->a = sqlite3DbMallocRaw(db, sizeof(pList->a[0]));\n    if( pList->a==0 ) goto no_mem;\n  }else if( (pList->nExpr & (pList->nExpr-1))==0 ){\n    struct ExprList_item *a;\n    assert( pList->nExpr>0 );\n    a = sqlite3DbRealloc(db, pList->a, pList->nExpr*2*sizeof(pList->a[0]));\n    if( a==0 ){\n      goto no_mem;\n    }\n    pList->a = a;\n  }\n  assert( pList->a!=0 );\n  if( 1 ){\n    struct ExprList_item *pItem = &pList->a[pList->nExpr++];\n    memset(pItem, 0, sizeof(*pItem));\n    pItem->pExpr = pExpr;\n  }\n  return pList;\n\nno_mem:     \n  /* Avoid leaking memory if malloc has failed. */\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3ExprListDelete(db, pList);\n  return 0;\n}\n\n/*\n** Set the ExprList.a[].zName element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pName should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetName(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  Token *pName,           /* Name to be added */\n  int dequote             /* True to cause the name to be dequoted */\n){\n  assert( pList!=0 || pParse->db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem;\n    assert( pList->nExpr>0 );\n    pItem = &pList->a[pList->nExpr-1];\n    assert( pItem->zName==0 );\n    pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);\n    if( dequote && pItem->zName ) sqlite3Dequote(pItem->zName);\n  }\n}\n\n/*\n** Set the ExprList.a[].zSpan element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pSpan should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  ExprSpan *pSpan         /* The span to be added */\n){\n  sqlite3 *db = pParse->db;\n  assert( pList!=0 || db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem = &pList->a[pList->nExpr-1];\n    assert( pList->nExpr>0 );\n    assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem->zSpan = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                    (int)(pSpan->zEnd - pSpan->zStart));\n  }\n}\n\n/*\n** If the expression list pEList contains more than iLimit elements,\n** leave an error message in pParse.\n*/\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(\n  Parse *pParse,\n  ExprList *pEList,\n  const char *zObject\n){\n  int mx = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];\n  testcase( pEList && pEList->nExpr==mx );\n  testcase( pEList && pEList->nExpr==mx+1 );\n  if( pEList && pEList->nExpr>mx ){\n    sqlite3ErrorMsg(pParse, \"too many columns in %s\", zObject);\n  }\n}\n\n/*\n** Delete an entire expression list.\n*/\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){\n  int i;\n  struct ExprList_item *pItem;\n  if( pList==0 ) return;\n  assert( pList->a!=0 || pList->nExpr==0 );\n  for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){\n    sqlite3ExprDelete(db, pItem->pExpr);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zSpan);\n  }\n  sqlite3DbFree(db, pList->a);\n  sqlite3DbFree(db, pList);\n}\n\n/*\n** These routines are Walker callbacks.  Walker.u.pi is a pointer\n** to an integer.  These routines are checking an expression to see\n** if it is a constant.  Set *Walker.u.pi to 0 if the expression is\n** not constant.\n**\n** These callback routines are used to implement the following:\n**\n**     sqlite3ExprIsConstant()\n**     sqlite3ExprIsConstantNotJoin()\n**     sqlite3ExprIsConstantOrFunction()\n**\n*/\nstatic int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){\n\n  /* If pWalker->u.i is 3 then any term of the expression that comes from\n  ** the ON or USING clauses of a join disqualifies the expression\n  ** from being considered constant. */\n  if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){\n    pWalker->u.i = 0;\n    return WRC_Abort;\n  }\n\n  switch( pExpr->op ){\n    /* Consider functions to be constant if all their arguments are constant\n    ** and pWalker->u.i==2 */\n    case TK_FUNCTION:\n      if( pWalker->u.i==2 ) return 0;\n      /* Fall through */\n    case TK_ID:\n    case TK_COLUMN:\n    case TK_AGG_FUNCTION:\n    case TK_AGG_COLUMN:\n      testcase( pExpr->op==TK_ID );\n      testcase( pExpr->op==TK_COLUMN );\n      testcase( pExpr->op==TK_AGG_FUNCTION );\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      pWalker->u.i = 0;\n      return WRC_Abort;\n    default:\n      testcase( pExpr->op==TK_SELECT ); /* selectNodeIsConstant will disallow */\n      testcase( pExpr->op==TK_EXISTS ); /* selectNodeIsConstant will disallow */\n      return WRC_Continue;\n  }\n}\nstatic int selectNodeIsConstant(Walker *pWalker, Select *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  pWalker->u.i = 0;\n  return WRC_Abort;\n}\nstatic int exprIsConst(Expr *p, int initFlag){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.u.i = initFlag;\n  w.xExprCallback = exprNodeIsConstant;\n  w.xSelectCallback = selectNodeIsConstant;\n  sqlite3WalkExpr(&w, p);\n  return w.u.i;\n}\n\n/*\n** Walk an expression tree.  Return 1 if the expression is constant\n** and 0 if it involves variables or function calls.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){\n  return exprIsConst(p, 1);\n}\n\n/*\n** Walk an expression tree.  Return 1 if the expression is constant\n** that does no originate from the ON or USING clauses of a join.\n** Return 0 if it involves variables or function calls or terms from\n** an ON or USING clause.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){\n  return exprIsConst(p, 3);\n}\n\n/*\n** Walk an expression tree.  Return 1 if the expression is constant\n** or a function call with constant arguments.  Return and 0 if there\n** are any variables.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p){\n  return exprIsConst(p, 2);\n}\n\n/*\n** If the expression p codes a constant integer that is small enough\n** to fit in a 32-bit integer, return 1 and put the value of the integer\n** in *pValue.  If the expression is not an integer or if it is too big\n** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){\n  int rc = 0;\n\n  /* If an expression is an integer literal that fits in a signed 32-bit\n  ** integer, then the EP_IntValue flag will have already been set */\n  assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0\n           || sqlite3GetInt32(p->u.zToken, &rc)==0 );\n\n  if( p->flags & EP_IntValue ){\n    *pValue = p->u.iValue;\n    return 1;\n  }\n  switch( p->op ){\n    case TK_UPLUS: {\n      rc = sqlite3ExprIsInteger(p->pLeft, pValue);\n      break;\n    }\n    case TK_UMINUS: {\n      int v;\n      if( sqlite3ExprIsInteger(p->pLeft, &v) ){\n        *pValue = -v;\n        rc = 1;\n      }\n      break;\n    }\n    default: break;\n  }\n  return rc;\n}\n\n/*\n** Return FALSE if there is no chance that the expression can be NULL.\n**\n** If the expression might be NULL or if the expression is too complex\n** to tell return TRUE.  \n**\n** This routine is used as an optimization, to skip OP_IsNull opcodes\n** when we know that a value cannot be NULL.  Hence, a false positive\n** (returning TRUE when in fact the expression can never be NULL) might\n** be a small performance hit but is otherwise harmless.  On the other\n** hand, a false negative (returning FALSE when the result could be NULL)\n** will likely result in an incorrect answer.  So when in doubt, return\n** TRUE.\n*/\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){\n  u8 op;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER:\n    case TK_STRING:\n    case TK_FLOAT:\n    case TK_BLOB:\n      return 0;\n    default:\n      return 1;\n  }\n}\n\n/*\n** Generate an OP_IsNull instruction that tests register iReg and jumps\n** to location iDest if the value in iReg is NULL.  The value in iReg \n** was computed by pExpr.  If we can look at pExpr at compile-time and\n** determine that it can never generate a NULL, then the OP_IsNull operation\n** can be omitted.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(\n  Vdbe *v,            /* The VDBE under construction */\n  const Expr *pExpr,  /* Only generate OP_IsNull if this expr can be NULL */\n  int iReg,           /* Test the value in this register for NULL */\n  int iDest           /* Jump here if the value is null */\n){\n  if( sqlite3ExprCanBeNull(pExpr) ){\n    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iDest);\n  }\n}\n\n/*\n** Return TRUE if the given expression is a constant which would be\n** unchanged by OP_Affinity with the affinity given in the second\n** argument.\n**\n** This routine is used to determine if the OP_Affinity operation\n** can be omitted.  When in doubt return FALSE.  A false negative\n** is harmless.  A false positive, however, can result in the wrong\n** answer.\n*/\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){\n  u8 op;\n  if( aff==SQLITE_AFF_NONE ) return 1;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER: {\n      return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_FLOAT: {\n      return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_STRING: {\n      return aff==SQLITE_AFF_TEXT;\n    }\n    case TK_BLOB: {\n      return 1;\n    }\n    case TK_COLUMN: {\n      assert( p->iTable>=0 );  /* p cannot be part of a CHECK constraint */\n      return p->iColumn<0\n          && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);\n    }\n    default: {\n      return 0;\n    }\n  }\n}\n\n/*\n** Return TRUE if the given string is a row-id column name.\n*/\nSQLITE_PRIVATE int sqlite3IsRowid(const char *z){\n  if( sqlite3StrICmp(z, \"_ROWID_\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"ROWID\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"OID\")==0 ) return 1;\n  return 0;\n}\n\n/*\n** Return true if we are able to the IN operator optimization on a\n** query of the form\n**\n**       x IN (SELECT ...)\n**\n** Where the SELECT... clause is as specified by the parameter to this\n** routine.\n**\n** The Select object passed in has already been preprocessed and no\n** errors have been found.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nstatic int isCandidateForInOpt(Select *p){\n  SrcList *pSrc;\n  ExprList *pEList;\n  Table *pTab;\n  if( p==0 ) return 0;                   /* right-hand side of IN is SELECT */\n  if( p->pPrior ) return 0;              /* Not a compound SELECT */\n  if( p->selFlags & (SF_Distinct|SF_Aggregate) ){\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n    return 0; /* No DISTINCT keyword and no aggregate functions */\n  }\n  assert( p->pGroupBy==0 );              /* Has no GROUP BY clause */\n  if( p->pLimit ) return 0;              /* Has no LIMIT clause */\n  assert( p->pOffset==0 );               /* No LIMIT means no OFFSET */\n  if( p->pWhere ) return 0;              /* Has no WHERE clause */\n  pSrc = p->pSrc;\n  assert( pSrc!=0 );\n  if( pSrc->nSrc!=1 ) return 0;          /* Single term in FROM clause */\n  if( pSrc->a[0].pSelect ) return 0;     /* FROM is not a subquery or view */\n  pTab = pSrc->a[0].pTab;\n  if( NEVER(pTab==0) ) return 0;\n  assert( pTab->pSelect==0 );            /* FROM clause is not a view */\n  if( IsVirtual(pTab) ) return 0;        /* FROM clause not a virtual table */\n  pEList = p->pEList;\n  if( pEList->nExpr!=1 ) return 0;       /* One column in the result set */\n  if( pEList->a[0].pExpr->op!=TK_COLUMN ) return 0; /* Result is a column */\n  return 1;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n/*\n** Code an OP_Once instruction and allocate space for its flag. Return the \n** address of the new instruction.\n*/\nSQLITE_PRIVATE int sqlite3CodeOnce(Parse *pParse){\n  Vdbe *v = sqlite3GetVdbe(pParse);      /* Virtual machine being coded */\n  return sqlite3VdbeAddOp1(v, OP_Once, pParse->nOnce++);\n}\n\n/*\n** This function is used by the implementation of the IN (...) operator.\n** The pX parameter is the expression on the RHS of the IN operator, which\n** might be either a list of expressions or a subquery.\n**\n** The job of this routine is to find or create a b-tree object that can\n** be used either to test for membership in the RHS set or to iterate through\n** all members of the RHS set, skipping duplicates.\n**\n** A cursor is opened on the b-tree object that the RHS of the IN operator\n** and pX->iTable is set to the index of that cursor.\n**\n** The returned value of this function indicates the b-tree type, as follows:\n**\n**   IN_INDEX_ROWID      - The cursor was opened on a database table.\n**   IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.\n**   IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.\n**   IN_INDEX_EPH        - The cursor was opened on a specially created and\n**                         populated epheremal table.\n**\n** An existing b-tree might be used if the RHS expression pX is a simple\n** subquery such as:\n**\n**     SELECT <column> FROM <table>\n**\n** If the RHS of the IN operator is a list or a more complex subquery, then\n** an ephemeral table might need to be generated from the RHS and then\n** pX->iTable made to point to the ephermeral table instead of an\n** existing table.  \n**\n** If the prNotFound parameter is 0, then the b-tree will be used to iterate\n** through the set members, skipping any duplicates. In this case an\n** epheremal table must be used unless the selected <column> is guaranteed\n** to be unique - either because it is an INTEGER PRIMARY KEY or it\n** has a UNIQUE constraint or UNIQUE index.\n**\n** If the prNotFound parameter is not 0, then the b-tree will be used \n** for fast set membership tests. In this case an epheremal table must \n** be used unless <column> is an INTEGER PRIMARY KEY or an index can \n** be found with <column> as its left-most column.\n**\n** When the b-tree is being used for membership tests, the calling function\n** needs to know whether or not the structure contains an SQL NULL \n** value in order to correctly evaluate expressions like \"X IN (Y, Z)\".\n** If there is any chance that the (...) might contain a NULL value at\n** runtime, then a register is allocated and the register number written\n** to *prNotFound. If there is no chance that the (...) contains a\n** NULL value, then *prNotFound is left unchanged.\n**\n** If a register is allocated and its location stored in *prNotFound, then\n** its initial value is NULL.  If the (...) does not remain constant\n** for the duration of the query (i.e. the SELECT within the (...)\n** is a correlated subquery) then the value of the allocated register is\n** reset to NULL each time the subquery is rerun. This allows the\n** caller to use vdbe code equivalent to the following:\n**\n**   if( register==NULL ){\n**     has_null = <test if data structure contains null>\n**     register = 1\n**   }\n**\n** in order to avoid running the <test if data structure contains null>\n** test more often than is necessary.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){\n  Select *p;                            /* SELECT to the right of IN operator */\n  int eType = 0;                        /* Type of RHS table. IN_INDEX_* */\n  int iTab = pParse->nTab++;            /* Cursor of the RHS table */\n  int mustBeUnique = (prNotFound==0);   /* True if RHS must be unique */\n  Vdbe *v = sqlite3GetVdbe(pParse);     /* Virtual machine being coded */\n\n  assert( pX->op==TK_IN );\n\n  /* Check to see if an existing table or index can be used to\n  ** satisfy the query.  This is preferable to generating a new \n  ** ephemeral table.\n  */\n  p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);\n  if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){\n    sqlite3 *db = pParse->db;              /* Database connection */\n    Table *pTab;                           /* Table <table>. */\n    Expr *pExpr;                           /* Expression <column> */\n    int iCol;                              /* Index of column <column> */\n    int iDb;                               /* Database idx for pTab */\n\n    assert( p );                        /* Because of isCandidateForInOpt(p) */\n    assert( p->pEList!=0 );             /* Because of isCandidateForInOpt(p) */\n    assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */\n    assert( p->pSrc!=0 );               /* Because of isCandidateForInOpt(p) */\n    pTab = p->pSrc->a[0].pTab;\n    pExpr = p->pEList->a[0].pExpr;\n    iCol = pExpr->iColumn;\n   \n    /* Code an OP_VerifyCookie and OP_TableLock for <table>. */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3CodeVerifySchema(pParse, iDb);\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n    /* This function is only called from two places. In both cases the vdbe\n    ** has already been allocated. So assume sqlite3GetVdbe() is always\n    ** successful here.\n    */\n    assert(v);\n    if( iCol<0 ){\n      int iAddr;\n\n      iAddr = sqlite3CodeOnce(pParse);\n\n      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n      eType = IN_INDEX_ROWID;\n\n      sqlite3VdbeJumpHere(v, iAddr);\n    }else{\n      Index *pIdx;                         /* Iterator variable */\n\n      /* The collation sequence used by the comparison. If an index is to\n      ** be used in place of a temp-table, it must be ordered according\n      ** to this collation sequence.  */\n      CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);\n\n      /* Check that the affinity that will be used to perform the \n      ** comparison is the same as the affinity of the column. If\n      ** it is not, it is not possible to use any index.\n      */\n      int affinity_ok = sqlite3IndexAffinityOk(pX, pTab->aCol[iCol].affinity);\n\n      for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){\n        if( (pIdx->aiColumn[0]==iCol)\n         && sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0)==pReq\n         && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None))\n        ){\n          int iAddr;\n          char *pKey;\n  \n          pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx);\n          iAddr = sqlite3CodeOnce(pParse);\n  \n          sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb,\n                               pKey,P4_KEYINFO_HANDOFF);\n          VdbeComment((v, \"%s\", pIdx->zName));\n          assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );\n          eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];\n\n          sqlite3VdbeJumpHere(v, iAddr);\n          if( prNotFound && !pTab->aCol[iCol].notNull ){\n            *prNotFound = ++pParse->nMem;\n            sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound);\n          }\n        }\n      }\n    }\n  }\n\n  if( eType==0 ){\n    /* Could not found an existing table or index to use as the RHS b-tree.\n    ** We will have to generate an ephemeral table to do the job.\n    */\n    double savedNQueryLoop = pParse->nQueryLoop;\n    int rMayHaveNull = 0;\n    eType = IN_INDEX_EPH;\n    if( prNotFound ){\n      *prNotFound = rMayHaveNull = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, *prNotFound);\n    }else{\n      testcase( pParse->nQueryLoop>(double)1 );\n      pParse->nQueryLoop = (double)1;\n      if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){\n        eType = IN_INDEX_ROWID;\n      }\n    }\n    sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);\n    pParse->nQueryLoop = savedNQueryLoop;\n  }else{\n    pX->iTable = iTab;\n  }\n  return eType;\n}\n#endif\n\n/*\n** Generate code for scalar subqueries used as a subquery expression, EXISTS,\n** or IN operators.  Examples:\n**\n**     (SELECT a FROM b)          -- subquery\n**     EXISTS (SELECT a FROM b)   -- EXISTS subquery\n**     x IN (4,5,11)              -- IN operator with list on right-hand side\n**     x IN (SELECT a FROM b)     -- IN operator with subquery on the right\n**\n** The pExpr parameter describes the expression that contains the IN\n** operator or subquery.\n**\n** If parameter isRowid is non-zero, then expression pExpr is guaranteed\n** to be of the form \"<rowid> IN (?, ?, ?)\", where <rowid> is a reference\n** to some integer key column of a table B-Tree. In this case, use an\n** intkey B-Tree to store the set of IN(...) values instead of the usual\n** (slower) variable length keys B-Tree.\n**\n** If rMayHaveNull is non-zero, that means that the operation is an IN\n** (not a SELECT or EXISTS) and that the RHS might contains NULLs.\n** Furthermore, the IN is in a WHERE clause and that we really want\n** to iterate over the RHS of the IN operator in order to quickly locate\n** all corresponding LHS elements.  All this routine does is initialize\n** the register given by rMayHaveNull to NULL.  Calling routines will take\n** care of changing this register value to non-NULL if the RHS is NULL-free.\n**\n** If rMayHaveNull is zero, that means that the subquery is being used\n** for membership testing only.  There is no need to initialize any\n** registers to indicate the presense or absence of NULLs on the RHS.\n**\n** For a SELECT or EXISTS operator, return the register that holds the\n** result.  For IN operators or if an error occurs, the return value is 0.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3CodeSubselect(\n  Parse *pParse,          /* Parsing context */\n  Expr *pExpr,            /* The IN, SELECT, or EXISTS operator */\n  int rMayHaveNull,       /* Register that records whether NULLs exist in RHS */\n  int isRowid             /* If true, LHS of IN operator is a rowid */\n){\n  int testAddr = -1;                      /* One-time test address */\n  int rReg = 0;                           /* Register storing resulting */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return 0;\n  sqlite3ExprCachePush(pParse);\n\n  /* This code must be run in its entirety every time it is encountered\n  ** if any of the following is true:\n  **\n  **    *  The right-hand side is a correlated subquery\n  **    *  The right-hand side is an expression list containing variables\n  **    *  We are inside a trigger\n  **\n  ** If all of the above are false, then we can run this code just once\n  ** save the results, and reuse the same result on subsequent invocations.\n  */\n  if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){\n    testAddr = sqlite3CodeOnce(pParse);\n  }\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( pParse->explain==2 ){\n    char *zMsg = sqlite3MPrintf(\n        pParse->db, \"EXECUTE %s%s SUBQUERY %d\", testAddr>=0?\"\":\"CORRELATED \",\n        pExpr->op==TK_IN?\"LIST\":\"SCALAR\", pParse->iNextSelectId\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n#endif\n\n  switch( pExpr->op ){\n    case TK_IN: {\n      char affinity;              /* Affinity of the LHS of the IN */\n      KeyInfo keyInfo;            /* Keyinfo for the generated table */\n      static u8 sortOrder = 0;    /* Fake aSortOrder for keyInfo */\n      int addr;                   /* Address of OP_OpenEphemeral instruction */\n      Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */\n\n      if( rMayHaveNull ){\n        sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull);\n      }\n\n      affinity = sqlite3ExprAffinity(pLeft);\n\n      /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'\n      ** expression it is handled the same way.  An ephemeral table is \n      ** filled with single-field index keys representing the results\n      ** from the SELECT or the <exprlist>.\n      **\n      ** If the 'x' expression is a column value, or the SELECT...\n      ** statement returns a column value, then the affinity of that\n      ** column is used to build the index keys. If both 'x' and the\n      ** SELECT... statement are columns, then numeric affinity is used\n      ** if either column has NUMERIC or INTEGER affinity. If neither\n      ** 'x' nor the SELECT... statement are columns, then numeric affinity\n      ** is used.\n      */\n      pExpr->iTable = pParse->nTab++;\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid);\n      if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n      memset(&keyInfo, 0, sizeof(keyInfo));\n      keyInfo.nField = 1;\n      keyInfo.aSortOrder = &sortOrder;\n\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* Case 1:     expr IN (SELECT ...)\n        **\n        ** Generate code to write the results of the select into the temporary\n        ** table allocated and opened above.\n        */\n        SelectDest dest;\n        ExprList *pEList;\n\n        assert( !isRowid );\n        sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);\n        dest.affSdst = (u8)affinity;\n        assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable );\n        pExpr->x.pSelect->iLimit = 0;\n        if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){\n          return 0;\n        }\n        pEList = pExpr->x.pSelect->pEList;\n        if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){ \n          keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft,\n              pEList->a[0].pExpr);\n        }\n      }else if( ALWAYS(pExpr->x.pList!=0) ){\n        /* Case 2:     expr IN (exprlist)\n        **\n        ** For each expression, build an index key from the evaluation and\n        ** store it in the temporary table. If <expr> is a column, then use\n        ** that columns affinity when building index keys. If <expr> is not\n        ** a column, use numeric affinity.\n        */\n        int i;\n        ExprList *pList = pExpr->x.pList;\n        struct ExprList_item *pItem;\n        int r1, r2, r3;\n\n        if( !affinity ){\n          affinity = SQLITE_AFF_NONE;\n        }\n        keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n        keyInfo.aSortOrder = &sortOrder;\n\n        /* Loop through each expression in <exprlist>. */\n        r1 = sqlite3GetTempReg(pParse);\n        r2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_Null, 0, r2);\n        for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){\n          Expr *pE2 = pItem->pExpr;\n          int iValToIns;\n\n          /* If the expression is not constant then we will need to\n          ** disable the test that was generated above that makes sure\n          ** this code only executes once.  Because for a non-constant\n          ** expression we need to rerun this code each time.\n          */\n          if( testAddr>=0 && !sqlite3ExprIsConstant(pE2) ){\n            sqlite3VdbeChangeToNoop(v, testAddr);\n            testAddr = -1;\n          }\n\n          /* Evaluate the expression and insert it into the temp table */\n          if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){\n            sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);\n          }else{\n            r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);\n            if( isRowid ){\n              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,\n                                sqlite3VdbeCurrentAddr(v)+2);\n              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);\n            }else{\n              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);\n              sqlite3ExprCacheAffinityChange(pParse, r3, 1);\n              sqlite3VdbeAddOp2(v, OP_IdxInsert, pExpr->iTable, r2);\n            }\n          }\n        }\n        sqlite3ReleaseTempReg(pParse, r1);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      if( !isRowid ){\n        sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO);\n      }\n      break;\n    }\n\n    case TK_EXISTS:\n    case TK_SELECT:\n    default: {\n      /* If this has to be a scalar SELECT.  Generate code to put the\n      ** value of this select in a memory cell and record the number\n      ** of the memory cell in iColumn.  If this is an EXISTS, write\n      ** an integer 0 (not exists) or 1 (exists) into a memory cell\n      ** and record that memory cell in iColumn.\n      */\n      Select *pSel;                         /* SELECT statement to encode */\n      SelectDest dest;                      /* How to deal with SELECt result */\n\n      testcase( pExpr->op==TK_EXISTS );\n      testcase( pExpr->op==TK_SELECT );\n      assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );\n\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n      pSel = pExpr->x.pSelect;\n      sqlite3SelectDestInit(&dest, 0, ++pParse->nMem);\n      if( pExpr->op==TK_SELECT ){\n        dest.eDest = SRT_Mem;\n        sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iSDParm);\n        VdbeComment((v, \"Init subquery result\"));\n      }else{\n        dest.eDest = SRT_Exists;\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);\n        VdbeComment((v, \"Init EXISTS result\"));\n      }\n      sqlite3ExprDelete(pParse->db, pSel->pLimit);\n      pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0,\n                                  &sqlite3IntTokens[1]);\n      pSel->iLimit = 0;\n      if( sqlite3Select(pParse, pSel, &dest) ){\n        return 0;\n      }\n      rReg = dest.iSDParm;\n      ExprSetIrreducible(pExpr);\n      break;\n    }\n  }\n\n  if( testAddr>=0 ){\n    sqlite3VdbeJumpHere(v, testAddr);\n  }\n  sqlite3ExprCachePop(pParse, 1);\n\n  return rReg;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code for an IN expression.\n**\n**      x IN (SELECT ...)\n**      x IN (value, value, ...)\n**\n** The left-hand side (LHS) is a scalar expression.  The right-hand side (RHS)\n** is an array of zero or more values.  The expression is true if the LHS is\n** contained within the RHS.  The value of the expression is unknown (NULL)\n** if the LHS is NULL or if the LHS is not contained within the RHS and the\n** RHS contains one or more NULL values.\n**\n** This routine generates code will jump to destIfFalse if the LHS is not \n** contained within the RHS.  If due to NULLs we cannot determine if the LHS\n** is contained in the RHS then jump to destIfNull.  If the LHS is contained\n** within the RHS then fall through.\n*/\nstatic void sqlite3ExprCodeIN(\n  Parse *pParse,        /* Parsing and code generating context */\n  Expr *pExpr,          /* The IN expression */\n  int destIfFalse,      /* Jump here if LHS is not contained in the RHS */\n  int destIfNull        /* Jump here if the results are unknown due to NULLs */\n){\n  int rRhsHasNull = 0;  /* Register that is true if RHS contains NULL values */\n  char affinity;        /* Comparison affinity to use */\n  int eType;            /* Type of the RHS */\n  int r1;               /* Temporary use register */\n  Vdbe *v;              /* Statement under construction */\n\n  /* Compute the RHS.   After this step, the table with cursor\n  ** pExpr->iTable will contains the values that make up the RHS.\n  */\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* OOM detected prior to this routine */\n  VdbeNoopComment((v, \"begin IN expr\"));\n  eType = sqlite3FindInIndex(pParse, pExpr, &rRhsHasNull);\n\n  /* Figure out the affinity to use to create a key from the results\n  ** of the expression. affinityStr stores a static string suitable for\n  ** P4 of OP_MakeRecord.\n  */\n  affinity = comparisonAffinity(pExpr);\n\n  /* Code the LHS, the <expr> from \"<expr> IN (...)\".\n  */\n  sqlite3ExprCachePush(pParse);\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3ExprCode(pParse, pExpr->pLeft, r1);\n\n  /* If the LHS is NULL, then the result is either false or NULL depending\n  ** on whether the RHS is empty or not, respectively.\n  */\n  if( destIfNull==destIfFalse ){\n    /* Shortcut for the common case where the false and NULL outcomes are\n    ** the same. */\n    sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull);\n  }else{\n    int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1);\n    sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);\n    sqlite3VdbeJumpHere(v, addr1);\n  }\n\n  if( eType==IN_INDEX_ROWID ){\n    /* In this case, the RHS is the ROWID of table b-tree\n    */\n    sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse);\n    sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1);\n  }else{\n    /* In this case, the RHS is an index b-tree.\n    */\n    sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1);\n\n    /* If the set membership test fails, then the result of the \n    ** \"x IN (...)\" expression must be either 0 or NULL. If the set\n    ** contains no NULL values, then the result is 0. If the set \n    ** contains one or more NULL values, then the result of the\n    ** expression is also NULL.\n    */\n    if( rRhsHasNull==0 || destIfFalse==destIfNull ){\n      /* This branch runs if it is known at compile time that the RHS\n      ** cannot contain NULL values. This happens as the result\n      ** of a \"NOT NULL\" constraint in the database schema.\n      **\n      ** Also run this branch if NULL is equivalent to FALSE\n      ** for this particular IN operator.\n      */\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse, r1, 1);\n\n    }else{\n      /* In this branch, the RHS of the IN might contain a NULL and\n      ** the presence of a NULL on the RHS makes a difference in the\n      ** outcome.\n      */\n      int j1, j2, j3;\n\n      /* First check to see if the LHS is contained in the RHS.  If so,\n      ** then the presence of NULLs in the RHS does not matter, so jump\n      ** over all of the code that follows.\n      */\n      j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1);\n\n      /* Here we begin generating code that runs if the LHS is not\n      ** contained within the RHS.  Generate additional code that\n      ** tests the RHS for NULLs.  If the RHS contains a NULL then\n      ** jump to destIfNull.  If there are no NULLs in the RHS then\n      ** jump to destIfFalse.\n      */\n      j2 = sqlite3VdbeAddOp1(v, OP_NotNull, rRhsHasNull);\n      j3 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, rRhsHasNull, 1);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, rRhsHasNull);\n      sqlite3VdbeJumpHere(v, j3);\n      sqlite3VdbeAddOp2(v, OP_AddImm, rRhsHasNull, 1);\n      sqlite3VdbeJumpHere(v, j2);\n\n      /* Jump to the appropriate target depending on whether or not\n      ** the RHS contains a NULL\n      */\n      sqlite3VdbeAddOp2(v, OP_If, rRhsHasNull, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);\n\n      /* The OP_Found at the top of this branch jumps here when true, \n      ** causing the overall IN expression evaluation to fall through.\n      */\n      sqlite3VdbeJumpHere(v, j1);\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, r1);\n  sqlite3ExprCachePop(pParse, 1);\n  VdbeComment((v, \"end IN expr\"));\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n/*\n** Duplicate an 8-byte value\n*/\nstatic char *dup8bytes(Vdbe *v, const char *in){\n  char *out = sqlite3DbMallocRaw(sqlite3VdbeDb(v), 8);\n  if( out ){\n    memcpy(out, in, 8);\n  }\n  return out;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Generate an instruction that will put the floating point\n** value described by z[0..n-1] into register iMem.\n**\n** The z[] string will probably not be zero-terminated.  But the \n** z[n] character is guaranteed to be something that does not look\n** like the continuation of the number.\n*/\nstatic void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){\n  if( ALWAYS(z!=0) ){\n    double value;\n    char *zV;\n    sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);\n    assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */\n    if( negateFlag ) value = -value;\n    zV = dup8bytes(v, (char*)&value);\n    sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL);\n  }\n}\n#endif\n\n\n/*\n** Generate an instruction that will put the integer describe by\n** text z[0..n-1] into register iMem.\n**\n** Expr.u.zToken is always UTF8 and zero-terminated.\n*/\nstatic void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){\n  Vdbe *v = pParse->pVdbe;\n  if( pExpr->flags & EP_IntValue ){\n    int i = pExpr->u.iValue;\n    assert( i>=0 );\n    if( negFlag ) i = -i;\n    sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);\n  }else{\n    int c;\n    i64 value;\n    const char *z = pExpr->u.zToken;\n    assert( z!=0 );\n    c = sqlite3Atoi64(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);\n    if( c==0 || (c==2 && negFlag) ){\n      char *zV;\n      if( negFlag ){ value = c==2 ? SMALLEST_INT64 : -value; }\n      zV = dup8bytes(v, (char*)&value);\n      sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64);\n    }else{\n#ifdef SQLITE_OMIT_FLOATING_POINT\n      sqlite3ErrorMsg(pParse, \"oversized integer: %s%s\", negFlag ? \"-\" : \"\", z);\n#else\n      codeReal(v, z, negFlag, iMem);\n#endif\n    }\n  }\n}\n\n/*\n** Clear a cache entry.\n*/\nstatic void cacheEntryClear(Parse *pParse, struct yColCache *p){\n  if( p->tempReg ){\n    if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n      pParse->aTempReg[pParse->nTempReg++] = p->iReg;\n    }\n    p->tempReg = 0;\n  }\n}\n\n\n/*\n** Record in the column cache that a particular column from a\n** particular table is stored in a particular register.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){\n  int i;\n  int minLru;\n  int idxLru;\n  struct yColCache *p;\n\n  assert( iReg>0 );  /* Register numbers are always positive */\n  assert( iCol>=-1 && iCol<32768 );  /* Finite column numbers */\n\n  /* The SQLITE_ColumnCache flag disables the column cache.  This is used\n  ** for testing only - to verify that SQLite always gets the same answer\n  ** with and without the column cache.\n  */\n  if( OptimizationDisabled(pParse->db, SQLITE_ColumnCache) ) return;\n\n  /* First replace any existing entry.\n  **\n  ** Actually, the way the column cache is currently used, we are guaranteed\n  ** that the object will never already be in cache.  Verify this guarantee.\n  */\n#ifndef NDEBUG\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );\n  }\n#endif\n\n  /* Find an empty slot and replace it */\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->iReg==0 ){\n      p->iLevel = pParse->iCacheLevel;\n      p->iTable = iTab;\n      p->iColumn = iCol;\n      p->iReg = iReg;\n      p->tempReg = 0;\n      p->lru = pParse->iCacheCnt++;\n      return;\n    }\n  }\n\n  /* Replace the last recently used */\n  minLru = 0x7fffffff;\n  idxLru = -1;\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->lru<minLru ){\n      idxLru = i;\n      minLru = p->lru;\n    }\n  }\n  if( ALWAYS(idxLru>=0) ){\n    p = &pParse->aColCache[idxLru];\n    p->iLevel = pParse->iCacheLevel;\n    p->iTable = iTab;\n    p->iColumn = iCol;\n    p->iReg = iReg;\n    p->tempReg = 0;\n    p->lru = pParse->iCacheCnt++;\n    return;\n  }\n}\n\n/*\n** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.\n** Purge the range of registers from the column cache.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){\n  int i;\n  int iLast = iReg + nReg - 1;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    int r = p->iReg;\n    if( r>=iReg && r<=iLast ){\n      cacheEntryClear(pParse, p);\n      p->iReg = 0;\n    }\n  }\n}\n\n/*\n** Remember the current column cache context.  Any new entries added\n** added to the column cache after this call are removed when the\n** corresponding pop occurs.\n*/\nSQLITE_PRIVATE void sqlite3ExprCachePush(Parse *pParse){\n  pParse->iCacheLevel++;\n}\n\n/*\n** Remove from the column cache any entries that were added since the\n** the previous N Push operations.  In other words, restore the cache\n** to the state it was in N Pushes ago.\n*/\nSQLITE_PRIVATE void sqlite3ExprCachePop(Parse *pParse, int N){\n  int i;\n  struct yColCache *p;\n  assert( N>0 );\n  assert( pParse->iCacheLevel>=N );\n  pParse->iCacheLevel -= N;\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->iReg && p->iLevel>pParse->iCacheLevel ){\n      cacheEntryClear(pParse, p);\n      p->iReg = 0;\n    }\n  }\n}\n\n/*\n** When a cached column is reused, make sure that its register is\n** no longer available as a temp register.  ticket #3879:  that same\n** register might be in the cache in multiple places, so be sure to\n** get them all.\n*/\nstatic void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->iReg==iReg ){\n      p->tempReg = 0;\n    }\n  }\n}\n\n/*\n** Generate code to extract the value of the iCol-th column of a table.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(\n  Vdbe *v,        /* The VDBE under construction */\n  Table *pTab,    /* The table containing the value */\n  int iTabCur,    /* The cursor for this table */\n  int iCol,       /* Index of the column to extract */\n  int regOut      /* Extract the valud into this register */\n){\n  if( iCol<0 || iCol==pTab->iPKey ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);\n  }else{\n    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;\n    sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut);\n  }\n  if( iCol>=0 ){\n    sqlite3ColumnDefault(v, pTab, iCol, regOut);\n  }\n}\n\n/*\n** Generate code that will extract the iColumn-th column from\n** table pTab and store the column value in a register.  An effort\n** is made to store the column value in register iReg, but this is\n** not guaranteed.  The location of the column value is returned.\n**\n** There must be an open cursor to pTab in iTable when this routine\n** is called.  If iColumn<0 then code is generated that extracts the rowid.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg,        /* Store results here */\n  u8 p5            /* P5 value for OP_Column */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct yColCache *p;\n\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn ){\n      p->lru = pParse->iCacheCnt++;\n      sqlite3ExprCachePinRegister(pParse, p->iReg);\n      return p->iReg;\n    }\n  }  \n  assert( v!=0 );\n  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);\n  if( p5 ){\n    sqlite3VdbeChangeP5(v, p5);\n  }else{   \n    sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);\n  }\n  return iReg;\n}\n\n/*\n** Clear all column cache entries.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){\n  int i;\n  struct yColCache *p;\n\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    if( p->iReg ){\n      cacheEntryClear(pParse, p);\n      p->iReg = 0;\n    }\n  }\n}\n\n/*\n** Record the fact that an affinity change has occurred on iCount\n** registers starting with iStart.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){\n  sqlite3ExprCacheRemove(pParse, iStart, iCount);\n}\n\n/*\n** Generate code to move content from registers iFrom...iFrom+nReg-1\n** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){\n  int i;\n  struct yColCache *p;\n  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );\n  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg-1);\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    int x = p->iReg;\n    if( x>=iFrom && x<iFrom+nReg ){\n      p->iReg += iTo-iFrom;\n    }\n  }\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n/*\n** Return true if any register in the range iFrom..iTo (inclusive)\n** is used as part of the column cache.\n**\n** This routine is used within assert() and testcase() macros only\n** and does not appear in a normal build.\n*/\nstatic int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n    int r = p->iReg;\n    if( r>=iFrom && r<=iTo ) return 1;    /*NO_TEST*/\n  }\n  return 0;\n}\n#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */\n\n/*\n** Generate code into the current Vdbe to evaluate the given\n** expression.  Attempt to store the results in register \"target\".\n** Return the register where results are stored.\n**\n** With this routine, there is no guarantee that results will\n** be stored in target.  The result might be stored in some other\n** register if it is convenient to do so.  The calling function\n** must check the return code and move the results to the desired\n** register.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;  /* The VM under construction */\n  int op;                   /* The opcode being coded */\n  int inReg = target;       /* Results stored in register inReg */\n  int regFree1 = 0;         /* If non-zero free this temporary register */\n  int regFree2 = 0;         /* If non-zero free this temporary register */\n  int r1, r2, r3, r4;       /* Various register numbers */\n  sqlite3 *db = pParse->db; /* The database connection */\n\n  assert( target>0 && target<=pParse->nMem );\n  if( v==0 ){\n    assert( pParse->db->mallocFailed );\n    return 0;\n  }\n\n  if( pExpr==0 ){\n    op = TK_NULL;\n  }else{\n    op = pExpr->op;\n  }\n  switch( op ){\n    case TK_AGG_COLUMN: {\n      AggInfo *pAggInfo = pExpr->pAggInfo;\n      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];\n      if( !pAggInfo->directMode ){\n        assert( pCol->iMem>0 );\n        inReg = pCol->iMem;\n        break;\n      }else if( pAggInfo->useSortingIdx ){\n        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,\n                              pCol->iSorterColumn, target);\n        break;\n      }\n      /* Otherwise, fall thru into the TK_COLUMN case */\n    }\n    case TK_COLUMN: {\n      if( pExpr->iTable<0 ){\n        /* This only happens when coding check constraints */\n        assert( pParse->ckBase>0 );\n        inReg = pExpr->iColumn + pParse->ckBase;\n      }else{\n        inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,\n                                 pExpr->iColumn, pExpr->iTable, target,\n                                 pExpr->op2);\n      }\n      break;\n    }\n    case TK_INTEGER: {\n      codeInteger(pParse, pExpr, 0, target);\n      break;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      codeReal(v, pExpr->u.zToken, 0, target);\n      break;\n    }\n#endif\n    case TK_STRING: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);\n      break;\n    }\n    case TK_NULL: {\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      break;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      int n;\n      const char *z;\n      char *zBlob;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n      assert( pExpr->u.zToken[1]=='\\'' );\n      z = &pExpr->u.zToken[2];\n      n = sqlite3Strlen30(z) - 1;\n      assert( z[n]=='\\'' );\n      zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n);\n      sqlite3VdbeAddOp4(v, OP_Blob, n/2, target, 0, zBlob, P4_DYNAMIC);\n      break;\n    }\n#endif\n    case TK_VARIABLE: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken!=0 );\n      assert( pExpr->u.zToken[0]!=0 );\n      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);\n      if( pExpr->u.zToken[1]!=0 ){\n        assert( pExpr->u.zToken[0]=='?' \n             || strcmp(pExpr->u.zToken, pParse->azVar[pExpr->iColumn-1])==0 );\n        sqlite3VdbeChangeP4(v, -1, pParse->azVar[pExpr->iColumn-1], P4_STATIC);\n      }\n      break;\n    }\n    case TK_REGISTER: {\n      inReg = pExpr->iTable;\n      break;\n    }\n    case TK_AS: {\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      break;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      int aff, to_op;\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      aff = sqlite3AffinityType(pExpr->u.zToken);\n      to_op = aff - SQLITE_AFF_TEXT + OP_ToText;\n      assert( to_op==OP_ToText    || aff!=SQLITE_AFF_TEXT    );\n      assert( to_op==OP_ToBlob    || aff!=SQLITE_AFF_NONE    );\n      assert( to_op==OP_ToNumeric || aff!=SQLITE_AFF_NUMERIC );\n      assert( to_op==OP_ToInt     || aff!=SQLITE_AFF_INTEGER );\n      assert( to_op==OP_ToReal    || aff!=SQLITE_AFF_REAL    );\n      testcase( to_op==OP_ToText );\n      testcase( to_op==OP_ToBlob );\n      testcase( to_op==OP_ToNumeric );\n      testcase( to_op==OP_ToInt );\n      testcase( to_op==OP_ToReal );\n      if( inReg!=target ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);\n        inReg = target;\n      }\n      sqlite3VdbeAddOp1(v, to_op, inReg);\n      testcase( usedAsColumnCache(pParse, inReg, inReg) );\n      sqlite3ExprCacheAffinityChange(pParse, inReg, 1);\n      break;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      assert( TK_LT==OP_Lt );\n      assert( TK_LE==OP_Le );\n      assert( TK_GT==OP_Gt );\n      assert( TK_GE==OP_Ge );\n      assert( TK_EQ==OP_Eq );\n      assert( TK_NE==OP_Ne );\n      testcase( op==TK_LT );\n      testcase( op==TK_LE );\n      testcase( op==TK_GT );\n      testcase( op==TK_GE );\n      testcase( op==TK_EQ );\n      testcase( op==TK_NE );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, inReg, SQLITE_STOREP2);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT: {\n      testcase( op==TK_IS );\n      testcase( op==TK_ISNOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_AND:\n    case TK_OR:\n    case TK_PLUS:\n    case TK_STAR:\n    case TK_MINUS:\n    case TK_REM:\n    case TK_BITAND:\n    case TK_BITOR:\n    case TK_SLASH:\n    case TK_LSHIFT:\n    case TK_RSHIFT: \n    case TK_CONCAT: {\n      assert( TK_AND==OP_And );\n      assert( TK_OR==OP_Or );\n      assert( TK_PLUS==OP_Add );\n      assert( TK_MINUS==OP_Subtract );\n      assert( TK_REM==OP_Remainder );\n      assert( TK_BITAND==OP_BitAnd );\n      assert( TK_BITOR==OP_BitOr );\n      assert( TK_SLASH==OP_Divide );\n      assert( TK_LSHIFT==OP_ShiftLeft );\n      assert( TK_RSHIFT==OP_ShiftRight );\n      assert( TK_CONCAT==OP_Concat );\n      testcase( op==TK_AND );\n      testcase( op==TK_OR );\n      testcase( op==TK_PLUS );\n      testcase( op==TK_MINUS );\n      testcase( op==TK_REM );\n      testcase( op==TK_BITAND );\n      testcase( op==TK_BITOR );\n      testcase( op==TK_SLASH );\n      testcase( op==TK_LSHIFT );\n      testcase( op==TK_RSHIFT );\n      testcase( op==TK_CONCAT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      sqlite3VdbeAddOp3(v, op, r2, r1, target);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_UMINUS: {\n      Expr *pLeft = pExpr->pLeft;\n      assert( pLeft );\n      if( pLeft->op==TK_INTEGER ){\n        codeInteger(pParse, pLeft, 1, target);\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      }else if( pLeft->op==TK_FLOAT ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        codeReal(v, pLeft->u.zToken, 1, target);\n#endif\n      }else{\n        regFree1 = r1 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);\n        sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);\n        testcase( regFree2==0 );\n      }\n      inReg = target;\n      break;\n    }\n    case TK_BITNOT:\n    case TK_NOT: {\n      assert( TK_BITNOT==OP_BitNot );\n      assert( TK_NOT==OP_Not );\n      testcase( op==TK_BITNOT );\n      testcase( op==TK_NOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      inReg = target;\n      sqlite3VdbeAddOp2(v, op, r1, inReg);\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      int addr;\n      assert( TK_ISNULL==OP_IsNull );\n      assert( TK_NOTNULL==OP_NotNull );\n      testcase( op==TK_ISNULL );\n      testcase( op==TK_NOTNULL );\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      addr = sqlite3VdbeAddOp1(v, op, r1);\n      sqlite3VdbeAddOp2(v, OP_AddImm, target, -1);\n      sqlite3VdbeJumpHere(v, addr);\n      break;\n    }\n    case TK_AGG_FUNCTION: {\n      AggInfo *pInfo = pExpr->pAggInfo;\n      if( pInfo==0 ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate: %s()\", pExpr->u.zToken);\n      }else{\n        inReg = pInfo->aFunc[pExpr->iAgg].iMem;\n      }\n      break;\n    }\n    case TK_CONST_FUNC:\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      int nFarg;             /* Number of function arguments */\n      FuncDef *pDef;         /* The function definition object */\n      int nId;               /* Length of the function name in bytes */\n      const char *zId;       /* The function name */\n      int constMask = 0;     /* Mask of function arguments that are constant */\n      int i;                 /* Loop counter */\n      u8 enc = ENC(db);      /* The text encoding used by this database */\n      CollSeq *pColl = 0;    /* A collating sequence */\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      testcase( op==TK_CONST_FUNC );\n      testcase( op==TK_FUNCTION );\n      if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      nFarg = pFarg ? pFarg->nExpr : 0;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      zId = pExpr->u.zToken;\n      nId = sqlite3Strlen30(zId);\n      pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0);\n      if( pDef==0 ){\n        sqlite3ErrorMsg(pParse, \"unknown function: %.*s()\", nId, zId);\n        break;\n      }\n\n      /* Attempt a direct implementation of the built-in COALESCE() and\n      ** IFNULL() functions.  This avoids unnecessary evalation of\n      ** arguments past the first non-NULL argument.\n      */\n      if( pDef->flags & SQLITE_FUNC_COALESCE ){\n        int endCoalesce = sqlite3VdbeMakeLabel(v);\n        assert( nFarg>=2 );\n        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);\n        for(i=1; i<nFarg; i++){\n          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);\n          sqlite3ExprCacheRemove(pParse, target, 1);\n          sqlite3ExprCachePush(pParse);\n          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);\n          sqlite3ExprCachePop(pParse, 1);\n        }\n        sqlite3VdbeResolveLabel(v, endCoalesce);\n        break;\n      }\n\n\n      if( pFarg ){\n        r1 = sqlite3GetTempRange(pParse, nFarg);\n\n        /* For length() and typeof() functions with a column argument,\n        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG\n        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data\n        ** loading.\n        */\n        if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){\n          u8 exprOp;\n          assert( nFarg==1 );\n          assert( pFarg->a[0].pExpr!=0 );\n          exprOp = pFarg->a[0].pExpr->op;\n          if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){\n            assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );\n            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );\n            testcase( pDef->flags==SQLITE_FUNC_LENGTH );\n            pFarg->a[0].pExpr->op2 = pDef->flags;\n          }\n        }\n\n        sqlite3ExprCachePush(pParse);     /* Ticket 2ea2425d34be */\n        sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);\n        sqlite3ExprCachePop(pParse, 1);   /* Ticket 2ea2425d34be */\n      }else{\n        r1 = 0;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* Possibly overload the function if the first argument is\n      ** a virtual table column.\n      **\n      ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the\n      ** second argument, not the first, as the argument to test to\n      ** see if it is a column in a virtual table.  This is done because\n      ** the left operand of infix functions (the operand we want to\n      ** control overloading) ends up as the second argument to the\n      ** function.  The expression \"A glob B\" is equivalent to \n      ** \"glob(B,A).  We want to use the A in \"A glob B\" to test\n      ** for function overloading.  But we use the B term in \"glob(B,A)\".\n      */\n      if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);\n      }else if( nFarg>0 ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);\n      }\n#endif\n      for(i=0; i<nFarg; i++){\n        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){\n          constMask |= (1<<i);\n        }\n        if( (pDef->flags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){\n          pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);\n        }\n      }\n      if( pDef->flags & SQLITE_FUNC_NEEDCOLL ){\n        if( !pColl ) pColl = db->pDfltColl; \n        sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);\n      }\n      sqlite3VdbeAddOp4(v, OP_Function, constMask, r1, target,\n                        (char*)pDef, P4_FUNCDEF);\n      sqlite3VdbeChangeP5(v, (u8)nFarg);\n      if( nFarg ){\n        sqlite3ReleaseTempRange(pParse, r1, nFarg);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS:\n    case TK_SELECT: {\n      testcase( op==TK_EXISTS );\n      testcase( op==TK_SELECT );\n      inReg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);\n      break;\n    }\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);\n      sqlite3VdbeResolveLabel(v, destIfNull);\n      break;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      Expr *pLeft = pExpr->pLeft;\n      struct ExprList_item *pLItem = pExpr->x.pList->a;\n      Expr *pRight = pLItem->pExpr;\n\n      r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      r3 = sqlite3GetTempReg(pParse);\n      r4 = sqlite3GetTempReg(pParse);\n      codeCompare(pParse, pLeft, pRight, OP_Ge,\n                  r1, r2, r3, SQLITE_STOREP2);\n      pLItem++;\n      pRight = pLItem->pExpr;\n      sqlite3ReleaseTempReg(pParse, regFree2);\n      r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);\n      testcase( regFree2==0 );\n      codeCompare(pParse, pLeft, pRight, OP_Le, r1, r2, r4, SQLITE_STOREP2);\n      sqlite3VdbeAddOp3(v, OP_And, r3, r4, target);\n      sqlite3ReleaseTempReg(pParse, r3);\n      sqlite3ReleaseTempReg(pParse, r4);\n      break;\n    }\n    case TK_COLLATE: \n    case TK_UPLUS: {\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      break;\n    }\n\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      **\n      ** The expression is implemented using an OP_Param opcode. The p1\n      ** parameter is set to 0 for an old.rowid reference, or to (i+1)\n      ** to reference another column of the old.* pseudo-table, where \n      ** i is the index of the column. For a new.rowid reference, p1 is\n      ** set to (n+1), where n is the number of columns in each pseudo-table.\n      ** For a reference to any other column in the new.* pseudo-table, p1\n      ** is set to (n+2+i), where n and i are as defined previously. For\n      ** example, if the table on which triggers are being fired is\n      ** declared as:\n      **\n      **   CREATE TABLE t1(a, b);\n      **\n      ** Then p1 is interpreted as follows:\n      **\n      **   p1==0   ->    old.rowid     p1==3   ->    new.rowid\n      **   p1==1   ->    old.a         p1==4   ->    new.a\n      **   p1==2   ->    old.b         p1==5   ->    new.b       \n      */\n      Table *pTab = pExpr->pTab;\n      int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;\n\n      assert( pExpr->iTable==0 || pExpr->iTable==1 );\n      assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );\n      assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );\n      assert( p1>=0 && p1<(pTab->nCol*2+2) );\n\n      sqlite3VdbeAddOp2(v, OP_Param, p1, target);\n      VdbeComment((v, \"%s.%s -> $%d\",\n        (pExpr->iTable ? \"new\" : \"old\"),\n        (pExpr->iColumn<0 ? \"rowid\" : pExpr->pTab->aCol[pExpr->iColumn].zName),\n        target\n      ));\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      /* If the column has REAL affinity, it may currently be stored as an\n      ** integer. Use OP_RealAffinity to make sure it is really real.  */\n      if( pExpr->iColumn>=0 \n       && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL\n      ){\n        sqlite3VdbeAddOp1(v, OP_RealAffinity, target);\n      }\n#endif\n      break;\n    }\n\n\n    /*\n    ** Form A:\n    **   CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form B:\n    **   CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form A is can be transformed into the equivalent form B as follows:\n    **   CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...\n    **        WHEN x=eN THEN rN ELSE y END\n    **\n    ** X (if it exists) is in pExpr->pLeft.\n    ** Y is in pExpr->pRight.  The Y is also optional.  If there is no\n    ** ELSE clause and no other term matches, then the result of the\n    ** exprssion is NULL.\n    ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].\n    **\n    ** The result of the expression is the Ri for the first matching Ei,\n    ** or if there is no matching Ei, the ELSE term Y, or if there is\n    ** no ELSE term, NULL.\n    */\n    default: assert( op==TK_CASE ); {\n      int endLabel;                     /* GOTO label for end of CASE stmt */\n      int nextCase;                     /* GOTO label for next WHEN clause */\n      int nExpr;                        /* 2x number of WHEN terms */\n      int i;                            /* Loop counter */\n      ExprList *pEList;                 /* List of WHEN terms */\n      struct ExprList_item *aListelem;  /* Array of WHEN terms */\n      Expr opCompare;                   /* The X==Ei expression */\n      Expr cacheX;                      /* Cached expression X */\n      Expr *pX;                         /* The X expression */\n      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */\n      VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );\n      assert((pExpr->x.pList->nExpr % 2) == 0);\n      assert(pExpr->x.pList->nExpr > 0);\n      pEList = pExpr->x.pList;\n      aListelem = pEList->a;\n      nExpr = pEList->nExpr;\n      endLabel = sqlite3VdbeMakeLabel(v);\n      if( (pX = pExpr->pLeft)!=0 ){\n        cacheX = *pX;\n        testcase( pX->op==TK_COLUMN );\n        testcase( pX->op==TK_REGISTER );\n        cacheX.iTable = sqlite3ExprCodeTemp(pParse, pX, &regFree1);\n        testcase( regFree1==0 );\n        cacheX.op = TK_REGISTER;\n        opCompare.op = TK_EQ;\n        opCompare.pLeft = &cacheX;\n        pTest = &opCompare;\n        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:\n        ** The value in regFree1 might get SCopy-ed into the file result.\n        ** So make sure that the regFree1 register is not reused for other\n        ** purposes and possibly overwritten.  */\n        regFree1 = 0;\n      }\n      for(i=0; i<nExpr; i=i+2){\n        sqlite3ExprCachePush(pParse);\n        if( pX ){\n          assert( pTest!=0 );\n          opCompare.pRight = aListelem[i].pExpr;\n        }else{\n          pTest = aListelem[i].pExpr;\n        }\n        nextCase = sqlite3VdbeMakeLabel(v);\n        testcase( pTest->op==TK_COLUMN );\n        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);\n        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );\n        testcase( aListelem[i+1].pExpr->op==TK_REGISTER );\n        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, endLabel);\n        sqlite3ExprCachePop(pParse, 1);\n        sqlite3VdbeResolveLabel(v, nextCase);\n      }\n      if( pExpr->pRight ){\n        sqlite3ExprCachePush(pParse);\n        sqlite3ExprCode(pParse, pExpr->pRight, target);\n        sqlite3ExprCachePop(pParse, 1);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      }\n      assert( db->mallocFailed || pParse->nErr>0 \n           || pParse->iCacheLevel==iCacheLevel );\n      sqlite3VdbeResolveLabel(v, endLabel);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      assert( pExpr->affinity==OE_Rollback \n           || pExpr->affinity==OE_Abort\n           || pExpr->affinity==OE_Fail\n           || pExpr->affinity==OE_Ignore\n      );\n      if( !pParse->pTriggerTab ){\n        sqlite3ErrorMsg(pParse,\n                       \"RAISE() may only be used within a trigger-program\");\n        return 0;\n      }\n      if( pExpr->affinity==OE_Abort ){\n        sqlite3MayAbort(pParse);\n      }\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      if( pExpr->affinity==OE_Ignore ){\n        sqlite3VdbeAddOp4(\n            v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);\n      }else{\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,\n                              pExpr->affinity, pExpr->u.zToken, 0);\n      }\n\n      break;\n    }\n#endif\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n  return inReg;\n}\n\n/*\n** Generate code to evaluate an expression and store the results\n** into a register.  Return the register number where the results\n** are stored.\n**\n** If the register is a temporary register that can be deallocated,\n** then write its number into *pReg.  If the result register is not\n** a temporary, then set *pReg to zero.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){\n  int r1 = sqlite3GetTempReg(pParse);\n  int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);\n  if( r2==r1 ){\n    *pReg = r1;\n  }else{\n    sqlite3ReleaseTempReg(pParse, r1);\n    *pReg = 0;\n  }\n  return r2;\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.\n*/\nSQLITE_PRIVATE int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){\n  int inReg;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( pExpr && pExpr->op==TK_REGISTER ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);\n  }else{\n    inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);\n    assert( pParse->pVdbe || pParse->db->mallocFailed );\n    if( inReg!=target && pParse->pVdbe ){\n      sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);\n    }\n  }\n  return target;\n}\n\n/*\n** Generate code that evalutes the given expression and puts the result\n** in register target.\n**\n** Also make a copy of the expression results into another \"cache\" register\n** and modify the expression so that the next time it is evaluated,\n** the result is a copy of the cache register.\n**\n** This routine is used for expressions that are used multiple \n** times.  They are evaluated once and the results of the expression\n** are reused.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;\n  int inReg;\n  inReg = sqlite3ExprCode(pParse, pExpr, target);\n  assert( target>0 );\n  /* This routine is called for terms to INSERT or UPDATE.  And the only\n  ** other place where expressions can be converted into TK_REGISTER is\n  ** in WHERE clause processing.  So as currently implemented, there is\n  ** no way for a TK_REGISTER to exist here.  But it seems prudent to\n  ** keep the ALWAYS() in case the conditions above change with future\n  ** modifications or enhancements. */\n  if( ALWAYS(pExpr->op!=TK_REGISTER) ){  \n    int iMem;\n    iMem = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, inReg, iMem);\n    pExpr->iTable = iMem;\n    pExpr->op2 = pExpr->op;\n    pExpr->op = TK_REGISTER;\n  }\n  return inReg;\n}\n\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n/*\n** Generate a human-readable explanation of an expression tree.\n*/\nSQLITE_PRIVATE void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){\n  int op;                   /* The opcode being coded */\n  const char *zBinOp = 0;   /* Binary operator */\n  const char *zUniOp = 0;   /* Unary operator */\n  if( pExpr==0 ){\n    op = TK_NULL;\n  }else{\n    op = pExpr->op;\n  }\n  switch( op ){\n    case TK_AGG_COLUMN: {\n      sqlite3ExplainPrintf(pOut, \"AGG{%d:%d}\",\n            pExpr->iTable, pExpr->iColumn);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iTable<0 ){\n        /* This only happens when coding check constraints */\n        sqlite3ExplainPrintf(pOut, \"COLUMN(%d)\", pExpr->iColumn);\n      }else{\n        sqlite3ExplainPrintf(pOut, \"{%d:%d}\",\n                             pExpr->iTable, pExpr->iColumn);\n      }\n      break;\n    }\n    case TK_INTEGER: {\n      if( pExpr->flags & EP_IntValue ){\n        sqlite3ExplainPrintf(pOut, \"%d\", pExpr->u.iValue);\n      }else{\n        sqlite3ExplainPrintf(pOut, \"%s\", pExpr->u.zToken);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      sqlite3ExplainPrintf(pOut,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_STRING: {\n      sqlite3ExplainPrintf(pOut,\"%Q\", pExpr->u.zToken);\n      break;\n    }\n    case TK_NULL: {\n      sqlite3ExplainPrintf(pOut,\"NULL\");\n      break;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      sqlite3ExplainPrintf(pOut,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_VARIABLE: {\n      sqlite3ExplainPrintf(pOut,\"VARIABLE(%s,%d)\",\n                           pExpr->u.zToken, pExpr->iColumn);\n      break;\n    }\n    case TK_REGISTER: {\n      sqlite3ExplainPrintf(pOut,\"REGISTER(%d)\", pExpr->iTable);\n      break;\n    }\n    case TK_AS: {\n      sqlite3ExplainExpr(pOut, pExpr->pLeft);\n      break;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      const char *zAff = \"unk\";\n      switch( sqlite3AffinityType(pExpr->u.zToken) ){\n        case SQLITE_AFF_TEXT:    zAff = \"TEXT\";     break;\n        case SQLITE_AFF_NONE:    zAff = \"NONE\";     break;\n        case SQLITE_AFF_NUMERIC: zAff = \"NUMERIC\";  break;\n        case SQLITE_AFF_INTEGER: zAff = \"INTEGER\";  break;\n        case SQLITE_AFF_REAL:    zAff = \"REAL\";     break;\n      }\n      sqlite3ExplainPrintf(pOut, \"CAST-%s(\", zAff);\n      sqlite3ExplainExpr(pOut, pExpr->pLeft);\n      sqlite3ExplainPrintf(pOut, \")\");\n      break;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_LT:      zBinOp = \"LT\";     break;\n    case TK_LE:      zBinOp = \"LE\";     break;\n    case TK_GT:      zBinOp = \"GT\";     break;\n    case TK_GE:      zBinOp = \"GE\";     break;\n    case TK_NE:      zBinOp = \"NE\";     break;\n    case TK_EQ:      zBinOp = \"EQ\";     break;\n    case TK_IS:      zBinOp = \"IS\";     break;\n    case TK_ISNOT:   zBinOp = \"ISNOT\";  break;\n    case TK_AND:     zBinOp = \"AND\";    break;\n    case TK_OR:      zBinOp = \"OR\";     break;\n    case TK_PLUS:    zBinOp = \"ADD\";    break;\n    case TK_STAR:    zBinOp = \"MUL\";    break;\n    case TK_MINUS:   zBinOp = \"SUB\";    break;\n    case TK_REM:     zBinOp = \"REM\";    break;\n    case TK_BITAND:  zBinOp = \"BITAND\"; break;\n    case TK_BITOR:   zBinOp = \"BITOR\";  break;\n    case TK_SLASH:   zBinOp = \"DIV\";    break;\n    case TK_LSHIFT:  zBinOp = \"LSHIFT\"; break;\n    case TK_RSHIFT:  zBinOp = \"RSHIFT\"; break;\n    case TK_CONCAT:  zBinOp = \"CONCAT\"; break;\n\n    case TK_UMINUS:  zUniOp = \"UMINUS\"; break;\n    case TK_UPLUS:   zUniOp = \"UPLUS\";  break;\n    case TK_BITNOT:  zUniOp = \"BITNOT\"; break;\n    case TK_NOT:     zUniOp = \"NOT\";    break;\n    case TK_ISNULL:  zUniOp = \"ISNULL\"; break;\n    case TK_NOTNULL: zUniOp = \"NOTNULL\"; break;\n\n    case TK_COLLATE: {\n      sqlite3ExplainExpr(pOut, pExpr->pLeft);\n      sqlite3ExplainPrintf(pOut,\".COLLATE(%s)\",pExpr->u.zToken);\n      break;\n    }\n\n    case TK_AGG_FUNCTION:\n    case TK_CONST_FUNC:\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      if( op==TK_AGG_FUNCTION ){\n        sqlite3ExplainPrintf(pOut, \"AGG_FUNCTION%d:%s(\",\n                             pExpr->op2, pExpr->u.zToken);\n      }else{\n        sqlite3ExplainPrintf(pOut, \"FUNCTION:%s(\", pExpr->u.zToken);\n      }\n      if( pFarg ){\n        sqlite3ExplainExprList(pOut, pFarg);\n      }\n      sqlite3ExplainPrintf(pOut, \")\");\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS: {\n      sqlite3ExplainPrintf(pOut, \"EXISTS(\");\n      sqlite3ExplainSelect(pOut, pExpr->x.pSelect);\n      sqlite3ExplainPrintf(pOut,\")\");\n      break;\n    }\n    case TK_SELECT: {\n      sqlite3ExplainPrintf(pOut, \"(\");\n      sqlite3ExplainSelect(pOut, pExpr->x.pSelect);\n      sqlite3ExplainPrintf(pOut, \")\");\n      break;\n    }\n    case TK_IN: {\n      sqlite3ExplainPrintf(pOut, \"IN(\");\n      sqlite3ExplainExpr(pOut, pExpr->pLeft);\n      sqlite3ExplainPrintf(pOut, \",\");\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        sqlite3ExplainSelect(pOut, pExpr->x.pSelect);\n      }else{\n        sqlite3ExplainExprList(pOut, pExpr->x.pList);\n      }\n      sqlite3ExplainPrintf(pOut, \")\");\n      break;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      Expr *pX = pExpr->pLeft;\n      Expr *pY = pExpr->x.pList->a[0].pExpr;\n      Expr *pZ = pExpr->x.pList->a[1].pExpr;\n      sqlite3ExplainPrintf(pOut, \"BETWEEN(\");\n      sqlite3ExplainExpr(pOut, pX);\n      sqlite3ExplainPrintf(pOut, \",\");\n      sqlite3ExplainExpr(pOut, pY);\n      sqlite3ExplainPrintf(pOut, \",\");\n      sqlite3ExplainExpr(pOut, pZ);\n      sqlite3ExplainPrintf(pOut, \")\");\n      break;\n    }\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      */\n      sqlite3ExplainPrintf(pOut, \"%s(%d)\", \n          pExpr->iTable ? \"NEW\" : \"OLD\", pExpr->iColumn);\n      break;\n    }\n    case TK_CASE: {\n      sqlite3ExplainPrintf(pOut, \"CASE(\");\n      sqlite3ExplainExpr(pOut, pExpr->pLeft);\n      sqlite3ExplainPrintf(pOut, \",\");\n      sqlite3ExplainExprList(pOut, pExpr->x.pList);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      const char *zType = \"unk\";\n      switch( pExpr->affinity ){\n        case OE_Rollback:   zType = \"rollback\";  break;\n        case OE_Abort:      zType = \"abort\";     break;\n        case OE_Fail:       zType = \"fail\";      break;\n        case OE_Ignore:     zType = \"ignore\";    break;\n      }\n      sqlite3ExplainPrintf(pOut, \"RAISE-%s(%s)\", zType, pExpr->u.zToken);\n      break;\n    }\n#endif\n  }\n  if( zBinOp ){\n    sqlite3ExplainPrintf(pOut,\"%s(\", zBinOp);\n    sqlite3ExplainExpr(pOut, pExpr->pLeft);\n    sqlite3ExplainPrintf(pOut,\",\");\n    sqlite3ExplainExpr(pOut, pExpr->pRight);\n    sqlite3ExplainPrintf(pOut,\")\");\n  }else if( zUniOp ){\n    sqlite3ExplainPrintf(pOut,\"%s(\", zUniOp);\n    sqlite3ExplainExpr(pOut, pExpr->pLeft);\n    sqlite3ExplainPrintf(pOut,\")\");\n  }\n}\n#endif /* defined(SQLITE_ENABLE_TREE_EXPLAIN) */\n\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n/*\n** Generate a human-readable explanation of an expression list.\n*/\nSQLITE_PRIVATE void sqlite3ExplainExprList(Vdbe *pOut, ExprList *pList){\n  int i;\n  if( pList==0 || pList->nExpr==0 ){\n    sqlite3ExplainPrintf(pOut, \"(empty-list)\");\n    return;\n  }else if( pList->nExpr==1 ){\n    sqlite3ExplainExpr(pOut, pList->a[0].pExpr);\n  }else{\n    sqlite3ExplainPush(pOut);\n    for(i=0; i<pList->nExpr; i++){\n      sqlite3ExplainPrintf(pOut, \"item[%d] = \", i);\n      sqlite3ExplainPush(pOut);\n      sqlite3ExplainExpr(pOut, pList->a[i].pExpr);\n      sqlite3ExplainPop(pOut);\n      if( pList->a[i].zName ){\n        sqlite3ExplainPrintf(pOut, \" AS %s\", pList->a[i].zName);\n      }\n      if( pList->a[i].bSpanIsTab ){\n        sqlite3ExplainPrintf(pOut, \" (%s)\", pList->a[i].zSpan);\n      }\n      if( i<pList->nExpr-1 ){\n        sqlite3ExplainNL(pOut);\n      }\n    }\n    sqlite3ExplainPop(pOut);\n  }\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** Return TRUE if pExpr is an constant expression that is appropriate\n** for factoring out of a loop.  Appropriate expressions are:\n**\n**    *  Any expression that evaluates to two or more opcodes.\n**\n**    *  Any OP_Integer, OP_Real, OP_String, OP_Blob, OP_Null, \n**       or OP_Variable that does not need to be placed in a \n**       specific register.\n**\n** There is no point in factoring out single-instruction constant\n** expressions that need to be placed in a particular register.  \n** We could factor them out, but then we would end up adding an\n** OP_SCopy instruction to move the value into the correct register\n** later.  We might as well just use the original instruction and\n** avoid the OP_SCopy.\n*/\nstatic int isAppropriateForFactoring(Expr *p){\n  if( !sqlite3ExprIsConstantNotJoin(p) ){\n    return 0;  /* Only constant expressions are appropriate for factoring */\n  }\n  if( (p->flags & EP_FixedDest)==0 ){\n    return 1;  /* Any constant without a fixed destination is appropriate */\n  }\n  while( p->op==TK_UPLUS ) p = p->pLeft;\n  switch( p->op ){\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB:\n#endif\n    case TK_VARIABLE:\n    case TK_INTEGER:\n    case TK_FLOAT:\n    case TK_NULL:\n    case TK_STRING: {\n      testcase( p->op==TK_BLOB );\n      testcase( p->op==TK_VARIABLE );\n      testcase( p->op==TK_INTEGER );\n      testcase( p->op==TK_FLOAT );\n      testcase( p->op==TK_NULL );\n      testcase( p->op==TK_STRING );\n      /* Single-instruction constants with a fixed destination are\n      ** better done in-line.  If we factor them, they will just end\n      ** up generating an OP_SCopy to move the value to the destination\n      ** register. */\n      return 0;\n    }\n    case TK_UMINUS: {\n      if( p->pLeft->op==TK_FLOAT || p->pLeft->op==TK_INTEGER ){\n        return 0;\n      }\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n  return 1;\n}\n\n/*\n** If pExpr is a constant expression that is appropriate for\n** factoring out of a loop, then evaluate the expression\n** into a register and convert the expression into a TK_REGISTER\n** expression.\n*/\nstatic int evalConstExpr(Walker *pWalker, Expr *pExpr){\n  Parse *pParse = pWalker->pParse;\n  switch( pExpr->op ){\n    case TK_IN:\n    case TK_REGISTER: {\n      return WRC_Prune;\n    }\n    case TK_COLLATE: {\n      return WRC_Continue;\n    }\n    case TK_FUNCTION:\n    case TK_AGG_FUNCTION:\n    case TK_CONST_FUNC: {\n      /* The arguments to a function have a fixed destination.\n      ** Mark them this way to avoid generated unneeded OP_SCopy\n      ** instructions. \n      */\n      ExprList *pList = pExpr->x.pList;\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      if( pList ){\n        int i = pList->nExpr;\n        struct ExprList_item *pItem = pList->a;\n        for(; i>0; i--, pItem++){\n          if( ALWAYS(pItem->pExpr) ) pItem->pExpr->flags |= EP_FixedDest;\n        }\n      }\n      break;\n    }\n  }\n  if( isAppropriateForFactoring(pExpr) ){\n    int r1 = ++pParse->nMem;\n    int r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);\n    /* If r2!=r1, it means that register r1 is never used.  That is harmless\n    ** but suboptimal, so we want to know about the situation to fix it.\n    ** Hence the following assert: */\n    assert( r2==r1 );\n    pExpr->op2 = pExpr->op;\n    pExpr->op = TK_REGISTER;\n    pExpr->iTable = r2;\n    return WRC_Prune;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Preevaluate constant subexpressions within pExpr and store the\n** results in registers.  Modify pExpr so that the constant subexpresions\n** are TK_REGISTER opcodes that refer to the precomputed values.\n**\n** This routine is a no-op if the jump to the cookie-check code has\n** already occur.  Since the cookie-check jump is generated prior to\n** any other serious processing, this check ensures that there is no\n** way to accidently bypass the constant initializations.\n**\n** This routine is also a no-op if the SQLITE_FactorOutConst optimization\n** is disabled via the sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS)\n** interface.  This allows test logic to verify that the same answer is\n** obtained for queries regardless of whether or not constants are\n** precomputed into registers or if they are inserted in-line.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeConstants(Parse *pParse, Expr *pExpr){\n  Walker w;\n  if( pParse->cookieGoto ) return;\n  if( OptimizationDisabled(pParse->db, SQLITE_FactorOutConst) ) return;\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = evalConstExpr;\n  w.pParse = pParse;\n  sqlite3WalkExpr(&w, pExpr);\n}\n\n\n/*\n** Generate code that pushes the value of every element of the given\n** expression list into a sequence of registers beginning at target.\n**\n** Return the number of elements evaluated.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(\n  Parse *pParse,     /* Parsing context */\n  ExprList *pList,   /* The expression list to be coded */\n  int target,        /* Where to write results */\n  int doHardCopy     /* Make a hard copy of every element */\n){\n  struct ExprList_item *pItem;\n  int i, n;\n  assert( pList!=0 );\n  assert( target>0 );\n  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */\n  n = pList->nExpr;\n  for(pItem=pList->a, i=0; i<n; i++, pItem++){\n    Expr *pExpr = pItem->pExpr;\n    int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);\n    if( inReg!=target+i ){\n      sqlite3VdbeAddOp2(pParse->pVdbe, doHardCopy ? OP_Copy : OP_SCopy,\n                        inReg, target+i);\n    }\n  }\n  return n;\n}\n\n/*\n** Generate code for a BETWEEN operator.\n**\n**    x BETWEEN y AND z\n**\n** The above is equivalent to \n**\n**    x>=y AND x<=z\n**\n** Code it as such, taking care to do the common subexpression\n** elementation of x.\n*/\nstatic void exprCodeBetween(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* The BETWEEN expression */\n  int dest,         /* Jump here if the jump is taken */\n  int jumpIfTrue,   /* Take the jump if the BETWEEN is true */\n  int jumpIfNull    /* Take the jump if the BETWEEN is NULL */\n){\n  Expr exprAnd;     /* The AND operator in  x>=y AND x<=z  */\n  Expr compLeft;    /* The  x>=y  term */\n  Expr compRight;   /* The  x<=z  term */\n  Expr exprX;       /* The  x  subexpression */\n  int regFree1 = 0; /* Temporary use register */\n\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  exprX = *pExpr->pLeft;\n  exprAnd.op = TK_AND;\n  exprAnd.pLeft = &compLeft;\n  exprAnd.pRight = &compRight;\n  compLeft.op = TK_GE;\n  compLeft.pLeft = &exprX;\n  compLeft.pRight = pExpr->x.pList->a[0].pExpr;\n  compRight.op = TK_LE;\n  compRight.pLeft = &exprX;\n  compRight.pRight = pExpr->x.pList->a[1].pExpr;\n  exprX.iTable = sqlite3ExprCodeTemp(pParse, &exprX, &regFree1);\n  exprX.op = TK_REGISTER;\n  if( jumpIfTrue ){\n    sqlite3ExprIfTrue(pParse, &exprAnd, dest, jumpIfNull);\n  }else{\n    sqlite3ExprIfFalse(pParse, &exprAnd, dest, jumpIfNull);\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n\n  /* Ensure adequate test coverage */\n  testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1==0 );\n  testcase( jumpIfTrue==0 && jumpIfNull==0 && regFree1!=0 );\n  testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1==0 );\n  testcase( jumpIfTrue==0 && jumpIfNull!=0 && regFree1!=0 );\n  testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1==0 );\n  testcase( jumpIfTrue!=0 && jumpIfNull==0 && regFree1!=0 );\n  testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1==0 );\n  testcase( jumpIfTrue!=0 && jumpIfNull!=0 && regFree1!=0 );\n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is true but execution\n** continues straight thru if the expression is false.\n**\n** If the expression evaluates to NULL (neither true nor false), then\n** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL.\n**\n** This code depends on the fact that certain token values (ex: TK_EQ)\n** are the same as opcode values (ex: OP_Eq) that implement the corresponding\n** operation.  Special comments in vdbe.c and the mkopcodeh.awk script in\n** the make process cause these values to align.  Assert()s in the code\n** below verify that the numbers are aligned correctly.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) )     return;  /* Existence of VDBE checked by caller */\n  if( NEVER(pExpr==0) ) return;  /* No way this can happen */\n  op = pExpr->op;\n  switch( op ){\n    case TK_AND: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse, 1);\n      break;\n    }\n    case TK_OR: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      assert( TK_LT==OP_Lt );\n      assert( TK_LE==OP_Le );\n      assert( TK_GT==OP_Gt );\n      assert( TK_GE==OP_Ge );\n      assert( TK_EQ==OP_Eq );\n      assert( TK_NE==OP_Ne );\n      testcase( op==TK_LT );\n      testcase( op==TK_LE );\n      testcase( op==TK_GT );\n      testcase( op==TK_GE );\n      testcase( op==TK_EQ );\n      testcase( op==TK_NE );\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT: {\n      testcase( op==TK_IS );\n      testcase( op==TK_ISNOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      assert( TK_ISNULL==OP_IsNull );\n      assert( TK_NOTNULL==OP_NotNull );\n      testcase( op==TK_ISNULL );\n      testcase( op==TK_NOTNULL );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, 1, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = jumpIfNull ? dest : destIfFalse;\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, dest);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      break;\n    }\n#endif\n    default: {\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n      sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);\n      testcase( regFree1==0 );\n      testcase( jumpIfNull==0 );\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);  \n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is false but execution\n** continues straight thru if the expression is true.\n**\n** If the expression evaluates to NULL (neither true nor false) then\n** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull\n** is 0.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */\n  if( pExpr==0 )    return;\n\n  /* The value of pExpr->op and op are related as follows:\n  **\n  **       pExpr->op            op\n  **       ---------          ----------\n  **       TK_ISNULL          OP_NotNull\n  **       TK_NOTNULL         OP_IsNull\n  **       TK_NE              OP_Eq\n  **       TK_EQ              OP_Ne\n  **       TK_GT              OP_Le\n  **       TK_LE              OP_Gt\n  **       TK_GE              OP_Lt\n  **       TK_LT              OP_Ge\n  **\n  ** For other values of pExpr->op, op is undefined and unused.\n  ** The value of TK_ and OP_ constants are arranged such that we\n  ** can compute the mapping above using the following expression.\n  ** Assert()s verify that the computation is correct.\n  */\n  op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);\n\n  /* Verify correct alignment of TK_ and OP_ constants\n  */\n  assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );\n  assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );\n  assert( pExpr->op!=TK_NE || op==OP_Eq );\n  assert( pExpr->op!=TK_EQ || op==OP_Ne );\n  assert( pExpr->op!=TK_LT || op==OP_Ge );\n  assert( pExpr->op!=TK_LE || op==OP_Gt );\n  assert( pExpr->op!=TK_GT || op==OP_Le );\n  assert( pExpr->op!=TK_GE || op==OP_Lt );\n\n  switch( pExpr->op ){\n    case TK_AND: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      break;\n    }\n    case TK_OR: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse, 1);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      testcase( op==TK_LT );\n      testcase( op==TK_LE );\n      testcase( op==TK_GT );\n      testcase( op==TK_GE );\n      testcase( op==TK_EQ );\n      testcase( op==TK_NE );\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT: {\n      testcase( pExpr->op==TK_IS );\n      testcase( pExpr->op==TK_ISNOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      testcase( op==TK_ISNULL );\n      testcase( op==TK_NOTNULL );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, 0, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      if( jumpIfNull ){\n        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);\n      }else{\n        int destIfNull = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);\n        sqlite3VdbeResolveLabel(v, destIfNull);\n      }\n      break;\n    }\n#endif\n    default: {\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n      sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);\n      testcase( regFree1==0 );\n      testcase( jumpIfNull==0 );\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n}\n\n/*\n** Do a deep comparison of two expression trees.  Return 0 if the two\n** expressions are completely identical.  Return 1 if they differ only\n** by a COLLATE operator at the top level.  Return 2 if there are differences\n** other than the top-level COLLATE operator.\n**\n** Sometimes this routine will return 2 even if the two expressions\n** really are equivalent.  If we cannot prove that the expressions are\n** identical, we return 2 just to be safe.  So if this routine\n** returns 2, then you do not really know for certain if the two\n** expressions are the same.  But if you get a 0 or 1 return, then you\n** can be sure the expressions are the same.  In the places where\n** this routine is used, it does not hurt to get an extra 2 - that\n** just might result in some slightly slower code.  But returning\n** an incorrect 0 or 1 could lead to a malfunction.\n*/\nSQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){\n  if( pA==0||pB==0 ){\n    return pB==pA ? 0 : 2;\n  }\n  assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) );\n  assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) );\n  if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){\n    return 2;\n  }\n  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;\n  if( pA->op!=pB->op ){\n    if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){\n      return 1;\n    }\n    if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){\n      return 1;\n    }\n    return 2;\n  }\n  if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2;\n  if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2;\n  if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2;\n  if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2;\n  if( ExprHasProperty(pA, EP_IntValue) ){\n    if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){\n      return 2;\n    }\n  }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){\n    if( ExprHasProperty(pB, EP_IntValue) || NEVER(pB->u.zToken==0) ) return 2;\n    if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){\n      return pA->op==TK_COLLATE ? 1 : 2;\n    }\n  }\n  return 0;\n}\n\n/*\n** Compare two ExprList objects.  Return 0 if they are identical and \n** non-zero if they differ in any way.\n**\n** This routine might return non-zero for equivalent ExprLists.  The\n** only consequence will be disabled optimizations.  But this routine\n** must never return 0 if the two ExprList objects are different, or\n** a malfunction will result.\n**\n** Two NULL pointers are considered to be the same.  But a NULL pointer\n** always differs from a non-NULL pointer.\n*/\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){\n  int i;\n  if( pA==0 && pB==0 ) return 0;\n  if( pA==0 || pB==0 ) return 1;\n  if( pA->nExpr!=pB->nExpr ) return 1;\n  for(i=0; i<pA->nExpr; i++){\n    Expr *pExprA = pA->a[i].pExpr;\n    Expr *pExprB = pB->a[i].pExpr;\n    if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;\n    if( sqlite3ExprCompare(pExprA, pExprB) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** An instance of the following structure is used by the tree walker\n** to count references to table columns in the arguments of an \n** aggregate function, in order to implement the\n** sqlite3FunctionThisSrc() routine.\n*/\nstruct SrcCount {\n  SrcList *pSrc;   /* One particular FROM clause in a nested query */\n  int nThis;       /* Number of references to columns in pSrcList */\n  int nOther;      /* Number of references to columns in other FROM clauses */\n};\n\n/*\n** Count the number of references to columns.\n*/\nstatic int exprSrcCount(Walker *pWalker, Expr *pExpr){\n  /* The NEVER() on the second term is because sqlite3FunctionUsesThisSrc()\n  ** is always called before sqlite3ExprAnalyzeAggregates() and so the\n  ** TK_COLUMNs have not yet been converted into TK_AGG_COLUMN.  If\n  ** sqlite3FunctionUsesThisSrc() is used differently in the future, the\n  ** NEVER() will need to be removed. */\n  if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){\n    int i;\n    struct SrcCount *p = pWalker->u.pSrcCount;\n    SrcList *pSrc = p->pSrc;\n    for(i=0; i<pSrc->nSrc; i++){\n      if( pExpr->iTable==pSrc->a[i].iCursor ) break;\n    }\n    if( i<pSrc->nSrc ){\n      p->nThis++;\n    }else{\n      p->nOther++;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if any of the arguments to the pExpr Function reference\n** pSrcList.  Return true if they do.  Also return true if the function\n** has no arguments or has only constant arguments.  Return false if pExpr\n** references columns but not columns of tables found in pSrcList.\n*/\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){\n  Walker w;\n  struct SrcCount cnt;\n  assert( pExpr->op==TK_AGG_FUNCTION );\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = exprSrcCount;\n  w.u.pSrcCount = &cnt;\n  cnt.pSrc = pSrcList;\n  cnt.nThis = 0;\n  cnt.nOther = 0;\n  sqlite3WalkExprList(&w, pExpr->x.pList);\n  return cnt.nThis>0 || cnt.nOther==0;\n}\n\n/*\n** Add a new element to the pAggInfo->aCol[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoColumn(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aCol = sqlite3ArrayAllocate(\n       db,\n       pInfo->aCol,\n       sizeof(pInfo->aCol[0]),\n       &pInfo->nColumn,\n       &i\n  );\n  return i;\n}    \n\n/*\n** Add a new element to the pAggInfo->aFunc[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aFunc = sqlite3ArrayAllocate(\n       db, \n       pInfo->aFunc,\n       sizeof(pInfo->aFunc[0]),\n       &pInfo->nFunc,\n       &i\n  );\n  return i;\n}    \n\n/*\n** This is the xExprCallback for a tree walker.  It is used to\n** implement sqlite3ExprAnalyzeAggregates().  See sqlite3ExprAnalyzeAggregates\n** for additional information.\n*/\nstatic int analyzeAggregate(Walker *pWalker, Expr *pExpr){\n  int i;\n  NameContext *pNC = pWalker->u.pNC;\n  Parse *pParse = pNC->pParse;\n  SrcList *pSrcList = pNC->pSrcList;\n  AggInfo *pAggInfo = pNC->pAggInfo;\n\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      /* Check to see if the column is in one of the tables in the FROM\n      ** clause of the aggregate query */\n      if( ALWAYS(pSrcList!=0) ){\n        struct SrcList_item *pItem = pSrcList->a;\n        for(i=0; i<pSrcList->nSrc; i++, pItem++){\n          struct AggInfo_col *pCol;\n          assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n          if( pExpr->iTable==pItem->iCursor ){\n            /* If we reach this point, it means that pExpr refers to a table\n            ** that is in the FROM clause of the aggregate query.  \n            **\n            ** Make an entry for the column in pAggInfo->aCol[] if there\n            ** is not an entry there already.\n            */\n            int k;\n            pCol = pAggInfo->aCol;\n            for(k=0; k<pAggInfo->nColumn; k++, pCol++){\n              if( pCol->iTable==pExpr->iTable &&\n                  pCol->iColumn==pExpr->iColumn ){\n                break;\n              }\n            }\n            if( (k>=pAggInfo->nColumn)\n             && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 \n            ){\n              pCol = &pAggInfo->aCol[k];\n              pCol->pTab = pExpr->pTab;\n              pCol->iTable = pExpr->iTable;\n              pCol->iColumn = pExpr->iColumn;\n              pCol->iMem = ++pParse->nMem;\n              pCol->iSorterColumn = -1;\n              pCol->pExpr = pExpr;\n              if( pAggInfo->pGroupBy ){\n                int j, n;\n                ExprList *pGB = pAggInfo->pGroupBy;\n                struct ExprList_item *pTerm = pGB->a;\n                n = pGB->nExpr;\n                for(j=0; j<n; j++, pTerm++){\n                  Expr *pE = pTerm->pExpr;\n                  if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&\n                      pE->iColumn==pExpr->iColumn ){\n                    pCol->iSorterColumn = j;\n                    break;\n                  }\n                }\n              }\n              if( pCol->iSorterColumn<0 ){\n                pCol->iSorterColumn = pAggInfo->nSortingColumn++;\n              }\n            }\n            /* There is now an entry for pExpr in pAggInfo->aCol[] (either\n            ** because it was there before or because we just created it).\n            ** Convert the pExpr to be a TK_AGG_COLUMN referring to that\n            ** pAggInfo->aCol[] entry.\n            */\n            ExprSetIrreducible(pExpr);\n            pExpr->pAggInfo = pAggInfo;\n            pExpr->op = TK_AGG_COLUMN;\n            pExpr->iAgg = (i16)k;\n            break;\n          } /* endif pExpr->iTable==pItem->iCursor */\n        } /* end loop over pSrcList */\n      }\n      return WRC_Prune;\n    }\n    case TK_AGG_FUNCTION: {\n      if( (pNC->ncFlags & NC_InAggFunc)==0\n       && pWalker->walkerDepth==pExpr->op2\n      ){\n        /* Check to see if pExpr is a duplicate of another aggregate \n        ** function that is already in the pAggInfo structure\n        */\n        struct AggInfo_func *pItem = pAggInfo->aFunc;\n        for(i=0; i<pAggInfo->nFunc; i++, pItem++){\n          if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){\n            break;\n          }\n        }\n        if( i>=pAggInfo->nFunc ){\n          /* pExpr is original.  Make a new entry in pAggInfo->aFunc[]\n          */\n          u8 enc = ENC(pParse->db);\n          i = addAggInfoFunc(pParse->db, pAggInfo);\n          if( i>=0 ){\n            assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n            pItem = &pAggInfo->aFunc[i];\n            pItem->pExpr = pExpr;\n            pItem->iMem = ++pParse->nMem;\n            assert( !ExprHasProperty(pExpr, EP_IntValue) );\n            pItem->pFunc = sqlite3FindFunction(pParse->db,\n                   pExpr->u.zToken, sqlite3Strlen30(pExpr->u.zToken),\n                   pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);\n            if( pExpr->flags & EP_Distinct ){\n              pItem->iDistinct = pParse->nTab++;\n            }else{\n              pItem->iDistinct = -1;\n            }\n          }\n        }\n        /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry\n        */\n        assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n        ExprSetIrreducible(pExpr);\n        pExpr->iAgg = (i16)i;\n        pExpr->pAggInfo = pAggInfo;\n        return WRC_Prune;\n      }else{\n        return WRC_Continue;\n      }\n    }\n  }\n  return WRC_Continue;\n}\nstatic int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pWalker);\n  UNUSED_PARAMETER(pSelect);\n  return WRC_Continue;\n}\n\n/*\n** Analyze the pExpr expression looking for aggregate functions and\n** for variables that need to be added to AggInfo object that pNC->pAggInfo\n** points to.  Additional entries are made on the AggInfo object as\n** necessary.\n**\n** This routine should only be called after the expression has been\n** analyzed by sqlite3ResolveExprNames().\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = analyzeAggregate;\n  w.xSelectCallback = analyzeAggregatesInSelect;\n  w.u.pNC = pNC;\n  assert( pNC->pSrcList!=0 );\n  sqlite3WalkExpr(&w, pExpr);\n}\n\n/*\n** Call sqlite3ExprAnalyzeAggregates() for every expression in an\n** expression list.  Return the number of errors.\n**\n** If an error is found, the analysis is cut short.\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext *pNC, ExprList *pList){\n  struct ExprList_item *pItem;\n  int i;\n  if( pList ){\n    for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){\n      sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);\n    }\n  }\n}\n\n/*\n** Allocate a single new register for use to hold some intermediate result.\n*/\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){\n  if( pParse->nTempReg==0 ){\n    return ++pParse->nMem;\n  }\n  return pParse->aTempReg[--pParse->nTempReg];\n}\n\n/*\n** Deallocate a register, making available for reuse for some other\n** purpose.\n**\n** If a register is currently being used by the column cache, then\n** the dallocation is deferred until the column cache line that uses\n** the register becomes stale.\n*/\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){\n  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n    int i;\n    struct yColCache *p;\n    for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n      if( p->iReg==iReg ){\n        p->tempReg = 1;\n        return;\n      }\n    }\n    pParse->aTempReg[pParse->nTempReg++] = iReg;\n  }\n}\n\n/*\n** Allocate or deallocate a block of nReg consecutive registers\n*/\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){\n  int i, n;\n  i = pParse->iRangeReg;\n  n = pParse->nRangeReg;\n  if( nReg<=n ){\n    assert( !usedAsColumnCache(pParse, i, i+n-1) );\n    pParse->iRangeReg += nReg;\n    pParse->nRangeReg -= nReg;\n  }else{\n    i = pParse->nMem+1;\n    pParse->nMem += nReg;\n  }\n  return i;\n}\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){\n  sqlite3ExprCacheRemove(pParse, iReg, nReg);\n  if( nReg>pParse->nRangeReg ){\n    pParse->nRangeReg = nReg;\n    pParse->iRangeReg = iReg;\n  }\n}\n\n/*\n** Mark all temporary registers as being unavailable for reuse.\n*/\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse *pParse){\n  pParse->nTempReg = 0;\n  pParse->nRangeReg = 0;\n}\n\n/************** End of expr.c ************************************************/\n/************** Begin file alter.c *******************************************/\n/*\n** 2005 February 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that used to generate VDBE code\n** that implements the ALTER TABLE command.\n*/\n\n/*\n** The code in this file only exists if we are not omitting the\n** ALTER TABLE logic from the build.\n*/\n#ifndef SQLITE_OMIT_ALTERTABLE\n\n\n/*\n** This function is used by SQL generated to implement the \n** ALTER TABLE command. The first argument is the text of a CREATE TABLE or\n** CREATE INDEX command. The second is a table name. The table name in \n** the CREATE TABLE or CREATE INDEX statement is replaced with the third\n** argument and the result returned. Examples:\n**\n** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')\n**     -> 'CREATE TABLE def(a, b, c)'\n**\n** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')\n**     -> 'CREATE INDEX i ON def(a, b, c)'\n*/\nstatic void renameTableFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TABLE \n  ** statement is that the table name is the first non-space token that\n  ** is immediately followed by a TK_LP or TK_USING token.\n  */\n  if( zSql ){\n    do {\n      if( !*zCsr ){\n        /* Ran out of input before finding an opening bracket. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      } while( token==TK_SPACE );\n      assert( len>0 );\n    } while( token!=TK_LP && token!=TK_USING );\n\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", ((u8*)tname.z) - zSql, zSql, \n       zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** This C function implements an SQL user function that is used by SQL code\n** generated by the ALTER TABLE ... RENAME command to modify the definition\n** of any foreign key constraints that use the table being renamed as the \n** parent table. It is passed three arguments:\n**\n**   1) The complete text of the CREATE TABLE statement being modified,\n**   2) The old name of the table being renamed, and\n**   3) The new name of the table being renamed.\n**\n** It returns the new CREATE TABLE statement. For example:\n**\n**   sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')\n**       -> 'CREATE TABLE t1(a REFERENCES t3)'\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic void renameParentFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zOutput = 0;\n  char *zResult;\n  unsigned char const *zInput = sqlite3_value_text(argv[0]);\n  unsigned char const *zOld = sqlite3_value_text(argv[1]);\n  unsigned char const *zNew = sqlite3_value_text(argv[2]);\n\n  unsigned const char *z;         /* Pointer to token */\n  int n;                          /* Length of token z */\n  int token;                      /* Type of token */\n\n  UNUSED_PARAMETER(NotUsed);\n  for(z=zInput; *z; z=z+n){\n    n = sqlite3GetToken(z, &token);\n    if( token==TK_REFERENCES ){\n      char *zParent;\n      do {\n        z += n;\n        n = sqlite3GetToken(z, &token);\n      }while( token==TK_SPACE );\n\n      zParent = sqlite3DbStrNDup(db, (const char *)z, n);\n      if( zParent==0 ) break;\n      sqlite3Dequote(zParent);\n      if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){\n        char *zOut = sqlite3MPrintf(db, \"%s%.*s\\\"%w\\\"\", \n            (zOutput?zOutput:\"\"), z-zInput, zInput, (const char *)zNew\n        );\n        sqlite3DbFree(db, zOutput);\n        zOutput = zOut;\n        zInput = &z[n];\n      }\n      sqlite3DbFree(db, zParent);\n    }\n  }\n\n  zResult = sqlite3MPrintf(db, \"%s%s\", (zOutput?zOutput:\"\"), zInput), \n  sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);\n  sqlite3DbFree(db, zOutput);\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n/* This function is used by SQL generated to implement the\n** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER \n** statement. The second is a table name. The table name in the CREATE \n** TRIGGER statement is replaced with the third argument and the result \n** returned. This is analagous to renameTableFunc() above, except for CREATE\n** TRIGGER, not CREATE INDEX and CREATE TABLE.\n*/\nstatic void renameTriggerFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  int dist = 3;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TRIGGER \n  ** statement is that the table name is the first token that is immediatedly\n  ** preceded by either TK_ON or TK_DOT and immediatedly followed by one\n  ** of TK_WHEN, TK_BEGIN or TK_FOR.\n  */\n  if( zSql ){\n    do {\n\n      if( !*zCsr ){\n        /* Ran out of input before finding the table name. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      }while( token==TK_SPACE );\n      assert( len>0 );\n\n      /* Variable 'dist' stores the number of tokens read since the most\n      ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN \n      ** token is read and 'dist' equals 2, the condition stated above\n      ** to be met.\n      **\n      ** Note that ON cannot be a database, table or column name, so\n      ** there is no need to worry about syntax like \n      ** \"CREATE TRIGGER ... ON ON.ON BEGIN ...\" etc.\n      */\n      dist++;\n      if( token==TK_DOT || token==TK_ON ){\n        dist = 0;\n      }\n    } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );\n\n    /* Variable tname now contains the token that is the old table-name\n    ** in the CREATE TRIGGER statement.\n    */\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", ((u8*)tname.z) - zSql, zSql, \n       zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n#endif   /* !SQLITE_OMIT_TRIGGER */\n\n/*\n** Register built-in functions used to help implement ALTER TABLE\n*/\nSQLITE_PRIVATE void sqlite3AlterFunctions(void){\n  static SQLITE_WSD FuncDef aAlterTableFuncs[] = {\n    FUNCTION(sqlite_rename_table,   2, 0, 0, renameTableFunc),\n#ifndef SQLITE_OMIT_TRIGGER\n    FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    FUNCTION(sqlite_rename_parent,  3, 0, 0, renameParentFunc),\n#endif\n  };\n  int i;\n  FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);\n  FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aAlterTableFuncs);\n\n  for(i=0; i<ArraySize(aAlterTableFuncs); i++){\n    sqlite3FuncDefInsert(pHash, &aFunc[i]);\n  }\n}\n\n/*\n** This function is used to create the text of expressions of the form:\n**\n**   name=<constant1> OR name=<constant2> OR ...\n**\n** If argument zWhere is NULL, then a pointer string containing the text \n** \"name=<constant>\" is returned, where <constant> is the quoted version\n** of the string passed as argument zConstant. The returned buffer is\n** allocated using sqlite3DbMalloc(). It is the responsibility of the\n** caller to ensure that it is eventually freed.\n**\n** If argument zWhere is not NULL, then the string returned is \n** \"<where> OR name=<constant>\", where <where> is the contents of zWhere.\n** In this case zWhere is passed to sqlite3DbFree() before returning.\n** \n*/\nstatic char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){\n  char *zNew;\n  if( !zWhere ){\n    zNew = sqlite3MPrintf(db, \"name=%Q\", zConstant);\n  }else{\n    zNew = sqlite3MPrintf(db, \"%s OR name=%Q\", zWhere, zConstant);\n    sqlite3DbFree(db, zWhere);\n  }\n  return zNew;\n}\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** tables that have foreign key constraints that refer to table pTab (i.e.\n** constraints for which pTab is the parent table) from the sqlite_master\n** table.\n*/\nstatic char *whereForeignKeys(Parse *pParse, Table *pTab){\n  FKey *p;\n  char *zWhere = 0;\n  for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n    zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);\n  }\n  return zWhere;\n}\n#endif\n\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** temporary triggers on table pTab from the sqlite_temp_master table. If\n** table pTab has no temporary triggers, or is itself stored in the \n** temporary database, NULL is returned.\n*/\nstatic char *whereTempTriggers(Parse *pParse, Table *pTab){\n  Trigger *pTrig;\n  char *zWhere = 0;\n  const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */\n\n  /* If the table is not located in the temp-db (in which case NULL is \n  ** returned, loop through the tables list of triggers. For each trigger\n  ** that is not part of the temp-db schema, add a clause to the WHERE \n  ** expression being built up in zWhere.\n  */\n  if( pTab->pSchema!=pTempSchema ){\n    sqlite3 *db = pParse->db;\n    for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n      if( pTrig->pSchema==pTempSchema ){\n        zWhere = whereOrName(db, zWhere, pTrig->zName);\n      }\n    }\n  }\n  if( zWhere ){\n    char *zNew = sqlite3MPrintf(pParse->db, \"type='trigger' AND (%s)\", zWhere);\n    sqlite3DbFree(pParse->db, zWhere);\n    zWhere = zNew;\n  }\n  return zWhere;\n}\n\n/*\n** Generate code to drop and reload the internal representation of table\n** pTab from the database, including triggers and temporary triggers.\n** Argument zName is the name of the table in the database schema at\n** the time the generated code is executed. This can be different from\n** pTab->zName if this function is being called to code part of an \n** \"ALTER TABLE RENAME TO\" statement.\n*/\nstatic void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){\n  Vdbe *v;\n  char *zWhere;\n  int iDb;                   /* Index of database containing pTab */\n#ifndef SQLITE_OMIT_TRIGGER\n  Trigger *pTrig;\n#endif\n\n  v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  assert( iDb>=0 );\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Drop any table triggers from the internal schema. */\n  for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n    int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n    assert( iTrigDb==iDb || iTrigDb==1 );\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);\n  }\n#endif\n\n  /* Drop the table and index from the internal schema.  */\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n\n  /* Reload the table, index and permanent trigger schemas. */\n  zWhere = sqlite3MPrintf(pParse->db, \"tbl_name=%Q\", zName);\n  if( !zWhere ) return;\n  sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Now, if the table is not stored in the temp database, reload any temp \n  ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. \n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);\n  }\n#endif\n}\n\n/*\n** Parameter zName is the name of a table that is about to be altered\n** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).\n** If the table is a system table, this function leaves an error message\n** in pParse->zErr (system tables may not be altered) and returns non-zero.\n**\n** Or, if zName is not a system table, zero is returned.\n*/\nstatic int isSystemTable(Parse *pParse, const char *zName){\n  if( sqlite3Strlen30(zName)>6 && 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be altered\", zName);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Generate code to implement the \"ALTER TABLE xxx RENAME TO yyy\" \n** command. \n*/\nSQLITE_PRIVATE void sqlite3AlterRenameTable(\n  Parse *pParse,            /* Parser context. */\n  SrcList *pSrc,            /* The table to rename. */\n  Token *pName              /* The new table name. */\n){\n  int iDb;                  /* Database that contains the table */\n  char *zDb;                /* Name of database iDb */\n  Table *pTab;              /* Table being renamed */\n  char *zName = 0;          /* NULL-terminated version of pName */ \n  sqlite3 *db = pParse->db; /* Database connection */\n  int nTabName;             /* Number of UTF-8 characters in zTabName */\n  const char *zTabName;     /* Original name of the table */\n  Vdbe *v;\n#ifndef SQLITE_OMIT_TRIGGER\n  char *zWhere = 0;         /* Where clause to locate temp triggers */\n#endif\n  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */\n  int savedDbFlags;         /* Saved value of db->flags */\n\n  savedDbFlags = db->flags;  \n  if( NEVER(db->mallocFailed) ) goto exit_rename_table;\n  assert( pSrc->nSrc==1 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_rename_table;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  zDb = db->aDb[iDb].zName;\n  db->flags |= SQLITE_PreferBuiltin;\n\n  /* Get a NULL terminated version of the new table name. */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName ) goto exit_rename_table;\n\n  /* Check that a table or index named 'zName' does not already exist\n  ** in database iDb. If so, this is an error.\n  */\n  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){\n    sqlite3ErrorMsg(pParse, \n        \"there is already another table or index with this name: %s\", zName);\n    goto exit_rename_table;\n  }\n\n  /* Make sure it is not a system table being altered, or a reserved name\n  ** that the table is being renamed to.\n  */\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_rename_table;\n  }\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto\n    exit_rename_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"view %s may not be altered\", pTab->zName);\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_rename_table;\n  }\n  if( IsVirtual(pTab) ){\n    pVTab = sqlite3GetVTable(db, pTab);\n    if( pVTab->pVtab->pModule->xRename==0 ){\n      pVTab = 0;\n    }\n  }\n#endif\n\n  /* Begin a transaction and code the VerifyCookie for database iDb. \n  ** Then modify the schema cookie (since the ALTER TABLE modifies the\n  ** schema). Open a statement transaction if the table is a virtual\n  ** table.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto exit_rename_table;\n  }\n  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);\n  sqlite3ChangeCookie(pParse, iDb);\n\n  /* If this is a virtual table, invoke the xRename() function if\n  ** one is defined. The xRename() callback will modify the names\n  ** of any resources used by the v-table implementation (including other\n  ** SQLite tables) that are identified by the name of the virtual table.\n  */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pVTab ){\n    int i = ++pParse->nMem;\n    sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0);\n    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);\n    sqlite3MayAbort(pParse);\n  }\n#endif\n\n  /* figure out how many UTF-8 characters are in zName */\n  zTabName = pTab->zName;\n  nTabName = sqlite3Utf8CharLen(zTabName, -1);\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    /* If foreign-key support is enabled, rewrite the CREATE TABLE \n    ** statements corresponding to all child tables of foreign key constraints\n    ** for which the renamed table is the parent table.  */\n    if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){\n      sqlite3NestedParse(pParse, \n          \"UPDATE \\\"%w\\\".%s SET \"\n              \"sql = sqlite_rename_parent(sql, %Q, %Q) \"\n              \"WHERE %s;\", zDb, SCHEMA_TABLE(iDb), zTabName, zName, zWhere);\n      sqlite3DbFree(db, zWhere);\n    }\n  }\n#endif\n\n  /* Modify the sqlite_master table to use the new table name. */\n  sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s SET \"\n#ifdef SQLITE_OMIT_TRIGGER\n          \"sql = sqlite_rename_table(sql, %Q), \"\n#else\n          \"sql = CASE \"\n            \"WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)\"\n            \"ELSE sqlite_rename_table(sql, %Q) END, \"\n#endif\n          \"tbl_name = %Q, \"\n          \"name = CASE \"\n            \"WHEN type='table' THEN %Q \"\n            \"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN \"\n             \"'sqlite_autoindex_' || %Q || substr(name,%d+18) \"\n            \"ELSE name END \"\n      \"WHERE tbl_name=%Q COLLATE nocase AND \"\n          \"(type='table' OR type='index' OR type='trigger');\", \n      zDb, SCHEMA_TABLE(iDb), zName, zName, zName, \n#ifndef SQLITE_OMIT_TRIGGER\n      zName,\n#endif\n      zName, nTabName, zTabName\n  );\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* If the sqlite_sequence table exists in this database, then update \n  ** it with the new table name.\n  */\n  if( sqlite3FindTable(db, \"sqlite_sequence\", zDb) ){\n    sqlite3NestedParse(pParse,\n        \"UPDATE \\\"%w\\\".sqlite_sequence set name = %Q WHERE name = %Q\",\n        zDb, zName, pTab->zName);\n  }\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* If there are TEMP triggers on this table, modify the sqlite_temp_master\n  ** table. Don't do this if the table being ALTERed is itself located in\n  ** the temp database.\n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3NestedParse(pParse, \n        \"UPDATE sqlite_temp_master SET \"\n            \"sql = sqlite_rename_trigger(sql, %Q), \"\n            \"tbl_name = %Q \"\n            \"WHERE %s;\", zName, zName, zWhere);\n    sqlite3DbFree(db, zWhere);\n  }\n#endif\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Table *pFrom = p->pFrom;\n      if( pFrom!=pTab ){\n        reloadTableSchema(pParse, p->pFrom, pFrom->zName);\n      }\n    }\n  }\n#endif\n\n  /* Drop and reload the internal table schema. */\n  reloadTableSchema(pParse, pTab, zName);\n\nexit_rename_table:\n  sqlite3SrcListDelete(db, pSrc);\n  sqlite3DbFree(db, zName);\n  db->flags = savedDbFlags;\n}\n\n\n/*\n** Generate code to make sure the file format number is at least minFormat.\n** The generated code will increase the file format number if necessary.\n*/\nSQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse *pParse, int iDb, int minFormat){\n  Vdbe *v;\n  v = sqlite3GetVdbe(pParse);\n  /* The VDBE should have been allocated before this routine is called.\n  ** If that allocation failed, we would have quit before reaching this\n  ** point */\n  if( ALWAYS(v) ){\n    int r1 = sqlite3GetTempReg(pParse);\n    int r2 = sqlite3GetTempReg(pParse);\n    int j1;\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    sqlite3VdbeAddOp2(v, OP_Integer, minFormat, r2);\n    j1 = sqlite3VdbeAddOp3(v, OP_Ge, r2, 0, r1);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, r2);\n    sqlite3VdbeJumpHere(v, j1);\n    sqlite3ReleaseTempReg(pParse, r1);\n    sqlite3ReleaseTempReg(pParse, r2);\n  }\n}\n\n/*\n** This function is called after an \"ALTER TABLE ... ADD\" statement\n** has been parsed. Argument pColDef contains the text of the new\n** column definition.\n**\n** The Table structure pParse->pNewTable was extended to include\n** the new column during parsing.\n*/\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){\n  Table *pNew;              /* Copy of pParse->pNewTable */\n  Table *pTab;              /* Table being altered */\n  int iDb;                  /* Database number */\n  const char *zDb;          /* Database name */\n  const char *zTab;         /* Table name */\n  char *zCol;               /* Null-terminated column definition */\n  Column *pCol;             /* The new column */\n  Expr *pDflt;              /* Default value for the new column */\n  sqlite3 *db;              /* The database connection; */\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ) return;\n  pNew = pParse->pNewTable;\n  assert( pNew );\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);\n  zDb = db->aDb[iDb].zName;\n  zTab = &pNew->zName[16];  /* Skip the \"sqlite_altertab_\" prefix on the name */\n  pCol = &pNew->aCol[pNew->nCol-1];\n  pDflt = pCol->pDflt;\n  pTab = sqlite3FindTable(db, zTab, zDb);\n  assert( pTab );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    return;\n  }\n#endif\n\n  /* If the default value for the new column was specified with a \n  ** literal NULL, then set pDflt to 0. This simplifies checking\n  ** for an SQL NULL default below.\n  */\n  if( pDflt && pDflt->op==TK_NULL ){\n    pDflt = 0;\n  }\n\n  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.\n  ** If there is a NOT NULL constraint, then the default value for the\n  ** column must not be NULL.\n  */\n  if( pCol->colFlags & COLFLAG_PRIMKEY ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a PRIMARY KEY column\");\n    return;\n  }\n  if( pNew->pIndex ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a UNIQUE column\");\n    return;\n  }\n  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a REFERENCES column with non-NULL default value\");\n    return;\n  }\n  if( pCol->notNull && !pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a NOT NULL column with default value NULL\");\n    return;\n  }\n\n  /* Ensure the default expression is something that sqlite3ValueFromExpr()\n  ** can handle (i.e. not CURRENT_TIME etc.)\n  */\n  if( pDflt ){\n    sqlite3_value *pVal;\n    if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){\n      db->mallocFailed = 1;\n      return;\n    }\n    if( !pVal ){\n      sqlite3ErrorMsg(pParse, \"Cannot add a column with non-constant default\");\n      return;\n    }\n    sqlite3ValueFree(pVal);\n  }\n\n  /* Modify the CREATE TABLE statement. */\n  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);\n  if( zCol ){\n    char *zEnd = &zCol[pColDef->n-1];\n    int savedDbFlags = db->flags;\n    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){\n      *zEnd-- = '\\0';\n    }\n    db->flags |= SQLITE_PreferBuiltin;\n    sqlite3NestedParse(pParse, \n        \"UPDATE \\\"%w\\\".%s SET \"\n          \"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) \"\n        \"WHERE type = 'table' AND name = %Q\", \n      zDb, SCHEMA_TABLE(iDb), pNew->addColOffset, zCol, pNew->addColOffset+1,\n      zTab\n    );\n    sqlite3DbFree(db, zCol);\n    db->flags = savedDbFlags;\n  }\n\n  /* If the default value of the new column is NULL, then set the file\n  ** format to 2. If the default value of the new column is not NULL,\n  ** the file format becomes 3.\n  */\n  sqlite3MinimumFileFormat(pParse, iDb, pDflt ? 3 : 2);\n\n  /* Reload the schema of the modified table. */\n  reloadTableSchema(pParse, pTab, pTab->zName);\n}\n\n/*\n** This function is called by the parser after the table-name in\n** an \"ALTER TABLE <table-name> ADD\" statement is parsed. Argument \n** pSrc is the full-name of the table being altered.\n**\n** This routine makes a (partial) copy of the Table structure\n** for the table being altered and sets Parse.pNewTable to point\n** to it. Routines called by the parser as the column definition\n** is parsed (i.e. sqlite3AddColumn()) add the new Column data to \n** the copy. The copy of the Table structure is deleted by tokenize.c \n** after parsing is finished.\n**\n** Routine sqlite3AlterFinishAddColumn() will be called to complete\n** coding the \"ALTER TABLE ... ADD\" statement.\n*/\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){\n  Table *pNew;\n  Table *pTab;\n  Vdbe *v;\n  int iDb;\n  int i;\n  int nAlloc;\n  sqlite3 *db = pParse->db;\n\n  /* Look up the table being altered. */\n  assert( pParse->pNewTable==0 );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  if( db->mallocFailed ) goto exit_begin_add_column;\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_begin_add_column;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be altered\");\n    goto exit_begin_add_column;\n  }\n#endif\n\n  /* Make sure this is not an attempt to ALTER a view. */\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a column to a view\");\n    goto exit_begin_add_column;\n  }\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_begin_add_column;\n  }\n\n  assert( pTab->addColOffset>0 );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n  /* Put a copy of the Table struct in Parse.pNewTable for the\n  ** sqlite3AddColumn() function and friends to modify.  But modify\n  ** the name by adding an \"sqlite_altertab_\" prefix.  By adding this\n  ** prefix, we insure that the name will not collide with an existing\n  ** table because user table are not allowed to have the \"sqlite_\"\n  ** prefix on their name.\n  */\n  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));\n  if( !pNew ) goto exit_begin_add_column;\n  pParse->pNewTable = pNew;\n  pNew->nRef = 1;\n  pNew->nCol = pTab->nCol;\n  assert( pNew->nCol>0 );\n  nAlloc = (((pNew->nCol-1)/8)*8)+8;\n  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );\n  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);\n  pNew->zName = sqlite3MPrintf(db, \"sqlite_altertab_%s\", pTab->zName);\n  if( !pNew->aCol || !pNew->zName ){\n    db->mallocFailed = 1;\n    goto exit_begin_add_column;\n  }\n  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);\n  for(i=0; i<pNew->nCol; i++){\n    Column *pCol = &pNew->aCol[i];\n    pCol->zName = sqlite3DbStrDup(db, pCol->zName);\n    pCol->zColl = 0;\n    pCol->zType = 0;\n    pCol->pDflt = 0;\n    pCol->zDflt = 0;\n  }\n  pNew->pSchema = db->aDb[iDb].pSchema;\n  pNew->addColOffset = pTab->addColOffset;\n  pNew->nRef = 1;\n\n  /* Begin a transaction and increment the schema cookie.  */\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) goto exit_begin_add_column;\n  sqlite3ChangeCookie(pParse, iDb);\n\nexit_begin_add_column:\n  sqlite3SrcListDelete(db, pSrc);\n  return;\n}\n#endif  /* SQLITE_ALTER_TABLE */\n\n/************** End of alter.c ***********************************************/\n/************** Begin file analyze.c *****************************************/\n/*\n** 2005 July 8\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code associated with the ANALYZE command.\n**\n** The ANALYZE command gather statistics about the content of tables\n** and indices.  These statistics are made available to the query planner\n** to help it make better decisions about how to perform queries.\n**\n** The following system tables are or have been supported:\n**\n**    CREATE TABLE sqlite_stat1(tbl, idx, stat);\n**    CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);\n**    CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);\n**\n** Additional tables might be added in future releases of SQLite.\n** The sqlite_stat2 table is not created or used unless the SQLite version\n** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled\n** with SQLITE_ENABLE_STAT2.  The sqlite_stat2 table is deprecated.\n** The sqlite_stat2 table is superceded by sqlite_stat3, which is only\n** created and used by SQLite versions 3.7.9 and later and with\n** SQLITE_ENABLE_STAT3 defined.  The fucntionality of sqlite_stat3\n** is a superset of sqlite_stat2.  \n**\n** Format of sqlite_stat1:\n**\n** There is normally one row per index, with the index identified by the\n** name in the idx column.  The tbl column is the name of the table to\n** which the index belongs.  In each such row, the stat column will be\n** a string consisting of a list of integers.  The first integer in this\n** list is the number of rows in the index and in the table.  The second\n** integer is the average number of rows in the index that have the same\n** value in the first column of the index.  The third integer is the average\n** number of rows in the index that have the same value for the first two\n** columns.  The N-th integer (for N>1) is the average number of rows in \n** the index which have the same value for the first N-1 columns.  For\n** a K-column index, there will be K+1 integers in the stat column.  If\n** the index is unique, then the last integer will be 1.\n**\n** The list of integers in the stat column can optionally be followed\n** by the keyword \"unordered\".  The \"unordered\" keyword, if it is present,\n** must be separated from the last integer by a single space.  If the\n** \"unordered\" keyword is present, then the query planner assumes that\n** the index is unordered and will not use the index for a range query.\n** \n** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat\n** column contains a single integer which is the (estimated) number of\n** rows in the table identified by sqlite_stat1.tbl.\n**\n** Format of sqlite_stat2:\n**\n** The sqlite_stat2 is only created and is only used if SQLite is compiled\n** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between\n** 3.6.18 and 3.7.8.  The \"stat2\" table contains additional information\n** about the distribution of keys within an index.  The index is identified by\n** the \"idx\" column and the \"tbl\" column is the name of the table to which\n** the index belongs.  There are usually 10 rows in the sqlite_stat2\n** table for each index.\n**\n** The sqlite_stat2 entries for an index that have sampleno between 0 and 9\n** inclusive are samples of the left-most key value in the index taken at\n** evenly spaced points along the index.  Let the number of samples be S\n** (10 in the standard build) and let C be the number of rows in the index.\n** Then the sampled rows are given by:\n**\n**     rownumber = (i*C*2 + C)/(S*2)\n**\n** For i between 0 and S-1.  Conceptually, the index space is divided into\n** S uniform buckets and the samples are the middle row from each bucket.\n**\n** The format for sqlite_stat2 is recorded here for legacy reference.  This\n** version of SQLite does not support sqlite_stat2.  It neither reads nor\n** writes the sqlite_stat2 table.  This version of SQLite only supports\n** sqlite_stat3.\n**\n** Format for sqlite_stat3:\n**\n** The sqlite_stat3 is an enhancement to sqlite_stat2.  A new name is\n** used to avoid compatibility problems.  \n**\n** The format of the sqlite_stat3 table is similar to the format of\n** the sqlite_stat2 table.  There are multiple entries for each index.\n** The idx column names the index and the tbl column is the table of the\n** index.  If the idx and tbl columns are the same, then the sample is\n** of the INTEGER PRIMARY KEY.  The sample column is a value taken from\n** the left-most column of the index.  The nEq column is the approximate\n** number of entires in the index whose left-most column exactly matches\n** the sample.  nLt is the approximate number of entires whose left-most\n** column is less than the sample.  The nDLt column is the approximate\n** number of distinct left-most entries in the index that are less than\n** the sample.\n**\n** Future versions of SQLite might change to store a string containing\n** multiple integers values in the nDLt column of sqlite_stat3.  The first\n** integer will be the number of prior index entires that are distinct in\n** the left-most column.  The second integer will be the number of prior index\n** entries that are distinct in the first two columns.  The third integer\n** will be the number of prior index entries that are distinct in the first\n** three columns.  And so forth.  With that extension, the nDLt field is\n** similar in function to the sqlite_stat1.stat field.\n**\n** There can be an arbitrary number of sqlite_stat3 entries per index.\n** The ANALYZE command will typically generate sqlite_stat3 tables\n** that contain between 10 and 40 samples which are distributed across\n** the key space, though not uniformly, and which include samples with\n** largest possible nEq values.\n*/\n#ifndef SQLITE_OMIT_ANALYZE\n\n/*\n** This routine generates code that opens the sqlite_stat1 table for\n** writing with cursor iStatCur. If the library was built with the\n** SQLITE_ENABLE_STAT3 macro defined, then the sqlite_stat3 table is\n** opened for writing using cursor (iStatCur+1)\n**\n** If the sqlite_stat1 tables does not previously exist, it is created.\n** Similarly, if the sqlite_stat3 table does not exist and the library\n** is compiled with SQLITE_ENABLE_STAT3 defined, it is created. \n**\n** Argument zWhere may be a pointer to a buffer containing a table name,\n** or it may be a NULL pointer. If it is not NULL, then all entries in\n** the sqlite_stat1 and (if applicable) sqlite_stat3 tables associated\n** with the named table are deleted. If zWhere==0, then code is generated\n** to delete all stat table entries.\n*/\nstatic void openStatTable(\n  Parse *pParse,          /* Parsing context */\n  int iDb,                /* The database we are looking in */\n  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */\n  const char *zWhere,     /* Delete entries for this table or index */\n  const char *zWhereType  /* Either \"tbl\" or \"idx\" */\n){\n  static const struct {\n    const char *zName;\n    const char *zCols;\n  } aTable[] = {\n    { \"sqlite_stat1\", \"tbl,idx,stat\" },\n#ifdef SQLITE_ENABLE_STAT3\n    { \"sqlite_stat3\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n#endif\n  };\n\n  int aRoot[] = {0, 0};\n  u8 aCreateTbl[] = {0, 0};\n\n  int i;\n  sqlite3 *db = pParse->db;\n  Db *pDb;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v==0 ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3VdbeDb(v)==db );\n  pDb = &db->aDb[iDb];\n\n  /* Create new statistic tables if they do not exist, or clear them\n  ** if they do already exist.\n  */\n  for(i=0; i<ArraySize(aTable); i++){\n    const char *zTab = aTable[i].zName;\n    Table *pStat;\n    if( (pStat = sqlite3FindTable(db, zTab, pDb->zName))==0 ){\n      /* The sqlite_stat[12] table does not exist. Create it. Note that a \n      ** side-effect of the CREATE TABLE statement is to leave the rootpage \n      ** of the new table in register pParse->regRoot. This is important \n      ** because the OpenWrite opcode below will be needing it. */\n      sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.%s(%s)\", pDb->zName, zTab, aTable[i].zCols\n      );\n      aRoot[i] = pParse->regRoot;\n      aCreateTbl[i] = OPFLAG_P2ISREG;\n    }else{\n      /* The table already exists. If zWhere is not NULL, delete all entries \n      ** associated with the table zWhere. If zWhere is NULL, delete the\n      ** entire contents of the table. */\n      aRoot[i] = pStat->tnum;\n      sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);\n      if( zWhere ){\n        sqlite3NestedParse(pParse,\n           \"DELETE FROM %Q.%s WHERE %s=%Q\", pDb->zName, zTab, zWhereType, zWhere\n        );\n      }else{\n        /* The sqlite_stat[12] table already exists.  Delete all rows. */\n        sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);\n      }\n    }\n  }\n\n  /* Open the sqlite_stat[13] tables for writing. */\n  for(i=0; i<ArraySize(aTable); i++){\n    sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb);\n    sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32);\n    sqlite3VdbeChangeP5(v, aCreateTbl[i]);\n  }\n}\n\n/*\n** Recommended number of samples for sqlite_stat3\n*/\n#ifndef SQLITE_STAT3_SAMPLES\n# define SQLITE_STAT3_SAMPLES 24\n#endif\n\n/*\n** Three SQL functions - stat3_init(), stat3_push(), and stat3_pop() -\n** share an instance of the following structure to hold their state\n** information.\n*/\ntypedef struct Stat3Accum Stat3Accum;\nstruct Stat3Accum {\n  tRowcnt nRow;             /* Number of rows in the entire table */\n  tRowcnt nPSample;         /* How often to do a periodic sample */\n  int iMin;                 /* Index of entry with minimum nEq and hash */\n  int mxSample;             /* Maximum number of samples to accumulate */\n  int nSample;              /* Current number of samples */\n  u32 iPrn;                 /* Pseudo-random number used for sampling */\n  struct Stat3Sample {\n    i64 iRowid;                /* Rowid in main table of the key */\n    tRowcnt nEq;               /* sqlite_stat3.nEq */\n    tRowcnt nLt;               /* sqlite_stat3.nLt */\n    tRowcnt nDLt;              /* sqlite_stat3.nDLt */\n    u8 isPSample;              /* True if a periodic sample */\n    u32 iHash;                 /* Tiebreaker hash */\n  } *a;                     /* An array of samples */\n};\n\n#ifdef SQLITE_ENABLE_STAT3\n/*\n** Implementation of the stat3_init(C,S) SQL function.  The two parameters\n** are the number of rows in the table or index (C) and the number of samples\n** to accumulate (S).\n**\n** This routine allocates the Stat3Accum object.\n**\n** The return value is the Stat3Accum object (P).\n*/\nstatic void stat3Init(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat3Accum *p;\n  tRowcnt nRow;\n  int mxSample;\n  int n;\n\n  UNUSED_PARAMETER(argc);\n  nRow = (tRowcnt)sqlite3_value_int64(argv[0]);\n  mxSample = sqlite3_value_int(argv[1]);\n  n = sizeof(*p) + sizeof(p->a[0])*mxSample;\n  p = sqlite3MallocZero( n );\n  if( p==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  p->a = (struct Stat3Sample*)&p[1];\n  p->nRow = nRow;\n  p->mxSample = mxSample;\n  p->nPSample = p->nRow/(mxSample/3+1) + 1;\n  sqlite3_randomness(sizeof(p->iPrn), &p->iPrn);\n  sqlite3_result_blob(context, p, sizeof(p), sqlite3_free);\n}\nstatic const FuncDef stat3InitFuncdef = {\n  2,                /* nArg */\n  SQLITE_UTF8,      /* iPrefEnc */\n  0,                /* flags */\n  0,                /* pUserData */\n  0,                /* pNext */\n  stat3Init,        /* xFunc */\n  0,                /* xStep */\n  0,                /* xFinalize */\n  \"stat3_init\",     /* zName */\n  0,                /* pHash */\n  0                 /* pDestructor */\n};\n\n\n/*\n** Implementation of the stat3_push(nEq,nLt,nDLt,rowid,P) SQL function.  The\n** arguments describe a single key instance.  This routine makes the \n** decision about whether or not to retain this key for the sqlite_stat3\n** table.\n**\n** The return value is NULL.\n*/\nstatic void stat3Push(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[4]);\n  tRowcnt nEq = sqlite3_value_int64(argv[0]);\n  tRowcnt nLt = sqlite3_value_int64(argv[1]);\n  tRowcnt nDLt = sqlite3_value_int64(argv[2]);\n  i64 rowid = sqlite3_value_int64(argv[3]);\n  u8 isPSample = 0;\n  u8 doInsert = 0;\n  int iMin = p->iMin;\n  struct Stat3Sample *pSample;\n  int i;\n  u32 h;\n\n  UNUSED_PARAMETER(context);\n  UNUSED_PARAMETER(argc);\n  if( nEq==0 ) return;\n  h = p->iPrn = p->iPrn*1103515245 + 12345;\n  if( (nLt/p->nPSample)!=((nEq+nLt)/p->nPSample) ){\n    doInsert = isPSample = 1;\n  }else if( p->nSample<p->mxSample ){\n    doInsert = 1;\n  }else{\n    if( nEq>p->a[iMin].nEq || (nEq==p->a[iMin].nEq && h>p->a[iMin].iHash) ){\n      doInsert = 1;\n    }\n  }\n  if( !doInsert ) return;\n  if( p->nSample==p->mxSample ){\n    assert( p->nSample - iMin - 1 >= 0 );\n    memmove(&p->a[iMin], &p->a[iMin+1], sizeof(p->a[0])*(p->nSample-iMin-1));\n    pSample = &p->a[p->nSample-1];\n  }else{\n    pSample = &p->a[p->nSample++];\n  }\n  pSample->iRowid = rowid;\n  pSample->nEq = nEq;\n  pSample->nLt = nLt;\n  pSample->nDLt = nDLt;\n  pSample->iHash = h;\n  pSample->isPSample = isPSample;\n\n  /* Find the new minimum */\n  if( p->nSample==p->mxSample ){\n    pSample = p->a;\n    i = 0;\n    while( pSample->isPSample ){\n      i++;\n      pSample++;\n      assert( i<p->nSample );\n    }\n    nEq = pSample->nEq;\n    h = pSample->iHash;\n    iMin = i;\n    for(i++, pSample++; i<p->nSample; i++, pSample++){\n      if( pSample->isPSample ) continue;\n      if( pSample->nEq<nEq\n       || (pSample->nEq==nEq && pSample->iHash<h)\n      ){\n        iMin = i;\n        nEq = pSample->nEq;\n        h = pSample->iHash;\n      }\n    }\n    p->iMin = iMin;\n  }\n}\nstatic const FuncDef stat3PushFuncdef = {\n  5,                /* nArg */\n  SQLITE_UTF8,      /* iPrefEnc */\n  0,                /* flags */\n  0,                /* pUserData */\n  0,                /* pNext */\n  stat3Push,        /* xFunc */\n  0,                /* xStep */\n  0,                /* xFinalize */\n  \"stat3_push\",     /* zName */\n  0,                /* pHash */\n  0                 /* pDestructor */\n};\n\n/*\n** Implementation of the stat3_get(P,N,...) SQL function.  This routine is\n** used to query the results.  Content is returned for the Nth sqlite_stat3\n** row where N is between 0 and S-1 and S is the number of samples.  The\n** value returned depends on the number of arguments.\n**\n**   argc==2    result:  rowid\n**   argc==3    result:  nEq\n**   argc==4    result:  nLt\n**   argc==5    result:  nDLt\n*/\nstatic void stat3Get(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n = sqlite3_value_int(argv[1]);\n  Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[0]);\n\n  assert( p!=0 );\n  if( p->nSample<=n ) return;\n  switch( argc ){\n    case 2:  sqlite3_result_int64(context, p->a[n].iRowid); break;\n    case 3:  sqlite3_result_int64(context, p->a[n].nEq);    break;\n    case 4:  sqlite3_result_int64(context, p->a[n].nLt);    break;\n    default: sqlite3_result_int64(context, p->a[n].nDLt);   break;\n  }\n}\nstatic const FuncDef stat3GetFuncdef = {\n  -1,               /* nArg */\n  SQLITE_UTF8,      /* iPrefEnc */\n  0,                /* flags */\n  0,                /* pUserData */\n  0,                /* pNext */\n  stat3Get,         /* xFunc */\n  0,                /* xStep */\n  0,                /* xFinalize */\n  \"stat3_get\",     /* zName */\n  0,                /* pHash */\n  0                 /* pDestructor */\n};\n#endif /* SQLITE_ENABLE_STAT3 */\n\n\n\n\n/*\n** Generate code to do an analysis of all indices associated with\n** a single table.\n*/\nstatic void analyzeOneTable(\n  Parse *pParse,   /* Parser context */\n  Table *pTab,     /* Table whose indices are to be analyzed */\n  Index *pOnlyIdx, /* If not NULL, only analyze this one index */\n  int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */\n  int iMem         /* Available memory locations begin here */\n){\n  sqlite3 *db = pParse->db;    /* Database handle */\n  Index *pIdx;                 /* An index to being analyzed */\n  int iIdxCur;                 /* Cursor open on index being analyzed */\n  Vdbe *v;                     /* The virtual machine being built up */\n  int i;                       /* Loop counter */\n  int topOfLoop;               /* The top of the loop */\n  int endOfLoop;               /* The end of the loop */\n  int jZeroRows = -1;          /* Jump from here if number of rows is zero */\n  int iDb;                     /* Index of database containing pTab */\n  int regTabname = iMem++;     /* Register containing table name */\n  int regIdxname = iMem++;     /* Register containing index name */\n  int regStat1 = iMem++;       /* The stat column of sqlite_stat1 */\n#ifdef SQLITE_ENABLE_STAT3\n  int regNumEq = regStat1;     /* Number of instances.  Same as regStat1 */\n  int regNumLt = iMem++;       /* Number of keys less than regSample */\n  int regNumDLt = iMem++;      /* Number of distinct keys less than regSample */\n  int regSample = iMem++;      /* The next sample value */\n  int regRowid = regSample;    /* Rowid of a sample */\n  int regAccum = iMem++;       /* Register to hold Stat3Accum object */\n  int regLoop = iMem++;        /* Loop counter */\n  int regCount = iMem++;       /* Number of rows in the table or index */\n  int regTemp1 = iMem++;       /* Intermediate register */\n  int regTemp2 = iMem++;       /* Intermediate register */\n  int once = 1;                /* One-time initialization */\n  int shortJump = 0;           /* Instruction address */\n  int iTabCur = pParse->nTab++; /* Table cursor */\n#endif\n  int regCol = iMem++;         /* Content of a column in analyzed table */\n  int regRec = iMem++;         /* Register holding completed record */\n  int regTemp = iMem++;        /* Temporary use register */\n  int regNewRowid = iMem++;    /* Rowid for the inserted record */\n\n\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 || NEVER(pTab==0) ){\n    return;\n  }\n  if( pTab->tnum==0 ){\n    /* Do not gather statistics on views or virtual tables */\n    return;\n  }\n  if( sqlite3_strnicmp(pTab->zName, \"sqlite_\", 7)==0 ){\n    /* Do not gather statistics on system tables */\n    return;\n  }\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,\n      db->aDb[iDb].zName ) ){\n    return;\n  }\n#endif\n\n  /* Establish a read-lock on the table at the shared-cache level. */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n  iIdxCur = pParse->nTab++;\n  sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0);\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int nCol;\n    KeyInfo *pKey;\n    int addrIfNot = 0;           /* address of OP_IfNot */\n    int *aChngAddr;              /* Array of jump instruction addresses */\n\n    if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;\n    VdbeNoopComment((v, \"Begin analysis of %s\", pIdx->zName));\n    nCol = pIdx->nColumn;\n    aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol);\n    if( aChngAddr==0 ) continue;\n    pKey = sqlite3IndexKeyinfo(pParse, pIdx);\n    if( iMem+1+(nCol*2)>pParse->nMem ){\n      pParse->nMem = iMem+1+(nCol*2);\n    }\n\n    /* Open a cursor to the index to be analyzed. */\n    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );\n    sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb,\n        (char *)pKey, P4_KEYINFO_HANDOFF);\n    VdbeComment((v, \"%s\", pIdx->zName));\n\n    /* Populate the register containing the index name. */\n    sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0);\n\n#ifdef SQLITE_ENABLE_STAT3\n    if( once ){\n      once = 0;\n      sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n    }\n    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regCount);\n    sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_STAT3_SAMPLES, regTemp1);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumEq);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumLt);\n    sqlite3VdbeAddOp2(v, OP_Integer, -1, regNumDLt);\n    sqlite3VdbeAddOp3(v, OP_Null, 0, regSample, regAccum);\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regCount, regAccum,\n                      (char*)&stat3InitFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2);\n#endif /* SQLITE_ENABLE_STAT3 */\n\n    /* The block of memory cells initialized here is used as follows.\n    **\n    **    iMem:                \n    **        The total number of rows in the table.\n    **\n    **    iMem+1 .. iMem+nCol: \n    **        Number of distinct entries in index considering the \n    **        left-most N columns only, where N is between 1 and nCol, \n    **        inclusive.\n    **\n    **    iMem+nCol+1 .. Mem+2*nCol:  \n    **        Previous value of indexed columns, from left to right.\n    **\n    ** Cells iMem through iMem+nCol are initialized to 0. The others are \n    ** initialized to contain an SQL NULL.\n    */\n    for(i=0; i<=nCol; i++){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iMem+i);\n    }\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, iMem+nCol+i+1);\n    }\n\n    /* Start the analysis loop. This loop runs through all the entries in\n    ** the index b-tree.  */\n    endOfLoop = sqlite3VdbeMakeLabel(v);\n    sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop);\n    topOfLoop = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1);  /* Increment row counter */\n\n    for(i=0; i<nCol; i++){\n      CollSeq *pColl;\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol);\n      if( i==0 ){\n        /* Always record the very first row */\n        addrIfNot = sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1);\n      }\n      assert( pIdx->azColl!=0 );\n      assert( pIdx->azColl[i]!=0 );\n      pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);\n      aChngAddr[i] = sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1,\n                                      (char*)pColl, P4_COLLSEQ);\n      sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n      VdbeComment((v, \"jump if column %d changed\", i));\n#ifdef SQLITE_ENABLE_STAT3\n      if( i==0 ){\n        sqlite3VdbeAddOp2(v, OP_AddImm, regNumEq, 1);\n        VdbeComment((v, \"incr repeat count\"));\n      }\n#endif\n    }\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop);\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeJumpHere(v, aChngAddr[i]);  /* Set jump dest for the OP_Ne */\n      if( i==0 ){\n        sqlite3VdbeJumpHere(v, addrIfNot);   /* Jump dest for OP_IfNot */\n#ifdef SQLITE_ENABLE_STAT3\n        sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2,\n                          (char*)&stat3PushFuncdef, P4_FUNCDEF);\n        sqlite3VdbeChangeP5(v, 5);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, pIdx->nColumn, regRowid);\n        sqlite3VdbeAddOp3(v, OP_Add, regNumEq, regNumLt, regNumLt);\n        sqlite3VdbeAddOp2(v, OP_AddImm, regNumDLt, 1);\n        sqlite3VdbeAddOp2(v, OP_Integer, 1, regNumEq);\n#endif        \n      }\n      sqlite3VdbeAddOp2(v, OP_AddImm, iMem+i+1, 1);\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem+nCol+i+1);\n    }\n    sqlite3DbFree(db, aChngAddr);\n\n    /* Always jump here after updating the iMem+1...iMem+1+nCol counters */\n    sqlite3VdbeResolveLabel(v, endOfLoop);\n\n    sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop);\n    sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);\n#ifdef SQLITE_ENABLE_STAT3\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2,\n                      (char*)&stat3PushFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 5);\n    sqlite3VdbeAddOp2(v, OP_Integer, -1, regLoop);\n    shortJump = \n    sqlite3VdbeAddOp2(v, OP_AddImm, regLoop, 1);\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regTemp1,\n                      (char*)&stat3GetFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2);\n    sqlite3VdbeAddOp1(v, OP_IsNull, regTemp1);\n    sqlite3VdbeAddOp3(v, OP_NotExists, iTabCur, shortJump, regTemp1);\n    sqlite3VdbeAddOp3(v, OP_Column, iTabCur, pIdx->aiColumn[0], regSample);\n    sqlite3ColumnDefault(v, pTab, pIdx->aiColumn[0], regSample);\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumEq,\n                      (char*)&stat3GetFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 3);\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumLt,\n                      (char*)&stat3GetFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 4);\n    sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumDLt,\n                      (char*)&stat3GetFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 5);\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 6, regRec, \"bbbbbb\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regNewRowid);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, shortJump);\n    sqlite3VdbeJumpHere(v, shortJump+2);\n#endif        \n\n    /* Store the results in sqlite_stat1.\n    **\n    ** The result is a single row of the sqlite_stat1 table.  The first\n    ** two columns are the names of the table and index.  The third column\n    ** is a string composed of a list of integer statistics about the\n    ** index.  The first integer in the list is the total number of entries\n    ** in the index.  There is one additional integer in the list for each\n    ** column of the table.  This additional integer is a guess of how many\n    ** rows of the table the index will select.  If D is the count of distinct\n    ** values and K is the total number of rows, then the integer is computed\n    ** as:\n    **\n    **        I = (K+D-1)/D\n    **\n    ** If K==0 then no entry is made into the sqlite_stat1 table.  \n    ** If K>0 then it is always the case the D>0 so division by zero\n    ** is never possible.\n    */\n    sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1);\n    if( jZeroRows<0 ){\n      jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem);\n    }\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, \" \", 0);\n      sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);\n      sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp);\n      sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1);\n      sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp);\n      sqlite3VdbeAddOp1(v, OP_ToInt, regTemp);\n      sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1);\n    }\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, \"aaa\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n  }\n\n  /* If the table has no indices, create a single sqlite_stat1 entry\n  ** containing NULL as the index name and the row count as the content.\n  */\n  if( pTab->pIndex==0 ){\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb);\n    VdbeComment((v, \"%s\", pTab->zName));\n    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1);\n    sqlite3VdbeAddOp1(v, OP_Close, iIdxCur);\n    jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1);\n  }else{\n    sqlite3VdbeJumpHere(v, jZeroRows);\n    jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto);\n  }\n  sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);\n  sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, \"aaa\", 0);\n  sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n  sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid);\n  sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n  if( pParse->nMem<regRec ) pParse->nMem = regRec;\n  sqlite3VdbeJumpHere(v, jZeroRows);\n}\n\n\n/*\n** Generate code that will cause the most recent index analysis to\n** be loaded into internal hash tables where is can be used.\n*/\nstatic void loadAnalysis(Parse *pParse, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb);\n  }\n}\n\n/*\n** Generate code that will do an analysis of an entire database\n*/\nstatic void analyzeDatabase(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Schema *pSchema = db->aDb[iDb].pSchema;    /* Schema of database iDb */\n  HashElem *k;\n  int iStatCur;\n  int iMem;\n\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  openStatTable(pParse, iDb, iStatCur, 0, 0);\n  iMem = pParse->nMem+1;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n    Table *pTab = (Table*)sqliteHashData(k);\n    analyzeOneTable(pParse, pTab, 0, iStatCur, iMem);\n  }\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code that will do an analysis of a single table in\n** a database.  If pOnlyIdx is not NULL then it is a single index\n** in pTab that should be analyzed.\n*/\nstatic void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){\n  int iDb;\n  int iStatCur;\n\n  assert( pTab!=0 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  if( pOnlyIdx ){\n    openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, \"idx\");\n  }else{\n    openStatTable(pParse, iDb, iStatCur, pTab->zName, \"tbl\");\n  }\n  analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur, pParse->nMem+1);\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code for the ANALYZE command.  The parser calls this routine\n** when it recognizes an ANALYZE command.\n**\n**        ANALYZE                            -- 1\n**        ANALYZE  <database>                -- 2\n**        ANALYZE  ?<database>.?<tablename>  -- 3\n**\n** Form 1 causes all indices in all attached databases to be analyzed.\n** Form 2 analyzes all indices the single database named.\n** Form 3 analyzes all indices associated with the named table.\n*/\nSQLITE_PRIVATE void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int i;\n  char *z, *zDb;\n  Table *pTab;\n  Index *pIdx;\n  Token *pTableName;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  assert( pName2!=0 || pName1==0 );\n  if( pName1==0 ){\n    /* Form 1:  Analyze everything */\n    for(i=0; i<db->nDb; i++){\n      if( i==1 ) continue;  /* Do not analyze the TEMP database */\n      analyzeDatabase(pParse, i);\n    }\n  }else if( pName2->n==0 ){\n    /* Form 2:  Analyze the database or table named */\n    iDb = sqlite3FindDb(db, pName1);\n    if( iDb>=0 ){\n      analyzeDatabase(pParse, iDb);\n    }else{\n      z = sqlite3NameFromToken(db, pName1);\n      if( z ){\n        if( (pIdx = sqlite3FindIndex(db, z, 0))!=0 ){\n          analyzeTable(pParse, pIdx->pTable, pIdx);\n        }else if( (pTab = sqlite3LocateTable(pParse, 0, z, 0))!=0 ){\n          analyzeTable(pParse, pTab, 0);\n        }\n        sqlite3DbFree(db, z);\n      }\n    }\n  }else{\n    /* Form 3: Analyze the fully qualified table name */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);\n    if( iDb>=0 ){\n      zDb = db->aDb[iDb].zName;\n      z = sqlite3NameFromToken(db, pTableName);\n      if( z ){\n        if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){\n          analyzeTable(pParse, pIdx->pTable, pIdx);\n        }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){\n          analyzeTable(pParse, pTab, 0);\n        }\n        sqlite3DbFree(db, z);\n      }\n    }   \n  }\n}\n\n/*\n** Used to pass information from the analyzer reader through to the\n** callback routine.\n*/\ntypedef struct analysisInfo analysisInfo;\nstruct analysisInfo {\n  sqlite3 *db;\n  const char *zDatabase;\n};\n\n/*\n** This callback is invoked once for each index when reading the\n** sqlite_stat1 table.  \n**\n**     argv[0] = name of the table\n**     argv[1] = name of the index (might be NULL)\n**     argv[2] = results of analysis - on integer for each column\n**\n** Entries for which argv[1]==NULL simply record the number of rows in\n** the table.\n*/\nstatic int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){\n  analysisInfo *pInfo = (analysisInfo*)pData;\n  Index *pIndex;\n  Table *pTable;\n  int i, c, n;\n  tRowcnt v;\n  const char *z;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n\n  if( argv==0 || argv[0]==0 || argv[2]==0 ){\n    return 0;\n  }\n  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);\n  if( pTable==0 ){\n    return 0;\n  }\n  if( argv[1] ){\n    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);\n  }else{\n    pIndex = 0;\n  }\n  n = pIndex ? pIndex->nColumn : 0;\n  z = argv[2];\n  for(i=0; *z && i<=n; i++){\n    v = 0;\n    while( (c=z[0])>='0' && c<='9' ){\n      v = v*10 + c - '0';\n      z++;\n    }\n    if( i==0 ) pTable->nRowEst = v;\n    if( pIndex==0 ) break;\n    pIndex->aiRowEst[i] = v;\n    if( *z==' ' ) z++;\n    if( strcmp(z, \"unordered\")==0 ){\n      pIndex->bUnordered = 1;\n      break;\n    }\n  }\n  return 0;\n}\n\n/*\n** If the Index.aSample variable is not NULL, delete the aSample[] array\n** and its contents.\n*/\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){\n#ifdef SQLITE_ENABLE_STAT3\n  if( pIdx->aSample ){\n    int j;\n    for(j=0; j<pIdx->nSample; j++){\n      IndexSample *p = &pIdx->aSample[j];\n      if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){\n        sqlite3DbFree(db, p->u.z);\n      }\n    }\n    sqlite3DbFree(db, pIdx->aSample);\n  }\n  if( db && db->pnBytesFreed==0 ){\n    pIdx->nSample = 0;\n    pIdx->aSample = 0;\n  }\n#else\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pIdx);\n#endif\n}\n\n#ifdef SQLITE_ENABLE_STAT3\n/*\n** Load content from the sqlite_stat3 table into the Index.aSample[]\n** arrays of all indices.\n*/\nstatic int loadStat3(sqlite3 *db, const char *zDb){\n  int rc;                       /* Result codes from subroutines */\n  sqlite3_stmt *pStmt = 0;      /* An SQL statement being run */\n  char *zSql;                   /* Text of the SQL statement */\n  Index *pPrevIdx = 0;          /* Previous index in the loop */\n  int idx = 0;                  /* slot in pIdx->aSample[] for next sample */\n  int eType;                    /* Datatype of a sample */\n  IndexSample *pSample;         /* A slot in pIdx->aSample[] */\n\n  assert( db->lookaside.bEnabled==0 );\n  if( !sqlite3FindTable(db, \"sqlite_stat3\", zDb) ){\n    return SQLITE_OK;\n  }\n\n  zSql = sqlite3MPrintf(db, \n      \"SELECT idx,count(*) FROM %Q.sqlite_stat3\"\n      \" GROUP BY idx\", zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    char *zIndex;   /* Index name */\n    Index *pIdx;    /* Pointer to the index object */\n    int nSample;    /* Number of samples */\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    nSample = sqlite3_column_int(pStmt, 1);\n    pIdx = sqlite3FindIndex(db, zIndex, zDb);\n    if( pIdx==0 ) continue;\n    assert( pIdx->nSample==0 );\n    pIdx->nSample = nSample;\n    pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));\n    pIdx->avgEq = pIdx->aiRowEst[1];\n    if( pIdx->aSample==0 ){\n      db->mallocFailed = 1;\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM;\n    }\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc ) return rc;\n\n  zSql = sqlite3MPrintf(db, \n      \"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat3\", zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    char *zIndex;   /* Index name */\n    Index *pIdx;    /* Pointer to the index object */\n    int i;          /* Loop counter */\n    tRowcnt sumEq;  /* Sum of the nEq values */\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    pIdx = sqlite3FindIndex(db, zIndex, zDb);\n    if( pIdx==0 ) continue;\n    if( pIdx==pPrevIdx ){\n      idx++;\n    }else{\n      pPrevIdx = pIdx;\n      idx = 0;\n    }\n    assert( idx<pIdx->nSample );\n    pSample = &pIdx->aSample[idx];\n    pSample->nEq = (tRowcnt)sqlite3_column_int64(pStmt, 1);\n    pSample->nLt = (tRowcnt)sqlite3_column_int64(pStmt, 2);\n    pSample->nDLt = (tRowcnt)sqlite3_column_int64(pStmt, 3);\n    if( idx==pIdx->nSample-1 ){\n      if( pSample->nDLt>0 ){\n        for(i=0, sumEq=0; i<=idx-1; i++) sumEq += pIdx->aSample[i].nEq;\n        pIdx->avgEq = (pSample->nLt - sumEq)/pSample->nDLt;\n      }\n      if( pIdx->avgEq<=0 ) pIdx->avgEq = 1;\n    }\n    eType = sqlite3_column_type(pStmt, 4);\n    pSample->eType = (u8)eType;\n    switch( eType ){\n      case SQLITE_INTEGER: {\n        pSample->u.i = sqlite3_column_int64(pStmt, 4);\n        break;\n      }\n      case SQLITE_FLOAT: {\n        pSample->u.r = sqlite3_column_double(pStmt, 4);\n        break;\n      }\n      case SQLITE_NULL: {\n        break;\n      }\n      default: assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); {\n        const char *z = (const char *)(\n              (eType==SQLITE_BLOB) ?\n              sqlite3_column_blob(pStmt, 4):\n              sqlite3_column_text(pStmt, 4)\n           );\n        int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;\n        pSample->nByte = n;\n        if( n < 1){\n          pSample->u.z = 0;\n        }else{\n          pSample->u.z = sqlite3DbMallocRaw(db, n);\n          if( pSample->u.z==0 ){\n            db->mallocFailed = 1;\n            sqlite3_finalize(pStmt);\n            return SQLITE_NOMEM;\n          }\n          memcpy(pSample->u.z, z, n);\n        }\n      }\n    }\n  }\n  return sqlite3_finalize(pStmt);\n}\n#endif /* SQLITE_ENABLE_STAT3 */\n\n/*\n** Load the content of the sqlite_stat1 and sqlite_stat3 tables. The\n** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]\n** arrays. The contents of sqlite_stat3 are used to populate the\n** Index.aSample[] arrays.\n**\n** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR\n** is returned. In this case, even if SQLITE_ENABLE_STAT3 was defined \n** during compilation and the sqlite_stat3 table is present, no data is \n** read from it.\n**\n** If SQLITE_ENABLE_STAT3 was defined during compilation and the \n** sqlite_stat3 table is not present in the database, SQLITE_ERROR is\n** returned. However, in this case, data is read from the sqlite_stat1\n** table (if it is present) before returning.\n**\n** If an OOM error occurs, this function always sets db->mallocFailed.\n** This means if the caller does not care about other errors, the return\n** code may be ignored.\n*/\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){\n  analysisInfo sInfo;\n  HashElem *i;\n  char *zSql;\n  int rc;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n\n  /* Clear any prior statistics */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    sqlite3DefaultRowEst(pIdx);\n#ifdef SQLITE_ENABLE_STAT3\n    sqlite3DeleteIndexSamples(db, pIdx);\n    pIdx->aSample = 0;\n#endif\n  }\n\n  /* Check to make sure the sqlite_stat1 table exists */\n  sInfo.db = db;\n  sInfo.zDatabase = db->aDb[iDb].zName;\n  if( sqlite3FindTable(db, \"sqlite_stat1\", sInfo.zDatabase)==0 ){\n    return SQLITE_ERROR;\n  }\n\n  /* Load new statistics out of the sqlite_stat1 table */\n  zSql = sqlite3MPrintf(db, \n      \"SELECT tbl,idx,stat FROM %Q.sqlite_stat1\", sInfo.zDatabase);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);\n    sqlite3DbFree(db, zSql);\n  }\n\n\n  /* Load the statistics from the sqlite_stat3 table. */\n#ifdef SQLITE_ENABLE_STAT3\n  if( rc==SQLITE_OK ){\n    int lookasideEnabled = db->lookaside.bEnabled;\n    db->lookaside.bEnabled = 0;\n    rc = loadStat3(db, sInfo.zDatabase);\n    db->lookaside.bEnabled = lookasideEnabled;\n  }\n#endif\n\n  if( rc==SQLITE_NOMEM ){\n    db->mallocFailed = 1;\n  }\n  return rc;\n}\n\n\n#endif /* SQLITE_OMIT_ANALYZE */\n\n/************** End of analyze.c *********************************************/\n/************** Begin file attach.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the ATTACH and DETACH commands.\n*/\n\n#ifndef SQLITE_OMIT_ATTACH\n/*\n** Resolve an expression that was part of an ATTACH or DETACH statement. This\n** is slightly different from resolving a normal SQL expression, because simple\n** identifiers are treated as strings, not possible column names or aliases.\n**\n** i.e. if the parser sees:\n**\n**     ATTACH DATABASE abc AS def\n**\n** it treats the two expressions as literal strings 'abc' and 'def' instead of\n** looking for columns of the same name.\n**\n** This only applies to the root node of pExpr, so the statement:\n**\n**     ATTACH DATABASE abc||def AS 'db2'\n**\n** will fail because neither abc or def can be resolved.\n*/\nstatic int resolveAttachExpr(NameContext *pName, Expr *pExpr)\n{\n  int rc = SQLITE_OK;\n  if( pExpr ){\n    if( pExpr->op!=TK_ID ){\n      rc = sqlite3ResolveExprNames(pName, pExpr);\n      if( rc==SQLITE_OK && !sqlite3ExprIsConstant(pExpr) ){\n        sqlite3ErrorMsg(pName->pParse, \"invalid name: \\\"%s\\\"\", pExpr->u.zToken);\n        return SQLITE_ERROR;\n      }\n    }else{\n      pExpr->op = TK_STRING;\n    }\n  }\n  return rc;\n}\n\n/*\n** An SQL user-function registered to do the work of an ATTACH statement. The\n** three arguments to the function come directly from an attach statement:\n**\n**     ATTACH DATABASE x AS y KEY z\n**\n**     SELECT sqlite_attach(x, y, z)\n**\n** If the optional \"KEY z\" syntax is omitted, an SQL NULL is passed as the\n** third argument.\n*/\nstatic void attachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  int i;\n  int rc = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zName;\n  const char *zFile;\n  char *zPath = 0;\n  char *zErr = 0;\n  unsigned int flags;\n  Db *aNew;\n  char *zErrDyn = 0;\n  sqlite3_vfs *pVfs;\n\n  UNUSED_PARAMETER(NotUsed);\n\n  zFile = (const char *)sqlite3_value_text(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[1]);\n  if( zFile==0 ) zFile = \"\";\n  if( zName==0 ) zName = \"\";\n\n  /* Check for the following errors:\n  **\n  **     * Too many attached databases,\n  **     * Transaction currently open\n  **     * Specified database name already being used.\n  */\n  if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){\n    zErrDyn = sqlite3MPrintf(db, \"too many attached databases - max %d\", \n      db->aLimit[SQLITE_LIMIT_ATTACHED]\n    );\n    goto attach_error;\n  }\n  if( !db->autoCommit ){\n    zErrDyn = sqlite3MPrintf(db, \"cannot ATTACH database within transaction\");\n    goto attach_error;\n  }\n  for(i=0; i<db->nDb; i++){\n    char *z = db->aDb[i].zName;\n    assert( z && zName );\n    if( sqlite3StrICmp(z, zName)==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"database %s is already in use\", zName);\n      goto attach_error;\n    }\n  }\n\n  /* Allocate the new entry in the db->aDb[] array and initialize the schema\n  ** hash tables.\n  */\n  if( db->aDb==db->aDbStatic ){\n    aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 );\n    if( aNew==0 ) return;\n    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);\n  }else{\n    aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );\n    if( aNew==0 ) return;\n  }\n  db->aDb = aNew;\n  aNew = &db->aDb[db->nDb];\n  memset(aNew, 0, sizeof(*aNew));\n\n  /* Open the database file. If the btree is successfully opened, use\n  ** it to obtain the database schema. At this point the schema may\n  ** or may not be initialized.\n  */\n  flags = db->openFlags;\n  rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n  assert( pVfs );\n  flags |= SQLITE_OPEN_MAIN_DB;\n  rc = sqlite3BtreeOpen(pVfs, zPath, db, &aNew->pBt, 0, flags);\n  sqlite3_free( zPath );\n  db->nDb++;\n  if( rc==SQLITE_CONSTRAINT ){\n    rc = SQLITE_ERROR;\n    zErrDyn = sqlite3MPrintf(db, \"database is already attached\");\n  }else if( rc==SQLITE_OK ){\n    Pager *pPager;\n    aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);\n    if( !aNew->pSchema ){\n      rc = SQLITE_NOMEM;\n    }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){\n      zErrDyn = sqlite3MPrintf(db, \n        \"attached databases must use the same text encoding as main database\");\n      rc = SQLITE_ERROR;\n    }\n    pPager = sqlite3BtreePager(aNew->pBt);\n    sqlite3PagerLockingMode(pPager, db->dfltLockMode);\n    sqlite3BtreeSecureDelete(aNew->pBt,\n                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );\n  }\n  aNew->safety_level = 3;\n  aNew->zName = sqlite3DbStrDup(db, zName);\n  if( rc==SQLITE_OK && aNew->zName==0 ){\n    rc = SQLITE_NOMEM;\n  }\n\n\n#ifdef SQLITE_HAS_CODEC\n  if( rc==SQLITE_OK ){\n    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    int t = sqlite3_value_type(argv[2]);\n    switch( t ){\n      case SQLITE_INTEGER:\n      case SQLITE_FLOAT:\n        zErrDyn = sqlite3DbStrDup(db, \"Invalid key value\");\n        rc = SQLITE_ERROR;\n        break;\n        \n      case SQLITE_TEXT:\n      case SQLITE_BLOB:\n        nKey = sqlite3_value_bytes(argv[2]);\n        zKey = (char *)sqlite3_value_blob(argv[2]);\n        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        break;\n\n      case SQLITE_NULL:\n        /* No key specified.  Use the key from the main database */\n        sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);\n        if( nKey>0 || sqlite3BtreeGetReserve(db->aDb[0].pBt)>0 ){\n          rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        }\n        break;\n    }\n  }\n#endif\n\n  /* If the file was opened successfully, read the schema for the new database.\n  ** If this fails, or if opening the file failed, then close the file and \n  ** remove the entry from the db->aDb[] array. i.e. put everything back the way\n  ** we found it.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3BtreeEnterAll(db);\n    rc = sqlite3Init(db, &zErrDyn);\n    sqlite3BtreeLeaveAll(db);\n  }\n  if( rc ){\n    int iDb = db->nDb - 1;\n    assert( iDb>=2 );\n    if( db->aDb[iDb].pBt ){\n      sqlite3BtreeClose(db->aDb[iDb].pBt);\n      db->aDb[iDb].pBt = 0;\n      db->aDb[iDb].pSchema = 0;\n    }\n    sqlite3ResetAllSchemasOfConnection(db);\n    db->nDb = iDb;\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      db->mallocFailed = 1;\n      sqlite3DbFree(db, zErrDyn);\n      zErrDyn = sqlite3MPrintf(db, \"out of memory\");\n    }else if( zErrDyn==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"unable to open database: %s\", zFile);\n    }\n    goto attach_error;\n  }\n  \n  return;\n\nattach_error:\n  /* Return an error if we get here */\n  if( zErrDyn ){\n    sqlite3_result_error(context, zErrDyn, -1);\n    sqlite3DbFree(db, zErrDyn);\n  }\n  if( rc ) sqlite3_result_error_code(context, rc);\n}\n\n/*\n** An SQL user-function registered to do the work of an DETACH statement. The\n** three arguments to the function come directly from a detach statement:\n**\n**     DETACH DATABASE x\n**\n**     SELECT sqlite_detach(x)\n*/\nstatic void detachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *zName = (const char *)sqlite3_value_text(argv[0]);\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int i;\n  Db *pDb = 0;\n  char zErr[128];\n\n  UNUSED_PARAMETER(NotUsed);\n\n  if( zName==0 ) zName = \"\";\n  for(i=0; i<db->nDb; i++){\n    pDb = &db->aDb[i];\n    if( pDb->pBt==0 ) continue;\n    if( sqlite3StrICmp(pDb->zName, zName)==0 ) break;\n  }\n\n  if( i>=db->nDb ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"no such database: %s\", zName);\n    goto detach_error;\n  }\n  if( i<2 ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"cannot detach database %s\", zName);\n    goto detach_error;\n  }\n  if( !db->autoCommit ){\n    sqlite3_snprintf(sizeof(zErr), zErr,\n                     \"cannot DETACH database within transaction\");\n    goto detach_error;\n  }\n  if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"database %s is locked\", zName);\n    goto detach_error;\n  }\n\n  sqlite3BtreeClose(pDb->pBt);\n  pDb->pBt = 0;\n  pDb->pSchema = 0;\n  sqlite3ResetAllSchemasOfConnection(db);\n  return;\n\ndetach_error:\n  sqlite3_result_error(context, zErr, -1);\n}\n\n/*\n** This procedure generates VDBE code for a single invocation of either the\n** sqlite_detach() or sqlite_attach() SQL user functions.\n*/\nstatic void codeAttach(\n  Parse *pParse,       /* The parser context */\n  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */\n  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */\n  Expr *pAuthArg,      /* Expression to pass to authorization callback */\n  Expr *pFilename,     /* Name of database file */\n  Expr *pDbname,       /* Name of the database to use internally */\n  Expr *pKey           /* Database key for encryption extension */\n){\n  int rc;\n  NameContext sName;\n  Vdbe *v;\n  sqlite3* db = pParse->db;\n  int regArgs;\n\n  memset(&sName, 0, sizeof(NameContext));\n  sName.pParse = pParse;\n\n  if( \n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))\n  ){\n    pParse->nErr++;\n    goto attach_end;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( pAuthArg ){\n    char *zAuthArg;\n    if( pAuthArg->op==TK_STRING ){\n      zAuthArg = pAuthArg->u.zToken;\n    }else{\n      zAuthArg = 0;\n    }\n    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);\n    if(rc!=SQLITE_OK ){\n      goto attach_end;\n    }\n  }\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n\n  v = sqlite3GetVdbe(pParse);\n  regArgs = sqlite3GetTempRange(pParse, 4);\n  sqlite3ExprCode(pParse, pFilename, regArgs);\n  sqlite3ExprCode(pParse, pDbname, regArgs+1);\n  sqlite3ExprCode(pParse, pKey, regArgs+2);\n\n  assert( v || db->mallocFailed );\n  if( v ){\n    sqlite3VdbeAddOp3(v, OP_Function, 0, regArgs+3-pFunc->nArg, regArgs+3);\n    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );\n    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));\n    sqlite3VdbeChangeP4(v, -1, (char *)pFunc, P4_FUNCDEF);\n\n    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this\n    ** statement only). For DETACH, set it to false (expire all existing\n    ** statements).\n    */\n    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));\n  }\n  \nattach_end:\n  sqlite3ExprDelete(db, pFilename);\n  sqlite3ExprDelete(db, pDbname);\n  sqlite3ExprDelete(db, pKey);\n}\n\n/*\n** Called by the parser to compile a DETACH statement.\n**\n**     DETACH pDbname\n*/\nSQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){\n  static const FuncDef detach_func = {\n    1,                /* nArg */\n    SQLITE_UTF8,      /* iPrefEnc */\n    0,                /* flags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    detachFunc,       /* xFunc */\n    0,                /* xStep */\n    0,                /* xFinalize */\n    \"sqlite_detach\",  /* zName */\n    0,                /* pHash */\n    0                 /* pDestructor */\n  };\n  codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);\n}\n\n/*\n** Called by the parser to compile an ATTACH statement.\n**\n**     ATTACH p AS pDbname KEY pKey\n*/\nSQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){\n  static const FuncDef attach_func = {\n    3,                /* nArg */\n    SQLITE_UTF8,      /* iPrefEnc */\n    0,                /* flags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    attachFunc,       /* xFunc */\n    0,                /* xStep */\n    0,                /* xFinalize */\n    \"sqlite_attach\",  /* zName */\n    0,                /* pHash */\n    0                 /* pDestructor */\n  };\n  codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);\n}\n#endif /* SQLITE_OMIT_ATTACH */\n\n/*\n** Initialize a DbFixer structure.  This routine must be called prior\n** to passing the structure to one of the sqliteFixAAAA() routines below.\n**\n** The return value indicates whether or not fixation is required.  TRUE\n** means we do need to fix the database references, FALSE means we do not.\n*/\nSQLITE_PRIVATE int sqlite3FixInit(\n  DbFixer *pFix,      /* The fixer to be initialized */\n  Parse *pParse,      /* Error messages will be written here */\n  int iDb,            /* This is the database that must be used */\n  const char *zType,  /* \"view\", \"trigger\", or \"index\" */\n  const Token *pName  /* Name of the view, trigger, or index */\n){\n  sqlite3 *db;\n\n  if( NEVER(iDb<0) || iDb==1 ) return 0;\n  db = pParse->db;\n  assert( db->nDb>iDb );\n  pFix->pParse = pParse;\n  pFix->zDb = db->aDb[iDb].zName;\n  pFix->pSchema = db->aDb[iDb].pSchema;\n  pFix->zType = zType;\n  pFix->pName = pName;\n  return 1;\n}\n\n/*\n** The following set of routines walk through the parse tree and assign\n** a specific database to all table references where the database name\n** was left unspecified in the original SQL statement.  The pFix structure\n** must have been initialized by a prior call to sqlite3FixInit().\n**\n** These routines are used to make sure that an index, trigger, or\n** view in one database does not refer to objects in a different database.\n** (Exception: indices, triggers, and views in the TEMP database are\n** allowed to refer to anything.)  If a reference is explicitly made\n** to an object in a different database, an error message is added to\n** pParse->zErrMsg and these routines return non-zero.  If everything\n** checks out, these routines return 0.\n*/\nSQLITE_PRIVATE int sqlite3FixSrcList(\n  DbFixer *pFix,       /* Context of the fixation */\n  SrcList *pList       /* The Source list to check and modify */\n){\n  int i;\n  const char *zDb;\n  struct SrcList_item *pItem;\n\n  if( NEVER(pList==0) ) return 0;\n  zDb = pFix->zDb;\n  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n    if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){\n      sqlite3ErrorMsg(pFix->pParse,\n         \"%s %T cannot reference objects in database %s\",\n         pFix->zType, pFix->pName, pItem->zDatabase);\n      return 1;\n    }\n    sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);\n    pItem->zDatabase = 0;\n    pItem->pSchema = pFix->pSchema;\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\n    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;\n    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;\n#endif\n  }\n  return 0;\n}\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE int sqlite3FixSelect(\n  DbFixer *pFix,       /* Context of the fixation */\n  Select *pSelect      /* The SELECT statement to be fixed to one database */\n){\n  while( pSelect ){\n    if( sqlite3FixExprList(pFix, pSelect->pEList) ){\n      return 1;\n    }\n    if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pHaving) ){\n      return 1;\n    }\n    pSelect = pSelect->pPrior;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExpr(\n  DbFixer *pFix,     /* Context of the fixation */\n  Expr *pExpr        /* The expression to be fixed to one database */\n){\n  while( pExpr ){\n    if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;\n    }else{\n      if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;\n    }\n    if( sqlite3FixExpr(pFix, pExpr->pRight) ){\n      return 1;\n    }\n    pExpr = pExpr->pLeft;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExprList(\n  DbFixer *pFix,     /* Context of the fixation */\n  ExprList *pList    /* The expression to be fixed to one database */\n){\n  int i;\n  struct ExprList_item *pItem;\n  if( pList==0 ) return 0;\n  for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){\n    if( sqlite3FixExpr(pFix, pItem->pExpr) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE int sqlite3FixTriggerStep(\n  DbFixer *pFix,     /* Context of the fixation */\n  TriggerStep *pStep /* The trigger step be fixed to one database */\n){\n  while( pStep ){\n    if( sqlite3FixSelect(pFix, pStep->pSelect) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pStep->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pStep->pExprList) ){\n      return 1;\n    }\n    pStep = pStep->pNext;\n  }\n  return 0;\n}\n#endif\n\n/************** End of attach.c **********************************************/\n/************** Begin file auth.c ********************************************/\n/*\n** 2003 January 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the sqlite3_set_authorizer()\n** API.  This facility is an optional feature of the library.  Embedded\n** systems that do not need this facility may omit it by recompiling\n** the library with -DSQLITE_OMIT_AUTHORIZATION=1\n*/\n\n/*\n** All of the code in this file may be omitted by defining a single\n** macro.\n*/\n#ifndef SQLITE_OMIT_AUTHORIZATION\n\n/*\n** Set or clear the access authorization function.\n**\n** The access authorization function is be called during the compilation\n** phase to verify that the user has read and/or write access permission on\n** various fields of the database.  The first argument to the auth function\n** is a copy of the 3rd argument to this routine.  The second argument\n** to the auth function is one of these constants:\n**\n**       SQLITE_CREATE_INDEX\n**       SQLITE_CREATE_TABLE\n**       SQLITE_CREATE_TEMP_INDEX\n**       SQLITE_CREATE_TEMP_TABLE\n**       SQLITE_CREATE_TEMP_TRIGGER\n**       SQLITE_CREATE_TEMP_VIEW\n**       SQLITE_CREATE_TRIGGER\n**       SQLITE_CREATE_VIEW\n**       SQLITE_DELETE\n**       SQLITE_DROP_INDEX\n**       SQLITE_DROP_TABLE\n**       SQLITE_DROP_TEMP_INDEX\n**       SQLITE_DROP_TEMP_TABLE\n**       SQLITE_DROP_TEMP_TRIGGER\n**       SQLITE_DROP_TEMP_VIEW\n**       SQLITE_DROP_TRIGGER\n**       SQLITE_DROP_VIEW\n**       SQLITE_INSERT\n**       SQLITE_PRAGMA\n**       SQLITE_READ\n**       SQLITE_SELECT\n**       SQLITE_TRANSACTION\n**       SQLITE_UPDATE\n**\n** The third and fourth arguments to the auth function are the name of\n** the table and the column that are being accessed.  The auth function\n** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If\n** SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY\n** means that the SQL statement will never-run - the sqlite3_exec() call\n** will return with an error.  SQLITE_IGNORE means that the SQL statement\n** should run but attempts to read the specified column will return NULL\n** and attempts to write the column will be ignored.\n**\n** Setting the auth function to NULL disables this hook.  The default\n** setting of the auth function is NULL.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3 *db,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pArg\n){\n  sqlite3_mutex_enter(db->mutex);\n  db->xAuth = xAuth;\n  db->pAuthArg = pArg;\n  sqlite3ExpirePreparedStatements(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into pParse->zErrMsg that explains that the\n** user-supplied authorization function returned an illegal value.\n*/\nstatic void sqliteAuthBadReturnCode(Parse *pParse){\n  sqlite3ErrorMsg(pParse, \"authorizer malfunction\");\n  pParse->rc = SQLITE_ERROR;\n}\n\n/*\n** Invoke the authorization callback for permission to read column zCol from\n** table zTab in database zDb. This function assumes that an authorization\n** callback has been registered (i.e. that sqlite3.xAuth is not NULL).\n**\n** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed\n** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE\n** is treated as SQLITE_DENY. In this case an error is left in pParse.\n*/\nSQLITE_PRIVATE int sqlite3AuthReadCol(\n  Parse *pParse,                  /* The parser context */\n  const char *zTab,               /* Table name */\n  const char *zCol,               /* Column name */\n  int iDb                         /* Index of containing database. */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  char *zDb = db->aDb[iDb].zName; /* Name of attached database */\n  int rc;                         /* Auth callback return code */\n\n  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext);\n  if( rc==SQLITE_DENY ){\n    if( db->nDb>2 || iDb!=0 ){\n      sqlite3ErrorMsg(pParse, \"access to %s.%s.%s is prohibited\",zDb,zTab,zCol);\n    }else{\n      sqlite3ErrorMsg(pParse, \"access to %s.%s is prohibited\", zTab, zCol);\n    }\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** The pExpr should be a TK_COLUMN expression.  The table referred to\n** is in pTabList or else it is the NEW or OLD table of a trigger.  \n** Check to see if it is OK to read this particular column.\n**\n** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN \n** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,\n** then generate an error.\n*/\nSQLITE_PRIVATE void sqlite3AuthRead(\n  Parse *pParse,        /* The parser context */\n  Expr *pExpr,          /* The expression to check authorization on */\n  Schema *pSchema,      /* The schema of the expression */\n  SrcList *pTabList     /* All table that pExpr might refer to */\n){\n  sqlite3 *db = pParse->db;\n  Table *pTab = 0;      /* The table being read */\n  const char *zCol;     /* Name of the column of the table */\n  int iSrc;             /* Index in pTabList->a[] of table being read */\n  int iDb;              /* The index of the database the expression refers to */\n  int iCol;             /* Index of column in table */\n\n  if( db->xAuth==0 ) return;\n  iDb = sqlite3SchemaToIndex(pParse->db, pSchema);\n  if( iDb<0 ){\n    /* An attempt to read a column out of a subquery or other\n    ** temporary table. */\n    return;\n  }\n\n  assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );\n  if( pExpr->op==TK_TRIGGER ){\n    pTab = pParse->pTriggerTab;\n  }else{\n    assert( pTabList );\n    for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){\n      if( pExpr->iTable==pTabList->a[iSrc].iCursor ){\n        pTab = pTabList->a[iSrc].pTab;\n        break;\n      }\n    }\n  }\n  iCol = pExpr->iColumn;\n  if( NEVER(pTab==0) ) return;\n\n  if( iCol>=0 ){\n    assert( iCol<pTab->nCol );\n    zCol = pTab->aCol[iCol].zName;\n  }else if( pTab->iPKey>=0 ){\n    assert( pTab->iPKey<pTab->nCol );\n    zCol = pTab->aCol[pTab->iPKey].zName;\n  }else{\n    zCol = \"ROWID\";\n  }\n  assert( iDb>=0 && iDb<db->nDb );\n  if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){\n    pExpr->op = TK_NULL;\n  }\n}\n\n/*\n** Do an authorization check using the code and arguments given.  Return\n** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY\n** is returned, then the error count and error message in pParse are\n** modified appropriately.\n*/\nSQLITE_PRIVATE int sqlite3AuthCheck(\n  Parse *pParse,\n  int code,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3\n){\n  sqlite3 *db = pParse->db;\n  int rc;\n\n  /* Don't do any authorization checks if the database is initialising\n  ** or if the parser is being invoked from within sqlite3_declare_vtab.\n  */\n  if( db->init.busy || IN_DECLARE_VTAB ){\n    return SQLITE_OK;\n  }\n\n  if( db->xAuth==0 ){\n    return SQLITE_OK;\n  }\n  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);\n  if( rc==SQLITE_DENY ){\n    sqlite3ErrorMsg(pParse, \"not authorized\");\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){\n    rc = SQLITE_DENY;\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** Push an authorization context.  After this routine is called, the\n** zArg3 argument to authorization callbacks will be zContext until\n** popped.  Or if pParse==0, this routine is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPush(\n  Parse *pParse,\n  AuthContext *pContext, \n  const char *zContext\n){\n  assert( pParse );\n  pContext->pParse = pParse;\n  pContext->zAuthContext = pParse->zAuthContext;\n  pParse->zAuthContext = zContext;\n}\n\n/*\n** Pop an authorization context that was previously pushed\n** by sqlite3AuthContextPush\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){\n  if( pContext->pParse ){\n    pContext->pParse->zAuthContext = pContext->zAuthContext;\n    pContext->pParse = 0;\n  }\n}\n\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n/************** End of auth.c ************************************************/\n/************** Begin file build.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the SQLite parser\n** when syntax rules are reduced.  The routines in this file handle the\n** following kinds of SQL syntax:\n**\n**     CREATE TABLE\n**     DROP TABLE\n**     CREATE INDEX\n**     DROP INDEX\n**     creating ID lists\n**     BEGIN TRANSACTION\n**     COMMIT\n**     ROLLBACK\n*/\n\n/*\n** This routine is called when a new SQL statement is beginning to\n** be parsed.  Initialize the pParse structure as needed.\n*/\nSQLITE_PRIVATE void sqlite3BeginParse(Parse *pParse, int explainFlag){\n  pParse->explain = (u8)explainFlag;\n  pParse->nVar = 0;\n}\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** The TableLock structure is only used by the sqlite3TableLock() and\n** codeTableLocks() functions.\n*/\nstruct TableLock {\n  int iDb;             /* The database containing the table to be locked */\n  int iTab;            /* The root page of the table to be locked */\n  u8 isWriteLock;      /* True for write lock.  False for a read lock */\n  const char *zName;   /* Name of the table */\n};\n\n/*\n** Record the fact that we want to lock a table at run-time.  \n**\n** The table to be locked has root page iTab and is found in database iDb.\n** A read or a write lock can be taken depending on isWritelock.\n**\n** This routine just records the fact that the lock is desired.  The\n** code to make the lock occur is generated by a later call to\n** codeTableLocks() which occurs during sqlite3FinishCoding().\n*/\nSQLITE_PRIVATE void sqlite3TableLock(\n  Parse *pParse,     /* Parsing context */\n  int iDb,           /* Index of the database containing the table to lock */\n  int iTab,          /* Root page number of the table to be locked */\n  u8 isWriteLock,    /* True for a write lock */\n  const char *zName  /* Name of the table to be locked */\n){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i;\n  int nBytes;\n  TableLock *p;\n  assert( iDb>=0 );\n\n  for(i=0; i<pToplevel->nTableLock; i++){\n    p = &pToplevel->aTableLock[i];\n    if( p->iDb==iDb && p->iTab==iTab ){\n      p->isWriteLock = (p->isWriteLock || isWriteLock);\n      return;\n    }\n  }\n\n  nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);\n  pToplevel->aTableLock =\n      sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);\n  if( pToplevel->aTableLock ){\n    p = &pToplevel->aTableLock[pToplevel->nTableLock++];\n    p->iDb = iDb;\n    p->iTab = iTab;\n    p->isWriteLock = isWriteLock;\n    p->zName = zName;\n  }else{\n    pToplevel->nTableLock = 0;\n    pToplevel->db->mallocFailed = 1;\n  }\n}\n\n/*\n** Code an OP_TableLock instruction for each table locked by the\n** statement (configured by calls to sqlite3TableLock()).\n*/\nstatic void codeTableLocks(Parse *pParse){\n  int i;\n  Vdbe *pVdbe; \n\n  pVdbe = sqlite3GetVdbe(pParse);\n  assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */\n\n  for(i=0; i<pParse->nTableLock; i++){\n    TableLock *p = &pParse->aTableLock[i];\n    int p1 = p->iDb;\n    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,\n                      p->zName, P4_STATIC);\n  }\n}\n#else\n  #define codeTableLocks(x)\n#endif\n\n/*\n** This routine is called after a single SQL statement has been\n** parsed and a VDBE program to execute that statement has been\n** prepared.  This routine puts the finishing touches on the\n** VDBE program and resets the pParse structure for the next\n** parse.\n**\n** Note that if an error occurred, it might be the case that\n** no VDBE code was generated.\n*/\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){\n  sqlite3 *db;\n  Vdbe *v;\n\n  assert( pParse->pToplevel==0 );\n  db = pParse->db;\n  if( db->mallocFailed ) return;\n  if( pParse->nested ) return;\n  if( pParse->nErr ) return;\n\n  /* Begin by generating some termination code at the end of the\n  ** vdbe program\n  */\n  v = sqlite3GetVdbe(pParse);\n  assert( !pParse->isMultiWrite \n       || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));\n  if( v ){\n    sqlite3VdbeAddOp0(v, OP_Halt);\n\n    /* The cookie mask contains one bit for each database file open.\n    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are\n    ** set for each database that is used.  Generate code to start a\n    ** transaction on each used database and to verify the schema cookie\n    ** on each used database.\n    */\n    if( pParse->cookieGoto>0 ){\n      yDbMask mask;\n      int iDb;\n      sqlite3VdbeJumpHere(v, pParse->cookieGoto-1);\n      for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){\n        if( (mask & pParse->cookieMask)==0 ) continue;\n        sqlite3VdbeUsesBtree(v, iDb);\n        sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask & pParse->writeMask)!=0);\n        if( db->init.busy==0 ){\n          assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n          sqlite3VdbeAddOp3(v, OP_VerifyCookie,\n                            iDb, pParse->cookieValue[iDb],\n                            db->aDb[iDb].pSchema->iGeneration);\n        }\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      {\n        int i;\n        for(i=0; i<pParse->nVtabLock; i++){\n          char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);\n          sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);\n        }\n        pParse->nVtabLock = 0;\n      }\n#endif\n\n      /* Once all the cookies have been verified and transactions opened, \n      ** obtain the required table-locks. This is a no-op unless the \n      ** shared-cache feature is enabled.\n      */\n      codeTableLocks(pParse);\n\n      /* Initialize any AUTOINCREMENT data structures required.\n      */\n      sqlite3AutoincrementBegin(pParse);\n\n      /* Finally, jump back to the beginning of the executable code. */\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, pParse->cookieGoto);\n    }\n  }\n\n\n  /* Get the VDBE program ready for execution\n  */\n  if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){\n#ifdef SQLITE_DEBUG\n    FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;\n    sqlite3VdbeTrace(v, trace);\n#endif\n    assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */\n    /* A minimum of one cursor is required if autoincrement is used\n    *  See ticket [a696379c1f08866] */\n    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;\n    sqlite3VdbeMakeReady(v, pParse);\n    pParse->rc = SQLITE_DONE;\n    pParse->colNamesSet = 0;\n  }else{\n    pParse->rc = SQLITE_ERROR;\n  }\n  pParse->nTab = 0;\n  pParse->nMem = 0;\n  pParse->nSet = 0;\n  pParse->nVar = 0;\n  pParse->cookieMask = 0;\n  pParse->cookieGoto = 0;\n}\n\n/*\n** Run the parser and code generator recursively in order to generate\n** code for the SQL statement given onto the end of the pParse context\n** currently under construction.  When the parser is run recursively\n** this way, the final OP_Halt is not appended and other initialization\n** and finalization steps are omitted because those are handling by the\n** outermost parser.\n**\n** Not everything is nestable.  This facility is designed to permit\n** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use\n** care if you decide to try to use this routine for some other purposes.\n*/\nSQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  char *zErrMsg = 0;\n  sqlite3 *db = pParse->db;\n# define SAVE_SZ  (sizeof(Parse) - offsetof(Parse,nVar))\n  char saveBuf[SAVE_SZ];\n\n  if( pParse->nErr ) return;\n  assert( pParse->nested<10 );  /* Nesting should only be of limited depth */\n  va_start(ap, zFormat);\n  zSql = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    return;   /* A malloc must have failed */\n  }\n  pParse->nested++;\n  memcpy(saveBuf, &pParse->nVar, SAVE_SZ);\n  memset(&pParse->nVar, 0, SAVE_SZ);\n  sqlite3RunParser(pParse, zSql, &zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  sqlite3DbFree(db, zSql);\n  memcpy(&pParse->nVar, saveBuf, SAVE_SZ);\n  pParse->nested--;\n}\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the table and the\n** first matching table is returned.  (No checking for duplicate table\n** names is done.)  The search order is TEMP first, then MAIN, then any\n** auxiliary databases added using the ATTACH command.\n**\n** See also sqlite3LocateTable().\n*/\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){\n  Table *p = 0;\n  int i;\n  int nName;\n  assert( zName!=0 );\n  nName = sqlite3Strlen30(zName);\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */\n    if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName, nName);\n    if( p ) break;\n  }\n  return p;\n}\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.  Also leave an\n** error message in pParse->zErrMsg.\n**\n** The difference between this routine and sqlite3FindTable() is that this\n** routine leaves an error message in pParse->zErrMsg where\n** sqlite3FindTable() does not.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTable(\n  Parse *pParse,         /* context in which to report errors */\n  int isView,            /* True if looking for a VIEW rather than a TABLE */\n  const char *zName,     /* Name of the table we are looking for */\n  const char *zDbase     /* Name of the database.  Might be NULL */\n){\n  Table *p;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return 0;\n  }\n\n  p = sqlite3FindTable(pParse->db, zName, zDbase);\n  if( p==0 ){\n    const char *zMsg = isView ? \"no such view\" : \"no such table\";\n    if( zDbase ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zMsg, zDbase, zName);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zMsg, zName);\n    }\n    pParse->checkSchema = 1;\n  }\n  return p;\n}\n\n/*\n** Locate the table identified by *p.\n**\n** This is a wrapper around sqlite3LocateTable(). The difference between\n** sqlite3LocateTable() and this function is that this function restricts\n** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be\n** non-NULL if it is part of a view or trigger program definition. See\n** sqlite3FixSrcList() for details.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(\n  Parse *pParse, \n  int isView, \n  struct SrcList_item *p\n){\n  const char *zDb;\n  assert( p->pSchema==0 || p->zDatabase==0 );\n  if( p->pSchema ){\n    int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);\n    zDb = pParse->db->aDb[iDb].zName;\n  }else{\n    zDb = p->zDatabase;\n  }\n  return sqlite3LocateTable(pParse, isView, p->zName, zDb);\n}\n\n/*\n** Locate the in-memory structure that describes \n** a particular index given the name of that index\n** and the name of the database that contains the index.\n** Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the\n** table and the first matching index is returned.  (No checking\n** for duplicate index names is done.)  The search order is\n** TEMP first, then MAIN, then any auxiliary databases added\n** using the ATTACH command.\n*/\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){\n  Index *p = 0;\n  int i;\n  int nName = sqlite3Strlen30(zName);\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    Schema *pSchema = db->aDb[j].pSchema;\n    assert( pSchema );\n    if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zName) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    p = sqlite3HashFind(&pSchema->idxHash, zName, nName);\n    if( p ) break;\n  }\n  return p;\n}\n\n/*\n** Reclaim the memory used by an index\n*/\nstatic void freeIndex(sqlite3 *db, Index *p){\n#ifndef SQLITE_OMIT_ANALYZE\n  sqlite3DeleteIndexSamples(db, p);\n#endif\n  sqlite3DbFree(db, p->zColAff);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** For the index called zIdxName which is found in the database iDb,\n** unlike that index from its Table then remove the index from\n** the index hash table and free all memory structures associated\n** with the index.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){\n  Index *pIndex;\n  int len;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &db->aDb[iDb].pSchema->idxHash;\n  len = sqlite3Strlen30(zIdxName);\n  pIndex = sqlite3HashInsert(pHash, zIdxName, len, 0);\n  if( ALWAYS(pIndex) ){\n    if( pIndex->pTable->pIndex==pIndex ){\n      pIndex->pTable->pIndex = pIndex->pNext;\n    }else{\n      Index *p;\n      /* Justification of ALWAYS();  The index must be on the list of\n      ** indices. */\n      p = pIndex->pTable->pIndex;\n      while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }\n      if( ALWAYS(p && p->pNext==pIndex) ){\n        p->pNext = pIndex->pNext;\n      }\n    }\n    freeIndex(db, pIndex);\n  }\n  db->flags |= SQLITE_InternChanges;\n}\n\n/*\n** Look through the list of open database files in db->aDb[] and if\n** any have been closed, remove them from the list.  Reallocate the\n** db->aDb[] structure to a smaller size, if possible.\n**\n** Entry 0 (the \"main\" database) and entry 1 (the \"temp\" database)\n** are never candidates for being collapsed.\n*/\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3 *db){\n  int i, j;\n  for(i=j=2; i<db->nDb; i++){\n    struct Db *pDb = &db->aDb[i];\n    if( pDb->pBt==0 ){\n      sqlite3DbFree(db, pDb->zName);\n      pDb->zName = 0;\n      continue;\n    }\n    if( j<i ){\n      db->aDb[j] = db->aDb[i];\n    }\n    j++;\n  }\n  memset(&db->aDb[j], 0, (db->nDb-j)*sizeof(db->aDb[j]));\n  db->nDb = j;\n  if( db->nDb<=2 && db->aDb!=db->aDbStatic ){\n    memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0]));\n    sqlite3DbFree(db, db->aDb);\n    db->aDb = db->aDbStatic;\n  }\n}\n\n/*\n** Reset the schema for the database at index iDb.  Also reset the\n** TEMP schema.\n*/\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){\n  Db *pDb;\n  assert( iDb<db->nDb );\n\n  /* Case 1:  Reset the single schema identified by iDb */\n  pDb = &db->aDb[iDb];\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  assert( pDb->pSchema!=0 );\n  sqlite3SchemaClear(pDb->pSchema);\n\n  /* If any database other than TEMP is reset, then also reset TEMP\n  ** since TEMP might be holding triggers that reference tables in the\n  ** other database.\n  */\n  if( iDb!=1 ){\n    pDb = &db->aDb[1];\n    assert( pDb->pSchema!=0 );\n    sqlite3SchemaClear(pDb->pSchema);\n  }\n  return;\n}\n\n/*\n** Erase all schema information from all attached databases (including\n** \"main\" and \"temp\") for a single database connection.\n*/\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){\n  int i;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pSchema ){\n      sqlite3SchemaClear(pDb->pSchema);\n    }\n  }\n  db->flags &= ~SQLITE_InternChanges;\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n  sqlite3CollapseDatabaseArray(db);\n}\n\n/*\n** This routine is called when a commit occurs.\n*/\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){\n  db->flags &= ~SQLITE_InternChanges;\n}\n\n/*\n** Delete memory allocated for the column names of a table or view (the\n** Table.aCol[] array).\n*/\nstatic void sqliteDeleteColumnNames(sqlite3 *db, Table *pTable){\n  int i;\n  Column *pCol;\n  assert( pTable!=0 );\n  if( (pCol = pTable->aCol)!=0 ){\n    for(i=0; i<pTable->nCol; i++, pCol++){\n      sqlite3DbFree(db, pCol->zName);\n      sqlite3ExprDelete(db, pCol->pDflt);\n      sqlite3DbFree(db, pCol->zDflt);\n      sqlite3DbFree(db, pCol->zType);\n      sqlite3DbFree(db, pCol->zColl);\n    }\n    sqlite3DbFree(db, pTable->aCol);\n  }\n}\n\n/*\n** Remove the memory data structures associated with the given\n** Table.  No changes are made to disk by this routine.\n**\n** This routine just deletes the data structure.  It does not unlink\n** the table data structure from the hash table.  But it does destroy\n** memory structures of the indices and foreign keys associated with \n** the table.\n**\n** The db parameter is optional.  It is needed if the Table object \n** contains lookaside memory.  (Table objects in the schema do not use\n** lookaside memory, but some ephemeral Table objects do.)  Or the\n** db parameter can be used with db->pnBytesFreed to measure the memory\n** used by the Table object.\n*/\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){\n  Index *pIndex, *pNext;\n  TESTONLY( int nLookaside; ) /* Used to verify lookaside not used for schema */\n\n  assert( !pTable || pTable->nRef>0 );\n\n  /* Do not delete the table until the reference count reaches zero. */\n  if( !pTable ) return;\n  if( ((!db || db->pnBytesFreed==0) && (--pTable->nRef)>0) ) return;\n\n  /* Record the number of outstanding lookaside allocations in schema Tables\n  ** prior to doing any free() operations.  Since schema Tables do not use\n  ** lookaside, this number should not change. */\n  TESTONLY( nLookaside = (db && (pTable->tabFlags & TF_Ephemeral)==0) ?\n                         db->lookaside.nOut : 0 );\n\n  /* Delete all indices associated with this table. */\n  for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){\n    pNext = pIndex->pNext;\n    assert( pIndex->pSchema==pTable->pSchema );\n    if( !db || db->pnBytesFreed==0 ){\n      char *zName = pIndex->zName; \n      TESTONLY ( Index *pOld = ) sqlite3HashInsert(\n         &pIndex->pSchema->idxHash, zName, sqlite3Strlen30(zName), 0\n      );\n      assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n      assert( pOld==pIndex || pOld==0 );\n    }\n    freeIndex(db, pIndex);\n  }\n\n  /* Delete any foreign keys attached to this table. */\n  sqlite3FkDelete(db, pTable);\n\n  /* Delete the Table structure itself.\n  */\n  sqliteDeleteColumnNames(db, pTable);\n  sqlite3DbFree(db, pTable->zName);\n  sqlite3DbFree(db, pTable->zColAff);\n  sqlite3SelectDelete(db, pTable->pSelect);\n#ifndef SQLITE_OMIT_CHECK\n  sqlite3ExprListDelete(db, pTable->pCheck);\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3VtabClear(db, pTable);\n#endif\n  sqlite3DbFree(db, pTable);\n\n  /* Verify that no lookaside memory was used by schema tables */\n  assert( nLookaside==0 || nLookaside==db->lookaside.nOut );\n}\n\n/*\n** Unlink the given table from the hash tables and the delete the\n** table structure with all its indices and foreign keys.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){\n  Table *p;\n  Db *pDb;\n\n  assert( db!=0 );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( zTabName );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */\n  pDb = &db->aDb[iDb];\n  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,\n                        sqlite3Strlen30(zTabName),0);\n  sqlite3DeleteTable(db, p);\n  db->flags |= SQLITE_InternChanges;\n}\n\n/*\n** Given a token, return a string that consists of the text of that\n** token.  Space to hold the returned string\n** is obtained from sqliteMalloc() and must be freed by the calling\n** function.\n**\n** Any quotation marks (ex:  \"name\", 'name', [name], or `name`) that\n** surround the body of the token are removed.\n**\n** Tokens are often just pointers into the original SQL text and so\n** are not \\000 terminated and are not persistent.  The returned string\n** is \\000 terminated and is persistent.\n*/\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){\n  char *zName;\n  if( pName ){\n    zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n);\n    sqlite3Dequote(zName);\n  }else{\n    zName = 0;\n  }\n  return zName;\n}\n\n/*\n** Open the sqlite_master table stored in database number iDb for\n** writing. The table is opened using cursor 0.\n*/\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){\n  Vdbe *v = sqlite3GetVdbe(p);\n  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb));\n  sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb);\n  sqlite3VdbeChangeP4(v, -1, (char *)5, P4_INT32);  /* 5 column table */\n  if( p->nTab==0 ){\n    p->nTab = 1;\n  }\n}\n\n/*\n** Parameter zName points to a nul-terminated buffer containing the name\n** of a database (\"main\", \"temp\" or the name of an attached db). This\n** function returns the index of the named database in db->aDb[], or\n** -1 if the named db cannot be found.\n*/\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *db, const char *zName){\n  int i = -1;         /* Database number */\n  if( zName ){\n    Db *pDb;\n    int n = sqlite3Strlen30(zName);\n    for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){\n      if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) && \n          0==sqlite3StrICmp(pDb->zName, zName) ){\n        break;\n      }\n    }\n  }\n  return i;\n}\n\n/*\n** The token *pName contains the name of a database (either \"main\" or\n** \"temp\" or the name of an attached db). This routine returns the\n** index of the named database in db->aDb[], or -1 if the named db \n** does not exist.\n*/\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3 *db, Token *pName){\n  int i;                               /* Database number */\n  char *zName;                         /* Name we are searching for */\n  zName = sqlite3NameFromToken(db, pName);\n  i = sqlite3FindDbName(db, zName);\n  sqlite3DbFree(db, zName);\n  return i;\n}\n\n/* The table or view or trigger name is passed to this routine via tokens\n** pName1 and pName2. If the table name was fully qualified, for example:\n**\n** CREATE TABLE xxx.yyy (...);\n** \n** Then pName1 is set to \"xxx\" and pName2 \"yyy\". On the other hand if\n** the table name is not fully qualified, i.e.:\n**\n** CREATE TABLE yyy(...);\n**\n** Then pName1 is set to \"yyy\" and pName2 is \"\".\n**\n** This routine sets the *ppUnqual pointer to point at the token (pName1 or\n** pName2) that stores the unqualified table name.  The index of the\n** database \"xxx\" is returned.\n*/\nSQLITE_PRIVATE int sqlite3TwoPartName(\n  Parse *pParse,      /* Parsing and code generating context */\n  Token *pName1,      /* The \"xxx\" in the name \"xxx.yyy\" or \"xxx\" */\n  Token *pName2,      /* The \"yyy\" in the name \"xxx.yyy\" */\n  Token **pUnqual     /* Write the unqualified object name here */\n){\n  int iDb;                    /* Database holding the object */\n  sqlite3 *db = pParse->db;\n\n  if( ALWAYS(pName2!=0) && pName2->n>0 ){\n    if( db->init.busy ) {\n      sqlite3ErrorMsg(pParse, \"corrupt database\");\n      pParse->nErr++;\n      return -1;\n    }\n    *pUnqual = pName2;\n    iDb = sqlite3FindDb(db, pName1);\n    if( iDb<0 ){\n      sqlite3ErrorMsg(pParse, \"unknown database %T\", pName1);\n      pParse->nErr++;\n      return -1;\n    }\n  }else{\n    assert( db->init.iDb==0 || db->init.busy );\n    iDb = db->init.iDb;\n    *pUnqual = pName1;\n  }\n  return iDb;\n}\n\n/*\n** This routine is used to check if the UTF-8 string zName is a legal\n** unqualified name for a new schema object (table, index, view or\n** trigger). All names are legal except those that begin with the string\n** \"sqlite_\" (in upper, lower or mixed case). This portion of the namespace\n** is reserved for internal use.\n*/\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){\n  if( !pParse->db->init.busy && pParse->nested==0 \n          && (pParse->db->flags & SQLITE_WriteSchema)==0\n          && 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"object name reserved for internal use: %s\", zName);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Begin constructing a new table representation in memory.  This is\n** the first of several action routines that get called in response\n** to a CREATE TABLE statement.  In particular, this routine is called\n** after seeing tokens \"CREATE\" and \"TABLE\" and the table name. The isTemp\n** flag is true if the table should be stored in the auxiliary database\n** file instead of in the main database file.  This is normally the case\n** when the \"TEMP\" or \"TEMPORARY\" keyword occurs in between\n** CREATE and TABLE.\n**\n** The new table record is initialized and put in pParse->pNewTable.\n** As more of the CREATE TABLE statement is parsed, additional action\n** routines will be called to add more information to this record.\n** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine\n** is called to complete the construction of the new table record.\n*/\nSQLITE_PRIVATE void sqlite3StartTable(\n  Parse *pParse,   /* Parser context */\n  Token *pName1,   /* First part of the name of the table or view */\n  Token *pName2,   /* Second part of the name of the table or view */\n  int isTemp,      /* True if this is a TEMP table */\n  int isView,      /* True if this is a VIEW */\n  int isVirtual,   /* True if this is a VIRTUAL table */\n  int noErr        /* Do nothing if table already exists */\n){\n  Table *pTable;\n  char *zName = 0; /* The name of the new table */\n  sqlite3 *db = pParse->db;\n  Vdbe *v;\n  int iDb;         /* Database number to create the table in */\n  Token *pName;    /* Unqualified name of the table to create */\n\n  /* The table or view name to create is passed to this routine via tokens\n  ** pName1 and pName2. If the table name was fully qualified, for example:\n  **\n  ** CREATE TABLE xxx.yyy (...);\n  ** \n  ** Then pName1 is set to \"xxx\" and pName2 \"yyy\". On the other hand if\n  ** the table name is not fully qualified, i.e.:\n  **\n  ** CREATE TABLE yyy(...);\n  **\n  ** Then pName1 is set to \"yyy\" and pName2 is \"\".\n  **\n  ** The call below sets the pName pointer to point at the token (pName1 or\n  ** pName2) that stores the unqualified table name. The variable iDb is\n  ** set to the index of the database that the table or view is to be\n  ** created in.\n  */\n  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n  if( iDb<0 ) return;\n  if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){\n    /* If creating a temp table, the name may not be qualified. Unless \n    ** the database name is \"temp\" anyway.  */\n    sqlite3ErrorMsg(pParse, \"temporary table name must be unqualified\");\n    return;\n  }\n  if( !OMIT_TEMPDB && isTemp ) iDb = 1;\n\n  pParse->sNameToken = *pName;\n  zName = sqlite3NameFromToken(db, pName);\n  if( zName==0 ) return;\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto begin_table_error;\n  }\n  if( db->init.iDb==1 ) isTemp = 1;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  assert( (isTemp & 1)==isTemp );\n  {\n    int code;\n    char *zDb = db->aDb[iDb].zName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){\n      goto begin_table_error;\n    }\n    if( isView ){\n      if( !OMIT_TEMPDB && isTemp ){\n        code = SQLITE_CREATE_TEMP_VIEW;\n      }else{\n        code = SQLITE_CREATE_VIEW;\n      }\n    }else{\n      if( !OMIT_TEMPDB && isTemp ){\n        code = SQLITE_CREATE_TEMP_TABLE;\n      }else{\n        code = SQLITE_CREATE_TABLE;\n      }\n    }\n    if( !isVirtual && sqlite3AuthCheck(pParse, code, zName, 0, zDb) ){\n      goto begin_table_error;\n    }\n  }\n#endif\n\n  /* Make sure the new table name does not collide with an existing\n  ** index or table name in the same database.  Issue an error message if\n  ** it does. The exception is if the statement being parsed was passed\n  ** to an sqlite3_declare_vtab() call. In that case only the column names\n  ** and types will be used, so there is no need to test for namespace\n  ** collisions.\n  */\n  if( !IN_DECLARE_VTAB ){\n    char *zDb = db->aDb[iDb].zName;\n    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n      goto begin_table_error;\n    }\n    pTable = sqlite3FindTable(db, zName, zDb);\n    if( pTable ){\n      if( !noErr ){\n        sqlite3ErrorMsg(pParse, \"table %T already exists\", pName);\n      }else{\n        assert( !db->init.busy );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto begin_table_error;\n    }\n    if( sqlite3FindIndex(db, zName, zDb)!=0 ){\n      sqlite3ErrorMsg(pParse, \"there is already an index named %s\", zName);\n      goto begin_table_error;\n    }\n  }\n\n  pTable = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTable==0 ){\n    db->mallocFailed = 1;\n    pParse->rc = SQLITE_NOMEM;\n    pParse->nErr++;\n    goto begin_table_error;\n  }\n  pTable->zName = zName;\n  pTable->iPKey = -1;\n  pTable->pSchema = db->aDb[iDb].pSchema;\n  pTable->nRef = 1;\n  pTable->nRowEst = 1000000;\n  assert( pParse->pNewTable==0 );\n  pParse->pNewTable = pTable;\n\n  /* If this is the magic sqlite_sequence table used by autoincrement,\n  ** then record a pointer to this table in the main database structure\n  ** so that INSERT can find the table easily.\n  */\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  if( !pParse->nested && strcmp(zName, \"sqlite_sequence\")==0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTable->pSchema->pSeqTab = pTable;\n  }\n#endif\n\n  /* Begin generating the code that will insert the table record into\n  ** the SQLITE_MASTER table.  Note in particular that we must go ahead\n  ** and allocate the record number for the table entry now.  Before any\n  ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause\n  ** indices to be created and the table record must come before the \n  ** indices.  Hence, the record number for the table must be allocated\n  ** now.\n  */\n  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){\n    int j1;\n    int fileFormat;\n    int reg1, reg2, reg3;\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( isVirtual ){\n      sqlite3VdbeAddOp0(v, OP_VBegin);\n    }\n#endif\n\n    /* If the file format and encoding in the database have not been set, \n    ** set them now.\n    */\n    reg1 = pParse->regRowid = ++pParse->nMem;\n    reg2 = pParse->regRoot = ++pParse->nMem;\n    reg3 = ++pParse->nMem;\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    j1 = sqlite3VdbeAddOp1(v, OP_If, reg3);\n    fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?\n                  1 : SQLITE_MAX_FILE_FORMAT;\n    sqlite3VdbeAddOp2(v, OP_Integer, fileFormat, reg3);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, reg3);\n    sqlite3VdbeAddOp2(v, OP_Integer, ENC(db), reg3);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, reg3);\n    sqlite3VdbeJumpHere(v, j1);\n\n    /* This just creates a place-holder record in the sqlite_master table.\n    ** The record created does not contain anything yet.  It will be replaced\n    ** by the real entry in code generated at sqlite3EndTable().\n    **\n    ** The rowid for the new entry is left in register pParse->regRowid.\n    ** The root page number of the new table is left in reg pParse->regRoot.\n    ** The rowid and root page number values are needed by the code that\n    ** sqlite3EndTable will generate.\n    */\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n    if( isView || isVirtual ){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);\n    }else\n#endif\n    {\n      sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2);\n    }\n    sqlite3OpenMasterTable(pParse, iDb);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);\n    sqlite3VdbeAddOp2(v, OP_Null, 0, reg3);\n    sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeAddOp0(v, OP_Close);\n  }\n\n  /* Normal (non-error) return. */\n  return;\n\n  /* If an error occurs, we jump here */\nbegin_table_error:\n  sqlite3DbFree(db, zName);\n  return;\n}\n\n/*\n** This macro is used to compare two strings in a case-insensitive manner.\n** It is slightly faster than calling sqlite3StrICmp() directly, but\n** produces larger code.\n**\n** WARNING: This macro is not compatible with the strcmp() family. It\n** returns true if the two strings are equal, otherwise false.\n*/\n#define STRICMP(x, y) (\\\nsqlite3UpperToLower[*(unsigned char *)(x)]==   \\\nsqlite3UpperToLower[*(unsigned char *)(y)]     \\\n&& sqlite3StrICmp((x)+1,(y)+1)==0 )\n\n/*\n** Add a new column to the table currently being constructed.\n**\n** The parser calls this routine once for each column declaration\n** in a CREATE TABLE statement.  sqlite3StartTable() gets called\n** first to get things going.  Then this routine is called for each\n** column.\n*/\nSQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName){\n  Table *p;\n  int i;\n  char *z;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  if( (p = pParse->pNewTable)==0 ) return;\n#if SQLITE_MAX_COLUMN\n  if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns on %s\", p->zName);\n    return;\n  }\n#endif\n  z = sqlite3NameFromToken(db, pName);\n  if( z==0 ) return;\n  for(i=0; i<p->nCol; i++){\n    if( STRICMP(z, p->aCol[i].zName) ){\n      sqlite3ErrorMsg(pParse, \"duplicate column name: %s\", z);\n      sqlite3DbFree(db, z);\n      return;\n    }\n  }\n  if( (p->nCol & 0x7)==0 ){\n    Column *aNew;\n    aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));\n    if( aNew==0 ){\n      sqlite3DbFree(db, z);\n      return;\n    }\n    p->aCol = aNew;\n  }\n  pCol = &p->aCol[p->nCol];\n  memset(pCol, 0, sizeof(p->aCol[0]));\n  pCol->zName = z;\n \n  /* If there is no type specified, columns have the default affinity\n  ** 'NONE'. If there is a type specified, then sqlite3AddColumnType() will\n  ** be called next to set pCol->affinity correctly.\n  */\n  pCol->affinity = SQLITE_AFF_NONE;\n  p->nCol++;\n}\n\n/*\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.  A \"NOT NULL\" constraint has\n** been seen on a column.  This routine sets the notNull flag on\n** the column currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){\n  Table *p;\n  p = pParse->pNewTable;\n  if( p==0 || NEVER(p->nCol<1) ) return;\n  p->aCol[p->nCol-1].notNull = (u8)onError;\n}\n\n/*\n** Scan the column type name zType (length nType) and return the\n** associated affinity type.\n**\n** This routine does a case-independent search of zType for the \n** substrings in the following table. If one of the substrings is\n** found, the corresponding affinity is returned. If zType contains\n** more than one of the substrings, entries toward the top of \n** the table take priority. For example, if zType is 'BLOBINT', \n** SQLITE_AFF_INTEGER is returned.\n**\n** Substring     | Affinity\n** --------------------------------\n** 'INT'         | SQLITE_AFF_INTEGER\n** 'CHAR'        | SQLITE_AFF_TEXT\n** 'CLOB'        | SQLITE_AFF_TEXT\n** 'TEXT'        | SQLITE_AFF_TEXT\n** 'BLOB'        | SQLITE_AFF_NONE\n** 'REAL'        | SQLITE_AFF_REAL\n** 'FLOA'        | SQLITE_AFF_REAL\n** 'DOUB'        | SQLITE_AFF_REAL\n**\n** If none of the substrings in the above table are found,\n** SQLITE_AFF_NUMERIC is returned.\n*/\nSQLITE_PRIVATE char sqlite3AffinityType(const char *zIn){\n  u32 h = 0;\n  char aff = SQLITE_AFF_NUMERIC;\n\n  if( zIn ) while( zIn[0] ){\n    h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];\n    zIn++;\n    if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){             /* CHAR */\n      aff = SQLITE_AFF_TEXT; \n    }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){       /* CLOB */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */\n        && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){\n      aff = SQLITE_AFF_NONE;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l')          /* REAL */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a')          /* FLOA */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b')          /* DOUB */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n#endif\n    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */\n      aff = SQLITE_AFF_INTEGER;\n      break;\n    }\n  }\n\n  return aff;\n}\n\n/*\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.  The pFirst token is the first\n** token in the sequence of tokens that describe the type of the\n** column currently under construction.   pLast is the last token\n** in the sequence.  Use this information to construct a string\n** that contains the typename of the column and store that string\n** in zType.\n*/ \nSQLITE_PRIVATE void sqlite3AddColumnType(Parse *pParse, Token *pType){\n  Table *p;\n  Column *pCol;\n\n  p = pParse->pNewTable;\n  if( p==0 || NEVER(p->nCol<1) ) return;\n  pCol = &p->aCol[p->nCol-1];\n  assert( pCol->zType==0 );\n  pCol->zType = sqlite3NameFromToken(pParse->db, pType);\n  pCol->affinity = sqlite3AffinityType(pCol->zType);\n}\n\n/*\n** The expression is the default value for the most recently added column\n** of the table currently under construction.\n**\n** Default value expressions must be constant.  Raise an exception if this\n** is not the case.\n**\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){\n  Table *p;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  p = pParse->pNewTable;\n  if( p!=0 ){\n    pCol = &(p->aCol[p->nCol-1]);\n    if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr) ){\n      sqlite3ErrorMsg(pParse, \"default value of column [%s] is not constant\",\n          pCol->zName);\n    }else{\n      /* A copy of pExpr is used instead of the original, as pExpr contains\n      ** tokens that point to volatile memory. The 'span' of the expression\n      ** is required by pragma table_info.\n      */\n      sqlite3ExprDelete(db, pCol->pDflt);\n      pCol->pDflt = sqlite3ExprDup(db, pSpan->pExpr, EXPRDUP_REDUCE);\n      sqlite3DbFree(db, pCol->zDflt);\n      pCol->zDflt = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                     (int)(pSpan->zEnd - pSpan->zStart));\n    }\n  }\n  sqlite3ExprDelete(db, pSpan->pExpr);\n}\n\n/*\n** Designate the PRIMARY KEY for the table.  pList is a list of names \n** of columns that form the primary key.  If pList is NULL, then the\n** most recently added column of the table is the primary key.\n**\n** A table can have at most one primary key.  If the table already has\n** a primary key (and this is the second primary key) then create an\n** error.\n**\n** If the PRIMARY KEY is on a single column whose datatype is INTEGER,\n** then we will try to use that column as the rowid.  Set the Table.iPKey\n** field of the table under construction to be the index of the\n** INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is\n** no INTEGER PRIMARY KEY.\n**\n** If the key is not an INTEGER PRIMARY KEY, then create a unique\n** index for the key.  No index is created for INTEGER PRIMARY KEYs.\n*/\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(\n  Parse *pParse,    /* Parsing context */\n  ExprList *pList,  /* List of field names to be indexed */\n  int onError,      /* What to do with a uniqueness conflict */\n  int autoInc,      /* True if the AUTOINCREMENT keyword is present */\n  int sortOrder     /* SQLITE_SO_ASC or SQLITE_SO_DESC */\n){\n  Table *pTab = pParse->pNewTable;\n  char *zType = 0;\n  int iCol = -1, i;\n  if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit;\n  if( pTab->tabFlags & TF_HasPrimaryKey ){\n    sqlite3ErrorMsg(pParse, \n      \"table \\\"%s\\\" has more than one primary key\", pTab->zName);\n    goto primary_key_exit;\n  }\n  pTab->tabFlags |= TF_HasPrimaryKey;\n  if( pList==0 ){\n    iCol = pTab->nCol - 1;\n    pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;\n  }else{\n    for(i=0; i<pList->nExpr; i++){\n      for(iCol=0; iCol<pTab->nCol; iCol++){\n        if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){\n          break;\n        }\n      }\n      if( iCol<pTab->nCol ){\n        pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY;\n      }\n    }\n    if( pList->nExpr>1 ) iCol = -1;\n  }\n  if( iCol>=0 && iCol<pTab->nCol ){\n    zType = pTab->aCol[iCol].zType;\n  }\n  if( zType && sqlite3StrICmp(zType, \"INTEGER\")==0\n        && sortOrder==SQLITE_SO_ASC ){\n    pTab->iPKey = iCol;\n    pTab->keyConf = (u8)onError;\n    assert( autoInc==0 || autoInc==1 );\n    pTab->tabFlags |= autoInc*TF_Autoincrement;\n  }else if( autoInc ){\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    sqlite3ErrorMsg(pParse, \"AUTOINCREMENT is only allowed on an \"\n       \"INTEGER PRIMARY KEY\");\n#endif\n  }else{\n    Index *p;\n    p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0);\n    if( p ){\n      p->autoIndex = 2;\n    }\n    pList = 0;\n  }\n\nprimary_key_exit:\n  sqlite3ExprListDelete(pParse->db, pList);\n  return;\n}\n\n/*\n** Add a new CHECK constraint to the table currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(\n  Parse *pParse,    /* Parsing context */\n  Expr *pCheckExpr  /* The check expression */\n){\n#ifndef SQLITE_OMIT_CHECK\n  Table *pTab = pParse->pNewTable;\n  if( pTab && !IN_DECLARE_VTAB ){\n    pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);\n    if( pParse->constraintName.n ){\n      sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);\n    }\n  }else\n#endif\n  {\n    sqlite3ExprDelete(pParse->db, pCheckExpr);\n  }\n}\n\n/*\n** Set the collation function of the most recently parsed table column\n** to the CollSeq given.\n*/\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){\n  Table *p;\n  int i;\n  char *zColl;              /* Dequoted name of collation sequence */\n  sqlite3 *db;\n\n  if( (p = pParse->pNewTable)==0 ) return;\n  i = p->nCol-1;\n  db = pParse->db;\n  zColl = sqlite3NameFromToken(db, pToken);\n  if( !zColl ) return;\n\n  if( sqlite3LocateCollSeq(pParse, zColl) ){\n    Index *pIdx;\n    p->aCol[i].zColl = zColl;\n  \n    /* If the column is declared as \"<name> PRIMARY KEY COLLATE <type>\",\n    ** then an index may have been created on this column before the\n    ** collation type was added. Correct this if it is the case.\n    */\n    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->nColumn==1 );\n      if( pIdx->aiColumn[0]==i ){\n        pIdx->azColl[0] = p->aCol[i].zColl;\n      }\n    }\n  }else{\n    sqlite3DbFree(db, zColl);\n  }\n}\n\n/*\n** This function returns the collation sequence for database native text\n** encoding identified by the string zName, length nName.\n**\n** If the requested collation sequence is not available, or not available\n** in the database native encoding, the collation factory is invoked to\n** request it. If the collation factory does not supply such a sequence,\n** and the sequence is available in another text encoding, then that is\n** returned instead.\n**\n** If no versions of the requested collations sequence are available, or\n** another error occurs, NULL is returned and an error message written into\n** pParse.\n**\n** This routine is a wrapper around sqlite3FindCollSeq().  This routine\n** invokes the collation factory if the named collation cannot be found\n** and generates an error message.\n**\n** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){\n  sqlite3 *db = pParse->db;\n  u8 enc = ENC(db);\n  u8 initbusy = db->init.busy;\n  CollSeq *pColl;\n\n  pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);\n  if( !initbusy && (!pColl || !pColl->xCmp) ){\n    pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);\n  }\n\n  return pColl;\n}\n\n\n/*\n** Generate code that will increment the schema cookie.\n**\n** The schema cookie is used to determine when the schema for the\n** database changes.  After each schema change, the cookie value\n** changes.  When a process first reads the schema it records the\n** cookie.  Thereafter, whenever it goes to access the database,\n** it checks the cookie to make sure the schema has not changed\n** since it was last read.\n**\n** This plan is not completely bullet-proof.  It is possible for\n** the schema to change multiple times and for the cookie to be\n** set back to prior value.  But schema changes are infrequent\n** and the probability of hitting the same cookie value is only\n** 1 chance in 2^32.  So we're safe enough.\n*/\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){\n  int r1 = sqlite3GetTempReg(pParse);\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  sqlite3VdbeAddOp2(v, OP_Integer, db->aDb[iDb].pSchema->schema_cookie+1, r1);\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, r1);\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** Measure the number of characters needed to output the given\n** identifier.  The number returned includes any quotes used\n** but does not include the null terminator.\n**\n** The estimate is conservative.  It might be larger that what is\n** really needed.\n*/\nstatic int identLength(const char *z){\n  int n;\n  for(n=0; *z; n++, z++){\n    if( *z=='\"' ){ n++; }\n  }\n  return n + 2;\n}\n\n/*\n** The first parameter is a pointer to an output buffer. The second \n** parameter is a pointer to an integer that contains the offset at\n** which to write into the output buffer. This function copies the\n** nul-terminated string pointed to by the third parameter, zSignedIdent,\n** to the specified offset in the buffer and updates *pIdx to refer\n** to the first byte after the last byte written before returning.\n** \n** If the string zSignedIdent consists entirely of alpha-numeric\n** characters, does not begin with a digit and is not an SQL keyword,\n** then it is copied to the output buffer exactly as it is. Otherwise,\n** it is quoted using double-quotes.\n*/\nstatic void identPut(char *z, int *pIdx, char *zSignedIdent){\n  unsigned char *zIdent = (unsigned char*)zSignedIdent;\n  int i, j, needQuote;\n  i = *pIdx;\n\n  for(j=0; zIdent[j]; j++){\n    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;\n  }\n  needQuote = sqlite3Isdigit(zIdent[0]) || sqlite3KeywordCode(zIdent, j)!=TK_ID;\n  if( !needQuote ){\n    needQuote = zIdent[j];\n  }\n\n  if( needQuote ) z[i++] = '\"';\n  for(j=0; zIdent[j]; j++){\n    z[i++] = zIdent[j];\n    if( zIdent[j]=='\"' ) z[i++] = '\"';\n  }\n  if( needQuote ) z[i++] = '\"';\n  z[i] = 0;\n  *pIdx = i;\n}\n\n/*\n** Generate a CREATE TABLE statement appropriate for the given\n** table.  Memory to hold the text of the statement is obtained\n** from sqliteMalloc() and must be freed by the calling function.\n*/\nstatic char *createTableStmt(sqlite3 *db, Table *p){\n  int i, k, n;\n  char *zStmt;\n  char *zSep, *zSep2, *zEnd;\n  Column *pCol;\n  n = 0;\n  for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){\n    n += identLength(pCol->zName) + 5;\n  }\n  n += identLength(p->zName);\n  if( n<50 ){ \n    zSep = \"\";\n    zSep2 = \",\";\n    zEnd = \")\";\n  }else{\n    zSep = \"\\n  \";\n    zSep2 = \",\\n  \";\n    zEnd = \"\\n)\";\n  }\n  n += 35 + 6*p->nCol;\n  zStmt = sqlite3DbMallocRaw(0, n);\n  if( zStmt==0 ){\n    db->mallocFailed = 1;\n    return 0;\n  }\n  sqlite3_snprintf(n, zStmt, \"CREATE TABLE \");\n  k = sqlite3Strlen30(zStmt);\n  identPut(zStmt, &k, p->zName);\n  zStmt[k++] = '(';\n  for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){\n    static const char * const azType[] = {\n        /* SQLITE_AFF_TEXT    */ \" TEXT\",\n        /* SQLITE_AFF_NONE    */ \"\",\n        /* SQLITE_AFF_NUMERIC */ \" NUM\",\n        /* SQLITE_AFF_INTEGER */ \" INT\",\n        /* SQLITE_AFF_REAL    */ \" REAL\"\n    };\n    int len;\n    const char *zType;\n\n    sqlite3_snprintf(n-k, &zStmt[k], zSep);\n    k += sqlite3Strlen30(&zStmt[k]);\n    zSep = zSep2;\n    identPut(zStmt, &k, pCol->zName);\n    assert( pCol->affinity-SQLITE_AFF_TEXT >= 0 );\n    assert( pCol->affinity-SQLITE_AFF_TEXT < ArraySize(azType) );\n    testcase( pCol->affinity==SQLITE_AFF_TEXT );\n    testcase( pCol->affinity==SQLITE_AFF_NONE );\n    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );\n    testcase( pCol->affinity==SQLITE_AFF_INTEGER );\n    testcase( pCol->affinity==SQLITE_AFF_REAL );\n    \n    zType = azType[pCol->affinity - SQLITE_AFF_TEXT];\n    len = sqlite3Strlen30(zType);\n    assert( pCol->affinity==SQLITE_AFF_NONE \n            || pCol->affinity==sqlite3AffinityType(zType) );\n    memcpy(&zStmt[k], zType, len);\n    k += len;\n    assert( k<=n );\n  }\n  sqlite3_snprintf(n-k, &zStmt[k], \"%s\", zEnd);\n  return zStmt;\n}\n\n/*\n** This routine is called to report the final \")\" that terminates\n** a CREATE TABLE statement.\n**\n** The table structure that other action routines have been building\n** is added to the internal hash tables, assuming no errors have\n** occurred.\n**\n** An entry for the table is made in the master table on disk, unless\n** this is a temporary table or db->init.busy==1.  When db->init.busy==1\n** it means we are reading the sqlite_master table because we just\n** connected to the database or because the sqlite_master table has\n** recently changed, so the entry for this table already exists in\n** the sqlite_master table.  We do not want to create it again.\n**\n** If the pSelect argument is not NULL, it means that this routine\n** was called to create a table generated from a \n** \"CREATE TABLE ... AS SELECT ...\" statement.  The column names of\n** the new table will match the result set of the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3EndTable(\n  Parse *pParse,          /* Parse context */\n  Token *pCons,           /* The ',' token after the last column defn. */\n  Token *pEnd,            /* The final ')' token in the CREATE TABLE */\n  Select *pSelect         /* Select from a \"CREATE ... AS SELECT\" */\n){\n  Table *p;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  if( (pEnd==0 && pSelect==0) || db->mallocFailed ){\n    return;\n  }\n  p = pParse->pNewTable;\n  if( p==0 ) return;\n\n  assert( !db->init.busy || !pSelect );\n\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n\n#ifndef SQLITE_OMIT_CHECK\n  /* Resolve names in all CHECK constraint expressions.\n  */\n  if( p->pCheck ){\n    SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */\n    NameContext sNC;                /* Name context for pParse->pNewTable */\n    ExprList *pList;                /* List of all CHECK constraints */\n    int i;                          /* Loop counter */\n\n    memset(&sNC, 0, sizeof(sNC));\n    memset(&sSrc, 0, sizeof(sSrc));\n    sSrc.nSrc = 1;\n    sSrc.a[0].zName = p->zName;\n    sSrc.a[0].pTab = p;\n    sSrc.a[0].iCursor = -1;\n    sNC.pParse = pParse;\n    sNC.pSrcList = &sSrc;\n    sNC.ncFlags = NC_IsCheck;\n    pList = p->pCheck;\n    for(i=0; i<pList->nExpr; i++){\n      if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){\n        return;\n      }\n    }\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* If the db->init.busy is 1 it means we are reading the SQL off the\n  ** \"sqlite_master\" or \"sqlite_temp_master\" table on the disk.\n  ** So do not write to the disk again.  Extract the root page number\n  ** for the table from the db->init.newTnum field.  (The page number\n  ** should have been put there by the sqliteOpenCb routine.)\n  */\n  if( db->init.busy ){\n    p->tnum = db->init.newTnum;\n  }\n\n  /* If not initializing, then create a record for the new table\n  ** in the SQLITE_MASTER table of the database.\n  **\n  ** If this is a TEMPORARY table, write the entry into the auxiliary\n  ** file instead of into the main database file.\n  */\n  if( !db->init.busy ){\n    int n;\n    Vdbe *v;\n    char *zType;    /* \"view\" or \"table\" */\n    char *zType2;   /* \"VIEW\" or \"TABLE\" */\n    char *zStmt;    /* Text of the CREATE TABLE or CREATE VIEW statement */\n\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;\n\n    sqlite3VdbeAddOp1(v, OP_Close, 0);\n\n    /* \n    ** Initialize zType for the new view or table.\n    */\n    if( p->pSelect==0 ){\n      /* A regular table */\n      zType = \"table\";\n      zType2 = \"TABLE\";\n#ifndef SQLITE_OMIT_VIEW\n    }else{\n      /* A view */\n      zType = \"view\";\n      zType2 = \"VIEW\";\n#endif\n    }\n\n    /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT\n    ** statement to populate the new table. The root-page number for the\n    ** new table is in register pParse->regRoot.\n    **\n    ** Once the SELECT has been coded by sqlite3Select(), it is in a\n    ** suitable state to query for the column names and types to be used\n    ** by the new table.\n    **\n    ** A shared-cache write-lock is not required to write to the new table,\n    ** as a schema-lock must have already been obtained to create it. Since\n    ** a schema-lock excludes all other database users, the write-lock would\n    ** be redundant.\n    */\n    if( pSelect ){\n      SelectDest dest;\n      Table *pSelTab;\n\n      assert(pParse->nTab==1);\n      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);\n      sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);\n      pParse->nTab = 2;\n      sqlite3SelectDestInit(&dest, SRT_Table, 1);\n      sqlite3Select(pParse, pSelect, &dest);\n      sqlite3VdbeAddOp1(v, OP_Close, 1);\n      if( pParse->nErr==0 ){\n        pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);\n        if( pSelTab==0 ) return;\n        assert( p->aCol==0 );\n        p->nCol = pSelTab->nCol;\n        p->aCol = pSelTab->aCol;\n        pSelTab->nCol = 0;\n        pSelTab->aCol = 0;\n        sqlite3DeleteTable(db, pSelTab);\n      }\n    }\n\n    /* Compute the complete text of the CREATE statement */\n    if( pSelect ){\n      zStmt = createTableStmt(db, p);\n    }else{\n      n = (int)(pEnd->z - pParse->sNameToken.z) + 1;\n      zStmt = sqlite3MPrintf(db, \n          \"CREATE %s %.*s\", zType2, n, pParse->sNameToken.z\n      );\n    }\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.\n    */\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zName, SCHEMA_TABLE(iDb),\n      zType,\n      p->zName,\n      p->zName,\n      pParse->regRoot,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    sqlite3ChangeCookie(pParse, iDb);\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    /* Check to see if we need to create an sqlite_sequence table for\n    ** keeping track of autoincrement keys.\n    */\n    if( p->tabFlags & TF_Autoincrement ){\n      Db *pDb = &db->aDb[iDb];\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      if( pDb->pSchema->pSeqTab==0 ){\n        sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.sqlite_sequence(name,seq)\",\n          pDb->zName\n        );\n      }\n    }\n#endif\n\n    /* Reparse everything to update our internal data structures */\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n               sqlite3MPrintf(db, \"tbl_name='%q'\", p->zName));\n  }\n\n\n  /* Add the table to the in-memory representation of the database.\n  */\n  if( db->init.busy ){\n    Table *pOld;\n    Schema *pSchema = p->pSchema;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName,\n                             sqlite3Strlen30(p->zName),p);\n    if( pOld ){\n      assert( p==pOld );  /* Malloc must have failed inside HashInsert() */\n      db->mallocFailed = 1;\n      return;\n    }\n    pParse->pNewTable = 0;\n    db->flags |= SQLITE_InternChanges;\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n    if( !p->pSelect ){\n      const char *zName = (const char *)pParse->sNameToken.z;\n      int nName;\n      assert( !pSelect && pCons && pEnd );\n      if( pCons->z==0 ){\n        pCons = pEnd;\n      }\n      nName = (int)((const char *)pCons->z - zName);\n      p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);\n    }\n#endif\n  }\n}\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** The parser calls this routine in order to create a new VIEW\n*/\nSQLITE_PRIVATE void sqlite3CreateView(\n  Parse *pParse,     /* The parsing context */\n  Token *pBegin,     /* The CREATE token that begins the statement */\n  Token *pName1,     /* The token that holds the name of the view */\n  Token *pName2,     /* The token that holds the name of the view */\n  Select *pSelect,   /* A SELECT statement that will become the new view */\n  int isTemp,        /* TRUE for a TEMPORARY view */\n  int noErr          /* Suppress error messages if VIEW already exists */\n){\n  Table *p;\n  int n;\n  const char *z;\n  Token sEnd;\n  DbFixer sFix;\n  Token *pName = 0;\n  int iDb;\n  sqlite3 *db = pParse->db;\n\n  if( pParse->nVar>0 ){\n    sqlite3ErrorMsg(pParse, \"parameters are not allowed in views\");\n    sqlite3SelectDelete(db, pSelect);\n    return;\n  }\n  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);\n  p = pParse->pNewTable;\n  if( p==0 || pParse->nErr ){\n    sqlite3SelectDelete(db, pSelect);\n    return;\n  }\n  sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n  if( sqlite3FixInit(&sFix, pParse, iDb, \"view\", pName)\n    && sqlite3FixSelect(&sFix, pSelect)\n  ){\n    sqlite3SelectDelete(db, pSelect);\n    return;\n  }\n\n  /* Make a copy of the entire SELECT statement that defines the view.\n  ** This will force all the Expr.token.z values to be dynamically\n  ** allocated rather than point to the input string - which means that\n  ** they will persist after the current sqlite3_exec() call returns.\n  */\n  p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n  sqlite3SelectDelete(db, pSelect);\n  if( db->mallocFailed ){\n    return;\n  }\n  if( !db->init.busy ){\n    sqlite3ViewGetColumnNames(pParse, p);\n  }\n\n  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to\n  ** the end.\n  */\n  sEnd = pParse->sLastToken;\n  if( ALWAYS(sEnd.z[0]!=0) && sEnd.z[0]!=';' ){\n    sEnd.z += sEnd.n;\n  }\n  sEnd.n = 0;\n  n = (int)(sEnd.z - pBegin->z);\n  z = pBegin->z;\n  while( ALWAYS(n>0) && sqlite3Isspace(z[n-1]) ){ n--; }\n  sEnd.z = &z[n-1];\n  sEnd.n = 1;\n\n  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */\n  sqlite3EndTable(pParse, 0, &sEnd, 0);\n  return;\n}\n#endif /* SQLITE_OMIT_VIEW */\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n/*\n** The Table structure pTable is really a VIEW.  Fill in the names of\n** the columns of the view in the pTable structure.  Return the number\n** of errors.  If an error is seen leave an error message in pParse->zErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){\n  Table *pSelTab;   /* A fake table from which we get the result set */\n  Select *pSel;     /* Copy of the SELECT that implements the view */\n  int nErr = 0;     /* Number of errors encountered */\n  int n;            /* Temporarily holds the number of cursors assigned */\n  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);\n\n  assert( pTable );\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3VtabCallConnect(pParse, pTable) ){\n    return SQLITE_ERROR;\n  }\n  if( IsVirtual(pTable) ) return 0;\n#endif\n\n#ifndef SQLITE_OMIT_VIEW\n  /* A positive nCol means the columns names for this view are\n  ** already known.\n  */\n  if( pTable->nCol>0 ) return 0;\n\n  /* A negative nCol is a special marker meaning that we are currently\n  ** trying to compute the column names.  If we enter this routine with\n  ** a negative nCol, it means two or more views form a loop, like this:\n  **\n  **     CREATE VIEW one AS SELECT * FROM two;\n  **     CREATE VIEW two AS SELECT * FROM one;\n  **\n  ** Actually, the error above is now caught prior to reaching this point.\n  ** But the following test is still important as it does come up\n  ** in the following:\n  ** \n  **     CREATE TABLE main.ex1(a);\n  **     CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;\n  **     SELECT * FROM temp.ex1;\n  */\n  if( pTable->nCol<0 ){\n    sqlite3ErrorMsg(pParse, \"view %s is circularly defined\", pTable->zName);\n    return 1;\n  }\n  assert( pTable->nCol>=0 );\n\n  /* If we get this far, it means we need to compute the table names.\n  ** Note that the call to sqlite3ResultSetOfSelect() will expand any\n  ** \"*\" elements in the results set of the view and will assign cursors\n  ** to the elements of the FROM clause.  But we do not want these changes\n  ** to be permanent.  So the computation is done on a copy of the SELECT\n  ** statement that defines the view.\n  */\n  assert( pTable->pSelect );\n  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);\n  if( pSel ){\n    u8 enableLookaside = db->lookaside.bEnabled;\n    n = pParse->nTab;\n    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);\n    pTable->nCol = -1;\n    db->lookaside.bEnabled = 0;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    xAuth = db->xAuth;\n    db->xAuth = 0;\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n    db->xAuth = xAuth;\n#else\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n#endif\n    db->lookaside.bEnabled = enableLookaside;\n    pParse->nTab = n;\n    if( pSelTab ){\n      assert( pTable->aCol==0 );\n      pTable->nCol = pSelTab->nCol;\n      pTable->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      sqlite3DeleteTable(db, pSelTab);\n      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );\n      pTable->pSchema->flags |= DB_UnresetViews;\n    }else{\n      pTable->nCol = 0;\n      nErr++;\n    }\n    sqlite3SelectDelete(db, pSel);\n  } else {\n    nErr++;\n  }\n#endif /* SQLITE_OMIT_VIEW */\n  return nErr;  \n}\n#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** Clear the column names from every VIEW in database idx.\n*/\nstatic void sqliteViewResetAll(sqlite3 *db, int idx){\n  HashElem *i;\n  assert( sqlite3SchemaMutexHeld(db, idx, 0) );\n  if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;\n  for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    if( pTab->pSelect ){\n      sqliteDeleteColumnNames(db, pTab);\n      pTab->aCol = 0;\n      pTab->nCol = 0;\n    }\n  }\n  DbClearProperty(db, idx, DB_UnresetViews);\n}\n#else\n# define sqliteViewResetAll(A,B)\n#endif /* SQLITE_OMIT_VIEW */\n\n/*\n** This function is called by the VDBE to adjust the internal schema\n** used by SQLite when the btree layer moves a table root page. The\n** root-page of a table or index in database iDb has changed from iFrom\n** to iTo.\n**\n** Ticket #1728:  The symbol table might still contain information\n** on tables and/or indices that are the process of being deleted.\n** If you are unlucky, one of those deleted indices or tables might\n** have the same rootpage number as the real table or index that is\n** being moved.  So we cannot stop searching after the first match \n** because the first match might be for one of the deleted indices\n** or tables and not the table/index that is actually being moved.\n** We must continue looping until all tables and indices with\n** rootpage==iFrom have been converted to have a rootpage of iTo\n** in order to be certain that we got the right one.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){\n  HashElem *pElem;\n  Hash *pHash;\n  Db *pDb;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pDb = &db->aDb[iDb];\n  pHash = &pDb->pSchema->tblHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    if( pTab->tnum==iFrom ){\n      pTab->tnum = iTo;\n    }\n  }\n  pHash = &pDb->pSchema->idxHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Index *pIdx = sqliteHashData(pElem);\n    if( pIdx->tnum==iFrom ){\n      pIdx->tnum = iTo;\n    }\n  }\n}\n#endif\n\n/*\n** Write code to erase the table with root-page iTable from database iDb.\n** Also write code to modify the sqlite_master table and internal schema\n** if a root-page of another table is moved by the btree-layer whilst\n** erasing iTable (this can happen with an auto-vacuum database).\n*/ \nstatic void destroyRootPage(Parse *pParse, int iTable, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);\n  sqlite3MayAbort(pParse);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* OP_Destroy stores an in integer r1. If this integer\n  ** is non-zero, then it is the root page number of a table moved to\n  ** location iTable. The following code modifies the sqlite_master table to\n  ** reflect this.\n  **\n  ** The \"#NNN\" in the SQL is a special constant that means whatever value\n  ** is in register NNN.  See grammar rules associated with the TK_REGISTER\n  ** token for additional information.\n  */\n  sqlite3NestedParse(pParse, \n     \"UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d\",\n     pParse->db->aDb[iDb].zName, SCHEMA_TABLE(iDb), iTable, r1, r1);\n#endif\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** Write VDBE code to erase table pTab and all associated indices on disk.\n** Code to update the sqlite_master tables and internal schema definitions\n** in case a root-page belonging to another table is moved by the btree layer\n** is also added (this can happen with an auto-vacuum database).\n*/\nstatic void destroyTable(Parse *pParse, Table *pTab){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  Index *pIdx;\n  int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  destroyRootPage(pParse, pTab->tnum, iDb);\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    destroyRootPage(pParse, pIdx->tnum, iDb);\n  }\n#else\n  /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM\n  ** is not defined), then it is important to call OP_Destroy on the\n  ** table and index root-pages in order, starting with the numerically \n  ** largest root-page number. This guarantees that none of the root-pages\n  ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the\n  ** following were coded:\n  **\n  ** OP_Destroy 4 0\n  ** ...\n  ** OP_Destroy 5 0\n  **\n  ** and root page 5 happened to be the largest root-page number in the\n  ** database, then root page 5 would be moved to page 4 by the \n  ** \"OP_Destroy 4 0\" opcode. The subsequent \"OP_Destroy 5 0\" would hit\n  ** a free-list page.\n  */\n  int iTab = pTab->tnum;\n  int iDestroyed = 0;\n\n  while( 1 ){\n    Index *pIdx;\n    int iLargest = 0;\n\n    if( iDestroyed==0 || iTab<iDestroyed ){\n      iLargest = iTab;\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int iIdx = pIdx->tnum;\n      assert( pIdx->pSchema==pTab->pSchema );\n      if( (iDestroyed==0 || (iIdx<iDestroyed)) && iIdx>iLargest ){\n        iLargest = iIdx;\n      }\n    }\n    if( iLargest==0 ){\n      return;\n    }else{\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      assert( iDb>=0 && iDb<pParse->db->nDb );\n      destroyRootPage(pParse, iLargest, iDb);\n      iDestroyed = iLargest;\n    }\n  }\n#endif\n}\n\n/*\n** Remove entries from the sqlite_statN tables (for N in (1,2,3))\n** after a DROP INDEX or DROP TABLE command.\n*/\nstatic void sqlite3ClearStatTables(\n  Parse *pParse,         /* The parsing context */\n  int iDb,               /* The database number */\n  const char *zType,     /* \"idx\" or \"tbl\" */\n  const char *zName      /* Name of index or table */\n){\n  int i;\n  const char *zDbName = pParse->db->aDb[iDb].zName;\n  for(i=1; i<=3; i++){\n    char zTab[24];\n    sqlite3_snprintf(sizeof(zTab),zTab,\"sqlite_stat%d\",i);\n    if( sqlite3FindTable(pParse->db, zTab, zDbName) ){\n      sqlite3NestedParse(pParse,\n        \"DELETE FROM %Q.%s WHERE %s=%Q\",\n        zDbName, zTab, zType, zName\n      );\n    }\n  }\n}\n\n/*\n** Generate code to drop a table.\n*/\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  Trigger *pTrigger;\n  Db *pDb = &db->aDb[iDb];\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp0(v, OP_VBegin);\n  }\n#endif\n\n  /* Drop all triggers associated with the table being dropped. Code\n  ** is generated to remove entries from sqlite_master and/or\n  ** sqlite_temp_master if required.\n  */\n  pTrigger = sqlite3TriggerList(pParse, pTab);\n  while( pTrigger ){\n    assert( pTrigger->pSchema==pTab->pSchema || \n        pTrigger->pSchema==db->aDb[1].pSchema );\n    sqlite3DropTriggerPtr(pParse, pTrigger);\n    pTrigger = pTrigger->pNext;\n  }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* Remove any entries of the sqlite_sequence table associated with\n  ** the table being dropped. This is done before the table is dropped\n  ** at the btree level, in case the sqlite_sequence table needs to\n  ** move as a result of the drop (can happen in auto-vacuum mode).\n  */\n  if( pTab->tabFlags & TF_Autoincrement ){\n    sqlite3NestedParse(pParse,\n      \"DELETE FROM %Q.sqlite_sequence WHERE name=%Q\",\n      pDb->zName, pTab->zName\n    );\n  }\n#endif\n\n  /* Drop all SQLITE_MASTER table and index entries that refer to the\n  ** table. The program name loops through the master table and deletes\n  ** every row that refers to a table of the same name as the one being\n  ** dropped. Triggers are handled separately because a trigger can be\n  ** created in the temp database that refers to a table in another\n  ** database.\n  */\n  sqlite3NestedParse(pParse, \n      \"DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'\",\n      pDb->zName, SCHEMA_TABLE(iDb), pTab->zName);\n  if( !isView && !IsVirtual(pTab) ){\n    destroyTable(pParse, pTab);\n  }\n\n  /* Remove the table entry from SQLite's internal schema and modify\n  ** the schema cookie.\n  */\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);\n  }\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n  sqlite3ChangeCookie(pParse, iDb);\n  sqliteViewResetAll(db, iDb);\n}\n\n/*\n** This routine is called to do the work of a DROP TABLE statement.\n** pName is the name of the table to be dropped.\n*/\nSQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){\n  Table *pTab;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  if( db->mallocFailed ){\n    goto exit_drop_table;\n  }\n  assert( pParse->nErr==0 );\n  assert( pName->nSrc==1 );\n  if( noErr ) db->suppressErr++;\n  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);\n  if( noErr ) db->suppressErr--;\n\n  if( pTab==0 ){\n    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    goto exit_drop_table;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n\n  /* If pTab is a virtual table, call ViewGetColumnNames() to ensure\n  ** it is initialized.\n  */\n  if( IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_drop_table;\n  }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    const char *zDb = db->aDb[iDb].zName;\n    const char *zArg2 = 0;\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){\n      goto exit_drop_table;\n    }\n    if( isView ){\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_VIEW;\n      }else{\n        code = SQLITE_DROP_VIEW;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    }else if( IsVirtual(pTab) ){\n      code = SQLITE_DROP_VTABLE;\n      zArg2 = sqlite3GetVTable(db, pTab)->pMod->zName;\n#endif\n    }else{\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_TABLE;\n      }else{\n        code = SQLITE_DROP_TABLE;\n      }\n    }\n    if( sqlite3AuthCheck(pParse, code, pTab->zName, zArg2, zDb) ){\n      goto exit_drop_table;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){\n      goto exit_drop_table;\n    }\n  }\n#endif\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n    && sqlite3StrNICmp(pTab->zName, \"sqlite_stat\", 11)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be dropped\", pTab->zName);\n    goto exit_drop_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used\n  ** on a table.\n  */\n  if( isView && pTab->pSelect==0 ){\n    sqlite3ErrorMsg(pParse, \"use DROP TABLE to delete table %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n  if( !isView && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"use DROP VIEW to delete view %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n#endif\n\n  /* Generate code to remove the table from the master table\n  ** on disk.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3ClearStatTables(pParse, iDb, \"tbl\", pTab->zName);\n    sqlite3FkDropTable(pParse, pName, pTab);\n    sqlite3CodeDropTable(pParse, pTab, iDb, isView);\n  }\n\nexit_drop_table:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** This routine is called to create a new foreign key on the table\n** currently under construction.  pFromCol determines which columns\n** in the current table point to the foreign key.  If pFromCol==0 then\n** connect the key to the last column inserted.  pTo is the name of\n** the table referred to.  pToCol is a list of tables in the other\n** pTo table that the foreign key points to.  flags contains all\n** information about the conflict resolution algorithms specified\n** in the ON DELETE, ON UPDATE and ON INSERT clauses.\n**\n** An FKey structure is created and added to the table currently\n** under construction in the pParse->pNewTable field.\n**\n** The foreign key is set for IMMEDIATE processing.  A subsequent call\n** to sqlite3DeferForeignKey() might change this to DEFERRED.\n*/\nSQLITE_PRIVATE void sqlite3CreateForeignKey(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pFromCol,  /* Columns in this table that point to other table */\n  Token *pTo,          /* Name of the other table */\n  ExprList *pToCol,    /* Columns in the other table */\n  int flags            /* Conflict resolution algorithms. */\n){\n  sqlite3 *db = pParse->db;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  FKey *pFKey = 0;\n  FKey *pNextTo;\n  Table *p = pParse->pNewTable;\n  int nByte;\n  int i;\n  int nCol;\n  char *z;\n\n  assert( pTo!=0 );\n  if( p==0 || IN_DECLARE_VTAB ) goto fk_end;\n  if( pFromCol==0 ){\n    int iCol = p->nCol-1;\n    if( NEVER(iCol<0) ) goto fk_end;\n    if( pToCol && pToCol->nExpr!=1 ){\n      sqlite3ErrorMsg(pParse, \"foreign key on %s\"\n         \" should reference only one column of table %T\",\n         p->aCol[iCol].zName, pTo);\n      goto fk_end;\n    }\n    nCol = 1;\n  }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){\n    sqlite3ErrorMsg(pParse,\n        \"number of columns in foreign key does not match the number of \"\n        \"columns in the referenced table\");\n    goto fk_end;\n  }else{\n    nCol = pFromCol->nExpr;\n  }\n  nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1;\n  if( pToCol ){\n    for(i=0; i<pToCol->nExpr; i++){\n      nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;\n    }\n  }\n  pFKey = sqlite3DbMallocZero(db, nByte );\n  if( pFKey==0 ){\n    goto fk_end;\n  }\n  pFKey->pFrom = p;\n  pFKey->pNextFrom = p->pFKey;\n  z = (char*)&pFKey->aCol[nCol];\n  pFKey->zTo = z;\n  memcpy(z, pTo->z, pTo->n);\n  z[pTo->n] = 0;\n  sqlite3Dequote(z);\n  z += pTo->n+1;\n  pFKey->nCol = nCol;\n  if( pFromCol==0 ){\n    pFKey->aCol[0].iFrom = p->nCol-1;\n  }else{\n    for(i=0; i<nCol; i++){\n      int j;\n      for(j=0; j<p->nCol; j++){\n        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){\n          pFKey->aCol[i].iFrom = j;\n          break;\n        }\n      }\n      if( j>=p->nCol ){\n        sqlite3ErrorMsg(pParse, \n          \"unknown column \\\"%s\\\" in foreign key definition\", \n          pFromCol->a[i].zName);\n        goto fk_end;\n      }\n    }\n  }\n  if( pToCol ){\n    for(i=0; i<nCol; i++){\n      int n = sqlite3Strlen30(pToCol->a[i].zName);\n      pFKey->aCol[i].zCol = z;\n      memcpy(z, pToCol->a[i].zName, n);\n      z[n] = 0;\n      z += n+1;\n    }\n  }\n  pFKey->isDeferred = 0;\n  pFKey->aAction[0] = (u8)(flags & 0xff);            /* ON DELETE action */\n  pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff);    /* ON UPDATE action */\n\n  assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n  pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, \n      pFKey->zTo, sqlite3Strlen30(pFKey->zTo), (void *)pFKey\n  );\n  if( pNextTo==pFKey ){\n    db->mallocFailed = 1;\n    goto fk_end;\n  }\n  if( pNextTo ){\n    assert( pNextTo->pPrevTo==0 );\n    pFKey->pNextTo = pNextTo;\n    pNextTo->pPrevTo = pFKey;\n  }\n\n  /* Link the foreign key to the table as the last step.\n  */\n  p->pFKey = pFKey;\n  pFKey = 0;\n\nfk_end:\n  sqlite3DbFree(db, pFKey);\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n  sqlite3ExprListDelete(db, pFromCol);\n  sqlite3ExprListDelete(db, pToCol);\n}\n\n/*\n** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED\n** clause is seen as part of a foreign key definition.  The isDeferred\n** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.\n** The behavior of the most recently created foreign key is adjusted\n** accordingly.\n*/\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  Table *pTab;\n  FKey *pFKey;\n  if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;\n  assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */\n  pFKey->isDeferred = (u8)isDeferred;\n#endif\n}\n\n/*\n** Generate code that will erase and refill index *pIdx.  This is\n** used to initialize a newly created index or to recompute the\n** content of an index in response to a REINDEX command.\n**\n** if memRootPage is not negative, it means that the index is newly\n** created.  The register specified by memRootPage contains the\n** root page number of the index.  If memRootPage is negative, then\n** the index already exists and must be cleared before being refilled and\n** the root page number of the index is taken from pIndex->tnum.\n*/\nstatic void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){\n  Table *pTab = pIndex->pTable;  /* The table that is indexed */\n  int iTab = pParse->nTab++;     /* Btree cursor used for pTab */\n  int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */\n  int iSorter;                   /* Cursor opened by OpenSorter (if in use) */\n  int addr1;                     /* Address of top of loop */\n  int addr2;                     /* Address to jump to for next iteration */\n  int tnum;                      /* Root page of index */\n  Vdbe *v;                       /* Generate code into this virtual machine */\n  KeyInfo *pKey;                 /* KeyInfo for index */\n  int regRecord;                 /* Register holding assemblied index record */\n  sqlite3 *db = pParse->db;      /* The database connection */\n  int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,\n      db->aDb[iDb].zName ) ){\n    return;\n  }\n#endif\n\n  /* Require a write-lock on the table to perform this operation */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) return;\n  if( memRootPage>=0 ){\n    tnum = memRootPage;\n  }else{\n    tnum = pIndex->tnum;\n    sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);\n  }\n  pKey = sqlite3IndexKeyinfo(pParse, pIndex);\n  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, \n                    (char *)pKey, P4_KEYINFO_HANDOFF);\n  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));\n\n  /* Open the sorter cursor if we are to use one. */\n  iSorter = pParse->nTab++;\n  sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO);\n\n  /* Open the table. Loop through all rows of the table, inserting index\n  ** records into the sorter. */\n  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0);\n  regRecord = sqlite3GetTempReg(pParse);\n\n  sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1);\n  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);\n  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1);\n  sqlite3VdbeJumpHere(v, addr1);\n  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0);\n  if( pIndex->onError!=OE_None ){\n    int j2 = sqlite3VdbeCurrentAddr(v) + 3;\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, j2);\n    addr2 = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp3(v, OP_SorterCompare, iSorter, j2, regRecord);\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE,\n        OE_Abort, \"indexed columns are not unique\", P4_STATIC\n    );\n  }else{\n    addr2 = sqlite3VdbeCurrentAddr(v);\n  }\n  sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord);\n  sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  sqlite3VdbeAddOp1(v, OP_Close, iTab);\n  sqlite3VdbeAddOp1(v, OP_Close, iIdx);\n  sqlite3VdbeAddOp1(v, OP_Close, iSorter);\n}\n\n/*\n** Create a new index for an SQL table.  pName1.pName2 is the name of the index \n** and pTblList is the name of the table that is to be indexed.  Both will \n** be NULL for a primary key or an index that is created to satisfy a\n** UNIQUE constraint.  If pTable and pIndex are NULL, use pParse->pNewTable\n** as the table to be indexed.  pParse->pNewTable is a table that is\n** currently being constructed by a CREATE TABLE statement.\n**\n** pList is a list of columns to be indexed.  pList will be NULL if this\n** is a primary key or unique-constraint on the most recent column added\n** to the table currently under construction.  \n**\n** If the index is created successfully, return a pointer to the new Index\n** structure. This is used by sqlite3AddPrimaryKey() to mark the index\n** as the tables primary key (Index.autoIndex==2).\n*/\nSQLITE_PRIVATE Index *sqlite3CreateIndex(\n  Parse *pParse,     /* All information about this parse */\n  Token *pName1,     /* First part of index name. May be NULL */\n  Token *pName2,     /* Second part of index name. May be NULL */\n  SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */\n  ExprList *pList,   /* A list of columns to be indexed */\n  int onError,       /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  Token *pStart,     /* The CREATE token that begins this statement */\n  Token *pEnd,       /* The \")\" that closes the CREATE INDEX statement */\n  int sortOrder,     /* Sort order of primary key when pList==NULL */\n  int ifNotExist     /* Omit error if index already exists */\n){\n  Index *pRet = 0;     /* Pointer to return */\n  Table *pTab = 0;     /* Table to be indexed */\n  Index *pIndex = 0;   /* The index to be created */\n  char *zName = 0;     /* Name of the index */\n  int nName;           /* Number of characters in zName */\n  int i, j;\n  Token nullId;        /* Fake token for an empty ID list */\n  DbFixer sFix;        /* For assigning database names to pTable */\n  int sortOrderMask;   /* 1 to honor DESC in index.  0 to ignore. */\n  sqlite3 *db = pParse->db;\n  Db *pDb;             /* The specific table containing the indexed database */\n  int iDb;             /* Index of the database that is being written */\n  Token *pName = 0;    /* Unqualified name of the index to create */\n  struct ExprList_item *pListItem; /* For looping over pList */\n  int nCol;\n  int nExtra = 0;\n  char *zExtra;\n\n  assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */\n  assert( pParse->nErr==0 );      /* Never called with prior errors */\n  if( db->mallocFailed || IN_DECLARE_VTAB ){\n    goto exit_create_index;\n  }\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_create_index;\n  }\n\n  /*\n  ** Find the table that is to be indexed.  Return early if not found.\n  */\n  if( pTblName!=0 ){\n\n    /* Use the two-part index name to determine the database \n    ** to search for the table. 'Fix' the table name to this db\n    ** before looking up the table.\n    */\n    assert( pName1 && pName2 );\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) goto exit_create_index;\n    assert( pName && pName->z );\n\n#ifndef SQLITE_OMIT_TEMPDB\n    /* If the index name was unqualified, check if the table\n    ** is a temp table. If so, set the database to 1. Do not do this\n    ** if initialising a database schema.\n    */\n    if( !db->init.busy ){\n      pTab = sqlite3SrcListLookup(pParse, pTblName);\n      if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){\n        iDb = 1;\n      }\n    }\n#endif\n\n    if( sqlite3FixInit(&sFix, pParse, iDb, \"index\", pName) &&\n        sqlite3FixSrcList(&sFix, pTblName)\n    ){\n      /* Because the parser constructs pTblName from a single identifier,\n      ** sqlite3FixSrcList can never fail. */\n      assert(0);\n    }\n    pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);\n    assert( db->mallocFailed==0 || pTab==0 );\n    if( pTab==0 ) goto exit_create_index;\n    assert( db->aDb[iDb].pSchema==pTab->pSchema );\n  }else{\n    assert( pName==0 );\n    assert( pStart==0 );\n    pTab = pParse->pNewTable;\n    if( !pTab ) goto exit_create_index;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  }\n  pDb = &db->aDb[iDb];\n\n  assert( pTab!=0 );\n  assert( pParse->nErr==0 );\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n       && sqlite3StrNICmp(&pTab->zName[7],\"altertab_\",9)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be indexed\", pTab->zName);\n    goto exit_create_index;\n  }\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"views may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n\n  /*\n  ** Find the name of the index.  Make sure there is not already another\n  ** index or table with the same name.  \n  **\n  ** Exception:  If we are reading the names of permanent indices from the\n  ** sqlite_master table (because some other process changed the schema) and\n  ** one of the index names collides with the name of a temporary table or\n  ** index, then we will continue to process this index.\n  **\n  ** If pName==0 it means that we are\n  ** dealing with a primary key or UNIQUE constraint.  We have to invent our\n  ** own name.\n  */\n  if( pName ){\n    zName = sqlite3NameFromToken(db, pName);\n    if( zName==0 ) goto exit_create_index;\n    assert( pName->z!=0 );\n    if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n      goto exit_create_index;\n    }\n    if( !db->init.busy ){\n      if( sqlite3FindTable(db, zName, 0)!=0 ){\n        sqlite3ErrorMsg(pParse, \"there is already a table named %s\", zName);\n        goto exit_create_index;\n      }\n    }\n    if( sqlite3FindIndex(db, zName, pDb->zName)!=0 ){\n      if( !ifNotExist ){\n        sqlite3ErrorMsg(pParse, \"index %s already exists\", zName);\n      }else{\n        assert( !db->init.busy );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto exit_create_index;\n    }\n  }else{\n    int n;\n    Index *pLoop;\n    for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}\n    zName = sqlite3MPrintf(db, \"sqlite_autoindex_%s_%d\", pTab->zName, n);\n    if( zName==0 ){\n      goto exit_create_index;\n    }\n  }\n\n  /* Check for authorization to create an index.\n  */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    const char *zDb = pDb->zName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){\n      goto exit_create_index;\n    }\n    i = SQLITE_CREATE_INDEX;\n    if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){\n      goto exit_create_index;\n    }\n  }\n#endif\n\n  /* If pList==0, it means this routine was called to make a primary\n  ** key out of the last column added to the table under construction.\n  ** So create a fake list to simulate this.\n  */\n  if( pList==0 ){\n    nullId.z = pTab->aCol[pTab->nCol-1].zName;\n    nullId.n = sqlite3Strlen30((char*)nullId.z);\n    pList = sqlite3ExprListAppend(pParse, 0, 0);\n    if( pList==0 ) goto exit_create_index;\n    sqlite3ExprListSetName(pParse, pList, &nullId, 0);\n    pList->a[0].sortOrder = (u8)sortOrder;\n  }\n\n  /* Figure out how many bytes of space are required to store explicitly\n  ** specified collation sequence names.\n  */\n  for(i=0; i<pList->nExpr; i++){\n    Expr *pExpr = pList->a[i].pExpr;\n    if( pExpr ){\n      assert( pExpr->op==TK_COLLATE );\n      nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));\n    }\n  }\n\n  /* \n  ** Allocate the index structure. \n  */\n  nName = sqlite3Strlen30(zName);\n  nCol = pList->nExpr;\n  pIndex = sqlite3DbMallocZero(db, \n      ROUND8(sizeof(Index)) +              /* Index structure  */\n      ROUND8(sizeof(tRowcnt)*(nCol+1)) +   /* Index.aiRowEst   */\n      sizeof(char *)*nCol +                /* Index.azColl     */\n      sizeof(int)*nCol +                   /* Index.aiColumn   */\n      sizeof(u8)*nCol +                    /* Index.aSortOrder */\n      nName + 1 +                          /* Index.zName      */\n      nExtra                               /* Collation sequence names */\n  );\n  if( db->mallocFailed ){\n    goto exit_create_index;\n  }\n  zExtra = (char*)pIndex;\n  pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))];\n  pIndex->azColl = (char**)\n     ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1));\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) );\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );\n  pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]);\n  pIndex->aSortOrder = (u8 *)(&pIndex->aiColumn[nCol]);\n  pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]);\n  zExtra = (char *)(&pIndex->zName[nName+1]);\n  memcpy(pIndex->zName, zName, nName+1);\n  pIndex->pTable = pTab;\n  pIndex->nColumn = pList->nExpr;\n  pIndex->onError = (u8)onError;\n  pIndex->autoIndex = (u8)(pName==0);\n  pIndex->pSchema = db->aDb[iDb].pSchema;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n\n  /* Check to see if we should honor DESC requests on index columns\n  */\n  if( pDb->pSchema->file_format>=4 ){\n    sortOrderMask = -1;   /* Honor DESC */\n  }else{\n    sortOrderMask = 0;    /* Ignore DESC */\n  }\n\n  /* Scan the names of the columns of the table to be indexed and\n  ** load the column indices into the Index structure.  Report an error\n  ** if any column is not found.\n  **\n  ** TODO:  Add a test to make sure that the same column is not named\n  ** more than once within the same index.  Only the first instance of\n  ** the column will ever be used by the optimizer.  Note that using the\n  ** same column more than once cannot be an error because that would \n  ** break backwards compatibility - it needs to be a warning.\n  */\n  for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){\n    const char *zColName = pListItem->zName;\n    Column *pTabCol;\n    int requestedSortOrder;\n    char *zColl;                   /* Collation sequence name */\n\n    for(j=0, pTabCol=pTab->aCol; j<pTab->nCol; j++, pTabCol++){\n      if( sqlite3StrICmp(zColName, pTabCol->zName)==0 ) break;\n    }\n    if( j>=pTab->nCol ){\n      sqlite3ErrorMsg(pParse, \"table %s has no column named %s\",\n        pTab->zName, zColName);\n      pParse->checkSchema = 1;\n      goto exit_create_index;\n    }\n    pIndex->aiColumn[i] = j;\n    if( pListItem->pExpr ){\n      int nColl;\n      assert( pListItem->pExpr->op==TK_COLLATE );\n      zColl = pListItem->pExpr->u.zToken;\n      nColl = sqlite3Strlen30(zColl) + 1;\n      assert( nExtra>=nColl );\n      memcpy(zExtra, zColl, nColl);\n      zColl = zExtra;\n      zExtra += nColl;\n      nExtra -= nColl;\n    }else{\n      zColl = pTab->aCol[j].zColl;\n      if( !zColl ) zColl = \"BINARY\";\n    }\n    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){\n      goto exit_create_index;\n    }\n    pIndex->azColl[i] = zColl;\n    requestedSortOrder = pListItem->sortOrder & sortOrderMask;\n    pIndex->aSortOrder[i] = (u8)requestedSortOrder;\n  }\n  sqlite3DefaultRowEst(pIndex);\n\n  if( pTab==pParse->pNewTable ){\n    /* This routine has been called to create an automatic index as a\n    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or\n    ** a PRIMARY KEY or UNIQUE clause following the column definitions.\n    ** i.e. one of:\n    **\n    ** CREATE TABLE t(x PRIMARY KEY, y);\n    ** CREATE TABLE t(x, y, UNIQUE(x, y));\n    **\n    ** Either way, check to see if the table already has such an index. If\n    ** so, don't bother creating this one. This only applies to\n    ** automatically created indices. Users can do as they wish with\n    ** explicit indices.\n    **\n    ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent\n    ** (and thus suppressing the second one) even if they have different\n    ** sort orders.\n    **\n    ** If there are different collating sequences or if the columns of\n    ** the constraint occur in different orders, then the constraints are\n    ** considered distinct and both result in separate indices.\n    */\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int k;\n      assert( pIdx->onError!=OE_None );\n      assert( pIdx->autoIndex );\n      assert( pIndex->onError!=OE_None );\n\n      if( pIdx->nColumn!=pIndex->nColumn ) continue;\n      for(k=0; k<pIdx->nColumn; k++){\n        const char *z1;\n        const char *z2;\n        if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;\n        z1 = pIdx->azColl[k];\n        z2 = pIndex->azColl[k];\n        if( z1!=z2 && sqlite3StrICmp(z1, z2) ) break;\n      }\n      if( k==pIdx->nColumn ){\n        if( pIdx->onError!=pIndex->onError ){\n          /* This constraint creates the same index as a previous\n          ** constraint specified somewhere in the CREATE TABLE statement.\n          ** However the ON CONFLICT clauses are different. If both this \n          ** constraint and the previous equivalent constraint have explicit\n          ** ON CONFLICT clauses this is an error. Otherwise, use the\n          ** explicitly specified behavior for the index.\n          */\n          if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){\n            sqlite3ErrorMsg(pParse, \n                \"conflicting ON CONFLICT clauses specified\", 0);\n          }\n          if( pIdx->onError==OE_Default ){\n            pIdx->onError = pIndex->onError;\n          }\n        }\n        goto exit_create_index;\n      }\n    }\n  }\n\n  /* Link the new Index structure to its table and to the other\n  ** in-memory database structures. \n  */\n  if( db->init.busy ){\n    Index *p;\n    assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n    p = sqlite3HashInsert(&pIndex->pSchema->idxHash, \n                          pIndex->zName, sqlite3Strlen30(pIndex->zName),\n                          pIndex);\n    if( p ){\n      assert( p==pIndex );  /* Malloc must have failed */\n      db->mallocFailed = 1;\n      goto exit_create_index;\n    }\n    db->flags |= SQLITE_InternChanges;\n    if( pTblName!=0 ){\n      pIndex->tnum = db->init.newTnum;\n    }\n  }\n\n  /* If the db->init.busy is 0 then create the index on disk.  This\n  ** involves writing the index into the master table and filling in the\n  ** index with the current table contents.\n  **\n  ** The db->init.busy is 0 when the user first enters a CREATE INDEX \n  ** command.  db->init.busy is 1 when a database is opened and \n  ** CREATE INDEX statements are read out of the master table.  In\n  ** the latter case the index already exists on disk, which is why\n  ** we don't want to recreate it.\n  **\n  ** If pTblName==0 it means this index is generated as a primary key\n  ** or UNIQUE constraint of a CREATE TABLE statement.  Since the table\n  ** has just been created, it contains no data and the index initialization\n  ** step can be skipped.\n  */\n  else{ /* if( db->init.busy==0 ) */\n    Vdbe *v;\n    char *zStmt;\n    int iMem = ++pParse->nMem;\n\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto exit_create_index;\n\n\n    /* Create the rootpage for the index\n    */\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem);\n\n    /* Gather the complete text of the CREATE INDEX statement into\n    ** the zStmt variable\n    */\n    if( pStart ){\n      assert( pEnd!=0 );\n      /* A named index with an explicit CREATE INDEX statement */\n      zStmt = sqlite3MPrintf(db, \"CREATE%s INDEX %.*s\",\n        onError==OE_None ? \"\" : \" UNIQUE\",\n        (int)(pEnd->z - pName->z) + 1,\n        pName->z);\n    }else{\n      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */\n      /* zStmt = sqlite3MPrintf(\"\"); */\n      zStmt = 0;\n    }\n\n    /* Add an entry in sqlite_master for this index\n    */\n    sqlite3NestedParse(pParse, \n        \"INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);\",\n        db->aDb[iDb].zName, SCHEMA_TABLE(iDb),\n        pIndex->zName,\n        pTab->zName,\n        iMem,\n        zStmt\n    );\n    sqlite3DbFree(db, zStmt);\n\n    /* Fill the index with data and reparse the schema. Code an OP_Expire\n    ** to invalidate all pre-compiled statements.\n    */\n    if( pTblName ){\n      sqlite3RefillIndex(pParse, pIndex, iMem);\n      sqlite3ChangeCookie(pParse, iDb);\n      sqlite3VdbeAddParseSchemaOp(v, iDb,\n         sqlite3MPrintf(db, \"name='%q' AND type='index'\", pIndex->zName));\n      sqlite3VdbeAddOp1(v, OP_Expire, 0);\n    }\n  }\n\n  /* When adding an index to the list of indices for a table, make\n  ** sure all indices labeled OE_Replace come after all those labeled\n  ** OE_Ignore.  This is necessary for the correct constraint check\n  ** processing (in sqlite3GenerateConstraintChecks()) as part of\n  ** UPDATE and INSERT statements.  \n  */\n  if( db->init.busy || pTblName==0 ){\n    if( onError!=OE_Replace || pTab->pIndex==0\n         || pTab->pIndex->onError==OE_Replace){\n      pIndex->pNext = pTab->pIndex;\n      pTab->pIndex = pIndex;\n    }else{\n      Index *pOther = pTab->pIndex;\n      while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){\n        pOther = pOther->pNext;\n      }\n      pIndex->pNext = pOther->pNext;\n      pOther->pNext = pIndex;\n    }\n    pRet = pIndex;\n    pIndex = 0;\n  }\n\n  /* Clean up before exiting */\nexit_create_index:\n  if( pIndex ){\n    sqlite3DbFree(db, pIndex->zColAff);\n    sqlite3DbFree(db, pIndex);\n  }\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SrcListDelete(db, pTblName);\n  sqlite3DbFree(db, zName);\n  return pRet;\n}\n\n/*\n** Fill the Index.aiRowEst[] array with default information - information\n** to be used when we have not run the ANALYZE command.\n**\n** aiRowEst[0] is suppose to contain the number of elements in the index.\n** Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the\n** number of rows in the table that match any particular value of the\n** first column of the index.  aiRowEst[2] is an estimate of the number\n** of rows that match any particular combiniation of the first 2 columns\n** of the index.  And so forth.  It must always be the case that\n*\n**           aiRowEst[N]<=aiRowEst[N-1]\n**           aiRowEst[N]>=1\n**\n** Apart from that, we have little to go on besides intuition as to\n** how aiRowEst[] should be initialized.  The numbers generated here\n** are based on typical values found in actual indices.\n*/\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){\n  tRowcnt *a = pIdx->aiRowEst;\n  int i;\n  tRowcnt n;\n  assert( a!=0 );\n  a[0] = pIdx->pTable->nRowEst;\n  if( a[0]<10 ) a[0] = 10;\n  n = 10;\n  for(i=1; i<=pIdx->nColumn; i++){\n    a[i] = n;\n    if( n>5 ) n--;\n  }\n  if( pIdx->onError!=OE_None ){\n    a[pIdx->nColumn] = 1;\n  }\n}\n\n/*\n** This routine will drop an existing named index.  This routine\n** implements the DROP INDEX statement.\n*/\nSQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){\n  Index *pIndex;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  assert( pParse->nErr==0 );   /* Never called with prior errors */\n  if( db->mallocFailed ){\n    goto exit_drop_index;\n  }\n  assert( pName->nSrc==1 );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_drop_index;\n  }\n  pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);\n  if( pIndex==0 ){\n    if( !ifExists ){\n      sqlite3ErrorMsg(pParse, \"no such index: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    }\n    pParse->checkSchema = 1;\n    goto exit_drop_index;\n  }\n  if( pIndex->autoIndex ){\n    sqlite3ErrorMsg(pParse, \"index associated with UNIQUE \"\n      \"or PRIMARY KEY constraint cannot be dropped\", 0);\n    goto exit_drop_index;\n  }\n  iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_INDEX;\n    Table *pTab = pIndex->pTable;\n    const char *zDb = db->aDb[iDb].zName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      goto exit_drop_index;\n    }\n    if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){\n      goto exit_drop_index;\n    }\n  }\n#endif\n\n  /* Generate code to remove the index and from the master table */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='index'\",\n       db->aDb[iDb].zName, SCHEMA_TABLE(iDb), pIndex->zName\n    );\n    sqlite3ClearStatTables(pParse, iDb, \"idx\", pIndex->zName);\n    sqlite3ChangeCookie(pParse, iDb);\n    destroyRootPage(pParse, pIndex->tnum, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);\n  }\n\nexit_drop_index:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** pArray is a pointer to an array of objects. Each object in the\n** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()\n** to extend the array so that there is space for a new object at the end.\n**\n** When this function is called, *pnEntry contains the current size of\n** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes\n** in total).\n**\n** If the realloc() is successful (i.e. if no OOM condition occurs), the\n** space allocated for the new object is zeroed, *pnEntry updated to\n** reflect the new size of the array and a pointer to the new allocation\n** returned. *pIdx is set to the index of the new array entry in this case.\n**\n** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains\n** unchanged and a copy of pArray returned.\n*/\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(\n  sqlite3 *db,      /* Connection to notify of malloc failures */\n  void *pArray,     /* Array of objects.  Might be reallocated */\n  int szEntry,      /* Size of each object in the array */\n  int *pnEntry,     /* Number of objects currently in use */\n  int *pIdx         /* Write the index of a new slot here */\n){\n  char *z;\n  int n = *pnEntry;\n  if( (n & (n-1))==0 ){\n    int sz = (n==0) ? 1 : 2*n;\n    void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry);\n    if( pNew==0 ){\n      *pIdx = -1;\n      return pArray;\n    }\n    pArray = pNew;\n  }\n  z = (char*)pArray;\n  memset(&z[n * szEntry], 0, szEntry);\n  *pIdx = n;\n  ++*pnEntry;\n  return pArray;\n}\n\n/*\n** Append a new element to the given IdList.  Create a new IdList if\n** need be.\n**\n** A new IdList is returned, or NULL if malloc() fails.\n*/\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken){\n  int i;\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(IdList) );\n    if( pList==0 ) return 0;\n  }\n  pList->a = sqlite3ArrayAllocate(\n      db,\n      pList->a,\n      sizeof(pList->a[0]),\n      &pList->nId,\n      &i\n  );\n  if( i<0 ){\n    sqlite3IdListDelete(db, pList);\n    return 0;\n  }\n  pList->a[i].zName = sqlite3NameFromToken(db, pToken);\n  return pList;\n}\n\n/*\n** Delete an IdList.\n*/\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nId; i++){\n    sqlite3DbFree(db, pList->a[i].zName);\n  }\n  sqlite3DbFree(db, pList->a);\n  sqlite3DbFree(db, pList);\n}\n\n/*\n** Return the index in pList of the identifier named zId.  Return -1\n** if not found.\n*/\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){\n  int i;\n  if( pList==0 ) return -1;\n  for(i=0; i<pList->nId; i++){\n    if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Expand the space allocated for the given SrcList object by\n** creating nExtra new slots beginning at iStart.  iStart is zero based.\n** New slots are zeroed.\n**\n** For example, suppose a SrcList initially contains two entries: A,B.\n** To append 3 new entries onto the end, do this:\n**\n**    sqlite3SrcListEnlarge(db, pSrclist, 3, 2);\n**\n** After the call above it would contain:  A, B, nil, nil, nil.\n** If the iStart argument had been 1 instead of 2, then the result\n** would have been:  A, nil, nil, nil, B.  To prepend the new slots,\n** the iStart value would be 0.  The result then would\n** be: nil, nil, nil, A, B.\n**\n** If a memory allocation fails the SrcList is unchanged.  The\n** db->mallocFailed flag will be set to true.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(\n  sqlite3 *db,       /* Database connection to notify of OOM errors */\n  SrcList *pSrc,     /* The SrcList to be enlarged */\n  int nExtra,        /* Number of new slots to add to pSrc->a[] */\n  int iStart         /* Index in pSrc->a[] of first new slot */\n){\n  int i;\n\n  /* Sanity checking on calling parameters */\n  assert( iStart>=0 );\n  assert( nExtra>=1 );\n  assert( pSrc!=0 );\n  assert( iStart<=pSrc->nSrc );\n\n  /* Allocate additional space if needed */\n  if( pSrc->nSrc+nExtra>pSrc->nAlloc ){\n    SrcList *pNew;\n    int nAlloc = pSrc->nSrc+nExtra;\n    int nGot;\n    pNew = sqlite3DbRealloc(db, pSrc,\n               sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );\n    if( pNew==0 ){\n      assert( db->mallocFailed );\n      return pSrc;\n    }\n    pSrc = pNew;\n    nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;\n    pSrc->nAlloc = (u16)nGot;\n  }\n\n  /* Move existing slots that come after the newly inserted slots\n  ** out of the way */\n  for(i=pSrc->nSrc-1; i>=iStart; i--){\n    pSrc->a[i+nExtra] = pSrc->a[i];\n  }\n  pSrc->nSrc += (i16)nExtra;\n\n  /* Zero the newly allocated slots */\n  memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);\n  for(i=iStart; i<iStart+nExtra; i++){\n    pSrc->a[i].iCursor = -1;\n  }\n\n  /* Return a pointer to the enlarged SrcList */\n  return pSrc;\n}\n\n\n/*\n** Append a new table name to the given SrcList.  Create a new SrcList if\n** need be.  A new entry is created in the SrcList even if pTable is NULL.\n**\n** A SrcList is returned, or NULL if there is an OOM error.  The returned\n** SrcList might be the same as the SrcList that was input or it might be\n** a new one.  If an OOM error does occurs, then the prior value of pList\n** that is input to this routine is automatically freed.\n**\n** If pDatabase is not null, it means that the table has an optional\n** database name prefix.  Like this:  \"database.table\".  The pDatabase\n** points to the table name and the pTable points to the database name.\n** The SrcList.a[].zName field is filled with the table name which might\n** come from pTable (if pDatabase is NULL) or from pDatabase.  \n** SrcList.a[].zDatabase is filled with the database name from pTable,\n** or with NULL if no database is specified.\n**\n** In other words, if call like this:\n**\n**         sqlite3SrcListAppend(D,A,B,0);\n**\n** Then B is a table name and the database name is unspecified.  If called\n** like this:\n**\n**         sqlite3SrcListAppend(D,A,B,C);\n**\n** Then C is the table name and B is the database name.  If C is defined\n** then so is B.  In other words, we never have a case where:\n**\n**         sqlite3SrcListAppend(D,A,0,C);\n**\n** Both pTable and pDatabase are assumed to be quoted.  They are dequoted\n** before being added to the SrcList.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(\n  sqlite3 *db,        /* Connection to notify of malloc failures */\n  SrcList *pList,     /* Append to this SrcList. NULL creates a new SrcList */\n  Token *pTable,      /* Table to append */\n  Token *pDatabase    /* Database of the table */\n){\n  struct SrcList_item *pItem;\n  assert( pDatabase==0 || pTable!=0 );  /* Cannot have C without B */\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(SrcList) );\n    if( pList==0 ) return 0;\n    pList->nAlloc = 1;\n  }\n  pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);\n  if( db->mallocFailed ){\n    sqlite3SrcListDelete(db, pList);\n    return 0;\n  }\n  pItem = &pList->a[pList->nSrc-1];\n  if( pDatabase && pDatabase->z==0 ){\n    pDatabase = 0;\n  }\n  if( pDatabase ){\n    Token *pTemp = pDatabase;\n    pDatabase = pTable;\n    pTable = pTemp;\n  }\n  pItem->zName = sqlite3NameFromToken(db, pTable);\n  pItem->zDatabase = sqlite3NameFromToken(db, pDatabase);\n  return pList;\n}\n\n/*\n** Assign VdbeCursor index numbers to all tables in a SrcList\n*/\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  assert(pList || pParse->db->mallocFailed );\n  if( pList ){\n    for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n      if( pItem->iCursor>=0 ) break;\n      pItem->iCursor = pParse->nTab++;\n      if( pItem->pSelect ){\n        sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);\n      }\n    }\n  }\n}\n\n/*\n** Delete an entire SrcList including all its substructure.\n*/\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  if( pList==0 ) return;\n  for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){\n    sqlite3DbFree(db, pItem->zDatabase);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zAlias);\n    sqlite3DbFree(db, pItem->zIndex);\n    sqlite3DeleteTable(db, pItem->pTab);\n    sqlite3SelectDelete(db, pItem->pSelect);\n    sqlite3ExprDelete(db, pItem->pOn);\n    sqlite3IdListDelete(db, pItem->pUsing);\n  }\n  sqlite3DbFree(db, pList);\n}\n\n/*\n** This routine is called by the parser to add a new term to the\n** end of a growing FROM clause.  The \"p\" parameter is the part of\n** the FROM clause that has already been constructed.  \"p\" is NULL\n** if this is the first term of the FROM clause.  pTable and pDatabase\n** are the name of the table and database named in the FROM clause term.\n** pDatabase is NULL if the database name qualifier is missing - the\n** usual case.  If the term has a alias, then pAlias points to the\n** alias token.  If the term is a subquery, then pSubquery is the\n** SELECT statement that the subquery encodes.  The pTable and\n** pDatabase parameters are NULL for subqueries.  The pOn and pUsing\n** parameters are the content of the ON and USING clauses.\n**\n** Return a new SrcList which encodes is the FROM with the new\n** term added.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(\n  Parse *pParse,          /* Parsing context */\n  SrcList *p,             /* The left part of the FROM clause already seen */\n  Token *pTable,          /* Name of the table to add to the FROM clause */\n  Token *pDatabase,       /* Name of the database containing pTable */\n  Token *pAlias,          /* The right-hand side of the AS subexpression */\n  Select *pSubquery,      /* A subquery used in place of a table name */\n  Expr *pOn,              /* The ON clause of a join */\n  IdList *pUsing          /* The USING clause of a join */\n){\n  struct SrcList_item *pItem;\n  sqlite3 *db = pParse->db;\n  if( !p && (pOn || pUsing) ){\n    sqlite3ErrorMsg(pParse, \"a JOIN clause is required before %s\", \n      (pOn ? \"ON\" : \"USING\")\n    );\n    goto append_from_error;\n  }\n  p = sqlite3SrcListAppend(db, p, pTable, pDatabase);\n  if( p==0 || NEVER(p->nSrc==0) ){\n    goto append_from_error;\n  }\n  pItem = &p->a[p->nSrc-1];\n  assert( pAlias!=0 );\n  if( pAlias->n ){\n    pItem->zAlias = sqlite3NameFromToken(db, pAlias);\n  }\n  pItem->pSelect = pSubquery;\n  pItem->pOn = pOn;\n  pItem->pUsing = pUsing;\n  return p;\n\n append_from_error:\n  assert( p==0 );\n  sqlite3ExprDelete(db, pOn);\n  sqlite3IdListDelete(db, pUsing);\n  sqlite3SelectDelete(db, pSubquery);\n  return 0;\n}\n\n/*\n** Add an INDEXED BY or NOT INDEXED clause to the most recently added \n** element of the source-list passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){\n  assert( pIndexedBy!=0 );\n  if( p && ALWAYS(p->nSrc>0) ){\n    struct SrcList_item *pItem = &p->a[p->nSrc-1];\n    assert( pItem->notIndexed==0 && pItem->zIndex==0 );\n    if( pIndexedBy->n==1 && !pIndexedBy->z ){\n      /* A \"NOT INDEXED\" clause was supplied. See parse.y \n      ** construct \"indexed_opt\" for details. */\n      pItem->notIndexed = 1;\n    }else{\n      pItem->zIndex = sqlite3NameFromToken(pParse->db, pIndexedBy);\n    }\n  }\n}\n\n/*\n** When building up a FROM clause in the parser, the join operator\n** is initially attached to the left operand.  But the code generator\n** expects the join operator to be on the right operand.  This routine\n** Shifts all join operators from left to right for an entire FROM\n** clause.\n**\n** Example: Suppose the join is like this:\n**\n**           A natural cross join B\n**\n** The operator is \"natural cross join\".  The A and B operands are stored\n** in p->a[0] and p->a[1], respectively.  The parser initially stores the\n** operator with A.  This routine shifts that operator over to B.\n*/\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){\n  if( p ){\n    int i;\n    assert( p->a || p->nSrc==0 );\n    for(i=p->nSrc-1; i>0; i--){\n      p->a[i].jointype = p->a[i-1].jointype;\n    }\n    p->a[0].jointype = 0;\n  }\n}\n\n/*\n** Begin a transaction\n*/\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse *pParse, int type){\n  sqlite3 *db;\n  Vdbe *v;\n  int i;\n\n  assert( pParse!=0 );\n  db = pParse->db;\n  assert( db!=0 );\n/*  if( db->aDb[0].pBt==0 ) return; */\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"BEGIN\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) return;\n  if( type!=TK_DEFERRED ){\n    for(i=0; i<db->nDb; i++){\n      sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);\n      sqlite3VdbeUsesBtree(v, i);\n    }\n  }\n  sqlite3VdbeAddOp2(v, OP_AutoCommit, 0, 0);\n}\n\n/*\n** Commit a transaction\n*/\nSQLITE_PRIVATE void sqlite3CommitTransaction(Parse *pParse){\n  Vdbe *v;\n\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"COMMIT\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 0);\n  }\n}\n\n/*\n** Rollback a transaction\n*/\nSQLITE_PRIVATE void sqlite3RollbackTransaction(Parse *pParse){\n  Vdbe *v;\n\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"ROLLBACK\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 1);\n  }\n}\n\n/*\n** This function is called by the parser when it parses a command to create,\n** release or rollback an SQL savepoint. \n*/\nSQLITE_PRIVATE void sqlite3Savepoint(Parse *pParse, int op, Token *pName){\n  char *zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName ){\n    Vdbe *v = sqlite3GetVdbe(pParse);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    static const char * const az[] = { \"BEGIN\", \"RELEASE\", \"ROLLBACK\" };\n    assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );\n#endif\n    if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){\n      sqlite3DbFree(pParse->db, zName);\n      return;\n    }\n    sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);\n  }\n}\n\n/*\n** Make sure the TEMP database is open and available for use.  Return\n** the number of errors.  Leave any error messages in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt==0 && !pParse->explain ){\n    int rc;\n    Btree *pBt;\n    static const int flags = \n          SQLITE_OPEN_READWRITE |\n          SQLITE_OPEN_CREATE |\n          SQLITE_OPEN_EXCLUSIVE |\n          SQLITE_OPEN_DELETEONCLOSE |\n          SQLITE_OPEN_TEMP_DB;\n\n    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"unable to open a temporary database \"\n        \"file for storing temporary tables\");\n      pParse->rc = rc;\n      return 1;\n    }\n    db->aDb[1].pBt = pBt;\n    assert( db->aDb[1].pSchema );\n    if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){\n      db->mallocFailed = 1;\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Generate VDBE code that will verify the schema cookie and start\n** a read-transaction for all named database files.\n**\n** It is important that all schema cookies be verified and all\n** read transactions be started before anything else happens in\n** the VDBE program.  But this routine can be called after much other\n** code has been generated.  So here is what we do:\n**\n** The first time this routine is called, we code an OP_Goto that\n** will jump to a subroutine at the end of the program.  Then we\n** record every database that needs its schema verified in the\n** pParse->cookieMask field.  Later, after all other code has been\n** generated, the subroutine that does the cookie verifications and\n** starts the transactions will be coded and the OP_Goto P2 value\n** will be made to point to that subroutine.  The generation of the\n** cookie verification subroutine code happens in sqlite3FinishCoding().\n**\n** If iDb<0 then code the OP_Goto only - don't set flag to verify the\n** schema on any databases.  This can be used to position the OP_Goto\n** early in the code, before we know if any database tables will be used.\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n\n#ifndef SQLITE_OMIT_TRIGGER\n  if( pToplevel!=pParse ){\n    /* This branch is taken if a trigger is currently being coded. In this\n    ** case, set cookieGoto to a non-zero value to show that this function\n    ** has been called. This is used by the sqlite3ExprCodeConstants()\n    ** function. */\n    pParse->cookieGoto = -1;\n  }\n#endif\n  if( pToplevel->cookieGoto==0 ){\n    Vdbe *v = sqlite3GetVdbe(pToplevel);\n    if( v==0 ) return;  /* This only happens if there was a prior error */\n    pToplevel->cookieGoto = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0)+1;\n  }\n  if( iDb>=0 ){\n    sqlite3 *db = pToplevel->db;\n    yDbMask mask;\n\n    assert( iDb<db->nDb );\n    assert( db->aDb[iDb].pBt!=0 || iDb==1 );\n    assert( iDb<SQLITE_MAX_ATTACHED+2 );\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    mask = ((yDbMask)1)<<iDb;\n    if( (pToplevel->cookieMask & mask)==0 ){\n      pToplevel->cookieMask |= mask;\n      pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie;\n      if( !OMIT_TEMPDB && iDb==1 ){\n        sqlite3OpenTempDatabase(pToplevel);\n      }\n    }\n  }\n}\n\n/*\n** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each \n** attached database. Otherwise, invoke it for the database named zDb only.\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){\n  sqlite3 *db = pParse->db;\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zName)) ){\n      sqlite3CodeVerifySchema(pParse, i);\n    }\n  }\n}\n\n/*\n** Generate VDBE code that prepares for doing an operation that\n** might change the database.\n**\n** This routine starts a new transaction if we are not already within\n** a transaction.  If we are already within a transaction, then a checkpoint\n** is set if the setStatement parameter is true.  A checkpoint should\n** be set for operations that might fail (due to a constraint) part of\n** the way through and which will need to undo some writes without having to\n** rollback the whole transaction.  For operations where all constraints\n** can be checked before any changes are made to the database, it is never\n** necessary to undo a write and the checkpoint should not be set.\n*/\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  sqlite3CodeVerifySchema(pParse, iDb);\n  pToplevel->writeMask |= ((yDbMask)1)<<iDb;\n  pToplevel->isMultiWrite |= setStatement;\n}\n\n/*\n** Indicate that the statement currently under construction might write\n** more than one entry (example: deleting one row then inserting another,\n** inserting multiple rows in a table, or inserting a row and index entries.)\n** If an abort occurs after some of these writes have completed, then it will\n** be necessary to undo the completed writes.\n*/\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->isMultiWrite = 1;\n}\n\n/* \n** The code generator calls this routine if is discovers that it is\n** possible to abort a statement prior to completion.  In order to \n** perform this abort without corrupting the database, we need to make\n** sure that the statement is protected by a statement transaction.\n**\n** Technically, we only need to set the mayAbort flag if the\n** isMultiWrite flag was previously set.  There is a time dependency\n** such that the abort must occur after the multiwrite.  This makes\n** some statements involving the REPLACE conflict resolution algorithm\n** go a little faster.  But taking advantage of this time dependency\n** makes it more difficult to prove that the code is correct (in \n** particular, it prevents us from writing an effective\n** implementation of sqlite3AssertMayAbort()) and so we have chosen\n** to take the safe route and skip the optimization.\n*/\nSQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->mayAbort = 1;\n}\n\n/*\n** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT\n** error. The onError parameter determines which (if any) of the statement\n** and/or current transaction is rolled back.\n*/\nSQLITE_PRIVATE void sqlite3HaltConstraint(\n  Parse *pParse,    /* Parsing context */\n  int errCode,      /* extended error code */\n  int onError,      /* Constraint type */\n  char *p4,         /* Error message */\n  int p4type        /* P4_STATIC or P4_TRANSIENT */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  assert( (errCode&0xff)==SQLITE_CONSTRAINT );\n  if( onError==OE_Abort ){\n    sqlite3MayAbort(pParse);\n  }\n  sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);\n}\n\n/*\n** Check to see if pIndex uses the collating sequence pColl.  Return\n** true if it does and false if it does not.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic int collationMatch(const char *zColl, Index *pIndex){\n  int i;\n  assert( zColl!=0 );\n  for(i=0; i<pIndex->nColumn; i++){\n    const char *z = pIndex->azColl[i];\n    assert( z!=0 );\n    if( 0==sqlite3StrICmp(z, zColl) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n/*\n** Recompute all indices of pTab that use the collating sequence pColl.\n** If pColl==0 then recompute all indices of pTab.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexTable(Parse *pParse, Table *pTab, char const *zColl){\n  Index *pIndex;              /* An index associated with pTab */\n\n  for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n    if( zColl==0 || collationMatch(zColl, pIndex) ){\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3RefillIndex(pParse, pIndex, -1);\n    }\n  }\n}\n#endif\n\n/*\n** Recompute all indices of all tables in all databases where the\n** indices use the collating sequence pColl.  If pColl==0 then recompute\n** all indices everywhere.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexDatabases(Parse *pParse, char const *zColl){\n  Db *pDb;                    /* A single database */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  HashElem *k;                /* For looping over tables in pDb */\n  Table *pTab;                /* A table in the database */\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );  /* Needed for schema access */\n  for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){\n    assert( pDb!=0 );\n    for(k=sqliteHashFirst(&pDb->pSchema->tblHash);  k; k=sqliteHashNext(k)){\n      pTab = (Table*)sqliteHashData(k);\n      reindexTable(pParse, pTab, zColl);\n    }\n  }\n}\n#endif\n\n/*\n** Generate code for the REINDEX command.\n**\n**        REINDEX                            -- 1\n**        REINDEX  <collation>               -- 2\n**        REINDEX  ?<database>.?<tablename>  -- 3\n**        REINDEX  ?<database>.?<indexname>  -- 4\n**\n** Form 1 causes all indices in all attached databases to be rebuilt.\n** Form 2 rebuilds all indices in all databases that use the named\n** collating function.  Forms 3 and 4 rebuild the named index or all\n** indices associated with the named table.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nSQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){\n  CollSeq *pColl;             /* Collating sequence to be reindexed, or NULL */\n  char *z;                    /* Name of a table or index */\n  const char *zDb;            /* Name of the database */\n  Table *pTab;                /* A table in the database */\n  Index *pIndex;              /* An index associated with pTab */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  Token *pObjName;            /* Name of the table or index to be reindexed */\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  if( pName1==0 ){\n    reindexDatabases(pParse, 0);\n    return;\n  }else if( NEVER(pName2==0) || pName2->z==0 ){\n    char *zColl;\n    assert( pName1->z );\n    zColl = sqlite3NameFromToken(pParse->db, pName1);\n    if( !zColl ) return;\n    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n    if( pColl ){\n      reindexDatabases(pParse, zColl);\n      sqlite3DbFree(db, zColl);\n      return;\n    }\n    sqlite3DbFree(db, zColl);\n  }\n  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);\n  if( iDb<0 ) return;\n  z = sqlite3NameFromToken(db, pObjName);\n  if( z==0 ) return;\n  zDb = db->aDb[iDb].zName;\n  pTab = sqlite3FindTable(db, z, zDb);\n  if( pTab ){\n    reindexTable(pParse, pTab, 0);\n    sqlite3DbFree(db, z);\n    return;\n  }\n  pIndex = sqlite3FindIndex(db, z, zDb);\n  sqlite3DbFree(db, z);\n  if( pIndex ){\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3RefillIndex(pParse, pIndex, -1);\n    return;\n  }\n  sqlite3ErrorMsg(pParse, \"unable to identify the object to be reindexed\");\n}\n#endif\n\n/*\n** Return a dynamicly allocated KeyInfo structure that can be used\n** with OP_OpenRead or OP_OpenWrite to access database index pIdx.\n**\n** If successful, a pointer to the new structure is returned. In this case\n** the caller is responsible for calling sqlite3DbFree(db, ) on the returned \n** pointer. If an error occurs (out of memory or missing collation \n** sequence), NULL is returned and the state of pParse updated to reflect\n** the error.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){\n  int i;\n  int nCol = pIdx->nColumn;\n  int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol;\n  sqlite3 *db = pParse->db;\n  KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes);\n\n  if( pKey ){\n    pKey->db = pParse->db;\n    pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]);\n    assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) );\n    for(i=0; i<nCol; i++){\n      char *zColl = pIdx->azColl[i];\n      assert( zColl );\n      pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl);\n      pKey->aSortOrder[i] = pIdx->aSortOrder[i];\n    }\n    pKey->nField = (u16)nCol;\n  }\n\n  if( pParse->nErr ){\n    sqlite3DbFree(db, pKey);\n    pKey = 0;\n  }\n  return pKey;\n}\n\n/************** End of build.c ***********************************************/\n/************** Begin file callback.c ****************************************/\n/*\n** 2005 May 23 \n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains functions used to access the internal hash tables\n** of user defined functions and collation sequences.\n*/\n\n\n/*\n** Invoke the 'collation needed' callback to request a collation sequence\n** in the encoding enc of name zName, length nName.\n*/\nstatic void callCollNeeded(sqlite3 *db, int enc, const char *zName){\n  assert( !db->xCollNeeded || !db->xCollNeeded16 );\n  if( db->xCollNeeded ){\n    char *zExternal = sqlite3DbStrDup(db, zName);\n    if( !zExternal ) return;\n    db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);\n    sqlite3DbFree(db, zExternal);\n  }\n#ifndef SQLITE_OMIT_UTF16\n  if( db->xCollNeeded16 ){\n    char const *zExternal;\n    sqlite3_value *pTmp = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);\n    zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);\n    if( zExternal ){\n      db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);\n    }\n    sqlite3ValueFree(pTmp);\n  }\n#endif\n}\n\n/*\n** This routine is called if the collation factory fails to deliver a\n** collation function in the best encoding but there may be other versions\n** of this collation function (for other text encodings) available. Use one\n** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if\n** possible.\n*/\nstatic int synthCollSeq(sqlite3 *db, CollSeq *pColl){\n  CollSeq *pColl2;\n  char *z = pColl->zName;\n  int i;\n  static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };\n  for(i=0; i<3; i++){\n    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0);\n    if( pColl2->xCmp!=0 ){\n      memcpy(pColl, pColl2, sizeof(CollSeq));\n      pColl->xDel = 0;         /* Do not copy the destructor */\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** This function is responsible for invoking the collation factory callback\n** or substituting a collation sequence of a different encoding when the\n** requested collation sequence is not available in the desired encoding.\n** \n** If it is not NULL, then pColl must point to the database native encoding \n** collation sequence with name zName, length nName.\n**\n** The return value is either the collation sequence to be used in database\n** db for collation type name zName, length nName, or NULL, if no collation\n** sequence can be found.  If no collation is found, leave an error message.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(\n  Parse *pParse,        /* Parsing context */\n  u8 enc,               /* The desired encoding for the collating sequence */\n  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */\n  const char *zName     /* Collating sequence name */\n){\n  CollSeq *p;\n  sqlite3 *db = pParse->db;\n\n  p = pColl;\n  if( !p ){\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( !p || !p->xCmp ){\n    /* No collation sequence of this type for this encoding is registered.\n    ** Call the collation factory to see if it can supply us with one.\n    */\n    callCollNeeded(db, enc, zName);\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( p && !p->xCmp && synthCollSeq(db, p) ){\n    p = 0;\n  }\n  assert( !p || p->xCmp );\n  if( p==0 ){\n    sqlite3ErrorMsg(pParse, \"no such collation sequence: %s\", zName);\n  }\n  return p;\n}\n\n/*\n** This routine is called on a collation sequence before it is used to\n** check that it is defined. An undefined collation sequence exists when\n** a database is loaded that contains references to collation sequences\n** that have not been defined by sqlite3_create_collation() etc.\n**\n** If required, this routine calls the 'collation needed' callback to\n** request a definition of the collating sequence. If this doesn't work, \n** an equivalent collating sequence that uses a text encoding different\n** from the main database is substituted, if one is available.\n*/\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){\n  if( pColl ){\n    const char *zName = pColl->zName;\n    sqlite3 *db = pParse->db;\n    CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);\n    if( !p ){\n      return SQLITE_ERROR;\n    }\n    assert( p==pColl );\n  }\n  return SQLITE_OK;\n}\n\n\n\n/*\n** Locate and return an entry from the db.aCollSeq hash table. If the entry\n** specified by zName and nName is not found and parameter 'create' is\n** true, then create a new entry. Otherwise return NULL.\n**\n** Each pointer stored in the sqlite3.aCollSeq hash table contains an\n** array of three CollSeq structures. The first is the collation sequence\n** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.\n**\n** Stored immediately after the three collation sequences is a copy of\n** the collation sequence name. A pointer to this string is stored in\n** each collation sequence structure.\n*/\nstatic CollSeq *findCollSeqEntry(\n  sqlite3 *db,          /* Database connection */\n  const char *zName,    /* Name of the collating sequence */\n  int create            /* Create a new entry if true */\n){\n  CollSeq *pColl;\n  int nName = sqlite3Strlen30(zName);\n  pColl = sqlite3HashFind(&db->aCollSeq, zName, nName);\n\n  if( 0==pColl && create ){\n    pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 );\n    if( pColl ){\n      CollSeq *pDel = 0;\n      pColl[0].zName = (char*)&pColl[3];\n      pColl[0].enc = SQLITE_UTF8;\n      pColl[1].zName = (char*)&pColl[3];\n      pColl[1].enc = SQLITE_UTF16LE;\n      pColl[2].zName = (char*)&pColl[3];\n      pColl[2].enc = SQLITE_UTF16BE;\n      memcpy(pColl[0].zName, zName, nName);\n      pColl[0].zName[nName] = 0;\n      pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, nName, pColl);\n\n      /* If a malloc() failure occurred in sqlite3HashInsert(), it will \n      ** return the pColl pointer to be deleted (because it wasn't added\n      ** to the hash table).\n      */\n      assert( pDel==0 || pDel==pColl );\n      if( pDel!=0 ){\n        db->mallocFailed = 1;\n        sqlite3DbFree(db, pDel);\n        pColl = 0;\n      }\n    }\n  }\n  return pColl;\n}\n\n/*\n** Parameter zName points to a UTF-8 encoded string nName bytes long.\n** Return the CollSeq* pointer for the collation sequence named zName\n** for the encoding 'enc' from the database 'db'.\n**\n** If the entry specified is not found and 'create' is true, then create a\n** new entry.  Otherwise return NULL.\n**\n** A separate function sqlite3LocateCollSeq() is a wrapper around\n** this routine.  sqlite3LocateCollSeq() invokes the collation factory\n** if necessary and generates an error message if the collating sequence\n** cannot be found.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(\n  sqlite3 *db,\n  u8 enc,\n  const char *zName,\n  int create\n){\n  CollSeq *pColl;\n  if( zName ){\n    pColl = findCollSeqEntry(db, zName, create);\n  }else{\n    pColl = db->pDfltColl;\n  }\n  assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n  assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );\n  if( pColl ) pColl += enc-1;\n  return pColl;\n}\n\n/* During the search for the best function definition, this procedure\n** is called to test how well the function passed as the first argument\n** matches the request for a function with nArg arguments in a system\n** that uses encoding enc. The value returned indicates how well the\n** request is matched. A higher value indicates a better match.\n**\n** If nArg is -1 that means to only return a match (non-zero) if p->nArg\n** is also -1.  In other words, we are searching for a function that\n** takes a variable number of arguments.\n**\n** If nArg is -2 that means that we are searching for any function \n** regardless of the number of arguments it uses, so return a positive\n** match score for any\n**\n** The returned value is always between 0 and 6, as follows:\n**\n** 0: Not a match.\n** 1: UTF8/16 conversion required and function takes any number of arguments.\n** 2: UTF16 byte order change required and function takes any number of args.\n** 3: encoding matches and function takes any number of arguments\n** 4: UTF8/16 conversion required - argument count matches exactly\n** 5: UTF16 byte order conversion required - argument count matches exactly\n** 6: Perfect match:  encoding and argument count match exactly.\n**\n** If nArg==(-2) then any function with a non-null xStep or xFunc is\n** a perfect match and any function with both xStep and xFunc NULL is\n** a non-match.\n*/\n#define FUNC_PERFECT_MATCH 6  /* The score for a perfect match */\nstatic int matchQuality(\n  FuncDef *p,     /* The function we are evaluating for match quality */\n  int nArg,       /* Desired number of arguments.  (-1)==any */\n  u8 enc          /* Desired text encoding */\n){\n  int match;\n\n  /* nArg of -2 is a special case */\n  if( nArg==(-2) ) return (p->xFunc==0 && p->xStep==0) ? 0 : FUNC_PERFECT_MATCH;\n\n  /* Wrong number of arguments means \"no match\" */\n  if( p->nArg!=nArg && p->nArg>=0 ) return 0;\n\n  /* Give a better score to a function with a specific number of arguments\n  ** than to function that accepts any number of arguments. */\n  if( p->nArg==nArg ){\n    match = 4;\n  }else{\n    match = 1;\n  }\n\n  /* Bonus points if the text encoding matches */\n  if( enc==p->iPrefEnc ){\n    match += 2;  /* Exact encoding match */\n  }else if( (enc & p->iPrefEnc & 2)!=0 ){\n    match += 1;  /* Both are UTF16, but with different byte orders */\n  }\n\n  return match;\n}\n\n/*\n** Search a FuncDefHash for a function with the given name.  Return\n** a pointer to the matching FuncDef if found, or 0 if there is no match.\n*/\nstatic FuncDef *functionSearch(\n  FuncDefHash *pHash,  /* Hash table to search */\n  int h,               /* Hash of the name */\n  const char *zFunc,   /* Name of function */\n  int nFunc            /* Number of bytes in zFunc */\n){\n  FuncDef *p;\n  for(p=pHash->a[h]; p; p=p->pHash){\n    if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 && p->zName[nFunc]==0 ){\n      return p;\n    }\n  }\n  return 0;\n}\n\n/*\n** Insert a new FuncDef into a FuncDefHash hash table.\n*/\nSQLITE_PRIVATE void sqlite3FuncDefInsert(\n  FuncDefHash *pHash,  /* The hash table into which to insert */\n  FuncDef *pDef        /* The function definition to insert */\n){\n  FuncDef *pOther;\n  int nName = sqlite3Strlen30(pDef->zName);\n  u8 c1 = (u8)pDef->zName[0];\n  int h = (sqlite3UpperToLower[c1] + nName) % ArraySize(pHash->a);\n  pOther = functionSearch(pHash, h, pDef->zName, nName);\n  if( pOther ){\n    assert( pOther!=pDef && pOther->pNext!=pDef );\n    pDef->pNext = pOther->pNext;\n    pOther->pNext = pDef;\n  }else{\n    pDef->pNext = 0;\n    pDef->pHash = pHash->a[h];\n    pHash->a[h] = pDef;\n  }\n}\n  \n  \n\n/*\n** Locate a user function given a name, a number of arguments and a flag\n** indicating whether the function prefers UTF-16 over UTF-8.  Return a\n** pointer to the FuncDef structure that defines that function, or return\n** NULL if the function does not exist.\n**\n** If the createFlag argument is true, then a new (blank) FuncDef\n** structure is created and liked into the \"db\" structure if a\n** no matching function previously existed.\n**\n** If nArg is -2, then the first valid function found is returned.  A\n** function is valid if either xFunc or xStep is non-zero.  The nArg==(-2)\n** case is used to see if zName is a valid function name for some number\n** of arguments.  If nArg is -2, then createFlag must be 0.\n**\n** If createFlag is false, then a function with the required name and\n** number of arguments may be returned even if the eTextRep flag does not\n** match that requested.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(\n  sqlite3 *db,       /* An open database */\n  const char *zName, /* Name of the function.  Not null-terminated */\n  int nName,         /* Number of characters in the name */\n  int nArg,          /* Number of arguments.  -1 means any number */\n  u8 enc,            /* Preferred text encoding */\n  u8 createFlag      /* Create new entry if true and does not otherwise exist */\n){\n  FuncDef *p;         /* Iterator variable */\n  FuncDef *pBest = 0; /* Best match found so far */\n  int bestScore = 0;  /* Score of best match */\n  int h;              /* Hash value */\n\n  assert( nArg>=(-2) );\n  assert( nArg>=(-1) || createFlag==0 );\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % ArraySize(db->aFunc.a);\n\n  /* First search for a match amongst the application-defined functions.\n  */\n  p = functionSearch(&db->aFunc, h, zName, nName);\n  while( p ){\n    int score = matchQuality(p, nArg, enc);\n    if( score>bestScore ){\n      pBest = p;\n      bestScore = score;\n    }\n    p = p->pNext;\n  }\n\n  /* If no match is found, search the built-in functions.\n  **\n  ** If the SQLITE_PreferBuiltin flag is set, then search the built-in\n  ** functions even if a prior app-defined function was found.  And give\n  ** priority to built-in functions.\n  **\n  ** Except, if createFlag is true, that means that we are trying to\n  ** install a new function.  Whatever FuncDef structure is returned it will\n  ** have fields overwritten with new information appropriate for the\n  ** new function.  But the FuncDefs for built-in functions are read-only.\n  ** So we must not search for built-ins when creating a new function.\n  */ \n  if( !createFlag && (pBest==0 || (db->flags & SQLITE_PreferBuiltin)!=0) ){\n    FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);\n    bestScore = 0;\n    p = functionSearch(pHash, h, zName, nName);\n    while( p ){\n      int score = matchQuality(p, nArg, enc);\n      if( score>bestScore ){\n        pBest = p;\n        bestScore = score;\n      }\n      p = p->pNext;\n    }\n  }\n\n  /* If the createFlag parameter is true and the search did not reveal an\n  ** exact match for the name, number of arguments and encoding, then add a\n  ** new entry to the hash table and return it.\n  */\n  if( createFlag && bestScore<FUNC_PERFECT_MATCH && \n      (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){\n    pBest->zName = (char *)&pBest[1];\n    pBest->nArg = (u16)nArg;\n    pBest->iPrefEnc = enc;\n    memcpy(pBest->zName, zName, nName);\n    pBest->zName[nName] = 0;\n    sqlite3FuncDefInsert(&db->aFunc, pBest);\n  }\n\n  if( pBest && (pBest->xStep || pBest->xFunc || createFlag) ){\n    return pBest;\n  }\n  return 0;\n}\n\n/*\n** Free all resources held by the schema structure. The void* argument points\n** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the \n** pointer itself, it just cleans up subsidiary resources (i.e. the contents\n** of the schema hash tables).\n**\n** The Schema.cache_size variable is not cleared.\n*/\nSQLITE_PRIVATE void sqlite3SchemaClear(void *p){\n  Hash temp1;\n  Hash temp2;\n  HashElem *pElem;\n  Schema *pSchema = (Schema *)p;\n\n  temp1 = pSchema->tblHash;\n  temp2 = pSchema->trigHash;\n  sqlite3HashInit(&pSchema->trigHash);\n  sqlite3HashClear(&pSchema->idxHash);\n  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){\n    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));\n  }\n  sqlite3HashClear(&temp2);\n  sqlite3HashInit(&pSchema->tblHash);\n  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    sqlite3DeleteTable(0, pTab);\n  }\n  sqlite3HashClear(&temp1);\n  sqlite3HashClear(&pSchema->fkeyHash);\n  pSchema->pSeqTab = 0;\n  if( pSchema->flags & DB_SchemaLoaded ){\n    pSchema->iGeneration++;\n    pSchema->flags &= ~DB_SchemaLoaded;\n  }\n}\n\n/*\n** Find and return the schema associated with a BTree.  Create\n** a new one if necessary.\n*/\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){\n  Schema * p;\n  if( pBt ){\n    p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);\n  }else{\n    p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));\n  }\n  if( !p ){\n    db->mallocFailed = 1;\n  }else if ( 0==p->file_format ){\n    sqlite3HashInit(&p->tblHash);\n    sqlite3HashInit(&p->idxHash);\n    sqlite3HashInit(&p->trigHash);\n    sqlite3HashInit(&p->fkeyHash);\n    p->enc = SQLITE_UTF8;\n  }\n  return p;\n}\n\n/************** End of callback.c ********************************************/\n/************** Begin file delete.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** in order to generate code for DELETE FROM statements.\n*/\n\n/*\n** While a SrcList can in general represent multiple tables and subqueries\n** (as in the FROM clause of a SELECT statement) in this case it contains\n** the name of a single table, as one might find in an INSERT, DELETE,\n** or UPDATE statement.  Look up that table in the symbol table and\n** return a pointer.  Set an error message and return NULL if the table \n** name is not found or if any other error occurs.\n**\n** The following fields are initialized appropriate in pSrc:\n**\n**    pSrc->a[0].pTab       Pointer to the Table object\n**    pSrc->a[0].pIndex     Pointer to the INDEXED BY index, if there is one\n**\n*/\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){\n  struct SrcList_item *pItem = pSrc->a;\n  Table *pTab;\n  assert( pItem && pSrc->nSrc==1 );\n  pTab = sqlite3LocateTableItem(pParse, 0, pItem);\n  sqlite3DeleteTable(pParse->db, pItem->pTab);\n  pItem->pTab = pTab;\n  if( pTab ){\n    pTab->nRef++;\n  }\n  if( sqlite3IndexedByLookup(pParse, pItem) ){\n    pTab = 0;\n  }\n  return pTab;\n}\n\n/*\n** Check to make sure the given table is writable.  If it is not\n** writable, generate an error message and return 1.  If it is\n** writable return 0;\n*/\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){\n  /* A table is not writable under the following circumstances:\n  **\n  **   1) It is a virtual table and no implementation of the xUpdate method\n  **      has been provided, or\n  **   2) It is a system table (i.e. sqlite_master), this call is not\n  **      part of a nested parse and writable_schema pragma has not \n  **      been specified.\n  **\n  ** In either case leave an error message in pParse and return non-zero.\n  */\n  if( ( IsVirtual(pTab) \n     && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 )\n   || ( (pTab->tabFlags & TF_Readonly)!=0\n     && (pParse->db->flags & SQLITE_WriteSchema)==0\n     && pParse->nested==0 )\n  ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be modified\", pTab->zName);\n    return 1;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( !viewOk && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse,\"cannot modify %s because it is a view\",pTab->zName);\n    return 1;\n  }\n#endif\n  return 0;\n}\n\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Evaluate a view and store its result in an ephemeral table.  The\n** pWhere argument is an optional WHERE clause that restricts the\n** set of rows in the view that are to be added to the ephemeral table.\n*/\nSQLITE_PRIVATE void sqlite3MaterializeView(\n  Parse *pParse,       /* Parsing context */\n  Table *pView,        /* View definition */\n  Expr *pWhere,        /* Optional WHERE clause to be added */\n  int iCur             /* Cursor number for ephemerial table */\n){\n  SelectDest dest;\n  Select *pSel;\n  SrcList *pFrom;\n  sqlite3 *db = pParse->db;\n  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);\n\n  pWhere = sqlite3ExprDup(db, pWhere, 0);\n  pFrom = sqlite3SrcListAppend(db, 0, 0, 0);\n\n  if( pFrom ){\n    assert( pFrom->nSrc==1 );\n    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);\n    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);\n    assert( pFrom->a[0].pOn==0 );\n    assert( pFrom->a[0].pUsing==0 );\n  }\n\n  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, 0, 0, 0);\n  if( pSel ) pSel->selFlags |= SF_Materialize;\n\n  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);\n  sqlite3Select(pParse, pSel, &dest);\n  sqlite3SelectDelete(db, pSel);\n}\n#endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Generate an expression tree to implement the WHERE, ORDER BY,\n** and LIMIT/OFFSET portion of DELETE and UPDATE statements.\n**\n**     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;\n**                            \\__________________________/\n**                               pLimitWhere (pInClause)\n*/\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(\n  Parse *pParse,               /* The parser context */\n  SrcList *pSrc,               /* the FROM clause -- which tables to scan */\n  Expr *pWhere,                /* The WHERE clause.  May be null */\n  ExprList *pOrderBy,          /* The ORDER BY clause.  May be null */\n  Expr *pLimit,                /* The LIMIT clause.  May be null */\n  Expr *pOffset,               /* The OFFSET clause.  May be null */\n  char *zStmtType              /* Either DELETE or UPDATE.  For error messages. */\n){\n  Expr *pWhereRowid = NULL;    /* WHERE rowid .. */\n  Expr *pInClause = NULL;      /* WHERE rowid IN ( select ) */\n  Expr *pSelectRowid = NULL;   /* SELECT rowid ... */\n  ExprList *pEList = NULL;     /* Expression list contaning only pSelectRowid */\n  SrcList *pSelectSrc = NULL;  /* SELECT rowid FROM x ... (dup of pSrc) */\n  Select *pSelect = NULL;      /* Complete SELECT tree */\n\n  /* Check that there isn't an ORDER BY without a LIMIT clause.\n  */\n  if( pOrderBy && (pLimit == 0) ) {\n    sqlite3ErrorMsg(pParse, \"ORDER BY without LIMIT on %s\", zStmtType);\n    goto limit_where_cleanup_2;\n  }\n\n  /* We only need to generate a select expression if there\n  ** is a limit/offset term to enforce.\n  */\n  if( pLimit == 0 ) {\n    /* if pLimit is null, pOffset will always be null as well. */\n    assert( pOffset == 0 );\n    return pWhere;\n  }\n\n  /* Generate a select expression tree to enforce the limit/offset \n  ** term for the DELETE or UPDATE statement.  For example:\n  **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  ** becomes:\n  **   DELETE FROM table_a WHERE rowid IN ( \n  **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  **   );\n  */\n\n  pSelectRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0, 0);\n  if( pSelectRowid == 0 ) goto limit_where_cleanup_2;\n  pEList = sqlite3ExprListAppend(pParse, 0, pSelectRowid);\n  if( pEList == 0 ) goto limit_where_cleanup_2;\n\n  /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree\n  ** and the SELECT subtree. */\n  pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);\n  if( pSelectSrc == 0 ) {\n    sqlite3ExprListDelete(pParse->db, pEList);\n    goto limit_where_cleanup_2;\n  }\n\n  /* generate the SELECT expression tree. */\n  pSelect = sqlite3SelectNew(pParse,pEList,pSelectSrc,pWhere,0,0,\n                             pOrderBy,0,pLimit,pOffset);\n  if( pSelect == 0 ) return 0;\n\n  /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */\n  pWhereRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0, 0);\n  if( pWhereRowid == 0 ) goto limit_where_cleanup_1;\n  pInClause = sqlite3PExpr(pParse, TK_IN, pWhereRowid, 0, 0);\n  if( pInClause == 0 ) goto limit_where_cleanup_1;\n\n  pInClause->x.pSelect = pSelect;\n  pInClause->flags |= EP_xIsSelect;\n  sqlite3ExprSetHeight(pParse, pInClause);\n  return pInClause;\n\n  /* something went wrong. clean up anything allocated. */\nlimit_where_cleanup_1:\n  sqlite3SelectDelete(pParse->db, pSelect);\n  return 0;\n\nlimit_where_cleanup_2:\n  sqlite3ExprDelete(pParse->db, pWhere);\n  sqlite3ExprListDelete(pParse->db, pOrderBy);\n  sqlite3ExprDelete(pParse->db, pLimit);\n  sqlite3ExprDelete(pParse->db, pOffset);\n  return 0;\n}\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */\n\n/*\n** Generate code for a DELETE FROM statement.\n**\n**     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;\n**                 \\________/       \\________________/\n**                  pTabList              pWhere\n*/\nSQLITE_PRIVATE void sqlite3DeleteFrom(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table from which we should delete things */\n  Expr *pWhere           /* The WHERE clause.  May be null */\n){\n  Vdbe *v;               /* The virtual database engine */\n  Table *pTab;           /* The table from which records will be deleted */\n  const char *zDb;       /* Name of database holding pTab */\n  int end, addr = 0;     /* A couple addresses of generated code */\n  int i;                 /* Loop counter */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Index *pIdx;           /* For looping over indices of the table */\n  int iCur;              /* VDBE Cursor number for pTab */\n  sqlite3 *db;           /* Main database structure */\n  AuthContext sContext;  /* Authorization context */\n  NameContext sNC;       /* Name context to resolve expressions in */\n  int iDb;               /* Database number */\n  int memCnt = -1;       /* Memory cell used for change counting */\n  int rcauth;            /* Value returned by authorization callback */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                  /* True if attempting to delete from a view */\n  Trigger *pTrigger;           /* List of table triggers, if required */\n#endif\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto delete_from_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to delete.  This table has to be\n  ** put in an SrcList structure because some of the subroutines we\n  ** will be calling are designed to work with multiple tables and expect\n  ** an SrcList* parameter instead of just a Table* parameter.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 )  goto delete_from_cleanup;\n\n  /* Figure out if we have any triggers and if the table being\n  ** deleted from is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  /* If pTab is really a view, make sure it has been initialized.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto delete_from_cleanup;\n  }\n\n  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){\n    goto delete_from_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  zDb = db->aDb[iDb].zName;\n  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb);\n  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );\n  if( rcauth==SQLITE_DENY ){\n    goto delete_from_cleanup;\n  }\n  assert(!isView || pTrigger);\n\n  /* Assign  cursor number to the table and all its indices.\n  */\n  assert( pTabList->nSrc==1 );\n  iCur = pTabList->a[0].iCursor = pParse->nTab++;\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    pParse->nTab++;\n  }\n\n  /* Start the view context\n  */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* Begin generating code.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto delete_from_cleanup;\n  }\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n  /* If we are trying to delete from a view, realize that view into\n  ** a ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iCur);\n  }\n#endif\n\n  /* Resolve the column names in the WHERE clause.\n  */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto delete_from_cleanup;\n  }\n\n  /* Initialize the counter of the number of rows deleted, if\n  ** we are counting rows.\n  */\n  if( db->flags & SQLITE_CountRows ){\n    memCnt = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);\n  }\n\n#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  /* Special case: A DELETE without a WHERE clause deletes everything.\n  ** It is easier just to erase the whole table. Prior to version 3.6.5,\n  ** this optimization caused the row change count (the value returned by \n  ** API function sqlite3_count_changes) to be set incorrectly.  */\n  if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab) \n   && 0==sqlite3FkRequired(pParse, pTab, 0, 0)\n  ){\n    assert( !isView );\n    sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,\n                      pTab->zName, P4_STATIC);\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->pSchema==pTab->pSchema );\n      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);\n    }\n  }else\n#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */\n  /* The usual case: There is a WHERE clause so we have to scan through\n  ** the table and pick which records to delete.\n  */\n  {\n    int iRowSet = ++pParse->nMem;   /* Register for rowset of rows to delete */\n    int iRowid = ++pParse->nMem;    /* Used for storing rowid values. */\n    int regRowid;                   /* Actual register containing rowids */\n\n    /* Collect rowids of every row to be deleted.\n    */\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);\n    pWInfo = sqlite3WhereBegin(\n        pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK, 0\n    );\n    if( pWInfo==0 ) goto delete_from_cleanup;\n    regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);\n    sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);\n    if( db->flags & SQLITE_CountRows ){\n      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);\n    }\n    sqlite3WhereEnd(pWInfo);\n\n    /* Delete every item whose key was written to the list during the\n    ** database scan.  We have to delete items after the scan is complete\n    ** because deleting an item can change the scan order.  */\n    end = sqlite3VdbeMakeLabel(v);\n\n    /* Unless this is a view, open cursors for the table we are \n    ** deleting from and all its indices. If this is a view, then the\n    ** only effect this statement has is to fire the INSTEAD OF \n    ** triggers.  */\n    if( !isView ){\n      sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite);\n    }\n\n    addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid);\n\n    /* Delete the row */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iRowid, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, OE_Abort);\n      sqlite3MayAbort(pParse);\n    }else\n#endif\n    {\n      int count = (pParse->nested==0);    /* True to count changes */\n      sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default);\n    }\n\n    /* End of the delete loop */\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);\n    sqlite3VdbeResolveLabel(v, end);\n\n    /* Close the cursors open on the table and its indexes. */\n    if( !isView && !IsVirtual(pTab) ){\n      for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){\n        sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx->tnum);\n      }\n      sqlite3VdbeAddOp1(v, OP_Close, iCur);\n    }\n  }\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /* Return the number of rows that were deleted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows deleted\", SQLITE_STATIC);\n  }\n\ndelete_from_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprDelete(db, pWhere);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** thely may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n/*\n** This routine generates VDBE code that causes a single row of a\n** single table to be deleted.\n**\n** The VDBE must be in a particular state when this routine is called.\n** These are the requirements:\n**\n**   1.  A read/write cursor pointing to pTab, the table containing the row\n**       to be deleted, must be opened as cursor number $iCur.\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number base+i for the i-th index.\n**\n**   3.  The record number of the row to be deleted must be stored in\n**       memory cell iRowid.\n**\n** This routine generates code to remove both the table record and all \n** index entries that point to that record.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(\n  Parse *pParse,     /* Parsing context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  int iCur,          /* Cursor number for the table */\n  int iRowid,        /* Memory cell that contains the rowid to delete */\n  int count,         /* If non-zero, increment the row change counter */\n  Trigger *pTrigger, /* List of triggers to (potentially) fire */\n  int onconf         /* Default ON CONFLICT policy for triggers */\n){\n  Vdbe *v = pParse->pVdbe;        /* Vdbe */\n  int iOld = 0;                   /* First register in OLD.* array */\n  int iLabel;                     /* Label resolved to end of generated code */\n\n  /* Vdbe is guaranteed to have been allocated by this stage. */\n  assert( v );\n\n  /* Seek cursor iCur to the row to delete. If this row no longer exists \n  ** (this can happen if a trigger program has already deleted it), do\n  ** not attempt to delete it or fire any DELETE triggers.  */\n  iLabel = sqlite3VdbeMakeLabel(v);\n  sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);\n \n  /* If there are any triggers to fire, allocate a range of registers to\n  ** use for the old.* references in the triggers.  */\n  if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){\n    u32 mask;                     /* Mask of OLD.* columns in use */\n    int iCol;                     /* Iterator used while populating OLD.* */\n\n    /* TODO: Could use temporary registers here. Also could attempt to\n    ** avoid copying the contents of the rowid register.  */\n    mask = sqlite3TriggerColmask(\n        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf\n    );\n    mask |= sqlite3FkOldmask(pParse, pTab);\n    iOld = pParse->nMem+1;\n    pParse->nMem += (1 + pTab->nCol);\n\n    /* Populate the OLD.* pseudo-table register array. These values will be \n    ** used by any BEFORE and AFTER triggers that exist.  */\n    sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld);\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      if( mask==0xffffffff || mask&(1<<iCol) ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld+iCol+1);\n      }\n    }\n\n    /* Invoke BEFORE DELETE trigger programs. */\n    sqlite3CodeRowTrigger(pParse, pTrigger, \n        TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel\n    );\n\n    /* Seek the cursor to the row to be deleted again. It may be that\n    ** the BEFORE triggers coded above have already removed the row\n    ** being deleted. Do not attempt to delete the row a second time, and \n    ** do not fire AFTER triggers.  */\n    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid);\n\n    /* Do FK processing. This call checks that any FK constraints that\n    ** refer to this table (i.e. constraints attached to other tables) \n    ** are not violated by deleting this row.  */\n    sqlite3FkCheck(pParse, pTab, iOld, 0);\n  }\n\n  /* Delete the index and table entries. Skip this step if pTab is really\n  ** a view (in which case the only effect of the DELETE statement is to\n  ** fire the INSTEAD OF triggers).  */ \n  if( pTab->pSelect==0 ){\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, 0);\n    sqlite3VdbeAddOp2(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0));\n    if( count ){\n      sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);\n    }\n  }\n\n  /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n  ** handle rows (possibly in other tables) that refer via a foreign key\n  ** to the row just deleted. */ \n  sqlite3FkActions(pParse, pTab, 0, iOld);\n\n  /* Invoke AFTER DELETE trigger programs. */\n  sqlite3CodeRowTrigger(pParse, pTrigger, \n      TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel\n  );\n\n  /* Jump here if the row had already been deleted before any BEFORE\n  ** trigger programs were invoked. Or if a trigger program throws a \n  ** RAISE(IGNORE) exception.  */\n  sqlite3VdbeResolveLabel(v, iLabel);\n}\n\n/*\n** This routine generates VDBE code that causes the deletion of all\n** index entries associated with a single row of a single table.\n**\n** The VDBE must be in a particular state when this routine is called.\n** These are the requirements:\n**\n**   1.  A read/write cursor pointing to pTab, the table containing the row\n**       to be deleted, must be opened as cursor number \"iCur\".\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iCur+i for the i-th index.\n**\n**   3.  The \"iCur\" cursor must be pointing to the row that is to be\n**       deleted.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  int iCur,          /* Cursor number for the table */\n  int *aRegIdx       /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */\n){\n  int i;\n  Index *pIdx;\n  int r1;\n\n  for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){\n    if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue;\n    r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0);\n    sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1);\n  }\n}\n\n/*\n** Generate code that will assemble an index key and put it in register\n** regOut.  The key with be for index pIdx which is an index on pTab.\n** iCur is the index of a cursor open on the pTab table and pointing to\n** the entry that needs indexing.\n**\n** Return a register number which is the first in a block of\n** registers that holds the elements of the index key.  The\n** block of registers has already been deallocated by the time\n** this routine returns.\n*/\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(\n  Parse *pParse,     /* Parsing context */\n  Index *pIdx,       /* The index for which to generate a key */\n  int iCur,          /* Cursor number for the pIdx->pTable table */\n  int regOut,        /* Write the new index key to this register */\n  int doMakeRec      /* Run the OP_MakeRecord instruction if true */\n){\n  Vdbe *v = pParse->pVdbe;\n  int j;\n  Table *pTab = pIdx->pTable;\n  int regBase;\n  int nCol;\n\n  nCol = pIdx->nColumn;\n  regBase = sqlite3GetTempRange(pParse, nCol+1);\n  sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol);\n  for(j=0; j<nCol; j++){\n    int idx = pIdx->aiColumn[j];\n    if( idx==pTab->iPKey ){\n      sqlite3VdbeAddOp2(v, OP_SCopy, regBase+nCol, regBase+j);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j);\n      sqlite3ColumnDefault(v, pTab, idx, -1);\n    }\n  }\n  if( doMakeRec ){\n    const char *zAff;\n    if( pTab->pSelect\n     || OptimizationDisabled(pParse->db, SQLITE_IdxRealAsInt)\n    ){\n      zAff = 0;\n    }else{\n      zAff = sqlite3IndexAffinityStr(v, pIdx);\n    }\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);\n    sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);\n  }\n  sqlite3ReleaseTempRange(pParse, regBase, nCol+1);\n  return regBase;\n}\n\n/************** End of delete.c **********************************************/\n/************** Begin file func.c ********************************************/\n/*\n** 2002 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement various SQL\n** functions of SQLite.  \n**\n** There is only one exported symbol in this file - the function\n** sqliteRegisterBuildinFunctions() found at the bottom of the file.\n** All other code has file scope.\n*/\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n\n/*\n** Return the collating function associated with a function.\n*/\nstatic CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){\n  return context->pColl;\n}\n\n/*\n** Indicate that the accumulator load should be skipped on this\n** iteration of the aggregate loop.\n*/\nstatic void sqlite3SkipAccumulatorLoad(sqlite3_context *context){\n  context->skipFlag = 1;\n}\n\n/*\n** Implementation of the non-aggregate min() and max() functions\n*/\nstatic void minmaxFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  int mask;    /* 0 for min() or 0xffffffff for max() */\n  int iBest;\n  CollSeq *pColl;\n\n  assert( argc>1 );\n  mask = sqlite3_user_data(context)==0 ? 0 : -1;\n  pColl = sqlite3GetFuncCollSeq(context);\n  assert( pColl );\n  assert( mask==-1 || mask==0 );\n  iBest = 0;\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  for(i=1; i<argc; i++){\n    if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;\n    if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){\n      testcase( mask==0 );\n      iBest = i;\n    }\n  }\n  sqlite3_result_value(context, argv[iBest]);\n}\n\n/*\n** Return the type of the argument.\n*/\nstatic void typeofFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *z = 0;\n  UNUSED_PARAMETER(NotUsed);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_INTEGER: z = \"integer\"; break;\n    case SQLITE_TEXT:    z = \"text\";    break;\n    case SQLITE_FLOAT:   z = \"real\";    break;\n    case SQLITE_BLOB:    z = \"blob\";    break;\n    default:             z = \"null\";    break;\n  }\n  sqlite3_result_text(context, z, -1, SQLITE_STATIC);\n}\n\n\n/*\n** Implementation of the length() function\n*/\nstatic void lengthFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int len;\n\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_BLOB:\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_value_text(argv[0]);\n      if( z==0 ) return;\n      len = 0;\n      while( *z ){\n        len++;\n        SQLITE_SKIP_UTF8(z);\n      }\n      sqlite3_result_int(context, len);\n      break;\n    }\n    default: {\n      sqlite3_result_null(context);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the abs() function.\n**\n** IMP: R-23979-26855 The abs(X) function returns the absolute value of\n** the numeric argument X. \n*/\nstatic void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_INTEGER: {\n      i64 iVal = sqlite3_value_int64(argv[0]);\n      if( iVal<0 ){\n        if( (iVal<<1)==0 ){\n          /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then\n          ** abs(X) throws an integer overflow error since there is no\n          ** equivalent positive 64-bit two complement value. */\n          sqlite3_result_error(context, \"integer overflow\", -1);\n          return;\n        }\n        iVal = -iVal;\n      } \n      sqlite3_result_int64(context, iVal);\n      break;\n    }\n    case SQLITE_NULL: {\n      /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */\n      sqlite3_result_null(context);\n      break;\n    }\n    default: {\n      /* Because sqlite3_value_double() returns 0.0 if the argument is not\n      ** something that can be converted into a number, we have:\n      ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that\n      ** cannot be converted to a numeric value. \n      */\n      double rVal = sqlite3_value_double(argv[0]);\n      if( rVal<0 ) rVal = -rVal;\n      sqlite3_result_double(context, rVal);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the instr() function.\n**\n** instr(haystack,needle) finds the first occurrence of needle\n** in haystack and returns the number of previous characters plus 1,\n** or 0 if needle does not occur within haystack.\n**\n** If both haystack and needle are BLOBs, then the result is one more than\n** the number of bytes in haystack prior to the first occurrence of needle,\n** or 0 if needle never occurs in haystack.\n*/\nstatic void instrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zHaystack;\n  const unsigned char *zNeedle;\n  int nHaystack;\n  int nNeedle;\n  int typeHaystack, typeNeedle;\n  int N = 1;\n  int isText;\n\n  UNUSED_PARAMETER(argc);\n  typeHaystack = sqlite3_value_type(argv[0]);\n  typeNeedle = sqlite3_value_type(argv[1]);\n  if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;\n  nHaystack = sqlite3_value_bytes(argv[0]);\n  nNeedle = sqlite3_value_bytes(argv[1]);\n  if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){\n    zHaystack = sqlite3_value_blob(argv[0]);\n    zNeedle = sqlite3_value_blob(argv[1]);\n    isText = 0;\n  }else{\n    zHaystack = sqlite3_value_text(argv[0]);\n    zNeedle = sqlite3_value_text(argv[1]);\n    isText = 1;\n  }\n  while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){\n    N++;\n    do{\n      nHaystack--;\n      zHaystack++;\n    }while( isText && (zHaystack[0]&0xc0)==0x80 );\n  }\n  if( nNeedle>nHaystack ) N = 0;\n  sqlite3_result_int(context, N);\n}\n\n/*\n** Implementation of the substr() function.\n**\n** substr(x,p1,p2)  returns p2 characters of x[] beginning with p1.\n** p1 is 1-indexed.  So substr(x,1,1) returns the first character\n** of x.  If x is text, then we actually count UTF-8 characters.\n** If x is a blob, then we count bytes.\n**\n** If p1 is negative, then we begin abs(p1) from the end of x[].\n**\n** If p2 is negative, return the p2 characters preceeding p1.\n*/\nstatic void substrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z;\n  const unsigned char *z2;\n  int len;\n  int p0type;\n  i64 p1, p2;\n  int negP2 = 0;\n\n  assert( argc==3 || argc==2 );\n  if( sqlite3_value_type(argv[1])==SQLITE_NULL\n   || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)\n  ){\n    return;\n  }\n  p0type = sqlite3_value_type(argv[0]);\n  p1 = sqlite3_value_int(argv[1]);\n  if( p0type==SQLITE_BLOB ){\n    len = sqlite3_value_bytes(argv[0]);\n    z = sqlite3_value_blob(argv[0]);\n    if( z==0 ) return;\n    assert( len==sqlite3_value_bytes(argv[0]) );\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( z==0 ) return;\n    len = 0;\n    if( p1<0 ){\n      for(z2=z; *z2; len++){\n        SQLITE_SKIP_UTF8(z2);\n      }\n    }\n  }\n  if( argc==3 ){\n    p2 = sqlite3_value_int(argv[2]);\n    if( p2<0 ){\n      p2 = -p2;\n      negP2 = 1;\n    }\n  }else{\n    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  if( p1<0 ){\n    p1 += len;\n    if( p1<0 ){\n      p2 += p1;\n      if( p2<0 ) p2 = 0;\n      p1 = 0;\n    }\n  }else if( p1>0 ){\n    p1--;\n  }else if( p2>0 ){\n    p2--;\n  }\n  if( negP2 ){\n    p1 -= p2;\n    if( p1<0 ){\n      p2 += p1;\n      p1 = 0;\n    }\n  }\n  assert( p1>=0 && p2>=0 );\n  if( p0type!=SQLITE_BLOB ){\n    while( *z && p1 ){\n      SQLITE_SKIP_UTF8(z);\n      p1--;\n    }\n    for(z2=z; *z2 && p2; p2--){\n      SQLITE_SKIP_UTF8(z2);\n    }\n    sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);\n  }else{\n    if( p1+p2>len ){\n      p2 = len-p1;\n      if( p2<0 ) p2 = 0;\n    }\n    sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n** Implementation of the round() function\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\nstatic void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  int n = 0;\n  double r;\n  char *zBuf;\n  assert( argc==1 || argc==2 );\n  if( argc==2 ){\n    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;\n    n = sqlite3_value_int(argv[1]);\n    if( n>30 ) n = 30;\n    if( n<0 ) n = 0;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  r = sqlite3_value_double(argv[0]);\n  /* If Y==0 and X will fit in a 64-bit int,\n  ** handle the rounding directly,\n  ** otherwise use printf.\n  */\n  if( n==0 && r>=0 && r<LARGEST_INT64-1 ){\n    r = (double)((sqlite_int64)(r+0.5));\n  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){\n    r = -(double)((sqlite_int64)((-r)+0.5));\n  }else{\n    zBuf = sqlite3_mprintf(\"%.*f\",n,r);\n    if( zBuf==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);\n    sqlite3_free(zBuf);\n  }\n  sqlite3_result_double(context, r);\n}\n#endif\n\n/*\n** Allocate nByte bytes of space using sqlite3_malloc(). If the\n** allocation fails, call sqlite3_result_error_nomem() to notify\n** the database handle that malloc() has failed and return NULL.\n** If nByte is larger than the maximum string or blob length, then\n** raise an SQLITE_TOOBIG exception and return NULL.\n*/\nstatic void *contextMalloc(sqlite3_context *context, i64 nByte){\n  char *z;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  assert( nByte>0 );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    z = 0;\n  }else{\n    z = sqlite3Malloc((int)nByte);\n    if( !z ){\n      sqlite3_result_error_nomem(context);\n    }\n  }\n  return z;\n}\n\n/*\n** Implementation of the upper() and lower() SQL functions.\n*/\nstatic void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = (char)sqlite3Toupper(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\nstatic void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = sqlite3Tolower(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\n\n/*\n** The COALESCE() and IFNULL() functions are implemented as VDBE code so\n** that unused argument values do not have to be computed.  However, we\n** still need some kind of function implementation for this routines in\n** the function table.  That function implementation will never be called\n** so it doesn't matter what the implementation is.  We might as well use\n** the \"version()\" function as a substitute.\n*/\n#define ifnullFunc versionFunc   /* Substitute function - never called */\n\n/*\n** Implementation of random().  Return a random integer.  \n*/\nstatic void randomFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite_int64 r;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_randomness(sizeof(r), &r);\n  if( r<0 ){\n    /* We need to prevent a random number of 0x8000000000000000 \n    ** (or -9223372036854775808) since when you do abs() of that\n    ** number of you get the same value back again.  To do this\n    ** in a way that is testable, mask the sign bit off of negative\n    ** values, resulting in a positive value.  Then take the \n    ** 2s complement of that positive value.  The end result can\n    ** therefore be no less than -9223372036854775807.\n    */\n    r = -(r & LARGEST_INT64);\n  }\n  sqlite3_result_int64(context, r);\n}\n\n/*\n** Implementation of randomblob(N).  Return a random blob\n** that is N bytes long.\n*/\nstatic void randomBlob(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  unsigned char *p;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int(argv[0]);\n  if( n<1 ){\n    n = 1;\n  }\n  p = contextMalloc(context, n);\n  if( p ){\n    sqlite3_randomness(n, p);\n    sqlite3_result_blob(context, (char*)p, n, sqlite3_free);\n  }\n}\n\n/*\n** Implementation of the last_insert_rowid() SQL function.  The return\n** value is the same as the sqlite3_last_insert_rowid() API function.\n*/\nstatic void last_insert_rowid(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a\n  ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface\n  ** function. */\n  sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));\n}\n\n/*\n** Implementation of the changes() SQL function.\n**\n** IMP: R-62073-11209 The changes() SQL function is a wrapper\n** around the sqlite3_changes() C/C++ function and hence follows the same\n** rules for counting changes.\n*/\nstatic void changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_result_int(context, sqlite3_changes(db));\n}\n\n/*\n** Implementation of the total_changes() SQL function.  The return value is\n** the same as the sqlite3_total_changes() API function.\n*/\nstatic void total_changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-52756-41993 This function is a wrapper around the\n  ** sqlite3_total_changes() C/C++ interface. */\n  sqlite3_result_int(context, sqlite3_total_changes(db));\n}\n\n/*\n** A structure defining how to do GLOB-style comparisons.\n*/\nstruct compareInfo {\n  u8 matchAll;\n  u8 matchOne;\n  u8 matchSet;\n  u8 noCase;\n};\n\n/*\n** For LIKE and GLOB matching on EBCDIC machines, assume that every\n** character is exactly one byte in size.  Also, all characters are\n** able to participate in upper-case-to-lower-case mappings in EBCDIC\n** whereas only characters less than 0x80 do in ASCII.\n*/\n#if defined(SQLITE_EBCDIC)\n# define sqlite3Utf8Read(A)    (*((*A)++))\n# define GlogUpperToLower(A)   A = sqlite3UpperToLower[A]\n#else\n# define GlogUpperToLower(A)   if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; }\n#endif\n\nstatic const struct compareInfo globInfo = { '*', '?', '[', 0 };\n/* The correct SQL-92 behavior is for the LIKE operator to ignore\n** case.  Thus  'a' LIKE 'A' would be true. */\nstatic const struct compareInfo likeInfoNorm = { '%', '_',   0, 1 };\n/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator\n** is case sensitive causing 'a' LIKE 'A' to be false */\nstatic const struct compareInfo likeInfoAlt = { '%', '_',   0, 0 };\n\n/*\n** Compare two UTF-8 strings for equality where the first string can\n** potentially be a \"glob\" expression.  Return true (1) if they\n** are the same and false (0) if they are different.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n** With the [...] and [^...] matching, a ']' character can be included\n** in the list by making it the first character after '[' or '^'.  A\n** range of characters can be specified using '-'.  Example:\n** \"[a-z]\" matches any single lower-case letter.  To match a '-', make\n** it the last character in the list.\n**\n** This routine is usually quick, but can be N**2 in the worst case.\n**\n** Hints: to match '*' or '?', put them in \"[]\".  Like this:\n**\n**         abc[*]xyz        Matches \"abc*xyz\" only\n*/\nstatic int patternCompare(\n  const u8 *zPattern,              /* The glob pattern */\n  const u8 *zString,               /* The string to compare against the glob */\n  const struct compareInfo *pInfo, /* Information about how to do the compare */\n  u32 esc                          /* The escape character */\n){\n  u32 c, c2;\n  int invert;\n  int seen;\n  u8 matchOne = pInfo->matchOne;\n  u8 matchAll = pInfo->matchAll;\n  u8 matchSet = pInfo->matchSet;\n  u8 noCase = pInfo->noCase; \n  int prevEscape = 0;     /* True if the previous character was 'escape' */\n\n  while( (c = sqlite3Utf8Read(&zPattern))!=0 ){\n    if( c==matchAll && !prevEscape ){\n      while( (c=sqlite3Utf8Read(&zPattern)) == matchAll\n               || c == matchOne ){\n        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){\n          return 0;\n        }\n      }\n      if( c==0 ){\n        return 1;\n      }else if( c==esc ){\n        c = sqlite3Utf8Read(&zPattern);\n        if( c==0 ){\n          return 0;\n        }\n      }else if( c==matchSet ){\n        assert( esc==0 );         /* This is GLOB, not LIKE */\n        assert( matchSet<0x80 );  /* '[' is a single-byte character */\n        while( *zString && patternCompare(&zPattern[-1],zString,pInfo,esc)==0 ){\n          SQLITE_SKIP_UTF8(zString);\n        }\n        return *zString!=0;\n      }\n      while( (c2 = sqlite3Utf8Read(&zString))!=0 ){\n        if( noCase ){\n          GlogUpperToLower(c2);\n          GlogUpperToLower(c);\n          while( c2 != 0 && c2 != c ){\n            c2 = sqlite3Utf8Read(&zString);\n            GlogUpperToLower(c2);\n          }\n        }else{\n          while( c2 != 0 && c2 != c ){\n            c2 = sqlite3Utf8Read(&zString);\n          }\n        }\n        if( c2==0 ) return 0;\n        if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;\n      }\n      return 0;\n    }else if( c==matchOne && !prevEscape ){\n      if( sqlite3Utf8Read(&zString)==0 ){\n        return 0;\n      }\n    }else if( c==matchSet ){\n      u32 prior_c = 0;\n      assert( esc==0 );    /* This only occurs for GLOB, not LIKE */\n      seen = 0;\n      invert = 0;\n      c = sqlite3Utf8Read(&zString);\n      if( c==0 ) return 0;\n      c2 = sqlite3Utf8Read(&zPattern);\n      if( c2=='^' ){\n        invert = 1;\n        c2 = sqlite3Utf8Read(&zPattern);\n      }\n      if( c2==']' ){\n        if( c==']' ) seen = 1;\n        c2 = sqlite3Utf8Read(&zPattern);\n      }\n      while( c2 && c2!=']' ){\n        if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){\n          c2 = sqlite3Utf8Read(&zPattern);\n          if( c>=prior_c && c<=c2 ) seen = 1;\n          prior_c = 0;\n        }else{\n          if( c==c2 ){\n            seen = 1;\n          }\n          prior_c = c2;\n        }\n        c2 = sqlite3Utf8Read(&zPattern);\n      }\n      if( c2==0 || (seen ^ invert)==0 ){\n        return 0;\n      }\n    }else if( esc==c && !prevEscape ){\n      prevEscape = 1;\n    }else{\n      c2 = sqlite3Utf8Read(&zString);\n      if( noCase ){\n        GlogUpperToLower(c);\n        GlogUpperToLower(c2);\n      }\n      if( c!=c2 ){\n        return 0;\n      }\n      prevEscape = 0;\n    }\n  }\n  return *zString==0;\n}\n\n/*\n** The sqlite3_strglob() interface.\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){\n  return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;\n}\n\n/*\n** Count the number of times that the LIKE operator (or GLOB which is\n** just a variation of LIKE) gets called.  This is used for testing\n** only.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_like_count = 0;\n#endif\n\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B,A).\n**\n** This same function (with a different compareInfo structure) computes\n** the GLOB operator.\n*/\nstatic void likeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA, *zB;\n  u32 escape = 0;\n  int nPat;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  zB = sqlite3_value_text(argv[0]);\n  zA = sqlite3_value_text(argv[1]);\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  nPat = sqlite3_value_bytes(argv[0]);\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );\n  if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n  assert( zB==sqlite3_value_text(argv[0]) );  /* Encoding did not change */\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    const unsigned char *zEsc = sqlite3_value_text(argv[2]);\n    if( zEsc==0 ) return;\n    if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n    escape = sqlite3Utf8Read(&zEsc);\n  }\n  if( zA && zB ){\n    struct compareInfo *pInfo = sqlite3_user_data(context);\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    \n    sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape));\n  }\n}\n\n/*\n** Implementation of the NULLIF(x,y) function.  The result is the first\n** argument if the arguments are different.  The result is NULL if the\n** arguments are equal to each other.\n*/\nstatic void nullifFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n  UNUSED_PARAMETER(NotUsed);\n  if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){\n    sqlite3_result_value(context, argv[0]);\n  }\n}\n\n/*\n** Implementation of the sqlite_version() function.  The result is the version\n** of the SQLite library that is running.\n*/\nstatic void versionFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-48699-48617 This function is an SQL wrapper around the\n  ** sqlite3_libversion() C-interface. */\n  sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_source_id() function. The result is a string\n** that identifies the particular version of the source code used to build\n** SQLite.\n*/\nstatic void sourceidFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-24470-31136 This function is an SQL wrapper around the\n  ** sqlite3_sourceid() C interface. */\n  sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_log() function.  This is a wrapper around\n** sqlite3_log().  The return value is NULL.  The function exists purely for\n** its side-effects.\n*/\nstatic void errlogFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(context);\n  sqlite3_log(sqlite3_value_int(argv[0]), \"%s\", sqlite3_value_text(argv[1]));\n}\n\n/*\n** Implementation of the sqlite_compileoption_used() function.\n** The result is an integer that identifies if the compiler option\n** was used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptionusedFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zOptName;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL\n  ** function is a wrapper around the sqlite3_compileoption_used() C/C++\n  ** function.\n  */\n  if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    sqlite3_result_int(context, sqlite3_compileoption_used(zOptName));\n  }\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/*\n** Implementation of the sqlite_compileoption_get() function. \n** The result is a string that identifies the compiler options \n** used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptiongetFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function\n  ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.\n  */\n  n = sqlite3_value_int(argv[0]);\n  sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC);\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/* Array for converting from half-bytes (nybbles) into ASCII hex\n** digits. */\nstatic const char hexdigits[] = {\n  '0', '1', '2', '3', '4', '5', '6', '7',\n  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' \n};\n\n/*\n** EXPERIMENTAL - This is not an official function.  The interface may\n** change.  This function may disappear.  Do not write code that depends\n** on this function.\n**\n** Implementation of the QUOTE() function.  This function takes a single\n** argument.  If the argument is numeric, the return value is the same as\n** the argument.  If the argument is NULL, the return value is the string\n** \"NULL\".  Otherwise, the argument is enclosed in single quotes with\n** single-quote escapes.\n*/\nstatic void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      double r1, r2;\n      char zBuf[50];\n      r1 = sqlite3_value_double(argv[0]);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.15g\", r1);\n      sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);\n      if( r1!=r2 ){\n        sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.20e\", r1);\n      }\n      sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_result_value(context, argv[0]);\n      break;\n    }\n    case SQLITE_BLOB: {\n      char *zText = 0;\n      char const *zBlob = sqlite3_value_blob(argv[0]);\n      int nBlob = sqlite3_value_bytes(argv[0]);\n      assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */\n      zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4); \n      if( zText ){\n        int i;\n        for(i=0; i<nBlob; i++){\n          zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];\n          zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F];\n        }\n        zText[(nBlob*2)+2] = '\\'';\n        zText[(nBlob*2)+3] = '\\0';\n        zText[0] = 'X';\n        zText[1] = '\\'';\n        sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);\n        sqlite3_free(zText);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      int i,j;\n      u64 n;\n      const unsigned char *zArg = sqlite3_value_text(argv[0]);\n      char *z;\n\n      if( zArg==0 ) return;\n      for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\\'' ) n++; }\n      z = contextMalloc(context, ((i64)i)+((i64)n)+3);\n      if( z ){\n        z[0] = '\\'';\n        for(i=0, j=1; zArg[i]; i++){\n          z[j++] = zArg[i];\n          if( zArg[i]=='\\'' ){\n            z[j++] = '\\'';\n          }\n        }\n        z[j++] = '\\'';\n        z[j] = 0;\n        sqlite3_result_text(context, z, j, sqlite3_free);\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      sqlite3_result_text(context, \"NULL\", 4, SQLITE_STATIC);\n      break;\n    }\n  }\n}\n\n/*\n** The unicode() function.  Return the integer unicode code-point value\n** for the first character of the input string. \n*/\nstatic void unicodeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z = sqlite3_value_text(argv[0]);\n  (void)argc;\n  if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z));\n}\n\n/*\n** The char() function takes zero or more arguments, each of which is\n** an integer.  It constructs a string where each character of the string\n** is the unicode character for the corresponding integer argument.\n*/\nstatic void charFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  unsigned char *z, *zOut;\n  int i;\n  zOut = z = sqlite3_malloc( argc*4 );\n  if( z==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  for(i=0; i<argc; i++){\n    sqlite3_int64 x;\n    unsigned c;\n    x = sqlite3_value_int64(argv[i]);\n    if( x<0 || x>0x10ffff ) x = 0xfffd;\n    c = (unsigned)(x & 0x1fffff);\n    if( c<0x00080 ){\n      *zOut++ = (u8)(c&0xFF);\n    }else if( c<0x00800 ){\n      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else if( c<0x10000 ){\n      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else{\n      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);\n      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }                                                    \\\n  }\n  sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free);\n}\n\n/*\n** The hex() function.  Interpret the argument as a blob.  Return\n** a hexadecimal rendering as text.\n*/\nstatic void hexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i, n;\n  const unsigned char *pBlob;\n  char *zHex, *z;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  pBlob = sqlite3_value_blob(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  assert( pBlob==sqlite3_value_blob(argv[0]) );  /* No encoding change */\n  z = zHex = contextMalloc(context, ((i64)n)*2 + 1);\n  if( zHex ){\n    for(i=0; i<n; i++, pBlob++){\n      unsigned char c = *pBlob;\n      *(z++) = hexdigits[(c>>4)&0xf];\n      *(z++) = hexdigits[c&0xf];\n    }\n    *z = 0;\n    sqlite3_result_text(context, zHex, n*2, sqlite3_free);\n  }\n}\n\n/*\n** The zeroblob(N) function returns a zero-filled blob of size N bytes.\n*/\nstatic void zeroblobFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  i64 n;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int64(argv[0]);\n  testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH] );\n  testcase( n==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  if( n>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n  }else{\n    sqlite3_result_zeroblob(context, (int)n); /* IMP: R-00293-64994 */\n  }\n}\n\n/*\n** The replace() function.  Three arguments are all strings: call\n** them A, B, and C. The result is also a string which is derived\n** from A by replacing every occurance of B with C.  The match\n** must be exact.  Collating sequences are not used.\n*/\nstatic void replaceFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zStr;        /* The input string A */\n  const unsigned char *zPattern;    /* The pattern string B */\n  const unsigned char *zRep;        /* The replacement string C */\n  unsigned char *zOut;              /* The output */\n  int nStr;                /* Size of zStr */\n  int nPattern;            /* Size of zPattern */\n  int nRep;                /* Size of zRep */\n  i64 nOut;                /* Maximum size of zOut */\n  int loopLimit;           /* Last zStr[] that might match zPattern[] */\n  int i, j;                /* Loop counters */\n\n  assert( argc==3 );\n  UNUSED_PARAMETER(argc);\n  zStr = sqlite3_value_text(argv[0]);\n  if( zStr==0 ) return;\n  nStr = sqlite3_value_bytes(argv[0]);\n  assert( zStr==sqlite3_value_text(argv[0]) );  /* No encoding change */\n  zPattern = sqlite3_value_text(argv[1]);\n  if( zPattern==0 ){\n    assert( sqlite3_value_type(argv[1])==SQLITE_NULL\n            || sqlite3_context_db_handle(context)->mallocFailed );\n    return;\n  }\n  if( zPattern[0]==0 ){\n    assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );\n    sqlite3_result_value(context, argv[0]);\n    return;\n  }\n  nPattern = sqlite3_value_bytes(argv[1]);\n  assert( zPattern==sqlite3_value_text(argv[1]) );  /* No encoding change */\n  zRep = sqlite3_value_text(argv[2]);\n  if( zRep==0 ) return;\n  nRep = sqlite3_value_bytes(argv[2]);\n  assert( zRep==sqlite3_value_text(argv[2]) );\n  nOut = nStr + 1;\n  assert( nOut<SQLITE_MAX_LENGTH );\n  zOut = contextMalloc(context, (i64)nOut);\n  if( zOut==0 ){\n    return;\n  }\n  loopLimit = nStr - nPattern;  \n  for(i=j=0; i<=loopLimit; i++){\n    if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){\n      zOut[j++] = zStr[i];\n    }else{\n      u8 *zOld;\n      sqlite3 *db = sqlite3_context_db_handle(context);\n      nOut += nRep - nPattern;\n      testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        sqlite3_result_error_toobig(context);\n        sqlite3_free(zOut);\n        return;\n      }\n      zOld = zOut;\n      zOut = sqlite3_realloc(zOut, (int)nOut);\n      if( zOut==0 ){\n        sqlite3_result_error_nomem(context);\n        sqlite3_free(zOld);\n        return;\n      }\n      memcpy(&zOut[j], zRep, nRep);\n      j += nRep;\n      i += nPattern-1;\n    }\n  }\n  assert( j+nStr-i+1==nOut );\n  memcpy(&zOut[j], &zStr[i], nStr-i);\n  j += nStr - i;\n  assert( j<=nOut );\n  zOut[j] = 0;\n  sqlite3_result_text(context, (char*)zOut, j, sqlite3_free);\n}\n\n/*\n** Implementation of the TRIM(), LTRIM(), and RTRIM() functions.\n** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both.\n*/\nstatic void trimFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;         /* Input string */\n  const unsigned char *zCharSet;    /* Set of characters to trim */\n  int nIn;                          /* Number of bytes in input */\n  int flags;                        /* 1: trimleft  2: trimright  3: trim */\n  int i;                            /* Loop counter */\n  unsigned char *aLen = 0;          /* Length of each character in zCharSet */\n  unsigned char **azChar = 0;       /* Individual characters in zCharSet */\n  int nChar;                        /* Number of characters in zCharSet */\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    return;\n  }\n  zIn = sqlite3_value_text(argv[0]);\n  if( zIn==0 ) return;\n  nIn = sqlite3_value_bytes(argv[0]);\n  assert( zIn==sqlite3_value_text(argv[0]) );\n  if( argc==1 ){\n    static const unsigned char lenOne[] = { 1 };\n    static unsigned char * const azOne[] = { (u8*)\" \" };\n    nChar = 1;\n    aLen = (u8*)lenOne;\n    azChar = (unsigned char **)azOne;\n    zCharSet = 0;\n  }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){\n    return;\n  }else{\n    const unsigned char *z;\n    for(z=zCharSet, nChar=0; *z; nChar++){\n      SQLITE_SKIP_UTF8(z);\n    }\n    if( nChar>0 ){\n      azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));\n      if( azChar==0 ){\n        return;\n      }\n      aLen = (unsigned char*)&azChar[nChar];\n      for(z=zCharSet, nChar=0; *z; nChar++){\n        azChar[nChar] = (unsigned char *)z;\n        SQLITE_SKIP_UTF8(z);\n        aLen[nChar] = (u8)(z - azChar[nChar]);\n      }\n    }\n  }\n  if( nChar>0 ){\n    flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));\n    if( flags & 1 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        zIn += len;\n        nIn -= len;\n      }\n    }\n    if( flags & 2 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        nIn -= len;\n      }\n    }\n    if( zCharSet ){\n      sqlite3_free(azChar);\n    }\n  }\n  sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);\n}\n\n\n/* IMP: R-25361-16150 This function is omitted from SQLite by default. It\n** is only available if the SQLITE_SOUNDEX compile-time option is used\n** when SQLite is built.\n*/\n#ifdef SQLITE_SOUNDEX\n/*\n** Compute the soundex encoding of a word.\n**\n** IMP: R-59782-00072 The soundex(X) function returns a string that is the\n** soundex encoding of the string X. \n*/\nstatic void soundexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  char zResult[8];\n  const u8 *zIn;\n  int i, j;\n  static const unsigned char iCode[] = {\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n  };\n  assert( argc==1 );\n  zIn = (u8*)sqlite3_value_text(argv[0]);\n  if( zIn==0 ) zIn = (u8*)\"\";\n  for(i=0; zIn[i] && !sqlite3Isalpha(zIn[i]); i++){}\n  if( zIn[i] ){\n    u8 prevcode = iCode[zIn[i]&0x7f];\n    zResult[0] = sqlite3Toupper(zIn[i]);\n    for(j=1; j<4 && zIn[i]; i++){\n      int code = iCode[zIn[i]&0x7f];\n      if( code>0 ){\n        if( code!=prevcode ){\n          prevcode = code;\n          zResult[j++] = code + '0';\n        }\n      }else{\n        prevcode = 0;\n      }\n    }\n    while( j<4 ){\n      zResult[j++] = '0';\n    }\n    zResult[j] = 0;\n    sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);\n  }else{\n    /* IMP: R-64894-50321 The string \"?000\" is returned if the argument\n    ** is NULL or contains no ASCII alphabetic characters. */\n    sqlite3_result_text(context, \"?000\", 4, SQLITE_STATIC);\n  }\n}\n#endif /* SQLITE_SOUNDEX */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** A function that loads a shared-library extension then returns NULL.\n*/\nstatic void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){\n  const char *zFile = (const char *)sqlite3_value_text(argv[0]);\n  const char *zProc;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zErrMsg = 0;\n\n  if( argc==2 ){\n    zProc = (const char *)sqlite3_value_text(argv[1]);\n  }else{\n    zProc = 0;\n  }\n  if( zFile && sqlite3_load_extension(db, zFile, zProc, &zErrMsg) ){\n    sqlite3_result_error(context, zErrMsg, -1);\n    sqlite3_free(zErrMsg);\n  }\n}\n#endif\n\n\n/*\n** An instance of the following structure holds the context of a\n** sum() or avg() aggregate computation.\n*/\ntypedef struct SumCtx SumCtx;\nstruct SumCtx {\n  double rSum;      /* Floating point sum */\n  i64 iSum;         /* Integer sum */   \n  i64 cnt;          /* Number of elements summed */\n  u8 overflow;      /* True if integer overflow seen */\n  u8 approx;        /* True if non-integer value was input to the sum */\n};\n\n/*\n** Routines used to compute the sum, average, and total.\n**\n** The SUM() function follows the (broken) SQL standard which means\n** that it returns NULL if it sums over no inputs.  TOTAL returns\n** 0.0 in that case.  In addition, TOTAL always returns a float where\n** SUM might return an integer if it never encounters a floating point\n** value.  TOTAL never fails, but SUM might through an exception if\n** it overflows an integer.\n*/\nstatic void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  SumCtx *p;\n  int type;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  type = sqlite3_value_numeric_type(argv[0]);\n  if( p && type!=SQLITE_NULL ){\n    p->cnt++;\n    if( type==SQLITE_INTEGER ){\n      i64 v = sqlite3_value_int64(argv[0]);\n      p->rSum += v;\n      if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){\n        p->overflow = 1;\n      }\n    }else{\n      p->rSum += sqlite3_value_double(argv[0]);\n      p->approx = 1;\n    }\n  }\n}\nstatic void sumFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    if( p->overflow ){\n      sqlite3_result_error(context,\"integer overflow\",-1);\n    }else if( p->approx ){\n      sqlite3_result_double(context, p->rSum);\n    }else{\n      sqlite3_result_int64(context, p->iSum);\n    }\n  }\n}\nstatic void avgFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    sqlite3_result_double(context, p->rSum/(double)p->cnt);\n  }\n}\nstatic void totalFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  sqlite3_result_double(context, p ? p->rSum : (double)0);\n}\n\n/*\n** The following structure keeps track of state information for the\n** count() aggregate function.\n*/\ntypedef struct CountCtx CountCtx;\nstruct CountCtx {\n  i64 n;\n};\n\n/*\n** Routines to implement the count() aggregate function.\n*/\nstatic void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){\n    p->n++;\n  }\n\n#ifndef SQLITE_OMIT_DEPRECATED\n  /* The sqlite3_aggregate_count() function is deprecated.  But just to make\n  ** sure it still operates correctly, verify that its count agrees with our \n  ** internal count when using count(*) and when the total count can be\n  ** expressed as a 32-bit integer. */\n  assert( argc==1 || p==0 || p->n>0x7fffffff\n          || p->n==sqlite3_aggregate_count(context) );\n#endif\n}   \nstatic void countFinalize(sqlite3_context *context){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  sqlite3_result_int64(context, p ? p->n : 0);\n}\n\n/*\n** Routines to implement min() and max() aggregate functions.\n*/\nstatic void minmaxStep(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **argv\n){\n  Mem *pArg  = (Mem *)argv[0];\n  Mem *pBest;\n  UNUSED_PARAMETER(NotUsed);\n\n  pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));\n  if( !pBest ) return;\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);\n  }else if( pBest->flags ){\n    int max;\n    int cmp;\n    CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n    /* This step function is used for both the min() and max() aggregates,\n    ** the only difference between the two being that the sense of the\n    ** comparison is inverted. For the max() aggregate, the\n    ** sqlite3_user_data() function returns (void *)-1. For min() it\n    ** returns (void *)db, where db is the sqlite3* database pointer.\n    ** Therefore the next statement sets variable 'max' to 1 for the max()\n    ** aggregate, or 0 for min().\n    */\n    max = sqlite3_user_data(context)!=0;\n    cmp = sqlite3MemCompare(pBest, pArg, pColl);\n    if( (max && cmp<0) || (!max && cmp>0) ){\n      sqlite3VdbeMemCopy(pBest, pArg);\n    }else{\n      sqlite3SkipAccumulatorLoad(context);\n    }\n  }else{\n    sqlite3VdbeMemCopy(pBest, pArg);\n  }\n}\nstatic void minMaxFinalize(sqlite3_context *context){\n  sqlite3_value *pRes;\n  pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);\n  if( pRes ){\n    if( pRes->flags ){\n      sqlite3_result_value(context, pRes);\n    }\n    sqlite3VdbeMemRelease(pRes);\n  }\n}\n\n/*\n** group_concat(EXPR, ?SEPARATOR?)\n*/\nstatic void groupConcatStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zVal;\n  StrAccum *pAccum;\n  const char *zSep;\n  int nVal, nSep;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));\n\n  if( pAccum ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    int firstTerm = pAccum->useMalloc==0;\n    pAccum->useMalloc = 2;\n    pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];\n    if( !firstTerm ){\n      if( argc==2 ){\n        zSep = (char*)sqlite3_value_text(argv[1]);\n        nSep = sqlite3_value_bytes(argv[1]);\n      }else{\n        zSep = \",\";\n        nSep = 1;\n      }\n      sqlite3StrAccumAppend(pAccum, zSep, nSep);\n    }\n    zVal = (char*)sqlite3_value_text(argv[0]);\n    nVal = sqlite3_value_bytes(argv[0]);\n    sqlite3StrAccumAppend(pAccum, zVal, nVal);\n  }\n}\nstatic void groupConcatFinalize(sqlite3_context *context){\n  StrAccum *pAccum;\n  pAccum = sqlite3_aggregate_context(context, 0);\n  if( pAccum ){\n    if( pAccum->tooBig ){\n      sqlite3_result_error_toobig(context);\n    }else if( pAccum->mallocFailed ){\n      sqlite3_result_error_nomem(context);\n    }else{    \n      sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, \n                          sqlite3_free);\n    }\n  }\n}\n\n/*\n** This routine does per-connection function registration.  Most\n** of the built-in functions above are part of the global function set.\n** This routine only deals with those that are not global.\n*/\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(sqlite3 *db){\n  int rc = sqlite3_overload_function(db, \"MATCH\", 2);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    db->mallocFailed = 1;\n  }\n}\n\n/*\n** Set the LIKEOPT flag on the 2-argument function with the given name.\n*/\nstatic void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){\n  FuncDef *pDef;\n  pDef = sqlite3FindFunction(db, zName, sqlite3Strlen30(zName),\n                             2, SQLITE_UTF8, 0);\n  if( ALWAYS(pDef) ){\n    pDef->flags = flagVal;\n  }\n}\n\n/*\n** Register the built-in LIKE and GLOB functions.  The caseSensitive\n** parameter determines whether or not the LIKE operator is case\n** sensitive.  GLOB is always case sensitive.\n*/\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){\n  struct compareInfo *pInfo;\n  if( caseSensitive ){\n    pInfo = (struct compareInfo*)&likeInfoAlt;\n  }else{\n    pInfo = (struct compareInfo*)&likeInfoNorm;\n  }\n  sqlite3CreateFunc(db, \"like\", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"like\", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"glob\", 2, SQLITE_UTF8, \n      (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);\n  setLikeOptFlag(db, \"glob\", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);\n  setLikeOptFlag(db, \"like\", \n      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);\n}\n\n/*\n** pExpr points to an expression which implements a function.  If\n** it is appropriate to apply the LIKE optimization to that function\n** then set aWc[0] through aWc[2] to the wildcard characters and\n** return TRUE.  If the function is not a LIKE-style function then\n** return FALSE.\n*/\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){\n  FuncDef *pDef;\n  if( pExpr->op!=TK_FUNCTION \n   || !pExpr->x.pList \n   || pExpr->x.pList->nExpr!=2\n  ){\n    return 0;\n  }\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  pDef = sqlite3FindFunction(db, pExpr->u.zToken, \n                             sqlite3Strlen30(pExpr->u.zToken),\n                             2, SQLITE_UTF8, 0);\n  if( NEVER(pDef==0) || (pDef->flags & SQLITE_FUNC_LIKE)==0 ){\n    return 0;\n  }\n\n  /* The memcpy() statement assumes that the wildcard characters are\n  ** the first three statements in the compareInfo structure.  The\n  ** asserts() that follow verify that assumption\n  */\n  memcpy(aWc, pDef->pUserData, 3);\n  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );\n  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );\n  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );\n  *pIsNocase = (pDef->flags & SQLITE_FUNC_CASE)==0;\n  return 1;\n}\n\n/*\n** All all of the FuncDef structures in the aBuiltinFunc[] array above\n** to the global function hash table.  This occurs at start-time (as\n** a consequence of calling sqlite3_initialize()).\n**\n** After this routine runs\n*/\nSQLITE_PRIVATE void sqlite3RegisterGlobalFunctions(void){\n  /*\n  ** The following array holds FuncDef structures for all of the functions\n  ** defined in this file.\n  **\n  ** The array cannot be constant since changes are made to the\n  ** FuncDef.pHash elements at start-time.  The elements of this array\n  ** are read-only after initialization is complete.\n  */\n  static SQLITE_WSD FuncDef aBuiltinFunc[] = {\n    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),\n    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),\n    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),\n    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),\n    FUNCTION(trim,               1, 3, 0, trimFunc         ),\n    FUNCTION(trim,               2, 3, 0, trimFunc         ),\n    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),\n    FUNCTION(min,                0, 0, 1, 0                ),\n    AGGREGATE(min,               1, 0, 1, minmaxStep,      minMaxFinalize ),\n    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),\n    FUNCTION(max,                0, 1, 1, 0                ),\n    AGGREGATE(max,               1, 1, 1, minmaxStep,      minMaxFinalize ),\n    FUNCTION2(typeof,            1, 0, 0, typeofFunc,  SQLITE_FUNC_TYPEOF),\n    FUNCTION2(length,            1, 0, 0, lengthFunc,  SQLITE_FUNC_LENGTH),\n    FUNCTION(instr,              2, 0, 0, instrFunc        ),\n    FUNCTION(substr,             2, 0, 0, substrFunc       ),\n    FUNCTION(substr,             3, 0, 0, substrFunc       ),\n    FUNCTION(unicode,            1, 0, 0, unicodeFunc      ),\n    FUNCTION(char,              -1, 0, 0, charFunc         ),\n    FUNCTION(abs,                1, 0, 0, absFunc          ),\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    FUNCTION(round,              1, 0, 0, roundFunc        ),\n    FUNCTION(round,              2, 0, 0, roundFunc        ),\n#endif\n    FUNCTION(upper,              1, 0, 0, upperFunc        ),\n    FUNCTION(lower,              1, 0, 0, lowerFunc        ),\n    FUNCTION(coalesce,           1, 0, 0, 0                ),\n    FUNCTION(coalesce,           0, 0, 0, 0                ),\n    FUNCTION2(coalesce,         -1, 0, 0, ifnullFunc,  SQLITE_FUNC_COALESCE),\n    FUNCTION(hex,                1, 0, 0, hexFunc          ),\n    FUNCTION2(ifnull,            2, 0, 0, ifnullFunc,  SQLITE_FUNC_COALESCE),\n    FUNCTION(random,             0, 0, 0, randomFunc       ),\n    FUNCTION(randomblob,         1, 0, 0, randomBlob       ),\n    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),\n    FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),\n    FUNCTION(sqlite_source_id,   0, 0, 0, sourceidFunc     ),\n    FUNCTION(sqlite_log,         2, 0, 0, errlogFunc       ),\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n    FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),\n    FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n    FUNCTION(quote,              1, 0, 0, quoteFunc        ),\n    FUNCTION(last_insert_rowid,  0, 0, 0, last_insert_rowid),\n    FUNCTION(changes,            0, 0, 0, changes          ),\n    FUNCTION(total_changes,      0, 0, 0, total_changes    ),\n    FUNCTION(replace,            3, 0, 0, replaceFunc      ),\n    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),\n  #ifdef SQLITE_SOUNDEX\n    FUNCTION(soundex,            1, 0, 0, soundexFunc      ),\n  #endif\n  #ifndef SQLITE_OMIT_LOAD_EXTENSION\n    FUNCTION(load_extension,     1, 0, 0, loadExt          ),\n    FUNCTION(load_extension,     2, 0, 0, loadExt          ),\n  #endif\n    AGGREGATE(sum,               1, 0, 0, sumStep,         sumFinalize    ),\n    AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),\n    AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),\n /* AGGREGATE(count,             0, 0, 0, countStep,       countFinalize  ), */\n    {0,SQLITE_UTF8,SQLITE_FUNC_COUNT,0,0,0,countStep,countFinalize,\"count\",0,0},\n    AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),\n    AGGREGATE(group_concat,      1, 0, 0, groupConcatStep, groupConcatFinalize),\n    AGGREGATE(group_concat,      2, 0, 0, groupConcatStep, groupConcatFinalize),\n  \n    LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n  #ifdef SQLITE_CASE_SENSITIVE_LIKE\n    LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n    LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n  #else\n    LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),\n    LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),\n  #endif\n  };\n\n  int i;\n  FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);\n  FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aBuiltinFunc);\n\n  for(i=0; i<ArraySize(aBuiltinFunc); i++){\n    sqlite3FuncDefInsert(pHash, &aFunc[i]);\n  }\n  sqlite3RegisterDateTimeFunctions();\n#ifndef SQLITE_OMIT_ALTERTABLE\n  sqlite3AlterFunctions();\n#endif\n}\n\n/************** End of func.c ************************************************/\n/************** Begin file fkey.c ********************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used by the compiler to add foreign key\n** support to compiled SQL statements.\n*/\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n\n/*\n** Deferred and Immediate FKs\n** --------------------------\n**\n** Foreign keys in SQLite come in two flavours: deferred and immediate.\n** If an immediate foreign key constraint is violated,\n** SQLITE_CONSTRAINT_FOREIGNKEY is returned and the current\n** statement transaction rolled back. If a \n** deferred foreign key constraint is violated, no action is taken \n** immediately. However if the application attempts to commit the \n** transaction before fixing the constraint violation, the attempt fails.\n**\n** Deferred constraints are implemented using a simple counter associated\n** with the database handle. The counter is set to zero each time a \n** database transaction is opened. Each time a statement is executed \n** that causes a foreign key violation, the counter is incremented. Each\n** time a statement is executed that removes an existing violation from\n** the database, the counter is decremented. When the transaction is\n** committed, the commit fails if the current value of the counter is\n** greater than zero. This scheme has two big drawbacks:\n**\n**   * When a commit fails due to a deferred foreign key constraint, \n**     there is no way to tell which foreign constraint is not satisfied,\n**     or which row it is not satisfied for.\n**\n**   * If the database contains foreign key violations when the \n**     transaction is opened, this may cause the mechanism to malfunction.\n**\n** Despite these problems, this approach is adopted as it seems simpler\n** than the alternatives.\n**\n** INSERT operations:\n**\n**   I.1) For each FK for which the table is the child table, search\n**        the parent table for a match. If none is found increment the\n**        constraint counter.\n**\n**   I.2) For each FK for which the table is the parent table, \n**        search the child table for rows that correspond to the new\n**        row in the parent table. Decrement the counter for each row\n**        found (as the constraint is now satisfied).\n**\n** DELETE operations:\n**\n**   D.1) For each FK for which the table is the child table, \n**        search the parent table for a row that corresponds to the \n**        deleted row in the child table. If such a row is not found, \n**        decrement the counter.\n**\n**   D.2) For each FK for which the table is the parent table, search \n**        the child table for rows that correspond to the deleted row \n**        in the parent table. For each found increment the counter.\n**\n** UPDATE operations:\n**\n**   An UPDATE command requires that all 4 steps above are taken, but only\n**   for FK constraints for which the affected columns are actually \n**   modified (values must be compared at runtime).\n**\n** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.\n** This simplifies the implementation a bit.\n**\n** For the purposes of immediate FK constraints, the OR REPLACE conflict\n** resolution is considered to delete rows before the new row is inserted.\n** If a delete caused by OR REPLACE violates an FK constraint, an exception\n** is thrown, even if the FK constraint would be satisfied after the new \n** row is inserted.\n**\n** Immediate constraints are usually handled similarly. The only difference \n** is that the counter used is stored as part of each individual statement\n** object (struct Vdbe). If, after the statement has run, its immediate\n** constraint counter is greater than zero,\n** it returns SQLITE_CONSTRAINT_FOREIGNKEY\n** and the statement transaction is rolled back. An exception is an INSERT\n** statement that inserts a single row only (no triggers). In this case,\n** instead of using a counter, an exception is thrown immediately if the\n** INSERT violates a foreign key constraint. This is necessary as such\n** an INSERT does not open a statement transaction.\n**\n** TODO: How should dropping a table be handled? How should renaming a \n** table be handled?\n**\n**\n** Query API Notes\n** ---------------\n**\n** Before coding an UPDATE or DELETE row operation, the code-generator\n** for those two operations needs to know whether or not the operation\n** requires any FK processing and, if so, which columns of the original\n** row are required by the FK processing VDBE code (i.e. if FKs were\n** implemented using triggers, which of the old.* columns would be \n** accessed). No information is required by the code-generator before\n** coding an INSERT operation. The functions used by the UPDATE/DELETE\n** generation code to query for this information are:\n**\n**   sqlite3FkRequired() - Test to see if FK processing is required.\n**   sqlite3FkOldmask()  - Query for the set of required old.* columns.\n**\n**\n** Externally accessible module functions\n** --------------------------------------\n**\n**   sqlite3FkCheck()    - Check for foreign key violations.\n**   sqlite3FkActions()  - Code triggers for ON UPDATE/ON DELETE actions.\n**   sqlite3FkDelete()   - Delete an FKey structure.\n*/\n\n/*\n** VDBE Calling Convention\n** -----------------------\n**\n** Example:\n**\n**   For the following INSERT statement:\n**\n**     CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);\n**     INSERT INTO t1 VALUES(1, 2, 3.1);\n**\n**   Register (x):        2    (type integer)\n**   Register (x+1):      1    (type integer)\n**   Register (x+2):      NULL (type NULL)\n**   Register (x+3):      3.1  (type real)\n*/\n\n/*\n** A foreign key constraint requires that the key columns in the parent\n** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.\n** Given that pParent is the parent table for foreign key constraint pFKey, \n** search the schema for a unique index on the parent key columns. \n**\n** If successful, zero is returned. If the parent key is an INTEGER PRIMARY \n** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx \n** is set to point to the unique index. \n** \n** If the parent key consists of a single column (the foreign key constraint\n** is not a composite foreign key), output variable *paiCol is set to NULL.\n** Otherwise, it is set to point to an allocated array of size N, where\n** N is the number of columns in the parent key. The first element of the\n** array is the index of the child table column that is mapped by the FK\n** constraint to the parent table column stored in the left-most column\n** of index *ppIdx. The second element of the array is the index of the\n** child table column that corresponds to the second left-most column of\n** *ppIdx, and so on.\n**\n** If the required index cannot be found, either because:\n**\n**   1) The named parent key columns do not exist, or\n**\n**   2) The named parent key columns do exist, but are not subject to a\n**      UNIQUE or PRIMARY KEY constraint, or\n**\n**   3) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the parent table does not have a\n**      PRIMARY KEY, or\n**\n**   4) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the PRIMARY KEY of the parent table \n**      consists of a a different number of columns to the child key in \n**      the child table.\n**\n** then non-zero is returned, and a \"foreign key mismatch\" error loaded\n** into pParse. If an OOM error occurs, non-zero is returned and the\n** pParse->db->mallocFailed flag is set.\n*/\nSQLITE_PRIVATE int sqlite3FkLocateIndex(\n  Parse *pParse,                  /* Parse context to store any error in */\n  Table *pParent,                 /* Parent table of FK constraint pFKey */\n  FKey *pFKey,                    /* Foreign key to find index for */\n  Index **ppIdx,                  /* OUT: Unique index on parent table */\n  int **paiCol                    /* OUT: Map of index columns in pFKey */\n){\n  Index *pIdx = 0;                    /* Value to return via *ppIdx */\n  int *aiCol = 0;                     /* Value to return via *paiCol */\n  int nCol = pFKey->nCol;             /* Number of columns in parent key */\n  char *zKey = pFKey->aCol[0].zCol;   /* Name of left-most parent key column */\n\n  /* The caller is responsible for zeroing output parameters. */\n  assert( ppIdx && *ppIdx==0 );\n  assert( !paiCol || *paiCol==0 );\n  assert( pParse );\n\n  /* If this is a non-composite (single column) foreign key, check if it \n  ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx \n  ** and *paiCol set to zero and return early. \n  **\n  ** Otherwise, for a composite foreign key (more than one column), allocate\n  ** space for the aiCol array (returned via output parameter *paiCol).\n  ** Non-composite foreign keys do not require the aiCol array.\n  */\n  if( nCol==1 ){\n    /* The FK maps to the IPK if any of the following are true:\n    **\n    **   1) There is an INTEGER PRIMARY KEY column and the FK is implicitly \n    **      mapped to the primary key of table pParent, or\n    **   2) The FK is explicitly mapped to a column declared as INTEGER\n    **      PRIMARY KEY.\n    */\n    if( pParent->iPKey>=0 ){\n      if( !zKey ) return 0;\n      if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;\n    }\n  }else if( paiCol ){\n    assert( nCol>1 );\n    aiCol = (int *)sqlite3DbMallocRaw(pParse->db, nCol*sizeof(int));\n    if( !aiCol ) return 1;\n    *paiCol = aiCol;\n  }\n\n  for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->nColumn==nCol && pIdx->onError!=OE_None ){ \n      /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number\n      ** of columns. If each indexed column corresponds to a foreign key\n      ** column of pFKey, then this index is a winner.  */\n\n      if( zKey==0 ){\n        /* If zKey is NULL, then this foreign key is implicitly mapped to \n        ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be \n        ** identified by the test (Index.autoIndex==2).  */\n        if( pIdx->autoIndex==2 ){\n          if( aiCol ){\n            int i;\n            for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;\n          }\n          break;\n        }\n      }else{\n        /* If zKey is non-NULL, then this foreign key was declared to\n        ** map to an explicit list of columns in table pParent. Check if this\n        ** index matches those columns. Also, check that the index uses\n        ** the default collation sequences for each column. */\n        int i, j;\n        for(i=0; i<nCol; i++){\n          int iCol = pIdx->aiColumn[i];     /* Index of column in parent tbl */\n          char *zDfltColl;                  /* Def. collation for column */\n          char *zIdxCol;                    /* Name of indexed column */\n\n          /* If the index uses a collation sequence that is different from\n          ** the default collation sequence for the column, this index is\n          ** unusable. Bail out early in this case.  */\n          zDfltColl = pParent->aCol[iCol].zColl;\n          if( !zDfltColl ){\n            zDfltColl = \"BINARY\";\n          }\n          if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;\n\n          zIdxCol = pParent->aCol[iCol].zName;\n          for(j=0; j<nCol; j++){\n            if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){\n              if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;\n              break;\n            }\n          }\n          if( j==nCol ) break;\n        }\n        if( i==nCol ) break;      /* pIdx is usable */\n      }\n    }\n  }\n\n  if( !pIdx ){\n    if( !pParse->disableTriggers ){\n      sqlite3ErrorMsg(pParse,\n           \"foreign key mismatch - \\\"%w\\\" referencing \\\"%w\\\"\",\n           pFKey->pFrom->zName, pFKey->zTo);\n    }\n    sqlite3DbFree(pParse->db, aiCol);\n    return 1;\n  }\n\n  *ppIdx = pIdx;\n  return 0;\n}\n\n/*\n** This function is called when a row is inserted into or deleted from the \n** child table of foreign key constraint pFKey. If an SQL UPDATE is executed \n** on the child table of pFKey, this function is invoked twice for each row\n** affected - once to \"delete\" the old row, and then again to \"insert\" the\n** new row.\n**\n** Each time it is called, this function generates VDBE code to locate the\n** row in the parent table that corresponds to the row being inserted into \n** or deleted from the child table. If the parent row can be found, no \n** special action is taken. Otherwise, if the parent row can *not* be\n** found in the parent table:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   INSERT      immediate   Increment the \"immediate constraint counter\".\n**\n**   DELETE      immediate   Decrement the \"immediate constraint counter\".\n**\n**   INSERT      deferred    Increment the \"deferred constraint counter\".\n**\n**   DELETE      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.1\" and \"D.1\".\n*/\nstatic void fkLookupParent(\n  Parse *pParse,        /* Parse context */\n  int iDb,              /* Index of database housing pTab */\n  Table *pTab,          /* Parent table of FK pFKey */\n  Index *pIdx,          /* Unique index on parent key columns in pTab */\n  FKey *pFKey,          /* Foreign key constraint */\n  int *aiCol,           /* Map from parent key columns to child table columns */\n  int regData,          /* Address of array containing child table row */\n  int nIncr,            /* Increment constraint counter by this */\n  int isIgnore          /* If true, pretend pTab contains all NULL values */\n){\n  int i;                                    /* Iterator variable */\n  Vdbe *v = sqlite3GetVdbe(pParse);         /* Vdbe to add code to */\n  int iCur = pParse->nTab - 1;              /* Cursor number to use */\n  int iOk = sqlite3VdbeMakeLabel(v);        /* jump here if parent key found */\n\n  /* If nIncr is less than zero, then check at runtime if there are any\n  ** outstanding constraints to resolve. If there are not, there is no need\n  ** to check if deleting this row resolves any outstanding violations.\n  **\n  ** Check if any of the key columns in the child table row are NULL. If \n  ** any are, then the constraint is considered satisfied. No need to \n  ** search for a matching row in the parent table.  */\n  if( nIncr<0 ){\n    sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);\n  }\n  for(i=0; i<pFKey->nCol; i++){\n    int iReg = aiCol[i] + regData + 1;\n    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk);\n  }\n\n  if( isIgnore==0 ){\n    if( pIdx==0 ){\n      /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY\n      ** column of the parent table (table pTab).  */\n      int iMustBeInt;               /* Address of MustBeInt instruction */\n      int regTemp = sqlite3GetTempReg(pParse);\n  \n      /* Invoke MustBeInt to coerce the child key value to an integer (i.e. \n      ** apply the affinity of the parent key). If this fails, then there\n      ** is no matching parent key. Before using MustBeInt, make a copy of\n      ** the value. Otherwise, the value inserted into the child key column\n      ** will have INTEGER affinity applied to it, which may not be correct.  */\n      sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);\n      iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter.  */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp);\n      }\n  \n      sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp);\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);\n      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      sqlite3VdbeJumpHere(v, iMustBeInt);\n      sqlite3ReleaseTempReg(pParse, regTemp);\n    }else{\n      int nCol = pFKey->nCol;\n      int regTemp = sqlite3GetTempRange(pParse, nCol);\n      int regRec = sqlite3GetTempReg(pParse);\n      KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);\n  \n      sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);\n      sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF);\n      for(i=0; i<nCol; i++){\n        sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);\n      }\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter. \n      **\n      ** If any of the parent-key values are NULL, then the row cannot match \n      ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any\n      ** of the parent-key values are NULL (at this point it is known that\n      ** none of the child key values are).\n      */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;\n        for(i=0; i<nCol; i++){\n          int iChild = aiCol[i]+1+regData;\n          int iParent = pIdx->aiColumn[i]+1+regData;\n          assert( aiCol[i]!=pTab->iPKey );\n          if( pIdx->aiColumn[i]==pTab->iPKey ){\n            /* The parent key is a composite key that includes the IPK column */\n            iParent = regData;\n          }\n          sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent);\n          sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);\n        }\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk);\n      }\n  \n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regTemp, nCol, regRec);\n      sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);\n      sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0);\n  \n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempRange(pParse, regTemp, nCol);\n    }\n  }\n\n  if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){\n    /* Special case: If this is an INSERT statement that will insert exactly\n    ** one row into the table, raise a constraint immediately instead of\n    ** incrementing a counter. This is necessary as the VM code is being\n    ** generated for will not open a statement transaction.  */\n    assert( nIncr==1 );\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n        OE_Abort, \"foreign key constraint failed\", P4_STATIC\n    );\n  }else{\n    if( nIncr>0 && pFKey->isDeferred==0 ){\n      sqlite3ParseToplevel(pParse)->mayAbort = 1;\n    }\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n  }\n\n  sqlite3VdbeResolveLabel(v, iOk);\n  sqlite3VdbeAddOp1(v, OP_Close, iCur);\n}\n\n/*\n** This function is called to generate code executed when a row is deleted\n** from the parent table of foreign key constraint pFKey and, if pFKey is \n** deferred, when a row is inserted into the same table. When generating\n** code for an SQL UPDATE operation, this function may be called twice -\n** once to \"delete\" the old row and once to \"insert\" the new row.\n**\n** The code generated by this function scans through the rows in the child\n** table that correspond to the parent table row being deleted or inserted.\n** For each child row found, one of the following actions is taken:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   DELETE      immediate   Increment the \"immediate constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"foreign key constraint failed\" exception.\n**\n**   INSERT      immediate   Decrement the \"immediate constraint counter\".\n**\n**   DELETE      deferred    Increment the \"deferred constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"foreign key constraint failed\" exception.\n**\n**   INSERT      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.2\" and \"D.2\".\n*/\nstatic void fkScanChildren(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pSrc,                  /* SrcList containing the table to scan */\n  Table *pTab,\n  Index *pIdx,                    /* Foreign key index */\n  FKey *pFKey,                    /* Foreign key relationship */\n  int *aiCol,                     /* Map from pIdx cols to child table cols */\n  int regData,                    /* Referenced table data starts here */\n  int nIncr                       /* Amount to increment deferred counter by */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int i;                          /* Iterator variable */\n  Expr *pWhere = 0;               /* WHERE clause to scan with */\n  NameContext sNameContext;       /* Context used to resolve WHERE clause */\n  WhereInfo *pWInfo;              /* Context used by sqlite3WhereXXX() */\n  int iFkIfZero = 0;              /* Address of OP_FkIfZero */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n\n  assert( !pIdx || pIdx->pTable==pTab );\n\n  if( nIncr<0 ){\n    iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);\n  }\n\n  /* Create an Expr object representing an SQL expression like:\n  **\n  **   <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...\n  **\n  ** The collation sequence used for the comparison should be that of\n  ** the parent key columns. The affinity of the parent key column should\n  ** be applied to each child key value before the comparison takes place.\n  */\n  for(i=0; i<pFKey->nCol; i++){\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    Expr *pEq;                    /* Expression (pLeft = pRight) */\n    int iCol;                     /* Index of column in child table */ \n    const char *zCol;             /* Name of column in child table */\n\n    pLeft = sqlite3Expr(db, TK_REGISTER, 0);\n    if( pLeft ){\n      /* Set the collation sequence and affinity of the LHS of each TK_EQ\n      ** expression to the parent key column defaults.  */\n      if( pIdx ){\n        Column *pCol;\n        const char *zColl;\n        iCol = pIdx->aiColumn[i];\n        pCol = &pTab->aCol[iCol];\n        if( pTab->iPKey==iCol ) iCol = -1;\n        pLeft->iTable = regData+iCol+1;\n        pLeft->affinity = pCol->affinity;\n        zColl = pCol->zColl;\n        if( zColl==0 ) zColl = db->pDfltColl->zName;\n        pLeft = sqlite3ExprAddCollateString(pParse, pLeft, zColl);\n      }else{\n        pLeft->iTable = regData;\n        pLeft->affinity = SQLITE_AFF_INTEGER;\n      }\n    }\n    iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n    assert( iCol>=0 );\n    zCol = pFKey->pFrom->aCol[iCol].zName;\n    pRight = sqlite3Expr(db, TK_ID, zCol);\n    pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0);\n    pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n  }\n\n  /* If the child table is the same as the parent table, and this scan\n  ** is taking place as part of a DELETE operation (operation D.2), omit the\n  ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE \n  ** clause, where $rowid is the rowid of the row being deleted.  */\n  if( pTab==pFKey->pFrom && nIncr>0 ){\n    Expr *pEq;                    /* Expression (pLeft = pRight) */\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    pLeft = sqlite3Expr(db, TK_REGISTER, 0);\n    pRight = sqlite3Expr(db, TK_COLUMN, 0);\n    if( pLeft && pRight ){\n      pLeft->iTable = regData;\n      pLeft->affinity = SQLITE_AFF_INTEGER;\n      pRight->iTable = pSrc->a[0].iCursor;\n      pRight->iColumn = -1;\n    }\n    pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0);\n    pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n  }\n\n  /* Resolve the references in the WHERE clause. */\n  memset(&sNameContext, 0, sizeof(NameContext));\n  sNameContext.pSrcList = pSrc;\n  sNameContext.pParse = pParse;\n  sqlite3ResolveExprNames(&sNameContext, pWhere);\n\n  /* Create VDBE to loop through the entries in pSrc that match the WHERE\n  ** clause. If the constraint is not deferred, throw an exception for\n  ** each row found. Otherwise, for deferred constraints, increment the\n  ** deferred constraint counter by nIncr for each row selected.  */\n  pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);\n  if( nIncr>0 && pFKey->isDeferred==0 ){\n    sqlite3ParseToplevel(pParse)->mayAbort = 1;\n  }\n  sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n  if( pWInfo ){\n    sqlite3WhereEnd(pWInfo);\n  }\n\n  /* Clean up the WHERE clause constructed above. */\n  sqlite3ExprDelete(db, pWhere);\n  if( iFkIfZero ){\n    sqlite3VdbeJumpHere(v, iFkIfZero);\n  }\n}\n\n/*\n** This function returns a pointer to the head of a linked list of FK\n** constraints for which table pTab is the parent table. For example,\n** given the following schema:\n**\n**   CREATE TABLE t1(a PRIMARY KEY);\n**   CREATE TABLE t2(b REFERENCES t1(a);\n**\n** Calling this function with table \"t1\" as an argument returns a pointer\n** to the FKey structure representing the foreign key constraint on table\n** \"t2\". Calling this function with \"t2\" as the argument would return a\n** NULL pointer (as there are no FK constraints for which t2 is the parent\n** table).\n*/\nSQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){\n  int nName = sqlite3Strlen30(pTab->zName);\n  return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName, nName);\n}\n\n/*\n** The second argument is a Trigger structure allocated by the \n** fkActionTrigger() routine. This function deletes the Trigger structure\n** and all of its sub-components.\n**\n** The Trigger structure or any of its sub-components may be allocated from\n** the lookaside buffer belonging to database handle dbMem.\n*/\nstatic void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){\n  if( p ){\n    TriggerStep *pStep = p->step_list;\n    sqlite3ExprDelete(dbMem, pStep->pWhere);\n    sqlite3ExprListDelete(dbMem, pStep->pExprList);\n    sqlite3SelectDelete(dbMem, pStep->pSelect);\n    sqlite3ExprDelete(dbMem, p->pWhen);\n    sqlite3DbFree(dbMem, p);\n  }\n}\n\n/*\n** This function is called to generate code that runs when table pTab is\n** being dropped from the database. The SrcList passed as the second argument\n** to this function contains a single entry guaranteed to resolve to\n** table pTab.\n**\n** Normally, no code is required. However, if either\n**\n**   (a) The table is the parent table of a FK constraint, or\n**   (b) The table is the child table of a deferred FK constraint and it is\n**       determined at runtime that there are outstanding deferred FK \n**       constraint violations in the database,\n**\n** then the equivalent of \"DELETE FROM <tbl>\" is executed before dropping\n** the table from the database. Triggers are disabled while running this\n** DELETE, but foreign key actions are not.\n*/\nSQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){\n  sqlite3 *db = pParse->db;\n  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){\n    int iSkip = 0;\n    Vdbe *v = sqlite3GetVdbe(pParse);\n\n    assert( v );                  /* VDBE has already been allocated */\n    if( sqlite3FkReferences(pTab)==0 ){\n      /* Search for a deferred foreign key constraint for which this table\n      ** is the child table. If one cannot be found, return without \n      ** generating any VDBE code. If one can be found, then jump over\n      ** the entire DELETE if there are no outstanding deferred constraints\n      ** when this statement is run.  */\n      FKey *p;\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( p->isDeferred ) break;\n      }\n      if( !p ) return;\n      iSkip = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);\n    }\n\n    pParse->disableTriggers = 1;\n    sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);\n    pParse->disableTriggers = 0;\n\n    /* If the DELETE has generated immediate foreign key constraint \n    ** violations, halt the VDBE and return an error at this point, before\n    ** any modifications to the schema are made. This is because statement\n    ** transactions are not able to rollback schema changes.  */\n    sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n        OE_Abort, \"foreign key constraint failed\", P4_STATIC\n    );\n\n    if( iSkip ){\n      sqlite3VdbeResolveLabel(v, iSkip);\n    }\n  }\n}\n\n/*\n** This function is called when inserting, deleting or updating a row of\n** table pTab to generate VDBE code to perform foreign key constraint \n** processing for the operation.\n**\n** For a DELETE operation, parameter regOld is passed the index of the\n** first register in an array of (pTab->nCol+1) registers containing the\n** rowid of the row being deleted, followed by each of the column values\n** of the row being deleted, from left to right. Parameter regNew is passed\n** zero in this case.\n**\n** For an INSERT operation, regOld is passed zero and regNew is passed the\n** first register of an array of (pTab->nCol+1) registers containing the new\n** row data.\n**\n** For an UPDATE operation, this function is called twice. Once before\n** the original record is deleted from the table using the calling convention\n** described for DELETE. Then again after the original record is deleted\n** but before the new record is inserted using the INSERT convention. \n*/\nSQLITE_PRIVATE void sqlite3FkCheck(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Row is being deleted from this table */ \n  int regOld,                     /* Previous row data is stored here */\n  int regNew                      /* New row data is stored here */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  FKey *pFKey;                    /* Used to iterate through FKs */\n  int iDb;                        /* Index of database containing pTab */\n  const char *zDb;                /* Name of database containing pTab */\n  int isIgnoreErrors = pParse->disableTriggers;\n\n  /* Exactly one of regOld and regNew should be non-zero. */\n  assert( (regOld==0)!=(regNew==0) );\n\n  /* If foreign-keys are disabled, this function is a no-op. */\n  if( (db->flags&SQLITE_ForeignKeys)==0 ) return;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  zDb = db->aDb[iDb].zName;\n\n  /* Loop through all the foreign key constraints for which pTab is the\n  ** child table (the table that the foreign key definition is part of).  */\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n    Table *pTo;                   /* Parent table of foreign key pFKey */\n    Index *pIdx = 0;              /* Index on key columns in pTo */\n    int *aiFree = 0;\n    int *aiCol;\n    int iCol;\n    int i;\n    int isIgnore = 0;\n\n    /* Find the parent table of this foreign key. Also find a unique index \n    ** on the parent key columns in the parent table. If either of these \n    ** schema items cannot be located, set an error in pParse and return \n    ** early.  */\n    if( pParse->disableTriggers ){\n      pTo = sqlite3FindTable(db, pFKey->zTo, zDb);\n    }else{\n      pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);\n    }\n    if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){\n      assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      if( pTo==0 ){\n        /* If isIgnoreErrors is true, then a table is being dropped. In this\n        ** case SQLite runs a \"DELETE FROM xxx\" on the table being dropped\n        ** before actually dropping it in order to check FK constraints.\n        ** If the parent table of an FK constraint on the current table is\n        ** missing, behave as if it is empty. i.e. decrement the relevant\n        ** FK counter for each row of the current table with non-NULL keys.\n        */\n        Vdbe *v = sqlite3GetVdbe(pParse);\n        int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;\n        for(i=0; i<pFKey->nCol; i++){\n          int iReg = pFKey->aCol[i].iFrom + regOld + 1;\n          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump);\n        }\n        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);\n      }\n      continue;\n    }\n    assert( pFKey->nCol==1 || (aiFree && pIdx) );\n\n    if( aiFree ){\n      aiCol = aiFree;\n    }else{\n      iCol = pFKey->aCol[0].iFrom;\n      aiCol = &iCol;\n    }\n    for(i=0; i<pFKey->nCol; i++){\n      if( aiCol[i]==pTab->iPKey ){\n        aiCol[i] = -1;\n      }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      /* Request permission to read the parent key columns. If the \n      ** authorization callback returns SQLITE_IGNORE, behave as if any\n      ** values read from the parent table are NULL. */\n      if( db->xAuth ){\n        int rcauth;\n        char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;\n        rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);\n        isIgnore = (rcauth==SQLITE_IGNORE);\n      }\n#endif\n    }\n\n    /* Take a shared-cache advisory read-lock on the parent table. Allocate \n    ** a cursor to use to search the unique index on the parent key columns \n    ** in the parent table.  */\n    sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);\n    pParse->nTab++;\n\n    if( regOld!=0 ){\n      /* A row is being removed from the child table. Search for the parent.\n      ** If the parent does not exist, removing the child row resolves an \n      ** outstanding foreign key constraint violation. */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);\n    }\n    if( regNew!=0 ){\n      /* A row is being added to the child table. If a parent row cannot\n      ** be found, adding the child row has violated the FK constraint. */ \n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);\n    }\n\n    sqlite3DbFree(db, aiFree);\n  }\n\n  /* Loop through all the foreign key constraints that refer to this table */\n  for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n    Index *pIdx = 0;              /* Foreign key index for pFKey */\n    SrcList *pSrc;\n    int *aiCol = 0;\n\n    if( !pFKey->isDeferred && !pParse->pToplevel && !pParse->isMultiWrite ){\n      assert( regOld==0 && regNew!=0 );\n      /* Inserting a single row into a parent table cannot cause an immediate\n      ** foreign key violation. So do nothing in this case.  */\n      continue;\n    }\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      continue;\n    }\n    assert( aiCol || pFKey->nCol==1 );\n\n    /* Create a SrcList structure containing a single table (the table \n    ** the foreign key that refers to this table is attached to). This\n    ** is required for the sqlite3WhereXXX() interface.  */\n    pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n    if( pSrc ){\n      struct SrcList_item *pItem = pSrc->a;\n      pItem->pTab = pFKey->pFrom;\n      pItem->zName = pFKey->pFrom->zName;\n      pItem->pTab->nRef++;\n      pItem->iCursor = pParse->nTab++;\n  \n      if( regNew!=0 ){\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);\n      }\n      if( regOld!=0 ){\n        /* If there is a RESTRICT action configured for the current operation\n        ** on the parent table of this FK, then throw an exception \n        ** immediately if the FK constraint is violated, even if this is a\n        ** deferred trigger. That's what RESTRICT means. To defer checking\n        ** the constraint, the FK should specify NO ACTION (represented\n        ** using OE_None). NO ACTION is the default.  */\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);\n      }\n      pItem->zName = 0;\n      sqlite3SrcListDelete(db, pSrc);\n    }\n    sqlite3DbFree(db, aiCol);\n  }\n}\n\n#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab.\n*/\nSQLITE_PRIVATE u32 sqlite3FkOldmask(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab                     /* Table being modified */\n){\n  u32 mask = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    int i;\n    for(p=pTab->pFKey; p; p=p->pNextFrom){\n      for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);\n    }\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Index *pIdx = 0;\n      sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);\n      if( pIdx ){\n        for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]);\n      }\n    }\n  }\n  return mask;\n}\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab. If the operation is a DELETE, then\n** parameter aChange is passed a NULL value. For an UPDATE, aChange points\n** to an array of size N, where N is the number of columns in table pTab.\n** If the i'th column is not modified by the UPDATE, then the corresponding \n** entry in the aChange[] array is set to -1. If the column is modified,\n** the value is 0 or greater. Parameter chngRowid is set to true if the\n** UPDATE statement modifies the rowid fields of the table.\n**\n** If any foreign key processing will be required, this function returns\n** true. If there is no foreign key related processing, this function \n** returns false.\n*/\nSQLITE_PRIVATE int sqlite3FkRequired(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being modified */\n  int *aChange,                   /* Non-NULL for UPDATE operations */\n  int chngRowid                   /* True for UPDATE that affects rowid */\n){\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    if( !aChange ){\n      /* A DELETE operation. Foreign key processing is required if the \n      ** table in question is either the child or parent table for any \n      ** foreign key constraint.  */\n      return (sqlite3FkReferences(pTab) || pTab->pFKey);\n    }else{\n      /* This is an UPDATE. Foreign key processing is only required if the\n      ** operation modifies one or more child or parent key columns. */\n      int i;\n      FKey *p;\n\n      /* Check if any child key columns are being modified. */\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        for(i=0; i<p->nCol; i++){\n          int iChildKey = p->aCol[i].iFrom;\n          if( aChange[iChildKey]>=0 ) return 1;\n          if( iChildKey==pTab->iPKey && chngRowid ) return 1;\n        }\n      }\n\n      /* Check if any parent key columns are being modified. */\n      for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n        for(i=0; i<p->nCol; i++){\n          char *zKey = p->aCol[i].zCol;\n          int iKey;\n          for(iKey=0; iKey<pTab->nCol; iKey++){\n            Column *pCol = &pTab->aCol[iKey];\n            if( (zKey ? !sqlite3StrICmp(pCol->zName, zKey)\n                      : (pCol->colFlags & COLFLAG_PRIMKEY)!=0) ){\n              if( aChange[iKey]>=0 ) return 1;\n              if( iKey==pTab->iPKey && chngRowid ) return 1;\n            }\n          }\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is called when an UPDATE or DELETE operation is being \n** compiled on table pTab, which is the parent table of foreign-key pFKey.\n** If the current operation is an UPDATE, then the pChanges parameter is\n** passed a pointer to the list of columns being modified. If it is a\n** DELETE, pChanges is passed a NULL pointer.\n**\n** It returns a pointer to a Trigger structure containing a trigger\n** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.\n** If the action is \"NO ACTION\" or \"RESTRICT\", then a NULL pointer is\n** returned (these actions require no special handling by the triggers\n** sub-system, code for them is created by fkScanChildren()).\n**\n** For example, if pFKey is the foreign key and pTab is table \"p\" in \n** the following schema:\n**\n**   CREATE TABLE p(pk PRIMARY KEY);\n**   CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);\n**\n** then the returned trigger structure is equivalent to:\n**\n**   CREATE TRIGGER ... DELETE ON p BEGIN\n**     DELETE FROM c WHERE ck = old.pk;\n**   END;\n**\n** The returned pointer is cached as part of the foreign key object. It\n** is eventually freed along with the rest of the foreign key object by \n** sqlite3FkDelete().\n*/\nstatic Trigger *fkActionTrigger(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  FKey *pFKey,                    /* Foreign key to get action for */\n  ExprList *pChanges              /* Change-list for UPDATE, NULL for DELETE */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int action;                     /* One of OE_None, OE_Cascade etc. */\n  Trigger *pTrigger;              /* Trigger definition to return */\n  int iAction = (pChanges!=0);    /* 1 for UPDATE, 0 for DELETE */\n\n  action = pFKey->aAction[iAction];\n  pTrigger = pFKey->apTrigger[iAction];\n\n  if( action!=OE_None && !pTrigger ){\n    u8 enableLookaside;           /* Copy of db->lookaside.bEnabled */\n    char const *zFrom;            /* Name of child table */\n    int nFrom;                    /* Length in bytes of zFrom */\n    Index *pIdx = 0;              /* Parent key index for this FK */\n    int *aiCol = 0;               /* child table cols -> parent key cols */\n    TriggerStep *pStep = 0;        /* First (only) step of trigger program */\n    Expr *pWhere = 0;             /* WHERE clause of trigger step */\n    ExprList *pList = 0;          /* Changes list if ON UPDATE CASCADE */\n    Select *pSelect = 0;          /* If RESTRICT, \"SELECT RAISE(...)\" */\n    int i;                        /* Iterator variable */\n    Expr *pWhen = 0;              /* WHEN clause for the trigger */\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;\n    assert( aiCol || pFKey->nCol==1 );\n\n    for(i=0; i<pFKey->nCol; i++){\n      Token tOld = { \"old\", 3 };  /* Literal \"old\" token */\n      Token tNew = { \"new\", 3 };  /* Literal \"new\" token */\n      Token tFromCol;             /* Name of column in child table */\n      Token tToCol;               /* Name of column in parent table */\n      int iFromCol;               /* Idx of column in child table */\n      Expr *pEq;                  /* tFromCol = OLD.tToCol */\n\n      iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n      assert( iFromCol>=0 );\n      tToCol.z = pIdx ? pTab->aCol[pIdx->aiColumn[i]].zName : \"oid\";\n      tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;\n\n      tToCol.n = sqlite3Strlen30(tToCol.z);\n      tFromCol.n = sqlite3Strlen30(tFromCol.z);\n\n      /* Create the expression \"OLD.zToCol = zFromCol\". It is important\n      ** that the \"OLD.zToCol\" term is on the LHS of the = operator, so\n      ** that the affinity and collation sequence associated with the\n      ** parent table are used for the comparison. */\n      pEq = sqlite3PExpr(pParse, TK_EQ,\n          sqlite3PExpr(pParse, TK_DOT, \n            sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),\n            sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)\n          , 0),\n          sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)\n      , 0);\n      pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n\n      /* For ON UPDATE, construct the next term of the WHEN clause.\n      ** The final WHEN clause will be like this:\n      **\n      **    WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)\n      */\n      if( pChanges ){\n        pEq = sqlite3PExpr(pParse, TK_IS,\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),\n              sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),\n              0),\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),\n              sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),\n              0),\n            0);\n        pWhen = sqlite3ExprAnd(db, pWhen, pEq);\n      }\n  \n      if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){\n        Expr *pNew;\n        if( action==OE_Cascade ){\n          pNew = sqlite3PExpr(pParse, TK_DOT, \n            sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),\n            sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)\n          , 0);\n        }else if( action==OE_SetDflt ){\n          Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;\n          if( pDflt ){\n            pNew = sqlite3ExprDup(db, pDflt, 0);\n          }else{\n            pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);\n          }\n        }else{\n          pNew = sqlite3PExpr(pParse, TK_NULL, 0, 0, 0);\n        }\n        pList = sqlite3ExprListAppend(pParse, pList, pNew);\n        sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);\n      }\n    }\n    sqlite3DbFree(db, aiCol);\n\n    zFrom = pFKey->pFrom->zName;\n    nFrom = sqlite3Strlen30(zFrom);\n\n    if( action==OE_Restrict ){\n      Token tFrom;\n      Expr *pRaise; \n\n      tFrom.z = zFrom;\n      tFrom.n = nFrom;\n      pRaise = sqlite3Expr(db, TK_RAISE, \"foreign key constraint failed\");\n      if( pRaise ){\n        pRaise->affinity = OE_Abort;\n      }\n      pSelect = sqlite3SelectNew(pParse, \n          sqlite3ExprListAppend(pParse, 0, pRaise),\n          sqlite3SrcListAppend(db, 0, &tFrom, 0),\n          pWhere,\n          0, 0, 0, 0, 0, 0\n      );\n      pWhere = 0;\n    }\n\n    /* Disable lookaside memory allocation */\n    enableLookaside = db->lookaside.bEnabled;\n    db->lookaside.bEnabled = 0;\n\n    pTrigger = (Trigger *)sqlite3DbMallocZero(db, \n        sizeof(Trigger) +         /* struct Trigger */\n        sizeof(TriggerStep) +     /* Single step in trigger program */\n        nFrom + 1                 /* Space for pStep->target.z */\n    );\n    if( pTrigger ){\n      pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];\n      pStep->target.z = (char *)&pStep[1];\n      pStep->target.n = nFrom;\n      memcpy((char *)pStep->target.z, zFrom, nFrom);\n  \n      pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n      pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);\n      pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n      if( pWhen ){\n        pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0, 0);\n        pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n      }\n    }\n\n    /* Re-enable the lookaside buffer, if it was disabled earlier. */\n    db->lookaside.bEnabled = enableLookaside;\n\n    sqlite3ExprDelete(db, pWhere);\n    sqlite3ExprDelete(db, pWhen);\n    sqlite3ExprListDelete(db, pList);\n    sqlite3SelectDelete(db, pSelect);\n    if( db->mallocFailed==1 ){\n      fkTriggerDelete(db, pTrigger);\n      return 0;\n    }\n    assert( pStep!=0 );\n\n    switch( action ){\n      case OE_Restrict:\n        pStep->op = TK_SELECT; \n        break;\n      case OE_Cascade: \n        if( !pChanges ){ \n          pStep->op = TK_DELETE; \n          break; \n        }\n      default:\n        pStep->op = TK_UPDATE;\n    }\n    pStep->pTrig = pTrigger;\n    pTrigger->pSchema = pTab->pSchema;\n    pTrigger->pTabSchema = pTab->pSchema;\n    pFKey->apTrigger[iAction] = pTrigger;\n    pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);\n  }\n\n  return pTrigger;\n}\n\n/*\n** This function is called when deleting or updating a row to implement\n** any required CASCADE, SET NULL or SET DEFAULT actions.\n*/\nSQLITE_PRIVATE void sqlite3FkActions(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  ExprList *pChanges,             /* Change-list for UPDATE, NULL for DELETE */\n  int regOld                      /* Address of array containing old row */\n){\n  /* If foreign-key support is enabled, iterate through all FKs that \n  ** refer to table pTab. If there is an action associated with the FK \n  ** for this operation (either update or delete), invoke the associated \n  ** trigger sub-program.  */\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *pFKey;                  /* Iterator variable */\n    for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n      Trigger *pAction = fkActionTrigger(pParse, pTab, pFKey, pChanges);\n      if( pAction ){\n        sqlite3CodeRowTriggerDirect(pParse, pAction, pTab, regOld, OE_Abort, 0);\n      }\n    }\n  }\n}\n\n#endif /* ifndef SQLITE_OMIT_TRIGGER */\n\n/*\n** Free all memory associated with foreign key definitions attached to\n** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash\n** hash table.\n*/\nSQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){\n  FKey *pFKey;                    /* Iterator variable */\n  FKey *pNext;                    /* Copy of pFKey->pNextFrom */\n\n  assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){\n\n    /* Remove the FK from the fkeyHash hash table. */\n    if( !db || db->pnBytesFreed==0 ){\n      if( pFKey->pPrevTo ){\n        pFKey->pPrevTo->pNextTo = pFKey->pNextTo;\n      }else{\n        void *p = (void *)pFKey->pNextTo;\n        const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo);\n        sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, sqlite3Strlen30(z), p);\n      }\n      if( pFKey->pNextTo ){\n        pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;\n      }\n    }\n\n    /* EV: R-30323-21917 Each foreign key constraint in SQLite is\n    ** classified as either immediate or deferred.\n    */\n    assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );\n\n    /* Delete any triggers created to implement actions for this FK. */\n#ifndef SQLITE_OMIT_TRIGGER\n    fkTriggerDelete(db, pFKey->apTrigger[0]);\n    fkTriggerDelete(db, pFKey->apTrigger[1]);\n#endif\n\n    pNext = pFKey->pNextFrom;\n    sqlite3DbFree(db, pFKey);\n  }\n}\n#endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n/************** End of fkey.c ************************************************/\n/************** Begin file insert.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle INSERT statements in SQLite.\n*/\n\n/*\n** Generate code that will open a table for reading.\n*/\nSQLITE_PRIVATE void sqlite3OpenTable(\n  Parse *p,       /* Generate code into this VDBE */\n  int iCur,       /* The cursor number of the table */\n  int iDb,        /* The database index in sqlite3.aDb[] */\n  Table *pTab,    /* The table to be opened */\n  int opcode      /* OP_OpenRead or OP_OpenWrite */\n){\n  Vdbe *v;\n  assert( !IsVirtual(pTab) );\n  v = sqlite3GetVdbe(p);\n  assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );\n  sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName);\n  sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb);\n  sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32);\n  VdbeComment((v, \"%s\", pTab->zName));\n}\n\n/*\n** Return a pointer to the column affinity string associated with index\n** pIdx. A column affinity string has one character for each column in \n** the table, according to the affinity of the column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'a'            TEXT\n**  'b'            NONE\n**  'c'            NUMERIC\n**  'd'            INTEGER\n**  'e'            REAL\n**\n** An extra 'd' is appended to the end of the string to cover the\n** rowid that appears as the last column in every index.\n**\n** Memory for the buffer containing the column index affinity string\n** is managed along with the rest of the Index structure. It will be\n** released when sqlite3DeleteIndex() is called.\n*/\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){\n  if( !pIdx->zColAff ){\n    /* The first time a column affinity string for a particular index is\n    ** required, it is allocated and populated here. It is then stored as\n    ** a member of the Index structure for subsequent use.\n    **\n    ** The column affinity string will eventually be deleted by\n    ** sqliteDeleteIndex() when the Index structure itself is cleaned\n    ** up.\n    */\n    int n;\n    Table *pTab = pIdx->pTable;\n    sqlite3 *db = sqlite3VdbeDb(v);\n    pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+2);\n    if( !pIdx->zColAff ){\n      db->mallocFailed = 1;\n      return 0;\n    }\n    for(n=0; n<pIdx->nColumn; n++){\n      pIdx->zColAff[n] = pTab->aCol[pIdx->aiColumn[n]].affinity;\n    }\n    pIdx->zColAff[n++] = SQLITE_AFF_INTEGER;\n    pIdx->zColAff[n] = 0;\n  }\n \n  return pIdx->zColAff;\n}\n\n/*\n** Set P4 of the most recently inserted opcode to a column affinity\n** string for table pTab. A column affinity string has one character\n** for each column indexed by the index, according to the affinity of the\n** column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'a'            TEXT\n**  'b'            NONE\n**  'c'            NUMERIC\n**  'd'            INTEGER\n**  'e'            REAL\n*/\nSQLITE_PRIVATE void sqlite3TableAffinityStr(Vdbe *v, Table *pTab){\n  /* The first time a column affinity string for a particular table\n  ** is required, it is allocated and populated here. It is then \n  ** stored as a member of the Table structure for subsequent use.\n  **\n  ** The column affinity string will eventually be deleted by\n  ** sqlite3DeleteTable() when the Table structure itself is cleaned up.\n  */\n  if( !pTab->zColAff ){\n    char *zColAff;\n    int i;\n    sqlite3 *db = sqlite3VdbeDb(v);\n\n    zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);\n    if( !zColAff ){\n      db->mallocFailed = 1;\n      return;\n    }\n\n    for(i=0; i<pTab->nCol; i++){\n      zColAff[i] = pTab->aCol[i].affinity;\n    }\n    zColAff[pTab->nCol] = '\\0';\n\n    pTab->zColAff = zColAff;\n  }\n\n  sqlite3VdbeChangeP4(v, -1, pTab->zColAff, P4_TRANSIENT);\n}\n\n/*\n** Return non-zero if the table pTab in database iDb or any of its indices\n** have been opened at any point in the VDBE program beginning at location\n** iStartAddr throught the end of the program.  This is used to see if \n** a statement of the form  \"INSERT INTO <iDb, pTab> SELECT ...\" can \n** run without using temporary table for the results of the SELECT. \n*/\nstatic int readsTable(Parse *p, int iStartAddr, int iDb, Table *pTab){\n  Vdbe *v = sqlite3GetVdbe(p);\n  int i;\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  VTable *pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p->db, pTab) : 0;\n#endif\n\n  for(i=iStartAddr; i<iEnd; i++){\n    VdbeOp *pOp = sqlite3VdbeGetOp(v, i);\n    assert( pOp!=0 );\n    if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){\n      Index *pIndex;\n      int tnum = pOp->p2;\n      if( tnum==pTab->tnum ){\n        return 1;\n      }\n      for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n        if( tnum==pIndex->tnum ){\n          return 1;\n        }\n      }\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( pOp->opcode==OP_VOpen && pOp->p4.pVtab==pVTab ){\n      assert( pOp->p4.pVtab!=0 );\n      assert( pOp->p4type==P4_VTAB );\n      return 1;\n    }\n#endif\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/*\n** Locate or create an AutoincInfo structure associated with table pTab\n** which is in database iDb.  Return the register number for the register\n** that holds the maximum rowid.\n**\n** There is at most one AutoincInfo structure per table even if the\n** same table is autoincremented multiple times due to inserts within\n** triggers.  A new AutoincInfo structure is created if this is the\n** first use of table pTab.  On 2nd and subsequent uses, the original\n** AutoincInfo structure is used.\n**\n** Three memory locations are allocated:\n**\n**   (1)  Register to hold the name of the pTab table.\n**   (2)  Register to hold the maximum ROWID of pTab.\n**   (3)  Register to hold the rowid in sqlite_sequence of pTab\n**\n** The 2nd register is the one that is returned.  That is all the\n** insert routine needs to know about.\n*/\nstatic int autoIncBegin(\n  Parse *pParse,      /* Parsing context */\n  int iDb,            /* Index of the database holding pTab */\n  Table *pTab         /* The table we are writing to */\n){\n  int memId = 0;      /* Register holding maximum rowid */\n  if( pTab->tabFlags & TF_Autoincrement ){\n    Parse *pToplevel = sqlite3ParseToplevel(pParse);\n    AutoincInfo *pInfo;\n\n    pInfo = pToplevel->pAinc;\n    while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }\n    if( pInfo==0 ){\n      pInfo = sqlite3DbMallocRaw(pParse->db, sizeof(*pInfo));\n      if( pInfo==0 ) return 0;\n      pInfo->pNext = pToplevel->pAinc;\n      pToplevel->pAinc = pInfo;\n      pInfo->pTab = pTab;\n      pInfo->iDb = iDb;\n      pToplevel->nMem++;                  /* Register to hold name of table */\n      pInfo->regCtr = ++pToplevel->nMem;  /* Max rowid register */\n      pToplevel->nMem++;                  /* Rowid in sqlite_sequence */\n    }\n    memId = pInfo->regCtr;\n  }\n  return memId;\n}\n\n/*\n** This routine generates code that will initialize all of the\n** register used by the autoincrement tracker.  \n*/\nSQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse){\n  AutoincInfo *p;            /* Information about an AUTOINCREMENT */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  Db *pDb;                   /* Database only autoinc table */\n  int memId;                 /* Register holding max rowid */\n  int addr;                  /* A VDBE address */\n  Vdbe *v = pParse->pVdbe;   /* VDBE under construction */\n\n  /* This routine is never called during trigger-generation.  It is\n  ** only called from the top-level */\n  assert( pParse->pTriggerTab==0 );\n  assert( pParse==sqlite3ParseToplevel(pParse) );\n\n  assert( v );   /* We failed long ago if this is not so */\n  for(p = pParse->pAinc; p; p = p->pNext){\n    pDb = &db->aDb[p->iDb];\n    memId = p->regCtr;\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);\n    sqlite3VdbeAddOp3(v, OP_Null, 0, memId, memId+1);\n    addr = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0);\n    sqlite3VdbeAddOp2(v, OP_Rewind, 0, addr+9);\n    sqlite3VdbeAddOp3(v, OP_Column, 0, 0, memId);\n    sqlite3VdbeAddOp3(v, OP_Ne, memId-1, addr+7, memId);\n    sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);\n    sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId+1);\n    sqlite3VdbeAddOp3(v, OP_Column, 0, 1, memId);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr+9);\n    sqlite3VdbeAddOp2(v, OP_Next, 0, addr+2);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, memId);\n    sqlite3VdbeAddOp0(v, OP_Close);\n  }\n}\n\n/*\n** Update the maximum rowid for an autoincrement calculation.\n**\n** This routine should be called when the top of the stack holds a\n** new rowid that is about to be inserted.  If that new rowid is\n** larger than the maximum rowid in the memId memory cell, then the\n** memory cell is updated.  The stack is unchanged.\n*/\nstatic void autoIncStep(Parse *pParse, int memId, int regRowid){\n  if( memId>0 ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_MemMax, memId, regRowid);\n  }\n}\n\n/*\n** This routine generates the code needed to write autoincrement\n** maximum rowid values back into the sqlite_sequence register.\n** Every statement that might do an INSERT into an autoincrement\n** table (either directly or through triggers) needs to call this\n** routine just before the \"exit\" code.\n*/\nSQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse){\n  AutoincInfo *p;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( v );\n  for(p = pParse->pAinc; p; p = p->pNext){\n    Db *pDb = &db->aDb[p->iDb];\n    int j1, j2, j3, j4, j5;\n    int iRec;\n    int memId = p->regCtr;\n\n    iRec = sqlite3GetTempReg(pParse);\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);\n    j1 = sqlite3VdbeAddOp1(v, OP_NotNull, memId+1);\n    j2 = sqlite3VdbeAddOp0(v, OP_Rewind);\n    j3 = sqlite3VdbeAddOp3(v, OP_Column, 0, 0, iRec);\n    j4 = sqlite3VdbeAddOp3(v, OP_Eq, memId-1, 0, iRec);\n    sqlite3VdbeAddOp2(v, OP_Next, 0, j3);\n    sqlite3VdbeJumpHere(v, j2);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, memId+1);\n    j5 = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, j4);\n    sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId+1);\n    sqlite3VdbeJumpHere(v, j1);\n    sqlite3VdbeJumpHere(v, j5);\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, memId-1, 2, iRec);\n    sqlite3VdbeAddOp3(v, OP_Insert, 0, iRec, memId+1);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeAddOp0(v, OP_Close);\n    sqlite3ReleaseTempReg(pParse, iRec);\n  }\n}\n#else\n/*\n** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines\n** above are all no-ops\n*/\n# define autoIncBegin(A,B,C) (0)\n# define autoIncStep(A,B,C)\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n\n/*\n** Generate code for a co-routine that will evaluate a subquery one\n** row at a time.\n**\n** The pSelect parameter is the subquery that the co-routine will evaluation.\n** Information about the location of co-routine and the registers it will use\n** is returned by filling in the pDest object.\n**\n** Registers are allocated as follows:\n**\n**   pDest->iSDParm      The register holding the next entry-point of the\n**                       co-routine.  Run the co-routine to its next breakpoint\n**                       by calling \"OP_Yield $X\" where $X is pDest->iSDParm.\n**\n**   pDest->iSDParm+1    The register holding the \"completed\" flag for the\n**                       co-routine. This register is 0 if the previous Yield\n**                       generated a new result row, or 1 if the subquery\n**                       has completed.  If the Yield is called again\n**                       after this register becomes 1, then the VDBE will\n**                       halt with an SQLITE_INTERNAL error.\n**\n**   pDest->iSdst        First result register.\n**\n**   pDest->nSdst        Number of result registers.\n**\n** This routine handles all of the register allocation and fills in the\n** pDest structure appropriately.\n**\n** Here is a schematic of the generated code assuming that X is the \n** co-routine entry-point register reg[pDest->iSDParm], that EOF is the\n** completed flag reg[pDest->iSDParm+1], and R and S are the range of\n** registers that hold the result set, reg[pDest->iSdst] through\n** reg[pDest->iSdst+pDest->nSdst-1]:\n**\n**         X <- A\n**         EOF <- 0\n**         goto B\n**      A: setup for the SELECT\n**         loop rows in the SELECT\n**           load results into registers R..S\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         EOF <- 1\n**         yield X\n**         halt-error\n**      B:\n**\n** To use this subroutine, the caller generates code as follows:\n**\n**         [ Co-routine generated by this subroutine, shown above ]\n**      S: yield X\n**         if EOF goto E\n**         if skip this row, goto C\n**         if terminate loop, goto E\n**         deal with this row\n**      C: goto S\n**      E:\n*/\nSQLITE_PRIVATE int sqlite3CodeCoroutine(Parse *pParse, Select *pSelect, SelectDest *pDest){\n  int regYield;       /* Register holding co-routine entry-point */\n  int regEof;         /* Register holding co-routine completion flag */\n  int addrTop;        /* Top of the co-routine */\n  int j1;             /* Jump instruction */\n  int rc;             /* Result code */\n  Vdbe *v;            /* VDBE under construction */\n\n  regYield = ++pParse->nMem;\n  regEof = ++pParse->nMem;\n  v = sqlite3GetVdbe(pParse);\n  addrTop = sqlite3VdbeCurrentAddr(v);\n  sqlite3VdbeAddOp2(v, OP_Integer, addrTop+2, regYield); /* X <- A */\n  VdbeComment((v, \"Co-routine entry point\"));\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regEof);           /* EOF <- 0 */\n  VdbeComment((v, \"Co-routine completion flag\"));\n  sqlite3SelectDestInit(pDest, SRT_Coroutine, regYield);\n  j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);\n  rc = sqlite3Select(pParse, pSelect, pDest);\n  assert( pParse->nErr==0 || rc );\n  if( pParse->db->mallocFailed && rc==SQLITE_OK ) rc = SQLITE_NOMEM;\n  if( rc ) return rc;\n  sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof);            /* EOF <- 1 */\n  sqlite3VdbeAddOp1(v, OP_Yield, regYield);   /* yield X */\n  sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort);\n  VdbeComment((v, \"End of coroutine\"));\n  sqlite3VdbeJumpHere(v, j1);                             /* label B: */\n  return rc;\n}\n\n\n\n/* Forward declaration */\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n);\n\n/*\n** This routine is call to handle SQL of the following forms:\n**\n**    insert into TABLE (IDLIST) values(EXPRLIST)\n**    insert into TABLE (IDLIST) select\n**\n** The IDLIST following the table name is always optional.  If omitted,\n** then a list of all columns for the table is substituted.  The IDLIST\n** appears in the pColumn parameter.  pColumn is NULL if IDLIST is omitted.\n**\n** The pList parameter holds EXPRLIST in the first form of the INSERT\n** statement above, and pSelect is NULL.  For the second form, pList is\n** NULL and pSelect is a pointer to the select statement used to generate\n** data for the insert.\n**\n** The code generated follows one of four templates.  For a simple\n** select with data coming from a VALUES clause, the code executes\n** once straight down through.  Pseudo-code follows (we call this\n** the \"1st template\"):\n**\n**         open write cursor to <table> and its indices\n**         puts VALUES clause expressions onto the stack\n**         write the resulting record into <table>\n**         cleanup\n**\n** The three remaining templates assume the statement is of the form\n**\n**   INSERT INTO <table> SELECT ...\n**\n** If the SELECT clause is of the restricted form \"SELECT * FROM <table2>\" -\n** in other words if the SELECT pulls all columns from a single table\n** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and\n** if <table2> and <table1> are distinct tables but have identical\n** schemas, including all the same indices, then a special optimization\n** is invoked that copies raw records from <table2> over to <table1>.\n** See the xferOptimization() function for the implementation of this\n** template.  This is the 2nd template.\n**\n**         open a write cursor to <table>\n**         open read cursor on <table2>\n**         transfer all records in <table2> over to <table>\n**         close cursors\n**         foreach index on <table>\n**           open a write cursor on the <table> index\n**           open a read cursor on the corresponding <table2> index\n**           transfer all records from the read to the write cursors\n**           close cursors\n**         end foreach\n**\n** The 3rd template is for when the second template does not apply\n** and the SELECT clause does not read from <table> at any time.\n** The generated code follows this template:\n**\n**         EOF <- 0\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the rows in the SELECT\n**           load values into registers R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         EOF <- 1\n**         yield X\n**         goto A\n**      B: open write cursor to <table> and its indices\n**      C: yield X\n**         if EOF goto D\n**         insert the select result into <table> from R..R+n\n**         goto C\n**      D: cleanup\n**\n** The 4th template is used if the insert statement takes its\n** values from a SELECT but the data is being inserted into a table\n** that is also read as part of the SELECT.  In the third form,\n** we have to use a intermediate table to store the results of\n** the select.  The template is like this:\n**\n**         EOF <- 0\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the tables in the SELECT\n**           load value into register R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         EOF <- 1\n**         yield X\n**         halt-error\n**      B: open temp table\n**      L: yield X\n**         if EOF goto M\n**         insert row from R..R+n into temp table\n**         goto L\n**      M: open write cursor to <table> and its indices\n**         rewind temp table\n**      C: loop over rows of intermediate table\n**           transfer values form intermediate table into <table>\n**         end loop\n**      D: cleanup\n*/\nSQLITE_PRIVATE void sqlite3Insert(\n  Parse *pParse,        /* Parser context */\n  SrcList *pTabList,    /* Name of table into which we are inserting */\n  ExprList *pList,      /* List of values to be inserted */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  IdList *pColumn,      /* Column names corresponding to IDLIST. */\n  int onError           /* How to handle constraint errors */\n){\n  sqlite3 *db;          /* The main database structure */\n  Table *pTab;          /* The table to insert into.  aka TABLE */\n  char *zTab;           /* Name of the table into which we are inserting */\n  const char *zDb;      /* Name of the database holding this table */\n  int i, j, idx;        /* Loop counters */\n  Vdbe *v;              /* Generate code into this virtual machine */\n  Index *pIdx;          /* For looping over indices of the table */\n  int nColumn;          /* Number of columns in the data */\n  int nHidden = 0;      /* Number of hidden columns if TABLE is virtual */\n  int baseCur = 0;      /* VDBE Cursor number for pTab */\n  int keyColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */\n  int endOfLoop;        /* Label for the end of the insertion loop */\n  int useTempTable = 0; /* Store SELECT results in intermediate table */\n  int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */\n  int addrInsTop = 0;   /* Jump to label \"D\" */\n  int addrCont = 0;     /* Top of insert loop. Label \"C\" in templates 3 and 4 */\n  int addrSelect = 0;   /* Address of coroutine that implements the SELECT */\n  SelectDest dest;      /* Destination for SELECT on rhs of INSERT */\n  int iDb;              /* Index of database holding TABLE */\n  Db *pDb;              /* The database containing table being inserted into */\n  int appendFlag = 0;   /* True if the insert is likely to be an append */\n\n  /* Register allocations */\n  int regFromSelect = 0;/* Base register for data coming from SELECT */\n  int regAutoinc = 0;   /* Register holding the AUTOINCREMENT counter */\n  int regRowCount = 0;  /* Memory cell used for the row counter */\n  int regIns;           /* Block of regs holding rowid+data being inserted */\n  int regRowid;         /* registers holding insert rowid */\n  int regData;          /* register holding first column to insert */\n  int regEof = 0;       /* Register recording end of SELECT data */\n  int *aRegIdx = 0;     /* One register allocated to each index */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                 /* True if attempting to insert into a view */\n  Trigger *pTrigger;          /* List of triggers on pTab, if required */\n  int tmask;                  /* Mask of trigger times */\n#endif\n\n  db = pParse->db;\n  memset(&dest, 0, sizeof(dest));\n  if( pParse->nErr || db->mallocFailed ){\n    goto insert_cleanup;\n  }\n\n  /* Locate the table into which we will be inserting new information.\n  */\n  assert( pTabList->nSrc==1 );\n  zTab = pTabList->a[0].zName;\n  if( NEVER(zTab==0) ) goto insert_cleanup;\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ){\n    goto insert_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  pDb = &db->aDb[iDb];\n  zDb = pDb->zName;\n  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){\n    goto insert_cleanup;\n  }\n\n  /* Figure out if we have any triggers and if the table being\n  ** inserted into is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define tmask 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n  assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) );\n\n  /* If pTab is really a view, make sure it has been initialized.\n  ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual \n  ** module table).\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto insert_cleanup;\n  }\n\n  /* Ensure that:\n  *  (a) the table is not read-only, \n  *  (b) that if it is a view then ON INSERT triggers exist\n  */\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto insert_cleanup;\n  }\n\n  /* Allocate a VDBE\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto insert_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, pSelect || pTrigger, iDb);\n\n#ifndef SQLITE_OMIT_XFER_OPT\n  /* If the statement is of the form\n  **\n  **       INSERT INTO <table1> SELECT * FROM <table2>;\n  **\n  ** Then special optimizations can be applied that make the transfer\n  ** very fast and which reduce fragmentation of indices.\n  **\n  ** This is the 2nd template.\n  */\n  if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){\n    assert( !pTrigger );\n    assert( pList==0 );\n    goto insert_end;\n  }\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n  /* If this is an AUTOINCREMENT table, look up the sequence number in the\n  ** sqlite_sequence table and store it in memory cell regAutoinc.\n  */\n  regAutoinc = autoIncBegin(pParse, iDb, pTab);\n\n  /* Figure out how many columns of data are supplied.  If the data\n  ** is coming from a SELECT statement, then generate a co-routine that\n  ** produces a single row of the SELECT on each invocation.  The\n  ** co-routine is the common header to the 3rd and 4th templates.\n  */\n  if( pSelect ){\n    /* Data is coming from a SELECT.  Generate a co-routine to run that\n    ** SELECT. */\n    int rc = sqlite3CodeCoroutine(pParse, pSelect, &dest);\n    if( rc ) goto insert_cleanup;\n\n    regEof = dest.iSDParm + 1;\n    regFromSelect = dest.iSdst;\n    assert( pSelect->pEList );\n    nColumn = pSelect->pEList->nExpr;\n    assert( dest.nSdst==nColumn );\n\n    /* Set useTempTable to TRUE if the result of the SELECT statement\n    ** should be written into a temporary table (template 4).  Set to\n    ** FALSE if each* row of the SELECT can be written directly into\n    ** the destination table (template 3).\n    **\n    ** A temp table must be used if the table being updated is also one\n    ** of the tables being read by the SELECT statement.  Also use a \n    ** temp table in the case of row triggers.\n    */\n    if( pTrigger || readsTable(pParse, addrSelect, iDb, pTab) ){\n      useTempTable = 1;\n    }\n\n    if( useTempTable ){\n      /* Invoke the coroutine to extract information from the SELECT\n      ** and add it to a transient table srcTab.  The code generated\n      ** here is from the 4th template:\n      **\n      **      B: open temp table\n      **      L: yield X\n      **         if EOF goto M\n      **         insert row from R..R+n into temp table\n      **         goto L\n      **      M: ...\n      */\n      int regRec;          /* Register to hold packed record */\n      int regTempRowid;    /* Register to hold temp table ROWID */\n      int addrTop;         /* Label \"L\" */\n      int addrIf;          /* Address of jump to M */\n\n      srcTab = pParse->nTab++;\n      regRec = sqlite3GetTempReg(pParse);\n      regTempRowid = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn);\n      addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n      addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid);\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);\n      sqlite3VdbeJumpHere(v, addrIf);\n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempReg(pParse, regTempRowid);\n    }\n  }else{\n    /* This is the case if the data for the INSERT is coming from a VALUES\n    ** clause\n    */\n    NameContext sNC;\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    srcTab = -1;\n    assert( useTempTable==0 );\n    nColumn = pList ? pList->nExpr : 0;\n    for(i=0; i<nColumn; i++){\n      if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){\n        goto insert_cleanup;\n      }\n    }\n  }\n\n  /* Make sure the number of columns in the source data matches the number\n  ** of columns to be inserted into the table.\n  */\n  if( IsVirtual(pTab) ){\n    for(i=0; i<pTab->nCol; i++){\n      nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);\n    }\n  }\n  if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){\n    sqlite3ErrorMsg(pParse, \n       \"table %S has %d columns but %d values were supplied\",\n       pTabList, 0, pTab->nCol-nHidden, nColumn);\n    goto insert_cleanup;\n  }\n  if( pColumn!=0 && nColumn!=pColumn->nId ){\n    sqlite3ErrorMsg(pParse, \"%d values for %d columns\", nColumn, pColumn->nId);\n    goto insert_cleanup;\n  }\n\n  /* If the INSERT statement included an IDLIST term, then make sure\n  ** all elements of the IDLIST really are columns of the table and \n  ** remember the column indices.\n  **\n  ** If the table has an INTEGER PRIMARY KEY column and that column\n  ** is named in the IDLIST, then record in the keyColumn variable\n  ** the index into IDLIST of the primary key column.  keyColumn is\n  ** the index of the primary key as it appears in IDLIST, not as\n  ** is appears in the original table.  (The index of the primary\n  ** key in the original table is pTab->iPKey.)\n  */\n  if( pColumn ){\n    for(i=0; i<pColumn->nId; i++){\n      pColumn->a[i].idx = -1;\n    }\n    for(i=0; i<pColumn->nId; i++){\n      for(j=0; j<pTab->nCol; j++){\n        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){\n          pColumn->a[i].idx = j;\n          if( j==pTab->iPKey ){\n            keyColumn = i;\n          }\n          break;\n        }\n      }\n      if( j>=pTab->nCol ){\n        if( sqlite3IsRowid(pColumn->a[i].zName) ){\n          keyColumn = i;\n        }else{\n          sqlite3ErrorMsg(pParse, \"table %S has no column named %s\",\n              pTabList, 0, pColumn->a[i].zName);\n          pParse->checkSchema = 1;\n          goto insert_cleanup;\n        }\n      }\n    }\n  }\n\n  /* If there is no IDLIST term but the table has an integer primary\n  ** key, the set the keyColumn variable to the primary key column index\n  ** in the original table definition.\n  */\n  if( pColumn==0 && nColumn>0 ){\n    keyColumn = pTab->iPKey;\n  }\n    \n  /* Initialize the count of rows to be inserted\n  */\n  if( db->flags & SQLITE_CountRows ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  /* If this is not a view, open the table and and all indices */\n  if( !isView ){\n    int nIdx;\n\n    baseCur = pParse->nTab;\n    nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite);\n    aRegIdx = sqlite3DbMallocRaw(db, sizeof(int)*(nIdx+1));\n    if( aRegIdx==0 ){\n      goto insert_cleanup;\n    }\n    for(i=0; i<nIdx; i++){\n      aRegIdx[i] = ++pParse->nMem;\n    }\n  }\n\n  /* This is the top of the main insertion loop */\n  if( useTempTable ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 4):\n    **\n    **         rewind temp table\n    **      C: loop over rows of intermediate table\n    **           transfer values form intermediate table into <table>\n    **         end loop\n    **      D: ...\n    */\n    addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab);\n    addrCont = sqlite3VdbeCurrentAddr(v);\n  }else if( pSelect ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 3):\n    **\n    **      C: yield X\n    **         if EOF goto D\n    **         insert the select result into <table> from R..R+n\n    **         goto C\n    **      D: ...\n    */\n    addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n    addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof);\n  }\n\n  /* Allocate registers for holding the rowid of the new row,\n  ** the content of the new row, and the assemblied row record.\n  */\n  regRowid = regIns = pParse->nMem+1;\n  pParse->nMem += pTab->nCol + 1;\n  if( IsVirtual(pTab) ){\n    regRowid++;\n    pParse->nMem++;\n  }\n  regData = regRowid+1;\n\n  /* Run the BEFORE and INSTEAD OF triggers, if there are any\n  */\n  endOfLoop = sqlite3VdbeMakeLabel(v);\n  if( tmask & TRIGGER_BEFORE ){\n    int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);\n\n    /* build the NEW.* reference row.  Note that if there is an INTEGER\n    ** PRIMARY KEY into which a NULL is being inserted, that NULL will be\n    ** translated into a unique ID for the row.  But on a BEFORE trigger,\n    ** we do not know what the unique ID will be (because the insert has\n    ** not happened yet) so we substitute a rowid of -1\n    */\n    if( keyColumn<0 ){\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n    }else{\n      int j1;\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regCols);\n      }else{\n        assert( pSelect==0 );  /* Otherwise useTempTable is true */\n        sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regCols);\n      }\n      j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n      sqlite3VdbeJumpHere(v, j1);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols);\n    }\n\n    /* Cannot have triggers on a virtual table. If it were possible,\n    ** this block would have to account for hidden column.\n    */\n    assert( !IsVirtual(pTab) );\n\n    /* Create the new column data\n    */\n    for(i=0; i<pTab->nCol; i++){\n      if( pColumn==0 ){\n        j = i;\n      }else{\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId) ){\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); \n      }else{\n        assert( pSelect==0 ); /* Otherwise useTempTable is true */\n        sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);\n      }\n    }\n\n    /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,\n    ** do not attempt any conversions before assembling the record.\n    ** If this is a real table, attempt conversions as required by the\n    ** table column affinities.\n    */\n    if( !isView ){\n      sqlite3VdbeAddOp2(v, OP_Affinity, regCols+1, pTab->nCol);\n      sqlite3TableAffinityStr(v, pTab);\n    }\n\n    /* Fire BEFORE or INSTEAD OF triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE, \n        pTab, regCols-pTab->nCol-1, onError, endOfLoop);\n\n    sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);\n  }\n\n  /* Push the record number for the new entry onto the stack.  The\n  ** record number is a randomly generate integer created by NewRowid\n  ** except when the table has an INTEGER PRIMARY KEY column, in which\n  ** case the record number is the same as that column. \n  */\n  if( !isView ){\n    if( IsVirtual(pTab) ){\n      /* The row that the VUpdate opcode will delete: none */\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);\n    }\n    if( keyColumn>=0 ){\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regRowid);\n      }else if( pSelect ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+keyColumn, regRowid);\n      }else{\n        VdbeOp *pOp;\n        sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid);\n        pOp = sqlite3VdbeGetOp(v, -1);\n        if( ALWAYS(pOp) && pOp->opcode==OP_Null && !IsVirtual(pTab) ){\n          appendFlag = 1;\n          pOp->opcode = OP_NewRowid;\n          pOp->p1 = baseCur;\n          pOp->p2 = regRowid;\n          pOp->p3 = regAutoinc;\n        }\n      }\n      /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid\n      ** to generate a unique primary key value.\n      */\n      if( !appendFlag ){\n        int j1;\n        if( !IsVirtual(pTab) ){\n          j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid);\n          sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc);\n          sqlite3VdbeJumpHere(v, j1);\n        }else{\n          j1 = sqlite3VdbeCurrentAddr(v);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1+2);\n        }\n        sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid);\n      }\n    }else if( IsVirtual(pTab) ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc);\n      appendFlag = 1;\n    }\n    autoIncStep(pParse, regAutoinc, regRowid);\n\n    /* Push onto the stack, data for all columns of the new entry, beginning\n    ** with the first column.\n    */\n    nHidden = 0;\n    for(i=0; i<pTab->nCol; i++){\n      int iRegStore = regRowid+1+i;\n      if( i==pTab->iPKey ){\n        /* The value of the INTEGER PRIMARY KEY column is always a NULL.\n        ** Whenever this column is read, the record number will be substituted\n        ** in its place.  So will fill this column with a NULL to avoid\n        ** taking up data space with information that will never be used. */\n        sqlite3VdbeAddOp2(v, OP_Null, 0, iRegStore);\n        continue;\n      }\n      if( pColumn==0 ){\n        if( IsHiddenColumn(&pTab->aCol[i]) ){\n          assert( IsVirtual(pTab) );\n          j = -1;\n          nHidden++;\n        }else{\n          j = i - nHidden;\n        }\n      }else{\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, iRegStore);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); \n      }else if( pSelect ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);\n      }else{\n        sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);\n      }\n    }\n\n    /* Generate code to check constraints and generate index keys and\n    ** do the insertion.\n    */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab->nCol+2, regIns, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n      sqlite3MayAbort(pParse);\n    }else\n#endif\n    {\n      int isReplace;    /* Set to true if constraints may cause a replace */\n      sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx,\n          keyColumn>=0, 0, onError, endOfLoop, &isReplace\n      );\n      sqlite3FkCheck(pParse, pTab, 0, regIns);\n      sqlite3CompleteInsertion(\n          pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0\n      );\n    }\n  }\n\n  /* Update the count of rows that are inserted\n  */\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  if( pTrigger ){\n    /* Code AFTER triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, \n        pTab, regData-2-pTab->nCol, onError, endOfLoop);\n  }\n\n  /* The bottom of the main insertion loop, if the data source\n  ** is a SELECT statement.\n  */\n  sqlite3VdbeResolveLabel(v, endOfLoop);\n  if( useTempTable ){\n    sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n    sqlite3VdbeAddOp1(v, OP_Close, srcTab);\n  }else if( pSelect ){\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrCont);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n  }\n\n  if( !IsVirtual(pTab) && !isView ){\n    /* Close all tables opened */\n    sqlite3VdbeAddOp1(v, OP_Close, baseCur);\n    for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){\n      sqlite3VdbeAddOp1(v, OP_Close, idx+baseCur);\n    }\n  }\n\ninsert_end:\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows inserted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows inserted\", SQLITE_STATIC);\n  }\n\ninsert_cleanup:\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3IdListDelete(db, pColumn);\n  sqlite3DbFree(db, aRegIdx);\n}\n\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** thely may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n#ifdef tmask\n #undef tmask\n#endif\n\n\n/*\n** Generate code to do constraint checks prior to an INSERT or an UPDATE.\n**\n** The input is a range of consecutive registers as follows:\n**\n**    1.  The rowid of the row after the update.\n**\n**    2.  The data in the first column of the entry after the update.\n**\n**    i.  Data from middle columns...\n**\n**    N.  The data in the last column of the entry after the update.\n**\n** The regRowid parameter is the index of the register containing (1).\n**\n** If isUpdate is true and rowidChng is non-zero, then rowidChng contains\n** the address of a register containing the rowid before the update takes\n** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate\n** is false, indicating an INSERT statement, then a non-zero rowidChng \n** indicates that the rowid was explicitly specified as part of the\n** INSERT statement. If rowidChng is false, it means that  the rowid is\n** computed automatically in an insert or that the rowid value is not \n** modified by an update.\n**\n** The code generated by this routine store new index entries into\n** registers identified by aRegIdx[].  No index entry is created for\n** indices where aRegIdx[i]==0.  The order of indices in aRegIdx[] is\n** the same as the order of indices on the linked list of indices\n** attached to the table.\n**\n** This routine also generates code to check constraints.  NOT NULL,\n** CHECK, and UNIQUE constraints are all checked.  If a constraint fails,\n** then the appropriate action is performed.  There are five possible\n** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.\n**\n**  Constraint type  Action       What Happens\n**  ---------------  ----------   ----------------------------------------\n**  any              ROLLBACK     The current transaction is rolled back and\n**                                sqlite3_exec() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.\n**\n**  any              ABORT        Back out changes from the current command\n**                                only (do not do a complete rollback) then\n**                                cause sqlite3_exec() to return immediately\n**                                with SQLITE_CONSTRAINT.\n**\n**  any              FAIL         Sqlite3_exec() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.  The\n**                                transaction is not rolled back and any\n**                                prior changes are retained.\n**\n**  any              IGNORE       The record number and data is popped from\n**                                the stack and there is an immediate jump\n**                                to label ignoreDest.\n**\n**  NOT NULL         REPLACE      The NULL value is replace by the default\n**                                value for that column.  If the default value\n**                                is NULL, the action is the same as ABORT.\n**\n**  UNIQUE           REPLACE      The other row that conflicts with the row\n**                                being inserted is removed.\n**\n**  CHECK            REPLACE      Illegal.  The results in an exception.\n**\n** Which action to take is determined by the overrideError parameter.\n** Or if overrideError==OE_Default, then the pParse->onError parameter\n** is used.  Or if pParse->onError==OE_Default then the onError value\n** for the constraint is used.\n**\n** The calling routine must open a read/write cursor for pTab with\n** cursor number \"baseCur\".  All indices of pTab must also have open\n** read/write cursors with cursor number baseCur+i for the i-th cursor.\n** Except, if there is no possibility of a REPLACE action then\n** cursors do not need to be open for indices where aRegIdx[i]==0.\n*/\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(\n  Parse *pParse,      /* The parser context */\n  Table *pTab,        /* the table into which we are inserting */\n  int baseCur,        /* Index of a read/write cursor pointing at pTab */\n  int regRowid,       /* Index of the range of input registers */\n  int *aRegIdx,       /* Register used by each index.  0 for unused indices */\n  int rowidChng,      /* True if the rowid might collide with existing entry */\n  int isUpdate,       /* True for UPDATE, False for INSERT */\n  int overrideError,  /* Override onError to this if not OE_Default */\n  int ignoreDest,     /* Jump to this label on an OE_Ignore resolution */\n  int *pbMayReplace   /* OUT: Set to true if constraint may cause a replace */\n){\n  int i;              /* loop counter */\n  Vdbe *v;            /* VDBE under constrution */\n  int nCol;           /* Number of columns */\n  int onError;        /* Conflict resolution strategy */\n  int j1;             /* Addresss of jump instruction */\n  int j2 = 0, j3;     /* Addresses of jump instructions */\n  int regData;        /* Register containing first data column */\n  int iCur;           /* Table cursor number */\n  Index *pIdx;         /* Pointer to one of the indices */\n  sqlite3 *db;         /* Database connection */\n  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */\n  int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;\n\n  db = pParse->db;\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  nCol = pTab->nCol;\n  regData = regRowid + 1;\n\n  /* Test all NOT NULL constraints.\n  */\n  for(i=0; i<nCol; i++){\n    if( i==pTab->iPKey ){\n      continue;\n    }\n    onError = pTab->aCol[i].notNull;\n    if( onError==OE_None ) continue;\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){\n      onError = OE_Abort;\n    }\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Abort:\n        sqlite3MayAbort(pParse);\n      case OE_Rollback:\n      case OE_Fail: {\n        char *zMsg;\n        sqlite3VdbeAddOp3(v, OP_HaltIfNull,\n                          SQLITE_CONSTRAINT_NOTNULL, onError, regData+i);\n        zMsg = sqlite3MPrintf(db, \"%s.%s may not be NULL\",\n                              pTab->zName, pTab->aCol[i].zName);\n        sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);\n        break;\n      }\n      case OE_Ignore: {\n        sqlite3VdbeAddOp2(v, OP_IsNull, regData+i, ignoreDest);\n        break;\n      }\n      default: {\n        assert( onError==OE_Replace );\n        j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regData+i);\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regData+i);\n        sqlite3VdbeJumpHere(v, j1);\n        break;\n      }\n    }\n  }\n\n  /* Test all CHECK constraints\n  */\n#ifndef SQLITE_OMIT_CHECK\n  if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n    ExprList *pCheck = pTab->pCheck;\n    pParse->ckBase = regData;\n    onError = overrideError!=OE_Default ? overrideError : OE_Abort;\n    for(i=0; i<pCheck->nExpr; i++){\n      int allOk = sqlite3VdbeMakeLabel(v);\n      sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);\n      if( onError==OE_Ignore ){\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);\n      }else{\n        char *zConsName = pCheck->a[i].zName;\n        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */\n        if( zConsName ){\n          zConsName = sqlite3MPrintf(db, \"constraint %s failed\", zConsName);\n        }else{\n          zConsName = 0;\n        }\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,\n                              onError, zConsName, P4_DYNAMIC);\n      }\n      sqlite3VdbeResolveLabel(v, allOk);\n    }\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* If we have an INTEGER PRIMARY KEY, make sure the primary key\n  ** of the new record does not previously exist.  Except, if this\n  ** is an UPDATE and the primary key is not changing, that is OK.\n  */\n  if( rowidChng ){\n    onError = pTab->keyConf;\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    \n    if( isUpdate ){\n      j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);\n    }\n    j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);\n    switch( onError ){\n      default: {\n        onError = OE_Abort;\n        /* Fall thru into the next case */\n      }\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY,\n           onError, \"PRIMARY KEY must be unique\", P4_STATIC);\n        break;\n      }\n      case OE_Replace: {\n        /* If there are DELETE triggers on this table and the\n        ** recursive-triggers flag is set, call GenerateRowDelete() to\n        ** remove the conflicting row from the table. This will fire\n        ** the triggers and remove both the table and index b-tree entries.\n        **\n        ** Otherwise, if there are no triggers or the recursive-triggers\n        ** flag is not set, but the table has one or more indexes, call \n        ** GenerateRowIndexDelete(). This removes the index b-tree entries \n        ** only. The table b-tree entry will be replaced by the new entry \n        ** when it is inserted.  \n        **\n        ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,\n        ** also invoke MultiWrite() to indicate that this VDBE may require\n        ** statement rollback (if the statement is aborted after the delete\n        ** takes place). Earlier versions called sqlite3MultiWrite() regardless,\n        ** but being more selective here allows statements like:\n        **\n        **   REPLACE INTO t(rowid) VALUES($newrowid)\n        **\n        ** to run without a statement journal if there are no indexes on the\n        ** table.\n        */\n        Trigger *pTrigger = 0;\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){\n          sqlite3MultiWrite(pParse);\n          sqlite3GenerateRowDelete(\n              pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace\n          );\n        }else if( pTab->pIndex ){\n          sqlite3MultiWrite(pParse);\n          sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0);\n        }\n        seenReplace = 1;\n        break;\n      }\n      case OE_Ignore: {\n        assert( seenReplace==0 );\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);\n        break;\n      }\n    }\n    sqlite3VdbeJumpHere(v, j3);\n    if( isUpdate ){\n      sqlite3VdbeJumpHere(v, j2);\n    }\n  }\n\n  /* Test all UNIQUE constraints by creating entries for each UNIQUE\n  ** index and making sure that duplicate entries do not already exist.\n  ** Add the new records to the indices as we go.\n  */\n  for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){\n    int regIdx;\n    int regR;\n\n    if( aRegIdx[iCur]==0 ) continue;  /* Skip unused indices */\n\n    /* Create a key for accessing the index entry */\n    regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1);\n    for(i=0; i<pIdx->nColumn; i++){\n      int idx = pIdx->aiColumn[i];\n      if( idx==pTab->iPKey ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_SCopy, regData+idx, regIdx+i);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i);\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn+1, aRegIdx[iCur]);\n    sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT);\n    sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn+1);\n\n    /* Find out what action to take in case there is an indexing conflict */\n    onError = pIdx->onError;\n    if( onError==OE_None ){ \n      sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);\n      continue;  /* pIdx is not a UNIQUE index */\n    }\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    if( seenReplace ){\n      if( onError==OE_Ignore ) onError = OE_Replace;\n      else if( onError==OE_Fail ) onError = OE_Abort;\n    }\n    \n    /* Check to see if the new index entry will be unique */\n    regR = sqlite3GetTempReg(pParse);\n    sqlite3VdbeAddOp2(v, OP_SCopy, regOldRowid, regR);\n    j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur+iCur+1, 0,\n                           regR, SQLITE_INT_TO_PTR(regIdx),\n                           P4_INT32);\n    sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1);\n\n    /* Generate code that executes if the new index entry is not unique */\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        int j;\n        StrAccum errMsg;\n        const char *zSep;\n        char *zErr;\n\n        sqlite3StrAccumInit(&errMsg, 0, 0, 200);\n        errMsg.db = db;\n        zSep = pIdx->nColumn>1 ? \"columns \" : \"column \";\n        for(j=0; j<pIdx->nColumn; j++){\n          char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;\n          sqlite3StrAccumAppend(&errMsg, zSep, -1);\n          zSep = \", \";\n          sqlite3StrAccumAppend(&errMsg, zCol, -1);\n        }\n        sqlite3StrAccumAppend(&errMsg,\n            pIdx->nColumn>1 ? \" are not unique\" : \" is not unique\", -1);\n        zErr = sqlite3StrAccumFinish(&errMsg);\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE,\n                              onError, zErr, 0);\n        sqlite3DbFree(errMsg.db, zErr);\n        break;\n      }\n      case OE_Ignore: {\n        assert( seenReplace==0 );\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);\n        break;\n      }\n      default: {\n        Trigger *pTrigger = 0;\n        assert( onError==OE_Replace );\n        sqlite3MultiWrite(pParse);\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        sqlite3GenerateRowDelete(\n            pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace\n        );\n        seenReplace = 1;\n        break;\n      }\n    }\n    sqlite3VdbeJumpHere(v, j3);\n    sqlite3ReleaseTempReg(pParse, regR);\n  }\n  \n  if( pbMayReplace ){\n    *pbMayReplace = seenReplace;\n  }\n}\n\n/*\n** This routine generates code to finish the INSERT or UPDATE operation\n** that was started by a prior call to sqlite3GenerateConstraintChecks.\n** A consecutive range of registers starting at regRowid contains the\n** rowid and the content to be inserted.\n**\n** The arguments to this routine should be the same as the first six\n** arguments to sqlite3GenerateConstraintChecks.\n*/\nSQLITE_PRIVATE void sqlite3CompleteInsertion(\n  Parse *pParse,      /* The parser context */\n  Table *pTab,        /* the table into which we are inserting */\n  int baseCur,        /* Index of a read/write cursor pointing at pTab */\n  int regRowid,       /* Range of content */\n  int *aRegIdx,       /* Register used by each index.  0 for unused indices */\n  int isUpdate,       /* True for UPDATE, False for INSERT */\n  int appendBias,     /* True if this is likely to be an append */\n  int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */\n){\n  int i;\n  Vdbe *v;\n  int nIdx;\n  Index *pIdx;\n  u8 pik_flags;\n  int regData;\n  int regRec;\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}\n  for(i=nIdx-1; i>=0; i--){\n    if( aRegIdx[i]==0 ) continue;\n    sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]);\n    if( useSeekResult ){\n      sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n    }\n  }\n  regData = regRowid + 1;\n  regRec = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);\n  sqlite3TableAffinityStr(v, pTab);\n  sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);\n  if( pParse->nested ){\n    pik_flags = 0;\n  }else{\n    pik_flags = OPFLAG_NCHANGE;\n    pik_flags |= (isUpdate?OPFLAG_ISUPDATE:OPFLAG_LASTROWID);\n  }\n  if( appendBias ){\n    pik_flags |= OPFLAG_APPEND;\n  }\n  if( useSeekResult ){\n    pik_flags |= OPFLAG_USESEEKRESULT;\n  }\n  sqlite3VdbeAddOp3(v, OP_Insert, baseCur, regRec, regRowid);\n  if( !pParse->nested ){\n    sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT);\n  }\n  sqlite3VdbeChangeP5(v, pik_flags);\n}\n\n/*\n** Generate code that will open cursors for a table and for all\n** indices of that table.  The \"baseCur\" parameter is the cursor number used\n** for the table.  Indices are opened on subsequent cursors.\n**\n** Return the number of indices on the table.\n*/\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(\n  Parse *pParse,   /* Parsing context */\n  Table *pTab,     /* Table to be opened */\n  int baseCur,     /* Cursor number assigned to the table */\n  int op           /* OP_OpenRead or OP_OpenWrite */\n){\n  int i;\n  int iDb;\n  Index *pIdx;\n  Vdbe *v;\n\n  if( IsVirtual(pTab) ) return 0;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  sqlite3OpenTable(pParse, baseCur, iDb, pTab, op);\n  for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);\n    assert( pIdx->pSchema==pTab->pSchema );\n    sqlite3VdbeAddOp4(v, op, i+baseCur, pIdx->tnum, iDb,\n                      (char*)pKey, P4_KEYINFO_HANDOFF);\n    VdbeComment((v, \"%s\", pIdx->zName));\n  }\n  if( pParse->nTab<baseCur+i ){\n    pParse->nTab = baseCur+i;\n  }\n  return i-1;\n}\n\n\n#ifdef SQLITE_TEST\n/*\n** The following global variable is incremented whenever the\n** transfer optimization is used.  This is used for testing\n** purposes only - to make sure the transfer optimization really\n** is happening when it is suppose to.\n*/\nSQLITE_API int sqlite3_xferopt_count;\n#endif /* SQLITE_TEST */\n\n\n#ifndef SQLITE_OMIT_XFER_OPT\n/*\n** Check to collation names to see if they are compatible.\n*/\nstatic int xferCompatibleCollation(const char *z1, const char *z2){\n  if( z1==0 ){\n    return z2==0;\n  }\n  if( z2==0 ){\n    return 0;\n  }\n  return sqlite3StrICmp(z1, z2)==0;\n}\n\n\n/*\n** Check to see if index pSrc is compatible as a source of data\n** for index pDest in an insert transfer optimization.  The rules\n** for a compatible index:\n**\n**    *   The index is over the same set of columns\n**    *   The same DESC and ASC markings occurs on all columns\n**    *   The same onError processing (OE_Abort, OE_Ignore, etc)\n**    *   The same collating sequence on each column\n*/\nstatic int xferCompatibleIndex(Index *pDest, Index *pSrc){\n  int i;\n  assert( pDest && pSrc );\n  assert( pDest->pTable!=pSrc->pTable );\n  if( pDest->nColumn!=pSrc->nColumn ){\n    return 0;   /* Different number of columns */\n  }\n  if( pDest->onError!=pSrc->onError ){\n    return 0;   /* Different conflict resolution strategies */\n  }\n  for(i=0; i<pSrc->nColumn; i++){\n    if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){\n      return 0;   /* Different columns indexed */\n    }\n    if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){\n      return 0;   /* Different sort orders */\n    }\n    if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){\n      return 0;   /* Different collating sequences */\n    }\n  }\n\n  /* If no test above fails then the indices must be compatible */\n  return 1;\n}\n\n/*\n** Attempt the transfer optimization on INSERTs of the form\n**\n**     INSERT INTO tab1 SELECT * FROM tab2;\n**\n** The xfer optimization transfers raw records from tab2 over to tab1.  \n** Columns are not decoded and reassemblied, which greatly improves\n** performance.  Raw index records are transferred in the same way.\n**\n** The xfer optimization is only attempted if tab1 and tab2 are compatible.\n** There are lots of rules for determining compatibility - see comments\n** embedded in the code for details.\n**\n** This routine returns TRUE if the optimization is guaranteed to be used.\n** Sometimes the xfer optimization will only work if the destination table\n** is empty - a factor that can only be determined at run-time.  In that\n** case, this routine generates code for the xfer optimization but also\n** does a test to see if the destination table is empty and jumps over the\n** xfer optimization code if the test fails.  In that case, this routine\n** returns FALSE so that the caller will know to go ahead and generate\n** an unoptimized transfer.  This routine also returns FALSE if there\n** is no chance that the xfer optimization can be applied.\n**\n** This optimization is particularly useful at making VACUUM run faster.\n*/\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n){\n  ExprList *pEList;                /* The result set of the SELECT */\n  Table *pSrc;                     /* The table in the FROM clause of SELECT */\n  Index *pSrcIdx, *pDestIdx;       /* Source and destination indices */\n  struct SrcList_item *pItem;      /* An element of pSelect->pSrc */\n  int i;                           /* Loop counter */\n  int iDbSrc;                      /* The database of pSrc */\n  int iSrc, iDest;                 /* Cursors from source and destination */\n  int addr1, addr2;                /* Loop addresses */\n  int emptyDestTest;               /* Address of test for empty pDest */\n  int emptySrcTest;                /* Address of test for empty pSrc */\n  Vdbe *v;                         /* The VDBE we are building */\n  KeyInfo *pKey;                   /* Key information for an index */\n  int regAutoinc;                  /* Memory register used by AUTOINC */\n  int destHasUniqueIdx = 0;        /* True if pDest has a UNIQUE index */\n  int regData, regRowid;           /* Registers holding data and rowid */\n\n  if( pSelect==0 ){\n    return 0;   /* Must be of the form  INSERT INTO ... SELECT ... */\n  }\n  if( sqlite3TriggerList(pParse, pDest) ){\n    return 0;   /* tab1 must not have triggers */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pDest->tabFlags & TF_Virtual ){\n    return 0;   /* tab1 must not be a virtual table */\n  }\n#endif\n  if( onError==OE_Default ){\n    if( pDest->iPKey>=0 ) onError = pDest->keyConf;\n    if( onError==OE_Default ) onError = OE_Abort;\n  }\n  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */\n  if( pSelect->pSrc->nSrc!=1 ){\n    return 0;   /* FROM clause must have exactly one term */\n  }\n  if( pSelect->pSrc->a[0].pSelect ){\n    return 0;   /* FROM clause cannot contain a subquery */\n  }\n  if( pSelect->pWhere ){\n    return 0;   /* SELECT may not have a WHERE clause */\n  }\n  if( pSelect->pOrderBy ){\n    return 0;   /* SELECT may not have an ORDER BY clause */\n  }\n  /* Do not need to test for a HAVING clause.  If HAVING is present but\n  ** there is no ORDER BY, we will get an error. */\n  if( pSelect->pGroupBy ){\n    return 0;   /* SELECT may not have a GROUP BY clause */\n  }\n  if( pSelect->pLimit ){\n    return 0;   /* SELECT may not have a LIMIT clause */\n  }\n  assert( pSelect->pOffset==0 );  /* Must be so if pLimit==0 */\n  if( pSelect->pPrior ){\n    return 0;   /* SELECT may not be a compound query */\n  }\n  if( pSelect->selFlags & SF_Distinct ){\n    return 0;   /* SELECT may not be DISTINCT */\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );\n  if( pEList->nExpr!=1 ){\n    return 0;   /* The result set must have exactly one column */\n  }\n  assert( pEList->a[0].pExpr );\n  if( pEList->a[0].pExpr->op!=TK_ALL ){\n    return 0;   /* The result set must be the special operator \"*\" */\n  }\n\n  /* At this point we have established that the statement is of the\n  ** correct syntactic form to participate in this optimization.  Now\n  ** we have to check the semantics.\n  */\n  pItem = pSelect->pSrc->a;\n  pSrc = sqlite3LocateTableItem(pParse, 0, pItem);\n  if( pSrc==0 ){\n    return 0;   /* FROM clause does not contain a real table */\n  }\n  if( pSrc==pDest ){\n    return 0;   /* tab1 and tab2 may not be the same table */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pSrc->tabFlags & TF_Virtual ){\n    return 0;   /* tab2 must not be a virtual table */\n  }\n#endif\n  if( pSrc->pSelect ){\n    return 0;   /* tab2 may not be a view */\n  }\n  if( pDest->nCol!=pSrc->nCol ){\n    return 0;   /* Number of columns must be the same in tab1 and tab2 */\n  }\n  if( pDest->iPKey!=pSrc->iPKey ){\n    return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */\n  }\n  for(i=0; i<pDest->nCol; i++){\n    if( pDest->aCol[i].affinity!=pSrc->aCol[i].affinity ){\n      return 0;    /* Affinity must be the same on all columns */\n    }\n    if( !xferCompatibleCollation(pDest->aCol[i].zColl, pSrc->aCol[i].zColl) ){\n      return 0;    /* Collating sequence must be the same on all columns */\n    }\n    if( pDest->aCol[i].notNull && !pSrc->aCol[i].notNull ){\n      return 0;    /* tab2 must be NOT NULL if tab1 is */\n    }\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    if( pDestIdx->onError!=OE_None ){\n      destHasUniqueIdx = 1;\n    }\n    for(pSrcIdx=pSrc->pIndex; pSrcIdx; pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    if( pSrcIdx==0 ){\n      return 0;    /* pDestIdx has no corresponding index in pSrc */\n    }\n  }\n#ifndef SQLITE_OMIT_CHECK\n  if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){\n    return 0;   /* Tables have different CHECK constraints.  Ticket #2252 */\n  }\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  /* Disallow the transfer optimization if the destination table constains\n  ** any foreign key constraints.  This is more restrictive than necessary.\n  ** But the main beneficiary of the transfer optimization is the VACUUM \n  ** command, and the VACUUM command disables foreign key constraints.  So\n  ** the extra complication to make this rule less restrictive is probably\n  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]\n  */\n  if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){\n    return 0;\n  }\n#endif\n  if( (pParse->db->flags & SQLITE_CountRows)!=0 ){\n    return 0;  /* xfer opt does not play well with PRAGMA count_changes */\n  }\n\n  /* If we get this far, it means that the xfer optimization is at\n  ** least a possibility, though it might only work if the destination\n  ** table (tab1) is initially empty.\n  */\n#ifdef SQLITE_TEST\n  sqlite3_xferopt_count++;\n#endif\n  iDbSrc = sqlite3SchemaToIndex(pParse->db, pSrc->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  sqlite3CodeVerifySchema(pParse, iDbSrc);\n  iSrc = pParse->nTab++;\n  iDest = pParse->nTab++;\n  regAutoinc = autoIncBegin(pParse, iDbDest, pDest);\n  sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);\n  if( (pDest->iPKey<0 && pDest->pIndex!=0)          /* (1) */\n   || destHasUniqueIdx                              /* (2) */\n   || (onError!=OE_Abort && onError!=OE_Rollback)   /* (3) */\n  ){\n    /* In some circumstances, we are able to run the xfer optimization\n    ** only if the destination table is initially empty.  This code makes\n    ** that determination.  Conditions under which the destination must\n    ** be empty:\n    **\n    ** (1) There is no INTEGER PRIMARY KEY but there are indices.\n    **     (If the destination is not initially empty, the rowid fields\n    **     of index entries might need to change.)\n    **\n    ** (2) The destination has a unique index.  (The xfer optimization \n    **     is unable to test uniqueness.)\n    **\n    ** (3) onError is something other than OE_Abort and OE_Rollback.\n    */\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0);\n    emptyDestTest = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);\n    sqlite3VdbeJumpHere(v, addr1);\n  }else{\n    emptyDestTest = 0;\n  }\n  sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);\n  emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0);\n  regData = sqlite3GetTempReg(pParse);\n  regRowid = sqlite3GetTempReg(pParse);\n  if( pDest->iPKey>=0 ){\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n    addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY,\n        onError, \"PRIMARY KEY must be unique\", P4_STATIC);\n    sqlite3VdbeJumpHere(v, addr2);\n    autoIncStep(pParse, regAutoinc, regRowid);\n  }else if( pDest->pIndex==0 ){\n    addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);\n  }else{\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n    assert( (pDest->tabFlags & TF_Autoincrement)==0 );\n  }\n  sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData);\n  sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid);\n  sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND);\n  sqlite3VdbeChangeP4(v, -1, pDest->zName, 0);\n  sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1);\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    assert( pSrcIdx );\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n    pKey = sqlite3IndexKeyinfo(pParse, pSrcIdx);\n    sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc,\n                      (char*)pKey, P4_KEYINFO_HANDOFF);\n    VdbeComment((v, \"%s\", pSrcIdx->zName));\n    pKey = sqlite3IndexKeyinfo(pParse, pDestIdx);\n    sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest,\n                      (char*)pKey, P4_KEYINFO_HANDOFF);\n    VdbeComment((v, \"%s\", pDestIdx->zName));\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);\n    sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1);\n    sqlite3VdbeJumpHere(v, addr1);\n  }\n  sqlite3VdbeJumpHere(v, emptySrcTest);\n  sqlite3ReleaseTempReg(pParse, regRowid);\n  sqlite3ReleaseTempReg(pParse, regData);\n  sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n  sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  if( emptyDestTest ){\n    sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0);\n    sqlite3VdbeJumpHere(v, emptyDestTest);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n    return 0;\n  }else{\n    return 1;\n  }\n}\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n/************** End of insert.c **********************************************/\n/************** Begin file legacy.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n\n\n/*\n** Execute SQL code.  Return one of the SQLITE_ success/failure\n** codes.  Also write an error message into memory obtained from\n** malloc() and make *pzErrMsg point to that message.\n**\n** If the SQL is a query, then for each row in the query result\n** the xCallback() function is called.  pArg becomes the first\n** argument to xCallback().  If xCallback=NULL then no callback\n** is invoked, even for queries.\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  sqlite3_callback xCallback, /* Invoke this callback routine */\n  void *pArg,                 /* First argument to xCallback() */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc = SQLITE_OK;         /* Return code */\n  const char *zLeftover;      /* Tail of unprocessed SQL */\n  sqlite3_stmt *pStmt = 0;    /* The current SQL statement */\n  char **azCols = 0;          /* Names of result columns */\n  int callbackIsInit;         /* True if callback data is initialized */\n\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n  if( zSql==0 ) zSql = \"\";\n\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3Error(db, SQLITE_OK, 0);\n  while( rc==SQLITE_OK && zSql[0] ){\n    int nCol;\n    char **azVals = 0;\n\n    pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    assert( rc==SQLITE_OK || pStmt==0 );\n    if( rc!=SQLITE_OK ){\n      continue;\n    }\n    if( !pStmt ){\n      /* this happens for a comment or white-space */\n      zSql = zLeftover;\n      continue;\n    }\n\n    callbackIsInit = 0;\n    nCol = sqlite3_column_count(pStmt);\n\n    while( 1 ){\n      int i;\n      rc = sqlite3_step(pStmt);\n\n      /* Invoke the callback function if required */\n      if( xCallback && (SQLITE_ROW==rc || \n          (SQLITE_DONE==rc && !callbackIsInit\n                           && db->flags&SQLITE_NullCallback)) ){\n        if( !callbackIsInit ){\n          azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1);\n          if( azCols==0 ){\n            goto exec_out;\n          }\n          for(i=0; i<nCol; i++){\n            azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n            /* sqlite3VdbeSetColName() installs column names as UTF8\n            ** strings so there is no way for sqlite3_column_name() to fail. */\n            assert( azCols[i]!=0 );\n          }\n          callbackIsInit = 1;\n        }\n        if( rc==SQLITE_ROW ){\n          azVals = &azCols[nCol];\n          for(i=0; i<nCol; i++){\n            azVals[i] = (char *)sqlite3_column_text(pStmt, i);\n            if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n              db->mallocFailed = 1;\n              goto exec_out;\n            }\n          }\n        }\n        if( xCallback(pArg, nCol, azVals, azCols) ){\n          rc = SQLITE_ABORT;\n          sqlite3VdbeFinalize((Vdbe *)pStmt);\n          pStmt = 0;\n          sqlite3Error(db, SQLITE_ABORT, 0);\n          goto exec_out;\n        }\n      }\n\n      if( rc!=SQLITE_ROW ){\n        rc = sqlite3VdbeFinalize((Vdbe *)pStmt);\n        pStmt = 0;\n        zSql = zLeftover;\n        while( sqlite3Isspace(zSql[0]) ) zSql++;\n        break;\n      }\n    }\n\n    sqlite3DbFree(db, azCols);\n    azCols = 0;\n  }\n\nexec_out:\n  if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);\n  sqlite3DbFree(db, azCols);\n\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && ALWAYS(rc==sqlite3_errcode(db)) && pzErrMsg ){\n    int nErrMsg = 1 + sqlite3Strlen30(sqlite3_errmsg(db));\n    *pzErrMsg = sqlite3Malloc(nErrMsg);\n    if( *pzErrMsg ){\n      memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);\n    }else{\n      rc = SQLITE_NOMEM;\n      sqlite3Error(db, SQLITE_NOMEM, 0);\n    }\n  }else if( pzErrMsg ){\n    *pzErrMsg = 0;\n  }\n\n  assert( (rc&db->errMask)==rc );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of legacy.c **********************************************/\n/************** Begin file loadext.c *****************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to dynamically load extensions into\n** the SQLite library.\n*/\n\n#ifndef SQLITE_CORE\n  #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */\n#endif\n/************** Include sqlite3ext.h in the middle of loadext.c **************/\n/************** Begin file sqlite3ext.h **************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef _SQLITE3EXT_H_\n#define _SQLITE3EXT_H_\n\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each others' shared\n** libraries!\n*/\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n  int  (*global_recover)(void);\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*snprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*vsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n};\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected throught the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#ifndef SQLITE_CORE\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->snprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->vsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n#endif /* SQLITE_CORE */\n\n#ifndef SQLITE_CORE\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n#endif\n\n#endif /* _SQLITE3EXT_H_ */\n\n/************** End of sqlite3ext.h ******************************************/\n/************** Continuing where we left off in loadext.c ********************/\n/* #include <string.h> */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n\n/*\n** Some API routines are omitted when various features are\n** excluded from a build of SQLite.  Substitute a NULL pointer\n** for any missing APIs.\n*/\n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n# define sqlite3_column_database_name   0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name      0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name     0\n# define sqlite3_column_origin_name16   0\n# define sqlite3_table_column_metadata  0\n#endif\n\n#ifdef SQLITE_OMIT_AUTHORIZATION\n# define sqlite3_set_authorizer         0\n#endif\n\n#ifdef SQLITE_OMIT_UTF16\n# define sqlite3_bind_text16            0\n# define sqlite3_collation_needed16     0\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_name16          0\n# define sqlite3_column_text16          0\n# define sqlite3_complete16             0\n# define sqlite3_create_collation16     0\n# define sqlite3_create_function16      0\n# define sqlite3_errmsg16               0\n# define sqlite3_open16                 0\n# define sqlite3_prepare16              0\n# define sqlite3_prepare16_v2           0\n# define sqlite3_result_error16         0\n# define sqlite3_result_text16          0\n# define sqlite3_result_text16be        0\n# define sqlite3_result_text16le        0\n# define sqlite3_value_text16           0\n# define sqlite3_value_text16be         0\n# define sqlite3_value_text16le         0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_COMPLETE\n# define sqlite3_complete 0\n# define sqlite3_complete16 0\n#endif\n\n#ifdef SQLITE_OMIT_DECLTYPE\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_decltype        0\n#endif\n\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n# define sqlite3_progress_handler 0\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# define sqlite3_create_module 0\n# define sqlite3_create_module_v2 0\n# define sqlite3_declare_vtab 0\n# define sqlite3_vtab_config 0\n# define sqlite3_vtab_on_conflict 0\n#endif\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n# define sqlite3_enable_shared_cache 0\n#endif\n\n#ifdef SQLITE_OMIT_TRACE\n# define sqlite3_profile       0\n# define sqlite3_trace         0\n#endif\n\n#ifdef SQLITE_OMIT_GET_TABLE\n# define sqlite3_free_table    0\n# define sqlite3_get_table     0\n#endif\n\n#ifdef SQLITE_OMIT_INCRBLOB\n#define sqlite3_bind_zeroblob  0\n#define sqlite3_blob_bytes     0\n#define sqlite3_blob_close     0\n#define sqlite3_blob_open      0\n#define sqlite3_blob_read      0\n#define sqlite3_blob_write     0\n#define sqlite3_blob_reopen    0\n#endif\n\n/*\n** The following structure contains pointers to all SQLite API routines.\n** A pointer to this structure is passed into extensions when they are\n** loaded so that the extension can make calls back into the SQLite\n** library.\n**\n** When adding new APIs, add them to the bottom of this structure\n** in order to preserve backwards compatibility.\n**\n** Extensions that use newer APIs should first call the\n** sqlite3_libversion_number() to make sure that the API they\n** intend to use is supported by the library.  Extensions should\n** also check to make sure that the pointer to the function is\n** not NULL before calling it.\n*/\nstatic const sqlite3_api_routines sqlite3Apis = {\n  sqlite3_aggregate_context,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_aggregate_count,\n#else\n  0,\n#endif\n  sqlite3_bind_blob,\n  sqlite3_bind_double,\n  sqlite3_bind_int,\n  sqlite3_bind_int64,\n  sqlite3_bind_null,\n  sqlite3_bind_parameter_count,\n  sqlite3_bind_parameter_index,\n  sqlite3_bind_parameter_name,\n  sqlite3_bind_text,\n  sqlite3_bind_text16,\n  sqlite3_bind_value,\n  sqlite3_busy_handler,\n  sqlite3_busy_timeout,\n  sqlite3_changes,\n  sqlite3_close,\n  sqlite3_collation_needed,\n  sqlite3_collation_needed16,\n  sqlite3_column_blob,\n  sqlite3_column_bytes,\n  sqlite3_column_bytes16,\n  sqlite3_column_count,\n  sqlite3_column_database_name,\n  sqlite3_column_database_name16,\n  sqlite3_column_decltype,\n  sqlite3_column_decltype16,\n  sqlite3_column_double,\n  sqlite3_column_int,\n  sqlite3_column_int64,\n  sqlite3_column_name,\n  sqlite3_column_name16,\n  sqlite3_column_origin_name,\n  sqlite3_column_origin_name16,\n  sqlite3_column_table_name,\n  sqlite3_column_table_name16,\n  sqlite3_column_text,\n  sqlite3_column_text16,\n  sqlite3_column_type,\n  sqlite3_column_value,\n  sqlite3_commit_hook,\n  sqlite3_complete,\n  sqlite3_complete16,\n  sqlite3_create_collation,\n  sqlite3_create_collation16,\n  sqlite3_create_function,\n  sqlite3_create_function16,\n  sqlite3_create_module,\n  sqlite3_data_count,\n  sqlite3_db_handle,\n  sqlite3_declare_vtab,\n  sqlite3_enable_shared_cache,\n  sqlite3_errcode,\n  sqlite3_errmsg,\n  sqlite3_errmsg16,\n  sqlite3_exec,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_expired,\n#else\n  0,\n#endif\n  sqlite3_finalize,\n  sqlite3_free,\n  sqlite3_free_table,\n  sqlite3_get_autocommit,\n  sqlite3_get_auxdata,\n  sqlite3_get_table,\n  0,     /* Was sqlite3_global_recover(), but that function is deprecated */\n  sqlite3_interrupt,\n  sqlite3_last_insert_rowid,\n  sqlite3_libversion,\n  sqlite3_libversion_number,\n  sqlite3_malloc,\n  sqlite3_mprintf,\n  sqlite3_open,\n  sqlite3_open16,\n  sqlite3_prepare,\n  sqlite3_prepare16,\n  sqlite3_profile,\n  sqlite3_progress_handler,\n  sqlite3_realloc,\n  sqlite3_reset,\n  sqlite3_result_blob,\n  sqlite3_result_double,\n  sqlite3_result_error,\n  sqlite3_result_error16,\n  sqlite3_result_int,\n  sqlite3_result_int64,\n  sqlite3_result_null,\n  sqlite3_result_text,\n  sqlite3_result_text16,\n  sqlite3_result_text16be,\n  sqlite3_result_text16le,\n  sqlite3_result_value,\n  sqlite3_rollback_hook,\n  sqlite3_set_authorizer,\n  sqlite3_set_auxdata,\n  sqlite3_snprintf,\n  sqlite3_step,\n  sqlite3_table_column_metadata,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup,\n#else\n  0,\n#endif\n  sqlite3_total_changes,\n  sqlite3_trace,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_transfer_bindings,\n#else\n  0,\n#endif\n  sqlite3_update_hook,\n  sqlite3_user_data,\n  sqlite3_value_blob,\n  sqlite3_value_bytes,\n  sqlite3_value_bytes16,\n  sqlite3_value_double,\n  sqlite3_value_int,\n  sqlite3_value_int64,\n  sqlite3_value_numeric_type,\n  sqlite3_value_text,\n  sqlite3_value_text16,\n  sqlite3_value_text16be,\n  sqlite3_value_text16le,\n  sqlite3_value_type,\n  sqlite3_vmprintf,\n  /*\n  ** The original API set ends here.  All extensions can call any\n  ** of the APIs above provided that the pointer is not NULL.  But\n  ** before calling APIs that follow, extension should check the\n  ** sqlite3_libversion_number() to make sure they are dealing with\n  ** a library that is new enough to support that API.\n  *************************************************************************\n  */\n  sqlite3_overload_function,\n\n  /*\n  ** Added after 3.3.13\n  */\n  sqlite3_prepare_v2,\n  sqlite3_prepare16_v2,\n  sqlite3_clear_bindings,\n\n  /*\n  ** Added for 3.4.1\n  */\n  sqlite3_create_module_v2,\n\n  /*\n  ** Added for 3.5.0\n  */\n  sqlite3_bind_zeroblob,\n  sqlite3_blob_bytes,\n  sqlite3_blob_close,\n  sqlite3_blob_open,\n  sqlite3_blob_read,\n  sqlite3_blob_write,\n  sqlite3_create_collation_v2,\n  sqlite3_file_control,\n  sqlite3_memory_highwater,\n  sqlite3_memory_used,\n#ifdef SQLITE_MUTEX_OMIT\n  0, \n  0, \n  0,\n  0,\n  0,\n#else\n  sqlite3_mutex_alloc,\n  sqlite3_mutex_enter,\n  sqlite3_mutex_free,\n  sqlite3_mutex_leave,\n  sqlite3_mutex_try,\n#endif\n  sqlite3_open_v2,\n  sqlite3_release_memory,\n  sqlite3_result_error_nomem,\n  sqlite3_result_error_toobig,\n  sqlite3_sleep,\n  sqlite3_soft_heap_limit,\n  sqlite3_vfs_find,\n  sqlite3_vfs_register,\n  sqlite3_vfs_unregister,\n\n  /*\n  ** Added for 3.5.8\n  */\n  sqlite3_threadsafe,\n  sqlite3_result_zeroblob,\n  sqlite3_result_error_code,\n  sqlite3_test_control,\n  sqlite3_randomness,\n  sqlite3_context_db_handle,\n\n  /*\n  ** Added for 3.6.0\n  */\n  sqlite3_extended_result_codes,\n  sqlite3_limit,\n  sqlite3_next_stmt,\n  sqlite3_sql,\n  sqlite3_status,\n\n  /*\n  ** Added for 3.7.4\n  */\n  sqlite3_backup_finish,\n  sqlite3_backup_init,\n  sqlite3_backup_pagecount,\n  sqlite3_backup_remaining,\n  sqlite3_backup_step,\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  sqlite3_compileoption_get,\n  sqlite3_compileoption_used,\n#else\n  0,\n  0,\n#endif\n  sqlite3_create_function_v2,\n  sqlite3_db_config,\n  sqlite3_db_mutex,\n  sqlite3_db_status,\n  sqlite3_extended_errcode,\n  sqlite3_log,\n  sqlite3_soft_heap_limit64,\n  sqlite3_sourceid,\n  sqlite3_stmt_status,\n  sqlite3_strnicmp,\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  sqlite3_unlock_notify,\n#else\n  0,\n#endif\n#ifndef SQLITE_OMIT_WAL\n  sqlite3_wal_autocheckpoint,\n  sqlite3_wal_checkpoint,\n  sqlite3_wal_hook,\n#else\n  0,\n  0,\n  0,\n#endif\n  sqlite3_blob_reopen,\n  sqlite3_vtab_config,\n  sqlite3_vtab_on_conflict,\n  sqlite3_close_v2,\n  sqlite3_db_filename,\n  sqlite3_db_readonly,\n  sqlite3_db_release_memory,\n  sqlite3_errstr,\n  sqlite3_stmt_busy,\n  sqlite3_stmt_readonly,\n  sqlite3_stricmp,\n  sqlite3_uri_boolean,\n  sqlite3_uri_int64,\n  sqlite3_uri_parameter,\n  sqlite3_vsnprintf,\n  sqlite3_wal_checkpoint_v2\n};\n\n/*\n** Attempt to load an SQLite extension library contained in the file\n** zFile.  The entry point is zProc.  zProc may be 0 in which case a\n** default entry point name (sqlite3_extension_init) is used.  Use\n** of the default name is recommended.\n**\n** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.\n**\n** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with \n** error message text.  The calling function should free this memory\n** by calling sqlite3DbFree(db, ).\n*/\nstatic int sqlite3LoadExtension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  sqlite3_vfs *pVfs = db->pVfs;\n  void *handle;\n  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);\n  char *zErrmsg = 0;\n  const char *zEntry;\n  char *zAltEntry = 0;\n  void **aHandle;\n  int nMsg = 300 + sqlite3Strlen30(zFile);\n  int ii;\n\n  /* Shared library endings to try if zFile cannot be loaded as written */\n  static const char *azEndings[] = {\n#if SQLITE_OS_WIN\n     \"dll\"   \n#elif defined(__APPLE__)\n     \"dylib\"\n#else\n     \"so\"\n#endif\n  };\n\n\n  if( pzErrMsg ) *pzErrMsg = 0;\n\n  /* Ticket #1863.  To avoid a creating security problems for older\n  ** applications that relink against newer versions of SQLite, the\n  ** ability to run load_extension is turned off by default.  One\n  ** must call sqlite3_enable_load_extension() to turn on extension\n  ** loading.  Otherwise you get the following error.\n  */\n  if( (db->flags & SQLITE_LoadExtension)==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"not authorized\");\n    }\n    return SQLITE_ERROR;\n  }\n\n  zEntry = zProc ? zProc : \"sqlite3_extension_init\";\n\n  handle = sqlite3OsDlOpen(pVfs, zFile);\n#if SQLITE_OS_UNIX || SQLITE_OS_WIN\n  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){\n    char *zAltFile = sqlite3_mprintf(\"%s.%s\", zFile, azEndings[ii]);\n    if( zAltFile==0 ) return SQLITE_NOMEM;\n    handle = sqlite3OsDlOpen(pVfs, zAltFile);\n    sqlite3_free(zAltFile);\n  }\n#endif\n  if( handle==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg, \n            \"unable to open shared library [%s]\", zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    return SQLITE_ERROR;\n  }\n  xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))\n                   sqlite3OsDlSym(pVfs, handle, zEntry);\n\n  /* If no entry point was specified and the default legacy\n  ** entry point name \"sqlite3_extension_init\" was not found, then\n  ** construct an entry point name \"sqlite3_X_init\" where the X is\n  ** replaced by the lowercase value of every ASCII alphabetic \n  ** character in the filename after the last \"/\" upto the first \".\",\n  ** and eliding the first three characters if they are \"lib\".  \n  ** Examples:\n  **\n  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init\n  **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init\n  */\n  if( xInit==0 && zProc==0 ){\n    int iFile, iEntry, c;\n    int ncFile = sqlite3Strlen30(zFile);\n    zAltEntry = sqlite3_malloc(ncFile+30);\n    if( zAltEntry==0 ){\n      sqlite3OsDlClose(pVfs, handle);\n      return SQLITE_NOMEM;\n    }\n    memcpy(zAltEntry, \"sqlite3_\", 8);\n    for(iFile=ncFile-1; iFile>=0 && zFile[iFile]!='/'; iFile--){}\n    iFile++;\n    if( sqlite3_strnicmp(zFile+iFile, \"lib\", 3)==0 ) iFile += 3;\n    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){\n      if( sqlite3Isalpha(c) ){\n        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];\n      }\n    }\n    memcpy(zAltEntry+iEntry, \"_init\", 6);\n    zEntry = zAltEntry;\n    xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))\n                     sqlite3OsDlSym(pVfs, handle, zEntry);\n  }\n  if( xInit==0 ){\n    if( pzErrMsg ){\n      nMsg += sqlite3Strlen30(zEntry);\n      *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg,\n            \"no entry point [%s] in shared library [%s]\", zEntry, zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    sqlite3OsDlClose(pVfs, handle);\n    sqlite3_free(zAltEntry);\n    return SQLITE_ERROR;\n  }\n  sqlite3_free(zAltEntry);\n  if( xInit(db, &zErrmsg, &sqlite3Apis) ){\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"error during initialization: %s\", zErrmsg);\n    }\n    sqlite3_free(zErrmsg);\n    sqlite3OsDlClose(pVfs, handle);\n    return SQLITE_ERROR;\n  }\n\n  /* Append the new shared library handle to the db->aExtension array. */\n  aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1));\n  if( aHandle==0 ){\n    return SQLITE_NOMEM;\n  }\n  if( db->nExtension>0 ){\n    memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension);\n  }\n  sqlite3DbFree(db, db->aExtension);\n  db->aExtension = aHandle;\n\n  db->aExtension[db->nExtension++] = handle;\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Call this routine when the database connection is closing in order\n** to clean up loaded extensions\n*/\nSQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){\n  int i;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nExtension; i++){\n    sqlite3OsDlClose(db->pVfs, db->aExtension[i]);\n  }\n  sqlite3DbFree(db, db->aExtension);\n}\n\n/*\n** Enable or disable extension loading.  Extension loading is disabled by\n** default so as not to open security holes in older applications.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){\n  sqlite3_mutex_enter(db->mutex);\n  if( onoff ){\n    db->flags |= SQLITE_LoadExtension;\n  }else{\n    db->flags &= ~SQLITE_LoadExtension;\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** The auto-extension code added regardless of whether or not extension\n** loading is supported.  We need a dummy sqlite3Apis pointer for that\n** code if regular extension loading is not available.  This is that\n** dummy pointer.\n*/\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\nstatic const sqlite3_api_routines sqlite3Apis = { 0 };\n#endif\n\n\n/*\n** The following object holds the list of automatically loaded\n** extensions.\n**\n** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MASTER\n** mutex must be held while accessing this list.\n*/\ntypedef struct sqlite3AutoExtList sqlite3AutoExtList;\nstatic SQLITE_WSD struct sqlite3AutoExtList {\n  int nExt;              /* Number of entries in aExt[] */          \n  void (**aExt)(void);   /* Pointers to the extension init functions */\n} sqlite3Autoext = { 0, 0 };\n\n/* The \"wsdAutoext\" macro will resolve to the autoextension\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Autoext\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdAutoextInit \\\n  sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext)\n# define wsdAutoext x[0]\n#else\n# define wsdAutoextInit\n# define wsdAutoext sqlite3Autoext\n#endif\n\n\n/*\n** Register a statically linked extension that is automatically\n** loaded by every new database connection.\n*/\nSQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ){\n    return rc;\n  }else\n#endif\n  {\n    int i;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    for(i=0; i<wsdAutoext.nExt; i++){\n      if( wsdAutoext.aExt[i]==xInit ) break;\n    }\n    if( i==wsdAutoext.nExt ){\n      int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);\n      void (**aNew)(void);\n      aNew = sqlite3_realloc(wsdAutoext.aExt, nByte);\n      if( aNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        wsdAutoext.aExt = aNew;\n        wsdAutoext.aExt[wsdAutoext.nExt] = xInit;\n        wsdAutoext.nExt++;\n      }\n    }\n    sqlite3_mutex_leave(mutex);\n    assert( (rc&0xff)==rc );\n    return rc;\n  }\n}\n\n/*\n** Reset the automatic extension loading mechanism.\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize()==SQLITE_OK )\n#endif\n  {\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    sqlite3_free(wsdAutoext.aExt);\n    wsdAutoext.aExt = 0;\n    wsdAutoext.nExt = 0;\n    sqlite3_mutex_leave(mutex);\n  }\n}\n\n/*\n** Load all automatic extensions.\n**\n** If anything goes wrong, set an error in the database connection.\n*/\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){\n  int i;\n  int go = 1;\n  int rc;\n  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);\n\n  wsdAutoextInit;\n  if( wsdAutoext.nExt==0 ){\n    /* Common case: early out without every having to acquire a mutex */\n    return;\n  }\n  for(i=0; go; i++){\n    char *zErrmsg;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    sqlite3_mutex_enter(mutex);\n    if( i>=wsdAutoext.nExt ){\n      xInit = 0;\n      go = 0;\n    }else{\n      xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))\n              wsdAutoext.aExt[i];\n    }\n    sqlite3_mutex_leave(mutex);\n    zErrmsg = 0;\n    if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){\n      sqlite3Error(db, rc,\n            \"automatic extension loading failed: %s\", zErrmsg);\n      go = 0;\n    }\n    sqlite3_free(zErrmsg);\n  }\n}\n\n/************** End of loadext.c *********************************************/\n/************** Begin file pragma.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the PRAGMA command.\n*/\n\n/*\n** Interpret the given string as a safety level.  Return 0 for OFF,\n** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or \n** unrecognized string argument.  The FULL option is disallowed\n** if the omitFull parameter it 1.\n**\n** Note that the values returned are one less that the values that\n** should be passed into sqlite3BtreeSetSafetyLevel().  The is done\n** to support legacy SQL code.  The safety level used to be boolean\n** and older scripts may have used numbers 0 for OFF and 1 for ON.\n*/\nstatic u8 getSafetyLevel(const char *z, int omitFull, int dflt){\n                             /* 123456789 123456789 */\n  static const char zText[] = \"onoffalseyestruefull\";\n  static const u8 iOffset[] = {0, 1, 2, 4, 9, 12, 16};\n  static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};\n  static const u8 iValue[] =  {1, 0, 0, 0, 1, 1, 2};\n  int i, n;\n  if( sqlite3Isdigit(*z) ){\n    return (u8)sqlite3Atoi(z);\n  }\n  n = sqlite3Strlen30(z);\n  for(i=0; i<ArraySize(iLength)-omitFull; i++){\n    if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0 ){\n      return iValue[i];\n    }\n  }\n  return dflt;\n}\n\n/*\n** Interpret the given string as a boolean value.\n*/\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z, int dflt){\n  return getSafetyLevel(z,1,dflt)!=0;\n}\n\n/* The sqlite3GetBoolean() function is used by other modules but the\n** remainder of this file is specific to PRAGMA processing.  So omit\n** the rest of the file if PRAGMAs are omitted from the build.\n*/\n#if !defined(SQLITE_OMIT_PRAGMA)\n\n/*\n** Interpret the given string as a locking mode value.\n*/\nstatic int getLockingMode(const char *z){\n  if( z ){\n    if( 0==sqlite3StrICmp(z, \"exclusive\") ) return PAGER_LOCKINGMODE_EXCLUSIVE;\n    if( 0==sqlite3StrICmp(z, \"normal\") ) return PAGER_LOCKINGMODE_NORMAL;\n  }\n  return PAGER_LOCKINGMODE_QUERY;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Interpret the given string as an auto-vacuum mode value.\n**\n** The following strings, \"none\", \"full\" and \"incremental\" are \n** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.\n*/\nstatic int getAutoVacuum(const char *z){\n  int i;\n  if( 0==sqlite3StrICmp(z, \"none\") ) return BTREE_AUTOVACUUM_NONE;\n  if( 0==sqlite3StrICmp(z, \"full\") ) return BTREE_AUTOVACUUM_FULL;\n  if( 0==sqlite3StrICmp(z, \"incremental\") ) return BTREE_AUTOVACUUM_INCR;\n  i = sqlite3Atoi(z);\n  return (u8)((i>=0&&i<=2)?i:0);\n}\n#endif /* ifndef SQLITE_OMIT_AUTOVACUUM */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Interpret the given string as a temp db location. Return 1 for file\n** backed temporary databases, 2 for the Red-Black tree in memory database\n** and 0 to use the compile-time default.\n*/\nstatic int getTempStore(const char *z){\n  if( z[0]>='0' && z[0]<='2' ){\n    return z[0] - '0';\n  }else if( sqlite3StrICmp(z, \"file\")==0 ){\n    return 1;\n  }else if( sqlite3StrICmp(z, \"memory\")==0 ){\n    return 2;\n  }else{\n    return 0;\n  }\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Invalidate temp storage, either when the temp storage is changed\n** from default, or when 'file' and the temp_store_directory has changed\n*/\nstatic int invalidateTempStorage(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt!=0 ){\n    if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){\n      sqlite3ErrorMsg(pParse, \"temporary storage cannot be changed \"\n        \"from within a transaction\");\n      return SQLITE_ERROR;\n    }\n    sqlite3BtreeClose(db->aDb[1].pBt);\n    db->aDb[1].pBt = 0;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** If the TEMP database is open, close it and mark the database schema\n** as needing reloading.  This must be done when using the SQLITE_TEMP_STORE\n** or DEFAULT_TEMP_STORE pragmas.\n*/\nstatic int changeTempStorage(Parse *pParse, const char *zStorageType){\n  int ts = getTempStore(zStorageType);\n  sqlite3 *db = pParse->db;\n  if( db->temp_store==ts ) return SQLITE_OK;\n  if( invalidateTempStorage( pParse ) != SQLITE_OK ){\n    return SQLITE_ERROR;\n  }\n  db->temp_store = (u8)ts;\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n/*\n** Generate code to return a single integer value.\n*/\nstatic void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int mem = ++pParse->nMem;\n  i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));\n  if( pI64 ){\n    memcpy(pI64, &value, sizeof(value));\n  }\n  sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);\n  sqlite3VdbeSetNumCols(v, 1);\n  sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);\n  sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);\n}\n\n#ifndef SQLITE_OMIT_FLAG_PRAGMAS\n/*\n** Check to see if zRight and zLeft refer to a pragma that queries\n** or changes one of the flags in db->flags.  Return 1 if so and 0 if not.\n** Also, implement the pragma.\n*/\nstatic int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){\n  static const struct sPragmaType {\n    const char *zName;  /* Name of the pragma */\n    int mask;           /* Mask for the db->flags value */\n  } aPragma[] = {\n    { \"full_column_names\",        SQLITE_FullColNames  },\n    { \"short_column_names\",       SQLITE_ShortColNames },\n    { \"count_changes\",            SQLITE_CountRows     },\n    { \"empty_result_callbacks\",   SQLITE_NullCallback  },\n    { \"legacy_file_format\",       SQLITE_LegacyFileFmt },\n    { \"fullfsync\",                SQLITE_FullFSync     },\n    { \"checkpoint_fullfsync\",     SQLITE_CkptFullFSync },\n    { \"reverse_unordered_selects\", SQLITE_ReverseOrder  },\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n    { \"automatic_index\",          SQLITE_AutoIndex     },\n#endif\n#ifdef SQLITE_DEBUG\n    { \"sql_trace\",                SQLITE_SqlTrace      },\n    { \"vdbe_listing\",             SQLITE_VdbeListing   },\n    { \"vdbe_trace\",               SQLITE_VdbeTrace     },\n    { \"vdbe_addoptrace\",          SQLITE_VdbeAddopTrace},\n    { \"vdbe_debug\",    SQLITE_SqlTrace | SQLITE_VdbeListing\n                               | SQLITE_VdbeTrace      },\n#endif\n#ifndef SQLITE_OMIT_CHECK\n    { \"ignore_check_constraints\", SQLITE_IgnoreChecks  },\n#endif\n    /* The following is VERY experimental */\n    { \"writable_schema\",          SQLITE_WriteSchema|SQLITE_RecoveryMode },\n\n    /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted\n    ** flag if there are any active statements. */\n    { \"read_uncommitted\",         SQLITE_ReadUncommitted },\n    { \"recursive_triggers\",       SQLITE_RecTriggers },\n\n    /* This flag may only be set if both foreign-key and trigger support\n    ** are present in the build.  */\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n    { \"foreign_keys\",             SQLITE_ForeignKeys },\n#endif\n  };\n  int i;\n  const struct sPragmaType *p;\n  for(i=0, p=aPragma; i<ArraySize(aPragma); i++, p++){\n    if( sqlite3StrICmp(zLeft, p->zName)==0 ){\n      sqlite3 *db = pParse->db;\n      Vdbe *v;\n      v = sqlite3GetVdbe(pParse);\n      assert( v!=0 );  /* Already allocated by sqlite3Pragma() */\n      if( ALWAYS(v) ){\n        if( zRight==0 ){\n          returnSingleInt(pParse, p->zName, (db->flags & p->mask)!=0 );\n        }else{\n          int mask = p->mask;          /* Mask of bits to set or clear. */\n          if( db->autoCommit==0 ){\n            /* Foreign key support may not be enabled or disabled while not\n            ** in auto-commit mode.  */\n            mask &= ~(SQLITE_ForeignKeys);\n          }\n\n          if( sqlite3GetBoolean(zRight, 0) ){\n            db->flags |= mask;\n          }else{\n            db->flags &= ~mask;\n          }\n\n          /* Many of the flag-pragmas modify the code generated by the SQL \n          ** compiler (eg. count_changes). So add an opcode to expire all\n          ** compiled SQL statements after modifying a pragma value.\n          */\n          sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);\n        }\n      }\n\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_FLAG_PRAGMAS */\n\n/*\n** Return a human-readable name for a constraint resolution action.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic const char *actionName(u8 action){\n  const char *zName;\n  switch( action ){\n    case OE_SetNull:  zName = \"SET NULL\";        break;\n    case OE_SetDflt:  zName = \"SET DEFAULT\";     break;\n    case OE_Cascade:  zName = \"CASCADE\";         break;\n    case OE_Restrict: zName = \"RESTRICT\";        break;\n    default:          zName = \"NO ACTION\";  \n                      assert( action==OE_None ); break;\n  }\n  return zName;\n}\n#endif\n\n\n/*\n** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants\n** defined in pager.h. This function returns the associated lowercase\n** journal-mode name.\n*/\nSQLITE_PRIVATE const char *sqlite3JournalModename(int eMode){\n  static char * const azModeName[] = {\n    \"delete\", \"persist\", \"off\", \"truncate\", \"memory\"\n#ifndef SQLITE_OMIT_WAL\n     , \"wal\"\n#endif\n  };\n  assert( PAGER_JOURNALMODE_DELETE==0 );\n  assert( PAGER_JOURNALMODE_PERSIST==1 );\n  assert( PAGER_JOURNALMODE_OFF==2 );\n  assert( PAGER_JOURNALMODE_TRUNCATE==3 );\n  assert( PAGER_JOURNALMODE_MEMORY==4 );\n  assert( PAGER_JOURNALMODE_WAL==5 );\n  assert( eMode>=0 && eMode<=ArraySize(azModeName) );\n\n  if( eMode==ArraySize(azModeName) ) return 0;\n  return azModeName[eMode];\n}\n\n/*\n** Process a pragma statement.  \n**\n** Pragmas are of this form:\n**\n**      PRAGMA [database.]id [= value]\n**\n** The identifier might also be a string.  The value is a string, and\n** identifier, or a number.  If minusFlag is true, then the value is\n** a number that was preceded by a minus sign.\n**\n** If the left side is \"database.id\" then pId1 is the database name\n** and pId2 is the id.  If the left side is just \"id\" then pId1 is the\n** id and pId2 is any empty string.\n*/\nSQLITE_PRIVATE void sqlite3Pragma(\n  Parse *pParse, \n  Token *pId1,        /* First part of [database.]id field */\n  Token *pId2,        /* Second part of [database.]id field, or NULL */\n  Token *pValue,      /* Token for <value>, or NULL */\n  int minusFlag       /* True if a '-' sign preceded <value> */\n){\n  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */\n  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */\n  const char *zDb = 0;   /* The database name */\n  Token *pId;            /* Pointer to <id> token */\n  int iDb;               /* Database index for <database> */\n  char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */\n  int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */\n  sqlite3 *db = pParse->db;    /* The database connection */\n  Db *pDb;                     /* The specific database being pragmaed */\n  Vdbe *v = sqlite3GetVdbe(pParse);  /* Prepared statement */\n\n  if( v==0 ) return;\n  sqlite3VdbeRunOnlyOnce(v);\n  pParse->nMem = 2;\n\n  /* Interpret the [database.] part of the pragma statement. iDb is the\n  ** index of the database this pragma is being applied to in db.aDb[]. */\n  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);\n  if( iDb<0 ) return;\n  pDb = &db->aDb[iDb];\n\n  /* If the temp database has been explicitly named as part of the \n  ** pragma, make sure it is open. \n  */\n  if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){\n    return;\n  }\n\n  zLeft = sqlite3NameFromToken(db, pId);\n  if( !zLeft ) return;\n  if( minusFlag ){\n    zRight = sqlite3MPrintf(db, \"-%T\", pValue);\n  }else{\n    zRight = sqlite3NameFromToken(db, pValue);\n  }\n\n  assert( pId2 );\n  zDb = pId2->n>0 ? pDb->zName : 0;\n  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){\n    goto pragma_out;\n  }\n\n  /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS\n  ** connection.  If it returns SQLITE_OK, then assume that the VFS\n  ** handled the pragma and generate a no-op prepared statement.\n  */\n  aFcntl[0] = 0;\n  aFcntl[1] = zLeft;\n  aFcntl[2] = zRight;\n  aFcntl[3] = 0;\n  db->busyHandler.nBusy = 0;\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);\n  if( rc==SQLITE_OK ){\n    if( aFcntl[0] ){\n      int mem = ++pParse->nMem;\n      sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);\n      sqlite3VdbeSetNumCols(v, 1);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"result\", SQLITE_STATIC);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);\n      sqlite3_free(aFcntl[0]);\n    }\n  }else if( rc!=SQLITE_NOTFOUND ){\n    if( aFcntl[0] ){\n      sqlite3ErrorMsg(pParse, \"%s\", aFcntl[0]);\n      sqlite3_free(aFcntl[0]);\n    }\n    pParse->nErr++;\n    pParse->rc = rc;\n  }else\n                            \n \n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n  /*\n  **  PRAGMA [database.]default_cache_size\n  **  PRAGMA [database.]default_cache_size=N\n  **\n  ** The first form reports the current persistent setting for the\n  ** page cache size.  The value returned is the maximum number of\n  ** pages in the page cache.  The second form sets both the current\n  ** page cache size value and the persistent page cache size value\n  ** stored in the database file.\n  **\n  ** Older versions of SQLite would set the default cache size to a\n  ** negative number to indicate synchronous=OFF.  These days, synchronous\n  ** is always on by default regardless of the sign of the default cache\n  ** size.  But continue to take the absolute value of the default cache\n  ** size of historical compatibility.\n  */\n  if( sqlite3StrICmp(zLeft,\"default_cache_size\")==0 ){\n    static const VdbeOpList getCacheSize[] = {\n      { OP_Transaction, 0, 0,        0},                         /* 0 */\n      { OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE},  /* 1 */\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 2,        0},\n      { OP_Subtract,    1, 2,        1},\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 1,        0},                         /* 6 */\n      { OP_Noop,        0, 0,        0},\n      { OP_ResultRow,   1, 1,        0},\n    };\n    int addr;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( !zRight ){\n      sqlite3VdbeSetNumCols(v, 1);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"cache_size\", SQLITE_STATIC);\n      pParse->nMem += 2;\n      addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);\n      sqlite3VdbeChangeP1(v, addr, iDb);\n      sqlite3VdbeChangeP1(v, addr+1, iDb);\n      sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE);\n    }else{\n      int size = sqlite3AbsInt32(sqlite3Atoi(zRight));\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3VdbeAddOp2(v, OP_Integer, size, 1);\n      sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, 1);\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n  }else\n#endif /* !SQLITE_OMIT_PAGER_PRAGMAS && !SQLITE_OMIT_DEPRECATED */\n\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n  /*\n  **  PRAGMA [database.]page_size\n  **  PRAGMA [database.]page_size=N\n  **\n  ** The first form reports the current setting for the\n  ** database page size in bytes.  The second form sets the\n  ** database page size value.  The value can only be set if\n  ** the database has not yet been created.\n  */\n  if( sqlite3StrICmp(zLeft,\"page_size\")==0 ){\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;\n      returnSingleInt(pParse, \"page_size\", size);\n    }else{\n      /* Malloc may fail when setting the page-size, as there is an internal\n      ** buffer that the pager module resizes using sqlite3_realloc().\n      */\n      db->nextPagesize = sqlite3Atoi(zRight);\n      if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){\n        db->mallocFailed = 1;\n      }\n    }\n  }else\n\n  /*\n  **  PRAGMA [database.]secure_delete\n  **  PRAGMA [database.]secure_delete=ON/OFF\n  **\n  ** The first form reports the current setting for the\n  ** secure_delete flag.  The second form changes the secure_delete\n  ** flag setting and reports thenew value.\n  */\n  if( sqlite3StrICmp(zLeft,\"secure_delete\")==0 ){\n    Btree *pBt = pDb->pBt;\n    int b = -1;\n    assert( pBt!=0 );\n    if( zRight ){\n      b = sqlite3GetBoolean(zRight, 0);\n    }\n    if( pId2->n==0 && b>=0 ){\n      int ii;\n      for(ii=0; ii<db->nDb; ii++){\n        sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);\n      }\n    }\n    b = sqlite3BtreeSecureDelete(pBt, b);\n    returnSingleInt(pParse, \"secure_delete\", b);\n  }else\n\n  /*\n  **  PRAGMA [database.]max_page_count\n  **  PRAGMA [database.]max_page_count=N\n  **\n  ** The first form reports the current setting for the\n  ** maximum number of pages in the database file.  The \n  ** second form attempts to change this setting.  Both\n  ** forms return the current setting.\n  **\n  ** The absolute value of N is used.  This is undocumented and might\n  ** change.  The only purpose is to provide an easy way to test\n  ** the sqlite3AbsInt32() function.\n  **\n  **  PRAGMA [database.]page_count\n  **\n  ** Return the number of pages in the specified database.\n  */\n  if( sqlite3StrICmp(zLeft,\"page_count\")==0\n   || sqlite3StrICmp(zLeft,\"max_page_count\")==0\n  ){\n    int iReg;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    iReg = ++pParse->nMem;\n    if( sqlite3Tolower(zLeft[0])=='p' ){\n      sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, \n                        sqlite3AbsInt32(sqlite3Atoi(zRight)));\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);\n  }else\n\n  /*\n  **  PRAGMA [database.]locking_mode\n  **  PRAGMA [database.]locking_mode = (normal|exclusive)\n  */\n  if( sqlite3StrICmp(zLeft,\"locking_mode\")==0 ){\n    const char *zRet = \"normal\";\n    int eMode = getLockingMode(zRight);\n\n    if( pId2->n==0 && eMode==PAGER_LOCKINGMODE_QUERY ){\n      /* Simple \"PRAGMA locking_mode;\" statement. This is a query for\n      ** the current default locking mode (which may be different to\n      ** the locking-mode of the main database).\n      */\n      eMode = db->dfltLockMode;\n    }else{\n      Pager *pPager;\n      if( pId2->n==0 ){\n        /* This indicates that no database name was specified as part\n        ** of the PRAGMA command. In this case the locking-mode must be\n        ** set on all attached databases, as well as the main db file.\n        **\n        ** Also, the sqlite3.dfltLockMode variable is set so that\n        ** any subsequently attached databases also use the specified\n        ** locking mode.\n        */\n        int ii;\n        assert(pDb==&db->aDb[0]);\n        for(ii=2; ii<db->nDb; ii++){\n          pPager = sqlite3BtreePager(db->aDb[ii].pBt);\n          sqlite3PagerLockingMode(pPager, eMode);\n        }\n        db->dfltLockMode = (u8)eMode;\n      }\n      pPager = sqlite3BtreePager(pDb->pBt);\n      eMode = sqlite3PagerLockingMode(pPager, eMode);\n    }\n\n    assert(eMode==PAGER_LOCKINGMODE_NORMAL||eMode==PAGER_LOCKINGMODE_EXCLUSIVE);\n    if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){\n      zRet = \"exclusive\";\n    }\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"locking_mode\", SQLITE_STATIC);\n    sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n  }else\n\n  /*\n  **  PRAGMA [database.]journal_mode\n  **  PRAGMA [database.]journal_mode =\n  **                      (delete|persist|off|truncate|memory|wal|off)\n  */\n  if( sqlite3StrICmp(zLeft,\"journal_mode\")==0 ){\n    int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */\n    int ii;           /* Loop counter */\n\n    /* Force the schema to be loaded on all databases.  This causes all\n    ** database files to be opened and the journal_modes set.  This is\n    ** necessary because subsequent processing must know if the databases\n    ** are in WAL mode. */\n    if( sqlite3ReadSchema(pParse) ){\n      goto pragma_out;\n    }\n\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"journal_mode\", SQLITE_STATIC);\n\n    if( zRight==0 ){\n      /* If there is no \"=MODE\" part of the pragma, do a query for the\n      ** current mode */\n      eMode = PAGER_JOURNALMODE_QUERY;\n    }else{\n      const char *zMode;\n      int n = sqlite3Strlen30(zRight);\n      for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){\n        if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;\n      }\n      if( !zMode ){\n        /* If the \"=MODE\" part does not match any known journal mode,\n        ** then do a query */\n        eMode = PAGER_JOURNALMODE_QUERY;\n      }\n    }\n    if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){\n      /* Convert \"PRAGMA journal_mode\" into \"PRAGMA main.journal_mode\" */\n      iDb = 0;\n      pId2->n = 1;\n    }\n    for(ii=db->nDb-1; ii>=0; ii--){\n      if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n        sqlite3VdbeUsesBtree(v, ii);\n        sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n  }else\n\n  /*\n  **  PRAGMA [database.]journal_size_limit\n  **  PRAGMA [database.]journal_size_limit=N\n  **\n  ** Get or set the size limit on rollback journal files.\n  */\n  if( sqlite3StrICmp(zLeft,\"journal_size_limit\")==0 ){\n    Pager *pPager = sqlite3BtreePager(pDb->pBt);\n    i64 iLimit = -2;\n    if( zRight ){\n      sqlite3Atoi64(zRight, &iLimit, 1000000, SQLITE_UTF8);\n      if( iLimit<-1 ) iLimit = -1;\n    }\n    iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);\n    returnSingleInt(pParse, \"journal_size_limit\", iLimit);\n  }else\n\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n  /*\n  **  PRAGMA [database.]auto_vacuum\n  **  PRAGMA [database.]auto_vacuum=N\n  **\n  ** Get or set the value of the database 'auto-vacuum' parameter.\n  ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  if( sqlite3StrICmp(zLeft,\"auto_vacuum\")==0 ){\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( sqlite3ReadSchema(pParse) ){\n      goto pragma_out;\n    }\n    if( !zRight ){\n      int auto_vacuum;\n      if( ALWAYS(pBt) ){\n         auto_vacuum = sqlite3BtreeGetAutoVacuum(pBt);\n      }else{\n         auto_vacuum = SQLITE_DEFAULT_AUTOVACUUM;\n      }\n      returnSingleInt(pParse, \"auto_vacuum\", auto_vacuum);\n    }else{\n      int eAuto = getAutoVacuum(zRight);\n      assert( eAuto>=0 && eAuto<=2 );\n      db->nextAutovac = (u8)eAuto;\n      if( ALWAYS(eAuto>=0) ){\n        /* Call SetAutoVacuum() to set initialize the internal auto and\n        ** incr-vacuum flags. This is required in case this connection\n        ** creates the database file. It is important that it is created\n        ** as an auto-vacuum capable db.\n        */\n        rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);\n        if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){\n          /* When setting the auto_vacuum mode to either \"full\" or \n          ** \"incremental\", write the value of meta[6] in the database\n          ** file. Before writing to meta[6], check that meta[3] indicates\n          ** that this really is an auto-vacuum capable database.\n          */\n          static const VdbeOpList setMeta6[] = {\n            { OP_Transaction,    0,         1,                 0},    /* 0 */\n            { OP_ReadCookie,     0,         1,         BTREE_LARGEST_ROOT_PAGE},\n            { OP_If,             1,         0,                 0},    /* 2 */\n            { OP_Halt,           SQLITE_OK, OE_Abort,          0},    /* 3 */\n            { OP_Integer,        0,         1,                 0},    /* 4 */\n            { OP_SetCookie,      0,         BTREE_INCR_VACUUM, 1},    /* 5 */\n          };\n          int iAddr;\n          iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6);\n          sqlite3VdbeChangeP1(v, iAddr, iDb);\n          sqlite3VdbeChangeP1(v, iAddr+1, iDb);\n          sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4);\n          sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1);\n          sqlite3VdbeChangeP1(v, iAddr+5, iDb);\n          sqlite3VdbeUsesBtree(v, iDb);\n        }\n      }\n    }\n  }else\n#endif\n\n  /*\n  **  PRAGMA [database.]incremental_vacuum(N)\n  **\n  ** Do N steps of incremental vacuuming on a database.\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  if( sqlite3StrICmp(zLeft,\"incremental_vacuum\")==0 ){\n    int iLimit, addr;\n    if( sqlite3ReadSchema(pParse) ){\n      goto pragma_out;\n    }\n    if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){\n      iLimit = 0x7fffffff;\n    }\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);\n    addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb);\n    sqlite3VdbeAddOp1(v, OP_ResultRow, 1);\n    sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);\n    sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr);\n    sqlite3VdbeJumpHere(v, addr);\n  }else\n#endif\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n  /*\n  **  PRAGMA [database.]cache_size\n  **  PRAGMA [database.]cache_size=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache size. The second form sets the local\n  ** page cache size value.  If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  */\n  if( sqlite3StrICmp(zLeft,\"cache_size\")==0 ){\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(pParse, \"cache_size\", pDb->pSchema->cache_size);\n    }else{\n      int size = sqlite3Atoi(zRight);\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n  }else\n\n  /*\n  **  PRAGMA [database.]mmap_size(N)\n  **\n  ** Used to set mapping size limit. The mapping size limit is\n  ** used to limit the aggregate size of all memory mapped regions of the\n  ** database file. If this parameter is set to zero, then memory mapping\n  ** is not used at all.  If N is negative, then the default memory map\n  ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set.\n  ** The parameter N is measured in bytes.\n  **\n  ** This value is advisory.  The underlying VFS is free to memory map\n  ** as little or as much as it wants.  Except, if N is set to 0 then the\n  ** upper layers will never invoke the xFetch interfaces to the VFS.\n  */\n  if( sqlite3StrICmp(zLeft,\"mmap_size\")==0 ){\n    sqlite3_int64 sz;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( zRight ){\n      int ii;\n      sqlite3Atoi64(zRight, &sz, 1000, SQLITE_UTF8);\n      if( sz<0 ) sz = sqlite3GlobalConfig.szMmap;\n      if( pId2->n==0 ) db->szMmap = sz;\n      for(ii=db->nDb-1; ii>=0; ii--){\n        if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n          sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz);\n        }\n      }\n    }\n    sz = -1;\n    if( sqlite3_file_control(db,zDb,SQLITE_FCNTL_MMAP_SIZE,&sz)==SQLITE_OK ){\n#if SQLITE_MAX_MMAP_SIZE==0\n      sz = 0;\n#endif\n      returnSingleInt(pParse, \"mmap_size\", sz);\n    }\n  }else\n\n  /*\n  **   PRAGMA temp_store\n  **   PRAGMA temp_store = \"default\"|\"memory\"|\"file\"\n  **\n  ** Return or set the local value of the temp_store flag.  Changing\n  ** the local value does not make changes to the disk file and the default\n  ** value will be restored the next time the database is opened.\n  **\n  ** Note that it is possible for the library compile-time options to\n  ** override this setting\n  */\n  if( sqlite3StrICmp(zLeft, \"temp_store\")==0 ){\n    if( !zRight ){\n      returnSingleInt(pParse, \"temp_store\", db->temp_store);\n    }else{\n      changeTempStorage(pParse, zRight);\n    }\n  }else\n\n  /*\n  **   PRAGMA temp_store_directory\n  **   PRAGMA temp_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the temp_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for temporary files.\n  ** Setting to a null string reverts to the default temporary directory search.\n  ** If temporary directory is changed, then invalidateTempStorage.\n  **\n  */\n  if( sqlite3StrICmp(zLeft, \"temp_store_directory\")==0 ){\n    if( !zRight ){\n      if( sqlite3_temp_directory ){\n        sqlite3VdbeSetNumCols(v, 1);\n        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \n            \"temp_store_directory\", SQLITE_STATIC);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n      }\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      if( SQLITE_TEMP_STORE==0\n       || (SQLITE_TEMP_STORE==1 && db->temp_store<=1)\n       || (SQLITE_TEMP_STORE==2 && db->temp_store==1)\n      ){\n        invalidateTempStorage(pParse);\n      }\n      sqlite3_free(sqlite3_temp_directory);\n      if( zRight[0] ){\n        sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_temp_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n  }else\n\n#if SQLITE_OS_WIN\n  /*\n  **   PRAGMA data_store_directory\n  **   PRAGMA data_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the data_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for database files that\n  ** were specified with a relative pathname.  Setting to a null string reverts\n  ** to the default database directory, which for database files specified with\n  ** a relative path will probably be based on the current directory for the\n  ** process.  Database file specified with an absolute path are not impacted\n  ** by this setting, regardless of its value.\n  **\n  */\n  if( sqlite3StrICmp(zLeft, \"data_store_directory\")==0 ){\n    if( !zRight ){\n      if( sqlite3_data_directory ){\n        sqlite3VdbeSetNumCols(v, 1);\n        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \n            \"data_store_directory\", SQLITE_STATIC);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_data_directory, 0);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n      }\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      sqlite3_free(sqlite3_data_directory);\n      if( zRight[0] ){\n        sqlite3_data_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_data_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n  }else\n#endif\n\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n  /*\n   **   PRAGMA [database.]lock_proxy_file\n   **   PRAGMA [database.]lock_proxy_file = \":auto:\"|\"lock_file_path\"\n   **\n   ** Return or set the value of the lock_proxy_file flag.  Changing\n   ** the value sets a specific file to be used for database access locks.\n   **\n   */\n  if( sqlite3StrICmp(zLeft, \"lock_proxy_file\")==0 ){\n    if( !zRight ){\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      char *proxy_file_path = NULL;\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, \n                           &proxy_file_path);\n      \n      if( proxy_file_path ){\n        sqlite3VdbeSetNumCols(v, 1);\n        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \n                              \"lock_proxy_file\", SQLITE_STATIC);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, proxy_file_path, 0);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n      }\n    }else{\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      int res;\n      if( zRight[0] ){\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     zRight);\n      } else {\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     NULL);\n      }\n      if( res!=SQLITE_OK ){\n        sqlite3ErrorMsg(pParse, \"failed to set lock proxy file\");\n        goto pragma_out;\n      }\n    }\n  }else\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */      \n    \n  /*\n  **   PRAGMA [database.]synchronous\n  **   PRAGMA [database.]synchronous=OFF|ON|NORMAL|FULL\n  **\n  ** Return or set the local value of the synchronous flag.  Changing\n  ** the local value does not make changes to the disk file and the\n  ** default value will be restored the next time the database is\n  ** opened.\n  */\n  if( sqlite3StrICmp(zLeft,\"synchronous\")==0 ){\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    if( !zRight ){\n      returnSingleInt(pParse, \"synchronous\", pDb->safety_level-1);\n    }else{\n      if( !db->autoCommit ){\n        sqlite3ErrorMsg(pParse, \n            \"Safety level may not be changed inside a transaction\");\n      }else{\n        pDb->safety_level = getSafetyLevel(zRight,0,1)+1;\n      }\n    }\n  }else\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FLAG_PRAGMAS\n  if( flagPragma(pParse, zLeft, zRight) ){\n    /* The flagPragma() subroutine also generates any necessary code\n    ** there is nothing more to do here */\n  }else\n#endif /* SQLITE_OMIT_FLAG_PRAGMAS */\n\n#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS\n  /*\n  **   PRAGMA table_info(<table>)\n  **\n  ** Return a single row for each column of the named table. The columns of\n  ** the returned data set are:\n  **\n  ** cid:        Column id (numbered from left to right, starting at 0)\n  ** name:       Column name\n  ** type:       Column declaration type.\n  ** notnull:    True if 'NOT NULL' is part of column declaration\n  ** dflt_value: The default value for the column, if any.\n  */\n  if( sqlite3StrICmp(zLeft, \"table_info\")==0 && zRight ){\n    Table *pTab;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      int i, k;\n      int nHidden = 0;\n      Column *pCol;\n      Index *pPk;\n      for(pPk=pTab->pIndex; pPk && pPk->autoIndex!=2; pPk=pPk->pNext){}\n      sqlite3VdbeSetNumCols(v, 6);\n      pParse->nMem = 6;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"cid\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"name\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"type\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 3, COLNAME_NAME, \"notnull\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 4, COLNAME_NAME, \"dflt_value\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 5, COLNAME_NAME, \"pk\", SQLITE_STATIC);\n      sqlite3ViewGetColumnNames(pParse, pTab);\n      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n        if( IsHiddenColumn(pCol) ){\n          nHidden++;\n          continue;\n        }\n        sqlite3VdbeAddOp2(v, OP_Integer, i-nHidden, 1);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n           pCol->zType ? pCol->zType : \"\", 0);\n        sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4);\n        if( pCol->zDflt ){\n          sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pCol->zDflt, 0);\n        }else{\n          sqlite3VdbeAddOp2(v, OP_Null, 0, 5);\n        }\n        if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){\n          k = 0;\n        }else if( pPk==0 ){\n          k = 1;\n        }else{\n          for(k=1; ALWAYS(k<=pTab->nCol) && pPk->aiColumn[k-1]!=i; k++){}\n        }\n        sqlite3VdbeAddOp2(v, OP_Integer, k, 6);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);\n      }\n    }\n  }else\n\n  if( sqlite3StrICmp(zLeft, \"index_info\")==0 && zRight ){\n    Index *pIdx;\n    Table *pTab;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    pIdx = sqlite3FindIndex(db, zRight, zDb);\n    if( pIdx ){\n      int i;\n      pTab = pIdx->pTable;\n      sqlite3VdbeSetNumCols(v, 3);\n      pParse->nMem = 3;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"seqno\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"cid\", SQLITE_STATIC);\n      sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"name\", SQLITE_STATIC);\n      for(i=0; i<pIdx->nColumn; i++){\n        int cnum = pIdx->aiColumn[i];\n        sqlite3VdbeAddOp2(v, OP_Integer, i, 1);\n        sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);\n        assert( pTab->nCol>cnum );\n        sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n      }\n    }\n  }else\n\n  if( sqlite3StrICmp(zLeft, \"index_list\")==0 && zRight ){\n    Index *pIdx;\n    Table *pTab;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      v = sqlite3GetVdbe(pParse);\n      pIdx = pTab->pIndex;\n      if( pIdx ){\n        int i = 0; \n        sqlite3VdbeSetNumCols(v, 3);\n        pParse->nMem = 3;\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"seq\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"name\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"unique\", SQLITE_STATIC);\n        while(pIdx){\n          sqlite3VdbeAddOp2(v, OP_Integer, i, 1);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);\n          sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);\n          sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n          ++i;\n          pIdx = pIdx->pNext;\n        }\n      }\n    }\n  }else\n\n  if( sqlite3StrICmp(zLeft, \"database_list\")==0 ){\n    int i;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    sqlite3VdbeSetNumCols(v, 3);\n    pParse->nMem = 3;\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"seq\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"name\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"file\", SQLITE_STATIC);\n    for(i=0; i<db->nDb; i++){\n      if( db->aDb[i].pBt==0 ) continue;\n      assert( db->aDb[i].zName!=0 );\n      sqlite3VdbeAddOp2(v, OP_Integer, i, 1);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, db->aDb[i].zName, 0);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n           sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n    }\n  }else\n\n  if( sqlite3StrICmp(zLeft, \"collation_list\")==0 ){\n    int i = 0;\n    HashElem *p;\n    sqlite3VdbeSetNumCols(v, 2);\n    pParse->nMem = 2;\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"seq\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"name\", SQLITE_STATIC);\n    for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){\n      CollSeq *pColl = (CollSeq *)sqliteHashData(p);\n      sqlite3VdbeAddOp2(v, OP_Integer, i++, 1);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl->zName, 0);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);\n    }\n  }else\n#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  if( sqlite3StrICmp(zLeft, \"foreign_key_list\")==0 && zRight ){\n    FKey *pFK;\n    Table *pTab;\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      v = sqlite3GetVdbe(pParse);\n      pFK = pTab->pFKey;\n      if( pFK ){\n        int i = 0; \n        sqlite3VdbeSetNumCols(v, 8);\n        pParse->nMem = 8;\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"id\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"seq\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"table\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 3, COLNAME_NAME, \"from\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 4, COLNAME_NAME, \"to\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 5, COLNAME_NAME, \"on_update\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 6, COLNAME_NAME, \"on_delete\", SQLITE_STATIC);\n        sqlite3VdbeSetColName(v, 7, COLNAME_NAME, \"match\", SQLITE_STATIC);\n        while(pFK){\n          int j;\n          for(j=0; j<pFK->nCol; j++){\n            char *zCol = pFK->aCol[j].zCol;\n            char *zOnDelete = (char *)actionName(pFK->aAction[0]);\n            char *zOnUpdate = (char *)actionName(pFK->aAction[1]);\n            sqlite3VdbeAddOp2(v, OP_Integer, i, 1);\n            sqlite3VdbeAddOp2(v, OP_Integer, j, 2);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0,\n                              pTab->aCol[pFK->aCol[j].iFrom].zName, 0);\n            sqlite3VdbeAddOp4(v, zCol ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, \"NONE\", 0);\n            sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);\n          }\n          ++i;\n          pFK = pFK->pNextFrom;\n        }\n      }\n    }\n  }else\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n  if( sqlite3StrICmp(zLeft, \"foreign_key_check\")==0 ){\n    FKey *pFK;             /* A foreign key constraint */\n    Table *pTab;           /* Child table contain \"REFERENCES\" keyword */\n    Table *pParent;        /* Parent table that child points to */\n    Index *pIdx;           /* Index in the parent table */\n    int i;                 /* Loop counter:  Foreign key number for pTab */\n    int j;                 /* Loop counter:  Field of the foreign key */\n    HashElem *k;           /* Loop counter:  Next table in schema */\n    int x;                 /* result variable */\n    int regResult;         /* 3 registers to hold a result row */\n    int regKey;            /* Register to hold key for checking the FK */\n    int regRow;            /* Registers to hold a row from pTab */\n    int addrTop;           /* Top of a loop checking foreign keys */\n    int addrOk;            /* Jump here if the key is OK */\n    int *aiCols;           /* child to parent column mapping */\n\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    regResult = pParse->nMem+1;\n    pParse->nMem += 4;\n    regKey = ++pParse->nMem;\n    regRow = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    sqlite3VdbeSetNumCols(v, 4);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"table\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"rowid\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"parent\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 3, COLNAME_NAME, \"fkid\", SQLITE_STATIC);\n    sqlite3CodeVerifySchema(pParse, iDb);\n    k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);\n    while( k ){\n      if( zRight ){\n        pTab = sqlite3LocateTable(pParse, 0, zRight, zDb);\n        k = 0;\n      }else{\n        pTab = (Table*)sqliteHashData(k);\n        k = sqliteHashNext(k);\n      }\n      if( pTab==0 || pTab->pFKey==0 ) continue;\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n      if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;\n      sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,\n                        P4_TRANSIENT);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);\n        if( pParent==0 ) break;\n        pIdx = 0;\n        sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);\n        x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);\n        if( x==0 ){\n          if( pIdx==0 ){\n            sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead);\n          }else{\n            KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);\n            sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);\n            sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF);\n          }\n        }else{\n          k = 0;\n          break;\n        }\n      }\n      if( pFK ) break;\n      if( pParse->nTab<i ) pParse->nTab = i;\n      addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);\n        assert( pParent!=0 );\n        pIdx = 0;\n        aiCols = 0;\n        x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);\n        assert( x==0 );\n        addrOk = sqlite3VdbeMakeLabel(v);\n        if( pIdx==0 ){\n          int iKey = pFK->aCol[0].iFrom;\n          assert( iKey>=0 && iKey<pTab->nCol );\n          if( iKey!=pTab->iPKey ){\n            sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);\n            sqlite3ColumnDefault(v, pTab, iKey, regRow);\n            sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk);\n            sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow,\n               sqlite3VdbeCurrentAddr(v)+3);\n          }else{\n            sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow);\n          }\n          sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow);\n          sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);\n          sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n        }else{\n          for(j=0; j<pFK->nCol; j++){\n            sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,\n                            aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);\n            sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);\n          }\n          sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);\n          sqlite3VdbeChangeP4(v, -1,\n                   sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);\n          sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);\n        }\n        sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);\n        sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, \n                          pFK->zTo, P4_TRANSIENT);\n        sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);\n        sqlite3VdbeResolveLabel(v, addrOk);\n        sqlite3DbFree(db, aiCols);\n      }\n      sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1);\n      sqlite3VdbeJumpHere(v, addrTop);\n    }\n  }else\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef NDEBUG\n  if( sqlite3StrICmp(zLeft, \"parser_trace\")==0 ){\n    if( zRight ){\n      if( sqlite3GetBoolean(zRight, 0) ){\n        sqlite3ParserTrace(stderr, \"parser: \");\n      }else{\n        sqlite3ParserTrace(0, 0);\n      }\n    }\n  }else\n#endif\n\n  /* Reinstall the LIKE and GLOB functions.  The variant of LIKE\n  ** used will be case sensitive or not depending on the RHS.\n  */\n  if( sqlite3StrICmp(zLeft, \"case_sensitive_like\")==0 ){\n    if( zRight ){\n      sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0));\n    }\n  }else\n\n#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100\n#endif\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n  /* Pragma \"quick_check\" is an experimental reduced version of \n  ** integrity_check designed to detect most database corruption\n  ** without most of the overhead of a full integrity-check.\n  */\n  if( sqlite3StrICmp(zLeft, \"integrity_check\")==0\n   || sqlite3StrICmp(zLeft, \"quick_check\")==0 \n  ){\n    int i, j, addr, mxErr;\n\n    /* Code that appears at the end of the integrity check.  If no error\n    ** messages have been generated, output OK.  Otherwise output the\n    ** error message\n    */\n    static const VdbeOpList endCode[] = {\n      { OP_AddImm,      1, 0,        0},    /* 0 */\n      { OP_IfNeg,       1, 0,        0},    /* 1 */\n      { OP_String8,     0, 3,        0},    /* 2 */\n      { OP_ResultRow,   3, 1,        0},\n    };\n\n    int isQuick = (sqlite3Tolower(zLeft[0])=='q');\n\n    /* If the PRAGMA command was of the form \"PRAGMA <db>.integrity_check\",\n    ** then iDb is set to the index of the database identified by <db>.\n    ** In this case, the integrity of database iDb only is verified by\n    ** the VDBE created below.\n    **\n    ** Otherwise, if the command was simply \"PRAGMA integrity_check\" (or\n    ** \"PRAGMA quick_check\"), then iDb is set to 0. In this case, set iDb\n    ** to -1 here, to indicate that the VDBE should verify the integrity\n    ** of all attached databases.  */\n    assert( iDb>=0 );\n    assert( iDb==0 || pId2->z );\n    if( pId2->z==0 ) iDb = -1;\n\n    /* Initialize the VDBE program */\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    pParse->nMem = 6;\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"integrity_check\", SQLITE_STATIC);\n\n    /* Set the maximum error count */\n    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n    if( zRight ){\n      sqlite3GetInt32(zRight, &mxErr);\n      if( mxErr<=0 ){\n        mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1);  /* reg[1] holds errors left */\n\n    /* Do an integrity check on each database file */\n    for(i=0; i<db->nDb; i++){\n      HashElem *x;\n      Hash *pTbls;\n      int cnt = 0;\n\n      if( OMIT_TEMPDB && i==1 ) continue;\n      if( iDb>=0 && i!=iDb ) continue;\n\n      sqlite3CodeVerifySchema(pParse, i);\n      addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */\n      sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);\n      sqlite3VdbeJumpHere(v, addr);\n\n      /* Do an integrity check of the B-Tree\n      **\n      ** Begin by filling registers 2, 3, ... with the root pages numbers\n      ** for all tables and indices in the database.\n      */\n      assert( sqlite3SchemaMutexHeld(db, i, 0) );\n      pTbls = &db->aDb[i].pSchema->tblHash;\n      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx;\n        sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt);\n        cnt++;\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt);\n          cnt++;\n        }\n      }\n\n      /* Make sure sufficient number of registers have been allocated */\n      if( pParse->nMem < cnt+4 ){\n        pParse->nMem = cnt+4;\n      }\n\n      /* Do the b-tree integrity checks */\n      sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1);\n      sqlite3VdbeChangeP5(v, (u8)i);\n      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n         sqlite3MPrintf(db, \"*** in database %s ***\\n\", db->aDb[i].zName),\n         P4_DYNAMIC);\n      sqlite3VdbeAddOp2(v, OP_Move, 2, 4);\n      sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1);\n      sqlite3VdbeJumpHere(v, addr);\n\n      /* Make sure all the indices are constructed correctly.\n      */\n      for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx;\n        int loopTop;\n\n        if( pTab->pIndex==0 ) continue;\n        addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);  /* Stop if out of errors */\n        sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);\n        sqlite3VdbeJumpHere(v, addr);\n        sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, 2);  /* reg(2) will count entries */\n        loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);\n        sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1);   /* increment entry count */\n        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n          int jmp2;\n          int r1;\n          static const VdbeOpList idxErr[] = {\n            { OP_AddImm,      1, -1,  0},\n            { OP_String8,     0,  3,  0},    /* 1 */\n            { OP_Rowid,       1,  4,  0},\n            { OP_String8,     0,  5,  0},    /* 3 */\n            { OP_String8,     0,  6,  0},    /* 4 */\n            { OP_Concat,      4,  3,  3},\n            { OP_Concat,      5,  3,  3},\n            { OP_Concat,      6,  3,  3},\n            { OP_ResultRow,   3,  1,  0},\n            { OP_IfPos,       1,  0,  0},    /* 9 */\n            { OP_Halt,        0,  0,  0},\n          };\n          r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0);\n          jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1);\n          addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);\n          sqlite3VdbeChangeP4(v, addr+1, \"rowid \", P4_STATIC);\n          sqlite3VdbeChangeP4(v, addr+3, \" missing from index \", P4_STATIC);\n          sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT);\n          sqlite3VdbeJumpHere(v, addr+9);\n          sqlite3VdbeJumpHere(v, jmp2);\n        }\n        sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1);\n        sqlite3VdbeJumpHere(v, loopTop);\n        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n          static const VdbeOpList cntIdx[] = {\n             { OP_Integer,      0,  3,  0},\n             { OP_Rewind,       0,  0,  0},  /* 1 */\n             { OP_AddImm,       3,  1,  0},\n             { OP_Next,         0,  0,  0},  /* 3 */\n             { OP_Eq,           2,  0,  3},  /* 4 */\n             { OP_AddImm,       1, -1,  0},\n             { OP_String8,      0,  2,  0},  /* 6 */\n             { OP_String8,      0,  3,  0},  /* 7 */\n             { OP_Concat,       3,  2,  2},\n             { OP_ResultRow,    2,  1,  0},\n          };\n          addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1);\n          sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);\n          sqlite3VdbeJumpHere(v, addr);\n          addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);\n          sqlite3VdbeChangeP1(v, addr+1, j+2);\n          sqlite3VdbeChangeP2(v, addr+1, addr+4);\n          sqlite3VdbeChangeP1(v, addr+3, j+2);\n          sqlite3VdbeChangeP2(v, addr+3, addr+2);\n          sqlite3VdbeJumpHere(v, addr+4);\n          sqlite3VdbeChangeP4(v, addr+6, \n                     \"wrong # of entries in index \", P4_STATIC);\n          sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT);\n        }\n      } \n    }\n    addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);\n    sqlite3VdbeChangeP2(v, addr, -mxErr);\n    sqlite3VdbeJumpHere(v, addr+1);\n    sqlite3VdbeChangeP4(v, addr+2, \"ok\", P4_STATIC);\n  }else\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_UTF16\n  /*\n  **   PRAGMA encoding\n  **   PRAGMA encoding = \"utf-8\"|\"utf-16\"|\"utf-16le\"|\"utf-16be\"\n  **\n  ** In its first form, this pragma returns the encoding of the main\n  ** database. If the database is not initialized, it is initialized now.\n  **\n  ** The second form of this pragma is a no-op if the main database file\n  ** has not already been initialized. In this case it sets the default\n  ** encoding that will be used for the main database file if a new file\n  ** is created. If an existing main database file is opened, then the\n  ** default text encoding for the existing database is used.\n  ** \n  ** In all cases new databases created using the ATTACH command are\n  ** created to use the same default text encoding as the main database. If\n  ** the main database has not been initialized and/or created when ATTACH\n  ** is executed, this is done before the ATTACH operation.\n  **\n  ** In the second form this pragma sets the text encoding to be used in\n  ** new database files created using this database handle. It is only\n  ** useful if invoked immediately after the main database i\n  */\n  if( sqlite3StrICmp(zLeft, \"encoding\")==0 ){\n    static const struct EncName {\n      char *zName;\n      u8 enc;\n    } encnames[] = {\n      { \"UTF8\",     SQLITE_UTF8        },\n      { \"UTF-8\",    SQLITE_UTF8        },  /* Must be element [1] */\n      { \"UTF-16le\", SQLITE_UTF16LE     },  /* Must be element [2] */\n      { \"UTF-16be\", SQLITE_UTF16BE     },  /* Must be element [3] */\n      { \"UTF16le\",  SQLITE_UTF16LE     },\n      { \"UTF16be\",  SQLITE_UTF16BE     },\n      { \"UTF-16\",   0                  }, /* SQLITE_UTF16NATIVE */\n      { \"UTF16\",    0                  }, /* SQLITE_UTF16NATIVE */\n      { 0, 0 }\n    };\n    const struct EncName *pEnc;\n    if( !zRight ){    /* \"PRAGMA encoding\" */\n      if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n      sqlite3VdbeSetNumCols(v, 1);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"encoding\", SQLITE_STATIC);\n      sqlite3VdbeAddOp2(v, OP_String8, 0, 1);\n      assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );\n      assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );\n      assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );\n      sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse->db)].zName, P4_STATIC);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    }else{                        /* \"PRAGMA encoding = XXX\" */\n      /* Only change the value of sqlite.enc if the database handle is not\n      ** initialized. If the main database exists, the new sqlite.enc value\n      ** will be overwritten when the schema is next loaded. If it does not\n      ** already exists, it will be created to use the new encoding value.\n      */\n      if( \n        !(DbHasProperty(db, 0, DB_SchemaLoaded)) || \n        DbHasProperty(db, 0, DB_Empty) \n      ){\n        for(pEnc=&encnames[0]; pEnc->zName; pEnc++){\n          if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){\n            ENC(pParse->db) = pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;\n            break;\n          }\n        }\n        if( !pEnc->zName ){\n          sqlite3ErrorMsg(pParse, \"unsupported encoding: %s\", zRight);\n        }\n      }\n    }\n  }else\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  /*\n  **   PRAGMA [database.]schema_version\n  **   PRAGMA [database.]schema_version = <integer>\n  **\n  **   PRAGMA [database.]user_version\n  **   PRAGMA [database.]user_version = <integer>\n  **\n  **   PRAGMA [database.]freelist_count = <integer>\n  **\n  **   PRAGMA [database.]application_id\n  **   PRAGMA [database.]application_id = <integer>\n  **\n  ** The pragma's schema_version and user_version are used to set or get\n  ** the value of the schema-version and user-version, respectively. Both\n  ** the schema-version and the user-version are 32-bit signed integers\n  ** stored in the database header.\n  **\n  ** The schema-cookie is usually only manipulated internally by SQLite. It\n  ** is incremented by SQLite whenever the database schema is modified (by\n  ** creating or dropping a table or index). The schema version is used by\n  ** SQLite each time a query is executed to ensure that the internal cache\n  ** of the schema used when compiling the SQL query matches the schema of\n  ** the database against which the compiled query is actually executed.\n  ** Subverting this mechanism by using \"PRAGMA schema_version\" to modify\n  ** the schema-version is potentially dangerous and may lead to program\n  ** crashes or database corruption. Use with caution!\n  **\n  ** The user-version is not used internally by SQLite. It may be used by\n  ** applications for any purpose.\n  */\n  if( sqlite3StrICmp(zLeft, \"schema_version\")==0 \n   || sqlite3StrICmp(zLeft, \"user_version\")==0 \n   || sqlite3StrICmp(zLeft, \"freelist_count\")==0 \n   || sqlite3StrICmp(zLeft, \"application_id\")==0 \n  ){\n    int iCookie;   /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */\n    sqlite3VdbeUsesBtree(v, iDb);\n    switch( zLeft[0] ){\n      case 'a': case 'A':\n        iCookie = BTREE_APPLICATION_ID;\n        break;\n      case 'f': case 'F':\n        iCookie = BTREE_FREE_PAGE_COUNT;\n        break;\n      case 's': case 'S':\n        iCookie = BTREE_SCHEMA_VERSION;\n        break;\n      default:\n        iCookie = BTREE_USER_VERSION;\n        break;\n    }\n\n    if( zRight && iCookie!=BTREE_FREE_PAGE_COUNT ){\n      /* Write the specified cookie value */\n      static const VdbeOpList setCookie[] = {\n        { OP_Transaction,    0,  1,  0},    /* 0 */\n        { OP_Integer,        0,  1,  0},    /* 1 */\n        { OP_SetCookie,      0,  0,  1},    /* 2 */\n      };\n      int addr = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie);\n      sqlite3VdbeChangeP1(v, addr, iDb);\n      sqlite3VdbeChangeP1(v, addr+1, sqlite3Atoi(zRight));\n      sqlite3VdbeChangeP1(v, addr+2, iDb);\n      sqlite3VdbeChangeP2(v, addr+2, iCookie);\n    }else{\n      /* Read the specified cookie value */\n      static const VdbeOpList readCookie[] = {\n        { OP_Transaction,     0,  0,  0},    /* 0 */\n        { OP_ReadCookie,      0,  1,  0},    /* 1 */\n        { OP_ResultRow,       1,  1,  0}\n      };\n      int addr = sqlite3VdbeAddOpList(v, ArraySize(readCookie), readCookie);\n      sqlite3VdbeChangeP1(v, addr, iDb);\n      sqlite3VdbeChangeP1(v, addr+1, iDb);\n      sqlite3VdbeChangeP3(v, addr+1, iCookie);\n      sqlite3VdbeSetNumCols(v, 1);\n      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLeft, SQLITE_TRANSIENT);\n    }\n  }else\n#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  /*\n  **   PRAGMA compile_options\n  **\n  ** Return the names of all compile-time options used in this build,\n  ** one option per row.\n  */\n  if( sqlite3StrICmp(zLeft, \"compile_options\")==0 ){\n    int i = 0;\n    const char *zOpt;\n    sqlite3VdbeSetNumCols(v, 1);\n    pParse->nMem = 1;\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"compile_option\", SQLITE_STATIC);\n    while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    }\n  }else\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n#ifndef SQLITE_OMIT_WAL\n  /*\n  **   PRAGMA [database.]wal_checkpoint = passive|full|restart\n  **\n  ** Checkpoint the database.\n  */\n  if( sqlite3StrICmp(zLeft, \"wal_checkpoint\")==0 ){\n    int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);\n    int eMode = SQLITE_CHECKPOINT_PASSIVE;\n    if( zRight ){\n      if( sqlite3StrICmp(zRight, \"full\")==0 ){\n        eMode = SQLITE_CHECKPOINT_FULL;\n      }else if( sqlite3StrICmp(zRight, \"restart\")==0 ){\n        eMode = SQLITE_CHECKPOINT_RESTART;\n      }\n    }\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n    sqlite3VdbeSetNumCols(v, 3);\n    pParse->nMem = 3;\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"busy\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"log\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 2, COLNAME_NAME, \"checkpointed\", SQLITE_STATIC);\n\n    sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n  }else\n\n  /*\n  **   PRAGMA wal_autocheckpoint\n  **   PRAGMA wal_autocheckpoint = N\n  **\n  ** Configure a database connection to automatically checkpoint a database\n  ** after accumulating N frames in the log. Or query for the current value\n  ** of N.\n  */\n  if( sqlite3StrICmp(zLeft, \"wal_autocheckpoint\")==0 ){\n    if( zRight ){\n      sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(pParse, \"wal_autocheckpoint\", \n       db->xWalCallback==sqlite3WalDefaultHook ? \n           SQLITE_PTR_TO_INT(db->pWalArg) : 0);\n  }else\n#endif\n\n  /*\n  **  PRAGMA shrink_memory\n  **\n  ** This pragma attempts to free as much memory as possible from the\n  ** current database connection.\n  */\n  if( sqlite3StrICmp(zLeft, \"shrink_memory\")==0 ){\n    sqlite3_db_release_memory(db);\n  }else\n\n  /*\n  **   PRAGMA busy_timeout\n  **   PRAGMA busy_timeout = N\n  **\n  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value\n  ** if one is set.  If no busy handler or a different busy handler is set\n  ** then 0 is returned.  Setting the busy_timeout to 0 or negative\n  ** disables the timeout.\n  */\n  if( sqlite3StrICmp(zLeft, \"busy_timeout\")==0 ){\n    if( zRight ){\n      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(pParse, \"timeout\",  db->busyTimeout);\n  }else\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Report the current state of file logs for all databases\n  */\n  if( sqlite3StrICmp(zLeft, \"lock_status\")==0 ){\n    static const char *const azLockName[] = {\n      \"unlocked\", \"shared\", \"reserved\", \"pending\", \"exclusive\"\n    };\n    int i;\n    sqlite3VdbeSetNumCols(v, 2);\n    pParse->nMem = 2;\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"database\", SQLITE_STATIC);\n    sqlite3VdbeSetColName(v, 1, COLNAME_NAME, \"status\", SQLITE_STATIC);\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt;\n      const char *zState = \"unknown\";\n      int j;\n      if( db->aDb[i].zName==0 ) continue;\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC);\n      pBt = db->aDb[i].pBt;\n      if( pBt==0 || sqlite3BtreePager(pBt)==0 ){\n        zState = \"closed\";\n      }else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0, \n                                     SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){\n         zState = azLockName[j];\n      }\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);\n    }\n\n  }else\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n  if( sqlite3StrICmp(zLeft, \"key\")==0 && zRight ){\n    sqlite3_key(db, zRight, sqlite3Strlen30(zRight));\n  }else\n  if( sqlite3StrICmp(zLeft, \"rekey\")==0 && zRight ){\n    sqlite3_rekey(db, zRight, sqlite3Strlen30(zRight));\n  }else\n  if( zRight && (sqlite3StrICmp(zLeft, \"hexkey\")==0 ||\n                 sqlite3StrICmp(zLeft, \"hexrekey\")==0) ){\n    int i, h1, h2;\n    char zKey[40];\n    for(i=0; (h1 = zRight[i])!=0 && (h2 = zRight[i+1])!=0; i+=2){\n      h1 += 9*(1&(h1>>6));\n      h2 += 9*(1&(h2>>6));\n      zKey[i/2] = (h2 & 0x0f) | ((h1 & 0xf)<<4);\n    }\n    if( (zLeft[3] & 0xf)==0xb ){\n      sqlite3_key(db, zKey, i/2);\n    }else{\n      sqlite3_rekey(db, zKey, i/2);\n    }\n  }else\n#endif\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n  if( sqlite3StrICmp(zLeft, \"activate_extensions\")==0 && zRight ){\n#ifdef SQLITE_HAS_CODEC\n    if( sqlite3StrNICmp(zRight, \"see-\", 4)==0 ){\n      sqlite3_activate_see(&zRight[4]);\n    }\n#endif\n#ifdef SQLITE_ENABLE_CEROD\n    if( sqlite3StrNICmp(zRight, \"cerod-\", 6)==0 ){\n      sqlite3_activate_cerod(&zRight[6]);\n    }\n#endif\n  }else\n#endif\n\n \n  {/* Empty ELSE clause */}\n\n  /*\n  ** Reset the safety level, in case the fullfsync flag or synchronous\n  ** setting changed.\n  */\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n  if( db->autoCommit ){\n    sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level,\n               (db->flags&SQLITE_FullFSync)!=0,\n               (db->flags&SQLITE_CkptFullFSync)!=0);\n  }\n#endif\npragma_out:\n  sqlite3DbFree(db, zLeft);\n  sqlite3DbFree(db, zRight);\n}\n\n#endif /* SQLITE_OMIT_PRAGMA */\n\n/************** End of pragma.c **********************************************/\n/************** Begin file prepare.c *****************************************/\n/*\n** 2005 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_prepare()\n** interface, and routines that contribute to loading the database schema\n** from disk.\n*/\n\n/*\n** Fill the InitData structure with an error message that indicates\n** that the database is corrupt.\n*/\nstatic void corruptSchema(\n  InitData *pData,     /* Initialization context */\n  const char *zObj,    /* Object being parsed at the point of error */\n  const char *zExtra   /* Error information */\n){\n  sqlite3 *db = pData->db;\n  if( !db->mallocFailed && (db->flags & SQLITE_RecoveryMode)==0 ){\n    if( zObj==0 ) zObj = \"?\";\n    sqlite3SetString(pData->pzErrMsg, db,\n      \"malformed database schema (%s)\", zObj);\n    if( zExtra ){\n      *pData->pzErrMsg = sqlite3MAppendf(db, *pData->pzErrMsg, \n                                 \"%s - %s\", *pData->pzErrMsg, zExtra);\n    }\n  }\n  pData->rc = db->mallocFailed ? SQLITE_NOMEM : SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** This is the callback routine for the code that initializes the\n** database.  See sqlite3Init() below for additional information.\n** This routine is also called from the OP_ParseSchema opcode of the VDBE.\n**\n** Each callback contains the following information:\n**\n**     argv[0] = name of thing being created\n**     argv[1] = root page number for table or index. 0 for trigger or view.\n**     argv[2] = SQL text for the CREATE statement.\n**\n*/\nSQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){\n  InitData *pData = (InitData*)pInit;\n  sqlite3 *db = pData->db;\n  int iDb = pData->iDb;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n  assert( sqlite3_mutex_held(db->mutex) );\n  DbClearProperty(db, iDb, DB_Empty);\n  if( db->mallocFailed ){\n    corruptSchema(pData, argv[0], 0);\n    return 1;\n  }\n\n  assert( iDb>=0 && iDb<db->nDb );\n  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */\n  if( argv[1]==0 ){\n    corruptSchema(pData, argv[0], 0);\n  }else if( argv[2] && argv[2][0] ){\n    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.\n    ** But because db->init.busy is set to 1, no VDBE code is generated\n    ** or executed.  All the parser does is build the internal data\n    ** structures that describe the table, index, or view.\n    */\n    int rc;\n    sqlite3_stmt *pStmt;\n    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */\n\n    assert( db->init.busy );\n    db->init.iDb = iDb;\n    db->init.newTnum = sqlite3Atoi(argv[1]);\n    db->init.orphanTrigger = 0;\n    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);\n    rc = db->errCode;\n    assert( (rc&0xFF)==(rcp&0xFF) );\n    db->init.iDb = 0;\n    if( SQLITE_OK!=rc ){\n      if( db->init.orphanTrigger ){\n        assert( iDb==1 );\n      }else{\n        pData->rc = rc;\n        if( rc==SQLITE_NOMEM ){\n          db->mallocFailed = 1;\n        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){\n          corruptSchema(pData, argv[0], sqlite3_errmsg(db));\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }else if( argv[0]==0 ){\n    corruptSchema(pData, 0, 0);\n  }else{\n    /* If the SQL column is blank it means this is an index that\n    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE\n    ** constraint for a CREATE TABLE.  The index should have already\n    ** been created when we processed the CREATE TABLE.  All we have\n    ** to do here is record the root page number for that index.\n    */\n    Index *pIndex;\n    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zName);\n    if( pIndex==0 ){\n      /* This can occur if there exists an index on a TEMP table which\n      ** has the same name as another index on a permanent index.  Since\n      ** the permanent table is hidden by the TEMP table, we can also\n      ** safely ignore the index on the permanent table.\n      */\n      /* Do Nothing */;\n    }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){\n      corruptSchema(pData, argv[0], \"invalid rootpage\");\n    }\n  }\n  return 0;\n}\n\n/*\n** Attempt to read the database schema and initialize internal\n** data structures for a single database file.  The index of the\n** database file is given by iDb.  iDb==0 is used for the main\n** database.  iDb==1 should never be used.  iDb>=2 is used for\n** auxiliary databases.  Return one of the SQLITE_ error codes to\n** indicate success or failure.\n*/\nstatic int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){\n  int rc;\n  int i;\n#ifndef SQLITE_OMIT_DEPRECATED\n  int size;\n#endif\n  Table *pTab;\n  Db *pDb;\n  char const *azArg[4];\n  int meta[5];\n  InitData initData;\n  char const *zMasterSchema;\n  char const *zMasterName;\n  int openedTransaction = 0;\n\n  /*\n  ** The master database table has a structure like this\n  */\n  static const char master_schema[] = \n     \"CREATE TABLE sqlite_master(\\n\"\n     \"  type text,\\n\"\n     \"  name text,\\n\"\n     \"  tbl_name text,\\n\"\n     \"  rootpage integer,\\n\"\n     \"  sql text\\n\"\n     \")\"\n  ;\n#ifndef SQLITE_OMIT_TEMPDB\n  static const char temp_master_schema[] = \n     \"CREATE TEMP TABLE sqlite_temp_master(\\n\"\n     \"  type text,\\n\"\n     \"  name text,\\n\"\n     \"  tbl_name text,\\n\"\n     \"  rootpage integer,\\n\"\n     \"  sql text\\n\"\n     \")\"\n  ;\n#else\n  #define temp_master_schema 0\n#endif\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n\n  /* zMasterSchema and zInitScript are set to point at the master schema\n  ** and initialisation script appropriate for the database being\n  ** initialized. zMasterName is the name of the master table.\n  */\n  if( !OMIT_TEMPDB && iDb==1 ){\n    zMasterSchema = temp_master_schema;\n  }else{\n    zMasterSchema = master_schema;\n  }\n  zMasterName = SCHEMA_TABLE(iDb);\n\n  /* Construct the schema tables.  */\n  azArg[0] = zMasterName;\n  azArg[1] = \"1\";\n  azArg[2] = zMasterSchema;\n  azArg[3] = 0;\n  initData.db = db;\n  initData.iDb = iDb;\n  initData.rc = SQLITE_OK;\n  initData.pzErrMsg = pzErrMsg;\n  sqlite3InitCallback(&initData, 3, (char **)azArg, 0);\n  if( initData.rc ){\n    rc = initData.rc;\n    goto error_out;\n  }\n  pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);\n  if( ALWAYS(pTab) ){\n    pTab->tabFlags |= TF_Readonly;\n  }\n\n  /* Create a cursor to hold the database open\n  */\n  pDb = &db->aDb[iDb];\n  if( pDb->pBt==0 ){\n    if( !OMIT_TEMPDB && ALWAYS(iDb==1) ){\n      DbSetProperty(db, 1, DB_SchemaLoaded);\n    }\n    return SQLITE_OK;\n  }\n\n  /* If there is not already a read-only (or read-write) transaction opened\n  ** on the b-tree database, open one now. If a transaction is opened, it \n  ** will be closed before this function returns.  */\n  sqlite3BtreeEnter(pDb->pBt);\n  if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){\n    rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3SetString(pzErrMsg, db, \"%s\", sqlite3ErrStr(rc));\n      goto initone_error_out;\n    }\n    openedTransaction = 1;\n  }\n\n  /* Get the database meta information.\n  **\n  ** Meta values are as follows:\n  **    meta[0]   Schema cookie.  Changes with each schema change.\n  **    meta[1]   File format of schema layer.\n  **    meta[2]   Size of the page cache.\n  **    meta[3]   Largest rootpage (auto/incr_vacuum mode)\n  **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE\n  **    meta[5]   User version\n  **    meta[6]   Incremental vacuum mode\n  **    meta[7]   unused\n  **    meta[8]   unused\n  **    meta[9]   unused\n  **\n  ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to\n  ** the possible values of meta[4].\n  */\n  for(i=0; i<ArraySize(meta); i++){\n    sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);\n  }\n  pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];\n\n  /* If opening a non-empty database, check the text encoding. For the\n  ** main database, set sqlite3.enc to the encoding of the main database.\n  ** For an attached db, it is an error if the encoding is not the same\n  ** as sqlite3.enc.\n  */\n  if( meta[BTREE_TEXT_ENCODING-1] ){  /* text encoding */\n    if( iDb==0 ){\n#ifndef SQLITE_OMIT_UTF16\n      u8 encoding;\n      /* If opening the main database, set ENC(db). */\n      encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;\n      if( encoding==0 ) encoding = SQLITE_UTF8;\n      ENC(db) = encoding;\n#else\n      ENC(db) = SQLITE_UTF8;\n#endif\n    }else{\n      /* If opening an attached database, the encoding much match ENC(db) */\n      if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){\n        sqlite3SetString(pzErrMsg, db, \"attached databases must use the same\"\n            \" text encoding as main database\");\n        rc = SQLITE_ERROR;\n        goto initone_error_out;\n      }\n    }\n  }else{\n    DbSetProperty(db, iDb, DB_Empty);\n  }\n  pDb->pSchema->enc = ENC(db);\n\n  if( pDb->pSchema->cache_size==0 ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    size = sqlite3AbsInt32(meta[BTREE_DEFAULT_CACHE_SIZE-1]);\n    if( size==0 ){ size = SQLITE_DEFAULT_CACHE_SIZE; }\n    pDb->pSchema->cache_size = size;\n#else\n    pDb->pSchema->cache_size = SQLITE_DEFAULT_CACHE_SIZE;\n#endif\n    sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n  }\n\n  /*\n  ** file_format==1    Version 3.0.0.\n  ** file_format==2    Version 3.1.3.  // ALTER TABLE ADD COLUMN\n  ** file_format==3    Version 3.1.4.  // ditto but with non-NULL defaults\n  ** file_format==4    Version 3.3.0.  // DESC indices.  Boolean constants\n  */\n  pDb->pSchema->file_format = (u8)meta[BTREE_FILE_FORMAT-1];\n  if( pDb->pSchema->file_format==0 ){\n    pDb->pSchema->file_format = 1;\n  }\n  if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){\n    sqlite3SetString(pzErrMsg, db, \"unsupported file format\");\n    rc = SQLITE_ERROR;\n    goto initone_error_out;\n  }\n\n  /* Ticket #2804:  When we open a database in the newer file format,\n  ** clear the legacy_file_format pragma flag so that a VACUUM will\n  ** not downgrade the database and thus invalidate any descending\n  ** indices that the user might have created.\n  */\n  if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){\n    db->flags &= ~SQLITE_LegacyFileFmt;\n  }\n\n  /* Read the schema information out of the schema tables\n  */\n  assert( db->init.busy );\n  {\n    char *zSql;\n    zSql = sqlite3MPrintf(db, \n        \"SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid\",\n        db->aDb[iDb].zName, zMasterName);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      int (*xAuth)(void*,int,const char*,const char*,const char*,const char*);\n      xAuth = db->xAuth;\n      db->xAuth = 0;\n#endif\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      db->xAuth = xAuth;\n    }\n#endif\n    if( rc==SQLITE_OK ) rc = initData.rc;\n    sqlite3DbFree(db, zSql);\n#ifndef SQLITE_OMIT_ANALYZE\n    if( rc==SQLITE_OK ){\n      sqlite3AnalysisLoad(db, iDb);\n    }\n#endif\n  }\n  if( db->mallocFailed ){\n    rc = SQLITE_NOMEM;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  if( rc==SQLITE_OK || (db->flags&SQLITE_RecoveryMode)){\n    /* Black magic: If the SQLITE_RecoveryMode flag is set, then consider\n    ** the schema loaded, even if errors occurred. In this situation the \n    ** current sqlite3_prepare() operation will fail, but the following one\n    ** will attempt to compile the supplied statement against whatever subset\n    ** of the schema was loaded before the error occurred. The primary\n    ** purpose of this is to allow access to the sqlite_master table\n    ** even when its contents have been corrupted.\n    */\n    DbSetProperty(db, iDb, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n  }\n\n  /* Jump here for an error that occurs after successfully allocating\n  ** curMain and calling sqlite3BtreeEnter(). For an error that occurs\n  ** before that point, jump to error_out.\n  */\ninitone_error_out:\n  if( openedTransaction ){\n    sqlite3BtreeCommit(pDb->pBt);\n  }\n  sqlite3BtreeLeave(pDb->pBt);\n\nerror_out:\n  if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n    db->mallocFailed = 1;\n  }\n  return rc;\n}\n\n/*\n** Initialize all database files - the main database file, the file\n** used to store temporary tables, and any additional database files\n** created using ATTACH statements.  Return a success code.  If an\n** error occurs, write an error message into *pzErrMsg.\n**\n** After a database is initialized, the DB_SchemaLoaded bit is set\n** bit is set in the flags field of the Db structure. If the database\n** file was of zero-length, then the DB_Empty flag is also set.\n*/\nSQLITE_PRIVATE int sqlite3Init(sqlite3 *db, char **pzErrMsg){\n  int i, rc;\n  int commit_internal = !(db->flags&SQLITE_InternChanges);\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n  rc = SQLITE_OK;\n  db->init.busy = 1;\n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n    if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;\n    rc = sqlite3InitOne(db, i, pzErrMsg);\n    if( rc ){\n      sqlite3ResetOneSchema(db, i);\n    }\n  }\n\n  /* Once all the other databases have been initialized, load the schema\n  ** for the TEMP database. This is loaded last, as the TEMP database\n  ** schema may contain references to objects in other databases.\n  */\n#ifndef SQLITE_OMIT_TEMPDB\n  if( rc==SQLITE_OK && ALWAYS(db->nDb>1)\n                    && !DbHasProperty(db, 1, DB_SchemaLoaded) ){\n    rc = sqlite3InitOne(db, 1, pzErrMsg);\n    if( rc ){\n      sqlite3ResetOneSchema(db, 1);\n    }\n  }\n#endif\n\n  db->init.busy = 0;\n  if( rc==SQLITE_OK && commit_internal ){\n    sqlite3CommitInternalChanges(db);\n  }\n\n  return rc; \n}\n\n/*\n** This routine is a no-op if the database schema is already initialized.\n** Otherwise, the schema is loaded. An error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){\n  int rc = SQLITE_OK;\n  sqlite3 *db = pParse->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( !db->init.busy ){\n    rc = sqlite3Init(db, &pParse->zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    pParse->rc = rc;\n    pParse->nErr++;\n  }\n  return rc;\n}\n\n\n/*\n** Check schema cookies in all databases.  If any cookie is out\n** of date set pParse->rc to SQLITE_SCHEMA.  If all schema cookies\n** make no changes to pParse->rc.\n*/\nstatic void schemaIsValid(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int rc;\n  int cookie;\n\n  assert( pParse->checkSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(iDb=0; iDb<db->nDb; iDb++){\n    int openedTransaction = 0;         /* True if a transaction is opened */\n    Btree *pBt = db->aDb[iDb].pBt;     /* Btree database to read cookie from */\n    if( pBt==0 ) continue;\n\n    /* If there is not already a read-only (or read-write) transaction opened\n    ** on the b-tree database, open one now. If a transaction is opened, it \n    ** will be closed immediately after reading the meta-value. */\n    if( !sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0);\n      if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n        db->mallocFailed = 1;\n      }\n      if( rc!=SQLITE_OK ) return;\n      openedTransaction = 1;\n    }\n\n    /* Read the schema cookie from the database. If it does not match the \n    ** value stored as part of the in-memory schema representation,\n    ** set Parse.rc to SQLITE_SCHEMA. */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){\n      sqlite3ResetOneSchema(db, iDb);\n      pParse->rc = SQLITE_SCHEMA;\n    }\n\n    /* Close the transaction, if one was opened. */\n    if( openedTransaction ){\n      sqlite3BtreeCommit(pBt);\n    }\n  }\n}\n\n/*\n** Convert a schema pointer into the iDb index that indicates\n** which database file in db->aDb[] the schema refers to.\n**\n** If the same database is attached more than once, the first\n** attached database is returned.\n*/\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){\n  int i = -1000000;\n\n  /* If pSchema is NULL, then return -1000000. This happens when code in \n  ** expr.c is trying to resolve a reference to a transient table (i.e. one\n  ** created by a sub-select). In this case the return value of this \n  ** function should never be used.\n  **\n  ** We return -1000000 instead of the more usual -1 simply because using\n  ** -1000000 as the incorrect index into db->aDb[] is much \n  ** more likely to cause a segfault than -1 (of course there are assert()\n  ** statements too, but it never hurts to play the odds).\n  */\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( pSchema ){\n    for(i=0; ALWAYS(i<db->nDb); i++){\n      if( db->aDb[i].pSchema==pSchema ){\n        break;\n      }\n    }\n    assert( i>=0 && i<db->nDb );\n  }\n  return i;\n}\n\n/*\n** Compile the UTF-8 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  int saveSqlFlag,          /* True to copy SQL text into the sqlite3_stmt */\n  Vdbe *pReprepare,         /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  Parse *pParse;            /* Parsing context */\n  char *zErrMsg = 0;        /* Error message */\n  int rc = SQLITE_OK;       /* Result code */\n  int i;                    /* Loop counter */\n\n  /* Allocate the parsing context */\n  pParse = sqlite3StackAllocZero(db, sizeof(*pParse));\n  if( pParse==0 ){\n    rc = SQLITE_NOMEM;\n    goto end_prepare;\n  }\n  pParse->pReprepare = pReprepare;\n  assert( ppStmt && *ppStmt==0 );\n  assert( !db->mallocFailed );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* Check to verify that it is possible to get a read lock on all\n  ** database schemas.  The inability to get a read lock indicates that\n  ** some other database connection is holding a write-lock, which in\n  ** turn means that the other connection has made uncommitted changes\n  ** to the schema.\n  **\n  ** Were we to proceed and prepare the statement against the uncommitted\n  ** schema changes and if those schema changes are subsequently rolled\n  ** back and different changes are made in their place, then when this\n  ** prepared statement goes to run the schema cookie would fail to detect\n  ** the schema change.  Disaster would follow.\n  **\n  ** This thread is currently holding mutexes on all Btrees (because\n  ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it\n  ** is not possible for another thread to start a new schema change\n  ** while this routine is running.  Hence, we do not need to hold \n  ** locks on the schema, we just need to make sure nobody else is \n  ** holding them.\n  **\n  ** Note that setting READ_UNCOMMITTED overrides most lock detection,\n  ** but it does *not* override schema lock detection, so this all still\n  ** works even if READ_UNCOMMITTED is set.\n  */\n  for(i=0; i<db->nDb; i++) {\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      assert( sqlite3BtreeHoldsMutex(pBt) );\n      rc = sqlite3BtreeSchemaLocked(pBt);\n      if( rc ){\n        const char *zDb = db->aDb[i].zName;\n        sqlite3Error(db, rc, \"database schema is locked: %s\", zDb);\n        testcase( db->flags & SQLITE_ReadUncommitted );\n        goto end_prepare;\n      }\n    }\n  }\n\n  sqlite3VtabUnlockList(db);\n\n  pParse->db = db;\n  pParse->nQueryLoop = (double)1;\n  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){\n    char *zSqlCopy;\n    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n    testcase( nBytes==mxLen );\n    testcase( nBytes==mxLen+1 );\n    if( nBytes>mxLen ){\n      sqlite3Error(db, SQLITE_TOOBIG, \"statement too long\");\n      rc = sqlite3ApiExit(db, SQLITE_TOOBIG);\n      goto end_prepare;\n    }\n    zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);\n    if( zSqlCopy ){\n      sqlite3RunParser(pParse, zSqlCopy, &zErrMsg);\n      sqlite3DbFree(db, zSqlCopy);\n      pParse->zTail = &zSql[pParse->zTail-zSqlCopy];\n    }else{\n      pParse->zTail = &zSql[nBytes];\n    }\n  }else{\n    sqlite3RunParser(pParse, zSql, &zErrMsg);\n  }\n  assert( 1==(int)pParse->nQueryLoop );\n\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM;\n  }\n  if( pParse->rc==SQLITE_DONE ) pParse->rc = SQLITE_OK;\n  if( pParse->checkSchema ){\n    schemaIsValid(pParse);\n  }\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM;\n  }\n  if( pzTail ){\n    *pzTail = pParse->zTail;\n  }\n  rc = pParse->rc;\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( rc==SQLITE_OK && pParse->pVdbe && pParse->explain ){\n    static const char * const azColName[] = {\n       \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\",\n       \"selectid\", \"order\", \"from\", \"detail\"\n    };\n    int iFirst, mx;\n    if( pParse->explain==2 ){\n      sqlite3VdbeSetNumCols(pParse->pVdbe, 4);\n      iFirst = 8;\n      mx = 12;\n    }else{\n      sqlite3VdbeSetNumCols(pParse->pVdbe, 8);\n      iFirst = 0;\n      mx = 8;\n    }\n    for(i=iFirst; i<mx; i++){\n      sqlite3VdbeSetColName(pParse->pVdbe, i-iFirst, COLNAME_NAME,\n                            azColName[i], SQLITE_STATIC);\n    }\n  }\n#endif\n\n  if( db->init.busy==0 ){\n    Vdbe *pVdbe = pParse->pVdbe;\n    sqlite3VdbeSetSql(pVdbe, zSql, (int)(pParse->zTail-zSql), saveSqlFlag);\n  }\n  if( pParse->pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){\n    sqlite3VdbeFinalize(pParse->pVdbe);\n    assert(!(*ppStmt));\n  }else{\n    *ppStmt = (sqlite3_stmt*)pParse->pVdbe;\n  }\n\n  if( zErrMsg ){\n    sqlite3Error(db, rc, \"%s\", zErrMsg);\n    sqlite3DbFree(db, zErrMsg);\n  }else{\n    sqlite3Error(db, rc, 0);\n  }\n\n  /* Delete any TriggerPrg structures allocated while parsing this statement. */\n  while( pParse->pTriggerPrg ){\n    TriggerPrg *pT = pParse->pTriggerPrg;\n    pParse->pTriggerPrg = pT->pNext;\n    sqlite3DbFree(db, pT);\n  }\n\nend_prepare:\n\n  sqlite3StackFree(db, pParse);\n  rc = sqlite3ApiExit(db, rc);\n  assert( (rc&db->errMask)==rc );\n  return rc;\n}\nstatic int sqlite3LockAndPrepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  int saveSqlFlag,          /* True to copy SQL text into the sqlite3_stmt */\n  Vdbe *pOld,               /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  assert( ppStmt!=0 );\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);\n  if( rc==SQLITE_SCHEMA ){\n    sqlite3_finalize(*ppStmt);\n    rc = sqlite3Prepare(db, zSql, nBytes, saveSqlFlag, pOld, ppStmt, pzTail);\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  assert( rc==SQLITE_OK || *ppStmt==0 );\n  return rc;\n}\n\n/*\n** Rerun the compilation of a statement after a schema change.\n**\n** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,\n** if the statement cannot be recompiled because another connection has\n** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error\n** occurs, return SQLITE_SCHEMA.\n*/\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){\n  int rc;\n  sqlite3_stmt *pNew;\n  const char *zSql;\n  sqlite3 *db;\n\n  assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );\n  zSql = sqlite3_sql((sqlite3_stmt *)p);\n  assert( zSql!=0 );  /* Reprepare only called for prepare_v2() statements */\n  db = sqlite3VdbeDb(p);\n  assert( sqlite3_mutex_held(db->mutex) );\n  rc = sqlite3LockAndPrepare(db, zSql, -1, 0, p, &pNew, 0);\n  if( rc ){\n    if( rc==SQLITE_NOMEM ){\n      db->mallocFailed = 1;\n    }\n    assert( pNew==0 );\n    return rc;\n  }else{\n    assert( pNew!=0 );\n  }\n  sqlite3VdbeSwap((Vdbe*)pNew, p);\n  sqlite3TransferBindings(pNew, (sqlite3_stmt*)p);\n  sqlite3VdbeResetStepResult((Vdbe*)pNew);\n  sqlite3VdbeFinalize((Vdbe*)pNew);\n  return SQLITE_OK;\n}\n\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,1,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Compile the UTF-16 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  int saveSqlFlag,          /* True to save SQL text into the sqlite3_stmt */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  /* This function currently works by first transforming the UTF-16\n  ** encoded string to UTF-8, then invoking sqlite3_prepare(). The\n  ** tricky bit is figuring out the pointer to return in *pzTail.\n  */\n  char *zSql8;\n  const char *zTail8 = 0;\n  int rc = SQLITE_OK;\n\n  assert( ppStmt );\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);\n  if( zSql8 ){\n    rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);\n  }\n\n  if( zTail8 && pzTail ){\n    /* If sqlite3_prepare returns a tail pointer, we calculate the\n    ** equivalent pointer into the UTF-16 string by counting the unicode\n    ** characters between zSql8 and zTail8, and then returning a pointer\n    ** the same number of characters into the UTF-16 string.\n    */\n    int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));\n    *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);\n  }\n  sqlite3DbFree(db, zSql8); \n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,1,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of prepare.c *********************************************/\n/************** Begin file select.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle SELECT statements in SQLite.\n*/\n\n\n/*\n** Delete all the content of a Select structure but do not deallocate\n** the select structure itself.\n*/\nstatic void clearSelect(sqlite3 *db, Select *p){\n  sqlite3ExprListDelete(db, p->pEList);\n  sqlite3SrcListDelete(db, p->pSrc);\n  sqlite3ExprDelete(db, p->pWhere);\n  sqlite3ExprListDelete(db, p->pGroupBy);\n  sqlite3ExprDelete(db, p->pHaving);\n  sqlite3ExprListDelete(db, p->pOrderBy);\n  sqlite3SelectDelete(db, p->pPrior);\n  sqlite3ExprDelete(db, p->pLimit);\n  sqlite3ExprDelete(db, p->pOffset);\n}\n\n/*\n** Initialize a SelectDest structure.\n*/\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){\n  pDest->eDest = (u8)eDest;\n  pDest->iSDParm = iParm;\n  pDest->affSdst = 0;\n  pDest->iSdst = 0;\n  pDest->nSdst = 0;\n}\n\n\n/*\n** Allocate a new Select structure and return a pointer to that\n** structure.\n*/\nSQLITE_PRIVATE Select *sqlite3SelectNew(\n  Parse *pParse,        /* Parsing context */\n  ExprList *pEList,     /* which columns to include in the result */\n  SrcList *pSrc,        /* the FROM clause -- which tables to scan */\n  Expr *pWhere,         /* the WHERE clause */\n  ExprList *pGroupBy,   /* the GROUP BY clause */\n  Expr *pHaving,        /* the HAVING clause */\n  ExprList *pOrderBy,   /* the ORDER BY clause */\n  u16 selFlags,         /* Flag parameters, such as SF_Distinct */\n  Expr *pLimit,         /* LIMIT value.  NULL means not used */\n  Expr *pOffset         /* OFFSET value.  NULL means no offset */\n){\n  Select *pNew;\n  Select standin;\n  sqlite3 *db = pParse->db;\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );\n  assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */\n  if( pNew==0 ){\n    assert( db->mallocFailed );\n    pNew = &standin;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  if( pEList==0 ){\n    pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ALL,0));\n  }\n  pNew->pEList = pEList;\n  if( pSrc==0 ) pSrc = sqlite3DbMallocZero(db, sizeof(*pSrc));\n  pNew->pSrc = pSrc;\n  pNew->pWhere = pWhere;\n  pNew->pGroupBy = pGroupBy;\n  pNew->pHaving = pHaving;\n  pNew->pOrderBy = pOrderBy;\n  pNew->selFlags = selFlags;\n  pNew->op = TK_SELECT;\n  pNew->pLimit = pLimit;\n  pNew->pOffset = pOffset;\n  assert( pOffset==0 || pLimit!=0 );\n  pNew->addrOpenEphm[0] = -1;\n  pNew->addrOpenEphm[1] = -1;\n  pNew->addrOpenEphm[2] = -1;\n  if( db->mallocFailed ) {\n    clearSelect(db, pNew);\n    if( pNew!=&standin ) sqlite3DbFree(db, pNew);\n    pNew = 0;\n  }else{\n    assert( pNew->pSrc!=0 || pParse->nErr>0 );\n  }\n  assert( pNew!=&standin );\n  return pNew;\n}\n\n/*\n** Delete the given Select structure and all of its substructures.\n*/\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){\n  if( p ){\n    clearSelect(db, p);\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Given 1 to 3 identifiers preceeding the JOIN keyword, determine the\n** type of join.  Return an integer constant that expresses that type\n** in terms of the following bit values:\n**\n**     JT_INNER\n**     JT_CROSS\n**     JT_OUTER\n**     JT_NATURAL\n**     JT_LEFT\n**     JT_RIGHT\n**\n** A full outer join is the combination of JT_LEFT and JT_RIGHT.\n**\n** If an illegal or unsupported join type is seen, then still return\n** a join type, but put an error in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){\n  int jointype = 0;\n  Token *apAll[3];\n  Token *p;\n                             /*   0123456789 123456789 123456789 123 */\n  static const char zKeyText[] = \"naturaleftouterightfullinnercross\";\n  static const struct {\n    u8 i;        /* Beginning of keyword text in zKeyText[] */\n    u8 nChar;    /* Length of the keyword in characters */\n    u8 code;     /* Join type mask */\n  } aKeyword[] = {\n    /* natural */ { 0,  7, JT_NATURAL                },\n    /* left    */ { 6,  4, JT_LEFT|JT_OUTER          },\n    /* outer   */ { 10, 5, JT_OUTER                  },\n    /* right   */ { 14, 5, JT_RIGHT|JT_OUTER         },\n    /* full    */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER },\n    /* inner   */ { 23, 5, JT_INNER                  },\n    /* cross   */ { 28, 5, JT_INNER|JT_CROSS         },\n  };\n  int i, j;\n  apAll[0] = pA;\n  apAll[1] = pB;\n  apAll[2] = pC;\n  for(i=0; i<3 && apAll[i]; i++){\n    p = apAll[i];\n    for(j=0; j<ArraySize(aKeyword); j++){\n      if( p->n==aKeyword[j].nChar \n          && sqlite3StrNICmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0 ){\n        jointype |= aKeyword[j].code;\n        break;\n      }\n    }\n    testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );\n    if( j>=ArraySize(aKeyword) ){\n      jointype |= JT_ERROR;\n      break;\n    }\n  }\n  if(\n     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||\n     (jointype & JT_ERROR)!=0\n  ){\n    const char *zSp = \" \";\n    assert( pB!=0 );\n    if( pC==0 ){ zSp++; }\n    sqlite3ErrorMsg(pParse, \"unknown or unsupported join type: \"\n       \"%T %T%s%T\", pA, pB, zSp, pC);\n    jointype = JT_INNER;\n  }else if( (jointype & JT_OUTER)!=0 \n         && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){\n    sqlite3ErrorMsg(pParse, \n      \"RIGHT and FULL OUTER JOINs are not currently supported\");\n    jointype = JT_INNER;\n  }\n  return jointype;\n}\n\n/*\n** Return the index of a column in a table.  Return -1 if the column\n** is not contained in the table.\n*/\nstatic int columnIndex(Table *pTab, const char *zCol){\n  int i;\n  for(i=0; i<pTab->nCol; i++){\n    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Search the first N tables in pSrc, from left to right, looking for a\n** table that has a column named zCol.  \n**\n** When found, set *piTab and *piCol to the table index and column index\n** of the matching column and return TRUE.\n**\n** If not found, return FALSE.\n*/\nstatic int tableAndColumnIndex(\n  SrcList *pSrc,       /* Array of tables to search */\n  int N,               /* Number of tables in pSrc->a[] to search */\n  const char *zCol,    /* Name of the column we are looking for */\n  int *piTab,          /* Write index of pSrc->a[] here */\n  int *piCol           /* Write index of pSrc->a[*piTab].pTab->aCol[] here */\n){\n  int i;               /* For looping over tables in pSrc */\n  int iCol;            /* Index of column matching zCol */\n\n  assert( (piTab==0)==(piCol==0) );  /* Both or neither are NULL */\n  for(i=0; i<N; i++){\n    iCol = columnIndex(pSrc->a[i].pTab, zCol);\n    if( iCol>=0 ){\n      if( piTab ){\n        *piTab = i;\n        *piCol = iCol;\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is used to add terms implied by JOIN syntax to the\n** WHERE clause expression of a SELECT statement. The new term, which\n** is ANDed with the existing WHERE clause, is of the form:\n**\n**    (tab1.col1 = tab2.col2)\n**\n** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the \n** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is\n** column iColRight of tab2.\n*/\nstatic void addWhereTerm(\n  Parse *pParse,                  /* Parsing context */\n  SrcList *pSrc,                  /* List of tables in FROM clause */\n  int iLeft,                      /* Index of first table to join in pSrc */\n  int iColLeft,                   /* Index of column in first table */\n  int iRight,                     /* Index of second table in pSrc */\n  int iColRight,                  /* Index of column in second table */\n  int isOuterJoin,                /* True if this is an OUTER join */\n  Expr **ppWhere                  /* IN/OUT: The WHERE clause to add to */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pE1;\n  Expr *pE2;\n  Expr *pEq;\n\n  assert( iLeft<iRight );\n  assert( pSrc->nSrc>iRight );\n  assert( pSrc->a[iLeft].pTab );\n  assert( pSrc->a[iRight].pTab );\n\n  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);\n  pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);\n\n  pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);\n  if( pEq && isOuterJoin ){\n    ExprSetProperty(pEq, EP_FromJoin);\n    assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );\n    ExprSetIrreducible(pEq);\n    pEq->iRightJoinTable = (i16)pE2->iTable;\n  }\n  *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);\n}\n\n/*\n** Set the EP_FromJoin property on all terms of the given expression.\n** And set the Expr.iRightJoinTable to iTable for every term in the\n** expression.\n**\n** The EP_FromJoin property is used on terms of an expression to tell\n** the LEFT OUTER JOIN processing logic that this term is part of the\n** join restriction specified in the ON or USING clause and not a part\n** of the more general WHERE clause.  These terms are moved over to the\n** WHERE clause during join processing but we need to remember that they\n** originated in the ON or USING clause.\n**\n** The Expr.iRightJoinTable tells the WHERE clause processing that the\n** expression depends on table iRightJoinTable even if that table is not\n** explicitly mentioned in the expression.  That information is needed\n** for cases like this:\n**\n**    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5\n**\n** The where clause needs to defer the handling of the t1.x=5\n** term until after the t2 loop of the join.  In that way, a\n** NULL t2 row will be inserted whenever t1.x!=5.  If we do not\n** defer the handling of t1.x=5, it will be processed immediately\n** after the t1 loop and rows with t1.x!=5 will never appear in\n** the output, which is incorrect.\n*/\nstatic void setJoinExpr(Expr *p, int iTable){\n  while( p ){\n    ExprSetProperty(p, EP_FromJoin);\n    assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) );\n    ExprSetIrreducible(p);\n    p->iRightJoinTable = (i16)iTable;\n    setJoinExpr(p->pLeft, iTable);\n    p = p->pRight;\n  } \n}\n\n/*\n** This routine processes the join information for a SELECT statement.\n** ON and USING clauses are converted into extra terms of the WHERE clause.\n** NATURAL joins also create extra WHERE clause terms.\n**\n** The terms of a FROM clause are contained in the Select.pSrc structure.\n** The left most table is the first entry in Select.pSrc.  The right-most\n** table is the last entry.  The join operator is held in the entry to\n** the left.  Thus entry 0 contains the join operator for the join between\n** entries 0 and 1.  Any ON or USING clauses associated with the join are\n** also attached to the left entry.\n**\n** This routine returns the number of errors encountered.\n*/\nstatic int sqliteProcessJoin(Parse *pParse, Select *p){\n  SrcList *pSrc;                  /* All tables in the FROM clause */\n  int i, j;                       /* Loop counters */\n  struct SrcList_item *pLeft;     /* Left table being joined */\n  struct SrcList_item *pRight;    /* Right table being joined */\n\n  pSrc = p->pSrc;\n  pLeft = &pSrc->a[0];\n  pRight = &pLeft[1];\n  for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){\n    Table *pLeftTab = pLeft->pTab;\n    Table *pRightTab = pRight->pTab;\n    int isOuter;\n\n    if( NEVER(pLeftTab==0 || pRightTab==0) ) continue;\n    isOuter = (pRight->jointype & JT_OUTER)!=0;\n\n    /* When the NATURAL keyword is present, add WHERE clause terms for\n    ** every column that the two tables have in common.\n    */\n    if( pRight->jointype & JT_NATURAL ){\n      if( pRight->pOn || pRight->pUsing ){\n        sqlite3ErrorMsg(pParse, \"a NATURAL join may not have \"\n           \"an ON or USING clause\", 0);\n        return 1;\n      }\n      for(j=0; j<pRightTab->nCol; j++){\n        char *zName;   /* Name of column in the right table */\n        int iLeft;     /* Matching left table */\n        int iLeftCol;  /* Matching column in the left table */\n\n        zName = pRightTab->aCol[j].zName;\n        if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){\n          addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,\n                       isOuter, &p->pWhere);\n        }\n      }\n    }\n\n    /* Disallow both ON and USING clauses in the same join\n    */\n    if( pRight->pOn && pRight->pUsing ){\n      sqlite3ErrorMsg(pParse, \"cannot have both ON and USING \"\n        \"clauses in the same join\");\n      return 1;\n    }\n\n    /* Add the ON clause to the end of the WHERE clause, connected by\n    ** an AND operator.\n    */\n    if( pRight->pOn ){\n      if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);\n      p->pWhere = sqlite3ExprAnd(pParse->db, p->pWhere, pRight->pOn);\n      pRight->pOn = 0;\n    }\n\n    /* Create extra terms on the WHERE clause for each column named\n    ** in the USING clause.  Example: If the two tables to be joined are \n    ** A and B and the USING clause names X, Y, and Z, then add this\n    ** to the WHERE clause:    A.X=B.X AND A.Y=B.Y AND A.Z=B.Z\n    ** Report an error if any column mentioned in the USING clause is\n    ** not contained in both tables to be joined.\n    */\n    if( pRight->pUsing ){\n      IdList *pList = pRight->pUsing;\n      for(j=0; j<pList->nId; j++){\n        char *zName;     /* Name of the term in the USING clause */\n        int iLeft;       /* Table on the left with matching column name */\n        int iLeftCol;    /* Column number of matching column on the left */\n        int iRightCol;   /* Column number of matching column on the right */\n\n        zName = pList->a[j].zName;\n        iRightCol = columnIndex(pRightTab, zName);\n        if( iRightCol<0\n         || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)\n        ){\n          sqlite3ErrorMsg(pParse, \"cannot join using column %s - column \"\n            \"not present in both tables\", zName);\n          return 1;\n        }\n        addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,\n                     isOuter, &p->pWhere);\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Insert code into \"v\" that will push the record on the top of the\n** stack into the sorter.\n*/\nstatic void pushOntoSorter(\n  Parse *pParse,         /* Parser context */\n  ExprList *pOrderBy,    /* The ORDER BY clause */\n  Select *pSelect,       /* The whole SELECT statement */\n  int regData            /* Register holding data to be sorted */\n){\n  Vdbe *v = pParse->pVdbe;\n  int nExpr = pOrderBy->nExpr;\n  int regBase = sqlite3GetTempRange(pParse, nExpr+2);\n  int regRecord = sqlite3GetTempReg(pParse);\n  int op;\n  sqlite3ExprCacheClear(pParse);\n  sqlite3ExprCodeExprList(pParse, pOrderBy, regBase, 0);\n  sqlite3VdbeAddOp2(v, OP_Sequence, pOrderBy->iECursor, regBase+nExpr);\n  sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+1, 1);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nExpr + 2, regRecord);\n  if( pSelect->selFlags & SF_UseSorter ){\n    op = OP_SorterInsert;\n  }else{\n    op = OP_IdxInsert;\n  }\n  sqlite3VdbeAddOp2(v, op, pOrderBy->iECursor, regRecord);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3ReleaseTempRange(pParse, regBase, nExpr+2);\n  if( pSelect->iLimit ){\n    int addr1, addr2;\n    int iLimit;\n    if( pSelect->iOffset ){\n      iLimit = pSelect->iOffset+1;\n    }else{\n      iLimit = pSelect->iLimit;\n    }\n    addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit);\n    sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1);\n    addr2 = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp1(v, OP_Last, pOrderBy->iECursor);\n    sqlite3VdbeAddOp1(v, OP_Delete, pOrderBy->iECursor);\n    sqlite3VdbeJumpHere(v, addr2);\n  }\n}\n\n/*\n** Add code to implement the OFFSET\n*/\nstatic void codeOffset(\n  Vdbe *v,          /* Generate code into this VM */\n  Select *p,        /* The SELECT statement being coded */\n  int iContinue     /* Jump here to skip the current record */\n){\n  if( p->iOffset && iContinue!=0 ){\n    int addr;\n    sqlite3VdbeAddOp2(v, OP_AddImm, p->iOffset, -1);\n    addr = sqlite3VdbeAddOp1(v, OP_IfNeg, p->iOffset);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, iContinue);\n    VdbeComment((v, \"skip OFFSET records\"));\n    sqlite3VdbeJumpHere(v, addr);\n  }\n}\n\n/*\n** Add code that will check to make sure the N registers starting at iMem\n** form a distinct entry.  iTab is a sorting index that holds previously\n** seen combinations of the N values.  A new entry is made in iTab\n** if the current N values are new.\n**\n** A jump to addrRepeat is made and the N+1 values are popped from the\n** stack if the top N elements are not distinct.\n*/\nstatic void codeDistinct(\n  Parse *pParse,     /* Parsing and code generating context */\n  int iTab,          /* A sorting index used to test for distinctness */\n  int addrRepeat,    /* Jump to here if not distinct */\n  int N,             /* Number of elements */\n  int iMem           /* First element */\n){\n  Vdbe *v;\n  int r1;\n\n  v = pParse->pVdbe;\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, iTab, r1);\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate an error message when a SELECT is used within a subexpression\n** (example:  \"a IN (SELECT * FROM table)\") but it has more than 1 result\n** column.  We do this in a subroutine because the error used to occur\n** in multiple places.  (The error only occurs in one place now, but we\n** retain the subroutine to minimize code disruption.)\n*/\nstatic int checkForMultiColumnSelectError(\n  Parse *pParse,       /* Parse context. */\n  SelectDest *pDest,   /* Destination of SELECT results */\n  int nExpr            /* Number of result columns returned by SELECT */\n){\n  int eDest = pDest->eDest;\n  if( nExpr>1 && (eDest==SRT_Mem || eDest==SRT_Set) ){\n    sqlite3ErrorMsg(pParse, \"only a single result allowed for \"\n       \"a SELECT that is part of an expression\");\n    return 1;\n  }else{\n    return 0;\n  }\n}\n#endif\n\n/*\n** An instance of the following object is used to record information about\n** how to process the DISTINCT keyword, to simplify passing that information\n** into the selectInnerLoop() routine.\n*/\ntypedef struct DistinctCtx DistinctCtx;\nstruct DistinctCtx {\n  u8 isTnct;      /* True if the DISTINCT keyword is present */\n  u8 eTnctType;   /* One of the WHERE_DISTINCT_* operators */\n  int tabTnct;    /* Ephemeral table used for DISTINCT processing */\n  int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */\n};\n\n/*\n** This routine generates the code for the inside of the inner loop\n** of a SELECT.\n**\n** If srcTab and nColumn are both zero, then the pEList expressions\n** are evaluated in order to get the data for this row.  If nColumn>0\n** then data is pulled from srcTab and pEList is used only to get the\n** datatypes for each column.\n*/\nstatic void selectInnerLoop(\n  Parse *pParse,          /* The parser context */\n  Select *p,              /* The complete select statement being coded */\n  ExprList *pEList,       /* List of values being extracted */\n  int srcTab,             /* Pull data from this table */\n  int nColumn,            /* Number of columns in the source table */\n  ExprList *pOrderBy,     /* If not NULL, sort results using this key */\n  DistinctCtx *pDistinct, /* If not NULL, info on how to process DISTINCT */\n  SelectDest *pDest,      /* How to dispose of the results */\n  int iContinue,          /* Jump here to continue with next row */\n  int iBreak              /* Jump here to break out of the inner loop */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int hasDistinct;        /* True if the DISTINCT keyword is present */\n  int regResult;              /* Start of memory holding result set */\n  int eDest = pDest->eDest;   /* How to dispose of results */\n  int iParm = pDest->iSDParm; /* First argument to disposal method */\n  int nResultCol;             /* Number of result columns */\n\n  assert( v );\n  if( NEVER(v==0) ) return;\n  assert( pEList!=0 );\n  hasDistinct = pDistinct ? pDistinct->eTnctType : WHERE_DISTINCT_NOOP;\n  if( pOrderBy==0 && !hasDistinct ){\n    codeOffset(v, p, iContinue);\n  }\n\n  /* Pull the requested columns.\n  */\n  if( nColumn>0 ){\n    nResultCol = nColumn;\n  }else{\n    nResultCol = pEList->nExpr;\n  }\n  if( pDest->iSdst==0 ){\n    pDest->iSdst = pParse->nMem+1;\n    pDest->nSdst = nResultCol;\n    pParse->nMem += nResultCol;\n  }else{ \n    assert( pDest->nSdst==nResultCol );\n  }\n  regResult = pDest->iSdst;\n  if( nColumn>0 ){\n    for(i=0; i<nColumn; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);\n    }\n  }else if( eDest!=SRT_Exists ){\n    /* If the destination is an EXISTS(...) expression, the actual\n    ** values returned by the SELECT are not required.\n    */\n    sqlite3ExprCacheClear(pParse);\n    sqlite3ExprCodeExprList(pParse, pEList, regResult, eDest==SRT_Output);\n  }\n  nColumn = nResultCol;\n\n  /* If the DISTINCT keyword was present on the SELECT statement\n  ** and this row has been seen before, then do not make this row\n  ** part of the result.\n  */\n  if( hasDistinct ){\n    assert( pEList!=0 );\n    assert( pEList->nExpr==nColumn );\n    switch( pDistinct->eTnctType ){\n      case WHERE_DISTINCT_ORDERED: {\n        VdbeOp *pOp;            /* No longer required OpenEphemeral instr. */\n        int iJump;              /* Jump destination */\n        int regPrev;            /* Previous row content */\n\n        /* Allocate space for the previous row */\n        regPrev = pParse->nMem+1;\n        pParse->nMem += nColumn;\n\n        /* Change the OP_OpenEphemeral coded earlier to an OP_Null\n        ** sets the MEM_Cleared bit on the first register of the\n        ** previous value.  This will cause the OP_Ne below to always\n        ** fail on the first iteration of the loop even if the first\n        ** row is all NULLs.\n        */\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);\n        pOp->opcode = OP_Null;\n        pOp->p1 = 1;\n        pOp->p2 = regPrev;\n\n        iJump = sqlite3VdbeCurrentAddr(v) + nColumn;\n        for(i=0; i<nColumn; i++){\n          CollSeq *pColl = sqlite3ExprCollSeq(pParse, pEList->a[i].pExpr);\n          if( i<nColumn-1 ){\n            sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i);\n          }\n          sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ);\n          sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        }\n        assert( sqlite3VdbeCurrentAddr(v)==iJump );\n        sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nColumn-1);\n        break;\n      }\n\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        break;\n      }\n\n      default: {\n        assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED );\n        codeDistinct(pParse, pDistinct->tabTnct, iContinue, nColumn, regResult);\n        break;\n      }\n    }\n    if( pOrderBy==0 ){\n      codeOffset(v, p, iContinue);\n    }\n  }\n\n  switch( eDest ){\n    /* In this mode, write each query result to the key of the temporary\n    ** table iParm.\n    */\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n    case SRT_Union: {\n      int r1;\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1);\n      sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* Construct a record from the query result, but instead of\n    ** saving that record, use it as a key to delete elements from\n    ** the temporary table iParm.\n    */\n    case SRT_Except: {\n      sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nColumn);\n      break;\n    }\n#endif\n\n    /* Store the result as data using a unique key.\n    */\n    case SRT_Table:\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempReg(pParse);\n      testcase( eDest==SRT_Table );\n      testcase( eDest==SRT_EphemTab );\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1);\n      if( pOrderBy ){\n        pushOntoSorter(pParse, pOrderBy, p, r1);\n      }else{\n        int r2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);\n        sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);\n        sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\" construct,\n    ** then there should be a single item on the stack.  Write this\n    ** item into the set table with bogus data.\n    */\n    case SRT_Set: {\n      assert( nColumn==1 );\n      pDest->affSdst =\n                  sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst);\n      if( pOrderBy ){\n        /* At first glance you would think we could optimize out the\n        ** ORDER BY in this case since the order of entries in the set\n        ** does not matter.  But there might be a LIMIT clause, in which\n        ** case the order does matter */\n        pushOntoSorter(pParse, pOrderBy, p, regResult);\n      }else{\n        int r1 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult,1,r1, &pDest->affSdst, 1);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, 1);\n        sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1);\n        sqlite3ReleaseTempReg(pParse, r1);\n      }\n      break;\n    }\n\n    /* If any row exist in the result set, record that fact and abort.\n    */\n    case SRT_Exists: {\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell and break out\n    ** of the scan loop.\n    */\n    case SRT_Mem: {\n      assert( nColumn==1 );\n      if( pOrderBy ){\n        pushOntoSorter(pParse, pOrderBy, p, regResult);\n      }else{\n        sqlite3ExprCodeMove(pParse, regResult, iParm, 1);\n        /* The LIMIT clause will jump out of the loop for us */\n      }\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    /* Send the data to the callback function or to a subroutine.  In the\n    ** case of a subroutine, the subroutine itself is responsible for\n    ** popping the data from the stack.\n    */\n    case SRT_Coroutine:\n    case SRT_Output: {\n      testcase( eDest==SRT_Coroutine );\n      testcase( eDest==SRT_Output );\n      if( pOrderBy ){\n        int r1 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nColumn, r1);\n        pushOntoSorter(pParse, pOrderBy, p, r1);\n        sqlite3ReleaseTempReg(pParse, r1);\n      }else if( eDest==SRT_Coroutine ){\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn);\n      }\n      break;\n    }\n\n#if !defined(SQLITE_OMIT_TRIGGER)\n    /* Discard the results.  This is used for SELECT statements inside\n    ** the body of a TRIGGER.  The purpose of such selects is to call\n    ** user-defined functions that have side effects.  We do not care\n    ** about the actual results of the select.\n    */\n    default: {\n      assert( eDest==SRT_Discard );\n      break;\n    }\n#endif\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.  Except, if\n  ** there is a sorter, in which case the sorter has already limited\n  ** the output for us.\n  */\n  if( pOrderBy==0 && p->iLimit ){\n    sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);\n  }\n}\n\n/*\n** Given an expression list, generate a KeyInfo structure that records\n** the collating sequence for each expression in that expression list.\n**\n** If the ExprList is an ORDER BY or GROUP BY clause then the resulting\n** KeyInfo structure is appropriate for initializing a virtual index to\n** implement that clause.  If the ExprList is the result set of a SELECT\n** then the KeyInfo structure is appropriate for initializing a virtual\n** index to implement a DISTINCT test.\n**\n** Space to hold the KeyInfo structure is obtain from malloc.  The calling\n** function is responsible for seeing that this structure is eventually\n** freed.  Add the KeyInfo structure to the P4 field of an opcode using\n** P4_KEYINFO_HANDOFF is the usual way of dealing with this.\n*/\nstatic KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){\n  sqlite3 *db = pParse->db;\n  int nExpr;\n  KeyInfo *pInfo;\n  struct ExprList_item *pItem;\n  int i;\n\n  nExpr = pList->nExpr;\n  pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) );\n  if( pInfo ){\n    pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr];\n    pInfo->nField = (u16)nExpr;\n    pInfo->enc = ENC(db);\n    pInfo->db = db;\n    for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){\n      CollSeq *pColl;\n      pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);\n      if( !pColl ){\n        pColl = db->pDfltColl;\n      }\n      pInfo->aColl[i] = pColl;\n      pInfo->aSortOrder[i] = pItem->sortOrder;\n    }\n  }\n  return pInfo;\n}\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** Name of the connection operator, used for error messages.\n*/\nstatic const char *selectOpName(int id){\n  char *z;\n  switch( id ){\n    case TK_ALL:       z = \"UNION ALL\";   break;\n    case TK_INTERSECT: z = \"INTERSECT\";   break;\n    case TK_EXCEPT:    z = \"EXCEPT\";      break;\n    default:           z = \"UNION\";       break;\n  }\n  return z;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of the form:\n**\n**   \"USE TEMP B-TREE FOR xxx\"\n**\n** where xxx is one of \"DISTINCT\", \"ORDER BY\" or \"GROUP BY\". Exactly which\n** is determined by the zUsage argument.\n*/\nstatic void explainTempTable(Parse *pParse, const char *zUsage){\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(pParse->db, \"USE TEMP B-TREE FOR %s\", zUsage);\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n\n/*\n** Assign expression b to lvalue a. A second, no-op, version of this macro\n** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code\n** in sqlite3Select() to assign values to structure member variables that\n** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the\n** code with #ifndef directives.\n*/\n# define explainSetInteger(a, b) a = b\n\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainTempTable(y,z)\n# define explainSetInteger(y,z)\n#endif\n\n#if !defined(SQLITE_OMIT_EXPLAIN) && !defined(SQLITE_OMIT_COMPOUND_SELECT)\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of one of the two forms:\n**\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 (op)\"\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)\"\n**\n** where iSub1 and iSub2 are the integers passed as the corresponding\n** function parameters, and op is the text representation of the parameter\n** of the same name. The parameter \"op\" must be one of TK_UNION, TK_EXCEPT,\n** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is \n** false, or the second form if it is true.\n*/\nstatic void explainComposite(\n  Parse *pParse,                  /* Parse context */\n  int op,                         /* One of TK_UNION, TK_EXCEPT etc. */\n  int iSub1,                      /* Subquery id 1 */\n  int iSub2,                      /* Subquery id 2 */\n  int bUseTmp                     /* True if a temp table was used */\n){\n  assert( op==TK_UNION || op==TK_EXCEPT || op==TK_INTERSECT || op==TK_ALL );\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(\n        pParse->db, \"COMPOUND SUBQUERIES %d AND %d %s(%s)\", iSub1, iSub2,\n        bUseTmp?\"USING TEMP B-TREE \":\"\", selectOpName(op)\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainComposite(v,w,x,y,z)\n#endif\n\n/*\n** If the inner loop was generated using a non-null pOrderBy argument,\n** then the results were placed in a sorter.  After the loop is terminated\n** we need to run the sorter and output the results.  The following\n** routine generates the code needed to do that.\n*/\nstatic void generateSortTail(\n  Parse *pParse,    /* Parsing context */\n  Select *p,        /* The SELECT statement */\n  Vdbe *v,          /* Generate code into this VDBE */\n  int nColumn,      /* Number of columns of data */\n  SelectDest *pDest /* Write the sorted results here */\n){\n  int addrBreak = sqlite3VdbeMakeLabel(v);     /* Jump here to exit loop */\n  int addrContinue = sqlite3VdbeMakeLabel(v);  /* Jump here for next cycle */\n  int addr;\n  int iTab;\n  int pseudoTab = 0;\n  ExprList *pOrderBy = p->pOrderBy;\n\n  int eDest = pDest->eDest;\n  int iParm = pDest->iSDParm;\n\n  int regRow;\n  int regRowid;\n\n  iTab = pOrderBy->iECursor;\n  regRow = sqlite3GetTempReg(pParse);\n  if( eDest==SRT_Output || eDest==SRT_Coroutine ){\n    pseudoTab = pParse->nTab++;\n    sqlite3VdbeAddOp3(v, OP_OpenPseudo, pseudoTab, regRow, nColumn);\n    regRowid = 0;\n  }else{\n    regRowid = sqlite3GetTempReg(pParse);\n  }\n  if( p->selFlags & SF_UseSorter ){\n    int regSortOut = ++pParse->nMem;\n    int ptab2 = pParse->nTab++;\n    sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);\n    codeOffset(v, p, addrContinue);\n    sqlite3VdbeAddOp2(v, OP_SorterData, iTab, regSortOut);\n    sqlite3VdbeAddOp3(v, OP_Column, ptab2, pOrderBy->nExpr+1, regRow);\n    sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE);\n  }else{\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak);\n    codeOffset(v, p, addrContinue);\n    sqlite3VdbeAddOp3(v, OP_Column, iTab, pOrderBy->nExpr+1, regRow);\n  }\n  switch( eDest ){\n    case SRT_Table:\n    case SRT_EphemTab: {\n      testcase( eDest==SRT_Table );\n      testcase( eDest==SRT_EphemTab );\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case SRT_Set: {\n      assert( nColumn==1 );\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, 1, regRowid,\n                        &pDest->affSdst, 1);\n      sqlite3ExprCacheAffinityChange(pParse, regRow, 1);\n      sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, regRowid);\n      break;\n    }\n    case SRT_Mem: {\n      assert( nColumn==1 );\n      sqlite3ExprCodeMove(pParse, regRow, iParm, 1);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n#endif\n    default: {\n      int i;\n      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); \n      testcase( eDest==SRT_Output );\n      testcase( eDest==SRT_Coroutine );\n      for(i=0; i<nColumn; i++){\n        assert( regRow!=pDest->iSdst+i );\n        sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iSdst+i);\n        if( i==0 ){\n          sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE);\n        }\n      }\n      if( eDest==SRT_Output ){\n        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);\n        sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn);\n      }else{\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regRow);\n  sqlite3ReleaseTempReg(pParse, regRowid);\n\n  /* The bottom of the loop\n  */\n  sqlite3VdbeResolveLabel(v, addrContinue);\n  if( p->selFlags & SF_UseSorter ){\n    sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, iTab, addr);\n  }\n  sqlite3VdbeResolveLabel(v, addrBreak);\n  if( eDest==SRT_Output || eDest==SRT_Coroutine ){\n    sqlite3VdbeAddOp2(v, OP_Close, pseudoTab, 0);\n  }\n}\n\n/*\n** Return a pointer to a string containing the 'declaration type' of the\n** expression pExpr. The string may be treated as static by the caller.\n**\n** The declaration type is the exact datatype definition extracted from the\n** original CREATE TABLE statement if the expression is a column. The\n** declaration type for a ROWID field is INTEGER. Exactly when an expression\n** is considered a column can be complex in the presence of subqueries. The\n** result-set expression in all of the following SELECT statements is \n** considered a column by this function.\n**\n**   SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl);\n**   SELECT abc FROM (SELECT col AS abc FROM tbl);\n** \n** The declaration type for any expression other than a column is NULL.\n*/\nstatic const char *columnType(\n  NameContext *pNC, \n  Expr *pExpr,\n  const char **pzOriginDb,\n  const char **pzOriginTab,\n  const char **pzOriginCol\n){\n  char const *zType = 0;\n  char const *zOriginDb = 0;\n  char const *zOriginTab = 0;\n  char const *zOriginCol = 0;\n  int j;\n  if( NEVER(pExpr==0) || pNC->pSrcList==0 ) return 0;\n\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      /* The expression is a column. Locate the table the column is being\n      ** extracted from in NameContext.pSrcList. This table may be real\n      ** database table or a subquery.\n      */\n      Table *pTab = 0;            /* Table structure column is extracted from */\n      Select *pS = 0;             /* Select the column is extracted from */\n      int iCol = pExpr->iColumn;  /* Index of column in pTab */\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      while( pNC && !pTab ){\n        SrcList *pTabList = pNC->pSrcList;\n        for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);\n        if( j<pTabList->nSrc ){\n          pTab = pTabList->a[j].pTab;\n          pS = pTabList->a[j].pSelect;\n        }else{\n          pNC = pNC->pNext;\n        }\n      }\n\n      if( pTab==0 ){\n        /* At one time, code such as \"SELECT new.x\" within a trigger would\n        ** cause this condition to run.  Since then, we have restructured how\n        ** trigger code is generated and so this condition is no longer \n        ** possible. However, it can still be true for statements like\n        ** the following:\n        **\n        **   CREATE TABLE t1(col INTEGER);\n        **   SELECT (SELECT t1.col) FROM FROM t1;\n        **\n        ** when columnType() is called on the expression \"t1.col\" in the \n        ** sub-select. In this case, set the column type to NULL, even\n        ** though it should really be \"INTEGER\".\n        **\n        ** This is not a problem, as the column type of \"t1.col\" is never\n        ** used. When columnType() is called on the expression \n        ** \"(SELECT t1.col)\", the correct type is returned (see the TK_SELECT\n        ** branch below.  */\n        break;\n      }\n\n      assert( pTab && pExpr->pTab==pTab );\n      if( pS ){\n        /* The \"table\" is actually a sub-select or a view in the FROM clause\n        ** of the SELECT statement. Return the declaration type and origin\n        ** data for the result-set column of the sub-select.\n        */\n        if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){\n          /* If iCol is less than zero, then the expression requests the\n          ** rowid of the sub-select or view. This expression is legal (see \n          ** test case misc2.2.2) - it always evaluates to NULL.\n          */\n          NameContext sNC;\n          Expr *p = pS->pEList->a[iCol].pExpr;\n          sNC.pSrcList = pS->pSrc;\n          sNC.pNext = pNC;\n          sNC.pParse = pNC->pParse;\n          zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol); \n        }\n      }else if( ALWAYS(pTab->pSchema) ){\n        /* A real table */\n        assert( !pS );\n        if( iCol<0 ) iCol = pTab->iPKey;\n        assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n          zOriginCol = \"rowid\";\n        }else{\n          zType = pTab->aCol[iCol].zType;\n          zOriginCol = pTab->aCol[iCol].zName;\n        }\n        zOriginTab = pTab->zName;\n        if( pNC->pParse ){\n          int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);\n          zOriginDb = pNC->pParse->db->aDb[iDb].zName;\n        }\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT: {\n      /* The expression is a sub-select. Return the declaration type and\n      ** origin info for the single column in the result set of the SELECT\n      ** statement.\n      */\n      NameContext sNC;\n      Select *pS = pExpr->x.pSelect;\n      Expr *p = pS->pEList->a[0].pExpr;\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n      sNC.pSrcList = pS->pSrc;\n      sNC.pNext = pNC;\n      sNC.pParse = pNC->pParse;\n      zType = columnType(&sNC, p, &zOriginDb, &zOriginTab, &zOriginCol); \n      break;\n    }\n#endif\n  }\n  \n  if( pzOriginDb ){\n    assert( pzOriginTab && pzOriginCol );\n    *pzOriginDb = zOriginDb;\n    *pzOriginTab = zOriginTab;\n    *pzOriginCol = zOriginCol;\n  }\n  return zType;\n}\n\n/*\n** Generate code that will tell the VDBE the declaration types of columns\n** in the result set.\n*/\nstatic void generateColumnTypes(\n  Parse *pParse,      /* Parser context */\n  SrcList *pTabList,  /* List of tables */\n  ExprList *pEList    /* Expressions defining the result set */\n){\n#ifndef SQLITE_OMIT_DECLTYPE\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  NameContext sNC;\n  sNC.pSrcList = pTabList;\n  sNC.pParse = pParse;\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n    const char *zType;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n    const char *zOrigDb = 0;\n    const char *zOrigTab = 0;\n    const char *zOrigCol = 0;\n    zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);\n\n    /* The vdbe must make its own copy of the column-type and other \n    ** column specific strings, in case the schema is reset before this\n    ** virtual machine is deleted.\n    */\n    sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);\n#else\n    zType = columnType(&sNC, p, 0, 0, 0);\n#endif\n    sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);\n  }\n#endif /* SQLITE_OMIT_DECLTYPE */\n}\n\n/*\n** Generate code that will tell the VDBE the names of columns\n** in the result set.  This information is used to provide the\n** azCol[] values in the callback.\n*/\nstatic void generateColumnNames(\n  Parse *pParse,      /* Parser context */\n  SrcList *pTabList,  /* List of tables */\n  ExprList *pEList    /* Expressions defining the result set */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i, j;\n  sqlite3 *db = pParse->db;\n  int fullNames, shortNames;\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  /* If this is an EXPLAIN, skip this step */\n  if( pParse->explain ){\n    return;\n  }\n#endif\n\n  if( pParse->colNamesSet || NEVER(v==0) || db->mallocFailed ) return;\n  pParse->colNamesSet = 1;\n  fullNames = (db->flags & SQLITE_FullColNames)!=0;\n  shortNames = (db->flags & SQLITE_ShortColNames)!=0;\n  sqlite3VdbeSetNumCols(v, pEList->nExpr);\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p;\n    p = pEList->a[i].pExpr;\n    if( NEVER(p==0) ) continue;\n    if( pEList->a[i].zName ){\n      char *zName = pEList->a[i].zName;\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);\n    }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) && pTabList ){\n      Table *pTab;\n      char *zCol;\n      int iCol = p->iColumn;\n      for(j=0; ALWAYS(j<pTabList->nSrc); j++){\n        if( pTabList->a[j].iCursor==p->iTable ) break;\n      }\n      assert( j<pTabList->nSrc );\n      pTab = pTabList->a[j].pTab;\n      if( iCol<0 ) iCol = pTab->iPKey;\n      assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );\n      if( iCol<0 ){\n        zCol = \"rowid\";\n      }else{\n        zCol = pTab->aCol[iCol].zName;\n      }\n      if( !shortNames && !fullNames ){\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, \n            sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);\n      }else if( fullNames ){\n        char *zName = 0;\n        zName = sqlite3MPrintf(db, \"%s.%s\", pTab->zName, zCol);\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);\n      }else{\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);\n      }\n    }else{\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, \n          sqlite3DbStrDup(db, pEList->a[i].zSpan), SQLITE_DYNAMIC);\n    }\n  }\n  generateColumnTypes(pParse, pTabList, pEList);\n}\n\n/*\n** Given a an expression list (which is really the list of expressions\n** that form the result set of a SELECT statement) compute appropriate\n** column names for a table that would hold the expression list.\n**\n** All column names will be unique.\n**\n** Only the column names are computed.  Column.zType, Column.zColl,\n** and other fields of Column are zeroed.\n**\n** Return SQLITE_OK on success.  If a memory allocation error occurs,\n** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM.\n*/\nstatic int selectColumnsFromExprList(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pEList,       /* Expr list from which to derive column names */\n  i16 *pnCol,             /* Write the number of columns here */\n  Column **paCol          /* Write the new column list here */\n){\n  sqlite3 *db = pParse->db;   /* Database connection */\n  int i, j;                   /* Loop counters */\n  int cnt;                    /* Index added to make the name unique */\n  Column *aCol, *pCol;        /* For looping over result columns */\n  int nCol;                   /* Number of columns in the result set */\n  Expr *p;                    /* Expression for a single result column */\n  char *zName;                /* Column name */\n  int nName;                  /* Size of name in zName[] */\n\n  if( pEList ){\n    nCol = pEList->nExpr;\n    aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);\n    testcase( aCol==0 );\n  }else{\n    nCol = 0;\n    aCol = 0;\n  }\n  *pnCol = nCol;\n  *paCol = aCol;\n\n  for(i=0, pCol=aCol; i<nCol; i++, pCol++){\n    /* Get an appropriate name for the column\n    */\n    p = sqlite3ExprSkipCollate(pEList->a[i].pExpr);\n    if( (zName = pEList->a[i].zName)!=0 ){\n      /* If the column contains an \"AS <name>\" phrase, use <name> as the name */\n      zName = sqlite3DbStrDup(db, zName);\n    }else{\n      Expr *pColExpr = p;  /* The expression that is the result column name */\n      Table *pTab;         /* Table associated with this expression */\n      while( pColExpr->op==TK_DOT ){\n        pColExpr = pColExpr->pRight;\n        assert( pColExpr!=0 );\n      }\n      if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){\n        /* For columns use the column name name */\n        int iCol = pColExpr->iColumn;\n        pTab = pColExpr->pTab;\n        if( iCol<0 ) iCol = pTab->iPKey;\n        zName = sqlite3MPrintf(db, \"%s\",\n                 iCol>=0 ? pTab->aCol[iCol].zName : \"rowid\");\n      }else if( pColExpr->op==TK_ID ){\n        assert( !ExprHasProperty(pColExpr, EP_IntValue) );\n        zName = sqlite3MPrintf(db, \"%s\", pColExpr->u.zToken);\n      }else{\n        /* Use the original text of the column expression as its name */\n        zName = sqlite3MPrintf(db, \"%s\", pEList->a[i].zSpan);\n      }\n    }\n    if( db->mallocFailed ){\n      sqlite3DbFree(db, zName);\n      break;\n    }\n\n    /* Make sure the column name is unique.  If the name is not unique,\n    ** append a integer to the name so that it becomes unique.\n    */\n    nName = sqlite3Strlen30(zName);\n    for(j=cnt=0; j<i; j++){\n      if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){\n        char *zNewName;\n        int k;\n        for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}\n        if( zName[k]==':' ) nName = k;\n        zName[nName] = 0;\n        zNewName = sqlite3MPrintf(db, \"%s:%d\", zName, ++cnt);\n        sqlite3DbFree(db, zName);\n        zName = zNewName;\n        j = -1;\n        if( zName==0 ) break;\n      }\n    }\n    pCol->zName = zName;\n  }\n  if( db->mallocFailed ){\n    for(j=0; j<i; j++){\n      sqlite3DbFree(db, aCol[j].zName);\n    }\n    sqlite3DbFree(db, aCol);\n    *paCol = 0;\n    *pnCol = 0;\n    return SQLITE_NOMEM;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Add type and collation information to a column list based on\n** a SELECT statement.\n** \n** The column list presumably came from selectColumnNamesFromExprList().\n** The column list has only names, not types or collations.  This\n** routine goes through and adds the types and collations.\n**\n** This routine requires that all identifiers in the SELECT\n** statement be resolved.\n*/\nstatic void selectAddColumnTypeAndCollation(\n  Parse *pParse,        /* Parsing contexts */\n  int nCol,             /* Number of columns */\n  Column *aCol,         /* List of columns */\n  Select *pSelect       /* SELECT used to determine types and collations */\n){\n  sqlite3 *db = pParse->db;\n  NameContext sNC;\n  Column *pCol;\n  CollSeq *pColl;\n  int i;\n  Expr *p;\n  struct ExprList_item *a;\n\n  assert( pSelect!=0 );\n  assert( (pSelect->selFlags & SF_Resolved)!=0 );\n  assert( nCol==pSelect->pEList->nExpr || db->mallocFailed );\n  if( db->mallocFailed ) return;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pSrcList = pSelect->pSrc;\n  a = pSelect->pEList->a;\n  for(i=0, pCol=aCol; i<nCol; i++, pCol++){\n    p = a[i].pExpr;\n    pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p, 0, 0, 0));\n    pCol->affinity = sqlite3ExprAffinity(p);\n    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    if( pColl ){\n      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);\n    }\n  }\n}\n\n/*\n** Given a SELECT statement, generate a Table structure that describes\n** the result set of that SELECT.\n*/\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){\n  Table *pTab;\n  sqlite3 *db = pParse->db;\n  int savedFlags;\n\n  savedFlags = db->flags;\n  db->flags &= ~SQLITE_FullColNames;\n  db->flags |= SQLITE_ShortColNames;\n  sqlite3SelectPrep(pParse, pSelect, 0);\n  if( pParse->nErr ) return 0;\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  db->flags = savedFlags;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table) );\n  if( pTab==0 ){\n    return 0;\n  }\n  /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside\n  ** is disabled */\n  assert( db->lookaside.bEnabled==0 );\n  pTab->nRef = 1;\n  pTab->zName = 0;\n  pTab->nRowEst = 1000000;\n  selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);\n  selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSelect);\n  pTab->iPKey = -1;\n  if( db->mallocFailed ){\n    sqlite3DeleteTable(db, pTab);\n    return 0;\n  }\n  return pTab;\n}\n\n/*\n** Get a VDBE for the given parser context.  Create a new one if necessary.\n** If an error occurs, return NULL and leave a message in pParse.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse *pParse){\n  Vdbe *v = pParse->pVdbe;\n  if( v==0 ){\n    v = pParse->pVdbe = sqlite3VdbeCreate(pParse->db);\n#ifndef SQLITE_OMIT_TRACE\n    if( v ){\n      sqlite3VdbeAddOp0(v, OP_Trace);\n    }\n#endif\n  }\n  return v;\n}\n\n\n/*\n** Compute the iLimit and iOffset fields of the SELECT based on the\n** pLimit and pOffset expressions.  pLimit and pOffset hold the expressions\n** that appear in the original SQL statement after the LIMIT and OFFSET\n** keywords.  Or NULL if those keywords are omitted. iLimit and iOffset \n** are the integer memory register numbers for counters used to compute \n** the limit and offset.  If there is no limit and/or offset, then \n** iLimit and iOffset are negative.\n**\n** This routine changes the values of iLimit and iOffset only if\n** a limit or offset is defined by pLimit and pOffset.  iLimit and\n** iOffset should have been preset to appropriate default values\n** (usually but not always -1) prior to calling this routine.\n** Only if pLimit!=0 or pOffset!=0 do the limit registers get\n** redefined.  The UNION ALL operator uses this property to force\n** the reuse of the same limit and offset registers across multiple\n** SELECT statements.\n*/\nstatic void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){\n  Vdbe *v = 0;\n  int iLimit = 0;\n  int iOffset;\n  int addr1, n;\n  if( p->iLimit ) return;\n\n  /* \n  ** \"LIMIT -1\" always shows all rows.  There is some\n  ** contraversy about what the correct behavior should be.\n  ** The current implementation interprets \"LIMIT 0\" to mean\n  ** no rows.\n  */\n  sqlite3ExprCacheClear(pParse);\n  assert( p->pOffset==0 || p->pLimit!=0 );\n  if( p->pLimit ){\n    p->iLimit = iLimit = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;  /* VDBE should have already been allocated */\n    if( sqlite3ExprIsInteger(p->pLimit, &n) ){\n      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      if( n==0 ){\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak);\n      }else{\n        if( p->nSelectRow > (double)n ) p->nSelectRow = (double)n;\n      }\n    }else{\n      sqlite3ExprCode(pParse, p->pLimit, iLimit);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak);\n    }\n    if( p->pOffset ){\n      p->iOffset = iOffset = ++pParse->nMem;\n      pParse->nMem++;   /* Allocate an extra register for limit+offset */\n      sqlite3ExprCode(pParse, p->pOffset, iOffset);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset);\n      VdbeComment((v, \"OFFSET counter\"));\n      addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iOffset);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iOffset);\n      sqlite3VdbeJumpHere(v, addr1);\n      sqlite3VdbeAddOp3(v, OP_Add, iLimit, iOffset, iOffset+1);\n      VdbeComment((v, \"LIMIT+OFFSET\"));\n      addr1 = sqlite3VdbeAddOp1(v, OP_IfPos, iLimit);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, iOffset+1);\n      sqlite3VdbeJumpHere(v, addr1);\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** Return the appropriate collating sequence for the iCol-th column of\n** the result set for the compound-select statement \"p\".  Return NULL if\n** the column has no default collating sequence.\n**\n** The collating sequence for the compound select is taken from the\n** left-most term of the select that has a collating sequence.\n*/\nstatic CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){\n  CollSeq *pRet;\n  if( p->pPrior ){\n    pRet = multiSelectCollSeq(pParse, p->pPrior, iCol);\n  }else{\n    pRet = 0;\n  }\n  assert( iCol>=0 );\n  if( pRet==0 && iCol<p->pEList->nExpr ){\n    pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);\n  }\n  return pRet;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n/* Forward reference */\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n);\n\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** This routine is called to process a compound query form from\n** two or more separate queries using UNION, UNION ALL, EXCEPT, or\n** INTERSECT\n**\n** \"p\" points to the right-most of the two queries.  the query on the\n** left is p->pPrior.  The left query could also be a compound query\n** in which case this routine will be called recursively. \n**\n** The results of the total query are to be written into a destination\n** of type eDest with parameter iParm.\n**\n** Example 1:  Consider a three-way compound SQL statement.\n**\n**     SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3\n**\n** This statement is parsed up as follows:\n**\n**     SELECT c FROM t3\n**      |\n**      `----->  SELECT b FROM t2\n**                |\n**                `------>  SELECT a FROM t1\n**\n** The arrows in the diagram above represent the Select.pPrior pointer.\n** So if this routine is called with p equal to the t3 query, then\n** pPrior will be the t2 query.  p->op will be TK_UNION in this case.\n**\n** Notice that because of the way SQLite parses compound SELECTs, the\n** individual selects always group from left to right.\n*/\nstatic int multiSelect(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int rc = SQLITE_OK;   /* Success code from a subroutine */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest dest;      /* Alternative data destination */\n  Select *pDelete = 0;  /* Chain of simple selects to delete */\n  sqlite3 *db;          /* Database connection */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1;            /* EQP id of left-hand query */\n  int iSub2;            /* EQP id of right-hand query */\n#endif\n\n  /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only\n  ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.\n  */\n  assert( p && p->pPrior );  /* Calling function guarantees this much */\n  db = pParse->db;\n  pPrior = p->pPrior;\n  assert( pPrior->pRightmost!=pPrior );\n  assert( pPrior->pRightmost==p->pRightmost );\n  dest = *pDest;\n  if( pPrior->pOrderBy ){\n    sqlite3ErrorMsg(pParse,\"ORDER BY clause should come after %s not before\",\n      selectOpName(p->op));\n    rc = 1;\n    goto multi_select_end;\n  }\n  if( pPrior->pLimit ){\n    sqlite3ErrorMsg(pParse,\"LIMIT clause should come after %s not before\",\n      selectOpName(p->op));\n    rc = 1;\n    goto multi_select_end;\n  }\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );  /* The VDBE already created by calling function */\n\n  /* Create the destination temporary table if necessary\n  */\n  if( dest.eDest==SRT_EphemTab ){\n    assert( p->pEList );\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);\n    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n    dest.eDest = SRT_Table;\n  }\n\n  /* Make sure all SELECTs in the statement have the same number of elements\n  ** in their result sets.\n  */\n  assert( p->pEList && pPrior->pEList );\n  if( p->pEList->nExpr!=pPrior->pEList->nExpr ){\n    if( p->selFlags & SF_Values ){\n      sqlite3ErrorMsg(pParse, \"all VALUES must have the same number of terms\");\n    }else{\n      sqlite3ErrorMsg(pParse, \"SELECTs to the left and right of %s\"\n        \" do not have the same number of result columns\", selectOpName(p->op));\n    }\n    rc = 1;\n    goto multi_select_end;\n  }\n\n  /* Compound SELECTs that have an ORDER BY clause are handled separately.\n  */\n  if( p->pOrderBy ){\n    return multiSelectOrderBy(pParse, p, pDest);\n  }\n\n  /* Generate code for the left and right SELECT statements.\n  */\n  switch( p->op ){\n    case TK_ALL: {\n      int addr = 0;\n      int nLimit;\n      assert( !pPrior->pLimit );\n      pPrior->iLimit = p->iLimit;\n      pPrior->iOffset = p->iOffset;\n      pPrior->pLimit = p->pLimit;\n      pPrior->pOffset = p->pOffset;\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &dest);\n      p->pLimit = 0;\n      p->pOffset = 0;\n      if( rc ){\n        goto multi_select_end;\n      }\n      p->pPrior = 0;\n      p->iLimit = pPrior->iLimit;\n      p->iOffset = pPrior->iOffset;\n      if( p->iLimit ){\n        addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit);\n        VdbeComment((v, \"Jump ahead if LIMIT reached\"));\n      }\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &dest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->nSelectRow += pPrior->nSelectRow;\n      if( pPrior->pLimit\n       && sqlite3ExprIsInteger(pPrior->pLimit, &nLimit)\n       && p->nSelectRow > (double)nLimit \n      ){\n        p->nSelectRow = (double)nLimit;\n      }\n      if( addr ){\n        sqlite3VdbeJumpHere(v, addr);\n      }\n      break;\n    }\n    case TK_EXCEPT:\n    case TK_UNION: {\n      int unionTab;    /* Cursor number of the temporary table holding result */\n      u8 op = 0;       /* One of the SRT_ operations to apply to self */\n      int priorOp;     /* The SRT_ operation to apply to prior selects */\n      Expr *pLimit, *pOffset; /* Saved values of p->nLimit and p->nOffset */\n      int addr;\n      SelectDest uniondest;\n\n      testcase( p->op==TK_EXCEPT );\n      testcase( p->op==TK_UNION );\n      priorOp = SRT_Union;\n      if( dest.eDest==priorOp && ALWAYS(!p->pLimit &&!p->pOffset) ){\n        /* We can reuse a temporary table generated by a SELECT to our\n        ** right.\n        */\n        assert( p->pRightmost!=p );  /* Can only happen for leftward elements\n                                     ** of a 3-way or more compound */\n        assert( p->pLimit==0 );      /* Not allowed on leftward elements */\n        assert( p->pOffset==0 );     /* Not allowed on leftward elements */\n        unionTab = dest.iSDParm;\n      }else{\n        /* We will need to create our own temporary table to hold the\n        ** intermediate results.\n        */\n        unionTab = pParse->nTab++;\n        assert( p->pOrderBy==0 );\n        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);\n        assert( p->addrOpenEphm[0] == -1 );\n        p->addrOpenEphm[0] = addr;\n        p->pRightmost->selFlags |= SF_UsesEphemeral;\n        assert( p->pEList );\n      }\n\n      /* Code the SELECT statements to our left\n      */\n      assert( !pPrior->pOrderBy );\n      sqlite3SelectDestInit(&uniondest, priorOp, unionTab);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &uniondest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT statement\n      */\n      if( p->op==TK_EXCEPT ){\n        op = SRT_Except;\n      }else{\n        assert( p->op==TK_UNION );\n        op = SRT_Union;\n      }\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      uniondest.eDest = op;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &uniondest);\n      testcase( rc!=SQLITE_OK );\n      /* Query flattening in sqlite3Select() might refill p->pOrderBy.\n      ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */\n      sqlite3ExprListDelete(db, p->pOrderBy);\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->pOrderBy = 0;\n      if( p->op==TK_UNION ) p->nSelectRow += pPrior->nSelectRow;\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n      p->iLimit = 0;\n      p->iOffset = 0;\n\n      /* Convert the data in the temporary table into whatever form\n      ** it is that we currently need.\n      */\n      assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );\n      if( dest.eDest!=priorOp ){\n        int iCont, iBreak, iStart;\n        assert( p->pEList );\n        if( dest.eDest==SRT_Output ){\n          Select *pFirst = p;\n          while( pFirst->pPrior ) pFirst = pFirst->pPrior;\n          generateColumnNames(pParse, 0, pFirst->pEList);\n        }\n        iBreak = sqlite3VdbeMakeLabel(v);\n        iCont = sqlite3VdbeMakeLabel(v);\n        computeLimitRegisters(pParse, p, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak);\n        iStart = sqlite3VdbeCurrentAddr(v);\n        selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr,\n                        0, 0, &dest, iCont, iBreak);\n        sqlite3VdbeResolveLabel(v, iCont);\n        sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart);\n        sqlite3VdbeResolveLabel(v, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);\n      }\n      break;\n    }\n    default: assert( p->op==TK_INTERSECT ); {\n      int tab1, tab2;\n      int iCont, iBreak, iStart;\n      Expr *pLimit, *pOffset;\n      int addr;\n      SelectDest intersectdest;\n      int r1;\n\n      /* INTERSECT is different from the others since it requires\n      ** two temporary tables.  Hence it has its own case.  Begin\n      ** by allocating the tables we will need.\n      */\n      tab1 = pParse->nTab++;\n      tab2 = pParse->nTab++;\n      assert( p->pOrderBy==0 );\n\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);\n      assert( p->addrOpenEphm[0] == -1 );\n      p->addrOpenEphm[0] = addr;\n      p->pRightmost->selFlags |= SF_UsesEphemeral;\n      assert( p->pEList );\n\n      /* Code the SELECTs to our left into temporary table \"tab1\".\n      */\n      sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &intersectdest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT into temporary table \"tab2\"\n      */\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);\n      assert( p->addrOpenEphm[1] == -1 );\n      p->addrOpenEphm[1] = addr;\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      intersectdest.iSDParm = tab2;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &intersectdest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      if( p->nSelectRow>pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n\n      /* Generate code to take the intersection of the two temporary\n      ** tables.\n      */\n      assert( p->pEList );\n      if( dest.eDest==SRT_Output ){\n        Select *pFirst = p;\n        while( pFirst->pPrior ) pFirst = pFirst->pPrior;\n        generateColumnNames(pParse, 0, pFirst->pEList);\n      }\n      iBreak = sqlite3VdbeMakeLabel(v);\n      iCont = sqlite3VdbeMakeLabel(v);\n      computeLimitRegisters(pParse, p, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak);\n      r1 = sqlite3GetTempReg(pParse);\n      iStart = sqlite3VdbeAddOp2(v, OP_RowKey, tab1, r1);\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);\n      sqlite3ReleaseTempReg(pParse, r1);\n      selectInnerLoop(pParse, p, p->pEList, tab1, p->pEList->nExpr,\n                      0, 0, &dest, iCont, iBreak);\n      sqlite3VdbeResolveLabel(v, iCont);\n      sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart);\n      sqlite3VdbeResolveLabel(v, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);\n      sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);\n      break;\n    }\n  }\n\n  explainComposite(pParse, p->op, iSub1, iSub2, p->op!=TK_ALL);\n\n  /* Compute collating sequences used by \n  ** temporary tables needed to implement the compound select.\n  ** Attach the KeyInfo structure to all temporary tables.\n  **\n  ** This section is run by the right-most SELECT statement only.\n  ** SELECT statements to the left always skip this part.  The right-most\n  ** SELECT might also skip this part if it has no ORDER BY clause and\n  ** no temp tables are required.\n  */\n  if( p->selFlags & SF_UsesEphemeral ){\n    int i;                        /* Loop counter */\n    KeyInfo *pKeyInfo;            /* Collating sequence for the result set */\n    Select *pLoop;                /* For looping through SELECT statements */\n    CollSeq **apColl;             /* For looping through pKeyInfo->aColl[] */\n    int nCol;                     /* Number of columns in result set */\n\n    assert( p->pRightmost==p );\n    nCol = p->pEList->nExpr;\n    pKeyInfo = sqlite3DbMallocZero(db,\n                       sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1));\n    if( !pKeyInfo ){\n      rc = SQLITE_NOMEM;\n      goto multi_select_end;\n    }\n\n    pKeyInfo->enc = ENC(db);\n    pKeyInfo->nField = (u16)nCol;\n\n    for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){\n      *apColl = multiSelectCollSeq(pParse, p, i);\n      if( 0==*apColl ){\n        *apColl = db->pDfltColl;\n      }\n    }\n    pKeyInfo->aSortOrder = (u8*)apColl;\n\n    for(pLoop=p; pLoop; pLoop=pLoop->pPrior){\n      for(i=0; i<2; i++){\n        int addr = pLoop->addrOpenEphm[i];\n        if( addr<0 ){\n          /* If [0] is unused then [1] is also unused.  So we can\n          ** always safely abort as soon as the first unused slot is found */\n          assert( pLoop->addrOpenEphm[1]<0 );\n          break;\n        }\n        sqlite3VdbeChangeP2(v, addr, nCol);\n        sqlite3VdbeChangeP4(v, addr, (char*)pKeyInfo, P4_KEYINFO);\n        pLoop->addrOpenEphm[i] = -1;\n      }\n    }\n    sqlite3DbFree(db, pKeyInfo);\n  }\n\nmulti_select_end:\n  pDest->iSdst = dest.iSdst;\n  pDest->nSdst = dest.nSdst;\n  sqlite3SelectDelete(db, pDelete);\n  return rc;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n/*\n** Code an output subroutine for a coroutine implementation of a\n** SELECT statment.\n**\n** The data to be output is contained in pIn->iSdst.  There are\n** pIn->nSdst columns to be output.  pDest is where the output should\n** be sent.\n**\n** regReturn is the number of the register holding the subroutine\n** return address.\n**\n** If regPrev>0 then it is the first register in a vector that\n** records the previous output.  mem[regPrev] is a flag that is false\n** if there has been no previous output.  If regPrev>0 then code is\n** generated to suppress duplicates.  pKeyInfo is used for comparing\n** keys.\n**\n** If the LIMIT found in p->iLimit is reached, jump immediately to\n** iBreak.\n*/\nstatic int generateOutputSubroutine(\n  Parse *pParse,          /* Parsing context */\n  Select *p,              /* The SELECT statement */\n  SelectDest *pIn,        /* Coroutine supplying data */\n  SelectDest *pDest,      /* Where to send the data */\n  int regReturn,          /* The return address register */\n  int regPrev,            /* Previous result register.  No uniqueness if 0 */\n  KeyInfo *pKeyInfo,      /* For comparing with previous entry */\n  int p4type,             /* The p4 type for pKeyInfo */\n  int iBreak              /* Jump here if we hit the LIMIT */\n){\n  Vdbe *v = pParse->pVdbe;\n  int iContinue;\n  int addr;\n\n  addr = sqlite3VdbeCurrentAddr(v);\n  iContinue = sqlite3VdbeMakeLabel(v);\n\n  /* Suppress duplicates for UNION, EXCEPT, and INTERSECT \n  */\n  if( regPrev ){\n    int j1, j2;\n    j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev);\n    j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,\n                              (char*)pKeyInfo, p4type);\n    sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2);\n    sqlite3VdbeJumpHere(v, j1);\n    sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);\n  }\n  if( pParse->db->mallocFailed ) return 0;\n\n  /* Suppress the first OFFSET entries if there is an OFFSET clause\n  */\n  codeOffset(v, p, iContinue);\n\n  switch( pDest->eDest ){\n    /* Store the result as data using a unique key.\n    */\n    case SRT_Table:\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempReg(pParse);\n      int r2 = sqlite3GetTempReg(pParse);\n      testcase( pDest->eDest==SRT_Table );\n      testcase( pDest->eDest==SRT_EphemTab );\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);\n      sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      sqlite3ReleaseTempReg(pParse, r2);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\" construct,\n    ** then there should be a single item on the stack.  Write this\n    ** item into the set table with bogus data.\n    */\n    case SRT_Set: {\n      int r1;\n      assert( pIn->nSdst==1 );\n      pDest->affSdst = \n         sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);\n      sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#if 0  /* Never occurs on an ORDER BY query */\n    /* If any row exist in the result set, record that fact and abort.\n    */\n    case SRT_Exists: {\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iSDParm);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n#endif\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell and break out\n    ** of the scan loop.\n    */\n    case SRT_Mem: {\n      assert( pIn->nSdst==1 );\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);\n      /* The LIMIT clause will jump out of the loop for us */\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    /* The results are stored in a sequence of registers\n    ** starting at pDest->iSdst.  Then the co-routine yields.\n    */\n    case SRT_Coroutine: {\n      if( pDest->iSdst==0 ){\n        pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);\n        pDest->nSdst = pIn->nSdst;\n      }\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst);\n      sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      break;\n    }\n\n    /* If none of the above, then the result destination must be\n    ** SRT_Output.  This routine is never called with any other\n    ** destination other than the ones handled above or SRT_Output.\n    **\n    ** For SRT_Output, results are stored in a sequence of registers.  \n    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to\n    ** return the next row of result.\n    */\n    default: {\n      assert( pDest->eDest==SRT_Output );\n      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);\n      break;\n    }\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.\n  */\n  if( p->iLimit ){\n    sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1);\n  }\n\n  /* Generate the subroutine return\n  */\n  sqlite3VdbeResolveLabel(v, iContinue);\n  sqlite3VdbeAddOp1(v, OP_Return, regReturn);\n\n  return addr;\n}\n\n/*\n** Alternative compound select code generator for cases when there\n** is an ORDER BY clause.\n**\n** We assume a query of the following form:\n**\n**      <selectA>  <operator>  <selectB>  ORDER BY <orderbylist>\n**\n** <operator> is one of UNION ALL, UNION, EXCEPT, or INTERSECT.  The idea\n** is to code both <selectA> and <selectB> with the ORDER BY clause as\n** co-routines.  Then run the co-routines in parallel and merge the results\n** into the output.  In addition to the two coroutines (called selectA and\n** selectB) there are 7 subroutines:\n**\n**    outA:    Move the output of the selectA coroutine into the output\n**             of the compound query.\n**\n**    outB:    Move the output of the selectB coroutine into the output\n**             of the compound query.  (Only generated for UNION and\n**             UNION ALL.  EXCEPT and INSERTSECT never output a row that\n**             appears only in B.)\n**\n**    AltB:    Called when there is data from both coroutines and A<B.\n**\n**    AeqB:    Called when there is data from both coroutines and A==B.\n**\n**    AgtB:    Called when there is data from both coroutines and A>B.\n**\n**    EofA:    Called when data is exhausted from selectA.\n**\n**    EofB:    Called when data is exhausted from selectB.\n**\n** The implementation of the latter five subroutines depend on which \n** <operator> is used:\n**\n**\n**             UNION ALL         UNION            EXCEPT          INTERSECT\n**          -------------  -----------------  --------------  -----------------\n**   AltB:   outA, nextA      outA, nextA       outA, nextA         nextA\n**\n**   AeqB:   outA, nextA         nextA             nextA         outA, nextA\n**\n**   AgtB:   outB, nextB      outB, nextB          nextB            nextB\n**\n**   EofA:   outB, nextB      outB, nextB          halt             halt\n**\n**   EofB:   outA, nextA      outA, nextA       outA, nextA         halt\n**\n** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA\n** causes an immediate jump to EofA and an EOF on B following nextB causes\n** an immediate jump to EofB.  Within EofA and EofB, and EOF on entry or\n** following nextX causes a jump to the end of the select processing.\n**\n** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled\n** within the output subroutine.  The regPrev register set holds the previously\n** output value.  A comparison is made against this value and the output\n** is skipped if the next results would be the same as the previous.\n**\n** The implementation plan is to implement the two coroutines and seven\n** subroutines first, then put the control logic at the bottom.  Like this:\n**\n**          goto Init\n**     coA: coroutine for left query (A)\n**     coB: coroutine for right query (B)\n**    outA: output one row of A\n**    outB: output one row of B (UNION and UNION ALL only)\n**    EofA: ...\n**    EofB: ...\n**    AltB: ...\n**    AeqB: ...\n**    AgtB: ...\n**    Init: initialize coroutine registers\n**          yield coA\n**          if eof(A) goto EofA\n**          yield coB\n**          if eof(B) goto EofB\n**    Cmpr: Compare A, B\n**          Jump AltB, AeqB, AgtB\n**     End: ...\n**\n** We call AltB, AeqB, AgtB, EofA, and EofB \"subroutines\" but they are not\n** actually called using Gosub and they do not Return.  EofA and EofB loop\n** until all data is exhausted then jump to the \"end\" labe.  AltB, AeqB,\n** and AgtB jump to either L2 or to one of EofA or EofB.\n*/\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int i, j;             /* Loop counters */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest destA;     /* Destination for coroutine A */\n  SelectDest destB;     /* Destination for coroutine B */\n  int regAddrA;         /* Address register for select-A coroutine */\n  int regEofA;          /* Flag to indicate when select-A is complete */\n  int regAddrB;         /* Address register for select-B coroutine */\n  int regEofB;          /* Flag to indicate when select-B is complete */\n  int addrSelectA;      /* Address of the select-A coroutine */\n  int addrSelectB;      /* Address of the select-B coroutine */\n  int regOutA;          /* Address register for the output-A subroutine */\n  int regOutB;          /* Address register for the output-B subroutine */\n  int addrOutA;         /* Address of the output-A subroutine */\n  int addrOutB = 0;     /* Address of the output-B subroutine */\n  int addrEofA;         /* Address of the select-A-exhausted subroutine */\n  int addrEofB;         /* Address of the select-B-exhausted subroutine */\n  int addrAltB;         /* Address of the A<B subroutine */\n  int addrAeqB;         /* Address of the A==B subroutine */\n  int addrAgtB;         /* Address of the A>B subroutine */\n  int regLimitA;        /* Limit register for select-A */\n  int regLimitB;        /* Limit register for select-A */\n  int regPrev;          /* A range of registers to hold previous output */\n  int savedLimit;       /* Saved value of p->iLimit */\n  int savedOffset;      /* Saved value of p->iOffset */\n  int labelCmpr;        /* Label for the start of the merge algorithm */\n  int labelEnd;         /* Label for the end of the overall SELECT stmt */\n  int j1;               /* Jump instructions that get retargetted */\n  int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */\n  KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */\n  KeyInfo *pKeyMerge;   /* Comparison information for merging rows */\n  sqlite3 *db;          /* Database connection */\n  ExprList *pOrderBy;   /* The ORDER BY clause */\n  int nOrderBy;         /* Number of terms in the ORDER BY clause */\n  int *aPermute;        /* Mapping from ORDER BY terms to result set columns */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1;            /* EQP id of left-hand query */\n  int iSub2;            /* EQP id of right-hand query */\n#endif\n\n  assert( p->pOrderBy!=0 );\n  assert( pKeyDup==0 ); /* \"Managed\" code needs this.  Ticket #3382. */\n  db = pParse->db;\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* Already thrown the error if VDBE alloc failed */\n  labelEnd = sqlite3VdbeMakeLabel(v);\n  labelCmpr = sqlite3VdbeMakeLabel(v);\n\n\n  /* Patch up the ORDER BY clause\n  */\n  op = p->op;  \n  pPrior = p->pPrior;\n  assert( pPrior->pOrderBy==0 );\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy );\n  nOrderBy = pOrderBy->nExpr;\n\n  /* For operators other than UNION ALL we have to make sure that\n  ** the ORDER BY clause covers every term of the result set.  Add\n  ** terms to the ORDER BY clause as necessary.\n  */\n  if( op!=TK_ALL ){\n    for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){\n      struct ExprList_item *pItem;\n      for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){\n        assert( pItem->iOrderByCol>0 );\n        if( pItem->iOrderByCol==i ) break;\n      }\n      if( j==nOrderBy ){\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return SQLITE_NOMEM;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = i;\n        pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew);\n        if( pOrderBy ) pOrderBy->a[nOrderBy++].iOrderByCol = (u16)i;\n      }\n    }\n  }\n\n  /* Compute the comparison permutation and keyinfo that is used with\n  ** the permutation used to determine if the next\n  ** row of results comes from selectA or selectB.  Also add explicit\n  ** collations to the ORDER BY clause terms so that when the subqueries\n  ** to the right and the left are evaluated, they use the correct\n  ** collation.\n  */\n  aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy);\n  if( aPermute ){\n    struct ExprList_item *pItem;\n    for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){\n      assert( pItem->iOrderByCol>0  && pItem->iOrderByCol<=p->pEList->nExpr );\n      aPermute[i] = pItem->iOrderByCol - 1;\n    }\n    pKeyMerge =\n      sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1));\n    if( pKeyMerge ){\n      pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy];\n      pKeyMerge->nField = (u16)nOrderBy;\n      pKeyMerge->enc = ENC(db);\n      for(i=0; i<nOrderBy; i++){\n        CollSeq *pColl;\n        Expr *pTerm = pOrderBy->a[i].pExpr;\n        if( pTerm->flags & EP_Collate ){\n          pColl = sqlite3ExprCollSeq(pParse, pTerm);\n        }else{\n          pColl = multiSelectCollSeq(pParse, p, aPermute[i]);\n          if( pColl==0 ) pColl = db->pDfltColl;\n          pOrderBy->a[i].pExpr =\n             sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);\n        }\n        pKeyMerge->aColl[i] = pColl;\n        pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder;\n      }\n    }\n  }else{\n    pKeyMerge = 0;\n  }\n\n  /* Reattach the ORDER BY clause to the query.\n  */\n  p->pOrderBy = pOrderBy;\n  pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);\n\n  /* Allocate a range of temporary registers and the KeyInfo needed\n  ** for the logic that removes duplicate result rows when the\n  ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).\n  */\n  if( op==TK_ALL ){\n    regPrev = 0;\n  }else{\n    int nExpr = p->pEList->nExpr;\n    assert( nOrderBy>=nExpr || db->mallocFailed );\n    regPrev = pParse->nMem+1;\n    pParse->nMem += nExpr+1;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);\n    pKeyDup = sqlite3DbMallocZero(db,\n                  sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) );\n    if( pKeyDup ){\n      pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr];\n      pKeyDup->nField = (u16)nExpr;\n      pKeyDup->enc = ENC(db);\n      for(i=0; i<nExpr; i++){\n        pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);\n        pKeyDup->aSortOrder[i] = 0;\n      }\n    }\n  }\n \n  /* Separate the left and the right query from one another\n  */\n  p->pPrior = 0;\n  sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, \"ORDER\");\n  if( pPrior->pPrior==0 ){\n    sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, \"ORDER\");\n  }\n\n  /* Compute the limit registers */\n  computeLimitRegisters(pParse, p, labelEnd);\n  if( p->iLimit && op==TK_ALL ){\n    regLimitA = ++pParse->nMem;\n    regLimitB = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit,\n                                  regLimitA);\n    sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB);\n  }else{\n    regLimitA = regLimitB = 0;\n  }\n  sqlite3ExprDelete(db, p->pLimit);\n  p->pLimit = 0;\n  sqlite3ExprDelete(db, p->pOffset);\n  p->pOffset = 0;\n\n  regAddrA = ++pParse->nMem;\n  regEofA = ++pParse->nMem;\n  regAddrB = ++pParse->nMem;\n  regEofB = ++pParse->nMem;\n  regOutA = ++pParse->nMem;\n  regOutB = ++pParse->nMem;\n  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);\n  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);\n\n  /* Jump past the various subroutines and coroutines to the main\n  ** merge loop\n  */\n  j1 = sqlite3VdbeAddOp0(v, OP_Goto);\n  addrSelectA = sqlite3VdbeCurrentAddr(v);\n\n\n  /* Generate a coroutine to evaluate the SELECT statement to the\n  ** left of the compound operator - the \"A\" select.\n  */\n  VdbeNoopComment((v, \"Begin coroutine for left SELECT\"));\n  pPrior->iLimit = regLimitA;\n  explainSetInteger(iSub1, pParse->iNextSelectId);\n  sqlite3Select(pParse, pPrior, &destA);\n  sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofA);\n  sqlite3VdbeAddOp1(v, OP_Yield, regAddrA);\n  VdbeNoopComment((v, \"End coroutine for left SELECT\"));\n\n  /* Generate a coroutine to evaluate the SELECT statement on \n  ** the right - the \"B\" select\n  */\n  addrSelectB = sqlite3VdbeCurrentAddr(v);\n  VdbeNoopComment((v, \"Begin coroutine for right SELECT\"));\n  savedLimit = p->iLimit;\n  savedOffset = p->iOffset;\n  p->iLimit = regLimitB;\n  p->iOffset = 0;  \n  explainSetInteger(iSub2, pParse->iNextSelectId);\n  sqlite3Select(pParse, p, &destB);\n  p->iLimit = savedLimit;\n  p->iOffset = savedOffset;\n  sqlite3VdbeAddOp2(v, OP_Integer, 1, regEofB);\n  sqlite3VdbeAddOp1(v, OP_Yield, regAddrB);\n  VdbeNoopComment((v, \"End coroutine for right SELECT\"));\n\n  /* Generate a subroutine that outputs the current row of the A\n  ** select as the next output row of the compound select.\n  */\n  VdbeNoopComment((v, \"Output routine for A\"));\n  addrOutA = generateOutputSubroutine(pParse,\n                 p, &destA, pDest, regOutA,\n                 regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd);\n  \n  /* Generate a subroutine that outputs the current row of the B\n  ** select as the next output row of the compound select.\n  */\n  if( op==TK_ALL || op==TK_UNION ){\n    VdbeNoopComment((v, \"Output routine for B\"));\n    addrOutB = generateOutputSubroutine(pParse,\n                 p, &destB, pDest, regOutB,\n                 regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd);\n  }\n\n  /* Generate a subroutine to run when the results from select A\n  ** are exhausted and only data in select B remains.\n  */\n  VdbeNoopComment((v, \"eof-A subroutine\"));\n  if( op==TK_EXCEPT || op==TK_INTERSECT ){\n    addrEofA = sqlite3VdbeAddOp2(v, OP_Goto, 0, labelEnd);\n  }else{  \n    addrEofA = sqlite3VdbeAddOp2(v, OP_If, regEofB, labelEnd);\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n    sqlite3VdbeAddOp1(v, OP_Yield, regAddrB);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofA);\n    p->nSelectRow += pPrior->nSelectRow;\n  }\n\n  /* Generate a subroutine to run when the results from select B\n  ** are exhausted and only data in select A remains.\n  */\n  if( op==TK_INTERSECT ){\n    addrEofB = addrEofA;\n    if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n  }else{  \n    VdbeNoopComment((v, \"eof-B subroutine\"));\n    addrEofB = sqlite3VdbeAddOp2(v, OP_If, regEofA, labelEnd);\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n    sqlite3VdbeAddOp1(v, OP_Yield, regAddrA);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofB);\n  }\n\n  /* Generate code to handle the case of A<B\n  */\n  VdbeNoopComment((v, \"A-lt-B subroutine\"));\n  addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n  sqlite3VdbeAddOp1(v, OP_Yield, regAddrA);\n  sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA);\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr);\n\n  /* Generate code to handle the case of A==B\n  */\n  if( op==TK_ALL ){\n    addrAeqB = addrAltB;\n  }else if( op==TK_INTERSECT ){\n    addrAeqB = addrAltB;\n    addrAltB++;\n  }else{\n    VdbeNoopComment((v, \"A-eq-B subroutine\"));\n    addrAeqB =\n    sqlite3VdbeAddOp1(v, OP_Yield, regAddrA);\n    sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA);\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr);\n  }\n\n  /* Generate code to handle the case of A>B\n  */\n  VdbeNoopComment((v, \"A-gt-B subroutine\"));\n  addrAgtB = sqlite3VdbeCurrentAddr(v);\n  if( op==TK_ALL || op==TK_UNION ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n  }\n  sqlite3VdbeAddOp1(v, OP_Yield, regAddrB);\n  sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB);\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr);\n\n  /* This code runs once to initialize everything.\n  */\n  sqlite3VdbeJumpHere(v, j1);\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofA);\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regEofB);\n  sqlite3VdbeAddOp2(v, OP_Gosub, regAddrA, addrSelectA);\n  sqlite3VdbeAddOp2(v, OP_Gosub, regAddrB, addrSelectB);\n  sqlite3VdbeAddOp2(v, OP_If, regEofA, addrEofA);\n  sqlite3VdbeAddOp2(v, OP_If, regEofB, addrEofB);\n\n  /* Implement the main merge loop\n  */\n  sqlite3VdbeResolveLabel(v, labelCmpr);\n  sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);\n  sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,\n                         (char*)pKeyMerge, P4_KEYINFO_HANDOFF);\n  sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);\n  sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB);\n\n  /* Jump to the this point in order to terminate the query.\n  */\n  sqlite3VdbeResolveLabel(v, labelEnd);\n\n  /* Set the number of output columns\n  */\n  if( pDest->eDest==SRT_Output ){\n    Select *pFirst = pPrior;\n    while( pFirst->pPrior ) pFirst = pFirst->pPrior;\n    generateColumnNames(pParse, 0, pFirst->pEList);\n  }\n\n  /* Reassembly the compound query so that it will be freed correctly\n  ** by the calling function */\n  if( p->pPrior ){\n    sqlite3SelectDelete(db, p->pPrior);\n  }\n  p->pPrior = pPrior;\n\n  /*** TBD:  Insert subroutine calls to close cursors on incomplete\n  **** subqueries ****/\n  explainComposite(pParse, p->op, iSub1, iSub2, 0);\n  return SQLITE_OK;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/* Forward Declarations */\nstatic void substExprList(sqlite3*, ExprList*, int, ExprList*);\nstatic void substSelect(sqlite3*, Select *, int, ExprList *);\n\n/*\n** Scan through the expression pExpr.  Replace every reference to\n** a column in table number iTable with a copy of the iColumn-th\n** entry in pEList.  (But leave references to the ROWID column \n** unchanged.)\n**\n** This routine is part of the flattening procedure.  A subquery\n** whose result set is defined by pEList appears as entry in the\n** FROM clause of a SELECT such that the VDBE cursor assigned to that\n** FORM clause entry is iTable.  This routine make the necessary \n** changes to pExpr so that it refers directly to the source table\n** of the subquery rather the result set of the subquery.\n*/\nstatic Expr *substExpr(\n  sqlite3 *db,        /* Report malloc errors to this connection */\n  Expr *pExpr,        /* Expr in which substitution occurs */\n  int iTable,         /* Table to be substituted */\n  ExprList *pEList    /* Substitute expressions */\n){\n  if( pExpr==0 ) return 0;\n  if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){\n    if( pExpr->iColumn<0 ){\n      pExpr->op = TK_NULL;\n    }else{\n      Expr *pNew;\n      assert( pEList!=0 && pExpr->iColumn<pEList->nExpr );\n      assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n      pNew = sqlite3ExprDup(db, pEList->a[pExpr->iColumn].pExpr, 0);\n      sqlite3ExprDelete(db, pExpr);\n      pExpr = pNew;\n    }\n  }else{\n    pExpr->pLeft = substExpr(db, pExpr->pLeft, iTable, pEList);\n    pExpr->pRight = substExpr(db, pExpr->pRight, iTable, pEList);\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      substSelect(db, pExpr->x.pSelect, iTable, pEList);\n    }else{\n      substExprList(db, pExpr->x.pList, iTable, pEList);\n    }\n  }\n  return pExpr;\n}\nstatic void substExprList(\n  sqlite3 *db,         /* Report malloc errors here */\n  ExprList *pList,     /* List to scan and in which to make substitutes */\n  int iTable,          /* Table to be substituted */\n  ExprList *pEList     /* Substitute values */\n){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nExpr; i++){\n    pList->a[i].pExpr = substExpr(db, pList->a[i].pExpr, iTable, pEList);\n  }\n}\nstatic void substSelect(\n  sqlite3 *db,         /* Report malloc errors here */\n  Select *p,           /* SELECT statement in which to make substitutions */\n  int iTable,          /* Table to be replaced */\n  ExprList *pEList     /* Substitute values */\n){\n  SrcList *pSrc;\n  struct SrcList_item *pItem;\n  int i;\n  if( !p ) return;\n  substExprList(db, p->pEList, iTable, pEList);\n  substExprList(db, p->pGroupBy, iTable, pEList);\n  substExprList(db, p->pOrderBy, iTable, pEList);\n  p->pHaving = substExpr(db, p->pHaving, iTable, pEList);\n  p->pWhere = substExpr(db, p->pWhere, iTable, pEList);\n  substSelect(db, p->pPrior, iTable, pEList);\n  pSrc = p->pSrc;\n  assert( pSrc );  /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */\n  if( ALWAYS(pSrc) ){\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      substSelect(db, pItem->pSelect, iTable, pEList);\n    }\n  }\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** This routine attempts to flatten subqueries as a performance optimization.\n** This routine returns 1 if it makes changes and 0 if no flattening occurs.\n**\n** To understand the concept of flattening, consider the following\n** query:\n**\n**     SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5\n**\n** The default way of implementing this query is to execute the\n** subquery first and store the results in a temporary table, then\n** run the outer query on that temporary table.  This requires two\n** passes over the data.  Furthermore, because the temporary table\n** has no indices, the WHERE clause on the outer query cannot be\n** optimized.\n**\n** This routine attempts to rewrite queries such as the above into\n** a single flat select, like this:\n**\n**     SELECT x+y AS a FROM t1 WHERE z<100 AND a>5\n**\n** The code generated for this simpification gives the same result\n** but only has to scan the data once.  And because indices might \n** exist on the table t1, a complete scan of the data might be\n** avoided.\n**\n** Flattening is only attempted if all of the following are true:\n**\n**   (1)  The subquery and the outer query do not both use aggregates.\n**\n**   (2)  The subquery is not an aggregate or the outer query is not a join.\n**\n**   (3)  The subquery is not the right operand of a left outer join\n**        (Originally ticket #306.  Strengthened by ticket #3300)\n**\n**   (4)  The subquery is not DISTINCT.\n**\n**  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT\n**        sub-queries that were excluded from this optimization. Restriction \n**        (4) has since been expanded to exclude all DISTINCT subqueries.\n**\n**   (6)  The subquery does not use aggregates or the outer query is not\n**        DISTINCT.\n**\n**   (7)  The subquery has a FROM clause.  TODO:  For subqueries without\n**        A FROM clause, consider adding a FROM close with the special\n**        table sqlite_once that consists of a single row containing a\n**        single NULL.\n**\n**   (8)  The subquery does not use LIMIT or the outer query is not a join.\n**\n**   (9)  The subquery does not use LIMIT or the outer query does not use\n**        aggregates.\n**\n**  (10)  The subquery does not use aggregates or the outer query does not\n**        use LIMIT.\n**\n**  (11)  The subquery and the outer query do not both have ORDER BY clauses.\n**\n**  (**)  Not implemented.  Subsumed into restriction (3).  Was previously\n**        a separate restriction deriving from ticket #350.\n**\n**  (13)  The subquery and outer query do not both use LIMIT.\n**\n**  (14)  The subquery does not use OFFSET.\n**\n**  (15)  The outer query is not part of a compound select or the\n**        subquery does not have a LIMIT clause.\n**        (See ticket #2339 and ticket [02a8e81d44]).\n**\n**  (16)  The outer query is not an aggregate or the subquery does\n**        not contain ORDER BY.  (Ticket #2942)  This used to not matter\n**        until we introduced the group_concat() function.  \n**\n**  (17)  The sub-query is not a compound select, or it is a UNION ALL \n**        compound clause made up entirely of non-aggregate queries, and \n**        the parent query:\n**\n**          * is not itself part of a compound select,\n**          * is not an aggregate or DISTINCT query, and\n**          * is not a join\n**\n**        The parent and sub-query may contain WHERE clauses. Subject to\n**        rules (11), (13) and (14), they may also contain ORDER BY,\n**        LIMIT and OFFSET clauses.  The subquery cannot use any compound\n**        operator other than UNION ALL because all the other compound\n**        operators have an implied DISTINCT which is disallowed by\n**        restriction (4).\n**\n**        Also, each component of the sub-query must return the same number\n**        of result columns. This is actually a requirement for any compound\n**        SELECT statement, but all the code here does is make sure that no\n**        such (illegal) sub-query is flattened. The caller will detect the\n**        syntax error and return a detailed message.\n**\n**  (18)  If the sub-query is a compound select, then all terms of the\n**        ORDER by clause of the parent must be simple references to \n**        columns of the sub-query.\n**\n**  (19)  The subquery does not use LIMIT or the outer query does not\n**        have a WHERE clause.\n**\n**  (20)  If the sub-query is a compound select, then it must not use\n**        an ORDER BY clause.  Ticket #3773.  We could relax this constraint\n**        somewhat by saying that the terms of the ORDER BY clause must\n**        appear as unmodified result columns in the outer query.  But we\n**        have other optimizations in mind to deal with that case.\n**\n**  (21)  The subquery does not use LIMIT or the outer query is not\n**        DISTINCT.  (See ticket [752e1646fc]).\n**\n** In this routine, the \"p\" parameter is a pointer to the outer query.\n** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query\n** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.\n**\n** If flattening is not attempted, this routine is a no-op and returns 0.\n** If flattening is attempted this routine returns 1.\n**\n** All of the expression analysis must occur on both the outer query and\n** the subquery before this routine runs.\n*/\nstatic int flattenSubquery(\n  Parse *pParse,       /* Parsing context */\n  Select *p,           /* The parent or outer SELECT statement */\n  int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */\n  int isAgg,           /* True if outer SELECT uses aggregate functions */\n  int subqueryIsAgg    /* True if the subquery uses aggregate functions */\n){\n  const char *zSavedAuthContext = pParse->zAuthContext;\n  Select *pParent;\n  Select *pSub;       /* The inner query or \"subquery\" */\n  Select *pSub1;      /* Pointer to the rightmost select in sub-query */\n  SrcList *pSrc;      /* The FROM clause of the outer query */\n  SrcList *pSubSrc;   /* The FROM clause of the subquery */\n  ExprList *pList;    /* The result set of the outer query */\n  int iParent;        /* VDBE cursor number of the pSub result set temp table */\n  int i;              /* Loop counter */\n  Expr *pWhere;                    /* The WHERE clause */\n  struct SrcList_item *pSubitem;   /* The subquery */\n  sqlite3 *db = pParse->db;\n\n  /* Check to see if flattening is permitted.  Return 0 if not.\n  */\n  assert( p!=0 );\n  assert( p->pPrior==0 );  /* Unable to flatten compound queries */\n  if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;\n  pSrc = p->pSrc;\n  assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );\n  pSubitem = &pSrc->a[iFrom];\n  iParent = pSubitem->iCursor;\n  pSub = pSubitem->pSelect;\n  assert( pSub!=0 );\n  if( isAgg && subqueryIsAgg ) return 0;                 /* Restriction (1)  */\n  if( subqueryIsAgg && pSrc->nSrc>1 ) return 0;          /* Restriction (2)  */\n  pSubSrc = pSub->pSrc;\n  assert( pSubSrc );\n  /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,\n  ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET\n  ** because they could be computed at compile-time.  But when LIMIT and OFFSET\n  ** became arbitrary expressions, we were forced to add restrictions (13)\n  ** and (14). */\n  if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */\n  if( pSub->pOffset ) return 0;                          /* Restriction (14) */\n  if( p->pRightmost && pSub->pLimit ){\n    return 0;                                            /* Restriction (15) */\n  }\n  if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */\n  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (5)  */\n  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){\n     return 0;         /* Restrictions (8)(9) */\n  }\n  if( (p->selFlags & SF_Distinct)!=0 && subqueryIsAgg ){\n     return 0;         /* Restriction (6)  */\n  }\n  if( p->pOrderBy && pSub->pOrderBy ){\n     return 0;                                           /* Restriction (11) */\n  }\n  if( isAgg && pSub->pOrderBy ) return 0;                /* Restriction (16) */\n  if( pSub->pLimit && p->pWhere ) return 0;              /* Restriction (19) */\n  if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){\n     return 0;         /* Restriction (21) */\n  }\n\n  /* OBSOLETE COMMENT 1:\n  ** Restriction 3:  If the subquery is a join, make sure the subquery is \n  ** not used as the right operand of an outer join.  Examples of why this\n  ** is not allowed:\n  **\n  **         t1 LEFT OUTER JOIN (t2 JOIN t3)\n  **\n  ** If we flatten the above, we would get\n  **\n  **         (t1 LEFT OUTER JOIN t2) JOIN t3\n  **\n  ** which is not at all the same thing.\n  **\n  ** OBSOLETE COMMENT 2:\n  ** Restriction 12:  If the subquery is the right operand of a left outer\n  ** join, make sure the subquery has no WHERE clause.\n  ** An examples of why this is not allowed:\n  **\n  **         t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0)\n  **\n  ** If we flatten the above, we would get\n  **\n  **         (t1 LEFT OUTER JOIN t2) WHERE t2.x>0\n  **\n  ** But the t2.x>0 test will always fail on a NULL row of t2, which\n  ** effectively converts the OUTER JOIN into an INNER JOIN.\n  **\n  ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE:\n  ** Ticket #3300 shows that flattening the right term of a LEFT JOIN\n  ** is fraught with danger.  Best to avoid the whole thing.  If the\n  ** subquery is the right term of a LEFT JOIN, then do not flatten.\n  */\n  if( (pSubitem->jointype & JT_OUTER)!=0 ){\n    return 0;\n  }\n\n  /* Restriction 17: If the sub-query is a compound SELECT, then it must\n  ** use only the UNION ALL operator. And none of the simple select queries\n  ** that make up the compound SELECT are allowed to be aggregate or distinct\n  ** queries.\n  */\n  if( pSub->pPrior ){\n    if( pSub->pOrderBy ){\n      return 0;  /* Restriction 20 */\n    }\n    if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){\n      return 0;\n    }\n    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n      assert( pSub->pSrc!=0 );\n      if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0\n       || (pSub1->pPrior && pSub1->op!=TK_ALL) \n       || pSub1->pSrc->nSrc<1\n       || pSub->pEList->nExpr!=pSub1->pEList->nExpr\n      ){\n        return 0;\n      }\n      testcase( pSub1->pSrc->nSrc>1 );\n    }\n\n    /* Restriction 18. */\n    if( p->pOrderBy ){\n      int ii;\n      for(ii=0; ii<p->pOrderBy->nExpr; ii++){\n        if( p->pOrderBy->a[ii].iOrderByCol==0 ) return 0;\n      }\n    }\n  }\n\n  /***** If we reach this point, flattening is permitted. *****/\n\n  /* Authorize the subquery */\n  pParse->zAuthContext = pSubitem->zName;\n  TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);\n  testcase( i==SQLITE_DENY );\n  pParse->zAuthContext = zSavedAuthContext;\n\n  /* If the sub-query is a compound SELECT statement, then (by restrictions\n  ** 17 and 18 above) it must be a UNION ALL and the parent query must \n  ** be of the form:\n  **\n  **     SELECT <expr-list> FROM (<sub-query>) <where-clause> \n  **\n  ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block\n  ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or \n  ** OFFSET clauses and joins them to the left-hand-side of the original\n  ** using UNION ALL operators. In this case N is the number of simple\n  ** select statements in the compound sub-query.\n  **\n  ** Example:\n  **\n  **     SELECT a+1 FROM (\n  **        SELECT x FROM tab\n  **        UNION ALL\n  **        SELECT y FROM tab\n  **        UNION ALL\n  **        SELECT abs(z*2) FROM tab2\n  **     ) WHERE a!=5 ORDER BY 1\n  **\n  ** Transformed into:\n  **\n  **     SELECT x+1 FROM tab WHERE x+1!=5\n  **     UNION ALL\n  **     SELECT y+1 FROM tab WHERE y+1!=5\n  **     UNION ALL\n  **     SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5\n  **     ORDER BY 1\n  **\n  ** We call this the \"compound-subquery flattening\".\n  */\n  for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){\n    Select *pNew;\n    ExprList *pOrderBy = p->pOrderBy;\n    Expr *pLimit = p->pLimit;\n    Expr *pOffset = p->pOffset;\n    Select *pPrior = p->pPrior;\n    p->pOrderBy = 0;\n    p->pSrc = 0;\n    p->pPrior = 0;\n    p->pLimit = 0;\n    p->pOffset = 0;\n    pNew = sqlite3SelectDup(db, p, 0);\n    p->pOffset = pOffset;\n    p->pLimit = pLimit;\n    p->pOrderBy = pOrderBy;\n    p->pSrc = pSrc;\n    p->op = TK_ALL;\n    p->pRightmost = 0;\n    if( pNew==0 ){\n      pNew = pPrior;\n    }else{\n      pNew->pPrior = pPrior;\n      pNew->pRightmost = 0;\n    }\n    p->pPrior = pNew;\n    if( db->mallocFailed ) return 1;\n  }\n\n  /* Begin flattening the iFrom-th entry of the FROM clause \n  ** in the outer query.\n  */\n  pSub = pSub1 = pSubitem->pSelect;\n\n  /* Delete the transient table structure associated with the\n  ** subquery\n  */\n  sqlite3DbFree(db, pSubitem->zDatabase);\n  sqlite3DbFree(db, pSubitem->zName);\n  sqlite3DbFree(db, pSubitem->zAlias);\n  pSubitem->zDatabase = 0;\n  pSubitem->zName = 0;\n  pSubitem->zAlias = 0;\n  pSubitem->pSelect = 0;\n\n  /* Defer deleting the Table object associated with the\n  ** subquery until code generation is\n  ** complete, since there may still exist Expr.pTab entries that\n  ** refer to the subquery even after flattening.  Ticket #3346.\n  **\n  ** pSubitem->pTab is always non-NULL by test restrictions and tests above.\n  */\n  if( ALWAYS(pSubitem->pTab!=0) ){\n    Table *pTabToDel = pSubitem->pTab;\n    if( pTabToDel->nRef==1 ){\n      Parse *pToplevel = sqlite3ParseToplevel(pParse);\n      pTabToDel->pNextZombie = pToplevel->pZombieTab;\n      pToplevel->pZombieTab = pTabToDel;\n    }else{\n      pTabToDel->nRef--;\n    }\n    pSubitem->pTab = 0;\n  }\n\n  /* The following loop runs once for each term in a compound-subquery\n  ** flattening (as described above).  If we are doing a different kind\n  ** of flattening - a flattening other than a compound-subquery flattening -\n  ** then this loop only runs once.\n  **\n  ** This loop moves all of the FROM elements of the subquery into the\n  ** the FROM clause of the outer query.  Before doing this, remember\n  ** the cursor number for the original outer query FROM element in\n  ** iParent.  The iParent cursor will never be used.  Subsequent code\n  ** will scan expressions looking for iParent references and replace\n  ** those references with expressions that resolve to the subquery FROM\n  ** elements we are now copying in.\n  */\n  for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){\n    int nSubSrc;\n    u8 jointype = 0;\n    pSubSrc = pSub->pSrc;     /* FROM clause of subquery */\n    nSubSrc = pSubSrc->nSrc;  /* Number of terms in subquery FROM clause */\n    pSrc = pParent->pSrc;     /* FROM clause of the outer query */\n\n    if( pSrc ){\n      assert( pParent==p );  /* First time through the loop */\n      jointype = pSubitem->jointype;\n    }else{\n      assert( pParent!=p );  /* 2nd and subsequent times through the loop */\n      pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n      if( pSrc==0 ){\n        assert( db->mallocFailed );\n        break;\n      }\n    }\n\n    /* The subquery uses a single slot of the FROM clause of the outer\n    ** query.  If the subquery has more than one element in its FROM clause,\n    ** then expand the outer query to make space for it to hold all elements\n    ** of the subquery.\n    **\n    ** Example:\n    **\n    **    SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;\n    **\n    ** The outer query has 3 slots in its FROM clause.  One slot of the\n    ** outer query (the middle slot) is used by the subquery.  The next\n    ** block of code will expand the out query to 4 slots.  The middle\n    ** slot is expanded to two slots in order to make space for the\n    ** two elements in the FROM clause of the subquery.\n    */\n    if( nSubSrc>1 ){\n      pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);\n      if( db->mallocFailed ){\n        break;\n      }\n    }\n\n    /* Transfer the FROM clause terms from the subquery into the\n    ** outer query.\n    */\n    for(i=0; i<nSubSrc; i++){\n      sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing);\n      pSrc->a[i+iFrom] = pSubSrc->a[i];\n      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));\n    }\n    pSrc->a[iFrom].jointype = jointype;\n  \n    /* Now begin substituting subquery result set expressions for \n    ** references to the iParent in the outer query.\n    ** \n    ** Example:\n    **\n    **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;\n    **   \\                     \\_____________ subquery __________/          /\n    **    \\_____________________ outer query ______________________________/\n    **\n    ** We look at every expression in the outer query and every place we see\n    ** \"a\" we substitute \"x*3\" and every place we see \"b\" we substitute \"y+10\".\n    */\n    pList = pParent->pEList;\n    for(i=0; i<pList->nExpr; i++){\n      if( pList->a[i].zName==0 ){\n        char *zName = sqlite3DbStrDup(db, pList->a[i].zSpan);\n        sqlite3Dequote(zName);\n        pList->a[i].zName = zName;\n      }\n    }\n    substExprList(db, pParent->pEList, iParent, pSub->pEList);\n    if( isAgg ){\n      substExprList(db, pParent->pGroupBy, iParent, pSub->pEList);\n      pParent->pHaving = substExpr(db, pParent->pHaving, iParent, pSub->pEList);\n    }\n    if( pSub->pOrderBy ){\n      assert( pParent->pOrderBy==0 );\n      pParent->pOrderBy = pSub->pOrderBy;\n      pSub->pOrderBy = 0;\n    }else if( pParent->pOrderBy ){\n      substExprList(db, pParent->pOrderBy, iParent, pSub->pEList);\n    }\n    if( pSub->pWhere ){\n      pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);\n    }else{\n      pWhere = 0;\n    }\n    if( subqueryIsAgg ){\n      assert( pParent->pHaving==0 );\n      pParent->pHaving = pParent->pWhere;\n      pParent->pWhere = pWhere;\n      pParent->pHaving = substExpr(db, pParent->pHaving, iParent, pSub->pEList);\n      pParent->pHaving = sqlite3ExprAnd(db, pParent->pHaving, \n                                  sqlite3ExprDup(db, pSub->pHaving, 0));\n      assert( pParent->pGroupBy==0 );\n      pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0);\n    }else{\n      pParent->pWhere = substExpr(db, pParent->pWhere, iParent, pSub->pEList);\n      pParent->pWhere = sqlite3ExprAnd(db, pParent->pWhere, pWhere);\n    }\n  \n    /* The flattened query is distinct if either the inner or the\n    ** outer query is distinct. \n    */\n    pParent->selFlags |= pSub->selFlags & SF_Distinct;\n  \n    /*\n    ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;\n    **\n    ** One is tempted to try to add a and b to combine the limits.  But this\n    ** does not work if either limit is negative.\n    */\n    if( pSub->pLimit ){\n      pParent->pLimit = pSub->pLimit;\n      pSub->pLimit = 0;\n    }\n  }\n\n  /* Finially, delete what is left of the subquery and return\n  ** success.\n  */\n  sqlite3SelectDelete(db, pSub1);\n\n  return 1;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n/*\n** Based on the contents of the AggInfo structure indicated by the first\n** argument, this function checks if the following are true:\n**\n**    * the query contains just a single aggregate function,\n**    * the aggregate function is either min() or max(), and\n**    * the argument to the aggregate function is a column value.\n**\n** If all of the above are true, then WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX\n** is returned as appropriate. Also, *ppMinMax is set to point to the \n** list of arguments passed to the aggregate before returning.\n**\n** Or, if the conditions above are not met, *ppMinMax is set to 0 and\n** WHERE_ORDERBY_NORMAL is returned.\n*/\nstatic u8 minMaxQuery(AggInfo *pAggInfo, ExprList **ppMinMax){\n  int eRet = WHERE_ORDERBY_NORMAL;          /* Return value */\n\n  *ppMinMax = 0;\n  if( pAggInfo->nFunc==1 ){\n    Expr *pExpr = pAggInfo->aFunc[0].pExpr; /* Aggregate function */\n    ExprList *pEList = pExpr->x.pList;      /* Arguments to agg function */\n\n    assert( pExpr->op==TK_AGG_FUNCTION );\n    if( pEList && pEList->nExpr==1 && pEList->a[0].pExpr->op==TK_AGG_COLUMN ){\n      const char *zFunc = pExpr->u.zToken;\n      if( sqlite3StrICmp(zFunc, \"min\")==0 ){\n        eRet = WHERE_ORDERBY_MIN;\n        *ppMinMax = pEList;\n      }else if( sqlite3StrICmp(zFunc, \"max\")==0 ){\n        eRet = WHERE_ORDERBY_MAX;\n        *ppMinMax = pEList;\n      }\n    }\n  }\n\n  assert( *ppMinMax==0 || (*ppMinMax)->nExpr==1 );\n  return eRet;\n}\n\n/*\n** The select statement passed as the first argument is an aggregate query.\n** The second argment is the associated aggregate-info object. This \n** function tests if the SELECT is of the form:\n**\n**   SELECT count(*) FROM <tbl>\n**\n** where table is a database table, not a sub-select or view. If the query\n** does match this pattern, then a pointer to the Table object representing\n** <tbl> is returned. Otherwise, 0 is returned.\n*/\nstatic Table *isSimpleCount(Select *p, AggInfo *pAggInfo){\n  Table *pTab;\n  Expr *pExpr;\n\n  assert( !p->pGroupBy );\n\n  if( p->pWhere || p->pEList->nExpr!=1 \n   || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect\n  ){\n    return 0;\n  }\n  pTab = p->pSrc->a[0].pTab;\n  pExpr = p->pEList->a[0].pExpr;\n  assert( pTab && !pTab->pSelect && pExpr );\n\n  if( IsVirtual(pTab) ) return 0;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;\n  if( NEVER(pAggInfo->nFunc==0) ) return 0;\n  if( (pAggInfo->aFunc[0].pFunc->flags&SQLITE_FUNC_COUNT)==0 ) return 0;\n  if( pExpr->flags&EP_Distinct ) return 0;\n\n  return pTab;\n}\n\n/*\n** If the source-list item passed as an argument was augmented with an\n** INDEXED BY clause, then try to locate the specified index. If there\n** was such a clause and the named index cannot be found, return \n** SQLITE_ERROR and leave an error in pParse. Otherwise, populate \n** pFrom->pIndex and return SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->pTab && pFrom->zIndex ){\n    Table *pTab = pFrom->pTab;\n    char *zIndex = pFrom->zIndex;\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; \n        pIdx && sqlite3StrICmp(pIdx->zName, zIndex); \n        pIdx=pIdx->pNext\n    );\n    if( !pIdx ){\n      sqlite3ErrorMsg(pParse, \"no such index: %s\", zIndex, 0);\n      pParse->checkSchema = 1;\n      return SQLITE_ERROR;\n    }\n    pFrom->pIndex = pIdx;\n  }\n  return SQLITE_OK;\n}\n/*\n** Detect compound SELECT statements that use an ORDER BY clause with \n** an alternative collating sequence.\n**\n**    SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ...\n**\n** These are rewritten as a subquery:\n**\n**    SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2)\n**     ORDER BY ... COLLATE ...\n**\n** This transformation is necessary because the multiSelectOrderBy() routine\n** above that generates the code for a compound SELECT with an ORDER BY clause\n** uses a merge algorithm that requires the same collating sequence on the\n** result columns as on the ORDER BY clause.  See ticket\n** http://www.sqlite.org/src/info/6709574d2a\n**\n** This transformation is only needed for EXCEPT, INTERSECT, and UNION.\n** The UNION ALL operator works fine with multiSelectOrderBy() even when\n** there are COLLATE terms in the ORDER BY.\n*/\nstatic int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){\n  int i;\n  Select *pNew;\n  Select *pX;\n  sqlite3 *db;\n  struct ExprList_item *a;\n  SrcList *pNewSrc;\n  Parse *pParse;\n  Token dummy;\n\n  if( p->pPrior==0 ) return WRC_Continue;\n  if( p->pOrderBy==0 ) return WRC_Continue;\n  for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){}\n  if( pX==0 ) return WRC_Continue;\n  a = p->pOrderBy->a;\n  for(i=p->pOrderBy->nExpr-1; i>=0; i--){\n    if( a[i].pExpr->flags & EP_Collate ) break;\n  }\n  if( i<0 ) return WRC_Continue;\n\n  /* If we reach this point, that means the transformation is required. */\n\n  pParse = pWalker->pParse;\n  db = pParse->db;\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );\n  if( pNew==0 ) return WRC_Abort;\n  memset(&dummy, 0, sizeof(dummy));\n  pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);\n  if( pNewSrc==0 ) return WRC_Abort;\n  *pNew = *p;\n  p->pSrc = pNewSrc;\n  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ALL, 0));\n  p->op = TK_SELECT;\n  p->pWhere = 0;\n  pNew->pGroupBy = 0;\n  pNew->pHaving = 0;\n  pNew->pOrderBy = 0;\n  p->pPrior = 0;\n  pNew->pLimit = 0;\n  pNew->pOffset = 0;\n  return WRC_Continue;\n}\n\n/*\n** This routine is a Walker callback for \"expanding\" a SELECT statement.\n** \"Expanding\" means to do the following:\n**\n**    (1)  Make sure VDBE cursor numbers have been assigned to every\n**         element of the FROM clause.\n**\n**    (2)  Fill in the pTabList->a[].pTab fields in the SrcList that \n**         defines FROM clause.  When views appear in the FROM clause,\n**         fill pTabList->a[].pSelect with a copy of the SELECT statement\n**         that implements the view.  A copy is made of the view's SELECT\n**         statement so that we can freely modify or delete that statement\n**         without worrying about messing up the presistent representation\n**         of the view.\n**\n**    (3)  Add terms to the WHERE clause to accomodate the NATURAL keyword\n**         on joins and the ON and USING clause of joins.\n**\n**    (4)  Scan the list of columns in the result set (pEList) looking\n**         for instances of the \"*\" operator or the TABLE.* operator.\n**         If found, expand each \"*\" to be every column in every table\n**         and TABLE.* to be every column in TABLE.\n**\n*/\nstatic int selectExpander(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  int i, j, k;\n  SrcList *pTabList;\n  ExprList *pEList;\n  struct SrcList_item *pFrom;\n  sqlite3 *db = pParse->db;\n  Expr *pE, *pRight, *pExpr;\n  u16 selFlags = p->selFlags;\n\n  p->selFlags |= SF_Expanded;\n  if( db->mallocFailed  ){\n    return WRC_Abort;\n  }\n  if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){\n    return WRC_Prune;\n  }\n  pTabList = p->pSrc;\n  pEList = p->pEList;\n\n  /* Make sure cursor numbers have been assigned to all entries in\n  ** the FROM clause of the SELECT statement.\n  */\n  sqlite3SrcListAssignCursors(pParse, pTabList);\n\n  /* Look up every table named in the FROM clause of the select.  If\n  ** an entry of the FROM clause is a subquery instead of a table or view,\n  ** then create a transient table structure to describe the subquery.\n  */\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab;\n    if( pFrom->pTab!=0 ){\n      /* This statement has already been prepared.  There is no need\n      ** to go further. */\n      assert( i==0 );\n      return WRC_Prune;\n    }\n    if( pFrom->zName==0 ){\n#ifndef SQLITE_OMIT_SUBQUERY\n      Select *pSel = pFrom->pSelect;\n      /* A sub-query in the FROM clause of a SELECT */\n      assert( pSel!=0 );\n      assert( pFrom->pTab==0 );\n      sqlite3WalkSelect(pWalker, pSel);\n      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n      if( pTab==0 ) return WRC_Abort;\n      pTab->nRef = 1;\n      pTab->zName = sqlite3MPrintf(db, \"sqlite_subquery_%p_\", (void*)pTab);\n      while( pSel->pPrior ){ pSel = pSel->pPrior; }\n      selectColumnsFromExprList(pParse, pSel->pEList, &pTab->nCol, &pTab->aCol);\n      pTab->iPKey = -1;\n      pTab->nRowEst = 1000000;\n      pTab->tabFlags |= TF_Ephemeral;\n#endif\n    }else{\n      /* An ordinary table or view name in the FROM clause */\n      assert( pFrom->pTab==0 );\n      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);\n      if( pTab==0 ) return WRC_Abort;\n      if( pTab->nRef==0xffff ){\n        sqlite3ErrorMsg(pParse, \"too many references to \\\"%s\\\": max 65535\",\n           pTab->zName);\n        pFrom->pTab = 0;\n        return WRC_Abort;\n      }\n      pTab->nRef++;\n#if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE)\n      if( pTab->pSelect || IsVirtual(pTab) ){\n        /* We reach here if the named table is a really a view */\n        if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;\n        assert( pFrom->pSelect==0 );\n        pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);\n        sqlite3WalkSelect(pWalker, pFrom->pSelect);\n      }\n#endif\n    }\n\n    /* Locate the index named by the INDEXED BY clause, if any. */\n    if( sqlite3IndexedByLookup(pParse, pFrom) ){\n      return WRC_Abort;\n    }\n  }\n\n  /* Process NATURAL keywords, and ON and USING clauses of joins.\n  */\n  if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){\n    return WRC_Abort;\n  }\n\n  /* For every \"*\" that occurs in the column list, insert the names of\n  ** all columns in all tables.  And for every TABLE.* insert the names\n  ** of all columns in TABLE.  The parser inserted a special expression\n  ** with the TK_ALL operator for each \"*\" that it found in the column list.\n  ** The following code just has to locate the TK_ALL expressions and expand\n  ** each one to the list of all columns in all tables.\n  **\n  ** The first loop just checks to see if there are any \"*\" operators\n  ** that need expanding.\n  */\n  for(k=0; k<pEList->nExpr; k++){\n    pE = pEList->a[k].pExpr;\n    if( pE->op==TK_ALL ) break;\n    assert( pE->op!=TK_DOT || pE->pRight!=0 );\n    assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );\n    if( pE->op==TK_DOT && pE->pRight->op==TK_ALL ) break;\n  }\n  if( k<pEList->nExpr ){\n    /*\n    ** If we get here it means the result set contains one or more \"*\"\n    ** operators that need to be expanded.  Loop through each expression\n    ** in the result set and expand them one by one.\n    */\n    struct ExprList_item *a = pEList->a;\n    ExprList *pNew = 0;\n    int flags = pParse->db->flags;\n    int longNames = (flags & SQLITE_FullColNames)!=0\n                      && (flags & SQLITE_ShortColNames)==0;\n\n    /* When processing FROM-clause subqueries, it is always the case\n    ** that full_column_names=OFF and short_column_names=ON.  The\n    ** sqlite3ResultSetOfSelect() routine makes it so. */\n    assert( (p->selFlags & SF_NestedFrom)==0\n          || ((flags & SQLITE_FullColNames)==0 &&\n              (flags & SQLITE_ShortColNames)!=0) );\n\n    for(k=0; k<pEList->nExpr; k++){\n      pE = a[k].pExpr;\n      pRight = pE->pRight;\n      assert( pE->op!=TK_DOT || pRight!=0 );\n      if( pE->op!=TK_ALL && (pE->op!=TK_DOT || pRight->op!=TK_ALL) ){\n        /* This particular expression does not need to be expanded.\n        */\n        pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);\n        if( pNew ){\n          pNew->a[pNew->nExpr-1].zName = a[k].zName;\n          pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;\n          a[k].zName = 0;\n          a[k].zSpan = 0;\n        }\n        a[k].pExpr = 0;\n      }else{\n        /* This expression is a \"*\" or a \"TABLE.*\" and needs to be\n        ** expanded. */\n        int tableSeen = 0;      /* Set to 1 when TABLE matches */\n        char *zTName = 0;       /* text of name of TABLE */\n        if( pE->op==TK_DOT ){\n          assert( pE->pLeft!=0 );\n          assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );\n          zTName = pE->pLeft->u.zToken;\n        }\n        for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n          Table *pTab = pFrom->pTab;\n          Select *pSub = pFrom->pSelect;\n          char *zTabName = pFrom->zAlias;\n          const char *zSchemaName = 0;\n          int iDb;\n          if( zTabName==0 ){\n            zTabName = pTab->zName;\n          }\n          if( db->mallocFailed ) break;\n          if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){\n            pSub = 0;\n            if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){\n              continue;\n            }\n            iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n            zSchemaName = iDb>=0 ? db->aDb[iDb].zName : \"*\";\n          }\n          for(j=0; j<pTab->nCol; j++){\n            char *zName = pTab->aCol[j].zName;\n            char *zColname;  /* The computed column name */\n            char *zToFree;   /* Malloced string that needs to be freed */\n            Token sColname;  /* Computed column name as a token */\n\n            assert( zName );\n            if( zTName && pSub\n             && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0\n            ){\n              continue;\n            }\n\n            /* If a column is marked as 'hidden' (currently only possible\n            ** for virtual tables), do not include it in the expanded\n            ** result-set list.\n            */\n            if( IsHiddenColumn(&pTab->aCol[j]) ){\n              assert(IsVirtual(pTab));\n              continue;\n            }\n            tableSeen = 1;\n\n            if( i>0 && zTName==0 ){\n              if( (pFrom->jointype & JT_NATURAL)!=0\n                && tableAndColumnIndex(pTabList, i, zName, 0, 0)\n              ){\n                /* In a NATURAL join, omit the join columns from the \n                ** table to the right of the join */\n                continue;\n              }\n              if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){\n                /* In a join with a USING clause, omit columns in the\n                ** using clause from the table on the right. */\n                continue;\n              }\n            }\n            pRight = sqlite3Expr(db, TK_ID, zName);\n            zColname = zName;\n            zToFree = 0;\n            if( longNames || pTabList->nSrc>1 ){\n              Expr *pLeft;\n              pLeft = sqlite3Expr(db, TK_ID, zTabName);\n              pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);\n              if( zSchemaName ){\n                pLeft = sqlite3Expr(db, TK_ID, zSchemaName);\n                pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr, 0);\n              }\n              if( longNames ){\n                zColname = sqlite3MPrintf(db, \"%s.%s\", zTabName, zName);\n                zToFree = zColname;\n              }\n            }else{\n              pExpr = pRight;\n            }\n            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);\n            sColname.z = zColname;\n            sColname.n = sqlite3Strlen30(zColname);\n            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);\n            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){\n              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];\n              if( pSub ){\n                pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);\n                testcase( pX->zSpan==0 );\n              }else{\n                pX->zSpan = sqlite3MPrintf(db, \"%s.%s.%s\",\n                                           zSchemaName, zTabName, zColname);\n                testcase( pX->zSpan==0 );\n              }\n              pX->bSpanIsTab = 1;\n            }\n            sqlite3DbFree(db, zToFree);\n          }\n        }\n        if( !tableSeen ){\n          if( zTName ){\n            sqlite3ErrorMsg(pParse, \"no such table: %s\", zTName);\n          }else{\n            sqlite3ErrorMsg(pParse, \"no tables specified\");\n          }\n        }\n      }\n    }\n    sqlite3ExprListDelete(db, pEList);\n    p->pEList = pNew;\n  }\n#if SQLITE_MAX_COLUMN\n  if( p->pEList && p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns in result set\");\n  }\n#endif\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker.\n**\n** When this routine is the Walker.xExprCallback then expression trees\n** are walked without any actions being taken at each node.  Presumably,\n** when this routine is used for Walker.xExprCallback then \n** Walker.xSelectCallback is set to do something useful for every \n** subquery in the parser tree.\n*/\nstatic int exprWalkNoop(Walker *NotUsed, Expr *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n/*\n** This routine \"expands\" a SELECT statement and all of its subqueries.\n** For additional information on what it means to \"expand\" a SELECT\n** statement, see the comment on the selectExpand worker callback above.\n**\n** Expanding a SELECT statement is the first step in processing a\n** SELECT statement.  The SELECT statement must be expanded before\n** name resolution is performed.\n**\n** If anything goes wrong, an error message is written into pParse.\n** The calling function can detect the problem by looking at pParse->nErr\n** and/or pParse->db->mallocFailed.\n*/\nstatic void sqlite3SelectExpand(Parse *pParse, Select *pSelect){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.xSelectCallback = convertCompoundSelectToSubquery;\n  w.xExprCallback = exprWalkNoop;\n  w.pParse = pParse;\n  sqlite3WalkSelect(&w, pSelect);\n  w.xSelectCallback = selectExpander;\n  sqlite3WalkSelect(&w, pSelect);\n}\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()\n** interface.\n**\n** For each FROM-clause subquery, add Column.zType and Column.zColl\n** information to the Table structure that represents the result set\n** of that subquery.\n**\n** The Table structure that represents the result set was constructed\n** by selectExpander() but the type and collation information was omitted\n** at that point because identifiers had not yet been resolved.  This\n** routine is called after identifier resolution.\n*/\nstatic int selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){\n  Parse *pParse;\n  int i;\n  SrcList *pTabList;\n  struct SrcList_item *pFrom;\n\n  assert( p->selFlags & SF_Resolved );\n  if( (p->selFlags & SF_HasTypeInfo)==0 ){\n    p->selFlags |= SF_HasTypeInfo;\n    pParse = pWalker->pParse;\n    pTabList = p->pSrc;\n    for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n      Table *pTab = pFrom->pTab;\n      if( ALWAYS(pTab!=0) && (pTab->tabFlags & TF_Ephemeral)!=0 ){\n        /* A sub-query in the FROM clause of a SELECT */\n        Select *pSel = pFrom->pSelect;\n        assert( pSel );\n        while( pSel->pPrior ) pSel = pSel->pPrior;\n        selectAddColumnTypeAndCollation(pParse, pTab->nCol, pTab->aCol, pSel);\n      }\n    }\n  }\n  return WRC_Continue;\n}\n#endif\n\n\n/*\n** This routine adds datatype and collating sequence information to\n** the Table structures of all FROM-clause subqueries in a\n** SELECT statement.\n**\n** Use this routine after name resolution.\n*/\nstatic void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){\n#ifndef SQLITE_OMIT_SUBQUERY\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.xSelectCallback = selectAddSubqueryTypeInfo;\n  w.xExprCallback = exprWalkNoop;\n  w.pParse = pParse;\n  w.bSelectDepthFirst = 1;\n  sqlite3WalkSelect(&w, pSelect);\n#endif\n}\n\n\n/*\n** This routine sets up a SELECT statement for processing.  The\n** following is accomplished:\n**\n**     *  VDBE Cursor numbers are assigned to all FROM-clause terms.\n**     *  Ephemeral Table objects are created for all FROM-clause subqueries.\n**     *  ON and USING clauses are shifted into WHERE statements\n**     *  Wildcards \"*\" and \"TABLE.*\" in result sets are expanded.\n**     *  Identifiers in expression are matched to tables.\n**\n** This routine acts recursively on all subqueries within the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3SelectPrep(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for container */\n){\n  sqlite3 *db;\n  if( NEVER(p==0) ) return;\n  db = pParse->db;\n  if( db->mallocFailed ) return;\n  if( p->selFlags & SF_HasTypeInfo ) return;\n  sqlite3SelectExpand(pParse, p);\n  if( pParse->nErr || db->mallocFailed ) return;\n  sqlite3ResolveSelectNames(pParse, p, pOuterNC);\n  if( pParse->nErr || db->mallocFailed ) return;\n  sqlite3SelectAddTypeInfo(pParse, p);\n}\n\n/*\n** Reset the aggregate accumulator.\n**\n** The aggregate accumulator is a set of memory cells that hold\n** intermediate results while calculating an aggregate.  This\n** routine generates code that stores NULLs in all of those memory\n** cells.\n*/\nstatic void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pFunc;\n  if( pAggInfo->nFunc+pAggInfo->nColumn==0 ){\n    return;\n  }\n  for(i=0; i<pAggInfo->nColumn; i++){\n    sqlite3VdbeAddOp2(v, OP_Null, 0, pAggInfo->aCol[i].iMem);\n  }\n  for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){\n    sqlite3VdbeAddOp2(v, OP_Null, 0, pFunc->iMem);\n    if( pFunc->iDistinct>=0 ){\n      Expr *pE = pFunc->pExpr;\n      assert( !ExprHasProperty(pE, EP_xIsSelect) );\n      if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){\n        sqlite3ErrorMsg(pParse, \"DISTINCT aggregates must have exactly one \"\n           \"argument\");\n        pFunc->iDistinct = -1;\n      }else{\n        KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList);\n        sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,\n                          (char*)pKeyInfo, P4_KEYINFO_HANDOFF);\n      }\n    }\n  }\n}\n\n/*\n** Invoke the OP_AggFinalize opcode for every aggregate function\n** in the AggInfo structure.\n*/\nstatic void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pF;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    sqlite3VdbeAddOp4(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0, 0,\n                      (void*)pF->pFunc, P4_FUNCDEF);\n  }\n}\n\n/*\n** Update the accumulator memory cells for an aggregate based on\n** the current cursor position.\n*/\nstatic void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int regHit = 0;\n  int addrHitTest = 0;\n  struct AggInfo_func *pF;\n  struct AggInfo_col *pC;\n\n  pAggInfo->directMode = 1;\n  sqlite3ExprCacheClear(pParse);\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    int nArg;\n    int addrNext = 0;\n    int regAgg;\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    if( pList ){\n      nArg = pList->nExpr;\n      regAgg = sqlite3GetTempRange(pParse, nArg);\n      sqlite3ExprCodeExprList(pParse, pList, regAgg, 1);\n    }else{\n      nArg = 0;\n      regAgg = 0;\n    }\n    if( pF->iDistinct>=0 ){\n      addrNext = sqlite3VdbeMakeLabel(v);\n      assert( nArg==1 );\n      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);\n    }\n    if( pF->pFunc->flags & SQLITE_FUNC_NEEDCOLL ){\n      CollSeq *pColl = 0;\n      struct ExprList_item *pItem;\n      int j;\n      assert( pList!=0 );  /* pList!=0 if pF->pFunc has NEEDCOLL */\n      for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){\n        pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);\n      }\n      if( !pColl ){\n        pColl = pParse->db->pDfltColl;\n      }\n      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;\n      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);\n    }\n    sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,\n                      (void*)pF->pFunc, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, (u8)nArg);\n    sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);\n    sqlite3ReleaseTempRange(pParse, regAgg, nArg);\n    if( addrNext ){\n      sqlite3VdbeResolveLabel(v, addrNext);\n      sqlite3ExprCacheClear(pParse);\n    }\n  }\n\n  /* Before populating the accumulator registers, clear the column cache.\n  ** Otherwise, if any of the required column values are already present \n  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value\n  ** to pC->iMem. But by the time the value is used, the original register\n  ** may have been used, invalidating the underlying buffer holding the\n  ** text or blob value. See ticket [883034dcb5].\n  **\n  ** Another solution would be to change the OP_SCopy used to copy cached\n  ** values to an OP_Copy.\n  */\n  if( regHit ){\n    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit);\n  }\n  sqlite3ExprCacheClear(pParse);\n  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){\n    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);\n  }\n  pAggInfo->directMode = 0;\n  sqlite3ExprCacheClear(pParse);\n  if( addrHitTest ){\n    sqlite3VdbeJumpHere(v, addrHitTest);\n  }\n}\n\n/*\n** Add a single OP_Explain instruction to the VDBE to explain a simple\n** count(*) query (\"SELECT count(*) FROM pTab\").\n*/\n#ifndef SQLITE_OMIT_EXPLAIN\nstatic void explainSimpleCount(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being queried */\n  Index *pIdx                     /* Index used to optimize scan, or NULL */\n){\n  if( pParse->explain==2 ){\n    char *zEqp = sqlite3MPrintf(pParse->db, \"SCAN TABLE %s %s%s(~%d rows)\",\n        pTab->zName, \n        pIdx ? \"USING COVERING INDEX \" : \"\",\n        pIdx ? pIdx->zName : \"\",\n        pTab->nRowEst\n    );\n    sqlite3VdbeAddOp4(\n        pParse->pVdbe, OP_Explain, pParse->iSelectId, 0, 0, zEqp, P4_DYNAMIC\n    );\n  }\n}\n#else\n# define explainSimpleCount(a,b,c)\n#endif\n\n/*\n** Generate code for the SELECT statement given in the p argument.  \n**\n** The results are distributed in various ways depending on the\n** contents of the SelectDest structure pointed to by argument pDest\n** as follows:\n**\n**     pDest->eDest    Result\n**     ------------    -------------------------------------------\n**     SRT_Output      Generate a row of output (using the OP_ResultRow\n**                     opcode) for each row in the result set.\n**\n**     SRT_Mem         Only valid if the result is a single column.\n**                     Store the first column of the first result row\n**                     in register pDest->iSDParm then abandon the rest\n**                     of the query.  This destination implies \"LIMIT 1\".\n**\n**     SRT_Set         The result must be a single column.  Store each\n**                     row of result as the key in table pDest->iSDParm. \n**                     Apply the affinity pDest->affSdst before storing\n**                     results.  Used to implement \"IN (SELECT ...)\".\n**\n**     SRT_Union       Store results as a key in a temporary table \n**                     identified by pDest->iSDParm.\n**\n**     SRT_Except      Remove results from the temporary table pDest->iSDParm.\n**\n**     SRT_Table       Store results in temporary table pDest->iSDParm.\n**                     This is like SRT_EphemTab except that the table\n**                     is assumed to already be open.\n**\n**     SRT_EphemTab    Create an temporary table pDest->iSDParm and store\n**                     the result there. The cursor is left open after\n**                     returning.  This is like SRT_Table except that\n**                     this destination uses OP_OpenEphemeral to create\n**                     the table first.\n**\n**     SRT_Coroutine   Generate a co-routine that returns a new row of\n**                     results each time it is invoked.  The entry point\n**                     of the co-routine is stored in register pDest->iSDParm.\n**\n**     SRT_Exists      Store a 1 in memory cell pDest->iSDParm if the result\n**                     set is not empty.\n**\n**     SRT_Discard     Throw the results away.  This is used by SELECT\n**                     statements within triggers whose only purpose is\n**                     the side-effects of functions.\n**\n** This routine returns the number of errors.  If any errors are\n** encountered, then an appropriate error message is left in\n** pParse->zErrMsg.\n**\n** This routine does NOT free the Select structure passed in.  The\n** calling function needs to do that.\n*/\nSQLITE_PRIVATE int sqlite3Select(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  SelectDest *pDest      /* What to do with the query results */\n){\n  int i, j;              /* Loop counters */\n  WhereInfo *pWInfo;     /* Return from sqlite3WhereBegin() */\n  Vdbe *v;               /* The virtual machine under construction */\n  int isAgg;             /* True for select lists like \"count(*)\" */\n  ExprList *pEList;      /* List of columns to extract. */\n  SrcList *pTabList;     /* List of tables to select from */\n  Expr *pWhere;          /* The WHERE clause.  May be NULL */\n  ExprList *pOrderBy;    /* The ORDER BY clause.  May be NULL */\n  ExprList *pGroupBy;    /* The GROUP BY clause.  May be NULL */\n  Expr *pHaving;         /* The HAVING clause.  May be NULL */\n  int rc = 1;            /* Value to return from this function */\n  int addrSortIndex;     /* Address of an OP_OpenEphemeral instruction */\n  DistinctCtx sDistinct; /* Info on how to code the DISTINCT keyword */\n  AggInfo sAggInfo;      /* Information used by aggregate queries */\n  int iEnd;              /* Address of the end of the query */\n  sqlite3 *db;           /* The database connection */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iRestoreSelectId = pParse->iSelectId;\n  pParse->iSelectId = pParse->iNextSelectId++;\n#endif\n\n  db = pParse->db;\n  if( p==0 || db->mallocFailed || pParse->nErr ){\n    return 1;\n  }\n  if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;\n  memset(&sAggInfo, 0, sizeof(sAggInfo));\n\n  if( IgnorableOrderby(pDest) ){\n    assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || \n           pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard);\n    /* If ORDER BY makes no difference in the output then neither does\n    ** DISTINCT so it can be removed too. */\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    p->pOrderBy = 0;\n    p->selFlags &= ~SF_Distinct;\n  }\n  sqlite3SelectPrep(pParse, p, 0);\n  pOrderBy = p->pOrderBy;\n  pTabList = p->pSrc;\n  pEList = p->pEList;\n  if( pParse->nErr || db->mallocFailed ){\n    goto select_end;\n  }\n  isAgg = (p->selFlags & SF_Aggregate)!=0;\n  assert( pEList!=0 );\n\n  /* Begin generating code.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto select_end;\n\n  /* If writing to memory or generating a set\n  ** only a single column may be output.\n  */\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( checkForMultiColumnSelectError(pParse, pDest, pEList->nExpr) ){\n    goto select_end;\n  }\n#endif\n\n  /* Generate code for all sub-queries in the FROM clause\n  */\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    SelectDest dest;\n    Select *pSub = pItem->pSelect;\n    int isAggSub;\n\n    if( pSub==0 ) continue;\n\n    /* Sometimes the code for a subquery will be generated more than\n    ** once, if the subquery is part of the WHERE clause in a LEFT JOIN,\n    ** for example.  In that case, do not regenerate the code to manifest\n    ** a view or the co-routine to implement a view.  The first instance\n    ** is sufficient, though the subroutine to manifest the view does need\n    ** to be invoked again. */\n    if( pItem->addrFillSub ){\n      if( pItem->viaCoroutine==0 ){\n        sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub);\n      }\n      continue;\n    }\n\n    /* Increment Parse.nHeight by the height of the largest expression\n    ** tree refered to by this, the parent select. The child select\n    ** may contain expression trees of at most\n    ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit\n    ** more conservative than necessary, but much easier than enforcing\n    ** an exact limit.\n    */\n    pParse->nHeight += sqlite3SelectExprHeight(p);\n\n    isAggSub = (pSub->selFlags & SF_Aggregate)!=0;\n    if( flattenSubquery(pParse, p, i, isAgg, isAggSub) ){\n      /* This subquery can be absorbed into its parent. */\n      if( isAggSub ){\n        isAgg = 1;\n        p->selFlags |= SF_Aggregate;\n      }\n      i = -1;\n    }else if( pTabList->nSrc==1 && (p->selFlags & SF_Materialize)==0\n      && OptimizationEnabled(db, SQLITE_SubqCoroutine)\n    ){\n      /* Implement a co-routine that will return a single row of the result\n      ** set on each invocation.\n      */\n      int addrTop;\n      int addrEof;\n      pItem->regReturn = ++pParse->nMem;\n      addrEof = ++pParse->nMem;\n      /* Before coding the OP_Goto to jump to the start of the main routine,\n      ** ensure that the jump to the verify-schema routine has already\n      ** been coded. Otherwise, the verify-schema would likely be coded as \n      ** part of the co-routine. If the main routine then accessed the \n      ** database before invoking the co-routine for the first time (for \n      ** example to initialize a LIMIT register from a sub-select), it would \n      ** be doing so without having verified the schema version and obtained \n      ** the required db locks. See ticket d6b36be38.  */\n      sqlite3CodeVerifySchema(pParse, -1);\n      sqlite3VdbeAddOp0(v, OP_Goto);\n      addrTop = sqlite3VdbeAddOp1(v, OP_OpenPseudo, pItem->iCursor);\n      sqlite3VdbeChangeP5(v, 1);\n      VdbeComment((v, \"coroutine for %s\", pItem->pTab->zName));\n      pItem->addrFillSub = addrTop;\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, addrEof);\n      sqlite3VdbeChangeP5(v, 1);\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);\n      explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n      sqlite3Select(pParse, pSub, &dest);\n      pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;\n      pItem->viaCoroutine = 1;\n      sqlite3VdbeChangeP2(v, addrTop, dest.iSdst);\n      sqlite3VdbeChangeP3(v, addrTop, dest.nSdst);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, addrEof);\n      sqlite3VdbeAddOp1(v, OP_Yield, pItem->regReturn);\n      VdbeComment((v, \"end %s\", pItem->pTab->zName));\n      sqlite3VdbeJumpHere(v, addrTop-1);\n      sqlite3ClearTempRegCache(pParse);\n    }else{\n      /* Generate a subroutine that will fill an ephemeral table with\n      ** the content of this subquery.  pItem->addrFillSub will point\n      ** to the address of the generated subroutine.  pItem->regReturn\n      ** is a register allocated to hold the subroutine return address\n      */\n      int topAddr;\n      int onceAddr = 0;\n      int retAddr;\n      assert( pItem->addrFillSub==0 );\n      pItem->regReturn = ++pParse->nMem;\n      topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);\n      pItem->addrFillSub = topAddr+1;\n      VdbeNoopComment((v, \"materialize %s\", pItem->pTab->zName));\n      if( pItem->isCorrelated==0 ){\n        /* If the subquery is not correlated and if we are not inside of\n        ** a trigger, then we only need to compute the value of the subquery\n        ** once. */\n        onceAddr = sqlite3CodeOnce(pParse);\n      }\n      sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);\n      explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n      sqlite3Select(pParse, pSub, &dest);\n      pItem->pTab->nRowEst = (unsigned)pSub->nSelectRow;\n      if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);\n      retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);\n      VdbeComment((v, \"end %s\", pItem->pTab->zName));\n      sqlite3VdbeChangeP1(v, topAddr, retAddr);\n      sqlite3ClearTempRegCache(pParse);\n    }\n    if( /*pParse->nErr ||*/ db->mallocFailed ){\n      goto select_end;\n    }\n    pParse->nHeight -= sqlite3SelectExprHeight(p);\n    pTabList = p->pSrc;\n    if( !IgnorableOrderby(pDest) ){\n      pOrderBy = p->pOrderBy;\n    }\n  }\n  pEList = p->pEList;\n#endif\n  pWhere = p->pWhere;\n  pGroupBy = p->pGroupBy;\n  pHaving = p->pHaving;\n  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n  /* If there is are a sequence of queries, do the earlier ones first.\n  */\n  if( p->pPrior ){\n    if( p->pRightmost==0 ){\n      Select *pLoop, *pRight = 0;\n      int cnt = 0;\n      int mxSelect;\n      for(pLoop=p; pLoop; pLoop=pLoop->pPrior, cnt++){\n        pLoop->pRightmost = p;\n        pLoop->pNext = pRight;\n        pRight = pLoop;\n      }\n      mxSelect = db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT];\n      if( mxSelect && cnt>mxSelect ){\n        sqlite3ErrorMsg(pParse, \"too many terms in compound SELECT\");\n        goto select_end;\n      }\n    }\n    rc = multiSelect(pParse, p, pDest);\n    explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n    return rc;\n  }\n#endif\n\n  /* If there is both a GROUP BY and an ORDER BY clause and they are\n  ** identical, then disable the ORDER BY clause since the GROUP BY\n  ** will cause elements to come out in the correct order.  This is\n  ** an optimization - the correct answer should result regardless.\n  ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER\n  ** to disable this optimization for testing purposes.\n  */\n  if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0\n         && OptimizationEnabled(db, SQLITE_GroupByOrder) ){\n    pOrderBy = 0;\n  }\n\n  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and \n  ** if the select-list is the same as the ORDER BY list, then this query\n  ** can be rewritten as a GROUP BY. In other words, this:\n  **\n  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz\n  **\n  ** is transformed to:\n  **\n  **     SELECT xyz FROM ... GROUP BY xyz\n  **\n  ** The second form is preferred as a single index (or temp-table) may be \n  ** used for both the ORDER BY and DISTINCT processing. As originally \n  ** written the query must use a temp-table for at least one of the ORDER \n  ** BY and DISTINCT, and an index or separate temp-table for the other.\n  */\n  if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct \n   && sqlite3ExprListCompare(pOrderBy, p->pEList)==0\n  ){\n    p->selFlags &= ~SF_Distinct;\n    p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);\n    pGroupBy = p->pGroupBy;\n    pOrderBy = 0;\n    /* Notice that even thought SF_Distinct has been cleared from p->selFlags,\n    ** the sDistinct.isTnct is still set.  Hence, isTnct represents the\n    ** original setting of the SF_Distinct flag, not the current setting */\n    assert( sDistinct.isTnct );\n  }\n\n  /* If there is an ORDER BY clause, then this sorting\n  ** index might end up being unused if the data can be \n  ** extracted in pre-sorted order.  If that is the case, then the\n  ** OP_OpenEphemeral instruction will be changed to an OP_Noop once\n  ** we figure out that the sorting index is not needed.  The addrSortIndex\n  ** variable is used to facilitate that change.\n  */\n  if( pOrderBy ){\n    KeyInfo *pKeyInfo;\n    pKeyInfo = keyInfoFromExprList(pParse, pOrderBy);\n    pOrderBy->iECursor = pParse->nTab++;\n    p->addrOpenEphm[2] = addrSortIndex =\n      sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n                           pOrderBy->iECursor, pOrderBy->nExpr+2, 0,\n                           (char*)pKeyInfo, P4_KEYINFO_HANDOFF);\n  }else{\n    addrSortIndex = -1;\n  }\n\n  /* If the output is destined for a temporary table, open that table.\n  */\n  if( pDest->eDest==SRT_EphemTab ){\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr);\n  }\n\n  /* Set the limiter.\n  */\n  iEnd = sqlite3VdbeMakeLabel(v);\n  p->nSelectRow = (double)LARGEST_INT64;\n  computeLimitRegisters(pParse, p, iEnd);\n  if( p->iLimit==0 && addrSortIndex>=0 ){\n    sqlite3VdbeGetOp(v, addrSortIndex)->opcode = OP_SorterOpen;\n    p->selFlags |= SF_UseSorter;\n  }\n\n  /* Open a virtual index to use for the distinct set.\n  */\n  if( p->selFlags & SF_Distinct ){\n    sDistinct.tabTnct = pParse->nTab++;\n    sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n                                sDistinct.tabTnct, 0, 0,\n                                (char*)keyInfoFromExprList(pParse, p->pEList),\n                                P4_KEYINFO_HANDOFF);\n    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n    sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;\n  }else{\n    sDistinct.eTnctType = WHERE_DISTINCT_NOOP;\n  }\n\n  if( !isAgg && pGroupBy==0 ){\n    /* No aggregate functions and no GROUP BY clause */\n    ExprList *pDist = (sDistinct.isTnct ? p->pEList : 0);\n\n    /* Begin the database scan. */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pOrderBy, pDist, 0,0);\n    if( pWInfo==0 ) goto select_end;\n    if( pWInfo->nRowOut < p->nSelectRow ) p->nSelectRow = pWInfo->nRowOut;\n    if( pWInfo->eDistinct ) sDistinct.eTnctType = pWInfo->eDistinct;\n    if( pOrderBy && pWInfo->nOBSat==pOrderBy->nExpr ) pOrderBy = 0;\n\n    /* If sorting index that was created by a prior OP_OpenEphemeral \n    ** instruction ended up not being needed, then change the OP_OpenEphemeral\n    ** into an OP_Noop.\n    */\n    if( addrSortIndex>=0 && pOrderBy==0 ){\n      sqlite3VdbeChangeToNoop(v, addrSortIndex);\n      p->addrOpenEphm[2] = -1;\n    }\n\n    /* Use the standard inner loop. */\n    selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, &sDistinct, pDest,\n                    pWInfo->iContinue, pWInfo->iBreak);\n\n    /* End the database scan loop.\n    */\n    sqlite3WhereEnd(pWInfo);\n  }else{\n    /* This case when there exist aggregate functions or a GROUP BY clause\n    ** or both */\n    NameContext sNC;    /* Name context for processing aggregate information */\n    int iAMem;          /* First Mem address for storing current GROUP BY */\n    int iBMem;          /* First Mem address for previous GROUP BY */\n    int iUseFlag;       /* Mem address holding flag indicating that at least\n                        ** one row of the input to the aggregator has been\n                        ** processed */\n    int iAbortFlag;     /* Mem address which causes query abort if positive */\n    int groupBySort;    /* Rows come from source in GROUP BY order */\n    int addrEnd;        /* End of processing for this SELECT */\n    int sortPTab = 0;   /* Pseudotable used to decode sorting results */\n    int sortOut = 0;    /* Output register from the sorter */\n\n    /* Remove any and all aliases between the result set and the\n    ** GROUP BY clause.\n    */\n    if( pGroupBy ){\n      int k;                        /* Loop counter */\n      struct ExprList_item *pItem;  /* For looping over expression in a list */\n\n      for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0; k--, pItem++){\n        pItem->iAlias = 0;\n      }\n      for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0; k--, pItem++){\n        pItem->iAlias = 0;\n      }\n      if( p->nSelectRow>(double)100 ) p->nSelectRow = (double)100;\n    }else{\n      p->nSelectRow = (double)1;\n    }\n\n \n    /* Create a label to jump to when we want to abort the query */\n    addrEnd = sqlite3VdbeMakeLabel(v);\n\n    /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in\n    ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the\n    ** SELECT statement.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    sNC.pSrcList = pTabList;\n    sNC.pAggInfo = &sAggInfo;\n    sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr+1 : 0;\n    sAggInfo.pGroupBy = pGroupBy;\n    sqlite3ExprAnalyzeAggList(&sNC, pEList);\n    sqlite3ExprAnalyzeAggList(&sNC, pOrderBy);\n    if( pHaving ){\n      sqlite3ExprAnalyzeAggregates(&sNC, pHaving);\n    }\n    sAggInfo.nAccumulator = sAggInfo.nColumn;\n    for(i=0; i<sAggInfo.nFunc; i++){\n      assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );\n      sNC.ncFlags |= NC_InAggFunc;\n      sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);\n      sNC.ncFlags &= ~NC_InAggFunc;\n    }\n    if( db->mallocFailed ) goto select_end;\n\n    /* Processing for aggregates with GROUP BY is very different and\n    ** much more complex than aggregates without a GROUP BY.\n    */\n    if( pGroupBy ){\n      KeyInfo *pKeyInfo;  /* Keying information for the group by clause */\n      int j1;             /* A-vs-B comparision jump */\n      int addrOutputRow;  /* Start of subroutine that outputs a result row */\n      int regOutputRow;   /* Return address register for output subroutine */\n      int addrSetAbort;   /* Set the abort flag and return */\n      int addrTopOfLoop;  /* Top of the input loop */\n      int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */\n      int addrReset;      /* Subroutine for resetting the accumulator */\n      int regReset;       /* Return address register for reset subroutine */\n\n      /* If there is a GROUP BY clause we might need a sorting index to\n      ** implement it.  Allocate that sorting index now.  If it turns out\n      ** that we do not need it after all, the OP_SorterOpen instruction\n      ** will be converted into a Noop.  \n      */\n      sAggInfo.sortingIdx = pParse->nTab++;\n      pKeyInfo = keyInfoFromExprList(pParse, pGroupBy);\n      addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen, \n          sAggInfo.sortingIdx, sAggInfo.nSortingColumn, \n          0, (char*)pKeyInfo, P4_KEYINFO_HANDOFF);\n\n      /* Initialize memory locations used by GROUP BY aggregate processing\n      */\n      iUseFlag = ++pParse->nMem;\n      iAbortFlag = ++pParse->nMem;\n      regOutputRow = ++pParse->nMem;\n      addrOutputRow = sqlite3VdbeMakeLabel(v);\n      regReset = ++pParse->nMem;\n      addrReset = sqlite3VdbeMakeLabel(v);\n      iAMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      iBMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);\n      VdbeComment((v, \"clear abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);\n      VdbeComment((v, \"indicate accumulator empty\"));\n      sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);\n\n      /* Begin a loop that will extract all source rows in GROUP BY order.\n      ** This might involve two separate loops with an OP_Sort in between, or\n      ** it might be a single loop that uses an index to extract information\n      ** in the right order to begin with.\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0, 0, 0);\n      if( pWInfo==0 ) goto select_end;\n      if( pWInfo->nOBSat==pGroupBy->nExpr ){\n        /* The optimizer is able to deliver rows in group by order so\n        ** we do not have to sort.  The OP_OpenEphemeral table will be\n        ** cancelled later because we still need to use the pKeyInfo\n        */\n        groupBySort = 0;\n      }else{\n        /* Rows are coming out in undetermined order.  We have to push\n        ** each row into a sorting index, terminate the first loop,\n        ** then loop over the sorting index in order to get the output\n        ** in sorted order\n        */\n        int regBase;\n        int regRecord;\n        int nCol;\n        int nGroupBy;\n\n        explainTempTable(pParse, \n            (sDistinct.isTnct && (p->selFlags&SF_Distinct)==0) ?\n                    \"DISTINCT\" : \"GROUP BY\");\n\n        groupBySort = 1;\n        nGroupBy = pGroupBy->nExpr;\n        nCol = nGroupBy + 1;\n        j = nGroupBy+1;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          if( sAggInfo.aCol[i].iSorterColumn>=j ){\n            nCol++;\n            j++;\n          }\n        }\n        regBase = sqlite3GetTempRange(pParse, nCol);\n        sqlite3ExprCacheClear(pParse);\n        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0);\n        sqlite3VdbeAddOp2(v, OP_Sequence, sAggInfo.sortingIdx,regBase+nGroupBy);\n        j = nGroupBy+1;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          struct AggInfo_col *pCol = &sAggInfo.aCol[i];\n          if( pCol->iSorterColumn>=j ){\n            int r1 = j + regBase;\n            int r2;\n\n            r2 = sqlite3ExprCodeGetColumn(pParse, \n                               pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);\n            if( r1!=r2 ){\n              sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);\n            }\n            j++;\n          }\n        }\n        regRecord = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);\n        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);\n        sqlite3ReleaseTempReg(pParse, regRecord);\n        sqlite3ReleaseTempRange(pParse, regBase, nCol);\n        sqlite3WhereEnd(pWInfo);\n        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;\n        sortOut = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);\n        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);\n        VdbeComment((v, \"GROUP BY sort\"));\n        sAggInfo.useSortingIdx = 1;\n        sqlite3ExprCacheClear(pParse);\n      }\n\n      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...\n      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)\n      ** Then compare the current GROUP BY terms against the GROUP BY terms\n      ** from the previous row currently stored in a0, a1, a2...\n      */\n      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);\n      sqlite3ExprCacheClear(pParse);\n      if( groupBySort ){\n        sqlite3VdbeAddOp2(v, OP_SorterData, sAggInfo.sortingIdx, sortOut);\n      }\n      for(j=0; j<pGroupBy->nExpr; j++){\n        if( groupBySort ){\n          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);\n          if( j==0 ) sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE);\n        }else{\n          sAggInfo.directMode = 1;\n          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);\n        }\n      }\n      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,\n                          (char*)pKeyInfo, P4_KEYINFO);\n      j1 = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp3(v, OP_Jump, j1+1, 0, j1+1);\n\n      /* Generate code that runs whenever the GROUP BY changes.\n      ** Changes in the GROUP BY are detected by the previous code\n      ** block.  If there were no changes, this block is skipped.\n      **\n      ** This code copies current group by terms in b0,b1,b2,...\n      ** over to a0,a1,a2.  It then calls the output subroutine\n      ** and resets the aggregate accumulator registers in preparation\n      ** for the next GROUP BY batch.\n      */\n      sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output one row\"));\n      sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd);\n      VdbeComment((v, \"check abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      VdbeComment((v, \"reset accumulator\"));\n\n      /* Update the aggregate accumulators based on the content of\n      ** the current row\n      */\n      sqlite3VdbeJumpHere(v, j1);\n      updateAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);\n      VdbeComment((v, \"indicate data in accumulator\"));\n\n      /* End of the loop\n      */\n      if( groupBySort ){\n        sqlite3VdbeAddOp2(v, OP_SorterNext, sAggInfo.sortingIdx, addrTopOfLoop);\n      }else{\n        sqlite3WhereEnd(pWInfo);\n        sqlite3VdbeChangeToNoop(v, addrSortingIdx);\n      }\n\n      /* Output the final row of result\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output final row\"));\n\n      /* Jump over the subroutines\n      */\n      sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEnd);\n\n      /* Generate a subroutine that outputs a single row of the result\n      ** set.  This subroutine first looks at the iUseFlag.  If iUseFlag\n      ** is less than or equal to zero, the subroutine is a no-op.  If\n      ** the processing calls for the query to abort, this subroutine\n      ** increments the iAbortFlag memory location before returning in\n      ** order to signal the caller to abort.\n      */\n      addrSetAbort = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag);\n      VdbeComment((v, \"set abort flag\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      sqlite3VdbeResolveLabel(v, addrOutputRow);\n      addrOutputRow = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);\n      VdbeComment((v, \"Groupby result generator entry point\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      finalizeAggFunctions(pParse, &sAggInfo);\n      sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, p->pEList, 0, 0, pOrderBy,\n                      &sDistinct, pDest,\n                      addrOutputRow+1, addrSetAbort);\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      VdbeComment((v, \"end groupby result generator\"));\n\n      /* Generate a subroutine that will reset the group-by accumulator\n      */\n      sqlite3VdbeResolveLabel(v, addrReset);\n      resetAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp1(v, OP_Return, regReset);\n     \n    } /* endif pGroupBy.  Begin aggregate queries without GROUP BY: */\n    else {\n      ExprList *pDel = 0;\n#ifndef SQLITE_OMIT_BTREECOUNT\n      Table *pTab;\n      if( (pTab = isSimpleCount(p, &sAggInfo))!=0 ){\n        /* If isSimpleCount() returns a pointer to a Table structure, then\n        ** the SQL statement is of the form:\n        **\n        **   SELECT count(*) FROM <tbl>\n        **\n        ** where the Table structure returned represents table <tbl>.\n        **\n        ** This statement is so common that it is optimized specially. The\n        ** OP_Count instruction is executed either on the intkey table that\n        ** contains the data for table <tbl> or on one of its indexes. It\n        ** is better to execute the op on an index, as indexes are almost\n        ** always spread across less pages than their corresponding tables.\n        */\n        const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n        const int iCsr = pParse->nTab++;     /* Cursor to scan b-tree */\n        Index *pIdx;                         /* Iterator variable */\n        KeyInfo *pKeyInfo = 0;               /* Keyinfo for scanned index */\n        Index *pBest = 0;                    /* Best index found so far */\n        int iRoot = pTab->tnum;              /* Root page of scanned b-tree */\n\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n        /* Search for the index that has the least amount of columns. If\n        ** there is such an index, and it has less columns than the table\n        ** does, then we can assume that it consumes less space on disk and\n        ** will therefore be cheaper to scan to determine the query result.\n        ** In this case set iRoot to the root page number of the index b-tree\n        ** and pKeyInfo to the KeyInfo structure required to navigate the\n        ** index.\n        **\n        ** (2011-04-15) Do not do a full scan of an unordered index.\n        **\n        ** In practice the KeyInfo structure will not be used. It is only \n        ** passed to keep OP_OpenRead happy.\n        */\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( pIdx->bUnordered==0 && (!pBest || pIdx->nColumn<pBest->nColumn) ){\n            pBest = pIdx;\n          }\n        }\n        if( pBest && pBest->nColumn<pTab->nCol ){\n          iRoot = pBest->tnum;\n          pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest);\n        }\n\n        /* Open a read-only cursor, execute the OP_Count, close the cursor. */\n        sqlite3VdbeAddOp3(v, OP_OpenRead, iCsr, iRoot, iDb);\n        if( pKeyInfo ){\n          sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO_HANDOFF);\n        }\n        sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem);\n        sqlite3VdbeAddOp1(v, OP_Close, iCsr);\n        explainSimpleCount(pParse, pTab, pBest);\n      }else\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      {\n        /* Check if the query is of one of the following forms:\n        **\n        **   SELECT min(x) FROM ...\n        **   SELECT max(x) FROM ...\n        **\n        ** If it is, then ask the code in where.c to attempt to sort results\n        ** as if there was an \"ORDER ON x\" or \"ORDER ON x DESC\" clause. \n        ** If where.c is able to produce results sorted in this order, then\n        ** add vdbe code to break out of the processing loop after the \n        ** first iteration (since the first iteration of the loop is \n        ** guaranteed to operate on the row with the minimum or maximum \n        ** value of x, the only row required).\n        **\n        ** A special flag must be passed to sqlite3WhereBegin() to slightly\n        ** modify behavior as follows:\n        **\n        **   + If the query is a \"SELECT min(x)\", then the loop coded by\n        **     where.c should not iterate over any values with a NULL value\n        **     for x.\n        **\n        **   + The optimizer code in where.c (the thing that decides which\n        **     index or indices to use) should place a different priority on \n        **     satisfying the 'ORDER BY' clause than it does in other cases.\n        **     Refer to code and comments in where.c for details.\n        */\n        ExprList *pMinMax = 0;\n        u8 flag = WHERE_ORDERBY_NORMAL;\n        \n        assert( p->pGroupBy==0 );\n        assert( flag==0 );\n        if( p->pHaving==0 ){\n          flag = minMaxQuery(&sAggInfo, &pMinMax);\n        }\n        assert( flag==0 || (pMinMax!=0 && pMinMax->nExpr==1) );\n\n        if( flag ){\n          pMinMax = sqlite3ExprListDup(db, pMinMax, 0);\n          pDel = pMinMax;\n          if( pMinMax && !db->mallocFailed ){\n            pMinMax->a[0].sortOrder = flag!=WHERE_ORDERBY_MIN ?1:0;\n            pMinMax->a[0].pExpr->op = TK_COLUMN;\n          }\n        }\n  \n        /* This case runs if the aggregate has no GROUP BY clause.  The\n        ** processing is much simpler since there is only a single row\n        ** of output.\n        */\n        resetAccumulator(pParse, &sAggInfo);\n        pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMax,0,flag,0);\n        if( pWInfo==0 ){\n          sqlite3ExprListDelete(db, pDel);\n          goto select_end;\n        }\n        updateAccumulator(pParse, &sAggInfo);\n        assert( pMinMax==0 || pMinMax->nExpr==1 );\n        if( pWInfo->nOBSat>0 ){\n          sqlite3VdbeAddOp2(v, OP_Goto, 0, pWInfo->iBreak);\n          VdbeComment((v, \"%s() by index\",\n                (flag==WHERE_ORDERBY_MIN?\"min\":\"max\")));\n        }\n        sqlite3WhereEnd(pWInfo);\n        finalizeAggFunctions(pParse, &sAggInfo);\n      }\n\n      pOrderBy = 0;\n      sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, p->pEList, 0, 0, 0, 0, \n                      pDest, addrEnd, addrEnd);\n      sqlite3ExprListDelete(db, pDel);\n    }\n    sqlite3VdbeResolveLabel(v, addrEnd);\n    \n  } /* endif aggregate query */\n\n  if( sDistinct.eTnctType==WHERE_DISTINCT_UNORDERED ){\n    explainTempTable(pParse, \"DISTINCT\");\n  }\n\n  /* If there is an ORDER BY clause, then we need to sort the results\n  ** and send them to the callback one by one.\n  */\n  if( pOrderBy ){\n    explainTempTable(pParse, \"ORDER BY\");\n    generateSortTail(pParse, p, v, pEList->nExpr, pDest);\n  }\n\n  /* Jump here to skip this query\n  */\n  sqlite3VdbeResolveLabel(v, iEnd);\n\n  /* The SELECT was successfully coded.   Set the return code to 0\n  ** to indicate no errors.\n  */\n  rc = 0;\n\n  /* Control jumps to here if an error is encountered above, or upon\n  ** successful coding of the SELECT.\n  */\nselect_end:\n  explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n\n  /* Identify column names if results of the SELECT are to be output.\n  */\n  if( rc==SQLITE_OK && pDest->eDest==SRT_Output ){\n    generateColumnNames(pParse, pTabList, pEList);\n  }\n\n  sqlite3DbFree(db, sAggInfo.aCol);\n  sqlite3DbFree(db, sAggInfo.aFunc);\n  return rc;\n}\n\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n/*\n** Generate a human-readable description of a the Select object.\n*/\nstatic void explainOneSelect(Vdbe *pVdbe, Select *p){\n  sqlite3ExplainPrintf(pVdbe, \"SELECT \");\n  if( p->selFlags & (SF_Distinct|SF_Aggregate) ){\n    if( p->selFlags & SF_Distinct ){\n      sqlite3ExplainPrintf(pVdbe, \"DISTINCT \");\n    }\n    if( p->selFlags & SF_Aggregate ){\n      sqlite3ExplainPrintf(pVdbe, \"agg_flag \");\n    }\n    sqlite3ExplainNL(pVdbe);\n    sqlite3ExplainPrintf(pVdbe, \"   \");\n  }\n  sqlite3ExplainExprList(pVdbe, p->pEList);\n  sqlite3ExplainNL(pVdbe);\n  if( p->pSrc && p->pSrc->nSrc ){\n    int i;\n    sqlite3ExplainPrintf(pVdbe, \"FROM \");\n    sqlite3ExplainPush(pVdbe);\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      sqlite3ExplainPrintf(pVdbe, \"{%d,*} = \", pItem->iCursor);\n      if( pItem->pSelect ){\n        sqlite3ExplainSelect(pVdbe, pItem->pSelect);\n        if( pItem->pTab ){\n          sqlite3ExplainPrintf(pVdbe, \" (tabname=%s)\", pItem->pTab->zName);\n        }\n      }else if( pItem->zName ){\n        sqlite3ExplainPrintf(pVdbe, \"%s\", pItem->zName);\n      }\n      if( pItem->zAlias ){\n        sqlite3ExplainPrintf(pVdbe, \" (AS %s)\", pItem->zAlias);\n      }\n      if( pItem->jointype & JT_LEFT ){\n        sqlite3ExplainPrintf(pVdbe, \" LEFT-JOIN\");\n      }\n      sqlite3ExplainNL(pVdbe);\n    }\n    sqlite3ExplainPop(pVdbe);\n  }\n  if( p->pWhere ){\n    sqlite3ExplainPrintf(pVdbe, \"WHERE \");\n    sqlite3ExplainExpr(pVdbe, p->pWhere);\n    sqlite3ExplainNL(pVdbe);\n  }\n  if( p->pGroupBy ){\n    sqlite3ExplainPrintf(pVdbe, \"GROUPBY \");\n    sqlite3ExplainExprList(pVdbe, p->pGroupBy);\n    sqlite3ExplainNL(pVdbe);\n  }\n  if( p->pHaving ){\n    sqlite3ExplainPrintf(pVdbe, \"HAVING \");\n    sqlite3ExplainExpr(pVdbe, p->pHaving);\n    sqlite3ExplainNL(pVdbe);\n  }\n  if( p->pOrderBy ){\n    sqlite3ExplainPrintf(pVdbe, \"ORDERBY \");\n    sqlite3ExplainExprList(pVdbe, p->pOrderBy);\n    sqlite3ExplainNL(pVdbe);\n  }\n  if( p->pLimit ){\n    sqlite3ExplainPrintf(pVdbe, \"LIMIT \");\n    sqlite3ExplainExpr(pVdbe, p->pLimit);\n    sqlite3ExplainNL(pVdbe);\n  }\n  if( p->pOffset ){\n    sqlite3ExplainPrintf(pVdbe, \"OFFSET \");\n    sqlite3ExplainExpr(pVdbe, p->pOffset);\n    sqlite3ExplainNL(pVdbe);\n  }\n}\nSQLITE_PRIVATE void sqlite3ExplainSelect(Vdbe *pVdbe, Select *p){\n  if( p==0 ){\n    sqlite3ExplainPrintf(pVdbe, \"(null-select)\");\n    return;\n  }\n  while( p->pPrior ){\n    p->pPrior->pNext = p;\n    p = p->pPrior;\n  }\n  sqlite3ExplainPush(pVdbe);\n  while( p ){\n    explainOneSelect(pVdbe, p);\n    p = p->pNext;\n    if( p==0 ) break;\n    sqlite3ExplainNL(pVdbe);\n    sqlite3ExplainPrintf(pVdbe, \"%s\\n\", selectOpName(p->op));\n  }\n  sqlite3ExplainPrintf(pVdbe, \"END\");\n  sqlite3ExplainPop(pVdbe);\n}\n\n/* End of the structure debug printing code\n*****************************************************************************/\n#endif /* defined(SQLITE_ENABLE_TREE_EXPLAIN) */\n\n/************** End of select.c **********************************************/\n/************** Begin file table.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the sqlite3_get_table() and sqlite3_free_table()\n** interface routines.  These are just wrappers around the main\n** interface routine of sqlite3_exec().\n**\n** These routines are in a separate files so that they will not be linked\n** if they are not used.\n*/\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n#ifndef SQLITE_OMIT_GET_TABLE\n\n/*\n** This structure is used to pass data from sqlite3_get_table() through\n** to the callback function is uses to build the result.\n*/\ntypedef struct TabResult {\n  char **azResult;   /* Accumulated output */\n  char *zErrMsg;     /* Error message text, if an error occurs */\n  int nAlloc;        /* Slots allocated for azResult[] */\n  int nRow;          /* Number of rows in the result */\n  int nColumn;       /* Number of columns in the result */\n  int nData;         /* Slots used in azResult[].  (nRow+1)*nColumn */\n  int rc;            /* Return code from sqlite3_exec() */\n} TabResult;\n\n/*\n** This routine is called once for each row in the result table.  Its job\n** is to fill in the TabResult structure appropriately, allocating new\n** memory as necessary.\n*/\nstatic int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){\n  TabResult *p = (TabResult*)pArg;  /* Result accumulator */\n  int need;                         /* Slots needed in p->azResult[] */\n  int i;                            /* Loop counter */\n  char *z;                          /* A single column of result */\n\n  /* Make sure there is enough space in p->azResult to hold everything\n  ** we need to remember from this invocation of the callback.\n  */\n  if( p->nRow==0 && argv!=0 ){\n    need = nCol*2;\n  }else{\n    need = nCol;\n  }\n  if( p->nData + need > p->nAlloc ){\n    char **azNew;\n    p->nAlloc = p->nAlloc*2 + need;\n    azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );\n    if( azNew==0 ) goto malloc_failed;\n    p->azResult = azNew;\n  }\n\n  /* If this is the first row, then generate an extra row containing\n  ** the names of all columns.\n  */\n  if( p->nRow==0 ){\n    p->nColumn = nCol;\n    for(i=0; i<nCol; i++){\n      z = sqlite3_mprintf(\"%s\", colv[i]);\n      if( z==0 ) goto malloc_failed;\n      p->azResult[p->nData++] = z;\n    }\n  }else if( p->nColumn!=nCol ){\n    sqlite3_free(p->zErrMsg);\n    p->zErrMsg = sqlite3_mprintf(\n       \"sqlite3_get_table() called with two or more incompatible queries\"\n    );\n    p->rc = SQLITE_ERROR;\n    return 1;\n  }\n\n  /* Copy over the row data\n  */\n  if( argv!=0 ){\n    for(i=0; i<nCol; i++){\n      if( argv[i]==0 ){\n        z = 0;\n      }else{\n        int n = sqlite3Strlen30(argv[i])+1;\n        z = sqlite3_malloc( n );\n        if( z==0 ) goto malloc_failed;\n        memcpy(z, argv[i], n);\n      }\n      p->azResult[p->nData++] = z;\n    }\n    p->nRow++;\n  }\n  return 0;\n\nmalloc_failed:\n  p->rc = SQLITE_NOMEM;\n  return 1;\n}\n\n/*\n** Query the database.  But instead of invoking a callback for each row,\n** malloc() for space to hold the result and return the entire results\n** at the conclusion of the call.\n**\n** The result that is written to ***pazResult is held in memory obtained\n** from malloc().  But the caller cannot free this memory directly.  \n** Instead, the entire table should be passed to sqlite3_free_table() when\n** the calling procedure is finished using it.\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  char ***pazResult,          /* Write the result table here */\n  int *pnRow,                 /* Write the number of rows in the result here */\n  int *pnColumn,              /* Write the number of columns of result here */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc;\n  TabResult res;\n\n  *pazResult = 0;\n  if( pnColumn ) *pnColumn = 0;\n  if( pnRow ) *pnRow = 0;\n  if( pzErrMsg ) *pzErrMsg = 0;\n  res.zErrMsg = 0;\n  res.nRow = 0;\n  res.nColumn = 0;\n  res.nData = 1;\n  res.nAlloc = 20;\n  res.rc = SQLITE_OK;\n  res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc );\n  if( res.azResult==0 ){\n     db->errCode = SQLITE_NOMEM;\n     return SQLITE_NOMEM;\n  }\n  res.azResult[0] = 0;\n  rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);\n  assert( sizeof(res.azResult[0])>= sizeof(res.nData) );\n  res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);\n  if( (rc&0xff)==SQLITE_ABORT ){\n    sqlite3_free_table(&res.azResult[1]);\n    if( res.zErrMsg ){\n      if( pzErrMsg ){\n        sqlite3_free(*pzErrMsg);\n        *pzErrMsg = sqlite3_mprintf(\"%s\",res.zErrMsg);\n      }\n      sqlite3_free(res.zErrMsg);\n    }\n    db->errCode = res.rc;  /* Assume 32-bit assignment is atomic */\n    return res.rc;\n  }\n  sqlite3_free(res.zErrMsg);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free_table(&res.azResult[1]);\n    return rc;\n  }\n  if( res.nAlloc>res.nData ){\n    char **azNew;\n    azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );\n    if( azNew==0 ){\n      sqlite3_free_table(&res.azResult[1]);\n      db->errCode = SQLITE_NOMEM;\n      return SQLITE_NOMEM;\n    }\n    res.azResult = azNew;\n  }\n  *pazResult = &res.azResult[1];\n  if( pnColumn ) *pnColumn = res.nColumn;\n  if( pnRow ) *pnRow = res.nRow;\n  return rc;\n}\n\n/*\n** This routine frees the space the sqlite3_get_table() malloced.\n*/\nSQLITE_API void sqlite3_free_table(\n  char **azResult            /* Result returned from from sqlite3_get_table() */\n){\n  if( azResult ){\n    int i, n;\n    azResult--;\n    assert( azResult!=0 );\n    n = SQLITE_PTR_TO_INT(azResult[0]);\n    for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }\n    sqlite3_free(azResult);\n  }\n}\n\n#endif /* SQLITE_OMIT_GET_TABLE */\n\n/************** End of table.c ***********************************************/\n/************** Begin file trigger.c *****************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation for TRIGGERs\n*/\n\n#ifndef SQLITE_OMIT_TRIGGER\n/*\n** Delete a linked list of TriggerStep structures.\n*/\nSQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){\n  while( pTriggerStep ){\n    TriggerStep * pTmp = pTriggerStep;\n    pTriggerStep = pTriggerStep->pNext;\n\n    sqlite3ExprDelete(db, pTmp->pWhere);\n    sqlite3ExprListDelete(db, pTmp->pExprList);\n    sqlite3SelectDelete(db, pTmp->pSelect);\n    sqlite3IdListDelete(db, pTmp->pIdList);\n\n    sqlite3DbFree(db, pTmp);\n  }\n}\n\n/*\n** Given table pTab, return a list of all the triggers attached to \n** the table. The list is connected by Trigger.pNext pointers.\n**\n** All of the triggers on pTab that are in the same database as pTab\n** are already attached to pTab->pTrigger.  But there might be additional\n** triggers on pTab in the TEMP schema.  This routine prepends all\n** TEMP triggers on pTab to the beginning of the pTab->pTrigger list\n** and returns the combined list.\n**\n** To state it another way:  This routine returns a list of all triggers\n** that fire off of pTab.  The list will include any TEMP triggers on\n** pTab as well as the triggers lised in pTab->pTrigger.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){\n  Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;\n  Trigger *pList = 0;                  /* List of triggers to return */\n\n  if( pParse->disableTriggers ){\n    return 0;\n  }\n\n  if( pTmpSchema!=pTab->pSchema ){\n    HashElem *p;\n    assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) );\n    for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){\n      Trigger *pTrig = (Trigger *)sqliteHashData(p);\n      if( pTrig->pTabSchema==pTab->pSchema\n       && 0==sqlite3StrICmp(pTrig->table, pTab->zName) \n      ){\n        pTrig->pNext = (pList ? pList : pTab->pTrigger);\n        pList = pTrig;\n      }\n    }\n  }\n\n  return (pList ? pList : pTab->pTrigger);\n}\n\n/*\n** This is called by the parser when it sees a CREATE TRIGGER statement\n** up to the point of the BEGIN before the trigger actions.  A Trigger\n** structure is generated based on the information available and stored\n** in pParse->pNewTrigger.  After the trigger actions have been parsed, the\n** sqlite3FinishTrigger() function is called to complete the trigger\n** construction process.\n*/\nSQLITE_PRIVATE void sqlite3BeginTrigger(\n  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */\n  Token *pName1,      /* The name of the trigger */\n  Token *pName2,      /* The name of the trigger */\n  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */\n  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */\n  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */\n  SrcList *pTableName,/* The name of the table/view the trigger applies to */\n  Expr *pWhen,        /* WHEN clause */\n  int isTemp,         /* True if the TEMPORARY keyword is present */\n  int noErr           /* Suppress errors if the trigger already exists */\n){\n  Trigger *pTrigger = 0;  /* The new trigger */\n  Table *pTab;            /* Table that the trigger fires off of */\n  char *zName = 0;        /* Name of the trigger */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  int iDb;                /* The database to store the trigger in */\n  Token *pName;           /* The unqualified db name */\n  DbFixer sFix;           /* State vector for the DB fixer */\n  int iTabDb;             /* Index of the database holding pTab */\n\n  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */\n  assert( pName2!=0 );\n  assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );\n  assert( op>0 && op<0xff );\n  if( isTemp ){\n    /* If TEMP was specified, then the trigger name may not be qualified. */\n    if( pName2->n>0 ){\n      sqlite3ErrorMsg(pParse, \"temporary trigger may not have qualified name\");\n      goto trigger_cleanup;\n    }\n    iDb = 1;\n    pName = pName1;\n  }else{\n    /* Figure out the db that the trigger will be created in */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ){\n      goto trigger_cleanup;\n    }\n  }\n  if( !pTableName || db->mallocFailed ){\n    goto trigger_cleanup;\n  }\n\n  /* A long-standing parser bug is that this syntax was allowed:\n  **\n  **    CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....\n  **                                                 ^^^^^^^^\n  **\n  ** To maintain backwards compatibility, ignore the database\n  ** name on pTableName if we are reparsing our of SQLITE_MASTER.\n  */\n  if( db->init.busy && iDb!=1 ){\n    sqlite3DbFree(db, pTableName->a[0].zDatabase);\n    pTableName->a[0].zDatabase = 0;\n  }\n\n  /* If the trigger name was unqualified, and the table is a temp table,\n  ** then set iDb to 1 to create the trigger in the temporary database.\n  ** If sqlite3SrcListLookup() returns 0, indicating the table does not\n  ** exist, the error is caught by the block below.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( db->init.busy==0 && pName2->n==0 && pTab\n        && pTab->pSchema==db->aDb[1].pSchema ){\n    iDb = 1;\n  }\n\n  /* Ensure the table name matches database name and that the table exists */\n  if( db->mallocFailed ) goto trigger_cleanup;\n  assert( pTableName->nSrc==1 );\n  if( sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", pName) && \n      sqlite3FixSrcList(&sFix, pTableName) ){\n    goto trigger_cleanup;\n  }\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( !pTab ){\n    /* The table does not exist. */\n    if( db->init.iDb==1 ){\n      /* Ticket #3810.\n      ** Normally, whenever a table is dropped, all associated triggers are\n      ** dropped too.  But if a TEMP trigger is created on a non-TEMP table\n      ** and the table is dropped by a different database connection, the\n      ** trigger is not visible to the database connection that does the\n      ** drop so the trigger cannot be dropped.  This results in an\n      ** \"orphaned trigger\" - a trigger whose associated table is missing.\n      */\n      db->init.orphanTrigger = 1;\n    }\n    goto trigger_cleanup;\n  }\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"cannot create triggers on virtual tables\");\n    goto trigger_cleanup;\n  }\n\n  /* Check that the trigger name is not reserved and that no trigger of the\n  ** specified name exists */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto trigger_cleanup;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),\n                      zName, sqlite3Strlen30(zName)) ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"trigger %T already exists\", pName);\n    }else{\n      assert( !db->init.busy );\n      sqlite3CodeVerifySchema(pParse, iDb);\n    }\n    goto trigger_cleanup;\n  }\n\n  /* Do not create a trigger on a system table */\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 ){\n    sqlite3ErrorMsg(pParse, \"cannot create trigger on system table\");\n    pParse->nErr++;\n    goto trigger_cleanup;\n  }\n\n  /* INSTEAD of triggers are only for views and views only support INSTEAD\n  ** of triggers.\n  */\n  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create %s trigger on view: %S\", \n        (tr_tm == TK_BEFORE)?\"BEFORE\":\"AFTER\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create INSTEAD OF\"\n        \" trigger on table: %S\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n  iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_CREATE_TRIGGER;\n    const char *zDb = db->aDb[iTabDb].zName;\n    const char *zDbTrig = isTemp ? db->aDb[1].zName : zDb;\n    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){\n      goto trigger_cleanup;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){\n      goto trigger_cleanup;\n    }\n  }\n#endif\n\n  /* INSTEAD OF triggers can only appear on views and BEFORE triggers\n  ** cannot appear on views.  So we might as well translate every\n  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code\n  ** elsewhere.\n  */\n  if (tr_tm == TK_INSTEAD){\n    tr_tm = TK_BEFORE;\n  }\n\n  /* Build the Trigger object */\n  pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));\n  if( pTrigger==0 ) goto trigger_cleanup;\n  pTrigger->zName = zName;\n  zName = 0;\n  pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);\n  pTrigger->pSchema = db->aDb[iDb].pSchema;\n  pTrigger->pTabSchema = pTab->pSchema;\n  pTrigger->op = (u8)op;\n  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;\n  pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n  pTrigger->pColumns = sqlite3IdListDup(db, pColumns);\n  assert( pParse->pNewTrigger==0 );\n  pParse->pNewTrigger = pTrigger;\n\ntrigger_cleanup:\n  sqlite3DbFree(db, zName);\n  sqlite3SrcListDelete(db, pTableName);\n  sqlite3IdListDelete(db, pColumns);\n  sqlite3ExprDelete(db, pWhen);\n  if( !pParse->pNewTrigger ){\n    sqlite3DeleteTrigger(db, pTrigger);\n  }else{\n    assert( pParse->pNewTrigger==pTrigger );\n  }\n}\n\n/*\n** This routine is called after all of the trigger actions have been parsed\n** in order to complete the process of building the trigger.\n*/\nSQLITE_PRIVATE void sqlite3FinishTrigger(\n  Parse *pParse,          /* Parser context */\n  TriggerStep *pStepList, /* The triggered program */\n  Token *pAll             /* Token that describes the complete CREATE TRIGGER */\n){\n  Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */\n  char *zName;                            /* Name of trigger */\n  sqlite3 *db = pParse->db;               /* The database */\n  DbFixer sFix;                           /* Fixer object */\n  int iDb;                                /* Database containing the trigger */\n  Token nameToken;                        /* Trigger name for error reporting */\n\n  pParse->pNewTrigger = 0;\n  if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;\n  zName = pTrig->zName;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n  pTrig->step_list = pStepList;\n  while( pStepList ){\n    pStepList->pTrig = pTrig;\n    pStepList = pStepList->pNext;\n  }\n  nameToken.z = pTrig->zName;\n  nameToken.n = sqlite3Strlen30(nameToken.z);\n  if( sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", &nameToken) \n          && sqlite3FixTriggerStep(&sFix, pTrig->step_list) ){\n    goto triggerfinish_cleanup;\n  }\n\n  /* if we are not initializing,\n  ** build the sqlite_master entry\n  */\n  if( !db->init.busy ){\n    Vdbe *v;\n    char *z;\n\n    /* Make an entry in the sqlite_master table */\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto triggerfinish_cleanup;\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);\n    sqlite3NestedParse(pParse,\n       \"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\",\n       db->aDb[iDb].zName, SCHEMA_TABLE(iDb), zName,\n       pTrig->table, z);\n    sqlite3DbFree(db, z);\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n        sqlite3MPrintf(db, \"type='trigger' AND name='%q'\", zName));\n  }\n\n  if( db->init.busy ){\n    Trigger *pLink = pTrig;\n    Hash *pHash = &db->aDb[iDb].pSchema->trigHash;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTrig = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), pTrig);\n    if( pTrig ){\n      db->mallocFailed = 1;\n    }else if( pLink->pSchema==pLink->pTabSchema ){\n      Table *pTab;\n      int n = sqlite3Strlen30(pLink->table);\n      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table, n);\n      assert( pTab!=0 );\n      pLink->pNext = pTab->pTrigger;\n      pTab->pTrigger = pLink;\n    }\n  }\n\ntriggerfinish_cleanup:\n  sqlite3DeleteTrigger(db, pTrig);\n  assert( !pParse->pNewTrigger );\n  sqlite3DeleteTriggerStep(db, pStepList);\n}\n\n/*\n** Turn a SELECT statement (that the pSelect parameter points to) into\n** a trigger step.  Return a pointer to a TriggerStep structure.\n**\n** The parser calls this routine when it finds a SELECT statement in\n** body of a TRIGGER.  \n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){\n  TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));\n  if( pTriggerStep==0 ) {\n    sqlite3SelectDelete(db, pSelect);\n    return 0;\n  }\n  pTriggerStep->op = TK_SELECT;\n  pTriggerStep->pSelect = pSelect;\n  pTriggerStep->orconf = OE_Default;\n  return pTriggerStep;\n}\n\n/*\n** Allocate space to hold a new trigger step.  The allocated space\n** holds both the TriggerStep object and the TriggerStep.target.z string.\n**\n** If an OOM error occurs, NULL is returned and db->mallocFailed is set.\n*/\nstatic TriggerStep *triggerStepAllocate(\n  sqlite3 *db,                /* Database connection */\n  u8 op,                      /* Trigger opcode */\n  Token *pName                /* The target name */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n);\n  if( pTriggerStep ){\n    char *z = (char*)&pTriggerStep[1];\n    memcpy(z, pName->z, pName->n);\n    pTriggerStep->target.z = z;\n    pTriggerStep->target.n = pName->n;\n    pTriggerStep->op = op;\n  }\n  return pTriggerStep;\n}\n\n/*\n** Build a trigger step out of an INSERT statement.  Return a pointer\n** to the new trigger step.\n**\n** The parser calls this routine when it sees an INSERT inside the\n** body of a trigger.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(\n  sqlite3 *db,        /* The database connection */\n  Token *pTableName,  /* Name of the table into which we insert */\n  IdList *pColumn,    /* List of columns in pTableName to insert into */\n  ExprList *pEList,   /* The VALUE clause: a list of values to be inserted */\n  Select *pSelect,    /* A SELECT statement that supplies values */\n  u8 orconf           /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */\n){\n  TriggerStep *pTriggerStep;\n\n  assert(pEList == 0 || pSelect == 0);\n  assert(pEList != 0 || pSelect != 0 || db->mallocFailed);\n\n  pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n    pTriggerStep->pIdList = pColumn;\n    pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = orconf;\n  }else{\n    sqlite3IdListDelete(db, pColumn);\n  }\n  sqlite3ExprListDelete(db, pEList);\n  sqlite3SelectDelete(db, pSelect);\n\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements an UPDATE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees an UPDATE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(\n  sqlite3 *db,         /* The database connection */\n  Token *pTableName,   /* Name of the table to be updated */\n  ExprList *pEList,    /* The SET clause: list of column and new values */\n  Expr *pWhere,        /* The WHERE clause */\n  u8 orconf            /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = orconf;\n  }\n  sqlite3ExprListDelete(db, pEList);\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements a DELETE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees a DELETE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(\n  sqlite3 *db,            /* Database connection */\n  Token *pTableName,      /* The table from which rows are deleted */\n  Expr *pWhere            /* The WHERE clause */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = OE_Default;\n  }\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/* \n** Recursively delete a Trigger structure\n*/\nSQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){\n  if( pTrigger==0 ) return;\n  sqlite3DeleteTriggerStep(db, pTrigger->step_list);\n  sqlite3DbFree(db, pTrigger->zName);\n  sqlite3DbFree(db, pTrigger->table);\n  sqlite3ExprDelete(db, pTrigger->pWhen);\n  sqlite3IdListDelete(db, pTrigger->pColumns);\n  sqlite3DbFree(db, pTrigger);\n}\n\n/*\n** This function is called to drop a trigger from the database schema. \n**\n** This may be called directly from the parser and therefore identifies\n** the trigger by name.  The sqlite3DropTriggerPtr() routine does the\n** same job as this routine except it takes a pointer to the trigger\n** instead of the trigger name.\n**/\nSQLITE_PRIVATE void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){\n  Trigger *pTrigger = 0;\n  int i;\n  const char *zDb;\n  const char *zName;\n  int nName;\n  sqlite3 *db = pParse->db;\n\n  if( db->mallocFailed ) goto drop_trigger_cleanup;\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto drop_trigger_cleanup;\n  }\n\n  assert( pName->nSrc==1 );\n  zDb = pName->a[0].zDatabase;\n  zName = pName->a[0].zName;\n  nName = sqlite3Strlen30(zName);\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName);\n    if( pTrigger ) break;\n  }\n  if( !pTrigger ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"no such trigger: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, zDb);\n    }\n    pParse->checkSchema = 1;\n    goto drop_trigger_cleanup;\n  }\n  sqlite3DropTriggerPtr(pParse, pTrigger);\n\ndrop_trigger_cleanup:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** Return a pointer to the Table structure for the table that a trigger\n** is set on.\n*/\nstatic Table *tableOfTrigger(Trigger *pTrigger){\n  int n = sqlite3Strlen30(pTrigger->table);\n  return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n);\n}\n\n\n/*\n** Drop a trigger given a pointer to that trigger. \n*/\nSQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){\n  Table   *pTable;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  pTable = tableOfTrigger(pTrigger);\n  assert( pTable );\n  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_TRIGGER;\n    const char *zDb = db->aDb[iDb].zName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||\n      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      return;\n    }\n  }\n#endif\n\n  /* Generate code to destroy the database record of the trigger.\n  */\n  assert( pTable!=0 );\n  if( (v = sqlite3GetVdbe(pParse))!=0 ){\n    int base;\n    static const VdbeOpList dropTrigger[] = {\n      { OP_Rewind,     0, ADDR(9),  0},\n      { OP_String8,    0, 1,        0}, /* 1 */\n      { OP_Column,     0, 1,        2},\n      { OP_Ne,         2, ADDR(8),  1},\n      { OP_String8,    0, 1,        0}, /* 4: \"trigger\" */\n      { OP_Column,     0, 0,        2},\n      { OP_Ne,         2, ADDR(8),  1},\n      { OP_Delete,     0, 0,        0},\n      { OP_Next,       0, ADDR(1),  0}, /* 8 */\n    };\n\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3OpenMasterTable(pParse, iDb);\n    base = sqlite3VdbeAddOpList(v,  ArraySize(dropTrigger), dropTrigger);\n    sqlite3VdbeChangeP4(v, base+1, pTrigger->zName, P4_TRANSIENT);\n    sqlite3VdbeChangeP4(v, base+4, \"trigger\", P4_STATIC);\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddOp2(v, OP_Close, 0, 0);\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);\n    if( pParse->nMem<3 ){\n      pParse->nMem = 3;\n    }\n  }\n}\n\n/*\n** Remove a trigger from the hash tables of the sqlite* pointer.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){\n  Trigger *pTrigger;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &(db->aDb[iDb].pSchema->trigHash);\n  pTrigger = sqlite3HashInsert(pHash, zName, sqlite3Strlen30(zName), 0);\n  if( ALWAYS(pTrigger) ){\n    if( pTrigger->pSchema==pTrigger->pTabSchema ){\n      Table *pTab = tableOfTrigger(pTrigger);\n      Trigger **pp;\n      for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));\n      *pp = (*pp)->pNext;\n    }\n    sqlite3DeleteTrigger(db, pTrigger);\n    db->flags |= SQLITE_InternChanges;\n  }\n}\n\n/*\n** pEList is the SET clause of an UPDATE statement.  Each entry\n** in pEList is of the format <id>=<expr>.  If any of the entries\n** in pEList have an <id> which matches an identifier in pIdList,\n** then return TRUE.  If pIdList==NULL, then it is considered a\n** wildcard that matches anything.  Likewise if pEList==NULL then\n** it matches anything so always return true.  Return false only\n** if there is no match.\n*/\nstatic int checkColumnOverlap(IdList *pIdList, ExprList *pEList){\n  int e;\n  if( pIdList==0 || NEVER(pEList==0) ) return 1;\n  for(e=0; e<pEList->nExpr; e++){\n    if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1;\n  }\n  return 0; \n}\n\n/*\n** Return a list of all triggers on table pTab if there exists at least\n** one trigger that must be fired when an operation of type 'op' is \n** performed on the table, and, if that operation is an UPDATE, if at\n** least one of the columns in pChanges is being modified.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggersExist(\n  Parse *pParse,          /* Parse context */\n  Table *pTab,            /* The table the contains the triggers */\n  int op,                 /* one of TK_DELETE, TK_INSERT, TK_UPDATE */\n  ExprList *pChanges,     /* Columns that change in an UPDATE statement */\n  int *pMask              /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n){\n  int mask = 0;\n  Trigger *pList = 0;\n  Trigger *p;\n\n  if( (pParse->db->flags & SQLITE_EnableTrigger)!=0 ){\n    pList = sqlite3TriggerList(pParse, pTab);\n  }\n  assert( pList==0 || IsVirtual(pTab)==0 );\n  for(p=pList; p; p=p->pNext){\n    if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){\n      mask |= p->tr_tm;\n    }\n  }\n  if( pMask ){\n    *pMask = mask;\n  }\n  return (mask ? pList : 0);\n}\n\n/*\n** Convert the pStep->target token into a SrcList and return a pointer\n** to that SrcList.\n**\n** This routine adds a specific database name, if needed, to the target when\n** forming the SrcList.  This prevents a trigger in one database from\n** referring to a target in another database.  An exception is when the\n** trigger is in TEMP in which case it can refer to any other database it\n** wants.\n*/\nstatic SrcList *targetSrcList(\n  Parse *pParse,       /* The parsing context */\n  TriggerStep *pStep   /* The trigger containing the target token */\n){\n  int iDb;             /* Index of the database to use */\n  SrcList *pSrc;       /* SrcList to be returned */\n\n  pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0);\n  if( pSrc ){\n    assert( pSrc->nSrc>0 );\n    assert( pSrc->a!=0 );\n    iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema);\n    if( iDb==0 || iDb>=2 ){\n      sqlite3 *db = pParse->db;\n      assert( iDb<pParse->db->nDb );\n      pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);\n    }\n  }\n  return pSrc;\n}\n\n/*\n** Generate VDBE code for the statements inside the body of a single \n** trigger.\n*/\nstatic int codeTriggerProgram(\n  Parse *pParse,            /* The parser context */\n  TriggerStep *pStepList,   /* List of statements inside the trigger body */\n  int orconf                /* Conflict algorithm. (OE_Abort, etc) */  \n){\n  TriggerStep *pStep;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( pParse->pTriggerTab && pParse->pToplevel );\n  assert( pStepList );\n  assert( v!=0 );\n  for(pStep=pStepList; pStep; pStep=pStep->pNext){\n    /* Figure out the ON CONFLICT policy that will be used for this step\n    ** of the trigger program. If the statement that caused this trigger\n    ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use\n    ** the ON CONFLICT policy that was specified as part of the trigger\n    ** step statement. Example:\n    **\n    **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;\n    **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);\n    **   END;\n    **\n    **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy\n    **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy\n    */\n    pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;\n\n    /* Clear the cookieGoto flag. When coding triggers, the cookieGoto \n    ** variable is used as a flag to indicate to sqlite3ExprCodeConstants()\n    ** that it is not safe to refactor constants (this happens after the\n    ** start of the first loop in the SQL statement is coded - at that \n    ** point code may be conditionally executed, so it is no longer safe to \n    ** initialize constant register values).  */\n    assert( pParse->cookieGoto==0 || pParse->cookieGoto==-1 );\n    pParse->cookieGoto = 0;\n\n    switch( pStep->op ){\n      case TK_UPDATE: {\n        sqlite3Update(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprListDup(db, pStep->pExprList, 0), \n          sqlite3ExprDup(db, pStep->pWhere, 0), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_INSERT: {\n        sqlite3Insert(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprListDup(db, pStep->pExprList, 0), \n          sqlite3SelectDup(db, pStep->pSelect, 0), \n          sqlite3IdListDup(db, pStep->pIdList), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_DELETE: {\n        sqlite3DeleteFrom(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprDup(db, pStep->pWhere, 0)\n        );\n        break;\n      }\n      default: assert( pStep->op==TK_SELECT ); {\n        SelectDest sDest;\n        Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);\n        sqlite3SelectDestInit(&sDest, SRT_Discard, 0);\n        sqlite3Select(pParse, pSelect, &sDest);\n        sqlite3SelectDelete(db, pSelect);\n        break;\n      }\n    } \n    if( pStep->op!=TK_SELECT ){\n      sqlite3VdbeAddOp0(v, OP_ResetCount);\n    }\n  }\n\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function is used to add VdbeComment() annotations to a VDBE\n** program. It is not used in production code, only for debugging.\n*/\nstatic const char *onErrorText(int onError){\n  switch( onError ){\n    case OE_Abort:    return \"abort\";\n    case OE_Rollback: return \"rollback\";\n    case OE_Fail:     return \"fail\";\n    case OE_Replace:  return \"replace\";\n    case OE_Ignore:   return \"ignore\";\n    case OE_Default:  return \"default\";\n  }\n  return \"n/a\";\n}\n#endif\n\n/*\n** Parse context structure pFrom has just been used to create a sub-vdbe\n** (trigger program). If an error has occurred, transfer error information\n** from pFrom to pTo.\n*/\nstatic void transferParseError(Parse *pTo, Parse *pFrom){\n  assert( pFrom->zErrMsg==0 || pFrom->nErr );\n  assert( pTo->zErrMsg==0 || pTo->nErr );\n  if( pTo->nErr==0 ){\n    pTo->zErrMsg = pFrom->zErrMsg;\n    pTo->nErr = pFrom->nErr;\n  }else{\n    sqlite3DbFree(pFrom->db, pFrom->zErrMsg);\n  }\n}\n\n/*\n** Create and populate a new TriggerPrg object with a sub-program \n** implementing trigger pTrigger with ON CONFLICT policy orconf.\n*/\nstatic TriggerPrg *codeRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table pTrigger is attached to */\n  int orconf           /* ON CONFLICT policy to code trigger program with */\n){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  sqlite3 *db = pParse->db;   /* Database handle */\n  TriggerPrg *pPrg;           /* Value to return */\n  Expr *pWhen = 0;            /* Duplicate of trigger WHEN expression */\n  Vdbe *v;                    /* Temporary VM */\n  NameContext sNC;            /* Name context for sub-vdbe */\n  SubProgram *pProgram = 0;   /* Sub-vdbe for trigger program */\n  Parse *pSubParse;           /* Parse context for sub-vdbe */\n  int iEndTrigger = 0;        /* Label to jump to if WHEN is false */\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n  assert( pTop->pVdbe );\n\n  /* Allocate the TriggerPrg and SubProgram objects. To ensure that they\n  ** are freed if an error occurs, link them into the Parse.pTriggerPrg \n  ** list of the top-level Parse object sooner rather than later.  */\n  pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));\n  if( !pPrg ) return 0;\n  pPrg->pNext = pTop->pTriggerPrg;\n  pTop->pTriggerPrg = pPrg;\n  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));\n  if( !pProgram ) return 0;\n  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);\n  pPrg->pTrigger = pTrigger;\n  pPrg->orconf = orconf;\n  pPrg->aColmask[0] = 0xffffffff;\n  pPrg->aColmask[1] = 0xffffffff;\n\n  /* Allocate and populate a new Parse context to use for coding the \n  ** trigger sub-program.  */\n  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));\n  if( !pSubParse ) return 0;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pSubParse;\n  pSubParse->db = db;\n  pSubParse->pTriggerTab = pTab;\n  pSubParse->pToplevel = pTop;\n  pSubParse->zAuthContext = pTrigger->zName;\n  pSubParse->eTriggerOp = pTrigger->op;\n  pSubParse->nQueryLoop = pParse->nQueryLoop;\n\n  v = sqlite3GetVdbe(pSubParse);\n  if( v ){\n    VdbeComment((v, \"Start: %s.%s (%s %s%s%s ON %s)\", \n      pTrigger->zName, onErrorText(orconf),\n      (pTrigger->tr_tm==TRIGGER_BEFORE ? \"BEFORE\" : \"AFTER\"),\n        (pTrigger->op==TK_UPDATE ? \"UPDATE\" : \"\"),\n        (pTrigger->op==TK_INSERT ? \"INSERT\" : \"\"),\n        (pTrigger->op==TK_DELETE ? \"DELETE\" : \"\"),\n      pTab->zName\n    ));\n#ifndef SQLITE_OMIT_TRACE\n    sqlite3VdbeChangeP4(v, -1, \n      sqlite3MPrintf(db, \"-- TRIGGER %s\", pTrigger->zName), P4_DYNAMIC\n    );\n#endif\n\n    /* If one was specified, code the WHEN clause. If it evaluates to false\n    ** (or NULL) the sub-vdbe is immediately halted by jumping to the \n    ** OP_Halt inserted at the end of the program.  */\n    if( pTrigger->pWhen ){\n      pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);\n      if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) \n       && db->mallocFailed==0 \n      ){\n        iEndTrigger = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);\n      }\n      sqlite3ExprDelete(db, pWhen);\n    }\n\n    /* Code the trigger program into the sub-vdbe. */\n    codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);\n\n    /* Insert an OP_Halt at the end of the sub-program. */\n    if( iEndTrigger ){\n      sqlite3VdbeResolveLabel(v, iEndTrigger);\n    }\n    sqlite3VdbeAddOp0(v, OP_Halt);\n    VdbeComment((v, \"End: %s.%s\", pTrigger->zName, onErrorText(orconf)));\n\n    transferParseError(pParse, pSubParse);\n    if( db->mallocFailed==0 ){\n      pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);\n    }\n    pProgram->nMem = pSubParse->nMem;\n    pProgram->nCsr = pSubParse->nTab;\n    pProgram->nOnce = pSubParse->nOnce;\n    pProgram->token = (void *)pTrigger;\n    pPrg->aColmask[0] = pSubParse->oldmask;\n    pPrg->aColmask[1] = pSubParse->newmask;\n    sqlite3VdbeDelete(v);\n  }\n\n  assert( !pSubParse->pAinc       && !pSubParse->pZombieTab );\n  assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );\n  sqlite3StackFree(db, pSubParse);\n\n  return pPrg;\n}\n    \n/*\n** Return a pointer to a TriggerPrg object containing the sub-program for\n** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such\n** TriggerPrg object exists, a new object is allocated and populated before\n** being returned.\n*/\nstatic TriggerPrg *getRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table trigger pTrigger is attached to */\n  int orconf           /* ON CONFLICT algorithm. */\n){\n  Parse *pRoot = sqlite3ParseToplevel(pParse);\n  TriggerPrg *pPrg;\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n\n  /* It may be that this trigger has already been coded (or is in the\n  ** process of being coded). If this is the case, then an entry with\n  ** a matching TriggerPrg.pTrigger field will be present somewhere\n  ** in the Parse.pTriggerPrg list. Search for such an entry.  */\n  for(pPrg=pRoot->pTriggerPrg; \n      pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf); \n      pPrg=pPrg->pNext\n  );\n\n  /* If an existing TriggerPrg could not be located, create a new one. */\n  if( !pPrg ){\n    pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);\n  }\n\n  return pPrg;\n}\n\n/*\n** Generate code for the trigger program associated with trigger p on \n** table pTab. The reg, orconf and ignoreJump parameters passed to this\n** function are the same as those described in the header function for\n** sqlite3CodeRowTrigger()\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(\n  Parse *pParse,       /* Parse context */\n  Trigger *p,          /* Trigger to code */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* Reg array containing OLD.* and NEW.* values */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */\n  TriggerPrg *pPrg;\n  pPrg = getRowTrigger(pParse, p, pTab, orconf);\n  assert( pPrg || pParse->nErr || pParse->db->mallocFailed );\n\n  /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program \n  ** is a pointer to the sub-vdbe containing the trigger program.  */\n  if( pPrg ){\n    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));\n\n    sqlite3VdbeAddOp3(v, OP_Program, reg, ignoreJump, ++pParse->nMem);\n    sqlite3VdbeChangeP4(v, -1, (const char *)pPrg->pProgram, P4_SUBPROGRAM);\n    VdbeComment(\n        (v, \"Call: %s.%s\", (p->zName?p->zName:\"fkey\"), onErrorText(orconf)));\n\n    /* Set the P5 operand of the OP_Program instruction to non-zero if\n    ** recursive invocation of this trigger program is disallowed. Recursive\n    ** invocation is disallowed if (a) the sub-program is really a trigger,\n    ** not a foreign key action, and (b) the flag to enable recursive triggers\n    ** is clear.  */\n    sqlite3VdbeChangeP5(v, (u8)bRecursive);\n  }\n}\n\n/*\n** This is called to code the required FOR EACH ROW triggers for an operation\n** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)\n** is given by the op paramater. The tr_tm parameter determines whether the\n** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then\n** parameter pChanges is passed the list of columns being modified.\n**\n** If there are no triggers that fire at the specified time for the specified\n** operation on pTab, this function is a no-op.\n**\n** The reg argument is the address of the first in an array of registers \n** that contain the values substituted for the new.* and old.* references\n** in the trigger program. If N is the number of columns in table pTab\n** (a copy of pTab->nCol), then registers are populated as follows:\n**\n**   Register       Contains\n**   ------------------------------------------------------\n**   reg+0          OLD.rowid\n**   reg+1          OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N          OLD.* value of right-most column of pTab\n**   reg+N+1        NEW.rowid\n**   reg+N+2        OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N+N+1      NEW.* value of right-most column of pTab\n**\n** For ON DELETE triggers, the registers containing the NEW.* values will\n** never be accessed by the trigger program, so they are not allocated or \n** populated by the caller (there is no data to populate them with anyway). \n** Similarly, for ON INSERT triggers the values stored in the OLD.* registers\n** are never accessed, and so are not allocated by the caller. So, for an\n** ON INSERT trigger, the value passed to this function as parameter reg\n** is not a readable register, although registers (reg+N) through \n** (reg+N+N+1) are.\n**\n** Parameter orconf is the default conflict resolution algorithm for the\n** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump\n** is the instruction that control should jump to if a trigger program\n** raises an IGNORE exception.\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTrigger(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  int op,              /* One of TK_UPDATE, TK_INSERT, TK_DELETE */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int tr_tm,           /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* The first in an array of registers (see above) */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Trigger *p;          /* Used to iterate through pTrigger list */\n\n  assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );\n  assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );\n  assert( (op==TK_UPDATE)==(pChanges!=0) );\n\n  for(p=pTrigger; p; p=p->pNext){\n\n    /* Sanity checking:  The schema for the trigger and for the table are\n    ** always defined.  The trigger must be in the same schema as the table\n    ** or else it must be a TEMP trigger. */\n    assert( p->pSchema!=0 );\n    assert( p->pTabSchema!=0 );\n    assert( p->pSchema==p->pTabSchema \n         || p->pSchema==pParse->db->aDb[1].pSchema );\n\n    /* Determine whether we should code this trigger */\n    if( p->op==op \n     && p->tr_tm==tr_tm \n     && checkColumnOverlap(p->pColumns, pChanges)\n    ){\n      sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);\n    }\n  }\n}\n\n/*\n** Triggers may access values stored in the old.* or new.* pseudo-table. \n** This function returns a 32-bit bitmask indicating which columns of the \n** old.* or new.* tables actually are used by triggers. This information \n** may be used by the caller, for example, to avoid having to load the entire\n** old.* record into memory when executing an UPDATE or DELETE command.\n**\n** Bit 0 of the returned mask is set if the left-most column of the\n** table may be accessed using an [old|new].<col> reference. Bit 1 is set if\n** the second leftmost column value is required, and so on. If there\n** are more than 32 columns in the table, and at least one of the columns\n** with an index greater than 32 may be accessed, 0xffffffff is returned.\n**\n** It is not possible to determine if the old.rowid or new.rowid column is \n** accessed by triggers. The caller must always assume that it is.\n**\n** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned\n** applies to the old.* table. If 1, the new.* table.\n**\n** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE\n** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only\n** included in the returned mask if the TRIGGER_BEFORE bit is set in the\n** tr_tm parameter. Similarly, values accessed by AFTER triggers are only\n** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.\n*/\nSQLITE_PRIVATE u32 sqlite3TriggerColmask(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int isNew,           /* 1 for new.* ref mask, 0 for old.* ref mask */\n  int tr_tm,           /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int orconf           /* Default ON CONFLICT policy for trigger steps */\n){\n  const int op = pChanges ? TK_UPDATE : TK_DELETE;\n  u32 mask = 0;\n  Trigger *p;\n\n  assert( isNew==1 || isNew==0 );\n  for(p=pTrigger; p; p=p->pNext){\n    if( p->op==op && (tr_tm&p->tr_tm)\n     && checkColumnOverlap(p->pColumns,pChanges)\n    ){\n      TriggerPrg *pPrg;\n      pPrg = getRowTrigger(pParse, p, pTab, orconf);\n      if( pPrg ){\n        mask |= pPrg->aColmask[isNew];\n      }\n    }\n  }\n\n  return mask;\n}\n\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n/************** End of trigger.c *********************************************/\n/************** Begin file update.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle UPDATE statements.\n*/\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Forward declaration */\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowidExpr,    /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** The most recently coded instruction was an OP_Column to retrieve the\n** i-th column of table pTab. This routine sets the P4 parameter of the \n** OP_Column to the default value, if any.\n**\n** The default value of a column is specified by a DEFAULT clause in the \n** column definition. This was either supplied by the user when the table\n** was created, or added later to the table definition by an ALTER TABLE\n** command. If the latter, then the row-records in the table btree on disk\n** may not contain a value for the column and the default value, taken\n** from the P4 parameter of the OP_Column instruction, is returned instead.\n** If the former, then all row-records are guaranteed to include a value\n** for the column and the P4 value is not required.\n**\n** Column definitions created by an ALTER TABLE command may only have \n** literal default values specified: a number, null or a string. (If a more\n** complicated default expression value was provided, it is evaluated \n** when the ALTER TABLE is executed and one of the literal values written\n** into the sqlite_master table.)\n**\n** Therefore, the P4 parameter is only required if the default value for\n** the column is a literal number, string or null. The sqlite3ValueFromExpr()\n** function is capable of transforming these types of expressions into\n** sqlite3_value objects.\n**\n** If parameter iReg is not negative, code an OP_RealAffinity instruction\n** on register iReg. This is used when an equivalent integer value is \n** stored in place of an 8-byte floating point value in order to save \n** space.\n*/\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){\n  assert( pTab!=0 );\n  if( !pTab->pSelect ){\n    sqlite3_value *pValue;\n    u8 enc = ENC(sqlite3VdbeDb(v));\n    Column *pCol = &pTab->aCol[i];\n    VdbeComment((v, \"%s.%s\", pTab->zName, pCol->zName));\n    assert( i<pTab->nCol );\n    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, \n                         pCol->affinity, &pValue);\n    if( pValue ){\n      sqlite3VdbeChangeP4(v, -1, (const char *)pValue, P4_MEM);\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    if( iReg>=0 && pTab->aCol[i].affinity==SQLITE_AFF_REAL ){\n      sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);\n    }\n#endif\n  }\n}\n\n/*\n** Process an UPDATE statement.\n**\n**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;\n**          \\_______/ \\________/     \\______/       \\________________/\n*            onError   pTabList      pChanges             pWhere\n*/\nSQLITE_PRIVATE void sqlite3Update(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table in which we should change things */\n  ExprList *pChanges,    /* Things to be changed */\n  Expr *pWhere,          /* The WHERE clause.  May be null */\n  int onError            /* How to handle constraint errors */\n){\n  int i, j;              /* Loop counters */\n  Table *pTab;           /* The table to be updated */\n  int addr = 0;          /* VDBE instruction address of the start of the loop */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Vdbe *v;               /* The virtual database engine */\n  Index *pIdx;           /* For looping over indices */\n  int nIdx;              /* Number of indices that need updating */\n  int iCur;              /* VDBE Cursor number of pTab */\n  sqlite3 *db;           /* The database structure */\n  int *aRegIdx = 0;      /* One register assigned to each index to be updated */\n  int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the\n                         ** an expression for the i-th column of the table.\n                         ** aXRef[i]==-1 if the i-th column is not changed. */\n  int chngRowid;         /* True if the record number is being changed */\n  Expr *pRowidExpr = 0;  /* Expression defining the new record number */\n  int openAll = 0;       /* True if all indices need to be opened */\n  AuthContext sContext;  /* The authorization context */\n  NameContext sNC;       /* The name-context to resolve expressions in */\n  int iDb;               /* Database containing the table being updated */\n  int okOnePass;         /* True for one-pass algorithm without the FIFO */\n  int hasFK;             /* True if foreign key processing is required */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;            /* True when updating a view (INSTEAD OF trigger) */\n  Trigger *pTrigger;     /* List of triggers on pTab, if required */\n  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n#endif\n  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */\n\n  /* Register Allocations */\n  int regRowCount = 0;   /* A count of rows changed */\n  int regOldRowid;       /* The old rowid */\n  int regNewRowid;       /* The new rowid */\n  int regNew;            /* Content of the NEW.* table in triggers */\n  int regOld = 0;        /* Content of OLD.* table in triggers */\n  int regRowSet = 0;     /* Rowset of rows to be updated */\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto update_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to update. \n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ) goto update_cleanup;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n\n  /* Figure out if we have any triggers and if the table being\n  ** updated is a view.\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);\n  isView = pTab->pSelect!=0;\n  assert( pTrigger || tmask==0 );\n#else\n# define pTrigger 0\n# define isView 0\n# define tmask 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto update_cleanup;\n  }\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto update_cleanup;\n  }\n  aXRef = sqlite3DbMallocRaw(db, sizeof(int) * pTab->nCol );\n  if( aXRef==0 ) goto update_cleanup;\n  for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;\n\n  /* Allocate a cursors for the main database table and for all indices.\n  ** The index cursors might not be used, but if they are used they\n  ** need to occur right after the database cursor.  So go ahead and\n  ** allocate enough space, just in case.\n  */\n  pTabList->a[0].iCursor = iCur = pParse->nTab++;\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    pParse->nTab++;\n  }\n\n  /* Initialize the name-context */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n\n  /* Resolve the column names in all the expressions of the\n  ** of the UPDATE statement.  Also find the column index\n  ** for each column to be updated in the pChanges array.  For each\n  ** column to be updated, make sure we have authorization to change\n  ** that column.\n  */\n  chngRowid = 0;\n  for(i=0; i<pChanges->nExpr; i++){\n    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){\n      goto update_cleanup;\n    }\n    for(j=0; j<pTab->nCol; j++){\n      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){\n        if( j==pTab->iPKey ){\n          chngRowid = 1;\n          pRowidExpr = pChanges->a[i].pExpr;\n        }\n        aXRef[j] = i;\n        break;\n      }\n    }\n    if( j>=pTab->nCol ){\n      if( sqlite3IsRowid(pChanges->a[i].zName) ){\n        j = -1;\n        chngRowid = 1;\n        pRowidExpr = pChanges->a[i].pExpr;\n      }else{\n        sqlite3ErrorMsg(pParse, \"no such column: %s\", pChanges->a[i].zName);\n        pParse->checkSchema = 1;\n        goto update_cleanup;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      int rc;\n      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,\n                            j<0 ? \"ROWID\" : pTab->aCol[j].zName,\n                            db->aDb[iDb].zName);\n      if( rc==SQLITE_DENY ){\n        goto update_cleanup;\n      }else if( rc==SQLITE_IGNORE ){\n        aXRef[j] = -1;\n      }\n    }\n#endif\n  }\n\n  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid);\n\n  /* Allocate memory for the array aRegIdx[].  There is one entry in the\n  ** array for each index associated with table being updated.  Fill in\n  ** the value with a register number for indices that are to be used\n  ** and with zero for unused indices.\n  */\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}\n  if( nIdx>0 ){\n    aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx );\n    if( aRegIdx==0 ) goto update_cleanup;\n  }\n  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n    int reg;\n    if( hasFK || chngRowid ){\n      reg = ++pParse->nMem;\n    }else{\n      reg = 0;\n      for(i=0; i<pIdx->nColumn; i++){\n        if( aXRef[pIdx->aiColumn[i]]>=0 ){\n          reg = ++pParse->nMem;\n          break;\n        }\n      }\n    }\n    aRegIdx[j] = reg;\n  }\n\n  /* Begin generating code. */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto update_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Virtual tables must be handled separately */\n  if( IsVirtual(pTab) ){\n    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,\n                       pWhere, onError);\n    pWhere = 0;\n    pTabList = 0;\n    goto update_cleanup;\n  }\n#endif\n\n  /* Allocate required registers. */\n  regRowSet = ++pParse->nMem;\n  regOldRowid = regNewRowid = ++pParse->nMem;\n  if( pTrigger || hasFK ){\n    regOld = pParse->nMem + 1;\n    pParse->nMem += pTab->nCol;\n  }\n  if( chngRowid || pTrigger || hasFK ){\n    regNewRowid = ++pParse->nMem;\n  }\n  regNew = pParse->nMem + 1;\n  pParse->nMem += pTab->nCol;\n\n  /* Start the view context. */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* If we are trying to update a view, realize that view into\n  ** a ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iCur);\n  }\n#endif\n\n  /* Resolve the column names in all the expressions in the\n  ** WHERE clause.\n  */\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto update_cleanup;\n  }\n\n  /* Begin the database scan\n  */\n  sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);\n  pWInfo = sqlite3WhereBegin(\n      pParse, pTabList, pWhere, 0, 0, WHERE_ONEPASS_DESIRED, 0\n  );\n  if( pWInfo==0 ) goto update_cleanup;\n  okOnePass = pWInfo->okOnePass;\n\n  /* Remember the rowid of every item to be updated.\n  */\n  sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regOldRowid);\n  if( !okOnePass ){\n    sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);\n  }\n\n  /* End the database scan loop.\n  */\n  sqlite3WhereEnd(pWInfo);\n\n  /* Initialize the count of updated rows\n  */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  if( !isView ){\n    /* \n    ** Open every index that needs updating.  Note that if any\n    ** index could potentially invoke a REPLACE conflict resolution \n    ** action, then we need to open all indices because we might need\n    ** to be deleting some records.\n    */\n    if( !okOnePass ) sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); \n    if( onError==OE_Replace ){\n      openAll = 1;\n    }else{\n      openAll = 0;\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        if( pIdx->onError==OE_Replace ){\n          openAll = 1;\n          break;\n        }\n      }\n    }\n    for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n      assert( aRegIdx );\n      if( openAll || aRegIdx[i]>0 ){\n        KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx);\n        sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, iDb,\n                       (char*)pKey, P4_KEYINFO_HANDOFF);\n        assert( pParse->nTab>iCur+i+1 );\n      }\n    }\n  }\n\n  /* Top of the update loop */\n  if( okOnePass ){\n    int a1 = sqlite3VdbeAddOp1(v, OP_NotNull, regOldRowid);\n    addr = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, a1);\n  }else{\n    addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, 0, regOldRowid);\n  }\n\n  /* Make cursor iCur point to the record that is being updated. If\n  ** this record does not exist for some reason (deleted by a trigger,\n  ** for example, then jump to the next iteration of the RowSet loop.  */\n  sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);\n\n  /* If the record number will change, set register regNewRowid to\n  ** contain the new value. If the record number is not being modified,\n  ** then regNewRowid is the same register as regOldRowid, which is\n  ** already populated.  */\n  assert( chngRowid || pTrigger || hasFK || regOldRowid==regNewRowid );\n  if( chngRowid ){\n    sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);\n    sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid);\n  }\n\n  /* If there are triggers on this table, populate an array of registers \n  ** with the required old.* column data.  */\n  if( hasFK || pTrigger ){\n    u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);\n    oldmask |= sqlite3TriggerColmask(pParse, \n        pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError\n    );\n    for(i=0; i<pTab->nCol; i++){\n      if( aXRef[i]<0 || oldmask==0xffffffff || (i<32 && (oldmask & (1<<i))) ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);\n      }\n    }\n    if( chngRowid==0 ){\n      sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);\n    }\n  }\n\n  /* Populate the array of registers beginning at regNew with the new\n  ** row data. This array is used to check constaints, create the new\n  ** table and index records, and as the values for any new.* references\n  ** made by triggers.\n  **\n  ** If there are one or more BEFORE triggers, then do not populate the\n  ** registers associated with columns that are (a) not modified by\n  ** this UPDATE statement and (b) not accessed by new.* references. The\n  ** values for registers not modified by the UPDATE must be reloaded from \n  ** the database after the BEFORE triggers are fired anyway (as the trigger \n  ** may have modified them). So not loading those that are not going to\n  ** be used eliminates some redundant opcodes.\n  */\n  newmask = sqlite3TriggerColmask(\n      pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError\n  );\n  sqlite3VdbeAddOp3(v, OP_Null, 0, regNew, regNew+pTab->nCol-1);\n  for(i=0; i<pTab->nCol; i++){\n    if( i==pTab->iPKey ){\n      /*sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);*/\n    }else{\n      j = aXRef[i];\n      if( j>=0 ){\n        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);\n      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask&(1<<i)) ){\n        /* This branch loads the value of a column that will not be changed \n        ** into a register. This is done if there are no BEFORE triggers, or\n        ** if there are one or more BEFORE triggers that use this value via\n        ** a new.* reference in a trigger program.\n        */\n        testcase( i==31 );\n        testcase( i==32 );\n        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);\n        sqlite3ColumnDefault(v, pTab, i, regNew+i);\n      }\n    }\n  }\n\n  /* Fire any BEFORE UPDATE triggers. This happens before constraints are\n  ** verified. One could argue that this is wrong.\n  */\n  if( tmask&TRIGGER_BEFORE ){\n    sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol);\n    sqlite3TableAffinityStr(v, pTab);\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n        TRIGGER_BEFORE, pTab, regOldRowid, onError, addr);\n\n    /* The row-trigger may have deleted the row being updated. In this\n    ** case, jump to the next row. No updates or AFTER triggers are \n    ** required. This behavior - what happens when the row being updated\n    ** is deleted or renamed by a BEFORE trigger - is left undefined in the\n    ** documentation.\n    */\n    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid);\n\n    /* If it did not delete it, the row-trigger may still have modified \n    ** some of the columns of the row being updated. Load the values for \n    ** all columns not modified by the update statement into their \n    ** registers in case this has happened.\n    */\n    for(i=0; i<pTab->nCol; i++){\n      if( aXRef[i]<0 && i!=pTab->iPKey ){\n        sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i);\n        sqlite3ColumnDefault(v, pTab, i, regNew+i);\n      }\n    }\n  }\n\n  if( !isView ){\n    int j1;                       /* Address of jump instruction */\n\n    /* Do constraint checks. */\n    sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid,\n        aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0);\n\n    /* Do FK constraint checks. */\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, regOldRowid, 0);\n    }\n\n    /* Delete the index entries associated with the current record.  */\n    j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid);\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx);\n  \n    /* If changing the record number, delete the old record.  */\n    if( hasFK || chngRowid ){\n      sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0);\n    }\n    sqlite3VdbeJumpHere(v, j1);\n\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, 0, regNewRowid);\n    }\n  \n    /* Insert the new index entries and the new record. */\n    sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0);\n\n    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n    ** handle rows (possibly in other tables) that refer via a foreign key\n    ** to the row just updated. */ \n    if( hasFK ){\n      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid);\n    }\n  }\n\n  /* Increment the row counter \n  */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n      TRIGGER_AFTER, pTab, regOldRowid, onError, addr);\n\n  /* Repeat the above with the next record to be updated, until\n  ** all record selected by the WHERE clause have been updated.\n  */\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);\n  sqlite3VdbeJumpHere(v, addr);\n\n  /* Close all tables */\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    assert( aRegIdx );\n    if( openAll || aRegIdx[i]>0 ){\n      sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0);\n    }\n  }\n  sqlite3VdbeAddOp2(v, OP_Close, iCur, 0);\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows that were changed. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows updated\", SQLITE_STATIC);\n  }\n\nupdate_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3DbFree(db, aRegIdx);\n  sqlite3DbFree(db, aXRef);\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pChanges);\n  sqlite3ExprDelete(db, pWhere);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** thely may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Generate code for an UPDATE of a virtual table.\n**\n** The strategy is that we create an ephemerial table that contains\n** for each row to be changed:\n**\n**   (A)  The original rowid of that row.\n**   (B)  The revised rowid for the row. (note1)\n**   (C)  The content of every column in the row.\n**\n** Then we loop over this ephemeral table and for each row in\n** the ephermeral table call VUpdate.\n**\n** When finished, drop the ephemeral table.\n**\n** (note1) Actually, if we know in advance that (A) is always the same\n** as (B) we only store (A), then duplicate (A) when pulling\n** it out of the ephemeral table before calling VUpdate.\n*/\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowid,        /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n){\n  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */\n  ExprList *pEList = 0;     /* The result set of the SELECT statement */\n  Select *pSelect = 0;      /* The SELECT statement */\n  Expr *pExpr;              /* Temporary expression */\n  int ephemTab;             /* Table holding the result of the SELECT */\n  int i;                    /* Loop counter */\n  int addr;                 /* Address of top of loop */\n  int iReg;                 /* First register in set passed to OP_VUpdate */\n  sqlite3 *db = pParse->db; /* Database connection */\n  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);\n  SelectDest dest;\n\n  /* Construct the SELECT statement that will find the new values for\n  ** all updated rows. \n  */\n  pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, \"_rowid_\"));\n  if( pRowid ){\n    pEList = sqlite3ExprListAppend(pParse, pEList,\n                                   sqlite3ExprDup(db, pRowid, 0));\n  }\n  assert( pTab->iPKey<0 );\n  for(i=0; i<pTab->nCol; i++){\n    if( aXRef[i]>=0 ){\n      pExpr = sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0);\n    }else{\n      pExpr = sqlite3Expr(db, TK_ID, pTab->aCol[i].zName);\n    }\n    pEList = sqlite3ExprListAppend(pParse, pEList, pExpr);\n  }\n  pSelect = sqlite3SelectNew(pParse, pEList, pSrc, pWhere, 0, 0, 0, 0, 0, 0);\n  \n  /* Create the ephemeral table into which the update results will\n  ** be stored.\n  */\n  assert( v );\n  ephemTab = pParse->nTab++;\n  sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, pTab->nCol+1+(pRowid!=0));\n  sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n\n  /* fill the ephemeral table \n  */\n  sqlite3SelectDestInit(&dest, SRT_Table, ephemTab);\n  sqlite3Select(pParse, pSelect, &dest);\n\n  /* Generate code to scan the ephemeral table and call VUpdate. */\n  iReg = ++pParse->nMem;\n  pParse->nMem += pTab->nCol+1;\n  addr = sqlite3VdbeAddOp2(v, OP_Rewind, ephemTab, 0);\n  sqlite3VdbeAddOp3(v, OP_Column,  ephemTab, 0, iReg);\n  sqlite3VdbeAddOp3(v, OP_Column, ephemTab, (pRowid?1:0), iReg+1);\n  for(i=0; i<pTab->nCol; i++){\n    sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i+1+(pRowid!=0), iReg+2+i);\n  }\n  sqlite3VtabMakeWritable(pParse, pTab);\n  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, pTab->nCol+2, iReg, pVTab, P4_VTAB);\n  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n  sqlite3MayAbort(pParse);\n  sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1);\n  sqlite3VdbeJumpHere(v, addr);\n  sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);\n\n  /* Cleanup */\n  sqlite3SelectDelete(db, pSelect);  \n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of update.c **********************************************/\n/************** Begin file vacuum.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the VACUUM command.\n**\n** Most of the code in this file may be omitted by defining the\n** SQLITE_OMIT_VACUUM macro.\n*/\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n/*\n** Finalize a prepared statement.  If there was an error, store the\n** text of the error message in *pzErrMsg.  Return the result code.\n*/\nstatic int vacuumFinalize(sqlite3 *db, sqlite3_stmt *pStmt, char **pzErrMsg){\n  int rc;\n  rc = sqlite3VdbeFinalize((Vdbe*)pStmt);\n  if( rc ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n  }\n  return rc;\n}\n\n/*\n** Execute zSql on database db. Return an error code.\n*/\nstatic int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  VVA_ONLY( int rc; )\n  if( !zSql ){\n    return SQLITE_NOMEM;\n  }\n  if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n    return sqlite3_errcode(db);\n  }\n  VVA_ONLY( rc = ) sqlite3_step(pStmt);\n  assert( rc!=SQLITE_ROW || (db->flags&SQLITE_CountRows) );\n  return vacuumFinalize(db, pStmt, pzErrMsg);\n}\n\n/*\n** Execute zSql on database db. The statement returns exactly\n** one column. Execute this as SQL on the same database.\n*/\nstatic int execExecSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    rc = execSql(db, pzErrMsg, (char*)sqlite3_column_text(pStmt, 0));\n    if( rc!=SQLITE_OK ){\n      vacuumFinalize(db, pStmt, pzErrMsg);\n      return rc;\n    }\n  }\n\n  return vacuumFinalize(db, pStmt, pzErrMsg);\n}\n\n/*\n** The non-standard VACUUM command is used to clean up the database,\n** collapse free space, etc.  It is modelled after the VACUUM command\n** in PostgreSQL.\n**\n** In version 1.0.x of SQLite, the VACUUM command would call\n** gdbm_reorganize() on all the database tables.  But beginning\n** with 2.0.0, SQLite no longer uses GDBM so this command has\n** become a no-op.\n*/\nSQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);\n    sqlite3VdbeUsesBtree(v, 0);\n  }\n  return;\n}\n\n/*\n** This routine implements the OP_Vacuum opcode of the VDBE.\n*/\nSQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){\n  int rc = SQLITE_OK;     /* Return code from service routines */\n  Btree *pMain;           /* The database being vacuumed */\n  Btree *pTemp;           /* The temporary database we vacuum into */\n  char *zSql = 0;         /* SQL statements */\n  int saved_flags;        /* Saved value of the db->flags */\n  int saved_nChange;      /* Saved value of db->nChange */\n  int saved_nTotalChange; /* Saved value of db->nTotalChange */\n  void (*saved_xTrace)(void*,const char*);  /* Saved db->xTrace */\n  Db *pDb = 0;            /* Database to detach at end of vacuum */\n  int isMemDb;            /* True if vacuuming a :memory: database */\n  int nRes;               /* Bytes of reserved space at the end of each page */\n  int nDb;                /* Number of attached databases */\n\n  if( !db->autoCommit ){\n    sqlite3SetString(pzErrMsg, db, \"cannot VACUUM from within a transaction\");\n    return SQLITE_ERROR;\n  }\n  if( db->activeVdbeCnt>1 ){\n    sqlite3SetString(pzErrMsg, db,\"cannot VACUUM - SQL statements in progress\");\n    return SQLITE_ERROR;\n  }\n\n  /* Save the current value of the database flags so that it can be \n  ** restored before returning. Then set the writable-schema flag, and\n  ** disable CHECK and foreign key constraints.  */\n  saved_flags = db->flags;\n  saved_nChange = db->nChange;\n  saved_nTotalChange = db->nTotalChange;\n  saved_xTrace = db->xTrace;\n  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin;\n  db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);\n  db->xTrace = 0;\n\n  pMain = db->aDb[0].pBt;\n  isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));\n\n  /* Attach the temporary database as 'vacuum_db'. The synchronous pragma\n  ** can be set to 'off' for this file, as it is not recovered if a crash\n  ** occurs anyway. The integrity of the database is maintained by a\n  ** (possibly synchronous) transaction opened on the main database before\n  ** sqlite3BtreeCopyFile() is called.\n  **\n  ** An optimisation would be to use a non-journaled pager.\n  ** (Later:) I tried setting \"PRAGMA vacuum_db.journal_mode=OFF\" but\n  ** that actually made the VACUUM run slower.  Very little journalling\n  ** actually occurs when doing a vacuum since the vacuum_db is initially\n  ** empty.  Only the journal header is written.  Apparently it takes more\n  ** time to parse and run the PRAGMA to turn journalling off than it does\n  ** to write the journal header file.\n  */\n  nDb = db->nDb;\n  if( sqlite3TempInMemory(db) ){\n    zSql = \"ATTACH ':memory:' AS vacuum_db;\";\n  }else{\n    zSql = \"ATTACH '' AS vacuum_db;\";\n  }\n  rc = execSql(db, pzErrMsg, zSql);\n  if( db->nDb>nDb ){\n    pDb = &db->aDb[db->nDb-1];\n    assert( strcmp(pDb->zName,\"vacuum_db\")==0 );\n  }\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  pTemp = db->aDb[db->nDb-1].pBt;\n\n  /* The call to execSql() to attach the temp database has left the file\n  ** locked (as there was more than one active statement when the transaction\n  ** to read the schema was concluded. Unlock it here so that this doesn't\n  ** cause problems for the call to BtreeSetPageSize() below.  */\n  sqlite3BtreeCommit(pTemp);\n\n  nRes = sqlite3BtreeGetReserve(pMain);\n\n  /* A VACUUM cannot change the pagesize of an encrypted database. */\n#ifdef SQLITE_HAS_CODEC\n  if( db->nextPagesize ){\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);\n    if( nKey ) db->nextPagesize = 0;\n  }\n#endif\n\n  rc = execSql(db, pzErrMsg, \"PRAGMA vacuum_db.synchronous=OFF\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Begin a transaction and take an exclusive lock on the main database\n  ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,\n  ** to ensure that we do not try to change the page-size on a WAL database.\n  */\n  rc = execSql(db, pzErrMsg, \"BEGIN;\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = sqlite3BtreeBeginTrans(pMain, 2);\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Do not attempt to change the page size for a WAL database */\n  if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))\n                                               ==PAGER_JOURNALMODE_WAL ){\n    db->nextPagesize = 0;\n  }\n\n  if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)\n   || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))\n   || NEVER(db->mallocFailed)\n  ){\n    rc = SQLITE_NOMEM;\n    goto end_of_vacuum;\n  }\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  sqlite3BtreeSetAutoVacuum(pTemp, db->nextAutovac>=0 ? db->nextAutovac :\n                                           sqlite3BtreeGetAutoVacuum(pMain));\n#endif\n\n  /* Query the schema of the main database. Create a mirror schema\n  ** in the temporary database.\n  */\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) \"\n      \"  FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'\"\n      \"   AND rootpage>0\"\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)\"\n      \"  FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' \");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) \"\n      \"  FROM sqlite_master WHERE sql LIKE 'CREATE UNIQUE INDEX %'\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Loop through the tables in the main database. For each, do\n  ** an \"INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;\" to copy\n  ** the contents to the temporary database.\n  */\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'INSERT INTO vacuum_db.' || quote(name) \"\n      \"|| ' SELECT * FROM main.' || quote(name) || ';'\"\n      \"FROM main.sqlite_master \"\n      \"WHERE type = 'table' AND name!='sqlite_sequence' \"\n      \"  AND rootpage>0\"\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Copy over the sequence table\n  */\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' \"\n      \"FROM vacuum_db.sqlite_master WHERE name='sqlite_sequence' \"\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execExecSql(db, pzErrMsg,\n      \"SELECT 'INSERT INTO vacuum_db.' || quote(name) \"\n      \"|| ' SELECT * FROM main.' || quote(name) || ';' \"\n      \"FROM vacuum_db.sqlite_master WHERE name=='sqlite_sequence';\"\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n\n  /* Copy the triggers, views, and virtual tables from the main database\n  ** over to the temporary database.  None of these objects has any\n  ** associated storage, so all we have to do is copy their entries\n  ** from the SQLITE_MASTER table.\n  */\n  rc = execSql(db, pzErrMsg,\n      \"INSERT INTO vacuum_db.sqlite_master \"\n      \"  SELECT type, name, tbl_name, rootpage, sql\"\n      \"    FROM main.sqlite_master\"\n      \"   WHERE type='view' OR type='trigger'\"\n      \"      OR (type='table' AND rootpage=0)\"\n  );\n  if( rc ) goto end_of_vacuum;\n\n  /* At this point, there is a write transaction open on both the \n  ** vacuum database and the main database. Assuming no error occurs,\n  ** both transactions are closed by this block - the main database\n  ** transaction by sqlite3BtreeCopyFile() and the other by an explicit\n  ** call to sqlite3BtreeCommit().\n  */\n  {\n    u32 meta;\n    int i;\n\n    /* This array determines which meta meta values are preserved in the\n    ** vacuum.  Even entries are the meta value number and odd entries\n    ** are an increment to apply to the meta value after the vacuum.\n    ** The increment is used to increase the schema cookie so that other\n    ** connections to the same database will know to reread the schema.\n    */\n    static const unsigned char aCopy[] = {\n       BTREE_SCHEMA_VERSION,     1,  /* Add one to the old schema cookie */\n       BTREE_DEFAULT_CACHE_SIZE, 0,  /* Preserve the default page cache size */\n       BTREE_TEXT_ENCODING,      0,  /* Preserve the text encoding */\n       BTREE_USER_VERSION,       0,  /* Preserve the user version */\n       BTREE_APPLICATION_ID,     0,  /* Preserve the application id */\n    };\n\n    assert( 1==sqlite3BtreeIsInTrans(pTemp) );\n    assert( 1==sqlite3BtreeIsInTrans(pMain) );\n\n    /* Copy Btree meta values */\n    for(i=0; i<ArraySize(aCopy); i+=2){\n      /* GetMeta() and UpdateMeta() cannot fail in this context because\n      ** we already have page 1 loaded into cache and marked dirty. */\n      sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);\n      rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);\n      if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;\n    }\n\n    rc = sqlite3BtreeCopyFile(pMain, pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n    rc = sqlite3BtreeCommit(pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));\n#endif\n  }\n\n  assert( rc==SQLITE_OK );\n  rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);\n\nend_of_vacuum:\n  /* Restore the original value of db->flags */\n  db->flags = saved_flags;\n  db->nChange = saved_nChange;\n  db->nTotalChange = saved_nTotalChange;\n  db->xTrace = saved_xTrace;\n  sqlite3BtreeSetPageSize(pMain, -1, -1, 1);\n\n  /* Currently there is an SQL level transaction open on the vacuum\n  ** database. No locks are held on any other files (since the main file\n  ** was committed at the btree level). So it safe to end the transaction\n  ** by manually setting the autoCommit flag to true and detaching the\n  ** vacuum database. The vacuum_db journal file is deleted when the pager\n  ** is closed by the DETACH.\n  */\n  db->autoCommit = 1;\n\n  if( pDb ){\n    sqlite3BtreeClose(pDb->pBt);\n    pDb->pBt = 0;\n    pDb->pSchema = 0;\n  }\n\n  /* This both clears the schemas and reduces the size of the db->aDb[]\n  ** array. */ \n  sqlite3ResetAllSchemasOfConnection(db);\n\n  return rc;\n}\n\n#endif  /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */\n\n/************** End of vacuum.c **********************************************/\n/************** Begin file vtab.c ********************************************/\n/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to help implement virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Before a virtual table xCreate() or xConnect() method is invoked, the\n** sqlite3.pVtabCtx member variable is set to point to an instance of\n** this struct allocated on the stack. It is used by the implementation of \n** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which\n** are invoked only from within xCreate and xConnect methods.\n*/\nstruct VtabCtx {\n  VTable *pVTable;    /* The virtual table being constructed */\n  Table *pTab;        /* The Table object to which the virtual table belongs */\n};\n\n/*\n** The actual function that does the work of creating a new module.\n** This function implements the sqlite3_create_module() and\n** sqlite3_create_module_v2() interfaces.\n*/\nstatic int createModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  int rc = SQLITE_OK;\n  int nName;\n\n  sqlite3_mutex_enter(db->mutex);\n  nName = sqlite3Strlen30(zName);\n  if( sqlite3HashFind(&db->aModule, zName, nName) ){\n    rc = SQLITE_MISUSE_BKPT;\n  }else{\n    Module *pMod;\n    pMod = (Module *)sqlite3DbMallocRaw(db, sizeof(Module) + nName + 1);\n    if( pMod ){\n      Module *pDel;\n      char *zCopy = (char *)(&pMod[1]);\n      memcpy(zCopy, zName, nName+1);\n      pMod->zName = zCopy;\n      pMod->pModule = pModule;\n      pMod->pAux = pAux;\n      pMod->xDestroy = xDestroy;\n      pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,nName,(void*)pMod);\n      assert( pDel==0 || pDel==pMod );\n      if( pDel ){\n        db->mallocFailed = 1;\n        sqlite3DbFree(db, pDel);\n      }\n    }\n  }\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);\n\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux                      /* Context pointer for xCreate/xConnect */\n){\n  return createModule(db, zName, pModule, pAux, 0);\n}\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  return createModule(db, zName, pModule, pAux, xDestroy);\n}\n\n/*\n** Lock the virtual table so that it cannot be disconnected.\n** Locks nest.  Every lock should have a corresponding unlock.\n** If an unlock is omitted, resources leaks will occur.  \n**\n** If a disconnect is attempted while a virtual table is locked,\n** the disconnect is deferred until all locks have been removed.\n*/\nSQLITE_PRIVATE void sqlite3VtabLock(VTable *pVTab){\n  pVTab->nRef++;\n}\n\n\n/*\n** pTab is a pointer to a Table structure representing a virtual-table.\n** Return a pointer to the VTable object used by connection db to access \n** this virtual-table, if one has been created, or NULL otherwise.\n*/\nSQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){\n  VTable *pVtab;\n  assert( IsVirtual(pTab) );\n  for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);\n  return pVtab;\n}\n\n/*\n** Decrement the ref-count on a virtual table object. When the ref-count\n** reaches zero, call the xDisconnect() method to delete the object.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlock(VTable *pVTab){\n  sqlite3 *db = pVTab->db;\n\n  assert( db );\n  assert( pVTab->nRef>0 );\n  assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );\n\n  pVTab->nRef--;\n  if( pVTab->nRef==0 ){\n    sqlite3_vtab *p = pVTab->pVtab;\n    if( p ){\n      p->pModule->xDisconnect(p);\n    }\n    sqlite3DbFree(db, pVTab);\n  }\n}\n\n/*\n** Table p is a virtual table. This function moves all elements in the\n** p->pVTable list to the sqlite3.pDisconnect lists of their associated\n** database connections to be disconnected at the next opportunity. \n** Except, if argument db is not NULL, then the entry associated with\n** connection db is left in the p->pVTable list.\n*/\nstatic VTable *vtabDisconnectAll(sqlite3 *db, Table *p){\n  VTable *pRet = 0;\n  VTable *pVTable = p->pVTable;\n  p->pVTable = 0;\n\n  /* Assert that the mutex (if any) associated with the BtShared database \n  ** that contains table p is held by the caller. See header comments \n  ** above function sqlite3VtabUnlockList() for an explanation of why\n  ** this makes it safe to access the sqlite3.pDisconnect list of any\n  ** database connection that may have an entry in the p->pVTable list.\n  */\n  assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n\n  while( pVTable ){\n    sqlite3 *db2 = pVTable->db;\n    VTable *pNext = pVTable->pNext;\n    assert( db2 );\n    if( db2==db ){\n      pRet = pVTable;\n      p->pVTable = pRet;\n      pRet->pNext = 0;\n    }else{\n      pVTable->pNext = db2->pDisconnect;\n      db2->pDisconnect = pVTable;\n    }\n    pVTable = pNext;\n  }\n\n  assert( !db || pRet );\n  return pRet;\n}\n\n/*\n** Table *p is a virtual table. This function removes the VTable object\n** for table *p associated with database connection db from the linked\n** list in p->pVTab. It also decrements the VTable ref count. This is\n** used when closing database connection db to free all of its VTable\n** objects without disturbing the rest of the Schema object (which may\n** be being used by other shared-cache connections).\n*/\nSQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){\n  VTable **ppVTab;\n\n  assert( IsVirtual(p) );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){\n    if( (*ppVTab)->db==db  ){\n      VTable *pVTab = *ppVTab;\n      *ppVTab = pVTab->pNext;\n      sqlite3VtabUnlock(pVTab);\n      break;\n    }\n  }\n}\n\n\n/*\n** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.\n**\n** This function may only be called when the mutexes associated with all\n** shared b-tree databases opened using connection db are held by the \n** caller. This is done to protect the sqlite3.pDisconnect list. The\n** sqlite3.pDisconnect list is accessed only as follows:\n**\n**   1) By this function. In this case, all BtShared mutexes and the mutex\n**      associated with the database handle itself must be held.\n**\n**   2) By function vtabDisconnectAll(), when it adds a VTable entry to\n**      the sqlite3.pDisconnect list. In this case either the BtShared mutex\n**      associated with the database the virtual table is stored in is held\n**      or, if the virtual table is stored in a non-sharable database, then\n**      the database handle mutex is held.\n**\n** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously \n** by multiple threads. It is thread-safe.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){\n  VTable *p = db->pDisconnect;\n  db->pDisconnect = 0;\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  if( p ){\n    sqlite3ExpirePreparedStatements(db);\n    do {\n      VTable *pNext = p->pNext;\n      sqlite3VtabUnlock(p);\n      p = pNext;\n    }while( p );\n  }\n}\n\n/*\n** Clear any and all virtual-table information from the Table record.\n** This routine is called, for example, just before deleting the Table\n** record.\n**\n** Since it is a virtual-table, the Table structure contains a pointer\n** to the head of a linked list of VTable structures. Each VTable \n** structure is associated with a single sqlite3* user of the schema.\n** The reference count of the VTable structure associated with database \n** connection db is decremented immediately (which may lead to the \n** structure being xDisconnected and free). Any other VTable structures\n** in the list are moved to the sqlite3.pDisconnect list of the associated \n** database connection.\n*/\nSQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){\n  if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);\n  if( p->azModuleArg ){\n    int i;\n    for(i=0; i<p->nModuleArg; i++){\n      if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);\n    }\n    sqlite3DbFree(db, p->azModuleArg);\n  }\n}\n\n/*\n** Add a new module argument to pTable->azModuleArg[].\n** The string is not copied - the pointer is stored.  The\n** string will be freed automatically when the table is\n** deleted.\n*/\nstatic void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){\n  int i = pTable->nModuleArg++;\n  int nBytes = sizeof(char *)*(1+pTable->nModuleArg);\n  char **azModuleArg;\n  azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);\n  if( azModuleArg==0 ){\n    int j;\n    for(j=0; j<i; j++){\n      sqlite3DbFree(db, pTable->azModuleArg[j]);\n    }\n    sqlite3DbFree(db, zArg);\n    sqlite3DbFree(db, pTable->azModuleArg);\n    pTable->nModuleArg = 0;\n  }else{\n    azModuleArg[i] = zArg;\n    azModuleArg[i+1] = 0;\n  }\n  pTable->azModuleArg = azModuleArg;\n}\n\n/*\n** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE\n** statement.  The module name has been parsed, but the optional list\n** of parameters that follow the module name are still pending.\n*/\nSQLITE_PRIVATE void sqlite3VtabBeginParse(\n  Parse *pParse,        /* Parsing context */\n  Token *pName1,        /* Name of new table, or database name */\n  Token *pName2,        /* Name of new table or NULL */\n  Token *pModuleName,   /* Name of the module for the virtual table */\n  int ifNotExists       /* No error if the table already exists */\n){\n  int iDb;              /* The database the table is being created in */\n  Table *pTable;        /* The new virtual table */\n  sqlite3 *db;          /* Database connection */\n\n  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);\n  pTable = pParse->pNewTable;\n  if( pTable==0 ) return;\n  assert( 0==pTable->pIndex );\n\n  db = pParse->db;\n  iDb = sqlite3SchemaToIndex(db, pTable->pSchema);\n  assert( iDb>=0 );\n\n  pTable->tabFlags |= TF_Virtual;\n  pTable->nModuleArg = 0;\n  addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));\n  addModuleArgument(db, pTable, 0);\n  addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));\n  pParse->sNameToken.n = (int)(&pModuleName->z[pModuleName->n] - pName1->z);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Creating a virtual table invokes the authorization callback twice.\n  ** The first invocation, to obtain permission to INSERT a row into the\n  ** sqlite_master table, has already been made by sqlite3StartTable().\n  ** The second call, to obtain permission to create the table, is made now.\n  */\n  if( pTable->azModuleArg ){\n    sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, \n            pTable->azModuleArg[0], pParse->db->aDb[iDb].zName);\n  }\n#endif\n}\n\n/*\n** This routine takes the module argument that has been accumulating\n** in pParse->zArg[] and appends it to the list of arguments on the\n** virtual table currently under construction in pParse->pTable.\n*/\nstatic void addArgumentToVtab(Parse *pParse){\n  if( pParse->sArg.z && pParse->pNewTable ){\n    const char *z = (const char*)pParse->sArg.z;\n    int n = pParse->sArg.n;\n    sqlite3 *db = pParse->db;\n    addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n));\n  }\n}\n\n/*\n** The parser calls this routine after the CREATE VIRTUAL TABLE statement\n** has been completely parsed.\n*/\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){\n  Table *pTab = pParse->pNewTable;  /* The table being constructed */\n  sqlite3 *db = pParse->db;         /* The database connection */\n\n  if( pTab==0 ) return;\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  if( pTab->nModuleArg<1 ) return;\n  \n  /* If the CREATE VIRTUAL TABLE statement is being entered for the\n  ** first time (in other words if the virtual table is actually being\n  ** created now instead of just being read out of sqlite_master) then\n  ** do additional initialization work and store the statement text\n  ** in the sqlite_master table.\n  */\n  if( !db->init.busy ){\n    char *zStmt;\n    char *zWhere;\n    int iDb;\n    Vdbe *v;\n\n    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */\n    if( pEnd ){\n      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;\n    }\n    zStmt = sqlite3MPrintf(db, \"CREATE VIRTUAL TABLE %T\", &pParse->sNameToken);\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.  \n    **\n    ** The VM register number pParse->regRowid holds the rowid of an\n    ** entry in the sqlite_master table tht was created for this vtab\n    ** by sqlite3StartTable().\n    */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zName, SCHEMA_TABLE(iDb),\n      pTab->zName,\n      pTab->zName,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    v = sqlite3GetVdbe(pParse);\n    sqlite3ChangeCookie(pParse, iDb);\n\n    sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);\n    zWhere = sqlite3MPrintf(db, \"name='%q' AND type='table'\", pTab->zName);\n    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n    sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0, \n                         pTab->zName, sqlite3Strlen30(pTab->zName) + 1);\n  }\n\n  /* If we are rereading the sqlite_master table create the in-memory\n  ** record of the table. The xConnect() method is not called until\n  ** the first time the virtual table is used in an SQL statement. This\n  ** allows a schema that contains virtual tables to be loaded before\n  ** the required virtual table implementations are registered.  */\n  else {\n    Table *pOld;\n    Schema *pSchema = pTab->pSchema;\n    const char *zName = pTab->zName;\n    int nName = sqlite3Strlen30(zName);\n    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, nName, pTab);\n    if( pOld ){\n      db->mallocFailed = 1;\n      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */\n      return;\n    }\n    pParse->pNewTable = 0;\n  }\n}\n\n/*\n** The parser calls this routine when it sees the first token\n** of an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse *pParse){\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  pParse->sArg.n = 0;\n}\n\n/*\n** The parser calls this routine for each token after the first token\n** in an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse *pParse, Token *p){\n  Token *pArg = &pParse->sArg;\n  if( pArg->z==0 ){\n    pArg->z = p->z;\n    pArg->n = p->n;\n  }else{\n    assert(pArg->z < p->z);\n    pArg->n = (int)(&p->z[p->n] - pArg->z);\n  }\n}\n\n/*\n** Invoke a virtual table constructor (either xCreate or xConnect). The\n** pointer to the function to invoke is passed as the fourth parameter\n** to this procedure.\n*/\nstatic int vtabCallConstructor(\n  sqlite3 *db, \n  Table *pTab,\n  Module *pMod,\n  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),\n  char **pzErr\n){\n  VtabCtx sCtx, *pPriorCtx;\n  VTable *pVTable;\n  int rc;\n  const char *const*azArg = (const char *const*)pTab->azModuleArg;\n  int nArg = pTab->nModuleArg;\n  char *zErr = 0;\n  char *zModuleName = sqlite3MPrintf(db, \"%s\", pTab->zName);\n  int iDb;\n\n  if( !zModuleName ){\n    return SQLITE_NOMEM;\n  }\n\n  pVTable = sqlite3DbMallocZero(db, sizeof(VTable));\n  if( !pVTable ){\n    sqlite3DbFree(db, zModuleName);\n    return SQLITE_NOMEM;\n  }\n  pVTable->db = db;\n  pVTable->pMod = pMod;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  pTab->azModuleArg[1] = db->aDb[iDb].zName;\n\n  /* Invoke the virtual table constructor */\n  assert( &db->pVtabCtx );\n  assert( xConstruct );\n  sCtx.pTab = pTab;\n  sCtx.pVTable = pVTable;\n  pPriorCtx = db->pVtabCtx;\n  db->pVtabCtx = &sCtx;\n  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);\n  db->pVtabCtx = pPriorCtx;\n  if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;\n\n  if( SQLITE_OK!=rc ){\n    if( zErr==0 ){\n      *pzErr = sqlite3MPrintf(db, \"vtable constructor failed: %s\", zModuleName);\n    }else {\n      *pzErr = sqlite3MPrintf(db, \"%s\", zErr);\n      sqlite3_free(zErr);\n    }\n    sqlite3DbFree(db, pVTable);\n  }else if( ALWAYS(pVTable->pVtab) ){\n    /* Justification of ALWAYS():  A correct vtab constructor must allocate\n    ** the sqlite3_vtab object if successful.  */\n    pVTable->pVtab->pModule = pMod->pModule;\n    pVTable->nRef = 1;\n    if( sCtx.pTab ){\n      const char *zFormat = \"vtable constructor did not declare schema: %s\";\n      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);\n      sqlite3VtabUnlock(pVTable);\n      rc = SQLITE_ERROR;\n    }else{\n      int iCol;\n      /* If everything went according to plan, link the new VTable structure\n      ** into the linked list headed by pTab->pVTable. Then loop through the \n      ** columns of the table to see if any of them contain the token \"hidden\".\n      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from\n      ** the type string.  */\n      pVTable->pNext = pTab->pVTable;\n      pTab->pVTable = pVTable;\n\n      for(iCol=0; iCol<pTab->nCol; iCol++){\n        char *zType = pTab->aCol[iCol].zType;\n        int nType;\n        int i = 0;\n        if( !zType ) continue;\n        nType = sqlite3Strlen30(zType);\n        if( sqlite3StrNICmp(\"hidden\", zType, 6)||(zType[6] && zType[6]!=' ') ){\n          for(i=0; i<nType; i++){\n            if( (0==sqlite3StrNICmp(\" hidden\", &zType[i], 7))\n             && (zType[i+7]=='\\0' || zType[i+7]==' ')\n            ){\n              i++;\n              break;\n            }\n          }\n        }\n        if( i<nType ){\n          int j;\n          int nDel = 6 + (zType[i+6] ? 1 : 0);\n          for(j=i; (j+nDel)<=nType; j++){\n            zType[j] = zType[j+nDel];\n          }\n          if( zType[i]=='\\0' && i>0 ){\n            assert(zType[i-1]==' ');\n            zType[i-1] = '\\0';\n          }\n          pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;\n        }\n      }\n    }\n  }\n\n  sqlite3DbFree(db, zModuleName);\n  return rc;\n}\n\n/*\n** This function is invoked by the parser to call the xConnect() method\n** of the virtual table pTab. If an error occurs, an error code is returned \n** and an error left in pParse.\n**\n** This call is a no-op if table pTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){\n  sqlite3 *db = pParse->db;\n  const char *zMod;\n  Module *pMod;\n  int rc;\n\n  assert( pTab );\n  if( (pTab->tabFlags & TF_Virtual)==0 || sqlite3GetVTable(db, pTab) ){\n    return SQLITE_OK;\n  }\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod, sqlite3Strlen30(zMod));\n\n  if( !pMod ){\n    const char *zModule = pTab->azModuleArg[0];\n    sqlite3ErrorMsg(pParse, \"no such module: %s\", zModule);\n    rc = SQLITE_ERROR;\n  }else{\n    char *zErr = 0;\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"%s\", zErr);\n    }\n    sqlite3DbFree(db, zErr);\n  }\n\n  return rc;\n}\n/*\n** Grow the db->aVTrans[] array so that there is room for at least one\n** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.\n*/\nstatic int growVTrans(sqlite3 *db){\n  const int ARRAY_INCR = 5;\n\n  /* Grow the sqlite3.aVTrans array if required */\n  if( (db->nVTrans%ARRAY_INCR)==0 ){\n    VTable **aVTrans;\n    int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);\n    aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);\n    if( !aVTrans ){\n      return SQLITE_NOMEM;\n    }\n    memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);\n    db->aVTrans = aVTrans;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should\n** have already been reserved using growVTrans().\n*/\nstatic void addToVTrans(sqlite3 *db, VTable *pVTab){\n  /* Add pVtab to the end of sqlite3.aVTrans */\n  db->aVTrans[db->nVTrans++] = pVTab;\n  sqlite3VtabLock(pVTab);\n}\n\n/*\n** This function is invoked by the vdbe to call the xCreate method\n** of the virtual table named zTab in database iDb. \n**\n** If an error occurs, *pzErr is set to point an an English language\n** description of the error and an SQLITE_XXX error code is returned.\n** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){\n  int rc = SQLITE_OK;\n  Table *pTab;\n  Module *pMod;\n  const char *zMod;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);\n  assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable );\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod, sqlite3Strlen30(zMod));\n\n  /* If the module has been registered and includes a Create method, \n  ** invoke it now. If the module has not been registered, return an \n  ** error. Otherwise, do nothing.\n  */\n  if( !pMod ){\n    *pzErr = sqlite3MPrintf(db, \"no such module: %s\", zMod);\n    rc = SQLITE_ERROR;\n  }else{\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);\n  }\n\n  /* Justification of ALWAYS():  The xConstructor method is required to\n  ** create a valid sqlite3_vtab if it returns SQLITE_OK. */\n  if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      addToVTrans(db, sqlite3GetVTable(db, pTab));\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to set the schema of a virtual table.  It is only\n** valid to call this function from within the xCreate() or xConnect() of a\n** virtual table module.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){\n  Parse *pParse;\n\n  int rc = SQLITE_OK;\n  Table *pTab;\n  char *zErr = 0;\n\n  sqlite3_mutex_enter(db->mutex);\n  if( !db->pVtabCtx || !(pTab = db->pVtabCtx->pTab) ){\n    sqlite3Error(db, SQLITE_MISUSE, 0);\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_MISUSE_BKPT;\n  }\n  assert( (pTab->tabFlags & TF_Virtual)!=0 );\n\n  pParse = sqlite3StackAllocZero(db, sizeof(*pParse));\n  if( pParse==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    pParse->declareVtab = 1;\n    pParse->db = db;\n    pParse->nQueryLoop = 1;\n  \n    if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr) \n     && pParse->pNewTable\n     && !db->mallocFailed\n     && !pParse->pNewTable->pSelect\n     && (pParse->pNewTable->tabFlags & TF_Virtual)==0\n    ){\n      if( !pTab->aCol ){\n        pTab->aCol = pParse->pNewTable->aCol;\n        pTab->nCol = pParse->pNewTable->nCol;\n        pParse->pNewTable->nCol = 0;\n        pParse->pNewTable->aCol = 0;\n      }\n      db->pVtabCtx->pTab = 0;\n    }else{\n      sqlite3Error(db, SQLITE_ERROR, (zErr ? \"%s\" : 0), zErr);\n      sqlite3DbFree(db, zErr);\n      rc = SQLITE_ERROR;\n    }\n    pParse->declareVtab = 0;\n  \n    if( pParse->pVdbe ){\n      sqlite3VdbeFinalize(pParse->pVdbe);\n    }\n    sqlite3DeleteTable(db, pParse->pNewTable);\n    sqlite3StackFree(db, pParse);\n  }\n\n  assert( (rc&0xff)==rc );\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is invoked by the vdbe to call the xDestroy method\n** of the virtual table named zTab in database iDb. This occurs\n** when a DROP TABLE is mentioned.\n**\n** This call is a no-op if zTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){\n  int rc = SQLITE_OK;\n  Table *pTab;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);\n  if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){\n    VTable *p = vtabDisconnectAll(db, pTab);\n\n    assert( rc==SQLITE_OK );\n    rc = p->pMod->pModule->xDestroy(p->pVtab);\n\n    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */\n    if( rc==SQLITE_OK ){\n      assert( pTab->pVTable==p && p->pNext==0 );\n      p->pVtab = 0;\n      pTab->pVTable = 0;\n      sqlite3VtabUnlock(p);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function invokes either the xRollback or xCommit method\n** of each of the virtual tables in the sqlite3.aVTrans array. The method\n** called is identified by the second argument, \"offset\", which is\n** the offset of the method to call in the sqlite3_module structure.\n**\n** The array is cleared after invoking the callbacks. \n*/\nstatic void callFinaliser(sqlite3 *db, int offset){\n  int i;\n  if( db->aVTrans ){\n    for(i=0; i<db->nVTrans; i++){\n      VTable *pVTab = db->aVTrans[i];\n      sqlite3_vtab *p = pVTab->pVtab;\n      if( p ){\n        int (*x)(sqlite3_vtab *);\n        x = *(int (**)(sqlite3_vtab *))((char *)p->pModule + offset);\n        if( x ) x(p);\n      }\n      pVTab->iSavepoint = 0;\n      sqlite3VtabUnlock(pVTab);\n    }\n    sqlite3DbFree(db, db->aVTrans);\n    db->nVTrans = 0;\n    db->aVTrans = 0;\n  }\n}\n\n/*\n** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans\n** array. Return the error code for the first error that occurs, or\n** SQLITE_OK if all xSync operations are successful.\n**\n** Set *pzErrmsg to point to a buffer that should be released using \n** sqlite3DbFree() containing an error message, if one is available.\n*/\nSQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, char **pzErrmsg){\n  int i;\n  int rc = SQLITE_OK;\n  VTable **aVTrans = db->aVTrans;\n\n  db->aVTrans = 0;\n  for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n    int (*x)(sqlite3_vtab *);\n    sqlite3_vtab *pVtab = aVTrans[i]->pVtab;\n    if( pVtab && (x = pVtab->pModule->xSync)!=0 ){\n      rc = x(pVtab);\n      sqlite3DbFree(db, *pzErrmsg);\n      *pzErrmsg = sqlite3DbStrDup(db, pVtab->zErrMsg);\n      sqlite3_free(pVtab->zErrMsg);\n    }\n  }\n  db->aVTrans = aVTrans;\n  return rc;\n}\n\n/*\n** Invoke the xRollback method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xRollback));\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xCommit method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xCommit));\n  return SQLITE_OK;\n}\n\n/*\n** If the virtual table pVtab supports the transaction interface\n** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is\n** not currently open, invoke the xBegin method now.\n**\n** If the xBegin call is successful, place the sqlite3_vtab pointer\n** in the sqlite3.aVTrans array.\n*/\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){\n  int rc = SQLITE_OK;\n  const sqlite3_module *pModule;\n\n  /* Special case: If db->aVTrans is NULL and db->nVTrans is greater\n  ** than zero, then this function is being called from within a\n  ** virtual module xSync() callback. It is illegal to write to \n  ** virtual module tables in this case, so return SQLITE_LOCKED.\n  */\n  if( sqlite3VtabInSync(db) ){\n    return SQLITE_LOCKED;\n  }\n  if( !pVTab ){\n    return SQLITE_OK;\n  } \n  pModule = pVTab->pVtab->pModule;\n\n  if( pModule->xBegin ){\n    int i;\n\n    /* If pVtab is already in the aVTrans array, return early */\n    for(i=0; i<db->nVTrans; i++){\n      if( db->aVTrans[i]==pVTab ){\n        return SQLITE_OK;\n      }\n    }\n\n    /* Invoke the xBegin method. If successful, add the vtab to the \n    ** sqlite3.aVTrans[] array. */\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      rc = pModule->xBegin(pVTab->pVtab);\n      if( rc==SQLITE_OK ){\n        addToVTrans(db, pVTab);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke either the xSavepoint, xRollbackTo or xRelease method of all\n** virtual tables that currently have an open transaction. Pass iSavepoint\n** as the second argument to the virtual table method invoked.\n**\n** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is\n** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is \n** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with\n** an open transaction is invoked.\n**\n** If any virtual table method returns an error code other than SQLITE_OK, \n** processing is abandoned and the error returned to the caller of this\n** function immediately. If all calls to virtual table methods are successful,\n** SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n\n  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );\n  assert( iSavepoint>=0 );\n  if( db->aVTrans ){\n    int i;\n    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n      VTable *pVTab = db->aVTrans[i];\n      const sqlite3_module *pMod = pVTab->pMod->pModule;\n      if( pVTab->pVtab && pMod->iVersion>=2 ){\n        int (*xMethod)(sqlite3_vtab *, int);\n        switch( op ){\n          case SAVEPOINT_BEGIN:\n            xMethod = pMod->xSavepoint;\n            pVTab->iSavepoint = iSavepoint+1;\n            break;\n          case SAVEPOINT_ROLLBACK:\n            xMethod = pMod->xRollbackTo;\n            break;\n          default:\n            xMethod = pMod->xRelease;\n            break;\n        }\n        if( xMethod && pVTab->iSavepoint>iSavepoint ){\n          rc = xMethod(pVTab->pVtab, iSavepoint);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The first parameter (pDef) is a function implementation.  The\n** second parameter (pExpr) is the first argument to this function.\n** If pExpr is a column in a virtual table, then let the virtual\n** table implementation have an opportunity to overload the function.\n**\n** This routine is used to allow virtual table implementations to\n** overload MATCH, LIKE, GLOB, and REGEXP operators.\n**\n** Return either the pDef argument (indicating no change) or a \n** new FuncDef structure that is marked as ephemeral using the\n** SQLITE_FUNC_EPHEM flag.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(\n  sqlite3 *db,    /* Database connection for reporting malloc problems */\n  FuncDef *pDef,  /* Function to possibly overload */\n  int nArg,       /* Number of arguments to the function */\n  Expr *pExpr     /* First argument to the function */\n){\n  Table *pTab;\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pMod;\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**) = 0;\n  void *pArg = 0;\n  FuncDef *pNew;\n  int rc = 0;\n  char *zLowerName;\n  unsigned char *z;\n\n\n  /* Check to see the left operand is a column in a virtual table */\n  if( NEVER(pExpr==0) ) return pDef;\n  if( pExpr->op!=TK_COLUMN ) return pDef;\n  pTab = pExpr->pTab;\n  if( NEVER(pTab==0) ) return pDef;\n  if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;\n  pVtab = sqlite3GetVTable(db, pTab)->pVtab;\n  assert( pVtab!=0 );\n  assert( pVtab->pModule!=0 );\n  pMod = (sqlite3_module *)pVtab->pModule;\n  if( pMod->xFindFunction==0 ) return pDef;\n \n  /* Call the xFindFunction method on the virtual table implementation\n  ** to see if the implementation wants to overload this function \n  */\n  zLowerName = sqlite3DbStrDup(db, pDef->zName);\n  if( zLowerName ){\n    for(z=(unsigned char*)zLowerName; *z; z++){\n      *z = sqlite3UpperToLower[*z];\n    }\n    rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xFunc, &pArg);\n    sqlite3DbFree(db, zLowerName);\n  }\n  if( rc==0 ){\n    return pDef;\n  }\n\n  /* Create a new ephemeral function definition for the overloaded\n  ** function */\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)\n                             + sqlite3Strlen30(pDef->zName) + 1);\n  if( pNew==0 ){\n    return pDef;\n  }\n  *pNew = *pDef;\n  pNew->zName = (char *)&pNew[1];\n  memcpy(pNew->zName, pDef->zName, sqlite3Strlen30(pDef->zName)+1);\n  pNew->xFunc = xFunc;\n  pNew->pUserData = pArg;\n  pNew->flags |= SQLITE_FUNC_EPHEM;\n  return pNew;\n}\n\n/*\n** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]\n** array so that an OP_VBegin will get generated for it.  Add pTab to the\n** array if it is missing.  If pTab is already in the array, this routine\n** is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i, n;\n  Table **apVtabLock;\n\n  assert( IsVirtual(pTab) );\n  for(i=0; i<pToplevel->nVtabLock; i++){\n    if( pTab==pToplevel->apVtabLock[i] ) return;\n  }\n  n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);\n  apVtabLock = sqlite3_realloc(pToplevel->apVtabLock, n);\n  if( apVtabLock ){\n    pToplevel->apVtabLock = apVtabLock;\n    pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;\n  }else{\n    pToplevel->db->mallocFailed = 1;\n  }\n}\n\n/*\n** Return the ON CONFLICT resolution mode in effect for the virtual\n** table update operation currently in progress.\n**\n** The results of this routine are undefined unless it is called from\n** within an xUpdate method.\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){\n  static const unsigned char aMap[] = { \n    SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE \n  };\n  assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 );\n  assert( OE_Ignore==4 && OE_Replace==5 );\n  assert( db->vtabOnConflict>=1 && db->vtabOnConflict<=5 );\n  return (int)aMap[db->vtabOnConflict-1];\n}\n\n/*\n** Call from within the xCreate() or xConnect() methods to provide \n** the SQLite core with additional information about the behavior\n** of the virtual table being implemented.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_VTAB_CONSTRAINT_SUPPORT: {\n      VtabCtx *p = db->pVtabCtx;\n      if( !p ){\n        rc = SQLITE_MISUSE_BKPT;\n      }else{\n        assert( p->pTab==0 || (p->pTab->tabFlags & TF_Virtual)!=0 );\n        p->pVTable->bConstraint = (u8)va_arg(ap, int);\n      }\n      break;\n    }\n    default:\n      rc = SQLITE_MISUSE_BKPT;\n      break;\n  }\n  va_end(ap);\n\n  if( rc!=SQLITE_OK ) sqlite3Error(db, rc, 0);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of vtab.c ************************************************/\n/************** Begin file where.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.  This module is responsible for\n** generating the code that loops through a table looking for applicable\n** rows.  Indices are selected and used to speed the search when doing\n** so is applicable.  Because this module is responsible for selecting\n** indices, you might also think of this module as the \"query optimizer\".\n*/\n\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace = 0;\n#endif\n#if defined(SQLITE_DEBUG) \\\n    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))\n# define WHERETRACE(X)  if(sqlite3WhereTrace) sqlite3DebugPrintf X\n#else\n# define WHERETRACE(X)\n#endif\n\n/* Forward reference\n*/\ntypedef struct WhereClause WhereClause;\ntypedef struct WhereMaskSet WhereMaskSet;\ntypedef struct WhereOrInfo WhereOrInfo;\ntypedef struct WhereAndInfo WhereAndInfo;\ntypedef struct WhereCost WhereCost;\n\n/*\n** The query generator uses an array of instances of this structure to\n** help it analyze the subexpressions of the WHERE clause.  Each WHERE\n** clause subexpression is separated from the others by AND operators,\n** usually, or sometimes subexpressions separated by OR.\n**\n** All WhereTerms are collected into a single WhereClause structure.  \n** The following identity holds:\n**\n**        WhereTerm.pWC->a[WhereTerm.idx] == WhereTerm\n**\n** When a term is of the form:\n**\n**              X <op> <expr>\n**\n** where X is a column name and <op> is one of certain operators,\n** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the\n** cursor number and column number for X.  WhereTerm.eOperator records\n** the <op> using a bitmask encoding defined by WO_xxx below.  The\n** use of a bitmask encoding for the operator allows us to search\n** quickly for terms that match any of several different operators.\n**\n** A WhereTerm might also be two or more subterms connected by OR:\n**\n**         (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....\n**\n** In this second case, wtFlag as the TERM_ORINFO set and eOperator==WO_OR\n** and the WhereTerm.u.pOrInfo field points to auxiliary information that\n** is collected about the\n**\n** If a term in the WHERE clause does not match either of the two previous\n** categories, then eOperator==0.  The WhereTerm.pExpr field is still set\n** to the original subexpression content and wtFlags is set up appropriately\n** but no other fields in the WhereTerm object are meaningful.\n**\n** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers,\n** but they do so indirectly.  A single WhereMaskSet structure translates\n** cursor number into bits and the translated bit is stored in the prereq\n** fields.  The translation is used in order to maximize the number of\n** bits that will fit in a Bitmask.  The VDBE cursor numbers might be\n** spread out over the non-negative integers.  For example, the cursor\n** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45.  The WhereMaskSet\n** translates these sparse cursor numbers into consecutive integers\n** beginning with 0 in order to make the best possible use of the available\n** bits in the Bitmask.  So, in the example above, the cursor numbers\n** would be mapped into integers 0 through 7.\n**\n** The number of terms in a join is limited by the number of bits\n** in prereqRight and prereqAll.  The default is 64 bits, hence SQLite\n** is only able to process joins with 64 or fewer tables.\n*/\ntypedef struct WhereTerm WhereTerm;\nstruct WhereTerm {\n  Expr *pExpr;            /* Pointer to the subexpression that is this term */\n  int iParent;            /* Disable pWC->a[iParent] when this term disabled */\n  int leftCursor;         /* Cursor number of X in \"X <op> <expr>\" */\n  union {\n    int leftColumn;         /* Column number of X in \"X <op> <expr>\" */\n    WhereOrInfo *pOrInfo;   /* Extra information if (eOperator & WO_OR)!=0 */\n    WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */\n  } u;\n  u16 eOperator;          /* A WO_xx value describing <op> */\n  u8 wtFlags;             /* TERM_xxx bit flags.  See below */\n  u8 nChild;              /* Number of children that must disable us */\n  WhereClause *pWC;       /* The clause this term is part of */\n  Bitmask prereqRight;    /* Bitmask of tables used by pExpr->pRight */\n  Bitmask prereqAll;      /* Bitmask of tables referenced by pExpr */\n};\n\n/*\n** Allowed values of WhereTerm.wtFlags\n*/\n#define TERM_DYNAMIC    0x01   /* Need to call sqlite3ExprDelete(db, pExpr) */\n#define TERM_VIRTUAL    0x02   /* Added by the optimizer.  Do not code */\n#define TERM_CODED      0x04   /* This term is already coded */\n#define TERM_COPIED     0x08   /* Has a child */\n#define TERM_ORINFO     0x10   /* Need to free the WhereTerm.u.pOrInfo object */\n#define TERM_ANDINFO    0x20   /* Need to free the WhereTerm.u.pAndInfo obj */\n#define TERM_OR_OK      0x40   /* Used during OR-clause processing */\n#ifdef SQLITE_ENABLE_STAT3\n#  define TERM_VNULL    0x80   /* Manufactured x>NULL or x<=NULL term */\n#else\n#  define TERM_VNULL    0x00   /* Disabled if not using stat3 */\n#endif\n\n/*\n** An instance of the following structure holds all information about a\n** WHERE clause.  Mostly this is a container for one or more WhereTerms.\n**\n** Explanation of pOuter:  For a WHERE clause of the form\n**\n**           a AND ((b AND c) OR (d AND e)) AND f\n**\n** There are separate WhereClause objects for the whole clause and for\n** the subclauses \"(b AND c)\" and \"(d AND e)\".  The pOuter field of the\n** subclauses points to the WhereClause object for the whole clause.\n*/\nstruct WhereClause {\n  Parse *pParse;           /* The parser context */\n  WhereMaskSet *pMaskSet;  /* Mapping of table cursor numbers to bitmasks */\n  WhereClause *pOuter;     /* Outer conjunction */\n  u8 op;                   /* Split operator.  TK_AND or TK_OR */\n  u16 wctrlFlags;          /* Might include WHERE_AND_ONLY */\n  int nTerm;               /* Number of terms */\n  int nSlot;               /* Number of entries in a[] */\n  WhereTerm *a;            /* Each a[] describes a term of the WHERE cluase */\n#if defined(SQLITE_SMALL_STACK)\n  WhereTerm aStatic[1];    /* Initial static space for a[] */\n#else\n  WhereTerm aStatic[8];    /* Initial static space for a[] */\n#endif\n};\n\n/*\n** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereOrInfo {\n  WhereClause wc;          /* Decomposition into subterms */\n  Bitmask indexable;       /* Bitmask of all indexable tables in the clause */\n};\n\n/*\n** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereAndInfo {\n  WhereClause wc;          /* The subexpression broken out */\n};\n\n/*\n** An instance of the following structure keeps track of a mapping\n** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.\n**\n** The VDBE cursor numbers are small integers contained in \n** SrcList_item.iCursor and Expr.iTable fields.  For any given WHERE \n** clause, the cursor numbers might not begin with 0 and they might\n** contain gaps in the numbering sequence.  But we want to make maximum\n** use of the bits in our bitmasks.  This structure provides a mapping\n** from the sparse cursor numbers into consecutive integers beginning\n** with 0.\n**\n** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask\n** corresponds VDBE cursor number B.  The A-th bit of a bitmask is 1<<A.\n**\n** For example, if the WHERE clause expression used these VDBE\n** cursors:  4, 5, 8, 29, 57, 73.  Then the  WhereMaskSet structure\n** would map those cursor numbers into bits 0 through 5.\n**\n** Note that the mapping is not necessarily ordered.  In the example\n** above, the mapping might go like this:  4->3, 5->1, 8->2, 29->0,\n** 57->5, 73->4.  Or one of 719 other combinations might be used. It\n** does not really matter.  What is important is that sparse cursor\n** numbers all get mapped into bit numbers that begin with 0 and contain\n** no gaps.\n*/\nstruct WhereMaskSet {\n  int n;                        /* Number of assigned cursor values */\n  int ix[BMS];                  /* Cursor assigned to each bit */\n};\n\n/*\n** A WhereCost object records a lookup strategy and the estimated\n** cost of pursuing that strategy.\n*/\nstruct WhereCost {\n  WherePlan plan;    /* The lookup strategy */\n  double rCost;      /* Overall cost of pursuing this search strategy */\n  Bitmask used;      /* Bitmask of cursors used by this plan */\n};\n\n/*\n** Bitmasks for the operators that indices are able to exploit.  An\n** OR-ed combination of these values can be used when searching for\n** terms in the where clause.\n*/\n#define WO_IN     0x001\n#define WO_EQ     0x002\n#define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))\n#define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))\n#define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))\n#define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))\n#define WO_MATCH  0x040\n#define WO_ISNULL 0x080\n#define WO_OR     0x100       /* Two or more OR-connected terms */\n#define WO_AND    0x200       /* Two or more AND-connected terms */\n#define WO_EQUIV  0x400       /* Of the form A==B, both columns */\n#define WO_NOOP   0x800       /* This term does not restrict search space */\n\n#define WO_ALL    0xfff       /* Mask of all possible WO_* values */\n#define WO_SINGLE 0x0ff       /* Mask of all non-compound WO_* values */\n\n/*\n** Value for wsFlags returned by bestIndex() and stored in\n** WhereLevel.wsFlags.  These flags determine which search\n** strategies are appropriate.\n**\n** The least significant 12 bits is reserved as a mask for WO_ values above.\n** The WhereLevel.wsFlags field is usually set to WO_IN|WO_EQ|WO_ISNULL.\n** But if the table is the right table of a left join, WhereLevel.wsFlags\n** is set to WO_IN|WO_EQ.  The WhereLevel.wsFlags field can then be used as\n** the \"op\" parameter to findTerm when we are resolving equality constraints.\n** ISNULL constraints will then not be used on the right table of a left\n** join.  Tickets #2177 and #2189.\n*/\n#define WHERE_ROWID_EQ     0x00001000  /* rowid=EXPR or rowid IN (...) */\n#define WHERE_ROWID_RANGE  0x00002000  /* rowid<EXPR and/or rowid>EXPR */\n#define WHERE_COLUMN_EQ    0x00010000  /* x=EXPR or x IN (...) or x IS NULL */\n#define WHERE_COLUMN_RANGE 0x00020000  /* x<EXPR and/or x>EXPR */\n#define WHERE_COLUMN_IN    0x00040000  /* x IN (...) */\n#define WHERE_COLUMN_NULL  0x00080000  /* x IS NULL */\n#define WHERE_INDEXED      0x000f0000  /* Anything that uses an index */\n#define WHERE_NOT_FULLSCAN 0x100f3000  /* Does not do a full table scan */\n#define WHERE_IN_ABLE      0x080f1000  /* Able to support an IN operator */\n#define WHERE_TOP_LIMIT    0x00100000  /* x<EXPR or x<=EXPR constraint */\n#define WHERE_BTM_LIMIT    0x00200000  /* x>EXPR or x>=EXPR constraint */\n#define WHERE_BOTH_LIMIT   0x00300000  /* Both x>EXPR and x<EXPR */\n#define WHERE_IDX_ONLY     0x00400000  /* Use index only - omit table */\n#define WHERE_ORDERED      0x00800000  /* Output will appear in correct order */\n#define WHERE_REVERSE      0x01000000  /* Scan in reverse order */\n#define WHERE_UNIQUE       0x02000000  /* Selects no more than one row */\n#define WHERE_ALL_UNIQUE   0x04000000  /* This and all prior have one row */\n#define WHERE_OB_UNIQUE    0x00004000  /* Values in ORDER BY columns are \n                                       ** different for every output row */\n#define WHERE_VIRTUALTABLE 0x08000000  /* Use virtual-table processing */\n#define WHERE_MULTI_OR     0x10000000  /* OR using multiple indices */\n#define WHERE_TEMP_INDEX   0x20000000  /* Uses an ephemeral index */\n#define WHERE_DISTINCT     0x40000000  /* Correct order for DISTINCT */\n#define WHERE_COVER_SCAN   0x80000000  /* Full scan of a covering index */\n\n/*\n** This module contains many separate subroutines that work together to\n** find the best indices to use for accessing a particular table in a query.\n** An instance of the following structure holds context information about the\n** index search so that it can be more easily passed between the various\n** routines.\n*/\ntypedef struct WhereBestIdx WhereBestIdx;\nstruct WhereBestIdx {\n  Parse *pParse;                  /* Parser context */\n  WhereClause *pWC;               /* The WHERE clause */\n  struct SrcList_item *pSrc;      /* The FROM clause term to search */\n  Bitmask notReady;               /* Mask of cursors not available */\n  Bitmask notValid;               /* Cursors not available for any purpose */\n  ExprList *pOrderBy;             /* The ORDER BY clause */\n  ExprList *pDistinct;            /* The select-list if query is DISTINCT */\n  sqlite3_index_info **ppIdxInfo; /* Index information passed to xBestIndex */\n  int i, n;                       /* Which loop is being coded; # of loops */\n  WhereLevel *aLevel;             /* Info about outer loops */\n  WhereCost cost;                 /* Lowest cost query plan */\n};\n\n/*\n** Return TRUE if the probe cost is less than the baseline cost\n*/\nstatic int compareCost(const WhereCost *pProbe, const WhereCost *pBaseline){\n  if( pProbe->rCost<pBaseline->rCost ) return 1;\n  if( pProbe->rCost>pBaseline->rCost ) return 0;\n  if( pProbe->plan.nOBSat>pBaseline->plan.nOBSat ) return 1;\n  if( pProbe->plan.nRow<pBaseline->plan.nRow ) return 1;\n  return 0;\n}\n\n/*\n** Initialize a preallocated WhereClause structure.\n*/\nstatic void whereClauseInit(\n  WhereClause *pWC,        /* The WhereClause to be initialized */\n  Parse *pParse,           /* The parsing context */\n  WhereMaskSet *pMaskSet,  /* Mapping from table cursor numbers to bitmasks */\n  u16 wctrlFlags           /* Might include WHERE_AND_ONLY */\n){\n  pWC->pParse = pParse;\n  pWC->pMaskSet = pMaskSet;\n  pWC->pOuter = 0;\n  pWC->nTerm = 0;\n  pWC->nSlot = ArraySize(pWC->aStatic);\n  pWC->a = pWC->aStatic;\n  pWC->wctrlFlags = wctrlFlags;\n}\n\n/* Forward reference */\nstatic void whereClauseClear(WhereClause*);\n\n/*\n** Deallocate all memory associated with a WhereOrInfo object.\n*/\nstatic void whereOrInfoDelete(sqlite3 *db, WhereOrInfo *p){\n  whereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Deallocate all memory associated with a WhereAndInfo object.\n*/\nstatic void whereAndInfoDelete(sqlite3 *db, WhereAndInfo *p){\n  whereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Deallocate a WhereClause structure.  The WhereClause structure\n** itself is not freed.  This routine is the inverse of whereClauseInit().\n*/\nstatic void whereClauseClear(WhereClause *pWC){\n  int i;\n  WhereTerm *a;\n  sqlite3 *db = pWC->pParse->db;\n  for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){\n    if( a->wtFlags & TERM_DYNAMIC ){\n      sqlite3ExprDelete(db, a->pExpr);\n    }\n    if( a->wtFlags & TERM_ORINFO ){\n      whereOrInfoDelete(db, a->u.pOrInfo);\n    }else if( a->wtFlags & TERM_ANDINFO ){\n      whereAndInfoDelete(db, a->u.pAndInfo);\n    }\n  }\n  if( pWC->a!=pWC->aStatic ){\n    sqlite3DbFree(db, pWC->a);\n  }\n}\n\n/*\n** Add a single new WhereTerm entry to the WhereClause object pWC.\n** The new WhereTerm object is constructed from Expr p and with wtFlags.\n** The index in pWC->a[] of the new WhereTerm is returned on success.\n** 0 is returned if the new WhereTerm could not be added due to a memory\n** allocation error.  The memory allocation failure will be recorded in\n** the db->mallocFailed flag so that higher-level functions can detect it.\n**\n** This routine will increase the size of the pWC->a[] array as necessary.\n**\n** If the wtFlags argument includes TERM_DYNAMIC, then responsibility\n** for freeing the expression p is assumed by the WhereClause object pWC.\n** This is true even if this routine fails to allocate a new WhereTerm.\n**\n** WARNING:  This routine might reallocate the space used to store\n** WhereTerms.  All pointers to WhereTerms should be invalidated after\n** calling this routine.  Such pointers may be reinitialized by referencing\n** the pWC->a[] array.\n*/\nstatic int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){\n  WhereTerm *pTerm;\n  int idx;\n  testcase( wtFlags & TERM_VIRTUAL );  /* EV: R-00211-15100 */\n  if( pWC->nTerm>=pWC->nSlot ){\n    WhereTerm *pOld = pWC->a;\n    sqlite3 *db = pWC->pParse->db;\n    pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 );\n    if( pWC->a==0 ){\n      if( wtFlags & TERM_DYNAMIC ){\n        sqlite3ExprDelete(db, p);\n      }\n      pWC->a = pOld;\n      return 0;\n    }\n    memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);\n    if( pOld!=pWC->aStatic ){\n      sqlite3DbFree(db, pOld);\n    }\n    pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);\n  }\n  pTerm = &pWC->a[idx = pWC->nTerm++];\n  pTerm->pExpr = sqlite3ExprSkipCollate(p);\n  pTerm->wtFlags = wtFlags;\n  pTerm->pWC = pWC;\n  pTerm->iParent = -1;\n  return idx;\n}\n\n/*\n** This routine identifies subexpressions in the WHERE clause where\n** each subexpression is separated by the AND operator or some other\n** operator specified in the op parameter.  The WhereClause structure\n** is filled with pointers to subexpressions.  For example:\n**\n**    WHERE  a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)\n**           \\________/     \\_______________/     \\________________/\n**            slot[0]            slot[1]               slot[2]\n**\n** The original WHERE clause in pExpr is unaltered.  All this routine\n** does is make slot[] entries point to substructure within pExpr.\n**\n** In the previous sentence and in the diagram, \"slot[]\" refers to\n** the WhereClause.a[] array.  The slot[] array grows as needed to contain\n** all terms of the WHERE clause.\n*/\nstatic void whereSplit(WhereClause *pWC, Expr *pExpr, int op){\n  pWC->op = (u8)op;\n  if( pExpr==0 ) return;\n  if( pExpr->op!=op ){\n    whereClauseInsert(pWC, pExpr, 0);\n  }else{\n    whereSplit(pWC, pExpr->pLeft, op);\n    whereSplit(pWC, pExpr->pRight, op);\n  }\n}\n\n/*\n** Initialize an expression mask set (a WhereMaskSet object)\n*/\n#define initMaskSet(P)  memset(P, 0, sizeof(*P))\n\n/*\n** Return the bitmask for the given cursor number.  Return 0 if\n** iCursor is not in the set.\n*/\nstatic Bitmask getMask(WhereMaskSet *pMaskSet, int iCursor){\n  int i;\n  assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );\n  for(i=0; i<pMaskSet->n; i++){\n    if( pMaskSet->ix[i]==iCursor ){\n      return ((Bitmask)1)<<i;\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a new mask for cursor iCursor.\n**\n** There is one cursor per table in the FROM clause.  The number of\n** tables in the FROM clause is limited by a test early in the\n** sqlite3WhereBegin() routine.  So we know that the pMaskSet->ix[]\n** array will never overflow.\n*/\nstatic void createMask(WhereMaskSet *pMaskSet, int iCursor){\n  assert( pMaskSet->n < ArraySize(pMaskSet->ix) );\n  pMaskSet->ix[pMaskSet->n++] = iCursor;\n}\n\n/*\n** This routine walks (recursively) an expression tree and generates\n** a bitmask indicating which tables are used in that expression\n** tree.\n**\n** In order for this routine to work, the calling function must have\n** previously invoked sqlite3ResolveExprNames() on the expression.  See\n** the header comment on that routine for additional information.\n** The sqlite3ResolveExprNames() routines looks for column names and\n** sets their opcodes to TK_COLUMN and their Expr.iTable fields to\n** the VDBE cursor number of the table.  This routine just has to\n** translate the cursor numbers into bitmask values and OR all\n** the bitmasks together.\n*/\nstatic Bitmask exprListTableUsage(WhereMaskSet*, ExprList*);\nstatic Bitmask exprSelectTableUsage(WhereMaskSet*, Select*);\nstatic Bitmask exprTableUsage(WhereMaskSet *pMaskSet, Expr *p){\n  Bitmask mask = 0;\n  if( p==0 ) return 0;\n  if( p->op==TK_COLUMN ){\n    mask = getMask(pMaskSet, p->iTable);\n    return mask;\n  }\n  mask = exprTableUsage(pMaskSet, p->pRight);\n  mask |= exprTableUsage(pMaskSet, p->pLeft);\n  if( ExprHasProperty(p, EP_xIsSelect) ){\n    mask |= exprSelectTableUsage(pMaskSet, p->x.pSelect);\n  }else{\n    mask |= exprListTableUsage(pMaskSet, p->x.pList);\n  }\n  return mask;\n}\nstatic Bitmask exprListTableUsage(WhereMaskSet *pMaskSet, ExprList *pList){\n  int i;\n  Bitmask mask = 0;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      mask |= exprTableUsage(pMaskSet, pList->a[i].pExpr);\n    }\n  }\n  return mask;\n}\nstatic Bitmask exprSelectTableUsage(WhereMaskSet *pMaskSet, Select *pS){\n  Bitmask mask = 0;\n  while( pS ){\n    SrcList *pSrc = pS->pSrc;\n    mask |= exprListTableUsage(pMaskSet, pS->pEList);\n    mask |= exprListTableUsage(pMaskSet, pS->pGroupBy);\n    mask |= exprListTableUsage(pMaskSet, pS->pOrderBy);\n    mask |= exprTableUsage(pMaskSet, pS->pWhere);\n    mask |= exprTableUsage(pMaskSet, pS->pHaving);\n    if( ALWAYS(pSrc!=0) ){\n      int i;\n      for(i=0; i<pSrc->nSrc; i++){\n        mask |= exprSelectTableUsage(pMaskSet, pSrc->a[i].pSelect);\n        mask |= exprTableUsage(pMaskSet, pSrc->a[i].pOn);\n      }\n    }\n    pS = pS->pPrior;\n  }\n  return mask;\n}\n\n/*\n** Return TRUE if the given operator is one of the operators that is\n** allowed for an indexable WHERE clause term.  The allowed operators are\n** \"=\", \"<\", \">\", \"<=\", \">=\", and \"IN\".\n**\n** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be\n** of one of the following forms: column = expression column > expression\n** column >= expression column < expression column <= expression\n** expression = column expression > column expression >= column\n** expression < column expression <= column column IN\n** (expression-list) column IN (subquery) column IS NULL\n*/\nstatic int allowedOp(int op){\n  assert( TK_GT>TK_EQ && TK_GT<TK_GE );\n  assert( TK_LT>TK_EQ && TK_LT<TK_GE );\n  assert( TK_LE>TK_EQ && TK_LE<TK_GE );\n  assert( TK_GE==TK_EQ+4 );\n  return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL;\n}\n\n/*\n** Swap two objects of type TYPE.\n*/\n#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n\n/*\n** Commute a comparison operator.  Expressions of the form \"X op Y\"\n** are converted into \"Y op X\".\n**\n** If left/right precedence rules come into play when determining the\n** collating\n** side of the comparison, it remains associated with the same side after\n** the commutation. So \"Y collate NOCASE op X\" becomes \n** \"X op Y\". This is because any collation sequence on\n** the left hand side of a comparison overrides any collation sequence \n** attached to the right. For the same reason the EP_Collate flag\n** is not commuted.\n*/\nstatic void exprCommute(Parse *pParse, Expr *pExpr){\n  u16 expRight = (pExpr->pRight->flags & EP_Collate);\n  u16 expLeft = (pExpr->pLeft->flags & EP_Collate);\n  assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );\n  if( expRight==expLeft ){\n    /* Either X and Y both have COLLATE operator or neither do */\n    if( expRight ){\n      /* Both X and Y have COLLATE operators.  Make sure X is always\n      ** used by clearing the EP_Collate flag from Y. */\n      pExpr->pRight->flags &= ~EP_Collate;\n    }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){\n      /* Neither X nor Y have COLLATE operators, but X has a non-default\n      ** collating sequence.  So add the EP_Collate marker on X to cause\n      ** it to be searched first. */\n      pExpr->pLeft->flags |= EP_Collate;\n    }\n  }\n  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);\n  if( pExpr->op>=TK_GT ){\n    assert( TK_LT==TK_GT+2 );\n    assert( TK_GE==TK_LE+2 );\n    assert( TK_GT>TK_EQ );\n    assert( TK_GT<TK_LE );\n    assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );\n    pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;\n  }\n}\n\n/*\n** Translate from TK_xx operator to WO_xx bitmask.\n*/\nstatic u16 operatorMask(int op){\n  u16 c;\n  assert( allowedOp(op) );\n  if( op==TK_IN ){\n    c = WO_IN;\n  }else if( op==TK_ISNULL ){\n    c = WO_ISNULL;\n  }else{\n    assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff );\n    c = (u16)(WO_EQ<<(op-TK_EQ));\n  }\n  assert( op!=TK_ISNULL || c==WO_ISNULL );\n  assert( op!=TK_IN || c==WO_IN );\n  assert( op!=TK_EQ || c==WO_EQ );\n  assert( op!=TK_LT || c==WO_LT );\n  assert( op!=TK_LE || c==WO_LE );\n  assert( op!=TK_GT || c==WO_GT );\n  assert( op!=TK_GE || c==WO_GE );\n  return c;\n}\n\n/*\n** Search for a term in the WHERE clause that is of the form \"X <op> <expr>\"\n** where X is a reference to the iColumn of table iCur and <op> is one of\n** the WO_xx operator codes specified by the op parameter.\n** Return a pointer to the term.  Return 0 if not found.\n**\n** The term returned might by Y=<expr> if there is another constraint in\n** the WHERE clause that specifies that X=Y.  Any such constraints will be\n** identified by the WO_EQUIV bit in the pTerm->eOperator field.  The\n** aEquiv[] array holds X and all its equivalents, with each SQL variable\n** taking up two slots in aEquiv[].  The first slot is for the cursor number\n** and the second is for the column number.  There are 22 slots in aEquiv[]\n** so that means we can look for X plus up to 10 other equivalent values.\n** Hence a search for X will return <expr> if X=A1 and A1=A2 and A2=A3\n** and ... and A9=A10 and A10=<expr>.\n**\n** If there are multiple terms in the WHERE clause of the form \"X <op> <expr>\"\n** then try for the one with no dependencies on <expr> - in other words where\n** <expr> is a constant expression of some kind.  Only return entries of\n** the form \"X <op> Y\" where Y is a column in another table if no terms of\n** the form \"X <op> <const-expr>\" exist.   If no terms with a constant RHS\n** exist, try to return a term that does not use WO_EQUIV.\n*/\nstatic WhereTerm *findTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n){\n  WhereTerm *pTerm;            /* Term being examined as possible result */\n  WhereTerm *pResult = 0;      /* The answer to return */\n  WhereClause *pWCOrig = pWC;  /* Original pWC value */\n  int j, k;                    /* Loop counters */\n  Expr *pX;                /* Pointer to an expression */\n  Parse *pParse;           /* Parsing context */\n  int iOrigCol = iColumn;  /* Original value of iColumn */\n  int nEquiv = 2;          /* Number of entires in aEquiv[] */\n  int iEquiv = 2;          /* Number of entries of aEquiv[] processed so far */\n  int aEquiv[22];          /* iCur,iColumn and up to 10 other equivalents */\n\n  assert( iCur>=0 );\n  aEquiv[0] = iCur;\n  aEquiv[1] = iColumn;\n  for(;;){\n    for(pWC=pWCOrig; pWC; pWC=pWC->pOuter){\n      for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){\n        if( pTerm->leftCursor==iCur\n          && pTerm->u.leftColumn==iColumn\n        ){\n          if( (pTerm->prereqRight & notReady)==0\n           && (pTerm->eOperator & op & WO_ALL)!=0\n          ){\n            if( iOrigCol>=0 && pIdx && (pTerm->eOperator & WO_ISNULL)==0 ){\n              CollSeq *pColl;\n              char idxaff;\n      \n              pX = pTerm->pExpr;\n              pParse = pWC->pParse;\n              idxaff = pIdx->pTable->aCol[iOrigCol].affinity;\n              if( !sqlite3IndexAffinityOk(pX, idxaff) ){\n                continue;\n              }\n      \n              /* Figure out the collation sequence required from an index for\n              ** it to be useful for optimising expression pX. Store this\n              ** value in variable pColl.\n              */\n              assert(pX->pLeft);\n              pColl = sqlite3BinaryCompareCollSeq(pParse,pX->pLeft,pX->pRight);\n              if( pColl==0 ) pColl = pParse->db->pDfltColl;\n      \n              for(j=0; pIdx->aiColumn[j]!=iOrigCol; j++){\n                if( NEVER(j>=pIdx->nColumn) ) return 0;\n              }\n              if( sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ){\n                continue;\n              }\n            }\n            if( pTerm->prereqRight==0 && (pTerm->eOperator&WO_EQ)!=0 ){\n              pResult = pTerm;\n              goto findTerm_success;\n            }else if( pResult==0 ){\n              pResult = pTerm;\n            }\n          }\n          if( (pTerm->eOperator & WO_EQUIV)!=0\n           && nEquiv<ArraySize(aEquiv)\n          ){\n            pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight);\n            assert( pX->op==TK_COLUMN );\n            for(j=0; j<nEquiv; j+=2){\n              if( aEquiv[j]==pX->iTable && aEquiv[j+1]==pX->iColumn ) break;\n            }\n            if( j==nEquiv ){\n              aEquiv[j] = pX->iTable;\n              aEquiv[j+1] = pX->iColumn;\n              nEquiv += 2;\n            }\n          }\n        }\n      }\n    }\n    if( iEquiv>=nEquiv ) break;\n    iCur = aEquiv[iEquiv++];\n    iColumn = aEquiv[iEquiv++];\n  }\nfindTerm_success:\n  return pResult;\n}\n\n/* Forward reference */\nstatic void exprAnalyze(SrcList*, WhereClause*, int);\n\n/*\n** Call exprAnalyze on all terms in a WHERE clause.  \n**\n**\n*/\nstatic void exprAnalyzeAll(\n  SrcList *pTabList,       /* the FROM clause */\n  WhereClause *pWC         /* the WHERE clause to be analyzed */\n){\n  int i;\n  for(i=pWC->nTerm-1; i>=0; i--){\n    exprAnalyze(pTabList, pWC, i);\n  }\n}\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n/*\n** Check to see if the given expression is a LIKE or GLOB operator that\n** can be optimized using inequality constraints.  Return TRUE if it is\n** so and false if not.\n**\n** In order for the operator to be optimizible, the RHS must be a string\n** literal that does not begin with a wildcard.  \n*/\nstatic int isLikeOrGlob(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* Test this expression */\n  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */\n  int *pisComplete, /* True if the only wildcard is % in the last character */\n  int *pnoCase      /* True if uppercase is equivalent to lowercase */\n){\n  const char *z = 0;         /* String on RHS of LIKE operator */\n  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */\n  ExprList *pList;           /* List of operands to the LIKE operator */\n  int c;                     /* One character in z[] */\n  int cnt;                   /* Number of non-wildcard prefix characters */\n  char wc[3];                /* Wildcard characters */\n  sqlite3 *db = pParse->db;  /* Database connection */\n  sqlite3_value *pVal = 0;\n  int op;                    /* Opcode of pRight */\n\n  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){\n    return 0;\n  }\n#ifdef SQLITE_EBCDIC\n  if( *pnoCase ) return 0;\n#endif\n  pList = pExpr->x.pList;\n  pLeft = pList->a[1].pExpr;\n  if( pLeft->op!=TK_COLUMN \n   || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT \n   || IsVirtual(pLeft->pTab)\n  ){\n    /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must\n    ** be the name of an indexed column with TEXT affinity. */\n    return 0;\n  }\n  assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */\n\n  pRight = pList->a[0].pExpr;\n  op = pRight->op;\n  if( op==TK_REGISTER ){\n    op = pRight->op2;\n  }\n  if( op==TK_VARIABLE ){\n    Vdbe *pReprepare = pParse->pReprepare;\n    int iCol = pRight->iColumn;\n    pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE);\n    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){\n      z = (char *)sqlite3_value_text(pVal);\n    }\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);\n    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );\n  }else if( op==TK_STRING ){\n    z = pRight->u.zToken;\n  }\n  if( z ){\n    cnt = 0;\n    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){\n      cnt++;\n    }\n    if( cnt!=0 && 255!=(u8)z[cnt-1] ){\n      Expr *pPrefix;\n      *pisComplete = c==wc[0] && z[cnt+1]==0;\n      pPrefix = sqlite3Expr(db, TK_STRING, z);\n      if( pPrefix ) pPrefix->u.zToken[cnt] = 0;\n      *ppPrefix = pPrefix;\n      if( op==TK_VARIABLE ){\n        Vdbe *v = pParse->pVdbe;\n        sqlite3VdbeSetVarmask(v, pRight->iColumn);\n        if( *pisComplete && pRight->u.zToken[1] ){\n          /* If the rhs of the LIKE expression is a variable, and the current\n          ** value of the variable means there is no need to invoke the LIKE\n          ** function, then no OP_Variable will be added to the program.\n          ** This causes problems for the sqlite3_bind_parameter_name()\n          ** API. To workaround them, add a dummy OP_Variable here.\n          */ \n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3ExprCodeTarget(pParse, pRight, r1);\n          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);\n          sqlite3ReleaseTempReg(pParse, r1);\n        }\n      }\n    }else{\n      z = 0;\n    }\n  }\n\n  sqlite3ValueFree(pVal);\n  return (z!=0);\n}\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Check to see if the given expression is of the form\n**\n**         column MATCH expr\n**\n** If it is then return TRUE.  If not, return FALSE.\n*/\nstatic int isMatchOfColumn(\n  Expr *pExpr      /* Test this expression */\n){\n  ExprList *pList;\n\n  if( pExpr->op!=TK_FUNCTION ){\n    return 0;\n  }\n  if( sqlite3StrICmp(pExpr->u.zToken,\"match\")!=0 ){\n    return 0;\n  }\n  pList = pExpr->x.pList;\n  if( pList->nExpr!=2 ){\n    return 0;\n  }\n  if( pList->a[1].pExpr->op != TK_COLUMN ){\n    return 0;\n  }\n  return 1;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** If the pBase expression originated in the ON or USING clause of\n** a join, then transfer the appropriate markings over to derived.\n*/\nstatic void transferJoinMarkings(Expr *pDerived, Expr *pBase){\n  pDerived->flags |= pBase->flags & EP_FromJoin;\n  pDerived->iRightJoinTable = pBase->iRightJoinTable;\n}\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Analyze a term that consists of two or more OR-connected\n** subterms.  So in:\n**\n**     ... WHERE  (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13)\n**                          ^^^^^^^^^^^^^^^^^^^^\n**\n** This routine analyzes terms such as the middle term in the above example.\n** A WhereOrTerm object is computed and attached to the term under\n** analysis, regardless of the outcome of the analysis.  Hence:\n**\n**     WhereTerm.wtFlags   |=  TERM_ORINFO\n**     WhereTerm.u.pOrInfo  =  a dynamically allocated WhereOrTerm object\n**\n** The term being analyzed must have two or more of OR-connected subterms.\n** A single subterm might be a set of AND-connected sub-subterms.\n** Examples of terms under analysis:\n**\n**     (A)     t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5\n**     (B)     x=expr1 OR expr2=x OR x=expr3\n**     (C)     t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)\n**     (D)     x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')\n**     (E)     (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)\n**\n** CASE 1:\n**\n** If all subterms are of the form T.C=expr for some single column of C and\n** a single table T (as shown in example B above) then create a new virtual\n** term that is an equivalent IN expression.  In other words, if the term\n** being analyzed is:\n**\n**      x = expr1  OR  expr2 = x  OR  x = expr3\n**\n** then create a new virtual term like this:\n**\n**      x IN (expr1,expr2,expr3)\n**\n** CASE 2:\n**\n** If all subterms are indexable by a single table T, then set\n**\n**     WhereTerm.eOperator              =  WO_OR\n**     WhereTerm.u.pOrInfo->indexable  |=  the cursor number for table T\n**\n** A subterm is \"indexable\" if it is of the form\n** \"T.C <op> <expr>\" where C is any column of table T and \n** <op> is one of \"=\", \"<\", \"<=\", \">\", \">=\", \"IS NULL\", or \"IN\".\n** A subterm is also indexable if it is an AND of two or more\n** subsubterms at least one of which is indexable.  Indexable AND \n** subterms have their eOperator set to WO_AND and they have\n** u.pAndInfo set to a dynamically allocated WhereAndTerm object.\n**\n** From another point of view, \"indexable\" means that the subterm could\n** potentially be used with an index if an appropriate index exists.\n** This analysis does not consider whether or not the index exists; that\n** is something the bestIndex() routine will determine.  This analysis\n** only looks at whether subterms appropriate for indexing exist.\n**\n** All examples A through E above all satisfy case 2.  But if a term\n** also statisfies case 1 (such as B) we know that the optimizer will\n** always prefer case 1, so in that case we pretend that case 2 is not\n** satisfied.\n**\n** It might be the case that multiple tables are indexable.  For example,\n** (E) above is indexable on tables P, Q, and R.\n**\n** Terms that satisfy case 2 are candidates for lookup by using\n** separate indices to find rowids for each subterm and composing\n** the union of all rowids using a RowSet object.  This is similar\n** to \"bitmap indices\" in other database engines.\n**\n** OTHERWISE:\n**\n** If neither case 1 nor case 2 apply, then leave the eOperator set to\n** zero.  This term is not useful for search.\n*/\nstatic void exprAnalyzeOrTerm(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the complete WHERE clause */\n  int idxTerm               /* Index of the OR-term to be analyzed */\n){\n  Parse *pParse = pWC->pParse;            /* Parser context */\n  sqlite3 *db = pParse->db;               /* Database connection */\n  WhereTerm *pTerm = &pWC->a[idxTerm];    /* The term to be analyzed */\n  Expr *pExpr = pTerm->pExpr;             /* The expression of the term */\n  WhereMaskSet *pMaskSet = pWC->pMaskSet; /* Table use masks */\n  int i;                                  /* Loop counters */\n  WhereClause *pOrWc;       /* Breakup of pTerm into subterms */\n  WhereTerm *pOrTerm;       /* A Sub-term within the pOrWc */\n  WhereOrInfo *pOrInfo;     /* Additional information associated with pTerm */\n  Bitmask chngToIN;         /* Tables that might satisfy case 1 */\n  Bitmask indexable;        /* Tables that are indexable, satisfying case 2 */\n\n  /*\n  ** Break the OR clause into its separate subterms.  The subterms are\n  ** stored in a WhereClause structure containing within the WhereOrInfo\n  ** object that is attached to the original OR clause term.\n  */\n  assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );\n  assert( pExpr->op==TK_OR );\n  pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));\n  if( pOrInfo==0 ) return;\n  pTerm->wtFlags |= TERM_ORINFO;\n  pOrWc = &pOrInfo->wc;\n  whereClauseInit(pOrWc, pWC->pParse, pMaskSet, pWC->wctrlFlags);\n  whereSplit(pOrWc, pExpr, TK_OR);\n  exprAnalyzeAll(pSrc, pOrWc);\n  if( db->mallocFailed ) return;\n  assert( pOrWc->nTerm>=2 );\n\n  /*\n  ** Compute the set of tables that might satisfy cases 1 or 2.\n  */\n  indexable = ~(Bitmask)0;\n  chngToIN = ~(Bitmask)0;\n  for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0 && indexable; i--, pOrTerm++){\n    if( (pOrTerm->eOperator & WO_SINGLE)==0 ){\n      WhereAndInfo *pAndInfo;\n      assert( (pOrTerm->wtFlags & (TERM_ANDINFO|TERM_ORINFO))==0 );\n      chngToIN = 0;\n      pAndInfo = sqlite3DbMallocRaw(db, sizeof(*pAndInfo));\n      if( pAndInfo ){\n        WhereClause *pAndWC;\n        WhereTerm *pAndTerm;\n        int j;\n        Bitmask b = 0;\n        pOrTerm->u.pAndInfo = pAndInfo;\n        pOrTerm->wtFlags |= TERM_ANDINFO;\n        pOrTerm->eOperator = WO_AND;\n        pAndWC = &pAndInfo->wc;\n        whereClauseInit(pAndWC, pWC->pParse, pMaskSet, pWC->wctrlFlags);\n        whereSplit(pAndWC, pOrTerm->pExpr, TK_AND);\n        exprAnalyzeAll(pSrc, pAndWC);\n        pAndWC->pOuter = pWC;\n        testcase( db->mallocFailed );\n        if( !db->mallocFailed ){\n          for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){\n            assert( pAndTerm->pExpr );\n            if( allowedOp(pAndTerm->pExpr->op) ){\n              b |= getMask(pMaskSet, pAndTerm->leftCursor);\n            }\n          }\n        }\n        indexable &= b;\n      }\n    }else if( pOrTerm->wtFlags & TERM_COPIED ){\n      /* Skip this term for now.  We revisit it when we process the\n      ** corresponding TERM_VIRTUAL term */\n    }else{\n      Bitmask b;\n      b = getMask(pMaskSet, pOrTerm->leftCursor);\n      if( pOrTerm->wtFlags & TERM_VIRTUAL ){\n        WhereTerm *pOther = &pOrWc->a[pOrTerm->iParent];\n        b |= getMask(pMaskSet, pOther->leftCursor);\n      }\n      indexable &= b;\n      if( (pOrTerm->eOperator & WO_EQ)==0 ){\n        chngToIN = 0;\n      }else{\n        chngToIN &= b;\n      }\n    }\n  }\n\n  /*\n  ** Record the set of tables that satisfy case 2.  The set might be\n  ** empty.\n  */\n  pOrInfo->indexable = indexable;\n  pTerm->eOperator = indexable==0 ? 0 : WO_OR;\n\n  /*\n  ** chngToIN holds a set of tables that *might* satisfy case 1.  But\n  ** we have to do some additional checking to see if case 1 really\n  ** is satisfied.\n  **\n  ** chngToIN will hold either 0, 1, or 2 bits.  The 0-bit case means\n  ** that there is no possibility of transforming the OR clause into an\n  ** IN operator because one or more terms in the OR clause contain\n  ** something other than == on a column in the single table.  The 1-bit\n  ** case means that every term of the OR clause is of the form\n  ** \"table.column=expr\" for some single table.  The one bit that is set\n  ** will correspond to the common table.  We still need to check to make\n  ** sure the same column is used on all terms.  The 2-bit case is when\n  ** the all terms are of the form \"table1.column=table2.column\".  It\n  ** might be possible to form an IN operator with either table1.column\n  ** or table2.column as the LHS if either is common to every term of\n  ** the OR clause.\n  **\n  ** Note that terms of the form \"table.column1=table.column2\" (the\n  ** same table on both sizes of the ==) cannot be optimized.\n  */\n  if( chngToIN ){\n    int okToChngToIN = 0;     /* True if the conversion to IN is valid */\n    int iColumn = -1;         /* Column index on lhs of IN operator */\n    int iCursor = -1;         /* Table cursor common to all terms */\n    int j = 0;                /* Loop counter */\n\n    /* Search for a table and column that appears on one side or the\n    ** other of the == operator in every subterm.  That table and column\n    ** will be recorded in iCursor and iColumn.  There might not be any\n    ** such table and column.  Set okToChngToIN if an appropriate table\n    ** and column is found but leave okToChngToIN false if not found.\n    */\n    for(j=0; j<2 && !okToChngToIN; j++){\n      pOrTerm = pOrWc->a;\n      for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        pOrTerm->wtFlags &= ~TERM_OR_OK;\n        if( pOrTerm->leftCursor==iCursor ){\n          /* This is the 2-bit case and we are on the second iteration and\n          ** current term is from the first iteration.  So skip this term. */\n          assert( j==1 );\n          continue;\n        }\n        if( (chngToIN & getMask(pMaskSet, pOrTerm->leftCursor))==0 ){\n          /* This term must be of the form t1.a==t2.b where t2 is in the\n          ** chngToIN set but t1 is not.  This term will be either preceeded\n          ** or follwed by an inverted copy (t2.b==t1.a).  Skip this term \n          ** and use its inversion. */\n          testcase( pOrTerm->wtFlags & TERM_COPIED );\n          testcase( pOrTerm->wtFlags & TERM_VIRTUAL );\n          assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );\n          continue;\n        }\n        iColumn = pOrTerm->u.leftColumn;\n        iCursor = pOrTerm->leftCursor;\n        break;\n      }\n      if( i<0 ){\n        /* No candidate table+column was found.  This can only occur\n        ** on the second iteration */\n        assert( j==1 );\n        assert( IsPowerOfTwo(chngToIN) );\n        assert( chngToIN==getMask(pMaskSet, iCursor) );\n        break;\n      }\n      testcase( j==1 );\n\n      /* We have found a candidate table and column.  Check to see if that\n      ** table and column is common to every term in the OR clause */\n      okToChngToIN = 1;\n      for(; i>=0 && okToChngToIN; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        if( pOrTerm->leftCursor!=iCursor ){\n          pOrTerm->wtFlags &= ~TERM_OR_OK;\n        }else if( pOrTerm->u.leftColumn!=iColumn ){\n          okToChngToIN = 0;\n        }else{\n          int affLeft, affRight;\n          /* If the right-hand side is also a column, then the affinities\n          ** of both right and left sides must be such that no type\n          ** conversions are required on the right.  (Ticket #2249)\n          */\n          affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);\n          affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);\n          if( affRight!=0 && affRight!=affLeft ){\n            okToChngToIN = 0;\n          }else{\n            pOrTerm->wtFlags |= TERM_OR_OK;\n          }\n        }\n      }\n    }\n\n    /* At this point, okToChngToIN is true if original pTerm satisfies\n    ** case 1.  In that case, construct a new virtual term that is \n    ** pTerm converted into an IN operator.\n    **\n    ** EV: R-00211-15100\n    */\n    if( okToChngToIN ){\n      Expr *pDup;            /* A transient duplicate expression */\n      ExprList *pList = 0;   /* The RHS of the IN operator */\n      Expr *pLeft = 0;       /* The LHS of the IN operator */\n      Expr *pNew;            /* The complete IN operator */\n\n      for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){\n        if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;\n        assert( pOrTerm->eOperator & WO_EQ );\n        assert( pOrTerm->leftCursor==iCursor );\n        assert( pOrTerm->u.leftColumn==iColumn );\n        pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);\n        pList = sqlite3ExprListAppend(pWC->pParse, pList, pDup);\n        pLeft = pOrTerm->pExpr->pLeft;\n      }\n      assert( pLeft!=0 );\n      pDup = sqlite3ExprDup(db, pLeft, 0);\n      pNew = sqlite3PExpr(pParse, TK_IN, pDup, 0, 0);\n      if( pNew ){\n        int idxNew;\n        transferJoinMarkings(pNew, pExpr);\n        assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n        pNew->x.pList = pList;\n        idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        exprAnalyze(pSrc, pWC, idxNew);\n        pTerm = &pWC->a[idxTerm];\n        pWC->a[idxNew].iParent = idxTerm;\n        pTerm->nChild = 1;\n      }else{\n        sqlite3ExprListDelete(db, pList);\n      }\n      pTerm->eOperator = WO_NOOP;  /* case 1 trumps case 2 */\n    }\n  }\n}\n#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */\n\n/*\n** The input to this routine is an WhereTerm structure with only the\n** \"pExpr\" field filled in.  The job of this routine is to analyze the\n** subexpression and populate all the other fields of the WhereTerm\n** structure.\n**\n** If the expression is of the form \"<expr> <op> X\" it gets commuted\n** to the standard form of \"X <op> <expr>\".\n**\n** If the expression is of the form \"X <op> Y\" where both X and Y are\n** columns, then the original expression is unchanged and a new virtual\n** term of the form \"Y <op> X\" is added to the WHERE clause and\n** analyzed separately.  The original term is marked with TERM_COPIED\n** and the new term is marked with TERM_DYNAMIC (because it's pExpr\n** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it\n** is a commuted copy of a prior term.)  The original term has nChild=1\n** and the copy has idxParent set to the index of the original term.\n*/\nstatic void exprAnalyze(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the WHERE clause */\n  int idxTerm               /* Index of the term to be analyzed */\n){\n  WhereTerm *pTerm;                /* The term to be analyzed */\n  WhereMaskSet *pMaskSet;          /* Set of table index masks */\n  Expr *pExpr;                     /* The expression to be analyzed */\n  Bitmask prereqLeft;              /* Prerequesites of the pExpr->pLeft */\n  Bitmask prereqAll;               /* Prerequesites of pExpr */\n  Bitmask extraRight = 0;          /* Extra dependencies on LEFT JOIN */\n  Expr *pStr1 = 0;                 /* RHS of LIKE/GLOB operator */\n  int isComplete = 0;              /* RHS of LIKE/GLOB ends with wildcard */\n  int noCase = 0;                  /* LIKE/GLOB distinguishes case */\n  int op;                          /* Top-level operator.  pExpr->op */\n  Parse *pParse = pWC->pParse;     /* Parsing context */\n  sqlite3 *db = pParse->db;        /* Database connection */\n\n  if( db->mallocFailed ){\n    return;\n  }\n  pTerm = &pWC->a[idxTerm];\n  pMaskSet = pWC->pMaskSet;\n  pExpr = pTerm->pExpr;\n  assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );\n  prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft);\n  op = pExpr->op;\n  if( op==TK_IN ){\n    assert( pExpr->pRight==0 );\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      pTerm->prereqRight = exprSelectTableUsage(pMaskSet, pExpr->x.pSelect);\n    }else{\n      pTerm->prereqRight = exprListTableUsage(pMaskSet, pExpr->x.pList);\n    }\n  }else if( op==TK_ISNULL ){\n    pTerm->prereqRight = 0;\n  }else{\n    pTerm->prereqRight = exprTableUsage(pMaskSet, pExpr->pRight);\n  }\n  prereqAll = exprTableUsage(pMaskSet, pExpr);\n  if( ExprHasProperty(pExpr, EP_FromJoin) ){\n    Bitmask x = getMask(pMaskSet, pExpr->iRightJoinTable);\n    prereqAll |= x;\n    extraRight = x-1;  /* ON clause terms may not be used with an index\n                       ** on left table of a LEFT JOIN.  Ticket #3015 */\n  }\n  pTerm->prereqAll = prereqAll;\n  pTerm->leftCursor = -1;\n  pTerm->iParent = -1;\n  pTerm->eOperator = 0;\n  if( allowedOp(op) ){\n    Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);\n    Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);\n    u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;\n    if( pLeft->op==TK_COLUMN ){\n      pTerm->leftCursor = pLeft->iTable;\n      pTerm->u.leftColumn = pLeft->iColumn;\n      pTerm->eOperator = operatorMask(op) & opMask;\n    }\n    if( pRight && pRight->op==TK_COLUMN ){\n      WhereTerm *pNew;\n      Expr *pDup;\n      u16 eExtraOp = 0;        /* Extra bits for pNew->eOperator */\n      if( pTerm->leftCursor>=0 ){\n        int idxNew;\n        pDup = sqlite3ExprDup(db, pExpr, 0);\n        if( db->mallocFailed ){\n          sqlite3ExprDelete(db, pDup);\n          return;\n        }\n        idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);\n        if( idxNew==0 ) return;\n        pNew = &pWC->a[idxNew];\n        pNew->iParent = idxTerm;\n        pTerm = &pWC->a[idxTerm];\n        pTerm->nChild = 1;\n        pTerm->wtFlags |= TERM_COPIED;\n        if( pExpr->op==TK_EQ\n         && !ExprHasProperty(pExpr, EP_FromJoin)\n         && OptimizationEnabled(db, SQLITE_Transitive)\n        ){\n          pTerm->eOperator |= WO_EQUIV;\n          eExtraOp = WO_EQUIV;\n        }\n      }else{\n        pDup = pExpr;\n        pNew = pTerm;\n      }\n      exprCommute(pParse, pDup);\n      pLeft = sqlite3ExprSkipCollate(pDup->pLeft);\n      pNew->leftCursor = pLeft->iTable;\n      pNew->u.leftColumn = pLeft->iColumn;\n      testcase( (prereqLeft | extraRight) != prereqLeft );\n      pNew->prereqRight = prereqLeft | extraRight;\n      pNew->prereqAll = prereqAll;\n      pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;\n    }\n  }\n\n#ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  /* If a term is the BETWEEN operator, create two new virtual terms\n  ** that define the range that the BETWEEN implements.  For example:\n  **\n  **      a BETWEEN b AND c\n  **\n  ** is converted into:\n  **\n  **      (a BETWEEN b AND c) AND (a>=b) AND (a<=c)\n  **\n  ** The two new terms are added onto the end of the WhereClause object.\n  ** The new terms are \"dynamic\" and are children of the original BETWEEN\n  ** term.  That means that if the BETWEEN term is coded, the children are\n  ** skipped.  Or, if the children are satisfied by an index, the original\n  ** BETWEEN term is skipped.\n  */\n  else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){\n    ExprList *pList = pExpr->x.pList;\n    int i;\n    static const u8 ops[] = {TK_GE, TK_LE};\n    assert( pList!=0 );\n    assert( pList->nExpr==2 );\n    for(i=0; i<2; i++){\n      Expr *pNewExpr;\n      int idxNew;\n      pNewExpr = sqlite3PExpr(pParse, ops[i], \n                             sqlite3ExprDup(db, pExpr->pLeft, 0),\n                             sqlite3ExprDup(db, pList->a[i].pExpr, 0), 0);\n      idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n      testcase( idxNew==0 );\n      exprAnalyze(pSrc, pWC, idxNew);\n      pTerm = &pWC->a[idxTerm];\n      pWC->a[idxNew].iParent = idxTerm;\n    }\n    pTerm->nChild = 2;\n  }\n#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n  /* Analyze a term that is composed of two or more subterms connected by\n  ** an OR operator.\n  */\n  else if( pExpr->op==TK_OR ){\n    assert( pWC->op==TK_AND );\n    exprAnalyzeOrTerm(pSrc, pWC, idxTerm);\n    pTerm = &pWC->a[idxTerm];\n  }\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n  /* Add constraints to reduce the search space on a LIKE or GLOB\n  ** operator.\n  **\n  ** A like pattern of the form \"x LIKE 'abc%'\" is changed into constraints\n  **\n  **          x>='abc' AND x<'abd' AND x LIKE 'abc%'\n  **\n  ** The last character of the prefix \"abc\" is incremented to form the\n  ** termination condition \"abd\".\n  */\n  if( pWC->op==TK_AND \n   && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)\n  ){\n    Expr *pLeft;       /* LHS of LIKE/GLOB operator */\n    Expr *pStr2;       /* Copy of pStr1 - RHS of LIKE/GLOB operator */\n    Expr *pNewExpr1;\n    Expr *pNewExpr2;\n    int idxNew1;\n    int idxNew2;\n    Token sCollSeqName;  /* Name of collating sequence */\n\n    pLeft = pExpr->x.pList->a[1].pExpr;\n    pStr2 = sqlite3ExprDup(db, pStr1, 0);\n    if( !db->mallocFailed ){\n      u8 c, *pC;       /* Last character before the first wildcard */\n      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];\n      c = *pC;\n      if( noCase ){\n        /* The point is to increment the last character before the first\n        ** wildcard.  But if we increment '@', that will push it into the\n        ** alphabetic range where case conversions will mess up the \n        ** inequality.  To avoid this, make sure to also run the full\n        ** LIKE on all candidate expressions by clearing the isComplete flag\n        */\n        if( c=='A'-1 ) isComplete = 0;   /* EV: R-64339-08207 */\n\n\n        c = sqlite3UpperToLower[c];\n      }\n      *pC = c + 1;\n    }\n    sCollSeqName.z = noCase ? \"NOCASE\" : \"BINARY\";\n    sCollSeqName.n = 6;\n    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr1 = sqlite3PExpr(pParse, TK_GE, \n           sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),\n           pStr1, 0);\n    idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);\n    testcase( idxNew1==0 );\n    exprAnalyze(pSrc, pWC, idxNew1);\n    pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr2 = sqlite3PExpr(pParse, TK_LT,\n           sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),\n           pStr2, 0);\n    idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC);\n    testcase( idxNew2==0 );\n    exprAnalyze(pSrc, pWC, idxNew2);\n    pTerm = &pWC->a[idxTerm];\n    if( isComplete ){\n      pWC->a[idxNew1].iParent = idxTerm;\n      pWC->a[idxNew2].iParent = idxTerm;\n      pTerm->nChild = 2;\n    }\n  }\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Add a WO_MATCH auxiliary term to the constraint set if the\n  ** current expression is of the form:  column MATCH expr.\n  ** This information is used by the xBestIndex methods of\n  ** virtual tables.  The native query optimizer does not attempt\n  ** to do anything with MATCH functions.\n  */\n  if( isMatchOfColumn(pExpr) ){\n    int idxNew;\n    Expr *pRight, *pLeft;\n    WhereTerm *pNewTerm;\n    Bitmask prereqColumn, prereqExpr;\n\n    pRight = pExpr->x.pList->a[0].pExpr;\n    pLeft = pExpr->x.pList->a[1].pExpr;\n    prereqExpr = exprTableUsage(pMaskSet, pRight);\n    prereqColumn = exprTableUsage(pMaskSet, pLeft);\n    if( (prereqExpr & prereqColumn)==0 ){\n      Expr *pNewExpr;\n      pNewExpr = sqlite3PExpr(pParse, TK_MATCH, \n                              0, sqlite3ExprDup(db, pRight, 0), 0);\n      idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n      testcase( idxNew==0 );\n      pNewTerm = &pWC->a[idxNew];\n      pNewTerm->prereqRight = prereqExpr;\n      pNewTerm->leftCursor = pLeft->iTable;\n      pNewTerm->u.leftColumn = pLeft->iColumn;\n      pNewTerm->eOperator = WO_MATCH;\n      pNewTerm->iParent = idxTerm;\n      pTerm = &pWC->a[idxTerm];\n      pTerm->nChild = 1;\n      pTerm->wtFlags |= TERM_COPIED;\n      pNewTerm->prereqAll = pTerm->prereqAll;\n    }\n  }\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef SQLITE_ENABLE_STAT3\n  /* When sqlite_stat3 histogram data is available an operator of the\n  ** form \"x IS NOT NULL\" can sometimes be evaluated more efficiently\n  ** as \"x>NULL\" if x is not an INTEGER PRIMARY KEY.  So construct a\n  ** virtual term of that form.\n  **\n  ** Note that the virtual term must be tagged with TERM_VNULL.  This\n  ** TERM_VNULL tag will suppress the not-null check at the beginning\n  ** of the loop.  Without the TERM_VNULL flag, the not-null check at\n  ** the start of the loop will prevent any results from being returned.\n  */\n  if( pExpr->op==TK_NOTNULL\n   && pExpr->pLeft->op==TK_COLUMN\n   && pExpr->pLeft->iColumn>=0\n  ){\n    Expr *pNewExpr;\n    Expr *pLeft = pExpr->pLeft;\n    int idxNew;\n    WhereTerm *pNewTerm;\n\n    pNewExpr = sqlite3PExpr(pParse, TK_GT,\n                            sqlite3ExprDup(db, pLeft, 0),\n                            sqlite3PExpr(pParse, TK_NULL, 0, 0, 0), 0);\n\n    idxNew = whereClauseInsert(pWC, pNewExpr,\n                              TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);\n    if( idxNew ){\n      pNewTerm = &pWC->a[idxNew];\n      pNewTerm->prereqRight = 0;\n      pNewTerm->leftCursor = pLeft->iTable;\n      pNewTerm->u.leftColumn = pLeft->iColumn;\n      pNewTerm->eOperator = WO_GT;\n      pNewTerm->iParent = idxTerm;\n      pTerm = &pWC->a[idxTerm];\n      pTerm->nChild = 1;\n      pTerm->wtFlags |= TERM_COPIED;\n      pNewTerm->prereqAll = pTerm->prereqAll;\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT */\n\n  /* Prevent ON clause terms of a LEFT JOIN from being used to drive\n  ** an index for tables to the left of the join.\n  */\n  pTerm->prereqRight |= extraRight;\n}\n\n/*\n** This function searches the expression list passed as the second argument\n** for an expression of type TK_COLUMN that refers to the same column and\n** uses the same collation sequence as the iCol'th column of index pIdx.\n** Argument iBase is the cursor number used for the table that pIdx refers\n** to.\n**\n** If such an expression is found, its index in pList->a[] is returned. If\n** no expression is found, -1 is returned.\n*/\nstatic int findIndexCol(\n  Parse *pParse,                  /* Parse context */\n  ExprList *pList,                /* Expression list to search */\n  int iBase,                      /* Cursor for table associated with pIdx */\n  Index *pIdx,                    /* Index to match column of */\n  int iCol                        /* Column of index to match */\n){\n  int i;\n  const char *zColl = pIdx->azColl[iCol];\n\n  for(i=0; i<pList->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n    if( p->op==TK_COLUMN\n     && p->iColumn==pIdx->aiColumn[iCol]\n     && p->iTable==iBase\n    ){\n      CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);\n      if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){\n        return i;\n      }\n    }\n  }\n\n  return -1;\n}\n\n/*\n** This routine determines if pIdx can be used to assist in processing a\n** DISTINCT qualifier. In other words, it tests whether or not using this\n** index for the outer loop guarantees that rows with equal values for\n** all expressions in the pDistinct list are delivered grouped together.\n**\n** For example, the query \n**\n**   SELECT DISTINCT a, b, c FROM tbl WHERE a = ?\n**\n** can benefit from any index on columns \"b\" and \"c\".\n*/\nstatic int isDistinctIndex(\n  Parse *pParse,                  /* Parsing context */\n  WhereClause *pWC,               /* The WHERE clause */\n  Index *pIdx,                    /* The index being considered */\n  int base,                       /* Cursor number for the table pIdx is on */\n  ExprList *pDistinct,            /* The DISTINCT expressions */\n  int nEqCol                      /* Number of index columns with == */\n){\n  Bitmask mask = 0;               /* Mask of unaccounted for pDistinct exprs */\n  int i;                          /* Iterator variable */\n\n  assert( pDistinct!=0 );\n  if( pIdx->zName==0 || pDistinct->nExpr>=BMS ) return 0;\n  testcase( pDistinct->nExpr==BMS-1 );\n\n  /* Loop through all the expressions in the distinct list. If any of them\n  ** are not simple column references, return early. Otherwise, test if the\n  ** WHERE clause contains a \"col=X\" clause. If it does, the expression\n  ** can be ignored. If it does not, and the column does not belong to the\n  ** same table as index pIdx, return early. Finally, if there is no\n  ** matching \"col=X\" expression and the column is on the same table as pIdx,\n  ** set the corresponding bit in variable mask.\n  */\n  for(i=0; i<pDistinct->nExpr; i++){\n    WhereTerm *pTerm;\n    Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);\n    if( p->op!=TK_COLUMN ) return 0;\n    pTerm = findTerm(pWC, p->iTable, p->iColumn, ~(Bitmask)0, WO_EQ, 0);\n    if( pTerm ){\n      Expr *pX = pTerm->pExpr;\n      CollSeq *p1 = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);\n      CollSeq *p2 = sqlite3ExprCollSeq(pParse, p);\n      if( p1==p2 ) continue;\n    }\n    if( p->iTable!=base ) return 0;\n    mask |= (((Bitmask)1) << i);\n  }\n\n  for(i=nEqCol; mask && i<pIdx->nColumn; i++){\n    int iExpr = findIndexCol(pParse, pDistinct, base, pIdx, i);\n    if( iExpr<0 ) break;\n    mask &= ~(((Bitmask)1) << iExpr);\n  }\n\n  return (mask==0);\n}\n\n\n/*\n** Return true if the DISTINCT expression-list passed as the third argument\n** is redundant. A DISTINCT list is redundant if the database contains a\n** UNIQUE index that guarantees that the result of the query will be distinct\n** anyway.\n*/\nstatic int isDistinctRedundant(\n  Parse *pParse,\n  SrcList *pTabList,\n  WhereClause *pWC,\n  ExprList *pDistinct\n){\n  Table *pTab;\n  Index *pIdx;\n  int i;                          \n  int iBase;\n\n  /* If there is more than one table or sub-select in the FROM clause of\n  ** this query, then it will not be possible to show that the DISTINCT \n  ** clause is redundant. */\n  if( pTabList->nSrc!=1 ) return 0;\n  iBase = pTabList->a[0].iCursor;\n  pTab = pTabList->a[0].pTab;\n\n  /* If any of the expressions is an IPK column on table iBase, then return \n  ** true. Note: The (p->iTable==iBase) part of this test may be false if the\n  ** current SELECT is a correlated sub-query.\n  */\n  for(i=0; i<pDistinct->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);\n    if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;\n  }\n\n  /* Loop through all indices on the table, checking each to see if it makes\n  ** the DISTINCT qualifier redundant. It does so if:\n  **\n  **   1. The index is itself UNIQUE, and\n  **\n  **   2. All of the columns in the index are either part of the pDistinct\n  **      list, or else the WHERE clause contains a term of the form \"col=X\",\n  **      where X is a constant value. The collation sequences of the\n  **      comparison and select-list expressions must match those of the index.\n  **\n  **   3. All of those index columns for which the WHERE clause does not\n  **      contain a \"col=X\" term are subject to a NOT NULL constraint.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->onError==OE_None ) continue;\n    for(i=0; i<pIdx->nColumn; i++){\n      int iCol = pIdx->aiColumn[i];\n      if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){\n        int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i);\n        if( iIdxCol<0 || pTab->aCol[pIdx->aiColumn[i]].notNull==0 ){\n          break;\n        }\n      }\n    }\n    if( i==pIdx->nColumn ){\n      /* This index implies that the DISTINCT qualifier is redundant. */\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Prepare a crude estimate of the logarithm of the input value.\n** The results need not be exact.  This is only used for estimating\n** the total cost of performing operations with O(logN) or O(NlogN)\n** complexity.  Because N is just a guess, it is no great tragedy if\n** logN is a little off.\n*/\nstatic double estLog(double N){\n  double logN = 1;\n  double x = 10;\n  while( N>x ){\n    logN += 1;\n    x *= 10;\n  }\n  return logN;\n}\n\n/*\n** Two routines for printing the content of an sqlite3_index_info\n** structure.  Used for testing and debugging only.  If neither\n** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines\n** are no-ops.\n*/\n#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_DEBUG)\nstatic void TRACE_IDX_INPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  constraint[%d]: col=%d termid=%d op=%d usabled=%d\\n\",\n       i,\n       p->aConstraint[i].iColumn,\n       p->aConstraint[i].iTermOffset,\n       p->aConstraint[i].op,\n       p->aConstraint[i].usable);\n  }\n  for(i=0; i<p->nOrderBy; i++){\n    sqlite3DebugPrintf(\"  orderby[%d]: col=%d desc=%d\\n\",\n       i,\n       p->aOrderBy[i].iColumn,\n       p->aOrderBy[i].desc);\n  }\n}\nstatic void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  usage[%d]: argvIdx=%d omit=%d\\n\",\n       i,\n       p->aConstraintUsage[i].argvIndex,\n       p->aConstraintUsage[i].omit);\n  }\n  sqlite3DebugPrintf(\"  idxNum=%d\\n\", p->idxNum);\n  sqlite3DebugPrintf(\"  idxStr=%s\\n\", p->idxStr);\n  sqlite3DebugPrintf(\"  orderByConsumed=%d\\n\", p->orderByConsumed);\n  sqlite3DebugPrintf(\"  estimatedCost=%g\\n\", p->estimatedCost);\n}\n#else\n#define TRACE_IDX_INPUTS(A)\n#define TRACE_IDX_OUTPUTS(A)\n#endif\n\n/* \n** Required because bestIndex() is called by bestOrClauseIndex() \n*/\nstatic void bestIndex(WhereBestIdx*);\n\n/*\n** This routine attempts to find an scanning strategy that can be used \n** to optimize an 'OR' expression that is part of a WHERE clause. \n**\n** The table associated with FROM clause term pSrc may be either a\n** regular B-Tree table or a virtual table.\n*/\nstatic void bestOrClauseIndex(WhereBestIdx *p){\n#ifndef SQLITE_OMIT_OR_OPTIMIZATION\n  WhereClause *pWC = p->pWC;           /* The WHERE clause */\n  struct SrcList_item *pSrc = p->pSrc; /* The FROM clause term to search */\n  const int iCur = pSrc->iCursor;      /* The cursor of the table  */\n  const Bitmask maskSrc = getMask(pWC->pMaskSet, iCur);  /* Bitmask for pSrc */\n  WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm];        /* End of pWC->a[] */\n  WhereTerm *pTerm;                    /* A single term of the WHERE clause */\n\n  /* The OR-clause optimization is disallowed if the INDEXED BY or\n  ** NOT INDEXED clauses are used or if the WHERE_AND_ONLY bit is set. */\n  if( pSrc->notIndexed || pSrc->pIndex!=0 ){\n    return;\n  }\n  if( pWC->wctrlFlags & WHERE_AND_ONLY ){\n    return;\n  }\n\n  /* Search the WHERE clause terms for a usable WO_OR term. */\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( (pTerm->eOperator & WO_OR)!=0\n     && ((pTerm->prereqAll & ~maskSrc) & p->notReady)==0\n     && (pTerm->u.pOrInfo->indexable & maskSrc)!=0 \n    ){\n      WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;\n      WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];\n      WhereTerm *pOrTerm;\n      int flags = WHERE_MULTI_OR;\n      double rTotal = 0;\n      double nRow = 0;\n      Bitmask used = 0;\n      WhereBestIdx sBOI;\n\n      sBOI = *p;\n      sBOI.pOrderBy = 0;\n      sBOI.pDistinct = 0;\n      sBOI.ppIdxInfo = 0;\n      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){\n        WHERETRACE((\"... Multi-index OR testing for term %d of %d....\\n\", \n          (pOrTerm - pOrWC->a), (pTerm - pWC->a)\n        ));\n        if( (pOrTerm->eOperator& WO_AND)!=0 ){\n          sBOI.pWC = &pOrTerm->u.pAndInfo->wc;\n          bestIndex(&sBOI);\n        }else if( pOrTerm->leftCursor==iCur ){\n          WhereClause tempWC;\n          tempWC.pParse = pWC->pParse;\n          tempWC.pMaskSet = pWC->pMaskSet;\n          tempWC.pOuter = pWC;\n          tempWC.op = TK_AND;\n          tempWC.a = pOrTerm;\n          tempWC.wctrlFlags = 0;\n          tempWC.nTerm = 1;\n          sBOI.pWC = &tempWC;\n          bestIndex(&sBOI);\n        }else{\n          continue;\n        }\n        rTotal += sBOI.cost.rCost;\n        nRow += sBOI.cost.plan.nRow;\n        used |= sBOI.cost.used;\n        if( rTotal>=p->cost.rCost ) break;\n      }\n\n      /* If there is an ORDER BY clause, increase the scan cost to account \n      ** for the cost of the sort. */\n      if( p->pOrderBy!=0 ){\n        WHERETRACE((\"... sorting increases OR cost %.9g to %.9g\\n\",\n                    rTotal, rTotal+nRow*estLog(nRow)));\n        rTotal += nRow*estLog(nRow);\n      }\n\n      /* If the cost of scanning using this OR term for optimization is\n      ** less than the current cost stored in pCost, replace the contents\n      ** of pCost. */\n      WHERETRACE((\"... multi-index OR cost=%.9g nrow=%.9g\\n\", rTotal, nRow));\n      if( rTotal<p->cost.rCost ){\n        p->cost.rCost = rTotal;\n        p->cost.used = used;\n        p->cost.plan.nRow = nRow;\n        p->cost.plan.nOBSat = p->i ? p->aLevel[p->i-1].plan.nOBSat : 0;\n        p->cost.plan.wsFlags = flags;\n        p->cost.plan.u.pTerm = pTerm;\n      }\n    }\n  }\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n}\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Return TRUE if the WHERE clause term pTerm is of a form where it\n** could be used with an index to access pSrc, assuming an appropriate\n** index existed.\n*/\nstatic int termCanDriveIndex(\n  WhereTerm *pTerm,              /* WHERE clause term to check */\n  struct SrcList_item *pSrc,     /* Table we are trying to access */\n  Bitmask notReady               /* Tables in outer loops of the join */\n){\n  char aff;\n  if( pTerm->leftCursor!=pSrc->iCursor ) return 0;\n  if( (pTerm->eOperator & WO_EQ)==0 ) return 0;\n  if( (pTerm->prereqRight & notReady)!=0 ) return 0;\n  aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;\n  if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;\n  return 1;\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** If the query plan for pSrc specified in pCost is a full table scan\n** and indexing is allows (if there is no NOT INDEXED clause) and it\n** possible to construct a transient index that would perform better\n** than a full table scan even when the cost of constructing the index\n** is taken into account, then alter the query plan to use the\n** transient index.\n*/\nstatic void bestAutomaticIndex(WhereBestIdx *p){\n  Parse *pParse = p->pParse;            /* The parsing context */\n  WhereClause *pWC = p->pWC;            /* The WHERE clause */\n  struct SrcList_item *pSrc = p->pSrc;  /* The FROM clause term to search */\n  double nTableRow;                     /* Rows in the input table */\n  double logN;                          /* log(nTableRow) */\n  double costTempIdx;         /* per-query cost of the transient index */\n  WhereTerm *pTerm;           /* A single term of the WHERE clause */\n  WhereTerm *pWCEnd;          /* End of pWC->a[] */\n  Table *pTable;              /* Table tht might be indexed */\n\n  if( pParse->nQueryLoop<=(double)1 ){\n    /* There is no point in building an automatic index for a single scan */\n    return;\n  }\n  if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){\n    /* Automatic indices are disabled at run-time */\n    return;\n  }\n  if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0\n   && (p->cost.plan.wsFlags & WHERE_COVER_SCAN)==0\n  ){\n    /* We already have some kind of index in use for this query. */\n    return;\n  }\n  if( pSrc->viaCoroutine ){\n    /* Cannot index a co-routine */\n    return;\n  }\n  if( pSrc->notIndexed ){\n    /* The NOT INDEXED clause appears in the SQL. */\n    return;\n  }\n  if( pSrc->isCorrelated ){\n    /* The source is a correlated sub-query. No point in indexing it. */\n    return;\n  }\n\n  assert( pParse->nQueryLoop >= (double)1 );\n  pTable = pSrc->pTab;\n  nTableRow = pTable->nRowEst;\n  logN = estLog(nTableRow);\n  costTempIdx = 2*logN*(nTableRow/pParse->nQueryLoop + 1);\n  if( costTempIdx>=p->cost.rCost ){\n    /* The cost of creating the transient table would be greater than\n    ** doing the full table scan */\n    return;\n  }\n\n  /* Search for any equality comparison term */\n  pWCEnd = &pWC->a[pWC->nTerm];\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, p->notReady) ){\n      WHERETRACE((\"auto-index reduces cost from %.1f to %.1f\\n\",\n                    p->cost.rCost, costTempIdx));\n      p->cost.rCost = costTempIdx;\n      p->cost.plan.nRow = logN + 1;\n      p->cost.plan.wsFlags = WHERE_TEMP_INDEX;\n      p->cost.used = pTerm->prereqRight;\n      break;\n    }\n  }\n}\n#else\n# define bestAutomaticIndex(A)  /* no-op */\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Generate code to construct the Index object for an automatic index\n** and to set up the WhereLevel object pLevel so that the code generator\n** makes use of the automatic index.\n*/\nstatic void constructAutomaticIndex(\n  Parse *pParse,              /* The parsing context */\n  WhereClause *pWC,           /* The WHERE clause */\n  struct SrcList_item *pSrc,  /* The FROM clause term to get the next index */\n  Bitmask notReady,           /* Mask of cursors that are not available */\n  WhereLevel *pLevel          /* Write new index here */\n){\n  int nColumn;                /* Number of columns in the constructed index */\n  WhereTerm *pTerm;           /* A single term of the WHERE clause */\n  WhereTerm *pWCEnd;          /* End of pWC->a[] */\n  int nByte;                  /* Byte of memory needed for pIdx */\n  Index *pIdx;                /* Object describing the transient index */\n  Vdbe *v;                    /* Prepared statement under construction */\n  int addrInit;               /* Address of the initialization bypass jump */\n  Table *pTable;              /* The table being indexed */\n  KeyInfo *pKeyinfo;          /* Key information for the index */   \n  int addrTop;                /* Top of the index fill loop */\n  int regRecord;              /* Register holding an index record */\n  int n;                      /* Column counter */\n  int i;                      /* Loop counter */\n  int mxBitCol;               /* Maximum column in pSrc->colUsed */\n  CollSeq *pColl;             /* Collating sequence to on a column */\n  Bitmask idxCols;            /* Bitmap of columns used for indexing */\n  Bitmask extraCols;          /* Bitmap of additional columns */\n\n  /* Generate code to skip over the creation and initialization of the\n  ** transient index on 2nd and subsequent iterations of the loop. */\n  v = pParse->pVdbe;\n  assert( v!=0 );\n  addrInit = sqlite3CodeOnce(pParse);\n\n  /* Count the number of columns that will be added to the index\n  ** and used to match WHERE clause constraints */\n  nColumn = 0;\n  pTable = pSrc->pTab;\n  pWCEnd = &pWC->a[pWC->nTerm];\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      if( (idxCols & cMask)==0 ){\n        nColumn++;\n        idxCols |= cMask;\n      }\n    }\n  }\n  assert( nColumn>0 );\n  pLevel->plan.nEq = nColumn;\n\n  /* Count the number of additional columns needed to create a\n  ** covering index.  A \"covering index\" is an index that contains all\n  ** columns that are needed by the query.  With a covering index, the\n  ** original table never needs to be accessed.  Automatic indices must\n  ** be a covering index because the index will not be updated if the\n  ** original table changes and the index and table cannot both be used\n  ** if they go out of sync.\n  */\n  extraCols = pSrc->colUsed & (~idxCols | (((Bitmask)1)<<(BMS-1)));\n  mxBitCol = (pTable->nCol >= BMS-1) ? BMS-1 : pTable->nCol;\n  testcase( pTable->nCol==BMS-1 );\n  testcase( pTable->nCol==BMS-2 );\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & (((Bitmask)1)<<i) ) nColumn++;\n  }\n  if( pSrc->colUsed & (((Bitmask)1)<<(BMS-1)) ){\n    nColumn += pTable->nCol - BMS + 1;\n  }\n  pLevel->plan.wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WO_EQ;\n\n  /* Construct the Index object to describe this index */\n  nByte = sizeof(Index);\n  nByte += nColumn*sizeof(int);     /* Index.aiColumn */\n  nByte += nColumn*sizeof(char*);   /* Index.azColl */\n  nByte += nColumn;                 /* Index.aSortOrder */\n  pIdx = sqlite3DbMallocZero(pParse->db, nByte);\n  if( pIdx==0 ) return;\n  pLevel->plan.u.pIdx = pIdx;\n  pIdx->azColl = (char**)&pIdx[1];\n  pIdx->aiColumn = (int*)&pIdx->azColl[nColumn];\n  pIdx->aSortOrder = (u8*)&pIdx->aiColumn[nColumn];\n  pIdx->zName = \"auto-index\";\n  pIdx->nColumn = nColumn;\n  pIdx->pTable = pTable;\n  n = 0;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? ((Bitmask)1)<<(BMS-1) : ((Bitmask)1)<<iCol;\n      if( (idxCols & cMask)==0 ){\n        Expr *pX = pTerm->pExpr;\n        idxCols |= cMask;\n        pIdx->aiColumn[n] = pTerm->u.leftColumn;\n        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);\n        pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : \"BINARY\";\n        n++;\n      }\n    }\n  }\n  assert( (u32)n==pLevel->plan.nEq );\n\n  /* Add additional columns needed to make the automatic index into\n  ** a covering index */\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & (((Bitmask)1)<<i) ){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = \"BINARY\";\n      n++;\n    }\n  }\n  if( pSrc->colUsed & (((Bitmask)1)<<(BMS-1)) ){\n    for(i=BMS-1; i<pTable->nCol; i++){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = \"BINARY\";\n      n++;\n    }\n  }\n  assert( n==nColumn );\n\n  /* Create the automatic index */\n  pKeyinfo = sqlite3IndexKeyinfo(pParse, pIdx);\n  assert( pLevel->iIdxCur>=0 );\n  sqlite3VdbeAddOp4(v, OP_OpenAutoindex, pLevel->iIdxCur, nColumn+1, 0,\n                    (char*)pKeyinfo, P4_KEYINFO_HANDOFF);\n  VdbeComment((v, \"for %s\", pTable->zName));\n\n  /* Fill the automatic index with content */\n  addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur);\n  regRecord = sqlite3GetTempReg(pParse);\n  sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1);\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);\n  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);\n  sqlite3VdbeJumpHere(v, addrTop);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  \n  /* Jump here when skipping the initialization */\n  sqlite3VdbeJumpHere(v, addrInit);\n}\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Allocate and populate an sqlite3_index_info structure. It is the \n** responsibility of the caller to eventually release the structure\n** by passing the pointer returned by this function to sqlite3_free().\n*/\nstatic sqlite3_index_info *allocateIndexInfo(WhereBestIdx *p){\n  Parse *pParse = p->pParse; \n  WhereClause *pWC = p->pWC;\n  struct SrcList_item *pSrc = p->pSrc;\n  ExprList *pOrderBy = p->pOrderBy;\n  int i, j;\n  int nTerm;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_orderby *pIdxOrderBy;\n  struct sqlite3_index_constraint_usage *pUsage;\n  WhereTerm *pTerm;\n  int nOrderBy;\n  sqlite3_index_info *pIdxInfo;\n\n  WHERETRACE((\"Recomputing index info for %s...\\n\", pSrc->pTab->zName));\n\n  /* Count the number of possible WHERE clause constraints referring\n  ** to this virtual table */\n  for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    if( pTerm->eOperator & (WO_ISNULL) ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    nTerm++;\n  }\n\n  /* If the ORDER BY clause contains only columns in the current \n  ** virtual table then allocate space for the aOrderBy part of\n  ** the sqlite3_index_info structure.\n  */\n  nOrderBy = 0;\n  if( pOrderBy ){\n    int n = pOrderBy->nExpr;\n    for(i=0; i<n; i++){\n      Expr *pExpr = pOrderBy->a[i].pExpr;\n      if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;\n    }\n    if( i==n){\n      nOrderBy = n;\n    }\n  }\n\n  /* Allocate the sqlite3_index_info structure\n  */\n  pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)\n                           + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm\n                           + sizeof(*pIdxOrderBy)*nOrderBy );\n  if( pIdxInfo==0 ){\n    sqlite3ErrorMsg(pParse, \"out of memory\");\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    return 0;\n  }\n\n  /* Initialize the structure.  The sqlite3_index_info structure contains\n  ** many fields that are declared \"const\" to prevent xBestIndex from\n  ** changing them.  We have to do some funky casting in order to\n  ** initialize those fields.\n  */\n  pIdxCons = (struct sqlite3_index_constraint*)&pIdxInfo[1];\n  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];\n  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];\n  *(int*)&pIdxInfo->nConstraint = nTerm;\n  *(int*)&pIdxInfo->nOrderBy = nOrderBy;\n  *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons;\n  *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy;\n  *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =\n                                                                   pUsage;\n\n  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    u8 op;\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    if( pTerm->eOperator & (WO_ISNULL) ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    pIdxCons[j].iColumn = pTerm->u.leftColumn;\n    pIdxCons[j].iTermOffset = i;\n    op = (u8)pTerm->eOperator & WO_ALL;\n    if( op==WO_IN ) op = WO_EQ;\n    pIdxCons[j].op = op;\n    /* The direct assignment in the previous line is possible only because\n    ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The\n    ** following asserts verify this fact. */\n    assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );\n    assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT );\n    assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );\n    assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );\n    assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );\n    assert( WO_MATCH==SQLITE_INDEX_CONSTRAINT_MATCH );\n    assert( pTerm->eOperator & (WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) );\n    j++;\n  }\n  for(i=0; i<nOrderBy; i++){\n    Expr *pExpr = pOrderBy->a[i].pExpr;\n    pIdxOrderBy[i].iColumn = pExpr->iColumn;\n    pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;\n  }\n\n  return pIdxInfo;\n}\n\n/*\n** The table object reference passed as the second argument to this function\n** must represent a virtual table. This function invokes the xBestIndex()\n** method of the virtual table with the sqlite3_index_info pointer passed\n** as the argument.\n**\n** If an error occurs, pParse is populated with an error message and a\n** non-zero value is returned. Otherwise, 0 is returned and the output\n** part of the sqlite3_index_info structure is left populated.\n**\n** Whether or not an error is returned, it is the responsibility of the\n** caller to eventually free p->idxStr if p->needToFreeIdxStr indicates\n** that this is required.\n*/\nstatic int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){\n  sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;\n  int i;\n  int rc;\n\n  WHERETRACE((\"xBestIndex for %s\\n\", pTab->zName));\n  TRACE_IDX_INPUTS(p);\n  rc = pVtab->pModule->xBestIndex(pVtab, p);\n  TRACE_IDX_OUTPUTS(p);\n\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ){\n      pParse->db->mallocFailed = 1;\n    }else if( !pVtab->zErrMsg ){\n      sqlite3ErrorMsg(pParse, \"%s\", sqlite3ErrStr(rc));\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s\", pVtab->zErrMsg);\n    }\n  }\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = 0;\n\n  for(i=0; i<p->nConstraint; i++){\n    if( !p->aConstraint[i].usable && p->aConstraintUsage[i].argvIndex>0 ){\n      sqlite3ErrorMsg(pParse, \n          \"table %s: xBestIndex returned an invalid plan\", pTab->zName);\n    }\n  }\n\n  return pParse->nErr;\n}\n\n\n/*\n** Compute the best index for a virtual table.\n**\n** The best index is computed by the xBestIndex method of the virtual\n** table module.  This routine is really just a wrapper that sets up\n** the sqlite3_index_info structure that is used to communicate with\n** xBestIndex.\n**\n** In a join, this routine might be called multiple times for the\n** same virtual table.  The sqlite3_index_info structure is created\n** and initialized on the first invocation and reused on all subsequent\n** invocations.  The sqlite3_index_info structure is also used when\n** code is generated to access the virtual table.  The whereInfoDelete() \n** routine takes care of freeing the sqlite3_index_info structure after\n** everybody has finished with it.\n*/\nstatic void bestVirtualIndex(WhereBestIdx *p){\n  Parse *pParse = p->pParse;      /* The parsing context */\n  WhereClause *pWC = p->pWC;      /* The WHERE clause */\n  struct SrcList_item *pSrc = p->pSrc; /* The FROM clause term to search */\n  Table *pTab = pSrc->pTab;\n  sqlite3_index_info *pIdxInfo;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_constraint_usage *pUsage;\n  WhereTerm *pTerm;\n  int i, j;\n  int nOrderBy;\n  int bAllowIN;                   /* Allow IN optimizations */\n  double rCost;\n\n  /* Make sure wsFlags is initialized to some sane value. Otherwise, if the \n  ** malloc in allocateIndexInfo() fails and this function returns leaving\n  ** wsFlags in an uninitialized state, the caller may behave unpredictably.\n  */\n  memset(&p->cost, 0, sizeof(p->cost));\n  p->cost.plan.wsFlags = WHERE_VIRTUALTABLE;\n\n  /* If the sqlite3_index_info structure has not been previously\n  ** allocated and initialized, then allocate and initialize it now.\n  */\n  pIdxInfo = *p->ppIdxInfo;\n  if( pIdxInfo==0 ){\n    *p->ppIdxInfo = pIdxInfo = allocateIndexInfo(p);\n  }\n  if( pIdxInfo==0 ){\n    return;\n  }\n\n  /* At this point, the sqlite3_index_info structure that pIdxInfo points\n  ** to will have been initialized, either during the current invocation or\n  ** during some prior invocation.  Now we just have to customize the\n  ** details of pIdxInfo for the current invocation and pass it to\n  ** xBestIndex.\n  */\n\n  /* The module name must be defined. Also, by this point there must\n  ** be a pointer to an sqlite3_vtab structure. Otherwise\n  ** sqlite3ViewGetColumnNames() would have picked up the error. \n  */\n  assert( pTab->azModuleArg && pTab->azModuleArg[0] );\n  assert( sqlite3GetVTable(pParse->db, pTab) );\n\n  /* Try once or twice.  On the first attempt, allow IN optimizations.\n  ** If an IN optimization is accepted by the virtual table xBestIndex\n  ** method, but the  pInfo->aConstrainUsage.omit flag is not set, then\n  ** the query will not work because it might allow duplicate rows in\n  ** output.  In that case, run the xBestIndex method a second time\n  ** without the IN constraints.  Usually this loop only runs once.\n  ** The loop will exit using a \"break\" statement.\n  */\n  for(bAllowIN=1; 1; bAllowIN--){\n    assert( bAllowIN==0 || bAllowIN==1 );\n\n    /* Set the aConstraint[].usable fields and initialize all \n    ** output variables to zero.\n    **\n    ** aConstraint[].usable is true for constraints where the right-hand\n    ** side contains only references to tables to the left of the current\n    ** table.  In other words, if the constraint is of the form:\n    **\n    **           column = expr\n    **\n    ** and we are evaluating a join, then the constraint on column is \n    ** only valid if all tables referenced in expr occur to the left\n    ** of the table containing column.\n    **\n    ** The aConstraints[] array contains entries for all constraints\n    ** on the current table.  That way we only have to compute it once\n    ** even though we might try to pick the best index multiple times.\n    ** For each attempt at picking an index, the order of tables in the\n    ** join might be different so we have to recompute the usable flag\n    ** each time.\n    */\n    pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n    pUsage = pIdxInfo->aConstraintUsage;\n    for(i=0; i<pIdxInfo->nConstraint; i++, pIdxCons++){\n      j = pIdxCons->iTermOffset;\n      pTerm = &pWC->a[j];\n      if( (pTerm->prereqRight&p->notReady)==0\n       && (bAllowIN || (pTerm->eOperator & WO_IN)==0)\n      ){\n        pIdxCons->usable = 1;\n      }else{\n        pIdxCons->usable = 0;\n      }\n    }\n    memset(pUsage, 0, sizeof(pUsage[0])*pIdxInfo->nConstraint);\n    if( pIdxInfo->needToFreeIdxStr ){\n      sqlite3_free(pIdxInfo->idxStr);\n    }\n    pIdxInfo->idxStr = 0;\n    pIdxInfo->idxNum = 0;\n    pIdxInfo->needToFreeIdxStr = 0;\n    pIdxInfo->orderByConsumed = 0;\n    /* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */\n    pIdxInfo->estimatedCost = SQLITE_BIG_DBL / ((double)2);\n    nOrderBy = pIdxInfo->nOrderBy;\n    if( !p->pOrderBy ){\n      pIdxInfo->nOrderBy = 0;\n    }\n  \n    if( vtabBestIndex(pParse, pTab, pIdxInfo) ){\n      return;\n    }\n  \n    pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n    for(i=0; i<pIdxInfo->nConstraint; i++, pIdxCons++){\n      if( pUsage[i].argvIndex>0 ){\n        j = pIdxCons->iTermOffset;\n        pTerm = &pWC->a[j];\n        p->cost.used |= pTerm->prereqRight;\n        if( (pTerm->eOperator & WO_IN)!=0 ){\n          if( pUsage[i].omit==0 ){\n            /* Do not attempt to use an IN constraint if the virtual table\n            ** says that the equivalent EQ constraint cannot be safely omitted.\n            ** If we do attempt to use such a constraint, some rows might be\n            ** repeated in the output. */\n            break;\n          }\n          /* A virtual table that is constrained by an IN clause may not\n          ** consume the ORDER BY clause because (1) the order of IN terms\n          ** is not necessarily related to the order of output terms and\n          ** (2) Multiple outputs from a single IN value will not merge\n          ** together.  */\n          pIdxInfo->orderByConsumed = 0;\n        }\n      }\n    }\n    if( i>=pIdxInfo->nConstraint ) break;\n  }\n\n  /* The orderByConsumed signal is only valid if all outer loops collectively\n  ** generate just a single row of output.\n  */\n  if( pIdxInfo->orderByConsumed ){\n    for(i=0; i<p->i; i++){\n      if( (p->aLevel[i].plan.wsFlags & WHERE_UNIQUE)==0 ){\n        pIdxInfo->orderByConsumed = 0;\n      }\n    }\n  }\n  \n  /* If there is an ORDER BY clause, and the selected virtual table index\n  ** does not satisfy it, increase the cost of the scan accordingly. This\n  ** matches the processing for non-virtual tables in bestBtreeIndex().\n  */\n  rCost = pIdxInfo->estimatedCost;\n  if( p->pOrderBy && pIdxInfo->orderByConsumed==0 ){\n    rCost += estLog(rCost)*rCost;\n  }\n\n  /* The cost is not allowed to be larger than SQLITE_BIG_DBL (the\n  ** inital value of lowestCost in this loop. If it is, then the\n  ** (cost<lowestCost) test below will never be true.\n  ** \n  ** Use \"(double)2\" instead of \"2.0\" in case OMIT_FLOATING_POINT \n  ** is defined.\n  */\n  if( (SQLITE_BIG_DBL/((double)2))<rCost ){\n    p->cost.rCost = (SQLITE_BIG_DBL/((double)2));\n  }else{\n    p->cost.rCost = rCost;\n  }\n  p->cost.plan.u.pVtabIdx = pIdxInfo;\n  if( pIdxInfo->orderByConsumed ){\n    p->cost.plan.wsFlags |= WHERE_ORDERED;\n    p->cost.plan.nOBSat = nOrderBy;\n  }else{\n    p->cost.plan.nOBSat = p->i ? p->aLevel[p->i-1].plan.nOBSat : 0;\n  }\n  p->cost.plan.nEq = 0;\n  pIdxInfo->nOrderBy = nOrderBy;\n\n  /* Try to find a more efficient access pattern by using multiple indexes\n  ** to optimize an OR expression within the WHERE clause. \n  */\n  bestOrClauseIndex(p);\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef SQLITE_ENABLE_STAT3\n/*\n** Estimate the location of a particular key among all keys in an\n** index.  Store the results in aStat as follows:\n**\n**    aStat[0]      Est. number of rows less than pVal\n**    aStat[1]      Est. number of rows equal to pVal\n**\n** Return SQLITE_OK on success.\n*/\nstatic int whereKeyStats(\n  Parse *pParse,              /* Database connection */\n  Index *pIdx,                /* Index to consider domain of */\n  sqlite3_value *pVal,        /* Value to consider */\n  int roundUp,                /* Round up if true.  Round down if false */\n  tRowcnt *aStat              /* OUT: stats written here */\n){\n  tRowcnt n;\n  IndexSample *aSample;\n  int i, eType;\n  int isEq = 0;\n  i64 v;\n  double r, rS;\n\n  assert( roundUp==0 || roundUp==1 );\n  assert( pIdx->nSample>0 );\n  if( pVal==0 ) return SQLITE_ERROR;\n  n = pIdx->aiRowEst[0];\n  aSample = pIdx->aSample;\n  eType = sqlite3_value_type(pVal);\n\n  if( eType==SQLITE_INTEGER ){\n    v = sqlite3_value_int64(pVal);\n    r = (i64)v;\n    for(i=0; i<pIdx->nSample; i++){\n      if( aSample[i].eType==SQLITE_NULL ) continue;\n      if( aSample[i].eType>=SQLITE_TEXT ) break;\n      if( aSample[i].eType==SQLITE_INTEGER ){\n        if( aSample[i].u.i>=v ){\n          isEq = aSample[i].u.i==v;\n          break;\n        }\n      }else{\n        assert( aSample[i].eType==SQLITE_FLOAT );\n        if( aSample[i].u.r>=r ){\n          isEq = aSample[i].u.r==r;\n          break;\n        }\n      }\n    }\n  }else if( eType==SQLITE_FLOAT ){\n    r = sqlite3_value_double(pVal);\n    for(i=0; i<pIdx->nSample; i++){\n      if( aSample[i].eType==SQLITE_NULL ) continue;\n      if( aSample[i].eType>=SQLITE_TEXT ) break;\n      if( aSample[i].eType==SQLITE_FLOAT ){\n        rS = aSample[i].u.r;\n      }else{\n        rS = aSample[i].u.i;\n      }\n      if( rS>=r ){\n        isEq = rS==r;\n        break;\n      }\n    }\n  }else if( eType==SQLITE_NULL ){\n    i = 0;\n    if( aSample[0].eType==SQLITE_NULL ) isEq = 1;\n  }else{\n    assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n    for(i=0; i<pIdx->nSample; i++){\n      if( aSample[i].eType==SQLITE_TEXT || aSample[i].eType==SQLITE_BLOB ){\n        break;\n      }\n    }\n    if( i<pIdx->nSample ){      \n      sqlite3 *db = pParse->db;\n      CollSeq *pColl;\n      const u8 *z;\n      if( eType==SQLITE_BLOB ){\n        z = (const u8 *)sqlite3_value_blob(pVal);\n        pColl = db->pDfltColl;\n        assert( pColl->enc==SQLITE_UTF8 );\n      }else{\n        pColl = sqlite3GetCollSeq(pParse, SQLITE_UTF8, 0, *pIdx->azColl);\n        if( pColl==0 ){\n          return SQLITE_ERROR;\n        }\n        z = (const u8 *)sqlite3ValueText(pVal, pColl->enc);\n        if( !z ){\n          return SQLITE_NOMEM;\n        }\n        assert( z && pColl && pColl->xCmp );\n      }\n      n = sqlite3ValueBytes(pVal, pColl->enc);\n  \n      for(; i<pIdx->nSample; i++){\n        int c;\n        int eSampletype = aSample[i].eType;\n        if( eSampletype<eType ) continue;\n        if( eSampletype!=eType ) break;\n#ifndef SQLITE_OMIT_UTF16\n        if( pColl->enc!=SQLITE_UTF8 ){\n          int nSample;\n          char *zSample = sqlite3Utf8to16(\n              db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample\n          );\n          if( !zSample ){\n            assert( db->mallocFailed );\n            return SQLITE_NOMEM;\n          }\n          c = pColl->xCmp(pColl->pUser, nSample, zSample, n, z);\n          sqlite3DbFree(db, zSample);\n        }else\n#endif\n        {\n          c = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z);\n        }\n        if( c>=0 ){\n          if( c==0 ) isEq = 1;\n          break;\n        }\n      }\n    }\n  }\n\n  /* At this point, aSample[i] is the first sample that is greater than\n  ** or equal to pVal.  Or if i==pIdx->nSample, then all samples are less\n  ** than pVal.  If aSample[i]==pVal, then isEq==1.\n  */\n  if( isEq ){\n    assert( i<pIdx->nSample );\n    aStat[0] = aSample[i].nLt;\n    aStat[1] = aSample[i].nEq;\n  }else{\n    tRowcnt iLower, iUpper, iGap;\n    if( i==0 ){\n      iLower = 0;\n      iUpper = aSample[0].nLt;\n    }else{\n      iUpper = i>=pIdx->nSample ? n : aSample[i].nLt;\n      iLower = aSample[i-1].nEq + aSample[i-1].nLt;\n    }\n    aStat[1] = pIdx->avgEq;\n    if( iLower>=iUpper ){\n      iGap = 0;\n    }else{\n      iGap = iUpper - iLower;\n    }\n    if( roundUp ){\n      iGap = (iGap*2)/3;\n    }else{\n      iGap = iGap/3;\n    }\n    aStat[0] = iLower + iGap;\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_ENABLE_STAT3 */\n\n/*\n** If expression pExpr represents a literal value, set *pp to point to\n** an sqlite3_value structure containing the same value, with affinity\n** aff applied to it, before returning. It is the responsibility of the \n** caller to eventually release this structure by passing it to \n** sqlite3ValueFree().\n**\n** If the current parse is a recompile (sqlite3Reprepare()) and pExpr\n** is an SQL variable that currently has a non-NULL value bound to it,\n** create an sqlite3_value structure containing this value, again with\n** affinity aff applied to it, instead.\n**\n** If neither of the above apply, set *pp to NULL.\n**\n** If an error occurs, return an error code. Otherwise, SQLITE_OK.\n*/\n#ifdef SQLITE_ENABLE_STAT3\nstatic int valueFromExpr(\n  Parse *pParse, \n  Expr *pExpr, \n  u8 aff, \n  sqlite3_value **pp\n){\n  if( pExpr->op==TK_VARIABLE\n   || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)\n  ){\n    int iVar = pExpr->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);\n    *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff);\n    return SQLITE_OK;\n  }\n  return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp);\n}\n#endif\n\n/*\n** This function is used to estimate the number of rows that will be visited\n** by scanning an index for a range of values. The range may have an upper\n** bound, a lower bound, or both. The WHERE clause terms that set the upper\n** and lower bounds are represented by pLower and pUpper respectively. For\n** example, assuming that index p is on t1(a):\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**                    |_____|   |_____|\n**                       |         |\n**                     pLower    pUpper\n**\n** If either of the upper or lower bound is not present, then NULL is passed in\n** place of the corresponding WhereTerm.\n**\n** The nEq parameter is passed the index of the index column subject to the\n** range constraint. Or, equivalently, the number of equality constraints\n** optimized by the proposed index scan. For example, assuming index p is\n** on t1(a, b), and the SQL query is:\n**\n**   ... FROM t1 WHERE a = ? AND b > ? AND b < ? ...\n**\n** then nEq should be passed the value 1 (as the range restricted column,\n** b, is the second left-most column of the index). Or, if the query is:\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**\n** then nEq should be passed 0.\n**\n** The returned value is an integer divisor to reduce the estimated\n** search space.  A return value of 1 means that range constraints are\n** no help at all.  A return value of 2 means range constraints are\n** expected to reduce the search space by half.  And so forth...\n**\n** In the absence of sqlite_stat3 ANALYZE data, each range inequality\n** reduces the search space by a factor of 4.  Hence a single constraint (x>?)\n** results in a return of 4 and a range constraint (x>? AND x<?) results\n** in a return of 16.\n*/\nstatic int whereRangeScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  Index *p,            /* The index containing the range-compared column; \"x\" */\n  int nEq,             /* index into p->aCol[] of the range-compared column */\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  double *pRangeDiv   /* OUT: Reduce search space by this divisor */\n){\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_STAT3\n\n  if( nEq==0 && p->nSample ){\n    sqlite3_value *pRangeVal;\n    tRowcnt iLower = 0;\n    tRowcnt iUpper = p->aiRowEst[0];\n    tRowcnt a[2];\n    u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;\n\n    if( pLower ){\n      Expr *pExpr = pLower->pExpr->pRight;\n      rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);\n      assert( (pLower->eOperator & (WO_GT|WO_GE))!=0 );\n      if( rc==SQLITE_OK\n       && whereKeyStats(pParse, p, pRangeVal, 0, a)==SQLITE_OK\n      ){\n        iLower = a[0];\n        if( (pLower->eOperator & WO_GT)!=0 ) iLower += a[1];\n      }\n      sqlite3ValueFree(pRangeVal);\n    }\n    if( rc==SQLITE_OK && pUpper ){\n      Expr *pExpr = pUpper->pExpr->pRight;\n      rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal);\n      assert( (pUpper->eOperator & (WO_LT|WO_LE))!=0 );\n      if( rc==SQLITE_OK\n       && whereKeyStats(pParse, p, pRangeVal, 1, a)==SQLITE_OK\n      ){\n        iUpper = a[0];\n        if( (pUpper->eOperator & WO_LE)!=0 ) iUpper += a[1];\n      }\n      sqlite3ValueFree(pRangeVal);\n    }\n    if( rc==SQLITE_OK ){\n      if( iUpper<=iLower ){\n        *pRangeDiv = (double)p->aiRowEst[0];\n      }else{\n        *pRangeDiv = (double)p->aiRowEst[0]/(double)(iUpper - iLower);\n      }\n      WHERETRACE((\"range scan regions: %u..%u  div=%g\\n\",\n                  (u32)iLower, (u32)iUpper, *pRangeDiv));\n      return SQLITE_OK;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pParse);\n  UNUSED_PARAMETER(p);\n  UNUSED_PARAMETER(nEq);\n#endif\n  assert( pLower || pUpper );\n  *pRangeDiv = (double)1;\n  if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ) *pRangeDiv *= (double)4;\n  if( pUpper ) *pRangeDiv *= (double)4;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_STAT3\n/*\n** Estimate the number of rows that will be returned based on\n** an equality constraint x=VALUE and where that VALUE occurs in\n** the histogram data.  This only works when x is the left-most\n** column of an index and sqlite_stat3 histogram data is available\n** for that index.  When pExpr==NULL that means the constraint is\n** \"x IS NULL\" instead of \"x=VALUE\".\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereEqualScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  Index *p,            /* The index whose left-most column is pTerm */\n  Expr *pExpr,         /* Expression for VALUE in the x=VALUE constraint */\n  double *pnRow        /* Write the revised row estimate here */\n){\n  sqlite3_value *pRhs = 0;  /* VALUE on right-hand side of pTerm */\n  u8 aff;                   /* Column affinity */\n  int rc;                   /* Subfunction return code */\n  tRowcnt a[2];             /* Statistics */\n\n  assert( p->aSample!=0 );\n  assert( p->nSample>0 );\n  aff = p->pTable->aCol[p->aiColumn[0]].affinity;\n  if( pExpr ){\n    rc = valueFromExpr(pParse, pExpr, aff, &pRhs);\n    if( rc ) goto whereEqualScanEst_cancel;\n  }else{\n    pRhs = sqlite3ValueNew(pParse->db);\n  }\n  if( pRhs==0 ) return SQLITE_NOTFOUND;\n  rc = whereKeyStats(pParse, p, pRhs, 0, a);\n  if( rc==SQLITE_OK ){\n    WHERETRACE((\"equality scan regions: %d\\n\", (int)a[1]));\n    *pnRow = a[1];\n  }\nwhereEqualScanEst_cancel:\n  sqlite3ValueFree(pRhs);\n  return rc;\n}\n#endif /* defined(SQLITE_ENABLE_STAT3) */\n\n#ifdef SQLITE_ENABLE_STAT3\n/*\n** Estimate the number of rows that will be returned based on\n** an IN constraint where the right-hand side of the IN operator\n** is a list of values.  Example:\n**\n**        WHERE x IN (1,2,3,4)\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereInScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  Index *p,            /* The index whose left-most column is pTerm */\n  ExprList *pList,     /* The value list on the RHS of \"x IN (v1,v2,v3,...)\" */\n  double *pnRow        /* Write the revised row estimate here */\n){\n  int rc = SQLITE_OK;         /* Subfunction return code */\n  double nEst;                /* Number of rows for a single term */\n  double nRowEst = (double)0; /* New estimate of the number of rows */\n  int i;                      /* Loop counter */\n\n  assert( p->aSample!=0 );\n  for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){\n    nEst = p->aiRowEst[0];\n    rc = whereEqualScanEst(pParse, p, pList->a[i].pExpr, &nEst);\n    nRowEst += nEst;\n  }\n  if( rc==SQLITE_OK ){\n    if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0];\n    *pnRow = nRowEst;\n    WHERETRACE((\"IN row estimate: est=%g\\n\", nRowEst));\n  }\n  return rc;\n}\n#endif /* defined(SQLITE_ENABLE_STAT3) */\n\n/*\n** Check to see if column iCol of the table with cursor iTab will appear\n** in sorted order according to the current query plan.\n**\n** Return values:\n**\n**    0   iCol is not ordered\n**    1   iCol has only a single value\n**    2   iCol is in ASC order\n**    3   iCol is in DESC order\n*/\nstatic int isOrderedColumn(\n  WhereBestIdx *p,\n  int iTab,\n  int iCol\n){\n  int i, j;\n  WhereLevel *pLevel = &p->aLevel[p->i-1];\n  Index *pIdx;\n  u8 sortOrder;\n  for(i=p->i-1; i>=0; i--, pLevel--){\n    if( pLevel->iTabCur!=iTab ) continue;\n    if( (pLevel->plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){\n      return 1;\n    }\n    assert( (pLevel->plan.wsFlags & WHERE_ORDERED)!=0 );\n    if( (pIdx = pLevel->plan.u.pIdx)!=0 ){\n      if( iCol<0 ){\n        sortOrder = 0;\n        testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );\n      }else{\n        int n = pIdx->nColumn;\n        for(j=0; j<n; j++){\n          if( iCol==pIdx->aiColumn[j] ) break;\n        }\n        if( j>=n ) return 0;\n        sortOrder = pIdx->aSortOrder[j];\n        testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );\n      }\n    }else{\n      if( iCol!=(-1) ) return 0;\n      sortOrder = 0;\n      testcase( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 );\n    }\n    if( (pLevel->plan.wsFlags & WHERE_REVERSE)!=0 ){\n      assert( sortOrder==0 || sortOrder==1 );\n      testcase( sortOrder==1 );\n      sortOrder = 1 - sortOrder;\n    }\n    return sortOrder+2;\n  }\n  return 0;\n}\n\n/*\n** This routine decides if pIdx can be used to satisfy the ORDER BY\n** clause, either in whole or in part.  The return value is the \n** cumulative number of terms in the ORDER BY clause that are satisfied\n** by the index pIdx and other indices in outer loops.\n**\n** The table being queried has a cursor number of \"base\".  pIdx is the\n** index that is postulated for use to access the table.\n**\n** The *pbRev value is set to 0 order 1 depending on whether or not\n** pIdx should be run in the forward order or in reverse order.\n*/\nstatic int isSortingIndex(\n  WhereBestIdx *p,    /* Best index search context */\n  Index *pIdx,        /* The index we are testing */\n  int base,           /* Cursor number for the table to be sorted */\n  int *pbRev,         /* Set to 1 for reverse-order scan of pIdx */\n  int *pbObUnique     /* ORDER BY column values will different in every row */\n){\n  int i;                        /* Number of pIdx terms used */\n  int j;                        /* Number of ORDER BY terms satisfied */\n  int sortOrder = 2;            /* 0: forward.  1: backward.  2: unknown */\n  int nTerm;                    /* Number of ORDER BY terms */\n  struct ExprList_item *pOBItem;/* A term of the ORDER BY clause */\n  Table *pTab = pIdx->pTable;   /* Table that owns index pIdx */\n  ExprList *pOrderBy;           /* The ORDER BY clause */\n  Parse *pParse = p->pParse;    /* Parser context */\n  sqlite3 *db = pParse->db;     /* Database connection */\n  int nPriorSat;                /* ORDER BY terms satisfied by outer loops */\n  int seenRowid = 0;            /* True if an ORDER BY rowid term is seen */\n  int uniqueNotNull;            /* pIdx is UNIQUE with all terms are NOT NULL */\n  int outerObUnique;            /* Outer loops generate different values in\n                                ** every row for the ORDER BY columns */\n\n  if( p->i==0 ){\n    nPriorSat = 0;\n    outerObUnique = 1;\n  }else{\n    u32 wsFlags = p->aLevel[p->i-1].plan.wsFlags;\n    nPriorSat = p->aLevel[p->i-1].plan.nOBSat;\n    if( (wsFlags & WHERE_ORDERED)==0 ){\n      /* This loop cannot be ordered unless the next outer loop is\n      ** also ordered */\n      return nPriorSat;\n    }\n    if( OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ){\n      /* Only look at the outer-most loop if the OrderByIdxJoin\n      ** optimization is disabled */\n      return nPriorSat;\n    }\n    testcase( wsFlags & WHERE_OB_UNIQUE );\n    testcase( wsFlags & WHERE_ALL_UNIQUE );\n    outerObUnique = (wsFlags & (WHERE_OB_UNIQUE|WHERE_ALL_UNIQUE))!=0;\n  }\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy!=0 );\n  if( pIdx->bUnordered ){\n    /* Hash indices (indicated by the \"unordered\" tag on sqlite_stat1) cannot\n    ** be used for sorting */\n    return nPriorSat;\n  }\n  nTerm = pOrderBy->nExpr;\n  uniqueNotNull = pIdx->onError!=OE_None;\n  assert( nTerm>0 );\n\n  /* Argument pIdx must either point to a 'real' named index structure, \n  ** or an index structure allocated on the stack by bestBtreeIndex() to\n  ** represent the rowid index that is part of every table.  */\n  assert( pIdx->zName || (pIdx->nColumn==1 && pIdx->aiColumn[0]==-1) );\n\n  /* Match terms of the ORDER BY clause against columns of\n  ** the index.\n  **\n  ** Note that indices have pIdx->nColumn regular columns plus\n  ** one additional column containing the rowid.  The rowid column\n  ** of the index is also allowed to match against the ORDER BY\n  ** clause.\n  */\n  j = nPriorSat;\n  for(i=0,pOBItem=&pOrderBy->a[j]; j<nTerm && i<=pIdx->nColumn; i++){\n    Expr *pOBExpr;          /* The expression of the ORDER BY pOBItem */\n    CollSeq *pColl;         /* The collating sequence of pOBExpr */\n    int termSortOrder;      /* Sort order for this term */\n    int iColumn;            /* The i-th column of the index.  -1 for rowid */\n    int iSortOrder;         /* 1 for DESC, 0 for ASC on the i-th index term */\n    int isEq;               /* Subject to an == or IS NULL constraint */\n    int isMatch;            /* ORDER BY term matches the index term */\n    const char *zColl;      /* Name of collating sequence for i-th index term */\n    WhereTerm *pConstraint; /* A constraint in the WHERE clause */\n\n    /* If the next term of the ORDER BY clause refers to anything other than\n    ** a column in the \"base\" table, then this index will not be of any\n    ** further use in handling the ORDER BY. */\n    pOBExpr = sqlite3ExprSkipCollate(pOBItem->pExpr);\n    if( pOBExpr->op!=TK_COLUMN || pOBExpr->iTable!=base ){\n      break;\n    }\n\n    /* Find column number and collating sequence for the next entry\n    ** in the index */\n    if( pIdx->zName && i<pIdx->nColumn ){\n      iColumn = pIdx->aiColumn[i];\n      if( iColumn==pIdx->pTable->iPKey ){\n        iColumn = -1;\n      }\n      iSortOrder = pIdx->aSortOrder[i];\n      zColl = pIdx->azColl[i];\n      assert( zColl!=0 );\n    }else{\n      iColumn = -1;\n      iSortOrder = 0;\n      zColl = 0;\n    }\n\n    /* Check to see if the column number and collating sequence of the\n    ** index match the column number and collating sequence of the ORDER BY\n    ** clause entry.  Set isMatch to 1 if they both match. */\n    if( pOBExpr->iColumn==iColumn ){\n      if( zColl ){\n        pColl = sqlite3ExprCollSeq(pParse, pOBItem->pExpr);\n        if( !pColl ) pColl = db->pDfltColl;\n        isMatch = sqlite3StrICmp(pColl->zName, zColl)==0;\n      }else{\n        isMatch = 1;\n      }\n    }else{\n      isMatch = 0;\n    }\n\n    /* termSortOrder is 0 or 1 for whether or not the access loop should\n    ** run forward or backwards (respectively) in order to satisfy this \n    ** term of the ORDER BY clause. */\n    assert( pOBItem->sortOrder==0 || pOBItem->sortOrder==1 );\n    assert( iSortOrder==0 || iSortOrder==1 );\n    termSortOrder = iSortOrder ^ pOBItem->sortOrder;\n\n    /* If X is the column in the index and ORDER BY clause, check to see\n    ** if there are any X= or X IS NULL constraints in the WHERE clause. */\n    pConstraint = findTerm(p->pWC, base, iColumn, p->notReady,\n                           WO_EQ|WO_ISNULL|WO_IN, pIdx);\n    if( pConstraint==0 ){\n      isEq = 0;\n    }else if( (pConstraint->eOperator & WO_IN)!=0 ){\n      isEq = 0;\n    }else if( (pConstraint->eOperator & WO_ISNULL)!=0 ){\n      uniqueNotNull = 0;\n      isEq = 1;  /* \"X IS NULL\" means X has only a single value */\n    }else if( pConstraint->prereqRight==0 ){\n      isEq = 1;  /* Constraint \"X=constant\" means X has only a single value */\n    }else{\n      Expr *pRight = pConstraint->pExpr->pRight;\n      if( pRight->op==TK_COLUMN ){\n        WHERETRACE((\"       .. isOrderedColumn(tab=%d,col=%d)\",\n                    pRight->iTable, pRight->iColumn));\n        isEq = isOrderedColumn(p, pRight->iTable, pRight->iColumn);\n        WHERETRACE((\" -> isEq=%d\\n\", isEq));\n\n        /* If the constraint is of the form X=Y where Y is an ordered value\n        ** in an outer loop, then make sure the sort order of Y matches the\n        ** sort order required for X. */\n        if( isMatch && isEq>=2 && isEq!=pOBItem->sortOrder+2 ){\n          testcase( isEq==2 );\n          testcase( isEq==3 );\n          break;\n        }\n      }else{\n        isEq = 0;  /* \"X=expr\" places no ordering constraints on X */\n      }\n    }\n    if( !isMatch ){\n      if( isEq==0 ){\n        break;\n      }else{\n        continue;\n      }\n    }else if( isEq!=1 ){\n      if( sortOrder==2 ){\n        sortOrder = termSortOrder;\n      }else if( termSortOrder!=sortOrder ){\n        break;\n      }\n    }\n    j++;\n    pOBItem++;\n    if( iColumn<0 ){\n      seenRowid = 1;\n      break;\n    }else if( pTab->aCol[iColumn].notNull==0 && isEq!=1 ){\n      testcase( isEq==0 );\n      testcase( isEq==2 );\n      testcase( isEq==3 );\n      uniqueNotNull = 0;\n    }\n  }\n  if( seenRowid ){\n    uniqueNotNull = 1;\n  }else if( uniqueNotNull==0 || i<pIdx->nColumn ){\n    uniqueNotNull = 0;\n  }\n\n  /* If we have not found at least one ORDER BY term that matches the\n  ** index, then show no progress. */\n  if( pOBItem==&pOrderBy->a[nPriorSat] ) return nPriorSat;\n\n  /* Either the outer queries must generate rows where there are no two\n  ** rows with the same values in all ORDER BY columns, or else this\n  ** loop must generate just a single row of output.  Example:  Suppose\n  ** the outer loops generate A=1 and A=1, and this loop generates B=3\n  ** and B=4.  Then without the following test, ORDER BY A,B would \n  ** generate the wrong order output: 1,3 1,4 1,3 1,4\n  */\n  if( outerObUnique==0 && uniqueNotNull==0 ) return nPriorSat;\n  *pbObUnique = uniqueNotNull;\n\n  /* Return the necessary scan order back to the caller */\n  *pbRev = sortOrder & 1;\n\n  /* If there was an \"ORDER BY rowid\" term that matched, or it is only\n  ** possible for a single row from this table to match, then skip over\n  ** any additional ORDER BY terms dealing with this table.\n  */\n  if( uniqueNotNull ){\n    /* Advance j over additional ORDER BY terms associated with base */\n    WhereMaskSet *pMS = p->pWC->pMaskSet;\n    Bitmask m = ~getMask(pMS, base);\n    while( j<nTerm && (exprTableUsage(pMS, pOrderBy->a[j].pExpr)&m)==0 ){\n      j++;\n    }\n  }\n  return j;\n}\n\n/*\n** Find the best query plan for accessing a particular table.  Write the\n** best query plan and its cost into the p->cost.\n**\n** The lowest cost plan wins.  The cost is an estimate of the amount of\n** CPU and disk I/O needed to process the requested result.\n** Factors that influence cost include:\n**\n**    *  The estimated number of rows that will be retrieved.  (The\n**       fewer the better.)\n**\n**    *  Whether or not sorting must occur.\n**\n**    *  Whether or not there must be separate lookups in the\n**       index and in the main table.\n**\n** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in\n** the SQL statement, then this function only considers plans using the \n** named index. If no such plan is found, then the returned cost is\n** SQLITE_BIG_DBL. If a plan is found that uses the named index, \n** then the cost is calculated in the usual way.\n**\n** If a NOT INDEXED clause was attached to the table \n** in the SELECT statement, then no indexes are considered. However, the \n** selected plan may still take advantage of the built-in rowid primary key\n** index.\n*/\nstatic void bestBtreeIndex(WhereBestIdx *p){\n  Parse *pParse = p->pParse;  /* The parsing context */\n  WhereClause *pWC = p->pWC;  /* The WHERE clause */\n  struct SrcList_item *pSrc = p->pSrc; /* The FROM clause term to search */\n  int iCur = pSrc->iCursor;   /* The cursor of the table to be accessed */\n  Index *pProbe;              /* An index we are evaluating */\n  Index *pIdx;                /* Copy of pProbe, or zero for IPK index */\n  int eqTermMask;             /* Current mask of valid equality operators */\n  int idxEqTermMask;          /* Index mask of valid equality operators */\n  Index sPk;                  /* A fake index object for the primary key */\n  tRowcnt aiRowEstPk[2];      /* The aiRowEst[] value for the sPk index */\n  int aiColumnPk = -1;        /* The aColumn[] value for the sPk index */\n  int wsFlagMask;             /* Allowed flags in p->cost.plan.wsFlag */\n  int nPriorSat;              /* ORDER BY terms satisfied by outer loops */\n  int nOrderBy;               /* Number of ORDER BY terms */\n  char bSortInit;             /* Initializer for bSort in inner loop */\n  char bDistInit;             /* Initializer for bDist in inner loop */\n\n\n  /* Initialize the cost to a worst-case value */\n  memset(&p->cost, 0, sizeof(p->cost));\n  p->cost.rCost = SQLITE_BIG_DBL;\n\n  /* If the pSrc table is the right table of a LEFT JOIN then we may not\n  ** use an index to satisfy IS NULL constraints on that table.  This is\n  ** because columns might end up being NULL if the table does not match -\n  ** a circumstance which the index cannot help us discover.  Ticket #2177.\n  */\n  if( pSrc->jointype & JT_LEFT ){\n    idxEqTermMask = WO_EQ|WO_IN;\n  }else{\n    idxEqTermMask = WO_EQ|WO_IN|WO_ISNULL;\n  }\n\n  if( pSrc->pIndex ){\n    /* An INDEXED BY clause specifies a particular index to use */\n    pIdx = pProbe = pSrc->pIndex;\n    wsFlagMask = ~(WHERE_ROWID_EQ|WHERE_ROWID_RANGE);\n    eqTermMask = idxEqTermMask;\n  }else{\n    /* There is no INDEXED BY clause.  Create a fake Index object in local\n    ** variable sPk to represent the rowid primary key index.  Make this\n    ** fake index the first in a chain of Index objects with all of the real\n    ** indices to follow */\n    Index *pFirst;                  /* First of real indices on the table */\n    memset(&sPk, 0, sizeof(Index));\n    sPk.nColumn = 1;\n    sPk.aiColumn = &aiColumnPk;\n    sPk.aiRowEst = aiRowEstPk;\n    sPk.onError = OE_Replace;\n    sPk.pTable = pSrc->pTab;\n    aiRowEstPk[0] = pSrc->pTab->nRowEst;\n    aiRowEstPk[1] = 1;\n    pFirst = pSrc->pTab->pIndex;\n    if( pSrc->notIndexed==0 ){\n      /* The real indices of the table are only considered if the\n      ** NOT INDEXED qualifier is omitted from the FROM clause */\n      sPk.pNext = pFirst;\n    }\n    pProbe = &sPk;\n    wsFlagMask = ~(\n        WHERE_COLUMN_IN|WHERE_COLUMN_EQ|WHERE_COLUMN_NULL|WHERE_COLUMN_RANGE\n    );\n    eqTermMask = WO_EQ|WO_IN;\n    pIdx = 0;\n  }\n\n  nOrderBy = p->pOrderBy ? p->pOrderBy->nExpr : 0;\n  if( p->i ){\n    nPriorSat = p->aLevel[p->i-1].plan.nOBSat;\n    bSortInit = nPriorSat<nOrderBy;\n    bDistInit = 0;\n  }else{\n    nPriorSat = 0;\n    bSortInit = nOrderBy>0;\n    bDistInit = p->pDistinct!=0;\n  }\n\n  /* Loop over all indices looking for the best one to use\n  */\n  for(; pProbe; pIdx=pProbe=pProbe->pNext){\n    const tRowcnt * const aiRowEst = pProbe->aiRowEst;\n    WhereCost pc;               /* Cost of using pProbe */\n    double log10N = (double)1;  /* base-10 logarithm of nRow (inexact) */\n\n    /* The following variables are populated based on the properties of\n    ** index being evaluated. They are then used to determine the expected\n    ** cost and number of rows returned.\n    **\n    **  pc.plan.nEq: \n    **    Number of equality terms that can be implemented using the index.\n    **    In other words, the number of initial fields in the index that\n    **    are used in == or IN or NOT NULL constraints of the WHERE clause.\n    **\n    **  nInMul:  \n    **    The \"in-multiplier\". This is an estimate of how many seek operations \n    **    SQLite must perform on the index in question. For example, if the \n    **    WHERE clause is:\n    **\n    **      WHERE a IN (1, 2, 3) AND b IN (4, 5, 6)\n    **\n    **    SQLite must perform 9 lookups on an index on (a, b), so nInMul is \n    **    set to 9. Given the same schema and either of the following WHERE \n    **    clauses:\n    **\n    **      WHERE a =  1\n    **      WHERE a >= 2\n    **\n    **    nInMul is set to 1.\n    **\n    **    If there exists a WHERE term of the form \"x IN (SELECT ...)\", then \n    **    the sub-select is assumed to return 25 rows for the purposes of \n    **    determining nInMul.\n    **\n    **  bInEst:  \n    **    Set to true if there was at least one \"x IN (SELECT ...)\" term used \n    **    in determining the value of nInMul.  Note that the RHS of the\n    **    IN operator must be a SELECT, not a value list, for this variable\n    **    to be true.\n    **\n    **  rangeDiv:\n    **    An estimate of a divisor by which to reduce the search space due\n    **    to inequality constraints.  In the absence of sqlite_stat3 ANALYZE\n    **    data, a single inequality reduces the search space to 1/4rd its\n    **    original size (rangeDiv==4).  Two inequalities reduce the search\n    **    space to 1/16th of its original size (rangeDiv==16).\n    **\n    **  bSort:   \n    **    Boolean. True if there is an ORDER BY clause that will require an \n    **    external sort (i.e. scanning the index being evaluated will not \n    **    correctly order records).\n    **\n    **  bDist:\n    **    Boolean. True if there is a DISTINCT clause that will require an \n    **    external btree.\n    **\n    **  bLookup: \n    **    Boolean. True if a table lookup is required for each index entry\n    **    visited.  In other words, true if this is not a covering index.\n    **    This is always false for the rowid primary key index of a table.\n    **    For other indexes, it is true unless all the columns of the table\n    **    used by the SELECT statement are present in the index (such an\n    **    index is sometimes described as a covering index).\n    **    For example, given the index on (a, b), the second of the following \n    **    two queries requires table b-tree lookups in order to find the value\n    **    of column c, but the first does not because columns a and b are\n    **    both available in the index.\n    **\n    **             SELECT a, b    FROM tbl WHERE a = 1;\n    **             SELECT a, b, c FROM tbl WHERE a = 1;\n    */\n    int bInEst = 0;               /* True if \"x IN (SELECT...)\" seen */\n    int nInMul = 1;               /* Number of distinct equalities to lookup */\n    double rangeDiv = (double)1;  /* Estimated reduction in search space */\n    int nBound = 0;               /* Number of range constraints seen */\n    char bSort = bSortInit;       /* True if external sort required */\n    char bDist = bDistInit;       /* True if index cannot help with DISTINCT */\n    char bLookup = 0;             /* True if not a covering index */\n    WhereTerm *pTerm;             /* A single term of the WHERE clause */\n#ifdef SQLITE_ENABLE_STAT3\n    WhereTerm *pFirstTerm = 0;    /* First term matching the index */\n#endif\n\n    WHERETRACE((\n      \"   %s(%s):\\n\",\n      pSrc->pTab->zName, (pIdx ? pIdx->zName : \"ipk\")\n    ));\n    memset(&pc, 0, sizeof(pc));\n    pc.plan.nOBSat = nPriorSat;\n\n    /* Determine the values of pc.plan.nEq and nInMul */\n    for(pc.plan.nEq=0; pc.plan.nEq<pProbe->nColumn; pc.plan.nEq++){\n      int j = pProbe->aiColumn[pc.plan.nEq];\n      pTerm = findTerm(pWC, iCur, j, p->notReady, eqTermMask, pIdx);\n      if( pTerm==0 ) break;\n      pc.plan.wsFlags |= (WHERE_COLUMN_EQ|WHERE_ROWID_EQ);\n      testcase( pTerm->pWC!=pWC );\n      if( pTerm->eOperator & WO_IN ){\n        Expr *pExpr = pTerm->pExpr;\n        pc.plan.wsFlags |= WHERE_COLUMN_IN;\n        if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n          /* \"x IN (SELECT ...)\":  Assume the SELECT returns 25 rows */\n          nInMul *= 25;\n          bInEst = 1;\n        }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){\n          /* \"x IN (value, value, ...)\" */\n          nInMul *= pExpr->x.pList->nExpr;\n        }\n      }else if( pTerm->eOperator & WO_ISNULL ){\n        pc.plan.wsFlags |= WHERE_COLUMN_NULL;\n      }\n#ifdef SQLITE_ENABLE_STAT3\n      if( pc.plan.nEq==0 && pProbe->aSample ) pFirstTerm = pTerm;\n#endif\n      pc.used |= pTerm->prereqRight;\n    }\n \n    /* If the index being considered is UNIQUE, and there is an equality \n    ** constraint for all columns in the index, then this search will find\n    ** at most a single row. In this case set the WHERE_UNIQUE flag to \n    ** indicate this to the caller.\n    **\n    ** Otherwise, if the search may find more than one row, test to see if\n    ** there is a range constraint on indexed column (pc.plan.nEq+1) that\n    ** can be optimized using the index. \n    */\n    if( pc.plan.nEq==pProbe->nColumn && pProbe->onError!=OE_None ){\n      testcase( pc.plan.wsFlags & WHERE_COLUMN_IN );\n      testcase( pc.plan.wsFlags & WHERE_COLUMN_NULL );\n      if( (pc.plan.wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_NULL))==0 ){\n        pc.plan.wsFlags |= WHERE_UNIQUE;\n        if( p->i==0 || (p->aLevel[p->i-1].plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){\n          pc.plan.wsFlags |= WHERE_ALL_UNIQUE;\n        }\n      }\n    }else if( pProbe->bUnordered==0 ){\n      int j;\n      j = (pc.plan.nEq==pProbe->nColumn ? -1 : pProbe->aiColumn[pc.plan.nEq]);\n      if( findTerm(pWC, iCur, j, p->notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){\n        WhereTerm *pTop, *pBtm;\n        pTop = findTerm(pWC, iCur, j, p->notReady, WO_LT|WO_LE, pIdx);\n        pBtm = findTerm(pWC, iCur, j, p->notReady, WO_GT|WO_GE, pIdx);\n        whereRangeScanEst(pParse, pProbe, pc.plan.nEq, pBtm, pTop, &rangeDiv);\n        if( pTop ){\n          nBound = 1;\n          pc.plan.wsFlags |= WHERE_TOP_LIMIT;\n          pc.used |= pTop->prereqRight;\n          testcase( pTop->pWC!=pWC );\n        }\n        if( pBtm ){\n          nBound++;\n          pc.plan.wsFlags |= WHERE_BTM_LIMIT;\n          pc.used |= pBtm->prereqRight;\n          testcase( pBtm->pWC!=pWC );\n        }\n        pc.plan.wsFlags |= (WHERE_COLUMN_RANGE|WHERE_ROWID_RANGE);\n      }\n    }\n\n    /* If there is an ORDER BY clause and the index being considered will\n    ** naturally scan rows in the required order, set the appropriate flags\n    ** in pc.plan.wsFlags. Otherwise, if there is an ORDER BY clause but\n    ** the index will scan rows in a different order, set the bSort\n    ** variable.  */\n    if( bSort && (pSrc->jointype & JT_LEFT)==0 ){\n      int bRev = 2;\n      int bObUnique = 0;\n      WHERETRACE((\"      --> before isSortIndex: nPriorSat=%d\\n\",nPriorSat));\n      pc.plan.nOBSat = isSortingIndex(p, pProbe, iCur, &bRev, &bObUnique);\n      WHERETRACE((\"      --> after  isSortIndex: bRev=%d bObU=%d nOBSat=%d\\n\",\n                  bRev, bObUnique, pc.plan.nOBSat));\n      if( nPriorSat<pc.plan.nOBSat || (pc.plan.wsFlags & WHERE_ALL_UNIQUE)!=0 ){\n        pc.plan.wsFlags |= WHERE_ORDERED;\n        if( bObUnique ) pc.plan.wsFlags |= WHERE_OB_UNIQUE;\n      }\n      if( nOrderBy==pc.plan.nOBSat ){\n        bSort = 0;\n        pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE;\n      }\n      if( bRev & 1 ) pc.plan.wsFlags |= WHERE_REVERSE;\n    }\n\n    /* If there is a DISTINCT qualifier and this index will scan rows in\n    ** order of the DISTINCT expressions, clear bDist and set the appropriate\n    ** flags in pc.plan.wsFlags. */\n    if( bDist\n     && isDistinctIndex(pParse, pWC, pProbe, iCur, p->pDistinct, pc.plan.nEq)\n     && (pc.plan.wsFlags & WHERE_COLUMN_IN)==0\n    ){\n      bDist = 0;\n      pc.plan.wsFlags |= WHERE_ROWID_RANGE|WHERE_COLUMN_RANGE|WHERE_DISTINCT;\n    }\n\n    /* If currently calculating the cost of using an index (not the IPK\n    ** index), determine if all required column data may be obtained without \n    ** using the main table (i.e. if the index is a covering\n    ** index for this query). If it is, set the WHERE_IDX_ONLY flag in\n    ** pc.plan.wsFlags. Otherwise, set the bLookup variable to true.  */\n    if( pIdx ){\n      Bitmask m = pSrc->colUsed;\n      int j;\n      for(j=0; j<pIdx->nColumn; j++){\n        int x = pIdx->aiColumn[j];\n        if( x<BMS-1 ){\n          m &= ~(((Bitmask)1)<<x);\n        }\n      }\n      if( m==0 ){\n        pc.plan.wsFlags |= WHERE_IDX_ONLY;\n      }else{\n        bLookup = 1;\n      }\n    }\n\n    /*\n    ** Estimate the number of rows of output.  For an \"x IN (SELECT...)\"\n    ** constraint, do not let the estimate exceed half the rows in the table.\n    */\n    pc.plan.nRow = (double)(aiRowEst[pc.plan.nEq] * nInMul);\n    if( bInEst && pc.plan.nRow*2>aiRowEst[0] ){\n      pc.plan.nRow = aiRowEst[0]/2;\n      nInMul = (int)(pc.plan.nRow / aiRowEst[pc.plan.nEq]);\n    }\n\n#ifdef SQLITE_ENABLE_STAT3\n    /* If the constraint is of the form x=VALUE or x IN (E1,E2,...)\n    ** and we do not think that values of x are unique and if histogram\n    ** data is available for column x, then it might be possible\n    ** to get a better estimate on the number of rows based on\n    ** VALUE and how common that value is according to the histogram.\n    */\n    if( pc.plan.nRow>(double)1 && pc.plan.nEq==1\n     && pFirstTerm!=0 && aiRowEst[1]>1 ){\n      assert( (pFirstTerm->eOperator & (WO_EQ|WO_ISNULL|WO_IN))!=0 );\n      if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){\n        testcase( pFirstTerm->eOperator & WO_EQ );\n        testcase( pFirstTerm->eOperator & WO_EQUIV );\n        testcase( pFirstTerm->eOperator & WO_ISNULL );\n        whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight,\n                          &pc.plan.nRow);\n      }else if( bInEst==0 ){\n        assert( pFirstTerm->eOperator & WO_IN );\n        whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList,\n                       &pc.plan.nRow);\n      }\n    }\n#endif /* SQLITE_ENABLE_STAT3 */\n\n    /* Adjust the number of output rows and downward to reflect rows\n    ** that are excluded by range constraints.\n    */\n    pc.plan.nRow = pc.plan.nRow/rangeDiv;\n    if( pc.plan.nRow<1 ) pc.plan.nRow = 1;\n\n    /* Experiments run on real SQLite databases show that the time needed\n    ** to do a binary search to locate a row in a table or index is roughly\n    ** log10(N) times the time to move from one row to the next row within\n    ** a table or index.  The actual times can vary, with the size of\n    ** records being an important factor.  Both moves and searches are\n    ** slower with larger records, presumably because fewer records fit\n    ** on one page and hence more pages have to be fetched.\n    **\n    ** The ANALYZE command and the sqlite_stat1 and sqlite_stat3 tables do\n    ** not give us data on the relative sizes of table and index records.\n    ** So this computation assumes table records are about twice as big\n    ** as index records\n    */\n    if( (pc.plan.wsFlags&~(WHERE_REVERSE|WHERE_ORDERED|WHERE_OB_UNIQUE))\n                                                              ==WHERE_IDX_ONLY\n     && (pWC->wctrlFlags & WHERE_ONEPASS_DESIRED)==0\n     && sqlite3GlobalConfig.bUseCis\n     && OptimizationEnabled(pParse->db, SQLITE_CoverIdxScan)\n    ){\n      /* This index is not useful for indexing, but it is a covering index.\n      ** A full-scan of the index might be a little faster than a full-scan\n      ** of the table, so give this case a cost slightly less than a table\n      ** scan. */\n      pc.rCost = aiRowEst[0]*3 + pProbe->nColumn;\n      pc.plan.wsFlags |= WHERE_COVER_SCAN|WHERE_COLUMN_RANGE;\n    }else if( (pc.plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ){\n      /* The cost of a full table scan is a number of move operations equal\n      ** to the number of rows in the table.\n      **\n      ** We add an additional 4x penalty to full table scans.  This causes\n      ** the cost function to err on the side of choosing an index over\n      ** choosing a full scan.  This 4x full-scan penalty is an arguable\n      ** decision and one which we expect to revisit in the future.  But\n      ** it seems to be working well enough at the moment.\n      */\n      pc.rCost = aiRowEst[0]*4;\n      pc.plan.wsFlags &= ~WHERE_IDX_ONLY;\n      if( pIdx ){\n        pc.plan.wsFlags &= ~WHERE_ORDERED;\n        pc.plan.nOBSat = nPriorSat;\n      }\n    }else{\n      log10N = estLog(aiRowEst[0]);\n      pc.rCost = pc.plan.nRow;\n      if( pIdx ){\n        if( bLookup ){\n          /* For an index lookup followed by a table lookup:\n          **    nInMul index searches to find the start of each index range\n          **  + nRow steps through the index\n          **  + nRow table searches to lookup the table entry using the rowid\n          */\n          pc.rCost += (nInMul + pc.plan.nRow)*log10N;\n        }else{\n          /* For a covering index:\n          **     nInMul index searches to find the initial entry \n          **   + nRow steps through the index\n          */\n          pc.rCost += nInMul*log10N;\n        }\n      }else{\n        /* For a rowid primary key lookup:\n        **    nInMult table searches to find the initial entry for each range\n        **  + nRow steps through the table\n        */\n        pc.rCost += nInMul*log10N;\n      }\n    }\n\n    /* Add in the estimated cost of sorting the result.  Actual experimental\n    ** measurements of sorting performance in SQLite show that sorting time\n    ** adds C*N*log10(N) to the cost, where N is the number of rows to be \n    ** sorted and C is a factor between 1.95 and 4.3.  We will split the\n    ** difference and select C of 3.0.\n    */\n    if( bSort ){\n      double m = estLog(pc.plan.nRow*(nOrderBy - pc.plan.nOBSat)/nOrderBy);\n      m *= (double)(pc.plan.nOBSat ? 2 : 3);\n      pc.rCost += pc.plan.nRow*m;\n    }\n    if( bDist ){\n      pc.rCost += pc.plan.nRow*estLog(pc.plan.nRow)*3;\n    }\n\n    /**** Cost of using this index has now been computed ****/\n\n    /* If there are additional constraints on this table that cannot\n    ** be used with the current index, but which might lower the number\n    ** of output rows, adjust the nRow value accordingly.  This only \n    ** matters if the current index is the least costly, so do not bother\n    ** with this step if we already know this index will not be chosen.\n    ** Also, never reduce the output row count below 2 using this step.\n    **\n    ** It is critical that the notValid mask be used here instead of\n    ** the notReady mask.  When computing an \"optimal\" index, the notReady\n    ** mask will only have one bit set - the bit for the current table.\n    ** The notValid mask, on the other hand, always has all bits set for\n    ** tables that are not in outer loops.  If notReady is used here instead\n    ** of notValid, then a optimal index that depends on inner joins loops\n    ** might be selected even when there exists an optimal index that has\n    ** no such dependency.\n    */\n    if( pc.plan.nRow>2 && pc.rCost<=p->cost.rCost ){\n      int k;                       /* Loop counter */\n      int nSkipEq = pc.plan.nEq;   /* Number of == constraints to skip */\n      int nSkipRange = nBound;     /* Number of < constraints to skip */\n      Bitmask thisTab;             /* Bitmap for pSrc */\n\n      thisTab = getMask(pWC->pMaskSet, iCur);\n      for(pTerm=pWC->a, k=pWC->nTerm; pc.plan.nRow>2 && k; k--, pTerm++){\n        if( pTerm->wtFlags & TERM_VIRTUAL ) continue;\n        if( (pTerm->prereqAll & p->notValid)!=thisTab ) continue;\n        if( pTerm->eOperator & (WO_EQ|WO_IN|WO_ISNULL) ){\n          if( nSkipEq ){\n            /* Ignore the first pc.plan.nEq equality matches since the index\n            ** has already accounted for these */\n            nSkipEq--;\n          }else{\n            /* Assume each additional equality match reduces the result\n            ** set size by a factor of 10 */\n            pc.plan.nRow /= 10;\n          }\n        }else if( pTerm->eOperator & (WO_LT|WO_LE|WO_GT|WO_GE) ){\n          if( nSkipRange ){\n            /* Ignore the first nSkipRange range constraints since the index\n            ** has already accounted for these */\n            nSkipRange--;\n          }else{\n            /* Assume each additional range constraint reduces the result\n            ** set size by a factor of 3.  Indexed range constraints reduce\n            ** the search space by a larger factor: 4.  We make indexed range\n            ** more selective intentionally because of the subjective \n            ** observation that indexed range constraints really are more\n            ** selective in practice, on average. */\n            pc.plan.nRow /= 3;\n          }\n        }else if( (pTerm->eOperator & WO_NOOP)==0 ){\n          /* Any other expression lowers the output row count by half */\n          pc.plan.nRow /= 2;\n        }\n      }\n      if( pc.plan.nRow<2 ) pc.plan.nRow = 2;\n    }\n\n\n    WHERETRACE((\n      \"      nEq=%d nInMul=%d rangeDiv=%d bSort=%d bLookup=%d wsFlags=0x%08x\\n\"\n      \"      notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f\\n\"\n      \"      used=0x%llx nOBSat=%d\\n\",\n      pc.plan.nEq, nInMul, (int)rangeDiv, bSort, bLookup, pc.plan.wsFlags,\n      p->notReady, log10N, pc.plan.nRow, pc.rCost, pc.used,\n      pc.plan.nOBSat\n    ));\n\n    /* If this index is the best we have seen so far, then record this\n    ** index and its cost in the p->cost structure.\n    */\n    if( (!pIdx || pc.plan.wsFlags) && compareCost(&pc, &p->cost) ){\n      p->cost = pc;\n      p->cost.plan.wsFlags &= wsFlagMask;\n      p->cost.plan.u.pIdx = pIdx;\n    }\n\n    /* If there was an INDEXED BY clause, then only that one index is\n    ** considered. */\n    if( pSrc->pIndex ) break;\n\n    /* Reset masks for the next index in the loop */\n    wsFlagMask = ~(WHERE_ROWID_EQ|WHERE_ROWID_RANGE);\n    eqTermMask = idxEqTermMask;\n  }\n\n  /* If there is no ORDER BY clause and the SQLITE_ReverseOrder flag\n  ** is set, then reverse the order that the index will be scanned\n  ** in. This is used for application testing, to help find cases\n  ** where application behavior depends on the (undefined) order that\n  ** SQLite outputs rows in in the absence of an ORDER BY clause.  */\n  if( !p->pOrderBy && pParse->db->flags & SQLITE_ReverseOrder ){\n    p->cost.plan.wsFlags |= WHERE_REVERSE;\n  }\n\n  assert( p->pOrderBy || (p->cost.plan.wsFlags&WHERE_ORDERED)==0 );\n  assert( p->cost.plan.u.pIdx==0 || (p->cost.plan.wsFlags&WHERE_ROWID_EQ)==0 );\n  assert( pSrc->pIndex==0 \n       || p->cost.plan.u.pIdx==0 \n       || p->cost.plan.u.pIdx==pSrc->pIndex \n  );\n\n  WHERETRACE((\"   best index is %s cost=%.1f\\n\",\n         p->cost.plan.u.pIdx ? p->cost.plan.u.pIdx->zName : \"ipk\",\n         p->cost.rCost));\n  \n  bestOrClauseIndex(p);\n  bestAutomaticIndex(p);\n  p->cost.plan.wsFlags |= eqTermMask;\n}\n\n/*\n** Find the query plan for accessing table pSrc->pTab. Write the\n** best query plan and its cost into the WhereCost object supplied \n** as the last parameter. This function may calculate the cost of\n** both real and virtual table scans.\n**\n** This function does not take ORDER BY or DISTINCT into account.  Nor\n** does it remember the virtual table query plan.  All it does is compute\n** the cost while determining if an OR optimization is applicable.  The\n** details will be reconsidered later if the optimization is found to be\n** applicable.\n*/\nstatic void bestIndex(WhereBestIdx *p){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(p->pSrc->pTab) ){\n    sqlite3_index_info *pIdxInfo = 0;\n    p->ppIdxInfo = &pIdxInfo;\n    bestVirtualIndex(p);\n    assert( pIdxInfo!=0 || p->pParse->db->mallocFailed );\n    if( pIdxInfo && pIdxInfo->needToFreeIdxStr ){\n      sqlite3_free(pIdxInfo->idxStr);\n    }\n    sqlite3DbFree(p->pParse->db, pIdxInfo);\n  }else\n#endif\n  {\n    bestBtreeIndex(p);\n  }\n}\n\n/*\n** Disable a term in the WHERE clause.  Except, do not disable the term\n** if it controls a LEFT OUTER JOIN and it did not originate in the ON\n** or USING clause of that join.\n**\n** Consider the term t2.z='ok' in the following queries:\n**\n**   (1)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'\n**   (2)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'\n**   (3)  SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'\n**\n** The t2.z='ok' is disabled in the in (2) because it originates\n** in the ON clause.  The term is disabled in (3) because it is not part\n** of a LEFT OUTER JOIN.  In (1), the term is not disabled.\n**\n** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are\n** completely satisfied by indices.\n**\n** Disabling a term causes that term to not be tested in the inner loop\n** of the join.  Disabling is an optimization.  When terms are satisfied\n** by indices, we disable them to prevent redundant tests in the inner\n** loop.  We would get the correct results if nothing were ever disabled,\n** but joins might run a little slower.  The trick is to disable as much\n** as we can without disabling too much.  If we disabled in (1), we'd get\n** the wrong answer.  See ticket #813.\n*/\nstatic void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){\n  if( pTerm\n      && (pTerm->wtFlags & TERM_CODED)==0\n      && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n  ){\n    pTerm->wtFlags |= TERM_CODED;\n    if( pTerm->iParent>=0 ){\n      WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent];\n      if( (--pOther->nChild)==0 ){\n        disableTerm(pLevel, pOther);\n      }\n    }\n  }\n}\n\n/*\n** Code an OP_Affinity opcode to apply the column affinity string zAff\n** to the n registers starting at base. \n**\n** As an optimization, SQLITE_AFF_NONE entries (which are no-ops) at the\n** beginning and end of zAff are ignored.  If all entries in zAff are\n** SQLITE_AFF_NONE, then no code gets generated.\n**\n** This routine makes its own copy of zAff so that the caller is free\n** to modify zAff after this routine returns.\n*/\nstatic void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){\n  Vdbe *v = pParse->pVdbe;\n  if( zAff==0 ){\n    assert( pParse->db->mallocFailed );\n    return;\n  }\n  assert( v!=0 );\n\n  /* Adjust base and n to skip over SQLITE_AFF_NONE entries at the beginning\n  ** and end of the affinity string.\n  */\n  while( n>0 && zAff[0]==SQLITE_AFF_NONE ){\n    n--;\n    base++;\n    zAff++;\n  }\n  while( n>1 && zAff[n-1]==SQLITE_AFF_NONE ){\n    n--;\n  }\n\n  /* Code the OP_Affinity opcode if there is anything left to do. */\n  if( n>0 ){\n    sqlite3VdbeAddOp2(v, OP_Affinity, base, n);\n    sqlite3VdbeChangeP4(v, -1, zAff, n);\n    sqlite3ExprCacheAffinityChange(pParse, base, n);\n  }\n}\n\n\n/*\n** Generate code for a single equality term of the WHERE clause.  An equality\n** term can be either X=expr or X IN (...).   pTerm is the term to be \n** coded.\n**\n** The current value for the constraint is left in register iReg.\n**\n** For a constraint of the form X=expr, the expression is evaluated and its\n** result is left on the stack.  For constraints of the form X IN (...)\n** this routine sets up a loop that will iterate over all values of X.\n*/\nstatic int codeEqualityTerm(\n  Parse *pParse,      /* The parsing context */\n  WhereTerm *pTerm,   /* The term of the WHERE clause to be coded */\n  WhereLevel *pLevel, /* The level of the FROM clause we are working on */\n  int iEq,            /* Index of the equality term within this level */\n  int iTarget         /* Attempt to leave results in this register */\n){\n  Expr *pX = pTerm->pExpr;\n  Vdbe *v = pParse->pVdbe;\n  int iReg;                  /* Register holding results */\n\n  assert( iTarget>0 );\n  if( pX->op==TK_EQ ){\n    iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);\n  }else if( pX->op==TK_ISNULL ){\n    iReg = iTarget;\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);\n#ifndef SQLITE_OMIT_SUBQUERY\n  }else{\n    int eType;\n    int iTab;\n    struct InLoop *pIn;\n    u8 bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0;\n\n    if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 \n      && pLevel->plan.u.pIdx->aSortOrder[iEq]\n    ){\n      testcase( iEq==0 );\n      testcase( iEq==pLevel->plan.u.pIdx->nColumn-1 );\n      testcase( iEq>0 && iEq+1<pLevel->plan.u.pIdx->nColumn );\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    assert( pX->op==TK_IN );\n    iReg = iTarget;\n    eType = sqlite3FindInIndex(pParse, pX, 0);\n    if( eType==IN_INDEX_INDEX_DESC ){\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    iTab = pX->iTable;\n    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);\n    assert( pLevel->plan.wsFlags & WHERE_IN_ABLE );\n    if( pLevel->u.in.nIn==0 ){\n      pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n    }\n    pLevel->u.in.nIn++;\n    pLevel->u.in.aInLoop =\n       sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,\n                              sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);\n    pIn = pLevel->u.in.aInLoop;\n    if( pIn ){\n      pIn += pLevel->u.in.nIn - 1;\n      pIn->iCur = iTab;\n      if( eType==IN_INDEX_ROWID ){\n        pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iReg);\n      }else{\n        pIn->addrInTop = sqlite3VdbeAddOp3(v, OP_Column, iTab, 0, iReg);\n      }\n      pIn->eEndLoopOp = bRev ? OP_Prev : OP_Next;\n      sqlite3VdbeAddOp1(v, OP_IsNull, iReg);\n    }else{\n      pLevel->u.in.nIn = 0;\n    }\n#endif\n  }\n  disableTerm(pLevel, pTerm);\n  return iReg;\n}\n\n/*\n** Generate code that will evaluate all == and IN constraints for an\n** index.\n**\n** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).\n** Suppose the WHERE clause is this:  a==5 AND b IN (1,2,3) AND c>5 AND c<10\n** The index has as many as three equality constraints, but in this\n** example, the third \"c\" value is an inequality.  So only two \n** constraints are coded.  This routine will generate code to evaluate\n** a==5 and b IN (1,2,3).  The current values for a and b will be stored\n** in consecutive registers and the index of the first register is returned.\n**\n** In the example above nEq==2.  But this subroutine works for any value\n** of nEq including 0.  If nEq==0, this routine is nearly a no-op.\n** The only thing it does is allocate the pLevel->iMem memory cell and\n** compute the affinity string.\n**\n** This routine always allocates at least one memory cell and returns\n** the index of that memory cell. The code that\n** calls this routine will use that memory cell to store the termination\n** key value of the loop.  If one or more IN operators appear, then\n** this routine allocates an additional nEq memory cells for internal\n** use.\n**\n** Before returning, *pzAff is set to point to a buffer containing a\n** copy of the column affinity string of the index allocated using\n** sqlite3DbMalloc(). Except, entries in the copy of the string associated\n** with equality constraints that use NONE affinity are set to\n** SQLITE_AFF_NONE. This is to deal with SQL such as the following:\n**\n**   CREATE TABLE t1(a TEXT PRIMARY KEY, b);\n**   SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;\n**\n** In the example above, the index on t1(a) has TEXT affinity. But since\n** the right hand side of the equality constraint (t2.b) has NONE affinity,\n** no conversion should be attempted before using a t2.b value as part of\n** a key to search the index. Hence the first byte in the returned affinity\n** string in this example would be set to SQLITE_AFF_NONE.\n*/\nstatic int codeAllEqualityTerms(\n  Parse *pParse,        /* Parsing context */\n  WhereLevel *pLevel,   /* Which nested loop of the FROM we are coding */\n  WhereClause *pWC,     /* The WHERE clause */\n  Bitmask notReady,     /* Which parts of FROM have not yet been coded */\n  int nExtraReg,        /* Number of extra registers to allocate */\n  char **pzAff          /* OUT: Set to point to affinity string */\n){\n  int nEq = pLevel->plan.nEq;   /* The number of == or IN constraints to code */\n  Vdbe *v = pParse->pVdbe;      /* The vm under construction */\n  Index *pIdx;                  /* The index being used for this loop */\n  int iCur = pLevel->iTabCur;   /* The cursor of the table */\n  WhereTerm *pTerm;             /* A single constraint term */\n  int j;                        /* Loop counter */\n  int regBase;                  /* Base register */\n  int nReg;                     /* Number of registers to allocate */\n  char *zAff;                   /* Affinity string to return */\n\n  /* This module is only called on query plans that use an index. */\n  assert( pLevel->plan.wsFlags & WHERE_INDEXED );\n  pIdx = pLevel->plan.u.pIdx;\n\n  /* Figure out how many memory cells we will need then allocate them.\n  */\n  regBase = pParse->nMem + 1;\n  nReg = pLevel->plan.nEq + nExtraReg;\n  pParse->nMem += nReg;\n\n  zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx));\n  if( !zAff ){\n    pParse->db->mallocFailed = 1;\n  }\n\n  /* Evaluate the equality constraints\n  */\n  assert( pIdx->nColumn>=nEq );\n  for(j=0; j<nEq; j++){\n    int r1;\n    int k = pIdx->aiColumn[j];\n    pTerm = findTerm(pWC, iCur, k, notReady, pLevel->plan.wsFlags, pIdx);\n    if( pTerm==0 ) break;\n    /* The following true for indices with redundant columns. \n    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */\n    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, regBase+j);\n    if( r1!=regBase+j ){\n      if( nReg==1 ){\n        sqlite3ReleaseTempReg(pParse, regBase);\n        regBase = r1;\n      }else{\n        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);\n      }\n    }\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_IN );\n    if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){\n      Expr *pRight = pTerm->pExpr->pRight;\n      sqlite3ExprCodeIsNullJump(v, pRight, regBase+j, pLevel->addrBrk);\n      if( zAff ){\n        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_NONE ){\n          zAff[j] = SQLITE_AFF_NONE;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){\n          zAff[j] = SQLITE_AFF_NONE;\n        }\n      }\n    }\n  }\n  *pzAff = zAff;\n  return regBase;\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** This routine is a helper for explainIndexRange() below\n**\n** pStr holds the text of an expression that we are building up one term\n** at a time.  This routine adds a new term to the end of the expression.\n** Terms are separated by AND so add the \"AND\" text for second and subsequent\n** terms only.\n*/\nstatic void explainAppendTerm(\n  StrAccum *pStr,             /* The text expression being built */\n  int iTerm,                  /* Index of this term.  First is zero */\n  const char *zColumn,        /* Name of the column */\n  const char *zOp             /* Name of the operator */\n){\n  if( iTerm ) sqlite3StrAccumAppend(pStr, \" AND \", 5);\n  sqlite3StrAccumAppend(pStr, zColumn, -1);\n  sqlite3StrAccumAppend(pStr, zOp, 1);\n  sqlite3StrAccumAppend(pStr, \"?\", 1);\n}\n\n/*\n** Argument pLevel describes a strategy for scanning table pTab. This \n** function returns a pointer to a string buffer containing a description\n** of the subset of table rows scanned by the strategy in the form of an\n** SQL expression. Or, if all rows are scanned, NULL is returned.\n**\n** For example, if the query:\n**\n**   SELECT * FROM t1 WHERE a=1 AND b>2;\n**\n** is run and there is an index on (a, b), then this function returns a\n** string similar to:\n**\n**   \"a=? AND b>?\"\n**\n** The returned pointer points to memory obtained from sqlite3DbMalloc().\n** It is the responsibility of the caller to free the buffer when it is\n** no longer required.\n*/\nstatic char *explainIndexRange(sqlite3 *db, WhereLevel *pLevel, Table *pTab){\n  WherePlan *pPlan = &pLevel->plan;\n  Index *pIndex = pPlan->u.pIdx;\n  int nEq = pPlan->nEq;\n  int i, j;\n  Column *aCol = pTab->aCol;\n  int *aiColumn = pIndex->aiColumn;\n  StrAccum txt;\n\n  if( nEq==0 && (pPlan->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ){\n    return 0;\n  }\n  sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH);\n  txt.db = db;\n  sqlite3StrAccumAppend(&txt, \" (\", 2);\n  for(i=0; i<nEq; i++){\n    explainAppendTerm(&txt, i, aCol[aiColumn[i]].zName, \"=\");\n  }\n\n  j = i;\n  if( pPlan->wsFlags&WHERE_BTM_LIMIT ){\n    char *z = (j==pIndex->nColumn ) ? \"rowid\" : aCol[aiColumn[j]].zName;\n    explainAppendTerm(&txt, i++, z, \">\");\n  }\n  if( pPlan->wsFlags&WHERE_TOP_LIMIT ){\n    char *z = (j==pIndex->nColumn ) ? \"rowid\" : aCol[aiColumn[j]].zName;\n    explainAppendTerm(&txt, i, z, \"<\");\n  }\n  sqlite3StrAccumAppend(&txt, \")\", 1);\n  return sqlite3StrAccumFinish(&txt);\n}\n\n/*\n** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN\n** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single\n** record is added to the output to describe the table scan strategy in \n** pLevel.\n*/\nstatic void explainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  int iLevel,                     /* Value for \"level\" column of output */\n  int iFrom,                      /* Value for \"from\" column of output */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n){\n  if( pParse->explain==2 ){\n    u32 flags = pLevel->plan.wsFlags;\n    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];\n    Vdbe *v = pParse->pVdbe;      /* VM being constructed */\n    sqlite3 *db = pParse->db;     /* Database handle */\n    char *zMsg;                   /* Text to add to EQP output */\n    sqlite3_int64 nRow;           /* Expected number of rows visited by scan */\n    int iId = pParse->iSelectId;  /* Select id (left-most output column) */\n    int isSearch;                 /* True for a SEARCH. False for SCAN. */\n\n    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return;\n\n    isSearch = (pLevel->plan.nEq>0)\n             || (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0\n             || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));\n\n    zMsg = sqlite3MPrintf(db, \"%s\", isSearch?\"SEARCH\":\"SCAN\");\n    if( pItem->pSelect ){\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s SUBQUERY %d\", zMsg,pItem->iSelectId);\n    }else{\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s TABLE %s\", zMsg, pItem->zName);\n    }\n\n    if( pItem->zAlias ){\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s AS %s\", zMsg, pItem->zAlias);\n    }\n    if( (flags & WHERE_INDEXED)!=0 ){\n      char *zWhere = explainIndexRange(db, pLevel, pItem->pTab);\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s USING %s%sINDEX%s%s%s\", zMsg, \n          ((flags & WHERE_TEMP_INDEX)?\"AUTOMATIC \":\"\"),\n          ((flags & WHERE_IDX_ONLY)?\"COVERING \":\"\"),\n          ((flags & WHERE_TEMP_INDEX)?\"\":\" \"),\n          ((flags & WHERE_TEMP_INDEX)?\"\": pLevel->plan.u.pIdx->zName),\n          zWhere\n      );\n      sqlite3DbFree(db, zWhere);\n    }else if( flags & (WHERE_ROWID_EQ|WHERE_ROWID_RANGE) ){\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s USING INTEGER PRIMARY KEY\", zMsg);\n\n      if( flags&WHERE_ROWID_EQ ){\n        zMsg = sqlite3MAppendf(db, zMsg, \"%s (rowid=?)\", zMsg);\n      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){\n        zMsg = sqlite3MAppendf(db, zMsg, \"%s (rowid>? AND rowid<?)\", zMsg);\n      }else if( flags&WHERE_BTM_LIMIT ){\n        zMsg = sqlite3MAppendf(db, zMsg, \"%s (rowid>?)\", zMsg);\n      }else if( flags&WHERE_TOP_LIMIT ){\n        zMsg = sqlite3MAppendf(db, zMsg, \"%s (rowid<?)\", zMsg);\n      }\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){\n      sqlite3_index_info *pVtabIdx = pLevel->plan.u.pVtabIdx;\n      zMsg = sqlite3MAppendf(db, zMsg, \"%s VIRTUAL TABLE INDEX %d:%s\", zMsg,\n                  pVtabIdx->idxNum, pVtabIdx->idxStr);\n    }\n#endif\n    if( wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX) ){\n      testcase( wctrlFlags & WHERE_ORDERBY_MIN );\n      nRow = 1;\n    }else{\n      nRow = (sqlite3_int64)pLevel->plan.nRow;\n    }\n    zMsg = sqlite3MAppendf(db, zMsg, \"%s (~%lld rows)\", zMsg, nRow);\n    sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg, P4_DYNAMIC);\n  }\n}\n#else\n# define explainOneScan(u,v,w,x,y,z)\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n\n/*\n** Generate code for the start of the iLevel-th loop in the WHERE clause\n** implementation described by pWInfo.\n*/\nstatic Bitmask codeOneLoopStart(\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  u16 wctrlFlags,      /* One of the WHERE_* flags defined in sqliteInt.h */\n  Bitmask notReady     /* Which tables are currently available */\n){\n  int j, k;            /* Loop counters */\n  int iCur;            /* The VDBE cursor for the table */\n  int addrNxt;         /* Where to jump to continue with the next IN case */\n  int omitTable;       /* True if we use the index only */\n  int bRev;            /* True if we need to scan in reverse order */\n  WhereLevel *pLevel;  /* The where level to be coded */\n  WhereClause *pWC;    /* Decomposition of the entire WHERE clause */\n  WhereTerm *pTerm;               /* A WHERE clause term */\n  Parse *pParse;                  /* Parsing context */\n  Vdbe *v;                        /* The prepared stmt under constructions */\n  struct SrcList_item *pTabItem;  /* FROM clause term being coded */\n  int addrBrk;                    /* Jump here to break out of the loop */\n  int addrCont;                   /* Jump here to continue with next cycle */\n  int iRowidReg = 0;        /* Rowid is stored in this register, if not zero */\n  int iReleaseReg = 0;      /* Temp register to free before returning */\n  Bitmask newNotReady;      /* Return value */\n\n  pParse = pWInfo->pParse;\n  v = pParse->pVdbe;\n  pWC = pWInfo->pWC;\n  pLevel = &pWInfo->a[iLevel];\n  pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];\n  iCur = pTabItem->iCursor;\n  bRev = (pLevel->plan.wsFlags & WHERE_REVERSE)!=0;\n  omitTable = (pLevel->plan.wsFlags & WHERE_IDX_ONLY)!=0 \n           && (wctrlFlags & WHERE_FORCE_TABLE)==0;\n  VdbeNoopComment((v, \"Begin Join Loop %d\", iLevel));\n\n  /* Create labels for the \"break\" and \"continue\" instructions\n  ** for the current loop.  Jump to addrBrk to break out of a loop.\n  ** Jump to cont to go immediately to the next iteration of the\n  ** loop.\n  **\n  ** When there is an IN operator, we also have a \"addrNxt\" label that\n  ** means to continue with the next IN value combination.  When\n  ** there are no IN operators in the constraints, the \"addrNxt\" label\n  ** is the same as \"addrBrk\".\n  */\n  addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n  addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);\n\n  /* If this is the right table of a LEFT OUTER JOIN, allocate and\n  ** initialize a memory cell that records if this table matches any\n  ** row of the left table of the join.\n  */\n  if( pLevel->iFrom>0 && (pTabItem[0].jointype & JT_LEFT)!=0 ){\n    pLevel->iLeftJoin = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);\n    VdbeComment((v, \"init LEFT JOIN no-match flag\"));\n  }\n\n  /* Special case of a FROM clause subquery implemented as a co-routine */\n  if( pTabItem->viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    sqlite3VdbeAddOp2(v, OP_Integer, pTabItem->addrFillSub-1, regYield);\n    pLevel->p2 =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);\n    VdbeComment((v, \"next row of co-routine %s\", pTabItem->pTab->zName));\n    sqlite3VdbeAddOp2(v, OP_If, regYield+1, addrBrk);\n    pLevel->op = OP_Goto;\n  }else\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if(  (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n    /* Case 0:  The table is a virtual-table.  Use the VFilter and VNext\n    **          to access the data.\n    */\n    int iReg;   /* P3 Value for OP_VFilter */\n    int addrNotFound;\n    sqlite3_index_info *pVtabIdx = pLevel->plan.u.pVtabIdx;\n    int nConstraint = pVtabIdx->nConstraint;\n    struct sqlite3_index_constraint_usage *aUsage =\n                                                pVtabIdx->aConstraintUsage;\n    const struct sqlite3_index_constraint *aConstraint =\n                                                pVtabIdx->aConstraint;\n\n    sqlite3ExprCachePush(pParse);\n    iReg = sqlite3GetTempRange(pParse, nConstraint+2);\n    addrNotFound = pLevel->addrBrk;\n    for(j=1; j<=nConstraint; j++){\n      for(k=0; k<nConstraint; k++){\n        if( aUsage[k].argvIndex==j ){\n          int iTarget = iReg+j+1;\n          pTerm = &pWC->a[aConstraint[k].iTermOffset];\n          if( pTerm->eOperator & WO_IN ){\n            codeEqualityTerm(pParse, pTerm, pLevel, k, iTarget);\n            addrNotFound = pLevel->addrNxt;\n          }else{\n            sqlite3ExprCode(pParse, pTerm->pExpr->pRight, iTarget);\n          }\n          break;\n        }\n      }\n      if( k==nConstraint ) break;\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, pVtabIdx->idxNum, iReg);\n    sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1);\n    sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg, pVtabIdx->idxStr,\n                      pVtabIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC);\n    pVtabIdx->needToFreeIdxStr = 0;\n    for(j=0; j<nConstraint; j++){\n      if( aUsage[j].omit ){\n        int iTerm = aConstraint[j].iTermOffset;\n        disableTerm(pLevel, &pWC->a[iTerm]);\n      }\n    }\n    pLevel->op = OP_VNext;\n    pLevel->p1 = iCur;\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);\n    sqlite3ExprCachePop(pParse, 1);\n  }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  if( pLevel->plan.wsFlags & WHERE_ROWID_EQ ){\n    /* Case 1:  We can directly reference a single row using an\n    **          equality comparison against the ROWID field.  Or\n    **          we reference multiple rows using a \"rowid IN (...)\"\n    **          construct.\n    */\n    iReleaseReg = sqlite3GetTempReg(pParse);\n    pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0);\n    assert( pTerm!=0 );\n    assert( pTerm->pExpr!=0 );\n    assert( omitTable==0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, iReleaseReg);\n    addrNxt = pLevel->addrNxt;\n    sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt);\n    sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg);\n    sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);\n    sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n    VdbeComment((v, \"pk\"));\n    pLevel->op = OP_Noop;\n  }else if( pLevel->plan.wsFlags & WHERE_ROWID_RANGE ){\n    /* Case 2:  We have an inequality comparison against the ROWID field.\n    */\n    int testOp = OP_Noop;\n    int start;\n    int memEndValue = 0;\n    WhereTerm *pStart, *pEnd;\n\n    assert( omitTable==0 );\n    pStart = findTerm(pWC, iCur, -1, notReady, WO_GT|WO_GE, 0);\n    pEnd = findTerm(pWC, iCur, -1, notReady, WO_LT|WO_LE, 0);\n    if( bRev ){\n      pTerm = pStart;\n      pStart = pEnd;\n      pEnd = pTerm;\n    }\n    if( pStart ){\n      Expr *pX;             /* The expression that defines the start bound */\n      int r1, rTemp;        /* Registers for holding the start boundary */\n\n      /* The following constant maps TK_xx codes into corresponding \n      ** seek opcodes.  It depends on a particular ordering of TK_xx\n      */\n      const u8 aMoveOp[] = {\n           /* TK_GT */  OP_SeekGt,\n           /* TK_LE */  OP_SeekLe,\n           /* TK_LT */  OP_SeekLt,\n           /* TK_GE */  OP_SeekGe\n      };\n      assert( TK_LE==TK_GT+1 );      /* Make sure the ordering.. */\n      assert( TK_LT==TK_GT+2 );      /*  ... of the TK_xx values... */\n      assert( TK_GE==TK_GT+3 );      /*  ... is correcct. */\n\n      testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n      pX = pStart->pExpr;\n      assert( pX!=0 );\n      assert( pStart->leftCursor==iCur );\n      r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);\n      sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1);\n      VdbeComment((v, \"pk\"));\n      sqlite3ExprCacheAffinityChange(pParse, r1, 1);\n      sqlite3ReleaseTempReg(pParse, rTemp);\n      disableTerm(pLevel, pStart);\n    }else{\n      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);\n    }\n    if( pEnd ){\n      Expr *pX;\n      pX = pEnd->pExpr;\n      assert( pX!=0 );\n      assert( pEnd->leftCursor==iCur );\n      testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n      memEndValue = ++pParse->nMem;\n      sqlite3ExprCode(pParse, pX->pRight, memEndValue);\n      if( pX->op==TK_LT || pX->op==TK_GT ){\n        testOp = bRev ? OP_Le : OP_Ge;\n      }else{\n        testOp = bRev ? OP_Lt : OP_Gt;\n      }\n      disableTerm(pLevel, pEnd);\n    }\n    start = sqlite3VdbeCurrentAddr(v);\n    pLevel->op = bRev ? OP_Prev : OP_Next;\n    pLevel->p1 = iCur;\n    pLevel->p2 = start;\n    if( pStart==0 && pEnd==0 ){\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }else{\n      assert( pLevel->p5==0 );\n    }\n    if( testOp!=OP_Noop ){\n      iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);\n      sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);\n      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);\n    }\n  }else if( pLevel->plan.wsFlags & (WHERE_COLUMN_RANGE|WHERE_COLUMN_EQ) ){\n    /* Case 3: A scan using an index.\n    **\n    **         The WHERE clause may contain zero or more equality \n    **         terms (\"==\" or \"IN\" operators) that refer to the N\n    **         left-most columns of the index. It may also contain\n    **         inequality constraints (>, <, >= or <=) on the indexed\n    **         column that immediately follows the N equalities. Only \n    **         the right-most column can be an inequality - the rest must\n    **         use the \"==\" and \"IN\" operators. For example, if the \n    **         index is on (x,y,z), then the following clauses are all \n    **         optimized:\n    **\n    **            x=5\n    **            x=5 AND y=10\n    **            x=5 AND y<10\n    **            x=5 AND y>5 AND y<10\n    **            x=5 AND y=5 AND z<=10\n    **\n    **         The z<10 term of the following cannot be used, only\n    **         the x=5 term:\n    **\n    **            x=5 AND z<10\n    **\n    **         N may be zero if there are inequality constraints.\n    **         If there are no inequality constraints, then N is at\n    **         least one.\n    **\n    **         This case is also used when there are no WHERE clause\n    **         constraints but an index is selected anyway, in order\n    **         to force the output order to conform to an ORDER BY.\n    */  \n    static const u8 aStartOp[] = {\n      0,\n      0,\n      OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */\n      OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */\n      OP_SeekGt,           /* 4: (start_constraints  && !startEq && !bRev) */\n      OP_SeekLt,           /* 5: (start_constraints  && !startEq &&  bRev) */\n      OP_SeekGe,           /* 6: (start_constraints  &&  startEq && !bRev) */\n      OP_SeekLe            /* 7: (start_constraints  &&  startEq &&  bRev) */\n    };\n    static const u8 aEndOp[] = {\n      OP_Noop,             /* 0: (!end_constraints) */\n      OP_IdxGE,            /* 1: (end_constraints && !bRev) */\n      OP_IdxLT             /* 2: (end_constraints && bRev) */\n    };\n    int nEq = pLevel->plan.nEq;  /* Number of == or IN terms */\n    int isMinQuery = 0;          /* If this is an optimized SELECT min(x).. */\n    int regBase;                 /* Base register holding constraint values */\n    int r1;                      /* Temp register */\n    WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */\n    WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */\n    int startEq;                 /* True if range start uses ==, >= or <= */\n    int endEq;                   /* True if range end uses ==, >= or <= */\n    int start_constraints;       /* Start of range is constrained */\n    int nConstraint;             /* Number of constraint terms */\n    Index *pIdx;                 /* The index we will be using */\n    int iIdxCur;                 /* The VDBE cursor for the index */\n    int nExtraReg = 0;           /* Number of extra registers needed */\n    int op;                      /* Instruction opcode */\n    char *zStartAff;             /* Affinity for start of range constraint */\n    char *zEndAff;               /* Affinity for end of range constraint */\n\n    pIdx = pLevel->plan.u.pIdx;\n    iIdxCur = pLevel->iIdxCur;\n    k = (nEq==pIdx->nColumn ? -1 : pIdx->aiColumn[nEq]);\n\n    /* If this loop satisfies a sort order (pOrderBy) request that \n    ** was passed to this function to implement a \"SELECT min(x) ...\" \n    ** query, then the caller will only allow the loop to run for\n    ** a single iteration. This means that the first row returned\n    ** should not have a NULL value stored in 'x'. If column 'x' is\n    ** the first one after the nEq equality constraints in the index,\n    ** this requires some special handling.\n    */\n    if( (wctrlFlags&WHERE_ORDERBY_MIN)!=0\n     && (pLevel->plan.wsFlags&WHERE_ORDERED)\n     && (pIdx->nColumn>nEq)\n    ){\n      /* assert( pOrderBy->nExpr==1 ); */\n      /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */\n      isMinQuery = 1;\n      nExtraReg = 1;\n    }\n\n    /* Find any inequality constraint terms for the start and end \n    ** of the range. \n    */\n    if( pLevel->plan.wsFlags & WHERE_TOP_LIMIT ){\n      pRangeEnd = findTerm(pWC, iCur, k, notReady, (WO_LT|WO_LE), pIdx);\n      nExtraReg = 1;\n    }\n    if( pLevel->plan.wsFlags & WHERE_BTM_LIMIT ){\n      pRangeStart = findTerm(pWC, iCur, k, notReady, (WO_GT|WO_GE), pIdx);\n      nExtraReg = 1;\n    }\n\n    /* Generate code to evaluate all constraint terms using == or IN\n    ** and store the values of those terms in an array of registers\n    ** starting at regBase.\n    */\n    regBase = codeAllEqualityTerms(\n        pParse, pLevel, pWC, notReady, nExtraReg, &zStartAff\n    );\n    zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);\n    addrNxt = pLevel->addrNxt;\n\n    /* If we are doing a reverse order scan on an ascending index, or\n    ** a forward order scan on a descending index, interchange the \n    ** start and end terms (pRangeStart and pRangeEnd).\n    */\n    if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))\n     || (bRev && pIdx->nColumn==nEq)\n    ){\n      SWAP(WhereTerm *, pRangeEnd, pRangeStart);\n    }\n\n    testcase( pRangeStart && pRangeStart->eOperator & WO_LE );\n    testcase( pRangeStart && pRangeStart->eOperator & WO_GE );\n    testcase( pRangeEnd && pRangeEnd->eOperator & WO_LE );\n    testcase( pRangeEnd && pRangeEnd->eOperator & WO_GE );\n    startEq = !pRangeStart || pRangeStart->eOperator & (WO_LE|WO_GE);\n    endEq =   !pRangeEnd || pRangeEnd->eOperator & (WO_LE|WO_GE);\n    start_constraints = pRangeStart || nEq>0;\n\n    /* Seek the index cursor to the start of the range. */\n    nConstraint = nEq;\n    if( pRangeStart ){\n      Expr *pRight = pRangeStart->pExpr->pRight;\n      sqlite3ExprCode(pParse, pRight, regBase+nEq);\n      if( (pRangeStart->wtFlags & TERM_VNULL)==0 ){\n        sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);\n      }\n      if( zStartAff ){\n        if( sqlite3CompareAffinity(pRight, zStartAff[nEq])==SQLITE_AFF_NONE){\n          /* Since the comparison is to be performed with no conversions\n          ** applied to the operands, set the affinity to apply to pRight to \n          ** SQLITE_AFF_NONE.  */\n          zStartAff[nEq] = SQLITE_AFF_NONE;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){\n          zStartAff[nEq] = SQLITE_AFF_NONE;\n        }\n      }  \n      nConstraint++;\n      testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n    }else if( isMinQuery ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      nConstraint++;\n      startEq = 0;\n      start_constraints = 1;\n    }\n    codeApplyAffinity(pParse, regBase, nConstraint, zStartAff);\n    op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];\n    assert( op!=0 );\n    testcase( op==OP_Rewind );\n    testcase( op==OP_Last );\n    testcase( op==OP_SeekGt );\n    testcase( op==OP_SeekGe );\n    testcase( op==OP_SeekLe );\n    testcase( op==OP_SeekLt );\n    sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n\n    /* Load the value for the inequality constraint at the end of the\n    ** range (if any).\n    */\n    nConstraint = nEq;\n    if( pRangeEnd ){\n      Expr *pRight = pRangeEnd->pExpr->pRight;\n      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);\n      sqlite3ExprCode(pParse, pRight, regBase+nEq);\n      if( (pRangeEnd->wtFlags & TERM_VNULL)==0 ){\n        sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);\n      }\n      if( zEndAff ){\n        if( sqlite3CompareAffinity(pRight, zEndAff[nEq])==SQLITE_AFF_NONE){\n          /* Since the comparison is to be performed with no conversions\n          ** applied to the operands, set the affinity to apply to pRight to \n          ** SQLITE_AFF_NONE.  */\n          zEndAff[nEq] = SQLITE_AFF_NONE;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zEndAff[nEq]) ){\n          zEndAff[nEq] = SQLITE_AFF_NONE;\n        }\n      }  \n      codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);\n      nConstraint++;\n      testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */\n    }\n    sqlite3DbFree(pParse->db, zStartAff);\n    sqlite3DbFree(pParse->db, zEndAff);\n\n    /* Top of the loop body */\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n\n    /* Check if the index cursor is past the end of the range. */\n    op = aEndOp[(pRangeEnd || nEq) * (1 + bRev)];\n    testcase( op==OP_Noop );\n    testcase( op==OP_IdxGE );\n    testcase( op==OP_IdxLT );\n    if( op!=OP_Noop ){\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      sqlite3VdbeChangeP5(v, endEq!=bRev ?1:0);\n    }\n\n    /* If there are inequality constraints, check that the value\n    ** of the table column that the inequality contrains is not NULL.\n    ** If it is, jump to the next iteration of the loop.\n    */\n    r1 = sqlite3GetTempReg(pParse);\n    testcase( pLevel->plan.wsFlags & WHERE_BTM_LIMIT );\n    testcase( pLevel->plan.wsFlags & WHERE_TOP_LIMIT );\n    if( (pLevel->plan.wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 ){\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, nEq, r1);\n      sqlite3VdbeAddOp2(v, OP_IsNull, r1, addrCont);\n    }\n    sqlite3ReleaseTempReg(pParse, r1);\n\n    /* Seek the table cursor, if required */\n    disableTerm(pLevel, pRangeStart);\n    disableTerm(pLevel, pRangeEnd);\n    if( !omitTable ){\n      iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);\n      sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n      sqlite3VdbeAddOp2(v, OP_Seek, iCur, iRowidReg);  /* Deferred seek */\n    }\n\n    /* Record the instruction used to terminate the loop. Disable \n    ** WHERE clause terms made redundant by the index range scan.\n    */\n    if( pLevel->plan.wsFlags & WHERE_UNIQUE ){\n      pLevel->op = OP_Noop;\n    }else if( bRev ){\n      pLevel->op = OP_Prev;\n    }else{\n      pLevel->op = OP_Next;\n    }\n    pLevel->p1 = iIdxCur;\n    if( pLevel->plan.wsFlags & WHERE_COVER_SCAN ){\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }else{\n      assert( pLevel->p5==0 );\n    }\n  }else\n\n#ifndef SQLITE_OMIT_OR_OPTIMIZATION\n  if( pLevel->plan.wsFlags & WHERE_MULTI_OR ){\n    /* Case 4:  Two or more separately indexed terms connected by OR\n    **\n    ** Example:\n    **\n    **   CREATE TABLE t1(a,b,c,d);\n    **   CREATE INDEX i1 ON t1(a);\n    **   CREATE INDEX i2 ON t1(b);\n    **   CREATE INDEX i3 ON t1(c);\n    **\n    **   SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)\n    **\n    ** In the example, there are three indexed terms connected by OR.\n    ** The top of the loop looks like this:\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **\n    ** Then, for each indexed term, the following. The arguments to\n    ** RowSetTest are such that the rowid of the current row is inserted\n    ** into the RowSet. If it is already present, control skips the\n    ** Gosub opcode and jumps straight to the code generated by WhereEnd().\n    **\n    **        sqlite3WhereBegin(<term>)\n    **          RowSetTest                  # Insert rowid into rowset\n    **          Gosub      2 A\n    **        sqlite3WhereEnd()\n    **\n    ** Following the above, code to terminate the loop. Label A, the target\n    ** of the Gosub above, jumps to the instruction right after the Goto.\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **          Goto       B                # The loop is finished.\n    **\n    **       A: <loop body>                 # Return data, whatever.\n    **\n    **          Return     2                # Jump back to the Gosub\n    **\n    **       B: <after the loop>\n    **\n    */\n    WhereClause *pOrWc;    /* The OR-clause broken out into subterms */\n    SrcList *pOrTab;       /* Shortened table list or OR-clause generation */\n    Index *pCov = 0;             /* Potential covering index (or NULL) */\n    int iCovCur = pParse->nTab++;  /* Cursor used for index scans (if any) */\n\n    int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */\n    int regRowset = 0;                        /* Register for RowSet object */\n    int regRowid = 0;                         /* Register holding rowid */\n    int iLoopBody = sqlite3VdbeMakeLabel(v);  /* Start of loop body */\n    int iRetInit;                             /* Address of regReturn init */\n    int untestedTerms = 0;             /* Some terms not completely tested */\n    int ii;                            /* Loop counter */\n    Expr *pAndExpr = 0;                /* An \".. AND (...)\" expression */\n   \n    pTerm = pLevel->plan.u.pTerm;\n    assert( pTerm!=0 );\n    assert( pTerm->eOperator & WO_OR );\n    assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );\n    pOrWc = &pTerm->u.pOrInfo->wc;\n    pLevel->op = OP_Return;\n    pLevel->p1 = regReturn;\n\n    /* Set up a new SrcList in pOrTab containing the table being scanned\n    ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.\n    ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().\n    */\n    if( pWInfo->nLevel>1 ){\n      int nNotReady;                 /* The number of notReady tables */\n      struct SrcList_item *origSrc;     /* Original list of tables */\n      nNotReady = pWInfo->nLevel - iLevel - 1;\n      pOrTab = sqlite3StackAllocRaw(pParse->db,\n                            sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));\n      if( pOrTab==0 ) return notReady;\n      pOrTab->nAlloc = (i16)(nNotReady + 1);\n      pOrTab->nSrc = pOrTab->nAlloc;\n      memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));\n      origSrc = pWInfo->pTabList->a;\n      for(k=1; k<=nNotReady; k++){\n        memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));\n      }\n    }else{\n      pOrTab = pWInfo->pTabList;\n    }\n\n    /* Initialize the rowset register to contain NULL. An SQL NULL is \n    ** equivalent to an empty rowset.\n    **\n    ** Also initialize regReturn to contain the address of the instruction \n    ** immediately following the OP_Return at the bottom of the loop. This\n    ** is required in a few obscure LEFT JOIN cases where control jumps\n    ** over the top of the loop into the body of it. In this case the \n    ** correct response for the end-of-loop code (the OP_Return) is to \n    ** fall through to the next instruction, just as an OP_Next does if\n    ** called on an uninitialized cursor.\n    */\n    if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n      regRowset = ++pParse->nMem;\n      regRowid = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset);\n    }\n    iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);\n\n    /* If the original WHERE clause is z of the form:  (x1 OR x2 OR ...) AND y\n    ** Then for every term xN, evaluate as the subexpression: xN AND z\n    ** That way, terms in y that are factored into the disjunction will\n    ** be picked up by the recursive calls to sqlite3WhereBegin() below.\n    **\n    ** Actually, each subexpression is converted to \"xN AND w\" where w is\n    ** the \"interesting\" terms of z - terms that did not originate in the\n    ** ON or USING clause of a LEFT JOIN, and terms that are usable as \n    ** indices.\n    **\n    ** This optimization also only applies if the (x1 OR x2 OR ...) term\n    ** is not contained in the ON clause of a LEFT JOIN.\n    ** See ticket http://www.sqlite.org/src/info/f2369304e4\n    */\n    if( pWC->nTerm>1 ){\n      int iTerm;\n      for(iTerm=0; iTerm<pWC->nTerm; iTerm++){\n        Expr *pExpr = pWC->a[iTerm].pExpr;\n        if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;\n        if( pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_ORINFO) ) continue;\n        if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;\n        pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);\n        pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);\n      }\n      if( pAndExpr ){\n        pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);\n      }\n    }\n\n    for(ii=0; ii<pOrWc->nTerm; ii++){\n      WhereTerm *pOrTerm = &pOrWc->a[ii];\n      if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){\n        WhereInfo *pSubWInfo;          /* Info for single OR-term scan */\n        Expr *pOrExpr = pOrTerm->pExpr;\n        if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){\n          pAndExpr->pLeft = pOrExpr;\n          pOrExpr = pAndExpr;\n        }\n        /* Loop through table entries that match term pOrTerm. */\n        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,\n                        WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |\n                        WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);\n        assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );\n        if( pSubWInfo ){\n          WhereLevel *pLvl;\n          explainOneScan(\n              pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0\n          );\n          if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);\n            int r;\n            r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur, \n                                         regRowid, 0);\n            sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,\n                                 sqlite3VdbeCurrentAddr(v)+2, r, iSet);\n          }\n          sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);\n\n          /* The pSubWInfo->untestedTerms flag means that this OR term\n          ** contained one or more AND term from a notReady table.  The\n          ** terms from the notReady table could not be tested and will\n          ** need to be tested later.\n          */\n          if( pSubWInfo->untestedTerms ) untestedTerms = 1;\n\n          /* If all of the OR-connected terms are optimized using the same\n          ** index, and the index is opened using the same cursor number\n          ** by each call to sqlite3WhereBegin() made by this loop, it may\n          ** be possible to use that index as a covering index.\n          **\n          ** If the call to sqlite3WhereBegin() above resulted in a scan that\n          ** uses an index, and this is either the first OR-connected term\n          ** processed or the index is the same as that used by all previous\n          ** terms, set pCov to the candidate covering index. Otherwise, set \n          ** pCov to NULL to indicate that no candidate covering index will \n          ** be available.\n          */\n          pLvl = &pSubWInfo->a[0];\n          if( (pLvl->plan.wsFlags & WHERE_INDEXED)!=0\n           && (pLvl->plan.wsFlags & WHERE_TEMP_INDEX)==0\n           && (ii==0 || pLvl->plan.u.pIdx==pCov)\n          ){\n            assert( pLvl->iIdxCur==iCovCur );\n            pCov = pLvl->plan.u.pIdx;\n          }else{\n            pCov = 0;\n          }\n\n          /* Finish the loop through table entries that match term pOrTerm. */\n          sqlite3WhereEnd(pSubWInfo);\n        }\n      }\n    }\n    pLevel->u.pCovidx = pCov;\n    if( pCov ) pLevel->iIdxCur = iCovCur;\n    if( pAndExpr ){\n      pAndExpr->pLeft = 0;\n      sqlite3ExprDelete(pParse->db, pAndExpr);\n    }\n    sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);\n    sqlite3VdbeResolveLabel(v, iLoopBody);\n\n    if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);\n    if( !untestedTerms ) disableTerm(pLevel, pTerm);\n  }else\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n  {\n    /* Case 5:  There is no usable index.  We must do a complete\n    **          scan of the entire table.\n    */\n    static const u8 aStep[] = { OP_Next, OP_Prev };\n    static const u8 aStart[] = { OP_Rewind, OP_Last };\n    assert( bRev==0 || bRev==1 );\n    assert( omitTable==0 );\n    pLevel->op = aStep[bRev];\n    pLevel->p1 = iCur;\n    pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);\n    pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n  }\n  newNotReady = notReady & ~getMask(pWC->pMaskSet, iCur);\n\n  /* Insert code to test every subexpression that can be completely\n  ** computed using the current set of tables.\n  **\n  ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through\n  ** the use of indices become tests that are evaluated against each row of\n  ** the relevant input tables.\n  */\n  for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n    Expr *pE;\n    testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */\n    testcase( pTerm->wtFlags & TERM_CODED );\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( (pTerm->prereqAll & newNotReady)!=0 ){\n      testcase( pWInfo->untestedTerms==0\n               && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );\n      pWInfo->untestedTerms = 1;\n      continue;\n    }\n    pE = pTerm->pExpr;\n    assert( pE!=0 );\n    if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){\n      continue;\n    }\n    sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);\n    pTerm->wtFlags |= TERM_CODED;\n  }\n\n  /* Insert code to test for implied constraints based on transitivity\n  ** of the \"==\" operator.\n  **\n  ** Example: If the WHERE clause contains \"t1.a=t2.b\" and \"t2.b=123\"\n  ** and we are coding the t1 loop and the t2 loop has not yet coded,\n  ** then we cannot use the \"t1.a=t2.b\" constraint, but we can code\n  ** the implied \"t1.a=123\" constraint.\n  */\n  for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n    Expr *pE;\n    WhereTerm *pAlt;\n    Expr sEq;\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;\n    if( pTerm->leftCursor!=iCur ) continue;\n    pE = pTerm->pExpr;\n    assert( !ExprHasProperty(pE, EP_FromJoin) );\n    assert( (pTerm->prereqRight & newNotReady)!=0 );\n    pAlt = findTerm(pWC, iCur, pTerm->u.leftColumn, notReady, WO_EQ|WO_IN, 0);\n    if( pAlt==0 ) continue;\n    if( pAlt->wtFlags & (TERM_CODED) ) continue;\n    VdbeNoopComment((v, \"begin transitive constraint\"));\n    sEq = *pAlt->pExpr;\n    sEq.pLeft = pE->pLeft;\n    sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);\n  }\n\n  /* For a LEFT OUTER JOIN, generate code that will record the fact that\n  ** at least one row of the right table has matched the left table.  \n  */\n  if( pLevel->iLeftJoin ){\n    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);\n    VdbeComment((v, \"record LEFT JOIN hit\"));\n    sqlite3ExprCacheClear(pParse);\n    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );  /* IMP: R-30575-11662 */\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & newNotReady)!=0 ){\n        assert( pWInfo->untestedTerms );\n        continue;\n      }\n      assert( pTerm->pExpr );\n      sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, iReleaseReg);\n\n  return newNotReady;\n}\n\n#if defined(SQLITE_TEST)\n/*\n** The following variable holds a text description of query plan generated\n** by the most recent call to sqlite3WhereBegin().  Each call to WhereBegin\n** overwrites the previous.  This information is used for testing and\n** analysis only.\n*/\nSQLITE_API char sqlite3_query_plan[BMS*2*40];  /* Text of the join */\nstatic int nQPlan = 0;              /* Next free slow in _query_plan[] */\n\n#endif /* SQLITE_TEST */\n\n\n/*\n** Free a WhereInfo structure\n*/\nstatic void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){\n  if( ALWAYS(pWInfo) ){\n    int i;\n    for(i=0; i<pWInfo->nLevel; i++){\n      sqlite3_index_info *pInfo = pWInfo->a[i].pIdxInfo;\n      if( pInfo ){\n        /* assert( pInfo->needToFreeIdxStr==0 || db->mallocFailed ); */\n        if( pInfo->needToFreeIdxStr ){\n          sqlite3_free(pInfo->idxStr);\n        }\n        sqlite3DbFree(db, pInfo);\n      }\n      if( pWInfo->a[i].plan.wsFlags & WHERE_TEMP_INDEX ){\n        Index *pIdx = pWInfo->a[i].plan.u.pIdx;\n        if( pIdx ){\n          sqlite3DbFree(db, pIdx->zColAff);\n          sqlite3DbFree(db, pIdx);\n        }\n      }\n    }\n    whereClauseClear(pWInfo->pWC);\n    sqlite3DbFree(db, pWInfo);\n  }\n}\n\n\n/*\n** Generate the beginning of the loop used for WHERE clause processing.\n** The return value is a pointer to an opaque structure that contains\n** information needed to terminate the loop.  Later, the calling routine\n** should invoke sqlite3WhereEnd() with the return value of this function\n** in order to complete the WHERE clause processing.\n**\n** If an error occurs, this routine returns NULL.\n**\n** The basic idea is to do a nested loop, one loop for each table in\n** the FROM clause of a select.  (INSERT and UPDATE statements are the\n** same as a SELECT with only a single table in the FROM clause.)  For\n** example, if the SQL is this:\n**\n**       SELECT * FROM t1, t2, t3 WHERE ...;\n**\n** Then the code generated is conceptually like the following:\n**\n**      foreach row1 in t1 do       \\    Code generated\n**        foreach row2 in t2 do      |-- by sqlite3WhereBegin()\n**          foreach row3 in t3 do   /\n**            ...\n**          end                     \\    Code generated\n**        end                        |-- by sqlite3WhereEnd()\n**      end                         /\n**\n** Note that the loops might not be nested in the order in which they\n** appear in the FROM clause if a different order is better able to make\n** use of indices.  Note also that when the IN operator appears in\n** the WHERE clause, it might result in additional nested loops for\n** scanning through all values on the right-hand side of the IN.\n**\n** There are Btree cursors associated with each table.  t1 uses cursor\n** number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor.\n** And so forth.  This routine generates code to open those VDBE cursors\n** and sqlite3WhereEnd() generates the code to close them.\n**\n** The code that sqlite3WhereBegin() generates leaves the cursors named\n** in pTabList pointing at their appropriate entries.  The [...] code\n** can use OP_Column and OP_Rowid opcodes on these cursors to extract\n** data from the various tables of the loop.\n**\n** If the WHERE clause is empty, the foreach loops must each scan their\n** entire tables.  Thus a three-way join is an O(N^3) operation.  But if\n** the tables have indices and there are terms in the WHERE clause that\n** refer to those indices, a complete table scan can be avoided and the\n** code will run much faster.  Most of the work of this routine is checking\n** to see if there are indices that can be used to speed up the loop.\n**\n** Terms of the WHERE clause are also used to limit which rows actually\n** make it to the \"...\" in the middle of the loop.  After each \"foreach\",\n** terms of the WHERE clause that use only terms in that loop and outer\n** loops are evaluated and if false a jump is made around all subsequent\n** inner loops (or around the \"...\" if the test occurs within the inner-\n** most loop)\n**\n** OUTER JOINS\n**\n** An outer join of tables t1 and t2 is conceptally coded as follows:\n**\n**    foreach row1 in t1 do\n**      flag = 0\n**      foreach row2 in t2 do\n**        start:\n**          ...\n**          flag = 1\n**      end\n**      if flag==0 then\n**        move the row2 cursor to a null row\n**        goto start\n**      fi\n**    end\n**\n** ORDER BY CLAUSE PROCESSING\n**\n** pOrderBy is a pointer to the ORDER BY clause of a SELECT statement,\n** if there is one.  If there is no ORDER BY clause or if this routine\n** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.\n**\n** If an index can be used so that the natural output order of the table\n** scan is correct for the ORDER BY clause, then that index is used and\n** the returned WhereInfo.nOBSat field is set to pOrderBy->nExpr.  This\n** is an optimization that prevents an unnecessary sort of the result set\n** if an index appropriate for the ORDER BY clause already exists.\n**\n** If the where clause loops cannot be arranged to provide the correct\n** output order, then WhereInfo.nOBSat is 0.\n*/\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(\n  Parse *pParse,        /* The parser context */\n  SrcList *pTabList,    /* A list of all tables to be scanned */\n  Expr *pWhere,         /* The WHERE clause */\n  ExprList *pOrderBy,   /* An ORDER BY clause, or NULL */\n  ExprList *pDistinct,  /* The select-list for DISTINCT queries - or NULL */\n  u16 wctrlFlags,       /* One of the WHERE_* flags defined in sqliteInt.h */\n  int iIdxCur           /* If WHERE_ONETABLE_ONLY is set, index cursor number */\n){\n  int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */\n  int nTabList;              /* Number of elements in pTabList */\n  WhereInfo *pWInfo;         /* Will become the return value of this function */\n  Vdbe *v = pParse->pVdbe;   /* The virtual database engine */\n  Bitmask notReady;          /* Cursors that are not yet positioned */\n  WhereBestIdx sWBI;         /* Best index search context */\n  WhereMaskSet *pMaskSet;    /* The expression mask set */\n  WhereLevel *pLevel;        /* A single level in pWInfo->a[] */\n  int iFrom;                 /* First unused FROM clause element */\n  int andFlags;              /* AND-ed combination of all pWC->a[].wtFlags */\n  int ii;                    /* Loop counter */\n  sqlite3 *db;               /* Database connection */\n\n\n  /* Variable initialization */\n  memset(&sWBI, 0, sizeof(sWBI));\n  sWBI.pParse = pParse;\n\n  /* The number of tables in the FROM clause is limited by the number of\n  ** bits in a Bitmask \n  */\n  testcase( pTabList->nSrc==BMS );\n  if( pTabList->nSrc>BMS ){\n    sqlite3ErrorMsg(pParse, \"at most %d tables in a join\", BMS);\n    return 0;\n  }\n\n  /* This function normally generates a nested loop for all tables in \n  ** pTabList.  But if the WHERE_ONETABLE_ONLY flag is set, then we should\n  ** only generate code for the first table in pTabList and assume that\n  ** any cursors associated with subsequent tables are uninitialized.\n  */\n  nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;\n\n  /* Allocate and initialize the WhereInfo structure that will become the\n  ** return value. A single allocation is used to store the WhereInfo\n  ** struct, the contents of WhereInfo.a[], the WhereClause structure\n  ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte\n  ** field (type Bitmask) it must be aligned on an 8-byte boundary on\n  ** some architectures. Hence the ROUND8() below.\n  */\n  db = pParse->db;\n  nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));\n  pWInfo = sqlite3DbMallocZero(db, \n      nByteWInfo + \n      sizeof(WhereClause) +\n      sizeof(WhereMaskSet)\n  );\n  if( db->mallocFailed ){\n    sqlite3DbFree(db, pWInfo);\n    pWInfo = 0;\n    goto whereBeginError;\n  }\n  pWInfo->nLevel = nTabList;\n  pWInfo->pParse = pParse;\n  pWInfo->pTabList = pTabList;\n  pWInfo->iBreak = sqlite3VdbeMakeLabel(v);\n  pWInfo->pWC = sWBI.pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo];\n  pWInfo->wctrlFlags = wctrlFlags;\n  pWInfo->savedNQueryLoop = pParse->nQueryLoop;\n  pMaskSet = (WhereMaskSet*)&sWBI.pWC[1];\n  sWBI.aLevel = pWInfo->a;\n\n  /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via\n  ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */\n  if( OptimizationDisabled(db, SQLITE_DistinctOpt) ) pDistinct = 0;\n\n  /* Split the WHERE clause into separate subexpressions where each\n  ** subexpression is separated by an AND operator.\n  */\n  initMaskSet(pMaskSet);\n  whereClauseInit(sWBI.pWC, pParse, pMaskSet, wctrlFlags);\n  sqlite3ExprCodeConstants(pParse, pWhere);\n  whereSplit(sWBI.pWC, pWhere, TK_AND);   /* IMP: R-15842-53296 */\n    \n  /* Special case: a WHERE clause that is constant.  Evaluate the\n  ** expression and either jump over all of the code or fall thru.\n  */\n  if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){\n    sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);\n    pWhere = 0;\n  }\n\n  /* Assign a bit from the bitmask to every term in the FROM clause.\n  **\n  ** When assigning bitmask values to FROM clause cursors, it must be\n  ** the case that if X is the bitmask for the N-th FROM clause term then\n  ** the bitmask for all FROM clause terms to the left of the N-th term\n  ** is (X-1).   An expression from the ON clause of a LEFT JOIN can use\n  ** its Expr.iRightJoinTable value to find the bitmask of the right table\n  ** of the join.  Subtracting one from the right table bitmask gives a\n  ** bitmask for all tables to the left of the join.  Knowing the bitmask\n  ** for all tables to the left of a left join is important.  Ticket #3015.\n  **\n  ** Note that bitmasks are created for all pTabList->nSrc tables in\n  ** pTabList, not just the first nTabList tables.  nTabList is normally\n  ** equal to pTabList->nSrc but might be shortened to 1 if the\n  ** WHERE_ONETABLE_ONLY flag is set.\n  */\n  for(ii=0; ii<pTabList->nSrc; ii++){\n    createMask(pMaskSet, pTabList->a[ii].iCursor);\n  }\n#ifndef NDEBUG\n  {\n    Bitmask toTheLeft = 0;\n    for(ii=0; ii<pTabList->nSrc; ii++){\n      Bitmask m = getMask(pMaskSet, pTabList->a[ii].iCursor);\n      assert( (m-1)==toTheLeft );\n      toTheLeft |= m;\n    }\n  }\n#endif\n\n  /* Analyze all of the subexpressions.  Note that exprAnalyze() might\n  ** add new virtual terms onto the end of the WHERE clause.  We do not\n  ** want to analyze these virtual terms, so start analyzing at the end\n  ** and work forward so that the added virtual terms are never processed.\n  */\n  exprAnalyzeAll(pTabList, sWBI.pWC);\n  if( db->mallocFailed ){\n    goto whereBeginError;\n  }\n\n  /* Check if the DISTINCT qualifier, if there is one, is redundant. \n  ** If it is, then set pDistinct to NULL and WhereInfo.eDistinct to\n  ** WHERE_DISTINCT_UNIQUE to tell the caller to ignore the DISTINCT.\n  */\n  if( pDistinct && isDistinctRedundant(pParse, pTabList, sWBI.pWC, pDistinct) ){\n    pDistinct = 0;\n    pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n  }\n\n  /* Chose the best index to use for each table in the FROM clause.\n  **\n  ** This loop fills in the following fields:\n  **\n  **   pWInfo->a[].pIdx      The index to use for this level of the loop.\n  **   pWInfo->a[].wsFlags   WHERE_xxx flags associated with pIdx\n  **   pWInfo->a[].nEq       The number of == and IN constraints\n  **   pWInfo->a[].iFrom     Which term of the FROM clause is being coded\n  **   pWInfo->a[].iTabCur   The VDBE cursor for the database table\n  **   pWInfo->a[].iIdxCur   The VDBE cursor for the index\n  **   pWInfo->a[].pTerm     When wsFlags==WO_OR, the OR-clause term\n  **\n  ** This loop also figures out the nesting order of tables in the FROM\n  ** clause.\n  */\n  sWBI.notValid = ~(Bitmask)0;\n  sWBI.pOrderBy = pOrderBy;\n  sWBI.n = nTabList;\n  sWBI.pDistinct = pDistinct;\n  andFlags = ~0;\n  WHERETRACE((\"*** Optimizer Start ***\\n\"));\n  for(sWBI.i=iFrom=0, pLevel=pWInfo->a; sWBI.i<nTabList; sWBI.i++, pLevel++){\n    WhereCost bestPlan;         /* Most efficient plan seen so far */\n    Index *pIdx;                /* Index for FROM table at pTabItem */\n    int j;                      /* For looping over FROM tables */\n    int bestJ = -1;             /* The value of j */\n    Bitmask m;                  /* Bitmask value for j or bestJ */\n    int isOptimal;              /* Iterator for optimal/non-optimal search */\n    int ckOptimal;              /* Do the optimal scan check */\n    int nUnconstrained;         /* Number tables without INDEXED BY */\n    Bitmask notIndexed;         /* Mask of tables that cannot use an index */\n\n    memset(&bestPlan, 0, sizeof(bestPlan));\n    bestPlan.rCost = SQLITE_BIG_DBL;\n    WHERETRACE((\"*** Begin search for loop %d ***\\n\", sWBI.i));\n\n    /* Loop through the remaining entries in the FROM clause to find the\n    ** next nested loop. The loop tests all FROM clause entries\n    ** either once or twice. \n    **\n    ** The first test is always performed if there are two or more entries\n    ** remaining and never performed if there is only one FROM clause entry\n    ** to choose from.  The first test looks for an \"optimal\" scan.  In\n    ** this context an optimal scan is one that uses the same strategy\n    ** for the given FROM clause entry as would be selected if the entry\n    ** were used as the innermost nested loop.  In other words, a table\n    ** is chosen such that the cost of running that table cannot be reduced\n    ** by waiting for other tables to run first.  This \"optimal\" test works\n    ** by first assuming that the FROM clause is on the inner loop and finding\n    ** its query plan, then checking to see if that query plan uses any\n    ** other FROM clause terms that are sWBI.notValid.  If no notValid terms\n    ** are used then the \"optimal\" query plan works.\n    **\n    ** Note that the WhereCost.nRow parameter for an optimal scan might\n    ** not be as small as it would be if the table really were the innermost\n    ** join.  The nRow value can be reduced by WHERE clause constraints\n    ** that do not use indices.  But this nRow reduction only happens if the\n    ** table really is the innermost join.  \n    **\n    ** The second loop iteration is only performed if no optimal scan\n    ** strategies were found by the first iteration. This second iteration\n    ** is used to search for the lowest cost scan overall.\n    **\n    ** Without the optimal scan step (the first iteration) a suboptimal\n    ** plan might be chosen for queries like this:\n    **   \n    **   CREATE TABLE t1(a, b); \n    **   CREATE TABLE t2(c, d);\n    **   SELECT * FROM t2, t1 WHERE t2.rowid = t1.a;\n    **\n    ** The best strategy is to iterate through table t1 first. However it\n    ** is not possible to determine this with a simple greedy algorithm.\n    ** Since the cost of a linear scan through table t2 is the same \n    ** as the cost of a linear scan through table t1, a simple greedy \n    ** algorithm may choose to use t2 for the outer loop, which is a much\n    ** costlier approach.\n    */\n    nUnconstrained = 0;\n    notIndexed = 0;\n\n    /* The optimal scan check only occurs if there are two or more tables\n    ** available to be reordered */\n    if( iFrom==nTabList-1 ){\n      ckOptimal = 0;  /* Common case of just one table in the FROM clause */\n    }else{\n      ckOptimal = -1;\n      for(j=iFrom, sWBI.pSrc=&pTabList->a[j]; j<nTabList; j++, sWBI.pSrc++){\n        m = getMask(pMaskSet, sWBI.pSrc->iCursor);\n        if( (m & sWBI.notValid)==0 ){\n          if( j==iFrom ) iFrom++;\n          continue;\n        }\n        if( j>iFrom && (sWBI.pSrc->jointype & (JT_LEFT|JT_CROSS))!=0 ) break;\n        if( ++ckOptimal ) break;\n        if( (sWBI.pSrc->jointype & JT_LEFT)!=0 ) break;\n      }\n    }\n    assert( ckOptimal==0 || ckOptimal==1 );\n\n    for(isOptimal=ckOptimal; isOptimal>=0 && bestJ<0; isOptimal--){\n      for(j=iFrom, sWBI.pSrc=&pTabList->a[j]; j<nTabList; j++, sWBI.pSrc++){\n        if( j>iFrom && (sWBI.pSrc->jointype & (JT_LEFT|JT_CROSS))!=0 ){\n          /* This break and one like it in the ckOptimal computation loop\n          ** above prevent table reordering across LEFT and CROSS JOINs.\n          ** The LEFT JOIN case is necessary for correctness.  The prohibition\n          ** against reordering across a CROSS JOIN is an SQLite feature that\n          ** allows the developer to control table reordering */\n          break;\n        }\n        m = getMask(pMaskSet, sWBI.pSrc->iCursor);\n        if( (m & sWBI.notValid)==0 ){\n          assert( j>iFrom );\n          continue;\n        }\n        sWBI.notReady = (isOptimal ? m : sWBI.notValid);\n        if( sWBI.pSrc->pIndex==0 ) nUnconstrained++;\n  \n        WHERETRACE((\"   === trying table %d (%s) with isOptimal=%d ===\\n\",\n                    j, sWBI.pSrc->pTab->zName, isOptimal));\n        assert( sWBI.pSrc->pTab );\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        if( IsVirtual(sWBI.pSrc->pTab) ){\n          sWBI.ppIdxInfo = &pWInfo->a[j].pIdxInfo;\n          bestVirtualIndex(&sWBI);\n        }else \n#endif\n        {\n          bestBtreeIndex(&sWBI);\n        }\n        assert( isOptimal || (sWBI.cost.used&sWBI.notValid)==0 );\n\n        /* If an INDEXED BY clause is present, then the plan must use that\n        ** index if it uses any index at all */\n        assert( sWBI.pSrc->pIndex==0 \n                  || (sWBI.cost.plan.wsFlags & WHERE_NOT_FULLSCAN)==0\n                  || sWBI.cost.plan.u.pIdx==sWBI.pSrc->pIndex );\n\n        if( isOptimal && (sWBI.cost.plan.wsFlags & WHERE_NOT_FULLSCAN)==0 ){\n          notIndexed |= m;\n        }\n        if( isOptimal ){\n          pWInfo->a[j].rOptCost = sWBI.cost.rCost;\n        }else if( ckOptimal ){\n          /* If two or more tables have nearly the same outer loop cost, but\n          ** very different inner loop (optimal) cost, we want to choose\n          ** for the outer loop that table which benefits the least from\n          ** being in the inner loop.  The following code scales the \n          ** outer loop cost estimate to accomplish that. */\n          WHERETRACE((\"   scaling cost from %.1f to %.1f\\n\",\n                      sWBI.cost.rCost,\n                      sWBI.cost.rCost/pWInfo->a[j].rOptCost));\n          sWBI.cost.rCost /= pWInfo->a[j].rOptCost;\n        }\n\n        /* Conditions under which this table becomes the best so far:\n        **\n        **   (1) The table must not depend on other tables that have not\n        **       yet run.  (In other words, it must not depend on tables\n        **       in inner loops.)\n        **\n        **   (2) (This rule was removed on 2012-11-09.  The scaling of the\n        **       cost using the optimal scan cost made this rule obsolete.)\n        **\n        **   (3) All tables have an INDEXED BY clause or this table lacks an\n        **       INDEXED BY clause or this table uses the specific\n        **       index specified by its INDEXED BY clause.  This rule ensures\n        **       that a best-so-far is always selected even if an impossible\n        **       combination of INDEXED BY clauses are given.  The error\n        **       will be detected and relayed back to the application later.\n        **       The NEVER() comes about because rule (2) above prevents\n        **       An indexable full-table-scan from reaching rule (3).\n        **\n        **   (4) The plan cost must be lower than prior plans, where \"cost\"\n        **       is defined by the compareCost() function above. \n        */\n        if( (sWBI.cost.used&sWBI.notValid)==0                    /* (1) */\n            && (nUnconstrained==0 || sWBI.pSrc->pIndex==0        /* (3) */\n                || NEVER((sWBI.cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0))\n            && (bestJ<0 || compareCost(&sWBI.cost, &bestPlan))   /* (4) */\n        ){\n          WHERETRACE((\"   === table %d (%s) is best so far\\n\"\n                      \"       cost=%.1f, nRow=%.1f, nOBSat=%d, wsFlags=%08x\\n\",\n                      j, sWBI.pSrc->pTab->zName,\n                      sWBI.cost.rCost, sWBI.cost.plan.nRow,\n                      sWBI.cost.plan.nOBSat, sWBI.cost.plan.wsFlags));\n          bestPlan = sWBI.cost;\n          bestJ = j;\n        }\n\n        /* In a join like \"w JOIN x LEFT JOIN y JOIN z\"  make sure that\n        ** table y (and not table z) is always the next inner loop inside\n        ** of table x. */\n        if( (sWBI.pSrc->jointype & JT_LEFT)!=0 ) break;\n      }\n    }\n    assert( bestJ>=0 );\n    assert( sWBI.notValid & getMask(pMaskSet, pTabList->a[bestJ].iCursor) );\n    assert( bestJ==iFrom || (pTabList->a[iFrom].jointype & JT_LEFT)==0 );\n    testcase( bestJ>iFrom && (pTabList->a[iFrom].jointype & JT_CROSS)!=0 );\n    testcase( bestJ>iFrom && bestJ<nTabList-1\n                          && (pTabList->a[bestJ+1].jointype & JT_LEFT)!=0 );\n    WHERETRACE((\"*** Optimizer selects table %d (%s) for loop %d with:\\n\"\n                \"    cost=%.1f, nRow=%.1f, nOBSat=%d, wsFlags=0x%08x\\n\",\n                bestJ, pTabList->a[bestJ].pTab->zName,\n                pLevel-pWInfo->a, bestPlan.rCost, bestPlan.plan.nRow,\n                bestPlan.plan.nOBSat, bestPlan.plan.wsFlags));\n    if( (bestPlan.plan.wsFlags & WHERE_DISTINCT)!=0 ){\n      assert( pWInfo->eDistinct==0 );\n      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n    }\n    andFlags &= bestPlan.plan.wsFlags;\n    pLevel->plan = bestPlan.plan;\n    pLevel->iTabCur = pTabList->a[bestJ].iCursor;\n    testcase( bestPlan.plan.wsFlags & WHERE_INDEXED );\n    testcase( bestPlan.plan.wsFlags & WHERE_TEMP_INDEX );\n    if( bestPlan.plan.wsFlags & (WHERE_INDEXED|WHERE_TEMP_INDEX) ){\n      if( (wctrlFlags & WHERE_ONETABLE_ONLY) \n       && (bestPlan.plan.wsFlags & WHERE_TEMP_INDEX)==0 \n      ){\n        pLevel->iIdxCur = iIdxCur;\n      }else{\n        pLevel->iIdxCur = pParse->nTab++;\n      }\n    }else{\n      pLevel->iIdxCur = -1;\n    }\n    sWBI.notValid &= ~getMask(pMaskSet, pTabList->a[bestJ].iCursor);\n    pLevel->iFrom = (u8)bestJ;\n    if( bestPlan.plan.nRow>=(double)1 ){\n      pParse->nQueryLoop *= bestPlan.plan.nRow;\n    }\n\n    /* Check that if the table scanned by this loop iteration had an\n    ** INDEXED BY clause attached to it, that the named index is being\n    ** used for the scan. If not, then query compilation has failed.\n    ** Return an error.\n    */\n    pIdx = pTabList->a[bestJ].pIndex;\n    if( pIdx ){\n      if( (bestPlan.plan.wsFlags & WHERE_INDEXED)==0 ){\n        sqlite3ErrorMsg(pParse, \"cannot use index: %s\", pIdx->zName);\n        goto whereBeginError;\n      }else{\n        /* If an INDEXED BY clause is used, the bestIndex() function is\n        ** guaranteed to find the index specified in the INDEXED BY clause\n        ** if it find an index at all. */\n        assert( bestPlan.plan.u.pIdx==pIdx );\n      }\n    }\n  }\n  WHERETRACE((\"*** Optimizer Finished ***\\n\"));\n  if( pParse->nErr || db->mallocFailed ){\n    goto whereBeginError;\n  }\n  if( nTabList ){\n    pLevel--;\n    pWInfo->nOBSat = pLevel->plan.nOBSat;\n  }else{\n    pWInfo->nOBSat = 0;\n  }\n\n  /* If the total query only selects a single row, then the ORDER BY\n  ** clause is irrelevant.\n  */\n  if( (andFlags & WHERE_UNIQUE)!=0 && pOrderBy ){\n    assert( nTabList==0 || (pLevel->plan.wsFlags & WHERE_ALL_UNIQUE)!=0 );\n    pWInfo->nOBSat = pOrderBy->nExpr;\n  }\n\n  /* If the caller is an UPDATE or DELETE statement that is requesting\n  ** to use a one-pass algorithm, determine if this is appropriate.\n  ** The one-pass algorithm only works if the WHERE clause constraints\n  ** the statement to update a single row.\n  */\n  assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 );\n  if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 && (andFlags & WHERE_UNIQUE)!=0 ){\n    pWInfo->okOnePass = 1;\n    pWInfo->a[0].plan.wsFlags &= ~WHERE_IDX_ONLY;\n  }\n\n  /* Open all tables in the pTabList and any indices selected for\n  ** searching those tables.\n  */\n  sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */\n  notReady = ~(Bitmask)0;\n  pWInfo->nRowOut = (double)1;\n  for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){\n    Table *pTab;     /* Table to open */\n    int iDb;         /* Index of database containing table/index */\n    struct SrcList_item *pTabItem;\n\n    pTabItem = &pTabList->a[pLevel->iFrom];\n    pTab = pTabItem->pTab;\n    pWInfo->nRowOut *= pLevel->plan.nRow;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){\n      /* Do nothing */\n    }else\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( (pLevel->plan.wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      int iCur = pTabItem->iCursor;\n      sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);\n    }else if( IsVirtual(pTab) ){\n      /* noop */\n    }else\n#endif\n    if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0\n         && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){\n      int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead;\n      sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);\n      testcase( pTab->nCol==BMS-1 );\n      testcase( pTab->nCol==BMS );\n      if( !pWInfo->okOnePass && pTab->nCol<BMS ){\n        Bitmask b = pTabItem->colUsed;\n        int n = 0;\n        for(; b; b=b>>1, n++){}\n        sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, \n                            SQLITE_INT_TO_PTR(n), P4_INT32);\n        assert( n<=pTab->nCol );\n      }\n    }else{\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n    }\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n    if( (pLevel->plan.wsFlags & WHERE_TEMP_INDEX)!=0 ){\n      constructAutomaticIndex(pParse, sWBI.pWC, pTabItem, notReady, pLevel);\n    }else\n#endif\n    if( (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 ){\n      Index *pIx = pLevel->plan.u.pIdx;\n      KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIx);\n      int iIndexCur = pLevel->iIdxCur;\n      assert( pIx->pSchema==pTab->pSchema );\n      assert( iIndexCur>=0 );\n      sqlite3VdbeAddOp4(v, OP_OpenRead, iIndexCur, pIx->tnum, iDb,\n                        (char*)pKey, P4_KEYINFO_HANDOFF);\n      VdbeComment((v, \"%s\", pIx->zName));\n    }\n    sqlite3CodeVerifySchema(pParse, iDb);\n    notReady &= ~getMask(sWBI.pWC->pMaskSet, pTabItem->iCursor);\n  }\n  pWInfo->iTop = sqlite3VdbeCurrentAddr(v);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Generate the code to do the search.  Each iteration of the for\n  ** loop below generates code for a single nested loop of the VM\n  ** program.\n  */\n  notReady = ~(Bitmask)0;\n  for(ii=0; ii<nTabList; ii++){\n    pLevel = &pWInfo->a[ii];\n    explainOneScan(pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags);\n    notReady = codeOneLoopStart(pWInfo, ii, wctrlFlags, notReady);\n    pWInfo->iContinue = pLevel->addrCont;\n  }\n\n#ifdef SQLITE_TEST  /* For testing and debugging use only */\n  /* Record in the query plan information about the current table\n  ** and the index used to access it (if any).  If the table itself\n  ** is not used, its name is just '{}'.  If no index is used\n  ** the index is listed as \"{}\".  If the primary key is used the\n  ** index name is '*'.\n  */\n  for(ii=0; ii<nTabList; ii++){\n    char *z;\n    int n;\n    int w;\n    struct SrcList_item *pTabItem;\n\n    pLevel = &pWInfo->a[ii];\n    w = pLevel->plan.wsFlags;\n    pTabItem = &pTabList->a[pLevel->iFrom];\n    z = pTabItem->zAlias;\n    if( z==0 ) z = pTabItem->pTab->zName;\n    n = sqlite3Strlen30(z);\n    if( n+nQPlan < sizeof(sqlite3_query_plan)-10 ){\n      if( (w & WHERE_IDX_ONLY)!=0 && (w & WHERE_COVER_SCAN)==0 ){\n        memcpy(&sqlite3_query_plan[nQPlan], \"{}\", 2);\n        nQPlan += 2;\n      }else{\n        memcpy(&sqlite3_query_plan[nQPlan], z, n);\n        nQPlan += n;\n      }\n      sqlite3_query_plan[nQPlan++] = ' ';\n    }\n    testcase( w & WHERE_ROWID_EQ );\n    testcase( w & WHERE_ROWID_RANGE );\n    if( w & (WHERE_ROWID_EQ|WHERE_ROWID_RANGE) ){\n      memcpy(&sqlite3_query_plan[nQPlan], \"* \", 2);\n      nQPlan += 2;\n    }else if( (w & WHERE_INDEXED)!=0 && (w & WHERE_COVER_SCAN)==0 ){\n      n = sqlite3Strlen30(pLevel->plan.u.pIdx->zName);\n      if( n+nQPlan < sizeof(sqlite3_query_plan)-2 ){\n        memcpy(&sqlite3_query_plan[nQPlan], pLevel->plan.u.pIdx->zName, n);\n        nQPlan += n;\n        sqlite3_query_plan[nQPlan++] = ' ';\n      }\n    }else{\n      memcpy(&sqlite3_query_plan[nQPlan], \"{} \", 3);\n      nQPlan += 3;\n    }\n  }\n  while( nQPlan>0 && sqlite3_query_plan[nQPlan-1]==' ' ){\n    sqlite3_query_plan[--nQPlan] = 0;\n  }\n  sqlite3_query_plan[nQPlan] = 0;\n  nQPlan = 0;\n#endif /* SQLITE_TEST // Testing and debugging use only */\n\n  /* Record the continuation address in the WhereInfo structure.  Then\n  ** clean up and return.\n  */\n  return pWInfo;\n\n  /* Jump here if malloc fails */\nwhereBeginError:\n  if( pWInfo ){\n    pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n    whereInfoFree(db, pWInfo);\n  }\n  return 0;\n}\n\n/*\n** Generate the end of the WHERE loop.  See comments on \n** sqlite3WhereBegin() for additional information.\n*/\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){\n  Parse *pParse = pWInfo->pParse;\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  WhereLevel *pLevel;\n  SrcList *pTabList = pWInfo->pTabList;\n  sqlite3 *db = pParse->db;\n\n  /* Generate loop termination code.\n  */\n  sqlite3ExprCacheClear(pParse);\n  for(i=pWInfo->nLevel-1; i>=0; i--){\n    pLevel = &pWInfo->a[i];\n    sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n    if( pLevel->op!=OP_Noop ){\n      sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);\n      sqlite3VdbeChangeP5(v, pLevel->p5);\n    }\n    if( pLevel->plan.wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){\n      struct InLoop *pIn;\n      int j;\n      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);\n      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){\n        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);\n        sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);\n        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);\n      }\n      sqlite3DbFree(db, pLevel->u.in.aInLoop);\n    }\n    sqlite3VdbeResolveLabel(v, pLevel->addrBrk);\n    if( pLevel->iLeftJoin ){\n      int addr;\n      addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin);\n      assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0\n           || (pLevel->plan.wsFlags & WHERE_INDEXED)!=0 );\n      if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);\n      }\n      if( pLevel->iIdxCur>=0 ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);\n      }\n      if( pLevel->op==OP_Return ){\n        sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst);\n      }\n      sqlite3VdbeJumpHere(v, addr);\n    }\n  }\n\n  /* The \"break\" point is here, just past the end of the outer loop.\n  ** Set it.\n  */\n  sqlite3VdbeResolveLabel(v, pWInfo->iBreak);\n\n  /* Close all of the cursors that were opened by sqlite3WhereBegin.\n  */\n  assert( pWInfo->nLevel==1 || pWInfo->nLevel==pTabList->nSrc );\n  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){\n    Index *pIdx = 0;\n    struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];\n    Table *pTab = pTabItem->pTab;\n    assert( pTab!=0 );\n    if( (pTab->tabFlags & TF_Ephemeral)==0\n     && pTab->pSelect==0\n     && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0\n    ){\n      int ws = pLevel->plan.wsFlags;\n      if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){\n        sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);\n      }\n      if( (ws & WHERE_INDEXED)!=0 && (ws & WHERE_TEMP_INDEX)==0 ){\n        sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);\n      }\n    }\n\n    /* If this scan uses an index, make code substitutions to read data\n    ** from the index in preference to the table. Sometimes, this means\n    ** the table need never be read from. This is a performance boost,\n    ** as the vdbe level waits until the table is read before actually\n    ** seeking the table cursor to the record corresponding to the current\n    ** position in the index.\n    ** \n    ** Calls to the code generator in between sqlite3WhereBegin and\n    ** sqlite3WhereEnd will have created code that references the table\n    ** directly.  This loop scans all that code looking for opcodes\n    ** that reference the table and converts them into opcodes that\n    ** reference the index.\n    */\n    if( pLevel->plan.wsFlags & WHERE_INDEXED ){\n      pIdx = pLevel->plan.u.pIdx;\n    }else if( pLevel->plan.wsFlags & WHERE_MULTI_OR ){\n      pIdx = pLevel->u.pCovidx;\n    }\n    if( pIdx && !db->mallocFailed){\n      int k, j, last;\n      VdbeOp *pOp;\n\n      pOp = sqlite3VdbeGetOp(v, pWInfo->iTop);\n      last = sqlite3VdbeCurrentAddr(v);\n      for(k=pWInfo->iTop; k<last; k++, pOp++){\n        if( pOp->p1!=pLevel->iTabCur ) continue;\n        if( pOp->opcode==OP_Column ){\n          for(j=0; j<pIdx->nColumn; j++){\n            if( pOp->p2==pIdx->aiColumn[j] ){\n              pOp->p2 = j;\n              pOp->p1 = pLevel->iIdxCur;\n              break;\n            }\n          }\n          assert( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0\n               || j<pIdx->nColumn );\n        }else if( pOp->opcode==OP_Rowid ){\n          pOp->p1 = pLevel->iIdxCur;\n          pOp->opcode = OP_IdxRowid;\n        }\n      }\n    }\n  }\n\n  /* Final cleanup\n  */\n  pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n  whereInfoFree(db, pWInfo);\n  return;\n}\n\n/************** End of where.c ***********************************************/\n/************** Begin file parse.c *******************************************/\n/* Driver template for the LEMON parser generator.\n** The author disclaims copyright to this source code.\n**\n** This version of \"lempar.c\" is modified, slightly, for use by SQLite.\n** The only modifications are the addition of a couple of NEVER()\n** macros to disable tests that are needed in the case of a general\n** LALR(1) grammar but which are always false in the\n** specific grammar used by SQLite.\n*/\n/* First off, code is included that follows the \"include\" declaration\n** in the input grammar file. */\n/* #include <stdio.h> */\n\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define YYNOERRORRECOVERY 1\n\n/*\n** Make yytestcase() the same as testcase()\n*/\n#define yytestcase(X) testcase(X)\n\n/*\n** An instance of this structure holds information about the\n** LIMIT clause of a SELECT statement.\n*/\nstruct LimitVal {\n  Expr *pLimit;    /* The LIMIT expression.  NULL if there is no limit */\n  Expr *pOffset;   /* The OFFSET expression.  NULL if there is none */\n};\n\n/*\n** An instance of this structure is used to store the LIKE,\n** GLOB, NOT LIKE, and NOT GLOB operators.\n*/\nstruct LikeOp {\n  Token eOperator;  /* \"like\" or \"glob\" or \"regexp\" */\n  int bNot;         /* True if the NOT keyword is present */\n};\n\n/*\n** An instance of the following structure describes the event of a\n** TRIGGER.  \"a\" is the event type, one of TK_UPDATE, TK_INSERT,\n** TK_DELETE, or TK_INSTEAD.  If the event is of the form\n**\n**      UPDATE ON (a,b,c)\n**\n** Then the \"b\" IdList records the list \"a,b,c\".\n*/\nstruct TrigEvent { int a; IdList * b; };\n\n/*\n** An instance of this structure holds the ATTACH key and the key type.\n*/\nstruct AttachKey { int type;  Token key; };\n\n/*\n** One or more VALUES claues\n*/\nstruct ValueList {\n  ExprList *pList;\n  Select *pSelect;\n};\n\n\n  /* This is a utility routine used to set the ExprSpan.zStart and\n  ** ExprSpan.zEnd values of pOut so that the span covers the complete\n  ** range of text beginning with pStart and going to the end of pEnd.\n  */\n  static void spanSet(ExprSpan *pOut, Token *pStart, Token *pEnd){\n    pOut->zStart = pStart->z;\n    pOut->zEnd = &pEnd->z[pEnd->n];\n  }\n\n  /* Construct a new Expr object from a single identifier.  Use the\n  ** new Expr to populate pOut.  Set the span of pOut to be the identifier\n  ** that created the expression.\n  */\n  static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token *pValue){\n    pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue);\n    pOut->zStart = pValue->z;\n    pOut->zEnd = &pValue->z[pValue->n];\n  }\n\n  /* This routine constructs a binary expression node out of two ExprSpan\n  ** objects and uses the result to populate a new ExprSpan object.\n  */\n  static void spanBinaryExpr(\n    ExprSpan *pOut,     /* Write the result here */\n    Parse *pParse,      /* The parsing context.  Errors accumulate here */\n    int op,             /* The binary operation */\n    ExprSpan *pLeft,    /* The left operand */\n    ExprSpan *pRight    /* The right operand */\n  ){\n    pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0);\n    pOut->zStart = pLeft->zStart;\n    pOut->zEnd = pRight->zEnd;\n  }\n\n  /* Construct an expression node for a unary postfix operator\n  */\n  static void spanUnaryPostfix(\n    ExprSpan *pOut,        /* Write the new expression node here */\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand */\n    Token *pPostOp         /* The operand token for setting the span */\n  ){\n    pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);\n    pOut->zStart = pOperand->zStart;\n    pOut->zEnd = &pPostOp->z[pPostOp->n];\n  }                           \n\n  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a\n  ** unary TK_ISNULL or TK_NOTNULL expression. */\n  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){\n    sqlite3 *db = pParse->db;\n    if( db->mallocFailed==0 && pY->op==TK_NULL ){\n      pA->op = (u8)op;\n      sqlite3ExprDelete(db, pA->pRight);\n      pA->pRight = 0;\n    }\n  }\n\n  /* Construct an expression node for a unary prefix operator\n  */\n  static void spanUnaryPrefix(\n    ExprSpan *pOut,        /* Write the new expression node here */\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand */\n    Token *pPreOp         /* The operand token for setting the span */\n  ){\n    pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0);\n    pOut->zStart = pPreOp->z;\n    pOut->zEnd = pOperand->zEnd;\n  }\n/* Next is all token values, in a form suitable for use by makeheaders.\n** This section will be null unless lemon is run with the -m switch.\n*/\n/* \n** These constants (all generated automatically by the parser generator)\n** specify the various kinds of tokens (terminals) that the parser\n** understands. \n**\n** Each symbol here is a terminal symbol in the grammar.\n*/\n/* Make sure the INTERFACE macro is defined.\n*/\n#ifndef INTERFACE\n# define INTERFACE 1\n#endif\n/* The next thing included is series of defines which control\n** various aspects of the generated parser.\n**    YYCODETYPE         is the data type used for storing terminal\n**                       and nonterminal numbers.  \"unsigned char\" is\n**                       used if there are fewer than 250 terminals\n**                       and nonterminals.  \"int\" is used otherwise.\n**    YYNOCODE           is a number of type YYCODETYPE which corresponds\n**                       to no legal terminal or nonterminal number.  This\n**                       number is used to fill in empty slots of the hash \n**                       table.\n**    YYFALLBACK         If defined, this indicates that one or more tokens\n**                       have fall-back values which should be used if the\n**                       original value of the token will not parse.\n**    YYACTIONTYPE       is the data type used for storing terminal\n**                       and nonterminal numbers.  \"unsigned char\" is\n**                       used if there are fewer than 250 rules and\n**                       states combined.  \"int\" is used otherwise.\n**    sqlite3ParserTOKENTYPE     is the data type used for minor tokens given \n**                       directly to the parser from the tokenizer.\n**    YYMINORTYPE        is the data type used for all minor tokens.\n**                       This is typically a union of many types, one of\n**                       which is sqlite3ParserTOKENTYPE.  The entry in the union\n**                       for base tokens is called \"yy0\".\n**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If\n**                       zero the stack is dynamically sized using realloc()\n**    sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument\n**    sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument\n**    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser\n**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser\n**    YYNSTATE           the combined number of states.\n**    YYNRULE            the number of rules in the grammar\n**    YYERRORSYMBOL      is the code number of the error symbol.  If not\n**                       defined, then do no error processing.\n*/\n#define YYCODETYPE unsigned char\n#define YYNOCODE 251\n#define YYACTIONTYPE unsigned short int\n#define YYWILDCARD 67\n#define sqlite3ParserTOKENTYPE Token\ntypedef union {\n  int yyinit;\n  sqlite3ParserTOKENTYPE yy0;\n  struct LimitVal yy64;\n  Expr* yy122;\n  Select* yy159;\n  IdList* yy180;\n  struct {int value; int mask;} yy207;\n  u8 yy258;\n  u16 yy305;\n  struct LikeOp yy318;\n  TriggerStep* yy327;\n  ExprSpan yy342;\n  SrcList* yy347;\n  int yy392;\n  struct TrigEvent yy410;\n  ExprList* yy442;\n  struct ValueList yy487;\n} YYMINORTYPE;\n#ifndef YYSTACKDEPTH\n#define YYSTACKDEPTH 100\n#endif\n#define sqlite3ParserARG_SDECL Parse *pParse;\n#define sqlite3ParserARG_PDECL ,Parse *pParse\n#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse\n#define sqlite3ParserARG_STORE yypParser->pParse = pParse\n#define YYNSTATE 627\n#define YYNRULE 327\n#define YYFALLBACK 1\n#define YY_NO_ACTION      (YYNSTATE+YYNRULE+2)\n#define YY_ACCEPT_ACTION  (YYNSTATE+YYNRULE+1)\n#define YY_ERROR_ACTION   (YYNSTATE+YYNRULE)\n\n/* The yyzerominor constant is used to initialize instances of\n** YYMINORTYPE objects to zero. */\nstatic const YYMINORTYPE yyzerominor = { 0 };\n\n/* Define the yytestcase() macro to be a no-op if is not already defined\n** otherwise.\n**\n** Applications can choose to define yytestcase() in the %include section\n** to a macro that can assist in verifying code coverage.  For production\n** code the yytestcase() macro should be turned off.  But it is useful\n** for testing.\n*/\n#ifndef yytestcase\n# define yytestcase(X)\n#endif\n\n\n/* Next are the tables used to determine what action to take based on the\n** current state and lookahead token.  These tables are used to implement\n** functions that take a state number and lookahead value and return an\n** action integer.  \n**\n** Suppose the action integer is N.  Then the action is determined as\n** follows\n**\n**   0 <= N < YYNSTATE                  Shift N.  That is, push the lookahead\n**                                      token onto the stack and goto state N.\n**\n**   YYNSTATE <= N < YYNSTATE+YYNRULE   Reduce by rule N-YYNSTATE.\n**\n**   N == YYNSTATE+YYNRULE              A syntax error has occurred.\n**\n**   N == YYNSTATE+YYNRULE+1            The parser accepts its input.\n**\n**   N == YYNSTATE+YYNRULE+2            No such action.  Denotes unused\n**                                      slots in the yy_action[] table.\n**\n** The action table is constructed as a single large table named yy_action[].\n** Given state S and lookahead X, the action is computed as\n**\n**      yy_action[ yy_shift_ofst[S] + X ]\n**\n** If the index value yy_shift_ofst[S]+X is out of range or if the value\n** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S]\n** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table\n** and that yy_default[S] should be used instead.  \n**\n** The formula above is for computing the action when the lookahead is\n** a terminal symbol.  If the lookahead is a non-terminal (as occurs after\n** a reduce action) then the yy_reduce_ofst[] array is used in place of\n** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of\n** YY_SHIFT_USE_DFLT.\n**\n** The following are the tables generated in this section:\n**\n**  yy_action[]        A single table containing all actions.\n**  yy_lookahead[]     A table containing the lookahead for each entry in\n**                     yy_action.  Used to detect hash collisions.\n**  yy_shift_ofst[]    For each state, the offset into yy_action for\n**                     shifting terminals.\n**  yy_reduce_ofst[]   For each state, the offset into yy_action for\n**                     shifting non-terminals after a reduce.\n**  yy_default[]       Default action for each state.\n*/\n#define YY_ACTTAB_COUNT (1564)\nstatic const YYACTIONTYPE yy_action[] = {\n /*     0 */   309,  955,  184,  417,    2,  171,  624,  594,   56,   56,\n /*    10 */    56,   56,   49,   54,   54,   54,   54,   53,   53,   52,\n /*    20 */    52,   52,   51,  233,  620,  619,  298,  620,  619,  234,\n /*    30 */   587,  581,   56,   56,   56,   56,   19,   54,   54,   54,\n /*    40 */    54,   53,   53,   52,   52,   52,   51,  233,  605,   57,\n /*    50 */    58,   48,  579,  578,  580,  580,   55,   55,   56,   56,\n /*    60 */    56,   56,  541,   54,   54,   54,   54,   53,   53,   52,\n /*    70 */    52,   52,   51,  233,  309,  594,  325,  196,  195,  194,\n /*    80 */    33,   54,   54,   54,   54,   53,   53,   52,   52,   52,\n /*    90 */    51,  233,  617,  616,  165,  617,  616,  380,  377,  376,\n /*   100 */   407,  532,  576,  576,  587,  581,  303,  422,  375,   59,\n /*   110 */    53,   53,   52,   52,   52,   51,  233,   50,   47,  146,\n /*   120 */   574,  545,   65,   57,   58,   48,  579,  578,  580,  580,\n /*   130 */    55,   55,   56,   56,   56,   56,  213,   54,   54,   54,\n /*   140 */    54,   53,   53,   52,   52,   52,   51,  233,  309,  223,\n /*   150 */   539,  420,  170,  176,  138,  280,  383,  275,  382,  168,\n /*   160 */   489,  551,  409,  668,  620,  619,  271,  438,  409,  438,\n /*   170 */   550,  604,   67,  482,  507,  618,  599,  412,  587,  581,\n /*   180 */   600,  483,  618,  412,  618,  598,   91,  439,  440,  439,\n /*   190 */   335,  598,   73,  669,  222,  266,  480,   57,   58,   48,\n /*   200 */   579,  578,  580,  580,   55,   55,   56,   56,   56,   56,\n /*   210 */   670,   54,   54,   54,   54,   53,   53,   52,   52,   52,\n /*   220 */    51,  233,  309,  279,  232,  231,    1,  132,  200,  385,\n /*   230 */   620,  619,  617,  616,  278,  435,  289,  563,  175,  262,\n /*   240 */   409,  264,  437,  497,  436,  166,  441,  568,  336,  568,\n /*   250 */   201,  537,  587,  581,  599,  412,  165,  594,  600,  380,\n /*   260 */   377,  376,  597,  598,   92,  523,  618,  569,  569,  592,\n /*   270 */   375,   57,   58,   48,  579,  578,  580,  580,   55,   55,\n /*   280 */    56,   56,   56,   56,  597,   54,   54,   54,   54,   53,\n /*   290 */    53,   52,   52,   52,   51,  233,  309,  463,  617,  616,\n /*   300 */   590,  590,  590,  174,  272,  396,  409,  272,  409,  548,\n /*   310 */   397,  620,  619,   68,  326,  620,  619,  620,  619,  618,\n /*   320 */   546,  412,  618,  412,  471,  594,  587,  581,  472,  598,\n /*   330 */    92,  598,   92,   52,   52,   52,   51,  233,  513,  512,\n /*   340 */   206,  322,  363,  464,  221,   57,   58,   48,  579,  578,\n /*   350 */   580,  580,   55,   55,   56,   56,   56,   56,  529,   54,\n /*   360 */    54,   54,   54,   53,   53,   52,   52,   52,   51,  233,\n /*   370 */   309,  396,  409,  396,  597,  372,  386,  530,  347,  617,\n /*   380 */   616,  575,  202,  617,  616,  617,  616,  412,  620,  619,\n /*   390 */   145,  255,  346,  254,  577,  598,   74,  351,   45,  489,\n /*   400 */   587,  581,  235,  189,  464,  544,  167,  296,  187,  469,\n /*   410 */   479,   67,   62,   39,  618,  546,  597,  345,  573,   57,\n /*   420 */    58,   48,  579,  578,  580,  580,   55,   55,   56,   56,\n /*   430 */    56,   56,    6,   54,   54,   54,   54,   53,   53,   52,\n /*   440 */    52,   52,   51,  233,  309,  562,  558,  407,  528,  576,\n /*   450 */   576,  344,  255,  346,  254,  182,  617,  616,  503,  504,\n /*   460 */   314,  409,  557,  235,  166,  271,  409,  352,  564,  181,\n /*   470 */   407,  546,  576,  576,  587,  581,  412,  537,  556,  561,\n /*   480 */   517,  412,  618,  249,  598,   16,    7,   36,  467,  598,\n /*   490 */    92,  516,  618,   57,   58,   48,  579,  578,  580,  580,\n /*   500 */    55,   55,   56,   56,   56,   56,  541,   54,   54,   54,\n /*   510 */    54,   53,   53,   52,   52,   52,   51,  233,  309,  327,\n /*   520 */   572,  571,  525,  558,  560,  394,  871,  246,  409,  248,\n /*   530 */   171,  392,  594,  219,  407,  409,  576,  576,  502,  557,\n /*   540 */   364,  145,  510,  412,  407,  229,  576,  576,  587,  581,\n /*   550 */   412,  598,   92,  381,  269,  556,  166,  400,  598,   69,\n /*   560 */   501,  419,  945,  199,  945,  198,  546,   57,   58,   48,\n /*   570 */   579,  578,  580,  580,   55,   55,   56,   56,   56,   56,\n /*   580 */   568,   54,   54,   54,   54,   53,   53,   52,   52,   52,\n /*   590 */    51,  233,  309,  317,  419,  944,  508,  944,  308,  597,\n /*   600 */   594,  565,  490,  212,  173,  247,  423,  615,  614,  613,\n /*   610 */   323,  197,  143,  405,  572,  571,  489,   66,   50,   47,\n /*   620 */   146,  594,  587,  581,  232,  231,  559,  427,   67,  555,\n /*   630 */    15,  618,  186,  543,  303,  421,   35,  206,  432,  423,\n /*   640 */   552,   57,   58,   48,  579,  578,  580,  580,   55,   55,\n /*   650 */    56,   56,   56,   56,  205,   54,   54,   54,   54,   53,\n /*   660 */    53,   52,   52,   52,   51,  233,  309,  569,  569,  260,\n /*   670 */   268,  597,   12,  373,  568,  166,  409,  313,  409,  420,\n /*   680 */   409,  473,  473,  365,  618,   50,   47,  146,  597,  594,\n /*   690 */   468,  412,  166,  412,  351,  412,  587,  581,   32,  598,\n /*   700 */    94,  598,   97,  598,   95,  627,  625,  329,  142,   50,\n /*   710 */    47,  146,  333,  349,  358,   57,   58,   48,  579,  578,\n /*   720 */   580,  580,   55,   55,   56,   56,   56,   56,  409,   54,\n /*   730 */    54,   54,   54,   53,   53,   52,   52,   52,   51,  233,\n /*   740 */   309,  409,  388,  412,  409,   22,  565,  404,  212,  362,\n /*   750 */   389,  598,  104,  359,  409,  156,  412,  409,  603,  412,\n /*   760 */   537,  331,  569,  569,  598,  103,  493,  598,  105,  412,\n /*   770 */   587,  581,  412,  260,  549,  618,   11,  598,  106,  521,\n /*   780 */   598,  133,  169,  457,  456,  170,   35,  601,  618,   57,\n /*   790 */    58,   48,  579,  578,  580,  580,   55,   55,   56,   56,\n /*   800 */    56,   56,  409,   54,   54,   54,   54,   53,   53,   52,\n /*   810 */    52,   52,   51,  233,  309,  409,  259,  412,  409,   50,\n /*   820 */    47,  146,  357,  318,  355,  598,  134,  527,  352,  337,\n /*   830 */   412,  409,  356,  412,  357,  409,  357,  618,  598,   98,\n /*   840 */   129,  598,  102,  618,  587,  581,  412,   21,  235,  618,\n /*   850 */   412,  618,  211,  143,  598,  101,   30,  167,  598,   93,\n /*   860 */   350,  535,  203,   57,   58,   48,  579,  578,  580,  580,\n /*   870 */    55,   55,   56,   56,   56,   56,  409,   54,   54,   54,\n /*   880 */    54,   53,   53,   52,   52,   52,   51,  233,  309,  409,\n /*   890 */   526,  412,  409,  425,  215,  305,  597,  551,  141,  598,\n /*   900 */   100,   40,  409,   38,  412,  409,  550,  412,  409,  228,\n /*   910 */   220,  314,  598,   77,  500,  598,   96,  412,  587,  581,\n /*   920 */   412,  338,  253,  412,  218,  598,  137,  379,  598,  136,\n /*   930 */    28,  598,  135,  270,  715,  210,  481,   57,   58,   48,\n /*   940 */   579,  578,  580,  580,   55,   55,   56,   56,   56,   56,\n /*   950 */   409,   54,   54,   54,   54,   53,   53,   52,   52,   52,\n /*   960 */    51,  233,  309,  409,  272,  412,  409,  315,  147,  597,\n /*   970 */   272,  626,    2,  598,   76,  209,  409,  127,  412,  618,\n /*   980 */   126,  412,  409,  621,  235,  618,  598,   90,  374,  598,\n /*   990 */    89,  412,  587,  581,   27,  260,  350,  412,  618,  598,\n /*  1000 */    75,  321,  541,  541,  125,  598,   88,  320,  278,  597,\n /*  1010 */   618,   57,   46,   48,  579,  578,  580,  580,   55,   55,\n /*  1020 */    56,   56,   56,   56,  409,   54,   54,   54,   54,   53,\n /*  1030 */    53,   52,   52,   52,   51,  233,  309,  409,  450,  412,\n /*  1040 */   164,  284,  282,  272,  609,  424,  304,  598,   87,  370,\n /*  1050 */   409,  477,  412,  409,  608,  409,  607,  602,  618,  618,\n /*  1060 */   598,   99,  586,  585,  122,  412,  587,  581,  412,  618,\n /*  1070 */   412,  618,  618,  598,   86,  366,  598,   17,  598,   85,\n /*  1080 */   319,  185,  519,  518,  583,  582,   58,   48,  579,  578,\n /*  1090 */   580,  580,   55,   55,   56,   56,   56,   56,  409,   54,\n /*  1100 */    54,   54,   54,   53,   53,   52,   52,   52,   51,  233,\n /*  1110 */   309,  584,  409,  412,  409,  260,  260,  260,  408,  591,\n /*  1120 */   474,  598,   84,  170,  409,  466,  518,  412,  121,  412,\n /*  1130 */   618,  618,  618,  618,  618,  598,   83,  598,   72,  412,\n /*  1140 */   587,  581,   51,  233,  625,  329,  470,  598,   71,  257,\n /*  1150 */   159,  120,   14,  462,  157,  158,  117,  260,  448,  447,\n /*  1160 */   446,   48,  579,  578,  580,  580,   55,   55,   56,   56,\n /*  1170 */    56,   56,  618,   54,   54,   54,   54,   53,   53,   52,\n /*  1180 */    52,   52,   51,  233,   44,  403,  260,    3,  409,  459,\n /*  1190 */   260,  413,  619,  118,  398,   10,   25,   24,  554,  348,\n /*  1200 */   217,  618,  406,  412,  409,  618,    4,   44,  403,  618,\n /*  1210 */     3,  598,   82,  618,  413,  619,  455,  542,  115,  412,\n /*  1220 */   538,  401,  536,  274,  506,  406,  251,  598,   81,  216,\n /*  1230 */   273,  563,  618,  243,  453,  618,  154,  618,  618,  618,\n /*  1240 */   449,  416,  623,  110,  401,  618,  409,  236,   64,  123,\n /*  1250 */   487,   41,   42,  531,  563,  204,  409,  267,   43,  411,\n /*  1260 */   410,  412,  265,  592,  108,  618,  107,  434,  332,  598,\n /*  1270 */    80,  412,  618,  263,   41,   42,  443,  618,  409,  598,\n /*  1280 */    70,   43,  411,  410,  433,  261,  592,  149,  618,  597,\n /*  1290 */   256,  237,  188,  412,  590,  590,  590,  589,  588,   13,\n /*  1300 */   618,  598,   18,  328,  235,  618,   44,  403,  360,    3,\n /*  1310 */   418,  461,  339,  413,  619,  227,  124,  590,  590,  590,\n /*  1320 */   589,  588,   13,  618,  406,  409,  618,  409,  139,   34,\n /*  1330 */   403,  387,    3,  148,  622,  312,  413,  619,  311,  330,\n /*  1340 */   412,  460,  412,  401,  180,  353,  412,  406,  598,   79,\n /*  1350 */   598,   78,  250,  563,  598,    9,  618,  612,  611,  610,\n /*  1360 */   618,    8,  452,  442,  242,  415,  401,  618,  239,  235,\n /*  1370 */   179,  238,  428,   41,   42,  288,  563,  618,  618,  618,\n /*  1380 */    43,  411,  410,  618,  144,  592,  618,  618,  177,   61,\n /*  1390 */   618,  596,  391,  620,  619,  287,   41,   42,  414,  618,\n /*  1400 */   293,   30,  393,   43,  411,  410,  292,  618,  592,   31,\n /*  1410 */   618,  395,  291,   60,  230,   37,  590,  590,  590,  589,\n /*  1420 */   588,   13,  214,  553,  183,  290,  172,  301,  300,  299,\n /*  1430 */   178,  297,  595,  563,  451,   29,  285,  390,  540,  590,\n /*  1440 */   590,  590,  589,  588,   13,  283,  520,  534,  150,  533,\n /*  1450 */   241,  281,  384,  192,  191,  324,  515,  514,  276,  240,\n /*  1460 */   510,  523,  307,  511,  128,  592,  509,  225,  226,  486,\n /*  1470 */   485,  224,  152,  491,  464,  306,  484,  163,  153,  371,\n /*  1480 */   478,  151,  162,  258,  369,  161,  367,  208,  475,  476,\n /*  1490 */    26,  160,  465,  140,  361,  131,  590,  590,  590,  116,\n /*  1500 */   119,  454,  343,  155,  114,  342,  113,  112,  445,  111,\n /*  1510 */   130,  109,  431,  316,  426,  430,   23,  429,   20,  606,\n /*  1520 */   190,  507,  255,  341,  244,   63,  294,  593,  310,  570,\n /*  1530 */   277,  402,  354,  235,  567,  496,  495,  492,  494,  302,\n /*  1540 */   458,  378,  286,  245,  566,    5,  252,  547,  193,  444,\n /*  1550 */   233,  340,  207,  524,  368,  505,  334,  522,  499,  399,\n /*  1560 */   295,  498,  956,  488,\n};\nstatic const YYCODETYPE yy_lookahead[] = {\n /*     0 */    19,  142,  143,  144,  145,   24,    1,   26,   77,   78,\n /*    10 */    79,   80,   81,   82,   83,   84,   85,   86,   87,   88,\n /*    20 */    89,   90,   91,   92,   26,   27,   15,   26,   27,  197,\n /*    30 */    49,   50,   77,   78,   79,   80,  204,   82,   83,   84,\n /*    40 */    85,   86,   87,   88,   89,   90,   91,   92,   23,   68,\n /*    50 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,\n /*    60 */    79,   80,  166,   82,   83,   84,   85,   86,   87,   88,\n /*    70 */    89,   90,   91,   92,   19,   94,   19,  105,  106,  107,\n /*    80 */    25,   82,   83,   84,   85,   86,   87,   88,   89,   90,\n /*    90 */    91,   92,   94,   95,   96,   94,   95,   99,  100,  101,\n /*   100 */   112,  205,  114,  115,   49,   50,   22,   23,  110,   54,\n /*   110 */    86,   87,   88,   89,   90,   91,   92,  221,  222,  223,\n /*   120 */    23,  120,   25,   68,   69,   70,   71,   72,   73,   74,\n /*   130 */    75,   76,   77,   78,   79,   80,   22,   82,   83,   84,\n /*   140 */    85,   86,   87,   88,   89,   90,   91,   92,   19,   92,\n /*   150 */    23,   67,   25,   96,   97,   98,   99,  100,  101,  102,\n /*   160 */   150,   32,  150,  118,   26,   27,  109,  150,  150,  150,\n /*   170 */    41,  161,  162,  180,  181,  165,  113,  165,   49,   50,\n /*   180 */   117,  188,  165,  165,  165,  173,  174,  170,  171,  170,\n /*   190 */   171,  173,  174,  118,  184,   16,  186,   68,   69,   70,\n /*   200 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,\n /*   210 */   118,   82,   83,   84,   85,   86,   87,   88,   89,   90,\n /*   220 */    91,   92,   19,   98,   86,   87,   22,   24,  160,   88,\n /*   230 */    26,   27,   94,   95,  109,   97,  224,   66,  118,   60,\n /*   240 */   150,   62,  104,   23,  106,   25,  229,  230,  229,  230,\n /*   250 */   160,  150,   49,   50,  113,  165,   96,   26,  117,   99,\n /*   260 */   100,  101,  194,  173,  174,   94,  165,  129,  130,   98,\n /*   270 */   110,   68,   69,   70,   71,   72,   73,   74,   75,   76,\n /*   280 */    77,   78,   79,   80,  194,   82,   83,   84,   85,   86,\n /*   290 */    87,   88,   89,   90,   91,   92,   19,   11,   94,   95,\n /*   300 */   129,  130,  131,  118,  150,  215,  150,  150,  150,   25,\n /*   310 */   220,   26,   27,   22,  213,   26,   27,   26,   27,  165,\n /*   320 */    25,  165,  165,  165,   30,   94,   49,   50,   34,  173,\n /*   330 */   174,  173,  174,   88,   89,   90,   91,   92,    7,    8,\n /*   340 */   160,  187,   48,   57,  187,   68,   69,   70,   71,   72,\n /*   350 */    73,   74,   75,   76,   77,   78,   79,   80,   23,   82,\n /*   360 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,\n /*   370 */    19,  215,  150,  215,  194,   19,  220,   88,  220,   94,\n /*   380 */    95,   23,  160,   94,   95,   94,   95,  165,   26,   27,\n /*   390 */    95,  105,  106,  107,  113,  173,  174,  217,   22,  150,\n /*   400 */    49,   50,  116,  119,   57,  120,   50,  158,   22,   21,\n /*   410 */   161,  162,  232,  136,  165,  120,  194,  237,   23,   68,\n /*   420 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,\n /*   430 */    79,   80,   22,   82,   83,   84,   85,   86,   87,   88,\n /*   440 */    89,   90,   91,   92,   19,   23,   12,  112,   23,  114,\n /*   450 */   115,   63,  105,  106,  107,   23,   94,   95,   97,   98,\n /*   460 */   104,  150,   28,  116,   25,  109,  150,  150,   23,   23,\n /*   470 */   112,   25,  114,  115,   49,   50,  165,  150,   44,   11,\n /*   480 */    46,  165,  165,   16,  173,  174,   76,  136,  100,  173,\n /*   490 */   174,   57,  165,   68,   69,   70,   71,   72,   73,   74,\n /*   500 */    75,   76,   77,   78,   79,   80,  166,   82,   83,   84,\n /*   510 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  169,\n /*   520 */   170,  171,   23,   12,   23,  214,  138,   60,  150,   62,\n /*   530 */    24,  215,   26,  216,  112,  150,  114,  115,   36,   28,\n /*   540 */   213,   95,  103,  165,  112,  205,  114,  115,   49,   50,\n /*   550 */   165,  173,  174,   51,   23,   44,   25,   46,  173,  174,\n /*   560 */    58,   22,   23,   22,   25,  160,  120,   68,   69,   70,\n /*   570 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,\n /*   580 */   230,   82,   83,   84,   85,   86,   87,   88,   89,   90,\n /*   590 */    91,   92,   19,  215,   22,   23,   23,   25,  163,  194,\n /*   600 */    94,  166,  167,  168,   25,  138,   67,    7,    8,    9,\n /*   610 */   108,  206,  207,  169,  170,  171,  150,   22,  221,  222,\n /*   620 */   223,   26,   49,   50,   86,   87,   23,  161,  162,   23,\n /*   630 */    22,  165,   24,  120,   22,   23,   25,  160,  241,   67,\n /*   640 */   176,   68,   69,   70,   71,   72,   73,   74,   75,   76,\n /*   650 */    77,   78,   79,   80,  160,   82,   83,   84,   85,   86,\n /*   660 */    87,   88,   89,   90,   91,   92,   19,  129,  130,  150,\n /*   670 */    23,  194,   35,   23,  230,   25,  150,  155,  150,   67,\n /*   680 */   150,  105,  106,  107,  165,  221,  222,  223,  194,   94,\n /*   690 */    23,  165,   25,  165,  217,  165,   49,   50,   25,  173,\n /*   700 */   174,  173,  174,  173,  174,    0,    1,    2,  118,  221,\n /*   710 */   222,  223,  193,  219,  237,   68,   69,   70,   71,   72,\n /*   720 */    73,   74,   75,   76,   77,   78,   79,   80,  150,   82,\n /*   730 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,\n /*   740 */    19,  150,   19,  165,  150,   24,  166,  167,  168,  227,\n /*   750 */    27,  173,  174,  231,  150,   25,  165,  150,  172,  165,\n /*   760 */   150,  242,  129,  130,  173,  174,  180,  173,  174,  165,\n /*   770 */    49,   50,  165,  150,  176,  165,   35,  173,  174,  165,\n /*   780 */   173,  174,   35,   23,   23,   25,   25,  173,  165,   68,\n /*   790 */    69,   70,   71,   72,   73,   74,   75,   76,   77,   78,\n /*   800 */    79,   80,  150,   82,   83,   84,   85,   86,   87,   88,\n /*   810 */    89,   90,   91,   92,   19,  150,  193,  165,  150,  221,\n /*   820 */   222,  223,  150,  213,   19,  173,  174,   23,  150,   97,\n /*   830 */   165,  150,   27,  165,  150,  150,  150,  165,  173,  174,\n /*   840 */    22,  173,  174,  165,   49,   50,  165,   52,  116,  165,\n /*   850 */   165,  165,  206,  207,  173,  174,  126,   50,  173,  174,\n /*   860 */   128,   27,  160,   68,   69,   70,   71,   72,   73,   74,\n /*   870 */    75,   76,   77,   78,   79,   80,  150,   82,   83,   84,\n /*   880 */    85,   86,   87,   88,   89,   90,   91,   92,   19,  150,\n /*   890 */    23,  165,  150,   23,  216,   25,  194,   32,   39,  173,\n /*   900 */   174,  135,  150,  137,  165,  150,   41,  165,  150,   52,\n /*   910 */   238,  104,  173,  174,   29,  173,  174,  165,   49,   50,\n /*   920 */   165,  219,  238,  165,  238,  173,  174,   52,  173,  174,\n /*   930 */    22,  173,  174,   23,   23,  160,   25,   68,   69,   70,\n /*   940 */    71,   72,   73,   74,   75,   76,   77,   78,   79,   80,\n /*   950 */   150,   82,   83,   84,   85,   86,   87,   88,   89,   90,\n /*   960 */    91,   92,   19,  150,  150,  165,  150,  245,  246,  194,\n /*   970 */   150,  144,  145,  173,  174,  160,  150,   22,  165,  165,\n /*   980 */    22,  165,  150,  150,  116,  165,  173,  174,   52,  173,\n /*   990 */   174,  165,   49,   50,   22,  150,  128,  165,  165,  173,\n /*  1000 */   174,  187,  166,  166,   22,  173,  174,  187,  109,  194,\n /*  1010 */   165,   68,   69,   70,   71,   72,   73,   74,   75,   76,\n /*  1020 */    77,   78,   79,   80,  150,   82,   83,   84,   85,   86,\n /*  1030 */    87,   88,   89,   90,   91,   92,   19,  150,  193,  165,\n /*  1040 */   102,  205,  205,  150,  150,  247,  248,  173,  174,   19,\n /*  1050 */   150,   20,  165,  150,  150,  150,  150,  150,  165,  165,\n /*  1060 */   173,  174,   49,   50,  104,  165,   49,   50,  165,  165,\n /*  1070 */   165,  165,  165,  173,  174,   43,  173,  174,  173,  174,\n /*  1080 */   187,   24,  190,  191,   71,   72,   69,   70,   71,   72,\n /*  1090 */    73,   74,   75,   76,   77,   78,   79,   80,  150,   82,\n /*  1100 */    83,   84,   85,   86,   87,   88,   89,   90,   91,   92,\n /*  1110 */    19,   98,  150,  165,  150,  150,  150,  150,  150,  150,\n /*  1120 */    59,  173,  174,   25,  150,  190,  191,  165,   53,  165,\n /*  1130 */   165,  165,  165,  165,  165,  173,  174,  173,  174,  165,\n /*  1140 */    49,   50,   91,   92,    1,    2,   53,  173,  174,  138,\n /*  1150 */   104,   22,    5,    1,   35,  118,  127,  150,  193,  193,\n /*  1160 */   193,   70,   71,   72,   73,   74,   75,   76,   77,   78,\n /*  1170 */    79,   80,  165,   82,   83,   84,   85,   86,   87,   88,\n /*  1180 */    89,   90,   91,   92,   19,   20,  150,   22,  150,   27,\n /*  1190 */   150,   26,   27,  108,  150,   22,   76,   76,  150,   25,\n /*  1200 */   193,  165,   37,  165,  150,  165,   22,   19,   20,  165,\n /*  1210 */    22,  173,  174,  165,   26,   27,   23,  150,  119,  165,\n /*  1220 */   150,   56,  150,  150,  150,   37,   16,  173,  174,  193,\n /*  1230 */   150,   66,  165,  193,    1,  165,  121,  165,  165,  165,\n /*  1240 */    20,  146,  147,  119,   56,  165,  150,  152,   16,  154,\n /*  1250 */   150,   86,   87,   88,   66,  160,  150,  150,   93,   94,\n /*  1260 */    95,  165,  150,   98,  108,  165,  127,   23,   65,  173,\n /*  1270 */   174,  165,  165,  150,   86,   87,  128,  165,  150,  173,\n /*  1280 */   174,   93,   94,   95,   23,  150,   98,   15,  165,  194,\n /*  1290 */   150,  140,   22,  165,  129,  130,  131,  132,  133,  134,\n /*  1300 */   165,  173,  174,    3,  116,  165,   19,   20,  150,   22,\n /*  1310 */     4,  150,  217,   26,   27,  179,  179,  129,  130,  131,\n /*  1320 */   132,  133,  134,  165,   37,  150,  165,  150,  164,   19,\n /*  1330 */    20,  150,   22,  246,  149,  249,   26,   27,  249,  244,\n /*  1340 */   165,  150,  165,   56,    6,  150,  165,   37,  173,  174,\n /*  1350 */   173,  174,  150,   66,  173,  174,  165,  149,  149,   13,\n /*  1360 */   165,   25,  150,  150,  150,  149,   56,  165,  150,  116,\n /*  1370 */   151,  150,  150,   86,   87,  150,   66,  165,  165,  165,\n /*  1380 */    93,   94,   95,  165,  150,   98,  165,  165,  151,   22,\n /*  1390 */   165,  194,  150,   26,   27,  150,   86,   87,  159,  165,\n /*  1400 */   199,  126,  123,   93,   94,   95,  200,  165,   98,  124,\n /*  1410 */   165,  122,  201,  125,  225,  135,  129,  130,  131,  132,\n /*  1420 */   133,  134,    5,  157,  157,  202,  118,   10,   11,   12,\n /*  1430 */    13,   14,  203,   66,   17,  104,  210,  121,  211,  129,\n /*  1440 */   130,  131,  132,  133,  134,  210,  175,  211,   31,  211,\n /*  1450 */    33,  210,  104,   86,   87,   47,  175,  183,  175,   42,\n /*  1460 */   103,   94,  178,  177,   22,   98,  175,   92,  228,  175,\n /*  1470 */   175,  228,   55,  183,   57,  178,  175,  156,   61,   18,\n /*  1480 */   157,   64,  156,  235,  157,  156,   45,  157,  236,  157,\n /*  1490 */   135,  156,  189,   68,  157,  218,  129,  130,  131,   22,\n /*  1500 */   189,  199,  157,  156,  192,   18,  192,  192,  199,  192,\n /*  1510 */   218,  189,   40,  157,   38,  157,  240,  157,  240,  153,\n /*  1520 */   196,  181,  105,  106,  107,  243,  198,  166,  111,  230,\n /*  1530 */   176,  226,  239,  116,  230,  176,  166,  166,  176,  148,\n /*  1540 */   199,  177,  209,  209,  166,  196,  239,  208,  185,  199,\n /*  1550 */    92,  209,  233,  173,  234,  182,  139,  173,  182,  191,\n /*  1560 */   195,  182,  250,  186,\n};\n#define YY_SHIFT_USE_DFLT (-70)\n#define YY_SHIFT_COUNT (416)\n#define YY_SHIFT_MIN   (-69)\n#define YY_SHIFT_MAX   (1487)\nstatic const short yy_shift_ofst[] = {\n /*     0 */  1143, 1188, 1417, 1188, 1287, 1287,  138,  138,   -2,  -19,\n /*    10 */  1287, 1287, 1287, 1287,  347,  362,  129,  129,  795, 1165,\n /*    20 */  1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,\n /*    30 */  1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,\n /*    40 */  1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,\n /*    50 */  1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,\n /*    60 */  1287, 1287,  286,  362,  362,  538,  538,  231, 1253,   55,\n /*    70 */   721,  647,  573,  499,  425,  351,  277,  203,  869,  869,\n /*    80 */   869,  869,  869,  869,  869,  869,  869,  869,  869,  869,\n /*    90 */   869,  869,  869,  943,  869, 1017, 1091, 1091,  -69,  -45,\n /*   100 */   -45,  -45,  -45,  -45,   -1,   24,  245,  362,  362,  362,\n /*   110 */   362,  362,  362,  362,  362,  362,  362,  362,  362,  362,\n /*   120 */   362,  362,  362,  388,  356,  362,  362,  362,  362,  362,\n /*   130 */   732,  868,  231, 1051, 1458,  -70,  -70,  -70, 1367,   57,\n /*   140 */   434,  434,  289,  291,  285,    1,  204,  572,  539,  362,\n /*   150 */   362,  362,  362,  362,  362,  362,  362,  362,  362,  362,\n /*   160 */   362,  362,  362,  362,  362,  362,  362,  362,  362,  362,\n /*   170 */   362,  362,  362,  362,  362,  362,  362,  362,  362,  362,\n /*   180 */   362,  506,  506,  506,  705, 1253, 1253, 1253,  -70,  -70,\n /*   190 */   -70,  171,  171,  160,  502,  502,  502,  446,  432,  511,\n /*   200 */   422,  358,  335,  -12,  -12,  -12,  -12,  576,  294,  -12,\n /*   210 */   -12,  295,  595,  141,  600,  730,  723,  723,  805,  730,\n /*   220 */   805,  439,  911,  231,  865,  231,  865,  807,  865,  723,\n /*   230 */   766,  633,  633,  231,  284,   63,  608, 1476, 1308, 1308,\n /*   240 */  1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487,\n /*   250 */  1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441,\n /*   260 */  1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348,\n /*   270 */  1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348,\n /*   280 */  1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280,\n /*   290 */  1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338,\n /*   300 */  1338, 1338, 1338,  -70,  -70,  -70,  -70,  -70,  -70, 1013,\n /*   310 */   467,  612,   84,  179,  -28,  870,  410,  761,  760,  667,\n /*   320 */   650,  531,  220,  361,  331,  125,  127,   97, 1306, 1300,\n /*   330 */  1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139,\n /*   340 */  1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174,\n /*   350 */  1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147,\n /*   360 */  1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032,  960, 1057,\n /*   370 */  1031, 1030,  899,  938,  982,  936,  972,  958,  910,  955,\n /*   380 */   875,  885,  908,  857,  859,  867,  804,  590,  834,  747,\n /*   390 */   818,  513,  611,  741,  673,  637,  611,  606,  603,  579,\n /*   400 */   501,  541,  468,  386,  445,  395,  376,  281,  185,  120,\n /*   410 */    92,   75,   45,  114,   25,   11,    5,\n};\n#define YY_REDUCE_USE_DFLT (-169)\n#define YY_REDUCE_COUNT (308)\n#define YY_REDUCE_MIN   (-168)\n#define YY_REDUCE_MAX   (1391)\nstatic const short yy_reduce_ofst[] = {\n /*     0 */  -141,   90, 1095,  222,  158,  156,   19,   17,   10, -104,\n /*    10 */   378,  316,  311,   12,  180,  249,  598,  464,  397, 1181,\n /*    20 */  1177, 1175, 1128, 1106, 1096, 1054, 1038,  974,  964,  962,\n /*    30 */   948,  905,  903,  900,  887,  874,  832,  826,  816,  813,\n /*    40 */   800,  758,  755,  752,  742,  739,  726,  685,  681,  668,\n /*    50 */   665,  652,  607,  604,  594,  591,  578,  530,  528,  526,\n /*    60 */   385,   18,  477,  466,  519,  444,  350,  435,  405,  488,\n /*    70 */   488,  488,  488,  488,  488,  488,  488,  488,  488,  488,\n /*    80 */   488,  488,  488,  488,  488,  488,  488,  488,  488,  488,\n /*    90 */   488,  488,  488,  488,  488,  488,  488,  488,  488,  488,\n /*   100 */   488,  488,  488,  488,  488,  488,  488, 1040,  678, 1036,\n /*   110 */  1007,  967,  966,  965,  845,  686,  610,  684,  317,  672,\n /*   120 */   893,  327,  623,  522,   -7,  820,  814,  157,  154,  101,\n /*   130 */   702,  494,  580,  488,  488,  488,  488,  488,  614,  586,\n /*   140 */   935,  892,  968, 1245, 1242, 1234, 1225,  798,  798, 1222,\n /*   150 */  1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158,\n /*   160 */  1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072,\n /*   170 */  1070, 1067, 1048, 1044,  969,  968,  907,  906,  904,  894,\n /*   180 */   833,  837,  836,  340,  827,  815,  775,   68,  722,  646,\n /*   190 */  -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368,\n /*   200 */  1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365,\n /*   210 */  1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341,\n /*   220 */  1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333,\n /*   230 */  1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358,\n /*   240 */  1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312,\n /*   250 */  1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248,\n /*   260 */  1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295,\n /*   270 */  1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281,\n /*   280 */  1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189,\n /*   290 */  1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216,\n /*   300 */  1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164,\n};\nstatic const YYACTIONTYPE yy_default[] = {\n /*     0 */   632,  866,  954,  954,  866,  866,  954,  954,  954,  756,\n /*    10 */   954,  954,  954,  864,  954,  954,  784,  784,  928,  954,\n /*    20 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*    30 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*    40 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*    50 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*    60 */   954,  954,  954,  954,  954,  954,  954,  671,  760,  790,\n /*    70 */   954,  954,  954,  954,  954,  954,  954,  954,  927,  929,\n /*    80 */   798,  797,  907,  771,  795,  788,  792,  867,  860,  861,\n /*    90 */   859,  863,  868,  954,  791,  827,  844,  826,  838,  843,\n /*   100 */   850,  842,  839,  829,  828,  830,  831,  954,  954,  954,\n /*   110 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   120 */   954,  954,  954,  658,  725,  954,  954,  954,  954,  954,\n /*   130 */   954,  954,  954,  832,  833,  847,  846,  845,  954,  663,\n /*   140 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   150 */   934,  932,  954,  879,  954,  954,  954,  954,  954,  954,\n /*   160 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   170 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   180 */   638,  756,  756,  756,  632,  954,  954,  954,  946,  760,\n /*   190 */   750,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   200 */   954,  954,  954,  800,  739,  917,  919,  954,  900,  737,\n /*   210 */   660,  758,  673,  748,  640,  794,  773,  773,  912,  794,\n /*   220 */   912,  696,  719,  954,  784,  954,  784,  693,  784,  773,\n /*   230 */   862,  954,  954,  954,  757,  748,  954,  939,  764,  764,\n /*   240 */   931,  931,  764,  806,  729,  794,  736,  736,  736,  736,\n /*   250 */   764,  655,  794,  806,  729,  729,  764,  655,  906,  904,\n /*   260 */   764,  764,  655,  764,  655,  764,  655,  872,  727,  727,\n /*   270 */   727,  711,  876,  876,  872,  727,  696,  727,  711,  727,\n /*   280 */   727,  777,  772,  777,  772,  777,  772,  764,  764,  954,\n /*   290 */   789,  778,  787,  785,  794,  954,  714,  648,  648,  637,\n /*   300 */   637,  637,  637,  951,  951,  946,  698,  698,  681,  954,\n /*   310 */   954,  954,  954,  954,  954,  954,  881,  954,  954,  954,\n /*   320 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  633,\n /*   330 */   941,  954,  954,  938,  954,  954,  954,  954,  799,  954,\n /*   340 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  916,\n /*   350 */   954,  954,  954,  954,  954,  954,  954,  910,  954,  954,\n /*   360 */   954,  954,  954,  954,  903,  902,  954,  954,  954,  954,\n /*   370 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   380 */   954,  954,  954,  954,  954,  954,  954,  954,  954,  954,\n /*   390 */   954,  954,  786,  954,  779,  954,  865,  954,  954,  954,\n /*   400 */   954,  954,  954,  954,  954,  954,  954,  742,  815,  954,\n /*   410 */   814,  818,  813,  665,  954,  646,  954,  629,  634,  950,\n /*   420 */   953,  952,  949,  948,  947,  942,  940,  937,  936,  935,\n /*   430 */   933,  930,  926,  885,  883,  890,  889,  888,  887,  886,\n /*   440 */   884,  882,  880,  801,  796,  793,  925,  878,  738,  735,\n /*   450 */   734,  654,  943,  909,  918,  805,  804,  807,  915,  914,\n /*   460 */   913,  911,  908,  895,  803,  802,  730,  870,  869,  657,\n /*   470 */   899,  898,  897,  901,  905,  896,  766,  656,  653,  662,\n /*   480 */   717,  718,  726,  724,  723,  722,  721,  720,  716,  664,\n /*   490 */   672,  710,  695,  694,  875,  877,  874,  873,  703,  702,\n /*   500 */   708,  707,  706,  705,  704,  701,  700,  699,  692,  691,\n /*   510 */   697,  690,  713,  712,  709,  689,  733,  732,  731,  728,\n /*   520 */   688,  687,  686,  818,  685,  684,  824,  823,  811,  854,\n /*   530 */   753,  752,  751,  763,  762,  775,  774,  809,  808,  776,\n /*   540 */   761,  755,  754,  770,  769,  768,  767,  759,  749,  781,\n /*   550 */   783,  782,  780,  856,  765,  853,  924,  923,  922,  921,\n /*   560 */   920,  858,  857,  825,  822,  676,  677,  893,  892,  894,\n /*   570 */   891,  679,  678,  675,  674,  855,  744,  743,  851,  848,\n /*   580 */   840,  836,  852,  849,  841,  837,  835,  834,  820,  819,\n /*   590 */   817,  816,  812,  821,  667,  745,  741,  740,  810,  747,\n /*   600 */   746,  683,  682,  680,  661,  659,  652,  650,  649,  651,\n /*   610 */   647,  645,  644,  643,  642,  641,  670,  669,  668,  666,\n /*   620 */   665,  639,  636,  635,  631,  630,  628,\n};\n\n/* The next table maps tokens into fallback tokens.  If a construct\n** like the following:\n** \n**      %fallback ID X Y Z.\n**\n** appears in the grammar, then ID becomes a fallback token for X, Y,\n** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser\n** but it does not parse, the type of the token is changed to ID and\n** the parse is retried before an error is thrown.\n*/\n#ifdef YYFALLBACK\nstatic const YYCODETYPE yyFallback[] = {\n    0,  /*          $ => nothing */\n    0,  /*       SEMI => nothing */\n   26,  /*    EXPLAIN => ID */\n   26,  /*      QUERY => ID */\n   26,  /*       PLAN => ID */\n   26,  /*      BEGIN => ID */\n    0,  /* TRANSACTION => nothing */\n   26,  /*   DEFERRED => ID */\n   26,  /*  IMMEDIATE => ID */\n   26,  /*  EXCLUSIVE => ID */\n    0,  /*     COMMIT => nothing */\n   26,  /*        END => ID */\n   26,  /*   ROLLBACK => ID */\n   26,  /*  SAVEPOINT => ID */\n   26,  /*    RELEASE => ID */\n    0,  /*         TO => nothing */\n    0,  /*      TABLE => nothing */\n    0,  /*     CREATE => nothing */\n   26,  /*         IF => ID */\n    0,  /*        NOT => nothing */\n    0,  /*     EXISTS => nothing */\n   26,  /*       TEMP => ID */\n    0,  /*         LP => nothing */\n    0,  /*         RP => nothing */\n    0,  /*         AS => nothing */\n    0,  /*      COMMA => nothing */\n    0,  /*         ID => nothing */\n    0,  /*    INDEXED => nothing */\n   26,  /*      ABORT => ID */\n   26,  /*     ACTION => ID */\n   26,  /*      AFTER => ID */\n   26,  /*    ANALYZE => ID */\n   26,  /*        ASC => ID */\n   26,  /*     ATTACH => ID */\n   26,  /*     BEFORE => ID */\n   26,  /*         BY => ID */\n   26,  /*    CASCADE => ID */\n   26,  /*       CAST => ID */\n   26,  /*   COLUMNKW => ID */\n   26,  /*   CONFLICT => ID */\n   26,  /*   DATABASE => ID */\n   26,  /*       DESC => ID */\n   26,  /*     DETACH => ID */\n   26,  /*       EACH => ID */\n   26,  /*       FAIL => ID */\n   26,  /*        FOR => ID */\n   26,  /*     IGNORE => ID */\n   26,  /*  INITIALLY => ID */\n   26,  /*    INSTEAD => ID */\n   26,  /*    LIKE_KW => ID */\n   26,  /*      MATCH => ID */\n   26,  /*         NO => ID */\n   26,  /*        KEY => ID */\n   26,  /*         OF => ID */\n   26,  /*     OFFSET => ID */\n   26,  /*     PRAGMA => ID */\n   26,  /*      RAISE => ID */\n   26,  /*    REPLACE => ID */\n   26,  /*   RESTRICT => ID */\n   26,  /*        ROW => ID */\n   26,  /*    TRIGGER => ID */\n   26,  /*     VACUUM => ID */\n   26,  /*       VIEW => ID */\n   26,  /*    VIRTUAL => ID */\n   26,  /*    REINDEX => ID */\n   26,  /*     RENAME => ID */\n   26,  /*   CTIME_KW => ID */\n};\n#endif /* YYFALLBACK */\n\n/* The following structure represents a single element of the\n** parser's stack.  Information stored includes:\n**\n**   +  The state number for the parser at this level of the stack.\n**\n**   +  The value of the token stored at this level of the stack.\n**      (In other words, the \"major\" token.)\n**\n**   +  The semantic value stored at this level of the stack.  This is\n**      the information used by the action routines in the grammar.\n**      It is sometimes called the \"minor\" token.\n*/\nstruct yyStackEntry {\n  YYACTIONTYPE stateno;  /* The state-number */\n  YYCODETYPE major;      /* The major token value.  This is the code\n                         ** number for the token at this stack level */\n  YYMINORTYPE minor;     /* The user-supplied minor token value.  This\n                         ** is the value of the token  */\n};\ntypedef struct yyStackEntry yyStackEntry;\n\n/* The state of the parser is completely contained in an instance of\n** the following structure */\nstruct yyParser {\n  int yyidx;                    /* Index of top element in stack */\n#ifdef YYTRACKMAXSTACKDEPTH\n  int yyidxMax;                 /* Maximum value of yyidx */\n#endif\n  int yyerrcnt;                 /* Shifts left before out of the error */\n  sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */\n#if YYSTACKDEPTH<=0\n  int yystksz;                  /* Current side of the stack */\n  yyStackEntry *yystack;        /* The parser's stack */\n#else\n  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */\n#endif\n};\ntypedef struct yyParser yyParser;\n\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic FILE *yyTraceFILE = 0;\nstatic char *yyTracePrompt = 0;\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* \n** Turn parser tracing on by giving a stream to which to write the trace\n** and a prompt to preface each trace message.  Tracing is turned off\n** by making either argument NULL \n**\n** Inputs:\n** <ul>\n** <li> A FILE* to which trace output should be written.\n**      If NULL, then tracing is turned off.\n** <li> A prefix string written at the beginning of every\n**      line of trace output.  If NULL, then tracing is\n**      turned off.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3ParserTrace(FILE *TraceFILE, char *zTracePrompt){\n  yyTraceFILE = TraceFILE;\n  yyTracePrompt = zTracePrompt;\n  if( yyTraceFILE==0 ) yyTracePrompt = 0;\n  else if( yyTracePrompt==0 ) yyTraceFILE = 0;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing shifts, the names of all terminals and nonterminals\n** are required.  The following table supplies these names */\nstatic const char *const yyTokenName[] = { \n  \"$\",             \"SEMI\",          \"EXPLAIN\",       \"QUERY\",       \n  \"PLAN\",          \"BEGIN\",         \"TRANSACTION\",   \"DEFERRED\",    \n  \"IMMEDIATE\",     \"EXCLUSIVE\",     \"COMMIT\",        \"END\",         \n  \"ROLLBACK\",      \"SAVEPOINT\",     \"RELEASE\",       \"TO\",          \n  \"TABLE\",         \"CREATE\",        \"IF\",            \"NOT\",         \n  \"EXISTS\",        \"TEMP\",          \"LP\",            \"RP\",          \n  \"AS\",            \"COMMA\",         \"ID\",            \"INDEXED\",     \n  \"ABORT\",         \"ACTION\",        \"AFTER\",         \"ANALYZE\",     \n  \"ASC\",           \"ATTACH\",        \"BEFORE\",        \"BY\",          \n  \"CASCADE\",       \"CAST\",          \"COLUMNKW\",      \"CONFLICT\",    \n  \"DATABASE\",      \"DESC\",          \"DETACH\",        \"EACH\",        \n  \"FAIL\",          \"FOR\",           \"IGNORE\",        \"INITIALLY\",   \n  \"INSTEAD\",       \"LIKE_KW\",       \"MATCH\",         \"NO\",          \n  \"KEY\",           \"OF\",            \"OFFSET\",        \"PRAGMA\",      \n  \"RAISE\",         \"REPLACE\",       \"RESTRICT\",      \"ROW\",         \n  \"TRIGGER\",       \"VACUUM\",        \"VIEW\",          \"VIRTUAL\",     \n  \"REINDEX\",       \"RENAME\",        \"CTIME_KW\",      \"ANY\",         \n  \"OR\",            \"AND\",           \"IS\",            \"BETWEEN\",     \n  \"IN\",            \"ISNULL\",        \"NOTNULL\",       \"NE\",          \n  \"EQ\",            \"GT\",            \"LE\",            \"LT\",          \n  \"GE\",            \"ESCAPE\",        \"BITAND\",        \"BITOR\",       \n  \"LSHIFT\",        \"RSHIFT\",        \"PLUS\",          \"MINUS\",       \n  \"STAR\",          \"SLASH\",         \"REM\",           \"CONCAT\",      \n  \"COLLATE\",       \"BITNOT\",        \"STRING\",        \"JOIN_KW\",     \n  \"CONSTRAINT\",    \"DEFAULT\",       \"NULL\",          \"PRIMARY\",     \n  \"UNIQUE\",        \"CHECK\",         \"REFERENCES\",    \"AUTOINCR\",    \n  \"ON\",            \"INSERT\",        \"DELETE\",        \"UPDATE\",      \n  \"SET\",           \"DEFERRABLE\",    \"FOREIGN\",       \"DROP\",        \n  \"UNION\",         \"ALL\",           \"EXCEPT\",        \"INTERSECT\",   \n  \"SELECT\",        \"DISTINCT\",      \"DOT\",           \"FROM\",        \n  \"JOIN\",          \"USING\",         \"ORDER\",         \"GROUP\",       \n  \"HAVING\",        \"LIMIT\",         \"WHERE\",         \"INTO\",        \n  \"VALUES\",        \"INTEGER\",       \"FLOAT\",         \"BLOB\",        \n  \"REGISTER\",      \"VARIABLE\",      \"CASE\",          \"WHEN\",        \n  \"THEN\",          \"ELSE\",          \"INDEX\",         \"ALTER\",       \n  \"ADD\",           \"error\",         \"input\",         \"cmdlist\",     \n  \"ecmd\",          \"explain\",       \"cmdx\",          \"cmd\",         \n  \"transtype\",     \"trans_opt\",     \"nm\",            \"savepoint_opt\",\n  \"create_table\",  \"create_table_args\",  \"createkw\",      \"temp\",        \n  \"ifnotexists\",   \"dbnm\",          \"columnlist\",    \"conslist_opt\",\n  \"select\",        \"column\",        \"columnid\",      \"type\",        \n  \"carglist\",      \"id\",            \"ids\",           \"typetoken\",   \n  \"typename\",      \"signed\",        \"plus_num\",      \"minus_num\",   \n  \"ccons\",         \"term\",          \"expr\",          \"onconf\",      \n  \"sortorder\",     \"autoinc\",       \"idxlist_opt\",   \"refargs\",     \n  \"defer_subclause\",  \"refarg\",        \"refact\",        \"init_deferred_pred_opt\",\n  \"conslist\",      \"tconscomma\",    \"tcons\",         \"idxlist\",     \n  \"defer_subclause_opt\",  \"orconf\",        \"resolvetype\",   \"raisetype\",   \n  \"ifexists\",      \"fullname\",      \"oneselect\",     \"multiselect_op\",\n  \"distinct\",      \"selcollist\",    \"from\",          \"where_opt\",   \n  \"groupby_opt\",   \"having_opt\",    \"orderby_opt\",   \"limit_opt\",   \n  \"sclp\",          \"as\",            \"seltablist\",    \"stl_prefix\",  \n  \"joinop\",        \"indexed_opt\",   \"on_opt\",        \"using_opt\",   \n  \"joinop2\",       \"inscollist\",    \"sortlist\",      \"nexprlist\",   \n  \"setlist\",       \"insert_cmd\",    \"inscollist_opt\",  \"valuelist\",   \n  \"exprlist\",      \"likeop\",        \"between_op\",    \"in_op\",       \n  \"case_operand\",  \"case_exprlist\",  \"case_else\",     \"uniqueflag\",  \n  \"collate\",       \"nmnum\",         \"number\",        \"trigger_decl\",\n  \"trigger_cmd_list\",  \"trigger_time\",  \"trigger_event\",  \"foreach_clause\",\n  \"when_clause\",   \"trigger_cmd\",   \"trnm\",          \"tridxby\",     \n  \"database_kw_opt\",  \"key_opt\",       \"add_column_fullname\",  \"kwcolumn_opt\",\n  \"create_vtab\",   \"vtabarglist\",   \"vtabarg\",       \"vtabargtoken\",\n  \"lp\",            \"anylist\",     \n};\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing reduce actions, the names of all rules are required.\n*/\nstatic const char *const yyRuleName[] = {\n /*   0 */ \"input ::= cmdlist\",\n /*   1 */ \"cmdlist ::= cmdlist ecmd\",\n /*   2 */ \"cmdlist ::= ecmd\",\n /*   3 */ \"ecmd ::= SEMI\",\n /*   4 */ \"ecmd ::= explain cmdx SEMI\",\n /*   5 */ \"explain ::=\",\n /*   6 */ \"explain ::= EXPLAIN\",\n /*   7 */ \"explain ::= EXPLAIN QUERY PLAN\",\n /*   8 */ \"cmdx ::= cmd\",\n /*   9 */ \"cmd ::= BEGIN transtype trans_opt\",\n /*  10 */ \"trans_opt ::=\",\n /*  11 */ \"trans_opt ::= TRANSACTION\",\n /*  12 */ \"trans_opt ::= TRANSACTION nm\",\n /*  13 */ \"transtype ::=\",\n /*  14 */ \"transtype ::= DEFERRED\",\n /*  15 */ \"transtype ::= IMMEDIATE\",\n /*  16 */ \"transtype ::= EXCLUSIVE\",\n /*  17 */ \"cmd ::= COMMIT trans_opt\",\n /*  18 */ \"cmd ::= END trans_opt\",\n /*  19 */ \"cmd ::= ROLLBACK trans_opt\",\n /*  20 */ \"savepoint_opt ::= SAVEPOINT\",\n /*  21 */ \"savepoint_opt ::=\",\n /*  22 */ \"cmd ::= SAVEPOINT nm\",\n /*  23 */ \"cmd ::= RELEASE savepoint_opt nm\",\n /*  24 */ \"cmd ::= ROLLBACK trans_opt TO savepoint_opt nm\",\n /*  25 */ \"cmd ::= create_table create_table_args\",\n /*  26 */ \"create_table ::= createkw temp TABLE ifnotexists nm dbnm\",\n /*  27 */ \"createkw ::= CREATE\",\n /*  28 */ \"ifnotexists ::=\",\n /*  29 */ \"ifnotexists ::= IF NOT EXISTS\",\n /*  30 */ \"temp ::= TEMP\",\n /*  31 */ \"temp ::=\",\n /*  32 */ \"create_table_args ::= LP columnlist conslist_opt RP\",\n /*  33 */ \"create_table_args ::= AS select\",\n /*  34 */ \"columnlist ::= columnlist COMMA column\",\n /*  35 */ \"columnlist ::= column\",\n /*  36 */ \"column ::= columnid type carglist\",\n /*  37 */ \"columnid ::= nm\",\n /*  38 */ \"id ::= ID\",\n /*  39 */ \"id ::= INDEXED\",\n /*  40 */ \"ids ::= ID|STRING\",\n /*  41 */ \"nm ::= id\",\n /*  42 */ \"nm ::= STRING\",\n /*  43 */ \"nm ::= JOIN_KW\",\n /*  44 */ \"type ::=\",\n /*  45 */ \"type ::= typetoken\",\n /*  46 */ \"typetoken ::= typename\",\n /*  47 */ \"typetoken ::= typename LP signed RP\",\n /*  48 */ \"typetoken ::= typename LP signed COMMA signed RP\",\n /*  49 */ \"typename ::= ids\",\n /*  50 */ \"typename ::= typename ids\",\n /*  51 */ \"signed ::= plus_num\",\n /*  52 */ \"signed ::= minus_num\",\n /*  53 */ \"carglist ::= carglist ccons\",\n /*  54 */ \"carglist ::=\",\n /*  55 */ \"ccons ::= CONSTRAINT nm\",\n /*  56 */ \"ccons ::= DEFAULT term\",\n /*  57 */ \"ccons ::= DEFAULT LP expr RP\",\n /*  58 */ \"ccons ::= DEFAULT PLUS term\",\n /*  59 */ \"ccons ::= DEFAULT MINUS term\",\n /*  60 */ \"ccons ::= DEFAULT id\",\n /*  61 */ \"ccons ::= NULL onconf\",\n /*  62 */ \"ccons ::= NOT NULL onconf\",\n /*  63 */ \"ccons ::= PRIMARY KEY sortorder onconf autoinc\",\n /*  64 */ \"ccons ::= UNIQUE onconf\",\n /*  65 */ \"ccons ::= CHECK LP expr RP\",\n /*  66 */ \"ccons ::= REFERENCES nm idxlist_opt refargs\",\n /*  67 */ \"ccons ::= defer_subclause\",\n /*  68 */ \"ccons ::= COLLATE ids\",\n /*  69 */ \"autoinc ::=\",\n /*  70 */ \"autoinc ::= AUTOINCR\",\n /*  71 */ \"refargs ::=\",\n /*  72 */ \"refargs ::= refargs refarg\",\n /*  73 */ \"refarg ::= MATCH nm\",\n /*  74 */ \"refarg ::= ON INSERT refact\",\n /*  75 */ \"refarg ::= ON DELETE refact\",\n /*  76 */ \"refarg ::= ON UPDATE refact\",\n /*  77 */ \"refact ::= SET NULL\",\n /*  78 */ \"refact ::= SET DEFAULT\",\n /*  79 */ \"refact ::= CASCADE\",\n /*  80 */ \"refact ::= RESTRICT\",\n /*  81 */ \"refact ::= NO ACTION\",\n /*  82 */ \"defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt\",\n /*  83 */ \"defer_subclause ::= DEFERRABLE init_deferred_pred_opt\",\n /*  84 */ \"init_deferred_pred_opt ::=\",\n /*  85 */ \"init_deferred_pred_opt ::= INITIALLY DEFERRED\",\n /*  86 */ \"init_deferred_pred_opt ::= INITIALLY IMMEDIATE\",\n /*  87 */ \"conslist_opt ::=\",\n /*  88 */ \"conslist_opt ::= COMMA conslist\",\n /*  89 */ \"conslist ::= conslist tconscomma tcons\",\n /*  90 */ \"conslist ::= tcons\",\n /*  91 */ \"tconscomma ::= COMMA\",\n /*  92 */ \"tconscomma ::=\",\n /*  93 */ \"tcons ::= CONSTRAINT nm\",\n /*  94 */ \"tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf\",\n /*  95 */ \"tcons ::= UNIQUE LP idxlist RP onconf\",\n /*  96 */ \"tcons ::= CHECK LP expr RP onconf\",\n /*  97 */ \"tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt\",\n /*  98 */ \"defer_subclause_opt ::=\",\n /*  99 */ \"defer_subclause_opt ::= defer_subclause\",\n /* 100 */ \"onconf ::=\",\n /* 101 */ \"onconf ::= ON CONFLICT resolvetype\",\n /* 102 */ \"orconf ::=\",\n /* 103 */ \"orconf ::= OR resolvetype\",\n /* 104 */ \"resolvetype ::= raisetype\",\n /* 105 */ \"resolvetype ::= IGNORE\",\n /* 106 */ \"resolvetype ::= REPLACE\",\n /* 107 */ \"cmd ::= DROP TABLE ifexists fullname\",\n /* 108 */ \"ifexists ::= IF EXISTS\",\n /* 109 */ \"ifexists ::=\",\n /* 110 */ \"cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select\",\n /* 111 */ \"cmd ::= DROP VIEW ifexists fullname\",\n /* 112 */ \"cmd ::= select\",\n /* 113 */ \"select ::= oneselect\",\n /* 114 */ \"select ::= select multiselect_op oneselect\",\n /* 115 */ \"multiselect_op ::= UNION\",\n /* 116 */ \"multiselect_op ::= UNION ALL\",\n /* 117 */ \"multiselect_op ::= EXCEPT|INTERSECT\",\n /* 118 */ \"oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt\",\n /* 119 */ \"distinct ::= DISTINCT\",\n /* 120 */ \"distinct ::= ALL\",\n /* 121 */ \"distinct ::=\",\n /* 122 */ \"sclp ::= selcollist COMMA\",\n /* 123 */ \"sclp ::=\",\n /* 124 */ \"selcollist ::= sclp expr as\",\n /* 125 */ \"selcollist ::= sclp STAR\",\n /* 126 */ \"selcollist ::= sclp nm DOT STAR\",\n /* 127 */ \"as ::= AS nm\",\n /* 128 */ \"as ::= ids\",\n /* 129 */ \"as ::=\",\n /* 130 */ \"from ::=\",\n /* 131 */ \"from ::= FROM seltablist\",\n /* 132 */ \"stl_prefix ::= seltablist joinop\",\n /* 133 */ \"stl_prefix ::=\",\n /* 134 */ \"seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt\",\n /* 135 */ \"seltablist ::= stl_prefix LP select RP as on_opt using_opt\",\n /* 136 */ \"seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt\",\n /* 137 */ \"dbnm ::=\",\n /* 138 */ \"dbnm ::= DOT nm\",\n /* 139 */ \"fullname ::= nm dbnm\",\n /* 140 */ \"joinop ::= COMMA|JOIN\",\n /* 141 */ \"joinop ::= JOIN_KW JOIN\",\n /* 142 */ \"joinop ::= JOIN_KW nm JOIN\",\n /* 143 */ \"joinop ::= JOIN_KW nm nm JOIN\",\n /* 144 */ \"on_opt ::= ON expr\",\n /* 145 */ \"on_opt ::=\",\n /* 146 */ \"indexed_opt ::=\",\n /* 147 */ \"indexed_opt ::= INDEXED BY nm\",\n /* 148 */ \"indexed_opt ::= NOT INDEXED\",\n /* 149 */ \"using_opt ::= USING LP inscollist RP\",\n /* 150 */ \"using_opt ::=\",\n /* 151 */ \"orderby_opt ::=\",\n /* 152 */ \"orderby_opt ::= ORDER BY sortlist\",\n /* 153 */ \"sortlist ::= sortlist COMMA expr sortorder\",\n /* 154 */ \"sortlist ::= expr sortorder\",\n /* 155 */ \"sortorder ::= ASC\",\n /* 156 */ \"sortorder ::= DESC\",\n /* 157 */ \"sortorder ::=\",\n /* 158 */ \"groupby_opt ::=\",\n /* 159 */ \"groupby_opt ::= GROUP BY nexprlist\",\n /* 160 */ \"having_opt ::=\",\n /* 161 */ \"having_opt ::= HAVING expr\",\n /* 162 */ \"limit_opt ::=\",\n /* 163 */ \"limit_opt ::= LIMIT expr\",\n /* 164 */ \"limit_opt ::= LIMIT expr OFFSET expr\",\n /* 165 */ \"limit_opt ::= LIMIT expr COMMA expr\",\n /* 166 */ \"cmd ::= DELETE FROM fullname indexed_opt where_opt\",\n /* 167 */ \"where_opt ::=\",\n /* 168 */ \"where_opt ::= WHERE expr\",\n /* 169 */ \"cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt\",\n /* 170 */ \"setlist ::= setlist COMMA nm EQ expr\",\n /* 171 */ \"setlist ::= nm EQ expr\",\n /* 172 */ \"cmd ::= insert_cmd INTO fullname inscollist_opt valuelist\",\n /* 173 */ \"cmd ::= insert_cmd INTO fullname inscollist_opt select\",\n /* 174 */ \"cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES\",\n /* 175 */ \"insert_cmd ::= INSERT orconf\",\n /* 176 */ \"insert_cmd ::= REPLACE\",\n /* 177 */ \"valuelist ::= VALUES LP nexprlist RP\",\n /* 178 */ \"valuelist ::= valuelist COMMA LP exprlist RP\",\n /* 179 */ \"inscollist_opt ::=\",\n /* 180 */ \"inscollist_opt ::= LP inscollist RP\",\n /* 181 */ \"inscollist ::= inscollist COMMA nm\",\n /* 182 */ \"inscollist ::= nm\",\n /* 183 */ \"expr ::= term\",\n /* 184 */ \"expr ::= LP expr RP\",\n /* 185 */ \"term ::= NULL\",\n /* 186 */ \"expr ::= id\",\n /* 187 */ \"expr ::= JOIN_KW\",\n /* 188 */ \"expr ::= nm DOT nm\",\n /* 189 */ \"expr ::= nm DOT nm DOT nm\",\n /* 190 */ \"term ::= INTEGER|FLOAT|BLOB\",\n /* 191 */ \"term ::= STRING\",\n /* 192 */ \"expr ::= REGISTER\",\n /* 193 */ \"expr ::= VARIABLE\",\n /* 194 */ \"expr ::= expr COLLATE ids\",\n /* 195 */ \"expr ::= CAST LP expr AS typetoken RP\",\n /* 196 */ \"expr ::= ID LP distinct exprlist RP\",\n /* 197 */ \"expr ::= ID LP STAR RP\",\n /* 198 */ \"term ::= CTIME_KW\",\n /* 199 */ \"expr ::= expr AND expr\",\n /* 200 */ \"expr ::= expr OR expr\",\n /* 201 */ \"expr ::= expr LT|GT|GE|LE expr\",\n /* 202 */ \"expr ::= expr EQ|NE expr\",\n /* 203 */ \"expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr\",\n /* 204 */ \"expr ::= expr PLUS|MINUS expr\",\n /* 205 */ \"expr ::= expr STAR|SLASH|REM expr\",\n /* 206 */ \"expr ::= expr CONCAT expr\",\n /* 207 */ \"likeop ::= LIKE_KW\",\n /* 208 */ \"likeop ::= NOT LIKE_KW\",\n /* 209 */ \"likeop ::= MATCH\",\n /* 210 */ \"likeop ::= NOT MATCH\",\n /* 211 */ \"expr ::= expr likeop expr\",\n /* 212 */ \"expr ::= expr likeop expr ESCAPE expr\",\n /* 213 */ \"expr ::= expr ISNULL|NOTNULL\",\n /* 214 */ \"expr ::= expr NOT NULL\",\n /* 215 */ \"expr ::= expr IS expr\",\n /* 216 */ \"expr ::= expr IS NOT expr\",\n /* 217 */ \"expr ::= NOT expr\",\n /* 218 */ \"expr ::= BITNOT expr\",\n /* 219 */ \"expr ::= MINUS expr\",\n /* 220 */ \"expr ::= PLUS expr\",\n /* 221 */ \"between_op ::= BETWEEN\",\n /* 222 */ \"between_op ::= NOT BETWEEN\",\n /* 223 */ \"expr ::= expr between_op expr AND expr\",\n /* 224 */ \"in_op ::= IN\",\n /* 225 */ \"in_op ::= NOT IN\",\n /* 226 */ \"expr ::= expr in_op LP exprlist RP\",\n /* 227 */ \"expr ::= LP select RP\",\n /* 228 */ \"expr ::= expr in_op LP select RP\",\n /* 229 */ \"expr ::= expr in_op nm dbnm\",\n /* 230 */ \"expr ::= EXISTS LP select RP\",\n /* 231 */ \"expr ::= CASE case_operand case_exprlist case_else END\",\n /* 232 */ \"case_exprlist ::= case_exprlist WHEN expr THEN expr\",\n /* 233 */ \"case_exprlist ::= WHEN expr THEN expr\",\n /* 234 */ \"case_else ::= ELSE expr\",\n /* 235 */ \"case_else ::=\",\n /* 236 */ \"case_operand ::= expr\",\n /* 237 */ \"case_operand ::=\",\n /* 238 */ \"exprlist ::= nexprlist\",\n /* 239 */ \"exprlist ::=\",\n /* 240 */ \"nexprlist ::= nexprlist COMMA expr\",\n /* 241 */ \"nexprlist ::= expr\",\n /* 242 */ \"cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP\",\n /* 243 */ \"uniqueflag ::= UNIQUE\",\n /* 244 */ \"uniqueflag ::=\",\n /* 245 */ \"idxlist_opt ::=\",\n /* 246 */ \"idxlist_opt ::= LP idxlist RP\",\n /* 247 */ \"idxlist ::= idxlist COMMA nm collate sortorder\",\n /* 248 */ \"idxlist ::= nm collate sortorder\",\n /* 249 */ \"collate ::=\",\n /* 250 */ \"collate ::= COLLATE ids\",\n /* 251 */ \"cmd ::= DROP INDEX ifexists fullname\",\n /* 252 */ \"cmd ::= VACUUM\",\n /* 253 */ \"cmd ::= VACUUM nm\",\n /* 254 */ \"cmd ::= PRAGMA nm dbnm\",\n /* 255 */ \"cmd ::= PRAGMA nm dbnm EQ nmnum\",\n /* 256 */ \"cmd ::= PRAGMA nm dbnm LP nmnum RP\",\n /* 257 */ \"cmd ::= PRAGMA nm dbnm EQ minus_num\",\n /* 258 */ \"cmd ::= PRAGMA nm dbnm LP minus_num RP\",\n /* 259 */ \"nmnum ::= plus_num\",\n /* 260 */ \"nmnum ::= nm\",\n /* 261 */ \"nmnum ::= ON\",\n /* 262 */ \"nmnum ::= DELETE\",\n /* 263 */ \"nmnum ::= DEFAULT\",\n /* 264 */ \"plus_num ::= PLUS number\",\n /* 265 */ \"plus_num ::= number\",\n /* 266 */ \"minus_num ::= MINUS number\",\n /* 267 */ \"number ::= INTEGER|FLOAT\",\n /* 268 */ \"cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END\",\n /* 269 */ \"trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause\",\n /* 270 */ \"trigger_time ::= BEFORE\",\n /* 271 */ \"trigger_time ::= AFTER\",\n /* 272 */ \"trigger_time ::= INSTEAD OF\",\n /* 273 */ \"trigger_time ::=\",\n /* 274 */ \"trigger_event ::= DELETE|INSERT\",\n /* 275 */ \"trigger_event ::= UPDATE\",\n /* 276 */ \"trigger_event ::= UPDATE OF inscollist\",\n /* 277 */ \"foreach_clause ::=\",\n /* 278 */ \"foreach_clause ::= FOR EACH ROW\",\n /* 279 */ \"when_clause ::=\",\n /* 280 */ \"when_clause ::= WHEN expr\",\n /* 281 */ \"trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI\",\n /* 282 */ \"trigger_cmd_list ::= trigger_cmd SEMI\",\n /* 283 */ \"trnm ::= nm\",\n /* 284 */ \"trnm ::= nm DOT nm\",\n /* 285 */ \"tridxby ::=\",\n /* 286 */ \"tridxby ::= INDEXED BY nm\",\n /* 287 */ \"tridxby ::= NOT INDEXED\",\n /* 288 */ \"trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt\",\n /* 289 */ \"trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist\",\n /* 290 */ \"trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select\",\n /* 291 */ \"trigger_cmd ::= DELETE FROM trnm tridxby where_opt\",\n /* 292 */ \"trigger_cmd ::= select\",\n /* 293 */ \"expr ::= RAISE LP IGNORE RP\",\n /* 294 */ \"expr ::= RAISE LP raisetype COMMA nm RP\",\n /* 295 */ \"raisetype ::= ROLLBACK\",\n /* 296 */ \"raisetype ::= ABORT\",\n /* 297 */ \"raisetype ::= FAIL\",\n /* 298 */ \"cmd ::= DROP TRIGGER ifexists fullname\",\n /* 299 */ \"cmd ::= ATTACH database_kw_opt expr AS expr key_opt\",\n /* 300 */ \"cmd ::= DETACH database_kw_opt expr\",\n /* 301 */ \"key_opt ::=\",\n /* 302 */ \"key_opt ::= KEY expr\",\n /* 303 */ \"database_kw_opt ::= DATABASE\",\n /* 304 */ \"database_kw_opt ::=\",\n /* 305 */ \"cmd ::= REINDEX\",\n /* 306 */ \"cmd ::= REINDEX nm dbnm\",\n /* 307 */ \"cmd ::= ANALYZE\",\n /* 308 */ \"cmd ::= ANALYZE nm dbnm\",\n /* 309 */ \"cmd ::= ALTER TABLE fullname RENAME TO nm\",\n /* 310 */ \"cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column\",\n /* 311 */ \"add_column_fullname ::= fullname\",\n /* 312 */ \"kwcolumn_opt ::=\",\n /* 313 */ \"kwcolumn_opt ::= COLUMNKW\",\n /* 314 */ \"cmd ::= create_vtab\",\n /* 315 */ \"cmd ::= create_vtab LP vtabarglist RP\",\n /* 316 */ \"create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm\",\n /* 317 */ \"vtabarglist ::= vtabarg\",\n /* 318 */ \"vtabarglist ::= vtabarglist COMMA vtabarg\",\n /* 319 */ \"vtabarg ::=\",\n /* 320 */ \"vtabarg ::= vtabarg vtabargtoken\",\n /* 321 */ \"vtabargtoken ::= ANY\",\n /* 322 */ \"vtabargtoken ::= lp anylist RP\",\n /* 323 */ \"lp ::= LP\",\n /* 324 */ \"anylist ::=\",\n /* 325 */ \"anylist ::= anylist LP anylist RP\",\n /* 326 */ \"anylist ::= anylist ANY\",\n};\n#endif /* NDEBUG */\n\n\n#if YYSTACKDEPTH<=0\n/*\n** Try to increase the size of the parser stack.\n*/\nstatic void yyGrowStack(yyParser *p){\n  int newSize;\n  yyStackEntry *pNew;\n\n  newSize = p->yystksz*2 + 100;\n  pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));\n  if( pNew ){\n    p->yystack = pNew;\n    p->yystksz = newSize;\n#ifndef NDEBUG\n    if( yyTraceFILE ){\n      fprintf(yyTraceFILE,\"%sStack grows to %d entries!\\n\",\n              yyTracePrompt, p->yystksz);\n    }\n#endif\n  }\n}\n#endif\n\n/* \n** This function allocates a new parser.\n** The only argument is a pointer to a function which works like\n** malloc.\n**\n** Inputs:\n** A pointer to the function used to allocate memory.\n**\n** Outputs:\n** A pointer to a parser.  This pointer is used in subsequent calls\n** to sqlite3Parser and sqlite3ParserFree.\n*/\nSQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(size_t)){\n  yyParser *pParser;\n  pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) );\n  if( pParser ){\n    pParser->yyidx = -1;\n#ifdef YYTRACKMAXSTACKDEPTH\n    pParser->yyidxMax = 0;\n#endif\n#if YYSTACKDEPTH<=0\n    pParser->yystack = NULL;\n    pParser->yystksz = 0;\n    yyGrowStack(pParser);\n#endif\n  }\n  return pParser;\n}\n\n/* The following function deletes the value associated with a\n** symbol.  The symbol can be either a terminal or nonterminal.\n** \"yymajor\" is the symbol code, and \"yypminor\" is a pointer to\n** the value.\n*/\nstatic void yy_destructor(\n  yyParser *yypParser,    /* The parser */\n  YYCODETYPE yymajor,     /* Type code for object to destroy */\n  YYMINORTYPE *yypminor   /* The object to be destroyed */\n){\n  sqlite3ParserARG_FETCH;\n  switch( yymajor ){\n    /* Here is inserted the actions which take place when a\n    ** terminal or non-terminal is destroyed.  This can happen\n    ** when the symbol is popped from the stack during a\n    ** reduce or during error processing or when a parser is \n    ** being destroyed before it is finished parsing.\n    **\n    ** Note: during a reduce, the only symbols destroyed are those\n    ** which appear on the RHS of the rule, but which are not used\n    ** inside the C code.\n    */\n    case 160: /* select */\n    case 194: /* oneselect */\n{\nsqlite3SelectDelete(pParse->db, (yypminor->yy159));\n}\n      break;\n    case 173: /* term */\n    case 174: /* expr */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr);\n}\n      break;\n    case 178: /* idxlist_opt */\n    case 187: /* idxlist */\n    case 197: /* selcollist */\n    case 200: /* groupby_opt */\n    case 202: /* orderby_opt */\n    case 204: /* sclp */\n    case 214: /* sortlist */\n    case 215: /* nexprlist */\n    case 216: /* setlist */\n    case 220: /* exprlist */\n    case 225: /* case_exprlist */\n{\nsqlite3ExprListDelete(pParse->db, (yypminor->yy442));\n}\n      break;\n    case 193: /* fullname */\n    case 198: /* from */\n    case 206: /* seltablist */\n    case 207: /* stl_prefix */\n{\nsqlite3SrcListDelete(pParse->db, (yypminor->yy347));\n}\n      break;\n    case 199: /* where_opt */\n    case 201: /* having_opt */\n    case 210: /* on_opt */\n    case 224: /* case_operand */\n    case 226: /* case_else */\n    case 236: /* when_clause */\n    case 241: /* key_opt */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy122));\n}\n      break;\n    case 211: /* using_opt */\n    case 213: /* inscollist */\n    case 218: /* inscollist_opt */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy180));\n}\n      break;\n    case 219: /* valuelist */\n{\n\n  sqlite3ExprListDelete(pParse->db, (yypminor->yy487).pList);\n  sqlite3SelectDelete(pParse->db, (yypminor->yy487).pSelect);\n\n}\n      break;\n    case 232: /* trigger_cmd_list */\n    case 237: /* trigger_cmd */\n{\nsqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327));\n}\n      break;\n    case 234: /* trigger_event */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy410).b);\n}\n      break;\n    default:  break;   /* If no destructor action specified: do nothing */\n  }\n}\n\n/*\n** Pop the parser's stack once.\n**\n** If there is a destructor routine associated with the token which\n** is popped from the stack, then call it.\n**\n** Return the major token number for the symbol popped.\n*/\nstatic int yy_pop_parser_stack(yyParser *pParser){\n  YYCODETYPE yymajor;\n  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];\n\n  /* There is no mechanism by which the parser stack can be popped below\n  ** empty in SQLite.  */\n  if( NEVER(pParser->yyidx<0) ) return 0;\n#ifndef NDEBUG\n  if( yyTraceFILE && pParser->yyidx>=0 ){\n    fprintf(yyTraceFILE,\"%sPopping %s\\n\",\n      yyTracePrompt,\n      yyTokenName[yytos->major]);\n  }\n#endif\n  yymajor = yytos->major;\n  yy_destructor(pParser, yymajor, &yytos->minor);\n  pParser->yyidx--;\n  return yymajor;\n}\n\n/* \n** Deallocate and destroy a parser.  Destructors are all called for\n** all stack elements before shutting the parser down.\n**\n** Inputs:\n** <ul>\n** <li>  A pointer to the parser.  This should be a pointer\n**       obtained from sqlite3ParserAlloc.\n** <li>  A pointer to a function used to reclaim memory obtained\n**       from malloc.\n** </ul>\n*/\nSQLITE_PRIVATE void sqlite3ParserFree(\n  void *p,                    /* The parser to be deleted */\n  void (*freeProc)(void*)     /* Function used to reclaim memory */\n){\n  yyParser *pParser = (yyParser*)p;\n  /* In SQLite, we never try to destroy a parser that was not successfully\n  ** created in the first place. */\n  if( NEVER(pParser==0) ) return;\n  while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser);\n#if YYSTACKDEPTH<=0\n  free(pParser->yystack);\n#endif\n  (*freeProc)((void*)pParser);\n}\n\n/*\n** Return the peak depth of the stack for a parser.\n*/\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){\n  yyParser *pParser = (yyParser*)p;\n  return pParser->yyidxMax;\n}\n#endif\n\n/*\n** Find the appropriate action for a parser given the terminal\n** look-ahead token iLookAhead.\n**\n** If the look-ahead token is YYNOCODE, then check to see if the action is\n** independent of the look-ahead.  If it is, return the action, otherwise\n** return YY_NO_ACTION.\n*/\nstatic int yy_find_shift_action(\n  yyParser *pParser,        /* The parser */\n  YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n  int stateno = pParser->yystack[pParser->yyidx].stateno;\n \n  if( stateno>YY_SHIFT_COUNT\n   || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){\n    return yy_default[stateno];\n  }\n  assert( iLookAhead!=YYNOCODE );\n  i += iLookAhead;\n  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){\n    if( iLookAhead>0 ){\n#ifdef YYFALLBACK\n      YYCODETYPE iFallback;            /* Fallback token */\n      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])\n             && (iFallback = yyFallback[iLookAhead])!=0 ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE, \"%sFALLBACK %s => %s\\n\",\n             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);\n        }\n#endif\n        return yy_find_shift_action(pParser, iFallback);\n      }\n#endif\n#ifdef YYWILDCARD\n      {\n        int j = i - iLookAhead + YYWILDCARD;\n        if( \n#if YY_SHIFT_MIN+YYWILDCARD<0\n          j>=0 &&\n#endif\n#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT\n          j<YY_ACTTAB_COUNT &&\n#endif\n          yy_lookahead[j]==YYWILDCARD\n        ){\n#ifndef NDEBUG\n          if( yyTraceFILE ){\n            fprintf(yyTraceFILE, \"%sWILDCARD %s => %s\\n\",\n               yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]);\n          }\n#endif /* NDEBUG */\n          return yy_action[j];\n        }\n      }\n#endif /* YYWILDCARD */\n    }\n    return yy_default[stateno];\n  }else{\n    return yy_action[i];\n  }\n}\n\n/*\n** Find the appropriate action for a parser given the non-terminal\n** look-ahead token iLookAhead.\n**\n** If the look-ahead token is YYNOCODE, then check to see if the action is\n** independent of the look-ahead.  If it is, return the action, otherwise\n** return YY_NO_ACTION.\n*/\nstatic int yy_find_reduce_action(\n  int stateno,              /* Current state number */\n  YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n#ifdef YYERRORSYMBOL\n  if( stateno>YY_REDUCE_COUNT ){\n    return yy_default[stateno];\n  }\n#else\n  assert( stateno<=YY_REDUCE_COUNT );\n#endif\n  i = yy_reduce_ofst[stateno];\n  assert( i!=YY_REDUCE_USE_DFLT );\n  assert( iLookAhead!=YYNOCODE );\n  i += iLookAhead;\n#ifdef YYERRORSYMBOL\n  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){\n    return yy_default[stateno];\n  }\n#else\n  assert( i>=0 && i<YY_ACTTAB_COUNT );\n  assert( yy_lookahead[i]==iLookAhead );\n#endif\n  return yy_action[i];\n}\n\n/*\n** The following routine is called if the stack overflows.\n*/\nstatic void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){\n   sqlite3ParserARG_FETCH;\n   yypParser->yyidx--;\n#ifndef NDEBUG\n   if( yyTraceFILE ){\n     fprintf(yyTraceFILE,\"%sStack Overflow!\\n\",yyTracePrompt);\n   }\n#endif\n   while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);\n   /* Here code is inserted which will execute if the parser\n   ** stack every overflows */\n\n  UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */\n  sqlite3ErrorMsg(pParse, \"parser stack overflow\");\n   sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */\n}\n\n/*\n** Perform a shift action.\n*/\nstatic void yy_shift(\n  yyParser *yypParser,          /* The parser to be shifted */\n  int yyNewState,               /* The new state to shift in */\n  int yyMajor,                  /* The major token to shift in */\n  YYMINORTYPE *yypMinor         /* Pointer to the minor token to shift in */\n){\n  yyStackEntry *yytos;\n  yypParser->yyidx++;\n#ifdef YYTRACKMAXSTACKDEPTH\n  if( yypParser->yyidx>yypParser->yyidxMax ){\n    yypParser->yyidxMax = yypParser->yyidx;\n  }\n#endif\n#if YYSTACKDEPTH>0 \n  if( yypParser->yyidx>=YYSTACKDEPTH ){\n    yyStackOverflow(yypParser, yypMinor);\n    return;\n  }\n#else\n  if( yypParser->yyidx>=yypParser->yystksz ){\n    yyGrowStack(yypParser);\n    if( yypParser->yyidx>=yypParser->yystksz ){\n      yyStackOverflow(yypParser, yypMinor);\n      return;\n    }\n  }\n#endif\n  yytos = &yypParser->yystack[yypParser->yyidx];\n  yytos->stateno = (YYACTIONTYPE)yyNewState;\n  yytos->major = (YYCODETYPE)yyMajor;\n  yytos->minor = *yypMinor;\n#ifndef NDEBUG\n  if( yyTraceFILE && yypParser->yyidx>0 ){\n    int i;\n    fprintf(yyTraceFILE,\"%sShift %d\\n\",yyTracePrompt,yyNewState);\n    fprintf(yyTraceFILE,\"%sStack:\",yyTracePrompt);\n    for(i=1; i<=yypParser->yyidx; i++)\n      fprintf(yyTraceFILE,\" %s\",yyTokenName[yypParser->yystack[i].major]);\n    fprintf(yyTraceFILE,\"\\n\");\n  }\n#endif\n}\n\n/* The following table contains information about every rule that\n** is used during the reduce.\n*/\nstatic const struct {\n  YYCODETYPE lhs;         /* Symbol on the left-hand side of the rule */\n  unsigned char nrhs;     /* Number of right-hand side symbols in the rule */\n} yyRuleInfo[] = {\n  { 142, 1 },\n  { 143, 2 },\n  { 143, 1 },\n  { 144, 1 },\n  { 144, 3 },\n  { 145, 0 },\n  { 145, 1 },\n  { 145, 3 },\n  { 146, 1 },\n  { 147, 3 },\n  { 149, 0 },\n  { 149, 1 },\n  { 149, 2 },\n  { 148, 0 },\n  { 148, 1 },\n  { 148, 1 },\n  { 148, 1 },\n  { 147, 2 },\n  { 147, 2 },\n  { 147, 2 },\n  { 151, 1 },\n  { 151, 0 },\n  { 147, 2 },\n  { 147, 3 },\n  { 147, 5 },\n  { 147, 2 },\n  { 152, 6 },\n  { 154, 1 },\n  { 156, 0 },\n  { 156, 3 },\n  { 155, 1 },\n  { 155, 0 },\n  { 153, 4 },\n  { 153, 2 },\n  { 158, 3 },\n  { 158, 1 },\n  { 161, 3 },\n  { 162, 1 },\n  { 165, 1 },\n  { 165, 1 },\n  { 166, 1 },\n  { 150, 1 },\n  { 150, 1 },\n  { 150, 1 },\n  { 163, 0 },\n  { 163, 1 },\n  { 167, 1 },\n  { 167, 4 },\n  { 167, 6 },\n  { 168, 1 },\n  { 168, 2 },\n  { 169, 1 },\n  { 169, 1 },\n  { 164, 2 },\n  { 164, 0 },\n  { 172, 2 },\n  { 172, 2 },\n  { 172, 4 },\n  { 172, 3 },\n  { 172, 3 },\n  { 172, 2 },\n  { 172, 2 },\n  { 172, 3 },\n  { 172, 5 },\n  { 172, 2 },\n  { 172, 4 },\n  { 172, 4 },\n  { 172, 1 },\n  { 172, 2 },\n  { 177, 0 },\n  { 177, 1 },\n  { 179, 0 },\n  { 179, 2 },\n  { 181, 2 },\n  { 181, 3 },\n  { 181, 3 },\n  { 181, 3 },\n  { 182, 2 },\n  { 182, 2 },\n  { 182, 1 },\n  { 182, 1 },\n  { 182, 2 },\n  { 180, 3 },\n  { 180, 2 },\n  { 183, 0 },\n  { 183, 2 },\n  { 183, 2 },\n  { 159, 0 },\n  { 159, 2 },\n  { 184, 3 },\n  { 184, 1 },\n  { 185, 1 },\n  { 185, 0 },\n  { 186, 2 },\n  { 186, 7 },\n  { 186, 5 },\n  { 186, 5 },\n  { 186, 10 },\n  { 188, 0 },\n  { 188, 1 },\n  { 175, 0 },\n  { 175, 3 },\n  { 189, 0 },\n  { 189, 2 },\n  { 190, 1 },\n  { 190, 1 },\n  { 190, 1 },\n  { 147, 4 },\n  { 192, 2 },\n  { 192, 0 },\n  { 147, 8 },\n  { 147, 4 },\n  { 147, 1 },\n  { 160, 1 },\n  { 160, 3 },\n  { 195, 1 },\n  { 195, 2 },\n  { 195, 1 },\n  { 194, 9 },\n  { 196, 1 },\n  { 196, 1 },\n  { 196, 0 },\n  { 204, 2 },\n  { 204, 0 },\n  { 197, 3 },\n  { 197, 2 },\n  { 197, 4 },\n  { 205, 2 },\n  { 205, 1 },\n  { 205, 0 },\n  { 198, 0 },\n  { 198, 2 },\n  { 207, 2 },\n  { 207, 0 },\n  { 206, 7 },\n  { 206, 7 },\n  { 206, 7 },\n  { 157, 0 },\n  { 157, 2 },\n  { 193, 2 },\n  { 208, 1 },\n  { 208, 2 },\n  { 208, 3 },\n  { 208, 4 },\n  { 210, 2 },\n  { 210, 0 },\n  { 209, 0 },\n  { 209, 3 },\n  { 209, 2 },\n  { 211, 4 },\n  { 211, 0 },\n  { 202, 0 },\n  { 202, 3 },\n  { 214, 4 },\n  { 214, 2 },\n  { 176, 1 },\n  { 176, 1 },\n  { 176, 0 },\n  { 200, 0 },\n  { 200, 3 },\n  { 201, 0 },\n  { 201, 2 },\n  { 203, 0 },\n  { 203, 2 },\n  { 203, 4 },\n  { 203, 4 },\n  { 147, 5 },\n  { 199, 0 },\n  { 199, 2 },\n  { 147, 7 },\n  { 216, 5 },\n  { 216, 3 },\n  { 147, 5 },\n  { 147, 5 },\n  { 147, 6 },\n  { 217, 2 },\n  { 217, 1 },\n  { 219, 4 },\n  { 219, 5 },\n  { 218, 0 },\n  { 218, 3 },\n  { 213, 3 },\n  { 213, 1 },\n  { 174, 1 },\n  { 174, 3 },\n  { 173, 1 },\n  { 174, 1 },\n  { 174, 1 },\n  { 174, 3 },\n  { 174, 5 },\n  { 173, 1 },\n  { 173, 1 },\n  { 174, 1 },\n  { 174, 1 },\n  { 174, 3 },\n  { 174, 6 },\n  { 174, 5 },\n  { 174, 4 },\n  { 173, 1 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 3 },\n  { 221, 1 },\n  { 221, 2 },\n  { 221, 1 },\n  { 221, 2 },\n  { 174, 3 },\n  { 174, 5 },\n  { 174, 2 },\n  { 174, 3 },\n  { 174, 3 },\n  { 174, 4 },\n  { 174, 2 },\n  { 174, 2 },\n  { 174, 2 },\n  { 174, 2 },\n  { 222, 1 },\n  { 222, 2 },\n  { 174, 5 },\n  { 223, 1 },\n  { 223, 2 },\n  { 174, 5 },\n  { 174, 3 },\n  { 174, 5 },\n  { 174, 4 },\n  { 174, 4 },\n  { 174, 5 },\n  { 225, 5 },\n  { 225, 4 },\n  { 226, 2 },\n  { 226, 0 },\n  { 224, 1 },\n  { 224, 0 },\n  { 220, 1 },\n  { 220, 0 },\n  { 215, 3 },\n  { 215, 1 },\n  { 147, 11 },\n  { 227, 1 },\n  { 227, 0 },\n  { 178, 0 },\n  { 178, 3 },\n  { 187, 5 },\n  { 187, 3 },\n  { 228, 0 },\n  { 228, 2 },\n  { 147, 4 },\n  { 147, 1 },\n  { 147, 2 },\n  { 147, 3 },\n  { 147, 5 },\n  { 147, 6 },\n  { 147, 5 },\n  { 147, 6 },\n  { 229, 1 },\n  { 229, 1 },\n  { 229, 1 },\n  { 229, 1 },\n  { 229, 1 },\n  { 170, 2 },\n  { 170, 1 },\n  { 171, 2 },\n  { 230, 1 },\n  { 147, 5 },\n  { 231, 11 },\n  { 233, 1 },\n  { 233, 1 },\n  { 233, 2 },\n  { 233, 0 },\n  { 234, 1 },\n  { 234, 1 },\n  { 234, 3 },\n  { 235, 0 },\n  { 235, 3 },\n  { 236, 0 },\n  { 236, 2 },\n  { 232, 3 },\n  { 232, 2 },\n  { 238, 1 },\n  { 238, 3 },\n  { 239, 0 },\n  { 239, 3 },\n  { 239, 2 },\n  { 237, 7 },\n  { 237, 5 },\n  { 237, 5 },\n  { 237, 5 },\n  { 237, 1 },\n  { 174, 4 },\n  { 174, 6 },\n  { 191, 1 },\n  { 191, 1 },\n  { 191, 1 },\n  { 147, 4 },\n  { 147, 6 },\n  { 147, 3 },\n  { 241, 0 },\n  { 241, 2 },\n  { 240, 1 },\n  { 240, 0 },\n  { 147, 1 },\n  { 147, 3 },\n  { 147, 1 },\n  { 147, 3 },\n  { 147, 6 },\n  { 147, 6 },\n  { 242, 1 },\n  { 243, 0 },\n  { 243, 1 },\n  { 147, 1 },\n  { 147, 4 },\n  { 244, 8 },\n  { 245, 1 },\n  { 245, 3 },\n  { 246, 0 },\n  { 246, 2 },\n  { 247, 1 },\n  { 247, 3 },\n  { 248, 1 },\n  { 249, 0 },\n  { 249, 4 },\n  { 249, 2 },\n};\n\nstatic void yy_accept(yyParser*);  /* Forward Declaration */\n\n/*\n** Perform a reduce action and the shift that must immediately\n** follow the reduce.\n*/\nstatic void yy_reduce(\n  yyParser *yypParser,         /* The parser */\n  int yyruleno                 /* Number of the rule by which to reduce */\n){\n  int yygoto;                     /* The next state */\n  int yyact;                      /* The next action */\n  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */\n  yyStackEntry *yymsp;            /* The top of the parser's stack */\n  int yysize;                     /* Amount to pop the stack */\n  sqlite3ParserARG_FETCH;\n  yymsp = &yypParser->yystack[yypParser->yyidx];\n#ifndef NDEBUG\n  if( yyTraceFILE && yyruleno>=0 \n        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){\n    fprintf(yyTraceFILE, \"%sReduce [%s].\\n\", yyTracePrompt,\n      yyRuleName[yyruleno]);\n  }\n#endif /* NDEBUG */\n\n  /* Silence complaints from purify about yygotominor being uninitialized\n  ** in some cases when it is copied into the stack after the following\n  ** switch.  yygotominor is uninitialized when a rule reduces that does\n  ** not set the value of its left-hand side nonterminal.  Leaving the\n  ** value of the nonterminal uninitialized is utterly harmless as long\n  ** as the value is never used.  So really the only thing this code\n  ** accomplishes is to quieten purify.  \n  **\n  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that\n  ** without this code, their parser segfaults.  I'm not sure what there\n  ** parser is doing to make this happen.  This is the second bug report\n  ** from wireshark this week.  Clearly they are stressing Lemon in ways\n  ** that it has not been previously stressed...  (SQLite ticket #2172)\n  */\n  /*memset(&yygotominor, 0, sizeof(yygotominor));*/\n  yygotominor = yyzerominor;\n\n\n  switch( yyruleno ){\n  /* Beginning here are the reduction cases.  A typical example\n  ** follows:\n  **   case 0:\n  **  #line <lineno> <grammarfile>\n  **     { ... }           // User supplied code\n  **  #line <lineno> <thisfile>\n  **     break;\n  */\n      case 5: /* explain ::= */\n{ sqlite3BeginParse(pParse, 0); }\n        break;\n      case 6: /* explain ::= EXPLAIN */\n{ sqlite3BeginParse(pParse, 1); }\n        break;\n      case 7: /* explain ::= EXPLAIN QUERY PLAN */\n{ sqlite3BeginParse(pParse, 2); }\n        break;\n      case 8: /* cmdx ::= cmd */\n{ sqlite3FinishCoding(pParse); }\n        break;\n      case 9: /* cmd ::= BEGIN transtype trans_opt */\n{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);}\n        break;\n      case 13: /* transtype ::= */\n{yygotominor.yy392 = TK_DEFERRED;}\n        break;\n      case 14: /* transtype ::= DEFERRED */\n      case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);\n      case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);\n      case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);\n      case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);\n{yygotominor.yy392 = yymsp[0].major;}\n        break;\n      case 17: /* cmd ::= COMMIT trans_opt */\n      case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);\n{sqlite3CommitTransaction(pParse);}\n        break;\n      case 19: /* cmd ::= ROLLBACK trans_opt */\n{sqlite3RollbackTransaction(pParse);}\n        break;\n      case 22: /* cmd ::= SAVEPOINT nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);\n}\n        break;\n      case 23: /* cmd ::= RELEASE savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);\n}\n        break;\n      case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);\n}\n        break;\n      case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */\n{\n   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392);\n}\n        break;\n      case 27: /* createkw ::= CREATE */\n{\n  pParse->db->lookaside.bEnabled = 0;\n  yygotominor.yy0 = yymsp[0].minor.yy0;\n}\n        break;\n      case 28: /* ifnotexists ::= */\n      case 31: /* temp ::= */ yytestcase(yyruleno==31);\n      case 69: /* autoinc ::= */ yytestcase(yyruleno==69);\n      case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);\n      case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);\n      case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);\n      case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);\n      case 109: /* ifexists ::= */ yytestcase(yyruleno==109);\n      case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221);\n      case 224: /* in_op ::= IN */ yytestcase(yyruleno==224);\n{yygotominor.yy392 = 0;}\n        break;\n      case 29: /* ifnotexists ::= IF NOT EXISTS */\n      case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);\n      case 70: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==70);\n      case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85);\n      case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);\n      case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222);\n      case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225);\n{yygotominor.yy392 = 1;}\n        break;\n      case 32: /* create_table_args ::= LP columnlist conslist_opt RP */\n{\n  sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);\n}\n        break;\n      case 33: /* create_table_args ::= AS select */\n{\n  sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy159);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);\n}\n        break;\n      case 36: /* column ::= columnid type carglist */\n{\n  yygotominor.yy0.z = yymsp[-2].minor.yy0.z;\n  yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n;\n}\n        break;\n      case 37: /* columnid ::= nm */\n{\n  sqlite3AddColumn(pParse,&yymsp[0].minor.yy0);\n  yygotominor.yy0 = yymsp[0].minor.yy0;\n  pParse->constraintName.n = 0;\n}\n        break;\n      case 38: /* id ::= ID */\n      case 39: /* id ::= INDEXED */ yytestcase(yyruleno==39);\n      case 40: /* ids ::= ID|STRING */ yytestcase(yyruleno==40);\n      case 41: /* nm ::= id */ yytestcase(yyruleno==41);\n      case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);\n      case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);\n      case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);\n      case 49: /* typename ::= ids */ yytestcase(yyruleno==49);\n      case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);\n      case 128: /* as ::= ids */ yytestcase(yyruleno==128);\n      case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);\n      case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);\n      case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250);\n      case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259);\n      case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260);\n      case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261);\n      case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262);\n      case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263);\n      case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264);\n      case 265: /* plus_num ::= number */ yytestcase(yyruleno==265);\n      case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);\n      case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);\n      case 283: /* trnm ::= nm */ yytestcase(yyruleno==283);\n{yygotominor.yy0 = yymsp[0].minor.yy0;}\n        break;\n      case 45: /* type ::= typetoken */\n{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 47: /* typetoken ::= typename LP signed RP */\n{\n  yygotominor.yy0.z = yymsp[-3].minor.yy0.z;\n  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);\n}\n        break;\n      case 48: /* typetoken ::= typename LP signed COMMA signed RP */\n{\n  yygotominor.yy0.z = yymsp[-5].minor.yy0.z;\n  yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);\n}\n        break;\n      case 50: /* typename ::= typename ids */\n{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}\n        break;\n      case 55: /* ccons ::= CONSTRAINT nm */\n      case 93: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);\n{pParse->constraintName = yymsp[0].minor.yy0;}\n        break;\n      case 56: /* ccons ::= DEFAULT term */\n      case 58: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==58);\n{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}\n        break;\n      case 57: /* ccons ::= DEFAULT LP expr RP */\n{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);}\n        break;\n      case 59: /* ccons ::= DEFAULT MINUS term */\n{\n  ExprSpan v;\n  v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0);\n  v.zStart = yymsp[-1].minor.yy0.z;\n  v.zEnd = yymsp[0].minor.yy342.zEnd;\n  sqlite3AddDefaultValue(pParse,&v);\n}\n        break;\n      case 60: /* ccons ::= DEFAULT id */\n{\n  ExprSpan v;\n  spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0);\n  sqlite3AddDefaultValue(pParse,&v);\n}\n        break;\n      case 62: /* ccons ::= NOT NULL onconf */\n{sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);}\n        break;\n      case 63: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */\n{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);}\n        break;\n      case 64: /* ccons ::= UNIQUE onconf */\n{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);}\n        break;\n      case 65: /* ccons ::= CHECK LP expr RP */\n{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);}\n        break;\n      case 66: /* ccons ::= REFERENCES nm idxlist_opt refargs */\n{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);}\n        break;\n      case 67: /* ccons ::= defer_subclause */\n{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);}\n        break;\n      case 68: /* ccons ::= COLLATE ids */\n{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}\n        break;\n      case 71: /* refargs ::= */\n{ yygotominor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */}\n        break;\n      case 72: /* refargs ::= refargs refarg */\n{ yygotominor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; }\n        break;\n      case 73: /* refarg ::= MATCH nm */\n      case 74: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==74);\n{ yygotominor.yy207.value = 0;     yygotominor.yy207.mask = 0x000000; }\n        break;\n      case 75: /* refarg ::= ON DELETE refact */\n{ yygotominor.yy207.value = yymsp[0].minor.yy392;     yygotominor.yy207.mask = 0x0000ff; }\n        break;\n      case 76: /* refarg ::= ON UPDATE refact */\n{ yygotominor.yy207.value = yymsp[0].minor.yy392<<8;  yygotominor.yy207.mask = 0x00ff00; }\n        break;\n      case 77: /* refact ::= SET NULL */\n{ yygotominor.yy392 = OE_SetNull;  /* EV: R-33326-45252 */}\n        break;\n      case 78: /* refact ::= SET DEFAULT */\n{ yygotominor.yy392 = OE_SetDflt;  /* EV: R-33326-45252 */}\n        break;\n      case 79: /* refact ::= CASCADE */\n{ yygotominor.yy392 = OE_Cascade;  /* EV: R-33326-45252 */}\n        break;\n      case 80: /* refact ::= RESTRICT */\n{ yygotominor.yy392 = OE_Restrict; /* EV: R-33326-45252 */}\n        break;\n      case 81: /* refact ::= NO ACTION */\n{ yygotominor.yy392 = OE_None;     /* EV: R-33326-45252 */}\n        break;\n      case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */\n      case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);\n      case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);\n      case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);\n{yygotominor.yy392 = yymsp[0].minor.yy392;}\n        break;\n      case 87: /* conslist_opt ::= */\n{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}\n        break;\n      case 88: /* conslist_opt ::= COMMA conslist */\n{yygotominor.yy0 = yymsp[-1].minor.yy0;}\n        break;\n      case 91: /* tconscomma ::= COMMA */\n{pParse->constraintName.n = 0;}\n        break;\n      case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */\n{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}\n        break;\n      case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */\n{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}\n        break;\n      case 96: /* tcons ::= CHECK LP expr RP onconf */\n{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}\n        break;\n      case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */\n{\n    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);\n    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);\n}\n        break;\n      case 100: /* onconf ::= */\n{yygotominor.yy392 = OE_Default;}\n        break;\n      case 102: /* orconf ::= */\n{yygotominor.yy258 = OE_Default;}\n        break;\n      case 103: /* orconf ::= OR resolvetype */\n{yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}\n        break;\n      case 105: /* resolvetype ::= IGNORE */\n{yygotominor.yy392 = OE_Ignore;}\n        break;\n      case 106: /* resolvetype ::= REPLACE */\n{yygotominor.yy392 = OE_Replace;}\n        break;\n      case 107: /* cmd ::= DROP TABLE ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);\n}\n        break;\n      case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */\n{\n  sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);\n}\n        break;\n      case 111: /* cmd ::= DROP VIEW ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);\n}\n        break;\n      case 112: /* cmd ::= select */\n{\n  SelectDest dest = {SRT_Output, 0, 0, 0, 0};\n  sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);\n  sqlite3ExplainBegin(pParse->pVdbe);\n  sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);\n  sqlite3ExplainFinish(pParse->pVdbe);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);\n}\n        break;\n      case 113: /* select ::= oneselect */\n{yygotominor.yy159 = yymsp[0].minor.yy159;}\n        break;\n      case 114: /* select ::= select multiselect_op oneselect */\n{\n  if( yymsp[0].minor.yy159 ){\n    yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;\n    yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;\n  }else{\n    sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);\n  }\n  yygotominor.yy159 = yymsp[0].minor.yy159;\n}\n        break;\n      case 116: /* multiselect_op ::= UNION ALL */\n{yygotominor.yy392 = TK_ALL;}\n        break;\n      case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */\n{\n  yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy305,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);\n}\n        break;\n      case 119: /* distinct ::= DISTINCT */\n{yygotominor.yy305 = SF_Distinct;}\n        break;\n      case 120: /* distinct ::= ALL */\n      case 121: /* distinct ::= */ yytestcase(yyruleno==121);\n{yygotominor.yy305 = 0;}\n        break;\n      case 122: /* sclp ::= selcollist COMMA */\n      case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246);\n{yygotominor.yy442 = yymsp[-1].minor.yy442;}\n        break;\n      case 123: /* sclp ::= */\n      case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);\n      case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);\n      case 239: /* exprlist ::= */ yytestcase(yyruleno==239);\n      case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245);\n{yygotominor.yy442 = 0;}\n        break;\n      case 124: /* selcollist ::= sclp expr as */\n{\n   yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);\n   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);\n   sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);\n}\n        break;\n      case 125: /* selcollist ::= sclp STAR */\n{\n  Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);\n}\n        break;\n      case 126: /* selcollist ::= sclp nm DOT STAR */\n{\n  Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);\n  Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);\n  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);\n}\n        break;\n      case 129: /* as ::= */\n{yygotominor.yy0.n = 0;}\n        break;\n      case 130: /* from ::= */\n{yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}\n        break;\n      case 131: /* from ::= FROM seltablist */\n{\n  yygotominor.yy347 = yymsp[0].minor.yy347;\n  sqlite3SrcListShiftJoinType(yygotominor.yy347);\n}\n        break;\n      case 132: /* stl_prefix ::= seltablist joinop */\n{\n   yygotominor.yy347 = yymsp[-1].minor.yy347;\n   if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;\n}\n        break;\n      case 133: /* stl_prefix ::= */\n{yygotominor.yy347 = 0;}\n        break;\n      case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */\n{\n  yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);\n  sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);\n}\n        break;\n      case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */\n{\n    yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);\n  }\n        break;\n      case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */\n{\n    if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){\n      yygotominor.yy347 = yymsp[-4].minor.yy347;\n    }else if( yymsp[-4].minor.yy347->nSrc==1 ){\n      yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);\n      if( yygotominor.yy347 ){\n        struct SrcList_item *pNew = &yygotominor.yy347->a[yygotominor.yy347->nSrc-1];\n        struct SrcList_item *pOld = yymsp[-4].minor.yy347->a;\n        pNew->zName = pOld->zName;\n        pNew->zDatabase = pOld->zDatabase;\n        pNew->pSelect = pOld->pSelect;\n        pOld->zName = pOld->zDatabase = 0;\n        pOld->pSelect = 0;\n      }\n      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347);\n    }else{\n      Select *pSubquery;\n      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347);\n      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0);\n      yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);\n    }\n  }\n        break;\n      case 137: /* dbnm ::= */\n      case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);\n{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}\n        break;\n      case 139: /* fullname ::= nm dbnm */\n{yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}\n        break;\n      case 140: /* joinop ::= COMMA|JOIN */\n{ yygotominor.yy392 = JT_INNER; }\n        break;\n      case 141: /* joinop ::= JOIN_KW JOIN */\n{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }\n        break;\n      case 142: /* joinop ::= JOIN_KW nm JOIN */\n{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }\n        break;\n      case 143: /* joinop ::= JOIN_KW nm nm JOIN */\n{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }\n        break;\n      case 144: /* on_opt ::= ON expr */\n      case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);\n      case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);\n      case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234);\n      case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236);\n{yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}\n        break;\n      case 145: /* on_opt ::= */\n      case 160: /* having_opt ::= */ yytestcase(yyruleno==160);\n      case 167: /* where_opt ::= */ yytestcase(yyruleno==167);\n      case 235: /* case_else ::= */ yytestcase(yyruleno==235);\n      case 237: /* case_operand ::= */ yytestcase(yyruleno==237);\n{yygotominor.yy122 = 0;}\n        break;\n      case 148: /* indexed_opt ::= NOT INDEXED */\n{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}\n        break;\n      case 149: /* using_opt ::= USING LP inscollist RP */\n      case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);\n{yygotominor.yy180 = yymsp[-1].minor.yy180;}\n        break;\n      case 150: /* using_opt ::= */\n      case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);\n{yygotominor.yy180 = 0;}\n        break;\n      case 152: /* orderby_opt ::= ORDER BY sortlist */\n      case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);\n      case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238);\n{yygotominor.yy442 = yymsp[0].minor.yy442;}\n        break;\n      case 153: /* sortlist ::= sortlist COMMA expr sortorder */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);\n  if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;\n}\n        break;\n      case 154: /* sortlist ::= expr sortorder */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);\n  if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;\n}\n        break;\n      case 155: /* sortorder ::= ASC */\n      case 157: /* sortorder ::= */ yytestcase(yyruleno==157);\n{yygotominor.yy392 = SQLITE_SO_ASC;}\n        break;\n      case 156: /* sortorder ::= DESC */\n{yygotominor.yy392 = SQLITE_SO_DESC;}\n        break;\n      case 162: /* limit_opt ::= */\n{yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}\n        break;\n      case 163: /* limit_opt ::= LIMIT expr */\n{yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}\n        break;\n      case 164: /* limit_opt ::= LIMIT expr OFFSET expr */\n{yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}\n        break;\n      case 165: /* limit_opt ::= LIMIT expr COMMA expr */\n{yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}\n        break;\n      case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */\n{\n  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);\n  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);\n}\n        break;\n      case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */\n{\n  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);\n  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,\"set list\"); \n  sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);\n}\n        break;\n      case 170: /* setlist ::= setlist COMMA nm EQ expr */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);\n  sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);\n}\n        break;\n      case 171: /* setlist ::= nm EQ expr */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);\n  sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);\n}\n        break;\n      case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */\n{sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}\n        break;\n      case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */\n{sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}\n        break;\n      case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */\n{sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}\n        break;\n      case 175: /* insert_cmd ::= INSERT orconf */\n{yygotominor.yy258 = yymsp[0].minor.yy258;}\n        break;\n      case 176: /* insert_cmd ::= REPLACE */\n{yygotominor.yy258 = OE_Replace;}\n        break;\n      case 177: /* valuelist ::= VALUES LP nexprlist RP */\n{\n  yygotominor.yy487.pList = yymsp[-1].minor.yy442;\n  yygotominor.yy487.pSelect = 0;\n}\n        break;\n      case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */\n{\n  Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);\n  if( yymsp[-4].minor.yy487.pList ){\n    yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);\n    yymsp[-4].minor.yy487.pList = 0;\n  }\n  yygotominor.yy487.pList = 0;\n  if( yymsp[-4].minor.yy487.pSelect==0 || pRight==0 ){\n    sqlite3SelectDelete(pParse->db, pRight);\n    sqlite3SelectDelete(pParse->db, yymsp[-4].minor.yy487.pSelect);\n    yygotominor.yy487.pSelect = 0;\n  }else{\n    pRight->op = TK_ALL;\n    pRight->pPrior = yymsp[-4].minor.yy487.pSelect;\n    pRight->selFlags |= SF_Values;\n    pRight->pPrior->selFlags |= SF_Values;\n    yygotominor.yy487.pSelect = pRight;\n  }\n}\n        break;\n      case 181: /* inscollist ::= inscollist COMMA nm */\n{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}\n        break;\n      case 182: /* inscollist ::= nm */\n{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}\n        break;\n      case 183: /* expr ::= term */\n{yygotominor.yy342 = yymsp[0].minor.yy342;}\n        break;\n      case 184: /* expr ::= LP expr RP */\n{yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}\n        break;\n      case 185: /* term ::= NULL */\n      case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);\n      case 191: /* term ::= STRING */ yytestcase(yyruleno==191);\n{spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}\n        break;\n      case 186: /* expr ::= id */\n      case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);\n{spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}\n        break;\n      case 188: /* expr ::= nm DOT nm */\n{\n  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);\n  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);\n  spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);\n}\n        break;\n      case 189: /* expr ::= nm DOT nm DOT nm */\n{\n  Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);\n  Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);\n  Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);\n  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);\n  spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);\n}\n        break;\n      case 192: /* expr ::= REGISTER */\n{\n  /* When doing a nested parse, one can include terms in an expression\n  ** that look like this:   #1 #2 ...  These terms refer to registers\n  ** in the virtual machine.  #N is the N-th register. */\n  if( pParse->nested==0 ){\n    sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &yymsp[0].minor.yy0);\n    yygotominor.yy342.pExpr = 0;\n  }else{\n    yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0);\n    if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);\n  }\n  spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);\n}\n        break;\n      case 193: /* expr ::= VARIABLE */\n{\n  spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);\n  sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);\n  spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);\n}\n        break;\n      case 194: /* expr ::= expr COLLATE ids */\n{\n  yygotominor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);\n  yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;\n  yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n}\n        break;\n      case 195: /* expr ::= CAST LP expr AS typetoken RP */\n{\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);\n  spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);\n}\n        break;\n      case 196: /* expr ::= ID LP distinct exprlist RP */\n{\n  if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){\n    sqlite3ErrorMsg(pParse, \"too many arguments on function %T\", &yymsp[-4].minor.yy0);\n  }\n  yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);\n  spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);\n  if( yymsp[-2].minor.yy305 && yygotominor.yy342.pExpr ){\n    yygotominor.yy342.pExpr->flags |= EP_Distinct;\n  }\n}\n        break;\n      case 197: /* expr ::= ID LP STAR RP */\n{\n  yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);\n  spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);\n}\n        break;\n      case 198: /* term ::= CTIME_KW */\n{\n  /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are\n  ** treated as functions that return constants */\n  yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);\n  if( yygotominor.yy342.pExpr ){\n    yygotominor.yy342.pExpr->op = TK_CONST_FUNC;  \n  }\n  spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);\n}\n        break;\n      case 199: /* expr ::= expr AND expr */\n      case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);\n      case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);\n      case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);\n      case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);\n      case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);\n      case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);\n      case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);\n{spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}\n        break;\n      case 207: /* likeop ::= LIKE_KW */\n      case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);\n{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;}\n        break;\n      case 208: /* likeop ::= NOT LIKE_KW */\n      case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);\n{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;}\n        break;\n      case 211: /* expr ::= expr likeop expr */\n{\n  ExprList *pList;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);\n  yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);\n  if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n  yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;\n  yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;\n  if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;\n}\n        break;\n      case 212: /* expr ::= expr likeop expr ESCAPE expr */\n{\n  ExprList *pList;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);\n  yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);\n  if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n  yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;\n  yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;\n  if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;\n}\n        break;\n      case 213: /* expr ::= expr ISNULL|NOTNULL */\n{spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}\n        break;\n      case 214: /* expr ::= expr NOT NULL */\n{spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}\n        break;\n      case 215: /* expr ::= expr IS expr */\n{\n  spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);\n}\n        break;\n      case 216: /* expr ::= expr IS NOT expr */\n{\n  spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);\n}\n        break;\n      case 217: /* expr ::= NOT expr */\n      case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218);\n{spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}\n        break;\n      case 219: /* expr ::= MINUS expr */\n{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}\n        break;\n      case 220: /* expr ::= PLUS expr */\n{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}\n        break;\n      case 223: /* expr ::= expr between_op expr AND expr */\n{\n  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);\n  if( yygotominor.yy342.pExpr ){\n    yygotominor.yy342.pExpr->x.pList = pList;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  } \n  if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n  yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;\n  yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;\n}\n        break;\n      case 226: /* expr ::= expr in_op LP exprlist RP */\n{\n    if( yymsp[-1].minor.yy442==0 ){\n      /* Expressions of the form\n      **\n      **      expr1 IN ()\n      **      expr1 NOT IN ()\n      **\n      ** simplify to constants 0 (false) and 1 (true), respectively,\n      ** regardless of the value of expr1.\n      */\n      yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]);\n      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr);\n    }else{\n      yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);\n      if( yygotominor.yy342.pExpr ){\n        yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442;\n        sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);\n      }else{\n        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);\n      }\n      if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n    }\n    yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;\n    yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 227: /* expr ::= LP select RP */\n{\n    yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);\n    if( yygotominor.yy342.pExpr ){\n      yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;\n      ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);\n      sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);\n    }else{\n      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159);\n    }\n    yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;\n    yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 228: /* expr ::= expr in_op LP select RP */\n{\n    yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);\n    if( yygotominor.yy342.pExpr ){\n      yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;\n      ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);\n      sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);\n    }else{\n      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159);\n    }\n    if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n    yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;\n    yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 229: /* expr ::= expr in_op nm dbnm */\n{\n    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);\n    yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);\n    if( yygotominor.yy342.pExpr ){\n      yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);\n      ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);\n      sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);\n    }else{\n      sqlite3SrcListDelete(pParse->db, pSrc);\n    }\n    if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);\n    yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;\n    yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];\n  }\n        break;\n      case 230: /* expr ::= EXISTS LP select RP */\n{\n    Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);\n    if( p ){\n      p->x.pSelect = yymsp[-1].minor.yy159;\n      ExprSetProperty(p, EP_xIsSelect);\n      sqlite3ExprSetHeight(pParse, p);\n    }else{\n      sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159);\n    }\n    yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;\n    yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 231: /* expr ::= CASE case_operand case_exprlist case_else END */\n{\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);\n  if( yygotominor.yy342.pExpr ){\n    yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;\n    sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);\n  }else{\n    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);\n  }\n  yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;\n  yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n}\n        break;\n      case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);\n}\n        break;\n      case 233: /* case_exprlist ::= WHEN expr THEN expr */\n{\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);\n}\n        break;\n      case 240: /* nexprlist ::= nexprlist COMMA expr */\n{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}\n        break;\n      case 241: /* nexprlist ::= expr */\n{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}\n        break;\n      case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */\n{\n  sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, \n                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,\n                      &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);\n}\n        break;\n      case 243: /* uniqueflag ::= UNIQUE */\n      case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);\n{yygotominor.yy392 = OE_Abort;}\n        break;\n      case 244: /* uniqueflag ::= */\n{yygotominor.yy392 = OE_None;}\n        break;\n      case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */\n{\n  Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, p);\n  sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);\n  sqlite3ExprListCheckLength(pParse, yygotominor.yy442, \"index\");\n  if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;\n}\n        break;\n      case 248: /* idxlist ::= nm collate sortorder */\n{\n  Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);\n  yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, p);\n  sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);\n  sqlite3ExprListCheckLength(pParse, yygotominor.yy442, \"index\");\n  if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;\n}\n        break;\n      case 249: /* collate ::= */\n{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}\n        break;\n      case 251: /* cmd ::= DROP INDEX ifexists fullname */\n{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}\n        break;\n      case 252: /* cmd ::= VACUUM */\n      case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253);\n{sqlite3Vacuum(pParse);}\n        break;\n      case 254: /* cmd ::= PRAGMA nm dbnm */\n{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}\n        break;\n      case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}\n        break;\n      case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}\n        break;\n      case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}\n        break;\n      case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}\n        break;\n      case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */\n{\n  Token all;\n  all.z = yymsp[-3].minor.yy0.z;\n  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;\n  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);\n}\n        break;\n      case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */\n{\n  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);\n  yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);\n}\n        break;\n      case 270: /* trigger_time ::= BEFORE */\n      case 273: /* trigger_time ::= */ yytestcase(yyruleno==273);\n{ yygotominor.yy392 = TK_BEFORE; }\n        break;\n      case 271: /* trigger_time ::= AFTER */\n{ yygotominor.yy392 = TK_AFTER;  }\n        break;\n      case 272: /* trigger_time ::= INSTEAD OF */\n{ yygotominor.yy392 = TK_INSTEAD;}\n        break;\n      case 274: /* trigger_event ::= DELETE|INSERT */\n      case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275);\n{yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}\n        break;\n      case 276: /* trigger_event ::= UPDATE OF inscollist */\n{yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}\n        break;\n      case 279: /* when_clause ::= */\n      case 301: /* key_opt ::= */ yytestcase(yyruleno==301);\n{ yygotominor.yy122 = 0; }\n        break;\n      case 280: /* when_clause ::= WHEN expr */\n      case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302);\n{ yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }\n        break;\n      case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */\n{\n  assert( yymsp[-2].minor.yy327!=0 );\n  yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;\n  yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;\n  yygotominor.yy327 = yymsp[-2].minor.yy327;\n}\n        break;\n      case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */\n{ \n  assert( yymsp[-1].minor.yy327!=0 );\n  yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;\n  yygotominor.yy327 = yymsp[-1].minor.yy327;\n}\n        break;\n      case 284: /* trnm ::= nm DOT nm */\n{\n  yygotominor.yy0 = yymsp[0].minor.yy0;\n  sqlite3ErrorMsg(pParse, \n        \"qualified table names are not allowed on INSERT, UPDATE, and DELETE \"\n        \"statements within triggers\");\n}\n        break;\n      case 286: /* tridxby ::= INDEXED BY nm */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the INDEXED BY clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 287: /* tridxby ::= NOT INDEXED */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */\n{ yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }\n        break;\n      case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */\n{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}\n        break;\n      case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */\n{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}\n        break;\n      case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */\n{yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}\n        break;\n      case 292: /* trigger_cmd ::= select */\n{yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }\n        break;\n      case 293: /* expr ::= RAISE LP IGNORE RP */\n{\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); \n  if( yygotominor.yy342.pExpr ){\n    yygotominor.yy342.pExpr->affinity = OE_Ignore;\n  }\n  yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;\n  yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n}\n        break;\n      case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */\n{\n  yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); \n  if( yygotominor.yy342.pExpr ) {\n    yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;\n  }\n  yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;\n  yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n}\n        break;\n      case 295: /* raisetype ::= ROLLBACK */\n{yygotominor.yy392 = OE_Rollback;}\n        break;\n      case 297: /* raisetype ::= FAIL */\n{yygotominor.yy392 = OE_Fail;}\n        break;\n      case 298: /* cmd ::= DROP TRIGGER ifexists fullname */\n{\n  sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);\n}\n        break;\n      case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */\n{\n  sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);\n}\n        break;\n      case 300: /* cmd ::= DETACH database_kw_opt expr */\n{\n  sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);\n}\n        break;\n      case 305: /* cmd ::= REINDEX */\n{sqlite3Reindex(pParse, 0, 0);}\n        break;\n      case 306: /* cmd ::= REINDEX nm dbnm */\n{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 307: /* cmd ::= ANALYZE */\n{sqlite3Analyze(pParse, 0, 0);}\n        break;\n      case 308: /* cmd ::= ANALYZE nm dbnm */\n{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */\n{\n  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);\n}\n        break;\n      case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */\n{\n  sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);\n}\n        break;\n      case 311: /* add_column_fullname ::= fullname */\n{\n  pParse->db->lookaside.bEnabled = 0;\n  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);\n}\n        break;\n      case 314: /* cmd ::= create_vtab */\n{sqlite3VtabFinishParse(pParse,0);}\n        break;\n      case 315: /* cmd ::= create_vtab LP vtabarglist RP */\n{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */\n{\n    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);\n}\n        break;\n      case 319: /* vtabarg ::= */\n{sqlite3VtabArgInit(pParse);}\n        break;\n      case 321: /* vtabargtoken ::= ANY */\n      case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322);\n      case 323: /* lp ::= LP */ yytestcase(yyruleno==323);\n{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}\n        break;\n      default:\n      /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);\n      /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);\n      /* (2) cmdlist ::= ecmd */ yytestcase(yyruleno==2);\n      /* (3) ecmd ::= SEMI */ yytestcase(yyruleno==3);\n      /* (4) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==4);\n      /* (10) trans_opt ::= */ yytestcase(yyruleno==10);\n      /* (11) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==11);\n      /* (12) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==12);\n      /* (20) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==20);\n      /* (21) savepoint_opt ::= */ yytestcase(yyruleno==21);\n      /* (25) cmd ::= create_table create_table_args */ yytestcase(yyruleno==25);\n      /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);\n      /* (35) columnlist ::= column */ yytestcase(yyruleno==35);\n      /* (44) type ::= */ yytestcase(yyruleno==44);\n      /* (51) signed ::= plus_num */ yytestcase(yyruleno==51);\n      /* (52) signed ::= minus_num */ yytestcase(yyruleno==52);\n      /* (53) carglist ::= carglist ccons */ yytestcase(yyruleno==53);\n      /* (54) carglist ::= */ yytestcase(yyruleno==54);\n      /* (61) ccons ::= NULL onconf */ yytestcase(yyruleno==61);\n      /* (89) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==89);\n      /* (90) conslist ::= tcons */ yytestcase(yyruleno==90);\n      /* (92) tconscomma ::= */ yytestcase(yyruleno==92);\n      /* (277) foreach_clause ::= */ yytestcase(yyruleno==277);\n      /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278);\n      /* (285) tridxby ::= */ yytestcase(yyruleno==285);\n      /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);\n      /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304);\n      /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312);\n      /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313);\n      /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317);\n      /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318);\n      /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320);\n      /* (324) anylist ::= */ yytestcase(yyruleno==324);\n      /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);\n      /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);\n        break;\n  };\n  assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );\n  yygoto = yyRuleInfo[yyruleno].lhs;\n  yysize = yyRuleInfo[yyruleno].nrhs;\n  yypParser->yyidx -= yysize;\n  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);\n  if( yyact < YYNSTATE ){\n#ifdef NDEBUG\n    /* If we are not debugging and the reduce action popped at least\n    ** one element off the stack, then we can push the new element back\n    ** onto the stack here, and skip the stack overflow test in yy_shift().\n    ** That gives a significant speed improvement. */\n    if( yysize ){\n      yypParser->yyidx++;\n      yymsp -= yysize-1;\n      yymsp->stateno = (YYACTIONTYPE)yyact;\n      yymsp->major = (YYCODETYPE)yygoto;\n      yymsp->minor = yygotominor;\n    }else\n#endif\n    {\n      yy_shift(yypParser,yyact,yygoto,&yygotominor);\n    }\n  }else{\n    assert( yyact == YYNSTATE + YYNRULE + 1 );\n    yy_accept(yypParser);\n  }\n}\n\n/*\n** The following code executes when the parse fails\n*/\n#ifndef YYNOERRORRECOVERY\nstatic void yy_parse_failed(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sFail!\\n\",yyTracePrompt);\n  }\n#endif\n  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser fails */\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n#endif /* YYNOERRORRECOVERY */\n\n/*\n** The following code executes when a syntax error first occurs.\n*/\nstatic void yy_syntax_error(\n  yyParser *yypParser,           /* The parser */\n  int yymajor,                   /* The major type of the error token */\n  YYMINORTYPE yyminor            /* The minor type of the error token */\n){\n  sqlite3ParserARG_FETCH;\n#define TOKEN (yyminor.yy0)\n\n  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */\n  assert( TOKEN.z[0] );  /* The tokenizer always gives us a token */\n  sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &TOKEN);\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/*\n** The following is executed when the parser accepts\n*/\nstatic void yy_accept(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sAccept!\\n\",yyTracePrompt);\n  }\n#endif\n  while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser accepts */\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/* The main parser program.\n** The first argument is a pointer to a structure obtained from\n** \"sqlite3ParserAlloc\" which describes the current state of the parser.\n** The second argument is the major token number.  The third is\n** the minor token.  The fourth optional argument is whatever the\n** user wants (and specified in the grammar) and is available for\n** use by the action routines.\n**\n** Inputs:\n** <ul>\n** <li> A pointer to the parser (an opaque structure.)\n** <li> The major token number.\n** <li> The minor token number.\n** <li> An option argument of a grammar-specified type.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3Parser(\n  void *yyp,                   /* The parser */\n  int yymajor,                 /* The major token code number */\n  sqlite3ParserTOKENTYPE yyminor       /* The value for the token */\n  sqlite3ParserARG_PDECL               /* Optional %extra_argument parameter */\n){\n  YYMINORTYPE yyminorunion;\n  int yyact;            /* The parser action. */\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  int yyendofinput;     /* True if we are at the end of input */\n#endif\n#ifdef YYERRORSYMBOL\n  int yyerrorhit = 0;   /* True if yymajor has invoked an error */\n#endif\n  yyParser *yypParser;  /* The parser */\n\n  /* (re)initialize the parser, if necessary */\n  yypParser = (yyParser*)yyp;\n  if( yypParser->yyidx<0 ){\n#if YYSTACKDEPTH<=0\n    if( yypParser->yystksz <=0 ){\n      /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/\n      yyminorunion = yyzerominor;\n      yyStackOverflow(yypParser, &yyminorunion);\n      return;\n    }\n#endif\n    yypParser->yyidx = 0;\n    yypParser->yyerrcnt = -1;\n    yypParser->yystack[0].stateno = 0;\n    yypParser->yystack[0].major = 0;\n  }\n  yyminorunion.yy0 = yyminor;\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  yyendofinput = (yymajor==0);\n#endif\n  sqlite3ParserARG_STORE;\n\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sInput %s\\n\",yyTracePrompt,yyTokenName[yymajor]);\n  }\n#endif\n\n  do{\n    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);\n    if( yyact<YYNSTATE ){\n      yy_shift(yypParser,yyact,yymajor,&yyminorunion);\n      yypParser->yyerrcnt--;\n      yymajor = YYNOCODE;\n    }else if( yyact < YYNSTATE + YYNRULE ){\n      yy_reduce(yypParser,yyact-YYNSTATE);\n    }else{\n      assert( yyact == YY_ERROR_ACTION );\n#ifdef YYERRORSYMBOL\n      int yymx;\n#endif\n#ifndef NDEBUG\n      if( yyTraceFILE ){\n        fprintf(yyTraceFILE,\"%sSyntax Error!\\n\",yyTracePrompt);\n      }\n#endif\n#ifdef YYERRORSYMBOL\n      /* A syntax error has occurred.\n      ** The response to an error depends upon whether or not the\n      ** grammar defines an error token \"ERROR\".  \n      **\n      ** This is what we do if the grammar does define ERROR:\n      **\n      **  * Call the %syntax_error function.\n      **\n      **  * Begin popping the stack until we enter a state where\n      **    it is legal to shift the error symbol, then shift\n      **    the error symbol.\n      **\n      **  * Set the error count to three.\n      **\n      **  * Begin accepting and shifting new tokens.  No new error\n      **    processing will occur until three tokens have been\n      **    shifted successfully.\n      **\n      */\n      if( yypParser->yyerrcnt<0 ){\n        yy_syntax_error(yypParser,yymajor,yyminorunion);\n      }\n      yymx = yypParser->yystack[yypParser->yyidx].major;\n      if( yymx==YYERRORSYMBOL || yyerrorhit ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE,\"%sDiscard input token %s\\n\",\n             yyTracePrompt,yyTokenName[yymajor]);\n        }\n#endif\n        yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion);\n        yymajor = YYNOCODE;\n      }else{\n         while(\n          yypParser->yyidx >= 0 &&\n          yymx != YYERRORSYMBOL &&\n          (yyact = yy_find_reduce_action(\n                        yypParser->yystack[yypParser->yyidx].stateno,\n                        YYERRORSYMBOL)) >= YYNSTATE\n        ){\n          yy_pop_parser_stack(yypParser);\n        }\n        if( yypParser->yyidx < 0 || yymajor==0 ){\n          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n          yy_parse_failed(yypParser);\n          yymajor = YYNOCODE;\n        }else if( yymx!=YYERRORSYMBOL ){\n          YYMINORTYPE u2;\n          u2.YYERRSYMDT = 0;\n          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);\n        }\n      }\n      yypParser->yyerrcnt = 3;\n      yyerrorhit = 1;\n#elif defined(YYNOERRORRECOVERY)\n      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to\n      ** do any kind of error recovery.  Instead, simply invoke the syntax\n      ** error routine and continue going as if nothing had happened.\n      **\n      ** Applications can set this macro (for example inside %include) if\n      ** they intend to abandon the parse upon the first syntax error seen.\n      */\n      yy_syntax_error(yypParser,yymajor,yyminorunion);\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      yymajor = YYNOCODE;\n      \n#else  /* YYERRORSYMBOL is not defined */\n      /* This is what we do if the grammar does not define ERROR:\n      **\n      **  * Report an error message, and throw away the input token.\n      **\n      **  * If the input token is $, then fail the parse.\n      **\n      ** As before, subsequent error messages are suppressed until\n      ** three input tokens have been successfully shifted.\n      */\n      if( yypParser->yyerrcnt<=0 ){\n        yy_syntax_error(yypParser,yymajor,yyminorunion);\n      }\n      yypParser->yyerrcnt = 3;\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      if( yyendofinput ){\n        yy_parse_failed(yypParser);\n      }\n      yymajor = YYNOCODE;\n#endif\n    }\n  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );\n  return;\n}\n\n/************** End of parse.c ***********************************************/\n/************** Begin file tokenize.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that splits an SQL input string up into\n** individual tokens and sends those tokens one-by-one over to the\n** parser for analysis.\n*/\n/* #include <stdlib.h> */\n\n/*\n** The charMap() macro maps alphabetic characters into their\n** lower-case ASCII equivalent.  On ASCII machines, this is just\n** an upper-to-lower case map.  On EBCDIC machines we also need\n** to adjust the encoding.  Only alphabetic characters and underscores\n** need to be translated.\n*/\n#ifdef SQLITE_ASCII\n# define charMap(X) sqlite3UpperToLower[(unsigned char)X]\n#endif\n#ifdef SQLITE_EBCDIC\n# define charMap(X) ebcdicToAscii[(unsigned char)X]\nconst unsigned char ebcdicToAscii[] = {\n/* 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 0x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 1x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 2x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 3x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 4x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 5x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 95,  0,  0,  /* 6x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 7x */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* 8x */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* 9x */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ax */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Bx */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* Cx */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* Dx */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ex */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Fx */\n};\n#endif\n\n/*\n** The sqlite3KeywordCode function looks up an identifier to determine if\n** it is a keyword.  If it is a keyword, the token code of that keyword is \n** returned.  If the input is not a keyword, TK_ID is returned.\n**\n** The implementation of this routine was generated by a program,\n** mkkeywordhash.h, located in the tool subdirectory of the distribution.\n** The output of the mkkeywordhash.c program is written into a file\n** named keywordhash.h and then included into this source file by\n** the #include below.\n*/\n/************** Include keywordhash.h in the middle of tokenize.c ************/\n/************** Begin file keywordhash.h *************************************/\n/***** This file contains automatically generated code ******\n**\n** The code in this file has been automatically generated by\n**\n**   sqlite/tool/mkkeywordhash.c\n**\n** The code in this file implements a function that determines whether\n** or not a given identifier is really an SQL keyword.  The same thing\n** might be implemented more directly using a hand-written hash table.\n** But by using this automatically generated code, the size of the code\n** is substantially reduced.  This is important for embedded applications\n** on platforms with limited memory.\n*/\n/* Hash score: 175 */\nstatic int keywordCode(const char *z, int n){\n  /* zText[] encodes 811 bytes of keywords in 541 bytes */\n  /*   REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT       */\n  /*   ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE         */\n  /*   XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY         */\n  /*   UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE          */\n  /*   CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN        */\n  /*   SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME         */\n  /*   AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS     */\n  /*   CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF      */\n  /*   ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW         */\n  /*   INITIALLY                                                          */\n  static const char zText[540] = {\n    'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',\n    'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',\n    'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',\n    'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',\n    'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',\n    'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',\n    'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',\n    'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',\n    'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',\n    'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',\n    'U','E','R','Y','A','T','T','A','C','H','A','V','I','N','G','R','O','U',\n    'P','D','A','T','E','B','E','G','I','N','N','E','R','E','L','E','A','S',\n    'E','B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C',\n    'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',\n    'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',\n    'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',\n    'J','O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A',\n    'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',\n    'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W',\n    'H','E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C',\n    'E','A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R',\n    'E','M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M',\n    'M','I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U',\n    'R','R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M',\n    'A','R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T',\n    'D','R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L',\n    'O','B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S',\n    'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',\n    'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',\n    'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',\n  };\n  static const unsigned char aHash[127] = {\n      72, 101, 114,  70,   0,  45,   0,   0,  78,   0,  73,   0,   0,\n      42,  12,  74,  15,   0, 113,  81,  50, 108,   0,  19,   0,   0,\n     118,   0, 116, 111,   0,  22,  89,   0,   9,   0,   0,  66,  67,\n       0,  65,   6,   0,  48,  86,  98,   0, 115,  97,   0,   0,  44,\n       0,  99,  24,   0,  17,   0, 119,  49,  23,   0,   5, 106,  25,\n      92,   0,   0, 121, 102,  56, 120,  53,  28,  51,   0,  87,   0,\n      96,  26,   0,  95,   0,   0,   0,  91,  88,  93,  84, 105,  14,\n      39, 104,   0,  77,   0,  18,  85, 107,  32,   0, 117,  76, 109,\n      58,  46,  80,   0,   0,  90,  40,   0, 112,   0,  36,   0,   0,\n      29,   0,  82,  59,  60,   0,  20,  57,   0,  52,\n  };\n  static const unsigned char aNext[121] = {\n       0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,\n       0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,\n       0,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n       0,   0,   0,   0,  33,   0,  21,   0,   0,   0,  43,   3,  47,\n       0,   0,   0,   0,  30,   0,  54,   0,  38,   0,   0,   0,   1,\n      62,   0,   0,  63,   0,  41,   0,   0,   0,   0,   0,   0,   0,\n      61,   0,   0,   0,   0,  31,  55,  16,  34,  10,   0,   0,   0,\n       0,   0,   0,   0,  11,  68,  75,   0,   8,   0, 100,  94,   0,\n     103,   0,  83,   0,  71,   0,   0, 110,  27,  37,  69,  79,   0,\n      35,  64,   0,   0,\n  };\n  static const unsigned char aLen[121] = {\n       7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,\n       7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,\n      11,   6,   2,   7,   5,   5,   9,   6,   9,   9,   7,  10,  10,\n       4,   6,   2,   3,   9,   4,   2,   6,   5,   6,   6,   5,   6,\n       5,   5,   7,   7,   7,   3,   2,   4,   4,   7,   3,   6,   4,\n       7,   6,  12,   6,   9,   4,   6,   5,   4,   7,   6,   5,   6,\n       7,   5,   4,   5,   6,   5,   7,   3,   7,  13,   2,   2,   4,\n       6,   6,   8,   5,  17,  12,   7,   8,   8,   2,   4,   4,   4,\n       4,   4,   2,   2,   6,   5,   8,   5,   5,   8,   3,   5,   5,\n       6,   4,   9,   3,\n  };\n  static const unsigned short int aOffset[121] = {\n       0,   2,   2,   8,   9,  14,  16,  20,  23,  25,  25,  29,  33,\n      36,  41,  46,  48,  53,  54,  59,  62,  65,  67,  69,  78,  81,\n      86,  91,  95,  96, 101, 105, 109, 117, 122, 128, 136, 142, 152,\n     159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197,\n     203, 206, 210, 217, 223, 223, 223, 226, 229, 233, 234, 238, 244,\n     248, 255, 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320,\n     326, 332, 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383,\n     387, 393, 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458,\n     462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516,\n     521, 527, 531, 536,\n  };\n  static const unsigned char aCode[121] = {\n    TK_REINDEX,    TK_INDEXED,    TK_INDEX,      TK_DESC,       TK_ESCAPE,     \n    TK_EACH,       TK_CHECK,      TK_KEY,        TK_BEFORE,     TK_FOREIGN,    \n    TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    TK_EXPLAIN,    TK_INSTEAD,    \n    TK_ADD,        TK_DATABASE,   TK_AS,         TK_SELECT,     TK_TABLE,      \n    TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DEFERRABLE, TK_ELSE,       \n    TK_EXCEPT,     TK_TRANSACTION,TK_ACTION,     TK_ON,         TK_JOIN_KW,    \n    TK_ALTER,      TK_RAISE,      TK_EXCLUSIVE,  TK_EXISTS,     TK_SAVEPOINT,  \n    TK_INTERSECT,  TK_TRIGGER,    TK_REFERENCES, TK_CONSTRAINT, TK_INTO,       \n    TK_OFFSET,     TK_OF,         TK_SET,        TK_TEMP,       TK_TEMP,       \n    TK_OR,         TK_UNIQUE,     TK_QUERY,      TK_ATTACH,     TK_HAVING,     \n    TK_GROUP,      TK_UPDATE,     TK_BEGIN,      TK_JOIN_KW,    TK_RELEASE,    \n    TK_BETWEEN,    TK_NOTNULL,    TK_NOT,        TK_NO,         TK_NULL,       \n    TK_LIKE_KW,    TK_CASCADE,    TK_ASC,        TK_DELETE,     TK_CASE,       \n    TK_COLLATE,    TK_CREATE,     TK_CTIME_KW,   TK_DETACH,     TK_IMMEDIATE,  \n    TK_JOIN,       TK_INSERT,     TK_MATCH,      TK_PLAN,       TK_ANALYZE,    \n    TK_PRAGMA,     TK_ABORT,      TK_VALUES,     TK_VIRTUAL,    TK_LIMIT,      \n    TK_WHEN,       TK_WHERE,      TK_RENAME,     TK_AFTER,      TK_REPLACE,    \n    TK_AND,        TK_DEFAULT,    TK_AUTOINCR,   TK_TO,         TK_IN,         \n    TK_CAST,       TK_COLUMNKW,   TK_COMMIT,     TK_CONFLICT,   TK_JOIN_KW,    \n    TK_CTIME_KW,   TK_CTIME_KW,   TK_PRIMARY,    TK_DEFERRED,   TK_DISTINCT,   \n    TK_IS,         TK_DROP,       TK_FAIL,       TK_FROM,       TK_JOIN_KW,    \n    TK_LIKE_KW,    TK_BY,         TK_IF,         TK_ISNULL,     TK_ORDER,      \n    TK_RESTRICT,   TK_JOIN_KW,    TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        \n    TK_UNION,      TK_USING,      TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  \n    TK_ALL,        \n  };\n  int h, i;\n  if( n<2 ) return TK_ID;\n  h = ((charMap(z[0])*4) ^\n      (charMap(z[n-1])*3) ^\n      n) % 127;\n  for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){\n    if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){\n      testcase( i==0 ); /* REINDEX */\n      testcase( i==1 ); /* INDEXED */\n      testcase( i==2 ); /* INDEX */\n      testcase( i==3 ); /* DESC */\n      testcase( i==4 ); /* ESCAPE */\n      testcase( i==5 ); /* EACH */\n      testcase( i==6 ); /* CHECK */\n      testcase( i==7 ); /* KEY */\n      testcase( i==8 ); /* BEFORE */\n      testcase( i==9 ); /* FOREIGN */\n      testcase( i==10 ); /* FOR */\n      testcase( i==11 ); /* IGNORE */\n      testcase( i==12 ); /* REGEXP */\n      testcase( i==13 ); /* EXPLAIN */\n      testcase( i==14 ); /* INSTEAD */\n      testcase( i==15 ); /* ADD */\n      testcase( i==16 ); /* DATABASE */\n      testcase( i==17 ); /* AS */\n      testcase( i==18 ); /* SELECT */\n      testcase( i==19 ); /* TABLE */\n      testcase( i==20 ); /* LEFT */\n      testcase( i==21 ); /* THEN */\n      testcase( i==22 ); /* END */\n      testcase( i==23 ); /* DEFERRABLE */\n      testcase( i==24 ); /* ELSE */\n      testcase( i==25 ); /* EXCEPT */\n      testcase( i==26 ); /* TRANSACTION */\n      testcase( i==27 ); /* ACTION */\n      testcase( i==28 ); /* ON */\n      testcase( i==29 ); /* NATURAL */\n      testcase( i==30 ); /* ALTER */\n      testcase( i==31 ); /* RAISE */\n      testcase( i==32 ); /* EXCLUSIVE */\n      testcase( i==33 ); /* EXISTS */\n      testcase( i==34 ); /* SAVEPOINT */\n      testcase( i==35 ); /* INTERSECT */\n      testcase( i==36 ); /* TRIGGER */\n      testcase( i==37 ); /* REFERENCES */\n      testcase( i==38 ); /* CONSTRAINT */\n      testcase( i==39 ); /* INTO */\n      testcase( i==40 ); /* OFFSET */\n      testcase( i==41 ); /* OF */\n      testcase( i==42 ); /* SET */\n      testcase( i==43 ); /* TEMPORARY */\n      testcase( i==44 ); /* TEMP */\n      testcase( i==45 ); /* OR */\n      testcase( i==46 ); /* UNIQUE */\n      testcase( i==47 ); /* QUERY */\n      testcase( i==48 ); /* ATTACH */\n      testcase( i==49 ); /* HAVING */\n      testcase( i==50 ); /* GROUP */\n      testcase( i==51 ); /* UPDATE */\n      testcase( i==52 ); /* BEGIN */\n      testcase( i==53 ); /* INNER */\n      testcase( i==54 ); /* RELEASE */\n      testcase( i==55 ); /* BETWEEN */\n      testcase( i==56 ); /* NOTNULL */\n      testcase( i==57 ); /* NOT */\n      testcase( i==58 ); /* NO */\n      testcase( i==59 ); /* NULL */\n      testcase( i==60 ); /* LIKE */\n      testcase( i==61 ); /* CASCADE */\n      testcase( i==62 ); /* ASC */\n      testcase( i==63 ); /* DELETE */\n      testcase( i==64 ); /* CASE */\n      testcase( i==65 ); /* COLLATE */\n      testcase( i==66 ); /* CREATE */\n      testcase( i==67 ); /* CURRENT_DATE */\n      testcase( i==68 ); /* DETACH */\n      testcase( i==69 ); /* IMMEDIATE */\n      testcase( i==70 ); /* JOIN */\n      testcase( i==71 ); /* INSERT */\n      testcase( i==72 ); /* MATCH */\n      testcase( i==73 ); /* PLAN */\n      testcase( i==74 ); /* ANALYZE */\n      testcase( i==75 ); /* PRAGMA */\n      testcase( i==76 ); /* ABORT */\n      testcase( i==77 ); /* VALUES */\n      testcase( i==78 ); /* VIRTUAL */\n      testcase( i==79 ); /* LIMIT */\n      testcase( i==80 ); /* WHEN */\n      testcase( i==81 ); /* WHERE */\n      testcase( i==82 ); /* RENAME */\n      testcase( i==83 ); /* AFTER */\n      testcase( i==84 ); /* REPLACE */\n      testcase( i==85 ); /* AND */\n      testcase( i==86 ); /* DEFAULT */\n      testcase( i==87 ); /* AUTOINCREMENT */\n      testcase( i==88 ); /* TO */\n      testcase( i==89 ); /* IN */\n      testcase( i==90 ); /* CAST */\n      testcase( i==91 ); /* COLUMN */\n      testcase( i==92 ); /* COMMIT */\n      testcase( i==93 ); /* CONFLICT */\n      testcase( i==94 ); /* CROSS */\n      testcase( i==95 ); /* CURRENT_TIMESTAMP */\n      testcase( i==96 ); /* CURRENT_TIME */\n      testcase( i==97 ); /* PRIMARY */\n      testcase( i==98 ); /* DEFERRED */\n      testcase( i==99 ); /* DISTINCT */\n      testcase( i==100 ); /* IS */\n      testcase( i==101 ); /* DROP */\n      testcase( i==102 ); /* FAIL */\n      testcase( i==103 ); /* FROM */\n      testcase( i==104 ); /* FULL */\n      testcase( i==105 ); /* GLOB */\n      testcase( i==106 ); /* BY */\n      testcase( i==107 ); /* IF */\n      testcase( i==108 ); /* ISNULL */\n      testcase( i==109 ); /* ORDER */\n      testcase( i==110 ); /* RESTRICT */\n      testcase( i==111 ); /* OUTER */\n      testcase( i==112 ); /* RIGHT */\n      testcase( i==113 ); /* ROLLBACK */\n      testcase( i==114 ); /* ROW */\n      testcase( i==115 ); /* UNION */\n      testcase( i==116 ); /* USING */\n      testcase( i==117 ); /* VACUUM */\n      testcase( i==118 ); /* VIEW */\n      testcase( i==119 ); /* INITIALLY */\n      testcase( i==120 ); /* ALL */\n      return aCode[i];\n    }\n  }\n  return TK_ID;\n}\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){\n  return keywordCode((char*)z, n);\n}\n#define SQLITE_N_KEYWORD 121\n\n/************** End of keywordhash.h *****************************************/\n/************** Continuing where we left off in tokenize.c *******************/\n\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** For EBCDIC, the rules are more complex but have the same\n** end result.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identfiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 4x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  /* 5x */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0,  /* 6x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,  /* 7x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,  /* 8x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,  /* 9x */\n    1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,  /* Ax */\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* Bx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Cx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Dx */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Ex */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0,  /* Fx */\n};\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n\n\n/*\n** Return the length of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){\n  int i, c;\n  switch( *z ){\n    case ' ': case '\\t': case '\\n': case '\\f': case '\\r': {\n      testcase( z[0]==' ' );\n      testcase( z[0]=='\\t' );\n      testcase( z[0]=='\\n' );\n      testcase( z[0]=='\\f' );\n      testcase( z[0]=='\\r' );\n      for(i=1; sqlite3Isspace(z[i]); i++){}\n      *tokenType = TK_SPACE;\n      return i;\n    }\n    case '-': {\n      if( z[1]=='-' ){\n        /* IMP: R-50417-27976 -- syntax diagram for comments */\n        for(i=2; (c=z[i])!=0 && c!='\\n'; i++){}\n        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n        return i;\n      }\n      *tokenType = TK_MINUS;\n      return 1;\n    }\n    case '(': {\n      *tokenType = TK_LP;\n      return 1;\n    }\n    case ')': {\n      *tokenType = TK_RP;\n      return 1;\n    }\n    case ';': {\n      *tokenType = TK_SEMI;\n      return 1;\n    }\n    case '+': {\n      *tokenType = TK_PLUS;\n      return 1;\n    }\n    case '*': {\n      *tokenType = TK_STAR;\n      return 1;\n    }\n    case '/': {\n      if( z[1]!='*' || z[2]==0 ){\n        *tokenType = TK_SLASH;\n        return 1;\n      }\n      /* IMP: R-50417-27976 -- syntax diagram for comments */\n      for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}\n      if( c ) i++;\n      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n      return i;\n    }\n    case '%': {\n      *tokenType = TK_REM;\n      return 1;\n    }\n    case '=': {\n      *tokenType = TK_EQ;\n      return 1 + (z[1]=='=');\n    }\n    case '<': {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_LE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_NE;\n        return 2;\n      }else if( c=='<' ){\n        *tokenType = TK_LSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_LT;\n        return 1;\n      }\n    }\n    case '>': {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_GE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_RSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_GT;\n        return 1;\n      }\n    }\n    case '!': {\n      if( z[1]!='=' ){\n        *tokenType = TK_ILLEGAL;\n        return 2;\n      }else{\n        *tokenType = TK_NE;\n        return 2;\n      }\n    }\n    case '|': {\n      if( z[1]!='|' ){\n        *tokenType = TK_BITOR;\n        return 1;\n      }else{\n        *tokenType = TK_CONCAT;\n        return 2;\n      }\n    }\n    case ',': {\n      *tokenType = TK_COMMA;\n      return 1;\n    }\n    case '&': {\n      *tokenType = TK_BITAND;\n      return 1;\n    }\n    case '~': {\n      *tokenType = TK_BITNOT;\n      return 1;\n    }\n    case '`':\n    case '\\'':\n    case '\"': {\n      int delim = z[0];\n      testcase( delim=='`' );\n      testcase( delim=='\\'' );\n      testcase( delim=='\"' );\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      if( c=='\\'' ){\n        *tokenType = TK_STRING;\n        return i+1;\n      }else if( c!=0 ){\n        *tokenType = TK_ID;\n        return i+1;\n      }else{\n        *tokenType = TK_ILLEGAL;\n        return i;\n      }\n    }\n    case '.': {\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( !sqlite3Isdigit(z[1]) )\n#endif\n      {\n        *tokenType = TK_DOT;\n        return 1;\n      }\n      /* If the next character is a digit, this is a floating point\n      ** number that begins with \".\".  Fall thru into the next case */\n    }\n    case '0': case '1': case '2': case '3': case '4':\n    case '5': case '6': case '7': case '8': case '9': {\n      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );\n      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );\n      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );\n      testcase( z[0]=='9' );\n      *tokenType = TK_INTEGER;\n      for(i=0; sqlite3Isdigit(z[i]); i++){}\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( z[i]=='.' ){\n        i++;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n      if( (z[i]=='e' || z[i]=='E') &&\n           ( sqlite3Isdigit(z[i+1]) \n            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))\n           )\n      ){\n        i += 2;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n#endif\n      while( IdChar(z[i]) ){\n        *tokenType = TK_ILLEGAL;\n        i++;\n      }\n      return i;\n    }\n    case '[': {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = c==']' ? TK_ID : TK_ILLEGAL;\n      return i;\n    }\n    case '?': {\n      *tokenType = TK_VARIABLE;\n      for(i=1; sqlite3Isdigit(z[i]); i++){}\n      return i;\n    }\n    case '#': {\n      for(i=1; sqlite3Isdigit(z[i]); i++){}\n      if( i>1 ){\n        /* Parameters of the form #NNN (where NNN is a number) are used\n        ** internally by sqlite3NestedParse.  */\n        *tokenType = TK_REGISTER;\n        return i;\n      }\n      /* Fall through into the next case if the '#' is not followed by\n      ** a digit. Try to match #AAAA where AAAA is a parameter name. */\n    }\n#ifndef SQLITE_OMIT_TCL_VARIABLE\n    case '$':\n#endif\n    case '@':  /* For compatibility with MS SQL Server */\n    case ':': {\n      int n = 0;\n      testcase( z[0]=='$' );  testcase( z[0]=='@' );  testcase( z[0]==':' );\n      *tokenType = TK_VARIABLE;\n      for(i=1; (c=z[i])!=0; i++){\n        if( IdChar(c) ){\n          n++;\n#ifndef SQLITE_OMIT_TCL_VARIABLE\n        }else if( c=='(' && n>0 ){\n          do{\n            i++;\n          }while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );\n          if( c==')' ){\n            i++;\n          }else{\n            *tokenType = TK_ILLEGAL;\n          }\n          break;\n        }else if( c==':' && z[i+1]==':' ){\n          i++;\n#endif\n        }else{\n          break;\n        }\n      }\n      if( n==0 ) *tokenType = TK_ILLEGAL;\n      return i;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case 'x': case 'X': {\n      testcase( z[0]=='x' ); testcase( z[0]=='X' );\n      if( z[1]=='\\'' ){\n        *tokenType = TK_BLOB;\n        for(i=2; sqlite3Isxdigit(z[i]); i++){}\n        if( z[i]!='\\'' || i%2 ){\n          *tokenType = TK_ILLEGAL;\n          while( z[i] && z[i]!='\\'' ){ i++; }\n        }\n        if( z[i] ) i++;\n        return i;\n      }\n      /* Otherwise fall through to the next case */\n    }\n#endif\n    default: {\n      if( !IdChar(*z) ){\n        break;\n      }\n      for(i=1; IdChar(z[i]); i++){}\n      *tokenType = keywordCode((char*)z, i);\n      return i;\n    }\n  }\n  *tokenType = TK_ILLEGAL;\n  return 1;\n}\n\n/*\n** Run the parser on the given SQL string.  The parser structure is\n** passed in.  An SQLITE_ status code is returned.  If an error occurs\n** then an and attempt is made to write an error message into \n** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that\n** error message.\n*/\nSQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){\n  int nErr = 0;                   /* Number of errors encountered */\n  int i;                          /* Loop counter */\n  void *pEngine;                  /* The LEMON-generated LALR(1) parser */\n  int tokenType;                  /* type of the next token */\n  int lastTokenParsed = -1;       /* type of the previous token */\n  u8 enableLookaside;             /* Saved value of db->lookaside.bEnabled */\n  sqlite3 *db = pParse->db;       /* The database connection */\n  int mxSqlLen;                   /* Max length of an SQL string */\n\n\n  mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n  if( db->activeVdbeCnt==0 ){\n    db->u1.isInterrupted = 0;\n  }\n  pParse->rc = SQLITE_OK;\n  pParse->zTail = zSql;\n  i = 0;\n  assert( pzErrMsg!=0 );\n  pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3Malloc);\n  if( pEngine==0 ){\n    db->mallocFailed = 1;\n    return SQLITE_NOMEM;\n  }\n  assert( pParse->pNewTable==0 );\n  assert( pParse->pNewTrigger==0 );\n  assert( pParse->nVar==0 );\n  assert( pParse->nzVar==0 );\n  assert( pParse->azVar==0 );\n  enableLookaside = db->lookaside.bEnabled;\n  if( db->lookaside.pStart ) db->lookaside.bEnabled = 1;\n  while( !db->mallocFailed && zSql[i]!=0 ){\n    assert( i>=0 );\n    pParse->sLastToken.z = &zSql[i];\n    pParse->sLastToken.n = sqlite3GetToken((unsigned char*)&zSql[i],&tokenType);\n    i += pParse->sLastToken.n;\n    if( i>mxSqlLen ){\n      pParse->rc = SQLITE_TOOBIG;\n      break;\n    }\n    switch( tokenType ){\n      case TK_SPACE: {\n        if( db->u1.isInterrupted ){\n          sqlite3ErrorMsg(pParse, \"interrupt\");\n          pParse->rc = SQLITE_INTERRUPT;\n          goto abort_parse;\n        }\n        break;\n      }\n      case TK_ILLEGAL: {\n        sqlite3DbFree(db, *pzErrMsg);\n        *pzErrMsg = sqlite3MPrintf(db, \"unrecognized token: \\\"%T\\\"\",\n                        &pParse->sLastToken);\n        nErr++;\n        goto abort_parse;\n      }\n      case TK_SEMI: {\n        pParse->zTail = &zSql[i];\n        /* Fall thru into the default case */\n      }\n      default: {\n        sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);\n        lastTokenParsed = tokenType;\n        if( pParse->rc!=SQLITE_OK ){\n          goto abort_parse;\n        }\n        break;\n      }\n    }\n  }\nabort_parse:\n  if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){\n    if( lastTokenParsed!=TK_SEMI ){\n      sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);\n      pParse->zTail = &zSql[i];\n    }\n    sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);\n  }\n#ifdef YYTRACKMAXSTACKDEPTH\n  sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,\n      sqlite3ParserStackPeak(pEngine)\n  );\n#endif /* YYDEBUG */\n  sqlite3ParserFree(pEngine, sqlite3_free);\n  db->lookaside.bEnabled = enableLookaside;\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM;\n  }\n  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){\n    sqlite3SetString(&pParse->zErrMsg, db, \"%s\", sqlite3ErrStr(pParse->rc));\n  }\n  assert( pzErrMsg!=0 );\n  if( pParse->zErrMsg ){\n    *pzErrMsg = pParse->zErrMsg;\n    sqlite3_log(pParse->rc, \"%s\", *pzErrMsg);\n    pParse->zErrMsg = 0;\n    nErr++;\n  }\n  if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){\n    sqlite3VdbeDelete(pParse->pVdbe);\n    pParse->pVdbe = 0;\n  }\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  if( pParse->nested==0 ){\n    sqlite3DbFree(db, pParse->aTableLock);\n    pParse->aTableLock = 0;\n    pParse->nTableLock = 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_free(pParse->apVtabLock);\n#endif\n\n  if( !IN_DECLARE_VTAB ){\n    /* If the pParse->declareVtab flag is set, do not delete any table \n    ** structure built up in pParse->pNewTable. The calling code (see vtab.c)\n    ** will take responsibility for freeing the Table structure.\n    */\n    sqlite3DeleteTable(db, pParse->pNewTable);\n  }\n\n  sqlite3DeleteTrigger(db, pParse->pNewTrigger);\n  for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]);\n  sqlite3DbFree(db, pParse->azVar);\n  sqlite3DbFree(db, pParse->aAlias);\n  while( pParse->pAinc ){\n    AutoincInfo *p = pParse->pAinc;\n    pParse->pAinc = p->pNext;\n    sqlite3DbFree(db, p);\n  }\n  while( pParse->pZombieTab ){\n    Table *p = pParse->pZombieTab;\n    pParse->pZombieTab = p->pNextZombie;\n    sqlite3DeleteTable(db, p);\n  }\n  if( nErr>0 && pParse->rc==SQLITE_OK ){\n    pParse->rc = SQLITE_ERROR;\n  }\n  return nErr;\n}\n\n/************** End of tokenize.c ********************************************/\n/************** Begin file complete.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that implements the sqlite3_complete() API.\n** This code used to be part of the tokenizer.c source file.  But by\n** separating it out, the code will be automatically omitted from\n** static links that do not use it.\n*/\n#ifndef SQLITE_OMIT_COMPLETE\n\n/*\n** This is defined in tokenize.c.  We just have to import the definition.\n*/\n#ifndef SQLITE_AMALGAMATION\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n#endif /* SQLITE_AMALGAMATION */\n\n\n/*\n** Token types used by the sqlite3_complete() routine.  See the header\n** comments on that procedure for additional information.\n*/\n#define tkSEMI    0\n#define tkWS      1\n#define tkOTHER   2\n#ifndef SQLITE_OMIT_TRIGGER\n#define tkEXPLAIN 3\n#define tkCREATE  4\n#define tkTEMP    5\n#define tkTRIGGER 6\n#define tkEND     7\n#endif\n\n/*\n** Return TRUE if the given SQL string ends in a semicolon.\n**\n** Special handling is require for CREATE TRIGGER statements.\n** Whenever the CREATE TRIGGER keywords are seen, the statement\n** must end with \";END;\".\n**\n** This implementation uses a state machine with 8 states:\n**\n**   (0) INVALID   We have not yet seen a non-whitespace character.\n**\n**   (1) START     At the beginning or end of an SQL statement.  This routine\n**                 returns 1 if it ends in the START state and 0 if it ends\n**                 in any other state.\n**\n**   (2) NORMAL    We are in the middle of statement which ends with a single\n**                 semicolon.\n**\n**   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of \n**                 a statement.\n**\n**   (4) CREATE    The keyword CREATE has been seen at the beginning of a\n**                 statement, possibly preceeded by EXPLAIN and/or followed by\n**                 TEMP or TEMPORARY\n**\n**   (5) TRIGGER   We are in the middle of a trigger definition that must be\n**                 ended by a semicolon, the keyword END, and another semicolon.\n**\n**   (6) SEMI      We've seen the first semicolon in the \";END;\" that occurs at\n**                 the end of a trigger definition.\n**\n**   (7) END       We've seen the \";END\" of the \";END;\" that occurs at the end\n**                 of a trigger difinition.\n**\n** Transitions between states above are determined by tokens extracted\n** from the input.  The following tokens are significant:\n**\n**   (0) tkSEMI      A semicolon.\n**   (1) tkWS        Whitespace.\n**   (2) tkOTHER     Any other SQL token.\n**   (3) tkEXPLAIN   The \"explain\" keyword.\n**   (4) tkCREATE    The \"create\" keyword.\n**   (5) tkTEMP      The \"temp\" or \"temporary\" keyword.\n**   (6) tkTRIGGER   The \"trigger\" keyword.\n**   (7) tkEND       The \"end\" keyword.\n**\n** Whitespace never causes a state transition and is always ignored.\n** This means that a SQL string of all whitespace is invalid.\n**\n** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed\n** to recognize the end of a trigger can be omitted.  All we have to do\n** is look for a semicolon that is not part of an string or comment.\n*/\nSQLITE_API int sqlite3_complete(const char *zSql){\n  u8 state = 0;   /* Current state, using numbers defined in header comment */\n  u8 token;       /* Value of the next token */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* A complex statement machine used to detect the end of a CREATE TRIGGER\n  ** statement.  This is the normal case.\n  */\n  static const u8 trans[8][8] = {\n                     /* Token:                                                */\n     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */\n     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },\n     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },\n     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },\n     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },\n     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },\n     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },\n     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },\n     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },\n  };\n#else\n  /* If triggers are not supported by this compile then the statement machine\n  ** used to detect the end of a statement is much simplier\n  */\n  static const u8 trans[3][3] = {\n                     /* Token:           */\n     /* State:       **  SEMI  WS  OTHER */\n     /* 0 INVALID: */ {    1,  0,     2, },\n     /* 1   START: */ {    1,  1,     2, },\n     /* 2  NORMAL: */ {    1,  2,     2, },\n  };\n#endif /* SQLITE_OMIT_TRIGGER */\n\n  while( *zSql ){\n    switch( *zSql ){\n      case ';': {  /* A semicolon */\n        token = tkSEMI;\n        break;\n      }\n      case ' ':\n      case '\\r':\n      case '\\t':\n      case '\\n':\n      case '\\f': {  /* White space is ignored */\n        token = tkWS;\n        break;\n      }\n      case '/': {   /* C-style comments */\n        if( zSql[1]!='*' ){\n          token = tkOTHER;\n          break;\n        }\n        zSql += 2;\n        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }\n        if( zSql[0]==0 ) return 0;\n        zSql++;\n        token = tkWS;\n        break;\n      }\n      case '-': {   /* SQL-style comments from \"--\" to end of line */\n        if( zSql[1]!='-' ){\n          token = tkOTHER;\n          break;\n        }\n        while( *zSql && *zSql!='\\n' ){ zSql++; }\n        if( *zSql==0 ) return state==1;\n        token = tkWS;\n        break;\n      }\n      case '[': {   /* Microsoft-style identifiers in [...] */\n        zSql++;\n        while( *zSql && *zSql!=']' ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      case '`':     /* Grave-accent quoted symbols used by MySQL */\n      case '\"':     /* single- and double-quoted strings */\n      case '\\'': {\n        int c = *zSql;\n        zSql++;\n        while( *zSql && *zSql!=c ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      default: {\n#ifdef SQLITE_EBCDIC\n        unsigned char c;\n#endif\n        if( IdChar((u8)*zSql) ){\n          /* Keywords and unquoted identifiers */\n          int nId;\n          for(nId=1; IdChar(zSql[nId]); nId++){}\n#ifdef SQLITE_OMIT_TRIGGER\n          token = tkOTHER;\n#else\n          switch( *zSql ){\n            case 'c': case 'C': {\n              if( nId==6 && sqlite3StrNICmp(zSql, \"create\", 6)==0 ){\n                token = tkCREATE;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 't': case 'T': {\n              if( nId==7 && sqlite3StrNICmp(zSql, \"trigger\", 7)==0 ){\n                token = tkTRIGGER;\n              }else if( nId==4 && sqlite3StrNICmp(zSql, \"temp\", 4)==0 ){\n                token = tkTEMP;\n              }else if( nId==9 && sqlite3StrNICmp(zSql, \"temporary\", 9)==0 ){\n                token = tkTEMP;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 'e':  case 'E': {\n              if( nId==3 && sqlite3StrNICmp(zSql, \"end\", 3)==0 ){\n                token = tkEND;\n              }else\n#ifndef SQLITE_OMIT_EXPLAIN\n              if( nId==7 && sqlite3StrNICmp(zSql, \"explain\", 7)==0 ){\n                token = tkEXPLAIN;\n              }else\n#endif\n              {\n                token = tkOTHER;\n              }\n              break;\n            }\n            default: {\n              token = tkOTHER;\n              break;\n            }\n          }\n#endif /* SQLITE_OMIT_TRIGGER */\n          zSql += nId-1;\n        }else{\n          /* Operators and special symbols */\n          token = tkOTHER;\n        }\n        break;\n      }\n    }\n    state = trans[state][token];\n    zSql++;\n  }\n  return state==1;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine is the same as the sqlite3_complete() routine described\n** above, except that the parameter is required to be UTF-16 encoded, not\n** UTF-8.\n*/\nSQLITE_API int sqlite3_complete16(const void *zSql){\n  sqlite3_value *pVal;\n  char const *zSql8;\n  int rc = SQLITE_NOMEM;\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zSql8 ){\n    rc = sqlite3_complete(zSql8);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  sqlite3ValueFree(pVal);\n  return sqlite3ApiExit(0, rc);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_COMPLETE */\n\n/************** End of complete.c ********************************************/\n/************** Begin file main.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n\n#ifdef SQLITE_ENABLE_FTS3\n/************** Include fts3.h in the middle of main.c ***********************/\n/************** Begin file fts3.h ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** FTS3 library.  All it does is declare the sqlite3Fts3Init() interface.\n*/\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of fts3.h ************************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_RTREE\n/************** Include rtree.h in the middle of main.c **********************/\n/************** Begin file rtree.h *******************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** RTREE library.  All it does is declare the sqlite3RtreeInit() interface.\n*/\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of rtree.h ***********************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_ICU\n/************** Include sqliteicu.h in the middle of main.c ******************/\n/************** Begin file sqliteicu.h ***************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** ICU extension.  All it does is declare the sqlite3IcuInit() interface.\n*/\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n\n/************** End of sqliteicu.h *******************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n\n#ifndef SQLITE_AMALGAMATION\n/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant\n** contains the text of SQLITE_VERSION macro. \n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\n#endif\n\n/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns\n** a pointer to the to the sqlite3_version[] string constant. \n*/\nSQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }\n\n/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a\n** pointer to a string constant whose value is the same as the\n** SQLITE_SOURCE_ID C preprocessor macro. \n*/\nSQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }\n\n/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function\n** returns an integer equal to SQLITE_VERSION_NUMBER.\n*/\nSQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }\n\n/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns\n** zero if and only if SQLite was compiled with mutexing code omitted due to\n** the SQLITE_THREADSAFE compile-time option being set to 0.\n*/\nSQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** If the following function pointer is not NULL and if\n** SQLITE_ENABLE_IOTRACE is enabled, then messages describing\n** I/O active are written using this function.  These messages\n** are intended for debugging activity only.\n*/\nSQLITE_PRIVATE void (*sqlite3IoTrace)(const char*, ...) = 0;\n#endif\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** temporary files.\n**\n** See also the \"PRAGMA temp_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_temp_directory = 0;\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** all database files specified with a relative pathname.\n**\n** See also the \"PRAGMA data_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_data_directory = 0;\n\n/*\n** Initialize SQLite.  \n**\n** This routine must be called to initialize the memory allocation,\n** VFS, and mutex subsystems prior to doing any serious work with\n** SQLite.  But as long as you do not compile with SQLITE_OMIT_AUTOINIT\n** this routine will be called automatically by key routines such as\n** sqlite3_open().  \n**\n** This routine is a no-op except on its very first call for the process,\n** or for the first call after a call to sqlite3_shutdown.\n**\n** The first thread to call this routine runs the initialization to\n** completion.  If subsequent threads call this routine before the first\n** thread has finished the initialization process, then the subsequent\n** threads must block until the first thread finishes with the initialization.\n**\n** The first thread might call this routine recursively.  Recursive\n** calls to this routine should not block, of course.  Otherwise the\n** initialization process would never complete.\n**\n** Let X be the first thread to enter this routine.  Let Y be some other\n** thread.  Then while the initial invocation of this routine by X is\n** incomplete, it is required that:\n**\n**    *  Calls to this routine from Y must block until the outer-most\n**       call by X completes.\n**\n**    *  Recursive calls to this routine from thread X return immediately\n**       without blocking.\n*/\nSQLITE_API int sqlite3_initialize(void){\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )       /* The main static mutex */\n  int rc;                                      /* Result code */\n\n#ifdef SQLITE_OMIT_WSD\n  rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  /* If SQLite is already completely initialized, then this call\n  ** to sqlite3_initialize() should be a no-op.  But the initialization\n  ** must be complete.  So isInit must not be set until the very end\n  ** of this routine.\n  */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  {\n    extern void sqlite3_init_sqllog(void);\n    sqlite3_init_sqllog();\n  }\n#endif\n\n  /* Make sure the mutex subsystem is initialized.  If unable to \n  ** initialize the mutex subsystem, return early with the error.\n  ** If the system is so sick that we are unable to allocate a mutex,\n  ** there is not much SQLite is going to be able to do.\n  **\n  ** The mutex subsystem must take care of serializing its own\n  ** initialization.\n  */\n  rc = sqlite3MutexInit();\n  if( rc ) return rc;\n\n  /* Initialize the malloc() system and the recursive pInitMutex mutex.\n  ** This operation is protected by the STATIC_MASTER mutex.  Note that\n  ** MutexAlloc() is called for a static mutex prior to initializing the\n  ** malloc subsystem - this implies that the allocation of a static\n  ** mutex must not require support from the malloc subsystem.\n  */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.isMutexInit = 1;\n  if( !sqlite3GlobalConfig.isMallocInit ){\n    rc = sqlite3MallocInit();\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.isMallocInit = 1;\n    if( !sqlite3GlobalConfig.pInitMutex ){\n      sqlite3GlobalConfig.pInitMutex =\n           sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n      if( sqlite3GlobalConfig.bCoreMutex && !sqlite3GlobalConfig.pInitMutex ){\n        rc = SQLITE_NOMEM;\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.nRefInitMutex++;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* If rc is not SQLITE_OK at this point, then either the malloc\n  ** subsystem could not be initialized or the system failed to allocate\n  ** the pInitMutex mutex. Return an error in either case.  */\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Do the rest of the initialization under the recursive mutex so\n  ** that we will be able to handle recursive calls into\n  ** sqlite3_initialize().  The recursive calls normally come through\n  ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other\n  ** recursive calls might also be possible.\n  **\n  ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls\n  ** to the xInit method, so the xInit method need not be threadsafe.\n  **\n  ** The following mutex is what serializes access to the appdef pcache xInit\n  ** methods.  The sqlite3_pcache_methods.xInit() all is embedded in the\n  ** call to sqlite3PcacheInitialize().\n  */\n  sqlite3_mutex_enter(sqlite3GlobalConfig.pInitMutex);\n  if( sqlite3GlobalConfig.isInit==0 && sqlite3GlobalConfig.inProgress==0 ){\n    FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);\n    sqlite3GlobalConfig.inProgress = 1;\n    memset(pHash, 0, sizeof(sqlite3GlobalFunctions));\n    sqlite3RegisterGlobalFunctions();\n    if( sqlite3GlobalConfig.isPCacheInit==0 ){\n      rc = sqlite3PcacheInitialize();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3GlobalConfig.isPCacheInit = 1;\n      rc = sqlite3OsInit();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, \n          sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);\n      sqlite3GlobalConfig.isInit = 1;\n    }\n    sqlite3GlobalConfig.inProgress = 0;\n  }\n  sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex);\n\n  /* Go back under the static mutex and clean up the recursive\n  ** mutex to prevent a resource leak.\n  */\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.nRefInitMutex--;\n  if( sqlite3GlobalConfig.nRefInitMutex<=0 ){\n    assert( sqlite3GlobalConfig.nRefInitMutex==0 );\n    sqlite3_mutex_free(sqlite3GlobalConfig.pInitMutex);\n    sqlite3GlobalConfig.pInitMutex = 0;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* The following is just a sanity check to make sure SQLite has\n  ** been compiled correctly.  It is important to run this code, but\n  ** we don't want to run it too often and soak up CPU cycles for no\n  ** reason.  So we run it once during initialization.\n  */\n#ifndef NDEBUG\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  /* This section of code's only \"output\" is via assert() statements. */\n  if ( rc==SQLITE_OK ){\n    u64 x = (((u64)1)<<63)-1;\n    double y;\n    assert(sizeof(x)==8);\n    assert(sizeof(x)==sizeof(y));\n    memcpy(&y, &x, 8);\n    assert( sqlite3IsNaN(y) );\n  }\n#endif\n#endif\n\n  /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT\n  ** compile-time option.\n  */\n#ifdef SQLITE_EXTRA_INIT\n  if( rc==SQLITE_OK && sqlite3GlobalConfig.isInit ){\n    int SQLITE_EXTRA_INIT(const char*);\n    rc = SQLITE_EXTRA_INIT(0);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Undo the effects of sqlite3_initialize().  Must not be called while\n** there are outstanding database connections or memory allocations or\n** while any part of SQLite is otherwise in use in any thread.  This\n** routine is not threadsafe.  But it is safe to invoke this routine\n** on when SQLite is already shut down.  If SQLite is already shut down\n** when this routine is invoked, then this routine is a harmless no-op.\n*/\nSQLITE_API int sqlite3_shutdown(void){\n  if( sqlite3GlobalConfig.isInit ){\n#ifdef SQLITE_EXTRA_SHUTDOWN\n    void SQLITE_EXTRA_SHUTDOWN(void);\n    SQLITE_EXTRA_SHUTDOWN();\n#endif\n    sqlite3_os_end();\n    sqlite3_reset_auto_extension();\n    sqlite3GlobalConfig.isInit = 0;\n  }\n  if( sqlite3GlobalConfig.isPCacheInit ){\n    sqlite3PcacheShutdown();\n    sqlite3GlobalConfig.isPCacheInit = 0;\n  }\n  if( sqlite3GlobalConfig.isMallocInit ){\n    sqlite3MallocEnd();\n    sqlite3GlobalConfig.isMallocInit = 0;\n\n#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n    /* The heap subsystem has now been shutdown and these values are supposed\n    ** to be NULL or point to memory that was obtained from sqlite3_malloc(),\n    ** which would rely on that heap subsystem; therefore, make sure these\n    ** values cannot refer to heap memory that was just invalidated when the\n    ** heap subsystem was shutdown.  This is only done if the current call to\n    ** this function resulted in the heap subsystem actually being shutdown.\n    */\n    sqlite3_data_directory = 0;\n    sqlite3_temp_directory = 0;\n#endif\n  }\n  if( sqlite3GlobalConfig.isMutexInit ){\n    sqlite3MutexEnd();\n    sqlite3GlobalConfig.isMutexInit = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This API allows applications to modify the global configuration of\n** the SQLite library at run-time.\n**\n** This routine should only be called when there are no outstanding\n** database connections or memory allocations.  This routine is not\n** threadsafe.  Failure to heed these warnings can lead to unpredictable\n** behavior.\n*/\nSQLITE_API int sqlite3_config(int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n  /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while\n  ** the SQLite library is in use. */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT;\n\n  va_start(ap, op);\n  switch( op ){\n\n    /* Mutex configuration options are only available in a threadsafe\n    ** compile. \n    */\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0\n    case SQLITE_CONFIG_SINGLETHREAD: {\n      /* Disable all mutexing */\n      sqlite3GlobalConfig.bCoreMutex = 0;\n      sqlite3GlobalConfig.bFullMutex = 0;\n      break;\n    }\n    case SQLITE_CONFIG_MULTITHREAD: {\n      /* Disable mutexing of database connections */\n      /* Enable mutexing of core data structures */\n      sqlite3GlobalConfig.bCoreMutex = 1;\n      sqlite3GlobalConfig.bFullMutex = 0;\n      break;\n    }\n    case SQLITE_CONFIG_SERIALIZED: {\n      /* Enable all mutexing */\n      sqlite3GlobalConfig.bCoreMutex = 1;\n      sqlite3GlobalConfig.bFullMutex = 1;\n      break;\n    }\n    case SQLITE_CONFIG_MUTEX: {\n      /* Specify an alternative mutex implementation */\n      sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);\n      break;\n    }\n    case SQLITE_CONFIG_GETMUTEX: {\n      /* Retrieve the current mutex implementation */\n      *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;\n      break;\n    }\n#endif\n\n\n    case SQLITE_CONFIG_MALLOC: {\n      /* Specify an alternative malloc implementation */\n      sqlite3GlobalConfig.m = *va_arg(ap, sqlite3_mem_methods*);\n      break;\n    }\n    case SQLITE_CONFIG_GETMALLOC: {\n      /* Retrieve the current malloc() implementation */\n      if( sqlite3GlobalConfig.m.xMalloc==0 ) sqlite3MemSetDefault();\n      *va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;\n      break;\n    }\n    case SQLITE_CONFIG_MEMSTATUS: {\n      /* Enable or disable the malloc status collection */\n      sqlite3GlobalConfig.bMemstat = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_SCRATCH: {\n      /* Designate a buffer for scratch memory space */\n      sqlite3GlobalConfig.pScratch = va_arg(ap, void*);\n      sqlite3GlobalConfig.szScratch = va_arg(ap, int);\n      sqlite3GlobalConfig.nScratch = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PAGECACHE: {\n      /* Designate a buffer for page cache memory space */\n      sqlite3GlobalConfig.pPage = va_arg(ap, void*);\n      sqlite3GlobalConfig.szPage = va_arg(ap, int);\n      sqlite3GlobalConfig.nPage = va_arg(ap, int);\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE: {\n      /* no-op */\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE: {\n      /* now an error */\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE2: {\n      /* Specify an alternative page cache implementation */\n      sqlite3GlobalConfig.pcache2 = *va_arg(ap, sqlite3_pcache_methods2*);\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE2: {\n      if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n        sqlite3PCacheSetDefault();\n      }\n      *va_arg(ap, sqlite3_pcache_methods2*) = sqlite3GlobalConfig.pcache2;\n      break;\n    }\n\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n    case SQLITE_CONFIG_HEAP: {\n      /* Designate a buffer for heap memory space */\n      sqlite3GlobalConfig.pHeap = va_arg(ap, void*);\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      sqlite3GlobalConfig.mnReq = va_arg(ap, int);\n\n      if( sqlite3GlobalConfig.mnReq<1 ){\n        sqlite3GlobalConfig.mnReq = 1;\n      }else if( sqlite3GlobalConfig.mnReq>(1<<12) ){\n        /* cap min request size at 2^12 */\n        sqlite3GlobalConfig.mnReq = (1<<12);\n      }\n\n      if( sqlite3GlobalConfig.pHeap==0 ){\n        /* If the heap pointer is NULL, then restore the malloc implementation\n        ** back to NULL pointers too.  This will cause the malloc to go\n        ** back to its default implementation when sqlite3_initialize() is\n        ** run.\n        */\n        memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));\n      }else{\n        /* The heap pointer is not NULL, then install one of the\n        ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor\n        ** ENABLE_MEMSYS5 is defined, return an error.\n        */\n#ifdef SQLITE_ENABLE_MEMSYS3\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys5();\n#endif\n      }\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_LOOKASIDE: {\n      sqlite3GlobalConfig.szLookaside = va_arg(ap, int);\n      sqlite3GlobalConfig.nLookaside = va_arg(ap, int);\n      break;\n    }\n    \n    /* Record a pointer to the logger funcction and its first argument.\n    ** The default is NULL.  Logging is disabled if the function pointer is\n    ** NULL.\n    */\n    case SQLITE_CONFIG_LOG: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*));\n      */\n      typedef void(*LOGFUNC_t)(void*,int,const char*);\n      sqlite3GlobalConfig.xLog = va_arg(ap, LOGFUNC_t);\n      sqlite3GlobalConfig.pLogArg = va_arg(ap, void*);\n      break;\n    }\n\n    case SQLITE_CONFIG_URI: {\n      sqlite3GlobalConfig.bOpenUri = va_arg(ap, int);\n      break;\n    }\n\n    case SQLITE_CONFIG_COVERING_INDEX_SCAN: {\n      sqlite3GlobalConfig.bUseCis = va_arg(ap, int);\n      break;\n    }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n    case SQLITE_CONFIG_SQLLOG: {\n      typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);\n      sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);\n      sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MMAP_SIZE: {\n      sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);\n      sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);\n      if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){\n        mxMmap = SQLITE_MAX_MMAP_SIZE;\n      }\n      sqlite3GlobalConfig.mxMmap = mxMmap;\n      if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;\n      if( szMmap>mxMmap) szMmap = mxMmap;\n      sqlite3GlobalConfig.szMmap = szMmap;\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Set up the lookaside buffers for a database connection.\n** Return SQLITE_OK on success.  \n** If lookaside is already active, return SQLITE_BUSY.\n**\n** The sz parameter is the number of bytes in each lookaside slot.\n** The cnt parameter is the number of slots.  If pStart is NULL the\n** space for the lookaside memory is obtained from sqlite3_malloc().\n** If pStart is not NULL then it is sz*cnt bytes of memory to use for\n** the lookaside memory.\n*/\nstatic int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){\n  void *pStart;\n  if( db->lookaside.nOut ){\n    return SQLITE_BUSY;\n  }\n  /* Free any existing lookaside buffer for this handle before\n  ** allocating a new one so we don't have to have space for \n  ** both at the same time.\n  */\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger\n  ** than a pointer to be useful.\n  */\n  sz = ROUNDDOWN8(sz);  /* IMP: R-33038-09382 */\n  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;\n  if( cnt<0 ) cnt = 0;\n  if( sz==0 || cnt==0 ){\n    sz = 0;\n    pStart = 0;\n  }else if( pBuf==0 ){\n    sqlite3BeginBenignMalloc();\n    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */\n    sqlite3EndBenignMalloc();\n    if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;\n  }else{\n    pStart = pBuf;\n  }\n  db->lookaside.pStart = pStart;\n  db->lookaside.pFree = 0;\n  db->lookaside.sz = (u16)sz;\n  if( pStart ){\n    int i;\n    LookasideSlot *p;\n    assert( sz > (int)sizeof(LookasideSlot*) );\n    p = (LookasideSlot*)pStart;\n    for(i=cnt-1; i>=0; i--){\n      p->pNext = db->lookaside.pFree;\n      db->lookaside.pFree = p;\n      p = (LookasideSlot*)&((u8*)p)[sz];\n    }\n    db->lookaside.pEnd = p;\n    db->lookaside.bEnabled = 1;\n    db->lookaside.bMalloced = pBuf==0 ?1:0;\n  }else{\n    db->lookaside.pEnd = 0;\n    db->lookaside.bEnabled = 0;\n    db->lookaside.bMalloced = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the mutex associated with a database connection.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){\n  return db->mutex;\n}\n\n/*\n** Free up as much memory as we can from the given database\n** connection.\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3 *db){\n  int i;\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      sqlite3PagerShrink(pPager);\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Configuration settings for an individual database connection\n*/\nSQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc;\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_DBCONFIG_LOOKASIDE: {\n      void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */\n      int sz = va_arg(ap, int);       /* IMP: R-47871-25994 */\n      int cnt = va_arg(ap, int);      /* IMP: R-04460-53386 */\n      rc = setupLookaside(db, pBuf, sz, cnt);\n      break;\n    }\n    default: {\n      static const struct {\n        int op;      /* The opcode */\n        u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */\n      } aFlagOp[] = {\n        { SQLITE_DBCONFIG_ENABLE_FKEY,    SQLITE_ForeignKeys    },\n        { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger  },\n      };\n      unsigned int i;\n      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */\n      for(i=0; i<ArraySize(aFlagOp); i++){\n        if( aFlagOp[i].op==op ){\n          int onoff = va_arg(ap, int);\n          int *pRes = va_arg(ap, int*);\n          int oldFlags = db->flags;\n          if( onoff>0 ){\n            db->flags |= aFlagOp[i].mask;\n          }else if( onoff==0 ){\n            db->flags &= ~aFlagOp[i].mask;\n          }\n          if( oldFlags!=db->flags ){\n            sqlite3ExpirePreparedStatements(db);\n          }\n          if( pRes ){\n            *pRes = (db->flags & aFlagOp[i].mask)!=0;\n          }\n          rc = SQLITE_OK;\n          break;\n        }\n      }\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n\n/*\n** Return true if the buffer z[0..n-1] contains all spaces.\n*/\nstatic int allSpaces(const char *z, int n){\n  while( n>0 && z[n-1]==' ' ){ n--; }\n  return n==0;\n}\n\n/*\n** This is the default collating function named \"BINARY\" which is always\n** available.\n**\n** If the padFlag argument is not NULL then space padding at the end\n** of strings is ignored.  This implements the RTRIM collation.\n*/\nstatic int binCollFunc(\n  void *padFlag,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ){\n    if( padFlag\n     && allSpaces(((char*)pKey1)+n, nKey1-n)\n     && allSpaces(((char*)pKey2)+n, nKey2-n)\n    ){\n      /* Leave rc unchanged at 0 */\n    }else{\n      rc = nKey1 - nKey2;\n    }\n  }\n  return rc;\n}\n\n/*\n** Another built-in collating sequence: NOCASE. \n**\n** This collating sequence is intended to be used for \"case independant\n** comparison\". SQLite's knowledge of upper and lower case equivalents\n** extends only to the 26 characters used in the English language.\n**\n** At the moment there is only a UTF-8 implementation.\n*/\nstatic int nocaseCollatingFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int r = sqlite3StrNICmp(\n      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);\n  UNUSED_PARAMETER(NotUsed);\n  if( 0==r ){\n    r = nKey1-nKey2;\n  }\n  return r;\n}\n\n/*\n** Return the ROWID of the most recent insert\n*/\nSQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){\n  return db->lastRowid;\n}\n\n/*\n** Return the number of changes in the most recent call to sqlite3_exec().\n*/\nSQLITE_API int sqlite3_changes(sqlite3 *db){\n  return db->nChange;\n}\n\n/*\n** Return the number of changes since the database handle was opened.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3 *db){\n  return db->nTotalChange;\n}\n\n/*\n** Close all open savepoints. This function only manipulates fields of the\n** database handle object, it does not close any savepoints that may be open\n** at the b-tree/pager level.\n*/\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *db){\n  while( db->pSavepoint ){\n    Savepoint *pTmp = db->pSavepoint;\n    db->pSavepoint = pTmp->pNext;\n    sqlite3DbFree(db, pTmp);\n  }\n  db->nSavepoint = 0;\n  db->nStatement = 0;\n  db->isTransactionSavepoint = 0;\n}\n\n/*\n** Invoke the destructor function associated with FuncDef p, if any. Except,\n** if this is not the last copy of the function, do not invoke it. Multiple\n** copies of a single function are created when create_function() is called\n** with SQLITE_ANY as the encoding.\n*/\nstatic void functionDestroy(sqlite3 *db, FuncDef *p){\n  FuncDestructor *pDestructor = p->pDestructor;\n  if( pDestructor ){\n    pDestructor->nRef--;\n    if( pDestructor->nRef==0 ){\n      pDestructor->xDestroy(pDestructor->pUserData);\n      sqlite3DbFree(db, pDestructor);\n    }\n  }\n}\n\n/*\n** Disconnect all sqlite3_vtab objects that belong to database connection\n** db. This is called when db is being closed.\n*/\nstatic void disconnectAllVtab(sqlite3 *db){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int i;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Schema *pSchema = db->aDb[i].pSchema;\n    if( db->aDb[i].pSchema ){\n      HashElem *p;\n      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n        Table *pTab = (Table *)sqliteHashData(p);\n        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);\n      }\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n#else\n  UNUSED_PARAMETER(db);\n#endif\n}\n\n/*\n** Return TRUE if database connection db has unfinalized prepared\n** statements or unfinished sqlite3_backup objects.  \n*/\nstatic int connectionIsBusy(sqlite3 *db){\n  int j;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->pVdbe ) return 1;\n  for(j=0; j<db->nDb; j++){\n    Btree *pBt = db->aDb[j].pBt;\n    if( pBt && sqlite3BtreeIsInBackup(pBt) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Close an existing SQLite database\n*/\nstatic int sqlite3Close(sqlite3 *db, int forceZombie){\n  if( !db ){\n    return SQLITE_OK;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n\n  /* Force xDisconnect calls on all virtual tables */\n  disconnectAllVtab(db);\n\n  /* If a transaction is open, the disconnectAllVtab() call above\n  ** will not have called the xDisconnect() method on any virtual\n  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()\n  ** call will do so. We need to do this before the check for active\n  ** SQL statements below, as the v-table implementation may be storing\n  ** some prepared statements internally.\n  */\n  sqlite3VtabRollback(db);\n\n  /* Legacy behavior (sqlite3_close() behavior) is to return\n  ** SQLITE_BUSY if the connection can not be closed immediately.\n  */\n  if( !forceZombie && connectionIsBusy(db) ){\n    sqlite3Error(db, SQLITE_BUSY, \"unable to close due to unfinalized \"\n       \"statements or unfinished backups\");\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_BUSY;\n  }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Closing the handle. Fourth parameter is passed the value 2. */\n    sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);\n  }\n#endif\n\n  /* Convert the connection into a zombie and then close it.\n  */\n  db->magic = SQLITE_MAGIC_ZOMBIE;\n  sqlite3LeaveMutexAndCloseZombie(db);\n  return SQLITE_OK;\n}\n\n/*\n** Two variations on the public interface for closing a database\n** connection. The sqlite3_close() version returns SQLITE_BUSY and\n** leaves the connection option if there are unfinalized prepared\n** statements or unfinished sqlite3_backups.  The sqlite3_close_v2()\n** version forces the connection to become a zombie if there are\n** unclosed resources, and arranges for deallocation when the last\n** prepare statement or sqlite3_backup closes.\n*/\nSQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }\nSQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }\n\n\n/*\n** Close the mutex on database connection db.\n**\n** Furthermore, if database connection db is a zombie (meaning that there\n** has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and\n** every sqlite3_stmt has now been finalized and every sqlite3_backup has\n** finished, then free all resources.\n*/\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){\n  HashElem *i;                    /* Hash table iterator */\n  int j;\n\n  /* If there are outstanding sqlite3_stmt or sqlite3_backup objects\n  ** or if the connection has not yet been closed by sqlite3_close_v2(),\n  ** then just leave the mutex and return.\n  */\n  if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){\n    sqlite3_mutex_leave(db->mutex);\n    return;\n  }\n\n  /* If we reach this point, it means that the database connection has\n  ** closed all sqlite3_stmt and sqlite3_backup objects and has been\n  ** passed to sqlite3_close (meaning that it is a zombie).  Therefore,\n  ** go ahead and free all resources.\n  */\n\n  /* If a transaction is open, roll it back. This also ensures that if\n  ** any database schemas have been modified by an uncommitted transaction\n  ** they are reset. And that the required b-tree mutex is held to make\n  ** the pager rollback and schema reset an atomic operation. */\n  sqlite3RollbackAll(db, SQLITE_OK);\n\n  /* Free any outstanding Savepoint structures. */\n  sqlite3CloseSavepoints(db);\n\n  /* Close all database connections */\n  for(j=0; j<db->nDb; j++){\n    struct Db *pDb = &db->aDb[j];\n    if( pDb->pBt ){\n      sqlite3BtreeClose(pDb->pBt);\n      pDb->pBt = 0;\n      if( j!=1 ){\n        pDb->pSchema = 0;\n      }\n    }\n  }\n  /* Clear the TEMP schema separately and last */\n  if( db->aDb[1].pSchema ){\n    sqlite3SchemaClear(db->aDb[1].pSchema);\n  }\n  sqlite3VtabUnlockList(db);\n\n  /* Free up the array of auxiliary databases */\n  sqlite3CollapseDatabaseArray(db);\n  assert( db->nDb<=2 );\n  assert( db->aDb==db->aDbStatic );\n\n  /* Tell the code in notify.c that the connection no longer holds any\n  ** locks and does not require any further unlock-notify callbacks.\n  */\n  sqlite3ConnectionClosed(db);\n\n  for(j=0; j<ArraySize(db->aFunc.a); j++){\n    FuncDef *pNext, *pHash, *p;\n    for(p=db->aFunc.a[j]; p; p=pHash){\n      pHash = p->pHash;\n      while( p ){\n        functionDestroy(db, p);\n        pNext = p->pNext;\n        sqlite3DbFree(db, p);\n        p = pNext;\n      }\n    }\n  }\n  for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){\n    CollSeq *pColl = (CollSeq *)sqliteHashData(i);\n    /* Invoke any destructors registered for collation sequence user data. */\n    for(j=0; j<3; j++){\n      if( pColl[j].xDel ){\n        pColl[j].xDel(pColl[j].pUser);\n      }\n    }\n    sqlite3DbFree(db, pColl);\n  }\n  sqlite3HashClear(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){\n    Module *pMod = (Module *)sqliteHashData(i);\n    if( pMod->xDestroy ){\n      pMod->xDestroy(pMod->pAux);\n    }\n    sqlite3DbFree(db, pMod);\n  }\n  sqlite3HashClear(&db->aModule);\n#endif\n\n  sqlite3Error(db, SQLITE_OK, 0); /* Deallocates any cached error strings. */\n  if( db->pErr ){\n    sqlite3ValueFree(db->pErr);\n  }\n  sqlite3CloseExtensions(db);\n\n  db->magic = SQLITE_MAGIC_ERROR;\n\n  /* The temp-database schema is allocated differently from the other schema\n  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).\n  ** So it needs to be freed here. Todo: Why not roll the temp schema into\n  ** the same sqliteMalloc() as the one that allocates the database \n  ** structure?\n  */\n  sqlite3DbFree(db, db->aDb[1].pSchema);\n  sqlite3_mutex_leave(db->mutex);\n  db->magic = SQLITE_MAGIC_CLOSED;\n  sqlite3_mutex_free(db->mutex);\n  assert( db->lookaside.nOut==0 );  /* Fails on a lookaside memory leak */\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  sqlite3_free(db);\n}\n\n/*\n** Rollback all database files.  If tripCode is not SQLITE_OK, then\n** any open cursors are invalidated (\"tripped\" - as in \"tripping a circuit\n** breaker\") and made to return tripCode if there are any further\n** attempts to use that cursor.\n*/\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3 *db, int tripCode){\n  int i;\n  int inTrans = 0;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3BeginBenignMalloc();\n\n  /* Obtain all b-tree mutexes before making any calls to BtreeRollback(). \n  ** This is important in case the transaction being rolled back has\n  ** modified the database schema. If the b-tree mutexes are not taken\n  ** here, then another shared-cache connection might sneak in between\n  ** the database rollback and schema reset, which can cause false\n  ** corruption reports in some cases.  */\n  sqlite3BtreeEnterAll(db);\n\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      if( sqlite3BtreeIsInTrans(p) ){\n        inTrans = 1;\n      }\n      sqlite3BtreeRollback(p, tripCode);\n      db->aDb[i].inTrans = 0;\n    }\n  }\n  sqlite3VtabRollback(db);\n  sqlite3EndBenignMalloc();\n\n  if( (db->flags&SQLITE_InternChanges)!=0 && db->init.busy==0 ){\n    sqlite3ExpirePreparedStatements(db);\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  sqlite3BtreeLeaveAll(db);\n\n  /* Any deferred constraint violations have now been resolved. */\n  db->nDeferredCons = 0;\n\n  /* If one has been configured, invoke the rollback-hook callback */\n  if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){\n    db->xRollbackCallback(db->pRollbackArg);\n  }\n}\n\n/*\n** Return a static string containing the name corresponding to the error code\n** specified in the argument.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) || \\\n    defined(SQLITE_DEBUG_OS_TRACE)\nSQLITE_PRIVATE const char *sqlite3ErrName(int rc){\n  const char *zName = 0;\n  int i, origRc = rc;\n  for(i=0; i<2 && zName==0; i++, rc &= 0xff){\n    switch( rc ){\n      case SQLITE_OK:                 zName = \"SQLITE_OK\";                break;\n      case SQLITE_ERROR:              zName = \"SQLITE_ERROR\";             break;\n      case SQLITE_INTERNAL:           zName = \"SQLITE_INTERNAL\";          break;\n      case SQLITE_PERM:               zName = \"SQLITE_PERM\";              break;\n      case SQLITE_ABORT:              zName = \"SQLITE_ABORT\";             break;\n      case SQLITE_ABORT_ROLLBACK:     zName = \"SQLITE_ABORT_ROLLBACK\";    break;\n      case SQLITE_BUSY:               zName = \"SQLITE_BUSY\";              break;\n      case SQLITE_BUSY_RECOVERY:      zName = \"SQLITE_BUSY_RECOVERY\";     break;\n      case SQLITE_LOCKED:             zName = \"SQLITE_LOCKED\";            break;\n      case SQLITE_LOCKED_SHAREDCACHE: zName = \"SQLITE_LOCKED_SHAREDCACHE\";break;\n      case SQLITE_NOMEM:              zName = \"SQLITE_NOMEM\";             break;\n      case SQLITE_READONLY:           zName = \"SQLITE_READONLY\";          break;\n      case SQLITE_READONLY_RECOVERY:  zName = \"SQLITE_READONLY_RECOVERY\"; break;\n      case SQLITE_READONLY_CANTLOCK:  zName = \"SQLITE_READONLY_CANTLOCK\"; break;\n      case SQLITE_READONLY_ROLLBACK:  zName = \"SQLITE_READONLY_ROLLBACK\"; break;\n      case SQLITE_INTERRUPT:          zName = \"SQLITE_INTERRUPT\";         break;\n      case SQLITE_IOERR:              zName = \"SQLITE_IOERR\";             break;\n      case SQLITE_IOERR_READ:         zName = \"SQLITE_IOERR_READ\";        break;\n      case SQLITE_IOERR_SHORT_READ:   zName = \"SQLITE_IOERR_SHORT_READ\";  break;\n      case SQLITE_IOERR_WRITE:        zName = \"SQLITE_IOERR_WRITE\";       break;\n      case SQLITE_IOERR_FSYNC:        zName = \"SQLITE_IOERR_FSYNC\";       break;\n      case SQLITE_IOERR_DIR_FSYNC:    zName = \"SQLITE_IOERR_DIR_FSYNC\";   break;\n      case SQLITE_IOERR_TRUNCATE:     zName = \"SQLITE_IOERR_TRUNCATE\";    break;\n      case SQLITE_IOERR_FSTAT:        zName = \"SQLITE_IOERR_FSTAT\";       break;\n      case SQLITE_IOERR_UNLOCK:       zName = \"SQLITE_IOERR_UNLOCK\";      break;\n      case SQLITE_IOERR_RDLOCK:       zName = \"SQLITE_IOERR_RDLOCK\";      break;\n      case SQLITE_IOERR_DELETE:       zName = \"SQLITE_IOERR_DELETE\";      break;\n      case SQLITE_IOERR_BLOCKED:      zName = \"SQLITE_IOERR_BLOCKED\";     break;\n      case SQLITE_IOERR_NOMEM:        zName = \"SQLITE_IOERR_NOMEM\";       break;\n      case SQLITE_IOERR_ACCESS:       zName = \"SQLITE_IOERR_ACCESS\";      break;\n      case SQLITE_IOERR_CHECKRESERVEDLOCK:\n                                zName = \"SQLITE_IOERR_CHECKRESERVEDLOCK\"; break;\n      case SQLITE_IOERR_LOCK:         zName = \"SQLITE_IOERR_LOCK\";        break;\n      case SQLITE_IOERR_CLOSE:        zName = \"SQLITE_IOERR_CLOSE\";       break;\n      case SQLITE_IOERR_DIR_CLOSE:    zName = \"SQLITE_IOERR_DIR_CLOSE\";   break;\n      case SQLITE_IOERR_SHMOPEN:      zName = \"SQLITE_IOERR_SHMOPEN\";     break;\n      case SQLITE_IOERR_SHMSIZE:      zName = \"SQLITE_IOERR_SHMSIZE\";     break;\n      case SQLITE_IOERR_SHMLOCK:      zName = \"SQLITE_IOERR_SHMLOCK\";     break;\n      case SQLITE_IOERR_SHMMAP:       zName = \"SQLITE_IOERR_SHMMAP\";      break;\n      case SQLITE_IOERR_SEEK:         zName = \"SQLITE_IOERR_SEEK\";        break;\n      case SQLITE_IOERR_DELETE_NOENT: zName = \"SQLITE_IOERR_DELETE_NOENT\";break;\n      case SQLITE_IOERR_MMAP:         zName = \"SQLITE_IOERR_MMAP\";        break;\n      case SQLITE_CORRUPT:            zName = \"SQLITE_CORRUPT\";           break;\n      case SQLITE_CORRUPT_VTAB:       zName = \"SQLITE_CORRUPT_VTAB\";      break;\n      case SQLITE_NOTFOUND:           zName = \"SQLITE_NOTFOUND\";          break;\n      case SQLITE_FULL:               zName = \"SQLITE_FULL\";              break;\n      case SQLITE_CANTOPEN:           zName = \"SQLITE_CANTOPEN\";          break;\n      case SQLITE_CANTOPEN_NOTEMPDIR: zName = \"SQLITE_CANTOPEN_NOTEMPDIR\";break;\n      case SQLITE_CANTOPEN_ISDIR:     zName = \"SQLITE_CANTOPEN_ISDIR\";    break;\n      case SQLITE_CANTOPEN_FULLPATH:  zName = \"SQLITE_CANTOPEN_FULLPATH\"; break;\n      case SQLITE_PROTOCOL:           zName = \"SQLITE_PROTOCOL\";          break;\n      case SQLITE_EMPTY:              zName = \"SQLITE_EMPTY\";             break;\n      case SQLITE_SCHEMA:             zName = \"SQLITE_SCHEMA\";            break;\n      case SQLITE_TOOBIG:             zName = \"SQLITE_TOOBIG\";            break;\n      case SQLITE_CONSTRAINT:         zName = \"SQLITE_CONSTRAINT\";        break;\n      case SQLITE_CONSTRAINT_UNIQUE:  zName = \"SQLITE_CONSTRAINT_UNIQUE\"; break;\n      case SQLITE_CONSTRAINT_TRIGGER: zName = \"SQLITE_CONSTRAINT_TRIGGER\";break;\n      case SQLITE_CONSTRAINT_FOREIGNKEY:\n                                zName = \"SQLITE_CONSTRAINT_FOREIGNKEY\";   break;\n      case SQLITE_CONSTRAINT_CHECK:   zName = \"SQLITE_CONSTRAINT_CHECK\";  break;\n      case SQLITE_CONSTRAINT_PRIMARYKEY:\n                                zName = \"SQLITE_CONSTRAINT_PRIMARYKEY\";   break;\n      case SQLITE_CONSTRAINT_NOTNULL: zName = \"SQLITE_CONSTRAINT_NOTNULL\";break;\n      case SQLITE_CONSTRAINT_COMMITHOOK:\n                                zName = \"SQLITE_CONSTRAINT_COMMITHOOK\";   break;\n      case SQLITE_CONSTRAINT_VTAB:    zName = \"SQLITE_CONSTRAINT_VTAB\";   break;\n      case SQLITE_CONSTRAINT_FUNCTION:\n                                zName = \"SQLITE_CONSTRAINT_FUNCTION\";     break;\n      case SQLITE_MISMATCH:           zName = \"SQLITE_MISMATCH\";          break;\n      case SQLITE_MISUSE:             zName = \"SQLITE_MISUSE\";            break;\n      case SQLITE_NOLFS:              zName = \"SQLITE_NOLFS\";             break;\n      case SQLITE_AUTH:               zName = \"SQLITE_AUTH\";              break;\n      case SQLITE_FORMAT:             zName = \"SQLITE_FORMAT\";            break;\n      case SQLITE_RANGE:              zName = \"SQLITE_RANGE\";             break;\n      case SQLITE_NOTADB:             zName = \"SQLITE_NOTADB\";            break;\n      case SQLITE_ROW:                zName = \"SQLITE_ROW\";               break;\n      case SQLITE_NOTICE:             zName = \"SQLITE_NOTICE\";            break;\n      case SQLITE_NOTICE_RECOVER_WAL: zName = \"SQLITE_NOTICE_RECOVER_WAL\";break;\n      case SQLITE_NOTICE_RECOVER_ROLLBACK:\n                                zName = \"SQLITE_NOTICE_RECOVER_ROLLBACK\"; break;\n      case SQLITE_WARNING:            zName = \"SQLITE_WARNING\";           break;\n      case SQLITE_DONE:               zName = \"SQLITE_DONE\";              break;\n    }\n  }\n  if( zName==0 ){\n    static char zBuf[50];\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"SQLITE_UNKNOWN(%d)\", origRc);\n    zName = zBuf;\n  }\n  return zName;\n}\n#endif\n\n/*\n** Return a static string that describes the kind of error specified in the\n** argument.\n*/\nSQLITE_PRIVATE const char *sqlite3ErrStr(int rc){\n  static const char* const aMsg[] = {\n    /* SQLITE_OK          */ \"not an error\",\n    /* SQLITE_ERROR       */ \"SQL logic error or missing database\",\n    /* SQLITE_INTERNAL    */ 0,\n    /* SQLITE_PERM        */ \"access permission denied\",\n    /* SQLITE_ABORT       */ \"callback requested query abort\",\n    /* SQLITE_BUSY        */ \"database is locked\",\n    /* SQLITE_LOCKED      */ \"database table is locked\",\n    /* SQLITE_NOMEM       */ \"out of memory\",\n    /* SQLITE_READONLY    */ \"attempt to write a readonly database\",\n    /* SQLITE_INTERRUPT   */ \"interrupted\",\n    /* SQLITE_IOERR       */ \"disk I/O error\",\n    /* SQLITE_CORRUPT     */ \"database disk image is malformed\",\n    /* SQLITE_NOTFOUND    */ \"unknown operation\",\n    /* SQLITE_FULL        */ \"database or disk is full\",\n    /* SQLITE_CANTOPEN    */ \"unable to open database file\",\n    /* SQLITE_PROTOCOL    */ \"locking protocol\",\n    /* SQLITE_EMPTY       */ \"table contains no data\",\n    /* SQLITE_SCHEMA      */ \"database schema has changed\",\n    /* SQLITE_TOOBIG      */ \"string or blob too big\",\n    /* SQLITE_CONSTRAINT  */ \"constraint failed\",\n    /* SQLITE_MISMATCH    */ \"datatype mismatch\",\n    /* SQLITE_MISUSE      */ \"library routine called out of sequence\",\n    /* SQLITE_NOLFS       */ \"large file support is disabled\",\n    /* SQLITE_AUTH        */ \"authorization denied\",\n    /* SQLITE_FORMAT      */ \"auxiliary database format error\",\n    /* SQLITE_RANGE       */ \"bind or column index out of range\",\n    /* SQLITE_NOTADB      */ \"file is encrypted or is not a database\",\n  };\n  const char *zErr = \"unknown error\";\n  switch( rc ){\n    case SQLITE_ABORT_ROLLBACK: {\n      zErr = \"abort due to ROLLBACK\";\n      break;\n    }\n    default: {\n      rc &= 0xff;\n      if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){\n        zErr = aMsg[rc];\n      }\n      break;\n    }\n  }\n  return zErr;\n}\n\n/*\n** This routine implements a busy callback that sleeps and tries\n** again until a timeout value is reached.  The timeout value is\n** an integer number of milliseconds passed in as the first\n** argument.\n*/\nstatic int sqliteDefaultBusyCallback(\n void *ptr,               /* Database connection */\n int count                /* Number of times table has been busy */\n){\n#if SQLITE_OS_WIN || (defined(HAVE_USLEEP) && HAVE_USLEEP)\n  static const u8 delays[] =\n     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };\n  static const u8 totals[] =\n     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };\n# define NDELAY ArraySize(delays)\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = db->busyTimeout;\n  int delay, prior;\n\n  assert( count>=0 );\n  if( count < NDELAY ){\n    delay = delays[count];\n    prior = totals[count];\n  }else{\n    delay = delays[NDELAY-1];\n    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));\n  }\n  if( prior + delay > timeout ){\n    delay = timeout - prior;\n    if( delay<=0 ) return 0;\n  }\n  sqlite3OsSleep(db->pVfs, delay*1000);\n  return 1;\n#else\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = ((sqlite3 *)ptr)->busyTimeout;\n  if( (count+1)*1000 > timeout ){\n    return 0;\n  }\n  sqlite3OsSleep(db->pVfs, 1000000);\n  return 1;\n#endif\n}\n\n/*\n** Invoke the given busy handler.\n**\n** This routine is called when an operation failed with a lock.\n** If this routine returns non-zero, the lock is retried.  If it\n** returns 0, the operation aborts with an SQLITE_BUSY error.\n*/\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p){\n  int rc;\n  if( NEVER(p==0) || p->xFunc==0 || p->nBusy<0 ) return 0;\n  rc = p->xFunc(p->pArg, p->nBusy);\n  if( rc==0 ){\n    p->nBusy = -1;\n  }else{\n    p->nBusy++;\n  }\n  return rc; \n}\n\n/*\n** This routine sets the busy callback for an Sqlite database to the\n** given callback function with the given argument.\n*/\nSQLITE_API int sqlite3_busy_handler(\n  sqlite3 *db,\n  int (*xBusy)(void*,int),\n  void *pArg\n){\n  sqlite3_mutex_enter(db->mutex);\n  db->busyHandler.xFunc = xBusy;\n  db->busyHandler.pArg = pArg;\n  db->busyHandler.nBusy = 0;\n  db->busyTimeout = 0;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This routine sets the progress callback for an Sqlite database to the\n** given callback function with the given argument. The progress callback will\n** be invoked every nOps opcodes.\n*/\nSQLITE_API void sqlite3_progress_handler(\n  sqlite3 *db, \n  int nOps,\n  int (*xProgress)(void*), \n  void *pArg\n){\n  sqlite3_mutex_enter(db->mutex);\n  if( nOps>0 ){\n    db->xProgress = xProgress;\n    db->nProgressOps = nOps;\n    db->pProgressArg = pArg;\n  }else{\n    db->xProgress = 0;\n    db->nProgressOps = 0;\n    db->pProgressArg = 0;\n  }\n  sqlite3_mutex_leave(db->mutex);\n}\n#endif\n\n\n/*\n** This routine installs a default busy handler that waits for the\n** specified number of milliseconds before returning 0.\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){\n  if( ms>0 ){\n    sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);\n    db->busyTimeout = ms;\n  }else{\n    sqlite3_busy_handler(db, 0, 0);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Cause any pending operation to stop at its earliest opportunity.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3 *db){\n  db->u1.isInterrupted = 1;\n}\n\n\n/*\n** This function is exactly the same as sqlite3_create_function(), except\n** that it is designed to be called by internal code. The difference is\n** that if a malloc() fails in sqlite3_create_function(), an error code\n** is returned and the mallocFailed flag cleared. \n*/\nSQLITE_PRIVATE int sqlite3CreateFunc(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int enc,\n  void *pUserData,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  FuncDestructor *pDestructor\n){\n  FuncDef *p;\n  int nName;\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( zFunctionName==0 ||\n      (xFunc && (xFinal || xStep)) || \n      (!xFunc && (xFinal && !xStep)) ||\n      (!xFunc && (!xFinal && xStep)) ||\n      (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||\n      (255<(nName = sqlite3Strlen30( zFunctionName))) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  \n#ifndef SQLITE_OMIT_UTF16\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  **\n  ** If SQLITE_ANY is specified, add three versions of the function\n  ** to the hash table.\n  */\n  if( enc==SQLITE_UTF16 ){\n    enc = SQLITE_UTF16NATIVE;\n  }else if( enc==SQLITE_ANY ){\n    int rc;\n    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8,\n         pUserData, xFunc, xStep, xFinal, pDestructor);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE,\n          pUserData, xFunc, xStep, xFinal, pDestructor);\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    enc = SQLITE_UTF16BE;\n  }\n#else\n  enc = SQLITE_UTF8;\n#endif\n  \n  /* Check if an existing function is being overridden or deleted. If so,\n  ** and there are active VMs, then return SQLITE_BUSY. If a function\n  ** is being overridden/deleted but there are no active VMs, allow the\n  ** operation to continue but invalidate all precompiled statements.\n  */\n  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 0);\n  if( p && p->iPrefEnc==enc && p->nArg==nArg ){\n    if( db->activeVdbeCnt ){\n      sqlite3Error(db, SQLITE_BUSY, \n        \"unable to delete/modify user-function due to active statements\");\n      assert( !db->mallocFailed );\n      return SQLITE_BUSY;\n    }else{\n      sqlite3ExpirePreparedStatements(db);\n    }\n  }\n\n  p = sqlite3FindFunction(db, zFunctionName, nName, nArg, (u8)enc, 1);\n  assert(p || db->mallocFailed);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n\n  /* If an older version of the function with a configured destructor is\n  ** being replaced invoke the destructor function here. */\n  functionDestroy(db, p);\n\n  if( pDestructor ){\n    pDestructor->nRef++;\n  }\n  p->pDestructor = pDestructor;\n  p->flags = 0;\n  p->xFunc = xFunc;\n  p->xStep = xStep;\n  p->xFinalize = xFinal;\n  p->pUserData = pUserData;\n  p->nArg = (u16)nArg;\n  return SQLITE_OK;\n}\n\n/*\n** Create new user functions.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*)\n){\n  return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,\n                                    xFinal, 0);\n}\n\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xDestroy)(void *)\n){\n  int rc = SQLITE_ERROR;\n  FuncDestructor *pArg = 0;\n  sqlite3_mutex_enter(db->mutex);\n  if( xDestroy ){\n    pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));\n    if( !pArg ){\n      xDestroy(p);\n      goto out;\n    }\n    pArg->xDestroy = xDestroy;\n    pArg->pUserData = p;\n  }\n  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xFunc, xStep, xFinal, pArg);\n  if( pArg && pArg->nRef==0 ){\n    assert( rc!=SQLITE_OK );\n    xDestroy(p);\n    sqlite3DbFree(db, pArg);\n  }\n\n out:\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *p,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n){\n  int rc;\n  char *zFunc8;\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);\n  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal,0);\n  sqlite3DbFree(db, zFunc8);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif\n\n\n/*\n** Declare that a function has been overloaded by a virtual table.\n**\n** If the function already exists as a regular global function, then\n** this routine is a no-op.  If the function does not exist, then create\n** a new one that always throws a run-time error.  \n**\n** When virtual tables intend to provide an overloaded function, they\n** should call this routine to make sure the global function exists.\n** A global function must exist in order for name resolution to work\n** properly.\n*/\nSQLITE_API int sqlite3_overload_function(\n  sqlite3 *db,\n  const char *zName,\n  int nArg\n){\n  int nName = sqlite3Strlen30(zName);\n  int rc = SQLITE_OK;\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0)==0 ){\n    rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,\n                           0, sqlite3InvalidFunction, 0, 0, 0);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Register a trace function.  The pArg from the previously registered trace\n** is returned.  \n**\n** A NULL trace function means that no tracing is executes.  A non-NULL\n** trace is a pointer to a function that is invoked at the start of each\n** SQL statement.\n*/\nSQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){\n  void *pOld;\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pTraceArg;\n  db->xTrace = xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n/*\n** Register a profile function.  The pArg from the previously registered \n** profile function is returned.  \n**\n** A NULL profile function means that no profiling is executes.  A non-NULL\n** profile is a pointer to a function that is invoked at the conclusion of\n** each SQL statement that is run.\n*/\nSQLITE_API void *sqlite3_profile(\n  sqlite3 *db,\n  void (*xProfile)(void*,const char*,sqlite_uint64),\n  void *pArg\n){\n  void *pOld;\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pProfileArg;\n  db->xProfile = xProfile;\n  db->pProfileArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_TRACE */\n\n/*\n** Register a function to be invoked when a transaction commits.\n** If the invoked function returns non-zero, then the commit becomes a\n** rollback.\n*/\nSQLITE_API void *sqlite3_commit_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  int (*xCallback)(void*),  /* Function to invoke on each commit */\n  void *pArg                /* Argument to the function */\n){\n  void *pOld;\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pCommitArg;\n  db->xCommitCallback = xCallback;\n  db->pCommitArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pUpdateArg;\n  db->xUpdateCallback = xCallback;\n  db->pUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is rolled\n** back by this database connection.\n*/\nSQLITE_API void *sqlite3_rollback_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*), /* Callback function */\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pRollbackArg;\n  db->xRollbackCallback = xCallback;\n  db->pRollbackArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().\n** Invoke sqlite3_wal_checkpoint if the number of frames in the log file\n** is greater than sqlite3.pWalArg cast to an integer (the value configured by\n** wal_autocheckpoint()).\n*/ \nSQLITE_PRIVATE int sqlite3WalDefaultHook(\n  void *pClientData,     /* Argument */\n  sqlite3 *db,           /* Connection */\n  const char *zDb,       /* Database */\n  int nFrame             /* Size of WAL */\n){\n  if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){\n    sqlite3BeginBenignMalloc();\n    sqlite3_wal_checkpoint(db, zDb);\n    sqlite3EndBenignMalloc();\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** Configure an sqlite3_wal_hook() callback to automatically checkpoint\n** a database after committing a transaction if there are nFrame or\n** more frames in the log file. Passing zero or a negative value as the\n** nFrame parameter disables automatic checkpoints entirely.\n**\n** The callback registered by this function replaces any existing callback\n** registered using sqlite3_wal_hook(). Likewise, registering a callback\n** using sqlite3_wal_hook() disables the automatic checkpoint mechanism\n** configured by this function.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){\n#ifdef SQLITE_OMIT_WAL\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(nFrame);\n#else\n  if( nFrame>0 ){\n    sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));\n  }else{\n    sqlite3_wal_hook(db, 0, 0);\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is written\n** into the write-ahead-log by this database connection.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3 *db,                    /* Attach the hook to this db handle */\n  int(*xCallback)(void *, sqlite3*, const char*, int),\n  void *pArg                      /* First argument passed to xCallback() */\n){\n#ifndef SQLITE_OMIT_WAL\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pWalArg;\n  db->xWalCallback = xCallback;\n  db->pWalArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n#else\n  return 0;\n#endif\n}\n\n/*\n** Checkpoint database zDb.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n){\n#ifdef SQLITE_OMIT_WAL\n  return SQLITE_OK;\n#else\n  int rc;                         /* Return code */\n  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */\n\n  /* Initialize the output variables to -1 in case an error occurs. */\n  if( pnLog ) *pnLog = -1;\n  if( pnCkpt ) *pnCkpt = -1;\n\n  assert( SQLITE_CHECKPOINT_FULL>SQLITE_CHECKPOINT_PASSIVE );\n  assert( SQLITE_CHECKPOINT_FULL<SQLITE_CHECKPOINT_RESTART );\n  assert( SQLITE_CHECKPOINT_PASSIVE+2==SQLITE_CHECKPOINT_RESTART );\n  if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_RESTART ){\n    return SQLITE_MISUSE;\n  }\n\n  sqlite3_mutex_enter(db->mutex);\n  if( zDb && zDb[0] ){\n    iDb = sqlite3FindDbName(db, zDb);\n  }\n  if( iDb<0 ){\n    rc = SQLITE_ERROR;\n    sqlite3Error(db, SQLITE_ERROR, \"unknown database: %s\", zDb);\n  }else{\n    rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);\n    sqlite3Error(db, rc, 0);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n#endif\n}\n\n\n/*\n** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points\n** to contains a zero-length string, all attached databases are \n** checkpointed.\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){\n  return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on database iDb. This is a no-op if database iDb is\n** not currently open in WAL mode.\n**\n** If a transaction is open on the database being checkpointed, this \n** function returns SQLITE_LOCKED and a checkpoint is not attempted. If \n** an error occurs while running the checkpoint, an SQLite error code is \n** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.\n**\n** The mutex on database handle db should be held by the caller. The mutex\n** associated with the specific b-tree being checkpointed is taken by\n** this function while the checkpoint is running.\n**\n** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are\n** checkpointed. If an error is encountered it is returned immediately -\n** no attempt is made to checkpoint any remaining databases.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Used to iterate through attached dbs */\n  int bBusy = 0;                  /* True if SQLITE_BUSY has been encountered */\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( !pnLog || *pnLog==-1 );\n  assert( !pnCkpt || *pnCkpt==-1 );\n\n  for(i=0; i<db->nDb && rc==SQLITE_OK; i++){\n    if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){\n      rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);\n      pnLog = 0;\n      pnCkpt = 0;\n      if( rc==SQLITE_BUSY ){\n        bBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** This function returns true if main-memory should be used instead of\n** a temporary file for transient pager files and statement journals.\n** The value returned depends on the value of db->temp_store (runtime\n** parameter) and the compile time value of SQLITE_TEMP_STORE. The\n** following table describes the relationship between these two values\n** and this functions return value.\n**\n**   SQLITE_TEMP_STORE     db->temp_store     Location of temporary database\n**   -----------------     --------------     ------------------------------\n**   0                     any                file      (return 0)\n**   1                     1                  file      (return 0)\n**   1                     2                  memory    (return 1)\n**   1                     0                  file      (return 0)\n**   2                     1                  file      (return 0)\n**   2                     2                  memory    (return 1)\n**   2                     0                  memory    (return 1)\n**   3                     any                memory    (return 1)\n*/\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){\n#if SQLITE_TEMP_STORE==1\n  return ( db->temp_store==2 );\n#endif\n#if SQLITE_TEMP_STORE==2\n  return ( db->temp_store!=1 );\n#endif\n#if SQLITE_TEMP_STORE==3\n  return 1;\n#endif\n#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3\n  return 0;\n#endif\n}\n\n/*\n** Return UTF-8 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const char *sqlite3_errmsg(sqlite3 *db){\n  const char *z;\n  if( !db ){\n    return sqlite3ErrStr(SQLITE_NOMEM);\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return sqlite3ErrStr(SQLITE_MISUSE_BKPT);\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = sqlite3ErrStr(SQLITE_NOMEM);\n  }else{\n    z = (char*)sqlite3_value_text(db->pErr);\n    assert( !db->mallocFailed );\n    if( z==0 ){\n      z = sqlite3ErrStr(db->errCode);\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Return UTF-16 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){\n  static const u16 outOfMem[] = {\n    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0\n  };\n  static const u16 misuse[] = {\n    'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ', \n    'r', 'o', 'u', 't', 'i', 'n', 'e', ' ', \n    'c', 'a', 'l', 'l', 'e', 'd', ' ', \n    'o', 'u', 't', ' ', \n    'o', 'f', ' ', \n    's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0\n  };\n\n  const void *z;\n  if( !db ){\n    return (void *)outOfMem;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return (void *)misuse;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = (void *)outOfMem;\n  }else{\n    z = sqlite3_value_text16(db->pErr);\n    if( z==0 ){\n      sqlite3ValueSetStr(db->pErr, -1, sqlite3ErrStr(db->errCode),\n           SQLITE_UTF8, SQLITE_STATIC);\n      z = sqlite3_value_text16(db->pErr);\n    }\n    /* A malloc() may have failed within the call to sqlite3_value_text16()\n    ** above. If this is the case, then the db->mallocFailed flag needs to\n    ** be cleared before returning. Do this directly, instead of via\n    ** sqlite3ApiExit(), to avoid setting the database handle error message.\n    */\n    db->mallocFailed = 0;\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the most recent error code generated by an SQLite routine. If NULL is\n** passed to this function, we assume a malloc() failed during sqlite3_open().\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM;\n  }\n  return db->errCode & db->errMask;\n}\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM;\n  }\n  return db->errCode;\n}\n\n/*\n** Return a string that describes the kind of error specified in the\n** argument.  For now, this simply calls the internal sqlite3ErrStr()\n** function.\n*/\nSQLITE_API const char *sqlite3_errstr(int rc){\n  return sqlite3ErrStr(rc);\n}\n\n/*\n** Create a new collating function for database \"db\".  The name is zName\n** and the encoding is enc.\n*/\nstatic int createCollation(\n  sqlite3* db,\n  const char *zName, \n  u8 enc,\n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  CollSeq *pColl;\n  int enc2;\n  int nName = sqlite3Strlen30(zName);\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  */\n  enc2 = enc;\n  testcase( enc2==SQLITE_UTF16 );\n  testcase( enc2==SQLITE_UTF16_ALIGNED );\n  if( enc2==SQLITE_UTF16 || enc2==SQLITE_UTF16_ALIGNED ){\n    enc2 = SQLITE_UTF16NATIVE;\n  }\n  if( enc2<SQLITE_UTF8 || enc2>SQLITE_UTF16BE ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  /* Check if this call is removing or replacing an existing collation \n  ** sequence. If so, and there are active VMs, return busy. If there\n  ** are no active VMs, invalidate any pre-compiled statements.\n  */\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);\n  if( pColl && pColl->xCmp ){\n    if( db->activeVdbeCnt ){\n      sqlite3Error(db, SQLITE_BUSY, \n        \"unable to delete/modify collation sequence due to active statements\");\n      return SQLITE_BUSY;\n    }\n    sqlite3ExpirePreparedStatements(db);\n\n    /* If collation sequence pColl was created directly by a call to\n    ** sqlite3_create_collation, and not generated by synthCollSeq(),\n    ** then any copies made by synthCollSeq() need to be invalidated.\n    ** Also, collation destructor - CollSeq.xDel() - function may need\n    ** to be called.\n    */ \n    if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){\n      CollSeq *aColl = sqlite3HashFind(&db->aCollSeq, zName, nName);\n      int j;\n      for(j=0; j<3; j++){\n        CollSeq *p = &aColl[j];\n        if( p->enc==pColl->enc ){\n          if( p->xDel ){\n            p->xDel(p->pUser);\n          }\n          p->xCmp = 0;\n        }\n      }\n    }\n  }\n\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1);\n  if( pColl==0 ) return SQLITE_NOMEM;\n  pColl->xCmp = xCompare;\n  pColl->pUser = pCtx;\n  pColl->xDel = xDel;\n  pColl->enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED));\n  sqlite3Error(db, SQLITE_OK, 0);\n  return SQLITE_OK;\n}\n\n\n/*\n** This array defines hard upper bounds on limit values.  The\n** initializer must be kept in sync with the SQLITE_LIMIT_*\n** #defines in sqlite3.h.\n*/\nstatic const int aHardLimit[] = {\n  SQLITE_MAX_LENGTH,\n  SQLITE_MAX_SQL_LENGTH,\n  SQLITE_MAX_COLUMN,\n  SQLITE_MAX_EXPR_DEPTH,\n  SQLITE_MAX_COMPOUND_SELECT,\n  SQLITE_MAX_VDBE_OP,\n  SQLITE_MAX_FUNCTION_ARG,\n  SQLITE_MAX_ATTACHED,\n  SQLITE_MAX_LIKE_PATTERN_LENGTH,\n  SQLITE_MAX_VARIABLE_NUMBER,\n  SQLITE_MAX_TRIGGER_DEPTH,\n};\n\n/*\n** Make sure the hard limits are set to reasonable values\n*/\n#if SQLITE_MAX_LENGTH<100\n# error SQLITE_MAX_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH<100\n# error SQLITE_MAX_SQL_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH\n# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH\n#endif\n#if SQLITE_MAX_COMPOUND_SELECT<2\n# error SQLITE_MAX_COMPOUND_SELECT must be at least 2\n#endif\n#if SQLITE_MAX_VDBE_OP<40\n# error SQLITE_MAX_VDBE_OP must be at least 40\n#endif\n#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000\n# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000\n#endif\n#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62\n# error SQLITE_MAX_ATTACHED must be between 0 and 62\n#endif\n#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1\n# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1\n#endif\n#if SQLITE_MAX_COLUMN>32767\n# error SQLITE_MAX_COLUMN must not exceed 32767\n#endif\n#if SQLITE_MAX_TRIGGER_DEPTH<1\n# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1\n#endif\n\n\n/*\n** Change the value of a limit.  Report the old value.\n** If an invalid limit index is supplied, report -1.\n** Make no changes but still report the old value if the\n** new limit is negative.\n**\n** A new lower limit does not shrink existing constructs.\n** It merely prevents new constructs that exceed the limit\n** from forming.\n*/\nSQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){\n  int oldLimit;\n\n\n  /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME\n  ** there is a hard upper bound set at compile-time by a C preprocessor\n  ** macro called SQLITE_MAX_NAME. (The \"_LIMIT_\" in the name is changed to\n  ** \"_MAX_\".)\n  */\n  assert( aHardLimit[SQLITE_LIMIT_LENGTH]==SQLITE_MAX_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH]==SQLITE_MAX_SQL_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_COLUMN]==SQLITE_MAX_COLUMN );\n  assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH]==SQLITE_MAX_EXPR_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT]==SQLITE_MAX_COMPOUND_SELECT);\n  assert( aHardLimit[SQLITE_LIMIT_VDBE_OP]==SQLITE_MAX_VDBE_OP );\n  assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG]==SQLITE_MAX_FUNCTION_ARG );\n  assert( aHardLimit[SQLITE_LIMIT_ATTACHED]==SQLITE_MAX_ATTACHED );\n  assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]==\n                                               SQLITE_MAX_LIKE_PATTERN_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER]==SQLITE_MAX_VARIABLE_NUMBER);\n  assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH]==SQLITE_MAX_TRIGGER_DEPTH );\n  assert( SQLITE_LIMIT_TRIGGER_DEPTH==(SQLITE_N_LIMIT-1) );\n\n\n  if( limitId<0 || limitId>=SQLITE_N_LIMIT ){\n    return -1;\n  }\n  oldLimit = db->aLimit[limitId];\n  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */\n    if( newLimit>aHardLimit[limitId] ){\n      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */\n    }\n    db->aLimit[limitId] = newLimit;\n  }\n  return oldLimit;                     /* IMP: R-53341-35419 */\n}\n\n/*\n** This function is used to parse both URIs and non-URI filenames passed by the\n** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database\n** URIs specified as part of ATTACH statements.\n**\n** The first argument to this function is the name of the VFS to use (or\n** a NULL to signify the default VFS) if the URI does not contain a \"vfs=xxx\"\n** query parameter. The second argument contains the URI (or non-URI filename)\n** itself. When this function is called the *pFlags variable should contain\n** the default flags to open the database handle with. The value stored in\n** *pFlags may be updated before returning if the URI filename contains \n** \"cache=xxx\" or \"mode=xxx\" query parameters.\n**\n** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to\n** the VFS that should be used to open the database file. *pzFile is set to\n** point to a buffer containing the name of the file to open. It is the \n** responsibility of the caller to eventually call sqlite3_free() to release\n** this buffer.\n**\n** If an error occurs, then an SQLite error code is returned and *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to eventually release\n** this buffer by calling sqlite3_free().\n*/\nSQLITE_PRIVATE int sqlite3ParseUri(\n  const char *zDefaultVfs,        /* VFS to use if no \"vfs=xxx\" query option */\n  const char *zUri,               /* Nul-terminated URI to parse */\n  unsigned int *pFlags,           /* IN/OUT: SQLITE_OPEN_XXX flags */\n  sqlite3_vfs **ppVfs,            /* OUT: VFS to use */ \n  char **pzFile,                  /* OUT: Filename component of URI */\n  char **pzErrMsg                 /* OUT: Error message (if rc!=SQLITE_OK) */\n){\n  int rc = SQLITE_OK;\n  unsigned int flags = *pFlags;\n  const char *zVfs = zDefaultVfs;\n  char *zFile;\n  char c;\n  int nUri = sqlite3Strlen30(zUri);\n\n  assert( *pzErrMsg==0 );\n\n  if( ((flags & SQLITE_OPEN_URI) || sqlite3GlobalConfig.bOpenUri) \n   && nUri>=5 && memcmp(zUri, \"file:\", 5)==0 \n  ){\n    char *zOpt;\n    int eState;                   /* Parser state when parsing URI */\n    int iIn;                      /* Input character index */\n    int iOut = 0;                 /* Output character index */\n    int nByte = nUri+2;           /* Bytes of space to allocate */\n\n    /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen \n    ** method that there may be extra parameters following the file-name.  */\n    flags |= SQLITE_OPEN_URI;\n\n    for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');\n    zFile = sqlite3_malloc(nByte);\n    if( !zFile ) return SQLITE_NOMEM;\n\n    /* Discard the scheme and authority segments of the URI. */\n    if( zUri[5]=='/' && zUri[6]=='/' ){\n      iIn = 7;\n      while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;\n\n      if( iIn!=7 && (iIn!=16 || memcmp(\"localhost\", &zUri[7], 9)) ){\n        *pzErrMsg = sqlite3_mprintf(\"invalid uri authority: %.*s\", \n            iIn-7, &zUri[7]);\n        rc = SQLITE_ERROR;\n        goto parse_uri_out;\n      }\n    }else{\n      iIn = 5;\n    }\n\n    /* Copy the filename and any query parameters into the zFile buffer. \n    ** Decode %HH escape codes along the way. \n    **\n    ** Within this loop, variable eState may be set to 0, 1 or 2, depending\n    ** on the parsing context. As follows:\n    **\n    **   0: Parsing file-name.\n    **   1: Parsing name section of a name=value query parameter.\n    **   2: Parsing value section of a name=value query parameter.\n    */\n    eState = 0;\n    while( (c = zUri[iIn])!=0 && c!='#' ){\n      iIn++;\n      if( c=='%' \n       && sqlite3Isxdigit(zUri[iIn]) \n       && sqlite3Isxdigit(zUri[iIn+1]) \n      ){\n        int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);\n        octet += sqlite3HexToInt(zUri[iIn++]);\n\n        assert( octet>=0 && octet<256 );\n        if( octet==0 ){\n          /* This branch is taken when \"%00\" appears within the URI. In this\n          ** case we ignore all text in the remainder of the path, name or\n          ** value currently being parsed. So ignore the current character\n          ** and skip to the next \"?\", \"=\" or \"&\", as appropriate. */\n          while( (c = zUri[iIn])!=0 && c!='#' \n              && (eState!=0 || c!='?')\n              && (eState!=1 || (c!='=' && c!='&'))\n              && (eState!=2 || c!='&')\n          ){\n            iIn++;\n          }\n          continue;\n        }\n        c = octet;\n      }else if( eState==1 && (c=='&' || c=='=') ){\n        if( zFile[iOut-1]==0 ){\n          /* An empty option name. Ignore this option altogether. */\n          while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++;\n          continue;\n        }\n        if( c=='&' ){\n          zFile[iOut++] = '\\0';\n        }else{\n          eState = 2;\n        }\n        c = 0;\n      }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){\n        c = 0;\n        eState = 1;\n      }\n      zFile[iOut++] = c;\n    }\n    if( eState==1 ) zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n\n    /* Check if there were any options specified that should be interpreted \n    ** here. Options that are interpreted here include \"vfs\" and those that\n    ** correspond to flags that may be passed to the sqlite3_open_v2()\n    ** method. */\n    zOpt = &zFile[sqlite3Strlen30(zFile)+1];\n    while( zOpt[0] ){\n      int nOpt = sqlite3Strlen30(zOpt);\n      char *zVal = &zOpt[nOpt+1];\n      int nVal = sqlite3Strlen30(zVal);\n\n      if( nOpt==3 && memcmp(\"vfs\", zOpt, 3)==0 ){\n        zVfs = zVal;\n      }else{\n        struct OpenMode {\n          const char *z;\n          int mode;\n        } *aMode = 0;\n        char *zModeType = 0;\n        int mask = 0;\n        int limit = 0;\n\n        if( nOpt==5 && memcmp(\"cache\", zOpt, 5)==0 ){\n          static struct OpenMode aCacheMode[] = {\n            { \"shared\",  SQLITE_OPEN_SHAREDCACHE },\n            { \"private\", SQLITE_OPEN_PRIVATECACHE },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE;\n          aMode = aCacheMode;\n          limit = mask;\n          zModeType = \"cache\";\n        }\n        if( nOpt==4 && memcmp(\"mode\", zOpt, 4)==0 ){\n          static struct OpenMode aOpenMode[] = {\n            { \"ro\",  SQLITE_OPEN_READONLY },\n            { \"rw\",  SQLITE_OPEN_READWRITE }, \n            { \"rwc\", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE },\n            { \"memory\", SQLITE_OPEN_MEMORY },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE\n                   | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY;\n          aMode = aOpenMode;\n          limit = mask & flags;\n          zModeType = \"access\";\n        }\n\n        if( aMode ){\n          int i;\n          int mode = 0;\n          for(i=0; aMode[i].z; i++){\n            const char *z = aMode[i].z;\n            if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){\n              mode = aMode[i].mode;\n              break;\n            }\n          }\n          if( mode==0 ){\n            *pzErrMsg = sqlite3_mprintf(\"no such %s mode: %s\", zModeType, zVal);\n            rc = SQLITE_ERROR;\n            goto parse_uri_out;\n          }\n          if( (mode & ~SQLITE_OPEN_MEMORY)>limit ){\n            *pzErrMsg = sqlite3_mprintf(\"%s mode not allowed: %s\",\n                                        zModeType, zVal);\n            rc = SQLITE_PERM;\n            goto parse_uri_out;\n          }\n          flags = (flags & ~mask) | mode;\n        }\n      }\n\n      zOpt = &zVal[nVal+1];\n    }\n\n  }else{\n    zFile = sqlite3_malloc(nUri+2);\n    if( !zFile ) return SQLITE_NOMEM;\n    memcpy(zFile, zUri, nUri);\n    zFile[nUri] = '\\0';\n    zFile[nUri+1] = '\\0';\n    flags &= ~SQLITE_OPEN_URI;\n  }\n\n  *ppVfs = sqlite3_vfs_find(zVfs);\n  if( *ppVfs==0 ){\n    *pzErrMsg = sqlite3_mprintf(\"no such vfs: %s\", zVfs);\n    rc = SQLITE_ERROR;\n  }\n parse_uri_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zFile);\n    zFile = 0;\n  }\n  *pFlags = flags;\n  *pzFile = zFile;\n  return rc;\n}\n\n\n/*\n** This routine does the work of opening a database on behalf of\n** sqlite3_open() and sqlite3_open16(). The database filename \"zFilename\"  \n** is UTF-8 encoded.\n*/\nstatic int openDatabase(\n  const char *zFilename, /* Database filename UTF-8 encoded */\n  sqlite3 **ppDb,        /* OUT: Returned database handle */\n  unsigned int flags,    /* Operational flags */\n  const char *zVfs       /* Name of the VFS to use */\n){\n  sqlite3 *db;                    /* Store allocated handle here */\n  int rc;                         /* Return code */\n  int isThreadsafe;               /* True for threadsafe connections */\n  char *zOpen = 0;                /* Filename argument to pass to BtreeOpen() */\n  char *zErrMsg = 0;              /* Error message from sqlite3ParseUri() */\n\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n\n  /* Only allow sensible combinations of bits in the flags argument.  \n  ** Throw an error if any non-sense combination is used.  If we\n  ** do not block illegal combinations here, it could trigger\n  ** assert() statements in deeper layers.  Sensible combinations\n  ** are:\n  **\n  **  1:  SQLITE_OPEN_READONLY\n  **  2:  SQLITE_OPEN_READWRITE\n  **  6:  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE\n  */\n  assert( SQLITE_OPEN_READONLY  == 0x01 );\n  assert( SQLITE_OPEN_READWRITE == 0x02 );\n  assert( SQLITE_OPEN_CREATE    == 0x04 );\n  testcase( (1<<(flags&7))==0x02 ); /* READONLY */\n  testcase( (1<<(flags&7))==0x04 ); /* READWRITE */\n  testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */\n  if( ((1<<(flags&7)) & 0x46)==0 ) return SQLITE_MISUSE_BKPT;\n\n  if( sqlite3GlobalConfig.bCoreMutex==0 ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_NOMUTEX ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_FULLMUTEX ){\n    isThreadsafe = 1;\n  }else{\n    isThreadsafe = sqlite3GlobalConfig.bFullMutex;\n  }\n  if( flags & SQLITE_OPEN_PRIVATECACHE ){\n    flags &= ~SQLITE_OPEN_SHAREDCACHE;\n  }else if( sqlite3GlobalConfig.sharedCacheEnabled ){\n    flags |= SQLITE_OPEN_SHAREDCACHE;\n  }\n\n  /* Remove harmful bits from the flags parameter\n  **\n  ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were\n  ** dealt with in the previous code block.  Besides these, the only\n  ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,\n  ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,\n  ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits.  Silently mask\n  ** off all other flags.\n  */\n  flags &=  ~( SQLITE_OPEN_DELETEONCLOSE |\n               SQLITE_OPEN_EXCLUSIVE |\n               SQLITE_OPEN_MAIN_DB |\n               SQLITE_OPEN_TEMP_DB | \n               SQLITE_OPEN_TRANSIENT_DB | \n               SQLITE_OPEN_MAIN_JOURNAL | \n               SQLITE_OPEN_TEMP_JOURNAL | \n               SQLITE_OPEN_SUBJOURNAL | \n               SQLITE_OPEN_MASTER_JOURNAL |\n               SQLITE_OPEN_NOMUTEX |\n               SQLITE_OPEN_FULLMUTEX |\n               SQLITE_OPEN_WAL\n             );\n\n  /* Allocate the sqlite data structure */\n  db = sqlite3MallocZero( sizeof(sqlite3) );\n  if( db==0 ) goto opendb_out;\n  if( isThreadsafe ){\n    db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n    if( db->mutex==0 ){\n      sqlite3_free(db);\n      db = 0;\n      goto opendb_out;\n    }\n  }\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = 0xff;\n  db->nDb = 2;\n  db->magic = SQLITE_MAGIC_BUSY;\n  db->aDb = db->aDbStatic;\n\n  assert( sizeof(db->aLimit)==sizeof(aHardLimit) );\n  memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));\n  db->autoCommit = 1;\n  db->nextAutovac = -1;\n  db->szMmap = sqlite3GlobalConfig.szMmap;\n  db->nextPagesize = 0;\n  db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger\n#if SQLITE_DEFAULT_FILE_FORMAT<4\n                 | SQLITE_LegacyFileFmt\n#endif\n#ifdef SQLITE_ENABLE_LOAD_EXTENSION\n                 | SQLITE_LoadExtension\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n                 | SQLITE_RecTriggers\n#endif\n#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS\n                 | SQLITE_ForeignKeys\n#endif\n      ;\n  sqlite3HashInit(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3HashInit(&db->aModule);\n#endif\n\n  /* Add the default collation sequence BINARY. BINARY works for both UTF-8\n  ** and UTF-16, so add a version for each to avoid any unnecessary\n  ** conversions. The only error that can occur here is a malloc() failure.\n  */\n  createCollation(db, \"BINARY\", SQLITE_UTF8, 0, binCollFunc, 0);\n  createCollation(db, \"BINARY\", SQLITE_UTF16BE, 0, binCollFunc, 0);\n  createCollation(db, \"BINARY\", SQLITE_UTF16LE, 0, binCollFunc, 0);\n  createCollation(db, \"RTRIM\", SQLITE_UTF8, (void*)1, binCollFunc, 0);\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, \"BINARY\", 0);\n  assert( db->pDfltColl!=0 );\n\n  /* Also add a UTF-8 case-insensitive collation sequence. */\n  createCollation(db, \"NOCASE\", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);\n\n  /* Parse the filename/URI argument. */\n  db->openFlags = flags;\n  rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;\n    sqlite3Error(db, rc, zErrMsg ? \"%s\" : 0, zErrMsg);\n    sqlite3_free(zErrMsg);\n    goto opendb_out;\n  }\n\n  /* Open the backend database driver */\n  rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,\n                        flags | SQLITE_OPEN_MAIN_DB);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM;\n    }\n    sqlite3Error(db, rc, 0);\n    goto opendb_out;\n  }\n  db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);\n  db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);\n\n\n  /* The default safety_level for the main database is 'full'; for the temp\n  ** database it is 'NONE'. This matches the pager layer defaults.  \n  */\n  db->aDb[0].zName = \"main\";\n  db->aDb[0].safety_level = 3;\n  db->aDb[1].zName = \"temp\";\n  db->aDb[1].safety_level = 1;\n\n  db->magic = SQLITE_MAGIC_OPEN;\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n\n  /* Register all built-in functions, but do not attempt to read the\n  ** database schema yet. This is delayed until the first time the database\n  ** is accessed.\n  */\n  sqlite3Error(db, SQLITE_OK, 0);\n  sqlite3RegisterBuiltinFunctions(db);\n\n  /* Load automatic extensions - extensions that have been registered\n  ** using the sqlite3_automatic_extension() API.\n  */\n  rc = sqlite3_errcode(db);\n  if( rc==SQLITE_OK ){\n    sqlite3AutoLoadExtensions(db);\n    rc = sqlite3_errcode(db);\n    if( rc!=SQLITE_OK ){\n      goto opendb_out;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_FTS1\n  if( !db->mallocFailed ){\n    extern int sqlite3Fts1Init(sqlite3*);\n    rc = sqlite3Fts1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS2\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    extern int sqlite3Fts2Init(sqlite3*);\n    rc = sqlite3Fts2Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS3\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts3Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3IcuInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3RtreeInit(db);\n  }\n#endif\n\n  sqlite3Error(db, rc, 0);\n\n  /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking\n  ** mode.  -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking\n  ** mode.  Doing nothing at all also makes NORMAL the default.\n  */\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE;\n  sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt),\n                          SQLITE_DEFAULT_LOCKING_MODE);\n#endif\n\n  /* Enable the lookaside-malloc subsystem */\n  setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,\n                        sqlite3GlobalConfig.nLookaside);\n\n  sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);\n\nopendb_out:\n  sqlite3_free(zOpen);\n  if( db ){\n    assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 );\n    sqlite3_mutex_leave(db->mutex);\n  }\n  rc = sqlite3_errcode(db);\n  assert( db!=0 || rc==SQLITE_NOMEM );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_close(db);\n    db = 0;\n  }else if( rc!=SQLITE_OK ){\n    db->magic = SQLITE_MAGIC_SICK;\n  }\n  *ppDb = db;\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Opening a db handle. Fourth parameter is passed 0. */\n    void *pArg = sqlite3GlobalConfig.pSqllogArg;\n    sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);\n  }\n#endif\n  return sqlite3ApiExit(0, rc);\n}\n\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open(\n  const char *zFilename, \n  sqlite3 **ppDb \n){\n  return openDatabase(zFilename, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n}\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n){\n  return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open16(\n  const void *zFilename, \n  sqlite3 **ppDb\n){\n  char const *zFilename8;   /* zFilename encoded in UTF-8 instead of UTF-16 */\n  sqlite3_value *pVal;\n  int rc;\n\n  assert( zFilename );\n  assert( ppDb );\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zFilename8 ){\n    rc = openDatabase(zFilename8, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n    assert( *ppDb || rc==SQLITE_NOMEM );\n    if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){\n      ENC(*ppDb) = SQLITE_UTF16NATIVE;\n    }\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  sqlite3ValueFree(pVal);\n\n  return sqlite3ApiExit(0, rc);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, 0);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3* db, \n  const void *zName,\n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  int rc = SQLITE_OK;\n  char *zName8;\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);\n  if( zName8 ){\n    rc = createCollation(db, zName8, (u8)enc, pCtx, xCompare, 0);\n    sqlite3DbFree(db, zName8);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)\n){\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = xCollNeeded;\n  db->xCollNeeded16 = 0;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)\n){\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = 0;\n  db->xCollNeeded16 = xCollNeeded16;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This function is now an anachronism. It used to be used to recover from a\n** malloc() failure, but SQLite now does this automatically.\n*/\nSQLITE_API int sqlite3_global_recover(void){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Test to see whether or not the database connection is in autocommit\n** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on\n** by default.  Autocommit is disabled by a BEGIN statement and reenabled\n** by the next COMMIT or ROLLBACK.\n**\n******* THIS IS AN EXPERIMENTAL API AND IS SUBJECT TO CHANGE ******\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3 *db){\n  return db->autoCommit;\n}\n\n/*\n** The following routines are subtitutes for constants SQLITE_CORRUPT,\n** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error\n** constants.  They server two purposes:\n**\n**   1.  Serve as a convenient place to set a breakpoint in a debugger\n**       to detect when version error conditions occurs.\n**\n**   2.  Invoke sqlite3_log() to provide the source code location where\n**       a low-level error is first detected.\n*/\nSQLITE_PRIVATE int sqlite3CorruptError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(SQLITE_CORRUPT,\n              \"database corruption at line %d of [%.10s]\",\n              lineno, 20+sqlite3_sourceid());\n  return SQLITE_CORRUPT;\n}\nSQLITE_PRIVATE int sqlite3MisuseError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(SQLITE_MISUSE, \n              \"misuse at line %d of [%.10s]\",\n              lineno, 20+sqlite3_sourceid());\n  return SQLITE_MISUSE;\n}\nSQLITE_PRIVATE int sqlite3CantopenError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(SQLITE_CANTOPEN, \n              \"cannot open file at line %d of [%.10s]\",\n              lineno, 20+sqlite3_sourceid());\n  return SQLITE_CANTOPEN;\n}\n\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This is a convenience routine that makes sure that all thread-specific\n** data for this thread has been deallocated.\n**\n** SQLite no longer uses thread-specific data so this routine is now a\n** no-op.  It is retained for historical compatibility.\n*/\nSQLITE_API void sqlite3_thread_cleanup(void){\n}\n#endif\n\n/*\n** Return meta information about a specific column of a database table.\n** See comment in sqlite3.h (sqlite.h.in) for details.\n*/\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n){\n  int rc;\n  char *zErrMsg = 0;\n  Table *pTab = 0;\n  Column *pCol = 0;\n  int iCol;\n\n  char const *zDataType = 0;\n  char const *zCollSeq = 0;\n  int notnull = 0;\n  int primarykey = 0;\n  int autoinc = 0;\n\n  /* Ensure the database schema has been loaded */\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Init(db, &zErrMsg);\n  if( SQLITE_OK!=rc ){\n    goto error_out;\n  }\n\n  /* Locate the table in question */\n  pTab = sqlite3FindTable(db, zTableName, zDbName);\n  if( !pTab || pTab->pSelect ){\n    pTab = 0;\n    goto error_out;\n  }\n\n  /* Find the column for which info is requested */\n  if( sqlite3IsRowid(zColumnName) ){\n    iCol = pTab->iPKey;\n    if( iCol>=0 ){\n      pCol = &pTab->aCol[iCol];\n    }\n  }else{\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      pCol = &pTab->aCol[iCol];\n      if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      pTab = 0;\n      goto error_out;\n    }\n  }\n\n  /* The following block stores the meta information that will be returned\n  ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey\n  ** and autoinc. At this point there are two possibilities:\n  ** \n  **     1. The specified column name was rowid\", \"oid\" or \"_rowid_\" \n  **        and there is no explicitly declared IPK column. \n  **\n  **     2. The table is not a view and the column name identified an \n  **        explicitly declared column. Copy meta information from *pCol.\n  */ \n  if( pCol ){\n    zDataType = pCol->zType;\n    zCollSeq = pCol->zColl;\n    notnull = pCol->notNull!=0;\n    primarykey  = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;\n    autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;\n  }else{\n    zDataType = \"INTEGER\";\n    primarykey = 1;\n  }\n  if( !zCollSeq ){\n    zCollSeq = \"BINARY\";\n  }\n\nerror_out:\n  sqlite3BtreeLeaveAll(db);\n\n  /* Whether the function call succeeded or failed, set the output parameters\n  ** to whatever their local counterparts contain. If an error did occur,\n  ** this has the effect of zeroing all output parameters.\n  */\n  if( pzDataType ) *pzDataType = zDataType;\n  if( pzCollSeq ) *pzCollSeq = zCollSeq;\n  if( pNotNull ) *pNotNull = notnull;\n  if( pPrimaryKey ) *pPrimaryKey = primarykey;\n  if( pAutoinc ) *pAutoinc = autoinc;\n\n  if( SQLITE_OK==rc && !pTab ){\n    sqlite3DbFree(db, zErrMsg);\n    zErrMsg = sqlite3MPrintf(db, \"no such table column: %s.%s\", zTableName,\n        zColumnName);\n    rc = SQLITE_ERROR;\n  }\n  sqlite3Error(db, rc, (zErrMsg?\"%s\":0), zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nSQLITE_API int sqlite3_sleep(int ms){\n  sqlite3_vfs *pVfs;\n  int rc;\n  pVfs = sqlite3_vfs_find(0);\n  if( pVfs==0 ) return 0;\n\n  /* This function works in milliseconds, but the underlying OsSleep() \n  ** API uses microseconds. Hence the 1000's.\n  */\n  rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);\n  return rc;\n}\n\n/*\n** Enable or disable the extended result codes.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = onoff ? 0xffffffff : 0xff;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xFileControl method on a particular database.\n*/\nSQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){\n  int rc = SQLITE_ERROR;\n  Btree *pBtree;\n\n  sqlite3_mutex_enter(db->mutex);\n  pBtree = sqlite3DbNameToBtree(db, zDbName);\n  if( pBtree ){\n    Pager *pPager;\n    sqlite3_file *fd;\n    sqlite3BtreeEnter(pBtree);\n    pPager = sqlite3BtreePager(pBtree);\n    assert( pPager!=0 );\n    fd = sqlite3PagerFile(pPager);\n    assert( fd!=0 );\n    if( op==SQLITE_FCNTL_FILE_POINTER ){\n      *(sqlite3_file**)pArg = fd;\n      rc = SQLITE_OK;\n    }else if( fd->pMethods ){\n      rc = sqlite3OsFileControl(fd, op, pArg);\n    }else{\n      rc = SQLITE_NOTFOUND;\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;   \n}\n\n/*\n** Interface to the testing logic.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...){\n  int rc = 0;\n#ifndef SQLITE_OMIT_BUILTIN_TEST\n  va_list ap;\n  va_start(ap, op);\n  switch( op ){\n\n    /*\n    ** Save the current state of the PRNG.\n    */\n    case SQLITE_TESTCTRL_PRNG_SAVE: {\n      sqlite3PrngSaveState();\n      break;\n    }\n\n    /*\n    ** Restore the state of the PRNG to the last state saved using\n    ** PRNG_SAVE.  If PRNG_SAVE has never before been called, then\n    ** this verb acts like PRNG_RESET.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESTORE: {\n      sqlite3PrngRestoreState();\n      break;\n    }\n\n    /*\n    ** Reset the PRNG back to its uninitialized state.  The next call\n    ** to sqlite3_randomness() will reseed the PRNG using a single call\n    ** to the xRandomness method of the default VFS.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESET: {\n      sqlite3PrngResetState();\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BITVEC_TEST, size, program)\n    **\n    ** Run a test against a Bitvec object of size.  The program argument\n    ** is an array of integers that defines the test.  Return -1 on a\n    ** memory allocation error, 0 on success, or non-zero for an error.\n    ** See the sqlite3BitvecBuiltinTest() for additional information.\n    */\n    case SQLITE_TESTCTRL_BITVEC_TEST: {\n      int sz = va_arg(ap, int);\n      int *aProg = va_arg(ap, int*);\n      rc = sqlite3BitvecBuiltinTest(sz, aProg);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)\n    **\n    ** Register hooks to call to indicate which malloc() failures \n    ** are benign.\n    */\n    case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: {\n      typedef void (*void_function)(void);\n      void_function xBenignBegin;\n      void_function xBenignEnd;\n      xBenignBegin = va_arg(ap, void_function);\n      xBenignEnd = va_arg(ap, void_function);\n      sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X)\n    **\n    ** Set the PENDING byte to the value in the argument, if X>0.\n    ** Make no changes if X==0.  Return the value of the pending byte\n    ** as it existing before this routine was called.\n    **\n    ** IMPORTANT:  Changing the PENDING byte from 0x40000000 results in\n    ** an incompatible database file format.  Changing the PENDING byte\n    ** while any database connection is open results in undefined and\n    ** dileterious behavior.\n    */\n    case SQLITE_TESTCTRL_PENDING_BYTE: {\n      rc = PENDING_BYTE;\n#ifndef SQLITE_OMIT_WSD\n      {\n        unsigned int newVal = va_arg(ap, unsigned int);\n        if( newVal ) sqlite3PendingByte = newVal;\n      }\n#endif\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X)\n    **\n    ** This action provides a run-time test to see whether or not\n    ** assert() was enabled at compile-time.  If X is true and assert()\n    ** is enabled, then the return value is true.  If X is true and\n    ** assert() is disabled, then the return value is zero.  If X is\n    ** false and assert() is enabled, then the assertion fires and the\n    ** process aborts.  If X is false and assert() is disabled, then the\n    ** return value is zero.\n    */\n    case SQLITE_TESTCTRL_ASSERT: {\n      volatile int x = 0;\n      assert( (x = va_arg(ap,int))!=0 );\n      rc = x;\n      break;\n    }\n\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X)\n    **\n    ** This action provides a run-time test to see how the ALWAYS and\n    ** NEVER macros were defined at compile-time.\n    **\n    ** The return value is ALWAYS(X).  \n    **\n    ** The recommended test is X==2.  If the return value is 2, that means\n    ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the\n    ** default setting.  If the return value is 1, then ALWAYS() is either\n    ** hard-coded to true or else it asserts if its argument is false.\n    ** The first behavior (hard-coded to true) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second\n    ** behavior (assert if the argument to ALWAYS() is false) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled.\n    **\n    ** The run-time test procedure might look something like this:\n    **\n    **    if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){\n    **      // ALWAYS() and NEVER() are no-op pass-through macros\n    **    }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){\n    **      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.\n    **    }else{\n    **      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.\n    **    }\n    */\n    case SQLITE_TESTCTRL_ALWAYS: {\n      int x = va_arg(ap,int);\n      rc = ALWAYS(x);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)\n    **\n    ** Set the nReserve size to N for the main database on the database\n    ** connection db.\n    */\n    case SQLITE_TESTCTRL_RESERVE: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      int x = va_arg(ap,int);\n      sqlite3_mutex_enter(db->mutex);\n      sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)\n    **\n    ** Enable or disable various optimizations for testing purposes.  The \n    ** argument N is a bitmask of optimizations to be disabled.  For normal\n    ** operation N should be 0.  The idea is that a test program (like the\n    ** SQL Logic Test or SLT test module) can run the same SQL multiple times\n    ** with various optimizations disabled to verify that the same answer\n    ** is obtained in every case.\n    */\n    case SQLITE_TESTCTRL_OPTIMIZATIONS: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);\n      break;\n    }\n\n#ifdef SQLITE_N_KEYWORD\n    /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)\n    **\n    ** If zWord is a keyword recognized by the parser, then return the\n    ** number of keywords.  Or if zWord is not a keyword, return 0.\n    ** \n    ** This test feature is only available in the amalgamation since\n    ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite\n    ** is built using separate source files.\n    */\n    case SQLITE_TESTCTRL_ISKEYWORD: {\n      const char *zWord = va_arg(ap, const char*);\n      int n = sqlite3Strlen30(zWord);\n      rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;\n      break;\n    }\n#endif \n\n    /* sqlite3_test_control(SQLITE_TESTCTRL_SCRATCHMALLOC, sz, &pNew, pFree);\n    **\n    ** Pass pFree into sqlite3ScratchFree(). \n    ** If sz>0 then allocate a scratch buffer into pNew.  \n    */\n    case SQLITE_TESTCTRL_SCRATCHMALLOC: {\n      void *pFree, **ppNew;\n      int sz;\n      sz = va_arg(ap, int);\n      ppNew = va_arg(ap, void**);\n      pFree = va_arg(ap, void*);\n      if( sz ) *ppNew = sqlite3ScratchMalloc(sz);\n      sqlite3ScratchFree(pFree);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);\n    **\n    ** If parameter onoff is non-zero, configure the wrappers so that all\n    ** subsequent calls to localtime() and variants fail. If onoff is zero,\n    ** undo this setting.\n    */\n    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {\n      sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);\n      break;\n    }\n\n#if defined(SQLITE_ENABLE_TREE_EXPLAIN)\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT,\n    **                        sqlite3_stmt*,const char**);\n    **\n    ** If compiled with SQLITE_ENABLE_TREE_EXPLAIN, each sqlite3_stmt holds\n    ** a string that describes the optimized parse tree.  This test-control\n    ** returns a pointer to that string.\n    */\n    case SQLITE_TESTCTRL_EXPLAIN_STMT: {\n      sqlite3_stmt *pStmt = va_arg(ap, sqlite3_stmt*);\n      const char **pzRet = va_arg(ap, const char**);\n      *pzRet = sqlite3VdbeExplanation((Vdbe*)pStmt);\n      break;\n    }\n#endif\n\n  }\n  va_end(ap);\n#endif /* SQLITE_OMIT_BUILTIN_TEST */\n  return rc;\n}\n\n/*\n** This is a utility routine, useful to VFS implementations, that checks\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of the query parameter.\n**\n** The zFilename argument is the filename pointer passed into the xOpen()\n** method of a VFS implementation.  The zParam argument is the name of the\n** query parameter we seek.  This routine returns the value of the zParam\n** parameter if it exists.  If the parameter does not exist, this routine\n** returns a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){\n  if( zFilename==0 ) return 0;\n  zFilename += sqlite3Strlen30(zFilename) + 1;\n  while( zFilename[0] ){\n    int x = strcmp(zFilename, zParam);\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n    if( x==0 ) return zFilename;\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n  }\n  return 0;\n}\n\n/*\n** Return a boolean value for a query parameter.\n*/\nSQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  bDflt = bDflt!=0;\n  return z ? sqlite3GetBoolean(z, bDflt) : bDflt;\n}\n\n/*\n** Return a 64-bit integer value for a query parameter.\n*/\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(\n  const char *zFilename,    /* Filename as passed to xOpen */\n  const char *zParam,       /* URI parameter sought */\n  sqlite3_int64 bDflt       /* return if parameter is missing */\n){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  sqlite3_int64 v;\n  if( z && sqlite3Atoi64(z, &v, sqlite3Strlen30(z), SQLITE_UTF8)==SQLITE_OK ){\n    bDflt = v;\n  }\n  return bDflt;\n}\n\n/*\n** Return the Btree pointer identified by zDbName.  Return NULL if not found.\n*/\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){\n  int i;\n  for(i=0; i<db->nDb; i++){\n    if( db->aDb[i].pBt\n     && (zDbName==0 || sqlite3StrICmp(zDbName, db->aDb[i].zName)==0)\n    ){\n      return db->aDb[i].pBt;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return the filename of the database associated with a database\n** connection.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){\n  Btree *pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeGetFilename(pBt) : 0;\n}\n\n/*\n** Return 1 if database is read-only or 0 if read/write.  Return -1 if\n** no such database exists.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){\n  Btree *pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3PagerIsreadonly(sqlite3BtreePager(pBt)) : -1;\n}\n\n/************** End of main.c ************************************************/\n/************** Begin file notify.c ******************************************/\n/*\n** 2009 March 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of the sqlite3_unlock_notify()\n** API method and its associated functionality.\n*/\n\n/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n\n/*\n** Public interfaces:\n**\n**   sqlite3ConnectionBlocked()\n**   sqlite3ConnectionUnlocked()\n**   sqlite3ConnectionClosed()\n**   sqlite3_unlock_notify()\n*/\n\n#define assertMutexHeld() \\\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) )\n\n/*\n** Head of a linked list of all sqlite3 objects created by this process\n** for which either sqlite3.pBlockingConnection or sqlite3.pUnlockConnection\n** is not NULL. This variable may only accessed while the STATIC_MASTER\n** mutex is held.\n*/\nstatic sqlite3 *SQLITE_WSD sqlite3BlockedList = 0;\n\n#ifndef NDEBUG\n/*\n** This function is a complex assert() that verifies the following \n** properties of the blocked connections list:\n**\n**   1) Each entry in the list has a non-NULL value for either \n**      pUnlockConnection or pBlockingConnection, or both.\n**\n**   2) All entries in the list that share a common value for \n**      xUnlockNotify are grouped together.\n**\n**   3) If the argument db is not NULL, then none of the entries in the\n**      blocked connections list have pUnlockConnection or pBlockingConnection\n**      set to db. This is used when closing connection db.\n*/\nstatic void checkListProperties(sqlite3 *db){\n  sqlite3 *p;\n  for(p=sqlite3BlockedList; p; p=p->pNextBlocked){\n    int seen = 0;\n    sqlite3 *p2;\n\n    /* Verify property (1) */\n    assert( p->pUnlockConnection || p->pBlockingConnection );\n\n    /* Verify property (2) */\n    for(p2=sqlite3BlockedList; p2!=p; p2=p2->pNextBlocked){\n      if( p2->xUnlockNotify==p->xUnlockNotify ) seen = 1;\n      assert( p2->xUnlockNotify==p->xUnlockNotify || !seen );\n      assert( db==0 || p->pUnlockConnection!=db );\n      assert( db==0 || p->pBlockingConnection!=db );\n    }\n  }\n}\n#else\n# define checkListProperties(x)\n#endif\n\n/*\n** Remove connection db from the blocked connections list. If connection\n** db is not currently a part of the list, this function is a no-op.\n*/\nstatic void removeFromBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(pp=&sqlite3BlockedList; *pp; pp = &(*pp)->pNextBlocked){\n    if( *pp==db ){\n      *pp = (*pp)->pNextBlocked;\n      break;\n    }\n  }\n}\n\n/*\n** Add connection db to the blocked connections list. It is assumed\n** that it is not already a part of the list.\n*/\nstatic void addToBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(\n    pp=&sqlite3BlockedList; \n    *pp && (*pp)->xUnlockNotify!=db->xUnlockNotify; \n    pp=&(*pp)->pNextBlocked\n  );\n  db->pNextBlocked = *pp;\n  *pp = db;\n}\n\n/*\n** Obtain the STATIC_MASTER mutex.\n*/\nstatic void enterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  checkListProperties(0);\n}\n\n/*\n** Release the STATIC_MASTER mutex.\n*/\nstatic void leaveMutex(void){\n  assertMutexHeld();\n  checkListProperties(0);\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n\n/*\n** Register an unlock-notify callback.\n**\n** This is called after connection \"db\" has attempted some operation\n** but has received an SQLITE_LOCKED error because another connection\n** (call it pOther) in the same process was busy using the same shared\n** cache.  pOther is found by looking at db->pBlockingConnection.\n**\n** If there is no blocking connection, the callback is invoked immediately,\n** before this routine returns.\n**\n** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate\n** a deadlock.\n**\n** Otherwise, make arrangements to invoke xNotify when pOther drops\n** its locks.\n**\n** Each call to this routine overrides any prior callbacks registered\n** on the same \"db\".  If xNotify==0 then any prior callbacks are immediately\n** cancelled.\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *db,\n  void (*xNotify)(void **, int),\n  void *pArg\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  enterMutex();\n\n  if( xNotify==0 ){\n    removeFromBlockedList(db);\n    db->pBlockingConnection = 0;\n    db->pUnlockConnection = 0;\n    db->xUnlockNotify = 0;\n    db->pUnlockArg = 0;\n  }else if( 0==db->pBlockingConnection ){\n    /* The blocking transaction has been concluded. Or there never was a \n    ** blocking transaction. In either case, invoke the notify callback\n    ** immediately. \n    */\n    xNotify(&pArg, 1);\n  }else{\n    sqlite3 *p;\n\n    for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}\n    if( p ){\n      rc = SQLITE_LOCKED;              /* Deadlock detected. */\n    }else{\n      db->pUnlockConnection = db->pBlockingConnection;\n      db->xUnlockNotify = xNotify;\n      db->pUnlockArg = pArg;\n      removeFromBlockedList(db);\n      addToBlockedList(db);\n    }\n  }\n\n  leaveMutex();\n  assert( !db->mallocFailed );\n  sqlite3Error(db, rc, (rc?\"database is deadlocked\":0));\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is called while stepping or preparing a statement \n** associated with connection db. The operation will return SQLITE_LOCKED\n** to the user because it requires a lock that will not be available\n** until connection pBlocker concludes its current transaction.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *db, sqlite3 *pBlocker){\n  enterMutex();\n  if( db->pBlockingConnection==0 && db->pUnlockConnection==0 ){\n    addToBlockedList(db);\n  }\n  db->pBlockingConnection = pBlocker;\n  leaveMutex();\n}\n\n/*\n** This function is called when\n** the transaction opened by database db has just finished. Locks held \n** by database connection db have been released.\n**\n** This function loops through each entry in the blocked connections\n** list and does the following:\n**\n**   1) If the sqlite3.pBlockingConnection member of a list entry is\n**      set to db, then set pBlockingConnection=0.\n**\n**   2) If the sqlite3.pUnlockConnection member of a list entry is\n**      set to db, then invoke the configured unlock-notify callback and\n**      set pUnlockConnection=0.\n**\n**   3) If the two steps above mean that pBlockingConnection==0 and\n**      pUnlockConnection==0, remove the entry from the blocked connections\n**      list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){\n  void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */\n  int nArg = 0;                            /* Number of entries in aArg[] */\n  sqlite3 **pp;                            /* Iterator variable */\n  void **aArg;               /* Arguments to the unlock callback */\n  void **aDyn = 0;           /* Dynamically allocated space for aArg[] */\n  void *aStatic[16];         /* Starter space for aArg[].  No malloc required */\n\n  aArg = aStatic;\n  enterMutex();         /* Enter STATIC_MASTER mutex */\n\n  /* This loop runs once for each entry in the blocked-connections list. */\n  for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){\n    sqlite3 *p = *pp;\n\n    /* Step 1. */\n    if( p->pBlockingConnection==db ){\n      p->pBlockingConnection = 0;\n    }\n\n    /* Step 2. */\n    if( p->pUnlockConnection==db ){\n      assert( p->xUnlockNotify );\n      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){\n        xUnlockNotify(aArg, nArg);\n        nArg = 0;\n      }\n\n      sqlite3BeginBenignMalloc();\n      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );\n      assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );\n      if( (!aDyn && nArg==(int)ArraySize(aStatic))\n       || (aDyn && nArg==(int)(sqlite3MallocSize(aDyn)/sizeof(void*)))\n      ){\n        /* The aArg[] array needs to grow. */\n        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);\n        if( pNew ){\n          memcpy(pNew, aArg, nArg*sizeof(void *));\n          sqlite3_free(aDyn);\n          aDyn = aArg = pNew;\n        }else{\n          /* This occurs when the array of context pointers that need to\n          ** be passed to the unlock-notify callback is larger than the\n          ** aStatic[] array allocated on the stack and the attempt to \n          ** allocate a larger array from the heap has failed.\n          **\n          ** This is a difficult situation to handle. Returning an error\n          ** code to the caller is insufficient, as even if an error code\n          ** is returned the transaction on connection db will still be\n          ** closed and the unlock-notify callbacks on blocked connections\n          ** will go unissued. This might cause the application to wait\n          ** indefinitely for an unlock-notify callback that will never \n          ** arrive.\n          **\n          ** Instead, invoke the unlock-notify callback with the context\n          ** array already accumulated. We can then clear the array and\n          ** begin accumulating any further context pointers without \n          ** requiring any dynamic allocation. This is sub-optimal because\n          ** it means that instead of one callback with a large array of\n          ** context pointers the application will receive two or more\n          ** callbacks with smaller arrays of context pointers, which will\n          ** reduce the applications ability to prioritize multiple \n          ** connections. But it is the best that can be done under the\n          ** circumstances.\n          */\n          xUnlockNotify(aArg, nArg);\n          nArg = 0;\n        }\n      }\n      sqlite3EndBenignMalloc();\n\n      aArg[nArg++] = p->pUnlockArg;\n      xUnlockNotify = p->xUnlockNotify;\n      p->pUnlockConnection = 0;\n      p->xUnlockNotify = 0;\n      p->pUnlockArg = 0;\n    }\n\n    /* Step 3. */\n    if( p->pBlockingConnection==0 && p->pUnlockConnection==0 ){\n      /* Remove connection p from the blocked connections list. */\n      *pp = p->pNextBlocked;\n      p->pNextBlocked = 0;\n    }else{\n      pp = &p->pNextBlocked;\n    }\n  }\n\n  if( nArg!=0 ){\n    xUnlockNotify(aArg, nArg);\n  }\n  sqlite3_free(aDyn);\n  leaveMutex();         /* Leave STATIC_MASTER mutex */\n}\n\n/*\n** This is called when the database connection passed as an argument is \n** being closed. The connection is removed from the blocked list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){\n  sqlite3ConnectionUnlocked(db);\n  enterMutex();\n  removeFromBlockedList(db);\n  checkListProperties(db);\n  leaveMutex();\n}\n#endif\n\n/************** End of notify.c **********************************************/\n/************** Begin file fts3.c ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n\n/* The full-text index is stored in a series of b+tree (-like)\n** structures called segments which map terms to doclists.  The\n** structures are like b+trees in layout, but are constructed from the\n** bottom up in optimal fashion and are not updatable.  Since trees\n** are built from the bottom up, things will be described from the\n** bottom up.\n**\n**\n**** Varints ****\n** The basic unit of encoding is a variable-length integer called a\n** varint.  We encode variable-length integers in little-endian order\n** using seven bits * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n**\n** This is similar in concept to how sqlite encodes \"varints\" but\n** the encoding is not the same.  SQLite varints are big-endian\n** are are limited to 9 bytes in length whereas FTS3 varints are\n** little-endian and can be up to 10 bytes in length (in theory).\n**\n** Example encodings:\n**\n**     1:    0x01\n**   127:    0x7f\n**   128:    0x81 0x00\n**\n**\n**** Document lists ****\n** A doclist (document list) holds a docid-sorted list of hits for a\n** given term.  Doclists hold docids and associated token positions.\n** A docid is the unique integer identifier for a single document.\n** A position is the index of a word within the document.  The first \n** word of the document has a position of 0.\n**\n** FTS3 used to optionally store character offsets using a compile-time\n** option.  But that functionality is no longer supported.\n**\n** A doclist is stored like this:\n**\n** array {\n**   varint docid;          (delta from previous doclist)\n**   array {                (position list for column 0)\n**     varint position;     (2 more than the delta from previous position)\n**   }\n**   array {\n**     varint POS_COLUMN;   (marks start of position list for new column)\n**     varint column;       (index of new column)\n**     array {\n**       varint position;   (2 more than the delta from previous position)\n**     }\n**   }\n**   varint POS_END;        (marks end of positions for this document.\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.  A \"position\" is an index of a token in the token stream\n** generated by the tokenizer. Note that POS_END and POS_COLUMN occur \n** in the same logical place as the position element, and act as sentinals\n** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.\n** The positions numbers are not stored literally but rather as two more\n** than the difference from the prior position, or the just the position plus\n** 2 for the first position.  Example:\n**\n**   label:       A B C D E  F  G H   I  J K\n**   value:     123 5 9 1 1 14 35 0 234 72 0\n**\n** The 123 value is the first docid.  For column zero in this document\n** there are two matches at positions 3 and 10 (5-2 and 9-2+3).  The 1\n** at D signals the start of a new column; the 1 at E indicates that the\n** new column is column number 1.  There are two positions at 12 and 45\n** (14-2 and 35-2+12).  The 0 at H indicate the end-of-document.  The\n** 234 at I is the delta to next docid (357).  It has one position 70\n** (72-2) and then terminates with the 0 at K.\n**\n** A \"position-list\" is the list of positions for multiple columns for\n** a single docid.  A \"column-list\" is the set of positions for a single\n** column.  Hence, a position-list consists of one or more column-lists,\n** a document record consists of a docid followed by a position-list and\n** a doclist consists of one or more document records.\n**\n** A bare doclist omits the position information, becoming an \n** array of varint-encoded docids.\n**\n**** Segment leaf nodes ****\n** Segment leaf nodes store terms and doclists, ordered by term.  Leaf\n** nodes are written using LeafWriter, and read using LeafReader (to\n** iterate through a single leaf node's data) and LeavesReader (to\n** iterate through a segment's entire leaf layer).  Leaf nodes have\n** the format:\n**\n** varint iHeight;             (height from leaf level, always 0)\n** varint nTerm;               (length of first term)\n** char pTerm[nTerm];          (content of first term)\n** varint nDoclist;            (length of term's associated doclist)\n** char pDoclist[nDoclist];    (content of doclist)\n** array {\n**                             (further terms are delta-encoded)\n**   varint nPrefix;           (length of prefix shared with previous term)\n**   varint nSuffix;           (length of unshared suffix)\n**   char pTermSuffix[nSuffix];(unshared suffix of next term)\n**   varint nDoclist;          (length of term's associated doclist)\n**   char pDoclist[nDoclist];  (content of doclist)\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.\n**\n** Leaf nodes are broken into blocks which are stored contiguously in\n** the %_segments table in sorted order.  This means that when the end\n** of a node is reached, the next term is in the node with the next\n** greater node id.\n**\n** New data is spilled to a new leaf node when the current node\n** exceeds LEAF_MAX bytes (default 2048).  New data which itself is\n** larger than STANDALONE_MIN (default 1024) is placed in a standalone\n** node (a leaf node with a single term and doclist).  The goal of\n** these settings is to pack together groups of small doclists while\n** making it efficient to directly access large doclists.  The\n** assumption is that large doclists represent terms which are more\n** likely to be query targets.\n**\n** TODO(shess) It may be useful for blocking decisions to be more\n** dynamic.  For instance, it may make more sense to have a 2.5k leaf\n** node rather than splitting into 2k and .5k nodes.  My intuition is\n** that this might extend through 2x or 4x the pagesize.\n**\n**\n**** Segment interior nodes ****\n** Segment interior nodes store blockids for subtree nodes and terms\n** to describe what data is stored by the each subtree.  Interior\n** nodes are written using InteriorWriter, and read using\n** InteriorReader.  InteriorWriters are created as needed when\n** SegmentWriter creates new leaf nodes, or when an interior node\n** itself grows too big and must be split.  The format of interior\n** nodes:\n**\n** varint iHeight;           (height from leaf level, always >0)\n** varint iBlockid;          (block id of node's leftmost subtree)\n** optional {\n**   varint nTerm;           (length of first term)\n**   char pTerm[nTerm];      (content of first term)\n**   array {\n**                                (further terms are delta-encoded)\n**     varint nPrefix;            (length of shared prefix with previous term)\n**     varint nSuffix;            (length of unshared suffix)\n**     char pTermSuffix[nSuffix]; (unshared suffix of next term)\n**   }\n** }\n**\n** Here, optional { X } means an optional element, while array { X }\n** means zero or more occurrences of X, adjacent in memory.\n**\n** An interior node encodes n terms separating n+1 subtrees.  The\n** subtree blocks are contiguous, so only the first subtree's blockid\n** is encoded.  The subtree at iBlockid will contain all terms less\n** than the first term encoded (or all terms if no term is encoded).\n** Otherwise, for terms greater than or equal to pTerm[i] but less\n** than pTerm[i+1], the subtree for that term will be rooted at\n** iBlockid+i.  Interior nodes only store enough term data to\n** distinguish adjacent children (if the rightmost term of the left\n** child is \"something\", and the leftmost term of the right child is\n** \"wicked\", only \"w\" is stored).\n**\n** New data is spilled to a new interior node at the same height when\n** the current node exceeds INTERIOR_MAX bytes (default 2048).\n** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing\n** interior nodes and making the tree too skinny.  The interior nodes\n** at a given height are naturally tracked by interior nodes at\n** height+1, and so on.\n**\n**\n**** Segment directory ****\n** The segment directory in table %_segdir stores meta-information for\n** merging and deleting segments, and also the root node of the\n** segment's tree.\n**\n** The root node is the top node of the segment's tree after encoding\n** the entire segment, restricted to ROOT_MAX bytes (default 1024).\n** This could be either a leaf node or an interior node.  If the top\n** node requires more than ROOT_MAX bytes, it is flushed to %_segments\n** and a new root interior node is generated (which should always fit\n** within ROOT_MAX because it only needs space for 2 varints, the\n** height and the blockid of the previous root).\n**\n** The meta-information in the segment directory is:\n**   level               - segment level (see below)\n**   idx                 - index within level\n**                       - (level,idx uniquely identify a segment)\n**   start_block         - first leaf node\n**   leaves_end_block    - last leaf node\n**   end_block           - last block (including interior nodes)\n**   root                - contents of root node\n**\n** If the root node is a leaf node, then start_block,\n** leaves_end_block, and end_block are all 0.\n**\n**\n**** Segment merging ****\n** To amortize update costs, segments are grouped into levels and\n** merged in batches.  Each increase in level represents exponentially\n** more documents.\n**\n** New documents (actually, document updates) are tokenized and\n** written individually (using LeafWriter) to a level 0 segment, with\n** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all\n** level 0 segments are merged into a single level 1 segment.  Level 1\n** is populated like level 0, and eventually MERGE_COUNT level 1\n** segments are merged to a single level 2 segment (representing\n** MERGE_COUNT^2 updates), and so on.\n**\n** A segment merge traverses all segments at a given level in\n** parallel, performing a straightforward sorted merge.  Since segment\n** leaf nodes are written in to the %_segments table in order, this\n** merge traverses the underlying sqlite disk structures efficiently.\n** After the merge, all segment blocks from the merged level are\n** deleted.\n**\n** MERGE_COUNT controls how often we merge segments.  16 seems to be\n** somewhat of a sweet spot for insertion performance.  32 and 64 show\n** very similar performance numbers to 16 on insertion, though they're\n** a tiny bit slower (perhaps due to more overhead in merge-time\n** sorting).  8 is about 20% slower than 16, 4 about 50% slower than\n** 16, 2 about 66% slower than 16.\n**\n** At query time, high MERGE_COUNT increases the number of segments\n** which need to be scanned and merged.  For instance, with 100k docs\n** inserted:\n**\n**    MERGE_COUNT   segments\n**       16           25\n**        8           12\n**        4           10\n**        2            6\n**\n** This appears to have only a moderate impact on queries for very\n** frequent terms (which are somewhat dominated by segment merge\n** costs), and infrequent and non-existent terms still seem to be fast\n** even with many segments.\n**\n** TODO(shess) That said, it would be nice to have a better query-side\n** argument for MERGE_COUNT of 16.  Also, it is possible/likely that\n** optimizations to things like doclist merging will swing the sweet\n** spot around.\n**\n**\n**\n**** Handling of deletions and updates ****\n** Since we're using a segmented structure, with no docid-oriented\n** index into the term index, we clearly cannot simply update the term\n** index when a document is deleted or updated.  For deletions, we\n** write an empty doclist (varint(docid) varint(POS_END)), for updates\n** we simply write the new doclist.  Segment merges overwrite older\n** data for a particular docid with newer data, so deletes or updates\n** will eventually overtake the earlier data and knock it out.  The\n** query logic likewise merges doclists so that newer data knocks out\n** older data.\n*/\n\n/************** Include fts3Int.h in the middle of fts3.c ********************/\n/************** Begin file fts3Int.h *****************************************/\n/*\n** 2009 Nov 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTSINT_H\n#define _FTSINT_H\n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all\n** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3\n#endif\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* If not building as part of the core, include sqlite3ext.h. */\n#ifndef SQLITE_CORE\nSQLITE_API extern const sqlite3_api_routines *sqlite3_api;\n#endif\n\n/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/\n/************** Begin file fts3_tokenizer.h **********************************/\n/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS3_TOKENIZER_H_\n#define _FTS3_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts3 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts3 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0 or 1.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts3 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialized by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts3 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts3 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset. *piStartOffset should be set to the index of the first\n  ** byte of the token in the input buffer. *piEndOffset should be set\n  ** to the index of the first byte just past the end of the token in\n  ** the input buffer.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n\n  /***********************************************************************\n  ** Methods below this point are only available if iVersion>=1.\n  */\n\n  /* \n  ** Configure the language id of a tokenizer cursor.\n  */\n  int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid);\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nint fts3_global_term_cnt(int iTerm, int iCol);\nint fts3_term_cnt(int iTerm, int iCol);\n\n\n#endif /* _FTS3_TOKENIZER_H_ */\n\n/************** End of fts3_tokenizer.h **************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n/************** Include fts3_hash.h in the middle of fts3Int.h ***************/\n/************** Begin file fts3_hash.h ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS3_HASH_H_\n#define _FTS3_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Fts3Hash Fts3Hash;\ntypedef struct Fts3HashElem Fts3HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct Fts3Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  Fts3HashElem *first;    /* The first element of the array */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts3ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    Fts3HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct Fts3HashElem {\n  Fts3HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS3_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS3_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts3HashInit is 1.  \n*/\n#define FTS3_HASH_STRING    1\n#define FTS3_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts3HashInit     sqlite3Fts3HashInit\n#define fts3HashInsert   sqlite3Fts3HashInsert\n#define fts3HashFind     sqlite3Fts3HashFind\n#define fts3HashClear    sqlite3Fts3HashClear\n#define fts3HashFindElem sqlite3Fts3HashFindElem\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Fts3Hash h;\n**   Fts3HashElem *p;\n**   ...\n**   for(p=fts3HashFirst(&h); p; p=fts3HashNext(p)){\n**     SomeStructure *pData = fts3HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts3HashFirst(H)  ((H)->first)\n#define fts3HashNext(E)   ((E)->next)\n#define fts3HashData(E)   ((E)->data)\n#define fts3HashKey(E)    ((E)->pKey)\n#define fts3HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts3HashCount(H)  ((H)->count)\n\n#endif /* _FTS3_HASH_H_ */\n\n/************** End of fts3_hash.h *******************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n\n/*\n** This constant controls how often segments are merged. Once there are\n** FTS3_MERGE_COUNT segments of level N, they are merged into a single\n** segment of level N+1.\n*/\n#define FTS3_MERGE_COUNT 16\n\n/*\n** This is the maximum amount of data (in bytes) to store in the \n** Fts3Table.pendingTerms hash table. Normally, the hash table is\n** populated as documents are inserted/updated/deleted in a transaction\n** and used to create a new segment when the transaction is committed.\n** However if this limit is reached midway through a transaction, a new \n** segment is created and the hash table cleared immediately.\n*/\n#define FTS3_MAX_PENDING_DATA (1*1024*1024)\n\n/*\n** Macro to return the number of elements in an array. SQLite has a\n** similar macro called ArraySize(). Use a different name to avoid\n** a collision when building an amalgamation with built-in FTS3.\n*/\n#define SizeofArray(X) ((int)(sizeof(X)/sizeof(X[0])))\n\n\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n#ifndef MAX\n# define MAX(x,y) ((x)>(y)?(x):(y))\n#endif\n\n/*\n** Maximum length of a varint encoded integer. The varint format is different\n** from that used by SQLite, so the maximum length is 10, not 9.\n*/\n#define FTS3_VARINT_MAX 10\n\n/*\n** FTS4 virtual tables may maintain multiple indexes - one index of all terms\n** in the document set and zero or more prefix indexes. All indexes are stored\n** as one or more b+-trees in the %_segments and %_segdir tables. \n**\n** It is possible to determine which index a b+-tree belongs to based on the\n** value stored in the \"%_segdir.level\" column. Given this value L, the index\n** that the b+-tree belongs to is (L<<10). In other words, all b+-trees with\n** level values between 0 and 1023 (inclusive) belong to index 0, all levels\n** between 1024 and 2047 to index 1, and so on.\n**\n** It is considered impossible for an index to use more than 1024 levels. In \n** theory though this may happen, but only after at least \n** (FTS3_MERGE_COUNT^1024) separate flushes of the pending-terms tables.\n*/\n#define FTS3_SEGDIR_MAXLEVEL      1024\n#define FTS3_SEGDIR_MAXLEVEL_STR \"1024\"\n\n/*\n** The testcase() macro is only used by the amalgamation.  If undefined,\n** make it a no-op.\n*/\n#ifndef testcase\n# define testcase(X)\n#endif\n\n/*\n** Terminator values for position-lists and column-lists.\n*/\n#define POS_COLUMN  (1)     /* Column-list terminator */\n#define POS_END     (0)     /* Position-list terminator */ \n\n/*\n** This section provides definitions to allow the\n** FTS3 extension to be compiled outside of the \n** amalgamation.\n*/\n#ifndef SQLITE_AMALGAMATION\n/*\n** Macros indicating that conditional expressions are always true or\n** false.\n*/\n#ifdef SQLITE_COVERAGE_TEST\n# define ALWAYS(x) (1)\n# define NEVER(X)  (0)\n#else\n# define ALWAYS(x) (x)\n# define NEVER(x)  (x)\n#endif\n\n/*\n** Internal types used by SQLite.\n*/\ntypedef unsigned char u8;         /* 1-byte (or larger) unsigned integer */\ntypedef short int i16;            /* 2-byte (or larger) signed integer */\ntypedef unsigned int u32;         /* 4-byte unsigned integer */\ntypedef sqlite3_uint64 u64;       /* 8-byte unsigned integer */\ntypedef sqlite3_int64 i64;        /* 8-byte signed integer */\n\n/*\n** Macro used to suppress compiler warnings for unused parameters.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** Activate assert() only if SQLITE_TEST is enabled.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n#endif /* SQLITE_AMALGAMATION */\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(void);\n# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()\n#else\n# define FTS_CORRUPT_VTAB SQLITE_CORRUPT_VTAB\n#endif\n\ntypedef struct Fts3Table Fts3Table;\ntypedef struct Fts3Cursor Fts3Cursor;\ntypedef struct Fts3Expr Fts3Expr;\ntypedef struct Fts3Phrase Fts3Phrase;\ntypedef struct Fts3PhraseToken Fts3PhraseToken;\n\ntypedef struct Fts3Doclist Fts3Doclist;\ntypedef struct Fts3SegFilter Fts3SegFilter;\ntypedef struct Fts3DeferredToken Fts3DeferredToken;\ntypedef struct Fts3SegReader Fts3SegReader;\ntypedef struct Fts3MultiSegReader Fts3MultiSegReader;\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure. The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct Fts3Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  sqlite3 *db;                    /* The database connection */\n  const char *zDb;                /* logical database name */\n  const char *zName;              /* virtual table name */\n  int nColumn;                    /* number of named columns in virtual table */\n  char **azColumn;                /* column names.  malloced */\n  sqlite3_tokenizer *pTokenizer;  /* tokenizer for inserts and queries */\n  char *zContentTbl;              /* content=xxx option, or NULL */\n  char *zLanguageid;              /* languageid=xxx option, or NULL */\n  u8 bAutoincrmerge;              /* True if automerge=1 */\n  u32 nLeafAdd;                   /* Number of leaf blocks added this trans */\n\n  /* Precompiled statements used by the implementation. Each of these \n  ** statements is run and reset within a single virtual table API call. \n  */\n  sqlite3_stmt *aStmt[37];\n\n  char *zReadExprlist;\n  char *zWriteExprlist;\n\n  int nNodeSize;                  /* Soft limit for node size */\n  u8 bFts4;                       /* True for FTS4, false for FTS3 */\n  u8 bHasStat;                    /* True if %_stat table exists */\n  u8 bHasDocsize;                 /* True if %_docsize table exists */\n  u8 bDescIdx;                    /* True if doclists are in reverse order */\n  u8 bIgnoreSavepoint;            /* True to ignore xSavepoint invocations */\n  int nPgsz;                      /* Page size for host database */\n  char *zSegmentsTbl;             /* Name of %_segments table */\n  sqlite3_blob *pSegments;        /* Blob handle open on %_segments table */\n\n  /* \n  ** The following array of hash tables is used to buffer pending index \n  ** updates during transactions. All pending updates buffered at any one\n  ** time must share a common language-id (see the FTS4 langid= feature).\n  ** The current language id is stored in variable iPrevLangid.\n  **\n  ** A single FTS4 table may have multiple full-text indexes. For each index\n  ** there is an entry in the aIndex[] array. Index 0 is an index of all the\n  ** terms that appear in the document set. Each subsequent index in aIndex[]\n  ** is an index of prefixes of a specific length.\n  **\n  ** Variable nPendingData contains an estimate the memory consumed by the \n  ** pending data structures, including hash table overhead, but not including\n  ** malloc overhead.  When nPendingData exceeds nMaxPendingData, all hash\n  ** tables are flushed to disk. Variable iPrevDocid is the docid of the most \n  ** recently inserted record.\n  */\n  int nIndex;                     /* Size of aIndex[] */\n  struct Fts3Index {\n    int nPrefix;                  /* Prefix length (0 for main terms index) */\n    Fts3Hash hPending;            /* Pending terms table for this index */\n  } *aIndex;\n  int nMaxPendingData;            /* Max pending data before flush to disk */\n  int nPendingData;               /* Current bytes of pending data */\n  sqlite_int64 iPrevDocid;        /* Docid of most recently inserted document */\n  int iPrevLangid;                /* Langid of recently inserted document */\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n  /* State variables used for validating that the transaction control\n  ** methods of the virtual table are called at appropriate times.  These\n  ** values do not contribute to FTS functionality; they are used for\n  ** verifying the operation of the SQLite core.\n  */\n  int inTransaction;     /* True after xBegin but before xCommit/xRollback */\n  int mxSavepoint;       /* Largest valid xSavepoint integer */\n#endif\n};\n\n/*\n** When the core wants to read from the virtual table, it creates a\n** virtual table cursor (an instance of the following structure) using\n** the xOpen method. Cursors are destroyed using the xClose method.\n*/\nstruct Fts3Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  i16 eSearch;                    /* Search strategy (see below) */\n  u8 isEof;                       /* True if at End Of Results */\n  u8 isRequireSeek;               /* True if must seek pStmt to %_content row */\n  sqlite3_stmt *pStmt;            /* Prepared statement in use by the cursor */\n  Fts3Expr *pExpr;                /* Parsed MATCH query string */\n  int iLangid;                    /* Language being queried for */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  Fts3DeferredToken *pDeferred;   /* Deferred search tokens, if any */\n  sqlite3_int64 iPrevId;          /* Previous id read from aDoclist */\n  char *pNextId;                  /* Pointer into the body of aDoclist */\n  char *aDoclist;                 /* List of docids for full-text queries */\n  int nDoclist;                   /* Size of buffer at aDoclist */\n  u8 bDesc;                       /* True to sort in descending order */\n  int eEvalmode;                  /* An FTS3_EVAL_XX constant */\n  int nRowAvg;                    /* Average size of database rows, in pages */\n  sqlite3_int64 nDoc;             /* Documents in table */\n\n  int isMatchinfoNeeded;          /* True when aMatchinfo[] needs filling in */\n  u32 *aMatchinfo;                /* Information about most recent match */\n  int nMatchinfo;                 /* Number of elements in aMatchinfo[] */\n  char *zMatchinfo;               /* Matchinfo specification */\n};\n\n#define FTS3_EVAL_FILTER    0\n#define FTS3_EVAL_NEXT      1\n#define FTS3_EVAL_MATCHINFO 2\n\n/*\n** The Fts3Cursor.eSearch member is always set to one of the following.\n** Actualy, Fts3Cursor.eSearch can be greater than or equal to\n** FTS3_FULLTEXT_SEARCH.  If so, then Fts3Cursor.eSearch - 2 is the index\n** of the column to be searched.  For example, in\n**\n**     CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);\n**     SELECT docid FROM ex1 WHERE b MATCH 'one two three';\n** \n** Because the LHS of the MATCH operator is 2nd column \"b\",\n** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1.  (+0 for a,\n** +1 for b, +2 for c, +3 for d.)  If the LHS of MATCH were \"ex1\" \n** indicating that all columns should be searched,\n** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.\n*/\n#define FTS3_FULLSCAN_SEARCH 0    /* Linear scan of %_content table */\n#define FTS3_DOCID_SEARCH    1    /* Lookup by rowid on %_content table */\n#define FTS3_FULLTEXT_SEARCH 2    /* Full-text index search */\n\n\nstruct Fts3Doclist {\n  char *aAll;                    /* Array containing doclist (or NULL) */\n  int nAll;                      /* Size of a[] in bytes */\n  char *pNextDocid;              /* Pointer to next docid */\n\n  sqlite3_int64 iDocid;          /* Current docid (if pList!=0) */\n  int bFreeList;                 /* True if pList should be sqlite3_free()d */\n  char *pList;                   /* Pointer to position list following iDocid */\n  int nList;                     /* Length of position list */\n};\n\n/*\n** A \"phrase\" is a sequence of one or more tokens that must match in\n** sequence.  A single token is the base case and the most common case.\n** For a sequence of tokens contained in double-quotes (i.e. \"one two three\")\n** nToken will be the number of tokens in the string.\n*/\nstruct Fts3PhraseToken {\n  char *z;                        /* Text of the token */\n  int n;                          /* Number of bytes in buffer z */\n  int isPrefix;                   /* True if token ends with a \"*\" character */\n  int bFirst;                     /* True if token must appear at position 0 */\n\n  /* Variables above this point are populated when the expression is\n  ** parsed (by code in fts3_expr.c). Below this point the variables are\n  ** used when evaluating the expression. */\n  Fts3DeferredToken *pDeferred;   /* Deferred token object for this token */\n  Fts3MultiSegReader *pSegcsr;    /* Segment-reader for this token */\n};\n\nstruct Fts3Phrase {\n  /* Cache of doclist for this phrase. */\n  Fts3Doclist doclist;\n  int bIncr;                 /* True if doclist is loaded incrementally */\n  int iDoclistToken;\n\n  /* Variables below this point are populated by fts3_expr.c when parsing \n  ** a MATCH expression. Everything above is part of the evaluation phase. \n  */\n  int nToken;                /* Number of tokens in the phrase */\n  int iColumn;               /* Index of column this phrase must match */\n  Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */\n};\n\n/*\n** A tree of these objects forms the RHS of a MATCH operator.\n**\n** If Fts3Expr.eType is FTSQUERY_PHRASE and isLoaded is true, then aDoclist \n** points to a malloced buffer, size nDoclist bytes, containing the results \n** of this phrase query in FTS3 doclist format. As usual, the initial \n** \"Length\" field found in doclists stored on disk is omitted from this \n** buffer.\n**\n** Variable aMI is used only for FTSQUERY_NEAR nodes to store the global\n** matchinfo data. If it is not NULL, it points to an array of size nCol*3,\n** where nCol is the number of columns in the queried FTS table. The array\n** is populated as follows:\n**\n**   aMI[iCol*3 + 0] = Undefined\n**   aMI[iCol*3 + 1] = Number of occurrences\n**   aMI[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** The aMI array is allocated using sqlite3_malloc(). It should be freed \n** when the expression node is.\n*/\nstruct Fts3Expr {\n  int eType;                 /* One of the FTSQUERY_XXX values defined below */\n  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */\n  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */\n  Fts3Expr *pLeft;           /* Left operand */\n  Fts3Expr *pRight;          /* Right operand */\n  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */\n\n  /* The following are used by the fts3_eval.c module. */\n  sqlite3_int64 iDocid;      /* Current docid */\n  u8 bEof;                   /* True this expression is at EOF already */\n  u8 bStart;                 /* True if iDocid is valid */\n  u8 bDeferred;              /* True if this expression is entirely deferred */\n\n  u32 *aMI;\n};\n\n/*\n** Candidate values for Fts3Query.eType. Note that the order of the first\n** four values is in order of precedence when parsing expressions. For \n** example, the following:\n**\n**   \"a OR b AND c NOT d NEAR e\"\n**\n** is equivalent to:\n**\n**   \"a OR (b AND (c NOT (d NEAR e)))\"\n*/\n#define FTSQUERY_NEAR   1\n#define FTSQUERY_NOT    2\n#define FTSQUERY_AND    3\n#define FTSQUERY_OR     4\n#define FTSQUERY_PHRASE 5\n\n\n/* fts3_write.c */\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(int, int, sqlite3_int64,\n  sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table*,int,const char*,int,int,Fts3SegReader**);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *);\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table*, int, int, int, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3ReadLock(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*, int*);\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(Fts3Table *, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(Fts3Table *, sqlite3_int64, sqlite3_stmt **);\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);\n#else\n# define sqlite3Fts3FreeDeferredTokens(x)\n# define sqlite3Fts3DeferToken(x,y,z) SQLITE_OK\n# define sqlite3Fts3CacheDeferredDoclists(x) SQLITE_OK\n# define sqlite3Fts3FreeDeferredDoclists(x)\n# define sqlite3Fts3DeferredTokenList(x,y,z) SQLITE_OK\n#endif\n\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);\n\n/* Special values interpreted by sqlite3SegReaderCursor() */\n#define FTS3_SEGCURSOR_PENDING        -1\n#define FTS3_SEGCURSOR_ALL            -2\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(Fts3Table*, Fts3MultiSegReader*, Fts3SegFilter*);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(Fts3Table *, Fts3MultiSegReader *);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(Fts3MultiSegReader *);\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(Fts3Table *, \n    int, int, int, const char *, int, int, int, Fts3MultiSegReader *);\n\n/* Flags allowed as part of the 4th argument to SegmentReaderIterate() */\n#define FTS3_SEGMENT_REQUIRE_POS   0x00000001\n#define FTS3_SEGMENT_IGNORE_EMPTY  0x00000002\n#define FTS3_SEGMENT_COLUMN_FILTER 0x00000004\n#define FTS3_SEGMENT_PREFIX        0x00000008\n#define FTS3_SEGMENT_SCAN          0x00000010\n#define FTS3_SEGMENT_FIRST         0x00000020\n\n/* Type passed as 4th argument to SegmentReaderIterate() */\nstruct Fts3SegFilter {\n  const char *zTerm;\n  int nTerm;\n  int iCol;\n  int flags;\n};\n\nstruct Fts3MultiSegReader {\n  /* Used internally by sqlite3Fts3SegReaderXXX() calls */\n  Fts3SegReader **apSegment;      /* Array of Fts3SegReader objects */\n  int nSegment;                   /* Size of apSegment array */\n  int nAdvance;                   /* How many seg-readers to advance */\n  Fts3SegFilter *pFilter;         /* Pointer to filter object */\n  char *aBuffer;                  /* Buffer to merge doclists in */\n  int nBuffer;                    /* Allocated size of aBuffer[] in bytes */\n\n  int iColFilter;                 /* If >=0, filter for this column */\n  int bRestart;\n\n  /* Used by fts3.c only. */\n  int nCost;                      /* Cost of running iterator */\n  int bLookup;                    /* True if a lookup of a single entry. */\n\n  /* Output values. Valid only after Fts3SegReaderStep() returns SQLITE_ROW. */\n  char *zTerm;                    /* Pointer to term buffer */\n  int nTerm;                      /* Size of zTerm in bytes */\n  char *aDoclist;                 /* Pointer to doclist buffer */\n  int nDoclist;                   /* Size of aDoclist[] in bytes */\n};\n\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);\n\n/* fts3.c */\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *);\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);\n\n/* fts3_tokenizer.c */\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, \n    sqlite3_tokenizer **, char **\n);\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char);\n\n/* fts3_snippet.c */\nSQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);\nSQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *,\n  const char *, const char *, int, int\n);\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);\n\n/* fts3_expr.c */\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,\n  char **, int, int, int, const char *, int, Fts3Expr **, char **\n);\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);\nSQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db);\n#endif\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int,\n  sqlite3_tokenizer_cursor **\n);\n\n/* fts3_aux.c */\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db);\n\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *);\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n    Fts3Table*, Fts3MultiSegReader*, int, const char*, int);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n    Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **); \nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);\n\n/* fts3_tokenize_vtab.c */\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);\n\n/* fts3_unicode2.c (functions generated by parsing unicode text files) */\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);\n#endif\n\n#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */\n#endif /* _FTSINT_H */\n\n/************** End of fts3Int.h *********************************************/\n/************** Continuing where we left off in fts3.c ***********************/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stddef.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n/* #include <stdarg.h> */\n\n#ifndef SQLITE_CORE \n  SQLITE_EXTENSION_INIT1\n#endif\n\nstatic int fts3EvalNext(Fts3Cursor *pCsr);\nstatic int fts3EvalStart(Fts3Cursor *pCsr);\nstatic int fts3TermSegReaderCursor(\n    Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);\n\n/* \n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.\n** The number of bytes written is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n/* \n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read, or 0 on error.\n** The value is stored in *v.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){\n  const unsigned char *q = (const unsigned char *) p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\n/*\n** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a\n** 32-bit integer before it is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){\n sqlite_int64 i;\n int ret = sqlite3Fts3GetVarint(p, &i);\n *pi = (int) i;\n return ret;\n}\n\n/*\n** Return the number of bytes required to encode v as a varint\n*/\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64 v){\n  int i = 0;\n  do{\n    i++;\n    v >>= 7;\n  }while( v!=0 );\n  return i;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n**\n*/\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    int iIn = 1;                  /* Index of next byte to read from input */\n    int iOut = 0;                 /* Index of next byte to write to output */\n\n    /* If the first byte was a '[', then the close-quote character is a ']' */\n    if( quote=='[' ) quote = ']';  \n\n    while( ALWAYS(z[iIn]) ){\n      if( z[iIn]==quote ){\n        if( z[iIn+1]!=quote ) break;\n        z[iOut++] = quote;\n        iIn += 2;\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** Read a single varint from the doclist at *pp and advance *pp to point\n** to the first byte past the end of the varint.  Add the value of the varint\n** to *pVal.\n*/\nstatic void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){\n  sqlite3_int64 iVal;\n  *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n  *pVal += iVal;\n}\n\n/*\n** When this function is called, *pp points to the first byte following a\n** varint that is part of a doclist (or position-list, or any other list\n** of varints). This function moves *pp to point to the start of that varint,\n** and sets *pVal by the varint value.\n**\n** Argument pStart points to the first byte of the doclist that the\n** varint is part of.\n*/\nstatic void fts3GetReverseVarint(\n  char **pp, \n  char *pStart, \n  sqlite3_int64 *pVal\n){\n  sqlite3_int64 iVal;\n  char *p;\n\n  /* Pointer p now points at the first byte past the varint we are \n  ** interested in. So, unless the doclist is corrupt, the 0x80 bit is\n  ** clear on character p[-1]. */\n  for(p = (*pp)-2; p>=pStart && *p&0x80; p--);\n  p++;\n  *pp = p;\n\n  sqlite3Fts3GetVarint(p, &iVal);\n  *pVal = iVal;\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts3DisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int i;\n\n  assert( p->nPendingData==0 );\n  assert( p->pSegments==0 );\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(p->aStmt); i++){\n    sqlite3_finalize(p->aStmt[i]);\n  }\n  sqlite3_free(p->zSegmentsTbl);\n  sqlite3_free(p->zReadExprlist);\n  sqlite3_free(p->zWriteExprlist);\n  sqlite3_free(p->zContentTbl);\n  sqlite3_free(p->zLanguageid);\n\n  /* Invoke the tokenizer destructor to free the tokenizer. */\n  p->pTokenizer->pModule->xDestroy(p->pTokenizer);\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Construct one or more SQL statements from the format string given\n** and then evaluate those statements. The success code is written\n** into *pRc.\n**\n** If *pRc is initially non-zero then this routine is a no-op.\n*/\nstatic void fts3DbExec(\n  int *pRc,              /* Success code */\n  sqlite3 *db,           /* Database in which to run SQL */\n  const char *zFormat,   /* Format string for SQL */\n  ...                    /* Arguments to the format string */\n){\n  va_list ap;\n  char *zSql;\n  if( *pRc ) return;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    *pRc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts3DestroyMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;              /* Return code */\n  const char *zDb = p->zDb;        /* Name of database (e.g. \"main\", \"temp\") */\n  sqlite3 *db = p->db;             /* Database handle */\n\n  /* Drop the shadow tables */\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_content'\", zDb, p->zName);\n  }\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segments'\", zDb,p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segdir'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_docsize'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_stat'\", zDb, p->zName);\n\n  /* If everything has worked, invoke fts3DisconnectMethod() to free the\n  ** memory associated with the Fts3Table structure and return SQLITE_OK.\n  ** Otherwise, return an SQLite error code.\n  */\n  return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);\n}\n\n\n/*\n** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table\n** passed as the first argument. This is done as part of the xConnect()\n** and xCreate() methods.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DeclareVtab(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int i;                        /* Iterator variable */\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL statement passed to declare_vtab() */\n    char *zCols;                  /* List of user defined columns */\n    const char *zLanguageid;\n\n    zLanguageid = (p->zLanguageid ? p->zLanguageid : \"__langid\");\n    sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n    /* Create a list of user columns for the virtual table */\n    zCols = sqlite3_mprintf(\"%Q, \", p->azColumn[0]);\n    for(i=1; zCols && i<p->nColumn; i++){\n      zCols = sqlite3_mprintf(\"%z%Q, \", zCols, p->azColumn[i]);\n    }\n\n    /* Create the whole \"CREATE TABLE\" statement to pass to SQLite */\n    zSql = sqlite3_mprintf(\n        \"CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)\", \n        zCols, p->zName, zLanguageid\n    );\n    if( !zCols || !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_declare_vtab(p->db, zSql);\n    }\n\n    sqlite3_free(zSql);\n    sqlite3_free(zCols);\n    *pRc = rc;\n  }\n}\n\n/*\n** Create the %_stat table if it does not already exist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){\n  fts3DbExec(pRc, p->db, \n      \"CREATE TABLE IF NOT EXISTS %Q.'%q_stat'\"\n          \"(id INTEGER PRIMARY KEY, value BLOB);\",\n      p->zDb, p->zName\n  );\n  if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;\n}\n\n/*\n** Create the backing store tables (%_content, %_segments and %_segdir)\n** required by the FTS3 table passed as the only argument. This is done\n** as part of the vtab xCreate() method.\n**\n** If the p->bHasDocsize boolean is true (indicating that this is an\n** FTS4 table, not an FTS3 table) then also create the %_docsize and\n** %_stat tables required by FTS4.\n*/\nstatic int fts3CreateTables(Fts3Table *p){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  sqlite3 *db = p->db;            /* The database connection */\n\n  if( p->zContentTbl==0 ){\n    const char *zLanguageid = p->zLanguageid;\n    char *zContentCols;           /* Columns of %_content table */\n\n    /* Create a list of user columns for the content table */\n    zContentCols = sqlite3_mprintf(\"docid INTEGER PRIMARY KEY\");\n    for(i=0; zContentCols && i<p->nColumn; i++){\n      char *z = p->azColumn[i];\n      zContentCols = sqlite3_mprintf(\"%z, 'c%d%q'\", zContentCols, i, z);\n    }\n    if( zLanguageid && zContentCols ){\n      zContentCols = sqlite3_mprintf(\"%z, langid\", zContentCols, zLanguageid);\n    }\n    if( zContentCols==0 ) rc = SQLITE_NOMEM;\n  \n    /* Create the content table */\n    fts3DbExec(&rc, db, \n       \"CREATE TABLE %Q.'%q_content'(%s)\",\n       p->zDb, p->zName, zContentCols\n    );\n    sqlite3_free(zContentCols);\n  }\n\n  /* Create other tables */\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);\",\n      p->zDb, p->zName\n  );\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segdir'(\"\n        \"level INTEGER,\"\n        \"idx INTEGER,\"\n        \"start_block INTEGER,\"\n        \"leaves_end_block INTEGER,\"\n        \"end_block INTEGER,\"\n        \"root BLOB,\"\n        \"PRIMARY KEY(level, idx)\"\n      \");\",\n      p->zDb, p->zName\n  );\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db, \n        \"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);\",\n        p->zDb, p->zName\n    );\n  }\n  assert( p->bHasStat==p->bFts4 );\n  if( p->bHasStat ){\n    sqlite3Fts3CreateStatTable(&rc, p);\n  }\n  return rc;\n}\n\n/*\n** Store the current database page-size in bytes in p->nPgsz.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DatabasePageSize(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL text \"PRAGMA %Q.page_size\" */\n    sqlite3_stmt *pStmt;          /* Compiled \"PRAGMA %Q.page_size\" statement */\n  \n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", p->zDb);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_step(pStmt);\n        p->nPgsz = sqlite3_column_int(pStmt, 0);\n        rc = sqlite3_finalize(pStmt);\n      }else if( rc==SQLITE_AUTH ){\n        p->nPgsz = 1024;\n        rc = SQLITE_OK;\n      }\n    }\n    assert( p->nPgsz>0 || rc!=SQLITE_OK );\n    sqlite3_free(zSql);\n    *pRc = rc;\n  }\n}\n\n/*\n** \"Special\" FTS4 arguments are column specifications of the following form:\n**\n**   <key> = <value>\n**\n** There may not be whitespace surrounding the \"=\" character. The <value> \n** term may be quoted, but the <key> may not.\n*/\nstatic int fts3IsSpecialColumn(\n  const char *z, \n  int *pnKey,\n  char **pzValue\n){\n  char *zValue;\n  const char *zCsr = z;\n\n  while( *zCsr!='=' ){\n    if( *zCsr=='\\0' ) return 0;\n    zCsr++;\n  }\n\n  *pnKey = (int)(zCsr-z);\n  zValue = sqlite3_mprintf(\"%s\", &zCsr[1]);\n  if( zValue ){\n    sqlite3Fts3Dequote(zValue);\n  }\n  *pzValue = zValue;\n  return 1;\n}\n\n/*\n** Append the output of a printf() style formatting to an existing string.\n*/\nstatic void fts3Appendf(\n  int *pRc,                       /* IN/OUT: Error code */\n  char **pz,                      /* IN/OUT: Pointer to string buffer */\n  const char *zFormat,            /* Printf format string to append */\n  ...                             /* Arguments for printf format string */\n){\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    char *z;\n    va_start(ap, zFormat);\n    z = sqlite3_vmprintf(zFormat, ap);\n    va_end(ap);\n    if( z && *pz ){\n      char *z2 = sqlite3_mprintf(\"%s%s\", *pz, z);\n      sqlite3_free(z);\n      z = z2;\n    }\n    if( z==0 ) *pRc = SQLITE_NOMEM;\n    sqlite3_free(*pz);\n    *pz = z;\n  }\n}\n\n/*\n** Return a copy of input string zInput enclosed in double-quotes (\") and\n** with all double quote characters escaped. For example:\n**\n**     fts3QuoteId(\"un \\\"zip\\\"\")   ->    \"un \\\"\\\"zip\\\"\\\"\"\n**\n** The pointer returned points to memory obtained from sqlite3_malloc(). It\n** is the callers responsibility to call sqlite3_free() to release this\n** memory.\n*/\nstatic char *fts3QuoteId(char const *zInput){\n  int nRet;\n  char *zRet;\n  nRet = 2 + (int)strlen(zInput)*2 + 1;\n  zRet = sqlite3_malloc(nRet);\n  if( zRet ){\n    int i;\n    char *z = zRet;\n    *(z++) = '\"';\n    for(i=0; zInput[i]; i++){\n      if( zInput[i]=='\"' ) *(z++) = '\"';\n      *(z++) = zInput[i];\n    }\n    *(z++) = '\"';\n    *(z++) = '\\0';\n  }\n  return zRet;\n}\n\n/*\n** Return a list of comma separated SQL expressions and a FROM clause that \n** could be used in a SELECT statement such as the following:\n**\n**     SELECT <list of expressions> FROM %_content AS x ...\n**\n** to return the docid, followed by each column of text data in order\n** from left to write. If parameter zFunc is not NULL, then instead of\n** being returned directly each column of text data is passed to an SQL\n** function named zFunc first. For example, if zFunc is \"unzip\" and the\n** table has the three user-defined columns \"a\", \"b\", and \"c\", the following\n** string is returned:\n**\n**     \"docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c') FROM %_content AS x\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3ReadExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( p->zContentTbl==0 ){\n    if( !zFunc ){\n      zFunction = \"\";\n    }else{\n      zFree = zFunction = fts3QuoteId(zFunc);\n    }\n    fts3Appendf(pRc, &zRet, \"docid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \",%s(x.'c%d%q')\", zFunction, i, p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", \"langid\");\n    }\n    sqlite3_free(zFree);\n  }else{\n    fts3Appendf(pRc, &zRet, \"rowid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \", x.'%q'\", p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", p->zLanguageid);\n    }\n  }\n  fts3Appendf(pRc, &zRet, \" FROM '%q'.'%q%s' AS x\", \n      p->zDb,\n      (p->zContentTbl ? p->zContentTbl : p->zName),\n      (p->zContentTbl ? \"\" : \"_content\")\n  );\n  return zRet;\n}\n\n/*\n** Return a list of N comma separated question marks, where N is the number\n** of columns in the %_content table (one for the docid plus one for each\n** user-defined text column).\n**\n** If argument zFunc is not NULL, then all but the first question mark\n** is preceded by zFunc and an open bracket, and followed by a closed\n** bracket. For example, if zFunc is \"zip\" and the FTS3 table has three \n** user-defined text columns, the following string is returned:\n**\n**     \"?, zip(?), zip(?), zip(?)\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( !zFunc ){\n    zFunction = \"\";\n  }else{\n    zFree = zFunction = fts3QuoteId(zFunc);\n  }\n  fts3Appendf(pRc, &zRet, \"?\");\n  for(i=0; i<p->nColumn; i++){\n    fts3Appendf(pRc, &zRet, \",%s(?)\", zFunction);\n  }\n  if( p->zLanguageid ){\n    fts3Appendf(pRc, &zRet, \", ?\");\n  }\n  sqlite3_free(zFree);\n  return zRet;\n}\n\n/*\n** This function interprets the string at (*pp) as a non-negative integer\n** value. It reads the integer and sets *pnOut to the value read, then \n** sets *pp to point to the byte immediately following the last byte of\n** the integer value.\n**\n** Only decimal digits ('0'..'9') may be part of an integer value. \n**\n** If *pp does not being with a decimal digit SQLITE_ERROR is returned and\n** the output value undefined. Otherwise SQLITE_OK is returned.\n**\n** This function is used when parsing the \"prefix=\" FTS4 parameter.\n*/\nstatic int fts3GobbleInt(const char **pp, int *pnOut){\n  const char *p;                  /* Iterator pointer */\n  int nInt = 0;                   /* Output value */\n\n  for(p=*pp; p[0]>='0' && p[0]<='9'; p++){\n    nInt = nInt * 10 + (p[0] - '0');\n  }\n  if( p==*pp ) return SQLITE_ERROR;\n  *pnOut = nInt;\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called to allocate an array of Fts3Index structures\n** representing the indexes maintained by the current FTS table. FTS tables\n** always maintain the main \"terms\" index, but may also maintain one or\n** more \"prefix\" indexes, depending on the value of the \"prefix=\" parameter\n** (if any) specified as part of the CREATE VIRTUAL TABLE statement.\n**\n** Argument zParam is passed the value of the \"prefix=\" option if one was\n** specified, or NULL otherwise.\n**\n** If no error occurs, SQLITE_OK is returned and *apIndex set to point to\n** the allocated array. *pnIndex is set to the number of elements in the\n** array. If an error does occur, an SQLite error code is returned.\n**\n** Regardless of whether or not an error is returned, it is the responsibility\n** of the caller to call sqlite3_free() on the output array to free it.\n*/\nstatic int fts3PrefixParameter(\n  const char *zParam,             /* ABC in prefix=ABC parameter to parse */\n  int *pnIndex,                   /* OUT: size of *apIndex[] array */\n  struct Fts3Index **apIndex      /* OUT: Array of indexes for this table */\n){\n  struct Fts3Index *aIndex;       /* Allocated array */\n  int nIndex = 1;                 /* Number of entries in array */\n\n  if( zParam && zParam[0] ){\n    const char *p;\n    nIndex++;\n    for(p=zParam; *p; p++){\n      if( *p==',' ) nIndex++;\n    }\n  }\n\n  aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);\n  *apIndex = aIndex;\n  *pnIndex = nIndex;\n  if( !aIndex ){\n    return SQLITE_NOMEM;\n  }\n\n  memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);\n  if( zParam ){\n    const char *p = zParam;\n    int i;\n    for(i=1; i<nIndex; i++){\n      int nPrefix;\n      if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;\n      aIndex[i].nPrefix = nPrefix;\n      p++;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called when initializing an FTS4 table that uses the\n** content=xxx option. It determines the number of and names of the columns\n** of the new FTS4 table.\n**\n** The third argument passed to this function is the value passed to the\n** config=xxx option (i.e. \"xxx\"). This function queries the database for\n** a table of that name. If found, the output variables are populated\n** as follows:\n**\n**   *pnCol:   Set to the number of columns table xxx has,\n**\n**   *pnStr:   Set to the total amount of space required to store a copy\n**             of each columns name, including the nul-terminator.\n**\n**   *pazCol:  Set to point to an array of *pnCol strings. Each string is\n**             the name of the corresponding column in table xxx. The array\n**             and its contents are allocated using a single allocation. It\n**             is the responsibility of the caller to free this allocation\n**             by eventually passing the *pazCol value to sqlite3_free().\n**\n** If the table cannot be found, an error code is returned and the output\n** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is\n** returned (and the output variables are undefined).\n*/\nstatic int fts3ContentColumns(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (i.e. \"main\", \"temp\" etc.) */\n  const char *zTbl,               /* Name of content table */\n  const char ***pazCol,           /* OUT: Malloc'd array of column names */\n  int *pnCol,                     /* OUT: Size of array *pazCol */\n  int *pnStr                      /* OUT: Bytes of string content */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* \"SELECT *\" statement on zTbl */  \n  sqlite3_stmt *pStmt = 0;        /* Compiled version of zSql */\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", zDb, zTbl);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    const char **azCol;           /* Output array */\n    int nStr = 0;                 /* Size of all column names (incl. 0x00) */\n    int nCol;                     /* Number of table columns */\n    int i;                        /* Used to iterate through columns */\n\n    /* Loop through the returned columns. Set nStr to the number of bytes of\n    ** space required to store a copy of each column name, including the\n    ** nul-terminator byte.  */\n    nCol = sqlite3_column_count(pStmt);\n    for(i=0; i<nCol; i++){\n      const char *zCol = sqlite3_column_name(pStmt, i);\n      nStr += (int)strlen(zCol) + 1;\n    }\n\n    /* Allocate and populate the array to return. */\n    azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);\n    if( azCol==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *p = (char *)&azCol[nCol];\n      for(i=0; i<nCol; i++){\n        const char *zCol = sqlite3_column_name(pStmt, i);\n        int n = (int)strlen(zCol)+1;\n        memcpy(p, zCol, n);\n        azCol[i] = p;\n        p += n;\n      }\n    }\n    sqlite3_finalize(pStmt);\n\n    /* Set the output variables. */\n    *pnCol = nCol;\n    *pnStr = nStr;\n    *pazCol = azCol;\n  }\n\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts3\" or \"fts4\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts3InitVtab(\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts3Hash *pHash = (Fts3Hash *)pAux;\n  Fts3Table *p = 0;               /* Pointer to allocated vtab */\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  int nByte;                      /* Size of allocation used for *p */\n  int iCol;                       /* Column index */\n  int nString = 0;                /* Bytes required to hold all column names */\n  int nCol = 0;                   /* Number of columns in the FTS table */\n  char *zCsr;                     /* Space for holding column names */\n  int nDb;                        /* Bytes required to hold database name */\n  int nName;                      /* Bytes required to hold table name */\n  int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */\n  const char **aCol;              /* Array of column names */\n  sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */\n\n  int nIndex;                     /* Size of aIndex[] array */\n  struct Fts3Index *aIndex = 0;   /* Array of indexes for this table */\n\n  /* The results of parsing supported FTS4 key=value options: */\n  int bNoDocsize = 0;             /* True to omit %_docsize table */\n  int bDescIdx = 0;               /* True to store descending indexes */\n  char *zPrefix = 0;              /* Prefix parameter value (or NULL) */\n  char *zCompress = 0;            /* compress=? parameter (or NULL) */\n  char *zUncompress = 0;          /* uncompress=? parameter (or NULL) */\n  char *zContent = 0;             /* content=? parameter (or NULL) */\n  char *zLanguageid = 0;          /* languageid=? parameter (or NULL) */\n\n  assert( strlen(argv[0])==4 );\n  assert( (sqlite3_strnicmp(argv[0], \"fts4\", 4)==0 && isFts4)\n       || (sqlite3_strnicmp(argv[0], \"fts3\", 4)==0 && !isFts4)\n  );\n\n  nDb = (int)strlen(argv[1]) + 1;\n  nName = (int)strlen(argv[2]) + 1;\n\n  aCol = (const char **)sqlite3_malloc(sizeof(const char *) * (argc-2) );\n  if( !aCol ) return SQLITE_NOMEM;\n  memset((void *)aCol, 0, sizeof(const char *) * (argc-2));\n\n  /* Loop through all of the arguments passed by the user to the FTS3/4\n  ** module (i.e. all the column names and special arguments). This loop\n  ** does the following:\n  **\n  **   + Figures out the number of columns the FTSX table will have, and\n  **     the number of bytes of space that must be allocated to store copies\n  **     of the column names.\n  **\n  **   + If there is a tokenizer specification included in the arguments,\n  **     initializes the tokenizer pTokenizer.\n  */\n  for(i=3; rc==SQLITE_OK && i<argc; i++){\n    char const *z = argv[i];\n    int nKey;\n    char *zVal;\n\n    /* Check if this is a tokenizer specification */\n    if( !pTokenizer \n     && strlen(z)>8\n     && 0==sqlite3_strnicmp(z, \"tokenize\", 8) \n     && 0==sqlite3Fts3IsIdChar(z[8])\n    ){\n      rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);\n    }\n\n    /* Check if it is an FTS4 special argument. */\n    else if( isFts4 && fts3IsSpecialColumn(z, &nKey, &zVal) ){\n      struct Fts4Option {\n        const char *zOpt;\n        int nOpt;\n      } aFts4Opt[] = {\n        { \"matchinfo\",   9 },     /* 0 -> MATCHINFO */\n        { \"prefix\",      6 },     /* 1 -> PREFIX */\n        { \"compress\",    8 },     /* 2 -> COMPRESS */\n        { \"uncompress\", 10 },     /* 3 -> UNCOMPRESS */\n        { \"order\",       5 },     /* 4 -> ORDER */\n        { \"content\",     7 },     /* 5 -> CONTENT */\n        { \"languageid\", 10 }      /* 6 -> LANGUAGEID */\n      };\n\n      int iOpt;\n      if( !zVal ){\n        rc = SQLITE_NOMEM;\n      }else{\n        for(iOpt=0; iOpt<SizeofArray(aFts4Opt); iOpt++){\n          struct Fts4Option *pOp = &aFts4Opt[iOpt];\n          if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){\n            break;\n          }\n        }\n        if( iOpt==SizeofArray(aFts4Opt) ){\n          *pzErr = sqlite3_mprintf(\"unrecognized parameter: %s\", z);\n          rc = SQLITE_ERROR;\n        }else{\n          switch( iOpt ){\n            case 0:               /* MATCHINFO */\n              if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"fts3\", 4) ){\n                *pzErr = sqlite3_mprintf(\"unrecognized matchinfo: %s\", zVal);\n                rc = SQLITE_ERROR;\n              }\n              bNoDocsize = 1;\n              break;\n\n            case 1:               /* PREFIX */\n              sqlite3_free(zPrefix);\n              zPrefix = zVal;\n              zVal = 0;\n              break;\n\n            case 2:               /* COMPRESS */\n              sqlite3_free(zCompress);\n              zCompress = zVal;\n              zVal = 0;\n              break;\n\n            case 3:               /* UNCOMPRESS */\n              sqlite3_free(zUncompress);\n              zUncompress = zVal;\n              zVal = 0;\n              break;\n\n            case 4:               /* ORDER */\n              if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, \"asc\", 3)) \n               && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"desc\", 4)) \n              ){\n                *pzErr = sqlite3_mprintf(\"unrecognized order: %s\", zVal);\n                rc = SQLITE_ERROR;\n              }\n              bDescIdx = (zVal[0]=='d' || zVal[0]=='D');\n              break;\n\n            case 5:              /* CONTENT */\n              sqlite3_free(zContent);\n              zContent = zVal;\n              zVal = 0;\n              break;\n\n            case 6:              /* LANGUAGEID */\n              assert( iOpt==6 );\n              sqlite3_free(zLanguageid);\n              zLanguageid = zVal;\n              zVal = 0;\n              break;\n          }\n        }\n        sqlite3_free(zVal);\n      }\n    }\n\n    /* Otherwise, the argument is a column name. */\n    else {\n      nString += (int)(strlen(z) + 1);\n      aCol[nCol++] = z;\n    }\n  }\n\n  /* If a content=xxx option was specified, the following:\n  **\n  **   1. Ignore any compress= and uncompress= options.\n  **\n  **   2. If no column names were specified as part of the CREATE VIRTUAL\n  **      TABLE statement, use all columns from the content table.\n  */\n  if( rc==SQLITE_OK && zContent ){\n    sqlite3_free(zCompress); \n    sqlite3_free(zUncompress); \n    zCompress = 0;\n    zUncompress = 0;\n    if( nCol==0 ){\n      sqlite3_free((void*)aCol); \n      aCol = 0;\n      rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString);\n\n      /* If a languageid= option was specified, remove the language id\n      ** column from the aCol[] array. */ \n      if( rc==SQLITE_OK && zLanguageid ){\n        int j;\n        for(j=0; j<nCol; j++){\n          if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){\n            int k;\n            for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];\n            nCol--;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  if( nCol==0 ){\n    assert( nString==0 );\n    aCol[0] = \"content\";\n    nString = 8;\n    nCol = 1;\n  }\n\n  if( pTokenizer==0 ){\n    rc = sqlite3Fts3InitTokenizer(pHash, \"simple\", &pTokenizer, pzErr);\n    if( rc!=SQLITE_OK ) goto fts3_init_out;\n  }\n  assert( pTokenizer );\n\n  rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);\n  if( rc==SQLITE_ERROR ){\n    assert( zPrefix );\n    *pzErr = sqlite3_mprintf(\"error parsing prefix parameter: %s\", zPrefix);\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* Allocate and populate the Fts3Table structure. */\n  nByte = sizeof(Fts3Table) +                  /* Fts3Table */\n          nCol * sizeof(char *) +              /* azColumn */\n          nIndex * sizeof(struct Fts3Index) +  /* aIndex */\n          nName +                              /* zName */\n          nDb +                                /* zDb */\n          nString;                             /* Space for azColumn strings */\n  p = (Fts3Table*)sqlite3_malloc(nByte);\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n  memset(p, 0, nByte);\n  p->db = db;\n  p->nColumn = nCol;\n  p->nPendingData = 0;\n  p->azColumn = (char **)&p[1];\n  p->pTokenizer = pTokenizer;\n  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;\n  p->bHasDocsize = (isFts4 && bNoDocsize==0);\n  p->bHasStat = isFts4;\n  p->bFts4 = isFts4;\n  p->bDescIdx = bDescIdx;\n  p->bAutoincrmerge = 0xff;   /* 0xff means setting unknown */\n  p->zContentTbl = zContent;\n  p->zLanguageid = zLanguageid;\n  zContent = 0;\n  zLanguageid = 0;\n  TESTONLY( p->inTransaction = -1 );\n  TESTONLY( p->mxSavepoint = -1 );\n\n  p->aIndex = (struct Fts3Index *)&p->azColumn[nCol];\n  memcpy(p->aIndex, aIndex, sizeof(struct Fts3Index) * nIndex);\n  p->nIndex = nIndex;\n  for(i=0; i<nIndex; i++){\n    fts3HashInit(&p->aIndex[i].hPending, FTS3_HASH_STRING, 1);\n  }\n\n  /* Fill in the zName and zDb fields of the vtab structure. */\n  zCsr = (char *)&p->aIndex[nIndex];\n  p->zName = zCsr;\n  memcpy(zCsr, argv[2], nName);\n  zCsr += nName;\n  p->zDb = zCsr;\n  memcpy(zCsr, argv[1], nDb);\n  zCsr += nDb;\n\n  /* Fill in the azColumn array */\n  for(iCol=0; iCol<nCol; iCol++){\n    char *z; \n    int n = 0;\n    z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);\n    memcpy(zCsr, z, n);\n    zCsr[n] = '\\0';\n    sqlite3Fts3Dequote(zCsr);\n    p->azColumn[iCol] = zCsr;\n    zCsr += n+1;\n    assert( zCsr <= &((char *)p)[nByte] );\n  }\n\n  if( (zCompress==0)!=(zUncompress==0) ){\n    char const *zMiss = (zCompress==0 ? \"compress\" : \"uncompress\");\n    rc = SQLITE_ERROR;\n    *pzErr = sqlite3_mprintf(\"missing %s parameter in fts4 constructor\", zMiss);\n  }\n  p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);\n  p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* If this is an xCreate call, create the underlying tables in the \n  ** database. TODO: For xConnect(), it could verify that said tables exist.\n  */\n  if( isCreate ){\n    rc = fts3CreateTables(p);\n  }\n\n  /* Check to see if a legacy fts3 table has been \"upgraded\" by the\n  ** addition of a %_stat table so that it can use incremental merge.\n  */\n  if( !isFts4 && !isCreate ){\n    int rc2 = SQLITE_OK;\n    fts3DbExec(&rc2, db, \"SELECT 1 FROM %Q.'%q_stat' WHERE id=2\",\n               p->zDb, p->zName);\n    if( rc2==SQLITE_OK ) p->bHasStat = 1;\n  }\n\n  /* Figure out the page-size for the database. This is required in order to\n  ** estimate the cost of loading large doclists from the database.  */\n  fts3DatabasePageSize(&rc, p);\n  p->nNodeSize = p->nPgsz-35;\n\n  /* Declare the table schema to SQLite. */\n  fts3DeclareVtab(&rc, p);\n\nfts3_init_out:\n  sqlite3_free(zPrefix);\n  sqlite3_free(aIndex);\n  sqlite3_free(zCompress);\n  sqlite3_free(zUncompress);\n  sqlite3_free(zContent);\n  sqlite3_free(zLanguageid);\n  sqlite3_free((void *)aCol);\n  if( rc!=SQLITE_OK ){\n    if( p ){\n      fts3DisconnectMethod((sqlite3_vtab *)p);\n    }else if( pTokenizer ){\n      pTokenizer->pModule->xDestroy(pTokenizer);\n    }\n  }else{\n    assert( p->pSegments==0 );\n    *ppVTab = &p->base;\n  }\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts3InitVtab().\n*/\nstatic int fts3ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts3CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/* \n** Implementation of the xBestIndex method for FTS3 tables. There\n** are three possible strategies, in order of preference:\n**\n**   1. Direct lookup by rowid or docid. \n**   2. Full-text search using a MATCH operator on a non-docid column.\n**   3. Linear scan of %_content table.\n*/\nstatic int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts3Table *p = (Fts3Table *)pVTab;\n  int i;                          /* Iterator variable */\n  int iCons = -1;                 /* Index of constraint to use */\n  int iLangidCons = -1;           /* Index of langid=x constraint, if present */\n\n  /* By default use a full table scan. This is an expensive option,\n  ** so search through the constraints to see if a more efficient \n  ** strategy is possible.\n  */\n  pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n  pInfo->estimatedCost = 500000;\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];\n    if( pCons->usable==0 ) continue;\n\n    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */\n    if( iCons<0 \n     && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ \n     && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )\n    ){\n      pInfo->idxNum = FTS3_DOCID_SEARCH;\n      pInfo->estimatedCost = 1.0;\n      iCons = i;\n    }\n\n    /* A MATCH constraint. Use a full-text search.\n    **\n    ** If there is more than one MATCH constraint available, use the first\n    ** one encountered. If there is both a MATCH constraint and a direct\n    ** rowid/docid lookup, prefer the MATCH strategy. This is done even \n    ** though the rowid/docid lookup is faster than a MATCH query, selecting\n    ** it would lead to an \"unable to use function MATCH in the requested \n    ** context\" error.\n    */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH \n     && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn\n    ){\n      pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;\n      pInfo->estimatedCost = 2.0;\n      iCons = i;\n    }\n\n    /* Equality constraint on the langid column */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ \n     && pCons->iColumn==p->nColumn + 2\n    ){\n      iLangidCons = i;\n    }\n  }\n\n  if( iCons>=0 ){\n    pInfo->aConstraintUsage[iCons].argvIndex = 1;\n    pInfo->aConstraintUsage[iCons].omit = 1;\n  } \n  if( iLangidCons>=0 ){\n    pInfo->aConstraintUsage[iLangidCons].argvIndex = 2;\n  } \n\n  /* Regardless of the strategy selected, FTS can deliver rows in rowid (or\n  ** docid) order. Both ascending and descending are possible. \n  */\n  if( pInfo->nOrderBy==1 ){\n    struct sqlite3_index_orderby *pOrder = &pInfo->aOrderBy[0];\n    if( pOrder->iColumn<0 || pOrder->iColumn==p->nColumn+1 ){\n      if( pOrder->desc ){\n        pInfo->idxStr = \"DESC\";\n      }else{\n        pInfo->idxStr = \"ASC\";\n      }\n      pInfo->orderByConsumed = 1;\n    }\n  }\n\n  assert( p->pSegments==0 );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts3OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  sqlite3_vtab_cursor *pCsr;               /* Allocated cursor */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* Allocate a buffer large enough for an Fts3Cursor structure. If the\n  ** allocation succeeds, zero it and return SQLITE_OK. Otherwise, \n  ** if the allocation fails, return SQLITE_NOMEM.\n  */\n  *ppCsr = pCsr = (sqlite3_vtab_cursor *)sqlite3_malloc(sizeof(Fts3Cursor));\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3Cursor));\n  return SQLITE_OK;\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3Fts3ExprFree(pCsr->pExpr);\n  sqlite3Fts3FreeDeferredTokens(pCsr);\n  sqlite3_free(pCsr->aDoclist);\n  sqlite3_free(pCsr->aMatchinfo);\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** If pCsr->pStmt has not been prepared (i.e. if pCsr->pStmt==0), then\n** compose and prepare an SQL statement of the form:\n**\n**    \"SELECT <columns> FROM %_content WHERE rowid = ?\"\n**\n** (or the equivalent for a content=xxx table) and set pCsr->pStmt to\n** it. If an error occurs, return an SQLite error code.\n**\n** Otherwise, set *ppStmt to point to pCsr->pStmt and return SQLITE_OK.\n*/\nstatic int fts3CursorSeekStmt(Fts3Cursor *pCsr, sqlite3_stmt **ppStmt){\n  int rc = SQLITE_OK;\n  if( pCsr->pStmt==0 ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    char *zSql;\n    zSql = sqlite3_mprintf(\"SELECT %s WHERE rowid = ?\", p->zReadExprlist);\n    if( !zSql ) return SQLITE_NOMEM;\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);\n    sqlite3_free(zSql);\n  }\n  *ppStmt = pCsr->pStmt;\n  return rc;\n}\n\n/*\n** Position the pCsr->pStmt statement so that it is on the row\n** of the %_content table that contains the last match.  Return\n** SQLITE_OK on success.  \n*/\nstatic int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->isRequireSeek ){\n    sqlite3_stmt *pStmt = 0;\n\n    rc = fts3CursorSeekStmt(pCsr, &pStmt);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);\n      pCsr->isRequireSeek = 0;\n      if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){\n        return SQLITE_OK;\n      }else{\n        rc = sqlite3_reset(pCsr->pStmt);\n        if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){\n          /* If no row was found and no error has occurred, then the %_content\n          ** table is missing a row that is present in the full-text index.\n          ** The data structures are corrupt.  */\n          rc = FTS_CORRUPT_VTAB;\n          pCsr->isEof = 1;\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK && pContext ){\n    sqlite3_result_error_code(pContext, rc);\n  }\n  return rc;\n}\n\n/*\n** This function is used to process a single interior node when searching\n** a b-tree for a term or term prefix. The node data is passed to this \n** function via the zNode/nNode parameters. The term to search for is\n** passed in zTerm/nTerm.\n**\n** If piFirst is not NULL, then this function sets *piFirst to the blockid\n** of the child node that heads the sub-tree that may contain the term.\n**\n** If piLast is not NULL, then *piLast is set to the right-most child node\n** that heads a sub-tree that may contain a term for which zTerm/nTerm is\n** a prefix.\n**\n** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3ScanInteriorNode(\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piFirst,         /* OUT: Selected child node */\n  sqlite3_int64 *piLast           /* OUT: Selected child node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *zCsr = zNode;       /* Cursor to iterate through node */\n  const char *zEnd = &zCsr[nNode];/* End of interior node buffer */\n  char *zBuffer = 0;              /* Buffer to load terms into */\n  int nAlloc = 0;                 /* Size of allocated buffer */\n  int isFirstTerm = 1;            /* True when processing first term on page */\n  sqlite3_int64 iChild;           /* Block id of child node to descend to */\n\n  /* Skip over the 'height' varint that occurs at the start of every \n  ** interior node. Then load the blockid of the left-child of the b-tree\n  ** node into variable iChild.  \n  **\n  ** Even if the data structure on disk is corrupted, this (reading two\n  ** varints from the buffer) does not risk an overread. If zNode is a\n  ** root node, then the buffer comes from a SELECT statement. SQLite does\n  ** not make this guarantee explicitly, but in practice there are always\n  ** either more than 20 bytes of allocated space following the nNode bytes of\n  ** contents, or two zero bytes. Or, if the node is read from the %_segments\n  ** table, then there are always 20 bytes of zeroed padding following the\n  ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).\n  */\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  if( zCsr>zEnd ){\n    return FTS_CORRUPT_VTAB;\n  }\n  \n  while( zCsr<zEnd && (piFirst || piLast) ){\n    int cmp;                      /* memcmp() result */\n    int nSuffix;                  /* Size of term suffix */\n    int nPrefix = 0;              /* Size of term prefix */\n    int nBuffer;                  /* Total term size */\n  \n    /* Load the next term on the node into zBuffer. Use realloc() to expand\n    ** the size of zBuffer if required.  */\n    if( !isFirstTerm ){\n      zCsr += sqlite3Fts3GetVarint32(zCsr, &nPrefix);\n    }\n    isFirstTerm = 0;\n    zCsr += sqlite3Fts3GetVarint32(zCsr, &nSuffix);\n    \n    if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){\n      rc = FTS_CORRUPT_VTAB;\n      goto finish_scan;\n    }\n    if( nPrefix+nSuffix>nAlloc ){\n      char *zNew;\n      nAlloc = (nPrefix+nSuffix) * 2;\n      zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);\n      if( !zNew ){\n        rc = SQLITE_NOMEM;\n        goto finish_scan;\n      }\n      zBuffer = zNew;\n    }\n    assert( zBuffer );\n    memcpy(&zBuffer[nPrefix], zCsr, nSuffix);\n    nBuffer = nPrefix + nSuffix;\n    zCsr += nSuffix;\n\n    /* Compare the term we are searching for with the term just loaded from\n    ** the interior node. If the specified term is greater than or equal\n    ** to the term from the interior node, then all terms on the sub-tree \n    ** headed by node iChild are smaller than zTerm. No need to search \n    ** iChild.\n    **\n    ** If the interior node term is larger than the specified term, then\n    ** the tree headed by iChild may contain the specified term.\n    */\n    cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));\n    if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){\n      *piFirst = iChild;\n      piFirst = 0;\n    }\n\n    if( piLast && cmp<0 ){\n      *piLast = iChild;\n      piLast = 0;\n    }\n\n    iChild++;\n  };\n\n  if( piFirst ) *piFirst = iChild;\n  if( piLast ) *piLast = iChild;\n\n finish_scan:\n  sqlite3_free(zBuffer);\n  return rc;\n}\n\n\n/*\n** The buffer pointed to by argument zNode (size nNode bytes) contains an\n** interior node of a b-tree segment. The zTerm buffer (size nTerm bytes)\n** contains a term. This function searches the sub-tree headed by the zNode\n** node for the range of leaf nodes that may contain the specified term\n** or terms for which the specified term is a prefix.\n**\n** If piLeaf is not NULL, then *piLeaf is set to the blockid of the \n** left-most leaf node in the tree that may contain the specified term.\n** If piLeaf2 is not NULL, then *piLeaf2 is set to the blockid of the\n** right-most leaf node that may contain a term for which the specified\n** term is a prefix.\n**\n** It is possible that the range of returned leaf nodes does not contain \n** the specified term or any terms for which it is a prefix. However, if the \n** segment does contain any such terms, they are stored within the identified\n** range. Because this function only inspects interior segment nodes (and\n** never loads leaf nodes into memory), it is not possible to be sure.\n**\n** If an error occurs, an error code other than SQLITE_OK is returned.\n*/ \nstatic int fts3SelectLeaf(\n  Fts3Table *p,                   /* Virtual table handle */\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piLeaf,          /* Selected leaf node */\n  sqlite3_int64 *piLeaf2          /* Selected leaf node */\n){\n  int rc;                         /* Return code */\n  int iHeight;                    /* Height of this node in tree */\n\n  assert( piLeaf || piLeaf2 );\n\n  sqlite3Fts3GetVarint32(zNode, &iHeight);\n  rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);\n  assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );\n\n  if( rc==SQLITE_OK && iHeight>1 ){\n    char *zBlob = 0;              /* Blob read from %_segments table */\n    int nBlob;                    /* Size of zBlob in bytes */\n\n    if( piLeaf && piLeaf2 && (*piLeaf!=*piLeaf2) ){\n      rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);\n      if( rc==SQLITE_OK ){\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, 0);\n      }\n      sqlite3_free(zBlob);\n      piLeaf = 0;\n      zBlob = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);\n    }\n    sqlite3_free(zBlob);\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to create delta-encoded serialized lists of FTS3 \n** varints. Each call to this function appends a single varint to a list.\n*/\nstatic void fts3PutDeltaVarint(\n  char **pp,                      /* IN/OUT: Output pointer */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );\n  *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);\n  *piPrev = iVal;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a position-list. After it returns, *ppPoslist points to the\n** first byte after the position-list.\n**\n** A position list is list of positions (delta encoded) and columns for \n** a single document record of a doclist.  So, in other words, this\n** routine advances *ppPoslist so that it points to the next docid in\n** the doclist, or to the first byte past the end of the doclist.\n**\n** If pp is not NULL, then the contents of the position list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.\n*/\nstatic void fts3PoslistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* The end of a position list is marked by a zero encoded as an FTS3 \n  ** varint. A single POS_END (0) byte. Except, if the 0 byte is preceded by\n  ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail\n  ** of some other, multi-byte, value.\n  **\n  ** The following while-loop moves pEnd to point to the first byte that is not \n  ** immediately preceded by a byte with the 0x80 bit set. Then increments\n  ** pEnd once more so that it points to the byte immediately following the\n  ** last byte in the position-list.\n  */\n  while( *pEnd | c ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && (*pEnd)==0 );\n  }\n  pEnd++;  /* Advance past the POS_END terminator byte */\n\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a column-list. After it returns, *ppPoslist points to the\n** to the terminator (POS_COLUMN or POS_END) byte of the column-list.\n**\n** A column-list is list of delta-encoded positions for a single column\n** within a single document within a doclist.\n**\n** The column-list is terminated either by a POS_COLUMN varint (1) or\n** a POS_END varint (0).  This routine leaves *ppPoslist pointing to\n** the POS_COLUMN or POS_END that terminates the column-list.\n**\n** If pp is not NULL, then the contents of the column-list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.  The POS_COLUMN or POS_END terminator\n** is not copied into *pp.\n*/\nstatic void fts3ColumnlistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00 byte that is\n  ** not part of a multi-byte varint.\n  */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && ((*pEnd)&0xfe)==0 );\n  }\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** Value used to signify the end of an position-list. This is safe because\n** it is not possible to have a document with 2^31 terms.\n*/\n#define POSITION_LIST_END 0x7fffffff\n\n/*\n** This function is used to help parse position-lists. When this function is\n** called, *pp may point to the start of the next varint in the position-list\n** being parsed, or it may point to 1 byte past the end of the position-list\n** (in which case **pp will be a terminator bytes POS_END (0) or\n** (1)).\n**\n** If *pp points past the end of the current position-list, set *pi to \n** POSITION_LIST_END and return. Otherwise, read the next varint from *pp,\n** increment the current value of *pi by the value read, and set *pp to\n** point to the next value before returning.\n**\n** Before calling this routine *pi must be initialized to the value of\n** the previous position, or zero if we are reading the first position\n** in the position-list.  Because positions are delta-encoded, the value\n** of the previous position is needed in order to compute the value of\n** the next position.\n*/\nstatic void fts3ReadNextPos(\n  char **pp,                    /* IN/OUT: Pointer into position-list buffer */\n  sqlite3_int64 *pi             /* IN/OUT: Value read from position-list */\n){\n  if( (**pp)&0xFE ){\n    fts3GetDeltaVarint(pp, pi);\n    *pi -= 2;\n  }else{\n    *pi = POSITION_LIST_END;\n  }\n}\n\n/*\n** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by\n** the value of iCol encoded as a varint to *pp.   This will start a new\n** column list.\n**\n** Set *pp to point to the byte just after the last byte written before \n** returning (do not modify it if iCol==0). Return the total number of bytes\n** written (0 if iCol==0).\n*/\nstatic int fts3PutColNumber(char **pp, int iCol){\n  int n = 0;                      /* Number of bytes written */\n  if( iCol ){\n    char *p = *pp;                /* Output pointer */\n    n = 1 + sqlite3Fts3PutVarint(&p[1], iCol);\n    *p = 0x01;\n    *pp = &p[n];\n  }\n  return n;\n}\n\n/*\n** Compute the union of two position lists.  The output written\n** into *pp contains all positions of both *pp1 and *pp2 in sorted\n** order and with any duplicates removed.  All pointers are\n** updated appropriately.   The caller is responsible for insuring\n** that there is enough space in *pp to hold the complete output.\n*/\nstatic void fts3PoslistMerge(\n  char **pp,                      /* Output buffer */\n  char **pp1,                     /* Left input list */\n  char **pp2                      /* Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  while( *p1 || *p2 ){\n    int iCol1;         /* The current column index in pp1 */\n    int iCol2;         /* The current column index in pp2 */\n\n    if( *p1==POS_COLUMN ) sqlite3Fts3GetVarint32(&p1[1], &iCol1);\n    else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;\n    else iCol1 = 0;\n\n    if( *p2==POS_COLUMN ) sqlite3Fts3GetVarint32(&p2[1], &iCol2);\n    else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;\n    else iCol2 = 0;\n\n    if( iCol1==iCol2 ){\n      sqlite3_int64 i1 = 0;       /* Last position from pp1 */\n      sqlite3_int64 i2 = 0;       /* Last position from pp2 */\n      sqlite3_int64 iPrev = 0;\n      int n = fts3PutColNumber(&p, iCol1);\n      p1 += n;\n      p2 += n;\n\n      /* At this point, both p1 and p2 point to the start of column-lists\n      ** for the same column (the column with index iCol1 and iCol2).\n      ** A column-list is a list of non-negative delta-encoded varints, each \n      ** incremented by 2 before being stored. Each list is terminated by a\n      ** POS_END (0) or POS_COLUMN (1). The following block merges the two lists\n      ** and writes the results to buffer p. p is left pointing to the byte\n      ** after the list written. No terminator (POS_END or POS_COLUMN) is\n      ** written to the output.\n      */\n      fts3GetDeltaVarint(&p1, &i1);\n      fts3GetDeltaVarint(&p2, &i2);\n      do {\n        fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2); \n        iPrev -= 2;\n        if( i1==i2 ){\n          fts3ReadNextPos(&p1, &i1);\n          fts3ReadNextPos(&p2, &i2);\n        }else if( i1<i2 ){\n          fts3ReadNextPos(&p1, &i1);\n        }else{\n          fts3ReadNextPos(&p2, &i2);\n        }\n      }while( i1!=POSITION_LIST_END || i2!=POSITION_LIST_END );\n    }else if( iCol1<iCol2 ){\n      p1 += fts3PutColNumber(&p, iCol1);\n      fts3ColumnlistCopy(&p, &p1);\n    }else{\n      p2 += fts3PutColNumber(&p, iCol2);\n      fts3ColumnlistCopy(&p, &p2);\n    }\n  }\n\n  *p++ = POS_END;\n  *pp = p;\n  *pp1 = p1 + 1;\n  *pp2 = p2 + 1;\n}\n\n/*\n** This function is used to merge two position lists into one. When it is\n** called, *pp1 and *pp2 must both point to position lists. A position-list is\n** the part of a doclist that follows each document id. For example, if a row\n** contains:\n**\n**     'a b c'|'x y z'|'a b b a'\n**\n** Then the position list for this row for token 'b' would consist of:\n**\n**     0x02 0x01 0x02 0x03 0x03 0x00\n**\n** When this function returns, both *pp1 and *pp2 are left pointing to the\n** byte following the 0x00 terminator of their respective position lists.\n**\n** If isSaveLeft is 0, an entry is added to the output position list for \n** each position in *pp2 for which there exists one or more positions in\n** *pp1 so that (pos(*pp2)>pos(*pp1) && pos(*pp2)-pos(*pp1)<=nToken). i.e.\n** when the *pp1 token appears before the *pp2 token, but not more than nToken\n** slots before it.\n**\n** e.g. nToken==1 searches for adjacent positions.\n*/\nstatic int fts3PoslistPhraseMerge(\n  char **pp,                      /* IN/OUT: Preallocated output buffer */\n  int nToken,                     /* Maximum difference in token positions */\n  int isSaveLeft,                 /* Save the left position */\n  int isExact,                    /* If *pp1 is exactly nTokens before *pp2 */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n  int iCol1 = 0;\n  int iCol2 = 0;\n\n  /* Never set both isSaveLeft and isExact for the same invocation. */\n  assert( isSaveLeft==0 || isExact==0 );\n\n  assert( p!=0 && *p1!=0 && *p2!=0 );\n  if( *p1==POS_COLUMN ){ \n    p1++;\n    p1 += sqlite3Fts3GetVarint32(p1, &iCol1);\n  }\n  if( *p2==POS_COLUMN ){ \n    p2++;\n    p2 += sqlite3Fts3GetVarint32(p2, &iCol2);\n  }\n\n  while( 1 ){\n    if( iCol1==iCol2 ){\n      char *pSave = p;\n      sqlite3_int64 iPrev = 0;\n      sqlite3_int64 iPos1 = 0;\n      sqlite3_int64 iPos2 = 0;\n\n      if( iCol1 ){\n        *p++ = POS_COLUMN;\n        p += sqlite3Fts3PutVarint(p, iCol1);\n      }\n\n      assert( *p1!=POS_END && *p1!=POS_COLUMN );\n      assert( *p2!=POS_END && *p2!=POS_COLUMN );\n      fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n      fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n\n      while( 1 ){\n        if( iPos2==iPos1+nToken \n         || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) \n        ){\n          sqlite3_int64 iSave;\n          iSave = isSaveLeft ? iPos1 : iPos2;\n          fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2;\n          pSave = 0;\n          assert( p );\n        }\n        if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){\n          if( (*p2&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n        }else{\n          if( (*p1&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n        }\n      }\n\n      if( pSave ){\n        assert( pp && p );\n        p = pSave;\n      }\n\n      fts3ColumnlistCopy(0, &p1);\n      fts3ColumnlistCopy(0, &p2);\n      assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );\n      if( 0==*p1 || 0==*p2 ) break;\n\n      p1++;\n      p1 += sqlite3Fts3GetVarint32(p1, &iCol1);\n      p2++;\n      p2 += sqlite3Fts3GetVarint32(p2, &iCol2);\n    }\n\n    /* Advance pointer p1 or p2 (whichever corresponds to the smaller of\n    ** iCol1 and iCol2) so that it points to either the 0x00 that marks the\n    ** end of the position list, or the 0x01 that precedes the next \n    ** column-number in the position list. \n    */\n    else if( iCol1<iCol2 ){\n      fts3ColumnlistCopy(0, &p1);\n      if( 0==*p1 ) break;\n      p1++;\n      p1 += sqlite3Fts3GetVarint32(p1, &iCol1);\n    }else{\n      fts3ColumnlistCopy(0, &p2);\n      if( 0==*p2 ) break;\n      p2++;\n      p2 += sqlite3Fts3GetVarint32(p2, &iCol2);\n    }\n  }\n\n  fts3PoslistCopy(0, &p2);\n  fts3PoslistCopy(0, &p1);\n  *pp1 = p1;\n  *pp2 = p2;\n  if( *pp==p ){\n    return 0;\n  }\n  *p++ = 0x00;\n  *pp = p;\n  return 1;\n}\n\n/*\n** Merge two position-lists as required by the NEAR operator. The argument\n** position lists correspond to the left and right phrases of an expression \n** like:\n**\n**     \"phrase 1\" NEAR \"phrase number 2\"\n**\n** Position list *pp1 corresponds to the left-hand side of the NEAR \n** expression and *pp2 to the right. As usual, the indexes in the position \n** lists are the offsets of the last token in each phrase (tokens \"1\" and \"2\" \n** in the example above).\n**\n** The output position list - written to *pp - is a copy of *pp2 with those\n** entries that are not sufficiently NEAR entries in *pp1 removed.\n*/\nstatic int fts3PoslistNearMerge(\n  char **pp,                      /* Output buffer */\n  char *aTmp,                     /* Temporary buffer space */\n  int nRight,                     /* Maximum difference in token positions */\n  int nLeft,                      /* Maximum difference in token positions */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  char *pTmp1 = aTmp;\n  char *pTmp2;\n  char *aTmp2;\n  int res = 1;\n\n  fts3PoslistPhraseMerge(&pTmp1, nRight, 0, 0, pp1, pp2);\n  aTmp2 = pTmp2 = pTmp1;\n  *pp1 = p1;\n  *pp2 = p2;\n  fts3PoslistPhraseMerge(&pTmp2, nLeft, 1, 0, pp2, pp1);\n  if( pTmp1!=aTmp && pTmp2!=aTmp2 ){\n    fts3PoslistMerge(pp, &aTmp, &aTmp2);\n  }else if( pTmp1!=aTmp ){\n    fts3PoslistCopy(pp, &aTmp);\n  }else if( pTmp2!=aTmp2 ){\n    fts3PoslistCopy(pp, &aTmp2);\n  }else{\n    res = 0;\n  }\n\n  return res;\n}\n\n/* \n** An instance of this function is used to merge together the (potentially\n** large number of) doclists for each term that matches a prefix query.\n** See function fts3TermSelectMerge() for details.\n*/\ntypedef struct TermSelect TermSelect;\nstruct TermSelect {\n  char *aaOutput[16];             /* Malloc'd output buffers */\n  int anOutput[16];               /* Size each output buffer in bytes */\n};\n\n/*\n** This function is used to read a single varint from a buffer. Parameter\n** pEnd points 1 byte past the end of the buffer. When this function is\n** called, if *pp points to pEnd or greater, then the end of the buffer\n** has been reached. In this case *pp is set to 0 and the function returns.\n**\n** If *pp does not point to or past pEnd, then a single varint is read\n** from *pp. *pp is then set to point 1 byte past the end of the read varint.\n**\n** If bDescIdx is false, the value read is added to *pVal before returning.\n** If it is true, the value read is subtracted from *pVal before this \n** function returns.\n*/\nstatic void fts3GetDeltaVarint3(\n  char **pp,                      /* IN/OUT: Point to read varint from */\n  char *pEnd,                     /* End of buffer */\n  int bDescIdx,                   /* True if docids are descending */\n  sqlite3_int64 *pVal             /* IN/OUT: Integer value */\n){\n  if( *pp>=pEnd ){\n    *pp = 0;\n  }else{\n    sqlite3_int64 iVal;\n    *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n    if( bDescIdx ){\n      *pVal -= iVal;\n    }else{\n      *pVal += iVal;\n    }\n  }\n}\n\n/*\n** This function is used to write a single varint to a buffer. The varint\n** is written to *pp. Before returning, *pp is set to point 1 byte past the\n** end of the value written.\n**\n** If *pbFirst is zero when this function is called, the value written to\n** the buffer is that of parameter iVal. \n**\n** If *pbFirst is non-zero when this function is called, then the value \n** written is either (iVal-*piPrev) (if bDescIdx is zero) or (*piPrev-iVal)\n** (if bDescIdx is non-zero).\n**\n** Before returning, this function always sets *pbFirst to 1 and *piPrev\n** to the value of parameter iVal.\n*/\nstatic void fts3PutDeltaVarint3(\n  char **pp,                      /* IN/OUT: Output pointer */\n  int bDescIdx,                   /* True for descending docids */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  int *pbFirst,                   /* IN/OUT: True after first int written */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  sqlite3_int64 iWrite;\n  if( bDescIdx==0 || *pbFirst==0 ){\n    iWrite = iVal - *piPrev;\n  }else{\n    iWrite = *piPrev - iVal;\n  }\n  assert( *pbFirst || *piPrev==0 );\n  assert( *pbFirst==0 || iWrite>0 );\n  *pp += sqlite3Fts3PutVarint(*pp, iWrite);\n  *piPrev = iVal;\n  *pbFirst = 1;\n}\n\n\n/*\n** This macro is used by various functions that merge doclists. The two\n** arguments are 64-bit docid values. If the value of the stack variable\n** bDescDoclist is 0 when this macro is invoked, then it returns (i1-i2). \n** Otherwise, (i2-i1).\n**\n** Using this makes it easier to write code that can merge doclists that are\n** sorted in either ascending or descending order.\n*/\n#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))\n\n/*\n** This function does an \"OR\" merge of two doclists (output contains all\n** positions contained in either argument doclist). If the docids in the \n** input doclists are sorted in ascending order, parameter bDescDoclist\n** should be false. If they are sorted in ascending order, it should be\n** passed a non-zero value.\n**\n** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer\n** containing the output doclist and SQLITE_OK is returned. In this case\n** *pnOut is set to the number of bytes in the output doclist.\n**\n** If an error occurs, an SQLite error code is returned. The output values\n** are undefined in this case.\n*/\nstatic int fts3DoclistOrMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  char *a1, int n1,               /* First doclist */\n  char *a2, int n2,               /* Second doclist */\n  char **paOut, int *pnOut        /* OUT: Malloc'd doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *pEnd1 = &a1[n1];\n  char *pEnd2 = &a2[n2];\n  char *p1 = a1;\n  char *p2 = a2;\n  char *p;\n  char *aOut;\n  int bFirstOut = 0;\n\n  *paOut = 0;\n  *pnOut = 0;\n\n  /* Allocate space for the output. Both the input and output doclists\n  ** are delta encoded. If they are in ascending order (bDescDoclist==0),\n  ** then the first docid in each list is simply encoded as a varint. For\n  ** each subsequent docid, the varint stored is the difference between the\n  ** current and previous docid (a positive number - since the list is in\n  ** ascending order).\n  **\n  ** The first docid written to the output is therefore encoded using the \n  ** same number of bytes as it is in whichever of the input lists it is\n  ** read from. And each subsequent docid read from the same input list \n  ** consumes either the same or less bytes as it did in the input (since\n  ** the difference between it and the previous value in the output must\n  ** be a positive value less than or equal to the delta value read from \n  ** the input list). The same argument applies to all but the first docid\n  ** read from the 'other' list. And to the contents of all position lists\n  ** that will be copied and merged from the input to the output.\n  **\n  ** However, if the first docid copied to the output is a negative number,\n  ** then the encoding of the first docid from the 'other' input list may\n  ** be larger in the output than it was in the input (since the delta value\n  ** may be a larger positive integer than the actual docid).\n  **\n  ** The space required to store the output is therefore the sum of the\n  ** sizes of the two inputs, plus enough space for exactly one of the input\n  ** docids to grow. \n  **\n  ** A symetric argument may be made if the doclists are in descending \n  ** order.\n  */\n  aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);\n  if( !aOut ) return SQLITE_NOMEM;\n\n  p = aOut;\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n  while( p1 || p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n\n    if( p2 && p1 && iDiff==0 ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistMerge(&p, &p1, &p2);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( !p2 || (p1 && iDiff<0) ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistCopy(&p, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i2);\n      fts3PoslistCopy(&p, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *paOut = aOut;\n  *pnOut = (int)(p-aOut);\n  assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );\n  return SQLITE_OK;\n}\n\n/*\n** This function does a \"phrase\" merge of two doclists. In a phrase merge,\n** the output contains a copy of each position from the right-hand input\n** doclist for which there is a position in the left-hand input doclist\n** exactly nDist tokens before it.\n**\n** If the docids in the input doclists are sorted in ascending order,\n** parameter bDescDoclist should be false. If they are sorted in ascending \n** order, it should be passed a non-zero value.\n**\n** The right-hand input doclist is overwritten by this function.\n*/\nstatic void fts3DoclistPhraseMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  int nDist,                      /* Distance from left to right (1=adjacent) */\n  char *aLeft, int nLeft,         /* Left doclist */\n  char *aRight, int *pnRight      /* IN/OUT: Right/output doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *pEnd1 = &aLeft[nLeft];\n  char *pEnd2 = &aRight[*pnRight];\n  char *p1 = aLeft;\n  char *p2 = aRight;\n  char *p;\n  int bFirstOut = 0;\n  char *aOut = aRight;\n\n  assert( nDist>0 );\n\n  p = aOut;\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n\n  while( p1 && p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n    if( iDiff==0 ){\n      char *pSave = p;\n      sqlite3_int64 iPrevSave = iPrev;\n      int bFirstOutSave = bFirstOut;\n\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      if( 0==fts3PoslistPhraseMerge(&p, nDist, 0, 1, &p1, &p2) ){\n        p = pSave;\n        iPrev = iPrevSave;\n        bFirstOut = bFirstOutSave;\n      }\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( iDiff<0 ){\n      fts3PoslistCopy(0, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PoslistCopy(0, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *pnRight = (int)(p - aOut);\n}\n\n/*\n** Argument pList points to a position list nList bytes in size. This\n** function checks to see if the position list contains any entries for\n** a token in position 0 (of any column). If so, it writes argument iDelta\n** to the output buffer pOut, followed by a position list consisting only\n** of the entries from pList at position 0, and terminated by an 0x00 byte.\n** The value returned is the number of bytes written to pOut (if any).\n*/\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(\n  sqlite3_int64 iDelta,           /* Varint that may be written to pOut */\n  char *pList,                    /* Position list (no 0x00 term) */\n  int nList,                      /* Size of pList in bytes */\n  char *pOut                      /* Write output here */\n){\n  int nOut = 0;\n  int bWritten = 0;               /* True once iDelta has been written */\n  char *p = pList;\n  char *pEnd = &pList[nList];\n\n  if( *p!=0x01 ){\n    if( *p==0x02 ){\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n      pOut[nOut++] = 0x02;\n      bWritten = 1;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n\n  while( p<pEnd && *p==0x01 ){\n    sqlite3_int64 iCol;\n    p++;\n    p += sqlite3Fts3GetVarint(p, &iCol);\n    if( *p==0x02 ){\n      if( bWritten==0 ){\n        nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n        bWritten = 1;\n      }\n      pOut[nOut++] = 0x01;\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iCol);\n      pOut[nOut++] = 0x02;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n  if( bWritten ){\n    pOut[nOut++] = 0x00;\n  }\n\n  return nOut;\n}\n\n\n/*\n** Merge all doclists in the TermSelect.aaOutput[] array into a single\n** doclist stored in TermSelect.aaOutput[0]. If successful, delete all\n** other doclists (except the aaOutput[0] one) and return SQLITE_OK.\n**\n** If an OOM error occurs, return SQLITE_NOMEM. In this case it is\n** the responsibility of the caller to free any doclists left in the\n** TermSelect.aaOutput[] array.\n*/\nstatic int fts3TermSelectFinishMerge(Fts3Table *p, TermSelect *pTS){\n  char *aOut = 0;\n  int nOut = 0;\n  int i;\n\n  /* Loop through the doclists in the aaOutput[] array. Merge them all\n  ** into a single doclist.\n  */\n  for(i=0; i<SizeofArray(pTS->aaOutput); i++){\n    if( pTS->aaOutput[i] ){\n      if( !aOut ){\n        aOut = pTS->aaOutput[i];\n        nOut = pTS->anOutput[i];\n        pTS->aaOutput[i] = 0;\n      }else{\n        int nNew;\n        char *aNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, \n            pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut, &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aOut);\n          return rc;\n        }\n\n        sqlite3_free(pTS->aaOutput[i]);\n        sqlite3_free(aOut);\n        pTS->aaOutput[i] = 0;\n        aOut = aNew;\n        nOut = nNew;\n      }\n    }\n  }\n\n  pTS->aaOutput[0] = aOut;\n  pTS->anOutput[0] = nOut;\n  return SQLITE_OK;\n}\n\n/*\n** Merge the doclist aDoclist/nDoclist into the TermSelect object passed\n** as the first argument. The merge is an \"OR\" merge (see function\n** fts3DoclistOrMerge() for details).\n**\n** This function is called with the doclist for each term that matches\n** a queried prefix. It merges all these doclists into one, the doclist\n** for the specified prefix. Since there can be a very large number of\n** doclists to merge, the merging is done pair-wise using the TermSelect\n** object.\n**\n** This function returns SQLITE_OK if the merge is successful, or an\n** SQLite error code (SQLITE_NOMEM) if an error occurs.\n*/\nstatic int fts3TermSelectMerge(\n  Fts3Table *p,                   /* FTS table handle */\n  TermSelect *pTS,                /* TermSelect object to merge into */\n  char *aDoclist,                 /* Pointer to doclist */\n  int nDoclist                    /* Size of aDoclist in bytes */\n){\n  if( pTS->aaOutput[0]==0 ){\n    /* If this is the first term selected, copy the doclist to the output\n    ** buffer using memcpy(). */\n    pTS->aaOutput[0] = sqlite3_malloc(nDoclist);\n    pTS->anOutput[0] = nDoclist;\n    if( pTS->aaOutput[0] ){\n      memcpy(pTS->aaOutput[0], aDoclist, nDoclist);\n    }else{\n      return SQLITE_NOMEM;\n    }\n  }else{\n    char *aMerge = aDoclist;\n    int nMerge = nDoclist;\n    int iOut;\n\n    for(iOut=0; iOut<SizeofArray(pTS->aaOutput); iOut++){\n      if( pTS->aaOutput[iOut]==0 ){\n        assert( iOut>0 );\n        pTS->aaOutput[iOut] = aMerge;\n        pTS->anOutput[iOut] = nMerge;\n        break;\n      }else{\n        char *aNew;\n        int nNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, aMerge, nMerge, \n            pTS->aaOutput[iOut], pTS->anOutput[iOut], &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n          return rc;\n        }\n\n        if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n        sqlite3_free(pTS->aaOutput[iOut]);\n        pTS->aaOutput[iOut] = 0;\n  \n        aMerge = aNew;\n        nMerge = nNew;\n        if( (iOut+1)==SizeofArray(pTS->aaOutput) ){\n          pTS->aaOutput[iOut] = aMerge;\n          pTS->anOutput[iOut] = nMerge;\n        }\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Append SegReader object pNew to the end of the pCsr->apSegment[] array.\n*/\nstatic int fts3SegReaderCursorAppend(\n  Fts3MultiSegReader *pCsr, \n  Fts3SegReader *pNew\n){\n  if( (pCsr->nSegment%16)==0 ){\n    Fts3SegReader **apNew;\n    int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);\n    apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);\n    if( !apNew ){\n      sqlite3Fts3SegReaderFree(pNew);\n      return SQLITE_NOMEM;\n    }\n    pCsr->apSegment = apNew;\n  }\n  pCsr->apSegment[pCsr->nSegment++] = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add seg-reader objects to the Fts3MultiSegReader object passed as the\n** 8th argument.\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nstatic int fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc = SQLITE_OK;             /* Error code */\n  sqlite3_stmt *pStmt = 0;        /* Statement to iterate through segments */\n  int rc2;                        /* Result of sqlite3_reset() */\n\n  /* If iLevel is less than 0 and this is not a scan, include a seg-reader \n  ** for the pending-terms. If this is a scan, then this call must be being\n  ** made by an fts4aux module, not an FTS table. In this case calling\n  ** Fts3SegReaderPending might segfault, as the data structures used by \n  ** fts4aux are not completely populated. So it's easiest to filter these\n  ** calls out here.  */\n  if( iLevel<0 && p->aIndex ){\n    Fts3SegReader *pSeg = 0;\n    rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix, &pSeg);\n    if( rc==SQLITE_OK && pSeg ){\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3AllSegdirs(p, iLangid, iIndex, iLevel, &pStmt);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n      Fts3SegReader *pSeg = 0;\n\n      /* Read the values returned by the SELECT into local variables. */\n      sqlite3_int64 iStartBlock = sqlite3_column_int64(pStmt, 1);\n      sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);\n      int nRoot = sqlite3_column_bytes(pStmt, 4);\n      char const *zRoot = sqlite3_column_blob(pStmt, 4);\n\n      /* If zTerm is not NULL, and this segment is not stored entirely on its\n      ** root node, the range of leaves scanned can be reduced. Do this. */\n      if( iStartBlock && zTerm ){\n        sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);\n        if( rc!=SQLITE_OK ) goto finished;\n        if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;\n      }\n \n      rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, \n          (isPrefix==0 && isScan==0),\n          iStartBlock, iLeavesEndBlock, \n          iEndBlock, zRoot, nRoot, &pSeg\n      );\n      if( rc!=SQLITE_OK ) goto finished;\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n finished:\n  rc2 = sqlite3_reset(pStmt);\n  if( rc==SQLITE_DONE ) rc = rc2;\n\n  return rc;\n}\n\n/*\n** Set up a cursor object for iterating through a full-text index or a \n** single level therein.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language-id to search */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr       /* Cursor object to populate */\n){\n  assert( iIndex>=0 && iIndex<p->nIndex );\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n      ||  iLevel==FTS3_SEGCURSOR_PENDING \n      ||  iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );\n  assert( isPrefix==0 || isScan==0 );\n\n  memset(pCsr, 0, sizeof(Fts3MultiSegReader));\n  return fts3SegReaderCursor(\n      p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr\n  );\n}\n\n/*\n** In addition to its current configuration, have the Fts3MultiSegReader\n** passed as the 4th argument also scan the doclist for term zTerm/nTerm.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3SegReaderCursorAddZero(\n  Fts3Table *p,                   /* FTS virtual table handle */\n  int iLangid,\n  const char *zTerm,              /* Term to scan doclist of */\n  int nTerm,                      /* Number of bytes in zTerm */\n  Fts3MultiSegReader *pCsr        /* Fts3MultiSegReader to modify */\n){\n  return fts3SegReaderCursor(p, \n      iLangid, 0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0,pCsr\n  );\n}\n\n/*\n** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,\n** if isPrefix is true, to scan the doclist for all terms for which \n** zTerm/nTerm is a prefix. If successful, return SQLITE_OK and write\n** a pointer to the new Fts3MultiSegReader to *ppSegcsr. Otherwise, return\n** an SQLite error code.\n**\n** It is the responsibility of the caller to free this object by eventually\n** passing it to fts3SegReaderCursorFree() \n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n** Output parameter *ppSegcsr is set to 0 if an error occurs.\n*/\nstatic int fts3TermSegReaderCursor(\n  Fts3Cursor *pCsr,               /* Virtual table cursor handle */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  Fts3MultiSegReader **ppSegcsr   /* OUT: Allocated seg-reader cursor */\n){\n  Fts3MultiSegReader *pSegcsr;    /* Object to allocate and return */\n  int rc = SQLITE_NOMEM;          /* Return code */\n\n  pSegcsr = sqlite3_malloc(sizeof(Fts3MultiSegReader));\n  if( pSegcsr ){\n    int i;\n    int bFound = 0;               /* True once an index has been found */\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n\n    if( isPrefix ){\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0, pSegcsr\n          );\n          pSegcsr->bLookup = 1;\n        }\n      }\n\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm+1 ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 1, 0, pSegcsr\n          );\n          if( rc==SQLITE_OK ){\n            rc = fts3SegReaderCursorAddZero(\n                p, pCsr->iLangid, zTerm, nTerm, pSegcsr\n            );\n          }\n        }\n      }\n    }\n\n    if( bFound==0 ){\n      rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n          0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, isPrefix, 0, pSegcsr\n      );\n      pSegcsr->bLookup = !isPrefix;\n    }\n  }\n\n  *ppSegcsr = pSegcsr;\n  return rc;\n}\n\n/*\n** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().\n*/\nstatic void fts3SegReaderCursorFree(Fts3MultiSegReader *pSegcsr){\n  sqlite3Fts3SegReaderFinish(pSegcsr);\n  sqlite3_free(pSegcsr);\n}\n\n/*\n** This function retrieves the doclist for the specified term (or term\n** prefix) from the database.\n*/\nstatic int fts3TermSelect(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3PhraseToken *pTok,          /* Token to query for */\n  int iColumn,                    /* Column to query (or -ve for all columns) */\n  int *pnOut,                     /* OUT: Size of buffer at *ppOut */\n  char **ppOut                    /* OUT: Malloced result buffer */\n){\n  int rc;                         /* Return code */\n  Fts3MultiSegReader *pSegcsr;    /* Seg-reader cursor for this term */\n  TermSelect tsc;                 /* Object for pair-wise doclist merging */\n  Fts3SegFilter filter;           /* Segment term filter configuration */\n\n  pSegcsr = pTok->pSegcsr;\n  memset(&tsc, 0, sizeof(TermSelect));\n\n  filter.flags = FTS3_SEGMENT_IGNORE_EMPTY | FTS3_SEGMENT_REQUIRE_POS\n        | (pTok->isPrefix ? FTS3_SEGMENT_PREFIX : 0)\n        | (pTok->bFirst ? FTS3_SEGMENT_FIRST : 0)\n        | (iColumn<p->nColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0);\n  filter.iCol = iColumn;\n  filter.zTerm = pTok->z;\n  filter.nTerm = pTok->n;\n\n  rc = sqlite3Fts3SegReaderStart(p, pSegcsr, &filter);\n  while( SQLITE_OK==rc\n      && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pSegcsr)) \n  ){\n    rc = fts3TermSelectMerge(p, &tsc, pSegcsr->aDoclist, pSegcsr->nDoclist);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3TermSelectFinishMerge(p, &tsc);\n  }\n  if( rc==SQLITE_OK ){\n    *ppOut = tsc.aaOutput[0];\n    *pnOut = tsc.anOutput[0];\n  }else{\n    int i;\n    for(i=0; i<SizeofArray(tsc.aaOutput); i++){\n      sqlite3_free(tsc.aaOutput[i]);\n    }\n  }\n\n  fts3SegReaderCursorFree(pSegcsr);\n  pTok->pSegcsr = 0;\n  return rc;\n}\n\n/*\n** This function counts the total number of docids in the doclist stored\n** in buffer aList[], size nList bytes.\n**\n** If the isPoslist argument is true, then it is assumed that the doclist\n** contains a position-list following each docid. Otherwise, it is assumed\n** that the doclist is simply a list of docids stored as delta encoded \n** varints.\n*/\nstatic int fts3DoclistCountDocids(char *aList, int nList){\n  int nDoc = 0;                   /* Return value */\n  if( aList ){\n    char *aEnd = &aList[nList];   /* Pointer to one byte after EOF */\n    char *p = aList;              /* Cursor */\n    while( p<aEnd ){\n      nDoc++;\n      while( (*p++)&0x80 );     /* Skip docid varint */\n      fts3PoslistCopy(0, &p);   /* Skip over position list */\n    }\n  }\n\n  return nDoc;\n}\n\n/*\n** Advance the cursor to the next row in the %_content table that\n** matches the search criteria.  For a MATCH search, this will be\n** the next row that matches. For a full-table scan, this will be\n** simply the next row in the %_content table.  For a docid lookup,\n** this routine simply sets the EOF flag.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts3EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts3NextMethod(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){\n      pCsr->isEof = 1;\n      rc = sqlite3_reset(pCsr->pStmt);\n    }else{\n      pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);\n      rc = SQLITE_OK;\n    }\n  }else{\n    rc = fts3EvalNext((Fts3Cursor *)pCursor);\n  }\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against\n** the %_content table.\n**\n** If idxNum==FTS3_DOCID_SEARCH then do a docid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-FTS3_FULLTEXT_SEARCH, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\nstatic int fts3FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc;\n  char *zSql;                     /* SQL statement used to access %_content */\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  assert( idxNum>=0 && idxNum<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );\n  assert( nVal==0 || nVal==1 || nVal==2 );\n  assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );\n  assert( p->pSegments==0 );\n\n  /* In case the cursor has been used before, clear it now. */\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr->aDoclist);\n  sqlite3Fts3ExprFree(pCsr->pExpr);\n  memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));\n\n  if( idxStr ){\n    pCsr->bDesc = (idxStr[0]=='D');\n  }else{\n    pCsr->bDesc = p->bDescIdx;\n  }\n  pCsr->eSearch = (i16)idxNum;\n\n  if( idxNum!=FTS3_DOCID_SEARCH && idxNum!=FTS3_FULLSCAN_SEARCH ){\n    int iCol = idxNum-FTS3_FULLTEXT_SEARCH;\n    const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);\n\n    if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n\n    pCsr->iLangid = 0;\n    if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);\n\n    assert( p->base.zErrMsg==0 );\n    rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,\n        p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr, \n        &p->base.zErrMsg\n    );\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    rc = sqlite3Fts3ReadLock(p);\n    if( rc!=SQLITE_OK ) return rc;\n\n    rc = fts3EvalStart(pCsr);\n\n    sqlite3Fts3SegmentsClose(p);\n    if( rc!=SQLITE_OK ) return rc;\n    pCsr->pNextId = pCsr->aDoclist;\n    pCsr->iPrevId = 0;\n  }\n\n  /* Compile a SELECT statement for this cursor. For a full-table-scan, the\n  ** statement loops through all rows of the %_content table. For a\n  ** full-text query or docid lookup, the statement retrieves a single\n  ** row by docid.\n  */\n  if( idxNum==FTS3_FULLSCAN_SEARCH ){\n    zSql = sqlite3_mprintf(\n        \"SELECT %s ORDER BY rowid %s\",\n        p->zReadExprlist, (pCsr->bDesc ? \"DESC\" : \"ASC\")\n    );\n    if( zSql ){\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);\n      sqlite3_free(zSql);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }else if( idxNum==FTS3_DOCID_SEARCH ){\n    rc = fts3CursorSeekStmt(pCsr, &pCsr->pStmt);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);\n    }\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fts3NextMethod(pCursor);\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts3EofMethod(sqlite3_vtab_cursor *pCursor){\n  return ((Fts3Cursor *)pCursor)->isEof;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts3\n** exposes %_content.docid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts3RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  *pRowid = pCsr->iPrevId;\n  return SQLITE_OK;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n**\n** If:\n**\n**   (iCol <  p->nColumn)   -> The value of the iCol'th user column.\n**   (iCol == p->nColumn)   -> Magic column with the same name as the table.\n**   (iCol == p->nColumn+1) -> Docid column\n**   (iCol == p->nColumn+2) -> Langid column\n*/\nstatic int fts3ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n\n  /* The column value supplied by SQLite must be in range. */\n  assert( iCol>=0 && iCol<=p->nColumn+2 );\n\n  if( iCol==p->nColumn+1 ){\n    /* This call is a request for the \"docid\" column. Since \"docid\" is an \n    ** alias for \"rowid\", use the xRowid() method to obtain the value.\n    */\n    sqlite3_result_int64(pCtx, pCsr->iPrevId);\n  }else if( iCol==p->nColumn ){\n    /* The extra column whose name is the same as the table.\n    ** Return a blob which is a pointer to the cursor.  */\n    sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);\n  }else if( iCol==p->nColumn+2 && pCsr->pExpr ){\n    sqlite3_result_int64(pCtx, pCsr->iLangid);\n  }else{\n    /* The requested column is either a user column (one that contains \n    ** indexed data), or the language-id column.  */\n    rc = fts3CursorSeek(0, pCsr);\n\n    if( rc==SQLITE_OK ){\n      if( iCol==p->nColumn+2 ){\n        int iLangid = 0;\n        if( p->zLanguageid ){\n          iLangid = sqlite3_column_int(pCsr->pStmt, p->nColumn+1);\n        }\n        sqlite3_result_int(pCtx, iLangid);\n      }else if( sqlite3_data_count(pCsr->pStmt)>(iCol+1) ){\n        sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n      }\n    }\n  }\n\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n*/\nstatic int fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  return sqlite3Fts3UpdateMethod(pVtab, nArg, apVal, pRowid);\n}\n\n/*\n** Implementation of xSync() method. Flush the contents of the pending-terms\n** hash-table to the database.\n*/\nstatic int fts3SyncMethod(sqlite3_vtab *pVtab){\n\n  /* Following an incremental-merge operation, assuming that the input\n  ** segments are not completely consumed (the usual case), they are updated\n  ** in place to remove the entries that have already been merged. This\n  ** involves updating the leaf block that contains the smallest unmerged\n  ** entry and each block (if any) between the leaf and the root node. So\n  ** if the height of the input segment b-trees is N, and input segments\n  ** are merged eight at a time, updating the input segments at the end\n  ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually\n  ** small - often between 0 and 2. So the overhead of the incremental\n  ** merge is somewhere between 8 and 24 blocks. To avoid this overhead\n  ** dwarfing the actual productive work accomplished, the incremental merge\n  ** is only attempted if it will write at least 64 leaf blocks. Hence\n  ** nMinMerge.\n  **\n  ** Of course, updating the input segments also involves deleting a bunch\n  ** of blocks from the segments table. But this is not considered overhead\n  ** as it would also be required by a crisis-merge that used the same input \n  ** segments.\n  */\n  const u32 nMinMerge = 64;       /* Minimum amount of incr-merge work to do */\n\n  Fts3Table *p = (Fts3Table*)pVtab;\n  int rc = sqlite3Fts3PendingTermsFlush(p);\n\n  if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){\n    int mxLevel = 0;              /* Maximum relative level value in db */\n    int A;                        /* Incr-merge parameter A */\n\n    rc = sqlite3Fts3MaxLevel(p, &mxLevel);\n    assert( rc==SQLITE_OK || mxLevel==0 );\n    A = p->nLeafAdd * mxLevel;\n    A += (A/2);\n    if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);\n  }\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. This is a no-op.\n*/\nstatic int fts3BeginMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(pVtab);\n  assert( p->pSegments==0 );\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=1 );\n  TESTONLY( p->inTransaction = 1 );\n  TESTONLY( p->mxSavepoint = -1; );\n  p->nLeafAdd = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts3SyncMethod().\n*/\nstatic int fts3CommitMethod(sqlite3_vtab *pVtab){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(pVtab);\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=0 );\n  assert( p->pSegments==0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts3RollbackMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  sqlite3Fts3PendingTermsClear(p);\n  assert( p->inTransaction!=0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** When called, *ppPoslist must point to the byte immediately following the\n** end of a position-list. i.e. ( (*ppPoslist)[-1]==POS_END ). This function\n** moves *ppPoslist so that it instead points to the first byte of the\n** same position list.\n*/\nstatic void fts3ReversePoslist(char *pStart, char **ppPoslist){\n  char *p = &(*ppPoslist)[-2];\n  char c = 0;\n\n  while( p>pStart && (c=*p--)==0 );\n  while( p>pStart && (*p & 0x80) | c ){ \n    c = *p--; \n  }\n  if( p>pStart ){ p = &p[2]; }\n  while( *p++&0x80 );\n  *ppPoslist = p;\n}\n\n/*\n** Helper function used by the implementation of the overloaded snippet(),\n** offsets() and optimize() SQL functions.\n**\n** If the value passed as the third argument is a blob of size\n** sizeof(Fts3Cursor*), then the blob contents are copied to the \n** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error\n** message is written to context pContext and SQLITE_ERROR returned. The\n** string passed via zFunc is used as part of the error message.\n*/\nstatic int fts3FunctionArg(\n  sqlite3_context *pContext,      /* SQL function call context */\n  const char *zFunc,              /* Function name */\n  sqlite3_value *pVal,            /* argv[0] passed to function */\n  Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */\n){\n  Fts3Cursor *pRet;\n  if( sqlite3_value_type(pVal)!=SQLITE_BLOB \n   || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *)\n  ){\n    char *zErr = sqlite3_mprintf(\"illegal first argument to %s\", zFunc);\n    sqlite3_result_error(pContext, zErr, -1);\n    sqlite3_free(zErr);\n    return SQLITE_ERROR;\n  }\n  memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *));\n  *ppCsr = pRet;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of the snippet() function for FTS3\n*/\nstatic void fts3SnippetFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of apVal[] array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  const char *zStart = \"<b>\";\n  const char *zEnd = \"</b>\";\n  const char *zEllipsis = \"<b>...</b>\";\n  int iCol = -1;\n  int nToken = 15;                /* Default number of tokens in snippet */\n\n  /* There must be at least one argument passed to this function (otherwise\n  ** the non-overloaded version would have been called instead of this one).\n  */\n  assert( nVal>=1 );\n\n  if( nVal>6 ){\n    sqlite3_result_error(pContext, \n        \"wrong number of arguments to function snippet()\", -1);\n    return;\n  }\n  if( fts3FunctionArg(pContext, \"snippet\", apVal[0], &pCsr) ) return;\n\n  switch( nVal ){\n    case 6: nToken = sqlite3_value_int(apVal[5]);\n    case 5: iCol = sqlite3_value_int(apVal[4]);\n    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);\n    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);\n    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);\n  }\n  if( !zEllipsis || !zEnd || !zStart ){\n    sqlite3_result_error_nomem(pContext);\n  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS3\n*/\nstatic void fts3OffsetsFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"offsets\", apVal[0], &pCsr) ) return;\n  assert( pCsr );\n  if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Offsets(pContext, pCsr);\n  }\n}\n\n/* \n** Implementation of the special optimize() function for FTS3. This \n** function merges all segments in the database to a single segment.\n** Example usage is:\n**\n**   SELECT optimize(t) FROM t LIMIT 1;\n**\n** where 't' is the name of an FTS3 table.\n*/\nstatic void fts3OptimizeFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  int rc;                         /* Return code */\n  Fts3Table *p;                   /* Virtual table handle */\n  Fts3Cursor *pCursor;            /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"optimize\", apVal[0], &pCursor) ) return;\n  p = (Fts3Table *)pCursor->base.pVtab;\n  assert( p );\n\n  rc = sqlite3Fts3Optimize(p);\n\n  switch( rc ){\n    case SQLITE_OK:\n      sqlite3_result_text(pContext, \"Index optimized\", -1, SQLITE_STATIC);\n      break;\n    case SQLITE_DONE:\n      sqlite3_result_text(pContext, \"Index already optimal\", -1, SQLITE_STATIC);\n      break;\n    default:\n      sqlite3_result_error_code(pContext, rc);\n      break;\n  }\n}\n\n/*\n** Implementation of the matchinfo() function for FTS3\n*/\nstatic void fts3MatchinfoFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  assert( nVal==1 || nVal==2 );\n  if( SQLITE_OK==fts3FunctionArg(pContext, \"matchinfo\", apVal[0], &pCsr) ){\n    const char *zArg = 0;\n    if( nVal>1 ){\n      zArg = (const char *)sqlite3_value_text(apVal[1]);\n    }\n    sqlite3Fts3Matchinfo(pContext, pCsr, zArg);\n  }\n}\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts3FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* Unused */\n){\n  struct Overloaded {\n    const char *zName;\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aOverload[] = {\n    { \"snippet\", fts3SnippetFunc },\n    { \"offsets\", fts3OffsetsFunc },\n    { \"optimize\", fts3OptimizeFunc },\n    { \"matchinfo\", fts3MatchinfoFunc },\n  };\n  int i;                          /* Iterator variable */\n\n  UNUSED_PARAMETER(pVtab);\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(ppArg);\n\n  for(i=0; i<SizeofArray(aOverload); i++){\n    if( strcmp(zName, aOverload[i].zName)==0 ){\n      *pxFunc = aOverload[i].xFunc;\n      return 1;\n    }\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS3 xRename method. Rename an fts3 table.\n*/\nstatic int fts3RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  sqlite3 *db = p->db;            /* Database connection */\n  int rc;                         /* Return Code */\n\n  /* As it happens, the pending terms table is always empty here. This is\n  ** because an \"ALTER TABLE RENAME TABLE\" statement inside a transaction \n  ** always opens a savepoint transaction. And the xSavepoint() method \n  ** flushes the pending terms table. But leave the (no-op) call to\n  ** PendingTermsFlush() in in case that changes.\n  */\n  assert( p->nPendingData==0 );\n  rc = sqlite3Fts3PendingTermsFlush(p);\n\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\",\n      p->zDb, p->zName, zName\n    );\n  }\n\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_docsize'  RENAME TO '%q_docsize';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  if( p->bHasStat ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_stat'  RENAME TO '%q_stat';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';\",\n    p->zDb, p->zName, zName\n  );\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';\",\n    p->zDb, p->zName, zName\n  );\n  return rc;\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( ((Fts3Table *)pVtab)->inTransaction );\n  assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );\n  TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );\n  if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){\n    rc = fts3SyncMethod(pVtab);\n  }\n  return rc;\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(iSavepoint);\n  UNUSED_PARAMETER(pVtab);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint-1 );\n  return SQLITE_OK;\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint );\n  sqlite3Fts3PendingTermsClear(p);\n  return SQLITE_OK;\n}\n\nstatic const sqlite3_module fts3Module = {\n  /* iVersion      */ 2,\n  /* xCreate       */ fts3CreateMethod,\n  /* xConnect      */ fts3ConnectMethod,\n  /* xBestIndex    */ fts3BestIndexMethod,\n  /* xDisconnect   */ fts3DisconnectMethod,\n  /* xDestroy      */ fts3DestroyMethod,\n  /* xOpen         */ fts3OpenMethod,\n  /* xClose        */ fts3CloseMethod,\n  /* xFilter       */ fts3FilterMethod,\n  /* xNext         */ fts3NextMethod,\n  /* xEof          */ fts3EofMethod,\n  /* xColumn       */ fts3ColumnMethod,\n  /* xRowid        */ fts3RowidMethod,\n  /* xUpdate       */ fts3UpdateMethod,\n  /* xBegin        */ fts3BeginMethod,\n  /* xSync         */ fts3SyncMethod,\n  /* xCommit       */ fts3CommitMethod,\n  /* xRollback     */ fts3RollbackMethod,\n  /* xFindFunction */ fts3FindFunctionMethod,\n  /* xRename */       fts3RenameMethod,\n  /* xSavepoint    */ fts3SavepointMethod,\n  /* xRelease      */ fts3ReleaseMethod,\n  /* xRollbackTo   */ fts3RollbackToMethod,\n};\n\n/*\n** This function is registered as the module destructor (called when an\n** FTS3 enabled database connection is closed). It frees the memory\n** allocated for the tokenizer hash table.\n*/\nstatic void hashDestroy(void *p){\n  Fts3Hash *pHash = (Fts3Hash *)p;\n  sqlite3Fts3HashClear(pHash);\n  sqlite3_free(pHash);\n}\n\n/*\n** The fts3 built-in tokenizers - \"simple\", \"porter\" and \"icu\"- are \n** implemented in files fts3_tokenizer1.c, fts3_porter.c and fts3_icu.c\n** respectively. The following three forward declarations are for functions\n** declared in these files used to retrieve the respective implementations.\n**\n** Calling sqlite3Fts3SimpleTokenizerModule() sets the value pointed\n** to by the argument to point to the \"simple\" tokenizer implementation.\n** And so on.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule);\n#endif\n#ifdef SQLITE_ENABLE_ICU\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#endif\n\n/*\n** Initialize the fts3 extension. If this extension is built as part\n** of the sqlite library, then this function is called directly by\n** SQLite. If fts3 is built as a dynamically loadable extension, this\n** function is called by the sqlite3_extension_init() entry point.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  Fts3Hash *pHash = 0;\n  const sqlite3_tokenizer_module *pSimple = 0;\n  const sqlite3_tokenizer_module *pPorter = 0;\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\n  const sqlite3_tokenizer_module *pUnicode = 0;\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  const sqlite3_tokenizer_module *pIcu = 0;\n  sqlite3Fts3IcuTokenizerModule(&pIcu);\n#endif\n\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\n  sqlite3Fts3UnicodeTokenizer(&pUnicode);\n#endif\n\n#ifdef SQLITE_TEST\n  rc = sqlite3Fts3InitTerm(db);\n  if( rc!=SQLITE_OK ) return rc;\n#endif\n\n  rc = sqlite3Fts3InitAux(db);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3Fts3SimpleTokenizerModule(&pSimple);\n  sqlite3Fts3PorterTokenizerModule(&pPorter);\n\n  /* Allocate and initialize the hash-table used to store tokenizers. */\n  pHash = sqlite3_malloc(sizeof(Fts3Hash));\n  if( !pHash ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n  }\n\n  /* Load the built-in tokenizers into the hash table */\n  if( rc==SQLITE_OK ){\n    if( sqlite3Fts3HashInsert(pHash, \"simple\", 7, (void *)pSimple)\n     || sqlite3Fts3HashInsert(pHash, \"porter\", 7, (void *)pPorter) \n\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\n     || sqlite3Fts3HashInsert(pHash, \"unicode61\", 10, (void *)pUnicode) \n#endif\n#ifdef SQLITE_ENABLE_ICU\n     || (pIcu && sqlite3Fts3HashInsert(pHash, \"icu\", 4, (void *)pIcu))\n#endif\n    ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3ExprInitTestInterface(db);\n  }\n#endif\n\n  /* Create the virtual table wrapper around the hash-table and overload \n  ** the two scalar functions. If this is successful, register the\n  ** module with sqlite.\n  */\n  if( SQLITE_OK==rc \n   && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, \"fts3_tokenizer\"))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"snippet\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"offsets\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 2))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"optimize\", 1))\n  ){\n    rc = sqlite3_create_module_v2(\n        db, \"fts3\", &fts3Module, (void *)pHash, hashDestroy\n    );\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_module_v2(\n          db, \"fts4\", &fts3Module, (void *)pHash, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3InitTok(db, (void *)pHash);\n    }\n    return rc;\n  }\n\n\n  /* An error has occurred. Delete the hash table and return the error code. */\n  assert( rc!=SQLITE_OK );\n  if( pHash ){\n    sqlite3Fts3HashClear(pHash);\n    sqlite3_free(pHash);\n  }\n  return rc;\n}\n\n/*\n** Allocate an Fts3MultiSegReader for each token in the expression headed\n** by pExpr. \n**\n** An Fts3SegReader object is a cursor that can seek or scan a range of\n** entries within a single segment b-tree. An Fts3MultiSegReader uses multiple\n** Fts3SegReader objects internally to provide an interface to seek or scan\n** within the union of all segments of a b-tree. Hence the name.\n**\n** If the allocated Fts3MultiSegReader just seeks to a single entry in a\n** segment b-tree (if the term is not a prefix or it is a prefix for which\n** there exists prefix b-tree of the right length) then it may be traversed\n** and merged incrementally. Otherwise, it has to be merged into an in-memory \n** doclist and then traversed.\n*/\nstatic void fts3EvalAllocateReaders(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Allocate readers for this expression */\n  int *pnToken,                   /* OUT: Total number of tokens in phrase. */\n  int *pnOr,                      /* OUT: Total number of OR nodes in expr. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int i;\n      int nToken = pExpr->pPhrase->nToken;\n      *pnToken += nToken;\n      for(i=0; i<nToken; i++){\n        Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];\n        int rc = fts3TermSegReaderCursor(pCsr, \n            pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr\n        );\n        if( rc!=SQLITE_OK ){\n          *pRc = rc;\n          return;\n        }\n      }\n      assert( pExpr->pPhrase->iDoclistToken==0 );\n      pExpr->pPhrase->iDoclistToken = -1;\n    }else{\n      *pnOr += (pExpr->eType==FTSQUERY_OR);\n      fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);\n      fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);\n    }\n  }\n}\n\n/*\n** Arguments pList/nList contain the doclist for token iToken of phrase p.\n** It is merged into the main doclist stored in p->doclist.aAll/nAll.\n**\n** This function assumes that pList points to a buffer allocated using\n** sqlite3_malloc(). This function takes responsibility for eventually\n** freeing the buffer.\n*/\nstatic void fts3EvalPhraseMergeToken(\n  Fts3Table *pTab,                /* FTS Table pointer */\n  Fts3Phrase *p,                  /* Phrase to merge pList/nList into */\n  int iToken,                     /* Token pList/nList corresponds to */\n  char *pList,                    /* Pointer to doclist */\n  int nList                       /* Number of bytes in pList */\n){\n  assert( iToken!=p->iDoclistToken );\n\n  if( pList==0 ){\n    sqlite3_free(p->doclist.aAll);\n    p->doclist.aAll = 0;\n    p->doclist.nAll = 0;\n  }\n\n  else if( p->iDoclistToken<0 ){\n    p->doclist.aAll = pList;\n    p->doclist.nAll = nList;\n  }\n\n  else if( p->doclist.aAll==0 ){\n    sqlite3_free(pList);\n  }\n\n  else {\n    char *pLeft;\n    char *pRight;\n    int nLeft;\n    int nRight;\n    int nDiff;\n\n    if( p->iDoclistToken<iToken ){\n      pLeft = p->doclist.aAll;\n      nLeft = p->doclist.nAll;\n      pRight = pList;\n      nRight = nList;\n      nDiff = iToken - p->iDoclistToken;\n    }else{\n      pRight = p->doclist.aAll;\n      nRight = p->doclist.nAll;\n      pLeft = pList;\n      nLeft = nList;\n      nDiff = p->iDoclistToken - iToken;\n    }\n\n    fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);\n    sqlite3_free(pLeft);\n    p->doclist.aAll = pRight;\n    p->doclist.nAll = nRight;\n  }\n\n  if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;\n}\n\n/*\n** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist\n** does not take deferred tokens into account.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseLoad(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p                   /* Phrase object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int iToken;\n  int rc = SQLITE_OK;\n\n  for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){\n    Fts3PhraseToken *pToken = &p->aToken[iToken];\n    assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );\n\n    if( pToken->pSegcsr ){\n      int nThis = 0;\n      char *pThis = 0;\n      rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);\n      if( rc==SQLITE_OK ){\n        fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);\n      }\n    }\n    assert( pToken->pSegcsr==0 );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called on each phrase after the position lists for\n** any deferred tokens have been loaded into memory. It updates the phrases\n** current position list to include only those positions that are really\n** instances of the phrase (after considering deferred tokens). If this\n** means that the phrase does not appear in the current row, doclist.pList\n** and doclist.nList are both zeroed.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){\n  int iToken;                     /* Used to iterate through phrase tokens */\n  char *aPoslist = 0;             /* Position list for deferred tokens */\n  int nPoslist = 0;               /* Number of bytes in aPoslist */\n  int iPrev = -1;                 /* Token number of previous deferred token */\n\n  assert( pPhrase->doclist.bFreeList==0 );\n\n  for(iToken=0; iToken<pPhrase->nToken; iToken++){\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    Fts3DeferredToken *pDeferred = pToken->pDeferred;\n\n    if( pDeferred ){\n      char *pList;\n      int nList;\n      int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList);\n      if( rc!=SQLITE_OK ) return rc;\n\n      if( pList==0 ){\n        sqlite3_free(aPoslist);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n        return SQLITE_OK;\n\n      }else if( aPoslist==0 ){\n        aPoslist = pList;\n        nPoslist = nList;\n\n      }else{\n        char *aOut = pList;\n        char *p1 = aPoslist;\n        char *p2 = aOut;\n\n        assert( iPrev>=0 );\n        fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);\n        sqlite3_free(aPoslist);\n        aPoslist = pList;\n        nPoslist = (int)(aOut - aPoslist);\n        if( nPoslist==0 ){\n          sqlite3_free(aPoslist);\n          pPhrase->doclist.pList = 0;\n          pPhrase->doclist.nList = 0;\n          return SQLITE_OK;\n        }\n      }\n      iPrev = iToken;\n    }\n  }\n\n  if( iPrev>=0 ){\n    int nMaxUndeferred = pPhrase->iDoclistToken;\n    if( nMaxUndeferred<0 ){\n      pPhrase->doclist.pList = aPoslist;\n      pPhrase->doclist.nList = nPoslist;\n      pPhrase->doclist.iDocid = pCsr->iPrevId;\n      pPhrase->doclist.bFreeList = 1;\n    }else{\n      int nDistance;\n      char *p1;\n      char *p2;\n      char *aOut;\n\n      if( nMaxUndeferred>iPrev ){\n        p1 = aPoslist;\n        p2 = pPhrase->doclist.pList;\n        nDistance = nMaxUndeferred - iPrev;\n      }else{\n        p1 = pPhrase->doclist.pList;\n        p2 = aPoslist;\n        nDistance = iPrev - nMaxUndeferred;\n      }\n\n      aOut = (char *)sqlite3_malloc(nPoslist+8);\n      if( !aOut ){\n        sqlite3_free(aPoslist);\n        return SQLITE_NOMEM;\n      }\n      \n      pPhrase->doclist.pList = aOut;\n      if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){\n        pPhrase->doclist.bFreeList = 1;\n        pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);\n      }else{\n        sqlite3_free(aOut);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n      }\n      sqlite3_free(aPoslist);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called for each Fts3Phrase in a full-text query \n** expression to initialize the mechanism for returning rows. Once this\n** function has been called successfully on an Fts3Phrase, it may be\n** used with fts3EvalPhraseNext() to iterate through the matching docids.\n**\n** If parameter bOptOk is true, then the phrase may (or may not) use the\n** incremental loading strategy. Otherwise, the entire doclist is loaded into\n** memory within this call.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){\n  int rc;                         /* Error code */\n  Fts3PhraseToken *pFirst = &p->aToken[0];\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n\n  if( pCsr->bDesc==pTab->bDescIdx \n   && bOptOk==1 \n   && p->nToken==1 \n   && pFirst->pSegcsr \n   && pFirst->pSegcsr->bLookup \n   && pFirst->bFirst==0\n  ){\n    /* Use the incremental approach. */\n    int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);\n    rc = sqlite3Fts3MsrIncrStart(\n        pTab, pFirst->pSegcsr, iCol, pFirst->z, pFirst->n);\n    p->bIncr = 1;\n\n  }else{\n    /* Load the full doclist for the phrase into memory. */\n    rc = fts3EvalPhraseLoad(pCsr, p);\n    p->bIncr = 0;\n  }\n\n  assert( rc!=SQLITE_OK || p->nToken<1 || p->aToken[0].pSegcsr==0 || p->bIncr );\n  return rc;\n}\n\n/*\n** This function is used to iterate backwards (from the end to start) \n** through doclists. It is used by this module to iterate through phrase\n** doclists in reverse and by the fts3_write.c module to iterate through\n** pending-terms lists when writing to databases with \"order=desc\".\n**\n** The doclist may be sorted in ascending (parameter bDescIdx==0) or \n** descending (parameter bDescIdx==1) order of docid. Regardless, this\n** function iterates from the end of the doclist to the beginning.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  int *pnList,                    /* OUT: List length pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    sqlite3_int64 iDocid = 0;\n    char *pNext = 0;\n    char *pDocid = aDoclist;\n    char *pEnd = &aDoclist[nDoclist];\n    int iMul = 1;\n\n    while( pDocid<pEnd ){\n      sqlite3_int64 iDelta;\n      pDocid += sqlite3Fts3GetVarint(pDocid, &iDelta);\n      iDocid += (iMul * iDelta);\n      pNext = pDocid;\n      fts3PoslistCopy(0, &pDocid);\n      while( pDocid<pEnd && *pDocid==0 ) pDocid++;\n      iMul = (bDescIdx ? -1 : 1);\n    }\n\n    *pnList = (int)(pEnd - pNext);\n    *ppIter = pNext;\n    *piDocid = iDocid;\n  }else{\n    int iMul = (bDescIdx ? -1 : 1);\n    sqlite3_int64 iDelta;\n    fts3GetReverseVarint(&p, aDoclist, &iDelta);\n    *piDocid -= (iMul * iDelta);\n\n    if( p==aDoclist ){\n      *pbEof = 1;\n    }else{\n      char *pSave = p;\n      fts3ReversePoslist(aDoclist, &p);\n      *pnList = (int)(pSave - p);\n    }\n    *ppIter = p;\n  }\n}\n\n/*\n** Iterate forwards through a doclist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistNext(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    p = aDoclist;\n    p += sqlite3Fts3GetVarint(p, piDocid);\n  }else{\n    fts3PoslistCopy(0, &p);\n    if( p>=&aDoclist[nDoclist] ){\n      *pbEof = 1;\n    }else{\n      sqlite3_int64 iVar;\n      p += sqlite3Fts3GetVarint(p, &iVar);\n      *piDocid += ((bDescIdx ? -1 : 1) * iVar);\n    }\n  }\n\n  *ppIter = p;\n}\n\n/*\n** Attempt to move the phrase iterator to point to the next matching docid. \n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n*/\nstatic int fts3EvalPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n\n  if( p->bIncr ){\n    assert( p->nToken==1 );\n    assert( pDL->pNextDocid==0 );\n    rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, \n        &pDL->iDocid, &pDL->pList, &pDL->nList\n    );\n    if( rc==SQLITE_OK && !pDL->pList ){\n      *pbEof = 1;\n    }\n  }else if( pCsr->bDesc!=pTab->bDescIdx && pDL->nAll ){\n    sqlite3Fts3DoclistPrev(pTab->bDescIdx, pDL->aAll, pDL->nAll, \n        &pDL->pNextDocid, &pDL->iDocid, &pDL->nList, pbEof\n    );\n    pDL->pList = pDL->pNextDocid;\n  }else{\n    char *pIter;                            /* Used to iterate through aAll */\n    char *pEnd = &pDL->aAll[pDL->nAll];     /* 1 byte past end of aAll */\n    if( pDL->pNextDocid ){\n      pIter = pDL->pNextDocid;\n    }else{\n      pIter = pDL->aAll;\n    }\n\n    if( pIter>=pEnd ){\n      /* We have already reached the end of this doclist. EOF. */\n      *pbEof = 1;\n    }else{\n      sqlite3_int64 iDelta;\n      pIter += sqlite3Fts3GetVarint(pIter, &iDelta);\n      if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){\n        pDL->iDocid += iDelta;\n      }else{\n        pDL->iDocid -= iDelta;\n      }\n      pDL->pList = pIter;\n      fts3PoslistCopy(0, &pIter);\n      pDL->nList = (int)(pIter - pDL->pList);\n\n      /* pIter now points just past the 0x00 that terminates the position-\n      ** list for document pDL->iDocid. However, if this position-list was\n      ** edited in place by fts3EvalNearTrim(), then pIter may not actually\n      ** point to the start of the next docid value. The following line deals\n      ** with this case by advancing pIter past the zero-padding added by\n      ** fts3EvalNearTrim().  */\n      while( pIter<pEnd && *pIter==0 ) pIter++;\n\n      pDL->pNextDocid = pIter;\n      assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );\n      *pbEof = 0;\n    }\n  }\n\n  return rc;\n}\n\n/*\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, fts3EvalPhraseStart() is called on all phrases within the\n** expression. Also the Fts3Expr.bDeferred variable is set to true for any\n** expressions for which all descendent tokens are deferred.\n**\n** If parameter bOptOk is zero, then it is guaranteed that the\n** Fts3Phrase.doclist.aAll/nAll variables contain the entire doclist for\n** each phrase in the expression (subject to deferred token processing).\n** Or, if bOptOk is non-zero, then one or more tokens within the expression\n** may be loaded incrementally, meaning doclist.aAll/nAll is not available.\n**\n** If an error occurs within this function, *pRc is set to an SQLite error\n** code before returning.\n*/\nstatic void fts3EvalStartReaders(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expression to initialize phrases in */\n  int bOptOk,                     /* True to enable incremental loading */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int i;\n      int nToken = pExpr->pPhrase->nToken;\n      for(i=0; i<nToken; i++){\n        if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;\n      }\n      pExpr->bDeferred = (i==nToken);\n      *pRc = fts3EvalPhraseStart(pCsr, bOptOk, pExpr->pPhrase);\n    }else{\n      fts3EvalStartReaders(pCsr, pExpr->pLeft, bOptOk, pRc);\n      fts3EvalStartReaders(pCsr, pExpr->pRight, bOptOk, pRc);\n      pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);\n    }\n  }\n}\n\n/*\n** An array of the following structures is assembled as part of the process\n** of selecting tokens to defer before the query starts executing (as part\n** of the xFilter() method). There is one element in the array for each\n** token in the FTS expression.\n**\n** Tokens are divided into AND/NEAR clusters. All tokens in a cluster belong\n** to phrases that are connected only by AND and NEAR operators (not OR or\n** NOT). When determining tokens to defer, each AND/NEAR cluster is considered\n** separately. The root of a tokens AND/NEAR cluster is stored in \n** Fts3TokenAndCost.pRoot.\n*/\ntypedef struct Fts3TokenAndCost Fts3TokenAndCost;\nstruct Fts3TokenAndCost {\n  Fts3Phrase *pPhrase;            /* The phrase the token belongs to */\n  int iToken;                     /* Position of token in phrase */\n  Fts3PhraseToken *pToken;        /* The token itself */\n  Fts3Expr *pRoot;                /* Root of NEAR/AND cluster */\n  int nOvfl;                      /* Number of overflow pages to load doclist */\n  int iCol;                       /* The column the token must match */\n};\n\n/*\n** This function is used to populate an allocated Fts3TokenAndCost array.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if an error occurs during execution, *pRc is set to an\n** SQLite error code.\n*/\nstatic void fts3EvalTokenCosts(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Root of current AND/NEAR cluster */\n  Fts3Expr *pExpr,                /* Expression to consider */\n  Fts3TokenAndCost **ppTC,        /* Write new entries to *(*ppTC)++ */\n  Fts3Expr ***ppOr,               /* Write new OR root to *(*ppOr)++ */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){\n        Fts3TokenAndCost *pTC = (*ppTC)++;\n        pTC->pPhrase = pPhrase;\n        pTC->iToken = i;\n        pTC->pRoot = pRoot;\n        pTC->pToken = &pPhrase->aToken[i];\n        pTC->iCol = pPhrase->iColumn;\n        *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);\n      }\n    }else if( pExpr->eType!=FTSQUERY_NOT ){\n      assert( pExpr->eType==FTSQUERY_OR\n           || pExpr->eType==FTSQUERY_AND\n           || pExpr->eType==FTSQUERY_NEAR\n      );\n      assert( pExpr->pLeft && pExpr->pRight );\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pLeft;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pRight;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);\n    }\n  }\n}\n\n/*\n** Determine the average document (row) size in pages. If successful,\n** write this value to *pnPage and return SQLITE_OK. Otherwise, return\n** an SQLite error code.\n**\n** The average document size in pages is calculated by first calculating \n** determining the average size in bytes, B. If B is less than the amount\n** of data that will fit on a single leaf page of an intkey table in\n** this database, then the average docsize is 1. Otherwise, it is 1 plus\n** the number of overflow pages consumed by a record B bytes in size.\n*/\nstatic int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){\n  if( pCsr->nRowAvg==0 ){\n    /* The average document size, which is required to calculate the cost\n    ** of each doclist, has not yet been determined. Read the required \n    ** data from the %_stat table to calculate it.\n    **\n    ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3 \n    ** varints, where nCol is the number of columns in the FTS3 table.\n    ** The first varint is the number of documents currently stored in\n    ** the table. The following nCol varints contain the total amount of\n    ** data stored in all rows of each column of the table, from left\n    ** to right.\n    */\n    int rc;\n    Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n    sqlite3_stmt *pStmt;\n    sqlite3_int64 nDoc = 0;\n    sqlite3_int64 nByte = 0;\n    const char *pEnd;\n    const char *a;\n\n    rc = sqlite3Fts3SelectDoctotal(p, &pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n    a = sqlite3_column_blob(pStmt, 0);\n    assert( a );\n\n    pEnd = &a[sqlite3_column_bytes(pStmt, 0)];\n    a += sqlite3Fts3GetVarint(a, &nDoc);\n    while( a<pEnd ){\n      a += sqlite3Fts3GetVarint(a, &nByte);\n    }\n    if( nDoc==0 || nByte==0 ){\n      sqlite3_reset(pStmt);\n      return FTS_CORRUPT_VTAB;\n    }\n\n    pCsr->nDoc = nDoc;\n    pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz);\n    assert( pCsr->nRowAvg>0 ); \n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  *pnPage = pCsr->nRowAvg;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called to select the tokens (if any) that will be \n** deferred. The array aTC[] has already been populated when this is\n** called.\n**\n** This function is called once for each AND/NEAR cluster in the \n** expression. Each invocation determines which tokens to defer within\n** the cluster with root node pRoot. See comments above the definition\n** of struct Fts3TokenAndCost for more details.\n**\n** If no error occurs, SQLITE_OK is returned and sqlite3Fts3DeferToken()\n** called on each token to defer. Otherwise, an SQLite error code is\n** returned.\n*/\nstatic int fts3EvalSelectDeferred(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Consider tokens with this root node */\n  Fts3TokenAndCost *aTC,          /* Array of expression tokens and costs */\n  int nTC                         /* Number of entries in aTC[] */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int nDocSize = 0;               /* Number of pages per doc loaded */\n  int rc = SQLITE_OK;             /* Return code */\n  int ii;                         /* Iterator variable for various purposes */\n  int nOvfl = 0;                  /* Total overflow pages used by doclists */\n  int nToken = 0;                 /* Total number of tokens in cluster */\n\n  int nMinEst = 0;                /* The minimum count for any phrase so far. */\n  int nLoad4 = 1;                 /* (Phrases that will be loaded)^4. */\n\n  /* Tokens are never deferred for FTS tables created using the content=xxx\n  ** option. The reason being that it is not guaranteed that the content\n  ** table actually contains the same data as the index. To prevent this from\n  ** causing any problems, the deferred token optimization is completely\n  ** disabled for content=xxx tables. */\n  if( pTab->zContentTbl ){\n    return SQLITE_OK;\n  }\n\n  /* Count the tokens in this AND/NEAR cluster. If none of the doclists\n  ** associated with the tokens spill onto overflow pages, or if there is\n  ** only 1 token, exit early. No tokens to defer in this case. */\n  for(ii=0; ii<nTC; ii++){\n    if( aTC[ii].pRoot==pRoot ){\n      nOvfl += aTC[ii].nOvfl;\n      nToken++;\n    }\n  }\n  if( nOvfl==0 || nToken<2 ) return SQLITE_OK;\n\n  /* Obtain the average docsize (in pages). */\n  rc = fts3EvalAverageDocsize(pCsr, &nDocSize);\n  assert( rc!=SQLITE_OK || nDocSize>0 );\n\n\n  /* Iterate through all tokens in this AND/NEAR cluster, in ascending order \n  ** of the number of overflow pages that will be loaded by the pager layer \n  ** to retrieve the entire doclist for the token from the full-text index.\n  ** Load the doclists for tokens that are either:\n  **\n  **   a. The cheapest token in the entire query (i.e. the one visited by the\n  **      first iteration of this loop), or\n  **\n  **   b. Part of a multi-token phrase.\n  **\n  ** After each token doclist is loaded, merge it with the others from the\n  ** same phrase and count the number of documents that the merged doclist\n  ** contains. Set variable \"nMinEst\" to the smallest number of documents in \n  ** any phrase doclist for which 1 or more token doclists have been loaded.\n  ** Let nOther be the number of other phrases for which it is certain that\n  ** one or more tokens will not be deferred.\n  **\n  ** Then, for each token, defer it if loading the doclist would result in\n  ** loading N or more overflow pages into memory, where N is computed as:\n  **\n  **    (nMinEst + 4^nOther - 1) / (4^nOther)\n  */\n  for(ii=0; ii<nToken && rc==SQLITE_OK; ii++){\n    int iTC;                      /* Used to iterate through aTC[] array. */\n    Fts3TokenAndCost *pTC = 0;    /* Set to cheapest remaining token. */\n\n    /* Set pTC to point to the cheapest remaining token. */\n    for(iTC=0; iTC<nTC; iTC++){\n      if( aTC[iTC].pToken && aTC[iTC].pRoot==pRoot \n       && (!pTC || aTC[iTC].nOvfl<pTC->nOvfl) \n      ){\n        pTC = &aTC[iTC];\n      }\n    }\n    assert( pTC );\n\n    if( ii && pTC->nOvfl>=((nMinEst+(nLoad4/4)-1)/(nLoad4/4))*nDocSize ){\n      /* The number of overflow pages to load for this (and therefore all\n      ** subsequent) tokens is greater than the estimated number of pages \n      ** that will be loaded if all subsequent tokens are deferred.\n      */\n      Fts3PhraseToken *pToken = pTC->pToken;\n      rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);\n      fts3SegReaderCursorFree(pToken->pSegcsr);\n      pToken->pSegcsr = 0;\n    }else{\n      /* Set nLoad4 to the value of (4^nOther) for the next iteration of the\n      ** for-loop. Except, limit the value to 2^24 to prevent it from \n      ** overflowing the 32-bit integer it is stored in. */\n      if( ii<12 ) nLoad4 = nLoad4*4;\n\n      if( ii==0 || pTC->pPhrase->nToken>1 ){\n        /* Either this is the cheapest token in the entire query, or it is\n        ** part of a multi-token phrase. Either way, the entire doclist will\n        ** (eventually) be loaded into memory. It may as well be now. */\n        Fts3PhraseToken *pToken = pTC->pToken;\n        int nList = 0;\n        char *pList = 0;\n        rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);\n        assert( rc==SQLITE_OK || pList==0 );\n        if( rc==SQLITE_OK ){\n          int nCount;\n          fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);\n          nCount = fts3DoclistCountDocids(\n              pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll\n          );\n          if( ii==0 || nCount<nMinEst ) nMinEst = nCount;\n        }\n      }\n    }\n    pTC->pToken = 0;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called from within the xFilter method. It initializes\n** the full-text query currently stored in pCsr->pExpr. To iterate through\n** the results of a query, the caller does:\n**\n**    fts3EvalStart(pCsr);\n**    while( 1 ){\n**      fts3EvalNext(pCsr);\n**      if( pCsr->bEof ) break;\n**      ... return row pCsr->iPrevId to the caller ...\n**    }\n*/\nstatic int fts3EvalStart(Fts3Cursor *pCsr){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int nToken = 0;\n  int nOr = 0;\n\n  /* Allocate a MultiSegReader for each token in the expression. */\n  fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);\n\n  /* Determine which, if any, tokens in the expression should be deferred. */\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n  if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){\n    Fts3TokenAndCost *aTC;\n    Fts3Expr **apOr;\n    aTC = (Fts3TokenAndCost *)sqlite3_malloc(\n        sizeof(Fts3TokenAndCost) * nToken\n      + sizeof(Fts3Expr *) * nOr * 2\n    );\n    apOr = (Fts3Expr **)&aTC[nToken];\n\n    if( !aTC ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int ii;\n      Fts3TokenAndCost *pTC = aTC;\n      Fts3Expr **ppOr = apOr;\n\n      fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);\n      nToken = (int)(pTC-aTC);\n      nOr = (int)(ppOr-apOr);\n\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);\n        for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){\n          rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);\n        }\n      }\n\n      sqlite3_free(aTC);\n    }\n  }\n#endif\n\n  fts3EvalStartReaders(pCsr, pCsr->pExpr, 1, &rc);\n  return rc;\n}\n\n/*\n** Invalidate the current position list for phrase pPhrase.\n*/\nstatic void fts3EvalInvalidatePoslist(Fts3Phrase *pPhrase){\n  if( pPhrase->doclist.bFreeList ){\n    sqlite3_free(pPhrase->doclist.pList);\n  }\n  pPhrase->doclist.pList = 0;\n  pPhrase->doclist.nList = 0;\n  pPhrase->doclist.bFreeList = 0;\n}\n\n/*\n** This function is called to edit the position list associated with\n** the phrase object passed as the fifth argument according to a NEAR\n** condition. For example:\n**\n**     abc NEAR/5 \"def ghi\"\n**\n** Parameter nNear is passed the NEAR distance of the expression (5 in\n** the example above). When this function is called, *paPoslist points to\n** the position list, and *pnToken is the number of phrase tokens in, the\n** phrase on the other side of the NEAR operator to pPhrase. For example,\n** if pPhrase refers to the \"def ghi\" phrase, then *paPoslist points to\n** the position list associated with phrase \"abc\".\n**\n** All positions in the pPhrase position list that are not sufficiently\n** close to a position in the *paPoslist position list are removed. If this\n** leaves 0 positions, zero is returned. Otherwise, non-zero.\n**\n** Before returning, *paPoslist is set to point to the position lsit \n** associated with pPhrase. And *pnToken is set to the number of tokens in\n** pPhrase.\n*/\nstatic int fts3EvalNearTrim(\n  int nNear,                      /* NEAR distance. As in \"NEAR/nNear\". */\n  char *aTmp,                     /* Temporary space to use */\n  char **paPoslist,               /* IN/OUT: Position list */\n  int *pnToken,                   /* IN/OUT: Tokens in phrase of *paPoslist */\n  Fts3Phrase *pPhrase             /* The phrase object to trim the doclist of */\n){\n  int nParam1 = nNear + pPhrase->nToken;\n  int nParam2 = nNear + *pnToken;\n  int nNew;\n  char *p2; \n  char *pOut; \n  int res;\n\n  assert( pPhrase->doclist.pList );\n\n  p2 = pOut = pPhrase->doclist.pList;\n  res = fts3PoslistNearMerge(\n    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2\n  );\n  if( res ){\n    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;\n    assert( pPhrase->doclist.pList[nNew]=='\\0' );\n    assert( nNew<=pPhrase->doclist.nList && nNew>0 );\n    memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);\n    pPhrase->doclist.nList = nNew;\n    *paPoslist = pPhrase->doclist.pList;\n    *pnToken = pPhrase->nToken;\n  }\n\n  return res;\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is called.\n** Otherwise, it advances the expression passed as the second argument to\n** point to the next matching row in the database. Expressions iterate through\n** matching rows in docid order. Ascending order if Fts3Cursor.bDesc is zero,\n** or descending if it is non-zero.\n**\n** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if\n** successful, the following variables in pExpr are set:\n**\n**   Fts3Expr.bEof                (non-zero if EOF - there is no next row)\n**   Fts3Expr.iDocid              (valid if bEof==0. The docid of the next row)\n**\n** If the expression is of type FTSQUERY_PHRASE, and the expression is not\n** at EOF, then the following variables are populated with the position list\n** for the phrase for the visited row:\n**\n**   FTs3Expr.pPhrase->doclist.nList        (length of pList in bytes)\n**   FTs3Expr.pPhrase->doclist.pList        (pointer to position list)\n**\n** It says above that this function advances the expression to the next\n** matching row. This is usually true, but there are the following exceptions:\n**\n**   1. Deferred tokens are not taken into account. If a phrase consists\n**      entirely of deferred tokens, it is assumed to match every row in\n**      the db. In this case the position-list is not populated at all. \n**\n**      Or, if a phrase contains one or more deferred tokens and one or\n**      more non-deferred tokens, then the expression is advanced to the \n**      next possible match, considering only non-deferred tokens. In other\n**      words, if the phrase is \"A B C\", and \"B\" is deferred, the expression\n**      is advanced to the next row that contains an instance of \"A * C\", \n**      where \"*\" may match any single token. The position list in this case\n**      is populated as for \"A * C\" before returning.\n**\n**   2. NEAR is treated as AND. If the expression is \"x NEAR y\", it is \n**      advanced to point to the next row that matches \"x AND y\".\n** \n** See fts3EvalTestDeferredAndNear() for details on testing if a row is\n** really a match, taking into account deferred tokens and NEAR operators.\n*/\nstatic void fts3EvalNextRow(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expr. to advance to next matching row */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int bDescDoclist = pCsr->bDesc;         /* Used by DOCID_CMP() macro */\n    assert( pExpr->bEof==0 );\n    pExpr->bStart = 1;\n\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        assert( !pLeft->bDeferred || !pRight->bDeferred );\n\n        if( pLeft->bDeferred ){\n          /* LHS is entirely deferred. So we assume it matches every row.\n          ** Advance the RHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          pExpr->iDocid = pRight->iDocid;\n          pExpr->bEof = pRight->bEof;\n        }else if( pRight->bDeferred ){\n          /* RHS is entirely deferred. So we assume it matches every row.\n          ** Advance the LHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = pLeft->bEof;\n        }else{\n          /* Neither the RHS or LHS are deferred. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          while( !pLeft->bEof && !pRight->bEof && *pRc==SQLITE_OK ){\n            sqlite3_int64 iDiff = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n            if( iDiff==0 ) break;\n            if( iDiff<0 ){\n              fts3EvalNextRow(pCsr, pLeft, pRc);\n            }else{\n              fts3EvalNextRow(pCsr, pRight, pRc);\n            }\n          }\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = (pLeft->bEof || pRight->bEof);\n        }\n        break;\n      }\n  \n      case FTSQUERY_OR: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n\n        assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid );\n        assert( pRight->bStart || pLeft->iDocid==pRight->iDocid );\n\n        if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n        }else if( pLeft->bEof || (pRight->bEof==0 && iCmp>0) ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }else{\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }\n\n        pExpr->bEof = (pLeft->bEof && pRight->bEof);\n        iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n        if( pRight->bEof || (pLeft->bEof==0 &&  iCmp<0) ){\n          pExpr->iDocid = pLeft->iDocid;\n        }else{\n          pExpr->iDocid = pRight->iDocid;\n        }\n\n        break;\n      }\n\n      case FTSQUERY_NOT: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n\n        if( pRight->bStart==0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          assert( *pRc!=SQLITE_OK || pRight->bStart );\n        }\n\n        fts3EvalNextRow(pCsr, pLeft, pRc);\n        if( pLeft->bEof==0 ){\n          while( !*pRc \n              && !pRight->bEof \n              && DOCID_CMP(pLeft->iDocid, pRight->iDocid)>0 \n          ){\n            fts3EvalNextRow(pCsr, pRight, pRc);\n          }\n        }\n        pExpr->iDocid = pLeft->iDocid;\n        pExpr->bEof = pLeft->bEof;\n        break;\n      }\n\n      default: {\n        Fts3Phrase *pPhrase = pExpr->pPhrase;\n        fts3EvalInvalidatePoslist(pPhrase);\n        *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);\n        pExpr->iDocid = pPhrase->doclist.iDocid;\n        break;\n      }\n    }\n  }\n}\n\n/*\n** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR\n** cluster, then this function returns 1 immediately.\n**\n** Otherwise, it checks if the current row really does match the NEAR \n** expression, using the data currently stored in the position lists \n** (Fts3Expr->pPhrase.doclist.pList/nList) for each phrase in the expression. \n**\n** If the current row is a match, the position list associated with each\n** phrase in the NEAR expression is edited in place to contain only those\n** phrase instances sufficiently close to their peers to satisfy all NEAR\n** constraints. In this case it returns 1. If the NEAR expression does not \n** match the current row, 0 is returned. The position lists may or may not\n** be edited if 0 is returned.\n*/\nstatic int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){\n  int res = 1;\n\n  /* The following block runs if pExpr is the root of a NEAR query.\n  ** For example, the query:\n  **\n  **         \"w\" NEAR \"x\" NEAR \"y\" NEAR \"z\"\n  **\n  ** which is represented in tree form as:\n  **\n  **                               |\n  **                          +--NEAR--+      <-- root of NEAR query\n  **                          |        |\n  **                     +--NEAR--+   \"z\"\n  **                     |        |\n  **                +--NEAR--+   \"y\"\n  **                |        |\n  **               \"w\"      \"x\"\n  **\n  ** The right-hand child of a NEAR node is always a phrase. The \n  ** left-hand child may be either a phrase or a NEAR node. There are\n  ** no exceptions to this - it's the way the parser in fts3_expr.c works.\n  */\n  if( *pRc==SQLITE_OK \n   && pExpr->eType==FTSQUERY_NEAR \n   && pExpr->bEof==0\n   && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n  ){\n    Fts3Expr *p; \n    int nTmp = 0;                 /* Bytes of temp space */\n    char *aTmp;                   /* Temp space for PoslistNearMerge() */\n\n    /* Allocate temporary working space. */\n    for(p=pExpr; p->pLeft; p=p->pLeft){\n      nTmp += p->pRight->pPhrase->doclist.nList;\n    }\n    nTmp += p->pPhrase->doclist.nList;\n    if( nTmp==0 ){\n      res = 0;\n    }else{\n      aTmp = sqlite3_malloc(nTmp*2);\n      if( !aTmp ){\n        *pRc = SQLITE_NOMEM;\n        res = 0;\n      }else{\n        char *aPoslist = p->pPhrase->doclist.pList;\n        int nToken = p->pPhrase->nToken;\n\n        for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){\n          Fts3Phrase *pPhrase = p->pRight->pPhrase;\n          int nNear = p->nNear;\n          res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n        }\n\n        aPoslist = pExpr->pRight->pPhrase->doclist.pList;\n        nToken = pExpr->pRight->pPhrase->nToken;\n        for(p=pExpr->pLeft; p && res; p=p->pLeft){\n          int nNear;\n          Fts3Phrase *pPhrase;\n          assert( p->pParent && p->pParent->pLeft==p );\n          nNear = p->pParent->nNear;\n          pPhrase = (\n              p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase\n              );\n          res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n        }\n      }\n\n      sqlite3_free(aTmp);\n    }\n  }\n\n  return res;\n}\n\n/*\n** This function is a helper function for fts3EvalTestDeferredAndNear().\n** Assuming no error occurs or has occurred, It returns non-zero if the\n** expression passed as the second argument matches the row that pCsr \n** currently points to, or zero if it does not.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** If an error occurs during execution of this function, *pRc is set to \n** the appropriate SQLite error code. In this case the returned value is \n** undefined.\n*/\nstatic int fts3EvalTestExpr(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Expr to test. May or may not be root. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int bHit = 1;                   /* Return value */\n  if( *pRc==SQLITE_OK ){\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n         && fts3EvalNearTest(pExpr, pRc)\n        );\n\n        /* If the NEAR expression does not match any rows, zero the doclist for \n        ** all phrases involved in the NEAR. This is because the snippet(),\n        ** offsets() and matchinfo() functions are not supposed to recognize \n        ** any instances of phrases that are part of unmatched NEAR queries. \n        ** For example if this expression:\n        **\n        **    ... MATCH 'a OR (b NEAR c)'\n        **\n        ** is matched against a row containing:\n        **\n        **        'a b d e'\n        **\n        ** then any snippet() should ony highlight the \"a\" term, not the \"b\"\n        ** (as \"b\" is part of a non-matching NEAR clause).\n        */\n        if( bHit==0 \n         && pExpr->eType==FTSQUERY_NEAR \n         && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n        ){\n          Fts3Expr *p;\n          for(p=pExpr; p->pPhrase==0; p=p->pLeft){\n            if( p->pRight->iDocid==pCsr->iPrevId ){\n              fts3EvalInvalidatePoslist(p->pRight->pPhrase);\n            }\n          }\n          if( p->iDocid==pCsr->iPrevId ){\n            fts3EvalInvalidatePoslist(p->pPhrase);\n          }\n        }\n\n        break;\n\n      case FTSQUERY_OR: {\n        int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);\n        int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);\n        bHit = bHit1 || bHit2;\n        break;\n      }\n\n      case FTSQUERY_NOT:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n        );\n        break;\n\n      default: {\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n        if( pCsr->pDeferred \n         && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)\n        ){\n          Fts3Phrase *pPhrase = pExpr->pPhrase;\n          assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );\n          if( pExpr->bDeferred ){\n            fts3EvalInvalidatePoslist(pPhrase);\n          }\n          *pRc = fts3EvalDeferredPhrase(pCsr, pPhrase);\n          bHit = (pPhrase->doclist.pList!=0);\n          pExpr->iDocid = pCsr->iPrevId;\n        }else\n#endif\n        {\n          bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);\n        }\n        break;\n      }\n    }\n  }\n  return bHit;\n}\n\n/*\n** This function is called as the second part of each xNext operation when\n** iterating through the results of a full-text query. At this point the\n** cursor points to a row that matches the query expression, with the\n** following caveats:\n**\n**   * Up until this point, \"NEAR\" operators in the expression have been\n**     treated as \"AND\".\n**\n**   * Deferred tokens have not yet been considered.\n**\n** If *pRc is not SQLITE_OK when this function is called, it immediately\n** returns 0. Otherwise, it tests whether or not after considering NEAR\n** operators and deferred tokens the current row is still a match for the\n** expression. It returns 1 if both of the following are true:\n**\n**   1. *pRc is SQLITE_OK when this function returns, and\n**\n**   2. After scanning the current FTS table row for the deferred tokens,\n**      it is determined that the row does *not* match the query.\n**\n** Or, if no error occurs and it seems the current row does match the FTS\n** query, return 0.\n*/\nstatic int fts3EvalTestDeferredAndNear(Fts3Cursor *pCsr, int *pRc){\n  int rc = *pRc;\n  int bMiss = 0;\n  if( rc==SQLITE_OK ){\n\n    /* If there are one or more deferred tokens, load the current row into\n    ** memory and scan it to determine the position list for each deferred\n    ** token. Then, see if this row is really a match, considering deferred\n    ** tokens and NEAR operators (neither of which were taken into account\n    ** earlier, by fts3EvalNextRow()). \n    */\n    if( pCsr->pDeferred ){\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts3CacheDeferredDoclists(pCsr);\n      }\n    }\n    bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));\n\n    /* Free the position-lists accumulated for each deferred token above. */\n    sqlite3Fts3FreeDeferredDoclists(pCsr);\n    *pRc = rc;\n  }\n  return (rc==SQLITE_OK && bMiss);\n}\n\n/*\n** Advance to the next document that matches the FTS expression in\n** Fts3Cursor.pExpr.\n*/\nstatic int fts3EvalNext(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Expr *pExpr = pCsr->pExpr;\n  assert( pCsr->isEof==0 );\n  if( pExpr==0 ){\n    pCsr->isEof = 1;\n  }else{\n    do {\n      if( pCsr->isRequireSeek==0 ){\n        sqlite3_reset(pCsr->pStmt);\n      }\n      assert( sqlite3_data_count(pCsr->pStmt)==0 );\n      fts3EvalNextRow(pCsr, pExpr, &rc);\n      pCsr->isEof = pExpr->bEof;\n      pCsr->isRequireSeek = 1;\n      pCsr->isMatchinfoNeeded = 1;\n      pCsr->iPrevId = pExpr->iDocid;\n    }while( pCsr->isEof==0 && fts3EvalTestDeferredAndNear(pCsr, &rc) );\n  }\n  return rc;\n}\n\n/*\n** Restart interation for expression pExpr so that the next call to\n** fts3EvalNext() visits the first row. Do not allow incremental \n** loading or merging of phrase doclists for this iteration.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op. If an error occurs within this function, *pRc is set to an\n** SQLite error code before returning.\n*/\nstatic void fts3EvalRestart(\n  Fts3Cursor *pCsr,\n  Fts3Expr *pExpr,\n  int *pRc\n){\n  if( pExpr && *pRc==SQLITE_OK ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n\n    if( pPhrase ){\n      fts3EvalInvalidatePoslist(pPhrase);\n      if( pPhrase->bIncr ){\n        assert( pPhrase->nToken==1 );\n        assert( pPhrase->aToken[0].pSegcsr );\n        sqlite3Fts3MsrIncrRestart(pPhrase->aToken[0].pSegcsr);\n        *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);\n      }\n\n      pPhrase->doclist.pNextDocid = 0;\n      pPhrase->doclist.iDocid = 0;\n    }\n\n    pExpr->iDocid = 0;\n    pExpr->bEof = 0;\n    pExpr->bStart = 0;\n\n    fts3EvalRestart(pCsr, pExpr->pLeft, pRc);\n    fts3EvalRestart(pCsr, pExpr->pRight, pRc);\n  }\n}\n\n/*\n** After allocating the Fts3Expr.aMI[] array for each phrase in the \n** expression rooted at pExpr, the cursor iterates through all rows matched\n** by pExpr, calling this function for each row. This function increments\n** the values in Fts3Expr.aMI[] according to the position-list currently\n** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase \n** expression nodes.\n*/\nstatic void fts3EvalUpdateCounts(Fts3Expr *pExpr){\n  if( pExpr ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n    if( pPhrase && pPhrase->doclist.pList ){\n      int iCol = 0;\n      char *p = pPhrase->doclist.pList;\n\n      assert( *p );\n      while( 1 ){\n        u8 c = 0;\n        int iCnt = 0;\n        while( 0xFE & (*p | c) ){\n          if( (c&0x80)==0 ) iCnt++;\n          c = *p++ & 0x80;\n        }\n\n        /* aMI[iCol*3 + 1] = Number of occurrences\n        ** aMI[iCol*3 + 2] = Number of rows containing at least one instance\n        */\n        pExpr->aMI[iCol*3 + 1] += iCnt;\n        pExpr->aMI[iCol*3 + 2] += (iCnt>0);\n        if( *p==0x00 ) break;\n        p++;\n        p += sqlite3Fts3GetVarint32(p, &iCol);\n      }\n    }\n\n    fts3EvalUpdateCounts(pExpr->pLeft);\n    fts3EvalUpdateCounts(pExpr->pRight);\n  }\n}\n\n/*\n** Expression pExpr must be of type FTSQUERY_PHRASE.\n**\n** If it is not already allocated and populated, this function allocates and\n** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part\n** of a NEAR expression, then it also allocates and populates the same array\n** for all other phrases that are part of the NEAR expression.\n**\n** SQLITE_OK is returned if the aMI[] array is successfully allocated and\n** populated. Otherwise, if an error occurs, an SQLite error code is returned.\n*/\nstatic int fts3EvalGatherStats(\n  Fts3Cursor *pCsr,               /* Cursor object */\n  Fts3Expr *pExpr                 /* FTSQUERY_PHRASE expression */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pExpr->eType==FTSQUERY_PHRASE );\n  if( pExpr->aMI==0 ){\n    Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n    Fts3Expr *pRoot;                /* Root of NEAR expression */\n    Fts3Expr *p;                    /* Iterator used for several purposes */\n\n    sqlite3_int64 iPrevId = pCsr->iPrevId;\n    sqlite3_int64 iDocid;\n    u8 bEof;\n\n    /* Find the root of the NEAR expression */\n    pRoot = pExpr;\n    while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){\n      pRoot = pRoot->pParent;\n    }\n    iDocid = pRoot->iDocid;\n    bEof = pRoot->bEof;\n    assert( pRoot->bStart );\n\n    /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */\n    for(p=pRoot; p; p=p->pLeft){\n      Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);\n      assert( pE->aMI==0 );\n      pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));\n      if( !pE->aMI ) return SQLITE_NOMEM;\n      memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));\n    }\n\n    fts3EvalRestart(pCsr, pRoot, &rc);\n\n    while( pCsr->isEof==0 && rc==SQLITE_OK ){\n\n      do {\n        /* Ensure the %_content statement is reset. */\n        if( pCsr->isRequireSeek==0 ) sqlite3_reset(pCsr->pStmt);\n        assert( sqlite3_data_count(pCsr->pStmt)==0 );\n\n        /* Advance to the next document */\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        pCsr->isEof = pRoot->bEof;\n        pCsr->isRequireSeek = 1;\n        pCsr->isMatchinfoNeeded = 1;\n        pCsr->iPrevId = pRoot->iDocid;\n      }while( pCsr->isEof==0 \n           && pRoot->eType==FTSQUERY_NEAR \n           && fts3EvalTestDeferredAndNear(pCsr, &rc) \n      );\n\n      if( rc==SQLITE_OK && pCsr->isEof==0 ){\n        fts3EvalUpdateCounts(pRoot);\n      }\n    }\n\n    pCsr->isEof = 0;\n    pCsr->iPrevId = iPrevId;\n\n    if( bEof ){\n      pRoot->bEof = bEof;\n    }else{\n      /* Caution: pRoot may iterate through docids in ascending or descending\n      ** order. For this reason, even though it seems more defensive, the \n      ** do loop can not be written:\n      **\n      **   do {...} while( pRoot->iDocid<iDocid && rc==SQLITE_OK );\n      */\n      fts3EvalRestart(pCsr, pRoot, &rc);\n      do {\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        assert( pRoot->bEof==0 );\n      }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );\n      fts3EvalTestDeferredAndNear(pCsr, &rc);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used by the matchinfo() module to query a phrase \n** expression node for the following information:\n**\n**   1. The total number of occurrences of the phrase in each column of \n**      the FTS table (considering all rows), and\n**\n**   2. For each column, the number of rows in the table for which the\n**      column contains at least one instance of the phrase.\n**\n** If no error occurs, SQLITE_OK is returned and the values for each column\n** written into the array aiOut as follows:\n**\n**   aiOut[iCol*3 + 1] = Number of occurrences\n**   aiOut[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** Caveats:\n**\n**   * If a phrase consists entirely of deferred tokens, then all output \n**     values are set to the number of documents in the table. In other\n**     words we assume that very common tokens occur exactly once in each \n**     column of each row of the table.\n**\n**   * If a phrase contains some deferred tokens (and some non-deferred \n**     tokens), count the potential occurrence identified by considering\n**     the non-deferred tokens instead of actual phrase occurrences.\n**\n**   * If the phrase is part of a NEAR expression, then only phrase instances\n**     that meet the NEAR constraint are included in the counts.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Phrase expression */\n  u32 *aiOut                      /* Array to write results into (see above) */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int iCol;\n\n  if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){\n    assert( pCsr->nDoc>0 );\n    for(iCol=0; iCol<pTab->nColumn; iCol++){\n      aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;\n      aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;\n    }\n  }else{\n    rc = fts3EvalGatherStats(pCsr, pExpr);\n    if( rc==SQLITE_OK ){\n      assert( pExpr->aMI );\n      for(iCol=0; iCol<pTab->nColumn; iCol++){\n        aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];\n        aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The expression pExpr passed as the second argument to this function\n** must be of type FTSQUERY_PHRASE. \n**\n** The returned value is either NULL or a pointer to a buffer containing\n** a position-list indicating the occurrences of the phrase in column iCol\n** of the current row. \n**\n** More specifically, the returned buffer contains 1 varint for each \n** occurrence of the phrase in the column, stored using the normal (delta+2) \n** compression and is terminated by either an 0x01 or 0x00 byte. For example,\n** if the requested column contains \"a b X c d X X\" and the position-list\n** for 'X' is requested, the buffer returned may contain:\n**\n**     0x04 0x05 0x03 0x01   or   0x04 0x05 0x03 0x00\n**\n** This function works regardless of whether or not the phrase is deferred,\n** incremental, or neither.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  Fts3Expr *pExpr,                /* Phrase to return doclist for */\n  int iCol,                       /* Column to return position list for */\n  char **ppOut                    /* OUT: Pointer to position list */\n){\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  char *pIter;\n  int iThis;\n  sqlite3_int64 iDocid;\n\n  /* If this phrase is applies specifically to some column other than \n  ** column iCol, return a NULL pointer.  */\n  *ppOut = 0;\n  assert( iCol>=0 && iCol<pTab->nColumn );\n  if( (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol) ){\n    return SQLITE_OK;\n  }\n\n  iDocid = pExpr->iDocid;\n  pIter = pPhrase->doclist.pList;\n  if( iDocid!=pCsr->iPrevId || pExpr->bEof ){\n    int bDescDoclist = pTab->bDescIdx;      /* For DOCID_CMP macro */\n    int bOr = 0;\n    u8 bEof = 0;\n    Fts3Expr *p;\n\n    /* Check if this phrase descends from an OR expression node. If not, \n    ** return NULL. Otherwise, the entry that corresponds to docid \n    ** pCsr->iPrevId may lie earlier in the doclist buffer. */\n    for(p=pExpr->pParent; p; p=p->pParent){\n      if( p->eType==FTSQUERY_OR ) bOr = 1;\n    }\n    if( bOr==0 ) return SQLITE_OK;\n\n    /* This is the descendent of an OR node. In this case we cannot use\n    ** an incremental phrase. Load the entire doclist for the phrase\n    ** into memory in this case.  */\n    if( pPhrase->bIncr ){\n      int rc = SQLITE_OK;\n      int bEofSave = pExpr->bEof;\n      fts3EvalRestart(pCsr, pExpr, &rc);\n      while( rc==SQLITE_OK && !pExpr->bEof ){\n        fts3EvalNextRow(pCsr, pExpr, &rc);\n        if( bEofSave==0 && pExpr->iDocid==iDocid ) break;\n      }\n      pIter = pPhrase->doclist.pList;\n      assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );\n      if( rc!=SQLITE_OK ) return rc;\n    }\n\n    if( pExpr->bEof ){\n      pIter = 0;\n      iDocid = 0;\n    }\n    bEof = (pPhrase->doclist.nAll==0);\n    assert( bDescDoclist==0 || bDescDoclist==1 );\n    assert( pCsr->bDesc==0 || pCsr->bDesc==1 );\n\n    if( pCsr->bDesc==bDescDoclist ){\n      int dummy;\n      while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){\n        sqlite3Fts3DoclistPrev(\n            bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, \n            &pIter, &iDocid, &dummy, &bEof\n        );\n      }\n    }else{\n      while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){\n        sqlite3Fts3DoclistNext(\n            bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll, \n            &pIter, &iDocid, &bEof\n        );\n      }\n    }\n\n    if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;\n  }\n  if( pIter==0 ) return SQLITE_OK;\n\n  if( *pIter==0x01 ){\n    pIter++;\n    pIter += sqlite3Fts3GetVarint32(pIter, &iThis);\n  }else{\n    iThis = 0;\n  }\n  while( iThis<iCol ){\n    fts3ColumnlistCopy(0, &pIter);\n    if( *pIter==0x00 ) return 0;\n    pIter++;\n    pIter += sqlite3Fts3GetVarint32(pIter, &iThis);\n  }\n\n  *ppOut = ((iCol==iThis)?pIter:0);\n  return SQLITE_OK;\n}\n\n/*\n** Free all components of the Fts3Phrase structure that were allocated by\n** the eval module. Specifically, this means to free:\n**\n**   * the contents of pPhrase->doclist, and\n**   * any Fts3MultiSegReader objects held by phrase tokens.\n*/\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    sqlite3_free(pPhrase->doclist.aAll);\n    fts3EvalInvalidatePoslist(pPhrase);\n    memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));\n    for(i=0; i<pPhrase->nToken; i++){\n      fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);\n      pPhrase->aToken[i].pSegcsr = 0;\n    }\n  }\n}\n\n\n/*\n** Return SQLITE_CORRUPT_VTAB.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(){\n  return SQLITE_CORRUPT_VTAB;\n}\n#endif\n\n#if !SQLITE_CORE\n/*\n** Initialize API pointer table, if required.\n*/\nSQLITE_API int sqlite3_extension_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts3Init(db);\n}\n#endif\n\n#endif\n\n/************** End of fts3.c ************************************************/\n/************** Begin file fts3_aux.c ****************************************/\n/*\n** 2011 Jan 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3auxTable Fts3auxTable;\ntypedef struct Fts3auxCursor Fts3auxCursor;\n\nstruct Fts3auxTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts3Table *pFts3Tab;\n};\n\nstruct Fts3auxCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts3MultiSegReader csr;        /* Must be right after \"base\" */\n  Fts3SegFilter filter;\n  char *zStop;\n  int nStop;                      /* Byte-length of string zStop */\n  int isEof;                      /* True if cursor is at EOF */\n  sqlite3_int64 iRowid;           /* Current rowid */\n\n  int iCol;                       /* Current value of 'col' column */\n  int nStat;                      /* Size of aStat[] array */\n  struct Fts3auxColstats {\n    sqlite3_int64 nDoc;           /* 'documents' values for current csr row */\n    sqlite3_int64 nOcc;           /* 'occurrences' values for current csr row */\n  } *aStat;\n};\n\n/*\n** Schema of the terms table.\n*/\n#define FTS3_TERMS_SCHEMA \"CREATE TABLE x(term, col, documents, occurrences)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n*/\nstatic int fts3auxConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pUnused,                  /* Unused */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  char const *zDb;                /* Name of database (e.g. \"main\") */\n  char const *zFts3;              /* Name of fts3 table */\n  int nDb;                        /* Result of strlen(zDb) */\n  int nFts3;                      /* Result of strlen(zFts3) */\n  int nByte;                      /* Bytes of space to allocate here */\n  int rc;                         /* value returned by declare_vtab() */\n  Fts3auxTable *p;                /* Virtual table object to return */\n\n  UNUSED_PARAMETER(pUnused);\n\n  /* The user should invoke this in one of two forms:\n  **\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);\n  */\n  if( argc!=4 && argc!=5 ) goto bad_args;\n\n  zDb = argv[1]; \n  nDb = (int)strlen(zDb);\n  if( argc==5 ){\n    if( nDb==4 && 0==sqlite3_strnicmp(\"temp\", zDb, 4) ){\n      zDb = argv[3]; \n      nDb = (int)strlen(zDb);\n      zFts3 = argv[4];\n    }else{\n      goto bad_args;\n    }\n  }else{\n    zFts3 = argv[3];\n  }\n  nFts3 = (int)strlen(zFts3);\n\n  rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;\n  p = (Fts3auxTable *)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFts3Tab = (Fts3Table *)&p[1];\n  p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];\n  p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];\n  p->pFts3Tab->db = db;\n  p->pFts3Tab->nIndex = 1;\n\n  memcpy((char *)p->pFts3Tab->zDb, zDb, nDb);\n  memcpy((char *)p->pFts3Tab->zName, zFts3, nFts3);\n  sqlite3Fts3Dequote((char *)p->pFts3Tab->zName);\n\n  *ppVtab = (sqlite3_vtab *)p;\n  return SQLITE_OK;\n\n bad_args:\n  *pzErr = sqlite3_mprintf(\"invalid arguments to fts4aux constructor\");\n  return SQLITE_ERROR;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3auxDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3auxTable *p = (Fts3auxTable *)pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int i;\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(pFts3->aStmt); i++){\n    sqlite3_finalize(pFts3->aStmt[i]);\n  }\n  sqlite3_free(pFts3->zSegmentsTbl);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n#define FTS4AUX_EQ_CONSTRAINT 1\n#define FTS4AUX_GE_CONSTRAINT 2\n#define FTS4AUX_LE_CONSTRAINT 4\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3auxBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iEq = -1;\n  int iGe = -1;\n  int iLe = -1;\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* This vtab delivers always results in \"ORDER BY term ASC\" order. */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  /* Search for equality and range constraints on the \"term\" column. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable && pInfo->aConstraint[i].iColumn==0 ){\n      int op = pInfo->aConstraint[i].op;\n      if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;\n      if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;\n      if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;\n      if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;\n      if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;\n    }\n  }\n\n  if( iEq>=0 ){\n    pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;\n    pInfo->aConstraintUsage[iEq].argvIndex = 1;\n    pInfo->estimatedCost = 5;\n  }else{\n    pInfo->idxNum = 0;\n    pInfo->estimatedCost = 20000;\n    if( iGe>=0 ){\n      pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;\n      pInfo->aConstraintUsage[iGe].argvIndex = 1;\n      pInfo->estimatedCost /= 2;\n    }\n    if( iLe>=0 ){\n      pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;\n      pInfo->aConstraintUsage[iLe].argvIndex = 1 + (iGe>=0);\n      pInfo->estimatedCost /= 2;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3auxOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3auxCursor *pCsr;            /* Pointer to cursor object to return */\n\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3auxCursor *)sqlite3_malloc(sizeof(Fts3auxCursor));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(Fts3auxCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n\n  sqlite3Fts3SegmentsClose(pFts3);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->zStop);\n  sqlite3_free(pCsr->aStat);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){\n  if( nSize>pCsr->nStat ){\n    struct Fts3auxColstats *aNew;\n    aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat, \n        sizeof(struct Fts3auxColstats) * nSize\n    );\n    if( aNew==0 ) return SQLITE_NOMEM;\n    memset(&aNew[pCsr->nStat], 0, \n        sizeof(struct Fts3auxColstats) * (nSize - pCsr->nStat)\n    );\n    pCsr->aStat = aNew;\n    pCsr->nStat = nSize;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n\n  /* Increment our pretend rowid value. */\n  pCsr->iRowid++;\n\n  for(pCsr->iCol++; pCsr->iCol<pCsr->nStat; pCsr->iCol++){\n    if( pCsr->aStat[pCsr->iCol].nDoc>0 ) return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);\n  if( rc==SQLITE_ROW ){\n    int i = 0;\n    int nDoclist = pCsr->csr.nDoclist;\n    char *aDoclist = pCsr->csr.aDoclist;\n    int iCol;\n\n    int eState = 0;\n\n    if( pCsr->zStop ){\n      int n = (pCsr->nStop<pCsr->csr.nTerm) ? pCsr->nStop : pCsr->csr.nTerm;\n      int mc = memcmp(pCsr->zStop, pCsr->csr.zTerm, n);\n      if( mc<0 || (mc==0 && pCsr->csr.nTerm>pCsr->nStop) ){\n        pCsr->isEof = 1;\n        return SQLITE_OK;\n      }\n    }\n\n    if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM;\n    memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat);\n    iCol = 0;\n\n    while( i<nDoclist ){\n      sqlite3_int64 v = 0;\n\n      i += sqlite3Fts3GetVarint(&aDoclist[i], &v);\n      switch( eState ){\n        /* State 0. In this state the integer just read was a docid. */\n        case 0:\n          pCsr->aStat[0].nDoc++;\n          eState = 1;\n          iCol = 0;\n          break;\n\n        /* State 1. In this state we are expecting either a 1, indicating\n        ** that the following integer will be a column number, or the\n        ** start of a position list for column 0.  \n        ** \n        ** The only difference between state 1 and state 2 is that if the\n        ** integer encountered in state 1 is not 0 or 1, then we need to\n        ** increment the column 0 \"nDoc\" count for this term.\n        */\n        case 1:\n          assert( iCol==0 );\n          if( v>1 ){\n            pCsr->aStat[1].nDoc++;\n          }\n          eState = 2;\n          /* fall through */\n\n        case 2:\n          if( v==0 ){       /* 0x00. Next integer will be a docid. */\n            eState = 0;\n          }else if( v==1 ){ /* 0x01. Next integer will be a column number. */\n            eState = 3;\n          }else{            /* 2 or greater. A position. */\n            pCsr->aStat[iCol+1].nOcc++;\n            pCsr->aStat[0].nOcc++;\n          }\n          break;\n\n        /* State 3. The integer just read is a column number. */\n        default: assert( eState==3 );\n          iCol = (int)v;\n          if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM;\n          pCsr->aStat[iCol+1].nDoc++;\n          eState = 2;\n          break;\n      }\n    }\n\n    pCsr->iCol = 0;\n    rc = SQLITE_OK;\n  }else{\n    pCsr->isEof = 1;\n  }\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3auxFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n  int isScan;\n\n  UNUSED_PARAMETER(nVal);\n  UNUSED_PARAMETER(idxStr);\n\n  assert( idxStr==0 );\n  assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0\n       || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT\n       || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)\n  );\n  isScan = (idxNum!=FTS4AUX_EQ_CONSTRAINT);\n\n  /* In case this cursor is being reused, close and zero it. */\n  testcase(pCsr->filter.zTerm);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->aStat);\n  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);\n\n  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;\n\n  if( idxNum&(FTS4AUX_EQ_CONSTRAINT|FTS4AUX_GE_CONSTRAINT) ){\n    const unsigned char *zStr = sqlite3_value_text(apVal[0]);\n    if( zStr ){\n      pCsr->filter.zTerm = sqlite3_mprintf(\"%s\", zStr);\n      pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);\n      if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;\n    }\n  }\n  if( idxNum&FTS4AUX_LE_CONSTRAINT ){\n    int iIdx = (idxNum&FTS4AUX_GE_CONSTRAINT) ? 1 : 0;\n    pCsr->zStop = sqlite3_mprintf(\"%s\", sqlite3_value_text(apVal[iIdx]));\n    pCsr->nStop = sqlite3_value_bytes(apVal[iIdx]);\n    if( pCsr->zStop==0 ) return SQLITE_NOMEM;\n  }\n\n  rc = sqlite3Fts3SegReaderCursor(pFts3, 0, 0, FTS3_SEGCURSOR_ALL,\n      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);\n  }\n\n  if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);\n  return rc;\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3auxEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  return pCsr->isEof;\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3auxColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pContext,      /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3auxCursor *p = (Fts3auxCursor *)pCursor;\n\n  assert( p->isEof==0 );\n  if( iCol==0 ){        /* Column \"term\" */\n    sqlite3_result_text(pContext, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);\n  }else if( iCol==1 ){  /* Column \"col\" */\n    if( p->iCol ){\n      sqlite3_result_int(pContext, p->iCol-1);\n    }else{\n      sqlite3_result_text(pContext, \"*\", -1, SQLITE_STATIC);\n    }\n  }else if( iCol==2 ){  /* Column \"documents\" */\n    sqlite3_result_int64(pContext, p->aStat[p->iCol].nDoc);\n  }else{                /* Column \"occurrences\" */\n    sqlite3_result_int64(pContext, p->aStat[p->iCol].nOcc);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3auxRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3aux module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){\n  static const sqlite3_module fts3aux_module = {\n     0,                           /* iVersion      */\n     fts3auxConnectMethod,        /* xCreate       */\n     fts3auxConnectMethod,        /* xConnect      */\n     fts3auxBestIndexMethod,      /* xBestIndex    */\n     fts3auxDisconnectMethod,     /* xDisconnect   */\n     fts3auxDisconnectMethod,     /* xDestroy      */\n     fts3auxOpenMethod,           /* xOpen         */\n     fts3auxCloseMethod,          /* xClose        */\n     fts3auxFilterMethod,         /* xFilter       */\n     fts3auxNextMethod,           /* xNext         */\n     fts3auxEofMethod,            /* xEof          */\n     fts3auxColumnMethod,         /* xColumn       */\n     fts3auxRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts4aux\", &fts3aux_module, 0);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_aux.c ********************************************/\n/************** Begin file fts3_expr.c ***************************************/\n/*\n** 2008 Nov 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This module contains code that implements a parser for fts3 query strings\n** (the right-hand argument to the MATCH operator). Because the supported \n** syntax is relatively simple, the whole tokenizer/parser system is\n** hand-coded. \n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/*\n** By default, this module parses the legacy syntax that has been \n** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined, then it uses the new syntax. The differences between\n** the new and the old syntaxes are:\n**\n**  a) The new syntax supports parenthesis. The old does not.\n**\n**  b) The new syntax supports the AND and NOT operators. The old does not.\n**\n**  c) The old syntax supports the \"-\" token qualifier. This is not \n**     supported by the new syntax (it is replaced by the NOT operator).\n**\n**  d) When using the old syntax, the OR operator has a greater precedence\n**     than an implicit AND. When using the new, both implicity and explicit\n**     AND operators have a higher precedence than OR.\n**\n** If compiled with SQLITE_TEST defined, then this module exports the\n** symbol \"int sqlite3_fts3_enable_parentheses\". Setting this variable\n** to zero causes the module to use the old syntax. If it is set to \n** non-zero the new syntax is activated. This is so both syntaxes can\n** be tested using a single build of testfixture.\n**\n** The following describes the syntax supported by the fts3 MATCH\n** operator in a similar format to that used by the lemon parser\n** generator. This module does not use actually lemon, it uses a\n** custom parser.\n**\n**   query ::= andexpr (OR andexpr)*.\n**\n**   andexpr ::= notexpr (AND? notexpr)*.\n**\n**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.\n**   notexpr ::= LP query RP.\n**\n**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.\n**\n**   distance_opt ::= .\n**   distance_opt ::= / INTEGER.\n**\n**   phrase ::= TOKEN.\n**   phrase ::= COLUMN:TOKEN.\n**   phrase ::= \"TOKEN TOKEN TOKEN...\".\n*/\n\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_fts3_enable_parentheses = 0;\n#else\n# ifdef SQLITE_ENABLE_FTS3_PARENTHESIS \n#  define sqlite3_fts3_enable_parentheses 1\n# else\n#  define sqlite3_fts3_enable_parentheses 0\n# endif\n#endif\n\n/*\n** Default span for NEAR operators.\n*/\n#define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** isNot:\n**   This variable is used by function getNextNode(). When getNextNode() is\n**   called, it sets ParseContext.isNot to true if the 'next node' is a \n**   FTSQUERY_PHRASE with a unary \"-\" attached to it. i.e. \"mysql\" in the\n**   FTS3 query \"sqlite -mysql\". Otherwise, ParseContext.isNot is set to\n**   zero.\n*/\ntypedef struct ParseContext ParseContext;\nstruct ParseContext {\n  sqlite3_tokenizer *pTokenizer;      /* Tokenizer module */\n  int iLangid;                        /* Language id used with tokenizer */\n  const char **azCol;                 /* Array of column names for fts3 table */\n  int bFts4;                          /* True to allow FTS4-only syntax */\n  int nCol;                           /* Number of entries in azCol[] */\n  int iDefaultCol;                    /* Default column to query */\n  int isNot;                          /* True if getNextNode() sees a unary - */\n  sqlite3_context *pCtx;              /* Write error message here */\n  int nNest;                          /* Number of nested brackets */\n};\n\n/*\n** This function is equivalent to the standard isspace() function. \n**\n** The standard isspace() can be awkward to use safely, because although it\n** is defined to accept an argument of type int, its behavior when passed\n** an integer that falls outside of the range of the unsigned char type\n** is undefined (and sometimes, \"undefined\" means segfault). This wrapper\n** is defined to accept an argument of type char, and always returns 0 for\n** any values that fall outside of the range of the unsigned char type (i.e.\n** negative values).\n*/\nstatic int fts3isspace(char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\n\n/*\n** Allocate nByte bytes of memory using sqlite3_malloc(). If successful,\n** zero the memory before returning a pointer to it. If unsuccessful, \n** return NULL.\n*/\nstatic void *fts3MallocZero(int nByte){\n  void *pRet = sqlite3_malloc(nByte);\n  if( pRet ) memset(pRet, 0, nByte);\n  return pRet;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(\n  sqlite3_tokenizer *pTokenizer,\n  int iLangid,\n  const char *z,\n  int n,\n  sqlite3_tokenizer_cursor **ppCsr\n){\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n  int rc;\n\n  rc = pModule->xOpen(pTokenizer, z, n, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( rc==SQLITE_OK ){\n    pCsr->pTokenizer = pTokenizer;\n    if( pModule->iVersion>=1 ){\n      rc = pModule->xLanguageid(pCsr, iLangid);\n      if( rc!=SQLITE_OK ){\n        pModule->xClose(pCsr);\n        pCsr = 0;\n      }\n    }\n  }\n  *ppCsr = pCsr;\n  return rc;\n}\n\n\n/*\n** Extract the next token from buffer z (length n) using the tokenizer\n** and other information (column names etc.) in pParse. Create an Fts3Expr\n** structure of type FTSQUERY_PHRASE containing a phrase consisting of this\n** single token and set *ppExpr to point to it. If the end of the buffer is\n** reached before a token is found, set *ppExpr to zero. It is the\n** responsibility of the caller to eventually deallocate the allocated \n** Fts3Expr structure (if any) by passing it to sqlite3_free().\n**\n** Return SQLITE_OK if successful, or SQLITE_NOMEM if a memory allocation\n** fails.\n*/\nstatic int getNextToken(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  int iCol,                               /* Value for Fts3Phrase.iColumn */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  sqlite3_tokenizer_cursor *pCursor;\n  Fts3Expr *pRet = 0;\n  int nConsumed = 0;\n\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, n, &pCursor);\n  if( rc==SQLITE_OK ){\n    const char *zToken;\n    int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;\n    int nByte;                               /* total space to allocate */\n\n    rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);\n    if( rc==SQLITE_OK ){\n      nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;\n      pRet = (Fts3Expr *)fts3MallocZero(nByte);\n      if( !pRet ){\n        rc = SQLITE_NOMEM;\n      }else{\n        pRet->eType = FTSQUERY_PHRASE;\n        pRet->pPhrase = (Fts3Phrase *)&pRet[1];\n        pRet->pPhrase->nToken = 1;\n        pRet->pPhrase->iColumn = iCol;\n        pRet->pPhrase->aToken[0].n = nToken;\n        pRet->pPhrase->aToken[0].z = (char *)&pRet->pPhrase[1];\n        memcpy(pRet->pPhrase->aToken[0].z, zToken, nToken);\n\n        if( iEnd<n && z[iEnd]=='*' ){\n          pRet->pPhrase->aToken[0].isPrefix = 1;\n          iEnd++;\n        }\n\n        while( 1 ){\n          if( !sqlite3_fts3_enable_parentheses \n           && iStart>0 && z[iStart-1]=='-' \n          ){\n            pParse->isNot = 1;\n            iStart--;\n          }else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){\n            pRet->pPhrase->aToken[0].bFirst = 1;\n            iStart--;\n          }else{\n            break;\n          }\n        }\n\n      }\n      nConsumed = iEnd;\n    }\n\n    pModule->xClose(pCursor);\n  }\n  \n  *pnConsumed = nConsumed;\n  *ppExpr = pRet;\n  return rc;\n}\n\n\n/*\n** Enlarge a memory allocation.  If an out-of-memory allocation occurs,\n** then free the old allocation.\n*/\nstatic void *fts3ReallocOrFree(void *pOrig, int nNew){\n  void *pRet = sqlite3_realloc(pOrig, nNew);\n  if( !pRet ){\n    sqlite3_free(pOrig);\n  }\n  return pRet;\n}\n\n/*\n** Buffer zInput, length nInput, contains the contents of a quoted string\n** that appeared as part of an fts3 query expression. Neither quote character\n** is included in the buffer. This function attempts to tokenize the entire\n** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE \n** containing the results.\n**\n** If successful, SQLITE_OK is returned and *ppExpr set to point at the\n** allocated Fts3Expr structure. Otherwise, either SQLITE_NOMEM (out of memory\n** error) or SQLITE_ERROR (tokenization error) is returned and *ppExpr set\n** to 0.\n*/\nstatic int getNextString(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *zInput, int nInput,         /* Input string */\n  Fts3Expr **ppExpr                       /* OUT: expression */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  Fts3Expr *p = 0;\n  sqlite3_tokenizer_cursor *pCursor = 0;\n  char *zTemp = 0;\n  int nTemp = 0;\n\n  const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);\n  int nToken = 0;\n\n  /* The final Fts3Expr data structure, including the Fts3Phrase,\n  ** Fts3PhraseToken structures token buffers are all stored as a single \n  ** allocation so that the expression can be freed with a single call to\n  ** sqlite3_free(). Setting this up requires a two pass approach.\n  **\n  ** The first pass, in the block below, uses a tokenizer cursor to iterate\n  ** through the tokens in the expression. This pass uses fts3ReallocOrFree()\n  ** to assemble data in two dynamic buffers:\n  **\n  **   Buffer p: Points to the Fts3Expr structure, followed by the Fts3Phrase\n  **             structure, followed by the array of Fts3PhraseToken \n  **             structures. This pass only populates the Fts3PhraseToken array.\n  **\n  **   Buffer zTemp: Contains copies of all tokens.\n  **\n  ** The second pass, in the block that begins \"if( rc==SQLITE_DONE )\" below,\n  ** appends buffer zTemp to buffer p, and fills in the Fts3Expr and Fts3Phrase\n  ** structures.\n  */\n  rc = sqlite3Fts3OpenTokenizer(\n      pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);\n  if( rc==SQLITE_OK ){\n    int ii;\n    for(ii=0; rc==SQLITE_OK; ii++){\n      const char *zByte;\n      int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;\n      rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);\n      if( rc==SQLITE_OK ){\n        Fts3PhraseToken *pToken;\n\n        p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));\n        if( !p ) goto no_mem;\n\n        zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);\n        if( !zTemp ) goto no_mem;\n\n        assert( nToken==ii );\n        pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];\n        memset(pToken, 0, sizeof(Fts3PhraseToken));\n\n        memcpy(&zTemp[nTemp], zByte, nByte);\n        nTemp += nByte;\n\n        pToken->n = nByte;\n        pToken->isPrefix = (iEnd<nInput && zInput[iEnd]=='*');\n        pToken->bFirst = (iBegin>0 && zInput[iBegin-1]=='^');\n        nToken = ii+1;\n      }\n    }\n\n    pModule->xClose(pCursor);\n    pCursor = 0;\n  }\n\n  if( rc==SQLITE_DONE ){\n    int jj;\n    char *zBuf = 0;\n\n    p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);\n    if( !p ) goto no_mem;\n    memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);\n    p->eType = FTSQUERY_PHRASE;\n    p->pPhrase = (Fts3Phrase *)&p[1];\n    p->pPhrase->iColumn = pParse->iDefaultCol;\n    p->pPhrase->nToken = nToken;\n\n    zBuf = (char *)&p->pPhrase->aToken[nToken];\n    if( zTemp ){\n      memcpy(zBuf, zTemp, nTemp);\n      sqlite3_free(zTemp);\n    }else{\n      assert( nTemp==0 );\n    }\n\n    for(jj=0; jj<p->pPhrase->nToken; jj++){\n      p->pPhrase->aToken[jj].z = zBuf;\n      zBuf += p->pPhrase->aToken[jj].n;\n    }\n    rc = SQLITE_OK;\n  }\n\n  *ppExpr = p;\n  return rc;\nno_mem:\n\n  if( pCursor ){\n    pModule->xClose(pCursor);\n  }\n  sqlite3_free(zTemp);\n  sqlite3_free(p);\n  *ppExpr = 0;\n  return SQLITE_NOMEM;\n}\n\n/*\n** Function getNextNode(), which is called by fts3ExprParse(), may itself\n** call fts3ExprParse(). So this forward declaration is required.\n*/\nstatic int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *);\n\n/*\n** The output variable *ppExpr is populated with an allocated Fts3Expr \n** structure, or set to 0 if the end of the input buffer is reached.\n**\n** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM\n** if a malloc failure occurs, or SQLITE_ERROR if a parse error is encountered.\n** If SQLITE_ERROR is returned, pContext is populated with an error message.\n*/\nstatic int getNextNode(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  static const struct Fts3Keyword {\n    char *z;                              /* Keyword text */\n    unsigned char n;                      /* Length of the keyword */\n    unsigned char parenOnly;              /* Only valid in paren mode */\n    unsigned char eType;                  /* Keyword code */\n  } aKeyword[] = {\n    { \"OR\" ,  2, 0, FTSQUERY_OR   },\n    { \"AND\",  3, 1, FTSQUERY_AND  },\n    { \"NOT\",  3, 1, FTSQUERY_NOT  },\n    { \"NEAR\", 4, 0, FTSQUERY_NEAR }\n  };\n  int ii;\n  int iCol;\n  int iColLen;\n  int rc;\n  Fts3Expr *pRet = 0;\n\n  const char *zInput = z;\n  int nInput = n;\n\n  pParse->isNot = 0;\n\n  /* Skip over any whitespace before checking for a keyword, an open or\n  ** close bracket, or a quoted string. \n  */\n  while( nInput>0 && fts3isspace(*zInput) ){\n    nInput--;\n    zInput++;\n  }\n  if( nInput==0 ){\n    return SQLITE_DONE;\n  }\n\n  /* See if we are dealing with a keyword. */\n  for(ii=0; ii<(int)(sizeof(aKeyword)/sizeof(struct Fts3Keyword)); ii++){\n    const struct Fts3Keyword *pKey = &aKeyword[ii];\n\n    if( (pKey->parenOnly & ~sqlite3_fts3_enable_parentheses)!=0 ){\n      continue;\n    }\n\n    if( nInput>=pKey->n && 0==memcmp(zInput, pKey->z, pKey->n) ){\n      int nNear = SQLITE_FTS3_DEFAULT_NEAR_PARAM;\n      int nKey = pKey->n;\n      char cNext;\n\n      /* If this is a \"NEAR\" keyword, check for an explicit nearness. */\n      if( pKey->eType==FTSQUERY_NEAR ){\n        assert( nKey==4 );\n        if( zInput[4]=='/' && zInput[5]>='0' && zInput[5]<='9' ){\n          nNear = 0;\n          for(nKey=5; zInput[nKey]>='0' && zInput[nKey]<='9'; nKey++){\n            nNear = nNear * 10 + (zInput[nKey] - '0');\n          }\n        }\n      }\n\n      /* At this point this is probably a keyword. But for that to be true,\n      ** the next byte must contain either whitespace, an open or close\n      ** parenthesis, a quote character, or EOF. \n      */\n      cNext = zInput[nKey];\n      if( fts3isspace(cNext) \n       || cNext=='\"' || cNext=='(' || cNext==')' || cNext==0\n      ){\n        pRet = (Fts3Expr *)fts3MallocZero(sizeof(Fts3Expr));\n        if( !pRet ){\n          return SQLITE_NOMEM;\n        }\n        pRet->eType = pKey->eType;\n        pRet->nNear = nNear;\n        *ppExpr = pRet;\n        *pnConsumed = (int)((zInput - z) + nKey);\n        return SQLITE_OK;\n      }\n\n      /* Turns out that wasn't a keyword after all. This happens if the\n      ** user has supplied a token such as \"ORacle\". Continue.\n      */\n    }\n  }\n\n  /* Check for an open bracket. */\n  if( sqlite3_fts3_enable_parentheses ){\n    if( *zInput=='(' ){\n      int nConsumed;\n      pParse->nNest++;\n      rc = fts3ExprParse(pParse, &zInput[1], nInput-1, ppExpr, &nConsumed);\n      if( rc==SQLITE_OK && !*ppExpr ){\n        rc = SQLITE_DONE;\n      }\n      *pnConsumed = (int)((zInput - z) + 1 + nConsumed);\n      return rc;\n    }\n  \n    /* Check for a close bracket. */\n    if( *zInput==')' ){\n      pParse->nNest--;\n      *pnConsumed = (int)((zInput - z) + 1);\n      return SQLITE_DONE;\n    }\n  }\n\n  /* See if we are dealing with a quoted phrase. If this is the case, then\n  ** search for the closing quote and pass the whole string to getNextString()\n  ** for processing. This is easy to do, as fts3 has no syntax for escaping\n  ** a quote character embedded in a string.\n  */\n  if( *zInput=='\"' ){\n    for(ii=1; ii<nInput && zInput[ii]!='\"'; ii++);\n    *pnConsumed = (int)((zInput - z) + ii + 1);\n    if( ii==nInput ){\n      return SQLITE_ERROR;\n    }\n    return getNextString(pParse, &zInput[1], ii-1, ppExpr);\n  }\n\n\n  /* If control flows to this point, this must be a regular token, or \n  ** the end of the input. Read a regular token using the sqlite3_tokenizer\n  ** interface. Before doing so, figure out if there is an explicit\n  ** column specifier for the token. \n  **\n  ** TODO: Strangely, it is not possible to associate a column specifier\n  ** with a quoted phrase, only with a single token. Not sure if this was\n  ** an implementation artifact or an intentional decision when fts3 was\n  ** first implemented. Whichever it was, this module duplicates the \n  ** limitation.\n  */\n  iCol = pParse->iDefaultCol;\n  iColLen = 0;\n  for(ii=0; ii<pParse->nCol; ii++){\n    const char *zStr = pParse->azCol[ii];\n    int nStr = (int)strlen(zStr);\n    if( nInput>nStr && zInput[nStr]==':' \n     && sqlite3_strnicmp(zStr, zInput, nStr)==0 \n    ){\n      iCol = ii;\n      iColLen = (int)((zInput - z) + nStr + 1);\n      break;\n    }\n  }\n  rc = getNextToken(pParse, iCol, &z[iColLen], n-iColLen, ppExpr, pnConsumed);\n  *pnConsumed += iColLen;\n  return rc;\n}\n\n/*\n** The argument is an Fts3Expr structure for a binary operator (any type\n** except an FTSQUERY_PHRASE). Return an integer value representing the\n** precedence of the operator. Lower values have a higher precedence (i.e.\n** group more tightly). For example, in the C language, the == operator\n** groups more tightly than ||, and would therefore have a higher precedence.\n**\n** When using the new fts3 query syntax (when SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined), the order of the operators in precedence from highest to\n** lowest is:\n**\n**   NEAR\n**   NOT\n**   AND (including implicit ANDs)\n**   OR\n**\n** Note that when using the old query syntax, the OR operator has a higher\n** precedence than the AND operator.\n*/\nstatic int opPrecedence(Fts3Expr *p){\n  assert( p->eType!=FTSQUERY_PHRASE );\n  if( sqlite3_fts3_enable_parentheses ){\n    return p->eType;\n  }else if( p->eType==FTSQUERY_NEAR ){\n    return 1;\n  }else if( p->eType==FTSQUERY_OR ){\n    return 2;\n  }\n  assert( p->eType==FTSQUERY_AND );\n  return 3;\n}\n\n/*\n** Argument ppHead contains a pointer to the current head of a query \n** expression tree being parsed. pPrev is the expression node most recently\n** inserted into the tree. This function adds pNew, which is always a binary\n** operator node, into the expression tree based on the relative precedence\n** of pNew and the existing nodes of the tree. This may result in the head\n** of the tree changing, in which case *ppHead is set to the new root node.\n*/\nstatic void insertBinaryOperator(\n  Fts3Expr **ppHead,       /* Pointer to the root node of a tree */\n  Fts3Expr *pPrev,         /* Node most recently inserted into the tree */\n  Fts3Expr *pNew           /* New binary node to insert into expression tree */\n){\n  Fts3Expr *pSplit = pPrev;\n  while( pSplit->pParent && opPrecedence(pSplit->pParent)<=opPrecedence(pNew) ){\n    pSplit = pSplit->pParent;\n  }\n\n  if( pSplit->pParent ){\n    assert( pSplit->pParent->pRight==pSplit );\n    pSplit->pParent->pRight = pNew;\n    pNew->pParent = pSplit->pParent;\n  }else{\n    *ppHead = pNew;\n  }\n  pNew->pLeft = pSplit;\n  pSplit->pParent = pNew;\n}\n\n/*\n** Parse the fts3 query expression found in buffer z, length n. This function\n** returns either when the end of the buffer is reached or an unmatched \n** closing bracket - ')' - is encountered.\n**\n** If successful, SQLITE_OK is returned, *ppExpr is set to point to the\n** parsed form of the expression and *pnConsumed is set to the number of\n** bytes read from buffer z. Otherwise, *ppExpr is set to 0 and SQLITE_NOMEM\n** (out of memory error) or SQLITE_ERROR (parse error) is returned.\n*/\nstatic int fts3ExprParse(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Text of MATCH query */\n  Fts3Expr **ppExpr,                      /* OUT: Parsed query structure */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  Fts3Expr *pRet = 0;\n  Fts3Expr *pPrev = 0;\n  Fts3Expr *pNotBranch = 0;               /* Only used in legacy parse mode */\n  int nIn = n;\n  const char *zIn = z;\n  int rc = SQLITE_OK;\n  int isRequirePhrase = 1;\n\n  while( rc==SQLITE_OK ){\n    Fts3Expr *p = 0;\n    int nByte = 0;\n    rc = getNextNode(pParse, zIn, nIn, &p, &nByte);\n    if( rc==SQLITE_OK ){\n      int isPhrase;\n\n      if( !sqlite3_fts3_enable_parentheses \n       && p->eType==FTSQUERY_PHRASE && pParse->isNot \n      ){\n        /* Create an implicit NOT operator. */\n        Fts3Expr *pNot = fts3MallocZero(sizeof(Fts3Expr));\n        if( !pNot ){\n          sqlite3Fts3ExprFree(p);\n          rc = SQLITE_NOMEM;\n          goto exprparse_out;\n        }\n        pNot->eType = FTSQUERY_NOT;\n        pNot->pRight = p;\n        p->pParent = pNot;\n        if( pNotBranch ){\n          pNot->pLeft = pNotBranch;\n          pNotBranch->pParent = pNot;\n        }\n        pNotBranch = pNot;\n        p = pPrev;\n      }else{\n        int eType = p->eType;\n        isPhrase = (eType==FTSQUERY_PHRASE || p->pLeft);\n\n        /* The isRequirePhrase variable is set to true if a phrase or\n        ** an expression contained in parenthesis is required. If a\n        ** binary operator (AND, OR, NOT or NEAR) is encounted when\n        ** isRequirePhrase is set, this is a syntax error.\n        */\n        if( !isPhrase && isRequirePhrase ){\n          sqlite3Fts3ExprFree(p);\n          rc = SQLITE_ERROR;\n          goto exprparse_out;\n        }\n  \n        if( isPhrase && !isRequirePhrase ){\n          /* Insert an implicit AND operator. */\n          Fts3Expr *pAnd;\n          assert( pRet && pPrev );\n          pAnd = fts3MallocZero(sizeof(Fts3Expr));\n          if( !pAnd ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_NOMEM;\n            goto exprparse_out;\n          }\n          pAnd->eType = FTSQUERY_AND;\n          insertBinaryOperator(&pRet, pPrev, pAnd);\n          pPrev = pAnd;\n        }\n\n        /* This test catches attempts to make either operand of a NEAR\n        ** operator something other than a phrase. For example, either of\n        ** the following:\n        **\n        **    (bracketed expression) NEAR phrase\n        **    phrase NEAR (bracketed expression)\n        **\n        ** Return an error in either case.\n        */\n        if( pPrev && (\n            (eType==FTSQUERY_NEAR && !isPhrase && pPrev->eType!=FTSQUERY_PHRASE)\n         || (eType!=FTSQUERY_PHRASE && isPhrase && pPrev->eType==FTSQUERY_NEAR)\n        )){\n          sqlite3Fts3ExprFree(p);\n          rc = SQLITE_ERROR;\n          goto exprparse_out;\n        }\n  \n        if( isPhrase ){\n          if( pRet ){\n            assert( pPrev && pPrev->pLeft && pPrev->pRight==0 );\n            pPrev->pRight = p;\n            p->pParent = pPrev;\n          }else{\n            pRet = p;\n          }\n        }else{\n          insertBinaryOperator(&pRet, pPrev, p);\n        }\n        isRequirePhrase = !isPhrase;\n      }\n      assert( nByte>0 );\n    }\n    assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) );\n    nIn -= nByte;\n    zIn += nByte;\n    pPrev = p;\n  }\n\n  if( rc==SQLITE_DONE && pRet && isRequirePhrase ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    if( !sqlite3_fts3_enable_parentheses && pNotBranch ){\n      if( !pRet ){\n        rc = SQLITE_ERROR;\n      }else{\n        Fts3Expr *pIter = pNotBranch;\n        while( pIter->pLeft ){\n          pIter = pIter->pLeft;\n        }\n        pIter->pLeft = pRet;\n        pRet->pParent = pIter;\n        pRet = pNotBranch;\n      }\n    }\n  }\n  *pnConsumed = n - nIn;\n\nexprparse_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRet);\n    sqlite3Fts3ExprFree(pNotBranch);\n    pRet = 0;\n  }\n  *ppExpr = pRet;\n  return rc;\n}\n\n/*\n** Return SQLITE_ERROR if the maximum depth of the expression tree passed \n** as the only argument is more than nMaxDepth.\n*/\nstatic int fts3ExprCheckDepth(Fts3Expr *p, int nMaxDepth){\n  int rc = SQLITE_OK;\n  if( p ){\n    if( nMaxDepth<0 ){ \n      rc = SQLITE_TOOBIG;\n    }else{\n      rc = fts3ExprCheckDepth(p->pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprCheckDepth(p->pRight, nMaxDepth-1);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** This function attempts to transform the expression tree at (*pp) to\n** an equivalent but more balanced form. The tree is modified in place.\n** If successful, SQLITE_OK is returned and (*pp) set to point to the \n** new root expression node. \n**\n** nMaxDepth is the maximum allowable depth of the balanced sub-tree.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and \n** expression (*pp) freed.\n*/\nstatic int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts3Expr *pRoot = *pp;          /* Initial root node */\n  Fts3Expr *pFree = 0;            /* List of free nodes. Linked by pParent. */\n  int eType = pRoot->eType;       /* Type of node in this tree */\n\n  if( nMaxDepth==0 ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_OK && (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){\n    Fts3Expr **apLeaf;\n    apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);\n    if( 0==apLeaf ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(apLeaf, 0, sizeof(Fts3Expr *) * nMaxDepth);\n    }\n\n    if( rc==SQLITE_OK ){\n      int i;\n      Fts3Expr *p;\n\n      /* Set $p to point to the left-most leaf in the tree of eType nodes. */\n      for(p=pRoot; p->eType==eType; p=p->pLeft){\n        assert( p->pParent==0 || p->pParent->pLeft==p );\n        assert( p->pLeft && p->pRight );\n      }\n\n      /* This loop runs once for each leaf in the tree of eType nodes. */\n      while( 1 ){\n        int iLvl;\n        Fts3Expr *pParent = p->pParent;     /* Current parent of p */\n\n        assert( pParent==0 || pParent->pLeft==p );\n        p->pParent = 0;\n        if( pParent ){\n          pParent->pLeft = 0;\n        }else{\n          pRoot = 0;\n        }\n        rc = fts3ExprBalance(&p, nMaxDepth-1);\n        if( rc!=SQLITE_OK ) break;\n\n        for(iLvl=0; p && iLvl<nMaxDepth; iLvl++){\n          if( apLeaf[iLvl]==0 ){\n            apLeaf[iLvl] = p;\n            p = 0;\n          }else{\n            assert( pFree );\n            pFree->pLeft = apLeaf[iLvl];\n            pFree->pRight = p;\n            pFree->pLeft->pParent = pFree;\n            pFree->pRight->pParent = pFree;\n\n            p = pFree;\n            pFree = pFree->pParent;\n            p->pParent = 0;\n            apLeaf[iLvl] = 0;\n          }\n        }\n        if( p ){\n          sqlite3Fts3ExprFree(p);\n          rc = SQLITE_TOOBIG;\n          break;\n        }\n\n        /* If that was the last leaf node, break out of the loop */\n        if( pParent==0 ) break;\n\n        /* Set $p to point to the next leaf in the tree of eType nodes */\n        for(p=pParent->pRight; p->eType==eType; p=p->pLeft);\n\n        /* Remove pParent from the original tree. */\n        assert( pParent->pParent==0 || pParent->pParent->pLeft==pParent );\n        pParent->pRight->pParent = pParent->pParent;\n        if( pParent->pParent ){\n          pParent->pParent->pLeft = pParent->pRight;\n        }else{\n          assert( pParent==pRoot );\n          pRoot = pParent->pRight;\n        }\n\n        /* Link pParent into the free node list. It will be used as an\n        ** internal node of the new tree.  */\n        pParent->pParent = pFree;\n        pFree = pParent;\n      }\n\n      if( rc==SQLITE_OK ){\n        p = 0;\n        for(i=0; i<nMaxDepth; i++){\n          if( apLeaf[i] ){\n            if( p==0 ){\n              p = apLeaf[i];\n              p->pParent = 0;\n            }else{\n              assert( pFree!=0 );\n              pFree->pRight = p;\n              pFree->pLeft = apLeaf[i];\n              pFree->pLeft->pParent = pFree;\n              pFree->pRight->pParent = pFree;\n\n              p = pFree;\n              pFree = pFree->pParent;\n              p->pParent = 0;\n            }\n          }\n        }\n        pRoot = p;\n      }else{\n        /* An error occurred. Delete the contents of the apLeaf[] array \n        ** and pFree list. Everything else is cleaned up by the call to\n        ** sqlite3Fts3ExprFree(pRoot) below.  */\n        Fts3Expr *pDel;\n        for(i=0; i<nMaxDepth; i++){\n          sqlite3Fts3ExprFree(apLeaf[i]);\n        }\n        while( (pDel=pFree)!=0 ){\n          pFree = pDel->pParent;\n          sqlite3_free(pDel);\n        }\n      }\n\n      assert( pFree==0 );\n      sqlite3_free( apLeaf );\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRoot);\n    pRoot = 0;\n  }\n  *pp = pRoot;\n  return rc;\n}\n\n/*\n** This function is similar to sqlite3Fts3ExprParse(), with the following\n** differences:\n**\n**   1. It does not do expression rebalancing.\n**   2. It does not check that the expression does not exceed the \n**      maximum allowable depth.\n**   3. Even if it fails, *ppExpr may still be set to point to an \n**      expression tree. It should be deleted using sqlite3Fts3ExprFree()\n**      in this case.\n*/\nstatic int fts3ExprParseUnbalanced(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr                   /* OUT: Parsed query structure */\n){\n  int nParsed;\n  int rc;\n  ParseContext sParse;\n\n  memset(&sParse, 0, sizeof(ParseContext));\n  sParse.pTokenizer = pTokenizer;\n  sParse.iLangid = iLangid;\n  sParse.azCol = (const char **)azCol;\n  sParse.nCol = nCol;\n  sParse.iDefaultCol = iDefaultCol;\n  sParse.bFts4 = bFts4;\n  if( z==0 ){\n    *ppExpr = 0;\n    return SQLITE_OK;\n  }\n  if( n<0 ){\n    n = (int)strlen(z);\n  }\n  rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);\n  assert( rc==SQLITE_OK || *ppExpr==0 );\n\n  /* Check for mismatched parenthesis */\n  if( rc==SQLITE_OK && sParse.nNest ){\n    rc = SQLITE_ERROR;\n  }\n  \n  return rc;\n}\n\n/*\n** Parameters z and n contain a pointer to and length of a buffer containing\n** an fts3 query expression, respectively. This function attempts to parse the\n** query expression and create a tree of Fts3Expr structures representing the\n** parsed expression. If successful, *ppExpr is set to point to the head\n** of the parsed expression tree and SQLITE_OK is returned. If an error\n** occurs, either SQLITE_NOMEM (out-of-memory error) or SQLITE_ERROR (parse\n** error) is returned and *ppExpr is set to 0.\n**\n** If parameter n is a negative number, then z is assumed to point to a\n** nul-terminated string and the length is determined using strlen().\n**\n** The first parameter, pTokenizer, is passed the fts3 tokenizer module to\n** use to normalize query tokens while parsing the expression. The azCol[]\n** array, which is assumed to contain nCol entries, should contain the names\n** of each column in the target fts3 table, in order from left to right. \n** Column names must be nul-terminated strings.\n**\n** The iDefaultCol parameter should be passed the index of the table column\n** that appears on the left-hand-side of the MATCH operator (the default\n** column to match against for tokens for which a column name is not explicitly\n** specified as part of the query string), or -1 if tokens may by default\n** match any table column.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr,                  /* OUT: Parsed query structure */\n  char **pzErr                        /* OUT: Error message (sqlite3_malloc) */\n){\n  static const int MAX_EXPR_DEPTH = 12;\n  int rc = fts3ExprParseUnbalanced(\n      pTokenizer, iLangid, azCol, bFts4, nCol, iDefaultCol, z, n, ppExpr\n  );\n  \n  /* Rebalance the expression. And check that its depth does not exceed\n  ** MAX_EXPR_DEPTH.  */\n  if( rc==SQLITE_OK && *ppExpr ){\n    rc = fts3ExprBalance(ppExpr, MAX_EXPR_DEPTH);\n    if( rc==SQLITE_OK ){\n      rc = fts3ExprCheckDepth(*ppExpr, MAX_EXPR_DEPTH);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(*ppExpr);\n    *ppExpr = 0;\n    if( rc==SQLITE_TOOBIG ){\n      *pzErr = sqlite3_mprintf(\n          \"FTS expression tree is too large (maximum depth %d)\", MAX_EXPR_DEPTH\n      );\n      rc = SQLITE_ERROR;\n    }else if( rc==SQLITE_ERROR ){\n      *pzErr = sqlite3_mprintf(\"malformed MATCH expression: [%s]\", z);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free a single node of an expression tree.\n*/\nstatic void fts3FreeExprNode(Fts3Expr *p){\n  assert( p->eType==FTSQUERY_PHRASE || p->pPhrase==0 );\n  sqlite3Fts3EvalPhraseCleanup(p->pPhrase);\n  sqlite3_free(p->aMI);\n  sqlite3_free(p);\n}\n\n/*\n** Free a parsed fts3 query expression allocated by sqlite3Fts3ExprParse().\n**\n** This function would be simpler if it recursively called itself. But\n** that would mean passing a sufficiently large expression to ExprParse()\n** could cause a stack overflow.\n*/\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *pDel){\n  Fts3Expr *p;\n  assert( pDel==0 || pDel->pParent==0 );\n  for(p=pDel; p && (p->pLeft||p->pRight); p=(p->pLeft ? p->pLeft : p->pRight)){\n    assert( p->pParent==0 || p==p->pParent->pRight || p==p->pParent->pLeft );\n  }\n  while( p ){\n    Fts3Expr *pParent = p->pParent;\n    fts3FreeExprNode(p);\n    if( pParent && p==pParent->pLeft && pParent->pRight ){\n      p = pParent->pRight;\n      while( p && (p->pLeft || p->pRight) ){\n        assert( p==p->pParent->pRight || p==p->pParent->pLeft );\n        p = (p->pLeft ? p->pLeft : p->pRight);\n      }\n    }else{\n      p = pParent;\n    }\n  }\n}\n\n/****************************************************************************\n*****************************************************************************\n** Everything after this point is just test code.\n*/\n\n#ifdef SQLITE_TEST\n\n/* #include <stdio.h> */\n\n/*\n** Function to query the hash-table of tokenizers (see README.tokenizers).\n*/\nstatic int queryTestTokenizer(\n  sqlite3 *db, \n  const char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\n/*\n** Return a pointer to a buffer containing a text representation of the\n** expression passed as the first argument. The buffer is obtained from\n** sqlite3_malloc(). It is the responsibility of the caller to use \n** sqlite3_free() to release the memory. If an OOM condition is encountered,\n** NULL is returned.\n**\n** If the second argument is not NULL, then its contents are prepended to \n** the returned expression text and then freed using sqlite3_free().\n*/\nstatic char *exprToString(Fts3Expr *pExpr, char *zBuf){\n  if( pExpr==0 ){\n    return sqlite3_mprintf(\"\");\n  }\n  switch( pExpr->eType ){\n    case FTSQUERY_PHRASE: {\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      zBuf = sqlite3_mprintf(\n          \"%zPHRASE %d 0\", zBuf, pPhrase->iColumn);\n      for(i=0; zBuf && i<pPhrase->nToken; i++){\n        zBuf = sqlite3_mprintf(\"%z %.*s%s\", zBuf, \n            pPhrase->aToken[i].n, pPhrase->aToken[i].z,\n            (pPhrase->aToken[i].isPrefix?\"+\":\"\")\n        );\n      }\n      return zBuf;\n    }\n\n    case FTSQUERY_NEAR:\n      zBuf = sqlite3_mprintf(\"%zNEAR/%d \", zBuf, pExpr->nNear);\n      break;\n    case FTSQUERY_NOT:\n      zBuf = sqlite3_mprintf(\"%zNOT \", zBuf);\n      break;\n    case FTSQUERY_AND:\n      zBuf = sqlite3_mprintf(\"%zAND \", zBuf);\n      break;\n    case FTSQUERY_OR:\n      zBuf = sqlite3_mprintf(\"%zOR \", zBuf);\n      break;\n  }\n\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z{\", zBuf);\n  if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z} {\", zBuf);\n\n  if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z}\", zBuf);\n\n  return zBuf;\n}\n\n/*\n** This is the implementation of a scalar SQL function used to test the \n** expression parser. It should be called as follows:\n**\n**   fts3_exprtest(<tokenizer>, <expr>, <column 1>, ...);\n**\n** The first argument, <tokenizer>, is the name of the fts3 tokenizer used\n** to parse the query expression (see README.tokenizers). The second argument\n** is the query expression to parse. Each subsequent argument is the name\n** of a column of the fts3 table that the query expression may refer to.\n** For example:\n**\n**   SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');\n*/\nstatic void fts3ExprTest(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_tokenizer_module const *pModule = 0;\n  sqlite3_tokenizer *pTokenizer = 0;\n  int rc;\n  char **azCol = 0;\n  const char *zExpr;\n  int nExpr;\n  int nCol;\n  int ii;\n  Fts3Expr *pExpr;\n  char *zBuf = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc<3 ){\n    sqlite3_result_error(context, \n        \"Usage: fts3_exprtest(tokenizer, expr, col1, ...\", -1\n    );\n    return;\n  }\n\n  rc = queryTestTokenizer(db,\n                          (const char *)sqlite3_value_text(argv[0]), &pModule);\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }else if( !pModule ){\n    sqlite3_result_error(context, \"No such tokenizer module\", -1);\n    goto exprtest_out;\n  }\n\n  rc = pModule->xCreate(0, 0, &pTokenizer);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  pTokenizer->pModule = pModule;\n\n  zExpr = (const char *)sqlite3_value_text(argv[1]);\n  nExpr = sqlite3_value_bytes(argv[1]);\n  nCol = argc-2;\n  azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));\n  if( !azCol ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  for(ii=0; ii<nCol; ii++){\n    azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);\n  }\n\n  if( sqlite3_user_data(context) ){\n    char *zDummy = 0;\n    rc = sqlite3Fts3ExprParse(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy\n    );\n    assert( rc==SQLITE_OK || pExpr==0 );\n    sqlite3_free(zDummy);\n  }else{\n    rc = fts3ExprParseUnbalanced(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr\n    );\n  }\n\n  if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){\n    sqlite3Fts3ExprFree(pExpr);\n    sqlite3_result_error(context, \"Error parsing expression\", -1);\n  }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n    sqlite3_free(zBuf);\n  }\n\n  sqlite3Fts3ExprFree(pExpr);\n\nexprtest_out:\n  if( pModule && pTokenizer ){\n    rc = pModule->xDestroy(pTokenizer);\n  }\n  sqlite3_free(azCol);\n}\n\n/*\n** Register the query expression parser test function fts3_exprtest() \n** with database connection db. \n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){\n  int rc = sqlite3_create_function(\n      db, \"fts3_exprtest\", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"fts3_exprtest_rebalance\", \n        -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0\n    );\n  }\n  return rc;\n}\n\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_expr.c *******************************************/\n/************** Begin file fts3_hash.c ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n\n/*\n** Malloc and Free functions\n*/\nstatic void *fts3HashMalloc(int n){\n  void *p = sqlite3_malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\nstatic void fts3HashFree(void *p){\n  sqlite3_free(p);\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS3_HASH_BINARY or FTS3_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash *pH){\n  Fts3HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  fts3HashFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    Fts3HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      fts3HashFree(elem->pKey);\n    }\n    fts3HashFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_STRING\n*/\nstatic int fts3StrHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  int h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return h & 0x7fffffff;\n}\nstatic int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_BINARY\n*/\nstatic int fts3BinHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int fts3BinCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"ftsHashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of ftsHashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of ftsHashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*ftsHashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrHash;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*ftsCompareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrCompare;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void fts3HashInsertElement(\n  Fts3Hash *pH,            /* The complete hash table */\n  struct _fts3ht *pEntry,  /* The entry into which pNew is inserted */\n  Fts3HashElem *pNew       /* The element to be inserted */\n){\n  Fts3HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n**\n** Return non-zero if a memory allocation error occurs.\n*/\nstatic int fts3Rehash(Fts3Hash *pH, int new_size){\n  struct _fts3ht *new_ht;          /* The new hash table */\n  Fts3HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts3ht *)fts3HashMalloc( new_size*sizeof(struct _fts3ht) );\n  if( new_ht==0 ) return 1;\n  fts3HashFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = ftsHashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    fts3HashInsertElement(pH, &new_ht[h], elem);\n  }\n  return 0;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic Fts3HashElem *fts3FindElementByHash(\n  const Fts3Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  Fts3HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts3ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = ftsCompareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void fts3RemoveElementByHash(\n  Fts3Hash *pH,         /* The pH containing \"elem\" */\n  Fts3HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts3ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    fts3HashFree(elem->pKey);\n  }\n  fts3HashFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts3HashClear(pH);\n  }\n}\n\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(\n  const Fts3Hash *pH, \n  const void *pKey, \n  int nKey\n){\n  int h;                          /* A hash on key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));\n}\n\n/* \n** Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){\n  Fts3HashElem *pElem;            /* The element that matches key (if any) */\n\n  pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);\n  return pElem ? pElem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(\n  Fts3Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  Fts3HashElem *elem;       /* Used to loop thru the element list */\n  Fts3HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = fts3FindElementByHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      fts3RemoveElementByHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  if( (pH->htsize==0 && fts3Rehash(pH,8))\n   || (pH->count>=pH->htsize && fts3Rehash(pH, pH->htsize*2))\n  ){\n    pH->count = 0;\n    return data;\n  }\n  assert( pH->htsize>0 );\n  new_elem = (Fts3HashElem*)fts3HashMalloc( sizeof(Fts3HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = fts3HashMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      fts3HashFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  fts3HashInsertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_hash.c *******************************************/\n/************** Begin file fts3_porter.c *************************************/\n/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlite3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->zToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1];\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    isVowel(z+1) &&\n    isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=(int)sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     stem(&z, \"lanoita\", \"ate\", m_gt_0) ||\n     stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     break;\n   case 'c':\n     stem(&z, \"icne\", \"ence\", m_gt_0) ||\n     stem(&z, \"icna\", \"ance\", m_gt_0);\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"ilb\", \"ble\", m_gt_0) ||\n     stem(&z, \"illa\", \"al\", m_gt_0) ||\n     stem(&z, \"iltne\", \"ent\", m_gt_0) ||\n     stem(&z, \"ile\", \"e\", m_gt_0) ||\n     stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     break;\n   case 'o':\n     stem(&z, \"noitazi\", \"ize\", m_gt_0) ||\n     stem(&z, \"noita\", \"ate\", m_gt_0) ||\n     stem(&z, \"rota\", \"ate\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"msila\", \"al\", m_gt_0) ||\n     stem(&z, \"ssenevi\", \"ive\", m_gt_0) ||\n     stem(&z, \"ssenluf\", \"ful\", m_gt_0) ||\n     stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     break;\n   case 't':\n     stem(&z, \"itila\", \"al\", m_gt_0) ||\n     stem(&z, \"itivi\", \"ive\", m_gt_0) ||\n     stem(&z, \"itilib\", \"ble\", m_gt_0);\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     stem(&z, \"etaci\", \"ic\", m_gt_0) ||\n     stem(&z, \"evita\", \"\", m_gt_0)   ||\n     stem(&z, \"ezila\", \"al\", m_gt_0);\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"laci\", \"ic\", m_gt_0) ||\n     stem(&z, \"luf\", \"\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         stem(&z, \"tneme\", \"\", m_gt_1) ||\n         stem(&z, \"tnem\", \"\", m_gt_1) ||\n         stem(&z, \"tne\", \"\", m_gt_1);\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     stem(&z, \"eta\", \"\", m_gt_1) ||\n     stem(&z, \"iti\", \"\", m_gt_1);\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = (int)strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char porterIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !porterIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        char *pNew;\n        c->nAllocated = n+20;\n        pNew = sqlite3_realloc(c->zToken, c->nAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->zToken = pNew;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n  0\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_porter.c *****************************************/\n/************** Begin file fts3_tokenizer.c **********************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is part of an SQLite module implementing full-text search.\n** This particular file implements the generic tokenizer interface.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <string.h> */\n\n/*\n** Implementation of the SQL scalar function for accessing the underlying \n** hash table. This function may be called as follows:\n**\n**   SELECT <function-name>(<key-name>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer').\n**\n** If the <pointer> argument is specified, it must be a blob value\n** containing a pointer to be stored as the hash data corresponding\n** to the string <key-name>. If <pointer> is not specified, then\n** the string <key-name> must already exist in the has table. Otherwise,\n** an error is returned.\n**\n** Whether or not the <pointer> argument is specified, the value returned\n** is a blob containing the pointer stored as the hash data corresponding\n** to string <key-name> (after the hash-table is updated, if applicable).\n*/\nstatic void scalarFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  void *pPtr = 0;\n  const unsigned char *zName;\n  int nName;\n\n  assert( argc==1 || argc==2 );\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n\n  zName = sqlite3_value_text(argv[0]);\n  nName = sqlite3_value_bytes(argv[0])+1;\n\n  if( argc==2 ){\n    void *pOld;\n    int n = sqlite3_value_bytes(argv[1]);\n    if( n!=sizeof(pPtr) ){\n      sqlite3_result_error(context, \"argument type mismatch\", -1);\n      return;\n    }\n    pPtr = *(void **)sqlite3_value_blob(argv[1]);\n    pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);\n    if( pOld==pPtr ){\n      sqlite3_result_error(context, \"out of memory\", -1);\n      return;\n    }\n  }else{\n    pPtr = sqlite3Fts3HashFind(pHash, zName, nName);\n    if( !pPtr ){\n      char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n  }\n\n  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){\n  static const char isFtsIdChar[] = {\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */\n      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n  };\n  return (c&0x80 || isFtsIdChar[(int)(c)]);\n}\n\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *zStr, int *pn){\n  const char *z1;\n  const char *z2 = 0;\n\n  /* Find the start of the next token. */\n  z1 = zStr;\n  while( z2==0 ){\n    char c = *z1;\n    switch( c ){\n      case '\\0': return 0;        /* No more tokens here */\n      case '\\'':\n      case '\"':\n      case '`': {\n        z2 = z1;\n        while( *++z2 && (*z2!=c || *++z2==c) );\n        break;\n      }\n      case '[':\n        z2 = &z1[1];\n        while( *z2 && z2[0]!=']' ) z2++;\n        if( *z2 ) z2++;\n        break;\n\n      default:\n        if( sqlite3Fts3IsIdChar(*z1) ){\n          z2 = &z1[1];\n          while( sqlite3Fts3IsIdChar(*z2) ) z2++;\n        }else{\n          z1++;\n        }\n    }\n  }\n\n  *pn = (int)(z2-z1);\n  return z1;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(\n  Fts3Hash *pHash,                /* Tokenizer hash table */\n  const char *zArg,               /* Tokenizer name */\n  sqlite3_tokenizer **ppTok,      /* OUT: Tokenizer (if applicable) */\n  char **pzErr                    /* OUT: Set to malloced error message */\n){\n  int rc;\n  char *z = (char *)zArg;\n  int n = 0;\n  char *zCopy;\n  char *zEnd;                     /* Pointer to nul-term of zCopy */\n  sqlite3_tokenizer_module *m;\n\n  zCopy = sqlite3_mprintf(\"%s\", zArg);\n  if( !zCopy ) return SQLITE_NOMEM;\n  zEnd = &zCopy[strlen(zCopy)];\n\n  z = (char *)sqlite3Fts3NextToken(zCopy, &n);\n  z[n] = '\\0';\n  sqlite3Fts3Dequote(z);\n\n  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);\n  if( !m ){\n    *pzErr = sqlite3_mprintf(\"unknown tokenizer: %s\", z);\n    rc = SQLITE_ERROR;\n  }else{\n    char const **aArg = 0;\n    int iArg = 0;\n    z = &z[n+1];\n    while( z<zEnd && (NULL!=(z = (char *)sqlite3Fts3NextToken(z, &n))) ){\n      int nNew = sizeof(char *)*(iArg+1);\n      char const **aNew = (const char **)sqlite3_realloc((void *)aArg, nNew);\n      if( !aNew ){\n        sqlite3_free(zCopy);\n        sqlite3_free((void *)aArg);\n        return SQLITE_NOMEM;\n      }\n      aArg = aNew;\n      aArg[iArg++] = z;\n      z[n] = '\\0';\n      sqlite3Fts3Dequote(z);\n      z = &z[n+1];\n    }\n    rc = m->xCreate(iArg, aArg, ppTok);\n    assert( rc!=SQLITE_OK || *ppTok );\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"unknown tokenizer\");\n    }else{\n      (*ppTok)->pModule = m; \n    }\n    sqlite3_free((void *)aArg);\n  }\n\n  sqlite3_free(zCopy);\n  return rc;\n}\n\n\n#ifdef SQLITE_TEST\n\n/* #include <tcl.h> */\n/* #include <string.h> */\n\n/*\n** Implementation of a special SQL scalar function for testing tokenizers \n** designed to be used in concert with the Tcl testing framework. This\n** function must be called with two or more arguments:\n**\n**   SELECT <function-name>(<key-name>, ..., <input-string>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer')\n** concatenated with the string '_test' (e.g. 'fts3_tokenizer_test').\n**\n** The return value is a string that may be interpreted as a Tcl\n** list. For each token in the <input-string>, three elements are\n** added to the returned list. The first is the token position, the \n** second is the token text (folded, stemmed, etc.) and the third is the\n** substring of <input-string> associated with the token. For example, \n** using the built-in \"simple\" tokenizer:\n**\n**   SELECT fts_tokenizer_test('simple', 'I don't see how');\n**\n** will return the string:\n**\n**   \"{0 i I 1 dont don't 2 see see 3 how how}\"\n**   \n*/\nstatic void testFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  sqlite3_tokenizer_module *p;\n  sqlite3_tokenizer *pTokenizer = 0;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n\n  const char *zErr = 0;\n\n  const char *zName;\n  int nName;\n  const char *zInput;\n  int nInput;\n\n  const char *azArg[64];\n\n  const char *zToken;\n  int nToken = 0;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int i;\n\n  Tcl_Obj *pRet;\n\n  if( argc<2 ){\n    sqlite3_result_error(context, \"insufficient arguments\", -1);\n    return;\n  }\n\n  nName = sqlite3_value_bytes(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[0]);\n  nInput = sqlite3_value_bytes(argv[argc-1]);\n  zInput = (const char *)sqlite3_value_text(argv[argc-1]);\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n\n  if( !p ){\n    char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  for(i=1; i<argc-1; i++){\n    azArg[i-1] = (const char *)sqlite3_value_text(argv[i]);\n  }\n\n  if( SQLITE_OK!=p->xCreate(argc-2, azArg, &pTokenizer) ){\n    zErr = \"error in xCreate()\";\n    goto finish;\n  }\n  pTokenizer->pModule = p;\n  if( sqlite3Fts3OpenTokenizer(pTokenizer, 0, zInput, nInput, &pCsr) ){\n    zErr = \"error in xOpen()\";\n    goto finish;\n  }\n\n  while( SQLITE_OK==p->xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos) ){\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(iPos));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n    zToken = &zInput[iStart];\n    nToken = iEnd-iStart;\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n  }\n\n  if( SQLITE_OK!=p->xClose(pCsr) ){\n    zErr = \"error in xClose()\";\n    goto finish;\n  }\n  if( SQLITE_OK!=p->xDestroy(pTokenizer) ){\n    zErr = \"error in xDestroy()\";\n    goto finish;\n  }\n\nfinish:\n  if( zErr ){\n    sqlite3_result_error(context, zErr, -1);\n  }else{\n    sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  }\n  Tcl_DecrRefCount(pRet);\n}\n\nstatic\nint registerTokenizer(\n  sqlite3 *db, \n  char *zName, \n  const sqlite3_tokenizer_module *p\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?, ?)\";\n\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n  sqlite3_step(pStmt);\n\n  return sqlite3_finalize(pStmt);\n}\n\nstatic\nint queryTokenizer(\n  sqlite3 *db, \n  char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n/*\n** Implementation of the scalar function fts3_tokenizer_internal_test().\n** This function is used for testing only, it is not included in the\n** build unless SQLITE_TEST is defined.\n**\n** The purpose of this is to test that the fts3_tokenizer() function\n** can be used as designed by the C-code in the queryTokenizer and\n** registerTokenizer() functions above. These two functions are repeated\n** in the README.tokenizer file as an example, so it is important to\n** test them.\n**\n** To run the tests, evaluate the fts3_tokenizer_internal_test() scalar\n** function with no arguments. An assert() will fail if a problem is\n** detected. i.e.:\n**\n**     SELECT fts3_tokenizer_internal_test();\n**\n*/\nstatic void intTestFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc;\n  const sqlite3_tokenizer_module *p1;\n  const sqlite3_tokenizer_module *p2;\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  /* Test the query function */\n  sqlite3Fts3SimpleTokenizerModule(&p1);\n  rc = queryTokenizer(db, \"simple\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p1==p2 );\n  rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_ERROR );\n  assert( p2==0 );\n  assert( 0==strcmp(sqlite3_errmsg(db), \"unknown tokenizer: nosuchtokenizer\") );\n\n  /* Test the storage function */\n  rc = registerTokenizer(db, \"nosuchtokenizer\", p1);\n  assert( rc==SQLITE_OK );\n  rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p2==p1 );\n\n  sqlite3_result_text(context, \"ok\", -1, SQLITE_STATIC);\n}\n\n#endif\n\n/*\n** Set up SQL objects in database db used to access the contents of\n** the hash table pointed to by argument pHash. The hash table must\n** been initialized to use string keys, and to take a private copy \n** of the key when a value is inserted. i.e. by a call similar to:\n**\n**    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n**\n** This function adds a scalar function (see header comment above\n** scalarFunc() in this file for details) and, if ENABLE_TABLE is\n** defined at compilation time, a temporary virtual table (see header \n** comment above struct HashTableVtab) to the database schema. Both \n** provide read/write access to the contents of *pHash.\n**\n** The third argument to this function, zName, is used as the name\n** of both the scalar and, if created, the virtual table.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(\n  sqlite3 *db, \n  Fts3Hash *pHash, \n  const char *zName\n){\n  int rc = SQLITE_OK;\n  void *p = (void *)pHash;\n  const int any = SQLITE_ANY;\n\n#ifdef SQLITE_TEST\n  char *zTest = 0;\n  char *zTest2 = 0;\n  void *pdb = (void *)db;\n  zTest = sqlite3_mprintf(\"%s_test\", zName);\n  zTest2 = sqlite3_mprintf(\"%s_internal_test\", zName);\n  if( !zTest || !zTest2 ){\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0);\n  }\n#ifdef SQLITE_TEST\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0);\n  }\n#endif\n\n#ifdef SQLITE_TEST\n  sqlite3_free(zTest);\n  sqlite3_free(zTest2);\n#endif\n\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer.c **************************************/\n/************** Begin file fts3_tokenizer1.c *********************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\nstatic int simpleDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\nstatic int fts3_isalnum(int x){\n  return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = (int)strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        sqlite3_free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !fts3_isalnum(i) ? -1 : 0;\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->pToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        char *pNew;\n        c->nTokenAllocated = n+20;\n        pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->pToken = pNew;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = (char)((ch>='A' && ch<='Z') ? ch-'A'+'a' : ch);\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n  0,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer1.c *************************************/\n/************** Begin file fts3_tokenize_vtab.c ******************************/\n/*\n** 2013 Apr 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for the \"fts3tokenize\" virtual table module.\n** An fts3tokenize virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(\n**       <tokenizer-name>, <arg-1>, ...\n**   );\n**\n** The table created has the following schema:\n**\n**   CREATE TABLE <tbl>(input, token, start, end, position)\n**\n** When queried, the query must include a WHERE clause of type:\n**\n**   input = <string>\n**\n** The virtual table module tokenizes this <string>, using the FTS3 \n** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE \n** statement and returns one row for each token in the result. With\n** fields set as follows:\n**\n**   input:   Always set to a copy of <string>\n**   token:   A token from the input.\n**   start:   Byte offset of the token within the input <string>.\n**   end:     Byte offset of the byte immediately following the end of the\n**            token within the input string.\n**   pos:     Token offset of token within input.\n**\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3tokTable Fts3tokTable;\ntypedef struct Fts3tokCursor Fts3tokCursor;\n\n/*\n** Virtual table structure.\n*/\nstruct Fts3tokTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  const sqlite3_tokenizer_module *pMod;\n  sqlite3_tokenizer *pTok;\n};\n\n/*\n** Virtual table cursor structure.\n*/\nstruct Fts3tokCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  char *zInput;                   /* Input string */\n  sqlite3_tokenizer_cursor *pCsr; /* Cursor to iterate through zInput */\n  int iRowid;                     /* Current 'rowid' value */\n  const char *zToken;             /* Current 'token' value */\n  int nToken;                     /* Size of zToken in bytes */\n  int iStart;                     /* Current 'start' value */\n  int iEnd;                       /* Current 'end' value */\n  int iPos;                       /* Current 'pos' value */\n};\n\n/*\n** Query FTS for the tokenizer implementation named zName.\n*/\nstatic int fts3tokQueryTokenizer(\n  Fts3Hash *pHash,\n  const char *zName,\n  const sqlite3_tokenizer_module **pp,\n  char **pzErr\n){\n  sqlite3_tokenizer_module *p;\n  int nName = (int)strlen(zName);\n\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n  if( !p ){\n    *pzErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    return SQLITE_ERROR;\n  }\n\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** The second argument, argv[], is an array of pointers to nul-terminated\n** strings. This function makes a copy of the array and strings into a \n** single block of memory. It then dequotes any of the strings that appear\n** to be quoted.\n**\n** If successful, output parameter *pazDequote is set to point at the\n** array of dequoted strings and SQLITE_OK is returned. The caller is\n** responsible for eventually calling sqlite3_free() to free the array\n** in this case. Or, if an error occurs, an SQLite error code is returned.\n** The final value of *pazDequote is undefined in this case.\n*/\nstatic int fts3tokDequoteArray(\n  int argc,                       /* Number of elements in argv[] */\n  const char * const *argv,       /* Input array */\n  char ***pazDequote              /* Output array */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( argc==0 ){\n    *pazDequote = 0;\n  }else{\n    int i;\n    int nByte = 0;\n    char **azDequote;\n\n    for(i=0; i<argc; i++){\n      nByte += (int)(strlen(argv[i]) + 1);\n    }\n\n    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);\n    if( azDequote==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *pSpace = (char *)&azDequote[argc];\n      for(i=0; i<argc; i++){\n        int n = (int)strlen(argv[i]);\n        azDequote[i] = pSpace;\n        memcpy(pSpace, argv[i], n+1);\n        sqlite3Fts3Dequote(pSpace);\n        pSpace += (n+1);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Schema of the tokenizer table.\n*/\n#define FTS3_TOK_SCHEMA \"CREATE TABLE x(input, token, start, end, position)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n**\n**   argv[0]: module name\n**   argv[1]: database name \n**   argv[2]: table name\n**   argv[3]: first argument (tokenizer name)\n*/\nstatic int fts3tokConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pHash,                    /* Hash table of tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  Fts3tokTable *pTab;\n  const sqlite3_tokenizer_module *pMod = 0;\n  sqlite3_tokenizer *pTok = 0;\n  int rc;\n  char **azDequote = 0;\n  int nDequote;\n\n  rc = sqlite3_declare_vtab(db, FTS3_TOK_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nDequote = argc-3;\n  rc = fts3tokDequoteArray(nDequote, &argv[3], &azDequote);\n\n  if( rc==SQLITE_OK ){\n    const char *zModule;\n    if( nDequote<1 ){\n      zModule = \"simple\";\n    }else{\n      zModule = azDequote[0];\n    }\n    rc = fts3tokQueryTokenizer((Fts3Hash*)pHash, zModule, &pMod, pzErr);\n  }\n\n  assert( (rc==SQLITE_OK)==(pMod!=0) );\n  if( rc==SQLITE_OK ){\n    const char * const *azArg = (const char * const *)&azDequote[1];\n    rc = pMod->xCreate((nDequote>1 ? nDequote-1 : 0), azArg, &pTok);\n  }\n\n  if( rc==SQLITE_OK ){\n    pTab = (Fts3tokTable *)sqlite3_malloc(sizeof(Fts3tokTable));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(Fts3tokTable));\n    pTab->pMod = pMod;\n    pTab->pTok = pTok;\n    *ppVtab = &pTab->base;\n  }else{\n    if( pTok ){\n      pMod->xDestroy(pTok);\n    }\n  }\n\n  sqlite3_free(azDequote);\n  return rc;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3tokDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3tokTable *pTab = (Fts3tokTable *)pVtab;\n\n  pTab->pMod->xDestroy(pTab->pTok);\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3tokBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  UNUSED_PARAMETER(pVTab);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable \n     && pInfo->aConstraint[i].iColumn==0 \n     && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      pInfo->idxNum = 1;\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->estimatedCost = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  pInfo->idxNum = 0;\n  assert( pInfo->estimatedCost>1000000.0 );\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3tokCursor *pCsr;\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3tokCursor *)sqlite3_malloc(sizeof(Fts3tokCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3tokCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the tokenizer cursor passed as the only argument. As if it had\n** just been returned by fts3tokOpenMethod().\n*/\nstatic void fts3tokResetCursor(Fts3tokCursor *pCsr){\n  if( pCsr->pCsr ){\n    Fts3tokTable *pTab = (Fts3tokTable *)(pCsr->base.pVtab);\n    pTab->pMod->xClose(pCsr->pCsr);\n    pCsr->pCsr = 0;\n  }\n  sqlite3_free(pCsr->zInput);\n  pCsr->zInput = 0;\n  pCsr->zToken = 0;\n  pCsr->nToken = 0;\n  pCsr->iStart = 0;\n  pCsr->iEnd = 0;\n  pCsr->iPos = 0;\n  pCsr->iRowid = 0;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3tokCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  fts3tokResetCursor(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3tokNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  int rc;                         /* Return code */\n\n  pCsr->iRowid++;\n  rc = pTab->pMod->xNext(pCsr->pCsr,\n      &pCsr->zToken, &pCsr->nToken,\n      &pCsr->iStart, &pCsr->iEnd, &pCsr->iPos\n  );\n\n  if( rc!=SQLITE_OK ){\n    fts3tokResetCursor(pCsr);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3tokFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_ERROR;\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  fts3tokResetCursor(pCsr);\n  if( idxNum==1 ){\n    const char *zByte = (const char *)sqlite3_value_text(apVal[0]);\n    int nByte = sqlite3_value_bytes(apVal[0]);\n    pCsr->zInput = sqlite3_malloc(nByte+1);\n    if( pCsr->zInput==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memcpy(pCsr->zInput, zByte, nByte);\n      pCsr->zInput[nByte] = 0;\n      rc = pTab->pMod->xOpen(pTab->pTok, pCsr->zInput, nByte, &pCsr->pCsr);\n      if( rc==SQLITE_OK ){\n        pCsr->pCsr->pTokenizer = pTab->pTok;\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ) return rc;\n  return fts3tokNextMethod(pCursor);\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3tokEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  return (pCsr->zToken==0);\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3tokColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  /* CREATE TABLE x(input, token, start, end, position) */\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_text(pCtx, pCsr->zToken, pCsr->nToken, SQLITE_TRANSIENT);\n      break;\n    case 2:\n      sqlite3_result_int(pCtx, pCsr->iStart);\n      break;\n    case 3:\n      sqlite3_result_int(pCtx, pCsr->iEnd);\n      break;\n    default:\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, pCsr->iPos);\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3tokRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  *pRowid = (sqlite3_int64)pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3tok module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){\n  static const sqlite3_module fts3tok_module = {\n     0,                           /* iVersion      */\n     fts3tokConnectMethod,        /* xCreate       */\n     fts3tokConnectMethod,        /* xConnect      */\n     fts3tokBestIndexMethod,      /* xBestIndex    */\n     fts3tokDisconnectMethod,     /* xDisconnect   */\n     fts3tokDisconnectMethod,     /* xDestroy      */\n     fts3tokOpenMethod,           /* xOpen         */\n     fts3tokCloseMethod,          /* xClose        */\n     fts3tokFilterMethod,         /* xFilter       */\n     fts3tokNextMethod,           /* xNext         */\n     fts3tokEofMethod,            /* xEof          */\n     fts3tokColumnMethod,         /* xColumn       */\n     fts3tokRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts3tokenize\", &fts3tok_module, (void*)pHash);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenize_vtab.c **********************************/\n/************** Begin file fts3_write.c **************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is part of the SQLite FTS3 extension module. Specifically,\n** this file contains code to insert, update and delete rows from FTS3\n** tables. It also contains code to merge FTS3 b-tree segments. Some\n** of the sub-routines used to merge segments are also used by the query \n** code in fts3.c.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n\n\n#define FTS_MAX_APPENDABLE_HEIGHT 16\n\n/*\n** When full-text index nodes are loaded from disk, the buffer that they\n** are loaded into has the following number of bytes of padding at the end \n** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer\n** of 920 bytes is allocated for it.\n**\n** This means that if we have a pointer into a buffer containing node data,\n** it is always safe to read up to two varints from it without risking an\n** overread, even if the node data is corrupted.\n*/\n#define FTS3_NODE_PADDING (FTS3_VARINT_MAX*2)\n\n/*\n** Under certain circumstances, b-tree nodes (doclists) can be loaded into\n** memory incrementally instead of all at once. This can be a big performance\n** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()\n** method before retrieving all query results (as may happen, for example,\n** if a query has a LIMIT clause).\n**\n** Incremental loading is used for b-tree nodes FTS3_NODE_CHUNK_THRESHOLD \n** bytes and larger. Nodes are loaded in chunks of FTS3_NODE_CHUNKSIZE bytes.\n** The code is written so that the hard lower-limit for each of these values \n** is 1. Clearly such small values would be inefficient, but can be useful \n** for testing purposes.\n**\n** If this module is built with SQLITE_TEST defined, these constants may\n** be overridden at runtime for testing purposes. File fts3_test.c contains\n** a Tcl interface to read and write the values.\n*/\n#ifdef SQLITE_TEST\nint test_fts3_node_chunksize = (4*1024);\nint test_fts3_node_chunk_threshold = (4*1024)*4;\n# define FTS3_NODE_CHUNKSIZE       test_fts3_node_chunksize\n# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold\n#else\n# define FTS3_NODE_CHUNKSIZE (4*1024) \n# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)\n#endif\n\n/*\n** The two values that may be meaningfully bound to the :1 parameter in\n** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.\n*/\n#define FTS_STAT_DOCTOTAL      0\n#define FTS_STAT_INCRMERGEHINT 1\n#define FTS_STAT_AUTOINCRMERGE 2\n\n/*\n** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic\n** and incremental merge operation that takes place. This is used for \n** debugging FTS only, it should not usually be turned on in production\n** systems.\n*/\n#ifdef FTS3_LOG_MERGES\nstatic void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){\n  sqlite3_log(SQLITE_OK, \"%d-way merge from level %d\", nMerge, (int)iAbsLevel);\n}\n#else\n#define fts3LogMerge(x, y)\n#endif\n\n\ntypedef struct PendingList PendingList;\ntypedef struct SegmentNode SegmentNode;\ntypedef struct SegmentWriter SegmentWriter;\n\n/*\n** An instance of the following data structure is used to build doclists\n** incrementally. See function fts3PendingListAppend() for details.\n*/\nstruct PendingList {\n  int nData;\n  char *aData;\n  int nSpace;\n  sqlite3_int64 iLastDocid;\n  sqlite3_int64 iLastCol;\n  sqlite3_int64 iLastPos;\n};\n\n\n/*\n** Each cursor has a (possibly empty) linked list of the following objects.\n*/\nstruct Fts3DeferredToken {\n  Fts3PhraseToken *pToken;        /* Pointer to corresponding expr token */\n  int iCol;                       /* Column token must occur in */\n  Fts3DeferredToken *pNext;       /* Next in list of deferred tokens */\n  PendingList *pList;             /* Doclist is assembled here */\n};\n\n/*\n** An instance of this structure is used to iterate through the terms on\n** a contiguous set of segment b-tree leaf nodes. Although the details of\n** this structure are only manipulated by code in this file, opaque handles\n** of type Fts3SegReader* are also used by code in fts3.c to iterate through\n** terms when querying the full-text index. See functions:\n**\n**   sqlite3Fts3SegReaderNew()\n**   sqlite3Fts3SegReaderFree()\n**   sqlite3Fts3SegReaderIterate()\n**\n** Methods used to manipulate Fts3SegReader structures:\n**\n**   fts3SegReaderNext()\n**   fts3SegReaderFirstDocid()\n**   fts3SegReaderNextDocid()\n*/\nstruct Fts3SegReader {\n  int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */\n  u8 bLookup;                     /* True for a lookup only */\n  u8 rootOnly;                    /* True for a root-only reader */\n\n  sqlite3_int64 iStartBlock;      /* Rowid of first leaf block to traverse */\n  sqlite3_int64 iLeafEndBlock;    /* Rowid of final leaf block to traverse */\n  sqlite3_int64 iEndBlock;        /* Rowid of final block in segment (or 0) */\n  sqlite3_int64 iCurrentBlock;    /* Current leaf block (or 0) */\n\n  char *aNode;                    /* Pointer to node data (or NULL) */\n  int nNode;                      /* Size of buffer at aNode (or 0) */\n  int nPopulate;                  /* If >0, bytes of buffer aNode[] loaded */\n  sqlite3_blob *pBlob;            /* If not NULL, blob handle to read node */\n\n  Fts3HashElem **ppNextElem;\n\n  /* Variables set by fts3SegReaderNext(). These may be read directly\n  ** by the caller. They are valid from the time SegmentReaderNew() returns\n  ** until SegmentReaderNext() returns something other than SQLITE_OK\n  ** (i.e. SQLITE_DONE).\n  */\n  int nTerm;                      /* Number of bytes in current term */\n  char *zTerm;                    /* Pointer to current term */\n  int nTermAlloc;                 /* Allocated size of zTerm buffer */\n  char *aDoclist;                 /* Pointer to doclist of current entry */\n  int nDoclist;                   /* Size of doclist in current entry */\n\n  /* The following variables are used by fts3SegReaderNextDocid() to iterate \n  ** through the current doclist (aDoclist/nDoclist).\n  */\n  char *pOffsetList;\n  int nOffsetList;                /* For descending pending seg-readers only */\n  sqlite3_int64 iDocid;\n};\n\n#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)\n#define fts3SegReaderIsRootOnly(p) ((p)->rootOnly!=0)\n\n/*\n** An instance of this structure is used to create a segment b-tree in the\n** database. The internal details of this type are only accessed by the\n** following functions:\n**\n**   fts3SegWriterAdd()\n**   fts3SegWriterFlush()\n**   fts3SegWriterFree()\n*/\nstruct SegmentWriter {\n  SegmentNode *pTree;             /* Pointer to interior tree structure */\n  sqlite3_int64 iFirst;           /* First slot in %_segments written */\n  sqlite3_int64 iFree;            /* Next free slot in %_segments */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nSize;                      /* Size of allocation at aData */\n  int nData;                      /* Bytes of data in aData */\n  char *aData;                    /* Pointer to block from malloc() */\n};\n\n/*\n** Type SegmentNode is used by the following three functions to create\n** the interior part of the segment b+-tree structures (everything except\n** the leaf nodes). These functions and type are only ever used by code\n** within the fts3SegWriterXXX() family of functions described above.\n**\n**   fts3NodeAddTerm()\n**   fts3NodeWrite()\n**   fts3NodeFree()\n**\n** When a b+tree is written to the database (either as a result of a merge\n** or the pending-terms table being flushed), leaves are written into the \n** database file as soon as they are completely populated. The interior of\n** the tree is assembled in memory and written out only once all leaves have\n** been populated and stored. This is Ok, as the b+-tree fanout is usually\n** very large, meaning that the interior of the tree consumes relatively \n** little memory.\n*/\nstruct SegmentNode {\n  SegmentNode *pParent;           /* Parent node (or NULL for root node) */\n  SegmentNode *pRight;            /* Pointer to right-sibling */\n  SegmentNode *pLeftmost;         /* Pointer to left-most node of this depth */\n  int nEntry;                     /* Number of terms written to node so far */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nData;                      /* Bytes of valid data so far */\n  char *aData;                    /* Node data */\n};\n\n/*\n** Valid values for the second argument to fts3SqlStmt().\n*/\n#define SQL_DELETE_CONTENT             0\n#define SQL_IS_EMPTY                   1\n#define SQL_DELETE_ALL_CONTENT         2 \n#define SQL_DELETE_ALL_SEGMENTS        3\n#define SQL_DELETE_ALL_SEGDIR          4\n#define SQL_DELETE_ALL_DOCSIZE         5\n#define SQL_DELETE_ALL_STAT            6\n#define SQL_SELECT_CONTENT_BY_ROWID    7\n#define SQL_NEXT_SEGMENT_INDEX         8\n#define SQL_INSERT_SEGMENTS            9\n#define SQL_NEXT_SEGMENTS_ID          10\n#define SQL_INSERT_SEGDIR             11\n#define SQL_SELECT_LEVEL              12\n#define SQL_SELECT_LEVEL_RANGE        13\n#define SQL_SELECT_LEVEL_COUNT        14\n#define SQL_SELECT_SEGDIR_MAX_LEVEL   15\n#define SQL_DELETE_SEGDIR_LEVEL       16\n#define SQL_DELETE_SEGMENTS_RANGE     17\n#define SQL_CONTENT_INSERT            18\n#define SQL_DELETE_DOCSIZE            19\n#define SQL_REPLACE_DOCSIZE           20\n#define SQL_SELECT_DOCSIZE            21\n#define SQL_SELECT_STAT               22\n#define SQL_REPLACE_STAT              23\n\n#define SQL_SELECT_ALL_PREFIX_LEVEL   24\n#define SQL_DELETE_ALL_TERMS_SEGDIR   25\n#define SQL_DELETE_SEGDIR_RANGE       26\n#define SQL_SELECT_ALL_LANGID         27\n#define SQL_FIND_MERGE_LEVEL          28\n#define SQL_MAX_LEAF_NODE_ESTIMATE    29\n#define SQL_DELETE_SEGDIR_ENTRY       30\n#define SQL_SHIFT_SEGDIR_ENTRY        31\n#define SQL_SELECT_SEGDIR             32\n#define SQL_CHOMP_SEGDIR              33\n#define SQL_SEGMENT_IS_APPENDABLE     34\n#define SQL_SELECT_INDEXES            35\n#define SQL_SELECT_MXLEVEL            36\n\n/*\n** This function is used to obtain an SQLite prepared statement handle\n** for the statement identified by the second argument. If successful,\n** *pp is set to the requested statement handle and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned and *pp is set to 0.\n**\n** If argument apVal is not NULL, then it must point to an array with\n** at least as many entries as the requested statement has bound \n** parameters. The values are bound to the statements parameters before\n** returning.\n*/\nstatic int fts3SqlStmt(\n  Fts3Table *p,                   /* Virtual table handle */\n  int eStmt,                      /* One of the SQL_XXX constants above */\n  sqlite3_stmt **pp,              /* OUT: Statement handle */\n  sqlite3_value **apVal           /* Values to bind to statement */\n){\n  const char *azSql[] = {\n/* 0  */  \"DELETE FROM %Q.'%q_content' WHERE rowid = ?\",\n/* 1  */  \"SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)\",\n/* 2  */  \"DELETE FROM %Q.'%q_content'\",\n/* 3  */  \"DELETE FROM %Q.'%q_segments'\",\n/* 4  */  \"DELETE FROM %Q.'%q_segdir'\",\n/* 5  */  \"DELETE FROM %Q.'%q_docsize'\",\n/* 6  */  \"DELETE FROM %Q.'%q_stat'\",\n/* 7  */  \"SELECT %s WHERE rowid=?\",\n/* 8  */  \"SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1\",\n/* 9  */  \"REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)\",\n/* 10 */  \"SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)\",\n/* 11 */  \"REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 12 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC\",\n/* 13 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\"\n            \"ORDER BY level DESC, idx ASC\",\n\n/* 14 */  \"SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 15 */  \"SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n\n/* 16 */  \"DELETE FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 17 */  \"DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?\",\n/* 18 */  \"INSERT INTO %Q.'%q_content' VALUES(%s)\",\n/* 19 */  \"DELETE FROM %Q.'%q_docsize' WHERE docid = ?\",\n/* 20 */  \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",\n/* 21 */  \"SELECT size FROM %Q.'%q_docsize' WHERE docid=?\",\n/* 22 */  \"SELECT value FROM %Q.'%q_stat' WHERE id=?\",\n/* 23 */  \"REPLACE INTO %Q.'%q_stat' VALUES(?,?)\",\n/* 24 */  \"\",\n/* 25 */  \"\",\n\n/* 26 */ \"DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n/* 27 */ \"SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'\",\n\n/* This statement is used to determine which level to read the input from\n** when performing an incremental merge. It returns the absolute level number\n** of the oldest level in the db that contains at least ? segments. Or,\n** if no level in the FTS index contains more than ? segments, the statement\n** returns zero rows.  */\n/* 28 */ \"SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?\"\n         \"  ORDER BY (level %% 1024) ASC LIMIT 1\",\n\n/* Estimate the upper limit on the number of leaf nodes in a new segment\n** created by merging the oldest :2 segments from absolute level :1. See \n** function sqlite3Fts3Incrmerge() for details.  */\n/* 29 */ \"SELECT 2 * total(1 + leaves_end_block - start_block) \"\n         \"  FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?\",\n\n/* SQL_DELETE_SEGDIR_ENTRY\n**   Delete the %_segdir entry on absolute level :1 with index :2.  */\n/* 30 */ \"DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_SHIFT_SEGDIR_ENTRY\n**   Modify the idx value for the segment with idx=:3 on absolute level :2\n**   to :1.  */\n/* 31 */ \"UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?\",\n\n/* SQL_SELECT_SEGDIR\n**   Read a single entry from the %_segdir table. The entry from absolute \n**   level :1 with index value :2.  */\n/* 32 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_CHOMP_SEGDIR\n**   Update the start_block (:1) and root (:2) fields of the %_segdir\n**   entry located on absolute level :3 with index :4.  */\n/* 33 */  \"UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?\"\n            \"WHERE level = ? AND idx = ?\",\n\n/* SQL_SEGMENT_IS_APPENDABLE\n**   Return a single row if the segment with end_block=? is appendable. Or\n**   no rows otherwise.  */\n/* 34 */  \"SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL\",\n\n/* SQL_SELECT_INDEXES\n**   Return the list of valid segment indexes for absolute level ?  */\n/* 35 */  \"SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC\",\n\n/* SQL_SELECT_MXLEVEL\n**   Return the largest relative level in the FTS index or indexes.  */\n/* 36 */  \"SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'\"\n  };\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt;\n\n  assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );\n  assert( eStmt<SizeofArray(azSql) && eStmt>=0 );\n  \n  pStmt = p->aStmt[eStmt];\n  if( !pStmt ){\n    char *zSql;\n    if( eStmt==SQL_CONTENT_INSERT ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);\n    }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);\n    }else{\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);\n    }\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, NULL);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pStmt==0 );\n      p->aStmt[eStmt] = pStmt;\n    }\n  }\n  if( apVal ){\n    int i;\n    int nParam = sqlite3_bind_parameter_count(pStmt);\n    for(i=0; rc==SQLITE_OK && i<nParam; i++){\n      rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);\n    }\n  }\n  *pp = pStmt;\n  return rc;\n}\n\n\nstatic int fts3SelectDocsize(\n  Fts3Table *pTab,                /* FTS3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to bind for SQL_SELECT_DOCSIZE */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;        /* Statement requested from fts3SqlStmt() */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iDocid);\n    rc = sqlite3_step(pStmt);\n    if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n    if( sqlite3_step(pStmt)!=SQLITE_ROW\n     || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB\n    ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to read size data for */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  return fts3SelectDocsize(pTab, iDocid, ppStmt);\n}\n\n/*\n** Similar to fts3SqlStmt(). Except, after binding the parameters in\n** array apVal[] to the SQL statement identified by eStmt, the statement\n** is executed.\n**\n** Returns SQLITE_OK if the statement is successfully executed, or an\n** SQLite error code otherwise.\n*/\nstatic void fts3SqlExec(\n  int *pRC,                /* Result code */\n  Fts3Table *p,            /* The FTS3 table */\n  int eStmt,               /* Index of statement to evaluate */\n  sqlite3_value **apVal    /* Parameters to bind */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, eStmt, &pStmt, apVal); \n  if( rc==SQLITE_OK ){\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  *pRC = rc;\n}\n\n\n/*\n** This function ensures that the caller has obtained a shared-cache\n** table-lock on the %_content table. This is required before reading\n** data from the fts3 table. If this lock is not acquired first, then\n** the caller may end up holding read-locks on the %_segments and %_segdir\n** tables, but no read-lock on the %_content table. If this happens \n** a second connection will be able to write to the fts3 table, but\n** attempting to commit those writes might return SQLITE_LOCKED or\n** SQLITE_LOCKED_SHAREDCACHE (because the commit attempts to obtain \n** write-locks on the %_segments and %_segdir ** tables). \n**\n** We try to avoid this because if FTS3 returns any error when committing\n** a transaction, the whole transaction will be rolled back. And this is\n** not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. It can\n** still happen if the user reads data directly from the %_segments or\n** %_segdir tables instead of going through FTS3 though.\n**\n** This reasoning does not apply to a content=xxx table.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ReadLock(Fts3Table *p){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pStmt;            /* Statement used to obtain lock */\n\n  if( p->zContentTbl==0 ){\n    rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pStmt, 1);\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n    }\n  }else{\n    rc = SQLITE_OK;\n  }\n\n  return rc;\n}\n\n/*\n** FTS maintains a separate indexes for each language-id (a 32-bit integer).\n** Within each language id, a separate index is maintained to store the\n** document terms, and each configured prefix size (configured the FTS \n** \"prefix=\" option). And each index consists of multiple levels (\"relative\n** levels\").\n**\n** All three of these values (the language id, the specific index and the\n** level within the index) are encoded in 64-bit integer values stored\n** in the %_segdir table on disk. This function is used to convert three\n** separate component values into the single 64-bit integer value that\n** can be used to query the %_segdir table.\n**\n** Specifically, each language-id/index combination is allocated 1024 \n** 64-bit integer level values (\"absolute levels\"). The main terms index\n** for language-id 0 is allocate values 0-1023. The first prefix index\n** (if any) for language-id 0 is allocated values 1024-2047. And so on.\n** Language 1 indexes are allocated immediately following language 0.\n**\n** So, for a system with nPrefix prefix indexes configured, the block of\n** absolute levels that corresponds to language-id iLangid and index \n** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).\n*/\nstatic sqlite3_int64 getAbsoluteLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index in p->aIndex[] */\n  int iLevel                      /* Level of segments */\n){\n  sqlite3_int64 iBase;            /* First absolute level for iLangid/iIndex */\n  assert( iLangid>=0 );\n  assert( p->nIndex>0 );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;\n  return iBase + iLevel;\n}\n\n/*\n** Set *ppStmt to a statement handle that may be used to iterate through\n** all rows in the %_segdir table, from oldest to newest. If successful,\n** return SQLITE_OK. If an error occurs while preparing the statement, \n** return an SQLite error code.\n**\n** There is only ever one instance of this SQL statement compiled for\n** each FTS3 table.\n**\n** The statement returns the following columns from the %_segdir table:\n**\n**   0: idx\n**   1: start_block\n**   2: leaves_end_block\n**   3: end_block\n**   4: root\n*/\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(\n  Fts3Table *p,                   /* FTS3 table */\n  int iLangid,                    /* Language being queried */\n  int iIndex,                     /* Index for p->aIndex[] */\n  int iLevel,                     /* Level to select (relative level) */\n  sqlite3_stmt **ppStmt           /* OUT: Compiled statement */\n){\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL || iLevel>=0 );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  if( iLevel<0 ){\n    /* \"SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pStmt, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    /* \"SELECT * FROM %_segdir WHERE level = ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\n\n/*\n** Append a single varint to a PendingList buffer. SQLITE_OK is returned\n** if successful, or an SQLite error code otherwise.\n**\n** This function also serves to allocate the PendingList structure itself.\n** For example, to create a new PendingList structure containing two\n** varints:\n**\n**   PendingList *p = 0;\n**   fts3PendingListAppendVarint(&p, 1);\n**   fts3PendingListAppendVarint(&p, 2);\n*/\nstatic int fts3PendingListAppendVarint(\n  PendingList **pp,               /* IN/OUT: Pointer to PendingList struct */\n  sqlite3_int64 i                 /* Value to append to data */\n){\n  PendingList *p = *pp;\n\n  /* Allocate or grow the PendingList as required. */\n  if( !p ){\n    p = sqlite3_malloc(sizeof(*p) + 100);\n    if( !p ){\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = 100;\n    p->aData = (char *)&p[1];\n    p->nData = 0;\n  }\n  else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){\n    int nNew = p->nSpace * 2;\n    p = sqlite3_realloc(p, sizeof(*p) + nNew);\n    if( !p ){\n      sqlite3_free(*pp);\n      *pp = 0;\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = nNew;\n    p->aData = (char *)&p[1];\n  }\n\n  /* Append the new serialized varint to the end of the list. */\n  p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i);\n  p->aData[p->nData] = '\\0';\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** Add a docid/column/position entry to a PendingList structure. Non-zero\n** is returned if the structure is sqlite3_realloced as part of adding\n** the entry. Otherwise, zero.\n**\n** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.\n** Zero is always returned in this case. Otherwise, if no OOM error occurs,\n** it is set to SQLITE_OK.\n*/\nstatic int fts3PendingListAppend(\n  PendingList **pp,               /* IN/OUT: PendingList structure */\n  sqlite3_int64 iDocid,           /* Docid for entry to add */\n  sqlite3_int64 iCol,             /* Column for entry to add */\n  sqlite3_int64 iPos,             /* Position of term for entry to add */\n  int *pRc                        /* OUT: Return code */\n){\n  PendingList *p = *pp;\n  int rc = SQLITE_OK;\n\n  assert( !p || p->iLastDocid<=iDocid );\n\n  if( !p || p->iLastDocid!=iDocid ){\n    sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);\n    if( p ){\n      assert( p->nData<p->nSpace );\n      assert( p->aData[p->nData]==0 );\n      p->nData++;\n    }\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = -1;\n    p->iLastPos = 0;\n    p->iLastDocid = iDocid;\n  }\n  if( iCol>0 && p->iLastCol!=iCol ){\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))\n     || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))\n    ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = iCol;\n    p->iLastPos = 0;\n  }\n  if( iCol>=0 ){\n    assert( iPos>p->iLastPos || (iPos==0 && p->iLastPos==0) );\n    rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);\n    if( rc==SQLITE_OK ){\n      p->iLastPos = iPos;\n    }\n  }\n\n pendinglistappend_out:\n  *pRc = rc;\n  if( p!=*pp ){\n    *pp = p;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Free a PendingList object allocated by fts3PendingListAppend().\n*/\nstatic void fts3PendingListDelete(PendingList *pList){\n  sqlite3_free(pList);\n}\n\n/*\n** Add an entry to one of the pending-terms hash tables.\n*/\nstatic int fts3PendingTermsAddOne(\n  Fts3Table *p,\n  int iCol,\n  int iPos,\n  Fts3Hash *pHash,                /* Pending terms hash table to add entry to */\n  const char *zToken,\n  int nToken\n){\n  PendingList *pList;\n  int rc = SQLITE_OK;\n\n  pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);\n  if( pList ){\n    p->nPendingData -= (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){\n    if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){\n      /* Malloc failed while inserting the new entry. This can only \n      ** happen if there was no previous entry for this token.\n      */\n      assert( 0==fts3HashFind(pHash, zToken, nToken) );\n      sqlite3_free(pList);\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    p->nPendingData += (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  return rc;\n}\n\n/*\n** Tokenize the nul-terminated string zText and add all tokens to the\n** pending-terms hash-table. The docid used is that currently stored in\n** p->iPrevDocid, and the column is specified by argument iCol.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3PendingTermsAdd(\n  Fts3Table *p,                   /* Table into which text will be inserted */\n  int iLangid,                    /* Language id to use */\n  const char *zText,              /* Text of document to be inserted */\n  int iCol,                       /* Column into which text is being inserted */\n  u32 *pnWord                     /* IN/OUT: Incr. by number tokens inserted */\n){\n  int rc;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int nWord = 0;\n\n  char const *zToken;\n  int nToken = 0;\n\n  sqlite3_tokenizer *pTokenizer = p->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr;\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n      const char**,int*,int*,int*,int*);\n\n  assert( pTokenizer && pModule );\n\n  /* If the user has inserted a NULL value, this function may be called with\n  ** zText==0. In this case, add zero token entries to the hash table and \n  ** return early. */\n  if( zText==0 ){\n    *pnWord = 0;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, iLangid, zText, -1, &pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  xNext = pModule->xNext;\n  while( SQLITE_OK==rc\n      && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))\n  ){\n    int i;\n    if( iPos>=nWord ) nWord = iPos+1;\n\n    /* Positions cannot be negative; we use -1 as a terminator internally.\n    ** Tokens must have a non-zero length.\n    */\n    if( iPos<0 || !zToken || nToken<=0 ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    /* Add the term to the terms index */\n    rc = fts3PendingTermsAddOne(\n        p, iCol, iPos, &p->aIndex[0].hPending, zToken, nToken\n    );\n    \n    /* Add the term to each of the prefix indexes that it is not too \n    ** short for. */\n    for(i=1; rc==SQLITE_OK && i<p->nIndex; i++){\n      struct Fts3Index *pIndex = &p->aIndex[i];\n      if( nToken<pIndex->nPrefix ) continue;\n      rc = fts3PendingTermsAddOne(\n          p, iCol, iPos, &pIndex->hPending, zToken, pIndex->nPrefix\n      );\n    }\n  }\n\n  pModule->xClose(pCsr);\n  *pnWord += nWord;\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/* \n** Calling this function indicates that subsequent calls to \n** fts3PendingTermsAdd() are to add term/position-list pairs for the\n** contents of the document with docid iDocid.\n*/\nstatic int fts3PendingTermsDocid(\n  Fts3Table *p,                   /* Full-text table handle */\n  int iLangid,                    /* Language id of row being written */\n  sqlite_int64 iDocid             /* Docid of row being written */\n){\n  assert( iLangid>=0 );\n\n  /* TODO(shess) Explore whether partially flushing the buffer on\n  ** forced-flush would provide better performance.  I suspect that if\n  ** we ordered the doclists by size and flushed the largest until the\n  ** buffer was half empty, that would let the less frequent terms\n  ** generate longer doclists.\n  */\n  if( iDocid<=p->iPrevDocid \n   || p->iPrevLangid!=iLangid\n   || p->nPendingData>p->nMaxPendingData \n  ){\n    int rc = sqlite3Fts3PendingTermsFlush(p);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  p->iPrevDocid = iDocid;\n  p->iPrevLangid = iLangid;\n  return SQLITE_OK;\n}\n\n/*\n** Discard the contents of the pending-terms hash tables. \n*/\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *p){\n  int i;\n  for(i=0; i<p->nIndex; i++){\n    Fts3HashElem *pElem;\n    Fts3Hash *pHash = &p->aIndex[i].hPending;\n    for(pElem=fts3HashFirst(pHash); pElem; pElem=fts3HashNext(pElem)){\n      PendingList *pList = (PendingList *)fts3HashData(pElem);\n      fts3PendingListDelete(pList);\n    }\n    fts3HashClear(pHash);\n  }\n  p->nPendingData = 0;\n}\n\n/*\n** This function is called by the xUpdate() method as part of an INSERT\n** operation. It adds entries for each term in the new record to the\n** pendingTerms hash table.\n**\n** Argument apVal is the same as the similarly named argument passed to\n** fts3InsertData(). Parameter iDocid is the docid of the new row.\n*/\nstatic int fts3InsertTerms(\n  Fts3Table *p, \n  int iLangid, \n  sqlite3_value **apVal, \n  u32 *aSz\n){\n  int i;                          /* Iterator variable */\n  for(i=2; i<p->nColumn+2; i++){\n    const char *zText = (const char *)sqlite3_value_text(apVal[i]);\n    int rc = fts3PendingTermsAdd(p, iLangid, zText, i-2, &aSz[i-2]);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is called by the xUpdate() method for an INSERT operation.\n** The apVal parameter is passed a copy of the apVal argument passed by\n** SQLite to the xUpdate() method. i.e:\n**\n**   apVal[0]                Not used for INSERT.\n**   apVal[1]                rowid\n**   apVal[2]                Left-most user-defined column\n**   ...\n**   apVal[p->nColumn+1]     Right-most user-defined column\n**   apVal[p->nColumn+2]     Hidden column with same name as table\n**   apVal[p->nColumn+3]     Hidden \"docid\" column (alias for rowid)\n**   apVal[p->nColumn+4]     Hidden languageid column\n*/\nstatic int fts3InsertData(\n  Fts3Table *p,                   /* Full-text table */\n  sqlite3_value **apVal,          /* Array of values to insert */\n  sqlite3_int64 *piDocid          /* OUT: Docid for row just inserted */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pContentInsert;   /* INSERT INTO %_content VALUES(...) */\n\n  if( p->zContentTbl ){\n    sqlite3_value *pRowid = apVal[p->nColumn+3];\n    if( sqlite3_value_type(pRowid)==SQLITE_NULL ){\n      pRowid = apVal[1];\n    }\n    if( sqlite3_value_type(pRowid)!=SQLITE_INTEGER ){\n      return SQLITE_CONSTRAINT;\n    }\n    *piDocid = sqlite3_value_int64(pRowid);\n    return SQLITE_OK;\n  }\n\n  /* Locate the statement handle used to insert data into the %_content\n  ** table. The SQL for this statement is:\n  **\n  **   INSERT INTO %_content VALUES(?, ?, ?, ...)\n  **\n  ** The statement features N '?' variables, where N is the number of user\n  ** defined columns in the FTS3 table, plus one for the docid field.\n  */\n  rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);\n  if( rc==SQLITE_OK && p->zLanguageid ){\n    rc = sqlite3_bind_int(\n        pContentInsert, p->nColumn+2, \n        sqlite3_value_int(apVal[p->nColumn+4])\n    );\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* There is a quirk here. The users INSERT statement may have specified\n  ** a value for the \"rowid\" field, for the \"docid\" field, or for both.\n  ** Which is a problem, since \"rowid\" and \"docid\" are aliases for the\n  ** same value. For example:\n  **\n  **   INSERT INTO fts3tbl(rowid, docid) VALUES(1, 2);\n  **\n  ** In FTS3, this is an error. It is an error to specify non-NULL values\n  ** for both docid and some other rowid alias.\n  */\n  if( SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) ){\n    if( SQLITE_NULL==sqlite3_value_type(apVal[0])\n     && SQLITE_NULL!=sqlite3_value_type(apVal[1])\n    ){\n      /* A rowid/docid conflict. */\n      return SQLITE_ERROR;\n    }\n    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* Execute the statement to insert the record. Set *piDocid to the \n  ** new docid value. \n  */\n  sqlite3_step(pContentInsert);\n  rc = sqlite3_reset(pContentInsert);\n\n  *piDocid = sqlite3_last_insert_rowid(p->db);\n  return rc;\n}\n\n\n\n/*\n** Remove all data from the FTS3 table. Clear the hash table containing\n** pending terms.\n*/\nstatic int fts3DeleteAll(Fts3Table *p, int bContent){\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* Discard the contents of the pending-terms hash table. */\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Delete everything from the shadow tables. Except, leave %_content as\n  ** is if bContent is false.  */\n  assert( p->zContentTbl==0 || bContent==0 );\n  if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0);\n  if( p->bHasDocsize ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_DOCSIZE, 0);\n  }\n  if( p->bHasStat ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_STAT, 0);\n  }\n  return rc;\n}\n\n/*\n**\n*/\nstatic int langidFromSelect(Fts3Table *p, sqlite3_stmt *pSelect){\n  int iLangid = 0;\n  if( p->zLanguageid ) iLangid = sqlite3_column_int(pSelect, p->nColumn+1);\n  return iLangid;\n}\n\n/*\n** The first element in the apVal[] array is assumed to contain the docid\n** (an integer) of a row about to be deleted. Remove all terms from the\n** full-text index.\n*/\nstatic void fts3DeleteTerms( \n  int *pRC,               /* Result code */\n  Fts3Table *p,           /* The FTS table to delete from */\n  sqlite3_value *pRowid,  /* The docid to be deleted */\n  u32 *aSz,               /* Sizes of deleted document written here */\n  int *pbFound            /* OUT: Set to true if row really does exist */\n){\n  int rc;\n  sqlite3_stmt *pSelect;\n\n  assert( *pbFound==0 );\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      int i;\n      int iLangid = langidFromSelect(p, pSelect);\n      rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pSelect, 0));\n      for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){\n        const char *zText = (const char *)sqlite3_column_text(pSelect, i);\n        rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[i-1]);\n        aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_reset(pSelect);\n        *pRC = rc;\n        return;\n      }\n      *pbFound = 1;\n    }\n    rc = sqlite3_reset(pSelect);\n  }else{\n    sqlite3_reset(pSelect);\n  }\n  *pRC = rc;\n}\n\n/*\n** Forward declaration to account for the circular dependency between\n** functions fts3SegmentMerge() and fts3AllocateSegdirIdx().\n*/\nstatic int fts3SegmentMerge(Fts3Table *, int, int, int);\n\n/* \n** This function allocates a new level iLevel index in the segdir table.\n** Usually, indexes are allocated within a level sequentially starting\n** with 0, so the allocated index is one greater than the value returned\n** by:\n**\n**   SELECT max(idx) FROM %_segdir WHERE level = :iLevel\n**\n** However, if there are already FTS3_MERGE_COUNT indexes at the requested\n** level, they are merged into a single level (iLevel+1) segment and the \n** allocated index is 0.\n**\n** If successful, *piIdx is set to the allocated index slot and SQLITE_OK\n** returned. Otherwise, an SQLite error code is returned.\n*/\nstatic int fts3AllocateSegdirIdx(\n  Fts3Table *p, \n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel, \n  int *piIdx\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pNextIdx;         /* Query for next idx at level iLevel */\n  int iNext = 0;                  /* Result of query pNextIdx */\n\n  assert( iLangid>=0 );\n  assert( p->nIndex>=1 );\n\n  /* Set variable iNext to the next available segdir index at level iLevel. */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(\n        pNextIdx, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n    );\n    if( SQLITE_ROW==sqlite3_step(pNextIdx) ){\n      iNext = sqlite3_column_int(pNextIdx, 0);\n    }\n    rc = sqlite3_reset(pNextIdx);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already\n    ** full, merge all segments in level iLevel into a single iLevel+1\n    ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,\n    ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.\n    */\n    if( iNext>=FTS3_MERGE_COUNT ){\n      fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));\n      rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);\n      *piIdx = 0;\n    }else{\n      *piIdx = iNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The %_segments table is declared as follows:\n**\n**   CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)\n**\n** This function reads data from a single row of the %_segments table. The\n** specific row is identified by the iBlockid parameter. If paBlob is not\n** NULL, then a buffer is allocated using sqlite3_malloc() and populated\n** with the contents of the blob stored in the \"block\" column of the \n** identified table row is. Whether or not paBlob is NULL, *pnBlob is set\n** to the size of the blob in bytes before returning.\n**\n** If an error occurs, or the table does not contain the specified row,\n** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If\n** paBlob is non-NULL, then it is the responsibility of the caller to\n** eventually free the returned buffer.\n**\n** This function may leave an open sqlite3_blob* handle in the\n** Fts3Table.pSegments variable. This handle is reused by subsequent calls\n** to this function. The handle may be closed by calling the\n** sqlite3Fts3SegmentsClose() function. Reusing a blob handle is a handy\n** performance improvement, but the blob handle should always be closed\n** before control is returned to the user (to prevent a lock being held\n** on the database file for longer than necessary). Thus, any virtual table\n** method (xFilter etc.) that may directly or indirectly call this function\n** must call sqlite3Fts3SegmentsClose() before returning.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iBlockid,         /* Access the row with blockid=$iBlockid */\n  char **paBlob,                  /* OUT: Blob data in malloc'd buffer */\n  int *pnBlob,                    /* OUT: Size of blob data */\n  int *pnLoad                     /* OUT: Bytes actually loaded */\n){\n  int rc;                         /* Return code */\n\n  /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */\n  assert( pnBlob );\n\n  if( p->pSegments ){\n    rc = sqlite3_blob_reopen(p->pSegments, iBlockid);\n  }else{\n    if( 0==p->zSegmentsTbl ){\n      p->zSegmentsTbl = sqlite3_mprintf(\"%s_segments\", p->zName);\n      if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM;\n    }\n    rc = sqlite3_blob_open(\n       p->db, p->zDb, p->zSegmentsTbl, \"block\", iBlockid, 0, &p->pSegments\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = sqlite3_blob_bytes(p->pSegments);\n    *pnBlob = nByte;\n    if( paBlob ){\n      char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING);\n      if( !aByte ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){\n          nByte = FTS3_NODE_CHUNKSIZE;\n          *pnLoad = nByte;\n        }\n        rc = sqlite3_blob_read(p->pSegments, aByte, nByte, 0);\n        memset(&aByte[nByte], 0, FTS3_NODE_PADDING);\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aByte);\n          aByte = 0;\n        }\n      }\n      *paBlob = aByte;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Close the blob handle at p->pSegments, if it is open. See comments above\n** the sqlite3Fts3ReadBlock() function for details.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *p){\n  sqlite3_blob_close(p->pSegments);\n  p->pSegments = 0;\n}\n    \nstatic int fts3SegReaderIncrRead(Fts3SegReader *pReader){\n  int nRead;                      /* Number of bytes to read */\n  int rc;                         /* Return code */\n\n  nRead = MIN(pReader->nNode - pReader->nPopulate, FTS3_NODE_CHUNKSIZE);\n  rc = sqlite3_blob_read(\n      pReader->pBlob, \n      &pReader->aNode[pReader->nPopulate],\n      nRead,\n      pReader->nPopulate\n  );\n\n  if( rc==SQLITE_OK ){\n    pReader->nPopulate += nRead;\n    memset(&pReader->aNode[pReader->nPopulate], 0, FTS3_NODE_PADDING);\n    if( pReader->nPopulate==pReader->nNode ){\n      sqlite3_blob_close(pReader->pBlob);\n      pReader->pBlob = 0;\n      pReader->nPopulate = 0;\n    }\n  }\n  return rc;\n}\n\nstatic int fts3SegReaderRequire(Fts3SegReader *pReader, char *pFrom, int nByte){\n  int rc = SQLITE_OK;\n  assert( !pReader->pBlob \n       || (pFrom>=pReader->aNode && pFrom<&pReader->aNode[pReader->nNode])\n  );\n  while( pReader->pBlob && rc==SQLITE_OK \n     &&  (pFrom - pReader->aNode + nByte)>pReader->nPopulate\n  ){\n    rc = fts3SegReaderIncrRead(pReader);\n  }\n  return rc;\n}\n\n/*\n** Set an Fts3SegReader cursor to point at EOF.\n*/\nstatic void fts3SegReaderSetEof(Fts3SegReader *pSeg){\n  if( !fts3SegReaderIsRootOnly(pSeg) ){\n    sqlite3_free(pSeg->aNode);\n    sqlite3_blob_close(pSeg->pBlob);\n    pSeg->pBlob = 0;\n  }\n  pSeg->aNode = 0;\n}\n\n/*\n** Move the iterator passed as the first argument to the next term in the\n** segment. If successful, SQLITE_OK is returned. If there is no next term,\n** SQLITE_DONE. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegReaderNext(\n  Fts3Table *p, \n  Fts3SegReader *pReader,\n  int bIncr\n){\n  int rc;                         /* Return code of various sub-routines */\n  char *pNext;                    /* Cursor variable */\n  int nPrefix;                    /* Number of bytes in term prefix */\n  int nSuffix;                    /* Number of bytes in term suffix */\n\n  if( !pReader->aDoclist ){\n    pNext = pReader->aNode;\n  }else{\n    pNext = &pReader->aDoclist[pReader->nDoclist];\n  }\n\n  if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){\n\n    if( fts3SegReaderIsPending(pReader) ){\n      Fts3HashElem *pElem = *(pReader->ppNextElem);\n      if( pElem==0 ){\n        pReader->aNode = 0;\n      }else{\n        PendingList *pList = (PendingList *)fts3HashData(pElem);\n        pReader->zTerm = (char *)fts3HashKey(pElem);\n        pReader->nTerm = fts3HashKeysize(pElem);\n        pReader->nNode = pReader->nDoclist = pList->nData + 1;\n        pReader->aNode = pReader->aDoclist = pList->aData;\n        pReader->ppNextElem++;\n        assert( pReader->aNode );\n      }\n      return SQLITE_OK;\n    }\n\n    fts3SegReaderSetEof(pReader);\n\n    /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf \n    ** blocks have already been traversed.  */\n    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock );\n    if( pReader->iCurrentBlock>=pReader->iLeafEndBlock ){\n      return SQLITE_OK;\n    }\n\n    rc = sqlite3Fts3ReadBlock(\n        p, ++pReader->iCurrentBlock, &pReader->aNode, &pReader->nNode, \n        (bIncr ? &pReader->nPopulate : 0)\n    );\n    if( rc!=SQLITE_OK ) return rc;\n    assert( pReader->pBlob==0 );\n    if( bIncr && pReader->nPopulate<pReader->nNode ){\n      pReader->pBlob = p->pSegments;\n      p->pSegments = 0;\n    }\n    pNext = pReader->aNode;\n  }\n\n  assert( !fts3SegReaderIsPending(pReader) );\n\n  rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);\n  if( rc!=SQLITE_OK ) return rc;\n  \n  /* Because of the FTS3_NODE_PADDING bytes of padding, the following is \n  ** safe (no risk of overread) even if the node data is corrupted. */\n  pNext += sqlite3Fts3GetVarint32(pNext, &nPrefix);\n  pNext += sqlite3Fts3GetVarint32(pNext, &nSuffix);\n  if( nPrefix<0 || nSuffix<=0 \n   || &pNext[nSuffix]>&pReader->aNode[pReader->nNode] \n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n\n  if( nPrefix+nSuffix>pReader->nTermAlloc ){\n    int nNew = (nPrefix+nSuffix)*2;\n    char *zNew = sqlite3_realloc(pReader->zTerm, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pReader->zTerm = zNew;\n    pReader->nTermAlloc = nNew;\n  }\n\n  rc = fts3SegReaderRequire(pReader, pNext, nSuffix+FTS3_VARINT_MAX);\n  if( rc!=SQLITE_OK ) return rc;\n\n  memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);\n  pReader->nTerm = nPrefix+nSuffix;\n  pNext += nSuffix;\n  pNext += sqlite3Fts3GetVarint32(pNext, &pReader->nDoclist);\n  pReader->aDoclist = pNext;\n  pReader->pOffsetList = 0;\n\n  /* Check that the doclist does not appear to extend past the end of the\n  ** b-tree node. And that the final byte of the doclist is 0x00. If either \n  ** of these statements is untrue, then the data structure is corrupt.\n  */\n  if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode] \n   || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])\n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set the SegReader to point to the first docid in the doclist associated\n** with the current term.\n*/\nstatic int fts3SegReaderFirstDocid(Fts3Table *pTab, Fts3SegReader *pReader){\n  int rc = SQLITE_OK;\n  assert( pReader->aDoclist );\n  assert( !pReader->pOffsetList );\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    u8 bEof = 0;\n    pReader->iDocid = 0;\n    pReader->nOffsetList = 0;\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &pReader->pOffsetList, \n        &pReader->iDocid, &pReader->nOffsetList, &bEof\n    );\n  }else{\n    rc = fts3SegReaderRequire(pReader, pReader->aDoclist, FTS3_VARINT_MAX);\n    if( rc==SQLITE_OK ){\n      int n = sqlite3Fts3GetVarint(pReader->aDoclist, &pReader->iDocid);\n      pReader->pOffsetList = &pReader->aDoclist[n];\n    }\n  }\n  return rc;\n}\n\n/*\n** Advance the SegReader to point to the next docid in the doclist\n** associated with the current term.\n** \n** If arguments ppOffsetList and pnOffsetList are not NULL, then \n** *ppOffsetList is set to point to the first column-offset list\n** in the doclist entry (i.e. immediately past the docid varint).\n** *pnOffsetList is set to the length of the set of column-offset\n** lists, not including the nul-terminator byte. For example:\n*/\nstatic int fts3SegReaderNextDocid(\n  Fts3Table *pTab,\n  Fts3SegReader *pReader,         /* Reader to advance to next docid */\n  char **ppOffsetList,            /* OUT: Pointer to current position-list */\n  int *pnOffsetList               /* OUT: Length of *ppOffsetList in bytes */\n){\n  int rc = SQLITE_OK;\n  char *p = pReader->pOffsetList;\n  char c = 0;\n\n  assert( p );\n\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    /* A pending-terms seg-reader for an FTS4 table that uses order=desc.\n    ** Pending-terms doclists are always built up in ascending order, so\n    ** we have to iterate through them backwards here. */\n    u8 bEof = 0;\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = pReader->nOffsetList - 1;\n    }\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &p, &pReader->iDocid,\n        &pReader->nOffsetList, &bEof\n    );\n    if( bEof ){\n      pReader->pOffsetList = 0;\n    }else{\n      pReader->pOffsetList = p;\n    }\n  }else{\n    char *pEnd = &pReader->aDoclist[pReader->nDoclist];\n\n    /* Pointer p currently points at the first byte of an offset list. The\n    ** following block advances it to point one byte past the end of\n    ** the same offset list. */\n    while( 1 ){\n  \n      /* The following line of code (and the \"p++\" below the while() loop) is\n      ** normally all that is required to move pointer p to the desired \n      ** position. The exception is if this node is being loaded from disk\n      ** incrementally and pointer \"p\" now points to the first byte passed\n      ** the populated part of pReader->aNode[].\n      */\n      while( *p | c ) c = *p++ & 0x80;\n      assert( *p==0 );\n  \n      if( pReader->pBlob==0 || p<&pReader->aNode[pReader->nPopulate] ) break;\n      rc = fts3SegReaderIncrRead(pReader);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    p++;\n  \n    /* If required, populate the output variables with a pointer to and the\n    ** size of the previous offset-list.\n    */\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = (int)(p - pReader->pOffsetList - 1);\n    }\n\n    /* List may have been edited in place by fts3EvalNearTrim() */\n    while( p<pEnd && *p==0 ) p++;\n  \n    /* If there are no more entries in the doclist, set pOffsetList to\n    ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and\n    ** Fts3SegReader.pOffsetList to point to the next offset list before\n    ** returning.\n    */\n    if( p>=pEnd ){\n      pReader->pOffsetList = 0;\n    }else{\n      rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);\n      if( rc==SQLITE_OK ){\n        sqlite3_int64 iDelta;\n        pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);\n        if( pTab->bDescIdx ){\n          pReader->iDocid -= iDelta;\n        }else{\n          pReader->iDocid += iDelta;\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(\n  Fts3Cursor *pCsr, \n  Fts3MultiSegReader *pMsr,\n  int *pnOvfl\n){\n  Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n  int nOvfl = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int pgsz = p->nPgsz;\n\n  assert( p->bFts4 );\n  assert( pgsz>0 );\n\n  for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){\n    Fts3SegReader *pReader = pMsr->apSegment[ii];\n    if( !fts3SegReaderIsPending(pReader) \n     && !fts3SegReaderIsRootOnly(pReader) \n    ){\n      sqlite3_int64 jj;\n      for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){\n        int nBlob;\n        rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( (nBlob+35)>pgsz ){\n          nOvfl += (nBlob + 34)/pgsz;\n        }\n      }\n    }\n  }\n  *pnOvfl = nOvfl;\n  return rc;\n}\n\n/*\n** Free all allocations associated with the iterator passed as the \n** second argument.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){\n  if( pReader && !fts3SegReaderIsPending(pReader) ){\n    sqlite3_free(pReader->zTerm);\n    if( !fts3SegReaderIsRootOnly(pReader) ){\n      sqlite3_free(pReader->aNode);\n      sqlite3_blob_close(pReader->pBlob);\n    }\n  }\n  sqlite3_free(pReader);\n}\n\n/*\n** Allocate a new SegReader object.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(\n  int iAge,                       /* Segment \"age\". */\n  int bLookup,                    /* True for a lookup only */\n  sqlite3_int64 iStartLeaf,       /* First leaf to traverse */\n  sqlite3_int64 iEndLeaf,         /* Final leaf to traverse */\n  sqlite3_int64 iEndBlock,        /* Final block of segment */\n  const char *zRoot,              /* Buffer containing root node */\n  int nRoot,                      /* Size of buffer containing root node */\n  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */\n){\n  Fts3SegReader *pReader;         /* Newly allocated SegReader object */\n  int nExtra = 0;                 /* Bytes to allocate segment root node */\n\n  assert( iStartLeaf<=iEndLeaf );\n  if( iStartLeaf==0 ){\n    nExtra = nRoot + FTS3_NODE_PADDING;\n  }\n\n  pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);\n  if( !pReader ){\n    return SQLITE_NOMEM;\n  }\n  memset(pReader, 0, sizeof(Fts3SegReader));\n  pReader->iIdx = iAge;\n  pReader->bLookup = bLookup!=0;\n  pReader->iStartBlock = iStartLeaf;\n  pReader->iLeafEndBlock = iEndLeaf;\n  pReader->iEndBlock = iEndBlock;\n\n  if( nExtra ){\n    /* The entire segment is stored in the root node. */\n    pReader->aNode = (char *)&pReader[1];\n    pReader->rootOnly = 1;\n    pReader->nNode = nRoot;\n    memcpy(pReader->aNode, zRoot, nRoot);\n    memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);\n  }else{\n    pReader->iCurrentBlock = iStartLeaf-1;\n  }\n  *ppReader = pReader;\n  return SQLITE_OK;\n}\n\n/*\n** This is a comparison function used as a qsort() callback when sorting\n** an array of pending terms by term. This occurs as part of flushing\n** the contents of the pending-terms hash table to the database.\n*/\nstatic int fts3CompareElemByTerm(const void *lhs, const void *rhs){\n  char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);\n  char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);\n  int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);\n  int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);\n\n  int n = (n1<n2 ? n1 : n2);\n  int c = memcmp(z1, z2, n);\n  if( c==0 ){\n    c = n1 - n2;\n  }\n  return c;\n}\n\n/*\n** This function is used to allocate an Fts3SegReader that iterates through\n** a subset of the terms stored in the Fts3Table.pendingTerms array.\n**\n** If the isPrefixIter parameter is zero, then the returned SegReader iterates\n** through each term in the pending-terms table. Or, if isPrefixIter is\n** non-zero, it iterates through each term and its prefixes. For example, if\n** the pending terms hash table contains the terms \"sqlite\", \"mysql\" and\n** \"firebird\", then the iterator visits the following 'terms' (in the order\n** shown):\n**\n**   f fi fir fire fireb firebi firebir firebird\n**   m my mys mysq mysql\n**   s sq sql sqli sqlit sqlite\n**\n** Whereas if isPrefixIter is zero, the terms visited are:\n**\n**   firebird mysql sqlite\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iIndex,                     /* Index for p->aIndex */\n  const char *zTerm,              /* Term to search for */\n  int nTerm,                      /* Size of buffer zTerm */\n  int bPrefix,                    /* True for a prefix iterator */\n  Fts3SegReader **ppReader        /* OUT: SegReader for pending-terms */\n){\n  Fts3SegReader *pReader = 0;     /* Fts3SegReader object to return */\n  Fts3HashElem *pE;               /* Iterator variable */\n  Fts3HashElem **aElem = 0;       /* Array of term hash entries to scan */\n  int nElem = 0;                  /* Size of array at aElem */\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Hash *pHash;\n\n  pHash = &p->aIndex[iIndex].hPending;\n  if( bPrefix ){\n    int nAlloc = 0;               /* Size of allocated array at aElem */\n\n    for(pE=fts3HashFirst(pHash); pE; pE=fts3HashNext(pE)){\n      char *zKey = (char *)fts3HashKey(pE);\n      int nKey = fts3HashKeysize(pE);\n      if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){\n        if( nElem==nAlloc ){\n          Fts3HashElem **aElem2;\n          nAlloc += 16;\n          aElem2 = (Fts3HashElem **)sqlite3_realloc(\n              aElem, nAlloc*sizeof(Fts3HashElem *)\n          );\n          if( !aElem2 ){\n            rc = SQLITE_NOMEM;\n            nElem = 0;\n            break;\n          }\n          aElem = aElem2;\n        }\n\n        aElem[nElem++] = pE;\n      }\n    }\n\n    /* If more than one term matches the prefix, sort the Fts3HashElem\n    ** objects in term order using qsort(). This uses the same comparison\n    ** callback as is used when flushing terms to disk.\n    */\n    if( nElem>1 ){\n      qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);\n    }\n\n  }else{\n    /* The query is a simple term lookup that matches at most one term in\n    ** the index. All that is required is a straight hash-lookup. \n    **\n    ** Because the stack address of pE may be accessed via the aElem pointer\n    ** below, the \"Fts3HashElem *pE\" must be declared so that it is valid\n    ** within this entire function, not just this \"else{...}\" block.\n    */\n    pE = fts3HashFindElem(pHash, zTerm, nTerm);\n    if( pE ){\n      aElem = &pE;\n      nElem = 1;\n    }\n  }\n\n  if( nElem>0 ){\n    int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);\n    pReader = (Fts3SegReader *)sqlite3_malloc(nByte);\n    if( !pReader ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pReader, 0, nByte);\n      pReader->iIdx = 0x7FFFFFFF;\n      pReader->ppNextElem = (Fts3HashElem **)&pReader[1];\n      memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));\n    }\n  }\n\n  if( bPrefix ){\n    sqlite3_free(aElem);\n  }\n  *ppReader = pReader;\n  return rc;\n}\n\n/*\n** Compare the entries pointed to by two Fts3SegReader structures. \n** Comparison is as follows:\n**\n**   1) EOF is greater than not EOF.\n**\n**   2) The current terms (if any) are compared using memcmp(). If one\n**      term is a prefix of another, the longer term is considered the\n**      larger.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc;\n  if( pLhs->aNode && pRhs->aNode ){\n    int rc2 = pLhs->nTerm - pRhs->nTerm;\n    if( rc2<0 ){\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);\n    }else{\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);\n    }\n    if( rc==0 ){\n      rc = rc2;\n    }\n  }else{\n    rc = (pLhs->aNode==0) - (pRhs->aNode==0);\n  }\n  if( rc==0 ){\n    rc = pRhs->iIdx - pLhs->iIdx;\n  }\n  assert( rc!=0 );\n  return rc;\n}\n\n/*\n** A different comparison function for SegReader structures. In this\n** version, it is assumed that each SegReader points to an entry in\n** a doclist for identical terms. Comparison is made as follows:\n**\n**   1) EOF (end of doclist in this case) is greater than not EOF.\n**\n**   2) By current docid.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderDoclistCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\nstatic int fts3SegReaderDoclistCmpRev(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid < pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\n\n/*\n** Compare the term that the Fts3SegReader object passed as the first argument\n** points to with the term specified by arguments zTerm and nTerm. \n**\n** If the pSeg iterator is already at EOF, return 0. Otherwise, return\n** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are\n** equal, or +ve if the pSeg term is greater than zTerm/nTerm.\n*/\nstatic int fts3SegReaderTermCmp(\n  Fts3SegReader *pSeg,            /* Segment reader object */\n  const char *zTerm,              /* Term to compare to */\n  int nTerm                       /* Size of term zTerm in bytes */\n){\n  int res = 0;\n  if( pSeg->aNode ){\n    if( pSeg->nTerm>nTerm ){\n      res = memcmp(pSeg->zTerm, zTerm, nTerm);\n    }else{\n      res = memcmp(pSeg->zTerm, zTerm, pSeg->nTerm);\n    }\n    if( res==0 ){\n      res = pSeg->nTerm-nTerm;\n    }\n  }\n  return res;\n}\n\n/*\n** Argument apSegment is an array of nSegment elements. It is known that\n** the final (nSegment-nSuspect) members are already in sorted order\n** (according to the comparison function provided). This function shuffles\n** the array around until all entries are in sorted order.\n*/\nstatic void fts3SegReaderSort(\n  Fts3SegReader **apSegment,                     /* Array to sort entries of */\n  int nSegment,                                  /* Size of apSegment array */\n  int nSuspect,                                  /* Unsorted entry count */\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *)  /* Comparison function */\n){\n  int i;                          /* Iterator variable */\n\n  assert( nSuspect<=nSegment );\n\n  if( nSuspect==nSegment ) nSuspect--;\n  for(i=nSuspect-1; i>=0; i--){\n    int j;\n    for(j=i; j<(nSegment-1); j++){\n      Fts3SegReader *pTmp;\n      if( xCmp(apSegment[j], apSegment[j+1])<0 ) break;\n      pTmp = apSegment[j+1];\n      apSegment[j+1] = apSegment[j];\n      apSegment[j] = pTmp;\n    }\n  }\n\n#ifndef NDEBUG\n  /* Check that the list really is sorted now. */\n  for(i=0; i<(nSuspect-1); i++){\n    assert( xCmp(apSegment[i], apSegment[i+1])<0 );\n  }\n#endif\n}\n\n/* \n** Insert a record into the %_segments table.\n*/\nstatic int fts3WriteSegment(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iBlock,           /* Block id for new block */\n  char *z,                        /* Pointer to buffer containing block data */\n  int n                           /* Size of buffer z in bytes */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iBlock);\n    sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Find the largest relative level number in the table. If successful, set\n** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,\n** set *pnMax to zero and return an SQLite error code.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){\n  int rc;\n  int mxLevel = 0;\n  sqlite3_stmt *pStmt = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      mxLevel = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_reset(pStmt);\n  }\n  *pnMax = mxLevel;\n  return rc;\n}\n\n/* \n** Insert a record into the %_segdir table.\n*/\nstatic int fts3WriteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iLevel,           /* Value for \"level\" field (absolute level) */\n  int iIdx,                       /* Value for \"idx\" field */\n  sqlite3_int64 iStartBlock,      /* Value for \"start_block\" field */\n  sqlite3_int64 iLeafEndBlock,    /* Value for \"leaves_end_block\" field */\n  sqlite3_int64 iEndBlock,        /* Value for \"end_block\" field */\n  char *zRoot,                    /* Blob value for \"root\" field */\n  int nRoot                       /* Number of bytes in buffer zRoot */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iLevel);\n    sqlite3_bind_int(pStmt, 2, iIdx);\n    sqlite3_bind_int64(pStmt, 3, iStartBlock);\n    sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);\n    sqlite3_bind_int64(pStmt, 5, iEndBlock);\n    sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Return the size of the common prefix (if any) shared by zPrev and\n** zNext, in bytes. For example, \n**\n**   fts3PrefixCompress(\"abc\", 3, \"abcdef\", 6)   // returns 3\n**   fts3PrefixCompress(\"abX\", 3, \"abcdef\", 6)   // returns 2\n**   fts3PrefixCompress(\"abX\", 3, \"Xbcdef\", 6)   // returns 0\n*/\nstatic int fts3PrefixCompress(\n  const char *zPrev,              /* Buffer containing previous term */\n  int nPrev,                      /* Size of buffer zPrev in bytes */\n  const char *zNext,              /* Buffer containing next term */\n  int nNext                       /* Size of buffer zNext in bytes */\n){\n  int n;\n  UNUSED_PARAMETER(nNext);\n  for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);\n  return n;\n}\n\n/*\n** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger\n** (according to memcmp) than the previous term.\n*/\nstatic int fts3NodeAddTerm(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode **ppTree,           /* IN/OUT: SegmentNode handle */ \n  int isCopyTerm,                 /* True if zTerm/nTerm is transient */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm                       /* Size of term in bytes */\n){\n  SegmentNode *pTree = *ppTree;\n  int rc;\n  SegmentNode *pNew;\n\n  /* First try to append the term to the current node. Return early if \n  ** this is possible.\n  */\n  if( pTree ){\n    int nData = pTree->nData;     /* Current size of node in bytes */\n    int nReq = nData;             /* Required space after adding zTerm */\n    int nPrefix;                  /* Number of bytes of prefix compression */\n    int nSuffix;                  /* Suffix length */\n\n    nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);\n    nSuffix = nTerm-nPrefix;\n\n    nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;\n    if( nReq<=p->nNodeSize || !pTree->zTerm ){\n\n      if( nReq>p->nNodeSize ){\n        /* An unusual case: this is the first term to be added to the node\n        ** and the static node buffer (p->nNodeSize bytes) is not large\n        ** enough. Use a separately malloced buffer instead This wastes\n        ** p->nNodeSize bytes, but since this scenario only comes about when\n        ** the database contain two terms that share a prefix of almost 2KB, \n        ** this is not expected to be a serious problem. \n        */\n        assert( pTree->aData==(char *)&pTree[1] );\n        pTree->aData = (char *)sqlite3_malloc(nReq);\n        if( !pTree->aData ){\n          return SQLITE_NOMEM;\n        }\n      }\n\n      if( pTree->zTerm ){\n        /* There is no prefix-length field for first term in a node */\n        nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nPrefix);\n      }\n\n      nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nSuffix);\n      memcpy(&pTree->aData[nData], &zTerm[nPrefix], nSuffix);\n      pTree->nData = nData + nSuffix;\n      pTree->nEntry++;\n\n      if( isCopyTerm ){\n        if( pTree->nMalloc<nTerm ){\n          char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2);\n          if( !zNew ){\n            return SQLITE_NOMEM;\n          }\n          pTree->nMalloc = nTerm*2;\n          pTree->zMalloc = zNew;\n        }\n        pTree->zTerm = pTree->zMalloc;\n        memcpy(pTree->zTerm, zTerm, nTerm);\n        pTree->nTerm = nTerm;\n      }else{\n        pTree->zTerm = (char *)zTerm;\n        pTree->nTerm = nTerm;\n      }\n      return SQLITE_OK;\n    }\n  }\n\n  /* If control flows to here, it was not possible to append zTerm to the\n  ** current node. Create a new node (a right-sibling of the current node).\n  ** If this is the first node in the tree, the term is added to it.\n  **\n  ** Otherwise, the term is not added to the new node, it is left empty for\n  ** now. Instead, the term is inserted into the parent of pTree. If pTree \n  ** has no parent, one is created here.\n  */\n  pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize);\n  if( !pNew ){\n    return SQLITE_NOMEM;\n  }\n  memset(pNew, 0, sizeof(SegmentNode));\n  pNew->nData = 1 + FTS3_VARINT_MAX;\n  pNew->aData = (char *)&pNew[1];\n\n  if( pTree ){\n    SegmentNode *pParent = pTree->pParent;\n    rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);\n    if( pTree->pParent==0 ){\n      pTree->pParent = pParent;\n    }\n    pTree->pRight = pNew;\n    pNew->pLeftmost = pTree->pLeftmost;\n    pNew->pParent = pParent;\n    pNew->zMalloc = pTree->zMalloc;\n    pNew->nMalloc = pTree->nMalloc;\n    pTree->zMalloc = 0;\n  }else{\n    pNew->pLeftmost = pNew;\n    rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm); \n  }\n\n  *ppTree = pNew;\n  return rc;\n}\n\n/*\n** Helper function for fts3NodeWrite().\n*/\nstatic int fts3TreeFinishNode(\n  SegmentNode *pTree, \n  int iHeight, \n  sqlite3_int64 iLeftChild\n){\n  int nStart;\n  assert( iHeight>=1 && iHeight<128 );\n  nStart = FTS3_VARINT_MAX - sqlite3Fts3VarintLen(iLeftChild);\n  pTree->aData[nStart] = (char)iHeight;\n  sqlite3Fts3PutVarint(&pTree->aData[nStart+1], iLeftChild);\n  return nStart;\n}\n\n/*\n** Write the buffer for the segment node pTree and all of its peers to the\n** database. Then call this function recursively to write the parent of \n** pTree and its peers to the database. \n**\n** Except, if pTree is a root node, do not write it to the database. Instead,\n** set output variables *paRoot and *pnRoot to contain the root node.\n**\n** If successful, SQLITE_OK is returned and output variable *piLast is\n** set to the largest blockid written to the database (or zero if no\n** blocks were written to the db). Otherwise, an SQLite error code is \n** returned.\n*/\nstatic int fts3NodeWrite(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode *pTree,             /* SegmentNode handle */\n  int iHeight,                    /* Height of this node in tree */\n  sqlite3_int64 iLeaf,            /* Block id of first leaf node */\n  sqlite3_int64 iFree,            /* Block id of next free slot in %_segments */\n  sqlite3_int64 *piLast,          /* OUT: Block id of last entry written */\n  char **paRoot,                  /* OUT: Data for root node */\n  int *pnRoot                     /* OUT: Size of root node in bytes */\n){\n  int rc = SQLITE_OK;\n\n  if( !pTree->pParent ){\n    /* Root node of the tree. */\n    int nStart = fts3TreeFinishNode(pTree, iHeight, iLeaf);\n    *piLast = iFree-1;\n    *pnRoot = pTree->nData - nStart;\n    *paRoot = &pTree->aData[nStart];\n  }else{\n    SegmentNode *pIter;\n    sqlite3_int64 iNextFree = iFree;\n    sqlite3_int64 iNextLeaf = iLeaf;\n    for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){\n      int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);\n      int nWrite = pIter->nData - nStart;\n  \n      rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);\n      iNextFree++;\n      iNextLeaf += (pIter->nEntry+1);\n    }\n    if( rc==SQLITE_OK ){\n      assert( iNextLeaf==iFree );\n      rc = fts3NodeWrite(\n          p, pTree->pParent, iHeight+1, iFree, iNextFree, piLast, paRoot, pnRoot\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free all memory allocations associated with the tree pTree.\n*/\nstatic void fts3NodeFree(SegmentNode *pTree){\n  if( pTree ){\n    SegmentNode *p = pTree->pLeftmost;\n    fts3NodeFree(p->pParent);\n    while( p ){\n      SegmentNode *pRight = p->pRight;\n      if( p->aData!=(char *)&p[1] ){\n        sqlite3_free(p->aData);\n      }\n      assert( pRight==0 || p->zMalloc==0 );\n      sqlite3_free(p->zMalloc);\n      sqlite3_free(p);\n      p = pRight;\n    }\n  }\n}\n\n/*\n** Add a term to the segment being constructed by the SegmentWriter object\n** *ppWriter. When adding the first term to a segment, *ppWriter should\n** be passed NULL. This function will allocate a new SegmentWriter object\n** and return it via the input/output variable *ppWriter in this case.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterAdd(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter **ppWriter,       /* IN/OUT: SegmentWriter handle */ \n  int isCopyTerm,                 /* True if buffer zTerm must be copied */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of term in bytes */\n  const char *aDoclist,           /* Pointer to buffer containing doclist */\n  int nDoclist                    /* Size of doclist in bytes */\n){\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n  int nReq;                       /* Number of bytes required on leaf page */\n  int nData;\n  SegmentWriter *pWriter = *ppWriter;\n\n  if( !pWriter ){\n    int rc;\n    sqlite3_stmt *pStmt;\n\n    /* Allocate the SegmentWriter structure */\n    pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));\n    if( !pWriter ) return SQLITE_NOMEM;\n    memset(pWriter, 0, sizeof(SegmentWriter));\n    *ppWriter = pWriter;\n\n    /* Allocate a buffer in which to accumulate data */\n    pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);\n    if( !pWriter->aData ) return SQLITE_NOMEM;\n    pWriter->nSize = p->nNodeSize;\n\n    /* Find the next free blockid in the %_segments table */\n    rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      pWriter->iFree = sqlite3_column_int64(pStmt, 0);\n      pWriter->iFirst = pWriter->iFree;\n    }\n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nData = pWriter->nData;\n\n  nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);\n  nSuffix = nTerm-nPrefix;\n\n  /* Figure out how many bytes are required by this new entry */\n  nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */\n    sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */\n    nSuffix +                               /* Term suffix */\n    sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */\n    nDoclist;                               /* Doclist data */\n\n  if( nData>0 && nData+nReq>p->nNodeSize ){\n    int rc;\n\n    /* The current leaf node is full. Write it out to the database. */\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);\n    if( rc!=SQLITE_OK ) return rc;\n    p->nLeafAdd++;\n\n    /* Add the current term to the interior node tree. The term added to\n    ** the interior tree must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pWriter->zTerm), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    assert( nPrefix<nTerm );\n    rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);\n    if( rc!=SQLITE_OK ) return rc;\n\n    nData = 0;\n    pWriter->nTerm = 0;\n\n    nPrefix = 0;\n    nSuffix = nTerm;\n    nReq = 1 +                              /* varint containing prefix size */\n      sqlite3Fts3VarintLen(nTerm) +         /* varint containing suffix size */\n      nTerm +                               /* Term suffix */\n      sqlite3Fts3VarintLen(nDoclist) +      /* Size of doclist */\n      nDoclist;                             /* Doclist data */\n  }\n\n  /* If the buffer currently allocated is too small for this entry, realloc\n  ** the buffer to make it large enough.\n  */\n  if( nReq>pWriter->nSize ){\n    char *aNew = sqlite3_realloc(pWriter->aData, nReq);\n    if( !aNew ) return SQLITE_NOMEM;\n    pWriter->aData = aNew;\n    pWriter->nSize = nReq;\n  }\n  assert( nData+nReq<=pWriter->nSize );\n\n  /* Append the prefix-compressed term and doclist to the buffer. */\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);\n  memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);\n  nData += nSuffix;\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);\n  memcpy(&pWriter->aData[nData], aDoclist, nDoclist);\n  pWriter->nData = nData + nDoclist;\n\n  /* Save the current term so that it can be used to prefix-compress the next.\n  ** If the isCopyTerm parameter is true, then the buffer pointed to by\n  ** zTerm is transient, so take a copy of the term data. Otherwise, just\n  ** store a copy of the pointer.\n  */\n  if( isCopyTerm ){\n    if( nTerm>pWriter->nMalloc ){\n      char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pWriter->nMalloc = nTerm*2;\n      pWriter->zMalloc = zNew;\n      pWriter->zTerm = zNew;\n    }\n    assert( pWriter->zTerm==pWriter->zMalloc );\n    memcpy(pWriter->zTerm, zTerm, nTerm);\n  }else{\n    pWriter->zTerm = (char *)zTerm;\n  }\n  pWriter->nTerm = nTerm;\n\n  return SQLITE_OK;\n}\n\n/*\n** Flush all data associated with the SegmentWriter object pWriter to the\n** database. This function must be called after all terms have been added\n** to the segment using fts3SegWriterAdd(). If successful, SQLITE_OK is\n** returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterFlush(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter *pWriter,         /* SegmentWriter to flush to the db */\n  sqlite3_int64 iLevel,           /* Value for 'level' column of %_segdir */\n  int iIdx                        /* Value for 'idx' column of %_segdir */\n){\n  int rc;                         /* Return code */\n  if( pWriter->pTree ){\n    sqlite3_int64 iLast = 0;      /* Largest block id written to database */\n    sqlite3_int64 iLastLeaf;      /* Largest leaf block id written to db */\n    char *zRoot = NULL;           /* Pointer to buffer containing root node */\n    int nRoot = 0;                /* Size of buffer zRoot */\n\n    iLastLeaf = pWriter->iFree;\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);\n    if( rc==SQLITE_OK ){\n      rc = fts3NodeWrite(p, pWriter->pTree, 1,\n          pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegdir(\n          p, iLevel, iIdx, pWriter->iFirst, iLastLeaf, iLast, zRoot, nRoot);\n    }\n  }else{\n    /* The entire tree fits on the root node. Write it to the segdir table. */\n    rc = fts3WriteSegdir(\n        p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);\n  }\n  p->nLeafAdd++;\n  return rc;\n}\n\n/*\n** Release all memory held by the SegmentWriter object passed as the \n** first argument.\n*/\nstatic void fts3SegWriterFree(SegmentWriter *pWriter){\n  if( pWriter ){\n    sqlite3_free(pWriter->aData);\n    sqlite3_free(pWriter->zMalloc);\n    fts3NodeFree(pWriter->pTree);\n    sqlite3_free(pWriter);\n  }\n}\n\n/*\n** The first value in the apVal[] array is assumed to contain an integer.\n** This function tests if there exist any documents with docid values that\n** are different from that integer. i.e. if deleting the document with docid\n** pRowid would mean the FTS3 table were empty.\n**\n** If successful, *pisEmpty is set to true if the table is empty except for\n** document pRowid, or false otherwise, and SQLITE_OK is returned. If an\n** error occurs, an SQLite error code is returned.\n*/\nstatic int fts3IsEmpty(Fts3Table *p, sqlite3_value *pRowid, int *pisEmpty){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( p->zContentTbl ){\n    /* If using the content=xxx option, assume the table is never empty */\n    *pisEmpty = 0;\n    rc = SQLITE_OK;\n  }else{\n    rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *pisEmpty = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Set *pnMax to the largest segment level in the database for the index\n** iIndex.\n**\n** Segment levels are stored in the 'level' column of the %_segdir table.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if not.\n*/\nstatic int fts3SegmentMaxLevel(\n  Fts3Table *p, \n  int iLangid,\n  int iIndex, \n  sqlite3_int64 *pnMax\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n  sqlite3_bind_int64(pStmt, 2, \n      getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n  );\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pnMax = sqlite3_column_int64(pStmt, 0);\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** Delete all entries in the %_segments table associated with the segment\n** opened with seg-reader pSeg. This function does not affect the contents\n** of the %_segdir table.\n*/\nstatic int fts3DeleteSegment(\n  Fts3Table *p,                   /* FTS table handle */\n  Fts3SegReader *pSeg             /* Segment to delete */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pSeg->iStartBlock ){\n    sqlite3_stmt *pDelete;        /* SQL statement to delete rows */\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);\n      sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);\n      sqlite3_step(pDelete);\n      rc = sqlite3_reset(pDelete);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used after merging multiple segments into a single large\n** segment to delete the old, now redundant, segment b-trees. Specifically,\n** it:\n** \n**   1) Deletes all %_segments entries for the segments associated with \n**      each of the SegReader objects in the array passed as the third \n**      argument, and\n**\n**   2) deletes all %_segdir entries with level iLevel, or all %_segdir\n**      entries regardless of level if (iLevel<0).\n**\n** SQLITE_OK is returned if successful, otherwise an SQLite error code.\n*/\nstatic int fts3DeleteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel,                     /* Level of %_segdir entries to delete */\n  Fts3SegReader **apSegment,      /* Array of SegReader objects */\n  int nReader                     /* Size of array apSegment */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pDelete = 0;      /* SQL statement to delete rows */\n\n  for(i=0; rc==SQLITE_OK && i<nReader; i++){\n    rc = fts3DeleteSegment(p, apSegment[i]);\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pDelete, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(\n          pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** When this function is called, buffer *ppList (size *pnList bytes) contains \n** a position list that may (or may not) feature multiple columns. This\n** function adjusts the pointer *ppList and the length *pnList so that they\n** identify the subset of the position list that corresponds to column iCol.\n**\n** If there are no entries in the input position list for column iCol, then\n** *pnList is set to zero before returning.\n**\n** If parameter bZero is non-zero, then any part of the input list following\n** the end of the output list is zeroed before returning.\n*/\nstatic void fts3ColumnFilter(\n  int iCol,                       /* Column to filter on */\n  int bZero,                      /* Zero out anything following *ppList */\n  char **ppList,                  /* IN/OUT: Pointer to position list */\n  int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */\n){\n  char *pList = *ppList;\n  int nList = *pnList;\n  char *pEnd = &pList[nList];\n  int iCurrent = 0;\n  char *p = pList;\n\n  assert( iCol>=0 );\n  while( 1 ){\n    char c = 0;\n    while( p<pEnd && (c | *p)&0xFE ) c = *p++ & 0x80;\n  \n    if( iCol==iCurrent ){\n      nList = (int)(p - pList);\n      break;\n    }\n\n    nList -= (int)(p - pList);\n    pList = p;\n    if( nList==0 ){\n      break;\n    }\n    p = &pList[1];\n    p += sqlite3Fts3GetVarint32(p, &iCurrent);\n  }\n\n  if( bZero && &pList[nList]!=pEnd ){\n    memset(&pList[nList], 0, pEnd - &pList[nList]);\n  }\n  *ppList = pList;\n  *pnList = nList;\n}\n\n/*\n** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any\n** existing data). Grow the buffer if required.\n**\n** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered\n** trying to resize the buffer, return SQLITE_NOMEM.\n*/\nstatic int fts3MsrBufferData(\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  char *pList,\n  int nList\n){\n  if( nList>pMsr->nBuffer ){\n    char *pNew;\n    pMsr->nBuffer = nList*2;\n    pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);\n    if( !pNew ) return SQLITE_NOMEM;\n    pMsr->aBuffer = pNew;\n  }\n\n  memcpy(pMsr->aBuffer, pList, nList);\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  sqlite3_int64 *piDocid,         /* OUT: Docid value */\n  char **paPoslist,               /* OUT: Pointer to position list */\n  int *pnPoslist                  /* OUT: Size of position list in bytes */\n){\n  int nMerge = pMsr->nAdvance;\n  Fts3SegReader **apSegment = pMsr->apSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( nMerge==0 ){\n    *paPoslist = 0;\n    return SQLITE_OK;\n  }\n\n  while( 1 ){\n    Fts3SegReader *pSeg;\n    pSeg = pMsr->apSegment[0];\n\n    if( pSeg->pOffsetList==0 ){\n      *paPoslist = 0;\n      break;\n    }else{\n      int rc;\n      char *pList;\n      int nList;\n      int j;\n      sqlite3_int64 iDocid = apSegment[0]->iDocid;\n\n      rc = fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n      j = 1;\n      while( rc==SQLITE_OK \n        && j<nMerge\n        && apSegment[j]->pOffsetList\n        && apSegment[j]->iDocid==iDocid\n      ){\n        rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n        j++;\n      }\n      if( rc!=SQLITE_OK ) return rc;\n      fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp);\n\n      if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pMsr, pList, nList+1);\n        if( rc!=SQLITE_OK ) return rc;\n        assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );\n        pList = pMsr->aBuffer;\n      }\n\n      if( pMsr->iColFilter>=0 ){\n        fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList);\n      }\n\n      if( nList>0 ){\n        *paPoslist = pList;\n        *piDocid = iDocid;\n        *pnPoslist = nList;\n        break;\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  const char *zTerm,              /* Term searched for (or NULL) */\n  int nTerm                       /* Length of zTerm in bytes */\n){\n  int i;\n  int nSeg = pCsr->nSegment;\n\n  /* If the Fts3SegFilter defines a specific term (or term prefix) to search \n  ** for, then advance each segment iterator until it points to a term of\n  ** equal or greater value than the specified term. This prevents many\n  ** unnecessary merge/sort operations for the case where single segment\n  ** b-tree leaf nodes contain more than one term.\n  */\n  for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){\n    int res = 0;\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    do {\n      int rc = fts3SegReaderNext(p, pSeg, 0);\n      if( rc!=SQLITE_OK ) return rc;\n    }while( zTerm && (res = fts3SegReaderTermCmp(pSeg, zTerm, nTerm))<0 );\n\n    if( pSeg->bLookup && res!=0 ){\n      fts3SegReaderSetEof(pSeg);\n    }\n  }\n  fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);\n\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  Fts3SegFilter *pFilter          /* Restrictions on range of iteration */\n){\n  pCsr->pFilter = pFilter;\n  return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  int iCol,                       /* Column to match on. */\n  const char *zTerm,              /* Term to iterate through a doclist for */\n  int nTerm                       /* Number of bytes in zTerm */\n){\n  int i;\n  int rc;\n  int nSegment = pCsr->nSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  assert( pCsr->pFilter==0 );\n  assert( zTerm && nTerm>0 );\n\n  /* Advance each segment iterator until it points to the term zTerm/nTerm. */\n  rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Determine how many of the segments actually point to zTerm/nTerm. */\n  for(i=0; i<nSegment; i++){\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){\n      break;\n    }\n  }\n  pCsr->nAdvance = i;\n\n  /* Advance each of the segments to point to the first docid. */\n  for(i=0; i<pCsr->nAdvance; i++){\n    rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);\n\n  assert( iCol<0 || iCol<p->nColumn );\n  pCsr->iColFilter = iCol;\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called on a MultiSegReader that has been started using\n** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also\n** have been made. Calling this function puts the MultiSegReader in such\n** a state that if the next two calls are:\n**\n**   sqlite3Fts3SegReaderStart()\n**   sqlite3Fts3SegReaderStep()\n**\n** then the entire doclist for the term is available in \n** MultiSegReader.aDoclist/nDoclist.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){\n  int i;                          /* Used to iterate through segment-readers */\n\n  assert( pCsr->zTerm==0 );\n  assert( pCsr->nTerm==0 );\n  assert( pCsr->aDoclist==0 );\n  assert( pCsr->nDoclist==0 );\n\n  pCsr->nAdvance = 0;\n  pCsr->bRestart = 1;\n  for(i=0; i<pCsr->nSegment; i++){\n    pCsr->apSegment[i]->pOffsetList = 0;\n    pCsr->apSegment[i]->nOffsetList = 0;\n    pCsr->apSegment[i]->iDocid = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr        /* Cursor object */\n){\n  int rc = SQLITE_OK;\n\n  int isIgnoreEmpty =  (pCsr->pFilter->flags & FTS3_SEGMENT_IGNORE_EMPTY);\n  int isRequirePos =   (pCsr->pFilter->flags & FTS3_SEGMENT_REQUIRE_POS);\n  int isColFilter =    (pCsr->pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER);\n  int isPrefix =       (pCsr->pFilter->flags & FTS3_SEGMENT_PREFIX);\n  int isScan =         (pCsr->pFilter->flags & FTS3_SEGMENT_SCAN);\n  int isFirst =        (pCsr->pFilter->flags & FTS3_SEGMENT_FIRST);\n\n  Fts3SegReader **apSegment = pCsr->apSegment;\n  int nSegment = pCsr->nSegment;\n  Fts3SegFilter *pFilter = pCsr->pFilter;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( pCsr->nSegment==0 ) return SQLITE_OK;\n\n  do {\n    int nMerge;\n    int i;\n  \n    /* Advance the first pCsr->nAdvance entries in the apSegment[] array\n    ** forward. Then sort the list in order of current term again.  \n    */\n    for(i=0; i<pCsr->nAdvance; i++){\n      Fts3SegReader *pSeg = apSegment[i];\n      if( pSeg->bLookup ){\n        fts3SegReaderSetEof(pSeg);\n      }else{\n        rc = fts3SegReaderNext(p, pSeg, 0);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    fts3SegReaderSort(apSegment, nSegment, pCsr->nAdvance, fts3SegReaderCmp);\n    pCsr->nAdvance = 0;\n\n    /* If all the seg-readers are at EOF, we're finished. return SQLITE_OK. */\n    assert( rc==SQLITE_OK );\n    if( apSegment[0]->aNode==0 ) break;\n\n    pCsr->nTerm = apSegment[0]->nTerm;\n    pCsr->zTerm = apSegment[0]->zTerm;\n\n    /* If this is a prefix-search, and if the term that apSegment[0] points\n    ** to does not share a suffix with pFilter->zTerm/nTerm, then all \n    ** required callbacks have been made. In this case exit early.\n    **\n    ** Similarly, if this is a search for an exact match, and the first term\n    ** of segment apSegment[0] is not a match, exit early.\n    */\n    if( pFilter->zTerm && !isScan ){\n      if( pCsr->nTerm<pFilter->nTerm \n       || (!isPrefix && pCsr->nTerm>pFilter->nTerm)\n       || memcmp(pCsr->zTerm, pFilter->zTerm, pFilter->nTerm) \n      ){\n        break;\n      }\n    }\n\n    nMerge = 1;\n    while( nMerge<nSegment \n        && apSegment[nMerge]->aNode\n        && apSegment[nMerge]->nTerm==pCsr->nTerm \n        && 0==memcmp(pCsr->zTerm, apSegment[nMerge]->zTerm, pCsr->nTerm)\n    ){\n      nMerge++;\n    }\n\n    assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );\n    if( nMerge==1 \n     && !isIgnoreEmpty \n     && !isFirst \n     && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)\n    ){\n      pCsr->nDoclist = apSegment[0]->nDoclist;\n      if( fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);\n        pCsr->aDoclist = pCsr->aBuffer;\n      }else{\n        pCsr->aDoclist = apSegment[0]->aDoclist;\n      }\n      if( rc==SQLITE_OK ) rc = SQLITE_ROW;\n    }else{\n      int nDoclist = 0;           /* Size of doclist */\n      sqlite3_int64 iPrev = 0;    /* Previous docid stored in doclist */\n\n      /* The current term of the first nMerge entries in the array\n      ** of Fts3SegReader objects is the same. The doclists must be merged\n      ** and a single term returned with the merged doclist.\n      */\n      for(i=0; i<nMerge; i++){\n        fts3SegReaderFirstDocid(p, apSegment[i]);\n      }\n      fts3SegReaderSort(apSegment, nMerge, nMerge, xCmp);\n      while( apSegment[0]->pOffsetList ){\n        int j;                    /* Number of segments that share a docid */\n        char *pList;\n        int nList;\n        int nByte;\n        sqlite3_int64 iDocid = apSegment[0]->iDocid;\n        fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n        j = 1;\n        while( j<nMerge\n            && apSegment[j]->pOffsetList\n            && apSegment[j]->iDocid==iDocid\n        ){\n          fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n          j++;\n        }\n\n        if( isColFilter ){\n          fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList);\n        }\n\n        if( !isIgnoreEmpty || nList>0 ){\n\n          /* Calculate the 'docid' delta value to write into the merged \n          ** doclist. */\n          sqlite3_int64 iDelta;\n          if( p->bDescIdx && nDoclist>0 ){\n            iDelta = iPrev - iDocid;\n          }else{\n            iDelta = iDocid - iPrev;\n          }\n          assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );\n          assert( nDoclist>0 || iDelta==iDocid );\n\n          nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);\n          if( nDoclist+nByte>pCsr->nBuffer ){\n            char *aNew;\n            pCsr->nBuffer = (nDoclist+nByte)*2;\n            aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);\n            if( !aNew ){\n              return SQLITE_NOMEM;\n            }\n            pCsr->aBuffer = aNew;\n          }\n\n          if( isFirst ){\n            char *a = &pCsr->aBuffer[nDoclist];\n            int nWrite;\n           \n            nWrite = sqlite3Fts3FirstFilter(iDelta, pList, nList, a);\n            if( nWrite ){\n              iPrev = iDocid;\n              nDoclist += nWrite;\n            }\n          }else{\n            nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta);\n            iPrev = iDocid;\n            if( isRequirePos ){\n              memcpy(&pCsr->aBuffer[nDoclist], pList, nList);\n              nDoclist += nList;\n              pCsr->aBuffer[nDoclist++] = '\\0';\n            }\n          }\n        }\n\n        fts3SegReaderSort(apSegment, nMerge, j, xCmp);\n      }\n      if( nDoclist>0 ){\n        pCsr->aDoclist = pCsr->aBuffer;\n        pCsr->nDoclist = nDoclist;\n        rc = SQLITE_ROW;\n      }\n    }\n    pCsr->nAdvance = nMerge;\n  }while( rc==SQLITE_OK );\n\n  return rc;\n}\n\n\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(\n  Fts3MultiSegReader *pCsr       /* Cursor object */\n){\n  if( pCsr ){\n    int i;\n    for(i=0; i<pCsr->nSegment; i++){\n      sqlite3Fts3SegReaderFree(pCsr->apSegment[i]);\n    }\n    sqlite3_free(pCsr->apSegment);\n    sqlite3_free(pCsr->aBuffer);\n\n    pCsr->nSegment = 0;\n    pCsr->apSegment = 0;\n    pCsr->aBuffer = 0;\n  }\n}\n\n/*\n** Merge all level iLevel segments in the database into a single \n** iLevel+1 segment. Or, if iLevel<0, merge all segments into a\n** single segment with a level equal to the numerically largest level \n** currently present in the database.\n**\n** If this function is called with iLevel<0, but there is only one\n** segment in the database, SQLITE_DONE is returned immediately. \n** Otherwise, if successful, SQLITE_OK is returned. If an error occurs, \n** an SQLite error code is returned.\n*/\nstatic int fts3SegmentMerge(\n  Fts3Table *p, \n  int iLangid,                    /* Language id to merge */\n  int iIndex,                     /* Index in p->aIndex[] to merge */\n  int iLevel                      /* Level to merge */\n){\n  int rc;                         /* Return code */\n  int iIdx = 0;                   /* Index of new segment */\n  sqlite3_int64 iNewLevel = 0;    /* Level/index to create new segment at */\n  SegmentWriter *pWriter = 0;     /* Used to write the new, merged, segment */\n  Fts3SegFilter filter;           /* Segment term filter condition */\n  Fts3MultiSegReader csr;         /* Cursor to iterate through level(s) */\n  int bIgnoreEmpty = 0;           /* True to ignore empty segments */\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n       || iLevel==FTS3_SEGCURSOR_PENDING\n       || iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);\n  if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;\n\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    /* This call is to merge all segments in the database to a single\n    ** segment. The level of the new segment is equal to the numerically\n    ** greatest segment level currently present in the database for this\n    ** index. The idx of the new segment is always 0.  */\n    if( csr.nSegment==1 ){\n      rc = SQLITE_DONE;\n      goto finished;\n    }\n    rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iNewLevel);\n    bIgnoreEmpty = 1;\n\n  }else if( iLevel==FTS3_SEGCURSOR_PENDING ){\n    iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, 0);\n    rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, 0, &iIdx);\n  }else{\n    /* This call is to merge all segments at level iLevel. find the next\n    ** available segment index at level iLevel+1. The call to\n    ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to \n    ** a single iLevel+2 segment if necessary.  */\n    rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);\n    iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, iLevel+1);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n  assert( csr.nSegment>0 );\n  assert( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );\n  assert( iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) );\n\n  memset(&filter, 0, sizeof(Fts3SegFilter));\n  filter.flags = FTS3_SEGMENT_REQUIRE_POS;\n  filter.flags |= (bIgnoreEmpty ? FTS3_SEGMENT_IGNORE_EMPTY : 0);\n\n  rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  while( SQLITE_OK==rc ){\n    rc = sqlite3Fts3SegReaderStep(p, &csr);\n    if( rc!=SQLITE_ROW ) break;\n    rc = fts3SegWriterAdd(p, &pWriter, 1, \n        csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n  assert( pWriter );\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3DeleteSegdir(\n        p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment\n    );\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n  rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);\n\n finished:\n  fts3SegWriterFree(pWriter);\n  sqlite3Fts3SegReaderFinish(&csr);\n  return rc;\n}\n\n\n/* \n** Flush the contents of pendingTerms to level 0 segments.\n*/\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){\n  int rc = SQLITE_OK;\n  int i;\n        \n  for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n    rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Determine the auto-incr-merge setting if unknown.  If enabled,\n  ** estimate the number of leaf blocks of content to be written\n  */\n  if( rc==SQLITE_OK && p->bHasStat\n   && p->bAutoincrmerge==0xff && p->nLeafAdd>0\n  ){\n    sqlite3_stmt *pStmt = 0;\n    rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n      rc = sqlite3_step(pStmt);\n      p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Encode N integers as varints into a blob.\n*/\nstatic void fts3EncodeIntArray(\n  int N,             /* The number of integers to encode */\n  u32 *a,            /* The integer values */\n  char *zBuf,        /* Write the BLOB here */\n  int *pNBuf         /* Write number of bytes if zBuf[] used here */\n){\n  int i, j;\n  for(i=j=0; i<N; i++){\n    j += sqlite3Fts3PutVarint(&zBuf[j], (sqlite3_int64)a[i]);\n  }\n  *pNBuf = j;\n}\n\n/*\n** Decode a blob of varints into N integers\n*/\nstatic void fts3DecodeIntArray(\n  int N,             /* The number of integers to decode */\n  u32 *a,            /* Write the integer values */\n  const char *zBuf,  /* The BLOB containing the varints */\n  int nBuf           /* size of the BLOB */\n){\n  int i, j;\n  UNUSED_PARAMETER(nBuf);\n  for(i=j=0; i<N; i++){\n    sqlite3_int64 x;\n    j += sqlite3Fts3GetVarint(&zBuf[j], &x);\n    assert(j<=nBuf);\n    a[i] = (u32)(x & 0xffffffff);\n  }\n}\n\n/*\n** Insert the sizes (in tokens) for each column of the document\n** with docid equal to p->iPrevDocid.  The sizes are encoded as\n** a blob of varints.\n*/\nstatic void fts3InsertDocsize(\n  int *pRC,                       /* Result code */\n  Fts3Table *p,                   /* Table into which to insert */\n  u32 *aSz                        /* Sizes of each column, in tokens */\n){\n  char *pBlob;             /* The BLOB encoding of the document size */\n  int nBlob;               /* Number of bytes in the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement used to insert the encoding */\n  int rc;                  /* Result code from subfunctions */\n\n  if( *pRC ) return;\n  pBlob = sqlite3_malloc( 10*p->nColumn );\n  if( pBlob==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  fts3EncodeIntArray(p->nColumn, aSz, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_DOCSIZE, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(pBlob);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int64(pStmt, 1, p->iPrevDocid);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, sqlite3_free);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n}\n\n/*\n** Record 0 of the %_stat table contains a blob consisting of N varints,\n** where N is the number of user defined columns in the fts3 table plus\n** two. If nCol is the number of user defined columns, then values of the \n** varints are set as follows:\n**\n**   Varint 0:       Total number of rows in the table.\n**\n**   Varint 1..nCol: For each column, the total number of tokens stored in\n**                   the column for all rows of the table.\n**\n**   Varint 1+nCol:  The total size, in bytes, of all text values in all\n**                   columns of all rows of the table.\n**\n*/\nstatic void fts3UpdateDocTotals(\n  int *pRC,                       /* The result code */\n  Fts3Table *p,                   /* Table being updated */\n  u32 *aSzIns,                    /* Size increases */\n  u32 *aSzDel,                    /* Size decreases */\n  int nChng                       /* Change in the number of documents */\n){\n  char *pBlob;             /* Storage for BLOB written into %_stat */\n  int nBlob;               /* Size of BLOB written into %_stat */\n  u32 *a;                  /* Array of integers that becomes the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement for reading and writing */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subfunctions */\n\n  const int nStat = p->nColumn+2;\n\n  if( *pRC ) return;\n  a = sqlite3_malloc( (sizeof(u32)+10)*nStat );\n  if( a==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  pBlob = (char*)&a[nStat];\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    fts3DecodeIntArray(nStat, a,\n         sqlite3_column_blob(pStmt, 0),\n         sqlite3_column_bytes(pStmt, 0));\n  }else{\n    memset(a, 0, sizeof(u32)*(nStat) );\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  if( nChng<0 && a[0]<(u32)(-nChng) ){\n    a[0] = 0;\n  }else{\n    a[0] += nChng;\n  }\n  for(i=0; i<p->nColumn+1; i++){\n    u32 x = a[i+1];\n    if( x+aSzIns[i] < aSzDel[i] ){\n      x = 0;\n    }else{\n      x = x + aSzIns[i] - aSzDel[i];\n    }\n    a[i+1] = x;\n  }\n  fts3EncodeIntArray(nStat, a, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n  sqlite3_free(a);\n}\n\n/*\n** Merge the entire database so that there is one segment for each \n** iIndex/iLangid combination.\n*/\nstatic int fts3DoOptimize(Fts3Table *p, int bReturnDone){\n  int bSeenDone = 0;\n  int rc;\n  sqlite3_stmt *pAllLangid = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->nIndex);\n    while( sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int i;\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n        rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);\n        if( rc==SQLITE_DONE ){\n          bSeenDone = 1;\n          rc = SQLITE_OK;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3Fts3PendingTermsClear(p);\n\n  return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;\n}\n\n/*\n** This function is called when the user executes the following statement:\n**\n**     INSERT INTO <tbl>(<tbl>) VALUES('rebuild');\n**\n** The entire FTS index is discarded and rebuilt. If the table is one \n** created using the content=xxx option, then the new index is based on\n** the current contents of the xxx table. Otherwise, it is rebuilt based\n** on the contents of the %_content table.\n*/\nstatic int fts3DoRebuild(Fts3Table *p){\n  int rc;                         /* Return Code */\n\n  rc = fts3DeleteAll(p, 0);\n  if( rc==SQLITE_OK ){\n    u32 *aSz = 0;\n    u32 *aSzIns = 0;\n    u32 *aSzDel = 0;\n    sqlite3_stmt *pStmt = 0;\n    int nEntry = 0;\n\n    /* Compose and prepare an SQL statement to loop through the content table */\n    char *zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    if( rc==SQLITE_OK ){\n      int nByte = sizeof(u32) * (p->nColumn+1)*3;\n      aSz = (u32 *)sqlite3_malloc(nByte);\n      if( aSz==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(aSz, 0, nByte);\n        aSzIns = &aSz[p->nColumn+1];\n        aSzDel = &aSzIns[p->nColumn+1];\n      }\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      int iCol;\n      int iLangid = langidFromSelect(p, pStmt);\n      rc = fts3PendingTermsDocid(p, iLangid, sqlite3_column_int64(pStmt, 0));\n      memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);\n        rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);\n        aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);\n      }\n      if( p->bHasDocsize ){\n        fts3InsertDocsize(&rc, p, aSz);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_finalize(pStmt);\n        pStmt = 0;\n      }else{\n        nEntry++;\n        for(iCol=0; iCol<=p->nColumn; iCol++){\n          aSzIns[iCol] += aSz[iCol];\n        }\n      }\n    }\n    if( p->bFts4 ){\n      fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);\n    }\n    sqlite3_free(aSz);\n\n    if( pStmt ){\n      int rc2 = sqlite3_finalize(pStmt);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** This function opens a cursor used to read the input data for an \n** incremental merge operation. Specifically, it opens a cursor to scan\n** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute \n** level iAbsLevel.\n*/\nstatic int fts3IncrmergeCsr(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to open */\n  int nSeg,                       /* Number of segments to merge */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  \n  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */\n\n  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */\n  memset(pCsr, 0, sizeof(*pCsr));\n  nByte = sizeof(Fts3SegReader *) * nSeg;\n  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);\n\n  if( pCsr->apSegment==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pCsr->apSegment, 0, nByte);\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n  }\n  if( rc==SQLITE_OK ){\n    int i;\n    int rc2;\n    sqlite3_bind_int64(pStmt, 1, iAbsLevel);\n    assert( pCsr->nSegment==0 );\n    for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){\n      rc = sqlite3Fts3SegReaderNew(i, 0,\n          sqlite3_column_int64(pStmt, 1),        /* segdir.start_block */\n          sqlite3_column_int64(pStmt, 2),        /* segdir.leaves_end_block */\n          sqlite3_column_int64(pStmt, 3),        /* segdir.end_block */\n          sqlite3_column_blob(pStmt, 4),         /* segdir.root */\n          sqlite3_column_bytes(pStmt, 4),        /* segdir.root */\n          &pCsr->apSegment[i]\n      );\n      pCsr->nSegment++;\n    }\n    rc2 = sqlite3_reset(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\ntypedef struct IncrmergeWriter IncrmergeWriter;\ntypedef struct NodeWriter NodeWriter;\ntypedef struct Blob Blob;\ntypedef struct NodeReader NodeReader;\n\n/*\n** An instance of the following structure is used as a dynamic buffer\n** to build up nodes or other blobs of data in.\n**\n** The function blobGrowBuffer() is used to extend the allocation.\n*/\nstruct Blob {\n  char *a;                        /* Pointer to allocation */\n  int n;                          /* Number of valid bytes of data in a[] */\n  int nAlloc;                     /* Allocated size of a[] (nAlloc>=n) */\n};\n\n/*\n** This structure is used to build up buffers containing segment b-tree \n** nodes (blocks).\n*/\nstruct NodeWriter {\n  sqlite3_int64 iBlock;           /* Current block id */\n  Blob key;                       /* Last key written to the current block */\n  Blob block;                     /* Current block image */\n};\n\n/*\n** An object of this type contains the state required to create or append\n** to an appendable b-tree segment.\n*/\nstruct IncrmergeWriter {\n  int nLeafEst;                   /* Space allocated for leaf blocks */\n  int nWork;                      /* Number of leaf pages flushed */\n  sqlite3_int64 iAbsLevel;        /* Absolute level of input segments */\n  int iIdx;                       /* Index of *output* segment in iAbsLevel+1 */\n  sqlite3_int64 iStart;           /* Block number of first allocated block */\n  sqlite3_int64 iEnd;             /* Block number of last allocated block */\n  NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];\n};\n\n/*\n** An object of the following type is used to read data from a single\n** FTS segment node. See the following functions:\n**\n**     nodeReaderInit()\n**     nodeReaderNext()\n**     nodeReaderRelease()\n*/\nstruct NodeReader {\n  const char *aNode;\n  int nNode;\n  int iOff;                       /* Current offset within aNode[] */\n\n  /* Output variables. Containing the current node entry. */\n  sqlite3_int64 iChild;           /* Pointer to child node */\n  Blob term;                      /* Current term */\n  const char *aDoclist;           /* Pointer to doclist */\n  int nDoclist;                   /* Size of doclist in bytes */\n};\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if the allocation at pBlob->a is not already at least nMin\n** bytes in size, extend (realloc) it to be so.\n**\n** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a\n** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc\n** to reflect the new size of the pBlob->a[] buffer.\n*/\nstatic void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){\n  if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){\n    int nAlloc = nMin;\n    char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);\n    if( a ){\n      pBlob->nAlloc = nAlloc;\n      pBlob->a = a;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Attempt to advance the node-reader object passed as the first argument to\n** the next entry on the node. \n**\n** Return an error code if an error occurs (SQLITE_NOMEM is possible). \n** Otherwise return SQLITE_OK. If there is no next entry on the node\n** (e.g. because the current entry is the last) set NodeReader->aNode to\n** NULL to indicate EOF. Otherwise, populate the NodeReader structure output \n** variables for the new entry.\n*/\nstatic int nodeReaderNext(NodeReader *p){\n  int bFirst = (p->term.n==0);    /* True for first term on the node */\n  int nPrefix = 0;                /* Bytes to copy from previous term */\n  int nSuffix = 0;                /* Bytes to append to the prefix */\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( p->aNode );\n  if( p->iChild && bFirst==0 ) p->iChild++;\n  if( p->iOff>=p->nNode ){\n    /* EOF */\n    p->aNode = 0;\n  }else{\n    if( bFirst==0 ){\n      p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);\n    }\n    p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);\n\n    blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);\n    if( rc==SQLITE_OK ){\n      memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);\n      p->term.n = nPrefix+nSuffix;\n      p->iOff += nSuffix;\n      if( p->iChild==0 ){\n        p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);\n        p->aDoclist = &p->aNode[p->iOff];\n        p->iOff += p->nDoclist;\n      }\n    }\n  }\n\n  assert( p->iOff<=p->nNode );\n\n  return rc;\n}\n\n/*\n** Release all dynamic resources held by node-reader object *p.\n*/\nstatic void nodeReaderRelease(NodeReader *p){\n  sqlite3_free(p->term.a);\n}\n\n/*\n** Initialize a node-reader object to read the node in buffer aNode/nNode.\n**\n** If successful, SQLITE_OK is returned and the NodeReader object set to \n** point to the first entry on the node (if any). Otherwise, an SQLite\n** error code is returned.\n*/\nstatic int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){\n  memset(p, 0, sizeof(NodeReader));\n  p->aNode = aNode;\n  p->nNode = nNode;\n\n  /* Figure out if this is a leaf or an internal node. */\n  if( p->aNode[0] ){\n    /* An internal node. */\n    p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);\n  }else{\n    p->iOff = 1;\n  }\n\n  return nodeReaderNext(p);\n}\n\n/*\n** This function is called while writing an FTS segment each time a leaf o\n** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed\n** to be greater than the largest key on the node just written, but smaller\n** than or equal to the first key that will be written to the next leaf\n** node.\n**\n** The block id of the leaf node just written to disk may be found in\n** (pWriter->aNodeWriter[0].iBlock) when this function is called.\n*/\nstatic int fts3IncrmergePush(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  const char *zTerm,              /* Term to write to internal node */\n  int nTerm                       /* Bytes at zTerm */\n){\n  sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;\n  int iLayer;\n\n  assert( nTerm>0 );\n  for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){\n    sqlite3_int64 iNextPtr = 0;\n    NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];\n    int rc = SQLITE_OK;\n    int nPrefix;\n    int nSuffix;\n    int nSpace;\n\n    /* Figure out how much space the key will consume if it is written to\n    ** the current node of layer iLayer. Due to the prefix compression, \n    ** the space required changes depending on which node the key is to\n    ** be added to.  */\n    nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);\n    nSuffix = nTerm - nPrefix;\n    nSpace  = sqlite3Fts3VarintLen(nPrefix);\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n\n    if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){ \n      /* If the current node of layer iLayer contains zero keys, or if adding\n      ** the key to it will not cause it to grow to larger than nNodeSize \n      ** bytes in size, write the key here.  */\n\n      Blob *pBlk = &pNode->block;\n      if( pBlk->n==0 ){\n        blobGrowBuffer(pBlk, p->nNodeSize, &rc);\n        if( rc==SQLITE_OK ){\n          pBlk->a[0] = (char)iLayer;\n          pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);\n        }\n      }\n      blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);\n      blobGrowBuffer(&pNode->key, nTerm, &rc);\n\n      if( rc==SQLITE_OK ){\n        if( pNode->key.n ){\n          pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);\n        }\n        pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);\n        memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);\n        pBlk->n += nSuffix;\n\n        memcpy(pNode->key.a, zTerm, nTerm);\n        pNode->key.n = nTerm;\n      }\n    }else{\n      /* Otherwise, flush the current node of layer iLayer to disk.\n      ** Then allocate a new, empty sibling node. The key will be written\n      ** into the parent of this node. */\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n\n      assert( pNode->block.nAlloc>=p->nNodeSize );\n      pNode->block.a[0] = (char)iLayer;\n      pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);\n\n      iNextPtr = pNode->iBlock;\n      pNode->iBlock++;\n      pNode->key.n = 0;\n    }\n\n    if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;\n    iPtr = iNextPtr;\n  }\n\n  assert( 0 );\n  return 0;\n}\n\n/*\n** Append a term and (optionally) doclist to the FTS segment node currently\n** stored in blob *pNode. The node need not contain any terms, but the\n** header must be written before this function is called.\n**\n** A node header is a single 0x00 byte for a leaf node, or a height varint\n** followed by the left-hand-child varint for an internal node.\n**\n** The term to be appended is passed via arguments zTerm/nTerm. For a \n** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal\n** node, both aDoclist and nDoclist must be passed 0.\n**\n** If the size of the value in blob pPrev is zero, then this is the first\n** term written to the node. Otherwise, pPrev contains a copy of the \n** previous term. Before this function returns, it is updated to contain a\n** copy of zTerm/nTerm.\n**\n** It is assumed that the buffer associated with pNode is already large\n** enough to accommodate the new entry. The buffer associated with pPrev\n** is extended by this function if requrired.\n**\n** If an error (i.e. OOM condition) occurs, an SQLite error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3AppendToNode(\n  Blob *pNode,                    /* Current node image to append to */\n  Blob *pPrev,                    /* Buffer containing previous term written */\n  const char *zTerm,              /* New term to write */\n  int nTerm,                      /* Size of zTerm in bytes */\n  const char *aDoclist,           /* Doclist (or NULL) to write */\n  int nDoclist                    /* Size of aDoclist in bytes */ \n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFirst = (pPrev->n==0);     /* True if this is the first term written */\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n\n  /* Node must have already been started. There must be a doclist for a\n  ** leaf node, and there must not be a doclist for an internal node.  */\n  assert( pNode->n>0 );\n  assert( (pNode->a[0]=='\\0')==(aDoclist!=0) );\n\n  blobGrowBuffer(pPrev, nTerm, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n  memcpy(pPrev->a, zTerm, nTerm);\n  pPrev->n = nTerm;\n\n  if( bFirst==0 ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);\n  }\n  pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);\n  memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);\n  pNode->n += nSuffix;\n\n  if( aDoclist ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);\n    memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);\n    pNode->n += nDoclist;\n  }\n\n  assert( pNode->n<=pNode->nAlloc );\n\n  return SQLITE_OK;\n}\n\n/*\n** Append the current term and doclist pointed to by cursor pCsr to the\n** appendable b-tree segment opened for writing by pWriter.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int fts3IncrmergeAppend(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  Fts3MultiSegReader *pCsr        /* Cursor containing term and doclist */\n){\n  const char *zTerm = pCsr->zTerm;\n  int nTerm = pCsr->nTerm;\n  const char *aDoclist = pCsr->aDoclist;\n  int nDoclist = pCsr->nDoclist;\n  int rc = SQLITE_OK;           /* Return code */\n  int nSpace;                   /* Total space in bytes required on leaf */\n  int nPrefix;                  /* Size of prefix shared with previous term */\n  int nSuffix;                  /* Size of suffix (nTerm - nPrefix) */\n  NodeWriter *pLeaf;            /* Object used to write leaf nodes */\n\n  pLeaf = &pWriter->aNodeWriter[0];\n  nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n\n  nSpace  = sqlite3Fts3VarintLen(nPrefix);\n  nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n  nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n\n  /* If the current block is not empty, and if adding this term/doclist\n  ** to the current block would make it larger than Fts3Table.nNodeSize\n  ** bytes, write this block out to the database. */\n  if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){\n    rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);\n    pWriter->nWork++;\n\n    /* Add the current term to the parent node. The term added to the \n    ** parent must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pLeaf->key), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);\n    }\n\n    /* Advance to the next output block */\n    pLeaf->iBlock++;\n    pLeaf->key.n = 0;\n    pLeaf->block.n = 0;\n\n    nSuffix = nTerm;\n    nSpace  = 1;\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n    nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n  }\n\n  blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);\n\n  if( rc==SQLITE_OK ){\n    if( pLeaf->block.n==0 ){\n      pLeaf->block.n = 1;\n      pLeaf->block.a[0] = '\\0';\n    }\n    rc = fts3AppendToNode(\n        &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist\n    );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to release all dynamic resources held by the\n** merge-writer object pWriter, and if no error has occurred, to flush\n** all outstanding node buffers held by pWriter to disk.\n**\n** If *pRc is not SQLITE_OK when this function is called, then no attempt\n** is made to write any data to disk. Instead, this function serves only\n** to release outstanding resources.\n**\n** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while\n** flushing buffers to disk, *pRc is set to an SQLite error code before\n** returning.\n*/\nstatic void fts3IncrmergeRelease(\n  Fts3Table *p,                   /* FTS3 table handle */\n  IncrmergeWriter *pWriter,       /* Merge-writer object */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;                          /* Used to iterate through non-root layers */\n  int iRoot;                      /* Index of root in pWriter->aNodeWriter */\n  NodeWriter *pRoot;              /* NodeWriter for root node */\n  int rc = *pRc;                  /* Error code */\n\n  /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment \n  ** root node. If the segment fits entirely on a single leaf node, iRoot\n  ** will be set to 0. If the root node is the parent of the leaves, iRoot\n  ** will be 1. And so on.  */\n  for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){\n    NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];\n    if( pNode->block.n>0 ) break;\n    assert( *pRc || pNode->block.nAlloc==0 );\n    assert( *pRc || pNode->key.nAlloc==0 );\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Empty output segment. This is a no-op. */\n  if( iRoot<0 ) return;\n\n  /* The entire output segment fits on a single node. Normally, this means\n  ** the node would be stored as a blob in the \"root\" column of the %_segdir\n  ** table. However, this is not permitted in this case. The problem is that \n  ** space has already been reserved in the %_segments table, and so the \n  ** start_block and end_block fields of the %_segdir table must be populated. \n  ** And, by design or by accident, released versions of FTS cannot handle \n  ** segments that fit entirely on the root node with start_block!=0.\n  **\n  ** Instead, create a synthetic root node that contains nothing but a \n  ** pointer to the single content node. So that the segment consists of a\n  ** single leaf and a single interior (root) node.\n  **\n  ** Todo: Better might be to defer allocating space in the %_segments \n  ** table until we are sure it is needed.\n  */\n  if( iRoot==0 ){\n    Blob *pBlock = &pWriter->aNodeWriter[1].block;\n    blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);\n    if( rc==SQLITE_OK ){\n      pBlock->a[0] = 0x01;\n      pBlock->n = 1 + sqlite3Fts3PutVarint(\n          &pBlock->a[1], pWriter->aNodeWriter[0].iBlock\n      );\n    }\n    iRoot = 1;\n  }\n  pRoot = &pWriter->aNodeWriter[iRoot];\n\n  /* Flush all currently outstanding nodes to disk. */\n  for(i=0; i<iRoot; i++){\n    NodeWriter *pNode = &pWriter->aNodeWriter[i];\n    if( pNode->block.n>0 && rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n    }\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Write the %_segdir record. */\n  if( rc==SQLITE_OK ){\n    rc = fts3WriteSegdir(p, \n        pWriter->iAbsLevel+1,               /* level */\n        pWriter->iIdx,                      /* idx */\n        pWriter->iStart,                    /* start_block */\n        pWriter->aNodeWriter[0].iBlock,     /* leaves_end_block */\n        pWriter->iEnd,                      /* end_block */\n        pRoot->block.a, pRoot->block.n      /* root */\n    );\n  }\n  sqlite3_free(pRoot->block.a);\n  sqlite3_free(pRoot->key.a);\n\n  *pRc = rc;\n}\n\n/*\n** Compare the term in buffer zLhs (size in bytes nLhs) with that in\n** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of\n** the other, it is considered to be smaller than the other.\n**\n** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve\n** if it is greater.\n*/\nstatic int fts3TermCmp(\n  const char *zLhs, int nLhs,     /* LHS of comparison */\n  const char *zRhs, int nRhs      /* RHS of comparison */\n){\n  int nCmp = MIN(nLhs, nRhs);\n  int res;\n\n  res = memcmp(zLhs, zRhs, nCmp);\n  if( res==0 ) res = nLhs - nRhs;\n\n  return res;\n}\n\n\n/*\n** Query to see if the entry in the %_segments table with blockid iEnd is \n** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before\n** returning. Otherwise, set *pbRes to 0. \n**\n** Or, if an error occurs while querying the database, return an SQLite \n** error code. The final value of *pbRes is undefined in this case.\n**\n** This is used to test if a segment is an \"appendable\" segment. If it\n** is, then a NULL entry has been inserted into the %_segments table\n** with blockid %_segdir.end_block.\n*/\nstatic int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){\n  int bRes = 0;                   /* Result to set *pbRes to */\n  sqlite3_stmt *pCheck = 0;       /* Statement to query database with */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pCheck, 1, iEnd);\n    if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;\n    rc = sqlite3_reset(pCheck);\n  }\n  \n  *pbRes = bRes;\n  return rc;\n}\n\n/*\n** This function is called when initializing an incremental-merge operation.\n** It checks if the existing segment with index value iIdx at absolute level \n** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the\n** merge-writer object *pWriter is initialized to write to it.\n**\n** An existing segment can be appended to by an incremental merge if:\n**\n**   * It was initially created as an appendable segment (with all required\n**     space pre-allocated), and\n**\n**   * The first key read from the input (arguments zKey and nKey) is \n**     greater than the largest key currently stored in the potential\n**     output segment.\n*/\nstatic int fts3IncrmergeLoad(\n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of candidate output segment */\n  const char *zKey,               /* First key to write */\n  int nKey,                       /* Number of bytes in nKey */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSelect = 0;      /* SELECT to read %_segdir entry */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_int64 iStart = 0;     /* Value of %_segdir.start_block */\n    sqlite3_int64 iLeafEnd = 0;   /* Value of %_segdir.leaves_end_block */\n    sqlite3_int64 iEnd = 0;       /* Value of %_segdir.end_block */\n    const char *aRoot = 0;        /* Pointer to %_segdir.root buffer */\n    int nRoot = 0;                /* Size of aRoot[] in bytes */\n    int rc2;                      /* Return code from sqlite3_reset() */\n    int bAppendable = 0;          /* Set to true if segment is appendable */\n\n    /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);\n    sqlite3_bind_int(pSelect, 2, iIdx);\n    if( sqlite3_step(pSelect)==SQLITE_ROW ){\n      iStart = sqlite3_column_int64(pSelect, 1);\n      iLeafEnd = sqlite3_column_int64(pSelect, 2);\n      iEnd = sqlite3_column_int64(pSelect, 3);\n      nRoot = sqlite3_column_bytes(pSelect, 4);\n      aRoot = sqlite3_column_blob(pSelect, 4);\n    }else{\n      return sqlite3_reset(pSelect);\n    }\n\n    /* Check for the zero-length marker in the %_segments table */\n    rc = fts3IsAppendable(p, iEnd, &bAppendable);\n\n    /* Check that zKey/nKey is larger than the largest key the candidate */\n    if( rc==SQLITE_OK && bAppendable ){\n      char *aLeaf = 0;\n      int nLeaf = 0;\n\n      rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);\n      if( rc==SQLITE_OK ){\n        NodeReader reader;\n        for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);\n            rc==SQLITE_OK && reader.aNode;\n            rc = nodeReaderNext(&reader)\n        ){\n          assert( reader.aNode );\n        }\n        if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){\n          bAppendable = 0;\n        }\n        nodeReaderRelease(&reader);\n      }\n      sqlite3_free(aLeaf);\n    }\n\n    if( rc==SQLITE_OK && bAppendable ){\n      /* It is possible to append to this segment. Set up the IncrmergeWriter\n      ** object to do so.  */\n      int i;\n      int nHeight = (int)aRoot[0];\n      NodeWriter *pNode;\n\n      pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;\n      pWriter->iStart = iStart;\n      pWriter->iEnd = iEnd;\n      pWriter->iAbsLevel = iAbsLevel;\n      pWriter->iIdx = iIdx;\n\n      for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n        pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n      }\n\n      pNode = &pWriter->aNodeWriter[nHeight];\n      pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;\n      blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);\n      if( rc==SQLITE_OK ){\n        memcpy(pNode->block.a, aRoot, nRoot);\n        pNode->block.n = nRoot;\n      }\n\n      for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){\n        NodeReader reader;\n        pNode = &pWriter->aNodeWriter[i];\n\n        rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);\n        while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);\n        blobGrowBuffer(&pNode->key, reader.term.n, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pNode->key.a, reader.term.a, reader.term.n);\n          pNode->key.n = reader.term.n;\n          if( i>0 ){\n            char *aBlock = 0;\n            int nBlock = 0;\n            pNode = &pWriter->aNodeWriter[i-1];\n            pNode->iBlock = reader.iChild;\n            rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);\n            blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);\n            if( rc==SQLITE_OK ){\n              memcpy(pNode->block.a, aBlock, nBlock);\n              pNode->block.n = nBlock;\n            }\n            sqlite3_free(aBlock);\n          }\n        }\n        nodeReaderRelease(&reader);\n      }\n    }\n\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** Determine the largest segment index value that exists within absolute\n** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus\n** one before returning SQLITE_OK. Or, if there are no segments at all \n** within level iAbsLevel, set *piIdx to zero.\n**\n** If an error occurs, return an SQLite error code. The final value of\n** *piIdx is undefined in this case.\n*/\nstatic int fts3IncrmergeOutputIdx( \n  Fts3Table *p,                   /* FTS Table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute index of input segments */\n  int *piIdx                      /* OUT: Next free index at iAbsLevel+1 */\n){\n  int rc;\n  sqlite3_stmt *pOutputIdx = 0;   /* SQL used to find output index */\n\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);\n    sqlite3_step(pOutputIdx);\n    *piIdx = sqlite3_column_int(pOutputIdx, 0);\n    rc = sqlite3_reset(pOutputIdx);\n  }\n\n  return rc;\n}\n\n/* \n** Allocate an appendable output segment on absolute level iAbsLevel+1\n** with idx value iIdx.\n**\n** In the %_segdir table, a segment is defined by the values in three\n** columns:\n**\n**     start_block\n**     leaves_end_block\n**     end_block\n**\n** When an appendable segment is allocated, it is estimated that the\n** maximum number of leaf blocks that may be required is the sum of the\n** number of leaf blocks consumed by the input segments, plus the number\n** of input segments, multiplied by two. This value is stored in stack \n** variable nLeafEst.\n**\n** A total of 16*nLeafEst blocks are allocated when an appendable segment\n** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous\n** array of leaf nodes starts at the first block allocated. The array\n** of interior nodes that are parents of the leaf nodes start at block\n** (start_block + (1 + end_block - start_block) / 16). And so on.\n**\n** In the actual code below, the value \"16\" is replaced with the \n** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.\n*/\nstatic int fts3IncrmergeWriter( \n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of new output segment */\n  Fts3MultiSegReader *pCsr,       /* Cursor that data will be read from */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return Code */\n  int i;                          /* Iterator variable */\n  int nLeafEst = 0;               /* Blocks allocated for leaf nodes */\n  sqlite3_stmt *pLeafEst = 0;     /* SQL used to determine nLeafEst */\n  sqlite3_stmt *pFirstBlock = 0;  /* SQL used to determine first block */\n\n  /* Calculate nLeafEst. */\n  rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);\n    sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);\n    if( SQLITE_ROW==sqlite3_step(pLeafEst) ){\n      nLeafEst = sqlite3_column_int(pLeafEst, 0);\n    }\n    rc = sqlite3_reset(pLeafEst);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Calculate the first block to use in the output segment */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){\n      pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);\n      pWriter->iEnd = pWriter->iStart - 1;\n      pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;\n    }\n    rc = sqlite3_reset(pFirstBlock);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Insert the marker in the %_segments table to make sure nobody tries\n  ** to steal the space just allocated. This is also used to identify \n  ** appendable segments.  */\n  rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pWriter->iAbsLevel = iAbsLevel;\n  pWriter->nLeafEst = nLeafEst;\n  pWriter->iIdx = iIdx;\n\n  /* Set up the array of NodeWriter objects */\n  for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n    pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Remove an entry from the %_segdir table. This involves running the \n** following two statements:\n**\n**   DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx\n**   UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx\n**\n** The DELETE statement removes the specific %_segdir level. The UPDATE \n** statement ensures that the remaining segments have contiguously allocated\n** idx values.\n*/\nstatic int fts3RemoveSegdirEntry(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to delete from */\n  int iIdx                        /* Index of %_segdir entry to delete */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pDelete = 0;      /* DELETE statement */\n\n  rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pDelete, 1, iAbsLevel);\n    sqlite3_bind_int(pDelete, 2, iIdx);\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** One or more segments have just been removed from absolute level iAbsLevel.\n** Update the 'idx' values of the remaining segments in the level so that\n** the idx values are a contiguous sequence starting from 0.\n*/\nstatic int fts3RepackSegdirLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel         /* Absolute level to repack */\n){\n  int rc;                         /* Return code */\n  int *aIdx = 0;                  /* Array of remaining idx values */\n  int nIdx = 0;                   /* Valid entries in aIdx[] */\n  int nAlloc = 0;                 /* Allocated size of aIdx[] */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pSelect = 0;      /* Select statement to read idx values */\n  sqlite3_stmt *pUpdate = 0;      /* Update statement to modify idx values */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel);\n    while( SQLITE_ROW==sqlite3_step(pSelect) ){\n      if( nIdx>=nAlloc ){\n        int *aNew;\n        nAlloc += 16;\n        aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));\n        if( !aNew ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        aIdx = aNew;\n      }\n      aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pUpdate, 2, iAbsLevel);\n  }\n\n  assert( p->bIgnoreSavepoint==0 );\n  p->bIgnoreSavepoint = 1;\n  for(i=0; rc==SQLITE_OK && i<nIdx; i++){\n    if( aIdx[i]!=i ){\n      sqlite3_bind_int(pUpdate, 3, aIdx[i]);\n      sqlite3_bind_int(pUpdate, 1, i);\n      sqlite3_step(pUpdate);\n      rc = sqlite3_reset(pUpdate);\n    }\n  }\n  p->bIgnoreSavepoint = 0;\n\n  sqlite3_free(aIdx);\n  return rc;\n}\n\nstatic void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){\n  pNode->a[0] = (char)iHeight;\n  if( iChild ){\n    assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );\n    pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);\n  }else{\n    assert( pNode->nAlloc>=1 );\n    pNode->n = 1;\n  }\n}\n\n/*\n** The first two arguments are a pointer to and the size of a segment b-tree\n** node. The node may be a leaf or an internal node.\n**\n** This function creates a new node image in blob object *pNew by copying\n** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)\n** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.\n*/\nstatic int fts3TruncateNode(\n  const char *aNode,              /* Current node image */\n  int nNode,                      /* Size of aNode in bytes */\n  Blob *pNew,                     /* OUT: Write new node image here */\n  const char *zTerm,              /* Omit all terms smaller than this */\n  int nTerm,                      /* Size of zTerm in bytes */\n  sqlite3_int64 *piBlock          /* OUT: Block number in next layer down */\n){\n  NodeReader reader;              /* Reader object */\n  Blob prev = {0, 0, 0};          /* Previous term written to new node */\n  int rc = SQLITE_OK;             /* Return code */\n  int bLeaf = aNode[0]=='\\0';     /* True for a leaf node */\n\n  /* Allocate required output space */\n  blobGrowBuffer(pNew, nNode, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n  pNew->n = 0;\n\n  /* Populate new node buffer */\n  for(rc = nodeReaderInit(&reader, aNode, nNode); \n      rc==SQLITE_OK && reader.aNode; \n      rc = nodeReaderNext(&reader)\n  ){\n    if( pNew->n==0 ){\n      int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);\n      if( res<0 || (bLeaf==0 && res==0) ) continue;\n      fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n      *piBlock = reader.iChild;\n    }\n    rc = fts3AppendToNode(\n        pNew, &prev, reader.term.a, reader.term.n,\n        reader.aDoclist, reader.nDoclist\n    );\n    if( rc!=SQLITE_OK ) break;\n  }\n  if( pNew->n==0 ){\n    fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n    *piBlock = reader.iChild;\n  }\n  assert( pNew->n<=pNew->nAlloc );\n\n  nodeReaderRelease(&reader);\n  sqlite3_free(prev.a);\n  return rc;\n}\n\n/*\n** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute \n** level iAbsLevel. This may involve deleting entries from the %_segments\n** table, and modifying existing entries in both the %_segments and %_segdir\n** tables.\n**\n** SQLITE_OK is returned if the segment is updated successfully. Or an\n** SQLite error code otherwise.\n*/\nstatic int fts3TruncateSegment(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of segment to modify */\n  int iIdx,                       /* Index within level of segment to modify */\n  const char *zTerm,              /* Remove terms smaller than this */\n  int nTerm                      /* Number of bytes in buffer zTerm */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Blob root = {0,0,0};            /* New root page image */\n  Blob block = {0,0,0};           /* Buffer used for any other block */\n  sqlite3_int64 iBlock = 0;       /* Block id */\n  sqlite3_int64 iNewStart = 0;    /* New value for iStartBlock */\n  sqlite3_int64 iOldStart = 0;    /* Old value for iStartBlock */\n  sqlite3_stmt *pFetch = 0;       /* Statement used to fetch segdir */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;                      /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pFetch, 1, iAbsLevel);\n    sqlite3_bind_int(pFetch, 2, iIdx);\n    if( SQLITE_ROW==sqlite3_step(pFetch) ){\n      const char *aRoot = sqlite3_column_blob(pFetch, 4);\n      int nRoot = sqlite3_column_bytes(pFetch, 4);\n      iOldStart = sqlite3_column_int64(pFetch, 1);\n      rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);\n    }\n    rc2 = sqlite3_reset(pFetch);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  while( rc==SQLITE_OK && iBlock ){\n    char *aBlock = 0;\n    int nBlock = 0;\n    iNewStart = iBlock;\n\n    rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);\n    if( rc==SQLITE_OK ){\n      rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, iNewStart, block.a, block.n);\n    }\n    sqlite3_free(aBlock);\n  }\n\n  /* Variable iNewStart now contains the first valid leaf node. */\n  if( rc==SQLITE_OK && iNewStart ){\n    sqlite3_stmt *pDel = 0;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iOldStart);\n      sqlite3_bind_int64(pDel, 2, iNewStart-1);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_stmt *pChomp = 0;\n    rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pChomp, 1, iNewStart);\n      sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);\n      sqlite3_bind_int64(pChomp, 3, iAbsLevel);\n      sqlite3_bind_int(pChomp, 4, iIdx);\n      sqlite3_step(pChomp);\n      rc = sqlite3_reset(pChomp);\n    }\n  }\n\n  sqlite3_free(root.a);\n  sqlite3_free(block.a);\n  return rc;\n}\n\n/*\n** This function is called after an incrmental-merge operation has run to\n** merge (or partially merge) two or more segments from absolute level\n** iAbsLevel.\n**\n** Each input segment is either removed from the db completely (if all of\n** its data was copied to the output segment by the incrmerge operation)\n** or modified in place so that it no longer contains those entries that\n** have been duplicated in the output segment.\n*/\nstatic int fts3IncrmergeChomp(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level containing segments */\n  Fts3MultiSegReader *pCsr,       /* Chomp all segments opened by this cursor */\n  int *pnRem                      /* Number of segments not deleted */\n){\n  int i;\n  int nRem = 0;\n  int rc = SQLITE_OK;\n\n  for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){\n    Fts3SegReader *pSeg = 0;\n    int j;\n\n    /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding\n    ** somewhere in the pCsr->apSegment[] array.  */\n    for(j=0; ALWAYS(j<pCsr->nSegment); j++){\n      pSeg = pCsr->apSegment[j];\n      if( pSeg->iIdx==i ) break;\n    }\n    assert( j<pCsr->nSegment && pSeg->iIdx==i );\n\n    if( pSeg->aNode==0 ){\n      /* Seg-reader is at EOF. Remove the entire input segment. */\n      rc = fts3DeleteSegment(p, pSeg);\n      if( rc==SQLITE_OK ){\n        rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);\n      }\n      *pnRem = 0;\n    }else{\n      /* The incremental merge did not copy all the data from this \n      ** segment to the upper level. The segment is modified in place\n      ** so that it contains no keys smaller than zTerm/nTerm. */ \n      const char *zTerm = pSeg->zTerm;\n      int nTerm = pSeg->nTerm;\n      rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);\n      nRem++;\n    }\n  }\n\n  if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){\n    rc = fts3RepackSegdirLevel(p, iAbsLevel);\n  }\n\n  *pnRem = nRem;\n  return rc;\n}\n\n/*\n** Store an incr-merge hint in the database.\n*/\nstatic int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pReplace = 0;\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);\n    sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n  }\n\n  return rc;\n}\n\n/*\n** Load an incr-merge hint from the database. The incr-merge hint, if one \n** exists, is stored in the rowid==1 row of the %_stat table.\n**\n** If successful, populate blob *pHint with the value read from the %_stat\n** table and return SQLITE_OK. Otherwise, if an error occurs, return an\n** SQLite error code.\n*/\nstatic int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pSelect = 0;\n  int rc;\n\n  pHint->n = 0;\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      const char *aHint = sqlite3_column_blob(pSelect, 0);\n      int nHint = sqlite3_column_bytes(pSelect, 0);\n      if( aHint ){\n        blobGrowBuffer(pHint, nHint, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pHint->a, aHint, nHint);\n          pHint->n = nHint;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, append an entry to the hint stored in blob *pHint. Each entry\n** consists of two varints, the absolute level number of the input segments \n** and the number of input segments.\n**\n** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,\n** set *pRc to an SQLite error code before returning.\n*/\nstatic void fts3IncrmergeHintPush(\n  Blob *pHint,                    /* Hint blob to append to */\n  i64 iAbsLevel,                  /* First varint to store in hint */\n  int nInput,                     /* Second varint to store in hint */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);\n  if( *pRc==SQLITE_OK ){\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);\n  }\n}\n\n/*\n** Read the last entry (most recently pushed) from the hint blob *pHint\n** and then remove the entry. Write the two values read to *piAbsLevel and \n** *pnInput before returning.\n**\n** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does\n** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.\n*/\nstatic int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){\n  const int nHint = pHint->n;\n  int i;\n\n  i = pHint->n-2;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n\n  pHint->n = i;\n  i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);\n  i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);\n  if( i!=nHint ) return SQLITE_CORRUPT_VTAB;\n\n  return SQLITE_OK;\n}\n\n\n/*\n** Attempt an incremental merge that writes nMerge leaf blocks.\n**\n** Incremental merges happen nMin segments at a time. The two\n** segments to be merged are the nMin oldest segments (the ones with\n** the smallest indexes) in the highest level that contains at least\n** nMin segments. Multiple merges might occur in an attempt to write the \n** quota of nMerge leaf blocks.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){\n  int rc;                         /* Return code */\n  int nRem = nMerge;              /* Number of leaf pages yet to  be written */\n  Fts3MultiSegReader *pCsr;       /* Cursor used to read input data */\n  Fts3SegFilter *pFilter;         /* Filter used with cursor pCsr */\n  IncrmergeWriter *pWriter;       /* Writer object */\n  int nSeg = 0;                   /* Number of input segments */\n  sqlite3_int64 iAbsLevel = 0;    /* Absolute level number to work on */\n  Blob hint = {0, 0, 0};          /* Hint read from %_stat table */\n  int bDirtyHint = 0;             /* True if blob 'hint' has been modified */\n\n  /* Allocate space for the cursor, filter and writer objects */\n  const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);\n  pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);\n  if( !pWriter ) return SQLITE_NOMEM;\n  pFilter = (Fts3SegFilter *)&pWriter[1];\n  pCsr = (Fts3MultiSegReader *)&pFilter[1];\n\n  rc = fts3IncrmergeHintLoad(p, &hint);\n  while( rc==SQLITE_OK && nRem>0 ){\n    const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;\n    sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */\n    int bUseHint = 0;             /* True if attempting to append */\n\n    /* Search the %_segdir table for the absolute level with the smallest\n    ** relative level number that contains at least nMin segments, if any.\n    ** If one is found, set iAbsLevel to the absolute level number and\n    ** nSeg to nMin. If no level with at least nMin segments can be found, \n    ** set nSeg to -1.\n    */\n    rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);\n    sqlite3_bind_int(pFindLevel, 1, nMin);\n    if( sqlite3_step(pFindLevel)==SQLITE_ROW ){\n      iAbsLevel = sqlite3_column_int64(pFindLevel, 0);\n      nSeg = nMin;\n    }else{\n      nSeg = -1;\n    }\n    rc = sqlite3_reset(pFindLevel);\n\n    /* If the hint read from the %_stat table is not empty, check if the\n    ** last entry in it specifies a relative level smaller than or equal\n    ** to the level identified by the block above (if any). If so, this \n    ** iteration of the loop will work on merging at the hinted level.\n    */\n    if( rc==SQLITE_OK && hint.n ){\n      int nHint = hint.n;\n      sqlite3_int64 iHintAbsLevel = 0;      /* Hint level */\n      int nHintSeg = 0;                     /* Hint number of segments */\n\n      rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);\n      if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){\n        iAbsLevel = iHintAbsLevel;\n        nSeg = nHintSeg;\n        bUseHint = 1;\n        bDirtyHint = 1;\n      }else{\n        /* This undoes the effect of the HintPop() above - so that no entry\n        ** is removed from the hint blob.  */\n        hint.n = nHint;\n      }\n    }\n\n    /* If nSeg is less that zero, then there is no level with at least\n    ** nMin segments and no hint in the %_stat table. No work to do.\n    ** Exit early in this case.  */\n    if( nSeg<0 ) break;\n\n    /* Open a cursor to iterate through the contents of the oldest nSeg \n    ** indexes of absolute level iAbsLevel. If this cursor is opened using \n    ** the 'hint' parameters, it is possible that there are less than nSeg\n    ** segments available in level iAbsLevel. In this case, no work is\n    ** done on iAbsLevel - fall through to the next iteration of the loop \n    ** to start work on some other level.  */\n    memset(pWriter, 0, nAlloc);\n    pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);\n    }\n    if( SQLITE_OK==rc && pCsr->nSegment==nSeg\n     && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))\n     && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))\n    ){\n      int iIdx = 0;               /* Largest idx in level (iAbsLevel+1) */\n      rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);\n      if( rc==SQLITE_OK ){\n        if( bUseHint && iIdx>0 ){\n          const char *zKey = pCsr->zTerm;\n          int nKey = pCsr->nTerm;\n          rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);\n        }else{\n          rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);\n        }\n      }\n\n      if( rc==SQLITE_OK && pWriter->nLeafEst ){\n        fts3LogMerge(nSeg, iAbsLevel);\n        do {\n          rc = fts3IncrmergeAppend(p, pWriter, pCsr);\n          if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);\n          if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;\n        }while( rc==SQLITE_ROW );\n\n        /* Update or delete the input segments */\n        if( rc==SQLITE_OK ){\n          nRem -= (1 + pWriter->nWork);\n          rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);\n          if( nSeg!=0 ){\n            bDirtyHint = 1;\n            fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);\n          }\n        }\n      }\n\n      fts3IncrmergeRelease(p, pWriter, &rc);\n    }\n\n    sqlite3Fts3SegReaderFinish(pCsr);\n  }\n\n  /* Write the hint values into the %_stat table for the next incr-merger */\n  if( bDirtyHint && rc==SQLITE_OK ){\n    rc = fts3IncrmergeHintStore(p, &hint);\n  }\n\n  sqlite3_free(pWriter);\n  sqlite3_free(hint.a);\n  return rc;\n}\n\n/*\n** Convert the text beginning at *pz into an integer and return\n** its value.  Advance *pz to point to the first character past\n** the integer.\n*/\nstatic int fts3Getint(const char **pz){\n  const char *z = *pz;\n  int i = 0;\n  while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0';\n  *pz = z;\n  return i;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('merge=A,B');\n**\n** A and B are integers that decode to be the number of leaf pages\n** written for the merge, and the minimum number of segments on a level\n** before it will be selected for a merge, respectively.\n*/\nstatic int fts3DoIncrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing \"A,B\" */\n){\n  int rc;\n  int nMin = (FTS3_MERGE_COUNT / 2);\n  int nMerge = 0;\n  const char *z = zParam;\n\n  /* Read the first integer value */\n  nMerge = fts3Getint(&z);\n\n  /* If the first integer value is followed by a ',',  read the second\n  ** integer value. */\n  if( z[0]==',' && z[1]!='\\0' ){\n    z++;\n    nMin = fts3Getint(&z);\n  }\n\n  if( z[0]!='\\0' || nMin<2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = SQLITE_OK;\n    if( !p->bHasStat ){\n      assert( p->bFts4==0 );\n      sqlite3Fts3CreateStatTable(&rc, p);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);\n    }\n    sqlite3Fts3SegmentsClose(p);\n  }\n  return rc;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('automerge=X');\n**\n** where X is an integer.  X==0 means to turn automerge off.  X!=0 means\n** turn it on.  The setting is persistent.\n*/\nstatic int fts3DoAutoincrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing boolean */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  p->bAutoincrmerge = fts3Getint(&zParam)!=0;\n  if( !p->bHasStat ){\n    assert( p->bFts4==0 );\n    sqlite3Fts3CreateStatTable(&rc, p);\n    if( rc ) return rc;\n  }\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ) return rc;;\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n  sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);\n  sqlite3_step(pStmt);\n  rc = sqlite3_reset(pStmt);\n  return rc;\n}\n\n/*\n** Return a 64-bit checksum for the FTS index entry specified by the\n** arguments to this function.\n*/\nstatic u64 fts3ChecksumEntry(\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int iLangid,                    /* Language id for current row */\n  int iIndex,                     /* Index (0..Fts3Table.nIndex-1) */\n  i64 iDocid,                     /* Docid for current row. */\n  int iCol,                       /* Column number */\n  int iPos                        /* Position */\n){\n  int i;\n  u64 ret = (u64)iDocid;\n\n  ret += (ret<<3) + iLangid;\n  ret += (ret<<3) + iIndex;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];\n\n  return ret;\n}\n\n/*\n** Return a checksum of all entries in the FTS index that correspond to\n** language id iLangid. The checksum is calculated by XORing the checksums\n** of each individual entry (see fts3ChecksumEntry()) together.\n**\n** If successful, the checksum value is returned and *pRc set to SQLITE_OK.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The\n** return value is undefined in this case.\n*/\nstatic u64 fts3ChecksumIndex(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id to return cksum for */\n  int iIndex,                     /* Index to cksum (0..p->nIndex-1) */\n  int *pRc                        /* OUT: Return code */\n){\n  Fts3SegFilter filter;\n  Fts3MultiSegReader csr;\n  int rc;\n  u64 cksum = 0;\n\n  assert( *pRc==SQLITE_OK );\n\n  memset(&filter, 0, sizeof(filter));\n  memset(&csr, 0, sizeof(csr));\n  filter.flags =  FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  filter.flags |= FTS3_SEGMENT_SCAN;\n\n  rc = sqlite3Fts3SegReaderCursor(\n      p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  }\n\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){\n      char *pCsr = csr.aDoclist;\n      char *pEnd = &pCsr[csr.nDoclist];\n\n      i64 iDocid = 0;\n      i64 iCol = 0;\n      i64 iPos = 0;\n\n      pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);\n      while( pCsr<pEnd ){\n        i64 iVal = 0;\n        pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n        if( pCsr<pEnd ){\n          if( iVal==0 || iVal==1 ){\n            iCol = 0;\n            iPos = 0;\n            if( iVal ){\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);\n            }else{\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n              iDocid += iVal;\n            }\n          }else{\n            iPos += (iVal - 2);\n            cksum = cksum ^ fts3ChecksumEntry(\n                csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,\n                (int)iCol, (int)iPos\n            );\n          }\n        }\n      }\n    }\n  }\n  sqlite3Fts3SegReaderFinish(&csr);\n\n  *pRc = rc;\n  return cksum;\n}\n\n/*\n** Check if the contents of the FTS index match the current contents of the\n** content table. If no error occurs and the contents do match, set *pbOk\n** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk\n** to false before returning.\n**\n** If an error occurs (e.g. an OOM or IO error), return an SQLite error \n** code. The final value of *pbOk is undefined in this case.\n*/\nstatic int fts3IntegrityCheck(Fts3Table *p, int *pbOk){\n  int rc = SQLITE_OK;             /* Return code */\n  u64 cksum1 = 0;                 /* Checksum based on FTS index contents */\n  u64 cksum2 = 0;                 /* Checksum based on %_content contents */\n  sqlite3_stmt *pAllLangid = 0;   /* Statement to return all language-ids */\n\n  /* This block calculates the checksum according to the FTS index. */\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->nIndex);\n    while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      int i;\n      for(i=0; i<p->nIndex; i++){\n        cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* This block calculates the checksum according to the %_content table */\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;\n    sqlite3_stmt *pStmt = 0;\n    char *zSql;\n   \n    zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      i64 iDocid = sqlite3_column_int64(pStmt, 0);\n      int iLang = langidFromSelect(p, pStmt);\n      int iCol;\n\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);\n        int nText = sqlite3_column_bytes(pStmt, iCol+1);\n        sqlite3_tokenizer_cursor *pT = 0;\n\n        rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);\n        while( rc==SQLITE_OK ){\n          char const *zToken;       /* Buffer containing token */\n          int nToken = 0;           /* Number of bytes in token */\n          int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n          int iPos = 0;             /* Position of token in zText */\n\n          rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n          if( rc==SQLITE_OK ){\n            int i;\n            cksum2 = cksum2 ^ fts3ChecksumEntry(\n                zToken, nToken, iLang, 0, iDocid, iCol, iPos\n            );\n            for(i=1; i<p->nIndex; i++){\n              if( p->aIndex[i].nPrefix<=nToken ){\n                cksum2 = cksum2 ^ fts3ChecksumEntry(\n                  zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos\n                );\n              }\n            }\n          }\n        }\n        if( pT ) pModule->xClose(pT);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n      }\n    }\n\n    sqlite3_finalize(pStmt);\n  }\n\n  *pbOk = (cksum1==cksum2);\n  return rc;\n}\n\n/*\n** Run the integrity-check. If no error occurs and the current contents of\n** the FTS index are correct, return SQLITE_OK. Or, if the contents of the\n** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.\n**\n** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite \n** error code.\n**\n** The integrity-check works as follows. For each token and indexed token\n** prefix in the document set, a 64-bit checksum is calculated (by code\n** in fts3ChecksumEntry()) based on the following:\n**\n**     + The index number (0 for the main index, 1 for the first prefix\n**       index etc.),\n**     + The token (or token prefix) text itself, \n**     + The language-id of the row it appears in,\n**     + The docid of the row it appears in,\n**     + The column it appears in, and\n**     + The tokens position within that column.\n**\n** The checksums for all entries in the index are XORed together to create\n** a single checksum for the entire index.\n**\n** The integrity-check code calculates the same checksum in two ways:\n**\n**     1. By scanning the contents of the FTS index, and \n**     2. By scanning and tokenizing the content table.\n**\n** If the two checksums are identical, the integrity-check is deemed to have\n** passed.\n*/\nstatic int fts3DoIntegrityCheck(\n  Fts3Table *p                    /* FTS3 table handle */\n){\n  int rc;\n  int bOk = 0;\n  rc = fts3IntegrityCheck(p, &bOk);\n  if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;\n  return rc;\n}\n\n/*\n** Handle a 'special' INSERT of the form:\n**\n**   \"INSERT INTO tbl(tbl) VALUES(<expr>)\"\n**\n** Argument pVal contains the result of <expr>. Currently the only \n** meaningful value to insert is the text 'optimize'.\n*/\nstatic int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){\n  int rc;                         /* Return Code */\n  const char *zVal = (const char *)sqlite3_value_text(pVal);\n  int nVal = sqlite3_value_bytes(pVal);\n\n  if( !zVal ){\n    return SQLITE_NOMEM;\n  }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, \"optimize\", 8) ){\n    rc = fts3DoOptimize(p, 0);\n  }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, \"rebuild\", 7) ){\n    rc = fts3DoRebuild(p);\n  }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, \"integrity-check\", 15) ){\n    rc = fts3DoIntegrityCheck(p);\n  }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, \"merge=\", 6) ){\n    rc = fts3DoIncrmerge(p, &zVal[6]);\n  }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, \"automerge=\", 10) ){\n    rc = fts3DoAutoincrmerge(p, &zVal[10]);\n#ifdef SQLITE_TEST\n  }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, \"nodesize=\", 9) ){\n    p->nNodeSize = atoi(&zVal[9]);\n    rc = SQLITE_OK;\n  }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, \"maxpending=\", 9) ){\n    p->nMaxPendingData = atoi(&zVal[11]);\n    rc = SQLITE_OK;\n#endif\n  }else{\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n/*\n** Delete all cached deferred doclists. Deferred doclists are cached\n** (allocated) by the sqlite3Fts3CacheDeferredDoclists() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pDef->pNext){\n    fts3PendingListDelete(pDef->pList);\n    pDef->pList = 0;\n  }\n}\n\n/*\n** Free all entries in the pCsr->pDeffered list. Entries are added to \n** this list using sqlite3Fts3DeferToken().\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  Fts3DeferredToken *pNext;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pNext){\n    pNext = pDef->pNext;\n    fts3PendingListDelete(pDef->pList);\n    sqlite3_free(pDef);\n  }\n  pCsr->pDeferred = 0;\n}\n\n/*\n** Generate deferred-doclists for all tokens in the pCsr->pDeferred list\n** based on the row that pCsr currently points to.\n**\n** A deferred-doclist is like any other doclist with position information\n** included, except that it only contains entries for a single row of the\n** table, not for all rows.\n*/\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pCsr->pDeferred ){\n    int i;                        /* Used to iterate through table columns */\n    sqlite3_int64 iDocid;         /* Docid of the row pCsr points to */\n    Fts3DeferredToken *pDef;      /* Used to iterate through deferred tokens */\n  \n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    sqlite3_tokenizer *pT = p->pTokenizer;\n    sqlite3_tokenizer_module const *pModule = pT->pModule;\n   \n    assert( pCsr->isRequireSeek==0 );\n    iDocid = sqlite3_column_int64(pCsr->pStmt, 0);\n  \n    for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){\n      const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);\n      sqlite3_tokenizer_cursor *pTC = 0;\n  \n      rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);\n      while( rc==SQLITE_OK ){\n        char const *zToken;       /* Buffer containing token */\n        int nToken = 0;           /* Number of bytes in token */\n        int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n        int iPos = 0;             /* Position of token in zText */\n  \n        rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n        for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n          Fts3PhraseToken *pPT = pDef->pToken;\n          if( (pDef->iCol>=p->nColumn || pDef->iCol==i)\n           && (pPT->bFirst==0 || iPos==0)\n           && (pPT->n==nToken || (pPT->isPrefix && pPT->n<nToken))\n           && (0==memcmp(zToken, pPT->z, pPT->n))\n          ){\n            fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);\n          }\n        }\n      }\n      if( pTC ) pModule->xClose(pTC);\n      if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n    }\n  \n    for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n      if( pDef->pList ){\n        rc = fts3PendingListAppendVarint(&pDef->pList, 0);\n      }\n    }\n  }\n\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(\n  Fts3DeferredToken *p, \n  char **ppData, \n  int *pnData\n){\n  char *pRet;\n  int nSkip;\n  sqlite3_int64 dummy;\n\n  *ppData = 0;\n  *pnData = 0;\n\n  if( p->pList==0 ){\n    return SQLITE_OK;\n  }\n\n  pRet = (char *)sqlite3_malloc(p->pList->nData);\n  if( !pRet ) return SQLITE_NOMEM;\n\n  nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy);\n  *pnData = p->pList->nData - nSkip;\n  *ppData = pRet;\n  \n  memcpy(pRet, &p->pList->aData[nSkip], *pnData);\n  return SQLITE_OK;\n}\n\n/*\n** Add an entry for token pToken to the pCsr->pDeferred list.\n*/\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(\n  Fts3Cursor *pCsr,               /* Fts3 table cursor */\n  Fts3PhraseToken *pToken,        /* Token to defer */\n  int iCol                        /* Column that token must appear in (or -1) */\n){\n  Fts3DeferredToken *pDeferred;\n  pDeferred = sqlite3_malloc(sizeof(*pDeferred));\n  if( !pDeferred ){\n    return SQLITE_NOMEM;\n  }\n  memset(pDeferred, 0, sizeof(*pDeferred));\n  pDeferred->pToken = pToken;\n  pDeferred->pNext = pCsr->pDeferred; \n  pDeferred->iCol = iCol;\n  pCsr->pDeferred = pDeferred;\n\n  assert( pToken->pDeferred==0 );\n  pToken->pDeferred = pDeferred;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** SQLite value pRowid contains the rowid of a row that may or may not be\n** present in the FTS3 table. If it is, delete it and adjust the contents\n** of subsiduary data structures accordingly.\n*/\nstatic int fts3DeleteByRowid(\n  Fts3Table *p, \n  sqlite3_value *pRowid, \n  int *pnChng,                    /* IN/OUT: Decrement if row is deleted */\n  u32 *aSzDel\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFound = 0;                 /* True if *pRowid really is in the table */\n\n  fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);\n  if( bFound && rc==SQLITE_OK ){\n    int isEmpty = 0;              /* Deleting *pRowid leaves the table empty */\n    rc = fts3IsEmpty(p, pRowid, &isEmpty);\n    if( rc==SQLITE_OK ){\n      if( isEmpty ){\n        /* Deleting this row means the whole table is empty. In this case\n        ** delete the contents of all three tables and throw away any\n        ** data in the pendingTerms hash table.  */\n        rc = fts3DeleteAll(p, 1);\n        *pnChng = 0;\n        memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);\n      }else{\n        *pnChng = *pnChng - 1;\n        if( p->zContentTbl==0 ){\n          fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);\n        }\n        if( p->bHasDocsize ){\n          fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function does the work for the xUpdate method of FTS3 virtual\n** tables. The schema of the virtual table being:\n**\n**     CREATE TABLE <table name>( \n**       <user columns>,\n**       <table name> HIDDEN, \n**       docid HIDDEN, \n**       <langid> HIDDEN\n**     );\n**\n** \n*/\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* FTS3 vtab object */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;             /* Return Code */\n  int isRemove = 0;               /* True for an UPDATE or DELETE */\n  u32 *aSzIns = 0;                /* Sizes of inserted documents */\n  u32 *aSzDel = 0;                /* Sizes of deleted documents */\n  int nChng = 0;                  /* Net change in number of documents */\n  int bInsertDone = 0;\n\n  assert( p->pSegments==0 );\n  assert( \n      nArg==1                     /* DELETE operations */\n   || nArg==(2 + p->nColumn + 3)  /* INSERT or UPDATE operations */\n  );\n\n  /* Check for a \"special\" INSERT operation. One of the form:\n  **\n  **   INSERT INTO xyz(xyz) VALUES('command');\n  */\n  if( nArg>1 \n   && sqlite3_value_type(apVal[0])==SQLITE_NULL \n   && sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL \n  ){\n    rc = fts3SpecialInsert(p, apVal[p->nColumn+2]);\n    goto update_out;\n  }\n\n  if( nArg>1 && sqlite3_value_int(apVal[2 + p->nColumn + 2])<0 ){\n    rc = SQLITE_CONSTRAINT;\n    goto update_out;\n  }\n\n  /* Allocate space to hold the change in document sizes */\n  aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );\n  if( aSzDel==0 ){\n    rc = SQLITE_NOMEM;\n    goto update_out;\n  }\n  aSzIns = &aSzDel[p->nColumn+1];\n  memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);\n\n  /* If this is an INSERT operation, or an UPDATE that modifies the rowid\n  ** value, then this operation requires constraint handling.\n  **\n  ** If the on-conflict mode is REPLACE, this means that the existing row\n  ** should be deleted from the database before inserting the new row. Or,\n  ** if the on-conflict mode is other than REPLACE, then this method must\n  ** detect the conflict and return SQLITE_CONSTRAINT before beginning to\n  ** modify the database file.\n  */\n  if( nArg>1 && p->zContentTbl==0 ){\n    /* Find the value object that holds the new rowid value. */\n    sqlite3_value *pNewRowid = apVal[3+p->nColumn];\n    if( sqlite3_value_type(pNewRowid)==SQLITE_NULL ){\n      pNewRowid = apVal[1];\n    }\n\n    if( sqlite3_value_type(pNewRowid)!=SQLITE_NULL && ( \n        sqlite3_value_type(apVal[0])==SQLITE_NULL\n     || sqlite3_value_int64(apVal[0])!=sqlite3_value_int64(pNewRowid)\n    )){\n      /* The new rowid is not NULL (in this case the rowid will be\n      ** automatically assigned and there is no chance of a conflict), and \n      ** the statement is either an INSERT or an UPDATE that modifies the\n      ** rowid column. So if the conflict mode is REPLACE, then delete any\n      ** existing row with rowid=pNewRowid. \n      **\n      ** Or, if the conflict mode is not REPLACE, insert the new record into \n      ** the %_content table. If we hit the duplicate rowid constraint (or any\n      ** other error) while doing so, return immediately.\n      **\n      ** This branch may also run if pNewRowid contains a value that cannot\n      ** be losslessly converted to an integer. In this case, the eventual \n      ** call to fts3InsertData() (either just below or further on in this\n      ** function) will return SQLITE_MISMATCH. If fts3DeleteByRowid is \n      ** invoked, it will delete zero rows (since no row will have\n      ** docid=$pNewRowid if $pNewRowid is not an integer value).\n      */\n      if( sqlite3_vtab_on_conflict(p->db)==SQLITE_REPLACE ){\n        rc = fts3DeleteByRowid(p, pNewRowid, &nChng, aSzDel);\n      }else{\n        rc = fts3InsertData(p, apVal, pRowid);\n        bInsertDone = 1;\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    goto update_out;\n  }\n\n  /* If this is a DELETE or UPDATE operation, remove the old record. */\n  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){\n    assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER );\n    rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel);\n    isRemove = 1;\n  }\n  \n  /* If this is an INSERT or UPDATE operation, insert the new record. */\n  if( nArg>1 && rc==SQLITE_OK ){\n    int iLangid = sqlite3_value_int(apVal[2 + p->nColumn + 2]);\n    if( bInsertDone==0 ){\n      rc = fts3InsertData(p, apVal, pRowid);\n      if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){\n        rc = FTS_CORRUPT_VTAB;\n      }\n    }\n    if( rc==SQLITE_OK && (!isRemove || *pRowid!=p->iPrevDocid ) ){\n      rc = fts3PendingTermsDocid(p, iLangid, *pRowid);\n    }\n    if( rc==SQLITE_OK ){\n      assert( p->iPrevDocid==*pRowid );\n      rc = fts3InsertTerms(p, iLangid, apVal, aSzIns);\n    }\n    if( p->bHasDocsize ){\n      fts3InsertDocsize(&rc, p, aSzIns);\n    }\n    nChng++;\n  }\n\n  if( p->bFts4 ){\n    fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);\n  }\n\n update_out:\n  sqlite3_free(aSzDel);\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n/* \n** Flush any data in the pending-terms hash table to disk. If successful,\n** merge all segments in the database (including the new segment, if \n** there was any data to flush) into a single segment. \n*/\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){\n  int rc;\n  rc = sqlite3_exec(p->db, \"SAVEPOINT fts3\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = fts3DoOptimize(p, 1);\n    if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n      int rc2 = sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n      if( rc2!=SQLITE_OK ) rc = rc2;\n    }else{\n      sqlite3_exec(p->db, \"ROLLBACK TO fts3\", 0, 0, 0);\n      sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n    }\n  }\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n#endif\n\n/************** End of fts3_write.c ******************************************/\n/************** Begin file fts3_snippet.c ************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** Characters that may appear in the second argument to matchinfo().\n*/\n#define FTS3_MATCHINFO_NPHRASE   'p'        /* 1 value */\n#define FTS3_MATCHINFO_NCOL      'c'        /* 1 value */\n#define FTS3_MATCHINFO_NDOC      'n'        /* 1 value */\n#define FTS3_MATCHINFO_AVGLENGTH 'a'        /* nCol values */\n#define FTS3_MATCHINFO_LENGTH    'l'        /* nCol values */\n#define FTS3_MATCHINFO_LCS       's'        /* nCol values */\n#define FTS3_MATCHINFO_HITS      'x'        /* 3*nCol*nPhrase values */\n\n/*\n** The default value for the second argument to matchinfo(). \n*/\n#define FTS3_MATCHINFO_DEFAULT   \"pcx\"\n\n\n/*\n** Used as an fts3ExprIterate() context when loading phrase doclists to\n** Fts3Expr.aDoclist[]/nDoclist.\n*/\ntypedef struct LoadDoclistCtx LoadDoclistCtx;\nstruct LoadDoclistCtx {\n  Fts3Cursor *pCsr;               /* FTS3 Cursor */\n  int nPhrase;                    /* Number of phrases seen so far */\n  int nToken;                     /* Number of tokens seen so far */\n};\n\n/*\n** The following types are used as part of the implementation of the \n** fts3BestSnippet() routine.\n*/\ntypedef struct SnippetIter SnippetIter;\ntypedef struct SnippetPhrase SnippetPhrase;\ntypedef struct SnippetFragment SnippetFragment;\n\nstruct SnippetIter {\n  Fts3Cursor *pCsr;               /* Cursor snippet is being generated from */\n  int iCol;                       /* Extract snippet from this column */\n  int nSnippet;                   /* Requested snippet length (in tokens) */\n  int nPhrase;                    /* Number of phrases in query */\n  SnippetPhrase *aPhrase;         /* Array of size nPhrase */\n  int iCurrent;                   /* First token of current snippet */\n};\n\nstruct SnippetPhrase {\n  int nToken;                     /* Number of tokens in phrase */\n  char *pList;                    /* Pointer to start of phrase position list */\n  int iHead;                      /* Next value in position list */\n  char *pHead;                    /* Position list data following iHead */\n  int iTail;                      /* Next value in trailing position list */\n  char *pTail;                    /* Position list data following iTail */\n};\n\nstruct SnippetFragment {\n  int iCol;                       /* Column snippet is extracted from */\n  int iPos;                       /* Index of first token in snippet */\n  u64 covered;                    /* Mask of query phrases covered */\n  u64 hlmask;                     /* Mask of snippet terms to highlight */\n};\n\n/*\n** This type is used as an fts3ExprIterate() context object while \n** accumulating the data returned by the matchinfo() function.\n*/\ntypedef struct MatchInfo MatchInfo;\nstruct MatchInfo {\n  Fts3Cursor *pCursor;            /* FTS3 Cursor */\n  int nCol;                       /* Number of columns in table */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  sqlite3_int64 nDoc;             /* Number of docs in database */\n  u32 *aMatchinfo;                /* Pre-allocated buffer */\n};\n\n\n\n/*\n** The snippet() and offsets() functions both return text values. An instance\n** of the following structure is used to accumulate those values while the\n** functions are running. See fts3StringAppend() for details.\n*/\ntypedef struct StrBuffer StrBuffer;\nstruct StrBuffer {\n  char *z;                        /* Pointer to buffer containing string */\n  int n;                          /* Length of z in bytes (excl. nul-term) */\n  int nAlloc;                     /* Allocated size of buffer z in bytes */\n};\n\n\n/*\n** This function is used to help iterate through a position-list. A position\n** list is a list of unique integers, sorted from smallest to largest. Each\n** element of the list is represented by an FTS3 varint that takes the value\n** of the difference between the current element and the previous one plus\n** two. For example, to store the position-list:\n**\n**     4 9 113\n**\n** the three varints:\n**\n**     6 7 106\n**\n** are encoded.\n**\n** When this function is called, *pp points to the start of an element of\n** the list. *piPos contains the value of the previous entry in the list.\n** After it returns, *piPos contains the value of the next element of the\n** list and *pp is advanced to the following varint.\n*/\nstatic void fts3GetDeltaPosition(char **pp, int *piPos){\n  int iVal;\n  *pp += sqlite3Fts3GetVarint32(*pp, &iVal);\n  *piPos += (iVal-2);\n}\n\n/*\n** Helper function for fts3ExprIterate() (see below).\n*/\nstatic int fts3ExprIterate2(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int *piPhrase,                  /* Pointer to phrase counter */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int rc;                         /* Return code */\n  int eType = pExpr->eType;       /* Type of expression node pExpr */\n\n  if( eType!=FTSQUERY_PHRASE ){\n    assert( pExpr->pLeft && pExpr->pRight );\n    rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);\n    if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){\n      rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);\n    }\n  }else{\n    rc = x(pExpr, *piPhrase, pCtx);\n    (*piPhrase)++;\n  }\n  return rc;\n}\n\n/*\n** Iterate through all phrase nodes in an FTS3 query, except those that\n** are part of a sub-tree that is the right-hand-side of a NOT operator.\n** For each phrase node found, the supplied callback function is invoked.\n**\n** If the callback function returns anything other than SQLITE_OK, \n** the iteration is abandoned and the error code returned immediately.\n** Otherwise, SQLITE_OK is returned after a callback has been made for\n** all eligible phrase nodes.\n*/\nstatic int fts3ExprIterate(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int iPhrase = 0;                /* Variable used as the phrase counter */\n  return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);\n}\n\n/*\n** This is an fts3ExprIterate() callback used while loading the doclists\n** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also\n** fts3ExprLoadDoclists().\n*/\nstatic int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  int rc = SQLITE_OK;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;\n\n  UNUSED_PARAMETER(iPhrase);\n\n  p->nPhrase++;\n  p->nToken += pPhrase->nToken;\n\n  return rc;\n}\n\n/*\n** Load the doclists for each phrase in the query associated with FTS3 cursor\n** pCsr. \n**\n** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable \n** phrases in the expression (all phrases except those directly or \n** indirectly descended from the right-hand-side of a NOT operator). If \n** pnToken is not NULL, then it is set to the number of tokens in all\n** matchable phrases of the expression.\n*/\nstatic int fts3ExprLoadDoclists(\n  Fts3Cursor *pCsr,               /* Fts3 cursor for current query */\n  int *pnPhrase,                  /* OUT: Number of phrases in query */\n  int *pnToken                    /* OUT: Number of tokens in query */\n){\n  int rc;                         /* Return Code */\n  LoadDoclistCtx sCtx = {0,0,0};  /* Context for fts3ExprIterate() */\n  sCtx.pCsr = pCsr;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);\n  if( pnPhrase ) *pnPhrase = sCtx.nPhrase;\n  if( pnToken ) *pnToken = sCtx.nToken;\n  return rc;\n}\n\nstatic int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  (*(int *)ctx)++;\n  UNUSED_PARAMETER(pExpr);\n  UNUSED_PARAMETER(iPhrase);\n  return SQLITE_OK;\n}\nstatic int fts3ExprPhraseCount(Fts3Expr *pExpr){\n  int nPhrase = 0;\n  (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);\n  return nPhrase;\n}\n\n/*\n** Advance the position list iterator specified by the first two \n** arguments so that it points to the first element with a value greater\n** than or equal to parameter iNext.\n*/\nstatic void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){\n  char *pIter = *ppIter;\n  if( pIter ){\n    int iIter = *piIter;\n\n    while( iIter<iNext ){\n      if( 0==(*pIter & 0xFE) ){\n        iIter = -1;\n        pIter = 0;\n        break;\n      }\n      fts3GetDeltaPosition(&pIter, &iIter);\n    }\n\n    *piIter = iIter;\n    *ppIter = pIter;\n  }\n}\n\n/*\n** Advance the snippet iterator to the next candidate snippet.\n*/\nstatic int fts3SnippetNextCandidate(SnippetIter *pIter){\n  int i;                          /* Loop counter */\n\n  if( pIter->iCurrent<0 ){\n    /* The SnippetIter object has just been initialized. The first snippet\n    ** candidate always starts at offset 0 (even if this candidate has a\n    ** score of 0.0).\n    */\n    pIter->iCurrent = 0;\n\n    /* Advance the 'head' iterator of each phrase to the first offset that\n    ** is greater than or equal to (iNext+nSnippet).\n    */\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, pIter->nSnippet);\n    }\n  }else{\n    int iStart;\n    int iEnd = 0x7FFFFFFF;\n\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      if( pPhrase->pHead && pPhrase->iHead<iEnd ){\n        iEnd = pPhrase->iHead;\n      }\n    }\n    if( iEnd==0x7FFFFFFF ){\n      return 1;\n    }\n\n    pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);\n      fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Retrieve information about the current candidate snippet of snippet \n** iterator pIter.\n*/\nstatic void fts3SnippetDetails(\n  SnippetIter *pIter,             /* Snippet iterator */\n  u64 mCovered,                   /* Bitmask of phrases already covered */\n  int *piToken,                   /* OUT: First token of proposed snippet */\n  int *piScore,                   /* OUT: \"Score\" for this snippet */\n  u64 *pmCover,                   /* OUT: Bitmask of phrases covered */\n  u64 *pmHighlight                /* OUT: Bitmask of terms to highlight */\n){\n  int iStart = pIter->iCurrent;   /* First token of snippet */\n  int iScore = 0;                 /* Score of this snippet */\n  int i;                          /* Loop counter */\n  u64 mCover = 0;                 /* Mask of phrases covered by this snippet */\n  u64 mHighlight = 0;             /* Mask of tokens to highlight in snippet */\n\n  for(i=0; i<pIter->nPhrase; i++){\n    SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n    if( pPhrase->pTail ){\n      char *pCsr = pPhrase->pTail;\n      int iCsr = pPhrase->iTail;\n\n      while( iCsr<(iStart+pIter->nSnippet) ){\n        int j;\n        u64 mPhrase = (u64)1 << i;\n        u64 mPos = (u64)1 << (iCsr - iStart);\n        assert( iCsr>=iStart );\n        if( (mCover|mCovered)&mPhrase ){\n          iScore++;\n        }else{\n          iScore += 1000;\n        }\n        mCover |= mPhrase;\n\n        for(j=0; j<pPhrase->nToken; j++){\n          mHighlight |= (mPos>>j);\n        }\n\n        if( 0==(*pCsr & 0x0FE) ) break;\n        fts3GetDeltaPosition(&pCsr, &iCsr);\n      }\n    }\n  }\n\n  /* Set the output variables before returning. */\n  *piToken = iStart;\n  *piScore = iScore;\n  *pmCover = mCover;\n  *pmHighlight = mHighlight;\n}\n\n/*\n** This function is an fts3ExprIterate() callback used by fts3BestSnippet().\n** Each invocation populates an element of the SnippetIter.aPhrase[] array.\n*/\nstatic int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  SnippetIter *p = (SnippetIter *)ctx;\n  SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];\n  char *pCsr;\n  int rc;\n\n  pPhrase->nToken = pExpr->pPhrase->nToken;\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( pCsr ){\n    int iFirst = 0;\n    pPhrase->pList = pCsr;\n    fts3GetDeltaPosition(&pCsr, &iFirst);\n    assert( iFirst>=0 );\n    pPhrase->pHead = pCsr;\n    pPhrase->pTail = pCsr;\n    pPhrase->iHead = iFirst;\n    pPhrase->iTail = iFirst;\n  }else{\n    assert( rc!=SQLITE_OK || (\n       pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 \n    ));\n  }\n\n  return rc;\n}\n\n/*\n** Select the fragment of text consisting of nFragment contiguous tokens \n** from column iCol that represent the \"best\" snippet. The best snippet\n** is the snippet with the highest score, where scores are calculated\n** by adding:\n**\n**   (a) +1 point for each occurrence of a matchable phrase in the snippet.\n**\n**   (b) +1000 points for the first occurrence of each matchable phrase in \n**       the snippet for which the corresponding mCovered bit is not set.\n**\n** The selected snippet parameters are stored in structure *pFragment before\n** returning. The score of the selected snippet is stored in *piScore\n** before returning.\n*/\nstatic int fts3BestSnippet(\n  int nSnippet,                   /* Desired snippet length */\n  Fts3Cursor *pCsr,               /* Cursor to create snippet for */\n  int iCol,                       /* Index of column to create snippet from */\n  u64 mCovered,                   /* Mask of phrases already covered */\n  u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */\n  SnippetFragment *pFragment,     /* OUT: Best snippet found */\n  int *piScore                    /* OUT: Score of snippet pFragment */\n){\n  int rc;                         /* Return Code */\n  int nList;                      /* Number of phrases in expression */\n  SnippetIter sIter;              /* Iterates through snippet candidates */\n  int nByte;                      /* Number of bytes of space to allocate */\n  int iBestScore = -1;            /* Best snippet score found so far */\n  int i;                          /* Loop counter */\n\n  memset(&sIter, 0, sizeof(sIter));\n\n  /* Iterate through the phrases in the expression to count them. The same\n  ** callback makes sure the doclists are loaded for each phrase.\n  */\n  rc = fts3ExprLoadDoclists(pCsr, &nList, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Now that it is known how many phrases there are, allocate and zero\n  ** the required space using malloc().\n  */\n  nByte = sizeof(SnippetPhrase) * nList;\n  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);\n  if( !sIter.aPhrase ){\n    return SQLITE_NOMEM;\n  }\n  memset(sIter.aPhrase, 0, nByte);\n\n  /* Initialize the contents of the SnippetIter object. Then iterate through\n  ** the set of phrases in the expression to populate the aPhrase[] array.\n  */\n  sIter.pCsr = pCsr;\n  sIter.iCol = iCol;\n  sIter.nSnippet = nSnippet;\n  sIter.nPhrase = nList;\n  sIter.iCurrent = -1;\n  (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter);\n\n  /* Set the *pmSeen output variable. */\n  for(i=0; i<nList; i++){\n    if( sIter.aPhrase[i].pHead ){\n      *pmSeen |= (u64)1 << i;\n    }\n  }\n\n  /* Loop through all candidate snippets. Store the best snippet in \n  ** *pFragment. Store its associated 'score' in iBestScore.\n  */\n  pFragment->iCol = iCol;\n  while( !fts3SnippetNextCandidate(&sIter) ){\n    int iPos;\n    int iScore;\n    u64 mCover;\n    u64 mHighlight;\n    fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover, &mHighlight);\n    assert( iScore>=0 );\n    if( iScore>iBestScore ){\n      pFragment->iPos = iPos;\n      pFragment->hlmask = mHighlight;\n      pFragment->covered = mCover;\n      iBestScore = iScore;\n    }\n  }\n\n  sqlite3_free(sIter.aPhrase);\n  *piScore = iBestScore;\n  return SQLITE_OK;\n}\n\n\n/*\n** Append a string to the string-buffer passed as the first argument.\n**\n** If nAppend is negative, then the length of the string zAppend is\n** determined using strlen().\n*/\nstatic int fts3StringAppend(\n  StrBuffer *pStr,                /* Buffer to append to */\n  const char *zAppend,            /* Pointer to data to append to buffer */\n  int nAppend                     /* Size of zAppend in bytes (or -1) */\n){\n  if( nAppend<0 ){\n    nAppend = (int)strlen(zAppend);\n  }\n\n  /* If there is insufficient space allocated at StrBuffer.z, use realloc()\n  ** to grow the buffer until so that it is big enough to accomadate the\n  ** appended data.\n  */\n  if( pStr->n+nAppend+1>=pStr->nAlloc ){\n    int nAlloc = pStr->nAlloc+nAppend+100;\n    char *zNew = sqlite3_realloc(pStr->z, nAlloc);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pStr->z = zNew;\n    pStr->nAlloc = nAlloc;\n  }\n\n  /* Append the data to the string buffer. */\n  memcpy(&pStr->z[pStr->n], zAppend, nAppend);\n  pStr->n += nAppend;\n  pStr->z[pStr->n] = '\\0';\n\n  return SQLITE_OK;\n}\n\n/*\n** The fts3BestSnippet() function often selects snippets that end with a\n** query term. That is, the final term of the snippet is always a term\n** that requires highlighting. For example, if 'X' is a highlighted term\n** and '.' is a non-highlighted term, BestSnippet() may select:\n**\n**     ........X.....X\n**\n** This function \"shifts\" the beginning of the snippet forward in the \n** document so that there are approximately the same number of \n** non-highlighted terms to the right of the final highlighted term as there\n** are to the left of the first highlighted term. For example, to this:\n**\n**     ....X.....X....\n**\n** This is done as part of extracting the snippet text, not when selecting\n** the snippet. Snippet selection is done based on doclists only, so there\n** is no way for fts3BestSnippet() to know whether or not the document \n** actually contains terms that follow the final highlighted term. \n*/\nstatic int fts3SnippetShift(\n  Fts3Table *pTab,                /* FTS3 table snippet comes from */\n  int iLangid,                    /* Language id to use in tokenizing */\n  int nSnippet,                   /* Number of tokens desired for snippet */\n  const char *zDoc,               /* Document text to extract snippet from */\n  int nDoc,                       /* Size of buffer zDoc in bytes */\n  int *piPos,                     /* IN/OUT: First token of snippet */\n  u64 *pHlmask                    /* IN/OUT: Mask of tokens to highlight */\n){\n  u64 hlmask = *pHlmask;          /* Local copy of initial highlight-mask */\n\n  if( hlmask ){\n    int nLeft;                    /* Tokens to the left of first highlight */\n    int nRight;                   /* Tokens to the right of last highlight */\n    int nDesired;                 /* Ideal number of tokens to shift forward */\n\n    for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);\n    for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);\n    nDesired = (nLeft-nRight)/2;\n\n    /* Ideally, the start of the snippet should be pushed forward in the\n    ** document nDesired tokens. This block checks if there are actually\n    ** nDesired tokens to the right of the snippet. If so, *piPos and\n    ** *pHlMask are updated to shift the snippet nDesired tokens to the\n    ** right. Otherwise, the snippet is shifted by the number of tokens\n    ** available.\n    */\n    if( nDesired>0 ){\n      int nShift;                 /* Number of tokens to shift snippet by */\n      int iCurrent = 0;           /* Token counter */\n      int rc;                     /* Return Code */\n      sqlite3_tokenizer_module *pMod;\n      sqlite3_tokenizer_cursor *pC;\n      pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n\n      /* Open a cursor on zDoc/nDoc. Check if there are (nSnippet+nDesired)\n      ** or more tokens in zDoc/nDoc.\n      */\n      rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){\n        const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;\n        rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);\n      }\n      pMod->xClose(pC);\n      if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }\n\n      nShift = (rc==SQLITE_DONE)+iCurrent-nSnippet;\n      assert( nShift<=nDesired );\n      if( nShift>0 ){\n        *piPos += nShift;\n        *pHlmask = hlmask >> nShift;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Extract the snippet text for fragment pFragment from cursor pCsr and\n** append it to string buffer pOut.\n*/\nstatic int fts3SnippetText(\n  Fts3Cursor *pCsr,               /* FTS3 Cursor */\n  SnippetFragment *pFragment,     /* Snippet to extract */\n  int iFragment,                  /* Fragment number */\n  int isLast,                     /* True for final fragment in snippet */\n  int nSnippet,                   /* Number of tokens in extracted snippet */\n  const char *zOpen,              /* String inserted before highlighted term */\n  const char *zClose,             /* String inserted after highlighted term */\n  const char *zEllipsis,          /* String inserted between snippets */\n  StrBuffer *pOut                 /* Write output here */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc;                         /* Return code */\n  const char *zDoc;               /* Document text to extract snippet from */\n  int nDoc;                       /* Size of zDoc in bytes */\n  int iCurrent = 0;               /* Current token number of document */\n  int iEnd = 0;                   /* Byte offset of end of current token */\n  int isShiftDone = 0;            /* True after snippet is shifted */\n  int iPos = pFragment->iPos;     /* First token of snippet */\n  u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */\n  int iCol = pFragment->iCol+1;   /* Query column to extract text from */\n  sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */\n  sqlite3_tokenizer_cursor *pC;   /* Tokenizer cursor open on zDoc/nDoc */\n  \n  zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);\n  if( zDoc==0 ){\n    if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n    return SQLITE_OK;\n  }\n  nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol);\n\n  /* Open a token cursor on the document. */\n  pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n  rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid, zDoc,nDoc,&pC);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  while( rc==SQLITE_OK ){\n    const char *ZDUMMY;           /* Dummy argument used with tokenizer */\n    int DUMMY1 = -1;              /* Dummy argument used with tokenizer */\n    int iBegin = 0;               /* Offset in zDoc of start of token */\n    int iFin = 0;                 /* Offset in zDoc of end of token */\n    int isHighlight = 0;          /* True for highlighted terms */\n\n    /* Variable DUMMY1 is initialized to a negative value above. Elsewhere\n    ** in the FTS code the variable that the third argument to xNext points to\n    ** is initialized to zero before the first (*but not necessarily\n    ** subsequent*) call to xNext(). This is done for a particular application\n    ** that needs to know whether or not the tokenizer is being used for\n    ** snippet generation or for some other purpose.\n    **\n    ** Extreme care is required when writing code to depend on this\n    ** initialization. It is not a documented part of the tokenizer interface.\n    ** If a tokenizer is used directly by any code outside of FTS, this\n    ** convention might not be respected.  */\n    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);\n    if( rc!=SQLITE_OK ){\n      if( rc==SQLITE_DONE ){\n        /* Special case - the last token of the snippet is also the last token\n        ** of the column. Append any punctuation that occurred between the end\n        ** of the previous token and the end of the document to the output. \n        ** Then break out of the loop. */\n        rc = fts3StringAppend(pOut, &zDoc[iEnd], -1);\n      }\n      break;\n    }\n    if( iCurrent<iPos ){ continue; }\n\n    if( !isShiftDone ){\n      int n = nDoc - iBegin;\n      rc = fts3SnippetShift(\n          pTab, pCsr->iLangid, nSnippet, &zDoc[iBegin], n, &iPos, &hlmask\n      );\n      isShiftDone = 1;\n\n      /* Now that the shift has been done, check if the initial \"...\" are\n      ** required. They are required if (a) this is not the first fragment,\n      ** or (b) this fragment does not begin at position 0 of its column. \n      */\n      if( rc==SQLITE_OK && (iPos>0 || iFragment>0) ){\n        rc = fts3StringAppend(pOut, zEllipsis, -1);\n      }\n      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;\n    }\n\n    if( iCurrent>=(iPos+nSnippet) ){\n      if( isLast ){\n        rc = fts3StringAppend(pOut, zEllipsis, -1);\n      }\n      break;\n    }\n\n    /* Set isHighlight to true if this term should be highlighted. */\n    isHighlight = (hlmask & ((u64)1 << (iCurrent-iPos)))!=0;\n\n    if( iCurrent>iPos ) rc = fts3StringAppend(pOut, &zDoc[iEnd], iBegin-iEnd);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zOpen, -1);\n    if( rc==SQLITE_OK ) rc = fts3StringAppend(pOut, &zDoc[iBegin], iFin-iBegin);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zClose, -1);\n\n    iEnd = iFin;\n  }\n\n  pMod->xClose(pC);\n  return rc;\n}\n\n\n/*\n** This function is used to count the entries in a column-list (a \n** delta-encoded list of term offsets within a single column of a single \n** row). When this function is called, *ppCollist should point to the\n** beginning of the first varint in the column-list (the varint that\n** contains the position of the first matching term in the column data).\n** Before returning, *ppCollist is set to point to the first byte after\n** the last varint in the column-list (either the 0x00 signifying the end\n** of the position-list, or the 0x01 that precedes the column number of\n** the next column in the position-list).\n**\n** The number of elements in the column-list is returned.\n*/\nstatic int fts3ColumnlistCount(char **ppCollist){\n  char *pEnd = *ppCollist;\n  char c = 0;\n  int nEntry = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00. */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    if( !c ) nEntry++;\n  }\n\n  *ppCollist = pEnd;\n  return nEntry;\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"global\" matchinfo stats\n** for a single query. \n**\n** fts3ExprIterate() callback to load the 'global' elements of a\n** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements \n** of the matchinfo array that are constant for all rows returned by the \n** current query.\n**\n** Argument pCtx is actually a pointer to a struct of type MatchInfo. This\n** function populates Matchinfo.aMatchinfo[] as follows:\n**\n**   for(iCol=0; iCol<nCol; iCol++){\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 1] = X;\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 2] = Y;\n**   }\n**\n** where X is the number of matches for phrase iPhrase is column iCol of all\n** rows of the table. Y is the number of rows for which column iCol contains\n** at least one instance of phrase iPhrase.\n**\n** If the phrase pExpr consists entirely of deferred tokens, then all X and\n** Y values are set to nDoc, where nDoc is the number of documents in the \n** file system. This is done because the full-text index doclist is required\n** to calculate these values properly, and the full-text index doclist is\n** not available for deferred tokens.\n*/\nstatic int fts3ExprGlobalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  MatchInfo *p = (MatchInfo *)pCtx;\n  return sqlite3Fts3EvalPhraseStats(\n      p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]\n  );\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"local\" part of the\n** FTS3_MATCHINFO_HITS array. The local stats are those elements of the \n** array that are different for each row returned by the query.\n*/\nstatic int fts3ExprLocalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  int rc = SQLITE_OK;\n  MatchInfo *p = (MatchInfo *)pCtx;\n  int iStart = iPhrase * p->nCol * 3;\n  int i;\n\n  for(i=0; i<p->nCol && rc==SQLITE_OK; i++){\n    char *pCsr;\n    rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);\n    if( pCsr ){\n      p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);\n    }else{\n      p->aMatchinfo[iStart+i*3] = 0;\n    }\n  }\n\n  return rc;\n}\n\nstatic int fts3MatchinfoCheck(\n  Fts3Table *pTab, \n  char cArg,\n  char **pzErr\n){\n  if( (cArg==FTS3_MATCHINFO_NPHRASE)\n   || (cArg==FTS3_MATCHINFO_NCOL)\n   || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)\n   || (cArg==FTS3_MATCHINFO_LCS)\n   || (cArg==FTS3_MATCHINFO_HITS)\n  ){\n    return SQLITE_OK;\n  }\n  *pzErr = sqlite3_mprintf(\"unrecognized matchinfo request: %c\", cArg);\n  return SQLITE_ERROR;\n}\n\nstatic int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){\n  int nVal;                       /* Number of integers output by cArg */\n\n  switch( cArg ){\n    case FTS3_MATCHINFO_NDOC:\n    case FTS3_MATCHINFO_NPHRASE: \n    case FTS3_MATCHINFO_NCOL: \n      nVal = 1;\n      break;\n\n    case FTS3_MATCHINFO_AVGLENGTH:\n    case FTS3_MATCHINFO_LENGTH:\n    case FTS3_MATCHINFO_LCS:\n      nVal = pInfo->nCol;\n      break;\n\n    default:\n      assert( cArg==FTS3_MATCHINFO_HITS );\n      nVal = pInfo->nCol * pInfo->nPhrase * 3;\n      break;\n  }\n\n  return nVal;\n}\n\nstatic int fts3MatchinfoSelectDoctotal(\n  Fts3Table *pTab,\n  sqlite3_stmt **ppStmt,\n  sqlite3_int64 *pnDoc,\n  const char **paLen\n){\n  sqlite3_stmt *pStmt;\n  const char *a;\n  sqlite3_int64 nDoc;\n\n  if( !*ppStmt ){\n    int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  pStmt = *ppStmt;\n  assert( sqlite3_data_count(pStmt)==1 );\n\n  a = sqlite3_column_blob(pStmt, 0);\n  a += sqlite3Fts3GetVarint(a, &nDoc);\n  if( nDoc==0 ) return FTS_CORRUPT_VTAB;\n  *pnDoc = (u32)nDoc;\n\n  if( paLen ) *paLen = a;\n  return SQLITE_OK;\n}\n\n/*\n** An instance of the following structure is used to store state while \n** iterating through a multi-column position-list corresponding to the\n** hits for a single phrase on a single row in order to calculate the\n** values for a matchinfo() FTS3_MATCHINFO_LCS request.\n*/\ntypedef struct LcsIterator LcsIterator;\nstruct LcsIterator {\n  Fts3Expr *pExpr;                /* Pointer to phrase expression */\n  int iPosOffset;                 /* Tokens count up to end of this phrase */\n  char *pRead;                    /* Cursor used to iterate through aDoclist */\n  int iPos;                       /* Current position */\n};\n\n/* \n** If LcsIterator.iCol is set to the following value, the iterator has\n** finished iterating through all offsets for all columns.\n*/\n#define LCS_ITERATOR_FINISHED 0x7FFFFFFF;\n\nstatic int fts3MatchinfoLcsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  LcsIterator *aIter = (LcsIterator *)pCtx;\n  aIter[iPhrase].pExpr = pExpr;\n  return SQLITE_OK;\n}\n\n/*\n** Advance the iterator passed as an argument to the next position. Return\n** 1 if the iterator is at EOF or if it now points to the start of the\n** position list for the next column.\n*/\nstatic int fts3LcsIteratorAdvance(LcsIterator *pIter){\n  char *pRead = pIter->pRead;\n  sqlite3_int64 iRead;\n  int rc = 0;\n\n  pRead += sqlite3Fts3GetVarint(pRead, &iRead);\n  if( iRead==0 || iRead==1 ){\n    pRead = 0;\n    rc = 1;\n  }else{\n    pIter->iPos += (int)(iRead-2);\n  }\n\n  pIter->pRead = pRead;\n  return rc;\n}\n  \n/*\n** This function implements the FTS3_MATCHINFO_LCS matchinfo() flag. \n**\n** If the call is successful, the longest-common-substring lengths for each\n** column are written into the first nCol elements of the pInfo->aMatchinfo[] \n** array before returning. SQLITE_OK is returned in this case.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and the\n** data written to the first nCol elements of pInfo->aMatchinfo[] is \n** undefined.\n*/\nstatic int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){\n  LcsIterator *aIter;\n  int i;\n  int iCol;\n  int nToken = 0;\n\n  /* Allocate and populate the array of LcsIterator objects. The array\n  ** contains one element for each matchable phrase in the query.\n  **/\n  aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);\n  if( !aIter ) return SQLITE_NOMEM;\n  memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);\n  (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);\n\n  for(i=0; i<pInfo->nPhrase; i++){\n    LcsIterator *pIter = &aIter[i];\n    nToken -= pIter->pExpr->pPhrase->nToken;\n    pIter->iPosOffset = nToken;\n  }\n\n  for(iCol=0; iCol<pInfo->nCol; iCol++){\n    int nLcs = 0;                 /* LCS value for this column */\n    int nLive = 0;                /* Number of iterators in aIter not at EOF */\n\n    for(i=0; i<pInfo->nPhrase; i++){\n      int rc;\n      LcsIterator *pIt = &aIter[i];\n      rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);\n      if( rc!=SQLITE_OK ) return rc;\n      if( pIt->pRead ){\n        pIt->iPos = pIt->iPosOffset;\n        fts3LcsIteratorAdvance(&aIter[i]);\n        nLive++;\n      }\n    }\n\n    while( nLive>0 ){\n      LcsIterator *pAdv = 0;      /* The iterator to advance by one position */\n      int nThisLcs = 0;           /* LCS for the current iterator positions */\n\n      for(i=0; i<pInfo->nPhrase; i++){\n        LcsIterator *pIter = &aIter[i];\n        if( pIter->pRead==0 ){\n          /* This iterator is already at EOF for this column. */\n          nThisLcs = 0;\n        }else{\n          if( pAdv==0 || pIter->iPos<pAdv->iPos ){\n            pAdv = pIter;\n          }\n          if( nThisLcs==0 || pIter->iPos==pIter[-1].iPos ){\n            nThisLcs++;\n          }else{\n            nThisLcs = 1;\n          }\n          if( nThisLcs>nLcs ) nLcs = nThisLcs;\n        }\n      }\n      if( fts3LcsIteratorAdvance(pAdv) ) nLive--;\n    }\n\n    pInfo->aMatchinfo[iCol] = nLcs;\n  }\n\n  sqlite3_free(aIter);\n  return SQLITE_OK;\n}\n\n/*\n** Populate the buffer pInfo->aMatchinfo[] with an array of integers to\n** be returned by the matchinfo() function. Argument zArg contains the \n** format string passed as the second argument to matchinfo (or the\n** default value \"pcx\" if no second argument was specified). The format\n** string has already been validated and the pInfo->aMatchinfo[] array\n** is guaranteed to be large enough for the output.\n**\n** If bGlobal is true, then populate all fields of the matchinfo() output.\n** If it is false, then assume that those fields that do not change between\n** rows (i.e. FTS3_MATCHINFO_NPHRASE, NCOL, NDOC, AVGLENGTH and part of HITS)\n** have already been populated.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error \n** occurs. If a value other than SQLITE_OK is returned, the state the\n** pInfo->aMatchinfo[] buffer is left in is undefined.\n*/\nstatic int fts3MatchinfoValues(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  int bGlobal,                    /* True to grab the global stats */\n  MatchInfo *pInfo,               /* Matchinfo context object */\n  const char *zArg                /* Matchinfo format string */\n){\n  int rc = SQLITE_OK;\n  int i;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_stmt *pSelect = 0;\n\n  for(i=0; rc==SQLITE_OK && zArg[i]; i++){\n\n    switch( zArg[i] ){\n      case FTS3_MATCHINFO_NPHRASE:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nPhrase;\n        break;\n\n      case FTS3_MATCHINFO_NCOL:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;\n        break;\n        \n      case FTS3_MATCHINFO_NDOC:\n        if( bGlobal ){\n          sqlite3_int64 nDoc = 0;\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);\n          pInfo->aMatchinfo[0] = (u32)nDoc;\n        }\n        break;\n\n      case FTS3_MATCHINFO_AVGLENGTH: \n        if( bGlobal ){\n          sqlite3_int64 nDoc;     /* Number of rows in table */\n          const char *a;          /* Aggregate column length array */\n\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);\n          if( rc==SQLITE_OK ){\n            int iCol;\n            for(iCol=0; iCol<pInfo->nCol; iCol++){\n              u32 iVal;\n              sqlite3_int64 nToken;\n              a += sqlite3Fts3GetVarint(a, &nToken);\n              iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);\n              pInfo->aMatchinfo[iCol] = iVal;\n            }\n          }\n        }\n        break;\n\n      case FTS3_MATCHINFO_LENGTH: {\n        sqlite3_stmt *pSelectDocsize = 0;\n        rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);\n        if( rc==SQLITE_OK ){\n          int iCol;\n          const char *a = sqlite3_column_blob(pSelectDocsize, 0);\n          for(iCol=0; iCol<pInfo->nCol; iCol++){\n            sqlite3_int64 nToken;\n            a += sqlite3Fts3GetVarint(a, &nToken);\n            pInfo->aMatchinfo[iCol] = (u32)nToken;\n          }\n        }\n        sqlite3_reset(pSelectDocsize);\n        break;\n      }\n\n      case FTS3_MATCHINFO_LCS:\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc==SQLITE_OK ){\n          rc = fts3MatchinfoLcs(pCsr, pInfo);\n        }\n        break;\n\n      default: {\n        Fts3Expr *pExpr;\n        assert( zArg[i]==FTS3_MATCHINFO_HITS );\n        pExpr = pCsr->pExpr;\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( bGlobal ){\n          if( pCsr->pDeferred ){\n            rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);\n            if( rc!=SQLITE_OK ) break;\n          }\n          rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);\n          if( rc!=SQLITE_OK ) break;\n        }\n        (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);\n        break;\n      }\n    }\n\n    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);\n  }\n\n  sqlite3_reset(pSelect);\n  return rc;\n}\n\n\n/*\n** Populate pCsr->aMatchinfo[] with data for the current row. The \n** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).\n*/\nstatic int fts3GetMatchinfo(\n  Fts3Cursor *pCsr,               /* FTS3 Cursor object */\n  const char *zArg                /* Second argument to matchinfo() function */\n){\n  MatchInfo sInfo;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int bGlobal = 0;                /* Collect 'global' stats as well as local */\n\n  memset(&sInfo, 0, sizeof(MatchInfo));\n  sInfo.pCursor = pCsr;\n  sInfo.nCol = pTab->nColumn;\n\n  /* If there is cached matchinfo() data, but the format string for the \n  ** cache does not match the format string for this request, discard \n  ** the cached data. */\n  if( pCsr->zMatchinfo && strcmp(pCsr->zMatchinfo, zArg) ){\n    assert( pCsr->aMatchinfo );\n    sqlite3_free(pCsr->aMatchinfo);\n    pCsr->zMatchinfo = 0;\n    pCsr->aMatchinfo = 0;\n  }\n\n  /* If Fts3Cursor.aMatchinfo[] is NULL, then this is the first time the\n  ** matchinfo function has been called for this query. In this case \n  ** allocate the array used to accumulate the matchinfo data and\n  ** initialize those elements that are constant for every row.\n  */\n  if( pCsr->aMatchinfo==0 ){\n    int nMatchinfo = 0;           /* Number of u32 elements in match-info */\n    int nArg;                     /* Bytes in zArg */\n    int i;                        /* Used to iterate through zArg */\n\n    /* Determine the number of phrases in the query */\n    pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);\n    sInfo.nPhrase = pCsr->nPhrase;\n\n    /* Determine the number of integers in the buffer returned by this call. */\n    for(i=0; zArg[i]; i++){\n      nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);\n    }\n\n    /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */\n    nArg = (int)strlen(zArg);\n    pCsr->aMatchinfo = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo + nArg + 1);\n    if( !pCsr->aMatchinfo ) return SQLITE_NOMEM;\n\n    pCsr->zMatchinfo = (char *)&pCsr->aMatchinfo[nMatchinfo];\n    pCsr->nMatchinfo = nMatchinfo;\n    memcpy(pCsr->zMatchinfo, zArg, nArg+1);\n    memset(pCsr->aMatchinfo, 0, sizeof(u32)*nMatchinfo);\n    pCsr->isMatchinfoNeeded = 1;\n    bGlobal = 1;\n  }\n\n  sInfo.aMatchinfo = pCsr->aMatchinfo;\n  sInfo.nPhrase = pCsr->nPhrase;\n  if( pCsr->isMatchinfoNeeded ){\n    rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg);\n    pCsr->isMatchinfoNeeded = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of snippet() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Snippet(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr,               /* Cursor object */\n  const char *zStart,             /* Snippet start text - \"<b>\" */\n  const char *zEnd,               /* Snippet end text - \"</b>\" */\n  const char *zEllipsis,          /* Snippet ellipsis text - \"<b>...</b>\" */\n  int iCol,                       /* Extract snippet from this column */\n  int nToken                      /* Approximate number of tokens in snippet */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int i;\n  StrBuffer res = {0, 0, 0};\n\n  /* The returned text includes up to four fragments of text extracted from\n  ** the data in the current row. The first iteration of the for(...) loop\n  ** below attempts to locate a single fragment of text nToken tokens in \n  ** size that contains at least one instance of all phrases in the query\n  ** expression that appear in the current row. If such a fragment of text\n  ** cannot be found, the second iteration of the loop attempts to locate\n  ** a pair of fragments, and so on.\n  */\n  int nSnippet = 0;               /* Number of fragments in this snippet */\n  SnippetFragment aSnippet[4];    /* Maximum of 4 fragments per snippet */\n  int nFToken = -1;               /* Number of tokens in each fragment */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(nSnippet=1; 1; nSnippet++){\n\n    int iSnip;                    /* Loop counter 0..nSnippet-1 */\n    u64 mCovered = 0;             /* Bitmask of phrases covered by snippet */\n    u64 mSeen = 0;                /* Bitmask of phrases seen by BestSnippet() */\n\n    if( nToken>=0 ){\n      nFToken = (nToken+nSnippet-1) / nSnippet;\n    }else{\n      nFToken = -1 * nToken;\n    }\n\n    for(iSnip=0; iSnip<nSnippet; iSnip++){\n      int iBestScore = -1;        /* Best score of columns checked so far */\n      int iRead;                  /* Used to iterate through columns */\n      SnippetFragment *pFragment = &aSnippet[iSnip];\n\n      memset(pFragment, 0, sizeof(*pFragment));\n\n      /* Loop through all columns of the table being considered for snippets.\n      ** If the iCol argument to this function was negative, this means all\n      ** columns of the FTS3 table. Otherwise, only column iCol is considered.\n      */\n      for(iRead=0; iRead<pTab->nColumn; iRead++){\n        SnippetFragment sF = {0, 0, 0, 0};\n        int iS;\n        if( iCol>=0 && iRead!=iCol ) continue;\n\n        /* Find the best snippet of nFToken tokens in column iRead. */\n        rc = fts3BestSnippet(nFToken, pCsr, iRead, mCovered, &mSeen, &sF, &iS);\n        if( rc!=SQLITE_OK ){\n          goto snippet_out;\n        }\n        if( iS>iBestScore ){\n          *pFragment = sF;\n          iBestScore = iS;\n        }\n      }\n\n      mCovered |= pFragment->covered;\n    }\n\n    /* If all query phrases seen by fts3BestSnippet() are present in at least\n    ** one of the nSnippet snippet fragments, break out of the loop.\n    */\n    assert( (mCovered&mSeen)==mCovered );\n    if( mSeen==mCovered || nSnippet==SizeofArray(aSnippet) ) break;\n  }\n\n  assert( nFToken>0 );\n\n  for(i=0; i<nSnippet && rc==SQLITE_OK; i++){\n    rc = fts3SnippetText(pCsr, &aSnippet[i], \n        i, (i==nSnippet-1), nFToken, zStart, zEnd, zEllipsis, &res\n    );\n  }\n\n snippet_out:\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, -1, sqlite3_free);\n  }\n}\n\n\ntypedef struct TermOffset TermOffset;\ntypedef struct TermOffsetCtx TermOffsetCtx;\n\nstruct TermOffset {\n  char *pList;                    /* Position-list */\n  int iPos;                       /* Position just read from pList */\n  int iOff;                       /* Offset of this term from read positions */\n};\n\nstruct TermOffsetCtx {\n  Fts3Cursor *pCsr;\n  int iCol;                       /* Column of table to populate aTerm for */\n  int iTerm;\n  sqlite3_int64 iDocid;\n  TermOffset *aTerm;\n};\n\n/*\n** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().\n*/\nstatic int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  TermOffsetCtx *p = (TermOffsetCtx *)ctx;\n  int nTerm;                      /* Number of tokens in phrase */\n  int iTerm;                      /* For looping through nTerm phrase terms */\n  char *pList;                    /* Pointer to position list for phrase */\n  int iPos = 0;                   /* First position in position-list */\n  int rc;\n\n  UNUSED_PARAMETER(iPhrase);\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);\n  nTerm = pExpr->pPhrase->nToken;\n  if( pList ){\n    fts3GetDeltaPosition(&pList, &iPos);\n    assert( iPos>=0 );\n  }\n\n  for(iTerm=0; iTerm<nTerm; iTerm++){\n    TermOffset *pT = &p->aTerm[p->iTerm++];\n    pT->iOff = nTerm-iTerm-1;\n    pT->pList = pList;\n    pT->iPos = iPos;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of offsets() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Offsets(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr                /* Cursor object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;\n  int rc;                         /* Return Code */\n  int nToken;                     /* Number of tokens in query */\n  int iCol;                       /* Column currently being processed */\n  StrBuffer res = {0, 0, 0};      /* Result string */\n  TermOffsetCtx sCtx;             /* Context for fts3ExprTermOffsetInit() */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  memset(&sCtx, 0, sizeof(sCtx));\n  assert( pCsr->isRequireSeek==0 );\n\n  /* Count the number of terms in the query */\n  rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);\n  if( rc!=SQLITE_OK ) goto offsets_out;\n\n  /* Allocate the array of TermOffset iterators. */\n  sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);\n  if( 0==sCtx.aTerm ){\n    rc = SQLITE_NOMEM;\n    goto offsets_out;\n  }\n  sCtx.iDocid = pCsr->iPrevId;\n  sCtx.pCsr = pCsr;\n\n  /* Loop through the table columns, appending offset information to \n  ** string-buffer res for each column.\n  */\n  for(iCol=0; iCol<pTab->nColumn; iCol++){\n    sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */\n    const char *ZDUMMY;           /* Dummy argument used with xNext() */\n    int NDUMMY = 0;               /* Dummy argument used with xNext() */\n    int iStart = 0;\n    int iEnd = 0;\n    int iCurrent = 0;\n    const char *zDoc;\n    int nDoc;\n\n    /* Initialize the contents of sCtx.aTerm[] for column iCol. There is \n    ** no way that this operation can fail, so the return code from\n    ** fts3ExprIterate() can be discarded.\n    */\n    sCtx.iCol = iCol;\n    sCtx.iTerm = 0;\n    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void *)&sCtx);\n\n    /* Retreive the text stored in column iCol. If an SQL NULL is stored \n    ** in column iCol, jump immediately to the next iteration of the loop.\n    ** If an OOM occurs while retrieving the data (this can happen if SQLite\n    ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM \n    ** to the caller. \n    */\n    zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    if( zDoc==0 ){\n      if( sqlite3_column_type(pCsr->pStmt, iCol+1)==SQLITE_NULL ){\n        continue;\n      }\n      rc = SQLITE_NOMEM;\n      goto offsets_out;\n    }\n\n    /* Initialize a tokenizer iterator to iterate through column iCol. */\n    rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid,\n        zDoc, nDoc, &pC\n    );\n    if( rc!=SQLITE_OK ) goto offsets_out;\n\n    rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n    while( rc==SQLITE_OK ){\n      int i;                      /* Used to loop through terms */\n      int iMinPos = 0x7FFFFFFF;   /* Position of next token */\n      TermOffset *pTerm = 0;      /* TermOffset associated with next token */\n\n      for(i=0; i<nToken; i++){\n        TermOffset *pT = &sCtx.aTerm[i];\n        if( pT->pList && (pT->iPos-pT->iOff)<iMinPos ){\n          iMinPos = pT->iPos-pT->iOff;\n          pTerm = pT;\n        }\n      }\n\n      if( !pTerm ){\n        /* All offsets for this column have been gathered. */\n        rc = SQLITE_DONE;\n      }else{\n        assert( iCurrent<=iMinPos );\n        if( 0==(0xFE&*pTerm->pList) ){\n          pTerm->pList = 0;\n        }else{\n          fts3GetDeltaPosition(&pTerm->pList, &pTerm->iPos);\n        }\n        while( rc==SQLITE_OK && iCurrent<iMinPos ){\n          rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n        }\n        if( rc==SQLITE_OK ){\n          char aBuffer[64];\n          sqlite3_snprintf(sizeof(aBuffer), aBuffer, \n              \"%d %d %d %d \", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart\n          );\n          rc = fts3StringAppend(&res, aBuffer, -1);\n        }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){\n          rc = FTS_CORRUPT_VTAB;\n        }\n      }\n    }\n    if( rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pMod->xClose(pC);\n    if( rc!=SQLITE_OK ) goto offsets_out;\n  }\n\n offsets_out:\n  sqlite3_free(sCtx.aTerm);\n  assert( rc!=SQLITE_DONE );\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx,  rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, res.n-1, sqlite3_free);\n  }\n  return;\n}\n\n/*\n** Implementation of matchinfo() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(\n  sqlite3_context *pContext,      /* Function call context */\n  Fts3Cursor *pCsr,               /* FTS3 table cursor */\n  const char *zArg                /* Second arg to matchinfo() function */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc;\n  int i;\n  const char *zFormat;\n\n  if( zArg ){\n    for(i=0; zArg[i]; i++){\n      char *zErr = 0;\n      if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){\n        sqlite3_result_error(pContext, zErr, -1);\n        sqlite3_free(zErr);\n        return;\n      }\n    }\n    zFormat = zArg;\n  }else{\n    zFormat = FTS3_MATCHINFO_DEFAULT;\n  }\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_blob(pContext, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  /* Retrieve matchinfo() data. */\n  rc = fts3GetMatchinfo(pCsr, zFormat);\n  sqlite3Fts3SegmentsClose(pTab);\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pContext, rc);\n  }else{\n    int n = pCsr->nMatchinfo * sizeof(u32);\n    sqlite3_result_blob(pContext, pCsr->aMatchinfo, n, SQLITE_TRANSIENT);\n  }\n}\n\n#endif\n\n/************** End of fts3_snippet.c ****************************************/\n/************** Begin file fts3_unicode.c ************************************/\n/*\n** 2012 May 24\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"unicode\" full-text-search tokenizer.\n*/\n\n#ifdef SQLITE_ENABLE_FTS4_UNICODE61\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct unicode_tokenizer unicode_tokenizer;\ntypedef struct unicode_cursor unicode_cursor;\n\nstruct unicode_tokenizer {\n  sqlite3_tokenizer base;\n  int bRemoveDiacritic;\n  int nException;\n  int *aiException;\n};\n\nstruct unicode_cursor {\n  sqlite3_tokenizer_cursor base;\n  const unsigned char *aInput;    /* Input text being tokenized */\n  int nInput;                     /* Size of aInput[] in bytes */\n  int iOff;                       /* Current offset within aInput[] */\n  int iToken;                     /* Index of next token to be returned */\n  char *zToken;                   /* storage for current token */\n  int nAlloc;                     /* space allocated at zToken */\n};\n\n\n/*\n** Destroy a tokenizer allocated by unicodeCreate().\n*/\nstatic int unicodeDestroy(sqlite3_tokenizer *pTokenizer){\n  if( pTokenizer ){\n    unicode_tokenizer *p = (unicode_tokenizer *)pTokenizer;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE\n** statement has specified that the tokenizer for this table shall consider\n** all characters in string zIn/nIn to be separators (if bAlnum==0) or\n** token characters (if bAlnum==1).\n**\n** For each codepoint in the zIn/nIn string, this function checks if the\n** sqlite3FtsUnicodeIsalnum() function already returns the desired result.\n** If so, no action is taken. Otherwise, the codepoint is added to the \n** unicode_tokenizer.aiException[] array. For the purposes of tokenization,\n** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all\n** codepoints in the aiException[] array.\n**\n** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic()\n** identifies as a diacritic) occurs in the zIn/nIn string it is ignored.\n** It is not possible to change the behavior of the tokenizer with respect\n** to these codepoints.\n*/\nstatic int unicodeAddExceptions(\n  unicode_tokenizer *p,           /* Tokenizer to add exceptions to */\n  int bAlnum,                     /* Replace Isalnum() return value with this */\n  const char *zIn,                /* Array of characters to make exceptions */\n  int nIn                         /* Length of z in bytes */\n){\n  const unsigned char *z = (const unsigned char *)zIn;\n  const unsigned char *zTerm = &z[nIn];\n  int iCode;\n  int nEntry = 0;\n\n  assert( bAlnum==0 || bAlnum==1 );\n\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n    if( sqlite3FtsUnicodeIsalnum(iCode)!=bAlnum \n     && sqlite3FtsUnicodeIsdiacritic(iCode)==0 \n    ){\n      nEntry++;\n    }\n  }\n\n  if( nEntry ){\n    int *aNew;                    /* New aiException[] array */\n    int nNew;                     /* Number of valid entries in array aNew[] */\n\n    aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    nNew = p->nException;\n\n    z = (const unsigned char *)zIn;\n    while( z<zTerm ){\n      READ_UTF8(z, zTerm, iCode);\n      if( sqlite3FtsUnicodeIsalnum(iCode)!=bAlnum \n       && sqlite3FtsUnicodeIsdiacritic(iCode)==0\n      ){\n        int i, j;\n        for(i=0; i<nNew && aNew[i]<iCode; i++);\n        for(j=nNew; j>i; j--) aNew[j] = aNew[j-1];\n        aNew[i] = iCode;\n        nNew++;\n      }\n    }\n    p->aiException = aNew;\n    p->nException = nNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int unicodeIsException(unicode_tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Return true if, for the purposes of tokenization, codepoint iCode is\n** considered a token character (not a separator).\n*/\nstatic int unicodeIsAlnum(unicode_tokenizer *p, int iCode){\n  assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3FtsUnicodeIsalnum(iCode) ^ unicodeIsException(p, iCode);\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int unicodeCreate(\n  int nArg,                       /* Size of array argv[] */\n  const char * const *azArg,      /* Tokenizer creation arguments */\n  sqlite3_tokenizer **pp          /* OUT: New tokenizer handle */\n){\n  unicode_tokenizer *pNew;        /* New tokenizer object */\n  int i;\n  int rc = SQLITE_OK;\n\n  pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));\n  if( pNew==NULL ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(unicode_tokenizer));\n  pNew->bRemoveDiacritic = 1;\n\n  for(i=0; rc==SQLITE_OK && i<nArg; i++){\n    const char *z = azArg[i];\n    int n = strlen(z);\n\n    if( n==19 && memcmp(\"remove_diacritics=1\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 1;\n    }\n    else if( n==19 && memcmp(\"remove_diacritics=0\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 0;\n    }\n    else if( n>=11 && memcmp(\"tokenchars=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);\n    }\n    else if( n>=11 && memcmp(\"separators=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 0, &z[11], n-11);\n    }\n    else{\n      /* Unrecognized argument */\n      rc  = SQLITE_ERROR;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    unicodeDestroy((sqlite3_tokenizer *)pNew);\n    pNew = 0;\n  }\n  *pp = (sqlite3_tokenizer *)pNew;\n  return rc;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int unicodeOpen(\n  sqlite3_tokenizer *p,           /* The tokenizer */\n  const char *aInput,             /* Input string */\n  int nInput,                     /* Size of string aInput in bytes */\n  sqlite3_tokenizer_cursor **pp   /* OUT: New cursor object */\n){\n  unicode_cursor *pCsr;\n\n  pCsr = (unicode_cursor *)sqlite3_malloc(sizeof(unicode_cursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(unicode_cursor));\n\n  pCsr->aInput = (const unsigned char *)aInput;\n  if( aInput==0 ){\n    pCsr->nInput = 0;\n  }else if( nInput<0 ){\n    pCsr->nInput = (int)strlen(aInput);\n  }else{\n    pCsr->nInput = nInput;\n  }\n\n  *pp = &pCsr->base;\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int unicodeClose(sqlite3_tokenizer_cursor *pCursor){\n  unicode_cursor *pCsr = (unicode_cursor *) pCursor;\n  sqlite3_free(pCsr->zToken);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int unicodeNext(\n  sqlite3_tokenizer_cursor *pC,   /* Cursor returned by simpleOpen */\n  const char **paToken,           /* OUT: Token text */\n  int *pnToken,                   /* OUT: Number of bytes at *paToken */\n  int *piStart,                   /* OUT: Starting offset of token */\n  int *piEnd,                     /* OUT: Ending offset of token */\n  int *piPos                      /* OUT: Position integer of token */\n){\n  unicode_cursor *pCsr = (unicode_cursor *)pC;\n  unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer);\n  int iCode;\n  char *zOut;\n  const unsigned char *z = &pCsr->aInput[pCsr->iOff];\n  const unsigned char *zStart = z;\n  const unsigned char *zEnd;\n  const unsigned char *zTerm = &pCsr->aInput[pCsr->nInput];\n\n  /* Scan past any delimiter characters before the start of the next token.\n  ** Return SQLITE_DONE early if this takes us all the way to the end of \n  ** the input.  */\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    if( unicodeIsAlnum(p, iCode) ) break;\n    zStart = z;\n  }\n  if( zStart>=zTerm ) return SQLITE_DONE;\n\n  zOut = pCsr->zToken;\n  do {\n    int iOut;\n\n    /* Grow the output buffer if required. */\n    if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){\n      char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);\n      if( !zNew ) return SQLITE_NOMEM;\n      zOut = &zNew[zOut - pCsr->zToken];\n      pCsr->zToken = zNew;\n      pCsr->nAlloc += 64;\n    }\n\n    /* Write the folded case of the last character read to the output */\n    zEnd = z;\n    iOut = sqlite3FtsUnicodeFold(iCode, p->bRemoveDiacritic);\n    if( iOut ){\n      WRITE_UTF8(zOut, iOut);\n    }\n\n    /* If the cursor is not at EOF, read the next character */\n    if( z>=zTerm ) break;\n    READ_UTF8(z, zTerm, iCode);\n  }while( unicodeIsAlnum(p, iCode) \n       || sqlite3FtsUnicodeIsdiacritic(iCode)\n  );\n\n  /* Set the output variables and return. */\n  pCsr->iOff = (z - pCsr->aInput);\n  *paToken = pCsr->zToken;\n  *pnToken = zOut - pCsr->zToken;\n  *piStart = (zStart - pCsr->aInput);\n  *piEnd = (zEnd - pCsr->aInput);\n  *piPos = pCsr->iToken++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppModule to a pointer to the sqlite3_tokenizer_module \n** structure for the unicode tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const **ppModule){\n  static const sqlite3_tokenizer_module module = {\n    0,\n    unicodeCreate,\n    unicodeDestroy,\n    unicodeOpen,\n    unicodeClose,\n    unicodeNext,\n    0,\n  };\n  *ppModule = &module;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n#endif /* ifndef SQLITE_ENABLE_FTS4_UNICODE61 */\n\n/************** End of fts3_unicode.c ****************************************/\n/************** Begin file fts3_unicode2.c ***********************************/\n/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n#if defined(SQLITE_ENABLE_FTS4_UNICODE61)\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n\n/* #include <assert.h> */\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  const static unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC02, 0x03E3FC01, 0x03EC7801, 0x03ECA401, 0x03EEC810,\n    0x03F4F802, 0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023,\n    0x03F95013, 0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807,\n    0x03FCEC06, 0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405,\n    0x04040003, 0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E,\n    0x040E7C01, 0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01,\n    0x04280403, 0x04281402, 0x04283004, 0x0428E003, 0x0428FC01,\n    0x04294009, 0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016,\n    0x04420003, 0x0442C012, 0x04440003, 0x04449C0E, 0x04450004,\n    0x04460003, 0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004,\n    0x05BD442E, 0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5,\n    0x07480046, 0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01,\n    0x075C5401, 0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401,\n    0x075EA401, 0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064,\n    0x07C2800F, 0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F,\n    0x07C4C03C, 0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009,\n    0x07C94002, 0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014,\n    0x07CE8025, 0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001,\n    0x07D108B6, 0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018,\n    0x07D7EC46, 0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401,\n    0x38008060, 0x380400F0, 0x3C000001, 0x3FFFF401, 0x40000001,\n    0x43FFF401,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( c<128 ){\n    return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );\n  }else if( c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int remove_diacritic(int c){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3896,  3912,  3928, \n     3968,  4008,  4040,  4106,  4138,  4170,  4202,  4234, \n     4266,  4296,  4312,  4344,  4408,  4424,  4472,  4504, \n     6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529, \n    61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, \n    61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, \n    62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, \n    62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, \n    62924, 63050, 63082, 63274, 63390, \n  };\n  char aChar[] = {\n    '\\0', 'a',  'c',  'e',  'i',  'n',  'o',  'u',  'y',  'y',  'a',  'c',  \n    'd',  'e',  'e',  'g',  'h',  'i',  'j',  'k',  'l',  'n',  'o',  'r',  \n    's',  't',  'u',  'u',  'w',  'y',  'z',  'o',  'u',  'a',  'i',  'o',  \n    'u',  'g',  'k',  'o',  'j',  'g',  'n',  'a',  'e',  'i',  'o',  'r',  \n    'u',  's',  't',  'h',  'a',  'e',  'o',  'y',  '\\0', '\\0', '\\0', '\\0', \n    '\\0', '\\0', '\\0', '\\0', 'a',  'b',  'd',  'd',  'e',  'f',  'g',  'h',  \n    'h',  'i',  'k',  'l',  'l',  'm',  'n',  'p',  'r',  'r',  's',  't',  \n    'u',  'v',  'w',  'w',  'x',  'y',  'z',  'h',  't',  'w',  'y',  'a',  \n    'e',  'i',  'o',  'u',  'y',  \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);\n};\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & (1 << (c-768))) :\n      (mask1 & (1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( c>=0 );\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( iRes<0 || c>=aEntry[iRes].iCode );\n\n    if( iRes>=0 ){\n      const struct TableEntry *p = &aEntry[iRes];\n      if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n        ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n        assert( ret>0 );\n      }\n    }\n\n    if( bRemoveDiacritic ) ret = remove_diacritic(ret);\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */\n#endif /* !defined(SQLITE_ENABLE_FTS4_UNICODE61) */\n\n/************** End of fts3_unicode2.c ***************************************/\n/************** Begin file rtree.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for implementations of the r-tree and r*-tree\n** algorithms packaged as an SQLite virtual table module.\n*/\n\n/*\n** Database Format of R-Tree Tables\n** --------------------------------\n**\n** The data structure for a single virtual r-tree table is stored in three \n** native SQLite tables declared as follows. In each case, the '%' character\n** in the table name is replaced with the user-supplied name of the r-tree\n** table.\n**\n**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)\n**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)\n**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)\n**\n** The data for each node of the r-tree structure is stored in the %_node\n** table. For each node that is not the root node of the r-tree, there is\n** an entry in the %_parent table associating the node with its parent.\n** And for each row of data in the table, there is an entry in the %_rowid\n** table that maps from the entries rowid to the id of the node that it\n** is stored on.\n**\n** The root node of an r-tree always exists, even if the r-tree table is\n** empty. The nodeno of the root node is always 1. All other nodes in the\n** table must be the same size as the root node. The content of each node\n** is formatted as follows:\n**\n**   1. If the node is the root node (node 1), then the first 2 bytes\n**      of the node contain the tree depth as a big-endian integer.\n**      For non-root nodes, the first 2 bytes are left unused.\n**\n**   2. The next 2 bytes contain the number of entries currently \n**      stored in the node.\n**\n**   3. The remainder of the node contains the node entries. Each entry\n**      consists of a single 8-byte integer followed by an even number\n**      of 4-byte coordinates. For leaf nodes the integer is the rowid\n**      of a record. For internal nodes it is the node number of a\n**      child page.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)\n\n/*\n** This file contains an implementation of a couple of different variants\n** of the r-tree algorithm. See the README file for further details. The \n** same data-structure is used for all, but the algorithms for insert and\n** delete operations vary. The variants used are selected at compile time \n** by defining the following symbols:\n*/\n\n/* Either, both or none of the following may be set to activate \n** r*tree variant algorithms.\n*/\n#define VARIANT_RSTARTREE_CHOOSESUBTREE 0\n#define VARIANT_RSTARTREE_REINSERT      1\n\n/* \n** Exactly one of the following must be set to 1.\n*/\n#define VARIANT_GUTTMAN_QUADRATIC_SPLIT 0\n#define VARIANT_GUTTMAN_LINEAR_SPLIT    0\n#define VARIANT_RSTARTREE_SPLIT         1\n\n#define VARIANT_GUTTMAN_SPLIT \\\n        (VARIANT_GUTTMAN_LINEAR_SPLIT||VARIANT_GUTTMAN_QUADRATIC_SPLIT)\n\n#if VARIANT_GUTTMAN_QUADRATIC_SPLIT\n  #define PickNext QuadraticPickNext\n  #define PickSeeds QuadraticPickSeeds\n  #define AssignCells splitNodeGuttman\n#endif\n#if VARIANT_GUTTMAN_LINEAR_SPLIT\n  #define PickNext LinearPickNext\n  #define PickSeeds LinearPickSeeds\n  #define AssignCells splitNodeGuttman\n#endif\n#if VARIANT_RSTARTREE_SPLIT\n  #define AssignCells splitNodeStartree\n#endif\n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n#ifndef SQLITE_CORE\n  SQLITE_EXTENSION_INIT1\n#else\n#endif\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n#ifndef SQLITE_AMALGAMATION\n#include \"sqlite3rtree.h\"\ntypedef sqlite3_int64 i64;\ntypedef unsigned char u8;\ntypedef unsigned int u32;\n#endif\n\n/*  The following macro is used to suppress compiler warnings.\n*/\n#ifndef UNUSED_PARAMETER\n# define UNUSED_PARAMETER(x) (void)(x)\n#endif\n\ntypedef struct Rtree Rtree;\ntypedef struct RtreeCursor RtreeCursor;\ntypedef struct RtreeNode RtreeNode;\ntypedef struct RtreeCell RtreeCell;\ntypedef struct RtreeConstraint RtreeConstraint;\ntypedef struct RtreeMatchArg RtreeMatchArg;\ntypedef struct RtreeGeomCallback RtreeGeomCallback;\ntypedef union RtreeCoord RtreeCoord;\n\n/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */\n#define RTREE_MAX_DIMENSIONS 5\n\n/* Size of hash table Rtree.aHash. This hash table is not expected to\n** ever contain very many entries, so a fixed number of buckets is \n** used.\n*/\n#define HASHSIZE 128\n\n/* \n** An rtree virtual-table object.\n*/\nstruct Rtree {\n  sqlite3_vtab base;\n  sqlite3 *db;                /* Host database connection */\n  int iNodeSize;              /* Size in bytes of each node in the node table */\n  int nDim;                   /* Number of dimensions */\n  int nBytesPerCell;          /* Bytes consumed per cell */\n  int iDepth;                 /* Current depth of the r-tree structure */\n  char *zDb;                  /* Name of database containing r-tree table */\n  char *zName;                /* Name of r-tree table */ \n  RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ \n  int nBusy;                  /* Current number of users of this structure */\n\n  /* List of nodes removed during a CondenseTree operation. List is\n  ** linked together via the pointer normally used for hash chains -\n  ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree \n  ** headed by the node (leaf nodes have RtreeNode.iNode==0).\n  */\n  RtreeNode *pDeleted;\n  int iReinsertHeight;        /* Height of sub-trees Reinsert() has run on */\n\n  /* Statements to read/write/delete a record from xxx_node */\n  sqlite3_stmt *pReadNode;\n  sqlite3_stmt *pWriteNode;\n  sqlite3_stmt *pDeleteNode;\n\n  /* Statements to read/write/delete a record from xxx_rowid */\n  sqlite3_stmt *pReadRowid;\n  sqlite3_stmt *pWriteRowid;\n  sqlite3_stmt *pDeleteRowid;\n\n  /* Statements to read/write/delete a record from xxx_parent */\n  sqlite3_stmt *pReadParent;\n  sqlite3_stmt *pWriteParent;\n  sqlite3_stmt *pDeleteParent;\n\n  int eCoordType;\n};\n\n/* Possible values for eCoordType: */\n#define RTREE_COORD_REAL32 0\n#define RTREE_COORD_INT32  1\n\n/*\n** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will\n** only deal with integer coordinates.  No floating point operations\n** will be done.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 RtreeDValue;       /* High accuracy coordinate */\n  typedef int RtreeValue;                  /* Low accuracy coordinate */\n#else\n  typedef double RtreeDValue;              /* High accuracy coordinate */\n  typedef float RtreeValue;                /* Low accuracy coordinate */\n#endif\n\n/*\n** The minimum number of cells allowed for a node is a third of the \n** maximum. In Gutman's notation:\n**\n**     m = M/3\n**\n** If an R*-tree \"Reinsert\" operation is required, the same number of\n** cells are removed from the overfull node and reinserted into the tree.\n*/\n#define RTREE_MINCELLS(p) ((((p)->iNodeSize-4)/(p)->nBytesPerCell)/3)\n#define RTREE_REINSERT(p) RTREE_MINCELLS(p)\n#define RTREE_MAXCELLS 51\n\n/*\n** The smallest possible node-size is (512-64)==448 bytes. And the largest\n** supported cell size is 48 bytes (8 byte rowid + ten 4 byte coordinates).\n** Therefore all non-root nodes must contain at least 3 entries. Since \n** 2^40 is greater than 2^64, an r-tree structure always has a depth of\n** 40 or less.\n*/\n#define RTREE_MAX_DEPTH 40\n\n/* \n** An rtree cursor object.\n*/\nstruct RtreeCursor {\n  sqlite3_vtab_cursor base;\n  RtreeNode *pNode;                 /* Node cursor is currently pointing at */\n  int iCell;                        /* Index of current cell in pNode */\n  int iStrategy;                    /* Copy of idxNum search parameter */\n  int nConstraint;                  /* Number of entries in aConstraint */\n  RtreeConstraint *aConstraint;     /* Search constraints. */\n};\n\nunion RtreeCoord {\n  RtreeValue f;\n  int i;\n};\n\n/*\n** The argument is an RtreeCoord. Return the value stored within the RtreeCoord\n** formatted as a RtreeDValue (double or int64). This macro assumes that local\n** variable pRtree points to the Rtree structure associated with the\n** RtreeCoord.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n# define DCOORD(coord) ((RtreeDValue)coord.i)\n#else\n# define DCOORD(coord) (                           \\\n    (pRtree->eCoordType==RTREE_COORD_REAL32) ?      \\\n      ((double)coord.f) :                           \\\n      ((double)coord.i)                             \\\n  )\n#endif\n\n/*\n** A search constraint.\n*/\nstruct RtreeConstraint {\n  int iCoord;                     /* Index of constrained coordinate */\n  int op;                         /* Constraining operation */\n  RtreeDValue rValue;             /* Constraint value. */\n  int (*xGeom)(sqlite3_rtree_geometry*, int, RtreeDValue*, int*);\n  sqlite3_rtree_geometry *pGeom;  /* Constraint callback argument for a MATCH */\n};\n\n/* Possible values for RtreeConstraint.op */\n#define RTREE_EQ    0x41\n#define RTREE_LE    0x42\n#define RTREE_LT    0x43\n#define RTREE_GE    0x44\n#define RTREE_GT    0x45\n#define RTREE_MATCH 0x46\n\n/* \n** An rtree structure node.\n*/\nstruct RtreeNode {\n  RtreeNode *pParent;               /* Parent node */\n  i64 iNode;\n  int nRef;\n  int isDirty;\n  u8 *zData;\n  RtreeNode *pNext;                 /* Next node in this hash chain */\n};\n#define NCELL(pNode) readInt16(&(pNode)->zData[2])\n\n/* \n** Structure to store a deserialized rtree record.\n*/\nstruct RtreeCell {\n  i64 iRowid;\n  RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2];\n};\n\n\n/*\n** Value for the first field of every RtreeMatchArg object. The MATCH\n** operator tests that the first field of a blob operand matches this\n** value to avoid operating on invalid blobs (which could cause a segfault).\n*/\n#define RTREE_GEOMETRY_MAGIC 0x891245AB\n\n/*\n** An instance of this structure must be supplied as a blob argument to\n** the right-hand-side of an SQL MATCH operator used to constrain an\n** r-tree query.\n*/\nstruct RtreeMatchArg {\n  u32 magic;                      /* Always RTREE_GEOMETRY_MAGIC */\n  int (*xGeom)(sqlite3_rtree_geometry *, int, RtreeDValue*, int *);\n  void *pContext;\n  int nParam;\n  RtreeDValue aParam[1];\n};\n\n/*\n** When a geometry callback is created (see sqlite3_rtree_geometry_callback),\n** a single instance of the following structure is allocated. It is used\n** as the context for the user-function created by by s_r_g_c(). The object\n** is eventually deleted by the destructor mechanism provided by\n** sqlite3_create_function_v2() (which is called by s_r_g_c() to create\n** the geometry callback function).\n*/\nstruct RtreeGeomCallback {\n  int (*xGeom)(sqlite3_rtree_geometry*, int, RtreeDValue*, int*);\n  void *pContext;\n};\n\n#ifndef MAX\n# define MAX(x,y) ((x) < (y) ? (y) : (x))\n#endif\n#ifndef MIN\n# define MIN(x,y) ((x) > (y) ? (y) : (x))\n#endif\n\n/*\n** Functions to deserialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The deserialized value is returned.\n*/\nstatic int readInt16(u8 *p){\n  return (p[0]<<8) + p[1];\n}\nstatic void readCoord(u8 *p, RtreeCoord *pCoord){\n  u32 i = (\n    (((u32)p[0]) << 24) + \n    (((u32)p[1]) << 16) + \n    (((u32)p[2]) <<  8) + \n    (((u32)p[3]) <<  0)\n  );\n  *(u32 *)pCoord = i;\n}\nstatic i64 readInt64(u8 *p){\n  return (\n    (((i64)p[0]) << 56) + \n    (((i64)p[1]) << 48) + \n    (((i64)p[2]) << 40) + \n    (((i64)p[3]) << 32) + \n    (((i64)p[4]) << 24) + \n    (((i64)p[5]) << 16) + \n    (((i64)p[6]) <<  8) + \n    (((i64)p[7]) <<  0)\n  );\n}\n\n/*\n** Functions to serialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The value returned is the number of bytes written\n** to the argument buffer (always 2, 4 and 8 respectively).\n*/\nstatic int writeInt16(u8 *p, int i){\n  p[0] = (i>> 8)&0xFF;\n  p[1] = (i>> 0)&0xFF;\n  return 2;\n}\nstatic int writeCoord(u8 *p, RtreeCoord *pCoord){\n  u32 i;\n  assert( sizeof(RtreeCoord)==4 );\n  assert( sizeof(u32)==4 );\n  i = *(u32 *)pCoord;\n  p[0] = (i>>24)&0xFF;\n  p[1] = (i>>16)&0xFF;\n  p[2] = (i>> 8)&0xFF;\n  p[3] = (i>> 0)&0xFF;\n  return 4;\n}\nstatic int writeInt64(u8 *p, i64 i){\n  p[0] = (i>>56)&0xFF;\n  p[1] = (i>>48)&0xFF;\n  p[2] = (i>>40)&0xFF;\n  p[3] = (i>>32)&0xFF;\n  p[4] = (i>>24)&0xFF;\n  p[5] = (i>>16)&0xFF;\n  p[6] = (i>> 8)&0xFF;\n  p[7] = (i>> 0)&0xFF;\n  return 8;\n}\n\n/*\n** Increment the reference count of node p.\n*/\nstatic void nodeReference(RtreeNode *p){\n  if( p ){\n    p->nRef++;\n  }\n}\n\n/*\n** Clear the content of node p (set all bytes to 0x00).\n*/\nstatic void nodeZero(Rtree *pRtree, RtreeNode *p){\n  memset(&p->zData[2], 0, pRtree->iNodeSize-2);\n  p->isDirty = 1;\n}\n\n/*\n** Given a node number iNode, return the corresponding key to use\n** in the Rtree.aHash table.\n*/\nstatic int nodeHash(i64 iNode){\n  return (\n    (iNode>>56) ^ (iNode>>48) ^ (iNode>>40) ^ (iNode>>32) ^ \n    (iNode>>24) ^ (iNode>>16) ^ (iNode>> 8) ^ (iNode>> 0)\n  ) % HASHSIZE;\n}\n\n/*\n** Search the node hash table for node iNode. If found, return a pointer\n** to it. Otherwise, return 0.\n*/\nstatic RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){\n  RtreeNode *p;\n  for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext);\n  return p;\n}\n\n/*\n** Add node pNode to the node hash table.\n*/\nstatic void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){\n  int iHash;\n  assert( pNode->pNext==0 );\n  iHash = nodeHash(pNode->iNode);\n  pNode->pNext = pRtree->aHash[iHash];\n  pRtree->aHash[iHash] = pNode;\n}\n\n/*\n** Remove node pNode from the node hash table.\n*/\nstatic void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode **pp;\n  if( pNode->iNode!=0 ){\n    pp = &pRtree->aHash[nodeHash(pNode->iNode)];\n    for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }\n    *pp = pNode->pNext;\n    pNode->pNext = 0;\n  }\n}\n\n/*\n** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0),\n** indicating that node has not yet been assigned a node number. It is\n** assigned a node number when nodeWrite() is called to write the\n** node contents out to the database.\n*/\nstatic RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){\n  RtreeNode *pNode;\n  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);\n  if( pNode ){\n    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);\n    pNode->zData = (u8 *)&pNode[1];\n    pNode->nRef = 1;\n    pNode->pParent = pParent;\n    pNode->isDirty = 1;\n    nodeReference(pParent);\n  }\n  return pNode;\n}\n\n/*\n** Obtain a reference to an r-tree node.\n*/\nstatic int\nnodeAcquire(\n  Rtree *pRtree,             /* R-tree structure */\n  i64 iNode,                 /* Node number to load */\n  RtreeNode *pParent,        /* Either the parent node or NULL */\n  RtreeNode **ppNode         /* OUT: Acquired node */\n){\n  int rc;\n  int rc2 = SQLITE_OK;\n  RtreeNode *pNode;\n\n  /* Check if the requested node is already in the hash table. If so,\n  ** increase its reference count and return it.\n  */\n  if( (pNode = nodeHashLookup(pRtree, iNode)) ){\n    assert( !pParent || !pNode->pParent || pNode->pParent==pParent );\n    if( pParent && !pNode->pParent ){\n      nodeReference(pParent);\n      pNode->pParent = pParent;\n    }\n    pNode->nRef++;\n    *ppNode = pNode;\n    return SQLITE_OK;\n  }\n\n  sqlite3_bind_int64(pRtree->pReadNode, 1, iNode);\n  rc = sqlite3_step(pRtree->pReadNode);\n  if( rc==SQLITE_ROW ){\n    const u8 *zBlob = sqlite3_column_blob(pRtree->pReadNode, 0);\n    if( pRtree->iNodeSize==sqlite3_column_bytes(pRtree->pReadNode, 0) ){\n      pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);\n      if( !pNode ){\n        rc2 = SQLITE_NOMEM;\n      }else{\n        pNode->pParent = pParent;\n        pNode->zData = (u8 *)&pNode[1];\n        pNode->nRef = 1;\n        pNode->iNode = iNode;\n        pNode->isDirty = 0;\n        pNode->pNext = 0;\n        memcpy(pNode->zData, zBlob, pRtree->iNodeSize);\n        nodeReference(pParent);\n      }\n    }\n  }\n  rc = sqlite3_reset(pRtree->pReadNode);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  /* If the root node was just loaded, set pRtree->iDepth to the height\n  ** of the r-tree structure. A height of zero means all data is stored on\n  ** the root node. A height of one means the children of the root node\n  ** are the leaves, and so on. If the depth as specified on the root node\n  ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.\n  */\n  if( pNode && iNode==1 ){\n    pRtree->iDepth = readInt16(pNode->zData);\n    if( pRtree->iDepth>RTREE_MAX_DEPTH ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  /* If no error has occurred so far, check if the \"number of entries\"\n  ** field on the node is too large. If so, set the return code to \n  ** SQLITE_CORRUPT_VTAB.\n  */\n  if( pNode && rc==SQLITE_OK ){\n    if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( pNode!=0 ){\n      nodeHashInsert(pRtree, pNode);\n    }else{\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n    *ppNode = pNode;\n  }else{\n    sqlite3_free(pNode);\n    *ppNode = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Overwrite cell iCell of node pNode with the contents of pCell.\n*/\nstatic void nodeOverwriteCell(\n  Rtree *pRtree, \n  RtreeNode *pNode,  \n  RtreeCell *pCell, \n  int iCell\n){\n  int ii;\n  u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  p += writeInt64(p, pCell->iRowid);\n  for(ii=0; ii<(pRtree->nDim*2); ii++){\n    p += writeCoord(p, &pCell->aCoord[ii]);\n  }\n  pNode->isDirty = 1;\n}\n\n/*\n** Remove cell the cell with index iCell from node pNode.\n*/\nstatic void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){\n  u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  u8 *pSrc = &pDst[pRtree->nBytesPerCell];\n  int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;\n  memmove(pDst, pSrc, nByte);\n  writeInt16(&pNode->zData[2], NCELL(pNode)-1);\n  pNode->isDirty = 1;\n}\n\n/*\n** Insert the contents of cell pCell into node pNode. If the insert\n** is successful, return SQLITE_OK.\n**\n** If there is not enough free space in pNode, return SQLITE_FULL.\n*/\nstatic int\nnodeInsertCell(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  RtreeCell *pCell \n){\n  int nCell;                    /* Current number of cells in pNode */\n  int nMaxCell;                 /* Maximum number of cells for pNode */\n\n  nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell;\n  nCell = NCELL(pNode);\n\n  assert( nCell<=nMaxCell );\n  if( nCell<nMaxCell ){\n    nodeOverwriteCell(pRtree, pNode, pCell, nCell);\n    writeInt16(&pNode->zData[2], nCell+1);\n    pNode->isDirty = 1;\n  }\n\n  return (nCell==nMaxCell);\n}\n\n/*\n** If the node is dirty, write it out to the database.\n*/\nstatic int\nnodeWrite(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode->isDirty ){\n    sqlite3_stmt *p = pRtree->pWriteNode;\n    if( pNode->iNode ){\n      sqlite3_bind_int64(p, 1, pNode->iNode);\n    }else{\n      sqlite3_bind_null(p, 1);\n    }\n    sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);\n    sqlite3_step(p);\n    pNode->isDirty = 0;\n    rc = sqlite3_reset(p);\n    if( pNode->iNode==0 && rc==SQLITE_OK ){\n      pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);\n      nodeHashInsert(pRtree, pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Release a reference to a node. If the node is dirty and the reference\n** count drops to zero, the node data is written to the database.\n*/\nstatic int\nnodeRelease(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode ){\n    assert( pNode->nRef>0 );\n    pNode->nRef--;\n    if( pNode->nRef==0 ){\n      if( pNode->iNode==1 ){\n        pRtree->iDepth = -1;\n      }\n      if( pNode->pParent ){\n        rc = nodeRelease(pRtree, pNode->pParent);\n      }\n      if( rc==SQLITE_OK ){\n        rc = nodeWrite(pRtree, pNode);\n      }\n      nodeHashDelete(pRtree, pNode);\n      sqlite3_free(pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the 64-bit integer value associated with cell iCell of\n** node pNode. If pNode is a leaf node, this is a rowid. If it is\n** an internal node, then the 64-bit integer is a child page number.\n*/\nstatic i64 nodeGetRowid(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  int iCell\n){\n  assert( iCell<NCELL(pNode) );\n  return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);\n}\n\n/*\n** Return coordinate iCoord from cell iCell in node pNode.\n*/\nstatic void nodeGetCoord(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  int iCell,\n  int iCoord,\n  RtreeCoord *pCoord           /* Space to write result to */\n){\n  readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);\n}\n\n/*\n** Deserialize cell iCell of node pNode. Populate the structure pointed\n** to by pCell with the results.\n*/\nstatic void nodeGetCell(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  int iCell,\n  RtreeCell *pCell\n){\n  int ii;\n  pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);\n  for(ii=0; ii<pRtree->nDim*2; ii++){\n    nodeGetCoord(pRtree, pNode, iCell, ii, &pCell->aCoord[ii]);\n  }\n}\n\n\n/* Forward declaration for the function that does the work of\n** the virtual table module xCreate() and xConnect() methods.\n*/\nstatic int rtreeInit(\n  sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **, int\n);\n\n/* \n** Rtree virtual table module xCreate method.\n*/\nstatic int rtreeCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1);\n}\n\n/* \n** Rtree virtual table module xConnect method.\n*/\nstatic int rtreeConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 0);\n}\n\n/*\n** Increment the r-tree reference count.\n*/\nstatic void rtreeReference(Rtree *pRtree){\n  pRtree->nBusy++;\n}\n\n/*\n** Decrement the r-tree reference count. When the reference count reaches\n** zero the structure is deleted.\n*/\nstatic void rtreeRelease(Rtree *pRtree){\n  pRtree->nBusy--;\n  if( pRtree->nBusy==0 ){\n    sqlite3_finalize(pRtree->pReadNode);\n    sqlite3_finalize(pRtree->pWriteNode);\n    sqlite3_finalize(pRtree->pDeleteNode);\n    sqlite3_finalize(pRtree->pReadRowid);\n    sqlite3_finalize(pRtree->pWriteRowid);\n    sqlite3_finalize(pRtree->pDeleteRowid);\n    sqlite3_finalize(pRtree->pReadParent);\n    sqlite3_finalize(pRtree->pWriteParent);\n    sqlite3_finalize(pRtree->pDeleteParent);\n    sqlite3_free(pRtree);\n  }\n}\n\n/* \n** Rtree virtual table module xDisconnect method.\n*/\nstatic int rtreeDisconnect(sqlite3_vtab *pVtab){\n  rtreeRelease((Rtree *)pVtab);\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xDestroy method.\n*/\nstatic int rtreeDestroy(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc;\n  char *zCreate = sqlite3_mprintf(\n    \"DROP TABLE '%q'.'%q_node';\"\n    \"DROP TABLE '%q'.'%q_rowid';\"\n    \"DROP TABLE '%q'.'%q_parent';\",\n    pRtree->zDb, pRtree->zName, \n    pRtree->zDb, pRtree->zName,\n    pRtree->zDb, pRtree->zName\n  );\n  if( !zCreate ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n  }\n  if( rc==SQLITE_OK ){\n    rtreeRelease(pRtree);\n  }\n\n  return rc;\n}\n\n/* \n** Rtree virtual table module xOpen method.\n*/\nstatic int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  RtreeCursor *pCsr;\n\n  pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));\n  if( pCsr ){\n    memset(pCsr, 0, sizeof(RtreeCursor));\n    pCsr->base.pVtab = pVTab;\n    rc = SQLITE_OK;\n  }\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n\n  return rc;\n}\n\n\n/*\n** Free the RtreeCursor.aConstraint[] array and its contents.\n*/\nstatic void freeCursorConstraints(RtreeCursor *pCsr){\n  if( pCsr->aConstraint ){\n    int i;                        /* Used to iterate through constraint array */\n    for(i=0; i<pCsr->nConstraint; i++){\n      sqlite3_rtree_geometry *pGeom = pCsr->aConstraint[i].pGeom;\n      if( pGeom ){\n        if( pGeom->xDelUser ) pGeom->xDelUser(pGeom->pUser);\n        sqlite3_free(pGeom);\n      }\n    }\n    sqlite3_free(pCsr->aConstraint);\n    pCsr->aConstraint = 0;\n  }\n}\n\n/* \n** Rtree virtual table module xClose method.\n*/\nstatic int rtreeClose(sqlite3_vtab_cursor *cur){\n  Rtree *pRtree = (Rtree *)(cur->pVtab);\n  int rc;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  freeCursorConstraints(pCsr);\n  rc = nodeRelease(pRtree, pCsr->pNode);\n  sqlite3_free(pCsr);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xEof method.\n**\n** Return non-zero if the cursor does not currently point to a valid \n** record (i.e if the scan has finished), or zero otherwise.\n*/\nstatic int rtreeEof(sqlite3_vtab_cursor *cur){\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  return (pCsr->pNode==0);\n}\n\n/*\n** The r-tree constraint passed as the second argument to this function is\n** guaranteed to be a MATCH constraint.\n*/\nstatic int testRtreeGeom(\n  Rtree *pRtree,                  /* R-Tree object */\n  RtreeConstraint *pConstraint,   /* MATCH constraint to test */\n  RtreeCell *pCell,               /* Cell to test */\n  int *pbRes                      /* OUT: Test result */\n){\n  int i;\n  RtreeDValue aCoord[RTREE_MAX_DIMENSIONS*2];\n  int nCoord = pRtree->nDim*2;\n\n  assert( pConstraint->op==RTREE_MATCH );\n  assert( pConstraint->pGeom );\n\n  for(i=0; i<nCoord; i++){\n    aCoord[i] = DCOORD(pCell->aCoord[i]);\n  }\n  return pConstraint->xGeom(pConstraint->pGeom, nCoord, aCoord, pbRes);\n}\n\n/* \n** Cursor pCursor currently points to a cell in a non-leaf page.\n** Set *pbEof to true if the sub-tree headed by the cell is filtered\n** (excluded) by the constraints in the pCursor->aConstraint[] \n** array, or false otherwise.\n**\n** Return SQLITE_OK if successful or an SQLite error code if an error\n** occurs within a geometry callback.\n*/\nstatic int testRtreeCell(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){\n  RtreeCell cell;\n  int ii;\n  int bRes = 0;\n  int rc = SQLITE_OK;\n\n  nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);\n  for(ii=0; bRes==0 && ii<pCursor->nConstraint; ii++){\n    RtreeConstraint *p = &pCursor->aConstraint[ii];\n    RtreeDValue cell_min = DCOORD(cell.aCoord[(p->iCoord>>1)*2]);\n    RtreeDValue cell_max = DCOORD(cell.aCoord[(p->iCoord>>1)*2+1]);\n\n    assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n        || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_MATCH\n    );\n\n    switch( p->op ){\n      case RTREE_LE: case RTREE_LT: \n        bRes = p->rValue<cell_min; \n        break;\n\n      case RTREE_GE: case RTREE_GT: \n        bRes = p->rValue>cell_max; \n        break;\n\n      case RTREE_EQ:\n        bRes = (p->rValue>cell_max || p->rValue<cell_min);\n        break;\n\n      default: {\n        assert( p->op==RTREE_MATCH );\n        rc = testRtreeGeom(pRtree, p, &cell, &bRes);\n        bRes = !bRes;\n        break;\n      }\n    }\n  }\n\n  *pbEof = bRes;\n  return rc;\n}\n\n/* \n** Test if the cell that cursor pCursor currently points to\n** would be filtered (excluded) by the constraints in the \n** pCursor->aConstraint[] array. If so, set *pbEof to true before\n** returning. If the cell is not filtered (excluded) by the constraints,\n** set pbEof to zero.\n**\n** Return SQLITE_OK if successful or an SQLite error code if an error\n** occurs within a geometry callback.\n**\n** This function assumes that the cell is part of a leaf node.\n*/\nstatic int testRtreeEntry(Rtree *pRtree, RtreeCursor *pCursor, int *pbEof){\n  RtreeCell cell;\n  int ii;\n  *pbEof = 0;\n\n  nodeGetCell(pRtree, pCursor->pNode, pCursor->iCell, &cell);\n  for(ii=0; ii<pCursor->nConstraint; ii++){\n    RtreeConstraint *p = &pCursor->aConstraint[ii];\n    RtreeDValue coord = DCOORD(cell.aCoord[p->iCoord]);\n    int res;\n    assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n        || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_MATCH\n    );\n    switch( p->op ){\n      case RTREE_LE: res = (coord<=p->rValue); break;\n      case RTREE_LT: res = (coord<p->rValue);  break;\n      case RTREE_GE: res = (coord>=p->rValue); break;\n      case RTREE_GT: res = (coord>p->rValue);  break;\n      case RTREE_EQ: res = (coord==p->rValue); break;\n      default: {\n        int rc;\n        assert( p->op==RTREE_MATCH );\n        rc = testRtreeGeom(pRtree, p, &cell, &res);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        break;\n      }\n    }\n\n    if( !res ){\n      *pbEof = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Cursor pCursor currently points at a node that heads a sub-tree of\n** height iHeight (if iHeight==0, then the node is a leaf). Descend\n** to point to the left-most cell of the sub-tree that matches the \n** configured constraints.\n*/\nstatic int descendToCell(\n  Rtree *pRtree, \n  RtreeCursor *pCursor, \n  int iHeight,\n  int *pEof                 /* OUT: Set to true if cannot descend */\n){\n  int isEof;\n  int rc;\n  int ii;\n  RtreeNode *pChild;\n  sqlite3_int64 iRowid;\n\n  RtreeNode *pSavedNode = pCursor->pNode;\n  int iSavedCell = pCursor->iCell;\n\n  assert( iHeight>=0 );\n\n  if( iHeight==0 ){\n    rc = testRtreeEntry(pRtree, pCursor, &isEof);\n  }else{\n    rc = testRtreeCell(pRtree, pCursor, &isEof);\n  }\n  if( rc!=SQLITE_OK || isEof || iHeight==0 ){\n    goto descend_to_cell_out;\n  }\n\n  iRowid = nodeGetRowid(pRtree, pCursor->pNode, pCursor->iCell);\n  rc = nodeAcquire(pRtree, iRowid, pCursor->pNode, &pChild);\n  if( rc!=SQLITE_OK ){\n    goto descend_to_cell_out;\n  }\n\n  nodeRelease(pRtree, pCursor->pNode);\n  pCursor->pNode = pChild;\n  isEof = 1;\n  for(ii=0; isEof && ii<NCELL(pChild); ii++){\n    pCursor->iCell = ii;\n    rc = descendToCell(pRtree, pCursor, iHeight-1, &isEof);\n    if( rc!=SQLITE_OK ){\n      goto descend_to_cell_out;\n    }\n  }\n\n  if( isEof ){\n    assert( pCursor->pNode==pChild );\n    nodeReference(pSavedNode);\n    nodeRelease(pRtree, pChild);\n    pCursor->pNode = pSavedNode;\n    pCursor->iCell = iSavedCell;\n  }\n\ndescend_to_cell_out:\n  *pEof = isEof;\n  return rc;\n}\n\n/*\n** One of the cells in node pNode is guaranteed to have a 64-bit \n** integer value equal to iRowid. Return the index of this cell.\n*/\nstatic int nodeRowidIndex(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  i64 iRowid,\n  int *piIndex\n){\n  int ii;\n  int nCell = NCELL(pNode);\n  for(ii=0; ii<nCell; ii++){\n    if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){\n      *piIndex = ii;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_CORRUPT_VTAB;\n}\n\n/*\n** Return the index of the cell containing a pointer to node pNode\n** in its parent. If pNode is the root node, return -1.\n*/\nstatic int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){\n  RtreeNode *pParent = pNode->pParent;\n  if( pParent ){\n    return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);\n  }\n  *piIndex = -1;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xNext method.\n*/\nstatic int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){\n  Rtree *pRtree = (Rtree *)(pVtabCursor->pVtab);\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* RtreeCursor.pNode must not be NULL. If is is NULL, then this cursor is\n  ** already at EOF. It is against the rules to call the xNext() method of\n  ** a cursor that has already reached EOF.\n  */\n  assert( pCsr->pNode );\n\n  if( pCsr->iStrategy==1 ){\n    /* This \"scan\" is a direct lookup by rowid. There is no next entry. */\n    nodeRelease(pRtree, pCsr->pNode);\n    pCsr->pNode = 0;\n  }else{\n    /* Move to the next entry that matches the configured constraints. */\n    int iHeight = 0;\n    while( pCsr->pNode ){\n      RtreeNode *pNode = pCsr->pNode;\n      int nCell = NCELL(pNode);\n      for(pCsr->iCell++; pCsr->iCell<nCell; pCsr->iCell++){\n        int isEof;\n        rc = descendToCell(pRtree, pCsr, iHeight, &isEof);\n        if( rc!=SQLITE_OK || !isEof ){\n          return rc;\n        }\n      }\n      pCsr->pNode = pNode->pParent;\n      rc = nodeParentIndex(pRtree, pNode, &pCsr->iCell);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      nodeReference(pCsr->pNode);\n      nodeRelease(pRtree, pNode);\n      iHeight++;\n    }\n  }\n\n  return rc;\n}\n\n/* \n** Rtree virtual table module xRowid method.\n*/\nstatic int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n\n  assert(pCsr->pNode);\n  *pRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);\n\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xColumn method.\n*/\nstatic int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Rtree *pRtree = (Rtree *)cur->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n\n  if( i==0 ){\n    i64 iRowid = nodeGetRowid(pRtree, pCsr->pNode, pCsr->iCell);\n    sqlite3_result_int64(ctx, iRowid);\n  }else{\n    RtreeCoord c;\n    nodeGetCoord(pRtree, pCsr->pNode, pCsr->iCell, i-1, &c);\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      sqlite3_result_double(ctx, c.f);\n    }else\n#endif\n    {\n      assert( pRtree->eCoordType==RTREE_COORD_INT32 );\n      sqlite3_result_int(ctx, c.i);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/* \n** Use nodeAcquire() to obtain the leaf node containing the record with \n** rowid iRowid. If successful, set *ppLeaf to point to the node and\n** return SQLITE_OK. If there is no such record in the table, set\n** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf\n** to zero and return an SQLite error code.\n*/\nstatic int findLeafNode(Rtree *pRtree, i64 iRowid, RtreeNode **ppLeaf){\n  int rc;\n  *ppLeaf = 0;\n  sqlite3_bind_int64(pRtree->pReadRowid, 1, iRowid);\n  if( sqlite3_step(pRtree->pReadRowid)==SQLITE_ROW ){\n    i64 iNode = sqlite3_column_int64(pRtree->pReadRowid, 0);\n    rc = nodeAcquire(pRtree, iNode, 0, ppLeaf);\n    sqlite3_reset(pRtree->pReadRowid);\n  }else{\n    rc = sqlite3_reset(pRtree->pReadRowid);\n  }\n  return rc;\n}\n\n/*\n** This function is called to configure the RtreeConstraint object passed\n** as the second argument for a MATCH constraint. The value passed as the\n** first argument to this function is the right-hand operand to the MATCH\n** operator.\n*/\nstatic int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){\n  RtreeMatchArg *p;\n  sqlite3_rtree_geometry *pGeom;\n  int nBlob;\n\n  /* Check that value is actually a blob. */\n  if( sqlite3_value_type(pValue)!=SQLITE_BLOB ) return SQLITE_ERROR;\n\n  /* Check that the blob is roughly the right size. */\n  nBlob = sqlite3_value_bytes(pValue);\n  if( nBlob<(int)sizeof(RtreeMatchArg) \n   || ((nBlob-sizeof(RtreeMatchArg))%sizeof(RtreeDValue))!=0\n  ){\n    return SQLITE_ERROR;\n  }\n\n  pGeom = (sqlite3_rtree_geometry *)sqlite3_malloc(\n      sizeof(sqlite3_rtree_geometry) + nBlob\n  );\n  if( !pGeom ) return SQLITE_NOMEM;\n  memset(pGeom, 0, sizeof(sqlite3_rtree_geometry));\n  p = (RtreeMatchArg *)&pGeom[1];\n\n  memcpy(p, sqlite3_value_blob(pValue), nBlob);\n  if( p->magic!=RTREE_GEOMETRY_MAGIC \n   || nBlob!=(int)(sizeof(RtreeMatchArg) + (p->nParam-1)*sizeof(RtreeDValue))\n  ){\n    sqlite3_free(pGeom);\n    return SQLITE_ERROR;\n  }\n\n  pGeom->pContext = p->pContext;\n  pGeom->nParam = p->nParam;\n  pGeom->aParam = p->aParam;\n\n  pCons->xGeom = p->xGeom;\n  pCons->pGeom = pGeom;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xFilter method.\n*/\nstatic int rtreeFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n\n  RtreeNode *pRoot = 0;\n  int ii;\n  int rc = SQLITE_OK;\n\n  rtreeReference(pRtree);\n\n  freeCursorConstraints(pCsr);\n  pCsr->iStrategy = idxNum;\n\n  if( idxNum==1 ){\n    /* Special case - lookup by rowid. */\n    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */\n    i64 iRowid = sqlite3_value_int64(argv[0]);\n    rc = findLeafNode(pRtree, iRowid, &pLeaf);\n    pCsr->pNode = pLeaf; \n    if( pLeaf ){\n      assert( rc==SQLITE_OK );\n      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &pCsr->iCell);\n    }\n  }else{\n    /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array \n    ** with the configured constraints. \n    */\n    if( argc>0 ){\n      pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);\n      pCsr->nConstraint = argc;\n      if( !pCsr->aConstraint ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);\n        assert( (idxStr==0 && argc==0)\n                || (idxStr && (int)strlen(idxStr)==argc*2) );\n        for(ii=0; ii<argc; ii++){\n          RtreeConstraint *p = &pCsr->aConstraint[ii];\n          p->op = idxStr[ii*2];\n          p->iCoord = idxStr[ii*2+1]-'a';\n          if( p->op==RTREE_MATCH ){\n            /* A MATCH operator. The right-hand-side must be a blob that\n            ** can be cast into an RtreeMatchArg object. One created using\n            ** an sqlite3_rtree_geometry_callback() SQL user function.\n            */\n            rc = deserializeGeometry(argv[ii], p);\n            if( rc!=SQLITE_OK ){\n              break;\n            }\n          }else{\n#ifdef SQLITE_RTREE_INT_ONLY\n            p->rValue = sqlite3_value_int64(argv[ii]);\n#else\n            p->rValue = sqlite3_value_double(argv[ii]);\n#endif\n          }\n        }\n      }\n    }\n  \n    if( rc==SQLITE_OK ){\n      pCsr->pNode = 0;\n      rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n    }\n    if( rc==SQLITE_OK ){\n      int isEof = 1;\n      int nCell = NCELL(pRoot);\n      pCsr->pNode = pRoot;\n      for(pCsr->iCell=0; rc==SQLITE_OK && pCsr->iCell<nCell; pCsr->iCell++){\n        assert( pCsr->pNode==pRoot );\n        rc = descendToCell(pRtree, pCsr, pRtree->iDepth, &isEof);\n        if( !isEof ){\n          break;\n        }\n      }\n      if( rc==SQLITE_OK && isEof ){\n        assert( pCsr->pNode==pRoot );\n        nodeRelease(pRtree, pRoot);\n        pCsr->pNode = 0;\n      }\n      assert( rc!=SQLITE_OK || !pCsr->pNode || pCsr->iCell<NCELL(pCsr->pNode) );\n    }\n  }\n\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xBestIndex method. There are three\n** table scan strategies to choose from (in order from most to \n** least desirable):\n**\n**   idxNum     idxStr        Strategy\n**   ------------------------------------------------\n**     1        Unused        Direct lookup by rowid.\n**     2        See below     R-tree query or full-table scan.\n**   ------------------------------------------------\n**\n** If strategy 1 is used, then idxStr is not meaningful. If strategy\n** 2 is used, idxStr is formatted to contain 2 bytes for each \n** constraint used. The first two bytes of idxStr correspond to \n** the constraint in sqlite3_index_info.aConstraintUsage[] with\n** (argvIndex==1) etc.\n**\n** The first of each pair of bytes in idxStr identifies the constraint\n** operator as follows:\n**\n**   Operator    Byte Value\n**   ----------------------\n**      =        0x41 ('A')\n**     <=        0x42 ('B')\n**      <        0x43 ('C')\n**     >=        0x44 ('D')\n**      >        0x45 ('E')\n**   MATCH       0x46 ('F')\n**   ----------------------\n**\n** The second of each pair of bytes identifies the coordinate column\n** to which the constraint applies. The leftmost coordinate column\n** is 'a', the second from the left 'b' etc.\n*/\nstatic int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int rc = SQLITE_OK;\n  int ii;\n\n  int iIdx = 0;\n  char zIdxStr[RTREE_MAX_DIMENSIONS*8+1];\n  memset(zIdxStr, 0, sizeof(zIdxStr));\n  UNUSED_PARAMETER(tab);\n\n  assert( pIdxInfo->idxStr==0 );\n  for(ii=0; ii<pIdxInfo->nConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii];\n\n    if( p->usable && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      /* We have an equality constraint on the rowid. Use strategy 1. */\n      int jj;\n      for(jj=0; jj<ii; jj++){\n        pIdxInfo->aConstraintUsage[jj].argvIndex = 0;\n        pIdxInfo->aConstraintUsage[jj].omit = 0;\n      }\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[ii].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[jj].omit = 1;\n\n      /* This strategy involves a two rowid lookups on an B-Tree structures\n      ** and then a linear search of an R-Tree node. This should be \n      ** considered almost as quick as a direct rowid lookup (for which \n      ** sqlite uses an internal cost of 0.0).\n      */ \n      pIdxInfo->estimatedCost = 10.0;\n      return SQLITE_OK;\n    }\n\n    if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){\n      u8 op;\n      switch( p->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;\n        case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;\n        case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;\n        case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;\n        case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;\n        default:\n          assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );\n          op = RTREE_MATCH; \n          break;\n      }\n      zIdxStr[iIdx++] = op;\n      zIdxStr[iIdx++] = p->iColumn - 1 + 'a';\n      pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);\n      pIdxInfo->aConstraintUsage[ii].omit = 1;\n    }\n  }\n\n  pIdxInfo->idxNum = 2;\n  pIdxInfo->needToFreeIdxStr = 1;\n  if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf(\"%s\", zIdxStr)) ){\n    return SQLITE_NOMEM;\n  }\n  assert( iIdx>=0 );\n  pIdxInfo->estimatedCost = (2000000.0 / (double)(iIdx + 1));\n  return rc;\n}\n\n/*\n** Return the N-dimensional volumn of the cell stored in *p.\n*/\nstatic RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue area = (RtreeDValue)1;\n  int ii;\n  for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n    area = (area * (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii])));\n  }\n  return area;\n}\n\n/*\n** Return the margin length of cell p. The margin length is the sum\n** of the objects size in each dimension.\n*/\nstatic RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue margin = (RtreeDValue)0;\n  int ii;\n  for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n    margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));\n  }\n  return margin;\n}\n\n/*\n** Store the union of cells p1 and p2 in p1.\n*/\nstatic void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii;\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n      p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f);\n      p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f);\n    }\n  }else{\n    for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n      p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i);\n      p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i);\n    }\n  }\n}\n\n/*\n** Return true if the area covered by p2 is a subset of the area covered\n** by p1. False otherwise.\n*/\nstatic int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii;\n  int isInt = (pRtree->eCoordType==RTREE_COORD_INT32);\n  for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n    RtreeCoord *a1 = &p1->aCoord[ii];\n    RtreeCoord *a2 = &p2->aCoord[ii];\n    if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) \n     || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) \n    ){\n      return 0;\n    }\n  }\n  return 1;\n}\n\n/*\n** Return the amount cell p would grow by if it were unioned with pCell.\n*/\nstatic RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){\n  RtreeDValue area;\n  RtreeCell cell;\n  memcpy(&cell, p, sizeof(RtreeCell));\n  area = cellArea(pRtree, &cell);\n  cellUnion(pRtree, &cell, pCell);\n  return (cellArea(pRtree, &cell)-area);\n}\n\n#if VARIANT_RSTARTREE_CHOOSESUBTREE || VARIANT_RSTARTREE_SPLIT\nstatic RtreeDValue cellOverlap(\n  Rtree *pRtree, \n  RtreeCell *p, \n  RtreeCell *aCell, \n  int nCell, \n  int iExclude\n){\n  int ii;\n  RtreeDValue overlap = 0.0;\n  for(ii=0; ii<nCell; ii++){\n#if VARIANT_RSTARTREE_CHOOSESUBTREE\n    if( ii!=iExclude )\n#else\n    assert( iExclude==-1 );\n    UNUSED_PARAMETER(iExclude);\n#endif\n    {\n      int jj;\n      RtreeDValue o = (RtreeDValue)1;\n      for(jj=0; jj<(pRtree->nDim*2); jj+=2){\n        RtreeDValue x1, x2;\n\n        x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj]));\n        x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1]));\n\n        if( x2<x1 ){\n          o = 0.0;\n          break;\n        }else{\n          o = o * (x2-x1);\n        }\n      }\n      overlap += o;\n    }\n  }\n  return overlap;\n}\n#endif\n\n#if VARIANT_RSTARTREE_CHOOSESUBTREE\nstatic RtreeDValue cellOverlapEnlargement(\n  Rtree *pRtree, \n  RtreeCell *p, \n  RtreeCell *pInsert, \n  RtreeCell *aCell, \n  int nCell, \n  int iExclude\n){\n  RtreeDValue before, after;\n  before = cellOverlap(pRtree, p, aCell, nCell, iExclude);\n  cellUnion(pRtree, p, pInsert);\n  after = cellOverlap(pRtree, p, aCell, nCell, iExclude);\n  return (after-before);\n}\n#endif\n\n\n/*\n** This function implements the ChooseLeaf algorithm from Gutman[84].\n** ChooseSubTree in r*tree terminology.\n*/\nstatic int ChooseLeaf(\n  Rtree *pRtree,               /* Rtree table */\n  RtreeCell *pCell,            /* Cell to insert into rtree */\n  int iHeight,                 /* Height of sub-tree rooted at pCell */\n  RtreeNode **ppLeaf           /* OUT: Selected leaf page */\n){\n  int rc;\n  int ii;\n  RtreeNode *pNode;\n  rc = nodeAcquire(pRtree, 1, 0, &pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){\n    int iCell;\n    sqlite3_int64 iBest = 0;\n\n    RtreeDValue fMinGrowth = 0.0;\n    RtreeDValue fMinArea = 0.0;\n#if VARIANT_RSTARTREE_CHOOSESUBTREE\n    RtreeDValue fMinOverlap = 0.0;\n    RtreeDValue overlap;\n#endif\n\n    int nCell = NCELL(pNode);\n    RtreeCell cell;\n    RtreeNode *pChild;\n\n    RtreeCell *aCell = 0;\n\n#if VARIANT_RSTARTREE_CHOOSESUBTREE\n    if( ii==(pRtree->iDepth-1) ){\n      int jj;\n      aCell = sqlite3_malloc(sizeof(RtreeCell)*nCell);\n      if( !aCell ){\n        rc = SQLITE_NOMEM;\n        nodeRelease(pRtree, pNode);\n        pNode = 0;\n        continue;\n      }\n      for(jj=0; jj<nCell; jj++){\n        nodeGetCell(pRtree, pNode, jj, &aCell[jj]);\n      }\n    }\n#endif\n\n    /* Select the child node which will be enlarged the least if pCell\n    ** is inserted into it. Resolve ties by choosing the entry with\n    ** the smallest area.\n    */\n    for(iCell=0; iCell<nCell; iCell++){\n      int bBest = 0;\n      RtreeDValue growth;\n      RtreeDValue area;\n      nodeGetCell(pRtree, pNode, iCell, &cell);\n      growth = cellGrowth(pRtree, &cell, pCell);\n      area = cellArea(pRtree, &cell);\n\n#if VARIANT_RSTARTREE_CHOOSESUBTREE\n      if( ii==(pRtree->iDepth-1) ){\n        overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell);\n      }else{\n        overlap = 0.0;\n      }\n      if( (iCell==0) \n       || (overlap<fMinOverlap) \n       || (overlap==fMinOverlap && growth<fMinGrowth)\n       || (overlap==fMinOverlap && growth==fMinGrowth && area<fMinArea)\n      ){\n        bBest = 1;\n        fMinOverlap = overlap;\n      }\n#else\n      if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){\n        bBest = 1;\n      }\n#endif\n      if( bBest ){\n        fMinGrowth = growth;\n        fMinArea = area;\n        iBest = cell.iRowid;\n      }\n    }\n\n    sqlite3_free(aCell);\n    rc = nodeAcquire(pRtree, iBest, pNode, &pChild);\n    nodeRelease(pRtree, pNode);\n    pNode = pChild;\n  }\n\n  *ppLeaf = pNode;\n  return rc;\n}\n\n/*\n** A cell with the same content as pCell has just been inserted into\n** the node pNode. This function updates the bounding box cells in\n** all ancestor elements.\n*/\nstatic int AdjustTree(\n  Rtree *pRtree,                    /* Rtree table */\n  RtreeNode *pNode,                 /* Adjust ancestry of this node. */\n  RtreeCell *pCell                  /* This cell was just inserted */\n){\n  RtreeNode *p = pNode;\n  while( p->pParent ){\n    RtreeNode *pParent = p->pParent;\n    RtreeCell cell;\n    int iCell;\n\n    if( nodeParentIndex(pRtree, p, &iCell) ){\n      return SQLITE_CORRUPT_VTAB;\n    }\n\n    nodeGetCell(pRtree, pParent, iCell, &cell);\n    if( !cellContains(pRtree, &cell, pCell) ){\n      cellUnion(pRtree, &cell, pCell);\n      nodeOverwriteCell(pRtree, pParent, &cell, iCell);\n    }\n \n    p = pParent;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Write mapping (iRowid->iNode) to the <rtree>_rowid table.\n*/\nstatic int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){\n  sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid);\n  sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode);\n  sqlite3_step(pRtree->pWriteRowid);\n  return sqlite3_reset(pRtree->pWriteRowid);\n}\n\n/*\n** Write mapping (iNode->iPar) to the <rtree>_parent table.\n*/\nstatic int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){\n  sqlite3_bind_int64(pRtree->pWriteParent, 1, iNode);\n  sqlite3_bind_int64(pRtree->pWriteParent, 2, iPar);\n  sqlite3_step(pRtree->pWriteParent);\n  return sqlite3_reset(pRtree->pWriteParent);\n}\n\nstatic int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int);\n\n#if VARIANT_GUTTMAN_LINEAR_SPLIT\n/*\n** Implementation of the linear variant of the PickNext() function from\n** Guttman[84].\n*/\nstatic RtreeCell *LinearPickNext(\n  Rtree *pRtree,\n  RtreeCell *aCell, \n  int nCell, \n  RtreeCell *pLeftBox, \n  RtreeCell *pRightBox,\n  int *aiUsed\n){\n  int ii;\n  for(ii=0; aiUsed[ii]; ii++);\n  aiUsed[ii] = 1;\n  return &aCell[ii];\n}\n\n/*\n** Implementation of the linear variant of the PickSeeds() function from\n** Guttman[84].\n*/\nstatic void LinearPickSeeds(\n  Rtree *pRtree,\n  RtreeCell *aCell, \n  int nCell, \n  int *piLeftSeed, \n  int *piRightSeed\n){\n  int i;\n  int iLeftSeed = 0;\n  int iRightSeed = 1;\n  RtreeDValue maxNormalInnerWidth = (RtreeDValue)0;\n\n  /* Pick two \"seed\" cells from the array of cells. The algorithm used\n  ** here is the LinearPickSeeds algorithm from Gutman[1984]. The \n  ** indices of the two seed cells in the array are stored in local\n  ** variables iLeftSeek and iRightSeed.\n  */\n  for(i=0; i<pRtree->nDim; i++){\n    RtreeDValue x1 = DCOORD(aCell[0].aCoord[i*2]);\n    RtreeDValue x2 = DCOORD(aCell[0].aCoord[i*2+1]);\n    RtreeDValue x3 = x1;\n    RtreeDValue x4 = x2;\n    int jj;\n\n    int iCellLeft = 0;\n    int iCellRight = 0;\n\n    for(jj=1; jj<nCell; jj++){\n      RtreeDValue left = DCOORD(aCell[jj].aCoord[i*2]);\n      RtreeDValue right = DCOORD(aCell[jj].aCoord[i*2+1]);\n\n      if( left<x1 ) x1 = left;\n      if( right>x4 ) x4 = right;\n      if( left>x3 ){\n        x3 = left;\n        iCellRight = jj;\n      }\n      if( right<x2 ){\n        x2 = right;\n        iCellLeft = jj;\n      }\n    }\n\n    if( x4!=x1 ){\n      RtreeDValue normalwidth = (x3 - x2) / (x4 - x1);\n      if( normalwidth>maxNormalInnerWidth ){\n        iLeftSeed = iCellLeft;\n        iRightSeed = iCellRight;\n      }\n    }\n  }\n\n  *piLeftSeed = iLeftSeed;\n  *piRightSeed = iRightSeed;\n}\n#endif /* VARIANT_GUTTMAN_LINEAR_SPLIT */\n\n#if VARIANT_GUTTMAN_QUADRATIC_SPLIT\n/*\n** Implementation of the quadratic variant of the PickNext() function from\n** Guttman[84].\n*/\nstatic RtreeCell *QuadraticPickNext(\n  Rtree *pRtree,\n  RtreeCell *aCell, \n  int nCell, \n  RtreeCell *pLeftBox, \n  RtreeCell *pRightBox,\n  int *aiUsed\n){\n  #define FABS(a) ((a)<0.0?-1.0*(a):(a))\n\n  int iSelect = -1;\n  RtreeDValue fDiff;\n  int ii;\n  for(ii=0; ii<nCell; ii++){\n    if( aiUsed[ii]==0 ){\n      RtreeDValue left = cellGrowth(pRtree, pLeftBox, &aCell[ii]);\n      RtreeDValue right = cellGrowth(pRtree, pLeftBox, &aCell[ii]);\n      RtreeDValue diff = FABS(right-left);\n      if( iSelect<0 || diff>fDiff ){\n        fDiff = diff;\n        iSelect = ii;\n      }\n    }\n  }\n  aiUsed[iSelect] = 1;\n  return &aCell[iSelect];\n}\n\n/*\n** Implementation of the quadratic variant of the PickSeeds() function from\n** Guttman[84].\n*/\nstatic void QuadraticPickSeeds(\n  Rtree *pRtree,\n  RtreeCell *aCell, \n  int nCell, \n  int *piLeftSeed, \n  int *piRightSeed\n){\n  int ii;\n  int jj;\n\n  int iLeftSeed = 0;\n  int iRightSeed = 1;\n  RtreeDValue fWaste = 0.0;\n\n  for(ii=0; ii<nCell; ii++){\n    for(jj=ii+1; jj<nCell; jj++){\n      RtreeDValue right = cellArea(pRtree, &aCell[jj]);\n      RtreeDValue growth = cellGrowth(pRtree, &aCell[ii], &aCell[jj]);\n      RtreeDValue waste = growth - right;\n\n      if( waste>fWaste ){\n        iLeftSeed = ii;\n        iRightSeed = jj;\n        fWaste = waste;\n      }\n    }\n  }\n\n  *piLeftSeed = iLeftSeed;\n  *piRightSeed = iRightSeed;\n}\n#endif /* VARIANT_GUTTMAN_QUADRATIC_SPLIT */\n\n/*\n** Arguments aIdx, aDistance and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to the indexed values in aDistance. For\n** example, assuming the inputs:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**   aDistance = { 5.0, 2.0, 7.0, 6.0 }\n**\n** this function sets the aIdx array to contain:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDistance(\n  int *aIdx, \n  int nIdx, \n  RtreeDValue *aDistance, \n  int *aSpare\n){\n  if( nIdx>1 ){\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDistance(aLeft, nLeft, aDistance, aSpare);\n    SortByDistance(aRight, nRight, aDistance, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n\n    while( iLeft<nLeft || iRight<nRight ){\n      if( iLeft==nLeft ){\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }else if( iRight==nRight ){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        RtreeDValue fLeft = aDistance[aLeft[iLeft]];\n        RtreeDValue fRight = aDistance[aRight[iRight]];\n        if( fLeft<fRight ){\n          aIdx[iLeft+iRight] = aLeft[iLeft];\n          iLeft++;\n        }else{\n          aIdx[iLeft+iRight] = aRight[iRight];\n          iRight++;\n        }\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue left = aDistance[aIdx[jj-1]];\n        RtreeDValue right = aDistance[aIdx[jj]];\n        assert( left<=right );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Arguments aIdx, aCell and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to dimension iDim of the cells in aCell. The\n** minimum value of dimension iDim is considered first, the\n** maximum used to break ties.\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDimension(\n  Rtree *pRtree,\n  int *aIdx, \n  int nIdx, \n  int iDim, \n  RtreeCell *aCell, \n  int *aSpare\n){\n  if( nIdx>1 ){\n\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDimension(pRtree, aLeft, nLeft, iDim, aCell, aSpare);\n    SortByDimension(pRtree, aRight, nRight, iDim, aCell, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n    while( iLeft<nLeft || iRight<nRight ){\n      RtreeDValue xleft1 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2]);\n      RtreeDValue xleft2 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2+1]);\n      RtreeDValue xright1 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2]);\n      RtreeDValue xright2 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2+1]);\n      if( (iLeft!=nLeft) && ((iRight==nRight)\n       || (xleft1<xright1)\n       || (xleft1==xright1 && xleft2<xright2)\n      )){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue xleft1 = aCell[aIdx[jj-1]].aCoord[iDim*2];\n        RtreeDValue xleft2 = aCell[aIdx[jj-1]].aCoord[iDim*2+1];\n        RtreeDValue xright1 = aCell[aIdx[jj]].aCoord[iDim*2];\n        RtreeDValue xright2 = aCell[aIdx[jj]].aCoord[iDim*2+1];\n        assert( xleft1<=xright1 && (xleft1<xright1 || xleft2<=xright2) );\n      }\n    }\n#endif\n  }\n}\n\n#if VARIANT_RSTARTREE_SPLIT\n/*\n** Implementation of the R*-tree variant of SplitNode from Beckman[1990].\n*/\nstatic int splitNodeStartree(\n  Rtree *pRtree,\n  RtreeCell *aCell,\n  int nCell,\n  RtreeNode *pLeft,\n  RtreeNode *pRight,\n  RtreeCell *pBboxLeft,\n  RtreeCell *pBboxRight\n){\n  int **aaSorted;\n  int *aSpare;\n  int ii;\n\n  int iBestDim = 0;\n  int iBestSplit = 0;\n  RtreeDValue fBestMargin = 0.0;\n\n  int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));\n\n  aaSorted = (int **)sqlite3_malloc(nByte);\n  if( !aaSorted ){\n    return SQLITE_NOMEM;\n  }\n\n  aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell];\n  memset(aaSorted, 0, nByte);\n  for(ii=0; ii<pRtree->nDim; ii++){\n    int jj;\n    aaSorted[ii] = &((int *)&aaSorted[pRtree->nDim])[ii*nCell];\n    for(jj=0; jj<nCell; jj++){\n      aaSorted[ii][jj] = jj;\n    }\n    SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);\n  }\n\n  for(ii=0; ii<pRtree->nDim; ii++){\n    RtreeDValue margin = 0.0;\n    RtreeDValue fBestOverlap = 0.0;\n    RtreeDValue fBestArea = 0.0;\n    int iBestLeft = 0;\n    int nLeft;\n\n    for(\n      nLeft=RTREE_MINCELLS(pRtree); \n      nLeft<=(nCell-RTREE_MINCELLS(pRtree)); \n      nLeft++\n    ){\n      RtreeCell left;\n      RtreeCell right;\n      int kk;\n      RtreeDValue overlap;\n      RtreeDValue area;\n\n      memcpy(&left, &aCell[aaSorted[ii][0]], sizeof(RtreeCell));\n      memcpy(&right, &aCell[aaSorted[ii][nCell-1]], sizeof(RtreeCell));\n      for(kk=1; kk<(nCell-1); kk++){\n        if( kk<nLeft ){\n          cellUnion(pRtree, &left, &aCell[aaSorted[ii][kk]]);\n        }else{\n          cellUnion(pRtree, &right, &aCell[aaSorted[ii][kk]]);\n        }\n      }\n      margin += cellMargin(pRtree, &left);\n      margin += cellMargin(pRtree, &right);\n      overlap = cellOverlap(pRtree, &left, &right, 1, -1);\n      area = cellArea(pRtree, &left) + cellArea(pRtree, &right);\n      if( (nLeft==RTREE_MINCELLS(pRtree))\n       || (overlap<fBestOverlap)\n       || (overlap==fBestOverlap && area<fBestArea)\n      ){\n        iBestLeft = nLeft;\n        fBestOverlap = overlap;\n        fBestArea = area;\n      }\n    }\n\n    if( ii==0 || margin<fBestMargin ){\n      iBestDim = ii;\n      fBestMargin = margin;\n      iBestSplit = iBestLeft;\n    }\n  }\n\n  memcpy(pBboxLeft, &aCell[aaSorted[iBestDim][0]], sizeof(RtreeCell));\n  memcpy(pBboxRight, &aCell[aaSorted[iBestDim][iBestSplit]], sizeof(RtreeCell));\n  for(ii=0; ii<nCell; ii++){\n    RtreeNode *pTarget = (ii<iBestSplit)?pLeft:pRight;\n    RtreeCell *pBbox = (ii<iBestSplit)?pBboxLeft:pBboxRight;\n    RtreeCell *pCell = &aCell[aaSorted[iBestDim][ii]];\n    nodeInsertCell(pRtree, pTarget, pCell);\n    cellUnion(pRtree, pBbox, pCell);\n  }\n\n  sqlite3_free(aaSorted);\n  return SQLITE_OK;\n}\n#endif\n\n#if VARIANT_GUTTMAN_SPLIT\n/*\n** Implementation of the regular R-tree SplitNode from Guttman[1984].\n*/\nstatic int splitNodeGuttman(\n  Rtree *pRtree,\n  RtreeCell *aCell,\n  int nCell,\n  RtreeNode *pLeft,\n  RtreeNode *pRight,\n  RtreeCell *pBboxLeft,\n  RtreeCell *pBboxRight\n){\n  int iLeftSeed = 0;\n  int iRightSeed = 1;\n  int *aiUsed;\n  int i;\n\n  aiUsed = sqlite3_malloc(sizeof(int)*nCell);\n  if( !aiUsed ){\n    return SQLITE_NOMEM;\n  }\n  memset(aiUsed, 0, sizeof(int)*nCell);\n\n  PickSeeds(pRtree, aCell, nCell, &iLeftSeed, &iRightSeed);\n\n  memcpy(pBboxLeft, &aCell[iLeftSeed], sizeof(RtreeCell));\n  memcpy(pBboxRight, &aCell[iRightSeed], sizeof(RtreeCell));\n  nodeInsertCell(pRtree, pLeft, &aCell[iLeftSeed]);\n  nodeInsertCell(pRtree, pRight, &aCell[iRightSeed]);\n  aiUsed[iLeftSeed] = 1;\n  aiUsed[iRightSeed] = 1;\n\n  for(i=nCell-2; i>0; i--){\n    RtreeCell *pNext;\n    pNext = PickNext(pRtree, aCell, nCell, pBboxLeft, pBboxRight, aiUsed);\n    RtreeDValue diff =  \n      cellGrowth(pRtree, pBboxLeft, pNext) - \n      cellGrowth(pRtree, pBboxRight, pNext)\n    ;\n    if( (RTREE_MINCELLS(pRtree)-NCELL(pRight)==i)\n     || (diff>0.0 && (RTREE_MINCELLS(pRtree)-NCELL(pLeft)!=i))\n    ){\n      nodeInsertCell(pRtree, pRight, pNext);\n      cellUnion(pRtree, pBboxRight, pNext);\n    }else{\n      nodeInsertCell(pRtree, pLeft, pNext);\n      cellUnion(pRtree, pBboxLeft, pNext);\n    }\n  }\n\n  sqlite3_free(aiUsed);\n  return SQLITE_OK;\n}\n#endif\n\nstatic int updateMapping(\n  Rtree *pRtree, \n  i64 iRowid, \n  RtreeNode *pNode, \n  int iHeight\n){\n  int (*xSetMapping)(Rtree *, sqlite3_int64, sqlite3_int64);\n  xSetMapping = ((iHeight==0)?rowidWrite:parentWrite);\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  return xSetMapping(pRtree, iRowid, pNode->iNode);\n}\n\nstatic int SplitNode(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int i;\n  int newCellIsRight = 0;\n\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n  RtreeCell *aCell;\n  int *aiUsed;\n\n  RtreeNode *pLeft = 0;\n  RtreeNode *pRight = 0;\n\n  RtreeCell leftbbox;\n  RtreeCell rightbbox;\n\n  /* Allocate an array and populate it with a copy of pCell and \n  ** all cells from node pLeft. Then zero the original node.\n  */\n  aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));\n  if( !aCell ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n  aiUsed = (int *)&aCell[nCell+1];\n  memset(aiUsed, 0, sizeof(int)*(nCell+1));\n  for(i=0; i<nCell; i++){\n    nodeGetCell(pRtree, pNode, i, &aCell[i]);\n  }\n  nodeZero(pRtree, pNode);\n  memcpy(&aCell[nCell], pCell, sizeof(RtreeCell));\n  nCell++;\n\n  if( pNode->iNode==1 ){\n    pRight = nodeNew(pRtree, pNode);\n    pLeft = nodeNew(pRtree, pNode);\n    pRtree->iDepth++;\n    pNode->isDirty = 1;\n    writeInt16(pNode->zData, pRtree->iDepth);\n  }else{\n    pLeft = pNode;\n    pRight = nodeNew(pRtree, pLeft->pParent);\n    nodeReference(pLeft);\n  }\n\n  if( !pLeft || !pRight ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n\n  memset(pLeft->zData, 0, pRtree->iNodeSize);\n  memset(pRight->zData, 0, pRtree->iNodeSize);\n\n  rc = AssignCells(pRtree, aCell, nCell, pLeft, pRight, &leftbbox, &rightbbox);\n  if( rc!=SQLITE_OK ){\n    goto splitnode_out;\n  }\n\n  /* Ensure both child nodes have node numbers assigned to them by calling\n  ** nodeWrite(). Node pRight always needs a node number, as it was created\n  ** by nodeNew() above. But node pLeft sometimes already has a node number.\n  ** In this case avoid the all to nodeWrite().\n  */\n  if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))\n   || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))\n  ){\n    goto splitnode_out;\n  }\n\n  rightbbox.iRowid = pRight->iNode;\n  leftbbox.iRowid = pLeft->iNode;\n\n  if( pNode->iNode==1 ){\n    rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1);\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }else{\n    RtreeNode *pParent = pLeft->pParent;\n    int iCell;\n    rc = nodeParentIndex(pRtree, pLeft, &iCell);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);\n      rc = AdjustTree(pRtree, pParent, &leftbbox);\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){\n    goto splitnode_out;\n  }\n\n  for(i=0; i<NCELL(pRight); i++){\n    i64 iRowid = nodeGetRowid(pRtree, pRight, i);\n    rc = updateMapping(pRtree, iRowid, pRight, iHeight);\n    if( iRowid==pCell->iRowid ){\n      newCellIsRight = 1;\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( pNode->iNode==1 ){\n    for(i=0; i<NCELL(pLeft); i++){\n      i64 iRowid = nodeGetRowid(pRtree, pLeft, i);\n      rc = updateMapping(pRtree, iRowid, pLeft, iHeight);\n      if( rc!=SQLITE_OK ){\n        goto splitnode_out;\n      }\n    }\n  }else if( newCellIsRight==0 ){\n    rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRight);\n    pRight = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pLeft);\n    pLeft = 0;\n  }\n\nsplitnode_out:\n  nodeRelease(pRtree, pRight);\n  nodeRelease(pRtree, pLeft);\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** If node pLeaf is not the root of the r-tree and its pParent pointer is \n** still NULL, load all ancestor nodes of pLeaf into memory and populate\n** the pLeaf->pParent chain all the way up to the root node.\n**\n** This operation is required when a row is deleted (or updated - an update\n** is implemented as a delete followed by an insert). SQLite provides the\n** rowid of the row to delete, which can be used to find the leaf on which\n** the entry resides (argument pLeaf). Once the leaf is located, this \n** function is called to determine its ancestry.\n*/\nstatic int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){\n  int rc = SQLITE_OK;\n  RtreeNode *pChild = pLeaf;\n  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){\n    int rc2 = SQLITE_OK;          /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);\n    rc = sqlite3_step(pRtree->pReadParent);\n    if( rc==SQLITE_ROW ){\n      RtreeNode *pTest;           /* Used to test for reference loops */\n      i64 iNode;                  /* Node number of parent node */\n\n      /* Before setting pChild->pParent, test that we are not creating a\n      ** loop of references (as we would if, say, pChild==pParent). We don't\n      ** want to do this as it leads to a memory leak when trying to delete\n      ** the referenced counted node structures.\n      */\n      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);\n      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);\n      if( !pTest ){\n        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);\n      }\n    }\n    rc = sqlite3_reset(pRtree->pReadParent);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;\n    pChild = pChild->pParent;\n  }\n  return rc;\n}\n\nstatic int deleteCell(Rtree *, RtreeNode *, int, int);\n\nstatic int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){\n  int rc;\n  int rc2;\n  RtreeNode *pParent = 0;\n  int iCell;\n\n  assert( pNode->nRef==1 );\n\n  /* Remove the entry in the parent cell. */\n  rc = nodeParentIndex(pRtree, pNode, &iCell);\n  if( rc==SQLITE_OK ){\n    pParent = pNode->pParent;\n    pNode->pParent = 0;\n    rc = deleteCell(pRtree, pParent, iCell, iHeight+1);\n  }\n  rc2 = nodeRelease(pRtree, pParent);\n  if( rc==SQLITE_OK ){\n    rc = rc2;\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Remove the xxx_node entry. */\n  sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteNode);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){\n    return rc;\n  }\n\n  /* Remove the xxx_parent entry. */\n  sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteParent);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){\n    return rc;\n  }\n  \n  /* Remove the node from the in-memory hash table and link it into\n  ** the Rtree.pDeleted list. Its contents will be re-inserted later on.\n  */\n  nodeHashDelete(pRtree, pNode);\n  pNode->iNode = iHeight;\n  pNode->pNext = pRtree->pDeleted;\n  pNode->nRef++;\n  pRtree->pDeleted = pNode;\n\n  return SQLITE_OK;\n}\n\nstatic int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode *pParent = pNode->pParent;\n  int rc = SQLITE_OK; \n  if( pParent ){\n    int ii; \n    int nCell = NCELL(pNode);\n    RtreeCell box;                            /* Bounding box for pNode */\n    nodeGetCell(pRtree, pNode, 0, &box);\n    for(ii=1; ii<nCell; ii++){\n      RtreeCell cell;\n      nodeGetCell(pRtree, pNode, ii, &cell);\n      cellUnion(pRtree, &box, &cell);\n    }\n    box.iRowid = pNode->iNode;\n    rc = nodeParentIndex(pRtree, pNode, &ii);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &box, ii);\n      rc = fixBoundingBox(pRtree, pParent);\n    }\n  }\n  return rc;\n}\n\n/*\n** Delete the cell at index iCell of node pNode. After removing the\n** cell, adjust the r-tree data structure if required.\n*/\nstatic int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){\n  RtreeNode *pParent;\n  int rc;\n\n  if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){\n    return rc;\n  }\n\n  /* Remove the cell from the node. This call just moves bytes around\n  ** the in-memory node image, so it cannot fail.\n  */\n  nodeDeleteCell(pRtree, pNode, iCell);\n\n  /* If the node is not the tree root and now has less than the minimum\n  ** number of cells, remove it from the tree. Otherwise, update the\n  ** cell in the parent node so that it tightly contains the updated\n  ** node.\n  */\n  pParent = pNode->pParent;\n  assert( pParent || pNode->iNode==1 );\n  if( pParent ){\n    if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){\n      rc = removeNode(pRtree, pNode, iHeight);\n    }else{\n      rc = fixBoundingBox(pRtree, pNode);\n    }\n  }\n\n  return rc;\n}\n\nstatic int Reinsert(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  RtreeCell *pCell, \n  int iHeight\n){\n  int *aOrder;\n  int *aSpare;\n  RtreeCell *aCell;\n  RtreeDValue *aDistance;\n  int nCell;\n  RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS];\n  int iDim;\n  int ii;\n  int rc = SQLITE_OK;\n  int n;\n\n  memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS);\n\n  nCell = NCELL(pNode)+1;\n  n = (nCell+1)&(~1);\n\n  /* Allocate the buffers used by this operation. The allocation is\n  ** relinquished before this function returns.\n  */\n  aCell = (RtreeCell *)sqlite3_malloc(n * (\n    sizeof(RtreeCell)     +         /* aCell array */\n    sizeof(int)           +         /* aOrder array */\n    sizeof(int)           +         /* aSpare array */\n    sizeof(RtreeDValue)             /* aDistance array */\n  ));\n  if( !aCell ){\n    return SQLITE_NOMEM;\n  }\n  aOrder    = (int *)&aCell[n];\n  aSpare    = (int *)&aOrder[n];\n  aDistance = (RtreeDValue *)&aSpare[n];\n\n  for(ii=0; ii<nCell; ii++){\n    if( ii==(nCell-1) ){\n      memcpy(&aCell[ii], pCell, sizeof(RtreeCell));\n    }else{\n      nodeGetCell(pRtree, pNode, ii, &aCell[ii]);\n    }\n    aOrder[ii] = ii;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);\n    }\n  }\n  for(iDim=0; iDim<pRtree->nDim; iDim++){\n    aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2));\n  }\n\n  for(ii=0; ii<nCell; ii++){\n    aDistance[ii] = 0.0;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - \n                               DCOORD(aCell[ii].aCoord[iDim*2]));\n      aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);\n    }\n  }\n\n  SortByDistance(aOrder, nCell, aDistance, aSpare);\n  nodeZero(pRtree, pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){\n    RtreeCell *p = &aCell[aOrder[ii]];\n    nodeInsertCell(pRtree, pNode, p);\n    if( p->iRowid==pCell->iRowid ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, p->iRowid, pNode->iNode);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = fixBoundingBox(pRtree, pNode);\n  }\n  for(; rc==SQLITE_OK && ii<nCell; ii++){\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    RtreeNode *pInsert;\n    RtreeCell *p = &aCell[aOrder[ii]];\n    rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** Insert cell pCell into node pNode. Node pNode is the head of a \n** subtree iHeight high (leaf nodes have iHeight==0).\n*/\nstatic int rtreeInsertCell(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int rc = SQLITE_OK;\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  if( nodeInsertCell(pRtree, pNode, pCell) ){\n#if VARIANT_RSTARTREE_REINSERT\n    if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){\n      rc = SplitNode(pRtree, pNode, pCell, iHeight);\n    }else{\n      pRtree->iReinsertHeight = iHeight;\n      rc = Reinsert(pRtree, pNode, pCell, iHeight);\n    }\n#else\n    rc = SplitNode(pRtree, pNode, pCell, iHeight);\n#endif\n  }else{\n    rc = AdjustTree(pRtree, pNode, pCell);\n    if( rc==SQLITE_OK ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){\n  int ii;\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){\n    RtreeNode *pInsert;\n    RtreeCell cell;\n    nodeGetCell(pRtree, pNode, ii, &cell);\n\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Select a currently unused rowid for a new r-tree record.\n*/\nstatic int newRowid(Rtree *pRtree, i64 *piRowid){\n  int rc;\n  sqlite3_bind_null(pRtree->pWriteRowid, 1);\n  sqlite3_bind_null(pRtree->pWriteRowid, 2);\n  sqlite3_step(pRtree->pWriteRowid);\n  rc = sqlite3_reset(pRtree->pWriteRowid);\n  *piRowid = sqlite3_last_insert_rowid(pRtree->db);\n  return rc;\n}\n\n/*\n** Remove the entry with rowid=iDelete from the r-tree structure.\n*/\nstatic int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){\n  int rc;                         /* Return code */\n  RtreeNode *pLeaf = 0;           /* Leaf node containing record iDelete */\n  int iCell;                      /* Index of iDelete cell in pLeaf */\n  RtreeNode *pRoot;               /* Root node of rtree structure */\n\n\n  /* Obtain a reference to the root node to initialize Rtree.iDepth */\n  rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n\n  /* Obtain a reference to the leaf node that contains the entry \n  ** about to be deleted. \n  */\n  if( rc==SQLITE_OK ){\n    rc = findLeafNode(pRtree, iDelete, &pLeaf);\n  }\n\n  /* Delete the cell in question from the leaf node. */\n  if( rc==SQLITE_OK ){\n    int rc2;\n    rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);\n    if( rc==SQLITE_OK ){\n      rc = deleteCell(pRtree, pLeaf, iCell, 0);\n    }\n    rc2 = nodeRelease(pRtree, pLeaf);\n    if( rc==SQLITE_OK ){\n      rc = rc2;\n    }\n  }\n\n  /* Delete the corresponding entry in the <rtree>_rowid table. */\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pRtree->pDeleteRowid, 1, iDelete);\n    sqlite3_step(pRtree->pDeleteRowid);\n    rc = sqlite3_reset(pRtree->pDeleteRowid);\n  }\n\n  /* Check if the root node now has exactly one child. If so, remove\n  ** it, schedule the contents of the child for reinsertion and \n  ** reduce the tree height by one.\n  **\n  ** This is equivalent to copying the contents of the child into\n  ** the root node (the operation that Gutman's paper says to perform \n  ** in this scenario).\n  */\n  if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){\n    int rc2;\n    RtreeNode *pChild;\n    i64 iChild = nodeGetRowid(pRtree, pRoot, 0);\n    rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);\n    if( rc==SQLITE_OK ){\n      rc = removeNode(pRtree, pChild, pRtree->iDepth-1);\n    }\n    rc2 = nodeRelease(pRtree, pChild);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK ){\n      pRtree->iDepth--;\n      writeInt16(pRoot->zData, pRtree->iDepth);\n      pRoot->isDirty = 1;\n    }\n  }\n\n  /* Re-insert the contents of any underfull nodes removed from the tree. */\n  for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){\n    if( rc==SQLITE_OK ){\n      rc = reinsertNodeContent(pRtree, pLeaf);\n    }\n    pRtree->pDeleted = pLeaf->pNext;\n    sqlite3_free(pLeaf);\n  }\n\n  /* Release the reference to the root node. */\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRoot);\n  }else{\n    nodeRelease(pRtree, pRoot);\n  }\n\n  return rc;\n}\n\n/*\n** Rounding constants for float->double conversion.\n*/\n#define RNDTOWARDS  (1.0 - 1.0/8388608.0)  /* Round towards zero */\n#define RNDAWAY     (1.0 + 1.0/8388608.0)  /* Round away from zero */\n\n#if !defined(SQLITE_RTREE_INT_ONLY)\n/*\n** Convert an sqlite3_value into an RtreeValue (presumably a float)\n** while taking care to round toward negative or positive, respectively.\n*/\nstatic RtreeValue rtreeValueDown(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f>d ){\n    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));\n  }\n  return f;\n}\nstatic RtreeValue rtreeValueUp(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f<d ){\n    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));\n  }\n  return f;\n}\n#endif /* !defined(SQLITE_RTREE_INT_ONLY) */\n\n\n/*\n** The xUpdate method for rtree module virtual tables.\n*/\nstatic int rtreeUpdate(\n  sqlite3_vtab *pVtab, \n  int nData, \n  sqlite3_value **azData, \n  sqlite_int64 *pRowid\n){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_OK;\n  RtreeCell cell;                 /* New cell to insert if nData>1 */\n  int bHaveRowid = 0;             /* Set to 1 after new rowid is determined */\n\n  rtreeReference(pRtree);\n  assert(nData>=1);\n\n  /* Constraint handling. A write operation on an r-tree table may return\n  ** SQLITE_CONSTRAINT for two reasons:\n  **\n  **   1. A duplicate rowid value, or\n  **   2. The supplied data violates the \"x2>=x1\" constraint.\n  **\n  ** In the first case, if the conflict-handling mode is REPLACE, then\n  ** the conflicting row can be removed before proceeding. In the second\n  ** case, SQLITE_CONSTRAINT must be returned regardless of the\n  ** conflict-handling mode specified by the user.\n  */\n  if( nData>1 ){\n    int ii;\n\n    /* Populate the cell.aCoord[] array. The first coordinate is azData[3]. */\n    assert( nData==(pRtree->nDim*2 + 3) );\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n        cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);\n        cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);\n        if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){\n          rc = SQLITE_CONSTRAINT;\n          goto constraint;\n        }\n      }\n    }else\n#endif\n    {\n      for(ii=0; ii<(pRtree->nDim*2); ii+=2){\n        cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);\n        cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);\n        if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){\n          rc = SQLITE_CONSTRAINT;\n          goto constraint;\n        }\n      }\n    }\n\n    /* If a rowid value was supplied, check if it is already present in \n    ** the table. If so, the constraint has failed. */\n    if( sqlite3_value_type(azData[2])!=SQLITE_NULL ){\n      cell.iRowid = sqlite3_value_int64(azData[2]);\n      if( sqlite3_value_type(azData[0])==SQLITE_NULL\n       || sqlite3_value_int64(azData[0])!=cell.iRowid\n      ){\n        int steprc;\n        sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);\n        steprc = sqlite3_step(pRtree->pReadRowid);\n        rc = sqlite3_reset(pRtree->pReadRowid);\n        if( SQLITE_ROW==steprc ){\n          if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){\n            rc = rtreeDeleteRowid(pRtree, cell.iRowid);\n          }else{\n            rc = SQLITE_CONSTRAINT;\n            goto constraint;\n          }\n        }\n      }\n      bHaveRowid = 1;\n    }\n  }\n\n  /* If azData[0] is not an SQL NULL value, it is the rowid of a\n  ** record to delete from the r-tree table. The following block does\n  ** just that.\n  */\n  if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){\n    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(azData[0]));\n  }\n\n  /* If the azData[] array contains more than one element, elements\n  ** (azData[2]..azData[argc-1]) contain a new record to insert into\n  ** the r-tree structure.\n  */\n  if( rc==SQLITE_OK && nData>1 ){\n    /* Insert the new record into the r-tree */\n    RtreeNode *pLeaf = 0;\n\n    /* Figure out the rowid of the new row. */\n    if( bHaveRowid==0 ){\n      rc = newRowid(pRtree, &cell.iRowid);\n    }\n    *pRowid = cell.iRowid;\n\n    if( rc==SQLITE_OK ){\n      rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);\n    }\n    if( rc==SQLITE_OK ){\n      int rc2;\n      pRtree->iReinsertHeight = -1;\n      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);\n      rc2 = nodeRelease(pRtree, pLeaf);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\nconstraint:\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** The xRename method for rtree module virtual tables.\n*/\nstatic int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_node'   RENAME TO \\\"%w_node\\\";\"\n    \"ALTER TABLE %Q.'%q_parent' RENAME TO \\\"%w_parent\\\";\"\n    \"ALTER TABLE %Q.'%q_rowid'  RENAME TO \\\"%w_rowid\\\";\"\n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName\n  );\n  if( zSql ){\n    rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\nstatic sqlite3_module rtreeModule = {\n  0,                          /* iVersion */\n  rtreeCreate,                /* xCreate - create a table */\n  rtreeConnect,               /* xConnect - connect to an existing table */\n  rtreeBestIndex,             /* xBestIndex - Determine search strategy */\n  rtreeDisconnect,            /* xDisconnect - Disconnect from a table */\n  rtreeDestroy,               /* xDestroy - Drop a table */\n  rtreeOpen,                  /* xOpen - open a cursor */\n  rtreeClose,                 /* xClose - close a cursor */\n  rtreeFilter,                /* xFilter - configure scan constraints */\n  rtreeNext,                  /* xNext - advance a cursor */\n  rtreeEof,                   /* xEof */\n  rtreeColumn,                /* xColumn - read data */\n  rtreeRowid,                 /* xRowid - read data */\n  rtreeUpdate,                /* xUpdate - write data */\n  0,                          /* xBegin - begin transaction */\n  0,                          /* xSync - sync transaction */\n  0,                          /* xCommit - commit transaction */\n  0,                          /* xRollback - rollback transaction */\n  0,                          /* xFindFunction - function overloading */\n  rtreeRename,                /* xRename - rename the table */\n  0,                          /* xSavepoint */\n  0,                          /* xRelease */\n  0                           /* xRollbackTo */\n};\n\nstatic int rtreeSqlInit(\n  Rtree *pRtree, \n  sqlite3 *db, \n  const char *zDb, \n  const char *zPrefix, \n  int isCreate\n){\n  int rc = SQLITE_OK;\n\n  #define N_STATEMENT 9\n  static const char *azSql[N_STATEMENT] = {\n    /* Read and write the xxx_node table */\n    \"SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_node' WHERE nodeno = :1\",\n\n    /* Read and write the xxx_rowid table */\n    \"SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n\n    /* Read and write the xxx_parent table */\n    \"SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1\"\n  };\n  sqlite3_stmt **appStmt[N_STATEMENT];\n  int i;\n\n  pRtree->db = db;\n\n  if( isCreate ){\n    char *zCreate = sqlite3_mprintf(\n\"CREATE TABLE \\\"%w\\\".\\\"%w_node\\\"(nodeno INTEGER PRIMARY KEY, data BLOB);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_rowid\\\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_parent\\\"(nodeno INTEGER PRIMARY KEY, parentnode INTEGER);\"\n\"INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))\",\n      zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize\n    );\n    if( !zCreate ){\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_exec(db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  appStmt[0] = &pRtree->pReadNode;\n  appStmt[1] = &pRtree->pWriteNode;\n  appStmt[2] = &pRtree->pDeleteNode;\n  appStmt[3] = &pRtree->pReadRowid;\n  appStmt[4] = &pRtree->pWriteRowid;\n  appStmt[5] = &pRtree->pDeleteRowid;\n  appStmt[6] = &pRtree->pReadParent;\n  appStmt[7] = &pRtree->pWriteParent;\n  appStmt[8] = &pRtree->pDeleteParent;\n\n  for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){\n    char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);\n    if( zSql ){\n      rc = sqlite3_prepare_v2(db, zSql, -1, appStmt[i], 0); \n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\n/*\n** The second argument to this function contains the text of an SQL statement\n** that returns a single integer value. The statement is compiled and executed\n** using database connection db. If successful, the integer value returned\n** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error\n** code is returned and the value of *piVal after returning is not defined.\n*/\nstatic int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){\n  int rc = SQLITE_NOMEM;\n  if( zSql ){\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *piVal = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called from within the xConnect() or xCreate() method to\n** determine the node-size used by the rtree table being created or connected\n** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned.\n**\n** If this function is being called as part of an xConnect(), then the rtree\n** table already exists. In this case the node-size is determined by inspecting\n** the root node of the tree.\n**\n** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. \n** This ensures that each node is stored on a single database page. If the \n** database page-size is so large that more than RTREE_MAXCELLS entries \n** would fit in a single node, use a smaller node-size.\n*/\nstatic int getNodeSize(\n  sqlite3 *db,                    /* Database handle */\n  Rtree *pRtree,                  /* Rtree handle */\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  char **pzErr                    /* OUT: Error message, if any */\n){\n  int rc;\n  char *zSql;\n  if( isCreate ){\n    int iPageSize = 0;\n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", pRtree->zDb);\n    rc = getIntFromStmt(db, zSql, &iPageSize);\n    if( rc==SQLITE_OK ){\n      pRtree->iNodeSize = iPageSize-64;\n      if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){\n        pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS;\n      }\n    }else{\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }else{\n    zSql = sqlite3_mprintf(\n        \"SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\",\n        pRtree->zDb, pRtree->zName\n    );\n    rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/* \n** This function is the implementation of both the xConnect and xCreate\n** methods of the r-tree virtual table.\n**\n**   argv[0]   -> module name\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> column names...\n*/\nstatic int rtreeInit(\n  sqlite3 *db,                        /* Database connection */\n  void *pAux,                         /* One of the RTREE_COORD_* constants */\n  int argc, const char *const*argv,   /* Parameters to CREATE TABLE statement */\n  sqlite3_vtab **ppVtab,              /* OUT: New virtual table */\n  char **pzErr,                       /* OUT: Error message, if any */\n  int isCreate                        /* True for xCreate, false for xConnect */\n){\n  int rc = SQLITE_OK;\n  Rtree *pRtree;\n  int nDb;              /* Length of string argv[1] */\n  int nName;            /* Length of string argv[2] */\n  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);\n\n  const char *aErrMsg[] = {\n    0,                                                    /* 0 */\n    \"Wrong number of columns for an rtree table\",         /* 1 */\n    \"Too few columns for an rtree table\",                 /* 2 */\n    \"Too many columns for an rtree table\"                 /* 3 */\n  };\n\n  int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2;\n  if( aErrMsg[iErr] ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[iErr]);\n    return SQLITE_ERROR;\n  }\n\n  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n  /* Allocate the sqlite3_vtab structure */\n  nDb = (int)strlen(argv[1]);\n  nName = (int)strlen(argv[2]);\n  pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);\n  if( !pRtree ){\n    return SQLITE_NOMEM;\n  }\n  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);\n  pRtree->nBusy = 1;\n  pRtree->base.pModule = &rtreeModule;\n  pRtree->zDb = (char *)&pRtree[1];\n  pRtree->zName = &pRtree->zDb[nDb+1];\n  pRtree->nDim = (argc-4)/2;\n  pRtree->nBytesPerCell = 8 + pRtree->nDim*4*2;\n  pRtree->eCoordType = eCoordType;\n  memcpy(pRtree->zDb, argv[1], nDb);\n  memcpy(pRtree->zName, argv[2], nName);\n\n  /* Figure out the node size to use. */\n  rc = getNodeSize(db, pRtree, isCreate, pzErr);\n\n  /* Create/Connect to the underlying relational database schema. If\n  ** that is successful, call sqlite3_declare_vtab() to configure\n  ** the r-tree table schema.\n  */\n  if( rc==SQLITE_OK ){\n    if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else{\n      char *zSql = sqlite3_mprintf(\"CREATE TABLE x(%s\", argv[3]);\n      char *zTmp;\n      int ii;\n      for(ii=4; zSql && ii<argc; ii++){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s, %s\", zTmp, argv[ii]);\n        sqlite3_free(zTmp);\n      }\n      if( zSql ){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s);\", zTmp);\n        sqlite3_free(zTmp);\n      }\n      if( !zSql ){\n        rc = SQLITE_NOMEM;\n      }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){\n        *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      }\n      sqlite3_free(zSql);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    *ppVtab = (sqlite3_vtab *)pRtree;\n  }else{\n    rtreeRelease(pRtree);\n  }\n  return rc;\n}\n\n\n/*\n** Implementation of a scalar function that decodes r-tree nodes to\n** human readable strings. This can be used for debugging and analysis.\n**\n** The scalar function takes two arguments, a blob of data containing\n** an r-tree node, and the number of dimensions the r-tree indexes.\n** For a two-dimensional r-tree structure called \"rt\", to deserialize\n** all nodes, a statement like:\n**\n**   SELECT rtreenode(2, data) FROM rt_node;\n**\n** The human readable string takes the form of a Tcl list with one\n** entry for each cell in the r-tree node. Each entry is itself a\n** list, containing the 8-byte rowid/pageno followed by the \n** <num-dimension>*2 coordinates.\n*/\nstatic void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  char *zText = 0;\n  RtreeNode node;\n  Rtree tree;\n  int ii;\n\n  UNUSED_PARAMETER(nArg);\n  memset(&node, 0, sizeof(RtreeNode));\n  memset(&tree, 0, sizeof(Rtree));\n  tree.nDim = sqlite3_value_int(apArg[0]);\n  tree.nBytesPerCell = 8 + 8 * tree.nDim;\n  node.zData = (u8 *)sqlite3_value_blob(apArg[1]);\n\n  for(ii=0; ii<NCELL(&node); ii++){\n    char zCell[512];\n    int nCell = 0;\n    RtreeCell cell;\n    int jj;\n\n    nodeGetCell(&tree, &node, ii, &cell);\n    sqlite3_snprintf(512-nCell,&zCell[nCell],\"%lld\", cell.iRowid);\n    nCell = (int)strlen(zCell);\n    for(jj=0; jj<tree.nDim*2; jj++){\n#ifndef SQLITE_RTREE_INT_ONLY\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %f\",\n                       (double)cell.aCoord[jj].f);\n#else\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %d\",\n                       cell.aCoord[jj].i);\n#endif\n      nCell = (int)strlen(zCell);\n    }\n\n    if( zText ){\n      char *zTextNew = sqlite3_mprintf(\"%s {%s}\", zText, zCell);\n      sqlite3_free(zText);\n      zText = zTextNew;\n    }else{\n      zText = sqlite3_mprintf(\"{%s}\", zCell);\n    }\n  }\n  \n  sqlite3_result_text(ctx, zText, -1, sqlite3_free);\n}\n\nstatic void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  UNUSED_PARAMETER(nArg);\n  if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB \n   || sqlite3_value_bytes(apArg[0])<2\n  ){\n    sqlite3_result_error(ctx, \"Invalid argument to rtreedepth()\", -1); \n  }else{\n    u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);\n    sqlite3_result_int(ctx, readInt16(zBlob));\n  }\n}\n\n/*\n** Register the r-tree module with database handle db. This creates the\n** virtual table module \"rtree\" and the debugging/analysis scalar \n** function \"rtreenode\".\n*/\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){\n  const int utf8 = SQLITE_UTF8;\n  int rc;\n\n  rc = sqlite3_create_function(db, \"rtreenode\", 2, utf8, 0, rtreenode, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"rtreedepth\", 1, utf8, 0,rtreedepth, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n#ifdef SQLITE_RTREE_INT_ONLY\n    void *c = (void *)RTREE_COORD_INT32;\n#else\n    void *c = (void *)RTREE_COORD_REAL32;\n#endif\n    rc = sqlite3_create_module_v2(db, \"rtree\", &rtreeModule, c, 0);\n  }\n  if( rc==SQLITE_OK ){\n    void *c = (void *)RTREE_COORD_INT32;\n    rc = sqlite3_create_module_v2(db, \"rtree_i32\", &rtreeModule, c, 0);\n  }\n\n  return rc;\n}\n\n/*\n** A version of sqlite3_free() that can be used as a callback. This is used\n** in two places - as the destructor for the blob value returned by the\n** invocation of a geometry function, and as the destructor for the geometry\n** functions themselves.\n*/\nstatic void doSqlite3Free(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite\n** scalar user function. This C function is the callback used for all such\n** registered SQL functions.\n**\n** The scalar user functions return a blob that is interpreted by r-tree\n** table MATCH operators.\n*/\nstatic void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n  RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);\n  RtreeMatchArg *pBlob;\n  int nBlob;\n\n  nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue);\n  pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);\n  if( !pBlob ){\n    sqlite3_result_error_nomem(ctx);\n  }else{\n    int i;\n    pBlob->magic = RTREE_GEOMETRY_MAGIC;\n    pBlob->xGeom = pGeomCtx->xGeom;\n    pBlob->pContext = pGeomCtx->pContext;\n    pBlob->nParam = nArg;\n    for(i=0; i<nArg; i++){\n#ifdef SQLITE_RTREE_INT_ONLY\n      pBlob->aParam[i] = sqlite3_value_int64(aArg[i]);\n#else\n      pBlob->aParam[i] = sqlite3_value_double(aArg[i]);\n#endif\n    }\n    sqlite3_result_blob(ctx, pBlob, nBlob, doSqlite3Free);\n  }\n}\n\n/*\n** Register a new geometry function for use with the r-tree MATCH operator.\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry *, int, RtreeDValue *, int *),\n  void *pContext\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = xGeom;\n  pGeomCtx->pContext = pContext;\n\n  /* Create the new user-function. Register a destructor function to delete\n  ** the context object when it is no longer required.  */\n  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, doSqlite3Free\n  );\n}\n\n#if !SQLITE_CORE\nSQLITE_API int sqlite3_extension_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3RtreeInit(db);\n}\n#endif\n\n#endif\n\n/************** End of rtree.c ***********************************************/\n/************** Begin file icu.c *********************************************/\n/*\n** 2007 May 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $\n**\n** This file implements an integration between the ICU library \n** (\"International Components for Unicode\", an open-source library \n** for handling unicode data) and SQLite. The integration uses \n** ICU to provide the following to SQLite:\n**\n**   * An implementation of the SQL regexp() function (and hence REGEXP\n**     operator) using the ICU uregex_XX() APIs.\n**\n**   * Implementations of the SQL scalar upper() and lower() functions\n**     for case mapping.\n**\n**   * Integration of ICU and SQLite collation seqences.\n**\n**   * An implementation of the LIKE operator that uses ICU to \n**     provide case-independent matching.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)\n\n/* Include ICU headers */\n#include <unicode/utypes.h>\n#include <unicode/uregex.h>\n#include <unicode/ustring.h>\n#include <unicode/ucol.h>\n\n/* #include <assert.h> */\n\n#ifndef SQLITE_CORE\n  SQLITE_EXTENSION_INIT1\n#else\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Version of sqlite3_free() that is always a function, never a macro.\n*/\nstatic void xFree(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a \"LIKE\" expression. Return true (1) if they are the same and \n** false (0) if they are different.\n*/\nstatic int icuLikeCompare(\n  const uint8_t *zPattern,   /* LIKE pattern */\n  const uint8_t *zString,    /* The UTF-8 string to compare against */\n  const UChar32 uEsc         /* The escape character */\n){\n  static const int MATCH_ONE = (UChar32)'_';\n  static const int MATCH_ALL = (UChar32)'%';\n\n  int iPattern = 0;       /* Current byte index in zPattern */\n  int iString = 0;        /* Current byte index in zString */\n\n  int prevEscape = 0;     /* True if the previous character was uEsc */\n\n  while( zPattern[iPattern]!=0 ){\n\n    /* Read (and consume) the next character from the input pattern. */\n    UChar32 uPattern;\n    U8_NEXT_UNSAFE(zPattern, iPattern, uPattern);\n    assert(uPattern!=0);\n\n    /* There are now 4 possibilities:\n    **\n    **     1. uPattern is an unescaped match-all character \"%\",\n    **     2. uPattern is an unescaped match-one character \"_\",\n    **     3. uPattern is an unescaped escape character, or\n    **     4. uPattern is to be handled as an ordinary character\n    */\n    if( !prevEscape && uPattern==MATCH_ALL ){\n      /* Case 1. */\n      uint8_t c;\n\n      /* Skip any MATCH_ALL or MATCH_ONE characters that follow a\n      ** MATCH_ALL. For each MATCH_ONE, skip one character in the \n      ** test string.\n      */\n      while( (c=zPattern[iPattern]) == MATCH_ALL || c == MATCH_ONE ){\n        if( c==MATCH_ONE ){\n          if( zString[iString]==0 ) return 0;\n          U8_FWD_1_UNSAFE(zString, iString);\n        }\n        iPattern++;\n      }\n\n      if( zPattern[iPattern]==0 ) return 1;\n\n      while( zString[iString] ){\n        if( icuLikeCompare(&zPattern[iPattern], &zString[iString], uEsc) ){\n          return 1;\n        }\n        U8_FWD_1_UNSAFE(zString, iString);\n      }\n      return 0;\n\n    }else if( !prevEscape && uPattern==MATCH_ONE ){\n      /* Case 2. */\n      if( zString[iString]==0 ) return 0;\n      U8_FWD_1_UNSAFE(zString, iString);\n\n    }else if( !prevEscape && uPattern==uEsc){\n      /* Case 3. */\n      prevEscape = 1;\n\n    }else{\n      /* Case 4. */\n      UChar32 uString;\n      U8_NEXT_UNSAFE(zString, iString, uString);\n      uString = u_foldCase(uString, U_FOLD_CASE_DEFAULT);\n      uPattern = u_foldCase(uPattern, U_FOLD_CASE_DEFAULT);\n      if( uString!=uPattern ){\n        return 0;\n      }\n      prevEscape = 0;\n    }\n  }\n\n  return zString[iString]==0;\n}\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B, A). If there is an escape character E, \n**\n**       A LIKE B ESCAPE E\n**\n** is mapped to like(B, A, E).\n*/\nstatic void icuLikeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA = sqlite3_value_text(argv[0]);\n  const unsigned char *zB = sqlite3_value_text(argv[1]);\n  UChar32 uEsc = 0;\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    int nE= sqlite3_value_bytes(argv[2]);\n    const unsigned char *zE = sqlite3_value_text(argv[2]);\n    int i = 0;\n    if( zE==0 ) return;\n    U8_NEXT(zE, i, nE, uEsc);\n    if( i!=nE){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n  }\n\n  if( zA && zB ){\n    sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));\n  }\n}\n\n/*\n** This function is called when an ICU function called from within\n** the implementation of an SQL scalar function returns an error.\n**\n** The scalar function context passed as the first argument is \n** loaded with an error message based on the following two args.\n*/\nstatic void icuFunctionError(\n  sqlite3_context *pCtx,       /* SQLite scalar function context */\n  const char *zName,           /* Name of ICU function that failed */\n  UErrorCode e                 /* Error code returned by ICU function */\n){\n  char zBuf[128];\n  sqlite3_snprintf(128, zBuf, \"ICU error: %s(): %s\", zName, u_errorName(e));\n  zBuf[127] = '\\0';\n  sqlite3_result_error(pCtx, zBuf, -1);\n}\n\n/*\n** Function to delete compiled regexp objects. Registered as\n** a destructor function with sqlite3_set_auxdata().\n*/\nstatic void icuRegexpDelete(void *p){\n  URegularExpression *pExpr = (URegularExpression *)p;\n  uregex_close(pExpr);\n}\n\n/*\n** Implementation of SQLite REGEXP operator. This scalar function takes\n** two arguments. The first is a regular expression pattern to compile\n** the second is a string to match against that pattern. If either \n** argument is an SQL NULL, then NULL Is returned. Otherwise, the result\n** is 1 if the string matches the pattern, or 0 otherwise.\n**\n** SQLite maps the regexp() function to the regexp() operator such\n** that the following two are equivalent:\n**\n**     zString REGEXP zPattern\n**     regexp(zPattern, zString)\n**\n** Uses the following ICU regexp APIs:\n**\n**     uregex_open()\n**     uregex_matches()\n**     uregex_close()\n*/\nstatic void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  UErrorCode status = U_ZERO_ERROR;\n  URegularExpression *pExpr;\n  UBool res;\n  const UChar *zString = sqlite3_value_text16(apArg[1]);\n\n  (void)nArg;  /* Unused parameter */\n\n  /* If the left hand side of the regexp operator is NULL, \n  ** then the result is also NULL. \n  */\n  if( !zString ){\n    return;\n  }\n\n  pExpr = sqlite3_get_auxdata(p, 0);\n  if( !pExpr ){\n    const UChar *zPattern = sqlite3_value_text16(apArg[0]);\n    if( !zPattern ){\n      return;\n    }\n    pExpr = uregex_open(zPattern, -1, 0, 0, &status);\n\n    if( U_SUCCESS(status) ){\n      sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);\n    }else{\n      assert(!pExpr);\n      icuFunctionError(p, \"uregex_open\", status);\n      return;\n    }\n  }\n\n  /* Configure the text that the regular expression operates on. */\n  uregex_setText(pExpr, zString, -1, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_setText\", status);\n    return;\n  }\n\n  /* Attempt the match */\n  res = uregex_matches(pExpr, 0, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_matches\", status);\n    return;\n  }\n\n  /* Set the text that the regular expression operates on to a NULL\n  ** pointer. This is not really necessary, but it is tidier than \n  ** leaving the regular expression object configured with an invalid\n  ** pointer after this function returns.\n  */\n  uregex_setText(pExpr, 0, 0, &status);\n\n  /* Return 1 or 0. */\n  sqlite3_result_int(p, res ? 1 : 0);\n}\n\n/*\n** Implementations of scalar functions for case mapping - upper() and \n** lower(). Function upper() converts its input to upper-case (ABC).\n** Function lower() converts to lower-case (abc).\n**\n** ICU provides two types of case mapping, \"general\" case mapping and\n** \"language specific\". Refer to ICU documentation for the differences\n** between the two.\n**\n** To utilise \"general\" case mapping, the upper() or lower() scalar \n** functions are invoked with one argument:\n**\n**     upper('ABC') -> 'abc'\n**     lower('abc') -> 'ABC'\n**\n** To access ICU \"language specific\" case mapping, upper() or lower()\n** should be invoked with two arguments. The second argument is the name\n** of the locale to use. Passing an empty string (\"\") or SQL NULL value\n** as the second argument is the same as invoking the 1 argument version\n** of upper() or lower().\n**\n**     lower('I', 'en_us') -> 'i'\n**     lower('I', 'tr_tr') -> 'ı' (small dotless i)\n**\n** http://www.icu-project.org/userguide/posix.html#case_mappings\n*/\nstatic void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  const UChar *zInput;\n  UChar *zOutput;\n  int nInput;\n  int nOutput;\n\n  UErrorCode status = U_ZERO_ERROR;\n  const char *zLocale = 0;\n\n  assert(nArg==1 || nArg==2);\n  if( nArg==2 ){\n    zLocale = (const char *)sqlite3_value_text(apArg[1]);\n  }\n\n  zInput = sqlite3_value_text16(apArg[0]);\n  if( !zInput ){\n    return;\n  }\n  nInput = sqlite3_value_bytes16(apArg[0]);\n\n  nOutput = nInput * 2 + 2;\n  zOutput = sqlite3_malloc(nOutput);\n  if( !zOutput ){\n    return;\n  }\n\n  if( sqlite3_user_data(p) ){\n    u_strToUpper(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status);\n  }else{\n    u_strToLower(zOutput, nOutput/2, zInput, nInput/2, zLocale, &status);\n  }\n\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"u_strToLower()/u_strToUpper\", status);\n    return;\n  }\n\n  sqlite3_result_text16(p, zOutput, -1, xFree);\n}\n\n/*\n** Collation sequence destructor function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic void icuCollationDel(void *pCtx){\n  UCollator *p = (UCollator *)pCtx;\n  ucol_close(p);\n}\n\n/*\n** Collation sequence comparison function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic int icuCollationColl(\n  void *pCtx,\n  int nLeft,\n  const void *zLeft,\n  int nRight,\n  const void *zRight\n){\n  UCollationResult res;\n  UCollator *p = (UCollator *)pCtx;\n  res = ucol_strcoll(p, (UChar *)zLeft, nLeft/2, (UChar *)zRight, nRight/2);\n  switch( res ){\n    case UCOL_LESS:    return -1;\n    case UCOL_GREATER: return +1;\n    case UCOL_EQUAL:   return 0;\n  }\n  assert(!\"Unexpected return value from ucol_strcoll()\");\n  return 0;\n}\n\n/*\n** Implementation of the scalar function icu_load_collation().\n**\n** This scalar function is used to add ICU collation based collation \n** types to an SQLite database connection. It is intended to be called\n** as follows:\n**\n**     SELECT icu_load_collation(<locale>, <collation-name>);\n**\n** Where <locale> is a string containing an ICU locale identifier (i.e.\n** \"en_AU\", \"tr_TR\" etc.) and <collation-name> is the name of the\n** collation sequence to create.\n*/\nstatic void icuLoadCollation(\n  sqlite3_context *p, \n  int nArg, \n  sqlite3_value **apArg\n){\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(p);\n  UErrorCode status = U_ZERO_ERROR;\n  const char *zLocale;      /* Locale identifier - (eg. \"jp_JP\") */\n  const char *zName;        /* SQL Collation sequence name (eg. \"japanese\") */\n  UCollator *pUCollator;    /* ICU library collation object */\n  int rc;                   /* Return code from sqlite3_create_collation_x() */\n\n  assert(nArg==2);\n  zLocale = (const char *)sqlite3_value_text(apArg[0]);\n  zName = (const char *)sqlite3_value_text(apArg[1]);\n\n  if( !zLocale || !zName ){\n    return;\n  }\n\n  pUCollator = ucol_open(zLocale, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"ucol_open\", status);\n    return;\n  }\n  assert(p);\n\n  rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, \n      icuCollationColl, icuCollationDel\n  );\n  if( rc!=SQLITE_OK ){\n    ucol_close(pUCollator);\n    sqlite3_result_error(p, \"Error registering collation function\", -1);\n  }\n}\n\n/*\n** Register the ICU extension functions with database db.\n*/\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){\n  struct IcuScalar {\n    const char *zName;                        /* Function name */\n    int nArg;                                 /* Number of arguments */\n    int enc;                                  /* Optimal text encoding */\n    void *pContext;                           /* sqlite3_user_data() context */\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } scalars[] = {\n    {\"regexp\", 2, SQLITE_ANY,          0, icuRegexpFunc},\n\n    {\"lower\",  1, SQLITE_UTF16,        0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF16,        0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF16, (void*)1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF16, (void*)1, icuCaseFunc16},\n\n    {\"lower\",  1, SQLITE_UTF8,         0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF8,         0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF8,  (void*)1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF8,  (void*)1, icuCaseFunc16},\n\n    {\"like\",   2, SQLITE_UTF8,         0, icuLikeFunc},\n    {\"like\",   3, SQLITE_UTF8,         0, icuLikeFunc},\n\n    {\"icu_load_collation\",  2, SQLITE_UTF8, (void*)db, icuLoadCollation},\n  };\n\n  int rc = SQLITE_OK;\n  int i;\n\n  for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){\n    struct IcuScalar *p = &scalars[i];\n    rc = sqlite3_create_function(\n        db, p->zName, p->nArg, p->enc, p->pContext, p->xFunc, 0, 0\n    );\n  }\n\n  return rc;\n}\n\n#if !SQLITE_CORE\nSQLITE_API int sqlite3_extension_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3IcuInit(db);\n}\n#endif\n\n#endif\n\n/************** End of icu.c *************************************************/\n/************** Begin file fts3_icu.c ****************************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a tokenizer for fts3 based on the ICU library.\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n#ifdef SQLITE_ENABLE_ICU\n\n/* #include <assert.h> */\n/* #include <string.h> */\n\n#include <unicode/ubrk.h>\n/* #include <unicode/ucol.h> */\n/* #include <unicode/ustring.h> */\n#include <unicode/utf16.h>\n\ntypedef struct IcuTokenizer IcuTokenizer;\ntypedef struct IcuCursor IcuCursor;\n\nstruct IcuTokenizer {\n  sqlite3_tokenizer base;\n  char *zLocale;\n};\n\nstruct IcuCursor {\n  sqlite3_tokenizer_cursor base;\n\n  UBreakIterator *pIter;      /* ICU break-iterator object */\n  int nChar;                  /* Number of UChar elements in pInput */\n  UChar *aChar;               /* Copy of input using utf-16 encoding */\n  int *aOffset;               /* Offsets of each character in utf-8 input */\n\n  int nBuffer;\n  char *zBuffer;\n\n  int iToken;\n};\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int icuCreate(\n  int argc,                            /* Number of entries in argv[] */\n  const char * const *argv,            /* Tokenizer creation arguments */\n  sqlite3_tokenizer **ppTokenizer      /* OUT: Created tokenizer */\n){\n  IcuTokenizer *p;\n  int n = 0;\n\n  if( argc>0 ){\n    n = strlen(argv[0])+1;\n  }\n  p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(IcuTokenizer));\n\n  if( n ){\n    p->zLocale = (char *)&p[1];\n    memcpy(p->zLocale, argv[0], n);\n  }\n\n  *ppTokenizer = (sqlite3_tokenizer *)p;\n\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int icuDestroy(sqlite3_tokenizer *pTokenizer){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int icuOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput,                    /* Input string */\n  int nInput,                            /* Length of zInput in bytes */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  IcuCursor *pCsr;\n\n  const int32_t opt = U_FOLD_CASE_DEFAULT;\n  UErrorCode status = U_ZERO_ERROR;\n  int nChar;\n\n  UChar32 c;\n  int iInput = 0;\n  int iOut = 0;\n\n  *ppCursor = 0;\n\n  if( zInput==0 ){\n    nInput = 0;\n    zInput = \"\";\n  }else if( nInput<0 ){\n    nInput = strlen(zInput);\n  }\n  nChar = nInput+1;\n  pCsr = (IcuCursor *)sqlite3_malloc(\n      sizeof(IcuCursor) +                /* IcuCursor */\n      ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */\n      (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */\n  );\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(IcuCursor));\n  pCsr->aChar = (UChar *)&pCsr[1];\n  pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];\n\n  pCsr->aOffset[iOut] = iInput;\n  U8_NEXT(zInput, iInput, nInput, c); \n  while( c>0 ){\n    int isError = 0;\n    c = u_foldCase(c, opt);\n    U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);\n    if( isError ){\n      sqlite3_free(pCsr);\n      return SQLITE_ERROR;\n    }\n    pCsr->aOffset[iOut] = iInput;\n\n    if( iInput<nInput ){\n      U8_NEXT(zInput, iInput, nInput, c);\n    }else{\n      c = 0;\n    }\n  }\n\n  pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);\n  if( !U_SUCCESS(status) ){\n    sqlite3_free(pCsr);\n    return SQLITE_ERROR;\n  }\n  pCsr->nChar = iOut;\n\n  ubrk_first(pCsr->pIter);\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to icuOpen().\n*/\nstatic int icuClose(sqlite3_tokenizer_cursor *pCursor){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n  ubrk_close(pCsr->pIter);\n  sqlite3_free(pCsr->zBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.\n*/\nstatic int icuNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n\n  int iStart = 0;\n  int iEnd = 0;\n  int nByte = 0;\n\n  while( iStart==iEnd ){\n    UChar32 c;\n\n    iStart = ubrk_current(pCsr->pIter);\n    iEnd = ubrk_next(pCsr->pIter);\n    if( iEnd==UBRK_DONE ){\n      return SQLITE_DONE;\n    }\n\n    while( iStart<iEnd ){\n      int iWhite = iStart;\n      U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);\n      if( u_isspace(c) ){\n        iStart = iWhite;\n      }else{\n        break;\n      }\n    }\n    assert(iStart<=iEnd);\n  }\n\n  do {\n    UErrorCode status = U_ZERO_ERROR;\n    if( nByte ){\n      char *zNew = sqlite3_realloc(pCsr->zBuffer, nByte);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pCsr->zBuffer = zNew;\n      pCsr->nBuffer = nByte;\n    }\n\n    u_strToUTF8(\n        pCsr->zBuffer, pCsr->nBuffer, &nByte,    /* Output vars */\n        &pCsr->aChar[iStart], iEnd-iStart,       /* Input vars */\n        &status                                  /* Output success/failure */\n    );\n  } while( nByte>pCsr->nBuffer );\n\n  *ppToken = pCsr->zBuffer;\n  *pnBytes = nByte;\n  *piStartOffset = pCsr->aOffset[iStart];\n  *piEndOffset = pCsr->aOffset[iEnd];\n  *piPosition = pCsr->iToken++;\n\n  return SQLITE_OK;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module icuTokenizerModule = {\n  0,                           /* iVersion */\n  icuCreate,                   /* xCreate  */\n  icuDestroy,                  /* xCreate  */\n  icuOpen,                     /* xOpen    */\n  icuClose,                    /* xClose   */\n  icuNext,                     /* xNext    */\n};\n\n/*\n** Set *ppModule to point at the implementation of the ICU tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &icuTokenizerModule;\n}\n\n#endif /* defined(SQLITE_ENABLE_ICU) */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_icu.c ********************************************/\n"
  },
  {
    "path": "deps/sqlite/sqlite3.h",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are suppose to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef _SQLITE3_H_\n#define _SQLITE3_H_\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** Add the ability to override 'extern'\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are support for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since version 3.6.18, SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and an SHA1\n** hash of the entire source tree.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.7.17\"\n#define SQLITE_VERSION_NUMBER 3007017\n#define SQLITE_SOURCE_ID      \"2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version, sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus insure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API SQLITE_EXTERN const char sqlite3_version[];\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_MUTEX].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n  typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** of sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must insure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: SQLITE_OK {error code} {error codes}\n** KEYWORDS: {result code} {result codes}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [SQLITE_IOERR_READ | extended result codes],\n** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* SQL error or missing database */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Database is empty */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Auxiliary database format error */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended error code} {extended error codes}\n** KEYWORDS: {extended result code} {extended result codes}\n**\n** In its default configuration, SQLite API routines return one of 26 integer\n** [SQLITE_OK | result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 and later) include\n** support for additional result codes that provide more detailed information\n** about errors. The extended result codes are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.\n**\n** Some of the available extended result codes are listed here.\n** One may expect the number of extended result codes will be expand\n** over time.  Software that uses extended result codes should expect\n** to see new result codes in future releases of SQLite.\n**\n** The SQLITE_OK result code will never be extended.  It will always\n** be exactly zero.\n*/\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and only needs to be supported when SQLITE_TEST\n** is defined.\n** <ul>\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See the [sqlite3_file_control()] documentation for\n** additional information.\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by\n** SQLite and sent to all VFSes in place of a call to the xSync method\n** when the database connection has [PRAGMA synchronous] set to OFF.)^\n** Some specialized VFSes need this signal in order to operate correctly\n** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most \n** VFSes do not need this signal and should silently ignore this opcode.\n** Applications should not call [sqlite3_file_control()] with this\n** opcode as doing so may disrupt the operation of the specialized VFSes\n** that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer i the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log and shared memory files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement.  ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_GET_LOCKPROXYFILE             2\n#define SQLITE_SET_LOCKPROXYFILE             3\n#define SQLITE_LAST_ERRNO                    4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The value of the iVersion field is initially 1 but may be larger in\n** future versions of SQLite.  Additional fields may be appended to this\n** object when the iVersion value is increased.  Note that the structure\n** of the sqlite3_vfs object changes in the transaction between\n** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not\n** modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in figure versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given no the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** The sqlite3_config() interface is not threadsafe.  The application\n** must insure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.  Furthermore, sqlite3_config()\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  (For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mem_methods] structure.  The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mem_methods] structure.  The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^This option takes single argument of type int, interpreted as a \n** boolean, which enables or disables the collection of memory allocation \n** statistics. ^(When memory allocation statistics are disabled, the \n** following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite can use for\n** scratch memory.  There are three arguments:  A pointer an 8-byte\n** aligned memory buffer from which the scratch allocations will be\n** drawn, the size of each scratch allocation (sz),\n** and the maximum number of scratch allocations (N).  The sz\n** argument must be a multiple of 16.\n** The first argument must be a pointer to an 8-byte aligned buffer\n** of at least sz*N bytes of memory.\n** ^SQLite will use no more than two scratch buffers per thread.  So\n** N should be set to twice the expected maximum number of threads.\n** ^SQLite will never require a scratch buffer that is more than 6\n** times the database page size. ^If SQLite needs needs additional\n** scratch memory beyond what is provided by this configuration option, then \n** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite can use for\n** the database page cache with the default page cache implementation.  \n** This configuration should not be used if an application-define page\n** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.\n** There are three arguments to this option: A pointer to 8-byte aligned\n** memory, the size of each page buffer (sz), and the number of pages (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 32768) plus a little extra for each\n** page header.  ^The page header size is 20 to 40 bytes depending on\n** the host architecture.  ^It is harmless, apart from the wasted memory,\n** to make sz a little too large.  The first\n** argument should point to an allocation of at least sz*N bytes of memory.\n** ^SQLite will use the memory provided by the first argument to satisfy its\n** memory needs for the first N pages that it adds to cache.  ^If additional\n** page cache memory is needed beyond what is provided by this option, then\n** SQLite goes to [sqlite3_malloc()] for the additional storage space.\n** The pointer in the first argument must\n** be aligned to an 8-byte boundary or subsequent behavior of SQLite\n** will be undefined.</dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^This option specifies a static memory buffer that SQLite will use\n** for all of its dynamic memory allocation needs beyond those provided\n** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].\n** There are three arguments: An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or\n** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mutex_methods] structure.  The argument specifies\n** alternative low-level mutex routines to be used in place\n** the mutex routines built into SQLite.)^  ^SQLite makes a copy of the\n** content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(This option takes two arguments that determine the default\n** memory allocation for the lookaside memory allocator on each\n** [database connection].  The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(This option sets the\n** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** verb to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(This option takes a single argument which is a pointer to\n** an [sqlite3_pcache_methods2] object.  This object specifies the interface\n** to a custom page cache implementation.)^  ^SQLite makes a copy of the\n** object and uses it for page cache memory allocations.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(This option takes a single argument which is a pointer to an\n** [sqlite3_pcache_methods2] object.  SQLite copies of the current\n** page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd> This option takes a single argument of type int. If non-zero, then\n** URI handling is globally enabled. If the parameter is zero, then URI handling\n** is globally disabled. If URI handling is globally enabled, all filenames\n** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd> This option takes a single integer argument which is interpreted as\n** a boolean in order to enable or disable the use of covering indices for\n** full table scans in the query optimizer.  The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** malfunction when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  The maximum allowed mmap size\n** cannot be changed at run-time.  Nor may the maximum allowed mmap size\n** exceed the compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.  \n** If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* void*, int sz, int N */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** </dl>\n*/\n#define SQLITE_DBCONFIG_LOOKASIDE       1001  /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY     1002  /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER  1003  /* int int* */\n\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n**\n** ^Each entry in an SQLite table has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^This routine returns the [rowid] of the most recent\n** successful [INSERT] into the database from the [database connection]\n** in the first argument.  ^As of SQLite version 3.7.7, this routines\n** records the last insert rowid of both ordinary tables and [virtual tables].\n** ^If no successful [INSERT]s\n** have ever occurred on that database connection, zero is returned.\n**\n** ^(If an [INSERT] occurs within a trigger or within a [virtual table]\n** method, then this routine will return the [rowid] of the inserted\n** row as long as the trigger or virtual table method is running.\n** But once the trigger or virtual table method ends, the value returned \n** by this routine reverts to what it was before the trigger or virtual\n** table method began.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n**\n** ^This function returns the number of database rows that were changed\n** or inserted or deleted by the most recently completed SQL statement\n** on the [database connection] specified by the first parameter.\n** ^(Only changes that are directly specified by the [INSERT], [UPDATE],\n** or [DELETE] statement are counted.  Auxiliary changes caused by\n** triggers or [foreign key actions] are not counted.)^ Use the\n** [sqlite3_total_changes()] function to find the total number of changes\n** including changes caused by triggers and foreign key actions.\n**\n** ^Changes to a view that are simulated by an [INSTEAD OF trigger]\n** are not counted.  Only real table changes are counted.\n**\n** ^(A \"row change\" is a change to a single row of a single table\n** caused by an INSERT, DELETE, or UPDATE statement.  Rows that\n** are changed as side effects of [REPLACE] constraint resolution,\n** rollback, ABORT processing, [DROP TABLE], or by any other\n** mechanisms do not count as direct row changes.)^\n**\n** A \"trigger context\" is a scope of execution that begins and\n** ends with the script of a [CREATE TRIGGER | trigger]. \n** Most SQL statements are\n** evaluated outside of any trigger.  This is the \"top level\"\n** trigger context.  If a trigger fires from the top level, a\n** new trigger context is entered for the duration of that one\n** trigger.  Subtriggers create subcontexts for their duration.\n**\n** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does\n** not create a new trigger context.\n**\n** ^This function returns the number of direct row changes in the\n** most recent INSERT, UPDATE, or DELETE statement within the same\n** trigger context.\n**\n** ^Thus, when called from the top level, this function returns the\n** number of changes in the most recent INSERT, UPDATE, or DELETE\n** that also occurred at the top level.  ^(Within the body of a trigger,\n** the sqlite3_changes() interface can be called to find the number of\n** changes in the most recently completed INSERT, UPDATE, or DELETE\n** statement within the body of the same trigger.\n** However, the number returned does not include changes\n** caused by subtriggers since those have their own context.)^\n**\n** See also the [sqlite3_total_changes()] interface, the\n** [count_changes pragma], and the [changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n**\n** ^This function returns the number of row changes caused by [INSERT],\n** [UPDATE] or [DELETE] statements since the [database connection] was opened.\n** ^(The count returned by sqlite3_total_changes() includes all changes\n** from all [CREATE TRIGGER | trigger] contexts and changes made by\n** [foreign key actions]. However,\n** the count does not include changes used to implement [REPLACE] constraints,\n** do rollbacks or ABORT processing, or [DROP TABLE] processing.  The\n** count does not include rows of views that fire an [INSTEAD OF trigger],\n** though if the INSTEAD OF trigger makes changes of its own, those changes \n** are counted.)^\n** ^The sqlite3_total_changes() function counts the changes as soon as\n** the statement that makes them is completed (when the statement handle\n** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).\n**\n** See also the [sqlite3_changes()] interface, the\n** [count_changes pragma], and the [total_changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n**\n** If the database connection closes while [sqlite3_interrupt()]\n** is running then bad things will likely happen.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n**\n** ^This routine sets a callback function that might be invoked whenever\n** an attempt is made to open a database table that another thread\n** or process has locked.\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked for this locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.\n** ^If the callback returns non-zero, then another attempt\n** is made to open the database for reading and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]\n** when SQLite is in the middle of a large transaction where all the\n** changes will not fit into the in-memory cache.  SQLite will\n** already hold a RESERVED lock on the database file, but it needs\n** to promote this lock to EXCLUSIVE so that it can spill cache\n** pages into the database file without harm to concurrent\n** readers.  ^If it is unable to promote the lock, then the in-memory\n** cache will be left in an inconsistent state and so the error\n** code is promoted from the relatively benign [SQLITE_BUSY] to\n** the more severe [SQLITE_IOERR_BLOCKED].  ^This error code promotion\n** forces an automatic rollback of the changes.  See the\n** <a href=\"/cvstrac/wiki?p=CorruptionFollowingBusyError\">\n** CorruptionFollowingBusyError</a> wiki page for a discussion of why\n** this is important.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** will also set or clear the busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] any any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** These routines all implement some additional formatting\n** options that are useful for constructing SQL statements.\n** All of the usual printf() formatting options apply.  In addition, there\n** is are \"%q\", \"%Q\", and \"%z\" options.\n**\n** ^(The %q option works like %s in that it substitutes a nul-terminated\n** string from the argument list.  But %q also doubles every '\\'' character.\n** %q is designed for use inside a string literal.)^  By doubling each '\\''\n** character it escapes that character and allows it to be inserted into\n** the string.\n**\n** For example, assume the string variable zText contains text as follows:\n**\n** <blockquote><pre>\n**  char *zText = \"It's a happy day!\";\n** </pre></blockquote>\n**\n** One can use this text in an SQL statement as follows:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES('%q')\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** Because the %q format string is used, the '\\'' character in zText\n** is escaped and the SQL generated is as follows:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It''s a happy day!')\n** </pre></blockquote>\n**\n** This is correct.  Had we used %s instead of %q, the generated SQL\n** would have looked like this:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It's a happy day!');\n** </pre></blockquote>\n**\n** This second example is an SQL syntax error.  As a general rule you should\n** always use %q instead of %s when inserting text into a string literal.\n**\n** ^(The %Q option works like %q except it also adds single quotes around\n** the outside of the total string.  Additionally, if the parameter in the\n** argument list is a NULL pointer, %Q substitutes the text \"NULL\" (without\n** single quotes).)^  So, for example, one could say:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES(%Q)\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** The code above will render a correct SQL statement in the zSQL\n** variable even if the zText variable is a NULL pointer.\n**\n** ^(The \"%z\" formatting option works like \"%s\" but with the\n** addition that after the string has been read and copied into\n** the result, [sqlite3_free()] is called on the input string.)^\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^(The sqlite3_realloc() interface attempts to resize a\n** prior memory allocation to be at least N bytes, where N is the\n** second parameter.  The memory allocation to be resized is the first\n** parameter.)^ ^ If the first parameter to sqlite3_realloc()\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().\n** ^If the second parameter to sqlite3_realloc() is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().\n** ^sqlite3_realloc() returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if sufficient memory is unavailable.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc() and the prior allocation is freed.\n** ^If sqlite3_realloc() returns NULL, then the prior allocation\n** is not freed.\n**\n** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void sqlite3_free(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n**\n** ^The first time this routine is invoked (either internally or by\n** the application) the PRNG is seeded using randomness obtained\n** from the xRandomness method of the default [sqlite3_vfs] object.\n** ^On all subsequent invocations, the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are zero-terminated strings that contain additional\n** details about the action to be authorized.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code]\n** from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  The\n** sqlite3_profile() function is considered experimental and is\n** subject to change in future versions of SQLite.\n*/\nSQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding for the database will be UTF-8 if\n** sqlite3_open() or sqlite3_open_v2() is called and\n** UTF-16 in the native byte order if sqlite3_open16() is used.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the fourth argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** As of SQLite version 3.7.7, URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite interprets the following three query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-nolock\".\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n**\n** ^The sqlite3_errcode() interface returns the numeric [result code] or\n** [extended result code] for the most recent failed sqlite3_* API call\n** associated with a [database connection]. If a prior API call failed\n** but the most recent API call succeeded, the return value from\n** sqlite3_errcode() is undefined.  ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: SQL Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement.\n** This object is variously known as a \"prepared statement\" or a\n** \"compiled SQL statement\" or simply as a \"statement\".\n**\n** The life of a statement object goes something like this:\n**\n** <ol>\n** <li> Create the object using [sqlite3_prepare_v2()] or a related\n**      function.\n** <li> Bind values to [host parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n**\n** Refer to documentation on individual methods above for additional\n** information.\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  This limit is not currently\n** enforced, though that might be added in some future release of\n** SQLite.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n**\n** To execute an SQL query, it must first be compiled into a byte-code\n** program using one of these routines.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare() and sqlite3_prepare_v2()\n** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()\n** use UTF-16.\n**\n** ^If the nByte argument is less than zero, then zSql is read up to the\n** first zero terminator. ^If nByte is non-negative, then it is the maximum\n** number of  bytes read from zSql.  ^When nByte is non-negative, the\n** zSql string ends at either the first '\\000' or '\\u0000' character or\n** the nByte-th byte, whichever comes first. If the caller knows\n** that the supplied string is nul-terminated, then there is a small\n** performance advantage to be gained by passing an nByte parameter that\n** is equal to the number of bytes in the input string <i>including</i>\n** the nul-terminator bytes as this saves SQLite from having to\n** make a copy of the input string.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are\n** recommended for all new programs. The two older interfaces are retained\n** for backwards compatibility, but their use is discouraged.\n** ^In the \"v2\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** the \n** </li>\n** </ol>\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n**\n** ^This interface can be used to retrieve a saved copy of the original\n** SQL text used to create a [prepared statement] if that statement was\n** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has not run to completion and/or has not \n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used with\n** [sqlite3_result_value()] and [sqlite3_bind_value()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct Mem sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() then that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and\n** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),\n** sqlite3_bind_text(), or sqlite3_bind_text16() fails.  \n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()] or\n** [sqlite3_prepare16_v2()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^This routine returns 0 if pStmt is an SQL\n** statement that does not return data (for example an [UPDATE]).\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n**\n** After a [prepared statement] has been prepared using either\n** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"v2\" interface\n** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy\n** interface [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"v2\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after version 3.6.23.1, sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"v2\" interface is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n**\n** These routines form the \"result set\" interface.\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].  The value\n** returned by sqlite3_column_type() is only meaningful if no type\n** conversions have occurred as described below.  After a type conversion,\n** the value returned by sqlite3_column_type() is undefined.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  An unprotected sqlite3_value object\n** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], then the behavior is undefined.\n**\n** These routines attempt to convert the value where appropriate.  ^For\n** example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> Convert from float to integer\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> Same as FLOAT->TEXT\n** <tr><td>  TEXT    <td> INTEGER   <td> Use atoi()\n** <tr><td>  TEXT    <td>  FLOAT    <td> Use atof()\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> Convert to TEXT then use atoi()\n** <tr><td>  BLOB    <td>  FLOAT    <td> Convert to TEXT then use atof()\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** The table above makes reference to standard C library functions atoi()\n** and atof().  SQLite does not really use these functions.  It has its\n** own equivalent internal routines.  The atoi() and atof() names are\n** used in the table for brevity and because they are familiar to most\n** C programmers.\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest and easiest to remember policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do <b>not</b> pass the pointers returned\n** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** ^(If a memory allocation error occurs during the evaluation of any\n** of these routines, a default value is returned.  The default value\n** is either the integer 0, the floating point number 0.0, or a NULL\n** pointer.  Subsequent calls to [sqlite3_errcode()] will return\n** [SQLITE_NOMEM].)^\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates.  The only differences between\n** these routines are the text encoding expected for\n** the second parameter (the name of the function being created)\n** and the presence or absence of a destructor callback for\n** the application data pointer.\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  Every SQL function implementation must be able to work\n** with UTF-8, UTF-16le, or UTF-16be.  But some implementations may be\n** more efficient with one encoding than another.  ^An application may\n** invoke sqlite3_create_function() or sqlite3_create_function16() multiple\n** times with the same function but with different values of eTextRep.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n** If there is only a single implementation which does not care what text\n** encoding is used, then the fourth argument should be [SQLITE_ANY].\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,\n** then it is destructor for the application data pointer. \n** The destructor is invoked when the function is deleted, either by being\n** overloaded or when the database connection closes.)^\n** ^The destructor is also invoked if the call to\n** sqlite3_create_function_v2() fails.\n** ^When the destructor callback of the tenth parameter is invoked, it\n** is passed a single argument which is a copy of the application data \n** pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1\n#define SQLITE_UTF16LE        2\n#define SQLITE_UTF16BE        3\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* sqlite3_create_function only */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To help encourage people to avoid\n** using these functions, we are not going to tell you what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Function Parameter Values\n**\n** The C-language implementation of SQL functions and aggregates uses\n** this set of interface routines to access the parameter values on\n** the function or aggregate.\n**\n** The xFunc (for scalar functions) or xStep (for aggregates) parameters\n** to [sqlite3_create_function()] and [sqlite3_create_function16()]\n** define callbacks that implement the SQL functions and aggregates.\n** The 3rd parameter to these callbacks is an array of pointers to\n** [protected sqlite3_value] objects.  There is one [sqlite3_value] object for\n** each parameter to the SQL function.  These routines are used to\n** extract values from the [sqlite3_value] objects.\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** object results in undefined behavior.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that  these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n**\n** The following two functions may be used by scalar SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved. This may\n** be used, for example, to add a regular-expression matching scalar\n** function. The compiled version of the regular expression is stored as\n** metadata associated with the SQL value passed as the regular expression\n** pattern.  The compiled regular expression can be reused on multiple\n** invocations of the same function so that the original pattern string\n** does not need to be recompiled on each invocation.\n**\n** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata() function with the Nth argument\n** value to the application-defined function. ^If no metadata has been ever\n** been set for the Nth argument of the function, or if the corresponding\n** function parameter has changed since the meta-data was set,\n** then sqlite3_get_auxdata() returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata() interface saves the metadata\n** pointed to by its 3rd parameter as the metadata for the N-th\n** argument of the application-defined function.  Subsequent\n** calls to sqlite3_get_auxdata() might return this data, if it has\n** not been destroyed.\n** ^If it is not NULL, SQLite will invoke the destructor\n** function given by the 4th parameter to sqlite3_set_auxdata() on\n** the metadata when the corresponding function parameter changes\n** or when the SQL statement completes, whichever comes first.\n**\n** SQLite is free to call the destructor and drop metadata on any\n** parameter of any function at any time.  ^The only guarantee is that\n** the destructor will be called before the metadata is dropped.\n**\n** ^(In practice, metadata is preserved between function calls for\n** expressions that are constant at compile time. This includes literal\n** values and [parameters].)^\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob() interfaces set the result of\n** the application-defined function to be a BLOB containing all zero\n** bytes and N bytes in size, where N is the value of the 2nd parameter.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained from\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted.\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n**\n** ^In the current implementation, the update hook\n** is not invoked when duplication rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]\n** interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is effect even\n** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite version 3.7.3, the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n**\n** ^This routine returns metadata about a specific column of a specific\n** database table accessible using the [database connection] handle\n** passed as the first function argument.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL. ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively. Neither of these parameters\n** may be NULL.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid only until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** explicitly declared [INTEGER PRIMARY KEY] column, then the output\n** parameters are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^(This function may load one or more schemas from database files. If an\n** error occurs during this process, or if the requested table or column\n** cannot be found, an [error code] is returned and an error message left\n** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^\n**\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] prior to calling this API,\n** otherwise an error will be returned.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects and integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()].\n*/\nSQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of doing the\n** particular lookup.  A full scan of a table with N entries should have\n** a cost of N.  A binary search of a table of N entries should have a\n** cost of approximately log(N).\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column on left-hand side of constraint */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;      /* Estimated cost of using this index */\n};\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ    2\n#define SQLITE_INDEX_CONSTRAINT_GT    4\n#define SQLITE_INDEX_CONSTRAINT_LE    8\n#define SQLITE_INDEX_CONSTRAINT_LT    16\n#define SQLITE_INDEX_CONSTRAINT_GE    32\n#define SQLITE_INDEX_CONSTRAINT_MATCH 64\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* NO LONGER USED */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If it is zero, the BLOB is opened for read access.\n** ^It is not possible to open a column that is part of an index or primary \n** key for writing. ^If [foreign key constraints] are enabled, it is \n** not possible to open a column that is part of a [child key] for writing.\n**\n** ^Note that the database name is not the filename that contains\n** the database but rather the symbolic name of the database that\n** appears after the AS keyword when the database is connected using [ATTACH].\n** ^For the main database file, the database name is \"main\".\n** ^For TEMP tables, the database name is \"temp\".\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written\n** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set\n** to be a null pointer.)^\n** ^This function sets the [database connection] error code and message\n** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related\n** functions. ^Note that the *ppBlob variable is always initialized in a\n** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob\n** regardless of the success or failure of this routine.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function can be used, if desired,\n** to create an empty, zero-filled blob in which to read or write using\n** this interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n**\n** ^This function is used to move an existing blob handle so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing blob handle to a new row can be\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n**\n** ^Closes an open [BLOB handle].\n**\n** ^Closing a BLOB shall cause the current transaction to commit\n** if there are no other BLOBs, no pending prepared statements, and the\n** database connection is in [autocommit mode].\n** ^If any writes were made to the BLOB, they might be held in cache\n** until the close operation if they will fit.\n**\n** ^(Closing the BLOB often forces the changes\n** out to disk and so if any I/O errors occur, they will likely occur\n** at the time when the BLOB is closed.  Any errors that occur during\n** closing are reported as a non-zero return value.)^\n**\n** ^(The BLOB is closed unconditionally.  Even if this routine returns\n** an error code, the BLOB is still closed.)^\n**\n** ^Calling this routine with a null pointer (such as would be returned\n** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n**\n** ^This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. ^N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.\n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** ^This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written.  ^If N is\n** less than zero [SQLITE_ERROR] is returned and no data is written.\n** The size of the BLOB (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  ^(The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>)^\n**\n** ^The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  ^The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().)^\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^If it returns NULL\n** that means that a mutex could not be allocated.  ^SQLite\n** will unwind its stack and return an error.  ^(The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_MEM2\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_LRU2\n** </ul>)^\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  ^SQLite will only request a recursive mutex in\n** cases where it really needs one.  ^If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^But for the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  ^SQLite is careful to deallocate every\n** dynamic mutex that it allocates.  The dynamic mutexes must not be in\n** use when they are deallocated.  Attempting to deallocate a static\n** mutex results in undefined behavior.  ^SQLite never deallocates\n** a static mutex.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  ^(If the same thread tries to enter any other\n** kind of mutex more than once, the behavior is undefined.\n** SQLite will never exhibit\n** such behavior in its own use of mutexes.)^\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY.  The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   ^(The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.  SQLite will\n** never do either.)^\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the user has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the user\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  ^It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  ^Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  ^The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  ^The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  ^External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** ^These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** ^The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** ^If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  ^The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_random() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  ^The SQLITE_FCNTL_FILE_POINTER\n** case is a short-circuit path which does not actually invoke the\n** underlying sqlite3_io_methods.xFileControl method.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [SQLITE_FCNTL_LOCKSTATE]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19\n#define SQLITE_TESTCTRL_LAST                    19\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^This interface is used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** This routine is threadsafe but is not atomic.  This routine can be\n** called while other threads are running the same or different SQLite\n** interfaces.  However the values returned in *pCurrent and\n** *pHighwater reflect the status of SQLite at different points in time\n** and it is possible that another thread might change the parameter\n** in between the times when *pCurrent and *pHighwater are written.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Scratch memory\n** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>This parameter returns the number of allocations used out of the\n** [scratch memory allocator] configured using\n** [SQLITE_CONFIG_SCRATCH].  The value returned is in allocations, not\n** in bytes.  Since a single thread may only have one scratch allocation\n** outstanding at time, this parameter also reports the number of threads\n** using scratch memory at the same time.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of scratch memory\n** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The values\n** returned include overflows because the requested allocation was too\n** larger (that is, because the requested allocation was larger than the\n** \"sz\" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer\n** slots were available.\n** </dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [scratch memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>This parameter records the deepest parser stack.  It is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_MAX                  9   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^Each call to sqlite3_backup_step() sets two values inside\n** the [sqlite3_backup] object: the number of pages still to be backed\n** up and the total number of pages in the source database file.\n** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces\n** retrieve these two values, respectively.\n**\n** ^The values returned by these functions are only updated by\n** sqlite3_backup_step(). ^If the source database is modified during a backup\n** operation, then the values are not updated to account for any extra\n** pages that need to be updated or the size of the source database file\n** changing.\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches\n** the glob pattern P, and it returns non-zero if string X does not match\n** the glob pattern P.  ^The definition of glob pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect used by SQLite.  ^The sqlite3_strglob(P,X) function is case\n** sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** will be invoked each time a database connection commits data to a\n** [write-ahead log] (i.e. whenever a transaction is committed in\n** [journal_mode | journal_mode=WAL mode]). \n**\n** ^The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** those overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n**\n** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X\n** on [database connection] D to be [checkpointed].  ^If X is NULL or an\n** empty string, then a checkpoint is run on all databases of\n** connection D.  ^If the database connection D is not in\n** [WAL | write-ahead log mode] then this interface is a harmless no-op.\n**\n** ^The [wal_checkpoint pragma] can be used to invoke this interface\n** from SQL.  ^The [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] can be used to cause this interface to be\n** run whenever the WAL reaches a certain size threshold.\n**\n** See also: [sqlite3_wal_checkpoint_v2()]\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n**\n** Run a checkpoint operation on WAL database zDb attached to database \n** handle db. The specific operation is determined by the value of the \n** eMode parameter:\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish. Sync the db file if all frames in the log\n**   are checkpointed. This mode is the same as calling \n**   sqlite3_wal_checkpoint(). The busy-handler callback is never invoked.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   This mode blocks (calls the busy-handler callback) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. It then checkpoints all frames in the log file and syncs the\n**   database file. This call blocks database writers while it is running,\n**   but not database readers.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   This mode works the same way as SQLITE_CHECKPOINT_FULL, except after \n**   checkpointing the log file it blocks (calls the busy-handler callback)\n**   until all readers are reading from the database file only. This ensures \n**   that the next client to write to the database file restarts the log file \n**   from the beginning. This call blocks database writers while it is running,\n**   but not database readers.\n** </dl>\n**\n** If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to\n** the total number of checkpointed frames (including any that were already\n** checkpointed when this function is called). *pnLog and *pnCkpt may be\n** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.\n** If no values are available because of an error, they are both set to -1\n** before returning to communicate this to the caller.\n**\n** All calls obtain an exclusive \"checkpoint\" lock on the database file. If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive \n** \"writer\" lock on the database file. If the writer lock cannot be obtained\n** immediately, and a busy-handler is configured, it is invoked and the writer\n** lock retried until either the busy-handler returns 0 or the lock is\n** successfully obtained. The busy-handler is also invoked while waiting for\n** database readers as described above. If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. SQLITE_BUSY is returned in this case.\n**\n** If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases. In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned to the caller. If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code returned to the caller immediately. If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint operation parameters\n**\n** These constants can be used as the 3rd parameter to\n** [sqlite3_wal_checkpoint_v2()].  See the [sqlite3_wal_checkpoint_v2()]\n** documentation for additional information about the meaning and use of\n** each of these values.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE 0\n#define SQLITE_CHECKPOINT_FULL    1\n#define SQLITE_CHECKPOINT_RESTART 2\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Conflict resolution modes\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif\n\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n#ifdef SQLITE_RTREE_INT_ONLY\n  int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),\n#else\n  int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),\n#endif\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  double *aParam;                 /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n"
  },
  {
    "path": "deps/sqlite/sqlite3ext.h",
    "content": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef _SQLITE3EXT_H_\n#define _SQLITE3EXT_H_\n#include \"sqlite3.h\"\n\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each others' shared\n** libraries!\n*/\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n  int  (*global_recover)(void);\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*snprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*vsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n};\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected throught the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#ifndef SQLITE_CORE\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->snprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->vsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n#endif /* SQLITE_CORE */\n\n#ifndef SQLITE_CORE\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n#endif\n\n#endif /* _SQLITE3EXT_H_ */\n"
  },
  {
    "path": "deps/tinycthread/tinycthread.c",
    "content": "/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; -*-\nCopyright (c) 2012 Marcus Geelnard\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n/* 2013-01-06 Camilla Berglund <elmindreda@elmindreda.org>\n * \n * Added casts from time_t to DWORD to avoid warnings on VC++.\n */\n\n#include \"tinycthread.h\"\n#include <stdlib.h>\n\n/* Platform specific includes */\n#if defined(_TTHREAD_POSIX_)\n  #include <signal.h>\n  #include <sched.h>\n  #include <unistd.h>\n  #include <sys/time.h>\n  #include <errno.h>\n#elif defined(_TTHREAD_WIN32_)\n  #include <process.h>\n  #include <sys/timeb.h>\n#endif\n\n/* Standard, good-to-have defines */\n#ifndef NULL\n  #define NULL (void*)0\n#endif\n#ifndef TRUE\n  #define TRUE 1\n#endif\n#ifndef FALSE\n  #define FALSE 0\n#endif\n\nint mtx_init(mtx_t *mtx, int type)\n{\n#if defined(_TTHREAD_WIN32_)\n  mtx->mAlreadyLocked = FALSE;\n  mtx->mRecursive = type & mtx_recursive;\n  InitializeCriticalSection(&mtx->mHandle);\n  return thrd_success;\n#else\n  int ret;\n  pthread_mutexattr_t attr;\n  pthread_mutexattr_init(&attr);\n  if (type & mtx_recursive)\n  {\n    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n  }\n  ret = pthread_mutex_init(mtx, &attr);\n  pthread_mutexattr_destroy(&attr);\n  return ret == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nvoid mtx_destroy(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  DeleteCriticalSection(&mtx->mHandle);\n#else\n  pthread_mutex_destroy(mtx);\n#endif\n}\n\nint mtx_lock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  EnterCriticalSection(&mtx->mHandle);\n  if (!mtx->mRecursive)\n  {\n    while(mtx->mAlreadyLocked) Sleep(1000); /* Simulate deadlock... */\n    mtx->mAlreadyLocked = TRUE;\n  }\n  return thrd_success;\n#else\n  return pthread_mutex_lock(mtx) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint mtx_timedlock(mtx_t *mtx, const struct timespec *ts)\n{\n  /* FIXME! */\n  (void)mtx;\n  (void)ts;\n  return thrd_error;\n}\n\nint mtx_trylock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  int ret = TryEnterCriticalSection(&mtx->mHandle) ? thrd_success : thrd_busy;\n  if ((!mtx->mRecursive) && (ret == thrd_success) && mtx->mAlreadyLocked)\n  {\n    LeaveCriticalSection(&mtx->mHandle);\n    ret = thrd_busy;\n  }\n  return ret;\n#else\n  return (pthread_mutex_trylock(mtx) == 0) ? thrd_success : thrd_busy;\n#endif\n}\n\nint mtx_unlock(mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  mtx->mAlreadyLocked = FALSE;\n  LeaveCriticalSection(&mtx->mHandle);\n  return thrd_success;\n#else\n  return pthread_mutex_unlock(mtx) == 0 ? thrd_success : thrd_error;;\n#endif\n}\n\n#if defined(_TTHREAD_WIN32_)\n#define _CONDITION_EVENT_ONE 0\n#define _CONDITION_EVENT_ALL 1\n#endif\n\nint cnd_init(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  cond->mWaitersCount = 0;\n\n  /* Init critical section */\n  InitializeCriticalSection(&cond->mWaitersCountLock);\n\n  /* Init events */\n  cond->mEvents[_CONDITION_EVENT_ONE] = CreateEvent(NULL, FALSE, FALSE, NULL);\n  if (cond->mEvents[_CONDITION_EVENT_ONE] == NULL)\n  {\n    cond->mEvents[_CONDITION_EVENT_ALL] = NULL;\n    return thrd_error;\n  }\n  cond->mEvents[_CONDITION_EVENT_ALL] = CreateEvent(NULL, TRUE, FALSE, NULL);\n  if (cond->mEvents[_CONDITION_EVENT_ALL] == NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]);\n    cond->mEvents[_CONDITION_EVENT_ONE] = NULL;\n    return thrd_error;\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_init(cond, NULL) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nvoid cnd_destroy(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (cond->mEvents[_CONDITION_EVENT_ONE] != NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ONE]);\n  }\n  if (cond->mEvents[_CONDITION_EVENT_ALL] != NULL)\n  {\n    CloseHandle(cond->mEvents[_CONDITION_EVENT_ALL]);\n  }\n  DeleteCriticalSection(&cond->mWaitersCountLock);\n#else\n  pthread_cond_destroy(cond);\n#endif\n}\n\nint cnd_signal(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  int haveWaiters;\n\n  /* Are there any waiters? */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  haveWaiters = (cond->mWaitersCount > 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we have any waiting threads, send them a signal */\n  if(haveWaiters)\n  {\n    if (SetEvent(cond->mEvents[_CONDITION_EVENT_ONE]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint cnd_broadcast(cnd_t *cond)\n{\n#if defined(_TTHREAD_WIN32_)\n  int haveWaiters;\n\n  /* Are there any waiters? */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  haveWaiters = (cond->mWaitersCount > 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we have any waiting threads, send them a signal */\n  if(haveWaiters)\n  {\n    if (SetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  return thrd_success;\n#else\n  return pthread_cond_signal(cond) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\n#if defined(_TTHREAD_WIN32_)\nstatic int _cnd_timedwait_win32(cnd_t *cond, mtx_t *mtx, DWORD timeout)\n{\n  int result, lastWaiter;\n\n  /* Increment number of waiters */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  ++ cond->mWaitersCount;\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* Release the mutex while waiting for the condition (will decrease\n     the number of waiters when done)... */\n  mtx_unlock(mtx);\n\n  /* Wait for either event to become signaled due to cnd_signal() or\n     cnd_broadcast() being called */\n  result = WaitForMultipleObjects(2, cond->mEvents, FALSE, timeout);\n  if (result == WAIT_TIMEOUT)\n  {\n    return thrd_timeout;\n  }\n  else if (result == (int)WAIT_FAILED)\n  {\n    return thrd_error;\n  }\n\n  /* Check if we are the last waiter */\n  EnterCriticalSection(&cond->mWaitersCountLock);\n  -- cond->mWaitersCount;\n  lastWaiter = (result == (WAIT_OBJECT_0 + _CONDITION_EVENT_ALL)) &&\n               (cond->mWaitersCount == 0);\n  LeaveCriticalSection(&cond->mWaitersCountLock);\n\n  /* If we are the last waiter to be notified to stop waiting, reset the event */\n  if (lastWaiter)\n  {\n    if (ResetEvent(cond->mEvents[_CONDITION_EVENT_ALL]) == 0)\n    {\n      return thrd_error;\n    }\n  }\n\n  /* Re-acquire the mutex */\n  mtx_lock(mtx);\n\n  return thrd_success;\n}\n#endif\n\nint cnd_wait(cnd_t *cond, mtx_t *mtx)\n{\n#if defined(_TTHREAD_WIN32_)\n  return _cnd_timedwait_win32(cond, mtx, INFINITE);\n#else\n  return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error;\n#endif\n}\n\nint cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts)\n{\n#if defined(_TTHREAD_WIN32_)\n  struct timespec now;\n  if (clock_gettime(TIME_UTC, &now) == 0)\n  {\n    DWORD delta = (DWORD) ((ts->tv_sec - now.tv_sec) * 1000 +\n                           (ts->tv_nsec - now.tv_nsec + 500000) / 1000000);\n    return _cnd_timedwait_win32(cond, mtx, delta);\n  }\n  else\n    return thrd_error;\n#else\n  int ret;\n  ret = pthread_cond_timedwait(cond, mtx, ts);\n  if (ret == ETIMEDOUT)\n  {\n    return thrd_timeout;\n  }\n  return ret == 0 ? thrd_success : thrd_error;\n#endif\n}\n\n\n/** Information to pass to the new thread (what to run). */\ntypedef struct {\n  thrd_start_t mFunction; /**< Pointer to the function to be executed. */\n  void * mArg;            /**< Function argument for the thread function. */\n} _thread_start_info;\n\n/* Thread wrapper function. */\n#if defined(_TTHREAD_WIN32_)\nstatic unsigned WINAPI _thrd_wrapper_function(void * aArg)\n#elif defined(_TTHREAD_POSIX_)\nstatic void * _thrd_wrapper_function(void * aArg)\n#endif\n{\n  thrd_start_t fun;\n  void *arg;\n  int  res;\n#if defined(_TTHREAD_POSIX_)\n  void *pres;\n#endif\n\n  /* Get thread startup information */\n  _thread_start_info *ti = (_thread_start_info *) aArg;\n  fun = ti->mFunction;\n  arg = ti->mArg;\n\n  /* The thread is responsible for freeing the startup information */\n  free((void *)ti);\n\n  /* Call the actual client thread function */\n  res = fun(arg);\n\n#if defined(_TTHREAD_WIN32_)\n  return res;\n#else\n  pres = malloc(sizeof(int));\n  if (pres != NULL)\n  {\n    *(int*)pres = res;\n  }\n  return pres;\n#endif\n}\n\nint thrd_create(thrd_t *thr, thrd_start_t func, void *arg)\n{\n  /* Fill out the thread startup information (passed to the thread wrapper,\n     which will eventually free it) */\n  _thread_start_info* ti = (_thread_start_info*)malloc(sizeof(_thread_start_info));\n  if (ti == NULL)\n  {\n    return thrd_nomem;\n  }\n  ti->mFunction = func;\n  ti->mArg = arg;\n\n  /* Create the thread */\n#if defined(_TTHREAD_WIN32_)\n  *thr = (HANDLE)_beginthreadex(NULL, 0, _thrd_wrapper_function, (void *)ti, 0, NULL);\n#elif defined(_TTHREAD_POSIX_)\n  if(pthread_create(thr, NULL, _thrd_wrapper_function, (void *)ti) != 0)\n  {\n    *thr = 0;\n  }\n#endif\n\n  /* Did we fail to create the thread? */\n  if(!*thr)\n  {\n    free(ti);\n    return thrd_error;\n  }\n\n  return thrd_success;\n}\n\nthrd_t thrd_current(void)\n{\n#if defined(_TTHREAD_WIN32_)\n  return GetCurrentThread();\n#else\n  return pthread_self();\n#endif\n}\n\nint thrd_detach(thrd_t thr)\n{\n  /* FIXME! */\n  (void)thr;\n  return thrd_error;\n}\n\nint thrd_equal(thrd_t thr0, thrd_t thr1)\n{\n#if defined(_TTHREAD_WIN32_)\n  return thr0 == thr1;\n#else\n  return pthread_equal(thr0, thr1);\n#endif\n}\n\nvoid thrd_exit(int res)\n{\n#if defined(_TTHREAD_WIN32_)\n  ExitThread(res);\n#else\n  void *pres = malloc(sizeof(int));\n  if (pres != NULL)\n  {\n    *(int*)pres = res;\n  }\n  pthread_exit(pres);\n#endif\n}\n\nint thrd_join(thrd_t thr, int *res)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (WaitForSingleObject(thr, INFINITE) == WAIT_FAILED)\n  {\n    return thrd_error;\n  }\n  if (res != NULL)\n  {\n    DWORD dwRes;\n    GetExitCodeThread(thr, &dwRes);\n    *res = dwRes;\n  }\n#elif defined(_TTHREAD_POSIX_)\n  void *pres;\n  int ires = 0;\n  if (pthread_join(thr, &pres) != 0)\n  {\n    return thrd_error;\n  }\n  if (pres != NULL)\n  {\n    ires = *(int*)pres;\n    free(pres);\n  }\n  if (res != NULL)\n  {\n    *res = ires;\n  }\n#endif\n  return thrd_success;\n}\n\nint thrd_sleep(const struct timespec *time_point, struct timespec *remaining)\n{\n  struct timespec now;\n#if defined(_TTHREAD_WIN32_)\n  DWORD delta;\n#else\n  long delta;\n#endif\n\n  /* Get the current time */\n  if (clock_gettime(TIME_UTC, &now) != 0)\n    return -2;  // FIXME: Some specific error code?\n\n#if defined(_TTHREAD_WIN32_)\n  /* Delta in milliseconds */\n  delta = (DWORD) ((time_point->tv_sec - now.tv_sec) * 1000 +\n                   (time_point->tv_nsec - now.tv_nsec + 500000) / 1000000);\n  if (delta > 0)\n  {\n    Sleep(delta);\n  }\n#else\n  /* Delta in microseconds */\n  delta = (time_point->tv_sec - now.tv_sec) * 1000000L +\n          (time_point->tv_nsec - now.tv_nsec + 500L) / 1000L;\n\n  /* On some systems, the usleep argument must be < 1000000 */\n  while (delta > 999999L)\n  {\n    usleep(999999);\n    delta -= 999999L;\n  }\n  if (delta > 0L)\n  {\n    usleep((useconds_t)delta);\n  }\n#endif\n\n  /* We don't support waking up prematurely (yet) */\n  if (remaining)\n  {\n    remaining->tv_sec = 0;\n    remaining->tv_nsec = 0;\n  }\n  return 0;\n}\n\nvoid thrd_yield(void)\n{\n#if defined(_TTHREAD_WIN32_)\n  Sleep(0);\n#else\n  sched_yield();\n#endif\n}\n\nint tss_create(tss_t *key, tss_dtor_t dtor)\n{\n#if defined(_TTHREAD_WIN32_)\n  /* FIXME: The destructor function is not supported yet... */\n  if (dtor != NULL)\n  {\n    return thrd_error;\n  }\n  *key = TlsAlloc();\n  if (*key == TLS_OUT_OF_INDEXES)\n  {\n    return thrd_error;\n  }\n#else\n  if (pthread_key_create(key, dtor) != 0)\n  {\n    return thrd_error;\n  }\n#endif\n  return thrd_success;\n}\n\nvoid tss_delete(tss_t key)\n{\n#if defined(_TTHREAD_WIN32_)\n  TlsFree(key);\n#else\n  pthread_key_delete(key);\n#endif\n}\n\nvoid *tss_get(tss_t key)\n{\n#if defined(_TTHREAD_WIN32_)\n  return TlsGetValue(key);\n#else\n  return pthread_getspecific(key);\n#endif\n}\n\nint tss_set(tss_t key, void *val)\n{\n#if defined(_TTHREAD_WIN32_)\n  if (TlsSetValue(key, val) == 0)\n  {\n    return thrd_error;\n  }\n#else\n  if (pthread_setspecific(key, val) != 0)\n  {\n    return thrd_error;\n  }\n#endif\n  return thrd_success;\n}\n\n#if defined(_TTHREAD_EMULATE_CLOCK_GETTIME_)\nint _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts)\n{\n#if defined(_TTHREAD_WIN32_)\n  struct _timeb tb;\n  _ftime(&tb);\n  ts->tv_sec = (time_t)tb.time;\n  ts->tv_nsec = 1000000L * (long)tb.millitm;\n#else\n  struct timeval tv;\n  gettimeofday(&tv, NULL);\n  ts->tv_sec = (time_t)tv.tv_sec;\n  ts->tv_nsec = 1000L * (long)tv.tv_usec;\n#endif\n  return 0;\n}\n#endif // _TTHREAD_EMULATE_CLOCK_GETTIME_\n\n"
  },
  {
    "path": "deps/tinycthread/tinycthread.h",
    "content": "/* -*- mode: c; tab-width: 2; indent-tabs-mode: nil; -*-\nCopyright (c) 2012 Marcus Geelnard\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n    1. The origin of this software must not be misrepresented; you must not\n    claim that you wrote the original software. If you use this software\n    in a product, an acknowledgment in the product documentation would be\n    appreciated but is not required.\n\n    2. Altered source versions must be plainly marked as such, and must not be\n    misrepresented as being the original software.\n\n    3. This notice may not be removed or altered from any source\n    distribution.\n*/\n\n#ifndef _TINYCTHREAD_H_\n#define _TINYCTHREAD_H_\n\n/**\n* @file\n* @mainpage TinyCThread API Reference\n*\n* @section intro_sec Introduction\n* TinyCThread is a minimal, portable implementation of basic threading\n* classes for C.\n*\n* They closely mimic the functionality and naming of the C11 standard, and\n* should be easily replaceable with the corresponding standard variants.\n*\n* @section port_sec Portability\n* The Win32 variant uses the native Win32 API for implementing the thread\n* classes, while for other systems, the POSIX threads API (pthread) is used.\n*\n* @section misc_sec Miscellaneous\n* The following special keywords are available: #_Thread_local.\n*\n* For more detailed information, browse the different sections of this\n* documentation. A good place to start is:\n* tinycthread.h.\n*/\n\n/* Which platform are we on? */\n#if !defined(_TTHREAD_PLATFORM_DEFINED_)\n  #if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__)\n    #define _TTHREAD_WIN32_\n  #else\n    #define _TTHREAD_POSIX_\n  #endif\n  #define _TTHREAD_PLATFORM_DEFINED_\n#endif\n\n/* Activate some POSIX functionality (e.g. clock_gettime and recursive mutexes) */\n#if defined(_TTHREAD_POSIX_)\n  #undef _FEATURES_H\n  #if !defined(_GNU_SOURCE)\n    #define _GNU_SOURCE\n  #endif\n  #if !defined(_POSIX_C_SOURCE) || ((_POSIX_C_SOURCE - 0) < 199309L)\n    #undef _POSIX_C_SOURCE\n    #define _POSIX_C_SOURCE 199309L\n  #endif\n  #if !defined(_XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 500)\n    #undef _XOPEN_SOURCE\n    #define _XOPEN_SOURCE 500\n  #endif\n#endif\n\n/* Generic includes */\n#include <time.h>\n\n/* Platform specific includes */\n#if defined(_TTHREAD_POSIX_)\n  #include <pthread.h>\n#elif defined(_TTHREAD_WIN32_)\n  #ifndef WIN32_LEAN_AND_MEAN\n    #define WIN32_LEAN_AND_MEAN\n    #define __UNDEF_LEAN_AND_MEAN\n  #endif\n  #include <windows.h>\n  #ifdef __UNDEF_LEAN_AND_MEAN\n    #undef WIN32_LEAN_AND_MEAN\n    #undef __UNDEF_LEAN_AND_MEAN\n  #endif\n#endif\n\n/* Workaround for missing TIME_UTC: If time.h doesn't provide TIME_UTC,\n   it's quite likely that libc does not support it either. Hence, fall back to\n   the only other supported time specifier: CLOCK_REALTIME (and if that fails,\n   we're probably emulating clock_gettime anyway, so anything goes). */\n#ifndef TIME_UTC\n  #ifdef CLOCK_REALTIME\n    #define TIME_UTC CLOCK_REALTIME\n  #else\n    #define TIME_UTC 0\n  #endif\n#endif\n\n/* Workaround for missing clock_gettime (most Windows compilers, afaik) */\n#if defined(_TTHREAD_WIN32_) || defined(__APPLE_CC__)\n#define _TTHREAD_EMULATE_CLOCK_GETTIME_\n/* Emulate struct timespec */\n#if defined(_TTHREAD_WIN32_)\nstruct _ttherad_timespec {\n  time_t tv_sec;\n  long   tv_nsec;\n};\n#define timespec _ttherad_timespec\n#endif\n\n/* Emulate clockid_t */\ntypedef int _tthread_clockid_t;\n#define clockid_t _tthread_clockid_t\n\n/* Emulate clock_gettime */\nint _tthread_clock_gettime(clockid_t clk_id, struct timespec *ts);\n#define clock_gettime _tthread_clock_gettime\n#endif\n\n\n/** TinyCThread version (major number). */\n#define TINYCTHREAD_VERSION_MAJOR 1\n/** TinyCThread version (minor number). */\n#define TINYCTHREAD_VERSION_MINOR 1\n/** TinyCThread version (full version). */\n#define TINYCTHREAD_VERSION (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR)\n\n/**\n* @def _Thread_local\n* Thread local storage keyword.\n* A variable that is declared with the @c _Thread_local keyword makes the\n* value of the variable local to each thread (known as thread-local storage,\n* or TLS). Example usage:\n* @code\n* // This variable is local to each thread.\n* _Thread_local int variable;\n* @endcode\n* @note The @c _Thread_local keyword is a macro that maps to the corresponding\n* compiler directive (e.g. @c __declspec(thread)).\n* @note This directive is currently not supported on Mac OS X (it will give\n* a compiler error), since compile-time TLS is not supported in the Mac OS X\n* executable format. Also, some older versions of MinGW (before GCC 4.x) do\n* not support this directive.\n* @hideinitializer\n*/\n\n/* FIXME: Check for a PROPER value of __STDC_VERSION__ to know if we have C11 */\n#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) && !defined(_Thread_local)\n #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)\n  #define _Thread_local __thread\n #else\n  #define _Thread_local __declspec(thread)\n #endif\n#endif\n\n/* Macros */\n#define TSS_DTOR_ITERATIONS 0\n\n/* Function return values */\n#define thrd_error    0 /**< The requested operation failed */\n#define thrd_success  1 /**< The requested operation succeeded */\n#define thrd_timeout  2 /**< The time specified in the call was reached without acquiring the requested resource */\n#define thrd_busy     3 /**< The requested operation failed because a tesource requested by a test and return function is already in use */\n#define thrd_nomem    4 /**< The requested operation failed because it was unable to allocate memory */\n\n/* Mutex types */\n#define mtx_plain     1\n#define mtx_timed     2\n#define mtx_try       4\n#define mtx_recursive 8\n\n/* Mutex */\n#if defined(_TTHREAD_WIN32_)\ntypedef struct {\n  CRITICAL_SECTION mHandle;   /* Critical section handle */\n  int mAlreadyLocked;         /* TRUE if the mutex is already locked */\n  int mRecursive;             /* TRUE if the mutex is recursive */\n} mtx_t;\n#else\ntypedef pthread_mutex_t mtx_t;\n#endif\n\n/** Create a mutex object.\n* @param mtx A mutex object.\n* @param type Bit-mask that must have one of the following six values:\n*   @li @c mtx_plain for a simple non-recursive mutex\n*   @li @c mtx_timed for a non-recursive mutex that supports timeout\n*   @li @c mtx_try for a non-recursive mutex that supports test and return\n*   @li @c mtx_plain | @c mtx_recursive (same as @c mtx_plain, but recursive)\n*   @li @c mtx_timed | @c mtx_recursive (same as @c mtx_timed, but recursive)\n*   @li @c mtx_try | @c mtx_recursive (same as @c mtx_try, but recursive)\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_init(mtx_t *mtx, int type);\n\n/** Release any resources used by the given mutex.\n* @param mtx A mutex object.\n*/\nvoid mtx_destroy(mtx_t *mtx);\n\n/** Lock the given mutex.\n* Blocks until the given mutex can be locked. If the mutex is non-recursive, and\n* the calling thread already has a lock on the mutex, this call will block\n* forever.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_lock(mtx_t *mtx);\n\n/** NOT YET IMPLEMENTED.\n*/\nint mtx_timedlock(mtx_t *mtx, const struct timespec *ts);\n\n/** Try to lock the given mutex.\n* The specified mutex shall support either test and return or timeout. If the\n* mutex is already locked, the function returns without blocking.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_busy if the resource\n* requested is already in use, or @ref thrd_error if the request could not be\n* honored.\n*/\nint mtx_trylock(mtx_t *mtx);\n\n/** Unlock the given mutex.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint mtx_unlock(mtx_t *mtx);\n\n/* Condition variable */\n#if defined(_TTHREAD_WIN32_)\ntypedef struct {\n  HANDLE mEvents[2];                  /* Signal and broadcast event HANDLEs. */\n  unsigned int mWaitersCount;         /* Count of the number of waiters. */\n  CRITICAL_SECTION mWaitersCountLock; /* Serialize access to mWaitersCount. */\n} cnd_t;\n#else\ntypedef pthread_cond_t cnd_t;\n#endif\n\n/** Create a condition variable object.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_init(cnd_t *cond);\n\n/** Release any resources used by the given condition variable.\n* @param cond A condition variable object.\n*/\nvoid cnd_destroy(cnd_t *cond);\n\n/** Signal a condition variable.\n* Unblocks one of the threads that are blocked on the given condition variable\n* at the time of the call. If no threads are blocked on the condition variable\n* at the time of the call, the function does nothing and return success.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_signal(cnd_t *cond);\n\n/** Broadcast a condition variable.\n* Unblocks all of the threads that are blocked on the given condition variable\n* at the time of the call. If no threads are blocked on the condition variable\n* at the time of the call, the function does nothing and return success.\n* @param cond A condition variable object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_broadcast(cnd_t *cond);\n\n/** Wait for a condition variable to become signaled.\n* The function atomically unlocks the given mutex and endeavors to block until\n* the given condition variable is signaled by a call to cnd_signal or to\n* cnd_broadcast. When the calling thread becomes unblocked it locks the mutex\n* before it returns.\n* @param cond A condition variable object.\n* @param mtx A mutex object.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint cnd_wait(cnd_t *cond, mtx_t *mtx);\n\n/** Wait for a condition variable to become signaled.\n* The function atomically unlocks the given mutex and endeavors to block until\n* the given condition variable is signaled by a call to cnd_signal or to\n* cnd_broadcast, or until after the specified time. When the calling thread\n* becomes unblocked it locks the mutex before it returns.\n* @param cond A condition variable object.\n* @param mtx A mutex object.\n* @param xt A point in time at which the request will time out (absolute time).\n* @return @ref thrd_success upon success, or @ref thrd_timeout if the time\n* specified in the call was reached without acquiring the requested resource, or\n* @ref thrd_error if the request could not be honored.\n*/\nint cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts);\n\n/* Thread */\n#if defined(_TTHREAD_WIN32_)\ntypedef HANDLE thrd_t;\n#else\ntypedef pthread_t thrd_t;\n#endif\n\n/** Thread start function.\n* Any thread that is started with the @ref thrd_create() function must be\n* started through a function of this type.\n* @param arg The thread argument (the @c arg argument of the corresponding\n*        @ref thrd_create() call).\n* @return The thread return value, which can be obtained by another thread\n* by using the @ref thrd_join() function.\n*/\ntypedef int (*thrd_start_t)(void *arg);\n\n/** Create a new thread.\n* @param thr Identifier of the newly created thread.\n* @param func A function pointer to the function that will be executed in\n*        the new thread.\n* @param arg An argument to the thread function.\n* @return @ref thrd_success on success, or @ref thrd_nomem if no memory could\n* be allocated for the thread requested, or @ref thrd_error if the request\n* could not be honored.\n* @note A thread’s identifier may be reused for a different thread once the\n* original thread has exited and either been detached or joined to another\n* thread.\n*/\nint thrd_create(thrd_t *thr, thrd_start_t func, void *arg);\n\n/** Identify the calling thread.\n* @return The identifier of the calling thread.\n*/\nthrd_t thrd_current(void);\n\n/** NOT YET IMPLEMENTED.\n*/\nint thrd_detach(thrd_t thr);\n\n/** Compare two thread identifiers.\n* The function determines if two thread identifiers refer to the same thread.\n* @return Zero if the two thread identifiers refer to different threads.\n* Otherwise a nonzero value is returned.\n*/\nint thrd_equal(thrd_t thr0, thrd_t thr1);\n\n/** Terminate execution of the calling thread.\n* @param res Result code of the calling thread.\n*/\nvoid thrd_exit(int res);\n\n/** Wait for a thread to terminate.\n* The function joins the given thread with the current thread by blocking\n* until the other thread has terminated.\n* @param thr The thread to join with.\n* @param res If this pointer is not NULL, the function will store the result\n*        code of the given thread in the integer pointed to by @c res.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint thrd_join(thrd_t thr, int *res);\n\n/** Put the calling thread to sleep.\n* Suspend execution of the calling thread.\n* @param time_point A point in time at which the thread will resume (absolute time).\n* @param remaining If non-NULL, this parameter will hold the remaining time until\n*                  time_point upon return. This will typically be zero, but if\n*                  the thread was woken up by a signal that is not ignored before\n*                  time_point was reached @c remaining will hold a positive\n*                  time.\n* @return 0 (zero) on successful sleep, or -1 if an interrupt occurred.\n*/\nint thrd_sleep(const struct timespec *time_point, struct timespec *remaining);\n\n/** Yield execution to another thread.\n* Permit other threads to run, even if the current thread would ordinarily\n* continue to run.\n*/\nvoid thrd_yield(void);\n\n/* Thread local storage */\n#if defined(_TTHREAD_WIN32_)\ntypedef DWORD tss_t;\n#else\ntypedef pthread_key_t tss_t;\n#endif\n\n/** Destructor function for a thread-specific storage.\n* @param val The value of the destructed thread-specific storage.\n*/\ntypedef void (*tss_dtor_t)(void *val);\n\n/** Create a thread-specific storage.\n* @param key The unique key identifier that will be set if the function is\n*        successful.\n* @param dtor Destructor function. This can be NULL.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n* @note The destructor function is not supported under Windows. If @c dtor is\n* not NULL when calling this function under Windows, the function will fail\n* and return @ref thrd_error.\n*/\nint tss_create(tss_t *key, tss_dtor_t dtor);\n\n/** Delete a thread-specific storage.\n* The function releases any resources used by the given thread-specific\n* storage.\n* @param key The key that shall be deleted.\n*/\nvoid tss_delete(tss_t key);\n\n/** Get the value for a thread-specific storage.\n* @param key The thread-specific storage identifier.\n* @return The value for the current thread held in the given thread-specific\n* storage.\n*/\nvoid *tss_get(tss_t key);\n\n/** Set the value for a thread-specific storage.\n* @param key The thread-specific storage identifier.\n* @param val The value of the thread-specific storage to set for the current\n*        thread.\n* @return @ref thrd_success on success, or @ref thrd_error if the request could\n* not be honored.\n*/\nint tss_set(tss_t key, void *val);\n\n\n#endif /* _TINYTHREAD_H_ */\n\n"
  },
  {
    "path": "server.py",
    "content": "from math import floor\nfrom world import World\nimport Queue\nimport SocketServer\nimport datetime\nimport random\nimport re\nimport requests\nimport sqlite3\nimport sys\nimport threading\nimport time\nimport traceback\n\nDEFAULT_HOST = '0.0.0.0'\nDEFAULT_PORT = 4080\n\nDB_PATH = 'craft.db'\nLOG_PATH = 'log.txt'\n\nCHUNK_SIZE = 32\nBUFFER_SIZE = 4096\nCOMMIT_INTERVAL = 5\n\nAUTH_REQUIRED = True\nAUTH_URL = 'https://craft.michaelfogleman.com/api/1/access'\n\nDAY_LENGTH = 600\nSPAWN_POINT = (0, 0, 0, 0, 0)\nRATE_LIMIT = False\nRECORD_HISTORY = False\nINDESTRUCTIBLE_ITEMS = set([16])\nALLOWED_ITEMS = set([\n    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n    17, 18, 19, 20, 21, 22, 23,\n    32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\n    48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63])\n\nAUTHENTICATE = 'A'\nBLOCK = 'B'\nCHUNK = 'C'\nDISCONNECT = 'D'\nKEY = 'K'\nLIGHT = 'L'\nNICK = 'N'\nPOSITION = 'P'\nREDRAW = 'R'\nSIGN = 'S'\nTALK = 'T'\nTIME = 'E'\nVERSION = 'V'\nYOU = 'U'\n\ntry:\n    from config import *\nexcept ImportError:\n    pass\n\ndef log(*args):\n    now = datetime.datetime.utcnow()\n    line = ' '.join(map(str, (now,) + args))\n    print line\n    with open(LOG_PATH, 'a') as fp:\n        fp.write('%s\\n' % line)\n\ndef chunked(x):\n    return int(floor(round(x) / CHUNK_SIZE))\n\ndef packet(*args):\n    return '%s\\n' % ','.join(map(str, args))\n\nclass RateLimiter(object):\n    def __init__(self, rate, per):\n        self.rate = float(rate)\n        self.per = float(per)\n        self.allowance = self.rate\n        self.last_check = time.time()\n    def tick(self):\n        if not RATE_LIMIT:\n            return False\n        now = time.time()\n        elapsed = now - self.last_check\n        self.last_check = now\n        self.allowance += elapsed * (self.rate / self.per)\n        if self.allowance > self.rate:\n            self.allowance = self.rate\n        if self.allowance < 1:\n            return True # too fast\n        else:\n            self.allowance -= 1\n            return False # okay\n\nclass Server(SocketServer.ThreadingMixIn, SocketServer.TCPServer):\n    allow_reuse_address = True\n    daemon_threads = True\n\nclass Handler(SocketServer.BaseRequestHandler):\n    def setup(self):\n        self.position_limiter = RateLimiter(100, 5)\n        self.limiter = RateLimiter(1000, 10)\n        self.version = None\n        self.client_id = None\n        self.user_id = None\n        self.nick = None\n        self.queue = Queue.Queue()\n        self.running = True\n        self.start()\n    def handle(self):\n        model = self.server.model\n        model.enqueue(model.on_connect, self)\n        try:\n            buf = []\n            while True:\n                data = self.request.recv(BUFFER_SIZE)\n                if not data:\n                    break\n                buf.extend(data.replace('\\r\\n', '\\n'))\n                while '\\n' in buf:\n                    index = buf.index('\\n')\n                    line = ''.join(buf[:index])\n                    buf = buf[index + 1:]\n                    if not line:\n                        continue\n                    if line[0] == POSITION:\n                        if self.position_limiter.tick():\n                            log('RATE', self.client_id)\n                            self.stop()\n                            return\n                    else:\n                        if self.limiter.tick():\n                            log('RATE', self.client_id)\n                            self.stop()\n                            return\n                    model.enqueue(model.on_data, self, line)\n        finally:\n            model.enqueue(model.on_disconnect, self)\n    def finish(self):\n        self.running = False\n    def stop(self):\n        self.request.close()\n    def start(self):\n        thread = threading.Thread(target=self.run)\n        thread.setDaemon(True)\n        thread.start()\n    def run(self):\n        while self.running:\n            try:\n                buf = []\n                try:\n                    buf.append(self.queue.get(timeout=5))\n                    try:\n                        while True:\n                            buf.append(self.queue.get(False))\n                    except Queue.Empty:\n                        pass\n                except Queue.Empty:\n                    continue\n                data = ''.join(buf)\n                self.request.sendall(data)\n            except Exception:\n                self.request.close()\n                raise\n    def send_raw(self, data):\n        if data:\n            self.queue.put(data)\n    def send(self, *args):\n        self.send_raw(packet(*args))\n\nclass Model(object):\n    def __init__(self, seed):\n        self.world = World(seed)\n        self.clients = []\n        self.queue = Queue.Queue()\n        self.commands = {\n            AUTHENTICATE: self.on_authenticate,\n            CHUNK: self.on_chunk,\n            BLOCK: self.on_block,\n            LIGHT: self.on_light,\n            POSITION: self.on_position,\n            TALK: self.on_talk,\n            SIGN: self.on_sign,\n            VERSION: self.on_version,\n        }\n        self.patterns = [\n            (re.compile(r'^/nick(?:\\s+([^,\\s]+))?$'), self.on_nick),\n            (re.compile(r'^/spawn$'), self.on_spawn),\n            (re.compile(r'^/goto(?:\\s+(\\S+))?$'), self.on_goto),\n            (re.compile(r'^/pq\\s+(-?[0-9]+)\\s*,?\\s*(-?[0-9]+)$'), self.on_pq),\n            (re.compile(r'^/help(?:\\s+(\\S+))?$'), self.on_help),\n            (re.compile(r'^/list$'), self.on_list),\n        ]\n    def start(self):\n        thread = threading.Thread(target=self.run)\n        thread.setDaemon(True)\n        thread.start()\n    def run(self):\n        self.connection = sqlite3.connect(DB_PATH)\n        self.create_tables()\n        self.commit()\n        while True:\n            try:\n                if time.time() - self.last_commit > COMMIT_INTERVAL:\n                    self.commit()\n                self.dequeue()\n            except Exception:\n                traceback.print_exc()\n    def enqueue(self, func, *args, **kwargs):\n        self.queue.put((func, args, kwargs))\n    def dequeue(self):\n        try:\n            func, args, kwargs = self.queue.get(timeout=5)\n            func(*args, **kwargs)\n        except Queue.Empty:\n            pass\n    def execute(self, *args, **kwargs):\n        return self.connection.execute(*args, **kwargs)\n    def commit(self):\n        self.last_commit = time.time()\n        self.connection.commit()\n    def create_tables(self):\n        queries = [\n            'create table if not exists block ('\n            '    p int not null,'\n            '    q int not null,'\n            '    x int not null,'\n            '    y int not null,'\n            '    z int not null,'\n            '    w int not null'\n            ');',\n            'create unique index if not exists block_pqxyz_idx on '\n            '    block (p, q, x, y, z);',\n            'create table if not exists light ('\n            '    p int not null,'\n            '    q int not null,'\n            '    x int not null,'\n            '    y int not null,'\n            '    z int not null,'\n            '    w int not null'\n            ');',\n            'create unique index if not exists light_pqxyz_idx on '\n            '    light (p, q, x, y, z);',\n            'create table if not exists sign ('\n            '    p int not null,'\n            '    q int not null,'\n            '    x int not null,'\n            '    y int not null,'\n            '    z int not null,'\n            '    face int not null,'\n            '    text text not null'\n            ');',\n            'create index if not exists sign_pq_idx on sign (p, q);',\n            'create unique index if not exists sign_xyzface_idx on '\n            '    sign (x, y, z, face);',\n            'create table if not exists block_history ('\n            '   timestamp real not null,'\n            '   user_id int not null,'\n            '   x int not null,'\n            '   y int not null,'\n            '   z int not null,'\n            '   w int not null'\n            ');',\n        ]\n        for query in queries:\n            self.execute(query)\n    def get_default_block(self, x, y, z):\n        p, q = chunked(x), chunked(z)\n        chunk = self.world.get_chunk(p, q)\n        return chunk.get((x, y, z), 0)\n    def get_block(self, x, y, z):\n        query = (\n            'select w from block where '\n            'p = :p and q = :q and x = :x and y = :y and z = :z;'\n        )\n        p, q = chunked(x), chunked(z)\n        rows = list(self.execute(query, dict(p=p, q=q, x=x, y=y, z=z)))\n        if rows:\n            return rows[0][0]\n        return self.get_default_block(x, y, z)\n    def next_client_id(self):\n        result = 1\n        client_ids = set(x.client_id for x in self.clients)\n        while result in client_ids:\n            result += 1\n        return result\n    def on_connect(self, client):\n        client.client_id = self.next_client_id()\n        client.nick = 'guest%d' % client.client_id\n        log('CONN', client.client_id, *client.client_address)\n        client.position = SPAWN_POINT\n        self.clients.append(client)\n        client.send(YOU, client.client_id, *client.position)\n        client.send(TIME, time.time(), DAY_LENGTH)\n        client.send(TALK, 'Welcome to Craft!')\n        client.send(TALK, 'Type \"/help\" for a list of commands.')\n        self.send_position(client)\n        self.send_positions(client)\n        self.send_nick(client)\n        self.send_nicks(client)\n    def on_data(self, client, data):\n        #log('RECV', client.client_id, data)\n        args = data.split(',')\n        command, args = args[0], args[1:]\n        if command in self.commands:\n            func = self.commands[command]\n            func(client, *args)\n    def on_disconnect(self, client):\n        log('DISC', client.client_id, *client.client_address)\n        self.clients.remove(client)\n        self.send_disconnect(client)\n        self.send_talk('%s has disconnected from the server.' % client.nick)\n    def on_version(self, client, version):\n        if client.version is not None:\n            return\n        version = int(version)\n        if version != 1:\n            client.stop()\n            return\n        client.version = version\n        # TODO: client.start() here\n    def on_authenticate(self, client, username, access_token):\n        user_id = None\n        if username and access_token:\n            payload = {\n                'username': username,\n                'access_token': access_token,\n            }\n            response = requests.post(AUTH_URL, data=payload)\n            if response.status_code == 200 and response.text.isdigit():\n                user_id = int(response.text)\n        client.user_id = user_id\n        if user_id is None:\n            client.nick = 'guest%d' % client.client_id\n            client.send(TALK, 'Visit craft.michaelfogleman.com to register!')\n        else:\n            client.nick = username\n        self.send_nick(client)\n        # TODO: has left message if was already authenticated\n        self.send_talk('%s has joined the game.' % client.nick)\n    def on_chunk(self, client, p, q, key=0):\n        packets = []\n        p, q, key = map(int, (p, q, key))\n        query = (\n            'select rowid, x, y, z, w from block where '\n            'p = :p and q = :q and rowid > :key;'\n        )\n        rows = self.execute(query, dict(p=p, q=q, key=key))\n        max_rowid = 0\n        blocks = 0\n        for rowid, x, y, z, w in rows:\n            blocks += 1\n            packets.append(packet(BLOCK, p, q, x, y, z, w))\n            max_rowid = max(max_rowid, rowid)\n        query = (\n            'select x, y, z, w from light where '\n            'p = :p and q = :q;'\n        )\n        rows = self.execute(query, dict(p=p, q=q))\n        lights = 0\n        for x, y, z, w in rows:\n            lights += 1\n            packets.append(packet(LIGHT, p, q, x, y, z, w))\n        query = (\n            'select x, y, z, face, text from sign where '\n            'p = :p and q = :q;'\n        )\n        rows = self.execute(query, dict(p=p, q=q))\n        signs = 0\n        for x, y, z, face, text in rows:\n            signs += 1\n            packets.append(packet(SIGN, p, q, x, y, z, face, text))\n        if blocks:\n            packets.append(packet(KEY, p, q, max_rowid))\n        if blocks or lights or signs:\n            packets.append(packet(REDRAW, p, q))\n        packets.append(packet(CHUNK, p, q))\n        client.send_raw(''.join(packets))\n    def on_block(self, client, x, y, z, w):\n        x, y, z, w = map(int, (x, y, z, w))\n        p, q = chunked(x), chunked(z)\n        previous = self.get_block(x, y, z)\n        message = None\n        if AUTH_REQUIRED and client.user_id is None:\n            message = 'Only logged in users are allowed to build.'\n        elif y <= 0 or y > 255:\n            message = 'Invalid block coordinates.'\n        elif w not in ALLOWED_ITEMS:\n            message = 'That item is not allowed.'\n        elif w and previous:\n            message = 'Cannot create blocks in a non-empty space.'\n        elif not w and not previous:\n            message = 'That space is already empty.'\n        elif previous in INDESTRUCTIBLE_ITEMS:\n            message = 'Cannot destroy that type of block.'\n        if message is not None:\n            client.send(BLOCK, p, q, x, y, z, previous)\n            client.send(REDRAW, p, q)\n            client.send(TALK, message)\n            return\n        query = (\n            'insert into block_history (timestamp, user_id, x, y, z, w) '\n            'values (:timestamp, :user_id, :x, :y, :z, :w);'\n        )\n        if RECORD_HISTORY:\n            self.execute(query, dict(timestamp=time.time(),\n                user_id=client.user_id, x=x, y=y, z=z, w=w))\n        query = (\n            'insert or replace into block (p, q, x, y, z, w) '\n            'values (:p, :q, :x, :y, :z, :w);'\n        )\n        self.execute(query, dict(p=p, q=q, x=x, y=y, z=z, w=w))\n        self.send_block(client, p, q, x, y, z, w)\n        for dx in range(-1, 2):\n            for dz in range(-1, 2):\n                if dx == 0 and dz == 0:\n                    continue\n                if dx and chunked(x + dx) == p:\n                    continue\n                if dz and chunked(z + dz) == q:\n                    continue\n                np, nq = p + dx, q + dz\n                self.execute(query, dict(p=np, q=nq, x=x, y=y, z=z, w=-w))\n                self.send_block(client, np, nq, x, y, z, -w)\n        if w == 0:\n            query = (\n                'delete from sign where '\n                'x = :x and y = :y and z = :z;'\n            )\n            self.execute(query, dict(x=x, y=y, z=z))\n            query = (\n                'update light set w = 0 where '\n                'x = :x and y = :y and z = :z;'\n            )\n            self.execute(query, dict(x=x, y=y, z=z))\n    def on_light(self, client, x, y, z, w):\n        x, y, z, w = map(int, (x, y, z, w))\n        p, q = chunked(x), chunked(z)\n        block = self.get_block(x, y, z)\n        message = None\n        if AUTH_REQUIRED and client.user_id is None:\n            message = 'Only logged in users are allowed to build.'\n        elif block == 0:\n            message = 'Lights must be placed on a block.'\n        elif w < 0 or w > 15:\n            message = 'Invalid light value.'\n        if message is not None:\n            # TODO: client.send(LIGHT, p, q, x, y, z, previous)\n            client.send(REDRAW, p, q)\n            client.send(TALK, message)\n            return\n        query = (\n            'insert or replace into light (p, q, x, y, z, w) '\n            'values (:p, :q, :x, :y, :z, :w);'\n        )\n        self.execute(query, dict(p=p, q=q, x=x, y=y, z=z, w=w))\n        self.send_light(client, p, q, x, y, z, w)\n    def on_sign(self, client, x, y, z, face, *args):\n        if AUTH_REQUIRED and client.user_id is None:\n            client.send(TALK, 'Only logged in users are allowed to build.')\n            return\n        text = ','.join(args)\n        x, y, z, face = map(int, (x, y, z, face))\n        if y <= 0 or y > 255:\n            return\n        if face < 0 or face > 7:\n            return\n        if len(text) > 48:\n            return\n        p, q = chunked(x), chunked(z)\n        if text:\n            query = (\n                'insert or replace into sign (p, q, x, y, z, face, text) '\n                'values (:p, :q, :x, :y, :z, :face, :text);'\n            )\n            self.execute(query,\n                dict(p=p, q=q, x=x, y=y, z=z, face=face, text=text))\n        else:\n            query = (\n                'delete from sign where '\n                'x = :x and y = :y and z = :z and face = :face;'\n            )\n            self.execute(query, dict(x=x, y=y, z=z, face=face))\n        self.send_sign(client, p, q, x, y, z, face, text)\n    def on_position(self, client, x, y, z, rx, ry):\n        x, y, z, rx, ry = map(float, (x, y, z, rx, ry))\n        client.position = (x, y, z, rx, ry)\n        self.send_position(client)\n    def on_talk(self, client, *args):\n        text = ','.join(args)\n        if text.startswith('/'):\n            for pattern, func in self.patterns:\n                match = pattern.match(text)\n                if match:\n                    func(client, *match.groups())\n                    break\n            else:\n                client.send(TALK, 'Unrecognized command: \"%s\"' % text)\n        elif text.startswith('@'):\n            nick = text[1:].split(' ', 1)[0]\n            for other in self.clients:\n                if other.nick == nick:\n                    client.send(TALK, '%s> %s' % (client.nick, text))\n                    other.send(TALK, '%s> %s' % (client.nick, text))\n                    break\n            else:\n                client.send(TALK, 'Unrecognized nick: \"%s\"' % nick)\n        else:\n            self.send_talk('%s> %s' % (client.nick, text))\n    def on_nick(self, client, nick=None):\n        if AUTH_REQUIRED:\n            client.send(TALK, 'You cannot change your nick on this server.')\n            return\n        if nick is None:\n            client.send(TALK, 'Your nickname is %s' % client.nick)\n        else:\n            self.send_talk('%s is now known as %s' % (client.nick, nick))\n            client.nick = nick\n            self.send_nick(client)\n    def on_spawn(self, client):\n        client.position = SPAWN_POINT\n        client.send(YOU, client.client_id, *client.position)\n        self.send_position(client)\n    def on_goto(self, client, nick=None):\n        if nick is None:\n            clients = [x for x in self.clients if x != client]\n            other = random.choice(clients) if clients else None\n        else:\n            nicks = dict((client.nick, client) for client in self.clients)\n            other = nicks.get(nick)\n        if other:\n            client.position = other.position\n            client.send(YOU, client.client_id, *client.position)\n            self.send_position(client)\n    def on_pq(self, client, p, q):\n        p, q = map(int, (p, q))\n        if abs(p) > 1000 or abs(q) > 1000:\n            return\n        client.position = (p * CHUNK_SIZE, 0, q * CHUNK_SIZE, 0, 0)\n        client.send(YOU, client.client_id, *client.position)\n        self.send_position(client)\n    def on_help(self, client, topic=None):\n        if topic is None:\n            client.send(TALK, 'Type \"t\" to chat. Type \"/\" to type commands:')\n            client.send(TALK, '/goto [NAME], /help [TOPIC], /list, /login NAME, /logout, /nick')\n            client.send(TALK, '/offline [FILE], /online HOST [PORT], /pq P Q, /spawn, /view N')\n            return\n        topic = topic.lower().strip()\n        if topic == 'goto':\n            client.send(TALK, 'Help: /goto [NAME]')\n            client.send(TALK, 'Teleport to another user.')\n            client.send(TALK, 'If NAME is unspecified, a random user is chosen.')\n        elif topic == 'list':\n            client.send(TALK, 'Help: /list')\n            client.send(TALK, 'Display a list of connected users.')\n        elif topic == 'login':\n            client.send(TALK, 'Help: /login NAME')\n            client.send(TALK, 'Switch to another registered username.')\n            client.send(TALK, 'The login server will be re-contacted. The username is case-sensitive.')\n        elif topic == 'logout':\n            client.send(TALK, 'Help: /logout')\n            client.send(TALK, 'Unauthenticate and become a guest user.')\n            client.send(TALK, 'Automatic logins will not occur again until the /login command is re-issued.')\n        elif topic == 'offline':\n            client.send(TALK, 'Help: /offline [FILE]')\n            client.send(TALK, 'Switch to offline mode.')\n            client.send(TALK, 'FILE specifies the save file to use and defaults to \"craft\".')\n        elif topic == 'online':\n            client.send(TALK, 'Help: /online HOST [PORT]')\n            client.send(TALK, 'Connect to the specified server.')\n        elif topic == 'nick':\n            client.send(TALK, 'Help: /nick [NICK]')\n            client.send(TALK, 'Get or set your nickname.')\n        elif topic == 'pq':\n            client.send(TALK, 'Help: /pq P Q')\n            client.send(TALK, 'Teleport to the specified chunk.')\n        elif topic == 'spawn':\n            client.send(TALK, 'Help: /spawn')\n            client.send(TALK, 'Teleport back to the spawn point.')\n        elif topic == 'view':\n            client.send(TALK, 'Help: /view N')\n            client.send(TALK, 'Set viewing distance, 1 - 24.')\n    def on_list(self, client):\n        client.send(TALK,\n            'Players: %s' % ', '.join(x.nick for x in self.clients))\n    def send_positions(self, client):\n        for other in self.clients:\n            if other == client:\n                continue\n            client.send(POSITION, other.client_id, *other.position)\n    def send_position(self, client):\n        for other in self.clients:\n            if other == client:\n                continue\n            other.send(POSITION, client.client_id, *client.position)\n    def send_nicks(self, client):\n        for other in self.clients:\n            if other == client:\n                continue\n            client.send(NICK, other.client_id, other.nick)\n    def send_nick(self, client):\n        for other in self.clients:\n            other.send(NICK, client.client_id, client.nick)\n    def send_disconnect(self, client):\n        for other in self.clients:\n            if other == client:\n                continue\n            other.send(DISCONNECT, client.client_id)\n    def send_block(self, client, p, q, x, y, z, w):\n        for other in self.clients:\n            if other == client:\n                continue\n            other.send(BLOCK, p, q, x, y, z, w)\n            other.send(REDRAW, p, q)\n    def send_light(self, client, p, q, x, y, z, w):\n        for other in self.clients:\n            if other == client:\n                continue\n            other.send(LIGHT, p, q, x, y, z, w)\n            other.send(REDRAW, p, q)\n    def send_sign(self, client, p, q, x, y, z, face, text):\n        for other in self.clients:\n            if other == client:\n                continue\n            other.send(SIGN, p, q, x, y, z, face, text)\n    def send_talk(self, text):\n        log(text)\n        for client in self.clients:\n            client.send(TALK, text)\n\ndef cleanup():\n    world = World(None)\n    conn = sqlite3.connect(DB_PATH)\n    query = 'select x, y, z from block order by rowid desc limit 1;'\n    last = list(conn.execute(query))[0]\n    query = 'select distinct p, q from block;'\n    chunks = list(conn.execute(query))\n    count = 0\n    total = 0\n    delete_query = 'delete from block where x = %d and y = %d and z = %d;'\n    print 'begin;'\n    for p, q in chunks:\n        chunk = world.create_chunk(p, q)\n        query = 'select x, y, z, w from block where p = :p and q = :q;'\n        rows = conn.execute(query, {'p': p, 'q': q})\n        for x, y, z, w in rows:\n            if chunked(x) != p or chunked(z) != q:\n                continue\n            total += 1\n            if (x, y, z) == last:\n                continue\n            original = chunk.get((x, y, z), 0)\n            if w == original or original in INDESTRUCTIBLE_ITEMS:\n                count += 1\n                print delete_query % (x, y, z)\n    conn.close()\n    print 'commit;'\n    print >> sys.stderr, '%d of %d blocks will be cleaned up' % (count, total)\n\ndef main():\n    if len(sys.argv) == 2 and sys.argv[1] == 'cleanup':\n        cleanup()\n        return\n    host, port = DEFAULT_HOST, DEFAULT_PORT\n    if len(sys.argv) > 1:\n        host = sys.argv[1]\n    if len(sys.argv) > 2:\n        port = int(sys.argv[2])\n    log('SERV', host, port)\n    model = Model(None)\n    model.start()\n    server = Server((host, port), Handler)\n    server.model = model\n    server.serve_forever()\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "shaders/block_fragment.glsl",
    "content": "#version 120\n\nuniform sampler2D sampler;\nuniform sampler2D sky_sampler;\nuniform float timer;\nuniform float daylight;\nuniform int ortho;\n\nvarying vec2 fragment_uv;\nvarying float fragment_ao;\nvarying float fragment_light;\nvarying float fog_factor;\nvarying float fog_height;\nvarying float diffuse;\n\nconst float pi = 3.14159265;\n\nvoid main() {\n    vec3 color = vec3(texture2D(sampler, fragment_uv));\n    if (color == vec3(1.0, 0.0, 1.0)) {\n        discard;\n    }\n    bool cloud = color == vec3(1.0, 1.0, 1.0);\n    if (cloud && bool(ortho)) {\n        discard;\n    }\n    float df = cloud ? 1.0 - diffuse * 0.2 : diffuse;\n    float ao = cloud ? 1.0 - (1.0 - fragment_ao) * 0.2 : fragment_ao;\n    ao = min(1.0, ao + fragment_light);\n    df = min(1.0, df + fragment_light);\n    float value = min(1.0, daylight + fragment_light);\n    vec3 light_color = vec3(value * 0.3 + 0.2);\n    vec3 ambient = vec3(value * 0.3 + 0.2);\n    vec3 light = ambient + light_color * df;\n    color = clamp(color * light * ao, vec3(0.0), vec3(1.0));\n    vec3 sky_color = vec3(texture2D(sky_sampler, vec2(timer, fog_height)));\n    color = mix(color, sky_color, fog_factor);\n    gl_FragColor = vec4(color, 1.0);\n}\n"
  },
  {
    "path": "shaders/block_vertex.glsl",
    "content": "#version 120\n\nuniform mat4 matrix;\nuniform vec3 camera;\nuniform float fog_distance;\nuniform int ortho;\n\nattribute vec4 position;\nattribute vec3 normal;\nattribute vec4 uv;\n\nvarying vec2 fragment_uv;\nvarying float fragment_ao;\nvarying float fragment_light;\nvarying float fog_factor;\nvarying float fog_height;\nvarying float diffuse;\n\nconst float pi = 3.14159265;\nconst vec3 light_direction = normalize(vec3(-1.0, 1.0, -1.0));\n\nvoid main() {\n    gl_Position = matrix * position;\n    fragment_uv = uv.xy;\n    fragment_ao = 0.3 + (1.0 - uv.z) * 0.7;\n    fragment_light = uv.w;\n    diffuse = max(0.0, dot(normal, light_direction));\n    if (bool(ortho)) {\n        fog_factor = 0.0;\n        fog_height = 0.0;\n    }\n    else {\n        float camera_distance = distance(camera, vec3(position));\n        fog_factor = pow(clamp(camera_distance / fog_distance, 0.0, 1.0), 4.0);\n        float dy = position.y - camera.y;\n        float dx = distance(position.xz, camera.xz);\n        fog_height = (atan(dy, dx) + pi / 2) / pi;\n    }\n}\n"
  },
  {
    "path": "shaders/line_fragment.glsl",
    "content": "#version 120\n\nvoid main() {\n    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n"
  },
  {
    "path": "shaders/line_vertex.glsl",
    "content": "#version 120\n\nuniform mat4 matrix;\n\nattribute vec4 position;\n\nvoid main() {\n    gl_Position = matrix * position;\n}\n"
  },
  {
    "path": "shaders/sky_fragment.glsl",
    "content": "#version 120\n\nuniform sampler2D sampler;\nuniform float timer;\n\nvarying vec2 fragment_uv;\n\nvoid main() {\n    vec2 uv = vec2(timer, fragment_uv.t);\n    gl_FragColor = texture2D(sampler, uv);\n}\n"
  },
  {
    "path": "shaders/sky_vertex.glsl",
    "content": "#version 120\n\nuniform mat4 matrix;\n\nattribute vec4 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nvarying vec2 fragment_uv;\n\nvoid main() {\n    gl_Position = matrix * position;\n    fragment_uv = uv;\n}\n"
  },
  {
    "path": "shaders/text_fragment.glsl",
    "content": "#version 120\n\nuniform sampler2D sampler;\nuniform bool is_sign;\n\nvarying vec2 fragment_uv;\n\nvoid main() {\n    vec4 color = texture2D(sampler, fragment_uv);\n    if (is_sign) {\n        if (color == vec4(1.0)) {\n            discard;\n        }\n    }\n    else {\n        color.a = max(color.a, 0.4);\n    }\n    gl_FragColor = color;\n}\n"
  },
  {
    "path": "shaders/text_vertex.glsl",
    "content": "#version 120\n\nuniform mat4 matrix;\n\nattribute vec4 position;\nattribute vec2 uv;\n\nvarying vec2 fragment_uv;\n\nvoid main() {\n    gl_Position = matrix * position;\n    fragment_uv = uv;\n}\n"
  },
  {
    "path": "src/auth.c",
    "content": "#include <curl/curl.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"auth.h\"\n\n#define MAX_POST_LENGTH 1024\n#define MAX_RESPONSE_LENGTH 1024\n\nsize_t write_function(char *data, size_t size, size_t count, void *arg) {\n    size_t length = size * count;\n    char *dst = (char *)arg;\n    char *src = malloc(length + 1);\n    memcpy(src, data, length);\n    src[length] = '\\0';\n    strncat(dst, src, MAX_RESPONSE_LENGTH - strlen(dst) - 1);\n    free(src);\n    return length;\n}\n\nint get_access_token(\n    char *result, int length, char *username, char *identity_token)\n{\n    static char url[] = \"https://craft.michaelfogleman.com/api/1/identity\";\n    strncpy(result, \"\", length);\n    CURL *curl = curl_easy_init();\n    if (curl) {\n        char post[MAX_POST_LENGTH] = {0};\n        char response[MAX_RESPONSE_LENGTH] = {0};\n        long http_code = 0;\n        snprintf(post, MAX_POST_LENGTH, \"username=%s&identity_token=%s\",\n            username, identity_token);\n        #ifdef _WIN32\n            curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);\n        #endif\n        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_function);\n        curl_easy_setopt(curl, CURLOPT_WRITEDATA, response);\n        curl_easy_setopt(curl, CURLOPT_URL, url);\n        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post);\n        CURLcode code = curl_easy_perform(curl);\n        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);\n        curl_easy_cleanup(curl);\n        if (code == CURLE_OK && http_code == 200) {\n            strncpy(result, response, length);\n            return 1;\n        }\n    }\n    return 0;\n}\n"
  },
  {
    "path": "src/auth.h",
    "content": "#ifndef _auth_h_\n#define _auth_h_\n\nint get_access_token(\n    char *result, int length, char *username, char *identity_token);\n\n#endif\n"
  },
  {
    "path": "src/client.c",
    "content": "#ifdef _WIN32\n    #include <winsock2.h>\n    #include <windows.h>\n    #define close closesocket\n    #define sleep Sleep\n#else\n    #include <netdb.h>\n    #include <unistd.h>\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"client.h\"\n#include \"tinycthread.h\"\n\n#define QUEUE_SIZE 1048576\n#define RECV_SIZE 4096\n\nstatic int client_enabled = 0;\nstatic int running = 0;\nstatic int sd = 0;\nstatic int bytes_sent = 0;\nstatic int bytes_received = 0;\nstatic char *queue = 0;\nstatic int qsize = 0;\nstatic thrd_t recv_thread;\nstatic mtx_t mutex;\n\nvoid client_enable() {\n    client_enabled = 1;\n}\n\nvoid client_disable() {\n    client_enabled = 0;\n}\n\nint get_client_enabled() {\n    return client_enabled;\n}\n\nint client_sendall(int sd, char *data, int length) {\n    if (!client_enabled) {\n        return 0;\n    }\n    int count = 0;\n    while (count < length) {\n        int n = send(sd, data + count, length, 0);\n        if (n == -1) {\n            return -1;\n        }\n        count += n;\n        length -= n;\n        bytes_sent += n;\n    }\n    return 0;\n}\n\nvoid client_send(char *data) {\n    if (!client_enabled) {\n        return;\n    }\n    if (client_sendall(sd, data, strlen(data)) == -1) {\n        perror(\"client_sendall\");\n        exit(1);\n    }\n}\n\nvoid client_version(int version) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"V,%d\\n\", version);\n    client_send(buffer);\n}\n\nvoid client_login(const char *username, const char *identity_token) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"A,%s,%s\\n\", username, identity_token);\n    client_send(buffer);\n}\n\nvoid client_position(float x, float y, float z, float rx, float ry) {\n    if (!client_enabled) {\n        return;\n    }\n    static float px, py, pz, prx, pry = 0;\n    float distance =\n        (px - x) * (px - x) +\n        (py - y) * (py - y) +\n        (pz - z) * (pz - z) +\n        (prx - rx) * (prx - rx) +\n        (pry - ry) * (pry - ry);\n    if (distance < 0.0001) {\n        return;\n    }\n    px = x; py = y; pz = z; prx = rx; pry = ry;\n    char buffer[1024];\n    snprintf(buffer, 1024, \"P,%.2f,%.2f,%.2f,%.2f,%.2f\\n\", x, y, z, rx, ry);\n    client_send(buffer);\n}\n\nvoid client_chunk(int p, int q, int key) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"C,%d,%d,%d\\n\", p, q, key);\n    client_send(buffer);\n}\n\nvoid client_block(int x, int y, int z, int w) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"B,%d,%d,%d,%d\\n\", x, y, z, w);\n    client_send(buffer);\n}\n\nvoid client_light(int x, int y, int z, int w) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"L,%d,%d,%d,%d\\n\", x, y, z, w);\n    client_send(buffer);\n}\n\nvoid client_sign(int x, int y, int z, int face, const char *text) {\n    if (!client_enabled) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"S,%d,%d,%d,%d,%s\\n\", x, y, z, face, text);\n    client_send(buffer);\n}\n\nvoid client_talk(const char *text) {\n    if (!client_enabled) {\n        return;\n    }\n    if (strlen(text) == 0) {\n        return;\n    }\n    char buffer[1024];\n    snprintf(buffer, 1024, \"T,%s\\n\", text);\n    client_send(buffer);\n}\n\nchar *client_recv() {\n    if (!client_enabled) {\n        return 0;\n    }\n    char *result = 0;\n    mtx_lock(&mutex);\n    char *p = queue + qsize - 1;\n    while (p >= queue && *p != '\\n') {\n        p--;\n    }\n    if (p >= queue) {\n        int length = p - queue + 1;\n        result = malloc(sizeof(char) * (length + 1));\n        memcpy(result, queue, sizeof(char) * length);\n        result[length] = '\\0';\n        int remaining = qsize - length;\n        memmove(queue, p + 1, remaining);\n        qsize -= length;\n        bytes_received += length;\n    }\n    mtx_unlock(&mutex);\n    return result;\n}\n\nint recv_worker(void *arg) {\n    char *data = malloc(sizeof(char) * RECV_SIZE);\n    while (1) {\n        int length;\n        if ((length = recv(sd, data, RECV_SIZE - 1, 0)) <= 0) {\n            if (running) {\n                perror(\"recv\");\n                exit(1);\n            }\n            else {\n                break;\n            }\n        }\n        data[length] = '\\0';\n        while (1) {\n            int done = 0;\n            mtx_lock(&mutex);\n            if (qsize + length < QUEUE_SIZE) {\n                memcpy(queue + qsize, data, sizeof(char) * (length + 1));\n                qsize += length;\n                done = 1;\n            }\n            mtx_unlock(&mutex);\n            if (done) {\n                break;\n            }\n            sleep(0);\n        }\n    }\n    free(data);\n    return 0;\n}\n\nvoid client_connect(char *hostname, int port) {\n    if (!client_enabled) {\n        return;\n    }\n    struct hostent *host;\n    struct sockaddr_in address;\n    if ((host = gethostbyname(hostname)) == 0) {\n        perror(\"gethostbyname\");\n        exit(1);\n    }\n    memset(&address, 0, sizeof(address));\n    address.sin_family = AF_INET;\n    address.sin_addr.s_addr = ((struct in_addr *)(host->h_addr_list[0]))->s_addr;\n    address.sin_port = htons(port);\n    if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n        perror(\"socket\");\n        exit(1);\n    }\n    if (connect(sd, (struct sockaddr *)&address, sizeof(address)) == -1) {\n        perror(\"connect\");\n        exit(1);\n    }\n}\n\nvoid client_start() {\n    if (!client_enabled) {\n        return;\n    }\n    running = 1;\n    queue = (char *)calloc(QUEUE_SIZE, sizeof(char));\n    qsize = 0;\n    mtx_init(&mutex, mtx_plain);\n    if (thrd_create(&recv_thread, recv_worker, NULL) != thrd_success) {\n        perror(\"thrd_create\");\n        exit(1);\n    }\n}\n\nvoid client_stop() {\n    if (!client_enabled) {\n        return;\n    }\n    running = 0;\n    close(sd);\n    // if (thrd_join(recv_thread, NULL) != thrd_success) {\n    //     perror(\"thrd_join\");\n    //     exit(1);\n    // }\n    // mtx_destroy(&mutex);\n    qsize = 0;\n    free(queue);\n    // printf(\"Bytes Sent: %d, Bytes Received: %d\\n\",\n    //     bytes_sent, bytes_received);\n}\n"
  },
  {
    "path": "src/client.h",
    "content": "#ifndef _client_h_\n#define _client_h_\n\n#define DEFAULT_PORT 4080\n\nvoid client_enable();\nvoid client_disable();\nint get_client_enabled();\nvoid client_connect(char *hostname, int port);\nvoid client_start();\nvoid client_stop();\nvoid client_send(char *data);\nchar *client_recv();\nvoid client_version(int version);\nvoid client_login(const char *username, const char *identity_token);\nvoid client_position(float x, float y, float z, float rx, float ry);\nvoid client_chunk(int p, int q, int key);\nvoid client_block(int x, int y, int z, int w);\nvoid client_light(int x, int y, int z, int w);\nvoid client_sign(int x, int y, int z, int face, const char *text);\nvoid client_talk(const char *text);\n\n#endif\n"
  },
  {
    "path": "src/config.h",
    "content": "#ifndef _config_h_\n#define _config_h_\n\n// app parameters\n#define DEBUG 0\n#define FULLSCREEN 0\n#define WINDOW_WIDTH 1024\n#define WINDOW_HEIGHT 768\n#define VSYNC 1\n#define SCROLL_THRESHOLD 0.1\n#define MAX_MESSAGES 4\n#define DB_PATH \"craft.db\"\n#define USE_CACHE 1\n#define DAY_LENGTH 600\n#define INVERT_MOUSE 0\n\n// rendering options\n#define SHOW_LIGHTS 1\n#define SHOW_PLANTS 1\n#define SHOW_CLOUDS 1\n#define SHOW_TREES 1\n#define SHOW_ITEM 1\n#define SHOW_CROSSHAIRS 1\n#define SHOW_WIREFRAME 1\n#define SHOW_INFO_TEXT 1\n#define SHOW_CHAT_TEXT 1\n#define SHOW_PLAYER_NAMES 1\n\n// key bindings\n#define CRAFT_KEY_FORWARD 'W'\n#define CRAFT_KEY_BACKWARD 'S'\n#define CRAFT_KEY_LEFT 'A'\n#define CRAFT_KEY_RIGHT 'D'\n#define CRAFT_KEY_JUMP GLFW_KEY_SPACE\n#define CRAFT_KEY_FLY GLFW_KEY_TAB\n#define CRAFT_KEY_OBSERVE 'O'\n#define CRAFT_KEY_OBSERVE_INSET 'P'\n#define CRAFT_KEY_ITEM_NEXT 'E'\n#define CRAFT_KEY_ITEM_PREV 'R'\n#define CRAFT_KEY_ZOOM GLFW_KEY_LEFT_SHIFT\n#define CRAFT_KEY_ORTHO 'F'\n#define CRAFT_KEY_CHAT 't'\n#define CRAFT_KEY_COMMAND '/'\n#define CRAFT_KEY_SIGN '`'\n\n// advanced parameters\n#define CREATE_CHUNK_RADIUS 10\n#define RENDER_CHUNK_RADIUS 10\n#define RENDER_SIGN_RADIUS 4\n#define DELETE_CHUNK_RADIUS 14\n#define CHUNK_SIZE 32\n#define COMMIT_INTERVAL 5\n\n#endif\n"
  },
  {
    "path": "src/cube.c",
    "content": "#include <math.h>\n#include \"cube.h\"\n#include \"item.h\"\n#include \"matrix.h\"\n#include \"util.h\"\n\nvoid make_cube_faces(\n    float *data, float ao[6][4], float light[6][4],\n    int left, int right, int top, int bottom, int front, int back,\n    int wleft, int wright, int wtop, int wbottom, int wfront, int wback,\n    float x, float y, float z, float n)\n{\n    static const float positions[6][4][3] = {\n        {{-1, -1, -1}, {-1, -1, +1}, {-1, +1, -1}, {-1, +1, +1}},\n        {{+1, -1, -1}, {+1, -1, +1}, {+1, +1, -1}, {+1, +1, +1}},\n        {{-1, +1, -1}, {-1, +1, +1}, {+1, +1, -1}, {+1, +1, +1}},\n        {{-1, -1, -1}, {-1, -1, +1}, {+1, -1, -1}, {+1, -1, +1}},\n        {{-1, -1, -1}, {-1, +1, -1}, {+1, -1, -1}, {+1, +1, -1}},\n        {{-1, -1, +1}, {-1, +1, +1}, {+1, -1, +1}, {+1, +1, +1}}\n    };\n    static const float normals[6][3] = {\n        {-1, 0, 0},\n        {+1, 0, 0},\n        {0, +1, 0},\n        {0, -1, 0},\n        {0, 0, -1},\n        {0, 0, +1}\n    };\n    static const float uvs[6][4][2] = {\n        {{0, 0}, {1, 0}, {0, 1}, {1, 1}},\n        {{1, 0}, {0, 0}, {1, 1}, {0, 1}},\n        {{0, 1}, {0, 0}, {1, 1}, {1, 0}},\n        {{0, 0}, {0, 1}, {1, 0}, {1, 1}},\n        {{0, 0}, {0, 1}, {1, 0}, {1, 1}},\n        {{1, 0}, {1, 1}, {0, 0}, {0, 1}}\n    };\n    static const float indices[6][6] = {\n        {0, 3, 2, 0, 1, 3},\n        {0, 3, 1, 0, 2, 3},\n        {0, 3, 2, 0, 1, 3},\n        {0, 3, 1, 0, 2, 3},\n        {0, 3, 2, 0, 1, 3},\n        {0, 3, 1, 0, 2, 3}\n    };\n    static const float flipped[6][6] = {\n        {0, 1, 2, 1, 3, 2},\n        {0, 2, 1, 2, 3, 1},\n        {0, 1, 2, 1, 3, 2},\n        {0, 2, 1, 2, 3, 1},\n        {0, 1, 2, 1, 3, 2},\n        {0, 2, 1, 2, 3, 1}\n    };\n    float *d = data;\n    float s = 0.0625;\n    float a = 0 + 1 / 2048.0;\n    float b = s - 1 / 2048.0;\n    int faces[6] = {left, right, top, bottom, front, back};\n    int tiles[6] = {wleft, wright, wtop, wbottom, wfront, wback};\n    for (int i = 0; i < 6; i++) {\n        if (faces[i] == 0) {\n            continue;\n        }\n        float du = (tiles[i] % 16) * s;\n        float dv = (tiles[i] / 16) * s;\n        int flip = ao[i][0] + ao[i][3] > ao[i][1] + ao[i][2];\n        for (int v = 0; v < 6; v++) {\n            int j = flip ? flipped[i][v] : indices[i][v];\n            *(d++) = x + n * positions[i][j][0];\n            *(d++) = y + n * positions[i][j][1];\n            *(d++) = z + n * positions[i][j][2];\n            *(d++) = normals[i][0];\n            *(d++) = normals[i][1];\n            *(d++) = normals[i][2];\n            *(d++) = du + (uvs[i][j][0] ? b : a);\n            *(d++) = dv + (uvs[i][j][1] ? b : a);\n            *(d++) = ao[i][j];\n            *(d++) = light[i][j];\n        }\n    }\n}\n\nvoid make_cube(\n    float *data, float ao[6][4], float light[6][4],\n    int left, int right, int top, int bottom, int front, int back,\n    float x, float y, float z, float n, int w)\n{\n    int wleft = blocks[w][0];\n    int wright = blocks[w][1];\n    int wtop = blocks[w][2];\n    int wbottom = blocks[w][3];\n    int wfront = blocks[w][4];\n    int wback = blocks[w][5];\n    make_cube_faces(\n        data, ao, light,\n        left, right, top, bottom, front, back,\n        wleft, wright, wtop, wbottom, wfront, wback,\n        x, y, z, n);\n}\n\nvoid make_plant(\n    float *data, float ao, float light,\n    float px, float py, float pz, float n, int w, float rotation)\n{\n    static const float positions[4][4][3] = {\n        {{ 0, -1, -1}, { 0, -1, +1}, { 0, +1, -1}, { 0, +1, +1}},\n        {{ 0, -1, -1}, { 0, -1, +1}, { 0, +1, -1}, { 0, +1, +1}},\n        {{-1, -1,  0}, {-1, +1,  0}, {+1, -1,  0}, {+1, +1,  0}},\n        {{-1, -1,  0}, {-1, +1,  0}, {+1, -1,  0}, {+1, +1,  0}}\n    };\n    static const float normals[4][3] = {\n        {-1, 0, 0},\n        {+1, 0, 0},\n        {0, 0, -1},\n        {0, 0, +1}\n    };\n    static const float uvs[4][4][2] = {\n        {{0, 0}, {1, 0}, {0, 1}, {1, 1}},\n        {{1, 0}, {0, 0}, {1, 1}, {0, 1}},\n        {{0, 0}, {0, 1}, {1, 0}, {1, 1}},\n        {{1, 0}, {1, 1}, {0, 0}, {0, 1}}\n    };\n    static const float indices[4][6] = {\n        {0, 3, 2, 0, 1, 3},\n        {0, 3, 1, 0, 2, 3},\n        {0, 3, 2, 0, 1, 3},\n        {0, 3, 1, 0, 2, 3}\n    };\n    float *d = data;\n    float s = 0.0625;\n    float a = 0;\n    float b = s;\n    float du = (plants[w] % 16) * s;\n    float dv = (plants[w] / 16) * s;\n    for (int i = 0; i < 4; i++) {\n        for (int v = 0; v < 6; v++) {\n            int j = indices[i][v];\n            *(d++) = n * positions[i][j][0];\n            *(d++) = n * positions[i][j][1];\n            *(d++) = n * positions[i][j][2];\n            *(d++) = normals[i][0];\n            *(d++) = normals[i][1];\n            *(d++) = normals[i][2];\n            *(d++) = du + (uvs[i][j][0] ? b : a);\n            *(d++) = dv + (uvs[i][j][1] ? b : a);\n            *(d++) = ao;\n            *(d++) = light;\n        }\n    }\n    float ma[16];\n    float mb[16];\n    mat_identity(ma);\n    mat_rotate(mb, 0, 1, 0, RADIANS(rotation));\n    mat_multiply(ma, mb, ma);\n    mat_apply(data, ma, 24, 3, 10);\n    mat_translate(mb, px, py, pz);\n    mat_multiply(ma, mb, ma);\n    mat_apply(data, ma, 24, 0, 10);\n}\n\nvoid make_player(\n    float *data,\n    float x, float y, float z, float rx, float ry)\n{\n    float ao[6][4] = {0};\n    float light[6][4] = {\n        {0.8, 0.8, 0.8, 0.8},\n        {0.8, 0.8, 0.8, 0.8},\n        {0.8, 0.8, 0.8, 0.8},\n        {0.8, 0.8, 0.8, 0.8},\n        {0.8, 0.8, 0.8, 0.8},\n        {0.8, 0.8, 0.8, 0.8}\n    };\n    make_cube_faces(\n        data, ao, light,\n        1, 1, 1, 1, 1, 1,\n        226, 224, 241, 209, 225, 227,\n        0, 0, 0, 0.4);\n    float ma[16];\n    float mb[16];\n    mat_identity(ma);\n    mat_rotate(mb, 0, 1, 0, rx);\n    mat_multiply(ma, mb, ma);\n    mat_rotate(mb, cosf(rx), 0, sinf(rx), -ry);\n    mat_multiply(ma, mb, ma);\n    mat_apply(data, ma, 36, 3, 10);\n    mat_translate(mb, x, y, z);\n    mat_multiply(ma, mb, ma);\n    mat_apply(data, ma, 36, 0, 10);\n}\n\nvoid make_cube_wireframe(float *data, float x, float y, float z, float n) {\n    static const float positions[8][3] = {\n        {-1, -1, -1},\n        {-1, -1, +1},\n        {-1, +1, -1},\n        {-1, +1, +1},\n        {+1, -1, -1},\n        {+1, -1, +1},\n        {+1, +1, -1},\n        {+1, +1, +1}\n    };\n    static const int indices[24] = {\n        0, 1, 0, 2, 0, 4, 1, 3,\n        1, 5, 2, 3, 2, 6, 3, 7,\n        4, 5, 4, 6, 5, 7, 6, 7\n    };\n    float *d = data;\n    for (int i = 0; i < 24; i++) {\n        int j = indices[i];\n        *(d++) = x + n * positions[j][0];\n        *(d++) = y + n * positions[j][1];\n        *(d++) = z + n * positions[j][2];\n    }\n}\n\nvoid make_character(\n    float *data,\n    float x, float y, float n, float m, char c)\n{\n    float *d = data;\n    float s = 0.0625;\n    float a = s;\n    float b = s * 2;\n    int w = c - 32;\n    float du = (w % 16) * a;\n    float dv = 1 - (w / 16) * b - b;\n    *(d++) = x - n; *(d++) = y - m;\n    *(d++) = du + 0; *(d++) = dv;\n    *(d++) = x + n; *(d++) = y - m;\n    *(d++) = du + a; *(d++) = dv;\n    *(d++) = x + n; *(d++) = y + m;\n    *(d++) = du + a; *(d++) = dv + b;\n    *(d++) = x - n; *(d++) = y - m;\n    *(d++) = du + 0; *(d++) = dv;\n    *(d++) = x + n; *(d++) = y + m;\n    *(d++) = du + a; *(d++) = dv + b;\n    *(d++) = x - n; *(d++) = y + m;\n    *(d++) = du + 0; *(d++) = dv + b;\n}\n\nvoid make_character_3d(\n    float *data, float x, float y, float z, float n, int face, char c)\n{\n    static const float positions[8][6][3] = {\n        {{0, -2, -1}, {0, +2, +1}, {0, +2, -1},\n         {0, -2, -1}, {0, -2, +1}, {0, +2, +1}},\n        {{0, -2, -1}, {0, +2, +1}, {0, -2, +1},\n         {0, -2, -1}, {0, +2, -1}, {0, +2, +1}},\n        {{-1, -2, 0}, {+1, +2, 0}, {+1, -2, 0},\n         {-1, -2, 0}, {-1, +2, 0}, {+1, +2, 0}},\n        {{-1, -2, 0}, {+1, -2, 0}, {+1, +2, 0},\n         {-1, -2, 0}, {+1, +2, 0}, {-1, +2, 0}},\n        {{-1, 0, +2}, {+1, 0, +2}, {+1, 0, -2},\n         {-1, 0, +2}, {+1, 0, -2}, {-1, 0, -2}},\n        {{-2, 0, +1}, {+2, 0, -1}, {-2, 0, -1},\n         {-2, 0, +1}, {+2, 0, +1}, {+2, 0, -1}},\n        {{+1, 0, +2}, {-1, 0, -2}, {-1, 0, +2},\n         {+1, 0, +2}, {+1, 0, -2}, {-1, 0, -2}},\n        {{+2, 0, -1}, {-2, 0, +1}, {+2, 0, +1},\n         {+2, 0, -1}, {-2, 0, -1}, {-2, 0, +1}}\n    };\n    static const float uvs[8][6][2] = {\n        {{0, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}, {1, 1}},\n        {{1, 0}, {0, 1}, {0, 0}, {1, 0}, {1, 1}, {0, 1}},\n        {{1, 0}, {0, 1}, {0, 0}, {1, 0}, {1, 1}, {0, 1}},\n        {{0, 0}, {1, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 1}},\n        {{0, 0}, {1, 0}, {1, 1}, {0, 0}, {1, 1}, {0, 1}},\n        {{0, 1}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}},\n        {{0, 1}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}},\n        {{0, 1}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}\n    };\n    static const float offsets[8][3] = {\n        {-1, 0, 0}, {+1, 0, 0}, {0, 0, -1}, {0, 0, +1},\n        {0, +1, 0}, {0, +1, 0}, {0, +1, 0}, {0, +1, 0},\n    };\n    float *d = data;\n    float s = 0.0625;\n    float pu = s / 5;\n    float pv = s / 2.5;\n    float u1 = pu;\n    float v1 = pv;\n    float u2 = s - pu;\n    float v2 = s * 2 - pv;\n    float p = 0.5;\n    int w = c - 32;\n    float du = (w % 16) * s;\n    float dv = 1 - (w / 16 + 1) * s * 2;\n    x += p * offsets[face][0];\n    y += p * offsets[face][1];\n    z += p * offsets[face][2];\n    for (int i = 0; i < 6; i++) {\n        *(d++) = x + n * positions[face][i][0];\n        *(d++) = y + n * positions[face][i][1];\n        *(d++) = z + n * positions[face][i][2];\n        *(d++) = du + (uvs[face][i][0] ? u2 : u1);\n        *(d++) = dv + (uvs[face][i][1] ? v2 : v1);\n    }\n}\n\nint _make_sphere(\n    float *data, float r, int detail,\n    float *a, float *b, float *c,\n    float *ta, float *tb, float *tc)\n{\n    if (detail == 0) {\n        float *d = data;\n        *(d++) = a[0] * r; *(d++) = a[1] * r; *(d++) = a[2] * r;\n        *(d++) = a[0]; *(d++) = a[1]; *(d++) = a[2];\n        *(d++) = ta[0]; *(d++) = ta[1];\n        *(d++) = b[0] * r; *(d++) = b[1] * r; *(d++) = b[2] * r;\n        *(d++) = b[0]; *(d++) = b[1]; *(d++) = b[2];\n        *(d++) = tb[0]; *(d++) = tb[1];\n        *(d++) = c[0] * r; *(d++) = c[1] * r; *(d++) = c[2] * r;\n        *(d++) = c[0]; *(d++) = c[1]; *(d++) = c[2];\n        *(d++) = tc[0]; *(d++) = tc[1];\n        return 1;\n    }\n    else {\n        float ab[3], ac[3], bc[3];\n        for (int i = 0; i < 3; i++) {\n            ab[i] = (a[i] + b[i]) / 2;\n            ac[i] = (a[i] + c[i]) / 2;\n            bc[i] = (b[i] + c[i]) / 2;\n        }\n        normalize(ab + 0, ab + 1, ab + 2);\n        normalize(ac + 0, ac + 1, ac + 2);\n        normalize(bc + 0, bc + 1, bc + 2);\n        float tab[2], tac[2], tbc[2];\n        tab[0] = 0; tab[1] = 1 - acosf(ab[1]) / PI;\n        tac[0] = 0; tac[1] = 1 - acosf(ac[1]) / PI;\n        tbc[0] = 0; tbc[1] = 1 - acosf(bc[1]) / PI;\n        int total = 0;\n        int n;\n        n = _make_sphere(data, r, detail - 1, a, ab, ac, ta, tab, tac);\n        total += n; data += n * 24;\n        n = _make_sphere(data, r, detail - 1, b, bc, ab, tb, tbc, tab);\n        total += n; data += n * 24;\n        n = _make_sphere(data, r, detail - 1, c, ac, bc, tc, tac, tbc);\n        total += n; data += n * 24;\n        n = _make_sphere(data, r, detail - 1, ab, bc, ac, tab, tbc, tac);\n        total += n; data += n * 24;\n        return total;\n    }\n}\n\nvoid make_sphere(float *data, float r, int detail) {\n    // detail, triangles, floats\n    // 0, 8, 192\n    // 1, 32, 768\n    // 2, 128, 3072\n    // 3, 512, 12288\n    // 4, 2048, 49152\n    // 5, 8192, 196608\n    // 6, 32768, 786432\n    // 7, 131072, 3145728\n    static int indices[8][3] = {\n        {4, 3, 0}, {1, 4, 0},\n        {3, 4, 5}, {4, 1, 5},\n        {0, 3, 2}, {0, 2, 1},\n        {5, 2, 3}, {5, 1, 2}\n    };\n    static float positions[6][3] = {\n        { 0, 0,-1}, { 1, 0, 0},\n        { 0,-1, 0}, {-1, 0, 0},\n        { 0, 1, 0}, { 0, 0, 1}\n    };\n    static float uvs[6][3] = {\n        {0, 0.5}, {0, 0.5},\n        {0, 0}, {0, 0.5},\n        {0, 1}, {0, 0.5}\n    };\n    int total = 0;\n    for (int i = 0; i < 8; i++) {\n        int n = _make_sphere(\n            data, r, detail,\n            positions[indices[i][0]],\n            positions[indices[i][1]],\n            positions[indices[i][2]],\n            uvs[indices[i][0]],\n            uvs[indices[i][1]],\n            uvs[indices[i][2]]);\n        total += n; data += n * 24;\n    }\n}\n"
  },
  {
    "path": "src/cube.h",
    "content": "#ifndef _cube_h_\n#define _cube_h_\n\nvoid make_cube_faces(\n    float *data, float ao[6][4], float light[6][4],\n    int left, int right, int top, int bottom, int front, int back,\n    int wleft, int wright, int wtop, int wbottom, int wfront, int wback,\n    float x, float y, float z, float n);\n\nvoid make_cube(\n    float *data, float ao[6][4], float light[6][4],\n    int left, int right, int top, int bottom, int front, int back,\n    float x, float y, float z, float n, int w);\n\nvoid make_plant(\n    float *data, float ao, float light,\n    float px, float py, float pz, float n, int w, float rotation);\n\nvoid make_player(\n    float *data,\n    float x, float y, float z, float rx, float ry);\n\nvoid make_cube_wireframe(\n    float *data, float x, float y, float z, float n);\n\nvoid make_character(\n    float *data,\n    float x, float y, float n, float m, char c);\n\nvoid make_character_3d(\n    float *data, float x, float y, float z, float n, int face, char c);\n\nvoid make_sphere(float *data, float r, int detail);\n\n#endif\n"
  },
  {
    "path": "src/db.c",
    "content": "#include <string.h>\n#include \"db.h\"\n#include \"ring.h\"\n#include \"sqlite3.h\"\n#include \"tinycthread.h\"\n\nstatic int db_enabled = 0;\n\nstatic sqlite3 *db;\nstatic sqlite3_stmt *insert_block_stmt;\nstatic sqlite3_stmt *insert_light_stmt;\nstatic sqlite3_stmt *insert_sign_stmt;\nstatic sqlite3_stmt *delete_sign_stmt;\nstatic sqlite3_stmt *delete_signs_stmt;\nstatic sqlite3_stmt *load_blocks_stmt;\nstatic sqlite3_stmt *load_lights_stmt;\nstatic sqlite3_stmt *load_signs_stmt;\nstatic sqlite3_stmt *get_key_stmt;\nstatic sqlite3_stmt *set_key_stmt;\n\nstatic Ring ring;\nstatic thrd_t thrd;\nstatic mtx_t mtx;\nstatic cnd_t cnd;\nstatic mtx_t load_mtx;\n\nvoid db_enable() {\n    db_enabled = 1;\n}\n\nvoid db_disable() {\n    db_enabled = 0;\n}\n\nint get_db_enabled() {\n    return db_enabled;\n}\n\nint db_init(char *path) {\n    if (!db_enabled) {\n        return 0;\n    }\n    static const char *create_query =\n        \"attach database 'auth.db' as auth;\"\n        \"create table if not exists auth.identity_token (\"\n        \"   username text not null,\"\n        \"   token text not null,\"\n        \"   selected int not null\"\n        \");\"\n        \"create unique index if not exists auth.identity_token_username_idx\"\n        \"   on identity_token (username);\"\n        \"create table if not exists state (\"\n        \"   x float not null,\"\n        \"   y float not null,\"\n        \"   z float not null,\"\n        \"   rx float not null,\"\n        \"   ry float not null\"\n        \");\"\n        \"create table if not exists block (\"\n        \"    p int not null,\"\n        \"    q int not null,\"\n        \"    x int not null,\"\n        \"    y int not null,\"\n        \"    z int not null,\"\n        \"    w int not null\"\n        \");\"\n        \"create table if not exists light (\"\n        \"    p int not null,\"\n        \"    q int not null,\"\n        \"    x int not null,\"\n        \"    y int not null,\"\n        \"    z int not null,\"\n        \"    w int not null\"\n        \");\"\n        \"create table if not exists key (\"\n        \"    p int not null,\"\n        \"    q int not null,\"\n        \"    key int not null\"\n        \");\"\n        \"create table if not exists sign (\"\n        \"    p int not null,\"\n        \"    q int not null,\"\n        \"    x int not null,\"\n        \"    y int not null,\"\n        \"    z int not null,\"\n        \"    face int not null,\"\n        \"    text text not null\"\n        \");\"\n        \"create unique index if not exists block_pqxyz_idx on block (p, q, x, y, z);\"\n        \"create unique index if not exists light_pqxyz_idx on light (p, q, x, y, z);\"\n        \"create unique index if not exists key_pq_idx on key (p, q);\"\n        \"create unique index if not exists sign_xyzface_idx on sign (x, y, z, face);\"\n        \"create index if not exists sign_pq_idx on sign (p, q);\";\n    static const char *insert_block_query =\n        \"insert or replace into block (p, q, x, y, z, w) \"\n        \"values (?, ?, ?, ?, ?, ?);\";\n    static const char *insert_light_query =\n        \"insert or replace into light (p, q, x, y, z, w) \"\n        \"values (?, ?, ?, ?, ?, ?);\";\n    static const char *insert_sign_query =\n        \"insert or replace into sign (p, q, x, y, z, face, text) \"\n        \"values (?, ?, ?, ?, ?, ?, ?);\";\n    static const char *delete_sign_query =\n        \"delete from sign where x = ? and y = ? and z = ? and face = ?;\";\n    static const char *delete_signs_query =\n        \"delete from sign where x = ? and y = ? and z = ?;\";\n    static const char *load_blocks_query =\n        \"select x, y, z, w from block where p = ? and q = ?;\";\n    static const char *load_lights_query =\n        \"select x, y, z, w from light where p = ? and q = ?;\";\n    static const char *load_signs_query =\n        \"select x, y, z, face, text from sign where p = ? and q = ?;\";\n    static const char *get_key_query =\n        \"select key from key where p = ? and q = ?;\";\n    static const char *set_key_query =\n        \"insert or replace into key (p, q, key) \"\n        \"values (?, ?, ?);\";\n    int rc;\n    rc = sqlite3_open(path, &db);\n    if (rc) return rc;\n    rc = sqlite3_exec(db, create_query, NULL, NULL, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(\n        db, insert_block_query, -1, &insert_block_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(\n        db, insert_light_query, -1, &insert_light_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(\n        db, insert_sign_query, -1, &insert_sign_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(\n        db, delete_sign_query, -1, &delete_sign_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(\n        db, delete_signs_query, -1, &delete_signs_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(db, load_blocks_query, -1, &load_blocks_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(db, load_lights_query, -1, &load_lights_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(db, load_signs_query, -1, &load_signs_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(db, get_key_query, -1, &get_key_stmt, NULL);\n    if (rc) return rc;\n    rc = sqlite3_prepare_v2(db, set_key_query, -1, &set_key_stmt, NULL);\n    if (rc) return rc;\n    sqlite3_exec(db, \"begin;\", NULL, NULL, NULL);\n    db_worker_start();\n    return 0;\n}\n\nvoid db_close() {\n    if (!db_enabled) {\n        return;\n    }\n    db_worker_stop();\n    sqlite3_exec(db, \"commit;\", NULL, NULL, NULL);\n    sqlite3_finalize(insert_block_stmt);\n    sqlite3_finalize(insert_light_stmt);\n    sqlite3_finalize(insert_sign_stmt);\n    sqlite3_finalize(delete_sign_stmt);\n    sqlite3_finalize(delete_signs_stmt);\n    sqlite3_finalize(load_blocks_stmt);\n    sqlite3_finalize(load_lights_stmt);\n    sqlite3_finalize(load_signs_stmt);\n    sqlite3_finalize(get_key_stmt);\n    sqlite3_finalize(set_key_stmt);\n    sqlite3_close(db);\n}\n\nvoid db_commit() {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&mtx);\n    ring_put_commit(&ring);\n    cnd_signal(&cnd);\n    mtx_unlock(&mtx);\n}\n\nvoid _db_commit() {\n    sqlite3_exec(db, \"commit; begin;\", NULL, NULL, NULL);\n}\n\nvoid db_auth_set(char *username, char *identity_token) {\n    if (!db_enabled) {\n        return;\n    }\n    static const char *query =\n        \"insert or replace into auth.identity_token \"\n        \"(username, token, selected) values (?, ?, ?);\";\n    sqlite3_stmt *stmt;\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    sqlite3_bind_text(stmt, 1, username, -1, NULL);\n    sqlite3_bind_text(stmt, 2, identity_token, -1, NULL);\n    sqlite3_bind_int(stmt, 3, 1);\n    sqlite3_step(stmt);\n    sqlite3_finalize(stmt);\n    db_auth_select(username);\n}\n\nint db_auth_select(char *username) {\n    if (!db_enabled) {\n        return 0;\n    }\n    db_auth_select_none();\n    static const char *query =\n        \"update auth.identity_token set selected = 1 where username = ?;\";\n    sqlite3_stmt *stmt;\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    sqlite3_bind_text(stmt, 1, username, -1, NULL);\n    sqlite3_step(stmt);\n    sqlite3_finalize(stmt);\n    return sqlite3_changes(db);\n}\n\nvoid db_auth_select_none() {\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_exec(db, \"update auth.identity_token set selected = 0;\",\n        NULL, NULL, NULL);\n}\n\nint db_auth_get(\n    char *username,\n    char *identity_token, int identity_token_length)\n{\n    if (!db_enabled) {\n        return 0;\n    }\n    static const char *query =\n        \"select token from auth.identity_token \"\n        \"where username = ?;\";\n    int result = 0;\n    sqlite3_stmt *stmt;\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    sqlite3_bind_text(stmt, 1, username, -1, NULL);\n    if (sqlite3_step(stmt) == SQLITE_ROW) {\n        const char *a = (const char *)sqlite3_column_text(stmt, 0);\n        strncpy(identity_token, a, identity_token_length - 1);\n        identity_token[identity_token_length - 1] = '\\0';\n        result = 1;\n    }\n    sqlite3_finalize(stmt);\n    return result;\n}\n\nint db_auth_get_selected(\n    char *username, int username_length,\n    char *identity_token, int identity_token_length)\n{\n    if (!db_enabled) {\n        return 0;\n    }\n    static const char *query =\n        \"select username, token from auth.identity_token \"\n        \"where selected = 1;\";\n    int result = 0;\n    sqlite3_stmt *stmt;\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    if (sqlite3_step(stmt) == SQLITE_ROW) {\n        const char *a = (const char *)sqlite3_column_text(stmt, 0);\n        const char *b = (const char *)sqlite3_column_text(stmt, 1);\n        strncpy(username, a, username_length - 1);\n        username[username_length - 1] = '\\0';\n        strncpy(identity_token, b, identity_token_length - 1);\n        identity_token[identity_token_length - 1] = '\\0';\n        result = 1;\n    }\n    sqlite3_finalize(stmt);\n    return result;\n}\n\nvoid db_save_state(float x, float y, float z, float rx, float ry) {\n    if (!db_enabled) {\n        return;\n    }\n    static const char *query =\n        \"insert into state (x, y, z, rx, ry) values (?, ?, ?, ?, ?);\";\n    sqlite3_stmt *stmt;\n    sqlite3_exec(db, \"delete from state;\", NULL, NULL, NULL);\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    sqlite3_bind_double(stmt, 1, x);\n    sqlite3_bind_double(stmt, 2, y);\n    sqlite3_bind_double(stmt, 3, z);\n    sqlite3_bind_double(stmt, 4, rx);\n    sqlite3_bind_double(stmt, 5, ry);\n    sqlite3_step(stmt);\n    sqlite3_finalize(stmt);\n}\n\nint db_load_state(float *x, float *y, float *z, float *rx, float *ry) {\n    if (!db_enabled) {\n        return 0;\n    }\n    static const char *query =\n        \"select x, y, z, rx, ry from state;\";\n    int result = 0;\n    sqlite3_stmt *stmt;\n    sqlite3_prepare_v2(db, query, -1, &stmt, NULL);\n    if (sqlite3_step(stmt) == SQLITE_ROW) {\n        *x = sqlite3_column_double(stmt, 0);\n        *y = sqlite3_column_double(stmt, 1);\n        *z = sqlite3_column_double(stmt, 2);\n        *rx = sqlite3_column_double(stmt, 3);\n        *ry = sqlite3_column_double(stmt, 4);\n        result = 1;\n    }\n    sqlite3_finalize(stmt);\n    return result;\n}\n\nvoid db_insert_block(int p, int q, int x, int y, int z, int w) {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&mtx);\n    ring_put_block(&ring, p, q, x, y, z, w);\n    cnd_signal(&cnd);\n    mtx_unlock(&mtx);\n}\n\nvoid _db_insert_block(int p, int q, int x, int y, int z, int w) {\n    sqlite3_reset(insert_block_stmt);\n    sqlite3_bind_int(insert_block_stmt, 1, p);\n    sqlite3_bind_int(insert_block_stmt, 2, q);\n    sqlite3_bind_int(insert_block_stmt, 3, x);\n    sqlite3_bind_int(insert_block_stmt, 4, y);\n    sqlite3_bind_int(insert_block_stmt, 5, z);\n    sqlite3_bind_int(insert_block_stmt, 6, w);\n    sqlite3_step(insert_block_stmt);\n}\n\nvoid db_insert_light(int p, int q, int x, int y, int z, int w) {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&mtx);\n    ring_put_light(&ring, p, q, x, y, z, w);\n    cnd_signal(&cnd);\n    mtx_unlock(&mtx);\n}\n\nvoid _db_insert_light(int p, int q, int x, int y, int z, int w) {\n    sqlite3_reset(insert_light_stmt);\n    sqlite3_bind_int(insert_light_stmt, 1, p);\n    sqlite3_bind_int(insert_light_stmt, 2, q);\n    sqlite3_bind_int(insert_light_stmt, 3, x);\n    sqlite3_bind_int(insert_light_stmt, 4, y);\n    sqlite3_bind_int(insert_light_stmt, 5, z);\n    sqlite3_bind_int(insert_light_stmt, 6, w);\n    sqlite3_step(insert_light_stmt);\n}\n\nvoid db_insert_sign(\n    int p, int q, int x, int y, int z, int face, const char *text)\n{\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_reset(insert_sign_stmt);\n    sqlite3_bind_int(insert_sign_stmt, 1, p);\n    sqlite3_bind_int(insert_sign_stmt, 2, q);\n    sqlite3_bind_int(insert_sign_stmt, 3, x);\n    sqlite3_bind_int(insert_sign_stmt, 4, y);\n    sqlite3_bind_int(insert_sign_stmt, 5, z);\n    sqlite3_bind_int(insert_sign_stmt, 6, face);\n    sqlite3_bind_text(insert_sign_stmt, 7, text, -1, NULL);\n    sqlite3_step(insert_sign_stmt);\n}\n\nvoid db_delete_sign(int x, int y, int z, int face) {\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_reset(delete_sign_stmt);\n    sqlite3_bind_int(delete_sign_stmt, 1, x);\n    sqlite3_bind_int(delete_sign_stmt, 2, y);\n    sqlite3_bind_int(delete_sign_stmt, 3, z);\n    sqlite3_bind_int(delete_sign_stmt, 4, face);\n    sqlite3_step(delete_sign_stmt);\n}\n\nvoid db_delete_signs(int x, int y, int z) {\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_reset(delete_signs_stmt);\n    sqlite3_bind_int(delete_signs_stmt, 1, x);\n    sqlite3_bind_int(delete_signs_stmt, 2, y);\n    sqlite3_bind_int(delete_signs_stmt, 3, z);\n    sqlite3_step(delete_signs_stmt);\n}\n\nvoid db_delete_all_signs() {\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_exec(db, \"delete from sign;\", NULL, NULL, NULL);\n}\n\nvoid db_load_blocks(Map *map, int p, int q) {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&load_mtx);\n    sqlite3_reset(load_blocks_stmt);\n    sqlite3_bind_int(load_blocks_stmt, 1, p);\n    sqlite3_bind_int(load_blocks_stmt, 2, q);\n    while (sqlite3_step(load_blocks_stmt) == SQLITE_ROW) {\n        int x = sqlite3_column_int(load_blocks_stmt, 0);\n        int y = sqlite3_column_int(load_blocks_stmt, 1);\n        int z = sqlite3_column_int(load_blocks_stmt, 2);\n        int w = sqlite3_column_int(load_blocks_stmt, 3);\n        map_set(map, x, y, z, w);\n    }\n    mtx_unlock(&load_mtx);\n}\n\nvoid db_load_lights(Map *map, int p, int q) {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&load_mtx);\n    sqlite3_reset(load_lights_stmt);\n    sqlite3_bind_int(load_lights_stmt, 1, p);\n    sqlite3_bind_int(load_lights_stmt, 2, q);\n    while (sqlite3_step(load_lights_stmt) == SQLITE_ROW) {\n        int x = sqlite3_column_int(load_lights_stmt, 0);\n        int y = sqlite3_column_int(load_lights_stmt, 1);\n        int z = sqlite3_column_int(load_lights_stmt, 2);\n        int w = sqlite3_column_int(load_lights_stmt, 3);\n        map_set(map, x, y, z, w);\n    }\n    mtx_unlock(&load_mtx);\n}\n\nvoid db_load_signs(SignList *list, int p, int q) {\n    if (!db_enabled) {\n        return;\n    }\n    sqlite3_reset(load_signs_stmt);\n    sqlite3_bind_int(load_signs_stmt, 1, p);\n    sqlite3_bind_int(load_signs_stmt, 2, q);\n    while (sqlite3_step(load_signs_stmt) == SQLITE_ROW) {\n        int x = sqlite3_column_int(load_signs_stmt, 0);\n        int y = sqlite3_column_int(load_signs_stmt, 1);\n        int z = sqlite3_column_int(load_signs_stmt, 2);\n        int face = sqlite3_column_int(load_signs_stmt, 3);\n        const char *text = (const char *)sqlite3_column_text(\n            load_signs_stmt, 4);\n        sign_list_add(list, x, y, z, face, text);\n    }\n}\n\nint db_get_key(int p, int q) {\n    if (!db_enabled) {\n        return 0;\n    }\n    sqlite3_reset(get_key_stmt);\n    sqlite3_bind_int(get_key_stmt, 1, p);\n    sqlite3_bind_int(get_key_stmt, 2, q);\n    if (sqlite3_step(get_key_stmt) == SQLITE_ROW) {\n        return sqlite3_column_int(get_key_stmt, 0);\n    }\n    return 0;\n}\n\nvoid db_set_key(int p, int q, int key) {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&mtx);\n    ring_put_key(&ring, p, q, key);\n    cnd_signal(&cnd);\n    mtx_unlock(&mtx);\n}\n\nvoid _db_set_key(int p, int q, int key) {\n    sqlite3_reset(set_key_stmt);\n    sqlite3_bind_int(set_key_stmt, 1, p);\n    sqlite3_bind_int(set_key_stmt, 2, q);\n    sqlite3_bind_int(set_key_stmt, 3, key);\n    sqlite3_step(set_key_stmt);\n}\n\nvoid db_worker_start(char *path) {\n    if (!db_enabled) {\n        return;\n    }\n    ring_alloc(&ring, 1024);\n    mtx_init(&mtx, mtx_plain);\n    mtx_init(&load_mtx, mtx_plain);\n    cnd_init(&cnd);\n    thrd_create(&thrd, db_worker_run, path);\n}\n\nvoid db_worker_stop() {\n    if (!db_enabled) {\n        return;\n    }\n    mtx_lock(&mtx);\n    ring_put_exit(&ring);\n    cnd_signal(&cnd);\n    mtx_unlock(&mtx);\n    thrd_join(thrd, NULL);\n    cnd_destroy(&cnd);\n    mtx_destroy(&load_mtx);\n    mtx_destroy(&mtx);\n    ring_free(&ring);\n}\n\nint db_worker_run(void *arg) {\n    int running = 1;\n    while (running) {\n        RingEntry e;\n        mtx_lock(&mtx);\n        while (!ring_get(&ring, &e)) {\n            cnd_wait(&cnd, &mtx);\n        }\n        mtx_unlock(&mtx);\n        switch (e.type) {\n            case BLOCK:\n                _db_insert_block(e.p, e.q, e.x, e.y, e.z, e.w);\n                break;\n            case LIGHT:\n                _db_insert_light(e.p, e.q, e.x, e.y, e.z, e.w);\n                break;\n            case KEY:\n                _db_set_key(e.p, e.q, e.key);\n                break;\n            case COMMIT:\n                _db_commit();\n                break;\n            case EXIT:\n                running = 0;\n                break;\n        }\n    }\n    return 0;\n}\n"
  },
  {
    "path": "src/db.h",
    "content": "#ifndef _db_h_\n#define _db_h_\n\n#include \"map.h\"\n#include \"sign.h\"\n\nvoid db_enable();\nvoid db_disable();\nint get_db_enabled();\nint db_init(char *path);\nvoid db_close();\nvoid db_commit();\nvoid db_auth_set(char *username, char *identity_token);\nint db_auth_select(char *username);\nvoid db_auth_select_none();\nint db_auth_get(\n    char *username,\n    char *identity_token, int identity_token_length);\nint db_auth_get_selected(\n    char *username, int username_length,\n    char *identity_token, int identity_token_length);\nvoid db_save_state(float x, float y, float z, float rx, float ry);\nint db_load_state(float *x, float *y, float *z, float *rx, float *ry);\nvoid db_insert_block(int p, int q, int x, int y, int z, int w);\nvoid db_insert_light(int p, int q, int x, int y, int z, int w);\nvoid db_insert_sign(\n    int p, int q, int x, int y, int z, int face, const char *text);\nvoid db_delete_sign(int x, int y, int z, int face);\nvoid db_delete_signs(int x, int y, int z);\nvoid db_delete_all_signs();\nvoid db_load_blocks(Map *map, int p, int q);\nvoid db_load_lights(Map *map, int p, int q);\nvoid db_load_signs(SignList *list, int p, int q);\nint db_get_key(int p, int q);\nvoid db_set_key(int p, int q, int key);\nvoid db_worker_start();\nvoid db_worker_stop();\nint db_worker_run(void *arg);\n\n#endif\n"
  },
  {
    "path": "src/item.c",
    "content": "#include \"item.h\"\n#include \"util.h\"\n\nconst int items[] = {\n    // items the user can build\n    GRASS,\n    SAND,\n    STONE,\n    BRICK,\n    WOOD,\n    CEMENT,\n    DIRT,\n    PLANK,\n    SNOW,\n    GLASS,\n    COBBLE,\n    LIGHT_STONE,\n    DARK_STONE,\n    CHEST,\n    LEAVES,\n    TALL_GRASS,\n    YELLOW_FLOWER,\n    RED_FLOWER,\n    PURPLE_FLOWER,\n    SUN_FLOWER,\n    WHITE_FLOWER,\n    BLUE_FLOWER,\n    COLOR_00,\n    COLOR_01,\n    COLOR_02,\n    COLOR_03,\n    COLOR_04,\n    COLOR_05,\n    COLOR_06,\n    COLOR_07,\n    COLOR_08,\n    COLOR_09,\n    COLOR_10,\n    COLOR_11,\n    COLOR_12,\n    COLOR_13,\n    COLOR_14,\n    COLOR_15,\n    COLOR_16,\n    COLOR_17,\n    COLOR_18,\n    COLOR_19,\n    COLOR_20,\n    COLOR_21,\n    COLOR_22,\n    COLOR_23,\n    COLOR_24,\n    COLOR_25,\n    COLOR_26,\n    COLOR_27,\n    COLOR_28,\n    COLOR_29,\n    COLOR_30,\n    COLOR_31\n};\n\nconst int item_count = sizeof(items) / sizeof(int);\n\nconst int blocks[256][6] = {\n    // w => (left, right, top, bottom, front, back) tiles\n    {0, 0, 0, 0, 0, 0}, // 0 - empty\n    {16, 16, 32, 0, 16, 16}, // 1 - grass\n    {1, 1, 1, 1, 1, 1}, // 2 - sand\n    {2, 2, 2, 2, 2, 2}, // 3 - stone\n    {3, 3, 3, 3, 3, 3}, // 4 - brick\n    {20, 20, 36, 4, 20, 20}, // 5 - wood\n    {5, 5, 5, 5, 5, 5}, // 6 - cement\n    {6, 6, 6, 6, 6, 6}, // 7 - dirt\n    {7, 7, 7, 7, 7, 7}, // 8 - plank\n    {24, 24, 40, 8, 24, 24}, // 9 - snow\n    {9, 9, 9, 9, 9, 9}, // 10 - glass\n    {10, 10, 10, 10, 10, 10}, // 11 - cobble\n    {11, 11, 11, 11, 11, 11}, // 12 - light stone\n    {12, 12, 12, 12, 12, 12}, // 13 - dark stone\n    {13, 13, 13, 13, 13, 13}, // 14 - chest\n    {14, 14, 14, 14, 14, 14}, // 15 - leaves\n    {15, 15, 15, 15, 15, 15}, // 16 - cloud\n    {0, 0, 0, 0, 0, 0}, // 17\n    {0, 0, 0, 0, 0, 0}, // 18\n    {0, 0, 0, 0, 0, 0}, // 19\n    {0, 0, 0, 0, 0, 0}, // 20\n    {0, 0, 0, 0, 0, 0}, // 21\n    {0, 0, 0, 0, 0, 0}, // 22\n    {0, 0, 0, 0, 0, 0}, // 23\n    {0, 0, 0, 0, 0, 0}, // 24\n    {0, 0, 0, 0, 0, 0}, // 25\n    {0, 0, 0, 0, 0, 0}, // 26\n    {0, 0, 0, 0, 0, 0}, // 27\n    {0, 0, 0, 0, 0, 0}, // 28\n    {0, 0, 0, 0, 0, 0}, // 29\n    {0, 0, 0, 0, 0, 0}, // 30\n    {0, 0, 0, 0, 0, 0}, // 31\n    {176, 176, 176, 176, 176, 176}, // 32\n    {177, 177, 177, 177, 177, 177}, // 33\n    {178, 178, 178, 178, 178, 178}, // 34\n    {179, 179, 179, 179, 179, 179}, // 35\n    {180, 180, 180, 180, 180, 180}, // 36\n    {181, 181, 181, 181, 181, 181}, // 37\n    {182, 182, 182, 182, 182, 182}, // 38\n    {183, 183, 183, 183, 183, 183}, // 39\n    {184, 184, 184, 184, 184, 184}, // 40\n    {185, 185, 185, 185, 185, 185}, // 41\n    {186, 186, 186, 186, 186, 186}, // 42\n    {187, 187, 187, 187, 187, 187}, // 43\n    {188, 188, 188, 188, 188, 188}, // 44\n    {189, 189, 189, 189, 189, 189}, // 45\n    {190, 190, 190, 190, 190, 190}, // 46\n    {191, 191, 191, 191, 191, 191}, // 47\n    {192, 192, 192, 192, 192, 192}, // 48\n    {193, 193, 193, 193, 193, 193}, // 49\n    {194, 194, 194, 194, 194, 194}, // 50\n    {195, 195, 195, 195, 195, 195}, // 51\n    {196, 196, 196, 196, 196, 196}, // 52\n    {197, 197, 197, 197, 197, 197}, // 53\n    {198, 198, 198, 198, 198, 198}, // 54\n    {199, 199, 199, 199, 199, 199}, // 55\n    {200, 200, 200, 200, 200, 200}, // 56\n    {201, 201, 201, 201, 201, 201}, // 57\n    {202, 202, 202, 202, 202, 202}, // 58\n    {203, 203, 203, 203, 203, 203}, // 59\n    {204, 204, 204, 204, 204, 204}, // 60\n    {205, 205, 205, 205, 205, 205}, // 61\n    {206, 206, 206, 206, 206, 206}, // 62\n    {207, 207, 207, 207, 207, 207}, // 63\n};\n\nconst int plants[256] = {\n    // w => tile\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 16\n    48, // 17 - tall grass\n    49, // 18 - yellow flower\n    50, // 19 - red flower\n    51, // 20 - purple flower\n    52, // 21 - sun flower\n    53, // 22 - white flower\n    54, // 23 - blue flower\n};\n\nint is_plant(int w) {\n    switch (w) {\n        case TALL_GRASS:\n        case YELLOW_FLOWER:\n        case RED_FLOWER:\n        case PURPLE_FLOWER:\n        case SUN_FLOWER:\n        case WHITE_FLOWER:\n        case BLUE_FLOWER:\n            return 1;\n        default:\n            return 0;\n    }\n}\n\nint is_obstacle(int w) {\n    w = ABS(w);\n    if (is_plant(w)) {\n        return 0;\n    }\n    switch (w) {\n        case EMPTY:\n        case CLOUD:\n            return 0;\n        default:\n            return 1;\n    }\n}\n\nint is_transparent(int w) {\n    if (w == EMPTY) {\n        return 1;\n    }\n    w = ABS(w);\n    if (is_plant(w)) {\n        return 1;\n    }\n    switch (w) {\n        case EMPTY:\n        case GLASS:\n        case LEAVES:\n            return 1;\n        default:\n            return 0;\n    }\n}\n\nint is_destructable(int w) {\n    switch (w) {\n        case EMPTY:\n        case CLOUD:\n            return 0;\n        default:\n            return 1;\n    }\n}\n"
  },
  {
    "path": "src/item.h",
    "content": "#ifndef _item_h_\n#define _item_h_\n\n#define EMPTY 0\n#define GRASS 1\n#define SAND 2\n#define STONE 3\n#define BRICK 4\n#define WOOD 5\n#define CEMENT 6\n#define DIRT 7\n#define PLANK 8\n#define SNOW 9\n#define GLASS 10\n#define COBBLE 11\n#define LIGHT_STONE 12\n#define DARK_STONE 13\n#define CHEST 14\n#define LEAVES 15\n#define CLOUD 16\n#define TALL_GRASS 17\n#define YELLOW_FLOWER 18\n#define RED_FLOWER 19\n#define PURPLE_FLOWER 20\n#define SUN_FLOWER 21\n#define WHITE_FLOWER 22\n#define BLUE_FLOWER 23\n#define COLOR_00 32\n#define COLOR_01 33\n#define COLOR_02 34\n#define COLOR_03 35\n#define COLOR_04 36\n#define COLOR_05 37\n#define COLOR_06 38\n#define COLOR_07 39\n#define COLOR_08 40\n#define COLOR_09 41\n#define COLOR_10 42\n#define COLOR_11 43\n#define COLOR_12 44\n#define COLOR_13 45\n#define COLOR_14 46\n#define COLOR_15 47\n#define COLOR_16 48\n#define COLOR_17 49\n#define COLOR_18 50\n#define COLOR_19 51\n#define COLOR_20 52\n#define COLOR_21 53\n#define COLOR_22 54\n#define COLOR_23 55\n#define COLOR_24 56\n#define COLOR_25 57\n#define COLOR_26 58\n#define COLOR_27 59\n#define COLOR_28 60\n#define COLOR_29 61\n#define COLOR_30 62\n#define COLOR_31 63\n\nextern const int items[];\nextern const int item_count;\nextern const int blocks[256][6];\nextern const int plants[256];\n\nint is_plant(int w);\nint is_obstacle(int w);\nint is_transparent(int w);\nint is_destructable(int w);\n\n#endif\n"
  },
  {
    "path": "src/main.c",
    "content": "#include <GL/glew.h>\n#include <GLFW/glfw3.h>\n#include <curl/curl.h>\n#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n#include \"auth.h\"\n#include \"client.h\"\n#include \"config.h\"\n#include \"cube.h\"\n#include \"db.h\"\n#include \"item.h\"\n#include \"map.h\"\n#include \"matrix.h\"\n#include \"noise.h\"\n#include \"sign.h\"\n#include \"tinycthread.h\"\n#include \"util.h\"\n#include \"world.h\"\n\n#define MAX_CHUNKS 8192\n#define MAX_PLAYERS 128\n#define WORKERS 4\n#define MAX_TEXT_LENGTH 256\n#define MAX_NAME_LENGTH 32\n#define MAX_PATH_LENGTH 256\n#define MAX_ADDR_LENGTH 256\n\n#define ALIGN_LEFT 0\n#define ALIGN_CENTER 1\n#define ALIGN_RIGHT 2\n\n#define MODE_OFFLINE 0\n#define MODE_ONLINE 1\n\n#define WORKER_IDLE 0\n#define WORKER_BUSY 1\n#define WORKER_DONE 2\n\ntypedef struct {\n    Map map;\n    Map lights;\n    SignList signs;\n    int p;\n    int q;\n    int faces;\n    int sign_faces;\n    int dirty;\n    int miny;\n    int maxy;\n    GLuint buffer;\n    GLuint sign_buffer;\n} Chunk;\n\ntypedef struct {\n    int p;\n    int q;\n    int load;\n    Map *block_maps[3][3];\n    Map *light_maps[3][3];\n    int miny;\n    int maxy;\n    int faces;\n    GLfloat *data;\n} WorkerItem;\n\ntypedef struct {\n    int index;\n    int state;\n    thrd_t thrd;\n    mtx_t mtx;\n    cnd_t cnd;\n    WorkerItem item;\n} Worker;\n\ntypedef struct {\n    int x;\n    int y;\n    int z;\n    int w;\n} Block;\n\ntypedef struct {\n    float x;\n    float y;\n    float z;\n    float rx;\n    float ry;\n    float t;\n} State;\n\ntypedef struct {\n    int id;\n    char name[MAX_NAME_LENGTH];\n    State state;\n    State state1;\n    State state2;\n    GLuint buffer;\n} Player;\n\ntypedef struct {\n    GLuint program;\n    GLuint position;\n    GLuint normal;\n    GLuint uv;\n    GLuint matrix;\n    GLuint sampler;\n    GLuint camera;\n    GLuint timer;\n    GLuint extra1;\n    GLuint extra2;\n    GLuint extra3;\n    GLuint extra4;\n} Attrib;\n\ntypedef struct {\n    GLFWwindow *window;\n    Worker workers[WORKERS];\n    Chunk chunks[MAX_CHUNKS];\n    int chunk_count;\n    int create_radius;\n    int render_radius;\n    int delete_radius;\n    int sign_radius;\n    Player players[MAX_PLAYERS];\n    int player_count;\n    int typing;\n    char typing_buffer[MAX_TEXT_LENGTH];\n    int message_index;\n    char messages[MAX_MESSAGES][MAX_TEXT_LENGTH];\n    int width;\n    int height;\n    int observe1;\n    int observe2;\n    int flying;\n    int item_index;\n    int scale;\n    int ortho;\n    float fov;\n    int suppress_char;\n    int mode;\n    int mode_changed;\n    char db_path[MAX_PATH_LENGTH];\n    char server_addr[MAX_ADDR_LENGTH];\n    int server_port;\n    int day_length;\n    int time_changed;\n    Block block0;\n    Block block1;\n    Block copy0;\n    Block copy1;\n} Model;\n\nstatic Model model;\nstatic Model *g = &model;\n\nint chunked(float x) {\n    return floorf(roundf(x) / CHUNK_SIZE);\n}\n\nfloat time_of_day() {\n    if (g->day_length <= 0) {\n        return 0.5;\n    }\n    float t;\n    t = glfwGetTime();\n    t = t / g->day_length;\n    t = t - (int)t;\n    return t;\n}\n\nfloat get_daylight() {\n    float timer = time_of_day();\n    if (timer < 0.5) {\n        float t = (timer - 0.25) * 100;\n        return 1 / (1 + powf(2, -t));\n    }\n    else {\n        float t = (timer - 0.85) * 100;\n        return 1 - 1 / (1 + powf(2, -t));\n    }\n}\n\nint get_scale_factor() {\n    int window_width, window_height;\n    int buffer_width, buffer_height;\n    glfwGetWindowSize(g->window, &window_width, &window_height);\n    glfwGetFramebufferSize(g->window, &buffer_width, &buffer_height);\n    int result = buffer_width / window_width;\n    result = MAX(1, result);\n    result = MIN(2, result);\n    return result;\n}\n\nvoid get_sight_vector(float rx, float ry, float *vx, float *vy, float *vz) {\n    float m = cosf(ry);\n    *vx = cosf(rx - RADIANS(90)) * m;\n    *vy = sinf(ry);\n    *vz = sinf(rx - RADIANS(90)) * m;\n}\n\nvoid get_motion_vector(int flying, int sz, int sx, float rx, float ry,\n    float *vx, float *vy, float *vz) {\n    *vx = 0; *vy = 0; *vz = 0;\n    if (!sz && !sx) {\n        return;\n    }\n    float strafe = atan2f(sz, sx);\n    if (flying) {\n        float m = cosf(ry);\n        float y = sinf(ry);\n        if (sx) {\n            if (!sz) {\n                y = 0;\n            }\n            m = 1;\n        }\n        if (sz > 0) {\n            y = -y;\n        }\n        *vx = cosf(rx + strafe) * m;\n        *vy = y;\n        *vz = sinf(rx + strafe) * m;\n    }\n    else {\n        *vx = cosf(rx + strafe);\n        *vy = 0;\n        *vz = sinf(rx + strafe);\n    }\n}\n\nGLuint gen_crosshair_buffer() {\n    int x = g->width / 2;\n    int y = g->height / 2;\n    int p = 10 * g->scale;\n    float data[] = {\n        x, y - p, x, y + p,\n        x - p, y, x + p, y\n    };\n    return gen_buffer(sizeof(data), data);\n}\n\nGLuint gen_wireframe_buffer(float x, float y, float z, float n) {\n    float data[72];\n    make_cube_wireframe(data, x, y, z, n);\n    return gen_buffer(sizeof(data), data);\n}\n\nGLuint gen_sky_buffer() {\n    float data[12288];\n    make_sphere(data, 1, 3);\n    return gen_buffer(sizeof(data), data);\n}\n\nGLuint gen_cube_buffer(float x, float y, float z, float n, int w) {\n    GLfloat *data = malloc_faces(10, 6);\n    float ao[6][4] = {0};\n    float light[6][4] = {\n        {0.5, 0.5, 0.5, 0.5},\n        {0.5, 0.5, 0.5, 0.5},\n        {0.5, 0.5, 0.5, 0.5},\n        {0.5, 0.5, 0.5, 0.5},\n        {0.5, 0.5, 0.5, 0.5},\n        {0.5, 0.5, 0.5, 0.5}\n    };\n    make_cube(data, ao, light, 1, 1, 1, 1, 1, 1, x, y, z, n, w);\n    return gen_faces(10, 6, data);\n}\n\nGLuint gen_plant_buffer(float x, float y, float z, float n, int w) {\n    GLfloat *data = malloc_faces(10, 4);\n    float ao = 0;\n    float light = 1;\n    make_plant(data, ao, light, x, y, z, n, w, 45);\n    return gen_faces(10, 4, data);\n}\n\nGLuint gen_player_buffer(float x, float y, float z, float rx, float ry) {\n    GLfloat *data = malloc_faces(10, 6);\n    make_player(data, x, y, z, rx, ry);\n    return gen_faces(10, 6, data);\n}\n\nGLuint gen_text_buffer(float x, float y, float n, char *text) {\n    int length = strlen(text);\n    GLfloat *data = malloc_faces(4, length);\n    for (int i = 0; i < length; i++) {\n        make_character(data + i * 24, x, y, n / 2, n, text[i]);\n        x += n;\n    }\n    return gen_faces(4, length, data);\n}\n\nvoid draw_triangles_3d_ao(Attrib *attrib, GLuint buffer, int count) {\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glEnableVertexAttribArray(attrib->position);\n    glEnableVertexAttribArray(attrib->normal);\n    glEnableVertexAttribArray(attrib->uv);\n    glVertexAttribPointer(attrib->position, 3, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 10, 0);\n    glVertexAttribPointer(attrib->normal, 3, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 10, (GLvoid *)(sizeof(GLfloat) * 3));\n    glVertexAttribPointer(attrib->uv, 4, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 10, (GLvoid *)(sizeof(GLfloat) * 6));\n    glDrawArrays(GL_TRIANGLES, 0, count);\n    glDisableVertexAttribArray(attrib->position);\n    glDisableVertexAttribArray(attrib->normal);\n    glDisableVertexAttribArray(attrib->uv);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nvoid draw_triangles_3d_text(Attrib *attrib, GLuint buffer, int count) {\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glEnableVertexAttribArray(attrib->position);\n    glEnableVertexAttribArray(attrib->uv);\n    glVertexAttribPointer(attrib->position, 3, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 5, 0);\n    glVertexAttribPointer(attrib->uv, 2, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 5, (GLvoid *)(sizeof(GLfloat) * 3));\n    glDrawArrays(GL_TRIANGLES, 0, count);\n    glDisableVertexAttribArray(attrib->position);\n    glDisableVertexAttribArray(attrib->uv);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nvoid draw_triangles_3d(Attrib *attrib, GLuint buffer, int count) {\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glEnableVertexAttribArray(attrib->position);\n    glEnableVertexAttribArray(attrib->normal);\n    glEnableVertexAttribArray(attrib->uv);\n    glVertexAttribPointer(attrib->position, 3, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 8, 0);\n    glVertexAttribPointer(attrib->normal, 3, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 8, (GLvoid *)(sizeof(GLfloat) * 3));\n    glVertexAttribPointer(attrib->uv, 2, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 8, (GLvoid *)(sizeof(GLfloat) * 6));\n    glDrawArrays(GL_TRIANGLES, 0, count);\n    glDisableVertexAttribArray(attrib->position);\n    glDisableVertexAttribArray(attrib->normal);\n    glDisableVertexAttribArray(attrib->uv);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nvoid draw_triangles_2d(Attrib *attrib, GLuint buffer, int count) {\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glEnableVertexAttribArray(attrib->position);\n    glEnableVertexAttribArray(attrib->uv);\n    glVertexAttribPointer(attrib->position, 2, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 4, 0);\n    glVertexAttribPointer(attrib->uv, 2, GL_FLOAT, GL_FALSE,\n        sizeof(GLfloat) * 4, (GLvoid *)(sizeof(GLfloat) * 2));\n    glDrawArrays(GL_TRIANGLES, 0, count);\n    glDisableVertexAttribArray(attrib->position);\n    glDisableVertexAttribArray(attrib->uv);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nvoid draw_lines(Attrib *attrib, GLuint buffer, int components, int count) {\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glEnableVertexAttribArray(attrib->position);\n    glVertexAttribPointer(\n        attrib->position, components, GL_FLOAT, GL_FALSE, 0, 0);\n    glDrawArrays(GL_LINES, 0, count);\n    glDisableVertexAttribArray(attrib->position);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n}\n\nvoid draw_chunk(Attrib *attrib, Chunk *chunk) {\n    draw_triangles_3d_ao(attrib, chunk->buffer, chunk->faces * 6);\n}\n\nvoid draw_item(Attrib *attrib, GLuint buffer, int count) {\n    draw_triangles_3d_ao(attrib, buffer, count);\n}\n\nvoid draw_text(Attrib *attrib, GLuint buffer, int length) {\n    glEnable(GL_BLEND);\n    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\n    draw_triangles_2d(attrib, buffer, length * 6);\n    glDisable(GL_BLEND);\n}\n\nvoid draw_signs(Attrib *attrib, Chunk *chunk) {\n    glEnable(GL_POLYGON_OFFSET_FILL);\n    glPolygonOffset(-8, -1024);\n    draw_triangles_3d_text(attrib, chunk->sign_buffer, chunk->sign_faces * 6);\n    glDisable(GL_POLYGON_OFFSET_FILL);\n}\n\nvoid draw_sign(Attrib *attrib, GLuint buffer, int length) {\n    glEnable(GL_POLYGON_OFFSET_FILL);\n    glPolygonOffset(-8, -1024);\n    draw_triangles_3d_text(attrib, buffer, length * 6);\n    glDisable(GL_POLYGON_OFFSET_FILL);\n}\n\nvoid draw_cube(Attrib *attrib, GLuint buffer) {\n    draw_item(attrib, buffer, 36);\n}\n\nvoid draw_plant(Attrib *attrib, GLuint buffer) {\n    draw_item(attrib, buffer, 24);\n}\n\nvoid draw_player(Attrib *attrib, Player *player) {\n    draw_cube(attrib, player->buffer);\n}\n\nPlayer *find_player(int id) {\n    for (int i = 0; i < g->player_count; i++) {\n        Player *player = g->players + i;\n        if (player->id == id) {\n            return player;\n        }\n    }\n    return 0;\n}\n\nvoid update_player(Player *player,\n    float x, float y, float z, float rx, float ry, int interpolate)\n{\n    if (interpolate) {\n        State *s1 = &player->state1;\n        State *s2 = &player->state2;\n        memcpy(s1, s2, sizeof(State));\n        s2->x = x; s2->y = y; s2->z = z; s2->rx = rx; s2->ry = ry;\n        s2->t = glfwGetTime();\n        if (s2->rx - s1->rx > PI) {\n            s1->rx += 2 * PI;\n        }\n        if (s1->rx - s2->rx > PI) {\n            s1->rx -= 2 * PI;\n        }\n    }\n    else {\n        State *s = &player->state;\n        s->x = x; s->y = y; s->z = z; s->rx = rx; s->ry = ry;\n        del_buffer(player->buffer);\n        player->buffer = gen_player_buffer(s->x, s->y, s->z, s->rx, s->ry);\n    }\n}\n\nvoid interpolate_player(Player *player) {\n    State *s1 = &player->state1;\n    State *s2 = &player->state2;\n    float t1 = s2->t - s1->t;\n    float t2 = glfwGetTime() - s2->t;\n    t1 = MIN(t1, 1);\n    t1 = MAX(t1, 0.1);\n    float p = MIN(t2 / t1, 1);\n    update_player(\n        player,\n        s1->x + (s2->x - s1->x) * p,\n        s1->y + (s2->y - s1->y) * p,\n        s1->z + (s2->z - s1->z) * p,\n        s1->rx + (s2->rx - s1->rx) * p,\n        s1->ry + (s2->ry - s1->ry) * p,\n        0);\n}\n\nvoid delete_player(int id) {\n    Player *player = find_player(id);\n    if (!player) {\n        return;\n    }\n    int count = g->player_count;\n    del_buffer(player->buffer);\n    Player *other = g->players + (--count);\n    memcpy(player, other, sizeof(Player));\n    g->player_count = count;\n}\n\nvoid delete_all_players() {\n    for (int i = 0; i < g->player_count; i++) {\n        Player *player = g->players + i;\n        del_buffer(player->buffer);\n    }\n    g->player_count = 0;\n}\n\nfloat player_player_distance(Player *p1, Player *p2) {\n    State *s1 = &p1->state;\n    State *s2 = &p2->state;\n    float x = s2->x - s1->x;\n    float y = s2->y - s1->y;\n    float z = s2->z - s1->z;\n    return sqrtf(x * x + y * y + z * z);\n}\n\nfloat player_crosshair_distance(Player *p1, Player *p2) {\n    State *s1 = &p1->state;\n    State *s2 = &p2->state;\n    float d = player_player_distance(p1, p2);\n    float vx, vy, vz;\n    get_sight_vector(s1->rx, s1->ry, &vx, &vy, &vz);\n    vx *= d; vy *= d; vz *= d;\n    float px, py, pz;\n    px = s1->x + vx; py = s1->y + vy; pz = s1->z + vz;\n    float x = s2->x - px;\n    float y = s2->y - py;\n    float z = s2->z - pz;\n    return sqrtf(x * x + y * y + z * z);\n}\n\nPlayer *player_crosshair(Player *player) {\n    Player *result = 0;\n    float threshold = RADIANS(5);\n    float best = 0;\n    for (int i = 0; i < g->player_count; i++) {\n        Player *other = g->players + i;\n        if (other == player) {\n            continue;\n        }\n        float p = player_crosshair_distance(player, other);\n        float d = player_player_distance(player, other);\n        if (d < 96 && p / d < threshold) {\n            if (best == 0 || d < best) {\n                best = d;\n                result = other;\n            }\n        }\n    }\n    return result;\n}\n\nChunk *find_chunk(int p, int q) {\n    for (int i = 0; i < g->chunk_count; i++) {\n        Chunk *chunk = g->chunks + i;\n        if (chunk->p == p && chunk->q == q) {\n            return chunk;\n        }\n    }\n    return 0;\n}\n\nint chunk_distance(Chunk *chunk, int p, int q) {\n    int dp = ABS(chunk->p - p);\n    int dq = ABS(chunk->q - q);\n    return MAX(dp, dq);\n}\n\nint chunk_visible(float planes[6][4], int p, int q, int miny, int maxy) {\n    int x = p * CHUNK_SIZE - 1;\n    int z = q * CHUNK_SIZE - 1;\n    int d = CHUNK_SIZE + 1;\n    float points[8][3] = {\n        {x + 0, miny, z + 0},\n        {x + d, miny, z + 0},\n        {x + 0, miny, z + d},\n        {x + d, miny, z + d},\n        {x + 0, maxy, z + 0},\n        {x + d, maxy, z + 0},\n        {x + 0, maxy, z + d},\n        {x + d, maxy, z + d}\n    };\n    int n = g->ortho ? 4 : 6;\n    for (int i = 0; i < n; i++) {\n        int in = 0;\n        int out = 0;\n        for (int j = 0; j < 8; j++) {\n            float d =\n                planes[i][0] * points[j][0] +\n                planes[i][1] * points[j][1] +\n                planes[i][2] * points[j][2] +\n                planes[i][3];\n            if (d < 0) {\n                out++;\n            }\n            else {\n                in++;\n            }\n            if (in && out) {\n                break;\n            }\n        }\n        if (in == 0) {\n            return 0;\n        }\n    }\n    return 1;\n}\n\nint highest_block(float x, float z) {\n    int result = -1;\n    int nx = roundf(x);\n    int nz = roundf(z);\n    int p = chunked(x);\n    int q = chunked(z);\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        Map *map = &chunk->map;\n        MAP_FOR_EACH(map, ex, ey, ez, ew) {\n            if (is_obstacle(ew) && ex == nx && ez == nz) {\n                result = MAX(result, ey);\n            }\n        } END_MAP_FOR_EACH;\n    }\n    return result;\n}\n\nint _hit_test(\n    Map *map, float max_distance, int previous,\n    float x, float y, float z,\n    float vx, float vy, float vz,\n    int *hx, int *hy, int *hz)\n{\n    int m = 32;\n    int px = 0;\n    int py = 0;\n    int pz = 0;\n    for (int i = 0; i < max_distance * m; i++) {\n        int nx = roundf(x);\n        int ny = roundf(y);\n        int nz = roundf(z);\n        if (nx != px || ny != py || nz != pz) {\n            int hw = map_get(map, nx, ny, nz);\n            if (hw > 0) {\n                if (previous) {\n                    *hx = px; *hy = py; *hz = pz;\n                }\n                else {\n                    *hx = nx; *hy = ny; *hz = nz;\n                }\n                return hw;\n            }\n            px = nx; py = ny; pz = nz;\n        }\n        x += vx / m; y += vy / m; z += vz / m;\n    }\n    return 0;\n}\n\nint hit_test(\n    int previous, float x, float y, float z, float rx, float ry,\n    int *bx, int *by, int *bz)\n{\n    int result = 0;\n    float best = 0;\n    int p = chunked(x);\n    int q = chunked(z);\n    float vx, vy, vz;\n    get_sight_vector(rx, ry, &vx, &vy, &vz);\n    for (int i = 0; i < g->chunk_count; i++) {\n        Chunk *chunk = g->chunks + i;\n        if (chunk_distance(chunk, p, q) > 1) {\n            continue;\n        }\n        int hx, hy, hz;\n        int hw = _hit_test(&chunk->map, 8, previous,\n            x, y, z, vx, vy, vz, &hx, &hy, &hz);\n        if (hw > 0) {\n            float d = sqrtf(\n                powf(hx - x, 2) + powf(hy - y, 2) + powf(hz - z, 2));\n            if (best == 0 || d < best) {\n                best = d;\n                *bx = hx; *by = hy; *bz = hz;\n                result = hw;\n            }\n        }\n    }\n    return result;\n}\n\nint hit_test_face(Player *player, int *x, int *y, int *z, int *face) {\n    State *s = &player->state;\n    int w = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, x, y, z);\n    if (is_obstacle(w)) {\n        int hx, hy, hz;\n        hit_test(1, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n        int dx = hx - *x;\n        int dy = hy - *y;\n        int dz = hz - *z;\n        if (dx == -1 && dy == 0 && dz == 0) {\n            *face = 0; return 1;\n        }\n        if (dx == 1 && dy == 0 && dz == 0) {\n            *face = 1; return 1;\n        }\n        if (dx == 0 && dy == 0 && dz == -1) {\n            *face = 2; return 1;\n        }\n        if (dx == 0 && dy == 0 && dz == 1) {\n            *face = 3; return 1;\n        }\n        if (dx == 0 && dy == 1 && dz == 0) {\n            int degrees = roundf(DEGREES(atan2f(s->x - hx, s->z - hz)));\n            if (degrees < 0) {\n                degrees += 360;\n            }\n            int top = ((degrees + 45) / 90) % 4;\n            *face = 4 + top; return 1;\n        }\n    }\n    return 0;\n}\n\nint collide(int height, float *x, float *y, float *z) {\n    int result = 0;\n    int p = chunked(*x);\n    int q = chunked(*z);\n    Chunk *chunk = find_chunk(p, q);\n    if (!chunk) {\n        return result;\n    }\n    Map *map = &chunk->map;\n    int nx = roundf(*x);\n    int ny = roundf(*y);\n    int nz = roundf(*z);\n    float px = *x - nx;\n    float py = *y - ny;\n    float pz = *z - nz;\n    float pad = 0.25;\n    for (int dy = 0; dy < height; dy++) {\n        if (px < -pad && is_obstacle(map_get(map, nx - 1, ny - dy, nz))) {\n            *x = nx - pad;\n        }\n        if (px > pad && is_obstacle(map_get(map, nx + 1, ny - dy, nz))) {\n            *x = nx + pad;\n        }\n        if (py < -pad && is_obstacle(map_get(map, nx, ny - dy - 1, nz))) {\n            *y = ny - pad;\n            result = 1;\n        }\n        if (py > pad && is_obstacle(map_get(map, nx, ny - dy + 1, nz))) {\n            *y = ny + pad;\n            result = 1;\n        }\n        if (pz < -pad && is_obstacle(map_get(map, nx, ny - dy, nz - 1))) {\n            *z = nz - pad;\n        }\n        if (pz > pad && is_obstacle(map_get(map, nx, ny - dy, nz + 1))) {\n            *z = nz + pad;\n        }\n    }\n    return result;\n}\n\nint player_intersects_block(\n    int height,\n    float x, float y, float z,\n    int hx, int hy, int hz)\n{\n    int nx = roundf(x);\n    int ny = roundf(y);\n    int nz = roundf(z);\n    for (int i = 0; i < height; i++) {\n        if (nx == hx && ny - i == hy && nz == hz) {\n            return 1;\n        }\n    }\n    return 0;\n}\n\nint _gen_sign_buffer(\n    GLfloat *data, float x, float y, float z, int face, const char *text)\n{\n    static const int glyph_dx[8] = {0, 0, -1, 1, 1, 0, -1, 0};\n    static const int glyph_dz[8] = {1, -1, 0, 0, 0, -1, 0, 1};\n    static const int line_dx[8] = {0, 0, 0, 0, 0, 1, 0, -1};\n    static const int line_dy[8] = {-1, -1, -1, -1, 0, 0, 0, 0};\n    static const int line_dz[8] = {0, 0, 0, 0, 1, 0, -1, 0};\n    if (face < 0 || face >= 8) {\n        return 0;\n    }\n    int count = 0;\n    float max_width = 64;\n    float line_height = 1.25;\n    char lines[1024];\n    int rows = wrap(text, max_width, lines, 1024);\n    rows = MIN(rows, 5);\n    int dx = glyph_dx[face];\n    int dz = glyph_dz[face];\n    int ldx = line_dx[face];\n    int ldy = line_dy[face];\n    int ldz = line_dz[face];\n    float n = 1.0 / (max_width / 10);\n    float sx = x - n * (rows - 1) * (line_height / 2) * ldx;\n    float sy = y - n * (rows - 1) * (line_height / 2) * ldy;\n    float sz = z - n * (rows - 1) * (line_height / 2) * ldz;\n    char *key;\n    char *line = tokenize(lines, \"\\n\", &key);\n    while (line) {\n        int length = strlen(line);\n        int line_width = string_width(line);\n        line_width = MIN(line_width, max_width);\n        float rx = sx - dx * line_width / max_width / 2;\n        float ry = sy;\n        float rz = sz - dz * line_width / max_width / 2;\n        for (int i = 0; i < length; i++) {\n            int width = char_width(line[i]);\n            line_width -= width;\n            if (line_width < 0) {\n                break;\n            }\n            rx += dx * width / max_width / 2;\n            rz += dz * width / max_width / 2;\n            if (line[i] != ' ') {\n                make_character_3d(\n                    data + count * 30, rx, ry, rz, n / 2, face, line[i]);\n                count++;\n            }\n            rx += dx * width / max_width / 2;\n            rz += dz * width / max_width / 2;\n        }\n        sx += n * line_height * ldx;\n        sy += n * line_height * ldy;\n        sz += n * line_height * ldz;\n        line = tokenize(NULL, \"\\n\", &key);\n        rows--;\n        if (rows <= 0) {\n            break;\n        }\n    }\n    return count;\n}\n\nvoid gen_sign_buffer(Chunk *chunk) {\n    SignList *signs = &chunk->signs;\n\n    // first pass - count characters\n    int max_faces = 0;\n    for (int i = 0; i < signs->size; i++) {\n        Sign *e = signs->data + i;\n        max_faces += strlen(e->text);\n    }\n\n    // second pass - generate geometry\n    GLfloat *data = malloc_faces(5, max_faces);\n    int faces = 0;\n    for (int i = 0; i < signs->size; i++) {\n        Sign *e = signs->data + i;\n        faces += _gen_sign_buffer(\n            data + faces * 30, e->x, e->y, e->z, e->face, e->text);\n    }\n\n    del_buffer(chunk->sign_buffer);\n    chunk->sign_buffer = gen_faces(5, faces, data);\n    chunk->sign_faces = faces;\n}\n\nint has_lights(Chunk *chunk) {\n    if (!SHOW_LIGHTS) {\n        return 0;\n    }\n    for (int dp = -1; dp <= 1; dp++) {\n        for (int dq = -1; dq <= 1; dq++) {\n            Chunk *other = chunk;\n            if (dp || dq) {\n                other = find_chunk(chunk->p + dp, chunk->q + dq);\n            }\n            if (!other) {\n                continue;\n            }\n            Map *map = &other->lights;\n            if (map->size) {\n                return 1;\n            }\n        }\n    }\n    return 0;\n}\n\nvoid dirty_chunk(Chunk *chunk) {\n    chunk->dirty = 1;\n    if (has_lights(chunk)) {\n        for (int dp = -1; dp <= 1; dp++) {\n            for (int dq = -1; dq <= 1; dq++) {\n                Chunk *other = find_chunk(chunk->p + dp, chunk->q + dq);\n                if (other) {\n                    other->dirty = 1;\n                }\n            }\n        }\n    }\n}\n\nvoid occlusion(\n    char neighbors[27], char lights[27], float shades[27],\n    float ao[6][4], float light[6][4])\n{\n    static const int lookup3[6][4][3] = {\n        {{0, 1, 3}, {2, 1, 5}, {6, 3, 7}, {8, 5, 7}},\n        {{18, 19, 21}, {20, 19, 23}, {24, 21, 25}, {26, 23, 25}},\n        {{6, 7, 15}, {8, 7, 17}, {24, 15, 25}, {26, 17, 25}},\n        {{0, 1, 9}, {2, 1, 11}, {18, 9, 19}, {20, 11, 19}},\n        {{0, 3, 9}, {6, 3, 15}, {18, 9, 21}, {24, 15, 21}},\n        {{2, 5, 11}, {8, 5, 17}, {20, 11, 23}, {26, 17, 23}}\n    };\n   static const int lookup4[6][4][4] = {\n        {{0, 1, 3, 4}, {1, 2, 4, 5}, {3, 4, 6, 7}, {4, 5, 7, 8}},\n        {{18, 19, 21, 22}, {19, 20, 22, 23}, {21, 22, 24, 25}, {22, 23, 25, 26}},\n        {{6, 7, 15, 16}, {7, 8, 16, 17}, {15, 16, 24, 25}, {16, 17, 25, 26}},\n        {{0, 1, 9, 10}, {1, 2, 10, 11}, {9, 10, 18, 19}, {10, 11, 19, 20}},\n        {{0, 3, 9, 12}, {3, 6, 12, 15}, {9, 12, 18, 21}, {12, 15, 21, 24}},\n        {{2, 5, 11, 14}, {5, 8, 14, 17}, {11, 14, 20, 23}, {14, 17, 23, 26}}\n    };\n    static const float curve[4] = {0.0, 0.25, 0.5, 0.75};\n    for (int i = 0; i < 6; i++) {\n        for (int j = 0; j < 4; j++) {\n            int corner = neighbors[lookup3[i][j][0]];\n            int side1 = neighbors[lookup3[i][j][1]];\n            int side2 = neighbors[lookup3[i][j][2]];\n            int value = side1 && side2 ? 3 : corner + side1 + side2;\n            float shade_sum = 0;\n            float light_sum = 0;\n            int is_light = lights[13] == 15;\n            for (int k = 0; k < 4; k++) {\n                shade_sum += shades[lookup4[i][j][k]];\n                light_sum += lights[lookup4[i][j][k]];\n            }\n            if (is_light) {\n                light_sum = 15 * 4 * 10;\n            }\n            float total = curve[value] + shade_sum / 4.0;\n            ao[i][j] = MIN(total, 1.0);\n            light[i][j] = light_sum / 15.0 / 4.0;\n        }\n    }\n}\n\n#define XZ_SIZE (CHUNK_SIZE * 3 + 2)\n#define XZ_LO (CHUNK_SIZE)\n#define XZ_HI (CHUNK_SIZE * 2 + 1)\n#define Y_SIZE 258\n#define XYZ(x, y, z) ((y) * XZ_SIZE * XZ_SIZE + (x) * XZ_SIZE + (z))\n#define XZ(x, z) ((x) * XZ_SIZE + (z))\n\nvoid light_fill(\n    char *opaque, char *light,\n    int x, int y, int z, int w, int force)\n{\n    if (x + w < XZ_LO || z + w < XZ_LO) {\n        return;\n    }\n    if (x - w > XZ_HI || z - w > XZ_HI) {\n        return;\n    }\n    if (y < 0 || y >= Y_SIZE) {\n        return;\n    }\n    if (light[XYZ(x, y, z)] >= w) {\n        return;\n    }\n    if (!force && opaque[XYZ(x, y, z)]) {\n        return;\n    }\n    light[XYZ(x, y, z)] = w--;\n    light_fill(opaque, light, x - 1, y, z, w, 0);\n    light_fill(opaque, light, x + 1, y, z, w, 0);\n    light_fill(opaque, light, x, y - 1, z, w, 0);\n    light_fill(opaque, light, x, y + 1, z, w, 0);\n    light_fill(opaque, light, x, y, z - 1, w, 0);\n    light_fill(opaque, light, x, y, z + 1, w, 0);\n}\n\nvoid compute_chunk(WorkerItem *item) {\n    char *opaque = (char *)calloc(XZ_SIZE * XZ_SIZE * Y_SIZE, sizeof(char));\n    char *light = (char *)calloc(XZ_SIZE * XZ_SIZE * Y_SIZE, sizeof(char));\n    char *highest = (char *)calloc(XZ_SIZE * XZ_SIZE, sizeof(char));\n\n    int ox = item->p * CHUNK_SIZE - CHUNK_SIZE - 1;\n    int oy = -1;\n    int oz = item->q * CHUNK_SIZE - CHUNK_SIZE - 1;\n\n    // check for lights\n    int has_light = 0;\n    if (SHOW_LIGHTS) {\n        for (int a = 0; a < 3; a++) {\n            for (int b = 0; b < 3; b++) {\n                Map *map = item->light_maps[a][b];\n                if (map && map->size) {\n                    has_light = 1;\n                }\n            }\n        }\n    }\n\n    // populate opaque array\n    for (int a = 0; a < 3; a++) {\n        for (int b = 0; b < 3; b++) {\n            Map *map = item->block_maps[a][b];\n            if (!map) {\n                continue;\n            }\n            MAP_FOR_EACH(map, ex, ey, ez, ew) {\n                int x = ex - ox;\n                int y = ey - oy;\n                int z = ez - oz;\n                int w = ew;\n                // TODO: this should be unnecessary\n                if (x < 0 || y < 0 || z < 0) {\n                    continue;\n                }\n                if (x >= XZ_SIZE || y >= Y_SIZE || z >= XZ_SIZE) {\n                    continue;\n                }\n                // END TODO\n                opaque[XYZ(x, y, z)] = !is_transparent(w);\n                if (opaque[XYZ(x, y, z)]) {\n                    highest[XZ(x, z)] = MAX(highest[XZ(x, z)], y);\n                }\n            } END_MAP_FOR_EACH;\n        }\n    }\n\n    // flood fill light intensities\n    if (has_light) {\n        for (int a = 0; a < 3; a++) {\n            for (int b = 0; b < 3; b++) {\n                Map *map = item->light_maps[a][b];\n                if (!map) {\n                    continue;\n                }\n                MAP_FOR_EACH(map, ex, ey, ez, ew) {\n                    int x = ex - ox;\n                    int y = ey - oy;\n                    int z = ez - oz;\n                    light_fill(opaque, light, x, y, z, ew, 1);\n                } END_MAP_FOR_EACH;\n            }\n        }\n    }\n\n    Map *map = item->block_maps[1][1];\n\n    // count exposed faces\n    int miny = 256;\n    int maxy = 0;\n    int faces = 0;\n    MAP_FOR_EACH(map, ex, ey, ez, ew) {\n        if (ew <= 0) {\n            continue;\n        }\n        int x = ex - ox;\n        int y = ey - oy;\n        int z = ez - oz;\n        int f1 = !opaque[XYZ(x - 1, y, z)];\n        int f2 = !opaque[XYZ(x + 1, y, z)];\n        int f3 = !opaque[XYZ(x, y + 1, z)];\n        int f4 = !opaque[XYZ(x, y - 1, z)] && (ey > 0);\n        int f5 = !opaque[XYZ(x, y, z - 1)];\n        int f6 = !opaque[XYZ(x, y, z + 1)];\n        int total = f1 + f2 + f3 + f4 + f5 + f6;\n        if (total == 0) {\n            continue;\n        }\n        if (is_plant(ew)) {\n            total = 4;\n        }\n        miny = MIN(miny, ey);\n        maxy = MAX(maxy, ey);\n        faces += total;\n    } END_MAP_FOR_EACH;\n\n    // generate geometry\n    GLfloat *data = malloc_faces(10, faces);\n    int offset = 0;\n    MAP_FOR_EACH(map, ex, ey, ez, ew) {\n        if (ew <= 0) {\n            continue;\n        }\n        int x = ex - ox;\n        int y = ey - oy;\n        int z = ez - oz;\n        int f1 = !opaque[XYZ(x - 1, y, z)];\n        int f2 = !opaque[XYZ(x + 1, y, z)];\n        int f3 = !opaque[XYZ(x, y + 1, z)];\n        int f4 = !opaque[XYZ(x, y - 1, z)] && (ey > 0);\n        int f5 = !opaque[XYZ(x, y, z - 1)];\n        int f6 = !opaque[XYZ(x, y, z + 1)];\n        int total = f1 + f2 + f3 + f4 + f5 + f6;\n        if (total == 0) {\n            continue;\n        }\n        char neighbors[27] = {0};\n        char lights[27] = {0};\n        float shades[27] = {0};\n        int index = 0;\n        for (int dx = -1; dx <= 1; dx++) {\n            for (int dy = -1; dy <= 1; dy++) {\n                for (int dz = -1; dz <= 1; dz++) {\n                    neighbors[index] = opaque[XYZ(x + dx, y + dy, z + dz)];\n                    lights[index] = light[XYZ(x + dx, y + dy, z + dz)];\n                    shades[index] = 0;\n                    if (y + dy <= highest[XZ(x + dx, z + dz)]) {\n                        for (int oy = 0; oy < 8; oy++) {\n                            if (opaque[XYZ(x + dx, y + dy + oy, z + dz)]) {\n                                shades[index] = 1.0 - oy * 0.125;\n                                break;\n                            }\n                        }\n                    }\n                    index++;\n                }\n            }\n        }\n        float ao[6][4];\n        float light[6][4];\n        occlusion(neighbors, lights, shades, ao, light);\n        if (is_plant(ew)) {\n            total = 4;\n            float min_ao = 1;\n            float max_light = 0;\n            for (int a = 0; a < 6; a++) {\n                for (int b = 0; b < 4; b++) {\n                    min_ao = MIN(min_ao, ao[a][b]);\n                    max_light = MAX(max_light, light[a][b]);\n                }\n            }\n            float rotation = simplex2(ex, ez, 4, 0.5, 2) * 360;\n            make_plant(\n                data + offset, min_ao, max_light,\n                ex, ey, ez, 0.5, ew, rotation);\n        }\n        else {\n            make_cube(\n                data + offset, ao, light,\n                f1, f2, f3, f4, f5, f6,\n                ex, ey, ez, 0.5, ew);\n        }\n        offset += total * 60;\n    } END_MAP_FOR_EACH;\n\n    free(opaque);\n    free(light);\n    free(highest);\n\n    item->miny = miny;\n    item->maxy = maxy;\n    item->faces = faces;\n    item->data = data;\n}\n\nvoid generate_chunk(Chunk *chunk, WorkerItem *item) {\n    chunk->miny = item->miny;\n    chunk->maxy = item->maxy;\n    chunk->faces = item->faces;\n    del_buffer(chunk->buffer);\n    chunk->buffer = gen_faces(10, item->faces, item->data);\n    gen_sign_buffer(chunk);\n}\n\nvoid gen_chunk_buffer(Chunk *chunk) {\n    WorkerItem _item;\n    WorkerItem *item = &_item;\n    item->p = chunk->p;\n    item->q = chunk->q;\n    for (int dp = -1; dp <= 1; dp++) {\n        for (int dq = -1; dq <= 1; dq++) {\n            Chunk *other = chunk;\n            if (dp || dq) {\n                other = find_chunk(chunk->p + dp, chunk->q + dq);\n            }\n            if (other) {\n                item->block_maps[dp + 1][dq + 1] = &other->map;\n                item->light_maps[dp + 1][dq + 1] = &other->lights;\n            }\n            else {\n                item->block_maps[dp + 1][dq + 1] = 0;\n                item->light_maps[dp + 1][dq + 1] = 0;\n            }\n        }\n    }\n    compute_chunk(item);\n    generate_chunk(chunk, item);\n    chunk->dirty = 0;\n}\n\nvoid map_set_func(int x, int y, int z, int w, void *arg) {\n    Map *map = (Map *)arg;\n    map_set(map, x, y, z, w);\n}\n\nvoid load_chunk(WorkerItem *item) {\n    int p = item->p;\n    int q = item->q;\n    Map *block_map = item->block_maps[1][1];\n    Map *light_map = item->light_maps[1][1];\n    create_world(p, q, map_set_func, block_map);\n    db_load_blocks(block_map, p, q);\n    db_load_lights(light_map, p, q);\n}\n\nvoid request_chunk(int p, int q) {\n    int key = db_get_key(p, q);\n    client_chunk(p, q, key);\n}\n\nvoid init_chunk(Chunk *chunk, int p, int q) {\n    chunk->p = p;\n    chunk->q = q;\n    chunk->faces = 0;\n    chunk->sign_faces = 0;\n    chunk->buffer = 0;\n    chunk->sign_buffer = 0;\n    dirty_chunk(chunk);\n    SignList *signs = &chunk->signs;\n    sign_list_alloc(signs, 16);\n    db_load_signs(signs, p, q);\n    Map *block_map = &chunk->map;\n    Map *light_map = &chunk->lights;\n    int dx = p * CHUNK_SIZE - 1;\n    int dy = 0;\n    int dz = q * CHUNK_SIZE - 1;\n    map_alloc(block_map, dx, dy, dz, 0x7fff);\n    map_alloc(light_map, dx, dy, dz, 0xf);\n}\n\nvoid create_chunk(Chunk *chunk, int p, int q) {\n    init_chunk(chunk, p, q);\n\n    WorkerItem _item;\n    WorkerItem *item = &_item;\n    item->p = chunk->p;\n    item->q = chunk->q;\n    item->block_maps[1][1] = &chunk->map;\n    item->light_maps[1][1] = &chunk->lights;\n    load_chunk(item);\n\n    request_chunk(p, q);\n}\n\nvoid delete_chunks() {\n    int count = g->chunk_count;\n    State *s1 = &g->players->state;\n    State *s2 = &(g->players + g->observe1)->state;\n    State *s3 = &(g->players + g->observe2)->state;\n    State *states[3] = {s1, s2, s3};\n    for (int i = 0; i < count; i++) {\n        Chunk *chunk = g->chunks + i;\n        int delete = 1;\n        for (int j = 0; j < 3; j++) {\n            State *s = states[j];\n            int p = chunked(s->x);\n            int q = chunked(s->z);\n            if (chunk_distance(chunk, p, q) < g->delete_radius) {\n                delete = 0;\n                break;\n            }\n        }\n        if (delete) {\n            map_free(&chunk->map);\n            map_free(&chunk->lights);\n            sign_list_free(&chunk->signs);\n            del_buffer(chunk->buffer);\n            del_buffer(chunk->sign_buffer);\n            Chunk *other = g->chunks + (--count);\n            memcpy(chunk, other, sizeof(Chunk));\n        }\n    }\n    g->chunk_count = count;\n}\n\nvoid delete_all_chunks() {\n    for (int i = 0; i < g->chunk_count; i++) {\n        Chunk *chunk = g->chunks + i;\n        map_free(&chunk->map);\n        map_free(&chunk->lights);\n        sign_list_free(&chunk->signs);\n        del_buffer(chunk->buffer);\n        del_buffer(chunk->sign_buffer);\n    }\n    g->chunk_count = 0;\n}\n\nvoid check_workers() {\n    for (int i = 0; i < WORKERS; i++) {\n        Worker *worker = g->workers + i;\n        mtx_lock(&worker->mtx);\n        if (worker->state == WORKER_DONE) {\n            WorkerItem *item = &worker->item;\n            Chunk *chunk = find_chunk(item->p, item->q);\n            if (chunk) {\n                if (item->load) {\n                    Map *block_map = item->block_maps[1][1];\n                    Map *light_map = item->light_maps[1][1];\n                    map_free(&chunk->map);\n                    map_free(&chunk->lights);\n                    map_copy(&chunk->map, block_map);\n                    map_copy(&chunk->lights, light_map);\n                    request_chunk(item->p, item->q);\n                }\n                generate_chunk(chunk, item);\n            }\n            for (int a = 0; a < 3; a++) {\n                for (int b = 0; b < 3; b++) {\n                    Map *block_map = item->block_maps[a][b];\n                    Map *light_map = item->light_maps[a][b];\n                    if (block_map) {\n                        map_free(block_map);\n                        free(block_map);\n                    }\n                    if (light_map) {\n                        map_free(light_map);\n                        free(light_map);\n                    }\n                }\n            }\n            worker->state = WORKER_IDLE;\n        }\n        mtx_unlock(&worker->mtx);\n    }\n}\n\nvoid force_chunks(Player *player) {\n    State *s = &player->state;\n    int p = chunked(s->x);\n    int q = chunked(s->z);\n    int r = 1;\n    for (int dp = -r; dp <= r; dp++) {\n        for (int dq = -r; dq <= r; dq++) {\n            int a = p + dp;\n            int b = q + dq;\n            Chunk *chunk = find_chunk(a, b);\n            if (chunk) {\n                if (chunk->dirty) {\n                    gen_chunk_buffer(chunk);\n                }\n            }\n            else if (g->chunk_count < MAX_CHUNKS) {\n                chunk = g->chunks + g->chunk_count++;\n                create_chunk(chunk, a, b);\n                gen_chunk_buffer(chunk);\n            }\n        }\n    }\n}\n\nvoid ensure_chunks_worker(Player *player, Worker *worker) {\n    State *s = &player->state;\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    float planes[6][4];\n    frustum_planes(planes, g->render_radius, matrix);\n    int p = chunked(s->x);\n    int q = chunked(s->z);\n    int r = g->create_radius;\n    int start = 0x0fffffff;\n    int best_score = start;\n    int best_a = 0;\n    int best_b = 0;\n    for (int dp = -r; dp <= r; dp++) {\n        for (int dq = -r; dq <= r; dq++) {\n            int a = p + dp;\n            int b = q + dq;\n            int index = (ABS(a) ^ ABS(b)) % WORKERS;\n            if (index != worker->index) {\n                continue;\n            }\n            Chunk *chunk = find_chunk(a, b);\n            if (chunk && !chunk->dirty) {\n                continue;\n            }\n            int distance = MAX(ABS(dp), ABS(dq));\n            int invisible = !chunk_visible(planes, a, b, 0, 256);\n            int priority = 0;\n            if (chunk) {\n                priority = chunk->buffer && chunk->dirty;\n            }\n            int score = (invisible << 24) | (priority << 16) | distance;\n            if (score < best_score) {\n                best_score = score;\n                best_a = a;\n                best_b = b;\n            }\n        }\n    }\n    if (best_score == start) {\n        return;\n    }\n    int a = best_a;\n    int b = best_b;\n    int load = 0;\n    Chunk *chunk = find_chunk(a, b);\n    if (!chunk) {\n        load = 1;\n        if (g->chunk_count < MAX_CHUNKS) {\n            chunk = g->chunks + g->chunk_count++;\n            init_chunk(chunk, a, b);\n        }\n        else {\n            return;\n        }\n    }\n    WorkerItem *item = &worker->item;\n    item->p = chunk->p;\n    item->q = chunk->q;\n    item->load = load;\n    for (int dp = -1; dp <= 1; dp++) {\n        for (int dq = -1; dq <= 1; dq++) {\n            Chunk *other = chunk;\n            if (dp || dq) {\n                other = find_chunk(chunk->p + dp, chunk->q + dq);\n            }\n            if (other) {\n                Map *block_map = malloc(sizeof(Map));\n                map_copy(block_map, &other->map);\n                Map *light_map = malloc(sizeof(Map));\n                map_copy(light_map, &other->lights);\n                item->block_maps[dp + 1][dq + 1] = block_map;\n                item->light_maps[dp + 1][dq + 1] = light_map;\n            }\n            else {\n                item->block_maps[dp + 1][dq + 1] = 0;\n                item->light_maps[dp + 1][dq + 1] = 0;\n            }\n        }\n    }\n    chunk->dirty = 0;\n    worker->state = WORKER_BUSY;\n    cnd_signal(&worker->cnd);\n}\n\nvoid ensure_chunks(Player *player) {\n    check_workers();\n    force_chunks(player);\n    for (int i = 0; i < WORKERS; i++) {\n        Worker *worker = g->workers + i;\n        mtx_lock(&worker->mtx);\n        if (worker->state == WORKER_IDLE) {\n            ensure_chunks_worker(player, worker);\n        }\n        mtx_unlock(&worker->mtx);\n    }\n}\n\nint worker_run(void *arg) {\n    Worker *worker = (Worker *)arg;\n    int running = 1;\n    while (running) {\n        mtx_lock(&worker->mtx);\n        while (worker->state != WORKER_BUSY) {\n            cnd_wait(&worker->cnd, &worker->mtx);\n        }\n        mtx_unlock(&worker->mtx);\n        WorkerItem *item = &worker->item;\n        if (item->load) {\n            load_chunk(item);\n        }\n        compute_chunk(item);\n        mtx_lock(&worker->mtx);\n        worker->state = WORKER_DONE;\n        mtx_unlock(&worker->mtx);\n    }\n    return 0;\n}\n\nvoid unset_sign(int x, int y, int z) {\n    int p = chunked(x);\n    int q = chunked(z);\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        SignList *signs = &chunk->signs;\n        if (sign_list_remove_all(signs, x, y, z)) {\n            chunk->dirty = 1;\n            db_delete_signs(x, y, z);\n        }\n    }\n    else {\n        db_delete_signs(x, y, z);\n    }\n}\n\nvoid unset_sign_face(int x, int y, int z, int face) {\n    int p = chunked(x);\n    int q = chunked(z);\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        SignList *signs = &chunk->signs;\n        if (sign_list_remove(signs, x, y, z, face)) {\n            chunk->dirty = 1;\n            db_delete_sign(x, y, z, face);\n        }\n    }\n    else {\n        db_delete_sign(x, y, z, face);\n    }\n}\n\nvoid _set_sign(\n    int p, int q, int x, int y, int z, int face, const char *text, int dirty)\n{\n    if (strlen(text) == 0) {\n        unset_sign_face(x, y, z, face);\n        return;\n    }\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        SignList *signs = &chunk->signs;\n        sign_list_add(signs, x, y, z, face, text);\n        if (dirty) {\n            chunk->dirty = 1;\n        }\n    }\n    db_insert_sign(p, q, x, y, z, face, text);\n}\n\nvoid set_sign(int x, int y, int z, int face, const char *text) {\n    int p = chunked(x);\n    int q = chunked(z);\n    _set_sign(p, q, x, y, z, face, text, 1);\n    client_sign(x, y, z, face, text);\n}\n\nvoid toggle_light(int x, int y, int z) {\n    int p = chunked(x);\n    int q = chunked(z);\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        Map *map = &chunk->lights;\n        int w = map_get(map, x, y, z) ? 0 : 15;\n        map_set(map, x, y, z, w);\n        db_insert_light(p, q, x, y, z, w);\n        client_light(x, y, z, w);\n        dirty_chunk(chunk);\n    }\n}\n\nvoid set_light(int p, int q, int x, int y, int z, int w) {\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        Map *map = &chunk->lights;\n        if (map_set(map, x, y, z, w)) {\n            dirty_chunk(chunk);\n            db_insert_light(p, q, x, y, z, w);\n        }\n    }\n    else {\n        db_insert_light(p, q, x, y, z, w);\n    }\n}\n\nvoid _set_block(int p, int q, int x, int y, int z, int w, int dirty) {\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        Map *map = &chunk->map;\n        if (map_set(map, x, y, z, w)) {\n            if (dirty) {\n                dirty_chunk(chunk);\n            }\n            db_insert_block(p, q, x, y, z, w);\n        }\n    }\n    else {\n        db_insert_block(p, q, x, y, z, w);\n    }\n    if (w == 0 && chunked(x) == p && chunked(z) == q) {\n        unset_sign(x, y, z);\n        set_light(p, q, x, y, z, 0);\n    }\n}\n\nvoid set_block(int x, int y, int z, int w) {\n    int p = chunked(x);\n    int q = chunked(z);\n    _set_block(p, q, x, y, z, w, 1);\n    for (int dx = -1; dx <= 1; dx++) {\n        for (int dz = -1; dz <= 1; dz++) {\n            if (dx == 0 && dz == 0) {\n                continue;\n            }\n            if (dx && chunked(x + dx) == p) {\n                continue;\n            }\n            if (dz && chunked(z + dz) == q) {\n                continue;\n            }\n            _set_block(p + dx, q + dz, x, y, z, -w, 1);\n        }\n    }\n    client_block(x, y, z, w);\n}\n\nvoid record_block(int x, int y, int z, int w) {\n    memcpy(&g->block1, &g->block0, sizeof(Block));\n    g->block0.x = x;\n    g->block0.y = y;\n    g->block0.z = z;\n    g->block0.w = w;\n}\n\nint get_block(int x, int y, int z) {\n    int p = chunked(x);\n    int q = chunked(z);\n    Chunk *chunk = find_chunk(p, q);\n    if (chunk) {\n        Map *map = &chunk->map;\n        return map_get(map, x, y, z);\n    }\n    return 0;\n}\n\nvoid builder_block(int x, int y, int z, int w) {\n    if (y <= 0 || y >= 256) {\n        return;\n    }\n    if (is_destructable(get_block(x, y, z))) {\n        set_block(x, y, z, 0);\n    }\n    if (w) {\n        set_block(x, y, z, w);\n    }\n}\n\nint render_chunks(Attrib *attrib, Player *player) {\n    int result = 0;\n    State *s = &player->state;\n    ensure_chunks(player);\n    int p = chunked(s->x);\n    int q = chunked(s->z);\n    float light = get_daylight();\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    float planes[6][4];\n    frustum_planes(planes, g->render_radius, matrix);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform3f(attrib->camera, s->x, s->y, s->z);\n    glUniform1i(attrib->sampler, 0);\n    glUniform1i(attrib->extra1, 2);\n    glUniform1f(attrib->extra2, light);\n    glUniform1f(attrib->extra3, g->render_radius * CHUNK_SIZE);\n    glUniform1i(attrib->extra4, g->ortho);\n    glUniform1f(attrib->timer, time_of_day());\n    for (int i = 0; i < g->chunk_count; i++) {\n        Chunk *chunk = g->chunks + i;\n        if (chunk_distance(chunk, p, q) > g->render_radius) {\n            continue;\n        }\n        if (!chunk_visible(\n            planes, chunk->p, chunk->q, chunk->miny, chunk->maxy))\n        {\n            continue;\n        }\n        draw_chunk(attrib, chunk);\n        result += chunk->faces;\n    }\n    return result;\n}\n\nvoid render_signs(Attrib *attrib, Player *player) {\n    State *s = &player->state;\n    int p = chunked(s->x);\n    int q = chunked(s->z);\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    float planes[6][4];\n    frustum_planes(planes, g->render_radius, matrix);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform1i(attrib->sampler, 3);\n    glUniform1i(attrib->extra1, 1);\n    for (int i = 0; i < g->chunk_count; i++) {\n        Chunk *chunk = g->chunks + i;\n        if (chunk_distance(chunk, p, q) > g->sign_radius) {\n            continue;\n        }\n        if (!chunk_visible(\n            planes, chunk->p, chunk->q, chunk->miny, chunk->maxy))\n        {\n            continue;\n        }\n        draw_signs(attrib, chunk);\n    }\n}\n\nvoid render_sign(Attrib *attrib, Player *player) {\n    if (!g->typing || g->typing_buffer[0] != CRAFT_KEY_SIGN) {\n        return;\n    }\n    int x, y, z, face;\n    if (!hit_test_face(player, &x, &y, &z, &face)) {\n        return;\n    }\n    State *s = &player->state;\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform1i(attrib->sampler, 3);\n    glUniform1i(attrib->extra1, 1);\n    char text[MAX_SIGN_LENGTH];\n    strncpy(text, g->typing_buffer + 1, MAX_SIGN_LENGTH);\n    text[MAX_SIGN_LENGTH - 1] = '\\0';\n    GLfloat *data = malloc_faces(5, strlen(text));\n    int length = _gen_sign_buffer(data, x, y, z, face, text);\n    GLuint buffer = gen_faces(5, length, data);\n    draw_sign(attrib, buffer, length);\n    del_buffer(buffer);\n}\n\nvoid render_players(Attrib *attrib, Player *player) {\n    State *s = &player->state;\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform3f(attrib->camera, s->x, s->y, s->z);\n    glUniform1i(attrib->sampler, 0);\n    glUniform1f(attrib->timer, time_of_day());\n    for (int i = 0; i < g->player_count; i++) {\n        Player *other = g->players + i;\n        if (other != player) {\n            draw_player(attrib, other);\n        }\n    }\n}\n\nvoid render_sky(Attrib *attrib, Player *player, GLuint buffer) {\n    State *s = &player->state;\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        0, 0, 0, s->rx, s->ry, g->fov, 0, g->render_radius);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform1i(attrib->sampler, 2);\n    glUniform1f(attrib->timer, time_of_day());\n    draw_triangles_3d(attrib, buffer, 512 * 3);\n}\n\nvoid render_wireframe(Attrib *attrib, Player *player) {\n    State *s = &player->state;\n    float matrix[16];\n    set_matrix_3d(\n        matrix, g->width, g->height,\n        s->x, s->y, s->z, s->rx, s->ry, g->fov, g->ortho, g->render_radius);\n    int hx, hy, hz;\n    int hw = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n    if (is_obstacle(hw)) {\n        glUseProgram(attrib->program);\n        glLineWidth(1);\n        glEnable(GL_COLOR_LOGIC_OP);\n        glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n        GLuint wireframe_buffer = gen_wireframe_buffer(hx, hy, hz, 0.53);\n        draw_lines(attrib, wireframe_buffer, 3, 24);\n        del_buffer(wireframe_buffer);\n        glDisable(GL_COLOR_LOGIC_OP);\n    }\n}\n\nvoid render_crosshairs(Attrib *attrib) {\n    float matrix[16];\n    set_matrix_2d(matrix, g->width, g->height);\n    glUseProgram(attrib->program);\n    glLineWidth(4 * g->scale);\n    glEnable(GL_COLOR_LOGIC_OP);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    GLuint crosshair_buffer = gen_crosshair_buffer();\n    draw_lines(attrib, crosshair_buffer, 2, 4);\n    del_buffer(crosshair_buffer);\n    glDisable(GL_COLOR_LOGIC_OP);\n}\n\nvoid render_item(Attrib *attrib) {\n    float matrix[16];\n    set_matrix_item(matrix, g->width, g->height, g->scale);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform3f(attrib->camera, 0, 0, 5);\n    glUniform1i(attrib->sampler, 0);\n    glUniform1f(attrib->timer, time_of_day());\n    int w = items[g->item_index];\n    if (is_plant(w)) {\n        GLuint buffer = gen_plant_buffer(0, 0, 0, 0.5, w);\n        draw_plant(attrib, buffer);\n        del_buffer(buffer);\n    }\n    else {\n        GLuint buffer = gen_cube_buffer(0, 0, 0, 0.5, w);\n        draw_cube(attrib, buffer);\n        del_buffer(buffer);\n    }\n}\n\nvoid render_text(\n    Attrib *attrib, int justify, float x, float y, float n, char *text)\n{\n    float matrix[16];\n    set_matrix_2d(matrix, g->width, g->height);\n    glUseProgram(attrib->program);\n    glUniformMatrix4fv(attrib->matrix, 1, GL_FALSE, matrix);\n    glUniform1i(attrib->sampler, 1);\n    glUniform1i(attrib->extra1, 0);\n    int length = strlen(text);\n    x -= n * justify * (length - 1) / 2;\n    GLuint buffer = gen_text_buffer(x, y, n, text);\n    draw_text(attrib, buffer, length);\n    del_buffer(buffer);\n}\n\nvoid add_message(const char *text) {\n    printf(\"%s\\n\", text);\n    snprintf(\n        g->messages[g->message_index], MAX_TEXT_LENGTH, \"%s\", text);\n    g->message_index = (g->message_index + 1) % MAX_MESSAGES;\n}\n\nvoid login() {\n    char username[128] = {0};\n    char identity_token[128] = {0};\n    char access_token[128] = {0};\n    if (db_auth_get_selected(username, 128, identity_token, 128)) {\n        printf(\"Contacting login server for username: %s\\n\", username);\n        if (get_access_token(\n            access_token, 128, username, identity_token))\n        {\n            printf(\"Successfully authenticated with the login server\\n\");\n            client_login(username, access_token);\n        }\n        else {\n            printf(\"Failed to authenticate with the login server\\n\");\n            client_login(\"\", \"\");\n        }\n    }\n    else {\n        printf(\"Logging in anonymously\\n\");\n        client_login(\"\", \"\");\n    }\n}\n\nvoid copy() {\n    memcpy(&g->copy0, &g->block0, sizeof(Block));\n    memcpy(&g->copy1, &g->block1, sizeof(Block));\n}\n\nvoid paste() {\n    Block *c1 = &g->copy1;\n    Block *c2 = &g->copy0;\n    Block *p1 = &g->block1;\n    Block *p2 = &g->block0;\n    int scx = SIGN(c2->x - c1->x);\n    int scz = SIGN(c2->z - c1->z);\n    int spx = SIGN(p2->x - p1->x);\n    int spz = SIGN(p2->z - p1->z);\n    int oy = p1->y - c1->y;\n    int dx = ABS(c2->x - c1->x);\n    int dz = ABS(c2->z - c1->z);\n    for (int y = 0; y < 256; y++) {\n        for (int x = 0; x <= dx; x++) {\n            for (int z = 0; z <= dz; z++) {\n                int w = get_block(c1->x + x * scx, y, c1->z + z * scz);\n                builder_block(p1->x + x * spx, y + oy, p1->z + z * spz, w);\n            }\n        }\n    }\n}\n\nvoid array(Block *b1, Block *b2, int xc, int yc, int zc) {\n    if (b1->w != b2->w) {\n        return;\n    }\n    int w = b1->w;\n    int dx = b2->x - b1->x;\n    int dy = b2->y - b1->y;\n    int dz = b2->z - b1->z;\n    xc = dx ? xc : 1;\n    yc = dy ? yc : 1;\n    zc = dz ? zc : 1;\n    for (int i = 0; i < xc; i++) {\n        int x = b1->x + dx * i;\n        for (int j = 0; j < yc; j++) {\n            int y = b1->y + dy * j;\n            for (int k = 0; k < zc; k++) {\n                int z = b1->z + dz * k;\n                builder_block(x, y, z, w);\n            }\n        }\n    }\n}\n\nvoid cube(Block *b1, Block *b2, int fill) {\n    if (b1->w != b2->w) {\n        return;\n    }\n    int w = b1->w;\n    int x1 = MIN(b1->x, b2->x);\n    int y1 = MIN(b1->y, b2->y);\n    int z1 = MIN(b1->z, b2->z);\n    int x2 = MAX(b1->x, b2->x);\n    int y2 = MAX(b1->y, b2->y);\n    int z2 = MAX(b1->z, b2->z);\n    int a = (x1 == x2) + (y1 == y2) + (z1 == z2);\n    for (int x = x1; x <= x2; x++) {\n        for (int y = y1; y <= y2; y++) {\n            for (int z = z1; z <= z2; z++) {\n                if (!fill) {\n                    int n = 0;\n                    n += x == x1 || x == x2;\n                    n += y == y1 || y == y2;\n                    n += z == z1 || z == z2;\n                    if (n <= a) {\n                        continue;\n                    }\n                }\n                builder_block(x, y, z, w);\n            }\n        }\n    }\n}\n\nvoid sphere(Block *center, int radius, int fill, int fx, int fy, int fz) {\n    static const float offsets[8][3] = {\n        {-0.5, -0.5, -0.5},\n        {-0.5, -0.5, 0.5},\n        {-0.5, 0.5, -0.5},\n        {-0.5, 0.5, 0.5},\n        {0.5, -0.5, -0.5},\n        {0.5, -0.5, 0.5},\n        {0.5, 0.5, -0.5},\n        {0.5, 0.5, 0.5}\n    };\n    int cx = center->x;\n    int cy = center->y;\n    int cz = center->z;\n    int w = center->w;\n    for (int x = cx - radius; x <= cx + radius; x++) {\n        if (fx && x != cx) {\n            continue;\n        }\n        for (int y = cy - radius; y <= cy + radius; y++) {\n            if (fy && y != cy) {\n                continue;\n            }\n            for (int z = cz - radius; z <= cz + radius; z++) {\n                if (fz && z != cz) {\n                    continue;\n                }\n                int inside = 0;\n                int outside = fill;\n                for (int i = 0; i < 8; i++) {\n                    float dx = x + offsets[i][0] - cx;\n                    float dy = y + offsets[i][1] - cy;\n                    float dz = z + offsets[i][2] - cz;\n                    float d = sqrtf(dx * dx + dy * dy + dz * dz);\n                    if (d < radius) {\n                        inside = 1;\n                    }\n                    else {\n                        outside = 1;\n                    }\n                }\n                if (inside && outside) {\n                    builder_block(x, y, z, w);\n                }\n            }\n        }\n    }\n}\n\nvoid cylinder(Block *b1, Block *b2, int radius, int fill) {\n    if (b1->w != b2->w) {\n        return;\n    }\n    int w = b1->w;\n    int x1 = MIN(b1->x, b2->x);\n    int y1 = MIN(b1->y, b2->y);\n    int z1 = MIN(b1->z, b2->z);\n    int x2 = MAX(b1->x, b2->x);\n    int y2 = MAX(b1->y, b2->y);\n    int z2 = MAX(b1->z, b2->z);\n    int fx = x1 != x2;\n    int fy = y1 != y2;\n    int fz = z1 != z2;\n    if (fx + fy + fz != 1) {\n        return;\n    }\n    Block block = {x1, y1, z1, w};\n    if (fx) {\n        for (int x = x1; x <= x2; x++) {\n            block.x = x;\n            sphere(&block, radius, fill, 1, 0, 0);\n        }\n    }\n    if (fy) {\n        for (int y = y1; y <= y2; y++) {\n            block.y = y;\n            sphere(&block, radius, fill, 0, 1, 0);\n        }\n    }\n    if (fz) {\n        for (int z = z1; z <= z2; z++) {\n            block.z = z;\n            sphere(&block, radius, fill, 0, 0, 1);\n        }\n    }\n}\n\nvoid tree(Block *block) {\n    int bx = block->x;\n    int by = block->y;\n    int bz = block->z;\n    for (int y = by + 3; y < by + 8; y++) {\n        for (int dx = -3; dx <= 3; dx++) {\n            for (int dz = -3; dz <= 3; dz++) {\n                int dy = y - (by + 4);\n                int d = (dx * dx) + (dy * dy) + (dz * dz);\n                if (d < 11) {\n                    builder_block(bx + dx, y, bz + dz, 15);\n                }\n            }\n        }\n    }\n    for (int y = by; y < by + 7; y++) {\n        builder_block(bx, y, bz, 5);\n    }\n}\n\nvoid parse_command(const char *buffer, int forward) {\n    char username[128] = {0};\n    char token[128] = {0};\n    char server_addr[MAX_ADDR_LENGTH];\n    int server_port = DEFAULT_PORT;\n    char filename[MAX_PATH_LENGTH];\n    int radius, count, xc, yc, zc;\n    if (sscanf(buffer, \"/identity %128s %128s\", username, token) == 2) {\n        db_auth_set(username, token);\n        add_message(\"Successfully imported identity token!\");\n        login();\n    }\n    else if (strcmp(buffer, \"/logout\") == 0) {\n        db_auth_select_none();\n        login();\n    }\n    else if (sscanf(buffer, \"/login %128s\", username) == 1) {\n        if (db_auth_select(username)) {\n            login();\n        }\n        else {\n            add_message(\"Unknown username.\");\n        }\n    }\n    else if (sscanf(buffer,\n        \"/online %128s %d\", server_addr, &server_port) >= 1)\n    {\n        g->mode_changed = 1;\n        g->mode = MODE_ONLINE;\n        strncpy(g->server_addr, server_addr, MAX_ADDR_LENGTH);\n        g->server_port = server_port;\n        snprintf(g->db_path, MAX_PATH_LENGTH,\n            \"cache.%s.%d.db\", g->server_addr, g->server_port);\n    }\n    else if (sscanf(buffer, \"/offline %128s\", filename) == 1) {\n        g->mode_changed = 1;\n        g->mode = MODE_OFFLINE;\n        snprintf(g->db_path, MAX_PATH_LENGTH, \"%s.db\", filename);\n    }\n    else if (strcmp(buffer, \"/offline\") == 0) {\n        g->mode_changed = 1;\n        g->mode = MODE_OFFLINE;\n        snprintf(g->db_path, MAX_PATH_LENGTH, \"%s\", DB_PATH);\n    }\n    else if (sscanf(buffer, \"/view %d\", &radius) == 1) {\n        if (radius >= 1 && radius <= 24) {\n            g->create_radius = radius;\n            g->render_radius = radius;\n            g->delete_radius = radius + 4;\n        }\n        else {\n            add_message(\"Viewing distance must be between 1 and 24.\");\n        }\n    }\n    else if (strcmp(buffer, \"/copy\") == 0) {\n        copy();\n    }\n    else if (strcmp(buffer, \"/paste\") == 0) {\n        paste();\n    }\n    else if (strcmp(buffer, \"/tree\") == 0) {\n        tree(&g->block0);\n    }\n    else if (sscanf(buffer, \"/array %d %d %d\", &xc, &yc, &zc) == 3) {\n        array(&g->block1, &g->block0, xc, yc, zc);\n    }\n    else if (sscanf(buffer, \"/array %d\", &count) == 1) {\n        array(&g->block1, &g->block0, count, count, count);\n    }\n    else if (strcmp(buffer, \"/fcube\") == 0) {\n        cube(&g->block0, &g->block1, 1);\n    }\n    else if (strcmp(buffer, \"/cube\") == 0) {\n        cube(&g->block0, &g->block1, 0);\n    }\n    else if (sscanf(buffer, \"/fsphere %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 1, 0, 0, 0);\n    }\n    else if (sscanf(buffer, \"/sphere %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 0, 0, 0, 0);\n    }\n    else if (sscanf(buffer, \"/fcirclex %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 1, 1, 0, 0);\n    }\n    else if (sscanf(buffer, \"/circlex %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 0, 1, 0, 0);\n    }\n    else if (sscanf(buffer, \"/fcircley %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 1, 0, 1, 0);\n    }\n    else if (sscanf(buffer, \"/circley %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 0, 0, 1, 0);\n    }\n    else if (sscanf(buffer, \"/fcirclez %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 1, 0, 0, 1);\n    }\n    else if (sscanf(buffer, \"/circlez %d\", &radius) == 1) {\n        sphere(&g->block0, radius, 0, 0, 0, 1);\n    }\n    else if (sscanf(buffer, \"/fcylinder %d\", &radius) == 1) {\n        cylinder(&g->block0, &g->block1, radius, 1);\n    }\n    else if (sscanf(buffer, \"/cylinder %d\", &radius) == 1) {\n        cylinder(&g->block0, &g->block1, radius, 0);\n    }\n    else if (forward) {\n        client_talk(buffer);\n    }\n}\n\nvoid on_light() {\n    State *s = &g->players->state;\n    int hx, hy, hz;\n    int hw = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n    if (hy > 0 && hy < 256 && is_destructable(hw)) {\n        toggle_light(hx, hy, hz);\n    }\n}\n\nvoid on_left_click() {\n    State *s = &g->players->state;\n    int hx, hy, hz;\n    int hw = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n    if (hy > 0 && hy < 256 && is_destructable(hw)) {\n        set_block(hx, hy, hz, 0);\n        record_block(hx, hy, hz, 0);\n        if (is_plant(get_block(hx, hy + 1, hz))) {\n            set_block(hx, hy + 1, hz, 0);\n        }\n    }\n}\n\nvoid on_right_click() {\n    State *s = &g->players->state;\n    int hx, hy, hz;\n    int hw = hit_test(1, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n    if (hy > 0 && hy < 256 && is_obstacle(hw)) {\n        if (!player_intersects_block(2, s->x, s->y, s->z, hx, hy, hz)) {\n            set_block(hx, hy, hz, items[g->item_index]);\n            record_block(hx, hy, hz, items[g->item_index]);\n        }\n    }\n}\n\nvoid on_middle_click() {\n    State *s = &g->players->state;\n    int hx, hy, hz;\n    int hw = hit_test(0, s->x, s->y, s->z, s->rx, s->ry, &hx, &hy, &hz);\n    for (int i = 0; i < item_count; i++) {\n        if (items[i] == hw) {\n            g->item_index = i;\n            break;\n        }\n    }\n}\n\nvoid on_key(GLFWwindow *window, int key, int scancode, int action, int mods) {\n    int control = mods & (GLFW_MOD_CONTROL | GLFW_MOD_SUPER);\n    int exclusive =\n        glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;\n    if (action == GLFW_RELEASE) {\n        return;\n    }\n    if (key == GLFW_KEY_BACKSPACE) {\n        if (g->typing) {\n            int n = strlen(g->typing_buffer);\n            if (n > 0) {\n                g->typing_buffer[n - 1] = '\\0';\n            }\n        }\n    }\n    if (action != GLFW_PRESS) {\n        return;\n    }\n    if (key == GLFW_KEY_ESCAPE) {\n        if (g->typing) {\n            g->typing = 0;\n        }\n        else if (exclusive) {\n            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);\n        }\n    }\n    if (key == GLFW_KEY_ENTER) {\n        if (g->typing) {\n            if (mods & GLFW_MOD_SHIFT) {\n                int n = strlen(g->typing_buffer);\n                if (n < MAX_TEXT_LENGTH - 1) {\n                    g->typing_buffer[n] = '\\r';\n                    g->typing_buffer[n + 1] = '\\0';\n                }\n            }\n            else {\n                g->typing = 0;\n                if (g->typing_buffer[0] == CRAFT_KEY_SIGN) {\n                    Player *player = g->players;\n                    int x, y, z, face;\n                    if (hit_test_face(player, &x, &y, &z, &face)) {\n                        set_sign(x, y, z, face, g->typing_buffer + 1);\n                    }\n                }\n                else if (g->typing_buffer[0] == '/') {\n                    parse_command(g->typing_buffer, 1);\n                }\n                else {\n                    client_talk(g->typing_buffer);\n                }\n            }\n        }\n        else {\n            if (control) {\n                on_right_click();\n            }\n            else {\n                on_left_click();\n            }\n        }\n    }\n    if (control && key == 'V') {\n        const char *buffer = glfwGetClipboardString(window);\n        if (g->typing) {\n            g->suppress_char = 1;\n            strncat(g->typing_buffer, buffer,\n                MAX_TEXT_LENGTH - strlen(g->typing_buffer) - 1);\n        }\n        else {\n            parse_command(buffer, 0);\n        }\n    }\n    if (!g->typing) {\n        if (key == CRAFT_KEY_FLY) {\n            g->flying = !g->flying;\n        }\n        if (key >= '1' && key <= '9') {\n            g->item_index = key - '1';\n        }\n        if (key == '0') {\n            g->item_index = 9;\n        }\n        if (key == CRAFT_KEY_ITEM_NEXT) {\n            g->item_index = (g->item_index + 1) % item_count;\n        }\n        if (key == CRAFT_KEY_ITEM_PREV) {\n            g->item_index--;\n            if (g->item_index < 0) {\n                g->item_index = item_count - 1;\n            }\n        }\n        if (key == CRAFT_KEY_OBSERVE) {\n            g->observe1 = (g->observe1 + 1) % g->player_count;\n        }\n        if (key == CRAFT_KEY_OBSERVE_INSET) {\n            g->observe2 = (g->observe2 + 1) % g->player_count;\n        }\n    }\n}\n\nvoid on_char(GLFWwindow *window, unsigned int u) {\n    if (g->suppress_char) {\n        g->suppress_char = 0;\n        return;\n    }\n    if (g->typing) {\n        if (u >= 32 && u < 128) {\n            char c = (char)u;\n            int n = strlen(g->typing_buffer);\n            if (n < MAX_TEXT_LENGTH - 1) {\n                g->typing_buffer[n] = c;\n                g->typing_buffer[n + 1] = '\\0';\n            }\n        }\n    }\n    else {\n        if (u == CRAFT_KEY_CHAT) {\n            g->typing = 1;\n            g->typing_buffer[0] = '\\0';\n        }\n        if (u == CRAFT_KEY_COMMAND) {\n            g->typing = 1;\n            g->typing_buffer[0] = '/';\n            g->typing_buffer[1] = '\\0';\n        }\n        if (u == CRAFT_KEY_SIGN) {\n            g->typing = 1;\n            g->typing_buffer[0] = CRAFT_KEY_SIGN;\n            g->typing_buffer[1] = '\\0';\n        }\n    }\n}\n\nvoid on_scroll(GLFWwindow *window, double xdelta, double ydelta) {\n    static double ypos = 0;\n    ypos += ydelta;\n    if (ypos < -SCROLL_THRESHOLD) {\n        g->item_index = (g->item_index + 1) % item_count;\n        ypos = 0;\n    }\n    if (ypos > SCROLL_THRESHOLD) {\n        g->item_index--;\n        if (g->item_index < 0) {\n            g->item_index = item_count - 1;\n        }\n        ypos = 0;\n    }\n}\n\nvoid on_mouse_button(GLFWwindow *window, int button, int action, int mods) {\n    int control = mods & (GLFW_MOD_CONTROL | GLFW_MOD_SUPER);\n    int exclusive =\n        glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;\n    if (action != GLFW_PRESS) {\n        return;\n    }\n    if (button == GLFW_MOUSE_BUTTON_LEFT) {\n        if (exclusive) {\n            if (control) {\n                on_right_click();\n            }\n            else {\n                on_left_click();\n            }\n        }\n        else {\n            glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n        }\n    }\n    if (button == GLFW_MOUSE_BUTTON_RIGHT) {\n        if (exclusive) {\n            if (control) {\n                on_light();\n            }\n            else {\n                on_right_click();\n            }\n        }\n    }\n    if (button == GLFW_MOUSE_BUTTON_MIDDLE) {\n        if (exclusive) {\n            on_middle_click();\n        }\n    }\n}\n\nvoid create_window() {\n    int window_width = WINDOW_WIDTH;\n    int window_height = WINDOW_HEIGHT;\n    GLFWmonitor *monitor = NULL;\n    if (FULLSCREEN) {\n        int mode_count;\n        monitor = glfwGetPrimaryMonitor();\n        const GLFWvidmode *modes = glfwGetVideoModes(monitor, &mode_count);\n        window_width = modes[mode_count - 1].width;\n        window_height = modes[mode_count - 1].height;\n    }\n    g->window = glfwCreateWindow(\n        window_width, window_height, \"Craft\", monitor, NULL);\n}\n\nvoid handle_mouse_input() {\n    int exclusive =\n        glfwGetInputMode(g->window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;\n    static double px = 0;\n    static double py = 0;\n    State *s = &g->players->state;\n    if (exclusive && (px || py)) {\n        double mx, my;\n        glfwGetCursorPos(g->window, &mx, &my);\n        float m = 0.0025;\n        s->rx += (mx - px) * m;\n        if (INVERT_MOUSE) {\n            s->ry += (my - py) * m;\n        }\n        else {\n            s->ry -= (my - py) * m;\n        }\n        if (s->rx < 0) {\n            s->rx += RADIANS(360);\n        }\n        if (s->rx >= RADIANS(360)){\n            s->rx -= RADIANS(360);\n        }\n        s->ry = MAX(s->ry, -RADIANS(90));\n        s->ry = MIN(s->ry, RADIANS(90));\n        px = mx;\n        py = my;\n    }\n    else {\n        glfwGetCursorPos(g->window, &px, &py);\n    }\n}\n\nvoid handle_movement(double dt) {\n    static float dy = 0;\n    State *s = &g->players->state;\n    int sz = 0;\n    int sx = 0;\n    if (!g->typing) {\n        float m = dt * 1.0;\n        g->ortho = glfwGetKey(g->window, CRAFT_KEY_ORTHO) ? 64 : 0;\n        g->fov = glfwGetKey(g->window, CRAFT_KEY_ZOOM) ? 15 : 65;\n        if (glfwGetKey(g->window, CRAFT_KEY_FORWARD)) sz--;\n        if (glfwGetKey(g->window, CRAFT_KEY_BACKWARD)) sz++;\n        if (glfwGetKey(g->window, CRAFT_KEY_LEFT)) sx--;\n        if (glfwGetKey(g->window, CRAFT_KEY_RIGHT)) sx++;\n        if (glfwGetKey(g->window, GLFW_KEY_LEFT)) s->rx -= m;\n        if (glfwGetKey(g->window, GLFW_KEY_RIGHT)) s->rx += m;\n        if (glfwGetKey(g->window, GLFW_KEY_UP)) s->ry += m;\n        if (glfwGetKey(g->window, GLFW_KEY_DOWN)) s->ry -= m;\n    }\n    float vx, vy, vz;\n    get_motion_vector(g->flying, sz, sx, s->rx, s->ry, &vx, &vy, &vz);\n    if (!g->typing) {\n        if (glfwGetKey(g->window, CRAFT_KEY_JUMP)) {\n            if (g->flying) {\n                vy = 1;\n            }\n            else if (dy == 0) {\n                dy = 8;\n            }\n        }\n    }\n    float speed = g->flying ? 20 : 5;\n    int estimate = roundf(sqrtf(\n        powf(vx * speed, 2) +\n        powf(vy * speed + ABS(dy) * 2, 2) +\n        powf(vz * speed, 2)) * dt * 8);\n    int step = MAX(8, estimate);\n    float ut = dt / step;\n    vx = vx * ut * speed;\n    vy = vy * ut * speed;\n    vz = vz * ut * speed;\n    for (int i = 0; i < step; i++) {\n        if (g->flying) {\n            dy = 0;\n        }\n        else {\n            dy -= ut * 25;\n            dy = MAX(dy, -250);\n        }\n        s->x += vx;\n        s->y += vy + dy * ut;\n        s->z += vz;\n        if (collide(2, &s->x, &s->y, &s->z)) {\n            dy = 0;\n        }\n    }\n    if (s->y < 0) {\n        s->y = highest_block(s->x, s->z) + 2;\n    }\n}\n\nvoid parse_buffer(char *buffer) {\n    Player *me = g->players;\n    State *s = &g->players->state;\n    char *key;\n    char *line = tokenize(buffer, \"\\n\", &key);\n    while (line) {\n        int pid;\n        float ux, uy, uz, urx, ury;\n        if (sscanf(line, \"U,%d,%f,%f,%f,%f,%f\",\n            &pid, &ux, &uy, &uz, &urx, &ury) == 6)\n        {\n            me->id = pid;\n            s->x = ux; s->y = uy; s->z = uz; s->rx = urx; s->ry = ury;\n            force_chunks(me);\n            if (uy == 0) {\n                s->y = highest_block(s->x, s->z) + 2;\n            }\n        }\n        int bp, bq, bx, by, bz, bw;\n        if (sscanf(line, \"B,%d,%d,%d,%d,%d,%d\",\n            &bp, &bq, &bx, &by, &bz, &bw) == 6)\n        {\n            _set_block(bp, bq, bx, by, bz, bw, 0);\n            if (player_intersects_block(2, s->x, s->y, s->z, bx, by, bz)) {\n                s->y = highest_block(s->x, s->z) + 2;\n            }\n        }\n        if (sscanf(line, \"L,%d,%d,%d,%d,%d,%d\",\n            &bp, &bq, &bx, &by, &bz, &bw) == 6)\n        {\n            set_light(bp, bq, bx, by, bz, bw);\n        }\n        float px, py, pz, prx, pry;\n        if (sscanf(line, \"P,%d,%f,%f,%f,%f,%f\",\n            &pid, &px, &py, &pz, &prx, &pry) == 6)\n        {\n            Player *player = find_player(pid);\n            if (!player && g->player_count < MAX_PLAYERS) {\n                player = g->players + g->player_count;\n                g->player_count++;\n                player->id = pid;\n                player->buffer = 0;\n                snprintf(player->name, MAX_NAME_LENGTH, \"player%d\", pid);\n                update_player(player, px, py, pz, prx, pry, 1); // twice\n            }\n            if (player) {\n                update_player(player, px, py, pz, prx, pry, 1);\n            }\n        }\n        if (sscanf(line, \"D,%d\", &pid) == 1) {\n            delete_player(pid);\n        }\n        int kp, kq, kk;\n        if (sscanf(line, \"K,%d,%d,%d\", &kp, &kq, &kk) == 3) {\n            db_set_key(kp, kq, kk);\n        }\n        if (sscanf(line, \"R,%d,%d\", &kp, &kq) == 2) {\n            Chunk *chunk = find_chunk(kp, kq);\n            if (chunk) {\n                dirty_chunk(chunk);\n            }\n        }\n        double elapsed;\n        int day_length;\n        if (sscanf(line, \"E,%lf,%d\", &elapsed, &day_length) == 2) {\n            glfwSetTime(fmod(elapsed, day_length));\n            g->day_length = day_length;\n            g->time_changed = 1;\n        }\n        if (line[0] == 'T' && line[1] == ',') {\n            char *text = line + 2;\n            add_message(text);\n        }\n        char format[64];\n        snprintf(\n            format, sizeof(format), \"N,%%d,%%%ds\", MAX_NAME_LENGTH - 1);\n        char name[MAX_NAME_LENGTH];\n        if (sscanf(line, format, &pid, name) == 2) {\n            Player *player = find_player(pid);\n            if (player) {\n                strncpy(player->name, name, MAX_NAME_LENGTH);\n            }\n        }\n        snprintf(\n            format, sizeof(format),\n            \"S,%%d,%%d,%%d,%%d,%%d,%%d,%%%d[^\\n]\", MAX_SIGN_LENGTH - 1);\n        int face;\n        char text[MAX_SIGN_LENGTH] = {0};\n        if (sscanf(line, format,\n            &bp, &bq, &bx, &by, &bz, &face, text) >= 6)\n        {\n            _set_sign(bp, bq, bx, by, bz, face, text, 0);\n        }\n        line = tokenize(NULL, \"\\n\", &key);\n    }\n}\n\nvoid reset_model() {\n    memset(g->chunks, 0, sizeof(Chunk) * MAX_CHUNKS);\n    g->chunk_count = 0;\n    memset(g->players, 0, sizeof(Player) * MAX_PLAYERS);\n    g->player_count = 0;\n    g->observe1 = 0;\n    g->observe2 = 0;\n    g->flying = 0;\n    g->item_index = 0;\n    memset(g->typing_buffer, 0, sizeof(char) * MAX_TEXT_LENGTH);\n    g->typing = 0;\n    memset(g->messages, 0, sizeof(char) * MAX_MESSAGES * MAX_TEXT_LENGTH);\n    g->message_index = 0;\n    g->day_length = DAY_LENGTH;\n    glfwSetTime(g->day_length / 3.0);\n    g->time_changed = 1;\n}\n\nint main(int argc, char **argv) {\n    // INITIALIZATION //\n    curl_global_init(CURL_GLOBAL_DEFAULT);\n    srand(time(NULL));\n    rand();\n\n    // WINDOW INITIALIZATION //\n    if (!glfwInit()) {\n        return -1;\n    }\n    create_window();\n    if (!g->window) {\n        glfwTerminate();\n        return -1;\n    }\n\n    glfwMakeContextCurrent(g->window);\n    glfwSwapInterval(VSYNC);\n    glfwSetInputMode(g->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);\n    glfwSetKeyCallback(g->window, on_key);\n    glfwSetCharCallback(g->window, on_char);\n    glfwSetMouseButtonCallback(g->window, on_mouse_button);\n    glfwSetScrollCallback(g->window, on_scroll);\n\n    if (glewInit() != GLEW_OK) {\n        return -1;\n    }\n\n    glEnable(GL_CULL_FACE);\n    glEnable(GL_DEPTH_TEST);\n    glLogicOp(GL_INVERT);\n    glClearColor(0, 0, 0, 1);\n\n    // LOAD TEXTURES //\n    GLuint texture;\n    glGenTextures(1, &texture);\n    glActiveTexture(GL_TEXTURE0);\n    glBindTexture(GL_TEXTURE_2D, texture);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n    load_png_texture(\"textures/texture.png\");\n\n    GLuint font;\n    glGenTextures(1, &font);\n    glActiveTexture(GL_TEXTURE1);\n    glBindTexture(GL_TEXTURE_2D, font);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    load_png_texture(\"textures/font.png\");\n\n    GLuint sky;\n    glGenTextures(1, &sky);\n    glActiveTexture(GL_TEXTURE2);\n    glBindTexture(GL_TEXTURE_2D, sky);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n    load_png_texture(\"textures/sky.png\");\n\n    GLuint sign;\n    glGenTextures(1, &sign);\n    glActiveTexture(GL_TEXTURE3);\n    glBindTexture(GL_TEXTURE_2D, sign);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n    load_png_texture(\"textures/sign.png\");\n\n    // LOAD SHADERS //\n    Attrib block_attrib = {0};\n    Attrib line_attrib = {0};\n    Attrib text_attrib = {0};\n    Attrib sky_attrib = {0};\n    GLuint program;\n\n    program = load_program(\n        \"shaders/block_vertex.glsl\", \"shaders/block_fragment.glsl\");\n    block_attrib.program = program;\n    block_attrib.position = glGetAttribLocation(program, \"position\");\n    block_attrib.normal = glGetAttribLocation(program, \"normal\");\n    block_attrib.uv = glGetAttribLocation(program, \"uv\");\n    block_attrib.matrix = glGetUniformLocation(program, \"matrix\");\n    block_attrib.sampler = glGetUniformLocation(program, \"sampler\");\n    block_attrib.extra1 = glGetUniformLocation(program, \"sky_sampler\");\n    block_attrib.extra2 = glGetUniformLocation(program, \"daylight\");\n    block_attrib.extra3 = glGetUniformLocation(program, \"fog_distance\");\n    block_attrib.extra4 = glGetUniformLocation(program, \"ortho\");\n    block_attrib.camera = glGetUniformLocation(program, \"camera\");\n    block_attrib.timer = glGetUniformLocation(program, \"timer\");\n\n    program = load_program(\n        \"shaders/line_vertex.glsl\", \"shaders/line_fragment.glsl\");\n    line_attrib.program = program;\n    line_attrib.position = glGetAttribLocation(program, \"position\");\n    line_attrib.matrix = glGetUniformLocation(program, \"matrix\");\n\n    program = load_program(\n        \"shaders/text_vertex.glsl\", \"shaders/text_fragment.glsl\");\n    text_attrib.program = program;\n    text_attrib.position = glGetAttribLocation(program, \"position\");\n    text_attrib.uv = glGetAttribLocation(program, \"uv\");\n    text_attrib.matrix = glGetUniformLocation(program, \"matrix\");\n    text_attrib.sampler = glGetUniformLocation(program, \"sampler\");\n    text_attrib.extra1 = glGetUniformLocation(program, \"is_sign\");\n\n    program = load_program(\n        \"shaders/sky_vertex.glsl\", \"shaders/sky_fragment.glsl\");\n    sky_attrib.program = program;\n    sky_attrib.position = glGetAttribLocation(program, \"position\");\n    sky_attrib.normal = glGetAttribLocation(program, \"normal\");\n    sky_attrib.uv = glGetAttribLocation(program, \"uv\");\n    sky_attrib.matrix = glGetUniformLocation(program, \"matrix\");\n    sky_attrib.sampler = glGetUniformLocation(program, \"sampler\");\n    sky_attrib.timer = glGetUniformLocation(program, \"timer\");\n\n    // CHECK COMMAND LINE ARGUMENTS //\n    if (argc == 2 || argc == 3) {\n        g->mode = MODE_ONLINE;\n        strncpy(g->server_addr, argv[1], MAX_ADDR_LENGTH);\n        g->server_port = argc == 3 ? atoi(argv[2]) : DEFAULT_PORT;\n        snprintf(g->db_path, MAX_PATH_LENGTH,\n            \"cache.%s.%d.db\", g->server_addr, g->server_port);\n    }\n    else {\n        g->mode = MODE_OFFLINE;\n        snprintf(g->db_path, MAX_PATH_LENGTH, \"%s\", DB_PATH);\n    }\n\n    g->create_radius = CREATE_CHUNK_RADIUS;\n    g->render_radius = RENDER_CHUNK_RADIUS;\n    g->delete_radius = DELETE_CHUNK_RADIUS;\n    g->sign_radius = RENDER_SIGN_RADIUS;\n\n    // INITIALIZE WORKER THREADS\n    for (int i = 0; i < WORKERS; i++) {\n        Worker *worker = g->workers + i;\n        worker->index = i;\n        worker->state = WORKER_IDLE;\n        mtx_init(&worker->mtx, mtx_plain);\n        cnd_init(&worker->cnd);\n        thrd_create(&worker->thrd, worker_run, worker);\n    }\n\n    // OUTER LOOP //\n    int running = 1;\n    while (running) {\n        // DATABASE INITIALIZATION //\n        if (g->mode == MODE_OFFLINE || USE_CACHE) {\n            db_enable();\n            if (db_init(g->db_path)) {\n                return -1;\n            }\n            if (g->mode == MODE_ONLINE) {\n                // TODO: support proper caching of signs (handle deletions)\n                db_delete_all_signs();\n            }\n        }\n\n        // CLIENT INITIALIZATION //\n        if (g->mode == MODE_ONLINE) {\n            client_enable();\n            client_connect(g->server_addr, g->server_port);\n            client_start();\n            client_version(1);\n            login();\n        }\n\n        // LOCAL VARIABLES //\n        reset_model();\n        FPS fps = {0, 0, 0};\n        double last_commit = glfwGetTime();\n        double last_update = glfwGetTime();\n        GLuint sky_buffer = gen_sky_buffer();\n\n        Player *me = g->players;\n        State *s = &g->players->state;\n        me->id = 0;\n        me->name[0] = '\\0';\n        me->buffer = 0;\n        g->player_count = 1;\n\n        // LOAD STATE FROM DATABASE //\n        int loaded = db_load_state(&s->x, &s->y, &s->z, &s->rx, &s->ry);\n        force_chunks(me);\n        if (!loaded) {\n            s->y = highest_block(s->x, s->z) + 2;\n        }\n\n        // BEGIN MAIN LOOP //\n        double previous = glfwGetTime();\n        while (1) {\n            // WINDOW SIZE AND SCALE //\n            g->scale = get_scale_factor();\n            glfwGetFramebufferSize(g->window, &g->width, &g->height);\n            glViewport(0, 0, g->width, g->height);\n\n            // FRAME RATE //\n            if (g->time_changed) {\n                g->time_changed = 0;\n                last_commit = glfwGetTime();\n                last_update = glfwGetTime();\n                memset(&fps, 0, sizeof(fps));\n            }\n            update_fps(&fps);\n            double now = glfwGetTime();\n            double dt = now - previous;\n            dt = MIN(dt, 0.2);\n            dt = MAX(dt, 0.0);\n            previous = now;\n\n            // HANDLE MOUSE INPUT //\n            handle_mouse_input();\n\n            // HANDLE MOVEMENT //\n            handle_movement(dt);\n\n            // HANDLE DATA FROM SERVER //\n            char *buffer = client_recv();\n            if (buffer) {\n                parse_buffer(buffer);\n                free(buffer);\n            }\n\n            // FLUSH DATABASE //\n            if (now - last_commit > COMMIT_INTERVAL) {\n                last_commit = now;\n                db_commit();\n            }\n\n            // SEND POSITION TO SERVER //\n            if (now - last_update > 0.1) {\n                last_update = now;\n                client_position(s->x, s->y, s->z, s->rx, s->ry);\n            }\n\n            // PREPARE TO RENDER //\n            g->observe1 = g->observe1 % g->player_count;\n            g->observe2 = g->observe2 % g->player_count;\n            delete_chunks();\n            del_buffer(me->buffer);\n            me->buffer = gen_player_buffer(s->x, s->y, s->z, s->rx, s->ry);\n            for (int i = 1; i < g->player_count; i++) {\n                interpolate_player(g->players + i);\n            }\n            Player *player = g->players + g->observe1;\n\n            // RENDER 3-D SCENE //\n            glClear(GL_COLOR_BUFFER_BIT);\n            glClear(GL_DEPTH_BUFFER_BIT);\n            render_sky(&sky_attrib, player, sky_buffer);\n            glClear(GL_DEPTH_BUFFER_BIT);\n            int face_count = render_chunks(&block_attrib, player);\n            render_signs(&text_attrib, player);\n            render_sign(&text_attrib, player);\n            render_players(&block_attrib, player);\n            if (SHOW_WIREFRAME) {\n                render_wireframe(&line_attrib, player);\n            }\n\n            // RENDER HUD //\n            glClear(GL_DEPTH_BUFFER_BIT);\n            if (SHOW_CROSSHAIRS) {\n                render_crosshairs(&line_attrib);\n            }\n            if (SHOW_ITEM) {\n                render_item(&block_attrib);\n            }\n\n            // RENDER TEXT //\n            char text_buffer[1024];\n            float ts = 12 * g->scale;\n            float tx = ts / 2;\n            float ty = g->height - ts;\n            if (SHOW_INFO_TEXT) {\n                int hour = time_of_day() * 24;\n                char am_pm = hour < 12 ? 'a' : 'p';\n                hour = hour % 12;\n                hour = hour ? hour : 12;\n                snprintf(\n                    text_buffer, 1024,\n                    \"(%d, %d) (%.2f, %.2f, %.2f) [%d, %d, %d] %d%cm %dfps\",\n                    chunked(s->x), chunked(s->z), s->x, s->y, s->z,\n                    g->player_count, g->chunk_count,\n                    face_count * 2, hour, am_pm, fps.fps);\n                render_text(&text_attrib, ALIGN_LEFT, tx, ty, ts, text_buffer);\n                ty -= ts * 2;\n            }\n            if (SHOW_CHAT_TEXT) {\n                for (int i = 0; i < MAX_MESSAGES; i++) {\n                    int index = (g->message_index + i) % MAX_MESSAGES;\n                    if (strlen(g->messages[index])) {\n                        render_text(&text_attrib, ALIGN_LEFT, tx, ty, ts,\n                            g->messages[index]);\n                        ty -= ts * 2;\n                    }\n                }\n            }\n            if (g->typing) {\n                snprintf(text_buffer, 1024, \"> %s\", g->typing_buffer);\n                render_text(&text_attrib, ALIGN_LEFT, tx, ty, ts, text_buffer);\n                ty -= ts * 2;\n            }\n            if (SHOW_PLAYER_NAMES) {\n                if (player != me) {\n                    render_text(&text_attrib, ALIGN_CENTER,\n                        g->width / 2, ts, ts, player->name);\n                }\n                Player *other = player_crosshair(player);\n                if (other) {\n                    render_text(&text_attrib, ALIGN_CENTER,\n                        g->width / 2, g->height / 2 - ts - 24, ts,\n                        other->name);\n                }\n            }\n\n            // RENDER PICTURE IN PICTURE //\n            if (g->observe2) {\n                player = g->players + g->observe2;\n\n                int pw = 256 * g->scale;\n                int ph = 256 * g->scale;\n                int offset = 32 * g->scale;\n                int pad = 3 * g->scale;\n                int sw = pw + pad * 2;\n                int sh = ph + pad * 2;\n\n                glEnable(GL_SCISSOR_TEST);\n                glScissor(g->width - sw - offset + pad, offset - pad, sw, sh);\n                glClear(GL_COLOR_BUFFER_BIT);\n                glDisable(GL_SCISSOR_TEST);\n                glClear(GL_DEPTH_BUFFER_BIT);\n                glViewport(g->width - pw - offset, offset, pw, ph);\n\n                g->width = pw;\n                g->height = ph;\n                g->ortho = 0;\n                g->fov = 65;\n\n                render_sky(&sky_attrib, player, sky_buffer);\n                glClear(GL_DEPTH_BUFFER_BIT);\n                render_chunks(&block_attrib, player);\n                render_signs(&text_attrib, player);\n                render_players(&block_attrib, player);\n                glClear(GL_DEPTH_BUFFER_BIT);\n                if (SHOW_PLAYER_NAMES) {\n                    render_text(&text_attrib, ALIGN_CENTER,\n                        pw / 2, ts, ts, player->name);\n                }\n            }\n\n            // SWAP AND POLL //\n            glfwSwapBuffers(g->window);\n            glfwPollEvents();\n            if (glfwWindowShouldClose(g->window)) {\n                running = 0;\n                break;\n            }\n            if (g->mode_changed) {\n                g->mode_changed = 0;\n                break;\n            }\n        }\n\n        // SHUTDOWN //\n        db_save_state(s->x, s->y, s->z, s->rx, s->ry);\n        db_close();\n        db_disable();\n        client_stop();\n        client_disable();\n        del_buffer(sky_buffer);\n        delete_all_chunks();\n        delete_all_players();\n    }\n\n    glfwTerminate();\n    curl_global_cleanup();\n    return 0;\n}\n"
  },
  {
    "path": "src/map.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include \"map.h\"\n\nint hash_int(int key) {\n    key = ~key + (key << 15);\n    key = key ^ (key >> 12);\n    key = key + (key << 2);\n    key = key ^ (key >> 4);\n    key = key * 2057;\n    key = key ^ (key >> 16);\n    return key;\n}\n\nint hash(int x, int y, int z) {\n    x = hash_int(x);\n    y = hash_int(y);\n    z = hash_int(z);\n    return x ^ y ^ z;\n}\n\nvoid map_alloc(Map *map, int dx, int dy, int dz, int mask) {\n    map->dx = dx;\n    map->dy = dy;\n    map->dz = dz;\n    map->mask = mask;\n    map->size = 0;\n    map->data = (MapEntry *)calloc(map->mask + 1, sizeof(MapEntry));\n}\n\nvoid map_free(Map *map) {\n    free(map->data);\n}\n\nvoid map_copy(Map *dst, Map *src) {\n    dst->dx = src->dx;\n    dst->dy = src->dy;\n    dst->dz = src->dz;\n    dst->mask = src->mask;\n    dst->size = src->size;\n    dst->data = (MapEntry *)calloc(dst->mask + 1, sizeof(MapEntry));\n    memcpy(dst->data, src->data, (dst->mask + 1) * sizeof(MapEntry));\n}\n\nint map_set(Map *map, int x, int y, int z, int w) {\n    unsigned int index = hash(x, y, z) & map->mask;\n    x -= map->dx;\n    y -= map->dy;\n    z -= map->dz;\n    MapEntry *entry = map->data + index;\n    int overwrite = 0;\n    while (!EMPTY_ENTRY(entry)) {\n        if (entry->e.x == x && entry->e.y == y && entry->e.z == z) {\n            overwrite = 1;\n            break;\n        }\n        index = (index + 1) & map->mask;\n        entry = map->data + index;\n    }\n    if (overwrite) {\n        if (entry->e.w != w) {\n            entry->e.w = w;\n            return 1;\n        }\n    }\n    else if (w) {\n        entry->e.x = x;\n        entry->e.y = y;\n        entry->e.z = z;\n        entry->e.w = w;\n        map->size++;\n        if (map->size * 2 > map->mask) {\n            map_grow(map);\n        }\n        return 1;\n    }\n    return 0;\n}\n\nint map_get(Map *map, int x, int y, int z) {\n    unsigned int index = hash(x, y, z) & map->mask;\n    x -= map->dx;\n    y -= map->dy;\n    z -= map->dz;\n    if (x < 0 || x > 255) return 0;\n    if (y < 0 || y > 255) return 0;\n    if (z < 0 || z > 255) return 0;\n    MapEntry *entry = map->data + index;\n    while (!EMPTY_ENTRY(entry)) {\n        if (entry->e.x == x && entry->e.y == y && entry->e.z == z) {\n            return entry->e.w;\n        }\n        index = (index + 1) & map->mask;\n        entry = map->data + index;\n    }\n    return 0;\n}\n\nvoid map_grow(Map *map) {\n    Map new_map;\n    new_map.dx = map->dx;\n    new_map.dy = map->dy;\n    new_map.dz = map->dz;\n    new_map.mask = (map->mask << 1) | 1;\n    new_map.size = 0;\n    new_map.data = (MapEntry *)calloc(new_map.mask + 1, sizeof(MapEntry));\n    MAP_FOR_EACH(map, ex, ey, ez, ew) {\n        map_set(&new_map, ex, ey, ez, ew);\n    } END_MAP_FOR_EACH;\n    free(map->data);\n    map->mask = new_map.mask;\n    map->size = new_map.size;\n    map->data = new_map.data;\n}\n"
  },
  {
    "path": "src/map.h",
    "content": "#ifndef _map_h_\n#define _map_h_\n\n#define EMPTY_ENTRY(entry) ((entry)->value == 0)\n\n#define MAP_FOR_EACH(map, ex, ey, ez, ew) \\\n    for (unsigned int i = 0; i <= map->mask; i++) { \\\n        MapEntry *entry = map->data + i; \\\n        if (EMPTY_ENTRY(entry)) { \\\n            continue; \\\n        } \\\n        int ex = entry->e.x + map->dx; \\\n        int ey = entry->e.y + map->dy; \\\n        int ez = entry->e.z + map->dz; \\\n        int ew = entry->e.w;\n\n#define END_MAP_FOR_EACH }\n\ntypedef union {\n    unsigned int value;\n    struct {\n        unsigned char x;\n        unsigned char y;\n        unsigned char z;\n        char w;\n    } e;\n} MapEntry;\n\ntypedef struct {\n    int dx;\n    int dy;\n    int dz;\n    unsigned int mask;\n    unsigned int size;\n    MapEntry *data;\n} Map;\n\nvoid map_alloc(Map *map, int dx, int dy, int dz, int mask);\nvoid map_free(Map *map);\nvoid map_copy(Map *dst, Map *src);\nvoid map_grow(Map *map);\nint map_set(Map *map, int x, int y, int z, int w);\nint map_get(Map *map, int x, int y, int z);\n\n#endif\n"
  },
  {
    "path": "src/matrix.c",
    "content": "#include <math.h>\n#include \"config.h\"\n#include \"matrix.h\"\n#include \"util.h\"\n\nvoid normalize(float *x, float *y, float *z) {\n    float d = sqrtf((*x) * (*x) + (*y) * (*y) + (*z) * (*z));\n    *x /= d; *y /= d; *z /= d;\n}\n\nvoid mat_identity(float *matrix) {\n    matrix[0] = 1;\n    matrix[1] = 0;\n    matrix[2] = 0;\n    matrix[3] = 0;\n    matrix[4] = 0;\n    matrix[5] = 1;\n    matrix[6] = 0;\n    matrix[7] = 0;\n    matrix[8] = 0;\n    matrix[9] = 0;\n    matrix[10] = 1;\n    matrix[11] = 0;\n    matrix[12] = 0;\n    matrix[13] = 0;\n    matrix[14] = 0;\n    matrix[15] = 1;\n}\n\nvoid mat_translate(float *matrix, float dx, float dy, float dz) {\n    matrix[0] = 1;\n    matrix[1] = 0;\n    matrix[2] = 0;\n    matrix[3] = 0;\n    matrix[4] = 0;\n    matrix[5] = 1;\n    matrix[6] = 0;\n    matrix[7] = 0;\n    matrix[8] = 0;\n    matrix[9] = 0;\n    matrix[10] = 1;\n    matrix[11] = 0;\n    matrix[12] = dx;\n    matrix[13] = dy;\n    matrix[14] = dz;\n    matrix[15] = 1;\n}\n\nvoid mat_rotate(float *matrix, float x, float y, float z, float angle) {\n    normalize(&x, &y, &z);\n    float s = sinf(angle);\n    float c = cosf(angle);\n    float m = 1 - c;\n    matrix[0] = m * x * x + c;\n    matrix[1] = m * x * y - z * s;\n    matrix[2] = m * z * x + y * s;\n    matrix[3] = 0;\n    matrix[4] = m * x * y + z * s;\n    matrix[5] = m * y * y + c;\n    matrix[6] = m * y * z - x * s;\n    matrix[7] = 0;\n    matrix[8] = m * z * x - y * s;\n    matrix[9] = m * y * z + x * s;\n    matrix[10] = m * z * z + c;\n    matrix[11] = 0;\n    matrix[12] = 0;\n    matrix[13] = 0;\n    matrix[14] = 0;\n    matrix[15] = 1;\n}\n\nvoid mat_vec_multiply(float *vector, float *a, float *b) {\n    float result[4];\n    for (int i = 0; i < 4; i++) {\n        float total = 0;\n        for (int j = 0; j < 4; j++) {\n            int p = j * 4 + i;\n            int q = j;\n            total += a[p] * b[q];\n        }\n        result[i] = total;\n    }\n    for (int i = 0; i < 4; i++) {\n        vector[i] = result[i];\n    }\n}\n\nvoid mat_multiply(float *matrix, float *a, float *b) {\n    float result[16];\n    for (int c = 0; c < 4; c++) {\n        for (int r = 0; r < 4; r++) {\n            int index = c * 4 + r;\n            float total = 0;\n            for (int i = 0; i < 4; i++) {\n                int p = i * 4 + r;\n                int q = c * 4 + i;\n                total += a[p] * b[q];\n            }\n            result[index] = total;\n        }\n    }\n    for (int i = 0; i < 16; i++) {\n        matrix[i] = result[i];\n    }\n}\n\nvoid mat_apply(float *data, float *matrix, int count, int offset, int stride) {\n    float vec[4] = {0, 0, 0, 1};\n    for (int i = 0; i < count; i++) {\n        float *d = data + offset + stride * i;\n        vec[0] = *(d++); vec[1] = *(d++); vec[2] = *(d++);\n        mat_vec_multiply(vec, matrix, vec);\n        d = data + offset + stride * i;\n        *(d++) = vec[0]; *(d++) = vec[1]; *(d++) = vec[2];\n    }\n}\n\nvoid frustum_planes(float planes[6][4], int radius, float *matrix) {\n    float znear = 0.125;\n    float zfar = radius * 32 + 64;\n    float *m = matrix;\n    planes[0][0] = m[3] + m[0];\n    planes[0][1] = m[7] + m[4];\n    planes[0][2] = m[11] + m[8];\n    planes[0][3] = m[15] + m[12];\n    planes[1][0] = m[3] - m[0];\n    planes[1][1] = m[7] - m[4];\n    planes[1][2] = m[11] - m[8];\n    planes[1][3] = m[15] - m[12];\n    planes[2][0] = m[3] + m[1];\n    planes[2][1] = m[7] + m[5];\n    planes[2][2] = m[11] + m[9];\n    planes[2][3] = m[15] + m[13];\n    planes[3][0] = m[3] - m[1];\n    planes[3][1] = m[7] - m[5];\n    planes[3][2] = m[11] - m[9];\n    planes[3][3] = m[15] - m[13];\n    planes[4][0] = znear * m[3] + m[2];\n    planes[4][1] = znear * m[7] + m[6];\n    planes[4][2] = znear * m[11] + m[10];\n    planes[4][3] = znear * m[15] + m[14];\n    planes[5][0] = zfar * m[3] - m[2];\n    planes[5][1] = zfar * m[7] - m[6];\n    planes[5][2] = zfar * m[11] - m[10];\n    planes[5][3] = zfar * m[15] - m[14];\n}\n\nvoid mat_frustum(\n    float *matrix, float left, float right, float bottom,\n    float top, float znear, float zfar)\n{\n    float temp, temp2, temp3, temp4;\n    temp = 2.0 * znear;\n    temp2 = right - left;\n    temp3 = top - bottom;\n    temp4 = zfar - znear;\n    matrix[0] = temp / temp2;\n    matrix[1] = 0.0;\n    matrix[2] = 0.0;\n    matrix[3] = 0.0;\n    matrix[4] = 0.0;\n    matrix[5] = temp / temp3;\n    matrix[6] = 0.0;\n    matrix[7] = 0.0;\n    matrix[8] = (right + left) / temp2;\n    matrix[9] = (top + bottom) / temp3;\n    matrix[10] = (-zfar - znear) / temp4;\n    matrix[11] = -1.0;\n    matrix[12] = 0.0;\n    matrix[13] = 0.0;\n    matrix[14] = (-temp * zfar) / temp4;\n    matrix[15] = 0.0;\n}\n\nvoid mat_perspective(\n    float *matrix, float fov, float aspect,\n    float znear, float zfar)\n{\n    float ymax, xmax;\n    ymax = znear * tanf(fov * PI / 360.0);\n    xmax = ymax * aspect;\n    mat_frustum(matrix, -xmax, xmax, -ymax, ymax, znear, zfar);\n}\n\nvoid mat_ortho(\n    float *matrix,\n    float left, float right, float bottom, float top, float near, float far)\n{\n    matrix[0] = 2 / (right - left);\n    matrix[1] = 0;\n    matrix[2] = 0;\n    matrix[3] = 0;\n    matrix[4] = 0;\n    matrix[5] = 2 / (top - bottom);\n    matrix[6] = 0;\n    matrix[7] = 0;\n    matrix[8] = 0;\n    matrix[9] = 0;\n    matrix[10] = -2 / (far - near);\n    matrix[11] = 0;\n    matrix[12] = -(right + left) / (right - left);\n    matrix[13] = -(top + bottom) / (top - bottom);\n    matrix[14] = -(far + near) / (far - near);\n    matrix[15] = 1;\n}\n\nvoid set_matrix_2d(float *matrix, int width, int height) {\n    mat_ortho(matrix, 0, width, 0, height, -1, 1);\n}\n\nvoid set_matrix_3d(\n    float *matrix, int width, int height,\n    float x, float y, float z, float rx, float ry,\n    float fov, int ortho, int radius)\n{\n    float a[16];\n    float b[16];\n    float aspect = (float)width / height;\n    float znear = 0.125;\n    float zfar = radius * 32 + 64;\n    mat_identity(a);\n    mat_translate(b, -x, -y, -z);\n    mat_multiply(a, b, a);\n    mat_rotate(b, cosf(rx), 0, sinf(rx), ry);\n    mat_multiply(a, b, a);\n    mat_rotate(b, 0, 1, 0, -rx);\n    mat_multiply(a, b, a);\n    if (ortho) {\n        int size = ortho;\n        mat_ortho(b, -size * aspect, size * aspect, -size, size, -zfar, zfar);\n    }\n    else {\n        mat_perspective(b, fov, aspect, znear, zfar);\n    }\n    mat_multiply(a, b, a);\n    mat_identity(matrix);\n    mat_multiply(matrix, a, matrix);\n}\n\nvoid set_matrix_item(float *matrix, int width, int height, int scale) {\n    float a[16];\n    float b[16];\n    float aspect = (float)width / height;\n    float size = 64 * scale;\n    float box = height / size / 2;\n    float xoffset = 1 - size / width * 2;\n    float yoffset = 1 - size / height * 2;\n    mat_identity(a);\n    mat_rotate(b, 0, 1, 0, -PI / 4);\n    mat_multiply(a, b, a);\n    mat_rotate(b, 1, 0, 0, -PI / 10);\n    mat_multiply(a, b, a);\n    mat_ortho(b, -box * aspect, box * aspect, -box, box, -1, 1);\n    mat_multiply(a, b, a);\n    mat_translate(b, -xoffset, -yoffset, 0);\n    mat_multiply(a, b, a);\n    mat_identity(matrix);\n    mat_multiply(matrix, a, matrix);\n}\n"
  },
  {
    "path": "src/matrix.h",
    "content": "#ifndef _matrix_h_\n#define _matrix_h_\n\nvoid normalize(float *x, float *y, float *z);\nvoid mat_identity(float *matrix);\nvoid mat_translate(float *matrix, float dx, float dy, float dz);\nvoid mat_rotate(float *matrix, float x, float y, float z, float angle);\nvoid mat_vec_multiply(float *vector, float *a, float *b);\nvoid mat_multiply(float *matrix, float *a, float *b);\nvoid mat_apply(float *data, float *matrix, int count, int offset, int stride);\nvoid frustum_planes(float planes[6][4], int radius, float *matrix);\nvoid mat_frustum(\n    float *matrix, float left, float right, float bottom,\n    float top, float znear, float zfar);\nvoid mat_perspective(\n    float *matrix, float fov, float aspect,\n    float near, float far);\nvoid mat_ortho(\n    float *matrix,\n    float left, float right, float bottom, float top, float near, float far);\nvoid set_matrix_2d(float *matrix, int width, int height);\nvoid set_matrix_3d(\n    float *matrix, int width, int height,\n    float x, float y, float z, float rx, float ry,\n    float fov, int ortho, int radius);\nvoid set_matrix_item(float *matrix, int width, int height, int scale);\n\n#endif\n"
  },
  {
    "path": "src/ring.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include \"ring.h\"\n\nvoid ring_alloc(Ring *ring, int capacity) {\n    ring->capacity = capacity;\n    ring->start = 0;\n    ring->end = 0;\n    ring->data = (RingEntry *)calloc(capacity, sizeof(RingEntry));\n}\n\nvoid ring_free(Ring *ring) {\n    free(ring->data);\n}\n\nint ring_empty(Ring *ring) {\n    return ring->start == ring->end;\n}\n\nint ring_full(Ring *ring) {\n    return ring->start == (ring->end + 1) % ring->capacity;\n}\n\nint ring_size(Ring *ring) {\n    if (ring->end >= ring->start) {\n        return ring->end - ring->start;\n    }\n    else {\n        return ring->capacity - (ring->start - ring->end);\n    }\n}\n\nvoid ring_grow(Ring *ring) {\n    Ring new_ring;\n    RingEntry entry;\n    ring_alloc(&new_ring, ring->capacity * 2);\n    while (ring_get(ring, &entry)) {\n        ring_put(&new_ring, &entry);\n    }\n    free(ring->data);\n    ring->capacity = new_ring.capacity;\n    ring->start = new_ring.start;\n    ring->end = new_ring.end;\n    ring->data = new_ring.data;\n}\n\nvoid ring_put(Ring *ring, RingEntry *entry) {\n    if (ring_full(ring)) {\n        ring_grow(ring);\n    }\n    RingEntry *e = ring->data + ring->end;\n    memcpy(e, entry, sizeof(RingEntry));\n    ring->end = (ring->end + 1) % ring->capacity;\n}\n\nvoid ring_put_block(Ring *ring, int p, int q, int x, int y, int z, int w) {\n    RingEntry entry;\n    entry.type = BLOCK;\n    entry.p = p;\n    entry.q = q;\n    entry.x = x;\n    entry.y = y;\n    entry.z = z;\n    entry.w = w;\n    ring_put(ring, &entry);\n}\n\nvoid ring_put_light(Ring *ring, int p, int q, int x, int y, int z, int w) {\n    RingEntry entry;\n    entry.type = LIGHT;\n    entry.p = p;\n    entry.q = q;\n    entry.x = x;\n    entry.y = y;\n    entry.z = z;\n    entry.w = w;\n    ring_put(ring, &entry);\n}\n\nvoid ring_put_key(Ring *ring, int p, int q, int key) {\n    RingEntry entry;\n    entry.type = KEY;\n    entry.p = p;\n    entry.q = q;\n    entry.key = key;\n    ring_put(ring, &entry);\n}\n\nvoid ring_put_commit(Ring *ring) {\n    RingEntry entry;\n    entry.type = COMMIT;\n    ring_put(ring, &entry);\n}\n\nvoid ring_put_exit(Ring *ring) {\n    RingEntry entry;\n    entry.type = EXIT;\n    ring_put(ring, &entry);\n}\n\nint ring_get(Ring *ring, RingEntry *entry) {\n    if (ring_empty(ring)) {\n        return 0;\n    }\n    RingEntry *e = ring->data + ring->start;\n    memcpy(entry, e, sizeof(RingEntry));\n    ring->start = (ring->start + 1) % ring->capacity;\n    return 1;\n}\n"
  },
  {
    "path": "src/ring.h",
    "content": "#ifndef _ring_h_\n#define _ring_h_\n\ntypedef enum {\n    BLOCK,\n    LIGHT,\n    KEY,\n    COMMIT,\n    EXIT\n} RingEntryType;\n\ntypedef struct {\n    RingEntryType type;\n    int p;\n    int q;\n    int x;\n    int y;\n    int z;\n    int w;\n    int key;\n} RingEntry;\n\ntypedef struct {\n    unsigned int capacity;\n    unsigned int start;\n    unsigned int end;\n    RingEntry *data;\n} Ring;\n\nvoid ring_alloc(Ring *ring, int capacity);\nvoid ring_free(Ring *ring);\nint ring_empty(Ring *ring);\nint ring_full(Ring *ring);\nint ring_size(Ring *ring);\nvoid ring_grow(Ring *ring);\nvoid ring_put(Ring *ring, RingEntry *entry);\nvoid ring_put_block(Ring *ring, int p, int q, int x, int y, int z, int w);\nvoid ring_put_light(Ring *ring, int p, int q, int x, int y, int z, int w);\nvoid ring_put_key(Ring *ring, int p, int q, int key);\nvoid ring_put_commit(Ring *ring);\nvoid ring_put_exit(Ring *ring);\nint ring_get(Ring *ring, RingEntry *entry);\n\n#endif\n"
  },
  {
    "path": "src/sign.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n#include \"sign.h\"\n\nvoid sign_list_alloc(SignList *list, int capacity) {\n    list->capacity = capacity;\n    list->size = 0;\n    list->data = (Sign *)calloc(capacity, sizeof(Sign));\n}\n\nvoid sign_list_free(SignList *list) {\n    free(list->data);\n}\n\nvoid sign_list_grow(SignList *list) {\n    SignList new_list;\n    sign_list_alloc(&new_list, list->capacity * 2);\n    memcpy(new_list.data, list->data, list->size * sizeof(Sign));\n    free(list->data);\n    list->capacity = new_list.capacity;\n    list->data = new_list.data;\n}\n\nvoid _sign_list_add(SignList *list, Sign *sign) {\n    if (list->size == list->capacity) {\n        sign_list_grow(list);\n    }\n    Sign *e = list->data + list->size++;\n    memcpy(e, sign, sizeof(Sign));\n}\n\nvoid sign_list_add(\n    SignList *list, int x, int y, int z, int face, const char *text)\n{\n    sign_list_remove(list, x, y, z, face);\n    Sign sign;\n    sign.x = x;\n    sign.y = y;\n    sign.z = z;\n    sign.face = face;\n    strncpy(sign.text, text, MAX_SIGN_LENGTH);\n    sign.text[MAX_SIGN_LENGTH - 1] = '\\0';\n    _sign_list_add(list, &sign);\n}\n\nint sign_list_remove(SignList *list, int x, int y, int z, int face) {\n    int result = 0;\n    for (int i = 0; i < list->size; i++) {\n        Sign *e = list->data + i;\n        if (e->x == x && e->y == y && e->z == z && e->face == face) {\n            Sign *other = list->data + (--list->size);\n            memcpy(e, other, sizeof(Sign));\n            i--;\n            result++;\n        }\n    }\n    return result;\n}\n\nint sign_list_remove_all(SignList *list, int x, int y, int z) {\n    int result = 0;\n    for (int i = 0; i < list->size; i++) {\n        Sign *e = list->data + i;\n        if (e->x == x && e->y == y && e->z == z) {\n            Sign *other = list->data + (--list->size);\n            memcpy(e, other, sizeof(Sign));\n            i--;\n            result++;\n        }\n    }\n    return result;\n}\n"
  },
  {
    "path": "src/sign.h",
    "content": "#ifndef _sign_h_\n#define _sign_h_\n\n#define MAX_SIGN_LENGTH 64\n\ntypedef struct {\n    int x;\n    int y;\n    int z;\n    int face;\n    char text[MAX_SIGN_LENGTH];\n} Sign;\n\ntypedef struct {\n    unsigned int capacity;\n    unsigned int size;\n    Sign *data;\n} SignList;\n\nvoid sign_list_alloc(SignList *list, int capacity);\nvoid sign_list_free(SignList *list);\nvoid sign_list_grow(SignList *list);\nvoid sign_list_add(\n    SignList *list, int x, int y, int z, int face, const char *text);\nint sign_list_remove(SignList *list, int x, int y, int z, int face);\nint sign_list_remove_all(SignList *list, int x, int y, int z);\n\n#endif\n"
  },
  {
    "path": "src/util.c",
    "content": "#include <math.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include \"lodepng.h\"\n#include \"matrix.h\"\n#include \"util.h\"\n\nint rand_int(int n) {\n    int result;\n    while (n <= (result = rand() / (RAND_MAX / n)));\n    return result;\n}\n\ndouble rand_double() {\n    return (double)rand() / (double)RAND_MAX;\n}\n\nvoid update_fps(FPS *fps) {\n    fps->frames++;\n    double now = glfwGetTime();\n    double elapsed = now - fps->since;\n    if (elapsed >= 1) {\n        fps->fps = round(fps->frames / elapsed);\n        fps->frames = 0;\n        fps->since = now;\n    }\n}\n\nchar *load_file(const char *path) {\n    FILE *file = fopen(path, \"rb\");\n    if (!file) {\n        fprintf(stderr, \"fopen %s failed: %d %s\\n\", path, errno, strerror(errno));\n        exit(1);\n    }\n    fseek(file, 0, SEEK_END);\n    int length = ftell(file);\n    rewind(file);\n    char *data = calloc(length + 1, sizeof(char));\n    fread(data, 1, length, file);\n    fclose(file);\n    return data;\n}\n\nGLuint gen_buffer(GLsizei size, GLfloat *data) {\n    GLuint buffer;\n    glGenBuffers(1, &buffer);\n    glBindBuffer(GL_ARRAY_BUFFER, buffer);\n    glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);\n    glBindBuffer(GL_ARRAY_BUFFER, 0);\n    return buffer;\n}\n\nvoid del_buffer(GLuint buffer) {\n    glDeleteBuffers(1, &buffer);\n}\n\nGLfloat *malloc_faces(int components, int faces) {\n    return malloc(sizeof(GLfloat) * 6 * components * faces);\n}\n\nGLuint gen_faces(int components, int faces, GLfloat *data) {\n    GLuint buffer = gen_buffer(\n        sizeof(GLfloat) * 6 * components * faces, data);\n    free(data);\n    return buffer;\n}\n\nGLuint make_shader(GLenum type, const char *source) {\n    GLuint shader = glCreateShader(type);\n    glShaderSource(shader, 1, &source, NULL);\n    glCompileShader(shader);\n    GLint status;\n    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);\n    if (status == GL_FALSE) {\n        GLint length;\n        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);\n        GLchar *info = calloc(length, sizeof(GLchar));\n        glGetShaderInfoLog(shader, length, NULL, info);\n        fprintf(stderr, \"glCompileShader failed:\\n%s\\n\", info);\n        free(info);\n    }\n    return shader;\n}\n\nGLuint load_shader(GLenum type, const char *path) {\n    char *data = load_file(path);\n    GLuint result = make_shader(type, data);\n    free(data);\n    return result;\n}\n\nGLuint make_program(GLuint shader1, GLuint shader2) {\n    GLuint program = glCreateProgram();\n    glAttachShader(program, shader1);\n    glAttachShader(program, shader2);\n    glLinkProgram(program);\n    GLint status;\n    glGetProgramiv(program, GL_LINK_STATUS, &status);\n    if (status == GL_FALSE) {\n        GLint length;\n        glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);\n        GLchar *info = calloc(length, sizeof(GLchar));\n        glGetProgramInfoLog(program, length, NULL, info);\n        fprintf(stderr, \"glLinkProgram failed: %s\\n\", info);\n        free(info);\n    }\n    glDetachShader(program, shader1);\n    glDetachShader(program, shader2);\n    glDeleteShader(shader1);\n    glDeleteShader(shader2);\n    return program;\n}\n\nGLuint load_program(const char *path1, const char *path2) {\n    GLuint shader1 = load_shader(GL_VERTEX_SHADER, path1);\n    GLuint shader2 = load_shader(GL_FRAGMENT_SHADER, path2);\n    GLuint program = make_program(shader1, shader2);\n    return program;\n}\n\nvoid flip_image_vertical(\n    unsigned char *data, unsigned int width, unsigned int height)\n{\n    unsigned int size = width * height * 4;\n    unsigned int stride = sizeof(char) * width * 4;\n    unsigned char *new_data = malloc(sizeof(unsigned char) * size);\n    for (unsigned int i = 0; i < height; i++) {\n        unsigned int j = height - i - 1;\n        memcpy(new_data + j * stride, data + i * stride, stride);\n    }\n    memcpy(data, new_data, size);\n    free(new_data);\n}\n\nvoid load_png_texture(const char *file_name) {\n    unsigned int error;\n    unsigned char *data;\n    unsigned int width, height;\n    error = lodepng_decode32_file(&data, &width, &height, file_name);\n    if (error) {\n        fprintf(stderr, \"load_png_texture %s failed, error %u: %s\\n\", file_name, error, lodepng_error_text(error));\n        exit(1);\n    }\n    flip_image_vertical(data, width, height);\n    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,\n        GL_UNSIGNED_BYTE, data);\n    free(data);\n}\n\nchar *tokenize(char *str, const char *delim, char **key) {\n    char *result;\n    if (str == NULL) {\n        str = *key;\n    }\n    str += strspn(str, delim);\n    if (*str == '\\0') {\n        return NULL;\n    }\n    result = str;\n    str += strcspn(str, delim);\n    if (*str) {\n        *str++ = '\\0';\n    }\n    *key = str;\n    return result;\n}\n\nint char_width(char input) {\n    static const int lookup[128] = {\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n        4, 2, 4, 7, 6, 9, 7, 2, 3, 3, 4, 6, 3, 5, 2, 7,\n        6, 3, 6, 6, 6, 6, 6, 6, 6, 6, 2, 3, 5, 6, 5, 7,\n        8, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 6, 5, 8, 8, 6,\n        6, 7, 6, 6, 6, 6, 8,10, 8, 6, 6, 3, 6, 3, 6, 6,\n        4, 7, 6, 6, 6, 6, 5, 6, 6, 2, 5, 5, 2, 9, 6, 6,\n        6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 4, 2, 5, 7, 0\n    };\n    return lookup[input];\n}\n\nint string_width(const char *input) {\n    int result = 0;\n    int length = strlen(input);\n    for (int i = 0; i < length; i++) {\n        result += char_width(input[i]);\n    }\n    return result;\n}\n\nint wrap(const char *input, int max_width, char *output, int max_length) {\n    *output = '\\0';\n    char *text = malloc(sizeof(char) * (strlen(input) + 1));\n    strcpy(text, input);\n    int space_width = char_width(' ');\n    int line_number = 0;\n    char *key1, *key2;\n    char *line = tokenize(text, \"\\r\\n\", &key1);\n    while (line) {\n        int line_width = 0;\n        char *token = tokenize(line, \" \", &key2);\n        while (token) {\n            int token_width = string_width(token);\n            if (line_width) {\n                if (line_width + token_width > max_width) {\n                    line_width = 0;\n                    line_number++;\n                    strncat(output, \"\\n\", max_length - strlen(output) - 1);\n                }\n                else {\n                    strncat(output, \" \", max_length - strlen(output) - 1);\n                }\n            }\n            strncat(output, token, max_length - strlen(output) - 1);\n            line_width += token_width + space_width;\n            token = tokenize(NULL, \" \", &key2);\n        }\n        line_number++;\n        strncat(output, \"\\n\", max_length - strlen(output) - 1);\n        line = tokenize(NULL, \"\\r\\n\", &key1);\n    }\n    free(text);\n    return line_number;\n}\n"
  },
  {
    "path": "src/util.h",
    "content": "#ifndef _util_h_\n#define _util_h_\n\n#include <GL/glew.h>\n#include <GLFW/glfw3.h>\n#include \"config.h\"\n\n#define PI 3.14159265359\n#define DEGREES(radians) ((radians) * 180 / PI)\n#define RADIANS(degrees) ((degrees) * PI / 180)\n#define ABS(x) ((x) < 0 ? (-(x)) : (x))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define SIGN(x) (((x) > 0) - ((x) < 0))\n\n#if DEBUG\n    #define LOG(...) printf(__VA_ARGS__)\n#else\n    #define LOG(...)\n#endif\n\ntypedef struct {\n    unsigned int fps;\n    unsigned int frames;\n    double since;\n} FPS;\n\nint rand_int(int n);\ndouble rand_double();\nvoid update_fps(FPS *fps);\n\nGLuint gen_buffer(GLsizei size, GLfloat *data);\nvoid del_buffer(GLuint buffer);\nGLfloat *malloc_faces(int components, int faces);\nGLuint gen_faces(int components, int faces, GLfloat *data);\nGLuint make_shader(GLenum type, const char *source);\nGLuint load_shader(GLenum type, const char *path);\nGLuint make_program(GLuint shader1, GLuint shader2);\nGLuint load_program(const char *path1, const char *path2);\nvoid load_png_texture(const char *file_name);\nchar *tokenize(char *str, const char *delim, char **key);\nint char_width(char input);\nint string_width(const char *input);\nint wrap(const char *input, int max_width, char *output, int max_length);\n\n#endif\n"
  },
  {
    "path": "src/world.c",
    "content": "#include \"config.h\"\n#include \"noise.h\"\n#include \"world.h\"\n\nvoid create_world(int p, int q, world_func func, void *arg) {\n    int pad = 1;\n    for (int dx = -pad; dx < CHUNK_SIZE + pad; dx++) {\n        for (int dz = -pad; dz < CHUNK_SIZE + pad; dz++) {\n            int flag = 1;\n            if (dx < 0 || dz < 0 || dx >= CHUNK_SIZE || dz >= CHUNK_SIZE) {\n                flag = -1;\n            }\n            int x = p * CHUNK_SIZE + dx;\n            int z = q * CHUNK_SIZE + dz;\n            float f = simplex2(x * 0.01, z * 0.01, 4, 0.5, 2);\n            float g = simplex2(-x * 0.01, -z * 0.01, 2, 0.9, 2);\n            int mh = g * 32 + 16;\n            int h = f * mh;\n            int w = 1;\n            int t = 12;\n            if (h <= t) {\n                h = t;\n                w = 2;\n            }\n            // sand and grass terrain\n            for (int y = 0; y < h; y++) {\n                func(x, y, z, w * flag, arg);\n            }\n            if (w == 1) {\n                if (SHOW_PLANTS) {\n                    // grass\n                    if (simplex2(-x * 0.1, z * 0.1, 4, 0.8, 2) > 0.6) {\n                        func(x, h, z, 17 * flag, arg);\n                    }\n                    // flowers\n                    if (simplex2(x * 0.05, -z * 0.05, 4, 0.8, 2) > 0.7) {\n                        int w = 18 + simplex2(x * 0.1, z * 0.1, 4, 0.8, 2) * 7;\n                        func(x, h, z, w * flag, arg);\n                    }\n                }\n                // trees\n                int ok = SHOW_TREES;\n                if (dx - 4 < 0 || dz - 4 < 0 ||\n                    dx + 4 >= CHUNK_SIZE || dz + 4 >= CHUNK_SIZE)\n                {\n                    ok = 0;\n                }\n                if (ok && simplex2(x, z, 6, 0.5, 2) > 0.84) {\n                    for (int y = h + 3; y < h + 8; y++) {\n                        for (int ox = -3; ox <= 3; ox++) {\n                            for (int oz = -3; oz <= 3; oz++) {\n                                int d = (ox * ox) + (oz * oz) +\n                                    (y - (h + 4)) * (y - (h + 4));\n                                if (d < 11) {\n                                    func(x + ox, y, z + oz, 15, arg);\n                                }\n                            }\n                        }\n                    }\n                    for (int y = h; y < h + 7; y++) {\n                        func(x, y, z, 5, arg);\n                    }\n                }\n            }\n            // clouds\n            if (SHOW_CLOUDS) {\n                for (int y = 64; y < 72; y++) {\n                    if (simplex3(\n                        x * 0.01, y * 0.1, z * 0.01, 8, 0.5, 2) > 0.75)\n                    {\n                        func(x, y, z, 16 * flag, arg);\n                    }\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/world.h",
    "content": "#ifndef _world_h_\n#define _world_h_\n\ntypedef void (*world_func)(int, int, int, int, void *);\n\nvoid create_world(int p, int q, world_func func, void *arg);\n\n#endif\n"
  },
  {
    "path": "world.py",
    "content": "# gcc -std=c99 -O3 -shared -o world \\\n#   -I src -I deps/noise deps/noise/noise.c src/world.c\n\nfrom ctypes import CDLL, CFUNCTYPE, c_float, c_int, c_void_p\nfrom collections import OrderedDict\n\ndll = CDLL('./world')\n\nWORLD_FUNC = CFUNCTYPE(None, c_int, c_int, c_int, c_int, c_void_p)\n\ndef dll_seed(x):\n    dll.seed(x)\n\ndef dll_create_world(p, q):\n    result = {}\n    def world_func(x, y, z, w, arg):\n        result[(x, y, z)] = w\n    dll.create_world(p, q, WORLD_FUNC(world_func), None)\n    return result\n\ndll.simplex2.restype = c_float\ndll.simplex2.argtypes = [c_float, c_float, c_int, c_float, c_float]\ndef dll_simplex2(x, y, octaves=1, persistence=0.5, lacunarity=2.0):\n    return dll.simplex2(x, y, octaves, persistence, lacunarity)\n\ndll.simplex3.restype = c_float\ndll.simplex3.argtypes = [c_float, c_float, c_float, c_int, c_float, c_float]\ndef dll_simplex3(x, y, z, octaves=1, persistence=0.5, lacunarity=2.0):\n    return dll.simplex3(x, y, z, octaves, persistence, lacunarity)\n\nclass World(object):\n    def __init__(self, seed=None, cache_size=64):\n        self.seed = seed\n        self.cache = OrderedDict()\n        self.cache_size = cache_size\n    def create_chunk(self, p, q):\n        if self.seed is not None:\n            dll_seed(self.seed)\n        return dll_create_world(p, q)\n    def get_chunk(self, p, q):\n        try:\n            chunk = self.cache.pop((p, q))\n        except KeyError:\n            chunk = self.create_chunk(p, q)\n        self.cache[(p, q)] = chunk\n        if len(self.cache) > self.cache_size:\n            self.cache.popitem(False)\n        return chunk\n"
  }
]